#ifndef _CAN_BUFFER_H
#define _CAN_BUFFER_H
#include <string.h>
#include "system.h"
#define CAN_BUFFER_SIZE 8
typedef enum CanBufferStatus {CAN_BUFFER_OK, CAN_BUFFER_EMPTY, CAN_BUFFER_FULL} CanBufferStatus;
typedef struct CanBuffer
{
volatile CanRxMsgTypeDef data[CAN_BUFFER_SIZE];
volatile uint8_t head;
volatile uint8_t tail;
volatile uint8_t count;
} CanBuffer;
void can_buffer_init(volatile CanBuffer *buffer);
CanBufferStatus can_buffer_add(volatile CanBuffer *buffer, CanRxMsgTypeDef *msg);
volatile CanRxMsgTypeDef* can_buffer_remove(volatile CanBuffer *buffer);
bool can_buffer_is_empty(volatile CanBuffer *buffer);
uint8_t can_buffer_size(volatile CanBuffer *buffer);
#endif //_CAN_BUFFER_H