diff options
Diffstat (limited to 'lib/chibios/os/hal/ports/ADUCM/ADUCM36x/hal_lld.h')
-rw-r--r-- | lib/chibios/os/hal/ports/ADUCM/ADUCM36x/hal_lld.h | 491 |
1 files changed, 491 insertions, 0 deletions
diff --git a/lib/chibios/os/hal/ports/ADUCM/ADUCM36x/hal_lld.h b/lib/chibios/os/hal/ports/ADUCM/ADUCM36x/hal_lld.h new file mode 100644 index 000000000..6572f0ede --- /dev/null +++ b/lib/chibios/os/hal/ports/ADUCM/ADUCM36x/hal_lld.h | |||
@@ -0,0 +1,491 @@ | |||
1 | /* | ||
2 | ChibiOS - Copyright (C) 2019 Rocco Marco Guglielmi | ||
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 ADUCM36x/hal_lld.h | ||
19 | * @brief ADUCM36x HAL subsystem low level driver header. | ||
20 | * @pre This module requires the following macros to be defined in the | ||
21 | * @p board.h file: | ||
22 | * - ADUCM_LFXTAL. | ||
23 | * . | ||
24 | * One of the following macros must also be defined: | ||
25 | * - ADUCM360, ADUCM361. | ||
26 | * . | ||
27 | * | ||
28 | * @addtogroup HAL | ||
29 | * @{ | ||
30 | */ | ||
31 | |||
32 | #ifndef HAL_LLD_H | ||
33 | #define HAL_LLD_H | ||
34 | |||
35 | /*===========================================================================*/ | ||
36 | /* Driver constants. */ | ||
37 | /*===========================================================================*/ | ||
38 | |||
39 | /** | ||
40 | * @name Platform identification macros | ||
41 | * @{ | ||
42 | */ | ||
43 | #if defined(ADUCM360) || defined(__DOXYGEN__) | ||
44 | #define PLATFORM_NAME "ADUCM360 Precision Analog MCU with Dual 24-bit ADC" | ||
45 | |||
46 | #elif defined(ADUCM361) | ||
47 | #define PLATFORM_NAME "ADUCM361 Precision Analog MCU with Single 24-bit ADC" | ||
48 | |||
49 | #else | ||
50 | #error "ADUCM36x device unsupported or not specified" | ||
51 | #endif | ||
52 | /** @} */ | ||
53 | |||
54 | /** | ||
55 | * @name Absolute Maximum Ratings | ||
56 | * @{ | ||
57 | */ | ||
58 | /** | ||
59 | * @brief Maximum External Low Frequency crystal clock frequency. | ||
60 | */ | ||
61 | #define ADUCM_LFXTAL_MAX 32768 | ||
62 | /** @} */ | ||
63 | |||
64 | /** | ||
65 | * @name Internal clock sources | ||
66 | * @{ | ||
67 | */ | ||
68 | #define ADUCM_HFOSC 16000000 /**< High speed internal clock. */ | ||
69 | #define ADUCM_LFOSC 32768 /**< Low speed internal clock. */ | ||
70 | /** @} */ | ||
71 | |||
72 | /** | ||
73 | * @name CLKCON0 register bits definitions | ||
74 | * @{ | ||
75 | */ | ||
76 | #define ADUCM_CD_DIV1 (0 << 0) /**< Clock divided by 1. */ | ||
77 | #define ADUCM_CD_DIV2 (1 << 0) /**< Clock divided by 2. */ | ||
78 | #define ADUCM_CD_DIV4 (2 << 0) /**< Clock divided by 4. */ | ||
79 | #define ADUCM_CD_DIV8 (3 << 0) /**< Clock divided by 8. */ | ||
80 | #define ADUCM_CD_DIV16 (4 << 0) /**< Clock divided by 16. */ | ||
81 | #define ADUCM_CD_DIV32 (5 << 0) /**< Clock divided by 32. */ | ||
82 | #define ADUCM_CD_DIV64 (6 << 0) /**< Clock divided by 64. */ | ||
83 | #define ADUCM_CD_DIV128 (7 << 0) /**< Clock divided by 128. */ | ||
84 | |||
85 | #define ADUCM_CLKMUX_HFOSC (0 << 3) /**< Clock source is HFOSC. */ | ||
86 | #define ADUCM_CLKMUX_LFXTAL (1 << 3) /**< Clock source is LFXTAL. */ | ||
87 | #define ADUCM_CLKMUX_LFOSC (2 << 3) /**< Clock source is LFOSC. */ | ||
88 | #define ADUCM_CLKMUX_EXTCLK (3 << 3) /**< Clock source is EXTCLK. */ | ||
89 | /** @} */ | ||
90 | |||
91 | /** | ||
92 | * @name CLKCON1 register bits definitions | ||
93 | * @{ | ||
94 | */ | ||
95 | #define ADUCM_SPI0CD_DIV1 (0 << 0) /**< SPI0 Clock divided by 1. */ | ||
96 | #define ADUCM_SPI0CD_DIV2 (1 << 0) /**< SPI0 Clock divided by 2. */ | ||
97 | #define ADUCM_SPI0CD_DIV4 (2 << 0) /**< SPI0 Clock divided by 4. */ | ||
98 | #define ADUCM_SPI0CD_DIV8 (3 << 0) /**< SPI0 Clock divided by 8. */ | ||
99 | #define ADUCM_SPI0CD_DIV16 (4 << 0) /**< SPI0 Clock divided by 16. */ | ||
100 | #define ADUCM_SPI0CD_DIV32 (5 << 0) /**< SPI0 Clock divided by 32. */ | ||
101 | #define ADUCM_SPI0CD_DIV64 (6 << 0) /**< SPI0 Clock divided by 64. */ | ||
102 | #define ADUCM_SPI0CD_DIV128 (7 << 0) /**< SPI0 Clock divided by 128. */ | ||
103 | |||
104 | #define ADUCM_SPI1CD_DIV1 (0 << 3) /**< SPI1 Clock divided by 1. */ | ||
105 | #define ADUCM_SPI1CD_DIV2 (1 << 3) /**< SPI1 Clock divided by 2. */ | ||
106 | #define ADUCM_SPI1CD_DIV4 (2 << 3) /**< SPI1 Clock divided by 4. */ | ||
107 | #define ADUCM_SPI1CD_DIV8 (3 << 3) /**< SPI1 Clock divided by 8. */ | ||
108 | #define ADUCM_SPI1CD_DIV16 (4 << 3) /**< SPI1 Clock divided by 16. */ | ||
109 | #define ADUCM_SPI1CD_DIV32 (5 << 3) /**< SPI1 Clock divided by 32. */ | ||
110 | #define ADUCM_SPI1CD_DIV64 (6 << 3) /**< SPI1 Clock divided by 64. */ | ||
111 | #define ADUCM_SPI1CD_DIV128 (7 << 3) /**< SPI1 Clock divided by 128. */ | ||
112 | |||
113 | #define ADUCM_I2CCD_DIV1 (0 << 6) /**< I2C Clock divided by 1. */ | ||
114 | #define ADUCM_I2CCD_DIV2 (1 << 6) /**< I2C Clock divided by 2. */ | ||
115 | #define ADUCM_I2CCD_DIV4 (2 << 6) /**< I2C Clock divided by 4. */ | ||
116 | #define ADUCM_I2CCD_DIV8 (3 << 6) /**< I2C Clock divided by 8. */ | ||
117 | #define ADUCM_I2CCD_DIV16 (4 << 6) /**< I2C Clock divided by 16. */ | ||
118 | #define ADUCM_I2CCD_DIV32 (5 << 6) /**< I2C Clock divided by 32. */ | ||
119 | #define ADUCM_I2CCD_DIV64 (6 << 6) /**< I2C Clock divided by 64. */ | ||
120 | #define ADUCM_I2CCD_DIV128 (7 << 6) /**< I2C Clock divided by 128. */ | ||
121 | |||
122 | #define ADUCM_UARTCD_DIV1 (0 << 9) /**< UART Clock divided by 1. */ | ||
123 | #define ADUCM_UARTCD_DIV2 (1 << 9) /**< UART Clock divided by 2. */ | ||
124 | #define ADUCM_UARTCD_DIV4 (2 << 9) /**< UART Clock divided by 4. */ | ||
125 | #define ADUCM_UARTCD_DIV8 (3 << 9) /**< UART Clock divided by 8. */ | ||
126 | #define ADUCM_UARTCD_DIV16 (4 << 9) /**< UART Clock divided by 16. */ | ||
127 | #define ADUCM_UARTCD_DIV32 (5 << 9) /**< UART Clock divided by 32. */ | ||
128 | #define ADUCM_UARTCD_DIV64 (6 << 9) /**< UART Clock divided by 64. */ | ||
129 | #define ADUCM_UARTCD_DIV128 (7 << 9) /**< UART Clock divided by 128. */ | ||
130 | |||
131 | #define ADUCM_PWMCD_DIV1 (0 << 12) /**< PWM Clock divided by 1. */ | ||
132 | #define ADUCM_PWMCD_DIV2 (1 << 12) /**< PWM Clock divided by 2. */ | ||
133 | #define ADUCM_PWMCD_DIV4 (2 << 12) /**< PWM Clock divided by 4. */ | ||
134 | #define ADUCM_PWMCD_DIV8 (3 << 12) /**< PWM Clock divided by 8. */ | ||
135 | #define ADUCM_PWMCD_DIV16 (4 << 12) /**< PWM Clock divided by 16. */ | ||
136 | #define ADUCM_PWMCD_DIV32 (5 << 12) /**< PWM Clock divided by 32. */ | ||
137 | #define ADUCM_PWMCD_DIV64 (6 << 12) /**< PWM Clock divided by 64. */ | ||
138 | #define ADUCM_PWMCD_DIV128 (7 << 12) /**< PWM Clock divided by 128. */ | ||
139 | /** @} */ | ||
140 | |||
141 | /** | ||
142 | * @name XOSCOCN register bits definitions | ||
143 | * @{ | ||
144 | */ | ||
145 | #define ADUCM_XOSC_DISABLE (0 << 0) /**< EXTOSC disabled. */ | ||
146 | #define ADUCM_XOSC_ENABLE (1 << 0) /**< EXTOSC enabled. */ | ||
147 | |||
148 | #define ADUCM_XOSC_DIV1 (0 << 2) /**< EXTOSC Clock divided by 1. */ | ||
149 | #define ADUCM_XOSC_DIV2 (1 << 2) /**< EXTOSC Clock divided by 2. */ | ||
150 | /** @} */ | ||
151 | |||
152 | /** | ||
153 | * @name CLKSYSDIV register bits definitions | ||
154 | * @{ | ||
155 | */ | ||
156 | #define ADUCM_HFOSC_DIV1 (0 << 0) /**< HFOSC Clock divided by 1. */ | ||
157 | #define ADUCM_HFOSC_DIV2 (1 << 0) /**< HFOSC Clock divided by 2. */ | ||
158 | /** @} */ | ||
159 | |||
160 | /*===========================================================================*/ | ||
161 | /* Driver pre-compile time settings. */ | ||
162 | /*===========================================================================*/ | ||
163 | |||
164 | /** | ||
165 | * @name Configuration options | ||
166 | * @{ | ||
167 | */ | ||
168 | /** | ||
169 | * @brief Disables the CA initialization in the HAL. | ||
170 | */ | ||
171 | #if !defined(ADUCM_NO_INIT) || defined(__DOXYGEN__) | ||
172 | #define ADUCM_NO_INIT FALSE | ||
173 | #endif | ||
174 | |||
175 | /** | ||
176 | * @brief Enables or disables the XOSC clock source. | ||
177 | */ | ||
178 | #if !defined(ADUCM_XOSC_ENABLED) || defined(__DOXYGEN__) | ||
179 | #define ADUCM_XOSC_ENABLED FALSE | ||
180 | #endif | ||
181 | |||
182 | /** | ||
183 | * @brief Main clock source selection. | ||
184 | */ | ||
185 | #if !defined(ADUCM_CLKMUX) || defined(__DOXYGEN__) | ||
186 | #define ADUCM_CLKMUX ADUCM_CLKMUX_HFOSC | ||
187 | #endif | ||
188 | |||
189 | /** | ||
190 | * @brief Internal High Speed oscillator clock source pre-divider. | ||
191 | * @note This setting has only effect if the HFOSC is selected as the | ||
192 | * system clock source. | ||
193 | */ | ||
194 | #if !defined(ADUCM_HFOSC_PREDIV) || defined(__DOXYGEN__) | ||
195 | #define ADUCM_HFOSC_PREDIV ADUCM_HFOSC_DIV1 | ||
196 | #endif | ||
197 | |||
198 | /** | ||
199 | * @brief External oscillator clock source pre-divider. | ||
200 | * @note This setting has only effect if the LFXTAL is selected as the | ||
201 | * system clock source. | ||
202 | */ | ||
203 | #if !defined(ADUCM_XOSC_PREDIV) || defined(__DOXYGEN__) | ||
204 | #define ADUCM_XOSC_PREDIV ADUCM_XOSC_DIV1 | ||
205 | #endif | ||
206 | |||
207 | /** | ||
208 | * @brief Main clock divider. | ||
209 | */ | ||
210 | #if !defined(ADUCM_CD_DIV) || defined(__DOXYGEN__) | ||
211 | #define ADUCM_CD_DIV ADUCM_CD_DIV1 | ||
212 | #endif | ||
213 | /** @} */ | ||
214 | |||
215 | /** | ||
216 | * @brief SPI0 clock divider. | ||
217 | */ | ||
218 | #if !defined(ADUCM_SPI0CD_DIV) || defined(__DOXYGEN__) | ||
219 | #define ADUCM_SPI0CD_DIV ADUCM_SPI0CD_DIV1 | ||
220 | #endif | ||
221 | /** @} */ | ||
222 | |||
223 | /** | ||
224 | * @brief SPI1 clock divider. | ||
225 | */ | ||
226 | #if !defined(ADUCM_SPI1CD_DIV) || defined(__DOXYGEN__) | ||
227 | #define ADUCM_SPI1CD_DIV ADUCM_SPI1CD_DIV1 | ||
228 | #endif | ||
229 | /** @} */ | ||
230 | |||
231 | /** | ||
232 | * @brief I2C clock divider. | ||
233 | */ | ||
234 | #if !defined(ADUCM_I2CCD_DIV) || defined(__DOXYGEN__) | ||
235 | #define ADUCM_I2CCD_DIV ADUCM_I2CCD_DIV1 | ||
236 | #endif | ||
237 | /** @} */ | ||
238 | |||
239 | /** | ||
240 | * @brief UART clock divider. | ||
241 | */ | ||
242 | #if !defined(ADUCM_UARTCD_DIV) || defined(__DOXYGEN__) | ||
243 | #define ADUCM_UARTCD_DIV ADUCM_UARTCD_DIV1 | ||
244 | #endif | ||
245 | /** @} */ | ||
246 | |||
247 | /** | ||
248 | * @brief PWM clock divider. | ||
249 | */ | ||
250 | #if !defined(ADUCM_PWMCD_DIV) || defined(__DOXYGEN__) | ||
251 | #define ADUCM_PWMCD_DIV ADUCM_PWMCD_DIV1 | ||
252 | #endif | ||
253 | /** @} */ | ||
254 | |||
255 | /*===========================================================================*/ | ||
256 | /* Derived constants and error checks. */ | ||
257 | /*===========================================================================*/ | ||
258 | |||
259 | /* | ||
260 | * Configuration-related checks. | ||
261 | */ | ||
262 | #if !defined(ADUCM36x_MCUCONF) | ||
263 | #error "Using a wrong mcuconf.h file, ADUCM36x_MCUCONF not defined" | ||
264 | #endif | ||
265 | |||
266 | /* | ||
267 | * LFXTAL related checks. | ||
268 | */ | ||
269 | #if ADUCM_CLKMUX == ADUCM_CLKMUX_LFXTAL | ||
270 | #define ADUCM_XOSC_REQUIRED TRUE | ||
271 | #if (ADUCM_XOSC_ENABLED == FALSE) | ||
272 | #error "LFXTAL not enabled, required by ADUCM_CLKMUX" | ||
273 | #endif | ||
274 | #if (ADUCM_LFXTAL != ADUCM_LFXTAL_MAX) | ||
275 | #error "LFXTAL wrong frequency or not defined" | ||
276 | #endif | ||
277 | #else | ||
278 | #define ADUCM_XOSC_REQUIRED FALSE | ||
279 | #endif | ||
280 | |||
281 | /** | ||
282 | * @brief UCLK source. | ||
283 | */ | ||
284 | #if (ADUCM_CLKMUX == ADUCM_CLKMUX_HFOSC) || defined(__DOXYGEN__) | ||
285 | #if (ADUCM_HFOSC_PREDIV == ADUCM_HFOSC_DIV1) || defined(__DOXYGEN__) | ||
286 | #define ADUCM_UCLK (ADUCM_HFOSC / 1) | ||
287 | #elif (ADUCM_HFOSC_PREDIV == ADUCM_HFOSC_DIV1) | ||
288 | #define ADUCM_UCLK (ADUCM_HFOSC / 2) | ||
289 | #else | ||
290 | #error "wrong HFOSC divider" | ||
291 | #endif | ||
292 | #elif ADUCM_CLKMUX == ADUCM_CLKMUX_LFXTAL | ||
293 | #if (ADUCM_XOSC_PREDIV == ADUCM_XOSC_DIV1) | ||
294 | #define ADUCM_UCLK (ADUCM_LFXTAL / 1) | ||
295 | #elif (ADUCM_XOSC_PREDIV == ADUCM_XOSC_DIV1) | ||
296 | #define ADUCM_UCLK (ADUCM_LFXTAL / 2) | ||
297 | #else | ||
298 | #error "wrong XOSC divider" | ||
299 | #endif | ||
300 | #elif ADUCM_CLKMUX == ADUCM_CLKMUX_LFOSC | ||
301 | #define ADUCM_UCLK (ADUCM_LFOSC / 1) | ||
302 | #elif ADUCM_CLKMUX == ADUCM_CLKMUX_EXTCLK | ||
303 | #error "external clock currently unsupported" | ||
304 | #else | ||
305 | #error "invalid ADUCM_CLKMUX value specified" | ||
306 | #endif | ||
307 | |||
308 | /** | ||
309 | * @brief FCLK, HCLK, PCLK frequency. | ||
310 | */ | ||
311 | #if (ADUCM_CD_DIV == ADUCM_CD_DIV1) || defined(__DOXYGEN__) | ||
312 | #define ADUCM_FCLK (ADUCM_UCLK / 1) | ||
313 | #define ADUCM_HCLK (ADUCM_UCLK / 1) | ||
314 | #define ADUCM_PCLK (ADUCM_UCLK / 1) | ||
315 | #elif ADUCM_CD_DIV == ADUCM_CD_DIV2 | ||
316 | #define ADUCM_FCLK (ADUCM_UCLK / 2) | ||
317 | #define ADUCM_HCLK (ADUCM_UCLK / 2) | ||
318 | #define ADUCM_PCLK (ADUCM_UCLK / 2) | ||
319 | #elif ADUCM_CD_DIV == ADUCM_CD_DIV4 | ||
320 | #define ADUCM_FCLK (ADUCM_UCLK / 4) | ||
321 | #define ADUCM_HCLK (ADUCM_UCLK / 4) | ||
322 | #define ADUCM_PCLK (ADUCM_UCLK / 4) | ||
323 | #elif ADUCM_CD_DIV == ADUCM_CD_DIV8 | ||
324 | #define ADUCM_FCLK (ADUCM_UCLK / 8) | ||
325 | #define ADUCM_HCLK (ADUCM_UCLK / 8) | ||
326 | #define ADUCM_PCLK (ADUCM_UCLK / 8) | ||
327 | #elif ADUCM_CD_DIV == ADUCM_CD_DIV16 | ||
328 | #define ADUCM_FCLK (ADUCM_UCLK / 16) | ||
329 | #define ADUCM_HCLK (ADUCM_UCLK / 16) | ||
330 | #define ADUCM_PCLK (ADUCM_UCLK / 16) | ||
331 | #elif ADUCM_CD_DIV == ADUCM_CD_DIV32 | ||
332 | #define ADUCM_FCLK (ADUCM_UCLK / 32) | ||
333 | #define ADUCM_HCLK (ADUCM_UCLK / 32) | ||
334 | #define ADUCM_PCLK (ADUCM_UCLK / 32) | ||
335 | #elif ADUCM_CD_DIV == ADUCM_CD_DIV64 | ||
336 | #define ADUCM_FCLK (ADUCM_UCLK / 64) | ||
337 | #define ADUCM_HCLK (ADUCM_UCLK / 64) | ||
338 | #define ADUCM_PCLK (ADUCM_UCLK / 64) | ||
339 | #elif ADUCM_CD_DIV == ADUCM_CD_DIV128 | ||
340 | #define ADUCM_FCLK (ADUCM_UCLK / 128) | ||
341 | #define ADUCM_HCLK (ADUCM_UCLK / 128) | ||
342 | #define ADUCM_PCLK (ADUCM_UCLK / 128) | ||
343 | #else | ||
344 | #error "invalid ADUCM_CD_DIV value specified" | ||
345 | #endif | ||
346 | |||
347 | /** | ||
348 | * @brief SPI0 frequency. | ||
349 | */ | ||
350 | #if (ADUCM_SPI0CD_DIV == ADUCM_SPI0CD_DIV1) || defined(__DOXYGEN__) | ||
351 | #define ADUCM_SPI0CLK (ADUCM_UCLK / 1) | ||
352 | #elif ADUCM_SPI0CD_DIV == ADUCM_SPI0CD_DIV2 | ||
353 | #define ADUCM_SPI0CLK (ADUCM_UCLK / 2) | ||
354 | #elif ADUCM_SPI0CD_DIV == ADUCM_SPI0CD_DIV4 | ||
355 | #define ADUCM_SPI0CLK (ADUCM_UCLK / 4) | ||
356 | #elif ADUCM_SPI0CD_DIV == ADUCM_SPI0CD_DIV8 | ||
357 | #define ADUCM_SPI0CLK (ADUCM_UCLK / 8) | ||
358 | #elif ADUCM_SPI0CD_DIV == ADUCM_SPI0CD_DIV16 | ||
359 | #define ADUCM_SPI0CLK (ADUCM_UCLK / 16) | ||
360 | #elif ADUCM_SPI0CD_DIV == ADUCM_SPI0CD_DIV32 | ||
361 | #define ADUCM_SPI0CLK (ADUCM_UCLK / 32) | ||
362 | #elif ADUCM_SPI0CD_DIV == ADUCM_SPI0CD_DIV64 | ||
363 | #define ADUCM_SPI0CLK (ADUCM_UCLK / 64) | ||
364 | #elif ADUCM_SPI0CD_DIV == ADUCM_SPI0CD_DIV128 | ||
365 | #define ADUCM_SPI0CLK (ADUCM_UCLK / 128) | ||
366 | #else | ||
367 | #error "invalid ADUCM_SPI0CD_DIV value specified" | ||
368 | #endif | ||
369 | |||
370 | /** | ||
371 | * @brief SPI1 frequency. | ||
372 | */ | ||
373 | #if (ADUCM_SPI1CD_DIV == ADUCM_SPI1CD_DIV1) || defined(__DOXYGEN__) | ||
374 | #define ADUCM_SPI1CLK (ADUCM_UCLK / 1) | ||
375 | #elif ADUCM_SPI1CD_DIV == ADUCM_SPI1CD_DIV2 | ||
376 | #define ADUCM_SPI1CLK (ADUCM_UCLK / 2) | ||
377 | #elif ADUCM_SPI1CD_DIV == ADUCM_SPI1CD_DIV4 | ||
378 | #define ADUCM_SPI1CLK (ADUCM_UCLK / 4) | ||
379 | #elif ADUCM_SPI1CD_DIV == ADUCM_SPI1CD_DIV8 | ||
380 | #define ADUCM_SPI1CLK (ADUCM_UCLK / 8) | ||
381 | #elif ADUCM_SPI1CD_DIV == ADUCM_SPI1CD_DIV16 | ||
382 | #define ADUCM_SPI1CLK (ADUCM_UCLK / 16) | ||
383 | #elif ADUCM_SPI1CD_DIV == ADUCM_SPI1CD_DIV32 | ||
384 | #define ADUCM_SPI1CLK (ADUCM_UCLK / 32) | ||
385 | #elif ADUCM_SPI1CD_DIV == ADUCM_SPI1CD_DIV64 | ||
386 | #define ADUCM_SPI1CLK (ADUCM_UCLK / 64) | ||
387 | #elif ADUCM_SPI1CD_DIV == ADUCM_SPI1CD_DIV128 | ||
388 | #define ADUCM_SPI1CLK (ADUCM_UCLK / 128) | ||
389 | #else | ||
390 | #error "invalid ADUCM_SPI1CD_DIV value specified" | ||
391 | #endif | ||
392 | |||
393 | /** | ||
394 | * @brief I2C frequency. | ||
395 | */ | ||
396 | #if (ADUCM_I2CCD_DIV == ADUCM_I2CCD_DIV1) || defined(__DOXYGEN__) | ||
397 | #define ADUCM_I2CCLK (ADUCM_UCLK / 1) | ||
398 | #elif ADUCM_I2CCD_DIV == ADUCM_I2CCD_DIV2 | ||
399 | #define ADUCM_I2CCLK (ADUCM_UCLK / 2) | ||
400 | #elif ADUCM_I2CCD_DIV == ADUCM_I2CCD_DIV4 | ||
401 | #define ADUCM_I2CCLK (ADUCM_UCLK / 4) | ||
402 | #elif ADUCM_I2CCD_DIV == ADUCM_I2CCD_DIV8 | ||
403 | #define ADUCM_I2CCLK (ADUCM_UCLK / 8) | ||
404 | #elif ADUCM_I2CCD_DIV == ADUCM_I2CCD_DIV16 | ||
405 | #define ADUCM_I2CCLK (ADUCM_UCLK / 16) | ||
406 | #elif ADUCM_I2CCD_DIV == ADUCM_I2CCD_DIV32 | ||
407 | #define ADUCM_I2CCLK (ADUCM_UCLK / 32) | ||
408 | #elif ADUCM_I2CCD_DIV == ADUCM_I2CCD_DIV64 | ||
409 | #define ADUCM_I2CCLK (ADUCM_UCLK / 64) | ||
410 | #elif ADUCM_I2CCD_DIV == ADUCM_I2CCD_DIV128 | ||
411 | #define ADUCM_I2CCLK (ADUCM_UCLK / 128) | ||
412 | #else | ||
413 | #error "invalid ADUCM_I2CCD_DIV value specified" | ||
414 | #endif | ||
415 | |||
416 | /** | ||
417 | * @brief UART frequency. | ||
418 | */ | ||
419 | #if (ADUCM_UARTCD_DIV == ADUCM_UARTCD_DIV1) || defined(__DOXYGEN__) | ||
420 | #define ADUCM_UARTCLK (ADUCM_UCLK / 1) | ||
421 | #elif ADUCM_UARTCD_DIV == ADUCM_UARTCD_DIV2 | ||
422 | #define ADUCM_UARTCLK (ADUCM_UCLK / 2) | ||
423 | #elif ADUCM_UARTCD_DIV == ADUCM_UARTCD_DIV4 | ||
424 | #define ADUCM_UARTCLK (ADUCM_UCLK / 4) | ||
425 | #elif ADUCM_UARTCD_DIV == ADUCM_UARTCD_DIV8 | ||
426 | #define ADUCM_UARTCLK (ADUCM_UCLK / 8) | ||
427 | #elif ADUCM_UARTCD_DIV == ADUCM_UARTCD_DIV16 | ||
428 | #define ADUCM_UARTCLK (ADUCM_UCLK / 16) | ||
429 | #elif ADUCM_UARTCD_DIV == ADUCM_UARTCD_DIV32 | ||
430 | #define ADUCM_UARTCLK (ADUCM_UCLK / 32) | ||
431 | #elif ADUCM_UARTCD_DIV == ADUCM_UARTCD_DIV64 | ||
432 | #define ADUCM_UARTCLK (ADUCM_UCLK / 64) | ||
433 | #elif ADUCM_UARTCD_DIV == ADUCM_UARTCD_DIV128 | ||
434 | #define ADUCM_UARTCLK (ADUCM_UCLK / 128) | ||
435 | #else | ||
436 | #error "invalid ADUCM_UARTCD_DIV value specified" | ||
437 | #endif | ||
438 | |||
439 | /** | ||
440 | * @brief PWM frequency. | ||
441 | */ | ||
442 | #if (ADUCM_PWMCD_DIV == ADUCM_PWMCD_DIV1) || defined(__DOXYGEN__) | ||
443 | #define ADUCM_PWMCLK (ADUCM_UCLK / 1) | ||
444 | #elif ADUCM_PWMCD_DIV == ADUCM_PWMCD_DIV2 | ||
445 | #define ADUCM_PWMCLK (ADUCM_UCLK / 2) | ||
446 | #elif ADUCM_PWMCD_DIV == ADUCM_PWMCD_DIV4 | ||
447 | #define ADUCM_PWMCLK (ADUCM_UCLK / 4) | ||
448 | #elif ADUCM_PWMCD_DIV == ADUCM_PWMCD_DIV8 | ||
449 | #define ADUCM_PWMCLK (ADUCM_UCLK / 8) | ||
450 | #elif ADUCM_PWMCD_DIV == ADUCM_PWMCD_DIV16 | ||
451 | #define ADUCM_PWMCLK (ADUCM_UCLK / 16) | ||
452 | #elif ADUCM_PWMCD_DIV == ADUCM_PWMCD_DIV32 | ||
453 | #define ADUCM_PWMCLK (ADUCM_UCLK / 32) | ||
454 | #elif ADUCM_PWMCD_DIV == ADUCM_PWMCD_DIV64 | ||
455 | #define ADUCM_PWMCLK (ADUCM_UCLK / 64) | ||
456 | #elif ADUCM_PWMCD_DIV == ADUCM_PWMCD_DIV128 | ||
457 | #define ADUCM_PWMCLK (ADUCM_UCLK / 128) | ||
458 | #else | ||
459 | #error "invalid ADUCM_PWMCD_DIV value specified" | ||
460 | #endif | ||
461 | |||
462 | /*===========================================================================*/ | ||
463 | /* Driver data structures and types. */ | ||
464 | /*===========================================================================*/ | ||
465 | |||
466 | /*===========================================================================*/ | ||
467 | /* Driver macros. */ | ||
468 | /*===========================================================================*/ | ||
469 | |||
470 | /*===========================================================================*/ | ||
471 | /* External declarations. */ | ||
472 | /*===========================================================================*/ | ||
473 | |||
474 | /* Various helpers.*/ | ||
475 | #include "nvic.h" | ||
476 | #include "cache.h" | ||
477 | #include "aducm_isr.h" | ||
478 | #include "aducm_cc.h" | ||
479 | |||
480 | #ifdef __cplusplus | ||
481 | extern "C" { | ||
482 | #endif | ||
483 | void hal_lld_init(void); | ||
484 | void aducm_clock_init(void); | ||
485 | #ifdef __cplusplus | ||
486 | } | ||
487 | #endif | ||
488 | |||
489 | #endif /* HAL_LLD_H */ | ||
490 | |||
491 | /** @} */ | ||