/* * SPI_Slave_Communication.h * * Created on: Jun 16, 2022 * Author: max */ #ifndef SPI_SLAVE_COMMUNICATION_H_ #define SPI_SLAVE_COMMUNICATION_H_ #include "AIR_State_Maschine.h" #include "Slave_Monitoring.h" #include "main.h" #include "stm32g4xx_hal_crc.h" #define SET_SHUNTDATA 0x01 #define SET_TSSTATE 0x02 #define GET_TSSTATE 0x03 #define GET_ERROR 0x04 #define GET_MEASUREMENTS 0x05 #define TOGGLE_STATUS_LED 0x06 #define SET_SHUNTDATA_CMD_LEN 14 #define SET_TSSTATE_CMD_LEN 2 #define GET_TSSTATE_CMD_LEN 1 #define GET_ERROR_CMD_LEN 1 #define GET_MEASUREMENTS_CMD_LEN 1 void spi_communication_init(SPI_HandleTypeDef* spi, AIRStateHandler* airstatemaschine); void checkSPI(); void set_SPI_errorInfo(AMSErrorHandle* errorinfo); uint8_t checkXor(uint8_t* buf, uint8_t len); uint8_t calculateChecksum(uint8_t* buf, uint8_t len); uint8_t receiveData(uint16_t length); uint8_t transmitData(uint16_t length); void InterSTMFrame(); void HAL_SPI_RxCpltCallback(SPI_HandleTypeDef* hspi); void HAL_SPI_TxRxCpltCallback(SPI_HandleTypeDef* hspi); void HAL_SPI_ErrorCallback(SPI_HandleTypeDef* hspi); #endif /* SPI_SLAVE_COMMUNICATION_H_ */