Transmitting multiple bytes through SPI
Hi everyone,
I am trying to transmit multiple bytes via SPI.
I could read the data through spi, so connections should be ok.
Does anyone have idea what can be the reason, that I can not write data to the register of the slave?
int writetospi(uint16 headerLength, const uint8 *headerBuffer, uint32 bodyLength, const uint8 *bodyBuffer)
{
while (HAL_SPI_GetState(&hspi2) != HAL_SPI_STATE_READY);
HAL_GPIO_WritePin(DW_SPI_Port, DW_SPI_Pin, GPIO_PIN_SET); /**< Put chip select line high */
HAL_GPIO_WritePin(DW_SPI_Port, DW_SPI_Pin2, GPIO_PIN_SET); /**< Put chip select line high */
HAL_GPIO_WritePin(DW_SPI_Port, DW_SPI_Pin, GPIO_PIN_RESET); /**< Put chip select line low */
HAL_GPIO_WritePin(DW_SPI_Port, DW_SPI_Pin2, GPIO_PIN_RESET); /**< Put chip select line low */
HAL_SPI_Transmit(&hspi2, (uint8_t *)&headerBuffer[0], headerLength, 300); /* Send header in polling mode */
HAL_SPI_Transmit(&hspi2, (uint8_t *)&bodyBuffer[0], bodyLength, 300); /* Send data in polling mode */
HAL_GPIO_WritePin(DW_SPI_Port, DW_SPI_Pin, GPIO_PIN_SET); /**< Put chip select line high */
HAL_GPIO_WritePin(DW_SPI_Port, DW_SPI_Pin2, GPIO_PIN_SET); /**< Put chip select line high */
return 0;
} // end writetospi()Note: Wrong pin was connected on the hardware as chip select, therefore I used both, chip select pin as well as connected pin.
This is a device of Decawave, I need to write this function so all the apis of manufacturer works. Thank you.
Best regards