ChibiOS/HAL  7.0.3
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 /*===========================================================================*/
112 /* External declarations. */
113 /*===========================================================================*/
114 
115 #if (PLATFORM_DAC_USE_DAC1 == TRUE) && !defined(__DOXYGEN__)
116 extern DACDriver DACD1;
117 #endif
118 
119 #ifdef __cplusplus
120 extern "C" {
121 #endif
122  void dac_lld_init(void);
123  void dac_lld_start(DACDriver *dacp);
124  void dac_lld_stop(DACDriver *dacp);
125  void dac_lld_put_channel(DACDriver *dacp,
126  dacchannel_t channel,
127  dacsample_t sample);
130 #ifdef __cplusplus
131 }
132 #endif
133 
134 #endif /* HAL_USE_DAC == TRUE */
135 
136 #endif /* HAL_DAC_LLD_H */
137 
138 /** @} */
uint32_t dacchannel_t
Type of a DAC channel index.
Definition: hal_dac_lld.h:68
DACDriver DACD1
DAC1 driver identifier.
Definition: hal_dac_lld.c:39
void dac_lld_start(DACDriver *dacp)
Configures and activates the DAC peripheral.
Definition: hal_dac_lld.c:77
Structure representing a DAC driver.
Definition: hal_dac.h:145
void dac_lld_stop(DACDriver *dacp)
Deactivates the DAC peripheral.
Definition: hal_dac_lld.c:98
void dac_lld_init(void)
Low level DAC driver initialization.
Definition: hal_dac_lld.c:63
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
void dac_lld_start_conversion(DACDriver *dacp)
Starts a DAC conversion.
Definition: hal_dac_lld.c:145
dacerror_t
Possible DAC failure causes.
Definition: hal_dac_lld.h:80
uint16_t dacsample_t
Type representing a DAC sample.
Definition: hal_dac_lld.h:73
void dac_lld_stop_conversion(DACDriver *dacp)
Stops an ongoing conversion.
Definition: hal_dac_lld.c:160