#ifndef CANAPI__H
#define CANAPI__H
#include "can.h"
#include "canapi_define.h"
#include "canapi_global.h"

/* The canapi.h is a header file, the functions and structure of the variables specific to the serial interface between the CPU and micro controller */

/* The canapi.h is a header file for the functions and structure  specific to the serial interface between the SoC and microcontroller */

/* Structure for CPU commands */
 struct uartStruct
{
	char    *Name;
	uint32_t Uart_Message_ID;     
	uint32_t Uart_Mask;     
	uint8_t  Uart_Rtr;                
	uint8_t  Uart_Length; 
	uint16_t Uart_Data[8]; 
	//unsigned char Uart_Data[8]; ?? 
	

       
} ;
 extern struct uartStruct uartFrame;
 extern struct uartStruct *ptr_uartStruct;
 
/* Implemented functions */

void Choose_Function(struct uartStruct *ptr_uartStruct);/* in terms of the command name is the competent function */

//extern uint8_t Communication_Error( const char  Error[MAX_LENGTH_ERROR],const uint8_t Error_Number, char Error_typ[5]);/* error communication  for serial, CAN and mailbox*/
uint8_t Communication_Error(  char  Error[MAX_LENGTH_ERROR], uint8_t Error_Number, char Error_typ[5]);/* error communication  for serial, CAN and mailbox*/

void Convert_pack_canFrame_to_UartFormat(struct canStruct *ptr_canStruct);/* this function collects the various CAN data in a string */

void Convert_UartFormat_to_CanFormat( char string[MAX_PARAMETER][MAX_LENGTH_PARAMETER]); /*converting the decomposed CPU format in    CAN-format */

void Decrypt_Uart_String(char decryptString[MAX_LENGTH_PARAMETER]); /*CPU-cutting format in various parameters */

uint8_t General_Communication_Error(char Error[MAX_LENGTH_ERROR],uint8_t Error_Number);/* general error communication */

int8_t Get_out_RingBuffer (void);/*function to get saved CAN data in ringbuffer*/

void Receive_Message(struct uartStruct *PtrFrame); /* function for the SEND command name and RTR set, initialization of the registers with elements of the structure uartStruct */

void Send_Message(struct uartStruct *PtrFrame);/*function for the SEND command name and RTR is not set, initialization of the registers with elements of the structure uartStruct*/

void Subscribe_Message(struct uartStruct *PtrFrame); /* function for the command name SUBS, initialization of the registers with elements of the structure uartStruct */ 

int8_t Timer0_Init(void); /*initializieren  bit Timer0 */

int8_t Timer0A_Init(void); /* initializieren 8 bit Timermit output compareA*/

void Unsubscribe_Message(struct uartStruct *PtrFrame); /* function for the command name USUB, initialization of the registers with elements of the structure uartStruct */

int8_t UART0_Init (void); /* initializieren serial communication */

void UART0_Transmit(unsigned char c);/* function send  data direction to cpu */
 
int8_t UART0_Send_Message_String(char *tempstr);/* help function for the output of register contents in CPU */
int8_t UART1_Send_Message_String(char *tempstr);/* help function for the output of register contents in CPU */

int8_t Put_in_RingBuffer (char PutData[MAX_LENGTH_CAN_DATA]);/*funtion to put received CAN data in ringbuffer*/

#endif 
