arduino / arduino/ArduinoCore-API
Low Power Shared API
- Dominant language
- C++
- Stars
- 306
- Forks
- 150
- PR merge metrics
- No merged PRs in 30d
Description
As per ongoing discussion with .org about libraries, here is a proposal for MCU (and companion MCU) standby API
https://github.com/rocketscream/Low-Power is a good starting point, AVR API is too granular so we should avoid it. But the SAMD API is quite good.
Function calls would simply be
- `idle()`
- `sleep()`
- `deepSleep()` -> might call `sleep()` if there is only one sleep mode
which in modern MCU is like WFI with peripherals enabled and WFI with peripherals disabled.
STM32 processors also have a mode called WFE which I would avoid exposing. Other MCU (nRF chips for example) might have multiple sleep levels; I'd select two/three of them to be exposed.
To register a wakeup source I propose overloading `attachInterrupt` API with a couple of versions:
- `attachInterrupt(pin, function, MODE, wakeup)` would become the main function;
- `attachInterrupt(pin, function, MODE, false)` will be called for classic API
- `attachInterruptWakeup(pin, function, MODE)` will call `attachInterrupt(pin, function, MODE, true)`
If function is NULL, wakeup-enable bit should be set and no function called
if `pin` in `NOT_A_PIN`, extra code can handle the additional wakeup sources.
I suggest using macros like `RTC_WAKEUP` or `ADC_WAKEUP` with high values (0xFF, 0FE etc)
@cmaglie @sandeepmistry @tigoe any thoughts about that?
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the proposed idle(), sleep(), and deepSleep() entry points and the attachInterrupt overloads described in the issue. Review the linked Low-Power library and SAMD API as references, then determine the supported MCU behavior and wakeup-source design. Done means the API proposal has a decided scope and an agreed implementation path.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- api, embedded-iot
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100