]> rtime.felk.cvut.cz Git - arc.git/blob - arch/hc1x/hcs12d/drivers/Adc.c
Enable Freeze mode on HCS12 adc.
[arc.git] / arch / hc1x / hcs12d / drivers / Adc.c
1 /* -------------------------------- Arctic Core ------------------------------\r
2  * Arctic Core - the open source AUTOSAR platform http://arccore.com\r
3  *\r
4  * Copyright (C) 2009  ArcCore AB <contact@arccore.com>\r
5  *\r
6  * This source code is free software; you can redistribute it and/or modify it\r
7  * under the terms of the GNU General Public License version 2 as published by the\r
8  * Free Software Foundation; See <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>.\r
9  *\r
10  * This program is distributed in the hope that it will be useful, but\r
11  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY\r
12  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License\r
13  * for more details.\r
14  * -------------------------------- Arctic Core ------------------------------*/\r
15 \r
16 \r
17 #include <assert.h>\r
18 #include <stdlib.h>\r
19 #include "Mcu.h"\r
20 #include "Adc.h"\r
21 #include "Det.h"\r
22 #include "Os.h"\r
23 #include "isr.h"\r
24 #include "regs.h"\r
25 #include "arc.h"\r
26 \r
27 \r
28 // ATDCTL2\r
29 #define BM_ADPU 0x80\r
30 #define BM_AFFC 0x40\r
31 #define BM_AWAI 0x20\r
32 #define BM_ETRIGLE 0x10\r
33 #define BM_ETRIGP 0x08\r
34 #define BM_ETRIG_E 0x04\r
35 #define BM_ASCIE 0x02\r
36 #define BM_ASCIF 0x01\r
37 \r
38 // ATDCTL3\r
39 #define BM_S8C 0x40\r
40 #define BM_S4C 0x20\r
41 #define BM_S2C 0x10\r
42 #define BM_S1C 0x08\r
43 #define BM_FIFO 0x04\r
44 #define BM_FRZ1 0x02\r
45 #define BM_FRZ0 0x01\r
46 \r
47 // ATDCTL4\r
48 #define BM_SRES8 0x80\r
49 #define BM_SMP1 0x40\r
50 #define BM_SMP0 0x20\r
51 #define BM_PRS4 0x10\r
52 #define BM_PRS3 0x08\r
53 #define BM_PRS2 0x04\r
54 #define BM_PRS1 0x02\r
55 #define BM_PRS0 0x01\r
56 \r
57 // ATDCTL5\r
58 #define BM_DJM 0x80\r
59 #define BM_DSGN 0x40\r
60 #define BM_SCAN 0x20\r
61 #define BM_MULT 0x10\r
62 #define BM_CC 0x04\r
63 #define BM_CB 0x02\r
64 #define BM_CA 0x01\r
65 \r
66 typedef enum\r
67 {\r
68   ADC_UNINIT,\r
69   ADC_INIT,\r
70 }Adc_StateType;\r
71 \r
72 /* Function prototypes. */\r
73 \r
74 /* Development error checking. */\r
75 #if (ADC_READ_GROUP_API == STD_ON)\r
76 static Std_ReturnType Adc_CheckReadGroup (Adc_GroupType group);\r
77 #endif\r
78 #if (ADC_ENABLE_START_STOP_GROUP_API == STD_ON)\r
79 static Std_ReturnType Adc_CheckStartGroupConversion (Adc_GroupType group);\r
80 static Std_ReturnType Adc_CheckStopGroupConversion (Adc_GroupType group);\r
81 #endif\r
82 static Std_ReturnType Adc_CheckInit (const Adc_ConfigType *ConfigPtr);\r
83 static Std_ReturnType Adc_CheckSetupResultBuffer (Adc_GroupType group);\r
84 static Std_ReturnType Adc_CheckDeInit (void);\r
85 \r
86 static void Adc_GroupConversionComplete (void);\r
87 \r
88 static Adc_StateType adcState = ADC_UNINIT;\r
89 \r
90 /* Pointer to configuration structure. */\r
91 static const Adc_ConfigType *AdcConfigPtr;\r
92 \r
93 /* Validate functions used for development error check */\r
94 #if ( ADC_DEV_ERROR_DETECT == STD_ON )\r
95 Std_ReturnType ValidateInit(Adc_APIServiceIDType api)\r
96 {\r
97         Std_ReturnType res = E_OK;\r
98         if(!(ADC_INIT == adcState)) {\r
99                 Det_ReportError(MODULE_ID_ADC,0,api,ADC_E_UNINIT );\r
100                 res = E_NOT_OK;\r
101         }\r
102         return res;\r
103 }\r
104 Std_ReturnType ValidateGroup(Adc_GroupType group,Adc_APIServiceIDType api)\r
105 {\r
106         Std_ReturnType res = E_OK;\r
107         if(!((group >= 0) && (group < AdcConfig->nbrOfGroups))) {\r
108                 Det_ReportError(MODULE_ID_ADC,0,api,ADC_E_PARAM_GROUP );\r
109                 res = E_NOT_OK;\r
110         }\r
111         return res;\r
112 }\r
113 #endif\r
114 \r
115 #if (ADC_DEINIT_API == STD_ON)\r
116 Std_ReturnType Adc_DeInit (const Adc_ConfigType *ConfigPtr)\r
117 {\r
118         if (E_OK == Adc_CheckDeInit())\r
119         {\r
120             /* Clean internal status. */\r
121             AdcConfigPtr = (Adc_ConfigType *)NULL;\r
122             adcState = ADC_UNINIT;\r
123         }\r
124 \r
125          return (E_OK);\r
126 }\r
127 #endif\r
128 \r
129 Std_ReturnType Adc_Init (const Adc_ConfigType *ConfigPtr)\r
130 {\r
131   Std_ReturnType returnValue;\r
132   Adc_GroupType group;\r
133 \r
134   if (E_OK == Adc_CheckInit(ConfigPtr))\r
135   {\r
136     /* First of all, store the location of the configuration data. */\r
137     AdcConfigPtr = ConfigPtr;\r
138 \r
139     // Connect interrupt to correct isr\r
140         ISR_INSTALL_ISR2("ADC",Adc_GroupConversionComplete,IRQ_TYPE_ATD0,6,0);\r
141 \r
142 \r
143         ATD0CTL2   = BM_ADPU | BM_AFFC | BM_ASCIE;      /* power enable, Fast Flag Clear, irq enable*/\r
144     ATD0CTL3   = 0x03;  /* 8 conversions per sequence default, freeze enable */\r
145 \r
146     ATD0CTL4   = (ConfigPtr->hwConfigPtr->resolution << 7) |\r
147                      (ConfigPtr->hwConfigPtr->convTime << 5) |\r
148                       ConfigPtr->hwConfigPtr->adcPrescale;\r
149 \r
150     for (group = 0; group < ADC_NBR_OF_GROUPS; group++)\r
151     {\r
152       /* ADC307. */\r
153       ConfigPtr->groupConfigPtr[group].status->groupStatus = ADC_IDLE;\r
154     }\r
155 \r
156     /* Move on to INIT state. */\r
157     adcState = ADC_INIT;\r
158     returnValue = E_OK;\r
159   }\r
160   else\r
161   {\r
162     returnValue = E_NOT_OK;\r
163   }\r
164 \r
165   return (returnValue);\r
166 }\r
167 \r
168 Std_ReturnType Adc_SetupResultBuffer (Adc_GroupType group, Adc_ValueGroupType *bufferPtr)\r
169 {\r
170   Std_ReturnType returnValue;\r
171 \r
172   /* Check for development errors. */\r
173   if (E_OK == Adc_CheckSetupResultBuffer (group))\r
174   {\r
175     AdcConfigPtr->groupConfigPtr[group].status->resultBufferPtr = bufferPtr;\r
176     returnValue = E_OK;\r
177   }\r
178   else\r
179   {\r
180     /* An error have been raised from Adc_CheckSetupResultBuffer(). */\r
181     returnValue = E_NOT_OK;\r
182   }\r
183 \r
184   return (returnValue);\r
185 }\r
186 \r
187 #if (ADC_READ_GROUP_API == STD_ON)\r
188 Std_ReturnType Adc_ReadGroup (Adc_GroupType group, Adc_ValueGroupType *dataBufferPtr)\r
189 {\r
190   Std_ReturnType returnValue;\r
191   Adc_ChannelType channel;\r
192 \r
193   if (E_OK == Adc_CheckReadGroup (group))\r
194   {\r
195     if ((ADC_CONV_MODE_CONTINUOUS == AdcConfigPtr->groupConfigPtr[group].conversionMode) &&\r
196          ((ADC_STREAM_COMPLETED    == AdcConfigPtr->groupConfigPtr[group].status->groupStatus) ||\r
197           (ADC_COMPLETED           == AdcConfigPtr->groupConfigPtr[group].status->groupStatus)))\r
198     {\r
199       /* ADC329, ADC331. */\r
200       AdcConfigPtr->groupConfigPtr[group].status->groupStatus = ADC_BUSY;\r
201       returnValue = E_OK;\r
202     }\r
203     else if ((ADC_CONV_MODE_ONESHOT == AdcConfigPtr->groupConfigPtr[group].conversionMode) &&\r
204              (ADC_STREAM_COMPLETED  == AdcConfigPtr->groupConfigPtr[group].status->groupStatus))\r
205     {\r
206       /* ADC330. */\r
207       AdcConfigPtr->groupConfigPtr[group].status->groupStatus = ADC_IDLE;\r
208 \r
209       returnValue = E_OK;\r
210     }\r
211     else\r
212     {\r
213       /* Keep status. */\r
214       returnValue = E_OK;\r
215     }\r
216 \r
217     if (E_OK == returnValue)\r
218     {\r
219       /* Copy the result to application buffer. */\r
220       for (channel = 0; channel < AdcConfigPtr->groupConfigPtr[group].numberOfChannels; channel++)\r
221       {\r
222         dataBufferPtr[channel] = AdcConfigPtr->groupConfigPtr[group].resultBuffer[channel];\r
223       }\r
224     }\r
225   }\r
226   else\r
227   {\r
228     /* An error have been raised from Adc_CheckReadGroup(). */\r
229     returnValue = E_NOT_OK;\r
230   }\r
231 \r
232   return (returnValue);\r
233 }\r
234 #endif\r
235 \r
236 Adc_StatusType Adc_GetGroupStatus (Adc_GroupType group)\r
237 {\r
238         Adc_StatusType returnValue;\r
239 \r
240 #if ( ADC_DEV_ERROR_DETECT == STD_ON )\r
241         if( (ValidateInit(ADC_GETGROUPSTATUS_ID) == E_NOT_OK) ||\r
242                 (ValidateGroup(group, ADC_GETGROUPSTATUS_ID) == E_NOT_OK))\r
243         {\r
244                 returnValue = ADC_IDLE;\r
245         }\r
246         else\r
247         {\r
248                 returnValue = AdcConfigPtr->groupConfigPtr[group].status->groupStatus;\r
249         }\r
250 #else\r
251   returnValue = AdcConfigPtr->groupConfigPtr[group].status->groupStatus;\r
252 #endif\r
253   return (returnValue);\r
254 }\r
255 \r
256 static void Adc_GroupConversionComplete (void)\r
257 {\r
258   uint8 index;\r
259   Adc_GroupDefType *groupPtr = NULL;\r
260   /* Clear SCF flag. Not needed if AFFC is set but better to always do it  */\r
261   ATD0STAT0 = SCF;\r
262 \r
263   // Check which group is busy, only one is allowed to be busy at a time in a hw unit\r
264   for (index = 0; index < ADC_NBR_OF_GROUPS; index++)\r
265   {\r
266           if(AdcConfigPtr->groupConfigPtr[index].status->groupStatus == ADC_BUSY)\r
267           {\r
268                   groupPtr = (Adc_GroupDefType *)&AdcConfigPtr->groupConfigPtr[index];\r
269                   break;\r
270           }\r
271   }\r
272   if(groupPtr != NULL)\r
273   {\r
274           // Read hw buffer,\r
275           volatile uint16_t *ptr = &ATD0DR0;\r
276           for(index=0; index<groupPtr->numberOfChannels; index++)\r
277           {\r
278                   groupPtr->resultBuffer[index] = *(ptr + groupPtr->channelList[index]);\r
279           }\r
280 \r
281           /* Sample completed. */\r
282           groupPtr->status->groupStatus = ADC_STREAM_COMPLETED;\r
283 \r
284           /* Call notification if enabled. */\r
285         #if (ADC_GRP_NOTIF_CAPABILITY == STD_ON)\r
286           if (groupPtr->status->notifictionEnable && groupPtr->groupCallback != NULL)\r
287           {\r
288                   groupPtr->groupCallback();\r
289           }\r
290         #endif\r
291   }\r
292 }\r
293 \r
294 #if (ADC_ENABLE_START_STOP_GROUP_API == STD_ON)\r
295 void Adc_StartGroupConversion (Adc_GroupType group)\r
296 {\r
297   /* Run development error check. */\r
298   if (E_OK == Adc_CheckStartGroupConversion (group))\r
299   {\r
300     /* Set single scan enable bit if this group is one shot. */\r
301     if (AdcConfigPtr->groupConfigPtr[group].conversionMode == ADC_CONV_MODE_ONESHOT)\r
302     {\r
303            /* Start next AD conversion. */\r
304            ATD0CTL5 = BM_DJM | BM_MULT; /* 10010000 Right Justified,unsigned */\r
305                                                                 /* No SCAN/MULT/AD0 start select */\r
306       /* Set group state to BUSY. */\r
307       AdcConfigPtr->groupConfigPtr[group].status->groupStatus = ADC_BUSY;\r
308     }\r
309     else\r
310     {\r
311         // Continous mode\r
312            /* Start AD conversion. */\r
313            ATD0CTL5 = BM_DJM | BM_MULT | BM_SCAN; /* 10010000 Right Justified,unsigned */\r
314                                                                           /* SCAN/MULT/AD0 start select */\r
315        /* Set group state to BUSY. */\r
316        AdcConfigPtr->groupConfigPtr[group].status->groupStatus = ADC_BUSY;\r
317     }\r
318   }\r
319 }\r
320 \r
321 void Adc_StopGroupConversion (Adc_GroupType group)\r
322 {\r
323   /* Run development error check. */\r
324   if (E_OK == Adc_CheckStopGroupConversion (group))\r
325   {\r
326            ATD0CTL3 = 0x03; /* Hard write to stop current conversion */\r
327   }\r
328   else\r
329   {\r
330         /* Error have been set within Adc_CheckStartGroupConversion(). */\r
331   }\r
332 }\r
333 #endif\r
334 \r
335 #if (ADC_GRP_NOTIF_CAPABILITY == STD_ON)\r
336 void Adc_EnableGroupNotification (Adc_GroupType group)\r
337 {\r
338         Std_ReturnType res;\r
339 \r
340 #if ( ADC_DEV_ERROR_DETECT == STD_ON )\r
341         if( (ValidateInit(ADC_ENABLEGROUPNOTIFICATION_ID) == E_NOT_OK) ||\r
342                 (ValidateGroup(group, ADC_ENABLEGROUPNOTIFICATION_ID) == E_NOT_OK))\r
343         {\r
344                 res = E_NOT_OK;\r
345         }\r
346         else if (AdcConfigPtr->groupConfigPtr[group].groupCallback == NULL)\r
347         {\r
348                 res = E_NOT_OK;\r
349                 Det_ReportError(MODULE_ID_ADC,0,ADC_ENABLEGROUPNOTIFICATION_ID ,ADC_E_NOTIF_CAPABILITY );\r
350         }\r
351         else\r
352         {\r
353                 /* Nothing strange. Go on... */\r
354                 res = E_OK;\r
355         }\r
356 #else\r
357         res = E_OK;\r
358 #endif\r
359         if (E_OK == res){\r
360                 AdcConfigPtr->groupConfigPtr[group].status->notifictionEnable = 1;\r
361         }\r
362 }\r
363 \r
364 void Adc_DisableGroupNotification (Adc_GroupType group)\r
365 {\r
366         Std_ReturnType res;\r
367 \r
368 #if ( ADC_DEV_ERROR_DETECT == STD_ON )\r
369         if( (ValidateInit(ADC_DISABLEGROUPNOTIFICATION_ID) == E_NOT_OK) ||\r
370                 (ValidateGroup(group, ADC_DISABLEGROUPNOTIFICATION_ID) == E_NOT_OK))\r
371         {\r
372                 res = E_NOT_OK;\r
373         }\r
374         else if (AdcConfigPtr->groupConfigPtr[group].groupCallback == NULL)\r
375         {\r
376                 res = E_NOT_OK;\r
377                 Det_ReportError(MODULE_ID_ADC,0,ADC_DISABLEGROUPNOTIFICATION_ID ,ADC_E_NOTIF_CAPABILITY );\r
378         }\r
379         else\r
380         {\r
381                 /* Nothing strange. Go on... */\r
382                 res = E_OK;\r
383         }\r
384 #else\r
385         res = E_OK;\r
386 #endif\r
387         if (E_OK == res){\r
388                 AdcConfigPtr->groupConfigPtr[group].status->notifictionEnable = 0;\r
389         }\r
390 }\r
391 #endif\r
392 \r
393 \r
394 /* Development error checking functions. */\r
395 #if (ADC_READ_GROUP_API == STD_ON)\r
396 static Std_ReturnType Adc_CheckReadGroup (Adc_GroupType group)\r
397 {\r
398   Std_ReturnType returnValue;\r
399 \r
400 #if ( ADC_DEV_ERROR_DETECT == STD_ON )\r
401 \r
402   if (ADC_UNINIT == adcState)\r
403   {\r
404     /* ADC296. */\r
405     returnValue = E_NOT_OK;\r
406     Det_ReportError(MODULE_ID_ADC,0,ADC_READGROUP_ID ,ADC_E_UNINIT );\r
407   }\r
408   else if ((group < ADC_GROUP0) || (group >= ADC_NBR_OF_GROUPS))\r
409   {\r
410     /* ADC152. */\r
411     returnValue = E_NOT_OK;\r
412     Det_ReportError(MODULE_ID_ADC,0,ADC_READGROUP_ID ,ADC_E_PARAM_GROUP );\r
413   }\r
414   else if (ADC_IDLE == AdcConfigPtr->groupConfigPtr[group].status->groupStatus)\r
415   {\r
416     /* ADC388. */\r
417     returnValue = E_NOT_OK;\r
418     Det_ReportError(MODULE_ID_ADC,0,ADC_READGROUP_ID ,ADC_E_IDLE );\r
419   }\r
420   else\r
421   {\r
422     /* Nothing strange. Go on... */\r
423     returnValue = E_OK;\r
424   }\r
425 #else\r
426   returnValue = E_OK;\r
427 #endif\r
428   return (returnValue);\r
429 }\r
430 #endif\r
431 \r
432 #if (ADC_ENABLE_START_STOP_GROUP_API == STD_ON)\r
433 static Std_ReturnType Adc_CheckStartGroupConversion (Adc_GroupType group)\r
434 {\r
435           Std_ReturnType returnValue;\r
436 \r
437         #if ( ADC_DEV_ERROR_DETECT == STD_ON )\r
438 \r
439           if( (ValidateInit(ADC_STARTGROUPCONVERSION_ID) == E_NOT_OK) ||\r
440               (ValidateGroup(group, ADC_STARTGROUPCONVERSION_ID) == E_NOT_OK))\r
441           {\r
442                   returnValue = E_NOT_OK;\r
443           }\r
444           else if ( NULL == AdcConfigPtr->groupConfigPtr[group].status->resultBufferPtr )\r
445           {\r
446               /* ResultBuffer not set, ADC424 */\r
447                   Det_ReportError(MODULE_ID_ADC,0,ADC_STARTGROUPCONVERSION_ID, ADC_E_BUFFER_UNINIT );\r
448                   returnValue = E_NOT_OK;\r
449           }\r
450           else if (!(ADC_TRIGG_SRC_SW == AdcConfigPtr->groupConfigPtr[group].triggerSrc))\r
451           {\r
452             /* Wrong trig source, ADC133. */\r
453             Det_ReportError(MODULE_ID_ADC,0,ADC_STARTGROUPCONVERSION_ID, ADC_E_WRONG_TRIGG_SRC);\r
454             returnValue = E_NOT_OK;\r
455           }\r
456           else if (!((ADC_IDLE             == AdcConfigPtr->groupConfigPtr[group].status->groupStatus) ||\r
457                      (ADC_STREAM_COMPLETED == AdcConfigPtr->groupConfigPtr[group].status->groupStatus)))\r
458           {\r
459             /* Group status not OK, ADC351, ADC428 */\r
460             Det_ReportError(MODULE_ID_ADC,0,ADC_STARTGROUPCONVERSION_ID, ADC_E_BUSY );\r
461 \r
462             /*\r
463              * This is a BUG!\r
464              * Sometimes the ADC-interrupt gets lost which means that the status is never reset to ADC_IDLE (done in Adc_ReadGroup).\r
465              * Therefor another group conversion is never started...\r
466              *\r
467              * The temporary fix is to always return E_OK here. But the reason for the bug needs to be investigated further.\r
468              */\r
469             //returnValue = E_NOT_OK;\r
470             returnValue = E_OK;\r
471           }\r
472           else\r
473           {\r
474             returnValue = E_OK;\r
475           }\r
476         #else\r
477           returnValue = E_OK;\r
478         #endif\r
479 \r
480           return (returnValue);\r
481 }\r
482 \r
483 static Std_ReturnType Adc_CheckStopGroupConversion (Adc_GroupType group)\r
484 {\r
485   Std_ReturnType returnValue;\r
486 \r
487 #if ( ADC_DEV_ERROR_DETECT == STD_ON )\r
488   if( (ValidateInit(ADC_STOPGROUPCONVERSION_ID) == E_NOT_OK) ||\r
489       (ValidateGroup(group, ADC_STOPGROUPCONVERSION_ID) == E_NOT_OK))\r
490   {\r
491           returnValue = E_NOT_OK;\r
492   }\r
493   else if (!(ADC_TRIGG_SRC_SW == AdcConfigPtr->groupConfigPtr[group].triggerSrc))\r
494   {\r
495         /* Wrong trig source, ADC164. */\r
496         Det_ReportError(MODULE_ID_ADC,0,ADC_STOPGROUPCONVERSION_ID, ADC_E_WRONG_TRIGG_SRC);\r
497         returnValue = E_NOT_OK;\r
498   }\r
499   else if (ADC_IDLE == AdcConfigPtr->groupConfigPtr[group].status->groupStatus)\r
500   {\r
501         /* Group status not OK, ADC241 */\r
502         Det_ReportError(MODULE_ID_ADC,0,ADC_STOPGROUPCONVERSION_ID, ADC_E_IDLE );\r
503         returnValue = E_NOT_OK;\r
504   }\r
505   else\r
506   {\r
507         returnValue = E_OK;\r
508   }\r
509 #else\r
510   returnValue = E_OK;\r
511 #endif\r
512 \r
513   return (returnValue);\r
514 }\r
515 #endif\r
516 \r
517 static Std_ReturnType Adc_CheckInit (const Adc_ConfigType *ConfigPtr)\r
518 {\r
519   Std_ReturnType returnValue;\r
520 \r
521 #if ( ADC_DEV_ERROR_DETECT == STD_ON )\r
522   if (!(ADC_UNINIT == adcState))\r
523   {\r
524     /* Oops, already initialised. */\r
525     Det_ReportError(MODULE_ID_ADC,0,ADC_INIT_ID, ADC_E_ALREADY_INITIALIZED );\r
526     returnValue = E_NOT_OK;\r
527   }\r
528   else if (ConfigPtr == NULL)\r
529   {\r
530     /* Wrong config! */\r
531     Det_ReportError(MODULE_ID_ADC,0,ADC_INIT_ID, ADC_E_PARAM_CONFIG );\r
532     returnValue = E_NOT_OK;\r
533   }\r
534   else\r
535   {\r
536     /* Looks good!! */\r
537     returnValue = E_OK;\r
538   }\r
539 #else\r
540     returnValue = E_OK;\r
541 #endif\r
542   return (returnValue);\r
543 }\r
544 \r
545 static Std_ReturnType Adc_CheckDeInit (void)\r
546 {\r
547         Std_ReturnType returnValue = E_OK;\r
548 \r
549 #if ( ADC_DEV_ERROR_DETECT == STD_ON )\r
550         if(ValidateInit(ADC_DEINIT_ID) == E_OK)\r
551         {\r
552                 for (Adc_GroupType group = ADC_GROUP0; group < AdcConfigPtr->nbrOfGroups; group++)\r
553                 {\r
554                         /*  Check ADC is IDLE or COMPLETE*/\r
555                         if((AdcConfigPtr->groupConfigPtr[group].status->groupStatus != ADC_IDLE) && (AdcConfigPtr->groupConfigPtr[group].status->groupStatus != ADC_STREAM_COMPLETED))\r
556                         {\r
557                                 Det_ReportError(MODULE_ID_ADC,0,ADC_DEINIT_ID, ADC_E_BUSY );\r
558                                 returnValue = E_NOT_OK;\r
559                         }\r
560                 }\r
561         }\r
562         else\r
563         {\r
564                 returnValue = E_NOT_OK;\r
565         }\r
566 #else\r
567         returnValue = E_OK;\r
568 #endif\r
569         return (returnValue);\r
570 }\r
571 static Std_ReturnType Adc_CheckSetupResultBuffer (Adc_GroupType group)\r
572 {\r
573           Std_ReturnType returnValue = E_OK;\r
574 \r
575         #if ( ADC_DEV_ERROR_DETECT == STD_ON )\r
576           if(ValidateGroup(group, ADC_SETUPRESULTBUFFER_ID) == E_NOT_OK)\r
577           {\r
578                   returnValue = E_NOT_OK;\r
579           }\r
580         #else\r
581           returnValue = E_OK;\r
582         #endif\r
583           return (returnValue);\r
584 }\r
585 \r
586 \r