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 HAL layer for LEDC (common part, in iram)
16 // make these functions in a seperate file to make sure all LL functions are in the IRAM.
17
18 #include "esp_attr.h"
19 #include "hal/ledc_hal.h"
20
ledc_hal_ls_channel_update(ledc_hal_context_t * hal,ledc_channel_t channel_num)21 void ledc_hal_ls_channel_update(ledc_hal_context_t *hal, ledc_channel_t channel_num)
22 {
23 ledc_ll_ls_channel_update(hal->dev, hal->speed_mode, channel_num);
24 }
25
ledc_hal_set_hpoint(ledc_hal_context_t * hal,ledc_channel_t channel_num,uint32_t hpoint_val)26 void ledc_hal_set_hpoint(ledc_hal_context_t *hal, ledc_channel_t channel_num, uint32_t hpoint_val)
27 {
28 ledc_ll_set_hpoint(hal->dev, hal->speed_mode, channel_num, hpoint_val);
29 }
30
ledc_hal_get_duty(ledc_hal_context_t * hal,ledc_channel_t channel_num,uint32_t * duty_val)31 void ledc_hal_get_duty(ledc_hal_context_t *hal, ledc_channel_t channel_num, uint32_t *duty_val)
32 {
33 ledc_ll_get_duty(hal->dev, hal->speed_mode, channel_num, duty_val);
34 }
35
ledc_hal_set_duty_direction(ledc_hal_context_t * hal,ledc_channel_t channel_num,ledc_duty_direction_t duty_direction)36 void ledc_hal_set_duty_direction(ledc_hal_context_t *hal, ledc_channel_t channel_num, ledc_duty_direction_t duty_direction)
37 {
38 ledc_ll_set_duty_direction(hal->dev, hal->speed_mode, channel_num, duty_direction);
39 }
40
ledc_hal_set_duty_num(ledc_hal_context_t * hal,ledc_channel_t channel_num,uint32_t duty_num)41 void ledc_hal_set_duty_num(ledc_hal_context_t *hal, ledc_channel_t channel_num, uint32_t duty_num)
42 {
43 ledc_ll_set_duty_num(hal->dev, hal->speed_mode, channel_num, duty_num);
44 }
45
ledc_hal_set_duty_cycle(ledc_hal_context_t * hal,ledc_channel_t channel_num,uint32_t duty_cycle)46 void ledc_hal_set_duty_cycle(ledc_hal_context_t *hal, ledc_channel_t channel_num, uint32_t duty_cycle)
47 {
48 ledc_ll_set_duty_cycle(hal->dev, hal->speed_mode, channel_num, duty_cycle);
49 }
50
ledc_hal_set_duty_scale(ledc_hal_context_t * hal,ledc_channel_t channel_num,uint32_t duty_scale)51 void ledc_hal_set_duty_scale(ledc_hal_context_t *hal, ledc_channel_t channel_num, uint32_t duty_scale)
52 {
53 ledc_ll_set_duty_scale(hal->dev, hal->speed_mode, channel_num, duty_scale);
54 }
55
ledc_hal_get_fade_end_intr_status(ledc_hal_context_t * hal,uint32_t * intr_status)56 void ledc_hal_get_fade_end_intr_status(ledc_hal_context_t *hal, uint32_t *intr_status)
57 {
58 ledc_ll_get_fade_end_intr_status(hal->dev, hal->speed_mode, intr_status);
59 }
60
ledc_hal_clear_fade_end_intr_status(ledc_hal_context_t * hal,ledc_channel_t channel_num)61 void ledc_hal_clear_fade_end_intr_status(ledc_hal_context_t *hal, ledc_channel_t channel_num)
62 {
63 ledc_ll_clear_fade_end_intr_status(hal->dev, hal->speed_mode, channel_num);
64 }
65