|
@@ -82,25 +82,29 @@ void |
|
|
rxdone(uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr) |
|
|
rxdone(uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr) |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
if (rxpktavail) { |
|
|
|
|
|
memcpy(rxpkt, payload, MIN(sizeof rxpkt, size)); |
|
|
|
|
|
|
|
|
if (rxpktavail && size <= sizeof rxpkt) { |
|
|
|
|
|
memcpy(rxpkt, payload, size); |
|
|
rxpktbuf = (struct pktbuf){ |
|
|
rxpktbuf = (struct pktbuf){ |
|
|
.pkt = rxpkt, |
|
|
.pkt = rxpkt, |
|
|
.pktlen = size, |
|
|
.pktlen = size, |
|
|
}; |
|
|
}; |
|
|
rxpktavail = false; |
|
|
rxpktavail = false; |
|
|
} |
|
|
} |
|
|
|
|
|
Radio.Rx(0); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void |
|
|
void |
|
|
rxtimeout(void) |
|
|
rxtimeout(void) |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
Radio.Rx(0); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void |
|
|
void |
|
|
rxerr(void) |
|
|
rxerr(void) |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
Radio.Rx(0); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
RadioEvents_t revents = { |
|
|
RadioEvents_t revents = { |
|
@@ -225,16 +229,26 @@ start_sched(struct sched *sched) |
|
|
set_chan(sched->chan, 1); |
|
|
set_chan(sched->chan, 1); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static void |
|
|
|
|
|
process_sched() |
|
|
|
|
|
|
|
|
static bool |
|
|
|
|
|
canproc_sched() |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
/* nothing to do? */ |
|
|
/* nothing to do? */ |
|
|
if (schedcnt == 0) |
|
|
if (schedcnt == 0) |
|
|
return; |
|
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
/* not yet expired */ |
|
|
/* not yet expired */ |
|
|
if (uwTick < SCHED_HEAD.end_wait_tick) |
|
|
if (uwTick < SCHED_HEAD.end_wait_tick) |
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void |
|
|
|
|
|
process_sched() |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
if (!canproc_sched()) |
|
|
return; |
|
|
return; |
|
|
|
|
|
|
|
|
if (SCHED_HEAD.cmd == CMD_RUNFOR) |
|
|
if (SCHED_HEAD.cmd == CMD_RUNFOR) |
|
@@ -390,7 +404,8 @@ main() |
|
|
//Radio.Rx(0); |
|
|
//Radio.Rx(0); |
|
|
|
|
|
|
|
|
loop: |
|
|
loop: |
|
|
process_sched(); |
|
|
|
|
|
|
|
|
while (canproc_sched()) |
|
|
|
|
|
process_sched(); |
|
|
|
|
|
|
|
|
BoardLowPowerHandler(); |
|
|
BoardLowPowerHandler(); |
|
|
if (Radio.IrqProcess != NULL) |
|
|
if (Radio.IrqProcess != NULL) |
|
|