mirror of
https://github.com/apache/nuttx.git
synced 2026-03-27 02:29:15 +08:00
drivers/wireless: Run all wireless drivers through tools/nxstyle, correcting as many complaints as possible.
This commit is contained in:
@@ -102,7 +102,7 @@
|
||||
* necessary to process pending interrupts whenever interrupts are re-enabled.
|
||||
*/
|
||||
|
||||
/****************************************************************************
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
@@ -401,7 +401,7 @@ static const struct spirit_pktstack_init_s g_pktstack_init =
|
||||
SPIRIT_CONTROL_LENGTH, /* ctrllen selected in board.h */
|
||||
SPIRIT_EN_FEC, /* fec selected in board.h */
|
||||
SPIRIT_EN_WHITENING /* datawhite selected in board.h */
|
||||
};
|
||||
};
|
||||
|
||||
/* LLP Configuration */
|
||||
|
||||
@@ -713,13 +713,13 @@ static void spirit_free_txhead(FAR struct spirit_driver_s *priv)
|
||||
priv->txtail = NULL;
|
||||
}
|
||||
|
||||
/* Free the IOB contained in the metadata container */
|
||||
/* Free the IOB contained in the metadata container */
|
||||
|
||||
iob_free(pktmeta->pm_iob, IOBUSER_WIRELESS_PACKETRADIO);
|
||||
iob_free(pktmeta->pm_iob, IOBUSER_WIRELESS_PACKETRADIO);
|
||||
|
||||
/* Then free the meta data container itself */
|
||||
/* Then free the meta data container itself */
|
||||
|
||||
pktradio_metadata_free(pktmeta);
|
||||
pktradio_metadata_free(pktmeta);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -1157,6 +1157,7 @@ static void spirit_interrupt_work(FAR void *arg)
|
||||
wlinfo("Pending: %08lx\n", *(FAR unsigned long *)&irqstatus);
|
||||
|
||||
/* Process the Spirit1 interrupt */
|
||||
|
||||
/* First check for errors */
|
||||
|
||||
if (irqstatus.IRQ_RX_FIFO_ERROR != 0)
|
||||
@@ -1439,18 +1440,18 @@ static void spirit_interrupt_work(FAR void *arg)
|
||||
* must be done on the LP worker thread with the network locked.
|
||||
*/
|
||||
|
||||
pktmeta = pktradio_metadata_allocate();
|
||||
if (pktmeta == NULL)
|
||||
{
|
||||
wlerr("ERROR: Failed to allocate metadata... dropping\n");
|
||||
NETDEV_RXDROPPED(&priv->radio.r_dev);
|
||||
iob_free(iob, IOBUSER_WIRELESS_PACKETRADIO);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Get the packet meta data. This consists only of the
|
||||
* source and destination addresses.
|
||||
*/
|
||||
pktmeta = pktradio_metadata_allocate();
|
||||
if (pktmeta == NULL)
|
||||
{
|
||||
wlerr("ERROR: Failed to allocate metadata... dropping\n");
|
||||
NETDEV_RXDROPPED(&priv->radio.r_dev);
|
||||
iob_free(iob, IOBUSER_WIRELESS_PACKETRADIO);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Get the packet meta data. This consists only of the
|
||||
* source and destination addresses.
|
||||
*/
|
||||
|
||||
pktmeta->pm_iob = iob;
|
||||
|
||||
@@ -1964,7 +1965,7 @@ static int spirit_ifup(FAR struct net_driver_s *dev)
|
||||
/* We are up! */
|
||||
|
||||
priv->ifup = true;
|
||||
}
|
||||
}
|
||||
|
||||
return OK;
|
||||
|
||||
@@ -2352,24 +2353,24 @@ static int spirit_req_data(FAR struct radio_driver_s *netdev,
|
||||
* IEEE 802.15.4 works.
|
||||
*/
|
||||
|
||||
pktmeta = pktradio_metadata_allocate();
|
||||
if (pktmeta == NULL)
|
||||
{
|
||||
wlerr("ERROR: Failed to allocate metadata... dropping\n");
|
||||
NETDEV_RXDROPPED(&priv->radio.r_dev);
|
||||
iob_free(iob, IOBUSER_WIRELESS_PACKETRADIO);
|
||||
continue;
|
||||
}
|
||||
pktmeta = pktradio_metadata_allocate();
|
||||
if (pktmeta == NULL)
|
||||
{
|
||||
wlerr("ERROR: Failed to allocate metadata... dropping\n");
|
||||
NETDEV_RXDROPPED(&priv->radio.r_dev);
|
||||
iob_free(iob, IOBUSER_WIRELESS_PACKETRADIO);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Save the IOB and addressing information in the newly allocated
|
||||
* container.
|
||||
*/
|
||||
/* Save the IOB and addressing information in the newly allocated
|
||||
* container.
|
||||
*/
|
||||
|
||||
memcpy(&pktmeta->pm_src, &metain->pm_src,
|
||||
sizeof(struct pktradio_addr_s));
|
||||
memcpy(&pktmeta->pm_dest, &metain->pm_dest,
|
||||
sizeof(struct pktradio_addr_s));
|
||||
pktmeta->pm_iob = iob;
|
||||
memcpy(&pktmeta->pm_src, &metain->pm_src,
|
||||
sizeof(struct pktradio_addr_s));
|
||||
memcpy(&pktmeta->pm_dest, &metain->pm_dest,
|
||||
sizeof(struct pktradio_addr_s));
|
||||
pktmeta->pm_iob = iob;
|
||||
|
||||
/* Add the IOB container to tail of the queue of outgoing IOBs. */
|
||||
|
||||
@@ -2522,7 +2523,7 @@ int spirit_hw_initialize(FAR struct spirit_driver_s *priv,
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret =spirit_radio_set_palevel_maxindex(spirit, 0);
|
||||
ret = spirit_radio_set_palevel_maxindex(spirit, 0);
|
||||
if (ret < 0)
|
||||
{
|
||||
wlerr("ERROR: spirit_radio_set_palevel_maxindex failed: %d\n", ret);
|
||||
@@ -2595,7 +2596,7 @@ int spirit_hw_initialize(FAR struct spirit_driver_s *priv,
|
||||
}
|
||||
|
||||
ret = spirit_irq_enable(spirit, TX_DATA_SENT, S_ENABLE);
|
||||
if (ret < 0)
|
||||
if (ret < 0)
|
||||
{
|
||||
wlerr("ERROR: Enable TX_DATA_SENT failed: %d\n", ret);
|
||||
return ret;
|
||||
@@ -2790,7 +2791,6 @@ int spirit_hw_initialize(FAR struct spirit_driver_s *priv,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
int spirit_netdev_initialize(FAR struct spi_dev_s *spi,
|
||||
FAR const struct spirit_lower_s *lower)
|
||||
{
|
||||
|
||||
@@ -246,10 +246,11 @@ int spirit_aes_write_key(FAR struct spirit_library_s *spirit,
|
||||
*
|
||||
* Input Parameters:
|
||||
* spirit - Reference to a Spirit library state structure instance
|
||||
* key pointer to the buffer of 4 words (16 bytes) containing the AES key.
|
||||
* The first byte of the buffer shall be the most significant byte AES_KEY_0 of the AES key.
|
||||
* The last byte of the buffer shall be the less significant byte AES_KEY_15 of the AES key.
|
||||
* This parameter is an uint8_t*.
|
||||
* key - Pointer to the buffer of 4 words (16 bytes) containing the AES
|
||||
* key. The first byte of the buffer shall be the most
|
||||
* significant byte AES_KEY_0 of the AES key.
|
||||
* The last byte of the buffer shall be the less significant byte
|
||||
* AES_KEY_15 of the AES key. This parameter is an uint8_t*.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; a negated errno value on any failure.
|
||||
|
||||
@@ -226,7 +226,7 @@ int spirit_calibration_get_rcocal(FAR struct spirit_library_s *spirit,
|
||||
|
||||
/* Build the RFB value */
|
||||
|
||||
(*rfb) = (regval[0] & 0x0F) << 1 | (regval[1] >> 7);
|
||||
(*rfb) = (regval[0] & 0x0f) << 1 | (regval[1] >> 7);
|
||||
}
|
||||
|
||||
return ret;
|
||||
@@ -461,7 +461,8 @@ int spirit_calibration_set_vcowin(FAR struct spirit_library_s *spirit,
|
||||
enum spirit_vcowin_e
|
||||
spirit_calibration_get_vcowin(FAR struct spirit_library_s *spirit)
|
||||
{
|
||||
uint8_t regval1, regval2;
|
||||
uint8_t regval1;
|
||||
uint8_t regval2;
|
||||
enum spirit_vcowin_e refword;
|
||||
|
||||
/* Reads the register containing the REFWORD value */
|
||||
@@ -525,7 +526,6 @@ enum spirit_vcowin_e
|
||||
case 3:
|
||||
refword = CALIB_TIME_58_67_US_24MHZ;
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -183,7 +183,7 @@ int spirit_csma_getinfo(FAR struct spirit_library_s *spirit,
|
||||
|
||||
/* Reads the Cca length */
|
||||
|
||||
csmainit->ccalen = (enum spirit_csmalen_e) (regval[3] & 0xF0);
|
||||
csmainit->ccalen = (enum spirit_csmalen_e) (regval[3] & 0xf0);
|
||||
|
||||
/* Reads the max number of back off */
|
||||
|
||||
|
||||
@@ -458,9 +458,10 @@ enum gm_conf_e spirit_general_get_xogm(FAR struct spirit_library_s *spirit)
|
||||
(void)spirit_reg_read(spirit, ANA_FUNC_CONF1_BASE, ®val, 1);
|
||||
|
||||
/* Mask the GM_CONF field field and returns the settled transconductance of
|
||||
* the XO at startup */
|
||||
* the XO at startup.
|
||||
*/
|
||||
|
||||
return ((enum gm_conf_e) ((regval & 0x1C) >> 2));
|
||||
return ((enum gm_conf_e) ((regval & 0x1c) >> 2));
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
|
||||
@@ -108,7 +108,8 @@ int spirit_gpio_enable_tempsensor(FAR struct spirit_library_s *spirit,
|
||||
DEBUGASSERT(IS_SPIRIT_FUNCTIONAL_STATE(newstate));
|
||||
|
||||
/* Reads the ANA_FUNC_CONF0 register and mask the result to enable or disable
|
||||
* the temperature sensor */
|
||||
* the temperature sensor.
|
||||
*/
|
||||
|
||||
ret = spirit_reg_read(spirit, ANA_FUNC_CONF0_BASE, ®val, 1);
|
||||
if (ret >= 0)
|
||||
@@ -280,7 +281,8 @@ int spirit_gpio_enable_clockoutput(FAR struct spirit_library_s *spirit,
|
||||
DEBUGASSERT(IS_SPIRIT_FUNCTIONAL_STATE(newstate));
|
||||
|
||||
/* Reads the MCU_CK_CONF register and mask the result to enable or disable
|
||||
* the clock output */
|
||||
* the clock output.
|
||||
*/
|
||||
|
||||
ret = spirit_reg_read(spirit, MCU_CK_CONF_BASE, ®val, 1);
|
||||
if (ret >= 0)
|
||||
@@ -335,7 +337,8 @@ int spirit_gpio_clockoutput_initialize(FAR struct spirit_library_s *spirit,
|
||||
DEBUGASSERT(IS_SPIRIT_CLOCK_OUTPUT_EXTRA_CYCLES(clockoutput->xtracycles));
|
||||
|
||||
/* Calculates the register value to write according to the specified
|
||||
* configuration */
|
||||
* configuration.
|
||||
*/
|
||||
|
||||
regval = ((uint8_t)(clockoutput->xoprescaler) |
|
||||
(uint8_t)(clockoutput->rcoprescaler) |
|
||||
@@ -529,9 +532,9 @@ int spirit_gpio_set_extracycles(FAR struct spirit_library_s *spirit,
|
||||
regval &= 0x9f;
|
||||
regval |= (uint8_t)xtracycles;
|
||||
|
||||
/* Write to the new number of extra clock cycles in the MCU_CLOCK
|
||||
* register.
|
||||
*/
|
||||
/* Write to the new number of extra clock cycles in the MCU_CLOCK
|
||||
* register.
|
||||
*/
|
||||
|
||||
ret = spirit_reg_write(spirit, MCU_CK_CONF_BASE, ®val, 1);
|
||||
}
|
||||
|
||||
@@ -64,7 +64,10 @@
|
||||
|
||||
int spirit_irq_disable_all(FAR struct spirit_library_s *spirit)
|
||||
{
|
||||
uint8_t regval[4] = { 0x00, 0x00, 0x00, 0x00 };
|
||||
uint8_t regval[4] =
|
||||
{
|
||||
0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
/* Writes the IRQ_MASK registers */
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ uint8_t spirit_fifo_get_txcount(FAR struct spirit_library_s *spirit)
|
||||
|
||||
/* Build and return value */
|
||||
|
||||
return (regval & 0x7F);
|
||||
return (regval & 0x7f);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
@@ -310,7 +310,7 @@ uint8_t spirit_fifo_get_txalmostfull(FAR struct spirit_library_s *spirit)
|
||||
|
||||
/* Build and returns value */
|
||||
|
||||
return (regval & 0x7F);
|
||||
return (regval & 0x7f);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
|
||||
@@ -478,7 +478,7 @@ int spirit_management_txstrobe(FAR struct spirit_library_s *spirit)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Enable VCO_L buffer */
|
||||
/* Enable VCO_L buffer */
|
||||
|
||||
tmp = 0x11;
|
||||
ret = spirit_reg_write(spirit, 0xa9, &tmp, 1);
|
||||
|
||||
@@ -483,19 +483,19 @@ int spirit_pktbasic_set_format(FAR struct spirit_library_s *spirit)
|
||||
|
||||
if (ret >= 0)
|
||||
{
|
||||
/* Reads the PROTOCOL1 register */
|
||||
/* Reads the PROTOCOL1 register */
|
||||
|
||||
ret = spirit_reg_read(spirit, PROTOCOL1_BASE, ®val, 1);
|
||||
if (ret >= 0)
|
||||
{
|
||||
/* Mask a reserved bit */
|
||||
ret = spirit_reg_read(spirit, PROTOCOL1_BASE, ®val, 1);
|
||||
if (ret >= 0)
|
||||
{
|
||||
/* Mask a reserved bit */
|
||||
|
||||
regval &= ~0x20;
|
||||
regval &= ~0x20;
|
||||
|
||||
/* Write the value to the register */
|
||||
/* Write the value to the register */
|
||||
|
||||
ret = spirit_reg_write(spirit, PROTOCOL1_BASE, ®val, 1);
|
||||
}
|
||||
ret = spirit_reg_write(spirit, PROTOCOL1_BASE, ®val, 1);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
@@ -628,7 +628,8 @@ int spirit_pktcommon_set_syncword(FAR struct spirit_library_s *spirit,
|
||||
uint8_t spirit_pktcommon_get_syncword(FAR struct spirit_library_s *spirit,
|
||||
enum spirit_pktsyncword_e syncwordno)
|
||||
{
|
||||
uint8_t regaddr, regval;
|
||||
uint8_t regaddr;
|
||||
uint8_t regval;
|
||||
|
||||
/* Check the parameters */
|
||||
|
||||
@@ -2020,7 +2021,7 @@ int spirit_pktcommon_enable_ctrl_filter(FAR struct spirit_library_s *spirit,
|
||||
else
|
||||
{
|
||||
regval &= ~PCKT_FLT_OPTIONS_CONTROL_FILTERING_MASK;
|
||||
}
|
||||
}
|
||||
|
||||
/* Write the new value to the PCKT_FLT_OPTIONS register */
|
||||
|
||||
|
||||
@@ -123,7 +123,7 @@ int spirit_pktmbus_get_setup(FAR struct spirit_library_s *spirit,
|
||||
|
||||
mbusinit->preamblen = regval[0];
|
||||
mbusinit->postamblen = regval[1];
|
||||
mbusinit->submode = (enum spirit_mbus_submode_e) (regval[2] & 0x0E);
|
||||
mbusinit->submode = (enum spirit_mbus_submode_e) (regval[2] & 0x0e);
|
||||
}
|
||||
|
||||
return ret;
|
||||
@@ -158,7 +158,7 @@ int spirit_pktmbus_set_format(FAR struct spirit_library_s *spirit)
|
||||
|
||||
/* Sets format bits. Also set to 0 the direct RX mode bits */
|
||||
|
||||
regval &= 0x0F;
|
||||
regval &= 0x0f;
|
||||
regval |= ((uint8_t) PCKTCTRL3_PCKT_FRMT_MBUS);
|
||||
|
||||
/* Writes value on the PCKTCTRL3 register */
|
||||
|
||||
@@ -130,7 +130,8 @@ int spirit_pktstack_initialize(FAR struct spirit_library_s *spirit,
|
||||
}
|
||||
|
||||
/* Address and control length setting: source and destination address are
|
||||
* always present so ADDRESS_LENGTH=2 */
|
||||
* always present so ADDRESS_LENGTH=2.
|
||||
*/
|
||||
|
||||
regval[0] = 0x10 | (uint8_t)pktstack->ctrllen;
|
||||
|
||||
@@ -479,7 +480,7 @@ int spirit_pktstack_llp_initialize(FAR struct spirit_library_s *spirit,
|
||||
regval[1] &= ~PROTOCOL0_NMAX_RETX_MASK;
|
||||
regval[1] |= llpinit->maxretx;
|
||||
|
||||
/* Write registers */
|
||||
/* Write registers */
|
||||
|
||||
ret = spirit_reg_write(spirit, PROTOCOL1_BASE, regval, 2);
|
||||
}
|
||||
|
||||
@@ -185,7 +185,7 @@ int spirit_qi_set_pqithreshold(FAR struct spirit_library_s *spirit,
|
||||
regval &= 0xc3;
|
||||
regval |= (uint8_t)pqithr;
|
||||
|
||||
/* Write the value on the QI register */
|
||||
/* Write the value on the QI register */
|
||||
|
||||
ret = spirit_reg_write(spirit, QI_BASE, ®val, 1);
|
||||
}
|
||||
|
||||
@@ -309,7 +309,8 @@ int spirit_radio_initialize(FAR struct spirit_library_s *spirit,
|
||||
/* Check the channel center frequency is in one of the possible range */
|
||||
|
||||
DEBUGASSERT(IS_FREQUENCY_BAND((radioinit->base_frequency +
|
||||
((fcoffset * spirit->xtal_frequency) / FBASE_DIVIDER) +
|
||||
((fcoffset * spirit->xtal_frequency) /
|
||||
FBASE_DIVIDER) +
|
||||
radioinit->chspace * radioinit->chnum)));
|
||||
|
||||
/* Calculates the datarate mantissa and exponent */
|
||||
@@ -1136,7 +1137,8 @@ int spirit_radio_set_foffset_ppm(FAR struct spirit_library_s *spirit,
|
||||
FBASE_DIVIDER);
|
||||
|
||||
/* Calculate the offset respect to RF frequency and according to xtal_ppm
|
||||
* parameter */
|
||||
* parameter.
|
||||
*/
|
||||
|
||||
offset = (int32_t)(((float)xtaloffset * fbase) / PPM_FACTOR);
|
||||
|
||||
@@ -1502,7 +1504,8 @@ uint32_t spirit_radio_get_centerfreq(FAR struct spirit_library_s *spirit)
|
||||
*
|
||||
* Input Parameters:
|
||||
* spirit - Reference to a Spirit library state structure instance
|
||||
* datarate - datarate expressed in bps. This parameter ranging between 100 and 500000.
|
||||
* datarate - datarate expressed in bps. This parameter ranging between
|
||||
* 100 and 500000.
|
||||
* pcm - pointer to the returned mantissa value.
|
||||
* pce - pointer to the returned exponent value.
|
||||
*
|
||||
@@ -1653,7 +1656,7 @@ int spirit_radio_convert_chbandwidth(FAR struct spirit_library_s *spirit,
|
||||
}
|
||||
}
|
||||
|
||||
delta = 0xFFFF;
|
||||
delta = 0xffff;
|
||||
|
||||
for (j = 0; j < 3; j++)
|
||||
{
|
||||
@@ -1698,7 +1701,7 @@ int spirit_radio_convert_freqdev(FAR struct spirit_library_s *spirit,
|
||||
uint32_t bp;
|
||||
uint32_t b = 0;
|
||||
uint8_t i;
|
||||
float xtalDivtmp = (float)spirit->xtal_frequency / (((uint32_t) 1) << 18);
|
||||
float divtmp = (float)spirit->xtal_frequency / (((uint32_t) 1) << 18);
|
||||
|
||||
/* Check the parameters */
|
||||
|
||||
@@ -1706,7 +1709,7 @@ int spirit_radio_convert_freqdev(FAR struct spirit_library_s *spirit,
|
||||
|
||||
for (i = 0; i < 10; i++)
|
||||
{
|
||||
a = (uint32_t)(xtalDivtmp * (uint32_t)(7.5 * (1 << i)));
|
||||
a = (uint32_t)(divtmp * (uint32_t)(7.5 * (1 << i)));
|
||||
if (fdev < a)
|
||||
{
|
||||
break;
|
||||
@@ -1718,7 +1721,7 @@ int spirit_radio_convert_freqdev(FAR struct spirit_library_s *spirit,
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
bp = b;
|
||||
b = (uint32_t)(xtalDivtmp * (uint32_t)((8.0 + i) / 2 * (1 << (*pce))));
|
||||
b = (uint32_t)(divtmp * (uint32_t)((8.0 + i) / 2 * (1 << (*pce))));
|
||||
if (fdev < b)
|
||||
{
|
||||
break;
|
||||
@@ -1754,7 +1757,8 @@ int spirit_radio_convert_freqdev(FAR struct spirit_library_s *spirit,
|
||||
int spirit_radio_set_datarate(FAR struct spirit_library_s *spirit,
|
||||
uint32_t datarate)
|
||||
{
|
||||
uint8_t dre, regval[2];
|
||||
uint8_t regval[2];
|
||||
uint8_t dre;
|
||||
int ret;
|
||||
|
||||
/* Check the parameters */
|
||||
@@ -1975,7 +1979,9 @@ int spirit_radio_set_chfilterbw(FAR struct spirit_library_s *spirit,
|
||||
|
||||
uint32_t spirit_radio_get_chfilterbw(FAR struct spirit_library_s *spirit)
|
||||
{
|
||||
uint8_t regval, bwm, bwe;
|
||||
uint8_t regval;
|
||||
uint8_t bwm;
|
||||
uint8_t bwe;
|
||||
|
||||
/* Read the channel filter register for mantissa and exponent */
|
||||
|
||||
@@ -2102,7 +2108,7 @@ int spirit_radio_enable_cwtxmode(FAR struct spirit_library_s *spirit,
|
||||
ret = spirit_reg_write(spirit, MOD0_BASE, ®val, 1);
|
||||
}
|
||||
|
||||
return ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
@@ -2365,7 +2371,8 @@ int spirit_radio_config_patable_dbm(FAR struct spirit_library_s *spirit,
|
||||
DEBUGASSERT(IS_PA_LOAD_CAP(load));
|
||||
|
||||
/* Check the PA level in dBm is in the range and calculate the PA_LEVEL value
|
||||
* to write in the corresponding register using the linearization formula */
|
||||
* to write in the corresponding register using the linearization formula.
|
||||
*/
|
||||
|
||||
for (i = 0; i <= nlevels; i++)
|
||||
{
|
||||
@@ -2401,7 +2408,7 @@ int spirit_radio_config_patable_dbm(FAR struct spirit_library_s *spirit,
|
||||
* table - Pointer to an array of 8 elements containing the PA value in dbm.
|
||||
* The first element will be the PA_LEVEL_0 and the last element
|
||||
* will be PA_LEVEL_7. Any value higher than PA_UPPER_LIMIT implies
|
||||
( no output power (output stage is in high impedance).
|
||||
* no output power (output stage is in high impedance).
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success. A negated errno value is returned on any failure.
|
||||
@@ -3440,7 +3447,8 @@ uint8_t spirit_radio_get_afclowgain(FAR struct spirit_library_s *spirit)
|
||||
uint8_t regval;
|
||||
|
||||
/* Read the AFC_0 register, mask the AFC Slow Gain field and return the
|
||||
* value */
|
||||
* value.
|
||||
*/
|
||||
|
||||
(void)spirit_reg_read(spirit, AFC0_BASE, ®val, 1);
|
||||
|
||||
@@ -3760,7 +3768,8 @@ int spirit_radio_enable_agcfreeze_maxatten(FAR struct spirit_library_s *spirit,
|
||||
DEBUGASSERT(IS_SPIRIT_FUNCTIONAL_STATE(newstate));
|
||||
|
||||
/* Read the AGCCTRL_2 register and configure the AGC Start Max Attenuation
|
||||
* field */
|
||||
* field.
|
||||
*/
|
||||
|
||||
ret = spirit_reg_read(spirit, AGCCTRL2_BASE, ®val, 1);
|
||||
if (ret >= 0)
|
||||
@@ -3960,7 +3969,8 @@ uint8_t spirit_radio_get_agcmeasure(FAR struct spirit_library_s *spirit)
|
||||
int spirit_radio_set_agcholdtime_us(FAR struct spirit_library_s *spirit,
|
||||
uint8_t time)
|
||||
{
|
||||
uint8_t regval, hold;
|
||||
uint8_t regval;
|
||||
uint8_t hold;
|
||||
|
||||
/* Check the parameter */
|
||||
|
||||
@@ -4149,7 +4159,8 @@ uint8_t spirit_radio_get_agchighthres(FAR struct spirit_library_s *spirit)
|
||||
uint8_t regval;
|
||||
|
||||
/* Read the AGCCTRL_1 register, mask the THRESHOLD_HIGH field and return the
|
||||
* value */
|
||||
* value.
|
||||
*/
|
||||
|
||||
(void)spirit_reg_read(spirit, AGCCTRL1_BASE, ®val, 1);
|
||||
|
||||
@@ -4216,7 +4227,8 @@ uint8_t spirit_radio_get_agclowthres(FAR struct spirit_library_s *spirit)
|
||||
uint8_t regval;
|
||||
|
||||
/* Read the AGCCTRL_1 register, mask the THRESHOLD_LOW field and return the
|
||||
* value */
|
||||
* value.
|
||||
*/
|
||||
|
||||
(void)spirit_reg_read(spirit, AGCCTRL1_BASE, ®val, 1);
|
||||
|
||||
@@ -4289,7 +4301,8 @@ enum spirit_clkrecmode_e
|
||||
uint8_t regval;
|
||||
|
||||
/* Read the FDEV_0 register, mask the CLOCK_REC_ALGO_SEL field and return
|
||||
* the value */
|
||||
* the value.
|
||||
*/
|
||||
|
||||
(void)spirit_reg_read(spirit, FDEV0_BASE, ®val, 1);
|
||||
|
||||
@@ -4357,7 +4370,8 @@ uint8_t spirit_radio_get_clkrecgain(FAR struct spirit_library_s *spirit)
|
||||
uint8_t regval;
|
||||
|
||||
/* Read the CLOCKREC register, mask the CLK_REC_P_GAIN field and return the
|
||||
* value */
|
||||
* value.
|
||||
*/
|
||||
|
||||
(void)spirit_reg_read(spirit, CLOCKREC_BASE, ®val, 1);
|
||||
|
||||
@@ -4498,7 +4512,8 @@ enum spirit_pstfltlen_e
|
||||
uint8_t regval;
|
||||
|
||||
/* Read the CLOCKREC register, mask the PSTFLT_LEN field and return the
|
||||
* value */
|
||||
* value.
|
||||
*/
|
||||
|
||||
(void)spirit_reg_read(spirit, CLOCKREC_BASE, ®val, 1);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/******************************************************************************
|
||||
* drivers/wireless/spirit/lib//spirit_spi.c
|
||||
* drivers/wireless/spirit/lib/spirit_spi.c
|
||||
* NuttX SPIRIT SPI driver interface.
|
||||
*
|
||||
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
||||
@@ -87,7 +87,7 @@
|
||||
#if defined(CONFIG_WL_SPIRIT_REGDEBUG) || defined(CONFIG_WL_SPIRIT_FIFODUMP)
|
||||
static void spirit_dump_buffer(FAR const uint8_t *buffer, unsigned int buflen)
|
||||
{
|
||||
char outbuf[16*3 + 3]; /* 16 hex bytes + 2 space separator + NUL termination */
|
||||
char outbuf[16 * 3 + 3]; /* 16 hex bytes + 2 space separator + NUL termination */
|
||||
FAR char *ptr;
|
||||
unsigned int i;
|
||||
unsigned int j;
|
||||
|
||||
@@ -99,7 +99,7 @@ int spirit_timer_enable_ldcrmode(FAR struct spirit_library_s *spirit,
|
||||
ret = spirit_reg_write(spirit, PROTOCOL2_BASE, ®val, 1);
|
||||
}
|
||||
|
||||
return ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
@@ -196,7 +196,10 @@ enum spirit_functional_state_e
|
||||
int spirit_timer_setup_rxtimeout(FAR struct spirit_library_s *spirit,
|
||||
uint8_t counter, uint8_t prescaler)
|
||||
{
|
||||
uint8_t regval[2] = { prescaler, counter };
|
||||
uint8_t regval[2] =
|
||||
{
|
||||
prescaler, counter
|
||||
};
|
||||
|
||||
/* Writes the prescaler and counter value for RX timeout to the corresponding
|
||||
* register.
|
||||
@@ -344,7 +347,10 @@ int spirit_timer_get_rxtimeout_setup(FAR struct spirit_library_s *spirit,
|
||||
*
|
||||
* Description:
|
||||
* Sets the LDCR wake up timer initialization registers with the values of
|
||||
* COUNTER and PRESCALER according to the formula: Twu=(PRESCALER +1)*(COUNTER+1)*Tck,
|
||||
* COUNTER and PRESCALER according to the formula:
|
||||
*
|
||||
* Twu=(PRESCALER + 1) * (COUNTER +1 ) * Tck,
|
||||
*
|
||||
* where Tck = 28.818 us. The minimum vale of the wakeup timeout is 28.818us
|
||||
* (PRESCALER and COUNTER equals to 0) and the maximum value is about 1.89 s
|
||||
* (PRESCALER anc COUNTER equals to 255).
|
||||
@@ -362,10 +368,14 @@ int spirit_timer_get_rxtimeout_setup(FAR struct spirit_library_s *spirit,
|
||||
int spirit_timer_setup_wakeuptimer(FAR struct spirit_library_s *spirit,
|
||||
uint8_t counter, uint8_t prescaler)
|
||||
{
|
||||
uint8_t regval[2] = { prescaler, counter };
|
||||
uint8_t regval[2] =
|
||||
{
|
||||
prescaler, counter
|
||||
};
|
||||
|
||||
/* Writes the counter and prescaler value of wake-up timer in the
|
||||
* corresponding register */
|
||||
* corresponding register.
|
||||
*/
|
||||
|
||||
return spirit_reg_write(spirit, TIMERS3_LDC_PRESCALER_BASE, regval, 2);
|
||||
}
|
||||
@@ -399,7 +409,8 @@ int spirit_timer_set_wakeuptimer(FAR struct spirit_library_s *spirit,
|
||||
spirit_timer_calc_wakeup_values(spirit, desired, ®val[1], ®val[0]);
|
||||
|
||||
/* Writes the counter and prescaler value of wake-up timer in the
|
||||
* corresponding register */
|
||||
* corresponding register.
|
||||
*/
|
||||
|
||||
return spirit_reg_write(spirit, TIMERS3_LDC_PRESCALER_BASE, regval, 2);
|
||||
}
|
||||
@@ -497,7 +508,8 @@ int spirit_timer_get_wakeuptimer_setup(FAR struct spirit_library_s *spirit,
|
||||
|
||||
*prescaler = regval[0];
|
||||
*counter = regval[1];
|
||||
*wakeupmsec = (float)((((*prescaler) + 1) * ((*counter) + 1) * (1000.0 / rco_freq)));
|
||||
*wakeupmsec = (float)((((*prescaler) + 1) * ((*counter) + 1) *
|
||||
(1000.0 / rco_freq)));
|
||||
}
|
||||
|
||||
return ret;
|
||||
@@ -529,7 +541,10 @@ int spirit_timer_get_wakeuptimer_setup(FAR struct spirit_library_s *spirit,
|
||||
int spirit_timer_setup_wakeuptimer_reload(FAR struct spirit_library_s *spirit,
|
||||
uint8_t counter, uint8_t prescaler)
|
||||
{
|
||||
uint8_t regval[2] = { prescaler, counter };
|
||||
uint8_t regval[2] =
|
||||
{
|
||||
prescaler, counter
|
||||
};
|
||||
|
||||
/* Write the counter and prescaler value of reload wake-up timer in the
|
||||
* corresponding register
|
||||
@@ -570,7 +585,8 @@ int spirit_timer_wakeuptimer_reload(FAR struct spirit_library_s *spirit,
|
||||
spirit_timer_calc_wakeup_values(spirit, desired, ®val[1], ®val[0]);
|
||||
|
||||
/* Writes the counter and prescaler value of reload wake-up timer in the
|
||||
* corresponding register */
|
||||
* corresponding register.
|
||||
*/
|
||||
|
||||
return spirit_reg_write(spirit, TIMERS1_LDC_RELOAD_PRESCALER_BASE, regval, 2);
|
||||
}
|
||||
@@ -679,7 +695,8 @@ int spirit_timer_get_wakeuptimer_reload_setup(FAR struct spirit_library_s *spiri
|
||||
|
||||
*prescaler = regval[0];
|
||||
*counter = regval[1];
|
||||
*reload = (float)((((*prescaler) + 1) * ((*counter) + 1) * (1000.0 / rco_freq)));
|
||||
*reload = (float)((((*prescaler) + 1) * ((*counter) + 1) *
|
||||
(1000.0 / rco_freq)));
|
||||
}
|
||||
|
||||
return ret;
|
||||
@@ -757,19 +774,22 @@ void spirit_timer_calc_wakeup_values(FAR struct spirit_library_s *spirit,
|
||||
float desired, FAR uint8_t *counter,
|
||||
FAR uint8_t *prescaler)
|
||||
{
|
||||
float rco_freq, err;
|
||||
float rco_freq;
|
||||
float err;
|
||||
uint32_t n;
|
||||
|
||||
rco_freq = ((float)spirit_timer_get_rcofrequency(spirit)) / 1000;
|
||||
|
||||
/* N cycles in the time base of the timer: - clock of the timer is RCO
|
||||
* frequency - divide times 1000 more because we have an input in ms
|
||||
* (variable rco_freq is already this frequency divided by 1000) */
|
||||
* (variable rco_freq is already this frequency divided by 1000).
|
||||
*/
|
||||
|
||||
n = (uint32_t)(desired * rco_freq);
|
||||
|
||||
/* check if it is possible to reach that target with prescaler and counter of
|
||||
* spirit1 */
|
||||
* spirit1.
|
||||
*/
|
||||
|
||||
if (n / 0xff > 0xfd)
|
||||
{
|
||||
@@ -878,18 +898,21 @@ void spirit_timer_calc_rxtimeout_values(FAR struct spirit_library_s *spirit,
|
||||
|
||||
/* check if the error is minimum */
|
||||
|
||||
err = S_ABS((float)(*counter) * (*prescaler) * 1210000 / xtal_frequency - desired);
|
||||
err = S_ABS((float)(*counter) * (*prescaler) * 1210000 /
|
||||
xtal_frequency - desired);
|
||||
|
||||
if ((*counter) <= 254)
|
||||
{
|
||||
if (S_ABS((float)((*counter) + 1) * (*prescaler) * 1210000 / xtal_frequency - desired) < err)
|
||||
if (S_ABS((float)((*counter) + 1) * (*prescaler) * 1210000 /
|
||||
xtal_frequency - desired) < err)
|
||||
{
|
||||
(*counter)++;
|
||||
}
|
||||
}
|
||||
|
||||
/* decrement prescaler and counter according to the logic of this timer in
|
||||
* spirit1 */
|
||||
* spirit1.
|
||||
*/
|
||||
|
||||
(*prescaler)--;
|
||||
if ((*counter) > 1)
|
||||
@@ -968,4 +991,3 @@ int spirit_timer_cmd_reload(FAR struct spirit_library_s *spirit)
|
||||
|
||||
return spirit_command(spirit, COMMAND_LDC_RELOAD);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user