]> rtime.felk.cvut.cz Git - arc.git/blobdiff - arch/ppc/mpc55xx/drivers/Can.c
Merged with dem-dev
[arc.git] / arch / ppc / mpc55xx / drivers / Can.c
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