You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

127 lines
5.0 KiB

/*
* Copyright (c) Hisilicon Technologies Co., Ltd. 2012-2019. All rights reserved.
* Description: supply the api for userspace application
*/
#ifndef UAPI_PWM_H
#define UAPI_PWM_H
#include "td_type.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif
#endif
/* Define the PWM attributes */
/* CNcomment: 定义PWM属性结构体 */
typedef struct {
/* < Frequency(HZ) */ /* < CNcomment: 频率, 单位HZ */
td_u32 pwm_frequency;
/* < Duty ratio(calculated to three decimal places) */ /* * <CNcomment: 占空比,保留小数点后三位 */
td_u32 pwm_duty_ratio;
} uapi_pwm_attr;
/*
* \brief Initializes the PWM module.CNcomment:PWM CNend
* \attention \n
* Before calling anyother interface, you must call this application programming interface (API) first.
* CNcomment PWM CNend
* \param N/A
* \retval ::TD_SUCCESS Success CNcomment: CNend
* \retval ::SOC_ERR_PWM_DEV_NOT_EXIST There is no PWM. CNcomment:PWM CNend
* \retval ::SOC_ERR_PWM_OPEN_ERR Open PWM failed. CNcomment:PWM CNend
* \see \n
* N/A
*/
td_s32 uapi_pwm_init(td_void);
/*
* \brief DeInitializes the PWM module.CNcomment:PWM CNend
* \attention N/A
* \param N/A
* \retval ::TD_SUCCESS Success CNcomment: CNend
* \retval ::SOC_ERR_PWM_DEV_NOT_EXIST There is no PWM. CNcomment:PWM CNend
* \retval ::SOC_ERR_PWM_CLOSE_ERR Open PWM failed. CNcomment:PWM CNend
* \see \n
* N/A
*/
td_s32 uapi_pwm_deinit(td_void);
/*
* \brief Set PWM attributes.CNcomment:PWM CNend
* \attention N/A
* \param[in] pwm_id Pin number. CNcomment:PWM
* \param[out] attr Pointer of PWM attributes. CNcomment:PWM::uapi_pwm_attr CNend
* \retval ::TD_SUCCESS Success CNcomment: CNend
* \retval ::SOC_ERR_PWM_INVALID_PARA Parameter is invalid. CNcomment: CNend
* \retval ::SOC_ERR_PWM_INVALID_OPT Opration is invalid. CNcomment: CNend
* \see \n
* N/A
*/
td_s32 uapi_pwm_get_attr(td_u32 pwm_id, uapi_pwm_attr *pwm_attr);
/*
* \brief Set PWM attributes.CNcomment:PWM CNend
* \attention N/A
* \param[in] pwm_id Pin number. CNcomment:PWM
* \param[in] attr Pointer of PWM attributes. CNcomment:PWM::uapi_pwm_attr CNend
* \retval ::TD_SUCCESS Success CNcomment: CNend
* \retval ::SOC_ERR_PWM_INVALID_PARA Parameter is invalid. CNcomment: CNend
* \retval ::SOC_ERR_PWM_INVALID_OPT Opration is invalid. CNcomment: CNend
* \see \n
* N/A
*/
td_s32 uapi_pwm_set_attr(td_u32 pwm_id, const uapi_pwm_attr *pwm_attr);
/*
* \brief Send signal to PWM.CNcomment:PWM CNend
* \attention N/A
* \param[in] pwm_id Pin number. CNcomment:PWM
* \param[in] carrier_time The duration of carrier signal(us). CNcomment:(us) CNend
* \param[in] low_level_time The duration of low-level signal(us). CNcomment:(us) CNend
* \retval ::TD_SUCCESS Success CNcomment: CNend
* \retval ::SOC_ERR_PWM_INVALID_PARA Parameter is invalid. CNcomment: CNend
* \retval ::SOC_ERR_PWM_INVALID_OPT Opration is invalid. CNcomment: CNend
* \see \n
* N/A
*/
td_s32 uapi_pwm_send_signal(td_u32 pwm_id, td_u32 carrier_time, td_u32 low_level_time);
/*
* \brief Set enable PWM.CNcomment:PWM使 CNend
* \attention N/A
* \param[in] pwm_id Pin number. CNcomment:PWM
* \param[in] eable enable or disable PWM. CNcomment:使使PWM CNend
* \retval ::TD_SUCCESS Success CNcomment: CNend
* \retval ::SOC_ERR_PWM_INVALID_PARA Parameter is invalid. CNcomment: CNend
* \retval ::SOC_ERR_PWM_INVALID_OPT Opration is invalid. CNcomment: CNend
* \see \n
* N/A
*/
td_s32 uapi_pwm_set_enable(td_u32 pwm_id, td_bool enable);
/*
* \brief Set PWM attributes.CNcomment:MOTO-PWM CNend
* \attention n
* This interface does not support continuous configuration. Disable this interface after it is used.
* CNcomment 使使 CNend
* \param[in] pwm_id Pin number. CNcomment:PWM
* \param[in] attr Pointer of PWM attributes. CNcomment:PWM::uapi_pwm_attr CNend
* \param[in] time_us Pwm wave output duration CNcomment:PWM(:us)
* \retval ::TD_SUCCESS Success CNcomment: CNend
* \retval ::SOC_ERR_PWM_INVALID_PARA Parameter is invalid. CNcomment: CNend
* \retval ::SOC_ERR_PWM_INVALID_OPT Opration is invalid. CNcomment: CNend
* \see \n
* N/A
*/
td_s32 uapi_pwm_moto_trigger(td_u32 pwm_id, const uapi_pwm_attr *pwm_attr, td_u32 time_us);
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif
#endif /* UAPI_PWM_H */