Commit Graph

1150 Commits

Author SHA1 Message Date
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
Takeo Takahashi 5228f4067d renesas-ra: Change file system size to 64KB for RA6M1.
Changes in this commit:
- Change file system size from 128KB to 64KB in ra6m1_ek.ld.
- Change EK-RA6M1's file system size in renesas-ra port document.

Signed-off-by: Takeo Takahashi <takeo.takahashi.xv@renesas.com>
2022-11-15 10:01:36 +11:00
Takeo Takahashi 75012cfd6e docs/renesas-ra: Correct the internal file system size of EK-RA6M2.
Signed-off-by: Takeo Takahashi <takeo.takahashi.xv@renesas.com>
2022-11-15 10:01:35 +11:00
Damien George ec12cc5ba6 docs/develop: Fix mp_compile snippet to match latest code.
Signed-off-by: Damien George <damien.p.george@gmail.com>
2022-11-11 15:43:48 +11:00
robert-hh b3ce059767 docs/samd/pinout: Fix the pin numbering for the default assignments.
It still used the 'old' pin numbers.
2022-11-08 23:24:35 +11:00
Matt Trentini e65b12a1b9 docs/library/machine: Add machine.memX to docs with brief example. 2022-11-08 23:12:34 +11:00
robert-hh 65fa7fd8bb mimxrt/machine_timer: Use soft-timer implementation for machine.Timer.
This releases the hardware timers for other tasks, which need a higher
resolution and faster response.  And it is less port-specific code.
2022-10-27 14:09:29 +11:00
robert-hh 11910e2fa1 docs/samd: Add documentation for the samd port.
Includes a general overview, a quickref, pinout tables, and the beginnings
of a tutorial.
2022-10-26 23:39:35 +11:00
Jim Mussared 64af916c11 docs/templates/layout.html: Indicate latest vs release docs.
When looking at latest (the default for docs.micropython.org), make it
clear that this isn't the release version.
 - Changes the version in the top-left to "latest".
 - Adds a message to the top of each page to explain.

For future release versions, add a short message to link to the latest
version.

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-10-26 16:23:20 +11:00
Jim Mussared 3cc6decfc4 py/py.mk: Make user-C-module handling self-contained in py.mk.
Removes the need for the port to add anything to OBJS or SRC_QSTR.

Also makes it possible for user-C-modules to differentiate between code
that should be processed for QSTR vs other files (e.g. helpers and
libraries).

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-10-11 23:23:18 +11:00
Jim Mussared 17f2783e4a all: Use += rather than = everywhere for CFLAGS/LDFLAGS/LIBS.
This avoids a surprise where an = can cancel out an earlier +=.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-10-11 23:17:41 +11:00
Jim Mussared 12ca918eb2 tools/mpremote: Add `mpremote mip install` to install packages.
This supports the same package sources as the new `mip` tool.
 - micropython-lib (by name)
 - http(s) & github packages with json description
 - directly downloading a .py/.mpy file

The version is specified with an optional `@version` on the end of the
package name. The target dir, index, and mpy/no-mpy can be set through
command line args.

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-10-01 22:44:24 +10:00
Jim Mussared 924a3e03ec top: Replace upip with mip everywhere.
Updates all README.md and docs, and manifests to `require("mip")`.

Also extend and improve the documentation on freezing and packaging.

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-30 17:34:03 +10:00
Jim Mussared b76ddcbc83 docs/Makefile: Enable parallel compilation for Sphinx.
This has a fairly dramatic (nearly 3x on a 6-core machine) speedup for docs
compilation, with no impact on correctness.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-29 23:51:29 +10:00
Jim Mussared d94141e147 py/persistentcode: Introduce .mpy sub-version.
The intent is to allow us to make breaking changes to the native ABI (e.g.
changes to dynruntime.h) without needing the bytecode version to increment.

With this commit the two bits previously used for the feature flags (but
now unused as of .mpy version 6) encode a sub-version.  A bytecode-only
.mpy file can be loaded as long as MPY_VERSION matches, but a native .mpy
(i.e. one with an arch set) must also match MPY_SUB_VERSION.  This allows 3
additional updates to the native ABI per bytecode revision.

The sub-version is set to 1 because the previous commits that changed the
layout of mp_obj_type_t have changed the native ABI.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Signed-off-by: Damien George <damien@micropython.org>
2022-09-19 23:19:55 +10:00
robert-hh 0f048a5a2a mimxrt/machine_spi: Allow a setting of -1 for cs in the constructor.
In that case, no Pin will be configured for the CS signal, even if it is
internally still generated.  That setting allows to use any pin for CS,
which then must be controlled by the Python script.

Also make the default cs=-1 to match other ports (software CS).
2022-09-13 18:35:48 +10:00
Jim Mussared cacc96d98c extmod/modbluetooth: Replace def_handle with end_handle in char IRQ.
This is technically a breaking change, but:
a) We need the end handle to do descriptor discovery properly.
b) We have no possible use for the existing definition handle in the
characteristic result IRQ. None of the methods can use it, and therefore
no existing code should be using it in a way that changing it to a
different integer value should break.

Unfortunately NimBLE doesn't make it easy to get the end handle, so also
implement a mechanism to use the following characteristic to calculate
the previous characteristic's end handle.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-09-09 11:24:24 +10:00
Damien George 655c29351a drivers/display: Don't include tests by default.
The tests can be copied to the board if needed.

Also update the docs to reflect this change.

Signed-off-by: Damien George <damien@micropython.org>
2022-09-06 12:09:20 +10:00
Takeo Takahashi af100b7029 docs/renesas-ra: Add pin drive keyword argument description.
Signed-off-by: Takeo Takahashi <takeo.takahashi.xv@renesas.com>
2022-08-31 12:01:38 +10:00
robert-hh b74eeee5e0 docs/library/machine.UART: Add docs for uart.flush() and uart.txdone(). 2022-08-31 00:20:44 +10:00
robert-hh 53ebbf10e5 docs/library/machine.I2C: Add a note about I2C pull-up resistors.
Quite regularly users complain about unexpected behavior of I2C, calling it
a bug, when in fact the trouble is caused by missing pull-up resistors.  So
this commit adds a note to the documentation, in the slim hope that people
will find and read it.
2022-08-31 00:07:23 +10:00
Jim Mussared 31d7ab327b docs/templates/topindex.html: Update forum link.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2022-08-30 13:17:26 +10:00
Laurens Valk 6dcfb25ae7 docs/library/micropython: Fix spelling of compiler.
Signed-off-by: Laurens Valk <laurens@pybricks.com>
2022-08-26 15:15:59 +10:00
Laurens Valk da217e83d9 docs/library: Fix nested rst styles not rendering.
These can't be nested, so apply styling separately.

Signed-off-by: Laurens Valk <laurens@pybricks.com>
2022-08-26 15:15:59 +10:00
Tomasz 'CeDeROM' CEDRO 602f9db2f3 docs/library/machine.UART: Add notes about UART init and deinit.
* `init()` can be called multiple times to reconfigure UART.
* After `deinit()` it is impossible to call `init()` again.

Signed-off-by: Tomasz 'CeDeROM' CEDRO <tomek@cedro.info>
2022-08-26 15:13:45 +10:00