]> rtime.felk.cvut.cz Git - arc.git/blobdiff - arch/ppc/mpc55xx/drivers/Adc_560x.c
Adc, fix for mpc5668.
[arc.git] / arch / ppc / mpc55xx / drivers / Adc_560x.c
index 839143f8953d0cec5bd67870270aceade5a50dcd..bb8633ebe880fba31015d4604f027c9dc478221e 100644 (file)
        #error Adc is configured to use Dma but the module is not enabled.\r
 #endif\r
 \r
+\r
 #if defined(CFG_MPC5668)\r
-#define ADC_0                          ADC\r
+#define ADC0_EOC_INT   ADC_A_EOC\r
+#define ADC0_ER_INT            ADC_A_ERR\r
+#define        ADC0_WD_INT             ADC_A_WD\r
+#define ADC1_EOC_INT   ADC_B_EOC\r
+#define ADC1_ER_INT            ADC_B_ERR\r
+#define        ADC1_WD_INT             ADC_B_WD\r
 #endif\r
 \r
 #if defined(CFG_MPC5668)\r
-#define ADC_EOC_INT    ADC_A_EOC\r
-#define ADC_ER_INT             ADC_A_ERR\r
-#define        ADC_WD_INT              ADC_A_WD\r
+#define ADC_BASE_ADDRESS 0xFFF80000\r
+#else\r
+#define ADC_BASE_ADDRESS 0xFFE00000\r
 #endif\r
 \r
 #define GET_HW_CONTROLLER(_controller)         \\r
-                                               ((struct ADC_tag *)(0xFFE00000 + 0x4000*(_controller)))\r
+                                               ((struct ADC_tag *)(ADC_BASE_ADDRESS + 0x4000*(_controller)))\r
 \r
-#define GET_HWUNITID_FROM_GROUP(_group) (_group / NOF_GROUP_PER_CONTROLLER)\r
+#define GET_HWUNITID_FROM_GROUP(_group) (_group / ADC_NOF_GROUP_PER_CONTROLLER)\r
 \r
 /* ----------------------------[private macro]-------------------------------*/\r
 /* ----------------------------[private typedef]-----------------------------*/\r
@@ -177,7 +183,7 @@ Std_ReturnType Adc_SetupResultBuffer (Adc_GroupType group, Adc_ValueGroupType *b
   /* Check for development errors. */\r
   if (E_OK == Adc_CheckSetupResultBuffer (adcState, AdcConfigPtr, group))\r
   {\r
-    AdcConfigPtr->groupConfigPtr[group%NOF_GROUP_PER_CONTROLLER].status->resultBufferPtr = bufferPtr;\r
+    AdcConfigPtr->groupConfigPtr[group%ADC_NOF_GROUP_PER_CONTROLLER].status->resultBufferPtr = bufferPtr;\r
     \r
     returnValue = E_OK;\r
   }\r
@@ -194,7 +200,7 @@ Adc_StreamNumSampleType Adc_GetStreamLastPointer(Adc_GroupType group, Adc_ValueG
        /* Check for development errors. */\r
        if (E_OK == Adc_CheckGetStreamLastPointer (adcState, AdcConfigPtr, group))\r
        {\r
-               Adc_GroupDefType *groupPtr = (Adc_GroupDefType *)&AdcConfigPtr->groupConfigPtr[group%NOF_GROUP_PER_CONTROLLER];\r
+               Adc_GroupDefType *groupPtr = (Adc_GroupDefType *)&AdcConfigPtr->groupConfigPtr[group%ADC_NOF_GROUP_PER_CONTROLLER];\r
 \r
                if (groupPtr->status->groupStatus != ADC_BUSY)\r
            {\r
@@ -258,7 +264,7 @@ Std_ReturnType Adc_ReadGroup (Adc_GroupType group, Adc_ValueGroupType *dataBuffe
 \r
   if (E_OK == Adc_CheckReadGroup (adcState, AdcConfigPtr, group))\r
   {\r
-       Adc_GroupDefType *groupPtr = (Adc_GroupDefType *)&AdcConfigPtr->groupConfigPtr[group%NOF_GROUP_PER_CONTROLLER];\r
+       Adc_GroupDefType *groupPtr = (Adc_GroupDefType *)&AdcConfigPtr->groupConfigPtr[group%ADC_NOF_GROUP_PER_CONTROLLER];\r
 \r
     /* Copy the result to application buffer. */\r
     for (channel = 0; channel < groupPtr->numberOfChannels; channel++)\r
@@ -313,7 +319,7 @@ Std_ReturnType Adc_ReadGroup (Adc_GroupType group, Adc_ValueGroupType *dataBuffe
 \r
 void Adc_GroupConversionComplete (Adc_GroupType group, const Adc_ConfigType *AdcConfigPtr, volatile struct ADC_tag *hwPtr)\r
 {\r
-  Adc_GroupDefType *adcGroup = (Adc_GroupDefType *)&AdcConfigPtr->groupConfigPtr[group%NOF_GROUP_PER_CONTROLLER];\r
+  Adc_GroupDefType *adcGroup = (Adc_GroupDefType *)&AdcConfigPtr->groupConfigPtr[group%ADC_NOF_GROUP_PER_CONTROLLER];\r
 \r
   if(ADC_ACCESS_MODE_SINGLE == adcGroup->accessMode )\r
   {\r
@@ -497,7 +503,7 @@ void Adc_StartGroupConversion (Adc_GroupType group)
        {\r
                volatile struct ADC_tag *hwPtr = GET_HW_CONTROLLER(AdcConfigPtr->hwConfigPtr->hwUnitId);\r
 \r
-               Adc_GroupDefType *groupPtr = (Adc_GroupDefType *)&AdcConfigPtr->groupConfigPtr[group%NOF_GROUP_PER_CONTROLLER];\r
+               Adc_GroupDefType *groupPtr = (Adc_GroupDefType *)&AdcConfigPtr->groupConfigPtr[group%ADC_NOF_GROUP_PER_CONTROLLER];\r
 \r
                /* Disable trigger normal conversions for ADC0 */\r
                hwPtr->MCR.B.NSTART = 0;\r
@@ -617,10 +623,10 @@ void Adc_StopGroupConversion (Adc_GroupType group)
        hwPtr->MCR.B.NSTART = 0;\r
 \r
        /* Set group state to IDLE. */\r
-       AdcConfigPtr->groupConfigPtr[group%NOF_GROUP_PER_CONTROLLER].status->groupStatus = ADC_IDLE;\r
+       AdcConfigPtr->groupConfigPtr[group%ADC_NOF_GROUP_PER_CONTROLLER].status->groupStatus = ADC_IDLE;\r
 \r
        /* Disable group notification if enabled. */\r
-    if(1 == AdcConfigPtr->groupConfigPtr[group%NOF_GROUP_PER_CONTROLLER].status->notifictionEnable){\r
+    if(1 == AdcConfigPtr->groupConfigPtr[group%ADC_NOF_GROUP_PER_CONTROLLER].status->notifictionEnable){\r
        Adc_DisableGroupNotification (group);\r
     }\r
   }\r