Commit Graph

364 Commits

Author SHA1 Message Date
Jeff Epler
fb768dfc14 samd: AnalogOut: Better handle boards which IGNOREd analog pins 2020-10-17 20:08:32 -05:00
Jeff Epler
eb0b023dee samd: extend IGNORE_PIN_foo to all sam e5x/e5x pins 2020-10-17 20:08:32 -05:00
Jeff Epler
aa3c890ead samd: pin: Fix 'undefined reference to pin_PA30'
.. when PA30 is IGNOREd
2020-10-17 20:08:32 -05:00
Scott Shawcroft
379e73af2e
Finer grained, per port tick locking
Fixes #3504 hopefully.
2020-10-12 18:43:21 -07:00
Radomir Dopieralski
3f6ca7bd32 Make end-of-line-fixer happy 2020-10-10 23:59:44 +02:00
Radomir Dopieralski
b227b79dec Fix #3504: Don't use time module in pew.tick()
The time.sleep() and time.monotonic() functions break the timer
interrupt on which PewPew10 display relies, so we can't use them
anymore. Instead I'm adding a time-keeping function to the display
code itself, which then can be used in pew.tick() internally.
2020-10-10 20:26:33 +02:00
Jeff Epler
16ed875f4e canio: remove unused fields
these relate to properties that were removed as well
2020-10-06 20:14:50 -05:00
Jeff Epler
611f81ac1a canio: actually drop the _error_count properties
thanks @tannewt
2020-09-29 14:25:53 -05:00
Jeff Epler
f4e36fc7f6 CAN: Use mp_obj_t insteaed of canio_message_obj_t, get rid of rtr field 2020-09-28 17:22:00 -05:00
Jeff Epler
3e97e9c4be canio: Listener: shuffle function declarations around 2020-09-28 17:22:00 -05:00
Jeff Epler
48bda589b8 Listerner: read -> receive, drop readinto
This prepares for creating a separate RemoteTransmissionRequest class
2020-09-28 17:22:00 -05:00
Jeff Epler
79ca430ddf Match: address -> id 2020-09-28 17:22:00 -05:00
Jeff Epler
59580d0f2d canio: Fix implementation bugs in atmel-sam 2020-09-22 09:36:29 -05:00
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
9e8f1820c8 canio.CAN: switch rx/tx, make both mandatory, move declarations around 2020-09-21 16:44:26 -05:00
Jeff Epler
7fd6cab2ac canio: Make both tx and rx (but not both) optional
.. loopback and silent come from the (optional) constructor parameters
not guessing based on the pin specification

.. docstring & comment improvements
2020-09-21 16:44:26 -05:00
Jeff Epler
44c5b2bbb1 Respond to review comments
Thanks @tannewt!
2020-09-21 16:44:26 -05:00
Jeff Epler
58b920ed97 fix whitespace 2020-09-21 16:44:26 -05:00
Jeff Epler
27cbb690e5 _canio: Add listener matching
Lightly tested:
 * no matches (catch-all)
 * standard address single address matches (even and odd positions)
 * standard address mask matches
 * only tested that extended doesn't match non-extended
2020-09-21 16:44:26 -05:00
Jeff Epler
635fcadb59 _canio.CAN: add error handling & bus state 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
Jeff Epler
183649aad8 samd: move mcu_find_pin_function to header
.. it'll be used in can as well as sdio
2020-09-21 16:44:07 -05:00
Dan Halbert
5116375604
Merge pull request #3436 from jepler/fix-spi-sercom4
samd: SPI: improve conditional code
2020-09-18 19:14:39 -04:00
Dan Halbert
23dd7c7c96
Merge pull request #3435 from jepler/fix-sdhc1
sdioio: fix code for the case where there is no SDHC1
2020-09-18 17:10:59 -04:00
Dan Halbert
550b42e4d3
Merge pull request #3434 from jepler/same54-disable-cpu-voltage
sam e54: disable microcontroller.cpu.voltage
2020-09-18 15:20:43 -04:00
Jeff Epler
45eec5b5a5 samd: SPI: improve conditional code
I recently misdiagnosed a "maybe-uninitialized" diagnostic as a bug in
asf4.  However, the problem was in our SPI code.

A special case for samr21 MCUs was being applied to same54p20a and possibly
other D5x/E5x MCUs, since the check was simply for pin PC19 existing at all.

Change the check to use the macro PIN_PC19F_SERCOM4_PAD0 which is only
defined if special function F of pin PC19 is SERCOM4 PAD0.

Reorganize the code a little bit so that brace-matching in editors is
not confused by the conditionalized code, including an unrelated change
for APA102_SCK's condition.

Revert the change to the Makefile that incorrectly attempted to silence
the diagnostic.
2020-09-17 18:30:22 -05:00
Jeff Epler
c73182803d sdioio: fix code for the case where there is no SDHC1
.. it doesn't really make a difference (the old code created an empty
else{} statement) but this is more correct.
2020-09-17 18:29:31 -05:00
Jeff Epler
1b29ceaf1a sam e54: disable microcontroller.cpu.voltage
This hangs, and the usual workarounds didn't work.
2020-09-17 18:27:43 -05:00
Jeff Epler
1fc797132a
Merge pull request #3237 from DavePutz/issue3216
Issue#3216 - Needed an alternate way to check if background tasks were run
2020-09-16 08:47:33 -05:00
Dan Halbert
3c6af94fb3
Merge pull request #3384 from jepler/feather_m4_can
atmel-samd: add same51, feather_m4_can
2020-09-14 23:57:51 -04:00
DavePutz
2a2a8d6457
Merge pull request #28 from adafruit/main
Merge from adafruit/main
2020-09-14 16:50:40 -05:00
DavePutz
2eca4ee902
Update PulseIn.c 2020-09-14 11:04:45 -05:00
DavePutz
c014ac3089
Reworked check for input taking too long 2020-09-14 10:54:57 -05:00
Jeff Epler
e066448e36 atmel-samd: add same51, feather_m4_can
This is compile-tested, and requires updates in the related submodules:

https://github.com/adafruit/samd-peripherals/pull/35
https://github.com/adafruit/asf4/pull/37

This should not be merged until those can also be merged.
2020-09-08 13:06:45 -05:00
root
2690faec43 Moved checks for invalid pin to common-hal/microcontroller/Pin.c 2020-09-05 11:42:06 -05:00
Lucian Copeland
8021da08d3 Fix problematic whitespace on pulseout parameter errors 2020-08-27 11:07:47 -04:00
root
fe0f79adce Making requested modifications 2020-08-21 20:38:19 -05:00
Scott Shawcroft
a5b01f7361
Merge remote-tracking branch 'adafruit/main' into add_pwmio 2020-08-21 11:13:53 -07:00
root
6eae7ce78f Requested changes to pulsein 2020-08-20 16:57:00 -05:00
Scott Shawcroft
6857f98426
Split pulseio.PWMOut into pwmio
This gives us better granularity when implementing new ports because
PWMOut is commonly implemented before PulseIn and PulseOut.

Fixes #3211
2020-08-18 13:08:33 -07:00
Lucian Copeland
da75445cd5 Style changes, reposition runtime errors 2020-08-18 11:42:06 -04:00
Lucian Copeland
0fc730bc5a Expand PulseOut API, debug cleanup 2020-08-14 16:36:02 -04:00
root
c7b6e66426 Fixes for pulsein tick handling 2020-08-05 10:03:20 -05:00
Jeff Epler
93b373d617 "pop from empty %q"
Saves 12 bytes code on trinket m0
2020-08-04 18:42:09 -05:00
Jeff Epler
c849b781c0 Combine 'index out of range' messages 2020-08-04 14:45:45 -05:00
Jeff Epler
dddd25a776 Combine similar strings to reduce size of translations
This is a slight trade-off with code size, in places where a "_varg"
mp_raise variant is now used.  The net savings on trinket_m0 is
just 32 bytes.

It also means that the translation will include the original English
text, and cannot be translated.  These are usually names of Python
types such as int, set, or dict or special values such as "inf" or
"Nan".
2020-08-04 13:34:29 -05:00
root
9203a77804 Turn off interrupts while in handler 2020-08-03 11:31:12 -05:00
root
12b81618a3 Changes for getting supervisor ticks 2020-08-01 13:27:02 -05:00
Dan Halbert
e5e132a364 add blm_badge; add CIRCUITPY_AUDIOBUSIOIO_I2SOUT 2020-07-28 11:49:54 -04:00
Jeff Epler
1df48176ce supervisor: factor supervisor_background_tasks from sundry ports 2020-07-15 11:49:44 -05:00
Scott Shawcroft
51c888d4be
Merge pull request #3003 from Flameeyes/master
License tagging according to REUSE specifications.
2020-07-13 16:28:49 -07:00
Diego Elio Pettenò
34b4993d63 Add license to some obvious files. 2020-07-06 19:16:25 +01:00
DavePutz
94d90742dd
Implementation of RTC continuous synchronization during pulsein
Flags and code to implement RTC continuous synchronization during pulsein
2020-07-04 21:15:38 -05:00
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
c5db97c50f atmel-sam: sdio: disable debug prints by default 2020-06-26 13:16:16 -05:00
Jeff Epler
f496c0b58d atmel-samd: Add SDIO SD card interface 2020-06-26 11:50:42 -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
Jeff Epler
da733c01da atmel-samd: Add support for SAM E54 family MCUs
This introduces the new macro SAM_D5X_E5X.  This is mostly the same
as SAMD51 before, except in a few places where a special case for
SAME54 is required
2020-06-23 10:41:48 -05:00
Scott Shawcroft
54b66d9484
Merge pull request #3052 from dhalbert/samd51-voltage-check-delay
delay 1ms on SAMD51 when reading processor voltage
2020-06-22 14:29:43 -07:00
Jeff Epler
a770b5a919 never_reset_pin: Move pin validity check before first use of pin number 2020-06-22 10:45:27 -05:00
Jeff Epler
a580f0f1c4 _pew: move to common-hal
I noticed that this code was referring to samd-specific functionality,
and isn't enabled except in one samd board (pewpew10).  Move it.

There is incomplte support for _pew in mimxrt10xx which then caused build
errors; adding a #if guard to check for _pew being enabled fixes it.
The _pew module is not likely to be important on mimxrt but I'll leave the
choice to remove it to someone else.
2020-06-22 10:45:27 -05:00
Dan Halbert
1687c8b1e3 delay 1ms on SAMD51 when reading processor voltage 2020-06-19 15:25:04 -04: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
Dan Halbert
3574670226
Merge pull request #2931 from tannewt/esp32s2_digitalio
Finish digitalio and pin use tracking for ESP32S2
2020-05-26 19:18:45 -04:00
DavePutz
2e05f628f0
Add an increment to tcc_refcount to allow deinits to work properly 2020-05-21 11:08:26 -05: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
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
Daniel Pollard
ee2cb703c8 merged master 2020-05-12 14:41:28 +10:00
warriorofwire
eb3d5fa453 ujson: do not eat trailing whitespace
Ujson should only worry about whitespace before JSON.  This becomes apparent when you are using MP stream protocol to read directly from input buffers.

When you attempt to read(1) on a UART (and possibly other protocols) you have to wait for either the byte or the timeout.

Fixes:
- Waiting for a timeout after you have completed reading a correct and complete JSON off the input.
- Raising an OSError after reading a correct and complete JSON off the input.
- Eating more data than semantically owned off the input buffer.
- Blocking to start parsing JSON until the entire JSON body has been loaded into a potentially large, contiguous Python object.

Code you would write before:
```
line = board_busio_uart_port.read_line()
json_dict = json.loads(line)
```
or reaching for fixed buffers and swapping them around in Python.

Code that did not work before that does now:
```
json_dict = json.load(board_busio_uart_port)
```

- This removes the need for intermediate copies of data when reading JSON from micropython stream protocol inputs.
- It also increases total application speed by parsing JSON concurrently with receiving on boards that read from UART via DMA.
- It simplifies code that users write while improving their apps.
2020-05-10 20:45:42 -07:00
Daniel Pollard
bfa5cd9c13 refactor countio based on feedback 2020-05-05 15:23:38 +10: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
23bced26da samd: actually disable protomatter timer
Just setting the timer handler to NO_INTERRUPT doesn't stop the
interrupt from occurring.
2020-04-14 18:24:58 -05:00
Jeff Epler
09dc46a984 Add Protomatter and FramebufferDisplay 2020-04-14 18:24:54 -05:00
Scott Shawcroft
d0a25ca9ac
Tweaks based on dhalberts feedback 2020-04-08 10:49:46 -07:00
Scott Shawcroft
c0ba2a839f
Updates based on feedback from jepler 2020-04-06 16:03:31 -07:00
Scott Shawcroft
e99cf6e441
Rework sleep timing
It didn't account for background task time and could end up
sleeping for way longer than it should because the RTC compare time
had already passed.
2020-04-03 18:07:56 -07:00
Scott Shawcroft
46af4bdd0e
Fix SAMD21 PulseIn 2020-04-02 17:35:52 -07:00
Scott Shawcroft
d9e68156b2
fix up SAMD21 sleep 2020-03-17 12:10:35 -07:00
Scott Shawcroft
76ca13b6ed
Fix SAMD51 pulsein 2020-03-13 17:21:15 -07:00
Scott Shawcroft
df5be65423
Update FrequencyIn for new clock API. 2020-03-13 16:12:52 -07:00
Scott Shawcroft
48b5f2a384
Initial work on SAMD 2020-03-13 11:16:41 -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
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
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
Scott Shawcroft
5d24ade5c9
Tweak error messages to reduce code size. 2020-01-29 17:32:07 -08:00
Jeff Epler
cb6193bbc7 samd: When possible, use one DMA channel for stereo AudioOut
.. the documentation doesn't make this clear, but in practice it works
to write both of the DATABUF registers at the same time.  This should
also reduce the amount of wear and tear DMA puts on the system, as the
number of transfers is cut in half.  (the number of bytes transferred
remains the same, though)

In principle, this could cover all stereo cases if audio_dma_convert_signed
also learned to 16-bit extend and swap values.  However, this is the
case that matters for stereo mp3 playback on PyGamer.

Testing performed: Listened to some tracks with good stereo separation.
2020-01-26 15:36:24 -06:00
Dan Halbert
2a75196aa3 merge from adafruit/circuitpython 2020-01-13 18:15:32 -05:00
Dan Halbert
189f2d5f07 Make requiring I2C pullups be optional 2020-01-09 17:31:50 -05:00
Dan Halbert
242d572470 wip 2020-01-03 10:24:07 -05:00