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

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

/*
* 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 */