Skip to content

Commit e85fa96

Browse files
authored
Merge branch 'micropython:master' into esp32_bitstream
2 parents cf75ac9 + ae6062a commit e85fa96

File tree

130 files changed

+3208
-1357
lines changed

Some content is hidden

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

130 files changed

+3208
-1357
lines changed

.github/workflows/ruff.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
runs-on: ubuntu-latest
88
steps:
99
- uses: actions/checkout@v4
10-
# ruff version should be kept in sync with .pre-commit-config.yaml
11-
- run: pipx install ruff==0.9.6
10+
# ruff version should be kept in sync with .pre-commit-config.yaml & also micropython-lib
11+
- run: pipx install ruff==0.11.6
1212
- run: ruff check --output-format=github .
1313
- run: ruff format --diff .

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ repos:
1212
verbose: true
1313
stages: [commit-msg]
1414
- repo: https://github.com/charliermarsh/ruff-pre-commit
15-
# Version should be kept in sync with .github/workflows/ruff.yml
16-
rev: v0.9.6
15+
# Version should be kept in sync with .github/workflows/ruff.yml & also micropython-lib
16+
rev: v0.11.6
1717
hooks:
1818
- id: ruff
1919
- id: ruff-format

CODECONVENTIONS.md

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -206,33 +206,65 @@ adhere to the existing style and use `tools/codeformat.py` to check any changes.
206206
The main conventions, and things not enforceable via the auto-formatter, are
207207
described below.
208208

209-
White space:
209+
As the MicroPython code base is over ten years old, not every source file
210+
conforms fully to these conventions. If making small changes to existing code,
211+
then it's usually acceptable to follow the existing code's style. New code or
212+
major changes should follow the conventions described here.
213+
214+
## White space
215+
210216
- Expand tabs to 4 spaces.
211217
- Don't leave trailing whitespace at the end of a line.
212218
- For control blocks (if, for, while), put 1 space between the
213219
keyword and the opening parenthesis.
214220
- Put 1 space after a comma, and 1 space around operators.
215221

216-
Braces:
222+
## Braces
223+
217224
- Use braces for all blocks, even no-line and single-line pieces of
218225
code.
219226
- Put opening braces on the end of the line it belongs to, not on
220227
a new line.
221228
- For else-statements, put the else on the same line as the previous
222229
closing brace.
223230

224-
Header files:
231+
## Header files
232+
225233
- Header files should be protected from multiple inclusion with #if
226234
directives. See an existing header for naming convention.
227235

228-
Names:
236+
## Names
237+
229238
- Use underscore_case, not camelCase for all names.
230239
- Use CAPS_WITH_UNDERSCORE for enums and macros.
231240
- When defining a type use underscore_case and put '_t' after it.
232241

233-
Integer types: MicroPython runs on 16, 32, and 64 bit machines, so it's
234-
important to use the correctly-sized (and signed) integer types. The
235-
general guidelines are:
242+
### Public names (declared in headers)
243+
244+
- MicroPython-specific names (especially any declared in `py/` and `extmod/`
245+
directories) should generally start with `mp_` or `MP_`.
246+
- Functions and variables declared in a header should generally share a longer
247+
common prefix. Usually the prefix matches the file name (i.e. items defined in
248+
`py/obj.c` are declared in `py/obj.h` and should be prefixed `mp_obj_`). There
249+
are exceptions, for example where one header file contains declarations
250+
implemented in multiple source files for expediency.
251+
252+
### Private names (specific to a single .c file)
253+
254+
- For static functions and variables exposed to Python (i.e. a static C function
255+
that is wrapped in `MP_DEFINE_CONST_FUN_...` and attached to a module), use
256+
the file-level shared common prefix, i.e. name them as if the function or
257+
variable was not static.
258+
- Other static definitions in source files (i.e. functions or variables defined
259+
in a .c file that are only used within that .c file) don't need any prefix
260+
(specifically: no `s_` or `_` prefix, and generally avoid adding the
261+
file-level common prefix).
262+
263+
## Integer types
264+
265+
MicroPython runs on 16, 32, and 64 bit machines, so it's important to use the
266+
correctly-sized (and signed) integer types. The general guidelines are:
267+
236268
- For most cases use mp_int_t for signed and mp_uint_t for unsigned
237269
integer values. These are guaranteed to be machine-word sized and
238270
therefore big enough to hold the value from a MicroPython small-int
@@ -241,11 +273,13 @@ general guidelines are:
241273
- You can use int/uint, but remember that they may be 16-bits wide.
242274
- If in doubt, use mp_int_t/mp_uint_t.
243275

244-
Comments:
276+
## Comments
277+
245278
- Be concise and only write comments for things that are not obvious.
246279
- Use `// ` prefix, NOT `/* ... */`. No extra fluff.
247280

248-
Memory allocation:
281+
## Memory allocation
282+
249283
- Use m_new, m_renew, m_del (and friends) to allocate and free heap memory.
250284
These macros are defined in py/misc.h.
251285

docs/library/wm8960.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -358,13 +358,13 @@ Run WM8960 on a MIMXRT10xx_DEV board in secondary mode (default)::
358358
sysclk_source=wm8960.SYSCLK_MCLK)
359359

360360

361-
Record with a Sparkfun WM8960 breakout board with Teensy in secondary mode (default)::
361+
Record with a SparkFun WM8960 breakout board with Teensy in secondary mode (default)::
362362

363363
# Micro_python WM8960 Codec driver
364364
#
365365
# The breakout board uses a fixed 24MHz MCLK. Therefore the internal
366366
# PLL must be used as sysclk, which is the master audio clock.
367-
# The Sparkfun board has the WS pins for RX and TX connected on the
367+
# The SparkFun board has the WS pins for RX and TX connected on the
368368
# board. Therefore adc_sync must be set to sync_adc, to configure
369369
# it's ADCLRC pin as input.
370370
#
@@ -379,11 +379,11 @@ Record with a Sparkfun WM8960 breakout board with Teensy in secondary mode (defa
379379
right_input=wm8960.INPUT_CLOSED)
380380

381381

382-
Play with a Sparkfun WM8960 breakout board with Teensy in secondary mode (default)::
382+
Play with a SparkFun WM8960 breakout board with Teensy in secondary mode (default)::
383383

384384
# The breakout board uses a fixed 24MHz MCLK. Therefore the internal
385385
# PLL must be used as sysclk, which is the master audio clock.
386-
# The Sparkfun board has the WS pins for RX and TX connected on the
386+
# The SparkFun board has the WS pins for RX and TX connected on the
387387
# board. Therefore adc_sync must be set to sync_adc, to configure
388388
# it's ADCLRC pin as input.
389389

docs/library/zephyr.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ Functions
2222

2323
Returns the thread id of the current thread, which is used to reference the thread.
2424

25-
.. function:: thread_analyze()
25+
.. function:: thread_analyze(cpu)
2626

27-
Runs the Zephyr debug thread analyzer on the current thread and prints stack size statistics in the format:
27+
Runs the Zephyr debug thread analyzer on the current thread on the given cpu
28+
and prints stack size statistics in the format:
2829

2930
"``thread_name``-20s: STACK: unused ``available_stack_space`` usage ``stack_space_used``
3031
/ ``stack_size`` (``percent_stack_space_used`` %); CPU: ``cpu_utilization`` %"
@@ -35,6 +36,9 @@ Functions
3536
For more information, see documentation for Zephyr `thread analyzer
3637
<https://docs.zephyrproject.org/latest/guides/debug_tools/thread-analyzer.html#thread-analyzer>`_.
3738

39+
Note that the ``cpu`` argument is only used in Zephyr v4.0.0 and
40+
newer and ignored otherwise.
41+
3842
.. function:: shell_exec(cmd_in)
3943

4044
Executes the given command on an UART backend. This function can only be accessed if ``CONFIG_SHELL_BACKEND_SERIAL``

docs/samd/pinout.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -892,7 +892,7 @@ Default pin assignments:
892892

893893
There seems to be no default pin assignment for this board.
894894

895-
Sparkfun SAMD51 Thing Plus pin assignment table
895+
SparkFun SAMD51 Thing Plus pin assignment table
896896
------------------------------------------------
897897

898898
=== ==== ============ ==== ==== ==== ====== ====== ===== ===== =====

docs/zephyr/quickref.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,21 @@ Use the :ref:`machine.Pin <machine.Pin>` class::
5656
switch = Pin(("gpioc", 6), Pin.IN) # create input pin for a switch
5757
switch.irq(lambda t: print("SW2 changed")) # enable an interrupt when switch state is changed
5858

59+
PWM
60+
---
61+
62+
Use the :ref:`machine.PWM <machine.PWM>` class::
63+
64+
from machine import PWM
65+
66+
pwm = PWM(("pwm0", 0), freq=3921568, duty_ns=200, invert=True) # create pwm on PWM0
67+
print(pwm) # print pwm
68+
69+
print(pwm.duty_ns()) # print pwm duty cycle in nanoseconds
70+
pwm.duty_ns(255) # set new pwm duty cycle in nanoseconds
71+
72+
pwm.deinit()
73+
5974
Hardware I2C bus
6075
----------------
6176

@@ -138,6 +153,8 @@ Use the :ref:`zephyr.FlashArea <zephyr.FlashArea>` class to support filesystem::
138153
f.write('Hello world') # write to the file
139154
print(open('/flash/hello.txt').read()) # print contents of the file
140155

156+
The FlashAreas' IDs that are available are listed in the FlashArea module, as ID_*.
157+
141158
Sensor
142159
------
143160

docs/zephyr/tutorial/repl.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ With your serial program open (PuTTY, screen, picocom, etc) you may see a
3131
blank screen with a flashing cursor. Press Enter (or reset the board) and
3232
you should be presented with the following text::
3333

34-
*** Booting Zephyr OS build v3.7.0 ***
34+
*** Booting Zephyr OS build v4.0.0 ***
3535
MicroPython v1.24.0-preview.179.g5b85b24bd on 2024-08-05; zephyr-frdm_k64f with mk64f12
3636
Type "help()" for more information.
3737
>>>

drivers/cyw43/README.md

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)