TMPM4KxA Group Peripheral Driver User Manual  V1.0.4.0
txz_adc.h
Go to the documentation of this file.
1 
13 /*------------------------------------------------------------------------------*/
14 /* Define to prevent recursive inclusion */
15 /*------------------------------------------------------------------------------*/
16 #ifndef __ADC_H
17 #define __ADC_H
18 
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22 
23 /*------------------------------------------------------------------------------*/
24 /* Includes */
25 /*------------------------------------------------------------------------------*/
26 #include "txz_driver_def.h"
27 #include "txz_adc_ch.h"
28 
39 /*------------------------------------------------------------------------------*/
40 /* Macro Definition */
41 /*------------------------------------------------------------------------------*/
52  #define ADC_NUM_MAX ((uint32_t)24) /* End of group ADC_ChannelMax */
56 
62 #define ADC_CONVERT_TIME_0_50_AVDD_4_5 ((uint32_t)0x00000000)
63 #define ADC_CONVERT_TIME_0_62_AVDD_4_5 ((uint32_t)0x00000001)
64 #define ADC_CONVERT_TIME_0_85_AVDD_4_5 ((uint32_t)0x00000002)
65 #define ADC_CONVERT_TIME_2_00_AVDD_2_7 ((uint32_t)0x00000003) /* End of group ADC_CONVERT_TIME */
69 
75 #define ADC_REFBSEL_VREFH ((uint32_t)0x00000000)
76 #define ADC_REFBSEL_AIN ((uint32_t)0x00000004) /* End of group ADC_REFBSEL */
80 
86 #define ADC_RCUT_NORMAL ((uint32_t)0x00000000)
87 #define ADC_RCUT_LOW ((uint32_t)0x00000002) /* End of group ADC_RCUT */
91 
97 #define ADC_INT_DISABLE ((uint32_t)0x00000000)
98 #define ADC_INT_ENABLE ((uint32_t)0x00000080) /* End of group ADC_IntEnable */
102 
108 #define ADC_CONVERSION_DISABLE ((uint32_t)0x00000000)
109 #define ADC_CONVERSION_CNT ((uint32_t)0x00000020)
110 #define ADC_CONVERSION_SGL ((uint32_t)0x00000040)
111 #define ADC_CONVERSION_TRG ((uint32_t)0x00000060) /* End of group ADC_Conversion */
115 
122 #define ADC_AIN_RANGE_MIN ((uint32_t)0x00000000)
123 #define ADC_AIN_RANGE_MAX ((uint32_t)0x00000017) /* End of group ADC_AINRange */
127 
133 #define ADC_STATUS_MASK ((uint32_t)0x00000080)
134 #define ADC_STATUS_SLEEP ((uint32_t)0x00000000)
135 #define ADC_STATUS_RUNNING ((uint32_t)0x00000080) /* End of group ADC_Status */
139 
145 #define ADC_CNT_STATUS_MASK ((uint32_t)0x00000008)
146 #define ADC_CNT_STATUS_SLEEP ((uint32_t)0x00000000)
147 #define ADC_CNT_STATUS_RUNNING ((uint32_t)0x00000008) /* End of group ADC_ContinuityStatus */
151 
157 #define ADC_SGL_STATUS_MASK ((uint32_t)0x00000004)
158 #define ADC_SGL_STATUS_SLEEP ((uint32_t)0x00000000)
159 #define ADC_SGL_STATUS_RUNNING ((uint32_t)0x00000004) /* End of group ADC_SingleStatus */
163 
169 #define ADC_TRG_STATUS_MASK ((uint32_t)0x00000002)
170 #define ADC_TRG_STATUS_SLEEP ((uint32_t)0x00000000)
171 #define ADC_TRG_STATUS_RUNNING ((uint32_t)0x00000002) /* End of group ADC_TriggerStatus */
175 
181 #define ADC_SH_TRGPAT_UPPER_0 ((uint32_t)0x00000000)
182 #define ADC_SH_TRGPAT_UPPER_1 ((uint32_t)0x00000004)
183 #define ADC_SH_TRGPAT_UPPER_2 ((uint32_t)0x00000008)
184 #define ADC_SH_TRGPAT_UPPER_3 ((uint32_t)0x0000000C)
185 #define ADC_SH_TRGPAT_LOWER_0 ((uint32_t)0x00000000)
186 #define ADC_SH_TRGPAT_LOWER_1 ((uint32_t)0x00000001)
187 #define ADC_SH_TRGPAT_LOWER_2 ((uint32_t)0x00000002)
188 #define ADC_SH_TRGPAT_LOWER_3 ((uint32_t)0x00000003) /* End of group ADC_SH_TriggerPattern */
192  /* End of group ADC_Exported_define */
196 
197 /*------------------------------------------------------------------------------*/
198 /* Enumerated Type Definition */
199 /*------------------------------------------------------------------------------*/
205 /* no define */
206  /* End of group ADC_Exported_define */
210 
211 /*------------------------------------------------------------------------------*/
212 /* Structure Definition */
213 /*------------------------------------------------------------------------------*/
218 /*----------------------------------*/
222 /*----------------------------------*/
223 typedef struct
224 {
225  uint32_t id;
226  uint32_t convert_time;
228  uint32_t refbsel;
230  uint32_t rcut;
234 
235 /*----------------------------------*/
239 /*----------------------------------*/
240 typedef struct
241 {
242  uint32_t ain;
245 
246 /*----------------------------------*/
250 /*----------------------------------*/
251 typedef struct
252 {
253  adc_ch_t ch[ADC_NUM_MAX];
255 
256 /*----------------------------------*/
260 /*----------------------------------*/
261 typedef struct
262 {
263  TSB_AD_TypeDef *p_instance;
265  void (*handler)(uint32_t id, TXZ_Result result);
267 } adc_t;
268  /* End of group ADC_Exported_typedef */
272 
273 /*------------------------------------------------------------------------------*/
274 /* Functions */
275 /*------------------------------------------------------------------------------*/
280 TXZ_Result adc_init(adc_t *p_obj);
281 TXZ_Result adc_deinit(adc_t *p_obj);
282 TXZ_Result adc_channel_setting(adc_t *p_obj, uint32_t ch, adc_channel_setting_t *p_setting);
283 TXZ_Result adc_channel_clear(adc_t *p_obj, uint32_t ch);
284 TXZ_Result adc_channel_get_value(adc_t *p_obj, uint32_t ch, uint32_t *p_value);
285 TXZ_Result adc_start(adc_t *p_obj);
286 TXZ_Result adc_stop(adc_t *p_obj);
287 TXZ_Result adc_startIt(adc_t *p_obj);
288 TXZ_Result adc_stopIt(adc_t *p_obj);
289 TXZ_WorkState adc_poll_conversion(adc_t *p_obj, uint32_t timeout);
290 void adc_irq_handler(adc_t *p_obj); /* End of group ADC_Exported_functions */
294  /* End of group ADC */
298  /* End of group Periph_Driver */
302 
303 #ifdef __cplusplus
304 }
305 #endif /* __cplusplus */
306 #endif /* __ADC_H */
307 
308 
This file provides all the functions prototypes for ADC driver. Channel Class.
TXZ_Result adc_startIt(adc_t *p_obj)
Start non-blocking single conversion.
Definition: txz_adc.c:608
TXZ_Result adc_channel_clear(adc_t *p_obj, uint32_t ch)
ADC Channel Clear.
Definition: txz_adc.c:436
TXZ_Result adc_channel_get_value(adc_t *p_obj, uint32_t ch, uint32_t *p_value)
Get AD value.
Definition: txz_adc.c:475
Initial setting structure definenition.
Definition: txz_adc.h:223
uint32_t convert_time
Definition: txz_adc.h:226
TXZ_Result adc_stop(adc_t *p_obj)
Stop blocking single conversion.
Definition: txz_adc.c:546
uint32_t refbsel
Definition: txz_adc.h:228
TXZ_Result adc_start(adc_t *p_obj)
Start blocking single conversion.
Definition: txz_adc.c:513
adc_internal_info_t info
Definition: txz_adc.h:266
Channel Setting. .
Definition: txz_adc.h:240
TXZ_Result adc_channel_setting(adc_t *p_obj, uint32_t ch, adc_channel_setting_t *p_setting)
ADC Channel Setting.
Definition: txz_adc.c:391
uint32_t ain
Definition: txz_adc.h:242
TXZ_Result adc_deinit(adc_t *p_obj)
Release the ADC object.
Definition: txz_adc.c:320
TXZ_WorkState adc_poll_conversion(adc_t *p_obj, uint32_t timeout)
Wait for single conversion to be completed.
Definition: txz_adc.c:702
TXZ_Result adc_stopIt(adc_t *p_obj)
Stop non-blocking single conversion.
Definition: txz_adc.c:670
All common macro and definition for TXZ peripheral drivers.
uint32_t id
Definition: txz_adc.h:225
adc_initial_setting_t init
Definition: txz_adc.h:264
Driver internal information structure definenition.
Definition: txz_adc.h:251
uint32_t rcut
Definition: txz_adc.h:230
ADC handle structure definenition.
Definition: txz_adc.h:261
ADC handle structure definenition.
Definition: txz_adc_ch.h:95
TSB_AD_TypeDef * p_instance
Definition: txz_adc.h:263
void adc_irq_handler(adc_t *p_obj)
IRQ Handler for single conversion done.
Definition: txz_adc.c:768
TXZ_Result adc_init(adc_t *p_obj)
Initialize the ADC object.
Definition: txz_adc.c:227