ChibiOS/HAL 9.0.0
hal_adc_lld.h
Go to the documentation of this file.
1/*
2 ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15*/
16
17/**
18 * @file hal_adc_lld.h
19 * @brief PLATFORM ADC subsystem low level driver header.
20 *
21 * @addtogroup ADC
22 * @{
23 */
24
25#ifndef HAL_ADC_LLD_H
26#define HAL_ADC_LLD_H
27
28#if (HAL_USE_ADC == TRUE) || defined(__DOXYGEN__)
29
30/*===========================================================================*/
31/* Driver constants. */
32/*===========================================================================*/
33
34/**
35 * @name Possible ADC errors mask bits.
36 * @{
37 */
38#define ADC_ERR_DMAFAILURE 1U /**< DMA operations failure. */
39#define ADC_ERR_OVERFLOW 2U /**< ADC overflow condition. */
40#define ADC_ERR_AWD 4U /**< Watchdog triggered. */
41/** @} */
42
43/*===========================================================================*/
44/* Driver pre-compile time settings. */
45/*===========================================================================*/
46
47/**
48 * @name PLATFORM configuration options
49 * @{
50 */
51/**
52 * @brief ADC1 driver enable switch.
53 * @details If set to @p TRUE the support for ADC1 is included.
54 * @note The default is @p FALSE.
55 */
56#if !defined(PLATFORM_ADC_USE_ADC1) || defined(__DOXYGEN__)
57#define PLATFORM_ADC_USE_ADC1 FALSE
58#endif
59/** @} */
60
61/*===========================================================================*/
62/* Derived constants and error checks. */
63/*===========================================================================*/
64
65/*===========================================================================*/
66/* Driver data structures and types. */
67/*===========================================================================*/
68
69/**
70 * @brief ADC sample data type.
71 */
72typedef uint16_t adcsample_t;
73
74/**
75 * @brief Channels number in a conversion group.
76 */
77typedef uint16_t adc_channels_num_t;
78
79/**
80 * @brief Type of an ADC error mask.
81 */
82typedef uint32_t adcerror_t;
83
84/*===========================================================================*/
85/* Driver macros. */
86/*===========================================================================*/
87
88/**
89 * @brief Low level fields of the ADC driver structure.
90 */
91#define adc_lld_driver_fields \
92 /* Dummy field, it is not needed.*/ \
93 uint32_t dummy;
94
95/**
96 * @brief Low level fields of the ADC configuration structure.
97 */
98#define adc_lld_config_fields \
99 /* Dummy configuration, it is not needed.*/ \
100 uint32_t dummy;
101
102/**
103 * @brief Low level fields of the ADC configuration structure.
104 */
105#define adc_lld_configuration_group_fields \
106 /* Dummy configuration, it is not needed.*/ \
107 uint32_t dummy;
108
109/*===========================================================================*/
110/* External declarations. */
111/*===========================================================================*/
112
113#if (PLATFORM_ADC_USE_ADC1 == TRUE) && !defined(__DOXYGEN__)
114extern ADCDriver ADCD1;
115#endif
116
117#ifdef __cplusplus
118extern "C" {
119#endif
120 void adc_lld_init(void);
121 void adc_lld_start(ADCDriver *adcp);
122 void adc_lld_stop(ADCDriver *adcp);
125#ifdef __cplusplus
126}
127#endif
128
129#endif /* HAL_USE_ADC == TRUE */
130
131#endif /* HAL_ADC_LLD_H */
132
133/** @} */
uint32_t adcerror_t
Type of an ADC error mask.
Definition hal_adc_lld.h:82
void adc_lld_stop_conversion(ADCDriver *adcp)
Stops an ongoing conversion.
struct hal_adc_driver ADCDriver
Type of a structure representing an ADC driver.
Definition hal_adc.h:82
void adc_lld_init(void)
Low level ADC driver initialization.
Definition hal_adc_lld.c:65
void adc_lld_start_conversion(ADCDriver *adcp)
Starts an ADC conversion.
void adc_lld_stop(ADCDriver *adcp)
Deactivates the ADC peripheral.
uint16_t adc_channels_num_t
Channels number in a conversion group.
Definition hal_adc_lld.h:77
void adc_lld_start(ADCDriver *adcp)
Configures and activates the ADC peripheral.
Definition hal_adc_lld.c:80
uint16_t adcsample_t
ADC sample data type.
Definition hal_adc_lld.h:72
ADCDriver ADCD1
ADC1 driver identifier.
Definition hal_adc_lld.c:41