]> rtime.felk.cvut.cz Git - lincan.git/blob - embedded/board/arm/ul_usb1/defines/system_def-hisc-keypad.h
Merge master into can-usb1 branch to include proc update for 3.12+ kernels.
[lincan.git] / embedded / board / arm / ul_usb1 / defines / system_def-hisc-keypad.h
1 /*******************************************************************
2   Components for embedded applications builded for
3   laboratory and medical instruments firmware  
4  
5   system_def.h - common cover for definition of hardware adresses,
6                  registers, timing and other hardware dependant
7                  parts of embedded hardware
8  
9   Copyright (C) 2001 by Pavel Pisa pisa@cmp.felk.cvut.cz
10             (C) 2002 by PiKRON Ltd. http://www.pikron.com
11
12  *******************************************************************/
13
14 #ifndef _SYSTEM_DEF_H_
15 #define _SYSTEM_DEF_H_
16
17 #include <types.h>
18 #include <system_stub.h>
19 #include <LPC214x.h>
20 #include <bspbase.h>
21
22 #ifndef NULL
23 #define NULL    0
24 #endif
25
26 #define WITH_SFI_SEL
27
28 #define VER_CODE(major,minor,patch) (major*0x10000+minor*0x100+patch)
29 /* Software version */
30 #define SW_VER_ID       "UL_USB"
31 #define SW_VER_MAJOR    0
32 #define SW_VER_MINOR    2
33 #define SW_VER_PATCH    0
34 #define SW_VER_CODE     VER_CODE(SW_VER_MAJOR,SW_VER_MINOR,SW_VER_PATCH)
35 /* Hardware version */
36 #define HW_VER_ID       "UL_USB"
37 #define HW_VER_MAJOR    1
38 #define HW_VER_MINOR    0
39 #define HW_VER_PATCH    0
40 #define HW_VER_CODE     VER_CODE(HW_VER_MAJOR,HW_VER_MINOR,HW_VER_PATCH)
41 /* Version of mechanical  */
42 #define MECH_VER_ID     "UL_USB"
43 #define MECH_VER_MAJOR  0
44 #define MECH_VER_MINOR  0
45 #define MECH_VER_PATCH  0
46 #define MECH_VER_CODE   VER_CODE(MECH_VER_MAJOR,MECH_VER_MINOR,MECH_VER_PATCH)
47
48
49 // PLL setup values are computed within the LPC include file
50 // It relies upon the following defines
51 #define FOSC                (14745600)  // Master Oscillator Freq.
52 #define PLL_MUL             (4)         // PLL Multiplier
53 #define CCLK                (FOSC * PLL_MUL) // CPU Clock Freq.
54
55 // Pheripheral Bus Speed Divider
56 #define PBSD                1           // MUST BE 1, 2, or 4
57 #define PCLK                (CCLK / PBSD) // Pheripheal Bus Clock Freq.
58
59 #define SYS_TIMER_HZ        1000
60
61 #ifndef BIT
62 #define BIT(n)              (1 << (n))
63 #endif
64
65 // Port Bit Definitions & Macros:    Description - initial conditions
66 #define TXD0_BIT            BIT(0)      // used by UART0
67 #define RXD0_BIT            BIT(1)      // used by UART0
68 #define P0_02_UNUSED_BIT    BIT(2)      // P0.02 unused - low output
69 #define P0_03_UNUSED_BIT    BIT(3)      // P0.03 unused - low output
70 #define P0_04_UNUSED_BIT    BIT(4)      // P0.04 unused - low output
71 #define P0_05_UNUSED_BIT    BIT(5)      // P0.05 unused - low output
72 #define IP1_BIT             BIT(6)      // P0.06 unused - low output
73 #define IP2_BIT             BIT(7)      // P0.07 unused - low output
74 #define TXD1_BIT            BIT(8)      // used by UART1
75 #define RXD1_BIT            BIT(9)      // used by UART1
76 #define RTS1_BIT            BIT(10)     // used by UART1
77 #define CTS1_BIT            BIT(11)     // used by UART1
78 #define DSR1_BIT            BIT(12)     // used by UART1
79 #define P0_13_UNUSED_BIT    BIT(13)     // P0.13 unused - low output
80 #define BOOT_BIT            BIT(14)     // SWITCH
81 #define P0_15_UNUSED_BIT    BIT(15)     // P0.15 unused - low output
82 #define P0_16_UNUSED_BIT    BIT(16)     // P0.16 unused - low output
83 #define P0_17_UNUSED_BIT    BIT(17)     // P0.17 unused - low output
84 #define P0_18_UNUSED_BIT    BIT(18)     // P0.18 unused - low output
85 #define P0_19_UNUSED_BIT    BIT(19)     // P0.19 unused - low output
86 #define P0_20_UNUSED_BIT    BIT(20)     // P0.20 unused - low output
87 #define LED1_BIT            BIT(21)     // used by LED
88 #define LED2_BIT            BIT(22)     // used by LED
89 #define P0_23_UNUSED_BIT    BIT(23)     // P0.23 unused - low output
90 #define P0_24_UNUSED_BIT    BIT(24)     // P0.24 unused - low output
91 #define P0_25_UNUSED_BIT    BIT(25)     // P0.25 unused - low output
92 #define P0_26_UNUSED_BIT    BIT(26)     // P0.26 unused - low output
93 #define P0_27_UNUSED_BIT    BIT(27)     // P0.27 unused - low output
94 #define P0_28_UNUSED_BIT    BIT(28)     // P0.28 unused - low output
95 #define P0_29_SOUND         BIT(29)     // P0.29 unused - low output
96 #define P0_30_LED_R         BIT(30)     // P0.30 unused - low output
97 #define P0_31_LED_G         BIT(31)     // P0.31 unused - low output
98
99
100 #define P1_16_RELE          BIT(16)     // P1.16 unused - low output
101 #define P1_17_UNUSED_BIT    BIT(17)     // P1.17 unused - low output
102 #define P1_18_UNUSED_BIT    BIT(18)     // P1.18 unused - low output
103 #define P1_19_UNUSED_BIT    BIT(19)     // P1.19 unused - low output
104 #define P1_20_UNUSED_BIT    BIT(20)     // P1.20 unused - low output
105 #define P1_21_UNUSED_BIT    BIT(21)     // P1.21 unused - low output
106 #define P1_22_UNUSED_BIT    BIT(22)     // P1.22 unused - low output
107 #define P1_23_UNUSED_BIT    BIT(23)     // P1.23 unused - low output
108 #define P1_24_COL369H       BIT(24)     // P1.24 unused - low output
109 #define P1_25_COL2580       BIT(25)     // P1.25 unused - low output
110 #define P1_26_COL147S       BIT(26)     // used by JTAG
111 #define P1_27_ROW123        BIT(27)     // used by JTAG
112 #define P1_28_ROW456        BIT(28)     // used by JTAG
113 #define P1_29_ROW789        BIT(29)     // used by JTAG
114 #define P1_30_ROWS0H        BIT(30)     // used by JTAG
115 #define P1_31_RING          BIT(31)     // used by JTAG
116
117 #define P0IO_INPUT_BITS      (uint32_t) ( \
118                                          BOOT_BIT | \
119                                          IP1_BIT | \
120                                          IP2_BIT | \
121                                          0 )
122
123 #define P1IO_INPUT_BITS      (uint32_t) ( \
124                                          P1_27_ROW123 | \
125                                          P1_28_ROW456 | \
126                                          P1_29_ROW789 | \
127                                          P1_30_ROWS0H | \
128                                          P1_31_RING | \
129                                          0 )
130
131 #define P0IO_ZERO_BITS       (uint32_t) ( \
132                                          P0_02_UNUSED_BIT | \
133                                          P0_03_UNUSED_BIT | \
134                                          P0_04_UNUSED_BIT | \
135                                          P0_05_UNUSED_BIT | \
136                                          P0_13_UNUSED_BIT | \
137                                          P0_15_UNUSED_BIT | \
138                                          P0_16_UNUSED_BIT | \
139                                          P0_17_UNUSED_BIT | \
140                                          P0_18_UNUSED_BIT | \
141                                          P0_19_UNUSED_BIT | \
142                                          P0_20_UNUSED_BIT | \
143                                          P0_23_UNUSED_BIT | \
144                                          P0_24_UNUSED_BIT | \
145                                          P0_25_UNUSED_BIT | \
146                                          P0_26_UNUSED_BIT | \
147                                          P0_27_UNUSED_BIT | \
148                                          P0_28_UNUSED_BIT | \
149                                          P0_29_SOUND | \
150                                          0 )
151
152 #define P1IO_ZERO_BITS       (uint32_t) ( \
153                                          P1_16_RELE | \
154                                          P1_17_UNUSED_BIT | \
155                                          P1_18_UNUSED_BIT | \
156                                          P1_19_UNUSED_BIT | \
157                                          P1_20_UNUSED_BIT | \
158                                          P1_21_UNUSED_BIT | \
159                                          P1_22_UNUSED_BIT | \
160                                          P1_23_UNUSED_BIT | \
161                                          0 )
162
163
164 #define P0IO_ONE_BITS        (uint32_t) ( \
165                                          LED1_BIT | \
166                                          BOOT_BIT | \
167                                          LED2_BIT | \
168                                          P0_30_LED_R | \
169                                          P0_31_LED_G | \
170                                          0 )
171
172 #define P1IO_ONE_BITS        (uint32_t) ( \
173                                          P1_24_COL369H | \
174                                          P1_25_COL2580 | \
175                                          P1_26_COL147S | \
176                                          0 )
177
178 #define P0IO_OUTPUT_BITS     (uint32_t) ( \
179                                          P0IO_ZERO_BITS | \
180                                          P0IO_ONE_BITS )
181
182 #define P1IO_OUTPUT_BITS     (uint32_t) ( \
183                                          P1IO_ZERO_BITS | \
184                                          P1IO_ONE_BITS )
185
186
187 /***************************************************************************/
188 /* io functions */
189 #define LED_GP                  LED1_BIT  /* GENREAL PURPOSE LED */
190 #define LED_ERR                 LED2_BIT
191
192 #define LED_YELLOW              LED1_BIT
193 #define LED_RED                 LED2_BIT
194 #define LED_KEYPAD_RED          P0_30_LED_R
195 #define LED_KEYPAD_YELLOW       P0_31_LED_G
196
197 /***************************************************************************/
198 /* io functions */
199 #define KBD_PORT                IO1
200 #define IN_PORT                 IO0
201 #define LED_PORT                IO0
202 #define OUT_PORT                IO1
203
204 #define CREATE_PORT_NAME_PIN(port) port##PIN
205 #define CREATE_PORT_NAME_CLR(port) port##CLR
206 #define CREATE_PORT_NAME_SET(port) port##SET
207
208 #define GET_IN_PIN(port,in)     ((CREATE_PORT_NAME_PIN(port) & in)?1:0) 
209 #define SET_OUT_PIN(port,out)   (CREATE_PORT_NAME_SET(port)=out)
210 #define CLR_OUT_PIN(port,out)   (CREATE_PORT_NAME_CLR(port)=out)
211
212 /***************************************************************************/
213 /* watchdog */
214 #define WATCHDOG_ENABLED
215 #define WATCHDOG_TIMEOUT_MS     1000
216
217 /***************************************************************************/
218 /* uLan configuration */
219 #ifdef UL_LOG_ENABLE
220   #undef UL_LOG_ENABLE
221 #endif
222
223 #ifdef ULD_DEFAULT_BUFFER_SIZE
224   #undef ULD_DEFAULT_BUFFER_SIZE
225   #define ULD_DEFAULT_BUFFER_SIZE 0x0800
226 #endif
227
228 #define UL_DRV_SYSLESS_PORT 0xE0010000
229 #define UL_DRV_SYSLESS_BAUD 19200
230 #define UL_DRV_SYSLESS_IRQ HAL_INTERRUPT_UART1
231 #define UL_DRV_SYSLESS_MY_ADR_DEFAULT 1
232
233 #define watchdog_feed lpc_watchdog_feed
234 #define kvpb_erase lpcisp_kvpb_erase
235 #define kvpb_copy lpcisp_kvpb_copy
236 #define kvpb_flush lpcisp_kvpb_flush
237 #define KVPB_DEFAULT_FLAGS KVPB_DESC_DOUBLE|KVPB_DESC_CHUNKWO
238
239 #define HAL_ARM_LPC2XXX_EXTINT_ERRATA 
240
241 /***************************************************************************/
242 /* kbd */
243 #define KEY_TIMER sys_timer_ticks
244 #define KBDDEVICE void
245
246 typedef unsigned short kbd_key_t;
247 typedef unsigned int kbd_keymod_t;
248 typedef long kbd_interval_t;
249 typedef unsigned short kbd_scan_code_t;
250
251 #define KEY_DEFAULT_TIMES
252 #define KEY_PUSH_T      70
253 #define KEY_RELEASE_T   50
254 #define KEY_REPFIRST_T  60000
255 #define KEY_REPNEXT_T   300
256
257 #define KBD_DR _reg_PTD_DR
258 #define KBD_SSR IO1PIN
259 #define KBD_DDIR _reg_PTD_DDIR
260 #define KBD_PUEN _reg_PTD_PUEN
261
262 typedef unsigned long kbdisr_lock_level_t;
263 #define kbdisr_lock   save_and_cli
264 #define kbdisr_unlock restore_flags
265
266 #define KBD_SCAN_CNT  3
267 #define KBD_SCAN_BIT0 24
268 #define KBD_RET_CNT   5
269 #define KBD_RET_BIT0  27
270
271 #define KBD_SCAN_MASK (((1<<KBD_SCAN_CNT)-1)<<KBD_SCAN_BIT0)
272 #define KBD_RET_MASK  (((1<<KBD_RET_CNT)-1)<<KBD_RET_BIT0)
273
274 #define KBD_USE_IO_SETCLR_OPS
275
276 #endif /* _SYSTEM_DEF_H_ */