# HG changeset patch # User David Douard # Date 1631217593 -7200 # Node ID f71f6c0af3cd8be150f9c855f3cf03f2a93d8c19 # Parent 55e3b4441b113c2e334ca754be8f32328d53a06b Simplify a bit the rst logic and make a bit more robust diff -r 55e3b4441b11 -r f71f6c0af3cd src/main.cpp --- a/src/main.cpp Thu Sep 09 21:49:16 2021 +0200 +++ b/src/main.cpp Thu Sep 09 21:59:53 2021 +0200 @@ -29,7 +29,7 @@ HPSerial *hp; Thread tdsp(osPriorityNormal, OS_STACK_SIZE, nullptr, "DSP"); Ticker dsp_refresh; -Timeout rst_delay; +//Timeout rst_delay; Timeout splashscreen_timer; Timeout byescreen_timer; InterruptIn rst(HP_RST); @@ -235,21 +235,22 @@ void end_splashscreen(void) { - // print is forbidden here because we are in an ISR context here - //printf("End of splash screen CB\r\n"); splashscreen = false; - dsp->cls(); - dsp->power_off(); + // wait for the reset irq from the CPU board + must_shutdown = true; } +/* void reset_irq_tmr(void) { must_reset = true; } +*/ void reset_irq(void) { - rst_delay.attach(callback(&reset_irq_tmr), 50ms); + must_reset = true; + //rst_delay.attach(callback(&reset_irq_tmr), 50ms); } void reset(void) @@ -258,13 +259,13 @@ printf("Reset connection to the main unit\n"); if (DigitalIn(HP_RST).read() == 0) { byescreen_timer.detach(); // cancel a "poweroff", if any + splashscreen_timer.detach(); // same for splashscreen splashscreen = false; // in case it still on if (hp == NULL) { printf("setup HP communication handler\r\n"); hp = new HPSerial(HP_TX, HP_RX); - } - else { + } else { printf("Connection already initialized\n"); } @@ -274,10 +275,12 @@ dsp->power_on(); dsp->cls(); printf("Initiate startup sequence\n"); - if (last_key.keyevent == KEY_PRESSED) + if (last_key.keyevent == KEY_PRESSED) { + printf(" with key pressed\n"); hp->send_startup_seq(kp_mapping[last_key.row][last_key.col]); - else + } else { hp->send_startup_seq(); + } } else { @@ -310,10 +313,13 @@ while(1) { if (must_reset) { must_reset = false; + must_shutdown = false; // just in case... reset(); } + if (must_shutdown) { must_shutdown = false; + dsp->cls(); dsp->power_off(); }