1 |
786 |
skrzyp |
#ifndef CYGONCE_PLF_IO_H
|
2 |
|
|
#define CYGONCE_PLF_IO_H
|
3 |
|
|
|
4 |
|
|
//=============================================================================
|
5 |
|
|
//
|
6 |
|
|
// plf_io.h
|
7 |
|
|
//
|
8 |
|
|
// Platform specific IO support
|
9 |
|
|
//
|
10 |
|
|
//=============================================================================
|
11 |
|
|
// ####ECOSGPLCOPYRIGHTBEGIN####
|
12 |
|
|
// -------------------------------------------
|
13 |
|
|
// This file is part of eCos, the Embedded Configurable Operating System.
|
14 |
|
|
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
|
15 |
|
|
//
|
16 |
|
|
// eCos is free software; you can redistribute it and/or modify it under
|
17 |
|
|
// the terms of the GNU General Public License as published by the Free
|
18 |
|
|
// Software Foundation; either version 2 or (at your option) any later
|
19 |
|
|
// version.
|
20 |
|
|
//
|
21 |
|
|
// eCos is distributed in the hope that it will be useful, but WITHOUT
|
22 |
|
|
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
23 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
24 |
|
|
// for more details.
|
25 |
|
|
//
|
26 |
|
|
// You should have received a copy of the GNU General Public License
|
27 |
|
|
// along with eCos; if not, write to the Free Software Foundation, Inc.,
|
28 |
|
|
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
29 |
|
|
//
|
30 |
|
|
// As a special exception, if other files instantiate templates or use
|
31 |
|
|
// macros or inline functions from this file, or you compile this file
|
32 |
|
|
// and link it with other works to produce a work based on this file,
|
33 |
|
|
// this file does not by itself cause the resulting work to be covered by
|
34 |
|
|
// the GNU General Public License. However the source code for this file
|
35 |
|
|
// must still be made available in accordance with section (3) of the GNU
|
36 |
|
|
// General Public License v2.
|
37 |
|
|
//
|
38 |
|
|
// This exception does not invalidate any other reasons why a work based
|
39 |
|
|
// on this file might be covered by the GNU General Public License.
|
40 |
|
|
// -------------------------------------------
|
41 |
|
|
// ####ECOSGPLCOPYRIGHTEND####
|
42 |
|
|
//=============================================================================
|
43 |
|
|
//#####DESCRIPTIONBEGIN####
|
44 |
|
|
//
|
45 |
|
|
// Author(s): dmoseley
|
46 |
|
|
// Contributors: dmoseley
|
47 |
|
|
// Date: 2000-08-11
|
48 |
|
|
// Purpose: ASB2303 platform IO support
|
49 |
|
|
// Description:
|
50 |
|
|
// Usage: #include <cyg/hal/plf_io.h>
|
51 |
|
|
//
|
52 |
|
|
//####DESCRIPTIONEND####
|
53 |
|
|
//
|
54 |
|
|
//=============================================================================
|
55 |
|
|
|
56 |
|
|
#include <pkgconf/hal.h>
|
57 |
|
|
|
58 |
|
|
#ifdef __ASSEMBLER__
|
59 |
|
|
#define HAL_REG_8(x) x
|
60 |
|
|
#define HAL_REG_16(x) x
|
61 |
|
|
#define HAL_REG_32(x) x
|
62 |
|
|
#else
|
63 |
|
|
#define HAL_REG_8(x) (volatile cyg_uint8*)(x)
|
64 |
|
|
#define HAL_REG_16(x) (volatile cyg_uint16*)(x)
|
65 |
|
|
#define HAL_REG_32(x) (volatile cyg_uint32*)(x)
|
66 |
|
|
#endif
|
67 |
|
|
|
68 |
|
|
//-----------------------------------------------------------------------------
|
69 |
|
|
|
70 |
|
|
/* ASB GPIO Registers */
|
71 |
|
|
#define HAL_GPIO_BASE 0xDB000000
|
72 |
|
|
|
73 |
|
|
#define HAL_GPIO_0_MODE_OFFSET 0x0000
|
74 |
|
|
#define HAL_GPIO_0_IN_OFFSET 0x0004
|
75 |
|
|
#define HAL_GPIO_0_OUT_OFFSET 0x0008
|
76 |
|
|
#define HAL_GPIO_1_MODE_OFFSET 0x0100
|
77 |
|
|
#define HAL_GPIO_1_IN_OFFSET 0x0104
|
78 |
|
|
#define HAL_GPIO_1_OUT_OFFSET 0x0108
|
79 |
|
|
#define HAL_GPIO_2_MODE_OFFSET 0x0200
|
80 |
|
|
#define HAL_GPIO_2_IN_OFFSET 0x0204
|
81 |
|
|
#define HAL_GPIO_2_OUT_OFFSET 0x0208
|
82 |
|
|
#define HAL_GPIO_3_MODE_OFFSET 0x0300
|
83 |
|
|
#define HAL_GPIO_3_IN_OFFSET 0x0304
|
84 |
|
|
#define HAL_GPIO_3_OUT_OFFSET 0x0308
|
85 |
|
|
#define HAL_GPIO_4_MODE_OFFSET 0x0400
|
86 |
|
|
#define HAL_GPIO_4_IN_OFFSET 0x0404
|
87 |
|
|
#define HAL_GPIO_4_OUT_OFFSET 0x0408
|
88 |
|
|
#define HAL_GPIO_5_MODE_OFFSET 0x0500
|
89 |
|
|
#define HAL_GPIO_5_IN_OFFSET 0x0504
|
90 |
|
|
#define HAL_GPIO_5_OUT_OFFSET 0x0508
|
91 |
|
|
|
92 |
|
|
#define HAL_GPIO_0_MODE HAL_REG_16 (HAL_GPIO_BASE + HAL_GPIO_0_MODE_OFFSET)
|
93 |
|
|
#define HAL_GPIO_0_IN HAL_REG_8 (HAL_GPIO_BASE + HAL_GPIO_0_IN_OFFSET)
|
94 |
|
|
#define HAL_GPIO_0_OUT HAL_REG_8 (HAL_GPIO_BASE + HAL_GPIO_0_OUT_OFFSET)
|
95 |
|
|
#define HAL_GPIO_1_MODE HAL_REG_16 (HAL_GPIO_BASE + HAL_GPIO_1_MODE_OFFSET)
|
96 |
|
|
#define HAL_GPIO_1_IN HAL_REG_8 (HAL_GPIO_BASE + HAL_GPIO_1_IN_OFFSET)
|
97 |
|
|
#define HAL_GPIO_1_OUT HAL_REG_8 (HAL_GPIO_BASE + HAL_GPIO_1_OUT_OFFSET)
|
98 |
|
|
#define HAL_GPIO_2_MODE HAL_REG_16 (HAL_GPIO_BASE + HAL_GPIO_2_MODE_OFFSET)
|
99 |
|
|
#define HAL_GPIO_2_IN HAL_REG_8 (HAL_GPIO_BASE + HAL_GPIO_2_IN_OFFSET)
|
100 |
|
|
#define HAL_GPIO_2_OUT HAL_REG_8 (HAL_GPIO_BASE + HAL_GPIO_2_OUT_OFFSET)
|
101 |
|
|
#define HAL_GPIO_3_MODE HAL_REG_16 (HAL_GPIO_BASE + HAL_GPIO_3_MODE_OFFSET)
|
102 |
|
|
#define HAL_GPIO_3_IN HAL_REG_8 (HAL_GPIO_BASE + HAL_GPIO_3_IN_OFFSET)
|
103 |
|
|
#define HAL_GPIO_3_OUT HAL_REG_8 (HAL_GPIO_BASE + HAL_GPIO_3_OUT_OFFSET)
|
104 |
|
|
#define HAL_GPIO_4_MODE HAL_REG_16 (HAL_GPIO_BASE + HAL_GPIO_4_MODE_OFFSET)
|
105 |
|
|
#define HAL_GPIO_4_IN HAL_REG_8 (HAL_GPIO_BASE + HAL_GPIO_4_IN_OFFSET)
|
106 |
|
|
#define HAL_GPIO_4_OUT HAL_REG_8 (HAL_GPIO_BASE + HAL_GPIO_4_OUT_OFFSET)
|
107 |
|
|
#define HAL_GPIO_5_MODE HAL_REG_16 (HAL_GPIO_BASE + HAL_GPIO_5_MODE_OFFSET)
|
108 |
|
|
#define HAL_GPIO_5_IN HAL_REG_8 (HAL_GPIO_BASE + HAL_GPIO_5_IN_OFFSET)
|
109 |
|
|
#define HAL_GPIO_5_OUT HAL_REG_8 (HAL_GPIO_BASE + HAL_GPIO_5_OUT_OFFSET)
|
110 |
|
|
|
111 |
|
|
//-----------------------------------------------------------------------------
|
112 |
|
|
#define HAL_LED_ADDRESS HAL_GPIO_0_OUT
|
113 |
|
|
#define HAL_GPIO_MODE_ALL_OUTPUT 0x5555
|
114 |
|
|
|
115 |
|
|
|
116 |
|
|
#ifdef __ASSEMBLER__
|
117 |
|
|
|
118 |
|
|
# include <cyg/hal/platform.inc>
|
119 |
|
|
# define DEBUG_DISPLAY(hexdig) hal_diag_led hexdig
|
120 |
|
|
# define DEBUG_DELAY() \
|
121 |
|
|
mov 0x20000, d0; \
|
122 |
|
|
0: sub 1, d0; \
|
123 |
|
|
bne 0b; \
|
124 |
|
|
nop
|
125 |
|
|
|
126 |
|
|
#else
|
127 |
|
|
|
128 |
|
|
extern cyg_uint8 led_val(CYG_WORD hexdig);
|
129 |
|
|
# define DEBUG_DISPLAY(hexdig) HAL_WRITE_UINT8(HAL_LED_ADDRESS, led_val(hexdig))
|
130 |
|
|
# define DEBUG_DELAY() \
|
131 |
|
|
{ \
|
132 |
|
|
volatile int i = 0x80000; \
|
133 |
|
|
while (--i) ; \
|
134 |
|
|
}
|
135 |
|
|
|
136 |
|
|
#endif
|
137 |
|
|
|
138 |
|
|
//-----------------------------------------------------------------------------
|
139 |
|
|
// end of plf_io.h
|
140 |
|
|
#endif // CYGONCE_PLF_IO_H
|