Wykres commitów

3451 Commity (ef497dc9243919c44c22b412f46143d78a6cdd3f)

Autor SHA1 Wiadomość Data
Jim Lipsey 7333c06d05 stm32/boards/ARDUINO_PORTENTA_H7: Enable FDCAN.
Add pin definitions to enable FDCAN support using the pyb.CAN() class.
2023-05-09 13:25:03 +10:00
glenn20 1093dea709 esp32,esp8266: Add support to set/get power saving mode of WLAN.
For esp32 and esp8266 this commit adds:
- a 'pm' option to WLAN.config() to set/get the wifi power saving mode; and
- PM_NONE, PM_PERFORMANCE and PM_POWERSAVE constants to the WLAN class.

This API should be general enough to use with all WLAN drivers.

Documentation is also added.
2023-05-06 13:51:00 +10:00
Damien George 38243cd8e0 extmod/machine_pwm: Remove PWM_INIT and PWM_DUTY_U16_NS config options.
All ports that enable MICROPY_PY_MACHINE_PWM now enable these two
sub-options, so remove these sub-options altogether to force consistency in
new ports that implement machine.PWM.

Signed-off-by: Damien George <damien@micropython.org>
2023-05-04 13:19:19 +10:00
robert-hh 7952694a3c rp2/machine_pwm: Add duty_x() checks and return 0 if PWM is not started.
Changes in this commit:
- Limit duty_u16() to 65535 and duty_ns() to the period duration.
- Return 0 for pwm.freq() if the frequency has not been set yet.
- Return 0 for pwm.duty_us16() and duty_ns() unless both frequency and
  duty cycle have been set.
- Initialize the pin to PWM at the very end of the constructor, to avoid
  possible glitches on the pin when setting up the PWM.
2023-05-04 13:18:58 +10:00
robert-hh 0b3b508d1d rp2/machine_pwm: Add support for inverting a PWM channel output.
Using the invert=True|False keyword option with the constructor or init().
2023-05-04 13:18:47 +10:00
robert-hh 2ac643c15b esp8266/machine_pwm: Implement duty_u16() and duty_ns() for consistency.
Also adds these keyword arguments to the constructor and init method.
2023-05-04 13:17:55 +10:00
robert-hh 84302b2854 rp2/machine_pwm: Enable keyword args in constructor and add init method.
This adds support for freq/duty_u16/duty_ns keyword arguments in the PWM
constructor, and adds the PWM.init() method.  Using init() without
arguments enables a previously deinit-ed PWM again.

Further changes in this commit:
- Do not start PWM output if only duty was set.
- Stop all PWM slices on soft-reset.
- Fix a bug when changing the freq on a channel pair with duty_ns set.
2023-05-04 13:13:05 +10:00
robert-hh 250757716a samd/machine_pwm: Add init() method to PWM and simplify the PWM code.
The PWM.init() method has been added.  Calling init() without arguments
restarts a PWM channel stopped with deinit().  Otherwise single parameters
except for "device=n" can be changed again.  The device can only be
specified once, either in the constructor or the first init() call.

Also simplify get_pwm_config() and get_adc_config(), and shrink the PWM
object.
2023-05-04 13:10:38 +10:00
robert-hh 9c7ad68165 mimxrt/machine_pwm: Start PWM only if freq and duty are set.
And also fix/improve the following:
- Simplify the duty handling a little bit.
- Allow duty_u16(65536), which sets the output high.
- Rename machine_pwm_start() to mp_machine_pwm_start(), in preparation for
  a possible start/stop method pair.
2023-05-04 13:09:39 +10:00
Christian Clauss 2a1db770ce all: Fix cases of Python variable assigned but never used.
This fixes ruff rule F841.
2023-05-02 16:36:05 +10:00
Christian Clauss 79e57473b2 all: Fix various Python coding inconsistencies found by ruff.
This fixes:
- type-comparison (E721): do not compare types, use isinstance().
- string-dot-format-missing-arguments (F524): .format call is missing
  argument(s) for placeholder(s): {message}.
- f-string-missing-placeholders (F541).
- is-literal (F632): Use != to compare constant literals.

The last one is fixed by just comparing for truthfulness of `state`.
2023-05-02 16:14:45 +10:00
Christian Clauss 8f8bd98164 all: Fix strings with backslash by using raw string literals. 2023-05-02 11:55:02 +10:00
Glenn Moloney 7fa322afb8 esp32,esp8266: Add support for the Espressif ESP-NOW protocol.
ESP-NOW is a proprietary wireless communication protocol which supports
connectionless communication between ESP32 and ESP8266 devices, using
vendor specific WiFi frames.  This commit adds support for this protocol
through a new `espnow` module.

This commit builds on original work done by @nickzoic, @shawwwn and with
contributions from @zoland.  Features include:
- Use of (extended) ring buffers in py/ringbuf.[ch] for robust IO.
- Signal strength (RSSI) monitoring.
- Core support in `_espnow` C module, extended by `espnow.py` module.
- Asyncio support via `aioespnow.py` module (separate to this commit).
- Docs provided at `docs/library/espnow.rst`.

Methods available in espnow.ESPNow class are:
- active(True/False)
- config(): set rx buffer size, read timeout and tx rate
- recv()/irecv()/recvinto() to read incoming messages from peers
- send() to send messages to peer devices
- any() to test if a message is ready to read
- irq() to set callback for received messages
- stats() returns transfer stats:
    (tx_pkts, tx_pkt_responses, tx_failures, rx_pkts, lost_rx_pkts)
- add_peer(mac, ...) registers a peer before sending messages
- get_peer(mac) returns peer info: (mac, lmk, channel, ifidx, encrypt)
- mod_peer(mac, ...) changes peer info parameters
- get_peers() returns all peer info tuples
- peers_table supports RSSI signal monitoring for received messages:
    {peer1: [rssi, time_ms], peer2: [rssi, time_ms], ...}

ESP8266 is a pared down version of the ESP32 ESPNow support due to code
size restrictions and differences in the low-level API.  See docs for
details.

Also included is a test suite in tests/multi_espnow.  This tests basic
espnow data transfer, multiple transfers, various message sizes, encrypted
messages (pmk and lmk), and asyncio support.

Initial work is from https://github.com/micropython/micropython/pull/4115.
Initial import of code is from:
https://github.com/nickzoic/micropython/tree/espnow-4115.
2023-05-01 16:47:21 +10:00
Carlosgg b5f4611969 lib/mbedtls_errors: Add esp32-specific mbedtls error file.
This allows updating mp_mbedtls_errors.c for the other mbedtls based ports
based on mbedTLS v2.28.1.  This esp32-specific file will not be required
after updating IDF support to >= v4.4.1.

Signed-off-by: Carlos Gil <carlosgilglez@gmail.com>
2023-05-01 10:50:01 +10:00
Damien George b1229efbd1 all: Fix spelling mistakes based on codespell check.
Signed-off-by: Damien George <damien@micropython.org>
2023-04-27 18:03:06 +10:00
Damien George 143b863f54 zephyr/modutime: Use extmod version of time module.
API change: time.time_ns() is added, but it just returns 0.

No API or functional change to existing time functions.

Signed-off-by: Damien George <damien@micropython.org>
2023-04-27 15:11:52 +10:00
Damien George fa8a81ae23 webassembly/modutime: Use extmod version of time module.
No API or functional change.

Signed-off-by: Damien George <damien@micropython.org>
2023-04-27 15:11:52 +10:00
Damien George 127fd170c8 unix/modutime: Use extmod version of time module.
No API or functional change.

Signed-off-by: Damien George <damien@micropython.org>
2023-04-27 15:11:52 +10:00
Damien George 996a1f911b stm32/modutime: Use extmod version of time module.
No API or functional change.

Signed-off-by: Damien George <damien@micropython.org>
2023-04-27 15:11:52 +10:00
Damien George d7cb53cb60 samd/modutime: Use extmod version of time module.
No API or functional change.

Signed-off-by: Damien George <damien@micropython.org>
2023-04-27 15:11:51 +10:00
Damien George 67e917609f rp2/modutime: Use extmod version of time module.
No API or functional change.

Signed-off-by: Damien George <damien@micropython.org>
2023-04-27 15:11:51 +10:00
Damien George 322c53bbc9 renesas-ra/modutime: Use extmod version of time module.
No API or functional change.

Signed-off-by: Damien George <damien@micropython.org>
2023-04-27 15:11:51 +10:00
Damien George a3c427898e nrf/modules/utime: Use extmod version of time module.
API additions;
- time.sleep() is added
- time.ticks_cpu() is added, but it just returns 0

No API or functional change to existing time functions.

Signed-off-by: Damien George <damien@micropython.org>
2023-04-27 15:11:51 +10:00
Damien George c234a26954 mimxrt/modutime: Use extmod version of time module.
No API or functional change.

Signed-off-by: Damien George <damien@micropython.org>
2023-04-27 15:11:51 +10:00
Damien George 4a4046d825 esp8266/modutime: Use extmod version of time module.
No API or functional change.

Signed-off-by: Damien George <damien@micropython.org>
2023-04-27 15:11:51 +10:00
Damien George 5be20b67df esp32/modutime: Use extmod version of time module.
No API or functional change.

Signed-off-by: Damien George <damien@micropython.org>
2023-04-27 15:11:51 +10:00
Damien George 8ad2da93be cc3200/mods/modutime: Use extmod version of time module.
API change: time.time_ns() is added, but it just returns 0.

No API or functional change to existing time functions.

Signed-off-by: Damien George <damien@micropython.org>
2023-04-27 15:11:51 +10:00
Damien George 9955553001 extmod/modutime: Provide a generic time module.
Based on extmod/utime_mphal.c, with:
- a globals dict added
- time.localtime wrapper added
- time.time wrapper added
- time.time_ns function added

New configuration options are added for this module:
- MICROPY_PY_UTIME (enabled at basic features level)
- MICROPY_PY_UTIME_GMTIME_LOCALTIME_MKTIME
- MICROPY_PY_UTIME_TIME_TIME_NS

Signed-off-by: Damien George <damien@micropython.org>
2023-04-27 15:09:56 +10:00
Damien George 083dc1f082 ports: Use extmod version of mktime instead of port-specific one.
Apart from slight differences in the error message, the functionality of
all ports is unchanged.

Signed-off-by: Damien George <damien@micropython.org>
2023-04-27 14:55:07 +10:00
Takeo Takahashi dc7de6ed83 renesas-ra: Change MICROPY_HW_BOARD_NAME definition to product name.
Changes in this commit:
- Change MICROPY_HW_BOARD_NAME definition to match the product name.
- Rename board folder's name to match the product name style.
- Change related files like Makefile, document descriptions, test cases, CI
  and tools.

Signed-off-by: Takeo Takahashi <takeo.takahashi.xv@renesas.com>
2023-04-27 14:12:53 +10:00
Damien George a14e79bcfb stm32/cyw43_configport: Provide cyw43_hal_pin_config_irq_falling func.
Signed-off-by: Damien George <damien@micropython.org>
2023-04-26 12:57:35 +10:00
Damien George fe4ac49d7f rp2/memmap_mp.ld: Allow a board to reserve memory for the C heap.
Since c80e7c14e6 changed the GC heap to use
all unused RAM, there is no longer any RAM available for the traditional C
heap (which is not used by default in MicroPython but may be used by C
extensions).  This commit adds a provision for a board to reserve RAM for
the C heap, by defining MICROPY_C_HEAP_SIZE.

Signed-off-by: Damien George <damien@micropython.org>
2023-04-26 12:36:21 +10:00
IcedRooibos 7ea06a3e26 esp32/esp32_rmt: Fix looping behaviour for RMT on ESP32-S3.
The previous code worked on ESP32 but not ESP32-S3.  All the IDF (v4.4.3)
examples call rmt_set_tx_loop_mode before rmt_write_items, so make that
change here.

Signed-off-by: Damien George <damien@micropython.org>
2023-04-26 12:32:13 +10:00
Jim Mussared a42a8022d8 extmod/modbluetooth: Make all HCI transports trace in the same format.
- Use HCI_TRACE macro consistently.
 - Use the same colour formatting.
 - Add a tool to convert to .pcap for Wireshark.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-04-26 11:37:20 +10:00
Jim Mussared 256f47e2f8 extmod/btstack: Fix indicate/notify queuing.
This adds a mechanism to track a pending notify/indicate operation that
is deferred due to the send buffer being full. This uses a tracked alloc
that is passed as the content arg to the callback.

This replaces the previous mechanism that did this via the global pending
op queue, shared with client read/write ops.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-04-26 11:37:20 +10:00
Jim Mussared bc9ec1cf71 extmod/modbluetooth: Merge gatts_notify/indicate implementation.
Makes gatts_notify and gatts_indicate work in the same way: by default they
send the DB value, but you can manually override the payload.

In other words, makes gatts_indicate work the same as gatts_notify.

Note: This removes support for queuing notifications and indications on
btstack when the ACL buffer is full. This functionality will be
reimplemented in a future commit.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-04-26 11:37:20 +10:00
Damien George 9e6885ad82 extmod/btstack: Switch to use hci_dump_init instead of hci_dump_open.
The latter is no longer available in the version of BTstack now in use by
this repository.

Signed-off-by: Damien George <damien@micropython.org>
2023-04-22 00:39:31 +10:00
David (Pololu) bf3eb9dc39 rp2/machine_i2c: Add timeout parameter for machine.I2C().
This commit adds support for the `timeout` keyword argument to machine.I2C
on the rp2 port, following how it's done on other ports.

The main motivation here is avoid the interpreter crashing due to infinite
loops when SDA is stuck low, which is quite common if the board gets reset
while reading from an I2C device.

A default timeout of 50ms is chosen because it's consistent with:
- Commit a707fe50b0 which used a timeout of
  50,000us for zero-length writes on the rp2 port.
- The machine.SoftI2C class which uses 50,000us as the default timeout.
- The stm32 port's hardware I2C, which uses 50,000us for
  I2C_POLL_DEFAULT_TIMEOUT_US.

This commit also fixes the default timeout on the esp32 port to be
consistent with the above, and updates the documentation for machine.I2C to
document this keyword argument.
2023-04-21 18:03:33 +10:00
iabdalkader 0acc73344a mimxrt: Fix the build for boards without ROM API. 2023-04-12 17:01:25 +02:00
iabdalkader bde222ce84 mimxrt/modmachine: Implement machine.bootloader().
If a board defines a custom bootloader entry function it will be called
first, if not and the ROM API supports RUN bootloader API, then
`machine.bootloader()` will jump to the ROM serial downloader in USB mode.
2023-04-11 17:40:18 +10:00
iabdalkader 8b72721b29 mimxrt/mpconfigport: Allow configuring different network interfaces.
This commit allows boards to disable Ethernet and keep the networking stack
enabled, to use an alternate networking interface, such as WiFi.

Note that the `network` and `socket` modules are now enabled by default for
a board.
2023-04-11 17:20:29 +10:00
iabdalkader 944b4c2058 mimxrt/boards/MIMXRT1064_EVK: Fix board config to use internal flash.
This commit is necessary to make MicroPython work on this eval kit out of
the box, as the eval kit ships with the HyperFlash physically disconnected
from the bus (refer to the schematics or the user guide) and the QSPI
connected instead, but the fuses/board/pins are configured to boot from
internal flash (on FlexSPI2).

Note that enabling the HyperFlash is not trivial, as it requires soldering
and desoldering of many small footprint resistors and changing fuses.
2023-04-11 17:04:21 +10:00
iabdalkader ed5e3598f1 mimxrt/Makefile: Fix internal flash configuration and build. 2023-04-11 17:03:28 +10:00
David Grayson c046b23ea2 shared/runtime/pyexec: Don't allow Ctrl+C to interrupt frozen boot code.
Helps prevent the filesystem from getting formatted by mistake, among other
things.  For example, on a Pico board, entering Ctrl+D and Ctrl+C fast many
times will eventually wipe the filesystem (without warning or notice).

Further rationale: Ctrl+C is used a lot by automation scripts (eg mpremote)
and UI's (eg Mu, Thonny) to get the board into a known state.  If the board
is not responding for a short time then it's not possible to know if it's
just a slow start up (eg in _boot.py), or an infinite loop in the main
application.  The former should not be interrupted, but the latter should.
The only way to distinguish these two cases would be to wait "long enough",
and if there's nothing on the serial after "long enough" then assume it's
running the application and Ctrl+C should break out of it.  But defining
"long enough" is impossible for all the different boards and their possible
behaviour.  The solution in this commit is to make it so that frozen
start-up code cannot be interrupted by Ctrl+C.  That code then effectively
acts like normal C start-up code, which also cannot be interrupted.

Note: on the stm32 port this was never seen as an issue because all
start-up code is in C.  But now other ports start to put more things in
_boot.py and so this problem crops up.

Signed-off-by: David Grayson <davidegrayson@gmail.com>
2023-04-05 10:38:50 +10:00
iabdalkader db4b416ea8 mimxrt/pendsv: Clean up PendSV code.
The dispatch active flag is only set once and never reset, so it will
always call the dispatch handler (once enabled), and it's not really
needed because it doesn't make things more efficient.

Also remove unused included headers.
2023-04-05 10:16:22 +10:00
robert-hh eb6e5143c4 nrf/modules/machine/uart: Prevent UART lock-up after a receive error.
Like frame error, overrun, etc.  Fix is provided by @ricksorensen.
2023-04-05 10:00:43 +10:00
robert-hh a529e0e8cf nrf/nrfx_config: Use UARTE for nrf52xxx devices.
It was incomplete.
2023-04-05 10:00:06 +10:00
robert-hh 408556504c nrf/modules/machine/pwm: Fix resource conflict, and change id to device.
Changes in this commit:
- Move the pwm_seq array to the p_config data structure.  That prevents
  potential resource collisions between PWM devices.
- Rename the keyword argument 'id' to 'device'.  That's consistent with the
  SAMD port as the other port allowing to specify it.
2023-04-05 09:58:33 +10:00
Jan Hrudka 5652f1f661 stm32/flash: Fix get_bank function for STM32H750.
STM32H750 has only 1 flash bank so function get_bank should always return
FLASH_BANK_1.
2023-04-04 14:58:54 +10:00
Damien George 783ddfc264 shared/tinyusb: Allow max USB descriptor string to be configured.
Signed-off-by: Damien George <damien@micropython.org>
2023-04-04 11:57:25 +10:00
Sebastian Romero 0a3600a9ad stm32/boards/ARDUINO_NICLA_VISION: Fix incorrect bootloader PID. 2023-03-31 17:11:14 +11:00
Damien George 38e7b842c6 ports: Implement simple write polling for stdout.
This is a best-effort implementation of write polling.  It's difficult to
do correctly because if there are multiple output streams (eg UART and USB
CDC) then some may not be writeable while others are.  A full solution
should also have a return value from mp_hal_stdout_tx_strn(), returning the
number of bytes written to the stream(s).  That's also hard to define.

The renesas-ra and stm32 ports already implement a similar best-effort
mechanism for write polling.

Fixes issue #11026.

Signed-off-by: Damien George <damien@micropython.org>
2023-03-23 13:51:17 +11:00
Damien George 31e7a0587d stm32/boards/NUCLEO_G0B1RE: Add config for USB and mboot.
But leave these disabled.

Signed-off-by: Damien George <damien@micropython.org>
2023-03-22 16:38:03 +11:00
Damien George 31638473b7 stm32/mboot: Add support for G0 MCUs.
Signed-off-by: Damien George <damien@micropython.org>
2023-03-22 16:38:03 +11:00
Damien George c7923b1139 stm32: Add support for USB on G0 MCUs.
Signed-off-by: Damien George <damien@micropython.org>
2023-03-22 16:38:03 +11:00
robert-hh b7ea90d4cb rp2/machine_uart: Fix setting of UART LCR parameters.
Prior to this change, setting of UART parameters like parity, stop bits or
data bits did not work correctly.  As suggested by @iabdalkader, adding
__DSB() fixes the problem, making sure that changes to the UART LCR_H
register are seen by the peripheral.

Note: the FIFO is already enabled in the call to uart_init(), so the call
to uart_set_fifo_enabled() is not required, but kept for visibility.

Fixes issue #10976.
2023-03-22 16:21:48 +11:00
Damien George 051e2900d9 stm32/boards/NUCLEO_H723ZG: Add new H723 board.
The following have been tested and are working:
- 550MHz CPU frequency
- UART REPL via ST-Link
- USB REPL and mass storage
- 3x LEDs and 1x user button
- Ethernet

Signed-off-by: Damien George <damien@micropython.org>
2023-03-21 14:05:59 +11:00
Damien George d995c01042 stm32/boards: Add ld and af.csv for H723.
Signed-off-by: Damien George <damien@micropython.org>
2023-03-21 14:02:49 +11:00
Damien George 13fcd8440e stm32: Add support for STM32H723 MCUs.
Signed-off-by: Damien George <damien@micropython.org>
2023-03-21 14:02:49 +11:00
Damien George 3187e4c7e7 stm32/mphalport: Update HAL version to 1.11.0 to match stm32lib.
Signed-off-by: Damien George <damien@micropython.org>
2023-03-21 14:02:49 +11:00
robert-hh 711bac511e rp2/main: Keep UART REPL with DEBUG=1 and MICROPY_HW_ENABLE_UART_REPL=1.
For builds with DEBUG=1 and MICROPY_HW_ENABLE_UART_REPL=1, calling
stdio_init_all() in main() detaches the UART input from REPL.  This change
suppresses calling stdio_init_all() then.
2023-03-20 22:33:45 +11:00
robert-hh be686e634e rp2: Allow disabling USB via MICROPY_HW_ENABLE_USBDEV config.
Previously, setting MICROPY_HW_ENABLE_USBDEV to 0 caused build errors.  The
change affects the nrf and samd ports as well, so MICROPY_HW_ENABLE_USBDEV
had to be explicitly enabled there.

The configuration options MICROPY_HW_ENABLE_USBDEV and
MICROPY_HW_ENABLE_UART_REPL are independent, and can be enabled or disabled
by a board.

Signed-off-by: Damien George <damien@micropython.org>
2023-03-20 22:33:45 +11:00
robert-hh a2b31f968d nrf/modules/machine: Support the freq=n argument for machine.I2C.
Mostly for compatibility.  Effective values are 100000, 250000 and 400000.
The supplied values are mapped to these.
2023-03-20 16:27:44 +11:00
robert-hh 3bbf2ef3fb nrf/modules/machine: Use a dedicated function for machine.idle().
Calling MICROPY_EVENT_POLL_HOOK.  That allows Ctrl-C to break loops with
idle().
2023-03-20 16:15:43 +11:00
robert-hh 2cd3a7b45c nrf/nrfx_config: Use the UARTE definitions and drivers for the NRF52xx.
Suggested by @ricksorensen after testing.  These match better the hardware
of the NRF52xx.
2023-03-20 16:12:16 +11:00
robert-hh 7ea192af05 nrf/modules/machine/uart: Add timeout keyword options and "any" method.
Changes in this commit:
- Add the timeout and timeout_char keyword options.
- Make uart.read() non-blocking.
- Add uart.any().
- Add ioctl MP_STREAM_POLL handling.
- Change uart.write() into non-busy waiting. uart.write() still waits until
  all data has been sent, but calls MICROPY_EVENT_POLL_HOOK while waiting.
  uart.write() uses DMA for transfer.  One option would be to add a small
  local buffer, such that transfers up to the size of the buffer could be
  done without waiting.
- As a side effect to the change of uart.write(), uart.txdone() and ioctl
  flush now report/wait correctly for the end of transmission.
- Change machine_hard_uart_buf_t in machine_hard_uart_obj_t to an instance
  of that struct, rather than a pointer to one.
2023-03-20 16:08:35 +11:00
Damien George 42511b5291 stm32/boards/NUCLEO_H743ZI2: Fix MCU tag in board.json file.
Signed-off-by: Damien George <damien@micropython.org>
2023-03-20 15:24:45 +11:00
iabdalkader a197823eb7 ports: Fix MCU tags in Arduino board.json files. 2023-03-20 15:22:24 +11:00
robert-hh 05bb26010e samd: Always provide the machine.RTC class.
Even if boards do not have a clock crystal.  In that case, the clock
quality will be very poor.

Always having machine.RTC means that the date/time can be set in a way that
is consistent with other ports.

This commit also removes the special code in modutime.c for devices without
the RTC class.

Signed-off-by: Damien George <damien@micropython.org>
2023-03-13 12:44:34 +11:00
pmendham d5c45a80d2 embed: Fix arguments to mp_raw_code_load_mem.
Update arguments to mp_raw_code_load_mem so that the embed port can build
when MICROPY_PERSISTENT_CODE_LOAD is enabled.
2023-03-13 12:35:12 +11:00
IhorNehrutsa 416707eefe esp32/machine_pin: Use const for size of machine_pin_irq_handler array. 2023-03-13 12:14:09 +11:00
Christian Clauss 4376c969f6 all: Fix Python comparison to None and True, and use "not in".
These are basic PEP8 recommendations.
2023-03-10 13:32:24 +11:00
Damien George b3c8ab37ec py/gc: Make gc_dump_info/gc_dump_alloc_table take a printer as argument.
So that callers can redirect the output if needed.

Signed-off-by: Damien George <damien@micropython.org>
2023-03-10 10:58:10 +11:00
Damien George f450e94ba0 ports: Rename remaining "Micro Python" to "MicroPython".
Signed-off-by: Damien George <damien@micropython.org>
2023-03-10 10:54:00 +11:00
robert-hh ed1f42cb49 nrf/modules/machine/pwm: Support using all 4 channels of a PWM module.
These have the same frequency, but can have different duty cycle and
polarity.

pwm.deinit() stops all channels of a module, but does not release the
module.  pwm.init() without arguments restarts all outputs.
2023-03-10 10:44:02 +11:00
robert-hh e3b877826c nrf/modules/machine/soft_pwm: Add PWM for nrf51x boards using soft PWM.
Using extmod/machine_pwm.c for the Python bindings and the existing
softpwm.c driver, by just adding the interface.

Properties:
- Frequency range 1-3906 Hz.
- All PWM outputs run at the same frequency but can have different duty
  cycles.
- Limited to the P0.x pins.

Since it uses the existing softpwm.c mechanism, it will be affected by
playing music with the music class.
2023-03-10 10:44:02 +11:00
robert-hh a1f838cdf1 nrf/modules/machine/pwm: Use extmod/machine_pwm.c for PWM module.
This is a breaking change, making the hardware PWM on the nrf port
compatible with the other ports providing machine.PWM.

Frequency range 4Hz - ~5.4 MHz.  The base clock range is 125kHz to 16 MHz,
and the divider range is 3 - 32767.

The hardware supports up to four outputs per PWM device with different duty
cycles, but only one output is (and was) supported.
2023-03-10 10:43:55 +11:00
robert-hh cf43df4caa nrf/modules/machine/pwm: Add paramter checks and error messages. 2023-03-10 10:30:16 +11:00
Damien George b336b6bb74 stm32/pybthread: Make pyb_thread_dump take a printer as its argument.
Signed-off-by: Damien George <damien@micropython.org>
2023-03-09 13:20:59 +11:00
Damien George 067c7cd9dc stm32/pin: Make pin_find debug output use mp_printf.
Signed-off-by: Damien George <damien@micropython.org>
2023-03-09 13:20:59 +11:00
Damien George f43c4dfc68 stm32/extint: Make ExtInt.regs print using mp_printf.
Signed-off-by: Damien George <damien@micropython.org>
2023-03-09 13:20:59 +11:00
Damien George f6a35f76af stm32/modmachine: Make machine.info print using mp_printf.
Signed-off-by: Damien George <damien@micropython.org>
2023-03-09 13:20:59 +11:00
Damien George 6c8b19c7e2 stm32/spi: Return error code and raise exception if SPI init fails.
Signed-off-by: Damien George <damien@micropython.org>
2023-03-09 12:47:45 +11:00
Damien George 98937dcfc2 stm32/i2c: Return error code and raise exception if I2C init fails.
Signed-off-by: Damien George <damien@micropython.org>
2023-03-09 12:47:45 +11:00
Damien George b981e37ccd stm32/main: Use mp_printf instead of printf for MPY start-up messages.
Signed-off-by: Damien George <damien@micropython.org>
2023-03-09 12:47:45 +11:00
Damien George b9dad0add2 stm32: Remove commented-out printf's and debugging code.
Signed-off-by: Damien George <damien@micropython.org>
2023-03-09 12:47:45 +11:00
cpottle9 c80e7c14e6 rp2: Allocate GC heap from unused RAM.
Borrowing an idea from the mimxrt port (also stm32 port): in the loader
input file memmap_mp.ld calculate __GcHeapStart and __GcHeapEnd as the
unused RAM.  Then in main.c use these addresses as arguments to gc_init().

The benefits of this change are:

1) When libraries are added or removed in the future changing BSS usage,
   main.c's sizing of the GC heap does not need to be changed.

2) Currently these changes make the GC area about 30 KBytes larger, eg on
   PICO_W the GC heap increases from 166016 to 192448 bytes.  Without that
   change this RAM would never get used.

3) If someone wants to disable one or more SRAM blocks on the RP2040 to
   reduce power consumption it will be easy: just change the MEMORY section
   in memmap_mp.ld.  For instance to not use SRAM2 and SRAM3 change it to:

        MEMORY
        {
            FLASH(rx) : ORIGIN = 0x10000000, LENGTH = 2048k
            RAM(rwx) : ORIGIN =  0x21000000, LENGTH = 128k
            SCRATCH_X(rwx) : ORIGIN = 0x20040000, LENGTH = 4k
            SCRATCH_Y(rwx) : ORIGIN = 0x20041000, LENGTH = 4k
        }

   Then to turn off clocks for SRAM2 and SRAM3 from MicroPython, set the
   appropriate bits in WAKE_EN0 and SLEEP_EN0.

Tested by running the firmware.uf2 file on PICO_W and displaying
micropython.mem_info().  Confirmed GC total size approximately matched the
size calculated by the loader.

Signed-off-by: cpottle9 <cpottle9@outlook.com>
2023-03-09 12:00:02 +11:00
David Grayson f80d040c03 rp2/modrp2: Disable other core, shorten delay to 8us in bootsel_button.
This function seems to work fine in multi-core applications now.

The delay is now in units of microseconds instead of depending on the clock
speed, and is adjustable by board configuration headers.

Also added documentation.
2023-03-09 11:44:20 +11:00
Tomofumi Inoue 673957b643 rp2/modrp2: Support reading the BOOTSEL button on the Pico board.
And any other board that exposes this pin with a button.
2023-03-09 11:43:39 +11:00
iabdalkader dc2186c35b rp2/boards/ARDUINO_NANO_RP2040_CONNECT: Include "senml" in manifest. 2023-03-09 10:38:06 +11:00
iabdalkader 8307046406 stm32/boards: Include "senml" in manifest for ARDUINO boards. 2023-03-09 10:37:06 +11:00
Damien George a234aa44f3 stm32/powerctrl: Don't compile WB helpers on WL MCUs.
Signed-off-by: Damien George <damien@micropython.org>
2023-03-08 23:57:53 +11:00
Damien George 8b3f1d47a6 stm32/powerctrlboot: Provide custom SystemInit for WB55.
Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
Signed-off-by: Damien George <damien@micropython.org>
2023-03-08 14:04:14 +11:00
Andrew Leech c551723914 stm32/powerctrl: Disable WB55 BLE before entering deepsleep.
Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
2023-03-08 14:03:36 +11:00
Andrew Leech 2eca86e8fa stm32/powerctrl: Add sleep RCC semaphore management for WB55 MCUs.
Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
2023-03-08 11:33:00 +11:00
iabdalkader 6bb60745be rp2/boards/ARDUINO_NANO_RP2040_CONNECT: Add more external pins.
Add the missing A4, A5 external (Nina-W controlled) pins.
2023-03-08 00:59:36 +11:00
iabdalkader e764bf0138 stm32/cyw43_configport: Add cyw43_sdio_enable_high_speed_4bit function.
Needed by the latest version of cyw43-driver.
2023-03-08 00:59:36 +11:00
iabdalkader 40a49f5a7a stm32/boards/ARDUINO_GIGA: Add support for Arduino Giga H7 board. 2023-03-08 00:55:51 +11:00
iabdalkader b6904cba76 stm32/boards/ARDUINO_NICLA_VISION: Add support for Arduino Nicla Vision. 2023-03-08 00:55:38 +11:00
iabdalkader 449be91e1a stm32/Makefile: Include HAL HSEM driver on H747 MCUs. 2023-03-08 00:55:01 +11:00