Skip to content

Commit 9ac577f

Browse files
committed
Merge branch 'master' of https://github.com/micropython/micropython into isr-rules
2 parents 2a9b12b + 3446d44 commit 9ac577f

File tree

131 files changed

+2467
-1046
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

131 files changed

+2467
-1046
lines changed

.github/workflows/code_size.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
- name: Build
2929
run: source tools/ci.sh && ci_code_size_build
3030
- name: Compute code size difference
31-
run: tools/metrics.py diff ~/size0 ~/size1 | tee > diff
31+
run: tools/metrics.py diff ~/size0 ~/size1 | tee diff
3232
- name: Save PR number
3333
if: github.event_name == 'pull_request'
3434
env:

.github/workflows/examples.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ jobs:
2020
steps:
2121
- uses: actions/checkout@v3
2222
- name: Build
23-
run: make -C examples/embedding
23+
run: make -C examples/embedding -f micropython_embed.mk && make -C examples/embedding
2424
- name: Run
25-
run: test "$(./examples/embedding/hello-embed)" = "Hello world of easy embedding!"
25+
run: ./examples/embedding/embed | grep "hello world"

CODECONVENTIONS.md

Lines changed: 47 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,30 +65,70 @@ changes to the correct style. Without arguments this tool will reformat all
6565
source code (and may take some time to run). Otherwise pass as arguments to
6666
the tool the files that changed and it will only reformat those.
6767

68-
**Important**: Use only [uncrustify](https://github.com/uncrustify/uncrustify)
69-
v0.71 or v0.72 for MicroPython. Different uncrustify versions produce slightly
70-
different formatting, and the configuration file formats are often incompatible.
68+
uncrustify
69+
==========
70+
71+
Only [uncrustify](https://github.com/uncrustify/uncrustify) v0.71 or v0.72 can
72+
be used for MicroPython. Different uncrustify versions produce slightly
73+
different formatting, and the configuration file formats are often
74+
incompatible. v0.73 or newer *will not work*.
75+
76+
Depending on your operating system version, it may be possible to install a pre-compiled
77+
uncrustify version:
78+
79+
Ubuntu, Debian
80+
--------------
81+
82+
Ubuntu versions 21.10 or 22.04LTS, and Debian versions bullseye or bookworm all
83+
include v0.72 so can be installed directly:
84+
85+
```
86+
$ apt install uncrustify
87+
```
88+
89+
Arch Linux
90+
----------
91+
92+
The current Arch uncrustify version is too new. There is an [old Arch package
93+
for v0.72](https://archive.archlinux.org/packages/u/uncrustify/) that can be
94+
installed from the Arch Linux archive ([more
95+
information](https://wiki.archlinux.org/title/Downgrading_packages#Arch_Linux_Archive)). Use
96+
the [IgnorePkg feature](https://wiki.archlinux.org/title/Pacman#Skip_package_from_being_upgraded)
97+
to prevent it re-updating.
98+
99+
Brew
100+
----
101+
102+
This command may work, please raise a new Issue if it doesn't:
103+
104+
```
105+
brew install https://github.com/Homebrew/homebrew-core/raw/2b07d8192623365078a8b855a164ebcdf81494a6/Formula/uncrustify.rb
106+
```
71107

72108
Automatic Pre-Commit Hooks
73109
==========================
74110

75111
To have code formatting and commit message conventions automatically checked,
76-
a configuration file is provided for the [pre-commit]
77-
(https://pre-commit.com/) tool.
112+
a configuration file is provided for the [pre-commit](https://pre-commit.com/)
113+
tool.
78114

79115
First install `pre-commit`, either from your system package manager or via
80116
`pip`. When installing `pre-commit` via pip, it is recommended to use a
81117
virtual environment. Other sources, such as Brew are also available, see
82118
[the docs](https://pre-commit.com/index.html#install) for details.
83119

84120
```
85-
$ apt install pre-commit # Ubuntu
121+
$ apt install pre-commit # Ubuntu, Debian
86122
$ pacman -Sy python-precommit # Arch Linux
87123
$ brew install pre-commit # Brew
88124
$ pip install pre-commit # PyPI
89125
```
90126

91-
Then inside the MicroPython repository, register the git hooks for pre-commit
127+
Next, install [uncrustify (see above)](#uncrustify). Other dependencies are managed by
128+
pre-commit automatically, but uncrustify needs to be installed and available on
129+
the PATH.
130+
131+
Then, inside the MicroPython repository, register the git hooks for pre-commit
92132
by running:
93133

94134
```
@@ -115,7 +155,6 @@ Tips:
115155
* To ignore the pre-commit message format check temporarily, start the commit
116156
message subject line with "WIP" (for "Work In Progress").
117157

118-
119158
Python code conventions
120159
=======================
121160

docs/esp32/quickref.rst

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ by reading the temperature sensor immediately after waking up from sleep.
6868
Networking
6969
----------
7070

71+
WLAN
72+
^^^^
73+
7174
The :mod:`network` module::
7275

7376
import network
@@ -110,6 +113,67 @@ calling ``wlan.config(reconnects=n)``, where n are the number of desired reconne
110113
attempts (0 means it won't retry, -1 will restore the default behaviour of trying
111114
to reconnect forever).
112115

116+
LAN
117+
^^^
118+
119+
To use the wired interfaces one has to specify the pins and mode ::
120+
121+
import network
122+
123+
lan = network.LAN(mdc=PIN_MDC, ...) # Set the pin and mode configuration
124+
lan.active(True) # activate the interface
125+
lan.ifconfig() # get the interface's IP/netmask/gw/DNS addresses
126+
127+
128+
The keyword arguments for the constructor defining the PHY type and interface are:
129+
130+
- mdc=pin-object # set the mdc and mdio pins.
131+
- mdio=pin-object
132+
- power=pin-object # set the pin which switches the power of the PHY device.
133+
- phy_type=<type> # Select the PHY device type. Supported devices are PHY_LAN8710,
134+
PHY_LAN8720, PH_IP101, PHY_RTL8201, PHY_DP83848 and PHY_KSZ8041
135+
- phy_addr=number # The address number of the PHY device.
136+
- ref_clk_mode=mode # Defines, whether the ref_clk at the ESP32 is an input
137+
or output. Suitable values are Pin.IN and Pin.OUT.
138+
- ref_clk=pin-object # defines the Pin used for ref_clk.
139+
140+
The options ref_clk_mode and ref_clk require at least esp-idf version 4.4. For
141+
earlier esp-idf versions, these parameters must be defined by kconfig board options.
142+
143+
These are working configurations for LAN interfaces of popular boards::
144+
145+
# Olimex ESP32-GATEWAY: power controlled by Pin(5)
146+
# Olimex ESP32 PoE and ESP32-PoE ISO: power controlled by Pin(12)
147+
148+
lan = network.LAN(mdc=machine.Pin(23), mdio=machine.Pin(18), power=machine.Pin(5),
149+
phy_type=network.PHY_LAN8720, phy_addr=0)
150+
151+
# or with dynamic ref_clk pin configuration
152+
153+
lan = network.LAN(mdc=machine.Pin(23), mdio=machine.Pin(18), power=machine.Pin(5),
154+
phy_type=network.PHY_LAN8720, phy_addr=0,
155+
ref_clk=machine.Pin(17), ref_clk_mode=machine.Pin.OUT)
156+
157+
# Wireless-Tag's WT32-ETH01
158+
159+
lan = network.LAN(mdc=machine.Pin(23), mdio=machine.Pin(18),
160+
phy_type=network.PHY_LAN8720, phy_addr=1, power=None)
161+
162+
# Espressif ESP32-Ethernet-Kit_A_V1.2
163+
164+
lan = network.LAN(id=0, mdc=Pin(23), mdio=Pin(18), power=Pin(5),
165+
phy_type=network.PHY_IP101, phy_addr=1)
166+
167+
A suitable definition of the PHY interface in a sdkconfig.board file is::
168+
169+
CONFIG_ETH_PHY_INTERFACE_RMII=y
170+
CONFIG_ETH_RMII_CLK_OUTPUT=y
171+
CONFIG_ETH_RMII_CLK_OUT_GPIO=17
172+
CONFIG_LWIP_LOCAL_HOSTNAME="ESP32_POE"
173+
174+
The value assigned to CONFIG_ETH_RMII_CLK_OUT_GPIO may vary depending on the
175+
board's wiring.
176+
113177
Delay and timing
114178
----------------
115179

docs/library/machine.Timer.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,16 @@ Constructors
3838
Methods
3939
-------
4040

41-
.. method:: Timer.init(*, mode=Timer.PERIODIC, period=-1, callback=None)
41+
.. method:: Timer.init(*, mode=Timer.PERIODIC, freq=-1, period=-1, callback=None)
4242

4343
Initialise the timer. Example::
4444

4545
def mycallback(t):
4646
pass
4747

48+
# periodic at 1kHz
49+
tim.init(mode=Timer.PERIODIC, freq=1000, callback=mycallback)
50+
4851
# periodic with 100ms period
4952
tim.init(period=100, callback=mycallback)
5053

@@ -60,6 +63,11 @@ Methods
6063
- ``Timer.PERIODIC`` - The timer runs periodically at the configured
6164
frequency of the channel.
6265

66+
- ``freq`` - The timer frequency, in units of Hz. The upper bound of
67+
the frequency is dependent on the port. When both the ``freq`` and
68+
``period`` arguments are given, ``freq`` has a higher priority and
69+
``period`` is ignored.
70+
6371
- ``period`` - The timer period, in milliseconds.
6472

6573
- ``callback`` - The callable to call upon expiration of the timer period.

docs/library/rp2.StateMachine.rst

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,17 @@ Methods
9999

100100
.. method:: StateMachine.put(value, shift=0)
101101

102-
Push a word onto the state machine's TX FIFO.
102+
Push words onto the state machine's TX FIFO.
103103

104-
If the FIFO is full, it blocks until there is space (i.e. the state machine
105-
pulls a word).
104+
*value* can be an integer, an array of type ``B``, ``H`` or ``I``, or a
105+
`bytearray`.
106106

107-
The value is first shifted left by *shift* bits, i.e. the state machine
108-
receives ``value << shift``.
107+
This method will block until all words have been written to the FIFO. If
108+
the FIFO is, or becomes, full, the method will block until the state machine
109+
pulls enough words to complete the write.
110+
111+
Each word is first shifted left by *shift* bits, i.e. the state machine
112+
receives ``word << shift``.
109113

110114
.. method:: StateMachine.rx_fifo()
111115

docs/library/socket.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ returned by `getaddrinfo` function, which must be used to resolve textual addres
2929
# You must use getaddrinfo() even for numeric addresses
3030
sockaddr = socket.getaddrinfo('127.0.0.1', 80)[0][-1]
3131
# Now you can use that address
32-
sock.connect(addr)
32+
sock.connect(sockaddr)
3333

3434
Using `getaddrinfo` is the most efficient (both in terms of memory and processing
3535
power) and portable way to work with addresses.

docs/reference/constrained.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,8 @@ Symbol Meaning
392392
F float
393393
B byte code
394394
M module
395+
S string or bytes
396+
A bytearray
395397
====== =================
396398

397399
Each letter represents a single block of memory, a block being 16 bytes. So each

docs/rp2/tutorial/pio.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,10 @@ and state machines. Below is the code for reference.
7676
nop() [29]
7777
jmp(x_dec, "delay_high")
7878
79-
# Cycles: 1 + 7 + 32 * (30 + 1) = 1000
79+
# Cycles: 1 + 1 + 6 + 32 * (30 + 1) = 1000
80+
nop()
8081
set(pins, 0)
81-
set(x, 31) [6]
82+
set(x, 31) [5]
8283
label("delay_low")
8384
nop() [29]
8485
jmp(x_dec, "delay_low")
@@ -113,6 +114,8 @@ the following:
113114
X starts with the value 31 this jump will happen 31 times, so the ``nop() [29]``
114115
runs 32 times in total (note there is also one instruction cycle taken by the
115116
``jmp`` for each of these 32 loops).
117+
- The single ``nop()`` correlates with the cycle used for IRQ raise, and ensures
118+
the same number of cycles are used for LED on and LED off.
116119
- ``set(pins, 0)`` will turn the LED off by setting pin 25 low.
117120
- Another 32 loops of ``nop() [29]`` and ``jmp(...)`` will execute.
118121
- Because ``wrap_target()`` and ``wrap()`` are not specified, their default will

docs/zephyr/quickref.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ Use the :ref:`zsensor.Sensor <zsensor.Sensor>` class to access sensor data::
151151
accel.measure() # obtain a measurement reading from the accelerometer
152152

153153
# each of these prints the value taken by measure()
154-
accel.float(zsensor.ACCEL_X) # print measurement value for accelerometer X-axis sensor channel as float
155-
accel.millis(zsensor.ACCEL_Y) # print measurement value for accelerometer Y-axis sensor channel in millionths
156-
accel.micro(zsensor.ACCEL_Z) # print measurement value for accelerometer Z-axis sensor channel in thousandths
157-
accel.int(zsensor.ACCEL_X) # print measurement integer value only for accelerometer X-axis sensor channel
154+
accel.get_float(zsensor.ACCEL_X) # print measurement value for accelerometer X-axis sensor channel as float
155+
accel.get_millis(zsensor.ACCEL_Y) # print measurement value for accelerometer Y-axis sensor channel in millionths
156+
accel.get_micro(zsensor.ACCEL_Z) # print measurement value for accelerometer Z-axis sensor channel in thousandths
157+
accel.get_int(zsensor.ACCEL_X) # print measurement integer value only for accelerometer X-axis sensor channel

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy