Re-initialise RX buffers each time we turn the RF on

This commit is contained in:
George Oikonomou 2016-10-23 02:31:53 +01:00
parent 82fd325b7a
commit ba12ed2cce

View file

@ -427,6 +427,26 @@ rf_cmd_prop_rx()
return ret; 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 static int
rx_on_prop(void) rx_on_prop(void)
{ {
@ -564,8 +584,6 @@ static const rf_core_primary_mode_t mode_prop = {
static int static int
init(void) init(void)
{ {
rfc_dataEntry_t *entry;
lpm_register_module(&prop_lpm_module); lpm_register_module(&prop_lpm_module);
if(ti_lib_chipinfo_chip_family_is_cc13xx() == false) { 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_0, 0, RX_BUF_SIZE);
memset(rx_buf_1, 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 */ /* 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; rx_data_queue.pLastEntry = NULL;
@ -904,6 +908,8 @@ on(void)
rf_core_setup_interrupts(false); rf_core_setup_interrupts(false);
init_rx_buffers();
/* /*
* Trigger a switch to the XOSC, so that we can subsequently use the RF FS * 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 * This will block until the XOSC is actually ready, but give how we
@ -927,8 +933,6 @@ on(void)
static int static int
off(void) off(void)
{ {
rfc_dataEntry_t *entry;
/* /*
* If we are in the middle of a BLE operation, we got called by ContikiMAC * 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. * 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 */ /* 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; 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; return RF_CORE_CMD_OK;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/