Send error codes to interface chip
This commit is contained in:
parent
8cf15685b8
commit
eaf86ff0ce
@ -57,7 +57,7 @@ typedef struct {
|
||||
void Error_Handler(void);
|
||||
|
||||
/* USER CODE BEGIN EFP */
|
||||
void AMS_Error_Handler(AMSErrorHandle);
|
||||
void AMS_Error_Handler(AMSErrorHandle*);
|
||||
/* USER CODE END EFP */
|
||||
|
||||
/* Private defines -----------------------------------------------------------*/
|
||||
|
@ -11,6 +11,8 @@
|
||||
|
||||
#include "stm32g4xx_hal_fdcan.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
// 3 should be programmed with CAN id 2
|
||||
// const uint16_t slave_CAN_id_to_slave_index[7] = {
|
||||
// 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) {
|
||||
AMSErrorHandle errorframe = {0};
|
||||
errorframe.errorcode = SlavesErrorFrameError;
|
||||
errorframe.errorarg[0] = rxFrame.data[0];
|
||||
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];
|
||||
memcpy(errorframe.errorarg, rxFrame.data, 7);
|
||||
|
||||
AMS_Error_Handler(errorframe);
|
||||
AMS_Error_Handler(&errorframe);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,19 +33,7 @@ AIRStateHandler* spi_airstates;
|
||||
|
||||
AMSErrorHandle* spierrorinfo;
|
||||
|
||||
void set_SPI_errorInfo(AMSErrorHandle* 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 set_SPI_errorInfo(AMSErrorHandle* errorinfo) { spierrorinfo = errorinfo; }
|
||||
|
||||
void spi_communication_init(SPI_HandleTypeDef* spi,
|
||||
AIRStateHandler* airstatemaschine) {
|
||||
|
@ -48,8 +48,9 @@ uint8_t checkSlaveTimeout() {
|
||||
|
||||
AMSErrorHandle timeouterror;
|
||||
timeouterror.errorcode = SlavesTimeoutError;
|
||||
timeouterror.errorarg[0] = n;
|
||||
|
||||
AMS_Error_Handler(timeouterror);
|
||||
AMS_Error_Handler(&timeouterror);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
@ -351,10 +351,9 @@ static void MX_GPIO_Init(void) {
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN 4 */
|
||||
void AMS_Error_Handler(AMSErrorHandle errorinfo) {
|
||||
void AMS_Error_Handler(AMSErrorHandle* errorinfo) {
|
||||
while (1) {
|
||||
set_SPI_errorInfo(&errorinfo);
|
||||
errorinfo.errorarg[7] = 1;
|
||||
set_SPI_errorInfo(errorinfo);
|
||||
setAMSError();
|
||||
airstates.targetTSState = TS_ERROR;
|
||||
Update_AIR_State(&airstates);
|
||||
|
Loading…
x
Reference in New Issue
Block a user