Spirit: Fix a bad debug assertion.

This commit is contained in:
Gregory Nutt
2017-08-01 09:01:46 -06:00
parent 4f0238339e
commit 2cb5ec542b
4 changed files with 12 additions and 10 deletions
@@ -223,7 +223,7 @@ static const struct radio_init_s g_radio_init =
{ {
SPIRIT_BASE_FREQUENCY, /* base_frequency */ SPIRIT_BASE_FREQUENCY, /* base_frequency */
SPIRIT_CHANNEL_SPACE, /* chspace */ SPIRIT_CHANNEL_SPACE, /* chspace */
SPIRIT_XTAL_OFFSET_PPM, /* xtal_offset_ppm */ SPIRIT_XTAL_OFFSET_PPM, /* foffset */
SPIRIT_CHANNEL_NUMBER, /* chnum */ SPIRIT_CHANNEL_NUMBER, /* chnum */
SPIRIT_MODULATION_SELECT, /* modselect */ SPIRIT_MODULATION_SELECT, /* modselect */
SPIRIT_DATARATE, /* datarate */ SPIRIT_DATARATE, /* datarate */
@@ -350,7 +350,7 @@ struct radio_init_s
* NxFREQUENCY_STEPS, where frequency STEPS is * NxFREQUENCY_STEPS, where frequency STEPS is
* F_Xo/2^15. This parameter can be in the * F_Xo/2^15. This parameter can be in the
* range: [0, F_Xo/2^15*255] Hz */ * range: [0, F_Xo/2^15*255] Hz */
int16_t xtal_offset_ppm; /* Specifies the offset frequency (in ppm) int16_t foffset; /* Specifies the offset frequency (in ppm)
* to compensate crystal inaccuracy expressed * to compensate crystal inaccuracy expressed
* as signed value. */ * as signed value. */
uint8_t chnum; /* Specifies the channel number. This value uint8_t chnum; /* Specifies the channel number. This value
@@ -111,11 +111,12 @@ enum spirit_state_e
* This field-oriented structure allows user to address in simple way the single * This field-oriented structure allows user to address in simple way the single
* field of the SPIRIT status. * field of the SPIRIT status.
* The user shall define a variable of SpiritStatus type to access on SPIRIT status fields. * The user shall define a variable of SpiritStatus type to access on SPIRIT status fields.
* @note The fields order in the structure depends on used endianness (little or big * NOTE: The fields order in the structure depends on used endianness (little or big
* endian). The actual definition is valid ONLY for LITTLE ENDIAN mode. Be sure to * endian). The actual definition is valid ONLY for LITTLE ENDIAN mode. Be sure to
* change opportunely the fields order when use a different endianness. * change opportunely the fields order when use a different endianness.
*/ */
#ifndef CONFIG_ENDIAN_BIG
struct spirit_status_s struct spirit_status_s
{ {
uint8_t XO_ON : 1; /* Notifies if XO is operating (XO_ON is uint8_t XO_ON : 1; /* Notifies if XO is operating (XO_ON is
@@ -134,6 +135,7 @@ struct spirit_status_s
uint8_t ANT_SELECT : 1; /* Notifies the currently selected antenna */ uint8_t ANT_SELECT : 1; /* Notifies the currently selected antenna */
uint8_t reserved : 4; /* Reserved and equal to 5 */ uint8_t reserved : 4; /* Reserved and equal to 5 */
}; };
#endif
/* One instance of this structure represents the overall state of one Spirit /* One instance of this structure represents the overall state of one Spirit
* device from the standpoint of the library. Multiple spirit devices may be * device from the standpoint of the library. Multiple spirit devices may be
+7 -7
View File
@@ -182,9 +182,8 @@ int spirit_radio_initialize(FAR struct spirit_library_s *spirit,
DEBUGASSERT(IS_FREQUENCY_BAND(radioinit->base_frequency)); DEBUGASSERT(IS_FREQUENCY_BAND(radioinit->base_frequency));
DEBUGASSERT(IS_MODULATION_SELECTED(radioinit->modselect)); DEBUGASSERT(IS_MODULATION_SELECTED(radioinit->modselect));
DEBUGASSERT(IS_DATARATE(radioinit->datarate)); DEBUGASSERT(IS_DATARATE(radioinit->datarate));
DEBUGASSERT(IS_FREQUENCY_OFFSET(offset, spirit->xtal_frequency)); DEBUGASSERT(IS_FREQUENCY_OFFSET(radioinit->foffset, spirit->xtal_frequency));
DEBUGASSERT(IS_CHANNEL_SPACE DEBUGASSERT(IS_CHANNEL_SPACE(radioinit->chspace, spirit->xtal_frequency));
(radioinit->chspace, spirit->xtal_frequency));
DEBUGASSERT(IS_F_DEV(radioinit->freqdev, spirit->xtal_frequency)); DEBUGASSERT(IS_F_DEV(radioinit->freqdev, spirit->xtal_frequency));
/* Workaround for Vtune */ /* Workaround for Vtune */
@@ -200,8 +199,8 @@ int spirit_radio_initialize(FAR struct spirit_library_s *spirit,
* parameter: (xtal_ppm*FBase)/10^6 * parameter: (xtal_ppm*FBase)/10^6
*/ */
offset = (int32_t)(((float)radioinit->xtal_offset_ppm * offset = (int32_t)(((float)radioinit->foffset * radioinit->base_frequency) /
radioinit->base_frequency) / PPM_FACTOR); PPM_FACTOR);
/* Disable the digital, ADC, SMPS reference clock divider if fXO > 24MHz or /* Disable the digital, ADC, SMPS reference clock divider if fXO > 24MHz or
* fXO < 26MHz * fXO < 26MHz
@@ -343,7 +342,8 @@ int spirit_radio_initialize(FAR struct spirit_library_s *spirit,
/* Calculates the channel filter mantissa and exponent */ /* Calculates the channel filter mantissa and exponent */
ret = spirit_radio_convert_chbandwidth(spirit, radioinit->bandwidth, &bwm, &bwe); ret = spirit_radio_convert_chbandwidth(spirit, radioinit->bandwidth,
&bwm, &bwe);
if (ret < 0) if (ret < 0)
{ {
return ret; return ret;
@@ -605,7 +605,7 @@ int spirit_radio_get_setup(FAR struct spirit_library_s *spirit,
/* Calculate the frequency offset in ppm */ /* Calculate the frequency offset in ppm */
radioinit->xtal_offset_ppm = (int16_t) radioinit->foffset = (int16_t)
((uint32_t)fcoffset * spirit->xtal_frequency * PPM_FACTOR) / ((uint32_t)fcoffset * spirit->xtal_frequency * PPM_FACTOR) /
((uint32_t)FBASE_DIVIDER * radioinit->base_frequency); ((uint32_t)FBASE_DIVIDER * radioinit->base_frequency);