Commit Graph

960 Commits

Author SHA1 Message Date
Jeff Epler fcddfd0f39
Merge pull request #3083 from tannewt/esp32s2_busio
Add busio support for the ESP32-S2
2020-07-01 21:02:08 -05:00
Jeff Epler 57fde2e07b sdcardio: implement new library for SD card I/O
Testing performed: That a card is successfully mounted on Pygamer with
the built in SD card slot

This module is enabled for most FULL_BUILD boards, but is disabled for
samd21 ("M0"), litex, and pca10100 for various reasons.
2020-06-26 11:50:23 -05:00
Jeff Epler 1d2cc0b968 I2CPeripheral: Rename class and its module
This is an incompatible change.
2020-06-25 11:44:19 -05:00
Scott Shawcroft c5fa9730a8
Compiles! 2020-06-24 12:47:59 -07:00
Scott Shawcroft a26102607e
Add UART support 2020-06-24 12:47:58 -07:00
Nick 33496e9c68 Add nice!nano board support 2020-06-05 19:58:54 -05:00
Diego Elio Pettenò dd5d7c86d2 Fix up end of file and trailing whitespace.
This can be enforced by pre-commit, but correct it separately to make it easier to review.
2020-06-03 10:56:35 +01:00
Scott Shawcroft 959f7297da
Merge remote-tracking branch 'adafruit/master' into wdt-nrf 2020-06-01 17:01:16 -07:00
Scott Shawcroft 4146d6f872
Merge pull request #2890 from jepler/nrf-audio-tick
nrf: put supervisor enable/disable tick in place
2020-06-01 15:51:22 -07:00
Scott Shawcroft 323cca8910
Merge remote-tracking branch 'adafruit/master' into wdt-nrf 2020-06-01 15:18:12 -07:00
Scott Shawcroft 2fd7a43f2f
Merge remote-tracking branch 'adafruit/master' into wdt-nrf 2020-05-29 10:16:24 -07:00
Dan Halbert 0d2fee95e2 enable aesio on all nRF52840 boards 2020-05-29 11:06:30 -04:00
Scott Shawcroft 796373b8be
A number of small ESP32S2 fixes:
* Fix flash writes that don't end on a sector boundary. Fixes #2944
* Fix enum incompatibility with IDF.
* Fix printf output so it goes out debug UART.
* Increase stack size to 8k.
* Fix sleep of less than a tick so it doesn't crash.
2020-05-28 15:43:55 -07:00
Scott Shawcroft 9380c34cf7
Merge remote-tracking branch 'adafruit/master' into wdt-nrf 2020-05-27 10:47:08 -07:00
Dan Halbert d06a7c4671
Correct HiiBot BlueFi USB_PID
Donated a PID set for HiiBot BlueFi.
2020-05-27 11:47:15 -04:00
Sean Cross aac5a4f178 watchdog: use common_hal_watchdog_* pattern
This pulls all common functionality into `shared-bindings` and keeps
platform-specific code inside `nrf`. Additionally, this performs most
validation in the `shared-bindings` site.

The only validation that occurs inside platform-specific `common-hal`
code is related to timeout limits that are platform-specific.

Additionally, all documentation is now inside the `shared-bindings`
directory.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-05-27 11:38:29 +08:00
Sean Cross e470376c12 nrf: add ticks (not subticks) to overflow count during reset
Signed-off-by: Sean Cross <sean@xobs.io>
2020-05-27 11:28:50 +08:00
Sean Cross 296ba101ec nrf: set WDT priority to 2
The previous setting of `1` meant that the bluetooth system couldn't be
used when the watchdog timer was enabled.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-05-27 11:28:50 +08:00
Sean Cross d0f1b59be5 nrf: pca10100: disable some unused features to shrink image
This removes some features that are largely unused in order to get the
image to fit.

Recommended in
https://github.com/adafruit/circuitpython/pull/2933#issuecomment-632859678

Signed-off-by: Sean Cross <sean@xobs.io>
2020-05-27 11:28:50 +08:00
Sean Cross 33001f4e19 nrf: simmel: shrink filesystem to fit watchdog timer
The watchdog timer has increased the amount of code and text that's
required.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-05-27 11:28:50 +08:00
Sean Cross daf7c2857d nrf: port: save rtc value across reboots
As part of the reset process, save the current tick count to an
uninitialized memory location.  That way, the current tick value will be
preserved across reboots.

A reboot will cause us to lose a certain number of ticks, depending on
how long a reboot takes, however if reboots are infrequent then this
will not be a large amount of time lost.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-05-27 11:28:49 +08:00
Sean Cross 5edc29c6a5 nrf: microcontroller: use port reset path
For `microcontroller.reset()`, don't manually call NVIC_SystemReset().
Instead, call the `port_reset()` in case the port wants to do any
cleanup.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-05-27 11:28:49 +08:00
Sean Cross c7efc94a33 watchdog: move timeout exception to shared-bindings
Make this exception globally available to all platforms that have
enabled the watchdog timer.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-05-27 11:28:49 +08:00
Sean Cross c5c13a8ba1 nrf: reset watchdog as part of port_reset()
Signed-off-by: Sean Cross <sean@xobs.io>
2020-05-27 11:28:49 +08:00
Sean Cross 108409c6cd nrf: common-hal: finish reworking exceptions
This finishes the rework of the exception handler, which is once
again stored inside the watchdog timer module.

This also implements a `watchdog_reset()` that is used to disable the
RAISE watchdog, if one is enabled.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-05-27 11:28:49 +08:00
Sean Cross bd086a102e Revert "add WatchDogTimeout exception"
This reverts commit 561e7e619095869f58fc728d428f3ff20e8bfc40.
2020-05-27 11:28:49 +08:00
Sean Cross 589cb1af6d nrf: watchdog: use nrfx_wdt driver
Instead of directly poking registers, use `nrfx_wdt`.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-05-27 11:28:49 +08:00
Sean Cross e738f5eaa1 nrf: boot into safe mode sometimes for watchdog reset
If the watchdog resets the system and we're plugged into USB, boot into
safe mode.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-05-27 11:28:49 +08:00
Sean Cross 08362c9cab watchdogtimer: refactor to new api
This refactors the WatchDogTimer API to use the format proposed in
https://github.com/adafruit/circuitpython/pull/2933#issuecomment-632268227

Signed-off-by: Sean Cross <sean@xobs.io>
2020-05-27 11:28:49 +08:00
Sean Cross ae950bc050 add WatchDogTimeout exception
This adds an exception to be raised when the WatchDogTimer times out.

Note that this currently causes a HardFault, and it's not clear why it's
not behaving properly.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-05-27 11:28:49 +08:00
Sean Cross 0169ea5155 nrf: discard arm exception sections
Since these exceptions are unused, don't include them in the output
binary.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-05-27 11:28:49 +08:00
Sean Cross 8f46133917 nrf: watchdog: implement software watchdogtimer
This adds a software WatchDogTimer implementation that can be used for
testing.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-05-27 11:28:49 +08:00
Sean Cross 595f6387c2 watchdog: rename module from `wdt` and move to `microcontroller`
This also places it under the `microcontroller` object.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-05-27 11:28:49 +08:00
Sean Cross c23f151b6b nrf: enable wdt for all platforms
Signed-off-by: Sean Cross <sean@xobs.io>
2020-05-27 11:28:48 +08:00
Sean Cross fbe1c05832 nrf: simmel: enable wdt support
This enables WDT support for Simmel. Other platforms cannot yet use
WDT because it overflows their flash storage.

Enable CIRCUITPY_WDT support for the nrf target.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-05-27 11:28:48 +08:00
Sean Cross abd01c5fbb nrf: add watchdog module
Add common-hal bindings to allow the watchdog module to be used
on nrf platforms.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-05-27 11:28:48 +08:00
Sean Cross 17ef2df2ca nrf: ld: add ARM.exidx to output image
With the WDT changes, building Circuit Python results in the following error:

/opt/gcc-arm-none-eabi-9-2019-q4-major/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld: section .ARM.exidx LMA [00000000000621c8,00000000000621cf] overlaps section .data LMA [00000000000621c8,0000000000062383]

This is because unwinding data is getting generated, but has nowhere to go.
Re-enable this data in the linker script so it is saved.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-05-27 11:28:48 +08:00
Scott Shawcroft 2ffd70417d
Merge remote-tracking branch 'adafruit/master' into esp32s2_digitalio 2020-05-26 13:09:57 -07:00
Dan Halbert 19f0d82048
Merge pull request #2955 from BradChan/master
Add hiibot_bluefi board definitions
2020-05-26 15:37:35 -04:00
Scott Shawcroft 3bb6a32a20
Merge branch 'master' into esp32s2_digitalio 2020-05-21 08:52:39 -07:00
Sean Cross 67cf005ee5 nrf: nvm: assume sd is not enabled if interrupts are off
If interrupts are disabled, then calling sd_* functions will hardfault.
Instead, assume that it's safe to write if interrupts are disabled.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-05-21 22:04:20 +08:00
Sean Cross fd4ef233c6 nrf: port: add memory barrier before wfi
ARM recommends issuing a DSB instruction propr to issuing WFI, as it is
required on many parts suchas Cortex-M7. This is effectively a no-op on
the Cortex-M4 used in most NRF parts, however it ensures that we won't
be surprised when new parts come out.

See
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dai0321a/BIHICBGB.html
for more information.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-05-21 21:46:37 +08:00
Sean Cross 77cf4dce8f nrf: disable interrupts before running wfi
In order to ensure we don't have any outstanding requests, disable
interrupts prior to issuing `WFI`.

As part of this process, check to see if there are any pending USB
requests, and only execute the `WFI` if there is no pending data.

This fixes #2855 on NRF.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-05-21 21:43:52 +08:00
Scott Shawcroft c32214ccc7
Merge pull request #2932 from simmel-project/nrf-rtc-reset
nrf: reset rtc as part of port_reset()
2020-05-20 11:39:16 -07:00
Scott Shawcroft ba724fffb4
Merge remote-tracking branch 'adafruit/master' into esp32s2_digitalio 2020-05-20 10:48:27 -07:00
Scott Shawcroft fd0420d432
Update digitalio api for other ports 2020-05-20 09:23:42 -07:00
Sean Cross 4cca455c9b nrf: reset rtc as part of port_reset()
On NRF, the `rtc_reset()` function is never called.  As a result,
calls to `time.time()` return a cryptic error>

```
>>> import time
>>> time.time()
'' object has no attribute 'datetime'
>>>
```

This is because `MP_STATE_VM(rtc_time_source)` is not initialized
due to `rtc_reset()` never being called.

If `CIRCUITPY_RTC` is enabled, call `rtc_reset()` as part of the
`reset_port()` call. This ensures that `time.time()` works as expected.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-05-20 16:44:18 +08:00
Scott Shawcroft 916ca9f8a6
Merge pull request #2910 from tannewt/esp32s2
Add initial ESP32S2 support
2020-05-19 12:53:23 -07:00
Sean Cross c1bcc25b88 nrf: _bleio: clean up timeout calculation
The timeout value is calculated by the common-hal layer now, so we don't
need to be quite so clever about calculating it here.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-05-19 21:56:39 +08:00
Sean Cross 34f91f01c6 bleio: adapter: add advertising timeout and status
Add a field to allow specifying a timeout when initiating advertising.
As part of this, add a new property to determine if the device is still
advertising.

Additionally, have the `anonymous` property require a timeout, and set
the timeout to the maximum possible value if no timeout is specified.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-05-19 15:01:19 +08:00