From b4d061943dd572005923ccee267c8e4e34c319cf Mon Sep 17 00:00:00 2001 From: Dylan Laduranty Date: Mon, 27 Jan 2025 21:38:14 +0100 Subject: [PATCH] cpu/sam3: fix PMC enable/disable peripheral clock access Signed-off-by: Dylan Laduranty --- cpu/sam3/periph/rtt.c | 4 ++-- cpu/sam3/periph/spi.c | 4 ++-- cpu/sam3/periph/uart.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cpu/sam3/periph/rtt.c b/cpu/sam3/periph/rtt.c index 2da87e712c..7cefa4f210 100644 --- a/cpu/sam3/periph/rtt.c +++ b/cpu/sam3/periph/rtt.c @@ -88,12 +88,12 @@ void rtt_clear_alarm(void) void rtt_poweron(void) { - PMC->PMC_PCER0 |= (1 << ID_RTT); + PMC->PMC_PCER0 = (1 << ID_RTT); } void rtt_poweroff(void) { - PMC->PMC_PCER0 &= ~(1 << ID_RTT); + PMC->PMC_PCDR0 = (1 << ID_RTT); } void isr_rtt(void) diff --git a/cpu/sam3/periph/spi.c b/cpu/sam3/periph/spi.c index e542519dab..f7c56afd80 100644 --- a/cpu/sam3/periph/spi.c +++ b/cpu/sam3/periph/spi.c @@ -71,7 +71,7 @@ void spi_acquire(spi_t bus, spi_cs_t cs, spi_mode_t mode, spi_clk_t clk) /* lock bus */ mutex_lock(&locks[bus]); /* enable SPI device clock */ - PMC->PMC_PCER0 |= (1 << spi_config[bus].id); + PMC->PMC_PCER0 = (1 << spi_config[bus].id); /* set mode and speed */ dev(bus)->SPI_CSR[0] = (SPI_CSR_SCBR(CLOCK_CORECLOCK / clk) | mode); dev(bus)->SPI_MR = (SPI_MR_MSTR | SPI_MR_MODFDIS); @@ -82,7 +82,7 @@ void spi_release(spi_t bus) { /* disable device and turn off clock signal */ dev(bus)->SPI_CR = 0; - PMC->PMC_PCER0 &= ~(1 << spi_config[bus].id); + PMC->PMC_PCDR0 = (1 << spi_config[bus].id); /* release device lock */ mutex_unlock(&locks[bus]); } diff --git a/cpu/sam3/periph/uart.c b/cpu/sam3/periph/uart.c index 206e457a42..8cb8723ed0 100644 --- a/cpu/sam3/periph/uart.c +++ b/cpu/sam3/periph/uart.c @@ -89,12 +89,12 @@ void uart_write(uart_t uart, const uint8_t *data, size_t len) void uart_poweron(uart_t uart) { - PMC->PMC_PCER0 |= (1 << uart_config[uart].pmc_id); + PMC->PMC_PCER0 = (1 << uart_config[uart].pmc_id); } void uart_poweroff(uart_t uart) { - PMC->PMC_PCER0 &= ~(1 << uart_config[uart].pmc_id); + PMC->PMC_PCDR0 = (1 << uart_config[uart].pmc_id); } static inline void isr_handler(int num)