cpu: lpc1768: provide periph_pm#8861
Conversation
59bfd39 to
587a41c
Compare
aabadie
left a comment
There was a problem hiding this comment.
Untested ACK (trusting your results)
|
And go! |
| LPC_SC->PCON = 0x00; | ||
| cortexm_sleep(1); | ||
| break; | ||
| case 2: |
There was a problem hiding this comment.
Should this be the default case, or is there a use-case for blocking mode 2?
There was a problem hiding this comment.
The way I interpret pm_layered.h is as follows:
- Mode 0 to
PM_NUM_MODES - 1apply power management - Mode
PM_NUM_MODES(the implicit one) doesn't.
That's what I have implemented here (PM_NUM_MODES is 3).
There was a problem hiding this comment.
OK!
It's just that the mode PM_NUM_MODES sets the CPU to idle on the other cortex-m. So I was wondering if LPC_SC->PCON = 0x00; means "no power management other than CPU idle", in which case I suggest setting PM_NUM_MODES=2.
There was a problem hiding this comment.
LPC_SC->PCON = 0x00; is needed to ensure that it doesn't erroneously enter deep sleep on __WFI(). This could be the case if another piece of code sets this before entering idle mode.
So now I understand that PM_NUM_MODES == 3 should enter idle mode (instead of while(1))? Then I should change PM_NUM_MODES to 2, so that the implicit idle power mode is __WFI(), right?
There was a problem hiding this comment.
Ok, thanks! I'll create another PR to fix this.
Just one more question: should I then add the default case, or case 2 in combination with an assert(mode <= PM_NUM_MODES)?
IMHO mode > PM_NUM_MODES is wrong.
There was a problem hiding this comment.
IMHO mode > PM_NUM_MODES is wrong.
True, but we should rather catch that in pm_layered.c instead of adding those asserts to every pm_set implementation. IMO the default case will cause the least maintanance in the future. ;)

Contribution description
This provides power management for the LPC1768. It's based on this application note.
Tested using #8848 on the Seeeduino Arch-Pro. Although I could only measure milli-amps, I do see a difference when forcing different power modes.
Issues/PRs references
None