From 2cda47272a32c25e49f5922802d42f930d37abc2 Mon Sep 17 00:00:00 2001 From: Matias N Date: Tue, 29 Sep 2020 15:19:20 -0300 Subject: [PATCH] nrf52_ppi: fix group disable and add group clear operation --- arch/arm/src/nrf52/nrf52_ppi.c | 15 ++++++++++++++- arch/arm/src/nrf52/nrf52_ppi.h | 13 +++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/arch/arm/src/nrf52/nrf52_ppi.c b/arch/arm/src/nrf52/nrf52_ppi.c index 1a8f412dcdc..cbe20e2b118 100644 --- a/arch/arm/src/nrf52/nrf52_ppi.c +++ b/arch/arm/src/nrf52/nrf52_ppi.c @@ -67,10 +67,12 @@ void nrf52_ppi_channel_enable(uint8_t ch, bool enable) if (enable) { + DEBUGASSERT(!(getreg32(NRF52_PPI_CHENSET) & PPI_CHEN_CH(ch))); putreg32(PPI_CHEN_CH(ch), NRF52_PPI_CHENSET); } else { + DEBUGASSERT(getreg32(NRF52_PPI_CHENSET) & PPI_CHEN_CH(ch)); putreg32(PPI_CHEN_CH(ch), NRF52_PPI_CHENCLR); } } @@ -121,6 +123,17 @@ void nrf52_ppi_grp_channel_enable(uint8_t group, uint8_t ch, bool enable) (enable ? PPI_CHEN_CH(ch) : 0)); } +/**************************************************************************** + * Name: nrf52_ppi_grp_clear + ****************************************************************************/ + +void nrf52_ppi_grp_clear(uint8_t group) +{ + DEBUGASSERT(group < NRF52_PPI_NUM_GROUPS); + + putreg32(0, NRF52_PPI_CHG(group)); +} + /**************************************************************************** * Name: nrf52_ppi_grp_enable ****************************************************************************/ @@ -130,5 +143,5 @@ void nrf52_ppi_grp_enable(uint8_t group, bool enable) DEBUGASSERT(group < NRF52_PPI_NUM_GROUPS); putreg32(1, (enable ? NRF52_PPI_TASK_CHGEN(group) : - NRF52_PPI_TASK_CHGDIS_OFFSET(group))); + NRF52_PPI_TASK_CHGDIS(group))); } diff --git a/arch/arm/src/nrf52/nrf52_ppi.h b/arch/arm/src/nrf52/nrf52_ppi.h index 81c1ed46930..9f7b283fcbb 100644 --- a/arch/arm/src/nrf52/nrf52_ppi.h +++ b/arch/arm/src/nrf52/nrf52_ppi.h @@ -131,6 +131,19 @@ void nrf52_ppi_set_task2_ep(uint8_t ch, uint32_t task_reg); void nrf52_ppi_grp_channel_enable(uint8_t group, uint8_t ch, bool enable); +/**************************************************************************** + * Name: nrf52_ppi_grp_clear + * + * Description: + * Clear group (disable all its channels) + * + * Input Parameters: + * - group: group number + * + ****************************************************************************/ + +void nrf52_ppi_grp_clear(uint8_t group); + /**************************************************************************** * Name: nrf52_ppi_grp_enable *