]> rtime.felk.cvut.cz Git - arc.git/blob - include/Adc.h
Splitting of Adc to eQADC and Adc_560x......continued....now for all architectures...
[arc.git] / include / Adc.h
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 /** @addtogroup Adc ADC Driver\r
17  *  @{ */\r
18 \r
19 /** @file Adc.h\r
20  * API and type definitions for ADC Driver.\r
21  */\r
22 \r
23 #ifndef ADC_H_\r
24 #define ADC_H_\r
25 \r
26 #include "Std_Types.h"\r
27 \r
28 #define ADC_VENDOR_ID                       1\r
29 #define ADC_MODULE_ID                       MODULE_ID_ADC\r
30 #define ADC_AR_MAJOR_VERSION            3\r
31 #define ADC_AR_MINOR_VERSION            0\r
32 #define ADC_AR_PATCH_VERSION            3\r
33 \r
34 #define ADC_SW_MAJOR_VERSION            1\r
35 #define ADC_SW_MINOR_VERSION            0\r
36 #define ADC_SW_PATCH_VERSION            0\r
37 \r
38 /** Group status. */\r
39 typedef enum\r
40 {\r
41   ADC_IDLE,\r
42   ADC_BUSY,\r
43   ADC_COMPLETED,\r
44   ADC_STREAM_COMPLETED,\r
45 }Adc_StatusType;\r
46 \r
47 \r
48 /* DET errors that the ADC can produce. */\r
49 typedef enum\r
50 {\r
51   ADC_E_UNINIT              = 0x0A,\r
52   ADC_E_BUSY                = 0x0B,\r
53   ADC_E_IDLE                = 0x0C,\r
54   ADC_E_ALREADY_INITIALIZED = 0x0D,\r
55   ADC_E_PARAM_CONFIG        = 0x0E,\r
56   ADC_E_PARAM_GROUP         = 0x15,\r
57   ADC_E_WRONG_CONV_MODE     = 0x16,\r
58   ADC_E_WRONG_TRIGG_SRC     = 0x17,\r
59   ADC_E_NOTIF_CAPABILITY    = 0x18,\r
60   ADC_E_BUFFER_UNINIT       = 0x19\r
61 }Adc_DetErrorType;\r
62 \r
63 /** API service ID's */\r
64 typedef enum\r
65 {\r
66   ADC_INIT_ID = 0x00,\r
67   ADC_DEINIT_ID = 0x01,\r
68   ADC_STARTGROUPCONVERSION_ID = 0x02,\r
69   ADC_STOPGROUPCONVERSION_ID = 0x03,\r
70   ADC_READGROUP_ID = 0x04,\r
71   ADC_ENABLEHARDWARETRIGGER_ID = 0x05,\r
72   ADC_DISBALEHARDWARETRIGGER_ID = 0x06,\r
73   ADC_ENABLEGROUPNOTIFICATION_ID = 0x07,\r
74   ADC_DISABLEGROUPNOTIFICATION_ID = 0x08,\r
75   ADC_GETGROUPSTATUS_ID = 0x09,\r
76   ADC_GETVERSIONINFO_ID = 0x0A,\r
77   ADC_GETSTREAMLASTPOINTER_ID = 0x0B,\r
78   ADC_SETUPRESULTBUFFER_ID = 0x0C,\r
79 }Adc_APIServiceIDType;\r
80 \r
81 /*\r
82  * Std-types\r
83  *\r
84  */\r
85 /** Access mode to group conversion results. */\r
86 typedef enum\r
87 {\r
88   ADC_ACCESS_MODE_SINGLE,\r
89   ADC_ACCESS_MODE_STREAMING\r
90 }Adc_GroupAccessModeType;\r
91 \r
92 /** Group trigger source (Not supported). */\r
93 typedef enum\r
94 {\r
95   ADC_TRIGG_SRC_HW,\r
96   ADC_TRIGG_SRC_SW,\r
97 }Adc_TriggerSourceType;\r
98 \r
99 /** HW trigger edge (Not supported). */\r
100 typedef enum\r
101 {\r
102   ADC_NO_HW_TRIG,\r
103   ADC_HW_TRIG_BOTH_EDGES,\r
104   ADC_HW_TRIG_FALLING_EDGE,\r
105   ADC_HW_TRIG_RISING_EDGE,\r
106 }Adc_HwTriggerSignalType;\r
107 \r
108 /** Stream buffer type. */\r
109 typedef enum\r
110 {\r
111   ADC_NO_STREAMING,\r
112   ADC_STREAM_BUFFER_CIRCULAR,\r
113   ADC_STREAM_BUFFER_LINEAR,\r
114 }Adc_StreamBufferModeType;\r
115 \r
116 #include "Adc_Cfg.h"\r
117 \r
118 /* Function interface. */\r
119 /** Initializes the ADC hardware units and driver. */\r
120 void Adc_Init (const Adc_ConfigType *ConfigPtr);\r
121 #if (ADC_DEINIT_API == STD_ON)\r
122 /** Returns all ADC HW Units to a state comparable to their power on reset state. */\r
123 void Adc_DeInit ();\r
124 #endif\r
125 /** Sets up the result buffer for a group. */\r
126 Std_ReturnType Adc_SetupResultBuffer (Adc_GroupType group, Adc_ValueGroupType *bufferPtr);\r
127 #if (ADC_ENABLE_START_STOP_GROUP_API == STD_ON)\r
128 /** Starts the conversion of all channels of the requested ADC Channel group. */\r
129 void           Adc_StartGroupConversion (Adc_GroupType group);\r
130 void           Adc_StopGroupConversion (Adc_GroupType group);\r
131 #endif\r
132 #if (ADC_READ_GROUP_API == STD_ON)\r
133 /** Reads results from last conversion into buffer */\r
134 Std_ReturnType Adc_ReadGroup (Adc_GroupType group, Adc_ValueGroupType *dataBufferPtr);\r
135 #endif\r
136 \r
137 #if !defined(CFG_HC1X)\r
138 /** Reads results from last streaming conversion into buffer */\r
139 Adc_StreamNumSampleType Adc_GetStreamLastPointer(Adc_GroupType group, Adc_ValueGroupType** PtrToSamplePtr);\r
140 #endif\r
141 \r
142 #if (ADC_GRP_NOTIF_CAPABILITY == STD_ON)\r
143 /** Enables the notification mechanism for the requested ADC Channel group. */\r
144 void           Adc_EnableGroupNotification (Adc_GroupType group);\r
145 /** Disables the notification mechanism for the requested ADC Channel group. */\r
146 void           Adc_DisableGroupNotification (Adc_GroupType group);\r
147 #endif\r
148 /** Returns the conversion status of the requested ADC Channel group. */\r
149 Adc_StatusType Adc_GetGroupStatus (Adc_GroupType group);\r
150 \r
151 #endif /*ADC_H_*/\r
152 \r
153 /** @} */\r
154 \r