1
0
mirror of git://projects.qi-hardware.com/antorcha.git synced 2024-11-01 09:24:05 +02:00

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.
This commit is contained in:
Werner Almesberger 2012-07-06 16:53:10 -03:00
parent ed19766266
commit a70caced48

View File

@ -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;
}
}
}