2018-11-15 12:23 AM
Output type of LL_ADC_REG_ReadConversiomData32() is uint32_t. Convertion in function is uint16_t.
I think convertion need be to type uint32_t. Like in function LL_ADC_REG_ReadMultiConversionData32().
Also in LL_ADC_REG_ReadConversionData6 and LL_ADC_REG_ReadConversionData8 convertion need to be (uint8_t).
2018-11-15 02:05 AM
I have my reasons to stay with the SPL for this MCU.
The last function is even more strange:
return (uint16_t) (READ_BIT) (ADCx->DR ...));
How can one convert a single bit to a 6 bit value ?
Or does the function/macro not do what it's name suggests ?
Guess this discloses something about the amount of code reviews and tests done for the Cube/LL ...
2018-11-15 02:35 AM
__STATIC_INLINE uint8_t LL_ADC_REG_ReadConversionData6(ADC_TypeDef *ADCx)
{
return (uint16_t)(READ_BIT(ADCx->DR, ADC_DR_DATA));
}
READ_BIT - macro.
#define READ_BIT(REG, BIT) ((REG) & (BIT))
Bitwise AND with mask. I think in func LL_ADC_REG_ReadConversion_Data6 mask shoud be 0x3F.
#define ADC_DR_DATA_Pos (0U)
#define ADC_DR_DATA_Msk (0xFFFFU << ADC_DR_DATA_Pos) /*!< 0x0000FFFF */
#define ADC_DR_DATA ADC_DR_DATA_Msk
Value for ADC_DR_DATA is 0xFFFF. In last func you recieve 8 bit of data from ADC. Seems LL_ADC_REG_ReadConversion_Data6 not works correctly.
2018-11-15 03:00 AM
I don't need to see the code behind that macro - the name is already appalling enough.
As said, I have my reasons to stick with the SPL for this MCU.