From ae790611827445d19a3ba7cd072db8b30dd878c7 Mon Sep 17 00:00:00 2001 From: Harald Pichler Date: Fri, 23 Sep 2016 14:59:30 +0200 Subject: [PATCH] bugfix powercyle and sleep mcu timing --- core/net/mac/contikimac/contikimac.c | 5 ++--- cpu/avr/radio/rf230bb/rf230bb.c | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/core/net/mac/contikimac/contikimac.c b/core/net/mac/contikimac/contikimac.c index 7912fe7dd..3c3e76429 100644 --- a/core/net/mac/contikimac/contikimac.c +++ b/core/net/mac/contikimac/contikimac.c @@ -502,10 +502,9 @@ powercycle(struct rtimer *t, void *ptr) ensure an occasional wake cycle or foreground processing will be blocked until a packet is detected */ #if RDC_CONF_MCU_SLEEP - static uint8_t sleepcycle; - if((sleepcycle++ < mcusleepcycle) && !we_are_sending && !radio_is_on) { - rtimer_arch_sleep(RTIMER_NOW() - cycle_start); + if((sleepcycle++ < mcusleepcycle) && !we_are_sending && !radio_is_on && !(NETSTACK_RADIO.receiving_packet() || NETSTACK_RADIO.pending_packet())) { + rtimer_arch_sleep(cycle_start - RTIMER_NOW()); } else { sleepcycle = 0; #ifndef RDC_CONF_PT_YIELD_OFF diff --git a/cpu/avr/radio/rf230bb/rf230bb.c b/cpu/avr/radio/rf230bb/rf230bb.c index 624018f36..6f5c5e47d 100644 --- a/cpu/avr/radio/rf230bb/rf230bb.c +++ b/cpu/avr/radio/rf230bb/rf230bb.c @@ -1796,8 +1796,8 @@ rf230_cca(void) // if (cca & 0x40) {/*DEBUGFLOW('3')*/;} else {rf230_pending=1;DEBUGFLOW('4');} if (cca & 0x40) { // DEBUGFLOW('5'); -// return 1; - return 0; + return 1; +// return 0; } else { // DEBUGFLOW('6'); busyexit: