cancel
Showing results for 
Search instead for 
Did you mean: 

HAL_SPI_Transmit

vimmi
Associate II
Posted on May 18, 2016 at 22:44

Hello,

We want to use HAL_SPI_Transmit function to load the data from 16 bit Array.  The function parameters are (SPI_Handle TypeDef *hspi, uint8_t * pdata, uint16_t Size, uint32_t Timeout).

Our data buffer is defined as following:

uint16_t DotRowBuff[24]

When we call above Transmit function, the pointer is uint8_t type and our data buffer is 16 bit. So can we not have 16 bit data pointer in this function? Or how can we define 8 bit pointer that will give the address of 16-bit array?

We are referring to UM1785 which gives the description of HAL drivers.

Please advise.

3 REPLIES 3
Amel NASRI
ST Employee
Posted on May 23, 2016 at 17:36

Hi adeshra.vimmi,

The data frame long may be configured to 8 bits or 16 bits (DFF). That is why HAL_SPI_Transmit takes 8 bit pointer as parameter.

In the implementation of this function, the behavior will depend on the selected data frame length (SPI_DATASIZE_16BIT or SPI_DATASIZE_8BIT).

In your case, it should be set to SPI_DATASIZE_16BIT.

-Mayla-

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

vimmi
Associate II
Posted on May 23, 2016 at 22:58

Thanks Mayla.

I have specified DataSize as SPI_DataSize_16bit. But how do I assign the 8-bit data pointer to 16-bit data buffer?

The data buffer and data pointer are defined as following:

uint16_t DotRowBuff[24];

uint8_t *DotRowPtr;

I want to assign DotRowPtr to DotRowBuff? How can I implement this?

TDK
Guru
Posted on May 25, 2016 at 05:01

You can just type-cast it to the desired type.

DotRowPtr = (uint8_t *) DotRowBuff;

If you feel a post has answered your question, please click "Accept as Solution".