Commit Graph

309 Commits

Author SHA1 Message Date
robert-hh
32e69f7fdb samd/boards: Change the SparkFun vendor name to SparkFun.
Only the board.json files are affected. No other file uses the
style "Sparkfun". The documentation is fine.

Signed-off-by: robert-hh <robert@hammelrath.com>
2025-06-19 15:12:49 +02:00
Matt Trentini
3e33d0567f ports: Update board.json files for vendor/product consistency.
The vendor and product fields in the `board.json` files were somewhat
inconsistent.  Remove any duplication of the vendor name in the product
field so that `f"{vendor} {product}"` reads well.

In addition to that, update most of the URL's for `board.json` files that
are modified here, and match case and spacing used by the manufacturers for
the vendor and product names.

Signed-off-by: Matt Trentini <matt.trentini@gmail.com>
2025-06-04 01:47:59 +10:00
robert-hh
bbdc832ca9 samd/boards: Add two SparkFun SAMD21 boards.
Add support for the boards:
- SparkFun SAMD21 Dev Breakout
- SparkFun RedBoard Turbo

Both boards are SAMD21 based and actively sold by SparkFun.

Signed-off-by: robert-hh <robert@hammelrath.com>
2025-05-28 12:04:42 +10:00
Angus Gratton
22f1d76633 shared/tinyusb: Use device event hook to schedule USB task.
Previously MicroPython ports would linker-wrap dcd_event_handler
in order to schedule the USB task callback to run when needed.

TinyUSB 0.16 added proper support for an event hook to do the
same thing without the hacky linker wrapping.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2025-05-26 11:15:33 +10:00
Alessandro Gatti
f47e214cdc all: Rename the "NORETURN" macro to "MP_NORETURN".
Some checks failed
unix port / settrace (push) Has been cancelled
unix port / settrace_stackless (push) Has been cancelled
unix port / macos (push) Has been cancelled
unix port / qemu_mips (push) Has been cancelled
unix port / qemu_arm (push) Has been cancelled
unix port / qemu_riscv64 (push) Has been cancelled
webassembly port / build (push) Has been cancelled
windows port / build-vs (Debug, x64, windows-2022, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Debug, x64, windows-latest, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Debug, x86, windows-2022, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Debug, x86, windows-latest, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x64, windows-2019, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x64, windows-2019, standard, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x64, windows-2022, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x64, windows-2022, standard, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x64, windows-latest, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x64, windows-latest, standard, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x86, windows-2019, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x86, windows-2019, standard, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x86, windows-2022, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x86, windows-2022, standard, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x86, windows-latest, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x86, windows-latest, standard, 2017, [15, 16)) (push) Has been cancelled
windows port / build-mingw (i686, mingw32, dev) (push) Has been cancelled
windows port / build-mingw (i686, mingw32, standard) (push) Has been cancelled
windows port / build-mingw (x86_64, mingw64, dev) (push) Has been cancelled
windows port / build-mingw (x86_64, mingw64, standard) (push) Has been cancelled
windows port / cross-build-on-linux (push) Has been cancelled
zephyr port / build (push) Has been cancelled
Python code lint and formatting with ruff / ruff (push) Has been cancelled
This commit renames the NORETURN macro, indicating to the compiler
that a function does not return, into MP_NORETURN to maintain the same
naming convention of other similar macros.

To maintain compaitiblity with existing code NORETURN is aliased to
MP_NORETURN, but it is also deprecated for MicroPython v2.

This changeset was created using a similar process to
decf8e6a8b ("all: Remove the "STATIC"
macro and just use "static" instead."), with no documentation or python
scripts to change to reflect the new macro name.

Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
2025-05-13 10:36:47 +10:00
robert-hh
80d03b7780 samd/samd_qspiflash: Remove the attempt to handle a unknown device.
Since all QSPI flash device used by this port are defined, this code was
only used unintentionally.  Besides that it was incomplete, so better drop
it.

Note: The flash type for Mini-SAM had to be changed too.

Signed-off-by: robert-hh <robert@hammelrath.com>
2025-05-07 16:20:19 +10:00
robert-hh
2e6df08e05 samd/samd_spiflash: Improve the flash type detection.
Changes in this commit:
- Check for the proper SFDP header.
- Use the flash size information from SFDP, if present.
- Add two more special flash chips <= 1 MByte without SFDP.  JEDEC-ID table
  for special flash types instead of a series of conditional statements.
- Add a compile flag `MICROPY_HW_SPIFLASH_SIZE` to set the size in
  `mpconfigboard.h`, which replaces getting the size from the JEDEC ID or
  the SFDP record.

Signed-off-by: robert-hh <robert@hammelrath.com>
2025-05-07 16:19:48 +10:00
robert-hh
c22c2c8066 samd/boards/SAMD_GENERIC_D51xxx: Fix VFS settings for internal flash.
Fixes in this commit:
- The wrong loader script was assigned for SAMD_GENERIC_D51X20, causing the
  VFS block count to be wrong.
- Change the VFS block size from 1536 to 2048.  With the setting of 1536,
  writing more that 1536 bytes at once failed.  This applies to
  SAMD_GENERIC_D51X19 and SAMD_GENERIC_D51X20.  No other SAMD51 board uses
  the internal flash for the file system.

Signed-off-by: robert-hh <robert@hammelrath.com>
2025-05-07 16:18:07 +10:00
robert-hh
ff9e01782b samd/modtime: Change time.time_ns() to follow the RTC time.
That is done by adding the offset to epoch, following the scheme from the
RP2 port.  RTC and `ticks_us()` are not precisely in sync, and so the
difference between `time.time_ns()/1e9` and `time.time()` will increase by
more than 9 seconds/24h.  So applications should avoid using `time.time()`
and `time.time_ns()` in the same context.

Signed-off-by: robert-hh <robert@hammelrath.com>
2025-05-07 16:17:07 +10:00
robert-hh
2fda4bbe05 samd/machine_i2c: Add the timeout keyword argument to the constructor.
To make it compliant with the documentation.  The default value is 50000us.

Signed-off-by: robert-hh <robert@hammelrath.com>
2025-05-07 16:16:45 +10:00
robert-hh
8e328da9bf samd/boards/SAMD_GENERIC_Dxxx: Add Microchip URL to board.json.
To the Microchip Web site.  Thanks to Matt Trentini for suggesting this
site.

Signed-off-by: robert-hh <robert@hammelrath.com>
2025-05-07 16:16:11 +10:00
Malcolm McKellips
288dce26bd docs,ports: Fix SparkFun capitalization.
Some checks failed
unix port / settrace (push) Has been cancelled
unix port / settrace_stackless (push) Has been cancelled
unix port / macos (push) Has been cancelled
unix port / qemu_mips (push) Has been cancelled
unix port / qemu_arm (push) Has been cancelled
unix port / qemu_riscv64 (push) Has been cancelled
webassembly port / build (push) Has been cancelled
windows port / build-vs (Debug, x64, windows-2022, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Debug, x64, windows-latest, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Debug, x86, windows-2022, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Debug, x86, windows-latest, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x64, windows-2019, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x64, windows-2019, standard, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x64, windows-2022, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x64, windows-2022, standard, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x64, windows-latest, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x64, windows-latest, standard, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x86, windows-2019, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x86, windows-2019, standard, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x86, windows-2022, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x86, windows-2022, standard, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x86, windows-latest, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x86, windows-latest, standard, 2017, [15, 16)) (push) Has been cancelled
windows port / build-mingw (i686, mingw32, dev) (push) Has been cancelled
windows port / build-mingw (i686, mingw32, standard) (push) Has been cancelled
windows port / build-mingw (x86_64, mingw64, dev) (push) Has been cancelled
windows port / build-mingw (x86_64, mingw64, standard) (push) Has been cancelled
windows port / cross-build-on-linux (push) Has been cancelled
zephyr port / build (push) Has been cancelled
Python code lint and formatting with ruff / ruff (push) Has been cancelled
This is a follow-up to 1e92bdd206 correcting
more of the instances where "Sparkfun" should be "SparkFun".

Signed-off-by: Damien George <damien@micropython.org>
2025-05-07 15:16:55 +10:00
robert-hh
4dfee50a0b samd/machine_uart: Fix lock-up in loopback mode if read buffer is full.
Signed-off-by: robert-hh <robert@hammelrath.com>
2025-03-27 11:39:02 +11:00
robert-hh
6db7b47ab9 samd/machine_uart: Fix unintended UART buffer allocation on init().
The buffer was be reset on every call to uart.init().  If no sizes were
given, the buffer was set to the default size 256.  That made problems
e.g. with PPP.

This commit fixes it, keeping the buffer size if not deliberately changed
and allocating new buffers only if the size was changed.  Cater for changes
of the bits value, which requires a change to the buffer size.

Signed-off-by: robert-hh <robert@hammelrath.com>
2025-03-27 11:38:31 +11:00
robert-hh
b9b4f1b40b samd/boards: Provide default IDs for UART, I2C and SPI.
In combination with the defautl Pins the default device can now be
instantiated e.g. as: uart = UART().  Similar for I2C and SPI.

Signed-off-by: robert-hh <robert@hammelrath.com>
2025-03-03 10:59:26 +11:00
robert-hh
4cbaab1766 samd/boards: Add missing TX/RX, SCL/SDA and SCK/MOSI/MISO pin names.
These were missing and are needed to support UART/I2C/SPI default pins.

Signed-off-by: robert-hh <robert@hammelrath.com>
2025-03-03 10:59:26 +11:00
robert-hh
daef1c1d14 samd/machine_uart: Support default instance and TX/RX pin values.
If a board configures a default UART instance and/or TX/RX pins then the
user can create a default UART object using `machine.UART()`.

Signed-off-by: robert-hh <robert@hammelrath.com>
2025-03-03 10:59:26 +11:00
robert-hh
62ed69b016 samd/machine_spi: Support default instance and SCK/MOSI/MISO pin values.
If a board configures a default SPI instance and/or SCK/MOSI/MISO pins,
then the user can create a default SPI object using `machine.SPI()`.

Also, if MISO is not going to be used, then MISO can be set to `None` with
`miso=None`.

Signed-off-by: robert-hh <robert@hammelrath.com>
2025-03-03 10:59:15 +11:00
robert-hh
213f1c1ee0 samd/machine_i2c: Support default instance and SCL/SDA pin values.
If a board configures a default I2C instance and/or SCL/SDA pins, then
these no longer need to be given in the constructor.  This allows the user
to easily construct the default I2C instance via `machine.I2C()` and that
will work on the default pins as designated on the board silkscreen.

Signed-off-by: robert-hh <robert@hammelrath.com>
2025-03-03 10:49:43 +11:00
Christian Clauss
5e206fdeb5 all: Upgrade codespell to v2.4.1.
This commit upgrades from codespell==2.2.6 to the current codespell==2.4.1,
adding emac to the ignore-words-list.

Signed-off-by: Christian Clauss <cclauss@me.com>
2025-02-25 16:11:33 +11:00
robert-hh
36a0a83997 samd/boards: Add support for the Adafruit NeoKey Trinkey board.
Tested with that board.

Signed-off-by: robert-hh <robert@hammelrath.com>
2025-02-07 18:02:52 +11:00
robert-hh
6cbe145ca8 samd/boards: Add support for the Adafruit QT Py board.
Supporting a variant with an optional SPIFLASH device as well.  Tested both
variants with a QT Py board.

Signed-off-by: robert-hh <robert@hammelrath.com>
2025-02-07 18:02:47 +11:00
robert-hh
ff9c6da88c samd/Makefile: Add support for board variants.
Tested with a Adafruit SAMD QT board, which may optionally be equipped with
SPIFLASH memory.

Signed-off-by: robert-hh <robert@hammelrath.com>
2025-02-07 18:01:57 +11:00
robert-hh
6b2e359076 samd/boards: Add generic SAMD51x20 board definitions.
The definition uses the internal oscillator for clock and only internal
flash for the file system.

It works at SAMD51J20 device as well, only that fewer pins are accessible.

Tested with a SAMD51J20 board.

Signed-off-by: robert-hh <robert@hammelrath.com>
2025-02-07 18:00:44 +11:00
robert-hh
9ced693ade samd/boards: Add generic SAMD51x19 board definitions.
The definition uses the internal oscillator for clock and only internal
flash for the file system.

It works at SAMD51G19 and SAMD51J19 devices as well, only that fewer pins
are accessible.

Tested with a SAMD51G19 and SAMD51J9 board.

Signed-off-by: robert-hh <robert@hammelrath.com>
2025-02-07 18:00:36 +11:00
robert-hh
304467518f samd/boards: Add generic SAMD21x18 board definitions.
The definition uses the internal oscillator for clock and only internal
flash for the file system.

It works at SAMD21G18 and SAMD21E18 devices as well, only that fewer pins
are accessible.

Tested with a SAMD21E18, SAM21G18 and SAMD21J18 board.

Signed-off-by: robert-hh <robert@hammelrath.com>
2025-02-07 17:59:35 +11:00
I. Tomita
c69f0e4eee samd/samd_qspiflash: Correct QSPI baud calculation.
Some checks failed
unix port / settrace (push) Has been cancelled
unix port / settrace_stackless (push) Has been cancelled
unix port / macos (push) Has been cancelled
unix port / qemu_mips (push) Has been cancelled
unix port / qemu_arm (push) Has been cancelled
unix port / qemu_riscv64 (push) Has been cancelled
webassembly port / build (push) Has been cancelled
windows port / build-vs (Debug, x64, windows-2022, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Debug, x64, windows-latest, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Debug, x86, windows-2022, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Debug, x86, windows-latest, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x64, windows-2019, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x64, windows-2019, standard, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x64, windows-2022, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x64, windows-2022, standard, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x64, windows-latest, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x64, windows-latest, standard, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x86, windows-2019, dev, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x86, windows-2019, standard, 2019, [16, 17)) (push) Has been cancelled
windows port / build-vs (Release, x86, windows-2022, dev, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x86, windows-2022, standard, 2022, [17, 18)) (push) Has been cancelled
windows port / build-vs (Release, x86, windows-latest, dev, 2017, [15, 16)) (push) Has been cancelled
windows port / build-vs (Release, x86, windows-latest, standard, 2017, [15, 16)) (push) Has been cancelled
windows port / build-mingw (i686, mingw32, dev) (push) Has been cancelled
windows port / build-mingw (i686, mingw32, standard) (push) Has been cancelled
windows port / build-mingw (x86_64, mingw64, dev) (push) Has been cancelled
windows port / build-mingw (x86_64, mingw64, standard) (push) Has been cancelled
windows port / cross-build-on-linux (push) Has been cancelled
zephyr port / build (push) Has been cancelled
Python code lint and formatting with ruff / ruff (push) Has been cancelled
The QSPI baud is derived from the AHB clock, not from the APB (peripheral)
clock.

Datasheet: The QSPI Baud rate clock is generated by dividing the module
clock (CLK_QSPI_AHB) by a value between 1 and 255.

As previously implemented, all baudrates are 2.5 times greater than
expected.

Signed-off-by: I. Tomita <ziceva@me.com>
2025-01-23 15:39:32 +11:00
Graeme Winter
70b95d8f93 samd/machine_dac: Fix SAMD51 DAC for two channels.
Improvements to DAC support for SAMD51:
- properly validate DAC id
- correctly use dac_init flag, as a 2-ple for A0, A1 channels
- disable DAC before adjusting settings, see SAMD5x data sheet §47.6.2.3

Co-authored-by: robert-hh <robert@hammelrath.com>
Signed-off-by: Graeme Winter <graeme.winter@gmail.com>
2025-01-23 15:29:11 +11:00
robert-hh
f4e4599523 ports: Fix machine.RTC.init() method so argument order matches the docs.
This commit makes the argument ordering of `machine.RTC.init()` the same
for all the ports that implement arguments to this method: cc3200, esp32,
mimxrt and samd.  The cc3200 argument ordering is used, which matches the
documentation.

Also document the availability and the differing semantics for the stm32
and renesas-ra port.

Signed-off-by: robert-hh <robert@hammelrath.com>
2024-12-19 16:04:47 +11:00
robert-hh
cbffe61f96 samd/mboot/README.md: Add information about the bootloader source.
Includes the LICENSE file of the source and the specific board files
for the Xplained Pro board.

Signed-off-by: robert-hh <robert@hammelrath.com>
2024-11-18 18:31:16 +01:00
robert-hh
ceae0e1494 samd/samd_flash: Make flash read/write methods access self parameters.
Some checks are pending
unix port / settrace (push) Waiting to run
unix port / settrace_stackless (push) Waiting to run
unix port / macos (push) Waiting to run
unix port / qemu_mips (push) Waiting to run
unix port / qemu_arm (push) Waiting to run
unix port / qemu_riscv64 (push) Waiting to run
webassembly port / build (push) Waiting to run
windows port / build-vs (Debug, x64, windows-2022, dev, 2022, [17, 18)) (push) Waiting to run
windows port / build-vs (Debug, x64, windows-latest, dev, 2017, [15, 16)) (push) Waiting to run
windows port / build-vs (Debug, x86, windows-2022, dev, 2022, [17, 18)) (push) Waiting to run
windows port / build-vs (Debug, x86, windows-latest, dev, 2017, [15, 16)) (push) Waiting to run
windows port / build-vs (Release, x64, windows-2019, dev, 2019, [16, 17)) (push) Waiting to run
windows port / build-vs (Release, x64, windows-2019, standard, 2019, [16, 17)) (push) Waiting to run
windows port / build-vs (Release, x64, windows-2022, dev, 2022, [17, 18)) (push) Waiting to run
windows port / build-vs (Release, x64, windows-2022, standard, 2022, [17, 18)) (push) Waiting to run
windows port / build-vs (Release, x64, windows-latest, dev, 2017, [15, 16)) (push) Waiting to run
windows port / build-vs (Release, x64, windows-latest, standard, 2017, [15, 16)) (push) Waiting to run
windows port / build-vs (Release, x86, windows-2019, dev, 2019, [16, 17)) (push) Waiting to run
windows port / build-vs (Release, x86, windows-2019, standard, 2019, [16, 17)) (push) Waiting to run
windows port / build-vs (Release, x86, windows-2022, dev, 2022, [17, 18)) (push) Waiting to run
windows port / build-vs (Release, x86, windows-2022, standard, 2022, [17, 18)) (push) Waiting to run
windows port / build-vs (Release, x86, windows-latest, dev, 2017, [15, 16)) (push) Waiting to run
windows port / build-vs (Release, x86, windows-latest, standard, 2017, [15, 16)) (push) Waiting to run
windows port / build-mingw (i686, mingw32, dev) (push) Waiting to run
windows port / build-mingw (i686, mingw32, standard) (push) Waiting to run
windows port / build-mingw (x86_64, mingw64, dev) (push) Waiting to run
windows port / build-mingw (x86_64, mingw64, standard) (push) Waiting to run
windows port / cross-build-on-linux (push) Waiting to run
zephyr port / build (push) Waiting to run
Python code lint and formatting with ruff / ruff (push) Waiting to run
Use `self` (the first argument) instead of the global `samd_flash_obj` when
accessing the `flash_base` parameter.  This allows there to be multiple
flash objects for various types of filesystem.

Signed-off-by: robert-hh <robert@hammelrath.com>
2024-11-18 23:54:42 +11:00
robert-hh
4a159d16fe samd/boards/SAMD21_XPLAINED_PRO: Use the SPI flash for the file system.
The initial settings did not support it.  The change required to add a
dedicated handling of the Adesto 1MByte flash of the XPLAINED PRO board,
which does not support the sfdp feature.

Fixes the ID check of the Adesto/Renesas 1MByte flash.

Signed-off-by: robert-hh <robert@hammelrath.com>
2024-11-18 23:51:02 +11:00
robert-hh
85de67f55d samd/mboot: Provide a UF2 bootloader for SAMD21 Xplained Pro.
A bootloader labelled for the SAMD21 XPLAINED PRO board.  The only
difference to a generic bootloader are the names and ID of the USB port and
the label of the drive that is opened.

Signed-off-by: robert-hh <robert@hammelrath.com>
2024-11-18 23:50:20 +11:00
robert-hh
4d36ecf8a8 samd/boards/SAMD21_XPLAINED_PRO: Add specific deploy instructions.
Add instructions to install a bootloader to the board.  The SAMD21 XPLAINED
PRO board is shipped without a bootloader, which therefore has to be
installed once before it can be used with MicroPython.

Signed-off-by: robert-hh <robert@hammelrath.com>
2024-11-18 23:49:39 +11:00
robert-hh
5a70850b30 samd/machine_uart: Add full support for 9-bit data.
Prior to this commit, 9-bit UART data could be specified in the constructor
and was transmitted, but the 9th bit was set to 0 when sending, and ignored
when receiving.  This commit completes 9-bit support in that the 9th bit is
taken from the data.

9-bit data has to be provided with `uart.write()` and and read with
`uart.read()` as two bytes for each transmitted item, low order byte first.
The data length supplied with `uart.write()` and requested by `uart.read()`
has to be even, which is checked.  The size of the UART buffers will be
transparently doubled to cater for 9-bit data.

Signed-off-by: robert-hh <robert@hammelrath.com>
2024-11-18 23:05:46 +11:00
robert-hh
898407defb ports: Make PWM duty_u16 have an upper value of 65535 across all ports.
The following ports used 65536 as the upper value (100% duty cycle) and are
changed in this commit to use 65535: esp8266, mimxrt, nrf, samd.

Tested that output is high at `duty_u16(65535)` and low at `duty_u16(0)`.
Also verified that at `duty_u16(32768)` the high and low pulse have the
same length.

Partially reverts #10850, commits 9c7ad68165
and 2ac643c15b.

Signed-off-by: robert-hh <robert@hammelrath.com>
2024-11-18 16:05:56 +11:00
Damien George
d50e36e7e4 ports: Include py/mphal.h instead of mphalport.h.
The `mphalport.h` header should not be included directly, rather
`py/mphal.h` should be used.

Signed-off-by: Damien George <damien@micropython.org>
2024-10-09 14:39:34 +11:00
Andrew Leech
548f88d2bd shared/tinyusb: Wake main task if needed at end of USB ISR.
Some checks are pending
unix port / settrace (push) Waiting to run
unix port / settrace_stackless (push) Waiting to run
unix port / macos (push) Waiting to run
unix port / qemu_mips (push) Waiting to run
unix port / qemu_arm (push) Waiting to run
unix port / qemu_riscv64 (push) Waiting to run
webassembly port / build (push) Waiting to run
windows port / build-vs (Debug, x64, windows-2022, dev, 2022, [17, 18)) (push) Waiting to run
windows port / build-vs (Debug, x64, windows-latest, dev, 2017, [15, 16)) (push) Waiting to run
windows port / build-vs (Debug, x86, windows-2022, dev, 2022, [17, 18)) (push) Waiting to run
windows port / build-vs (Debug, x86, windows-latest, dev, 2017, [15, 16)) (push) Waiting to run
windows port / build-vs (Release, x64, windows-2019, dev, 2019, [16, 17)) (push) Waiting to run
windows port / build-vs (Release, x64, windows-2019, standard, 2019, [16, 17)) (push) Waiting to run
windows port / build-vs (Release, x64, windows-2022, dev, 2022, [17, 18)) (push) Waiting to run
windows port / build-vs (Release, x64, windows-2022, standard, 2022, [17, 18)) (push) Waiting to run
windows port / build-vs (Release, x64, windows-latest, dev, 2017, [15, 16)) (push) Waiting to run
windows port / build-vs (Release, x64, windows-latest, standard, 2017, [15, 16)) (push) Waiting to run
windows port / build-vs (Release, x86, windows-2019, dev, 2019, [16, 17)) (push) Waiting to run
windows port / build-vs (Release, x86, windows-2019, standard, 2019, [16, 17)) (push) Waiting to run
windows port / build-vs (Release, x86, windows-2022, dev, 2022, [17, 18)) (push) Waiting to run
windows port / build-vs (Release, x86, windows-2022, standard, 2022, [17, 18)) (push) Waiting to run
windows port / build-vs (Release, x86, windows-latest, dev, 2017, [15, 16)) (push) Waiting to run
windows port / build-vs (Release, x86, windows-latest, standard, 2017, [15, 16)) (push) Waiting to run
windows port / build-mingw (i686, mingw32, dev) (push) Waiting to run
windows port / build-mingw (i686, mingw32, standard) (push) Waiting to run
windows port / build-mingw (x86_64, mingw64, dev) (push) Waiting to run
windows port / build-mingw (x86_64, mingw64, standard) (push) Waiting to run
windows port / cross-build-on-linux (push) Waiting to run
zephyr port / build (push) Waiting to run
Python code lint and formatting with ruff / ruff (push) Waiting to run
Signed-off-by: Andrew Leech <andrew@alelec.net>
2024-10-07 11:06:57 +11:00
Alexandre Iooss
aefd48b801 samd/Makefile: Specify UF2 family in firmware.uf2.
Set the UF2 firmware images family to Microchip SAMD21 or SAMD51.  This
helps tools such as file to identify built firmware.

Signed-off-by: Alexandre Iooss <erdnaxe@crans.org>
2024-09-06 20:36:06 +10:00
robert-hh
1a6279ba37 samd/mphalport: Simplify mp_hal_delay_ms().
Do NOT use `mp_hal_delay_us()` for short delays.  This was initially done
to make short delays precise, but it does not allow for scheduling.  Leave
using `mp_hal_delay_us()` to user code if needed.

Signed-off-by: robert-hh <robert@hammelrath.com>
2024-09-06 17:43:49 +10:00
robert-hh
ed86fdbdf6 samd/mphalport: Fix an execution order bug in mp_hal_ticks_us_64().
The upper 32 bit of the 64 bit ticks register was taken before disabling
the interrupts.  That may have caused a wrong return values.  Besides that,
the function may cause trouble when called in an IRQ context, because it
unconditionally enables IRQ.

Signed-off-by: robert-hh <robert@hammelrath.com>
2024-09-06 17:16:44 +10:00
robert-hh
ef69d0f2d3 samd/machine_uart: Implement UART.IRQ_RXIDLE based on the softtimer.
With the softtimer the minimal delay between the end of a message and the
trigger is 2 ms.  For baud rates <= 9600 baud it's three character times.
Tested with baud rates up tp 115200 baud.  The timer used for RXIDLE is
running only during UART receive, saving execution cycles when the timer is
not needed.

The irq.flags() value is changed only with an expected event.  Do not
change it otherwise.

Signed-off-by: robert-hh <robert@hammelrath.com>
2024-08-29 16:27:43 +10:00
robert-hh
8e1123b25b samd/machine_uart: Implement a Python UART IRQ handler.
Supported for all SAMD51 devices and SAMD21 with external flash.  For
interrupt events, IRQ_RX and IRQ_TXIDLE are provided.

IRQ_RX is called for every received byte.  This may not be useful for high
data rates, but can be used to build a wrapper class providing an
IRQ_RXIDLE event or to signal just the first byte of a message.

IRQ_TXIDLE is called only when messages are longer than 5 bytes and
triggers when still 5 bytes are due to be sent.

The SAMD hardware does not support implementing IRQ_RXIDLE.

Signed-off-by: robert-hh <robert@hammelrath.com>
2024-08-29 16:27:43 +10:00
Rick Sorensen
260568e081 samd/mcu/samd21: Allow user to enable additional options.
Currently for samd21 some features are disable because of limited memory.
With the ability to trade firmware and filesystem space, a user may wish to
selectively enable some of these features.  This change allows them to be
enabled in board `mpconfigboard.h` or on the build command line for
example.  The selectively enable functions are: MICROPY_PY_FRAMEBUF,
MICROPY_PY_SELECT, MICROPY_PY_ONEWIRE and MICROPY_PY_ASYNCIO.

Signed-off-by: Rick Sorensen <rick.sorensen@gmail.com>
2024-08-26 12:32:37 +10:00
Matt Trentini
ad38299779 samd/boards/ADAFRUIT_METRO_M4_EXPRESS: Remove wlan variant.
There is no such variant.

Signed-off-by: Matt Trentini <matt.trentini@gmail.com>
2024-08-20 12:48:46 +10:00
Andrew Leech
c11efc74ee samd/mphalport: Refactor to use shared TinyUSB CDC functions.
Signed-off-by: Andrew Leech <andrew@alelec.net>
2024-05-31 19:47:55 +10:00
Andrew Leech
c98789a6d8 shared/tinyusb: Add common CDC TX/RX functions.
There are a few TinyUSB CDC functions used for stdio that are currently
replicated across a number of ports.  Not surprisingly in a couple of cases
these have started to diverge slightly, with additional features added to
one of them.

This commit consolidates a couple of key shared functions used directly by
TinyUSB based ports, and makes those functions available to all.

Signed-off-by: Andrew Leech <andrew@alelec.net>
2024-05-31 19:45:42 +10:00
Damien George
b829450359 samd/mcu: Guard static function with appropriate #if.
Signed-off-by: Damien George <damien@micropython.org>
2024-03-29 17:48:06 +11:00
robert-hh
d9b9e88899 samd/samd_qspiflash: Avoid reading status byte 2 when not available.
Change provided by @ironss-iotec.

Tested with Adafruit, SEEED and MiniFig boards for non-interference.

Fixes issue #14190.

Signed-off-by: robert-hh <robert@hammelrath.com>
2024-03-28 15:52:40 +11:00
robert-hh
3980b36173 samd/samd_spiflash: Allow configuring the flash SPI baudrate.
Using a define for MICROPY_HW_SPIFLASH_BAUDRATE in mpconfigboard.h.  If not
defined the default is 24MHz.

Signed-off-by: robert-hh <robert@hammelrath.com>
2024-03-28 15:52:28 +11:00