Rev 21 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 21 | Rev 22 | ||
|---|---|---|---|
| Line 35... | Line 35... | ||
| 35 | #include "evtimer.h" |
35 | #include "evtimer.h" |
| 36 | #include "chprintf.h" |
36 | #include "chprintf.h" |
| 37 | 37 | ||
| 38 | 38 | ||
| 39 | 39 | ||
| 40 | #if (HAL_USE_SERIAL_USB == TRUE) |
40 | #if (HAL_USE_SERIAL_ == TRUE) |
| 41 | #include "usbcfg.h" |
41 | #include "cfg.h" |
| 42 | #endif |
42 | #endif |
| 43 | 43 | ||
| 44 | 44 | ||
| 45 | #include "ap_math.h" |
45 | #include "ap_math.h" |
| 46 | #include "hardware.h" |
46 | #include "hardware.h" |
| Line 65... | Line 65... | ||
| 65 | #define TEST_WA_SIZE THD_WORKING_AREA_SIZE(256) |
65 | #define TEST_WA_SIZE THD_WORKING_AREA_SIZE(256) |
| 66 | 66 | ||
| 67 | 67 | ||
| 68 | 68 | ||
| 69 | static const ShellConfig shell_cfg1 = { |
69 | static const ShellConfig shell_cfg1 = { |
| 70 | #if (HAL_USE_SERIAL_USB == TRUE) |
70 | #if (HAL_USE_SERIAL_ == TRUE) |
| 71 | (BaseSequentialStream *)&SDU1, |
71 | (BaseSequentialStream *)&SDU1, |
| 72 | #else |
72 | #else |
| 73 | (BaseSequentialStream *)&SD1, |
73 | (BaseSequentialStream *)&SD2, |
| 74 | #endif |
74 | #endif |
| 75 | shellCommands |
75 | shellCommands |
| 76 | }; |
76 | }; |
| 77 | //////// |
77 | //////// |
| 78 | // end of shell stuff |
78 | // end of shell stuff |
| Line 104... | Line 104... | ||
| 104 | * in this demo it just performs |
104 | * in this demo it just performs |
| 105 | * a shell respawn upon its termination. |
105 | * a shell respawn upon its termination. |
| 106 | */ |
106 | */ |
| 107 | while (true) { |
107 | while (true) { |
| 108 | if (!shelltp) { |
108 | if (!shelltp) { |
| 109 | #if (HAL_USE_SERIAL_USB == TRUE) |
109 | #if (HAL_USE_SERIAL_ == TRUE) |
| 110 | if (SDU1.config->usbp->state == USB_ACTIVE) { |
110 | if (SDU1.config->p->state == _ACTIVE) { |
| 111 | /* Spawns a new shell.*/ |
111 | /* Spawns a new shell.*/ |
| 112 | shelltp = chThdCreateFromHeap(NULL, SHELL_WA_SIZE, "shell", NORMALPRIO, shellThread, (void *) &shell_cfg1); |
112 | shelltp = chThdCreateFromHeap(NULL, SHELL_WA_SIZE, "shell", NORMALPRIO, shellThread, (void *) &shell_cfg1); |
| 113 | } |
113 | } |
| 114 | #else |
114 | #else |
| 115 | shelltp = chThdCreateFromHeap(NULL, SHELL_WA_SIZE, "shell", NORMALPRIO, shellThread, (void *) &shell_cfg1); |
115 | shelltp = chThdCreateFromHeap(NULL, SHELL_WA_SIZE, "shell", NORMALPRIO, shellThread, (void *) &shell_cfg1); |
| Line 148... | Line 148... | ||
| 148 | halInit(); |
148 | halInit(); |
| 149 | chSysInit(); |
149 | chSysInit(); |
| 150 | 150 | ||
| 151 | 151 | ||
| 152 | 152 | ||
| 153 | #if (HAL_USE_SERIAL_USB == TRUE) |
153 | #if (HAL_USE_SERIAL_ == TRUE) |
| 154 | /* |
154 | /* |
| 155 | * Initializes a serial-over-USB CDC driver. |
155 | * Initializes a serial-over- CDC driver. |
| 156 | */ |
156 | */ |
| 157 | sduObjectInit(&SDU1); |
157 | sduObjectInit(&SDU1); |
| 158 | sduStart(&SDU1, &serusbcfg); |
158 | sduStart(&SDU1, &sercfg); |
| 159 | 159 | ||
| 160 | #if HAL_USE_USB_DUAL_CDC == TRUE |
160 | #if HAL_USE__DUAL_CDC == TRUE |
| 161 | sduObjectInit(&SDU2); |
161 | sduObjectInit(&SDU2); |
| 162 | sduStart(&SDU2, &serusbcfg2); |
162 | sduStart(&SDU2, &sercfg2); |
| 163 | #endif |
163 | #endif |
| 164 | 164 | ||
| 165 | /* |
165 | /* |
| 166 | * Activates the USB driver and then the USB bus pull-up on D+. |
166 | * Activates the driver and then the bus pull-up on D+. |
| 167 | * Note, a delay is inserted in order to not have to disconnect the cable |
167 | * Note, a delay is inserted in order to not have to disconnect the cable |
| 168 | * after a reset. |
168 | * after a reset. |
| 169 | */ |
169 | */ |
| 170 | usbDisconnectBus(serusbcfg.usbp); |
170 | DisconnectBus(sercfg.p); |
| 171 | chThdSleepMilliseconds(1000); |
171 | chThdSleepMilliseconds(1000); |
| 172 | usbStart(serusbcfg.usbp, &usbcfg); |
172 | Start(sercfg.p, &cfg); |
| 173 | usbConnectBus(serusbcfg.usbp); |
173 | ConnectBus(sercfg.p); |
| 174 | #else |
174 | #else |
| 175 | /* |
175 | /* |
| 176 | * Initializes serial port. |
176 | * Initializes serial port. |
| 177 | */ |
177 | */ |
| 178 | sdStart(&SD2, NULL); |
178 | sdStart(&SD2, NULL); |
| 179 | #endif /* HAL_USE_SERIAL_USB */ |
179 | #endif /* HAL_USE_SERIAL_ */ |
| 180 | 180 | ||
| 181 | // Ignition timing code |
181 | // Ignition timing code |
| 182 | initTimers(); |
182 | initTimers(); |
| 183 | 183 | ||
| 184 | useAdc(); |
184 | useAdc(); |
| Line 245... | Line 245... | ||
| 245 | font_sig_digits(64,52,4,-1, getDelta()); |
245 | font_sig_digits(64,52,4,-1, getDelta()); |
| 246 | 246 | ||
| 247 | 247 | ||
| 248 | display(); |
248 | display(); |
| 249 | 249 | ||
| - | 250 | ||
| 250 | chMtxUnlock(&mutexDisplay); |
251 | chMtxUnlock(&mutexDisplay); |
| 251 | // |
252 | // |
| 252 | // invertDisplay(x & 32); |
253 | // invertDisplay(x & 32); |
| 253 | 254 | ||
| 254 | chThdSleep(chTimeMS2I(10)); |
255 | chThdSleep(chTimeMS2I(10)); |
| Line 258... | Line 259... | ||
| 258 | // shell thread code . dead at present |
259 | // shell thread code . dead at present |
| 259 | // /* |
260 | // /* |
| 260 | // * Normal main() thread activity, spawning shells. |
261 | // * Normal main() thread activity, spawning shells. |
| 261 | // */ |
262 | // */ |
| 262 | // while (true) { |
263 | // while (true) { |
| 263 | // if (SDU1.config->usbp->state == USB_ACTIVE) { |
264 | // if (SDU1.config->p->state == _ACTIVE) { |
| 264 | //o thread_t *shelltp = chThdCreateFromHeap(NULL, SHELL_WA_SIZE, |
265 | //o thread_t *shelltp = chThdCreateFromHeap(NULL, SHELL_WA_SIZE, |
| 265 | // "shell", NORMALPRIO + 1, |
266 | // "shell", NORMALPRIO + 1, |
| 266 | // shellThread, (void *)&shell_cfg1); |
267 | // shellThread, (void *)&shell_cfg1); |
| 267 | // chThdWait(shelltp); /* Waiting termination. */ |
268 | // chThdWait(shelltp); /* Waiting termination. */ |
| 268 | // } |
269 | // } |