From f73618906dbeba70db834a7289da0b6029eb1102 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrzej=20G=C5=82=C4=85bek?= Date: Fri, 8 Apr 2022 16:44:21 +0200 Subject: [PATCH] drivers: pwm_nrf5_sw: Correctly use allocated GPIOTE channels MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The driver improperly uses the PWM channel index to reference the GPIOTE channel to be used for the PWM signal generation. Consequently, the PWM signal on a given channel can be correctly generated only if both those indexes are by chance the same. Fix this by switching to use the stored index of the actually allocated GPIOTE channel. Signed-off-by: Andrzej Głąbek --- drivers/pwm/pwm_nrf5_sw.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/pwm/pwm_nrf5_sw.c b/drivers/pwm/pwm_nrf5_sw.c index 1ca3926c1b0..667ea900473 100644 --- a/drivers/pwm/pwm_nrf5_sw.c +++ b/drivers/pwm/pwm_nrf5_sw.c @@ -237,11 +237,11 @@ static int pwm_nrf5_sw_pin_set(const struct device *dev, uint32_t pwm, NRF_PPI->CH[ppi_chs[0]].EEP = (uint32_t) &(rtc->EVENTS_COMPARE[channel]); NRF_PPI->CH[ppi_chs[0]].TEP = - (uint32_t) &(NRF_GPIOTE->TASKS_OUT[channel]); + (uint32_t) &(NRF_GPIOTE->TASKS_OUT[gpiote_ch]); NRF_PPI->CH[ppi_chs[1]].EEP = (uint32_t) &(rtc->EVENTS_COMPARE[config->map_size]); NRF_PPI->CH[ppi_chs[1]].TEP = - (uint32_t) &(NRF_GPIOTE->TASKS_OUT[channel]); + (uint32_t) &(NRF_GPIOTE->TASKS_OUT[gpiote_ch]); NRF_PPI->CH[ppi_chs[2]].EEP = (uint32_t) &(rtc->EVENTS_COMPARE[config->map_size]); NRF_PPI->CH[ppi_chs[2]].TEP = @@ -250,11 +250,11 @@ static int pwm_nrf5_sw_pin_set(const struct device *dev, uint32_t pwm, NRF_PPI->CH[ppi_chs[0]].EEP = (uint32_t) &(timer->EVENTS_COMPARE[channel]); NRF_PPI->CH[ppi_chs[0]].TEP = - (uint32_t) &(NRF_GPIOTE->TASKS_OUT[channel]); + (uint32_t) &(NRF_GPIOTE->TASKS_OUT[gpiote_ch]); NRF_PPI->CH[ppi_chs[1]].EEP = (uint32_t) &(timer->EVENTS_COMPARE[config->map_size]); NRF_PPI->CH[ppi_chs[1]].TEP = - (uint32_t) &(NRF_GPIOTE->TASKS_OUT[channel]); + (uint32_t) &(NRF_GPIOTE->TASKS_OUT[gpiote_ch]); } NRF_PPI->CHENSET = ppi_mask;