Wykres commitów

14705 Commity (7c645b52e315fa3d63bb95bb42ccf2a9c15fe21d)

Autor SHA1 Wiadomość Data
Damien George 7c645b52e3 CODECONVENTIONS: Require that commits be signed-off by the author.
And use "must" instead of "should" where appropriate in related text.

Signed-off-by: Damien George <damien@micropython.org>
2023-05-08 12:20:56 +10:00
Damien George a31e3de400 extmod/network_cyw43: Add power management constants.
And allow querying the current power management mode.

Signed-off-by: Damien George <damien@micropython.org>
2023-05-08 11:56:31 +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
robert-hh 786013d467 docs/samd: Make use of pin names more consistent in examples.
This keeps up with the changed Pin naming scheme.
2023-05-04 13:19:19 +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 dc8f9d22ca docs: Update the PWM examples based on recent API improvements.
This adds the freq and duty_u16 keyword settings to the constructor, and
sometimes other details in the PWM section.

For mimxrt a clarification regarding the PWM invert argument was added, and
for rp2 a few words were spent on PWM output pairs of a channel/slice.
2023-05-04 13:15: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
Damien George 0264465585 tools/pyboard.py: Import serial.tools.list_ports.
This import is needed by newer versions of pyserial.

Signed-off-by: Damien George <damien@micropython.org>
2023-05-04 12:12:29 +10:00
Damien George f1c6cb7725 py/stackctrl: Add gcc pragmas to ignore dangling-pointer warning.
This warning became apparent in gcc 13.

Signed-off-by: Damien George <damien@micropython.org>
2023-05-04 10:08:12 +10:00
Carlosgg 61b8e1b2d8 lib/mbedtls: Update to mbedtls v2.28.3.
This is the latest release in the 2.28 long-time support branch.

Signed-off-by: Carlos Gil <carlosgilglez@gmail.com>
2023-05-03 17:33:38 +10:00
Damien George 1b980c9dbe py/compile: Remove over-eager optimisation of tuples as if condition.
When a tuple is the condition of an if statement, it's only possible to
optimise that tuple away when it is a constant tuple (ie all its elements
are constants), because if it's not constant then the elements must be
evaluated in case they have side effects (even though the resulting tuple
will always be "true").

The code before this change handled the empty tuple OK (because it doesn't
need to be evaluated), but it discarded non-empty tuples without evaluating
them, which is incorrect behaviour (as show by the updated test).

This optimisation is anyway rarely applied because it's not common Python
coding practice to write things like `if (): ...` and `if (1, 2): ...`, so
removing this optimisation completely won't affect much code, if any.

Furthermore, when MICROPY_COMP_CONST_TUPLE is enabled, constant tuples are
already optimised by the parser, so expression with constant tuples like
`if (): ...` and `if (1, 2): ...` will continue to be optimised properly
(and so when this option is enabled the code that's deleted in this commit
is actually unreachable when the if condition is a constant tuple).

Signed-off-by: Damien George <damien@micropython.org>
2023-05-03 13:21:18 +10:00
Damien George 957bd51184 py/parse: Fix build when COMP_CONST_FOLDING=0 and COMP_MODULE_CONST=1.
Signed-off-by: Damien George <damien@micropython.org>
2023-05-03 13:12:54 +10:00
Christian Clauss 78a1aa1711 github/workflows: Add GitHub Action to lint Python code with ruff.
Signed-off-by: Damien George <damien@micropython.org>
2023-05-02 23:52:11 +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
Christian Clauss cda292935d tools/mpremote: Remove unused import of serial. 2023-05-02 11:22:37 +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
glenn20 9d735d1be7 py/ringbuf: Implement put_bytes/get_bytes functions. 2023-05-01 16:47:03 +10:00
algonell a39e2827b7 docs/reference: Remove double 'are' in glossary. 2023-05-01 11:50:53 +10:00
Damien George 4ff148de45 lib/mbedtls_errors: Update patch and error list for new mbedtls.
Running `./do-mp.sh` now generates this mp_mbedtls_errors.c with mbedTLS
v2.28.1.

Signed-off-by: Damien George <damien@micropython.org>
2023-05-01 10:54:02 +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
Carlosgg 7e0a38f7f7 lib/mbedtls: Update to mbedtls v2.28.1.
Signed-off-by: Carlos Gil <carlosgilglez@gmail.com>
2023-04-30 18:07:57 +10:00
Damien George c2bf91219c lib/mbedtls_errors: Update error list for current version of mbedtls.
This should have been updated as part of commit
7d73b9ff99, when mbedtls was changed to the
LTS branch v2.16.

Signed-off-by: Damien George <damien@micropython.org>
2023-04-30 17:40:29 +10:00
Damien George 867e4dd3dc top: Add Black configuration section to pyproject.toml.
For convenience, eg for IDEs.

Signed-off-by: Damien George <damien@micropython.org>
2023-04-27 18:04:41 +10:00
Damien George 7ad41bc2d8 top: Update .git-blame-ignore-revs for latest spelling fix commit.
Signed-off-by: Damien George <damien@micropython.org>
2023-04-27 18:04:39 +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 e160fe7bc6 tools/pyboard.py: Rename ProcessPtyToTerminal member "ser" to "serial".
So that this file doesn't need to be excluded from codespell.

Signed-off-by: Damien George <damien@micropython.org>
2023-04-27 18:03:06 +10:00
Damien George e131b53fdf github/workflows: Add spell check to code formatting workflow.
Signed-off-by: Damien George <damien@micropython.org>
2023-04-27 18:03:06 +10:00
Damien George d77c35f110 tools/ci.sh: Add functions to check code spelling using codespell.
Signed-off-by: Damien George <damien@micropython.org>

tools/ci.sh: Explicitly specify pyproject.toml.

Signed-off-by: Damien George <damien@micropython.org>

tools/ci.sh: Import tomli.

Signed-off-by: Damien George <damien@micropython.org>
2023-04-27 16:01:14 +10:00
Damien George 07a719a315 tools/ci.sh: Build both SAMD21 and SAMD51 boards as part of samd CI.
Signed-off-by: Damien George <damien@micropython.org>
2023-04-27 15:11:52 +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