Wykres commitów

1174 Commity (5e0452125146f3afed89c09f5813790156d24471)

Autor SHA1 Wiadomość Data
robert-hh 633408a4a5 docs/samd: Add the pin-out for the Adafruit Metro M4 Airlift board.
Signed-off-by: robert-hh <robert@hammelrath.com>
2023-06-01 12:38:58 +10:00
robert-hh 74dda80236 docs/mimxrt: Add the pin-out for the Adafruit Metro M7 board.
Signed-off-by: robert-hh <robert@hammelrath.com>
2023-06-01 12:38:58 +10:00
Jim Mussared 0000eb2724 docs/reference/speed_python: Remove 4-arg limit for viper.
This limit was removed in a676b5acf6.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-05-23 17:40:17 +10:00
robert-hh 20fd22edad samd/machine_uart: Add support for UART hardware flow control.
By specifying rts=pin(x) and/or cts=Pin(x) in the constructor.  The pad
numbers for the UART pins are fix in this case: TX must be at pad 0, RX at
pad 1, RTS at pad 2 and CTS at pad 3.

repr(uart) shows the pin names for rts and cts, if set.  In case of a RX
overflow, the rx interrupt will be disabled instead of just discarding the
data.  That allows RTS to act.

If RTS is inactive, still 2 bytes can be buffered in the FIFO.

Signed-off-by: robert-hh <robert@hammelrath.com>
2023-05-23 09:53:24 +10:00
Damien George 2771b20d29 tools/mpremote: Add repl option to escape non-printable characters.
This commit adds the "--escape-non-printable" option to the repl command.
When specified the REPL console will escape non-printable characters,
printing them as their hex value in square brackets.

This escaping behaviour was previously the default and only behaviour, but
it is now opt-in.

As part of this change, the speed of echoing device data to the console is
improved by by reading and writing in chunks.

Signed-off-by: Damien George <damien@micropython.org>
2023-05-22 14:13:24 +10:00
patrick 05e143dbdd esp32/esp32_ulp: Enable FSM ULP for S2 and S3 chips.
This commit enables the ULP for the S2 and S3 chips.

Note this is the FSM (Finite State Machine) ULP.

Signed-off-by: Patrick Joy <patrick@joytech.com.au>
2023-05-19 22:37:25 +10:00
marble b5c81f6bfb docs/develop/porting: Add missing code to example main.c and Makefile.
These two missing lines caused the build process to fail when implementing
the tutorial example port.

Signed-off-by: marble <git@computer-in.love>
2023-05-19 21:51:19 +10:00
glenn20 12dbbc8065 docs/library/espnow: Update espnow docs for WLAN.config(pm=x) options.
Update docs/library/espnow.rst to add:
- guidance on using WLAN.config(pm=WLAN.PM_NONE) for reliable
  espnow performance while also connected to a wifi access point;
- guidance on receiving encrypted messages;
- correction for default value of "encrypt" parameter (add_peer());
- guidance on use of ESPNow.irq(): recommand users readout all messages
  in the buffer each time the callback is called.

Signed-off-by: Glenn Moloney <glenn.moloney@gmail.com>
2023-05-19 21:48:08 +10:00
Adam Green f9958417d8 rp2: Make rp2_state_machine_exec accept integers.
Currently rp2.StateMachine.exec(instr_in) requires that the instr_in
parameter be a string representing the PIO assembly language instruction
to be encoded by rp2.asm_pio_encode(). This commit allows the parameter
to also be of integral type. This is useful if the exec() method is
being called often where the use of pre-encoded machine code is
desireable.

This commit still supports calls like:
    sm.exec("set(0, 1)")

It also now supports calls like:
    # Performed once earlier, maybe in __init__()
    assembled_instr = rp2.asm_pio_encode("out(y, 8)", 0)
    # Performed multiple times later as the PIO state machine is
    # configured for its next run.
    sm.exec(assembled_instr)

The existing examples/rp2/pio_exec.py and examples/rp2/pio_pwm.py that
exercise the rp2.StateMachine.exec() method still work with this change.

Signed-off-by: Adam Green <adamgrym@yahoo.com>
2023-05-18 12:33:02 +10:00
David Lechner 3e64d76122 docs/reference/mpyfiles: Add release info on v6.1.
This documents when MPY v6.1 was released.

Also add some clarification on how the version is encoded in the header.

Signed-off-by: David Lechner <david@pybricks.com>
2023-05-11 14:30:34 +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
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 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 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
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
algonell a39e2827b7 docs/reference: Remove double 'are' in glossary. 2023-05-01 11:50:53 +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
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 57ca8b71ee LICENSE,docs: Update copyright year range to include 2023.
Signed-off-by: Damien George <damien@micropython.org>
2023-04-26 13:33:32 +10:00
Jim Mussared a6aa7397d8 extmod/btstack: Include value handle in client read/write events.
This replaces the previous pending operation queue (that used to also be
shared with pending server notify/indicate ops) with a single pending
operation per connection. This allows the value handle to be correctly
passed to the Python-level events.

Also re-structure GATT client event handling to simplify the packet handler
functions.

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
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
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
Jim Mussared 8b277d3c34 docs/library/network: Update docs for network.country, network.hostname.
Also marks wlan.config(hostname) as deprecated.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-03-01 01:28:02 +11:00
robert-hh 76cf98c35b samd/mcu: Implement a hardware seed for the SAMD21 random module.
By using the phase jitter between the DFLL48M clock and the FDPLL96M clock.
Even if both use the same reference source, they have a different jitter.
SysTick is driven by FDPLL96M, the us counter by DFLL48M.  As a random
source, the us counter is read out on every SysTick and the value is used
to accumulate a simple multiply, add and xor register.  According to tests
it creates about 30 bit random bit-flips per second.  That mechanism will
pass quite a few RNG tests, has a suitable frequency distribution and
serves better than just the time after boot to seed the PRNG.
2023-02-21 23:15:29 +11:00
enriquezgarc 5c10727b68 docs/zephyr/quickref: Fix zsensor module usage examples.
Signed-off-by: enriquezgarc <enriquezgarcia.external@infineon.com>
2023-01-19 16:04:24 +11:00
Chris Overgaauw 23ef29706e docs/reference/constrained: Add missing heap-dump symbols to mem_info(). 2023-01-19 15:59:29 +11:00
LiaoJingyi_winY7kp 7f6345a973 docs/library/machine.Timer: Add freq argument to machine.Timer.
Based on and tested on the rp2 port.

Signed-off-by: Liao Jingyi <liaojingyi2@gmail>
Signed-off-by: Damien George <damien@micropython.org>
2023-01-19 15:47:45 +11:00
robert-hh 30bac47b12 docs/esp32/quickref: Add docs for the LAN interface constructor.
Incorporating PR #7356.
2023-01-18 10:06:53 +11:00
Dorukyum f4811b0b42 docs/library/socket: Use correct sockaddr variable name.
Signed-off-by: Dorukyum <doruk.ak@hotmail.com>
2023-01-13 17:40:01 +11:00
Paul Warren a322ebafc0 docs/library/rp2.StateMachine: Expand put() documentation.
Document that put() can also accept arrays/bytearrays as values.

Fixes issue #10465.

Signed-off-by: Paul Warren <pdw@ex-parrot.com>
2023-01-12 17:14:04 +11:00
Stig Bjørlykke 209a6bb6b7 docs/rp2: Make LED have exactly 50% duty cycle in PIO 1Hz example.
This ensures the same number of cycles are used for LED on and LED off in
the PIO 1Hz example.  It's also possible to swap the first set() and the
irq() to avoid using an extra instruction, but this tutorial is a good
example of how to calculate the cycles.

Signed-off-by: Stig Bjørlykke <stig@bjorlykke.org>
2023-01-12 17:07:43 +11:00
robert-hh 988b6e2dae renesas-ra: Add the UART methods uart.txdone() and uart.flush().
This required to add two functions down the stack to uart.c and ra.sci.c.

- One for telling, whther the transmission is busy.
- One for reporting the size of the TX buffer.

Tested with a EK-RA6M2 board.
2022-12-15 12:09:34 +01:00
robert-hh e69313f89c samd: Add a vref=num option to the ADC and DAC constructor.
ADC: The argument of vref=num is an integer. Values for num are:

    SAMD21:
    0  INT1V   1.0V voltage reference
    1  INTVCC0 1/1.48 Analog voltage supply
    2  INTVCC1 1/2 Analog voltage supply (only for VDDANA > 2.0V)
    3  VREFA   External reference
    4  VREFB   External reference

    SAMD51:
    0  INTREF  internal bandgap reference
    1  INTVCC1 Analog voltage supply
    2  INTVCC0 1/2 Analog voltage supply (only for VDDANA > 2.0v)
    3  AREFA   External reference A
    4  AREFB   External reference B
    5  AREFC   External reference C (ADC1 only)

DAC: The argument of vref=num is an integer. Suitable values:

    SAMD21:
    0  INT1V   Internal voltage reference
    1  VDDANA  Analog voltage supply
    2  VREFA   External reference

    SAMD51:
    0  INTREF Internal bandgap reference
    1  VDDANA Analog voltage supply
    2  VREFAU Unbuffered external voltage reference (not buffered in DAC)
    4  VREFAB Buffered external voltage reference (buffered in DAC).
2022-12-14 12:48:24 +11:00
David Lechner f3d9fe7b2c docs/differences: Add Python 3.10 page.
This adds a new page for Python 3.10 implementation status similar to
previous releases.

Signed-off-by: David Lechner <david@pybricks.com>
2022-12-13 16:55:55 +11:00
David Lechner 918e0ae164 docs/differences: Update Python 3.9 status.
This marks PEP 584 as complete and notes a few PEPs as not relevant.

Signed-off-by: David Lechner <david@pybricks.com>
2022-12-13 16:31:11 +11:00
Damien George 2283b6d68f py: Pass in address to compiled module instead of returning it.
This change makes it so the compiler and persistent code loader take a
mp_compiled_module_t* as their last argument, instead of returning this
struct.  This eliminates a duplicate context variable for all callers of
these functions (because the context is now stored in the
mp_compiled_module_t by the caller), and also eliminates any confusion
about which context to use after the mp_compile_to_raw_code or
mp_raw_code_load function returns (because there is now only one context,
that stored in mp_compiled_module_t.context).

Reduces code size by 16 bytes on ARM Cortex-based ports.

Signed-off-by: Damien George <damien@micropython.org>
2022-12-08 12:27:23 +11:00
Jim Mussared 3ecbaf1e06 docs/library/neopixel: Update GitHub URL for neopixel.py link.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-12-07 13:36:20 +11:00
Laurens Valk a6fd13a026 docs/library/struct: Embed format tables.
Also add note about long support.

Signed-off-by: Laurens Valk <laurens@pybricks.com>
2022-12-06 09:32:05 +01:00
Laurens Valk 6503cd47af docs/library/struct: Fix buffer argument description.
The buffer is the data in this case. There is no buffer argument.

Signed-off-by: Laurens Valk <laurens@pybricks.com>
2022-12-06 17:46:42 +11:00
Michael Mogenson 921f397acb tools/mpremote: Only auto connect to serial device with USB VID/PID.
On MacOS and Windows there are a few default serial devices that are
returned by `serial.tools.list_ports.comports()`. For example on MacOS:

```
{'description': 'n/a',
 'device': '/dev/cu.Bluetooth-Incoming-Port',
 'hwid': 'n/a',
 'interface': None,
 'location': None,
 'manufacturer': None,
 'name': 'cu.Bluetooth-Incoming-Port',
 'pid': None,
 'product': None,
 'serial_number': None,
 'vid': None}

{'description': 'n/a',
 'device': '/dev/cu.wlan-debug',
 'hwid': 'n/a',
 'interface': None,
 'location': None,
 'manufacturer': None,
 'name': 'cu.wlan-debug',
 'pid': None,
 'product': None,
 'serial_number': None,
 'vid': None}
```

Users of mpremote most likely do not want to connect to these ports. It
would be desirable if mpremote did not select this ports when using the
auto connect behavior. These serial ports do not have USB VID or PID
values and serial ports for Micropython boards with FTDI/serial-to-USB
adapter or native USB CDC/ACM support do.

Check for the presence of a USB VID / PID int value when selecting a
serial port to auto connect to. All serial ports will still be listed by
the `list` command and can still be selected by name when connecting.

Signed-off-by: Michael Mogenson <michael.mogenson@gmail.com>
2022-11-25 17:20:14 -05:00
Laurens Valk a67989aa20 examples/usercmodule: Add example of a native C class.
This shows how ports can add their own custom types/classes.

It is part of the unix coverage build, so we can use it for tests too.

Signed-off-by: Laurens Valk <laurens@pybricks.com>
2022-11-23 11:46:17 +11:00
yn386 a74e4fabeb stm32/i2c: Fix I2C frequency calc so it doesn't exceed requested rate.
Prior to this commit, the actual I2C frequency can be faster than specified
one and it may exceed the I2C's specification for Fast Mode.  The frequency
of SCL should be less than or equal to 400KHz in Fast Mode.

This commit fixes this issue for F4 MCUs by rounding up the division in the
frequency calculation.
2022-11-18 14:25:19 +11:00
TPReal 859d0e9529 docs/library/framebuf: Clarify docs for blit regarding palette.
Clarified the behaviour when both key and palette are specified.
2022-11-17 23:18:22 +11:00
robert-hh 3459a4fa3d mimxrt/network: Rename the argument clock_mode to ref_clk_mode.
The definitions for LAN.IN and LAN.OUT are kept, but in the code Pin.IN
and Pin.OUT can be used as well as values for the ref_clk_mode argument.
2022-11-17 08:55:16 +01:00
Peter Hinch d1ed0f1610 docs/library/uasyncio: Describe restriction on ThreadSafeFlag.
As per Issue #7965, this class does not work on the Unix build.
2022-11-16 13:03:43 +11:00
Sky c1ae7d7534 docs/library/pyb.CAN: Update the recv example to take a 5-tuple.
A supplement to commit 5cdf964571
2022-11-15 22:50:17 +11:00
Howard Lovatt d2f8127258 docs/library/array: Add docs for dunder methods.
Signed-off-by: Damien George <damien@micropython.org>
2022-11-15 18:21:58 +11:00