Commit Graph

107 Commits

Author SHA1 Message Date
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
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
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
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
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
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
cf690bd390
Merge remote-tracking branch 'adafruit/master' into esp32s2 2020-05-18 16:46:41 -07:00
Sean Cross
9f7c26c60d nrf: port: call common_hal_rtc_init() during init
Call the new function to set the RTC, or reset it if the offset is not
valid.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-05-18 11:52:30 +08:00
Sean Cross
3b5f5ddaa6 nrf: port: move saved word into .uninitialized section
Circuit Python supports saving a single word of data across reboots.
Previously, this data was placed immediately following the .bss.

However, this appeared to not work, as Circuit Python zeroes out the
heap when it starts up, and the heap begins immediately after the .bss.

Switch to using the new .uninitialized section in order to store this
word across resets.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-05-18 11:52:25 +08:00
Sean Cross
192bb155fa nrf: port: move the heap after .uninitialized
Previously, it was placed following .bss.  However, now that there is a
new section after .bss, the heap must be moved forward.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-05-18 11:52:20 +08:00
Scott Shawcroft
3c1469b0a5
Add port_fixed_stack for more builds 2020-05-15 16:22:33 -07:00
Scott Shawcroft
755d404edf
Merge remote-tracking branch 'adafruit/master' into lower_power 2020-04-27 16:45:10 -07:00
Scott Shawcroft
9e4b94f466
Merge pull request #2805 from tannewt/update_tinyusb
Update tinyusb
2020-04-26 20:55:36 -07:00
Scott Shawcroft
5c7f6e6211
Remove empty #if and add missing includes. 2020-04-24 11:48:55 -07:00
Sean Cross
066f486b28 nrf: supervisor: support building without BUSIO
Only initialize i2c, spi, and uart if building with BUSIO.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-04-21 10:44:20 +08:00
Sean Cross
ac9d336f40 nrf: make neopixel support optional
Add a conditional around the call to neopixel_write(), allowing us
to build for nrf without neopixel support.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-04-21 09:56:27 +08:00
Scott Shawcroft
7e3d4c61b5
Update TinyUSB and add interrupt hooks. 2020-04-17 14:16:49 -07:00
Scott Shawcroft
48b5f2a384
Initial work on SAMD 2020-03-13 11:16:41 -07:00
Scott Shawcroft
ed5cdd7e09
Hopefully fix flash flush and hopefully audio as well. 2020-03-13 11:12:31 -07:00
Scott Shawcroft
418333979a
Fix autoreload, neopixel, monotonic_ns and sleep w/o SD 2020-03-13 11:12:31 -07:00
Scott Shawcroft
6f60afe8c5
First try at lowering the power consumption 2020-03-13 11:12:30 -07:00
Jeff Epler
1e6c08fc30 nrf: sqpi_flash: Handle unaligned reads 2020-02-28 10:03:37 -06:00
Dan Halbert
23d6a3dc1f merge from upstream 2020-02-20 22:27:16 -05:00
hierophect
898f4e1f72
Merge branch 'master' into stm32-meowbit 2020-01-29 16:32:08 -05:00
Lucian Copeland
100409961a Move board_init to main.c 2020-01-29 16:29:43 -05:00
Scott Shawcroft
1c39606345
Fix other builds missing new heap bounds functions 2020-01-18 18:06:56 -08:00
Roy Hooper
4e040b0152 add reset of heap to board reset for nrf port 2020-01-08 15:15:27 -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
013c840862 working on all ports 2019-12-10 20:27:30 -05:00
Dan Halbert
40434d6919 wip 2019-12-05 22:45:53 -05:00
Dan Halbert
7b79ac3739 Parameterize linker script 2019-10-20 23:50:12 -04:00
Kamil Tomaszewski
96756b3945 Add functions to get top and limit stack 2019-10-18 11:04:45 +02:00
Dan Halbert
be8136dc6d Merge remote-tracking branch 'adafruit/master' into bonding1 2019-10-15 15:55:21 -04:00
Dan Halbert
fdd7ebef2d change calibration from analogin_reset() to analogin_init() 2019-10-14 23:38:41 -04:00
Dan Halbert
c1ab2486f9 return chip vcc value 2019-10-12 15:42:15 -04:00
Dan Halbert
fc19e03128 WIP: bonding 2019-10-06 21:30:26 -04:00
jepler
f38ee42874 nrf: Add i2s audio output
Testing performed: I used a Particle Xenon with a HDA1334 I2S DAC.
I played a variety of mono 16-bit samples at 11025 and 22050Hz nominal
bit rates.  With this setup, all the 11025Hz samples sound good.
I tested play, pause,  and loop functionality.

During some runs with 22050Hz samples, there were glitches.  However,
these may have only occurred during runs where I had set breakpoints
and watchpoints in gdb.

I also tested with a MAX98357A I2S amplifier.  On this device, everything
sounded "scratchy".  I was powering it from 5V and the 5V rail seemed
steady, so I don't have an explanation for this.  However, I haven't
tried it with a SAMD board.
2019-09-08 16:46:35 -05:00
Dan Halbert
7a64af9280 rename bleio module to _bleio 2019-08-29 18:44:27 -04:00
Jeff Epler
b72352949b PWM audio: Rename AudioOut -> PWMAudioOut, _audioio_ -> _audiopwmio_ 2019-07-29 18:39:00 -04:00
Jeff Epler
a183425e00 ports/nrf: Implement audioio.AudioOut using PWM
This implements AudioOut, with known caveats:
 * pause/resume are not yet implemented (this is just a bug)
 * at best, the sample fidelity is 8 bits (this is a hardware limitation)

Testing performed:

My test system is a Particle Xenon with a PAM8302 op-amp
https://www.adafruit.com/product/2130 and 8-ohm speaker.  There's no
analog filtering between the Xenon's PWM pin and the "A+" input of
the amplifier; the "A-" pin is disconnected.  It is powered from
VUSB.

I used pin D4, which is *NOT* listed as a low-speed-only pin, but
the code does NOT switch the pin to high drive.  This is related to
an open issue for general inability to set drive level for pins
being used by a "special function" on nrf:
https://github.com/adafruit/circuitpython/issues/1270

Nothing about the code I've written should limit the usable pins.

All samples I played were 16-bit, generally monophonic at 11025Hz
and 22050Hz from the Debian LibreOffice package.
2019-07-26 07:57:11 -05:00
Dan Halbert
62de2506e4 Include display objects in gc. 2019-06-06 17:49:32 -04:00
Scott Shawcroft
9feb844b7e
Fix crash in internal filesystem on nrf
Fixes #1842
2019-05-08 15:43:18 -07:00
Nick Moore
83dad37562 Fixups for adafruit/circuitpython#1042 2019-04-16 14:53:44 +10:00
Nick Moore
02dd32da60 Make some space for NVM adafruit/circuitpython#1042 2019-04-16 14:53:44 +10:00
Nick Moore
f22c01a05e Switch supervisor/internal_flash to use new nrf_nvm_safe_flash_page_write
adafruit/circuitpython#1610
2019-04-16 14:53:44 +10:00
Scott Shawcroft
254d0a53ac
Revert "nrf nvm: touchups to nickzoic PR #1768" 2019-04-15 18:50:33 -07:00
Dan Halbert
3618461f9b Merge remote-tracking branch 'adafruit/master' into circuitpython-nickzoic-1042-nrf-nvm-bytearray-2 2019-04-10 14:09:26 -04:00