ChibiOS  21.6.0
hal_dac_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_dac_lld.h
19  * @brief PLATFORM DAC subsystem low level driver header.
20  *
21  * @addtogroup DAC
22  * @{
23  */
24 
25 #ifndef HAL_DAC_LLD_H
26 #define HAL_DAC_LLD_H
27 
28 #if (HAL_USE_DAC == TRUE) || defined(__DOXYGEN__)
29 
30 /*===========================================================================*/
31 /* Driver constants. */
32 /*===========================================================================*/
33 
34 /**
35  * @brief Maximum number of DAC channels per unit.
36  */
37 #define DAC_MAX_CHANNELS 2
38 
39 /*===========================================================================*/
40 /* Driver pre-compile time settings. */
41 /*===========================================================================*/
42 
43 /**
44  * @name Configuration options
45  * @{
46  */
47 /**
48  * @brief DAC1 CH1 driver enable switch.
49  * @details If set to @p TRUE the support for DAC1 channel 1 is included.
50  * @note The default is @p FALSE.
51  */
52 #if !defined(PLATFORM_DAC_USE_DAC1) || defined(__DOXYGEN__)
53 #define PLATFORM_DAC_USE_DAC1 FALSE
54 #endif
55 /** @} */
56 
57 /*===========================================================================*/
58 /* Derived constants and error checks. */
59 /*===========================================================================*/
60 
61 /*===========================================================================*/
62 /* Driver data structures and types. */
63 /*===========================================================================*/
64 
65 /**
66  * @brief Type of a DAC channel index.
67  */
68 typedef uint32_t dacchannel_t;
69 
70 /**
71  * @brief Type representing a DAC sample.
72  */
73 typedef uint16_t dacsample_t;
74 
75 /**
76  * @brief Possible DAC failure causes.
77  * @note Error codes are architecture dependent and should not relied
78  * upon.
79  */
80 typedef enum {
81  DAC_ERR_DMAFAILURE = 0, /**< DMA operations failure. */
82  DAC_ERR_UNDERFLOW = 1 /**< DAC overflow condition. */
83 } dacerror_t;
84 
85 /*===========================================================================*/
86 /* Driver macros. */
87 /*===========================================================================*/
88 
89 /**
90  * @brief Low level fields of the DAC driver structure.
91  */
92 #define dac_lld_driver_fields \
93  /* Dummy field, it is not needed.*/ \
94  uint32_t dummy
95 
96 /**
97  * @brief Low level fields of the DAC configuration structure.
98  */
99 #define dac_lld_config_fields \
100  /* Dummy configuration, it is not needed.*/ \
101  uint32_t dummy
102 
103 /**
104  * @brief Low level fields of the DAC group configuration structure.
105  */
106 #define dac_lld_conversion_group_fields \
107  /* Dummy configuration, it is not needed.*/ \
108  uint32_t dummy
109 
110 /*===========================================================================*/
111 /* External declarations. */
112 /*===========================================================================*/
113 
114 #if (PLATFORM_DAC_USE_DAC1 == TRUE) && !defined(__DOXYGEN__)
115 extern DACDriver DACD1;
116 #endif
117 
118 #ifdef __cplusplus
119 extern "C" {
120 #endif
121  void dac_lld_init(void);
122  void dac_lld_start(DACDriver *dacp);
123  void dac_lld_stop(DACDriver *dacp);
124  void dac_lld_put_channel(DACDriver *dacp,
125  dacchannel_t channel,
126  dacsample_t sample);
129 #ifdef __cplusplus
130 }
131 #endif
132 
133 #endif /* HAL_USE_DAC == TRUE */
134 
135 #endif /* HAL_DAC_LLD_H */
136 
137 /** @} */
DAC_ERR_UNDERFLOW
@ DAC_ERR_UNDERFLOW
Definition: hal_dac_lld.h:82
dac_lld_put_channel
void dac_lld_put_channel(DACDriver *dacp, dacchannel_t channel, dacsample_t sample)
Outputs a value directly on a DAC channel.
Definition: hal_dac_lld.c:120
dacchannel_t
uint32_t dacchannel_t
Type of a DAC channel index.
Definition: hal_dac_lld.h:68
dac_lld_start
void dac_lld_start(DACDriver *dacp)
Configures and activates the DAC peripheral.
Definition: hal_dac_lld.c:77
DACD1
DACDriver DACD1
DAC1 driver identifier.
Definition: hal_dac_lld.c:39
DAC_ERR_DMAFAILURE
@ DAC_ERR_DMAFAILURE
Definition: hal_dac_lld.h:81
dac_lld_init
void dac_lld_init(void)
Low level DAC driver initialization.
Definition: hal_dac_lld.c:63
dac_lld_stop
void dac_lld_stop(DACDriver *dacp)
Deactivates the DAC peripheral.
Definition: hal_dac_lld.c:98
dac_lld_start_conversion
void dac_lld_start_conversion(DACDriver *dacp)
Starts a DAC conversion.
Definition: hal_dac_lld.c:145
dacerror_t
dacerror_t
Possible DAC failure causes.
Definition: hal_dac_lld.h:80
hal_dac_driver
Structure representing a DAC driver.
Definition: hal_dac.h:145
dacsample_t
uint16_t dacsample_t
Type representing a DAC sample.
Definition: hal_dac_lld.h:73
dac_lld_stop_conversion
void dac_lld_stop_conversion(DACDriver *dacp)
Stops an ongoing conversion.
Definition: hal_dac_lld.c:160