nrf52_ppi: fix group disable and add group clear operation

This commit is contained in:
Matias N 2020-09-29 15:19:20 -03:00 committed by Alan Carvalho de Assis
parent 83f1f2bc42
commit 2cda47272a
2 changed files with 27 additions and 1 deletions

View File

@ -67,10 +67,12 @@ void nrf52_ppi_channel_enable(uint8_t ch, bool enable)
if (enable) if (enable)
{ {
DEBUGASSERT(!(getreg32(NRF52_PPI_CHENSET) & PPI_CHEN_CH(ch)));
putreg32(PPI_CHEN_CH(ch), NRF52_PPI_CHENSET); putreg32(PPI_CHEN_CH(ch), NRF52_PPI_CHENSET);
} }
else else
{ {
DEBUGASSERT(getreg32(NRF52_PPI_CHENSET) & PPI_CHEN_CH(ch));
putreg32(PPI_CHEN_CH(ch), NRF52_PPI_CHENCLR); 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)); (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 * 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); DEBUGASSERT(group < NRF52_PPI_NUM_GROUPS);
putreg32(1, (enable ? NRF52_PPI_TASK_CHGEN(group) : putreg32(1, (enable ? NRF52_PPI_TASK_CHGEN(group) :
NRF52_PPI_TASK_CHGDIS_OFFSET(group))); NRF52_PPI_TASK_CHGDIS(group)));
} }

View File

@ -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); 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 * Name: nrf52_ppi_grp_enable
* *