From e4391970ff11790973df4e2bf058702a13eeb9e6 Mon Sep 17 00:00:00 2001 From: asterix Date: Sun, 18 Apr 2010 21:38:19 +0000 Subject: [PATCH] Fix the pio pins settings everty time we change configuration. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@3448 38d2e660-2303-0410-9eaa-f027e97ec537 --- bertos/cpu/arm/drv/pwm_at91.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/bertos/cpu/arm/drv/pwm_at91.c b/bertos/cpu/arm/drv/pwm_at91.c index a95e6061..411f3ab6 100644 --- a/bertos/cpu/arm/drv/pwm_at91.c +++ b/bertos/cpu/arm/drv/pwm_at91.c @@ -121,7 +121,7 @@ void pwm_hw_setFrequency(PwmDev dev, uint32_t freq) for(int i = 0; i <= PWM_HW_MAX_PRESCALER_STEP; i++) { period = CPU_FREQ / (BV(i) * freq); -// LOG_INFO("period[%ld], prescale[%d]\n", period, i); + LOG_INFO("period[%ld], prescale[%d]\n", period, i); if ((period < PWM_HW_MAX_PERIOD) && (period != 0)) { //Clean previous channel prescaler, and set new @@ -152,12 +152,13 @@ void pwm_hw_setDutyUnlock(PwmDev dev, uint16_t duty) */ if (!duty) { - PWM_PIO_PER = pwm_map[dev].pwm_pin; + PWM_PIO_CODR = pwm_map[dev].pwm_pin; + PWM_PIO_PER = pwm_map[dev].pwm_pin; pwm_map[dev].duty_zero = true; } else { - /* + /* * If polarity flag is true we must invert * PWM polarity. */ @@ -168,12 +169,13 @@ void pwm_hw_setDutyUnlock(PwmDev dev, uint16_t duty) } PWM_PIO_PDR = pwm_map[dev].pwm_pin; + PWM_PIO_ABSR = pwm_map[dev].pwm_pin; + *pwm_map[dev].update_reg = duty; pwm_map[dev].duty_zero = false; } PWM_ENA = BV(dev); - LOG_INFO("PWM ch[%d] duty[%d], period[%ld]\n", dev, duty, *pwm_map[dev].period_reg); } @@ -184,7 +186,10 @@ void pwm_hw_setDutyUnlock(PwmDev dev, uint16_t duty) void pwm_hw_enable(PwmDev dev) { if (!pwm_map[dev].duty_zero) - PWM_PIO_PDR = pwm_map[dev].pwm_pin; + { + PWM_PIO_PDR = pwm_map[dev].pwm_pin; + PWM_PIO_ABSR = pwm_map[dev].pwm_pin; + } } /** @@ -220,8 +225,8 @@ void pwm_hw_init(void) * - Power on PWM */ PWM_PIO_CODR = BV(PWM0) | BV(PWM1) | BV(PWM2) | BV(PWM3); - PWM_PIO_OER = BV(PWM0) | BV(PWM1) | BV(PWM2) | BV(PWM3); - PWM_PIO_PDR = BV(PWM0) | BV(PWM1) | BV(PWM2) | BV(PWM3); + PWM_PIO_OER = BV(PWM0) | BV(PWM1) | BV(PWM2) | BV(PWM3); + PWM_PIO_PDR = BV(PWM0) | BV(PWM1) | BV(PWM2) | BV(PWM3); PWM_PIO_ABSR = BV(PWM0) | BV(PWM1) | BV(PWM2) | BV(PWM3); PMC_PCER |= BV(PWMC_ID); -- 2.25.1