app_adc.h
Go to the documentation of this file.
1
52 #ifndef _APP_ADC_H_
53 #define _APP_ADC_H_
54
55 #include "gr55xx_hal.h"
56 #include "app_io.h"
57 #include "app_drv_error.h"
58 #ifdef ENV_USE_FREERTOS
59 #include "app_rtos_cfg.h"
60 #endif
61
62 #ifdef __cplusplus
63 extern "C" {
64 #endif
65
66 #ifdef HAL_ADC_MODULE_ENABLED
67
75 typedef enum
76 {
77 APP_ADC_TYPE_POLLING,
78 APP_ADC_TYPE_DMA,
79 APP_ADC_TYPE_MAX,
80 } app_adc_type_t;
81
85 typedef enum
86 {
87 APP_ADC_EVT_CONV_CPLT,
88 } app_adc_evt_type_t;
89
100 typedef struct
101 {
102 app_io_type_t type;
103 app_io_mux_t mux;
104 uint32_t pin;
106 } app_adc_pin_t;
107
111 typedef struct
112 {
113 app_adc_pin_t channel_p;
114 app_adc_pin_t channel_n;
115 app_adc_pin_t extern_ref;
116 } app_adc_pin_cfg_t;
117
121 typedef struct
122 {
123 app_adc_type_t type;
124 dma_channel_t dma_channel;
125 } app_adc_mode_t;
126
130 typedef struct
131 {
132 app_adc_pin_cfg_t pin_cfg;
133 app_adc_mode_t use_mode;
134 adc_init_t init;
135 } app_adc_params_t;
136
140 typedef struct
141 {
142 app_adc_evt_type_t type;
143 } app_adc_evt_t;
144
148 typedef void (*app_adc_evt_handler_t)(app_adc_evt_t *p_evt);
149
152 /* Exported functions --------------------------------------------------------*/
171 uint16_t app_adc_init(app_adc_params_t *p_params, app_adc_evt_handler_t evt_handler);
172
180 uint16_t app_adc_deinit(void);
181
193 uint16_t app_adc_conversion_sync(uint16_t *p_data, uint32_t length, uint32_t timeout);
194
205 uint16_t app_adc_conversion_async(uint16_t *p_data, uint32_t length);
206
218 uint16_t app_adc_voltage_intern(uint16_t *inbuf, double *outbuf, uint32_t buflen);
219
232 uint16_t app_adc_voltage_extern(double ref, uint16_t *inbuf, double *outbuf, uint32_t buflen);
233
241 adc_handle_t *app_adc_get_handle(void);
242
243
244 #ifdef ENV_RTOS_USE_SEMP
245
255 uint16_t app_adc_conversion_sem_sync(uint16_t *p_data, uint32_t length);
256 #endif
257
260 #endif
261
262 #ifdef __cplusplus
263 }
264 #endif
265
266 #endif
267
app_adc_voltage_extern
uint16_t app_adc_voltage_extern(double ref, uint16_t *inbuf, double *outbuf, uint32_t buflen)
Convert the ADC conversion results to a voltage value(external reference).
APP_ADC_EVT_CONV_CPLT
@ APP_ADC_EVT_CONV_CPLT
Definition: app_adc.h:87
app_adc_pin_t::mux
app_io_mux_t mux
Definition: app_adc.h:103
app_adc_evt_t::type
app_adc_evt_type_t type
Definition: app_adc.h:142
app_io_type_t
app_io_type_t
GPIO type Enumerations definition.
Definition: app_io.h:141
app_adc_mode_t::dma_channel
dma_channel_t dma_channel
Definition: app_adc.h:124
app_adc_mode_t
ADC operate mode Structures.
Definition: app_adc.h:122
app_adc_params_t
ADC parameters structure definition.
Definition: app_adc.h:131
app_adc_pin_t::pin
uint32_t pin
Definition: app_adc.h:104
APP_ADC_TYPE_MAX
@ APP_ADC_TYPE_MAX
Definition: app_adc.h:79
app_adc_params_t::pin_cfg
app_adc_pin_cfg_t pin_cfg
Definition: app_adc.h:132
_ll_adc_init
LL ADC init Structure definition.
Definition: gr55xx_ll_adc.h:77
app_io.h
Header file containing functions prototypes of GPIO app library.
app_adc_evt_t
ADC event structure definition.
Definition: app_adc.h:141
app_adc_evt_type_t
app_adc_evt_type_t
ADC event Enumerations definition.
Definition: app_adc.h:86
app_adc_params_t::use_mode
app_adc_mode_t use_mode
Definition: app_adc.h:133
app_adc_voltage_intern
uint16_t app_adc_voltage_intern(uint16_t *inbuf, double *outbuf, uint32_t buflen)
Convert the ADC conversion results to a voltage value(internal reference).
app_adc_type_t
app_adc_type_t
ADC operating mode Enumerations definition.
Definition: app_adc.h:76
APP_ADC_TYPE_POLLING
@ APP_ADC_TYPE_POLLING
Definition: app_adc.h:77
app_adc_mode_t::type
app_adc_type_t type
Definition: app_adc.h:123
app_adc_evt_handler_t
void(* app_adc_evt_handler_t)(app_adc_evt_t *p_evt)
ADC event callback definition.
Definition: app_adc.h:148
app_adc_conversion_sync
uint16_t app_adc_conversion_sync(uint16_t *p_data, uint32_t length, uint32_t timeout)
Polling for conversion.
_adc_handle
ADC handle Structure definition.
Definition: gr55xx_hal_adc.h:111
app_adc_pin_t::type
app_io_type_t type
Definition: app_adc.h:102
app_adc_pin_cfg_t::extern_ref
app_adc_pin_t extern_ref
Definition: app_adc.h:115
app_adc_params_t::init
adc_init_t init
Definition: app_adc.h:134
gr55xx_hal.h
This file contains all the functions prototypes for the HAL module driver.
app_adc_deinit
uint16_t app_adc_deinit(void)
De-initialize the APP ADC DRIVER peripheral.
app_adc_pin_cfg_t::channel_n
app_adc_pin_t channel_n
Definition: app_adc.h:114
app_adc_get_handle
adc_handle_t * app_adc_get_handle(void)
Return the ADC handle.
app_io_mux_t
app_io_mux_t
GPIO mux Enumerations definition.
Definition: app_io.h:198
app_adc_conversion_async
uint16_t app_adc_conversion_async(uint16_t *p_data, uint32_t length)
DMA for conversion.
app_adc_pin_cfg_t::channel_p
app_adc_pin_t channel_p
Definition: app_adc.h:113
APP_ADC_TYPE_DMA
@ APP_ADC_TYPE_DMA
Definition: app_adc.h:78
app_rtos_cfg.h
Header file of app rtos config code.
app_drv_error.h
Header file of app driver error code.
app_adc_pin_cfg_t
ADC pins config Structures.
Definition: app_adc.h:112
dma_channel_t
dma_channel_t
HAL DMA Channel Enumerations definition.
Definition: gr55xx_hal_dma.h:93
app_adc_pin_t
ADC pins Structures.
Definition: app_adc.h:101
app_adc_init
uint16_t app_adc_init(app_adc_params_t *p_params, app_adc_evt_handler_t evt_handler)
Initialize the APP ADC DRIVER according to the specified parameters in the app_adc_params_t and app_a...