Commit Graph

210 Commits

Author SHA1 Message Date
Dan Halbert
d4d96bb25f
Merge pull request #4236 from jun2sak/nrf52-sleep
sleep and wakeup for nrf52
2021-04-28 12:11:31 -04:00
Dan Halbert
8500e846c6 partially working 2021-04-27 23:53:23 -04:00
Dan Halbert
f98a54628b wip: compiles 2021-04-27 14:37:36 -04:00
Dan Halbert
c26e49c2e6 wip: starting to try to compile 2021-04-25 23:17:41 -04:00
Dan Halbert
9d1fcc3b14 merge from main 2021-04-25 10:27:52 -04:00
jun2sak
7accb8b173 modify copyright notice. 2021-04-25 19:57:21 +09:00
Artyom Skrobov
4e3c1d4a4c [build] Allow USB to be set to 0
Unify USB-related makefile var and C def as CIRCUITPY_USB.

Always define it as 0 or 1, same as all other settings.

USB_AVAILABLE was conditionally defined in supervisor.mk,
but never actually used to #ifdef USB-related code.

Loosely related to #4546
2021-04-23 11:13:34 -04:00
Dan Halbert
2b4c88d633 wip: partial HID, still needs rework 2021-04-23 00:18:05 -04:00
Lucian Copeland
7eeea869ac Fix light sleep global alarms, API revisions 2021-04-15 15:02:42 -04:00
Dan Halbert
4a7e129287 wip: latent usb device enabling/disabling 2021-04-13 23:33:44 -04:00
jun2sak
6e9429d779 soft reboot for pretending deep sleep. 2021-04-12 20:53:14 +09:00
Lucian Copeland
15764b4c24 Merge remote-tracking branch 'upstream/main' into nrf52-sleep 2021-04-09 13:48:45 -04:00
Lucian Copeland
17585e1e07 Clean up API 2021-04-02 14:08:48 -04:00
Lucian Copeland
d35a307ffa Merge branch 'sleep-api-update' into stm-alarm 2021-03-29 12:27:25 -04:00
Lucian Copeland
00178ca5e0 Sleep API changes, redundancy fix 2021-03-27 14:14:57 -04:00
Lucian Copeland
529fb52309 Style changes and wakeup detection 2021-03-27 13:16:12 -04:00
Lucian Copeland
6b2c9985ff Extract RTC, implement fake RTC deepsleep 2021-03-11 17:50:05 -05:00
jun2sak
3fab9f8b1b new wait-until-alarm design, don't use System OFF. 2021-03-07 01:09:54 +09:00
Lucian Copeland
f1792c8474 Extract EXTI, create base sleep framework 2021-03-02 11:41:53 -05:00
jun2sak
7bb789625e use the original port_idle_until_interrupt() if not CIRCUITPY_ALARM. 2021-02-28 16:27:37 +09:00
jun2sak
3e47e00291 address the pretending-to-deep-sleep issue. 2021-02-28 15:57:37 +09:00
jun2sak
fac86c8277 remove unused debug printf's. 2021-02-28 15:34:55 +09:00
jun2sak
9661d67cd3 replace MY_DEBUG_UART -> NRF_DEBUG_PRINT. 2021-02-25 01:49:57 +09:00
jun2sak
057682f776 cleanup. 2021-02-24 00:13:11 +09:00
jun2sak
ec64fa6a29 move dump_xxx functions to debug_uart.c. 2021-02-23 12:16:37 +09:00
jun2sak
1da8b9900a Merge branch 'main' into nrf52-sleep 2021-02-21 13:35:06 +09:00
jun2sak
26f8f532f1 safe mode fix. 2021-02-21 00:47:07 +09:00
jun2sak
e6350ff834 Initial commit. 2021-02-17 20:53:18 +09:00
Dan Halbert
0b8f1b9a90 wip: usb_cdc.serials 2021-02-15 20:06:18 -05:00
Dan Halbert
25d456a5b8 shrink a couple of builds 2021-02-04 22:15:32 -05:00
hathach
8d7b1f9e8c add usb_background_schedule()
unconditionally schedule usb background after
background_callback_reset()
2021-02-04 16:00:14 +07:00
Christian Walther
8889ac12e1 Add supervisor.set_next_code() function (prototype).
Part of #1084.
2021-01-23 23:05:31 +01:00
Scott Shawcroft
fb1e0106b5
Fix press any key message 2021-01-20 19:16:56 -08:00
microDev
0bad6110d4
update wake-alarm implementation 2020-12-31 02:44:20 +05:30
Scott Shawcroft
1fca297a2d
A couple sleep fixes
* Better messaging when code is stopped by an auto-reload.
* Auto-reload works during sleeps on ESP32-S2. Ticks wake up the
  main task each time.
* Made internal naming consistent. CamelCase Python names are NOT
  separated by an underscore.
2020-12-22 16:13:02 -08:00
Dan Halbert
d4e9eea397
mark alarm.wake_alarm during gc sweep 2020-12-22 08:11:01 -08:00
Scott Shawcroft
1ad49d9a18
Add alarm.pin that wakes on pin level
Fixes #3787
2020-12-15 18:12:59 -08:00
Dan Halbert
cf938983e9 SleepMemory + set alarm.wake_alarm 2020-12-11 08:10:26 -05:00
Mike Causer
eedcc98cc5 Fix some spelling mistakes 2020-12-10 02:52:18 +11:00
Scott Shawcroft
0b4bcd9599
Fix build and more comments 2020-12-08 13:05:21 -08:00
Scott Shawcroft
40118bcf57
Add board_deinit for use with sleep
This changes lots of files to unify `board.h` across ports. It adds
`board_deinit` when CIRCUITPY_ALARM is set. `main.c` uses it to
deinit the board before deep sleeping (even when pretending.)

Deep sleep is now a two step process for the port. First, the
port should prepare to deep sleep based on the given alarms. It
should set alarms for both deep and pretend sleep. In particular,
the pretend versions should be set immediately so that we don't
miss an alarm as we shutdown. These alarms should also wake from
`port_idle_until_interrupt` which is used when pretending to deep
sleep.

Second, when real deep sleeping, `alarm_enter_deep_sleep` is called.
The port should set any alarms it didn't during prepare based on
data it saved internally during prepare.

ESP32-S2 sleep is a bit reorganized to locate more logic with
TimeAlarm. This will help it scale to more alarm types.

Fixes #3786
2020-12-08 10:52:25 -08:00
Dan Halbert
169b487509 Include wifi.radio singleton in gc 2020-12-07 11:07:56 -05:00
Scott Shawcroft
d7ba641ff6
Merge pull request #3767 from dhalbert/sleep
Initial alarm and sleep PR: time alarms with light and deep sleep; PinAlarms not yet implemented
2020-12-02 12:51:43 -08:00
Dan Halbert
8b7c23c1ee address review comments 2020-12-01 20:01:14 -05:00
Christian Walther
c7404a3ff8 Add movable allocation system.
This allows calls to `allocate_memory()` while the VM is running, it will then allocate from the GC heap (unless there is a suitable hole among the supervisor allocations), and when the VM exits and the GC heap is freed, the allocation will be moved to the bottom of the former GC heap and transformed into a proper supervisor allocation. Existing movable allocations will also be moved to defragment the supervisor heap and ensure that the next VM run gets as much memory as possible for the GC heap.

By itself this breaks terminalio because it violates the assumption that supervisor_display_move_memory() still has access to an undisturbed heap to copy the tilegrid from. It will work in many cases, but if you're unlucky you will get garbled terminal contents after exiting from the vm run that created the display. This will be fixed in the following commit, which is separate to simplify review.
2020-11-28 17:50:23 +01:00
Dan Halbert
104a089677 deep sleep working; deep sleep delay when connected 2020-11-26 22:06:37 -05:00
Dan Halbert
ef0830bfe2 merge from upstream + wip 2020-11-25 17:52:06 -05:00
Dan Halbert
9dbea36eac changed alarm.time API 2020-11-25 15:09:27 -05:00
Dan Halbert
f868cc5dd0 some API renaming and bug fixes; fix docs 2020-11-24 23:37:05 -05:00
Dan Halbert
7a45afc549 working, but need to avoid deep sleeping too fast before USB ready 2020-11-23 22:44:53 -05:00
Dan Halbert
a0f1ec3c4a wip 2020-11-22 19:10:09 -05:00
Dan Halbert
75559f35cc wip: ResetReason to microcontroller.cpu 2020-11-21 23:29:52 -05:00
Dan Halbert
39e1f52e28 wip; not compiling yet 2020-11-19 17:47:12 -05:00
Dan Halbert
649c930536 wip 2020-11-19 15:43:39 -05:00
Dan Halbert
bb77f1d130 wip: initial code changes, starting from @tannewt's sleepio branch 2020-11-16 11:56:20 -05:00
Scott Shawcroft
9a4efed8cb
Start tweaking the workflow to sleep 2020-10-27 17:55:03 -07:00
microDev
0e444f0de8
Implement sleep on code.py exit 2020-10-27 16:17:29 -07:00
microDev
e310b871c8
Get io wake working 2020-10-27 16:13:25 -07:00
microDev
3a30887b44
Update soft reboot message 2020-10-27 16:13:24 -07:00
Christian Walther
f4f80e07ca Fix lost board.SPI and board.I2C after being used by display.
Fixes #3581.

Pins were marked as never_reset by common_hal_displayio_fourwire_construct() and common_hal_sharpdisplay_framebuffer_construct(), but these marks were never removed, so at the end of a session after displayio.release_displays(), {spi|i2c}_singleton would be set to NULL but the pins would not be reset. In the next session, board.SPI() and board.I2C() were unable to reconstruct the object because the pins were still in use.

For symmetry with creation of the singleton, add deinitialization before setting it to NULL in reset_board_busses(). This makes the pins resettable, so that reset_port(), moved behind it, then resets them.
2020-10-26 22:44:38 +01:00
microDev
8487a51995
Factor out code.py status messages 2020-10-07 23:53:08 +05:30
microDev
d01b9ce933
Disable auto-reload in safe mode 2020-10-07 22:15:05 +05:30
Jeff Epler
4869dbdc67 canio: rename from _canio
This reflects our belief that the API is stable enough to avoid incompatible changes during 6.x.
2020-09-21 16:44:26 -05:00
Jeff Epler
ca32a81bf1 main.c: Correct CANIO if-guard 2020-09-21 16:44:26 -05:00
Jeff Epler
a2e1867f69 _canio: Minimal implementation for SAM E5x MCUs
Tested & working:

 * Send standard packets
 * Receive standard packets (1 FIFO, no filter)

Interoperation between SAM E54 Xplained running this tree and
MicroPython running on STM32F405 Feather with an external
transceiver was also tested.

Many other aspects of a full implementation are not yet present,
such as error detection and recovery.
2020-09-21 16:44:26 -05:00
Dan Halbert
6dbd369272 merge from upstream 2020-08-30 14:39:03 -04:00
Scott Shawcroft
f39708abb2
Add PSRAM support to ESP32S2
When configured the CircuitPython heap will be on the external RAM.
When not available, the heap will be 48k inside the IDF heap.
2020-08-21 16:20:58 -07:00
Dan Halbert
0e30dd8bcc merge from upstream; working; includes debug_out code for debugging via Saleae for posterity 2020-08-20 20:29:57 -04:00
Dan Halbert
d0ffdda5bb fix reset logic to not do pin ops or heap ops at bad times 2020-08-13 17:47:35 -04:00
Scott Shawcroft
bbac68e77c
Merge pull request #3232 from hierophect/esp32-neopixel
ESP32-S2: Add Neopixel support
2020-08-11 11:04:39 -07:00
Lucian Copeland
4613b58a31 Add skip for rgb matrix exception handling 2020-08-10 18:00:50 -04:00
Dan Halbert
ac95106b88 service discovery works; need to work on char and descriptor discovery 2020-08-04 18:24:37 -04:00
Jeff Epler
d92a77fdd3 main: Allow these arrays to reside in ROM
The missing second "const" made these mutable arrays pointing to
const string data.
2020-08-04 14:45:45 -05:00
Jeff Epler
a85b6441fc main: Drop "double extension" detection if not FULL_BUILD
This saves nearly 200 bytes.  Curiously, it also saves RAM.
2020-08-04 14:45:45 -05:00
Jeff Epler
d0427cf60c Combine some "safe mode" messages 2020-08-04 14:45:45 -05:00
Scott Shawcroft
2bd6d05663
Add externs. GCC10 complains about duplicate defines 2020-07-22 16:26:46 -07:00
Scott Shawcroft
1ec3580946
Merge branch 'main' into memmonitor 2020-07-22 12:24:19 -07:00
Scott Shawcroft
389c81341d
Tweak declaration for boards with TCM 2020-07-20 18:16:20 -07:00
Scott Shawcroft
a1e4814a27
Get AllocationAlarm working 2020-07-17 17:15:03 -07:00
Scott Shawcroft
1160635608
Enable PYSTACK to keep function state out of the heap 2020-07-17 17:03:42 -07:00
Jeff Epler
a18a392109 background_callback: Add gc collect callback
A background callback must never outlive its related object.  By
collecting the head of the linked list of background tasks, this will
not happen.

One hypothetical case where this could happen is if an MP3Decoder is
deleted while its callback to fill its buffer is scheduled.
2020-07-17 08:36:26 -05:00
Jeff Epler
1df48176ce supervisor: factor supervisor_background_tasks from sundry ports 2020-07-15 11:49:44 -05:00
Jeff Epler
1474fccd2f supervisor: Add a linked list of background callbacks
In time, we should transition interrupt driven background tasks out of the
overall run_background_tasks into distinct background callbacks,
so that the number of checks that occur with each tick is reduced.
2020-07-15 09:26:47 -05:00
Jeff Epler
fe3e8d1589 string compression: save a few bits per string
Length was stored as a 16-bit number always.  Most translations have
a max length far less.  For example, US English translation lengths
always fit in just 8 bits.  probably all languages fit in 9 bits.

This also has the side effect of reducing the alignment of
compressed_string_t from 2 bytes to 1.

testing performed: ran in german and english on pyruler, printed messages
looked right.

Firmware size, en_US
Before: 3044 bytes free in flash
After: 3408 bytes free in flash

Firmware size, de_DE (with #2967 merged to restore translations)
Before: 1236 bytes free in flash
After: 1600 bytes free in flash
2020-05-28 08:36:08 -05:00
Scott Shawcroft
916ca9f8a6
Merge pull request #2910 from tannewt/esp32s2
Add initial ESP32S2 support
2020-05-19 12:53:23 -07:00
Mark Olsson
007c92ee6a Enable showing the console on a debug uart 2020-05-19 02:02:52 +02:00
Scott Shawcroft
6aaab005c5
Initial ESP32S2 port.
Basic blinky works but doesn't check pins.
2020-05-15 15:36:16 -07:00
Scott Shawcroft
418333979a
Fix autoreload, neopixel, monotonic_ns and sleep w/o SD 2020-03-13 11:12:31 -07:00
Lucian Copeland
100409961a Move board_init to main.c 2020-01-29 16:29:43 -05:00
Dan Halbert
ef2ef7a6b8 merge from master 2019-12-12 15:51:13 -05:00
Dan Halbert
7889b999cc Fix flash write error handling; clean up safe mode message printing 2019-12-12 14:41:49 -05:00
Dan Halbert
40434d6919 wip 2019-12-05 22:45:53 -05:00
Scott Shawcroft
ae30a1e5aa
Refine _bleio
This PR refines the _bleio API. It was originally motivated by
the addition of a new CircuitPython service that enables reading
and modifying files on the device. Moving the BLE lifecycle outside
of the VM motivated a number of changes to remove heap allocations
in some APIs.

It also motivated unifying connection initiation to the Adapter class
rather than the Central and Peripheral classes which have been removed.
Adapter now handles the GAP portion of BLE including advertising, which
has moved but is largely unchanged, and scanning, which has been enhanced
to return an iterator of filtered results.

Once a connection is created (either by us (aka Central) or a remote
device (aka Peripheral)) it is represented by a new Connection class.
This class knows the current connection state and can discover and
instantiate remote Services along with their Characteristics and
Descriptors.

Relates to #586
2019-10-21 18:57:03 -07:00
Dan Halbert
7b79ac3739 Parameterize linker script 2019-10-20 23:50:12 -04:00
Kamil Tomaszewski
f3151bb6c4 Use get top and limit stack functions 2019-10-18 11:05:08 +02:00
Scott Shawcroft
f8e4ccac45
Fix builds without displayio 2019-08-22 14:23:33 -07:00
Scott Shawcroft
24b30965c4
Refresh ePaper displays once code.py is done running 2019-08-22 14:23:32 -07:00
Hierophect
a63df51893 Requested changes, general cleanup 2019-07-24 14:21:27 -04:00
Hierophect
ee75f1aaaf Fix LED misuse interfering with atmel builds 2019-07-22 14:59:06 -04:00
Hierophect
58630a844a Add feature conditionals and clean up 2019-07-22 12:58:28 -04:00