Commit Graph

294 Commits

Author SHA1 Message Date
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
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
1905d0746d samd: neopixel: Fix neopixels after #2297
This adapts the "inline assembler" code from the UF2 bootloader, which
in turn is said to be adapted from the arduino neopixel library.

This requires the cache remain ON when using M0, and be turned OFF on M4
(determined by trial and error)

Testing performed on a Metro M4:
 * measured timings using o'scope and found all values within
   datasheet tolerance.
 * Drove a string of 96 neopixels without visible glitches
 * on-board neopixel worked

Testing performed on a Circuit Playground Express (M0):
 * Color wheel code works on built-in neopixels
 * Color wheel code works on 96 neopixel strip

As a bonus, this may have freed up a bit of flash on M0 targets. (2988 ->
3068 bytes free on Trinket M0)

Closes: #2297
2019-12-07 19:19:45 -06:00
Dan Halbert
d628d2a261 atmel-samd working 2019-12-06 15:18:20 -05:00
Dan Halbert
40434d6919 wip 2019-12-05 22:45:53 -05: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
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
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
Thea Flowers
4b742f88d9
Fix spelling 2019-10-25 10:50:27 -07:00
Thea Flowers
4fdf518251
Track unadjusted PWM duty cycle to avoid accumulating conversion errors
Fixes #2086

When the frequency of a `PWMOut` is change it re-sets the PWM's duty cycle as
well, since the registers have to be re-calculated based on the new frequency.
Unfortunately, `common_hal_pulseio_pwmout_get_duty_cycle`
will return a value very close to, but not exactly, the value passed to `common_hal_pulseio_pwmout_set_duty_cycle`. If the frequency is modified
without the calling code also re-setting the duty cycle then the duty cycle
will decay over time. This fixes that problem by tracking the unadjusted duty
cycle and re-setting the duty cycle to that value when the frequency is changed.
2019-10-23 14:34:14 -07:00
Dan Halbert
7b79ac3739 Parameterize linker script 2019-10-20 23:50:12 -04:00
Dan Halbert
c1ab2486f9 return chip vcc value 2019-10-12 15:42:15 -04:00
jepler
61698eb5d8 AnalogOut / AudioOut: Copy settings from Arduino
Make changes in asf4_conf even though I think in these cases the
"peripherals" submodule is running the show.

Arduino clocks the DAC at 12MHz but uses the CCTRL setting for
clocking < 1.2MHz (100kSPS).

A fresh clock (6) is allocated for the new 12MHz clock.  This matches
the Arduino value, though not the GCLK index.

Modify other settings to more closely resemble Arduino.

In AudioOut, actually clock the waveform data from the timer we set up
for this purpose.

This gives good waveforms when setting AnalogOut full-scale in a loop,
but the rise/fall of waveforms that come from AudioOut are still erratic.
Weirdly, if AudioOut limits its range even slightly (e.g., to 1000..64000)
then the erratic

Note that this will require https://github.com/adafruit/samd-peripherals/pull/26
to be accepted for the submodule update here to work.
2019-09-15 11:30:49 -05:00
Scott Shawcroft
8066810abb
Merge pull request #2091 from jepler/samd-dma-tracking
Samd dma tracking
2019-09-05 11:27:59 -07:00
jepler
30a9346373 samd: audio_dma: Track channel allocation
Previously, we depended on allocated channels to always be
"dma_channel_enabled".  However, (A) sometimes, many operations
would take place between find_free_audio_dma_channel and
audio_dma_enable_channel, and (B) some debugging I did led me to believe
that "dma_channel_enabled" would become false when the hardware ended
a scheduled DMA transaction, but while a CP object would still think it
owned the DMA channel.

((B) is not documented in the datasheet and I am not 100% convinced that
my debugging session was not simply missing where we were disabling the
channel, but in either case, it shows a need to directly track allocated
separately from enabled)

Therefore,
 * Add audio_dma_{allocate,free}_channel.
   * audio_dma_free_channel implies audio_dma_disable_channel
   * track via a new array audio_dma_allocated[]
 * clear all allocated flags on soft-reboot
 * Convert find_free_audio_dma_channel to audio_dma_allocate_channel
   * use audio_dma_allocated[] instead of dma_channel_enabled() to check
     availability
 * remove find_free_audio_dma_channel
 * For each one, find a matching audio_dma_disable_channel to convert
   to audio_dma_free_channel

Closes: #2058
2019-08-28 17:00:22 -05:00
jepler
0b00787b4d samd: AudioOut: ensure stopped before deinit
.. otherwise, a sequence like
    >>> a = audioio.AudioOut(board.A0)
    >>> a.play(sample, loop=True)
    >>> a.deinit()
would potentially leave related DMA channel(s) active.
2019-08-28 16:43:55 -05:00
Scott Shawcroft
0876d5c4ad
Disable bitbangio on Itsy M0
Also, switch CIRCUITPY_BITBANG_APA102 to makefile setting so it can alter included files
2019-08-27 15:21:47 -07:00
Scott Shawcroft
7324b70a7c
Rework based on Dan's review 2019-08-23 15:27:21 -07:00
Scott Shawcroft
3a98de1236
Add reset() to display busses to detect whether it works 2019-08-22 14:23:33 -07:00
Scott Shawcroft
70680d5b22
EPaper displays work mostly. 2019-08-22 14:08:33 -07:00
Dan Halbert
7cc15e56c8 make translate 2019-08-22 15:20:23 -04:00
Dan Halbert
6e3a6d0ac5 typo in IncrementalEncoder.c 2019-08-20 16:23:17 -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
Dan Halbert
e2a4c76a37 make nrf touchio be generic: now available for SAMD51 too 2019-08-18 08:44:10 -04:00
Jeff Epler
d9ee2d28a0 atmel-samd: Use RUN_BACKGROUND_TASKS 2019-08-11 08:53:02 -05:00
Jeff Epler
8b717955ba samd: audio_dma: wrap dma_{en,dis}able_channel and add error checking
It turns out the "disable" error will fire in practice, we'll fix that
next.
2019-08-06 22:00:31 -05:00
Jeff Epler
6b44e40ee8 audiocore: Factor from audioio
When nrf pwm audio is introduced, it will be called `audiopwmio`.  To
enable code sharing with the existing (dac-based) `audioio`, factor
the sample and mixer types to `audiocore`.

INCOMPATIBLE CHANGE: Now, `Mixer`, `RawSample` and `WaveFile` must
be imported from `audiocore`, not `audioio`.
2019-07-25 06:44:26 -05: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
Scott Shawcroft
f4a64a2e80
Merge pull request #1989 from rce1086/master
Added conditional compilation around selection of TX pad candidates
2019-07-08 14:07:04 -07:00
Carl Elkins
64507207da Added conditional compilation around selection of TX pad candidates
Original code was correct for SAMD21
New code for SAMD51 only permits pad-0 for TX
2019-07-08 02:08:39 +01:00
iot49
4c72a3991e updated samd and esp8266 ports 2019-07-05 10:01:51 -07:00
Elvis Pfützenreuter
1da8d4b4da Add PS/2 support -- ps2io module 2019-06-04 18:05:46 -03:00
Scott Shawcroft
b87565138e
Rework safe mode so we can trigger on all resets 2019-05-09 10:15:28 -07:00
Scott Shawcroft
837d3f57ee
Update on_next_reset for new safe mode.
Fixes #1831
2019-05-08 15:23:40 -07:00
Dan Halbert
f59dadbb4f avoid double float arithmetic in FrequencyIn 2019-05-07 00:25:22 -04:00
Scott Shawcroft
f7c7904e2b
Correct call structure for throwing errors 2019-04-17 13:54:29 -07:00
Carlos
71c4f100de
Update translations and use same error for PDM too 2019-04-17 11:28:43 -07:00
Carlos
5865b28592
[audiobusio-I2SOut] Fix translation error 2019-04-17 11:12:38 -07:00
Carlos
65cc366280
[audiobusio-I2SOut] Fix compilation error by using mp_raise_ValueError_varg 2019-04-17 11:12:38 -07:00
Carlos
9f63125345
Fix I2SOut message, fix #1765 2019-04-17 11:12:38 -07:00
Scott Shawcroft
de48e4b262
Merge remote-tracking branch 'adafruit/master' into fix_cpx_display 2019-04-08 17:15:08 -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
Scott Shawcroft
7686f93ef4
Fix crash when getting board.SPI outside the VM
If one of the default pins was already in use it would crash.

The internal API has been refined to allow us to get the value
without causing an init of the singleton.

Fixes #1753
2019-04-05 19:06:37 -07:00
Dan Halbert
cdd77b5972 remove CPy-specific EIC handlers from samd-peripherals 2019-04-04 16:04:11 -04:00
Scott Shawcroft
ff7e729032
Fix custom pin in use logic for SWD
This should allow you to use SWD pins unless a debugger is attached.
You may have trouble connecting to SWD when CircuitPython has already
begun using them.

Fixes #1633
2019-03-14 11:11:35 -07:00
Dan Halbert
97140e6a62 wrong arg type for PWMOut variable_frequency 2019-03-12 21:28:30 -04:00
Scott Shawcroft
37e10d4a81
Be more careful when initing the board outside the VM. 2019-03-12 11:18:29 -07:00
sommersoft
b7b74d1f78 update translations 2019-03-02 18:17:58 -06:00
sommersoft
a44bfc2730 Merge branch 'master' of https://github.com/adafruit/circuitpython into new_freq_in 2019-03-01 21:24:30 -06:00
Dan Halbert
3c24e893e9 Fix SYNCBUSY loop typo. 2019-02-28 23:38:26 -05:00
Dan Halbert
808304e827 Use TCC LUPD lock when updating CCB 2019-02-28 19:53:35 -05:00
sommersoft
4d47ce5c60 fixes set_timer_handler call 2019-02-27 19:28:59 -06:00
sommersoft
4a9f05a44f final re-glue; compiles now. 2019-02-25 21:22:52 -06:00
sommersoft
f602fa3d9f fix init deps 2019-02-24 18:07:26 -06:00
sommersoft
2437ab9605 update frequencyin interrupt handler 2019-02-22 17:19:09 -06:00
sommersoft
a1060747f8 Merge branch 'new_master' into new_freq_in 2019-02-22 23:12:11 +00:00
Scott Shawcroft
af863a3780
Merge pull request #1586 from sommersoft/shared_timer_handler
Move shared_timer_handler
2019-02-22 11:04:27 -08:00
sommersoft
55e7c5a41b handle 'set_timer_handler' on this side, vs samd-periphs. 2019-02-19 20:18:21 -06:00
Dan Halbert
9c24c804fb Fix #ifdefs in port.c to call xxx_reset() rroutines properly. Remove most uses of EXPRESS_BOARD. 2019-02-18 22:44:31 -05:00
sommersoft
dafc370d22 moves 'shared_timer_handler' back to atmel-samd from samd-peripherals 2019-02-16 19:54:16 -06:00
sommersoft
ea9200a042 starting again; initial addition of 'frequencyio.FrequencyIn' 2019-02-16 19:26:24 -06:00
Dan Halbert
cf545cd477 WIP: fix issues with remaining atmel-samd builds 2019-02-15 09:52:45 -05:00
Dan Halbert
da5008f4d8 Fix atmel UART after ASF4 pruning. 2019-02-13 11:42:09 -05:00
Scott Shawcroft
1a6ad20943
Get space back by using less ASF4 and combining register writes 2019-02-11 17:36:34 -08:00
Scott Shawcroft
69bc5e189b
Rudamentary backlight support 2019-01-31 11:42:14 -08:00