From 9ed2a701d916d14fe347ff36f21aa732a9da6c7f Mon Sep 17 00:00:00 2001 From: ccli8 Date: Thu, 20 Apr 2017 16:18:16 +0800 Subject: [PATCH] Fix pwmout power-down condition --- targets/TARGET_NUVOTON/TARGET_M480/pwmout_api.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/targets/TARGET_NUVOTON/TARGET_M480/pwmout_api.c b/targets/TARGET_NUVOTON/TARGET_M480/pwmout_api.c index 4d771e78ea..dd3445ef50 100644 --- a/targets/TARGET_NUVOTON/TARGET_M480/pwmout_api.c +++ b/targets/TARGET_NUVOTON/TARGET_M480/pwmout_api.c @@ -99,11 +99,9 @@ void pwmout_init(pwmout_t* obj, PinName pin) ((struct nu_pwm_var *) modinit->var)->en_msk |= 1 << chn; - if (((struct nu_pwm_var *) modinit->var)->en_msk) { - // Mark this module to be inited. - int i = modinit - pwm_modinit_tab; - pwm_modinit_mask |= 1 << i; - } + // Mark this module to be inited. + int i = modinit - pwm_modinit_tab; + pwm_modinit_mask |= 1 << i; } void pwmout_free(pwmout_t* obj) @@ -122,11 +120,9 @@ void pwmout_free(pwmout_t* obj) CLK_DisableModuleClock(modinit->clkidx); } - if (((struct nu_pwm_var *) modinit->var)->en_msk == 0) { - // Mark this module to be deinited. - int i = modinit - pwm_modinit_tab; - pwm_modinit_mask &= ~(1 << i); - } + // Mark this module to be deinited. + int i = modinit - pwm_modinit_tab; + pwm_modinit_mask &= ~(1 << i); } void pwmout_write(pwmout_t* obj, float value)