

#ifndef RBA_DEMOBDBASIC_DEM_H
#define RBA_DEMOBDBASIC_DEM_H

#include "rba_DemObdBasic_Types.h"

/* Needed for DTCFilterState Type */
#include "Dem_DTCFilter.h"

#define DEM_START_SEC_SAVED_ZONE
#include "Dem_Cfg_MemMap.h"

DEM_ARRAY_DECLARE(rba_DemObdBasic_PdtcMemType, rba_DemObdBasic_PdtcMem, DEM_CFG_PERMANENT_MEMORY_SIZE);

#define DEM_STOP_SEC_SAVED_ZONE
#include "Dem_Cfg_MemMap.h"

/* Main */
void rba_DemObdBasic_Init(void);
void rba_DemObdBasic_InitCheckNvm(void);
void rba_DemObdBasic_MainFunction(void);
void rba_DemObdBasic_Shutdown(void);
void rba_DemObdBasic_Clear(Dem_DTCOriginType DTCOrigin);

/* MiL */
Dem_IndicatorStatusType rba_DemObdBasic_Mil_GetIndicatorStatusExternal(void);

/* FF */
void rba_DemObdBasic_FF_CaptureFF(Dem_EventIdType EventId, uint8* dest, uint16 destSize);
Std_ReturnType rba_DemObdBasic_FF_RetrievePidData(uint8 PID, uint8* DestBuffer, uint16* BufSize, Dem_EvMemEventMemoryType* EventMemory);

/* OperationCycle */
void rba_DemObdBasic_StartOperationCycle(Dem_OperationCycleList currentTriggers);
void rba_DemObdBasic_SetOperationCycleState(Dem_OperationCycleList *operationCycleBitmask, Dem_OperationCycleStateType CycleState);

/* Event */
boolean rba_DemObdBasic_Event_IsRequestingMil(Dem_EventIdType EventId);

/* EvMem */
uint16_least rba_DemObdBasic_EvMem_GetLocationOfOBDFreezeFrame (void);
boolean rba_DemObdBasic_EvMem_IsTriggerObdFreezeFrame (Dem_EventIdType EventId, uint16_least MemId, uint16_least StatusOld, uint16_least StatusNew);
void rba_DemObdBasic_EvMem_CopyFreezeFrame (Dem_EventIdType EventId, uint8* dest, uint16 destSize, const uint8* src);
void rba_DemObdBasic_EvMem_CommonMilDebModifyFailureCounter (uint16_least LocId, uint16_least MemId, Dem_EventIdType EventId, uint16_least *failureCounter);
boolean rba_DemObdBasic_EvMem_IsAgingOfLocationAllowed (uint16_least LocId);
boolean rba_DemObdBasic_EvMem_IsDisplaceEventMemoryLocAllowed (Dem_EventIdType NewEventId, uint16_least LocId, uint16_least LocIdObdServ02);
void rba_DemObdBasic_EvMem_HandleImmediateAgeing(Dem_EventIdType EventId);
void rba_DemObdBasic_EvMem_StatusNotificationPending (uint16_least LocId, Dem_EventIdType EventId);
void rba_DemObdBasic_EvMem_StatusNotificationPendingConfirmed (uint16_least LocId, Dem_EventIdType EventId);
void rba_DemObdBasic_EvMem_StatusNotificationConfirmed (uint16_least LocId, Dem_EventIdType EventId);


/* Dtc */
Dem_DtcCodeType rba_DemObdBasic_Dtc_GetCode(Dem_DtcIdType dtcId);
Dem_ReturnGetNextFilteredDTCType rba_DemObdBasic_Dtc_GetNextFilteredDTC(Dem_DTCFilterState* dtcFilter_p, uint32* DTC, uint8* DTCStatus);
void rba_DemObdBasic_Dtc_DtcFilterInit(Dem_DTCFilterState* dtcFilter_p);
void rba_DemObdBasic_Dtc_SetDTCFilter(Dem_DTCFilterState* dtcFilter_p, Dem_DTCOriginType DTCOrigin);

#endif
