Pixel7Pro_FHD_WL568_OLED_BC/src/sdk/include/hal_pwm.h

220 lines
6.5 KiB
C
Raw Normal View History

/*******************************************************************************
*
*
* 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 ctl0thr0时的操作pwm_out_ctrl_e
* @param ctl1thr1时的操作pwm_out_ctrl_e
* @param thr00us
* @param thr11us
* @param periodus
* @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 ctl0thr0时的操作pwm_out_ctrl_e
* @param ctl1thr1时的操作pwm_out_ctrl_e
* @param thr00us
* @param thr11us
* @param periodus
* @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 periodus
* @retval
*/
void hal_pwm_out_sync_period(uint32_t period);
/**
* @brief PWMO脉冲的控制
* @param ctl0thr0时的操作pwm_out_ctrl_e
* @param ctl1thr1时的操作pwm_out_ctrl_e
* @retval
*/
void hal_pwm_out_sync_ctl(pwm_out_ctrl_e ctl0, pwm_out_ctrl_e ctl1);
/**
* @brief PWMO脉冲的阈值
* @param thr00us
* @param thr11us
* @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_intpwm_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_MISOIO_PAD_TD_LEDPWM输出
* @retval
*/
void hal_pwm_out_sel_io(io_pad_e pad);
#endif
#endif /* __HAL_PWM_H__ */