Merge pull request #2071 from g-oikonomou/bugfix/cc13xx/no-acks

Make the number of Prop Mode RX Buffers easy to configure
This commit is contained in:
George Oikonomou 2017-01-21 00:17:49 +00:00 committed by GitHub
commit 7b7781360f
2 changed files with 40 additions and 31 deletions

View File

@ -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 };
@ -427,6 +436,24 @@ rf_cmd_prop_rx()
return ret;
}
/*---------------------------------------------------------------------------*/
static void
init_rx_buffers(void)
{
rfc_dataEntry_t *entry;
int i;
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];
}
((rfc_dataEntry_t *)rx_buf[PROP_MODE_RX_BUF_CNT - 1])->pNextEntry = rx_buf[0];
}
/*---------------------------------------------------------------------------*/
static int
rx_on_prop(void)
{
@ -564,8 +591,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) {
@ -575,29 +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);
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;
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;
@ -904,6 +914,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 +939,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 +958,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;
}
/*---------------------------------------------------------------------------*/

View File

@ -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