Rev 7 | Rev 9 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 7 | Rev 8 | ||
|---|---|---|---|
| Line 120... | Line 120... | ||
| 120 | /* |
120 | /* |
| 121 | * Red LEDs blinker thread, times are in milliseconds. |
121 | * Red LEDs blinker thread, times are in milliseconds. |
| 122 | */ |
122 | */ |
| 123 | uint16_t sampleVal; |
123 | uint16_t sampleVal; |
| 124 | 124 | ||
| 125 | static THD_WORKING_AREA(waThread1, 128); |
125 | static THD_WORKING_AREA(waThread1, 512); |
| 126 | static msg_t Thread1(void *arg) { |
126 | static msg_t Thread1(void *arg) { |
| 127 | 127 | ||
| 128 | (void) arg; |
128 | (void) arg; |
| 129 | chRegSetThreadName("PLL "); |
129 | chRegSetThreadName("PLL "); |
| 130 | while (TRUE) { |
130 | while (TRUE) { |
| 131 | sampleVal = getNextPulse(); |
131 | sampleVal = getNextPulse(); |
| 132 | 132 | ||
| 133 | chThdSleep(1); |
133 | chThdSleep(1000); |
| 134 | } |
134 | } |
| 135 | return 0; |
135 | return 0; |
| 136 | } |
136 | } |
| 137 | 137 | ||
| 138 | /* |
138 | /* |
| 139 | * USB Bulk thread, times are in milliseconds. |
139 | * USB Bulk thread, times are in milliseconds. |
| 140 | */ |
140 | */ |
| 141 | static THD_WORKING_AREA(waThread2, 128); |
141 | static THD_WORKING_AREA(waThread2, 512); |
| 142 | static msg_t Thread2(void *arg) { |
142 | static msg_t Thread2(void *arg) { |
| 143 | chThdSleep(TIME_INFINITE); |
143 | chThdSleep(TIME_INFINITE); |
| 144 | 144 | ||
| 145 | } |
145 | } |
| 146 | 146 | ||
| Line 165... | Line 165... | ||
| 165 | chSysInit(); |
165 | chSysInit(); |
| 166 | 166 | ||
| 167 | /* |
167 | /* |
| 168 | * Initializes a serial-over-USB CDC driver. |
168 | * Initializes a serial-over-USB CDC driver. |
| 169 | */ |
169 | */ |
| 170 | sduObjectInit(&SDU1); |
170 | // sduObjectInit(&SDU1); |
| 171 | sduStart(&SDU1, &serusbcfg); |
171 | // sduStart(&SDU1, &serusbcfg); |
| 172 | 172 | ||
| 173 | /* |
173 | /* |
| 174 | * Activates the USB driver and then the USB bus pull-up on D+. |
174 | * Activates the USB driver and then the USB bus pull-up on D+. |
| 175 | * Note, a delay is inserted in order to not have to disconnect the cable |
175 | * Note, a delay is inserted in order to not have to disconnect the cable |
| 176 | * after a reset. |
176 | * after a reset. |
| 177 | */ |
177 | */ |
| 178 | usbDisconnectBus(serusbcfg.usbp); |
178 | // usbDisconnectBus(serusbcfg.usbp); |
| 179 | chThdSleepMilliseconds(1500); |
179 | // chThdSleepMilliseconds(1500); |
| 180 | usbStart(serusbcfg.usbp, &usbcfg); |
180 | // usbStart(serusbcfg.usbp, &usbcfg); |
| 181 | usbConnectBus(serusbcfg.usbp); |
181 | // usbConnectBus(serusbcfg.usbp); |
| 182 | 182 | ||
| 183 | // Ignition timing code |
183 | // Ignition timing code |
| 184 | initTimer2(); |
184 | initTimer2(); |
| 185 | 185 | ||
| 186 | useAdc(); |
186 | useAdc(); |
| 187 | 187 | ||
| 188 | /* |
188 | /* |
| 189 | * Activates the serial driver 2 using the driver default configuration. |
189 | * Activates the serial driver 2 using the driver default configuration. |
| 190 | */ |
190 | */ |
| 191 | sdStart(&SD2, NULL); |
191 | // sdStart(&SD2, NULL); |
| 192 | 192 | ||
| 193 | /* |
193 | /* |
| 194 | * Shell manager initialization. |
194 | * Shell manager initialization. |
| 195 | */ |
195 | */ |
| 196 | shellInit(); |
196 | shellInit(); |
| Line 212... | Line 212... | ||
| 212 | int adv = 0; |
212 | int adv = 0; |
| 213 | setRPM(spd); |
213 | setRPM(spd); |
| 214 | 214 | ||
| 215 | while(1) |
215 | while(1) |
| 216 | { |
216 | { |
| 217 | spd = getRPM(); |
217 | adcSample(); |
| 218 | 218 | ||
| 219 | adv = getAdc(0) * 1200 / 4096 - 300; |
219 | adv = getAdc(0) * 1200 / 4096 - 300; |
| 220 | 220 | ||
| 221 | 221 | ||
| 222 | /* initialise the display */ |
222 | /* initialise the display */ |
| Line 243... | Line 243... | ||
| 243 | 243 | ||
| 244 | chThdSleep(chTimeMS2I(10)); |
244 | chThdSleep(chTimeMS2I(10)); |
| 245 | 245 | ||
| 246 | } |
246 | } |
| 247 | 247 | ||
| 248 | - | ||
| 249 | // shell thread code . dead at present |
248 | // shell thread code . dead at present |
| 250 | // /* |
249 | // /* |
| 251 | // * Normal main() thread activity, spawning shells. |
250 | // * Normal main() thread activity, spawning shells. |
| 252 | // */ |
251 | // */ |
| 253 | // while (true) { |
252 | // while (true) { |
| 254 | // if (SDU1.config->usbp->state == USB_ACTIVE) { |
253 | // if (SDU1.config->usbp->state == USB_ACTIVE) { |
| 255 | // thread_t *shelltp = chThdCreateFromHeap(NULL, SHELL_WA_SIZE, |
254 | //o thread_t *shelltp = chThdCreateFromHeap(NULL, SHELL_WA_SIZE, |
| 256 | // "shell", NORMALPRIO + 1, |
255 | // "shell", NORMALPRIO + 1, |
| 257 | // shellThread, (void *)&shell_cfg1); |
256 | // shellThread, (void *)&shell_cfg1); |
| 258 | // chThdWait(shelltp); /* Waiting termination. */ |
257 | // chThdWait(shelltp); /* Waiting termination. */ |
| 259 | // } |
258 | // } |
| 260 | // chThdSleepMilliseconds(1000); |
259 | // chThdSleepMilliseconds(1000); |