/*
 * AMS_CAN.h
 *
 *  Created on: Mar 19, 2022
 *      Author: jasper
 */

#ifndef INC_AMS_CAN_H_
#define INC_AMS_CAN_H_

#include "main.h"

#include "stm32f3xx_hal.h"
#include "stm32f3xx_hal_can.h"
#include "stm32f3xx_hal_def.h"

#include <stdint.h>

void ams_can_init(CAN_HandleTypeDef* hcan);

void ams_can_handle_ams_msg(CAN_RxHeaderTypeDef* header, uint8_t* data);

void ams_can_send_status();
/**
 * @brief Send an AMS Error via CAN.
 *
 * Data is taken from error_data
 */
void ams_can_send_error();

HAL_StatusTypeDef ams_can_wait_for_free_mailboxes(CAN_HandleTypeDef* handle,
                                                  int num_mailboxes,
                                                  uint32_t timeout);
void ams_can_send_log();

#endif /* INC_AMS_CAN_H_ */