#ifndef CAN__H
#define CAN__H
#include "canapi.h"
#include "canapi_define.h"
#include "canapi_global.h"
/* The can.h is a header file for the functions and structure specific to the CAN interface between the microcontroller and CAN devices */
/* Structur for CAN data */
struct canStruct
{
	uint32_t Can_Message_ID;       
	uint32_t Can_Mask; 
        uint8_t Can_Mob;   
	uint8_t Can_Length;  
	//uint8_t Can_Data[8];  
        unsigned char Can_Data[8];
       
} ;
extern  struct canStruct canFrame;
extern  struct canStruct *ptr_canStruct;

/* implemented functions */

 int8_t CAN_Init(int32_t Baudrate);  /* initializieren CAN communication*/

 void Convert_canFormat_to_UartFormat(struct canStruct *ptr_canStruct);/*This function grabs the CAN data received in a string*/

 void Get_BusState(void); /* state on the CAN channel */

 void Get_CanError(void); /* can error for the communication */

 int8_t Get_FreeMob(void); /* searches free Mob */

 uint8_t Get_Interrupt_of_Mob( uint32_t bitmask) ;/* this function gets the index of the MOb for which the interrupt occured*/

 void Init(void); /* clean up of parameters */

 void Wait_for_Can_Send_Message_Finished(void); /* verify that the sending of data is complete */

 void Wait_for_Can_Receive_message_Finished(void); /* verify that the sending of data in the "Request case" is complete */

#endif
