This callback argument was previously mis-labelled as a boolean,
but it's actually the tusb_xfer_result_t values from TinyUSB.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
This commit updates the documentation bits for pull-up/pull-down
constants, part of the `machine.Pin` class.
The documentation now mentions port-specific entries into a separate
section, making the only three standard pull-up/pull-down values being
`Pin.PULL_UP`, `Pin.PULL_DOWN`, and `None`.
Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
Add an Attributes section to the machine.Pin reference describing the
Pin.board and Pin.cpu class attributes, their purpose, availability
across ports, and their role in string-based pin name resolution.
Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
This commit updates the listed limitations of the native emitter in the
documentation related to how to increase speed of python code.
Context managers are supported, as in functions marked as native can use
the `with` statement in regular code. Generators can be used in native
functions both on the emitting (ie. `yield <whatever>`) and on the
receiving end.
Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
API is different to the original machine.CAN proposal, as numerous
shortcomings were found during initial implementation.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
Simplifies the pattern of an optional arg which can be a list of at
least a certain length, otherwise one is lazily initialised.
Modify pyb.CAN and ESP-NOW APIs to use the helper. Note this changes
the return type of pyb.CAN.recv() from tuple to list.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
This commit updates the documentation for the `re` library, officially
documenting non-capturing grouping rules (ie. "(?:...)").
The documentation mistakenly marked that feature as not supported, but
is is indeed supported in the current iteration of the regex library.
This closes#18900.
Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
This documents all of the available functionality in the new
`string.templatelib` module, which is associated with template strings.
Signed-off-by: Koudai Aono <koxudaxi@gmail.com>
Signed-off-by: Damien George <damien@micropython.org>
This adds MIMXRT-specific arguments and methods, as a superset of the
original Encoder/Counter documentation.
The mimxrt pinout and quickref docs are updated with relevant information.
Signed-off-by: robert-hh <robert@hammelrath.com>
The aim of this commit is to clarify the command line options available.
While they are available as well as in the CLI with --help, it's useful to
document them and provide a few examples.
Signed-off-by: Jos Verlinde <jos_verlinde@hotmail.com>
This argument isn't expected to be passed from Python code, but - as
pointed out - it doesn't make sense how the irq() mechanism works
otherwise.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
This adds docs for the `mimxrt` module and the `mimxrt.Flash` class, the
implementation for which was first added in
dfd4324eb1
The docs are simple, following the conventions used for similar classes in
the rp2 and stm32 ports.
Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
This adds support for the ALT11 alternate function mode on MIMXRT1176
MCUs, enabling FLEXPWM channels on GPIO_AD pins that were previously
unavailable for PWM use.
Changes:
- Add PIN_AF_MODE_ALT11 enum to pin.h
- Add ALT11 column to MIMXRT1176_af.csv with FLEXPWM mappings
- Enables FLEXPWM1-4 on GPIO_AD_06 through GPIO_AD_21
This change only affects MIMXRT1176-based boards (MIMXRT1170_EVK and
PHYBOARD_RT1170). Other MIMXRT family chips use alternate function
modes ALT0-ALT9 and are not affected.
Tested on MIMXRT1176 hardware with PWM output on GPIO_AD_14
(FLEXPWM3_PWM0_X).
Signed-off-by: Algy Tynan <algy@tynan.io>
This allows tests like `asyncio_event_queue.py` to succeed under the native
emitter when poll is enabled.
Signed-off-by: Jeff Epler <jepler@unpythonic.net>
SPIRAM usually uses GPIO 9 and 10 on ESP32, so don't use them as default
UART pins.
Fixes issue #18544.
Signed-off-by: Damien George <damien@micropython.org>
This commit lets "tools/mpy_ld.py" store architecture flags in generated
MPY files if explicitly requested, like "mpy-cross" does.
To achieve this, a new command-line option ("--arch-flags") was added to
receive the architecture flags value, accepting the same arguments'
format as "mpy-cross", and performing the same input validation.
The rest of the MPY toolchain was also modified to let the user pass the
arch flags to standard native module makefiles. Given that there's
already a well-established "ARCH" argument, "ARCH_FLAGS" was chosen to
pass the optional flags to "mpy_ld.py".
Finally, documentation was updated to mention the new variable.
Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
This commit adds the ability to compile native modules for the RV64
platform, using "rv64imc" as its architecture name (eg.
"make ARCH=rv64imc" should build a RV64 natmod).
The rest of 64-bits relocations needed to build a native module are now
implemented, and all sample native modules build without errors or
warnings. The same Picolibc caveats on RV32 also apply on RV64, thus
the documentation was updated accordingly.
RV64 native modules are also built as part of the CI process, but not
yet executed as the QEMU port is not yet able to load and run them.
Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
As noted in discussion on PR #18263, the id parameter is optional on ports
that support virtual timers.
Add some more general explanation of hardware vs virtual timers, and remove
redundant documentation about timer callbacks in favour of the isr_rules
page.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
There were a few typos in the documentation for the `I2CTarget.irq` method
description where `IRQ_ADDR_MATCH_READ` was used, however
`IRQ_ADDR_MATCH_WRITE` should have been used.
Fixes issue #18470.
Signed-off-by: Alex Tran <alex.t.tran@gmail.com>
This commit adds custom command completion functions for both the zsh
and fish shell.
The behaviour for those new completions follow the existing completion
for the bash shell, including the way to generate the completion alias
(with appropriately named command line switches).
Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
Changes are:
- Add constants for some of the supported ESP-NOW data rates.
- Add constants for switching an ESP32 WLAN radio in/out of
Long Range mode.
- Document the new constants and their usage.
This work was funded through GitHub Sponsors.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
The currently documentation for ilistdir tuples says that the size element
is included based on the platform. However, this is not the case as it is
included based on the filesystem type. This commit makes the according
adjustment.
Fixes issue #17516.
Signed-off-by: Alex Tran <alex.t.tran@gmail.com>
The documentation used integers to specify Teensy board pins, which match
the board's silkscreen. But in Python code Dxx have to be used, since
integers are not accepted as a Pin identifier.
This commit changes the Pinout tables accordingly, consistent with the
other MIMXRT boards.
Signed-off-by: robert-hh <robert@hammelrath.com>
The current `esp32.RMT` class uses a legacy API from ESP-IDF 4.x. The
ESP-IDF 5.x offers a new API, which is overall better, and easier to
implement the RX side in the future. This commit updates the module and
the documentation, preserving the current MicroPython RMT API as much as
possible.
The bitstream RMT implementation was updated as well, since ESP-IDF does
not allow firmware to reference legacy and new APIs at the same time (it
resets right after boot with an error message, even if neither module is
imported).
The documentation is updated accordingly.
Signed-off-by: Elvis Pfutzenreuter <elvis.pfutzenreuter@gmail.com>
Some boards support waking up via GPIO pins, but this is not currently
supported by MicroPython. This commit adds support for waking with GPIO in
a similar interface to waking with ext0, ext1, touch and ulp. This commit
adds documentation for this new function as well.
Signed-off-by: Meir Armon <meirarmon@gmail.com>
This commit adds the currently supported architecture flags value as the
upper part of "sys.implementation._mpy".
This had the side effect of perturbing quite a bit of testing
infrastructure and invalidating documentation related to MPY files. To
make the test suite run successfully and keep the documentation in sync
the following changes have been made:
* The target info feature check file now isolates eventual architecture
flags and adds them as a separate field
* The test runner now picks up the new architecture flags field, reports
it to STDOUT if needed and stores it for future uses
* Relevant test files for MPY files import code had to be updated to
mask out the architecture flags bits in order to perform correctly
* MPY file format documentation was updated to show how to mask off and
properly display the architecture flags information.
This works out of the box if the flag bits can fit in a smallint value
once merged with the MPY file header value.
Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
This commit introduces the MPY architecture flags checking code specific
for the RV32 target, currently checking for the only additional
extension that is supported by the runtime: Zba.
The warnings inside "mpy-cross" have also been removed since now there
is a way to reject incompatible MPY files at runtime.
Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
This commit extends the MPY file format in a backwards-compatible way to
store an encoded form of architecture-specific flags that have been
specified in the "mpy-cross" command line, or that have been explicitly
set as part of a native emitter configuration.
The file format changes are as follows:
* The features byte, previously containing the target native
architecture and the minor file format version, now claims bit 6 as a
flag indicating the presence of an encoded architecture flags integer
* If architecture flags need to be stored, they are placed right after
the MPY file header.
This means that properly-written MPY parsers, if encountering a MPY file
containing encoded architecture flags, should raise an error since no
architecture identifiers have been defined that make use of bits 6 and
7 in the referenced header byte. This should give enough guarantees of
backwards compatibility when this feature is used (improper parsers were
subjected to breakage anyway).
The encoded architecture flags could have been placed at the end, but:
* Having them right after the header makes the architecture
compatibility checks occur before having read the whole file in memory
(which still happens on certain platforms as the reader may be backed
by a memory buffer), and prevents eventual memory allocations that do
not take place if the module is rejected early
* Properly-written MPY file parsers should have checked the upper two
bits of the flags byte to be actually zero according to the format
specification available right before this change, so no assumptions
should have been made on the exact order of the chunks for an
unexpected format.
The meaning of the architecture flags value is backend-specific, with
the only common characteristic of being a variable-encoded unsigned
integer for the time being.
The changes made to the file format effectively limit the number of
possible target architectures to 16, of which 13 are already claimed.
There aren't that many new architectures planned to be supported for the
lifetime of the current MPY file format, so this change still leaves
space for architecture updates if needed.
Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
Assuming proper C99 language support, we can select "the int type as big as
a pointer" (most of the time) or "the 64-bit int type" (nanboxing with
REPR_D), and then define everything else automatically.
This simplifies port configuration files. And the types can still be
overridden if needed.
Signed-off-by: Jeff Epler <jepler@unpythonic.net>
MicroPython has quite a few ports now (20 of them), but not all are in the
same stage of development. This commit attempts to define port Tier levels
and assign a Tier to each of the existing ports.
The main aim here is to set expectations for the level of support and
development each port gets. And also lower the bar of entry for new ports
so they can enter at a low Tier and gradually rise up to Tier 1.
See prior art here:
- https://peps.python.org/pep-0011/
- https://doc.rust-lang.org/rustc/target-tier-policy.html
- https://docs.zephyrproject.org/latest/project/release_process.html#hardware-support-tiers
Signed-off-by: Damien George <damien@micropython.org>
Signed-off-by: Angus Gratton <angus@redyak.com.au>
Existing C code in `main.c` only mounts a flash filesystem if one exists,
and doesn't do anything if the 'storage' partition is not formatted.
This commit moves the mounting logic from `main.c` to frozen code using
`modules/_boot.py` and adds the formatting of a previously unformatted
partition if the mount fails.
Every available disk (in the newly added `DiskAccess.disks` tuple) will be
mounted on separate mount points (if they're formatted), and the 'storage'
flash partition (if any) will be mounted on /flash (and will be formatted
as LFS2 if necessary).
Also, `sys.path` will be updated with appropriate 'lib' subdirectories for
each mounted filesystem.
The current working directory will be changed to the last `DiskAccess.disk`
mounted, or to /flash if no disks were mounted.
Then `boot.py` and `main.py` will be executed from the current working
directory if they exist.
Thanks to @VynDragon for the logic in `zephyr/zephyr_storage.c`.
Signed-off-by: Ned Konz <ned@metamagix.tech>
This commit adds `Sensor.attr_set()` and `Sensor.attr_get_*()` methods that
are necessary to set various sensor attributes if they haven't been set
statically in the device tree.
This is needed, for example, because the LSM6DS3TR-C sensor on the XIAO BLE
NRF52840 SENSE board will not work with `zsensor` because it doesn't have
any default configuration for sampling frequency.
Various `SENSOR_ATTR_*` constants from
`zephyr/incude/zephyr/drivers/sensor.h` have been added as `ATTR_*`
constants in the `zsensor` module.
Signed-off-by: Ned Konz <ned@metamagix.tech>
This commit adds support for ADC peripherals in the Zephyr port.
As is typical for Zephyr, the ADC channel setup is done in the devicetree
(typically using an overlay). This code requires ADC channels to be listed
in the io-channels property of the zephyr,user root node.
Signed-off-by: Ned Konz <ned@metamagix.tech>