]> rtime.felk.cvut.cz Git - arc.git/commitdiff
Merged with dem-dev
authorpete <devnull@localhost>
Fri, 18 Dec 2009 12:15:45 +0000 (13:15 +0100)
committerpete <devnull@localhost>
Fri, 18 Dec 2009 12:15:45 +0000 (13:15 +0100)
27 files changed:
arch/arm/arm_cm3/drivers/Mcu.c
arch/ppc/mpc55xx/drivers/Can.c
arch/ppc/mpc55xx/drivers/Fls.c
arch/ppc/mpc55xx/drivers/Mcu.c
boards/board_common.mk
boards/generic/Dem_Cfg.h [new file with mode: 0644]
boards/generic/Dem_IntErrId.h [new file with mode: 0644]
boards/generic/Dem_IntEvtId.h [moved from diagnostic/Dem/Dem_IntEvtId.h with 80% similarity]
boards/generic/Dem_LCfg.c [moved from diagnostic/Dem/Dem_IntErrId.h with 52% similarity]
boards/mpc551xsim/config/EcuM_Lcfg.c
boards/mpc5567qrtech/build_config.mk
communication/Lin/LinIf.c
communication/PduR/PduR.c
communication/PduR/PduR_Cfg.h
communication/PduR/PduR_If.c
diagnostic/Dem/Dem.c
diagnostic/Dem/Dem_Lcfg.h
diagnostic/Dem/Dem_PBcfg.h [deleted file]
diagnostic/Dem/Dem_Types.h
include/Can.h
include/Dem.h
include/Fls.h
include/Lin.h
include/LinIf.h
memory/NvmM/NvM.c
peripherals/Fls_SST25xx.c
system/EcuM/EcuM_Callout_template.c

index 0ca26b49af38dd121eef1f6e1f8dc1e22744baa3..35105872982fb61c0b0bb00841db6cc4364ed033 100644 (file)
 
 #include "Std_Types.h"\r
 #include "Mcu.h"\r
-#include "Det.h"\r
+#include "Det.h"
+#if defined(USE_DEM)
+#include "Dem.h"\r
+#endif
 #include <assert.h>\r
 #include "cpu.h"\r
 #include <string.h>\r
@@ -85,11 +88,8 @@ Mcu_GlobalType Mcu_Global =
 
 #if 0\r
 static void Mcu_LossOfLock( void  ) {\r
-#if ( MCU_DEV_ERROR_DETECT == STD_ON )\r
-       /* Should report MCU_E_CLOCK_FAILURE with DEM here.... but\r
-        * we do the next best thing. Report with Det with API = 0\r
-        */\r
-       Det_ReportError(MODULE_ID_MCU,0,0,MCU_E_PLL_NOT_LOCKED);\r
+#if defined(USE_DEM)
+       Dem_ReportErrorStatus(MCU_E_CLOCK_FAILURE, DEM_EVENT_STATUS_FAILED);
 #endif\r
 \r
        Mcu_Global.stats.lossOfLockCnt++;\r
index aeddc2eb446d0f0aab5909cf01be00d83dcca360..6037bbc0264c1bc7491045539d41021445034335 100644 (file)
 #include "Cpu.h"\r
 #include "Mcu.h"\r
 #include "CanIf_Cbk.h"\r
-#include "Det.h"\r
+#include "Det.h"
+#if defined(USE_DEM)
+#include "Dem.h"\r
+#endif
 #include <assert.h>\r
 #include <stdlib.h>\r
 #include <string.h>\r
 #define VALIDATE_NO_RV(_exp,_api,_err )\r
 #define DET_REPORTERROR(_x,_y,_z,_q)\r
 #endif\r
-\r
+
+#if defined(USE_DEM)
+#define VALIDATE_DEM_NO_RV(_exp,_err ) \
+        if( !(_exp) ) { \
+          Dem_ReportErrorStatus(_err, DEM_EVENT_STATUS_FAILED); \
+          return; \
+        }
+#else
+#define VALIDATE_DEM_NO_RV(_exp,_err )
+#endif
+
 //-------------------------------------------------------------------\r
 \r
 // Message box status defines\r
@@ -853,10 +866,10 @@ void Can_InitController( uint8 controller, const Can_ControllerConfigType *confi
   tq2 = (config->CanControllerSeg2 + 1);\r
   tq = 1 + tq1 + tq2;\r
 \r
-  // Check TQ limitations..\r
-  VALIDATE_NO_RV(( (tq1>=4) && (tq1<=16)), 0x2, CAN_E_TIMEOUT ); // Actually should be sent to DEM\r
-  VALIDATE_NO_RV(( (tq2>=2) && (tq2<=8)), 0x2, CAN_E_TIMEOUT );  // but this is the next best thing\r
-  VALIDATE_NO_RV(( (tq>8) && (tq<25 )), 0x2, CAN_E_TIMEOUT );\r
+  // Check TQ limitations..
+  VALIDATE_DEM_NO_RV(( (tq1>=4) && (tq1<=16)), CAN_E_TIMEOUT );\r
+  VALIDATE_DEM_NO_RV(( (tq2>=2) && (tq2<=8)), CAN_E_TIMEOUT );\r
+  VALIDATE_DEM_NO_RV(( (tq>8) && (tq<25 )), CAN_E_TIMEOUT );\r
 \r
   // Assume we're using the peripheral clock instead of the crystal.\r
   clock = McuE_GetPeripheralClock(config->CanCpuClockRef);\r
index 5e2537dd897b54f6fadfd817566c12f04bff62df..68d21727326ab31616919a2183451ae52c668e41 100644 (file)
@@ -59,6 +59,9 @@
 #include <assert.h>
 #include <string.h>
 #include "Det.h"
+#if defined(USE_DEM)
+#include "Dem.h"
+#endif
 #include "h7f_types.h"
 #include "Cpu.h"
 #include "mpc55xx.h"
@@ -664,7 +667,9 @@ void Fls_MainFunction( void )
         Fls_Global.jobResultType = MEMIF_JOB_FAILED;
         Fls_Global.jobType = FLS_JOB_NONE;
         Fls_Global.status = MEMIF_IDLE;
-        DET_REPORTERROR(MODULE_ID_FLS,0, 0x6, FLS_E_WRITE_FAILED );
+#if defined(USE_DEM)
+               Dem_ReportErrorStatus(FLS_E_WRITE_FAILED, DEM_EVENT_STATUS_FAILED);
+#endif
         FEE_JOB_ERROR_NOTIFICATION();
       }
       break;
@@ -705,8 +710,10 @@ void Fls_MainFunction( void )
         Fls_Global.jobResultType = MEMIF_JOB_FAILED;
         Fls_Global.jobType = FLS_JOB_NONE;
         Fls_Global.status = MEMIF_IDLE;
-        DET_REPORTERROR(MODULE_ID_FLS,0, 0x6, FLS_E_WRITE_FAILED );
-        FEE_JOB_ERROR_NOTIFICATION();
+#if defined(USE_DEM)
+               Dem_ReportErrorStatus(FLS_E_WRITE_FAILED, DEM_EVENT_STATUS_FAILED);
+#endif
+               FEE_JOB_ERROR_NOTIFICATION();
       }
 
       break;
index 900fd5a1bcc69f70fe2bdd46321a57e6cabf08e1..77a654ba675a4adc8acef0a08ae9b7ea6f7c3319 100644 (file)
 #include <string.h>\r
 #include "Std_Types.h"\r
 #include "Mcu.h"\r
-#include "Det.h"\r
+#include "Det.h"
+#if defined(USE_DEM)
+#include "Dem.h"
+#endif
 #include "mpc55xx.h"\r
 #include "Cpu.h"\r
 #include "Ramlog.h"\r
@@ -101,11 +104,8 @@ Mcu_GlobalType Mcu_Global =
 //-------------------------------------------------------------------\r
 \r
 static void Mcu_LossOfLock( void  ) {\r
-#if ( MCU_DEV_ERROR_DETECT == STD_ON )\r
-       /* Should report MCU_E_CLOCK_FAILURE with DEM here.... but\r
-        * we do the next best thing. Report with Det with API = 0\r
-        */\r
-       Det_ReportError(MODULE_ID_MCU,0,0,MCU_E_PLL_NOT_LOCKED);\r
+#if defined(USE_DEM)
+       Dem_ReportErrorStatus(MCU_E_CLOCK_FAILURE, DEM_EVENT_STATUS_FAILED);
 #endif\r
 \r
        Mcu_Global.stats.lossOfLockCnt++;\r
index 8905c59e3e2278e6de1896f0d9dda0cc3a6cdf8e..9bed78fb7fc25df8be33057c70e05bffe938bca4 100644 (file)
@@ -132,6 +132,13 @@ inc-$(USE_PDUR) += $(ROOTDIR)/communication/PduR
 inc-$(USE_COM) += $(ROOTDIR)/communication/PduR\r
 vpath-$(USE_PDUR) += $(ROOTDIR)/communication/PduR\r
 \r
+#Dem\r
+obj-$(USE_DEM) += Dem.o\r
+obj-$(USE_DEM) += Dem_LCfg.o\r
+inc-$(USE_DEM) += $(ROOTDIR)/diagnostic/Dem\r
+vpath-$(USE_DEM) += $(ROOTDIR)/diagnostic/Dem\r
+\r
+\r
 #tests\r
 #obj-y += RunTests.o\r
 #obj-$(USE_CAN) += can_test.o\r
@@ -204,4 +211,4 @@ inc-y += $(ROOTDIR)/drivers/test
 # And last the generic board\r
 #\r
 inc-y += $(ROOTDIR)/boards/generic\r
-\r
+vpath-y += $(ROOTDIR)/boards/generic\r
diff --git a/boards/generic/Dem_Cfg.h b/boards/generic/Dem_Cfg.h
new file mode 100644 (file)
index 0000000..e87e6a8
--- /dev/null
@@ -0,0 +1,62 @@
+/* -------------------------------- Arctic Core ------------------------------
+ * Arctic Core - the open source AUTOSAR platform http://arccore.com
+ *
+ * Copyright (C) 2009  ArcCore AB <contact@arccore.com>
+ *
+ * This source code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by the
+ * Free Software Foundation; See <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * for more details.
+ * -------------------------------- Arctic Core ------------------------------*/
+
+
+
+
+
+
+
+
+#ifndef DEM_CFG_H_\r
+#define DEM_CFG_H_
+/*
+ * DEM General
+ */
+#define DEM_VERSION_INFO_API    STD_ON         // Activate/Deactivate ver info API.
+#define DEM_DEV_ERROR_DETECT   STD_ON          // Activate/Deactivate Dev Error Detection and Notification.
+#define DEM_OBD_SUPPORT                        STD_OFF
+#define DEM_PTO_SUPPORT                        STD_OFF
+
+#define DEM_BSW_ERROR_BUFFER_SIZE              20      // Max nr of elements in BSW error buffer (0..255)
+#define DEM_FF_DID_LENGTH                              TBD     // Length of DID & PID of FreezeFrames in Bytes.
+#define DEM_MAX_NUMBER_EVENT_ENTRY_MIR 0       // Max nr of events stored in mirror memory.
+#define DEM_MAX_NUMBER_EVENT_ENTRY_PER 0       // Max nr of events stored in permanent memory.
+#define DEM_MAX_NUMBER_EVENT_ENTRY_PRI 10      // Max nr of events stored in primary memory.
+#define DEM_MAX_NUMBER_EVENT_ENTRY_SEC 0       // Max nr of events stored in secondary memory.
+#define DEM_MAX_NUMBER_PRESTORED_FF            0       // Max nr of prestored FreezeFrames. 0=Not supported.
+
+/*
+ * Size limitations of the types derived from DemGeneral
+ */
+#define DEM_MAX_NR_OF_RECORDS_IN_EXTENDED_DATA 10      // 0..253 according to Autosar
+#define DEM_MAX_NR_OF_EVENT_DESTINATION                         4      // 0..4 according to Autosar
+
+/*
+ * Size limitations of storage area
+ */
+#define DEM_MAX_SIZE_FF_DATA                                    10     // Max number of bytes in one freeze frame
+#define DEM_MAX_SIZE_EXT_DATA                                   10     // Max number of bytes in one extended data record
+#define DEM_MAX_NUMBER_EVENT                                   100     // Max number of events to keep status on
+
+#define DEM_MAX_NUMBER_EVENT_PRE_INIT                   20     // Max number of events status to keep before init
+#define DEM_MAX_NUMBER_FF_DATA_PRE_INIT                         20     // Max number of freeze frames to store before init
+#define DEM_MAX_NUMBER_EXT_DATA_PRE_INIT                20     // Max number of extended data to store before init
+
+#define DEM_MAX_NUMBER_EVENT_PRI_MEM                   (DEM_MAX_NUMBER_EVENT_ENTRY_PRI)        // Max number of events status to store in primary memory
+#define DEM_MAX_NUMBER_FF_DATA_PRI_MEM                 5                                                                       // Max number of freeze frames to store in primary memory
+#define DEM_MAX_NUMBER_EXT_DATA_PRI_MEM                        5                                                                       // Max number of extended data to store in primary memory
+
+#endif /*DEM_CFG_H_*/\r
diff --git a/boards/generic/Dem_IntErrId.h b/boards/generic/Dem_IntErrId.h
new file mode 100644 (file)
index 0000000..30fc5cc
--- /dev/null
@@ -0,0 +1,81 @@
+/* -------------------------------- Arctic Core ------------------------------
+ * Arctic Core - the open source AUTOSAR platform http://arccore.com
+ *
+ * Copyright (C) 2009  ArcCore AB <contact@arccore.com>
+ *
+ * This source code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by the
+ * Free Software Foundation; See <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * for more details.
+ * -------------------------------- Arctic Core ------------------------------*/
+
+
+
+
+
+
+
+
+#ifndef DEM_INTERRID_H_\r
+#define DEM_INTERRID_H_\r
+\r
+#endif /*DEM_INTERRID_H_*/\r
+/*
+ * Definition of event IDs used by BSW
+ * NB! Must be unique for each event!
+ */
+\r
+enum {
+       // Event IDs from DEM module
+       DEM_EVENT_ID_NULL = 0,                  // Do not change this entry!!!
+
+       // Event IDs from MCU
+       MCU_E_CLOCK_FAILURE,
+
+       // Event IDs from CAN
+       CANTRCV_E_NO_TRCV_CONTROL,
+       CANTP_E_OPER_NOT_SUPPORTED,
+       CANTP_E_COMM,
+       CANNM_E_CANIF_TRANSMIT_ERROR,
+       CANM_E_NETWORK_TIMEOUT,
+       CANIF_TRCV_E_TRANSCEIVER,
+       CANIF_E_INVALID_DLC,
+       CANIF_STOPPED,
+       CANIF_E_FULL_TX_BUFFER,
+       CAN_E_TIMEOUT,
+
+       // Event IDs from EEPROM
+       EEP_E_COM_FAILURE,
+
+       // Event IDs from flash
+       FLS_E_ERASED_FAILED,
+       FLS_E_WRITE_FAILED,
+       FLS_E_READ_FAILED,
+       FLS_E_COMPARE_FAILED,
+       FLS_E_UNEXPECTED_FLASH_ID,
+
+       // Event IDs from LIN
+       LIN_E_TIMEOUT,
+       LINIF_E_RESPONSE,
+       LINIF_E_NC_NO_RESPONSE,
+       LINIF_E_CHANNEL_X_SLAVE_Y,
+
+       // Event IDs from ECU
+       ECUM_E_RAM_CHECK_FAILED,
+       ECUM_E_ALL_RUN_REQUESTS_KILLED,
+       ECUM_E_CONFIGURATION_DATA_INCONSISTENT,
+
+       // Event IDs from COM
+//     COMM_E_NET_START_IND_CHANNEL_<X>,
+
+       // Event IDs from PDUR
+       PDUR_E_PDU_INSTANCE_LOST,
+       PDUR_E_INIT_FAILED,
+
+       // DEM last event id for BSW
+       DEM_EVENT_ID_LAST_FOR_BSW
+};\r
similarity index 80%
rename from diagnostic/Dem/Dem_IntEvtId.h
rename to boards/generic/Dem_IntEvtId.h
index c6bf0c2fb79167f5ca0e9a2c941f1dc5d9690f90..6366aa27fec8f211b8bc16034513a95b02e440a5 100644 (file)
 
 
 #ifndef DEMINTEVTID_H_\r
-#define DEMINTEVTID_H_\r
+#define DEMINTEVTID_H_
+
+/*
+ * Definition of event IDs used by SW-C
+ * NB! Must be unique for each event!
+ */
+enum {
+       // NB! Event IDs below DEM_SWC_EVENT_ID_START not allowed!
+       DEM_EVENT_ID_SWC_START = DEM_EVENT_ID_LAST_FOR_BSW
+
+};
+\r
 \r
 #endif /*DEMINTEVTID_H_*/\r
similarity index 52%
rename from diagnostic/Dem/Dem_IntErrId.h
rename to boards/generic/Dem_LCfg.c
index b3078e46faa45dc6e518dd961b441b6b7c3938ad..23bd1543aa3ebed0dc131de206d4b31928200089 100644 (file)
 
 
 
-#ifndef DEM_INTERRID_H_\r
-#define DEM_INTERRID_H_\r
+#include "Dem.h"\r
 \r
-#endif /*DEM_INTERRID_H_*/\r
+/*********************\r
+ * DEM Configuration *
+ *********************/
+
+
+/*
+ * Classes of extended data record
+ */
+
+
+/*
+ * Classes of extended data
+ */
+
+
+/*
+ * Classes of freeze frames
+ */
+
+
+/*
+ * Classes of PreDebounce algorithms
+ */
+
+
+/*
+ * Classes of event
+ */
+
+
+/*
+ * Event parameter list
+ */
+const Dem_EventParameterType EventParameter[] = {
+               {
+                               .Arc_EOL  = TRUE
+               }
+};
+
+
+/*
+ * DEM's config set
+ */
+const Dem_ConfigSetType DEM_ConfigSet = {
+               .EventParameter = EventParameter,
+//             .DTCClassType = NULL,           TODO: Add later
+//             .GroupOfDtc = NULL,                     TODO: Add later
+//             .OemIdClass = NULL                      TODO: Add later
+};
 \r
-/* Added by Mattias Ekberg 2008-10-20 while implementing the PDU router. The value of PDUR_E_INSTANCE_LOST can\r
-   be changed without affecting the PDU router.*/\r
-#define PDUR_E_INSTANCE_LOST 0\r
+/*
+ * DEM's config
+ */
+const Dem_ConfigType DEM_Config = {\r
+       .ConfigSet = &DEM_ConfigSet,
+};\r
index 2e60b509e22da166e2b90b1fb44c84d1874ace89..d10fbed6e59490facf6da54fdc25ce5aba9af4d9 100644 (file)
@@ -91,7 +91,9 @@ void EcuM_Init( void ) {
 //     Mcu_GetResetReason();\r
 #if 0\r
        Det_Init();\r
+#if defined(USE_DEM)
        Dem_PreInit();\r
+#endif
        EcuM_AL_DriverInitOne();\r
 #endif\r
 \r
@@ -127,6 +129,7 @@ void EcuM_Init( void ) {
        NvM_WriteAll();\r
        NvM_CancelWriteAll();\r
 \r
+#if defined(USE_DEM)
        Dem_PreInit();\r
        Dem_Init();\r
        {\r
@@ -134,6 +137,7 @@ void EcuM_Init( void ) {
                Dem_EventStatusType status = 0;\r
                Dem_ReportErrorStatus(id,status);\r
        }\r
+#endif
        Rte_Start();\r
        Rte_Stop();\r
 #endif\r
index 266955cee58060558377c9df7f0680a0255981c5..f1650fc57ff4c115064403c65ba9d623ef872181 100644 (file)
@@ -9,7 +9,7 @@ CFG=PPC BOOKE E200Z6 MPC55XX MPC5567 BRD_MPC5567QRTECH SPE
 
 # What buildable modules does this board have, 
 # default or private
-MOD_AVAIL=KERNEL RAMLOG MCU WDG WDGM PORT DIO WDG WDGM T32_TERM WINIDEA_TERM PWM CAN CANIF COM ADC DMA SIMPLE_PRINTF
+MOD_AVAIL=KERNEL RAMLOG MCU WDG WDGM PORT DIO WDG WDGM T32_TERM WINIDEA_TERM PWM CAN CANIF COM ADC DMA SIMPLE_PRINTF DEM
 
 # Needed by us
 MOD_USE=KERNEL MCU
index 20011e3de52d70b7282fd8be26013f360fbd2979..9031a5f54923021cd7fc23982f437adb64b109ca 100644 (file)
 #include "Lin.h"\r
 #include "LinSM_Cbk.h"\r
 #include "PduR_LinIf.h"\r
-#include "Det.h"\r
+#include "Det.h"
+#if defined(USE_DEM)
+#include "Dem.h"
+#endif\r
 \r
 /* Development error macros. */\r
 #if ( LINIF_DEV_ERROR_DETECT == STD_ON )\r
@@ -207,15 +210,19 @@ void LinIf_MainFunction()
                                if(ptrFrame->LinIfPduDirection == LinIfRxPdu){\r
                                        if(Lin_GetStatus(LinIfChannelCfg[chIndex].LinIfChannelId, &Lin_SduPtr) == LIN_RX_OK){\r
                                                PduR_LinIfRxIndication(ptrFrame->LinIfTxTargetPduId,Lin_SduPtr);\r
-                                       }else{// RX_ERROR or BUSY\r
-                                       Det_ReportError(MODULE_ID_LINIF,0,LINIF_MAINFUNCTION_SERVICE_ID,LINIF_E_RESPONSE);\r
+                                       }else{// RX_ERROR or BUSY
+#if defined(USE_DEM)
+                                       Dem_ReportErrorStatus(LINIF_E_RESPONSE, DEM_EVENT_STATUS_FAILED);
+#endif\r
                                        }\r
                                } else if(ptrFrame->LinIfPduDirection == LinIfTxPdu){\r
                                        Lin_StatusType status = Lin_GetStatus(LinIfChannelCfg[chIndex].LinIfChannelId, &Lin_SduPtr);\r
                                        if(status == LIN_TX_OK){\r
                                                PduR_LinIfTxConfirmation(ptrFrame->LinIfTxTargetPduId);\r
                                        }else{// TX_ERROR or BUSY\r
-                                       Det_ReportError(MODULE_ID_LINIF,0,LINIF_MAINFUNCTION_SERVICE_ID,LINIF_E_RESPONSE);\r
+#if defined(USE_DEM)
+                                       Dem_ReportErrorStatus(LINIF_E_RESPONSE, DEM_EVENT_STATUS_FAILED);
+#endif
                                        }\r
                                }\r
                                // Update index after getting status of last frame\r
index 0780504e134b0e41809a92d00dfa4717511f2c4c..caf66f38b5ad0ed90e2442ebf673228e3b161fa6 100644 (file)
 #include <string.h>\r
 \r
 \r
-#include "Det.h"\r
+#include "Det.h"
+#if defined(USE_DEM)
+#include "Dem.h"\r
+#endif
 #include "PduR.h"\r
 #include "PduR_Com.h"\r
 #include "PduR_CanIf.h"\r
@@ -152,8 +155,9 @@ void PduR_BufferQueue(PduRTxBuffer_type *Buffer, const uint8 * SduPtr) {
 \r
        if (PduR_BufferIsFull(Buffer)) { // Buffer is full\r
                PduR_BufferFlush(Buffer);\r
-               DET_REPORTERROR(PDUR_MODULE_ID, PDUR_INSTANCE_ID, 0x00, PDUR_E_PDU_INSTANCE_LOST);\r
-\r
+#if defined(USE_DEM)
+               Dem_ReportErrorStatus(PDUR_E_PDU_INSTANCE_LOST, DEM_EVENT_STATUS_FAILED);\r
+#endif\r
 \r
        } else {\r
                // Copy data to last place in buffer\r
index 926029d755c135edddc4c9198d60e916eaadc190..b426545f1089b989d3eb1bf83026d812ada69caa 100644 (file)
@@ -92,4 +92,3 @@
 #define PDUR_E_PDU_ID_INVALID          0x02\r
 #define PDUR_E_TP_TX_REQ_REJECTED      0x03\r
 #define PDUR_E_DATA_PTR_INVALID                0x05\r
-#define PDUR_E_PDU_INSTANCE_LOST       0x10\r
index 3533d627639bb20424a8af4185ab9d923de7fb65..8b4712ade8645c65a21e0452815d0a23e603096a 100644 (file)
@@ -58,7 +58,7 @@ void PduR_LoIfRxIndication(PduIdType PduId, const uint8* SduPtr) {
                if (route->PduRDestPdu.TxBufferRef->TxConfP) { // Transfer confirmation pending.\r
                        // Enqueue the new I-PDU. This will flush the buffer if it is full according to the buffer specification.\r
                        PduR_BufferQueue(route->PduRDestPdu.TxBufferRef, SduPtr);\r
-                       // TODO report PDUR_E_INSTANCE_LOST to DEM if needed.\r
+                       // TODO report PDUR_E_PDU_INSTANCE_LOST to DEM if needed.\r
                }\r
 \r
                if (!route->PduRDestPdu.TxBufferRef->TxConfP) { // No transfer confirmation pending (anymore).\r
@@ -81,7 +81,7 @@ void PduR_LoIfRxIndication(PduIdType PduId, const uint8* SduPtr) {
                if (route->PduRDestPdu.TxBufferRef->TxConfP) { // Transfer confirmation pending.\r
                        DEBUG(DEBUG_LOW,"\tTransfer confirmation pending.\n");\r
                        PduR_BufferQueue(route->PduRDestPdu.TxBufferRef, SduPtr);\r
-                       // TODO report PDUR_E_INSTANCE_LOST to DEM if needed.\r
+                       // TODO report PDUR_E_PDU_INSTANCE_LOST to DEM if needed.\r
 \r
                }\r
 \r
@@ -99,10 +99,10 @@ void PduR_LoIfRxIndication(PduIdType PduId, const uint8* SduPtr) {
 \r
 \r
                        } else {\r
-                               // TODO report PDUR_E_INSTANCE_LOST to DEM.\r
-                               //Dem_ReportErrorStatus(PDUR_E_INSTANCE_LOST, 0);\r
-                               DET_REPORTERROR(PDUR_MODULE_ID, PDUR_INSTANCE_ID, 0x00, PDUR_E_PDU_INSTANCE_LOST);\r
-                               DEBUG(DEBUG_LOW,"\tTransmission failed. PDUR_E_INSTANCE_LOST\n");\r
+#if defined(USE_DEM)
+                               Dem_ReportErrorStatus(PDUR_E_PDU_INSTANCE_LOST, DEM_EVENT_STATUS_FAILED);\r
+#endif
+                               DEBUG(DEBUG_LOW,"\tTransmission failed. PDUR_E_PDU_INSTANCE_LOST\n");\r
                        }\r
                }\r
        }\r
index a9046c4084e3192fc85916bd5ad44c351c37e285..5cd685d4d680c414f179a247b4438534f3e9ba83 100644 (file)
 
 
 
+#include <string.h>
+#include "Dem.h"
+#include "Det.h"
+//#include "Fim.h"
+//#include "Nvm.h"
+//#include "SchM_Dem.h"
+#include "MemMap.h"
+#include "Mcu.h"
+
+/*
+ * Local types
+ */
+
+typedef uint16 ChecksumType;
+
+// For keeping track of the events status
+typedef struct {
+       Dem_EventIdType                         eventId;
+       uint16                                          occurrence;
+       Dem_EventStatusType                     eventStatus;
+       boolean                                         eventStatusChanged;
+       Dem_OperationCycleIdType        operationCycleId;
+       Dem_EventStatusExtendedType     eventStatusExtended;
+} EventStatusRecType;
+
+
+// Types for storing different event data on event memory
+typedef struct {
+       Dem_EventIdType         eventId;
+       uint16                          occurrence;
+       ChecksumType            checksum;
+} EventRecType;
+
+typedef struct {
+       Dem_EventIdType         eventId;
+       uint16                          occurrence;
+       uint16                          dataSize;
+       sint8                           data[DEM_MAX_SIZE_FF_DATA];
+       ChecksumType            checksum;
+} FreezeFrameRecType;
+
+typedef struct {
+       Dem_EventIdType         eventId;
+       uint16                          dataSize;
+       uint8                           data[DEM_MAX_SIZE_EXT_DATA];
+       ChecksumType            checksum;
+} ExtDataRecType;
+
+
+// State variable
+typedef enum
+{
+  DEM_UNINITIALIZED = 0,
+  DEM_PREINITIALIZED,
+  DEM_INITIALIZED
+} Dem_StateType;
+
+static Dem_StateType demState = DEM_UNINITIALIZED;
+
+// Help pointer to configuration set
+static const Dem_ConfigSetType *configSet;
+
+#if (DEM_VERSION_INFO_API == STD_ON)
+static Std_VersionInfoType _Dem_VersionInfo =
+{
+  .vendorID   = (uint16)1,
+  .moduleID   = (uint16)1,
+  .instanceID = (uint8)1,
+  .sw_major_version = (uint8)DEM_SW_MAJOR_VERSION,
+  .sw_minor_version = (uint8)DEM_SW_MINOR_VERSION,
+  .sw_patch_version = (uint8)DEM_SW_PATCH_VERSION,
+  .ar_major_version = (uint8)DEM_AR_MAJOR_VERSION,
+  .ar_minor_version = (uint8)DEM_AR_MINOR_VERSION,
+  .ar_patch_version = (uint8)DEM_AR_PATCH_VERSION,
+};
+#endif /* DEM_VERSION_INFO_API */
+
+/*
+ * Allocation of operation cycle state list
+ */
+
+static Dem_OperationCycleStateType operationCycleStateList[DEM_OPERATION_CYCLE_ID_ENDMARK];
+/*
+ * Allocation of local event status buffer
+ */
+static EventStatusRecType      eventStatusBuffer[DEM_MAX_NUMBER_EVENT];
+
+/*
+ * Allocation of pre-init event memory (used between pre-init and init)
+ */
+static FreezeFrameRecType      preInitFreezeFrameBuffer[DEM_MAX_NUMBER_FF_DATA_PRE_INIT];
+static ExtDataRecType          preInitExtDataBuffer[DEM_MAX_NUMBER_EXT_DATA_PRE_INIT];
+
+/*
+ * Allocation of primary event memory ramlog (after init)
+ */
+static EventRecType            priMemEventBuffer[DEM_MAX_NUMBER_EVENT_PRI_MEM];
+static FreezeFrameRecType      priMemFreezeFrameBuffer[DEM_MAX_NUMBER_FF_DATA_PRI_MEM];
+static ExtDataRecType          priMemExtDataBuffer[DEM_MAX_NUMBER_EXT_DATA_PRI_MEM];
+
+
+/*
+ * Procedure:  setZero
+ * Description:        Fill the *ptr to *(ptr+nrOfBytes-1) area with zeroes
+ */
+void setZero(void *ptr, uint16 nrOfBytes)
+{
+       uint8 *clrPtr = (uint8*)ptr;
+
+       if (nrOfBytes > 0)
+       {
+               *clrPtr = 0x00;
+               memcpy(clrPtr+1, clrPtr, nrOfBytes-1);
+       }
+}
+
+/*
+ * Procedure:  zeroPriMemBuffers
+ * Description:        Fill the primary buffers with zeroes
+ */
+void zeroPriMemBuffers(void)
+{
+       setZero(priMemEventBuffer, sizeof(priMemEventBuffer));
+       setZero(priMemFreezeFrameBuffer, sizeof(priMemFreezeFrameBuffer));
+       setZero(priMemExtDataBuffer, sizeof(priMemExtDataBuffer));
+}
+
+/*
+ * Procedure:  calcChecksum
+ * Description:        Calculate checksum over *data to *(data+nrOfBytes-1) area
+ */
+ChecksumType calcChecksum(void *data, uint16 nrOfBytes)
+{
+       uint16 i;
+       uint8 *ptr = (uint8*)data;
+       ChecksumType sum = 0;
+
+       for (i = 0; i < nrOfBytes; i++)
+               sum += *ptr++;
+       sum ^= 0xaaaa;
+       return sum;
+}
+
+/*
+ * Procedure:  updateEventStatusRec
+ * Description:        Update the status of "eventId", if not exist and "createIfNotExist" is
+ *                             true a new record is created
+ */
+void updateEventStatusRec(const Dem_EventParameterType *eventParam, Dem_EventStatusType eventStatus, boolean createIfNotExist, EventStatusRecType *eventStatusRec)
+{
+       uint16 i;
+       imask_t state = McuE_EnterCriticalSection();
+
+       // Lookup event ID
+       for (i = 0; (eventStatusBuffer[i].eventId != eventParam->EventID) && (i < DEM_MAX_NUMBER_EVENT); i++);
+
+       if ((i == DEM_MAX_NUMBER_EVENT) && (createIfNotExist)) {
+               // Search for free position
+               for (i = 0; (eventStatusBuffer[i].eventId != DEM_EVENT_ID_NULL) && (i < DEM_MAX_NUMBER_EVENT); i++);
+
+               if (i < DEM_MAX_NUMBER_EVENT) {
+                       // Create new event record
+                       eventStatusBuffer[i].eventId = eventParam->EventID;
+                       eventStatusBuffer[i].occurrence = 0;
+                       eventStatusBuffer[i].eventStatus = DEM_EVENT_STATUS_PASSED;
+                       eventStatusBuffer[i].eventStatusChanged = FALSE;
+                       eventStatusBuffer[i].operationCycleId = eventParam->EventClass->OperationCycleRef;
+                       eventStatusBuffer[i].eventStatusExtended = DEM_TEST_NOT_COMPLETED_SINCE_LAST_CLEAR | DEM_TEST_NOT_COMPLETED_THIS_OPERATION_CYCLE;
+               }
+               else {
+                       // Error: Event status buffer full
+                       Det_ReportError(MODULE_ID_DEM, 0, DEM_UPDATE_EVENT_STATUS_ID, DEM_E_EVENT_STATUS_BUFF_FULL);
+               }
+       }
+
+       if (i < DEM_MAX_NUMBER_EVENT) {
+               // Update event record
+               eventStatusBuffer[i].eventStatusExtended &= ~(DEM_TEST_NOT_COMPLETED_SINCE_LAST_CLEAR | DEM_TEST_NOT_COMPLETED_THIS_OPERATION_CYCLE);
+
+               if (eventStatus == DEM_EVENT_STATUS_FAILED) {
+                       eventStatusBuffer[i].eventStatusExtended |= (DEM_TEST_FAILED | DEM_TEST_FAILED_THIS_OPERATION_CYCLE | DEM_TEST_FAILED_SINCE_LAST_CLEAR);
+                       if       (eventStatusBuffer[i].eventStatus != eventStatus) {
+                               eventStatusBuffer[i].occurrence++;
+                       }
+               }
+
+               if (eventStatus == DEM_EVENT_STATUS_PASSED) {
+                       eventStatusBuffer[i].eventStatusExtended &= ~DEM_TEST_FAILED;
+               }
+
+               if (eventStatusBuffer[i].eventStatus != eventStatus) {
+                       eventStatusBuffer[i].eventStatus = eventStatus;
+                       eventStatusBuffer[i].eventStatusChanged = TRUE;
+               }
+               else {
+                       eventStatusBuffer[i].eventStatusChanged = FALSE;
+               }
+
+               // Copy the record
+               memcpy(eventStatusRec, &eventStatusBuffer[i], sizeof(EventStatusRecType));
+       }
+       else {
+               // Copy an empty record to return data
+               eventStatusRec->eventId = DEM_EVENT_ID_NULL;
+               eventStatusRec->eventStatus = DEM_EVENT_STATUS_PASSED;
+               eventStatusRec->occurrence = 0;
+               eventStatusBuffer[i].eventStatusChanged = FALSE;
+               eventStatusBuffer[i].eventStatusExtended = DEM_TEST_NOT_COMPLETED_THIS_OPERATION_CYCLE | DEM_TEST_NOT_COMPLETED_SINCE_LAST_CLEAR;
+       }
+
+
+       McuE_ExitCriticalSection(state);
+}
+
+
+/*
+ * Procedure:  mergeEventStatusRec
+ * Description:        Update the occurrence counter of status, if not exist a new record is created
+ */
+void mergeEventStatusRec(EventRecType *eventRec)
+{
+       uint16 i;
+       imask_t state = McuE_EnterCriticalSection();
+
+       // Lookup event ID
+       for (i = 0; (eventStatusBuffer[i].eventId != eventRec->eventId) && (i < DEM_MAX_NUMBER_EVENT); i++);
+
+       if (i < DEM_MAX_NUMBER_EVENT) {
+               // Update occurrence counter, rest of pre init state is kept.
+               eventStatusBuffer[i].occurrence += eventRec->occurrence;
+
+       }
+       else {
+               // Search for free position
+               for (i = 0; (eventStatusBuffer[i].eventId != DEM_EVENT_ID_NULL) && (i < DEM_MAX_NUMBER_EVENT); i++);
+
+               if (i < DEM_MAX_NUMBER_EVENT) {
+                       // Create new event, from stored event
+                       eventStatusBuffer[i].eventId = eventRec->eventId;
+                       eventStatusBuffer[i].occurrence = eventRec->occurrence;
+                       eventStatusBuffer[i].eventStatus = DEM_EVENT_STATUS_PASSED;
+                       eventStatusBuffer[i].eventStatusChanged = FALSE;
+               }
+               else {
+                       // Error: Event status buffer full
+                       Det_ReportError(MODULE_ID_DEM, 0, DEM_MERGE_EVENT_STATUS_ID, DEM_E_EVENT_STATUS_BUFF_FULL);
+               }
+       }
+
+       McuE_ExitCriticalSection(state);
+}
+
+/*
+ * Procedure:  getEventStatusRec
+ * Description:        Returns the status record of "eventId" in "eventStatusRec"
+ */
+void getEventStatusRec(Dem_EventIdType eventId, EventStatusRecType *eventStatusRec)
+{
+       uint16 i;
+       // Lookup event ID
+       for (i = 0; (eventStatusBuffer[i].eventId != eventId) && (i < DEM_MAX_NUMBER_EVENT); i++);
+
+       if (i < DEM_MAX_NUMBER_EVENT) {
+               // Copy the record
+               memcpy(eventStatusRec, &eventStatusBuffer[i], sizeof(EventStatusRecType));
+       }
+       else {
+               eventStatusRec->eventId = DEM_EVENT_ID_NULL;
+               eventStatusRec->eventStatus = DEM_EVENT_STATUS_PASSED;
+               eventStatusRec->occurrence = 0;
+       }
+}
+
+
+/*
+ * Procedure:  lookupEventIdParameter
+ * Description:        Returns the pointer to event id parameters of "eventId" in "*eventIdParam",
+ *                             if not found NULL is returned.
+ */
+void lookupEventIdParameter(Dem_EventIdType eventId, const Dem_EventParameterType **const eventIdParam)
+{
+       uint16 i;
+       *eventIdParam = NULL;
+
+       // Lookup the correct event id parameters
+       for (i = 0; !configSet->EventParameter[i].Arc_EOL; i++) {
+               if (configSet->EventParameter[i].EventID == eventId) {
+                       *eventIdParam = &configSet->EventParameter[i];
+                       return;
+               }
+       }
+       // Id not found return with NULL pointer
+}
+
+
+void getFreezeFrameData(const Dem_EventParameterType *eventParam, FreezeFrameRecType *freezeFrame)
+{
+       // TODO: Fill out
+}
+
+
+void storeFreezeFrameDataPreInit(const Dem_EventParameterType *eventParam, FreezeFrameRecType *freezeFrame)
+{
+       // TODO: Fill out
+}
+
+
+void updateFreezeFrameOccurrencePreInit(EventRecType *EventBuffer)
+{
+       // TODO: Fill out
+}
+
+/*
+ * Procedure:  getExtendedData
+ * Description:        Collects the extended data according to "eventParam" and return it in "extData",
+ *                             if not found eventId is set to DEM_EVENT_ID_NULL.
+ */
+void getExtendedData(const Dem_EventParameterType *eventParam, ExtDataRecType *extData)
+{
+       Std_ReturnType callbackReturnCode;
+       uint16 i;
+       uint16 storeIndex = 0;
+       uint16 recordSize;
+
+       // Clear ext data record
+       setZero(extData, sizeof(ExtDataRecType));
+
+       // Check if any pointer to extended data class
+       if (eventParam->ExtendedDataClassRef != NULL) {
+               // Request extended data and copy it to the buffer
+               for (i = 0; (i < DEM_MAX_NR_OF_RECORDS_IN_EXTENDED_DATA) && (eventParam->ExtendedDataClassRef->ExtendedDataRecordClassRef[i] != NULL); i++) {
+                       recordSize = eventParam->ExtendedDataClassRef->ExtendedDataRecordClassRef[i]->DataSize;
+                       if ((storeIndex + recordSize) <= DEM_MAX_SIZE_EXT_DATA) {
+                               callbackReturnCode = eventParam->ExtendedDataClassRef->ExtendedDataRecordClassRef[i]->CallbackGetExtDataRecord(&extData->data[storeIndex]);
+                               if (callbackReturnCode != E_OK) {
+                                       // Callback data currently not available, clear space.
+                                       setZero(&extData->data[storeIndex], recordSize);
+                               }
+                               storeIndex += recordSize;
+                       }
+                       else {
+                               // Error: Size of extended data record is bigger than reserved space.
+                               Det_ReportError(MODULE_ID_DEM, 0, DEM_GET_EXTENDED_DATA_ID, DEM_E_EXT_DATA_TO_BIG);
+                               break;  // Break the loop
+                       }
+               }
+       }
+
+       // Check if any data has been stored
+       if (storeIndex != 0) {
+               extData->eventId = eventParam->EventID;
+               extData->dataSize = storeIndex;
+               extData->checksum = calcChecksum(extData, sizeof(ExtDataRecType)-sizeof(ChecksumType));
+       }
+       else {
+               extData->eventId = DEM_EVENT_ID_NULL;
+               extData->dataSize = storeIndex;
+               extData->checksum = 0;
+       }
+}
+
+
+/*
+ * Procedure:  storeExtendedDataPreInit
+ * Description:        Store the extended data pointed by "extendedData" to the "preInitExtDataBuffer"
+ */
+void storeExtendedDataPreInit(const Dem_EventParameterType *eventParam, ExtDataRecType *extendedData)
+{
+       uint16 i;
+       imask_t state = McuE_EnterCriticalSection();
+
+       // Lookup first free position
+       for (i = 0; (preInitExtDataBuffer[i].eventId !=0) && (i<DEM_MAX_NUMBER_EXT_DATA_PRE_INIT); i++);
+
+       if (i < DEM_MAX_NUMBER_EXT_DATA_PRE_INIT) {
+               memcpy(&preInitExtDataBuffer[i], extendedData, sizeof(ExtDataRecType));
+       }
+       else {
+               // Error: Pre init extended data buffer full
+               Det_ReportError(MODULE_ID_DEM, 0, DEM_STORE_EXT_DATA_PRE_INIT_ID, DEM_E_PRE_INIT_EXT_DATA_BUFF_FULL);
+       }
+
+       McuE_ExitCriticalSection(state);
+}
+
+
+/*
+ * Procedure:  storeEventPriMem
+ * Description:        Store the event data of "eventStatus->eventId" in "priMemEventBuffer",
+ *                             if non existent a new entry is created.
+ */
+void storeEventPriMem(const Dem_EventParameterType *eventParam, EventStatusRecType *eventStatus)
+{
+       uint16 i;
+       imask_t state = McuE_EnterCriticalSection();
+
+
+       // Lookup event ID
+       for (i = 0; (priMemEventBuffer[i].eventId != eventStatus->eventId) && (i < DEM_MAX_NUMBER_EVENT_ENTRY_PRI); i++);
+
+       if (i < DEM_MAX_NUMBER_EVENT_ENTRY_PRI) {
+               // Update event found
+               priMemEventBuffer[i].occurrence = eventStatus->occurrence;
+               priMemEventBuffer[i].checksum = calcChecksum(&priMemEventBuffer[i], sizeof(EventRecType)-sizeof(ChecksumType));
+       }
+       else {
+               // Search for free position
+               for (i=0; (priMemEventBuffer[i].eventId != DEM_EVENT_ID_NULL) && (i < DEM_MAX_NUMBER_EVENT_ENTRY_PRI); i++);
+
+               if (i < DEM_MAX_NUMBER_EVENT_ENTRY_PRI) {
+                       priMemEventBuffer[i].eventId = eventStatus->eventId;
+                       priMemEventBuffer[i].occurrence = eventStatus->occurrence;
+                       priMemEventBuffer[i].checksum = calcChecksum(&priMemEventBuffer[i], sizeof(EventRecType)-sizeof(ChecksumType));
+               }
+               else {
+                       // Error: Pri mem event buffer full
+                       Det_ReportError(MODULE_ID_DEM, 0, DEM_STORE_EVENT_PRI_MEM_ID, DEM_E_PRI_MEM_EVENT_BUFF_FULL);
+               }
+       }
+
+       McuE_ExitCriticalSection(state);
+}
+
+
+/*
+ * Procedure:  storeEventEvtMem
+ * Description:        Store the event data of "eventStatus->eventId" in event memory according to
+ *                             "eventParam" destination option.
+ */
+void storeEventEvtMem(const Dem_EventParameterType *eventParam, EventStatusRecType *eventStatus)
+{
+       uint16 i;
+
+       for (i = 0; (i < DEM_MAX_NR_OF_EVENT_DESTINATION) && (eventParam->EventClass->EventDestination[i] != NULL); i++) {
+               switch (eventParam->EventClass->EventDestination[i])
+               {
+               case DEM_DTC_ORIGIN_PRIMARY_MEMORY:
+                       storeEventPriMem(eventParam, eventStatus);
+                       break;
+
+               case DEM_DTC_ORIGIN_SECONDARY_MEMORY:
+               case DEM_DTC_ORIGIN_PERMANENT_MEMORY:
+               case DEM_DTC_ORIGIN_MIRROR_MEMORY:
+                       // Not yet supported
+                       Det_ReportError(MODULE_ID_DEM, 0, DEM_GLOBAL_ID, DEM_E_NOT_IMPLEMENTED_YET);
+                       break;
+               default:
+                       break;
+               }
+       }
+}
+
+
+/*
+ * Procedure:  storeExtendedDataPriMem
+ * Description:        Creates new an extended data record in "priMemExtDataBuffer".
+ */
+void storeExtendedDataPriMem(const Dem_EventParameterType *eventParam, ExtDataRecType *extendedData)
+{
+       uint16 i;
+       imask_t state = McuE_EnterCriticalSection();
+
+       // Lookup first free position
+       for (i = 0; (priMemExtDataBuffer[i].eventId != DEM_EVENT_ID_NULL) && (i < DEM_MAX_NUMBER_EXT_DATA_PRI_MEM); i++);
+       if (i < DEM_MAX_NUMBER_EXT_DATA_PRI_MEM) {
+               memcpy(&priMemExtDataBuffer[i], extendedData, sizeof(ExtDataRecType));
+       }
+       else {
+               // Error: Pri mem extended data buffer full
+               Det_ReportError(MODULE_ID_DEM, 0, DEM_STORE_EXT_DATA_PRI_MEM_ID, DEM_E_PRI_MEM_EXT_DATA_BUFF_FULL);
+       }
+
+       McuE_ExitCriticalSection(state);
+}
+
+
+/*
+ * Procedure:  storeExtendedDataEvtMem
+ * Description:        Store the extended data in event memory according to
+ *                             "eventParam" destination option
+ */
+void storeExtendedDataEvtMem(const Dem_EventParameterType *eventParam, ExtDataRecType *extendedData)
+{
+       uint16 i;
+
+       for (i = 0; (i < DEM_MAX_NR_OF_EVENT_DESTINATION) && (eventParam->EventClass->EventDestination[i] != NULL); i++) {
+               switch (eventParam->EventClass->EventDestination[i])
+               {
+               case DEM_DTC_ORIGIN_PRIMARY_MEMORY:
+                       storeExtendedDataPriMem(eventParam, extendedData);
+                       break;
+
+               case DEM_DTC_ORIGIN_SECONDARY_MEMORY:
+               case DEM_DTC_ORIGIN_PERMANENT_MEMORY:
+               case DEM_DTC_ORIGIN_MIRROR_MEMORY:
+                       // Not yet supported
+                       Det_ReportError(MODULE_ID_DEM, 0, DEM_GLOBAL_ID, DEM_E_NOT_IMPLEMENTED_YET);
+                       break;
+               default:
+                       break;
+               }
+       }
+}
+
+
+void storeFreezeFrameDataPriMem(const Dem_EventParameterType *eventParam, FreezeFrameRecType *freezeFrame)
+{
+       // TODO: Fill out
+}
+
+
+/*
+ * Procedure:  storeFreezeFrameDataEvtMem
+ * Description:        Store the freeze frame data in event memory according to
+ *                             "eventParam" destination option
+ */
+void storeFreezeFrameDataEvtMem(const Dem_EventParameterType *eventParam, FreezeFrameRecType *freezeFrame)
+{
+       uint16 i;
+
+       for (i = 0; (i < DEM_MAX_NR_OF_EVENT_DESTINATION) && (eventParam->EventClass->EventDestination[i] != NULL); i++) {
+               switch (eventParam->EventClass->EventDestination[i])
+               {
+               case DEM_DTC_ORIGIN_PRIMARY_MEMORY:
+                       storeFreezeFrameDataPriMem(eventParam, freezeFrame);
+                       break;
+
+               case DEM_DTC_ORIGIN_SECONDARY_MEMORY:
+               case DEM_DTC_ORIGIN_PERMANENT_MEMORY:
+               case DEM_DTC_ORIGIN_MIRROR_MEMORY:
+                       // Not yet supported
+                       Det_ReportError(MODULE_ID_DEM, 0, DEM_GLOBAL_ID, DEM_E_NOT_IMPLEMENTED_YET);
+                       break;
+               default:
+                       break;
+               }
+       }
+}
+
+
+/*
+ * Procedure:  handlePreInitEvent
+ * Description:        Handle the updating of event status and storing of
+ *                             event related data in preInit buffers.
+ */
+void handlePreInitEvent(Dem_EventIdType eventId, Dem_EventStatusType eventStatus)
+{
+       const Dem_EventParameterType *eventParam;
+       EventStatusRecType eventStatusLocal;
+       FreezeFrameRecType freezeFrameLocal;
+       ExtDataRecType extendedDataLocal;
+
+       // Find configuration for this event
+       lookupEventIdParameter(eventId, &eventParam);
+       if (eventParam != NULL) {
+               if (eventParam->EventClass->OperationCycleRef < DEM_OPERATION_CYCLE_ID_ENDMARK) {
+                       if (operationCycleStateList[eventParam->EventClass->OperationCycleRef] == DEM_CYCLE_STATE_START) {
+                               if (eventStatus == DEM_EVENT_STATUS_PASSED) {
+                                       updateEventStatusRec(eventParam, eventStatus, FALSE, &eventStatusLocal);
+                               }
+                               else {
+                                       updateEventStatusRec(eventParam, eventStatus, TRUE, &eventStatusLocal);
+                               }
+
+                               if (eventStatusLocal.eventStatusChanged) {
+
+                                       if (eventStatusLocal.eventStatus == DEM_EVENT_STATUS_FAILED) {
+                                               // Collect freeze frame data
+                                               getFreezeFrameData(eventParam, &freezeFrameLocal);
+                                               storeFreezeFrameDataPreInit(eventParam, &freezeFrameLocal);
+
+                                               // Check if first time -> store extended data
+                                               if (eventStatusLocal.occurrence == 1) {
+                                                       // Collect extended data
+                                                       getExtendedData(eventParam, &extendedDataLocal);
+                                                       if (extendedDataLocal.eventId != DEM_EVENT_ID_NULL)
+                                                       {
+                                                               storeExtendedDataPreInit(eventParam, &extendedDataLocal);
+                                                       }
+                                               }
+                                       }
+                               }
+                       }
+                       else {
+                               // Operation cycle not started
+                               // TODO: Report error?
+                       }
+               }
+               else {
+                       // Operation cycle not set
+                       // TODO: Report error?
+               }
+       }
+       else {
+               // Event ID not configured
+               // TODO: Report error?
+       }
+}
+
+
+/*
+ * Procedure:  handleEvent
+ * Description:        Handle the updating of event status and storing of
+ *                             event related data in event memory.
+ */
+Std_ReturnType handleEvent(Dem_EventIdType eventId, Dem_EventStatusType eventStatus)
+{
+       Std_ReturnType returnCode = E_OK;
+       const Dem_EventParameterType *eventParam;
+       EventStatusRecType eventStatusLocal;
+       FreezeFrameRecType freezeFrameLocal;
+       ExtDataRecType extendedDataLocal;
+
+       // Find configuration for this event
+       lookupEventIdParameter(eventId, &eventParam);
+       if (eventParam != NULL) {
+               if (eventParam->EventClass->OperationCycleRef < DEM_OPERATION_CYCLE_ID_ENDMARK) {
+                       if (operationCycleStateList[eventParam->EventClass->OperationCycleRef] == DEM_CYCLE_STATE_START) {
+                               updateEventStatusRec(eventParam, eventStatus, TRUE, &eventStatusLocal);
+
+                               if (eventStatusLocal.eventStatusChanged) {
+
+                                       if (eventStatusLocal.eventStatus == DEM_EVENT_STATUS_FAILED) {
+                                               storeEventEvtMem(eventParam, &eventStatusLocal);
+                                               // Collect freeze frame data
+                                               getFreezeFrameData(eventParam, &freezeFrameLocal);
+                                               storeFreezeFrameDataEvtMem(eventParam, &freezeFrameLocal);
+
+                                               // Check if first time -> store extended data
+                                               if (eventStatusLocal.occurrence == 1) {
+                                                       // Collect extended data
+                                                       getExtendedData(eventParam, &extendedDataLocal);
+                                                       if (extendedDataLocal.eventId != DEM_EVENT_ID_NULL)
+                                                       {
+                                                               storeExtendedDataEvtMem(eventParam, &extendedDataLocal);
+                                                       }
+                                               }
+                                       }
+                               }
+                       }
+                       else {
+                               // Operation cycle not started
+                               returnCode = E_NOT_OK;
+                       }
+               }
+               else {
+                       // Operation cycle not set
+                       returnCode = E_NOT_OK;
+               }
+       }
+       else {
+               // Event ID not configured
+               returnCode = E_NOT_OK;
+       }
+
+       return returnCode;
+}
+
+
+/*
+ * Procedure:  getEventStatus
+ * Description:        Returns the extended event status bitmask of eventId in "eventStatusExtended".
+ */
+void getEventStatus(Dem_EventIdType eventId, Dem_EventStatusExtendedType *eventStatusExtended)
+{
+       EventStatusRecType eventStatusLocal;
+
+       // Get recorded status
+       getEventStatusRec(eventId, &eventStatusLocal);
+       if (eventStatusLocal.eventId == eventId) {
+               *eventStatusExtended = eventStatusLocal.eventStatusExtended;
+       }
+       else {
+               // Event Id not found, no report received.
+               *eventStatusExtended = DEM_TEST_NOT_COMPLETED_THIS_OPERATION_CYCLE | DEM_TEST_NOT_COMPLETED_SINCE_LAST_CLEAR;
+       }
+}
+
+/*
+ * Procedure:  getEventFailed
+ * Description:        Returns the TRUE or FALSE of "eventId" in "eventFailed" depending on current status.
+ */
+void getEventFailed(Dem_EventIdType eventId, boolean *eventFailed)
+{
+       EventStatusRecType eventStatusLocal;
+
+       // Get recorded status
+       getEventStatusRec(eventId, &eventStatusLocal);
+       if (eventStatusLocal.eventId == eventId) {
+               if (eventStatusLocal.eventStatusExtended & DEM_TEST_FAILED) {
+                       *eventFailed = TRUE;
+               }
+               else {
+                       *eventFailed = FALSE;
+               }
+       }
+       else {
+               // Event Id not found, assume ok.
+               *eventFailed = FALSE;
+       }
+}
+
+/*
+ * Procedure:  getEventTested
+ * Description:        Returns the TRUE or FALSE of "eventId" in "eventTested" depending on
+ *                             current status the "test not completed this operation cycle" bit.
+ */
+void getEventTested(Dem_EventIdType eventId, boolean *eventTested)
+{
+       EventStatusRecType eventStatusLocal;
+
+       // Get recorded status
+       getEventStatusRec(eventId, &eventStatusLocal);
+       if (eventStatusLocal.eventId == eventId) {
+               if ( !(eventStatusLocal.eventStatusExtended & DEM_TEST_NOT_COMPLETED_THIS_OPERATION_CYCLE)) {
+                       *eventTested = TRUE;
+               }
+               else {
+                       *eventTested = FALSE;
+               }
+       }
+       else {
+               // Event Id not found, not tested.
+               *eventTested = FALSE;
+       }
+}
+
+/*
+ * Procedure:  getFaultDetectionCounter
+ * Description:        Returns pre debounce counter of "eventId" in "counter" and return value E_OK if
+ *                     the counter was available else E_NOT_OK.
+ */
+Std_ReturnType getFaultDetectionCounter(Dem_EventIdType eventId, sint8 *counter)
+{
+       Std_ReturnType returnCode = E_NOT_OK;
+       const Dem_EventParameterType *eventParam;
+
+       lookupEventIdParameter(eventId, &eventParam);
+       if (eventParam != NULL) {
+               if (eventParam->EventClass->PreDebounceAlgorithmClass != NULL) {
+                       switch (eventParam->EventClass->PreDebounceAlgorithmClass->PreDebounceName)
+                       {
+                       case DEM_NO_PRE_DEBOUNCE:
+                               if (eventParam->EventClass->PreDebounceAlgorithmClass->PreDebounceAlgorithm.PreDebounceMonitorInternal != NULL) {
+                                       returnCode = eventParam->EventClass->PreDebounceAlgorithmClass->PreDebounceAlgorithm.PreDebounceMonitorInternal->CallbackGetFDCnt(counter);
+                               }
+                               break;
+
+                       case DEM_PRE_DEBOUNCE_COUNTER_BASED:
+                       case DEM_PRE_DEBOUNCE_FREQUENCY_BASED:
+                       case DEM_PRE_DEBOUNCE_TIME_BASED:
+#if (DEM_DEV_ERROR_DETECT == STD_ON)
+                               Det_ReportError(MODULE_ID_DEM, 0, DEM_GETFAULTDETECTIONCOUNTER_ID, DEM_E_NOT_IMPLEMENTED_YET);
+#endif
+                               break;
+
+                       default:
+#if (DEM_DEV_ERROR_DETECT == STD_ON)
+                               Det_ReportError(MODULE_ID_DEM, 0, DEM_GETFAULTDETECTIONCOUNTER_ID, DEM_E_PARAM_DATA);
+#endif
+                               break;
+                       }
+               }
+       }
+
+       return returnCode;
+}
+
+/*
+ * Procedure:  setOperationCycleState
+ * Description:        Change the operation state of "operationCycleId" to "cycleState" and updates stored
+ *                             event connected to this cycle id.
+ *                             Returns E_OK if operation was successful else E_NOT_OK.
+ */
+Std_ReturnType setOperationCycleState(Dem_OperationCycleIdType operationCycleId, Dem_OperationCycleStateType cycleState)
+{
+       uint16 i;
+       Std_ReturnType returnCode = E_OK;
+
+       if (operationCycleId < DEM_OPERATION_CYCLE_ID_ENDMARK) {
+               switch (cycleState)
+               {
+               case DEM_CYCLE_STATE_START:
+                       operationCycleStateList[operationCycleId] = cycleState;
+                       // Lookup event ID
+                       for (i = 0; i < DEM_MAX_NUMBER_EVENT; i++) {
+                               if ((eventStatusBuffer[i].eventId != DEM_EVENT_ID_NULL) && (eventStatusBuffer[i].operationCycleId == operationCycleId)) {
+                                       eventStatusBuffer[i].eventStatusExtended &= ~DEM_TEST_FAILED_THIS_OPERATION_CYCLE;
+                                       eventStatusBuffer[i].eventStatusExtended |= DEM_TEST_NOT_COMPLETED_THIS_OPERATION_CYCLE;
+                               }
+                       }
+                       break;
+
+               case DEM_CYCLE_STATE_END:
+                       operationCycleStateList[operationCycleId] = cycleState;
+                       break;
+               default:
+#if (DEM_DEV_ERROR_DETECT == STD_ON)
+                       Det_ReportError(MODULE_ID_DEM, 0, DEM_SETOPERATIONCYCLESTATE_ID, DEM_E_PARAM_DATA);
+#endif
+                       returnCode = E_NOT_OK;
+                       break;
+               }
+       }
+       else {
+#if (DEM_DEV_ERROR_DETECT == STD_ON)
+               Det_ReportError(MODULE_ID_DEM, 0, DEM_SETOPERATIONCYCLESTATE_ID, DEM_E_PARAM_DATA);
+#endif
+               returnCode = E_NOT_OK;
+               }
+
+       return returnCode;
+}
+
+//==============================================================================//
+//                                                                                                                                                             //
+//                                       E X T E R N A L   F U N C T I O N S                                           //
+//                                                                                                                                                             //
+//==============================================================================//
+
+/*********************************************
+ * Interface for upper layer modules (8.3.1) *
+ *********************************************/
+
+/*
+ * Procedure:  Dem_GetVersionInfo
+ * Reentrant:  Yes
+ */
+#if (DEM_VERSION_INFO_API == STD_ON)
+void Dem_GetVersionInfo(Std_VersionInfoType *versionInfo) {
+       memcpy(versionInfo, &_Dem_VersionInfo, sizeof(Std_VersionInfoType));
+}
+#endif /* DEM_VERSION_INFO_API */
+
+
+/***********************************************
+ * Interface ECU State Manager <-> DEM (8.3.2) *
+ ***********************************************/
+
+/*
+ * Procedure:  Dem_PreInit
+ * Reentrant:  No
+ */
+void Dem_PreInit(void)
+{
+       int i, j;
+
+       if (DEM_Config.ConfigSet == NULL) {
+               Det_ReportError(MODULE_ID_DEM, 0, DEM_PREINIT_ID, DEM_E_CONFIG_PTR_INVALID);
+               return;
+       } else {
+               configSet = DEM_Config.ConfigSet;
+       }
+
+       // Initializion of operation cycle states.
+       for (i = 0; i < DEM_OPERATION_CYCLE_ID_ENDMARK; i++) {
+               operationCycleStateList[i] = DEM_CYCLE_STATE_END;
+       }
+
+       // Initialize the event status buffer
+       for (i = 0; i < DEM_MAX_NUMBER_EVENT; i++) {
+               eventStatusBuffer[i].eventId = DEM_EVENT_ID_NULL;
+               eventStatusBuffer[i].occurrence = 0;
+               eventStatusBuffer[i].eventStatusExtended = DEM_TEST_NOT_COMPLETED_THIS_OPERATION_CYCLE | DEM_TEST_NOT_COMPLETED_SINCE_LAST_CLEAR;
+               eventStatusBuffer[i].eventStatus = DEM_EVENT_STATUS_PASSED;
+               eventStatusBuffer[i].eventStatusChanged = FALSE;
+       }
+
+       for (i = 0; i < DEM_MAX_NUMBER_FF_DATA_PRE_INIT; i++) {
+               preInitFreezeFrameBuffer[i].checksum = 0;
+               preInitFreezeFrameBuffer[i].eventId = DEM_EVENT_ID_NULL;
+               preInitFreezeFrameBuffer[i].occurrence = 0;
+               preInitFreezeFrameBuffer[i].dataSize = 0;
+               for (j = 0; j < DEM_MAX_SIZE_FF_DATA;j++)
+                       preInitFreezeFrameBuffer[i].data[j] = 0;
+       }
+
+       for (i = 0; i < DEM_MAX_NUMBER_EXT_DATA_PRE_INIT; i++) {
+               preInitExtDataBuffer[i].checksum = 0;
+               preInitExtDataBuffer[i].eventId = DEM_EVENT_ID_NULL;
+               preInitExtDataBuffer[i].dataSize = 0;
+               for (j = 0; j < DEM_MAX_SIZE_EXT_DATA;j++)
+                       preInitExtDataBuffer[i].data[j] = 0;
+       }
+
+       setOperationCycleState(DEM_ACTIVE, DEM_CYCLE_STATE_START);
+
+       demState = DEM_PREINITIALIZED;
+}
+
+
+/*
+ * Procedure:  Dem_Init
+ * Reentrant:  No
+ */
+void Dem_Init(void)
+{
+       uint16 i;
+       ChecksumType cSum;
+       EventStatusRecType eventStatusLocal;
+       const Dem_EventParameterType *eventParam;
+
+       /*
+        *  Validate and read out saved error log from non volatile memory
+        */
+
+       // Validate event records stored in primary memory
+       for (i = 0; i < DEM_MAX_NUMBER_EVENT_PRI_MEM; i++) {
+               cSum = calcChecksum(&priMemEventBuffer[i], sizeof(EventRecType)-sizeof(ChecksumType));
+               if ((cSum != priMemEventBuffer[i].checksum) || priMemEventBuffer[i].eventId == DEM_EVENT_ID_NULL) {
+                       // Not valid, clear the record
+                       setZero(&priMemEventBuffer[i], sizeof(EventRecType));
+               }
+               else {
+                       // Valid, update current status
+                       mergeEventStatusRec(&priMemEventBuffer[i]);
+
+                       // Update occurrence counter on pre init stored freeze frames
+                       updateFreezeFrameOccurrencePreInit(&priMemEventBuffer[i]);
+               }
+       }
+
+       // Validate extended data records stored in primary memory
+       for (i = 0; i < DEM_MAX_NUMBER_EXT_DATA_PRI_MEM; i++) {
+               cSum = calcChecksum(&priMemExtDataBuffer[i], sizeof(ExtDataRecType)-sizeof(ChecksumType));
+               if ((cSum != priMemExtDataBuffer[i].checksum) || priMemExtDataBuffer[i].eventId == DEM_EVENT_ID_NULL) {
+                       // Unlegal record, clear the record
+                       setZero(&priMemExtDataBuffer[i], sizeof(ExtDataRecType));
+               }
+       }
+
+       // Validate freeze frame records stored in primary memory
+       for (i = 0; i < DEM_MAX_NUMBER_FF_DATA_PRI_MEM; i++) {
+               cSum = calcChecksum(&priMemFreezeFrameBuffer[i], sizeof(FreezeFrameRecType)-sizeof(ChecksumType));
+               if ((cSum != priMemFreezeFrameBuffer[i].checksum) || (priMemFreezeFrameBuffer[i].eventId == DEM_EVENT_ID_NULL)) {
+                       // Wrong checksum, clear the record
+                       setZero(&priMemFreezeFrameBuffer[i], sizeof(FreezeFrameRecType));
+               }
+       }
+
+       /*
+        *  Handle errors stored in temporary buffer (if any)
+        */
+
+       // Transfer updated event data to event memory
+       for (i = 0; i < DEM_MAX_NUMBER_EVENT; i++) {
+               if (eventStatusBuffer[i].eventId != DEM_EVENT_ID_NULL) {
+                       // Update the event memory
+                       lookupEventIdParameter(eventStatusBuffer[i].eventId, &eventParam);
+                       storeEventEvtMem(eventParam, &eventStatusBuffer[i]);
+               }
+       }
+
+       // Transfer extended data to event memory if necessary
+       for (i = 0; i < DEM_MAX_NUMBER_EXT_DATA_PRE_INIT; i++) {
+               if (preInitExtDataBuffer[i].eventId !=  DEM_EVENT_ID_NULL) {
+                       getEventStatusRec(preInitExtDataBuffer[i].eventId, &eventStatusLocal);
+                       // Check if new or old error event
+                       if (eventStatusLocal.occurrence == 1) {
+                               // It has not been stored before so store it.
+                               lookupEventIdParameter(preInitExtDataBuffer[i].eventId, &eventParam);
+                               storeExtendedDataEvtMem(eventParam, &preInitExtDataBuffer[i]);
+                       }
+               }
+       }
+
+       // Transfer freeze frames to event memory
+       for (i = 0; i < DEM_MAX_NUMBER_FF_DATA_PRE_INIT; i++) {
+               if (preInitFreezeFrameBuffer[i].eventId != DEM_EVENT_ID_NULL) {
+                       lookupEventIdParameter(preInitFreezeFrameBuffer[i].eventId, &eventParam);
+                       storeFreezeFrameDataEvtMem(eventParam, &preInitFreezeFrameBuffer[i]);
+               }
+       }
+
+       demState = DEM_INITIALIZED;
+}
+
+
+/*
+ * Procedure:  Dem_shutdown
+ * Reentrant:  No
+ */
+void Dem_Shutdown(void)
+{
+       setOperationCycleState(DEM_ACTIVE, DEM_CYCLE_STATE_END);
+
+       demState = DEM_UNINITIALIZED;
+}
+
+
+/*
+ * Interface for basic software scheduler
+ */
+void Dem_MainFunction(void)
+{
+
+}
+
+
+/***************************************************
+ * Interface SW-Components via RTE <-> DEM (8.3.3) *
+ ***************************************************/
+
+/*
+ * Procedure:  Dem_SetEventStatus
+ * Reentrant:  Yes
+ */
+Std_ReturnType Dem_SetEventStatus(Dem_EventIdType eventId, Dem_EventStatusType eventStatus)
+{
+       Std_ReturnType returnCode = E_OK;
+
+       if (demState == DEM_INITIALIZED) // No action is taken if the module is not started
+       {
+               returnCode = handleEvent(eventId, eventStatus);
+       }
+       else
+       {
+#if (DEM_DEV_ERROR_DETECT == STD_ON)
+               Det_ReportError(MODULE_ID_DEM, 0, DEM_SETEVENTSTATUS_ID, DEM_E_UNINIT);
+               returnCode = E_NOT_OK;
+#endif
+       }
+
+       return returnCode;
+}
+
+
+/*
+ * Procedure:  Dem_ResetEventStatus
+ * Reentrant:  Yes
+ */
+Std_ReturnType Dem_ResetEventStatus(Dem_EventIdType eventId)
+{
+       const Dem_EventParameterType *eventParam;
+       EventStatusRecType eventStatusLocal;
+       Std_ReturnType returnCode = E_OK;
+
+       if (demState == DEM_INITIALIZED) // No action is taken if the module is not started
+       {
+               lookupEventIdParameter(eventId, &eventParam);
+               if (eventParam != NULL) {
+                       updateEventStatusRec(eventParam, DEM_EVENT_STATUS_PASSED, FALSE, &eventStatusLocal);
+               }
+       }
+       else
+       {
+#if (DEM_DEV_ERROR_DETECT == STD_ON)
+               Det_ReportError(MODULE_ID_DEM, 0, DEM_RESETEVENTSTATUS_ID, DEM_E_UNINIT);
+#endif
+               returnCode = E_NOT_OK;
+       }
+
+       return returnCode;
+}
+
+
+Std_ReturnType Dem_GetEventStatus(Dem_EventIdType eventId, Dem_EventStatusExtendedType *eventStatusExtended)
+{
+       Std_ReturnType returnCode = E_OK;
+
+       if (demState == DEM_INITIALIZED) // No action is taken if the module is not started
+       {
+               getEventStatus(eventId, eventStatusExtended);
+       }
+       else
+       {
+#if (DEM_DEV_ERROR_DETECT == STD_ON)
+               Det_ReportError(MODULE_ID_DEM, 0, DEM_GETEVENTSTATUS_ID, DEM_E_UNINIT);
+#endif
+               returnCode = E_NOT_OK;
+       }
+
+       return returnCode;
+}
+
+
+Std_ReturnType Dem_GetEventFailed(Dem_EventIdType eventId, boolean *eventFailed)
+{
+       Std_ReturnType returnCode = E_OK;
+
+       if (demState == DEM_INITIALIZED) // No action is taken if the module is not started
+       {
+               getEventFailed(eventId, eventFailed);
+       }
+       else
+       {
+#if (DEM_DEV_ERROR_DETECT == STD_ON)
+               Det_ReportError(MODULE_ID_DEM, 0, DEM_GETEVENTFAILED_ID, DEM_E_UNINIT);
+#endif
+               returnCode = E_NOT_OK;
+       }
+
+       return returnCode;
+}
+
+
+Std_ReturnType Dem_GetEventTested(Dem_EventIdType eventId, boolean *eventTested)
+{
+       Std_ReturnType returnCode = E_OK;
+
+       if (demState == DEM_INITIALIZED) // No action is taken if the module is not started
+       {
+               getEventTested(eventId, eventTested);
+       }
+       else
+       {
+#if (DEM_DEV_ERROR_DETECT == STD_ON)
+               Det_ReportError(MODULE_ID_DEM, 0, DEM_GETEVENTTESTED_ID, DEM_E_UNINIT);
+#endif
+               returnCode = E_NOT_OK;
+       }
+
+       return returnCode;
+}
+
+
+Std_ReturnType Dem_GetFaultDetectionCounter(Dem_EventIdType eventId, sint8 *counter)
+{
+       Std_ReturnType returnCode = E_OK;
+
+       if (demState == DEM_INITIALIZED) // No action is taken if the module is not started
+       {
+               returnCode = getFaultDetectionCounter(eventId, counter);
+       }
+       else
+       {
+#if (DEM_DEV_ERROR_DETECT == STD_ON)
+               Det_ReportError(MODULE_ID_DEM, 0, DEM_GETFAULTDETECTIONCOUNTER_ID, DEM_E_UNINIT);
+#endif
+               returnCode = E_NOT_OK;
+       }
+
+       return returnCode;
+}
+
+
+Std_ReturnType Dem_SetOperationCycleState(Dem_OperationCycleIdType operationCycleId, Dem_OperationCycleStateType cycleState)
+{
+       Std_ReturnType returnCode = E_OK;
+
+       if (demState == DEM_INITIALIZED) // No action is taken if the module is not started
+       {
+               returnCode = setOperationCycleState(operationCycleId, cycleState);
+
+       }
+       else
+       {
+#if (DEM_DEV_ERROR_DETECT == STD_ON)
+               Det_ReportError(MODULE_ID_DEM, 0, DEM_SETOPERATIONCYCLESTATE_ID, DEM_E_UNINIT);
+#endif
+               returnCode = E_NOT_OK;
+       }
+
+       return returnCode;
+}
+
+
+/********************************************
+ * Interface BSW-Components <-> DEM (8.3.4) *
+ ********************************************/
+
+/*
+ * Procedure:  Dem_ReportErrorStatus
+ * Reentrant:  Yes
+ */
+void Dem_ReportErrorStatus( Dem_EventIdType eventId, Dem_EventStatusType eventStatus )
+{
+
+       switch (demState) {
+               case DEM_PREINITIALIZED:
+                       // Update status and check if is to be stored
+                       if ((eventStatus == DEM_EVENT_STATUS_PASSED) || (eventStatus == DEM_EVENT_STATUS_FAILED)) {
+                               handlePreInitEvent(eventId, eventStatus);
+                       }
+                       break;
+
+               case DEM_INITIALIZED:
+                       // Handle report
+                       if ((eventStatus == DEM_EVENT_STATUS_PASSED) || (eventStatus == DEM_EVENT_STATUS_FAILED)) {
+                               (void)handleEvent(eventId, eventStatus);
+                       }
+                       break;
+
+               case DEM_UNINITIALIZED:
+               default:
+                       // Uninitialized can not do anything
+#if (DEM_DEV_ERROR_DETECT == STD_ON)
+                       Det_ReportError(MODULE_ID_DEM, 0, DEM_REPORTERRORSTATUS_ID, DEM_E_UNINIT);
+#endif
+                       break;
+
+       } // switch (demState)
+}
+
+/*********************************
+ * Interface DCM <-> DEM (8.3.5) *
+ *********************************/
+
+/***********************************
+ * OBD-specific Interfaces (8.3.6) *
+ ***********************************/
 
 
 
-\r
-#include "Std_Types.h"\r
-#include "Rte.h"\r
-#include "Dem.h"\r
-#include "Dem_Lcfg.h"\r
-#include "Dem_PBcfg.h"\r
-//#include "NvM.h"\r
-// #include "Fim.h"\r
-// #include "Rte_Dem.h"\r
-#include "Dem_IntEvtId.h"\r
-#include "Dem_IntErrId.h"\r
-#include "Os.h"\r
-\r
-void Dem_PreInit( void ) {\r
-       \r
-}\r
-void Dem_Init( void ) {\r
-       \r
-}\r
-\r
-Std_ReturnType Dem_ReportErrorStatus( Dem_EventIdType id ,Dem_EventStatusType type ) {\r
-       (void )id;\r
-       (void )type;\r
-       return RTE_E_OK;\r
-}\r
index be4a3c8b74aeaa59efb63f6be2e8a86363060416..cad02f535d35e71fab2c1d56cee5e607168c71e7 100644 (file)
 
 
 #ifndef DEM_LCFG_H_\r
-#define DEM_LCFG_H_\r
+#define DEM_LCFG_H_
+
+#include "Dem_Types.h"
+
+
+/*
+ * Callback function prototypes
+ */
+
+// InitMonitorForEvent
+typedef Std_ReturnType (*Dem_CallbackInitMonitorForEventFncType)(Dem_InitMonitorKindType InitMonitorKind);
+
+// InitMonitorForFunction
+typedef Std_ReturnType (*Dem_CallbackInitMonitorForFunctionFncType)(void);
+
+// EventStatusChanged
+typedef Std_ReturnType (*Dem_CallbackEventStatusChangedFncType)(Dem_EventStatusExtendedType EventStatusOld, Dem_EventStatusExtendedType EventStatusNew);
+
+// DTCStatusChanged
+typedef Std_ReturnType (*Dem_CallbackDTCStatusChangedFncType)(uint8 DTCStatusOld, uint8 DTCStatusNew);
+
+// DIDServices
+#if 1  // Until DCM is available
+typedef uint8 Dcm_NegativeResponseCodeType;
+#endif
+typedef Std_ReturnType (*Dem_CallbackConditionCheckReadFncType)(Dcm_NegativeResponseCodeType *Nrc);
+typedef Std_ReturnType (*Dem_CallbackReadDataFncType)(uint8 *Data);
+typedef Std_ReturnType (*Dem_CallbackReadDataLength)(uint16 *DidLength);
+
+// GetExtendedDataRecord
+typedef Std_ReturnType (*Dem_CallbackGetExtDataRecordFncType)(uint8 *ExtendedDataRecord);
+
+// GetFaultDetectionCounter
+typedef Std_ReturnType (*Dem_CallbackGetFaultDetectionCounterFncType)(sint8 *EventIdFaultDetectionCounter);
+
+// GetPIDValue
+typedef Std_ReturnType (*Dem_CallbackGetPIDValueFncType)(uint8 *DataValueBuffer);
+
+/*
+ * DemGeneral types
+ */
+
+// 10.2.25 DemEnableCondition
+typedef struct {
+       boolean EnableConditionStatus;          //
+       // uint16       EnableConditionID;              // Optional
+} Dem_EnableConditionType;
+
+// 10.2.30 DemExtendedDataRecordClass
+typedef struct {
+       uint16  RecordNumber;                                           // (1)
+       uint16  DataSize;                                                       // (1)
+       Dem_CallbackGetExtDataRecordFncType     CallbackGetExtDataRecord;// (1)
+} Dem_ExtendedDataRecordClassType;
+
+// 10.2.13 DemExtendedDataClass
+typedef struct {
+       const Dem_ExtendedDataRecordClassType *const ExtendedDataRecordClassRef[DEM_MAX_NR_OF_RECORDS_IN_EXTENDED_DATA+1]; // (1..253)
+} Dem_ExtendedDataClassType;
+
+// 10.2.8 DemPidOrDid
+typedef struct {
+       boolean                                                                 PidOrDidUsePort;                        // (1)
+       uint8                                                                   PidOrDidSize;                           // (1)
+       uint16                                                                  DidIdentifier;                          // (0..1)
+       Dem_CallbackConditionCheckReadFncType   DidConditionCheckReadFnc;       // (0..1)
+       Dem_CallbackReadDataLength                              DidReadDataLengthFnc;           // (0..1)
+       Dem_CallbackReadDataFncType                             DidReadFnc;                                     // (0..1)
+       uint8                                                                   PidIndentifier;                         // (0..1)
+       Dem_CallbackGetPIDValueFncType                  PidReadFnc;                                     // (0..1)
+} Dem_PidOrDidType;
+
+// 10.2.18 DemFreezeFrameClass
+typedef struct {
+       Dem_FreezeFrameKindType FFKind;                 // (1)
+//     uint8                                   FFRecordNumber; // (1) Optional
+//     const Dem_PidOrDidType  *FFIdClassRef;  // (1..255) Optional?
+} Dem_FreezeFrameClassType;
+
+// 10.2.4 DemIndicator
+typedef struct {
+       uint16  Indicator;              // (1)
+} Dem_IndicatorType;
+
+// 10.2.28 DemNvramBlockId
+typedef struct {
+       // TODO: Fill out
+} Dem_NvramBlockIdType;
+
+/*
+ * DemConfigSetType types
+ */
+
+// 10.2.6 DemCallbackDTCStatusChanged
+typedef struct {
+       Dem_CallbackDTCStatusChangedFncType CallbackDTCStatusChangedFnc;        // (0..1)
+} Dem_CallbackDTCStatusChangedType;
+
+// 10.2.26 DemCallbackInitMForF
+typedef struct {
+       Dem_CallbackInitMonitorForFunctionFncType       CallbackInitMForF;              // (0..1)
+} Dem_CallbackInitMForFType;
+
+// 10.2.17 DemDTCClass
+typedef struct {
+       uint32                                                                  DTC;                                            // (1)
+       uint8                                                                   DTCFunctionUnit;                        // (1)
+       Dem_DTCKindType                                                 DTCKind;                                        // (1)
+       const Dem_CallbackDTCStatusChangedType  *CallbackDTCStatusChanged;      // (0..*)
+       const Dem_CallbackInitMForFType                 *CallbackInitMForF;                     // (0..*)
+       // Dem_DTCSeverityType                                  DTCSeverity                                     // (0..1)  Optional
+} Dem_DTCClassType;
+
+// 10.2.5 DemCallbackEventStatusChanged
+typedef struct {
+       Dem_CallbackEventStatusChangedFncType   CallbackEventStatusChangedFnc;  // (0..1)
+} Dem_CallbackEventStatusChangedType;
+
+// 10.2.27 DemCallbackInitMForE
+typedef struct {
+       Dem_CallbackInitMonitorForEventFncType  CallbackInitMForEFnc;   // (0..1)
+} Dem_CallbackInitMforEType;
+
+typedef struct {
+       Dem_IndicatorStatusType IndicatorBehaviour;                     // (1)
+       Dem_IndicatorType               *LinkedIndicator;                       // (1)
+} Dem_IndicatorAttributeType;
+
+typedef struct {
+       Dem_CallbackGetFaultDetectionCounterFncType     CallbackGetFDCnt;       // (1)
+} Dem_PreDebounceMonitorInternalType;
+
+typedef struct {
+       // TODO: Fill out
+} Dem_PreDebounceCounterBasedType;
+
+typedef struct {
+       // TODO: Fill out
+} Dem_PreDebounceFrequencyBasedType;
+
+typedef struct {
+       // TODO: Fill out
+} Dem_PreDebounceTimeBasedType;
+
+typedef struct {
+       Dem_PreDebounceNameType         PreDebounceName;                                                // (1)
+       union {
+       const Dem_PreDebounceMonitorInternalType        *PreDebounceMonitorInternal;    // (0..1)
+       const Dem_PreDebounceCounterBasedType           *PreDebounceCouterBased;                // (0..1)
+       const Dem_PreDebounceFrequencyBasedType *PreDebounceFrequencyBased;             // (0..1)
+       const Dem_PreDebounceTimeBasedType              *PreDebounceTimeBased;                  // (0..1)
+       } PreDebounceAlgorithm;
+} Dem_PreDebounceAlgorithmClassType;
+
+// 10.2.14 DemEventClass
+typedef struct {
+       boolean                                         ConsiderPtoStatus;                                                                      // (1)
+       const Dem_DTCOriginType         EventDestination[DEM_MAX_NR_OF_EVENT_DESTINATION+1];// (0..4)
+       uint8                                           EventPriority;                                                                          // (1)
+       boolean                                         FFPrestorageSupported;                                                          // (1)
+       boolean                                         HealingAllowed;                                                                         // (1)
+       Dem_OperationCycleIdType        OperationCycleRef;                                                                      // (1)
+//     uint8                                   HealingCycleCounter;                                                                    // (0..1) Optional
+//     const Dem_EnableConditionType   *EnableConditionRef;                                                    // (0..*) Optional
+//     const Dem_OperationCycleTgtType *HealingCycleRef;                                                               // (0..1) Optional
+       const Dem_PreDebounceAlgorithmClassType *PreDebounceAlgorithmClass;                             // (0..255) (Only one supported)
+       const Dem_IndicatorAttributeType                        *IndicatorAttribute;                            // (0..255)
+//     Dem_OEMSPecific
+
+} Dem_EventClassType;
+
+// 10.2.12 DemEventParameter
+typedef struct {
+       uint16                                                                          EventID;                                        // (1)
+       Dem_EventKindType                                                       EventKind;                                      // (1)
+       const Dem_EventClassType                                        *EventClass;                            // (1)
+       const Dem_ExtendedDataClassType                         *ExtendedDataClassRef;          // (0..1)
+       const Dem_FreezeFrameClassType                          *FreezeFrameClassRef;           // (0..255)
+       const Dem_CallbackInitMforEType                         *CallbackInitMforE;                     // (0..1)
+       const Dem_CallbackEventStatusChangedType        *CallbackEventStatusChanged;// (0..*)
+       const Dem_DTCClassType                                          *DTCClass;                                      // (0..1)
+       boolean                                                                         Arc_EOL;
+} Dem_EventParameterType;
+
+// 10.2.19 DemGroupOfDTC
+typedef struct {
+       // TODO: Fill out
+} Dem_GroupOfDtcType;
+
+// 10.2.10 DemOemIdClass
+typedef struct {
+       uint8   OemID;  // (Pre+Post)
+} Dem_OemIdClassType;
+
+// 10.2.9 DemConfigSet
+typedef struct {
+       const Dem_EventParameterType    *EventParameter;        // (0..65535)
+       const Dem_DTCClassType                  *DTCClass;                      // (1..16777214)
+       const Dem_GroupOfDtcType                *GroupOfDtc;            // (1.16777214)
+       const Dem_OemIdClassType                *OemIdClass;            // (0..*)
+} Dem_ConfigSetType;
+
+// 10.2.2 Dem
+typedef struct {
+       const Dem_ConfigSetType *ConfigSet;     //      (1)
+} Dem_ConfigType;
+
+
+/*
+ * Make the DEM_Config visible for others.
+ */
+extern const Dem_ConfigType DEM_Config;
+\r
 \r
 #endif /*DEM_LCFG_H_*/\r
diff --git a/diagnostic/Dem/Dem_PBcfg.h b/diagnostic/Dem/Dem_PBcfg.h
deleted file mode 100644 (file)
index 1637d45..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-/* -------------------------------- Arctic Core ------------------------------
- * Arctic Core - the open source AUTOSAR platform http://arccore.com
- *
- * Copyright (C) 2009  ArcCore AB <contact@arccore.com>
- *
- * This source code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published by the
- * Free Software Foundation; See <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * for more details.
- * -------------------------------- Arctic Core ------------------------------*/
-
-
-
-
-
-
-
-
-#ifndef DEM_PBCFG_H_\r
-#define DEM_PBCFG_H_\r
-\r
-#endif /*DEM_PBCFG_H_*/\r
index bfc5dfd2e17c8368353b714e53d4a1979a230db1..2810b502bf6ecd80ddded86130af3e59acf8108e 100644 (file)
 
 
 #ifndef DEM_TYPES_H_\r
-#define DEM_TYPES_H_\r
-\r
+#define DEM_TYPES_H_
+#include "Std_Types.h"\r
+
+/*
+ * Dem_EventIdType
+ */
+typedef uint16 Dem_EventIdType;
+
+/*
+ * DemDTCKindType
+ */
+typedef uint8 Dem_DTCKindType;
+#define        DEM_DTC_KIND_ALL_DTCS                   0x01
+#define        DEM_DTC_KIND_EMISSON_REL_DTCS   0x02
+
+/*
+ * DemDTCOriginType
+ */
+typedef uint8 Dem_DTCOriginType;
+#define        DEM_DTC_ORIGIN_MIRROR_MEMORY    0x04
+#define        DEM_DTC_ORIGIN_PERMANENT_MEMORY 0x03
+#define        DEM_DTC_ORIGIN_PRIMARY_MEMORY   0x02
+#define        DEM_DTC_ORIGIN_SECONDARY_MEMORY 0x01
+
+/*
+ * DemEventStatusExtendedType
+ */
+typedef uint8 Dem_EventStatusExtendedType;
+#define        DEM_TEST_FAILED                                                         0x01
+#define        DEM_TEST_FAILED_THIS_OPERATION_CYCLE            0x02
+#define        DEM_PENDING_DTC                                                         0x04
+#define        DEM_CONFIRMED_DTC                                                       0x08
+#define        DEM_TEST_NOT_COMPLETED_SINCE_LAST_CLEAR         0x10
+#define        DEM_TEST_FAILED_SINCE_LAST_CLEAR                        0x20
+#define        DEM_TEST_NOT_COMPLETED_THIS_OPERATION_CYCLE 0x40
+#define        DEM_WARNING_INDICATOR_REQUESTED                         0x80
+
+/*
+ * DemOperationCycleType
+ */
+typedef uint8 Dem_OperationCycleIdType;        // TODO: Check type and values
+enum {
+       DEM_ACTIVE,             // Started by DEM on Dem_PreInit and stopped on Dem_Shutdown
+
+       DEM_POWER,              // Power ON/OFF Cycle
+       DEM_IGNITION,   // Ignition ON/OF Cycle
+       DEM_WARMUP,             // OBD Warm up Cycle
+       DEM_OBD_DCY,    // OBD Driving Cycle
+
+       DEM_OPERATION_CYCLE_ID_ENDMARK
+};
+
+/*
+ * Dem_OperationCycleStateType
+ */
+typedef uint8 Dem_OperationCycleStateType;
+#define DEM_CYCLE_STATE_START          1
+#define DEM_CYCLE_STATE_END                    2
+
+/*
+ * DemFreezeFrameKindType
+ */
+typedef uint8 Dem_FreezeFrameKindType; // TODO: Check type and values
+#define        DEM_FREEZE_FRAME_NON_OBD        0x01
+#define DEM_FREEZE_FRAME_OBD           0x02
+
+/*
+ * DemEventKindType
+ */
+typedef uint8 Dem_EventKindType;               // TODO: Check type and values
+#define DEM_EVENT_KIND_BSW             0x01
+#define DEM_EVENT_KIND_SWC             0x02
+
+/*
+ * Dem_EventStatusType
+ */
+typedef uint8 Dem_EventStatusType;
+#define DEM_EVENT_STATUS_PASSED                0
+#define DEM_EVENT_STATUS_FAILED                1
+#define DEM_EVENT_STATUS_PREPASSED     2
+#define DEM_EVENT_STATUS_PREFAILED     3
+
+/*
+ * Dem_DTCType
+ */
+typedef uint32 Dem_DTCType;
+
+/*
+ * Dem_InitMonitorKindType
+ */
+typedef uint8 Dem_InitMonitorKindType;
+#define DEM_INIT_MONITOR_CLEAR         1
+#define DEM_INIT_MONITOR_RESTART       2
+
+/*
+ * Dem_IndicatorStatusType
+ */
+typedef uint8 Dem_IndicatorStatusType;
+#define DEM_INDICATOR_OFF                      0
+#define DEM_INDICATOR_CONTINUOUS       1
+#define DEM_INDICATOR_BLINKING         2
+#define DEM_INDICATOR_BLINK_CONT       3
+
+/*
+ * Dem_FaultDetectionCpunterType
+ */
+typedef sint8 Dem_FaultDetectionCounterType;
+
+/*
+ * Dem_PreDebounceNameType
+ */
+typedef uint8 Dem_PreDebounceNameType;
+enum {
+       DEM_NO_PRE_DEBOUNCE,
+       DEM_PRE_DEBOUNCE_COUNTER_BASED,
+       DEM_PRE_DEBOUNCE_FREQUENCY_BASED,
+       DEM_PRE_DEBOUNCE_TIME_BASED
+};
+
+
 #endif /*DEM_TYPES_H_*/\r
index 3fd1f2f9ee0261174277c74b3eb390aa39d2db56..a61abb39bcb5b7a4e45d693c64b3e513ed22ae10 100644 (file)
@@ -42,8 +42,6 @@
 // Init transition for current mode\r
 #define CAN_E_TRANSITION       0x06\r
 \r
-#define CAN_E_TIMEOUT          0x10  // Should be defined by DEM\r
-\r
 \r
 #include "Std_Types.h"\r
 #include "CanIf_Types.h"\r
index 9969fd639f8bb8f367116f442299c48845d4a3c2..a0dd42b9b48a4288693f7c208e1e426043ec79d4 100644 (file)
 
 #ifndef DEM_H_\r
 #define DEM_H_\r
-\r
-#include "Std_Types.h"\r
-#include "Dem_Types.h"\r
-#include "Dem_IntErrId.h"\r
-\r
-typedef uint16 Dem_EventIdType;\r
-typedef uint8 Dem_EventStatusType;\r
-\r
-void Dem_PreInit( void );\r
-void Dem_Init( void );\r
-Std_ReturnType Dem_ReportErrorStatus( Dem_EventIdType,Dem_EventStatusType);\r
-\r
-\r
+
+#define DEM_SW_MAJOR_VERSION    1
+#define DEM_SW_MINOR_VERSION           0
+#define DEM_SW_PATCH_VERSION    0
+#define DEM_AR_MAJOR_VERSION    3
+#define DEM_AR_MINOR_VERSION    0
+#define DEM_AR_PATCH_VERSION    1
+
+#include "Dem_Types.h"
+#include "Dem_Cfg.h"
+#include "Dem_Lcfg.h"\r
+#include "Dem_IntErrId.h"
+#include "Dem_IntEvtId.h"
+// #include "Rte_Dem.h"
+
+
+#if (DEM_DEV_ERROR_DETECT == STD_ON)
+// Error codes produced by this module
+#define DEM_E_CONFIG_PTR_INVALID                       0x01
+#define DEM_E_PARAM_CONFIG                                     0x10
+#define DEM_E_PARAM_ADDRESS                                    0x11
+#define DEM_E_PARAM_DATA                                       0x12
+#define DEM_E_PARAM_LENGTH                                     0x13
+#define DEM_E_UNINIT                                           0x20
+#define DEM_E_NODATAAVAILABLE                          0x30
+
+#define DEM_E_EVENT_STATUS_BUFF_FULL           0x40
+#define DEM_E_EXT_DATA_TO_BIG                          0x41
+#define DEM_E_PRE_INIT_EXT_DATA_BUFF_FULL      0x42
+#define DEM_E_PRI_MEM_EVENT_BUFF_FULL          0x43
+#define DEM_E_PRI_MEM_EXT_DATA_BUFF_FULL       0x44
+
+#define DEM_E_NOT_IMPLEMENTED_YET                      0xff
+
+// Service ID in this module
+#define DEM_PREINIT_ID                                 0x01
+#define DEM_INIT_ID                                            0x02
+#define DEM_SETEVENTSTATUS_ID                  0x10
+#define DEM_RESETEVENTSTATUS_ID                        0x11
+#define DEM_GETEVENTSTATUS_ID                  0x12
+#define DEM_GETEVENTFAILED_ID                  0x13
+#define DEM_GETEVENTTESTED_ID                  0x14
+#define DEM_GETFAULTDETECTIONCOUNTER_ID 0x15
+#define DEM_SETOPERATIONCYCLESTATE_ID  0x16
+#define DEM_REPORTERRORSTATUS_ID               0x20
+
+#define DEM_UPDATE_EVENT_STATUS_ID             0x40
+#define DEM_MERGE_EVENT_STATUS_ID              0x41
+#define DEM_GET_EXTENDED_DATA_ID               0x42
+#define DEM_STORE_EXT_DATA_PRE_INIT_ID 0x43
+#define DEM_STORE_EVENT_PRI_MEM_ID             0x44
+#define DEM_STORE_EXT_DATA_PRI_MEM_ID  0x45
+
+#define DEM_GLOBAL_ID                                  0xff
+
+#endif
+
+
+/*
+ * Interface for upper layer modules (8.3.1)
+ */
+
+#if (DEM_VERSION_INFO_API == STD_ON)
+void Dem_GetVersionInfo(Std_VersionInfoType *versionInfo);
+#endif /* DEM_VERSION_INFO_API */
+
+/*
+ * Interface ECU State Manager <-> DEM (8.3.2)
+ */
+void Dem_PreInit( void );
+void Dem_Init( void );
+void Dem_Shutdown( void );
+
+
+/*
+ * Interface for basic software scheduler
+ */
+void Dem_MainFunction( void );
+
+
+/*
+ * Interface SW-Components via RTE <-> DEM (8.3.3)
+ */
+Std_ReturnType Dem_SetEventStatus(Dem_EventIdType eventId, uint8 eventStatus);
+Std_ReturnType Dem_ResetEventStatus(Dem_EventIdType eventId);
+Std_ReturnType Dem_GetEventStatus(Dem_EventIdType eventId, Dem_EventStatusExtendedType *eventStatusExtended);
+Std_ReturnType Dem_GetEventFailed(Dem_EventIdType eventId, boolean *eventFailed);
+Std_ReturnType Dem_GetEventTested(Dem_EventIdType eventId, boolean *eventTested);
+Std_ReturnType Dem_GetFaultDetectionCounter(Dem_EventIdType eventId, sint8 *counter);
+Std_ReturnType Dem_SetOperationCycleState(Dem_OperationCycleIdType OperationCycleId, Dem_OperationCycleStateType CycleState);
+
+
+/*
+ * Interface BSW-Components <-> DEM (8.3.4)
+ */
+void Dem_ReportErrorStatus(Dem_EventIdType eventId ,uint8 eventStatus);
+
+
+/*
+ * Interface DCM <-> DEM (8.3.5)
+ */
+
+
+/*
+ * OBD-specific Interfaces (8.3.6)
+ */
+
 #endif /*DEM_H_*/\r
index c82e975d801d3de66b65f80b9217ff14de872880..efab4690498fb89b43f676c9f9d5caee99ea4329 100644 (file)
@@ -28,8 +28,9 @@
 #include "Std_Types.h"
 #include "Det.h"
 //#include "MemIf_Types.h"
-// TODO: not yet #include "Dem.h"
-
+#if defined(USE_DEM)
+#include "Dem.h"
+#endif
 // SW ans Autosar spec versions
 #define FLS_SW_MAJOR_VERSION           1
 #define FLS_SW_MINOR_VERSION                   0
 // Write verification (compare) failed
 #define FLS_E_VERIFY_WRITE_FAILED      0x08
 
-// These should be assigned by the DEM module
-#define FLS_E_ERASED_FAILED 0x09
-#define FLS_E_WRITE_FAILED 0x0A
-#define FLS_E_READ_FAILED 0x0B
-#define FLS_E_COMPARE_FAILED 0x0C
-#define FLS_E_UNEXPECTED_FLASH_ID 0x0D
-
 // Service id's for fls functions
 #define FLS_INIT_ID                                    0x00
 #define FLS_ERASE_ID                           0x01
index 812de106391a6747a5895313b992ded374f6425a..04401d1dbd7f3746d39c00c9229ea66bb92df5b4 100644 (file)
@@ -172,7 +172,6 @@ typedef enum {
 #define LIN_E_INVALID_CHANNEL                  0x02\r
 #define LIN_E_INVALID_POINTER                  0x03\r
 #define LIN_E_STATE_TRANSITION                 0x04\r
-#define LIN_E_TIMEOUT                                  0x05 //TODO Assigned by DEM\r
 \r
 void Lin_Init( const Lin_ConfigType* Config );\r
 \r
index b8a1671d23ff4fba05ccb141626ae6670b091195..1065474d73f44267c805733c52fe781cd4958fa3 100644 (file)
@@ -55,9 +55,6 @@
 #define LINIF_E_PARAMETER_POINTER 0x40\r
 #define LINIF_E_SCHEDULE_OVERFLOW 0x50\r
 #define LINIF_E_SCHEDULE_REQUEST_ERROR 0x51\r
-#define LINIF_E_RESPONSE 0x52 //Assigned\r
-#define LINIF_E_NC_NO_RESPONSE 0x53 //Assigned by DEM\r
-#define LINIF_E_CHANNEL_X_SLAVE_Y 0x54 //Assigned by DEM\r
 
 #if (LINIF_VERSION_INFO_API == STD_ON)\r
 void LinIf_GetVersionInfo( Std_VersionInfoType *versionInfo );\r
index 511c41b9c21b97905bca4bee4a0442944e1ca4d6..fd2b948efd76d3051742f359f306dc24a9a0328e 100644 (file)
@@ -23,7 +23,9 @@
 
 #include "NvM.h"
 #include "Rte.h"
+#if defined(USE_DEM)
 #include "Dem.h"
+#endif
 //#include "Crc.h"
 
 void NvM_Init( void ){
index ac1308076227f672f7f7c577ae8989d7187a85fe..e1eec7e1c744cac8ccb2b2d43a0f645163934a84 100644 (file)
 #include "Fls.h"\r
 #include "Fls_SST25xx.h"\r
 #include "Spi.h"\r
-//#include "Dem.h"\r
 #include "Det.h"\r
+#if defined(USE_DEM)
+#include "Dem.h"
+#endif
 #include <stdlib.h>\r
 #include <assert.h>\r
 //#include <stdio.h>\r
@@ -725,7 +727,9 @@ void Fls_SST25xx_MainFunction( void )
                        } else if( jobResult == SPI_SEQ_OK ) {\r
 \r
                                if( memcmp(Fls_SST25xx_CompareBuffer,gJob->targetAddr, readSize) != 0 ) {\r
-                                       DET_REPORTERROR(MODULE_ID_FLS,0, 0x6, FLS_E_COMPARE_FAILED );\r
+#if defined(USE_DEM)
+                                       Dem_ReportErrorStatus(FLS_E_COMPARE_FAILED, DEM_EVENT_STATUS_FAILED);\r
+#endif
                                        FEE_JOB_ERROR_NOTIFICATION();\r
                                        return;\r
                                }\r
@@ -761,7 +765,9 @@ void Fls_SST25xx_MainFunction( void )
         Fls_SST25xx_Global.jobType = FLS_SST25XX_NONE;\r
         Fls_SST25xx_Global.status = MEMIF_IDLE;\r
 \r
-                               DET_REPORTERROR(MODULE_ID_FLS,0, 0x6, FLS_E_COMPARE_FAILED );\r
+#if defined(USE_DEM)
+                               Dem_ReportErrorStatus(FLS_E_COMPARE_FAILED, DEM_EVENT_STATUS_FAILED);
+#endif
                                FEE_JOB_ERROR_NOTIFICATION();\r
                        }\r
                }\r
@@ -787,13 +793,19 @@ void Fls_SST25xx_MainFunction( void )
 \r
        switch(Fls_SST25xx_Global.jobType) {\r
        case FLS_SST25XX_ERASE:\r
-                                       DET_REPORTERROR(MODULE_ID_FLS,0, 0x6, FLS_E_ERASED_FAILED );\r
+#if defined(USE_DEM)
+                                       Dem_ReportErrorStatus(FLS_E_ERASED_FAILED, DEM_EVENT_STATUS_FAILED);\r
+#endif
                                        break;\r
        case FLS_SST25XX_READ:\r
-                                       DET_REPORTERROR(MODULE_ID_FLS,0, 0x6, FLS_E_READ_FAILED );\r
+#if defined(USE_DEM)
+                                       Dem_ReportErrorStatus(FLS_E_READ_FAILED, DEM_EVENT_STATUS_FAILED);\r
+#endif
                                        break;\r
        case FLS_SST25XX_WRITE:\r
-                                       DET_REPORTERROR(MODULE_ID_FLS,0, 0x6, FLS_E_WRITE_FAILED );\r
+#if defined(USE_DEM)
+                                       Dem_ReportErrorStatus(FLS_E_WRITE_FAILED, DEM_EVENT_STATUS_FAILED);\r
+#endif
                                        break;\r
        default:\r
                assert(0);\r
index 15c88eb354b8cfb6b8ac952a098bb1671644a0ef..d57f160ba9255afdbbbf9ecb7045203bb1cadf1c 100644 (file)
@@ -26,6 +26,9 @@
 \r
 #include "EcuM.h"\r
 #include "Det.h"\r
+#if defined(USE_DEM)
+#include "Dem.h"
+#endif
 #if defined(USE_MCU)\r
 #include "Mcu.h"\r
 #endif\r
@@ -52,6 +55,12 @@ void EcuM_AL_DriverInitZero()
 {\r
        Det_Init();\r
     Det_Start();\r
+
+#if defined(USE_DEM)
+       // Preinitialize DEM
+       Dem_PreInit();
+#endif
+
 }\r
 \r
 EcuM_ConfigType* EcuM_DeterminePbConfiguration()\r
@@ -152,6 +161,11 @@ void EcuM_AL_DriverInitTwo(const EcuM_ConfigType* ConfigPtr)
        Com_Init(ConfigPtr->ComConfig);\r
 #endif\r
 \r
+#if defined(USE_DEM)
+       // Initialize DEM
+       Dem_Init();
+#endif
+
 }\r
 \r
 void EcuM_AL_DriverInitThree(const EcuM_ConfigType ConfigPtr)\r