From a70caced48b2459ec59b3753179a384b01234bef Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Fri, 6 Jul 2012 16:53:10 -0300 Subject: [PATCH] fw/antorcha.c (main): reset the RF subsystem if it's idle for ~1 second For some reason, DIAG often stalls the RF subsystem. The periodic reset brings it back to life. --- fw/antorcha.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/fw/antorcha.c b/fw/antorcha.c index 38e5cb7..7e326ae 100644 --- a/fw/antorcha.c +++ b/fw/antorcha.c @@ -122,6 +122,7 @@ int main(void) { uint8_t buf[PAYLOAD+5]; /* 3 bytes header, 2 bytes CRC */ uint8_t got; + uint32_t idle = 0; /* * The boot loader has already initialized PORTx, DDRx, and MCUCR.PUD. @@ -135,8 +136,10 @@ int main(void) while (1) { got = rf_recv(buf, sizeof(buf)); - if (got > 2) + if (got > 2) { dispatch(buf, got-2, protos); + idle = 0; + } if (wake && !sweeping) { wake = 0; if (state == LEFT) @@ -144,5 +147,10 @@ int main(void) else if (state == RIGHT) submit_bwd_sweep(); } + /* about 1 Hz */ + if (++idle == 100000) { + rf_init(); + idle = 0; + } } }