2018-12-13 07:52 AM
Hi,
there is a bug in the S2-LP library function S2LPTimerSetRxTimerStopCondition:
void S2LPTimerSetRxTimerStopCondition(RxTimeoutStopCondition xStopCondition)
{
uint8_t tmp;
s_assert_param(IS_RX_TIMEOUT_STOP_CONDITION(xStopCondition));
S2LPSpiReadRegisters(PROTOCOL2_ADDR, 1, &tmp);
tmp &= ~(CS_TIMEOUT_MASK_REGMASK | SQI_TIMEOUT_MASK_REGMASK | PQI_TIMEOUT_MASK_REGMASK);
tmp |= (((uint8_t)xStopCondition) << 5);
S2LPSpiWriteRegisters(PROTOCOL2_ADDR, 1, &tmp);
S2LPSpiReadRegisters(PCKT_FLT_OPTIONS_ADDR, 1, &tmp);
tmp &= ~RX_TIMEOUT_AND_OR_SEL_REGMASK;
tmp |= (((uint8_t)xStopCondition) >> 1);
g_xStatus = S2LPSpiWriteRegisters(PCKT_FLT_OPTIONS_ADDR, 1, &tmp);
}
The bug fixed function is:
void S2LPTimerSetRxTimerStopCondition(RxTimeoutStopCondition xStopCondition)
{
uint8_t tmp;
s_assert_param(IS_RX_TIMEOUT_STOP_CONDITION(xStopCondition));
S2LPSpiReadRegisters(PROTOCOL2_ADDR, 1, &tmp);
tmp &= ~(CS_TIMEOUT_MASK_REGMASK | SQI_TIMEOUT_MASK_REGMASK | PQI_TIMEOUT_MASK_REGMASK);
tmp |= ((uint8_t)xStopCondition & 0x7U) << 5U;
S2LPSpiWriteRegisters(PROTOCOL2_ADDR, 1, &tmp);
S2LPSpiReadRegisters(PCKT_FLT_OPTIONS_ADDR, 1, &tmp);
tmp &= ~RX_TIMEOUT_AND_OR_SEL_REGMASK;
tmp |= ((uint8_t)xStopCondition >> 3U) << 6U;
g_xStatus = S2LPSpiWriteRegisters(PCKT_FLT_OPTIONS_ADDR, 1, &tmp);
}