From b965b47d9b2bec92233647a6a74948f6026c2458 Mon Sep 17 00:00:00 2001 From: Jose Alamos Date: Mon, 7 Jan 2019 17:08:25 +0100 Subject: [PATCH 1/2] drivers/cc2420: move flush sequence to inline function --- drivers/cc2420/cc2420.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/cc2420/cc2420.c b/drivers/cc2420/cc2420.c index 69df2cfa52..d8e98fb18c 100644 --- a/drivers/cc2420/cc2420.c +++ b/drivers/cc2420/cc2420.c @@ -158,6 +158,12 @@ void cc2420_tx_exec(cc2420_t *dev) } } +static inline void _flush_rx_fifo(cc2420_t *dev) +{ + cc2420_strobe(dev, CC2420_STROBE_FLUSHRX); + cc2420_strobe(dev, CC2420_STROBE_FLUSHRX); +} + int cc2420_rx(cc2420_t *dev, uint8_t *buf, size_t max_len, void *info) { (void)info; @@ -202,8 +208,7 @@ int cc2420_rx(cc2420_t *dev, uint8_t *buf, size_t max_len, void *info) } /* finally flush the FIFO */ - cc2420_strobe(dev, CC2420_STROBE_FLUSHRX); - cc2420_strobe(dev, CC2420_STROBE_FLUSHRX); + _flush_rx_fifo(dev); } return (int)len; From 87e917264328af0ce022e69d72fda7652267e889 Mon Sep 17 00:00:00 2001 From: Jose Alamos Date: Mon, 7 Jan 2019 17:10:42 +0100 Subject: [PATCH 2/2] drivers/cc2420: add datasheet documentation to duplicated strobe call --- drivers/cc2420/cc2420.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/cc2420/cc2420.c b/drivers/cc2420/cc2420.c index d8e98fb18c..6fe3e764d8 100644 --- a/drivers/cc2420/cc2420.c +++ b/drivers/cc2420/cc2420.c @@ -160,6 +160,9 @@ void cc2420_tx_exec(cc2420_t *dev) static inline void _flush_rx_fifo(cc2420_t *dev) { + /* as stated in the CC2420 datasheet (section 14.3), the SFLUSHRX command + * strobe should be issued twice to ensure that the SFD pin goes back to its + * idle state */ cc2420_strobe(dev, CC2420_STROBE_FLUSHRX); cc2420_strobe(dev, CC2420_STROBE_FLUSHRX); }