summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2023-10-26nrf/modules/machine: Use SPI Python bindings provided by extmod.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2023-10-26extmod/modmachine: Consolidate simple machine headers into modmachine.h.Damien George
The contents of machine_bitstream.h, machine_pinbase.h, machine_pulse.h and machine_signal.h have been moved into extmod/modmachine.h. Signed-off-by: Damien George <damien@micropython.org>
2023-10-26extmod/modmachine: Clean up decls of machine types to use common ones.Damien George
The machine_i2c_type, machine_spi_type and machine_timer_type symbols are already declared in extmod/modmachine.h and should not be declared anywhere else. Also move declarations of machine_pin_type and machine_rtc_type to the common header in extmod. Signed-off-by: Damien George <damien@micropython.org>
2023-10-26extmod/machine_uart: Factor ports' UART Python bindings to common code.Damien George
This is a code factoring to have the Python bindings in one location, and all the ports use those same bindings. For all ports except the two listed below there is no functional change. The nrf port has UART.sendbreak() removed, but this method previously did nothing. The zephyr port has the following methods added: - UART.init(): supports setting timeout and timeout_char. - UART.deinit(): does nothing, just returns None. - UART.flush(): raises OSError(EINVAL) because it's not implemented. - UART.any() and UART.txdone(): raise NotImplementedError. Signed-off-by: Damien George <damien@micropython.org>
2023-10-23extmod/machine_adc: Factor ports' ADC Python bindings to common code.Damien George
No functional change, just code factoring to have the Python bindings in one location, and all the ports use those same bindings. Signed-off-by: Damien George <damien@micropython.org>
2023-10-23nrf/boards: Automatically configure MICROPY_PY_MACHINE_PWM.Damien George
This commit makes it so that MICROPY_PY_MACHINE_PWM is enabled if at least one of MICROPY_PY_MACHINE_HW_PWM and/or MICROPY_PY_MACHINE_SOFT_PWM are enabled. This simplifies the configuration for boards, and fixes DVK_BL652 which enabled PWM without selecting software or hardware implementations. With this change, DVK_BL652 and EVK_NINA_B1 now enable (hardware) PWM. Signed-off-by: Damien George <damien@micropython.org>
2023-10-23py/makeqstrdefs.py: Print a nicer error when preprocessing stage fails.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2023-10-20extmod/machine_i2s: Factor comments, some enums and macros.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2023-10-20extmod/machine_i2s: Factor init_helper argument parsing.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2023-10-20extmod/machine_i2s: Factor print function.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2023-10-20extmod/machine_i2s: Factor I2S.irq method.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2023-10-20extmod/machine_i2s: Factor I2S.shift method.Damien George
It's exactly the same for all four port implementations. Signed-off-by: Damien George <damien@micropython.org>
2023-10-20extmod/machine_i2s: Factor stream and ring-buf code.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2023-10-20extmod/machine_i2s: Factor ports' I2S Python bindings to common code.Damien George
This factors the basic top-level I2S class code from the ports into extmod/machine_i2s.c: - I2S class definition and method table. - The init and deinit method wrappers. - The make_new code. Further factoring will follow. Signed-off-by: Damien George <damien@micropython.org>
2023-10-20extmod/machine_pwm: Remove header file and move decls to .c file.Damien George
With public declarations moved to extmod/modmachine.h. It's now mandatory for a port to define MICROPY_PY_MACHINE_PWM_INCLUDEFILE if it enables MICROPY_PY_MACHINE_PWM. This follows how extmod/machine_wdt.c works. All ports have been updated to work with this modified scheme. Signed-off-by: Damien George <damien@micropython.org>
2023-10-20extmod/machine_wdt: Factor ports' WDT Python bindings to common code.Damien George
There are currently 7 ports that implement machine.WDT and a lot of code is duplicated across these implementations. This commit factors the common parts of all these implementations to a single location in extmod/machine_wdt.c. This common code provides the top-level Python bindings (class and method wrappers), and then each port implements the back end specific to that port. With this refactor the ports remain functionally the same except for: - The esp8266 WDT constructor now takes keyword arguments, and accepts the "timeout" argument but raises an exception if it's not the default value (this port doesn't support changing the timeout). - The mimxrt and samd ports now interpret the argument to WDT.timeout_ms() as signed and if it's negative truncate it to the minimum timeout (rather than it being unsigned and a negative value truncating to the maximum timeout). Signed-off-by: Damien George <damien@micropython.org>
2023-10-20rp2/boards/ARDUINO_NANO_RP2040_CONNECT: Add external analog pins.iabdalkader
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2023-10-20rp2/machine_adc: Add support for external ADC channels.iabdalkader
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2023-10-20drivers/ninaw10: Add support for external ADC channels.iabdalkader
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2023-10-20extmod/network_ninaw10: Raise an error if nina_ioctl fails.iabdalkader
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2023-10-20drivers/ninaw10: Add ioctl for reading analog pins.iabdalkader
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2023-10-19extmod/vfs_posix: Additional tests for coverage of error cases.Christian Walther
Signed-off-by: Christian Walther <cwalther@gmx.ch>
2023-10-19extmod/vfs_posix: Fix getcwd() on non-root VFS.Christian Walther
The unwritten API contract expected of a VFS.getcwd() by mp_vfs_getcwd() is that its return value should be either "" or "/" when the CWD is at the root of the VFS and otherwise start with a slash and not end with a slash. This was not correctly implemented in VfsPosix for instances with a non-empty root - the required leading slash, if any, was cut off because the root length includes a trailing slash. This would result in missing slashes in the middle of the return value of os.getcwd() or in uninitialized garbage from beyond a string's null terminator when the CWD was at the VFS root. Signed-off-by: Christian Walther <cwalther@gmx.ch>
2023-10-19extmod/vfs_posix: Fix relative paths on non-root VFS.Christian Walther
The unwritten API contract expected of a VFS by mp_vfs_lookup_path() is that paths passed in are relative to the root of the VFS if they start with '/' and relative to the current directory of the VFS otherwise. This was not correctly implemented in VfsPosix for instances with a non-empty root - all paths were interpreted relative to the root. Fix that. Since VfsPosix tracks its CWD using the "external" CWD of the Unix process, the correct handling for relative paths is to pass them through unmodified. Also, when concatenating absolute paths, fix an off-by-one resulting in a harmless double slash (the root path already has a trailing slash). Signed-off-by: Christian Walther <cwalther@gmx.ch>
2023-10-19extmod/vfs_posix: Fix accidentally passing tests.Christian Walther
These tests test an unrealistic situation and only pass by accident due to a bug. The upcoming fix for the bug would make them fail. The unrealistic situation is that VfsPosix methods are called with relative paths while the current working directory is somewhere outside of the root of the VFS. In the intended use of VFS objects via os.mount() (as opposed to calling methods directly as the tests do), this never happens, as mp_vfs_lookup_path() directs incoming calls to the VFS that contains the CWD. Make the testing situation realistic by changing the working directory to the root of the VFS before calling methods on it, as the subsequent relative path accesses expect. Thanks to the preceding commit, the tests still pass, but still for the wrong reason. The following commit "Fix relative paths on non-root VFS" will make them pass for the correct reason. Signed-off-by: Christian Walther <cwalther@gmx.ch>
2023-10-19extmod/vfs_posix: Fix relative root path.Christian Walther
A VfsPosix created with a relative root path would get confused when chdir() was called on it and become unable to properly resolve absolute paths, because changing directories effectively shifted its root. The simplest fix for that would be to say "don't do that", but since the unit tests themselves do it, fix it by making a relative path absolute before storing it. Signed-off-by: Christian Walther <cwalther@gmx.ch>
2023-10-19esp32/boards: Update UM board image names for consistency.Seon Rozenblum
Signed-off-by: Seon Rozenblum <seon@unexpectedmaker.com>
2023-10-18py/modthread: Initialise nlr_jump_callback_top on threads.Jim Mussared
The main thread gets this because the thread state is in bss, but subsequent threads need this field to be initialised. Also added a note to mpstate.h to help avoid missing this in the future. Fixes issue #12695. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-10-17mimxrt/modmachine: Add support for machine.deepsleep.Kwabena W. Agyeman
Signed-off-by: "Kwabena W. Agyeman" <kwagyeman@live.com>
2023-10-17mimxrt/machine_rtc: Add RTC alarm/wakeup functionality.Kwabena W. Agyeman
Following the documented Python machine.RTC API. Signed-off-by: "Kwabena W. Agyeman" <kwagyeman@live.com>
2023-10-17mimxrt/boards: Define missing SNVS pins for all processors.Kwabena W. Agyeman
Signed-off-by: "Kwabena W. Agyeman" <kwagyeman@live.com>
2023-10-17github/workflows: Pin ruff to 0.1.0 and change flags for new version.Jim Mussared
The `--format` flag was changed to `--output-format` in the recent update. Pin to this version to prevent further updates from breaking (e.g. through new rules or other changes). This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-10-17stm32/powerctrl: Add support for frequency scaling with HSI on H5 MCUs.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2023-10-17stm32/boards/STM32H573I_DK: Enable ETH and DAC peripherals.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2023-10-17stm32/eth: Add Ethernet support for H5 MCUs.Rene Straub
This commit implements Ethernet support for STM32H5. Changes are: - Add Cortex-M33 MPU code. Ethernet driver requires MPU to define cache strategy for DMA buffers (descriptors and frames). - Add support for STM32H5 Ethernet controller. The controller is mostly compatible with the STM32H7. However the descriptor layout is different. - Adapt clocking and reset for STM32H5. Tested on NUCLEO-H563ZI and STM32H573I-DK, using ping and iperf3. TCP rates of 80-90 Mbits/sec were achievable. Signed-off-by: Rene Straub <rene@see5.ch> Signed-off-by: Damien George <damien@micropython.org>
2023-10-17stm32/boards/ARDUINO_GIGA: Fix name of pins in board init.iabdalkader
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2023-10-16rp2/cyw43_configport: Use m_tracked_calloc and m_tracked_free.robert-hh
When using malloc and free there were out-of-memory situations depending on the arm-none-eabi package version. This commit changes malloc/free to use the MicroPython GC heap instead. Signed-off-by: robert-hh <robert@hammelrath.com> Signed-off-by: Damien George <damien@micropython.org>
2023-10-16stm32/boards/ARDUINO_GIGA: Add QSPI fix/workaround to early init.iabdalkader
This workaround fixes an issue with some production boards that have an older QSPI flash part revision, which can't handle floating pins. Note those pins can be reconfigured and reused later. Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2023-10-16docs/library/io: Remove io.FileIO and io.TextIOWrapper.Thomas Ackermann
FileIO and TextIOWrapper were removed in e65d1e69e88268145ff0e7e73240f028885915be. Remove them also from the documentation. Signed-off-by: Thomas Ackermann <th.acker@arcor.de>
2023-10-16extmod/modframebuf: Remove FrameBuffer1 from natmod build.Jim Mussared
This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-10-16extmod/modframebuf: Fix FrameBuffer get-buffer implementation.Jim Mussared
This wasn't correctly accounting for the bits-per-pixel and was returning a bufinfo struct with the incorrect length. Instead, just forward directly to the underlying buffer object. Fixes issue #12563. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-10-16extmod/modframebuf: Validate FrameBuffer bounds against input buffer.Jim Mussared
This ensures that the buffer is large enough for the specified width, height, bits-per-pixel, and stride. Also makes the legacy FrameBuffer1 constructor re-use the FrameBuffer make_new to save some code size. Fixes issue #12562. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-10-16docs/reference/mpyfiles: Document change in .mpy sub-version.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2023-10-16py/persistentcode: Bump .mpy sub-version.Damien George
This is required because the previous commit changed the .mpy native ABI. Signed-off-by: Damien George <damien@micropython.org>
2023-10-16py/dynruntime: Add mp_get_buffer.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2023-10-16py/obj: Generalise mp_get_buffer so it can raise if a flag is set.Damien George
This allows mp_get_buffer_raise() to be changed to a simple inline function that in the majority of cases costs the same (in code size) to call as the original mp_get_buffer_raise(), because the flags argument is a constant. Signed-off-by: Damien George <damien@micropython.org>
2023-10-13py/objboundmeth: Optimise check for types in binary_op.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2023-10-13tests/basics/boundmeth1.py: Add tests for bound method equality/hash.Ned Konz
This commit adds tests for bound method comparison and hashing to support the changes in the previous commit. Signed-off-by: Ned Konz <ned@productcreationstudio.com>
2023-10-13py/objboundmeth: Support comparing and hashing bound methods.Daniël van de Giessen
This behaviour matches CPython. It's useful to be able to store bound method objects in dicts/sets, and compare for equality, eg when storing them in a list and using list.remove(). Signed-off-by: Daniël van de Giessen <daniel@dvdgiessen.nl>
2023-10-13extmod/asyncio: Emit errors to stderr, not stdout.Matthias Urlichs
Sometimes these are different file descriptors, not to mention the Unix port, so use stderr to distinguish these error messages. CPython prints to stdout, but it does it via a call to the logging module. We don't want to introduce a dependency on logging, so printing to stderr is a good alternative. One can override default_exception_handler() if needed.