Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into ESP32_PCNT_Encode…
Browse files Browse the repository at this point in the history
…r_Counter
  • Loading branch information
IhorNehrutsa committed Jul 25, 2023
2 parents 420acbc + cfcce4b commit 0cb87ce
Show file tree
Hide file tree
Showing 1,625 changed files with 31,992 additions and 18,233 deletions.
3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# all: Fix spelling mistakes based on codespell check.
b1229efbd1509654dec6053865ab828d769e29db

# top: Update Python formatting to black "2023 stable style".
8b2748269244304854b3462cb8902952b4dcb892

Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/security.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: Security report
about: Report a security issue or vunerability in MicroPython
about: Report a security issue or vulnerability in MicroPython
title: ''
labels: security
assignees: ''
Expand Down
12 changes: 11 additions & 1 deletion .github/workflows/code_formatting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ concurrency:
cancel-in-progress: true

jobs:
build:
code-formatting:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
Expand All @@ -18,3 +18,13 @@ jobs:
run: source tools/ci.sh && ci_code_formatting_run
- name: Check code formatting
run: git diff --exit-code

code-spelling:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- name: Install packages
run: source tools/ci.sh && ci_code_spell_setup
- name: Run spell checker
run: source tools/ci.sh && ci_code_spell_run
8 changes: 3 additions & 5 deletions .github/workflows/mpremote.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@ jobs:
steps:
- uses: actions/checkout@v3
with:
# Version is determined from git,
# should be deep enough to get to latest tag
fetch-depth: '1000'
- run: |
git fetch --prune --unshallow --tags
# Setting this to zero means fetch all history and tags,
# which hatch-vcs can use to discover the version tag.
fetch-depth: 0
- uses: actions/setup-python@v4
- name: Install build tools
run: pip install build
Expand Down
13 changes: 2 additions & 11 deletions .github/workflows/ports_esp32.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,11 @@ concurrency:
cancel-in-progress: true

jobs:
build_idf402:
build_idf50:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Install packages
run: source tools/ci.sh && ci_esp32_idf402_setup
- name: Build
run: source tools/ci.sh && ci_esp32_build

build_idf44:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Install packages
run: source tools/ci.sh && ci_esp32_idf44_setup
run: source tools/ci.sh && ci_esp32_idf50_setup
- name: Build
run: source tools/ci.sh && ci_esp32_build
4 changes: 2 additions & 2 deletions .github/workflows/ports_unix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ jobs:
run: tests/run-tests.py --print-failures

coverage_32bit:
runs-on: ubuntu-latest
runs-on: ubuntu-20.04 # use 20.04 to get libffi-dev:i386
steps:
- uses: actions/checkout@v3
- name: Install packages
Expand All @@ -103,7 +103,7 @@ jobs:
run: tests/run-tests.py --print-failures

nanbox:
runs-on: ubuntu-20.04 # use 20.04 to get python2
runs-on: ubuntu-20.04 # use 20.04 to get python2, and libffi-dev:i386
steps:
- uses: actions/checkout@v3
- name: Install packages
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/ruff.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
name: Python code lint with ruff
on: [push, pull_request]
jobs:
ruff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: pip install --user ruff
- run: ruff --format=github .
4 changes: 4 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@ repos:
language: python
verbose: true
stages: [commit-msg]
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.265
hooks:
- id: ruff
20 changes: 8 additions & 12 deletions CODECONVENTIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ It's also ok to drop file extensions.

Besides prefix, first line of a commit message should describe a
change clearly and to the point, and be a grammatical sentence with
final full stop. First line should fit within 72 characters. Examples
final full stop. First line must fit within 72 characters. Examples
of good first line of commit messages:

py/objstr: Add splitlines() method.
Expand All @@ -27,12 +27,9 @@ change beyond 5 lines would likely require such detailed description.
To get good practical examples of good commits and their messages, browse
the `git log` of the project.

When committing you are encouraged to sign-off your commit by adding
"Signed-off-by" lines and similar, eg using "git commit -s". If you don't
explicitly sign-off in this way then the commit message, which includes your
name and email address in the "Author" line, implies your sign-off. In either
case, of explicit or implicit sign-off, you are certifying and signing off
against the following:
When committing you must sign-off your commit by adding "Signed-off-by:"
line(s) at the end of the commit message, e.g. using `git commit -s`. You
are then certifying and signing off against the following:

* That you wrote the change yourself, or took it from a project with
a compatible license (in the latter case the commit message, and possibly
Expand All @@ -49,10 +46,9 @@ against the following:
* Your contribution including commit message will be publicly and
indefinitely available for anyone to access, including redistribution
under the terms of the project's license.
* Your signature for all of the above, which is the "Signed-off-by" line
or the "Author" line in the commit message, includes your full real name and
a valid and active email address by which you can be contacted in the
foreseeable future.
* Your signature for all of the above, which is the "Signed-off-by" line,
includes your full real name and a valid and active email address by
which you can be contacted in the foreseeable future.

Code auto-formatting
====================
Expand Down Expand Up @@ -255,7 +251,7 @@ Documentation conventions
=========================

MicroPython generally follows CPython in documentation process and
conventions. reStructuredText syntax is used for the documention.
conventions. reStructuredText syntax is used for the documentation.

Specific conventions/suggestions:

Expand Down
6 changes: 4 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2013-2022 Damien P. George
Copyright (c) 2013-2023 Damien P. George

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -36,7 +36,6 @@ used during the build process and is not part of the compiled source code.
/ (MIT)
/drivers
/cc3100 (BSD-3-clause)
/wiznet5k (BSD-3-clause)
/lib
/asf4 (Apache-2.0)
/axtls (BSD-3-clause)
Expand All @@ -61,12 +60,15 @@ used during the build process and is not part of the compiled source code.
/tinytest (BSD-3-clause)
/tinyusb (MIT)
/uzlib (Zlib)
/wiznet5k (MIT)
/logo (uses OFL-1.1)
/ports
/cc3200
/hal (BSD-3-clause)
/simplelink (BSD-3-clause)
/FreeRTOS (GPL-2.0 with FreeRTOS exception)
/esp32
/ppp_set_auth.* (Apache-2.0)
/stm32
/usbd*.c (MCD-ST Liberty SW License Agreement V2)
/stm32_it.* (MIT + BSD-3-clause)
Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@

# General information about the project.
project = 'MicroPython'
copyright = '- The MicroPython Documentation is Copyright © 2014-2022, Damien P. George, Paul Sokolovsky, and contributors'
copyright = '- The MicroPython Documentation is Copyright © 2014-2023, Damien P. George, Paul Sokolovsky, and contributors'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down Expand Up @@ -233,7 +233,7 @@
# Additional stuff for the LaTeX preamble.
#'preamble': '',
# Include 3 levels of headers in PDF ToC
'preamble': '\setcounter{tocdepth}{2}',
'preamble': r'\setcounter{tocdepth}{2}',
}

# Grouping the document tree into LaTeX files. List of tuples
Expand Down
2 changes: 1 addition & 1 deletion docs/develop/cmodules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ A MicroPython user C module is a directory with the following files:
``SRC_USERMOD_C`` or ``SRC_USERMOD_LIB_C`` variables. The former will be
processed for ``MP_QSTR_`` and ``MP_REGISTER_MODULE`` definitions, the latter
will not (e.g. helpers and library code that isn't MicroPython-specific).
These paths should include your expaned copy of ``$(USERMOD_DIR)``, e.g.::
These paths should include your expanded copy of ``$(USERMOD_DIR)``, e.g.::

SRC_USERMOD_C += $(EXAMPLE_MOD_DIR)/modexample.c
SRC_USERMOD_LIB_C += $(EXAMPLE_MOD_DIR)/utils/algorithm.c
Expand Down
7 changes: 4 additions & 3 deletions docs/develop/porting.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ The basic MicroPython firmware is implemented in the main port file, e.g ``main.

.. code-block:: c
#include "py/builtin.h"
#include "py/compile.h"
#include "py/gc.h"
#include "py/mperrno.h"
Expand Down Expand Up @@ -110,6 +111,9 @@ We also need a Makefile at this point for the port:
shared/runtime/pyexec.c \
shared/runtime/stdout_helpers.c \
# Define source files containung qstrs.
SRC_QSTR += shared/readline/readline.c shared/runtime/pyexec.c
# Define the required object files.
OBJ = $(PY_CORE_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
Expand Down Expand Up @@ -147,9 +151,6 @@ The following is an example of an ``mpconfigport.h`` file:
#define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_TERSE)
#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_FLOAT)
// Enable u-modules to be imported with their standard name, like sys.
#define MICROPY_MODULE_WEAK_LINKS (1)
// Fine control over Python builtins, classes, modules, etc.
#define MICROPY_PY_ASYNC_AWAIT (0)
#define MICROPY_PY_BUILTINS_SET (0)
Expand Down
29 changes: 8 additions & 21 deletions docs/esp32/quickref.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ The :mod:`esp32` module::

import esp32

esp32.hall_sensor() # read the internal hall sensor
esp32.raw_temperature() # read the internal temperature of the MCU, in Fahrenheit
esp32.ULP() # access to the Ultra-Low-Power Co-processor

Expand Down Expand Up @@ -137,19 +136,11 @@ The keyword arguments for the constructor defining the PHY type and interface ar
or output. Suitable values are Pin.IN and Pin.OUT.
- ref_clk=pin-object # defines the Pin used for ref_clk.

The options ref_clk_mode and ref_clk require at least esp-idf version 4.4. For
earlier esp-idf versions, these parameters must be defined by kconfig board options.

These are working configurations for LAN interfaces of popular boards::

# Olimex ESP32-GATEWAY: power controlled by Pin(5)
# Olimex ESP32 PoE and ESP32-PoE ISO: power controlled by Pin(12)

lan = network.LAN(mdc=machine.Pin(23), mdio=machine.Pin(18), power=machine.Pin(5),
phy_type=network.PHY_LAN8720, phy_addr=0)

# or with dynamic ref_clk pin configuration

lan = network.LAN(mdc=machine.Pin(23), mdio=machine.Pin(18), power=machine.Pin(5),
phy_type=network.PHY_LAN8720, phy_addr=0,
ref_clk=machine.Pin(17), ref_clk_mode=machine.Pin.OUT)
Expand All @@ -159,21 +150,17 @@ These are working configurations for LAN interfaces of popular boards::
lan = network.LAN(mdc=machine.Pin(23), mdio=machine.Pin(18),
phy_type=network.PHY_LAN8720, phy_addr=1, power=None)

# Wireless-Tag's WT32-ETH01 v1.4

lan = network.LAN(mdc=machine.Pin(23), mdio=machine.Pin(18),
phy_type=network.PHY_LAN8720, phy_addr=1,
power=machine.Pin(16))

# Espressif ESP32-Ethernet-Kit_A_V1.2

lan = network.LAN(id=0, mdc=Pin(23), mdio=Pin(18), power=Pin(5),
phy_type=network.PHY_IP101, phy_addr=1)

A suitable definition of the PHY interface in a sdkconfig.board file is::

CONFIG_ETH_PHY_INTERFACE_RMII=y
CONFIG_ETH_RMII_CLK_OUTPUT=y
CONFIG_ETH_RMII_CLK_OUT_GPIO=17
CONFIG_LWIP_LOCAL_HOSTNAME="ESP32_POE"

The value assigned to CONFIG_ETH_RMII_CLK_OUT_GPIO may vary depending on the
board's wiring.

Delay and timing
----------------

Expand Down Expand Up @@ -305,8 +292,8 @@ Use the :ref:`machine.PWM <machine.PWM>` class::

from machine import Pin, PWM

pwm0 = PWM(Pin(0)) # create PWM object from a pin
freq = pwm0.freq() # get current frequency (default 5kHz)
pwm0 = PWM(Pin(0), freq=5000, duty_u16=32768) # create PWM object from a pin
freq = pwm0.freq() # get current frequency
pwm0.freq(1000) # set PWM frequency from 1Hz to 40MHz

duty = pwm0.duty() # get current duty cycle, range 0-1023 (default 512, 50%)
Expand Down
8 changes: 4 additions & 4 deletions docs/esp32/tutorial/intro.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Requirements
The first thing you need is a board with an ESP32 chip. The MicroPython
software supports the ESP32 chip itself and any board should work. The main
characteristic of a board is how the GPIO pins are connected to the outside
world, and whether it includes a built-in USB-serial convertor to make the
world, and whether it includes a built-in USB-serial converter to make the
UART available to your PC.

Names of pins will be given in this tutorial using the chip names (eg GPIO2)
Expand Down Expand Up @@ -59,7 +59,7 @@ bootloader mode, and second you need to copy across the firmware. The exact
procedure for these steps is highly dependent on the particular board and you will
need to refer to its documentation for details.

Fortunately, most boards have a USB connector, a USB-serial convertor, and the DTR
Fortunately, most boards have a USB connector, a USB-serial converter, and the DTR
and RTS pins wired in a special way then deploying the firmware should be easy as
all steps can be done automatically. Boards that have such features
include the Adafruit Feather HUZZAH32, M5Stack, Wemos LOLIN32, and TinyPICO
Expand Down Expand Up @@ -104,7 +104,7 @@ Serial prompt

Once you have the firmware on the device you can access the REPL (Python prompt)
over UART0 (GPIO1=TX, GPIO3=RX), which might be connected to a USB-serial
convertor, depending on your board. The baudrate is 115200.
converter, depending on your board. The baudrate is 115200.

From here you can now follow the ESP8266 tutorial, because these two Espressif chips
are very similar when it comes to using MicroPython on them. The ESP8266 tutorial
Expand All @@ -124,7 +124,7 @@ after it, here are troubleshooting recommendations:

* The flashing instructions above use flashing speed of 460800 baud, which is
good compromise between speed and stability. However, depending on your
module/board, USB-UART convertor, cables, host OS, etc., the above baud
module/board, USB-UART converter, cables, host OS, etc., the above baud
rate may be too high and lead to errors. Try a more common 115200 baud
rate instead in such cases.

Expand Down
4 changes: 2 additions & 2 deletions docs/esp32/tutorial/pwm.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ low all of the time.

* Example of a smooth frequency change::

from utime import sleep
from time import sleep
from machine import Pin, PWM

F_MIN = 500
Expand All @@ -75,7 +75,7 @@ low all of the time.

* Example of a smooth duty change::

from utime import sleep
from time import sleep
from machine import Pin, PWM

DUTY_MAX = 2**16 - 1
Expand Down
Loading

0 comments on commit 0cb87ce

Please sign in to comment.