ESP8266_RTOS_SDK  v1.4.0
Data Structures | Macros | Functions
PWM Driver APIs

PWM driver APIs. More...

Data Structures

struct  pwm_param
 

Macros

#define PWM_DEPTH   1023
 

Functions

void pwm_init (uint32 period, uint32 *duty, uint32 pwm_channel_num, uint32(*pin_info_list)[3])
 PWM function initialization, including GPIO, frequency and duty cycle. More...
 
void pwm_set_duty (uint32 duty, uint8 channel)
 Set the duty cycle of a PWM channel. More...
 
uint32 pwm_get_duty (uint8 channel)
 Get the duty cycle of a PWM channel. More...
 
void pwm_set_period (uint32 period)
 Set PWM period, unit : us. More...
 
uint32 pwm_get_period (void)
 Get PWM period, unit : us. More...
 
void pwm_start (void)
 Starts PWM. More...
 

Detailed Description

PWM driver APIs.

Function Documentation

uint32 pwm_get_duty ( uint8  channel)

Get the duty cycle of a PWM channel.

Parameters
uint8channel : PWM channel number
Returns
Duty cycle of PWM output.
uint32 pwm_get_period ( void  )

Get PWM period, unit : us.

Parameters
null
Returns
PWM period, unit : us.
void pwm_init ( uint32  period,
uint32 *  duty,
uint32  pwm_channel_num,
uint32(*)  pin_info_list[3] 
)

PWM function initialization, including GPIO, frequency and duty cycle.

Attention
This API can be called only once.
Parameters
uint32period : pwm frequency
uint32*duty : duty cycle
uint32pwm_channel_num : PWM channel number
uint32(*pin_info_list)[3] : GPIO parameter of PWM channel, it is a pointer of n x 3 array which defines GPIO register, IO reuse of corresponding pin and GPIO number.
Returns
null
void pwm_set_duty ( uint32  duty,
uint8  channel 
)

Set the duty cycle of a PWM channel.

Set the time that high level signal will last, duty depends on period, the maximum value can be 1023.

Attention
After set configuration, pwm_start needs to be called to take effect.
Parameters
uint32duty : duty cycle
uint8channel : PWM channel number
Returns
null
void pwm_set_period ( uint32  period)

Set PWM period, unit : us.

For example, for 1KHz PWM, period is 1000 us.

Attention
After set configuration, pwm_start needs to be called to take effect.
Parameters
uint32period : PWM period, unit : us.
Returns
null
void pwm_start ( void  )

Starts PWM.

Attention
This function needs to be called after PWM configuration is changed.
Parameters
null
Returns
null