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

WIP: pm_layered for cpu/atmega_common #8207

Closed

Conversation

roberthartung
Copy link
Member

This is a WIP PR for pm_layered in atmega_common. This has to be discussed on several parts, e.g.:

  • How to actually disable/enable correct hardware devices?

@@ -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);
Copy link
Member Author

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) {
Copy link
Member Author

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);
Copy link
Member Author

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 */
Copy link
Member Author

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) {
Copy link
Member Author

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;
Copy link
Member Author

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
Copy link
Member Author

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

@miri64 miri64 self-assigned this Dec 11, 2017
@miri64 miri64 added Platform: AVR Platform: This PR/issue effects AVR-based platforms Type: new feature The issue requests / The PR implemements a new feature for RIOT labels Dec 11, 2017
@miri64
Copy link
Member

miri64 commented Mar 15, 2018

I'm not sure why I self-assigned for this... Maybe @MichelRottleuthner @kaspar030 or @haukepetersen want to take a look instead?

@miri64 miri64 removed their assignment Mar 15, 2018
@stale
Copy link

stale bot commented Aug 10, 2019

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 stale bot added the State: stale State: The issue / PR has no activity for >185 days label Aug 10, 2019
@roberthartung
Copy link
Member Author

@miri64 Can you remove the label? Now that #11122 is merged, I can finally work on the pm_layered module again (can finally test it with our platform that needs #11122).

@stale stale bot removed the State: stale State: The issue / PR has no activity for >185 days label Aug 19, 2019
@miri64
Copy link
Member

miri64 commented Aug 28, 2019

@miri64 Can you remove the label?

Stale bot did it already in reaction to your comment ;-)

@maribu
Copy link
Member

maribu commented Oct 15, 2019

@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.

@roberthartung
Copy link
Member Author

@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:

  • A simple test that consists of an RTT and enters a low-power sleep mode and then wakes up from it using the RTT.

@miri64
Copy link
Member

miri64 commented Oct 16, 2019

@MrKevinWeiss can probably answer that.

@MrKevinWeiss
Copy link
Contributor

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.

@benpicco
Copy link
Contributor

benpicco commented Dec 3, 2019

A simple test that consists of an RTT and enters a low-power sleep mode and then wakes up from it using the RTT.

tests/periph_pm will do just that.
Unfortunately it uses the RTC instead of RTT, but that should be an easy change.

@stale
Copy link

stale bot commented Jun 5, 2020

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 stale bot added the State: stale State: The issue / PR has no activity for >185 days label Jun 5, 2020
@stale stale bot closed this Jul 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Platform: AVR Platform: This PR/issue effects AVR-based platforms State: stale State: The issue / PR has no activity for >185 days Type: new feature The issue requests / The PR implemements a new feature for RIOT
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants