Use new AMS CAN interface

This commit is contained in:
jazzpi
2022-06-23 14:55:10 +02:00
parent 2acde9d565
commit ec1383960b
4 changed files with 85 additions and 29 deletions

View File

@ -8,9 +8,15 @@
#ifndef INC_AMS_CAN_H_
#define INC_AMS_CAN_H_
#include "stm32f4xx_hal.h"
#include "main.h"
#define CAN_ID_AMS_SLAVE_HEARTBEAT_BASE 0x100
#include "stm32f4xx_hal.h"
#include "stm32f4xx_hal_can.h"
#include "stm32f4xx_hal_def.h"
#define CAN_ID_SLAVE_ERROR 0x001
#define CAN_ID_AMS_SLAVE_HEARTBEAT_BASE 0x600
#define CAN_HEARTBEAT_TX_TIMEOUT 5 /* ms */
void ams_can_init(CAN_HandleTypeDef* ams, CAN_HandleTypeDef* car);
@ -18,5 +24,9 @@ void ams_can_handle_ams_msg(CAN_RxHeaderTypeDef* header, uint8_t* data);
void ams_can_handle_car_msg(CAN_RxHeaderTypeDef* header, uint8_t* data);
void ams_can_send_heartbeat();
void ams_can_send_error(AMS_ErrorCode error_code);
HAL_StatusTypeDef ams_can_wait_for_free_mailbox(CAN_HandleTypeDef* handle,
uint32_t timeout);
#endif /* INC_AMS_CAN_H_ */

View File

@ -36,11 +36,17 @@ extern "C" {
/* Exported types ------------------------------------------------------------*/
/* USER CODE BEGIN ET */
typedef enum {
AMS_ERROR_UV,
AMS_ERROR_OV,
AMS_ERROR_UT,
AMS_ERROR_OT
} AMS_ErrorCode;
/* USER CODE END ET */
/* Exported constants --------------------------------------------------------*/
/* USER CODE BEGIN EC */
extern uint8_t slave_id;
/* USER CODE END EC */
/* Exported macro ------------------------------------------------------------*/