
#ifndef PROJECT_CFG_H
#define PROJECT_CFG_H

/* -------------------------------- Includes -------------------------------- */

/* -------------------------------- Defines --------------------------------- */
#define MAX_SECURITY_ATTEMPTS 3
//#define SW_VERSION ((UI_16)0x0101)
///*#define HW_VERSION ((UI_8)0x01)*/

/* Return the absolut value of the given parameter */
#define ABS(x) (((x)>=0)?(x):(-(x)))

/* Return the minimum parameter from the two parameters given */
#define MIN(x,y) (((x)>=(y))?(y):(x))

/* Return the maximum parameter from the two parameters given */
#define MAX(x,y) (((x)>=(y))?(x):(y))

/******* PWM *******/
//#define UC_PWM  				PwmConf_PwmChannel_PwmChannel1//PwmConf_PwmChannel_UC_PWM

//#define PWM_DUTY_0       ((UI_16)0x0000)
//#define PWM_DUTY_25      ((UI_16)0x2000)
//#define PWM_DUTY_50      ((UI_16)0x4000)
//#define PWM_DUTY_75      ((UI_16)0x6000)
//#define PWM_DUTY_100     ((UI_16)0x8000)
//#define PERCENT_0        ((UI_8)0)
//#define PERCENT_100      ((UI_8)1000)
//#define PWM_DUTY_X(X)    ((UI_16)(((UI_32)(X*PWM_DUTY_100))/PERCENT_100))
//#define PWM_X_DUTY(X)    ((UI_8)((UI_32)((X*PERCENT_100))/PWM_DUTY_100))

/******* DIO *******/
/* Defined at Dio_Cfg.h, DIO Channel Configuration Handles */

/******* ADC *******/
/* Defined at Adc_Cfg.h, ADC Group Handles */

/******* ATX GA *******/

/* GAC  ECU Identifier */
#define GAC_ECU_SW_VERSION_NUMBER   {'0','B','0','0','0','9'}
#define GAC_ECU_APP_VERSION_NUMBER  {'1','2','8'}
#define GAC_ECU_CALIBRATION_VERSION {'3','0','2','0','0','1','3','A','M','V','0','3','C','.','0','0','0'}
#define GAC_ECU_REPAIR_SHOP_CODE    {0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x30,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f}


#define GAC_ECUINSTALL_DATE_DEFAULT_VAL      {0,0,0,0}
#define GAC_APP_SW_FINGER_INFO      {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}
#define GAC_DCID_VALUE    		    {0x0D,0x00,0x00}
#define GAC_DIAG_PARAM_TABLE   	    {0x0,0x0,0x0,0x0}
#define GAC_VIN_DEFAULT_VALUE       {0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x30,0x30,0x30,0x30,0x30,0x30,0x30}
#define GAC_CLIBRATION_DATE_DEFAULT_VALUE  {0x05,0x31,0x20,0x21}
#define GAC_APP_DATAID_DEFAULT_VALUE  {0x00,0x00,0x00}
#define GAC_MANUF_ECUHWNUM_DEFAULT_VALUE   {'A','K','C','G','-','0','0','3','-','A','A'}
#define GAC_ECU_SN_DEFAULT_VALUE	{0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20}
#define GAC_APP_SW_LOGICAL_ID		{}
#define GAC_BOOT_ID_DEFAULT_VALUE  {'4','5','0'}
#define GAC_ECUSW_VERSION_DEFAULT_VALUE  {'S','W','0','4','0','1',' ',' ',' ',0x20,0x20,0x20,0x20,0x20,0x20,0x20}
#define GAC_APP_SUPPLIER_ID  {0x46,0x49,0x43,0x4F,0x53,0x41,0x20,0x49,0x4E,0x54,0x45,0x52,0x4e}; 


/* ------------------------------- Data Types ------------------------------- */
//typedef signed char int8_t;
//typedef unsigned char uint8_t;
typedef volatile signed char vint8_t;
typedef volatile unsigned char vuint8_t;

//typedef signed short int16_t;
//typedef unsigned short uint16_t;
typedef volatile signed short vint16_t;
typedef volatile unsigned short vuint16_t;

//typedef signed int int32_t;
//typedef unsigned int uint32_t;
typedef volatile signed int vint32_t;
typedef volatile unsigned int vuint32_t;

typedef enum {
	SYS_STARTUP  = 0,
	SYS_FAILSAFE = 1,
	SYS_RUN      = 2,
	SYS_SHUTDOWN = 3,
	SYS_SLEEP    = 4,
	SYS_MCAL     = 5,
}e_Sys_Status;


#define ISO15765_2_REPROGONCAN_HANDLER        ((UI_8)0)

#define DEBUG_ENABLE

/* ---------------------------- Global Variables ---------------------------- */
//extern Mcu_ResetType last_reset_cause;
//extern t_error cycle_violation;
/* --------------------------- Routine prototypes --------------------------- */

/* -------------------------------- Routines -------------------------------- */
//void OS_getFreezeRecordReset(UI_8 *pFreezeRecord);
//void OS_getFreezeRecordScheduler(UI_8 *pFreezeRecord);
/* IDs for Safety events. Must be consecutive numbers from 0 to NUM_SAFETY_EVENTS-1 */
#define SAFETY_EVENT_CAN_SPEED_LOST                 ((uint16)0)
#define SAFETY_EVENT_CAN_BRAKE_LOST                 ((uint16)1)
#define SAFETY_EVENT_ACT_SENSOR_1_NOK               ((uint16)2)
#define SAFETY_EVENT_ACT_SENSOR_2_NOK               ((uint16)3)
#define SAFETY_EVENT_ACT_SENSOR_ALL_NOK             ((uint16)4)
#define SAFETY_EVENT_ACT_CAL_NVM_KO                 ((uint16)5)
#define SAFETY_EVENT_ACT_SENSOR_1_NO_PLAUSIBLE      ((uint16)6)
#define SAFETY_EVENT_ACT_SENSOR_2_NO_PLAUSIBLE      ((uint16)7)
#define SAFETY_EVENT_ACT_POSITION_COMB_NO_PLAUSIBLE ((uint16)8)
#define SAFETY_EVENT_ACT_POSITION_INVALID           ((uint16)9)
#define SAFETY_EVENT_ROT_SENSOR_1_NOK               ((uint16)10)
#define SAFETY_EVENT_ROT_SENSOR_2_NOK               ((uint16)11)
#define SAFETY_EVENT_ROT_SENSOR_ALL_NOK             ((uint16)12)
#define SAFETY_EVENT_ROT_CAL_NVM_KO                 ((uint16)13)
#define SAFETY_EVENT_ROT_SENSOR_1_NO_PLAUSIBLE      ((uint16)14)
#define SAFETY_EVENT_ROT_SENSOR_2_NO_PLAUSIBLE      ((uint16)15)
#define SAFETY_EVENT_ROT_POSITION_COMB_NO_PLAUSIBLE ((uint16)16)
#define SAFETY_EVENT_PBUTTON_1_NOK                  ((uint16)17)
#define SAFETY_EVENT_PBUTTON_2_NOK                  ((uint16)18)
#define SAFETY_EVENT_PBUTTON_ALL_NOK                ((uint16)19)
#define SAFETY_EVENT_SSU_SFTY_WARNING               ((uint16)20)
#define SAFETY_EVENT_SSU_NOK                        ((uint16)21)
#define SAFETY_EVENT_INT_RAM_NOK                    ((uint16)22)
#define SAFETY_EVENT_INT_ROM_NOK                    ((uint16)23)
#define SAFETY_EVENT_INT_ADC_NOK                    ((uint16)24)
#define SAFETY_EVENT_INT_STACK_NOK                  ((uint16)25)
#define SAFETY_EVENT_INT_2E2_NOK                    ((uint16)26)
#define SAFETY_EVENT_INT_CPU_NOK                    ((uint16)27)
#define SAFETY_EVENT_CAN_SPEED_INVALID              ((uint16)28)
#define SAFETY_EVENT_CAN_BRAKE_INVALID              ((uint16)29)
#define SAFETY_EVENT_EPB_STS_LOST                   ((uint16)30)
#define SAFETY_EVENT_EPB_STS_INVALID                ((uint16)31)

#endif /* PROJECT_CFG_H */
