• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2019 Espressif Systems (Shanghai) PTE LTD
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 // The LL layer for LEDC register operations.
16 // Note that most of the register operations in this layer are non-atomic operations.
17 
18 #pragma once
19 
20 #include "hal/ledc_types.h"
21 #include "soc/ledc_periph.h"
22 
23 #define LEDC_LL_GET_HW() &LEDC
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 /**
30  * @brief Set LEDC low speed timer clock
31  *
32  * @param hw Beginning address of the peripheral registers
33  * @param slow_clk_sel LEDC low speed timer clock source
34  *
35  * @return None
36  */
ledc_ll_set_slow_clk_sel(ledc_dev_t * hw,ledc_slow_clk_sel_t slow_clk_sel)37 static inline void ledc_ll_set_slow_clk_sel(ledc_dev_t *hw, ledc_slow_clk_sel_t slow_clk_sel){
38     hw->conf.slow_clk_sel = slow_clk_sel;
39 }
40 
41 /**
42  * @brief Get LEDC low speed timer clock
43  *
44  * @param hw Beginning address of the peripheral registers
45  * @param slow_clk_sel LEDC low speed timer clock source
46  *
47  * @return None
48  */
ledc_ll_get_slow_clk_sel(ledc_dev_t * hw,ledc_slow_clk_sel_t * slow_clk_sel)49 static inline void ledc_ll_get_slow_clk_sel(ledc_dev_t *hw, ledc_slow_clk_sel_t *slow_clk_sel){
50     *slow_clk_sel = hw->conf.slow_clk_sel;
51 }
52 
53 /**
54  * @brief Update LEDC low speed timer
55  *
56  * @param hw Beginning address of the peripheral registers
57  * @param speed_mode LEDC speed_mode, high-speed mode or low-speed mode
58  * @param timer_sel LEDC timer index (0-3), select from ledc_timer_t
59  *
60  * @return None
61  */
ledc_ll_ls_timer_update(ledc_dev_t * hw,ledc_mode_t speed_mode,ledc_timer_t timer_sel)62 static inline void ledc_ll_ls_timer_update(ledc_dev_t *hw, ledc_mode_t speed_mode, ledc_timer_t timer_sel){
63     hw->timer_group[speed_mode].timer[timer_sel].conf.low_speed_update = 1;
64 }
65 
66 /**
67  * @brief Reset LEDC timer
68  *
69  * @param hw Beginning address of the peripheral registers
70  * @param speed_mode LEDC speed_mode, high-speed mode or low-speed mode
71  * @param timer_sel LEDC timer index (0-3), select from ledc_timer_t
72  *
73  * @return None
74  */
ledc_ll_timer_rst(ledc_dev_t * hw,ledc_mode_t speed_mode,ledc_timer_t timer_sel)75 static inline void ledc_ll_timer_rst(ledc_dev_t *hw, ledc_mode_t speed_mode, ledc_timer_t timer_sel){
76     hw->timer_group[speed_mode].timer[timer_sel].conf.rst = 1;
77     hw->timer_group[speed_mode].timer[timer_sel].conf.rst = 0;
78 }
79 
80 /**
81  * @brief Pause LEDC timer
82  *
83  * @param hw Beginning address of the peripheral registers
84  * @param speed_mode LEDC speed_mode, high-speed mode or low-speed mode
85  * @param timer_sel LEDC timer index (0-3), select from ledc_timer_t
86  *
87  * @return None
88  */
ledc_ll_timer_pause(ledc_dev_t * hw,ledc_mode_t speed_mode,ledc_timer_t timer_sel)89 static inline void ledc_ll_timer_pause(ledc_dev_t *hw, ledc_mode_t speed_mode, ledc_timer_t timer_sel){
90     hw->timer_group[speed_mode].timer[timer_sel].conf.pause = 1;
91 }
92 
93 /**
94  * @brief Resume LEDC timer
95  *
96  * @param hw Beginning address of the peripheral registers
97  * @param speed_mode LEDC speed_mode, high-speed mode or low-speed mode
98  * @param timer_sel LEDC timer index (0-3), select from ledc_timer_t
99  *
100  * @return None
101  */
ledc_ll_timer_resume(ledc_dev_t * hw,ledc_mode_t speed_mode,ledc_timer_t timer_sel)102 static inline void ledc_ll_timer_resume(ledc_dev_t *hw, ledc_mode_t speed_mode, ledc_timer_t timer_sel){
103     hw->timer_group[speed_mode].timer[timer_sel].conf.pause = 0;
104 }
105 
106 /**
107  * @brief Set LEDC timer clock divider
108  *
109  * @param hw Beginning address of the peripheral registers
110  * @param speed_mode LEDC speed_mode, high-speed mode or low-speed mode
111  * @param timer_sel LEDC timer index (0-3), select from ledc_timer_t
112  * @param clock_divider Timer clock divide value, the timer clock is divided from the selected clock source
113  *
114  * @return None
115  */
ledc_ll_set_clock_divider(ledc_dev_t * hw,ledc_mode_t speed_mode,ledc_timer_t timer_sel,uint32_t clock_divider)116 static inline void ledc_ll_set_clock_divider(ledc_dev_t *hw, ledc_mode_t speed_mode, ledc_timer_t timer_sel, uint32_t clock_divider){
117     hw->timer_group[speed_mode].timer[timer_sel].conf.clock_divider = clock_divider;
118 }
119 
120 /**
121  * @brief Get LEDC timer clock divider
122  *
123  * @param hw Beginning address of the peripheral registers
124  * @param speed_mode LEDC speed_mode, high-speed mode or low-speed mode
125  * @param timer_sel LEDC timer index (0-3), select from ledc_timer_t
126  * @param clock_divider Timer clock divide value, the timer clock is divided from the selected clock source
127  *
128  * @return None
129  */
ledc_ll_get_clock_divider(ledc_dev_t * hw,ledc_mode_t speed_mode,ledc_timer_t timer_sel,uint32_t * clock_divider)130 static inline void ledc_ll_get_clock_divider(ledc_dev_t *hw, ledc_mode_t speed_mode, ledc_timer_t timer_sel, uint32_t *clock_divider){
131     *clock_divider = hw->timer_group[speed_mode].timer[timer_sel].conf.clock_divider;
132 }
133 
134 /**
135  * @brief Set LEDC timer clock source
136  *
137  * @param hw Beginning address of the peripheral registers
138  * @param speed_mode LEDC speed_mode, high-speed mode or low-speed mode
139  * @param timer_sel LEDC timer index (0-3), select from ledc_timer_t
140  * @param clk_src Timer clock source
141  *
142  * @return None
143  */
ledc_ll_set_clock_source(ledc_dev_t * hw,ledc_mode_t speed_mode,ledc_timer_t timer_sel,ledc_clk_src_t clk_src)144 static inline void ledc_ll_set_clock_source(ledc_dev_t *hw, ledc_mode_t speed_mode, ledc_timer_t timer_sel, ledc_clk_src_t clk_src){
145     hw->timer_group[speed_mode].timer[timer_sel].conf.tick_sel = (clk_src == LEDC_APB_CLK);
146 }
147 
148 /**
149  * @brief Get LEDC timer clock source
150  *
151  * @param hw Beginning address of the peripheral registers
152  * @param speed_mode LEDC speed_mode, high-speed mode or low-speed mode
153  * @param timer_sel LEDC timer index (0-3), select from ledc_timer_t
154  * @param clk_src Pointer to accept the timer clock source
155  *
156  * @return None
157  */
ledc_ll_get_clock_source(ledc_dev_t * hw,ledc_mode_t speed_mode,ledc_timer_t timer_sel,ledc_clk_src_t * clk_src)158 static inline void ledc_ll_get_clock_source(ledc_dev_t *hw, ledc_mode_t speed_mode, ledc_timer_t timer_sel, ledc_clk_src_t *clk_src){
159     if (hw->timer_group[speed_mode].timer[timer_sel].conf.tick_sel) {
160         *clk_src = LEDC_APB_CLK;
161     } else {
162         *clk_src = LEDC_REF_TICK;
163     }
164 }
165 
166 /**
167  * @brief Set LEDC duty resolution
168  *
169  * @param hw Beginning address of the peripheral registers
170  * @param speed_mode LEDC speed_mode, high-speed mode or low-speed mode
171  * @param timer_sel LEDC timer index (0-3), select from ledc_timer_t
172  * @param duty_resolution Resolution of duty setting in number of bits. The range of duty values is [0, (2**duty_resolution)]
173  *
174  * @return None
175  */
ledc_ll_set_duty_resolution(ledc_dev_t * hw,ledc_mode_t speed_mode,ledc_timer_t timer_sel,uint32_t duty_resolution)176 static inline void ledc_ll_set_duty_resolution(ledc_dev_t *hw, ledc_mode_t speed_mode, ledc_timer_t timer_sel, uint32_t duty_resolution){
177     hw->timer_group[speed_mode].timer[timer_sel].conf.duty_resolution = duty_resolution;
178 }
179 
180 /**
181  * @brief Get LEDC duty resolution
182  *
183  * @param hw Beginning address of the peripheral registers
184  * @param speed_mode LEDC speed_mode, high-speed mode or low-speed mode
185  * @param timer_sel LEDC timer index (0-3), select from ledc_timer_t
186  * @param duty_resolution Pointer to accept the resolution of duty setting in number of bits.
187  *
188  * @return None
189  */
ledc_ll_get_duty_resolution(ledc_dev_t * hw,ledc_mode_t speed_mode,ledc_timer_t timer_sel,uint32_t * duty_resolution)190 static inline void ledc_ll_get_duty_resolution(ledc_dev_t *hw, ledc_mode_t speed_mode, ledc_timer_t timer_sel, uint32_t *duty_resolution){
191     *duty_resolution = hw->timer_group[speed_mode].timer[timer_sel].conf.duty_resolution;
192 }
193 
194 /**
195  * @brief Update channel configure when select low speed mode
196  *
197  * @param hw Beginning address of the peripheral registers
198  * @param speed_mode LEDC speed_mode, high-speed mode or low-speed mode
199  * @param channel_num LEDC channel index (0-7), select from ledc_channel_t
200  *
201  * @return None
202  */
ledc_ll_ls_channel_update(ledc_dev_t * hw,ledc_mode_t speed_mode,ledc_channel_t channel_num)203 static inline void ledc_ll_ls_channel_update(ledc_dev_t *hw, ledc_mode_t speed_mode, ledc_channel_t channel_num){
204     hw->channel_group[speed_mode].channel[channel_num].conf0.low_speed_update = 1;
205 }
206 
207 /**
208  * @brief Get LEDC max duty
209  *
210  * @param hw Beginning address of the peripheral registers
211  * @param speed_mode LEDC speed_mode, high-speed mode or low-speed mode
212  * @param channel_num LEDC channel index (0-7), select from ledc_channel_t
213  * @param max_duty Pointer to accept the max duty
214  *
215  * @return None
216  */
ledc_ll_get_max_duty(ledc_dev_t * hw,ledc_mode_t speed_mode,ledc_channel_t channel_num,uint32_t * max_duty)217 static inline void ledc_ll_get_max_duty(ledc_dev_t *hw, ledc_mode_t speed_mode, ledc_channel_t channel_num, uint32_t *max_duty){
218     int timer_sel = hw->channel_group[speed_mode].channel[channel_num].conf0.timer_sel;
219     *max_duty = (1 << (LEDC.timer_group[speed_mode].timer[timer_sel].conf.duty_resolution));
220 }
221 
222 /**
223  * @brief Set LEDC hpoint value
224  *
225  * @param hw Beginning address of the peripheral registers
226  * @param speed_mode LEDC speed_mode, high-speed mode or low-speed mode
227  * @param channel_num LEDC channel index (0-7), select from ledc_channel_t
228  * @param hpoint_val LEDC hpoint value(max: 0xfffff)
229  *
230  * @return None
231  */
ledc_ll_set_hpoint(ledc_dev_t * hw,ledc_mode_t speed_mode,ledc_channel_t channel_num,uint32_t hpoint_val)232 static inline void ledc_ll_set_hpoint(ledc_dev_t *hw, ledc_mode_t speed_mode, ledc_channel_t channel_num, uint32_t hpoint_val){
233     hw->channel_group[speed_mode].channel[channel_num].hpoint.hpoint = hpoint_val;
234 }
235 
236 /**
237  * @brief Get LEDC hpoint value
238  *
239  * @param hw Beginning address of the peripheral registers
240  * @param speed_mode LEDC speed_mode, high-speed mode or low-speed mode
241  * @param channel_num LEDC channel index (0-7), select from ledc_channel_t
242  * @param hpoint_val Pointer to accept the LEDC hpoint value(max: 0xfffff)
243  *
244  * @return None
245  */
ledc_ll_get_hpoint(ledc_dev_t * hw,ledc_mode_t speed_mode,ledc_channel_t channel_num,uint32_t * hpoint_val)246 static inline void ledc_ll_get_hpoint(ledc_dev_t *hw, ledc_mode_t speed_mode, ledc_channel_t channel_num, uint32_t *hpoint_val){
247     *hpoint_val = hw->channel_group[speed_mode].channel[channel_num].hpoint.hpoint;
248 }
249 
250 /**
251  * @brief Set LEDC the integer part of duty value
252  *
253  * @param hw Beginning address of the peripheral registers
254  * @param speed_mode LEDC speed_mode, high-speed mode or low-speed mode
255  * @param channel_num LEDC channel index (0-7), select from ledc_channel_t
256  * @param duty_val LEDC duty value, the range of duty setting is [0, (2**duty_resolution)]
257  *
258  * @return None
259  */
ledc_ll_set_duty_int_part(ledc_dev_t * hw,ledc_mode_t speed_mode,ledc_channel_t channel_num,uint32_t duty_val)260 static inline void ledc_ll_set_duty_int_part(ledc_dev_t *hw, ledc_mode_t speed_mode, ledc_channel_t channel_num, uint32_t duty_val){
261     hw->channel_group[speed_mode].channel[channel_num].duty.duty = duty_val << 4;
262 }
263 
264 /**
265  * @brief Get LEDC duty value
266  *
267  * @param hw Beginning address of the peripheral registers
268  * @param speed_mode LEDC speed_mode, high-speed mode or low-speed mode
269  * @param channel_num LEDC channel index (0-7), select from ledc_channel_t
270  * @param duty_val Pointer to accept the LEDC duty value
271  *
272  * @return None
273  */
ledc_ll_get_duty(ledc_dev_t * hw,ledc_mode_t speed_mode,ledc_channel_t channel_num,uint32_t * duty_val)274 static inline void ledc_ll_get_duty(ledc_dev_t *hw, ledc_mode_t speed_mode, ledc_channel_t channel_num, uint32_t *duty_val){
275     *duty_val = (hw->channel_group[speed_mode].channel[channel_num].duty_rd.duty_read >> 4);
276 }
277 
278 /**
279  * @brief Set LEDC duty change direction
280  *
281  * @param hw Beginning address of the peripheral registers
282  * @param speed_mode LEDC speed_mode, high-speed mode or low-speed mode
283  * @param channel_num LEDC channel index (0-7), select from ledc_channel_t
284  * @param duty_direction LEDC duty change direction, increase or decrease
285  *
286  * @return None
287  */
ledc_ll_set_duty_direction(ledc_dev_t * hw,ledc_mode_t speed_mode,ledc_channel_t channel_num,ledc_duty_direction_t duty_direction)288 static inline void ledc_ll_set_duty_direction(ledc_dev_t *hw, ledc_mode_t speed_mode, ledc_channel_t channel_num, ledc_duty_direction_t duty_direction){
289     hw->channel_group[speed_mode].channel[channel_num].conf1.duty_inc = duty_direction;
290 }
291 
292 /**
293  * @brief Get LEDC duty change direction
294  *
295  * @param hw Beginning address of the peripheral registers
296  * @param speed_mode LEDC speed_mode, high-speed mode or low-speed mode
297  * @param channel_num LEDC channel index (0-7), select from ledc_channel_t
298  * @param duty_direction Pointer to accept the LEDC duty change direction, increase or decrease
299  *
300  * @return None
301  */
ledc_ll_get_duty_direction(ledc_dev_t * hw,ledc_mode_t speed_mode,ledc_channel_t channel_num,ledc_duty_direction_t * duty_direction)302 static inline void ledc_ll_get_duty_direction(ledc_dev_t *hw, ledc_mode_t speed_mode, ledc_channel_t channel_num, ledc_duty_direction_t *duty_direction){
303     *duty_direction = hw->channel_group[speed_mode].channel[channel_num].conf1.duty_inc;
304 }
305 
306 /**
307  * @brief Set the number of increased or decreased times
308  *
309  * @param hw Beginning address of the peripheral registers
310  * @param speed_mode LEDC speed_mode, high-speed mode or low-speed mode
311  * @param channel_num LEDC channel index (0-7), select from ledc_channel_t
312  * @param duty_num The number of increased or decreased times
313  *
314  * @return None
315  */
ledc_ll_set_duty_num(ledc_dev_t * hw,ledc_mode_t speed_mode,ledc_channel_t channel_num,uint32_t duty_num)316 static inline void ledc_ll_set_duty_num(ledc_dev_t *hw, ledc_mode_t speed_mode, ledc_channel_t channel_num, uint32_t duty_num){
317     hw->channel_group[speed_mode].channel[channel_num].conf1.duty_num = duty_num;
318 }
319 
320 /**
321  * @brief Set the duty cycles of increase or decrease
322  *
323  * @param hw Beginning address of the peripheral registers
324  * @param speed_mode LEDC speed_mode, high-speed mode or low-speed mode
325  * @param channel_num LEDC channel index (0-7), select from ledc_channel_t
326  * @param duty_cycle The duty cycles
327  *
328  * @return None
329  */
ledc_ll_set_duty_cycle(ledc_dev_t * hw,ledc_mode_t speed_mode,ledc_channel_t channel_num,uint32_t duty_cycle)330 static inline void ledc_ll_set_duty_cycle(ledc_dev_t *hw, ledc_mode_t speed_mode, ledc_channel_t channel_num, uint32_t duty_cycle){
331     hw->channel_group[speed_mode].channel[channel_num].conf1.duty_cycle = duty_cycle;
332 }
333 
334 /**
335  * @brief Set the step scale of increase or decrease
336  *
337  * @param hw Beginning address of the peripheral registers
338  * @param speed_mode LEDC speed_mode, high-speed mode or low-speed mode
339  * @param channel_num LEDC channel index (0-7), select from ledc_channel_t
340  * @param duty_scale The step scale
341  *
342  * @return None
343  */
ledc_ll_set_duty_scale(ledc_dev_t * hw,ledc_mode_t speed_mode,ledc_channel_t channel_num,uint32_t duty_scale)344 static inline void ledc_ll_set_duty_scale(ledc_dev_t *hw, ledc_mode_t speed_mode, ledc_channel_t channel_num, uint32_t duty_scale){
345     hw->channel_group[speed_mode].channel[channel_num].conf1.duty_scale = duty_scale;
346 }
347 
348 /**
349  * @brief Set the output enable
350  *
351  * @param hw Beginning address of the peripheral registers
352  * @param speed_mode LEDC speed_mode, high-speed mode or low-speed mode
353  * @param channel_num LEDC channel index (0-7), select from ledc_channel_t
354  * @param sig_out_en The output enable status
355  *
356  * @return None
357  */
ledc_ll_set_sig_out_en(ledc_dev_t * hw,ledc_mode_t speed_mode,ledc_channel_t channel_num,bool sig_out_en)358 static inline void ledc_ll_set_sig_out_en(ledc_dev_t *hw, ledc_mode_t speed_mode, ledc_channel_t channel_num, bool sig_out_en){
359     hw->channel_group[speed_mode].channel[channel_num].conf0.sig_out_en = sig_out_en;
360 }
361 
362 /**
363  * @brief Set the duty start
364  *
365  * @param hw Beginning address of the peripheral registers
366  * @param speed_mode LEDC speed_mode, high-speed mode or low-speed mode
367  * @param channel_num LEDC channel index (0-7), select from ledc_channel_t
368  * @param duty_start The duty start
369  *
370  * @return None
371  */
ledc_ll_set_duty_start(ledc_dev_t * hw,ledc_mode_t speed_mode,ledc_channel_t channel_num,bool duty_start)372 static inline void ledc_ll_set_duty_start(ledc_dev_t *hw, ledc_mode_t speed_mode, ledc_channel_t channel_num, bool duty_start){
373     hw->channel_group[speed_mode].channel[channel_num].conf1.duty_start = duty_start;
374 }
375 
376 /**
377  * @brief Set output idle level
378  *
379  * @param hw Beginning address of the peripheral registers
380  * @param speed_mode LEDC speed_mode, high-speed mode or low-speed mode
381  * @param channel_num LEDC channel index (0-7), select from ledc_channel_t
382  * @param idle_level The output idle level
383  *
384  * @return None
385  */
ledc_ll_set_idle_level(ledc_dev_t * hw,ledc_mode_t speed_mode,ledc_channel_t channel_num,uint32_t idle_level)386 static inline void ledc_ll_set_idle_level(ledc_dev_t *hw, ledc_mode_t speed_mode, ledc_channel_t channel_num, uint32_t idle_level){
387     hw->channel_group[speed_mode].channel[channel_num].conf0.idle_lv = idle_level & 0x1;
388 }
389 
390 /**
391  * @brief Set fade end interrupt enable
392  *
393  * @param hw Beginning address of the peripheral registers
394  * @param speed_mode LEDC speed_mode, high-speed mode or low-speed mode
395  * @param channel_num LEDC channel index (0-7), select from ledc_channel_t
396  * @param fade_end_intr_en The fade end interrupt enable status
397  *
398  * @return None
399  */
ledc_ll_set_fade_end_intr(ledc_dev_t * hw,ledc_mode_t speed_mode,ledc_channel_t channel_num,bool fade_end_intr_en)400 static inline void ledc_ll_set_fade_end_intr(ledc_dev_t *hw, ledc_mode_t speed_mode, ledc_channel_t channel_num, bool fade_end_intr_en){
401     uint32_t value = hw->int_ena.val;
402     uint32_t int_en_base = (speed_mode == LEDC_LOW_SPEED_MODE) ? LEDC_DUTY_CHNG_END_LSCH0_INT_ENA_S : LEDC_DUTY_CHNG_END_HSCH0_INT_ENA_S;
403     hw->int_ena.val = fade_end_intr_en ? (value | BIT(int_en_base + channel_num)) : (value & (~(BIT(int_en_base + channel_num))));
404 }
405 
406 /**
407  * @brief Get fade end interrupt status
408  *
409  * @param hw Beginning address of the peripheral registers
410  * @param speed_mode LEDC speed_mode, high-speed mode or low-speed mode
411  * @param channel_num LEDC channel index (0-7), select from ledc_channel_t
412  * @param intr_status The fade end interrupt status
413  *
414  * @return None
415  */
ledc_ll_get_fade_end_intr_status(ledc_dev_t * hw,ledc_mode_t speed_mode,uint32_t * intr_status)416 static inline void ledc_ll_get_fade_end_intr_status(ledc_dev_t *hw, ledc_mode_t speed_mode, uint32_t *intr_status){
417     uint32_t value = hw->int_st.val;
418     uint32_t int_en_base = (speed_mode == LEDC_LOW_SPEED_MODE) ? LEDC_DUTY_CHNG_END_LSCH0_INT_ENA_S : LEDC_DUTY_CHNG_END_HSCH0_INT_ENA_S;
419     *intr_status = (value >> int_en_base) & 0xff;
420 }
421 
422 /**
423  * @brief Clear fade end interrupt status
424  *
425  * @param hw Beginning address of the peripheral registers
426  * @param speed_mode LEDC speed_mode, high-speed mode or low-speed mode
427  * @param channel_num LEDC channel index (0-7), select from ledc_channel_t
428  *
429  * @return None
430  */
ledc_ll_clear_fade_end_intr_status(ledc_dev_t * hw,ledc_mode_t speed_mode,ledc_channel_t channel_num)431 static inline void ledc_ll_clear_fade_end_intr_status(ledc_dev_t *hw, ledc_mode_t speed_mode, ledc_channel_t channel_num){
432     uint32_t int_en_base = (speed_mode == LEDC_LOW_SPEED_MODE) ? LEDC_DUTY_CHNG_END_LSCH0_INT_ENA_S : LEDC_DUTY_CHNG_END_HSCH0_INT_ENA_S;
433     hw->int_clr.val = BIT(int_en_base + channel_num);
434 }
435 
436 /**
437  * @brief Set timer index of the specified channel
438  *
439  * @param hw Beginning address of the peripheral registers
440  * @param speed_mode LEDC speed_mode, high-speed mode or low-speed mode
441  * @param channel_num LEDC channel index (0-7), select from ledc_channel_t
442  * @param timer_sel LEDC timer index (0-3), select from ledc_timer_t
443  *
444  * @return None
445  */
ledc_ll_bind_channel_timer(ledc_dev_t * hw,ledc_mode_t speed_mode,ledc_channel_t channel_num,ledc_timer_t timer_sel)446 static inline void ledc_ll_bind_channel_timer(ledc_dev_t *hw, ledc_mode_t speed_mode, ledc_channel_t channel_num, ledc_timer_t timer_sel){
447     hw->channel_group[speed_mode].channel[channel_num].conf0.timer_sel = timer_sel;
448 }
449 
450 /**
451  * @brief Get timer index of the specified channel
452  *
453  * @param hw Beginning address of the peripheral registers
454  * @param speed_mode LEDC speed_mode, high-speed mode or low-speed mode
455  * @param channel_num LEDC channel index (0-7), select from ledc_channel_t
456  * @param timer_sel Pointer to accept the LEDC timer index
457  *
458  * @return None
459  */
ledc_ll_get_channel_timer(ledc_dev_t * hw,ledc_mode_t speed_mode,ledc_channel_t channel_num,ledc_timer_t * timer_sel)460 static inline void ledc_ll_get_channel_timer(ledc_dev_t *hw, ledc_mode_t speed_mode, ledc_channel_t channel_num, ledc_timer_t *timer_sel){
461     *timer_sel = hw->channel_group[speed_mode].channel[channel_num].conf0.timer_sel;
462 }
463 
464 #ifdef __cplusplus
465 }
466 #endif
467