From d396306a10043e493d0df9115823024366ec8b9b Mon Sep 17 00:00:00 2001 From: Seppe Stas Date: Mon, 10 Apr 2017 11:56:35 +0200 Subject: [PATCH] EFM32: Fixed `pwmout_all_inactive` being inversed If one of the CC channel pins is enabled, `pwmout_all_inactive` it means a channel is active so it should return `true`. This commit also contains some cleanup in `pwm_init`. --- targets/TARGET_Silicon_Labs/TARGET_EFM32/pwmout_api.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/targets/TARGET_Silicon_Labs/TARGET_EFM32/pwmout_api.c b/targets/TARGET_Silicon_Labs/TARGET_EFM32/pwmout_api.c index 2bf2fb28f6..ac0f70d55e 100644 --- a/targets/TARGET_Silicon_Labs/TARGET_EFM32/pwmout_api.c +++ b/targets/TARGET_Silicon_Labs/TARGET_EFM32/pwmout_api.c @@ -131,7 +131,7 @@ bool pwmout_all_inactive(void) { return true; } #else - if(PWM_TIMER->ROUTE & (TIMER_ROUTE_CC0PEN | TIMER_ROUTE_CC1PEN | TIMER_ROUTE_CC2PEN)) { + if (!(PWM_TIMER->ROUTE & (TIMER_ROUTE_CC0PEN | TIMER_ROUTE_CC1PEN | TIMER_ROUTE_CC2PEN))) { return true; } #endif @@ -210,10 +210,11 @@ void pwmout_init(pwmout_t *obj, PinName pin) #else // On P1, the route location is statically defined for the entire timer. PWM_TIMER->ROUTE &= ~_TIMER_ROUTE_LOCATION_MASK; -if(pwmout_all_inactive()) { + // Make sure the route location is not overwritten + if(pwmout_all_inactive()) { PWM_TIMER->ROUTE |= pinmap_find_function(pin,PinMap_PWM) << _TIMER_ROUTE_LOCATION_SHIFT; } else { - MBED_ASSERT((pinmap_find_function(pin,PinMap_PWM) << _TIMER_ROUTE_LOCATION_SHIFT) == (PWM_TIMER->ROUTE & _TIMER_ROUTE_LOCATION_MASK)); + MBED_ASSERT(PWM_TIMER->ROUTE & _TIMER_ROUTE_LOCATION_MASK == pinmap_find_function(pin,PinMap_PWM) << _TIMER_ROUTE_LOCATION_SHIFT); } #endif