diff options
Diffstat (limited to 'lib/chibios/os/hal/templates/hal_pwm_lld.c')
-rw-r--r-- | lib/chibios/os/hal/templates/hal_pwm_lld.c | 220 |
1 files changed, 220 insertions, 0 deletions
diff --git a/lib/chibios/os/hal/templates/hal_pwm_lld.c b/lib/chibios/os/hal/templates/hal_pwm_lld.c new file mode 100644 index 000000000..301163fa2 --- /dev/null +++ b/lib/chibios/os/hal/templates/hal_pwm_lld.c | |||
@@ -0,0 +1,220 @@ | |||
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_pwm_lld.c | ||
19 | * @brief PLATFORM PWM subsystem low level driver source. | ||
20 | * | ||
21 | * @addtogroup PWM | ||
22 | * @{ | ||
23 | */ | ||
24 | |||
25 | #include "hal.h" | ||
26 | |||
27 | #if (HAL_USE_PWM == TRUE) || defined(__DOXYGEN__) | ||
28 | |||
29 | /*===========================================================================*/ | ||
30 | /* Driver local definitions. */ | ||
31 | /*===========================================================================*/ | ||
32 | |||
33 | /*===========================================================================*/ | ||
34 | /* Driver exported variables. */ | ||
35 | /*===========================================================================*/ | ||
36 | |||
37 | /** | ||
38 | * @brief PWMD1 driver identifier. | ||
39 | * @note The driver PWMD1 allocates the complex timer TIM1 when enabled. | ||
40 | */ | ||
41 | #if (PLATFORM_PWM_USE_PWM1 == TRUE) || defined(__DOXYGEN__) | ||
42 | PWMDriver PWMD1; | ||
43 | #endif | ||
44 | |||
45 | /*===========================================================================*/ | ||
46 | /* Driver local variables and types. */ | ||
47 | /*===========================================================================*/ | ||
48 | |||
49 | /*===========================================================================*/ | ||
50 | /* Driver local functions. */ | ||
51 | /*===========================================================================*/ | ||
52 | |||
53 | /*===========================================================================*/ | ||
54 | /* Driver interrupt handlers. */ | ||
55 | /*===========================================================================*/ | ||
56 | |||
57 | /*===========================================================================*/ | ||
58 | /* Driver exported functions. */ | ||
59 | /*===========================================================================*/ | ||
60 | |||
61 | /** | ||
62 | * @brief Low level PWM driver initialization. | ||
63 | * | ||
64 | * @notapi | ||
65 | */ | ||
66 | void pwm_lld_init(void) { | ||
67 | |||
68 | #if PLATFORM_PWM_USE_PWM1 == TRUE | ||
69 | /* Driver initialization.*/ | ||
70 | pwmObjectInit(&PWMD1); | ||
71 | #endif | ||
72 | } | ||
73 | |||
74 | /** | ||
75 | * @brief Configures and activates the PWM peripheral. | ||
76 | * @note Starting a driver that is already in the @p PWM_READY state | ||
77 | * disables all the active channels. | ||
78 | * | ||
79 | * @param[in] pwmp pointer to a @p PWMDriver object | ||
80 | * | ||
81 | * @notapi | ||
82 | */ | ||
83 | void pwm_lld_start(PWMDriver *pwmp) { | ||
84 | |||
85 | if (pwmp->state == PWM_STOP) { | ||
86 | /* Clock activation and timer reset.*/ | ||
87 | #if PLATFORM_PWM_USE_PWM1 == TRUE | ||
88 | if (&PWMD1 == pwmp) { | ||
89 | |||
90 | } | ||
91 | #endif | ||
92 | } | ||
93 | } | ||
94 | |||
95 | /** | ||
96 | * @brief Deactivates the PWM peripheral. | ||
97 | * | ||
98 | * @param[in] pwmp pointer to a @p PWMDriver object | ||
99 | * | ||
100 | * @notapi | ||
101 | */ | ||
102 | void pwm_lld_stop(PWMDriver *pwmp) { | ||
103 | |||
104 | /* If in ready state then disables the PWM clock.*/ | ||
105 | if (pwmp->state == PWM_READY) { | ||
106 | #if PLATFORM_PWM_USE_PWM1 == TRUE | ||
107 | if (&PWMD1 == pwmp) { | ||
108 | |||
109 | } | ||
110 | #endif | ||
111 | } | ||
112 | } | ||
113 | |||
114 | /** | ||
115 | * @brief Enables a PWM channel. | ||
116 | * @pre The PWM unit must have been activated using @p pwmStart(). | ||
117 | * @post The channel is active using the specified configuration. | ||
118 | * @note The function has effect at the next cycle start. | ||
119 | * @note Channel notification is not enabled. | ||
120 | * | ||
121 | * @param[in] pwmp pointer to a @p PWMDriver object | ||
122 | * @param[in] channel PWM channel identifier (0...channels-1) | ||
123 | * @param[in] width PWM pulse width as clock pulses number | ||
124 | * | ||
125 | * @notapi | ||
126 | */ | ||
127 | void pwm_lld_enable_channel(PWMDriver *pwmp, | ||
128 | pwmchannel_t channel, | ||
129 | pwmcnt_t width) { | ||
130 | |||
131 | (void)pwmp; | ||
132 | (void)channel; | ||
133 | (void)width; | ||
134 | } | ||
135 | |||
136 | /** | ||
137 | * @brief Disables a PWM channel and its notification. | ||
138 | * @pre The PWM unit must have been activated using @p pwmStart(). | ||
139 | * @post The channel is disabled and its output line returned to the | ||
140 | * idle state. | ||
141 | * @note The function has effect at the next cycle start. | ||
142 | * | ||
143 | * @param[in] pwmp pointer to a @p PWMDriver object | ||
144 | * @param[in] channel PWM channel identifier (0...channels-1) | ||
145 | * | ||
146 | * @notapi | ||
147 | */ | ||
148 | void pwm_lld_disable_channel(PWMDriver *pwmp, pwmchannel_t channel) { | ||
149 | |||
150 | (void)pwmp; | ||
151 | (void)channel; | ||
152 | } | ||
153 | |||
154 | /** | ||
155 | * @brief Enables the periodic activation edge notification. | ||
156 | * @pre The PWM unit must have been activated using @p pwmStart(). | ||
157 | * @note If the notification is already enabled then the call has no effect. | ||
158 | * | ||
159 | * @param[in] pwmp pointer to a @p PWMDriver object | ||
160 | * | ||
161 | * @notapi | ||
162 | */ | ||
163 | void pwm_lld_enable_periodic_notification(PWMDriver *pwmp) { | ||
164 | |||
165 | (void)pwmp; | ||
166 | } | ||
167 | |||
168 | /** | ||
169 | * @brief Disables the periodic activation edge notification. | ||
170 | * @pre The PWM unit must have been activated using @p pwmStart(). | ||
171 | * @note If the notification is already disabled then the call has no effect. | ||
172 | * | ||
173 | * @param[in] pwmp pointer to a @p PWMDriver object | ||
174 | * | ||
175 | * @notapi | ||
176 | */ | ||
177 | void pwm_lld_disable_periodic_notification(PWMDriver *pwmp) { | ||
178 | |||
179 | (void)pwmp; | ||
180 | } | ||
181 | |||
182 | /** | ||
183 | * @brief Enables a channel de-activation edge notification. | ||
184 | * @pre The PWM unit must have been activated using @p pwmStart(). | ||
185 | * @pre The channel must have been activated using @p pwmEnableChannel(). | ||
186 | * @note If the notification is already enabled then the call has no effect. | ||
187 | * | ||
188 | * @param[in] pwmp pointer to a @p PWMDriver object | ||
189 | * @param[in] channel PWM channel identifier (0...channels-1) | ||
190 | * | ||
191 | * @notapi | ||
192 | */ | ||
193 | void pwm_lld_enable_channel_notification(PWMDriver *pwmp, | ||
194 | pwmchannel_t channel) { | ||
195 | |||
196 | (void)pwmp; | ||
197 | (void)channel; | ||
198 | } | ||
199 | |||
200 | /** | ||
201 | * @brief Disables a channel de-activation edge notification. | ||
202 | * @pre The PWM unit must have been activated using @p pwmStart(). | ||
203 | * @pre The channel must have been activated using @p pwmEnableChannel(). | ||
204 | * @note If the notification is already disabled then the call has no effect. | ||
205 | * | ||
206 | * @param[in] pwmp pointer to a @p PWMDriver object | ||
207 | * @param[in] channel PWM channel identifier (0...channels-1) | ||
208 | * | ||
209 | * @notapi | ||
210 | */ | ||
211 | void pwm_lld_disable_channel_notification(PWMDriver *pwmp, | ||
212 | pwmchannel_t channel) { | ||
213 | |||
214 | (void)pwmp; | ||
215 | (void)channel; | ||
216 | } | ||
217 | |||
218 | #endif /* HAL_USE_PWM == TRUE */ | ||
219 | |||
220 | /** @} */ | ||