]> rtime.felk.cvut.cz Git - sysless.git/blob - board/arm/lpc17xx-common/defines/system_def-lmc1.h
LPC USB library modified to provide compatibility with LPC17xx.
[sysless.git] / board / arm / lpc17xx-common / defines / system_def-lmc1.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 <LPC17xx.h>
20 #include <bspbase.h>
21
22 #ifndef MACH_LPC17XX
23 #define MACH_LPC17XX
24 #endif
25
26 #ifndef NULL
27 #define NULL    0
28 #endif
29
30 #define VER_CODE(major,minor,patch) (major*0x10000+minor*0x100+patch)
31 /* Software version */
32 #define SW_VER_ID       "LMC1"
33 #define SW_VER_MAJOR    0
34 #define SW_VER_MINOR    1
35 #define SW_VER_PATCH    0
36 #define SW_VER_CODE     VER_CODE(SW_VER_MAJOR,SW_VER_MINOR,SW_VER_PATCH)
37 /* Hardware version */
38 #define HW_VER_ID       "LMC1"
39 #define HW_VER_MAJOR    1
40 #define HW_VER_MINOR    0
41 #define HW_VER_PATCH    0
42 #define HW_VER_CODE     VER_CODE(HW_VER_MAJOR,HW_VER_MINOR,HW_VER_PATCH)
43 /* Version of mechanical  */
44 #define MECH_VER_ID     "LMC1"
45 #define MECH_VER_MAJOR  0
46 #define MECH_VER_MINOR  0
47 #define MECH_VER_PATCH  0
48 #define MECH_VER_CODE   VER_CODE(MECH_VER_MAJOR,MECH_VER_MINOR,MECH_VER_PATCH)
49
50
51 /*--------------------- Clock Configuration ----------------------------------
52 //
53 // <e> Clock Configuration
54 //   <h> System Controls and Status Register (SCS)
55 //     <o1.4>    OSCRANGE: Main Oscillator Range Select
56 //                     <0=>  1 MHz to 20 MHz
57 //                     <1=> 15 MHz to 24 MHz
58 //     <e1.5>       OSCEN: Main Oscillator Enable
59 //     </e>
60 //   </h>
61 //
62 //   <h> Clock Source Select Register (CLKSRCSEL)
63 //     <o2.0..1>   CLKSRC: PLL Clock Source Selection
64 //                     <0=> Internal RC oscillator
65 //                     <1=> Main oscillator
66 //                     <2=> RTC oscillator
67 //   </h>
68 //
69 //   <e3> PLL0 Configuration (Main PLL)
70 //     <h> PLL0 Configuration Register (PLL0CFG)
71 //                     <i> F_cco0 = (2 * M * F_in) / N
72 //                     <i> F_in must be in the range of 32 kHz to 50 MHz
73 //                     <i> F_cco0 must be in the range of 275 MHz to 550 MHz
74 //       <o4.0..14>  MSEL: PLL Multiplier Selection
75 //                     <6-32768><#-1>
76 //                     <i> M Value
77 //       <o4.16..23> NSEL: PLL Divider Selection
78 //                     <1-256><#-1>
79 //                     <i> N Value
80 //     </h>
81 //   </e>
82 //
83 //   <e5> PLL1 Configuration (USB PLL)
84 //     <h> PLL1 Configuration Register (PLL1CFG)
85 //                     <i> F_usb = M * F_osc or F_usb = F_cco1 / (2 * P)
86 //                     <i> F_cco1 = F_osc * M * 2 * P
87 //                     <i> F_cco1 must be in the range of 156 MHz to 320 MHz
88 //       <o6.0..4>   MSEL: PLL Multiplier Selection
89 //                     <1-32><#-1>
90 //                     <i> M Value (for USB maximum value is 4)
91 //       <o6.5..6>   PSEL: PLL Divider Selection
92 //                     <0=> 1
93 //                     <1=> 2
94 //                     <2=> 4
95 //                     <3=> 8
96 //                     <i> P Value
97 //     </h>
98 //   </e>
99 //
100 //   <h> CPU Clock Configuration Register (CCLKCFG)
101 //     <o7.0..7>  CCLKSEL: Divide Value for CPU Clock from PLL0
102 //                     <2-256:2><#-1>
103 //   </h>
104 //
105 //   <h> USB Clock Configuration Register (USBCLKCFG)
106 //     <o8.0..3>   USBSEL: Divide Value for USB Clock from PLL1
107 //                     <0-15>
108 //                     <i> Divide is USBSEL + 1
109 //   </h>
110 //
111 //   <h> Peripheral Clock Selection Register 0 (PCLKSEL0)
112 //     <o9.0..1>    PCLK_WDT: Peripheral Clock Selection for WDT
113 //                     <0=> Pclk = Cclk / 4
114 //                     <1=> Pclk = Cclk
115 //                     <2=> Pclk = Cclk / 2
116 //                     <3=> Pclk = Hclk / 8
117 //     <o9.2..3>    PCLK_TIMER0: Peripheral Clock Selection for TIMER0
118 //                     <0=> Pclk = Cclk / 4
119 //                     <1=> Pclk = Cclk
120 //                     <2=> Pclk = Cclk / 2
121 //                     <3=> Pclk = Hclk / 8
122 //     <o9.4..5>    PCLK_TIMER1: Peripheral Clock Selection for TIMER1
123 //                     <0=> Pclk = Cclk / 4
124 //                     <1=> Pclk = Cclk
125 //                     <2=> Pclk = Cclk / 2
126 //                     <3=> Pclk = Hclk / 8
127 //     <o9.6..7>    PCLK_UART0: Peripheral Clock Selection for UART0
128 //                     <0=> Pclk = Cclk / 4
129 //                     <1=> Pclk = Cclk
130 //                     <2=> Pclk = Cclk / 2
131 //                     <3=> Pclk = Hclk / 8
132 //     <o9.8..9>    PCLK_UART1: Peripheral Clock Selection for UART1
133 //                     <0=> Pclk = Cclk / 4
134 //                     <1=> Pclk = Cclk
135 //                     <2=> Pclk = Cclk / 2
136 //                     <3=> Pclk = Hclk / 8
137 //     <o9.12..13>  PCLK_PWM1: Peripheral Clock Selection for PWM1
138 //                     <0=> Pclk = Cclk / 4
139 //                     <1=> Pclk = Cclk
140 //                     <2=> Pclk = Cclk / 2
141 //                     <3=> Pclk = Hclk / 8
142 //     <o9.14..15>  PCLK_I2C0: Peripheral Clock Selection for I2C0
143 //                     <0=> Pclk = Cclk / 4
144 //                     <1=> Pclk = Cclk
145 //                     <2=> Pclk = Cclk / 2
146 //                     <3=> Pclk = Hclk / 8
147 //     <o9.16..17>  PCLK_SPI: Peripheral Clock Selection for SPI
148 //                     <0=> Pclk = Cclk / 4
149 //                     <1=> Pclk = Cclk
150 //                     <2=> Pclk = Cclk / 2
151 //                     <3=> Pclk = Hclk / 8
152 //     <o9.20..21>  PCLK_SSP1: Peripheral Clock Selection for SSP1
153 //                     <0=> Pclk = Cclk / 4
154 //                     <1=> Pclk = Cclk
155 //                     <2=> Pclk = Cclk / 2
156 //                     <3=> Pclk = Hclk / 8
157 //     <o9.22..23>  PCLK_DAC: Peripheral Clock Selection for DAC
158 //                     <0=> Pclk = Cclk / 4
159 //                     <1=> Pclk = Cclk
160 //                     <2=> Pclk = Cclk / 2
161 //                     <3=> Pclk = Hclk / 8
162 //     <o9.24..25>  PCLK_ADC: Peripheral Clock Selection for ADC
163 //                     <0=> Pclk = Cclk / 4
164 //                     <1=> Pclk = Cclk
165 //                     <2=> Pclk = Cclk / 2
166 //                     <3=> Pclk = Hclk / 8
167 //     <o9.26..27>  PCLK_CAN1: Peripheral Clock Selection for CAN1
168 //                     <0=> Pclk = Cclk / 4
169 //                     <1=> Pclk = Cclk
170 //                     <2=> Pclk = Cclk / 2
171 //                     <3=> Pclk = Hclk / 6
172 //     <o9.28..29>  PCLK_CAN2: Peripheral Clock Selection for CAN2
173 //                     <0=> Pclk = Cclk / 4
174 //                     <1=> Pclk = Cclk
175 //                     <2=> Pclk = Cclk / 2
176 //                     <3=> Pclk = Hclk / 6
177 //     <o9.30..31>  PCLK_ACF: Peripheral Clock Selection for ACF
178 //                     <0=> Pclk = Cclk / 4
179 //                     <1=> Pclk = Cclk
180 //                     <2=> Pclk = Cclk / 2
181 //                     <3=> Pclk = Hclk / 6
182 //   </h>
183 //
184 //   <h> Peripheral Clock Selection Register 1 (PCLKSEL1)
185 //     <o10.0..1>   PCLK_QEI: Peripheral Clock Selection for the Quadrature Encoder Interface
186 //                     <0=> Pclk = Cclk / 4
187 //                     <1=> Pclk = Cclk
188 //                     <2=> Pclk = Cclk / 2
189 //                     <3=> Pclk = Hclk / 8
190 //     <o10.2..3>   PCLK_GPIO: Peripheral Clock Selection for GPIOs
191 //                     <0=> Pclk = Cclk / 4
192 //                     <1=> Pclk = Cclk
193 //                     <2=> Pclk = Cclk / 2
194 //                     <3=> Pclk = Hclk / 8
195 //     <o10.4..5>   PCLK_PCB: Peripheral Clock Selection for the Pin Connect Block
196 //                     <0=> Pclk = Cclk / 4
197 //                     <1=> Pclk = Cclk
198 //                     <2=> Pclk = Cclk / 2
199 //                     <3=> Pclk = Hclk / 8
200 //     <o10.6..7>   PCLK_I2C1: Peripheral Clock Selection for I2C1
201 //                     <0=> Pclk = Cclk / 4
202 //                     <1=> Pclk = Cclk
203 //                     <2=> Pclk = Cclk / 2
204 //                     <3=> Pclk = Hclk / 8
205 //     <o10.10..11> PCLK_SSP0: Peripheral Clock Selection for SSP0
206 //                     <0=> Pclk = Cclk / 4
207 //                     <1=> Pclk = Cclk
208 //                     <2=> Pclk = Cclk / 2
209 //                     <3=> Pclk = Hclk / 8
210 //     <o10.12..13> PCLK_TIMER2: Peripheral Clock Selection for TIMER2
211 //                     <0=> Pclk = Cclk / 4
212 //                     <1=> Pclk = Cclk
213 //                     <2=> Pclk = Cclk / 2
214 //                     <3=> Pclk = Hclk / 8
215 //     <o10.14..15> PCLK_TIMER3: Peripheral Clock Selection for TIMER3
216 //                     <0=> Pclk = Cclk / 4
217 //                     <1=> Pclk = Cclk
218 //                     <2=> Pclk = Cclk / 2
219 //                     <3=> Pclk = Hclk / 8
220 //     <o10.16..17> PCLK_UART2: Peripheral Clock Selection for UART2
221 //                     <0=> Pclk = Cclk / 4
222 //                     <1=> Pclk = Cclk
223 //                     <2=> Pclk = Cclk / 2
224 //                     <3=> Pclk = Hclk / 8
225 //     <o10.18..19> PCLK_UART3: Peripheral Clock Selection for UART3
226 //                     <0=> Pclk = Cclk / 4
227 //                     <1=> Pclk = Cclk
228 //                     <2=> Pclk = Cclk / 2
229 //                     <3=> Pclk = Hclk / 8
230 //     <o10.20..21> PCLK_I2C2: Peripheral Clock Selection for I2C2
231 //                     <0=> Pclk = Cclk / 4
232 //                     <1=> Pclk = Cclk
233 //                     <2=> Pclk = Cclk / 2
234 //                     <3=> Pclk = Hclk / 8
235 //     <o10.22..23> PCLK_I2S: Peripheral Clock Selection for I2S
236 //                     <0=> Pclk = Cclk / 4
237 //                     <1=> Pclk = Cclk
238 //                     <2=> Pclk = Cclk / 2
239 //                     <3=> Pclk = Hclk / 8
240 //     <o10.26..27> PCLK_RIT: Peripheral Clock Selection for the Repetitive Interrupt Timer
241 //                     <0=> Pclk = Cclk / 4
242 //                     <1=> Pclk = Cclk
243 //                     <2=> Pclk = Cclk / 2
244 //                     <3=> Pclk = Hclk / 8
245 //     <o10.28..29> PCLK_SYSCON: Peripheral Clock Selection for the System Control Block
246 //                     <0=> Pclk = Cclk / 4
247 //                     <1=> Pclk = Cclk
248 //                     <2=> Pclk = Cclk / 2
249 //                     <3=> Pclk = Hclk / 8
250 //     <o10.30..31> PCLK_MC: Peripheral Clock Selection for the Motor Control PWM
251 //                     <0=> Pclk = Cclk / 4
252 //                     <1=> Pclk = Cclk
253 //                     <2=> Pclk = Cclk / 2
254 //                     <3=> Pclk = Hclk / 8
255 //   </h>
256 //
257 //   <h> Power Control for Peripherals Register (PCONP)
258 //     <o11.1>      PCTIM0: Timer/Counter 0 power/clock enable
259 //     <o11.2>      PCTIM1: Timer/Counter 1 power/clock enable
260 //     <o11.3>      PCUART0: UART 0 power/clock enable
261 //     <o11.4>      PCUART1: UART 1 power/clock enable
262 //     <o11.6>      PCPWM1: PWM 1 power/clock enable
263 //     <o11.7>      PCI2C0: I2C interface 0 power/clock enable
264 //     <o11.8>      PCSPI: SPI interface power/clock enable
265 //     <o11.9>      PCRTC: RTC power/clock enable
266 //     <o11.10>     PCSSP1: SSP interface 1 power/clock enable
267 //     <o11.12>     PCAD: A/D converter power/clock enable
268 //     <o11.13>     PCCAN1: CAN controller 1 power/clock enable
269 //     <o11.14>     PCCAN2: CAN controller 2 power/clock enable
270 //     <o11.15>     PCGPIO: GPIOs power/clock enable
271 //     <o11.16>     PCRIT: Repetitive interrupt timer power/clock enable
272 //     <o11.17>     PCMC: Motor control PWM power/clock enable
273 //     <o11.18>     PCQEI: Quadrature encoder interface power/clock enable
274 //     <o11.19>     PCI2C1: I2C interface 1 power/clock enable
275 //     <o11.21>     PCSSP0: SSP interface 0 power/clock enable
276 //     <o11.22>     PCTIM2: Timer 2 power/clock enable
277 //     <o11.23>     PCTIM3: Timer 3 power/clock enable
278 //     <o11.24>     PCUART2: UART 2 power/clock enable
279 //     <o11.25>     PCUART3: UART 3 power/clock enable
280 //     <o11.26>     PCI2C2: I2C interface 2 power/clock enable
281 //     <o11.27>     PCI2S: I2S interface power/clock enable
282 //     <o11.29>     PCGPDMA: GP DMA function power/clock enable
283 //     <o11.30>     PCENET: Ethernet block power/clock enable
284 //     <o11.31>     PCUSB: USB interface power/clock enable
285 //   </h>
286 // </e>
287 */
288
289 #define CLOCK_SETUP           1
290
291 #define SCS_Val               0x00000020        /* OSCEN */
292 #define CLKSRCSEL_Val         0x00000001        /* XTAL */
293
294 #define PLL0_SETUP            1
295 #define PLL0CFG_Val           0x0000000B        /* 288000000Hz - must be in the range 275HMz-550MHz */
296
297 #define PLL1_SETUP            0
298 #define PLL1CFG_Val           0x00000023
299
300 #define CCLKCFG_Val           0x00000003        /* ppl0clk/(CCLKCFG_Val+1)=72000000Hz */
301 #define USBCLKCFG_Val         0x00000005        /* divide ppl0clk by 6 to 48MHz */
302
303 //#define PCLKSEL0_Val          0x00000000        /* all peripherial sysclk/4 */
304 //#define PCLKSEL1_Val          0x00000000
305 //#define PCONP_Val             0x042887DE
306
307 #define PCONP_CLK_DIV(x) ((x)==0?4:((x)==1?1:((x)==2?2:8)))
308
309 /*--------------------- Flash Accelerator Configuration ----------------------
310 //
311 // <e> Flash Accelerator Configuration
312 //   <o1.0..1>   FETCHCFG: Fetch Configuration
313 //               <0=> Instruction fetches from flash are not buffered
314 //               <1=> One buffer is used for all instruction fetch buffering
315 //               <2=> All buffers may be used for instruction fetch buffering
316 //               <3=> Reserved (do not use this setting)
317 //   <o1.2..3>   DATACFG: Data Configuration
318 //               <0=> Data accesses from flash are not buffered
319 //               <1=> One buffer is used for all data access buffering
320 //               <2=> All buffers may be used for data access buffering
321 //               <3=> Reserved (do not use this setting)
322 //   <o1.4>      ACCEL: Acceleration Enable
323 //   <o1.5>      PREFEN: Prefetch Enable
324 //   <o1.6>      PREFOVR: Prefetch Override
325 //   <o1.12..15> FLASHTIM: Flash Access Time
326 //               <0=> 1 CPU clock (for CPU clock up to 20 MHz)
327 //               <1=> 2 CPU clocks (for CPU clock up to 40 MHz)
328 //               <2=> 3 CPU clocks (for CPU clock up to 60 MHz)
329 //               <3=> 4 CPU clocks (for CPU clock up to 80 MHz)
330 //               <4=> 5 CPU clocks (for CPU clock up to 100 MHz)
331 //               <5=> 6 CPU clocks (for any CPU clock)
332 // </e>
333 */
334 #define FLASH_SETUP           1
335 #define FLASHCFG_Val          0x0000403A
336
337 /*----------------------------------------------------------------------------
338   Define clocks
339  *----------------------------------------------------------------------------*/
340 #define XTAL        (12000000UL)        /* Oscillator frequency               */
341 #define OSC_CLK     (      XTAL)        /* Main oscillator frequency          */
342 #define RTC_CLK     (   32000UL)        /* RTC oscillator frequency           */
343 #define IRC_OSC     ( 4000000UL)        /* Internal RC oscillator frequency   */
344
345 #define SYS_TIMER_HZ        1000
346
347 #ifndef BIT
348 #define BIT(n)              (1 << (n))
349 #endif
350
351 // Port Bit Definitions & Macros:    Description - initial conditions
352 #define CAN1_RX_BIT         BIT(0)      // CAN1 RX
353 #define CAN1_TX_BIT         BIT(1)      // CAN1 TX
354 #define TXD0_BIT            BIT(2)      // used by UART0
355 #define RXD0_BIT            BIT(3)      // used by UART0
356 #define CAN2_RX_BIT         BIT(4)      // CAN2 RX
357 #define CAN2_TX_BIT         BIT(5)      // CAN2 TX
358 #define LED2_BIT            BIT(6)      // active low/SSEL1
359 #define SCK1_BIT            BIT(7)      // clock SSP1 to gradient valves
360 #define MISO1_BIT           BIT(8)      // master input
361 #define MOSI1_BIT           BIT(9)      // master output
362 #define P0_10_UNUSED_BIT    BIT(10)     // P0.10 unused (SDA2/TXD2)
363 #define P0_11_UNUSED_BIT    BIT(11)     // P0.11 unused (SCL2/RXD2)
364 #define SCK0_BIT            BIT(15)     // clock SSP0 to display panel
365 #define SSEL0_BIT           BIT(16)     // slave select SSP0
366 #define MISO0_BIT           BIT(17)     // master input SSP0
367 #define MOSI0_BIT           BIT(18)     // master output SSP0
368 #define SDA1_BIT            BIT(19)     // I2C data - memory/connector
369 #define SCL1_BIT            BIT(20)     // I2C clock
370 #define SSP0_CS0_BIT        BIT(21)     // chip select SSP0 for display
371 #define SSP0_CS1_BIT        BIT(22)     // chip select SSP0/ A/D for display
372 #define ADC0_BIT            BIT(23)     // ADC motor current
373 #define ADC1_BIT            BIT(24)     // ADC motor current
374 #define ADC2_BIT            BIT(25)     // ADC motor current
375 #define ADC3_BIT            BIT(26)     // ADC motor current
376 #define P0_27_UNUSED_BIT    BIT(27)     // P0.27 unused
377 #define P0_28_UNUSED_BIT    BIT(28)     // P0.28 unused
378 #define USBDPLUS_BIT        BIT(29)     // P0.29 USBD+
379 #define USBDMINUS_BIT       BIT(30)     // P0.30 USBD-
380
381
382 // Port Bit Definitions & Macros:    Description - initial conditions
383
384 #define P1_ETH_BITS         (BIT(0)|BIT(1)|BIT(4)|BIT(8)|BIT(9)|\
385                              BIT(10)|BIT(14)|BIT(15)|BIT(16)|BIT(17))
386
387 #define P1_0_UNUSED_BIT     BIT(0)      // P1.0 unused - low output
388 #define P1_1_UNUSED_BIT     BIT(1)      // P1.1 unused - low output
389 #define P1_4_UNUSED_BIT     BIT(4)      // P1.4 unused - low output
390 #define P1_8_UNUSED_BIT     BIT(8)      // P1.8 unused - low output
391 #define P1_9_UNUSED_BIT     BIT(9)      // P1.9 unused - low output
392 #define P1_10_UNUSED_BIT    BIT(10)     // P1.10 unused - low output
393 #define P1_14_UNUSED_BIT    BIT(14)     // P1.14 unused - low output
394 #define P1_15_UNUSED_BIT    BIT(15)     // P1.15 unused - low output
395 #define PWM1_BIT            BIT(18)     // motor pwm 0 / ADC0
396 #define BLDC_HAL_A_BIT      BIT(19)     // motor HAL input A
397 #define IRC_A_BIT           BIT(20)     // motor IRC channel A (MCI0)
398 #define IRC_M_BIT           BIT(21)     // motor IRC channel mark (GPIO)
399 #define BLDC_HAL_B_BIT      BIT(22)     // motor HAL input B
400 #define IRC_B_BIT           BIT(23)     // motor IRC channel B (MCI1)
401 #define IRC_I_BIT           BIT(24)     // motor IRC index (MCI2)
402 #define BLDC_HAL_C_BIT      BIT(25)     // motor HAL input C
403 #define PWM1_EN_BIT         BIT(26)     // motor pwm 0 enable
404 #define PWM2_EN_BIT         BIT(27)     // motor pwm 1 enable
405 #define PWM4_EN_BIT         BIT(28)     // motor pwm 2 enable
406 #define PWM6_EN_BIT         BIT(29)     // motor pwm 3 enable
407 #define ADC4_BIT            BIT(30)     // ADC4 tensometer
408 #define ADC5_BIT            BIT(31)     // ADC5 external input
409
410 // Port Bit Definitions & Macros:    Description - initial conditions
411 #define TXD1_BIT            BIT(0)      // P2.0 TXD
412 #define RXD1_BIT            BIT(1)      // P2.1 RXD
413 #define CTS1_BIT            BIT(2)      // P2.2 CTS connected to RXD1
414 #define PWM4_BIT            BIT(3)      // P2.3 motor pwm 2 / ADC2
415 #define DSR1_BIT            BIT(4)      // P2.4 DSR connected to TXD1
416 #define PWM6_BIT            BIT(5)      // P2.5 motor pwm 3 / ADC3
417 #define LED1_BIT            BIT(6)      // P2.6 LED1 - error
418 #define RTS1_BIT            BIT(7)      // P2.7 RTS1 used as DIR1
419 #define AUX_OUT2_BIT        BIT(8)      // P2.8 auxual TLL port
420 #define USB_CONNECT_BIT     BIT(9)      // P2.9 USB output for soft connect
421 #define BOOT_BIT            BIT(10)     // P2.10 Boot input
422 #define AUX_IN2_BIT         BIT(11)     // P2.11 auxual TLL port
423 #define AUX_OUT4_BIT        BIT(12)     // P2.12 auxual TLL port
424 #define ETH_PD_IRQ_BIT      BIT(13)     // P2.13 power down/int
425
426 // Port Bit Definitions & Macros:    Description - initial conditions
427 #define PWM2_BIT            BIT(25)     // P3.25 motor pwm 1 / ADC1
428 #define AUX_OUT1_BIT        BIT(26)     // P3.26 auxual TLL port
429
430 // Port Bit Definitions & Macros:    Description - initial conditions
431 #define AUX_OUT3_BIT        BIT(28)     // P4.28 auxual TLL port / TXD3
432 #define AUX_IN1_BIT         BIT(29)     // P4.29 auxual TLL port / RXD3
433
434 #define P0IO_INPUT_BITS      (uint32_t) ( \
435                                          CAN1_RX_BIT | \
436                                          RXD0_BIT | \
437                                          CAN2_RX_BIT | \
438                                          MISO1_BIT | \
439                                          P0_10_UNUSED_BIT | \
440                                          P0_11_UNUSED_BIT | \
441                                          MISO0_BIT | \
442                                          SDA1_BIT | \
443                                          SCL1_BIT | \
444                                          ADC0_BIT | \
445                                          ADC1_BIT | \
446                                          ADC2_BIT | \
447                                          ADC3_BIT | \
448                                          USBDPLUS_BIT | \
449                                          USBDMINUS_BIT | \
450                                          0 )
451
452 #define P1IO_INPUT_BITS      (uint32_t) ( \
453                                          P1_ETH_BITS | \
454                                          BLDC_HAL_A_BIT | \
455                                          IRC_A_BIT | \
456                                          IRC_M_BIT | \
457                                          BLDC_HAL_B_BIT | \
458                                          IRC_B_BIT | \
459                                          IRC_I_BIT | \
460                                          BLDC_HAL_C_BIT | \
461                                          ADC4_BIT | \
462                                          ADC5_BIT | \
463                                          0 )
464
465 #define P2IO_INPUT_BITS      (uint32_t) ( \
466                                          RXD1_BIT | \
467                                          CTS1_BIT | \
468                                          DSR1_BIT | \
469                                          BOOT_BIT | \
470                                          AUX_IN2_BIT | \
471                                          ETH_PD_IRQ_BIT | \
472                                          0 )
473
474 #define P3IO_INPUT_BITS      (uint32_t) ( \
475                                          0 )
476
477 #define P4IO_INPUT_BITS      (uint32_t) ( \
478                                          AUX_IN1_BIT | \
479                                          0 )
480
481 #define P0IO_ZERO_BITS       (uint32_t) ( \
482                                          P0_27_UNUSED_BIT | \
483                                          P0_28_UNUSED_BIT | \
484                                          0 )
485
486 #define P1IO_ZERO_BITS       (uint32_t) ( \
487                                          PWM1_BIT | \
488                                          PWM1_EN_BIT | \
489                                          PWM2_EN_BIT | \
490                                          PWM4_EN_BIT | \
491                                          PWM6_EN_BIT | \
492                                          0 )
493
494 #define P2IO_ZERO_BITS       (uint32_t) ( \
495                                          PWM4_BIT | \
496                                          PWM6_BIT | \
497                                          0 )
498
499 #define P3IO_ZERO_BITS       (uint32_t) ( \
500                                          PWM2_BIT | \
501                                          0 )
502
503 #define P4IO_ZERO_BITS       (uint32_t) ( \
504                                          0 )
505
506 #define P0IO_ONE_BITS        (uint32_t) ( \
507                                          CAN1_TX_BIT | \
508                                          TXD0_BIT | \
509                                          CAN2_TX_BIT | \
510                                          LED2_BIT | \
511                                          SCK1_BIT | \
512                                          MOSI1_BIT | \
513                                          SCK0_BIT | \
514                                          SSEL0_BIT | \
515                                          MOSI0_BIT | \
516                                          SSP0_CS0_BIT | \
517                                          SSP0_CS1_BIT | \
518                                          0 )
519
520 #define P1IO_ONE_BITS        (uint32_t) ( \
521                                          0 )
522
523 #define P2IO_ONE_BITS        (uint32_t) ( \
524                                          TXD1_BIT | \
525                                          LED1_BIT | \
526                                          RTS1_BIT | \
527                                          AUX_OUT2_BIT | \
528                                          USB_CONNECT_BIT | \
529                                          AUX_OUT4_BIT | \
530                                          0 )
531
532 #define P3IO_ONE_BITS        (uint32_t) ( \
533                                          AUX_OUT1_BIT | \
534                                          0 )
535
536 #define P4IO_ONE_BITS        (uint32_t) ( \
537                                          AUX_OUT3_BIT | \
538                                          0 )
539
540 #define P0IO_OUTPUT_BITS     (uint32_t) ( \
541                                          P0IO_ZERO_BITS | \
542                                          P0IO_ONE_BITS )
543
544 #define P1IO_OUTPUT_BITS     (uint32_t) ( \
545                                          P1IO_ZERO_BITS | \
546                                          P1IO_ONE_BITS )
547
548 #define P2IO_OUTPUT_BITS     (uint32_t) ( \
549                                          P2IO_ZERO_BITS | \
550                                          P2IO_ONE_BITS )
551
552 #define P3IO_OUTPUT_BITS     (uint32_t) ( \
553                                          P3IO_ZERO_BITS | \
554                                          P3IO_ONE_BITS )
555
556 #define P4IO_OUTPUT_BITS     (uint32_t) ( \
557                                          P4IO_ZERO_BITS | \
558                                          P4IO_ONE_BITS )
559
560
561
562 /***************************************************************************/
563 /* io functions */
564 #define LED_GP                  LED2_BIT  /* GENREAL PURPOSE LED */
565 #define LED_ERR                 LED1_BIT
566
567 /***************************************************************************/
568 /* io functions */
569 #define IN_PORT                 GPIO0->FIO
570 #define OUT_PORT                GPIO1->FIO
571 #define LED_PORT                GPIO2->FIO
572
573 #define CREATE_PORT_NAME_PIN(port) port##PIN
574 #define CREATE_PORT_NAME_CLR(port) port##CLR
575 #define CREATE_PORT_NAME_SET(port) port##SET
576
577 #define GET_IN_PIN(port,in)     ((CREATE_PORT_NAME_PIN(port) & in)?1:0) 
578 #define GET_IN_PORT(port)       (CREATE_PORT_NAME_PIN(port))
579 #define SET_OUT_PIN(port,out)   (CREATE_PORT_NAME_SET(port)=out)
580 #define CLR_OUT_PIN(port,out)   (CREATE_PORT_NAME_CLR(port)=out)
581
582 /***************************************************************************/
583 /* watchdog */
584 #define WATCHDOG_ENABLED
585 #define WATCHDOG_TIMEOUT_MS     1000
586
587 /***************************************************************************/
588 /* uLan configuration */
589
590 #ifdef UL_LOG_ENABLE
591   #undef UL_LOG_ENABLE
592 #endif
593
594 #ifdef ULD_DEFAULT_BUFFER_SIZE
595   #undef ULD_DEFAULT_BUFFER_SIZE
596   #define ULD_DEFAULT_BUFFER_SIZE 0x2000
597 #endif
598
599 #define UL_DRV_SYSLESS_PORT UART1_BASE
600 #define UL_DRV_SYSLESS_BAUD 19200
601 #define UL_DRV_SYSLESS_IRQ UART1_IRQn
602 #define UL_DRV_SYSLESS_MY_ADR_DEFAULT 1
603
604 #define watchdog_feed lpc_watchdog_feed
605 #define kvpb_erase lpcisp_kvpb_erase
606 #define kvpb_copy lpcisp_kvpb_copy
607 #define kvpb_flush lpcisp_kvpb_flush
608 #define KVPB_DEFAULT_FLAGS KVPB_DESC_DOUBLE|KVPB_DESC_CHUNKWO
609
610 /***************************************************************************/
611 /* USB configuration */
612 #define USB_WITH_UDEV_FNC
613 #define USB_EP_NUM          32
614 #define USB_MAX_PACKET0     64
615 #define USB_MAX_PACKET      8
616 #define USB_DMA_EP          0x00000000
617
618 #define USB_VBUS_PIN_USED   0
619
620 /***************************************************************************/
621 /* I2C1 configuration */
622 #define I2C_DRV_SYSLESS_IRQ I2C1_IRQn
623 #define I2C_DRV_SYSLESS_PORT I2C1_BASE
624 #define I2C_DRV_SYSLESS_BITRATE 10000
625 #define I2C_DRV_SYSLESS_SLADR 0
626
627 #endif /* _SYSTEM_DEF_H_ */