]> rtime.felk.cvut.cz Git - arc.git/blobdiff - drivers/Adc_Internal.c
Added another check for illegal configPtr due to bad group number
[arc.git] / drivers / Adc_Internal.c
index 214584b9f153b8d8a9e8c45e673e5c5d013e671b..5ecf7690b7ca4f9fe708cadb7df5c8e9cc4c4edf 100644 (file)
@@ -20,8 +20,8 @@
 #include "arc.h"\r
 #include "Adc_Internal.h"\r
 \r
-#ifndef NOF_GROUP_PER_CONTROLLER\r
-#define NOF_GROUP_PER_CONTROLLER 100\r
+#ifndef CFG_MPC560X\r
+#define ADC_NOF_GROUP_PER_CONTROLLER 100\r
 #endif\r
 \r
 /* Validate functions used for development error check */\r
@@ -38,7 +38,8 @@ Std_ReturnType ValidateInit(Adc_StateType adcState, Adc_APIServiceIDType api)
 Std_ReturnType ValidateGroup(const Adc_ConfigType *ConfigPtr, Adc_GroupType group,Adc_APIServiceIDType api)\r
 {\r
        Std_ReturnType res = E_OK;\r
-       if(!(((group % NOF_GROUP_PER_CONTROLLER) >= 0) && ((group % NOF_GROUP_PER_CONTROLLER) < ConfigPtr->nbrOfGroups))) {\r
+       if(!(((group % ADC_NOF_GROUP_PER_CONTROLLER) >= 0) && ((group % ADC_NOF_GROUP_PER_CONTROLLER) < ConfigPtr->nbrOfGroups))\r
+     || ConfigPtr == 0) {\r
                Det_ReportError(MODULE_ID_ADC,0,api,ADC_E_PARAM_GROUP );\r
                res = E_NOT_OK;\r
        }\r
@@ -59,10 +60,10 @@ Adc_StatusType Adc_InternalGetGroupStatus (Adc_StateType adcState, const Adc_Con
        }\r
        else\r
        {\r
-               returnValue = ConfigPtr->groupConfigPtr[group%NOF_GROUP_PER_CONTROLLER].status->groupStatus;\r
+               returnValue = ConfigPtr->groupConfigPtr[group%ADC_NOF_GROUP_PER_CONTROLLER].status->groupStatus;\r
        }\r
 #else\r
-  returnValue = ConfigPtr->groupConfigPtr[group%NOF_GROUP_PER_CONTROLLER].status->groupStatus;\r
+  returnValue = ConfigPtr->groupConfigPtr[group%ADC_NOF_GROUP_PER_CONTROLLER].status->groupStatus;\r
 #endif\r
   return (returnValue);\r
 }\r
@@ -78,7 +79,7 @@ void Adc_EnableInternalGroupNotification (Adc_StateType adcState, const Adc_Conf
        {\r
                res = E_NOT_OK;\r
        }\r
-       else if (ConfigPtr->groupConfigPtr[group%NOF_GROUP_PER_CONTROLLER].groupCallback == NULL)\r
+       else if (ConfigPtr->groupConfigPtr[group%ADC_NOF_GROUP_PER_CONTROLLER].groupCallback == NULL)\r
        {\r
                res = E_NOT_OK;\r
                Det_ReportError(MODULE_ID_ADC,0,ADC_ENABLEGROUPNOTIFICATION_ID ,ADC_E_NOTIF_CAPABILITY );\r
@@ -92,7 +93,7 @@ void Adc_EnableInternalGroupNotification (Adc_StateType adcState, const Adc_Conf
        res = E_OK;\r
 #endif\r
        if (E_OK == res){\r
-               ConfigPtr->groupConfigPtr[group%NOF_GROUP_PER_CONTROLLER].status->notifictionEnable = 1;\r
+               ConfigPtr->groupConfigPtr[group%ADC_NOF_GROUP_PER_CONTROLLER].status->notifictionEnable = 1;\r
        }\r
 }\r
 \r
@@ -106,7 +107,7 @@ void Adc_InternalDisableGroupNotification (Adc_StateType adcState, const Adc_Con
        {\r
                res = E_NOT_OK;\r
        }\r
-       else if (ConfigPtr->groupConfigPtr[group%NOF_GROUP_PER_CONTROLLER].groupCallback == NULL)\r
+       else if (ConfigPtr->groupConfigPtr[group%ADC_NOF_GROUP_PER_CONTROLLER].groupCallback == NULL)\r
        {\r
                res = E_NOT_OK;\r
                Det_ReportError(MODULE_ID_ADC,0,ADC_DISABLEGROUPNOTIFICATION_ID ,ADC_E_NOTIF_CAPABILITY );\r
@@ -120,7 +121,7 @@ void Adc_InternalDisableGroupNotification (Adc_StateType adcState, const Adc_Con
        res = E_OK;\r
 #endif\r
        if (E_OK == res){\r
-               ConfigPtr->groupConfigPtr[group%NOF_GROUP_PER_CONTROLLER].status->notifictionEnable = 0;\r
+               ConfigPtr->groupConfigPtr[group%ADC_NOF_GROUP_PER_CONTROLLER].status->notifictionEnable = 0;\r
        }\r
 }\r
 #endif\r
@@ -140,7 +141,7 @@ Std_ReturnType Adc_CheckReadGroup (Adc_StateType adcState, const Adc_ConfigType
   {\r
          returnValue = E_NOT_OK;\r
   }\r
-  else if (ADC_IDLE == ConfigPtr->groupConfigPtr[group%NOF_GROUP_PER_CONTROLLER].status->groupStatus)\r
+  else if (ADC_IDLE == ConfigPtr->groupConfigPtr[group%ADC_NOF_GROUP_PER_CONTROLLER].status->groupStatus)\r
   {\r
     /* ADC388. */\r
     returnValue = E_NOT_OK;\r
@@ -168,20 +169,20 @@ Std_ReturnType Adc_CheckStartGroupConversion (Adc_StateType adcState, const Adc_
   {\r
          returnValue = E_NOT_OK;\r
   }\r
-  else if ( NULL == ConfigPtr->groupConfigPtr[group%NOF_GROUP_PER_CONTROLLER].status->resultBufferPtr )\r
+  else if ( NULL == ConfigPtr->groupConfigPtr[group%ADC_NOF_GROUP_PER_CONTROLLER].status->resultBufferPtr )\r
   {\r
       /* ResultBuffer not set, ADC424 */\r
          Det_ReportError(MODULE_ID_ADC,0,ADC_STARTGROUPCONVERSION_ID, ADC_E_BUFFER_UNINIT );\r
          returnValue = E_NOT_OK;\r
   }\r
-  else if (!(ADC_TRIGG_SRC_SW == ConfigPtr->groupConfigPtr[group%NOF_GROUP_PER_CONTROLLER].triggerSrc))\r
+  else if (!(ADC_TRIGG_SRC_SW == ConfigPtr->groupConfigPtr[group%ADC_NOF_GROUP_PER_CONTROLLER].triggerSrc))\r
   {\r
     /* Wrong trig source, ADC133. */\r
     Det_ReportError(MODULE_ID_ADC,0,ADC_STARTGROUPCONVERSION_ID, ADC_E_WRONG_TRIGG_SRC);\r
     returnValue = E_NOT_OK;\r
   }\r
-  else if (!((ADC_IDLE             == ConfigPtr->groupConfigPtr[group%NOF_GROUP_PER_CONTROLLER].status->groupStatus) ||\r
-             (ADC_STREAM_COMPLETED == ConfigPtr->groupConfigPtr[group%NOF_GROUP_PER_CONTROLLER].status->groupStatus)))\r
+  else if (!((ADC_IDLE             == ConfigPtr->groupConfigPtr[group%ADC_NOF_GROUP_PER_CONTROLLER].status->groupStatus) ||\r
+             (ADC_STREAM_COMPLETED == ConfigPtr->groupConfigPtr[group%ADC_NOF_GROUP_PER_CONTROLLER].status->groupStatus)))\r
   {\r
     /* Group status not OK, ADC351, ADC428 */\r
     Det_ReportError(MODULE_ID_ADC,0,ADC_STARTGROUPCONVERSION_ID, ADC_E_BUSY );\r
@@ -208,13 +209,13 @@ Std_ReturnType Adc_CheckStopGroupConversion (Adc_StateType adcState, const Adc_C
   {\r
          returnValue = E_NOT_OK;\r
   }\r
-  else if (!(ADC_TRIGG_SRC_SW == ConfigPtr->groupConfigPtr[group%NOF_GROUP_PER_CONTROLLER].triggerSrc))\r
+  else if (!(ADC_TRIGG_SRC_SW == ConfigPtr->groupConfigPtr[group%ADC_NOF_GROUP_PER_CONTROLLER].triggerSrc))\r
   {\r
        /* Wrong trig source, ADC164. */\r
        Det_ReportError(MODULE_ID_ADC,0,ADC_STOPGROUPCONVERSION_ID, ADC_E_WRONG_TRIGG_SRC);\r
        returnValue = E_NOT_OK;\r
   }\r
-  else if (ADC_IDLE == ConfigPtr->groupConfigPtr[group%NOF_GROUP_PER_CONTROLLER].status->groupStatus)\r
+  else if (ADC_IDLE == ConfigPtr->groupConfigPtr[group%ADC_NOF_GROUP_PER_CONTROLLER].status->groupStatus)\r
   {\r
        /* Group status not OK, ADC241 */\r
        Det_ReportError(MODULE_ID_ADC,0,ADC_STOPGROUPCONVERSION_ID, ADC_E_IDLE );\r
@@ -267,7 +268,7 @@ Std_ReturnType Adc_CheckDeInit (Adc_StateType adcState, const Adc_ConfigType *Co
                for (Adc_GroupType group = (Adc_GroupType)0; group < ConfigPtr->nbrOfGroups; group++)\r
                {\r
                        /*  Check ADC is IDLE or COMPLETE*/\r
-                       if((ConfigPtr->groupConfigPtr[group%NOF_GROUP_PER_CONTROLLER].status->groupStatus != ADC_IDLE) && (ConfigPtr->groupConfigPtr[group%NOF_GROUP_PER_CONTROLLER].status->groupStatus != ADC_STREAM_COMPLETED))\r
+                       if((ConfigPtr->groupConfigPtr[group%ADC_NOF_GROUP_PER_CONTROLLER].status->groupStatus != ADC_IDLE) && (ConfigPtr->groupConfigPtr[group%ADC_NOF_GROUP_PER_CONTROLLER].status->groupStatus != ADC_STREAM_COMPLETED))\r
                        {\r
                                Det_ReportError(MODULE_ID_ADC,0,ADC_DEINIT_ID, ADC_E_BUSY );\r
                                returnValue = E_NOT_OK;\r
@@ -307,7 +308,7 @@ Std_ReturnType Adc_CheckGetStreamLastPointer (Adc_StateType adcState, const Adc_
   {\r
          returnValue = E_NOT_OK;\r
   }\r
-  else if(ConfigPtr->groupConfigPtr[group%NOF_GROUP_PER_CONTROLLER].status->groupStatus == ADC_IDLE)\r
+  else if(ConfigPtr->groupConfigPtr[group%ADC_NOF_GROUP_PER_CONTROLLER].status->groupStatus == ADC_IDLE)\r
   { /** @req ADC215 Check ADC is not in IDLE */\r
        Det_ReportError(MODULE_ID_ADC,0,ADC_GETSTREAMLASTPOINTER_ID, ADC_E_IDLE );\r
        returnValue = E_NOT_OK;\r