aboutsummaryrefslogtreecommitdiff
path: root/lib/chibios/os/hal/ports/STM32/LLD/TIMv1/stm32_tim20.inc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chibios/os/hal/ports/STM32/LLD/TIMv1/stm32_tim20.inc')
-rw-r--r--lib/chibios/os/hal/ports/STM32/LLD/TIMv1/stm32_tim20.inc170
1 files changed, 170 insertions, 0 deletions
diff --git a/lib/chibios/os/hal/ports/STM32/LLD/TIMv1/stm32_tim20.inc b/lib/chibios/os/hal/ports/STM32/LLD/TIMv1/stm32_tim20.inc
new file mode 100644
index 000000000..1b0899811
--- /dev/null
+++ b/lib/chibios/os/hal/ports/STM32/LLD/TIMv1/stm32_tim20.inc
@@ -0,0 +1,170 @@
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 TIMv1/stm32_tim20.inc
19 * @brief Shared TIM20 handler.
20 *
21 * @addtogroup STM32_TIM20_HANDLER
22 * @{
23 */
24
25/*===========================================================================*/
26/* Driver local definitions. */
27/*===========================================================================*/
28
29/*===========================================================================*/
30/* Derived constants and error checks. */
31/*===========================================================================*/
32
33/* Registry checks for robustness.*/
34#if !defined(STM32_HAS_TIM20)
35#error "STM32_HAS_TIM20 not defined in registry"
36#endif
37
38/* Driver checks for robustness, undefined USE macros are defaulted to
39 FALSE. This makes this module independent from drivers implementation.*/
40#if !defined(STM32_GPT_USE_TIM20)
41#define STM32_GPT_USE_TIM20 FALSE
42#endif
43#if !defined(STM32_ICU_USE_TIM20)
44#define STM32_ICU_USE_TIM20 FALSE
45#endif
46#if !defined(STM32_PWM_USE_TIM20)
47#define STM32_PWM_USE_TIM20 FALSE
48#endif
49#if !defined(STM32_ST_USE_TIM20)
50#define STM32_ST_USE_TIM20 FALSE
51#endif
52
53#if STM32_HAS_TIM20
54
55/* Priority settings checks.*/
56#if !defined(STM32_IRQ_TIM20_UP_PRIORITY)
57#error "STM32_IRQ_TIM20_UP_PRIORITY not defined in mcuconf.h"
58#endif
59
60#if !defined(STM32_IRQ_TIM20_CC_PRIORITY)
61#error "STM32_IRQ_TIM20_CC_PRIORITY not defined in mcuconf.h"
62#endif
63
64#if !OSAL_IRQ_IS_VALID_PRIORITY(STM32_IRQ_TIM20_UP_PRIORITY)
65#error "Invalid IRQ priority assigned to STM32_IRQ_TIM20_UP_PRIORITY"
66#endif
67
68#if !OSAL_IRQ_IS_VALID_PRIORITY(STM32_IRQ_TIM20_CC_PRIORITY)
69#error "Invalid IRQ priority assigned to STM32_IRQ_TIM20_CC_PRIORITY"
70#endif
71
72#endif /* STM32_HAS_TIM20 */
73
74/*===========================================================================*/
75/* Driver exported variables. */
76/*===========================================================================*/
77
78/*===========================================================================*/
79/* Driver local variables. */
80/*===========================================================================*/
81
82/*===========================================================================*/
83/* Driver local functions. */
84/*===========================================================================*/
85
86static inline void tim20_irq_init(void) {
87#if defined(STM32_TIM20_IS_USED)
88 nvicEnableVector(STM32_TIM20_UP_NUMBER, STM32_IRQ_TIM20_UP_PRIORITY);
89 nvicEnableVector(STM32_TIM20_CC_NUMBER, STM32_IRQ_TIM20_CC_PRIORITY);
90#endif
91}
92
93static inline void tim20_irq_deinit(void) {
94#if defined(STM32_TIM20_IS_USED)
95 nvicDisableVector(STM32_TIM20_UP_NUMBER);
96 nvicDisableVector(STM32_TIM20_CC_NUMBER);
97#endif
98}
99
100/*===========================================================================*/
101/* Driver interrupt handlers. */
102/*===========================================================================*/
103
104#if defined(STM32_TIM20_IS_USED) || defined(__DOXYGEN__)
105/**
106 * @brief TIM20-UP interrupt handler.
107 *
108 * @isr
109 */
110OSAL_IRQ_HANDLER(STM32_TIM20_UP_HANDLER) {
111
112 OSAL_IRQ_PROLOGUE();
113
114#if HAL_USE_GPT
115#if STM32_GPT_USE_TIM20
116 pwm_lld_serve_interrupt(&GPTD20);
117#endif
118#endif
119#if HAL_USE_ICU
120#if STM32_ICU_USE_TIM20
121 pwm_lld_serve_interrupt(&ICUD20);
122#endif
123#endif
124#if HAL_USE_PWM
125#if STM32_PWM_USE_TIM20
126 pwm_lld_serve_interrupt(&PWMD20);
127#endif
128#endif
129#if 1
130#if STM32_ST_USE_TIM20
131 st_lld_serve_interrupt();
132#endif
133#endif
134
135 OSAL_IRQ_EPILOGUE();
136}
137
138/**
139 * @brief TIM20-CC interrupt handler.
140 *
141 * @isr
142 */
143OSAL_IRQ_HANDLER(STM32_TIM20_CC_HANDLER) {
144
145 OSAL_IRQ_PROLOGUE();
146
147#if HAL_USE_GPT
148 /* Not used by GPT.*/
149#endif
150#if STM32_ICU_USE_TIM20
151 pwm_lld_serve_interrupt(&ICUD20);
152#endif
153#if HAL_USE_PWM
154#if STM32_PWM_USE_TIM20
155 pwm_lld_serve_interrupt(&PWMD20);
156#endif
157#endif
158#if 1
159 /* Not used by ST.*/
160#endif
161
162 OSAL_IRQ_EPILOGUE();
163}
164#endif
165
166/*===========================================================================*/
167/* Driver exported functions. */
168/*===========================================================================*/
169
170/** @} */