21 #define PWM_V2_CH_MAX 4 29 #define PWM_POLARITY_ACTIVE_LOW 0 30 #define PWM_POLARITY_ACTIVE_HIGH 1 38 #define PWM_STATE_INACTIVE 0 39 #define PWM_STATE_ACTIVE 1 47 #define PWM_TRIG_ADC_SRC_CH0_L 0 48 #define PWM_TRIG_ADC_SRC_CH0_H 1 49 #define PWM_TRIG_ADC_SRC_CH1_L 2 50 #define PWM_TRIG_ADC_SRC_CH1_H 3 51 #define PWM_TRIG_ADC_SRC_CH2_L 4 52 #define PWM_TRIG_ADC_SRC_CH2_H 5 53 #define PWM_TRIG_ADC_SRC_CH3_L 6 54 #define PWM_TRIG_ADC_SRC_CH3_H 7 55 #define PWM_TRIG_ADC_SRC_PERIOD 8 56 #define PWM_TRIG_ADC_SRC_NONE 0xF 64 #define PWM_INTEN_CH0_L (1 << 0) 65 #define PWM_INTEN_CH0_H (1 << 1) 66 #define PWM_INTEN_CH1_L (1 << 2) 67 #define PWM_INTEN_CH1_H (1 << 3) 68 #define PWM_INTEN_CH2_L (1 << 4) 69 #define PWM_INTEN_CH2_H (1 << 5) 70 #define PWM_INTEN_CH3_L (1 << 6) 71 #define PWM_INTEN_CH3_H (1 << 7) 72 #define PWM_INTEN_PERIOD (1 << 8) 73 #define PWM_INTEN_BRAKE (1 << 9) 74 #define PWM_INTEN_REPT (1 << 10) 82 #define PWM_INTSTS_CH0_L (1 << 0) 83 #define PWM_INTSTS_CH0_H (1 << 1) 84 #define PWM_INTSTS_CH1_L (1 << 2) 85 #define PWM_INTSTS_CH1_H (1 << 3) 86 #define PWM_INTSTS_CH2_L (1 << 4) 87 #define PWM_INTSTS_CH2_H (1 << 5) 88 #define PWM_INTSTS_CH3_L (1 << 6) 89 #define PWM_INTSTS_CH3_H (1 << 7) 90 #define PWM_INTSTS_PERIOD (1 << 8) 91 #define PWM_INTSTS_BRAKE (1 << 9) 92 #define PWM_INTSTS_REPT (1 << 10) 100 #define PWM_INTCLR_CH0_L (1 << 0) 101 #define PWM_INTCLR_CH0_H (1 << 1) 102 #define PWM_INTCLR_CH1_L (1 << 2) 103 #define PWM_INTCLR_CH1_H (1 << 3) 104 #define PWM_INTCLR_CH2_L (1 << 4) 105 #define PWM_INTCLR_CH2_H (1 << 5) 106 #define PWM_INTCLR_CH3_L (1 << 6) 107 #define PWM_INTCLR_CH3_H (1 << 7) 108 #define PWM_INTCLR_PERIOD (1 << 8) 109 #define PWM_INTCLR_BRAKE (1 << 9) 110 #define PWM_INTCLR_REPT (1 << 10) 118 #define PWM_CMD_SET_TRIG_ADC_SRC (0x01) 119 #define PWM_CMD_SET_EXT_BRAKE_POLARITY (0x02) 120 #define PWM_CMD_SET_EXT_BRAKE_ENABLE (0x03) 121 #define PWM_CMD_SET_SW_BRAKE_ENABLE (0x04) 122 #define PWM_CMD_SET_STOP_ON_REPT (0x05) 123 #define PWM_CMD_SET_REPT_COUNT (0x06) uint8_t positive_polarity
void bflb_pwm_v2_channel_positive_start(struct bflb_device_s *dev, uint8_t ch)
Start pwm positive output.
void bflb_pwm_v2_init(struct bflb_device_s *dev, const struct bflb_pwm_v2_config_s *config)
Initialize pwm.
void bflb_pwm_v2_channel_init(struct bflb_device_s *dev, uint8_t ch, struct bflb_pwm_v2_channel_config_s *config)
Config pwm channel.
void bflb_pwm_v2_channel_negative_stop(struct bflb_device_s *dev, uint8_t ch)
Stop pwm negative output.
void bflb_pwm_v2_channel_negative_start(struct bflb_device_s *dev, uint8_t ch)
Start pwm negative output.
uint8_t negative_stop_state
uint32_t bflb_pwm_v2_get_intstatus(struct bflb_device_s *dev)
Get pwm interrupt status.
uint8_t negative_polarity
void bflb_pwm_v2_int_enable(struct bflb_device_s *dev, uint32_t int_en, bool enable)
Enable pwm interrupt.
void bflb_pwm_v2_set_period(struct bflb_device_s *dev, uint16_t period)
Set pwm period to change pwm frequence. Frequcence(hz) = pwm source clock /div/period.
PWM channel configuration structure.
float bflb_pwm_v2_get_frequency(struct bflb_device_s *dev)
Get pwm frequcency.
uint8_t positive_brake_state
void bflb_pwm_v2_stop(struct bflb_device_s *dev)
Stop pwm output.
void bflb_pwm_v2_start(struct bflb_device_s *dev)
Start pwm output.
uint8_t positive_stop_state
void bflb_pwm_v2_channel_positive_stop(struct bflb_device_s *dev, uint8_t ch)
Stop pwm positive output.
void bflb_pwm_v2_channel_set_threshold(struct bflb_device_s *dev, uint8_t ch, uint16_t low_threhold, uint16_t high_threhold)
Set pwm dutycycle. Dutycycle(%) = (high_threhold - low_threhold)/period * 100%.
int bflb_pwm_v2_feature_control(struct bflb_device_s *dev, int cmd, size_t arg)
Control pwm feature.
PWM configuration structure.
uint8_t negative_brake_state
void bflb_pwm_v2_deinit(struct bflb_device_s *dev)
Deinitialize pwm.
void bflb_pwm_v2_int_clear(struct bflb_device_s *dev, uint32_t int_clear)
Clear pwm interrupt status.