Skip to content

Commit

Permalink
MCPWM/deadtime: fix and sync preset deadtime modes with well-known de…
Browse files Browse the repository at this point in the history
…finition

Closes #7321
  • Loading branch information
SalimTerryLi authored and ginkgm committed Sep 3, 2021
1 parent de4c735 commit f68e0e0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
16 changes: 8 additions & 8 deletions components/driver/include/driver/mcpwm.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,14 +203,14 @@ typedef enum {
* @brief MCPWM deadtime types, used to generate deadtime, RED refers to rising edge delay and FED refers to falling edge delay
*/
typedef enum {
MCPWM_BYPASS_RED = 0, /*!<MCPWMXA = no change, MCPWMXB = falling edge delay*/
MCPWM_BYPASS_FED, /*!<MCPWMXA = rising edge delay, MCPWMXB = no change*/
MCPWM_ACTIVE_HIGH_MODE, /*!<MCPWMXA = rising edge delay, MCPWMXB = falling edge delay*/
MCPWM_ACTIVE_LOW_MODE, /*!<MCPWMXA = compliment of rising edge delay, MCPWMXB = compliment of falling edge delay*/
MCPWM_ACTIVE_HIGH_COMPLIMENT_MODE, /*!<MCPWMXA = rising edge delay, MCPWMXB = compliment of falling edge delay*/
MCPWM_ACTIVE_LOW_COMPLIMENT_MODE, /*!<MCPWMXA = compliment of rising edge delay, MCPWMXB = falling edge delay*/
MCPWM_ACTIVE_RED_FED_FROM_PWMXA, /*!<MCPWMXA = MCPWMXB = rising edge delay as well as falling edge delay, generated from MCPWMXA*/
MCPWM_ACTIVE_RED_FED_FROM_PWMXB, /*!<MCPWMXA = MCPWMXB = rising edge delay as well as falling edge delay, generated from MCPWMXB*/
MCPWM_BYPASS_RED = 0, /*!<MCPWMXA Out = MCPWMXA In with no delay, MCPWMXB Out = MCPWMXA In with falling edge delay*/
MCPWM_BYPASS_FED, /*!<MCPWMXA Out = MCPWMXA In with rising edge delay, MCPWMXB Out = MCPWMXB In with no delay*/
MCPWM_ACTIVE_HIGH_MODE, /*!<MCPWMXA Out = MCPWMXA In with rising edge delay, MCPWMXB Out = MCPWMXA In with falling edge delay*/
MCPWM_ACTIVE_LOW_MODE, /*!<MCPWMXA Out = MCPWMXA In with compliment of rising edge delay, MCPWMXB Out = MCPWMXA In with compliment of falling edge delay*/
MCPWM_ACTIVE_HIGH_COMPLIMENT_MODE, /*!<MCPWMXA Out = MCPWMXA In with rising edge delay, MCPWMXB = MCPWMXA In with compliment of falling edge delay*/
MCPWM_ACTIVE_LOW_COMPLIMENT_MODE, /*!<MCPWMXA Out = MCPWMXA In with compliment of rising edge delay, MCPWMXB Out = MCPWMXA In with falling edge delay*/
MCPWM_ACTIVE_RED_FED_FROM_PWMXA, /*!<MCPWMXA Out = MCPWMXB Out = MCPWMXA In with rising edge delay as well as falling edge delay*/
MCPWM_ACTIVE_RED_FED_FROM_PWMXB, /*!<MCPWMXA Out = MCPWMXB Out = MCPWMXB In with rising edge delay as well as falling edge delay*/
MCPWM_DEADTIME_TYPE_MAX,
} mcpwm_deadtime_type_t;

Expand Down
14 changes: 7 additions & 7 deletions components/driver/mcpwm.c
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ esp_err_t mcpwm_deadtime_enable(mcpwm_unit_t mcpwm_num, mcpwm_timer_t timer_num,
MCPWM[mcpwm_num]->channel[timer_num].db_cfg.red_outinvert = 0; //S2
MCPWM[mcpwm_num]->channel[timer_num].db_cfg.fed_outinvert = 0; //S3
MCPWM[mcpwm_num]->channel[timer_num].db_cfg.red_insel = 0; //S4
MCPWM[mcpwm_num]->channel[timer_num].db_cfg.fed_insel = 1; //S5
MCPWM[mcpwm_num]->channel[timer_num].db_cfg.fed_insel = 0; //S5
break;
case MCPWM_BYPASS_FED:
MCPWM[mcpwm_num]->channel[timer_num].db_cfg.b_outbypass = 1; //S0
Expand All @@ -475,44 +475,44 @@ esp_err_t mcpwm_deadtime_enable(mcpwm_unit_t mcpwm_num, mcpwm_timer_t timer_num,
MCPWM[mcpwm_num]->channel[timer_num].db_cfg.red_outinvert = 0; //S2
MCPWM[mcpwm_num]->channel[timer_num].db_cfg.fed_outinvert = 0; //S3
MCPWM[mcpwm_num]->channel[timer_num].db_cfg.red_insel = 0; //S4
MCPWM[mcpwm_num]->channel[timer_num].db_cfg.fed_insel = 1; //S5
MCPWM[mcpwm_num]->channel[timer_num].db_cfg.fed_insel = 0; //S5
break;
case MCPWM_ACTIVE_LOW_MODE:
MCPWM[mcpwm_num]->channel[timer_num].db_cfg.b_outbypass = 0; //S0
MCPWM[mcpwm_num]->channel[timer_num].db_cfg.a_outbypass = 0; //S1
MCPWM[mcpwm_num]->channel[timer_num].db_cfg.red_outinvert = 1; //S2
MCPWM[mcpwm_num]->channel[timer_num].db_cfg.fed_outinvert = 1; //S3
MCPWM[mcpwm_num]->channel[timer_num].db_cfg.red_insel = 0; //S4
MCPWM[mcpwm_num]->channel[timer_num].db_cfg.fed_insel = 1; //S5
MCPWM[mcpwm_num]->channel[timer_num].db_cfg.fed_insel = 0; //S5
break;
case MCPWM_ACTIVE_HIGH_COMPLIMENT_MODE:
MCPWM[mcpwm_num]->channel[timer_num].db_cfg.b_outbypass = 0; //S0
MCPWM[mcpwm_num]->channel[timer_num].db_cfg.a_outbypass = 0; //S1
MCPWM[mcpwm_num]->channel[timer_num].db_cfg.red_outinvert = 0; //S2
MCPWM[mcpwm_num]->channel[timer_num].db_cfg.fed_outinvert = 1; //S3
MCPWM[mcpwm_num]->channel[timer_num].db_cfg.red_insel = 0; //S4
MCPWM[mcpwm_num]->channel[timer_num].db_cfg.fed_insel = 1; //S5
MCPWM[mcpwm_num]->channel[timer_num].db_cfg.fed_insel = 0; //S5
break;
case MCPWM_ACTIVE_LOW_COMPLIMENT_MODE:
MCPWM[mcpwm_num]->channel[timer_num].db_cfg.b_outbypass = 0; //S0
MCPWM[mcpwm_num]->channel[timer_num].db_cfg.a_outbypass = 0; //S1
MCPWM[mcpwm_num]->channel[timer_num].db_cfg.red_outinvert = 1; //S2
MCPWM[mcpwm_num]->channel[timer_num].db_cfg.fed_outinvert = 0; //S3
MCPWM[mcpwm_num]->channel[timer_num].db_cfg.red_insel = 1; //S4
MCPWM[mcpwm_num]->channel[timer_num].db_cfg.red_insel = 0; //S4
MCPWM[mcpwm_num]->channel[timer_num].db_cfg.fed_insel = 0; //S5
break;
case MCPWM_ACTIVE_RED_FED_FROM_PWMXA:
MCPWM[mcpwm_num]->channel[timer_num].db_cfg.b_outbypass = 0; //S0
MCPWM[mcpwm_num]->channel[timer_num].db_cfg.fed_outinvert = 0; //S3
MCPWM[mcpwm_num]->channel[timer_num].db_cfg.red_insel = 1; //S4
MCPWM[mcpwm_num]->channel[timer_num].db_cfg.red_insel = 0; //S4
MCPWM[mcpwm_num]->channel[timer_num].db_cfg.a_outswap = 1; //S6
MCPWM[mcpwm_num]->channel[timer_num].db_cfg.b_outswap = 0; //S7
MCPWM[mcpwm_num]->channel[timer_num].db_cfg.deb_mode = 1; //S8
break;
case MCPWM_ACTIVE_RED_FED_FROM_PWMXB:
MCPWM[mcpwm_num]->channel[timer_num].db_cfg.b_outbypass = 0; //S0
MCPWM[mcpwm_num]->channel[timer_num].db_cfg.fed_outinvert = 0; //S3
MCPWM[mcpwm_num]->channel[timer_num].db_cfg.red_insel = 0; //S4
MCPWM[mcpwm_num]->channel[timer_num].db_cfg.red_insel = 1; //S4
MCPWM[mcpwm_num]->channel[timer_num].db_cfg.a_outswap = 1; //S6
MCPWM[mcpwm_num]->channel[timer_num].db_cfg.b_outswap = 0; //S7
MCPWM[mcpwm_num]->channel[timer_num].db_cfg.deb_mode = 1; //S8
Expand Down

0 comments on commit f68e0e0

Please sign in to comment.