mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
cpu: lpc1768: provide periph_pm.
This commit is contained in:
parent
77ad70ebb6
commit
587a41ceab
@ -1,3 +1,4 @@
|
||||
FEATURES_PROVIDED += periph_cpuid
|
||||
FEATURES_PROVIDED += periph_pm
|
||||
|
||||
-include $(RIOTCPU)/cortexm_common/Makefile.features
|
||||
|
@ -1,3 +1,5 @@
|
||||
export CPU_ARCH = cortex-m3
|
||||
|
||||
USEMODULE += pm_layered
|
||||
|
||||
include $(RIOTMAKE)/arch/cortexm.inc.mk
|
||||
|
@ -63,6 +63,16 @@ typedef enum {
|
||||
} gpio_mode_t;
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @brief CPU provides own pm_off() function
|
||||
*/
|
||||
#define PROVIDES_PM_LAYERED_OFF
|
||||
|
||||
/**
|
||||
* @brief Power management configuration
|
||||
*/
|
||||
#define PM_NUM_MODES (3U)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
49
cpu/lpc1768/periph/pm.c
Normal file
49
cpu/lpc1768/periph/pm.c
Normal file
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (C) 2018 Bas Stottelaar <basstottelaar@gmail.com>
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU Lesser
|
||||
* General Public License v2.1. See the file LICENSE in the top level
|
||||
* directory for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup cpu_lpc1768
|
||||
* @ingroup drivers_periph_pm
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Implementation of the power management peripheral
|
||||
*
|
||||
* @author Bas Stottelaar <basstottelaar@gmail.com>
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include "periph/pm.h"
|
||||
|
||||
void pm_set(unsigned mode)
|
||||
{
|
||||
switch (mode) {
|
||||
case 0:
|
||||
/* enter power down mode */
|
||||
LPC_SC->PCON = 0x01;
|
||||
cortexm_sleep(1);
|
||||
break;
|
||||
case 1:
|
||||
/* enter deep sleep mode */
|
||||
LPC_SC->PCON = 0x00;
|
||||
cortexm_sleep(1);
|
||||
break;
|
||||
case 2:
|
||||
/* enter sleep mode */
|
||||
LPC_SC->PCON = 0x00;
|
||||
cortexm_sleep(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void pm_off(void)
|
||||
{
|
||||
/* enter deep power down mode */
|
||||
LPC_SC->PCON = 0x03;
|
||||
cortexm_sleep(1);
|
||||
}
|
Loading…
Reference in New Issue
Block a user