pwm.h File Reference

Go to the source code of this file.

Enumerations

enum  pwm_id {
  PWM0_ID = 0, PWM1_ID, PWM2_ID, PWM3_ID,
  PWM4_ID, PWM5_ID
}
 enum variable, the number of PWM channels supported More...
 
enum  pwm_mode {
  PWM_NORMAL_MODE = 0x00, PWM_COUNT_MODE = 0x01, PWM_IR_MODE = 0x03, PWM_IR_FIFO_MODE = 0x07,
  PWM_IR_DMA_FIFO_MODE = 0x0F
}
 enum variable used for PWM work mode setting More...
 
enum  PWM_IRQ {
  PWM_IRQ_PWM0_PNUM = BIT(0), PWM_IRQ_PWM0_IR_DMA_FIFO_DONE = BIT(1), PWM_IRQ_PWM0_FRAME = BIT(2), PWM_IRQ_PWM1_FRAME = BIT(3),
  PWM_IRQ_PWM2_FRAME = BIT(4), PWM_IRQ_PWM3_FRAME = BIT(5), PWM_IRQ_PWM4_FRAME = BIT(6), PWM_IRQ_PWM5_FRAME = BIT(7)
}
 
enum  Pwm0Pulse_SelectDef { PWM0_PULSE_NORMAL = 0, PWM0_PULSE_SHADOW = BIT(14) }
 

Functions

static void pwm_set_mode (pwm_id id, pwm_mode mode)
 This fuction servers to set pwm mode. More...
 
static void pwm_set_clk (int system_clock_hz, int pwm_clk)
 This fuction servers to set pwm clock frequency. More...
 
static void pwm_set_cmp (pwm_id id, unsigned short cmp_tick)
 This fuction servers to set pwm count status(CMP) time. More...
 
static void pwm_set_cycle (pwm_id id, unsigned short cycle_tick)
 This fuction servers to set pwm cycle time. More...
 
static void pwm_set_cycle_and_duty (pwm_id id, unsigned short cycle_tick, unsigned short cmp_tick)
 This fuction servers to set pwm cycle time & count status. More...
 
static void pwm_set_pwm0_shadow_cycle_and_duty (unsigned short cycle_tick, unsigned short cmp_tick)
 This fuction servers to set pwm cycle time & count status. More...
 
static void pwm_set_phase (pwm_id id, unsigned short phase)
 This fuction servers to set the pwm phase. More...
 
static void pwm_set_pulse_num (pwm_id id, unsigned short pulse_num)
 This fuction servers to set the pwm pulse number. More...
 
static void pwm_start (pwm_id id)
 This fuction servers to start the pwm. More...
 
static void pwm_stop (pwm_id id)
 This fuction servers to stop the pwm. More...
 
static void pwm_revert (pwm_id id)
 This fuction servers to revert the PWMx. More...
 
static void pwm_n_revert (pwm_id id)
 This fuction servers to revert the PWMx_N. More...
 
static void pwm_polo_enable (pwm_id id, int en)
 This fuction servers to enable the pwm polarity. More...
 
static void pwm_set_interrupt_enable (PWM_IRQ irq)
 This fuction servers to enable the pwm interrupt. More...
 
static void pwm_set_interrupt_disable (PWM_IRQ irq)
 
static void pwm_clear_interrupt_status (PWM_IRQ irq)
 This fuction servers to clear the pwm interrupt. More...
 
static void pwm_ir_fifo_set_irq_trig_level (unsigned char trig_level)
 This fuction serves to set trigger level of interrupt for IR FiFo mode. More...
 
static void pwm_ir_fifo_clr_data (void)
 This fuction serves to clear data in fifo. Only when pwm is in not active mode, it is possible to clear data in fifo. More...
 
static unsigned char pwm_ir_fifo_get_data_num (void)
 This fuction serves to get the number of data in fifo. More...
 
static unsigned char pwm_ir_fifo_is_empty (void)
 This fuction serves to determine whether data in fifo is empty. More...
 
static unsigned char pwm_ir_fifo_is_full (void)
 This fuction serves to determine whether data in fifo is full. More...
 
static void pwm_ir_fifo_set_data_entry (unsigned short pulse_num, unsigned char use_shadow, unsigned char carrier_en)
 This fuction serves to write data into FiFo. More...
 
static unsigned short pwm_config_dma_fifo_waveform (int carrier_en, Pwm0Pulse_SelectDef pulse_type, unsigned short pulse_num)
 This fuction serves to config the pwm's dma wave form. More...
 
static void pwm_set_dma_address (void *pdat)
 This fuction servers to set the pwm's dma address. More...
 
static void pwm_start_dma_ir_sending (void)
 This fuction servers to start the pwm's IRQ sending. More...
 
static void pwm_stop_dma_ir_sending (void)
 This fuction servers to stop the pwm's IRQ sending. More...
 

Enumeration Type Documentation

◆ pwm_id

enum pwm_id

enum variable, the number of PWM channels supported

Enumerator
PWM0_ID 
PWM1_ID 
PWM2_ID 
PWM3_ID 
PWM4_ID 
PWM5_ID 

◆ pwm_mode

enum pwm_mode

enum variable used for PWM work mode setting

Enumerator
PWM_NORMAL_MODE 
PWM_COUNT_MODE 
PWM_IR_MODE 
PWM_IR_FIFO_MODE 
PWM_IR_DMA_FIFO_MODE 

◆ PWM_IRQ

enum PWM_IRQ

pwm interrupt source

Enumerator
PWM_IRQ_PWM0_PNUM 
PWM_IRQ_PWM0_IR_DMA_FIFO_DONE 
PWM_IRQ_PWM0_FRAME 
PWM_IRQ_PWM1_FRAME 
PWM_IRQ_PWM2_FRAME 
PWM_IRQ_PWM3_FRAME 
PWM_IRQ_PWM4_FRAME 
PWM_IRQ_PWM5_FRAME 

◆ Pwm0Pulse_SelectDef

Enumerator
PWM0_PULSE_NORMAL 
PWM0_PULSE_SHADOW 

Function Documentation

◆ pwm_set_mode()

static void pwm_set_mode ( pwm_id  id,
pwm_mode  mode 
)
inlinestatic

This fuction servers to set pwm mode.

Parameters
[in]pwm_id- variable of enum to select the pwm number.
[in]mode- variable of enum to indicates the pwm mode.
Returns
none.

◆ pwm_set_clk()

static void pwm_set_clk ( int  system_clock_hz,
int  pwm_clk 
)
inlinestatic

This fuction servers to set pwm clock frequency.

Parameters
[in]system_clock_hz- variable to set system clock hz.
[in]pwm_clk- variable of the pwm clock.
Returns
none.

◆ pwm_set_cmp()

static void pwm_set_cmp ( pwm_id  id,
unsigned short  cmp_tick 
)
inlinestatic

This fuction servers to set pwm count status(CMP) time.

Parameters
[in]pwm_id- variable of enum to select the pwm number.
[in]cmp_tick- variable of the CMP.
Returns
none.

◆ pwm_set_cycle()

static void pwm_set_cycle ( pwm_id  id,
unsigned short  cycle_tick 
)
inlinestatic

This fuction servers to set pwm cycle time.

Parameters
[in]pwm_id- variable of enum to select the pwm number.
[in]cycle_tick- variable of the cycle time.
Returns
none.

◆ pwm_set_cycle_and_duty()

static void pwm_set_cycle_and_duty ( pwm_id  id,
unsigned short  cycle_tick,
unsigned short  cmp_tick 
)
inlinestatic

This fuction servers to set pwm cycle time & count status.

Parameters
[in]pwm_id- variable of enum to select the pwm number.
[in]cycle_tick- variable of the cycle time.
[in]cmp_tick- variable of the CMP.
Returns
none.

◆ pwm_set_pwm0_shadow_cycle_and_duty()

static void pwm_set_pwm0_shadow_cycle_and_duty ( unsigned short  cycle_tick,
unsigned short  cmp_tick 
)
inlinestatic

This fuction servers to set pwm cycle time & count status.

Parameters
[in]cycle_tick- variable of the cycle time.
[in]cmp_tick- variable of the CMP.
Returns
none.

◆ pwm_set_phase()

static void pwm_set_phase ( pwm_id  id,
unsigned short  phase 
)
inlinestatic

This fuction servers to set the pwm phase.

Parameters
[in]pwm_id- variable of enum to select the pwm number.
[in]phase- variable of the pwm phase.
Returns
none.

◆ pwm_set_pulse_num()

static void pwm_set_pulse_num ( pwm_id  id,
unsigned short  pulse_num 
)
inlinestatic

This fuction servers to set the pwm pulse number.

Parameters
[in]pwm_id- variable of enum to select the pwm number.
[in]pulse_num- variable of the pwm pulse number.
Returns
none.

◆ pwm_start()

static void pwm_start ( pwm_id  id)
inlinestatic

This fuction servers to start the pwm.

Parameters
[in]pwm_id- variable of enum to select the pwm number.
Returns
none.

◆ pwm_stop()

static void pwm_stop ( pwm_id  id)
inlinestatic

This fuction servers to stop the pwm.

Parameters
[in]pwm_id- variable of enum to select the pwm number.
Returns
none.

◆ pwm_revert()

static void pwm_revert ( pwm_id  id)
inlinestatic

This fuction servers to revert the PWMx.

Parameters
[in]pwm_id- variable of enum to select the pwm number.
Returns
none.

◆ pwm_n_revert()

static void pwm_n_revert ( pwm_id  id)
inlinestatic

This fuction servers to revert the PWMx_N.

Parameters
[in]pwm_id- variable of enum to select the pwm number.
Returns
none.

◆ pwm_polo_enable()

static void pwm_polo_enable ( pwm_id  id,
int  en 
)
inlinestatic

This fuction servers to enable the pwm polarity.

Parameters
[in]pwm_id- variable of enum to select the pwm number.
[in]en1 enable. 0 disable.
Returns
none.

◆ pwm_set_interrupt_enable()

static void pwm_set_interrupt_enable ( PWM_IRQ  irq)
inlinestatic

This fuction servers to enable the pwm interrupt.

Parameters
[in]irq- variable of enum to select the pwm interrupt source.
Returns
none.

◆ pwm_set_interrupt_disable()

static void pwm_set_interrupt_disable ( PWM_IRQ  irq)
inlinestatic

◆ pwm_clear_interrupt_status()

static void pwm_clear_interrupt_status ( PWM_IRQ  irq)
inlinestatic

This fuction servers to clear the pwm interrupt.

Parameters
[in]irq- variable of enum to select the pwm interrupt source.
Returns
none.

◆ pwm_ir_fifo_set_irq_trig_level()

static void pwm_ir_fifo_set_irq_trig_level ( unsigned char  trig_level)
inlinestatic

This fuction serves to set trigger level of interrupt for IR FiFo mode.

Parameters
[in]trig_level- FIFO num int trigger level
Returns
none

◆ pwm_ir_fifo_clr_data()

static void pwm_ir_fifo_clr_data ( void  )
inlinestatic

This fuction serves to clear data in fifo. Only when pwm is in not active mode, it is possible to clear data in fifo.

Parameters
[in]none
Returns
none

◆ pwm_ir_fifo_get_data_num()

static unsigned char pwm_ir_fifo_get_data_num ( void  )
inlinestatic

This fuction serves to get the number of data in fifo.

Parameters
[in]none
Returns
the number of data in fifo

◆ pwm_ir_fifo_is_empty()

static unsigned char pwm_ir_fifo_is_empty ( void  )
inlinestatic

This fuction serves to determine whether data in fifo is empty.

Parameters
[in]none
Returns
yes: 1 ,no: 0;

◆ pwm_ir_fifo_is_full()

static unsigned char pwm_ir_fifo_is_full ( void  )
inlinestatic

This fuction serves to determine whether data in fifo is full.

Parameters
[in]none
Returns
yes: 1 ,no: 0;

◆ pwm_ir_fifo_set_data_entry()

static void pwm_ir_fifo_set_data_entry ( unsigned short  pulse_num,
unsigned char  use_shadow,
unsigned char  carrier_en 
)
inlinestatic

This fuction serves to write data into FiFo.

Parameters
[in]pulse_num- the number of pulse
[in]use_shadow- determine whether the configuration of shadow cmp and shadow max is used 1: use shadow, 0: not use
[in]carrier_en- enable sending carrier, 1: enable, 0: disable
Returns
none

◆ pwm_config_dma_fifo_waveform()

static unsigned short pwm_config_dma_fifo_waveform ( int  carrier_en,
Pwm0Pulse_SelectDef  pulse_type,
unsigned short  pulse_num 
)
inlinestatic

This fuction serves to config the pwm's dma wave form.

Parameters
[in]carrier_en- must 1 or 0.
[in]pulse_type- type of pwm0's pulse.
[in]pulse_num- the number of pulse.
Returns
none.

◆ pwm_set_dma_address()

static void pwm_set_dma_address ( void *  pdat)
inlinestatic

This fuction servers to set the pwm's dma address.

Parameters
[in]pdat- variable of pointer to indicate the address.
Returns
none.

◆ pwm_start_dma_ir_sending()

static void pwm_start_dma_ir_sending ( void  )
inlinestatic

This fuction servers to start the pwm's IRQ sending.

Parameters
[in]none.
Returns
none.

◆ pwm_stop_dma_ir_sending()

static void pwm_stop_dma_ir_sending ( void  )
inlinestatic

This fuction servers to stop the pwm's IRQ sending.

Parameters
[in]none.
Returns
none.