添加一些ledc注释

This commit is contained in:
2025-03-27 19:09:12 +08:00
parent 80cc752148
commit 4315af5d2c
3 changed files with 31 additions and 10 deletions

View File

@@ -116,7 +116,7 @@ void ledc_timer_ctrl(LEDC_PORT port, uint8_t status);
void ledc_cnt_ena(LEDC_PORT port, uint8_t status);
/**
* @brief ledc_polarity_sel() - ledc输出极性选择
* @brief ledc_polarity_sel() - ledc输出极性选择
* @param port: ledc 通道
* @param polarity: OUT_POL_ORIGINAL 不反相
* OUT_POL_INVERT 反相
@@ -124,7 +124,8 @@ void ledc_cnt_ena(LEDC_PORT port, uint8_t status);
void ledc_polarity_sel(LEDC_PORT port, uint8_t polarity);
/**
* @brief ledc_idle_level_sel() - ledc空闲时电平状态选择
* @brief ledc_idle_level_sel() - ledc空闲时电平状态选择
* 空闲是指关闭占空比的情况
* @param port: ledc 通道
* @param level: IDLE_LEVEL_HIGH 空闲时为高电平
* IDLE_LEVEL_LOW 空闲时为低电平
@@ -168,7 +169,7 @@ void ledc_l2h_point_set(LEDC_PORT port, uint16_t point);
void ledc_duty_cnt_sel(LEDC_PORT port, uint8_t duty_cnt);
/**
* @brief ledc_thrs_set() - 计数器阈值设置
* @brief ledc_thrs_set() - 计数器阈值设置,计数器大于这个值之后会重新开始计数
* @param port: ledc 通道
* @param thrs: 阈值范围0-0xffff
*/
@@ -211,35 +212,36 @@ void ledc_phase1_mode_sel(LEDC_PORT port, uint8_t mode);
void ledc_phase2_mode_sel(LEDC_PORT port, uint8_t mode);
/**
* @brief ledc_phase1_scale_set() - phase1的渐变幅度设置
* @brief ledc_phase1_scale_set() - phase1的渐变幅度设置scale为一次计数器周期中变化的count数
* @param port: ledc 通道
* @param scale: 范围 0-0xff
*/
void ledc_phase1_scale_set(LEDC_PORT port, uint8_t scale);
/**
* @brief ledc_phase2_scale_set() - phase2的渐变幅度设置
* @brief ledc_phase2_scale_set() - phase2的渐变幅度设置scale为一次计数器周期中变化的count数
* @param port: ledc 通道
* @param scale: 范围 0-0xff
*/
void ledc_phase2_scale_set(LEDC_PORT port, uint8_t scale);
/**
* @brief ledc_cycle_times_set() - 设置一个loop里有多少个cycle
* @brief ledc_cycle_times_set() - 设置一个loop里有多少个cycle,
* phase1 blink加上phase2 blink所使用的时间为一个cycle
* @param port: ledc 通道
* @param times: 范围 0-0xff
*/
void ledc_cycle_times_set(LEDC_PORT port, uint8_t times);
/**
* @brief ledc_cycle_times_set() - 设置一共多少个loop
* @brief ledc_loop_times_set() - 设置一共多少个loop
* @param port: ledc 通道
* @param times: 范围 0-0xff
*/
void ledc_loop_times_set(LEDC_PORT port, uint8_t times);
/**
* @brief ledc_nop_num_set() - 设置一共多少个loop
* @brief ledc_nop_num_set() - 设置一个loop里有多少个nop计数器周期,这个时候处于空闲状态
* @param port: ledc 通道
* @param times: 范围 0-0xff
*/
@@ -253,7 +255,7 @@ void ledc_nop_num_set(LEDC_PORT port, uint16_t num);
void ledc_common_cnt_ena(uint8_t en);
/**
* @brief ledc_common_thrs_set() - 共用计数器阈值设置
* @brief ledc_common_thrs_set() - 共用计数器阈值设置,计数器大于这个值之后会重新开始计数
* @param thrs: 阈值范围0-0xffff
*/
void ledc_common_thrs_set(uint16_t thrs);

View File

@@ -137,6 +137,7 @@ void ledc_gpio_config(LEDC_PORT port, uint8_t gpio)
gpio_module_sig_select(&info, GPIO_MTX_MODE_MATRIX);
}
// 定时器复位
void ledc_timer_rst(LEDC_PORT port)
{
uint32_t tmp;
@@ -152,6 +153,7 @@ void ledc_timer_rst(LEDC_PORT port)
timer_hw_write_reg(port, CFG_LEDC_TIMER0_CONF_ADDR, tmp);
}
// 定时器初始化 div是分频实际分频为div+1
void ledc_timer_init(LEDC_PORT port, uint16_t div)
{
uint32_t tmp;
@@ -165,6 +167,7 @@ void ledc_timer_init(LEDC_PORT port, uint16_t div)
timer_hw_write_reg(port, CFG_LEDC_TIMER0_CONF_ADDR, tmp);
}
// 定时器启动或暂停 1启动 0暂停
void ledc_timer_ctrl(LEDC_PORT port, uint8_t status)
{
uint32_t tmp;
@@ -185,6 +188,7 @@ void ledc_timer_ctrl(LEDC_PORT port, uint8_t status)
timer_hw_write_reg(port, CFG_LEDC_TIMER0_CONF_ADDR, tmp);
}
// 输出极性 1反向 0不反向
void ledc_polarity_sel(LEDC_PORT port, uint8_t polarity)
{
uint32_t tmp;
@@ -198,6 +202,7 @@ void ledc_polarity_sel(LEDC_PORT port, uint8_t polarity)
ledc_hw_write_reg(port, CFG_LEDC0_CONF_ADDR, tmp);
}
// 空闲时状态 1空闲时高 0 空闲时低
void ledc_idle_level_sel(LEDC_PORT port, uint8_t level)
{
uint32_t tmp;
@@ -211,6 +216,7 @@ void ledc_idle_level_sel(LEDC_PORT port, uint8_t level)
ledc_hw_write_reg(port, CFG_LEDC0_CONF_ADDR, tmp);
}
// 相位1闪烁次数
void ledc_phase1_blink_times_set(LEDC_PORT port, uint16_t times)
{
uint32_t tmp;
@@ -225,6 +231,7 @@ void ledc_phase1_blink_times_set(LEDC_PORT port, uint16_t times)
}
// 相位2闪烁次数
void ledc_phase2_blink_times_set(LEDC_PORT port, uint16_t times)
{
uint32_t tmp;
@@ -239,6 +246,7 @@ void ledc_phase2_blink_times_set(LEDC_PORT port, uint16_t times)
}
// 控制脉冲输出由高到低的时钟刻度
void ledc_h2l_point_set(LEDC_PORT port, uint16_t point)
{
uint32_t tmp;
@@ -252,6 +260,7 @@ void ledc_h2l_point_set(LEDC_PORT port, uint16_t point)
ledc_hw_write_reg(port, CFG_LEDC0_DUTY_CONF0_ADDR, tmp);
}
// 控制脉冲由低到高的时钟刻度
void ledc_l2h_point_set(LEDC_PORT port, uint16_t point)
{
uint32_t tmp;
@@ -265,6 +274,7 @@ void ledc_l2h_point_set(LEDC_PORT port, uint16_t point)
ledc_hw_write_reg(port, CFG_LEDC0_DUTY_CONF0_ADDR, tmp);
}
// 选择计数器 0使用自身参考时钟 1使用通用时钟
void ledc_duty_cnt_sel(LEDC_PORT port, uint8_t duty_cnt)
{
uint32_t tmp;
@@ -278,6 +288,7 @@ void ledc_duty_cnt_sel(LEDC_PORT port, uint8_t duty_cnt)
ledc_hw_write_reg(port, CFG_LEDC0_DUTY_CONF1_ADDR, tmp);
}
// 打开占空比计数
void ledc_cnt_ena(LEDC_PORT port, uint8_t en)
{
uint32_t tmp;
@@ -291,6 +302,7 @@ void ledc_cnt_ena(LEDC_PORT port, uint8_t en)
ledc_hw_write_reg(port, CFG_LEDC0_DUTY_CONF1_ADDR, tmp);
}
// 设置占空比阈值
void ledc_thrs_set(LEDC_PORT port, uint16_t thrs)
{
uint32_t tmp;
@@ -304,6 +316,7 @@ void ledc_thrs_set(LEDC_PORT port, uint16_t thrs)
ledc_hw_write_reg(port, CFG_LEDC0_DUTY_CONF1_ADDR, tmp);
}
// 相位模式选择 0普通模式 1相位模式
void ledc_phase_opt_sel(LEDC_PORT port, uint8_t opt)
{
uint32_t tmp;
@@ -317,6 +330,7 @@ void ledc_phase_opt_sel(LEDC_PORT port, uint8_t opt)
ledc_hw_write_reg(port, CFG_LEDC0_DUTY_CONF5_ADDR, tmp);
}
// 相位数量 0单相位 1双相位
void ledc_phase_num_sel(LEDC_PORT port, uint8_t num)
{
uint32_t tmp;
@@ -330,6 +344,7 @@ void ledc_phase_num_sel(LEDC_PORT port, uint8_t num)
ledc_hw_write_reg(port, CFG_LEDC0_DUTY_CONF5_ADDR, tmp);
}
// 相位1的相位模式 0占空比模式 1保持关闭 2递增模式 3递减模式
void ledc_phase1_mode_sel(LEDC_PORT port, uint8_t mode)
{
uint32_t tmp;
@@ -344,6 +359,7 @@ void ledc_phase1_mode_sel(LEDC_PORT port, uint8_t mode)
ledc_hw_write_reg(port, CFG_LEDC0_DUTY_CONF5_ADDR, tmp);
}
// 相位2的相位模式 0占空比模式 1保持关闭 2递增模式 3递减模式
void ledc_phase2_mode_sel(LEDC_PORT port, uint8_t mode)
{
uint32_t tmp;
@@ -359,6 +375,7 @@ void ledc_phase2_mode_sel(LEDC_PORT port, uint8_t mode)
ledc_hw_write_reg(port, CFG_LEDC0_DUTY_CONF5_ADDR, tmp);
}
// 相位1阴影模式下的信号周期变化程度
void ledc_phase1_scale_set(LEDC_PORT port, uint8_t scale)
{
uint32_t tmp;
@@ -372,6 +389,7 @@ void ledc_phase1_scale_set(LEDC_PORT port, uint8_t scale)
ledc_hw_write_reg(port, CFG_LEDC0_DUTY_CONF1_ADDR, tmp);
}
// 相位2阴影模式下的信号周期变化幅度
void ledc_phase2_scale_set(LEDC_PORT port, uint8_t scale)
{
uint32_t tmp;
@@ -385,6 +403,7 @@ void ledc_phase2_scale_set(LEDC_PORT port, uint8_t scale)
ledc_hw_write_reg(port, CFG_LEDC0_DUTY_CONF5_ADDR, tmp);
}
// 无nop状态的循环数
void ledc_cycle_times_set(LEDC_PORT port, uint8_t times)
{
uint32_t tmp;