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.

PWM_TIMER HAL

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

Return Value
  • 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

Return Value
  • 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
  • [in] ch: channel number of pwm_timer to control, must >= 0

  • [in] ctrl_cmd: control command, to change or get some thing related to pwm_timer

  • [inout] param: parameters that maybe argument of the command, or return values of the command

Return Value
  • 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
  • [in] ch: channel number of pwm_timer to write, must >= 0

  • [in] mode: set the mode of pwm_timer, must not be NULL

  • [in] freq: set the frequency of pwm_timer, must not be NULL

  • [in] dc: set the duty cycle of pwm_timer, must not be NULL

Return Value
  • 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
  • [in] ch: channel number of pwm_timer to read, must >= 0

  • [out] mode: pointer to data mode of pwm_timer, must not be NULL

  • [out] freq: pointer to data frequency of pwm_timer, must not be NULL

  • [out] dc: pointer to data duty cycle of pwm_timer, must not be NULL

Return Value
  • 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