From ba12ed2ccec47339cbcf32be41e9bd9c148059e8 Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Sun, 23 Oct 2016 02:31:53 +0100 Subject: [PATCH 1/3] Re-initialise RX buffers each time we turn the RF on --- cpu/cc26xx-cc13xx/rf-core/prop-mode.c | 46 +++++++++++++-------------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/cpu/cc26xx-cc13xx/rf-core/prop-mode.c b/cpu/cc26xx-cc13xx/rf-core/prop-mode.c index 21e54c181..826a3d4cd 100644 --- a/cpu/cc26xx-cc13xx/rf-core/prop-mode.c +++ b/cpu/cc26xx-cc13xx/rf-core/prop-mode.c @@ -427,6 +427,26 @@ rf_cmd_prop_rx() return ret; } /*---------------------------------------------------------------------------*/ +static void +init_rx_buffers(void) +{ + rfc_dataEntry_t *entry; + + entry = (rfc_dataEntry_t *)rx_buf_0; + entry->status = DATA_ENTRY_STATUS_PENDING; + entry->config.type = DATA_ENTRY_TYPE_GEN; + entry->config.lenSz = DATA_ENTRY_LENSZ_WORD; + entry->length = RX_BUF_SIZE - 8; + entry->pNextEntry = rx_buf_1; + + entry = (rfc_dataEntry_t *)rx_buf_1; + entry->status = DATA_ENTRY_STATUS_PENDING; + entry->config.type = DATA_ENTRY_TYPE_GEN; + entry->config.lenSz = DATA_ENTRY_LENSZ_WORD; + entry->length = RX_BUF_SIZE - 8; + entry->pNextEntry = rx_buf_0; +} +/*---------------------------------------------------------------------------*/ static int rx_on_prop(void) { @@ -564,8 +584,6 @@ static const rf_core_primary_mode_t mode_prop = { static int init(void) { - rfc_dataEntry_t *entry; - lpm_register_module(&prop_lpm_module); if(ti_lib_chipinfo_chip_family_is_cc13xx() == false) { @@ -578,20 +596,6 @@ init(void) memset(rx_buf_0, 0, RX_BUF_SIZE); memset(rx_buf_1, 0, RX_BUF_SIZE); - entry = (rfc_dataEntry_t *)rx_buf_0; - entry->status = DATA_ENTRY_STATUS_PENDING; - entry->config.type = DATA_ENTRY_TYPE_GEN; - entry->config.lenSz = DATA_ENTRY_LENSZ_WORD; - entry->length = RX_BUF_SIZE - 8; - entry->pNextEntry = rx_buf_1; - - entry = (rfc_dataEntry_t *)rx_buf_1; - entry->status = DATA_ENTRY_STATUS_PENDING; - entry->config.type = DATA_ENTRY_TYPE_GEN; - entry->config.lenSz = DATA_ENTRY_LENSZ_WORD; - entry->length = RX_BUF_SIZE - 8; - entry->pNextEntry = rx_buf_0; - /* Set of RF Core data queue. Circular buffer, no last entry */ rx_data_queue.pCurrEntry = rx_buf_0; rx_data_queue.pLastEntry = NULL; @@ -904,6 +908,8 @@ on(void) rf_core_setup_interrupts(false); + init_rx_buffers(); + /* * Trigger a switch to the XOSC, so that we can subsequently use the RF FS * This will block until the XOSC is actually ready, but give how we @@ -927,8 +933,6 @@ on(void) static int off(void) { - rfc_dataEntry_t *entry; - /* * If we are in the middle of a BLE operation, we got called by ContikiMAC * from within an interrupt context. Abort, but pretend everything is OK. @@ -948,12 +952,6 @@ off(void) /* We pulled the plug, so we need to restore the status manually */ smartrf_settings_cmd_prop_rx_adv.status = RF_CORE_RADIO_OP_STATUS_IDLE; - entry = (rfc_dataEntry_t *)rx_buf_0; - entry->status = DATA_ENTRY_STATUS_PENDING; - - entry = (rfc_dataEntry_t *)rx_buf_1; - entry->status = DATA_ENTRY_STATUS_PENDING; - return RF_CORE_CMD_OK; } /*---------------------------------------------------------------------------*/ From 07de8b238ba19b07293c6a1563d11fc245b3dfe0 Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Sat, 10 Dec 2016 22:05:09 +0000 Subject: [PATCH 2/3] Easy manipulation of CC13xx Prop Mode RX buffers --- cpu/cc26xx-cc13xx/rf-core/prop-mode.c | 44 +++++++++++++++------------ 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/cpu/cc26xx-cc13xx/rf-core/prop-mode.c b/cpu/cc26xx-cc13xx/rf-core/prop-mode.c index 826a3d4cd..6264ebf61 100644 --- a/cpu/cc26xx-cc13xx/rf-core/prop-mode.c +++ b/cpu/cc26xx-cc13xx/rf-core/prop-mode.c @@ -219,14 +219,23 @@ const output_config_t *tx_power_current = &output_power[1]; #define PROP_MODE_LO_DIVIDER 0x05 #endif /*---------------------------------------------------------------------------*/ +#ifdef PROP_MODE_CONF_RX_BUF_CNT +#define PROP_MODE_RX_BUF_CNT PROP_MODE_CONF_RX_BUF_CNT +#else +#define PROP_MODE_RX_BUF_CNT 4 +#endif +/*---------------------------------------------------------------------------*/ #define DATA_ENTRY_LENSZ_NONE 0 #define DATA_ENTRY_LENSZ_BYTE 1 #define DATA_ENTRY_LENSZ_WORD 2 /* 2 bytes */ +/* + * RX buffers. + * PROP_MODE_RX_BUF_CNT buffers of RX_BUF_SIZE bytes each. The start of each + * buffer must be 4-byte aligned, therefore RX_BUF_SIZE must divide by 4 + */ #define RX_BUF_SIZE 140 -/* Receive buffers: 1 frame in each */ -static uint8_t rx_buf_0[RX_BUF_SIZE] CC_ALIGN(4); -static uint8_t rx_buf_1[RX_BUF_SIZE] CC_ALIGN(4); +static uint8_t rx_buf[PROP_MODE_RX_BUF_CNT][RX_BUF_SIZE] CC_ALIGN(4); /* The RX Data Queue */ static dataQueue_t rx_data_queue = { 0 }; @@ -431,20 +440,18 @@ static void init_rx_buffers(void) { rfc_dataEntry_t *entry; + int i; - entry = (rfc_dataEntry_t *)rx_buf_0; - entry->status = DATA_ENTRY_STATUS_PENDING; - entry->config.type = DATA_ENTRY_TYPE_GEN; - entry->config.lenSz = DATA_ENTRY_LENSZ_WORD; - entry->length = RX_BUF_SIZE - 8; - entry->pNextEntry = rx_buf_1; + for(i = 0; i < PROP_MODE_RX_BUF_CNT; i++) { + entry = (rfc_dataEntry_t *)rx_buf[i]; + entry->status = DATA_ENTRY_STATUS_PENDING; + entry->config.type = DATA_ENTRY_TYPE_GEN; + entry->config.lenSz = DATA_ENTRY_LENSZ_WORD; + entry->length = RX_BUF_SIZE - 8; + entry->pNextEntry = rx_buf[i + 1]; + } - entry = (rfc_dataEntry_t *)rx_buf_1; - entry->status = DATA_ENTRY_STATUS_PENDING; - entry->config.type = DATA_ENTRY_TYPE_GEN; - entry->config.lenSz = DATA_ENTRY_LENSZ_WORD; - entry->length = RX_BUF_SIZE - 8; - entry->pNextEntry = rx_buf_0; + ((rfc_dataEntry_t *)rx_buf[PROP_MODE_RX_BUF_CNT - 1])->pNextEntry = rx_buf[0]; } /*---------------------------------------------------------------------------*/ static int @@ -593,15 +600,14 @@ init(void) rf_core_set_modesel(); /* Initialise RX buffers */ - memset(rx_buf_0, 0, RX_BUF_SIZE); - memset(rx_buf_1, 0, RX_BUF_SIZE); + memset(rx_buf, 0, sizeof(rx_buf)); /* Set of RF Core data queue. Circular buffer, no last entry */ - rx_data_queue.pCurrEntry = rx_buf_0; + rx_data_queue.pCurrEntry = rx_buf[0]; rx_data_queue.pLastEntry = NULL; /* Initialize current read pointer to first element (used in ISR) */ - rx_read_entry = rx_buf_0; + rx_read_entry = rx_buf[0]; smartrf_settings_cmd_prop_rx_adv.pQueue = &rx_data_queue; smartrf_settings_cmd_prop_rx_adv.pOutput = (uint8_t *)&rx_stats; From 5fb226f4c94786196221005638f5fa374bc1e3ec Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Sun, 15 Jan 2017 12:30:56 +0000 Subject: [PATCH 3/3] Make the count of prop mode RX buffers configurable --- platform/srf06-cc26xx/contiki-conf.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/platform/srf06-cc26xx/contiki-conf.h b/platform/srf06-cc26xx/contiki-conf.h index 85c99ee19..7eeb7be4d 100644 --- a/platform/srf06-cc26xx/contiki-conf.h +++ b/platform/srf06-cc26xx/contiki-conf.h @@ -93,6 +93,11 @@ #define RF_CORE_CONF_CHANNEL RF_CHANNEL #endif +/* Number of Prop Mode RX buffers */ +#ifndef PROP_MODE_CONF_RX_BUF_CNT +#define PROP_MODE_CONF_RX_BUF_CNT 4 +#endif + /* * Auto-configure Prop-mode radio if we are running on CC13xx, unless the * project has specified otherwise. Depending on the final mode, determine a