X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;ds=sidebyside;f=bertos%2Fcpu%2Farm%2Fdrv%2Fpwm_at91.c;h=397240ec2318f51e6971c52c3639aee3f5796351;hb=b46f64914c62fbb0297728280478681659469654;hp=411f3ab690df18f31c2d7c945f55aa036c8fcd9d;hpb=e4391970ff11790973df4e2bf058702a13eeb9e6;p=bertos.git diff --git a/bertos/cpu/arm/drv/pwm_at91.c b/bertos/cpu/arm/drv/pwm_at91.c index 411f3ab6..397240ec 100644 --- a/bertos/cpu/arm/drv/pwm_at91.c +++ b/bertos/cpu/arm/drv/pwm_at91.c @@ -33,7 +33,6 @@ * * \brief PWM hardware-specific implementation * - * \version $Id$ * \author Daniele Basile */ @@ -146,6 +145,16 @@ void pwm_hw_setDutyUnlock(PwmDev dev, uint16_t duty) ASSERT(duty <= (uint16_t)*pwm_map[dev].period_reg); + /* + * If polarity flag is true we must invert + * PWM polarity. + */ + if (pwm_map[dev].pol) + { + duty = (uint16_t)*pwm_map[dev].period_reg - duty; + LOG_INFO("Inverted duty[%d], pol[%d]\n", duty, pwm_map[dev].pol); + } + /* * WARNING: is forbidden to write 0 to duty cycle value, * and so for duty = 0 we must enable PIO and clear output! @@ -158,16 +167,6 @@ void pwm_hw_setDutyUnlock(PwmDev dev, uint16_t duty) } else { - /* - * If polarity flag is true we must invert - * PWM polarity. - */ - if (pwm_map[dev].pol) - { - duty = (uint16_t)*pwm_map[dev].period_reg - duty; - LOG_INFO("Inverted duty[%d], pol[%d]\n", duty, pwm_map[dev].pol); - } - PWM_PIO_PDR = pwm_map[dev].pwm_pin; PWM_PIO_ABSR = pwm_map[dev].pwm_pin;