Send error codes to interface chip

This commit is contained in:
jazzpi 2022-07-25 20:05:47 +02:00
parent 8cf15685b8
commit eaf86ff0ce
5 changed files with 10 additions and 27 deletions

View File

@ -57,7 +57,7 @@ typedef struct {
void Error_Handler(void); void Error_Handler(void);
/* USER CODE BEGIN EFP */ /* USER CODE BEGIN EFP */
void AMS_Error_Handler(AMSErrorHandle); void AMS_Error_Handler(AMSErrorHandle*);
/* USER CODE END EFP */ /* USER CODE END EFP */
/* Private defines -----------------------------------------------------------*/ /* Private defines -----------------------------------------------------------*/

View File

@ -11,6 +11,8 @@
#include "stm32g4xx_hal_fdcan.h" #include "stm32g4xx_hal_fdcan.h"
#include <string.h>
// 3 should be programmed with CAN id 2 // 3 should be programmed with CAN id 2
// const uint16_t slave_CAN_id_to_slave_index[7] = { // const uint16_t slave_CAN_id_to_slave_index[7] = {
// 255, 255, 0, 255, 255, 255, 1}; // TODO: Make this pretty pls // 255, 255, 0, 255, 255, 255, 1}; // TODO: Make this pretty pls
@ -68,16 +70,9 @@ uint8_t CAN_Receive(FDCAN_HandleTypeDef* hcan) {
} else if (rxFrame.FrameID == SLAVE_EMERGENCY_ADDRESS) { } else if (rxFrame.FrameID == SLAVE_EMERGENCY_ADDRESS) {
AMSErrorHandle errorframe = {0}; AMSErrorHandle errorframe = {0};
errorframe.errorcode = SlavesErrorFrameError; errorframe.errorcode = SlavesErrorFrameError;
errorframe.errorarg[0] = rxFrame.data[0]; memcpy(errorframe.errorarg, rxFrame.data, 7);
errorframe.errorarg[1] = rxFrame.data[1];
errorframe.errorarg[2] = rxFrame.data[2];
errorframe.errorarg[3] = rxFrame.data[3];
errorframe.errorarg[4] = rxFrame.data[4];
errorframe.errorarg[5] = rxFrame.data[5];
errorframe.errorarg[6] = rxFrame.data[6];
errorframe.errorarg[7] = rxFrame.data[7];
AMS_Error_Handler(errorframe); AMS_Error_Handler(&errorframe);
} }
} }

View File

@ -33,19 +33,7 @@ AIRStateHandler* spi_airstates;
AMSErrorHandle* spierrorinfo; AMSErrorHandle* spierrorinfo;
void set_SPI_errorInfo(AMSErrorHandle* errorinfo) { void set_SPI_errorInfo(AMSErrorHandle* errorinfo) { spierrorinfo = errorinfo; }
spierrorinfo = errorinfo;
spierrorinfo->errorcode = 0;
spierrorinfo->errorarg[0] = 0;
spierrorinfo->errorarg[1] = 0;
spierrorinfo->errorarg[2] = 0;
spierrorinfo->errorarg[3] = 0;
spierrorinfo->errorarg[4] = 0;
spierrorinfo->errorarg[5] = 0;
spierrorinfo->errorarg[6] = 0;
spierrorinfo->errorarg[7] = 0;
}
void spi_communication_init(SPI_HandleTypeDef* spi, void spi_communication_init(SPI_HandleTypeDef* spi,
AIRStateHandler* airstatemaschine) { AIRStateHandler* airstatemaschine) {

View File

@ -48,8 +48,9 @@ uint8_t checkSlaveTimeout() {
AMSErrorHandle timeouterror; AMSErrorHandle timeouterror;
timeouterror.errorcode = SlavesTimeoutError; timeouterror.errorcode = SlavesTimeoutError;
timeouterror.errorarg[0] = n;
AMS_Error_Handler(timeouterror); AMS_Error_Handler(&timeouterror);
return 1; return 1;
} }
} }

View File

@ -351,10 +351,9 @@ static void MX_GPIO_Init(void) {
} }
/* USER CODE BEGIN 4 */ /* USER CODE BEGIN 4 */
void AMS_Error_Handler(AMSErrorHandle errorinfo) { void AMS_Error_Handler(AMSErrorHandle* errorinfo) {
while (1) { while (1) {
set_SPI_errorInfo(&errorinfo); set_SPI_errorInfo(errorinfo);
errorinfo.errorarg[7] = 1;
setAMSError(); setAMSError();
airstates.targetTSState = TS_ERROR; airstates.targetTSState = TS_ERROR;
Update_AIR_State(&airstates); Update_AIR_State(&airstates);