PWM_TIMER HAL¶
The PWM_TIMER HAL definitions is in dev_pwm_timer.h
, it provide interfaces for pwm_timer
driver to implement. Here is a diagram for the pwm_timer interface.
Definitions¶
-
group
DEVICE_HAL_PWM_TIMER_DEVSTRUCT
Contains definitions of pwm_timer device interface structure.
This structure will be used in user implemented code, which was called Device Driver Implement Layer for pwm_timer to use in implementation code. Application developer should use the PWM_TIMER API provided here to access to PWM_TIMER devices. BSP developer should follow the API definition to implement PWM_TIMER device drivers.
Typedefs
-
typedef struct dev_pwm_timer_info
DEV_PWM_TIMER_INFO
¶ PWM_TIMER information struct definition.
informations about pwm_timer open count, working status, pwm_timer registers and ctrl structure
-
typedef struct dev_pwm_timer_info *
DEV_PWM_TIMER_INFO_PTR
¶
-
typedef struct dev_pwm_timer
DEV_PWM_TIMER
¶ PWM_TIMER device interface definition.
Define pwm_timer device interface, like pwm_timer information structure, provide functions to open/close/control pwm_timer, send/receive data by pwm_timer
Note
All this details are implemented by user in user porting code
-
typedef struct dev_pwm_timer *
DEV_PWM_TIMER_PTR
¶
Variables
-
int32_t (*
pwm_timer_open
)(void)¶ Open pwm_timer device
open pwm_timer device
- Returns
E_OK – Open successfully without any issues
E_OPNED – If device was opened before with different parameters, then just increase the opn_cnt and return E_OPNED
E_OBJ – Device object is not valid
E_PAR – Parameter is not valid
E_NOSPT – Open settings are not supported
-
int32_t (*
pwm_timer_close
)(void)¶ Close pwm_timer device
close an pwm_timer device, just decrease the opn_cnt, if opn_cnt equals 0, then close the device
- Returns
E_OK – Close successfully without any issues(including scenario that device is already closed)
E_OPNED – Device is still opened, the device opn_cnt decreased by 1
E_OBJ – Device object is not valid
-
int32_t (*
pwm_timer_control
)(uint32_t ch, uint32_t cmd, void *param2)¶ Control pwm_timer device
control an pwm_timer device [channel number: ch] by ctrl_cmd, with passed param.
- Parameters
ch – [in] channel number of pwm_timer to control, must >= 0
ctrl_cmd – [in] control command, to change or get some thing related to pwm_timer
param – [inout] parameters that maybe argument of the command, or return values of the command
- Returns
E_OK – Control device successfully
E_CLSED – Device is not opened
E_OBJ – Device object is not valid or not exists
E_PAR – Parameter is not valid for current control command
E_SYS – Control device failed, due to hardware issues, such as device is disabled
E_CTX – Control device failed, due to different reasons like in transfer state
E_NOSPT – Control command is not supported or not valid
-
int32_t (*
pwm_timer_write
)(uint32_t ch, uint32_t mode, uint32_t freq, uint32_t dc)¶ Set the configuration of pwm_timer
set the configuration of pwm_timer.
- Parameters
ch – [in] channel number of pwm_timer to write, must >= 0
mode – [in] set the mode of pwm_timer, must not be NULL
freq – [in] set the frequency of pwm_timer, must not be NULL
dc – [in] set the duty cycle of pwm_timer, must not be NULL
- Returns
E_OK – set device successfully
E_OBJ – Device object is not valid or not exists
E_PAR – Parameter is not valid
E_SYS – Can’t receive data from hardware due to hardware issues, such as device is disabled
-
int32_t (*
pwm_timer_read
)(uint32_t ch, uint32_t *mode, uint32_t *freq, uint32_t *dc)¶ Read the configuration of pwm_timer
read the configuration of pwm_timer.
- Parameters
ch – [in] channel number of pwm_timer to read, must >= 0
mode – [out] pointer to data mode of pwm_timer, must not be NULL
freq – [out] pointer to data frequency of pwm_timer, must not be NULL
dc – [out] pointer to data duty cycle of pwm_timer, must not be NULL
- Returns
E_OK – Read device successfully
E_OBJ – Device object is not valid or not exists
E_PAR – Parameter is not valid
E_SYS – Can’t receive data from hardware due to hardware issues, such as device is disabled
-
struct
dev_pwm_timer_info
¶ - #include <dev_pwm_timer.h>
PWM_TIMER information struct definition.
informations about pwm_timer open count, working status, pwm_timer registers and ctrl structure
-
struct
dev_pwm_timer
¶ - #include <dev_pwm_timer.h>
PWM_TIMER device interface definition.
Define pwm_timer device interface, like pwm_timer information structure, provide functions to open/close/control pwm_timer, send/receive data by pwm_timer
Note
All this details are implemented by user in user porting code
-
typedef struct dev_pwm_timer_info