ChibiOS 21.11.5
hal_pwm_lld.c
Go to the documentation of this file.
1/*
2 ChibiOS - Copyright (C) 2006-2026 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__)
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 */
66void pwm_lld_init(void) {
67
68#if PLATFORM_PWM_USE_PWM1 == TRUE
69 /* Driver initialization.*/
71 PWMD1.channels = PWM_CHANNELS;
72#endif
73}
74
75/**
76 * @brief Configures and activates the PWM peripheral.
77 * @note Starting a driver that is already in the @p PWM_READY state
78 * disables all the active channels.
79 *
80 * @param[in] pwmp pointer to a @p PWMDriver object
81 *
82 * @notapi
83 */
85
86 if (pwmp->state == PWM_STOP) {
87 /* Clock activation and timer reset.*/
88#if PLATFORM_PWM_USE_PWM1 == TRUE
89 if (&PWMD1 == pwmp) {
90
91 }
92#endif
93 }
94}
95
96/**
97 * @brief Deactivates the PWM peripheral.
98 *
99 * @param[in] pwmp pointer to a @p PWMDriver object
100 *
101 * @notapi
102 */
104
105 /* If in ready state then disables the PWM clock.*/
106 if (pwmp->state == PWM_READY) {
107#if PLATFORM_PWM_USE_PWM1 == TRUE
108 if (&PWMD1 == pwmp) {
109
110 }
111#endif
112 }
113}
114
115/**
116 * @brief Enables a PWM channel.
117 * @pre The PWM unit must have been activated using @p pwmStart().
118 * @post The channel is active using the specified configuration.
119 * @note The function has effect at the next cycle start.
120 * @note Channel notification is not enabled.
121 *
122 * @param[in] pwmp pointer to a @p PWMDriver object
123 * @param[in] channel PWM channel identifier (0...channels-1)
124 * @param[in] width PWM pulse width as clock pulses number
125 *
126 * @notapi
127 */
129 pwmchannel_t channel,
130 pwmcnt_t width) {
131
132 (void)pwmp;
133 (void)channel;
134 (void)width;
135}
136
137/**
138 * @brief Disables a PWM channel and its notification.
139 * @pre The PWM unit must have been activated using @p pwmStart().
140 * @post The channel is disabled and its output line returned to the
141 * idle state.
142 * @note The function has effect at the next cycle start.
143 *
144 * @param[in] pwmp pointer to a @p PWMDriver object
145 * @param[in] channel PWM channel identifier (0...channels-1)
146 *
147 * @notapi
148 */
150
151 (void)pwmp;
152 (void)channel;
153}
154
155/**
156 * @brief Enables the periodic activation edge notification.
157 * @pre The PWM unit must have been activated using @p pwmStart().
158 * @note If the notification is already enabled then the call has no effect.
159 *
160 * @param[in] pwmp pointer to a @p PWMDriver object
161 *
162 * @notapi
163 */
165
166 (void)pwmp;
167}
168
169/**
170 * @brief Disables the periodic activation edge notification.
171 * @pre The PWM unit must have been activated using @p pwmStart().
172 * @note If the notification is already disabled then the call has no effect.
173 *
174 * @param[in] pwmp pointer to a @p PWMDriver object
175 *
176 * @notapi
177 */
179
180 (void)pwmp;
181}
182
183/**
184 * @brief Enables a channel de-activation edge notification.
185 * @pre The PWM unit must have been activated using @p pwmStart().
186 * @pre The channel must have been activated using @p pwmEnableChannel().
187 * @note If the notification is already enabled then the call has no effect.
188 *
189 * @param[in] pwmp pointer to a @p PWMDriver object
190 * @param[in] channel PWM channel identifier (0...channels-1)
191 *
192 * @notapi
193 */
195 pwmchannel_t channel) {
196
197 (void)pwmp;
198 (void)channel;
199}
200
201/**
202 * @brief Disables a channel de-activation edge notification.
203 * @pre The PWM unit must have been activated using @p pwmStart().
204 * @pre The channel must have been activated using @p pwmEnableChannel().
205 * @note If the notification is already disabled then the call has no effect.
206 *
207 * @param[in] pwmp pointer to a @p PWMDriver object
208 * @param[in] channel PWM channel identifier (0...channels-1)
209 *
210 * @notapi
211 */
213 pwmchannel_t channel) {
214
215 (void)pwmp;
216 (void)channel;
217}
218
219#endif /* HAL_USE_PWM == TRUE */
220
221/** @} */
void pwm_lld_disable_periodic_notification(PWMDriver *pwmp)
Disables the periodic activation edge notification.
#define PWM_CHANNELS
Number of PWM channels per PWM driver.
Definition hal_pwm_lld.h:37
void pwm_lld_stop(PWMDriver *pwmp)
Deactivates the PWM peripheral.
uint32_t pwmcnt_t
Type of a PWM counter.
Definition hal_pwm_lld.h:83
void pwmObjectInit(PWMDriver *pwmp)
Initializes the standard part of a PWMDriver structure.
Definition hal_pwm.c:68
uint8_t pwmchannel_t
Type of a PWM channel.
Definition hal_pwm_lld.h:73
void pwm_lld_disable_channel_notification(PWMDriver *pwmp, pwmchannel_t channel)
Disables a channel de-activation edge notification.
void pwm_lld_disable_channel(PWMDriver *pwmp, pwmchannel_t channel)
Disables a PWM channel and its notification.
void pwm_lld_init(void)
Low level PWM driver initialization.
Definition hal_pwm_lld.c:66
void pwm_lld_start(PWMDriver *pwmp)
Configures and activates the PWM peripheral.
Definition hal_pwm_lld.c:84
void pwm_lld_enable_channel(PWMDriver *pwmp, pwmchannel_t channel, pwmcnt_t width)
Enables a PWM channel.
void pwm_lld_enable_periodic_notification(PWMDriver *pwmp)
Enables the periodic activation edge notification.
void pwm_lld_enable_channel_notification(PWMDriver *pwmp, pwmchannel_t channel)
Enables a channel de-activation edge notification.
PWMDriver PWMD1
PWMD1 driver identifier.
Definition hal_pwm_lld.c:42
@ PWM_READY
Definition hal_pwm.h:77
@ PWM_STOP
Definition hal_pwm.h:76
HAL subsystem header.
Structure representing a PWM driver.
pwmstate_t state
Driver state.