Rev 1935 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1156 | tk | 1 | // $Id: mios32_board.c 2578 2018-05-07 18:57:43Z tk $ |
2 | //! \defgroup MIOS32_BOARD |
||
3 | //! |
||
4 | //! Development Board specific functions for MIOS32 |
||
5 | //! |
||
6 | //! \{ |
||
7 | /* ========================================================================== |
||
8 | * |
||
9 | * Copyright (C) 2011 Thorsten Klose (tk@midibox.org) |
||
10 | * Licensed for personal non-commercial use only. |
||
11 | * All other rights reserved. |
||
12 | * |
||
13 | * ========================================================================== |
||
14 | */ |
||
15 | |||
16 | ///////////////////////////////////////////////////////////////////////////// |
||
17 | // Include files |
||
18 | ///////////////////////////////////////////////////////////////////////////// |
||
19 | |||
20 | #include <mios32.h> |
||
21 | |||
22 | // this module can be optionally disabled in a local mios32_config.h file (included from mios32.h) |
||
23 | #if !defined(MIOS32_DONT_USE_BOARD) |
||
24 | |||
25 | |||
26 | ///////////////////////////////////////////////////////////////////////////// |
||
27 | // J5 pin mapping |
||
28 | ///////////////////////////////////////////////////////////////////////////// |
||
29 | |||
1199 | tk | 30 | #if defined(MIOS32_BOARD_MBHP_CORE_LPC17) || defined(MIOS32_BOARD_LPCXPRESSO) |
1156 | tk | 31 | // note: adaptions also have to be done in MIOS32_BOARD_J5_(Set/Get), |
32 | // since these functions access the ports directly |
||
33 | typedef struct { |
||
1199 | tk | 34 | u8 port; |
35 | u8 pin; |
||
1156 | tk | 36 | } j5_pin_t; |
37 | |||
1199 | tk | 38 | #define J5_NUM_PINS 8 |
1156 | tk | 39 | static const j5_pin_t j5_pin[J5_NUM_PINS] = { |
40 | // J5A |
||
1199 | tk | 41 | { 0, 23 }, |
42 | { 0, 24 }, |
||
43 | { 0, 25 }, |
||
44 | { 0, 26 }, |
||
1156 | tk | 45 | |
1199 | tk | 46 | // J5BB |
47 | { 1, 30 }, |
||
48 | { 1, 31 }, |
||
49 | { 0, 3 }, |
||
50 | { 0, 2 }, |
||
1156 | tk | 51 | }; |
52 | |||
53 | #else |
||
54 | #define J5_NUM_PINS 0 |
||
1199 | tk | 55 | #warning "No J5 pins defined for this MIOS32_BOARD" |
1156 | tk | 56 | #endif |
57 | |||
58 | |||
59 | ///////////////////////////////////////////////////////////////////////////// |
||
1199 | tk | 60 | // J10 pin mapping |
1156 | tk | 61 | ///////////////////////////////////////////////////////////////////////////// |
62 | |||
1199 | tk | 63 | #if defined(MIOS32_BOARD_MBHP_CORE_LPC17) || defined(MIOS32_BOARD_LPCXPRESSO) |
64 | // note: adaptions also have to be done in MIOS32_BOARD_J10_(Set/Get), |
||
65 | // since these functions access the ports directly |
||
66 | typedef struct { |
||
67 | u8 port; |
||
68 | u8 pin; |
||
69 | } j10_pin_t; |
||
1156 | tk | 70 | |
1199 | tk | 71 | #define J10_NUM_PINS 8 |
72 | static const j10_pin_t j10_pin[J10_NUM_PINS] = { |
||
73 | // J10 |
||
74 | { 2, 2 }, |
||
75 | { 2, 3 }, |
||
76 | { 2, 4 }, |
||
77 | { 2, 5 }, |
||
78 | { 2, 6 }, |
||
79 | { 2, 7 }, |
||
80 | { 2, 8 }, |
||
81 | { 1, 18 }, |
||
82 | }; |
||
1156 | tk | 83 | |
1199 | tk | 84 | #else |
85 | #define J10_NUM_PINS 0 |
||
86 | #warning "No J10 pins defined for this MIOS32_BOARD" |
||
87 | #endif |
||
1156 | tk | 88 | |
89 | |||
1199 | tk | 90 | ///////////////////////////////////////////////////////////////////////////// |
1311 | tk | 91 | // J28 pin mapping |
92 | ///////////////////////////////////////////////////////////////////////////// |
||
93 | |||
94 | #if defined(MIOS32_BOARD_MBHP_CORE_LPC17) || defined(MIOS32_BOARD_LPCXPRESSO) |
||
95 | // note: adaptions also have to be done in MIOS32_BOARD_J28_(Set/Get), |
||
96 | // since these functions access the ports directly |
||
97 | typedef struct { |
||
98 | u8 port; |
||
99 | u8 pin; |
||
100 | } j28_pin_t; |
||
101 | |||
102 | #define J28_NUM_PINS 4 |
||
103 | static const j28_pin_t j28_pin[J28_NUM_PINS] = { |
||
104 | // J28 |
||
105 | { 2, 13 }, // J28:SDA |
||
106 | { 2, 11 }, // J28:SC |
||
107 | { 2, 12 }, // J28:WS |
||
108 | { 4, 29 }, // J28:MCLK |
||
109 | }; |
||
110 | |||
111 | #else |
||
112 | #define J28_NUM_PINS 0 |
||
113 | #warning "No J28 pins defined for this MIOS32_BOARD" |
||
114 | #endif |
||
115 | |||
116 | |||
117 | ///////////////////////////////////////////////////////////////////////////// |
||
1199 | tk | 118 | // J15 (LCD) pin mapping |
119 | ///////////////////////////////////////////////////////////////////////////// |
||
1156 | tk | 120 | |
1199 | tk | 121 | #if defined(MIOS32_BOARD_MBHP_CORE_LPC17) || defined(MIOS32_BOARD_LPCXPRESSO) |
1156 | tk | 122 | |
1199 | tk | 123 | #define J15_AVAILABLE 1 |
1156 | tk | 124 | |
1199 | tk | 125 | #define J15_SCLK_PORT 1 |
126 | #define J15_SCLK_PIN 25 |
||
1156 | tk | 127 | |
1199 | tk | 128 | #define J15_RCLK_PORT 1 |
129 | #define J15_RCLK_PIN 26 |
||
1156 | tk | 130 | |
1199 | tk | 131 | #define J15_SER_PORT 1 // also used as DC (data/command select) for serial interfaces |
132 | #define J15_SER_PIN 28 |
||
1156 | tk | 133 | |
1199 | tk | 134 | #define J15_E1_PORT 1 // also used to control SCLK of serial interfaces |
135 | #define J15_E1_PIN 29 |
||
1156 | tk | 136 | |
1199 | tk | 137 | #define J15_E2_PORT 3 |
138 | #define J15_E2_PIN 25 |
||
1156 | tk | 139 | |
1199 | tk | 140 | #define J15_RW_PORT 1 // also used to control data output of serial interfaces |
141 | #define J15_RW_PIN 27 |
||
142 | |||
143 | #define J15_D7_PORT 1 |
||
144 | #define J15_D7_PIN 19 |
||
145 | |||
1156 | tk | 146 | // following macros simplify the access to J15 pins |
1199 | tk | 147 | #define J15_PIN_SER(b) MIOS32_SYS_LPC_PINSET(J15_SER_PORT, J15_SER_PIN, b) |
148 | #define J15_PIN_E1(b) MIOS32_SYS_LPC_PINSET(J15_E1_PORT, J15_E1_PIN, b) |
||
149 | #define J15_PIN_E2(b) MIOS32_SYS_LPC_PINSET(J15_E2_PORT, J15_E2_PIN, b) |
||
150 | #define J15_PIN_RW(b) MIOS32_SYS_LPC_PINSET(J15_RW_PORT, J15_RW_PIN, b) |
||
1156 | tk | 151 | |
1899 | tk | 152 | #if 1 |
1199 | tk | 153 | #define J15_PIN_SERLCD_DATAOUT(b) MIOS32_SYS_LPC_PINSET(J15_RW_PORT, J15_RW_PIN, b) |
1876 | tk | 154 | #define J15_PIN_SERLCD_SCLK_0 { MIOS32_SYS_LPC_PINSET_0(J15_E1_PORT, J15_E1_PIN); MIOS32_SYS_LPC_PINSET_0(J15_E2_PORT, J15_E2_PIN); } |
155 | #define J15_PIN_SERLCD_SCLK_1 { MIOS32_SYS_LPC_PINSET_1(J15_E1_PORT, J15_E1_PIN); MIOS32_SYS_LPC_PINSET_1(J15_E2_PORT, J15_E2_PIN); } |
||
1899 | tk | 156 | #else |
157 | // try SDA at E2 |
||
158 | #define J15_PIN_SERLCD_DATAOUT(b) MIOS32_SYS_LPC_PINSET(J15_E2_PORT, J15_E2_PIN, b) |
||
159 | #define J15_PIN_SERLCD_SCLK_0 { MIOS32_SYS_LPC_PINSET_0(J15_E1_PORT, J15_E1_PIN); } |
||
160 | #define J15_PIN_SERLCD_SCLK_1 { MIOS32_SYS_LPC_PINSET_1(J15_E1_PORT, J15_E1_PIN); } |
||
161 | #endif |
||
1156 | tk | 162 | |
1199 | tk | 163 | #define J15_PIN_RCLK_0 MIOS32_SYS_LPC_PINSET_0(J15_RCLK_PORT, J15_RCLK_PIN) |
164 | #define J15_PIN_RCLK_1 MIOS32_SYS_LPC_PINSET_1(J15_RCLK_PORT, J15_RCLK_PIN) |
||
1156 | tk | 165 | |
1199 | tk | 166 | #define J15_PIN_SCLK_0 MIOS32_SYS_LPC_PINSET_0(J15_SCLK_PORT, J15_SCLK_PIN) |
167 | #define J15_PIN_SCLK_1 MIOS32_SYS_LPC_PINSET_1(J15_SCLK_PORT, J15_SCLK_PIN) |
||
1156 | tk | 168 | |
1199 | tk | 169 | #define J15_PIN_D7_IN MIOS32_SYS_LPC_PINGET(J15_D7_PORT, J15_D7_PIN) |
1156 | tk | 170 | |
171 | #else |
||
172 | #define J15_AVAILABLE 0 |
||
1199 | tk | 173 | #warning "No J15 (LCD) port defined for this MIOS32_BOARD" |
1156 | tk | 174 | #endif |
175 | |||
176 | |||
177 | ///////////////////////////////////////////////////////////////////////////// |
||
178 | // Local variables |
||
179 | ///////////////////////////////////////////////////////////////////////////// |
||
180 | |||
181 | static u16 j5_enable_mask; |
||
1199 | tk | 182 | static u8 j10_enable_mask; |
1311 | tk | 183 | static u8 j28_enable_mask; |
1156 | tk | 184 | |
185 | |||
186 | |||
187 | ///////////////////////////////////////////////////////////////////////////// |
||
188 | //! Initializes MIOS32_BOARD driver |
||
189 | //! \param[in] mode currently only mode 0 supported |
||
190 | //! \return < 0 if initialisation failed |
||
191 | ///////////////////////////////////////////////////////////////////////////// |
||
192 | s32 MIOS32_BOARD_Init(u32 mode) |
||
193 | { |
||
194 | // currently only mode 0 supported |
||
195 | if( mode != 0 ) |
||
196 | return -1; // unsupported mode |
||
197 | |||
198 | j5_enable_mask = 0; |
||
1199 | tk | 199 | j10_enable_mask = 0; |
1311 | tk | 200 | j28_enable_mask = 0; |
1156 | tk | 201 | |
202 | return 0; // no error |
||
203 | } |
||
204 | |||
205 | |||
206 | ///////////////////////////////////////////////////////////////////////////// |
||
1311 | tk | 207 | //! Internally used help function to initialize a pin |
208 | ///////////////////////////////////////////////////////////////////////////// |
||
209 | static s32 MIOS32_BOARD_PinInitHlp(u8 port, u8 pin, mios32_board_pin_mode_t mode) |
||
210 | { |
||
211 | u8 pinsel = 0; // default: select GPIO |
||
212 | u8 pinmode = 0; // default: enable pull-up |
||
213 | u8 pindir = 0; // default: input mode |
||
214 | u8 pinod = 0; // default: disable open drain |
||
215 | |||
216 | switch( mode ) { |
||
217 | case MIOS32_BOARD_PIN_MODE_ANALOG: |
||
218 | pinsel = 1; // select ADC |
||
219 | pinmode = 2; // set to floating... doesn't matter, but also doesn't hurt |
||
220 | break; |
||
221 | case MIOS32_BOARD_PIN_MODE_INPUT: |
||
222 | pinmode = 2; // set to floating |
||
223 | break; |
||
224 | case MIOS32_BOARD_PIN_MODE_INPUT_PD: |
||
225 | pinmode = 3; // enable pull-down |
||
226 | break; |
||
227 | case MIOS32_BOARD_PIN_MODE_INPUT_PU: |
||
228 | pinmode = 0; // enable pull-up |
||
229 | break; |
||
230 | case MIOS32_BOARD_PIN_MODE_OUTPUT_PP: |
||
231 | pindir = 1; // output mode |
||
232 | break; |
||
233 | case MIOS32_BOARD_PIN_MODE_OUTPUT_OD: |
||
234 | pindir = 1; // output mode |
||
235 | pinod = 1; // open drain |
||
236 | break; |
||
237 | default: |
||
238 | return -1; // invalid pin mode |
||
239 | } |
||
240 | |||
241 | MIOS32_SYS_LPC_PINSEL(port, pin, pinsel); |
||
242 | MIOS32_SYS_LPC_PINMODE(port, pin, pinmode); |
||
243 | MIOS32_SYS_LPC_PINDIR(port, pin, pindir); |
||
244 | MIOS32_SYS_LPC_PINMODE_OD(port, pin, pinod); |
||
245 | |||
246 | return 0; // no error |
||
247 | } |
||
248 | |||
249 | |||
250 | ///////////////////////////////////////////////////////////////////////////// |
||
1156 | tk | 251 | //! Initializes LEDs of the board |
252 | //! \param[in] leds mask contains a flag for each LED which should be initialized<BR> |
||
253 | //! <UL> |
||
254 | //! <LI>MBHP_CORE_STM32: 1 LED (flag 0: green) |
||
255 | //! <LI>STM32_PRIMER: 2 LEDs (flag 0: green, flag 1: red) |
||
256 | //! </UL> |
||
257 | //! \return 0 if initialisation passed |
||
258 | //! \return -1 if no LEDs specified for board |
||
259 | //! \return -2 if one or more LEDs not available on board |
||
260 | ///////////////////////////////////////////////////////////////////////////// |
||
261 | s32 MIOS32_BOARD_LED_Init(u32 leds) |
||
262 | { |
||
1191 | tk | 263 | #if defined(MIOS32_BOARD_LPCXPRESSO) || defined(MIOS32_BOARD_MBHP_CORE_LPC17) |
1156 | tk | 264 | if( leds & 1 ) { |
265 | // select GPIO for P0.22 |
||
1311 | tk | 266 | MIOS32_BOARD_PinInitHlp(0, 22, MIOS32_BOARD_PIN_MODE_OUTPUT_PP); |
1156 | tk | 267 | } |
268 | |||
269 | if( leds & 0xfffffffe) |
||
270 | return -2; // LED doesn't exist |
||
271 | |||
272 | return 0; // no error |
||
273 | #else |
||
1191 | tk | 274 | #warning "no LED specified for this MIOS32_BOARD!" |
275 | return -1; |
||
1156 | tk | 276 | #endif |
277 | } |
||
278 | |||
279 | |||
280 | ///////////////////////////////////////////////////////////////////////////// |
||
281 | //! Sets one or more LEDs to the given value(s) |
||
282 | //! \param[in] leds mask contains a flag for each LED which should be changed |
||
283 | //! \param[in] value contains the value which should be set |
||
284 | //! \return 0 if initialisation passed |
||
285 | //! \return -1 if no LEDs specified for board |
||
286 | //! \return -2 if one or more LEDs not available on board |
||
287 | ///////////////////////////////////////////////////////////////////////////// |
||
288 | s32 MIOS32_BOARD_LED_Set(u32 leds, u32 value) |
||
289 | { |
||
1191 | tk | 290 | #if defined(MIOS32_BOARD_LPCXPRESSO) || defined(MIOS32_BOARD_MBHP_CORE_LPC17) |
1156 | tk | 291 | // only one LED, connected to P0.22 |
292 | if( leds & 1 ) { |
||
1199 | tk | 293 | MIOS32_SYS_LPC_PINSET(0, 22, value & 1); |
1156 | tk | 294 | } |
295 | |||
296 | if( leds & 0xfffffffe) |
||
297 | return -2; // LED doesn't exist |
||
298 | |||
299 | return 0; // no error |
||
300 | #else |
||
1191 | tk | 301 | #warning "no LED specified for this MIOS32_BOARD!" |
302 | return -1; |
||
1156 | tk | 303 | #endif |
304 | } |
||
305 | |||
306 | |||
307 | ///////////////////////////////////////////////////////////////////////////// |
||
308 | //! Returns the status of all LEDs |
||
309 | //! \return status of all LEDs |
||
310 | ///////////////////////////////////////////////////////////////////////////// |
||
311 | u32 MIOS32_BOARD_LED_Get(void) |
||
312 | { |
||
313 | u32 values = 0; |
||
314 | |||
1191 | tk | 315 | #if defined(MIOS32_BOARD_LPCXPRESSO) || defined(MIOS32_BOARD_MBHP_CORE_LPC17) |
1156 | tk | 316 | // only one LED, connected to P0.22 |
1199 | tk | 317 | if( MIOS32_SYS_LPC_PINGET(0, 22) ) |
1156 | tk | 318 | values |= (1 << 0); |
319 | #else |
||
1191 | tk | 320 | #warning "no LED specified for this MIOS32_BOARD!" |
321 | return -1; |
||
1156 | tk | 322 | #endif |
323 | |||
324 | return values; |
||
325 | } |
||
326 | |||
327 | |||
328 | ///////////////////////////////////////////////////////////////////////////// |
||
329 | //! Initializes a J5 pin |
||
1199 | tk | 330 | //! \param[in] pin the pin number (0..7) |
1156 | tk | 331 | //! \param[in] mode the pin mode |
332 | //! <UL> |
||
333 | //! <LI>MIOS32_BOARD_PIN_MODE_IGNORE: configuration shouldn't be touched |
||
334 | //! <LI>MIOS32_BOARD_PIN_MODE_ANALOG: select analog input mode (default) |
||
335 | //! <LI>MIOS32_BOARD_PIN_MODE_INPUT: pin is used as input w/o pull device (floating) |
||
336 | //! <LI>MIOS32_BOARD_PIN_MODE_INPUT_PD: pin is used as input, internal pull down enabled |
||
337 | //! <LI>MIOS32_BOARD_PIN_MODE_INPUT_PU: pin is used as input, internal pull up enabled |
||
338 | //! <LI>MIOS32_BOARD_PIN_MODE_OUTPUT_PP: pin is used as output in push-pull mode |
||
339 | //! <LI>MIOS32_BOARD_PIN_MODE_OUTPUT_OD: pin is used as output in open drain mode |
||
340 | //! </UL> |
||
341 | //! \return < 0 if initialisation failed |
||
342 | ///////////////////////////////////////////////////////////////////////////// |
||
343 | s32 MIOS32_BOARD_J5_PinInit(u8 pin, mios32_board_pin_mode_t mode) |
||
344 | { |
||
345 | #if J5_NUM_PINS == 0 |
||
346 | return -1; // MIOS32_BOARD_J5 not supported |
||
347 | #else |
||
348 | if( pin >= J5_NUM_PINS ) |
||
349 | return -1; // pin not supported |
||
350 | |||
351 | if( mode == MIOS32_BOARD_PIN_MODE_IGNORE ) { |
||
352 | // don't touch |
||
353 | j5_enable_mask &= ~(1 << pin); |
||
354 | } else { |
||
355 | // enable pin |
||
356 | j5_enable_mask |= (1 << pin); |
||
357 | |||
1199 | tk | 358 | j5_pin_t *p = (j5_pin_t *)&j5_pin[pin]; |
1156 | tk | 359 | |
1311 | tk | 360 | if( MIOS32_BOARD_PinInitHlp(p->port, p->pin, mode) < 0 ) |
361 | return -2; // invalid pin mode |
||
1156 | tk | 362 | |
363 | #if 0 |
||
364 | // set pin value to 0 |
||
365 | // This should be done before IO mode configuration, because |
||
366 | // in input mode, this bit will control Pull Up/Down (configured |
||
367 | // by GPIO_Init) |
||
1199 | tk | 368 | MIOS32_SYS_LPC_PINSET(p->port, p->pin, 0); |
1156 | tk | 369 | // TK: disabled since there are application which have to switch between Input/Output |
370 | // without destroying the current pin value |
||
371 | #endif |
||
372 | } |
||
373 | |||
374 | return 0; // no error |
||
375 | #endif |
||
376 | } |
||
377 | |||
378 | |||
379 | ///////////////////////////////////////////////////////////////////////////// |
||
380 | //! This function sets all pins of J5 at once |
||
1199 | tk | 381 | //! \param[in] value 8 bits which are forwarded to J5A/B |
1156 | tk | 382 | //! \return < 0 on errors |
383 | ///////////////////////////////////////////////////////////////////////////// |
||
384 | s32 MIOS32_BOARD_J5_Set(u16 value) |
||
385 | { |
||
386 | #if J5_NUM_PINS == 0 |
||
387 | return -1; // MIOS32_BOARD_J5 not supported |
||
388 | #else |
||
1199 | tk | 389 | # if defined(MIOS32_BOARD_MBHP_CORE_LPC17) || defined(MIOS32_BOARD_LPCXPRESSO) |
390 | // J5A[3:0] -> P0[26:23] |
||
391 | // J5B[1:0] -> P1[31:30] |
||
392 | // J5B[2] -> P0[3] |
||
393 | // J5B[3] -> P0[2] |
||
1156 | tk | 394 | |
1199 | tk | 395 | LPC_GPIO0->FIOSET = |
396 | (( value & j5_enable_mask & 0x000f) << 23) | // set flags |
||
397 | (( value & j5_enable_mask & 0x0040) >> 3) | // set flags |
||
398 | (( value & j5_enable_mask & 0x0080) >> 5); |
||
1156 | tk | 399 | |
1199 | tk | 400 | LPC_GPIO1->FIOSET = |
401 | (( value & j5_enable_mask & 0x0030) << (30-4)); // set flags |
||
1156 | tk | 402 | |
1199 | tk | 403 | LPC_GPIO0->FIOCLR = |
404 | ((~value & j5_enable_mask & 0x000f) << 23) | // clear flags |
||
405 | ((~value & j5_enable_mask & 0x0040) >> 3) | // clear flags |
||
406 | ((~value & j5_enable_mask & 0x0080) >> 5); |
||
1156 | tk | 407 | |
1199 | tk | 408 | LPC_GPIO1->FIOCLR = |
409 | ((~value & j5_enable_mask & 0x0030) << (30-4)); // clear flags |
||
1156 | tk | 410 | |
411 | return 0; // no error |
||
412 | # else |
||
1199 | tk | 413 | # warning "Not prepared for this MIOS32_BOARD" |
1156 | tk | 414 | return -2; // board not supported |
415 | # endif |
||
416 | #endif |
||
417 | } |
||
418 | |||
419 | |||
420 | ///////////////////////////////////////////////////////////////////////////// |
||
421 | //! This function sets a single pin of J5 |
||
1199 | tk | 422 | //! \param[in] pin the pin number (0..7) |
1156 | tk | 423 | //! \param[in] value the pin value (0 or 1) |
424 | //! \return < 0 on errors |
||
425 | ///////////////////////////////////////////////////////////////////////////// |
||
426 | s32 MIOS32_BOARD_J5_PinSet(u8 pin, u8 value) |
||
427 | { |
||
428 | #if J5_NUM_PINS == 0 |
||
429 | return -1; // MIOS32_BOARD_J5 not supported |
||
430 | #else |
||
431 | if( pin >= J5_NUM_PINS ) |
||
432 | return -1; // pin not supported |
||
433 | |||
434 | if( !(j5_enable_mask & (1 << pin)) ) |
||
435 | return -2; // pin disabled |
||
436 | |||
1199 | tk | 437 | j5_pin_t *p = (j5_pin_t *)&j5_pin[pin]; |
438 | MIOS32_SYS_LPC_PINSET(p->port, p->pin, value); |
||
1156 | tk | 439 | |
440 | return 0; // no error |
||
441 | #endif |
||
442 | } |
||
443 | |||
444 | |||
445 | ///////////////////////////////////////////////////////////////////////////// |
||
446 | //! This function returns the state of all pins of J5 |
||
1199 | tk | 447 | //! \return 8 bits which are forwarded from J5A/B |
1156 | tk | 448 | ///////////////////////////////////////////////////////////////////////////// |
449 | s32 MIOS32_BOARD_J5_Get(void) |
||
450 | { |
||
451 | #if J5_NUM_PINS == 0 |
||
452 | return -1; // MIOS32_BOARD_J5 not supported |
||
453 | #else |
||
1199 | tk | 454 | # if defined(MIOS32_BOARD_MBHP_CORE_LPC17) || defined(MIOS32_BOARD_LPCXPRESSO) |
455 | // J5A[3:0] -> P0[26:23] |
||
456 | // J5B[1:0] -> P1[31:30] |
||
457 | // J5B[2] -> P0[3] |
||
458 | // J5B[3] -> P0[2] |
||
1156 | tk | 459 | |
1199 | tk | 460 | u32 p0 = LPC_GPIO0->FIOPIN; |
461 | u32 p1 = LPC_GPIO1->FIOPIN; |
||
1156 | tk | 462 | return |
1199 | tk | 463 | (((p0 >> (23-0)) & 0x000f) | |
2578 | tk | 464 | ((p1 >> (30-4)) & 0x0030) | |
465 | ((p0 << (6-3)) & 0x0040) | |
||
466 | ((p0 << (7-2)) & 0x0080)); |
||
1156 | tk | 467 | # else |
1199 | tk | 468 | # warning "Not prepared for this MIOS32_BOARD" |
1156 | tk | 469 | return -2; // board not supported |
470 | # endif |
||
471 | #endif |
||
472 | } |
||
473 | |||
474 | |||
475 | ///////////////////////////////////////////////////////////////////////////// |
||
476 | //! This function returns the state of a single pin of J5 |
||
1199 | tk | 477 | //! \param[in] pin the pin number (0..7) |
1156 | tk | 478 | //! \return < 0 if pin not available |
479 | //! \return >= 0: input state of pin |
||
480 | ///////////////////////////////////////////////////////////////////////////// |
||
481 | s32 MIOS32_BOARD_J5_PinGet(u8 pin) |
||
482 | { |
||
483 | #if J5_NUM_PINS == 0 |
||
484 | return -1; // MIOS32_BOARD_J5 not supported |
||
485 | #else |
||
486 | if( pin >= J5_NUM_PINS ) |
||
487 | return -1; // pin not supported |
||
488 | |||
489 | if( !(j5_enable_mask & (1 << pin)) ) |
||
490 | return -2; // pin disabled |
||
491 | |||
1199 | tk | 492 | j5_pin_t *p = (j5_pin_t *)&j5_pin[pin]; |
493 | return MIOS32_SYS_LPC_PINGET(p->port, p->pin) ? 1 : 0; |
||
1156 | tk | 494 | #endif |
495 | } |
||
496 | |||
497 | |||
498 | |||
499 | |||
500 | ///////////////////////////////////////////////////////////////////////////// |
||
1199 | tk | 501 | //! Initializes a J10 pin |
502 | //! \param[in] pin the pin number (0..7) |
||
503 | //! \param[in] mode the pin mode |
||
504 | //! <UL> |
||
505 | //! <LI>MIOS32_BOARD_PIN_MODE_IGNORE: configuration shouldn't be touched |
||
506 | //! <LI>MIOS32_BOARD_PIN_MODE_ANALOG: select analog input mode (default) |
||
507 | //! <LI>MIOS32_BOARD_PIN_MODE_INPUT: pin is used as input w/o pull device (floating) |
||
508 | //! <LI>MIOS32_BOARD_PIN_MODE_INPUT_PD: pin is used as input, internal pull down enabled |
||
509 | //! <LI>MIOS32_BOARD_PIN_MODE_INPUT_PU: pin is used as input, internal pull up enabled |
||
510 | //! <LI>MIOS32_BOARD_PIN_MODE_OUTPUT_PP: pin is used as output in push-pull mode |
||
511 | //! <LI>MIOS32_BOARD_PIN_MODE_OUTPUT_OD: pin is used as output in open drain mode |
||
512 | //! </UL> |
||
513 | //! \return < 0 if initialisation failed |
||
514 | ///////////////////////////////////////////////////////////////////////////// |
||
515 | s32 MIOS32_BOARD_J10_PinInit(u8 pin, mios32_board_pin_mode_t mode) |
||
516 | { |
||
517 | #if J10_NUM_PINS == 0 |
||
518 | return -1; // MIOS32_BOARD_J10 not supported |
||
519 | #else |
||
520 | if( pin >= J10_NUM_PINS ) |
||
521 | return -1; // pin not supported |
||
522 | |||
523 | if( mode == MIOS32_BOARD_PIN_MODE_IGNORE ) { |
||
524 | // don't touch |
||
525 | j10_enable_mask &= ~(1 << pin); |
||
526 | } else { |
||
527 | // enable pin |
||
528 | j10_enable_mask |= (1 << pin); |
||
529 | |||
530 | j10_pin_t *p = (j10_pin_t *)&j10_pin[pin]; |
||
531 | |||
1311 | tk | 532 | if( MIOS32_BOARD_PinInitHlp(p->port, p->pin, mode) < 0 ) |
533 | return -2; // invalid pin mode |
||
1199 | tk | 534 | |
535 | #if 0 |
||
536 | // set pin value to 0 |
||
537 | // This should be done before IO mode configuration, because |
||
538 | // in input mode, this bit will control Pull Up/Down (configured |
||
539 | // by GPIO_Init) |
||
540 | MIOS32_SYS_LPC_PINSET(p->port, p->pin, 0); |
||
541 | // TK: disabled since there are application which have to switch between Input/Output |
||
542 | // without destroying the current pin value |
||
543 | #endif |
||
544 | } |
||
545 | |||
546 | return 0; // no error |
||
547 | #endif |
||
548 | } |
||
549 | |||
550 | |||
551 | ///////////////////////////////////////////////////////////////////////////// |
||
552 | //! This function sets all pins of J10 at once |
||
553 | //! \param[in] value 8 bits which are forwarded to J10 |
||
554 | //! \return < 0 on errors |
||
555 | ///////////////////////////////////////////////////////////////////////////// |
||
556 | s32 MIOS32_BOARD_J10_Set(u16 value) |
||
557 | { |
||
558 | #if J10_NUM_PINS == 0 |
||
559 | return -1; // MIOS32_BOARD_J10 not supported |
||
560 | #else |
||
561 | # if defined(MIOS32_BOARD_MBHP_CORE_LPC17) || defined(MIOS32_BOARD_LPCXPRESSO) |
||
562 | // J10[6:0] -> P2[8:2] |
||
563 | // J10[7] -> P1[18] |
||
564 | |||
565 | LPC_GPIO2->FIOSET = |
||
566 | (( value & j10_enable_mask & 0x007f) << 2); // set flags |
||
567 | |||
568 | LPC_GPIO1->FIOSET = |
||
569 | (( value & j10_enable_mask & 0x0080) << (18-7)); // set flags |
||
570 | |||
571 | LPC_GPIO2->FIOCLR = |
||
572 | ((~value & j10_enable_mask & 0x007f) << 2); // clear flags |
||
573 | |||
574 | LPC_GPIO1->FIOCLR = |
||
575 | ((~value & j10_enable_mask & 0x0080) << (18-7)); // clear flags |
||
576 | |||
577 | return 0; // no error |
||
578 | # else |
||
579 | # warning "Not prepared for this MIOS32_BOARD" |
||
580 | return -2; // board not supported |
||
581 | # endif |
||
582 | #endif |
||
583 | } |
||
584 | |||
585 | |||
586 | ///////////////////////////////////////////////////////////////////////////// |
||
587 | //! This function sets a single pin of J10 |
||
588 | //! \param[in] pin the pin number (0..7) |
||
589 | //! \param[in] value the pin value (0 or 1) |
||
590 | //! \return < 0 on errors |
||
591 | ///////////////////////////////////////////////////////////////////////////// |
||
592 | s32 MIOS32_BOARD_J10_PinSet(u8 pin, u8 value) |
||
593 | { |
||
594 | #if J10_NUM_PINS == 0 |
||
595 | return -1; // MIOS32_BOARD_J10 not supported |
||
596 | #else |
||
597 | if( pin >= J10_NUM_PINS ) |
||
598 | return -1; // pin not supported |
||
599 | |||
600 | if( !(j10_enable_mask & (1 << pin)) ) |
||
601 | return -2; // pin disabled |
||
602 | |||
603 | j10_pin_t *p = (j10_pin_t *)&j10_pin[pin]; |
||
604 | MIOS32_SYS_LPC_PINSET(p->port, p->pin, value); |
||
605 | |||
606 | return 0; // no error |
||
607 | #endif |
||
608 | } |
||
609 | |||
610 | |||
611 | ///////////////////////////////////////////////////////////////////////////// |
||
612 | //! This function returns the state of all pins of J10 |
||
613 | //! \return 8 bits which are forwarded from J10 |
||
614 | ///////////////////////////////////////////////////////////////////////////// |
||
615 | s32 MIOS32_BOARD_J10_Get(void) |
||
616 | { |
||
617 | #if J10_NUM_PINS == 0 |
||
618 | return -1; // MIOS32_BOARD_J10 not supported |
||
619 | #else |
||
620 | # if defined(MIOS32_BOARD_MBHP_CORE_LPC17) || defined(MIOS32_BOARD_LPCXPRESSO) |
||
621 | // J10[6:0] -> P2[8:2] |
||
622 | // J10[7] -> P1[18] |
||
623 | |||
624 | u32 p2 = LPC_GPIO2->FIOPIN; |
||
625 | u32 p1 = LPC_GPIO1->FIOPIN; |
||
626 | return |
||
627 | (((p2 >> (2)) & 0x007f) | |
||
628 | ((p1 >> (18-7)) & 0x0080)); |
||
629 | # else |
||
630 | # warning "Not prepared for this MIOS32_BOARD" |
||
631 | return -2; // board not supported |
||
632 | # endif |
||
633 | #endif |
||
634 | } |
||
635 | |||
636 | |||
637 | ///////////////////////////////////////////////////////////////////////////// |
||
638 | //! This function returns the state of a single pin of J10 |
||
639 | //! \param[in] pin the pin number (0..7) |
||
640 | //! \return < 0 if pin not available |
||
641 | //! \return >= 0: input state of pin |
||
642 | ///////////////////////////////////////////////////////////////////////////// |
||
643 | s32 MIOS32_BOARD_J10_PinGet(u8 pin) |
||
644 | { |
||
645 | #if J10_NUM_PINS == 0 |
||
646 | return -1; // MIOS32_BOARD_J10 not supported |
||
647 | #else |
||
648 | if( pin >= J10_NUM_PINS ) |
||
649 | return -1; // pin not supported |
||
650 | |||
651 | if( !(j10_enable_mask & (1 << pin)) ) |
||
652 | return -2; // pin disabled |
||
653 | |||
654 | j10_pin_t *p = (j10_pin_t *)&j10_pin[pin]; |
||
655 | return MIOS32_SYS_LPC_PINGET(p->port, p->pin) ? 1 : 0; |
||
656 | #endif |
||
657 | } |
||
658 | |||
659 | |||
1930 | tk | 660 | ///////////////////////////////////////////////////////////////////////////// |
661 | //! This function returns the state of all pins of J10A (J10[7:0]) |
||
662 | //! \return 8 bits which are forwarded from J10A |
||
663 | ///////////////////////////////////////////////////////////////////////////// |
||
664 | s32 MIOS32_BOARD_J10A_Get(void) |
||
665 | { |
||
666 | return MIOS32_BOARD_J10_Get(); |
||
667 | } |
||
1199 | tk | 668 | |
669 | |||
670 | ///////////////////////////////////////////////////////////////////////////// |
||
1930 | tk | 671 | //! This function sets all pins of J10A (J10[7:0]) at once |
672 | //! \param[in] value 8 bits which are forwarded to J10A |
||
673 | //! \return < 0 on errors |
||
674 | ///////////////////////////////////////////////////////////////////////////// |
||
675 | s32 MIOS32_BOARD_J10A_Set(u8 value) |
||
676 | { |
||
677 | return MIOS32_BOARD_J10_Set(value); |
||
678 | } |
||
679 | |||
680 | |||
681 | |||
682 | ///////////////////////////////////////////////////////////////////////////// |
||
683 | //! This function returns the state of all pins of J10B (J10[15:8]) |
||
684 | //! \return 8 bits which are forwarded from J10B |
||
685 | ///////////////////////////////////////////////////////////////////////////// |
||
686 | s32 MIOS32_BOARD_J10B_Get(void) |
||
687 | { |
||
688 | #if J10_NUM_PINS <= 8 |
||
689 | return -1; // not supported |
||
690 | #else |
||
691 | # warning "Not prepared for this MIOS32_BOARD" |
||
692 | return -2; // board not supported |
||
693 | #endif |
||
694 | } |
||
695 | |||
696 | |||
697 | ///////////////////////////////////////////////////////////////////////////// |
||
698 | //! This function sets all pins of J10B (J10[15:8]) at once |
||
699 | //! \param[in] value 8 bits which are forwarded to J10B |
||
700 | //! \return < 0 on errors |
||
701 | ///////////////////////////////////////////////////////////////////////////// |
||
702 | s32 MIOS32_BOARD_J10B_Set(u8 value) |
||
703 | { |
||
704 | #if J10_NUM_PINS <= 8 |
||
705 | return -1; // not supported |
||
706 | #else |
||
707 | # warning "Not prepared for this MIOS32_BOARD" |
||
708 | return -2; // board not supported |
||
709 | #endif |
||
710 | } |
||
711 | |||
712 | |||
713 | ///////////////////////////////////////////////////////////////////////////// |
||
1311 | tk | 714 | //! Initializes a J28 pin |
715 | //! \param[in] pin the pin number (0..3) |
||
716 | //! \param[in] mode the pin mode |
||
717 | //! <UL> |
||
718 | //! <LI>MIOS32_BOARD_PIN_MODE_IGNORE: configuration shouldn't be touched |
||
719 | //! <LI>MIOS32_BOARD_PIN_MODE_ANALOG: select analog input mode (default) |
||
720 | //! <LI>MIOS32_BOARD_PIN_MODE_INPUT: pin is used as input w/o pull device (floating) |
||
721 | //! <LI>MIOS32_BOARD_PIN_MODE_INPUT_PD: pin is used as input, internal pull down enabled |
||
722 | //! <LI>MIOS32_BOARD_PIN_MODE_INPUT_PU: pin is used as input, internal pull up enabled |
||
723 | //! <LI>MIOS32_BOARD_PIN_MODE_OUTPUT_PP: pin is used as output in push-pull mode |
||
724 | //! <LI>MIOS32_BOARD_PIN_MODE_OUTPUT_OD: pin is used as output in open drain mode |
||
725 | //! </UL> |
||
726 | //! \return < 0 if initialisation failed |
||
727 | ///////////////////////////////////////////////////////////////////////////// |
||
728 | s32 MIOS32_BOARD_J28_PinInit(u8 pin, mios32_board_pin_mode_t mode) |
||
729 | { |
||
730 | #if J28_NUM_PINS == 0 |
||
731 | return -1; // MIOS32_BOARD_J28 not supported |
||
732 | #else |
||
733 | if( pin >= J28_NUM_PINS ) |
||
734 | return -1; // pin not supported |
||
735 | |||
736 | if( mode == MIOS32_BOARD_PIN_MODE_IGNORE ) { |
||
737 | // don't touch |
||
738 | j28_enable_mask &= ~(1 << pin); |
||
739 | } else { |
||
740 | // enable pin |
||
741 | j28_enable_mask |= (1 << pin); |
||
742 | |||
743 | j28_pin_t *p = (j28_pin_t *)&j28_pin[pin]; |
||
744 | |||
745 | if( MIOS32_BOARD_PinInitHlp(p->port, p->pin, mode) < 0 ) |
||
746 | return -2; // invalid pin mode |
||
747 | |||
748 | #if 0 |
||
749 | // set pin value to 0 |
||
750 | // This should be done before IO mode configuration, because |
||
751 | // in input mode, this bit will control Pull Up/Down (configured |
||
752 | // by GPIO_Init) |
||
753 | MIOS32_SYS_LPC_PINSET(p->port, p->pin, 0); |
||
754 | // TK: disabled since there are application which have to switch between Input/Output |
||
755 | // without destroying the current pin value |
||
756 | #endif |
||
757 | } |
||
758 | |||
759 | return 0; // no error |
||
760 | #endif |
||
761 | } |
||
762 | |||
763 | |||
764 | ///////////////////////////////////////////////////////////////////////////// |
||
765 | //! This function sets all pins of J28 at once |
||
766 | //! \param[in] value 8 bits which are forwarded to J28 |
||
767 | //! \return < 0 on errors |
||
768 | ///////////////////////////////////////////////////////////////////////////// |
||
769 | s32 MIOS32_BOARD_J28_Set(u16 value) |
||
770 | { |
||
771 | #if J28_NUM_PINS == 0 |
||
772 | return -1; // MIOS32_BOARD_J28 not supported |
||
773 | #else |
||
774 | # if defined(MIOS32_BOARD_MBHP_CORE_LPC17) || defined(MIOS32_BOARD_LPCXPRESSO) |
||
775 | LPC_GPIO2->FIOSET = |
||
776 | (( value & j28_enable_mask & 0x0001) << 13) | // set flags |
||
777 | (( value & j28_enable_mask & 0x0006) << (11-1)); |
||
778 | |||
779 | LPC_GPIO4->FIOSET = |
||
780 | (( value & j28_enable_mask & 0x0008) << (29-3)); // set flags |
||
781 | |||
782 | LPC_GPIO2->FIOCLR = |
||
783 | ((~value & j28_enable_mask & 0x0001) << 13) | // clear flags |
||
784 | ((~value & j28_enable_mask & 0x0006) << (11-1)); |
||
785 | |||
786 | LPC_GPIO4->FIOCLR = |
||
787 | ((~value & j28_enable_mask & 0x0008) << (29-3)); // clear flags |
||
788 | |||
789 | return 0; // no error |
||
790 | # else |
||
791 | # warning "Not prepared for this MIOS32_BOARD" |
||
792 | return -2; // board not supported |
||
793 | # endif |
||
794 | #endif |
||
795 | } |
||
796 | |||
797 | |||
798 | ///////////////////////////////////////////////////////////////////////////// |
||
799 | //! This function sets a single pin of J28 |
||
800 | //! \param[in] pin the pin number (0..7) |
||
801 | //! \param[in] value the pin value (0 or 1) |
||
802 | //! \return < 0 on errors |
||
803 | ///////////////////////////////////////////////////////////////////////////// |
||
804 | s32 MIOS32_BOARD_J28_PinSet(u8 pin, u8 value) |
||
805 | { |
||
806 | #if J28_NUM_PINS == 0 |
||
807 | return -1; // MIOS32_BOARD_J28 not supported |
||
808 | #else |
||
809 | if( pin >= J28_NUM_PINS ) |
||
810 | return -1; // pin not supported |
||
811 | |||
812 | if( !(j28_enable_mask & (1 << pin)) ) |
||
813 | return -2; // pin disabled |
||
814 | |||
815 | j28_pin_t *p = (j28_pin_t *)&j28_pin[pin]; |
||
816 | MIOS32_SYS_LPC_PINSET(p->port, p->pin, value); |
||
817 | |||
818 | return 0; // no error |
||
819 | #endif |
||
820 | } |
||
821 | |||
822 | |||
823 | ///////////////////////////////////////////////////////////////////////////// |
||
824 | //! This function returns the state of all pins of J28 |
||
825 | //! \return 8 bits which are forwarded from J28 |
||
826 | ///////////////////////////////////////////////////////////////////////////// |
||
827 | s32 MIOS32_BOARD_J28_Get(void) |
||
828 | { |
||
829 | #if J28_NUM_PINS == 0 |
||
830 | return -1; // MIOS32_BOARD_J28 not supported |
||
831 | #else |
||
832 | # if defined(MIOS32_BOARD_MBHP_CORE_LPC17) || defined(MIOS32_BOARD_LPCXPRESSO) |
||
833 | u32 p2 = LPC_GPIO2->FIOPIN; |
||
834 | u32 p4 = LPC_GPIO4->FIOPIN; |
||
835 | return |
||
836 | ((p2 >> (13)) & 0x0001) | |
||
837 | ((p2 >> (11-1)) & 0x0006) | |
||
838 | ((p4 >> (29-3)) & 0x0008); |
||
839 | # else |
||
840 | # warning "Not prepared for this MIOS32_BOARD" |
||
841 | return -2; // board not supported |
||
842 | # endif |
||
843 | #endif |
||
844 | } |
||
845 | |||
846 | |||
847 | ///////////////////////////////////////////////////////////////////////////// |
||
848 | //! This function returns the state of a single pin of J28 |
||
849 | //! \param[in] pin the pin number (0..7) |
||
850 | //! \return < 0 if pin not available |
||
851 | //! \return >= 0: input state of pin |
||
852 | ///////////////////////////////////////////////////////////////////////////// |
||
853 | s32 MIOS32_BOARD_J28_PinGet(u8 pin) |
||
854 | { |
||
855 | #if J28_NUM_PINS == 0 |
||
856 | return -1; // MIOS32_BOARD_J28 not supported |
||
857 | #else |
||
858 | if( pin >= J28_NUM_PINS ) |
||
859 | return -1; // pin not supported |
||
860 | |||
861 | if( !(j28_enable_mask & (1 << pin)) ) |
||
862 | return -2; // pin disabled |
||
863 | |||
864 | j28_pin_t *p = (j28_pin_t *)&j28_pin[pin]; |
||
865 | return MIOS32_SYS_LPC_PINGET(p->port, p->pin) ? 1 : 0; |
||
866 | #endif |
||
867 | } |
||
868 | |||
869 | |||
1656 | tk | 870 | ///////////////////////////////////////////////////////////////////////////// |
1156 | tk | 871 | //! Initializes the J15 port |
872 | //! \param[in] mode |
||
873 | //! <UL> |
||
874 | //! <LI>0: J15 pins are configured in Push Pull Mode (3.3V) |
||
875 | //! <LI>1: J15 pins are configured in Open Drain mode (perfect for 3.3V->5V levelshifting) |
||
876 | //! </UL> |
||
877 | //! \return < 0 if initialisation failed |
||
878 | ///////////////////////////////////////////////////////////////////////////// |
||
879 | s32 MIOS32_BOARD_J15_PortInit(u32 mode) |
||
880 | { |
||
881 | #if J15_AVAILABLE == 0 |
||
882 | return -1; // LCD port not available |
||
883 | #else |
||
884 | // currently only mode 0 and 1 supported |
||
885 | if( mode != 0 && mode != 1 ) |
||
886 | return -1; // unsupported mode |
||
887 | |||
888 | J15_PIN_SCLK_0; |
||
889 | J15_PIN_RCLK_0; |
||
890 | J15_PIN_RW(0); |
||
891 | J15_PIN_E1(0); |
||
892 | J15_PIN_E2(0); |
||
893 | |||
1311 | tk | 894 | // configure pins |
895 | MIOS32_BOARD_PinInitHlp(J15_SCLK_PORT, J15_SCLK_PIN, MIOS32_BOARD_PIN_MODE_OUTPUT_PP); |
||
896 | MIOS32_BOARD_PinInitHlp(J15_RCLK_PORT, J15_RCLK_PIN, MIOS32_BOARD_PIN_MODE_OUTPUT_PP); |
||
897 | MIOS32_BOARD_PinInitHlp(J15_SER_PORT, J15_SER_PIN, mode ? MIOS32_BOARD_PIN_MODE_OUTPUT_OD : MIOS32_BOARD_PIN_MODE_OUTPUT_PP); |
||
898 | MIOS32_BOARD_PinInitHlp(J15_E1_PORT, J15_E1_PIN, mode ? MIOS32_BOARD_PIN_MODE_OUTPUT_OD : MIOS32_BOARD_PIN_MODE_OUTPUT_PP); |
||
899 | MIOS32_BOARD_PinInitHlp(J15_E2_PORT, J15_E2_PIN, mode ? MIOS32_BOARD_PIN_MODE_OUTPUT_OD : MIOS32_BOARD_PIN_MODE_OUTPUT_PP); |
||
900 | MIOS32_BOARD_PinInitHlp(J15_RW_PORT, J15_RW_PIN, mode ? MIOS32_BOARD_PIN_MODE_OUTPUT_OD : MIOS32_BOARD_PIN_MODE_OUTPUT_PP); |
||
1156 | tk | 901 | |
1508 | tk | 902 | // configure "busy" input: let it float, otherwise it could activate D7 if RW=1 (and therefore 74HC595 drivers disabled) |
1509 | tk | 903 | // pull-up will be dynamically enabled in MIOS32_BOARD_J15_PollUnbusy() |
1508 | tk | 904 | MIOS32_BOARD_PinInitHlp(J15_D7_PORT, J15_D7_PIN, MIOS32_BOARD_PIN_MODE_INPUT); |
1156 | tk | 905 | |
906 | return 0; // no error |
||
907 | #endif |
||
908 | } |
||
909 | |||
910 | |||
911 | ///////////////////////////////////////////////////////////////////////////// |
||
912 | //! This function is used by LCD drivers under $MIOS32_PATH/modules/app_lcd |
||
913 | //! to output an 8bit value on the data lines |
||
914 | //! \param[in] data the 8bit value |
||
915 | //! \return < 0 if access to data port not supported by board |
||
916 | ///////////////////////////////////////////////////////////////////////////// |
||
917 | s32 MIOS32_BOARD_J15_DataSet(u8 data) |
||
918 | { |
||
919 | #if J15_AVAILABLE == 0 |
||
920 | return -1; // LCD port not available |
||
921 | #else |
||
922 | // shift in 8bit data |
||
1899 | tk | 923 | // whole function takes ca. 1 uS @ 120MHz |
1156 | tk | 924 | // thats acceptable for a (C)LCD, which is normaly busy after each access for ca. 20..40 uS |
925 | |||
926 | J15_PIN_SER(data & 0x80); // D7 |
||
927 | J15_PIN_SCLK_0; // setup delay |
||
1899 | tk | 928 | J15_PIN_SCLK_0; |
1156 | tk | 929 | J15_PIN_SCLK_1; |
1899 | tk | 930 | J15_PIN_SCLK_1; |
931 | J15_PIN_SCLK_1; |
||
1156 | tk | 932 | J15_PIN_SER(data & 0x40); // D6 |
933 | J15_PIN_SCLK_0; // setup delay |
||
1899 | tk | 934 | J15_PIN_SCLK_0; |
935 | J15_PIN_SCLK_0; |
||
1156 | tk | 936 | J15_PIN_SCLK_1; |
1899 | tk | 937 | J15_PIN_SCLK_1; |
938 | J15_PIN_SCLK_1; |
||
1156 | tk | 939 | J15_PIN_SER(data & 0x20); // D5 |
940 | J15_PIN_SCLK_0; // setup delay |
||
1899 | tk | 941 | J15_PIN_SCLK_0; |
1156 | tk | 942 | J15_PIN_SCLK_1; |
1899 | tk | 943 | J15_PIN_SCLK_1; |
944 | J15_PIN_SCLK_1; |
||
1156 | tk | 945 | J15_PIN_SER(data & 0x10); // D4 |
946 | J15_PIN_SCLK_0; // setup delay |
||
1899 | tk | 947 | J15_PIN_SCLK_0; |
1156 | tk | 948 | J15_PIN_SCLK_1; |
1899 | tk | 949 | J15_PIN_SCLK_1; |
950 | J15_PIN_SCLK_1; |
||
1156 | tk | 951 | J15_PIN_SER(data & 0x08); // D3 |
952 | J15_PIN_SCLK_0; // setup delay |
||
1899 | tk | 953 | J15_PIN_SCLK_0; |
1156 | tk | 954 | J15_PIN_SCLK_1; |
1899 | tk | 955 | J15_PIN_SCLK_1; |
956 | J15_PIN_SCLK_1; |
||
1156 | tk | 957 | J15_PIN_SER(data & 0x04); // D2 |
958 | J15_PIN_SCLK_0; // setup delay |
||
1899 | tk | 959 | J15_PIN_SCLK_0; |
1156 | tk | 960 | J15_PIN_SCLK_1; |
1899 | tk | 961 | J15_PIN_SCLK_1; |
962 | J15_PIN_SCLK_1; |
||
1156 | tk | 963 | J15_PIN_SER(data & 0x02); // D1 |
964 | J15_PIN_SCLK_0; // setup delay |
||
1899 | tk | 965 | J15_PIN_SCLK_0; |
1156 | tk | 966 | J15_PIN_SCLK_1; |
1899 | tk | 967 | J15_PIN_SCLK_1; |
968 | J15_PIN_SCLK_1; |
||
1156 | tk | 969 | J15_PIN_SER(data & 0x01); // D0 |
970 | J15_PIN_SCLK_0; // setup delay |
||
1899 | tk | 971 | J15_PIN_SCLK_0; |
1156 | tk | 972 | J15_PIN_SCLK_1; |
1852 | tk | 973 | J15_PIN_SCLK_1; |
1899 | tk | 974 | J15_PIN_SCLK_1; |
1156 | tk | 975 | |
976 | // transfer to output register |
||
977 | J15_PIN_RCLK_1; |
||
978 | J15_PIN_RCLK_1; |
||
979 | J15_PIN_RCLK_1; |
||
980 | J15_PIN_RCLK_0; |
||
981 | |||
982 | return 0; // no error |
||
983 | #endif |
||
984 | } |
||
985 | |||
986 | |||
987 | ///////////////////////////////////////////////////////////////////////////// |
||
988 | //! This function is used by LCD drivers under $MIOS32_PATH/modules/app_lcd |
||
989 | //! to shift an 8bit data value to LCDs with serial interface |
||
990 | //! (SCLK connected to J15A:E, Data line connected to J15A:RW) |
||
991 | //! \param[in] data the 8bit value |
||
992 | //! \return < 0 if access to data port not supported by board |
||
993 | ///////////////////////////////////////////////////////////////////////////// |
||
994 | s32 MIOS32_BOARD_J15_SerDataShift(u8 data) |
||
995 | { |
||
996 | #if J15_AVAILABLE == 0 |
||
997 | return -1; // LCD port not available |
||
998 | #else |
||
1889 | tk | 999 | MIOS32_IRQ_Disable(); |
1000 | |||
1156 | tk | 1001 | J15_PIN_SERLCD_DATAOUT(data & 0x80); // D7 |
1002 | J15_PIN_SERLCD_SCLK_0; // setup delay |
||
1199 | tk | 1003 | J15_PIN_SERLCD_SCLK_0; |
1004 | J15_PIN_SERLCD_SCLK_0; |
||
1005 | J15_PIN_SERLCD_SCLK_0; |
||
1156 | tk | 1006 | J15_PIN_SERLCD_SCLK_1; |
1199 | tk | 1007 | J15_PIN_SERLCD_SCLK_1; |
1156 | tk | 1008 | J15_PIN_SERLCD_DATAOUT(data & 0x40); // D6 |
1009 | J15_PIN_SERLCD_SCLK_0; // setup delay |
||
1199 | tk | 1010 | J15_PIN_SERLCD_SCLK_0; |
1011 | J15_PIN_SERLCD_SCLK_0; |
||
1012 | J15_PIN_SERLCD_SCLK_0; |
||
1156 | tk | 1013 | J15_PIN_SERLCD_SCLK_1; |
1199 | tk | 1014 | J15_PIN_SERLCD_SCLK_1; |
1156 | tk | 1015 | J15_PIN_SERLCD_DATAOUT(data & 0x20); // D5 |
1016 | J15_PIN_SERLCD_SCLK_0; // setup delay |
||
1199 | tk | 1017 | J15_PIN_SERLCD_SCLK_0; |
1018 | J15_PIN_SERLCD_SCLK_0; |
||
1019 | J15_PIN_SERLCD_SCLK_0; |
||
1156 | tk | 1020 | J15_PIN_SERLCD_SCLK_1; |
1199 | tk | 1021 | J15_PIN_SERLCD_SCLK_1; |
1156 | tk | 1022 | J15_PIN_SERLCD_DATAOUT(data & 0x10); // D4 |
1023 | J15_PIN_SERLCD_SCLK_0; // setup delay |
||
1199 | tk | 1024 | J15_PIN_SERLCD_SCLK_0; |
1025 | J15_PIN_SERLCD_SCLK_0; |
||
1026 | J15_PIN_SERLCD_SCLK_0; |
||
1156 | tk | 1027 | J15_PIN_SERLCD_SCLK_1; |
1199 | tk | 1028 | J15_PIN_SERLCD_SCLK_1; |
1156 | tk | 1029 | J15_PIN_SERLCD_DATAOUT(data & 0x08); // D3 |
1030 | J15_PIN_SERLCD_SCLK_0; // setup delay |
||
1199 | tk | 1031 | J15_PIN_SERLCD_SCLK_0; |
1032 | J15_PIN_SERLCD_SCLK_0; |
||
1033 | J15_PIN_SERLCD_SCLK_0; |
||
1156 | tk | 1034 | J15_PIN_SERLCD_SCLK_1; |
1199 | tk | 1035 | J15_PIN_SERLCD_SCLK_1; |
1156 | tk | 1036 | J15_PIN_SERLCD_DATAOUT(data & 0x04); // D2 |
1037 | J15_PIN_SERLCD_SCLK_0; // setup delay |
||
1199 | tk | 1038 | J15_PIN_SERLCD_SCLK_0; |
1039 | J15_PIN_SERLCD_SCLK_0; |
||
1040 | J15_PIN_SERLCD_SCLK_0; |
||
1156 | tk | 1041 | J15_PIN_SERLCD_SCLK_1; |
1199 | tk | 1042 | J15_PIN_SERLCD_SCLK_1; |
1156 | tk | 1043 | J15_PIN_SERLCD_DATAOUT(data & 0x02); // D1 |
1044 | J15_PIN_SERLCD_SCLK_0; // setup delay |
||
1199 | tk | 1045 | J15_PIN_SERLCD_SCLK_0; |
1046 | J15_PIN_SERLCD_SCLK_0; |
||
1047 | J15_PIN_SERLCD_SCLK_0; |
||
1156 | tk | 1048 | J15_PIN_SERLCD_SCLK_1; |
1199 | tk | 1049 | J15_PIN_SERLCD_SCLK_1; |
1156 | tk | 1050 | J15_PIN_SERLCD_DATAOUT(data & 0x01); // D0 |
1051 | J15_PIN_SERLCD_SCLK_0; // setup delay |
||
1199 | tk | 1052 | J15_PIN_SERLCD_SCLK_0; |
1053 | J15_PIN_SERLCD_SCLK_0; |
||
1054 | J15_PIN_SERLCD_SCLK_0; |
||
1156 | tk | 1055 | J15_PIN_SERLCD_SCLK_1; |
1842 | tk | 1056 | J15_PIN_SERLCD_SCLK_1; |
1057 | J15_PIN_SERLCD_SCLK_1; |
||
1156 | tk | 1058 | |
1842 | tk | 1059 | // set SERLCD_DATAOUT (=J15.RW) to an active level |
1060 | // RW is unfortunately also connected to OE# of the 74HC595, which drives the CS lines. |
||
1061 | // With RW=1 the CS lines will go into high impedance state, and after 100..200 uS we will |
||
1062 | // see on the scope how CS line levels are changing, e.g. from high to mid level. |
||
1063 | // Although I assume that this can't cause an issue (because CS is only relevant when |
||
1064 | // the display gets a SCLK_0->SCLK_1 clock), I feel better when we ensure a proper CS state |
||
1065 | // after each MIOS32_BOARD_J15_SerDataShift call. |
||
1884 | tk | 1066 | J15_PIN_SERLCD_SCLK_0; |
1067 | J15_PIN_SERLCD_SCLK_0; |
||
1842 | tk | 1068 | J15_PIN_SERLCD_DATAOUT(0); |
1069 | |||
1889 | tk | 1070 | MIOS32_IRQ_Enable(); |
1071 | |||
1156 | tk | 1072 | return 0; // no error |
1073 | #endif |
||
1074 | } |
||
1075 | |||
1076 | |||
1077 | ///////////////////////////////////////////////////////////////////////////// |
||
1078 | //! This function is used by LCD drivers under $MIOS32_PATH/modules/app_lcd |
||
1079 | //! to set the RS pin |
||
1080 | //! \param[in] rs state of the RS pin |
||
1081 | //! \return < 0 if access to RS pin not supported by board |
||
1082 | ///////////////////////////////////////////////////////////////////////////// |
||
1083 | s32 MIOS32_BOARD_J15_RS_Set(u8 rs) |
||
1084 | { |
||
1085 | #if J15_AVAILABLE == 0 |
||
1086 | return -1; // LCD port not available |
||
1087 | #else |
||
1088 | J15_PIN_SER(rs); |
||
1089 | |||
1090 | return 0; // no error |
||
1091 | #endif |
||
1092 | } |
||
1093 | |||
1094 | ///////////////////////////////////////////////////////////////////////////// |
||
1095 | //! This function is used by LCD drivers under $MIOS32_PATH/modules/app_lcd |
||
1096 | //! to set the RW pin |
||
1097 | //! \param[in] rw state of the RW pin |
||
1098 | //! \return < 0 if access to RW pin not supported by board |
||
1099 | ///////////////////////////////////////////////////////////////////////////// |
||
1100 | s32 MIOS32_BOARD_J15_RW_Set(u8 rw) |
||
1101 | { |
||
1102 | #if J15_AVAILABLE == 0 |
||
1103 | return -1; // LCD port not available |
||
1104 | #else |
||
1105 | J15_PIN_RW(rw); |
||
1106 | |||
1107 | return 0; // no error |
||
1108 | #endif |
||
1109 | } |
||
1110 | |||
1111 | ///////////////////////////////////////////////////////////////////////////// |
||
1112 | //! This function is used by LCD drivers under $MIOS32_PATH/modules/app_lcd |
||
1113 | //! to set the E pin |
||
1114 | //! \param[in] lcd display port (0=J15A, 1=J15B) |
||
1115 | //! \param[in] e state of the E pin |
||
1116 | //! \return < 0 if access to E pin not supported by board |
||
1117 | ///////////////////////////////////////////////////////////////////////////// |
||
1118 | s32 MIOS32_BOARD_J15_E_Set(u8 lcd, u8 e) |
||
1119 | { |
||
1120 | #if J15_AVAILABLE == 0 |
||
1121 | return -1; // LCD port not available |
||
1122 | #else |
||
1123 | switch( lcd ) { |
||
1124 | case 0: |
||
1125 | J15_PIN_E1(e); |
||
1126 | return 0; // no error |
||
1127 | |||
1128 | case 1: |
||
1129 | J15_PIN_E2(e); |
||
1130 | return 0; // no error |
||
1131 | } |
||
1132 | |||
1133 | return -1; // pin not available |
||
1134 | #endif |
||
1135 | } |
||
1136 | |||
1137 | |||
1138 | ///////////////////////////////////////////////////////////////////////////// |
||
1633 | tk | 1139 | //! This function returns the state of the D7_IN pin |
1140 | //! return < 0 if LCD port not available |
||
1141 | //! return 0 if logic level is 0 |
||
1142 | //! return 1 if logic level is 1 |
||
1143 | ///////////////////////////////////////////////////////////////////////////// |
||
1144 | s32 MIOS32_BOARD_J15_GetD7In(void) |
||
1145 | { |
||
1146 | #if J15_AVAILABLE == 0 |
||
1147 | return -1; // LCD port not available |
||
1148 | #else |
||
1149 | return J15_PIN_D7_IN ? 1 : 0; |
||
1150 | #endif |
||
1151 | } |
||
1152 | |||
1153 | |||
1154 | ///////////////////////////////////////////////////////////////////////////// |
||
1656 | tk | 1155 | //! This function enables/disables the pull up on the D7 pin |
1156 | //! return < 0 if LCD port not available |
||
1157 | ///////////////////////////////////////////////////////////////////////////// |
||
1158 | s32 MIOS32_BOARD_J15_D7InPullUpEnable(u8 enable) |
||
1159 | { |
||
1160 | #if J15_AVAILABLE == 0 |
||
1161 | return -1; // LCD port not available |
||
1162 | #else |
||
1163 | if( enable ) { |
||
1164 | MIOS32_BOARD_PinInitHlp(J15_D7_PORT, J15_D7_PIN, MIOS32_BOARD_PIN_MODE_INPUT_PU); |
||
1165 | } else { |
||
1166 | MIOS32_BOARD_PinInitHlp(J15_D7_PORT, J15_D7_PIN, MIOS32_BOARD_PIN_MODE_INPUT); |
||
1167 | } |
||
1168 | return 0; // no error |
||
1169 | #endif |
||
1170 | } |
||
1171 | |||
1172 | |||
1173 | ///////////////////////////////////////////////////////////////////////////// |
||
1156 | tk | 1174 | //! This function is used by LCD drivers under $MIOS32_PATH/modules/app_lcd |
1175 | //! to poll the busy bit (D7) of a LCD |
||
1176 | //! \param[in] lcd display port (0=J15A, 1=J15B) |
||
1177 | //! \param[in] time_out how many times should the busy bit be polled? |
||
1178 | //! \return -1 if LCD not available |
||
1179 | //! \return -2 on timeout |
||
1180 | //! return >= 0 on success |
||
1181 | ///////////////////////////////////////////////////////////////////////////// |
||
1182 | s32 MIOS32_BOARD_J15_PollUnbusy(u8 lcd, u32 time_out) |
||
1183 | { |
||
1184 | #if J15_AVAILABLE == 0 |
||
1185 | return -1; // LCD port not available |
||
1186 | #else |
||
1187 | u32 poll_ctr; |
||
1188 | u32 delay_ctr; |
||
1189 | |||
1190 | // select command register (RS=0) |
||
1191 | MIOS32_BOARD_J15_RS_Set(0); |
||
1192 | |||
1509 | tk | 1193 | // enable pull-up |
1656 | tk | 1194 | MIOS32_BOARD_J15_D7InPullUpEnable(1); |
1509 | tk | 1195 | |
1156 | tk | 1196 | // select read (will also disable output buffer of 74HC595) |
1197 | MIOS32_BOARD_J15_RW_Set(1); |
||
1198 | |||
1199 | // check if E pin is available |
||
1200 | if( MIOS32_BOARD_J15_E_Set(lcd, 1) < 0 ) |
||
1201 | return -1; // LCD port not available |
||
1202 | |||
1203 | // poll busy flag, timeout after 10 mS |
||
1204 | // each loop takes ca. 4 uS @ 72MHz, this has to be considered when defining the time_out value |
||
1205 | for(poll_ctr=time_out; poll_ctr>0; --poll_ctr) { |
||
1206 | MIOS32_BOARD_J15_E_Set(lcd, 1); |
||
1207 | |||
1208 | // due to slow slope we should wait at least for 1 uS |
||
1209 | for(delay_ctr=0; delay_ctr<10; ++delay_ctr) |
||
1210 | MIOS32_BOARD_J15_RW_Set(1); |
||
1211 | |||
1633 | tk | 1212 | u32 busy = MIOS32_BOARD_J15_GetD7In(); |
1156 | tk | 1213 | MIOS32_BOARD_J15_E_Set(lcd, 0); |
1214 | if( !busy ) |
||
1215 | break; |
||
1216 | } |
||
1217 | |||
1509 | tk | 1218 | // disable pull-up |
1656 | tk | 1219 | MIOS32_BOARD_J15_D7InPullUpEnable(0); |
1509 | tk | 1220 | |
1156 | tk | 1221 | // deselect read (output buffers of 74HC595 enabled again) |
1222 | MIOS32_BOARD_J15_RW_Set(0); |
||
1223 | |||
1224 | // timeout? |
||
1225 | if( poll_ctr == 0 ) |
||
1226 | return -2; // timeout error |
||
1227 | |||
1228 | return 0; // no error |
||
1229 | #endif |
||
1230 | } |
||
1231 | |||
1232 | |||
1233 | |||
1234 | ///////////////////////////////////////////////////////////////////////////// |
||
1235 | //! This function enables or disables one of the two DAC channels provided by |
||
1236 | //! STM32F103RE (and not by STM32F103RB). |
||
1237 | //! |
||
1238 | //! <UL> |
||
1239 | //! <LI>the first channel (chn == 0) is output at pin RA4 (J16:RC1 of the MBHP_CORE_STM32 module) |
||
1240 | //! <LI>the second channel (chn == 1) is output at pin RA5 (J16:SC of the MBHP_CORE_STM32 module) |
||
1241 | //! </UL> |
||
1242 | //! |
||
1243 | //! \param[in] chn channel number (0 or 1) |
||
1244 | //! \param[in] enable 0: channel disabled, 1: channel enabled. |
||
1245 | //! \return < 0 if DAC channel not supported (e.g. STM32F103RB) |
||
1246 | ///////////////////////////////////////////////////////////////////////////// |
||
1247 | s32 MIOS32_BOARD_DAC_PinInit(u8 chn, u8 enable) |
||
1248 | { |
||
1249 | #if 1 |
||
1250 | return -1; // generally not supported. Try DAC access for all other processors |
||
1251 | #else |
||
1252 | if( chn >= 2 ) |
||
1253 | return -1; // channel not supported |
||
1254 | |||
1255 | if( enable ) { |
||
1256 | // enable DAC clock |
||
1257 | RCC_APB1PeriphClockCmd(RCC_APB1Periph_DAC, ENABLE); |
||
1258 | |||
1259 | // Once the DAC channel is enabled, the corresponding GPIO pin is automatically |
||
1260 | // connected to the DAC converter. In order to avoid parasitic consumption, |
||
1261 | // the GPIO pin should be configured in analog |
||
1262 | GPIO_InitTypeDef GPIO_InitStructure; |
||
1263 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN; |
||
1264 | |||
1265 | // init DAC |
||
1266 | DAC_InitTypeDef DAC_InitStructure; |
||
1267 | DAC_InitStructure.DAC_Trigger = DAC_Trigger_Software; |
||
1268 | DAC_InitStructure.DAC_OutputBuffer = DAC_OutputBuffer_Enable; |
||
1269 | |||
1270 | switch( chn ) { |
||
1271 | case 0: |
||
1272 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4; |
||
1273 | GPIO_Init(GPIOA, &GPIO_InitStructure); |
||
1274 | DAC_Init(DAC_Channel_1, &DAC_InitStructure); |
||
1275 | DAC_Cmd(DAC_Channel_1, ENABLE); |
||
1276 | break; |
||
1277 | |||
1278 | case 1: |
||
1279 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5; |
||
1280 | GPIO_Init(GPIOA, &GPIO_InitStructure); |
||
1281 | DAC_Init(DAC_Channel_2, &DAC_InitStructure); |
||
1282 | DAC_Cmd(DAC_Channel_2, ENABLE); |
||
1283 | break; |
||
1284 | |||
1285 | default: |
||
1286 | return -2; // unexpected (chn already checked above) |
||
1287 | } |
||
1288 | |||
1289 | } else { |
||
1290 | // disable DAC channel |
||
1291 | switch( chn ) { |
||
1292 | case 0: DAC_Cmd(DAC_Channel_1, DISABLE); break; |
||
1293 | case 1: DAC_Cmd(DAC_Channel_2, DISABLE); break; |
||
1294 | default: |
||
1295 | return -2; // unexpected (chn already checked above) |
||
1296 | } |
||
1297 | } |
||
1298 | |||
1299 | return 0; // no error |
||
1300 | #endif |
||
1301 | } |
||
1302 | |||
1303 | |||
1304 | ///////////////////////////////////////////////////////////////////////////// |
||
1305 | //! This function sets an output channel to a given 16-bit value. |
||
1306 | //! |
||
1307 | //! Note that actually the DAC will work at 12-bit resolution. The lowest |
||
1308 | //! 4 bits are ignored (reserved for future STM chips). |
||
1309 | //! \param[in] chn channel number (0 or 1) |
||
1310 | //! \param[in] value the 16-bit value (0..65535). Lowest 4 bits are ignored. |
||
1311 | //! \return < 0 if DAC channel not supported (e.g. STM32F103RB) |
||
1312 | ///////////////////////////////////////////////////////////////////////////// |
||
1313 | s32 MIOS32_BOARD_DAC_PinSet(u8 chn, u16 value) |
||
1314 | { |
||
1315 | #if 1 |
||
1316 | return -1; // generally not supported. Try DAC access for all other processors |
||
1317 | #else |
||
1318 | switch( chn ) { |
||
1319 | case 0: |
||
1320 | DAC_SetChannel1Data(DAC_Align_12b_L, value); |
||
1321 | DAC_SoftwareTriggerCmd(DAC_Channel_1, ENABLE); |
||
1322 | break; |
||
1323 | |||
1324 | case 1: |
||
1325 | DAC_SetChannel2Data(DAC_Align_12b_L, value); |
||
1326 | DAC_SoftwareTriggerCmd(DAC_Channel_2, ENABLE); |
||
1327 | break; |
||
1328 | |||
1329 | default: |
||
1330 | return -1; // channel not supported |
||
1331 | } |
||
1332 | |||
1333 | return 0; // no error |
||
1334 | #endif |
||
1335 | } |
||
1336 | |||
1337 | //! \} |
||
1338 | |||
1339 | #endif /* MIOS32_DONT_USE_BOARD */ |