Commit Graph

615 Commits

Author SHA1 Message Date
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
hathach 894cad2e17 upgrade nrfx API to v2 2019-12-17 21:39:52 +07: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 ae64a669dd address review comments 2019-12-11 15:43:06 -05:00
Dan Halbert 68ae47907c merge from upstream 2019-12-10 21:04:46 -05:00
Jeff Epler 13620cc4db nRF: PWMAudioOut: fix half-speed playback of stereo samples
The "spacing" of "buffer structure" is confusing, use the "channel count"
instead.

Testing performed on nrf52840 feather:

Play stereo and mono, 8- and 16-bit, 8kHz RawSamples representing 333.33Hz
square waves.

Use both mono and stereo PWMAudioOut instances.

Scope the RC-filtered signal and use the scope's frequency
measurement function, verify the frequency is 333 or 334Hz in all tested
cases.

In the "stereo output" cases, verify both the L and R channels.  Verify
the output amplitude is the same in both channels.

In the "stereo output" cases, run a second test where the L channel's
amplitude is attenuated 50%. Verify the output amplitude is correct
in each channel.
2019-12-09 10:57:55 -06:00
Dan Halbert f5e913101c
Merge pull request #2301 from tannewt/support_extended_advertising
Add support for extended (>31 byte) BLE advertisements.
2019-12-06 23:51:05 -05:00
Scott Shawcroft da0ea979ff
Check connection validity after service discovery.
Fixes #2347
2019-12-06 16:03:14 -08:00
Dan Halbert 40434d6919 wip 2019-12-05 22:45:53 -05:00
Scott Shawcroft 17c8356b8c
Add connection interval and debugging
This also sets TinyUSB to master and to not include its submodules.

It also fixes an old displayio example comment and retries gattc
reads.
2019-12-04 14:39:02 -08:00
Jeff Epler 95d9c49e43 Merge remote-tracking branch 'origin/master' into tick-refactor 2019-11-29 11:27:09 -06:00
Dan Halbert b32a9192df make UART.write be blocking on SAMD; add timeout property 2019-11-27 13:05:29 -05:00
Scott Shawcroft 3fc58cee38
Merge remote-tracking branch 'adafruit/master' into support_extended_advertising 2019-11-26 13:12:43 -08:00
Scott Shawcroft e5dd78d393
Merge pull request #2324 from jepler/nrf-i2s-channels-widths
nrf: assign channel width and count correctly
2019-11-25 16:59:08 -08:00
Scott Shawcroft 2653455ded
Merge pull request #2321 from jepler/nrf-i2s-buglets
Nrf i2s buglets
2019-11-25 16:11:43 -08:00
Jeff Epler 1ee35fd6fd nrf: i2sout: move register settings closer together
.. just for consistency's sake
2019-11-25 11:43:51 -06:00
Jeff Epler 47a6eaa297 nrf: i2sout: Assign SWIDTH
The sample width register was never set, so all samples were played
as though they were 16 bit.

After this change, 8-bit samples no longer produce audio on the MAX 98357A
BOB, because only 16-, 24-, and 32-bit samples are supported by the
hardware.  This will be addressed by a future change to pad samples to
16 bits; see #2323 and the 98357A datasheet page 6.
2019-11-25 11:43:29 -06:00
Jeff Epler 8f4bab2d24 i2sout: Correctly retrieve channel_count
The meaning of the "single channel" parameter is not well-documented,
but in fact it seems that "true" must be passed or else the returned
channel_count is always 1.  This caused stereo samples to be played
incorrectly.
2019-11-25 10:59:59 -06:00
Jeff Epler c9946dfd63 nrf: i2sout: Use <, not !=, for loop condition
This is good C style, h/t @danh
2019-11-25 09:35:57 -06:00
Jeff Epler 19d122e546 nrf: i2sout: Fix double-increment when copying samples
This caused two problems when playing unsigned samples:
 * When an even number of samples were present, it "worked" but only
   every other sample was copied into the output, changing the waveform
 * When an odd number of samples were present, the copy continued beyond
   the end of the buffers and caused a hard fault
2019-11-25 09:07:20 -06:00
Jeff Epler 77b78d7fb9 Merge remote-tracking branch 'origin/master' into tick-refactor 2019-11-22 14:28:51 -06:00
Jeff Epler 1c6c9a3e1f nrf: i2sout: Ensure hardware I2S is stopped at deinit
.. otherwise, it may be possible under some scenario, for the background
task to continue and overwrite unrelated memory.
2019-11-22 14:15:07 -06:00
Jeff Epler aabb56c840 nrf: i2sout: Only update hold_value when appropriate
If we put no samples into the buffer, then there is no last
sample to fill out hold_value with.  (and, in fact, the expression such
as *(uint32_t*)(buffer-4) is outside an allocated region)

Detect this condition, and leave the prior value in place.

This improves clicks heard when pausing and resuming a waveform.
2019-11-22 13:54:37 -06:00
Scott Shawcroft 743bc829ab
Clean up debug changes 2019-11-21 16:39:57 -08:00
Scott Shawcroft e63796c7bc
Special exception message for when pairing prompt is ignored. 2019-11-21 16:32:42 -08:00
Scott Shawcroft 39f4046f70
Fix pairing when peripheral. Central untested. 2019-11-21 16:32:42 -08:00
Scott Shawcroft 5e857fdb67
Use BluetoothError in _bleio
This better differentiates errors than using OSError everywhere.
2019-11-20 14:02:15 -08:00
Scott Shawcroft 11c2c3443f
Add support for extended (>31 byte) BLE advertisements. 2019-11-19 13:55:58 -08:00
Jeff Epler 7f744a2369 Supervisor: move most of systick to the supervisor
This code is shared by most parts, except where not all the #ifdefs
inside the tick function were present in all ports.  This mostly would
have broken gamepad tick support on non-samd ports.

The "ms32" and "ms64" variants of the tick functions are introduced
because there is no 64-bit atomic read.  Disabling interrupts avoids
a low probability bug where milliseconds could be off by ~49.5 days
once every ~49.5 days (2^32 ms).

Avoiding disabling interrupts when only the low 32 bits are needed is a minor
optimization.

Testing performed: on metro m4 express, USB still works and
time.monotonic_ns() still counts up
2019-11-18 11:01:23 -06:00
Hierophect 81223c76bd revert error 2019-11-15 13:04:25 -05:00
Hierophect 2c6781f74d move neopixel_in_use flag to shared-bindings 2019-11-15 12:59:52 -05:00
Hierophect de5691acf5 Add never_reset and reset to pin common hal, adjust files 2019-11-15 12:47:00 -05:00
Dan Halbert 8cd2f87e99
Merge pull request #2236 from tannewt/bleio_tweaks
Refine _bleio
2019-11-04 22:27:54 -05:00
Dan Halbert e3638ffaad
Merge pull request #2262 from jepler/cpb-speaker-disable
cpb: Disable the onboard speaker until request
2019-11-03 18:34:29 -05:00
Dan Halbert 85a648224f Check for no pullups on I2C on nrf; give arduino nano 33 ble two I2C devices 2019-11-02 22:47:03 -04:00
jepler fe47eba97f nRF: Handle SPEAKER_ENABLE_PIN
.. the existing code, which was never activated by the preprocessor,
wasn't quite right.
2019-11-01 16:23:35 -05:00
Scott Shawcroft 47e50e5659
Merge remote-tracking branch 'adafruit/master' into bleio_tweaks 2019-11-01 13:20:58 -07:00
Dan Halbert cdeb0857a9 Initial Itsy nRF52840 defn 2019-10-25 11:15:34 -04:00
Scott Shawcroft 91c9d519ae
Refine comments and switch prefix_len to size_t 2019-10-22 23:09:56 -07: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
Dan Halbert eca73436c9 Merge remote-tracking branch 'adafruit/master' into cpu-voltage 2019-10-15 09:03:24 -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
Jeff Epler fae6e29546 nrf: PWMAudioOut: deactivate PWM when deinitting self
.. otherwise, when an AudioPWMOut object was deinitted without being
explicitly stop()ped, it would use up a slot in active_audio[]; the
5th iteration would create a non-working audio object which would just
buzz instead of playing the right thing.

Closes: #2203
2019-10-12 14:01:35 +09:00
Jeff Epler ef459326cb nrf: PWMAudioOut: coding style 2019-10-12 13:57:31 +09:00
Scott Shawcroft b5a9ed3688
Merge pull request #2161 from jepler/nrf-analog-reference
nRF: Change analog reference voltage
2019-09-17 09:41:52 -07:00
jepler d39c85e3f5 nRF: Change analog reference to VCC(/4)
@ladyada says:
"having this be adjustable (reference) would be ideal cause you can get
absolute voltages but for now, VCC/4 + 4x matches every other chip :)"

... and indeed doing it this way happens to give a much more steady
reading when using a VCC-referenced resistance, and so many of the simple
things you'd wire up are actually VCC-referenced anyway.
2019-09-16 21:43:07 -05:00
Jeff Epler c56186da8c nRF: Change analog reference voltage
Datasheet reading explains one reason why readings might have been 10% low.
2019-09-16 18:35:48 -05:00
jepler df48312ce7 nRF: PWMOut: At deinit, make pin available again
Closes: #2146
2019-09-11 20:09:38 -05:00
jepler 7b9dfc9952 nrf: i2s: tune audio buffering
.. based on some tasks I found that caused stuttering:

 # Test SD and printing
 while True: os.listdir('.')

 # Test bulk I/O
 while True: len(open('somefile.wav', 'rb').read())

Each of these tasks *WAS* worse and I am improving them in a separate
PR by adding RUN_BACKGROUND_TASKS to them.
2019-09-09 20:13:12 -05:00
jepler c66f5a8536 nrf: i2s: rewrite without 'goto' 2019-09-09 19:26:18 -05:00
jepler fe9605a6a3 nrf: i2s: Comment this slightly tricksy code 2019-09-09 19:25:52 -05:00
jepler ccf08aa3df nrf: I2SOut: deal more gracefully with errors from the sample 2019-09-08 21:59:07 -05: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
Dan Halbert b11b7916fd address minor issues: typos, make translate, and sphinx 2019-08-29 17:58:21 -04:00
Dan Halbert f17059b10b another API rework: less abstraction leakage 2019-08-28 23:15:22 -04:00
Dan Halbert 19c59b41ed bleio: API change to create and connect related objects simulatenously: no orphan bleio objects 2019-08-28 16:15:09 -04:00
Dan Halbert a72bcab0fd Merge remote-tracking branch 'adafruit/master' into bleio-api-revamp 2019-08-28 16:09:18 -04:00
Dan Halbert 0364f1dc85 remove some debugging prints 2019-08-26 08:17:59 -04:00
Dan Halbert 76446f634b BLE HID WIP: works everywhere except iOS; fixed a bunch of bugs; pretend bonding 2019-08-25 21:38:13 -04:00
Scott Shawcroft 7324b70a7c
Rework based on Dan's review 2019-08-23 15:27:21 -07:00
Scott Shawcroft 2497cbe186
Fix nrf builds 2019-08-22 14:23:33 -07:00
Benny Meisels d37dd4d758
Updated ParallelBus implementation in nrf port 2019-08-22 14:08:33 -07:00
Dan Halbert 7cc15e56c8 make translate 2019-08-22 15:20:23 -04:00
Dan Halbert 0b7291d767 fix default crystal value; fix include order 2019-08-22 09:01:05 -04:00
Dan Halbert d94023e9b3 Fix CPBlue LFCLKSRC; CPB has no status neopixel 2019-08-22 01:04:00 -04:00
Dan Halbert e00696de7f merge from upstream and make translate 2019-08-20 13:06:23 -04:00
Dan Halbert e3dc5e3a66 Merge remote-tracking branch 'adafruit/master' into run-background-tasks
Restore dependencies indicated by indentation in circuitpy_mpconfig.h.
2019-08-19 12:41:20 -04:00
Jeff Epler 26a05d01dc Merge remote-tracking branch 'origin/master' into nrf-pdm-audioin 2019-08-18 21:30:14 -05:00
Jeff Epler 912fd7759d nrf: PDMIn: Implement
So far, this supports only 16kHz and 16-bit samples with a fixed gain.
This is enough to support the basic functionality of e.g., sensing
ambient audio levels.
2019-08-18 15:58:04 -05:00
Jeff Epler 79f8a85786 nrf: stub out audiobusio.PDMIn, audiobusio.I2SOut 2019-08-18 15:55:57 -05:00
Dan Halbert e2a4c76a37 make nrf touchio be generic: now available for SAMD51 too 2019-08-18 08:44:10 -04:00
Dan Halbert 630c92392a address review comments; avoid calling common_hal_bleio_device... routines from shared-bindings 2019-08-16 15:18:53 -04:00
Jeff Epler 11dd3a260e nrf: Use RUN_BACKGROUND_TASKS 2019-08-11 08:53:02 -05:00
Dan Halbert 1570ef2dd4 specifying attribute length; fix up value setting 2019-08-07 23:49:09 -04:00
Dan Halbert d047b73a9c fix newly-introduced bugs; UART client/server working again 2019-08-07 11:10:21 -04:00
Dan Halbert d74c8b9425 WIP: more Descriptor work; refactor gattc/gatts read/write 2019-08-06 22:55:25 -04:00
Dan Halbert 243334da75 Merge remote-tracking branch 'adafruit/master' into ble-pairing 2019-08-05 23:06:24 -04:00
Scott Shawcroft b675a27e16
Merge pull request #2000 from jepler/nrf-pwm-audio
Implement PWM audio out for the nrf port
2019-08-05 17:26:27 -07:00
Dan Halbert b67d04a5b1 Merge remote-tracking branch 'adafruit/master' into ble-pairing 2019-08-05 16:35:44 -04:00
Jeff Epler 77bc1ba03e nrf: PWMAudioOut: Remove the need to wait in "pause"
The original formulation was because I saw the need to avoid a transition
from playing to stopped exactly when a resume was taking place.  However,
@tannewt was concerned about this pause causing trouble, because it could
be relatively lengthy (several ms even in a typical case).

After reflection, I've convinced myself that updating the registers
in this order in resume avoids a window where a "stopped" event can
be missed as long as the shortcut is updated first.

Testing re-performed: pause/resume testing of looped RawSample and
WaveFile audio sources.
2019-08-03 08:19:25 -05:00
Dan Halbert 7ce3776b80 WIP: rework of Characteristic properties; enhance Descriptor; not tested 2019-08-02 17:57:31 -04:00
jepler 34e2bab96a nrf: Implement RUNMODE_BOOTLOADER and RUNMODE_SAFE_MODE 2019-08-01 18:53:07 -05:00
Jeff Epler 76f65ac694 Implement play/pause
.. and also incidentally fix a problem where a RawSample could only
be looped 131070 times.
2019-07-31 20:02:56 -05:00
Dan Halbert 91d791afd0 cleanup adapter.address; add uniquish suffix to BLE device name 2019-07-31 00:30:24 -04:00
Dan Halbert 83129b8c63 BLE: peripheral client pairing (not yet bonding); fix time doc formatting 2019-07-30 14:26:26 -04:00
Jeff Epler b72352949b PWM audio: Rename AudioOut -> PWMAudioOut, _audioio_ -> _audiopwmio_ 2019-07-29 18:39:00 -04:00
Dan Halbert 28ca05ccdc allow discovery from central or peripheral 2019-07-27 13:22:15 -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
Jeff Epler 2bc704fe07 ports/nrf: factor out routines for allocating, freeing pwm channels 2019-07-26 07:52:37 -05:00
Scott Shawcroft 8ec2d6ce49
Merge pull request #2007 from hierophect/F4xx-port-setup
Add STM32 Discovery F412ZG and F411RE support
2019-07-24 18:49:48 -07:00
Hierophect 58630a844a Add feature conditionals and clean up 2019-07-22 12:58:28 -04:00
Scott Shawcroft 6797ec6ed3
Add support for grayscale displays that are < 8 bit depth.
This also improves Palette so it stores the original RGB888 colors.

Lastly, it adds I2CDisplay as a display bus to talk over I2C. Particularly
useful for the SSD1306.

Fixes #1828. Fixes #1956
2019-07-19 16:06:11 -07:00
Hierophect 43e8a4110f Add missing files for DigitalIO 2019-07-17 14:18:01 -04:00
Dan Halbert 364ee62d10 Address review comments. 2019-07-16 19:53:36 -04:00
Dan Halbert 1cf8a3e8d8 Merge remote-tracking branch 'adafruit/master' into ble-scanner 2019-07-11 18:42:16 -04:00
Scott Shawcroft 6fad383367
Merge pull request #1925 from C47D/rgb_status
Initial support for RGB led as Status indicator, fixes #1382
2019-07-09 10:31:34 -07:00
Dan Halbert 6a001786a9 merge from master 2019-07-09 08:58:49 -04:00
Dan Halbert 118b26b335 UARTClient now works both directions 2019-07-09 00:21:46 -04:00
Dan Halbert 09ddff8df1 WIP: Need descriptors for Central CCCD discovery; not done yet 2019-07-07 00:07:47 -04:00
Scott Shawcroft 5610e05b8c
Fix up nrf so that it is initialized properly. Also, do not reset
it's pins.
2019-07-06 12:48:16 -07:00
iot49 6e5d70fa19 changed type of receiver_buffer_size to uint16_t 2019-07-03 12:02:01 -07:00
Dan Halbert bf8a35b2f8 WIP: CharacteristicBuffer for Central; not working: need to set remote Characteristic Service 2019-07-02 22:34:54 -04:00
Dan Halbert 6ea01ea9b0 Central is connecting; characteristics can be read and written 2019-06-29 00:20:06 -04:00
Dan Halbert 140904ec84 getting Scanner to work 2019-06-22 22:10:15 -04:00
Dan Halbert 4881e1ff55 WIP: Central compiles; now will test 2019-06-21 18:04:04 -04:00
Dan Halbert 23bd861c9a nrf: fix neopixel_write pwm buf size calc 2019-06-20 18:02:14 -04:00
Dan Halbert 24ac1fdcab WIP: backup only; not compiled 2019-06-19 21:54:28 -04:00
Dan Halbert a1b5d800f3 Update copyrights; get ready for Central 2019-06-19 10:42:36 -04:00
Dan Halbert 35b9191857 Don't operate directly on bleio objects in shared-bindings: use common_hal
routines instead. Changes made but not yet tested.
2019-06-18 23:46:20 -04:00
Dan Halbert bed6d43a76 merge from upstream; WIP redo Address; no more AddressType 2019-06-13 21:55:07 -04:00
Dan Halbert 1905d90eaa Make advertising data buffers long-lived 2019-06-05 20:08:53 -04:00
Dan Halbert 613e12f99f Replace Broadcaster with enhanced Peripheral 2019-06-03 20:40:05 -04:00
Dan Halbert 63ac37946d 1. Remove advertising data construction in C: it's all done in Python now
2. Add scan response capability to advertising.
2019-06-02 23:21:30 -04:00
Dan Halbert 12f1d9d30c fix advertisement length check; add Service.secondary attribute 2019-05-31 18:03:05 -04:00
Dan Halbert 6cec81bcb5 Need to enable ble before scanning 2019-05-23 22:05:16 -04:00
Dan Halbert 1639354e5f Scanner working, but not very first time 2019-05-23 16:07:54 -04:00
Dan Halbert 15b7946fc4 Off-by-one error for usage of MAX_TX_IN_PROGRESS 2019-04-22 22:07:48 -04:00
Nick Moore 9c42a72275 Fix up single-byte access to nvm.ByteArray 2019-04-16 14:53:44 +10: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 66e8ceafad switch nvm.ByteArray to use new nrf_nvm_safe_flash_page_write
adafruit/circuitpython#1610
2019-04-16 14:53:44 +10:00
Nick Moore d0e5af3b09 Working flash pages for nvm.ByteArray adafruit/circuitpython#1042
import microcontroller

def dump(n = microcontroller.nvm):
    for i in range(0,len(n)):
        print ("%02X " % n[i], end="")
        if i % 16 == 15: print('')

microcontroller.nvm[0:4096] = bytes([1,2,3,4,5,6,7,8]) * 512
microcontroller.nvm[4096:8192] = bytes([16,17,18,19]) * 1024
microcontroller.nvm[4090:4101] = b'thisisatest'
microcontroller.nvm[100:105] = b'hello'
microcontroller.nvm[8000:8007] = b'goodbye'
dump()
2019-04-16 14:53:44 +10:00
Nick Moore 933500c448 nvm.ByteArray reads & writes but no sensible erase yet adafruit/circuitpython#1042 2019-04-16 14:53:44 +10:00
Nick Moore df89156f2f Start on nRF nvm.ByteArray adafruit/circuitpython#1042 (doesn't do anything yet) 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 864910559b fix subscripting 2019-04-10 21:41:55 -04:00
Nick Moore 18908c21f7 Fixups for adafruit/circuitpython#1042 2019-04-09 12:53:11 +10:00
Nick Moore fdaff00c78 Make some space for NVM adafruit/circuitpython#1042 2019-04-09 10:56:53 +10:00
Nick Moore bc92441803 switch nvm.ByteArray to use new nrf_nvm_safe_flash_page_write
adafruit/circuitpython#1610
2019-04-09 10:55:39 +10:00
Nick Moore 8e7fee2246 Working flash pages for nvm.ByteArray adafruit/circuitpython#1042
import microcontroller

def dump(n = microcontroller.nvm):
    for i in range(0,len(n)):
        print ("%02X " % n[i], end="")
        if i % 16 == 15: print('')

microcontroller.nvm[0:4096] = bytes([1,2,3,4,5,6,7,8]) * 512
microcontroller.nvm[4096:8192] = bytes([16,17,18,19]) * 1024
microcontroller.nvm[4090:4101] = b'thisisatest'
microcontroller.nvm[100:105] = b'hello'
microcontroller.nvm[8000:8007] = b'goodbye'
dump()
2019-04-09 10:55:39 +10:00
Nick Moore 492431a694 nvm.ByteArray reads & writes but no sensible erase yet adafruit/circuitpython#1042 2019-04-09 10:54:11 +10:00
Nick Moore f8e5e2da64 Start on nRF nvm.ByteArray adafruit/circuitpython#1042 (doesn't do anything yet) 2019-04-09 10:54:11 +10:00
Scott Shawcroft 049b9ca094
Remove terse TODOs 2019-04-08 14:46:45 -07:00
Radomir Dopieralski 8323721232 Stop hard-coding SPI frequency in FourWire
Instead remember and use the frequency, polarity and phase that was
set when the bus was first created.
2019-04-06 15:15:29 +02:00
Nick Moore 781d301bb6 Remove unnecessary MP_WEAK declarations 2019-04-02 13:33:22 +11:00
Nick Moore 94bda3bde1 Change nRF RTC implementation to use RTC2 #1046
(to avoid interference with Bluetooth Softdevice. See
https://github.com/adafruit/circuitpython/pull/1534#issuecomment-478776240
with thanks to @bboser for pointing it out)
2019-04-02 13:28:22 +11:00
Nick Moore 6afe23d0b0 There isn't really a good way to calibrate this RTC adafruit/circuitpython#1046 2019-04-02 13:28:03 +11:00
Nick Moore 6206fa9a82 adafruit/circuitpython#1046 handle overflows in the RTC counter 2019-04-02 13:27:45 +11:00
Nick Moore f846fa109e enable NRFX RTC adafruit/circuitpython#1046 2019-04-02 13:27:28 +11:00
Nick Moore f88f9fd748 more fake RTC code ... adafruit/circuitpython#1046
(works if MP_WEAK common_hal_rtc_get_time is removed)
2019-04-02 13:27:13 +11:00
Nick Moore 4a5c52fbd6 starting on #1046 rtc for nRF 2019-04-02 13:27:00 +11:00
Dan Halbert 0653bca323
Revert "Circuitpython nickzoic 1046 nrf rtc" 2019-03-29 16:41:29 -04:00
Nick Moore 71622a4515 There isn't really a good way to calibrate this RTC adafruit/circuitpython#1046 2019-03-28 09:50:09 +11:00
Nick Moore 28254def0b adafruit/circuitpython#1046 handle overflows in the RTC counter 2019-03-28 09:50:09 +11:00
Nick Moore b09d2c3c62 enable NRFX RTC adafruit/circuitpython#1046 2019-03-28 09:50:09 +11:00
Nick Moore 69cf33e6a1 more fake RTC code ... adafruit/circuitpython#1046
(works if MP_WEAK common_hal_rtc_get_time is removed)
2019-03-28 09:50:09 +11:00
Nick Moore 77f307c642 starting on #1046 rtc for nRF 2019-03-28 09:50:09 +11:00
Radomir Dopieralski f440e41819 Really fix the error messages in bleio, this time 2019-03-25 14:04:50 +01:00
Radomir Dopieralski bb10a8aaa1 Fix error messages in bleio 2019-03-25 09:19:48 +01:00
Dan Halbert fe555a4098 Allow NFC pins to be used for other purposes. 2019-03-21 11:22:58 -04:00
Dan Halbert 99da3b9646 Use critical section, not lock, in CharacteristicBuffer; use a root pointer for ble_drv list 2019-02-21 00:19:31 -05:00
Dan Halbert a345ef28f2 finish Makefile refactoring; nrf builds work 2019-02-15 18:55:10 -05:00
Dan Halbert ab4194f752 don't allocate DMA buffer as long-lived 2019-02-13 19:49:57 -05:00
Dan Halbert e92d90ce9c Add second UARTE to busio.UART. Init uarts on startup. 2019-02-12 22:34:05 -05:00
Scott Shawcroft 37b9cd5974
Merge pull request #1521 from nickzoic/circuitpython-nickzoic-1045-nrf-rotaryio
Circuitpython nickzoic 1045 nrf rotaryio
2019-02-07 10:38:20 -08:00
Nick Moore b9db977a2d Change pin mode to pullup for adafruit/circuitpython#1045 2019-02-07 09:47:56 +11:00
Nick Moore a7c349bc6e Add quarter-click logic to adafruit/circuitpython#1045 2019-02-05 16:41:33 +11:00
Nick Moore 95454ecde0 useful output from rotaryio adafruit/circuitpython#1045 2019-02-05 16:41:33 +11:00
Nick Moore 21eb7e8e64 GPIOTE handlers for rotaryio.IncrementalEncoder adafruit/circuitpython#1045 2019-02-05 14:15:13 +11:00
Nick Moore ee21cc163f Start on rotaryio.IncrementalEncoder adafruit/circuitpython#1045 (does nothing yet!) 2019-02-05 14:15:03 +11:00
Scott Shawcroft ec03887040
Fix hallowing and nrf builds 2019-01-31 11:42:15 -08:00
hathach 164e1e2341 re-init usb hardware when enable/disable SD 2019-01-30 14:13:07 +07:00
Scott Shawcroft 765d877dfa
Merge pull request #1499 from nickzoic/nickzoic/circuitpython-nrf-touchin-1048
Nickzoic/circuitpython nrf touchin 1048
2019-01-28 00:22:34 -08:00
Nick Moore 294b026aca Automatically set a default threshold for touchio.TouchIn channels 2019-01-28 18:22:57 +11:00
Nick Moore 539aaf08b5 speed up measurement loop 2019-01-27 21:54:59 +11:00
Nick Moore 4a093294ac hugely simplified version of the touchio.TouchIn.get_raw_reading code (adafruit/circuitpython#1048) 2019-01-27 15:08:03 +11:00
Dan Halbert 7998a7696d also handle BLE_GATTS_EVT_SYS_ATTR_MISSING: fixes Android: 2019-01-23 22:12:38 -05:00
Dan Halbert b1f1bb1389 support BLE_GAP_EVT_DATA_LENGTH_UPDATE_REQUEST, sent by newer devices 2019-01-23 21:07:23 -05:00
Dan Halbert e170e03f8c Merge remote-tracking branch 'adafruit/master' into bleio2 2019-01-21 20:38:26 -05:00
Dan Halbert 28cfd8a513 CharacteristicBuffer: make it be a stream class; add locking 2019-01-19 19:45:35 -05:00
Scott Shawcroft edc8383e22
Improvements thanks to danh's review 2019-01-18 16:37:06 -08:00
Scott Shawcroft fddc98858a
fix nonetype handling and nrf never reset 2019-01-17 18:51:40 -08:00
Scott Shawcroft 6404aaf411
Fix up nrf and using board.SPI in FourWire 2019-01-17 18:19:07 -08:00
Scott Shawcroft 760bd8d8a4
share fourwire and make nrf compile 2019-01-17 15:15:59 -08:00
Dan Halbert 50ee5ef24c merge translations; add bleio comments; fix minor sphinx issues in midi 2019-01-10 21:12:17 -05:00
hathach f366e3feea Merge branch 'master' into nrf52_pulsein 2019-01-09 20:39:35 +07:00
hathach cfc4c8cbfa
minor clean up 2019-01-09 15:43:54 +07:00
hathach db82160eef
fix pulsein incorrect compute 2019-01-09 15:15:30 +07:00
Dan Halbert 13d607698e m_tx_in_progress might underflow (check on this) 2019-01-08 16:37:14 -05:00
Dan Halbert 50641c4152 remove debugging printf's 2019-01-08 15:52:21 -05:00
Dan Halbert f66f55b4ed add CharacteristicBuffer; UART seems to work! 2019-01-07 22:46:20 -05:00
hathach 215008f78c
clean up neopixel write !! 2019-01-08 00:21:31 +07:00