#ifndef CANAPI_DEFINE__H
#define CANAPI_DEFINE__H
/*the define.h headerfile contents all define variable*/

/*Formula for calculating UBBR0
 *  UBBR0= F_CPU/(16*baud)-1
*/

/*currently selected baud rate for the serial communication: baudrate = 1152000 */
#define BAUD       10

/*size of array for the variable */
#define BUFFER_SIZE 100

/* maximun value for 11 bit identifier for CAN standard 2.0A*/
#define MAX_ELF_BIT  2047

/*maximun input in the ringbuffer*/
#define MAX_INPUT  30

/*maximun length of received CAN Data*/
#define MAX_LENGTH_CAN_DATA  41

/*maximun length of command with CAN standard 2.0A*/
#define MAX_LENGTH_COMMAND  48

/*maximun length of various error*/
#define MAX_LENGTH_ERROR  50

/* maximum length of their respective parameters of the strings via UART */
#define MAX_LENGTH_PARAMETER   8 

/*size of subscribe ID and Mask*/
#define MAX_LENGTH_SUBSCRIBE  15

/* maximum length of string received via UART */
#define MAX_PARAMETER          13  

/* undefined Mailbox */
#define NOMOB   0xFF

/*other selected baud rate for the CAN communication: baudrate = 125kps*/
#define ONEHUNDERTTWENTYFIVE_KPS  125000

/*timeout for sereial and CAN communication*/
#define TIMEOUT_A 5000 /*Timeout for UART-communication*/
#define TIMEOUT_C 5000 /*Timeout for CAN-communication*/

/*Timeout error*/
#define  TIME_S__ERROR "time is out for serial communication"
/*currently selected baud rate for the CAN communication: baudrate = 250kps*/
#define TWOHUNDERTFIFTY_KPS      250000


/*defined error for the serial communication */

#define  S_ERROR0  "no valid command name"
#define  S_ERROR1  "ID out of range"
#define  S_ERROR2  "mask out of range"
#define  S_ERROR3  "rtr out of range"
#define  S_ERROR4  "length out of range"
#define  S_ERROR50 "data 0 out of range"
#define  S_ERROR51 "data 1 out of range"
#define  S_ERROR52 "data 2 out of range"
#define  S_ERROR53 "data 3 out of range"
#define  S_ERROR54 "data 4 out of range"
#define  S_ERROR55 "data 5 out of range"
#define  S_ERROR56 "data 6 out of range"
#define  S_ERROR57 "data 7 out of range"
#define  S_ERROR6  "commando is out of range"
#define  S_ERROR10 "ID hat invalid typ"
#define  S_ERROR20 "mask has invalid typ"
#define  S_ERROR30 "rtr has invalid typ"
#define  S_ERROR40 "length had invalid typ"
#define  S_ERROR70 "data 0 had invalid typ"
#define  S_ERROR71 "data 1 had invalid typ"
#define  S_ERROR72 "data 2 had invalid typ"
#define  S_ERROR73 "data 3 had invalid typ"
#define  S_ERROR74 "data 4 had invalid typ"
#define  S_ERROR75 "data 5 had invalid typ"
#define  S_ERROR76 "data 6 had invalid typ"
#define  S_ERROR77 "data 7 had invalid typ"
#define  S_ERROR8  "undefined error typ" // not longer than MAX String
#define  S_ERROR9 "first Value is out of range "
#define  S_ERROR11 "second Value is out of range"

/*error number  for the serial communication */
#define  S_ERROR0_NO    11
#define  S_ERROR1_NO    12
#define  S_ERROR2_NO    13
#define  S_ERROR3_NO    14
#define  S_ERROR4_N0    15
#define  S_ERROR50_NO   16
#define  S_ERROR51_NO   17
#define  S_ERROR52_NO   18
#define  S_ERROR53_NO   19
#define  S_ERROR54_NO   110  
#define  S_ERROR55_NO   111
#define  S_ERROR56_NO   112
#define  S_ERROR57_NO   113
#define  S_ERROR6_NO    114
#define  S_ERROR10_NO   115
#define  S_ERROR20_NO   116
#define  S_ERROR30_NO   117
 #define S_ERROR40_NO   118
#define  S_ERROR70_NO   119
#define  S_ERROR71_NO   120
#define  S_ERROR72_NO   121
#define  S_ERROR73_NO   122
#define  S_ERROR74_NO   123
#define  S_ERROR75_NO   124 
#define  S_ERROR76_NO   125
#define  S_ERROR77_NO   126
#define  S_ERROR8_NO    127 
#define  S_ERROR9_NO    128
#define  S_ERROR11_NO   129 

#define ERROR_NO_ARRAY_SIZE (sizeof serial_error_number / sizeof serial_error_number[0])


/*defined error for the Message Object Block*/
#define  M_ERROR0  "all mailbox already in use"
#define  M_ERROR1  "message ID not found"
#define  M_ERROR2  "this message already exists"

/*defined error number for the Message Object Block*/
#define  M_ERROR0_NO  31
#define  M_ERROR1_NO  32
#define  M_ERROR2_NO  33

/* defined error for CAN channel states */
#define  C_ERROR0  "Can_Bus is off"
#define  C_ERROR1  "Can_Bus is passive"
#define  C_ERROR2  "Can_Bus is on"  
#define  C_ERROR8  "CAN was not successfully initialized"
/* error number for CAN channel states */
#define  C_ERROR0_NO  21
#define  C_ERROR1_NO  22
#define  C_ERROR2_NO  23
#define  C_ERROR8_NO  29

/* Error for CAN communikationl states */
#define  C_ERROR9  "timeout for CAN communication"
/* Error number for CAN communikationl states */
#define  C_ERROR9_NO  210

/*  CAN error states*/
#define  C_ERROR3 "Bit Error"
#define  C_ERROR4 "Stuff Error"
#define  C_ERROR5 "CRC Error"
#define  C_ERROR6 "Form Error"
#define  C_ERROR7 "Acknowdlegment Error"
/* defined error number for CAN states*/
#define  C_ERROR3_NO  24
#define  C_ERROR4_NO  25
#define  C_ERROR5_NO  26
#define  C_ERROR6_NO  27
#define  C_ERROR7_NO  28

/*defined error for the general communication */
#define  G_ERROR0   "initializieren for timer0 was unsuccessfully"
#define  G_ERROR1   "initializieren for timer0A was unsuccessfully"
#define  G_ERROR2   "the buffer is full"
#define  G_ERROR3   "CAN was not successfully initialized" 
#define  G_ERROR4   "all message were read" 
/* defined error number for the general communication */
#define  G_ERROR0_NO    41
#define  G_ERROR1_NO    42
#define  G_ERROR2_NO    43
#define  G_ERROR3_NO    44

/* confirmation of sending on the bus */
#define  READY     "command will be carried out"
#define  NOREADY   "command will  no be carried out"
/*define spezifish für gas_temp*/
#define  THIGH    900
#define  TLOW     100
#endif
