Skip to content

Commit

Permalink
cpu: stm32f1/2/4: unify periph/pm support
Browse files Browse the repository at this point in the history
  • Loading branch information
kaspar030 committed Jan 9, 2017
1 parent 54811b4 commit 6178094
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
11 changes: 10 additions & 1 deletion cpu/stm32f1/periph/pm.c → cpu/stm32_common/periph/pm.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2016 Kaspar Schleiser <kaspar@schleiser.de>
* 2015 Freie Universität Berlin
* 2015 Engineering-Spirit
*
* This file is subject to the terms and conditions of the GNU Lesser
Expand All @@ -8,14 +9,15 @@
*/

/**
* @ingroup cpu_stm32f1
* @ingroup cpu_stm32
* @{
*
* @file
* @brief Implementation of the kernels power management interface
*
* @author Nick v. IJzendoorn <nijzndoorn@engineering-spirit.nl>
* @author Kaspar Schleiser <kaspar@schleiser.de>
* @author Fabian Nack <nack@inf.fu-berlin.de>
*
* @}
*/
Expand All @@ -27,6 +29,10 @@

void pm_set(unsigned mode)
{

/* I just copied it from stm32f1/2/4, but I suppose it would work for the
* others... /KS */
#if defined(CPU_FAM_STM32F1) || defined(CPU_FAM_STM32F2) || defined(CPU_FAM_STM32F2)
switch (mode) {
case 0: /* STM Sleep mode */
/* Reset SLEEPDEEP bit of system control block */
Expand All @@ -42,13 +48,15 @@ void pm_set(unsigned mode)
default:
DEBUG("pm: invalid power mode selected.\n");
}
#endif

/* Executes a device DSB (Data Synchronization Barrier) */
__DSB();
/* Enter standby mode */
__WFI();
}

#if defined(CPU_FAM_STM32F1) || defined(CPU_FAM_STM32F2) || defined(CPU_FAM_STM32F2)
void pm_off(void)
{
/* Set PDDS to enter standby mode on deepsleep and clear flags */
Expand All @@ -61,3 +69,4 @@ void pm_off(void)
__DSB();
__WFI();
}
#endif
1 change: 1 addition & 0 deletions cpu/stm32f2/Makefile.features
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FEATURE_PROVIDED += periph_pm
1 change: 1 addition & 0 deletions cpu/stm32f4/Makefile.features
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FEATURE_PROVIDED += periph_pm

0 comments on commit 6178094

Please sign in to comment.