27 Display *dsp; |
27 Display *dsp; |
28 volatile bool splashscreen; |
28 volatile bool splashscreen; |
29 HPSerial *hp; |
29 HPSerial *hp; |
30 Thread tdsp(osPriorityNormal, OS_STACK_SIZE, nullptr, "DSP"); |
30 Thread tdsp(osPriorityNormal, OS_STACK_SIZE, nullptr, "DSP"); |
31 Ticker dsp_refresh; |
31 Ticker dsp_refresh; |
32 Timeout rst_delay; |
32 //Timeout rst_delay; |
33 Timeout splashscreen_timer; |
33 Timeout splashscreen_timer; |
34 Timeout byescreen_timer; |
34 Timeout byescreen_timer; |
35 InterruptIn rst(HP_RST); |
35 InterruptIn rst(HP_RST); |
36 |
36 |
37 QEI qenc(KP_ENC1, KP_ENC2, NC, 16); |
37 QEI qenc(KP_ENC1, KP_ENC2, NC, 16); |
233 printf("SETUP DONE\r\n"); |
233 printf("SETUP DONE\r\n"); |
234 } |
234 } |
235 |
235 |
236 void end_splashscreen(void) |
236 void end_splashscreen(void) |
237 { |
237 { |
238 // print is forbidden here because we are in an ISR context here |
|
239 //printf("End of splash screen CB\r\n"); |
|
240 splashscreen = false; |
238 splashscreen = false; |
241 dsp->cls(); |
239 // wait for the reset irq from the CPU board |
242 dsp->power_off(); |
240 must_shutdown = true; |
243 } |
241 } |
244 |
242 |
|
243 /* |
245 void reset_irq_tmr(void) |
244 void reset_irq_tmr(void) |
246 { |
245 { |
247 must_reset = true; |
246 must_reset = true; |
248 } |
247 } |
|
248 */ |
249 |
249 |
250 void reset_irq(void) |
250 void reset_irq(void) |
251 { |
251 { |
252 rst_delay.attach(callback(&reset_irq_tmr), 50ms); |
252 must_reset = true; |
|
253 //rst_delay.attach(callback(&reset_irq_tmr), 50ms); |
253 } |
254 } |
254 |
255 |
255 void reset(void) |
256 void reset(void) |
256 { |
257 { |
257 // this should be called as a result of the HP_RST pin going LO |
258 // this should be called as a result of the HP_RST pin going LO |
258 printf("Reset connection to the main unit\n"); |
259 printf("Reset connection to the main unit\n"); |
259 if (DigitalIn(HP_RST).read() == 0) { |
260 if (DigitalIn(HP_RST).read() == 0) { |
260 byescreen_timer.detach(); // cancel a "poweroff", if any |
261 byescreen_timer.detach(); // cancel a "poweroff", if any |
|
262 splashscreen_timer.detach(); // same for splashscreen |
261 splashscreen = false; // in case it still on |
263 splashscreen = false; // in case it still on |
262 |
264 |
263 if (hp == NULL) { |
265 if (hp == NULL) { |
264 printf("setup HP communication handler\r\n"); |
266 printf("setup HP communication handler\r\n"); |
265 hp = new HPSerial(HP_TX, HP_RX); |
267 hp = new HPSerial(HP_TX, HP_RX); |
266 } |
268 } else { |
267 else { |
|
268 printf("Connection already initialized\n"); |
269 printf("Connection already initialized\n"); |
269 } |
270 } |
270 |
271 |
271 printf("!! RST !! (gstate=%d, state=%d)\r\n", |
272 printf("!! RST !! (gstate=%d, state=%d)\r\n", |
272 hp->gstate(), hp->state()); |
273 hp->gstate(), hp->state()); |
273 //printf("Value is ... %X\n", hp->search()); |
274 //printf("Value is ... %X\n", hp->search()); |
274 dsp->power_on(); |
275 dsp->power_on(); |
275 dsp->cls(); |
276 dsp->cls(); |
276 printf("Initiate startup sequence\n"); |
277 printf("Initiate startup sequence\n"); |
277 if (last_key.keyevent == KEY_PRESSED) |
278 if (last_key.keyevent == KEY_PRESSED) { |
|
279 printf(" with key pressed\n"); |
278 hp->send_startup_seq(kp_mapping[last_key.row][last_key.col]); |
280 hp->send_startup_seq(kp_mapping[last_key.row][last_key.col]); |
279 else |
281 } else { |
280 hp->send_startup_seq(); |
282 hp->send_startup_seq(); |
|
283 } |
281 } |
284 } |
282 else |
285 else |
283 { |
286 { |
284 printf("HP_RST is not LOW, skipping\n"); |
287 printf("HP_RST is not LOW, skipping\n"); |
285 } |
288 } |