Commit Graph

500 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
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
Sean Cross
cfe65742a3 _bleio: support anonymous advertising
Add a new parameter to the `start_advertising()` function to enable
anonymous advertising.  This forces a call to `sd_ble_gap_privacy_set()`
with `privacy_mode` set to `BLE_GAP_PRIVACY_MODE_DEVICE_PRIVACY` and
`private_addr_type` set to
`BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE`.

With this, addresses will cycle at a predefined rate (currently once
every 15 minutes).

Signed-off-by: Sean Cross <sean@xobs.io>
2020-05-19 15:01:18 +08:00
Scott Shawcroft
2c2b53303d
Merge pull request #2837 from k0d/serial-debug
Add support for a debug console, such as ST-Link VCP.
2020-05-18 18:13:31 -07:00
Mark Olsson
007c92ee6a Enable showing the console on a debug uart 2020-05-19 02:02:52 +02:00
Sean Cross
83680c41db nrf: rtc: persist rtc offset across reboots
Store the RTC value in the .uninitialized section, but make sure to
flank it with some known values.  That way we can determine if the RTC
value has been initialized, or if it's random uninitialized garbage.

As part of this, add a `common_hal_rtc_init()` routine to determine if
the value is correct, or reset it to 0 if it is not valid.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-05-18 11:52:27 +08:00
Jeff Epler
eb876e21c3 nrf: code style 2020-05-13 10:40:41 -05:00
Jeff Epler
011acf41c0 nrf: Ensure ticks enabled while playing audio 2020-05-13 10:40:36 -05:00
Dan Halbert
b7836aeac6 address review comments 2020-05-04 19:51:08 -04:00
Dan Halbert
bae7a5e433 make translate again 2020-05-04 17:26:59 -04:00
Dan Halbert
d6c6f9f4f0 add PacketBuffer .incoming_ and .outgoing_packet_length 2020-05-04 15:59:45 -04:00
Dan Halbert
f3078511a6 further cleanup and bug fixing 2020-04-29 23:18:08 -04:00
Dan Halbert
3d62f87e29 back to '.packet_size' for compatiblity 2020-04-29 22:10:56 -04:00
Dan Halbert
84cee1ab8d rename and improve PacketBuffer packet length property 2020-04-29 17:49:31 -04:00
Scott Shawcroft
755d404edf
Merge remote-tracking branch 'adafruit/master' into lower_power 2020-04-27 16:45:10 -07:00
Dan Halbert
fbc8719fad ringbuf tested 2020-04-21 22:40:12 -04:00
Dan Halbert
77cd93ac2d merge from adafruit 2020-04-21 17:47:51 -04:00
Dan Halbert
38ec3bc574 further ringbuf cleanup 2020-04-21 17:38:20 -04:00
Sean Cross
c04e6d6f52 nrf: bleio: parameterize softradio configuration
Allow for setting various softradio memory settings as part of a
board in order to support lower-memory configurations.  If a
parameter is unspecified then the previously-defined value is used.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-04-21 12:29:59 +08:00
Sean Cross
3ed5b87b8f nrf: add support for nrf52833
This adds preliminary support for the nRF52833, which is a variant of
the nRF52840 with half the RAM, half the flash, and fewer peripherals.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-04-21 12:29:56 +08:00
Scott Shawcroft
bebf27e733
Merge remote-tracking branch 'adafruit/master' into lower_power
This isn't perfect and needs a bit more testing.
2020-04-20 18:25:13 -07:00
Jeff Epler
5fcc6d6286 RGBMatrix: finish renaming from Protomatter
This gets all the purely internal references.  Some uses of
protomatter/Protomatter/PROTOMATTER remain, as they are references
to symbols in the Protomatter C library itself.
2020-04-17 18:44:07 -05:00
Jeff Epler
3d6258f63d Rename Protomatter -> RGBMatrix
This is a quick rename, it changes the user-facing names but not the
internal names of things.
2020-04-17 18:43:57 -05:00
Jeff Epler
a32337718d Rename _protomatter -> protomatter
I originally believed that there would be a wrapper library around it,
like with _pixelbuf; but this proves not to be the case, as there's
too little for the library to do.
2020-04-17 18:43:57 -05:00
Scott Shawcroft
b580b34cbf
Merge remote-tracking branch 'adafruit/master' into lower_power 2020-04-14 17:14:44 -07:00
Jeff Epler
1d8a073c05 nrf: protomatter port 2020-04-14 18:24:58 -05:00
Scott Shawcroft
7e69d30c02
Fix nRF PulseIn 2020-04-03 14:22:56 -07:00
Scott Shawcroft
8fe512c7e9
Merge remote-tracking branch 'adafruit/master' into lower_power 2020-03-31 15:13:58 -07:00
Scott Shawcroft
8a5d3cd6c4
Add exception on small buffer and fix Connecion WRITE handling 2020-03-25 17:41:47 -07:00
Scott Shawcroft
3551b769a2
Fix connection handle tracking in PacketBuffer when a server. 2020-03-25 13:31:18 -07:00
William Moser
c961ed9025 Added 31250 and 56000 to baudrate_map in UART.c, to parallel definitions in nrfx/mdk/nrf*_bitfields.h files 2020-03-24 13:25:02 -04:00
Scott Shawcroft
76ca13b6ed
Fix SAMD51 pulsein 2020-03-13 17:21:15 -07:00
Scott Shawcroft
48b5f2a384
Initial work on SAMD 2020-03-13 11:16:41 -07:00
Scott Shawcroft
affd3fcc2a
Clear the pending IRQ in the NVIC as well. 2020-03-13 11:16:38 -07:00
Scott Shawcroft
00d5f63e7c
Hopefully fix PulseIn 2020-03-13 11:12:31 -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
Dan Halbert
8435935429 update uses of assert_pin_free; remove redundant checks 2020-02-29 15:37:32 -05:00
Dan Halbert
b6206406de new pin validation routines; don't use mp_const_none if NULL will do 2020-02-28 23:43:04 -05:00
Scott Shawcroft
28c7a1e9c3
Fix crash after empty REPL session
We were trying to reset bluetooth when it was off and then trying
to raise an exception without the heap.
2020-02-24 16:11:17 -08:00
Dan Halbert
f63b2c0d0c use realloc instead 2020-02-21 17:36:15 -05:00
Dan Halbert
9cf46ec947 put neopixel_write buffer in root pointers 2020-02-21 08:44:25 -05:00
Dan Halbert
23d6a3dc1f merge from upstream 2020-02-20 22:27:16 -05:00
Dan Halbert
634d246910 relicense nrf SPI.c to MIT 2020-02-20 16:00:21 -05:00
Dave Marples
24405cabaf Edits as a result of review 2020-02-19 00:07:01 +00:00
Dave Marples
490a808bf6 Addition of stubs for rs485/CTS/RTS handling on non-implemented chips 2020-02-18 23:16:40 +00:00
Dan Halbert
e00b3269fe use properly-sized SPI transactions 2020-02-12 15:04:19 -05:00
Dan Halbert
2e029d55fc nrf: add SPIM3 support 2020-02-11 19:22:14 -05:00
Dan Halbert
005c4caf8c fix function defs for compiler 2020-02-07 10:32:37 -05:00
Dan Halbert
857d8ab40a improve time.monotonic_ns() accuracy from ms to us 2020-02-07 10:02:50 -05:00
Dan Halbert
a63f49cb83
Merge pull request #2592 from tannewt/add_extra_ble_error
Add another error message to BLE
2020-02-05 23:39:17 -05:00
Scott Shawcroft
72a1bdab30
Add another error message for extended advertisements at the same
time as scan response. The SD can't do it.
2020-02-05 15:56:17 -08:00
Dan Halbert
b6da2fa173 nrf: fix i2c frequency setting 2020-02-05 11:25:31 -05:00
Dan Halbert
be4e681d07 fix UICR check; do not use NULL for no MISO 2020-01-31 18:57:41 -05:00
Dan Halbert
4abd5f1f7b increase max connections from 2 to 5 2020-01-31 14:58:23 -05:00
Dan Halbert
87f73e2729 track vm_used_ble better 2020-01-30 09:52:06 -05:00
Dan Halbert
68f9aee992 reset NeoPixels on CPB on soft reload 2020-01-23 20:16:31 -05:00
Dan Halbert
85dc4089b9 address review comments 2020-01-14 17:23:16 -05:00
Dan Halbert
0367ba7495 fix some typos and leftovers 2020-01-13 18:29:34 -05:00
Dan Halbert
2a75196aa3 merge from adafruit/circuitpython 2020-01-13 18:15:32 -05:00
Dan Halbert
4ad004f24e put bonding to-do flags into Connection objects instead of using a heap-allocated queue 2020-01-13 17:52:32 -05:00
Dan Halbert
9e7f8743c2 fix CCCD bonding store; avoid excessive bonding writes 2020-01-12 23:32:51 -05:00
Dan Halbert
346ce3b73b wip: HID bonding works! 2020-01-10 23:55:45 -05:00
Scott Shawcroft
6ea8d8a6c2
Merge pull request #2498 from dhalbert/optional-i2c-pullup-checking
Make requiring I2C pullups be optional
2020-01-10 11:42:44 -08:00
Scott Shawcroft
8708d3dc45
Merge pull request #2461 from jepler/urandom-hardfaults
Urandom hardfaults
2020-01-10 11:37:59 -08:00
Dan Halbert
9c167af17a wip; redid flash writing to be compatible with SD 2020-01-09 17:40:02 -05:00
Dan Halbert
189f2d5f07 Make requiring I2C pullups be optional 2020-01-09 17:31:50 -05:00
Jeff Epler
1c6efb9e66 os.urandom: remove unneeded sleep 2020-01-08 16:48:17 -06:00
Roy Hooper
1caf6bd8d3 add missing .h file 2020-01-08 15:23:38 -05:00
Roy Hooper
e1c1e32ceb address code review 2020-01-08 15:17:54 -05:00
Roy Hooper
4e040b0152 add reset of heap to board reset for nrf port 2020-01-08 15:15:27 -05:00
Roy Hooper
34c9e00f08 try (re)using the buffer in neopixel_write 2020-01-08 15:14:53 -05:00
Scott Shawcroft
7a94940c89
Replace magic number and add comment. 2020-01-08 11:01:43 -08:00
Jeff Epler
b3fb024301 nrf: Call into sd as many times as necessary to fill urandom request
Generating 51200 bytes in one go takes 4.966s, so that's a rate of about
10KiB/s.
2020-01-08 10:06:55 -06:00
Dan Halbert
390337b9a5 wip; compiles 2020-01-05 23:33:42 -05:00
Scott Shawcroft
82fb761c0f
Add PacketBuffer and MTU negotiation support.
PacketBuffer facilitates packet oriented BLE protocols such as BLE
MIDI and the Apple Media Service.

This also adds PHY, MTU and connection event extension negotiation
to speed up data transfer when possible.
2020-01-03 17:29:54 -08:00
Scott Shawcroft
f6ec1ea172
Throw an error when we cannot allocate PWM pixel buffer 2020-01-03 15:15:36 -08:00
Scott Shawcroft
6afb8dadbc
Change SPI and I2C in the same way. 2020-01-03 15:14:37 -08:00
Dan Halbert
242d572470 wip 2020-01-03 10:24:07 -05:00
Scott Shawcroft
cfd71d9023
Fix nRF UART reset
disable only turns off ENABLE but doesn't set the init tracking that
nrfx uses. uninit hangs if ENABLE is off and is called because it
waits forever for TX to stop.
2019-12-27 20:18:07 -08:00
Jeff Epler
51af8aadb7 nrf: PWMAudioOut: 62500Hz limitation is not needed
.. and it gets in the way of some example programs, due to the way
circuitplayground library generates different frequency sine waves
2019-12-19 10:34:56 -06:00
Ha Thach
25df6e613a
Merge pull request #2395 from hathach/nrfx-v2
upgrade nrfx API to v2
2019-12-18 16:14:25 +07:00
Jeff Epler
8137ac4c49 nRF: PWMAudioOut: handle non-looping rawsamples 2019-12-17 08:59:08 -06:00