44 lines
1.2 KiB
C
44 lines
1.2 KiB
C
/*
|
|
* AMS_CAN.h
|
|
*
|
|
* Created on: Mar 19, 2022
|
|
* Author: jasper
|
|
*/
|
|
|
|
#ifndef INC_AMS_CAN_H_
|
|
#define INC_AMS_CAN_H_
|
|
|
|
#include "main.h"
|
|
|
|
#include "stm32f4xx_hal.h"
|
|
#include "stm32f4xx_hal_can.h"
|
|
#include "stm32f4xx_hal_def.h"
|
|
|
|
#include <stdint.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);
|
|
|
|
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();
|
|
/**
|
|
* @brief Send an AMS Error via CAN.
|
|
*
|
|
* @param error_code The kind of error
|
|
* @param transmission_timeout How long to wait for the transmission to complete
|
|
* after starting it (in ms). Set to 0 for no wait.
|
|
*/
|
|
void ams_can_send_error(AMS_ErrorCode error_code,
|
|
uint32_t transmission_timeout);
|
|
|
|
HAL_StatusTypeDef ams_can_wait_for_free_mailboxes(CAN_HandleTypeDef* handle,
|
|
int num_mailboxes,
|
|
uint32_t timeout);
|
|
|
|
#endif /* INC_AMS_CAN_H_ */
|