Azure Sphere MT3620 M4 API Reference Manual
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Function

OS-HAL PWM API list information, including PWM hardware initializing and de-initializing, setting PWM frequency and duty cycle, enabling and disabling PWM hardware output, feature enabling. More...

Overview

OS-HAL PWM API list information, including PWM hardware initializing and de-initializing, setting PWM frequency and duty cycle, enabling and disabling PWM hardware output, feature enabling.

Functions

int mtk_os_hal_pwm_ctlr_init (pwm_groups group_num, u32 channel_bit_map)
 Init PWM controller. More...
 
int mtk_os_hal_pwm_ctlr_deinit (pwm_groups group_num, u32 channel_bit_map)
 Deinit PWM controller. More...
 
int mtk_os_hal_pwm_config_freq_duty_normal (pwm_groups group_num, pwm_channels pwm_num, u32 frequency, u32 duty_cycle)
 Config freq & duty. More...
 
int mtk_os_hal_pwm_feature_enable (pwm_groups group_num, pwm_channels pwm_num, bool global_kick_enable, bool io_ctrl_sel, bool polarity_set)
 PWM feature enable. More...
 
int mtk_os_hal_pwm_config_freq_duty_2_state (pwm_groups group_num, pwm_channels pwm_num, struct mtk_com_pwm_data state_config)
 Config 2-state freq & duty. More...
 
int mtk_os_hal_pwm_config_stay_cycle_2_state (pwm_groups group_num, pwm_channels pwm_num, struct mtk_com_pwm_data state_config)
 Config 2-state stay cycle. More...
 
int mtk_os_hal_pwm_config_dpsel (pwm_groups group_num, pwm_channels pwm_num, pwm_differential_select mode)
 Config dpsel. More...
 
int mtk_os_hal_pwm_start_normal (pwm_groups group_num, pwm_channels pwm_num)
 Start PWM controller. More...
 
int mtk_os_hal_pwm_stop_normal (pwm_groups group_num, pwm_channels pwm_num)
 Stop PWM controller. More...
 

Function Documentation

int mtk_os_hal_pwm_ctlr_init ( pwm_groups  group_num,
u32  channel_bit_map 
)

Init PWM controller.

Parameters
group_num: PWM group number, 0 is group0 , 1 is group1, 2 is group2
channel_bit_map: OS_HAL_PWM_0 = 0x1, OS_HAL_PWM_1 = 0x2, OS_HAL_PWM_2 = 0x4, OS_HAL_PWM_3 = 0x8 For example: use PWM0 and PWM1 channel_bit_map = OS_HAL_PWM_0 | OS_HAL_PWM_1
Returns
If return value is 0, it means success.
If return value is -PWM_EPTR , it means ctlr is NULL.
If return value is -PWM_ECLK , it means clock select invalid.
int mtk_os_hal_pwm_ctlr_deinit ( pwm_groups  group_num,
u32  channel_bit_map 
)

Deinit PWM controller.

Parameters
group_num: PWM group number, 0 is group0 , 1 is group1, 2 is group2
channel_bit_map: OS_HAL_PWM_0 = 0x1, OS_HAL_PWM_1 = 0x2, OS_HAL_PWM_2 = 0x4, OS_HAL_PWM_3 = 0x8 For example: use PWM0 and PWM1 channel_bit_map = OS_HAL_PWM_0 | OS_HAL_PWM_1
Returns
If return value is 0, it means success.
If return value is -PWM_EPTR , it means ctlr is NULL.
If return value is -PWM_EPARAMETER , it means pwm_num is invalid.
int mtk_os_hal_pwm_config_freq_duty_normal ( pwm_groups  group_num,
pwm_channels  pwm_num,
u32  frequency,
u32  duty_cycle 
)

Config freq & duty.

Parameters
group_num: PWM group number, 0 is group0 , 1 is group1, 2 is group2
pwm_num: PWM number, 0 is pwm0 , 1 is pwm1, 2 is pwm2, 3 is pwm3
frequency: PWM frequency select, unit is Hz. if set 1000, waveform frequency is 1000Hz. The maxinum supported frequency is the half of source clock frequency. When using the 26MHz Xtal as clock source, the maxinum supported frequency is 13MHz.
duty_cycle: PWM duty_cycle ,resolution is 0.1, ex: duty is 50%, duty_cycle = (50/0.1) = 500
Returns
If return value is 0, it means success.
If return value is -PWM_EPTR , it means ctlr is NULL.
If return value is -PWM_EPARAMETER , it means pwm_num is invalid.
int mtk_os_hal_pwm_feature_enable ( pwm_groups  group_num,
pwm_channels  pwm_num,
bool  global_kick_enable,
bool  io_ctrl_sel,
bool  polarity_set 
)

PWM feature enable.

Parameters
group_num: PWM group number, 0 is group0 , 1 is group1, 2 is group2
pwm_num: PWM number, 0 is pwm0 , 1 is pwm1, 2 is pwm2, 3 is pwm3
global_kick_enable: PWM global kick feature enable, typical set as 0: pwm channel is independent with other pwm channel, 1: all pwm channel with global_kick_enable set will output waveform at the same time.
io_ctrl_sel: PWM io ctrl select, typical set as 0: PIO as output, when pwm channel is disable, waveform will keep low, 1:open drain.
polarity_set: PWM plus level polarity select, typical set as 0: pwm waveform is high level active, 1:pwm waveform is low level active.
Returns
If return value is 0, it means success.
If return value is -PWM_EPTR , it means ctlr is NULL.
If return value is -PWM_EPARAMETER , it means pwm_num is invalid.
int mtk_os_hal_pwm_config_freq_duty_2_state ( pwm_groups  group_num,
pwm_channels  pwm_num,
struct mtk_com_pwm_data  state_config 
)

Config 2-state freq & duty.

Parameters
group_num: PWM group number, 0 is group0 , 1 is group1, 2 is group2
pwm_num: PWM number, 0 is pwm0 , 1 is pwm1, 2 is pwm2, 3 is pwm3
state_config: store the PWM base address, group number, clock source, pwm channel common structure information
Returns
If return value is 0, it means success.
If return value is -PWM_EPTR , it means ctlr is NULL.
If return value is -PWM_EPARAMETER , it means pwm_num is invalid.
int mtk_os_hal_pwm_config_stay_cycle_2_state ( pwm_groups  group_num,
pwm_channels  pwm_num,
struct mtk_com_pwm_data  state_config 
)

Config 2-state stay cycle.

Parameters
group_num: PWM group number, 0 is group0 , 1 is group1, 2 is group2
pwm_num: PWM number, 0 is pwm0 , 1 is pwm1, 2 is pwm2, 3 is pwm3
state_config: store the PWM base address, group number, clock source, pwm channel common structure information
Returns
If return value is 0, it means success.
If return value is -PWM_EPTR , it means ctlr is NULL.
If return value is -PWM_EPARAMETER , it means pwm_num is invalid.
int mtk_os_hal_pwm_config_dpsel ( pwm_groups  group_num,
pwm_channels  pwm_num,
pwm_differential_select  mode 
)

Config dpsel.

Parameters
group_num: PWM group number, 0 is group0 , 1 is group1, 2 is group2
pwm_num: PWM number, 0 is pwm0 , 1 is pwm1, 2 is pwm2, 3 is pwm3
mode: Defines the PWM channel's differential mode
Returns
If return value is 0, it means success.
If return value is -PWM_EPTR , it means ctlr is NULL.
If return value is -PWM_EPARAMETER , it means pwm_num is invalid.
int mtk_os_hal_pwm_start_normal ( pwm_groups  group_num,
pwm_channels  pwm_num 
)

Start PWM controller.

Parameters
group_num: PWM group number, 0 is group0 , 1 is group1, 2 is group2
pwm_num: PWM number, 0 is pwm0 , 1 is pwm1, 2 is pwm2, 3 is pwm3
Returns
If return value is 0, it means success.
If return value is -PWM_EPTR , it means ctlr is NULL.
If return value is -PWM_EPARAMETER , it means pwm_num is invalid.
int mtk_os_hal_pwm_stop_normal ( pwm_groups  group_num,
pwm_channels  pwm_num 
)

Stop PWM controller.

Parameters
group_num: PWM group number, 0 is group0 , 1 is group1, 2 is group2
pwm_num: PWM number, 0 is pwm0 , 1 is pwm1, 2 is pwm2, 3 is pwm3
Returns
If return value is 0, it means success.
If return value is -PWM_EPTR , it means ctlr is NULL.
If return value is -PWM_EPARAMETER , it means pwm_num is invalid.