-
Notifications
You must be signed in to change notification settings - Fork 2k
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
WIP: pm_layered for cpu/atmega_common #8207
Conversation
@@ -33,6 +36,10 @@ static mutex_t lock = MUTEX_INIT; | |||
static inline void _prep(void) | |||
{ | |||
mutex_lock(&lock); | |||
#ifdef MODULE_PM_LAYERED | |||
pm_block(PM_INVALID_ADC); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The define PM_INVALID_ADC defines the mode which the ADC needs to be running.
#ifdef MODULE_PM_LAYERED | ||
pm_block(PM_INVALID_SPI); | ||
#endif | ||
switch(bus) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a better way than a switch/case?
|
||
/* configure as master, with given mode and clock */ | ||
SPSR = (clk >> S2X_SHIFT); | ||
SPCR = ((1 << SPE) | (1 << MSTR) | mode | (clk & CLK_MASK)); | ||
//SPCR |= (1 << SPE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicate line... right?
@@ -58,6 +62,7 @@ typedef struct { | |||
void *arg; /**< interrupt callback argument */ | |||
uint8_t mode; /**< remember the configured mode */ | |||
uint8_t isrs; /**< remember the interrupt state */ | |||
int8_t num; /** < hardware timer number */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an approach where I map the timer within RIOT to the actual hardware timer. Any better solutions?
@@ -85,6 +90,113 @@ static ctx_t *ctx[] = {{ NULL }}; | |||
#endif | |||
/** @} */ | |||
|
|||
static inline void timer_poweroff(tim_t tim) { | |||
switch(ctx[tim].num) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, big switch/case
|
||
#ifdef MEGA_TIMER0 | ||
if(ctx[tim].dev == MEGA_TIMER0) { | ||
ctx[tim].num = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe there is a better/more elegant way of setting the hardware timer?
|
||
if (sched_context_switch_request) { | ||
thread_yield(); | ||
} | ||
} | ||
|
||
void uart_poweron(uart_t uart) { | ||
switch(ctx[uart].num) { | ||
#ifdef MEGA_UART0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need a differentiation if we have rx/tx enabled or not? See discussion in #7947
I'm not sure why I self-assigned for this... Maybe @MichelRottleuthner @kaspar030 or @haukepetersen want to take a look instead? |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you want me to ignore this issue, please mark it with the "State: don't stale" label. Thank you for your contributions. |
Stale bot did it already in reaction to your comment ;-) |
@roberthartung: Feel free to ping me when this PR has been rebased and got into a state a review makes sense. I really would like to see the power management of the ATmega platform improved in RIOT. |
@maribu Thanks! Will work on this as one of the next steps. Are there enough tests for pm already? I should also add my pm test to this PR:
|
@MrKevinWeiss can probably answer that. |
I haven't touch pm stuff yet in the testing. I am working on a way to do so with the HiL setup but I don't think it would be ready in time. I can however run some tests manually and can also monitor the current (I think). I think having a simple (on target) test that turns things off and on is great. You can also try failure cases where you try to turn the power off when something is held on. Or what happens when turning power on twice... That kind of thing. The easier the test is to run the easier it is to merge in. My "helping people" time is currently with the release and esp8266 PR but after I clear those away I would be happy work on how to test this. |
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you want me to ignore this issue, please mark it with the "State: don't stale" label. Thank you for your contributions. |
This is a WIP PR for pm_layered in atmega_common. This has to be discussed on several parts, e.g.: