- Joined
- Jan 12, 2023
- Messages
- 5
- Reaction score
- 0
Hi I m using STM32H743 Nucleo, SPI to transmit and receive data from a sensor, the sensor return 3 bytes of data, SensorRXBuff[0], SensorRXBuff[1], and SensorRXBuff[2], i m gona use these 3 byte for indivual computation, i enclosed the function below, could anyone advise if this function is correct? is the uint_16 in front of function correct? how can i call the 2nd byte i.e SensorRXBuff[1]? Anyone can advise ??
uint16_t Sensor(uint8_t *ch)
{
uint16_t SensorTxBuff[2] = {0x8, 0xAF};
HAL_GPIO_WritePin(..) // SPI CS low
if (HAL_SPI_TransmitReceive(&hspi1,(uint8_t *)&SensorTxBuff, (uint8_t *)&SensorRXBuff, 3, 100) != HAL_OK);
{
Error_Handler();
}
Hal_GPIO_WritePin;(...)// SPI CS hi..
return SensorRXBuff;
}
uint16_t Sensor(uint8_t *ch)
{
uint16_t SensorTxBuff[2] = {0x8, 0xAF};
HAL_GPIO_WritePin(..) // SPI CS low
if (HAL_SPI_TransmitReceive(&hspi1,(uint8_t *)&SensorTxBuff, (uint8_t *)&SensorRXBuff, 3, 100) != HAL_OK);
{
Error_Handler();
}
Hal_GPIO_WritePin;(...)// SPI CS hi..
return SensorRXBuff;
}