2022-02-23 01:20 AM
So why does HAL_SAI_Receive_DMA() return an 8bit-value? Wouldn't it be much easier to obtain data by passing uint32_t values?
2022-04-26 06:50 AM
Hello @JTedot and welcome to the community,
In fact the SAI data can be presented in three different way which are 8 bits, 16 bits and 32 bits.
It's ST implementation choice to be an 8 bits data length
Mohamed Aymen
2022-04-26 07:45 AM
/**
* @brief Receive an amount of data in non-blocking mode with DMA.
* @param hsai pointer to a SAI_HandleTypeDef structure that contains
* the configuration information for SAI module.
* @param pData Pointer to data buffer
* @param Size Amount of data to be received
* @retval HAL status
*/
HAL_StatusTypeDef HAL_SAI_Receive_DMA(SAI_HandleTypeDef *hsai, uint8_t *pData, uint16_t Size)
{
i.e. HAL_SAI_Receive_DMA() returns a value of HAL_StatusTypeDef type, which is an enum, and its actual width is compiler-dependent.
But you probably talk about the pData parameter. Its type is formal, it's just a pointer to an array of bytes. How are those bytes filled up, i.e. what datawidth is used by SAI and DMA, is probably determined by respective fields in SAI and DMA init structs; you can look that up. I don't use Cube.
JW
2022-04-26 03:32 PM
For universal buffer passing normal developers use void* type for read/receive and const void* for write/transmit and cast it to the required type internally.
2022-05-15 11:06 AM
I found out. Short answer: just ignore it, it will fit any unsigned integer pointer you provide it with. `uint8_t*` in this case is just a choice, a placeholder if you will. 8-bit, 16bit and 32bit work just fine.