1
0
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:
Bas Stottelaar 2018-03-31 22:23:12 +02:00
parent 77ad70ebb6
commit 587a41ceab
4 changed files with 62 additions and 0 deletions

View File

@ -1,3 +1,4 @@
FEATURES_PROVIDED += periph_cpuid
FEATURES_PROVIDED += periph_pm
-include $(RIOTCPU)/cortexm_common/Makefile.features

View File

@ -1,3 +1,5 @@
export CPU_ARCH = cortex-m3
USEMODULE += pm_layered
include $(RIOTMAKE)/arch/cortexm.inc.mk

View File

@ -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
View 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);
}