cancel
Showing results for 
Search instead for 
Did you mean: 

Bug in STSW-S2LP-DK in S2LP_Library in S2LP_Csma.c

TJaku.2
Associate II

There is a bug in S2LP_Library which is part of the STSW-S2LP-DK package. In the following function you need to shift xCcaLength to the upper nibble, but there is no shift in currently available version. The bug won't allow you to set CCA length.

Please fix that in next STSW-S2LP-DK release.

/**
 * @brief  Set the CCA length.
 * @param  xCcaLength the CCA length (a value between 1 and 15 that multiplies the CCA period).
 *     This parameter can be any value of @ref CsmaLength.
 * @retval None.
 */
void S2LPCsmaSetCcaLength(uint8_t xCcaLength)
{
  uint8_t tmp;
  s_assert_param(IS_CSMA_LENGTH(xCcaLength));
 
  S2LPSpiReadRegisters(CSMA_CONF0_ADDR, 1, &tmp);
 
  tmp &= ~CCA_LEN_REGMASK;
  tmp |= (xCcaLength << 4);
 
  *(uint8_t*)&g_xStatus = S2LPSpiWriteRegisters(CSMA_CONF0_ADDR, 1, &tmp);
 
}

1 REPLY 1
TJaku.2
Associate II

Thanks for fixing this bug in 1.3.4.

Though I don't understand the change in this:

/**
* @brief  Sets a specific PA_LEVEL register, with a value given in dBm.
* @param  cIndex PA_LEVEL to set. This parameter shall be in the range [0:7].
* @param  lPowerdBm PA value to write expressed in dBm . Be sure that this values is in the
*         correct range [-PA_LOWER_LIMIT: PA_UPPER_LIMIT] dBm.
* @retval None.
* @note This function makes use of the @ref S2LPRadioGetdBm2Reg fcn to interpolate the
*       power value.
*/
void S2LPRadioSetPALeveldBm(uint8_t cIndex, int32_t lPowerdBm)
{
  uint8_t address, paLevelValue;
  s_assert_param(IS_PA_MAX_INDEX(cIndex));
  s_assert_param(IS_PAPOWER_DBM(lPowerdBm));
 
  if(lPowerdBm> 14)
  {
    paLevelValue = 1;
  }
  else {
    paLevelValue = (uint8_t)((int32_t)25-2*lPowerdBm);
  }
 
  address = PA_POWER8_ADDR + 7 - cIndex;
 
  *(uint8_t*)&g_xStatus = S2LPSpiWriteRegisters(address, 1, &paLevelValue);
}

I would guess, that for `lPowerdBm=14` it will put `-3` to the register?

Please put the library to your GitHub, so we don't have to wait one year to replace one bug by another.