Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce new power management #6160

Merged
merged 26 commits into from
Jan 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
0194091
remove obsolete lpm code
kaspar030 Jan 9, 2017
6150e27
drivers: periph: pm: introduce new power management API
kaspar030 Jan 9, 2017
92f6fc6
drivers: add layered power modes module
kaspar030 Jan 11, 2017
4291c1f
native: support add periph/pm support
kaspar030 Jan 9, 2017
ac9b122
make: factor out features handling, add default feature handling
kaspar030 Jan 9, 2017
1b31fc7
core: reboot: map to periph/pm
kaspar030 Jan 9, 2017
ca7bf15
core: panic: adapt to pariph/pm
kaspar030 Jan 9, 2017
807a190
cpu: cortexm: adapt to periph/pm
kaspar030 Jan 9, 2017
f42e538
cpu: samd21: add periph/pm support
kaspar030 Jan 9, 2017
3e365b8
cpu: atmega_common: adapt to periph/pm
kaspar030 Jan 9, 2017
040c6e9
cpu: lpc11u34: remove obsolete reboot implementation
kaspar030 Jan 9, 2017
52d53a9
cpu: lpc1768: adapt to periph/pm
kaspar030 Jan 9, 2017
fb46d57
cpu: msp430-common: adapt reboot to periph/pm
kaspar030 Jan 9, 2017
8c8ce5a
cpu: x86: adapt to periph/pm
kaspar030 Jan 9, 2017
062b907
cpu: arm7_common: adapt to periph/pm
kaspar030 Jan 9, 2017
fa9fbab
cpu: x86: add stub periph_cpu.h
kaspar030 Jan 9, 2017
0fb66a0
cpu: cortexm: always use periph_common module
kaspar030 Jan 9, 2017
066332d
cpu: stm32f1: add periph/pm support
kaspar030 Jan 9, 2017
db82367
board: samr21-xpro: move periph_pm to cpu/samd21/Makefile.features
kaspar030 Jan 9, 2017
662bec0
cpu: k60: add periph/pm support
kaspar030 Jan 9, 2017
f0cf52f
cpu: nrf52: initial periph/pm support
kaspar030 Jan 9, 2017
c2b48ca
cpu: nrf51: initial periph/pm support
kaspar030 Jan 9, 2017
a8c5fcc
cpu: saml21: add periph/pm support
kaspar030 Jan 9, 2017
5798bec
cpu: stm32f1/2/4: unify periph/pm support
kaspar030 Jan 9, 2017
9d1c5f0
cpu: stm32_common: periph_cpu_common.h doxygen fix
kaspar030 Jan 10, 2017
51a86f7
boards: chronos: add stub support for periph/pm
kaspar030 Jan 12, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Makefile.features
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# import list of provided features
-include $(RIOTBOARD)/$(BOARD)/Makefile.features
-include $(RIOTCPU)/$(CPU)/Makefile.features

DEFAULT_FEATURES += periph_pm

# add available default features to required list
FEATURES_REQUIRED += $(filter-out $(DISABLE_FEATURES), $(filter $(FEATURES_PROVIDED), $(DEFAULT_FEATURES)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, I think there is a conceptual error here:
FEATURES_REQUIRED != (FEATURES_PROVIDED - DISABLE_FEATURES)
FEATURES_REQUIRED should filled by the dependency definitions in the Makefile.deps, e.g. the at86rf2xx requires periph_gpio and periph_spi.

So I guess this should be something like FEATURES_REAL := FEATURES_REQUIRED + DEFAULT_FEATURES - DISABLE_FEATURES?!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FEATURES_REQUIRED is being used to set the defines in riot_build.h.
DEFAULT_FEATURES is used to always include a feature, if available (e.g., always require periph_pm)
DISABLE_FEATURES can be used to override DEFAULT_FEATURES(e.g., this time, build without periph/pm)

The file adds all features from "default features" that are available, unless they are in "disabled features", to the required list.

So in set operations, FEATURES_REQUIRED += (DEFAULT_FEATURES | FEATURES_PROVIDED) - DISABLED_FEATURES. I think the last line in the file does that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think in your last statement we have the problem: FEATURES_REQUIRED should be (DEFAULT_FEATURES & FEATURES_PROVIDED) - DISABLED_FEATURES?!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hehe I think we need to define our operators. ;)

The make line adds all features from the default features that are provided and not disabled to the required features.

If during dependency processing other features are already in the required list, they stay in. Also, disabled_features does only disable default features.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in that case everything is just fine. Good thing we talked about it :-)

4 changes: 2 additions & 2 deletions Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -398,8 +398,8 @@ $(CURDIR)/eclipsesym.xml:
# Extra make goals for testing and comparing changes.
include $(RIOTBASE)/Makefile.buildtests

# import list of provided features
-include $(RIOTBOARD)/$(BOARD)/Makefile.features
# process provided features
include $(RIOTBASE)/Makefile.features

# Export variables used throughout the whole make system:
include $(RIOTBASE)/Makefile.vars
Expand Down
7 changes: 0 additions & 7 deletions boards/avsextrem/drivers/avsextrem-smb380.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

#include "lpc23xx.h" /* LPC23XX/24xx Peripheral Registers */
#include "cpu.h"
#include "lpm.h"
#include "VIC.h"
#include "ssp0-board.h"
#include "smb380-board.h"
Expand Down Expand Up @@ -142,8 +141,6 @@ uint8_t SMB380_HystereseFunctionSample(int16_t *value)

static void SMB380_simple_interrupthandler(void)
{
lpm_awake();

SMB380_getAcceleration(SMB380_X_AXIS, NULL, &simple_buffer[0]);
SMB380_getAcceleration(SMB380_Y_AXIS, NULL, &simple_buffer[1]);
SMB380_getAcceleration(SMB380_Z_AXIS, NULL, &simple_buffer[2]);
Expand Down Expand Up @@ -249,8 +246,6 @@ static void SMB380_extIntHandler(void)
{
int16_t accInt[4];

lpm_awake(); //initializes clock

SMB380_getAcceleration(SMB380_X_AXIS, NULL, &accInt[0]);
SMB380_getAcceleration(SMB380_Y_AXIS, NULL, &accInt[1]);
SMB380_getAcceleration(SMB380_Z_AXIS, NULL, &accInt[2]);
Expand Down Expand Up @@ -1021,7 +1016,6 @@ void SMB380_enableNewDataInt(void)
* prevent deep sleep, reason: 400 µs wake-up time is to long for 3kHz
* interrupts
*/
SETBIT(lpm_prevent_sleep, LPM_PREVENT_SLEEP_ACCSENSOR);
SMB380_Prepare();
SMB380_ssp_write(SMB380_CONTROL4, 0, SMB380_READ_REGISTER);
uReg = SMB380_ssp_read();
Expand Down Expand Up @@ -1050,7 +1044,6 @@ void SMB380_disableNewDataInt(void)
* enable deep sleep, reason: 400 µs wake-up time was to long for 3kHz
* interrupts
*/
CLRBIT(lpm_prevent_sleep, LPM_PREVENT_SLEEP_ACCSENSOR);
irq_restore(cpsr);
}

Expand Down
1 change: 0 additions & 1 deletion boards/avsextrem/drivers/avsextrem-ssp0.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
//#include "mma7455l-board.h"
#include "gpioint.h"
#include <stdio.h>
#include "lpm.h"

//uint16_t sampleRateMMA7455L;
//uint16_t interruptTicksMMA7455L;
Expand Down
1 change: 1 addition & 0 deletions boards/chronos/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ export FFLAGS = rf2500 "prog $(HEXFILE)"
INCLUDES += -I$(RIOTBOARD)/$(BOARD)/drivers/include

USEMODULE += chronos-drivers
USEMODULE += periph_common
53 changes: 0 additions & 53 deletions boards/qemu-i386/x86_board_lpm.c

This file was deleted.

100 changes: 0 additions & 100 deletions core/include/arch/lpm_arch.h

This file was deleted.

77 changes: 0 additions & 77 deletions core/include/lpm.h

This file was deleted.

7 changes: 6 additions & 1 deletion core/include/reboot.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#ifndef REBOOT_H_
#define REBOOT_H_

#include "periph/pm.h"

#ifdef __cplusplus
extern "C" {
#endif
Expand All @@ -28,7 +30,10 @@
*
* This function is used by core_panic() when the DEVELHELP macro is not defined.
*/
void reboot(void);
static inline void reboot(void)
{
pm_reboot();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: why don't we just throw out this file completely and use pm_reboot directly in core_panic?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just seen below, core_panic is already using pm_reboot directly...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I kept the interface for now in order to keep the PR small, and to maybe, have the option to hook in things, like a message, at a central spot.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm: I would like to say it with your words: don't leave stuff there because we might need it again at some point in the future, reintroduce once really needed :-)


#ifdef __cplusplus
}
Expand Down
17 changes: 5 additions & 12 deletions core/kernel_init.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2013 Freie Universität Berlin
* Copyright (C) 2016 Kaspar Schleiser <kaspar@schleiser.de>
* 2013 Freie Universität Berlin
*
* 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
Expand All @@ -24,10 +25,11 @@
#include "kernel_init.h"
#include "sched.h"
#include "thread.h"
#include "lpm.h"
#include "irq.h"
#include "log.h"

#include "periph/pm.h"

#ifdef MODULE_SCHEDSTATISTICS
#include "sched.h"
#endif
Expand All @@ -39,8 +41,6 @@
#include <auto_init.h>
#endif

volatile int lpm_prevent_sleep = 0;

extern int main(void);
static void *main_trampoline(void *arg)
{
Expand All @@ -66,14 +66,7 @@ static void *idle_thread(void *arg)
(void) arg;

while (1) {
if (lpm_prevent_sleep) {
lpm_set(LPM_IDLE);
}
else {
lpm_set(LPM_IDLE);
/* lpm_set(LPM_SLEEP); */
/* lpm_set(LPM_POWERDOWN); */
}
pm_set_lowest();
}

return NULL;
Expand Down
Loading