Commit Graph

378 Commits

Author SHA1 Message Date
Scott Shawcroft 412eb87080
Switch to pin, frequency and duty_cycle PulseOut
Passing in a PWMOut still works but is deprecated. It will be
removed in CircuitPython 8.0.0

This also switches STM32 timer indices and channel indices to
0-based in our pin data rather than `- 1` everywhere. The latter is
more bug prone.

Most of the way for #3264

Tested on Metro M0, Metro M4, Feather S2, Feather nRF52840, Feather
STM32F4 and Arduino RP2040.
2021-07-26 18:35:49 -07:00
Scott Shawcroft fece0fb432
Fix crash when UART construct fails
After the script stops with the exception thrown the final gc_sweep
will call any finalizers and they usually call deinit. deinit on
invalid objects can wreak havoc by changing random memory or
(hopefully) crashing. This fixes ensures the object is deinited
until initialization succeeds and the object is valid.

Do the same fix for I2C and SPI too.

Fixes #4700 and fixes #5005
2021-07-20 17:15:19 -07:00
Scott Shawcroft ca2cb9af2b
Remove MICROPY_PORT_* macros used for never reset
Now we use never_reset which is generally more correct and easier
to get right.

Fixes #5001 and fixes #4997
2021-07-15 16:20:04 -07:00
BoB LeSuer 35030fbb30 added pin object to analogout 2021-07-12 20:33:42 -04:00
Jeff Epler 268717e427 ParallelImageCapture: Switch to taking a list of pins
.. adopting validate_pins from RGBMatrix into shared-bindings

.. updating other platforms for API change
2021-06-10 11:15:18 -05:00
Jeff Epler 26a75f74ec
Merge pull request #4862 from DavePutz/issue_3383
Fix for issue #3383 - SAMD5x microcontroller.cpu.voltage
2021-06-09 14:42:27 -05:00
root bc34403d71 Removed all references to MICROCONTROLLER_VOLTAGE_DISABLE 2021-06-09 10:46:14 -05:00
root b2dea8ae0d Fix for issue #3383 - SAMD51 microcontroller.cpu.voltage 2021-06-05 16:17:14 -05:00
Jeff Epler 6b476c19ba fix formatting 2021-05-29 08:10:10 -05:00
Jeff Epler b0dd0e344c
Merge pull request #4772 from EmergReanimator/atmel-samd
[resolves #4771] DEBUG UART supported on ATMSAME5x
2021-05-28 20:05:06 -06:00
EmergReanimator 7805392b9e
Update UART.c
Incorporating feedback: https://github.com/adafruit/circuitpython/pull/4772#discussion_r634112839
2021-05-19 20:19:16 +02:00
EmergReanimator 2b64b1d335 [resolves #4771] DEBUG UART supported on ATMSAME5x 2021-05-17 21:22:24 +02:00
Scott Shawcroft 5c33c9d597
Fix SAMD
RTC needed to wait for sync. NeoPixel on SAMD doesn't need disabled
caches. It just needed timing adjustment for 120mhz clock speed.
2021-05-14 16:14:24 -07:00
Scott Shawcroft 1a0b4193b7
Simplify the status LED to save power
This also removes the need to pin share because we don't use the
status LED while user code is running.

The status flashes fallback to the HW_STATUS LED if no RGB LED is
present. Each status has a unique blink pattern as well.

One caveat is the REPL state. In order to not pin share, we set the
RGB color once. PWM and single color will be shutoff immediately but
DotStars and NeoPixels will hold the color until the user overrides
it.

Fixes #4133
2021-05-13 14:41:20 -07:00
Dan Halbert d2b558993e merge from main, including MicroPython 1.12 merge 2021-05-03 20:56:04 -04:00
Dan Halbert 9ca0e689a5
Merge branch 'main' into wio_add_pin_assign 2021-05-03 09:33:18 -04:00
Jeff Epler dfa7c3d32d codeformat: Fix handling of `**`
After discussing with danh, I noticed that `a/**/b` would not match `a/b`.

After correcting this and re-running "pre-commit run --all", additional
files were reindented, including the codeformat script itself.
2021-04-30 15:30:13 -05:00
Jeff Epler e95e921ca1 codeformat: Fix filename matching
In #4683, tannewt noticed that uncrustify was not running on some
file in common-hal.

I investigated and found that it was not being run on a bunch of paths.

Rather than make incremental changes, I rewrote list_files to work
bsaed on regular expressions; these regular expressions are created from
the same git-style glob patterns.

I spot-checked some specific filenames after this change, and all looks good:

```
$ python3 tools/codeformat.py -v --dry-run tests/basics/int_small.py ports/raspberrypi/common-hal/pulseio/PulseIn.c extmod/virtpin.c tests/thread/thread_exit1.py  ports/raspberrypi/background.h extmod/re1.5/recursiveloop.c
tools/codeformat.py -v --dry-run tests/basics/int_small.py ports/raspberrypi/common-hal/pulseio/PulseIn.c extmod/virtpin.c tests/thread/thread_exit1.py ports/raspberrypi/background.h extmod/re1.5/recursiveloop.c
uncrustify -c /home/jepler/src/circuitpython/tools/uncrustify.cfg -lC --no-backup extmod/virtpin.c ports/raspberrypi/background.h ports/raspberrypi/common-hal/pulseio/PulseIn.c
black --fast --line-length=99 -v tests/thread/thread_exit1.py
```
recursiveloop and int_small are excluded, while PulseIn, virtpin,
and background are included.

Testing running from a subdirectory (not _specifically_ supported though):
```
(cd ports && python3 ../tools/codeformat.py -v --dry-run raspberrypi/common-hal/pulseio/PulseIn.c ../extmod/virtpin.c)
../tools/codeformat.py -v --dry-run raspberrypi/common-hal/pulseio/PulseIn.c ../extmod/virtpin.c
uncrustify -c /home/jepler/src/circuitpython/tools/uncrustify.cfg -lC --no-backup ../extmod/virtpin.c raspberrypi/common-hal/pulseio/PulseIn.
```

As a side-effect, a bunch more files are re-formatted now. :-P
2021-04-30 10:48:08 -05:00
Dan Halbert be7b2b00a8 uncrustify with newer version of uncrustify 2021-04-30 10:40:12 -04:00
Tsutomu IKEGAMI 0d25b95f0d Add definitions of PB2[4-9] pins to microcontroller.pin for atmel-samd. 2021-04-29 02:19:34 +09:00
Dan Halbert 9d1fcc3b14 merge from main 2021-04-25 10:27:52 -04:00
Mark ed374a89fb
Merge pull request #4655 from DavePutz/issue_4602
Issue 4602 - Correct timing of PulseOut on SAMD21
2021-04-24 10:45:10 -05:00
Jeff Epler 34c4cc1bd9 samd: Rename dma_{allocate,free} channel
These are now used in the (video) parallel capture device as well.
2021-04-23 09:46:33 -05:00
Dan Halbert 64e0958916 wip: descriptor building 2021-04-21 23:25:36 -04:00
root 0e2431048d Fix PWMOut on SAMD21 2021-04-20 15:21:05 -05:00
Jeff Epler 46c9b1bc37 atmel-sam: Use DMA for ParallelImageCapture
This allows ctrl-c to interrupt the capture, and ensures we handle
interrupts & background tasks.
2021-04-20 13:52:44 -05:00
Jeff Epler d50feebd2c atmel-sam: Factor out find_sync_event_channel_raise 2021-04-20 13:33:11 -05:00
Jeff Epler 4dcbdac97e Complete the 'horizontal_reference' rename 2021-04-20 11:33:32 -05:00
Jeff Epler 5c5736ee1e atmel-sam: Allow PWM to go up to cpu_frequency/2
24MHz is the nominal external clock to use with OV7670.  (My testing
was actually at 16MHz)
2021-04-20 10:22:21 -05:00
Jeff Epler 99799cded6 imagecapture: implement to review suggestions 2021-04-20 10:21:32 -05:00
Jeff Epler fc4538f845 WIP: Implement 'ParallelImageCapture' for samd51 2021-04-16 17:18:59 -05:00
Dan Halbert 61e33a5619 fix nrf ISR; make direction consistent across ports; save code size 2021-04-09 11:07:47 -04:00
Jeff Epler 3aec1032f7 atmel-samd: switch to shared softencoder implementation 2021-04-08 16:32:36 -05:00
gamblor21 0890b54cd9 More formatting 2021-03-16 08:29:04 -05:00
gamblor21 fb437d8280 Formatting fixes 2021-03-16 08:22:02 -05:00
Mark e326d7ca80
Merge branch 'main' into rp_dp_parallel 2021-03-15 20:00:13 -05:00
microDev a52eb88031
run code formatting script 2021-03-15 19:27:36 +05:30
gamblor21 56a219911f Add frequency support to parallel bus 2021-03-11 19:32:43 -06:00
jposada202020 be90fa80e8 Initial Changes 2021-03-09 10:48:33 -05:00
Jeff Epler 1d1ff5f308 Merge remote-tracking branch 'origin/main' into update-protomatter-rp2 2021-02-26 09:56:35 -06:00
Jeff Epler ff1942cff6 Enable protomatter on RP2040 builds
Also found a race condition between timer_disable and redraw, which
would happen if I debugger-paused inside common_hal_rgbmatrix_timer_disable
or put a delay or print inside it.  That's what pausing inside reconstruct
fixes.

So that the "right timer" can be chosen, `timer_allocate` now gets the `self`
pointer.  It's guaranteed at this point that the pin information is accurate,
so you can e.g., find a PWM unit related to the pins themselves.
This required touching each port to add the parameter even though it's
unused everywhere but raspberrypi.
2021-02-12 08:25:15 -06:00
Dan Halbert f0564b4986 merge from upstream; complicated webusb merge 2021-02-11 18:50:02 -05:00
Dan Halbert 3a68ac8abb
Merge pull request #3536 from pewpew-game/pew-get-ticks
Fix #3504: Don't use time module in pew.tick()
2021-02-08 17:50:44 -05:00
BiffoBear 2656c84b01 Initial commit. Edited error messages in .c files 2021-02-03 05:49:40 +07:00
Dan Halbert 4be5e914ac
Merge pull request #3966 from dhalbert/samd-dac-channels
fix atmel-samd DAC channel selection logic
2021-01-12 13:01:50 -05:00
Dan Halbert 452d66dd0e
Update ports/atmel-samd/common-hal/analogio/AnalogOut.c
whoops, yes!

Co-authored-by: Scott Shawcroft <scott@tannewt.org>
2021-01-11 19:12:52 -05:00
Dan Halbert 316bd0c72d fix atmel-samd DAC channel selection logic 2021-01-10 19:22:15 -05:00
Dan Halbert 908e02439d Look up TCC resolution as necessary 2021-01-09 15:04:23 -05:00
microDev dc332baa87
update common_hal_reset_pin() 2020-12-28 20:04:00 +05:30
Uwe Gartmann 2729666d82
SAMD51: change of DAC power setting
Fixes wrong DAC output levels at high data rate
closes adafruit#3796
2020-12-25 17:53:43 +01:00