Pixel7Pro_FHD_WL568_OLED_BC/src/sdk/include/hal_pwm.h

220 lines
6.5 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*******************************************************************************
*
*
* File: hal_pwm.h
* Description pwm HAL层头文件
* Version V0.1
* Date 2021-03-17
* Author wuc
*******************************************************************************/
#ifndef __HAL_PWM_H__
#define __HAL_PWM_H__
/*******************************************************************************
* 1.Included files
*******************************************************************************/
#include "tau_device_datatype.h"
#include "tau_common.h"
#include "hal_gpio.h"
/*******************************************************************************
* 2.Global constant and macro definitions using #define
*******************************************************************************/
/*******************************************************************************
* 3.Global structures, unions and enumerations using typedef
*******************************************************************************/
/*! @brief PWM触发功能的定义 */
typedef enum _pwm_out_ctrl_e
{
PWMO_CTRL_KEEP = 0,
PWMO_CTRL_LOW = 1,
PWMO_CTRL_HIGH = 2,
PWMO_CTRL_TOGGLE = 3,
PWMO_CTRL_MAX
} pwm_out_ctrl_e;
/*******************************************************************************
* 4.Global variable extern declarations
*******************************************************************************/
/*******************************************************************************
* 5.Global function prototypes
*******************************************************************************/
/**
* @brief PWMO初始化
* @param 无
* @retval 无
*/
void hal_pwm_out_init(void);
/**
* @brief PWMO反初始化
* @param 无
* @retval 无
*/
void hal_pwm_out_deinit(void);
/**
* @brief PWMO输出脉冲暂停、恢复
* @param state开关控制
* @retval 无
*/
void hal_pwm_out_pause(function_state_e state);
/**
* @brief 配置PWMO脉冲并开始输出
* @param ctl0到达阈值thr0时的操作参考枚举类型pwm_out_ctrl_e
* @param ctl1到达阈值thr1时的操作参考枚举类型pwm_out_ctrl_e
* @param thr0阈值0单位us
* @param thr1阈值1单位us
* @param period一个周期的时间单位us
* @retval 无
*/
void hal_pwm_out_config_all(pwm_out_ctrl_e ctl0, pwm_out_ctrl_e ctl1, uint32_t thr0, uint32_t thr1, uint32_t period);
/**
* @brief 在同步所有模式下配置PWMO脉冲所有参数
* @param ctl0到达阈值thr0时的操作参考枚举类型pwm_out_ctrl_e
* @param ctl1到达阈值thr1时的操作参考枚举类型pwm_out_ctrl_e
* @param thr0阈值0单位us
* @param thr1阈值1单位us
* @param period一个周期的时间单位us
* @retval 无
*/
void hal_pwm_out_sync_all(pwm_out_ctrl_e ctl0, pwm_out_ctrl_e ctl1, uint32_t thr0, uint32_t thr1, uint32_t period);
/**
* @brief 调制pwm输出以控制背光
* @param polarity: 极性false:先高后低true:先低后高
* @param duty_ratio: 占空比(0-total_ratio)
* @param total_ratio: 可细分总量
* @param frequency: 频率单位HZ
* @retval 无
*/
void hal_pwm_out_config_duty_ratio(bool polarity, uint16_t duty_ratio, uint16_t total_ratio, uint32_t frequency);
/**
* @brief 在同步周期模式下配置PWMO脉冲的周期
* @param period一个周期的时间单位us
* @retval 无
*/
void hal_pwm_out_sync_period(uint32_t period);
/**
* @brief 在同步控制模式下配置PWMO脉冲的控制
* @param ctl0到达阈值thr0时的操作参考枚举类型pwm_out_ctrl_e
* @param ctl1到达阈值thr1时的操作参考枚举类型pwm_out_ctrl_e
* @retval 无
*/
void hal_pwm_out_sync_ctl(pwm_out_ctrl_e ctl0, pwm_out_ctrl_e ctl1);
/**
* @brief 在同步阈值模式下配置PWMO脉冲的阈值
* @param thr0阈值0单位us
* @param thr1阈值1单位us
* @retval 无
*/
void hal_pwm_out_sync_thr(uint32_t thr0, uint32_t thr1);
/**
* @brief 在同步暂停模式下暂停或恢复PWMO脉冲
* @param pause_state暂停或恢复
* @retval 无
*/
void hal_pwm_out_sync_pause(function_state_e pause_state);
/**
* @brief PWMI初始化
* @param 无
* @retval 无
*/
void hal_pwm_in_init(void);
/**
* @brief PWMI反初始化
* @param 无
* @retval 无
*/
void hal_pwm_in_deinit(void);
/**
* @brief 注册PWMI中断回调函数回传PWMI中断类型指针参考pwm_int_type_e
* @param cb_func回调函数地址
* @retval 无
*/
void hal_pwm_in_register_callback(fcb_type cb_func);
/**
* @brief 配置PWMI所有中断的开关
* @param high_overflow_enhigh overflow中断使能开关
* @param low_overflow_enlow overflow中断使能开关
* @param total_overflow_entotal overflow中断使能开关
* @param high_done_enhigh done中断使能开关
* @param low_done_enlow done中断使能开关
* @param total_done_entotal done中断使能开关
* @retval 无
*/
void hal_pwm_in_config_int(function_state_e high_overflow_en, function_state_e low_overflow_en, function_state_e total_overflow_en,
function_state_e high_done_en, function_state_e low_done_en, function_state_e total_done_en);
/**
* @brief 配置PWMI单个中断的开关
* @param pwm_int中断类型参考枚举类型pwm_int_type_e
* @param enable控制开关
* @retval 无
*/
void hal_pwm_in_set_int(pwm_int_type_e pwm_int, function_state_e enable);
/**
* @brief 关闭PWMI所有中断
* @param 无
* @retval 无
*/
void hal_pwm_in_clear_int(void);
/**
* @brief 开关PWMI中断
* @param state开关控制
* @retval 无
*/
void hal_pwm_in_ctrl_int(function_state_e state);
/**
* @brief 获取PWMI脉冲周期时长
* @param 无
* @retval 周期时长单位us
*/
uint32_t hal_pwm_in_get_total_period(void);
/**
* @brief 获取PWMI脉冲高电平时长
* @param 无
* @retval 高电平时长单位us
*/
uint32_t hal_pwm_in_get_high_period(void);
/**
* @brief 获取PWMI脉冲低电平时长
* @param 无
* @retval 低电平时长单位us
*/
uint32_t hal_pwm_in_get_low_period(void);
/**
* @brief 获取PWMI上升沿累积个数
* @param 无
* @retval 从模块使能到当前时间的上升沿个数超过32位宽后清零重新计数
*/
uint32_t hal_pwm_in_get_current_count(void);
#if defined(ISP_568) || defined(ISP_368)
/**
* @brief 选择PWMO输出的IO口
* @param pad: PWMO输出的IO口,默认为IO_PAD_AP_SWIRE,可选通过IO_PAD_TD_SPIM_MISO、IO_PAD_TD_LEDPWM输出
* @retval 无
*/
void hal_pwm_out_sel_io(io_pad_e pad);
#endif
#endif /* __HAL_PWM_H__ */