From 34e8609f2c4f589b8cd8d922a8f77abec98c39cb Mon Sep 17 00:00:00 2001 From: Vincent Dupont <vincent@otakeys.com> Date: Mon, 23 Oct 2017 11:37:01 +0200 Subject: [PATCH] cpu/stm32_common: add pm support in spi driver --- cpu/stm32_common/periph/spi.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cpu/stm32_common/periph/spi.c b/cpu/stm32_common/periph/spi.c index 843ed87439..9cc5fc2a5e 100644 --- a/cpu/stm32_common/periph/spi.c +++ b/cpu/stm32_common/periph/spi.c @@ -30,6 +30,7 @@ #include "mutex.h" #include "assert.h" #include "periph/spi.h" +#include "pm_layered.h" /** * @brief Number of bits to shift the BR value in the CR1 register @@ -119,6 +120,10 @@ int spi_acquire(spi_t bus, spi_cs_t cs, spi_mode_t mode, spi_clk_t clk) { /* lock bus */ mutex_lock(&locks[bus]); +#ifdef STM32_PM_STOP + /* block STOP mode */ + pm_block(STM32_PM_STOP); +#endif /* enable SPI device clock */ periph_clk_en(spi_config[bus].apbbus, spi_config[bus].rccmask); /* enable device */ @@ -140,6 +145,10 @@ void spi_release(spi_t bus) dev(bus)->CR1 = 0; dev(bus)->CR2 &= ~(SPI_CR2_SSOE); periph_clk_dis(spi_config[bus].apbbus, spi_config[bus].rccmask); +#ifdef STM32_PM_STOP + /* unblock STOP mode */ + pm_unblock(STM32_PM_STOP); +#endif mutex_unlock(&locks[bus]); } -- GitLab