diff options
Diffstat (limited to 'lib/chibios/os/hal/templates/hal_dac_lld.c')
-rw-r--r-- | lib/chibios/os/hal/templates/hal_dac_lld.c | 167 |
1 files changed, 167 insertions, 0 deletions
diff --git a/lib/chibios/os/hal/templates/hal_dac_lld.c b/lib/chibios/os/hal/templates/hal_dac_lld.c new file mode 100644 index 000000000..13f325b56 --- /dev/null +++ b/lib/chibios/os/hal/templates/hal_dac_lld.c | |||
@@ -0,0 +1,167 @@ | |||
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.c | ||
19 | * @brief PLATFORM DAC subsystem low level driver source. | ||
20 | * | ||
21 | * @addtogroup DAC | ||
22 | * @{ | ||
23 | */ | ||
24 | |||
25 | #include "hal.h" | ||
26 | |||
27 | #if (HAL_USE_DAC == TRUE) || defined(__DOXYGEN__) | ||
28 | |||
29 | /*===========================================================================*/ | ||
30 | /* Driver local definitions. */ | ||
31 | /*===========================================================================*/ | ||
32 | |||
33 | /*===========================================================================*/ | ||
34 | /* Driver exported variables. */ | ||
35 | /*===========================================================================*/ | ||
36 | |||
37 | /** @brief DAC1 driver identifier.*/ | ||
38 | #if (PLATFORM_DAC_USE_DAC1 == TRUE) || defined(__DOXYGEN__) | ||
39 | DACDriver DACD1; | ||
40 | #endif | ||
41 | |||
42 | /*===========================================================================*/ | ||
43 | /* Driver local variables. */ | ||
44 | /*===========================================================================*/ | ||
45 | |||
46 | /*===========================================================================*/ | ||
47 | /* Driver local functions. */ | ||
48 | /*===========================================================================*/ | ||
49 | |||
50 | /*===========================================================================*/ | ||
51 | /* Driver interrupt handlers. */ | ||
52 | /*===========================================================================*/ | ||
53 | |||
54 | /*===========================================================================*/ | ||
55 | /* Driver exported functions. */ | ||
56 | /*===========================================================================*/ | ||
57 | |||
58 | /** | ||
59 | * @brief Low level DAC driver initialization. | ||
60 | * | ||
61 | * @notapi | ||
62 | */ | ||
63 | void dac_lld_init(void) { | ||
64 | |||
65 | #if PLATFORM_DAC_USE_DAC1 == TRUE | ||
66 | dacObjectInit(&DACD1); | ||
67 | #endif | ||
68 | } | ||
69 | |||
70 | /** | ||
71 | * @brief Configures and activates the DAC peripheral. | ||
72 | * | ||
73 | * @param[in] dacp pointer to the @p DACDriver object | ||
74 | * | ||
75 | * @notapi | ||
76 | */ | ||
77 | void dac_lld_start(DACDriver *dacp) { | ||
78 | |||
79 | /* If the driver is in DAC_STOP state then a full initialization is | ||
80 | required.*/ | ||
81 | if (dacp->state == DAC_STOP) { | ||
82 | /* Enabling the clock source.*/ | ||
83 | #if PLATFORM_DAC_USE_DAC1 == TRUE | ||
84 | if (&DACD1 == dacp) { | ||
85 | |||
86 | } | ||
87 | #endif | ||
88 | } | ||
89 | } | ||
90 | |||
91 | /** | ||
92 | * @brief Deactivates the DAC peripheral. | ||
93 | * | ||
94 | * @param[in] dacp pointer to the @p DACDriver object | ||
95 | * | ||
96 | * @notapi | ||
97 | */ | ||
98 | void dac_lld_stop(DACDriver *dacp) { | ||
99 | |||
100 | /* If in ready state then disables the DAC clock.*/ | ||
101 | if (dacp->state == DAC_READY) { | ||
102 | |||
103 | #if PLATFORM_DAC_USE_DAC1 == TRUE | ||
104 | if (&DACD1 == dacp) { | ||
105 | |||
106 | } | ||
107 | #endif | ||
108 | } | ||
109 | } | ||
110 | |||
111 | /** | ||
112 | * @brief Outputs a value directly on a DAC channel. | ||
113 | * | ||
114 | * @param[in] dacp pointer to the @p DACDriver object | ||
115 | * @param[in] channel DAC channel number | ||
116 | * @param[in] sample value to be output | ||
117 | * | ||
118 | * @api | ||
119 | */ | ||
120 | void dac_lld_put_channel(DACDriver *dacp, | ||
121 | dacchannel_t channel, | ||
122 | dacsample_t sample) { | ||
123 | |||
124 | (void)dacp; | ||
125 | (void)channel; | ||
126 | (void)sample; | ||
127 | } | ||
128 | |||
129 | /** | ||
130 | * @brief Starts a DAC conversion. | ||
131 | * @details Starts an asynchronous conversion operation. | ||
132 | * @note In @p DAC_DHRM_8BIT_RIGHT mode the parameters passed to the | ||
133 | * callback are wrong because two samples are packed in a single | ||
134 | * dacsample_t element. This will not be corrected, do not rely | ||
135 | * on those parameters. | ||
136 | * @note In @p DAC_DHRM_8BIT_RIGHT_DUAL mode two samples are treated | ||
137 | * as a single 16 bits sample and packed into a single dacsample_t | ||
138 | * element. The num_channels must be set to one in the group | ||
139 | * conversion configuration structure. | ||
140 | * | ||
141 | * @param[in] dacp pointer to the @p DACDriver object | ||
142 | * | ||
143 | * @notapi | ||
144 | */ | ||
145 | void dac_lld_start_conversion(DACDriver *dacp) { | ||
146 | |||
147 | (void)dacp; | ||
148 | } | ||
149 | |||
150 | /** | ||
151 | * @brief Stops an ongoing conversion. | ||
152 | * @details This function stops the currently ongoing conversion and returns | ||
153 | * the driver in the @p DAC_READY state. If there was no conversion | ||
154 | * being processed then the function does nothing. | ||
155 | * | ||
156 | * @param[in] dacp pointer to the @p DACDriver object | ||
157 | * | ||
158 | * @iclass | ||
159 | */ | ||
160 | void dac_lld_stop_conversion(DACDriver *dacp) { | ||
161 | |||
162 | (void)dacp; | ||
163 | } | ||
164 | |||
165 | #endif /* HAL_USE_DAC == TRUE */ | ||
166 | |||
167 | /** @} */ | ||