diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index daa9e02a8e..90ebde9062 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,6 +12,10 @@ on: check_suite: types: [rerequested] +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + jobs: test: runs-on: ubuntu-20.04 @@ -30,16 +34,16 @@ jobs: with: submodules: false fetch-depth: 1 - - name: Set up Python 3.8 - uses: actions/setup-python@v1 + - name: Set up Python 3 + uses: actions/setup-python@v2 with: - python-version: 3.8 + python-version: "3.x" - name: Get CP deps - run: python tools/ci_fetch_deps.py test ${{ github.ref }} + run: python tools/ci_fetch_deps.py test ${{ github.sha }} - name: CircuitPython version run: | - git describe --dirty --tags || git log --parents HEAD~4.. - echo >>$GITHUB_ENV CP_VERSION=$(git describe --dirty --tags) + tools/describe || git log --parents HEAD~4.. + echo >>$GITHUB_ENV CP_VERSION=$(tools/describe) - name: Install dependencies run: | sudo apt-get update @@ -68,10 +72,23 @@ jobs: run: MICROPY_CPYTHON3=python3.8 MICROPY_MICROPYTHON=../ports/unix/micropython-coverage ./run-tests.py -j1 --emit native working-directory: tests - name: mpy Tests - run: MICROPY_CPYTHON3=python3.8 MICROPY_MICROPYTHON=../ports/unix/micropython-coverage ./run-tests.py -j1 --mpy-cross-flags='-mcache-lookup-bc' --via-mpy -d basics float micropython + run: MICROPY_CPYTHON3=python3.8 MICROPY_MICROPYTHON=../ports/unix/micropython-coverage ./run-tests.py -j1 --via-mpy -d basics float micropython working-directory: tests - name: Native mpy Tests - run: MICROPY_CPYTHON3=python3.8 MICROPY_MICROPYTHON=../ports/unix/micropython-coverage ./run-tests.py -j1 --mpy-cross-flags='-mcache-lookup-bc' --via-mpy --emit native -d basics float micropython + run: MICROPY_CPYTHON3=python3.8 MICROPY_MICROPYTHON=../ports/unix/micropython-coverage ./run-tests.py -j1 --via-mpy --emit native -d basics float micropython + working-directory: tests + - name: Build native modules + run: | + make -C examples/natmod/features1 + make -C examples/natmod/features2 + make -C examples/natmod/btree + make -C examples/natmod/framebuf + make -C examples/natmod/uheapq + make -C examples/natmod/urandom + make -C examples/natmod/ure + make -C examples/natmod/uzlib + - name: Test native modules + run: MICROPY_CPYTHON3=python3.8 MICROPY_MICROPYTHON=../ports/unix/micropython-coverage ./run-natmodtests.py extmod/{btree*,framebuf*,uheapq*,ure*,uzlib*}.py working-directory: tests - name: Build mpy-cross.static-aarch64 run: make -C mpy-cross -j2 -f Makefile.static-aarch64 @@ -136,16 +153,16 @@ jobs: with: submodules: false fetch-depth: 1 - - name: Set up Python 3.8 - uses: actions/setup-python@v1 + - name: Set up Python 3 + uses: actions/setup-python@v2 with: - python-version: 3.8 + python-version: "3.x" - name: Get CP deps - run: python tools/ci_fetch_deps.py mpy-cross-mac ${{ github.ref }} + run: python tools/ci_fetch_deps.py mpy-cross-mac ${{ github.sha }} - name: CircuitPython version run: | - git describe --dirty --tags - echo >>$GITHUB_ENV CP_VERSION=$(git describe --dirty --tags) + tools/describe || git log --parents HEAD~4.. + echo >>$GITHUB_ENV CP_VERSION=$(tools/describe) - name: Install dependencies run: | brew install gettext @@ -197,15 +214,15 @@ jobs: submodules: false fetch-depth: 1 - name: Get CP deps - run: python tools/ci_fetch_deps.py docs ${{ github.ref }} + run: python tools/ci_fetch_deps.py docs ${{ github.sha }} - name: CircuitPython version run: | - git describe --dirty --tags - echo >>$GITHUB_ENV CP_VERSION=$(git describe --dirty --tags) - - name: Set up Python 3.8 - uses: actions/setup-python@v1 + tools/describe || git log --parents HEAD~4.. + echo >>$GITHUB_ENV CP_VERSION=$(tools/describe) + - name: Set up Python 3 + uses: actions/setup-python@v2 with: - python-version: 3.8 + python-version: "3.x" - name: Install dependencies run: | sudo apt-get update @@ -241,7 +258,7 @@ jobs: zip -9r circuitpython-stubs.zip circuitpython-stubs [ -z "$AWS_ACCESS_KEY_ID" ] || aws s3 cp circuitpython-stubs/dist/*.tar.gz s3://adafruit-circuit-python/bin/stubs/circuitpython-stubs-${{ env.CP_VERSION }}.zip --no-progress --region us-east-1 - name: Upload stubs to PyPi - if: (github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository_owner == 'adafruit') || (github.event_name == 'release' && (github.event.action == 'published' || github.event.action == 'rerequested')) + if: github.event_name == 'release' && (github.event.action == 'published' || github.event.action == 'rerequested') env: TWINE_USERNAME: ${{ secrets.pypi_username }} TWINE_PASSWORD: ${{ secrets.pypi_password }} @@ -260,16 +277,16 @@ jobs: board: ${{ fromJSON(needs.test.outputs.boards-arm) }} if: ${{ needs.test.outputs.boards-arm != '[]' }} steps: - - name: Set up Python 3.8 - uses: actions/setup-python@v1 + - name: Set up Python 3 + uses: actions/setup-python@v2 with: - python-version: 3.8 + python-version: "3.x" - uses: actions/checkout@v2.2.0 with: submodules: false fetch-depth: 1 - name: Get CP deps - run: python tools/ci_fetch_deps.py ${{ matrix.board }} ${{ github.ref }} + run: python tools/ci_fetch_deps.py ${{ matrix.board }} ${{ github.sha }} - name: Install dependencies run: | sudo apt-get install -y gettext @@ -312,16 +329,16 @@ jobs: board: ${{ fromJSON(needs.test.outputs.boards-riscv) }} if: ${{ needs.test.outputs.boards-riscv != '[]' }} steps: - - name: Set up Python 3.8 - uses: actions/setup-python@v1 + - name: Set up Python 3 + uses: actions/setup-python@v2 with: - python-version: 3.8 + python-version: "3.x" - uses: actions/checkout@v2.2.0 with: submodules: false fetch-depth: 1 - name: Get CP deps - run: python tools/ci_fetch_deps.py ${{ matrix.board }} ${{ github.ref }} + run: python tools/ci_fetch_deps.py ${{ matrix.board }} ${{ github.sha }} - name: Install dependencies run: | sudo apt-get install -y gettext @@ -364,18 +381,20 @@ jobs: board: ${{ fromJSON(needs.test.outputs.boards-espressif) }} if: ${{ needs.test.outputs.boards-espressif != '[]' }} steps: - - name: Set up Python 3.8 - uses: actions/setup-python@v1 + - name: Set up Python 3 + uses: actions/setup-python@v2 with: - python-version: 3.8 + python-version: "3.x" - uses: actions/checkout@v2.2.0 with: submodules: false fetch-depth: 1 - name: Get CP deps - run: python tools/ci_fetch_deps.py ${{ matrix.board }} ${{ github.ref }} + run: python tools/ci_fetch_deps.py ${{ matrix.board }} ${{ github.sha }} - name: CircuitPython version - run: git describe --dirty --tags + run: | + tools/describe || git log --parents HEAD~4.. + echo >>$GITHUB_ENV CP_VERSION=$(tools/describe) - uses: actions/cache@v2 name: Fetch IDF tool cache id: idf-cache @@ -451,16 +470,16 @@ jobs: board: ${{ fromJSON(needs.test.outputs.boards-aarch) }} if: ${{ needs.test.outputs.boards-aarch != '[]' }} steps: - - name: Set up Python 3.8 - uses: actions/setup-python@v1 + - name: Set up Python 3 + uses: actions/setup-python@v2 with: - python-version: 3.8 + python-version: "3.x" - uses: actions/checkout@v2.2.0 with: submodules: false fetch-depth: 1 - name: Get CP deps - run: python tools/ci_fetch_deps.py ${{ matrix.board }} ${{ github.ref }} + run: python tools/ci_fetch_deps.py ${{ matrix.board }} ${{ github.sha }} - name: Install dependencies run: | sudo apt-get install -y gettext mtools diff --git a/.github/workflows/create_website_pr.yml b/.github/workflows/create_website_pr.yml index ad33cca136..2f171fe054 100644 --- a/.github/workflows/create_website_pr.yml +++ b/.github/workflows/create_website_pr.yml @@ -20,12 +20,12 @@ jobs: with: submodules: false fetch-depth: 1 - - name: Set up Python 3.8 - uses: actions/setup-python@v1 + - name: Set up Python 3 + uses: actions/setup-python@v2 with: - python-version: 3.8 + python-version: "3.x" - name: Get CP deps - run: python tools/ci_fetch_deps.py website ${{ github.ref }} + run: python tools/ci_fetch_deps.py website ${{ github.sha }} - name: Install deps run: | pip install -r requirements-dev.txt @@ -34,7 +34,9 @@ jobs: gcc --version python3 --version - name: CircuitPython version - run: git describe --dirty --tags + run: | + tools/describe || git log --parents HEAD~4.. + echo >>$GITHUB_ENV CP_VERSION=$(tools/describe) - name: Website run: python3 build_board_info.py working-directory: tools diff --git a/.github/workflows/notify.yml b/.github/workflows/notify.yml new file mode 100644 index 0000000000..4cfb22298f --- /dev/null +++ b/.github/workflows/notify.yml @@ -0,0 +1,14 @@ +name: Notify users based on issue labels + +on: + issues: + types: [labeled] + +jobs: + notify: + runs-on: ubuntu-latest + steps: + - uses: jenschelkopf/issue-label-notification-action@1.3 + with: + recipients: | + ulab=@v923z diff --git a/.github/workflows/ports_windows.yml b/.github/workflows/ports_windows.yml index 8491c4026d..777497485d 100644 --- a/.github/workflows/ports_windows.yml +++ b/.github/workflows/ports_windows.yml @@ -12,6 +12,10 @@ on: - 'ports/unix/**' - 'ports/windows/**' +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + jobs: build: runs-on: windows-2019 @@ -70,11 +74,11 @@ jobs: submodules: false fetch-depth: 1 - name: Get CP deps - run: python tools/ci_fetch_deps.py windows ${{ github.ref }} + run: python tools/ci_fetch_deps.py windows ${{ github.sha }} - name: CircuitPython version run: | - git describe --dirty --tags - echo >>$GITHUB_ENV CP_VERSION=$(git describe --dirty --tags) + tools/describe || git log --parents HEAD~4.. + echo >>$GITHUB_ENV CP_VERSION=$(tools/describe) - name: build mpy-cross run: make -j2 -C mpy-cross diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 2a8811115e..52e2d2b714 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -8,12 +8,19 @@ on: pull_request: push: +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + jobs: pre-commit: runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v2.2.0 - - uses: actions/setup-python@v1 + - name: Set up Python 3 + uses: actions/setup-python@v2 + with: + python-version: "3.x" - name: Install deps run: | sudo apt-add-repository -y -u ppa:pybricks/ppa diff --git a/.gitmodules b/.gitmodules index 9376daebdc..43fc7672ad 100644 --- a/.gitmodules +++ b/.gitmodules @@ -116,9 +116,6 @@ [submodule "frozen/Adafruit_CircuitPython_Requests"] path = frozen/Adafruit_CircuitPython_Requests url = https://github.com/adafruit/Adafruit_CircuitPython_Requests -[submodule "ports/stm/st_driver"] - path = ports/stm/st_driver - url = https://github.com/hathach/st_driver.git [submodule "lib/protomatter"] path = lib/protomatter url = https://github.com/adafruit/Adafruit_Protomatter @@ -148,8 +145,8 @@ url = https://github.com/adafruit/Adafruit_CircuitPython_RFM69.git [submodule "ports/espressif/esp-idf"] path = ports/espressif/esp-idf - url = https://github.com/espressif/esp-idf.git - branch = release/v4.4 + url = https://github.com/adafruit/esp-idf.git + branch = circuitpython-v4.4 [submodule "ports/espressif/certificates/nina-fw"] path = ports/espressif/certificates/nina-fw url = https://github.com/adafruit/nina-fw.git @@ -199,3 +196,90 @@ url = https://github.com/raspberrypi/rpi-firmware.git branch = master shallow = true +[submodule "ports/stm/st_driver/cmsis_device_f4"] + path = ports/stm/st_driver/cmsis_device_f4 + url = https://github.com/STMicroelectronics/cmsis_device_f4.git +[submodule "ports/stm/st_driver/cmsis_device_f0"] + path = ports/stm/st_driver/cmsis_device_f0 + url = https://github.com/STMicroelectronics/cmsis_device_f0.git +[submodule "ports/stm/st_driver/stm32f0xx_hal_driver"] + path = ports/stm/st_driver/stm32f0xx_hal_driver + url = https://github.com/STMicroelectronics/stm32f0xx_hal_driver.git +[submodule "ports/stm/st_driver/cmsis_device_f1"] + path = ports/stm/st_driver/cmsis_device_f1 + url = https://github.com/STMicroelectronics/cmsis_device_f1.git +[submodule "ports/stm/st_driver/stm32f1xx_hal_driver"] + path = ports/stm/st_driver/stm32f1xx_hal_driver + url = https://github.com/STMicroelectronics/stm32f1xx_hal_driver.git +[submodule "ports/stm/st_driver/cmsis_device_f2"] + path = ports/stm/st_driver/cmsis_device_f2 + url = https://github.com/STMicroelectronics/cmsis_device_f2.git +[submodule "ports/stm/st_driver/stm32f2xx_hal_driver"] + path = ports/stm/st_driver/stm32f2xx_hal_driver + url = https://github.com/STMicroelectronics/stm32f2xx_hal_driver.git +[submodule "ports/stm/st_driver/cmsis_device_f3"] + path = ports/stm/st_driver/cmsis_device_f3 + url = https://github.com/STMicroelectronics/cmsis_device_f3.git +[submodule "ports/stm/st_driver/stm32f3xx_hal_driver"] + path = ports/stm/st_driver/stm32f3xx_hal_driver + url = https://github.com/STMicroelectronics/stm32f3xx_hal_driver.git +[submodule "ports/stm/st_driver/cmsis_device_f7"] + path = ports/stm/st_driver/cmsis_device_f7 + url = https://github.com/STMicroelectronics/cmsis_device_f7.git +[submodule "ports/stm/st_driver/stm32f7xx_hal_driver"] + path = ports/stm/st_driver/stm32f7xx_hal_driver + url = https://github.com/STMicroelectronics/stm32f7xx_hal_driver.git +[submodule "ports/stm/st_driver/cmsis_device_h7"] + path = ports/stm/st_driver/cmsis_device_h7 + url = https://github.com/STMicroelectronics/cmsis_device_h7.git +[submodule "ports/stm/st_driver/stm32h7xx_hal_driver"] + path = ports/stm/st_driver/stm32h7xx_hal_driver + url = https://github.com/STMicroelectronics/stm32h7xx_hal_driver.git +[submodule "ports/stm/st_driver/cmsis_device_l0"] + path = ports/stm/st_driver/cmsis_device_l0 + url = https://github.com/STMicroelectronics/cmsis_device_l0.git +[submodule "ports/stm/st_driver/stm32l0xx_hal_driver"] + path = ports/stm/st_driver/stm32l0xx_hal_driver + url = https://github.com/STMicroelectronics/stm32l0xx_hal_driver.git +[submodule "ports/stm/st_driver/cmsis_device_l1"] + path = ports/stm/st_driver/cmsis_device_l1 + url = https://github.com/STMicroelectronics/cmsis_device_l1.git +[submodule "ports/stm/st_driver/stm32l1xx_hal_driver"] + path = ports/stm/st_driver/stm32l1xx_hal_driver + url = https://github.com/STMicroelectronics/stm32l1xx_hal_driver.git +[submodule "ports/stm/st_driver/cmsis_device_l4"] + path = ports/stm/st_driver/cmsis_device_l4 + url = https://github.com/STMicroelectronics/cmsis_device_l4.git +[submodule "ports/stm/st_driver/stm32l4xx_hal_driver"] + path = ports/stm/st_driver/stm32l4xx_hal_driver + url = https://github.com/STMicroelectronics/stm32l4xx_hal_driver.git +[submodule "ports/stm/st_driver/cmsis_device_g0"] + path = ports/stm/st_driver/cmsis_device_g0 + url = https://github.com/STMicroelectronics/cmsis_device_g0.git +[submodule "ports/stm/st_driver/stm32g0xx_hal_driver"] + path = ports/stm/st_driver/stm32g0xx_hal_driver + url = https://github.com/STMicroelectronics/stm32g0xx_hal_driver.git +[submodule "ports/stm/st_driver/cmsis_device_g4"] + path = ports/stm/st_driver/cmsis_device_g4 + url = https://github.com/STMicroelectronics/cmsis_device_g4.git +[submodule "ports/stm/st_driver/stm32g4xx_hal_driver"] + path = ports/stm/st_driver/stm32g4xx_hal_driver + url = https://github.com/STMicroelectronics/stm32g4xx_hal_driver.git +[submodule "ports/stm/st_driver/cmsis_device_l5"] + path = ports/stm/st_driver/cmsis_device_l5 + url = https://github.com/STMicroelectronics/cmsis_device_l5.git +[submodule "ports/stm/st_driver/stm32l5xx_hal_driver"] + path = ports/stm/st_driver/stm32l5xx_hal_driver + url = https://github.com/STMicroelectronics/stm32l5xx_hal_driver.git +[submodule "ports/stm/st_driver/CMSIS_5"] + path = ports/stm/st_driver/CMSIS_5 + url = https://github.com/ARM-software/CMSIS_5.git +[submodule "ports/stm/st_driver/stm32f4xx_hal_driver"] + path = ports/stm/st_driver/stm32f4xx_hal_driver + url = https://github.com/adafruit/stm32f4xx_hal_driver.git +[submodule "frozen/Adafruit_CircuitPython_PortalBase"] + path = frozen/Adafruit_CircuitPython_PortalBase + url = https://github.com/adafruit/Adafruit_CircuitPython_PortalBase.git +[submodule "frozen/Adafruit_CircuitPython_FakeRequests"] + path = frozen/Adafruit_CircuitPython_FakeRequests + url = https://github.com/adafruit/Adafruit_CircuitPython_FakeRequests.git diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index cfee897258..bcf7f8da2b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,7 +4,7 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v2.3.0 + rev: v4.0.1 hooks: - id: check-yaml - id: end-of-file-fixer diff --git a/.readthedocs.yml b/.readthedocs.yml index 770888b79e..9743a70494 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -11,7 +11,7 @@ version: 2 build: os: ubuntu-20.04 tools: - python: "3.9" + python: "3" submodules: include: @@ -22,4 +22,4 @@ formats: python: install: - - requirements: docs/requirements.txt + - requirements: requirements-doc.txt diff --git a/BUILDING.md b/BUILDING.md index 0686df3c04..fc7b116595 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -15,7 +15,7 @@ https://learn.adafruit.com/building-circuitpython/ ## Setup -Please ensure you setup your build environment appropriately, as per the guide. You will need: +Please ensure you set up your build environment appropriately, as per the guide. You will need: * Linux: https://learn.adafruit.com/building-circuitpython/linux * MacOS: https://learn.adafruit.com/building-circuitpython/macos @@ -25,8 +25,9 @@ Please ensure you setup your build environment appropriately, as per the guide. This project has a bunch of git submodules. You will need to update them regularly. - git submodule sync - git submodule update --init +In the root folder of the CircuitPython repository, execute the following: + + make fetch-submodules ### Required Python Packages @@ -100,7 +101,7 @@ We apply code quality checks using pre-commit. Install pre-commit once per syst Activate it once per git clone with - pre-commit --install + pre-commit install Pre-commit also requires some additional programs to be installed through your package manager: diff --git a/LICENSE b/LICENSE index 5b5c37f7d1..2b9a64b89a 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2013-2021 Damien P. George +Copyright (c) 2013-2022 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 diff --git a/conf.py b/conf.py index fd92a3cc93..7818d78917 100644 --- a/conf.py +++ b/conf.py @@ -24,12 +24,15 @@ import subprocess import sys import urllib.parse import time +import pathlib from collections import defaultdict from sphinx.transforms import SphinxTransform from docutils import nodes from sphinx import addnodes +tools_describe = str(pathlib.Path(__file__).parent / "tools/describe") + # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. @@ -129,7 +132,7 @@ copyright = f'2014-{current_date.tm_year}, MicroPython & CircuitPython contribut final_version = "" git_describe = subprocess.run( - ["git", "describe", "--dirty", "--tags"], + [tools_describe], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, encoding="utf-8" diff --git a/data/nvm.toml b/data/nvm.toml index e5b149599d..266ea20ed8 160000 --- a/data/nvm.toml +++ b/data/nvm.toml @@ -1 +1 @@ -Subproject commit e5b149599d14a8841167fe552846ca36925b87a0 +Subproject commit 266ea20ed80104c315dcb124b482fa5f9f48cdec diff --git a/devices/ble_hci/common-hal/_bleio/__init__.c b/devices/ble_hci/common-hal/_bleio/__init__.c index 4a439e8dd2..d8a222ecfe 100644 --- a/devices/ble_hci/common-hal/_bleio/__init__.c +++ b/devices/ble_hci/common-hal/_bleio/__init__.c @@ -107,6 +107,6 @@ void common_hal_bleio_gc_collect(void) { } -void bleio_background(void) { +void bleio_hci_background(void) { bleio_adapter_background(&common_hal_bleio_adapter_obj); } diff --git a/devices/ble_hci/common-hal/_bleio/__init__.h b/devices/ble_hci/common-hal/_bleio/__init__.h index 18bf71834f..5c9bbcc979 100644 --- a/devices/ble_hci/common-hal/_bleio/__init__.h +++ b/devices/ble_hci/common-hal/_bleio/__init__.h @@ -34,8 +34,7 @@ #include "att.h" #include "hci.h" -void bleio_background(void); -void bleio_reset(void); +void bleio_hci_background(void); typedef struct { // ble_gap_enc_key_t own_enc; diff --git a/docs/library/framebuf.rst b/docs/library/framebuf.rst index 42b5c9e732..421066b82d 100644 --- a/docs/library/framebuf.rst +++ b/docs/library/framebuf.rst @@ -21,11 +21,11 @@ For example:: import framebuf # FrameBuffer needs 2 bytes for every RGB565 pixel - fbuf = framebuf.FrameBuffer(bytearray(10 * 100 * 2), 10, 100, framebuf.RGB565) + fbuf = framebuf.FrameBuffer(bytearray(100 * 10 * 2), 100, 10, framebuf.RGB565) fbuf.fill(0) fbuf.text('MicroPython!', 0, 0, 0xffff) - fbuf.hline(0, 10, 96, 0xffff) + fbuf.hline(0, 9, 96, 0xffff) Constructors ------------ diff --git a/docs/library/re.rst b/docs/library/re.rst index 12e640654e..d09ef59ba4 100644 --- a/docs/library/re.rst +++ b/docs/library/re.rst @@ -95,11 +95,11 @@ Supported operators and special sequences are: Example:: - import ure + import re - # As ure doesn't support escapes itself, use of r"" strings is not + # As re doesn't support escapes itself, use of r"" strings is not # recommended. - regex = ure.compile("[\r\n]") + regex = re.compile("[\r\n]") regex.split("line1\rline2\nline3\r\n") diff --git a/docs/library/sys.rst b/docs/library/sys.rst index aad01edbb2..a0675f0f50 100644 --- a/docs/library/sys.rst +++ b/docs/library/sys.rst @@ -80,6 +80,14 @@ Constants A mutable list of directories to search for imported modules. + .. admonition:: Difference to CPython + :class: attention + + On MicroPython, an entry with the value ``".frozen"`` will indicate that import + should search :term:`frozen modules ` at that point in the search. + If no frozen module is found then search will *not* look for a directory called + ``.frozen``, instead it will continue with the next entry in ``sys.path``. + .. data:: platform The platform that CircuitPython is running on. For OS/RTOS ports, this is diff --git a/docs/requirements.txt b/docs/requirements.txt deleted file mode 100644 index aa3be74265..0000000000 --- a/docs/requirements.txt +++ /dev/null @@ -1,8 +0,0 @@ -sphinx<4 -myst-parser==0.14.0 -sphinxcontrib-svg2pdfconverter==0.1.0 -astroid -sphinx-autoapi -isort -black -readthedocs-sphinx-search diff --git a/docs/templates/breadcrumbs.html b/docs/templates/breadcrumbs.html new file mode 100644 index 0000000000..4ecb013f86 --- /dev/null +++ b/docs/templates/breadcrumbs.html @@ -0,0 +1,4 @@ +{%- extends "sphinx_rtd_theme/breadcrumbs.html" %} + +{% block breadcrumbs_aside %} +{% endblock %} diff --git a/examples/natmod/btree/btree_c.c b/examples/natmod/btree/btree_c.c index 5e8a34ac40..b44b7bb300 100644 --- a/examples/natmod/btree/btree_c.c +++ b/examples/natmod/btree/btree_c.c @@ -18,7 +18,7 @@ void *memmove(void *dest, const void *src, size_t n) { } void *malloc(size_t n) { - void *ptr = m_malloc(n); + void *ptr = m_malloc(n, false); return ptr; } void *realloc(void *ptr, size_t n) { @@ -26,7 +26,7 @@ void *realloc(void *ptr, size_t n) { return NULL; } void *calloc(size_t n, size_t m) { - void *ptr = m_malloc(n * m); + void *ptr = m_malloc(n * m, false); // memory already cleared by conservative GC return ptr; } @@ -51,7 +51,7 @@ int *__errno (void) ssize_t mp_stream_posix_write(void *stream, const void *buf, size_t len) { mp_obj_base_t* o = stream; - const mp_stream_p_t *stream_p = o->type->protocol; + const mp_stream_p_t *stream_p = o->type->ext[0].protocol; mp_uint_t out_sz = stream_p->write(MP_OBJ_FROM_PTR(stream), buf, len, &native_errno); if (out_sz == MP_STREAM_ERROR) { return -1; @@ -62,7 +62,7 @@ ssize_t mp_stream_posix_write(void *stream, const void *buf, size_t len) { ssize_t mp_stream_posix_read(void *stream, void *buf, size_t len) { mp_obj_base_t* o = stream; - const mp_stream_p_t *stream_p = o->type->protocol; + const mp_stream_p_t *stream_p = o->type->ext[0].protocol; mp_uint_t out_sz = stream_p->read(MP_OBJ_FROM_PTR(stream), buf, len, &native_errno); if (out_sz == MP_STREAM_ERROR) { return -1; @@ -73,7 +73,7 @@ ssize_t mp_stream_posix_read(void *stream, void *buf, size_t len) { off_t mp_stream_posix_lseek(void *stream, off_t offset, int whence) { const mp_obj_base_t* o = stream; - const mp_stream_p_t *stream_p = o->type->protocol; + const mp_stream_p_t *stream_p = o->type->ext[0].protocol; struct mp_stream_seek_t seek_s; seek_s.offset = offset; seek_s.whence = whence; @@ -86,7 +86,7 @@ off_t mp_stream_posix_lseek(void *stream, off_t offset, int whence) { int mp_stream_posix_fsync(void *stream) { mp_obj_base_t* o = stream; - const mp_stream_p_t *stream_p = o->type->protocol; + const mp_stream_p_t *stream_p = o->type->ext[0].protocol; mp_uint_t res = stream_p->ioctl(MP_OBJ_FROM_PTR(stream), MP_STREAM_FLUSH, 0, &native_errno); if (res == MP_STREAM_ERROR) { return -1; @@ -94,7 +94,7 @@ int mp_stream_posix_fsync(void *stream) { return res; } -mp_obj_type_t btree_type; +mp_obj_full_type_t btree_type; #include "extmod/modbtree.c" @@ -123,12 +123,13 @@ mp_obj_t mpy_init(mp_obj_fun_bc_t *self, size_t n_args, size_t n_kw, mp_obj_t *a MP_DYNRUNTIME_INIT_ENTRY btree_type.base.type = (void*)&mp_fun_table.type_type; + btree_type.flags = MP_TYPE_FLAG_EXTENDED; btree_type.name = MP_QSTR_btree; btree_type.print = btree_print; - btree_type.getiter = btree_getiter; - btree_type.iternext = btree_iternext; - btree_type.binary_op = btree_binary_op; - btree_type.subscr = btree_subscr; + btree_type.ext[0].getiter = btree_getiter; + btree_type.ext[0].iternext = btree_iternext; + btree_type.ext[0].binary_op = btree_binary_op; + btree_type.ext[0].subscr = btree_subscr; btree_locals_dict_table[0] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_close), MP_OBJ_FROM_PTR(&btree_close_obj) }; btree_locals_dict_table[1] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_flush), MP_OBJ_FROM_PTR(&btree_flush_obj) }; btree_locals_dict_table[2] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_get), MP_OBJ_FROM_PTR(&btree_get_obj) }; diff --git a/examples/natmod/framebuf/framebuf.c b/examples/natmod/framebuf/framebuf.c index 8d488cffd6..4497ab3318 100644 --- a/examples/natmod/framebuf/framebuf.c +++ b/examples/natmod/framebuf/framebuf.c @@ -8,7 +8,7 @@ void *memset(void *s, int c, size_t n) { } #endif -mp_obj_type_t mp_type_framebuf; +mp_obj_full_type_t mp_type_framebuf; #include "extmod/modframebuf.c" @@ -19,9 +19,10 @@ mp_obj_t mpy_init(mp_obj_fun_bc_t *self, size_t n_args, size_t n_kw, mp_obj_t *a MP_DYNRUNTIME_INIT_ENTRY mp_type_framebuf.base.type = (void*)&mp_type_type; + mp_type_framebuf.flags = MP_TYPE_FLAG_EXTENDED; mp_type_framebuf.name = MP_QSTR_FrameBuffer; mp_type_framebuf.make_new = framebuf_make_new; - mp_type_framebuf.buffer_p.get_buffer = framebuf_get_buffer; + mp_type_framebuf.ext[0].buffer_p.get_buffer = framebuf_get_buffer; framebuf_locals_dict_table[0] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_fill), MP_OBJ_FROM_PTR(&framebuf_fill_obj) }; framebuf_locals_dict_table[1] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_fill_rect), MP_OBJ_FROM_PTR(&framebuf_fill_rect_obj) }; framebuf_locals_dict_table[2] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_pixel), MP_OBJ_FROM_PTR(&framebuf_pixel_obj) }; diff --git a/examples/natmod/uzlib/uzlib.c b/examples/natmod/uzlib/uzlib.c index 99b3691761..6df9944d6a 100644 --- a/examples/natmod/uzlib/uzlib.c +++ b/examples/natmod/uzlib/uzlib.c @@ -8,7 +8,8 @@ void *memset(void *s, int c, size_t n) { } #endif -mp_obj_type_t decompio_type; +mp_obj_full_type_t decompio_type; +mp_stream_p_t decompio_stream_p; #include "extmod/moduzlib.c" @@ -18,10 +19,14 @@ STATIC MP_DEFINE_CONST_DICT(decompio_locals_dict, decompio_locals_dict_table); mp_obj_t mpy_init(mp_obj_fun_bc_t *self, size_t n_args, size_t n_kw, mp_obj_t *args) { MP_DYNRUNTIME_INIT_ENTRY + decompio_stream_p.name = MP_QSTR_protocol_stream; + decompio_stream_p.read = decompio_read; + decompio_type.base.type = mp_fun_table.type_type; + decompio_type.flags = MP_TYPE_FLAG_EXTENDED; decompio_type.name = MP_QSTR_DecompIO; decompio_type.make_new = decompio_make_new; - decompio_type.protocol = &decompio_stream_p; + decompio_type.ext[0].protocol = &decompio_stream_p; decompio_locals_dict_table[0] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_read), MP_OBJ_FROM_PTR(&mp_stream_read_obj) }; decompio_locals_dict_table[1] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_readinto), MP_OBJ_FROM_PTR(&mp_stream_readinto_obj) }; decompio_locals_dict_table[2] = (mp_map_elem_t){ MP_OBJ_NEW_QSTR(MP_QSTR_readline), MP_OBJ_FROM_PTR(&mp_stream_unbuffered_readline_obj) }; diff --git a/extmod/extmod.cmake b/extmod/extmod.cmake index c6b45b0d3e..67f7d8fd39 100644 --- a/extmod/extmod.cmake +++ b/extmod/extmod.cmake @@ -10,11 +10,13 @@ set(MICROPY_SOURCE_EXTMOD ${MICROPY_EXTMOD_DIR}/machine_i2c.c ${MICROPY_EXTMOD_DIR}/machine_mem.c ${MICROPY_EXTMOD_DIR}/machine_pulse.c + ${MICROPY_EXTMOD_DIR}/machine_pwm.c ${MICROPY_EXTMOD_DIR}/machine_signal.c ${MICROPY_EXTMOD_DIR}/machine_spi.c ${MICROPY_EXTMOD_DIR}/modbluetooth.c ${MICROPY_EXTMOD_DIR}/modbtree.c ${MICROPY_EXTMOD_DIR}/modframebuf.c + ${MICROPY_EXTMOD_DIR}/modnetwork.c ${MICROPY_EXTMOD_DIR}/modonewire.c ${MICROPY_EXTMOD_DIR}/moduasyncio.c ${MICROPY_EXTMOD_DIR}/modubinascii.c @@ -23,9 +25,11 @@ set(MICROPY_SOURCE_EXTMOD ${MICROPY_EXTMOD_DIR}/moduhashlib.c ${MICROPY_EXTMOD_DIR}/moduheapq.c ${MICROPY_EXTMOD_DIR}/modujson.c + ${MICROPY_EXTMOD_DIR}/moduplatform.c ${MICROPY_EXTMOD_DIR}/modurandom.c ${MICROPY_EXTMOD_DIR}/modure.c ${MICROPY_EXTMOD_DIR}/moduselect.c + ${MICROPY_EXTMOD_DIR}/modusocket.c ${MICROPY_EXTMOD_DIR}/modussl_axtls.c ${MICROPY_EXTMOD_DIR}/modussl_mbedtls.c ${MICROPY_EXTMOD_DIR}/modutimeq.c diff --git a/extmod/modbtree.c b/extmod/modbtree.c index 25bafaaee4..5f4b4696b4 100644 --- a/extmod/modbtree.c +++ b/extmod/modbtree.c @@ -47,7 +47,7 @@ void __dbpanic(DB *db) { STATIC mp_obj_btree_t *btree_new(DB *db, mp_obj_t stream) { mp_obj_btree_t *o = m_new_obj(mp_obj_btree_t); - o->base.type = &btree_type; + o->base.type = (mp_obj_type_t *)&btree_type; o->stream = stream; o->db = db; o->start_key = mp_const_none; diff --git a/extmod/modframebuf.c b/extmod/modframebuf.c index fa07b69522..a90f00c347 100644 --- a/extmod/modframebuf.c +++ b/extmod/modframebuf.c @@ -622,7 +622,7 @@ STATIC const mp_obj_type_t mp_type_framebuf = { // this factory function is provided for backwards compatibility with old FrameBuffer1 class STATIC mp_obj_t legacy_framebuffer1(size_t n_args, const mp_obj_t *args) { mp_obj_framebuf_t *o = m_new_obj(mp_obj_framebuf_t); - o->base.type = &mp_type_framebuf; + o->base.type = (mp_obj_type_t *)&mp_type_framebuf; mp_buffer_info_t bufinfo; mp_get_buffer_raise(args[0], &bufinfo, MP_BUFFER_WRITE); diff --git a/extmod/modonewire.c b/extmod/modonewire.c index a963c17ebb..ba7405fbae 100644 --- a/extmod/modonewire.c +++ b/extmod/modonewire.c @@ -9,6 +9,8 @@ #include "py/obj.h" #include "py/mphal.h" +#if MICROPY_PY_ONEWIRE + /******************************************************************************/ // Low-level 1-Wire routines @@ -139,3 +141,5 @@ const mp_obj_module_t mp_module_onewire = { .base = { &mp_type_module }, .globals = (mp_obj_dict_t *)&onewire_module_globals, }; + +#endif // MICROPY_PY_ONEWIRE diff --git a/extmod/moduasyncio.c b/extmod/moduasyncio.c index 1f5cc618d0..016ffcbc99 100644 --- a/extmod/moduasyncio.c +++ b/extmod/moduasyncio.c @@ -29,6 +29,10 @@ #include "py/pairheap.h" #include "py/mphal.h" +#if CIRCUITPY && !(defined(__unix__) || defined(__APPLE__)) +#include "shared-bindings/supervisor/__init__.h" +#endif + #if MICROPY_PY_UASYNCIO // Used when task cannot be guaranteed to be non-NULL. @@ -59,10 +63,12 @@ STATIC const mp_obj_type_t task_queue_type; STATIC const mp_obj_type_t task_type; STATIC mp_obj_t task_queue_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args); +STATIC mp_obj_t task_getiter(mp_obj_t self_in, mp_obj_iter_buf_t *iter_buf); /******************************************************************************/ // Ticks for task ordering in pairing heap +#if !CIRCUITPY || (defined(__unix__) || defined(__APPLE__)) STATIC mp_obj_t ticks(void) { return MP_OBJ_NEW_SMALL_INT(mp_hal_ticks_ms() & (MICROPY_PY_UTIME_TICKS_PERIOD - 1)); } @@ -74,6 +80,20 @@ STATIC mp_int_t ticks_diff(mp_obj_t t1_in, mp_obj_t t0_in) { - MICROPY_PY_UTIME_TICKS_PERIOD / 2; return diff; } +#else +#define _TICKS_PERIOD (1lu << 29) +#define _TICKS_MAX (_TICKS_PERIOD - 1) +#define _TICKS_HALFPERIOD (_TICKS_PERIOD >> 1) + +#define ticks() supervisor_ticks_ms() + +STATIC mp_int_t ticks_diff(mp_obj_t t1_in, mp_obj_t t0_in) { + mp_uint_t t0 = MP_OBJ_SMALL_INT_VALUE(t0_in); + mp_uint_t t1 = MP_OBJ_SMALL_INT_VALUE(t1_in); + mp_int_t diff = ((t1 - t0 + _TICKS_HALFPERIOD) & _TICKS_MAX) - _TICKS_HALFPERIOD; + return diff; +} +#endif STATIC int task_lt(mp_pairheap_t *n1, mp_pairheap_t *n2) { mp_obj_task_t *t1 = (mp_obj_task_t *)n1; @@ -225,6 +245,11 @@ STATIC mp_obj_t task_cancel(mp_obj_t self_in) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(task_cancel_obj, task_cancel); +STATIC mp_obj_t task_await(mp_obj_t self_in) { + return task_getiter(self_in, NULL); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(task_await_obj, task_await); + STATIC void task_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { mp_obj_task_t *self = MP_OBJ_TO_PTR(self_in); if (dest[0] == MP_OBJ_NULL) { @@ -243,6 +268,9 @@ STATIC void task_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { dest[1] = self_in; } else if (attr == MP_QSTR_ph_key) { dest[0] = self->ph_key; + } else if (attr == MP_QSTR___await__) { + dest[0] = MP_OBJ_FROM_PTR(&task_await_obj); + dest[1] = self_in; } } else if (dest[1] != MP_OBJ_NULL) { // Store @@ -301,7 +329,11 @@ STATIC const mp_obj_type_t task_type = { // C-level uasyncio module STATIC const mp_rom_map_elem_t mp_module_uasyncio_globals_table[] = { + #if CIRCUITPY + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR__asyncio) }, + #else { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR__uasyncio) }, + #endif { MP_ROM_QSTR(MP_QSTR_TaskQueue), MP_ROM_PTR(&task_queue_type) }, { MP_ROM_QSTR(MP_QSTR_Task), MP_ROM_PTR(&task_type) }, }; @@ -312,4 +344,6 @@ const mp_obj_module_t mp_module_uasyncio = { .globals = (mp_obj_dict_t *)&mp_module_uasyncio_globals, }; +MP_REGISTER_MODULE(MP_QSTR__asyncio, mp_module_uasyncio, MICROPY_PY_UASYNCIO); + #endif // MICROPY_PY_UASYNCIO diff --git a/extmod/modubinascii.c b/extmod/modubinascii.c index b11b8bf8a8..7157be31fa 100644 --- a/extmod/modubinascii.c +++ b/extmod/modubinascii.c @@ -1,5 +1,6 @@ // Copyright (c) 2014 Paul Sokolovsky // SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors) +// SPDX-FileCopyrightText: 2022 Beat Ludin for Adafruit Industries // // SPDX-License-Identifier: MIT @@ -204,19 +205,78 @@ STATIC mp_obj_t mod_binascii_b2a_base64(mp_obj_t data) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_binascii_b2a_base64_obj, mod_binascii_b2a_base64); -#if MICROPY_PY_UBINASCII_CRC32 -#include "lib/uzlib/tinf.h" +/* + * CRC32 checksum + * + * Copyright (c) 1998-2003 by Joergen Ibsen / Jibz + * All Rights Reserved + * + * http://www.ibsensoftware.com/ + * + * This software is provided 'as-is', without any express + * or implied warranty. In no event will the authors be + * held liable for any damages arising from the use of + * this software. + * + * Permission is granted to anyone to use this software + * for any purpose, including commercial applications, + * and to alter it and redistribute it freely, subject to + * the following restrictions: + * + * 1. The origin of this software must not be + * misrepresented; you must not claim that you + * wrote the original software. If you use this + * software in a product, an acknowledgment in + * the product documentation would be appreciated + * but is not required. + * + * 2. Altered source versions must be plainly marked + * as such, and must not be misrepresented as + * being the original software. + * + * 3. This notice may not be removed or altered from + * any source distribution. + */ + +/* + * CRC32 algorithm taken from the zlib source, which is + * Copyright (C) 1995-1998 Jean-loup Gailly and Mark Adler + */ + + +static const unsigned int tinf_crc32tab[16] = { + 0x00000000, 0x1db71064, 0x3b6e20c8, 0x26d930ac, 0x76dc4190, + 0x6b6b51f4, 0x4db26158, 0x5005713c, 0xedb88320, 0xf00f9344, + 0xd6d6a3e8, 0xcb61b38c, 0x9b64c2b0, 0x86d3d2d4, 0xa00ae278, + 0xbdbdf21c +}; + +/* crc is previous value for incremental computation, 0xffffffff initially */ +static uint32_t from_uzlib_crc32(const void *data, unsigned int length, uint32_t crc) { + const unsigned char *buf = (const unsigned char *)data; + unsigned int i; + + for (i = 0; i < length; ++i) + { + crc ^= buf[i]; + crc = tinf_crc32tab[crc & 0x0f] ^ (crc >> 4); + crc = tinf_crc32tab[crc & 0x0f] ^ (crc >> 4); + } + + // return value suitable for passing in next time, for final value invert it + return crc /* ^ 0xffffffff*/; +} STATIC mp_obj_t mod_binascii_crc32(size_t n_args, const mp_obj_t *args) { mp_buffer_info_t bufinfo; check_not_unicode(args[0]); mp_get_buffer_raise(args[0], &bufinfo, MP_BUFFER_READ); uint32_t crc = (n_args > 1) ? mp_obj_get_int_truncated(args[1]) : 0; - crc = uzlib_crc32(bufinfo.buf, bufinfo.len, crc ^ 0xffffffff); + crc = from_uzlib_crc32(bufinfo.buf, bufinfo.len, crc ^ 0xffffffff); return mp_obj_new_int_from_uint(crc ^ 0xffffffff); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_binascii_crc32_obj, 1, 2, mod_binascii_crc32); -#endif + STATIC const mp_rom_map_elem_t mp_module_binascii_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_binascii) }, @@ -224,9 +284,7 @@ STATIC const mp_rom_map_elem_t mp_module_binascii_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_unhexlify), MP_ROM_PTR(&mod_binascii_unhexlify_obj) }, { MP_ROM_QSTR(MP_QSTR_a2b_base64), MP_ROM_PTR(&mod_binascii_a2b_base64_obj) }, { MP_ROM_QSTR(MP_QSTR_b2a_base64), MP_ROM_PTR(&mod_binascii_b2a_base64_obj) }, - #if MICROPY_PY_UBINASCII_CRC32 { MP_ROM_QSTR(MP_QSTR_crc32), MP_ROM_PTR(&mod_binascii_crc32_obj) }, - #endif }; STATIC MP_DEFINE_CONST_DICT(mp_module_binascii_globals, mp_module_binascii_globals_table); diff --git a/extmod/moduplatform.c b/extmod/moduplatform.c new file mode 100644 index 0000000000..820feb312a --- /dev/null +++ b/extmod/moduplatform.c @@ -0,0 +1,146 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2013-2021 Ibrahim Abdelkader + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + */ + +#include "py/runtime.h" +#include "py/objtuple.h" +#include "py/objstr.h" +#include "py/mphal.h" +#include "genhdr/mpversion.h" + +#if MICROPY_PY_UPLATFORM + +// platform - Access to underlying platform's identifying data + +// TODO: Add more architectures, compilers and libraries. +// See: https://sourceforge.net/p/predef/wiki/Home/ + +#if defined(__ARM_ARCH) +#define PLATFORM_ARCH "arm" +#elif defined(__x86_64__) || defined(_WIN64) +#define PLATFORM_ARCH "x86_64" +#elif defined(__i386__) || defined(_M_IX86) +#define PLATFORM_ARCH "x86" +#elif defined(__xtensa__) || defined(_M_IX86) +#define PLATFORM_ARCH "xtensa" +#else +#define PLATFORM_ARCH "" +#endif + +#if defined(__GNUC__) +#define PLATFORM_COMPILER \ + "GCC " \ + MP_STRINGIFY(__GNUC__) "." \ + MP_STRINGIFY(__GNUC_MINOR__) "." \ + MP_STRINGIFY(__GNUC_PATCHLEVEL__) +#elif defined(__ARMCC_VERSION) +#define PLATFORM_COMPILER \ + "ARMCC " \ + MP_STRINGIFY((__ARMCC_VERSION / 1000000)) "." \ + MP_STRINGIFY((__ARMCC_VERSION / 10000 % 100)) "." \ + MP_STRINGIFY((__ARMCC_VERSION % 10000)) +#elif defined(_MSC_VER) +#if defined(_WIN64) +#define COMPILER_BITS "64 bit" +#elif defined(_M_IX86) +#define COMPILER_BITS "32 bit" +#else +#define COMPILER_BITS "" +#endif +#define PLATFORM_COMPILER \ + "MSC v." MP_STRINGIFY(_MSC_VER) " " COMPILER_BITS +#else +#define PLATFORM_COMPILER "" +#endif + +#if defined(__GLIBC__) +#define PLATFORM_LIBC_LIB "glibc" +#define PLATFORM_LIBC_VER \ + MP_STRINGIFY(__GLIBC__) "." \ + MP_STRINGIFY(__GLIBC_MINOR__) +#elif defined(__NEWLIB__) +#define PLATFORM_LIBC_LIB "newlib" +#define PLATFORM_LIBC_VER _NEWLIB_VERSION +#else +#define PLATFORM_LIBC_LIB "" +#define PLATFORM_LIBC_VER "" +#endif + +#if defined(__linux) +#define PLATFORM_SYSTEM "Linux" +#elif defined(__unix__) +#define PLATFORM_SYSTEM "Unix" +#elif defined(__CYGWIN__) +#define PLATFORM_SYSTEM "Cygwin" +#elif defined(_WIN32) +#define PLATFORM_SYSTEM "Windows" +#else +#define PLATFORM_SYSTEM "MicroPython" +#endif + +#ifndef MICROPY_PLATFORM_VERSION +#define MICROPY_PLATFORM_VERSION "" +#endif + +STATIC const MP_DEFINE_STR_OBJ(info_platform_obj, PLATFORM_SYSTEM "-" MICROPY_VERSION_STRING "-" \ + PLATFORM_ARCH "-" MICROPY_PLATFORM_VERSION "-with-" PLATFORM_LIBC_LIB "" PLATFORM_LIBC_VER); +STATIC const MP_DEFINE_STR_OBJ(info_python_compiler_obj, PLATFORM_COMPILER); +STATIC const MP_DEFINE_STR_OBJ(info_libc_lib_obj, PLATFORM_LIBC_LIB); +STATIC const MP_DEFINE_STR_OBJ(info_libc_ver_obj, PLATFORM_LIBC_VER); +STATIC const mp_rom_obj_tuple_t info_libc_tuple_obj = { + {&mp_type_tuple}, 2, {MP_ROM_PTR(&info_libc_lib_obj), MP_ROM_PTR(&info_libc_ver_obj)} +}; + +STATIC mp_obj_t platform_platform(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + return MP_OBJ_FROM_PTR(&info_platform_obj); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_KW(platform_platform_obj, 0, platform_platform); + +STATIC mp_obj_t platform_python_compiler(void) { + return MP_OBJ_FROM_PTR(&info_python_compiler_obj); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_0(platform_python_compiler_obj, platform_python_compiler); + +STATIC mp_obj_t platform_libc_ver(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + return MP_OBJ_FROM_PTR(&info_libc_tuple_obj); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_KW(platform_libc_ver_obj, 0, platform_libc_ver); + +STATIC const mp_rom_map_elem_t modplatform_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_uplatform) }, + { MP_ROM_QSTR(MP_QSTR_platform), MP_ROM_PTR(&platform_platform_obj) }, + { MP_ROM_QSTR(MP_QSTR_python_compiler), MP_ROM_PTR(&platform_python_compiler_obj) }, + { MP_ROM_QSTR(MP_QSTR_libc_ver), MP_ROM_PTR(&platform_libc_ver_obj) }, +}; + +STATIC MP_DEFINE_CONST_DICT(modplatform_globals, modplatform_globals_table); + +const mp_obj_module_t mp_module_uplatform = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t *)&modplatform_globals, +}; + +#endif // MICROPY_PY_UPLATFORM diff --git a/extmod/modure.c b/extmod/modure.c index cca74a7267..c65eddb988 100644 --- a/extmod/modure.c +++ b/extmod/modure.c @@ -477,11 +477,16 @@ MP_REGISTER_MODULE(MP_QSTR_re, mp_module_ure, MICROPY_PY_URE); // only if module is enabled by config setting. #define re1_5_fatal(x) assert(!x) + #include "lib/re1.5/compilecode.c" -#if MICROPY_PY_URE_DEBUG -#include "lib/re1.5/dumpcode.c" -#endif #include "lib/re1.5/recursiveloop.c" #include "lib/re1.5/charclass.c" +#if MICROPY_PY_URE_DEBUG +// Make sure the output print statements go to the same output as other Python output. +#define printf(...) mp_printf(&mp_plat_print, __VA_ARGS__) +#include "lib/re1.5/dumpcode.c" +#undef printf +#endif + #endif // MICROPY_PY_URE diff --git a/extmod/moduzlib.c b/extmod/moduzlib.c index 7f2dad476f..b1eeac934b 100644 --- a/extmod/moduzlib.c +++ b/extmod/moduzlib.c @@ -114,12 +114,12 @@ STATIC const mp_rom_map_elem_t decompio_locals_dict_table[] = { STATIC MP_DEFINE_CONST_DICT(decompio_locals_dict, decompio_locals_dict_table); #endif +#if !MICROPY_ENABLE_DYNRUNTIME STATIC const mp_stream_p_t decompio_stream_p = { MP_PROTO_IMPLEMENT(MP_QSTR_protocol_stream) .read = decompio_read, }; -#if !MICROPY_ENABLE_DYNRUNTIME STATIC const mp_obj_type_t decompio_type = { { &mp_type_type }, .flags = MP_TYPE_FLAG_EXTENDED, diff --git a/extmod/uasyncio/core.py b/extmod/uasyncio/core.py index 12833cf0cd..c3ce3ccafa 100644 --- a/extmod/uasyncio/core.py +++ b/extmod/uasyncio/core.py @@ -36,7 +36,7 @@ class SingletonGenerator: self.state = None self.exc = StopIteration() - def __iter__(self): + def __await__(self): return self def __next__(self): diff --git a/extmod/uasyncio/funcs.py b/extmod/uasyncio/funcs.py index 93f4fd256c..0ce48b015c 100644 --- a/extmod/uasyncio/funcs.py +++ b/extmod/uasyncio/funcs.py @@ -66,7 +66,7 @@ async def gather(*aws, return_exceptions=False): # # cancel all waiting tasks # raise er ts[i] = await ts[i] - except Exception as er: + except (core.CancelledError, Exception) as er: if return_exceptions: ts[i] = er else: diff --git a/extmod/uasyncio/task.py b/extmod/uasyncio/task.py index 26df7b1725..cd75a14a09 100644 --- a/extmod/uasyncio/task.py +++ b/extmod/uasyncio/task.py @@ -130,7 +130,7 @@ class Task: self.ph_next = None # Paring heap self.ph_rightmost_parent = None # Paring heap - def __iter__(self): + def __await__(self): if not self.state: # Task finished, signal that is has been await'ed on. self.state = False diff --git a/extmod/ulab b/extmod/ulab index c03990cc56..5d01882c41 160000 --- a/extmod/ulab +++ b/extmod/ulab @@ -1 +1 @@ -Subproject commit c03990cc56283417e752246c2738199f65d1b7ef +Subproject commit 5d01882c41dbc4115bc94f0b61c093d5a6b812b6 diff --git a/extmod/vfs_fat_file.c b/extmod/vfs_fat_file.c index 17b142b95a..65ee5f9024 100644 --- a/extmod/vfs_fat_file.c +++ b/extmod/vfs_fat_file.c @@ -139,39 +139,58 @@ STATIC const mp_arg_t file_open_args[] = { STATIC mp_obj_t file_open(fs_user_mount_t *vfs, const mp_obj_type_t *type, mp_arg_val_t *args) { int mode = 0; const char *mode_s = mp_obj_str_get_str(args[1].u_obj); - // TODO make sure only one of r, w, x, a, and b, t are specified + uint32_t rwxa_count = 0; + uint32_t bt_count = 0; + uint32_t plus_count = 0; + bool bad_mode = false; while (*mode_s) { switch (*mode_s++) { case 'r': mode |= FA_READ; + rwxa_count++; break; case 'w': mode |= FA_WRITE | FA_CREATE_ALWAYS; + rwxa_count++; break; case 'x': mode |= FA_WRITE | FA_CREATE_NEW; + rwxa_count++; break; case 'a': mode |= FA_WRITE | FA_OPEN_ALWAYS; + rwxa_count++; break; case '+': mode |= FA_READ | FA_WRITE; + plus_count++; break; #if MICROPY_PY_IO_FILEIO case 'b': + bt_count++; type = &mp_type_vfs_fat_fileio; break; #endif case 't': + bt_count++; type = &mp_type_vfs_fat_textio; break; + default: + bad_mode = true; + break; } } + + if (rwxa_count != 1 || plus_count > 1 || bt_count > 1 || bad_mode) { + mp_raise_ValueError(translate("Invalid mode")); + } + assert(vfs != NULL); if ((mode & FA_WRITE) != 0 && !filesystem_is_writable_by_python(vfs)) { mp_raise_OSError(MP_EROFS); } + pyb_file_obj_t *o = m_new_obj_with_finaliser(pyb_file_obj_t); o->base.type = type; diff --git a/extmod/vfs_posix_file.c b/extmod/vfs_posix_file.c index 8837fdbbd6..a984ace4a2 100644 --- a/extmod/vfs_posix_file.c +++ b/extmod/vfs_posix_file.c @@ -17,6 +17,8 @@ #ifdef _WIN32 #define fsync _commit +#else +#include #endif typedef struct _mp_obj_vfs_posix_file_t { @@ -180,6 +182,32 @@ STATIC mp_uint_t vfs_posix_file_ioctl(mp_obj_t o_in, mp_uint_t request, uintptr_ return 0; case MP_STREAM_GET_FILENO: return o->fd; + #if MICROPY_PY_USELECT + case MP_STREAM_POLL: { + #ifdef _WIN32 + mp_raise_NotImplementedError(MP_ERROR_TEXT("poll on file not available on win32")); + #else + mp_uint_t ret = 0; + uint8_t pollevents = 0; + if (arg & MP_STREAM_POLL_RD) { + pollevents |= POLLIN; + } + if (arg & MP_STREAM_POLL_WR) { + pollevents |= POLLOUT; + } + struct pollfd pfd = { .fd = o->fd, .events = pollevents }; + if (poll(&pfd, 1, 0) > 0) { + if (pfd.revents & POLLIN) { + ret |= MP_STREAM_POLL_RD; + } + if (pfd.revents & POLLOUT) { + ret |= MP_STREAM_POLL_WR; + } + } + return ret; + #endif + } + #endif default: *errcode = EINVAL; return MP_STREAM_ERROR; diff --git a/frozen/Adafruit_CircuitPython_APDS9960 b/frozen/Adafruit_CircuitPython_APDS9960 index c55da0dee6..baab505fd4 160000 --- a/frozen/Adafruit_CircuitPython_APDS9960 +++ b/frozen/Adafruit_CircuitPython_APDS9960 @@ -1 +1 @@ -Subproject commit c55da0dee66302d2fa8ed31623d047c307f409b2 +Subproject commit baab505fd4dcc54d8e9d45e6463c68bdc6d100eb diff --git a/frozen/Adafruit_CircuitPython_BLE b/frozen/Adafruit_CircuitPython_BLE index 781f46b73f..beec030657 160000 --- a/frozen/Adafruit_CircuitPython_BLE +++ b/frozen/Adafruit_CircuitPython_BLE @@ -1 +1 @@ -Subproject commit 781f46b73f71817b709d2e279fc188a7c1e69423 +Subproject commit beec03065712cd62f79e839d5cf8f7c9847fc3b1 diff --git a/frozen/Adafruit_CircuitPython_BLE_Apple_Notification_Center b/frozen/Adafruit_CircuitPython_BLE_Apple_Notification_Center index c24a5310bc..859a7d403e 160000 --- a/frozen/Adafruit_CircuitPython_BLE_Apple_Notification_Center +++ b/frozen/Adafruit_CircuitPython_BLE_Apple_Notification_Center @@ -1 +1 @@ -Subproject commit c24a5310bc259cd9d93b1f42468e07f41d4b0e56 +Subproject commit 859a7d403e4e79ec1c8915c81ba581dbaab8a4ac diff --git a/frozen/Adafruit_CircuitPython_BusDevice b/frozen/Adafruit_CircuitPython_BusDevice index 169715b344..a8abc3aa8d 160000 --- a/frozen/Adafruit_CircuitPython_BusDevice +++ b/frozen/Adafruit_CircuitPython_BusDevice @@ -1 +1 @@ -Subproject commit 169715b3444c614e55827ccf79b35b2b5e11f1d2 +Subproject commit a8abc3aa8dece6c4d0152b001dfca7d2c279f899 diff --git a/frozen/Adafruit_CircuitPython_CircuitPlayground b/frozen/Adafruit_CircuitPython_CircuitPlayground index 2017afdfb4..b04042addd 160000 --- a/frozen/Adafruit_CircuitPython_CircuitPlayground +++ b/frozen/Adafruit_CircuitPython_CircuitPlayground @@ -1 +1 @@ -Subproject commit 2017afdfb43d3d9c5a73f8e85e951a583b18206a +Subproject commit b04042addd47c2645e139032b02a3b9ddeeb3425 diff --git a/frozen/Adafruit_CircuitPython_Crickit b/frozen/Adafruit_CircuitPython_Crickit index 8d09b29a1a..938f6bb335 160000 --- a/frozen/Adafruit_CircuitPython_Crickit +++ b/frozen/Adafruit_CircuitPython_Crickit @@ -1 +1 @@ -Subproject commit 8d09b29a1a92499dbbd10dd832f27db71057af5f +Subproject commit 938f6bb335ba5e4c56a8062c591ff9f3c18c4297 diff --git a/frozen/Adafruit_CircuitPython_DRV2605 b/frozen/Adafruit_CircuitPython_DRV2605 index 8a6ab89b7d..8e7e111a9f 160000 --- a/frozen/Adafruit_CircuitPython_DRV2605 +++ b/frozen/Adafruit_CircuitPython_DRV2605 @@ -1 +1 @@ -Subproject commit 8a6ab89b7d19f45a20b3f794cf900e23c9a8453b +Subproject commit 8e7e111a9ff39d3f4311caa7babeb451422c759f diff --git a/frozen/Adafruit_CircuitPython_DS3231 b/frozen/Adafruit_CircuitPython_DS3231 index 92a6ce1da7..df24498154 160000 --- a/frozen/Adafruit_CircuitPython_DS3231 +++ b/frozen/Adafruit_CircuitPython_DS3231 @@ -1 +1 @@ -Subproject commit 92a6ce1da70c0c4f69ef34fc0d7ec7155cc2441f +Subproject commit df2449815433e05ea0f89c19518ccde7a10a2faa diff --git a/frozen/Adafruit_CircuitPython_Display_Shapes b/frozen/Adafruit_CircuitPython_Display_Shapes index 313c17cbb5..708bb0c82c 160000 --- a/frozen/Adafruit_CircuitPython_Display_Shapes +++ b/frozen/Adafruit_CircuitPython_Display_Shapes @@ -1 +1 @@ -Subproject commit 313c17cbb590ef8d505845369eb3b78c25c97fae +Subproject commit 708bb0c82c7b075bd6912c97231aea880b1a1cb8 diff --git a/frozen/Adafruit_CircuitPython_Display_Text b/frozen/Adafruit_CircuitPython_Display_Text index ca141954c0..0bd04a2355 160000 --- a/frozen/Adafruit_CircuitPython_Display_Text +++ b/frozen/Adafruit_CircuitPython_Display_Text @@ -1 +1 @@ -Subproject commit ca141954c0b39cc0343c63bedb64c02f307159b9 +Subproject commit 0bd04a235556979bd13a373821a6602445fe132b diff --git a/frozen/Adafruit_CircuitPython_DotStar b/frozen/Adafruit_CircuitPython_DotStar index e070901177..eb6124fdff 160000 --- a/frozen/Adafruit_CircuitPython_DotStar +++ b/frozen/Adafruit_CircuitPython_DotStar @@ -1 +1 @@ -Subproject commit e07090117766d4a9ea2de07cd6f5418990cc598b +Subproject commit eb6124fdff59b98d7d49dd86072df99c0e97167b diff --git a/frozen/Adafruit_CircuitPython_ESP32SPI b/frozen/Adafruit_CircuitPython_ESP32SPI index e25c1801c5..13775b0584 160000 --- a/frozen/Adafruit_CircuitPython_ESP32SPI +++ b/frozen/Adafruit_CircuitPython_ESP32SPI @@ -1 +1 @@ -Subproject commit e25c1801c5428598f543873bb846851b78efb329 +Subproject commit 13775b058422085762874fde8e587f2e9f066855 diff --git a/frozen/Adafruit_CircuitPython_FakeRequests b/frozen/Adafruit_CircuitPython_FakeRequests new file mode 160000 index 0000000000..f6cdec74b6 --- /dev/null +++ b/frozen/Adafruit_CircuitPython_FakeRequests @@ -0,0 +1 @@ +Subproject commit f6cdec74b64112016c459abe4a5d31a3b34caeb3 diff --git a/frozen/Adafruit_CircuitPython_FocalTouch b/frozen/Adafruit_CircuitPython_FocalTouch index 68744ede79..bccbe3da75 160000 --- a/frozen/Adafruit_CircuitPython_FocalTouch +++ b/frozen/Adafruit_CircuitPython_FocalTouch @@ -1 +1 @@ -Subproject commit 68744ede79c992a3df8322c21a1468c5ccaef2ee +Subproject commit bccbe3da75f42b540b3faebb9d5a2d1ccf5e7147 diff --git a/frozen/Adafruit_CircuitPython_HID b/frozen/Adafruit_CircuitPython_HID index d79dd180cf..2fddabcaf0 160000 --- a/frozen/Adafruit_CircuitPython_HID +++ b/frozen/Adafruit_CircuitPython_HID @@ -1 +1 @@ -Subproject commit d79dd180cf6062e97d6a12cbc8dc7fdbedcc752b +Subproject commit 2fddabcaf0df1763111ed9dbf9e2d4cdb5b0434e diff --git a/frozen/Adafruit_CircuitPython_IRRemote b/frozen/Adafruit_CircuitPython_IRRemote index 2ca37f927b..9771c9369c 160000 --- a/frozen/Adafruit_CircuitPython_IRRemote +++ b/frozen/Adafruit_CircuitPython_IRRemote @@ -1 +1 @@ -Subproject commit 2ca37f927b3ee3aad379c2991f36b3ef1be0203d +Subproject commit 9771c9369c7e251f514eb26abcfcea1e891e6f27 diff --git a/frozen/Adafruit_CircuitPython_LC709203F b/frozen/Adafruit_CircuitPython_LC709203F index ed41dd4460..29816fbe98 160000 --- a/frozen/Adafruit_CircuitPython_LC709203F +++ b/frozen/Adafruit_CircuitPython_LC709203F @@ -1 +1 @@ -Subproject commit ed41dd44605110f1d1411ed694ec2b5676dd8d9c +Subproject commit 29816fbe98c012ea0a1b5cae7f07aeae7ebf8b52 diff --git a/frozen/Adafruit_CircuitPython_LIS3DH b/frozen/Adafruit_CircuitPython_LIS3DH index daff8cdca7..acc4bdd73f 160000 --- a/frozen/Adafruit_CircuitPython_LIS3DH +++ b/frozen/Adafruit_CircuitPython_LIS3DH @@ -1 +1 @@ -Subproject commit daff8cdca78637915bea2f3a120cc84578516195 +Subproject commit acc4bdd73fdceb74d75cd5a1f261ae157ee32613 diff --git a/frozen/Adafruit_CircuitPython_LSM6DS b/frozen/Adafruit_CircuitPython_LSM6DS index 9873446ebd..75e9ec62e4 160000 --- a/frozen/Adafruit_CircuitPython_LSM6DS +++ b/frozen/Adafruit_CircuitPython_LSM6DS @@ -1 +1 @@ -Subproject commit 9873446ebde5779c03c2bd4e3e544a801fb27bd5 +Subproject commit 75e9ec62e4fe47a7212a69fb84aa1cfa7848e2b3 diff --git a/frozen/Adafruit_CircuitPython_MIDI b/frozen/Adafruit_CircuitPython_MIDI index 1127e3f7bc..6641509ef4 160000 --- a/frozen/Adafruit_CircuitPython_MIDI +++ b/frozen/Adafruit_CircuitPython_MIDI @@ -1 +1 @@ -Subproject commit 1127e3f7bcefa9fddb5b7f30533ecc6c58b420ea +Subproject commit 6641509ef43b672a82addf41f02b6466d6c67f01 diff --git a/frozen/Adafruit_CircuitPython_Motor b/frozen/Adafruit_CircuitPython_Motor index 88e5ae5142..fd478fda7a 160000 --- a/frozen/Adafruit_CircuitPython_Motor +++ b/frozen/Adafruit_CircuitPython_Motor @@ -1 +1 @@ -Subproject commit 88e5ae51427aa690de129c157223e93bf936ac41 +Subproject commit fd478fda7adbd254282b8cad5000f06a96760c91 diff --git a/frozen/Adafruit_CircuitPython_NeoPixel b/frozen/Adafruit_CircuitPython_NeoPixel index 9ca3bf00c6..a115fc30df 160000 --- a/frozen/Adafruit_CircuitPython_NeoPixel +++ b/frozen/Adafruit_CircuitPython_NeoPixel @@ -1 +1 @@ -Subproject commit 9ca3bf00c6a2dd1de2d315a3b952a381d720aa7d +Subproject commit a115fc30df1c230c09c8a533ca77f3a4afd9f6c3 diff --git a/frozen/Adafruit_CircuitPython_PortalBase b/frozen/Adafruit_CircuitPython_PortalBase new file mode 160000 index 0000000000..77ba8eedf8 --- /dev/null +++ b/frozen/Adafruit_CircuitPython_PortalBase @@ -0,0 +1 @@ +Subproject commit 77ba8eedf89b96c85a6194e5da2061c9d5c20242 diff --git a/frozen/Adafruit_CircuitPython_ProgressBar b/frozen/Adafruit_CircuitPython_ProgressBar index e4f7cd083d..011acd627f 160000 --- a/frozen/Adafruit_CircuitPython_ProgressBar +++ b/frozen/Adafruit_CircuitPython_ProgressBar @@ -1 +1 @@ -Subproject commit e4f7cd083dea8eb103954e7703bbb487491b433f +Subproject commit 011acd627fc24342c397fc640b204a798f7b69dd diff --git a/frozen/Adafruit_CircuitPython_RFM69 b/frozen/Adafruit_CircuitPython_RFM69 index 70ef86dc1a..c58defd709 160000 --- a/frozen/Adafruit_CircuitPython_RFM69 +++ b/frozen/Adafruit_CircuitPython_RFM69 @@ -1 +1 @@ -Subproject commit 70ef86dc1a42138efcab01945d5a421e45f2408e +Subproject commit c58defd70947531c5a9c37ddcb569f240567a78b diff --git a/frozen/Adafruit_CircuitPython_RFM9x b/frozen/Adafruit_CircuitPython_RFM9x index 379209dd7e..742ac7c8fb 160000 --- a/frozen/Adafruit_CircuitPython_RFM9x +++ b/frozen/Adafruit_CircuitPython_RFM9x @@ -1 +1 @@ -Subproject commit 379209dd7e4374c262b84256778d7895693e7fb6 +Subproject commit 742ac7c8fb52bb85d9fd367b60a7f80475d7ed14 diff --git a/frozen/Adafruit_CircuitPython_Register b/frozen/Adafruit_CircuitPython_Register index 79678c6adb..49ab415d6b 160000 --- a/frozen/Adafruit_CircuitPython_Register +++ b/frozen/Adafruit_CircuitPython_Register @@ -1 +1 @@ -Subproject commit 79678c6adb2252de8fed6273604bc6ac676132a5 +Subproject commit 49ab415d6b601c99979262f9e91c21dcb3a927a7 diff --git a/frozen/Adafruit_CircuitPython_Requests b/frozen/Adafruit_CircuitPython_Requests index 900b28cbae..270565665a 160000 --- a/frozen/Adafruit_CircuitPython_Requests +++ b/frozen/Adafruit_CircuitPython_Requests @@ -1 +1 @@ -Subproject commit 900b28cbae008e3253c4c40496e49faea9fb7034 +Subproject commit 270565665ada26fe8d7a99a3cb5941b452444471 diff --git a/frozen/Adafruit_CircuitPython_SD b/frozen/Adafruit_CircuitPython_SD index b7a76420d1..9dd51fecfc 160000 --- a/frozen/Adafruit_CircuitPython_SD +++ b/frozen/Adafruit_CircuitPython_SD @@ -1 +1 @@ -Subproject commit b7a76420d1dec119f8744aa7c0ea500e235561d1 +Subproject commit 9dd51fecfcbb15cb2a00eeadbd66b36ce0c09ee2 diff --git a/frozen/Adafruit_CircuitPython_ST7789 b/frozen/Adafruit_CircuitPython_ST7789 index c5b480434d..79c70a4928 160000 --- a/frozen/Adafruit_CircuitPython_ST7789 +++ b/frozen/Adafruit_CircuitPython_ST7789 @@ -1 +1 @@ -Subproject commit c5b480434de8fa56d8ba978a57cd3919fdc9da2a +Subproject commit 79c70a49285be8b6548de3f5ca20aa5ac1fafa22 diff --git a/frozen/Adafruit_CircuitPython_SimpleIO b/frozen/Adafruit_CircuitPython_SimpleIO index ca56187fe7..272d225365 160000 --- a/frozen/Adafruit_CircuitPython_SimpleIO +++ b/frozen/Adafruit_CircuitPython_SimpleIO @@ -1 +1 @@ -Subproject commit ca56187fe7af315130808191b004432fdfdc1b09 +Subproject commit 272d225365eed46916390cf1f393dd08bc00b7d4 diff --git a/frozen/Adafruit_CircuitPython_SimpleMath b/frozen/Adafruit_CircuitPython_SimpleMath index 5b699a6091..fad0f89e76 160000 --- a/frozen/Adafruit_CircuitPython_SimpleMath +++ b/frozen/Adafruit_CircuitPython_SimpleMath @@ -1 +1 @@ -Subproject commit 5b699a609197fb42aa059788c7c824c346d57c4e +Subproject commit fad0f89e760829a76f553ef8459f61001597a846 diff --git a/frozen/Adafruit_CircuitPython_Thermistor b/frozen/Adafruit_CircuitPython_Thermistor index d4ac6ce3ee..e86f258e43 160000 --- a/frozen/Adafruit_CircuitPython_Thermistor +++ b/frozen/Adafruit_CircuitPython_Thermistor @@ -1 +1 @@ -Subproject commit d4ac6ce3eea2c87781fa2df4e431d9440c610fad +Subproject commit e86f258e43591ce4a04661277e77e9fdf6fec27e diff --git a/frozen/Adafruit_CircuitPython_seesaw b/frozen/Adafruit_CircuitPython_seesaw index 0450119e16..c89c868916 160000 --- a/frozen/Adafruit_CircuitPython_seesaw +++ b/frozen/Adafruit_CircuitPython_seesaw @@ -1 +1 @@ -Subproject commit 0450119e163df782930a887022e197d6d25ca666 +Subproject commit c89c8689161e5b35bfe4fa8355615696e03f0648 diff --git a/lib/protomatter b/lib/protomatter index 7fe6406aff..d0a07e14ad 160000 --- a/lib/protomatter +++ b/lib/protomatter @@ -1 +1 @@ -Subproject commit 7fe6406affb1376193102cf76ded06e61316d7e6 +Subproject commit d0a07e14adcd71a7c22bcceb16c55aadb5e0d104 diff --git a/lib/sdmmc/sdmmc_io.c b/lib/sdmmc/sdmmc_io.c index 369be8c233..17ab291515 100644 --- a/lib/sdmmc/sdmmc_io.c +++ b/lib/sdmmc/sdmmc_io.c @@ -420,7 +420,10 @@ static sdmmc_err_t cis_tuple_func_manfid(const void* p, uint8_t* data, FILE* fp) int size = *(data++); fprintf(fp, "TUPLE: %s, size: %d\n", tuple->name, size); CIS_CHECK_SIZE(size, 4); + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wcast-align" fprintf(fp, " MANF: %04X, CARD: %04X\n", *(uint16_t*)(data), *(uint16_t*)(data+2)); + #pragma GCC diagnostic pop return SDMMC_OK; } @@ -480,7 +483,10 @@ static sdmmc_err_t cis_tuple_func_cftable_entry(const void* p, uint8_t* data, FI CIS_CHECK_SIZE(size, 2); size-=2; CIS_CHECK_UNSUPPORTED(mem_space==1); //other cases not handled yet + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wcast-align" int len = *(uint16_t*)data; + #pragma GCC diagnostic pop fprintf(fp, " LEN: %04X\n", len); data+=2; } diff --git a/lib/tinyusb b/lib/tinyusb index ae73873b5c..3b09b82123 160000 --- a/lib/tinyusb +++ b/lib/tinyusb @@ -1 +1 @@ -Subproject commit ae73873b5cba0eb11c89165f4559964940430d44 +Subproject commit 3b09b82123a50bef6b18cf90c2734ae7581da4a3 diff --git a/locale/ID.po b/locale/ID.po index a145d0048e..a4579f0846 100644 --- a/locale/ID.po +++ b/locale/ID.po @@ -107,7 +107,7 @@ msgstr "indeks %q harus bilangan bulat, bukan %s" msgid "%q length must be %d-%d" msgstr "%q panjang harus %d-%d" -#: shared-bindings/usb_hid/Device.c +#: shared-bindings/busio/I2C.c shared-bindings/usb_hid/Device.c msgid "%q length must be >= 1" msgstr "%q panjang harus >= 1" @@ -152,6 +152,10 @@ msgstr "%q harus antara %d dan %d" msgid "%q must be of type %q" msgstr "%q harus bertipe %q" +#: shared-bindings/digitalio/Pull.c +msgid "%q must be of type %q or None" +msgstr "" + #: ports/atmel-samd/common-hal/busio/UART.c msgid "%q must be power of 2" msgstr "%q harus pangkat 2" @@ -450,6 +454,7 @@ msgstr "Semua timer untuk pin ini sedang digunakan" msgid "All timers in use" msgstr "Semua timer sedang digunakan" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Already advertising." msgstr "Sudah disebarkan." @@ -584,7 +589,7 @@ msgstr "Kedua pin harus mendukung hardware interrut" #: shared-bindings/displayio/Display.c #: shared-bindings/framebufferio/FramebufferDisplay.c -#: shared-bindings/is31fl3741/is31fl3741.c +#: shared-bindings/is31fl3741/FrameBuffer.c #: shared-bindings/rgbmatrix/RGBMatrix.c msgid "Brightness must be 0-1.0" msgstr "Kecerahan harus di antara 0-1.0" @@ -636,7 +641,7 @@ msgstr "Panjang buffer harus kelipatan 512" msgid "Buffer must be a multiple of 512 bytes" msgstr "" -#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c +#: shared-bindings/bitbangio/I2C.c msgid "Buffer must be at least length 1" msgstr "Penyangga harus memiliki panjang setidaknya 1" @@ -669,6 +674,10 @@ msgstr "Bytes harus di antara 0 dan 255." msgid "CBC blocks must be multiples of 16 bytes" msgstr "Blok CBC harus merupakan kelipatan 16 byte" +#: supervisor/shared/safe_mode.c +msgid "CIRCUITPY drive could not be found or created." +msgstr "" + #: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c msgid "CRC or checksum was invalid" msgstr "" @@ -919,10 +928,12 @@ msgstr "Data 0 pin harus byte disejajarkan" msgid "Data chunk must follow fmt chunk" msgstr "Potongan data harus mengikuti fmt chunk" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data not supported with directed advertising" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data too large for advertisement packet" msgstr "Data terlalu besar untuk paket advertisment" @@ -1003,6 +1014,7 @@ msgstr "" msgid "Expected tuple of length %d, got %d" msgstr "Diharapkan tuple dengan panjang %d, didapatkan %d" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Extended advertisements with scan response not supported." msgstr "Penyebaran yang diperluas dengan respon pindai tidak didukung." @@ -1056,6 +1068,7 @@ msgstr "" msgid "Failed to buffer the sample" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Failed to connect: internal error" msgstr "Gagal terhubung: kesalahan internal" @@ -1135,6 +1148,13 @@ msgstr "" msgid "Group already used" msgstr "Grup sudah digunakan" +#: ports/atmel-samd/common-hal/busio/SPI.c ports/cxd56/common-hal/busio/SPI.c +#: ports/espressif/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/nrf/common-hal/busio/SPI.c +#: ports/raspberrypi/common-hal/busio/SPI.c +msgid "Half duplex SPI is not implemented" +msgstr "" + #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/I2C.c #: ports/stm/common-hal/busio/SPI.c ports/stm/common-hal/canio/CAN.c #: ports/stm/common-hal/sdioio/SDCard.c @@ -1289,6 +1309,7 @@ msgstr "Nilai Unit ADC tidak valid" msgid "Invalid AuthMode" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c msgid "Invalid BLE parameter" msgstr "" @@ -1383,6 +1404,10 @@ msgstr "Ukuran potongan format tidak valid" msgid "Invalid memory access." msgstr "Akses memori tidak valid." +#: extmod/vfs_fat_file.c +msgid "Invalid mode" +msgstr "" + #: ports/espressif/common-hal/wifi/Radio.c msgid "Invalid multicast MAC address" msgstr "" @@ -1483,7 +1508,7 @@ msgstr "Panjang kata/bit tidak valid" msgid "Key must be 16, 24, or 32 bytes long" msgstr "Panjang kunci harus 16, 24, atau 32 byte" -#: shared-module/is31fl3741/is31fl3741.c +#: shared-module/is31fl3741/FrameBuffer.c msgid "LED mappings must match display size" msgstr "" @@ -1511,6 +1536,10 @@ msgstr "Pin MISO gagal inisialisasi." msgid "MOSI pin init failed." msgstr "Pin MOSI gagal inisialisasi." +#: shared-bindings/is31fl3741/IS31FL3741.c +msgid "Mapping must be a tuple" +msgstr "" + #: shared-module/displayio/Shape.c #, c-format msgid "Maximum x value when mirrored is %d" @@ -1593,6 +1622,10 @@ msgstr "" msgid "Name too long" msgstr "Nama terlalu panjang" +#: ports/espressif/common-hal/_bleio/__init__.c +msgid "Nimble out of memory" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "Tidak ada CCCD untuk Karakteristik ini" @@ -1613,9 +1646,9 @@ msgstr "tidak ada channel DMA ditemukan" msgid "No DMA pacing timer found" msgstr "" -#: shared-module/adafruit_bus_device/I2CDevice.c +#: shared-module/adafruit_bus_device/i2c_device/I2CDevice.c #, c-format -msgid "No I2C device at address: %x" +msgid "No I2C device at address: 0x%x" msgstr "" #: ports/espressif/common-hal/busio/SPI.c @@ -1740,6 +1773,7 @@ msgstr "" msgid "Not a valid IP string" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -1920,7 +1954,7 @@ msgstr "Pin tidak mempunya kemampuan untuk ADC (Analog Digital Converter)" msgid "Pin interrupt already in use" msgstr "" -#: shared-bindings/adafruit_bus_device/SPIDevice.c +#: shared-bindings/adafruit_bus_device/spi_device/SPIDevice.c #: shared-bindings/digitalio/DigitalInOut.c msgid "Pin is input only" msgstr "" @@ -2007,6 +2041,10 @@ msgstr "Pull tidak digunakan saat arah output." msgid "RAISE mode is not implemented" msgstr "" +#: ports/raspberrypi/common-hal/countio/Counter.c +msgid "RISE_AND_FALL not available on this chip" +msgstr "" + #: ports/stm/common-hal/os/__init__.c msgid "RNG DeInit Error" msgstr "Kesalahan DeInit RNG" @@ -2125,10 +2163,11 @@ msgstr "Tingkat sampel harus positif" msgid "Sample rate too high. It must be less than %d" msgstr "Nilai sampel terlalu tinggi. Nilai harus kurang dari %d" -#: shared-bindings/is31fl3741/is31fl3741.c +#: shared-bindings/is31fl3741/FrameBuffer.c msgid "Scale dimensions must divide by 3" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Scan already in progess. Stop with stop_scan." msgstr "Pindai sudah dalam proses. Hentikan dengan stop_scan." @@ -2287,6 +2326,7 @@ msgstr "Lebar ubin harus persis membagi lebar bitmap" msgid "Time is in the past." msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2309,6 +2349,7 @@ msgstr "Terlalu banyak tampilan bus" msgid "Too many displays" msgstr "Terlalu banyak tampilan" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Total data to write is larger than %q" msgstr "" @@ -2386,7 +2427,7 @@ msgstr "Tidak dapat mengalokasikan buffer untuk signed conversion" msgid "Unable to create lock" msgstr "" -#: shared-module/displayio/I2CDisplay.c shared-module/is31fl3741/is31fl3741.c +#: shared-module/displayio/I2CDisplay.c shared-module/is31fl3741/IS31FL3741.c #, c-format msgid "Unable to find I2C Display at %x" msgstr "Tidak dapat menemukan Tampilan I2C di %x" @@ -2421,6 +2462,16 @@ msgstr "Tipe urf nrfx tak sesuai" msgid "Unhandled ESP TLS error %d %d %x %d" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown BLE error at %s:%d: %d" +msgstr "" + +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown BLE error: %d" +msgstr "" + #: shared-bindings/wifi/Radio.c #, c-format msgid "Unknown failure %d" @@ -2440,11 +2491,21 @@ msgstr "Alasan yang tidak diketahui." msgid "Unknown security error: 0x%04x" msgstr "Kesalahan keamanan tidak dikenal: 0x%04x" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error at %s:%d: %d" +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown system firmware error: %04x" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error: %d" +msgstr "" + #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #, c-format msgid "Unmatched number of items on RHS (expected %d, got %d)." @@ -2480,19 +2541,19 @@ msgstr "Format tidak didukung" msgid "Unsupported operation" msgstr "Operasi yang tidak didukung" -#: shared-bindings/digitalio/DigitalInOut.c -msgid "Unsupported pull value." -msgstr "Nilai tarikan yang tidak didukung." - #: ports/espressif/common-hal/dualbank/__init__.c msgid "Update Failed" msgstr "" +#: ports/espressif/common-hal/_bleio/Characteristic.c +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length != required fixed length" msgstr "Panjang nilai != Panjang tetap yang dibutuhkan" +#: ports/espressif/common-hal/_bleio/Characteristic.c +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length > max_length" @@ -2550,6 +2611,7 @@ msgstr "" msgid "Woken up by alarm.\n" msgstr "" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Writes not supported on Characteristic" msgstr "Menulis tidak didukung pada Karakteristik" @@ -2653,7 +2715,7 @@ msgstr "berusaha mendapatkan argmin/argmax dari urutan kosong" msgid "attributes not supported yet" msgstr "atribut belum didukung" -#: extmod/ulab/code/numpy/numerical.c +#: extmod/ulab/code/ulab_tools.c msgid "axis is out of bounds" msgstr "" @@ -2709,11 +2771,11 @@ msgstr "" msgid "branch not in range" msgstr "" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/utils/utils.c msgid "buffer is smaller than requested size" msgstr "" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/utils/utils.c msgid "buffer size must be a multiple of element size" msgstr "" @@ -2763,6 +2825,10 @@ msgstr "kalibrasi adalah read only" msgid "calibration value out of range +/-127" msgstr "nilai kalibrasi keluar dari jangkauan +/-127" +#: shared-module/vectorio/Rectangle.c +msgid "can only be registered in one parent" +msgstr "" + #: py/emitinlinethumb.c msgid "can only have up to 4 parameters to Thumb assembly" msgstr "hanya mampu memiliki hingga 4 parameter untuk Thumb assembly" @@ -2801,6 +2867,10 @@ msgstr "" msgid "can't convert '%q' object to %q implicitly" msgstr "" +#: extmod/ulab/code/numpy/vector.c +msgid "can't convert complex to float" +msgstr "" + #: py/obj.c msgid "can't convert to %q" msgstr "" @@ -2853,6 +2923,10 @@ msgstr "" msgid "can't load with '%q' index" msgstr "" +#: py/builtinimport.c +msgid "can't perform relative import" +msgstr "" + #: py/objgenerator.c msgid "can't send non-None value to a just-started generator" msgstr "" @@ -2895,6 +2969,14 @@ msgstr "" msgid "cannot cast output with casting rule" msgstr "" +#: extmod/ulab/code/ndarray.c +msgid "cannot convert complex to dtype" +msgstr "" + +#: extmod/ulab/code/ndarray.c +msgid "cannot convert complex type" +msgstr "" + #: py/objtype.c msgid "cannot create '%q' instances" msgstr "" @@ -2907,10 +2989,6 @@ msgstr "" msgid "cannot import name %q" msgstr "" -#: py/builtinimport.c -msgid "cannot perform relative import" -msgstr "tidak dapat melakukan relative import" - #: extmod/moductypes.c msgid "cannot unambiguously get sizeof scalar" msgstr "" @@ -3086,6 +3164,10 @@ msgstr "" msgid "divisor must be 4" msgstr "" +#: extmod/ulab/code/numpy/vector.c +msgid "dtype must be float, or complex" +msgstr "" + #: py/objdeque.c msgid "empty" msgstr "" @@ -3189,7 +3271,7 @@ msgstr "" msgid "first argument must be a function" msgstr "" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "first argument must be a tuple of ndarrays" msgstr "" @@ -3254,6 +3336,10 @@ msgstr "" msgid "function is defined for ndarrays only" msgstr "" +#: extmod/ulab/code/numpy/carray/carray.c +msgid "function is implemented for ndarrays only" +msgstr "" + #: py/argcheck.c #, c-format msgid "function missing %d required positional arguments" @@ -3367,7 +3453,7 @@ msgstr "inline assembler harus sebuah fungsi" msgid "input and output shapes are not compatible" msgstr "" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "input argument must be an integer, a tuple, or a list" msgstr "" @@ -3375,7 +3461,7 @@ msgstr "" msgid "input array length must be power of 2" msgstr "" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "input arrays are not compatible" msgstr "" @@ -3383,6 +3469,10 @@ msgstr "" msgid "input data must be an iterable" msgstr "" +#: extmod/ulab/code/numpy/vector.c +msgid "input dtype must be float or complex" +msgstr "" + #: extmod/ulab/code/numpy/linalg/linalg.c msgid "input matrix is asymmetric" msgstr "" @@ -3392,18 +3482,26 @@ msgstr "" msgid "input matrix is singular" msgstr "" +#: extmod/ulab/code/numpy/carray/carray.c +msgid "input must be a 1D ndarray" +msgstr "" + #: extmod/ulab/code/scipy/linalg/linalg.c extmod/ulab/code/user/user.c msgid "input must be a dense ndarray" msgstr "" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "input must be a tensor of rank 2" msgstr "" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/user/user.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/user/user.c msgid "input must be an ndarray" msgstr "" +#: extmod/ulab/code/numpy/carray/carray.c +msgid "input must be an ndarray, or a scalar" +msgstr "" + #: extmod/ulab/code/scipy/signal/signal.c msgid "input must be one-dimensional" msgstr "" @@ -3581,6 +3679,11 @@ msgstr "" msgid "matrix is not positive definite" msgstr "" +#: ports/espressif/common-hal/wifi/Radio.c +msgid "max_connections must be between 0 and 10" +msgstr "" + +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c #, c-format @@ -3734,6 +3837,7 @@ msgstr "" msgid "non-Device in %q" msgstr "" +#: ports/espressif/common-hal/_bleio/Connection.c #: ports/nrf/common-hal/_bleio/Connection.c msgid "non-UUID found in service_uuids_whitelist" msgstr "" @@ -3774,7 +3878,11 @@ msgstr "" msgid "not enough arguments for format string" msgstr "" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/carray/carray_tools.c +msgid "not implemented for complex dtype" +msgstr "" + +#: extmod/ulab/code/numpy/create.c msgid "number of points must be at least 2" msgstr "" @@ -3832,7 +3940,7 @@ msgstr "" msgid "odd-length string" msgstr "panjang data string memiliki keganjilan (odd-length)" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/utils/utils.c msgid "offset is too large" msgstr "" @@ -3840,7 +3948,7 @@ msgstr "" msgid "offset must be >= 0" msgstr "" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "offset must be non-negative and no greater than buffer length" msgstr "" @@ -3953,6 +4061,10 @@ msgstr "" msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "" +#: extmod/vfs_posix_file.c +msgid "poll on file not available on win32" +msgstr "" + #: shared-module/vectorio/Polygon.c msgid "polygon can only be registered in one parent" msgstr "" @@ -3982,18 +4094,27 @@ msgstr "" msgid "pow() with 3 arguments requires integers" msgstr "" +#: ports/espressif/boards/adafruit_esp32s2_camera/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tft/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h #: ports/espressif/boards/adafruit_funhouse/mpconfigboard.h #: ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h +#: ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h +#: ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h #: ports/espressif/boards/atmegazero_esp32s2/mpconfigboard.h #: ports/espressif/boards/crumpspace_crumps2/mpconfigboard.h #: ports/espressif/boards/electroniccats_bastwifi/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s2_devkitc_1_n4r2/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_box/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h #: ports/espressif/boards/espressif_hmi_devkit_1/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1.3/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1/mpconfigboard.h @@ -4019,7 +4140,10 @@ msgstr "" #: ports/espressif/boards/unexpectedmaker_feathers2/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_neo/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_prerelease/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_feathers3/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_pros3/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_tinys2/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_tinys3/mpconfigboard.h msgid "pressing boot button at start up.\n" msgstr "" @@ -4316,7 +4440,7 @@ msgstr "" msgid "too many arguments provided with the given format" msgstr "" -#: extmod/ulab/code/ndarray.c extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/ndarray.c extmod/ulab/code/numpy/create.c msgid "too many dimensions" msgstr "" @@ -4500,7 +4624,7 @@ msgstr "" msgid "width must be from 2 to 8 (inclusive), not %d" msgstr "" -#: shared-bindings/is31fl3741/is31fl3741.c +#: shared-bindings/is31fl3741/FrameBuffer.c #: shared-bindings/rgbmatrix/RGBMatrix.c msgid "width must be greater than zero" msgstr "" @@ -4517,7 +4641,7 @@ msgstr "jendela harus <= interval" msgid "wrong axis index" msgstr "indeks sumbu salah" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "wrong axis specified" msgstr "sumbu yang ditentukan salah" @@ -4525,7 +4649,11 @@ msgstr "sumbu yang ditentukan salah" msgid "wrong input type" msgstr "tipe input salah" -#: extmod/ulab/code/ulab_create.c py/objarray.c py/objstr.c +#: extmod/ulab/code/numpy/transform.c +msgid "wrong length of condition array" +msgstr "" + +#: extmod/ulab/code/numpy/create.c py/objarray.c py/objstr.c msgid "wrong number of arguments" msgstr "jumlah argumen salah" @@ -4569,6 +4697,12 @@ msgstr "zi harus berjenis float" msgid "zi must be of shape (n_section, 2)" msgstr "Zi harus berbentuk (n_section, 2)" +#~ msgid "cannot perform relative import" +#~ msgstr "tidak dapat melakukan relative import" + +#~ msgid "Unsupported pull value." +#~ msgstr "Nilai tarikan yang tidak didukung." + #, c-format #~ msgid "" #~ "Welcome to Adafruit CircuitPython %s!\n" diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index 835ef9538b..58e842598b 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -99,7 +99,7 @@ msgstr "" msgid "%q length must be %d-%d" msgstr "" -#: shared-bindings/usb_hid/Device.c +#: shared-bindings/busio/I2C.c shared-bindings/usb_hid/Device.c msgid "%q length must be >= 1" msgstr "" @@ -144,6 +144,10 @@ msgstr "" msgid "%q must be of type %q" msgstr "" +#: shared-bindings/digitalio/Pull.c +msgid "%q must be of type %q or None" +msgstr "" + #: ports/atmel-samd/common-hal/busio/UART.c msgid "%q must be power of 2" msgstr "" @@ -442,6 +446,7 @@ msgstr "" msgid "All timers in use" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Already advertising." msgstr "" @@ -574,7 +579,7 @@ msgstr "" #: shared-bindings/displayio/Display.c #: shared-bindings/framebufferio/FramebufferDisplay.c -#: shared-bindings/is31fl3741/is31fl3741.c +#: shared-bindings/is31fl3741/FrameBuffer.c #: shared-bindings/rgbmatrix/RGBMatrix.c msgid "Brightness must be 0-1.0" msgstr "" @@ -626,7 +631,7 @@ msgstr "" msgid "Buffer must be a multiple of 512 bytes" msgstr "" -#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c +#: shared-bindings/bitbangio/I2C.c msgid "Buffer must be at least length 1" msgstr "" @@ -659,6 +664,10 @@ msgstr "" msgid "CBC blocks must be multiples of 16 bytes" msgstr "" +#: supervisor/shared/safe_mode.c +msgid "CIRCUITPY drive could not be found or created." +msgstr "" + #: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c msgid "CRC or checksum was invalid" msgstr "" @@ -900,10 +909,12 @@ msgstr "" msgid "Data chunk must follow fmt chunk" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data not supported with directed advertising" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data too large for advertisement packet" msgstr "" @@ -984,6 +995,7 @@ msgstr "" msgid "Expected tuple of length %d, got %d" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Extended advertisements with scan response not supported." msgstr "" @@ -1037,6 +1049,7 @@ msgstr "" msgid "Failed to buffer the sample" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Failed to connect: internal error" msgstr "" @@ -1116,6 +1129,13 @@ msgstr "" msgid "Group already used" msgstr "" +#: ports/atmel-samd/common-hal/busio/SPI.c ports/cxd56/common-hal/busio/SPI.c +#: ports/espressif/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/nrf/common-hal/busio/SPI.c +#: ports/raspberrypi/common-hal/busio/SPI.c +msgid "Half duplex SPI is not implemented" +msgstr "" + #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/I2C.c #: ports/stm/common-hal/busio/SPI.c ports/stm/common-hal/canio/CAN.c #: ports/stm/common-hal/sdioio/SDCard.c @@ -1268,6 +1288,7 @@ msgstr "" msgid "Invalid AuthMode" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c msgid "Invalid BLE parameter" msgstr "" @@ -1362,6 +1383,10 @@ msgstr "" msgid "Invalid memory access." msgstr "" +#: extmod/vfs_fat_file.c +msgid "Invalid mode" +msgstr "" + #: ports/espressif/common-hal/wifi/Radio.c msgid "Invalid multicast MAC address" msgstr "" @@ -1462,7 +1487,7 @@ msgstr "" msgid "Key must be 16, 24, or 32 bytes long" msgstr "" -#: shared-module/is31fl3741/is31fl3741.c +#: shared-module/is31fl3741/FrameBuffer.c msgid "LED mappings must match display size" msgstr "" @@ -1490,6 +1515,10 @@ msgstr "" msgid "MOSI pin init failed." msgstr "" +#: shared-bindings/is31fl3741/IS31FL3741.c +msgid "Mapping must be a tuple" +msgstr "" + #: shared-module/displayio/Shape.c #, c-format msgid "Maximum x value when mirrored is %d" @@ -1572,6 +1601,10 @@ msgstr "" msgid "Name too long" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +msgid "Nimble out of memory" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "" @@ -1592,9 +1625,9 @@ msgstr "" msgid "No DMA pacing timer found" msgstr "" -#: shared-module/adafruit_bus_device/I2CDevice.c +#: shared-module/adafruit_bus_device/i2c_device/I2CDevice.c #, c-format -msgid "No I2C device at address: %x" +msgid "No I2C device at address: 0x%x" msgstr "" #: ports/espressif/common-hal/busio/SPI.c @@ -1719,6 +1752,7 @@ msgstr "" msgid "Not a valid IP string" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -1892,7 +1926,7 @@ msgstr "" msgid "Pin interrupt already in use" msgstr "" -#: shared-bindings/adafruit_bus_device/SPIDevice.c +#: shared-bindings/adafruit_bus_device/spi_device/SPIDevice.c #: shared-bindings/digitalio/DigitalInOut.c msgid "Pin is input only" msgstr "" @@ -1974,6 +2008,10 @@ msgstr "" msgid "RAISE mode is not implemented" msgstr "" +#: ports/raspberrypi/common-hal/countio/Counter.c +msgid "RISE_AND_FALL not available on this chip" +msgstr "" + #: ports/stm/common-hal/os/__init__.c msgid "RNG DeInit Error" msgstr "" @@ -2090,10 +2128,11 @@ msgstr "" msgid "Sample rate too high. It must be less than %d" msgstr "" -#: shared-bindings/is31fl3741/is31fl3741.c +#: shared-bindings/is31fl3741/FrameBuffer.c msgid "Scale dimensions must divide by 3" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Scan already in progess. Stop with stop_scan." msgstr "" @@ -2252,6 +2291,7 @@ msgstr "" msgid "Time is in the past." msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2274,6 +2314,7 @@ msgstr "" msgid "Too many displays" msgstr "" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Total data to write is larger than %q" msgstr "" @@ -2351,7 +2392,7 @@ msgstr "" msgid "Unable to create lock" msgstr "" -#: shared-module/displayio/I2CDisplay.c shared-module/is31fl3741/is31fl3741.c +#: shared-module/displayio/I2CDisplay.c shared-module/is31fl3741/IS31FL3741.c #, c-format msgid "Unable to find I2C Display at %x" msgstr "" @@ -2386,6 +2427,16 @@ msgstr "" msgid "Unhandled ESP TLS error %d %d %x %d" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown BLE error at %s:%d: %d" +msgstr "" + +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown BLE error: %d" +msgstr "" + #: shared-bindings/wifi/Radio.c #, c-format msgid "Unknown failure %d" @@ -2405,11 +2456,21 @@ msgstr "" msgid "Unknown security error: 0x%04x" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error at %s:%d: %d" +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown system firmware error: %04x" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error: %d" +msgstr "" + #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #, c-format msgid "Unmatched number of items on RHS (expected %d, got %d)." @@ -2443,19 +2504,19 @@ msgstr "" msgid "Unsupported operation" msgstr "" -#: shared-bindings/digitalio/DigitalInOut.c -msgid "Unsupported pull value." -msgstr "" - #: ports/espressif/common-hal/dualbank/__init__.c msgid "Update Failed" msgstr "" +#: ports/espressif/common-hal/_bleio/Characteristic.c +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length != required fixed length" msgstr "" +#: ports/espressif/common-hal/_bleio/Characteristic.c +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length > max_length" @@ -2513,6 +2574,7 @@ msgstr "" msgid "Woken up by alarm.\n" msgstr "" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Writes not supported on Characteristic" msgstr "" @@ -2616,7 +2678,7 @@ msgstr "" msgid "attributes not supported yet" msgstr "" -#: extmod/ulab/code/numpy/numerical.c +#: extmod/ulab/code/ulab_tools.c msgid "axis is out of bounds" msgstr "" @@ -2672,11 +2734,11 @@ msgstr "" msgid "branch not in range" msgstr "" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/utils/utils.c msgid "buffer is smaller than requested size" msgstr "" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/utils/utils.c msgid "buffer size must be a multiple of element size" msgstr "" @@ -2726,6 +2788,10 @@ msgstr "" msgid "calibration value out of range +/-127" msgstr "" +#: shared-module/vectorio/Rectangle.c +msgid "can only be registered in one parent" +msgstr "" + #: py/emitinlinethumb.c msgid "can only have up to 4 parameters to Thumb assembly" msgstr "" @@ -2764,6 +2830,10 @@ msgstr "" msgid "can't convert '%q' object to %q implicitly" msgstr "" +#: extmod/ulab/code/numpy/vector.c +msgid "can't convert complex to float" +msgstr "" + #: py/obj.c msgid "can't convert to %q" msgstr "" @@ -2816,6 +2886,10 @@ msgstr "" msgid "can't load with '%q' index" msgstr "" +#: py/builtinimport.c +msgid "can't perform relative import" +msgstr "" + #: py/objgenerator.c msgid "can't send non-None value to a just-started generator" msgstr "" @@ -2858,6 +2932,14 @@ msgstr "" msgid "cannot cast output with casting rule" msgstr "" +#: extmod/ulab/code/ndarray.c +msgid "cannot convert complex to dtype" +msgstr "" + +#: extmod/ulab/code/ndarray.c +msgid "cannot convert complex type" +msgstr "" + #: py/objtype.c msgid "cannot create '%q' instances" msgstr "" @@ -2870,10 +2952,6 @@ msgstr "" msgid "cannot import name %q" msgstr "" -#: py/builtinimport.c -msgid "cannot perform relative import" -msgstr "" - #: extmod/moductypes.c msgid "cannot unambiguously get sizeof scalar" msgstr "" @@ -3049,6 +3127,10 @@ msgstr "" msgid "divisor must be 4" msgstr "" +#: extmod/ulab/code/numpy/vector.c +msgid "dtype must be float, or complex" +msgstr "" + #: py/objdeque.c msgid "empty" msgstr "" @@ -3152,7 +3234,7 @@ msgstr "" msgid "first argument must be a function" msgstr "" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "first argument must be a tuple of ndarrays" msgstr "" @@ -3217,6 +3299,10 @@ msgstr "" msgid "function is defined for ndarrays only" msgstr "" +#: extmod/ulab/code/numpy/carray/carray.c +msgid "function is implemented for ndarrays only" +msgstr "" + #: py/argcheck.c #, c-format msgid "function missing %d required positional arguments" @@ -3330,7 +3416,7 @@ msgstr "" msgid "input and output shapes are not compatible" msgstr "" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "input argument must be an integer, a tuple, or a list" msgstr "" @@ -3338,7 +3424,7 @@ msgstr "" msgid "input array length must be power of 2" msgstr "" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "input arrays are not compatible" msgstr "" @@ -3346,6 +3432,10 @@ msgstr "" msgid "input data must be an iterable" msgstr "" +#: extmod/ulab/code/numpy/vector.c +msgid "input dtype must be float or complex" +msgstr "" + #: extmod/ulab/code/numpy/linalg/linalg.c msgid "input matrix is asymmetric" msgstr "" @@ -3355,18 +3445,26 @@ msgstr "" msgid "input matrix is singular" msgstr "" +#: extmod/ulab/code/numpy/carray/carray.c +msgid "input must be a 1D ndarray" +msgstr "" + #: extmod/ulab/code/scipy/linalg/linalg.c extmod/ulab/code/user/user.c msgid "input must be a dense ndarray" msgstr "" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "input must be a tensor of rank 2" msgstr "" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/user/user.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/user/user.c msgid "input must be an ndarray" msgstr "" +#: extmod/ulab/code/numpy/carray/carray.c +msgid "input must be an ndarray, or a scalar" +msgstr "" + #: extmod/ulab/code/scipy/signal/signal.c msgid "input must be one-dimensional" msgstr "" @@ -3544,6 +3642,11 @@ msgstr "" msgid "matrix is not positive definite" msgstr "" +#: ports/espressif/common-hal/wifi/Radio.c +msgid "max_connections must be between 0 and 10" +msgstr "" + +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c #, c-format @@ -3697,6 +3800,7 @@ msgstr "" msgid "non-Device in %q" msgstr "" +#: ports/espressif/common-hal/_bleio/Connection.c #: ports/nrf/common-hal/_bleio/Connection.c msgid "non-UUID found in service_uuids_whitelist" msgstr "" @@ -3737,7 +3841,11 @@ msgstr "" msgid "not enough arguments for format string" msgstr "" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/carray/carray_tools.c +msgid "not implemented for complex dtype" +msgstr "" + +#: extmod/ulab/code/numpy/create.c msgid "number of points must be at least 2" msgstr "" @@ -3795,7 +3903,7 @@ msgstr "" msgid "odd-length string" msgstr "" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/utils/utils.c msgid "offset is too large" msgstr "" @@ -3803,7 +3911,7 @@ msgstr "" msgid "offset must be >= 0" msgstr "" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "offset must be non-negative and no greater than buffer length" msgstr "" @@ -3915,6 +4023,10 @@ msgstr "" msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "" +#: extmod/vfs_posix_file.c +msgid "poll on file not available on win32" +msgstr "" + #: shared-module/vectorio/Polygon.c msgid "polygon can only be registered in one parent" msgstr "" @@ -3944,18 +4056,27 @@ msgstr "" msgid "pow() with 3 arguments requires integers" msgstr "" +#: ports/espressif/boards/adafruit_esp32s2_camera/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tft/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h #: ports/espressif/boards/adafruit_funhouse/mpconfigboard.h #: ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h +#: ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h +#: ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h #: ports/espressif/boards/atmegazero_esp32s2/mpconfigboard.h #: ports/espressif/boards/crumpspace_crumps2/mpconfigboard.h #: ports/espressif/boards/electroniccats_bastwifi/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s2_devkitc_1_n4r2/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_box/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h #: ports/espressif/boards/espressif_hmi_devkit_1/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1.3/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1/mpconfigboard.h @@ -3981,7 +4102,10 @@ msgstr "" #: ports/espressif/boards/unexpectedmaker_feathers2/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_neo/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_prerelease/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_feathers3/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_pros3/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_tinys2/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_tinys3/mpconfigboard.h msgid "pressing boot button at start up.\n" msgstr "" @@ -4278,7 +4402,7 @@ msgstr "" msgid "too many arguments provided with the given format" msgstr "" -#: extmod/ulab/code/ndarray.c extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/ndarray.c extmod/ulab/code/numpy/create.c msgid "too many dimensions" msgstr "" @@ -4462,7 +4586,7 @@ msgstr "" msgid "width must be from 2 to 8 (inclusive), not %d" msgstr "" -#: shared-bindings/is31fl3741/is31fl3741.c +#: shared-bindings/is31fl3741/FrameBuffer.c #: shared-bindings/rgbmatrix/RGBMatrix.c msgid "width must be greater than zero" msgstr "" @@ -4479,7 +4603,7 @@ msgstr "" msgid "wrong axis index" msgstr "" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "wrong axis specified" msgstr "" @@ -4487,7 +4611,11 @@ msgstr "" msgid "wrong input type" msgstr "" -#: extmod/ulab/code/ulab_create.c py/objarray.c py/objstr.c +#: extmod/ulab/code/numpy/transform.c +msgid "wrong length of condition array" +msgstr "" + +#: extmod/ulab/code/numpy/create.c py/objarray.c py/objstr.c msgid "wrong number of arguments" msgstr "" diff --git a/locale/cs.po b/locale/cs.po index 8a3a920fbb..2fb94b8586 100644 --- a/locale/cs.po +++ b/locale/cs.po @@ -6,27 +6,31 @@ msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-01-04 12:55-0600\n" -"PO-Revision-Date: 2020-12-04 18:33+0000\n" -"Last-Translator: vkuthan \n" +"PO-Revision-Date: 2021-12-23 01:53+0000\n" +"Last-Translator: dronecz \n" "Language-Team: LANGUAGE \n" "Language: cs\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n" -"X-Generator: Weblate 4.4-dev\n" +"X-Generator: Weblate 4.10.1\n" #: main.c msgid "" "\n" "Code done running.\n" msgstr "" +"\n" +"Program byl dokončen.\n" #: main.c msgid "" "\n" "Code stopped by auto-reload.\n" msgstr "" +"\n" +"Program byl zastaven automatickým načtením.\n" #: supervisor/shared/safe_mode.c msgid "" @@ -35,7 +39,7 @@ msgid "" "https://github.com/adafruit/circuitpython/issues\n" msgstr "" "\n" -"Založte prosím problém s obsahem vaší jednotky CIRCUITPY na adrese\n" +"Prosím vytvořte tiket s obsahem vaší jednotky CIRCUITPY na adrese\n" "https://github.com/adafruit/circuitpython/issues\n" #: py/obj.c @@ -48,11 +52,11 @@ msgstr " Soubor \"%q\", řádek %d" #: py/builtinhelp.c msgid " is of type %q\n" -msgstr "" +msgstr " je typu %q\n" #: main.c msgid " not found.\n" -msgstr "" +msgstr " nenalezen\n" #: main.c msgid " output:\n" @@ -67,23 +71,23 @@ msgstr "%%c vyžaduje int nebo char" #, c-format msgid "" "%d address pins, %d rgb pins and %d tiles indicate a height of %d, not %d" -msgstr "" +msgstr "%d adresní pin, %d rgb pin a %d dlaždice indikuje výšku %d, ne %d" #: shared-bindings/microcontroller/Pin.c msgid "%q and %q contain duplicate pins" -msgstr "" +msgstr "%q a %q obsahují duplicitní piny" #: shared-bindings/microcontroller/Pin.c msgid "%q contains duplicate pins" -msgstr "" +msgstr "%q obsahuje duplicitní piny" #: ports/atmel-samd/common-hal/sdioio/SDCard.c msgid "%q failure: %d" -msgstr "Selhání %q: %d" +msgstr "%q: selhání %d" #: shared-bindings/microcontroller/Pin.c msgid "%q in use" -msgstr "Používá se %q" +msgstr "%q se právě používá" #: ports/atmel-samd/common-hal/pulseio/PulseIn.c #: ports/cxd56/common-hal/pulseio/PulseIn.c @@ -100,23 +104,23 @@ msgstr "Indexy %q musí být celá čísla, nikoli %s" #: py/argcheck.c msgid "%q length must be %d-%d" -msgstr "" +msgstr "%q délka musí být %d-%d" -#: shared-bindings/usb_hid/Device.c +#: shared-bindings/busio/I2C.c shared-bindings/usb_hid/Device.c msgid "%q length must be >= 1" -msgstr "" +msgstr "%q délka musí být >= 1" #: py/argcheck.c msgid "%q must be %d-%d" -msgstr "" +msgstr "%q musí být %d-%d" #: py/argcheck.c shared-bindings/gifio/GifWriter.c msgid "%q must be <= %d" -msgstr "" +msgstr "%q musí být <= %d" #: py/argcheck.c msgid "%q must be >= %d" -msgstr "" +msgstr "%q musí být >= %d" #: py/argcheck.c shared-bindings/memorymonitor/AllocationAlarm.c msgid "%q must be >= 0" @@ -132,7 +136,7 @@ msgstr "%q musí být > = 1" #: py/argcheck.c msgid "%q must be a string" -msgstr "" +msgstr "%q musí být string" #: shared-module/vectorio/Polygon.c msgid "%q must be a tuple of length 2" @@ -141,19 +145,23 @@ msgstr "%q musí být n-tice délky 2" #: ports/espressif/common-hal/imagecapture/ParallelImageCapture.c #: shared-module/vectorio/VectorShape.c msgid "%q must be between %d and %d" -msgstr "" +msgstr "%q musí být mezi %d a %d" #: py/argcheck.c msgid "%q must be of type %q" +msgstr "%q musí být typu %q" + +#: shared-bindings/digitalio/Pull.c +msgid "%q must be of type %q or None" msgstr "" #: ports/atmel-samd/common-hal/busio/UART.c msgid "%q must be power of 2" -msgstr "" +msgstr "%q musí být mocnina 2" #: shared-bindings/wifi/Monitor.c msgid "%q out of bounds" -msgstr "" +msgstr "%q je mimo hranice" #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #: shared-bindings/canio/Match.c @@ -162,7 +170,7 @@ msgstr "%q je mimo rozsah" #: ports/atmel-samd/common-hal/microcontroller/Pin.c msgid "%q pin invalid" -msgstr "Pin %q není platný" +msgstr "pin %q není platný" #: shared-bindings/fontio/BuiltinFont.c msgid "%q should be an int" @@ -170,7 +178,7 @@ msgstr "%q by měl být int" #: shared-bindings/usb_hid/Device.c msgid "%q with a report ID of 0 must be of length 1" -msgstr "" +msgstr "%q s ID 0 musím být délky 1" #: py/bc.c py/objnamedtuple.c msgid "%q() takes %d positional arguments but %d were given" @@ -178,12 +186,12 @@ msgstr "%q() vyžaduje %d pozičních argumentů, ale %d jich bylo zadáno" #: shared-bindings/usb_hid/Device.c msgid "%q, %q, and %q must all be the same length" -msgstr "" +msgstr "%q, %q, a %q musí mít všechny shodnou délku" #: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c #, c-format msgid "%s error 0x%x" -msgstr "" +msgstr "%s chyba 0x%x" #: py/argcheck.c msgid "'%q' argument required" @@ -199,7 +207,7 @@ msgstr "Objekt '%q' není iterátor" #: py/objtype.c py/runtime.c shared-module/atexit/__init__.c msgid "'%q' object is not callable" -msgstr "Objekt '%q' nelze volat" +msgstr "Objekt '%q' nelze zavolat" #: py/runtime.c msgid "'%q' object is not iterable" @@ -208,17 +216,17 @@ msgstr "Objekt '%q' není iterovatelný" #: py/emitinlinethumb.c py/emitinlinextensa.c #, c-format msgid "'%s' expects a label" -msgstr "" +msgstr "'%s' očekává popisek" #: py/emitinlinethumb.c py/emitinlinextensa.c #, c-format msgid "'%s' expects a register" -msgstr "" +msgstr "'%s' očekává register" #: py/emitinlinethumb.c #, c-format msgid "'%s' expects a special register" -msgstr "" +msgstr "'%s' očekává speciální register" #: py/emitinlinethumb.c #, c-format @@ -238,7 +246,7 @@ msgstr "'%s' očekává integer (celé číslo)" #: py/emitinlinethumb.c #, c-format msgid "'%s' expects at most r%d" -msgstr "" +msgstr "'%s' očekává nejvíce r%d" #: py/emitinlinethumb.c #, c-format @@ -248,31 +256,31 @@ msgstr "'%s' očekává {r0, r1, ...}" #: py/emitinlinextensa.c #, c-format msgid "'%s' integer %d isn't within range %d..%d" -msgstr "" +msgstr "'%s' integer %d není v rozsahu %d..%d" #: py/emitinlinethumb.c #, c-format msgid "'%s' integer 0x%x doesn't fit in mask 0x%x" -msgstr "" +msgstr "'%s' integer 0x%x nepatří do masky 0x%x" #: py/obj.c #, c-format msgid "'%s' object doesn't support item assignment" -msgstr "" +msgstr "'%s' objekt nepodporuje přiřazení položky" #: py/obj.c #, c-format msgid "'%s' object doesn't support item deletion" -msgstr "" +msgstr "'%s' objekt nepodporuje smazání položky" #: py/runtime.c msgid "'%s' object has no attribute '%q'" -msgstr "" +msgstr "'%s' objekt nemá žádný atribut '%q'" #: py/obj.c #, c-format msgid "'%s' object isn't subscriptable" -msgstr "" +msgstr "'%s' objekt není vložitelný" #: py/objstr.c msgid "'=' alignment not allowed in string format specifier" @@ -340,7 +348,7 @@ msgstr "" #: py/obj.c msgid ", in %q\n" -msgstr "" +msgstr ", v %q\n" #: py/objcomplex.c msgid "0.0 to a complex power" @@ -445,6 +453,7 @@ msgstr "" msgid "All timers in use" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Already advertising." msgstr "" @@ -525,13 +534,15 @@ msgstr "" #: main.c msgid "Auto-reload is off.\n" -msgstr "" +msgstr "Automatické načtení je vypnuté.\n" #: main.c msgid "" "Auto-reload is on. Simply save files over USB to run them or enter REPL to " "disable.\n" msgstr "" +"Automatické načtení je zapnuté. Stačí uložit soubory na USB nebo vstoupit " +"do REPLu pro jeho zakázání.\n" #: ports/espressif/common-hal/canio/CAN.c msgid "Baudrate not supported by peripheral" @@ -577,7 +588,7 @@ msgstr "" #: shared-bindings/displayio/Display.c #: shared-bindings/framebufferio/FramebufferDisplay.c -#: shared-bindings/is31fl3741/is31fl3741.c +#: shared-bindings/is31fl3741/FrameBuffer.c #: shared-bindings/rgbmatrix/RGBMatrix.c msgid "Brightness must be 0-1.0" msgstr "" @@ -629,7 +640,7 @@ msgstr "" msgid "Buffer must be a multiple of 512 bytes" msgstr "" -#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c +#: shared-bindings/bitbangio/I2C.c msgid "Buffer must be at least length 1" msgstr "" @@ -662,6 +673,10 @@ msgstr "" msgid "CBC blocks must be multiples of 16 bytes" msgstr "" +#: supervisor/shared/safe_mode.c +msgid "CIRCUITPY drive could not be found or created." +msgstr "" + #: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c msgid "CRC or checksum was invalid" msgstr "" @@ -903,10 +918,12 @@ msgstr "" msgid "Data chunk must follow fmt chunk" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data not supported with directed advertising" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data too large for advertisement packet" msgstr "" @@ -987,6 +1004,7 @@ msgstr "" msgid "Expected tuple of length %d, got %d" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Extended advertisements with scan response not supported." msgstr "" @@ -1040,6 +1058,7 @@ msgstr "" msgid "Failed to buffer the sample" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Failed to connect: internal error" msgstr "" @@ -1119,6 +1138,13 @@ msgstr "" msgid "Group already used" msgstr "" +#: ports/atmel-samd/common-hal/busio/SPI.c ports/cxd56/common-hal/busio/SPI.c +#: ports/espressif/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/nrf/common-hal/busio/SPI.c +#: ports/raspberrypi/common-hal/busio/SPI.c +msgid "Half duplex SPI is not implemented" +msgstr "" + #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/I2C.c #: ports/stm/common-hal/busio/SPI.c ports/stm/common-hal/canio/CAN.c #: ports/stm/common-hal/sdioio/SDCard.c @@ -1271,6 +1297,7 @@ msgstr "" msgid "Invalid AuthMode" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c msgid "Invalid BLE parameter" msgstr "" @@ -1365,6 +1392,10 @@ msgstr "" msgid "Invalid memory access." msgstr "" +#: extmod/vfs_fat_file.c +msgid "Invalid mode" +msgstr "" + #: ports/espressif/common-hal/wifi/Radio.c msgid "Invalid multicast MAC address" msgstr "" @@ -1465,7 +1496,7 @@ msgstr "" msgid "Key must be 16, 24, or 32 bytes long" msgstr "" -#: shared-module/is31fl3741/is31fl3741.c +#: shared-module/is31fl3741/FrameBuffer.c msgid "LED mappings must match display size" msgstr "" @@ -1493,6 +1524,10 @@ msgstr "" msgid "MOSI pin init failed." msgstr "" +#: shared-bindings/is31fl3741/IS31FL3741.c +msgid "Mapping must be a tuple" +msgstr "" + #: shared-module/displayio/Shape.c #, c-format msgid "Maximum x value when mirrored is %d" @@ -1575,6 +1610,10 @@ msgstr "" msgid "Name too long" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +msgid "Nimble out of memory" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "" @@ -1595,9 +1634,9 @@ msgstr "" msgid "No DMA pacing timer found" msgstr "" -#: shared-module/adafruit_bus_device/I2CDevice.c +#: shared-module/adafruit_bus_device/i2c_device/I2CDevice.c #, c-format -msgid "No I2C device at address: %x" +msgid "No I2C device at address: 0x%x" msgstr "" #: ports/espressif/common-hal/busio/SPI.c @@ -1722,6 +1761,7 @@ msgstr "" msgid "Not a valid IP string" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -1895,7 +1935,7 @@ msgstr "" msgid "Pin interrupt already in use" msgstr "" -#: shared-bindings/adafruit_bus_device/SPIDevice.c +#: shared-bindings/adafruit_bus_device/spi_device/SPIDevice.c #: shared-bindings/digitalio/DigitalInOut.c msgid "Pin is input only" msgstr "" @@ -1943,10 +1983,12 @@ msgstr "" #: main.c msgid "Press any key to enter the REPL. Use CTRL-D to reload.\n" msgstr "" +"Zmáčkněte jakoukoli klávesu pro spuštění REPLu. Použijte CTRL-D pro opětovné " +"načtení.\n" #: main.c msgid "Pretending to deep sleep until alarm, CTRL-C or file write.\n" -msgstr "" +msgstr "Předstírám hluboký spánek do alarmu, CTRL-C nebo zápisu souboru.\n" #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c msgid "Program does IN without loading ISR" @@ -1977,6 +2019,10 @@ msgstr "" msgid "RAISE mode is not implemented" msgstr "" +#: ports/raspberrypi/common-hal/countio/Counter.c +msgid "RISE_AND_FALL not available on this chip" +msgstr "" + #: ports/stm/common-hal/os/__init__.c msgid "RNG DeInit Error" msgstr "" @@ -2093,10 +2139,11 @@ msgstr "" msgid "Sample rate too high. It must be less than %d" msgstr "" -#: shared-bindings/is31fl3741/is31fl3741.c +#: shared-bindings/is31fl3741/FrameBuffer.c msgid "Scale dimensions must divide by 3" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Scan already in progess. Stop with stop_scan." msgstr "" @@ -2255,6 +2302,7 @@ msgstr "" msgid "Time is in the past." msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2277,6 +2325,7 @@ msgstr "" msgid "Too many displays" msgstr "" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Total data to write is larger than %q" msgstr "" @@ -2354,7 +2403,7 @@ msgstr "" msgid "Unable to create lock" msgstr "" -#: shared-module/displayio/I2CDisplay.c shared-module/is31fl3741/is31fl3741.c +#: shared-module/displayio/I2CDisplay.c shared-module/is31fl3741/IS31FL3741.c #, c-format msgid "Unable to find I2C Display at %x" msgstr "" @@ -2389,6 +2438,16 @@ msgstr "" msgid "Unhandled ESP TLS error %d %d %x %d" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown BLE error at %s:%d: %d" +msgstr "" + +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown BLE error: %d" +msgstr "" + #: shared-bindings/wifi/Radio.c #, c-format msgid "Unknown failure %d" @@ -2408,11 +2467,21 @@ msgstr "" msgid "Unknown security error: 0x%04x" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error at %s:%d: %d" +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown system firmware error: %04x" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error: %d" +msgstr "" + #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #, c-format msgid "Unmatched number of items on RHS (expected %d, got %d)." @@ -2446,19 +2515,19 @@ msgstr "" msgid "Unsupported operation" msgstr "" -#: shared-bindings/digitalio/DigitalInOut.c -msgid "Unsupported pull value." -msgstr "" - #: ports/espressif/common-hal/dualbank/__init__.c msgid "Update Failed" msgstr "" +#: ports/espressif/common-hal/_bleio/Characteristic.c +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length != required fixed length" msgstr "" +#: ports/espressif/common-hal/_bleio/Characteristic.c +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length > max_length" @@ -2516,6 +2585,7 @@ msgstr "" msgid "Woken up by alarm.\n" msgstr "" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Writes not supported on Characteristic" msgstr "" @@ -2619,7 +2689,7 @@ msgstr "" msgid "attributes not supported yet" msgstr "" -#: extmod/ulab/code/numpy/numerical.c +#: extmod/ulab/code/ulab_tools.c msgid "axis is out of bounds" msgstr "" @@ -2675,11 +2745,11 @@ msgstr "" msgid "branch not in range" msgstr "" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/utils/utils.c msgid "buffer is smaller than requested size" msgstr "" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/utils/utils.c msgid "buffer size must be a multiple of element size" msgstr "" @@ -2729,6 +2799,10 @@ msgstr "" msgid "calibration value out of range +/-127" msgstr "" +#: shared-module/vectorio/Rectangle.c +msgid "can only be registered in one parent" +msgstr "" + #: py/emitinlinethumb.c msgid "can only have up to 4 parameters to Thumb assembly" msgstr "" @@ -2767,6 +2841,10 @@ msgstr "" msgid "can't convert '%q' object to %q implicitly" msgstr "" +#: extmod/ulab/code/numpy/vector.c +msgid "can't convert complex to float" +msgstr "" + #: py/obj.c msgid "can't convert to %q" msgstr "" @@ -2819,6 +2897,10 @@ msgstr "" msgid "can't load with '%q' index" msgstr "" +#: py/builtinimport.c +msgid "can't perform relative import" +msgstr "" + #: py/objgenerator.c msgid "can't send non-None value to a just-started generator" msgstr "" @@ -2861,6 +2943,14 @@ msgstr "" msgid "cannot cast output with casting rule" msgstr "" +#: extmod/ulab/code/ndarray.c +msgid "cannot convert complex to dtype" +msgstr "" + +#: extmod/ulab/code/ndarray.c +msgid "cannot convert complex type" +msgstr "" + #: py/objtype.c msgid "cannot create '%q' instances" msgstr "" @@ -2873,10 +2963,6 @@ msgstr "" msgid "cannot import name %q" msgstr "" -#: py/builtinimport.c -msgid "cannot perform relative import" -msgstr "" - #: extmod/moductypes.c msgid "cannot unambiguously get sizeof scalar" msgstr "" @@ -3052,6 +3138,10 @@ msgstr "" msgid "divisor must be 4" msgstr "" +#: extmod/ulab/code/numpy/vector.c +msgid "dtype must be float, or complex" +msgstr "" + #: py/objdeque.c msgid "empty" msgstr "" @@ -3155,7 +3245,7 @@ msgstr "" msgid "first argument must be a function" msgstr "" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "first argument must be a tuple of ndarrays" msgstr "" @@ -3220,6 +3310,10 @@ msgstr "" msgid "function is defined for ndarrays only" msgstr "" +#: extmod/ulab/code/numpy/carray/carray.c +msgid "function is implemented for ndarrays only" +msgstr "" + #: py/argcheck.c #, c-format msgid "function missing %d required positional arguments" @@ -3333,7 +3427,7 @@ msgstr "" msgid "input and output shapes are not compatible" msgstr "" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "input argument must be an integer, a tuple, or a list" msgstr "" @@ -3341,7 +3435,7 @@ msgstr "" msgid "input array length must be power of 2" msgstr "" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "input arrays are not compatible" msgstr "" @@ -3349,6 +3443,10 @@ msgstr "" msgid "input data must be an iterable" msgstr "" +#: extmod/ulab/code/numpy/vector.c +msgid "input dtype must be float or complex" +msgstr "" + #: extmod/ulab/code/numpy/linalg/linalg.c msgid "input matrix is asymmetric" msgstr "" @@ -3358,18 +3456,26 @@ msgstr "" msgid "input matrix is singular" msgstr "" +#: extmod/ulab/code/numpy/carray/carray.c +msgid "input must be a 1D ndarray" +msgstr "" + #: extmod/ulab/code/scipy/linalg/linalg.c extmod/ulab/code/user/user.c msgid "input must be a dense ndarray" msgstr "" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "input must be a tensor of rank 2" msgstr "" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/user/user.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/user/user.c msgid "input must be an ndarray" msgstr "" +#: extmod/ulab/code/numpy/carray/carray.c +msgid "input must be an ndarray, or a scalar" +msgstr "" + #: extmod/ulab/code/scipy/signal/signal.c msgid "input must be one-dimensional" msgstr "" @@ -3547,6 +3653,11 @@ msgstr "" msgid "matrix is not positive definite" msgstr "" +#: ports/espressif/common-hal/wifi/Radio.c +msgid "max_connections must be between 0 and 10" +msgstr "" + +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c #, c-format @@ -3700,6 +3811,7 @@ msgstr "" msgid "non-Device in %q" msgstr "" +#: ports/espressif/common-hal/_bleio/Connection.c #: ports/nrf/common-hal/_bleio/Connection.c msgid "non-UUID found in service_uuids_whitelist" msgstr "" @@ -3740,7 +3852,11 @@ msgstr "" msgid "not enough arguments for format string" msgstr "" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/carray/carray_tools.c +msgid "not implemented for complex dtype" +msgstr "" + +#: extmod/ulab/code/numpy/create.c msgid "number of points must be at least 2" msgstr "" @@ -3798,7 +3914,7 @@ msgstr "" msgid "odd-length string" msgstr "" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/utils/utils.c msgid "offset is too large" msgstr "" @@ -3806,7 +3922,7 @@ msgstr "" msgid "offset must be >= 0" msgstr "" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "offset must be non-negative and no greater than buffer length" msgstr "" @@ -3918,6 +4034,10 @@ msgstr "" msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "" +#: extmod/vfs_posix_file.c +msgid "poll on file not available on win32" +msgstr "" + #: shared-module/vectorio/Polygon.c msgid "polygon can only be registered in one parent" msgstr "" @@ -3947,18 +4067,27 @@ msgstr "" msgid "pow() with 3 arguments requires integers" msgstr "" +#: ports/espressif/boards/adafruit_esp32s2_camera/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tft/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h #: ports/espressif/boards/adafruit_funhouse/mpconfigboard.h #: ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h +#: ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h +#: ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h #: ports/espressif/boards/atmegazero_esp32s2/mpconfigboard.h #: ports/espressif/boards/crumpspace_crumps2/mpconfigboard.h #: ports/espressif/boards/electroniccats_bastwifi/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s2_devkitc_1_n4r2/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_box/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h #: ports/espressif/boards/espressif_hmi_devkit_1/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1.3/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1/mpconfigboard.h @@ -3984,7 +4113,10 @@ msgstr "" #: ports/espressif/boards/unexpectedmaker_feathers2/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_neo/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_prerelease/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_feathers3/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_pros3/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_tinys2/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_tinys3/mpconfigboard.h msgid "pressing boot button at start up.\n" msgstr "" @@ -4281,7 +4413,7 @@ msgstr "" msgid "too many arguments provided with the given format" msgstr "" -#: extmod/ulab/code/ndarray.c extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/ndarray.c extmod/ulab/code/numpy/create.c msgid "too many dimensions" msgstr "" @@ -4465,7 +4597,7 @@ msgstr "" msgid "width must be from 2 to 8 (inclusive), not %d" msgstr "" -#: shared-bindings/is31fl3741/is31fl3741.c +#: shared-bindings/is31fl3741/FrameBuffer.c #: shared-bindings/rgbmatrix/RGBMatrix.c msgid "width must be greater than zero" msgstr "" @@ -4482,7 +4614,7 @@ msgstr "" msgid "wrong axis index" msgstr "" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "wrong axis specified" msgstr "" @@ -4490,7 +4622,11 @@ msgstr "" msgid "wrong input type" msgstr "" -#: extmod/ulab/code/ulab_create.c py/objarray.c py/objstr.c +#: extmod/ulab/code/numpy/transform.c +msgid "wrong length of condition array" +msgstr "" + +#: extmod/ulab/code/numpy/create.c py/objarray.c py/objstr.c msgid "wrong number of arguments" msgstr "" diff --git a/locale/de_DE.po b/locale/de_DE.po index 2ee5eda3e9..e9c35a779f 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -6,14 +6,14 @@ msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-01-04 12:55-0600\n" -"PO-Revision-Date: 2021-08-23 14:19+0000\n" -"Last-Translator: Jeff Epler \n" +"PO-Revision-Date: 2022-02-23 09:55+0000\n" +"Last-Translator: Fabian Affolter \n" "Language: de_DE\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Generator: Weblate 4.8.1-dev\n" +"X-Generator: Weblate 4.11-dev\n" #: main.c msgid "" @@ -55,7 +55,7 @@ msgstr " ist vom Type %q\n" #: main.c msgid " not found.\n" -msgstr "" +msgstr " nicht gefunden.\n" #: main.c msgid " output:\n" @@ -107,21 +107,21 @@ msgstr "%q Indizes müssen Integer sein, nicht %s" msgid "%q length must be %d-%d" msgstr "" -#: shared-bindings/usb_hid/Device.c +#: shared-bindings/busio/I2C.c shared-bindings/usb_hid/Device.c msgid "%q length must be >= 1" msgstr "" #: py/argcheck.c msgid "%q must be %d-%d" -msgstr "" +msgstr "%q muss %d-%d sein" #: py/argcheck.c shared-bindings/gifio/GifWriter.c msgid "%q must be <= %d" -msgstr "" +msgstr "%q muss <= %d sein" #: py/argcheck.c msgid "%q must be >= %d" -msgstr "" +msgstr "%q muss >= %d sein" #: py/argcheck.c shared-bindings/memorymonitor/AllocationAlarm.c msgid "%q must be >= 0" @@ -137,7 +137,7 @@ msgstr "%q muss >= 1 sein" #: py/argcheck.c msgid "%q must be a string" -msgstr "" +msgstr "%q muss ein String sein" #: shared-module/vectorio/Polygon.c msgid "%q must be a tuple of length 2" @@ -152,6 +152,10 @@ msgstr "" msgid "%q must be of type %q" msgstr "" +#: shared-bindings/digitalio/Pull.c +msgid "%q must be of type %q or None" +msgstr "" + #: ports/atmel-samd/common-hal/busio/UART.c msgid "%q must be power of 2" msgstr "" @@ -451,6 +455,7 @@ msgstr "Alle timer für diesen Pin werden bereits benutzt" msgid "All timers in use" msgstr "Alle timer werden benutzt" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Already advertising." msgstr "Bereits am anbieten (advertising)." @@ -585,7 +590,7 @@ msgstr "Beide pins müssen Hardware Interrupts unterstützen" #: shared-bindings/displayio/Display.c #: shared-bindings/framebufferio/FramebufferDisplay.c -#: shared-bindings/is31fl3741/is31fl3741.c +#: shared-bindings/is31fl3741/FrameBuffer.c #: shared-bindings/rgbmatrix/RGBMatrix.c msgid "Brightness must be 0-1.0" msgstr "Die Helligkeit muss zwischen 0 und 1.0 liegen" @@ -637,7 +642,7 @@ msgstr "Die Pufferlänge muss ein vielfaches von 512 sein" msgid "Buffer must be a multiple of 512 bytes" msgstr "Der Puffer muss ein vielfaches von 512 bytes sein" -#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c +#: shared-bindings/bitbangio/I2C.c msgid "Buffer must be at least length 1" msgstr "Der Puffer muss eine Mindestenslänge von 1 haben" @@ -670,6 +675,10 @@ msgstr "Ein Bytes kann nur Werte zwischen 0 und 255 annehmen." msgid "CBC blocks must be multiples of 16 bytes" msgstr "CBC-Blöcke müssen ein Vielfaches von 16 Bytes sein" +#: supervisor/shared/safe_mode.c +msgid "CIRCUITPY drive could not be found or created." +msgstr "" + #: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c msgid "CRC or checksum was invalid" msgstr "CRC oder Checksumme ungültig" @@ -915,10 +924,12 @@ msgstr "Data 0 pin muss am Byte ausgerichtet sein" msgid "Data chunk must follow fmt chunk" msgstr "Dem fmt Block muss ein Datenblock folgen" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data not supported with directed advertising" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data too large for advertisement packet" msgstr "Zu vielen Daten für das advertisement packet" @@ -999,6 +1010,7 @@ msgstr "Alarm erwartet" msgid "Expected tuple of length %d, got %d" msgstr "Habe ein Tupel der Länge %d erwartet aber %d erhalten" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Extended advertisements with scan response not supported." msgstr "" @@ -1053,6 +1065,7 @@ msgstr "Zuweisung des Wifi Scan Speichers ist fehlgeschlagen" msgid "Failed to buffer the sample" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Failed to connect: internal error" msgstr "Verbindung fehlgeschlagen: interner Fehler" @@ -1134,6 +1147,13 @@ msgstr "Generischer Fehler" msgid "Group already used" msgstr "Gruppe schon benutzt" +#: ports/atmel-samd/common-hal/busio/SPI.c ports/cxd56/common-hal/busio/SPI.c +#: ports/espressif/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/nrf/common-hal/busio/SPI.c +#: ports/raspberrypi/common-hal/busio/SPI.c +msgid "Half duplex SPI is not implemented" +msgstr "" + #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/I2C.c #: ports/stm/common-hal/busio/SPI.c ports/stm/common-hal/canio/CAN.c #: ports/stm/common-hal/sdioio/SDCard.c @@ -1288,6 +1308,7 @@ msgstr "Ungültiger ADC-Einheitenwert" msgid "Invalid AuthMode" msgstr "Ungültiges AuthMode" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c msgid "Invalid BLE parameter" msgstr "Ungültiges BLE Parameter" @@ -1382,6 +1403,10 @@ msgstr "Ungültige format chunk size" msgid "Invalid memory access." msgstr "Ungültiger Speicherzugriff." +#: extmod/vfs_fat_file.c +msgid "Invalid mode" +msgstr "" + #: ports/espressif/common-hal/wifi/Radio.c msgid "Invalid multicast MAC address" msgstr "" @@ -1482,7 +1507,7 @@ msgstr "Ungültige Wort- / Bitlänge" msgid "Key must be 16, 24, or 32 bytes long" msgstr "Der Schlüssel muss 16, 24 oder 32 Byte lang sein" -#: shared-module/is31fl3741/is31fl3741.c +#: shared-module/is31fl3741/FrameBuffer.c msgid "LED mappings must match display size" msgstr "" @@ -1510,6 +1535,10 @@ msgstr "MISO pin Initialisierung fehlgeschlagen." msgid "MOSI pin init failed." msgstr "MOSI pin Initialisierung fehlgeschlagen." +#: shared-bindings/is31fl3741/IS31FL3741.c +msgid "Mapping must be a tuple" +msgstr "" + #: shared-module/displayio/Shape.c #, c-format msgid "Maximum x value when mirrored is %d" @@ -1593,6 +1622,10 @@ msgstr "NVS Fehler" msgid "Name too long" msgstr "Name zu lang" +#: ports/espressif/common-hal/_bleio/__init__.c +msgid "Nimble out of memory" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "Kein CCCD für diese Charakteristik" @@ -1613,9 +1646,9 @@ msgstr "Kein DMA Kanal gefunden" msgid "No DMA pacing timer found" msgstr "" -#: shared-module/adafruit_bus_device/I2CDevice.c +#: shared-module/adafruit_bus_device/i2c_device/I2CDevice.c #, c-format -msgid "No I2C device at address: %x" +msgid "No I2C device at address: 0x%x" msgstr "" #: ports/espressif/common-hal/busio/SPI.c @@ -1740,6 +1773,7 @@ msgstr "" msgid "Not a valid IP string" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -1902,7 +1936,7 @@ msgstr "" #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c msgid "Pin count too large" -msgstr "" +msgstr "Pin-Anzahl zu gross" #: ports/atmel-samd/common-hal/analogio/AnalogIn.c #: ports/cxd56/common-hal/analogio/AnalogIn.c @@ -1912,14 +1946,14 @@ msgstr "" #: ports/raspberrypi/common-hal/analogio/AnalogIn.c #: ports/stm/common-hal/analogio/AnalogIn.c msgid "Pin does not have ADC capabilities" -msgstr "Pin hat keine ADC Funktionalität" +msgstr "Pin hat keine ADC-Funktionalität" #: ports/stm/common-hal/alarm/pin/PinAlarm.c #: ports/stm/common-hal/pulseio/PulseIn.c msgid "Pin interrupt already in use" msgstr "" -#: shared-bindings/adafruit_bus_device/SPIDevice.c +#: shared-bindings/adafruit_bus_device/spi_device/SPIDevice.c #: shared-bindings/digitalio/DigitalInOut.c msgid "Pin is input only" msgstr "Pin kann nur als Eingang verwendet werden" @@ -1991,7 +2025,7 @@ msgstr "" #: ports/raspberrypi/bindings/rp2pio/StateMachine.c msgid "Program size invalid" -msgstr "" +msgstr "Programm-Größe ist ungültig" #: ports/raspberrypi/bindings/rp2pio/StateMachine.c msgid "Program too large" @@ -2006,6 +2040,10 @@ msgstr "Pull wird nicht verwendet, wenn die Richtung output ist." msgid "RAISE mode is not implemented" msgstr "" +#: ports/raspberrypi/common-hal/countio/Counter.c +msgid "RISE_AND_FALL not available on this chip" +msgstr "" + #: ports/stm/common-hal/os/__init__.c msgid "RNG DeInit Error" msgstr "RNG DeInit-Fehler" @@ -2122,10 +2160,11 @@ msgstr "Abtastrate muss positiv sein" msgid "Sample rate too high. It must be less than %d" msgstr "Abtastrate zu hoch. Wert muss unter %d liegen" -#: shared-bindings/is31fl3741/is31fl3741.c +#: shared-bindings/is31fl3741/FrameBuffer.c msgid "Scale dimensions must divide by 3" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Scan already in progess. Stop with stop_scan." msgstr "Scannen Sie bereits in Bearbeitung. Stoppen Sie mit stop_scan." @@ -2286,6 +2325,7 @@ msgstr "Die Kachelbreite muss die Bitmap-Breite genau teilen" msgid "Time is in the past." msgstr "Zeit liegt in der Vergangenheit" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2309,6 +2349,7 @@ msgstr "Zu viele Display Busse" msgid "Too many displays" msgstr "Zu viele displays" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Total data to write is larger than %q" msgstr "Gesamte zu schreibende Datenmenge ist größer als %q" @@ -2386,7 +2427,7 @@ msgstr "Konnte keine Buffer für Vorzeichenumwandlung allozieren" msgid "Unable to create lock" msgstr "" -#: shared-module/displayio/I2CDisplay.c shared-module/is31fl3741/is31fl3741.c +#: shared-module/displayio/I2CDisplay.c shared-module/is31fl3741/IS31FL3741.c #, c-format msgid "Unable to find I2C Display at %x" msgstr "Konnte kein I2C Display finden an %x" @@ -2421,6 +2462,16 @@ msgstr "Unerwarteter nrfx uuid-Typ" msgid "Unhandled ESP TLS error %d %d %x %d" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown BLE error at %s:%d: %d" +msgstr "" + +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown BLE error: %d" +msgstr "" + #: shared-bindings/wifi/Radio.c #, c-format msgid "Unknown failure %d" @@ -2440,11 +2491,21 @@ msgstr "Unbekannter Grund." msgid "Unknown security error: 0x%04x" msgstr "Unbekannter Sicherheitsfehler: 0x%04x" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error at %s:%d: %d" +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown system firmware error: %04x" msgstr "Unbekannter Systemfirmware Fehler: %04x" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error: %d" +msgstr "" + #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #, c-format msgid "Unmatched number of items on RHS (expected %d, got %d)." @@ -2482,19 +2543,19 @@ msgstr "Nicht unterstütztes Format" msgid "Unsupported operation" msgstr "Nicht unterstützte Operation" -#: shared-bindings/digitalio/DigitalInOut.c -msgid "Unsupported pull value." -msgstr "Nicht unterstützter Pull-Wert." - #: ports/espressif/common-hal/dualbank/__init__.c msgid "Update Failed" msgstr "Update fehlgeschlagen" +#: ports/espressif/common-hal/_bleio/Characteristic.c +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length != required fixed length" msgstr "Wert Länge != Erforderliche feste Länge" +#: ports/espressif/common-hal/_bleio/Characteristic.c +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length > max_length" @@ -2555,6 +2616,7 @@ msgstr "WiFi Passwort muss zwischen 8 und 63 Zeichen lang sein" msgid "Woken up by alarm.\n" msgstr "Aufgeweckt durch Alarm.\n" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Writes not supported on Characteristic" msgstr "Schreiben nicht unterstüzt für diese Charakteristik" @@ -2658,7 +2720,7 @@ msgstr "Sie haben versucht argmin/argmax einer leeren Sequenz zu erhalten" msgid "attributes not supported yet" msgstr "Attribute werden noch nicht unterstützt" -#: extmod/ulab/code/numpy/numerical.c +#: extmod/ulab/code/ulab_tools.c msgid "axis is out of bounds" msgstr "Achse außerhalb des Wertebereichs" @@ -2714,11 +2776,11 @@ msgstr "Es müssen 8 oder 16 bits_per_sample sein" msgid "branch not in range" msgstr "Zweig ist außerhalb der Reichweite" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/utils/utils.c msgid "buffer is smaller than requested size" msgstr "Der Puffer ist kleiner als die angefragte Größe" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/utils/utils.c msgid "buffer size must be a multiple of element size" msgstr "Die Puffergröße muss ein vielfaches der Elementgröße sein" @@ -2768,6 +2830,10 @@ msgstr "Kalibrierung ist Schreibgeschützt" msgid "calibration value out of range +/-127" msgstr "Kalibrierwert nicht im Bereich von +/-127" +#: shared-module/vectorio/Rectangle.c +msgid "can only be registered in one parent" +msgstr "" + #: py/emitinlinethumb.c msgid "can only have up to 4 parameters to Thumb assembly" msgstr "kann nur bis zu 4 Parameter für die Thumb assembly haben" @@ -2808,6 +2874,10 @@ msgstr "kann %s nicht nach complex konvertieren" msgid "can't convert '%q' object to %q implicitly" msgstr "Kann '%q' Objekt nicht implizit nach %q konvertieren" +#: extmod/ulab/code/numpy/vector.c +msgid "can't convert complex to float" +msgstr "" + #: py/obj.c msgid "can't convert to %q" msgstr "kann nicht zu %q konvertieren" @@ -2860,6 +2930,10 @@ msgstr "Laden von '%q' nicht möglich" msgid "can't load with '%q' index" msgstr "Laden mit '%q' index nicht möglich" +#: py/builtinimport.c +msgid "can't perform relative import" +msgstr "" + #: py/objgenerator.c msgid "can't send non-None value to a just-started generator" msgstr "" @@ -2908,6 +2982,14 @@ msgstr "Kann neue shape nicht zuweisen" msgid "cannot cast output with casting rule" msgstr "" +#: extmod/ulab/code/ndarray.c +msgid "cannot convert complex to dtype" +msgstr "" + +#: extmod/ulab/code/ndarray.c +msgid "cannot convert complex type" +msgstr "" + #: py/objtype.c msgid "cannot create '%q' instances" msgstr "Kann '%q' Instanzen nicht erstellen" @@ -2920,10 +3002,6 @@ msgstr "Kann Instanz nicht erstellen" msgid "cannot import name %q" msgstr "Name %q kann nicht importiert werden" -#: py/builtinimport.c -msgid "cannot perform relative import" -msgstr "kann keinen relativen Import durchführen" - #: extmod/moductypes.c msgid "cannot unambiguously get sizeof scalar" msgstr "Kann nicht eindeutig die Größe (sizeof) des Skalars ermitteln" @@ -3103,6 +3181,10 @@ msgstr "Division durch Null" msgid "divisor must be 4" msgstr "" +#: extmod/ulab/code/numpy/vector.c +msgid "dtype must be float, or complex" +msgstr "" + #: py/objdeque.c msgid "empty" msgstr "leer" @@ -3206,7 +3288,7 @@ msgstr "" msgid "first argument must be a function" msgstr "" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "first argument must be a tuple of ndarrays" msgstr "" @@ -3271,6 +3353,10 @@ msgstr "" msgid "function is defined for ndarrays only" msgstr "" +#: extmod/ulab/code/numpy/carray/carray.c +msgid "function is implemented for ndarrays only" +msgstr "" + #: py/argcheck.c #, c-format msgid "function missing %d required positional arguments" @@ -3386,7 +3472,7 @@ msgstr "inline assembler muss eine function sein" msgid "input and output shapes are not compatible" msgstr "" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "input argument must be an integer, a tuple, or a list" msgstr "das Eingabeargument muss ein Integer, Tupel oder eine Liste sein" @@ -3394,7 +3480,7 @@ msgstr "das Eingabeargument muss ein Integer, Tupel oder eine Liste sein" msgid "input array length must be power of 2" msgstr "Die Länge des Eingabearrays muss eine Potenz von 2 sein" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "input arrays are not compatible" msgstr "Eingabe-Arrays sind nicht kompatibel" @@ -3402,6 +3488,10 @@ msgstr "Eingabe-Arrays sind nicht kompatibel" msgid "input data must be an iterable" msgstr "Eingabedaten müssen iterierbar sein" +#: extmod/ulab/code/numpy/vector.c +msgid "input dtype must be float or complex" +msgstr "" + #: extmod/ulab/code/numpy/linalg/linalg.c msgid "input matrix is asymmetric" msgstr "Eingabematrix ist asymmetrisch" @@ -3411,18 +3501,26 @@ msgstr "Eingabematrix ist asymmetrisch" msgid "input matrix is singular" msgstr "Eingabematrix ist singulär" +#: extmod/ulab/code/numpy/carray/carray.c +msgid "input must be a 1D ndarray" +msgstr "" + #: extmod/ulab/code/scipy/linalg/linalg.c extmod/ulab/code/user/user.c msgid "input must be a dense ndarray" msgstr "" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "input must be a tensor of rank 2" msgstr "" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/user/user.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/user/user.c msgid "input must be an ndarray" msgstr "" +#: extmod/ulab/code/numpy/carray/carray.c +msgid "input must be an ndarray, or a scalar" +msgstr "" + #: extmod/ulab/code/scipy/signal/signal.c msgid "input must be one-dimensional" msgstr "die Eingabe muss ein-Dimensional sein" @@ -3606,6 +3704,11 @@ msgstr "Mathe-Domain-Fehler" msgid "matrix is not positive definite" msgstr "Matrix ist nicht positiv definitiv" +#: ports/espressif/common-hal/wifi/Radio.c +msgid "max_connections must be between 0 and 10" +msgstr "" + +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c #, c-format @@ -3759,6 +3862,7 @@ msgstr "kein solches Attribut" msgid "non-Device in %q" msgstr "" +#: ports/espressif/common-hal/_bleio/Connection.c #: ports/nrf/common-hal/_bleio/Connection.c msgid "non-UUID found in service_uuids_whitelist" msgstr "non-UUID gefunden in service_uuids_whitelist" @@ -3800,7 +3904,11 @@ msgstr "" msgid "not enough arguments for format string" msgstr "Nicht genügend Argumente für den Formatierungs-String" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/carray/carray_tools.c +msgid "not implemented for complex dtype" +msgstr "" + +#: extmod/ulab/code/numpy/create.c msgid "number of points must be at least 2" msgstr "Die Anzahl der Punkte muss mindestens 2 betragen" @@ -3858,7 +3966,7 @@ msgstr "Objekt mit Pufferprotokoll (buffer protocol) erforderlich" msgid "odd-length string" msgstr "String mit ungerader Länge" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/utils/utils.c msgid "offset is too large" msgstr "" @@ -3866,7 +3974,7 @@ msgstr "" msgid "offset must be >= 0" msgstr "" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "offset must be non-negative and no greater than buffer length" msgstr "" @@ -3981,6 +4089,10 @@ msgstr "Der Pixelwert erfordert zu viele Bits" msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "pixel_shader muss displayio.Palette oder displayio.ColorConverter sein" +#: extmod/vfs_posix_file.c +msgid "poll on file not available on win32" +msgstr "" + #: shared-module/vectorio/Polygon.c msgid "polygon can only be registered in one parent" msgstr "Polygon kann nur in einem übergeordneten Element registriert werden" @@ -4010,18 +4122,27 @@ msgstr "pow() drittes Argument darf nicht 0 sein" msgid "pow() with 3 arguments requires integers" msgstr "pow() mit 3 Argumenten erfordert Integer" +#: ports/espressif/boards/adafruit_esp32s2_camera/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tft/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h #: ports/espressif/boards/adafruit_funhouse/mpconfigboard.h #: ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h +#: ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h +#: ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h #: ports/espressif/boards/atmegazero_esp32s2/mpconfigboard.h #: ports/espressif/boards/crumpspace_crumps2/mpconfigboard.h #: ports/espressif/boards/electroniccats_bastwifi/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s2_devkitc_1_n4r2/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_box/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h #: ports/espressif/boards/espressif_hmi_devkit_1/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1.3/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1/mpconfigboard.h @@ -4047,7 +4168,10 @@ msgstr "pow() mit 3 Argumenten erfordert Integer" #: ports/espressif/boards/unexpectedmaker_feathers2/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_neo/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_prerelease/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_feathers3/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_pros3/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_tinys2/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_tinys3/mpconfigboard.h msgid "pressing boot button at start up.\n" msgstr "" @@ -4347,7 +4471,7 @@ msgstr "" msgid "too many arguments provided with the given format" msgstr "zu viele Argumente mit dem angegebenen Format" -#: extmod/ulab/code/ndarray.c extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/ndarray.c extmod/ulab/code/numpy/create.c msgid "too many dimensions" msgstr "zu viele Dimensionen" @@ -4484,11 +4608,11 @@ msgstr "nicht unterstützte Xtensa-Anweisung '%s' mit %d Argumenten" #: shared-module/gifio/GifWriter.c msgid "unsupported colorspace for GifWriter" -msgstr "" +msgstr "Farbraum wird nicht unterstützt für GifWriter" #: shared-bindings/bitmaptools/__init__.c msgid "unsupported colorspace for dither" -msgstr "" +msgstr "Farbraum wird nicht unterstützt für dither" #: py/objstr.c #, c-format @@ -4533,10 +4657,10 @@ msgstr "watchdog Zeitlimit muss größer als 0 sein" msgid "width must be from 2 to 8 (inclusive), not %d" msgstr "breite muss zwischen (inklusive) 2 und 8 liegen, nicht %d" -#: shared-bindings/is31fl3741/is31fl3741.c +#: shared-bindings/is31fl3741/FrameBuffer.c #: shared-bindings/rgbmatrix/RGBMatrix.c msgid "width must be greater than zero" -msgstr "breite muss größer als 0 sein" +msgstr "Breite muss größer als 0 sein" #: ports/espressif/common-hal/wifi/Radio.c msgid "wifi is not enabled" @@ -4550,7 +4674,7 @@ msgstr "Fenster muss <= Intervall sein" msgid "wrong axis index" msgstr "falscher Achsenindex" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "wrong axis specified" msgstr "falsche Achse gewählt" @@ -4558,7 +4682,11 @@ msgstr "falsche Achse gewählt" msgid "wrong input type" msgstr "falscher Eingabetyp" -#: extmod/ulab/code/ulab_create.c py/objarray.c py/objstr.c +#: extmod/ulab/code/numpy/transform.c +msgid "wrong length of condition array" +msgstr "falsche Länge des Array von Bedingungen" + +#: extmod/ulab/code/numpy/create.c py/objarray.c py/objstr.c msgid "wrong number of arguments" msgstr "falsche Anzahl an Argumenten" @@ -4602,6 +4730,12 @@ msgstr "zi muss eine Gleitkommazahl sein" msgid "zi must be of shape (n_section, 2)" msgstr "" +#~ msgid "cannot perform relative import" +#~ msgstr "kann keinen relativen Import durchführen" + +#~ msgid "Unsupported pull value." +#~ msgstr "Nicht unterstützter Pull-Wert." + #, c-format #~ msgid "" #~ "Welcome to Adafruit CircuitPython %s!\n" diff --git a/locale/el.po b/locale/el.po index de46c6c73d..902f7a35b6 100644 --- a/locale/el.po +++ b/locale/el.po @@ -99,7 +99,7 @@ msgstr "" msgid "%q length must be %d-%d" msgstr "" -#: shared-bindings/usb_hid/Device.c +#: shared-bindings/busio/I2C.c shared-bindings/usb_hid/Device.c msgid "%q length must be >= 1" msgstr "" @@ -144,6 +144,10 @@ msgstr "" msgid "%q must be of type %q" msgstr "" +#: shared-bindings/digitalio/Pull.c +msgid "%q must be of type %q or None" +msgstr "" + #: ports/atmel-samd/common-hal/busio/UART.c msgid "%q must be power of 2" msgstr "" @@ -442,6 +446,7 @@ msgstr "" msgid "All timers in use" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Already advertising." msgstr "" @@ -574,7 +579,7 @@ msgstr "" #: shared-bindings/displayio/Display.c #: shared-bindings/framebufferio/FramebufferDisplay.c -#: shared-bindings/is31fl3741/is31fl3741.c +#: shared-bindings/is31fl3741/FrameBuffer.c #: shared-bindings/rgbmatrix/RGBMatrix.c msgid "Brightness must be 0-1.0" msgstr "" @@ -626,7 +631,7 @@ msgstr "" msgid "Buffer must be a multiple of 512 bytes" msgstr "" -#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c +#: shared-bindings/bitbangio/I2C.c msgid "Buffer must be at least length 1" msgstr "" @@ -659,6 +664,10 @@ msgstr "" msgid "CBC blocks must be multiples of 16 bytes" msgstr "" +#: supervisor/shared/safe_mode.c +msgid "CIRCUITPY drive could not be found or created." +msgstr "" + #: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c msgid "CRC or checksum was invalid" msgstr "" @@ -900,10 +909,12 @@ msgstr "" msgid "Data chunk must follow fmt chunk" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data not supported with directed advertising" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data too large for advertisement packet" msgstr "" @@ -984,6 +995,7 @@ msgstr "" msgid "Expected tuple of length %d, got %d" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Extended advertisements with scan response not supported." msgstr "" @@ -1037,6 +1049,7 @@ msgstr "" msgid "Failed to buffer the sample" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Failed to connect: internal error" msgstr "" @@ -1116,6 +1129,13 @@ msgstr "" msgid "Group already used" msgstr "" +#: ports/atmel-samd/common-hal/busio/SPI.c ports/cxd56/common-hal/busio/SPI.c +#: ports/espressif/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/nrf/common-hal/busio/SPI.c +#: ports/raspberrypi/common-hal/busio/SPI.c +msgid "Half duplex SPI is not implemented" +msgstr "" + #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/I2C.c #: ports/stm/common-hal/busio/SPI.c ports/stm/common-hal/canio/CAN.c #: ports/stm/common-hal/sdioio/SDCard.c @@ -1268,6 +1288,7 @@ msgstr "" msgid "Invalid AuthMode" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c msgid "Invalid BLE parameter" msgstr "" @@ -1362,6 +1383,10 @@ msgstr "" msgid "Invalid memory access." msgstr "" +#: extmod/vfs_fat_file.c +msgid "Invalid mode" +msgstr "" + #: ports/espressif/common-hal/wifi/Radio.c msgid "Invalid multicast MAC address" msgstr "" @@ -1462,7 +1487,7 @@ msgstr "" msgid "Key must be 16, 24, or 32 bytes long" msgstr "" -#: shared-module/is31fl3741/is31fl3741.c +#: shared-module/is31fl3741/FrameBuffer.c msgid "LED mappings must match display size" msgstr "" @@ -1490,6 +1515,10 @@ msgstr "" msgid "MOSI pin init failed." msgstr "" +#: shared-bindings/is31fl3741/IS31FL3741.c +msgid "Mapping must be a tuple" +msgstr "" + #: shared-module/displayio/Shape.c #, c-format msgid "Maximum x value when mirrored is %d" @@ -1572,6 +1601,10 @@ msgstr "" msgid "Name too long" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +msgid "Nimble out of memory" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "" @@ -1592,9 +1625,9 @@ msgstr "" msgid "No DMA pacing timer found" msgstr "" -#: shared-module/adafruit_bus_device/I2CDevice.c +#: shared-module/adafruit_bus_device/i2c_device/I2CDevice.c #, c-format -msgid "No I2C device at address: %x" +msgid "No I2C device at address: 0x%x" msgstr "" #: ports/espressif/common-hal/busio/SPI.c @@ -1719,6 +1752,7 @@ msgstr "" msgid "Not a valid IP string" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -1892,7 +1926,7 @@ msgstr "" msgid "Pin interrupt already in use" msgstr "" -#: shared-bindings/adafruit_bus_device/SPIDevice.c +#: shared-bindings/adafruit_bus_device/spi_device/SPIDevice.c #: shared-bindings/digitalio/DigitalInOut.c msgid "Pin is input only" msgstr "" @@ -1974,6 +2008,10 @@ msgstr "" msgid "RAISE mode is not implemented" msgstr "" +#: ports/raspberrypi/common-hal/countio/Counter.c +msgid "RISE_AND_FALL not available on this chip" +msgstr "" + #: ports/stm/common-hal/os/__init__.c msgid "RNG DeInit Error" msgstr "" @@ -2090,10 +2128,11 @@ msgstr "" msgid "Sample rate too high. It must be less than %d" msgstr "" -#: shared-bindings/is31fl3741/is31fl3741.c +#: shared-bindings/is31fl3741/FrameBuffer.c msgid "Scale dimensions must divide by 3" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Scan already in progess. Stop with stop_scan." msgstr "" @@ -2252,6 +2291,7 @@ msgstr "" msgid "Time is in the past." msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2274,6 +2314,7 @@ msgstr "" msgid "Too many displays" msgstr "" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Total data to write is larger than %q" msgstr "" @@ -2351,7 +2392,7 @@ msgstr "" msgid "Unable to create lock" msgstr "" -#: shared-module/displayio/I2CDisplay.c shared-module/is31fl3741/is31fl3741.c +#: shared-module/displayio/I2CDisplay.c shared-module/is31fl3741/IS31FL3741.c #, c-format msgid "Unable to find I2C Display at %x" msgstr "" @@ -2386,6 +2427,16 @@ msgstr "" msgid "Unhandled ESP TLS error %d %d %x %d" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown BLE error at %s:%d: %d" +msgstr "" + +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown BLE error: %d" +msgstr "" + #: shared-bindings/wifi/Radio.c #, c-format msgid "Unknown failure %d" @@ -2405,11 +2456,21 @@ msgstr "" msgid "Unknown security error: 0x%04x" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error at %s:%d: %d" +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown system firmware error: %04x" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error: %d" +msgstr "" + #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #, c-format msgid "Unmatched number of items on RHS (expected %d, got %d)." @@ -2443,19 +2504,19 @@ msgstr "" msgid "Unsupported operation" msgstr "" -#: shared-bindings/digitalio/DigitalInOut.c -msgid "Unsupported pull value." -msgstr "" - #: ports/espressif/common-hal/dualbank/__init__.c msgid "Update Failed" msgstr "" +#: ports/espressif/common-hal/_bleio/Characteristic.c +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length != required fixed length" msgstr "" +#: ports/espressif/common-hal/_bleio/Characteristic.c +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length > max_length" @@ -2513,6 +2574,7 @@ msgstr "" msgid "Woken up by alarm.\n" msgstr "" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Writes not supported on Characteristic" msgstr "" @@ -2616,7 +2678,7 @@ msgstr "" msgid "attributes not supported yet" msgstr "" -#: extmod/ulab/code/numpy/numerical.c +#: extmod/ulab/code/ulab_tools.c msgid "axis is out of bounds" msgstr "" @@ -2672,11 +2734,11 @@ msgstr "" msgid "branch not in range" msgstr "" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/utils/utils.c msgid "buffer is smaller than requested size" msgstr "" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/utils/utils.c msgid "buffer size must be a multiple of element size" msgstr "" @@ -2726,6 +2788,10 @@ msgstr "" msgid "calibration value out of range +/-127" msgstr "" +#: shared-module/vectorio/Rectangle.c +msgid "can only be registered in one parent" +msgstr "" + #: py/emitinlinethumb.c msgid "can only have up to 4 parameters to Thumb assembly" msgstr "" @@ -2764,6 +2830,10 @@ msgstr "" msgid "can't convert '%q' object to %q implicitly" msgstr "" +#: extmod/ulab/code/numpy/vector.c +msgid "can't convert complex to float" +msgstr "" + #: py/obj.c msgid "can't convert to %q" msgstr "" @@ -2816,6 +2886,10 @@ msgstr "" msgid "can't load with '%q' index" msgstr "" +#: py/builtinimport.c +msgid "can't perform relative import" +msgstr "" + #: py/objgenerator.c msgid "can't send non-None value to a just-started generator" msgstr "" @@ -2858,6 +2932,14 @@ msgstr "" msgid "cannot cast output with casting rule" msgstr "" +#: extmod/ulab/code/ndarray.c +msgid "cannot convert complex to dtype" +msgstr "" + +#: extmod/ulab/code/ndarray.c +msgid "cannot convert complex type" +msgstr "" + #: py/objtype.c msgid "cannot create '%q' instances" msgstr "" @@ -2870,10 +2952,6 @@ msgstr "" msgid "cannot import name %q" msgstr "" -#: py/builtinimport.c -msgid "cannot perform relative import" -msgstr "" - #: extmod/moductypes.c msgid "cannot unambiguously get sizeof scalar" msgstr "" @@ -3049,6 +3127,10 @@ msgstr "" msgid "divisor must be 4" msgstr "" +#: extmod/ulab/code/numpy/vector.c +msgid "dtype must be float, or complex" +msgstr "" + #: py/objdeque.c msgid "empty" msgstr "" @@ -3152,7 +3234,7 @@ msgstr "" msgid "first argument must be a function" msgstr "" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "first argument must be a tuple of ndarrays" msgstr "" @@ -3217,6 +3299,10 @@ msgstr "" msgid "function is defined for ndarrays only" msgstr "" +#: extmod/ulab/code/numpy/carray/carray.c +msgid "function is implemented for ndarrays only" +msgstr "" + #: py/argcheck.c #, c-format msgid "function missing %d required positional arguments" @@ -3330,7 +3416,7 @@ msgstr "" msgid "input and output shapes are not compatible" msgstr "" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "input argument must be an integer, a tuple, or a list" msgstr "" @@ -3338,7 +3424,7 @@ msgstr "" msgid "input array length must be power of 2" msgstr "" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "input arrays are not compatible" msgstr "" @@ -3346,6 +3432,10 @@ msgstr "" msgid "input data must be an iterable" msgstr "" +#: extmod/ulab/code/numpy/vector.c +msgid "input dtype must be float or complex" +msgstr "" + #: extmod/ulab/code/numpy/linalg/linalg.c msgid "input matrix is asymmetric" msgstr "" @@ -3355,18 +3445,26 @@ msgstr "" msgid "input matrix is singular" msgstr "" +#: extmod/ulab/code/numpy/carray/carray.c +msgid "input must be a 1D ndarray" +msgstr "" + #: extmod/ulab/code/scipy/linalg/linalg.c extmod/ulab/code/user/user.c msgid "input must be a dense ndarray" msgstr "" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "input must be a tensor of rank 2" msgstr "" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/user/user.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/user/user.c msgid "input must be an ndarray" msgstr "" +#: extmod/ulab/code/numpy/carray/carray.c +msgid "input must be an ndarray, or a scalar" +msgstr "" + #: extmod/ulab/code/scipy/signal/signal.c msgid "input must be one-dimensional" msgstr "" @@ -3544,6 +3642,11 @@ msgstr "" msgid "matrix is not positive definite" msgstr "" +#: ports/espressif/common-hal/wifi/Radio.c +msgid "max_connections must be between 0 and 10" +msgstr "" + +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c #, c-format @@ -3697,6 +3800,7 @@ msgstr "" msgid "non-Device in %q" msgstr "" +#: ports/espressif/common-hal/_bleio/Connection.c #: ports/nrf/common-hal/_bleio/Connection.c msgid "non-UUID found in service_uuids_whitelist" msgstr "" @@ -3737,7 +3841,11 @@ msgstr "" msgid "not enough arguments for format string" msgstr "" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/carray/carray_tools.c +msgid "not implemented for complex dtype" +msgstr "" + +#: extmod/ulab/code/numpy/create.c msgid "number of points must be at least 2" msgstr "" @@ -3795,7 +3903,7 @@ msgstr "" msgid "odd-length string" msgstr "" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/utils/utils.c msgid "offset is too large" msgstr "" @@ -3803,7 +3911,7 @@ msgstr "" msgid "offset must be >= 0" msgstr "" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "offset must be non-negative and no greater than buffer length" msgstr "" @@ -3915,6 +4023,10 @@ msgstr "" msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "" +#: extmod/vfs_posix_file.c +msgid "poll on file not available on win32" +msgstr "" + #: shared-module/vectorio/Polygon.c msgid "polygon can only be registered in one parent" msgstr "" @@ -3944,18 +4056,27 @@ msgstr "" msgid "pow() with 3 arguments requires integers" msgstr "" +#: ports/espressif/boards/adafruit_esp32s2_camera/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tft/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h #: ports/espressif/boards/adafruit_funhouse/mpconfigboard.h #: ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h +#: ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h +#: ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h #: ports/espressif/boards/atmegazero_esp32s2/mpconfigboard.h #: ports/espressif/boards/crumpspace_crumps2/mpconfigboard.h #: ports/espressif/boards/electroniccats_bastwifi/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s2_devkitc_1_n4r2/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_box/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h #: ports/espressif/boards/espressif_hmi_devkit_1/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1.3/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1/mpconfigboard.h @@ -3981,7 +4102,10 @@ msgstr "" #: ports/espressif/boards/unexpectedmaker_feathers2/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_neo/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_prerelease/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_feathers3/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_pros3/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_tinys2/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_tinys3/mpconfigboard.h msgid "pressing boot button at start up.\n" msgstr "" @@ -4278,7 +4402,7 @@ msgstr "" msgid "too many arguments provided with the given format" msgstr "" -#: extmod/ulab/code/ndarray.c extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/ndarray.c extmod/ulab/code/numpy/create.c msgid "too many dimensions" msgstr "" @@ -4462,7 +4586,7 @@ msgstr "" msgid "width must be from 2 to 8 (inclusive), not %d" msgstr "" -#: shared-bindings/is31fl3741/is31fl3741.c +#: shared-bindings/is31fl3741/FrameBuffer.c #: shared-bindings/rgbmatrix/RGBMatrix.c msgid "width must be greater than zero" msgstr "" @@ -4479,7 +4603,7 @@ msgstr "" msgid "wrong axis index" msgstr "" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "wrong axis specified" msgstr "" @@ -4487,7 +4611,11 @@ msgstr "" msgid "wrong input type" msgstr "" -#: extmod/ulab/code/ulab_create.c py/objarray.c py/objstr.c +#: extmod/ulab/code/numpy/transform.c +msgid "wrong length of condition array" +msgstr "" + +#: extmod/ulab/code/numpy/create.c py/objarray.c py/objstr.c msgid "wrong number of arguments" msgstr "" diff --git a/locale/en_GB.po b/locale/en_GB.po index 9301346a34..ba24b0fa86 100644 --- a/locale/en_GB.po +++ b/locale/en_GB.po @@ -108,7 +108,7 @@ msgstr "%q indices must be integers, not %s" msgid "%q length must be %d-%d" msgstr "%q length must be %d-%d" -#: shared-bindings/usb_hid/Device.c +#: shared-bindings/busio/I2C.c shared-bindings/usb_hid/Device.c msgid "%q length must be >= 1" msgstr "%q length must be >= 1" @@ -153,6 +153,10 @@ msgstr "%q must be between %d and %d" msgid "%q must be of type %q" msgstr "" +#: shared-bindings/digitalio/Pull.c +msgid "%q must be of type %q or None" +msgstr "" + #: ports/atmel-samd/common-hal/busio/UART.c msgid "%q must be power of 2" msgstr "%q must be power of 2" @@ -451,6 +455,7 @@ msgstr "All timers for this pin are in use" msgid "All timers in use" msgstr "All timers in use" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Already advertising." msgstr "Already advertising." @@ -585,7 +590,7 @@ msgstr "Both pins must support hardware interrupts" #: shared-bindings/displayio/Display.c #: shared-bindings/framebufferio/FramebufferDisplay.c -#: shared-bindings/is31fl3741/is31fl3741.c +#: shared-bindings/is31fl3741/FrameBuffer.c #: shared-bindings/rgbmatrix/RGBMatrix.c msgid "Brightness must be 0-1.0" msgstr "Brightness must be 0-1.0" @@ -637,7 +642,7 @@ msgstr "Buffer length must be a multiple of 512" msgid "Buffer must be a multiple of 512 bytes" msgstr "Buffer must be a multiple of 512 bytes" -#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c +#: shared-bindings/bitbangio/I2C.c msgid "Buffer must be at least length 1" msgstr "Buffer must be at least length 1" @@ -670,6 +675,10 @@ msgstr "Bytes must be between 0 and 255." msgid "CBC blocks must be multiples of 16 bytes" msgstr "CBC blocks must be multiples of 16 bytes" +#: supervisor/shared/safe_mode.c +msgid "CIRCUITPY drive could not be found or created." +msgstr "" + #: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c msgid "CRC or checksum was invalid" msgstr "CRC or checksum was invalid" @@ -913,10 +922,12 @@ msgstr "Data 0 pin must be byte aligned" msgid "Data chunk must follow fmt chunk" msgstr "Data chunk must follow fmt chunk" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data not supported with directed advertising" msgstr "Data not supported with directed advertising" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data too large for advertisement packet" msgstr "Data too large for advertisement packet" @@ -997,6 +1008,7 @@ msgstr "Expected an alarm" msgid "Expected tuple of length %d, got %d" msgstr "Expected tuple of length %d, got %d" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Extended advertisements with scan response not supported." msgstr "Extended advertisements with scan response not supported." @@ -1050,6 +1062,7 @@ msgstr "Failed to allocate WiFi scan memory" msgid "Failed to buffer the sample" msgstr "Failed to buffer the sample" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Failed to connect: internal error" msgstr "Failed to connect: internal error" @@ -1129,6 +1142,13 @@ msgstr "Generic Failure" msgid "Group already used" msgstr "Group already used" +#: ports/atmel-samd/common-hal/busio/SPI.c ports/cxd56/common-hal/busio/SPI.c +#: ports/espressif/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/nrf/common-hal/busio/SPI.c +#: ports/raspberrypi/common-hal/busio/SPI.c +msgid "Half duplex SPI is not implemented" +msgstr "" + #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/I2C.c #: ports/stm/common-hal/busio/SPI.c ports/stm/common-hal/canio/CAN.c #: ports/stm/common-hal/sdioio/SDCard.c @@ -1283,6 +1303,7 @@ msgstr "Invalid ADC unit value" msgid "Invalid AuthMode" msgstr "Invalid AuthMode" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c msgid "Invalid BLE parameter" msgstr "Invalid BLE parameter" @@ -1377,6 +1398,10 @@ msgstr "Invalid format chunk size" msgid "Invalid memory access." msgstr "Invalid memory access." +#: extmod/vfs_fat_file.c +msgid "Invalid mode" +msgstr "" + #: ports/espressif/common-hal/wifi/Radio.c msgid "Invalid multicast MAC address" msgstr "" @@ -1477,7 +1502,7 @@ msgstr "Invalid word/bit length" msgid "Key must be 16, 24, or 32 bytes long" msgstr "Key must be 16, 24, or 32 bytes long" -#: shared-module/is31fl3741/is31fl3741.c +#: shared-module/is31fl3741/FrameBuffer.c msgid "LED mappings must match display size" msgstr "" @@ -1505,6 +1530,10 @@ msgstr "MISO pin init failed." msgid "MOSI pin init failed." msgstr "MOSI pin init failed." +#: shared-bindings/is31fl3741/IS31FL3741.c +msgid "Mapping must be a tuple" +msgstr "" + #: shared-module/displayio/Shape.c #, c-format msgid "Maximum x value when mirrored is %d" @@ -1587,6 +1616,10 @@ msgstr "NVS Error" msgid "Name too long" msgstr "Name too long" +#: ports/espressif/common-hal/_bleio/__init__.c +msgid "Nimble out of memory" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "No CCCD for this Characteristic" @@ -1607,10 +1640,10 @@ msgstr "No DMA channel found" msgid "No DMA pacing timer found" msgstr "No DMA pacing timer found" -#: shared-module/adafruit_bus_device/I2CDevice.c +#: shared-module/adafruit_bus_device/i2c_device/I2CDevice.c #, c-format -msgid "No I2C device at address: %x" -msgstr "No I2C device at address: %x" +msgid "No I2C device at address: 0x%x" +msgstr "" #: ports/espressif/common-hal/busio/SPI.c #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c @@ -1734,6 +1767,7 @@ msgstr "Nordic system firmware out of memory" msgid "Not a valid IP string" msgstr "Not a valid IP string" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -1913,7 +1947,7 @@ msgstr "Pin does not have ADC capabilities" msgid "Pin interrupt already in use" msgstr "Pin interrupt already in use" -#: shared-bindings/adafruit_bus_device/SPIDevice.c +#: shared-bindings/adafruit_bus_device/spi_device/SPIDevice.c #: shared-bindings/digitalio/DigitalInOut.c msgid "Pin is input only" msgstr "Pin is input only" @@ -1998,6 +2032,10 @@ msgstr "Pull not used when direction is output." msgid "RAISE mode is not implemented" msgstr "RAISE mode is not implemented" +#: ports/raspberrypi/common-hal/countio/Counter.c +msgid "RISE_AND_FALL not available on this chip" +msgstr "" + #: ports/stm/common-hal/os/__init__.c msgid "RNG DeInit Error" msgstr "RNG deinit Error" @@ -2114,10 +2152,11 @@ msgstr "Sample rate must be positive" msgid "Sample rate too high. It must be less than %d" msgstr "Sample rate too high. It must be less than %d" -#: shared-bindings/is31fl3741/is31fl3741.c +#: shared-bindings/is31fl3741/FrameBuffer.c msgid "Scale dimensions must divide by 3" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Scan already in progess. Stop with stop_scan." msgstr "Scan already in progess. Stop with stop_scan." @@ -2283,6 +2322,7 @@ msgstr "Tile width must exactly divide bitmap width" msgid "Time is in the past." msgstr "Time is in the past." +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2305,6 +2345,7 @@ msgstr "Too many display busses" msgid "Too many displays" msgstr "Too many displays" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Total data to write is larger than %q" msgstr "Total data to write is larger than %q" @@ -2382,7 +2423,7 @@ msgstr "Unable to allocate buffers for signed conversion" msgid "Unable to create lock" msgstr "Unable to create lock" -#: shared-module/displayio/I2CDisplay.c shared-module/is31fl3741/is31fl3741.c +#: shared-module/displayio/I2CDisplay.c shared-module/is31fl3741/IS31FL3741.c #, c-format msgid "Unable to find I2C Display at %x" msgstr "Unable to find I2C display at %x" @@ -2417,6 +2458,16 @@ msgstr "Unexpected nrfx uuid type" msgid "Unhandled ESP TLS error %d %d %x %d" msgstr "Unhandled ESP TLS error %d %d %x %d" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown BLE error at %s:%d: %d" +msgstr "" + +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown BLE error: %d" +msgstr "" + #: shared-bindings/wifi/Radio.c #, c-format msgid "Unknown failure %d" @@ -2436,11 +2487,21 @@ msgstr "Unknown reason." msgid "Unknown security error: 0x%04x" msgstr "Unknown security error: 0x%04x" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error at %s:%d: %d" +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown system firmware error: %04x" msgstr "Unknown system firmware error: %04x" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error: %d" +msgstr "" + #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #, c-format msgid "Unmatched number of items on RHS (expected %d, got %d)." @@ -2476,19 +2537,19 @@ msgstr "Unsupported format" msgid "Unsupported operation" msgstr "Unsupported operation" -#: shared-bindings/digitalio/DigitalInOut.c -msgid "Unsupported pull value." -msgstr "Unsupported pull value." - #: ports/espressif/common-hal/dualbank/__init__.c msgid "Update Failed" msgstr "Update failed" +#: ports/espressif/common-hal/_bleio/Characteristic.c +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length != required fixed length" msgstr "Value length != required fixed length" +#: ports/espressif/common-hal/_bleio/Characteristic.c +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length > max_length" @@ -2546,6 +2607,7 @@ msgstr "WiFi password must be between 8 and 63 characters" msgid "Woken up by alarm.\n" msgstr "Woken up by alarm.\n" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Writes not supported on Characteristic" msgstr "Writes not supported on Characteristic" @@ -2650,7 +2712,7 @@ msgstr "attempt to get argmin/argmax of an empty sequence" msgid "attributes not supported yet" msgstr "attributes not supported yet" -#: extmod/ulab/code/numpy/numerical.c +#: extmod/ulab/code/ulab_tools.c msgid "axis is out of bounds" msgstr "axis is out of bounds" @@ -2706,11 +2768,11 @@ msgstr "bits_per_sample must be 8 or 16" msgid "branch not in range" msgstr "Branch not in range" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/utils/utils.c msgid "buffer is smaller than requested size" msgstr "Buffer is smaller than requested size" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/utils/utils.c msgid "buffer size must be a multiple of element size" msgstr "Buffer size must be a multiple of element size" @@ -2760,6 +2822,10 @@ msgstr "Calibration is read only" msgid "calibration value out of range +/-127" msgstr "Calibration value out of range +/-127" +#: shared-module/vectorio/Rectangle.c +msgid "can only be registered in one parent" +msgstr "" + #: py/emitinlinethumb.c msgid "can only have up to 4 parameters to Thumb assembly" msgstr "Can only have up to 4 parameters to thumb assembly" @@ -2798,6 +2864,10 @@ msgstr "can't convert %s to complex" msgid "can't convert '%q' object to %q implicitly" msgstr "Can't convert '%q' object to %q implicitly" +#: extmod/ulab/code/numpy/vector.c +msgid "can't convert complex to float" +msgstr "" + #: py/obj.c msgid "can't convert to %q" msgstr "Can't convert to %q" @@ -2850,6 +2920,10 @@ msgstr "can't load from '%q'" msgid "can't load with '%q' index" msgstr "can't load with '%q' index" +#: py/builtinimport.c +msgid "can't perform relative import" +msgstr "" + #: py/objgenerator.c msgid "can't send non-None value to a just-started generator" msgstr "can't send non-None value to a just-started generator" @@ -2894,6 +2968,14 @@ msgstr "cannot assign new shape" msgid "cannot cast output with casting rule" msgstr "can't cast output with casting rule" +#: extmod/ulab/code/ndarray.c +msgid "cannot convert complex to dtype" +msgstr "" + +#: extmod/ulab/code/ndarray.c +msgid "cannot convert complex type" +msgstr "" + #: py/objtype.c msgid "cannot create '%q' instances" msgstr "can't create '%q' instances" @@ -2906,10 +2988,6 @@ msgstr "can't create instance" msgid "cannot import name %q" msgstr "can't import name %q" -#: py/builtinimport.c -msgid "cannot perform relative import" -msgstr "can't perform relative import" - #: extmod/moductypes.c msgid "cannot unambiguously get sizeof scalar" msgstr "cannot unambiguously get sizeof scalar" @@ -3086,6 +3164,10 @@ msgstr "division by zero" msgid "divisor must be 4" msgstr "" +#: extmod/ulab/code/numpy/vector.c +msgid "dtype must be float, or complex" +msgstr "" + #: py/objdeque.c msgid "empty" msgstr "empty" @@ -3189,7 +3271,7 @@ msgstr "first argument must be a callable" msgid "first argument must be a function" msgstr "first argument must be a function" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "first argument must be a tuple of ndarrays" msgstr "first argument must be a tuple of ndarrays" @@ -3254,6 +3336,10 @@ msgstr "function has the same sign at the ends of interval" msgid "function is defined for ndarrays only" msgstr "function is defined for ndarrays only" +#: extmod/ulab/code/numpy/carray/carray.c +msgid "function is implemented for ndarrays only" +msgstr "" + #: py/argcheck.c #, c-format msgid "function missing %d required positional arguments" @@ -3367,7 +3453,7 @@ msgstr "inline assembler must be a function" msgid "input and output shapes are not compatible" msgstr "input and output shapes are not compatible" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "input argument must be an integer, a tuple, or a list" msgstr "input argument must be an integer, a tuple, or a list" @@ -3375,7 +3461,7 @@ msgstr "input argument must be an integer, a tuple, or a list" msgid "input array length must be power of 2" msgstr "input array length must be power of 2" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "input arrays are not compatible" msgstr "input arrays are not compatible" @@ -3383,6 +3469,10 @@ msgstr "input arrays are not compatible" msgid "input data must be an iterable" msgstr "input data must be an iterable" +#: extmod/ulab/code/numpy/vector.c +msgid "input dtype must be float or complex" +msgstr "" + #: extmod/ulab/code/numpy/linalg/linalg.c msgid "input matrix is asymmetric" msgstr "input matrix is asymmetric" @@ -3392,18 +3482,26 @@ msgstr "input matrix is asymmetric" msgid "input matrix is singular" msgstr "input matrix is singular" +#: extmod/ulab/code/numpy/carray/carray.c +msgid "input must be a 1D ndarray" +msgstr "" + #: extmod/ulab/code/scipy/linalg/linalg.c extmod/ulab/code/user/user.c msgid "input must be a dense ndarray" msgstr "input must be a dense ndarray" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "input must be a tensor of rank 2" msgstr "input must be a tensor of rank 2" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/user/user.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/user/user.c msgid "input must be an ndarray" msgstr "input must be an ndarray" +#: extmod/ulab/code/numpy/carray/carray.c +msgid "input must be an ndarray, or a scalar" +msgstr "" + #: extmod/ulab/code/scipy/signal/signal.c msgid "input must be one-dimensional" msgstr "input must be one-dimensional" @@ -3581,6 +3679,11 @@ msgstr "math domain error" msgid "matrix is not positive definite" msgstr "matrix is not positive definite" +#: ports/espressif/common-hal/wifi/Radio.c +msgid "max_connections must be between 0 and 10" +msgstr "" + +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c #, c-format @@ -3734,6 +3837,7 @@ msgstr "no such attribute" msgid "non-Device in %q" msgstr "non-Device in %q" +#: ports/espressif/common-hal/_bleio/Connection.c #: ports/nrf/common-hal/_bleio/Connection.c msgid "non-UUID found in service_uuids_whitelist" msgstr "non-UUID found in service_uuids_whitelist" @@ -3774,7 +3878,11 @@ msgstr "not all arguments converted during string formatting" msgid "not enough arguments for format string" msgstr "not enough arguments for format string" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/carray/carray_tools.c +msgid "not implemented for complex dtype" +msgstr "" + +#: extmod/ulab/code/numpy/create.c msgid "number of points must be at least 2" msgstr "number of points must be at least 2" @@ -3832,7 +3940,7 @@ msgstr "object with buffer protocol required" msgid "odd-length string" msgstr "odd-length string" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/utils/utils.c msgid "offset is too large" msgstr "offset is too large" @@ -3840,7 +3948,7 @@ msgstr "offset is too large" msgid "offset must be >= 0" msgstr "offset must be >= 0" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "offset must be non-negative and no greater than buffer length" msgstr "offset must be non-negative and not greater than buffer length" @@ -3952,6 +4060,10 @@ msgstr "pixel value requires too many bits" msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "pixel_shader must be displayio.Palette or displayio.ColorConverter" +#: extmod/vfs_posix_file.c +msgid "poll on file not available on win32" +msgstr "" + #: shared-module/vectorio/Polygon.c msgid "polygon can only be registered in one parent" msgstr "polygon can only be registered in one parent" @@ -3981,18 +4093,27 @@ msgstr "pow() 3rd argument cannot be 0" msgid "pow() with 3 arguments requires integers" msgstr "pow() with 3 arguments requires integers" +#: ports/espressif/boards/adafruit_esp32s2_camera/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tft/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h #: ports/espressif/boards/adafruit_funhouse/mpconfigboard.h #: ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h +#: ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h +#: ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h #: ports/espressif/boards/atmegazero_esp32s2/mpconfigboard.h #: ports/espressif/boards/crumpspace_crumps2/mpconfigboard.h #: ports/espressif/boards/electroniccats_bastwifi/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s2_devkitc_1_n4r2/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_box/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h #: ports/espressif/boards/espressif_hmi_devkit_1/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1.3/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1/mpconfigboard.h @@ -4018,7 +4139,10 @@ msgstr "pow() with 3 arguments requires integers" #: ports/espressif/boards/unexpectedmaker_feathers2/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_neo/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_prerelease/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_feathers3/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_pros3/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_tinys2/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_tinys3/mpconfigboard.h msgid "pressing boot button at start up.\n" msgstr "pressing boot button at start up.\n" @@ -4317,7 +4441,7 @@ msgstr "tobytes can be invoked for dense arrays only" msgid "too many arguments provided with the given format" msgstr "too many arguments provided with the given format" -#: extmod/ulab/code/ndarray.c extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/ndarray.c extmod/ulab/code/numpy/create.c msgid "too many dimensions" msgstr "too many dimensions" @@ -4501,7 +4625,7 @@ msgstr "WatchDog timeout must be greater than 0" msgid "width must be from 2 to 8 (inclusive), not %d" msgstr "width must be from 2 to 8 (inclusive), not %d" -#: shared-bindings/is31fl3741/is31fl3741.c +#: shared-bindings/is31fl3741/FrameBuffer.c #: shared-bindings/rgbmatrix/RGBMatrix.c msgid "width must be greater than zero" msgstr "width must be greater than zero" @@ -4518,7 +4642,7 @@ msgstr "window must be <= interval" msgid "wrong axis index" msgstr "wrong axis index" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "wrong axis specified" msgstr "wrong axis specified" @@ -4526,7 +4650,11 @@ msgstr "wrong axis specified" msgid "wrong input type" msgstr "wrong input type" -#: extmod/ulab/code/ulab_create.c py/objarray.c py/objstr.c +#: extmod/ulab/code/numpy/transform.c +msgid "wrong length of condition array" +msgstr "" + +#: extmod/ulab/code/numpy/create.c py/objarray.c py/objstr.c msgid "wrong number of arguments" msgstr "wrong number of arguments" @@ -4570,6 +4698,16 @@ msgstr "zi must be of float type" msgid "zi must be of shape (n_section, 2)" msgstr "zi must be of shape (n_section, 2)" +#~ msgid "cannot perform relative import" +#~ msgstr "can't perform relative import" + +#, c-format +#~ msgid "No I2C device at address: %x" +#~ msgstr "No I2C device at address: %x" + +#~ msgid "Unsupported pull value." +#~ msgstr "Unsupported pull value." + #~ msgid "%q must <= %d" #~ msgstr "%q must <= %d" diff --git a/locale/es.po b/locale/es.po index 330eda2c2a..e13bac9cc5 100644 --- a/locale/es.po +++ b/locale/es.po @@ -110,7 +110,7 @@ msgstr "%q indices deben ser enteros, no %s" msgid "%q length must be %d-%d" msgstr "" -#: shared-bindings/usb_hid/Device.c +#: shared-bindings/busio/I2C.c shared-bindings/usb_hid/Device.c msgid "%q length must be >= 1" msgstr "" @@ -155,6 +155,10 @@ msgstr "%q debe estar entre %d y %d" msgid "%q must be of type %q" msgstr "" +#: shared-bindings/digitalio/Pull.c +msgid "%q must be of type %q or None" +msgstr "" + #: ports/atmel-samd/common-hal/busio/UART.c msgid "%q must be power of 2" msgstr "" @@ -455,6 +459,7 @@ msgstr "Todos los timers para este pin están siendo utilizados" msgid "All timers in use" msgstr "Todos los timers en uso" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Already advertising." msgstr "Ya se encuentra publicando." @@ -589,7 +594,7 @@ msgstr "Ambos pines deben soportar interrupciones por hardware" #: shared-bindings/displayio/Display.c #: shared-bindings/framebufferio/FramebufferDisplay.c -#: shared-bindings/is31fl3741/is31fl3741.c +#: shared-bindings/is31fl3741/FrameBuffer.c #: shared-bindings/rgbmatrix/RGBMatrix.c msgid "Brightness must be 0-1.0" msgstr "El brillo debe ser 0-1.0" @@ -642,7 +647,7 @@ msgstr "El tamaño del búfer debe ser múltiplo de 512" msgid "Buffer must be a multiple of 512 bytes" msgstr "Búfer deber ser un múltiplo de 512 bytes" -#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c +#: shared-bindings/bitbangio/I2C.c msgid "Buffer must be at least length 1" msgstr "Buffer debe ser de longitud 1 como minimo" @@ -675,6 +680,10 @@ msgstr "Bytes debe estar entre 0 y 255." msgid "CBC blocks must be multiples of 16 bytes" msgstr "Los bloques CBC deben ser múltiplos de 16 bytes" +#: supervisor/shared/safe_mode.c +msgid "CIRCUITPY drive could not be found or created." +msgstr "" + #: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c msgid "CRC or checksum was invalid" msgstr "CRC o suma de comprobación inválida" @@ -922,10 +931,12 @@ msgstr "El pin Data 0 debe estar alineado a bytes" msgid "Data chunk must follow fmt chunk" msgstr "Trozo de datos debe seguir fmt chunk" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data not supported with directed advertising" msgstr "Datos sin capacidad de anuncio dirigido" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data too large for advertisement packet" msgstr "Data es muy grande para el paquete de anuncio" @@ -1007,6 +1018,7 @@ msgstr "Un objecto alarm era esperado" msgid "Expected tuple of length %d, got %d" msgstr "Se esperaba un tuple de %d, se obtuvo %d" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Extended advertisements with scan response not supported." msgstr "No se admiten anuncios extendidos con respuesta de escaneo." @@ -1060,6 +1072,7 @@ msgstr "Fallo al tomar memoria para búsqueda wifi" msgid "Failed to buffer the sample" msgstr "Fallo al hacer el búfer de la muestra" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Failed to connect: internal error" msgstr "Error al conectar: error interno" @@ -1140,6 +1153,13 @@ msgstr "Fallo Genérico" msgid "Group already used" msgstr "Grupo ya está siendo utilizado" +#: ports/atmel-samd/common-hal/busio/SPI.c ports/cxd56/common-hal/busio/SPI.c +#: ports/espressif/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/nrf/common-hal/busio/SPI.c +#: ports/raspberrypi/common-hal/busio/SPI.c +msgid "Half duplex SPI is not implemented" +msgstr "" + #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/I2C.c #: ports/stm/common-hal/busio/SPI.c ports/stm/common-hal/canio/CAN.c #: ports/stm/common-hal/sdioio/SDCard.c @@ -1301,6 +1321,7 @@ msgstr "Valor de unidad de ADC no válido" msgid "Invalid AuthMode" msgstr "AuthMode invalido" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c msgid "Invalid BLE parameter" msgstr "Parámetro BLE invalido" @@ -1395,6 +1416,10 @@ msgstr "Formato de fragmento de formato no válido" msgid "Invalid memory access." msgstr "Acceso a memoria no válido." +#: extmod/vfs_fat_file.c +msgid "Invalid mode" +msgstr "" + #: ports/espressif/common-hal/wifi/Radio.c msgid "Invalid multicast MAC address" msgstr "" @@ -1495,7 +1520,7 @@ msgstr "Tamaño no válido de palabra/bit" msgid "Key must be 16, 24, or 32 bytes long" msgstr "La llave debe tener 16, 24 o 32 bytes de longitud" -#: shared-module/is31fl3741/is31fl3741.c +#: shared-module/is31fl3741/FrameBuffer.c msgid "LED mappings must match display size" msgstr "" @@ -1523,6 +1548,10 @@ msgstr "MISO pin init fallido." msgid "MOSI pin init failed." msgstr "MOSI pin init fallido." +#: shared-bindings/is31fl3741/IS31FL3741.c +msgid "Mapping must be a tuple" +msgstr "" + #: shared-module/displayio/Shape.c #, c-format msgid "Maximum x value when mirrored is %d" @@ -1609,6 +1638,10 @@ msgstr "Error NVS" msgid "Name too long" msgstr "Nombre muy largo" +#: ports/espressif/common-hal/_bleio/__init__.c +msgid "Nimble out of memory" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "No hay CCCD para esta característica" @@ -1629,10 +1662,10 @@ msgstr "No se encontró el canal DMA" msgid "No DMA pacing timer found" msgstr "timer por establecedor de paso DMA no encontrado" -#: shared-module/adafruit_bus_device/I2CDevice.c +#: shared-module/adafruit_bus_device/i2c_device/I2CDevice.c #, c-format -msgid "No I2C device at address: %x" -msgstr "No hay dispositivo I2C en la dirección: %x" +msgid "No I2C device at address: 0x%x" +msgstr "" #: ports/espressif/common-hal/busio/SPI.c #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c @@ -1756,6 +1789,7 @@ msgstr "El firmware del sistema Nordic no tiene memoria" msgid "Not a valid IP string" msgstr "No es una cadena de IP válida" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -1937,7 +1971,7 @@ msgstr "Pin no tiene capacidad ADC" msgid "Pin interrupt already in use" msgstr "Interrupción de Pin ya está en uso" -#: shared-bindings/adafruit_bus_device/SPIDevice.c +#: shared-bindings/adafruit_bus_device/spi_device/SPIDevice.c #: shared-bindings/digitalio/DigitalInOut.c msgid "Pin is input only" msgstr "El pin es solo de entrada" @@ -2025,6 +2059,10 @@ msgstr "Pull no se usa cuando la dirección es output." msgid "RAISE mode is not implemented" msgstr "El modo RAISE no esta implementado" +#: ports/raspberrypi/common-hal/countio/Counter.c +msgid "RISE_AND_FALL not available on this chip" +msgstr "" + #: ports/stm/common-hal/os/__init__.c msgid "RNG DeInit Error" msgstr "Error de desinicialización de RNG" @@ -2142,10 +2180,11 @@ msgstr "Sample rate debe ser positivo" msgid "Sample rate too high. It must be less than %d" msgstr "Frecuencia de muestreo demasiado alta. Debe ser menor a %d" -#: shared-bindings/is31fl3741/is31fl3741.c +#: shared-bindings/is31fl3741/FrameBuffer.c msgid "Scale dimensions must divide by 3" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Scan already in progess. Stop with stop_scan." msgstr "Escaneo en progreso. Usa stop_scan para detener." @@ -2312,6 +2351,7 @@ msgstr "Ancho del Tile debe dividir exactamente el ancho de mapa de bits" msgid "Time is in the past." msgstr "Tiempo suministrado esta en el pasado." +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2336,6 +2376,7 @@ msgstr "Demasiados buses de pantalla" msgid "Too many displays" msgstr "Muchos displays" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Total data to write is larger than %q" msgstr "La cantidad total de datos es mas grande que %q" @@ -2413,7 +2454,7 @@ msgstr "No se pudieron asignar buffers para la conversión con signo" msgid "Unable to create lock" msgstr "No se puede crear bloqueo" -#: shared-module/displayio/I2CDisplay.c shared-module/is31fl3741/is31fl3741.c +#: shared-module/displayio/I2CDisplay.c shared-module/is31fl3741/IS31FL3741.c #, c-format msgid "Unable to find I2C Display at %x" msgstr "No se puede encontrar la pantalla I2C en %x" @@ -2448,6 +2489,16 @@ msgstr "Tipo de uuid nrfx inesperado" msgid "Unhandled ESP TLS error %d %d %x %d" msgstr "Error no manejado de ESP TLS %d %d %x %d" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown BLE error at %s:%d: %d" +msgstr "" + +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown BLE error: %d" +msgstr "" + #: shared-bindings/wifi/Radio.c #, c-format msgid "Unknown failure %d" @@ -2467,11 +2518,21 @@ msgstr "Razón desconocida." msgid "Unknown security error: 0x%04x" msgstr "Error de seguridad desconocido: 0x%04x" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error at %s:%d: %d" +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown system firmware error: %04x" msgstr "Error desconocido en el firmware sistema: %04x" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error: %d" +msgstr "" + #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #, c-format msgid "Unmatched number of items on RHS (expected %d, got %d)." @@ -2507,19 +2568,19 @@ msgstr "Formato no soportado" msgid "Unsupported operation" msgstr "Operación no soportada" -#: shared-bindings/digitalio/DigitalInOut.c -msgid "Unsupported pull value." -msgstr "valor pull no soportado." - #: ports/espressif/common-hal/dualbank/__init__.c msgid "Update Failed" msgstr "La actualización fallo" +#: ports/espressif/common-hal/_bleio/Characteristic.c +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length != required fixed length" msgstr "Tamaño del valor != del tamaño fijo requerido" +#: ports/espressif/common-hal/_bleio/Characteristic.c +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length > max_length" @@ -2580,6 +2641,7 @@ msgstr "La clave de WiFi debe ser entre 8 y 63 caracteres" msgid "Woken up by alarm.\n" msgstr "Despertado por la alarma.\n" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Writes not supported on Characteristic" msgstr "Escrituras no admitidas en Characteristic" @@ -2685,7 +2747,7 @@ msgstr "intento de obtener argmin/argmax de una secuencia vacía" msgid "attributes not supported yet" msgstr "atributos aún no soportados" -#: extmod/ulab/code/numpy/numerical.c +#: extmod/ulab/code/ulab_tools.c msgid "axis is out of bounds" msgstr "Eje está fuera de sus límites" @@ -2741,11 +2803,11 @@ msgstr "bits_per_sample debe ser 8 ó 16" msgid "branch not in range" msgstr "la rama no está dentro del rango" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/utils/utils.c msgid "buffer is smaller than requested size" msgstr "El buffer es mas pequeño que el requerido" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/utils/utils.c msgid "buffer size must be a multiple of element size" msgstr "El tamaño del buffer debe ser un múltiplo del tamaño del elemento" @@ -2795,6 +2857,10 @@ msgstr "calibration es de solo lectura" msgid "calibration value out of range +/-127" msgstr "Valor de calibración fuera del rango +/-127" +#: shared-module/vectorio/Rectangle.c +msgid "can only be registered in one parent" +msgstr "" + #: py/emitinlinethumb.c msgid "can only have up to 4 parameters to Thumb assembly" msgstr "solo puede tener hasta 4 parámetros para ensamblar Thumb" @@ -2833,6 +2899,10 @@ msgstr "no se puede convertir %s a complejo" msgid "can't convert '%q' object to %q implicitly" msgstr "no se puede convertir el objeto '%q' a %q implícitamente" +#: extmod/ulab/code/numpy/vector.c +msgid "can't convert complex to float" +msgstr "" + #: py/obj.c msgid "can't convert to %q" msgstr "no puede convertir a %q" @@ -2885,6 +2955,10 @@ msgstr "no se puede cargar desde '%q'" msgid "can't load with '%q' index" msgstr "no se puede cargar con el índice '%q'" +#: py/builtinimport.c +msgid "can't perform relative import" +msgstr "" + #: py/objgenerator.c msgid "can't send non-None value to a just-started generator" msgstr "" @@ -2932,6 +3006,14 @@ msgstr "" msgid "cannot cast output with casting rule" msgstr "No se puede realizar cast de la salida sin una regla de cast" +#: extmod/ulab/code/ndarray.c +msgid "cannot convert complex to dtype" +msgstr "" + +#: extmod/ulab/code/ndarray.c +msgid "cannot convert complex type" +msgstr "" + #: py/objtype.c msgid "cannot create '%q' instances" msgstr "no se pueden crear '%q' instancias" @@ -2944,10 +3026,6 @@ msgstr "no se puede crear instancia" msgid "cannot import name %q" msgstr "no se puede importar name '%q'" -#: py/builtinimport.c -msgid "cannot perform relative import" -msgstr "no se puedo realizar importación relativa" - #: extmod/moductypes.c msgid "cannot unambiguously get sizeof scalar" msgstr "no se puede sin ambiguedades traer el sizeof del escalar" @@ -3125,6 +3203,10 @@ msgstr "división por cero" msgid "divisor must be 4" msgstr "" +#: extmod/ulab/code/numpy/vector.c +msgid "dtype must be float, or complex" +msgstr "" + #: py/objdeque.c msgid "empty" msgstr "vacío" @@ -3228,7 +3310,7 @@ msgstr "se debe poder llamar al primer argumento" msgid "first argument must be a function" msgstr "el primer argumento debe ser una función" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "first argument must be a tuple of ndarrays" msgstr "Primer argumento tiene que ser una tupla de ndarrays" @@ -3293,6 +3375,10 @@ msgstr "la función tiene el mismo signo a extremos del intervalo" msgid "function is defined for ndarrays only" msgstr "Función solo definida para ndarrays" +#: extmod/ulab/code/numpy/carray/carray.c +msgid "function is implemented for ndarrays only" +msgstr "" + #: py/argcheck.c #, c-format msgid "function missing %d required positional arguments" @@ -3406,7 +3492,7 @@ msgstr "ensamblador en línea debe ser una función" msgid "input and output shapes are not compatible" msgstr "Formas de entrada y salida no son compatibles" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "input argument must be an integer, a tuple, or a list" msgstr "argumento de entrada debe ser un entero, una tupla o una lista" @@ -3414,7 +3500,7 @@ msgstr "argumento de entrada debe ser un entero, una tupla o una lista" msgid "input array length must be power of 2" msgstr "el tamaño del arreglo de entrada debe ser potencia de 2" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "input arrays are not compatible" msgstr "Arrays de entrada no son compactibles" @@ -3422,6 +3508,10 @@ msgstr "Arrays de entrada no son compactibles" msgid "input data must be an iterable" msgstr "los datos de entrada deben ser iterables" +#: extmod/ulab/code/numpy/vector.c +msgid "input dtype must be float or complex" +msgstr "" + #: extmod/ulab/code/numpy/linalg/linalg.c msgid "input matrix is asymmetric" msgstr "la matriz de entrada es asimétrica" @@ -3431,18 +3521,26 @@ msgstr "la matriz de entrada es asimétrica" msgid "input matrix is singular" msgstr "la matriz de entrada es singular" +#: extmod/ulab/code/numpy/carray/carray.c +msgid "input must be a 1D ndarray" +msgstr "" + #: extmod/ulab/code/scipy/linalg/linalg.c extmod/ulab/code/user/user.c msgid "input must be a dense ndarray" msgstr "Entrada tiene que ser un ndarray denso" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "input must be a tensor of rank 2" msgstr "Entrada tiene que ser un tensor de rango 2" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/user/user.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/user/user.c msgid "input must be an ndarray" msgstr "Entrada tiene que ser un ndarray" +#: extmod/ulab/code/numpy/carray/carray.c +msgid "input must be an ndarray, or a scalar" +msgstr "" + #: extmod/ulab/code/scipy/signal/signal.c msgid "input must be one-dimensional" msgstr "Entrada tiene que ser unidimensional" @@ -3623,6 +3721,11 @@ msgstr "error de dominio matemático" msgid "matrix is not positive definite" msgstr "matrix no es definida positiva" +#: ports/espressif/common-hal/wifi/Radio.c +msgid "max_connections must be between 0 and 10" +msgstr "" + +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c #, c-format @@ -3777,6 +3880,7 @@ msgstr "no hay tal atributo" msgid "non-Device in %q" msgstr "hay un no-Device en %q" +#: ports/espressif/common-hal/_bleio/Connection.c #: ports/nrf/common-hal/_bleio/Connection.c msgid "non-UUID found in service_uuids_whitelist" msgstr "no UUID encontrado en service_uuids_whitelist" @@ -3820,7 +3924,11 @@ msgstr "" msgid "not enough arguments for format string" msgstr "no suficientes argumentos para format string" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/carray/carray_tools.c +msgid "not implemented for complex dtype" +msgstr "" + +#: extmod/ulab/code/numpy/create.c msgid "number of points must be at least 2" msgstr "el número de puntos debe ser al menos 2" @@ -3878,7 +3986,7 @@ msgstr "objeto con protocolo de buffer requerido" msgid "odd-length string" msgstr "string de longitud impar" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/utils/utils.c msgid "offset is too large" msgstr "offset es demasiado grande" @@ -3886,7 +3994,7 @@ msgstr "offset es demasiado grande" msgid "offset must be >= 0" msgstr "offset debe ser >= 0" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "offset must be non-negative and no greater than buffer length" msgstr "offset debe ser non-negative y no mayo que la longitud del buffer" @@ -3998,6 +4106,10 @@ msgstr "valor del pixel require demasiado bits" msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "pixel_shader debe ser displayio.Palette o displayio.ColorConverter" +#: extmod/vfs_posix_file.c +msgid "poll on file not available on win32" +msgstr "" + #: shared-module/vectorio/Polygon.c msgid "polygon can only be registered in one parent" msgstr "el polígono solo se puede registrar en uno de los padres" @@ -4027,18 +4139,27 @@ msgstr "el 3er argumento de pow() no puede ser 0" msgid "pow() with 3 arguments requires integers" msgstr "pow() con 3 argumentos requiere enteros" +#: ports/espressif/boards/adafruit_esp32s2_camera/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tft/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h #: ports/espressif/boards/adafruit_funhouse/mpconfigboard.h #: ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h +#: ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h +#: ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h #: ports/espressif/boards/atmegazero_esp32s2/mpconfigboard.h #: ports/espressif/boards/crumpspace_crumps2/mpconfigboard.h #: ports/espressif/boards/electroniccats_bastwifi/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s2_devkitc_1_n4r2/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_box/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h #: ports/espressif/boards/espressif_hmi_devkit_1/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1.3/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1/mpconfigboard.h @@ -4064,7 +4185,10 @@ msgstr "pow() con 3 argumentos requiere enteros" #: ports/espressif/boards/unexpectedmaker_feathers2/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_neo/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_prerelease/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_feathers3/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_pros3/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_tinys2/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_tinys3/mpconfigboard.h msgid "pressing boot button at start up.\n" msgstr "presionando botón de arranque al inicio.\n" @@ -4364,7 +4488,7 @@ msgstr "tobytes solo pueden ser invocados por arrays densos" msgid "too many arguments provided with the given format" msgstr "demasiados argumentos provistos con el formato dado" -#: extmod/ulab/code/ndarray.c extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/ndarray.c extmod/ulab/code/numpy/create.c msgid "too many dimensions" msgstr "demasiadas dimensiones" @@ -4548,7 +4672,7 @@ msgstr "el tiempo de espera del perro guardián debe ser mayor a 0" msgid "width must be from 2 to 8 (inclusive), not %d" msgstr "ancho debe estar entre 2 y 8 (inclusivamente), no %d" -#: shared-bindings/is31fl3741/is31fl3741.c +#: shared-bindings/is31fl3741/FrameBuffer.c #: shared-bindings/rgbmatrix/RGBMatrix.c msgid "width must be greater than zero" msgstr "el ancho debe ser mayor que cero" @@ -4565,7 +4689,7 @@ msgstr "la ventana debe ser <= intervalo" msgid "wrong axis index" msgstr "indice de eje erróneo" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "wrong axis specified" msgstr "eje especificado erróneo" @@ -4573,7 +4697,11 @@ msgstr "eje especificado erróneo" msgid "wrong input type" msgstr "tipo de entrada incorrecta" -#: extmod/ulab/code/ulab_create.c py/objarray.c py/objstr.c +#: extmod/ulab/code/numpy/transform.c +msgid "wrong length of condition array" +msgstr "" + +#: extmod/ulab/code/numpy/create.c py/objarray.c py/objstr.c msgid "wrong number of arguments" msgstr "numero erroneo de argumentos" @@ -4617,6 +4745,16 @@ msgstr "zi debe ser de tipo flotante" msgid "zi must be of shape (n_section, 2)" msgstr "zi debe ser una forma (n_section,2)" +#~ msgid "cannot perform relative import" +#~ msgstr "no se puedo realizar importación relativa" + +#, c-format +#~ msgid "No I2C device at address: %x" +#~ msgstr "No hay dispositivo I2C en la dirección: %x" + +#~ msgid "Unsupported pull value." +#~ msgstr "valor pull no soportado." + #~ msgid "%q must <= %d" #~ msgstr "%q debe ser <= %d" diff --git a/locale/fil.po b/locale/fil.po index cdf24b9389..ca9a65df37 100644 --- a/locale/fil.po +++ b/locale/fil.po @@ -100,7 +100,7 @@ msgstr "%q indeks ay dapat integers, hindi %s" msgid "%q length must be %d-%d" msgstr "" -#: shared-bindings/usb_hid/Device.c +#: shared-bindings/busio/I2C.c shared-bindings/usb_hid/Device.c msgid "%q length must be >= 1" msgstr "" @@ -146,6 +146,10 @@ msgstr "" msgid "%q must be of type %q" msgstr "" +#: shared-bindings/digitalio/Pull.c +msgid "%q must be of type %q or None" +msgstr "" + #: ports/atmel-samd/common-hal/busio/UART.c msgid "%q must be power of 2" msgstr "" @@ -447,6 +451,7 @@ msgstr "Lahat ng timers para sa pin na ito ay ginagamit" msgid "All timers in use" msgstr "Lahat ng timer ginagamit" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Already advertising." msgstr "" @@ -581,7 +586,7 @@ msgstr "Ang parehong mga pin ay dapat na sumusuporta sa hardware interrupts" #: shared-bindings/displayio/Display.c #: shared-bindings/framebufferio/FramebufferDisplay.c -#: shared-bindings/is31fl3741/is31fl3741.c +#: shared-bindings/is31fl3741/FrameBuffer.c #: shared-bindings/rgbmatrix/RGBMatrix.c msgid "Brightness must be 0-1.0" msgstr "" @@ -633,7 +638,7 @@ msgstr "" msgid "Buffer must be a multiple of 512 bytes" msgstr "" -#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c +#: shared-bindings/bitbangio/I2C.c msgid "Buffer must be at least length 1" msgstr "Buffer dapat ay hindi baba sa 1 na haba" @@ -667,6 +672,10 @@ msgstr "Sa gitna ng 0 o 255 dapat ang bytes." msgid "CBC blocks must be multiples of 16 bytes" msgstr "" +#: supervisor/shared/safe_mode.c +msgid "CIRCUITPY drive could not be found or created." +msgstr "" + #: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c msgid "CRC or checksum was invalid" msgstr "" @@ -911,10 +920,12 @@ msgstr "graphic ay dapat 2048 bytes ang haba" msgid "Data chunk must follow fmt chunk" msgstr "Dapat sunurin ng Data chunk ang fmt chunk" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data not supported with directed advertising" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c #, fuzzy msgid "Data too large for advertisement packet" @@ -997,6 +1008,7 @@ msgstr "" msgid "Expected tuple of length %d, got %d" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Extended advertisements with scan response not supported." msgstr "" @@ -1050,6 +1062,7 @@ msgstr "" msgid "Failed to buffer the sample" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Failed to connect: internal error" msgstr "" @@ -1129,6 +1142,13 @@ msgstr "" msgid "Group already used" msgstr "" +#: ports/atmel-samd/common-hal/busio/SPI.c ports/cxd56/common-hal/busio/SPI.c +#: ports/espressif/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/nrf/common-hal/busio/SPI.c +#: ports/raspberrypi/common-hal/busio/SPI.c +msgid "Half duplex SPI is not implemented" +msgstr "" + #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/I2C.c #: ports/stm/common-hal/busio/SPI.c ports/stm/common-hal/canio/CAN.c #: ports/stm/common-hal/sdioio/SDCard.c @@ -1283,6 +1303,7 @@ msgstr "" msgid "Invalid AuthMode" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c msgid "Invalid BLE parameter" msgstr "" @@ -1377,6 +1398,10 @@ msgstr "Mali ang format ng chunk size" msgid "Invalid memory access." msgstr "" +#: extmod/vfs_fat_file.c +msgid "Invalid mode" +msgstr "" + #: ports/espressif/common-hal/wifi/Radio.c msgid "Invalid multicast MAC address" msgstr "" @@ -1477,7 +1502,7 @@ msgstr "" msgid "Key must be 16, 24, or 32 bytes long" msgstr "" -#: shared-module/is31fl3741/is31fl3741.c +#: shared-module/is31fl3741/FrameBuffer.c msgid "LED mappings must match display size" msgstr "" @@ -1505,6 +1530,10 @@ msgstr "Hindi ma-initialize ang MISO pin." msgid "MOSI pin init failed." msgstr "Hindi ma-initialize ang MOSI pin." +#: shared-bindings/is31fl3741/IS31FL3741.c +msgid "Mapping must be a tuple" +msgstr "" + #: shared-module/displayio/Shape.c #, c-format msgid "Maximum x value when mirrored is %d" @@ -1587,6 +1616,10 @@ msgstr "" msgid "Name too long" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +msgid "Nimble out of memory" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "" @@ -1607,9 +1640,9 @@ msgstr "Walang DMA channel na mahanap" msgid "No DMA pacing timer found" msgstr "" -#: shared-module/adafruit_bus_device/I2CDevice.c +#: shared-module/adafruit_bus_device/i2c_device/I2CDevice.c #, c-format -msgid "No I2C device at address: %x" +msgid "No I2C device at address: 0x%x" msgstr "" #: ports/espressif/common-hal/busio/SPI.c @@ -1734,6 +1767,7 @@ msgstr "" msgid "Not a valid IP string" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c #, fuzzy @@ -1911,7 +1945,7 @@ msgstr "Ang pin ay walang kakayahan sa ADC" msgid "Pin interrupt already in use" msgstr "" -#: shared-bindings/adafruit_bus_device/SPIDevice.c +#: shared-bindings/adafruit_bus_device/spi_device/SPIDevice.c #: shared-bindings/digitalio/DigitalInOut.c msgid "Pin is input only" msgstr "" @@ -1993,6 +2027,10 @@ msgstr "Pull hindi ginagamit kapag ang direksyon ay output." msgid "RAISE mode is not implemented" msgstr "" +#: ports/raspberrypi/common-hal/countio/Counter.c +msgid "RISE_AND_FALL not available on this chip" +msgstr "" + #: ports/stm/common-hal/os/__init__.c msgid "RNG DeInit Error" msgstr "" @@ -2110,10 +2148,11 @@ msgstr "Sample rate ay dapat positibo" msgid "Sample rate too high. It must be less than %d" msgstr "Sample rate ay masyadong mataas. Ito ay dapat hindi hiigit sa %d" -#: shared-bindings/is31fl3741/is31fl3741.c +#: shared-bindings/is31fl3741/FrameBuffer.c msgid "Scale dimensions must divide by 3" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Scan already in progess. Stop with stop_scan." msgstr "" @@ -2272,6 +2311,7 @@ msgstr "" msgid "Time is in the past." msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2294,6 +2334,7 @@ msgstr "" msgid "Too many displays" msgstr "" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Total data to write is larger than %q" msgstr "" @@ -2371,7 +2412,7 @@ msgstr "Hindi ma-allocate ang buffers para sa naka-sign na conversion" msgid "Unable to create lock" msgstr "" -#: shared-module/displayio/I2CDisplay.c shared-module/is31fl3741/is31fl3741.c +#: shared-module/displayio/I2CDisplay.c shared-module/is31fl3741/IS31FL3741.c #, c-format msgid "Unable to find I2C Display at %x" msgstr "" @@ -2407,6 +2448,16 @@ msgstr "hindi inaasahang indent" msgid "Unhandled ESP TLS error %d %d %x %d" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown BLE error at %s:%d: %d" +msgstr "" + +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown BLE error: %d" +msgstr "" + #: shared-bindings/wifi/Radio.c #, c-format msgid "Unknown failure %d" @@ -2426,11 +2477,21 @@ msgstr "" msgid "Unknown security error: 0x%04x" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error at %s:%d: %d" +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown system firmware error: %04x" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error: %d" +msgstr "" + #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #, c-format msgid "Unmatched number of items on RHS (expected %d, got %d)." @@ -2465,19 +2526,19 @@ msgstr "Hindi supportadong format" msgid "Unsupported operation" msgstr "Hindi sinusuportahang operasyon" -#: shared-bindings/digitalio/DigitalInOut.c -msgid "Unsupported pull value." -msgstr "Hindi suportado ang pull value." - #: ports/espressif/common-hal/dualbank/__init__.c msgid "Update Failed" msgstr "" +#: ports/espressif/common-hal/_bleio/Characteristic.c +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length != required fixed length" msgstr "" +#: ports/espressif/common-hal/_bleio/Characteristic.c +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length > max_length" @@ -2535,6 +2596,7 @@ msgstr "" msgid "Woken up by alarm.\n" msgstr "" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Writes not supported on Characteristic" msgstr "" @@ -2638,7 +2700,7 @@ msgstr "" msgid "attributes not supported yet" msgstr "attributes hindi sinusuportahan" -#: extmod/ulab/code/numpy/numerical.c +#: extmod/ulab/code/ulab_tools.c msgid "axis is out of bounds" msgstr "" @@ -2694,11 +2756,11 @@ msgstr "bits_per_sample ay dapat 8 o 16" msgid "branch not in range" msgstr "branch wala sa range" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/utils/utils.c msgid "buffer is smaller than requested size" msgstr "" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/utils/utils.c msgid "buffer size must be a multiple of element size" msgstr "" @@ -2749,6 +2811,10 @@ msgstr "pagkakalibrate ay basahin lamang" msgid "calibration value out of range +/-127" msgstr "ang halaga ng pagkakalibrate ay wala sa sakop +/-127" +#: shared-module/vectorio/Rectangle.c +msgid "can only be registered in one parent" +msgstr "" + #: py/emitinlinethumb.c msgid "can only have up to 4 parameters to Thumb assembly" msgstr "maaari lamang magkaroon ng hanggang 4 na parameter sa Thumb assembly" @@ -2788,6 +2854,10 @@ msgstr "hindi ma-convert %s sa complex" msgid "can't convert '%q' object to %q implicitly" msgstr "hindi maaaring i-convert ang '%q' na bagay sa %q nang walang pahiwatig" +#: extmod/ulab/code/numpy/vector.c +msgid "can't convert complex to float" +msgstr "" + #: py/obj.c msgid "can't convert to %q" msgstr "" @@ -2841,6 +2911,10 @@ msgstr "hidi ma i-load galing sa '%q'" msgid "can't load with '%q' index" msgstr "hindi ma i-load gamit ng '%q' na index" +#: py/builtinimport.c +msgid "can't perform relative import" +msgstr "" + #: py/objgenerator.c msgid "can't send non-None value to a just-started generator" msgstr "hindi mapadala ang non-None value sa isang kaka umpisang generator" @@ -2887,6 +2961,14 @@ msgstr "" msgid "cannot cast output with casting rule" msgstr "" +#: extmod/ulab/code/ndarray.c +msgid "cannot convert complex to dtype" +msgstr "" + +#: extmod/ulab/code/ndarray.c +msgid "cannot convert complex type" +msgstr "" + #: py/objtype.c msgid "cannot create '%q' instances" msgstr "hindi magawa '%q' instances" @@ -2899,10 +2981,6 @@ msgstr "hindi magawa ang instance" msgid "cannot import name %q" msgstr "hindi ma-import ang name %q" -#: py/builtinimport.c -msgid "cannot perform relative import" -msgstr "hindi maaring isagawa ang relative import" - #: extmod/moductypes.c msgid "cannot unambiguously get sizeof scalar" msgstr "" @@ -3082,6 +3160,10 @@ msgstr "dibisyon ng zero" msgid "divisor must be 4" msgstr "" +#: extmod/ulab/code/numpy/vector.c +msgid "dtype must be float, or complex" +msgstr "" + #: py/objdeque.c msgid "empty" msgstr "walang laman" @@ -3186,7 +3268,7 @@ msgstr "" msgid "first argument must be a function" msgstr "" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "first argument must be a tuple of ndarrays" msgstr "" @@ -3251,6 +3333,10 @@ msgstr "" msgid "function is defined for ndarrays only" msgstr "" +#: extmod/ulab/code/numpy/carray/carray.c +msgid "function is implemented for ndarrays only" +msgstr "" + #: py/argcheck.c #, c-format msgid "function missing %d required positional arguments" @@ -3365,7 +3451,7 @@ msgstr "inline assembler ay dapat na function" msgid "input and output shapes are not compatible" msgstr "" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "input argument must be an integer, a tuple, or a list" msgstr "" @@ -3373,7 +3459,7 @@ msgstr "" msgid "input array length must be power of 2" msgstr "" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "input arrays are not compatible" msgstr "" @@ -3381,6 +3467,10 @@ msgstr "" msgid "input data must be an iterable" msgstr "" +#: extmod/ulab/code/numpy/vector.c +msgid "input dtype must be float or complex" +msgstr "" + #: extmod/ulab/code/numpy/linalg/linalg.c msgid "input matrix is asymmetric" msgstr "" @@ -3390,18 +3480,26 @@ msgstr "" msgid "input matrix is singular" msgstr "" +#: extmod/ulab/code/numpy/carray/carray.c +msgid "input must be a 1D ndarray" +msgstr "" + #: extmod/ulab/code/scipy/linalg/linalg.c extmod/ulab/code/user/user.c msgid "input must be a dense ndarray" msgstr "" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "input must be a tensor of rank 2" msgstr "" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/user/user.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/user/user.c msgid "input must be an ndarray" msgstr "" +#: extmod/ulab/code/numpy/carray/carray.c +msgid "input must be an ndarray, or a scalar" +msgstr "" + #: extmod/ulab/code/scipy/signal/signal.c msgid "input must be one-dimensional" msgstr "" @@ -3583,6 +3681,11 @@ msgstr "may pagkakamali sa math domain" msgid "matrix is not positive definite" msgstr "" +#: ports/espressif/common-hal/wifi/Radio.c +msgid "max_connections must be between 0 and 10" +msgstr "" + +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c #, c-format @@ -3736,6 +3839,7 @@ msgstr "walang ganoon na attribute" msgid "non-Device in %q" msgstr "" +#: ports/espressif/common-hal/_bleio/Connection.c #: ports/nrf/common-hal/_bleio/Connection.c msgid "non-UUID found in service_uuids_whitelist" msgstr "" @@ -3776,7 +3880,11 @@ msgstr "hindi lahat ng arguments na i-convert habang string formatting" msgid "not enough arguments for format string" msgstr "kulang sa arguments para sa format string" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/carray/carray_tools.c +msgid "not implemented for complex dtype" +msgstr "" + +#: extmod/ulab/code/numpy/create.c msgid "number of points must be at least 2" msgstr "" @@ -3834,7 +3942,7 @@ msgstr "object na may buffer protocol kinakailangan" msgid "odd-length string" msgstr "odd-length string" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/utils/utils.c msgid "offset is too large" msgstr "" @@ -3842,7 +3950,7 @@ msgstr "" msgid "offset must be >= 0" msgstr "" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "offset must be non-negative and no greater than buffer length" msgstr "" @@ -3956,6 +4064,10 @@ msgstr "" msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "pixel_shader ay dapat displayio.Palette o displayio.ColorConverter" +#: extmod/vfs_posix_file.c +msgid "poll on file not available on win32" +msgstr "" + #: shared-module/vectorio/Polygon.c msgid "polygon can only be registered in one parent" msgstr "" @@ -3985,18 +4097,27 @@ msgstr "pow() 3rd argument ay hindi maaring 0" msgid "pow() with 3 arguments requires integers" msgstr "pow() na may 3 argumento kailangan ng integers" +#: ports/espressif/boards/adafruit_esp32s2_camera/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tft/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h #: ports/espressif/boards/adafruit_funhouse/mpconfigboard.h #: ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h +#: ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h +#: ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h #: ports/espressif/boards/atmegazero_esp32s2/mpconfigboard.h #: ports/espressif/boards/crumpspace_crumps2/mpconfigboard.h #: ports/espressif/boards/electroniccats_bastwifi/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s2_devkitc_1_n4r2/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_box/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h #: ports/espressif/boards/espressif_hmi_devkit_1/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1.3/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1/mpconfigboard.h @@ -4022,7 +4143,10 @@ msgstr "pow() na may 3 argumento kailangan ng integers" #: ports/espressif/boards/unexpectedmaker_feathers2/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_neo/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_prerelease/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_feathers3/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_pros3/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_tinys2/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_tinys3/mpconfigboard.h msgid "pressing boot button at start up.\n" msgstr "" @@ -4323,7 +4447,7 @@ msgstr "" msgid "too many arguments provided with the given format" msgstr "masyadong maraming mga argumento na ibinigay sa ibinigay na format" -#: extmod/ulab/code/ndarray.c extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/ndarray.c extmod/ulab/code/numpy/create.c msgid "too many dimensions" msgstr "" @@ -4507,7 +4631,7 @@ msgstr "" msgid "width must be from 2 to 8 (inclusive), not %d" msgstr "" -#: shared-bindings/is31fl3741/is31fl3741.c +#: shared-bindings/is31fl3741/FrameBuffer.c #: shared-bindings/rgbmatrix/RGBMatrix.c msgid "width must be greater than zero" msgstr "" @@ -4524,7 +4648,7 @@ msgstr "" msgid "wrong axis index" msgstr "" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "wrong axis specified" msgstr "" @@ -4532,7 +4656,11 @@ msgstr "" msgid "wrong input type" msgstr "" -#: extmod/ulab/code/ulab_create.c py/objarray.c py/objstr.c +#: extmod/ulab/code/numpy/transform.c +msgid "wrong length of condition array" +msgstr "" + +#: extmod/ulab/code/numpy/create.c py/objarray.c py/objstr.c msgid "wrong number of arguments" msgstr "mali ang bilang ng argumento" @@ -4578,6 +4706,12 @@ msgstr "" msgid "zi must be of shape (n_section, 2)" msgstr "" +#~ msgid "cannot perform relative import" +#~ msgstr "hindi maaring isagawa ang relative import" + +#~ msgid "Unsupported pull value." +#~ msgstr "Hindi suportado ang pull value." + #, c-format #~ msgid "" #~ "Welcome to Adafruit CircuitPython %s!\n" diff --git a/locale/fr.po b/locale/fr.po index 4e938bae59..e07fca2007 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -8,8 +8,8 @@ msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-01-04 12:55-0600\n" -"PO-Revision-Date: 2021-11-26 13:46+0000\n" -"Last-Translator: Maxime Leroy \n" +"PO-Revision-Date: 2021-12-13 05:53+0000\n" +"Last-Translator: Jeff Epler \n" "Language: fr\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" @@ -110,7 +110,7 @@ msgstr "les indices %q doivent être des entiers, pas %s" msgid "%q length must be %d-%d" msgstr "La longueur de %q doit être %d-%d" -#: shared-bindings/usb_hid/Device.c +#: shared-bindings/busio/I2C.c shared-bindings/usb_hid/Device.c msgid "%q length must be >= 1" msgstr "La longueur de %q doit être >= 1" @@ -155,6 +155,10 @@ msgstr "%q doit être entre %d et %d" msgid "%q must be of type %q" msgstr "%q doit être du type %q" +#: shared-bindings/digitalio/Pull.c +msgid "%q must be of type %q or None" +msgstr "" + #: ports/atmel-samd/common-hal/busio/UART.c msgid "%q must be power of 2" msgstr "%q doit être une puissance de 2" @@ -453,6 +457,7 @@ msgstr "Tous les minuteurs pour cette broche sont utilisés" msgid "All timers in use" msgstr "Tous les minuteurs sont utilisés" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Already advertising." msgstr "S'annonce déjà." @@ -591,7 +596,7 @@ msgstr "Les deux broches doivent supporter les interruptions matérielles" #: shared-bindings/displayio/Display.c #: shared-bindings/framebufferio/FramebufferDisplay.c -#: shared-bindings/is31fl3741/is31fl3741.c +#: shared-bindings/is31fl3741/FrameBuffer.c #: shared-bindings/rgbmatrix/RGBMatrix.c msgid "Brightness must be 0-1.0" msgstr "La luminosité doit être de 0 à 1.0" @@ -643,7 +648,7 @@ msgstr "La longueur de la mémoire tampon doit être un multiple de 512" msgid "Buffer must be a multiple of 512 bytes" msgstr "La mémoire tampon doit être un multiple de 512" -#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c +#: shared-bindings/bitbangio/I2C.c msgid "Buffer must be at least length 1" msgstr "Le tampon doit être de longueur au moins 1" @@ -676,6 +681,10 @@ msgstr "Les octets 'bytes' doivent être entre 0 et 255." msgid "CBC blocks must be multiples of 16 bytes" msgstr "Les blocs CBC doivent être des multiples de 16 octets" +#: supervisor/shared/safe_mode.c +msgid "CIRCUITPY drive could not be found or created." +msgstr "" + #: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c msgid "CRC or checksum was invalid" msgstr "CRC ou somme de contrôle invalide" @@ -928,10 +937,12 @@ msgstr "La broche 'Data 0' doit être aligné sur l'octet" msgid "Data chunk must follow fmt chunk" msgstr "Un bloc de données doit suivre un bloc fmt" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data not supported with directed advertising" msgstr "Les données ne sont pas supportées avec les annonces directes" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data too large for advertisement packet" msgstr "Données trop volumineuses pour un paquet d'avertissement" @@ -1014,6 +1025,7 @@ msgstr "Une alarme était prévue" msgid "Expected tuple of length %d, got %d" msgstr "Tuple de longueur %d attendu, obtenu %d" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Extended advertisements with scan response not supported." msgstr "" @@ -1068,6 +1080,7 @@ msgstr "Impossible d'allouer la mémoire pour le scan wifi" msgid "Failed to buffer the sample" msgstr "Échec du tamponage de l'échantillon" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Failed to connect: internal error" msgstr "Impossible de se connecter : erreur interne" @@ -1151,6 +1164,13 @@ msgstr "Échec génerique" msgid "Group already used" msgstr "Groupe déjà utilisé" +#: ports/atmel-samd/common-hal/busio/SPI.c ports/cxd56/common-hal/busio/SPI.c +#: ports/espressif/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/nrf/common-hal/busio/SPI.c +#: ports/raspberrypi/common-hal/busio/SPI.c +msgid "Half duplex SPI is not implemented" +msgstr "" + #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/I2C.c #: ports/stm/common-hal/busio/SPI.c ports/stm/common-hal/canio/CAN.c #: ports/stm/common-hal/sdioio/SDCard.c @@ -1314,6 +1334,7 @@ msgstr "Valeur d'unité ADC non valide" msgid "Invalid AuthMode" msgstr "AuthMode invalide" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c msgid "Invalid BLE parameter" msgstr "Paramètre BLE invalide" @@ -1408,6 +1429,10 @@ msgstr "Taille de bloc de formatage invalide" msgid "Invalid memory access." msgstr "Accès à la mémoire invalide." +#: extmod/vfs_fat_file.c +msgid "Invalid mode" +msgstr "" + #: ports/espressif/common-hal/wifi/Radio.c msgid "Invalid multicast MAC address" msgstr "Adresse MAC multicast invalide" @@ -1508,7 +1533,7 @@ msgstr "Longueur de mot / bit invalide" msgid "Key must be 16, 24, or 32 bytes long" msgstr "La clé doit comporter 16, 24 ou 32 octets" -#: shared-module/is31fl3741/is31fl3741.c +#: shared-module/is31fl3741/FrameBuffer.c msgid "LED mappings must match display size" msgstr "La disposition des LED doit correspondre à la taille de l'écran" @@ -1536,6 +1561,10 @@ msgstr "Échec de l'initialization de la broche MISO." msgid "MOSI pin init failed." msgstr "Échec de l'initialization de la broche MOSI." +#: shared-bindings/is31fl3741/IS31FL3741.c +msgid "Mapping must be a tuple" +msgstr "" + #: shared-module/displayio/Shape.c #, c-format msgid "Maximum x value when mirrored is %d" @@ -1620,6 +1649,10 @@ msgstr "Erreur NVS" msgid "Name too long" msgstr "Nom trop long" +#: ports/espressif/common-hal/_bleio/__init__.c +msgid "Nimble out of memory" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "Pas de CCCD pour cette caractéristique" @@ -1640,10 +1673,10 @@ msgstr "Aucun canal DMA trouvé" msgid "No DMA pacing timer found" msgstr "Aucun minuteur de rythme DMA trouvé" -#: shared-module/adafruit_bus_device/I2CDevice.c +#: shared-module/adafruit_bus_device/i2c_device/I2CDevice.c #, c-format -msgid "No I2C device at address: %x" -msgstr "Pas de dispositif I2C à l'adresse : %x" +msgid "No I2C device at address: 0x%x" +msgstr "" #: ports/espressif/common-hal/busio/SPI.c #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c @@ -1767,6 +1800,7 @@ msgstr "Logiciel systême Nordic hors de mémoire" msgid "Not a valid IP string" msgstr "Chaîne IP non valide" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -1950,7 +1984,7 @@ msgstr "La broche 'pin' ne supporte pas les capacitées ADC" msgid "Pin interrupt already in use" msgstr "L'interruption de cette broche est déjà utilisée" -#: shared-bindings/adafruit_bus_device/SPIDevice.c +#: shared-bindings/adafruit_bus_device/spi_device/SPIDevice.c #: shared-bindings/digitalio/DigitalInOut.c msgid "Pin is input only" msgstr "La broche est entrée uniquement" @@ -2038,6 +2072,10 @@ msgstr "Le tirage 'pull' n'est pas utilisé quand la direction est 'output'." msgid "RAISE mode is not implemented" msgstr "Mode RAISE n'est pas implémenté" +#: ports/raspberrypi/common-hal/countio/Counter.c +msgid "RISE_AND_FALL not available on this chip" +msgstr "" + #: ports/stm/common-hal/os/__init__.c msgid "RNG DeInit Error" msgstr "Erreur de désinitialisation du RNG" @@ -2154,10 +2192,11 @@ msgstr "Le taux d'échantillonage doit être positif" msgid "Sample rate too high. It must be less than %d" msgstr "Taux d'échantillonage trop élevé. Doit être inférieur à %d" -#: shared-bindings/is31fl3741/is31fl3741.c +#: shared-bindings/is31fl3741/FrameBuffer.c msgid "Scale dimensions must divide by 3" msgstr "La dimension d'échelle doit être un multiple de 3" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Scan already in progess. Stop with stop_scan." msgstr "Scan déjà en cours. Arrêtez avec stop_scan." @@ -2327,6 +2366,7 @@ msgstr "La largeur de la tuile doit diviser exactement la largeur de l'image" msgid "Time is in the past." msgstr "L'heure est dans le passé." +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2349,6 +2389,7 @@ msgstr "Trop de bus d'affichage" msgid "Too many displays" msgstr "Trop d'affichages" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Total data to write is larger than %q" msgstr "Quantité de données à écrire est plus que %q" @@ -2429,7 +2470,7 @@ msgstr "Impossible d'allouer des tampons pour une conversion signée" msgid "Unable to create lock" msgstr "Impossible de créer un verrou ('lock')" -#: shared-module/displayio/I2CDisplay.c shared-module/is31fl3741/is31fl3741.c +#: shared-module/displayio/I2CDisplay.c shared-module/is31fl3741/IS31FL3741.c #, c-format msgid "Unable to find I2C Display at %x" msgstr "Impossible de trouver l'affichage I2C à %x" @@ -2464,6 +2505,16 @@ msgstr "Type inattendu pour l'uuid nrfx" msgid "Unhandled ESP TLS error %d %d %x %d" msgstr "Erreur ESP TLS non gérée %d %d %x %d" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown BLE error at %s:%d: %d" +msgstr "" + +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown BLE error: %d" +msgstr "" + #: shared-bindings/wifi/Radio.c #, c-format msgid "Unknown failure %d" @@ -2483,11 +2534,21 @@ msgstr "Raison inconnue." msgid "Unknown security error: 0x%04x" msgstr "Erreur de sécurité inconnue : 0x%04x" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error at %s:%d: %d" +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown system firmware error: %04x" msgstr "Faute inconnue du logiciel systême : %04x" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error: %d" +msgstr "" + #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #, c-format msgid "Unmatched number of items on RHS (expected %d, got %d)." @@ -2524,19 +2585,19 @@ msgstr "Format non supporté" msgid "Unsupported operation" msgstr "Opération non supportée" -#: shared-bindings/digitalio/DigitalInOut.c -msgid "Unsupported pull value." -msgstr "Valeur de tirage 'pull' non supportée." - #: ports/espressif/common-hal/dualbank/__init__.c msgid "Update Failed" msgstr "Mise-à-jour échouée" +#: ports/espressif/common-hal/_bleio/Characteristic.c +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length != required fixed length" msgstr "Longueur de valeur != Longueur fixe requise" +#: ports/espressif/common-hal/_bleio/Characteristic.c +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length > max_length" @@ -2603,6 +2664,7 @@ msgstr "Le mot de passe WiFi doit faire entre 8 et 63 caractères" msgid "Woken up by alarm.\n" msgstr "Réveil par alarme.\n" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Writes not supported on Characteristic" msgstr "Écritures non supporté vers les Characteristic" @@ -2708,7 +2770,7 @@ msgstr "tenter d'obtenir argmin / argmax d'une séquence vide" msgid "attributes not supported yet" msgstr "attribut pas encore supporté" -#: extmod/ulab/code/numpy/numerical.c +#: extmod/ulab/code/ulab_tools.c msgid "axis is out of bounds" msgstr "axis est hors limites" @@ -2764,11 +2826,11 @@ msgstr "'bits_per_sample' doivent être 8 ou 16" msgid "branch not in range" msgstr "branche hors-bornes" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/utils/utils.c msgid "buffer is smaller than requested size" msgstr "tampon est plus petit que la taille demandée" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/utils/utils.c msgid "buffer size must be a multiple of element size" msgstr "taille du tampon doit être un multiple de la taille de l'élement" @@ -2818,6 +2880,10 @@ msgstr "étalonnage en lecture seule" msgid "calibration value out of range +/-127" msgstr "valeur de étalonnage hors bornes +/-127" +#: shared-module/vectorio/Rectangle.c +msgid "can only be registered in one parent" +msgstr "" + #: py/emitinlinethumb.c msgid "can only have up to 4 parameters to Thumb assembly" msgstr "il peut y avoir jusqu'à 4 paramètres pour l'assemblage Thumb" @@ -2857,6 +2923,10 @@ msgstr "ne peut convertir %s en nombre complexe" msgid "can't convert '%q' object to %q implicitly" msgstr "impossible de convertir l'objet '%q' en '%q' implicitement" +#: extmod/ulab/code/numpy/vector.c +msgid "can't convert complex to float" +msgstr "" + #: py/obj.c msgid "can't convert to %q" msgstr "impossible de convertir en %q" @@ -2909,6 +2979,10 @@ msgstr "impossible de charger depuis '%q'" msgid "can't load with '%q' index" msgstr "impossible de charger avec l'indice '%q'" +#: py/builtinimport.c +msgid "can't perform relative import" +msgstr "" + #: py/objgenerator.c msgid "can't send non-None value to a just-started generator" msgstr "" @@ -2957,6 +3031,14 @@ msgstr "ne peut assigner une nouvelle forme" msgid "cannot cast output with casting rule" msgstr "output ne peut être projeté sans règle de projection" +#: extmod/ulab/code/ndarray.c +msgid "cannot convert complex to dtype" +msgstr "" + +#: extmod/ulab/code/ndarray.c +msgid "cannot convert complex type" +msgstr "" + #: py/objtype.c msgid "cannot create '%q' instances" msgstr "ne peut pas créer une instance de '%q'" @@ -2969,10 +3051,6 @@ msgstr "ne peut pas créer une instance" msgid "cannot import name %q" msgstr "ne peut pas importer le nom %q" -#: py/builtinimport.c -msgid "cannot perform relative import" -msgstr "ne peut pas réaliser un import relatif" - #: extmod/moductypes.c msgid "cannot unambiguously get sizeof scalar" msgstr "ne peut récupérer sans ambigüité le sizeof d'un scalaire" @@ -3152,6 +3230,10 @@ msgstr "division par zéro" msgid "divisor must be 4" msgstr "le diviseur doit être 4" +#: extmod/ulab/code/numpy/vector.c +msgid "dtype must be float, or complex" +msgstr "" + #: py/objdeque.c msgid "empty" msgstr "vide" @@ -3255,7 +3337,7 @@ msgstr "le premier argument doit être un appelable" msgid "first argument must be a function" msgstr "le premier argument doit être une fonction" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "first argument must be a tuple of ndarrays" msgstr "le premier paramêtre doit être un tuple de ndarrays" @@ -3320,6 +3402,10 @@ msgstr "la fonction a le même signe aux extrémités de l’intervalle" msgid "function is defined for ndarrays only" msgstr "fonction définie que pour les ndarrays" +#: extmod/ulab/code/numpy/carray/carray.c +msgid "function is implemented for ndarrays only" +msgstr "" + #: py/argcheck.c #, c-format msgid "function missing %d required positional arguments" @@ -3434,7 +3520,7 @@ msgstr "l'assembleur doit être une fonction" msgid "input and output shapes are not compatible" msgstr "les formes d'entrée et de sortie ne sont pas compatibles" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "input argument must be an integer, a tuple, or a list" msgstr "Paramètre entrant doit être un chiffre entier, un tuple, ou une liste" @@ -3442,7 +3528,7 @@ msgstr "Paramètre entrant doit être un chiffre entier, un tuple, ou une liste" msgid "input array length must be power of 2" msgstr "longueur de la matrice d'entrée doit être une puissance de 2" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "input arrays are not compatible" msgstr "les matrices d'entrée ne sont pas compatibles" @@ -3450,6 +3536,10 @@ msgstr "les matrices d'entrée ne sont pas compatibles" msgid "input data must be an iterable" msgstr "les données d'entrée doivent être un itérable" +#: extmod/ulab/code/numpy/vector.c +msgid "input dtype must be float or complex" +msgstr "" + #: extmod/ulab/code/numpy/linalg/linalg.c msgid "input matrix is asymmetric" msgstr "la matrice d'entrée est asymétrique" @@ -3459,18 +3549,26 @@ msgstr "la matrice d'entrée est asymétrique" msgid "input matrix is singular" msgstr "la matrice d'entrée est singulière" +#: extmod/ulab/code/numpy/carray/carray.c +msgid "input must be a 1D ndarray" +msgstr "" + #: extmod/ulab/code/scipy/linalg/linalg.c extmod/ulab/code/user/user.c msgid "input must be a dense ndarray" msgstr "l'entrée doit être un ndarray dense" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "input must be a tensor of rank 2" msgstr "l'entrée doit être un tenseur de rang 2" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/user/user.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/user/user.c msgid "input must be an ndarray" msgstr "l'entrée doit être un ndarray" +#: extmod/ulab/code/numpy/carray/carray.c +msgid "input must be an ndarray, or a scalar" +msgstr "" + #: extmod/ulab/code/scipy/signal/signal.c msgid "input must be one-dimensional" msgstr "l'entrée doit être uni-dimensionelle" @@ -3566,7 +3664,6 @@ msgid "invalid syntax for number" msgstr "syntaxe invalide pour un nombre" #: py/objexcept.c -#, fuzzy msgid "invalid traceback" msgstr "traceback invalide" @@ -3654,6 +3751,11 @@ msgstr "erreur de domaine math" msgid "matrix is not positive definite" msgstr "la matrice n'est pas définie positive" +#: ports/espressif/common-hal/wifi/Radio.c +msgid "max_connections must be between 0 and 10" +msgstr "" + +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c #, c-format @@ -3807,6 +3909,7 @@ msgstr "pas de tel attribut" msgid "non-Device in %q" msgstr "aucun appareil dans %q" +#: ports/espressif/common-hal/_bleio/Connection.c #: ports/nrf/common-hal/_bleio/Connection.c msgid "non-UUID found in service_uuids_whitelist" msgstr "non UUID trouvé dans service_uuids_whitelist" @@ -3849,7 +3952,11 @@ msgstr "" msgid "not enough arguments for format string" msgstr "pas assez d'arguments pour la chaîne de format" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/carray/carray_tools.c +msgid "not implemented for complex dtype" +msgstr "" + +#: extmod/ulab/code/numpy/create.c msgid "number of points must be at least 2" msgstr "le nombre de points doit être d'au moins 2" @@ -3907,7 +4014,7 @@ msgstr "un objet avec un protocole de tampon est nécessaire" msgid "odd-length string" msgstr "chaîne de longueur impaire" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/utils/utils.c msgid "offset is too large" msgstr "offset est trop large" @@ -3915,7 +4022,7 @@ msgstr "offset est trop large" msgid "offset must be >= 0" msgstr "offset doit être >= 0" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "offset must be non-negative and no greater than buffer length" msgstr "offset doit être non-négatif, et au plus la taille du tampon" @@ -4030,6 +4137,10 @@ msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "" "pixel_shader doit être un objet displayio.Palette ou displayio.ColorConverter" +#: extmod/vfs_posix_file.c +msgid "poll on file not available on win32" +msgstr "" + #: shared-module/vectorio/Polygon.c msgid "polygon can only be registered in one parent" msgstr "le polygone ne peut être enregistré que dans un parent" @@ -4059,18 +4170,27 @@ msgstr "le 3e argument de pow() ne peut être 0" msgid "pow() with 3 arguments requires integers" msgstr "pow() avec 3 arguments nécessite des entiers" +#: ports/espressif/boards/adafruit_esp32s2_camera/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tft/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h #: ports/espressif/boards/adafruit_funhouse/mpconfigboard.h #: ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h +#: ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h +#: ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h #: ports/espressif/boards/atmegazero_esp32s2/mpconfigboard.h #: ports/espressif/boards/crumpspace_crumps2/mpconfigboard.h #: ports/espressif/boards/electroniccats_bastwifi/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s2_devkitc_1_n4r2/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_box/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h #: ports/espressif/boards/espressif_hmi_devkit_1/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1.3/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1/mpconfigboard.h @@ -4096,7 +4216,10 @@ msgstr "pow() avec 3 arguments nécessite des entiers" #: ports/espressif/boards/unexpectedmaker_feathers2/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_neo/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_prerelease/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_feathers3/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_pros3/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_tinys2/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_tinys3/mpconfigboard.h msgid "pressing boot button at start up.\n" msgstr "bouton boot appuyé lors du démarrage.\n" @@ -4396,7 +4519,7 @@ msgstr "tobytes ne peut être appelée que pour des matrices dense" msgid "too many arguments provided with the given format" msgstr "trop d'arguments fournis avec ce format" -#: extmod/ulab/code/ndarray.c extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/ndarray.c extmod/ulab/code/numpy/create.c msgid "too many dimensions" msgstr "Trop de dimensions" @@ -4580,7 +4703,7 @@ msgstr "watchdog timeout doit être supérieur à 0" msgid "width must be from 2 to 8 (inclusive), not %d" msgstr "width doit être entre 2 et 8 (inclusivement), non %d" -#: shared-bindings/is31fl3741/is31fl3741.c +#: shared-bindings/is31fl3741/FrameBuffer.c #: shared-bindings/rgbmatrix/RGBMatrix.c msgid "width must be greater than zero" msgstr "width doit être plus que zero" @@ -4597,7 +4720,7 @@ msgstr "la fenêtre (window) doit être <= intervalle (interval)" msgid "wrong axis index" msgstr "index d'axe incorrecte" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "wrong axis specified" msgstr "axe incorrecte spécifiée" @@ -4605,7 +4728,11 @@ msgstr "axe incorrecte spécifiée" msgid "wrong input type" msgstr "type d'entrée incorrect" -#: extmod/ulab/code/ulab_create.c py/objarray.c py/objstr.c +#: extmod/ulab/code/numpy/transform.c +msgid "wrong length of condition array" +msgstr "" + +#: extmod/ulab/code/numpy/create.c py/objarray.c py/objstr.c msgid "wrong number of arguments" msgstr "mauvais nombres d'arguments" @@ -4649,6 +4776,16 @@ msgstr "zi doit être de type float" msgid "zi must be of shape (n_section, 2)" msgstr "zi doit être de forme (n_section, 2)" +#~ msgid "cannot perform relative import" +#~ msgstr "ne peut pas réaliser un import relatif" + +#, c-format +#~ msgid "No I2C device at address: %x" +#~ msgstr "Pas de dispositif I2C à l'adresse : %x" + +#~ msgid "Unsupported pull value." +#~ msgstr "Valeur de tirage 'pull' non supportée." + #, c-format #~ msgid "" #~ "Welcome to Adafruit CircuitPython %s!\n" diff --git a/locale/hi.po b/locale/hi.po index 7d6327a2ee..df890a9bf1 100644 --- a/locale/hi.po +++ b/locale/hi.po @@ -99,7 +99,7 @@ msgstr "" msgid "%q length must be %d-%d" msgstr "" -#: shared-bindings/usb_hid/Device.c +#: shared-bindings/busio/I2C.c shared-bindings/usb_hid/Device.c msgid "%q length must be >= 1" msgstr "" @@ -144,6 +144,10 @@ msgstr "" msgid "%q must be of type %q" msgstr "" +#: shared-bindings/digitalio/Pull.c +msgid "%q must be of type %q or None" +msgstr "" + #: ports/atmel-samd/common-hal/busio/UART.c msgid "%q must be power of 2" msgstr "" @@ -442,6 +446,7 @@ msgstr "" msgid "All timers in use" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Already advertising." msgstr "" @@ -574,7 +579,7 @@ msgstr "" #: shared-bindings/displayio/Display.c #: shared-bindings/framebufferio/FramebufferDisplay.c -#: shared-bindings/is31fl3741/is31fl3741.c +#: shared-bindings/is31fl3741/FrameBuffer.c #: shared-bindings/rgbmatrix/RGBMatrix.c msgid "Brightness must be 0-1.0" msgstr "" @@ -626,7 +631,7 @@ msgstr "" msgid "Buffer must be a multiple of 512 bytes" msgstr "" -#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c +#: shared-bindings/bitbangio/I2C.c msgid "Buffer must be at least length 1" msgstr "" @@ -659,6 +664,10 @@ msgstr "" msgid "CBC blocks must be multiples of 16 bytes" msgstr "" +#: supervisor/shared/safe_mode.c +msgid "CIRCUITPY drive could not be found or created." +msgstr "" + #: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c msgid "CRC or checksum was invalid" msgstr "" @@ -900,10 +909,12 @@ msgstr "" msgid "Data chunk must follow fmt chunk" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data not supported with directed advertising" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data too large for advertisement packet" msgstr "" @@ -984,6 +995,7 @@ msgstr "" msgid "Expected tuple of length %d, got %d" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Extended advertisements with scan response not supported." msgstr "" @@ -1037,6 +1049,7 @@ msgstr "" msgid "Failed to buffer the sample" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Failed to connect: internal error" msgstr "" @@ -1116,6 +1129,13 @@ msgstr "" msgid "Group already used" msgstr "" +#: ports/atmel-samd/common-hal/busio/SPI.c ports/cxd56/common-hal/busio/SPI.c +#: ports/espressif/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/nrf/common-hal/busio/SPI.c +#: ports/raspberrypi/common-hal/busio/SPI.c +msgid "Half duplex SPI is not implemented" +msgstr "" + #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/I2C.c #: ports/stm/common-hal/busio/SPI.c ports/stm/common-hal/canio/CAN.c #: ports/stm/common-hal/sdioio/SDCard.c @@ -1268,6 +1288,7 @@ msgstr "" msgid "Invalid AuthMode" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c msgid "Invalid BLE parameter" msgstr "" @@ -1362,6 +1383,10 @@ msgstr "" msgid "Invalid memory access." msgstr "" +#: extmod/vfs_fat_file.c +msgid "Invalid mode" +msgstr "" + #: ports/espressif/common-hal/wifi/Radio.c msgid "Invalid multicast MAC address" msgstr "" @@ -1462,7 +1487,7 @@ msgstr "" msgid "Key must be 16, 24, or 32 bytes long" msgstr "" -#: shared-module/is31fl3741/is31fl3741.c +#: shared-module/is31fl3741/FrameBuffer.c msgid "LED mappings must match display size" msgstr "" @@ -1490,6 +1515,10 @@ msgstr "" msgid "MOSI pin init failed." msgstr "" +#: shared-bindings/is31fl3741/IS31FL3741.c +msgid "Mapping must be a tuple" +msgstr "" + #: shared-module/displayio/Shape.c #, c-format msgid "Maximum x value when mirrored is %d" @@ -1572,6 +1601,10 @@ msgstr "" msgid "Name too long" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +msgid "Nimble out of memory" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "" @@ -1592,9 +1625,9 @@ msgstr "" msgid "No DMA pacing timer found" msgstr "" -#: shared-module/adafruit_bus_device/I2CDevice.c +#: shared-module/adafruit_bus_device/i2c_device/I2CDevice.c #, c-format -msgid "No I2C device at address: %x" +msgid "No I2C device at address: 0x%x" msgstr "" #: ports/espressif/common-hal/busio/SPI.c @@ -1719,6 +1752,7 @@ msgstr "" msgid "Not a valid IP string" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -1892,7 +1926,7 @@ msgstr "" msgid "Pin interrupt already in use" msgstr "" -#: shared-bindings/adafruit_bus_device/SPIDevice.c +#: shared-bindings/adafruit_bus_device/spi_device/SPIDevice.c #: shared-bindings/digitalio/DigitalInOut.c msgid "Pin is input only" msgstr "" @@ -1974,6 +2008,10 @@ msgstr "" msgid "RAISE mode is not implemented" msgstr "" +#: ports/raspberrypi/common-hal/countio/Counter.c +msgid "RISE_AND_FALL not available on this chip" +msgstr "" + #: ports/stm/common-hal/os/__init__.c msgid "RNG DeInit Error" msgstr "" @@ -2090,10 +2128,11 @@ msgstr "" msgid "Sample rate too high. It must be less than %d" msgstr "" -#: shared-bindings/is31fl3741/is31fl3741.c +#: shared-bindings/is31fl3741/FrameBuffer.c msgid "Scale dimensions must divide by 3" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Scan already in progess. Stop with stop_scan." msgstr "" @@ -2252,6 +2291,7 @@ msgstr "" msgid "Time is in the past." msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2274,6 +2314,7 @@ msgstr "" msgid "Too many displays" msgstr "" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Total data to write is larger than %q" msgstr "" @@ -2351,7 +2392,7 @@ msgstr "" msgid "Unable to create lock" msgstr "" -#: shared-module/displayio/I2CDisplay.c shared-module/is31fl3741/is31fl3741.c +#: shared-module/displayio/I2CDisplay.c shared-module/is31fl3741/IS31FL3741.c #, c-format msgid "Unable to find I2C Display at %x" msgstr "" @@ -2386,6 +2427,16 @@ msgstr "" msgid "Unhandled ESP TLS error %d %d %x %d" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown BLE error at %s:%d: %d" +msgstr "" + +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown BLE error: %d" +msgstr "" + #: shared-bindings/wifi/Radio.c #, c-format msgid "Unknown failure %d" @@ -2405,11 +2456,21 @@ msgstr "" msgid "Unknown security error: 0x%04x" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error at %s:%d: %d" +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown system firmware error: %04x" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error: %d" +msgstr "" + #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #, c-format msgid "Unmatched number of items on RHS (expected %d, got %d)." @@ -2443,19 +2504,19 @@ msgstr "" msgid "Unsupported operation" msgstr "" -#: shared-bindings/digitalio/DigitalInOut.c -msgid "Unsupported pull value." -msgstr "" - #: ports/espressif/common-hal/dualbank/__init__.c msgid "Update Failed" msgstr "" +#: ports/espressif/common-hal/_bleio/Characteristic.c +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length != required fixed length" msgstr "" +#: ports/espressif/common-hal/_bleio/Characteristic.c +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length > max_length" @@ -2513,6 +2574,7 @@ msgstr "" msgid "Woken up by alarm.\n" msgstr "" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Writes not supported on Characteristic" msgstr "" @@ -2616,7 +2678,7 @@ msgstr "" msgid "attributes not supported yet" msgstr "" -#: extmod/ulab/code/numpy/numerical.c +#: extmod/ulab/code/ulab_tools.c msgid "axis is out of bounds" msgstr "" @@ -2672,11 +2734,11 @@ msgstr "" msgid "branch not in range" msgstr "" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/utils/utils.c msgid "buffer is smaller than requested size" msgstr "" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/utils/utils.c msgid "buffer size must be a multiple of element size" msgstr "" @@ -2726,6 +2788,10 @@ msgstr "" msgid "calibration value out of range +/-127" msgstr "" +#: shared-module/vectorio/Rectangle.c +msgid "can only be registered in one parent" +msgstr "" + #: py/emitinlinethumb.c msgid "can only have up to 4 parameters to Thumb assembly" msgstr "" @@ -2764,6 +2830,10 @@ msgstr "" msgid "can't convert '%q' object to %q implicitly" msgstr "" +#: extmod/ulab/code/numpy/vector.c +msgid "can't convert complex to float" +msgstr "" + #: py/obj.c msgid "can't convert to %q" msgstr "" @@ -2816,6 +2886,10 @@ msgstr "" msgid "can't load with '%q' index" msgstr "" +#: py/builtinimport.c +msgid "can't perform relative import" +msgstr "" + #: py/objgenerator.c msgid "can't send non-None value to a just-started generator" msgstr "" @@ -2858,6 +2932,14 @@ msgstr "" msgid "cannot cast output with casting rule" msgstr "" +#: extmod/ulab/code/ndarray.c +msgid "cannot convert complex to dtype" +msgstr "" + +#: extmod/ulab/code/ndarray.c +msgid "cannot convert complex type" +msgstr "" + #: py/objtype.c msgid "cannot create '%q' instances" msgstr "" @@ -2870,10 +2952,6 @@ msgstr "" msgid "cannot import name %q" msgstr "" -#: py/builtinimport.c -msgid "cannot perform relative import" -msgstr "" - #: extmod/moductypes.c msgid "cannot unambiguously get sizeof scalar" msgstr "" @@ -3049,6 +3127,10 @@ msgstr "" msgid "divisor must be 4" msgstr "" +#: extmod/ulab/code/numpy/vector.c +msgid "dtype must be float, or complex" +msgstr "" + #: py/objdeque.c msgid "empty" msgstr "" @@ -3152,7 +3234,7 @@ msgstr "" msgid "first argument must be a function" msgstr "" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "first argument must be a tuple of ndarrays" msgstr "" @@ -3217,6 +3299,10 @@ msgstr "" msgid "function is defined for ndarrays only" msgstr "" +#: extmod/ulab/code/numpy/carray/carray.c +msgid "function is implemented for ndarrays only" +msgstr "" + #: py/argcheck.c #, c-format msgid "function missing %d required positional arguments" @@ -3330,7 +3416,7 @@ msgstr "" msgid "input and output shapes are not compatible" msgstr "" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "input argument must be an integer, a tuple, or a list" msgstr "" @@ -3338,7 +3424,7 @@ msgstr "" msgid "input array length must be power of 2" msgstr "" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "input arrays are not compatible" msgstr "" @@ -3346,6 +3432,10 @@ msgstr "" msgid "input data must be an iterable" msgstr "" +#: extmod/ulab/code/numpy/vector.c +msgid "input dtype must be float or complex" +msgstr "" + #: extmod/ulab/code/numpy/linalg/linalg.c msgid "input matrix is asymmetric" msgstr "" @@ -3355,18 +3445,26 @@ msgstr "" msgid "input matrix is singular" msgstr "" +#: extmod/ulab/code/numpy/carray/carray.c +msgid "input must be a 1D ndarray" +msgstr "" + #: extmod/ulab/code/scipy/linalg/linalg.c extmod/ulab/code/user/user.c msgid "input must be a dense ndarray" msgstr "" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "input must be a tensor of rank 2" msgstr "" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/user/user.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/user/user.c msgid "input must be an ndarray" msgstr "" +#: extmod/ulab/code/numpy/carray/carray.c +msgid "input must be an ndarray, or a scalar" +msgstr "" + #: extmod/ulab/code/scipy/signal/signal.c msgid "input must be one-dimensional" msgstr "" @@ -3544,6 +3642,11 @@ msgstr "" msgid "matrix is not positive definite" msgstr "" +#: ports/espressif/common-hal/wifi/Radio.c +msgid "max_connections must be between 0 and 10" +msgstr "" + +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c #, c-format @@ -3697,6 +3800,7 @@ msgstr "" msgid "non-Device in %q" msgstr "" +#: ports/espressif/common-hal/_bleio/Connection.c #: ports/nrf/common-hal/_bleio/Connection.c msgid "non-UUID found in service_uuids_whitelist" msgstr "" @@ -3737,7 +3841,11 @@ msgstr "" msgid "not enough arguments for format string" msgstr "" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/carray/carray_tools.c +msgid "not implemented for complex dtype" +msgstr "" + +#: extmod/ulab/code/numpy/create.c msgid "number of points must be at least 2" msgstr "" @@ -3795,7 +3903,7 @@ msgstr "" msgid "odd-length string" msgstr "" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/utils/utils.c msgid "offset is too large" msgstr "" @@ -3803,7 +3911,7 @@ msgstr "" msgid "offset must be >= 0" msgstr "" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "offset must be non-negative and no greater than buffer length" msgstr "" @@ -3915,6 +4023,10 @@ msgstr "" msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "" +#: extmod/vfs_posix_file.c +msgid "poll on file not available on win32" +msgstr "" + #: shared-module/vectorio/Polygon.c msgid "polygon can only be registered in one parent" msgstr "" @@ -3944,18 +4056,27 @@ msgstr "" msgid "pow() with 3 arguments requires integers" msgstr "" +#: ports/espressif/boards/adafruit_esp32s2_camera/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tft/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h #: ports/espressif/boards/adafruit_funhouse/mpconfigboard.h #: ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h +#: ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h +#: ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h #: ports/espressif/boards/atmegazero_esp32s2/mpconfigboard.h #: ports/espressif/boards/crumpspace_crumps2/mpconfigboard.h #: ports/espressif/boards/electroniccats_bastwifi/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s2_devkitc_1_n4r2/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_box/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h #: ports/espressif/boards/espressif_hmi_devkit_1/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1.3/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1/mpconfigboard.h @@ -3981,7 +4102,10 @@ msgstr "" #: ports/espressif/boards/unexpectedmaker_feathers2/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_neo/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_prerelease/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_feathers3/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_pros3/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_tinys2/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_tinys3/mpconfigboard.h msgid "pressing boot button at start up.\n" msgstr "" @@ -4278,7 +4402,7 @@ msgstr "" msgid "too many arguments provided with the given format" msgstr "" -#: extmod/ulab/code/ndarray.c extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/ndarray.c extmod/ulab/code/numpy/create.c msgid "too many dimensions" msgstr "" @@ -4462,7 +4586,7 @@ msgstr "" msgid "width must be from 2 to 8 (inclusive), not %d" msgstr "" -#: shared-bindings/is31fl3741/is31fl3741.c +#: shared-bindings/is31fl3741/FrameBuffer.c #: shared-bindings/rgbmatrix/RGBMatrix.c msgid "width must be greater than zero" msgstr "" @@ -4479,7 +4603,7 @@ msgstr "" msgid "wrong axis index" msgstr "" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "wrong axis specified" msgstr "" @@ -4487,7 +4611,11 @@ msgstr "" msgid "wrong input type" msgstr "" -#: extmod/ulab/code/ulab_create.c py/objarray.c py/objstr.c +#: extmod/ulab/code/numpy/transform.c +msgid "wrong length of condition array" +msgstr "" + +#: extmod/ulab/code/numpy/create.c py/objarray.c py/objstr.c msgid "wrong number of arguments" msgstr "" diff --git a/locale/it_IT.po b/locale/it_IT.po index 0f57f5ba80..aada2ef9fa 100644 --- a/locale/it_IT.po +++ b/locale/it_IT.po @@ -108,7 +108,7 @@ msgstr "gli indici %q devono essere interi, non %s" msgid "%q length must be %d-%d" msgstr "" -#: shared-bindings/usb_hid/Device.c +#: shared-bindings/busio/I2C.c shared-bindings/usb_hid/Device.c msgid "%q length must be >= 1" msgstr "" @@ -154,6 +154,10 @@ msgstr "" msgid "%q must be of type %q" msgstr "" +#: shared-bindings/digitalio/Pull.c +msgid "%q must be of type %q or None" +msgstr "" + #: ports/atmel-samd/common-hal/busio/UART.c msgid "%q must be power of 2" msgstr "" @@ -454,6 +458,7 @@ msgstr "Tutti i timer per questo pin sono in uso" msgid "All timers in use" msgstr "Tutti i timer utilizzati" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Already advertising." msgstr "" @@ -589,7 +594,7 @@ msgstr "Entrambi i pin devono supportare gli interrupt hardware" #: shared-bindings/displayio/Display.c #: shared-bindings/framebufferio/FramebufferDisplay.c -#: shared-bindings/is31fl3741/is31fl3741.c +#: shared-bindings/is31fl3741/FrameBuffer.c #: shared-bindings/rgbmatrix/RGBMatrix.c msgid "Brightness must be 0-1.0" msgstr "La luminosità deve essere tra 0-1.0" @@ -641,7 +646,7 @@ msgstr "La lunghezza del buffer deve essere un multiplo di 512" msgid "Buffer must be a multiple of 512 bytes" msgstr "Il buffer deve essere un multiplo di 512 bytes" -#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c +#: shared-bindings/bitbangio/I2C.c msgid "Buffer must be at least length 1" msgstr "Il buffer deve essere lungo almeno 1" @@ -674,6 +679,10 @@ msgstr "I byte devono essere compresi tra 0 e 255." msgid "CBC blocks must be multiples of 16 bytes" msgstr "I blocchi CBC devono essere multipli di 16 bytes" +#: supervisor/shared/safe_mode.c +msgid "CIRCUITPY drive could not be found or created." +msgstr "" + #: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c msgid "CRC or checksum was invalid" msgstr "CRC o controllo totale è risultato non valido" @@ -919,10 +928,12 @@ msgstr "graphic deve essere lunga 2048 byte" msgid "Data chunk must follow fmt chunk" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data not supported with directed advertising" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c #, fuzzy msgid "Data too large for advertisement packet" @@ -1004,6 +1015,7 @@ msgstr "" msgid "Expected tuple of length %d, got %d" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Extended advertisements with scan response not supported." msgstr "" @@ -1057,6 +1069,7 @@ msgstr "" msgid "Failed to buffer the sample" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Failed to connect: internal error" msgstr "" @@ -1136,6 +1149,13 @@ msgstr "" msgid "Group already used" msgstr "" +#: ports/atmel-samd/common-hal/busio/SPI.c ports/cxd56/common-hal/busio/SPI.c +#: ports/espressif/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/nrf/common-hal/busio/SPI.c +#: ports/raspberrypi/common-hal/busio/SPI.c +msgid "Half duplex SPI is not implemented" +msgstr "" + #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/I2C.c #: ports/stm/common-hal/busio/SPI.c ports/stm/common-hal/canio/CAN.c #: ports/stm/common-hal/sdioio/SDCard.c @@ -1290,6 +1310,7 @@ msgstr "" msgid "Invalid AuthMode" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c msgid "Invalid BLE parameter" msgstr "" @@ -1386,6 +1407,10 @@ msgstr "" msgid "Invalid memory access." msgstr "" +#: extmod/vfs_fat_file.c +msgid "Invalid mode" +msgstr "" + #: ports/espressif/common-hal/wifi/Radio.c msgid "Invalid multicast MAC address" msgstr "" @@ -1487,7 +1512,7 @@ msgstr "" msgid "Key must be 16, 24, or 32 bytes long" msgstr "" -#: shared-module/is31fl3741/is31fl3741.c +#: shared-module/is31fl3741/FrameBuffer.c msgid "LED mappings must match display size" msgstr "" @@ -1515,6 +1540,10 @@ msgstr "inizializzazione del pin MISO fallita." msgid "MOSI pin init failed." msgstr "inizializzazione del pin MOSI fallita." +#: shared-bindings/is31fl3741/IS31FL3741.c +msgid "Mapping must be a tuple" +msgstr "" + #: shared-module/displayio/Shape.c #, c-format msgid "Maximum x value when mirrored is %d" @@ -1598,6 +1627,10 @@ msgstr "" msgid "Name too long" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +msgid "Nimble out of memory" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "" @@ -1618,9 +1651,9 @@ msgstr "Nessun canale DMA trovato" msgid "No DMA pacing timer found" msgstr "" -#: shared-module/adafruit_bus_device/I2CDevice.c +#: shared-module/adafruit_bus_device/i2c_device/I2CDevice.c #, c-format -msgid "No I2C device at address: %x" +msgid "No I2C device at address: 0x%x" msgstr "" #: ports/espressif/common-hal/busio/SPI.c @@ -1745,6 +1778,7 @@ msgstr "" msgid "Not a valid IP string" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c #, fuzzy @@ -1927,7 +1961,7 @@ msgstr "Il pin non ha capacità di ADC" msgid "Pin interrupt already in use" msgstr "" -#: shared-bindings/adafruit_bus_device/SPIDevice.c +#: shared-bindings/adafruit_bus_device/spi_device/SPIDevice.c #: shared-bindings/digitalio/DigitalInOut.c msgid "Pin is input only" msgstr "" @@ -2010,6 +2044,10 @@ msgstr "" msgid "RAISE mode is not implemented" msgstr "" +#: ports/raspberrypi/common-hal/countio/Counter.c +msgid "RISE_AND_FALL not available on this chip" +msgstr "" + #: ports/stm/common-hal/os/__init__.c msgid "RNG DeInit Error" msgstr "" @@ -2129,10 +2167,11 @@ msgid "Sample rate too high. It must be less than %d" msgstr "" "Frequenza di campionamento troppo alta. Il valore deve essere inferiore a %d" -#: shared-bindings/is31fl3741/is31fl3741.c +#: shared-bindings/is31fl3741/FrameBuffer.c msgid "Scale dimensions must divide by 3" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Scan already in progess. Stop with stop_scan." msgstr "" @@ -2291,6 +2330,7 @@ msgstr "" msgid "Time is in the past." msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2313,6 +2353,7 @@ msgstr "" msgid "Too many displays" msgstr "Troppi schermi" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Total data to write is larger than %q" msgstr "" @@ -2390,7 +2431,7 @@ msgstr "Ipossibilitato ad allocare buffer per la conversione con segno" msgid "Unable to create lock" msgstr "" -#: shared-module/displayio/I2CDisplay.c shared-module/is31fl3741/is31fl3741.c +#: shared-module/displayio/I2CDisplay.c shared-module/is31fl3741/IS31FL3741.c #, c-format msgid "Unable to find I2C Display at %x" msgstr "" @@ -2426,6 +2467,16 @@ msgstr "indentazione inaspettata" msgid "Unhandled ESP TLS error %d %d %x %d" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown BLE error at %s:%d: %d" +msgstr "" + +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown BLE error: %d" +msgstr "" + #: shared-bindings/wifi/Radio.c #, c-format msgid "Unknown failure %d" @@ -2445,11 +2496,21 @@ msgstr "" msgid "Unknown security error: 0x%04x" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error at %s:%d: %d" +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown system firmware error: %04x" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error: %d" +msgstr "" + #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #, c-format msgid "Unmatched number of items on RHS (expected %d, got %d)." @@ -2484,19 +2545,19 @@ msgstr "Formato non supportato" msgid "Unsupported operation" msgstr "Operazione non supportata" -#: shared-bindings/digitalio/DigitalInOut.c -msgid "Unsupported pull value." -msgstr "Valore di pull non supportato." - #: ports/espressif/common-hal/dualbank/__init__.c msgid "Update Failed" msgstr "" +#: ports/espressif/common-hal/_bleio/Characteristic.c +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length != required fixed length" msgstr "" +#: ports/espressif/common-hal/_bleio/Characteristic.c +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length > max_length" @@ -2554,6 +2615,7 @@ msgstr "" msgid "Woken up by alarm.\n" msgstr "" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Writes not supported on Characteristic" msgstr "" @@ -2657,7 +2719,7 @@ msgstr "" msgid "attributes not supported yet" msgstr "attributi non ancora supportati" -#: extmod/ulab/code/numpy/numerical.c +#: extmod/ulab/code/ulab_tools.c msgid "axis is out of bounds" msgstr "" @@ -2715,11 +2777,11 @@ msgstr "i bit devono essere 7, 8 o 9" msgid "branch not in range" msgstr "argomento di chr() non è in range(256)" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/utils/utils.c msgid "buffer is smaller than requested size" msgstr "" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/utils/utils.c msgid "buffer size must be a multiple of element size" msgstr "" @@ -2770,6 +2832,10 @@ msgstr "la calibrazione è in sola lettura" msgid "calibration value out of range +/-127" msgstr "valore di calibrazione fuori intervallo +/-127" +#: shared-module/vectorio/Rectangle.c +msgid "can only be registered in one parent" +msgstr "" + #: py/emitinlinethumb.c #, fuzzy msgid "can only have up to 4 parameters to Thumb assembly" @@ -2809,6 +2875,10 @@ msgstr "non è possibile convertire a complex" msgid "can't convert '%q' object to %q implicitly" msgstr "impossibile convertire l'oggetto '%q' implicitamente in %q" +#: extmod/ulab/code/numpy/vector.c +msgid "can't convert complex to float" +msgstr "" + #: py/obj.c msgid "can't convert to %q" msgstr "" @@ -2861,6 +2931,10 @@ msgstr "impossibile caricare da '%q'" msgid "can't load with '%q' index" msgstr "impossibile caricare con indice '%q'" +#: py/builtinimport.c +msgid "can't perform relative import" +msgstr "" + #: py/objgenerator.c msgid "can't send non-None value to a just-started generator" msgstr "" @@ -2903,6 +2977,14 @@ msgstr "" msgid "cannot cast output with casting rule" msgstr "" +#: extmod/ulab/code/ndarray.c +msgid "cannot convert complex to dtype" +msgstr "" + +#: extmod/ulab/code/ndarray.c +msgid "cannot convert complex type" +msgstr "" + #: py/objtype.c msgid "cannot create '%q' instances" msgstr "creare '%q' istanze" @@ -2915,10 +2997,6 @@ msgstr "impossibile creare un istanza" msgid "cannot import name %q" msgstr "impossibile imporate il nome %q" -#: py/builtinimport.c -msgid "cannot perform relative import" -msgstr "impossibile effettuare l'importazione relativa" - #: extmod/moductypes.c msgid "cannot unambiguously get sizeof scalar" msgstr "" @@ -3099,6 +3177,10 @@ msgstr "divisione per zero" msgid "divisor must be 4" msgstr "" +#: extmod/ulab/code/numpy/vector.c +msgid "dtype must be float, or complex" +msgstr "" + #: py/objdeque.c msgid "empty" msgstr "vuoto" @@ -3203,7 +3285,7 @@ msgstr "" msgid "first argument must be a function" msgstr "" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "first argument must be a tuple of ndarrays" msgstr "" @@ -3268,6 +3350,10 @@ msgstr "" msgid "function is defined for ndarrays only" msgstr "" +#: extmod/ulab/code/numpy/carray/carray.c +msgid "function is implemented for ndarrays only" +msgstr "" + #: py/argcheck.c #, c-format msgid "function missing %d required positional arguments" @@ -3382,7 +3468,7 @@ msgstr "inline assembler deve essere una funzione" msgid "input and output shapes are not compatible" msgstr "" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "input argument must be an integer, a tuple, or a list" msgstr "" @@ -3390,7 +3476,7 @@ msgstr "" msgid "input array length must be power of 2" msgstr "" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "input arrays are not compatible" msgstr "" @@ -3398,6 +3484,10 @@ msgstr "" msgid "input data must be an iterable" msgstr "" +#: extmod/ulab/code/numpy/vector.c +msgid "input dtype must be float or complex" +msgstr "" + #: extmod/ulab/code/numpy/linalg/linalg.c msgid "input matrix is asymmetric" msgstr "" @@ -3407,18 +3497,26 @@ msgstr "" msgid "input matrix is singular" msgstr "" +#: extmod/ulab/code/numpy/carray/carray.c +msgid "input must be a 1D ndarray" +msgstr "" + #: extmod/ulab/code/scipy/linalg/linalg.c extmod/ulab/code/user/user.c msgid "input must be a dense ndarray" msgstr "" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "input must be a tensor of rank 2" msgstr "" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/user/user.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/user/user.c msgid "input must be an ndarray" msgstr "" +#: extmod/ulab/code/numpy/carray/carray.c +msgid "input must be an ndarray, or a scalar" +msgstr "" + #: extmod/ulab/code/scipy/signal/signal.c msgid "input must be one-dimensional" msgstr "" @@ -3601,6 +3699,11 @@ msgstr "errore di dominio matematico" msgid "matrix is not positive definite" msgstr "" +#: ports/espressif/common-hal/wifi/Radio.c +msgid "max_connections must be between 0 and 10" +msgstr "" + +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c #, c-format @@ -3754,6 +3857,7 @@ msgstr "attributo inesistente" msgid "non-Device in %q" msgstr "" +#: ports/espressif/common-hal/_bleio/Connection.c #: ports/nrf/common-hal/_bleio/Connection.c msgid "non-UUID found in service_uuids_whitelist" msgstr "" @@ -3796,7 +3900,11 @@ msgstr "" msgid "not enough arguments for format string" msgstr "argomenti non sufficienti per la stringa di formattazione" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/carray/carray_tools.c +msgid "not implemented for complex dtype" +msgstr "" + +#: extmod/ulab/code/numpy/create.c msgid "number of points must be at least 2" msgstr "" @@ -3854,7 +3962,7 @@ msgstr "" msgid "odd-length string" msgstr "stringa di lunghezza dispari" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/utils/utils.c msgid "offset is too large" msgstr "" @@ -3862,7 +3970,7 @@ msgstr "" msgid "offset must be >= 0" msgstr "" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "offset must be non-negative and no greater than buffer length" msgstr "" @@ -3978,6 +4086,10 @@ msgstr "" msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "pixel_shader deve essere displayio.Palette o displayio.ColorConverter" +#: extmod/vfs_posix_file.c +msgid "poll on file not available on win32" +msgstr "" + #: shared-module/vectorio/Polygon.c msgid "polygon can only be registered in one parent" msgstr "" @@ -4007,18 +4119,27 @@ msgstr "il terzo argomento di pow() non può essere 0" msgid "pow() with 3 arguments requires integers" msgstr "pow() con 3 argomenti richiede interi" +#: ports/espressif/boards/adafruit_esp32s2_camera/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tft/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h #: ports/espressif/boards/adafruit_funhouse/mpconfigboard.h #: ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h +#: ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h +#: ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h #: ports/espressif/boards/atmegazero_esp32s2/mpconfigboard.h #: ports/espressif/boards/crumpspace_crumps2/mpconfigboard.h #: ports/espressif/boards/electroniccats_bastwifi/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s2_devkitc_1_n4r2/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_box/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h #: ports/espressif/boards/espressif_hmi_devkit_1/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1.3/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1/mpconfigboard.h @@ -4044,7 +4165,10 @@ msgstr "pow() con 3 argomenti richiede interi" #: ports/espressif/boards/unexpectedmaker_feathers2/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_neo/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_prerelease/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_feathers3/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_pros3/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_tinys2/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_tinys3/mpconfigboard.h msgid "pressing boot button at start up.\n" msgstr "" @@ -4345,7 +4469,7 @@ msgstr "" msgid "too many arguments provided with the given format" msgstr "troppi argomenti forniti con il formato specificato" -#: extmod/ulab/code/ndarray.c extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/ndarray.c extmod/ulab/code/numpy/create.c msgid "too many dimensions" msgstr "" @@ -4529,7 +4653,7 @@ msgstr "" msgid "width must be from 2 to 8 (inclusive), not %d" msgstr "" -#: shared-bindings/is31fl3741/is31fl3741.c +#: shared-bindings/is31fl3741/FrameBuffer.c #: shared-bindings/rgbmatrix/RGBMatrix.c msgid "width must be greater than zero" msgstr "" @@ -4546,7 +4670,7 @@ msgstr "" msgid "wrong axis index" msgstr "" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "wrong axis specified" msgstr "" @@ -4554,7 +4678,11 @@ msgstr "" msgid "wrong input type" msgstr "" -#: extmod/ulab/code/ulab_create.c py/objarray.c py/objstr.c +#: extmod/ulab/code/numpy/transform.c +msgid "wrong length of condition array" +msgstr "" + +#: extmod/ulab/code/numpy/create.c py/objarray.c py/objstr.c msgid "wrong number of arguments" msgstr "numero di argomenti errato" @@ -4600,6 +4728,12 @@ msgstr "" msgid "zi must be of shape (n_section, 2)" msgstr "" +#~ msgid "cannot perform relative import" +#~ msgstr "impossibile effettuare l'importazione relativa" + +#~ msgid "Unsupported pull value." +#~ msgstr "Valore di pull non supportato." + #~ msgid "integer required" #~ msgstr "intero richiesto" diff --git a/locale/ja.po b/locale/ja.po index 5c76879f82..b35e3a22c0 100644 --- a/locale/ja.po +++ b/locale/ja.po @@ -104,7 +104,7 @@ msgstr "" msgid "%q length must be %d-%d" msgstr "" -#: shared-bindings/usb_hid/Device.c +#: shared-bindings/busio/I2C.c shared-bindings/usb_hid/Device.c msgid "%q length must be >= 1" msgstr "" @@ -149,6 +149,10 @@ msgstr "" msgid "%q must be of type %q" msgstr "" +#: shared-bindings/digitalio/Pull.c +msgid "%q must be of type %q or None" +msgstr "" + #: ports/atmel-samd/common-hal/busio/UART.c msgid "%q must be power of 2" msgstr "" @@ -447,6 +451,7 @@ msgstr "このピン用の全てのタイマが使用中" msgid "All timers in use" msgstr "全てのタイマーが使用中" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Already advertising." msgstr "すでにアドバータイズ中" @@ -581,7 +586,7 @@ msgstr "両方のピンにハードウェア割り込み対応が必要" #: shared-bindings/displayio/Display.c #: shared-bindings/framebufferio/FramebufferDisplay.c -#: shared-bindings/is31fl3741/is31fl3741.c +#: shared-bindings/is31fl3741/FrameBuffer.c #: shared-bindings/rgbmatrix/RGBMatrix.c msgid "Brightness must be 0-1.0" msgstr "brightnessは0から1.0まででなければなりません" @@ -633,7 +638,7 @@ msgstr "バッファ長は512の倍数でなければなりません" msgid "Buffer must be a multiple of 512 bytes" msgstr "バッファは512の倍数でなければなりません" -#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c +#: shared-bindings/bitbangio/I2C.c msgid "Buffer must be at least length 1" msgstr "バッファ長は少なくとも1以上でなければなりません" @@ -666,6 +671,10 @@ msgstr "バイト値は0から255の間でなければなりません" msgid "CBC blocks must be multiples of 16 bytes" msgstr "CBCブロックは16バイトの整数倍でなければなりません" +#: supervisor/shared/safe_mode.c +msgid "CIRCUITPY drive could not be found or created." +msgstr "" + #: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c msgid "CRC or checksum was invalid" msgstr "" @@ -909,10 +918,12 @@ msgstr "Data 0 ピンは、バイト整列されていなければなりませ msgid "Data chunk must follow fmt chunk" msgstr "fmtチャンクの後にdataチャンクが続かなければなりません" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data not supported with directed advertising" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data too large for advertisement packet" msgstr "データが、アドバタイズメントパケットには大きすぎます" @@ -993,6 +1004,7 @@ msgstr "" msgid "Expected tuple of length %d, got %d" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Extended advertisements with scan response not supported." msgstr "" @@ -1046,6 +1058,7 @@ msgstr "" msgid "Failed to buffer the sample" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Failed to connect: internal error" msgstr "接続失敗: 内部エラー" @@ -1125,6 +1138,13 @@ msgstr "" msgid "Group already used" msgstr "グループはすでに使われています" +#: ports/atmel-samd/common-hal/busio/SPI.c ports/cxd56/common-hal/busio/SPI.c +#: ports/espressif/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/nrf/common-hal/busio/SPI.c +#: ports/raspberrypi/common-hal/busio/SPI.c +msgid "Half duplex SPI is not implemented" +msgstr "" + #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/I2C.c #: ports/stm/common-hal/busio/SPI.c ports/stm/common-hal/canio/CAN.c #: ports/stm/common-hal/sdioio/SDCard.c @@ -1279,6 +1299,7 @@ msgstr "不正なADCユニット値" msgid "Invalid AuthMode" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c msgid "Invalid BLE parameter" msgstr "" @@ -1373,6 +1394,10 @@ msgstr "フォーマットチャンクのサイズが不正" msgid "Invalid memory access." msgstr "不正なメモリアクセス" +#: extmod/vfs_fat_file.c +msgid "Invalid mode" +msgstr "" + #: ports/espressif/common-hal/wifi/Radio.c msgid "Invalid multicast MAC address" msgstr "" @@ -1473,7 +1498,7 @@ msgstr "不正なワード/ビット長" msgid "Key must be 16, 24, or 32 bytes long" msgstr "Keyの長さは、16, 24, 32バイトのいずれかでなければなりません" -#: shared-module/is31fl3741/is31fl3741.c +#: shared-module/is31fl3741/FrameBuffer.c msgid "LED mappings must match display size" msgstr "" @@ -1501,6 +1526,10 @@ msgstr "MISOピン初期化に失敗" msgid "MOSI pin init failed." msgstr "MOSIピン初期化に失敗" +#: shared-bindings/is31fl3741/IS31FL3741.c +msgid "Mapping must be a tuple" +msgstr "" + #: shared-module/displayio/Shape.c #, c-format msgid "Maximum x value when mirrored is %d" @@ -1583,6 +1612,10 @@ msgstr "" msgid "Name too long" msgstr "名前が長すぎます" +#: ports/espressif/common-hal/_bleio/__init__.c +msgid "Nimble out of memory" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "" @@ -1603,9 +1636,9 @@ msgstr "DMAチャネルが見つかりません" msgid "No DMA pacing timer found" msgstr "" -#: shared-module/adafruit_bus_device/I2CDevice.c +#: shared-module/adafruit_bus_device/i2c_device/I2CDevice.c #, c-format -msgid "No I2C device at address: %x" +msgid "No I2C device at address: 0x%x" msgstr "" #: ports/espressif/common-hal/busio/SPI.c @@ -1730,6 +1763,7 @@ msgstr "" msgid "Not a valid IP string" msgstr "不正なIP文字列です" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -1906,7 +1940,7 @@ msgstr "ピンにADCの能力がありません" msgid "Pin interrupt already in use" msgstr "" -#: shared-bindings/adafruit_bus_device/SPIDevice.c +#: shared-bindings/adafruit_bus_device/spi_device/SPIDevice.c #: shared-bindings/digitalio/DigitalInOut.c msgid "Pin is input only" msgstr "ピンは入力専用" @@ -1988,6 +2022,10 @@ msgstr "方向がoutputのときpullは使われません" msgid "RAISE mode is not implemented" msgstr "" +#: ports/raspberrypi/common-hal/countio/Counter.c +msgid "RISE_AND_FALL not available on this chip" +msgstr "" + #: ports/stm/common-hal/os/__init__.c msgid "RNG DeInit Error" msgstr "RNG解体エラー" @@ -2104,10 +2142,11 @@ msgstr "サンプルレートは正数でなければなりません" msgid "Sample rate too high. It must be less than %d" msgstr "サンプルレートは%d以下でなければなりません" -#: shared-bindings/is31fl3741/is31fl3741.c +#: shared-bindings/is31fl3741/FrameBuffer.c msgid "Scale dimensions must divide by 3" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Scan already in progess. Stop with stop_scan." msgstr "既にスキャン進行中。stop_scanで停止してください" @@ -2266,6 +2305,7 @@ msgstr "タイルの幅はビットマップの幅を割り切れる値でなけ msgid "Time is in the past." msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2288,6 +2328,7 @@ msgstr "" msgid "Too many displays" msgstr "" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Total data to write is larger than %q" msgstr "" @@ -2366,7 +2407,7 @@ msgstr "" msgid "Unable to create lock" msgstr "" -#: shared-module/displayio/I2CDisplay.c shared-module/is31fl3741/is31fl3741.c +#: shared-module/displayio/I2CDisplay.c shared-module/is31fl3741/IS31FL3741.c #, c-format msgid "Unable to find I2C Display at %x" msgstr "I2Cディスプレイを %x に見つけられません" @@ -2401,6 +2442,16 @@ msgstr "想定されていないnrfx UUID型" msgid "Unhandled ESP TLS error %d %d %x %d" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown BLE error at %s:%d: %d" +msgstr "" + +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown BLE error: %d" +msgstr "" + #: shared-bindings/wifi/Radio.c #, c-format msgid "Unknown failure %d" @@ -2420,11 +2471,21 @@ msgstr "理由不明" msgid "Unknown security error: 0x%04x" msgstr "不明なセキュリティエラー: 0x%04x" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error at %s:%d: %d" +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown system firmware error: %04x" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error: %d" +msgstr "" + #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #, c-format msgid "Unmatched number of items on RHS (expected %d, got %d)." @@ -2458,19 +2519,19 @@ msgstr "非対応の形式" msgid "Unsupported operation" msgstr "非対応の操作" -#: shared-bindings/digitalio/DigitalInOut.c -msgid "Unsupported pull value." -msgstr "非対応のpull値" - #: ports/espressif/common-hal/dualbank/__init__.c msgid "Update Failed" msgstr "" +#: ports/espressif/common-hal/_bleio/Characteristic.c +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length != required fixed length" msgstr "" +#: ports/espressif/common-hal/_bleio/Characteristic.c +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length > max_length" @@ -2528,6 +2589,7 @@ msgstr "WiFiパスワードは8〜63文字でなければなりません" msgid "Woken up by alarm.\n" msgstr "" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Writes not supported on Characteristic" msgstr "" @@ -2631,7 +2693,7 @@ msgstr "" msgid "attributes not supported yet" msgstr "属性は未対応です" -#: extmod/ulab/code/numpy/numerical.c +#: extmod/ulab/code/ulab_tools.c msgid "axis is out of bounds" msgstr "" @@ -2687,11 +2749,11 @@ msgstr "bits_per_sampleは8または16でなければなりません" msgid "branch not in range" msgstr "" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/utils/utils.c msgid "buffer is smaller than requested size" msgstr "" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/utils/utils.c msgid "buffer size must be a multiple of element size" msgstr "" @@ -2741,6 +2803,10 @@ msgstr "calibrationは読み込み専用" msgid "calibration value out of range +/-127" msgstr "" +#: shared-module/vectorio/Rectangle.c +msgid "can only be registered in one parent" +msgstr "" + #: py/emitinlinethumb.c msgid "can only have up to 4 parameters to Thumb assembly" msgstr "" @@ -2779,6 +2845,10 @@ msgstr "" msgid "can't convert '%q' object to %q implicitly" msgstr "オブジェクト '%q' を %q に暗黙に変換できません" +#: extmod/ulab/code/numpy/vector.c +msgid "can't convert complex to float" +msgstr "" + #: py/obj.c msgid "can't convert to %q" msgstr "%q に変換できません" @@ -2831,6 +2901,10 @@ msgstr "" msgid "can't load with '%q' index" msgstr "" +#: py/builtinimport.c +msgid "can't perform relative import" +msgstr "" + #: py/objgenerator.c msgid "can't send non-None value to a just-started generator" msgstr "" @@ -2873,6 +2947,14 @@ msgstr "" msgid "cannot cast output with casting rule" msgstr "" +#: extmod/ulab/code/ndarray.c +msgid "cannot convert complex to dtype" +msgstr "" + +#: extmod/ulab/code/ndarray.c +msgid "cannot convert complex type" +msgstr "" + #: py/objtype.c msgid "cannot create '%q' instances" msgstr "" @@ -2885,10 +2967,6 @@ msgstr "インスタンスを作れません" msgid "cannot import name %q" msgstr "" -#: py/builtinimport.c -msgid "cannot perform relative import" -msgstr "相対インポートはできません" - #: extmod/moductypes.c msgid "cannot unambiguously get sizeof scalar" msgstr "" @@ -3068,6 +3146,10 @@ msgstr "ゼロ除算 (division by zero)" msgid "divisor must be 4" msgstr "" +#: extmod/ulab/code/numpy/vector.c +msgid "dtype must be float, or complex" +msgstr "" + #: py/objdeque.c msgid "empty" msgstr "" @@ -3171,7 +3253,7 @@ msgstr "1つ目の引数は呼び出し可能でなければなりません" msgid "first argument must be a function" msgstr "1つ目の引数は関数でなければなりません" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "first argument must be a tuple of ndarrays" msgstr "" @@ -3236,6 +3318,10 @@ msgstr "" msgid "function is defined for ndarrays only" msgstr "" +#: extmod/ulab/code/numpy/carray/carray.c +msgid "function is implemented for ndarrays only" +msgstr "" + #: py/argcheck.c #, c-format msgid "function missing %d required positional arguments" @@ -3350,7 +3436,7 @@ msgstr "インラインアセンブラは関数でなければなりません" msgid "input and output shapes are not compatible" msgstr "" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "input argument must be an integer, a tuple, or a list" msgstr "" @@ -3358,7 +3444,7 @@ msgstr "" msgid "input array length must be power of 2" msgstr "入力array長は2の累乗でなければなりません" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "input arrays are not compatible" msgstr "" @@ -3366,6 +3452,10 @@ msgstr "" msgid "input data must be an iterable" msgstr "" +#: extmod/ulab/code/numpy/vector.c +msgid "input dtype must be float or complex" +msgstr "" + #: extmod/ulab/code/numpy/linalg/linalg.c msgid "input matrix is asymmetric" msgstr "入力行列が非対称" @@ -3375,18 +3465,26 @@ msgstr "入力行列が非対称" msgid "input matrix is singular" msgstr "入力が非正則行列" +#: extmod/ulab/code/numpy/carray/carray.c +msgid "input must be a 1D ndarray" +msgstr "" + #: extmod/ulab/code/scipy/linalg/linalg.c extmod/ulab/code/user/user.c msgid "input must be a dense ndarray" msgstr "" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "input must be a tensor of rank 2" msgstr "" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/user/user.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/user/user.c msgid "input must be an ndarray" msgstr "" +#: extmod/ulab/code/numpy/carray/carray.c +msgid "input must be an ndarray, or a scalar" +msgstr "" + #: extmod/ulab/code/scipy/signal/signal.c msgid "input must be one-dimensional" msgstr "" @@ -3564,6 +3662,11 @@ msgstr "定義域エラー" msgid "matrix is not positive definite" msgstr "正定値行列ではありません" +#: ports/espressif/common-hal/wifi/Radio.c +msgid "max_connections must be between 0 and 10" +msgstr "" + +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c #, c-format @@ -3717,6 +3820,7 @@ msgstr "指定の属性はありません" msgid "non-Device in %q" msgstr "" +#: ports/espressif/common-hal/_bleio/Connection.c #: ports/nrf/common-hal/_bleio/Connection.c msgid "non-UUID found in service_uuids_whitelist" msgstr "" @@ -3757,7 +3861,11 @@ msgstr "文字列書式化で全ての引数が使われていません" msgid "not enough arguments for format string" msgstr "書式化文字列への引数が足りません" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/carray/carray_tools.c +msgid "not implemented for complex dtype" +msgstr "" + +#: extmod/ulab/code/numpy/create.c msgid "number of points must be at least 2" msgstr "" @@ -3815,7 +3923,7 @@ msgstr "" msgid "odd-length string" msgstr "奇数長の文字列" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/utils/utils.c msgid "offset is too large" msgstr "" @@ -3823,7 +3931,7 @@ msgstr "" msgid "offset must be >= 0" msgstr "" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "offset must be non-negative and no greater than buffer length" msgstr "" @@ -3937,6 +4045,10 @@ msgstr "" "pixel_shaderはdisplayio.Paletteかdisplayio.ColorConverterのどちらかでなければ" "なりません" +#: extmod/vfs_posix_file.c +msgid "poll on file not available on win32" +msgstr "" + #: shared-module/vectorio/Polygon.c msgid "polygon can only be registered in one parent" msgstr "" @@ -3966,18 +4078,27 @@ msgstr "pow()の3つ目の引数は0にできません" msgid "pow() with 3 arguments requires integers" msgstr "pow()の第3引数には整数が必要" +#: ports/espressif/boards/adafruit_esp32s2_camera/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tft/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h #: ports/espressif/boards/adafruit_funhouse/mpconfigboard.h #: ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h +#: ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h +#: ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h #: ports/espressif/boards/atmegazero_esp32s2/mpconfigboard.h #: ports/espressif/boards/crumpspace_crumps2/mpconfigboard.h #: ports/espressif/boards/electroniccats_bastwifi/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s2_devkitc_1_n4r2/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_box/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h #: ports/espressif/boards/espressif_hmi_devkit_1/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1.3/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1/mpconfigboard.h @@ -4003,7 +4124,10 @@ msgstr "pow()の第3引数には整数が必要" #: ports/espressif/boards/unexpectedmaker_feathers2/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_neo/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_prerelease/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_feathers3/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_pros3/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_tinys2/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_tinys3/mpconfigboard.h msgid "pressing boot button at start up.\n" msgstr "" @@ -4301,7 +4425,7 @@ msgstr "" msgid "too many arguments provided with the given format" msgstr "指定された書式に対して引数が多すぎます" -#: extmod/ulab/code/ndarray.c extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/ndarray.c extmod/ulab/code/numpy/create.c msgid "too many dimensions" msgstr "" @@ -4485,7 +4609,7 @@ msgstr "watchdogのtimeoutは0以上でなければなりません" msgid "width must be from 2 to 8 (inclusive), not %d" msgstr "" -#: shared-bindings/is31fl3741/is31fl3741.c +#: shared-bindings/is31fl3741/FrameBuffer.c #: shared-bindings/rgbmatrix/RGBMatrix.c msgid "width must be greater than zero" msgstr "" @@ -4502,7 +4626,7 @@ msgstr "windowはinterval以下でなければなりません" msgid "wrong axis index" msgstr "" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "wrong axis specified" msgstr "" @@ -4510,7 +4634,11 @@ msgstr "" msgid "wrong input type" msgstr "" -#: extmod/ulab/code/ulab_create.c py/objarray.c py/objstr.c +#: extmod/ulab/code/numpy/transform.c +msgid "wrong length of condition array" +msgstr "" + +#: extmod/ulab/code/numpy/create.c py/objarray.c py/objstr.c msgid "wrong number of arguments" msgstr "" @@ -4554,6 +4682,12 @@ msgstr "ziはfloat値でなければなりません" msgid "zi must be of shape (n_section, 2)" msgstr "" +#~ msgid "cannot perform relative import" +#~ msgstr "相対インポートはできません" + +#~ msgid "Unsupported pull value." +#~ msgstr "非対応のpull値" + #~ msgid "integer required" #~ msgstr "整数が必要" diff --git a/locale/ko.po b/locale/ko.po index b6a7791ae6..e77a66c1d9 100644 --- a/locale/ko.po +++ b/locale/ko.po @@ -100,7 +100,7 @@ msgstr "%q 인덱스는 %s 가 아닌 정수 여야합니다" msgid "%q length must be %d-%d" msgstr "" -#: shared-bindings/usb_hid/Device.c +#: shared-bindings/busio/I2C.c shared-bindings/usb_hid/Device.c msgid "%q length must be >= 1" msgstr "" @@ -145,6 +145,10 @@ msgstr "" msgid "%q must be of type %q" msgstr "" +#: shared-bindings/digitalio/Pull.c +msgid "%q must be of type %q or None" +msgstr "" + #: ports/atmel-samd/common-hal/busio/UART.c msgid "%q must be power of 2" msgstr "" @@ -443,6 +447,7 @@ msgstr "핀의 모든 타이머가 사용 중입니다" msgid "All timers in use" msgstr "모든 타이머가 사용 중입니다" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Already advertising." msgstr "" @@ -577,7 +582,7 @@ msgstr "" #: shared-bindings/displayio/Display.c #: shared-bindings/framebufferio/FramebufferDisplay.c -#: shared-bindings/is31fl3741/is31fl3741.c +#: shared-bindings/is31fl3741/FrameBuffer.c #: shared-bindings/rgbmatrix/RGBMatrix.c msgid "Brightness must be 0-1.0" msgstr "" @@ -629,7 +634,7 @@ msgstr "" msgid "Buffer must be a multiple of 512 bytes" msgstr "" -#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c +#: shared-bindings/bitbangio/I2C.c msgid "Buffer must be at least length 1" msgstr "잘못된 크기의 버퍼. >1 여야합니다" @@ -662,6 +667,10 @@ msgstr "바이트는 0에서 255 사이 여야합니다." msgid "CBC blocks must be multiples of 16 bytes" msgstr "" +#: supervisor/shared/safe_mode.c +msgid "CIRCUITPY drive could not be found or created." +msgstr "" + #: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c msgid "CRC or checksum was invalid" msgstr "" @@ -903,10 +912,12 @@ msgstr "" msgid "Data chunk must follow fmt chunk" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data not supported with directed advertising" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data too large for advertisement packet" msgstr "광고 (브로드 캐스트) 패킷에 대한 데이터가 너무 큽니다" @@ -987,6 +998,7 @@ msgstr "" msgid "Expected tuple of length %d, got %d" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Extended advertisements with scan response not supported." msgstr "" @@ -1040,6 +1052,7 @@ msgstr "" msgid "Failed to buffer the sample" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Failed to connect: internal error" msgstr "" @@ -1119,6 +1132,13 @@ msgstr "" msgid "Group already used" msgstr "" +#: ports/atmel-samd/common-hal/busio/SPI.c ports/cxd56/common-hal/busio/SPI.c +#: ports/espressif/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/nrf/common-hal/busio/SPI.c +#: ports/raspberrypi/common-hal/busio/SPI.c +msgid "Half duplex SPI is not implemented" +msgstr "" + #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/I2C.c #: ports/stm/common-hal/busio/SPI.c ports/stm/common-hal/canio/CAN.c #: ports/stm/common-hal/sdioio/SDCard.c @@ -1271,6 +1291,7 @@ msgstr "" msgid "Invalid AuthMode" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c msgid "Invalid BLE parameter" msgstr "" @@ -1365,6 +1386,10 @@ msgstr "형식 청크 크기가 잘못되었습니다" msgid "Invalid memory access." msgstr "" +#: extmod/vfs_fat_file.c +msgid "Invalid mode" +msgstr "" + #: ports/espressif/common-hal/wifi/Radio.c msgid "Invalid multicast MAC address" msgstr "" @@ -1465,7 +1490,7 @@ msgstr "" msgid "Key must be 16, 24, or 32 bytes long" msgstr "" -#: shared-module/is31fl3741/is31fl3741.c +#: shared-module/is31fl3741/FrameBuffer.c msgid "LED mappings must match display size" msgstr "" @@ -1493,6 +1518,10 @@ msgstr "" msgid "MOSI pin init failed." msgstr "" +#: shared-bindings/is31fl3741/IS31FL3741.c +msgid "Mapping must be a tuple" +msgstr "" + #: shared-module/displayio/Shape.c #, c-format msgid "Maximum x value when mirrored is %d" @@ -1575,6 +1604,10 @@ msgstr "" msgid "Name too long" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +msgid "Nimble out of memory" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "" @@ -1595,9 +1628,9 @@ msgstr "" msgid "No DMA pacing timer found" msgstr "" -#: shared-module/adafruit_bus_device/I2CDevice.c +#: shared-module/adafruit_bus_device/i2c_device/I2CDevice.c #, c-format -msgid "No I2C device at address: %x" +msgid "No I2C device at address: 0x%x" msgstr "" #: ports/espressif/common-hal/busio/SPI.c @@ -1722,6 +1755,7 @@ msgstr "" msgid "Not a valid IP string" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -1895,7 +1929,7 @@ msgstr "" msgid "Pin interrupt already in use" msgstr "" -#: shared-bindings/adafruit_bus_device/SPIDevice.c +#: shared-bindings/adafruit_bus_device/spi_device/SPIDevice.c #: shared-bindings/digitalio/DigitalInOut.c msgid "Pin is input only" msgstr "" @@ -1977,6 +2011,10 @@ msgstr "" msgid "RAISE mode is not implemented" msgstr "" +#: ports/raspberrypi/common-hal/countio/Counter.c +msgid "RISE_AND_FALL not available on this chip" +msgstr "" + #: ports/stm/common-hal/os/__init__.c msgid "RNG DeInit Error" msgstr "" @@ -2093,10 +2131,11 @@ msgstr "" msgid "Sample rate too high. It must be less than %d" msgstr "" -#: shared-bindings/is31fl3741/is31fl3741.c +#: shared-bindings/is31fl3741/FrameBuffer.c msgid "Scale dimensions must divide by 3" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Scan already in progess. Stop with stop_scan." msgstr "" @@ -2255,6 +2294,7 @@ msgstr "" msgid "Time is in the past." msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2277,6 +2317,7 @@ msgstr "" msgid "Too many displays" msgstr "" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Total data to write is larger than %q" msgstr "" @@ -2355,7 +2396,7 @@ msgstr "" msgid "Unable to create lock" msgstr "" -#: shared-module/displayio/I2CDisplay.c shared-module/is31fl3741/is31fl3741.c +#: shared-module/displayio/I2CDisplay.c shared-module/is31fl3741/IS31FL3741.c #, c-format msgid "Unable to find I2C Display at %x" msgstr "" @@ -2390,6 +2431,16 @@ msgstr "" msgid "Unhandled ESP TLS error %d %d %x %d" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown BLE error at %s:%d: %d" +msgstr "" + +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown BLE error: %d" +msgstr "" + #: shared-bindings/wifi/Radio.c #, c-format msgid "Unknown failure %d" @@ -2409,11 +2460,21 @@ msgstr "" msgid "Unknown security error: 0x%04x" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error at %s:%d: %d" +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown system firmware error: %04x" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error: %d" +msgstr "" + #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #, c-format msgid "Unmatched number of items on RHS (expected %d, got %d)." @@ -2447,19 +2508,19 @@ msgstr "" msgid "Unsupported operation" msgstr "" -#: shared-bindings/digitalio/DigitalInOut.c -msgid "Unsupported pull value." -msgstr "" - #: ports/espressif/common-hal/dualbank/__init__.c msgid "Update Failed" msgstr "" +#: ports/espressif/common-hal/_bleio/Characteristic.c +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length != required fixed length" msgstr "" +#: ports/espressif/common-hal/_bleio/Characteristic.c +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length > max_length" @@ -2517,6 +2578,7 @@ msgstr "" msgid "Woken up by alarm.\n" msgstr "" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Writes not supported on Characteristic" msgstr "" @@ -2620,7 +2682,7 @@ msgstr "" msgid "attributes not supported yet" msgstr "" -#: extmod/ulab/code/numpy/numerical.c +#: extmod/ulab/code/ulab_tools.c msgid "axis is out of bounds" msgstr "" @@ -2676,11 +2738,11 @@ msgstr "bits_per_sample은 8 또는 16이어야합니다." msgid "branch not in range" msgstr "" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/utils/utils.c msgid "buffer is smaller than requested size" msgstr "" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/utils/utils.c msgid "buffer size must be a multiple of element size" msgstr "" @@ -2730,6 +2792,10 @@ msgstr "" msgid "calibration value out of range +/-127" msgstr "" +#: shared-module/vectorio/Rectangle.c +msgid "can only be registered in one parent" +msgstr "" + #: py/emitinlinethumb.c msgid "can only have up to 4 parameters to Thumb assembly" msgstr "" @@ -2768,6 +2834,10 @@ msgstr "" msgid "can't convert '%q' object to %q implicitly" msgstr "" +#: extmod/ulab/code/numpy/vector.c +msgid "can't convert complex to float" +msgstr "" + #: py/obj.c msgid "can't convert to %q" msgstr "" @@ -2820,6 +2890,10 @@ msgstr "" msgid "can't load with '%q' index" msgstr "" +#: py/builtinimport.c +msgid "can't perform relative import" +msgstr "" + #: py/objgenerator.c msgid "can't send non-None value to a just-started generator" msgstr "" @@ -2862,6 +2936,14 @@ msgstr "" msgid "cannot cast output with casting rule" msgstr "" +#: extmod/ulab/code/ndarray.c +msgid "cannot convert complex to dtype" +msgstr "" + +#: extmod/ulab/code/ndarray.c +msgid "cannot convert complex type" +msgstr "" + #: py/objtype.c msgid "cannot create '%q' instances" msgstr "" @@ -2874,10 +2956,6 @@ msgstr "" msgid "cannot import name %q" msgstr "" -#: py/builtinimport.c -msgid "cannot perform relative import" -msgstr "" - #: extmod/moductypes.c msgid "cannot unambiguously get sizeof scalar" msgstr "" @@ -3053,6 +3131,10 @@ msgstr "" msgid "divisor must be 4" msgstr "" +#: extmod/ulab/code/numpy/vector.c +msgid "dtype must be float, or complex" +msgstr "" + #: py/objdeque.c msgid "empty" msgstr "" @@ -3156,7 +3238,7 @@ msgstr "" msgid "first argument must be a function" msgstr "" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "first argument must be a tuple of ndarrays" msgstr "" @@ -3221,6 +3303,10 @@ msgstr "" msgid "function is defined for ndarrays only" msgstr "" +#: extmod/ulab/code/numpy/carray/carray.c +msgid "function is implemented for ndarrays only" +msgstr "" + #: py/argcheck.c #, c-format msgid "function missing %d required positional arguments" @@ -3334,7 +3420,7 @@ msgstr "" msgid "input and output shapes are not compatible" msgstr "" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "input argument must be an integer, a tuple, or a list" msgstr "" @@ -3342,7 +3428,7 @@ msgstr "" msgid "input array length must be power of 2" msgstr "" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "input arrays are not compatible" msgstr "" @@ -3350,6 +3436,10 @@ msgstr "" msgid "input data must be an iterable" msgstr "" +#: extmod/ulab/code/numpy/vector.c +msgid "input dtype must be float or complex" +msgstr "" + #: extmod/ulab/code/numpy/linalg/linalg.c msgid "input matrix is asymmetric" msgstr "" @@ -3359,18 +3449,26 @@ msgstr "" msgid "input matrix is singular" msgstr "" +#: extmod/ulab/code/numpy/carray/carray.c +msgid "input must be a 1D ndarray" +msgstr "" + #: extmod/ulab/code/scipy/linalg/linalg.c extmod/ulab/code/user/user.c msgid "input must be a dense ndarray" msgstr "" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "input must be a tensor of rank 2" msgstr "" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/user/user.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/user/user.c msgid "input must be an ndarray" msgstr "" +#: extmod/ulab/code/numpy/carray/carray.c +msgid "input must be an ndarray, or a scalar" +msgstr "" + #: extmod/ulab/code/scipy/signal/signal.c msgid "input must be one-dimensional" msgstr "" @@ -3548,6 +3646,11 @@ msgstr "" msgid "matrix is not positive definite" msgstr "" +#: ports/espressif/common-hal/wifi/Radio.c +msgid "max_connections must be between 0 and 10" +msgstr "" + +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c #, c-format @@ -3701,6 +3804,7 @@ msgstr "" msgid "non-Device in %q" msgstr "" +#: ports/espressif/common-hal/_bleio/Connection.c #: ports/nrf/common-hal/_bleio/Connection.c msgid "non-UUID found in service_uuids_whitelist" msgstr "" @@ -3741,7 +3845,11 @@ msgstr "" msgid "not enough arguments for format string" msgstr "" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/carray/carray_tools.c +msgid "not implemented for complex dtype" +msgstr "" + +#: extmod/ulab/code/numpy/create.c msgid "number of points must be at least 2" msgstr "" @@ -3799,7 +3907,7 @@ msgstr "" msgid "odd-length string" msgstr "" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/utils/utils.c msgid "offset is too large" msgstr "" @@ -3807,7 +3915,7 @@ msgstr "" msgid "offset must be >= 0" msgstr "" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "offset must be non-negative and no greater than buffer length" msgstr "" @@ -3919,6 +4027,10 @@ msgstr "" msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "" +#: extmod/vfs_posix_file.c +msgid "poll on file not available on win32" +msgstr "" + #: shared-module/vectorio/Polygon.c msgid "polygon can only be registered in one parent" msgstr "" @@ -3948,18 +4060,27 @@ msgstr "" msgid "pow() with 3 arguments requires integers" msgstr "" +#: ports/espressif/boards/adafruit_esp32s2_camera/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tft/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h #: ports/espressif/boards/adafruit_funhouse/mpconfigboard.h #: ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h +#: ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h +#: ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h #: ports/espressif/boards/atmegazero_esp32s2/mpconfigboard.h #: ports/espressif/boards/crumpspace_crumps2/mpconfigboard.h #: ports/espressif/boards/electroniccats_bastwifi/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s2_devkitc_1_n4r2/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_box/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h #: ports/espressif/boards/espressif_hmi_devkit_1/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1.3/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1/mpconfigboard.h @@ -3985,7 +4106,10 @@ msgstr "" #: ports/espressif/boards/unexpectedmaker_feathers2/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_neo/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_prerelease/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_feathers3/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_pros3/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_tinys2/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_tinys3/mpconfigboard.h msgid "pressing boot button at start up.\n" msgstr "" @@ -4282,7 +4406,7 @@ msgstr "" msgid "too many arguments provided with the given format" msgstr "" -#: extmod/ulab/code/ndarray.c extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/ndarray.c extmod/ulab/code/numpy/create.c msgid "too many dimensions" msgstr "" @@ -4466,7 +4590,7 @@ msgstr "" msgid "width must be from 2 to 8 (inclusive), not %d" msgstr "" -#: shared-bindings/is31fl3741/is31fl3741.c +#: shared-bindings/is31fl3741/FrameBuffer.c #: shared-bindings/rgbmatrix/RGBMatrix.c msgid "width must be greater than zero" msgstr "" @@ -4483,7 +4607,7 @@ msgstr "" msgid "wrong axis index" msgstr "" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "wrong axis specified" msgstr "" @@ -4491,7 +4615,11 @@ msgstr "" msgid "wrong input type" msgstr "" -#: extmod/ulab/code/ulab_create.c py/objarray.c py/objstr.c +#: extmod/ulab/code/numpy/transform.c +msgid "wrong length of condition array" +msgstr "" + +#: extmod/ulab/code/numpy/create.c py/objarray.c py/objstr.c msgid "wrong number of arguments" msgstr "" diff --git a/locale/nl.po b/locale/nl.po index 2d888bc99a..cf119a8356 100644 --- a/locale/nl.po +++ b/locale/nl.po @@ -102,7 +102,7 @@ msgstr "%q indexen moeten integers zijn, niet %s" msgid "%q length must be %d-%d" msgstr "" -#: shared-bindings/usb_hid/Device.c +#: shared-bindings/busio/I2C.c shared-bindings/usb_hid/Device.c msgid "%q length must be >= 1" msgstr "" @@ -147,6 +147,10 @@ msgstr "" msgid "%q must be of type %q" msgstr "" +#: shared-bindings/digitalio/Pull.c +msgid "%q must be of type %q or None" +msgstr "" + #: ports/atmel-samd/common-hal/busio/UART.c msgid "%q must be power of 2" msgstr "" @@ -445,6 +449,7 @@ msgstr "Alle timers voor deze pin zijn in gebruik" msgid "All timers in use" msgstr "Alle timers zijn in gebruik" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Already advertising." msgstr "Advertising is al bezig." @@ -579,7 +584,7 @@ msgstr "Beide pinnen moeten hardware interrupts ondersteunen" #: shared-bindings/displayio/Display.c #: shared-bindings/framebufferio/FramebufferDisplay.c -#: shared-bindings/is31fl3741/is31fl3741.c +#: shared-bindings/is31fl3741/FrameBuffer.c #: shared-bindings/rgbmatrix/RGBMatrix.c msgid "Brightness must be 0-1.0" msgstr "Helderheid moet tussen de 0 en 1.0 liggen" @@ -631,7 +636,7 @@ msgstr "Buffer lengte moet een veelvoud van 512 zijn" msgid "Buffer must be a multiple of 512 bytes" msgstr "Buffer moet een veelvoud van 512 bytes zijn" -#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c +#: shared-bindings/bitbangio/I2C.c msgid "Buffer must be at least length 1" msgstr "Buffer moet op zijn minst lengte 1 zijn" @@ -664,6 +669,10 @@ msgstr "Bytes moeten tussen 0 en 255 liggen." msgid "CBC blocks must be multiples of 16 bytes" msgstr "CBC blocks moeten meervouden van 16 bytes zijn" +#: supervisor/shared/safe_mode.c +msgid "CIRCUITPY drive could not be found or created." +msgstr "" + #: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c msgid "CRC or checksum was invalid" msgstr "" @@ -909,10 +918,12 @@ msgstr "Data 0 pin moet byte uitgelijnd zijn" msgid "Data chunk must follow fmt chunk" msgstr "Data chunk moet gevolgd worden door fmt chunk" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data not supported with directed advertising" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data too large for advertisement packet" msgstr "Data te groot voor advertisement pakket" @@ -993,6 +1004,7 @@ msgstr "Verwachtte een alarm" msgid "Expected tuple of length %d, got %d" msgstr "Verwachtte een tuple met lengte %d, maar kreeg %d" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Extended advertisements with scan response not supported." msgstr "Extended advertisements met scan antwoord niet ondersteund." @@ -1046,6 +1058,7 @@ msgstr "Kon WiFi scan geheugen niet toewijzen" msgid "Failed to buffer the sample" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Failed to connect: internal error" msgstr "Verbinding mislukt: interne fout" @@ -1126,6 +1139,13 @@ msgstr "" msgid "Group already used" msgstr "Groep al gebruikt" +#: ports/atmel-samd/common-hal/busio/SPI.c ports/cxd56/common-hal/busio/SPI.c +#: ports/espressif/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/nrf/common-hal/busio/SPI.c +#: ports/raspberrypi/common-hal/busio/SPI.c +msgid "Half duplex SPI is not implemented" +msgstr "" + #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/I2C.c #: ports/stm/common-hal/busio/SPI.c ports/stm/common-hal/canio/CAN.c #: ports/stm/common-hal/sdioio/SDCard.c @@ -1280,6 +1300,7 @@ msgstr "Ongeldige ADC Unit waarde" msgid "Invalid AuthMode" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c msgid "Invalid BLE parameter" msgstr "" @@ -1374,6 +1395,10 @@ msgstr "Ongeldig formaat stuk grootte" msgid "Invalid memory access." msgstr "Ongeldig geheugen adres." +#: extmod/vfs_fat_file.c +msgid "Invalid mode" +msgstr "" + #: ports/espressif/common-hal/wifi/Radio.c msgid "Invalid multicast MAC address" msgstr "" @@ -1474,7 +1499,7 @@ msgstr "Ongeldig woord/bit lengte" msgid "Key must be 16, 24, or 32 bytes long" msgstr "Sleutel moet 16, 24, of 32 bytes lang zijn" -#: shared-module/is31fl3741/is31fl3741.c +#: shared-module/is31fl3741/FrameBuffer.c msgid "LED mappings must match display size" msgstr "" @@ -1502,6 +1527,10 @@ msgstr "MISO pin init mislukt." msgid "MOSI pin init failed." msgstr "MOSI pin init mislukt." +#: shared-bindings/is31fl3741/IS31FL3741.c +msgid "Mapping must be a tuple" +msgstr "" + #: shared-module/displayio/Shape.c #, c-format msgid "Maximum x value when mirrored is %d" @@ -1584,6 +1613,10 @@ msgstr "NVS-fout" msgid "Name too long" msgstr "Naam te lang" +#: ports/espressif/common-hal/_bleio/__init__.c +msgid "Nimble out of memory" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "Geen CCCD voor deze Characteristic" @@ -1604,10 +1637,10 @@ msgstr "Geen DMA kanaal gevonden" msgid "No DMA pacing timer found" msgstr "" -#: shared-module/adafruit_bus_device/I2CDevice.c +#: shared-module/adafruit_bus_device/i2c_device/I2CDevice.c #, c-format -msgid "No I2C device at address: %x" -msgstr "Geen I2C-apparaat op adres: %x" +msgid "No I2C device at address: 0x%x" +msgstr "" #: ports/espressif/common-hal/busio/SPI.c #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c @@ -1731,6 +1764,7 @@ msgstr "" msgid "Not a valid IP string" msgstr "Geen geldige IP string" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -1913,7 +1947,7 @@ msgstr "Pin heeft geen ADC mogelijkheden" msgid "Pin interrupt already in use" msgstr "" -#: shared-bindings/adafruit_bus_device/SPIDevice.c +#: shared-bindings/adafruit_bus_device/spi_device/SPIDevice.c #: shared-bindings/digitalio/DigitalInOut.c msgid "Pin is input only" msgstr "Pin kan alleen voor invoer gebruikt worden" @@ -2000,6 +2034,10 @@ msgstr "Pull niet gebruikt wanneer de richting output is." msgid "RAISE mode is not implemented" msgstr "" +#: ports/raspberrypi/common-hal/countio/Counter.c +msgid "RISE_AND_FALL not available on this chip" +msgstr "" + #: ports/stm/common-hal/os/__init__.c msgid "RNG DeInit Error" msgstr "RNG DeInit Fout" @@ -2116,10 +2154,11 @@ msgstr "Sample rate moet positief zijn" msgid "Sample rate too high. It must be less than %d" msgstr "Sample rate is te hoog. Moet minder dan %d zijn" -#: shared-bindings/is31fl3741/is31fl3741.c +#: shared-bindings/is31fl3741/FrameBuffer.c msgid "Scale dimensions must divide by 3" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Scan already in progess. Stop with stop_scan." msgstr "Scan wordt al uitvoerd. Stop met stop_scan." @@ -2278,6 +2317,7 @@ msgstr "Tile breedte moet exact de bitmap breedte verdelen" msgid "Time is in the past." msgstr "Tijdstip ligt in het verleden." +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2300,6 +2340,7 @@ msgstr "Teveel beeldscherm bussen" msgid "Too many displays" msgstr "Teveel beeldschermen" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Total data to write is larger than %q" msgstr "" @@ -2377,7 +2418,7 @@ msgstr "Niet in staat buffers voor gesigneerde conversie te alloceren" msgid "Unable to create lock" msgstr "Kan vergrendeling niet maken" -#: shared-module/displayio/I2CDisplay.c shared-module/is31fl3741/is31fl3741.c +#: shared-module/displayio/I2CDisplay.c shared-module/is31fl3741/IS31FL3741.c #, c-format msgid "Unable to find I2C Display at %x" msgstr "Geen I2C beeldscherm gevonden bij %x" @@ -2412,6 +2453,16 @@ msgstr "Onverwacht mrfx uuid type" msgid "Unhandled ESP TLS error %d %d %x %d" msgstr "Niet behandelde ESP TLS fout %d %d %x %d" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown BLE error at %s:%d: %d" +msgstr "" + +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown BLE error: %d" +msgstr "" + #: shared-bindings/wifi/Radio.c #, c-format msgid "Unknown failure %d" @@ -2431,11 +2482,21 @@ msgstr "Onbekende reden." msgid "Unknown security error: 0x%04x" msgstr "Onbekende veiligheidsfout: 0x%04x" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error at %s:%d: %d" +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown system firmware error: %04x" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error: %d" +msgstr "" + #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #, c-format msgid "Unmatched number of items on RHS (expected %d, got %d)." @@ -2471,19 +2532,19 @@ msgstr "Niet-ondersteunde format" msgid "Unsupported operation" msgstr "Niet-ondersteunde operatie" -#: shared-bindings/digitalio/DigitalInOut.c -msgid "Unsupported pull value." -msgstr "Niet-ondersteunde pull-waarde." - #: ports/espressif/common-hal/dualbank/__init__.c msgid "Update Failed" msgstr "Update Mislukt" +#: ports/espressif/common-hal/_bleio/Characteristic.c +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length != required fixed length" msgstr "Waarde lengte != vereist vaste lengte" +#: ports/espressif/common-hal/_bleio/Characteristic.c +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length > max_length" @@ -2545,6 +2606,7 @@ msgstr "WiFi wachtwoord moet tussen 8 en 63 karakters bevatten" msgid "Woken up by alarm.\n" msgstr "Gewekt door alarm.\n" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Writes not supported on Characteristic" msgstr "Schrijven niet ondersteund op Characteristic" @@ -2648,7 +2710,7 @@ msgstr "poging om argmin/argmax van een lege sequentie te krijgen" msgid "attributes not supported yet" msgstr "attributen nog niet ondersteund" -#: extmod/ulab/code/numpy/numerical.c +#: extmod/ulab/code/ulab_tools.c msgid "axis is out of bounds" msgstr "as is buiten bereik" @@ -2704,11 +2766,11 @@ msgstr "bits_per_sample moet 8 of 16 zijn" msgid "branch not in range" msgstr "pad (branch) niet binnen bereik" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/utils/utils.c msgid "buffer is smaller than requested size" msgstr "" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/utils/utils.c msgid "buffer size must be a multiple of element size" msgstr "" @@ -2758,6 +2820,10 @@ msgstr "calibration is alleen-lezen" msgid "calibration value out of range +/-127" msgstr "calibration waarde buiten bereik +/-127" +#: shared-module/vectorio/Rectangle.c +msgid "can only be registered in one parent" +msgstr "" + #: py/emitinlinethumb.c msgid "can only have up to 4 parameters to Thumb assembly" msgstr "kan slechts 4 parameters aan Thumb assembly geven" @@ -2797,6 +2863,10 @@ msgstr "kan %s niet converteren naar een complex" msgid "can't convert '%q' object to %q implicitly" msgstr "kan '%q' object niet omzetten naar %q impliciet" +#: extmod/ulab/code/numpy/vector.c +msgid "can't convert complex to float" +msgstr "" + #: py/obj.c msgid "can't convert to %q" msgstr "kan niet naar %q converteren" @@ -2849,6 +2919,10 @@ msgstr "kan niet laden van '%q'" msgid "can't load with '%q' index" msgstr "kan niet met '%q' index laden" +#: py/builtinimport.c +msgid "can't perform relative import" +msgstr "" + #: py/objgenerator.c msgid "can't send non-None value to a just-started generator" msgstr "kan geen niet-'None' waarde naar een net gestartte generator sturen" @@ -2891,6 +2965,14 @@ msgstr "" msgid "cannot cast output with casting rule" msgstr "kan uitvoer niet converteren zonder conversieregel" +#: extmod/ulab/code/ndarray.c +msgid "cannot convert complex to dtype" +msgstr "" + +#: extmod/ulab/code/ndarray.c +msgid "cannot convert complex type" +msgstr "" + #: py/objtype.c msgid "cannot create '%q' instances" msgstr "kan geen instanties van '%q' creëren" @@ -2903,10 +2985,6 @@ msgstr "kan geen instantie creëren" msgid "cannot import name %q" msgstr "kan naam %q niet importeren" -#: py/builtinimport.c -msgid "cannot perform relative import" -msgstr "kan geen relatieve import uitvoeren" - #: extmod/moductypes.c msgid "cannot unambiguously get sizeof scalar" msgstr "" @@ -3085,6 +3163,10 @@ msgstr "deling door nul" msgid "divisor must be 4" msgstr "" +#: extmod/ulab/code/numpy/vector.c +msgid "dtype must be float, or complex" +msgstr "" + #: py/objdeque.c msgid "empty" msgstr "leeg" @@ -3188,7 +3270,7 @@ msgstr "eerste argument moet een aanroepbare (callable) zijn" msgid "first argument must be a function" msgstr "eerste argument moet een functie zijn" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "first argument must be a tuple of ndarrays" msgstr "eerste argument moet een tupel van ndarrays zijn" @@ -3253,6 +3335,10 @@ msgstr "functie heeft hetzelfde teken aan beide uiteinden van het interval" msgid "function is defined for ndarrays only" msgstr "functie is alleen gedefinieerd voor ndarrays" +#: extmod/ulab/code/numpy/carray/carray.c +msgid "function is implemented for ndarrays only" +msgstr "" + #: py/argcheck.c #, c-format msgid "function missing %d required positional arguments" @@ -3367,7 +3453,7 @@ msgstr "inline assembler moet een functie zijn" msgid "input and output shapes are not compatible" msgstr "in- en uitvoervormen zijn niet compatibel" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "input argument must be an integer, a tuple, or a list" msgstr "" @@ -3375,7 +3461,7 @@ msgstr "" msgid "input array length must be power of 2" msgstr "invoer array lengte moet een macht van 2 zijn" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "input arrays are not compatible" msgstr "input arrays zijn niet compatibel" @@ -3383,6 +3469,10 @@ msgstr "input arrays zijn niet compatibel" msgid "input data must be an iterable" msgstr "invoerdata moet itereerbaar zijn" +#: extmod/ulab/code/numpy/vector.c +msgid "input dtype must be float or complex" +msgstr "" + #: extmod/ulab/code/numpy/linalg/linalg.c msgid "input matrix is asymmetric" msgstr "invoermatrix is asymmetrisch" @@ -3392,18 +3482,26 @@ msgstr "invoermatrix is asymmetrisch" msgid "input matrix is singular" msgstr "invoermatrix is singulier" +#: extmod/ulab/code/numpy/carray/carray.c +msgid "input must be a 1D ndarray" +msgstr "" + #: extmod/ulab/code/scipy/linalg/linalg.c extmod/ulab/code/user/user.c msgid "input must be a dense ndarray" msgstr "invoer moet een gesloten ndarray zijn" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "input must be a tensor of rank 2" msgstr "invoer moet een tensor van rang 2 zijn" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/user/user.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/user/user.c msgid "input must be an ndarray" msgstr "invoer moet een ndarray zijn" +#: extmod/ulab/code/numpy/carray/carray.c +msgid "input must be an ndarray, or a scalar" +msgstr "" + #: extmod/ulab/code/scipy/signal/signal.c msgid "input must be one-dimensional" msgstr "invoer moet eendimensionaal zijn" @@ -3584,6 +3682,11 @@ msgstr "fout in het wiskundig domein (math domain error)" msgid "matrix is not positive definite" msgstr "matrix is niet positief-definiet" +#: ports/espressif/common-hal/wifi/Radio.c +msgid "max_connections must be between 0 and 10" +msgstr "" + +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c #, c-format @@ -3737,6 +3840,7 @@ msgstr "niet zo'n attribuut" msgid "non-Device in %q" msgstr "" +#: ports/espressif/common-hal/_bleio/Connection.c #: ports/nrf/common-hal/_bleio/Connection.c msgid "non-UUID found in service_uuids_whitelist" msgstr "niet-UUID gevonden in service_uuids_whitelist" @@ -3777,7 +3881,11 @@ msgstr "niet alle argumenten omgezet bij formattering van string" msgid "not enough arguments for format string" msgstr "niet genoeg argumenten om string te formatteren" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/carray/carray_tools.c +msgid "not implemented for complex dtype" +msgstr "" + +#: extmod/ulab/code/numpy/create.c msgid "number of points must be at least 2" msgstr "aantal punten moet minimaal 2 zijn" @@ -3835,7 +3943,7 @@ msgstr "object met buffer protocol vereist" msgid "odd-length string" msgstr "string met oneven lengte" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/utils/utils.c msgid "offset is too large" msgstr "compensatie is te groot" @@ -3843,7 +3951,7 @@ msgstr "compensatie is te groot" msgid "offset must be >= 0" msgstr "compensatie moet groter of gelijk 0 zijn" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "offset must be non-negative and no greater than buffer length" msgstr "" @@ -3955,6 +4063,10 @@ msgstr "pixel waarde vereist te veel bits" msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "pixel_shader moet displayio.Palette of displayio.ColorConverter zijn" +#: extmod/vfs_posix_file.c +msgid "poll on file not available on win32" +msgstr "" + #: shared-module/vectorio/Polygon.c msgid "polygon can only be registered in one parent" msgstr "" @@ -3985,18 +4097,27 @@ msgstr "derde argument van pow() mag geen 0 zijn" msgid "pow() with 3 arguments requires integers" msgstr "pow() met 3 argumenten vereist integers" +#: ports/espressif/boards/adafruit_esp32s2_camera/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tft/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h #: ports/espressif/boards/adafruit_funhouse/mpconfigboard.h #: ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h +#: ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h +#: ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h #: ports/espressif/boards/atmegazero_esp32s2/mpconfigboard.h #: ports/espressif/boards/crumpspace_crumps2/mpconfigboard.h #: ports/espressif/boards/electroniccats_bastwifi/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s2_devkitc_1_n4r2/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_box/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h #: ports/espressif/boards/espressif_hmi_devkit_1/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1.3/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1/mpconfigboard.h @@ -4022,7 +4143,10 @@ msgstr "pow() met 3 argumenten vereist integers" #: ports/espressif/boards/unexpectedmaker_feathers2/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_neo/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_prerelease/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_feathers3/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_pros3/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_tinys2/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_tinys3/mpconfigboard.h msgid "pressing boot button at start up.\n" msgstr "druk bootknop in bij opstarten.\n" @@ -4321,7 +4445,7 @@ msgstr "tobytes kunnen alleen ingeroepen worden voor gesloten arrays" msgid "too many arguments provided with the given format" msgstr "te veel argumenten opgegeven bij dit formaat" -#: extmod/ulab/code/ndarray.c extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/ndarray.c extmod/ulab/code/numpy/create.c msgid "too many dimensions" msgstr "" @@ -4505,7 +4629,7 @@ msgstr "watchdog time-out moet groter zijn dan 0" msgid "width must be from 2 to 8 (inclusive), not %d" msgstr "" -#: shared-bindings/is31fl3741/is31fl3741.c +#: shared-bindings/is31fl3741/FrameBuffer.c #: shared-bindings/rgbmatrix/RGBMatrix.c msgid "width must be greater than zero" msgstr "breedte moet groter dan nul zijn" @@ -4522,7 +4646,7 @@ msgstr "window moet <= interval zijn" msgid "wrong axis index" msgstr "foute index voor as" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "wrong axis specified" msgstr "onjuiste as gespecificeerd" @@ -4530,7 +4654,11 @@ msgstr "onjuiste as gespecificeerd" msgid "wrong input type" msgstr "onjuist invoertype" -#: extmod/ulab/code/ulab_create.c py/objarray.c py/objstr.c +#: extmod/ulab/code/numpy/transform.c +msgid "wrong length of condition array" +msgstr "" + +#: extmod/ulab/code/numpy/create.c py/objarray.c py/objstr.c msgid "wrong number of arguments" msgstr "onjuist aantal argumenten" @@ -4574,6 +4702,16 @@ msgstr "zi moet van type float zijn" msgid "zi must be of shape (n_section, 2)" msgstr "zi moet vorm (n_section, 2) hebben" +#~ msgid "cannot perform relative import" +#~ msgstr "kan geen relatieve import uitvoeren" + +#, c-format +#~ msgid "No I2C device at address: %x" +#~ msgstr "Geen I2C-apparaat op adres: %x" + +#~ msgid "Unsupported pull value." +#~ msgstr "Niet-ondersteunde pull-waarde." + #, c-format #~ msgid "" #~ "Welcome to Adafruit CircuitPython %s!\n" diff --git a/locale/pl.po b/locale/pl.po index 77d99ea668..d8158be537 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -7,7 +7,7 @@ msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-01-04 12:55-0600\n" -"PO-Revision-Date: 2021-02-10 21:50+0000\n" +"PO-Revision-Date: 2022-02-09 18:11+0000\n" "Last-Translator: Maciej Stankiewicz \n" "Language-Team: pl\n" "Language: pl\n" @@ -16,7 +16,7 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=3; plural=n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 " "|| n%100>=20) ? 1 : 2;\n" -"X-Generator: Weblate 4.5-dev\n" +"X-Generator: Weblate 4.11-dev\n" #: main.c msgid "" @@ -104,7 +104,7 @@ msgstr "%q indeks musi być liczbą całkowitą, a nie %s" msgid "%q length must be %d-%d" msgstr "" -#: shared-bindings/usb_hid/Device.c +#: shared-bindings/busio/I2C.c shared-bindings/usb_hid/Device.c msgid "%q length must be >= 1" msgstr "" @@ -149,6 +149,10 @@ msgstr "" msgid "%q must be of type %q" msgstr "" +#: shared-bindings/digitalio/Pull.c +msgid "%q must be of type %q or None" +msgstr "" + #: ports/atmel-samd/common-hal/busio/UART.c msgid "%q must be power of 2" msgstr "" @@ -447,6 +451,7 @@ msgstr "Wszystkie timery tej nóżki w użyciu" msgid "All timers in use" msgstr "Wszystkie timery w użyciu" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Already advertising." msgstr "" @@ -544,7 +549,7 @@ msgstr "" #: shared-module/displayio/Display.c #: shared-module/framebufferio/FramebufferDisplay.c msgid "Below minimum frame rate" -msgstr "" +msgstr "Poniżej minimalnej liczby klatek na sekundę" #: ports/raspberrypi/common-hal/audiobusio/I2SOut.c msgid "Bit clock and word select must be sequential pins" @@ -581,7 +586,7 @@ msgstr "Obie nóżki muszą wspierać przerwania sprzętowe" #: shared-bindings/displayio/Display.c #: shared-bindings/framebufferio/FramebufferDisplay.c -#: shared-bindings/is31fl3741/is31fl3741.c +#: shared-bindings/is31fl3741/FrameBuffer.c #: shared-bindings/rgbmatrix/RGBMatrix.c msgid "Brightness must be 0-1.0" msgstr "Jasność musi wynosić 0-1,0" @@ -633,7 +638,7 @@ msgstr "Długość bufora musi być wielokrotnością 512" msgid "Buffer must be a multiple of 512 bytes" msgstr "Bufor musi być wielokrotnością 512 bajtów" -#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c +#: shared-bindings/bitbangio/I2C.c msgid "Buffer must be at least length 1" msgstr "Bufor musi mieć długość 1 lub więcej" @@ -666,6 +671,10 @@ msgstr "Bytes musi być między 0 a 255." msgid "CBC blocks must be multiples of 16 bytes" msgstr "Bloki CBC muszą być wielokrotnościami 16 bajtów" +#: supervisor/shared/safe_mode.c +msgid "CIRCUITPY drive could not be found or created." +msgstr "" + #: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c msgid "CRC or checksum was invalid" msgstr "" @@ -909,10 +918,12 @@ msgstr "Nóżka data 0 musi być wyrównana do bajtu" msgid "Data chunk must follow fmt chunk" msgstr "Fragment danych musi następować po fragmencie fmt" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data not supported with directed advertising" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data too large for advertisement packet" msgstr "Zbyt dużo danych pakietu rozgłoszeniowego" @@ -993,6 +1004,7 @@ msgstr "" msgid "Expected tuple of length %d, got %d" msgstr "Oczekiwano krotkę długości %d, otrzymano %d" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Extended advertisements with scan response not supported." msgstr "" @@ -1046,6 +1058,7 @@ msgstr "" msgid "Failed to buffer the sample" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Failed to connect: internal error" msgstr "Nie udało się połączyć: błąd wewnętrzny" @@ -1125,6 +1138,13 @@ msgstr "" msgid "Group already used" msgstr "Grupa już używana" +#: ports/atmel-samd/common-hal/busio/SPI.c ports/cxd56/common-hal/busio/SPI.c +#: ports/espressif/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/nrf/common-hal/busio/SPI.c +#: ports/raspberrypi/common-hal/busio/SPI.c +msgid "Half duplex SPI is not implemented" +msgstr "" + #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/I2C.c #: ports/stm/common-hal/busio/SPI.c ports/stm/common-hal/canio/CAN.c #: ports/stm/common-hal/sdioio/SDCard.c @@ -1279,6 +1299,7 @@ msgstr "" msgid "Invalid AuthMode" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c msgid "Invalid BLE parameter" msgstr "" @@ -1373,6 +1394,10 @@ msgstr "Zła wielkość fragmentu formatu" msgid "Invalid memory access." msgstr "Nieprawidłowy dostęp do pamięci." +#: extmod/vfs_fat_file.c +msgid "Invalid mode" +msgstr "" + #: ports/espressif/common-hal/wifi/Radio.c msgid "Invalid multicast MAC address" msgstr "" @@ -1473,7 +1498,7 @@ msgstr "Niepoprawna długość słowa/bitu" msgid "Key must be 16, 24, or 32 bytes long" msgstr "Klucz musi mieć długość 16, 24 lub 32 bajtów" -#: shared-module/is31fl3741/is31fl3741.c +#: shared-module/is31fl3741/FrameBuffer.c msgid "LED mappings must match display size" msgstr "" @@ -1501,6 +1526,10 @@ msgstr "Nie powiodło się ustawienie pinu MISO." msgid "MOSI pin init failed." msgstr "Nie powiodło się ustawienie pinu MOSI." +#: shared-bindings/is31fl3741/IS31FL3741.c +msgid "Mapping must be a tuple" +msgstr "" + #: shared-module/displayio/Shape.c #, c-format msgid "Maximum x value when mirrored is %d" @@ -1583,6 +1612,10 @@ msgstr "" msgid "Name too long" msgstr "Za długa nazwa" +#: ports/espressif/common-hal/_bleio/__init__.c +msgid "Nimble out of memory" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "" @@ -1603,9 +1636,9 @@ msgstr "Nie znaleziono kanału DMA" msgid "No DMA pacing timer found" msgstr "" -#: shared-module/adafruit_bus_device/I2CDevice.c +#: shared-module/adafruit_bus_device/i2c_device/I2CDevice.c #, c-format -msgid "No I2C device at address: %x" +msgid "No I2C device at address: 0x%x" msgstr "" #: ports/espressif/common-hal/busio/SPI.c @@ -1730,6 +1763,7 @@ msgstr "" msgid "Not a valid IP string" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -1903,7 +1937,7 @@ msgstr "Nóżka nie obsługuje ADC" msgid "Pin interrupt already in use" msgstr "" -#: shared-bindings/adafruit_bus_device/SPIDevice.c +#: shared-bindings/adafruit_bus_device/spi_device/SPIDevice.c #: shared-bindings/digitalio/DigitalInOut.c msgid "Pin is input only" msgstr "" @@ -1985,6 +2019,10 @@ msgstr "Podciągnięcie nieużywane w trybie wyjścia." msgid "RAISE mode is not implemented" msgstr "" +#: ports/raspberrypi/common-hal/countio/Counter.c +msgid "RISE_AND_FALL not available on this chip" +msgstr "" + #: ports/stm/common-hal/os/__init__.c msgid "RNG DeInit Error" msgstr "" @@ -2101,10 +2139,11 @@ msgstr "Częstotliwość próbkowania musi być dodatnia" msgid "Sample rate too high. It must be less than %d" msgstr "Zbyt wysoka częstotliwość próbkowania. Musi być mniejsza niż %d" -#: shared-bindings/is31fl3741/is31fl3741.c +#: shared-bindings/is31fl3741/FrameBuffer.c msgid "Scale dimensions must divide by 3" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Scan already in progess. Stop with stop_scan." msgstr "Skanuj już w toku. Zatrzymaj za pomocą stop_scan." @@ -2263,6 +2302,7 @@ msgstr "Szerokość bitmapy musi być wielokrotnością szerokości kafelka" msgid "Time is in the past." msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2285,6 +2325,7 @@ msgstr "Zbyt wiele magistrali" msgid "Too many displays" msgstr "Zbyt wiele wyświetlaczy" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Total data to write is larger than %q" msgstr "" @@ -2362,7 +2403,7 @@ msgstr "Nie udała się alokacja buforów do konwersji ze znakiem" msgid "Unable to create lock" msgstr "" -#: shared-module/displayio/I2CDisplay.c shared-module/is31fl3741/is31fl3741.c +#: shared-module/displayio/I2CDisplay.c shared-module/is31fl3741/IS31FL3741.c #, c-format msgid "Unable to find I2C Display at %x" msgstr "" @@ -2397,6 +2438,16 @@ msgstr "Nieoczekiwany typ nrfx uuid" msgid "Unhandled ESP TLS error %d %d %x %d" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown BLE error at %s:%d: %d" +msgstr "" + +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown BLE error: %d" +msgstr "" + #: shared-bindings/wifi/Radio.c #, c-format msgid "Unknown failure %d" @@ -2416,11 +2467,21 @@ msgstr "" msgid "Unknown security error: 0x%04x" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error at %s:%d: %d" +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown system firmware error: %04x" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error: %d" +msgstr "" + #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #, c-format msgid "Unmatched number of items on RHS (expected %d, got %d)." @@ -2454,19 +2515,19 @@ msgstr "Zły format" msgid "Unsupported operation" msgstr "Zła operacja" -#: shared-bindings/digitalio/DigitalInOut.c -msgid "Unsupported pull value." -msgstr "Zła wartość podciągnięcia." - #: ports/espressif/common-hal/dualbank/__init__.c msgid "Update Failed" msgstr "" +#: ports/espressif/common-hal/_bleio/Characteristic.c +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length != required fixed length" msgstr "" +#: ports/espressif/common-hal/_bleio/Characteristic.c +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length > max_length" @@ -2524,6 +2585,7 @@ msgstr "" msgid "Woken up by alarm.\n" msgstr "" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Writes not supported on Characteristic" msgstr "" @@ -2627,7 +2689,7 @@ msgstr "" msgid "attributes not supported yet" msgstr "atrybuty nie są jeszcze obsługiwane" -#: extmod/ulab/code/numpy/numerical.c +#: extmod/ulab/code/ulab_tools.c msgid "axis is out of bounds" msgstr "" @@ -2683,11 +2745,11 @@ msgstr "bits_per_sample musi być 8 lub 16" msgid "branch not in range" msgstr "skok poza zakres" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/utils/utils.c msgid "buffer is smaller than requested size" msgstr "" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/utils/utils.c msgid "buffer size must be a multiple of element size" msgstr "" @@ -2737,6 +2799,10 @@ msgstr "kalibracja tylko do odczytu" msgid "calibration value out of range +/-127" msgstr "wartość kalibracji poza zakresem +/-127" +#: shared-module/vectorio/Rectangle.c +msgid "can only be registered in one parent" +msgstr "" + #: py/emitinlinethumb.c msgid "can only have up to 4 parameters to Thumb assembly" msgstr "asembler Thumb może przyjąć do 4 parameterów" @@ -2775,6 +2841,10 @@ msgstr "nie można skonwertować %s do complex" msgid "can't convert '%q' object to %q implicitly" msgstr "nie można automatycznie skonwertować '%q' do '%q'" +#: extmod/ulab/code/numpy/vector.c +msgid "can't convert complex to float" +msgstr "" + #: py/obj.c msgid "can't convert to %q" msgstr "" @@ -2827,6 +2897,10 @@ msgstr "nie można ładować z '%q'" msgid "can't load with '%q' index" msgstr "nie można ładować z indeksem '%q'" +#: py/builtinimport.c +msgid "can't perform relative import" +msgstr "" + #: py/objgenerator.c msgid "can't send non-None value to a just-started generator" msgstr "świeżo stworzony generator może tylko przyjąć None" @@ -2869,6 +2943,14 @@ msgstr "" msgid "cannot cast output with casting rule" msgstr "" +#: extmod/ulab/code/ndarray.c +msgid "cannot convert complex to dtype" +msgstr "" + +#: extmod/ulab/code/ndarray.c +msgid "cannot convert complex type" +msgstr "" + #: py/objtype.c msgid "cannot create '%q' instances" msgstr "nie można tworzyć instancji '%q'" @@ -2881,10 +2963,6 @@ msgstr "nie można stworzyć instancji" msgid "cannot import name %q" msgstr "nie można zaimportować nazwy %q" -#: py/builtinimport.c -msgid "cannot perform relative import" -msgstr "nie można wykonać relatywnego importu" - #: extmod/moductypes.c msgid "cannot unambiguously get sizeof scalar" msgstr "" @@ -3061,6 +3139,10 @@ msgstr "dzielenie przez zero" msgid "divisor must be 4" msgstr "" +#: extmod/ulab/code/numpy/vector.c +msgid "dtype must be float, or complex" +msgstr "" + #: py/objdeque.c msgid "empty" msgstr "puste" @@ -3164,7 +3246,7 @@ msgstr "" msgid "first argument must be a function" msgstr "pierwszy argument musi być funkcją" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "first argument must be a tuple of ndarrays" msgstr "" @@ -3229,6 +3311,10 @@ msgstr "" msgid "function is defined for ndarrays only" msgstr "" +#: extmod/ulab/code/numpy/carray/carray.c +msgid "function is implemented for ndarrays only" +msgstr "" + #: py/argcheck.c #, c-format msgid "function missing %d required positional arguments" @@ -3342,7 +3428,7 @@ msgstr "wtrącony asembler musi być funkcją" msgid "input and output shapes are not compatible" msgstr "" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "input argument must be an integer, a tuple, or a list" msgstr "" @@ -3350,7 +3436,7 @@ msgstr "" msgid "input array length must be power of 2" msgstr "długość tablicy wejściowej musi być potęgą 2" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "input arrays are not compatible" msgstr "" @@ -3358,6 +3444,10 @@ msgstr "" msgid "input data must be an iterable" msgstr "" +#: extmod/ulab/code/numpy/vector.c +msgid "input dtype must be float or complex" +msgstr "" + #: extmod/ulab/code/numpy/linalg/linalg.c msgid "input matrix is asymmetric" msgstr "" @@ -3367,18 +3457,26 @@ msgstr "" msgid "input matrix is singular" msgstr "" +#: extmod/ulab/code/numpy/carray/carray.c +msgid "input must be a 1D ndarray" +msgstr "" + #: extmod/ulab/code/scipy/linalg/linalg.c extmod/ulab/code/user/user.c msgid "input must be a dense ndarray" msgstr "" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "input must be a tensor of rank 2" msgstr "" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/user/user.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/user/user.c msgid "input must be an ndarray" msgstr "" +#: extmod/ulab/code/numpy/carray/carray.c +msgid "input must be an ndarray, or a scalar" +msgstr "" + #: extmod/ulab/code/scipy/signal/signal.c msgid "input must be one-dimensional" msgstr "" @@ -3556,6 +3654,11 @@ msgstr "błąd domeny" msgid "matrix is not positive definite" msgstr "" +#: ports/espressif/common-hal/wifi/Radio.c +msgid "max_connections must be between 0 and 10" +msgstr "" + +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c #, c-format @@ -3709,6 +3812,7 @@ msgstr "nie ma takiego atrybutu" msgid "non-Device in %q" msgstr "" +#: ports/espressif/common-hal/_bleio/Connection.c #: ports/nrf/common-hal/_bleio/Connection.c msgid "non-UUID found in service_uuids_whitelist" msgstr "" @@ -3749,7 +3853,11 @@ msgstr "nie wszystkie argumenty wykorzystane w formatowaniu" msgid "not enough arguments for format string" msgstr "nie dość argumentów przy formatowaniu" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/carray/carray_tools.c +msgid "not implemented for complex dtype" +msgstr "" + +#: extmod/ulab/code/numpy/create.c msgid "number of points must be at least 2" msgstr "liczba punktów musi wynosić co najmniej 2" @@ -3807,7 +3915,7 @@ msgstr "wymagany obiekt z protokołem buforu" msgid "odd-length string" msgstr "łańcuch o nieparzystej długości" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/utils/utils.c msgid "offset is too large" msgstr "" @@ -3815,7 +3923,7 @@ msgstr "" msgid "offset must be >= 0" msgstr "" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "offset must be non-negative and no greater than buffer length" msgstr "" @@ -3928,6 +4036,10 @@ msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "" "pixel_shader musi być typu displayio.Palette lub dispalyio.ColorConverter" +#: extmod/vfs_posix_file.c +msgid "poll on file not available on win32" +msgstr "" + #: shared-module/vectorio/Polygon.c msgid "polygon can only be registered in one parent" msgstr "" @@ -3957,18 +4069,27 @@ msgstr "trzeci argument pow() nie może być 0" msgid "pow() with 3 arguments requires integers" msgstr "trzyargumentowe pow() wymaga liczb całkowitych" +#: ports/espressif/boards/adafruit_esp32s2_camera/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tft/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h #: ports/espressif/boards/adafruit_funhouse/mpconfigboard.h #: ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h +#: ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h +#: ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h #: ports/espressif/boards/atmegazero_esp32s2/mpconfigboard.h #: ports/espressif/boards/crumpspace_crumps2/mpconfigboard.h #: ports/espressif/boards/electroniccats_bastwifi/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s2_devkitc_1_n4r2/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_box/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h #: ports/espressif/boards/espressif_hmi_devkit_1/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1.3/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1/mpconfigboard.h @@ -3994,7 +4115,10 @@ msgstr "trzyargumentowe pow() wymaga liczb całkowitych" #: ports/espressif/boards/unexpectedmaker_feathers2/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_neo/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_prerelease/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_feathers3/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_pros3/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_tinys2/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_tinys3/mpconfigboard.h msgid "pressing boot button at start up.\n" msgstr "" @@ -4292,7 +4416,7 @@ msgstr "" msgid "too many arguments provided with the given format" msgstr "zbyt wiele argumentów podanych dla tego formatu" -#: extmod/ulab/code/ndarray.c extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/ndarray.c extmod/ulab/code/numpy/create.c msgid "too many dimensions" msgstr "" @@ -4476,7 +4600,7 @@ msgstr "" msgid "width must be from 2 to 8 (inclusive), not %d" msgstr "" -#: shared-bindings/is31fl3741/is31fl3741.c +#: shared-bindings/is31fl3741/FrameBuffer.c #: shared-bindings/rgbmatrix/RGBMatrix.c msgid "width must be greater than zero" msgstr "szerokość musi być większa niż zero" @@ -4493,7 +4617,7 @@ msgstr "" msgid "wrong axis index" msgstr "" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "wrong axis specified" msgstr "" @@ -4501,7 +4625,11 @@ msgstr "" msgid "wrong input type" msgstr "nieprawidłowy typ wejścia" -#: extmod/ulab/code/ulab_create.c py/objarray.c py/objstr.c +#: extmod/ulab/code/numpy/transform.c +msgid "wrong length of condition array" +msgstr "" + +#: extmod/ulab/code/numpy/create.c py/objarray.c py/objstr.c msgid "wrong number of arguments" msgstr "zła liczba argumentów" @@ -4545,6 +4673,12 @@ msgstr "" msgid "zi must be of shape (n_section, 2)" msgstr "" +#~ msgid "cannot perform relative import" +#~ msgstr "nie można wykonać relatywnego importu" + +#~ msgid "Unsupported pull value." +#~ msgstr "Zła wartość podciągnięcia." + #, c-format #~ msgid "" #~ "Welcome to Adafruit CircuitPython %s!\n" diff --git a/locale/pt_BR.po b/locale/pt_BR.po index 4e79af465e..d4e939b6c7 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -6,7 +6,7 @@ msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-01-04 12:55-0600\n" -"PO-Revision-Date: 2021-11-24 23:51+0000\n" +"PO-Revision-Date: 2022-02-21 08:55+0000\n" "Last-Translator: Wellington Terumi Uemura \n" "Language-Team: \n" "Language: pt_BR\n" @@ -14,7 +14,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=n > 1;\n" -"X-Generator: Weblate 4.10-dev\n" +"X-Generator: Weblate 4.11-dev\n" #: main.c msgid "" @@ -108,7 +108,7 @@ msgstr "Os índices %q devem ser inteiros, e não %s" msgid "%q length must be %d-%d" msgstr "o comprimento %q deve ser %d-%d" -#: shared-bindings/usb_hid/Device.c +#: shared-bindings/busio/I2C.c shared-bindings/usb_hid/Device.c msgid "%q length must be >= 1" msgstr "o comprimento %q deve ser >=1" @@ -153,6 +153,10 @@ msgstr "%q deve estar entre %d e %d" msgid "%q must be of type %q" msgstr "%q deve ser do tipo %q" +#: shared-bindings/digitalio/Pull.c +msgid "%q must be of type %q or None" +msgstr "%q deve ser do tipo %q ou nenhum" + #: ports/atmel-samd/common-hal/busio/UART.c msgid "%q must be power of 2" msgstr "%q deve ser a potência de 2" @@ -455,6 +459,7 @@ msgstr "Todos os temporizadores para este pino estão em uso" msgid "All timers in use" msgstr "Todos os temporizadores em uso" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Already advertising." msgstr "Já está anunciando." @@ -594,7 +599,7 @@ msgstr "Ambos os pinos devem suportar interrupções de hardware" #: shared-bindings/displayio/Display.c #: shared-bindings/framebufferio/FramebufferDisplay.c -#: shared-bindings/is31fl3741/is31fl3741.c +#: shared-bindings/is31fl3741/FrameBuffer.c #: shared-bindings/rgbmatrix/RGBMatrix.c msgid "Brightness must be 0-1.0" msgstr "O brilho deve ser 0-1,0" @@ -646,7 +651,7 @@ msgstr "O comprimento do Buffer deve ser um múltiplo de 512" msgid "Buffer must be a multiple of 512 bytes" msgstr "O buffer deve ser um múltiplo de 512 bytes" -#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c +#: shared-bindings/bitbangio/I2C.c msgid "Buffer must be at least length 1" msgstr "O comprimento do buffer deve ter pelo menos 1" @@ -679,6 +684,10 @@ msgstr "Os bytes devem estar entre 0 e 255." msgid "CBC blocks must be multiples of 16 bytes" msgstr "Os blocos CBC devem ter múltiplos de 16 bytes" +#: supervisor/shared/safe_mode.c +msgid "CIRCUITPY drive could not be found or created." +msgstr "A unidade CIRCUITPY não pôde ser encontrada nem criada." + #: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c msgid "CRC or checksum was invalid" msgstr "CRC ou checksum inválido" @@ -927,10 +936,12 @@ msgstr "O pino de dados 0 deve ser alinhado por bytes" msgid "Data chunk must follow fmt chunk" msgstr "Pedaço de dados deve seguir o pedaço de cortes" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data not supported with directed advertising" msgstr "Os dados não são compatíveis com publicidade direcionada" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data too large for advertisement packet" msgstr "Os dados são grandes demais para o pacote de publicidade" @@ -1011,6 +1022,7 @@ msgstr "Um alarme era esperado" msgid "Expected tuple of length %d, got %d" msgstr "Tupla esperada com comprimento %d, obteve %d" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Extended advertisements with scan response not supported." msgstr "Anúncios estendidos não compatíveis com a resposta da varredura." @@ -1064,6 +1076,7 @@ msgstr "Houve uma falha na alocação da memória para a varredura do Wifi" msgid "Failed to buffer the sample" msgstr "Houve uma falha ao fazer uma memória prévia (buffer) da amostra" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Failed to connect: internal error" msgstr "Falha ao conectar: erro interno" @@ -1145,6 +1158,13 @@ msgstr "Falha Genérica" msgid "Group already used" msgstr "O grupo já está em uso" +#: ports/atmel-samd/common-hal/busio/SPI.c ports/cxd56/common-hal/busio/SPI.c +#: ports/espressif/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/nrf/common-hal/busio/SPI.c +#: ports/raspberrypi/common-hal/busio/SPI.c +msgid "Half duplex SPI is not implemented" +msgstr "O SPI half duplex ainda não está implementado" + #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/I2C.c #: ports/stm/common-hal/busio/SPI.c ports/stm/common-hal/canio/CAN.c #: ports/stm/common-hal/sdioio/SDCard.c @@ -1305,6 +1325,7 @@ msgstr "Valor inválido da unidade ADC" msgid "Invalid AuthMode" msgstr "AuthMode inválido" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c msgid "Invalid BLE parameter" msgstr "Parâmetro BLE inválido" @@ -1399,6 +1420,10 @@ msgstr "Tamanho do pedaço de formato inválido" msgid "Invalid memory access." msgstr "O acesso da memória é inválido." +#: extmod/vfs_fat_file.c +msgid "Invalid mode" +msgstr "Modo inválido" + #: ports/espressif/common-hal/wifi/Radio.c msgid "Invalid multicast MAC address" msgstr "Endereço MAC multicast inválido" @@ -1499,7 +1524,7 @@ msgstr "O comprimento do bit/palavra são inválidos" msgid "Key must be 16, 24, or 32 bytes long" msgstr "A chave deve ter 16, 24 ou 32 bytes de comprimento" -#: shared-module/is31fl3741/is31fl3741.c +#: shared-module/is31fl3741/FrameBuffer.c msgid "LED mappings must match display size" msgstr "Os mapeamentos do led devem corresponder ao tamanho do display" @@ -1527,6 +1552,10 @@ msgstr "A inicialização do pino MISO falhou." msgid "MOSI pin init failed." msgstr "Inicialização do pino MOSI falhou." +#: shared-bindings/is31fl3741/IS31FL3741.c +msgid "Mapping must be a tuple" +msgstr "O mapeamento deve ser uma tupla" + #: shared-module/displayio/Shape.c #, c-format msgid "Maximum x value when mirrored is %d" @@ -1609,6 +1638,10 @@ msgstr "Erro NVS" msgid "Name too long" msgstr "Nome muito longo" +#: ports/espressif/common-hal/_bleio/__init__.c +msgid "Nimble out of memory" +msgstr "Ágil fora da memória" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "Não há nenhum CCCD para esta característica" @@ -1629,10 +1662,10 @@ msgstr "Nenhum canal DMA foi encontrado" msgid "No DMA pacing timer found" msgstr "Nenhum temporizador DMA foi encontrado" -#: shared-module/adafruit_bus_device/I2CDevice.c +#: shared-module/adafruit_bus_device/i2c_device/I2CDevice.c #, c-format -msgid "No I2C device at address: %x" -msgstr "Nenhum dispositivo I2C no endereço: %x" +msgid "No I2C device at address: 0x%x" +msgstr "Não há nenhum dispositivo I2C no endereço: 0x%x" #: ports/espressif/common-hal/busio/SPI.c #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c @@ -1758,6 +1791,7 @@ msgstr "O firmware do sistema nórdico está sem memória" msgid "Not a valid IP string" msgstr "Não é uma sequência válida de IP" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -1940,7 +1974,7 @@ msgstr "O pino não tem recursos de ADC" msgid "Pin interrupt already in use" msgstr "A interrupção do pino já está em uso" -#: shared-bindings/adafruit_bus_device/SPIDevice.c +#: shared-bindings/adafruit_bus_device/spi_device/SPIDevice.c #: shared-bindings/digitalio/DigitalInOut.c msgid "Pin is input only" msgstr "Apenas o pino de entrada" @@ -2030,6 +2064,10 @@ msgstr "O Pull não foi usado quando a direção for gerada." msgid "RAISE mode is not implemented" msgstr "O modo RAISE não foi implementado" +#: ports/raspberrypi/common-hal/countio/Counter.c +msgid "RISE_AND_FALL not available on this chip" +msgstr "RISE_AND_FALL não está disponível neste chip" + #: ports/stm/common-hal/os/__init__.c msgid "RNG DeInit Error" msgstr "Erro DeInit RNG" @@ -2146,10 +2184,11 @@ msgstr "A taxa de amostragem deve ser positiva" msgid "Sample rate too high. It must be less than %d" msgstr "Taxa de amostragem muito alta. Deve ser menor que %d" -#: shared-bindings/is31fl3741/is31fl3741.c +#: shared-bindings/is31fl3741/FrameBuffer.c msgid "Scale dimensions must divide by 3" msgstr "As dimensões da escala devem ser poder ser divididas por 3" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Scan already in progess. Stop with stop_scan." msgstr "O escaneamento já está em andamento. Interrompa com stop_scan." @@ -2320,6 +2359,7 @@ msgstr "A largura do bloco deve dividir exatamente com a largura do bitmap" msgid "Time is in the past." msgstr "O tempo está no passado." +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2344,6 +2384,7 @@ msgstr "Muitos barramentos estão sendo exibidos" msgid "Too many displays" msgstr "Exibições demais" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Total data to write is larger than %q" msgstr "O total dos dados que serão escritos é maior do que %q" @@ -2422,7 +2463,7 @@ msgstr "Não é possível alocar buffers para conversão assinada" msgid "Unable to create lock" msgstr "Não é possível criar um lock" -#: shared-module/displayio/I2CDisplay.c shared-module/is31fl3741/is31fl3741.c +#: shared-module/displayio/I2CDisplay.c shared-module/is31fl3741/IS31FL3741.c #, c-format msgid "Unable to find I2C Display at %x" msgstr "Não foi possível encontrar a tela I2C no %x" @@ -2457,6 +2498,16 @@ msgstr "Tipo uuid nrfx inesperado" msgid "Unhandled ESP TLS error %d %d %x %d" msgstr "Erro não tratado do ESP TLS %d %d %x %d" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown BLE error at %s:%d: %d" +msgstr "Houve um erro BLE desconhecido em %s:%d: %d" + +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown BLE error: %d" +msgstr "Houve um erro BLE desconhecido: %d" + #: shared-bindings/wifi/Radio.c #, c-format msgid "Unknown failure %d" @@ -2476,11 +2527,21 @@ msgstr "Motivo desconhecido." msgid "Unknown security error: 0x%04x" msgstr "Erro de segurança desconhecido: 0x%04x" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error at %s:%d: %d" +msgstr "Ocorreu um erro desconhecido no firmware do sistema em %s:%d: %d" + #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown system firmware error: %04x" msgstr "Erro desconhecido do firmware: %04x" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error: %d" +msgstr "Ocorreu um erro desconhecido no firmware do sistema: %d" + #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #, c-format msgid "Unmatched number of items on RHS (expected %d, got %d)." @@ -2516,19 +2577,19 @@ msgstr "Formato não suportado" msgid "Unsupported operation" msgstr "Operação não suportada" -#: shared-bindings/digitalio/DigitalInOut.c -msgid "Unsupported pull value." -msgstr "O valor pull não é compatível." - #: ports/espressif/common-hal/dualbank/__init__.c msgid "Update Failed" msgstr "A atualização falou" +#: ports/espressif/common-hal/_bleio/Characteristic.c +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length != required fixed length" msgstr "Comprimento do valor != comprimento fixo necessário" +#: ports/espressif/common-hal/_bleio/Characteristic.c +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length > max_length" @@ -2595,6 +2656,7 @@ msgstr "A senha do Wi-Fi deve ter entre 8 e 63 caracteres" msgid "Woken up by alarm.\n" msgstr "Foi despertado através do alarme.\n" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Writes not supported on Characteristic" msgstr "A escrita não é compatível na Característica" @@ -2700,7 +2762,7 @@ msgstr "tente obter argmin/argmax de uma sequência vazia" msgid "attributes not supported yet" msgstr "atributos ainda não suportados" -#: extmod/ulab/code/numpy/numerical.c +#: extmod/ulab/code/ulab_tools.c msgid "axis is out of bounds" msgstr "o eixo está fora dos limites" @@ -2756,11 +2818,11 @@ msgstr "bits_per_sample deve ser 8 ou 16" msgid "branch not in range" msgstr "ramo fora do alcance" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/utils/utils.c msgid "buffer is smaller than requested size" msgstr "o tamanho do buffer é menor do que o tamanho que foi solicitado" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/utils/utils.c msgid "buffer size must be a multiple of element size" msgstr "o tamanho do buffer deve ser um múltiplo do tamanho do elemento" @@ -2810,6 +2872,10 @@ msgstr "Calibração é somente leitura" msgid "calibration value out of range +/-127" msgstr "Valor de calibração fora do intervalo +/- 127" +#: shared-module/vectorio/Rectangle.c +msgid "can only be registered in one parent" +msgstr "pode ser registrado apenas numa principal" + #: py/emitinlinethumb.c msgid "can only have up to 4 parameters to Thumb assembly" msgstr "só pode haver até 4 parâmetros para a montagem Thumb" @@ -2848,6 +2914,10 @@ msgstr "Não é possível converter %s para complex" msgid "can't convert '%q' object to %q implicitly" msgstr "não é possível converter implicitamente o objeto '%q' para %q" +#: extmod/ulab/code/numpy/vector.c +msgid "can't convert complex to float" +msgstr "não foi possível converter complexo em flutuante" + #: py/obj.c msgid "can't convert to %q" msgstr "não é possível converter para %q" @@ -2900,6 +2970,10 @@ msgstr "não é possível carregar a partir de '%q'" msgid "can't load with '%q' index" msgstr "não é possível carregar com o índice '%q'" +#: py/builtinimport.c +msgid "can't perform relative import" +msgstr "não é possível realizar a importação relativa" + #: py/objgenerator.c msgid "can't send non-None value to a just-started generator" msgstr "" @@ -2946,6 +3020,14 @@ msgstr "não é possível atribuir uma nova forma" msgid "cannot cast output with casting rule" msgstr "não pode lançar a saída com a regra de fundição" +#: extmod/ulab/code/ndarray.c +msgid "cannot convert complex to dtype" +msgstr "não foi possível converter complexo em dtype" + +#: extmod/ulab/code/ndarray.c +msgid "cannot convert complex type" +msgstr "não foi possível converter o tipo complexo" + #: py/objtype.c msgid "cannot create '%q' instances" msgstr "não é possível criar instâncias '%q'" @@ -2958,10 +3040,6 @@ msgstr "não é possível criar instância" msgid "cannot import name %q" msgstr "não pode importar nome %q" -#: py/builtinimport.c -msgid "cannot perform relative import" -msgstr "não pode executar a importação relativa" - #: extmod/moductypes.c msgid "cannot unambiguously get sizeof scalar" msgstr "Não é possível obter de forma inequívoca a escala do sizeof" @@ -3142,6 +3220,10 @@ msgstr "divisão por zero" msgid "divisor must be 4" msgstr "o divisor deve ser 4" +#: extmod/ulab/code/numpy/vector.c +msgid "dtype must be float, or complex" +msgstr "dtype deve ser flutuante ou complexo" + #: py/objdeque.c msgid "empty" msgstr "vazio" @@ -3245,7 +3327,7 @@ msgstr "o primeiro argumento deve ser chamável" msgid "first argument must be a function" msgstr "o primeiro argumento deve ser uma função" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "first argument must be a tuple of ndarrays" msgstr "o primeiro argumento deve ser um tuple de ndarrays" @@ -3310,6 +3392,10 @@ msgstr "a função tem o mesmo sinal nas extremidades do intervalo" msgid "function is defined for ndarrays only" msgstr "A função é definida apenas para ndarrays" +#: extmod/ulab/code/numpy/carray/carray.c +msgid "function is implemented for ndarrays only" +msgstr "a função está implementada apenas para ndarrays" + #: py/argcheck.c #, c-format msgid "function missing %d required positional arguments" @@ -3423,7 +3509,7 @@ msgstr "o assembler em linha deve ser uma função" msgid "input and output shapes are not compatible" msgstr "as formas de entrada e saída não são compatíveis" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "input argument must be an integer, a tuple, or a list" msgstr "" "argumento da entrada deve ser um número inteiro, uma tupla ou uma lista" @@ -3432,7 +3518,7 @@ msgstr "" msgid "input array length must be power of 2" msgstr "comprimento da matriz da entrada deve ter potência de 2" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "input arrays are not compatible" msgstr "as matrizes da entrada não são compatíveis" @@ -3440,6 +3526,10 @@ msgstr "as matrizes da entrada não são compatíveis" msgid "input data must be an iterable" msgstr "os dados da entrada devem ser iteráveis" +#: extmod/ulab/code/numpy/vector.c +msgid "input dtype must be float or complex" +msgstr "o tipo da entrada dtype deve ser flutuante ou complexo" + #: extmod/ulab/code/numpy/linalg/linalg.c msgid "input matrix is asymmetric" msgstr "a matriz da entrada é assimétrica" @@ -3449,18 +3539,26 @@ msgstr "a matriz da entrada é assimétrica" msgid "input matrix is singular" msgstr "a matriz da entrada é singular" +#: extmod/ulab/code/numpy/carray/carray.c +msgid "input must be a 1D ndarray" +msgstr "a entrada deve ser um 1D ndarray" + #: extmod/ulab/code/scipy/linalg/linalg.c extmod/ulab/code/user/user.c msgid "input must be a dense ndarray" msgstr "a entrada deve ser um ndarray denso" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "input must be a tensor of rank 2" msgstr "a entrada dos dados deve ser um tensor de nível 2" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/user/user.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/user/user.c msgid "input must be an ndarray" msgstr "a entrada deve ser um ndarray" +#: extmod/ulab/code/numpy/carray/carray.c +msgid "input must be an ndarray, or a scalar" +msgstr "a entrada deve ser um ndarray ou um escalar" + #: extmod/ulab/code/scipy/signal/signal.c msgid "input must be one-dimensional" msgstr "a entrada deve ser unidimensional" @@ -3641,6 +3739,11 @@ msgstr "erro de domínio matemático" msgid "matrix is not positive definite" msgstr "a matriz não é definitiva positiva" +#: ports/espressif/common-hal/wifi/Radio.c +msgid "max_connections must be between 0 and 10" +msgstr "max_connections deve estar entre 0 e 10" + +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c #, c-format @@ -3796,6 +3899,7 @@ msgstr "não há tal atributo" msgid "non-Device in %q" msgstr "não dispositivo em %q" +#: ports/espressif/common-hal/_bleio/Connection.c #: ports/nrf/common-hal/_bleio/Connection.c msgid "non-UUID found in service_uuids_whitelist" msgstr "um não UUID foi encontrado na lista service_uuids_whitelist" @@ -3836,7 +3940,11 @@ msgstr "nem todos os argumentos são convertidos durante a formatação da strin msgid "not enough arguments for format string" msgstr "argumentos insuficientes para o formato da string" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/carray/carray_tools.c +msgid "not implemented for complex dtype" +msgstr "não foi implementado para dtype complexo" + +#: extmod/ulab/code/numpy/create.c msgid "number of points must be at least 2" msgstr "a quantidade dos pontos deve ser pelo menos 2" @@ -3894,7 +4002,7 @@ msgstr "é necessário objeto com protocolo do buffer" msgid "odd-length string" msgstr "sequência com comprimento ímpar" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/utils/utils.c msgid "offset is too large" msgstr "o offset é muito grande" @@ -3902,7 +4010,7 @@ msgstr "o offset é muito grande" msgid "offset must be >= 0" msgstr "o offset deve ser >= 0" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "offset must be non-negative and no greater than buffer length" msgstr "o offset deve ser positivo e não maior do que o comprimento do buffer" @@ -4019,6 +4127,10 @@ msgstr "o valor do pixel requer bits demais" msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "o pixel_shader deve ser displayio.Palette ou displayio.ColorConverter" +#: extmod/vfs_posix_file.c +msgid "poll on file not available on win32" +msgstr "a sondagem no arquivo não está disponível no win32" + #: shared-module/vectorio/Polygon.c msgid "polygon can only be registered in one parent" msgstr "o polígono só pode ser registrado em um pai" @@ -4048,18 +4160,27 @@ msgstr "O terceiro argumento pow() não pode ser 0" msgid "pow() with 3 arguments requires integers" msgstr "o pow() com 3 argumentos requer números inteiros" +#: ports/espressif/boards/adafruit_esp32s2_camera/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tft/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h #: ports/espressif/boards/adafruit_funhouse/mpconfigboard.h #: ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h +#: ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h +#: ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h #: ports/espressif/boards/atmegazero_esp32s2/mpconfigboard.h #: ports/espressif/boards/crumpspace_crumps2/mpconfigboard.h #: ports/espressif/boards/electroniccats_bastwifi/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s2_devkitc_1_n4r2/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_box/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h #: ports/espressif/boards/espressif_hmi_devkit_1/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1.3/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1/mpconfigboard.h @@ -4085,7 +4206,10 @@ msgstr "o pow() com 3 argumentos requer números inteiros" #: ports/espressif/boards/unexpectedmaker_feathers2/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_neo/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_prerelease/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_feathers3/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_pros3/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_tinys2/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_tinys3/mpconfigboard.h msgid "pressing boot button at start up.\n" msgstr "pressionando o botão de boot na inicialização.\n" @@ -4384,7 +4508,7 @@ msgstr "os tobytes podem ser invocados apenas nas matrizes densas" msgid "too many arguments provided with the given format" msgstr "Muitos argumentos fornecidos com o formato dado" -#: extmod/ulab/code/ndarray.c extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/ndarray.c extmod/ulab/code/numpy/create.c msgid "too many dimensions" msgstr "dimensões demais" @@ -4568,7 +4692,7 @@ msgstr "o tempo limite do watchdog deve ser maior que 0" msgid "width must be from 2 to 8 (inclusive), not %d" msgstr "a largura deve ser entre 2 a 8 (inclusive), não %d" -#: shared-bindings/is31fl3741/is31fl3741.c +#: shared-bindings/is31fl3741/FrameBuffer.c #: shared-bindings/rgbmatrix/RGBMatrix.c msgid "width must be greater than zero" msgstr "a largura deve ser maior que zero" @@ -4585,7 +4709,7 @@ msgstr "a janela deve ser <= intervalo" msgid "wrong axis index" msgstr "índice do eixo errado" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "wrong axis specified" msgstr "um eixo errado foi definido" @@ -4593,7 +4717,11 @@ msgstr "um eixo errado foi definido" msgid "wrong input type" msgstr "tipo da entrada incorreta" -#: extmod/ulab/code/ulab_create.c py/objarray.c py/objstr.c +#: extmod/ulab/code/numpy/transform.c +msgid "wrong length of condition array" +msgstr "comprimento errado na condição da matriz" + +#: extmod/ulab/code/numpy/create.c py/objarray.c py/objstr.c msgid "wrong number of arguments" msgstr "quantidade errada dos argumentos" @@ -4637,6 +4765,16 @@ msgstr "zi deve ser de um tipo float" msgid "zi must be of shape (n_section, 2)" msgstr "zi deve estar na forma (n_section, 2)" +#~ msgid "cannot perform relative import" +#~ msgstr "não pode executar a importação relativa" + +#, c-format +#~ msgid "No I2C device at address: %x" +#~ msgstr "Nenhum dispositivo I2C no endereço: %x" + +#~ msgid "Unsupported pull value." +#~ msgstr "O valor pull não é compatível." + #~ msgid "Station must be started" #~ msgstr "A estação deve ser iniciada" diff --git a/locale/ru.po b/locale/ru.po index 9c8da59303..c5cacfb4f4 100644 --- a/locale/ru.po +++ b/locale/ru.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"PO-Revision-Date: 2021-12-04 12:51+0000\n" +"PO-Revision-Date: 2022-02-14 18:08+0000\n" "Last-Translator: Clay \n" "Language-Team: none\n" "Language: ru\n" @@ -16,7 +16,7 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n" "%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" -"X-Generator: Weblate 4.10-dev\n" +"X-Generator: Weblate 4.11-dev\n" #: main.c msgid "" @@ -77,12 +77,10 @@ msgid "" msgstr "%d адресные пины, %d rgb пины и %d плитки указывают высоту %d а не %d" #: shared-bindings/microcontroller/Pin.c -#, fuzzy msgid "%q and %q contain duplicate pins" msgstr "%q и %q содержат пины-дупликаты" #: shared-bindings/microcontroller/Pin.c -#, fuzzy msgid "%q contains duplicate pins" msgstr "%q содержит пины-дупликаты" @@ -111,7 +109,7 @@ msgstr "Индексы %q должны быть целыми числами, а msgid "%q length must be %d-%d" msgstr "Длинна %q должна быть %d-%d" -#: shared-bindings/usb_hid/Device.c +#: shared-bindings/busio/I2C.c shared-bindings/usb_hid/Device.c msgid "%q length must be >= 1" msgstr "Длинна %q должна быть >= 1" @@ -156,6 +154,10 @@ msgstr "%q должен быть между %d и %d" msgid "%q must be of type %q" msgstr "%q должен быть типа %q" +#: shared-bindings/digitalio/Pull.c +msgid "%q must be of type %q or None" +msgstr "" + #: ports/atmel-samd/common-hal/busio/UART.c msgid "%q must be power of 2" msgstr "%q должен быть во 2-й степени" @@ -435,7 +437,7 @@ msgstr "Все каналы событий синхронизации уже и #: shared-bindings/pwmio/PWMOut.c msgid "All timers for this pin are in use" -msgstr "Все таймеры для этого Пина уже используются" +msgstr "Все таймеры для этого пина уже используются" #: ports/atmel-samd/common-hal/_pew/PewPew.c #: ports/atmel-samd/common-hal/audioio/AudioOut.c @@ -454,6 +456,7 @@ msgstr "Все таймеры для этого Пина уже использу msgid "All timers in use" msgstr "Все таймеры уже используются" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Already advertising." msgstr "Уже объявляемся (advertising)." @@ -592,7 +595,7 @@ msgstr "Оба пина должны поддерживать аппаратны #: shared-bindings/displayio/Display.c #: shared-bindings/framebufferio/FramebufferDisplay.c -#: shared-bindings/is31fl3741/is31fl3741.c +#: shared-bindings/is31fl3741/FrameBuffer.c #: shared-bindings/rgbmatrix/RGBMatrix.c msgid "Brightness must be 0-1.0" msgstr "Яркость должна быть в диапазоне от 0 до 1.0" @@ -644,7 +647,7 @@ msgstr "Размер буфера должен быть кратен 512" msgid "Buffer must be a multiple of 512 bytes" msgstr "Буфер должен быть кратен 512" -#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c +#: shared-bindings/bitbangio/I2C.c msgid "Buffer must be at least length 1" msgstr "Буфер должен быть размером не менее 1" @@ -677,6 +680,10 @@ msgstr "Bytes должен быть в диапазоне от 0 до 255." msgid "CBC blocks must be multiples of 16 bytes" msgstr "Блоки CBC должны быть кратны 16 байтам" +#: supervisor/shared/safe_mode.c +msgid "CIRCUITPY drive could not be found or created." +msgstr "" + #: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c msgid "CRC or checksum was invalid" msgstr "CRC или контрольная сумма неправильная" @@ -693,12 +700,12 @@ msgstr "Сигнал из глубокого сна может подавать msgid "Can only alarm on one low pin while others alarm high from deep sleep." msgstr "" "Сигнал из глубокого сна может подаваться по низкому уровню только на одном " -"выводе, пока остальные сигналят по высокому уровню." +"пане, пока остальные подают сигнал по высокому уровню." #: ports/espressif/common-hal/alarm/pin/PinAlarm.c msgid "Can only alarm on two low pins from deep sleep." msgstr "" -"Сигнал из глубокого сна может подаваться только на двух выводах по низкому " +"Сигнал из глубокого сна может подаваться только на двух пинах по низкому " "уровню." #: ports/nrf/common-hal/_bleio/Characteristic.c @@ -739,16 +746,16 @@ msgstr "" #: ports/atmel-samd/common-hal/audioio/AudioOut.c msgid "Cannot output both channels on the same pin" -msgstr "Невозможно вывести оба канала на один вывод" +msgstr "Невозможно вывести оба канала на один пин" #: ports/espressif/common-hal/alarm/pin/PinAlarm.c msgid "Cannot pull on input-only pin." msgstr "" -"Невозможно установить подтяжку на выводе, предназначенном только для ввода." +"Невозможно установить подтяжку на пине, предназначенном только для ввода." #: shared-module/bitbangio/SPI.c msgid "Cannot read without MISO pin." -msgstr "Считывание невозможно без вывода MISO." +msgstr "Считывание невозможно без пина MISO." #: shared-bindings/audiobusio/PDMIn.c msgid "Cannot record to a file" @@ -783,7 +790,7 @@ msgstr "Срез субкласса невозможен" #: shared-module/bitbangio/SPI.c msgid "Cannot transfer without MOSI and MISO pins." -msgstr "Передача данных невозможна без выводов MOSI и MISO." +msgstr "Передача данных невозможна без пинов MOSI и MISO." #: shared-bindings/pwmio/PWMOut.c msgid "Cannot vary frequency on a timer that is already in use" @@ -792,11 +799,11 @@ msgstr "Невозможно изменить частоту на таймере #: ports/espressif/common-hal/alarm/pin/PinAlarm.c #: ports/nrf/common-hal/alarm/pin/PinAlarm.c msgid "Cannot wake on pin edge. Only level." -msgstr "Невозможно проснуться по pin edge. Только по уровню." +msgstr "Невозможно проснуться по спаду/росту на пине. Только по уровню." #: shared-module/bitbangio/SPI.c msgid "Cannot write without MOSI pin." -msgstr "Запись невозможна без вывода MOSI." +msgstr "Запись невозможна без пина MOSI." #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "CharacteristicBuffer writing not provided" @@ -812,7 +819,7 @@ msgstr "CircuitPython не смог выделить heap." #: shared-module/bitbangio/SPI.c msgid "Clock pin init failed." -msgstr "Не удалось инициализировать тактовый вывод." +msgstr "Не удалось инициализировать пин Clock." #: shared-module/bitbangio/I2C.c msgid "Clock stretch too long" @@ -921,16 +928,18 @@ msgstr "ЦАП уже используется" #: ports/atmel-samd/common-hal/paralleldisplay/ParallelBus.c #: ports/nrf/common-hal/paralleldisplay/ParallelBus.c msgid "Data 0 pin must be byte aligned" -msgstr "Вывод data 0 должен быть выровнен по байтам" +msgstr "Пин data 0 должен быть байтово выровнен" #: shared-module/audiocore/WaveFile.c msgid "Data chunk must follow fmt chunk" msgstr "Блок данных должен следовать за блоком fmt" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data not supported with directed advertising" msgstr "Данные не поддерживаются направленным объявлением" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data too large for advertisement packet" msgstr "Данные слишком велики для пакета объявления" @@ -938,7 +947,8 @@ msgstr "Данные слишком велики для пакета объяв #: ports/stm/common-hal/alarm/pin/PinAlarm.c msgid "Deep sleep pins must use a rising edge with pulldown" msgstr "" -"Выводы глубокого сна должны использовать rising edge с подтяжкой к земле" +"Выводы глубокого сна должны использовать сигнал по возрастанию с подтяжкой к " +"земле" #: shared-bindings/audiobusio/PDMIn.c msgid "Destination capacity is smaller than destination_length." @@ -950,7 +960,7 @@ msgstr "Устройство используется" #: ports/cxd56/common-hal/digitalio/DigitalInOut.c msgid "DigitalInOut not supported on given pin" -msgstr "DigitalInOut не поддерживается на данном выводе" +msgstr "DigitalInOut не поддерживается на данном пине" #: shared-bindings/displayio/Display.c #: shared-bindings/framebufferio/FramebufferDisplay.c @@ -964,7 +974,6 @@ msgid "Display rotation must be in 90 degree increments" msgstr "Поворот дисплея должен осуществляться с шагом 90 градусов" #: shared-bindings/digitalio/DigitalInOut.c -#, fuzzy msgid "Drive mode not used when direction is input." msgstr "Drive mode не используется, когда направление является входным." @@ -1013,6 +1022,7 @@ msgstr "Ожидался сигнал" msgid "Expected tuple of length %d, got %d" msgstr "Ожидался кортеж длины %d, получен %d" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Extended advertisements with scan response not supported." msgstr "Расширенные объявления с ответом сканирования не поддерживаются." @@ -1066,6 +1076,7 @@ msgstr "Не удалось выделить память для сканиро msgid "Failed to buffer the sample" msgstr "Не удалось выполнить буферизацию образца" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Failed to connect: internal error" msgstr "Не удалось подключиться: внутренняя ошибка" @@ -1149,15 +1160,22 @@ msgstr "Общий сбой" msgid "Group already used" msgstr "Группа уже используется" +#: ports/atmel-samd/common-hal/busio/SPI.c ports/cxd56/common-hal/busio/SPI.c +#: ports/espressif/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/nrf/common-hal/busio/SPI.c +#: ports/raspberrypi/common-hal/busio/SPI.c +msgid "Half duplex SPI is not implemented" +msgstr "" + #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/I2C.c #: ports/stm/common-hal/busio/SPI.c ports/stm/common-hal/canio/CAN.c #: ports/stm/common-hal/sdioio/SDCard.c msgid "Hardware busy, try alternative pins" -msgstr "Оборудование занято, попробуйте использовать другие выводы" +msgstr "Оборудование занято, попробуйте использовать другие пины" #: ports/mimxrt10xx/common-hal/busio/UART.c ports/stm/common-hal/busio/UART.c msgid "Hardware in use, try alternative pins" -msgstr "Оборудование используется, попробуйте использовать другие выводы" +msgstr "Оборудование используется, попробуйте использовать другие пины" #: shared-bindings/wifi/Radio.c msgid "Hostname must be between 1 and 253 characters" @@ -1207,13 +1225,12 @@ msgstr "Неверный размер программы инициализац #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c msgid "Initial set pin direction conflicts with initial out pin direction" msgstr "" -"Начальное направление вывода set конфликтует с начальным направлением вывода " -"out" +"Начальное направление пина set конфликтует с начальным направлением пина out" #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c msgid "Initial set pin state conflicts with initial out pin state" msgstr "" -"Начальное состояние вывода set конфликтует с начальным состоянием вывода out" +"Начальное состояние пина set конфликтует с начальным состоянием пина out" #: ports/espressif/common-hal/watchdog/WatchDogTimer.c msgid "Initialization failed due to lack of memory" @@ -1236,20 +1253,19 @@ msgstr "Ошибка ввода/вывода" #, c-format msgid "Instruction %d shifts in more bits than pin count" msgstr "" -"Инструкция %d вводит (shifts in) большее количество бит, чем количество " -"выводов" +"Инструкция %d вводит (shifts in) большее количество бит, чем количество пинов" #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #, c-format msgid "Instruction %d shifts out more bits than pin count" msgstr "" "Инструкция %d выводит (shifts out) большее количество бит, чем количество " -"выводов" +"пинов" #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #, c-format msgid "Instruction %d uses extra pin" -msgstr "Инструкция %d использует дополнительный вывод" +msgstr "Инструкция %d использует дополнительный пин" #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #, c-format @@ -1265,7 +1281,6 @@ msgid "Insufficient encryption" msgstr "Недостаточное шифрование" #: ports/espressif/common-hal/wifi/Radio.c -#, fuzzy msgid "Interface must be started" msgstr "Интерфейс должен быть запущен" @@ -1295,13 +1310,13 @@ msgstr "Недопустимый %q" #: ports/atmel-samd/common-hal/imagecapture/ParallelImageCapture.c #: ports/mimxrt10xx/common-hal/busio/UART.c msgid "Invalid %q pin" -msgstr "Недопустимый вывод %q" +msgstr "Недопустимый пин %q" #: ports/stm/common-hal/busio/I2C.c ports/stm/common-hal/busio/SPI.c #: ports/stm/common-hal/busio/UART.c ports/stm/common-hal/canio/CAN.c #: ports/stm/common-hal/sdioio/SDCard.c msgid "Invalid %q pin selection" -msgstr "Неверный выбор вывода %q" +msgstr "Неверный выбор пина %q" #: ports/stm/common-hal/analogio/AnalogIn.c msgid "Invalid ADC Unit value" @@ -1311,6 +1326,7 @@ msgstr "Недопустимое значение единицы АЦП" msgid "Invalid AuthMode" msgstr "Недопустимый AuthMode" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c msgid "Invalid BLE parameter" msgstr "Недопустимый параметр BLE" @@ -1326,7 +1342,7 @@ msgstr "Неверный BSSID" #: ports/espressif/common-hal/analogio/AnalogOut.c #: ports/stm/common-hal/analogio/AnalogOut.c msgid "Invalid DAC pin supplied" -msgstr "Передан неверный вывод ЦАП" +msgstr "Передан неверный пин ЦАП" #: shared-bindings/wifi/Radio.c msgid "Invalid MAC address" @@ -1347,7 +1363,7 @@ msgstr "Недопустимая частота ШИМ" #: ports/espressif/common-hal/analogio/AnalogIn.c msgid "Invalid Pin" -msgstr "Неверный вывод" +msgstr "Неверный пин" #: ports/espressif/bindings/espidf/__init__.c #: ports/espressif/common-hal/busio/I2C.c @@ -1405,6 +1421,10 @@ msgstr "Неверный размер блока формата" msgid "Invalid memory access." msgstr "Неправильный доступ к памяти." +#: extmod/vfs_fat_file.c +msgid "Invalid mode" +msgstr "" + #: ports/espressif/common-hal/wifi/Radio.c msgid "Invalid multicast MAC address" msgstr "Неверный MAC-адрес multicast" @@ -1425,15 +1445,15 @@ msgstr "Неверная фаза" #: ports/nrf/common-hal/alarm/pin/PinAlarm.c shared-bindings/pwmio/PWMOut.c #: shared-module/rgbmatrix/RGBMatrix.c msgid "Invalid pin" -msgstr "Недопустимый вывод" +msgstr "Недопустимый пин" #: ports/atmel-samd/common-hal/audioio/AudioOut.c msgid "Invalid pin for left channel" -msgstr "Недопустимый вывод для левого канала" +msgstr "Недопустимый пин для левого канала" #: ports/atmel-samd/common-hal/audioio/AudioOut.c msgid "Invalid pin for right channel" -msgstr "Недопустимый вывод для правого канала" +msgstr "Недопустимый пин для правого канала" #: ports/atmel-samd/common-hal/busio/I2C.c #: ports/atmel-samd/common-hal/busio/SPI.c @@ -1453,7 +1473,7 @@ msgstr "Недопустимый вывод для правого канала" #: ports/raspberrypi/common-hal/busio/UART.c shared-bindings/busio/SPI.c #: shared-bindings/busio/UART.c msgid "Invalid pins" -msgstr "Недопустимые выводы" +msgstr "Недопустимые пины" #: shared-bindings/bitbangio/SPI.c shared-bindings/busio/SPI.c #: shared-bindings/displayio/FourWire.c @@ -1505,7 +1525,7 @@ msgstr "Недопустимая длина слова/бита" msgid "Key must be 16, 24, or 32 bytes long" msgstr "Ключ должен быть длинной 16, 24 или 32 байта" -#: shared-module/is31fl3741/is31fl3741.c +#: shared-module/is31fl3741/FrameBuffer.c msgid "LED mappings must match display size" msgstr "" @@ -1527,11 +1547,15 @@ msgstr "MAC адрес был недействительным" #: shared-module/bitbangio/SPI.c msgid "MISO pin init failed." -msgstr "Не удалось инициализировать вывод MISO." +msgstr "Не удалось инициализировать пин MISO." #: shared-module/bitbangio/SPI.c msgid "MOSI pin init failed." -msgstr "Не удалось инициализировать вывод MOSI." +msgstr "Не удалось инициализировать пин MOSI." + +#: shared-bindings/is31fl3741/IS31FL3741.c +msgid "Mapping must be a tuple" +msgstr "" #: shared-module/displayio/Shape.c #, c-format @@ -1548,44 +1572,43 @@ msgstr "Задержка включения микрофона должна бы #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "Missing MISO or MOSI Pin" -msgstr "Отсутствует вывод MISO или MOSI" +msgstr "Отсутствует пин MISO или MOSI" #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #, c-format msgid "Missing first_in_pin. Instruction %d reads pin(s)" -msgstr "Отсутствует first_in_pin. Инструкция %d читает состояние вывода (-ов)" +msgstr "Отсутствует first_in_pin. Инструкция %d читает состояние пина (-ов)" #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #, c-format msgid "Missing first_in_pin. Instruction %d shifts in from pin(s)" -msgstr "" -"Отсутствует first_out_pin. Инструкция %d вводит (shifts out) на вывод(ы)" +msgstr "Отсутствует first_out_pin. Инструкция %d вводит (shifts out) на пин(ы)" #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c -#, c-format, fuzzy +#, c-format msgid "Missing first_in_pin. Instruction %d waits based on pin" -msgstr "Отсутствует first_in_pin. Инструкция %d ожидает на основе вывода" +msgstr "Отсутствует first_in_pin. Инструкция %d ожидает на основе пина" #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #, c-format msgid "Missing first_out_pin. Instruction %d shifts out to pin(s)" msgstr "" -"Отсутствует first_out_pin. Инструкция %d выводит (shifts out) на вывод(ы)" +"Отсутствует first_out_pin. Инструкция %d выводит (shifts out) на пин(ы)" #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c -#, fuzzy, c-format +#, c-format msgid "Missing first_out_pin. Instruction %d writes pin(s)" -msgstr "Отсутствует first_out_pin. Инструкция %d записывает вывод(ы)" +msgstr "Отсутствует first_out_pin. Инструкция %d записывает пин(ы)" #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #, c-format msgid "Missing first_set_pin. Instruction %d sets pin(s)" -msgstr "Отсутствует first_set_pin. Инструкция %d устанавливает вывод(ы)" +msgstr "Отсутствует first_set_pin. Инструкция %d устанавливает пин(ы)" #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #, c-format msgid "Missing jmp_pin. Instruction %d jumps on pin" -msgstr "Отсутствует jmp_pin. Инструкция %d перепрыгивает на вывод" +msgstr "Отсутствует jmp_pin. Инструкция %d перепрыгивает на пин" #: shared-module/usb_hid/Device.c #, c-format @@ -1598,12 +1621,12 @@ msgstr "Должен быть субклассом %q." #: ports/mimxrt10xx/common-hal/busio/SPI.c shared-bindings/busio/SPI.c msgid "Must provide MISO or MOSI pin" -msgstr "Вывод MISO или MOSI должен быть предоставлен" +msgstr "Пин MISO или MOSI должен быть предоставлен" #: shared-bindings/rgbmatrix/RGBMatrix.c #, c-format msgid "Must use a multiple of 6 rgb pins, not %d" -msgstr "Количество используемых rgb-контактов должно быть кратно 6, а не %d." +msgstr "Количество используемых rgb-пинов должно быть кратно 6, а не %d" #: supervisor/shared/safe_mode.c msgid "NLR jump failed. Likely memory corruption." @@ -1617,6 +1640,10 @@ msgstr "Ошибка NVS" msgid "Name too long" msgstr "Имя слишком длинное" +#: ports/espressif/common-hal/_bleio/__init__.c +msgid "Nimble out of memory" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "Нет CCCD для этой Characteristic" @@ -1637,34 +1664,34 @@ msgstr "Канал DMA не найден" msgid "No DMA pacing timer found" msgstr "" -#: shared-module/adafruit_bus_device/I2CDevice.c +#: shared-module/adafruit_bus_device/i2c_device/I2CDevice.c #, c-format -msgid "No I2C device at address: %x" -msgstr "Нет устройства I2C по адресу: %x" +msgid "No I2C device at address: 0x%x" +msgstr "" #: ports/espressif/common-hal/busio/SPI.c #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "No MISO Pin" -msgstr "Нет вывода MISO" +msgstr "Нет пина MISO" #: ports/espressif/common-hal/busio/SPI.c #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c msgid "No MOSI Pin" -msgstr "Нет вывода MOSI" +msgstr "Нет пина MOSI" #: ports/atmel-samd/common-hal/busio/UART.c #: ports/espressif/common-hal/busio/UART.c #: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c #: ports/raspberrypi/common-hal/busio/UART.c ports/stm/common-hal/busio/UART.c msgid "No RX pin" -msgstr "Нет вывода RX" +msgstr "Нет пина RX" #: ports/atmel-samd/common-hal/busio/UART.c #: ports/espressif/common-hal/busio/UART.c #: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c #: ports/raspberrypi/common-hal/busio/UART.c ports/stm/common-hal/busio/UART.c msgid "No TX pin" -msgstr "Нет вывода TX" +msgstr "Нет пина TX" #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c msgid "No available clocks" @@ -1692,13 +1719,13 @@ msgstr "Отсутствует аппаратный генератор случ #: ports/atmel-samd/common-hal/ps2io/Ps2.c msgid "No hardware support on clk pin" -msgstr "Отсутствует аппаратная поддержка вывода clk" +msgstr "Отсутствует аппаратная поддержка пина clk" #: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c #: ports/atmel-samd/common-hal/pulseio/PulseIn.c msgid "No hardware support on pin" -msgstr "Отсутствует аппаратная поддержка на выводе" +msgstr "Отсутствует аппаратная поддержка на пине" #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c msgid "No in in program" @@ -1733,14 +1760,13 @@ msgstr "В программе отсутствует вывод" #: ports/espressif/common-hal/busio/I2C.c #: ports/mimxrt10xx/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c #: ports/raspberrypi/common-hal/busio/I2C.c -#, fuzzy msgid "No pull up found on SDA or SCL; check your wiring" msgstr "" "Подтяжка на выводах SDA или SCL не обнаружена; проверь схему подключения" #: shared-module/touchio/TouchIn.c msgid "No pulldown on pin; 1Mohm recommended" -msgstr "Отсутствует подтяжка к земле на выводе; Рекомендуется 1 Мегаом" +msgstr "Отсутствует подтяжка к земле на пине; Рекомендуется 1 Мегаом" #: py/moduerrno.c msgid "No space left on device" @@ -1766,6 +1792,7 @@ msgstr "" msgid "Not a valid IP string" msgstr "Недействительная строка IP" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -1777,7 +1804,6 @@ msgid "Not playing" msgstr "Не играет" #: shared-bindings/_bleio/__init__.c -#, fuzzy msgid "Not settable" msgstr "Не устанавливается" @@ -1799,7 +1825,6 @@ msgstr "" #: ports/atmel-samd/common-hal/audiobusio/PDMIn.c #: ports/raspberrypi/common-hal/audiobusio/PDMIn.c -#, fuzzy msgid "Only 8 or 16 bit mono with " msgstr "Только 8- или 16-битное моно с " @@ -1812,12 +1837,12 @@ msgid "Only IPv4 sockets supported" msgstr "Поддерживаются только сокеты IPv4" #: shared-module/displayio/OnDiskBitmap.c -#, fuzzy, c-format +#, c-format msgid "" "Only Windows format, uncompressed BMP supported: given header size is %d" msgstr "" "Поддерживается только формат Windows, несжатый BMP: заданный размер " -"заголовка - %d." +"заголовка - %d" #: shared-bindings/_bleio/Adapter.c msgid "Only connectable advertisements can be directed" @@ -1920,15 +1945,15 @@ msgstr "" #: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c #: ports/stm/common-hal/alarm/pin/PinAlarm.c msgid "Pin cannot wake from Deep Sleep" -msgstr "" +msgstr "Пин не может вывести из глубокого сна" #: ports/raspberrypi/bindings/rp2pio/StateMachine.c msgid "Pin count must be at least 1" -msgstr "" +msgstr "Количество пинов должно быть не менее 1" #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c msgid "Pin count too large" -msgstr "" +msgstr "Слишком большое количество пинов" #: ports/atmel-samd/common-hal/analogio/AnalogIn.c #: ports/cxd56/common-hal/analogio/AnalogIn.c @@ -1938,25 +1963,25 @@ msgstr "" #: ports/raspberrypi/common-hal/analogio/AnalogIn.c #: ports/stm/common-hal/analogio/AnalogIn.c msgid "Pin does not have ADC capabilities" -msgstr "" +msgstr "Пин не имеет возможности АЦП" #: ports/stm/common-hal/alarm/pin/PinAlarm.c #: ports/stm/common-hal/pulseio/PulseIn.c msgid "Pin interrupt already in use" -msgstr "" +msgstr "Прерывание пина уже используется" -#: shared-bindings/adafruit_bus_device/SPIDevice.c +#: shared-bindings/adafruit_bus_device/spi_device/SPIDevice.c #: shared-bindings/digitalio/DigitalInOut.c msgid "Pin is input only" -msgstr "" +msgstr "Пин является только входом" #: ports/raspberrypi/common-hal/countio/Counter.c msgid "Pin must be on PWM Channel B" -msgstr "" +msgstr "Пин должен быть на канале ШИМ B" #: ports/atmel-samd/common-hal/countio/Counter.c msgid "Pin must support hardware interrupts" -msgstr "" +msgstr "Пин должен поддерживать аппаратные прерывания" #: shared-bindings/rgbmatrix/RGBMatrix.c #, c-format @@ -1965,18 +1990,21 @@ msgid "" "bytes. If this cannot be avoided, pass allow_inefficient=True to the " "constructor" msgstr "" +"Pinout использует %d байт на элемент, что потребляет больше, чем идеальные " +"%d байт. Если этого нельзя избежать, передайте allow_inefficient=True в " +"конструктор" #: ports/raspberrypi/common-hal/imagecapture/ParallelImageCapture.c msgid "Pins must be sequential" -msgstr "" +msgstr "Пины должны быть последовательными" #: ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c msgid "Pins must be sequential GPIO pins" -msgstr "" +msgstr "Пины должны быть последовательными выводами GPIO" #: ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c msgid "Pins must share PWM slice" -msgstr "" +msgstr "Пины должны иметь общий срез ШИМ" #: py/builtinhelp.c msgid "Plus any modules on the filesystem\n" @@ -2029,6 +2057,10 @@ msgstr "" msgid "RAISE mode is not implemented" msgstr "" +#: ports/raspberrypi/common-hal/countio/Counter.c +msgid "RISE_AND_FALL not available on this chip" +msgstr "" + #: ports/stm/common-hal/os/__init__.c msgid "RNG DeInit Error" msgstr "" @@ -2145,10 +2177,11 @@ msgstr "" msgid "Sample rate too high. It must be less than %d" msgstr "" -#: shared-bindings/is31fl3741/is31fl3741.c +#: shared-bindings/is31fl3741/FrameBuffer.c msgid "Scale dimensions must divide by 3" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Scan already in progess. Stop with stop_scan." msgstr "" @@ -2164,7 +2197,7 @@ msgstr "" #: ports/raspberrypi/bindings/rp2pio/StateMachine.c msgid "Set pin count must be between 1 and 5" -msgstr "" +msgstr "Число Set пинов должно быть от 1 до 5" #: ports/raspberrypi/bindings/rp2pio/StateMachine.c msgid "Side set pin count must be between 1 and 5" @@ -2200,7 +2233,7 @@ msgstr "" #: shared-bindings/paralleldisplay/ParallelBus.c msgid "Specify exactly one of data0 or data_pins" -msgstr "" +msgstr "Укажите точно один из data0 или data_pins" #: extmod/modure.c msgid "Splitting with sub-captures" @@ -2224,7 +2257,7 @@ msgstr "" #: ports/mimxrt10xx/common-hal/busio/UART.c ports/stm/common-hal/busio/UART.c msgid "Supply at least one UART pin" -msgstr "" +msgstr "Предоставьте хотяб один пин UART" #: shared-bindings/alarm/time/TimeAlarm.c msgid "Supply one of monotonic_time or epoch_time" @@ -2252,7 +2285,7 @@ msgstr "" #: shared-bindings/rgbmatrix/RGBMatrix.c msgid "The length of rgb_pins must be 6, 12, 18, 24, or 30" -msgstr "" +msgstr "Длина rgb_pins должна быть 6, 12, 18, 24 или 30" #: supervisor/shared/safe_mode.c msgid "" @@ -2286,6 +2319,8 @@ msgid "" "This microcontroller only supports data0=, not data_pins=, because it " "requires contiguous pins." msgstr "" +"Этот микроконтроллер поддерживает только data0=, а не data_pins=, поскольку " +"для него требуются смежные выводы." #: shared-bindings/displayio/TileGrid.c msgid "Tile height must exactly divide bitmap height" @@ -2307,6 +2342,7 @@ msgstr "" msgid "Time is in the past." msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2329,6 +2365,7 @@ msgstr "" msgid "Too many displays" msgstr "" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Total data to write is larger than %q" msgstr "" @@ -2406,7 +2443,7 @@ msgstr "" msgid "Unable to create lock" msgstr "" -#: shared-module/displayio/I2CDisplay.c shared-module/is31fl3741/is31fl3741.c +#: shared-module/displayio/I2CDisplay.c shared-module/is31fl3741/IS31FL3741.c #, c-format msgid "Unable to find I2C Display at %x" msgstr "" @@ -2441,6 +2478,16 @@ msgstr "" msgid "Unhandled ESP TLS error %d %d %x %d" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown BLE error at %s:%d: %d" +msgstr "" + +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown BLE error: %d" +msgstr "" + #: shared-bindings/wifi/Radio.c #, c-format msgid "Unknown failure %d" @@ -2460,11 +2507,21 @@ msgstr "" msgid "Unknown security error: 0x%04x" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error at %s:%d: %d" +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown system firmware error: %04x" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error: %d" +msgstr "" + #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #, c-format msgid "Unmatched number of items on RHS (expected %d, got %d)." @@ -2498,19 +2555,19 @@ msgstr "" msgid "Unsupported operation" msgstr "" -#: shared-bindings/digitalio/DigitalInOut.c -msgid "Unsupported pull value." -msgstr "" - #: ports/espressif/common-hal/dualbank/__init__.c msgid "Update Failed" msgstr "" +#: ports/espressif/common-hal/_bleio/Characteristic.c +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length != required fixed length" msgstr "" +#: ports/espressif/common-hal/_bleio/Characteristic.c +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length > max_length" @@ -2568,6 +2625,7 @@ msgstr "" msgid "Woken up by alarm.\n" msgstr "" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Writes not supported on Characteristic" msgstr "" @@ -2671,7 +2729,7 @@ msgstr "" msgid "attributes not supported yet" msgstr "" -#: extmod/ulab/code/numpy/numerical.c +#: extmod/ulab/code/ulab_tools.c msgid "axis is out of bounds" msgstr "" @@ -2727,11 +2785,11 @@ msgstr "" msgid "branch not in range" msgstr "" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/utils/utils.c msgid "buffer is smaller than requested size" msgstr "" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/utils/utils.c msgid "buffer size must be a multiple of element size" msgstr "" @@ -2781,6 +2839,10 @@ msgstr "" msgid "calibration value out of range +/-127" msgstr "" +#: shared-module/vectorio/Rectangle.c +msgid "can only be registered in one parent" +msgstr "" + #: py/emitinlinethumb.c msgid "can only have up to 4 parameters to Thumb assembly" msgstr "" @@ -2819,6 +2881,10 @@ msgstr "" msgid "can't convert '%q' object to %q implicitly" msgstr "" +#: extmod/ulab/code/numpy/vector.c +msgid "can't convert complex to float" +msgstr "" + #: py/obj.c msgid "can't convert to %q" msgstr "" @@ -2871,6 +2937,10 @@ msgstr "" msgid "can't load with '%q' index" msgstr "" +#: py/builtinimport.c +msgid "can't perform relative import" +msgstr "" + #: py/objgenerator.c msgid "can't send non-None value to a just-started generator" msgstr "" @@ -2913,6 +2983,14 @@ msgstr "" msgid "cannot cast output with casting rule" msgstr "" +#: extmod/ulab/code/ndarray.c +msgid "cannot convert complex to dtype" +msgstr "" + +#: extmod/ulab/code/ndarray.c +msgid "cannot convert complex type" +msgstr "" + #: py/objtype.c msgid "cannot create '%q' instances" msgstr "" @@ -2925,10 +3003,6 @@ msgstr "" msgid "cannot import name %q" msgstr "" -#: py/builtinimport.c -msgid "cannot perform relative import" -msgstr "" - #: extmod/moductypes.c msgid "cannot unambiguously get sizeof scalar" msgstr "" @@ -3040,7 +3114,7 @@ msgstr "" #: ports/atmel-samd/common-hal/imagecapture/ParallelImageCapture.c #, c-format msgid "data pin #%d in use" -msgstr "" +msgstr "data-пин #%d уже используется" #: extmod/ulab/code/ndarray.c msgid "data type not understood" @@ -3104,6 +3178,10 @@ msgstr "" msgid "divisor must be 4" msgstr "" +#: extmod/ulab/code/numpy/vector.c +msgid "dtype must be float, or complex" +msgstr "" + #: py/objdeque.c msgid "empty" msgstr "" @@ -3207,7 +3285,7 @@ msgstr "" msgid "first argument must be a function" msgstr "" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "first argument must be a tuple of ndarrays" msgstr "" @@ -3272,6 +3350,10 @@ msgstr "" msgid "function is defined for ndarrays only" msgstr "" +#: extmod/ulab/code/numpy/carray/carray.c +msgid "function is implemented for ndarrays only" +msgstr "" + #: py/argcheck.c #, c-format msgid "function missing %d required positional arguments" @@ -3385,7 +3467,7 @@ msgstr "" msgid "input and output shapes are not compatible" msgstr "" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "input argument must be an integer, a tuple, or a list" msgstr "" @@ -3393,7 +3475,7 @@ msgstr "" msgid "input array length must be power of 2" msgstr "" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "input arrays are not compatible" msgstr "" @@ -3401,6 +3483,10 @@ msgstr "" msgid "input data must be an iterable" msgstr "" +#: extmod/ulab/code/numpy/vector.c +msgid "input dtype must be float or complex" +msgstr "" + #: extmod/ulab/code/numpy/linalg/linalg.c msgid "input matrix is asymmetric" msgstr "" @@ -3410,18 +3496,26 @@ msgstr "" msgid "input matrix is singular" msgstr "" +#: extmod/ulab/code/numpy/carray/carray.c +msgid "input must be a 1D ndarray" +msgstr "" + #: extmod/ulab/code/scipy/linalg/linalg.c extmod/ulab/code/user/user.c msgid "input must be a dense ndarray" msgstr "" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "input must be a tensor of rank 2" msgstr "" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/user/user.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/user/user.c msgid "input must be an ndarray" msgstr "" +#: extmod/ulab/code/numpy/carray/carray.c +msgid "input must be an ndarray, or a scalar" +msgstr "" + #: extmod/ulab/code/scipy/signal/signal.c msgid "input must be one-dimensional" msgstr "" @@ -3599,6 +3693,11 @@ msgstr "" msgid "matrix is not positive definite" msgstr "" +#: ports/espressif/common-hal/wifi/Radio.c +msgid "max_connections must be between 0 and 10" +msgstr "" + +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c #, c-format @@ -3738,7 +3837,7 @@ msgstr "" #: shared-bindings/displayio/FourWire.c shared-bindings/displayio/I2CDisplay.c #: shared-bindings/paralleldisplay/ParallelBus.c msgid "no reset pin available" -msgstr "" +msgstr "нет доступного контакта сброса" #: shared-module/sdcardio/SDCard.c msgid "no response from SD card" @@ -3752,6 +3851,7 @@ msgstr "" msgid "non-Device in %q" msgstr "" +#: ports/espressif/common-hal/_bleio/Connection.c #: ports/nrf/common-hal/_bleio/Connection.c msgid "non-UUID found in service_uuids_whitelist" msgstr "" @@ -3792,7 +3892,11 @@ msgstr "" msgid "not enough arguments for format string" msgstr "" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/carray/carray_tools.c +msgid "not implemented for complex dtype" +msgstr "" + +#: extmod/ulab/code/numpy/create.c msgid "number of points must be at least 2" msgstr "" @@ -3850,7 +3954,7 @@ msgstr "" msgid "odd-length string" msgstr "" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/utils/utils.c msgid "offset is too large" msgstr "" @@ -3858,7 +3962,7 @@ msgstr "" msgid "offset must be >= 0" msgstr "" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "offset must be non-negative and no greater than buffer length" msgstr "" @@ -3970,6 +4074,10 @@ msgstr "" msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "" +#: extmod/vfs_posix_file.c +msgid "poll on file not available on win32" +msgstr "" + #: shared-module/vectorio/Polygon.c msgid "polygon can only be registered in one parent" msgstr "" @@ -3999,18 +4107,27 @@ msgstr "" msgid "pow() with 3 arguments requires integers" msgstr "" +#: ports/espressif/boards/adafruit_esp32s2_camera/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tft/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h #: ports/espressif/boards/adafruit_funhouse/mpconfigboard.h #: ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h +#: ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h +#: ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h #: ports/espressif/boards/atmegazero_esp32s2/mpconfigboard.h #: ports/espressif/boards/crumpspace_crumps2/mpconfigboard.h #: ports/espressif/boards/electroniccats_bastwifi/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s2_devkitc_1_n4r2/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_box/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h #: ports/espressif/boards/espressif_hmi_devkit_1/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1.3/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1/mpconfigboard.h @@ -4036,7 +4153,10 @@ msgstr "" #: ports/espressif/boards/unexpectedmaker_feathers2/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_neo/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_prerelease/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_feathers3/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_pros3/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_tinys2/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_tinys3/mpconfigboard.h msgid "pressing boot button at start up.\n" msgstr "" @@ -4100,12 +4220,12 @@ msgstr "" #: shared-bindings/rgbmatrix/RGBMatrix.c #, c-format msgid "rgb_pins[%d] duplicates another pin assignment" -msgstr "" +msgstr "rgb_pins[%d] дублирует другое назначение пинов" #: shared-bindings/rgbmatrix/RGBMatrix.c #, c-format msgid "rgb_pins[%d] is not on the same port as clock" -msgstr "" +msgstr "rgb_pins[%d] не находится на том же порту, что и clock" #: extmod/ulab/code/numpy/numerical.c msgid "roll argument must be an ndarray" @@ -4333,7 +4453,7 @@ msgstr "" msgid "too many arguments provided with the given format" msgstr "" -#: extmod/ulab/code/ndarray.c extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/ndarray.c extmod/ulab/code/numpy/create.c msgid "too many dimensions" msgstr "" @@ -4517,7 +4637,7 @@ msgstr "" msgid "width must be from 2 to 8 (inclusive), not %d" msgstr "" -#: shared-bindings/is31fl3741/is31fl3741.c +#: shared-bindings/is31fl3741/FrameBuffer.c #: shared-bindings/rgbmatrix/RGBMatrix.c msgid "width must be greater than zero" msgstr "" @@ -4534,7 +4654,7 @@ msgstr "" msgid "wrong axis index" msgstr "" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "wrong axis specified" msgstr "" @@ -4542,7 +4662,11 @@ msgstr "" msgid "wrong input type" msgstr "" -#: extmod/ulab/code/ulab_create.c py/objarray.c py/objstr.c +#: extmod/ulab/code/numpy/transform.c +msgid "wrong length of condition array" +msgstr "" + +#: extmod/ulab/code/numpy/create.c py/objarray.c py/objstr.c msgid "wrong number of arguments" msgstr "" @@ -4579,10 +4703,13 @@ msgid "zi must be an ndarray" msgstr "" #: extmod/ulab/code/scipy/signal/signal.c -#, fuzzy msgid "zi must be of float type" msgstr "zi должно быть типа float" #: extmod/ulab/code/scipy/signal/signal.c msgid "zi must be of shape (n_section, 2)" msgstr "zi должен иметь форму (n_section, 2)" + +#, c-format +#~ msgid "No I2C device at address: %x" +#~ msgstr "Нет устройства I2C по адресу: %x" diff --git a/locale/sv.po b/locale/sv.po index 7e6ae3e77c..3f34ba0218 100644 --- a/locale/sv.po +++ b/locale/sv.po @@ -6,7 +6,7 @@ msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-01-04 12:55-0600\n" -"PO-Revision-Date: 2021-11-25 00:02+0000\n" +"PO-Revision-Date: 2022-02-19 20:22+0000\n" "Last-Translator: Jonny Bergdahl \n" "Language-Team: LANGUAGE \n" "Language: sv\n" @@ -14,7 +14,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Generator: Weblate 4.10-dev\n" +"X-Generator: Weblate 4.11-dev\n" #: main.c msgid "" @@ -107,7 +107,7 @@ msgstr "Indexet %q måste vara ett heltal, inte %s" msgid "%q length must be %d-%d" msgstr "längden på %q måste vara %d-%d" -#: shared-bindings/usb_hid/Device.c +#: shared-bindings/busio/I2C.c shared-bindings/usb_hid/Device.c msgid "%q length must be >= 1" msgstr "längden på %q måste vara >= 1" @@ -152,6 +152,10 @@ msgstr "%q måste vara mellan %d och %d" msgid "%q must be of type %q" msgstr "%q måste vara av typen %q" +#: shared-bindings/digitalio/Pull.c +msgid "%q must be of type %q or None" +msgstr "%q måste vara av typen %q eller None" + #: ports/atmel-samd/common-hal/busio/UART.c msgid "%q must be power of 2" msgstr "%q måste vara en potens av 2" @@ -450,6 +454,7 @@ msgstr "Alla timers för denna pinne är i bruk" msgid "All timers in use" msgstr "Alla timers används" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Already advertising." msgstr "Annonserar redan." @@ -584,7 +589,7 @@ msgstr "Båda pinnarna måste stödja maskinvaruavbrott" #: shared-bindings/displayio/Display.c #: shared-bindings/framebufferio/FramebufferDisplay.c -#: shared-bindings/is31fl3741/is31fl3741.c +#: shared-bindings/is31fl3741/FrameBuffer.c #: shared-bindings/rgbmatrix/RGBMatrix.c msgid "Brightness must be 0-1.0" msgstr "Ljusstyrkan måste vara mellan 0 och 1,0" @@ -636,7 +641,7 @@ msgstr "Buffertlängd måste vara en multipel av 512" msgid "Buffer must be a multiple of 512 bytes" msgstr "Bufferten måste vara en multipel av 512 byte" -#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c +#: shared-bindings/bitbangio/I2C.c msgid "Buffer must be at least length 1" msgstr "Bufferten måste ha minst längd 1" @@ -669,6 +674,10 @@ msgstr "Bytes måste vara mellan 0 och 255." msgid "CBC blocks must be multiples of 16 bytes" msgstr "CBC-block måste vara multiplar om 16 byte" +#: supervisor/shared/safe_mode.c +msgid "CIRCUITPY drive could not be found or created." +msgstr "CIRCUITPY-enheten kunde inte hittas eller skapas." + #: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c msgid "CRC or checksum was invalid" msgstr "CRC eller checksumma var ogiltig" @@ -915,10 +924,12 @@ msgstr "Datapinne 0 måste vara bytejusterad" msgid "Data chunk must follow fmt chunk" msgstr "Datasegmentet måste följa fmt-segmentet" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data not supported with directed advertising" msgstr "Data stöds inte med riktad annonsering" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data too large for advertisement packet" msgstr "Data för stor för annonseringspaket" @@ -999,6 +1010,7 @@ msgstr "Förväntade ett larm" msgid "Expected tuple of length %d, got %d" msgstr "Förväntad tupel med längd %d, fick %d" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Extended advertisements with scan response not supported." msgstr "Utökad annonsering i kombination med skanningssvar stöds inte." @@ -1052,6 +1064,7 @@ msgstr "Det gick inte att allokera minne för WiFi-scanning" msgid "Failed to buffer the sample" msgstr "Det gick inte att buffra samplingen" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Failed to connect: internal error" msgstr "Det gick inte att ansluta: internt fel" @@ -1131,6 +1144,13 @@ msgstr "Generiskt fel" msgid "Group already used" msgstr "Grupp används redan" +#: ports/atmel-samd/common-hal/busio/SPI.c ports/cxd56/common-hal/busio/SPI.c +#: ports/espressif/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/nrf/common-hal/busio/SPI.c +#: ports/raspberrypi/common-hal/busio/SPI.c +msgid "Half duplex SPI is not implemented" +msgstr "Halvduplex SPI är inte implementerat" + #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/I2C.c #: ports/stm/common-hal/busio/SPI.c ports/stm/common-hal/canio/CAN.c #: ports/stm/common-hal/sdioio/SDCard.c @@ -1287,6 +1307,7 @@ msgstr "Ogiltigt ADC-enhetsvärde" msgid "Invalid AuthMode" msgstr "Ogiltig AuthMode" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c msgid "Invalid BLE parameter" msgstr "Ogiltig BLE-parameter" @@ -1381,6 +1402,10 @@ msgstr "Ogiltig formatsegmentstorlek" msgid "Invalid memory access." msgstr "Ogiltig minnesåtkomst." +#: extmod/vfs_fat_file.c +msgid "Invalid mode" +msgstr "Ogiltigt läge" + #: ports/espressif/common-hal/wifi/Radio.c msgid "Invalid multicast MAC address" msgstr "Ogiltig MAC-adress för multicast" @@ -1481,7 +1506,7 @@ msgstr "Ogiltig word-/bitlängd" msgid "Key must be 16, 24, or 32 bytes long" msgstr "Nyckeln måste vara 16, 24 eller 32 byte lång" -#: shared-module/is31fl3741/is31fl3741.c +#: shared-module/is31fl3741/FrameBuffer.c msgid "LED mappings must match display size" msgstr "LED-mappning måste matcha displaystorlek" @@ -1509,6 +1534,10 @@ msgstr "init för MISO-pinne misslyckades." msgid "MOSI pin init failed." msgstr "init för MOSI-pinne misslyckades." +#: shared-bindings/is31fl3741/IS31FL3741.c +msgid "Mapping must be a tuple" +msgstr "Mappning måste vara en tuple" + #: shared-module/displayio/Shape.c #, c-format msgid "Maximum x value when mirrored is %d" @@ -1592,6 +1621,10 @@ msgstr "NVS-fel" msgid "Name too long" msgstr "Name är för långt" +#: ports/espressif/common-hal/_bleio/__init__.c +msgid "Nimble out of memory" +msgstr "Nimble har inget minne kvar" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "Ingen CCCD för denna karaktäristik" @@ -1612,10 +1645,10 @@ msgstr "Ingen DMA-kanal hittades" msgid "No DMA pacing timer found" msgstr "Ingen DMA pacing timer hittades" -#: shared-module/adafruit_bus_device/I2CDevice.c +#: shared-module/adafruit_bus_device/i2c_device/I2CDevice.c #, c-format -msgid "No I2C device at address: %x" -msgstr "Ingen I2C-enhet på adress: %x" +msgid "No I2C device at address: 0x%x" +msgstr "Ingen I2C-enhet på adress: 0x%x" #: ports/espressif/common-hal/busio/SPI.c #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c @@ -1739,6 +1772,7 @@ msgstr "Nordic systemfirmware fick slut på minne" msgid "Not a valid IP string" msgstr "Inte en giltig IP-sträng" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -1919,7 +1953,7 @@ msgstr "Pinnen har inte ADC-funktionalitet" msgid "Pin interrupt already in use" msgstr "Pinnavbrott används redan" -#: shared-bindings/adafruit_bus_device/SPIDevice.c +#: shared-bindings/adafruit_bus_device/spi_device/SPIDevice.c #: shared-bindings/digitalio/DigitalInOut.c msgid "Pin is input only" msgstr "Pinnen är enbart ingång" @@ -2006,6 +2040,10 @@ msgstr "Pull används inte när riktningen är output." msgid "RAISE mode is not implemented" msgstr "RAISE-läge är inte implementerat" +#: ports/raspberrypi/common-hal/countio/Counter.c +msgid "RISE_AND_FALL not available on this chip" +msgstr "RISE_AND_FALL är inte tillgängligt på detta chip" + #: ports/stm/common-hal/os/__init__.c msgid "RNG DeInit Error" msgstr "RNG DeInit-fel" @@ -2122,10 +2160,11 @@ msgstr "Samplingsfrekvensen måste vara positiv" msgid "Sample rate too high. It must be less than %d" msgstr "Samplingsfrekvensen är för hög. Den måste vara mindre än %d" -#: shared-bindings/is31fl3741/is31fl3741.c +#: shared-bindings/is31fl3741/FrameBuffer.c msgid "Scale dimensions must divide by 3" msgstr "Skaldimension måste vara delbar med 3" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Scan already in progess. Stop with stop_scan." msgstr "Skanning pågår redan. Avsluta med stop_scan." @@ -2294,6 +2333,7 @@ msgstr "Tile-bredd måste vara jämnt delbar med bredd på bitmap" msgid "Time is in the past." msgstr "Tid har passerats." +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2316,6 +2356,7 @@ msgstr "För många display-bussar" msgid "Too many displays" msgstr "För många displayer" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Total data to write is larger than %q" msgstr "Totala data att skriva är större än %q" @@ -2393,7 +2434,7 @@ msgstr "Det går inte att allokera buffert för signerad konvertering" msgid "Unable to create lock" msgstr "Kan inte skapa lås" -#: shared-module/displayio/I2CDisplay.c shared-module/is31fl3741/is31fl3741.c +#: shared-module/displayio/I2CDisplay.c shared-module/is31fl3741/IS31FL3741.c #, c-format msgid "Unable to find I2C Display at %x" msgstr "Det gick inte att hitta I2C-display på %x" @@ -2428,6 +2469,16 @@ msgstr "Oväntad nrfx uuid-typ" msgid "Unhandled ESP TLS error %d %d %x %d" msgstr "Ej hanterat ESP TLS-fel %d %d %x %d" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown BLE error at %s:%d: %d" +msgstr "Okänt BLE-fel vid %s:%d: %d" + +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown BLE error: %d" +msgstr "Okänt BLE-fel: %d" + #: shared-bindings/wifi/Radio.c #, c-format msgid "Unknown failure %d" @@ -2447,11 +2498,21 @@ msgstr "Okänd anledning." msgid "Unknown security error: 0x%04x" msgstr "Okänt säkerhetsfel: 0x%04x" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error at %s:%d: %d" +msgstr "Okänt fel i systemets firmware vid %s:%d: %d" + #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown system firmware error: %04x" msgstr "Okänt systemfirmwarefel: %04x" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error: %d" +msgstr "Okänt fel i systemets firmware: %d" + #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #, c-format msgid "Unmatched number of items on RHS (expected %d, got %d)." @@ -2487,19 +2548,19 @@ msgstr "Formatet stöds inte" msgid "Unsupported operation" msgstr "Åtgärd som inte stöds" -#: shared-bindings/digitalio/DigitalInOut.c -msgid "Unsupported pull value." -msgstr "Ogiltigt Pull-värde." - #: ports/espressif/common-hal/dualbank/__init__.c msgid "Update Failed" msgstr "Uppdateringen misslyckades" +#: ports/espressif/common-hal/_bleio/Characteristic.c +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length != required fixed length" msgstr "Värdets längde ! = krävd fast längd" +#: ports/espressif/common-hal/_bleio/Characteristic.c +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length > max_length" @@ -2563,6 +2624,7 @@ msgstr "WiFi-lösenord måste vara mellan 8 och 63 tecken" msgid "Woken up by alarm.\n" msgstr "Vaknade av larm.\n" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Writes not supported on Characteristic" msgstr "Skrivning stöds inte på karaktäristik" @@ -2668,7 +2730,7 @@ msgstr "försök att få argmin/argmax för en tom sekvens" msgid "attributes not supported yet" msgstr "attribut stöds inte än" -#: extmod/ulab/code/numpy/numerical.c +#: extmod/ulab/code/ulab_tools.c msgid "axis is out of bounds" msgstr "axis är utanför gränsen" @@ -2724,11 +2786,11 @@ msgstr "bits_per_sample måste vara 8 eller 16" msgid "branch not in range" msgstr "branch utanför räckvidd" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/utils/utils.c msgid "buffer is smaller than requested size" msgstr "bufferten är mindre än begärd storlek" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/utils/utils.c msgid "buffer size must be a multiple of element size" msgstr "buffertstorlek måste vara en multipel av elementstorlek" @@ -2778,6 +2840,10 @@ msgstr "kalibrering är skrivskyddad" msgid "calibration value out of range +/-127" msgstr "kalibreringsvärde utanför intervallet +/- 127" +#: shared-module/vectorio/Rectangle.c +msgid "can only be registered in one parent" +msgstr "kan endast registreras med en förälder" + #: py/emitinlinethumb.c msgid "can only have up to 4 parameters to Thumb assembly" msgstr "kan bara ha upp till 4 parametrar för Thumbs assembly" @@ -2816,6 +2882,10 @@ msgstr "kan inte konvertera %s till komplex" msgid "can't convert '%q' object to %q implicitly" msgstr "kan inte konvertera '%q' objekt implicit till %q" +#: extmod/ulab/code/numpy/vector.c +msgid "can't convert complex to float" +msgstr "kan inte konvertera complex till float" + #: py/obj.c msgid "can't convert to %q" msgstr "kan inte konvertera till %q" @@ -2868,6 +2938,10 @@ msgstr "kan inte ladda från '%q'" msgid "can't load with '%q' index" msgstr "kan inte ladda med '%q' index" +#: py/builtinimport.c +msgid "can't perform relative import" +msgstr "kan inte utföra relativ import" + #: py/objgenerator.c msgid "can't send non-None value to a just-started generator" msgstr "kan inte skicka icke-None värde till nystartad generator" @@ -2912,6 +2986,14 @@ msgstr "kan inte tilldela en ny form" msgid "cannot cast output with casting rule" msgstr "kan inte casta utdata med regel" +#: extmod/ulab/code/ndarray.c +msgid "cannot convert complex to dtype" +msgstr "kan inte konvertera komplex till dtype" + +#: extmod/ulab/code/ndarray.c +msgid "cannot convert complex type" +msgstr "kan inte konvertera complex typer" + #: py/objtype.c msgid "cannot create '%q' instances" msgstr "kan inte skapa instanser av '%q'" @@ -2924,10 +3006,6 @@ msgstr "kan inte skapa instans" msgid "cannot import name %q" msgstr "kan inte importera namn %q" -#: py/builtinimport.c -msgid "cannot perform relative import" -msgstr "kan inte utföra relativ import" - #: extmod/moductypes.c msgid "cannot unambiguously get sizeof scalar" msgstr "Kan inte entydigt få sizeof scalar" @@ -3106,6 +3184,10 @@ msgstr "division med noll" msgid "divisor must be 4" msgstr "divisor måste vara 4" +#: extmod/ulab/code/numpy/vector.c +msgid "dtype must be float, or complex" +msgstr "dtype måste vara float eller complex" + #: py/objdeque.c msgid "empty" msgstr "tom" @@ -3209,7 +3291,7 @@ msgstr "första argumentet måste vara en callable" msgid "first argument must be a function" msgstr "första argumentet måste vara en funktion" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "first argument must be a tuple of ndarrays" msgstr "första argumentet måste vara en tupel av ndarray" @@ -3274,6 +3356,10 @@ msgstr "funktionen har samma teckenvärden vid slutet av intervall" msgid "function is defined for ndarrays only" msgstr "funktionen är enbart definierad för ndarray" +#: extmod/ulab/code/numpy/carray/carray.c +msgid "function is implemented for ndarrays only" +msgstr "funktionen är bara implementerad för ndarrays" + #: py/argcheck.c #, c-format msgid "function missing %d required positional arguments" @@ -3387,7 +3473,7 @@ msgstr "inline assembler måste vara en funktion" msgid "input and output shapes are not compatible" msgstr "indata- och utdataformer är inte kompatibla" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "input argument must be an integer, a tuple, or a list" msgstr "indataargument måste vara integer, en tuple eller list" @@ -3395,7 +3481,7 @@ msgstr "indataargument måste vara integer, en tuple eller list" msgid "input array length must be power of 2" msgstr "indataarraylängden måste vara en multipel av 2" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "input arrays are not compatible" msgstr "indatamatriser är inte kompatibla" @@ -3403,6 +3489,10 @@ msgstr "indatamatriser är inte kompatibla" msgid "input data must be an iterable" msgstr "indata måste vara en iterable" +#: extmod/ulab/code/numpy/vector.c +msgid "input dtype must be float or complex" +msgstr "indatatyp måste vara float eller complex" + #: extmod/ulab/code/numpy/linalg/linalg.c msgid "input matrix is asymmetric" msgstr "indatamatrisen är asymmetrisk" @@ -3412,18 +3502,26 @@ msgstr "indatamatrisen är asymmetrisk" msgid "input matrix is singular" msgstr "indatamatrisen är singulär" +#: extmod/ulab/code/numpy/carray/carray.c +msgid "input must be a 1D ndarray" +msgstr "indata måste vara en 1D ndarray" + #: extmod/ulab/code/scipy/linalg/linalg.c extmod/ulab/code/user/user.c msgid "input must be a dense ndarray" msgstr "indata måste vara en dense ndarray" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "input must be a tensor of rank 2" msgstr "indata måste vara en tensor av rank 2" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/user/user.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/user/user.c msgid "input must be an ndarray" msgstr "indata måste vara en ndarray" +#: extmod/ulab/code/numpy/carray/carray.c +msgid "input must be an ndarray, or a scalar" +msgstr "indata måste vara en ndarray eller en scalar" + #: extmod/ulab/code/scipy/signal/signal.c msgid "input must be one-dimensional" msgstr "indata måste vara endimensionell" @@ -3604,6 +3702,11 @@ msgstr "matematikdomänfel" msgid "matrix is not positive definite" msgstr "matrisen är inte positiv bestämd" +#: ports/espressif/common-hal/wifi/Radio.c +msgid "max_connections must be between 0 and 10" +msgstr "max_connections måste vara mellan 0 och 10" + +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c #, c-format @@ -3757,6 +3860,7 @@ msgstr "inget sådant attribut" msgid "non-Device in %q" msgstr "icke-enhet i %q" +#: ports/espressif/common-hal/_bleio/Connection.c #: ports/nrf/common-hal/_bleio/Connection.c msgid "non-UUID found in service_uuids_whitelist" msgstr "icke-UUID hittades i service_uuids_whitelist" @@ -3797,7 +3901,11 @@ msgstr "inte alla argument omvandlade under strängformatering" msgid "not enough arguments for format string" msgstr "inte tillräckligt med argument för formatsträng" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/carray/carray_tools.c +msgid "not implemented for complex dtype" +msgstr "inte implementerat för complex dtype" + +#: extmod/ulab/code/numpy/create.c msgid "number of points must be at least 2" msgstr "antal punkter måste vara minst 2" @@ -3855,7 +3963,7 @@ msgstr "objekt med buffertprotokoll krävs" msgid "odd-length string" msgstr "sträng har udda längd" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/utils/utils.c msgid "offset is too large" msgstr "offset är för stor" @@ -3863,7 +3971,7 @@ msgstr "offset är för stor" msgid "offset must be >= 0" msgstr "offset måste vara >= 0" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "offset must be non-negative and no greater than buffer length" msgstr "offset måste vara icke-negativt och inte längre än buffertlängd" @@ -3976,6 +4084,10 @@ msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "" "pixel_shader måste vara displayio.Palette eller displayio.ColorConverter" +#: extmod/vfs_posix_file.c +msgid "poll on file not available on win32" +msgstr "filbevakning är inte tillgänglig på win32" + #: shared-module/vectorio/Polygon.c msgid "polygon can only be registered in one parent" msgstr "polygon kan endast registreras i en förälder" @@ -4005,18 +4117,27 @@ msgstr "pow() 3: e argument kan inte vara 0" msgid "pow() with 3 arguments requires integers" msgstr "pow() med 3 argument kräver heltal" +#: ports/espressif/boards/adafruit_esp32s2_camera/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tft/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h #: ports/espressif/boards/adafruit_funhouse/mpconfigboard.h #: ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h +#: ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h +#: ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h #: ports/espressif/boards/atmegazero_esp32s2/mpconfigboard.h #: ports/espressif/boards/crumpspace_crumps2/mpconfigboard.h #: ports/espressif/boards/electroniccats_bastwifi/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s2_devkitc_1_n4r2/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_box/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h #: ports/espressif/boards/espressif_hmi_devkit_1/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1.3/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1/mpconfigboard.h @@ -4042,7 +4163,10 @@ msgstr "pow() med 3 argument kräver heltal" #: ports/espressif/boards/unexpectedmaker_feathers2/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_neo/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_prerelease/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_feathers3/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_pros3/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_tinys2/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_tinys3/mpconfigboard.h msgid "pressing boot button at start up.\n" msgstr "trycka på startknappen vid start.\n" @@ -4341,7 +4465,7 @@ msgstr "tobyte kan enbart anropas för täta matriser" msgid "too many arguments provided with the given format" msgstr "för många argument för det givna formatet" -#: extmod/ulab/code/ndarray.c extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/ndarray.c extmod/ulab/code/numpy/create.c msgid "too many dimensions" msgstr "för många dimensioner" @@ -4525,7 +4649,7 @@ msgstr "watchdog timeout måste vara större än 0" msgid "width must be from 2 to 8 (inclusive), not %d" msgstr "width måste vara mellan 2 och 8, inte %d" -#: shared-bindings/is31fl3741/is31fl3741.c +#: shared-bindings/is31fl3741/FrameBuffer.c #: shared-bindings/rgbmatrix/RGBMatrix.c msgid "width must be greater than zero" msgstr "width måste vara större än noll" @@ -4542,7 +4666,7 @@ msgstr "window måste vara <= interval" msgid "wrong axis index" msgstr "fel axelindex" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "wrong axis specified" msgstr "fel axel angiven" @@ -4550,7 +4674,11 @@ msgstr "fel axel angiven" msgid "wrong input type" msgstr "fel indatatyp" -#: extmod/ulab/code/ulab_create.c py/objarray.c py/objstr.c +#: extmod/ulab/code/numpy/transform.c +msgid "wrong length of condition array" +msgstr "fel längd på villkorsmatrisen" + +#: extmod/ulab/code/numpy/create.c py/objarray.c py/objstr.c msgid "wrong number of arguments" msgstr "fel antal argument" @@ -4594,6 +4722,16 @@ msgstr "zi måste vara av typ float" msgid "zi must be of shape (n_section, 2)" msgstr "zi måste vara i formen (n_section, 2)" +#~ msgid "cannot perform relative import" +#~ msgstr "kan inte utföra relativ import" + +#, c-format +#~ msgid "No I2C device at address: %x" +#~ msgstr "Ingen I2C-enhet på adress: %x" + +#~ msgid "Unsupported pull value." +#~ msgstr "Ogiltigt Pull-värde." + #~ msgid "Station must be started" #~ msgstr "Stationen måste startas" diff --git a/locale/tr.po b/locale/tr.po new file mode 100644 index 0000000000..a4bc023646 --- /dev/null +++ b/locale/tr.po @@ -0,0 +1,4678 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2022-01-16 13:56+0000\n" +"Last-Translator: Gökhan Koçmarlı \n" +"Language-Team: none\n" +"Language: tr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.10.1\n" + +#: main.c +msgid "" +"\n" +"Code done running.\n" +msgstr "" +"\n" +"Program çalıştırıldı.\n" + +#: main.c +msgid "" +"\n" +"Code stopped by auto-reload.\n" +msgstr "" +"\n" +"Program otomatik yeniden yükleme tarafından sonlandırıldı.\n" + +#: supervisor/shared/safe_mode.c +msgid "" +"\n" +"Please file an issue with the contents of your CIRCUITPY drive at \n" +"https://github.com/adafruit/circuitpython/issues\n" +msgstr "" +"\n" +"Lütfen, şu adrese CIRCUITPY sürücünüzün içerikleri ile beraber bir hata/konu " +"kaydı ekleyin\n" +"https://github.com/adafruit/circuitpython/issues\n" + +#: py/obj.c +msgid " File \"%q\"" +msgstr " \"%q\" dosyası" + +#: py/obj.c +msgid " File \"%q\", line %d" +msgstr " \"%q\" dosyası, %d numaralı satır" + +#: py/builtinhelp.c +msgid " is of type %q\n" +msgstr " nesnesi, %q tipindedir\n" + +#: main.c +msgid " not found.\n" +msgstr " bulunamadı.\n" + +#: main.c +msgid " output:\n" +msgstr " çıktı:\n" + +#: py/objstr.c +#, c-format +msgid "%%c requires int or char" +msgstr "%%c int veya char tipine ihtiyaç duyar" + +#: shared-bindings/rgbmatrix/RGBMatrix.c +#, c-format +msgid "" +"%d address pins, %d rgb pins and %d tiles indicate a height of %d, not %d" +msgstr "" +"%d adres pinleri, %d RGB pinleri ve %d döşemeleri %d'nin yüksekliği " +"gösterir, %d'nin değil" + +#: shared-bindings/microcontroller/Pin.c +msgid "%q and %q contain duplicate pins" +msgstr "%q ve %q yinelenen pinler içeriyor" + +#: shared-bindings/microcontroller/Pin.c +msgid "%q contains duplicate pins" +msgstr "%q yinelenen pinler içeriyor" + +#: ports/atmel-samd/common-hal/sdioio/SDCard.c +msgid "%q failure: %d" +msgstr "%q hata: %d" + +#: shared-bindings/microcontroller/Pin.c +msgid "%q in use" +msgstr "%q kullanımda" + +#: ports/atmel-samd/common-hal/pulseio/PulseIn.c +#: ports/cxd56/common-hal/pulseio/PulseIn.c +#: ports/nrf/common-hal/pulseio/PulseIn.c +#: ports/raspberrypi/common-hal/pulseio/PulseIn.c +#: ports/stm/common-hal/pulseio/PulseIn.c py/obj.c py/objstr.c +#: py/objstrunicode.c +msgid "%q index out of range" +msgstr "%q indeksi aralık dışında" + +#: py/obj.c +msgid "%q indices must be integers, not %s" +msgstr "%q indeksleri integer olmalı, %s değil" + +#: py/argcheck.c +msgid "%q length must be %d-%d" +msgstr "%q boyutları %d-%d olmalıdır" + +#: shared-bindings/busio/I2C.c shared-bindings/usb_hid/Device.c +msgid "%q length must be >= 1" +msgstr "%q boyutu >=1 olmalıdır" + +#: py/argcheck.c +msgid "%q must be %d-%d" +msgstr "%q, %d-%d olmalıdır" + +#: py/argcheck.c shared-bindings/gifio/GifWriter.c +msgid "%q must be <= %d" +msgstr "%q <= %d olmalıdır" + +#: py/argcheck.c +msgid "%q must be >= %d" +msgstr "%q >= %d olmalıdır" + +#: py/argcheck.c shared-bindings/memorymonitor/AllocationAlarm.c +msgid "%q must be >= 0" +msgstr "%q >= 0 olmalıdır" + +#: shared-bindings/_bleio/CharacteristicBuffer.c +#: shared-bindings/_bleio/PacketBuffer.c shared-bindings/displayio/Group.c +#: shared-bindings/displayio/Shape.c +#: shared-bindings/memorymonitor/AllocationAlarm.c +#: shared-bindings/vectorio/Circle.c shared-bindings/vectorio/Rectangle.c +msgid "%q must be >= 1" +msgstr "%q >= 1 olmalıdır" + +#: py/argcheck.c +msgid "%q must be a string" +msgstr "%q bir string olmalıdır" + +#: shared-module/vectorio/Polygon.c +msgid "%q must be a tuple of length 2" +msgstr "%q, boyutu 2 olan bir tuple olmalıdır" + +#: ports/espressif/common-hal/imagecapture/ParallelImageCapture.c +#: shared-module/vectorio/VectorShape.c +msgid "%q must be between %d and %d" +msgstr "%q, %d ile %d arasında olmalıdır" + +#: py/argcheck.c +msgid "%q must be of type %q" +msgstr "%q, %q türünde olmalıdır" + +#: shared-bindings/digitalio/Pull.c +msgid "%q must be of type %q or None" +msgstr "%q, %q ya da None türünde olmalıdır" + +#: ports/atmel-samd/common-hal/busio/UART.c +msgid "%q must be power of 2" +msgstr "%q, 2'nin kuvveti olmalıdır" + +#: shared-bindings/wifi/Monitor.c +msgid "%q out of bounds" +msgstr "%q sınırların dışında" + +#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c +#: shared-bindings/canio/Match.c +msgid "%q out of range" +msgstr "%q aralık dışında" + +#: ports/atmel-samd/common-hal/microcontroller/Pin.c +msgid "%q pin invalid" +msgstr "%q pini geçersiz" + +#: shared-bindings/fontio/BuiltinFont.c +msgid "%q should be an int" +msgstr "%q bir int olmalıdır" + +#: shared-bindings/usb_hid/Device.c +msgid "%q with a report ID of 0 must be of length 1" +msgstr "Rapor kimliği 0 olan %q, 1 uzunluğunda olmalıdır" + +#: py/bc.c py/objnamedtuple.c +msgid "%q() takes %d positional arguments but %d were given" +msgstr "%q(), %d konumsal argümanını alır ancak %d verildi" + +#: shared-bindings/usb_hid/Device.c +msgid "%q, %q, and %q must all be the same length" +msgstr "%q, %q ve %q aynı uzunlukta olmalıdır" + +#: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c +#, c-format +msgid "%s error 0x%x" +msgstr "%s hatası 0x%x" + +#: py/argcheck.c +msgid "'%q' argument required" +msgstr "'%q' argümanı gerekli" + +#: py/proto.c +msgid "'%q' object does not support '%q'" +msgstr "'%q' nesnesi '%q' öğesini desteklemiyor" + +#: py/runtime.c +msgid "'%q' object is not an iterator" +msgstr "'%q' nesnesi bir iteratör değildir" + +#: py/objtype.c py/runtime.c shared-module/atexit/__init__.c +msgid "'%q' object is not callable" +msgstr "'%q' nesnesi çağrılabilir değil" + +#: py/runtime.c +msgid "'%q' object is not iterable" +msgstr "'%q' nesnesi iterable değildir" + +#: py/emitinlinethumb.c py/emitinlinextensa.c +#, c-format +msgid "'%s' expects a label" +msgstr "'%s' bir etiket bekliyor" + +#: py/emitinlinethumb.c py/emitinlinextensa.c +#, c-format +msgid "'%s' expects a register" +msgstr "'%s' bir yazmaç bekliyor" + +#: py/emitinlinethumb.c +#, c-format +msgid "'%s' expects a special register" +msgstr "'%s' özel bir yazmaç bekliyor" + +#: py/emitinlinethumb.c +#, c-format +msgid "'%s' expects an FPU register" +msgstr "'%s' bir FPU yazmacı bekliyor" + +#: py/emitinlinethumb.c +#, c-format +msgid "'%s' expects an address of the form [a, b]" +msgstr "'%s', [a, b] biçiminde bir adres bekliyor" + +#: py/emitinlinethumb.c py/emitinlinextensa.c +#, c-format +msgid "'%s' expects an integer" +msgstr "'%s' bir integer bekliyor" + +#: py/emitinlinethumb.c +#, c-format +msgid "'%s' expects at most r%d" +msgstr "'%s' en fazla r%d bekler" + +#: py/emitinlinethumb.c +#, c-format +msgid "'%s' expects {r0, r1, ...}" +msgstr "'%s' {r0, r1, ...} bekliyor" + +#: py/emitinlinextensa.c +#, c-format +msgid "'%s' integer %d isn't within range %d..%d" +msgstr "'%s' integer %d, %d..%d aralığında değil" + +#: py/emitinlinethumb.c +#, c-format +msgid "'%s' integer 0x%x doesn't fit in mask 0x%x" +msgstr "'%s' integer 0x%x, 0x%x maskesine uymuyor" + +#: py/obj.c +#, c-format +msgid "'%s' object doesn't support item assignment" +msgstr "'%s' nesnesi, öğe atamasını desteklemiyor" + +#: py/obj.c +#, c-format +msgid "'%s' object doesn't support item deletion" +msgstr "'%s' nesnesi, öğe silmeyi desteklemiyor" + +#: py/runtime.c +msgid "'%s' object has no attribute '%q'" +msgstr "'%s' nesnesinin '%q' özelliği yok" + +#: py/obj.c +#, c-format +msgid "'%s' object isn't subscriptable" +msgstr "'%s' nesnesi subscriptable özelliğe sahip değil" + +#: py/objstr.c +#, fuzzy +msgid "'=' alignment not allowed in string format specifier" +msgstr "'=' hizalamasına string biçiminde izin verilmez" + +#: shared-module/struct/__init__.c +msgid "'S' and 'O' are not supported format types" +msgstr "'S' ve 'O' desteklenen biçim türlerinden değildir" + +#: py/compile.c +msgid "'align' requires 1 argument" +msgstr "'align' 1 argümana ihtiyaç duyar" + +#: py/compile.c +msgid "'await' outside function" +msgstr "fonksiyon dışında 'await'" + +#: py/compile.c +msgid "'await', 'async for' or 'async with' outside async function" +msgstr "" +"asenkron fonksiyon dışında kullanılan 'await', 'async for' ya da 'async with'" + +#: py/compile.c +msgid "'break' outside loop" +msgstr "döngü dışında 'break'" + +#: py/compile.c +msgid "'continue' outside loop" +msgstr "döngü dışında 'continue'" + +#: py/objgenerator.c +msgid "'coroutine' object is not an iterator" +msgstr "'coroutine' nesnesi bir iteratör değildir" + +#: py/compile.c +msgid "'data' requires at least 2 arguments" +msgstr "'data' en az 2 argümana ihtiyaç duyar" + +#: py/compile.c +msgid "'data' requires integer arguments" +msgstr "'data' integer tipinde argümanlara ihtiyaç duyar" + +#: py/compile.c +msgid "'label' requires 1 argument" +msgstr "'label' 1 argümana ihtiyaç duyar" + +#: py/compile.c +msgid "'return' outside function" +msgstr "fonksiyon dışında 'return'" + +#: py/compile.c +msgid "'yield from' inside async function" +msgstr "asenkron fonksiyon içinde 'yield from'" + +#: py/compile.c +msgid "'yield' outside function" +msgstr "fonksiyon dışında 'yield'" + +#: shared-module/vectorio/VectorShape.c +msgid "(x,y) integers required" +msgstr "(x, y) integerları gereklidir" + +#: py/compile.c +msgid "*x must be assignment target" +msgstr "" + +#: py/obj.c +msgid ", in %q\n" +msgstr ", içinde %q\n" + +#: py/objcomplex.c +msgid "0.0 to a complex power" +msgstr "0.0'dan bir karmaşık güce" + +#: py/modbuiltins.c +msgid "3-arg pow() not supported" +msgstr "3-argümanlı pow() desteklenmemektedir" + +#: shared-module/msgpack/__init__.c +msgid "64 bit types" +msgstr "64 bit tipler" + +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c +#: ports/atmel-samd/common-hal/countio/Counter.c +#: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c +msgid "A hardware interrupt channel is already in use" +msgstr "Bir donanım kesme kanalı halihazırda kullanılmaktadır" + +#: ports/espressif/common-hal/analogio/AnalogIn.c +msgid "ADC2 is being used by WiFi" +msgstr "ADC2, WiFi tarafından kullanılmaktadır" + +#: shared-bindings/_bleio/Address.c shared-bindings/ipaddress/IPv4Address.c +#, c-format +msgid "Address must be %d bytes long" +msgstr "Adres %d byte uzunluğunda olmalıdır" + +#: shared-bindings/_bleio/Address.c +msgid "Address type out of range" +msgstr "Adres tipi beklenen aralığın dışında" + +#: ports/espressif/common-hal/canio/CAN.c +msgid "All CAN peripherals are in use" +msgstr "Tüm CAN çevre birimleri kullanımda" + +#: ports/espressif/common-hal/busio/I2C.c +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c +#: ports/nrf/common-hal/busio/I2C.c +msgid "All I2C peripherals are in use" +msgstr "Tüm I2C çevre birimleri kullanımda" + +#: ports/espressif/common-hal/countio/Counter.c +#: ports/espressif/common-hal/frequencyio/FrequencyIn.c +#: ports/espressif/common-hal/rotaryio/IncrementalEncoder.c +msgid "All PCNT units in use" +msgstr "Tüm PCNT birimleri kullanımda" + +#: ports/atmel-samd/common-hal/canio/Listener.c +#: ports/espressif/common-hal/canio/Listener.c +#: ports/stm/common-hal/canio/Listener.c +msgid "All RX FIFOs in use" +msgstr "Tüm RX FIFO'ları kullanımda" + +#: ports/espressif/common-hal/busio/SPI.c ports/nrf/common-hal/busio/SPI.c +msgid "All SPI peripherals are in use" +msgstr "Tüm SPI çevre birimleri kullanımda" + +#: ports/espressif/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/raspberrypi/common-hal/busio/UART.c +msgid "All UART peripherals are in use" +msgstr "Tüm UART çevre birimleri kullanımda" + +#: ports/nrf/common-hal/countio/Counter.c +#: ports/nrf/common-hal/pulseio/PulseIn.c +#: ports/nrf/common-hal/rotaryio/IncrementalEncoder.c +#: shared-bindings/pwmio/PWMOut.c +msgid "All channels in use" +msgstr "Tüm kanallar kullanımda" + +#: ports/atmel-samd/common-hal/audioio/AudioOut.c +msgid "All event channels in use" +msgstr "Tüm olay kanalları kullanımda" + +#: ports/raspberrypi/common-hal/pulseio/PulseIn.c +#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c +msgid "All state machines in use" +msgstr "Tüm durum makineleri kullanımda" + +#: ports/atmel-samd/audio_dma.c +msgid "All sync event channels in use" +msgstr "Tüm asenkron olay kanalları kullanımda" + +#: shared-bindings/pwmio/PWMOut.c +msgid "All timers for this pin are in use" +msgstr "Bu pin için tüm zamanlayıcılar kullanımda" + +#: ports/atmel-samd/common-hal/_pew/PewPew.c +#: ports/atmel-samd/common-hal/audioio/AudioOut.c +#: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c +#: ports/atmel-samd/common-hal/pulseio/PulseIn.c +#: ports/atmel-samd/common-hal/pulseio/PulseOut.c +#: ports/cxd56/common-hal/pulseio/PulseOut.c +#: ports/espressif/common-hal/frequencyio/FrequencyIn.c +#: ports/espressif/common-hal/neopixel_write/__init__.c +#: ports/espressif/common-hal/pulseio/PulseIn.c +#: ports/espressif/common-hal/pulseio/PulseOut.c +#: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c +#: ports/nrf/common-hal/pulseio/PulseIn.c ports/nrf/peripherals/nrf/timers.c +#: ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c +#: ports/stm/peripherals/timers.c shared-bindings/pwmio/PWMOut.c +msgid "All timers in use" +msgstr "Tüm zamanlayıcılar kullanımda" + +#: ports/espressif/common-hal/_bleio/Adapter.c +#: ports/nrf/common-hal/_bleio/Adapter.c +msgid "Already advertising." +msgstr "Halihazırda duyuruluyor." + +#: ports/atmel-samd/common-hal/canio/Listener.c +msgid "Already have all-matches listener" +msgstr "" + +#: shared-module/memorymonitor/AllocationAlarm.c +#: shared-module/memorymonitor/AllocationSize.c +msgid "Already running" +msgstr "Halihazırda çalışıyor" + +#: ports/espressif/common-hal/wifi/Radio.c +msgid "Already scanning for wifi networks" +msgstr "Halihazırda wifi ağları için tarama yapılıyor" + +#: ports/cxd56/common-hal/analogio/AnalogIn.c +msgid "AnalogIn not supported on given pin" +msgstr "Verilen pin için AnalogIn desteklenmemektedir" + +#: ports/cxd56/common-hal/analogio/AnalogOut.c +#: ports/mimxrt10xx/common-hal/analogio/AnalogOut.c +#: ports/nrf/common-hal/analogio/AnalogOut.c +#: ports/raspberrypi/common-hal/analogio/AnalogOut.c +msgid "AnalogOut functionality not supported" +msgstr "AnalogOut işlevi desteklenmemektedir" + +#: shared-bindings/analogio/AnalogOut.c +msgid "AnalogOut is only 16 bits. Value must be less than 65536." +msgstr "AnalogOut yalnızca 16 bitlik. Değer 65536'dan küçük olmalıdır." + +#: ports/atmel-samd/common-hal/analogio/AnalogOut.c +msgid "AnalogOut not supported on given pin" +msgstr "Verilen pin için AnalogOut desteklenmemektedir" + +#: ports/stm/common-hal/audiopwmio/PWMAudioOut.c +msgid "Another PWMAudioOut is already active" +msgstr "Başka bir PWMAudioOut zaten aktif durumda" + +#: ports/atmel-samd/common-hal/pulseio/PulseOut.c +#: ports/cxd56/common-hal/pulseio/PulseOut.c +msgid "Another send is already active" +msgstr "Başka bir gönderme zaten aktif" + +#: shared-bindings/pulseio/PulseOut.c +msgid "Array must contain halfwords (type 'H')" +msgstr "Dizi yarımsözcüklere sahip olmalıdır (tip 'H')" + +#: shared-bindings/alarm/SleepMemory.c shared-bindings/nvm/ByteArray.c +msgid "Array values should be single bytes." +msgstr "Dizi değerleri tekil bytelar olmalıdır." + +#: shared-bindings/microcontroller/Pin.c +msgid "At most %d %q may be specified (not %d)" +msgstr "" + +#: shared-module/memorymonitor/AllocationAlarm.c +#, c-format +msgid "Attempt to allocate %d blocks" +msgstr "%d bloğun ayrılması girişimi" + +#: supervisor/shared/safe_mode.c +msgid "Attempted heap allocation when VM not running." +msgstr "VM çalışmazken heap'ten alan tahsis edilmeye çalışıldı." + +#: ports/raspberrypi/audio_dma.c +msgid "Audio conversion not implemented" +msgstr "Ses dönüşümü implemente edilmedi" + +#: shared-bindings/wifi/Radio.c +msgid "AuthMode.OPEN is not used with password" +msgstr "AuthMode.OPEN bir şifre ile kullanılmadı" + +#: shared-bindings/wifi/Radio.c +msgid "Authentication failure" +msgstr "Kimlik doğrulama hatası" + +#: main.c +msgid "Auto-reload is off.\n" +msgstr "Otomatik yeniden yükleme devre dışı.\n" + +#: main.c +msgid "" +"Auto-reload is on. Simply save files over USB to run them or enter REPL to " +"disable.\n" +msgstr "" +"Otomatik yeniden yükleme aktif. Dosyaları çalıştırmak için USB aracılığı ile " +"kaydedin ya da deaktif etmek için REPL moda girin.\n" + +#: ports/espressif/common-hal/canio/CAN.c +msgid "Baudrate not supported by peripheral" +msgstr "Baudhızı, çevre birimi tarafından desteklenmiyor" + +#: shared-module/displayio/Display.c +#: shared-module/framebufferio/FramebufferDisplay.c +msgid "Below minimum frame rate" +msgstr "Minimum kare hızından altında" + +#: ports/raspberrypi/common-hal/audiobusio/I2SOut.c +msgid "Bit clock and word select must be sequential pins" +msgstr "" + +#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c +msgid "Bit clock and word select must share a clock unit" +msgstr "" + +#: shared-bindings/rgbmatrix/RGBMatrix.c +#, c-format +msgid "Bit depth must be from 1 to 6 inclusive, not %d" +msgstr "" + +#: shared-bindings/audiobusio/PDMIn.c +msgid "Bit depth must be multiple of 8." +msgstr "" + +#: shared-bindings/bitmaptools/__init__.c +msgid "Bitmap size and bits per value must match" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "Boot device must be first device (interface #0)." +msgstr "" + +#: ports/mimxrt10xx/common-hal/busio/UART.c +msgid "Both RX and TX required for flow control" +msgstr "" + +#: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c +msgid "Both pins must support hardware interrupts" +msgstr "" + +#: shared-bindings/displayio/Display.c +#: shared-bindings/framebufferio/FramebufferDisplay.c +#: shared-bindings/is31fl3741/FrameBuffer.c +#: shared-bindings/rgbmatrix/RGBMatrix.c +msgid "Brightness must be 0-1.0" +msgstr "" + +#: shared-bindings/supervisor/__init__.c +msgid "Brightness must be between 0 and 255" +msgstr "" + +#: shared-bindings/displayio/Display.c +#: shared-bindings/framebufferio/FramebufferDisplay.c +msgid "Brightness not adjustable" +msgstr "" + +#: shared-bindings/_bleio/UUID.c +#, c-format +msgid "Buffer + offset too small %d %d %d" +msgstr "" + +#: ports/raspberrypi/bindings/rp2pio/StateMachine.c +msgid "Buffer elements must be 4 bytes long or less" +msgstr "" + +#: shared-module/usb_hid/Device.c +#, c-format +msgid "Buffer incorrect size. Should be %d bytes." +msgstr "" + +#: shared-bindings/framebufferio/FramebufferDisplay.c +msgid "Buffer is not a bytearray." +msgstr "" + +#: ports/cxd56/common-hal/camera/Camera.c shared-bindings/displayio/Display.c +#: shared-bindings/framebufferio/FramebufferDisplay.c +msgid "Buffer is too small" +msgstr "" + +#: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c +#: ports/stm/common-hal/audiopwmio/PWMAudioOut.c +#, c-format +msgid "Buffer length %d too big. It must be less than %d" +msgstr "" + +#: ports/atmel-samd/common-hal/sdioio/SDCard.c +#: ports/cxd56/common-hal/sdioio/SDCard.c shared-module/sdcardio/SDCard.c +msgid "Buffer length must be a multiple of 512" +msgstr "" + +#: ports/stm/common-hal/sdioio/SDCard.c +msgid "Buffer must be a multiple of 512 bytes" +msgstr "" + +#: shared-bindings/bitbangio/I2C.c +msgid "Buffer must be at least length 1" +msgstr "" + +#: shared-bindings/_bleio/PacketBuffer.c +#, c-format +msgid "Buffer too short by %d bytes" +msgstr "" + +#: ports/espressif/common-hal/imagecapture/ParallelImageCapture.c +msgid "Buffers must be same size" +msgstr "" + +#: ports/atmel-samd/common-hal/paralleldisplay/ParallelBus.c +#: ports/espressif/common-hal/paralleldisplay/ParallelBus.c +#: ports/nrf/common-hal/paralleldisplay/ParallelBus.c +#: ports/raspberrypi/common-hal/paralleldisplay/ParallelBus.c +#, c-format +msgid "Bus pin %d is already in use" +msgstr "" + +#: shared-bindings/_bleio/UUID.c +msgid "Byte buffer must be 16 bytes." +msgstr "" + +#: shared-bindings/alarm/SleepMemory.c shared-bindings/nvm/ByteArray.c +msgid "Bytes must be between 0 and 255." +msgstr "" + +#: shared-bindings/aesio/aes.c +msgid "CBC blocks must be multiples of 16 bytes" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "CIRCUITPY drive could not be found or created." +msgstr "" + +#: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c +msgid "CRC or checksum was invalid" +msgstr "" + +#: py/objtype.c +msgid "Call super().__init__() before accessing native object." +msgstr "" + +#: ports/espressif/common-hal/alarm/pin/PinAlarm.c +msgid "Can only alarm on RTC IO from deep sleep." +msgstr "" + +#: ports/espressif/common-hal/alarm/pin/PinAlarm.c +msgid "Can only alarm on one low pin while others alarm high from deep sleep." +msgstr "" + +#: ports/espressif/common-hal/alarm/pin/PinAlarm.c +msgid "Can only alarm on two low pins from deep sleep." +msgstr "" + +#: ports/nrf/common-hal/_bleio/Characteristic.c +msgid "Can't set CCCD on local Characteristic" +msgstr "" + +#: shared-bindings/storage/__init__.c shared-bindings/usb_cdc/__init__.c +#: shared-bindings/usb_hid/__init__.c shared-bindings/usb_midi/__init__.c +msgid "Cannot change USB devices now" +msgstr "" + +#: shared-bindings/_bleio/Adapter.c +msgid "Cannot create a new Adapter; use _bleio.adapter;" +msgstr "" + +#: shared-bindings/displayio/Bitmap.c +#: shared-bindings/memorymonitor/AllocationSize.c +#: shared-bindings/pulseio/PulseIn.c +msgid "Cannot delete values" +msgstr "" + +#: ports/atmel-samd/common-hal/digitalio/DigitalInOut.c +#: ports/mimxrt10xx/common-hal/digitalio/DigitalInOut.c +#: ports/nrf/common-hal/digitalio/DigitalInOut.c +#: ports/raspberrypi/common-hal/digitalio/DigitalInOut.c +msgid "Cannot get pull while in output mode" +msgstr "" + +#: ports/nrf/common-hal/microcontroller/Processor.c +msgid "Cannot get temperature" +msgstr "" + +#: shared-bindings/_bleio/Adapter.c +msgid "Cannot have scan responses for extended, connectable advertisements." +msgstr "" + +#: ports/atmel-samd/common-hal/audioio/AudioOut.c +msgid "Cannot output both channels on the same pin" +msgstr "" + +#: ports/espressif/common-hal/alarm/pin/PinAlarm.c +msgid "Cannot pull on input-only pin." +msgstr "" + +#: shared-module/bitbangio/SPI.c +msgid "Cannot read without MISO pin." +msgstr "" + +#: shared-bindings/audiobusio/PDMIn.c +msgid "Cannot record to a file" +msgstr "" + +#: shared-module/storage/__init__.c +msgid "Cannot remount '/' when visible via USB." +msgstr "" + +#: ports/atmel-samd/common-hal/microcontroller/__init__.c +#: ports/cxd56/common-hal/microcontroller/__init__.c +#: ports/mimxrt10xx/common-hal/microcontroller/__init__.c +msgid "Cannot reset into bootloader because no bootloader is present." +msgstr "" + +#: ports/espressif/common-hal/socketpool/Socket.c +msgid "Cannot set socket options" +msgstr "" + +#: shared-bindings/digitalio/DigitalInOut.c +msgid "Cannot set value when direction is input." +msgstr "" + +#: ports/espressif/common-hal/busio/UART.c +#: ports/mimxrt10xx/common-hal/busio/UART.c +msgid "Cannot specify RTS or CTS in RS485 mode" +msgstr "" + +#: py/objslice.c +msgid "Cannot subclass slice" +msgstr "" + +#: shared-module/bitbangio/SPI.c +msgid "Cannot transfer without MOSI and MISO pins." +msgstr "" + +#: shared-bindings/pwmio/PWMOut.c +msgid "Cannot vary frequency on a timer that is already in use" +msgstr "" + +#: ports/espressif/common-hal/alarm/pin/PinAlarm.c +#: ports/nrf/common-hal/alarm/pin/PinAlarm.c +msgid "Cannot wake on pin edge. Only level." +msgstr "" + +#: shared-module/bitbangio/SPI.c +msgid "Cannot write without MOSI pin." +msgstr "" + +#: shared-bindings/_bleio/CharacteristicBuffer.c +msgid "CharacteristicBuffer writing not provided" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "CircuitPython core code crashed hard. Whoops!\n" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "CircuitPython was unable to allocate the heap." +msgstr "" + +#: shared-module/bitbangio/SPI.c +msgid "Clock pin init failed." +msgstr "" + +#: shared-module/bitbangio/I2C.c +msgid "Clock stretch too long" +msgstr "" + +#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c +msgid "Clock unit in use" +msgstr "" + +#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/I2CDisplay.c +#: shared-bindings/paralleldisplay/ParallelBus.c +msgid "Command must be an int between 0 and 255" +msgstr "" + +#: shared-bindings/_bleio/Connection.c +msgid "" +"Connection has been disconnected and can no longer be used. Create a new " +"connection." +msgstr "" + +#: py/persistentcode.c +msgid "Corrupt .mpy file" +msgstr "" + +#: ports/cxd56/common-hal/camera/Camera.c +msgid "Could not initialize Camera" +msgstr "" + +#: ports/cxd56/common-hal/gnss/GNSS.c +msgid "Could not initialize GNSS" +msgstr "" + +#: ports/cxd56/common-hal/sdioio/SDCard.c +msgid "Could not initialize SDCard" +msgstr "" + +#: ports/atmel-samd/common-hal/busio/UART.c ports/cxd56/common-hal/busio/UART.c +#: ports/espressif/common-hal/busio/UART.c +msgid "Could not initialize UART" +msgstr "" + +#: ports/stm/common-hal/pwmio/PWMOut.c +msgid "Could not re-init channel" +msgstr "" + +#: ports/stm/common-hal/pwmio/PWMOut.c +msgid "Could not re-init timer" +msgstr "" + +#: ports/stm/common-hal/pwmio/PWMOut.c +msgid "Could not restart PWM" +msgstr "" + +#: ports/espressif/common-hal/neopixel_write/__init__.c +msgid "Could not retrieve clock" +msgstr "" + +#: shared-bindings/_bleio/Adapter.c +msgid "Could not set address" +msgstr "" + +#: shared-bindings/pwmio/PWMOut.c +msgid "Could not start PWM" +msgstr "" + +#: ports/stm/common-hal/busio/UART.c +msgid "Could not start interrupt, RX busy" +msgstr "" + +#: shared-module/audiomp3/MP3Decoder.c +msgid "Couldn't allocate decoder" +msgstr "" + +#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c +#: shared-module/audiomp3/MP3Decoder.c +msgid "Couldn't allocate first buffer" +msgstr "" + +#: shared-module/audiomp3/MP3Decoder.c +msgid "Couldn't allocate input buffer" +msgstr "" + +#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c +#: shared-module/audiomp3/MP3Decoder.c +msgid "Couldn't allocate second buffer" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "Crash into the HardFault_Handler." +msgstr "" + +#: ports/stm/common-hal/analogio/AnalogOut.c +msgid "DAC Channel Init Error" +msgstr "" + +#: ports/stm/common-hal/analogio/AnalogOut.c +msgid "DAC Device Init Error" +msgstr "" + +#: ports/atmel-samd/common-hal/audioio/AudioOut.c +msgid "DAC already in use" +msgstr "" + +#: ports/atmel-samd/common-hal/paralleldisplay/ParallelBus.c +#: ports/nrf/common-hal/paralleldisplay/ParallelBus.c +msgid "Data 0 pin must be byte aligned" +msgstr "" + +#: shared-module/audiocore/WaveFile.c +msgid "Data chunk must follow fmt chunk" +msgstr "" + +#: ports/espressif/common-hal/_bleio/Adapter.c +#: ports/nrf/common-hal/_bleio/Adapter.c +msgid "Data not supported with directed advertising" +msgstr "" + +#: ports/espressif/common-hal/_bleio/Adapter.c +#: ports/nrf/common-hal/_bleio/Adapter.c +msgid "Data too large for advertisement packet" +msgstr "" + +#: ports/stm/common-hal/alarm/pin/PinAlarm.c +msgid "Deep sleep pins must use a rising edge with pulldown" +msgstr "" + +#: shared-bindings/audiobusio/PDMIn.c +msgid "Destination capacity is smaller than destination_length." +msgstr "" + +#: ports/nrf/common-hal/audiobusio/I2SOut.c +msgid "Device in use" +msgstr "" + +#: ports/cxd56/common-hal/digitalio/DigitalInOut.c +msgid "DigitalInOut not supported on given pin" +msgstr "" + +#: shared-bindings/displayio/Display.c +#: shared-bindings/framebufferio/FramebufferDisplay.c +msgid "Display must have a 16 bit colorspace." +msgstr "" + +#: shared-bindings/displayio/Display.c +#: shared-bindings/displayio/EPaperDisplay.c +#: shared-bindings/framebufferio/FramebufferDisplay.c +msgid "Display rotation must be in 90 degree increments" +msgstr "" + +#: shared-bindings/digitalio/DigitalInOut.c +msgid "Drive mode not used when direction is input." +msgstr "" + +#: shared-bindings/aesio/aes.c +msgid "ECB only operates on 16 bytes at a time" +msgstr "" + +#: ports/espressif/common-hal/busio/SPI.c +#: ports/espressif/common-hal/canio/CAN.c +msgid "ESP-IDF memory allocation failed" +msgstr "" + +#: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c +#: ports/atmel-samd/common-hal/ps2io/Ps2.c +#: ports/atmel-samd/common-hal/pulseio/PulseIn.c +#: ports/cxd56/common-hal/pulseio/PulseIn.c +msgid "EXTINT channel already in use" +msgstr "" + +#: shared-module/synthio/MidiTrack.c +#, c-format +msgid "Error in MIDI stream at position %d" +msgstr "" + +#: extmod/modure.c +msgid "Error in regex" +msgstr "" + +#: shared-bindings/socketpool/Socket.c shared-bindings/ssl/SSLSocket.c +msgid "Error: Failure to bind" +msgstr "" + +#: ports/raspberrypi/bindings/rp2pio/StateMachine.c py/enum.c +#: shared-bindings/_bleio/__init__.c shared-bindings/aesio/aes.c +#: shared-bindings/busio/SPI.c shared-bindings/microcontroller/Pin.c +#: shared-bindings/neopixel_write/__init__.c +msgid "Expected a %q" +msgstr "" + +#: shared-bindings/alarm/__init__.c +msgid "Expected an alarm" +msgstr "" + +#: shared-module/adafruit_pixelbuf/PixelBuf.c +#, c-format +msgid "Expected tuple of length %d, got %d" +msgstr "" + +#: ports/espressif/common-hal/_bleio/Adapter.c +#: ports/nrf/common-hal/_bleio/Adapter.c +msgid "Extended advertisements with scan response not supported." +msgstr "" + +#: extmod/ulab/code/numpy/fft/fft_tools.c +msgid "FFT is defined for ndarrays only" +msgstr "" + +#: extmod/ulab/code/numpy/fft/fft_tools.c +msgid "FFT is implemented for linear arrays only" +msgstr "" + +#: ports/espressif/common-hal/ssl/SSLSocket.c +msgid "Failed SSL handshake" +msgstr "" + +#: shared-bindings/ps2io/Ps2.c +msgid "Failed sending command." +msgstr "" + +#: ports/nrf/sd_mutex.c +#, c-format +msgid "Failed to acquire mutex, err 0x%04x" +msgstr "" + +#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/raspberrypi/common-hal/busio/UART.c +msgid "Failed to allocate RX buffer" +msgstr "" + +#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/atmel-samd/common-hal/pulseio/PulseIn.c +#: ports/cxd56/common-hal/pulseio/PulseIn.c +#: ports/espressif/common-hal/pulseio/PulseIn.c +#: ports/nrf/common-hal/pulseio/PulseIn.c +#: ports/raspberrypi/common-hal/pulseio/PulseIn.c +#: ports/stm/common-hal/pulseio/PulseIn.c +#, c-format +msgid "Failed to allocate RX buffer of %d bytes" +msgstr "" + +#: ports/espressif/common-hal/wifi/__init__.c +msgid "Failed to allocate Wifi memory" +msgstr "" + +#: ports/espressif/common-hal/wifi/ScannedNetworks.c +msgid "Failed to allocate wifi scan memory" +msgstr "" + +#: ports/stm/common-hal/audiopwmio/PWMAudioOut.c +msgid "Failed to buffer the sample" +msgstr "" + +#: ports/espressif/common-hal/_bleio/Adapter.c +#: ports/nrf/common-hal/_bleio/Adapter.c +msgid "Failed to connect: internal error" +msgstr "" + +#: ports/nrf/common-hal/_bleio/Adapter.c +msgid "Failed to connect: timeout" +msgstr "" + +#: ports/espressif/common-hal/wifi/__init__.c +msgid "Failed to init wifi" +msgstr "" + +#: shared-module/audiomp3/MP3Decoder.c +msgid "Failed to parse MP3 file" +msgstr "" + +#: ports/nrf/sd_mutex.c +#, c-format +msgid "Failed to release mutex, err 0x%04x" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "Failed to write internal flash." +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "Fatal error." +msgstr "" + +#: py/moduerrno.c +msgid "File exists" +msgstr "" + +#: ports/atmel-samd/common-hal/canio/Listener.c +#: ports/espressif/common-hal/canio/Listener.c +#: ports/stm/common-hal/canio/Listener.c +msgid "Filters too complex" +msgstr "" + +#: ports/espressif/common-hal/dualbank/__init__.c +msgid "Firmware image is invalid" +msgstr "" + +#: shared-bindings/bitmaptools/__init__.c +msgid "For L8 colorspace, input bitmap must have 8 bits per pixel" +msgstr "" + +#: shared-bindings/bitmaptools/__init__.c +msgid "For RGB colorspaces, input bitmap must have 16 bits per pixel" +msgstr "" + +#: ports/cxd56/common-hal/camera/Camera.c +msgid "Format not supported" +msgstr "" + +#: shared-module/framebufferio/FramebufferDisplay.c +#, c-format +msgid "Framebuffer requires %d bytes" +msgstr "" + +#: shared-bindings/pwmio/PWMOut.c +msgid "Frequency must match existing PWMOut using this timer" +msgstr "" + +#: shared-bindings/bitbangio/I2C.c shared-bindings/bitbangio/SPI.c +#: shared-bindings/busio/I2C.c shared-bindings/busio/SPI.c +msgid "Function requires lock" +msgstr "" + +#: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c +msgid "Generic Failure" +msgstr "" + +#: shared-bindings/displayio/Display.c +#: shared-bindings/displayio/EPaperDisplay.c +#: shared-bindings/framebufferio/FramebufferDisplay.c +msgid "Group already used" +msgstr "" + +#: ports/atmel-samd/common-hal/busio/SPI.c ports/cxd56/common-hal/busio/SPI.c +#: ports/espressif/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/nrf/common-hal/busio/SPI.c +#: ports/raspberrypi/common-hal/busio/SPI.c +msgid "Half duplex SPI is not implemented" +msgstr "" + +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/I2C.c +#: ports/stm/common-hal/busio/SPI.c ports/stm/common-hal/canio/CAN.c +#: ports/stm/common-hal/sdioio/SDCard.c +msgid "Hardware busy, try alternative pins" +msgstr "" + +#: ports/mimxrt10xx/common-hal/busio/UART.c ports/stm/common-hal/busio/UART.c +msgid "Hardware in use, try alternative pins" +msgstr "" + +#: shared-bindings/wifi/Radio.c +msgid "Hostname must be between 1 and 253 characters" +msgstr "" + +#: extmod/vfs_posix_file.c py/objstringio.c +msgid "I/O operation on closed file" +msgstr "" + +#: ports/stm/common-hal/busio/I2C.c +msgid "I2C Init Error" +msgstr "" + +#: ports/raspberrypi/common-hal/busio/I2C.c +msgid "I2C peripheral in use" +msgstr "" + +#: shared-bindings/audiobusio/I2SOut.c +msgid "I2SOut not available" +msgstr "" + +#: shared-bindings/aesio/aes.c +#, c-format +msgid "IV must be %d bytes long" +msgstr "" + +#: ports/raspberrypi/bindings/rp2pio/StateMachine.c +msgid "In-buffer elements must be <= 4 bytes long" +msgstr "" + +#: py/persistentcode.c +msgid "" +"Incompatible .mpy file. Please update all .mpy files. See http://adafru.it/" +"mpy-update for more info." +msgstr "" + +#: shared-bindings/_pew/PewPew.c +msgid "Incorrect buffer size" +msgstr "" + +#: ports/raspberrypi/bindings/rp2pio/StateMachine.c +msgid "Init program size invalid" +msgstr "" + +#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c +msgid "Initial set pin direction conflicts with initial out pin direction" +msgstr "" + +#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c +msgid "Initial set pin state conflicts with initial out pin state" +msgstr "" + +#: ports/espressif/common-hal/watchdog/WatchDogTimer.c +msgid "Initialization failed due to lack of memory" +msgstr "" + +#: shared-bindings/bitops/__init__.c +#, c-format +msgid "Input buffer length (%d) must be a multiple of the strand count (%d)" +msgstr "" + +#: ports/atmel-samd/common-hal/pulseio/PulseIn.c +msgid "Input taking too long" +msgstr "" + +#: ports/espressif/common-hal/neopixel_write/__init__.c py/moduerrno.c +msgid "Input/output error" +msgstr "" + +#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c +#, c-format +msgid "Instruction %d shifts in more bits than pin count" +msgstr "" + +#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c +#, c-format +msgid "Instruction %d shifts out more bits than pin count" +msgstr "" + +#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c +#, c-format +msgid "Instruction %d uses extra pin" +msgstr "" + +#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c +#, c-format +msgid "Instruction %d waits on input outside of count" +msgstr "" + +#: ports/nrf/common-hal/_bleio/__init__.c +msgid "Insufficient authentication" +msgstr "" + +#: ports/nrf/common-hal/_bleio/__init__.c +msgid "Insufficient encryption" +msgstr "" + +#: ports/espressif/common-hal/wifi/Radio.c +msgid "Interface must be started" +msgstr "" + +#: ports/atmel-samd/audio_dma.c ports/raspberrypi/audio_dma.c +msgid "Internal audio buffer too small" +msgstr "" + +#: ports/stm/common-hal/busio/UART.c +msgid "Internal define error" +msgstr "" + +#: ports/espressif/common-hal/paralleldisplay/ParallelBus.c +msgid "Internal error" +msgstr "" + +#: shared-module/rgbmatrix/RGBMatrix.c +#, c-format +msgid "Internal error #%d" +msgstr "" + +#: shared-bindings/sdioio/SDCard.c shared-module/usb_hid/Device.c +msgid "Invalid %q" +msgstr "" + +#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c +#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c +#: ports/atmel-samd/common-hal/imagecapture/ParallelImageCapture.c +#: ports/mimxrt10xx/common-hal/busio/UART.c +msgid "Invalid %q pin" +msgstr "" + +#: ports/stm/common-hal/busio/I2C.c ports/stm/common-hal/busio/SPI.c +#: ports/stm/common-hal/busio/UART.c ports/stm/common-hal/canio/CAN.c +#: ports/stm/common-hal/sdioio/SDCard.c +msgid "Invalid %q pin selection" +msgstr "" + +#: ports/stm/common-hal/analogio/AnalogIn.c +msgid "Invalid ADC Unit value" +msgstr "" + +#: ports/espressif/common-hal/wifi/Radio.c +msgid "Invalid AuthMode" +msgstr "" + +#: ports/espressif/common-hal/_bleio/__init__.c +#: ports/nrf/common-hal/_bleio/__init__.c +msgid "Invalid BLE parameter" +msgstr "" + +#: shared-module/displayio/OnDiskBitmap.c +msgid "Invalid BMP file" +msgstr "" + +#: shared-bindings/wifi/Radio.c +msgid "Invalid BSSID" +msgstr "" + +#: ports/espressif/common-hal/analogio/AnalogOut.c +#: ports/stm/common-hal/analogio/AnalogOut.c +msgid "Invalid DAC pin supplied" +msgstr "" + +#: shared-bindings/wifi/Radio.c +msgid "Invalid MAC address" +msgstr "" + +#: shared-bindings/synthio/__init__.c +msgid "Invalid MIDI file" +msgstr "" + +#: ports/atmel-samd/common-hal/pwmio/PWMOut.c +#: ports/cxd56/common-hal/pwmio/PWMOut.c +#: ports/espressif/common-hal/pwmio/PWMOut.c +#: ports/mimxrt10xx/common-hal/pwmio/PWMOut.c +#: ports/nrf/common-hal/pwmio/PWMOut.c +#: ports/raspberrypi/common-hal/pwmio/PWMOut.c shared-bindings/pwmio/PWMOut.c +msgid "Invalid PWM frequency" +msgstr "" + +#: ports/espressif/common-hal/analogio/AnalogIn.c +msgid "Invalid Pin" +msgstr "" + +#: ports/espressif/bindings/espidf/__init__.c +#: ports/espressif/common-hal/busio/I2C.c +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c +#: ports/espressif/esp_error.c py/moduerrno.c +#: shared-module/rgbmatrix/RGBMatrix.c +msgid "Invalid argument" +msgstr "" + +#: shared-module/displayio/Bitmap.c +msgid "Invalid bits per value" +msgstr "" + +#: ports/nrf/common-hal/busio/UART.c ports/raspberrypi/common-hal/busio/UART.c +#: ports/stm/common-hal/busio/UART.c +msgid "Invalid buffer size" +msgstr "" + +#: shared-bindings/adafruit_pixelbuf/PixelBuf.c +msgid "Invalid byteorder string" +msgstr "" + +#: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c +#: ports/espressif/common-hal/frequencyio/FrequencyIn.c +msgid "Invalid capture period. Valid range: 1 - 500" +msgstr "" + +#: shared-bindings/audiomixer/Mixer.c +msgid "Invalid channel count" +msgstr "" + +#: ports/atmel-samd/common-hal/imagecapture/ParallelImageCapture.c +#, c-format +msgid "Invalid data_count %d" +msgstr "" + +#: ports/atmel-samd/common-hal/imagecapture/ParallelImageCapture.c +#, c-format +msgid "Invalid data_pins[%d]" +msgstr "" + +#: shared-bindings/digitalio/DigitalInOut.c +msgid "Invalid direction." +msgstr "" + +#: shared-module/audiocore/WaveFile.c +msgid "Invalid file" +msgstr "" + +#: shared-module/audiocore/WaveFile.c +msgid "Invalid format chunk size" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "Invalid memory access." +msgstr "" + +#: extmod/vfs_fat_file.c +msgid "Invalid mode" +msgstr "" + +#: ports/espressif/common-hal/wifi/Radio.c +msgid "Invalid multicast MAC address" +msgstr "" + +#: shared-bindings/bitbangio/SPI.c shared-bindings/busio/SPI.c +msgid "Invalid number of bits" +msgstr "" + +#: shared-bindings/bitbangio/SPI.c shared-bindings/busio/SPI.c +#: shared-bindings/displayio/FourWire.c +msgid "Invalid phase" +msgstr "" + +#: ports/atmel-samd/common-hal/audioio/AudioOut.c +#: ports/atmel-samd/common-hal/touchio/TouchIn.c +#: ports/espressif/common-hal/alarm/touch/TouchAlarm.c +#: ports/espressif/common-hal/touchio/TouchIn.c +#: ports/nrf/common-hal/alarm/pin/PinAlarm.c shared-bindings/pwmio/PWMOut.c +#: shared-module/rgbmatrix/RGBMatrix.c +msgid "Invalid pin" +msgstr "" + +#: ports/atmel-samd/common-hal/audioio/AudioOut.c +msgid "Invalid pin for left channel" +msgstr "" + +#: ports/atmel-samd/common-hal/audioio/AudioOut.c +msgid "Invalid pin for right channel" +msgstr "" + +#: ports/atmel-samd/common-hal/busio/I2C.c +#: ports/atmel-samd/common-hal/busio/SPI.c +#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/atmel-samd/common-hal/i2cperipheral/I2CPeripheral.c +#: ports/cxd56/common-hal/busio/I2C.c ports/cxd56/common-hal/busio/SPI.c +#: ports/cxd56/common-hal/busio/UART.c ports/cxd56/common-hal/sdioio/SDCard.c +#: ports/espressif/common-hal/busio/I2C.c +#: ports/espressif/common-hal/busio/SPI.c +#: ports/espressif/common-hal/busio/UART.c +#: ports/espressif/common-hal/canio/CAN.c +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c +#: ports/mimxrt10xx/common-hal/busio/I2C.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/nrf/common-hal/busio/I2C.c +#: ports/raspberrypi/common-hal/busio/I2C.c +#: ports/raspberrypi/common-hal/busio/SPI.c +#: ports/raspberrypi/common-hal/busio/UART.c shared-bindings/busio/SPI.c +#: shared-bindings/busio/UART.c +msgid "Invalid pins" +msgstr "" + +#: shared-bindings/bitbangio/SPI.c shared-bindings/busio/SPI.c +#: shared-bindings/displayio/FourWire.c +msgid "Invalid polarity" +msgstr "" + +#: shared-bindings/_bleio/Characteristic.c +msgid "Invalid properties" +msgstr "" + +#: shared-bindings/microcontroller/__init__.c +msgid "Invalid run mode." +msgstr "" + +#: shared-module/_bleio/Attribute.c +msgid "Invalid security_mode" +msgstr "" + +#: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c +msgid "Invalid size" +msgstr "" + +#: ports/espressif/common-hal/ssl/SSLContext.c +msgid "Invalid socket for TLS" +msgstr "" + +#: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c +msgid "Invalid state" +msgstr "" + +#: shared-bindings/audiomixer/Mixer.c +msgid "Invalid voice" +msgstr "" + +#: shared-bindings/audiomixer/Mixer.c +msgid "Invalid voice count" +msgstr "" + +#: shared-module/audiocore/WaveFile.c +msgid "Invalid wave file" +msgstr "" + +#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/raspberrypi/common-hal/busio/UART.c ports/stm/common-hal/busio/UART.c +msgid "Invalid word/bit length" +msgstr "" + +#: shared-bindings/aesio/aes.c +msgid "Key must be 16, 24, or 32 bytes long" +msgstr "" + +#: shared-module/is31fl3741/FrameBuffer.c +msgid "LED mappings must match display size" +msgstr "" + +#: py/compile.c +msgid "LHS of keyword arg must be an id" +msgstr "" + +#: shared-module/displayio/Group.c +msgid "Layer already in a group." +msgstr "" + +#: shared-module/displayio/Group.c +msgid "Layer must be a Group or TileGrid subclass." +msgstr "" + +#: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c +msgid "MAC address was invalid" +msgstr "" + +#: shared-module/bitbangio/SPI.c +msgid "MISO pin init failed." +msgstr "" + +#: shared-module/bitbangio/SPI.c +msgid "MOSI pin init failed." +msgstr "" + +#: shared-bindings/is31fl3741/IS31FL3741.c +msgid "Mapping must be a tuple" +msgstr "" + +#: shared-module/displayio/Shape.c +#, c-format +msgid "Maximum x value when mirrored is %d" +msgstr "" + +#: shared-bindings/canio/Message.c +msgid "Messages limited to 8 bytes" +msgstr "" + +#: shared-bindings/audiobusio/PDMIn.c +msgid "Microphone startup delay must be in range 0.0 to 1.0" +msgstr "" + +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c +msgid "Missing MISO or MOSI Pin" +msgstr "" + +#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c +#, c-format +msgid "Missing first_in_pin. Instruction %d reads pin(s)" +msgstr "" + +#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c +#, c-format +msgid "Missing first_in_pin. Instruction %d shifts in from pin(s)" +msgstr "" + +#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c +#, c-format +msgid "Missing first_in_pin. Instruction %d waits based on pin" +msgstr "" + +#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c +#, c-format +msgid "Missing first_out_pin. Instruction %d shifts out to pin(s)" +msgstr "" + +#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c +#, c-format +msgid "Missing first_out_pin. Instruction %d writes pin(s)" +msgstr "" + +#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c +#, c-format +msgid "Missing first_set_pin. Instruction %d sets pin(s)" +msgstr "" + +#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c +#, c-format +msgid "Missing jmp_pin. Instruction %d jumps on pin" +msgstr "" + +#: shared-module/usb_hid/Device.c +#, c-format +msgid "More than %d report ids not supported" +msgstr "" + +#: shared-bindings/busio/UART.c shared-bindings/displayio/Group.c +msgid "Must be a %q subclass." +msgstr "" + +#: ports/mimxrt10xx/common-hal/busio/SPI.c shared-bindings/busio/SPI.c +msgid "Must provide MISO or MOSI pin" +msgstr "" + +#: shared-bindings/rgbmatrix/RGBMatrix.c +#, c-format +msgid "Must use a multiple of 6 rgb pins, not %d" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "NLR jump failed. Likely memory corruption." +msgstr "" + +#: ports/espressif/common-hal/nvm/ByteArray.c +msgid "NVS Error" +msgstr "" + +#: py/qstr.c +msgid "Name too long" +msgstr "" + +#: ports/espressif/common-hal/_bleio/__init__.c +msgid "Nimble out of memory" +msgstr "" + +#: ports/nrf/common-hal/_bleio/Characteristic.c +msgid "No CCCD for this Characteristic" +msgstr "" + +#: ports/atmel-samd/common-hal/analogio/AnalogOut.c +#: ports/stm/common-hal/analogio/AnalogOut.c +msgid "No DAC on chip" +msgstr "" + +#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c +#: ports/atmel-samd/common-hal/audioio/AudioOut.c +#: ports/raspberrypi/common-hal/audiobusio/I2SOut.c +#: ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c +msgid "No DMA channel found" +msgstr "" + +#: ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c +msgid "No DMA pacing timer found" +msgstr "" + +#: shared-module/adafruit_bus_device/i2c_device/I2CDevice.c +#, c-format +msgid "No I2C device at address: 0x%x" +msgstr "" + +#: ports/espressif/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c +msgid "No MISO Pin" +msgstr "" + +#: ports/espressif/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c +msgid "No MOSI Pin" +msgstr "" + +#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/espressif/common-hal/busio/UART.c +#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/raspberrypi/common-hal/busio/UART.c ports/stm/common-hal/busio/UART.c +msgid "No RX pin" +msgstr "" + +#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/espressif/common-hal/busio/UART.c +#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/raspberrypi/common-hal/busio/UART.c ports/stm/common-hal/busio/UART.c +msgid "No TX pin" +msgstr "" + +#: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c +msgid "No available clocks" +msgstr "" + +#: ports/espressif/common-hal/imagecapture/ParallelImageCapture.c +msgid "No capture in progress" +msgstr "" + +#: shared-bindings/_bleio/PacketBuffer.c +msgid "No connection: length cannot be determined" +msgstr "" + +#: shared-bindings/board/__init__.c +msgid "No default %q bus" +msgstr "" + +#: ports/atmel-samd/common-hal/touchio/TouchIn.c +msgid "No free GCLKs" +msgstr "" + +#: shared-bindings/os/__init__.c +msgid "No hardware random available" +msgstr "" + +#: ports/atmel-samd/common-hal/ps2io/Ps2.c +msgid "No hardware support on clk pin" +msgstr "" + +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c +#: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c +#: ports/atmel-samd/common-hal/pulseio/PulseIn.c +msgid "No hardware support on pin" +msgstr "" + +#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c +msgid "No in in program" +msgstr "" + +#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c +msgid "No in or out in program" +msgstr "" + +#: shared-bindings/aesio/aes.c +msgid "No key was specified" +msgstr "" + +#: shared-bindings/time/__init__.c +msgid "No long integer support" +msgstr "" + +#: shared-module/usb_hid/__init__.c +#, c-format +msgid "No more than %d HID devices allowed" +msgstr "" + +#: shared-bindings/wifi/Radio.c +msgid "No network with that ssid" +msgstr "" + +#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c +msgid "No out in program" +msgstr "" + +#: ports/atmel-samd/common-hal/busio/I2C.c +#: ports/espressif/common-hal/busio/I2C.c +#: ports/mimxrt10xx/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c +#: ports/raspberrypi/common-hal/busio/I2C.c +msgid "No pull up found on SDA or SCL; check your wiring" +msgstr "" + +#: shared-module/touchio/TouchIn.c +msgid "No pulldown on pin; 1Mohm recommended" +msgstr "" + +#: py/moduerrno.c +msgid "No space left on device" +msgstr "" + +#: py/moduerrno.c +msgid "No such file/directory" +msgstr "" + +#: shared-module/rgbmatrix/RGBMatrix.c +msgid "No timer available" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "Nordic system firmware failure assertion." +msgstr "" + +#: ports/nrf/common-hal/_bleio/__init__.c +msgid "Nordic system firmware out of memory" +msgstr "" + +#: shared-bindings/ipaddress/IPv4Address.c shared-bindings/ipaddress/__init__.c +msgid "Not a valid IP string" +msgstr "" + +#: ports/espressif/common-hal/_bleio/__init__.c +#: ports/nrf/common-hal/_bleio/__init__.c +#: shared-bindings/_bleio/CharacteristicBuffer.c +msgid "Not connected" +msgstr "" + +#: shared-bindings/audiobusio/I2SOut.c shared-bindings/audioio/AudioOut.c +#: shared-bindings/audiopwmio/PWMAudioOut.c +msgid "Not playing" +msgstr "" + +#: shared-bindings/_bleio/__init__.c +msgid "Not settable" +msgstr "" + +#: ports/espressif/common-hal/paralleldisplay/ParallelBus.c +#, c-format +msgid "Number of data_pins must be 8 or 16, not %d" +msgstr "" + +#: shared-bindings/util.c +msgid "" +"Object has been deinitialized and can no longer be used. Create a new object." +msgstr "" + +#: ports/nrf/common-hal/busio/UART.c +msgid "Odd parity is not supported" +msgstr "" + +#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c +#: ports/raspberrypi/common-hal/audiobusio/PDMIn.c +msgid "Only 8 or 16 bit mono with " +msgstr "" + +#: ports/espressif/common-hal/wifi/__init__.c +msgid "Only IPv4 addresses supported" +msgstr "" + +#: ports/espressif/common-hal/socketpool/SocketPool.c +msgid "Only IPv4 sockets supported" +msgstr "" + +#: shared-module/displayio/OnDiskBitmap.c +#, c-format +msgid "" +"Only Windows format, uncompressed BMP supported: given header size is %d" +msgstr "" + +#: shared-bindings/_bleio/Adapter.c +msgid "Only connectable advertisements can be directed" +msgstr "" + +#: ports/stm/common-hal/alarm/pin/PinAlarm.c +msgid "Only edge detection is available on this hardware" +msgstr "" + +#: shared-bindings/ipaddress/__init__.c +msgid "Only int or string supported for ip" +msgstr "" + +#: shared-module/displayio/OnDiskBitmap.c +#, c-format +msgid "" +"Only monochrome, indexed 4bpp or 8bpp, and 16bpp or greater BMPs supported: " +"%d bpp given" +msgstr "" + +#: ports/espressif/common-hal/alarm/touch/TouchAlarm.c +msgid "Only one TouchAlarm can be set in deep sleep." +msgstr "" + +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c +msgid "Only one address is allowed" +msgstr "" + +#: ports/atmel-samd/common-hal/alarm/time/TimeAlarm.c +#: ports/espressif/common-hal/alarm/time/TimeAlarm.c +#: ports/nrf/common-hal/alarm/time/TimeAlarm.c +#: ports/raspberrypi/common-hal/alarm/time/TimeAlarm.c +#: ports/stm/common-hal/alarm/time/TimeAlarm.c +msgid "Only one alarm.time alarm can be set." +msgstr "" + +#: shared-module/displayio/ColorConverter.c +msgid "Only one color can be transparent at a time" +msgstr "" + +#: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c +msgid "Operation or feature not supported" +msgstr "" + +#: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c +msgid "Operation timed out" +msgstr "" + +#: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c +msgid "Out of memory" +msgstr "" + +#: ports/espressif/common-hal/socketpool/SocketPool.c +msgid "Out of sockets" +msgstr "" + +#: ports/raspberrypi/bindings/rp2pio/StateMachine.c +msgid "Out-buffer elements must be <= 4 bytes long" +msgstr "" + +#: shared-bindings/bitops/__init__.c +#, c-format +msgid "Output buffer must be at least %d bytes" +msgstr "" + +#: shared-bindings/audiobusio/PDMIn.c +msgid "Oversample must be multiple of 8." +msgstr "" + +#: shared-bindings/audiobusio/PDMIn.c +msgid "PDMIn not available" +msgstr "" + +#: shared-bindings/pwmio/PWMOut.c +msgid "" +"PWM duty_cycle must be between 0 and 65535 inclusive (16 bit resolution)" +msgstr "" + +#: shared-bindings/pwmio/PWMOut.c +msgid "" +"PWM frequency not writable when variable_frequency is False on construction." +msgstr "" + +#: ports/raspberrypi/common-hal/countio/Counter.c +msgid "PWM slice already in use" +msgstr "" + +#: ports/raspberrypi/common-hal/countio/Counter.c +msgid "PWM slice channel A already in use" +msgstr "" + +#: ports/espressif/common-hal/audiobusio/__init__.c +msgid "Peripheral in use" +msgstr "" + +#: py/moduerrno.c +msgid "Permission denied" +msgstr "" + +#: ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c +#: ports/stm/common-hal/alarm/pin/PinAlarm.c +msgid "Pin cannot wake from Deep Sleep" +msgstr "" + +#: ports/raspberrypi/bindings/rp2pio/StateMachine.c +msgid "Pin count must be at least 1" +msgstr "" + +#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c +msgid "Pin count too large" +msgstr "" + +#: ports/atmel-samd/common-hal/analogio/AnalogIn.c +#: ports/cxd56/common-hal/analogio/AnalogIn.c +#: ports/espressif/common-hal/analogio/AnalogIn.c +#: ports/mimxrt10xx/common-hal/analogio/AnalogIn.c +#: ports/nrf/common-hal/analogio/AnalogIn.c +#: ports/raspberrypi/common-hal/analogio/AnalogIn.c +#: ports/stm/common-hal/analogio/AnalogIn.c +msgid "Pin does not have ADC capabilities" +msgstr "" + +#: ports/stm/common-hal/alarm/pin/PinAlarm.c +#: ports/stm/common-hal/pulseio/PulseIn.c +msgid "Pin interrupt already in use" +msgstr "" + +#: shared-bindings/adafruit_bus_device/spi_device/SPIDevice.c +#: shared-bindings/digitalio/DigitalInOut.c +msgid "Pin is input only" +msgstr "" + +#: ports/raspberrypi/common-hal/countio/Counter.c +msgid "Pin must be on PWM Channel B" +msgstr "" + +#: ports/atmel-samd/common-hal/countio/Counter.c +msgid "Pin must support hardware interrupts" +msgstr "" + +#: shared-bindings/rgbmatrix/RGBMatrix.c +#, c-format +msgid "" +"Pinout uses %d bytes per element, which consumes more than the ideal %d " +"bytes. If this cannot be avoided, pass allow_inefficient=True to the " +"constructor" +msgstr "" + +#: ports/raspberrypi/common-hal/imagecapture/ParallelImageCapture.c +msgid "Pins must be sequential" +msgstr "" + +#: ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c +msgid "Pins must be sequential GPIO pins" +msgstr "" + +#: ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c +msgid "Pins must share PWM slice" +msgstr "" + +#: py/builtinhelp.c +msgid "Plus any modules on the filesystem\n" +msgstr "" + +#: shared-module/vectorio/Polygon.c +msgid "Polygon needs at least 3 points" +msgstr "" + +#: shared-bindings/_bleio/Adapter.c +msgid "Prefix buffer must be on the heap" +msgstr "" + +#: main.c +msgid "Press any key to enter the REPL. Use CTRL-D to reload.\n" +msgstr "" +"REPL moda girmek için herhangi bir tuşa basınız. Programı yeniden yüklemek " +"için CTRL+D tuş kombinasyonunu kullanabilirsiniz.\n" + +#: main.c +msgid "Pretending to deep sleep until alarm, CTRL-C or file write.\n" +msgstr "" +"Alarma, CTRL-C'ye veya dosya yazana kadar derin uyku moduna geçiliyor.\n" + +#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c +msgid "Program does IN without loading ISR" +msgstr "" + +#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c +msgid "Program does OUT without loading OSR" +msgstr "" + +#: ports/raspberrypi/bindings/rp2pio/StateMachine.c +msgid "Program must contain at least one 16-bit instruction." +msgstr "" + +#: ports/raspberrypi/bindings/rp2pio/StateMachine.c +msgid "Program size invalid" +msgstr "" + +#: ports/raspberrypi/bindings/rp2pio/StateMachine.c +msgid "Program too large" +msgstr "" + +#: shared-bindings/digitalio/DigitalInOut.c +msgid "Pull not used when direction is output." +msgstr "" + +#: ports/atmel-samd/common-hal/watchdog/WatchDogTimer.c +#: ports/raspberrypi/common-hal/watchdog/WatchDogTimer.c +msgid "RAISE mode is not implemented" +msgstr "" + +#: ports/raspberrypi/common-hal/countio/Counter.c +msgid "RISE_AND_FALL not available on this chip" +msgstr "" + +#: ports/stm/common-hal/os/__init__.c +msgid "RNG DeInit Error" +msgstr "" + +#: ports/stm/common-hal/os/__init__.c +msgid "RNG Init Error" +msgstr "" + +#: ports/nrf/common-hal/busio/UART.c ports/raspberrypi/common-hal/busio/UART.c +msgid "RS485 Not yet supported on this device" +msgstr "" + +#: ports/espressif/common-hal/busio/UART.c +#: ports/mimxrt10xx/common-hal/busio/UART.c +msgid "RS485 inversion specified when not in RS485 mode" +msgstr "" + +#: ports/cxd56/common-hal/rtc/RTC.c ports/espressif/common-hal/rtc/RTC.c +#: ports/mimxrt10xx/common-hal/rtc/RTC.c ports/nrf/common-hal/rtc/RTC.c +#: ports/raspberrypi/common-hal/rtc/RTC.c +msgid "RTC calibration is not supported on this board" +msgstr "" + +#: shared-bindings/alarm/time/TimeAlarm.c shared-bindings/time/__init__.c +msgid "RTC is not supported on this board" +msgstr "" + +#: ports/atmel-samd/common-hal/busio/UART.c ports/cxd56/common-hal/busio/UART.c +#: ports/stm/common-hal/busio/UART.c +msgid "RTS/CTS/RS485 Not yet supported on this device" +msgstr "" + +#: ports/stm/common-hal/os/__init__.c +msgid "Random number generation error" +msgstr "" + +#: shared-bindings/memorymonitor/AllocationSize.c +#: shared-bindings/pulseio/PulseIn.c +msgid "Read-only" +msgstr "" + +#: extmod/vfs_fat.c py/moduerrno.c +msgid "Read-only filesystem" +msgstr "" + +#: shared-module/displayio/Bitmap.c +msgid "Read-only object" +msgstr "" + +#: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c +msgid "Received response was invalid" +msgstr "" + +#: shared-bindings/displayio/EPaperDisplay.c +msgid "Refresh too soon" +msgstr "" + +#: shared-bindings/canio/RemoteTransmissionRequest.c +msgid "RemoteTransmissionRequests limited to 8 bytes" +msgstr "" + +#: shared-bindings/aesio/aes.c +msgid "Requested AES mode is unsupported" +msgstr "" + +#: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c +msgid "Requested resource not found" +msgstr "" + +#: ports/atmel-samd/common-hal/audioio/AudioOut.c +msgid "Right channel unsupported" +msgstr "" + +#: main.c +msgid "Running in safe mode! Not running saved code.\n" +msgstr "" + +#: shared-module/sdcardio/SDCard.c +msgid "SD card CSD format not supported" +msgstr "" + +#: ports/stm/common-hal/sdioio/SDCard.c +#, c-format +msgid "SDIO GetCardInfo Error %d" +msgstr "" + +#: ports/stm/common-hal/sdioio/SDCard.c +#, c-format +msgid "SDIO Init Error %d" +msgstr "" + +#: ports/stm/common-hal/busio/SPI.c +msgid "SPI Init Error" +msgstr "" + +#: ports/stm/common-hal/busio/SPI.c +msgid "SPI Re-initialization error" +msgstr "" + +#: ports/espressif/common-hal/busio/SPI.c +msgid "SPI configuration failed" +msgstr "" + +#: ports/raspberrypi/common-hal/busio/SPI.c +msgid "SPI peripheral in use" +msgstr "" + +#: shared-bindings/audiomixer/Mixer.c +msgid "Sample rate must be positive" +msgstr "" + +#: ports/atmel-samd/common-hal/audioio/AudioOut.c +#, c-format +msgid "Sample rate too high. It must be less than %d" +msgstr "" + +#: shared-bindings/is31fl3741/FrameBuffer.c +msgid "Scale dimensions must divide by 3" +msgstr "" + +#: ports/espressif/common-hal/_bleio/Adapter.c +#: ports/nrf/common-hal/_bleio/Adapter.c +msgid "Scan already in progess. Stop with stop_scan." +msgstr "" + +#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c +#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c +msgid "Serializer in use" +msgstr "" + +#: shared-bindings/ssl/SSLContext.c +msgid "Server side context cannot have hostname" +msgstr "" + +#: ports/raspberrypi/bindings/rp2pio/StateMachine.c +msgid "Set pin count must be between 1 and 5" +msgstr "" + +#: ports/raspberrypi/bindings/rp2pio/StateMachine.c +msgid "Side set pin count must be between 1 and 5" +msgstr "" + +#: ports/cxd56/common-hal/camera/Camera.c +msgid "Size not supported" +msgstr "" + +#: ports/atmel-samd/common-hal/alarm/SleepMemory.c +#: ports/raspberrypi/common-hal/alarm/SleepMemory.c +msgid "Sleep Memory not available" +msgstr "" + +#: shared-bindings/alarm/SleepMemory.c shared-bindings/nvm/ByteArray.c +msgid "Slice and value different lengths." +msgstr "" + +#: shared-bindings/displayio/Bitmap.c shared-bindings/displayio/Group.c +#: shared-bindings/displayio/TileGrid.c +#: shared-bindings/memorymonitor/AllocationSize.c +#: shared-bindings/pulseio/PulseIn.c +msgid "Slices not supported" +msgstr "" + +#: ports/espressif/common-hal/socketpool/SocketPool.c +msgid "SocketPool can only be used with wifi.radio" +msgstr "" + +#: shared-bindings/aesio/aes.c +msgid "Source and destination buffers must be the same length" +msgstr "" + +#: shared-bindings/paralleldisplay/ParallelBus.c +msgid "Specify exactly one of data0 or data_pins" +msgstr "" + +#: extmod/modure.c +msgid "Splitting with sub-captures" +msgstr "" + +#: shared-bindings/supervisor/__init__.c +msgid "Stack size must be at least 256" +msgstr "" + +#: ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c +msgid "Stereo left must be on PWM channel A" +msgstr "" + +#: ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c +msgid "Stereo right must be on PWM channel B" +msgstr "" + +#: shared-bindings/multiterminal/__init__.c +msgid "Stream missing readinto() or write() method." +msgstr "" + +#: ports/mimxrt10xx/common-hal/busio/UART.c ports/stm/common-hal/busio/UART.c +msgid "Supply at least one UART pin" +msgstr "" + +#: shared-bindings/alarm/time/TimeAlarm.c +msgid "Supply one of monotonic_time or epoch_time" +msgstr "" + +#: shared-bindings/gnss/GNSS.c +msgid "System entry must be gnss.SatelliteSystem" +msgstr "" + +#: ports/stm/common-hal/microcontroller/Processor.c +msgid "Temperature read timed out" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "" +"The CircuitPython heap was corrupted because the stack was too small.\n" +"Increase the stack size if you know how. If not:" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "" +"The `microcontroller` module was used to boot into safe mode. Press reset to " +"exit safe mode." +msgstr "" + +#: shared-bindings/rgbmatrix/RGBMatrix.c +msgid "The length of rgb_pins must be 6, 12, 18, 24, or 30" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "" +"The microcontroller's power dipped. Make sure your power supply provides\n" +"enough power for the whole circuit and press reset (after ejecting " +"CIRCUITPY)." +msgstr "" + +#: shared-module/audiomixer/MixerVoice.c +msgid "The sample's bits_per_sample does not match the mixer's" +msgstr "" + +#: shared-module/audiomixer/MixerVoice.c +msgid "The sample's channel count does not match the mixer's" +msgstr "" + +#: shared-module/audiomixer/MixerVoice.c +msgid "The sample's sample rate does not match the mixer's" +msgstr "" + +#: shared-module/audiomixer/MixerVoice.c +msgid "The sample's signedness does not match the mixer's" +msgstr "" + +#: shared-module/imagecapture/ParallelImageCapture.c +msgid "This microcontroller does not support continuous capture." +msgstr "" + +#: shared-module/paralleldisplay/ParallelBus.c +msgid "" +"This microcontroller only supports data0=, not data_pins=, because it " +"requires contiguous pins." +msgstr "" + +#: shared-bindings/displayio/TileGrid.c +msgid "Tile height must exactly divide bitmap height" +msgstr "" + +#: shared-bindings/displayio/TileGrid.c shared-module/displayio/TileGrid.c +msgid "Tile index out of bounds" +msgstr "" + +#: shared-bindings/displayio/TileGrid.c +msgid "Tile value out of bounds" +msgstr "" + +#: shared-bindings/displayio/TileGrid.c +msgid "Tile width must exactly divide bitmap width" +msgstr "" + +#: shared-bindings/alarm/time/TimeAlarm.c +msgid "Time is in the past." +msgstr "" + +#: ports/espressif/common-hal/_bleio/Adapter.c +#: ports/nrf/common-hal/_bleio/Adapter.c +#, c-format +msgid "Timeout is too long: Maximum timeout length is %d seconds" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "To exit, please reset the board without " +msgstr "" + +#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c +#: ports/raspberrypi/common-hal/audiobusio/I2SOut.c +msgid "Too many channels in sample." +msgstr "" + +#: shared-module/displayio/__init__.c +msgid "Too many display busses" +msgstr "" + +#: shared-module/displayio/__init__.c +msgid "Too many displays" +msgstr "" + +#: ports/espressif/common-hal/_bleio/PacketBuffer.c +#: ports/nrf/common-hal/_bleio/PacketBuffer.c +msgid "Total data to write is larger than %q" +msgstr "" + +#: ports/atmel-samd/common-hal/alarm/touch/TouchAlarm.c +#: ports/raspberrypi/common-hal/alarm/touch/TouchAlarm.c +#: ports/stm/common-hal/alarm/touch/TouchAlarm.c +msgid "Touch alarms not available" +msgstr "" + +#: py/obj.c +msgid "Traceback (most recent call last):\n" +msgstr "" + +#: shared-bindings/time/__init__.c +msgid "Tuple or struct_time argument required" +msgstr "" + +#: ports/stm/common-hal/busio/UART.c +msgid "UART Buffer allocation error" +msgstr "" + +#: ports/stm/common-hal/busio/UART.c +msgid "UART De-init error" +msgstr "" + +#: ports/stm/common-hal/busio/UART.c +msgid "UART Init Error" +msgstr "" + +#: ports/stm/common-hal/busio/UART.c +msgid "UART Re-init error" +msgstr "" + +#: ports/stm/common-hal/busio/UART.c +msgid "UART write error" +msgstr "" + +#: shared-module/usb_hid/Device.c +msgid "USB busy" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "USB devices need more endpoints than are available." +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "USB devices specify too many interface names." +msgstr "" + +#: shared-module/usb_hid/Device.c +msgid "USB error" +msgstr "" + +#: shared-bindings/_bleio/UUID.c +msgid "UUID integer value must be 0-0xffff" +msgstr "" + +#: shared-bindings/_bleio/UUID.c +msgid "UUID string not 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'" +msgstr "" + +#: shared-bindings/_bleio/UUID.c +msgid "UUID value is not str, int or byte buffer" +msgstr "" + +#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c +#: ports/atmel-samd/common-hal/audioio/AudioOut.c +#: ports/raspberrypi/common-hal/audiobusio/I2SOut.c +#: ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c +msgid "Unable to allocate buffers for signed conversion" +msgstr "" + +#: ports/espressif/common-hal/busio/I2C.c +msgid "Unable to create lock" +msgstr "" + +#: shared-module/displayio/I2CDisplay.c shared-module/is31fl3741/IS31FL3741.c +#, c-format +msgid "Unable to find I2C Display at %x" +msgstr "" + +#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c +#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c +msgid "Unable to find free GCLK" +msgstr "" + +#: py/parse.c +msgid "Unable to init parser" +msgstr "" + +#: shared-module/displayio/OnDiskBitmap.c +msgid "Unable to read color palette data" +msgstr "" + +#: shared-bindings/nvm/ByteArray.c +msgid "Unable to write to nvm." +msgstr "" + +#: shared-bindings/alarm/SleepMemory.c +msgid "Unable to write to sleep_memory." +msgstr "" + +#: ports/nrf/common-hal/_bleio/UUID.c +msgid "Unexpected nrfx uuid type" +msgstr "" + +#: ports/espressif/common-hal/ssl/SSLSocket.c +#, c-format +msgid "Unhandled ESP TLS error %d %d %x %d" +msgstr "" + +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown BLE error at %s:%d: %d" +msgstr "" + +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown BLE error: %d" +msgstr "" + +#: shared-bindings/wifi/Radio.c +#, c-format +msgid "Unknown failure %d" +msgstr "" + +#: ports/nrf/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown gatt error: 0x%04x" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "Unknown reason." +msgstr "" + +#: ports/nrf/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown security error: 0x%04x" +msgstr "" + +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error at %s:%d: %d" +msgstr "" + +#: ports/nrf/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error: %04x" +msgstr "" + +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error: %d" +msgstr "" + +#: shared-bindings/adafruit_pixelbuf/PixelBuf.c +#, c-format +msgid "Unmatched number of items on RHS (expected %d, got %d)." +msgstr "" + +#: ports/nrf/common-hal/_bleio/__init__.c +msgid "" +"Unspecified issue. Can be that the pairing prompt on the other device was " +"declined or ignored." +msgstr "" + +#: ports/atmel-samd/common-hal/busio/I2C.c ports/cxd56/common-hal/busio/I2C.c +#: ports/espressif/common-hal/busio/UART.c +#: ports/raspberrypi/common-hal/busio/I2C.c ports/stm/common-hal/busio/I2C.c +msgid "Unsupported baudrate" +msgstr "" + +#: shared-bindings/bitmaptools/__init__.c +msgid "Unsupported colorspace" +msgstr "" + +#: shared-module/displayio/display_core.c +msgid "Unsupported display bus type" +msgstr "" + +#: shared-module/audiocore/WaveFile.c +msgid "Unsupported format" +msgstr "" + +#: py/moduerrno.c +msgid "Unsupported operation" +msgstr "" + +#: ports/espressif/common-hal/dualbank/__init__.c +msgid "Update Failed" +msgstr "" + +#: ports/espressif/common-hal/_bleio/Characteristic.c +#: ports/espressif/common-hal/_bleio/Descriptor.c +#: ports/nrf/common-hal/_bleio/Characteristic.c +#: ports/nrf/common-hal/_bleio/Descriptor.c +msgid "Value length != required fixed length" +msgstr "" + +#: ports/espressif/common-hal/_bleio/Characteristic.c +#: ports/espressif/common-hal/_bleio/Descriptor.c +#: ports/nrf/common-hal/_bleio/Characteristic.c +#: ports/nrf/common-hal/_bleio/Descriptor.c +msgid "Value length > max_length" +msgstr "" + +#: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c +msgid "Version was invalid" +msgstr "" + +#: ports/stm/common-hal/microcontroller/Processor.c +msgid "Voltage read timed out" +msgstr "" + +#: main.c +msgid "WARNING: Your code filename has two extensions\n" +msgstr "" + +#: ports/atmel-samd/common-hal/watchdog/WatchDogTimer.c +#: ports/nrf/common-hal/watchdog/WatchDogTimer.c +#: ports/raspberrypi/common-hal/watchdog/WatchDogTimer.c +msgid "WatchDogTimer cannot be deinitialized once mode is set to RESET" +msgstr "" + +#: shared-bindings/watchdog/WatchDogTimer.c +msgid "WatchDogTimer is not currently running" +msgstr "" + +#: shared-bindings/watchdog/WatchDogTimer.c +msgid "WatchDogTimer.mode cannot be changed once set to WatchDogMode.RESET" +msgstr "" + +#: shared-bindings/watchdog/WatchDogTimer.c +msgid "WatchDogTimer.timeout must be greater than 0" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "Watchdog timer expired." +msgstr "" + +#: py/builtinhelp.c +#, c-format +msgid "" +"Welcome to Adafruit CircuitPython %s!\n" +"\n" +"Visit circuitpython.org for more information.\n" +"\n" +"To list built-in modules type `help(\"modules\")`.\n" +msgstr "" + +#: shared-bindings/wifi/Radio.c +msgid "WiFi password must be between 8 and 63 characters" +msgstr "" + +#: main.c +msgid "Woken up by alarm.\n" +msgstr "" + +#: ports/espressif/common-hal/_bleio/PacketBuffer.c +#: ports/nrf/common-hal/_bleio/PacketBuffer.c +msgid "Writes not supported on Characteristic" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "You are in safe mode because:\n" +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "" +"You pressed the reset button during boot. Press again to exit safe mode." +msgstr "" + +#: supervisor/shared/safe_mode.c +msgid "You requested starting safe mode by " +msgstr "" + +#: py/objtype.c +msgid "__init__() should return None" +msgstr "" + +#: py/objtype.c +msgid "__init__() should return None, not '%q'" +msgstr "" + +#: py/objobject.c +msgid "__new__ arg must be a user-type" +msgstr "" + +#: extmod/modubinascii.c extmod/moduhashlib.c py/objarray.c +msgid "a bytes-like object is required" +msgstr "" + +#: shared-bindings/i2cperipheral/I2CPeripheral.c +msgid "address out of bounds" +msgstr "" + +#: shared-bindings/i2cperipheral/I2CPeripheral.c +msgid "addresses is empty" +msgstr "" + +#: py/compile.c +msgid "annotation must be an identifier" +msgstr "" + +#: py/modbuiltins.c +msgid "arg is an empty sequence" +msgstr "" + +#: py/objobject.c +msgid "arg must be user-type" +msgstr "" + +#: extmod/ulab/code/numpy/numerical.c +msgid "argsort argument must be an ndarray" +msgstr "" + +#: extmod/ulab/code/numpy/numerical.c +msgid "argsort is not implemented for flattened arrays" +msgstr "" + +#: py/runtime.c shared-bindings/supervisor/__init__.c +msgid "argument has wrong type" +msgstr "" + +#: py/compile.c +msgid "argument name reused" +msgstr "" + +#: py/argcheck.c shared-bindings/_stage/__init__.c +#: shared-bindings/digitalio/DigitalInOut.c +msgid "argument num/types mismatch" +msgstr "" + +#: py/runtime.c +msgid "argument should be a '%q' not a '%q'" +msgstr "" + +#: extmod/ulab/code/numpy/numerical.c extmod/ulab/code/numpy/transform.c +msgid "arguments must be ndarrays" +msgstr "" + +#: extmod/ulab/code/ndarray.c +msgid "array and index length must be equal" +msgstr "" + +#: py/objarray.c shared-bindings/alarm/SleepMemory.c +#: shared-bindings/nvm/ByteArray.c +msgid "array/bytes required on right side" +msgstr "" + +#: extmod/ulab/code/numpy/numerical.c +msgid "attempt to get (arg)min/(arg)max of empty sequence" +msgstr "" + +#: extmod/ulab/code/numpy/numerical.c +msgid "attempt to get argmin/argmax of an empty sequence" +msgstr "" + +#: py/objstr.c +msgid "attributes not supported yet" +msgstr "" + +#: extmod/ulab/code/ulab_tools.c +msgid "axis is out of bounds" +msgstr "" + +#: extmod/ulab/code/numpy/numerical.c extmod/ulab/code/ulab_tools.c +msgid "axis must be None, or an integer" +msgstr "" + +#: extmod/ulab/code/numpy/numerical.c +msgid "axis too long" +msgstr "" + +#: shared-bindings/bitmaptools/__init__.c +msgid "background value out of range of target" +msgstr "" + +#: py/builtinevex.c +msgid "bad compile mode" +msgstr "" + +#: py/objstr.c +msgid "bad conversion specifier" +msgstr "" + +#: py/objstr.c +msgid "bad format string" +msgstr "" + +#: py/binary.c py/objarray.c +msgid "bad typecode" +msgstr "" + +#: py/emitnative.c +msgid "binary op %q not implemented" +msgstr "" + +#: shared-bindings/bitmaptools/__init__.c +msgid "bitmap sizes must match" +msgstr "" + +#: extmod/modurandom.c +msgid "bits must be 32 or less" +msgstr "" + +#: shared-bindings/busio/UART.c +msgid "bits must be in range 5 to 9" +msgstr "" + +#: shared-bindings/audiomixer/Mixer.c +msgid "bits_per_sample must be 8 or 16" +msgstr "" + +#: py/emitinlinethumb.c +msgid "branch not in range" +msgstr "" + +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/utils/utils.c +msgid "buffer is smaller than requested size" +msgstr "" + +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/utils/utils.c +msgid "buffer size must be a multiple of element size" +msgstr "" + +#: shared-module/struct/__init__.c +msgid "buffer size must match format" +msgstr "" + +#: shared-bindings/bitbangio/SPI.c shared-bindings/busio/SPI.c +msgid "buffer slices must be of equal length" +msgstr "" + +#: py/modstruct.c shared-bindings/struct/__init__.c +#: shared-module/struct/__init__.c +msgid "buffer too small" +msgstr "" + +#: shared-bindings/socketpool/Socket.c shared-bindings/ssl/SSLSocket.c +msgid "buffer too small for requested bytes" +msgstr "" + +#: shared-bindings/adafruit_pixelbuf/PixelBuf.c +msgid "byteorder is not a string" +msgstr "" + +#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/espressif/common-hal/busio/UART.c +msgid "bytes > 8 bits not supported" +msgstr "" + +#: py/objarray.c +msgid "bytes length not a multiple of item size" +msgstr "" + +#: py/objstr.c +msgid "bytes value out of range" +msgstr "" + +#: ports/atmel-samd/bindings/samd/Clock.c ports/atmel-samd/common-hal/rtc/RTC.c +msgid "calibration is out of range" +msgstr "" + +#: ports/atmel-samd/bindings/samd/Clock.c +msgid "calibration is read only" +msgstr "" + +#: ports/atmel-samd/common-hal/rtc/RTC.c +msgid "calibration value out of range +/-127" +msgstr "" + +#: shared-module/vectorio/Rectangle.c +msgid "can only be registered in one parent" +msgstr "" + +#: py/emitinlinethumb.c +msgid "can only have up to 4 parameters to Thumb assembly" +msgstr "" + +#: py/emitinlinextensa.c +msgid "can only have up to 4 parameters to Xtensa assembly" +msgstr "" + +#: py/objtype.c +msgid "can't add special method to already-subclassed class" +msgstr "" + +#: py/compile.c +msgid "can't assign to expression" +msgstr "" + +#: extmod/moduasyncio.c +msgid "can't cancel self" +msgstr "" + +#: py/obj.c py/objint.c shared-bindings/i2cperipheral/I2CPeripheral.c +#: shared-module/adafruit_pixelbuf/PixelBuf.c +msgid "can't convert %q to %q" +msgstr "" + +#: py/runtime.c +msgid "can't convert %q to int" +msgstr "" + +#: py/obj.c +#, c-format +msgid "can't convert %s to complex" +msgstr "" + +#: py/objstr.c +msgid "can't convert '%q' object to %q implicitly" +msgstr "" + +#: extmod/ulab/code/numpy/vector.c +msgid "can't convert complex to float" +msgstr "" + +#: py/obj.c +msgid "can't convert to %q" +msgstr "" + +#: py/obj.c +msgid "can't convert to complex" +msgstr "" + +#: py/runtime.c +msgid "can't convert to int" +msgstr "" + +#: py/objstr.c +msgid "can't convert to str implicitly" +msgstr "" + +#: py/compile.c +msgid "can't declare nonlocal in outer code" +msgstr "" + +#: py/compile.c +msgid "can't delete expression" +msgstr "" + +#: py/emitnative.c +msgid "can't do binary op between '%q' and '%q'" +msgstr "" + +#: py/objcomplex.c +msgid "can't do truncated division of a complex number" +msgstr "" + +#: py/compile.c +msgid "can't have multiple **x" +msgstr "" + +#: py/compile.c +msgid "can't have multiple *x" +msgstr "" + +#: py/emitnative.c +msgid "can't implicitly convert '%q' to 'bool'" +msgstr "" + +#: py/emitnative.c +msgid "can't load from '%q'" +msgstr "" + +#: py/emitnative.c +msgid "can't load with '%q' index" +msgstr "" + +#: py/builtinimport.c +msgid "can't perform relative import" +msgstr "" + +#: py/objgenerator.c +msgid "can't send non-None value to a just-started generator" +msgstr "" + +#: shared-module/sdcardio/SDCard.c +msgid "can't set 512 block size" +msgstr "" + +#: py/objnamedtuple.c +msgid "can't set attribute" +msgstr "" + +#: py/emitnative.c +msgid "can't store '%q'" +msgstr "" + +#: py/emitnative.c +msgid "can't store to '%q'" +msgstr "" + +#: py/emitnative.c +msgid "can't store with '%q' index" +msgstr "" + +#: py/objstr.c +msgid "" +"can't switch from automatic field numbering to manual field specification" +msgstr "" + +#: py/objstr.c +msgid "" +"can't switch from manual field specification to automatic field numbering" +msgstr "" + +#: extmod/ulab/code/ndarray.c +msgid "cannot assign new shape" +msgstr "" + +#: extmod/ulab/code/ndarray_operators.c +msgid "cannot cast output with casting rule" +msgstr "" + +#: extmod/ulab/code/ndarray.c +msgid "cannot convert complex to dtype" +msgstr "" + +#: extmod/ulab/code/ndarray.c +msgid "cannot convert complex type" +msgstr "" + +#: py/objtype.c +msgid "cannot create '%q' instances" +msgstr "" + +#: py/objtype.c +msgid "cannot create instance" +msgstr "" + +#: py/runtime.c +msgid "cannot import name %q" +msgstr "" + +#: extmod/moductypes.c +msgid "cannot unambiguously get sizeof scalar" +msgstr "" + +#: py/emitnative.c +msgid "casting" +msgstr "" + +#: shared-bindings/_stage/Text.c +msgid "chars buffer too small" +msgstr "" + +#: py/modbuiltins.c +msgid "chr() arg not in range(0x110000)" +msgstr "" + +#: py/modbuiltins.c +msgid "chr() arg not in range(256)" +msgstr "" + +#: shared-module/vectorio/Circle.c +msgid "circle can only be registered in one parent" +msgstr "" + +#: shared-bindings/bitmaptools/__init__.c +msgid "clip point must be (x,y) tuple" +msgstr "" + +#: shared-bindings/msgpack/ExtType.c +msgid "code outside range 0~127" +msgstr "" + +#: shared-bindings/displayio/Palette.c +msgid "color buffer must be 3 bytes (RGB) or 4 bytes (RGB + pad byte)" +msgstr "" + +#: shared-bindings/displayio/Palette.c +msgid "color buffer must be a buffer, tuple, list, or int" +msgstr "" + +#: shared-bindings/displayio/Palette.c +msgid "color buffer must be a bytearray or array of type 'b' or 'B'" +msgstr "" + +#: shared-bindings/displayio/Palette.c +msgid "color must be between 0x000000 and 0xffffff" +msgstr "" + +#: shared-bindings/displayio/ColorConverter.c +msgid "color should be an int" +msgstr "" + +#: py/emitnative.c +msgid "comparison of int and uint" +msgstr "" + +#: py/objcomplex.c +msgid "complex division by zero" +msgstr "" + +#: py/objfloat.c py/parsenum.c +msgid "complex values not supported" +msgstr "" + +#: extmod/moduzlib.c +msgid "compression header" +msgstr "" + +#: py/parse.c +msgid "constant must be an integer" +msgstr "" + +#: py/emitnative.c +msgid "conversion to object" +msgstr "" + +#: extmod/ulab/code/numpy/filter.c +msgid "convolve arguments must be linear arrays" +msgstr "" + +#: extmod/ulab/code/numpy/filter.c +msgid "convolve arguments must be ndarrays" +msgstr "" + +#: extmod/ulab/code/numpy/filter.c +msgid "convolve arguments must not be empty" +msgstr "" + +#: extmod/ulab/code/numpy/poly.c +msgid "could not invert Vandermonde matrix" +msgstr "" + +#: shared-module/sdcardio/SDCard.c +msgid "couldn't determine SD card version" +msgstr "" + +#: extmod/ulab/code/numpy/numerical.c +msgid "cross is defined for 1D arrays of length 3" +msgstr "" + +#: extmod/ulab/code/scipy/optimize/optimize.c +msgid "data must be iterable" +msgstr "" + +#: extmod/ulab/code/scipy/optimize/optimize.c +msgid "data must be of equal length" +msgstr "" + +#: ports/atmel-samd/common-hal/imagecapture/ParallelImageCapture.c +#, c-format +msgid "data pin #%d in use" +msgstr "" + +#: extmod/ulab/code/ndarray.c +msgid "data type not understood" +msgstr "" + +#: py/parsenum.c +msgid "decimal numbers not supported" +msgstr "" + +#: py/compile.c +msgid "default 'except' must be last" +msgstr "" + +#: shared-bindings/msgpack/__init__.c +msgid "default is not a function" +msgstr "" + +#: shared-bindings/audiobusio/PDMIn.c +msgid "" +"destination buffer must be a bytearray or array of type 'B' for bit_depth = 8" +msgstr "" + +#: shared-bindings/audiobusio/PDMIn.c +msgid "destination buffer must be an array of type 'H' for bit_depth = 16" +msgstr "" + +#: shared-bindings/audiobusio/PDMIn.c +msgid "destination_length must be an int >= 0" +msgstr "" + +#: py/objdict.c +msgid "dict update sequence has wrong length" +msgstr "" + +#: extmod/ulab/code/numpy/numerical.c +msgid "diff argument must be an ndarray" +msgstr "" + +#: extmod/ulab/code/numpy/numerical.c +msgid "differentiation order out of range" +msgstr "" + +#: extmod/ulab/code/numpy/transform.c +msgid "dimensions do not match" +msgstr "" + +#: py/emitnative.c +msgid "div/mod not implemented for uint" +msgstr "" + +#: py/objfloat.c py/objint_mpz.c +msgid "divide by zero" +msgstr "" + +#: py/modmath.c py/objint_longlong.c py/runtime.c +#: shared-bindings/math/__init__.c +msgid "division by zero" +msgstr "" + +#: ports/espressif/common-hal/rotaryio/IncrementalEncoder.c +msgid "divisor must be 4" +msgstr "" + +#: extmod/ulab/code/numpy/vector.c +msgid "dtype must be float, or complex" +msgstr "" + +#: py/objdeque.c +msgid "empty" +msgstr "" + +#: extmod/moduasyncio.c extmod/moduheapq.c extmod/modutimeq.c +msgid "empty heap" +msgstr "" + +#: py/objstr.c +msgid "empty separator" +msgstr "" + +#: shared-bindings/random/__init__.c +msgid "empty sequence" +msgstr "" + +#: py/objstr.c +msgid "end of format while looking for conversion specifier" +msgstr "" + +#: shared-bindings/displayio/Shape.c +msgid "end_x should be an int" +msgstr "" + +#: shared-bindings/alarm/time/TimeAlarm.c +msgid "epoch_time not supported on this board" +msgstr "" + +#: ports/nrf/common-hal/busio/UART.c +#, c-format +msgid "error = 0x%08lX" +msgstr "" + +#: py/runtime.c +msgid "exceptions must derive from BaseException" +msgstr "" + +#: shared-bindings/canio/CAN.c +msgid "expected '%q' but got '%q'" +msgstr "" + +#: shared-bindings/canio/CAN.c +msgid "expected '%q' or '%q' but got '%q'" +msgstr "" + +#: py/objstr.c +msgid "expected ':' after format specifier" +msgstr "" + +#: py/obj.c +msgid "expected tuple/list" +msgstr "" + +#: py/modthread.c +msgid "expecting a dict for keyword args" +msgstr "" + +#: py/compile.c +msgid "expecting an assembler instruction" +msgstr "" + +#: py/compile.c +msgid "expecting just a value for set" +msgstr "" + +#: py/compile.c +msgid "expecting key:value for dict" +msgstr "" + +#: shared-bindings/msgpack/__init__.c +msgid "ext_hook is not a function" +msgstr "" + +#: py/argcheck.c +msgid "extra keyword arguments given" +msgstr "" + +#: py/argcheck.c +msgid "extra positional arguments given" +msgstr "" + +#: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c +#: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c +#: shared-module/gifio/GifWriter.c +msgid "file must be a file opened in byte mode" +msgstr "" + +#: shared-bindings/traceback/__init__.c +msgid "file write is not available" +msgstr "" + +#: shared-bindings/storage/__init__.c +msgid "filesystem must provide mount method" +msgstr "" + +#: extmod/ulab/code/numpy/vector.c +msgid "first argument must be a callable" +msgstr "" + +#: extmod/ulab/code/scipy/optimize/optimize.c +msgid "first argument must be a function" +msgstr "" + +#: extmod/ulab/code/numpy/create.c +msgid "first argument must be a tuple of ndarrays" +msgstr "" + +#: extmod/ulab/code/numpy/vector.c +msgid "first argument must be an ndarray" +msgstr "" + +#: py/objtype.c +msgid "first argument to super() must be type" +msgstr "" + +#: extmod/ulab/code/scipy/linalg/linalg.c +msgid "first two arguments must be ndarrays" +msgstr "" + +#: extmod/ulab/code/ndarray.c +msgid "flattening order must be either 'C', or 'F'" +msgstr "" + +#: extmod/ulab/code/numpy/numerical.c +msgid "flip argument must be an ndarray" +msgstr "" + +#: py/objint.c +msgid "float too big" +msgstr "" + +#: py/nativeglue.c +msgid "float unsupported" +msgstr "" + +#: shared-bindings/_stage/Text.c +msgid "font must be 2048 bytes long" +msgstr "" + +#: py/objstr.c +msgid "format requires a dict" +msgstr "" + +#: py/objdeque.c +msgid "full" +msgstr "" + +#: py/argcheck.c +msgid "function doesn't take keyword arguments" +msgstr "" + +#: py/argcheck.c +#, c-format +msgid "function expected at most %d arguments, got %d" +msgstr "" + +#: py/bc.c py/objnamedtuple.c +msgid "function got multiple values for argument '%q'" +msgstr "" + +#: extmod/ulab/code/scipy/optimize/optimize.c +msgid "function has the same sign at the ends of interval" +msgstr "" + +#: extmod/ulab/code/ndarray.c +msgid "function is defined for ndarrays only" +msgstr "" + +#: extmod/ulab/code/numpy/carray/carray.c +msgid "function is implemented for ndarrays only" +msgstr "" + +#: py/argcheck.c +#, c-format +msgid "function missing %d required positional arguments" +msgstr "" + +#: py/bc.c +msgid "function missing keyword-only argument" +msgstr "" + +#: py/bc.c +msgid "function missing required keyword argument '%q'" +msgstr "" + +#: py/bc.c +#, c-format +msgid "function missing required positional argument #%d" +msgstr "" + +#: py/argcheck.c py/bc.c py/objnamedtuple.c shared-bindings/time/__init__.c +#, c-format +msgid "function takes %d positional arguments but %d were given" +msgstr "" + +#: shared-bindings/time/__init__.c +msgid "function takes exactly 9 arguments" +msgstr "" + +#: py/objgenerator.c +msgid "generator already executing" +msgstr "" + +#: py/objgenerator.c +msgid "generator ignored GeneratorExit" +msgstr "" + +#: py/objgenerator.c py/runtime.c +msgid "generator raised StopIteration" +msgstr "" + +#: shared-bindings/_stage/Layer.c +msgid "graphic must be 2048 bytes long" +msgstr "" + +#: extmod/moduhashlib.c +msgid "hash is final" +msgstr "" + +#: extmod/moduheapq.c +msgid "heap must be a list" +msgstr "" + +#: py/compile.c +msgid "identifier redefined as global" +msgstr "" + +#: py/compile.c +msgid "identifier redefined as nonlocal" +msgstr "" + +#: py/compile.c +msgid "import * not at module level" +msgstr "" + +#: py/persistentcode.c +msgid "incompatible native .mpy architecture" +msgstr "" + +#: py/objstr.c +msgid "incomplete format" +msgstr "" + +#: py/objstr.c +msgid "incomplete format key" +msgstr "" + +#: extmod/modubinascii.c +msgid "incorrect padding" +msgstr "" + +#: extmod/ulab/code/ndarray.c +msgid "index is out of bounds" +msgstr "" + +#: extmod/ulab/code/numpy/numerical.c extmod/ulab/code/ulab_tools.c +#: ports/espressif/common-hal/pulseio/PulseIn.c py/obj.c +#: shared-bindings/bitmaptools/__init__.c +msgid "index out of range" +msgstr "" + +#: py/obj.c +msgid "indices must be integers" +msgstr "" + +#: extmod/ulab/code/ndarray.c +msgid "indices must be integers, slices, or Boolean lists" +msgstr "" + +#: extmod/ulab/code/scipy/optimize/optimize.c +msgid "initial values must be iterable" +msgstr "" + +#: shared-bindings/_bleio/Characteristic.c shared-bindings/_bleio/Descriptor.c +msgid "initial_value length is wrong" +msgstr "" + +#: py/compile.c +msgid "inline assembler must be a function" +msgstr "" + +#: extmod/ulab/code/ndarray.c +msgid "input and output shapes are not compatible" +msgstr "" + +#: extmod/ulab/code/numpy/create.c +msgid "input argument must be an integer, a tuple, or a list" +msgstr "" + +#: extmod/ulab/code/numpy/fft/fft_tools.c +msgid "input array length must be power of 2" +msgstr "" + +#: extmod/ulab/code/numpy/create.c +msgid "input arrays are not compatible" +msgstr "" + +#: extmod/ulab/code/numpy/poly.c +msgid "input data must be an iterable" +msgstr "" + +#: extmod/ulab/code/numpy/vector.c +msgid "input dtype must be float or complex" +msgstr "" + +#: extmod/ulab/code/numpy/linalg/linalg.c +msgid "input matrix is asymmetric" +msgstr "" + +#: extmod/ulab/code/numpy/linalg/linalg.c +#: extmod/ulab/code/scipy/linalg/linalg.c +msgid "input matrix is singular" +msgstr "" + +#: extmod/ulab/code/numpy/carray/carray.c +msgid "input must be a 1D ndarray" +msgstr "" + +#: extmod/ulab/code/scipy/linalg/linalg.c extmod/ulab/code/user/user.c +msgid "input must be a dense ndarray" +msgstr "" + +#: extmod/ulab/code/numpy/create.c +msgid "input must be a tensor of rank 2" +msgstr "" + +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/user/user.c +msgid "input must be an ndarray" +msgstr "" + +#: extmod/ulab/code/numpy/carray/carray.c +msgid "input must be an ndarray, or a scalar" +msgstr "" + +#: extmod/ulab/code/scipy/signal/signal.c +msgid "input must be one-dimensional" +msgstr "" + +#: extmod/ulab/code/ulab_tools.c +msgid "input must be square matrix" +msgstr "" + +#: extmod/ulab/code/numpy/numerical.c +msgid "input must be tuple, list, range, or ndarray" +msgstr "" + +#: extmod/ulab/code/numpy/poly.c +msgid "input vectors must be of equal length" +msgstr "" + +#: extmod/ulab/code/numpy/poly.c +msgid "inputs are not iterable" +msgstr "" + +#: py/parsenum.c +msgid "int() arg 2 must be >= 2 and <= 36" +msgstr "" + +#: extmod/ulab/code/numpy/approx.c +msgid "interp is defined for 1D iterables of equal length" +msgstr "" + +#: shared-bindings/_bleio/Adapter.c +#, c-format +msgid "interval must be in range %s-%s" +msgstr "" + +#: py/compile.c +msgid "invalid architecture" +msgstr "" + +#: shared-bindings/bitmaptools/__init__.c +#, c-format +msgid "invalid bits_per_pixel %d, must be, 1, 2, 4, 8, 16, 24, or 32" +msgstr "" + +#: shared-bindings/bitmaptools/__init__.c +#, c-format +msgid "invalid element size %d for bits_per_pixel %d\n" +msgstr "" + +#: shared-bindings/bitmaptools/__init__.c +#, c-format +msgid "invalid element_size %d, must be, 1, 2, or 4" +msgstr "" + +#: shared-bindings/traceback/__init__.c +msgid "invalid exception" +msgstr "" + +#: extmod/modframebuf.c +msgid "invalid format" +msgstr "" + +#: py/objstr.c +msgid "invalid format specifier" +msgstr "" + +#: shared-bindings/wifi/Radio.c +msgid "invalid hostname" +msgstr "" + +#: py/compile.c +msgid "invalid micropython decorator" +msgstr "" + +#: shared-bindings/random/__init__.c +msgid "invalid step" +msgstr "" + +#: py/compile.c py/parse.c +msgid "invalid syntax" +msgstr "" + +#: py/parsenum.c +msgid "invalid syntax for integer" +msgstr "" + +#: py/parsenum.c +#, c-format +msgid "invalid syntax for integer with base %d" +msgstr "" + +#: py/parsenum.c +msgid "invalid syntax for number" +msgstr "" + +#: py/objexcept.c +msgid "invalid traceback" +msgstr "" + +#: py/objtype.c +msgid "issubclass() arg 1 must be a class" +msgstr "" + +#: py/objtype.c +msgid "issubclass() arg 2 must be a class or a tuple of classes" +msgstr "" + +#: extmod/ulab/code/numpy/linalg/linalg.c +msgid "iterations did not converge" +msgstr "" + +#: py/objstr.c +msgid "join expects a list of str/bytes objects consistent with self object" +msgstr "" + +#: py/argcheck.c +msgid "keyword argument(s) not yet implemented - use normal args instead" +msgstr "" + +#: py/bc.c +msgid "keywords must be strings" +msgstr "" + +#: py/emitinlinethumb.c py/emitinlinextensa.c +msgid "label '%q' not defined" +msgstr "" + +#: py/compile.c +msgid "label redefined" +msgstr "" + +#: py/stream.c +msgid "length argument not allowed for this type" +msgstr "" + +#: shared-bindings/audiomixer/MixerVoice.c +msgid "level must be between 0 and 1" +msgstr "" + +#: py/objarray.c +msgid "lhs and rhs should be compatible" +msgstr "" + +#: py/emitnative.c +msgid "local '%q' has type '%q' but source is '%q'" +msgstr "" + +#: py/emitnative.c +msgid "local '%q' used before type known" +msgstr "" + +#: py/vm.c +msgid "local variable referenced before assignment" +msgstr "" + +#: py/objint.c +msgid "long int not supported in this build" +msgstr "" + +#: ports/espressif/common-hal/canio/CAN.c +msgid "loopback + silent mode not supported by peripheral" +msgstr "" + +#: py/parse.c +msgid "malformed f-string" +msgstr "" + +#: shared-bindings/_stage/Layer.c +msgid "map buffer too small" +msgstr "" + +#: py/modmath.c shared-bindings/math/__init__.c +msgid "math domain error" +msgstr "" + +#: extmod/ulab/code/numpy/linalg/linalg.c +msgid "matrix is not positive definite" +msgstr "" + +#: ports/espressif/common-hal/wifi/Radio.c +msgid "max_connections must be between 0 and 10" +msgstr "" + +#: ports/espressif/common-hal/_bleio/Descriptor.c +#: ports/nrf/common-hal/_bleio/Characteristic.c +#: ports/nrf/common-hal/_bleio/Descriptor.c +#, c-format +msgid "max_length must be 0-%d when fixed_length is %s" +msgstr "" + +#: shared-bindings/_bleio/Characteristic.c shared-bindings/_bleio/Descriptor.c +msgid "max_length must be >= 0" +msgstr "" + +#: extmod/ulab/code/ndarray.c +msgid "maximum number of dimensions is 4" +msgstr "" + +#: py/runtime.c +msgid "maximum recursion depth exceeded" +msgstr "" + +#: extmod/ulab/code/scipy/optimize/optimize.c +msgid "maxiter must be > 0" +msgstr "" + +#: extmod/ulab/code/scipy/optimize/optimize.c +msgid "maxiter should be > 0" +msgstr "" + +#: extmod/ulab/code/numpy/numerical.c +msgid "median argument must be an ndarray" +msgstr "" + +#: py/runtime.c +#, c-format +msgid "memory allocation failed, allocating %u bytes" +msgstr "" + +#: py/runtime.c +msgid "memory allocation failed, heap is locked" +msgstr "" + +#: py/objarray.c +msgid "memoryview: length is not a multiple of itemsize" +msgstr "" + +#: extmod/ulab/code/numpy/linalg/linalg.c +msgid "mode must be complete, or reduced" +msgstr "" + +#: py/builtinimport.c +msgid "module not found" +msgstr "" + +#: ports/espressif/common-hal/wifi/Monitor.c +msgid "monitor init failed" +msgstr "" + +#: extmod/ulab/code/numpy/poly.c +msgid "more degrees of freedom than data points" +msgstr "" + +#: py/compile.c +msgid "multiple *x in assignment" +msgstr "" + +#: py/objtype.c +msgid "multiple bases have instance lay-out conflict" +msgstr "" + +#: py/objtype.c +msgid "multiple inheritance not supported" +msgstr "" + +#: py/emitnative.c +msgid "must raise an object" +msgstr "" + +#: py/modbuiltins.c +msgid "must use keyword argument for key function" +msgstr "" + +#: py/runtime.c +msgid "name '%q' is not defined" +msgstr "" + +#: py/runtime.c +msgid "name not defined" +msgstr "" + +#: py/asmthumb.c +msgid "native method too big" +msgstr "" + +#: py/emitnative.c +msgid "native yield" +msgstr "" + +#: py/runtime.c +#, c-format +msgid "need more than %d values to unpack" +msgstr "" + +#: py/modmath.c +msgid "negative factorial" +msgstr "" + +#: py/objint_longlong.c py/objint_mpz.c py/runtime.c +msgid "negative power with no float support" +msgstr "" + +#: py/objint_mpz.c py/runtime.c +msgid "negative shift count" +msgstr "" + +#: shared-module/sdcardio/SDCard.c +msgid "no SD card" +msgstr "" + +#: py/vm.c +msgid "no active exception to reraise" +msgstr "" + +#: py/compile.c +msgid "no binding for nonlocal found" +msgstr "" + +#: shared-module/msgpack/__init__.c +msgid "no default packer" +msgstr "" + +#: extmod/modurandom.c +msgid "no default seed" +msgstr "" + +#: py/builtinimport.c +msgid "no module named '%q'" +msgstr "" + +#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/I2CDisplay.c +#: shared-bindings/paralleldisplay/ParallelBus.c +msgid "no reset pin available" +msgstr "" + +#: shared-module/sdcardio/SDCard.c +msgid "no response from SD card" +msgstr "" + +#: py/objobject.c py/runtime.c +msgid "no such attribute" +msgstr "" + +#: shared-bindings/usb_hid/__init__.c +msgid "non-Device in %q" +msgstr "" + +#: ports/espressif/common-hal/_bleio/Connection.c +#: ports/nrf/common-hal/_bleio/Connection.c +msgid "non-UUID found in service_uuids_whitelist" +msgstr "" + +#: py/compile.c +msgid "non-default argument follows default argument" +msgstr "" + +#: extmod/modubinascii.c +msgid "non-hex digit found" +msgstr "" + +#: py/compile.c +msgid "non-keyword arg after */**" +msgstr "" + +#: py/compile.c +msgid "non-keyword arg after keyword arg" +msgstr "" + +#: ports/nrf/common-hal/_bleio/Adapter.c +msgid "non-zero timeout must be > 0.01" +msgstr "" + +#: shared-bindings/_bleio/Adapter.c +msgid "non-zero timeout must be >= interval" +msgstr "" + +#: shared-bindings/_bleio/UUID.c +msgid "not a 128-bit UUID" +msgstr "" + +#: py/objstr.c +msgid "not all arguments converted during string formatting" +msgstr "" + +#: py/objstr.c +msgid "not enough arguments for format string" +msgstr "" + +#: extmod/ulab/code/numpy/carray/carray_tools.c +msgid "not implemented for complex dtype" +msgstr "" + +#: extmod/ulab/code/numpy/create.c +msgid "number of points must be at least 2" +msgstr "" + +#: py/builtinhelp.c +msgid "object " +msgstr "" + +#: py/obj.c +#, c-format +msgid "object '%s' isn't a tuple or list" +msgstr "" + +#: py/obj.c +msgid "object doesn't support item assignment" +msgstr "" + +#: py/obj.c +msgid "object doesn't support item deletion" +msgstr "" + +#: py/obj.c +msgid "object has no len" +msgstr "" + +#: py/obj.c +msgid "object isn't subscriptable" +msgstr "" + +#: py/runtime.c +msgid "object not an iterator" +msgstr "" + +#: py/objtype.c py/runtime.c +msgid "object not callable" +msgstr "" + +#: py/sequence.c shared-bindings/displayio/Group.c +msgid "object not in sequence" +msgstr "" + +#: py/runtime.c +msgid "object not iterable" +msgstr "" + +#: py/obj.c +#, c-format +msgid "object of type '%s' has no len()" +msgstr "" + +#: py/obj.c +msgid "object with buffer protocol required" +msgstr "" + +#: extmod/modubinascii.c +msgid "odd-length string" +msgstr "" + +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/utils/utils.c +msgid "offset is too large" +msgstr "" + +#: shared-bindings/dualbank/__init__.c +msgid "offset must be >= 0" +msgstr "" + +#: extmod/ulab/code/numpy/create.c +msgid "offset must be non-negative and no greater than buffer length" +msgstr "" + +#: py/objstr.c py/objstrunicode.c +msgid "offset out of bounds" +msgstr "" + +#: ports/nrf/common-hal/audiobusio/PDMIn.c +msgid "only bit_depth=16 is supported" +msgstr "" + +#: ports/nrf/common-hal/audiobusio/PDMIn.c +msgid "only sample_rate=16000 is supported" +msgstr "" + +#: py/objarray.c py/objstr.c py/objstrunicode.c py/objtuple.c +#: shared-bindings/alarm/SleepMemory.c shared-bindings/nvm/ByteArray.c +msgid "only slices with step=1 (aka None) are supported" +msgstr "" + +#: py/vm.c +msgid "opcode" +msgstr "" + +#: extmod/ulab/code/ndarray.c extmod/ulab/code/numpy/compare.c +#: extmod/ulab/code/numpy/vector.c +msgid "operands could not be broadcast together" +msgstr "" + +#: extmod/ulab/code/numpy/linalg/linalg.c +msgid "operation is defined for 2D arrays only" +msgstr "" + +#: extmod/ulab/code/numpy/linalg/linalg.c +msgid "operation is defined for ndarrays only" +msgstr "" + +#: extmod/ulab/code/ndarray.c +msgid "operation is implemented for 1D Boolean arrays only" +msgstr "" + +#: extmod/ulab/code/numpy/numerical.c +msgid "operation is not implemented on ndarrays" +msgstr "" + +#: extmod/ulab/code/ndarray.c +msgid "operation is not supported for given type" +msgstr "" + +#: py/modbuiltins.c +msgid "ord expects a character" +msgstr "" + +#: py/modbuiltins.c +#, c-format +msgid "ord() expected a character, but string of length %d found" +msgstr "" + +#: extmod/ulab/code/utils/utils.c +msgid "out array is too small" +msgstr "" + +#: extmod/ulab/code/utils/utils.c +msgid "out must be a float dense array" +msgstr "" + +#: shared-bindings/displayio/Bitmap.c +msgid "out of range of source" +msgstr "" + +#: shared-bindings/bitmaptools/__init__.c shared-bindings/displayio/Bitmap.c +msgid "out of range of target" +msgstr "" + +#: py/objint_mpz.c +msgid "overflow converting long int to machine word" +msgstr "" + +#: py/modstruct.c +#, c-format +msgid "pack expected %d items for packing (got %d)" +msgstr "" + +#: shared-bindings/_stage/Layer.c shared-bindings/_stage/Text.c +msgid "palette must be 32 bytes long" +msgstr "" + +#: shared-bindings/displayio/Palette.c +msgid "palette_index should be an int" +msgstr "" + +#: py/emitinlinextensa.c +msgid "parameters must be registers in sequence a2 to a5" +msgstr "" + +#: py/emitinlinethumb.c +msgid "parameters must be registers in sequence r0 to r3" +msgstr "" + +#: shared-bindings/bitmaptools/__init__.c shared-bindings/displayio/Bitmap.c +msgid "pixel coordinates out of bounds" +msgstr "" + +#: shared-bindings/displayio/Bitmap.c +msgid "pixel value requires too many bits" +msgstr "" + +#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c +msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" +msgstr "" + +#: extmod/vfs_posix_file.c +msgid "poll on file not available on win32" +msgstr "" + +#: shared-module/vectorio/Polygon.c +msgid "polygon can only be registered in one parent" +msgstr "" + +#: ports/espressif/common-hal/pulseio/PulseIn.c +msgid "pop from an empty PulseIn" +msgstr "" + +#: ports/atmel-samd/common-hal/pulseio/PulseIn.c +#: ports/cxd56/common-hal/pulseio/PulseIn.c +#: ports/nrf/common-hal/pulseio/PulseIn.c +#: ports/raspberrypi/common-hal/pulseio/PulseIn.c +#: ports/stm/common-hal/pulseio/PulseIn.c py/objdict.c py/objlist.c py/objset.c +#: shared-bindings/ps2io/Ps2.c +msgid "pop from empty %q" +msgstr "" + +#: shared-bindings/socketpool/Socket.c shared-bindings/ssl/SSLSocket.c +msgid "port must be >= 0" +msgstr "" + +#: py/objint_mpz.c +msgid "pow() 3rd argument cannot be 0" +msgstr "" + +#: py/objint_mpz.c +msgid "pow() with 3 arguments requires integers" +msgstr "" + +#: ports/espressif/boards/adafruit_esp32s2_camera/mpconfigboard.h +#: ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h +#: ports/espressif/boards/adafruit_feather_esp32s2_tft/mpconfigboard.h +#: ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h +#: ports/espressif/boards/adafruit_funhouse/mpconfigboard.h +#: ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h +#: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h +#: ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h +#: ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.h +#: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h +#: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h +#: ports/espressif/boards/artisense_rd00/mpconfigboard.h +#: ports/espressif/boards/atmegazero_esp32s2/mpconfigboard.h +#: ports/espressif/boards/crumpspace_crumps2/mpconfigboard.h +#: ports/espressif/boards/electroniccats_bastwifi/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s2_devkitc_1_n4r2/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_box/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h +#: ports/espressif/boards/espressif_hmi_devkit_1/mpconfigboard.h +#: ports/espressif/boards/espressif_kaluga_1.3/mpconfigboard.h +#: ports/espressif/boards/espressif_kaluga_1/mpconfigboard.h +#: ports/espressif/boards/espressif_saola_1_wroom/mpconfigboard.h +#: ports/espressif/boards/espressif_saola_1_wrover/mpconfigboard.h +#: ports/espressif/boards/franzininho_wifi_wroom/mpconfigboard.h +#: ports/espressif/boards/franzininho_wifi_wrover/mpconfigboard.h +#: ports/espressif/boards/gravitech_cucumber_m/mpconfigboard.h +#: ports/espressif/boards/gravitech_cucumber_ms/mpconfigboard.h +#: ports/espressif/boards/gravitech_cucumber_r/mpconfigboard.h +#: ports/espressif/boards/gravitech_cucumber_rs/mpconfigboard.h +#: ports/espressif/boards/lilygo_ttgo_t8_s2_st7789/mpconfigboard.h +#: ports/espressif/boards/lolin_s2_mini/mpconfigboard.h +#: ports/espressif/boards/lolin_s2_pico/mpconfigboard.h +#: ports/espressif/boards/microdev_micro_c3/mpconfigboard.h +#: ports/espressif/boards/microdev_micro_s2/mpconfigboard.h +#: ports/espressif/boards/morpheans_morphesp-240/mpconfigboard.h +#: ports/espressif/boards/muselab_nanoesp32_s2_wroom/mpconfigboard.h +#: ports/espressif/boards/muselab_nanoesp32_s2_wrover/mpconfigboard.h +#: ports/espressif/boards/odt_pixelwing_esp32_s2/mpconfigboard.h +#: ports/espressif/boards/targett_module_clip_wroom/mpconfigboard.h +#: ports/espressif/boards/targett_module_clip_wrover/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_feathers2/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_feathers2_neo/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_feathers2_prerelease/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_feathers3/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_pros3/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_tinys2/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_tinys3/mpconfigboard.h +msgid "pressing boot button at start up.\n" +msgstr "" + +#: ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.h +#: ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.h +#: ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.h +#: ports/atmel-samd/boards/escornabot_makech/mpconfigboard.h +#: ports/atmel-samd/boards/meowmeow/mpconfigboard.h +msgid "pressing both buttons at start up.\n" +msgstr "" + +#: ports/nrf/boards/aramcon2_badge/mpconfigboard.h +msgid "pressing the left button at start up\n" +msgstr "" + +#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c +msgid "pull masks conflict with direction masks" +msgstr "" + +#: ports/raspberrypi/bindings/rp2pio/StateMachine.c +msgid "pull_threshold must be between 1 and 32" +msgstr "" + +#: ports/raspberrypi/bindings/rp2pio/StateMachine.c +msgid "push_threshold must be between 1 and 32" +msgstr "" + +#: extmod/modutimeq.c +msgid "queue overflow" +msgstr "" + +#: py/parse.c +msgid "raw f-strings are not supported" +msgstr "" + +#: extmod/ulab/code/numpy/fft/fft_tools.c +msgid "real and imaginary parts must be of equal length" +msgstr "" + +#: py/builtinimport.c +msgid "relative import" +msgstr "" + +#: py/obj.c +#, c-format +msgid "requested length %d but object has length %d" +msgstr "" + +#: extmod/ulab/code/ndarray_operators.c +msgid "results cannot be cast to specified type" +msgstr "" + +#: py/compile.c +msgid "return annotation must be an identifier" +msgstr "" + +#: py/emitnative.c +msgid "return expected '%q' but got '%q'" +msgstr "" + +#: shared-bindings/rgbmatrix/RGBMatrix.c +#, c-format +msgid "rgb_pins[%d] duplicates another pin assignment" +msgstr "" + +#: shared-bindings/rgbmatrix/RGBMatrix.c +#, c-format +msgid "rgb_pins[%d] is not on the same port as clock" +msgstr "" + +#: extmod/ulab/code/numpy/numerical.c +msgid "roll argument must be an ndarray" +msgstr "" + +#: py/objstr.c +msgid "rsplit(None,n)" +msgstr "" + +#: shared-bindings/audiocore/RawSample.c +msgid "" +"sample_source buffer must be a bytearray or array of type 'h', 'H', 'b' or " +"'B'" +msgstr "" + +#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c +#: ports/raspberrypi/common-hal/audiobusio/PDMIn.c +msgid "sampling rate out of range" +msgstr "" + +#: py/modmicropython.c +msgid "schedule queue full" +msgstr "" + +#: py/builtinimport.c +msgid "script compilation not supported" +msgstr "" + +#: py/nativeglue.c +msgid "set unsupported" +msgstr "" + +#: extmod/ulab/code/ndarray.c +msgid "shape must be a tuple" +msgstr "" + +#: shared-module/msgpack/__init__.c +msgid "short read" +msgstr "" + +#: py/objstr.c +msgid "sign not allowed in string format specifier" +msgstr "" + +#: py/objstr.c +msgid "sign not allowed with integer format specifier 'c'" +msgstr "" + +#: py/objstr.c +msgid "single '}' encountered in format string" +msgstr "" + +#: extmod/ulab/code/ulab_tools.c +msgid "size is defined for ndarrays only" +msgstr "" + +#: shared-bindings/time/__init__.c +msgid "sleep length must be non-negative" +msgstr "" + +#: extmod/ulab/code/ndarray.c +msgid "slice step can't be zero" +msgstr "" + +#: py/objslice.c +msgid "slice step cannot be zero" +msgstr "" + +#: py/nativeglue.c +msgid "slice unsupported" +msgstr "" + +#: py/objint.c py/sequence.c +msgid "small int overflow" +msgstr "" + +#: main.c +msgid "soft reboot\n" +msgstr "" + +#: extmod/ulab/code/numpy/numerical.c +msgid "sort argument must be an ndarray" +msgstr "" + +#: extmod/ulab/code/scipy/signal/signal.c +msgid "sos array must be of shape (n_section, 6)" +msgstr "" + +#: extmod/ulab/code/scipy/signal/signal.c +msgid "sos[:, 3] should be all ones" +msgstr "" + +#: extmod/ulab/code/scipy/signal/signal.c +msgid "sosfilt requires iterable arguments" +msgstr "" + +#: shared-bindings/bitmaptools/__init__.c shared-bindings/displayio/Bitmap.c +msgid "source palette too large" +msgstr "" + +#: shared-bindings/bitmaptools/__init__.c +msgid "source_bitmap must have value_count of 2 or 65536" +msgstr "" + +#: shared-bindings/bitmaptools/__init__.c +msgid "source_bitmap must have value_count of 65536" +msgstr "" + +#: shared-bindings/bitmaptools/__init__.c +msgid "source_bitmap must have value_count of 8" +msgstr "" + +#: shared-bindings/wifi/Radio.c +msgid "ssid can't be more than 32 bytes" +msgstr "" + +#: py/objstr.c +msgid "start/end indices" +msgstr "" + +#: shared-bindings/displayio/Shape.c +msgid "start_x should be an int" +msgstr "" + +#: shared-bindings/random/__init__.c +msgid "step must be non-zero" +msgstr "" + +#: shared-bindings/busio/UART.c +msgid "stop must be 1 or 2" +msgstr "" + +#: shared-bindings/random/__init__.c +msgid "stop not reachable from start" +msgstr "" + +#: py/stream.c shared-bindings/getpass/__init__.c +msgid "stream operation not supported" +msgstr "" + +#: py/objstrunicode.c +msgid "string indices must be integers, not %q" +msgstr "" + +#: py/stream.c +msgid "string not supported; use bytes or bytearray" +msgstr "" + +#: extmod/moductypes.c +msgid "struct: can't index" +msgstr "" + +#: extmod/moductypes.c +msgid "struct: index out of range" +msgstr "" + +#: extmod/moductypes.c +msgid "struct: no fields" +msgstr "" + +#: py/objarray.c py/objstr.c +msgid "substring not found" +msgstr "" + +#: py/compile.c +msgid "super() can't find self" +msgstr "" + +#: extmod/modujson.c +msgid "syntax error in JSON" +msgstr "" + +#: extmod/moductypes.c +msgid "syntax error in uctypes descriptor" +msgstr "" + +#: shared-bindings/touchio/TouchIn.c +msgid "threshold must be in the range 0-65536" +msgstr "" + +#: shared-bindings/rgbmatrix/RGBMatrix.c +msgid "tile must be greater than zero" +msgstr "" + +#: shared-bindings/time/__init__.c +msgid "time.struct_time() takes a 9-sequence" +msgstr "" + +#: ports/atmel-samd/common-hal/watchdog/WatchDogTimer.c +#: ports/espressif/common-hal/watchdog/WatchDogTimer.c +#: ports/nrf/common-hal/watchdog/WatchDogTimer.c +#: ports/raspberrypi/common-hal/watchdog/WatchDogTimer.c +msgid "timeout duration exceeded the maximum supported value" +msgstr "" + +#: shared-bindings/busio/UART.c +msgid "timeout must be 0.0-100.0 seconds" +msgstr "" + +#: ports/nrf/common-hal/_bleio/Adapter.c +msgid "timeout must be < 655.35 secs" +msgstr "" + +#: shared-bindings/_bleio/CharacteristicBuffer.c +msgid "timeout must be >= 0.0" +msgstr "" + +#: shared-module/sdcardio/SDCard.c +msgid "timeout waiting for v1 card" +msgstr "" + +#: shared-module/sdcardio/SDCard.c +msgid "timeout waiting for v2 card" +msgstr "" + +#: shared-bindings/time/__init__.c +msgid "timestamp out of range for platform time_t" +msgstr "" + +#: extmod/ulab/code/ndarray.c +msgid "tobytes can be invoked for dense arrays only" +msgstr "" + +#: shared-module/struct/__init__.c +msgid "too many arguments provided with the given format" +msgstr "" + +#: extmod/ulab/code/ndarray.c extmod/ulab/code/numpy/create.c +msgid "too many dimensions" +msgstr "" + +#: extmod/ulab/code/ndarray.c +msgid "too many indices" +msgstr "" + +#: py/asmthumb.c +msgid "too many locals for native method" +msgstr "" + +#: py/runtime.c +#, c-format +msgid "too many values to unpack (expected %d)" +msgstr "" + +#: extmod/ulab/code/numpy/approx.c +msgid "trapz is defined for 1D arrays of equal length" +msgstr "" + +#: extmod/ulab/code/numpy/approx.c +msgid "trapz is defined for 1D iterables" +msgstr "" + +#: py/obj.c +msgid "tuple/list has wrong length" +msgstr "" + +#: ports/espressif/common-hal/canio/CAN.c +#, c-format +msgid "twai_driver_install returned esp-idf error #%d" +msgstr "" + +#: ports/espressif/common-hal/canio/CAN.c +#, c-format +msgid "twai_start returned esp-idf error #%d" +msgstr "" + +#: ports/atmel-samd/common-hal/busio/UART.c +#: ports/espressif/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: shared-bindings/busio/UART.c shared-bindings/canio/CAN.c +msgid "tx and rx cannot both be None" +msgstr "" + +#: py/objtype.c +msgid "type '%q' is not an acceptable base type" +msgstr "" + +#: py/objtype.c +msgid "type is not an acceptable base type" +msgstr "" + +#: py/runtime.c +msgid "type object '%q' has no attribute '%q'" +msgstr "" + +#: py/objgenerator.c +msgid "type object 'generator' has no attribute '__await__'" +msgstr "" + +#: py/objtype.c +msgid "type takes 1 or 3 arguments" +msgstr "" + +#: py/objint_longlong.c +msgid "ulonglong too large" +msgstr "" + +#: py/emitnative.c +msgid "unary op %q not implemented" +msgstr "" + +#: py/parse.c +msgid "unexpected indent" +msgstr "" + +#: py/bc.c +msgid "unexpected keyword argument" +msgstr "" + +#: py/bc.c py/objnamedtuple.c +msgid "unexpected keyword argument '%q'" +msgstr "" + +#: py/lexer.c +msgid "unicode name escapes" +msgstr "" + +#: py/parse.c +msgid "unindent doesn't match any outer indent level" +msgstr "" + +#: py/objstr.c +#, c-format +msgid "unknown conversion specifier %c" +msgstr "" + +#: py/objstr.c +msgid "unknown format code '%c' for object of type '%q'" +msgstr "" + +#: py/compile.c +msgid "unknown type" +msgstr "" + +#: py/compile.c +msgid "unknown type '%q'" +msgstr "" + +#: py/objstr.c +msgid "unmatched '{' in format" +msgstr "" + +#: py/objtype.c py/runtime.c +msgid "unreadable attribute" +msgstr "" + +#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c +#: shared-module/vectorio/Polygon.c shared-module/vectorio/VectorShape.c +msgid "unsupported %q type" +msgstr "" + +#: py/emitinlinethumb.c +#, c-format +msgid "unsupported Thumb instruction '%s' with %d arguments" +msgstr "" + +#: py/emitinlinextensa.c +#, c-format +msgid "unsupported Xtensa instruction '%s' with %d arguments" +msgstr "" + +#: shared-module/gifio/GifWriter.c +msgid "unsupported colorspace for GifWriter" +msgstr "" + +#: shared-bindings/bitmaptools/__init__.c +msgid "unsupported colorspace for dither" +msgstr "" + +#: py/objstr.c +#, c-format +msgid "unsupported format character '%c' (0x%x) at index %d" +msgstr "" + +#: py/runtime.c +msgid "unsupported type for %q: '%q'" +msgstr "" + +#: py/runtime.c +msgid "unsupported type for operator" +msgstr "" + +#: py/runtime.c +msgid "unsupported types for %q: '%q', '%q'" +msgstr "" + +#: py/objint.c +#, c-format +msgid "value must fit in %d byte(s)" +msgstr "" + +#: shared-bindings/bitmaptools/__init__.c +msgid "value out of range of target" +msgstr "" + +#: shared-bindings/displayio/Bitmap.c +msgid "value_count must be > 0" +msgstr "" + +#: ports/espressif/common-hal/watchdog/WatchDogTimer.c +msgid "watchdog not initialized" +msgstr "" + +#: shared-bindings/watchdog/WatchDogTimer.c +msgid "watchdog timeout must be greater than 0" +msgstr "" + +#: shared-bindings/bitops/__init__.c +#, c-format +msgid "width must be from 2 to 8 (inclusive), not %d" +msgstr "" + +#: shared-bindings/is31fl3741/FrameBuffer.c +#: shared-bindings/rgbmatrix/RGBMatrix.c +msgid "width must be greater than zero" +msgstr "" + +#: ports/espressif/common-hal/wifi/Radio.c +msgid "wifi is not enabled" +msgstr "" + +#: shared-bindings/_bleio/Adapter.c +msgid "window must be <= interval" +msgstr "" + +#: extmod/ulab/code/numpy/numerical.c +msgid "wrong axis index" +msgstr "" + +#: extmod/ulab/code/numpy/create.c +msgid "wrong axis specified" +msgstr "" + +#: extmod/ulab/code/numpy/compare.c extmod/ulab/code/numpy/vector.c +msgid "wrong input type" +msgstr "" + +#: extmod/ulab/code/numpy/transform.c +msgid "wrong length of condition array" +msgstr "" + +#: extmod/ulab/code/numpy/create.c py/objarray.c py/objstr.c +msgid "wrong number of arguments" +msgstr "" + +#: py/runtime.c +msgid "wrong number of values to unpack" +msgstr "" + +#: extmod/ulab/code/numpy/vector.c +msgid "wrong output type" +msgstr "" + +#: shared-module/displayio/Shape.c +msgid "x value out of bounds" +msgstr "" + +#: ports/espressif/common-hal/audiobusio/__init__.c +msgid "xTaskCreate failed" +msgstr "" + +#: shared-bindings/displayio/Shape.c +msgid "y should be an int" +msgstr "" + +#: shared-module/displayio/Shape.c +msgid "y value out of bounds" +msgstr "" + +#: py/objrange.c +msgid "zero step" +msgstr "" + +#: extmod/ulab/code/scipy/signal/signal.c +msgid "zi must be an ndarray" +msgstr "" + +#: extmod/ulab/code/scipy/signal/signal.c +msgid "zi must be of float type" +msgstr "" + +#: extmod/ulab/code/scipy/signal/signal.c +msgid "zi must be of shape (n_section, 2)" +msgstr "" diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index 07188c8f99..f58dd12cdb 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -7,15 +7,15 @@ msgstr "" "Project-Id-Version: circuitpython-cn\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-01-04 12:55-0600\n" -"PO-Revision-Date: 2021-11-16 01:34+0000\n" -"Last-Translator: River Wang \n" +"PO-Revision-Date: 2022-02-13 00:57+0000\n" +"Last-Translator: hexthat \n" "Language-Team: Chinese Hanyu Pinyin\n" "Language: zh_Latn_pinyin\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=1; plural=0;\n" -"X-Generator: Weblate 4.9.1-dev\n" +"X-Generator: Weblate 4.11-dev\n" #: main.c msgid "" @@ -69,12 +69,12 @@ msgid "%%c requires int or char" msgstr "%%c xūyào zhěngshù huòzhě zìfú" #: shared-bindings/rgbmatrix/RGBMatrix.c -#, fuzzy, c-format +#, c-format msgid "" "%d address pins, %d rgb pins and %d tiles indicate a height of %d, not %d" msgstr "" -"%d de zhǐ yǐn jiǎo , %d rgb yǐn jiǎo hé %d qiē piàn biǎo shì %d de gāo dù, " -"ér bù shì %d" +"%d de zhǐ yǐn jiǎo, %d rgb yǐn jiǎo hé %d qiē piàn biǎo shì %d de gāo dù, ér " +"bù shì %d" #: shared-bindings/microcontroller/Pin.c msgid "%q and %q contain duplicate pins" @@ -109,7 +109,7 @@ msgstr "%q suǒyǐn bìxū shì zhěngshù, ér bùshì %s" msgid "%q length must be %d-%d" msgstr "%q cháng dù bì xū wéi %d-%d" -#: shared-bindings/usb_hid/Device.c +#: shared-bindings/busio/I2C.c shared-bindings/usb_hid/Device.c msgid "%q length must be >= 1" msgstr "%q cháng dù bì xū >= 1" @@ -154,6 +154,10 @@ msgstr "%q bì xū zài %d hé %d zhī jiān" msgid "%q must be of type %q" msgstr "%q bì xū shì %q lèi xíng" +#: shared-bindings/digitalio/Pull.c +msgid "%q must be of type %q or None" +msgstr "%q lèi xíng bì xū wéi %q huò wú" + #: ports/atmel-samd/common-hal/busio/UART.c msgid "%q must be power of 2" msgstr "%q bì xū shì 2 de zhěng shù cì fāng" @@ -453,6 +457,7 @@ msgstr "cǐ yǐnjiǎo de suǒyǒu jìshíqì dōu zài shǐyòng zhōng" msgid "All timers in use" msgstr "suǒyǒu jìshí qì dōu zài shǐyòng zhōng" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Already advertising." msgstr "Mùqián zhèngzài guǎngbō." @@ -591,7 +596,7 @@ msgstr "liǎnggè yǐnjiǎo dōu bìxū zhīchí yìngjiàn zhōngduàn" #: shared-bindings/displayio/Display.c #: shared-bindings/framebufferio/FramebufferDisplay.c -#: shared-bindings/is31fl3741/is31fl3741.c +#: shared-bindings/is31fl3741/FrameBuffer.c #: shared-bindings/rgbmatrix/RGBMatrix.c msgid "Brightness must be 0-1.0" msgstr "Liàngdù bìxū wèi 0-1.0" @@ -641,20 +646,20 @@ msgstr "Huǎnchōngqū chángdù bìxū wéi 512 de bèishù" #: ports/stm/common-hal/sdioio/SDCard.c msgid "Buffer must be a multiple of 512 bytes" -msgstr "Huǎn chōng qū bì xū shì 512 zì jié de bèi shù" +msgstr "Huǎnchōngqū bìxū shì 512 zìjié de bèishù" -#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c +#: shared-bindings/bitbangio/I2C.c msgid "Buffer must be at least length 1" -msgstr "Huǎnchōng qū bìxū zhìshǎo chángdù 1" +msgstr "Huǎnchōng qū bìxū zhìshǎo chángdù wéi 1" #: shared-bindings/_bleio/PacketBuffer.c -#, c-format +#, fuzzy, c-format msgid "Buffer too short by %d bytes" msgstr "Huǎn chōng qū tài duǎn , àn %d zì jié" #: ports/espressif/common-hal/imagecapture/ParallelImageCapture.c msgid "Buffers must be same size" -msgstr "huǎn chōng qì bì xū dà xiǎo xiāng tóng" +msgstr "huǎnchōng qū bìxū dàxiǎo xiāngtóng" #: ports/atmel-samd/common-hal/paralleldisplay/ParallelBus.c #: ports/espressif/common-hal/paralleldisplay/ParallelBus.c @@ -662,39 +667,46 @@ msgstr "huǎn chōng qì bì xū dà xiǎo xiāng tóng" #: ports/raspberrypi/common-hal/paralleldisplay/ParallelBus.c #, c-format msgid "Bus pin %d is already in use" -msgstr "Zǒngxiàn yǐn jiǎo %d yǐ zài shǐyòng zhōng" +msgstr "Zǒngxiàn yǐnjiǎo %d yǐjīng zài shǐyòng zhōng" #: shared-bindings/_bleio/UUID.c msgid "Byte buffer must be 16 bytes." -msgstr "Zì jié huǎnchōng qū bìxū shì 16 zì jié." +msgstr "Zìjié huǎnchōng qū bìxū shì 16 zìjié." #: shared-bindings/alarm/SleepMemory.c shared-bindings/nvm/ByteArray.c msgid "Bytes must be between 0 and 255." -msgstr "Zì jié bìxū jiè yú 0 dào 255 zhī jiān." +msgstr "Zìjié bìxū jiè yú 0 dào 255 zhījiān." #: shared-bindings/aesio/aes.c msgid "CBC blocks must be multiples of 16 bytes" -msgstr "CBC kuài bì xū shì 16 zì jié de bèi shù" +msgstr "CBC kuài bìxū shì 16 zìjié de bèishù" + +#: supervisor/shared/safe_mode.c +msgid "CIRCUITPY drive could not be found or created." +msgstr "zhǎo bú dào huò chuàng jiàn CIRCUITPY qū dòng qì." #: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c msgid "CRC or checksum was invalid" -msgstr "CRC huò jiào yàn hé wú xiào" +msgstr "CRC huò jiàoyàn hé wúxiào" #: py/objtype.c msgid "Call super().__init__() before accessing native object." -msgstr "Zài fǎngwèn běn jī wùjiàn zhīqián diàoyòng super().__init__()." +msgstr "Zài fǎngwèn yuánshēn dùixiàng zhīqián diàoyòng super().__init__()." #: ports/espressif/common-hal/alarm/pin/PinAlarm.c +#, fuzzy msgid "Can only alarm on RTC IO from deep sleep." -msgstr "zhǐ néng zài RTC Io shàng cóng shēn dù shuì mián zhōng bào jǐng." +msgstr "zhǐ néng zài RTC IO shàng cóng shēndù shuìmián zhōng bào jǐng." #: ports/espressif/common-hal/alarm/pin/PinAlarm.c +#, fuzzy msgid "Can only alarm on one low pin while others alarm high from deep sleep." msgstr "" "Zhǐ néng zài yīgè dī diàn píng yǐn jiǎo shàng fāchū jǐngbào, ér qítā yǐn " "jiǎo cóng shēndù shuìmián zhōng fāchū gāo diàn píng jǐngbào." #: ports/espressif/common-hal/alarm/pin/PinAlarm.c +#, fuzzy msgid "Can only alarm on two low pins from deep sleep." msgstr "zhǐ néng cóng shēn dù shuì mián zhōng bào jǐng liǎng gè dī yǐn jiǎo." @@ -705,7 +717,7 @@ msgstr "Wúfǎ jiāng CCCD shèzhì wéi běndì tèzhēng" #: shared-bindings/storage/__init__.c shared-bindings/usb_cdc/__init__.c #: shared-bindings/usb_hid/__init__.c shared-bindings/usb_midi/__init__.c msgid "Cannot change USB devices now" -msgstr "xiàn zài wú fǎ gēng gǎi USB shè bèi" +msgstr "xiànzài wúfǎ gēnggǎi USB shèbèi" #: shared-bindings/_bleio/Adapter.c msgid "Cannot create a new Adapter; use _bleio.adapter;" @@ -715,14 +727,14 @@ msgstr "Wúfǎ chuàngjiàn xīn de shìpèiqì; shǐyòng_bleio.Adapter;" #: shared-bindings/memorymonitor/AllocationSize.c #: shared-bindings/pulseio/PulseIn.c msgid "Cannot delete values" -msgstr "Wúfǎ shānchú zhí" +msgstr "Wúfǎ jiāng zhí shānchú" #: ports/atmel-samd/common-hal/digitalio/DigitalInOut.c #: ports/mimxrt10xx/common-hal/digitalio/DigitalInOut.c #: ports/nrf/common-hal/digitalio/DigitalInOut.c #: ports/raspberrypi/common-hal/digitalio/DigitalInOut.c msgid "Cannot get pull while in output mode" -msgstr "Zài shūchū móshì xià wúfǎ huòqǔ lādòng" +msgstr "Zài shūchū móshì xià wúfǎ huòqǔ shànglā huò xiàlā zhuàngtài" #: ports/nrf/common-hal/microcontroller/Processor.c msgid "Cannot get temperature" @@ -919,10 +931,12 @@ msgstr "Shùjù 0 de yǐn jiǎo bìxū shì zì jié duìqí" msgid "Data chunk must follow fmt chunk" msgstr "Shùjù kuài bìxū zūnxún fmt qū kuài" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data not supported with directed advertising" msgstr "bù zhī chí dìng xiàng guǎng gào de shù jù" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data too large for advertisement packet" msgstr "Guǎnggào bāo de shùjù tài dà" @@ -1004,6 +1018,7 @@ msgstr "yù qī yǒu jǐng bào" msgid "Expected tuple of length %d, got %d" msgstr "Qīwàng de chángdù wèi %d de yuán zǔ, dédào %d" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Extended advertisements with scan response not supported." msgstr "Bù zhīchí dài yǒu sǎomiáo xiǎngyìng de kuòzhǎn guǎngbò." @@ -1057,6 +1072,7 @@ msgstr "Wúfǎ fēnpèi wifi sǎomiáo nèicún" msgid "Failed to buffer the sample" msgstr "wèi néng huǎn chōng yàng běn" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Failed to connect: internal error" msgstr "Liánjiē shībài: Nèibù cuòwù" @@ -1139,6 +1155,13 @@ msgstr "tōng yòng gù zhàng" msgid "Group already used" msgstr "Jítuán yǐjīng shǐyòngguò" +#: ports/atmel-samd/common-hal/busio/SPI.c ports/cxd56/common-hal/busio/SPI.c +#: ports/espressif/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/nrf/common-hal/busio/SPI.c +#: ports/raspberrypi/common-hal/busio/SPI.c +msgid "Half duplex SPI is not implemented" +msgstr "wèi shí xiàn bàn shuāng gōng SPI" + #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/I2C.c #: ports/stm/common-hal/busio/SPI.c ports/stm/common-hal/canio/CAN.c #: ports/stm/common-hal/sdioio/SDCard.c @@ -1254,7 +1277,7 @@ msgstr "Jiāmì bùzú" #: ports/espressif/common-hal/wifi/Radio.c msgid "Interface must be started" -msgstr "" +msgstr "jiē kǒu bì xū qǐ dòng" #: ports/atmel-samd/audio_dma.c ports/raspberrypi/audio_dma.c msgid "Internal audio buffer too small" @@ -1298,6 +1321,7 @@ msgstr "Wúxiào de ADC dānwèi zhí" msgid "Invalid AuthMode" msgstr "wú xiào AuthMode" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c msgid "Invalid BLE parameter" msgstr "wú xiào BLE cān shù" @@ -1317,7 +1341,7 @@ msgstr "Tí gōng liǎo wúxiào de DAC yǐn jiǎo" #: shared-bindings/wifi/Radio.c msgid "Invalid MAC address" -msgstr "" +msgstr "wú xiào de MAC dì zhǐ" #: shared-bindings/synthio/__init__.c msgid "Invalid MIDI file" @@ -1392,9 +1416,13 @@ msgstr "Géshì kuài dàxiǎo wúxiào" msgid "Invalid memory access." msgstr "Wúxiào de nèicún fǎngwèn." +#: extmod/vfs_fat_file.c +msgid "Invalid mode" +msgstr "wú xiào mó shì" + #: ports/espressif/common-hal/wifi/Radio.c msgid "Invalid multicast MAC address" -msgstr "" +msgstr "wú xiào de duō bō MAC dì zhǐ" #: shared-bindings/bitbangio/SPI.c shared-bindings/busio/SPI.c msgid "Invalid number of bits" @@ -1492,9 +1520,9 @@ msgstr "Wúxiào de zì/wèi chángdù" msgid "Key must be 16, 24, or 32 bytes long" msgstr "mì yào bì xū wéi 16, 24 huò 32 zì jié cháng" -#: shared-module/is31fl3741/is31fl3741.c +#: shared-module/is31fl3741/FrameBuffer.c msgid "LED mappings must match display size" -msgstr "" +msgstr "LED yìng shè bì xū yǔ xiǎn shì píng chǐ cùn pǐ pèi" #: py/compile.c msgid "LHS of keyword arg must be an id" @@ -1520,6 +1548,10 @@ msgstr "MISO yǐn jiǎo chūshǐhuà shībài." msgid "MOSI pin init failed." msgstr "MOSI yǐn jiǎo shūrù shībài." +#: shared-bindings/is31fl3741/IS31FL3741.c +msgid "Mapping must be a tuple" +msgstr "yìng shè bì xū shì yuán zǔ" + #: shared-module/displayio/Shape.c #, c-format msgid "Maximum x value when mirrored is %d" @@ -1603,6 +1635,10 @@ msgstr "NVS cuò wù" msgid "Name too long" msgstr "Míngchēng tài zhǎng" +#: ports/espressif/common-hal/_bleio/__init__.c +msgid "Nimble out of memory" +msgstr "líng huó de bǎi tuō jì yì" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "Zhège tèzhēng méiyǒu CCCD" @@ -1623,10 +1659,10 @@ msgstr "Wèi zhǎodào DMA píndào" msgid "No DMA pacing timer found" msgstr "wèi zhǎo dào DMA qǐ bó qì" -#: shared-module/adafruit_bus_device/I2CDevice.c +#: shared-module/adafruit_bus_device/i2c_device/I2CDevice.c #, c-format -msgid "No I2C device at address: %x" -msgstr "dì zhǐ wú I2C shè bèi: %x" +msgid "No I2C device at address: 0x%x" +msgstr "dì zhǐ: 0x%x shí méi yǒu I2C qì jiàn" #: ports/espressif/common-hal/busio/SPI.c #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c @@ -1750,6 +1786,7 @@ msgstr "běi ōu xì tǒng gù jiàn chū nèi cún" msgid "Not a valid IP string" msgstr "Wúxiào de IP zìfú chuàn" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -1929,7 +1966,7 @@ msgstr "Pin méiyǒu ADC nénglì" msgid "Pin interrupt already in use" msgstr "yǐn jiǎo zhōng duàn yǐ zài shǐ yòng zhōng" -#: shared-bindings/adafruit_bus_device/SPIDevice.c +#: shared-bindings/adafruit_bus_device/spi_device/SPIDevice.c #: shared-bindings/digitalio/DigitalInOut.c msgid "Pin is input only" msgstr "Yǐn jiǎo jǐn shūrù" @@ -2016,6 +2053,10 @@ msgstr "Fāngxiàng shūchū shí Pull méiyǒu shǐyòng." msgid "RAISE mode is not implemented" msgstr "wèi shí xiàn tí shēng mó shì" +#: ports/raspberrypi/common-hal/countio/Counter.c +msgid "RISE_AND_FALL not available on this chip" +msgstr "RISE_AND_FALL zài cǐ xīn piàn shàng bù kě yòng" + #: ports/stm/common-hal/os/__init__.c msgid "RNG DeInit Error" msgstr "RNG qǔxiāo chūshǐhuà cuòwù" @@ -2132,10 +2173,11 @@ msgstr "Cǎiyàng lǜ bìxū wèi zhèng shù" msgid "Sample rate too high. It must be less than %d" msgstr "Cǎiyàng lǜ tài gāo. Tā bìxū xiǎoyú %d" -#: shared-bindings/is31fl3741/is31fl3741.c +#: shared-bindings/is31fl3741/FrameBuffer.c msgid "Scale dimensions must divide by 3" -msgstr "" +msgstr "bǐ lì chǐ cùn bì xū chú yǐ 3" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Scan already in progess. Stop with stop_scan." msgstr "Zhèngzài jìn háng sǎomiáo. Shǐyòng stop_scan tíngzhǐ." @@ -2303,6 +2345,7 @@ msgstr "Píng pū kuāndù bìxū huàfēn wèi tú kuāndù" msgid "Time is in the past." msgstr "shí jiān yǐ jīng guò qù." +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2325,6 +2368,7 @@ msgstr "Xiǎnshì zǒngxiàn tài duōle" msgid "Too many displays" msgstr "Xiǎnshì tài duō" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Total data to write is larger than %q" msgstr "yào biān xiě de zǒng shù jù dà yú %q" @@ -2402,7 +2446,7 @@ msgstr "Wúfǎ fēnpèi huǎnchōng qū yòng yú qiānmíng zhuǎnhuàn" msgid "Unable to create lock" msgstr "Wúfǎ chuàngjiàn suǒ" -#: shared-module/displayio/I2CDisplay.c shared-module/is31fl3741/is31fl3741.c +#: shared-module/displayio/I2CDisplay.c shared-module/is31fl3741/IS31FL3741.c #, c-format msgid "Unable to find I2C Display at %x" msgstr "Wúfǎ zài%x zhǎodào I2C xiǎnshìqì" @@ -2437,6 +2481,16 @@ msgstr "Yìwài de nrfx uuid lèixíng" msgid "Unhandled ESP TLS error %d %d %x %d" msgstr "Wèi chǔlǐ de ESP TLS cuòwù %d %d %x %d" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown BLE error at %s:%d: %d" +msgstr "" + +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown BLE error: %d" +msgstr "" + #: shared-bindings/wifi/Radio.c #, c-format msgid "Unknown failure %d" @@ -2456,11 +2510,21 @@ msgstr "Yuányīn bùmíng." msgid "Unknown security error: 0x%04x" msgstr "Wèizhī de ānquán cuòwù: 0x%04x" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error at %s:%d: %d" +msgstr "%s:%d: %d shí chū xiàn wèi zhī xì tǒng gù jiàn cuò wù" + #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown system firmware error: %04x" msgstr "wèi zhī xì tǒng gù jiàn cuò wù: %04x" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error: %d" +msgstr "wèi zhī de xì tǒng gù jiàn cuò wù: %d" + #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #, c-format msgid "Unmatched number of items on RHS (expected %d, got %d)." @@ -2496,19 +2560,19 @@ msgstr "Bù zhīchí de géshì" msgid "Unsupported operation" msgstr "Bù zhīchí de cāozuò" -#: shared-bindings/digitalio/DigitalInOut.c -msgid "Unsupported pull value." -msgstr "Bù zhīchí de lādòng zhí." - #: ports/espressif/common-hal/dualbank/__init__.c msgid "Update Failed" msgstr "gēng xīn shī bài" +#: ports/espressif/common-hal/_bleio/Characteristic.c +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length != required fixed length" msgstr "Zhí chángdù != Suǒ xū de gùdìng chángdù" +#: ports/espressif/common-hal/_bleio/Characteristic.c +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length > max_length" @@ -2572,6 +2636,7 @@ msgstr "WiFi mìmǎ bìxū jiè yú 8 dào 63 gè zìfú zhī jiān" msgid "Woken up by alarm.\n" msgstr "bèi jǐng bào chǎo xǐng.\n" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Writes not supported on Characteristic" msgstr "Tèzhēng bù zhīchí xiě rù" @@ -2677,7 +2742,7 @@ msgstr "chángshì huòqǔ kōng xùliè de argmin/ argmax" msgid "attributes not supported yet" msgstr "shǔxìng shàngwèi zhīchí" -#: extmod/ulab/code/numpy/numerical.c +#: extmod/ulab/code/ulab_tools.c msgid "axis is out of bounds" msgstr "zhóu chāo chū biān jiè" @@ -2733,11 +2798,11 @@ msgstr "měi jiàn yàngběn bìxū wèi 8 huò 16" msgid "branch not in range" msgstr "fēnzhī bùzài fànwéi nèi" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/utils/utils.c msgid "buffer is smaller than requested size" msgstr "huǎn chōng qū xiǎo yú qǐng qiú de dà xiǎo" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/utils/utils.c msgid "buffer size must be a multiple of element size" msgstr "huǎn chōng qū dà xiǎo bì xū shì yuán sù dà xiǎo de bèi shù" @@ -2787,6 +2852,10 @@ msgstr "jiàozhǔn zhǐ dú dào" msgid "calibration value out of range +/-127" msgstr "jiàozhǔn zhí chāochū fànwéi +/-127" +#: shared-module/vectorio/Rectangle.c +msgid "can only be registered in one parent" +msgstr "zhǐ néng zài yí gè jiā zhǎng zhōng zhù cè" + #: py/emitinlinethumb.c msgid "can only have up to 4 parameters to Thumb assembly" msgstr "zhǐyǒu Thumb zǔjiàn zuìduō 4 cānshù" @@ -2825,6 +2894,10 @@ msgstr "wúfǎ zhuǎnhuàn%s dào fùzá" msgid "can't convert '%q' object to %q implicitly" msgstr "wúfǎ jiāng '%q' duìxiàng zhuǎnhuàn wèi %q yǐn hán" +#: extmod/ulab/code/numpy/vector.c +msgid "can't convert complex to float" +msgstr "wú fǎ jiāng fù zá zhuǎn huàn wéi fú dòng" + #: py/obj.c msgid "can't convert to %q" msgstr "wúfǎ zhuǎnhuàn wèi %q" @@ -2877,6 +2950,10 @@ msgstr "wúfǎ cóng '%q' jiāzài" msgid "can't load with '%q' index" msgstr "wúfǎ yòng '%q' ' suǒyǐn jiāzài" +#: py/builtinimport.c +msgid "can't perform relative import" +msgstr "" + #: py/objgenerator.c msgid "can't send non-None value to a just-started generator" msgstr "wúfǎ xiàng gānggāng qǐdòng de shēngchéng qì fāsòng fēi zhí" @@ -2920,6 +2997,14 @@ msgid "cannot cast output with casting rule" msgstr "" "wú fǎ shǐ yòng qiáng zhì zhuǎn huàn guī zé qiáng zhì zhuǎn huàn shū chū" +#: extmod/ulab/code/ndarray.c +msgid "cannot convert complex to dtype" +msgstr "wú fǎ jiāng fù zá zhuǎn huàn wéi dtype" + +#: extmod/ulab/code/ndarray.c +msgid "cannot convert complex type" +msgstr "wú fǎ zhuǎn huàn fù zá lèi xíng" + #: py/objtype.c msgid "cannot create '%q' instances" msgstr "wúfǎ chuàngjiàn '%q' ' shílì" @@ -2932,10 +3017,6 @@ msgstr "wúfǎ chuàngjiàn shílì" msgid "cannot import name %q" msgstr "wúfǎ dǎorù míngchēng %q" -#: py/builtinimport.c -msgid "cannot perform relative import" -msgstr "wúfǎ zhíxíng xiāngguān dǎorù" - #: extmod/moductypes.c msgid "cannot unambiguously get sizeof scalar" msgstr "bù néng háo bù hán hu de dé dào dà xiǎo de lín" @@ -3116,6 +3197,10 @@ msgstr "bèi líng chú" msgid "divisor must be 4" msgstr "èr chóng zòu bì xū shì 4" +#: extmod/ulab/code/numpy/vector.c +msgid "dtype must be float, or complex" +msgstr "dtype bì xū shì fú diǎn xíng huò fù shù" + #: py/objdeque.c msgid "empty" msgstr "kòngxián" @@ -3219,7 +3304,7 @@ msgstr "dì yī gè cānshù bìxū shì kě tiáo yòng de" msgid "first argument must be a function" msgstr "dì yīgè cānshù bìxū shì yī gè hánshù" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "first argument must be a tuple of ndarrays" msgstr "dì yī gè cān shù bì xū shì yí gè yuán zǔ ndarrays" @@ -3284,6 +3369,10 @@ msgstr "hánshù zài jiàngé mòwěi jùyǒu xiāngtóng de fúhào" msgid "function is defined for ndarrays only" msgstr "hán shù jǐn wéi ndarrays dìng yì" +#: extmod/ulab/code/numpy/carray/carray.c +msgid "function is implemented for ndarrays only" +msgstr "hán shù jǐn zhēn duì ndarray shí xiàn" + #: py/argcheck.c #, c-format msgid "function missing %d required positional arguments" @@ -3397,7 +3486,7 @@ msgstr "nèi lián jíhé bìxū shì yīgè hánshù" msgid "input and output shapes are not compatible" msgstr "shū rù hé shū chū xíng zhuàng bù jiān róng" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "input argument must be an integer, a tuple, or a list" msgstr "shū rù cān shù bì xū shì zhěng shù, yuán zǔ huò liè biǎo" @@ -3405,7 +3494,7 @@ msgstr "shū rù cān shù bì xū shì zhěng shù, yuán zǔ huò liè biǎo" msgid "input array length must be power of 2" msgstr "shūrù shùzǔ de chángdù bìxū shì 2 de mì" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "input arrays are not compatible" msgstr "shū rù shù zǔ bù jiān róng" @@ -3413,6 +3502,10 @@ msgstr "shū rù shù zǔ bù jiān róng" msgid "input data must be an iterable" msgstr "shūrù shùjù bìxū shì kě diédài de" +#: extmod/ulab/code/numpy/vector.c +msgid "input dtype must be float or complex" +msgstr "shū rù dtype bì xū shì fú diǎn xíng huò fù shù" + #: extmod/ulab/code/numpy/linalg/linalg.c msgid "input matrix is asymmetric" msgstr "shūrù jǔzhèn bù duìchèn" @@ -3422,18 +3515,26 @@ msgstr "shūrù jǔzhèn bù duìchèn" msgid "input matrix is singular" msgstr "shūrù jǔzhèn shì qíyì de" +#: extmod/ulab/code/numpy/carray/carray.c +msgid "input must be a 1D ndarray" +msgstr "shū rù bì xū shì 1D ndarray" + #: extmod/ulab/code/scipy/linalg/linalg.c extmod/ulab/code/user/user.c msgid "input must be a dense ndarray" msgstr "shū rù bì xū shì mì jí de ndarray" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "input must be a tensor of rank 2" msgstr "shū rù bì xū shì děng jí 2 de zhāng liàng" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/user/user.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/user/user.c msgid "input must be an ndarray" msgstr "shū rù bì xū shì ndarray" +#: extmod/ulab/code/numpy/carray/carray.c +msgid "input must be an ndarray, or a scalar" +msgstr "shū rù bì xū shì ndarray huò biāo liàng" + #: extmod/ulab/code/scipy/signal/signal.c msgid "input must be one-dimensional" msgstr "shū rù bì xū shì yì wéi de" @@ -3612,6 +3713,11 @@ msgstr "shùxué yù cuòwù" msgid "matrix is not positive definite" msgstr "jǔzhèn bùshì zhèngdìng de" +#: ports/espressif/common-hal/wifi/Radio.c +msgid "max_connections must be between 0 and 10" +msgstr "" + +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c #, c-format @@ -3765,6 +3871,7 @@ msgstr "méiyǒu cǐ shǔxìng" msgid "non-Device in %q" msgstr "fēi shè bèi zài %q" +#: ports/espressif/common-hal/_bleio/Connection.c #: ports/nrf/common-hal/_bleio/Connection.c msgid "non-UUID found in service_uuids_whitelist" msgstr "Zài service_uuids bái míngdān zhōng zhǎodào fēi UUID" @@ -3805,7 +3912,11 @@ msgstr "bùshì zì chuàn géshì huà guòchéng zhōng zhuǎnhuàn de suǒyǒ msgid "not enough arguments for format string" msgstr "géshì zìfú chuàn cān shǔ bùzú" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/carray/carray_tools.c +msgid "not implemented for complex dtype" +msgstr "wèi zhēn duì fù zá de dtype shí xiàn" + +#: extmod/ulab/code/numpy/create.c msgid "number of points must be at least 2" msgstr "diǎnshù bìxū zhìshǎo wèi 2" @@ -3863,7 +3974,7 @@ msgstr "xūyào huǎnchōng qū xiéyì de duìxiàng" msgid "odd-length string" msgstr "jīshù zìfú chuàn" -#: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c +#: extmod/ulab/code/numpy/create.c extmod/ulab/code/utils/utils.c msgid "offset is too large" msgstr "piān yí tài dà" @@ -3871,7 +3982,7 @@ msgstr "piān yí tài dà" msgid "offset must be >= 0" msgstr "piān yí liàng bì xū >= 0" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "offset must be non-negative and no greater than buffer length" msgstr "piān yí liàng bì xū wéi fēi fù shù qiě bù dà yú huǎn chōng qū cháng dù" @@ -3983,6 +4094,10 @@ msgstr "xiàngsù zhí xūyào tài duō wèi" msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter" msgstr "pixel_shader bìxū shì displayio.Palette huò displayio.ColorConverter" +#: extmod/vfs_posix_file.c +msgid "poll on file not available on win32" +msgstr "" + #: shared-module/vectorio/Polygon.c msgid "polygon can only be registered in one parent" msgstr "duōbiānxíng zhī néng zài yīgè fù jí zhōng zhùcè" @@ -4012,18 +4127,27 @@ msgstr "pow() 3 cān shǔ bùnéng wéi 0" msgid "pow() with 3 arguments requires integers" msgstr "pow() yǒu 3 cānshù xūyào zhěngshù" +#: ports/espressif/boards/adafruit_esp32s2_camera/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tft/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h #: ports/espressif/boards/adafruit_funhouse/mpconfigboard.h #: ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h +#: ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h +#: ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h #: ports/espressif/boards/atmegazero_esp32s2/mpconfigboard.h #: ports/espressif/boards/crumpspace_crumps2/mpconfigboard.h #: ports/espressif/boards/electroniccats_bastwifi/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s2_devkitc_1_n4r2/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_box/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h #: ports/espressif/boards/espressif_hmi_devkit_1/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1.3/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1/mpconfigboard.h @@ -4049,7 +4173,10 @@ msgstr "pow() yǒu 3 cānshù xūyào zhěngshù" #: ports/espressif/boards/unexpectedmaker_feathers2/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_neo/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_prerelease/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_feathers3/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_pros3/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_tinys2/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_tinys3/mpconfigboard.h msgid "pressing boot button at start up.\n" msgstr "Zài qǐdòng shí àn qǐdòng ànniǔ.\n" @@ -4238,7 +4365,7 @@ msgstr "yuán wèi tú (source_bitmap) de zhí de shù mù (value_count) bì xū #: shared-bindings/wifi/Radio.c msgid "ssid can't be more than 32 bytes" -msgstr "" +msgstr "ssid bù néng chāo guò 32 gè zì jié" #: py/objstr.c msgid "start/end indices" @@ -4351,7 +4478,7 @@ msgstr "tobytes zhǐ néng duì mì jí shù zǔ diào yòng" msgid "too many arguments provided with the given format" msgstr "tígōng jǐ dìng géshì de cānshù tài duō" -#: extmod/ulab/code/ndarray.c extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/ndarray.c extmod/ulab/code/numpy/create.c msgid "too many dimensions" msgstr "chǐ cùn tài duō" @@ -4535,7 +4662,7 @@ msgstr "kān mén gǒu chāoshí bìxū dàyú 0" msgid "width must be from 2 to 8 (inclusive), not %d" msgstr "kuān dù bì xū cóng 2 dào 8 ( hán ), ér bù shì %d" -#: shared-bindings/is31fl3741/is31fl3741.c +#: shared-bindings/is31fl3741/FrameBuffer.c #: shared-bindings/rgbmatrix/RGBMatrix.c msgid "width must be greater than zero" msgstr "kuāndù bìxū dàyú líng" @@ -4552,7 +4679,7 @@ msgstr "Chuāngkǒu bìxū shì <= jiàngé" msgid "wrong axis index" msgstr "cuò wù de zhóu suǒ yǐn" -#: extmod/ulab/code/ulab_create.c +#: extmod/ulab/code/numpy/create.c msgid "wrong axis specified" msgstr "zhǐ dìng de zhóu cuò wù" @@ -4560,7 +4687,11 @@ msgstr "zhǐ dìng de zhóu cuò wù" msgid "wrong input type" msgstr "shūrù lèixíng cuòwù" -#: extmod/ulab/code/ulab_create.c py/objarray.c py/objstr.c +#: extmod/ulab/code/numpy/transform.c +msgid "wrong length of condition array" +msgstr "tiáo jiàn shù zǔ de cháng dù cuò wù" + +#: extmod/ulab/code/numpy/create.c py/objarray.c py/objstr.c msgid "wrong number of arguments" msgstr "cānshù shù cuòwù" @@ -4604,6 +4735,16 @@ msgstr "zi bìxū wèi fú diǎn xíng" msgid "zi must be of shape (n_section, 2)" msgstr "zi bìxū jùyǒu xíngzhuàng (n_section,2)" +#~ msgid "cannot perform relative import" +#~ msgstr "wúfǎ zhíxíng xiāngguān dǎorù" + +#, c-format +#~ msgid "No I2C device at address: %x" +#~ msgstr "dì zhǐ wú I2C shè bèi: %x" + +#~ msgid "Unsupported pull value." +#~ msgstr "Bù zhīchí de lādòng zhí." + #~ msgid "%q must <= %d" #~ msgstr "%q bì xū <= %d" diff --git a/main.c b/main.c index b1b482f985..9bfdb37cc1 100644 --- a/main.c +++ b/main.c @@ -56,6 +56,7 @@ #include "supervisor/shared/safe_mode.h" #include "supervisor/shared/stack.h" #include "supervisor/shared/status_leds.h" +#include "supervisor/shared/tick.h" #include "supervisor/shared/traceback.h" #include "supervisor/shared/translate.h" #include "supervisor/shared/workflow.h" @@ -122,7 +123,7 @@ static void reset_devices(void) { #endif } -STATIC void start_mp(supervisor_allocation *heap) { +STATIC void start_mp(supervisor_allocation *heap, bool first_run) { autoreload_stop(); supervisor_workflow_reset(); @@ -161,16 +162,17 @@ STATIC void start_mp(supervisor_allocation *heap) { mp_obj_list_init((mp_obj_list_t *)mp_sys_path, 0); mp_obj_list_append(mp_sys_path, MP_OBJ_NEW_QSTR(MP_QSTR_)); // current dir (or base dir of the script) mp_obj_list_append(mp_sys_path, MP_OBJ_NEW_QSTR(MP_QSTR__slash_)); - // Frozen modules are in their own pseudo-dir, e.g., ".frozen". - // Prioritize .frozen over /lib. - mp_obj_list_append(mp_sys_path, MP_OBJ_NEW_QSTR(MP_FROZEN_FAKE_DIR_QSTR)); + #if MICROPY_MODULE_FROZEN + mp_obj_list_append(mp_sys_path, MP_OBJ_NEW_QSTR(MP_QSTR__dot_frozen)); + #endif mp_obj_list_append(mp_sys_path, MP_OBJ_NEW_QSTR(MP_QSTR__slash_lib)); mp_obj_list_init((mp_obj_list_t *)mp_sys_argv, 0); #if CIRCUITPY_ALARM // Record which alarm woke us up, if any. An object may be created so the heap must be functional. - shared_alarm_save_wake_alarm(common_hal_alarm_create_wake_alarm()); + // There is no alarm if this is not the first time code.py or the REPL has been run. + shared_alarm_save_wake_alarm(first_run ? common_hal_alarm_create_wake_alarm() : mp_const_none); // Reset alarm module only after we retrieved the wakeup alarm. alarm_reset(); #endif @@ -288,10 +290,10 @@ STATIC void cleanup_after_vm(supervisor_allocation *heap, mp_obj_t exception) { keypad_reset(); #endif - // reset_board_busses() first because it may release pins from the never_reset state, so that + // reset_board_buses() first because it may release pins from the never_reset state, so that // reset_port() can reset them. #if CIRCUITPY_BOARD - reset_board_busses(); + reset_board_buses(); #endif reset_port(); reset_board(); @@ -299,7 +301,8 @@ STATIC void cleanup_after_vm(supervisor_allocation *heap, mp_obj_t exception) { STATIC void print_code_py_status_message(safe_mode_t safe_mode) { if (autoreload_is_enabled()) { - serial_write_compressed(translate("Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.\n")); + serial_write_compressed( + translate("Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.\n")); } else { serial_write_compressed(translate("Auto-reload is off.\n")); } @@ -308,7 +311,7 @@ STATIC void print_code_py_status_message(safe_mode_t safe_mode) { } } -STATIC bool run_code_py(safe_mode_t safe_mode) { +STATIC bool run_code_py(safe_mode_t safe_mode, bool first_run, bool *simulate_reset) { bool serial_connected_at_start = serial_connected(); bool printed_safe_mode_message = false; #if CIRCUITPY_AUTORELOAD_DELAY_MS > 0 @@ -347,7 +350,7 @@ STATIC bool run_code_py(safe_mode_t safe_mode) { supervisor_allocation *heap = allocate_remaining_memory(); // Prepare the VM state. Includes an alarm check/reset for sleep. - start_mp(heap); + start_mp(heap, first_run); #if CIRCUITPY_USB usb_setup_with_vm(); @@ -399,7 +402,8 @@ STATIC bool run_code_py(safe_mode_t safe_mode) { // the options because it can be treated like any other reason-for-stickiness bit. The // source is different though: it comes from the options that will apply to the next run, // while the rest of next_code_options is what applied to this run. - if (next_code_allocation != NULL && (((next_code_info_t *)next_code_allocation->ptr)->options & SUPERVISOR_NEXT_CODE_OPT_NEWLY_SET)) { + if (next_code_allocation != NULL && + (((next_code_info_t *)next_code_allocation->ptr)->options & SUPERVISOR_NEXT_CODE_OPT_NEWLY_SET)) { next_code_options |= SUPERVISOR_NEXT_CODE_OPT_NEWLY_SET; } @@ -525,9 +529,9 @@ STATIC bool run_code_py(safe_mode_t safe_mode) { // Sleep until our next interrupt. #if CIRCUITPY_ALARM if (result.return_code & PYEXEC_DEEP_SLEEP) { - // Make sure we have been awake long enough for USB to connect (enumeration delay). - int64_t connecting_delay_ticks = CIRCUITPY_USB_CONNECTED_SLEEP_DELAY * 1024 - port_get_raw_ticks(NULL); - // Until it's safe to decide whether we're real/fake sleeping + const bool awoke_from_true_deep_sleep = + common_hal_mcu_processor_get_reset_reason() == RESET_REASON_DEEP_SLEEP_ALARM; + if (fake_sleeping) { // This waits until a pretend deep sleep alarm occurs. They are set // during common_hal_alarm_set_deep_sleep_alarms. On some platforms @@ -535,18 +539,28 @@ STATIC bool run_code_py(safe_mode_t safe_mode) { // for deep sleep alarms above. If it wasn't a deep sleep alarm, // then we'll idle here again. common_hal_alarm_pretending_deep_sleep(); - } else if (connecting_delay_ticks < 0) { - // Entering deep sleep (may be fake or real.) + } + // The first time we go into a deep sleep, make sure we have been awake long enough + // for USB to connect (enumeration delay), or for the BLE workflow to start. + // We wait CIRCUITPY_WORKFLOW_CONNECTION_SLEEP_DELAY seconds after a restart. + // But if we woke up from a real deep sleep, don't wait for connection. The user will need to + // do a hard reset to get out of the real deep sleep. + else if (awoke_from_true_deep_sleep || + port_get_raw_ticks(NULL) > CIRCUITPY_WORKFLOW_CONNECTION_SLEEP_DELAY * 1024) { + // OK to start sleeping, real or fake. status_led_deinit(); deinit_rxtx_leds(); board_deinit(); - if (!supervisor_workflow_active()) { + + // Continue with true deep sleep even if workflow is available. + if (awoke_from_true_deep_sleep || !supervisor_workflow_active()) { // Enter true deep sleep. When we wake up we'll be back at the // top of main(), not in this loop. common_hal_alarm_enter_deep_sleep(); // Does not return. } else { - serial_write_compressed(translate("Pretending to deep sleep until alarm, CTRL-C or file write.\n")); + serial_write_compressed( + translate("Pretending to deep sleep until alarm, CTRL-C or file write.\n")); fake_sleeping = true; } } else { @@ -630,6 +644,8 @@ STATIC bool run_code_py(safe_mode_t safe_mode) { #if CIRCUITPY_ALARM if (fake_sleeping) { board_init(); + // Pretend that the next run is the first run, as if we were reset. + *simulate_reset = true; } #endif @@ -651,7 +667,9 @@ STATIC void __attribute__ ((noinline)) run_boot_py(safe_mode_t safe_mode) { // Do USB setup even if boot.py is not run. supervisor_allocation *heap = allocate_remaining_memory(); - start_mp(heap); + + // true means this is the first set of VM's after a hard reset. + start_mp(heap, true); #if CIRCUITPY_USB // Set up default USB values after boot.py VM starts but before running boot.py. @@ -728,12 +746,12 @@ STATIC void __attribute__ ((noinline)) run_boot_py(safe_mode_t safe_mode) { #endif } -STATIC int run_repl(void) { +STATIC int run_repl(bool first_run) { int exit_code = PYEXEC_FORCED_EXIT; stack_resize(); filesystem_flush(); supervisor_allocation *heap = allocate_remaining_memory(); - start_mp(heap); + start_mp(heap, first_run); #if CIRCUITPY_USB usb_setup_with_vm(); @@ -805,7 +823,12 @@ int __attribute__((used)) main(void) { // Create a new filesystem only if we're not in a safe mode. // A power brownout here could make it appear as if there's // no SPI flash filesystem, and we might erase the existing one. - filesystem_init(safe_mode == NO_SAFE_MODE, false); + + // Check whether CIRCUITPY is available. No need to reset to get safe mode + // since we haven't run user code yet. + if (!filesystem_init(safe_mode == NO_SAFE_MODE, false)) { + safe_mode = NO_CIRCUITPY; + } // displays init after filesystem, since they could share the flash SPI board_init(); @@ -827,7 +850,7 @@ int __attribute__((used)) main(void) { // By default our internal flash is readonly to local python code and // writable over USB. Set it here so that boot.py can change it. filesystem_set_internal_concurrent_write_protection(true); - filesystem_set_internal_writable_by_usb(true); + filesystem_set_internal_writable_by_usb(CIRCUITPY_USB == 1); run_boot_py(safe_mode); @@ -846,28 +869,34 @@ int __attribute__((used)) main(void) { supervisor_start_bluetooth(); #endif - // Boot script is finished, so now go into REPL/main mode. + // Boot script is finished, so now go into REPL or run code.py. int exit_code = PYEXEC_FORCED_EXIT; bool skip_repl = true; bool first_run = true; + bool simulate_reset; for (;;) { + simulate_reset = false; if (!skip_repl) { - exit_code = run_repl(); + exit_code = run_repl(first_run); supervisor_set_run_reason(RUN_REASON_REPL_RELOAD); } if (exit_code == PYEXEC_FORCED_EXIT) { if (!first_run) { serial_write_compressed(translate("soft reboot\n")); } - first_run = false; if (pyexec_mode_kind == PYEXEC_MODE_FRIENDLY_REPL) { - skip_repl = run_code_py(safe_mode); + skip_repl = run_code_py(safe_mode, first_run, &simulate_reset); } else { skip_repl = false; } } else if (exit_code != 0) { break; } + + // Either the REPL or code.py has run and finished. + // If code.py did a fake deep sleep, pretend that we are running code.py for + // the first time after a hard reset. This will preserve any alarm information. + first_run = simulate_reset; } mp_deinit(); return 0; diff --git a/mpy-cross/README.md b/mpy-cross/README.md index 60f9c593c7..3d88814d64 100644 --- a/mpy-cross/README.md +++ b/mpy-cross/README.md @@ -23,10 +23,7 @@ by the target MicroPython runtime (eg onto a pyboard's filesystem), and then imported like any other Python module using `import foo`. Different target runtimes may require a different format of the compiled -bytecode, and such options can be passed to the cross compiler. For example, -the unix port of MicroPython requires the following: - - $ ./mpy-cross -mcache-lookup-bc foo.py +bytecode, and such options can be passed to the cross compiler. If the Python code contains `@native` or `@viper` annotations, then you must specify `-march` to match the target architecture. diff --git a/mpy-cross/main.c b/mpy-cross/main.c index c120d6f2db..c00829be10 100644 --- a/mpy-cross/main.c +++ b/mpy-cross/main.c @@ -87,7 +87,6 @@ STATIC int usage(char **argv) { "Target specific options:\n" "-msmall-int-bits=number : set the maximum bits used to encode a small-int\n" "-mno-unicode : don't support unicode in compiled strings\n" - "-mcache-lookup-bc : cache map lookups in the bytecode\n" "-march= : set architecture for native emitter; x86, x64, armv6, armv7m, armv7em, armv7emsp, armv7emdp, xtensa, xtensawin\n" "\n" "Implementation specific options:\n", argv[0] @@ -172,8 +171,6 @@ MP_NOINLINE int main_(int argc, char **argv) { #ifdef _WIN32 set_fmode_binary(); #endif - mp_obj_list_init(mp_sys_path, 0); - mp_obj_list_init(mp_sys_argv, 0); #if MICROPY_EMIT_NATIVE // Set default emitter options @@ -184,7 +181,6 @@ MP_NOINLINE int main_(int argc, char **argv) { // set default compiler configuration mp_dynamic_compiler.small_int_bits = 31; - mp_dynamic_compiler.opt_cache_map_lookup_in_bytecode = 0; mp_dynamic_compiler.py_builtins_str_unicode = 1; #if defined(__i386__) mp_dynamic_compiler.native_arch = MP_NATIVE_ARCH_X86; @@ -243,10 +239,6 @@ MP_NOINLINE int main_(int argc, char **argv) { return usage(argv); } // TODO check that small_int_bits is within range of host's capabilities - } else if (strcmp(argv[a], "-mno-cache-lookup-bc") == 0) { - mp_dynamic_compiler.opt_cache_map_lookup_in_bytecode = 0; - } else if (strcmp(argv[a], "-mcache-lookup-bc") == 0) { - mp_dynamic_compiler.opt_cache_map_lookup_in_bytecode = 1; } else if (strcmp(argv[a], "-mno-unicode") == 0) { mp_dynamic_compiler.py_builtins_str_unicode = 0; } else if (strcmp(argv[a], "-municode") == 0) { diff --git a/mpy-cross/mpconfigport.h b/mpy-cross/mpconfigport.h index 50c77a1186..d91e1d6d6e 100644 --- a/mpy-cross/mpconfigport.h +++ b/mpy-cross/mpconfigport.h @@ -36,8 +36,6 @@ #define MICROPY_COMP_TRIPLE_TUPLE_ASSIGN (1) #define MICROPY_COMP_RETURN_IF_EXPR (1) -#define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE (0) - #define MICROPY_READER_POSIX (1) #define MICROPY_ENABLE_RUNTIME (0) #define MICROPY_ENABLE_GC (1) diff --git a/ports/atmel-samd/boards/aloriumtech_evo_m51/pins.c b/ports/atmel-samd/boards/aloriumtech_evo_m51/pins.c index 35cc41b557..d6a2979d9e 100644 --- a/ports/atmel-samd/boards/aloriumtech_evo_m51/pins.c +++ b/ports/atmel-samd/boards/aloriumtech_evo_m51/pins.c @@ -53,6 +53,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_BATTERY), MP_ROM_PTR(&pin_PB01) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, diff --git a/ports/atmel-samd/boards/arduino_mkr1300/mpconfigboard.mk b/ports/atmel-samd/boards/arduino_mkr1300/mpconfigboard.mk index eda4d4d3e1..c3d75202bf 100644 --- a/ports/atmel-samd/boards/arduino_mkr1300/mpconfigboard.mk +++ b/ports/atmel-samd/boards/arduino_mkr1300/mpconfigboard.mk @@ -9,5 +9,3 @@ CHIP_FAMILY = samd21 INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE CIRCUITPY_FULL_BUILD = 0 - -CIRCUITPY_ONEWIREIO = 0 diff --git a/ports/atmel-samd/boards/arduino_nano_33_iot/mpconfigboard.mk b/ports/atmel-samd/boards/arduino_nano_33_iot/mpconfigboard.mk index 7fe396d698..38b1e96d6b 100644 --- a/ports/atmel-samd/boards/arduino_nano_33_iot/mpconfigboard.mk +++ b/ports/atmel-samd/boards/arduino_nano_33_iot/mpconfigboard.mk @@ -10,4 +10,5 @@ INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE CIRCUITPY_FULL_BUILD = 0 -CIRCUITPY_ONEWIREIO = 0 +# This board has many pins, and we have to remove something else to make room. +CIRCUITPY_RAINBOWIO = 0 diff --git a/ports/atmel-samd/boards/arduino_zero/mpconfigboard.mk b/ports/atmel-samd/boards/arduino_zero/mpconfigboard.mk index f1c3631dcb..5ee22c59ad 100644 --- a/ports/atmel-samd/boards/arduino_zero/mpconfigboard.mk +++ b/ports/atmel-samd/boards/arduino_zero/mpconfigboard.mk @@ -9,5 +9,3 @@ CHIP_FAMILY = samd21 INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE CIRCUITPY_FULL_BUILD = 0 - -CIRCUITPY_ONEWIREIO = 0 diff --git a/ports/atmel-samd/boards/bdmicro_vina_d51/pins.c b/ports/atmel-samd/boards/bdmicro_vina_d51/pins.c index 3a9dbc929c..925c5a525f 100644 --- a/ports/atmel-samd/boards/bdmicro_vina_d51/pins.c +++ b/ports/atmel-samd/boards/bdmicro_vina_d51/pins.c @@ -85,6 +85,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PA12) }, { MP_ROM_QSTR(MP_QSTR_I2C1_SDA), MP_ROM_PTR(&pin_PA13) }, { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PA13) }, + { MP_ROM_QSTR(MP_QSTR_LED_AUX), MP_ROM_PTR(&pin_PC26) }, { MP_ROM_QSTR(MP_QSTR_LED_B), MP_ROM_PTR(&pin_PA23) }, { MP_ROM_QSTR(MP_QSTR_LED_STATUS), MP_ROM_PTR(&pin_PA23) }, { MP_ROM_QSTR(MP_QSTR_LED_G), MP_ROM_PTR(&pin_PB15) }, diff --git a/ports/atmel-samd/boards/blm_badge/pins.c b/ports/atmel-samd/boards/blm_badge/pins.c index 6da6f0e9db..993abae2b8 100644 --- a/ports/atmel-samd/boards/blm_badge/pins.c +++ b/ports/atmel-samd/boards/blm_badge/pins.c @@ -44,5 +44,6 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_PA03) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, }; MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/atmel-samd/boards/capablerobot_usbhub/mpconfigboard.mk b/ports/atmel-samd/boards/capablerobot_usbhub/mpconfigboard.mk index 42d302b087..388aa6e914 100644 --- a/ports/atmel-samd/boards/capablerobot_usbhub/mpconfigboard.mk +++ b/ports/atmel-samd/boards/capablerobot_usbhub/mpconfigboard.mk @@ -12,3 +12,16 @@ LONGINT_IMPL = MPZ # No I2S on SAMD51G CIRCUITPY_AUDIOBUSIO = 0 + +CIRCUITPY_FULL_BUILD = 0 +CIRCUITPY_AUDIOIO = 0 +CIRCUITPY_AUDIOCORE = 0 +CIRCUITPY_COUNTIO = 0 +CIRCUITPY_ROTARYIO = 0 +CIRCUITPY_TOUCHIO = 0 +CIRCUITPY_SDCARDIO = 0 +CIRCUITPY_NEOPIXEL_WRITE = 0 +CIRCUITPY_PIXELBUF = 0 +CIRCUITPY_GAMEPAD = 0 +CIRCUITPY_USB_HID = 0 +CIRCUITPY_USB_MIDI = 0 diff --git a/ports/atmel-samd/boards/capablerobot_usbhub/pins.c b/ports/atmel-samd/boards/capablerobot_usbhub/pins.c index 02bb347fe0..a2b3c97822 100644 --- a/ports/atmel-samd/boards/capablerobot_usbhub/pins.c +++ b/ports/atmel-samd/boards/capablerobot_usbhub/pins.c @@ -22,6 +22,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_USBHOSTEN), MP_ROM_PTR(&pin_PA07) }, { MP_OBJ_NEW_QSTR(MP_QSTR_USBRESET), MP_ROM_PTR(&pin_PB08) }, { MP_OBJ_NEW_QSTR(MP_QSTR_USBBCEN), MP_ROM_PTR(&pin_PB22) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_PCBREV), MP_ROM_PTR(&pin_PB02) }, { MP_OBJ_NEW_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PA22) }, { MP_OBJ_NEW_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PA23) }, @@ -33,6 +34,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PB23) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, }; diff --git a/ports/atmel-samd/boards/cp32-m4/mpconfigboard.mk b/ports/atmel-samd/boards/cp32-m4/mpconfigboard.mk index dfdde0dbb0..af0129f10f 100644 --- a/ports/atmel-samd/boards/cp32-m4/mpconfigboard.mk +++ b/ports/atmel-samd/boards/cp32-m4/mpconfigboard.mk @@ -8,6 +8,7 @@ CHIP_FAMILY = samd51 QSPI_FLASH_FILESYSTEM = 1 EXTERNAL_FLASH_DEVICES = "W25Q128JVxM" +LONGINT_IMPL = MPZ # No I2S on SAMD51G. CIRCUITPY_AUDIOBUSIO = 0 diff --git a/ports/atmel-samd/boards/cp_sapling_m0/pins.c b/ports/atmel-samd/boards/cp_sapling_m0/pins.c index c830f86aa8..effb33ffe0 100644 --- a/ports/atmel-samd/boards/cp_sapling_m0/pins.c +++ b/ports/atmel-samd/boards/cp_sapling_m0/pins.c @@ -35,6 +35,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_PA15) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, }; MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/atmel-samd/boards/cp_sapling_m0_revb/pins.c b/ports/atmel-samd/boards/cp_sapling_m0_revb/pins.c index 93eefbdf8f..8524648651 100644 --- a/ports/atmel-samd/boards/cp_sapling_m0_revb/pins.c +++ b/ports/atmel-samd/boards/cp_sapling_m0_revb/pins.c @@ -50,6 +50,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_PA15) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, }; diff --git a/ports/atmel-samd/boards/cp_sapling_m0_spiflash/pins.c b/ports/atmel-samd/boards/cp_sapling_m0_spiflash/pins.c index c830f86aa8..effb33ffe0 100644 --- a/ports/atmel-samd/boards/cp_sapling_m0_spiflash/pins.c +++ b/ports/atmel-samd/boards/cp_sapling_m0_spiflash/pins.c @@ -35,6 +35,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_PA15) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, }; MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/atmel-samd/boards/feather_m0_adalogger/mpconfigboard.mk b/ports/atmel-samd/boards/feather_m0_adalogger/mpconfigboard.mk index e17cb8b3a1..62336ecf50 100644 --- a/ports/atmel-samd/boards/feather_m0_adalogger/mpconfigboard.mk +++ b/ports/atmel-samd/boards/feather_m0_adalogger/mpconfigboard.mk @@ -9,5 +9,3 @@ CHIP_FAMILY = samd21 INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE CIRCUITPY_FULL_BUILD = 0 - -CIRCUITPY_ONEWIREIO = 0 diff --git a/ports/atmel-samd/boards/feather_m4_can/mpconfigboard.mk b/ports/atmel-samd/boards/feather_m4_can/mpconfigboard.mk index ecadf211ff..088748a0cc 100644 --- a/ports/atmel-samd/boards/feather_m4_can/mpconfigboard.mk +++ b/ports/atmel-samd/boards/feather_m4_can/mpconfigboard.mk @@ -10,4 +10,5 @@ QSPI_FLASH_FILESYSTEM = 1 EXTERNAL_FLASH_DEVICES = GD25Q16C LONGINT_IMPL = MPZ +CIRCUITPY__EVE = 1 CIRCUITPY_CANIO = 1 diff --git a/ports/atmel-samd/boards/hallowing_m0_express/board.c b/ports/atmel-samd/boards/hallowing_m0_express/board.c index dfa60a5da6..aace060b01 100644 --- a/ports/atmel-samd/boards/hallowing_m0_express/board.c +++ b/ports/atmel-samd/boards/hallowing_m0_express/board.c @@ -71,7 +71,7 @@ uint8_t display_init_sequence[] = { void board_init(void) { displayio_fourwire_obj_t *bus = &displays[0].fourwire_bus; bus->base.type = &displayio_fourwire_type; - busio_spi_obj_t *spi = common_hal_board_create_spi(); + busio_spi_obj_t *spi = common_hal_board_create_spi(0); common_hal_busio_spi_never_reset(spi); common_hal_displayio_fourwire_construct(bus, spi, diff --git a/ports/atmel-samd/boards/hallowing_m0_express/pins.c b/ports/atmel-samd/boards/hallowing_m0_express/pins.c index 842832c392..576936a4aa 100644 --- a/ports/atmel-samd/boards/hallowing_m0_express/pins.c +++ b/ports/atmel-samd/boards/hallowing_m0_express/pins.c @@ -63,6 +63,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_ACCELEROMETER_INTERRUPT), MP_ROM_PTR(&pin_PA14) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, diff --git a/ports/atmel-samd/boards/hallowing_m4_express/board.c b/ports/atmel-samd/boards/hallowing_m4_express/board.c index 1b8623f528..358c326b62 100644 --- a/ports/atmel-samd/boards/hallowing_m4_express/board.c +++ b/ports/atmel-samd/boards/hallowing_m4_express/board.c @@ -48,7 +48,7 @@ uint8_t display_init_sequence[] = { void board_init(void) { busio_spi_obj_t *spi = &displays[0].fourwire_bus.inline_bus; - common_hal_busio_spi_construct(spi, &pin_PA01, &pin_PA00, NULL); + common_hal_busio_spi_construct(spi, &pin_PA01, &pin_PA00, NULL, false); common_hal_busio_spi_never_reset(spi); displayio_fourwire_obj_t *bus = &displays[0].fourwire_bus; diff --git a/ports/atmel-samd/boards/hallowing_m4_express/pins.c b/ports/atmel-samd/boards/hallowing_m4_express/pins.c index 9c5a007be0..105206ba8e 100644 --- a/ports/atmel-samd/boards/hallowing_m4_express/pins.c +++ b/ports/atmel-samd/boards/hallowing_m4_express/pins.c @@ -67,6 +67,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_CAP_PIN), MP_ROM_PTR(&pin_PA15) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, diff --git a/ports/atmel-samd/boards/matrixportal_m4/mpconfigboard.mk b/ports/atmel-samd/boards/matrixportal_m4/mpconfigboard.mk index 41e24f1995..c09005dba3 100644 --- a/ports/atmel-samd/boards/matrixportal_m4/mpconfigboard.mk +++ b/ports/atmel-samd/boards/matrixportal_m4/mpconfigboard.mk @@ -9,3 +9,15 @@ CHIP_FAMILY = samd51 QSPI_FLASH_FILESYSTEM = 1 EXTERNAL_FLASH_DEVICES = "S25FL116K, S25FL216K, GD25Q16C" LONGINT_IMPL = MPZ + +CIRCUITPY_BLEIO = 0 +CIRCUITPY_BLEIO_HCI = 0 +CIRCUITPY_ONEWIREIO = 0 +CIRCUITPY_SDCARDIO = 0 +CIRCUITPY_SHARPDISPLAY = 0 + +# Include these Python libraries in firmware. +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_PortalBase +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Requests +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_ESP32SPI +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel diff --git a/ports/atmel-samd/boards/matrixportal_m4/pins.c b/ports/atmel-samd/boards/matrixportal_m4/pins.c index 09957ba682..205cd6f3c6 100644 --- a/ports/atmel-samd/boards/matrixportal_m4/pins.c +++ b/ports/atmel-samd/boards/matrixportal_m4/pins.c @@ -58,6 +58,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_L),MP_ROM_PTR(&pin_PA14) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, }; diff --git a/ports/atmel-samd/boards/monster_m4sk/board.c b/ports/atmel-samd/boards/monster_m4sk/board.c index 16b2f0b167..e4e5da3ea5 100644 --- a/ports/atmel-samd/boards/monster_m4sk/board.c +++ b/ports/atmel-samd/boards/monster_m4sk/board.c @@ -49,7 +49,7 @@ uint8_t display_init_sequence[] = { void board_init(void) { busio_spi_obj_t *spi = &displays[0].fourwire_bus.inline_bus; - common_hal_busio_spi_construct(spi, &pin_PA13, &pin_PA12, NULL); + common_hal_busio_spi_construct(spi, &pin_PA13, &pin_PA12, NULL, false); common_hal_busio_spi_never_reset(spi); displayio_fourwire_obj_t *bus = &displays[0].fourwire_bus; diff --git a/ports/atmel-samd/boards/monster_m4sk/pins.c b/ports/atmel-samd/boards/monster_m4sk/pins.c index 8de94e2d70..9f5369c574 100644 --- a/ports/atmel-samd/boards/monster_m4sk/pins.c +++ b/ports/atmel-samd/boards/monster_m4sk/pins.c @@ -48,6 +48,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_LEFT_TFT_DC), MP_ROM_PTR(&pin_PB22) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display)}, { MP_ROM_QSTR(MP_QSTR_RIGHT_DISPLAY), MP_ROM_PTR(&displays[0].display)} diff --git a/ports/atmel-samd/boards/openbook_m4/board.c b/ports/atmel-samd/boards/openbook_m4/board.c index 1ff83b95b7..40512b9416 100644 --- a/ports/atmel-samd/boards/openbook_m4/board.c +++ b/ports/atmel-samd/boards/openbook_m4/board.c @@ -54,7 +54,7 @@ uint8_t stop_sequence[] = { void board_init(void) { busio_spi_obj_t *spi = &displays[0].fourwire_bus.inline_bus; - common_hal_busio_spi_construct(spi, &pin_PB13, &pin_PB15, NULL); + common_hal_busio_spi_construct(spi, &pin_PB13, &pin_PB15, NULL, false); common_hal_busio_spi_never_reset(spi); displayio_fourwire_obj_t *bus = &displays[0].fourwire_bus; @@ -98,7 +98,8 @@ void board_init(void) { false, // busy_state 5, // seconds_per_frame false, // chip_select (don't always toggle chip select) - false); // grayscale + false, // grayscale + false); // two_byte_sequence_length } bool board_requests_safe_mode(void) { diff --git a/ports/atmel-samd/boards/pewpew_m4/board.c b/ports/atmel-samd/boards/pewpew_m4/board.c index 20e7d337a5..50f829fa88 100644 --- a/ports/atmel-samd/boards/pewpew_m4/board.c +++ b/ports/atmel-samd/boards/pewpew_m4/board.c @@ -98,7 +98,7 @@ uint8_t display_init_sequence[] = { void board_init(void) { busio_spi_obj_t *spi = &displays[0].fourwire_bus.inline_bus; - common_hal_busio_spi_construct(spi, &pin_PA13, &pin_PA15, NULL); + common_hal_busio_spi_construct(spi, &pin_PA13, &pin_PA15, NULL, false); common_hal_busio_spi_never_reset(spi); displayio_fourwire_obj_t *bus = &displays[0].fourwire_bus; diff --git a/ports/atmel-samd/boards/pybadge/board.c b/ports/atmel-samd/boards/pybadge/board.c index f3c65ec8ca..ce5beb6bc3 100644 --- a/ports/atmel-samd/boards/pybadge/board.c +++ b/ports/atmel-samd/boards/pybadge/board.c @@ -71,7 +71,7 @@ uint8_t display_init_sequence[] = { void board_init(void) { busio_spi_obj_t *spi = &displays[0].fourwire_bus.inline_bus; - common_hal_busio_spi_construct(spi, &pin_PB13, &pin_PB15, NULL); + common_hal_busio_spi_construct(spi, &pin_PB13, &pin_PB15, NULL, false); common_hal_busio_spi_never_reset(spi); displayio_fourwire_obj_t *bus = &displays[0].fourwire_bus; diff --git a/ports/atmel-samd/boards/pybadge/pins.c b/ports/atmel-samd/boards/pybadge/pins.c index eb8aa81241..49a48447a6 100644 --- a/ports/atmel-samd/boards/pybadge/pins.c +++ b/ports/atmel-samd/boards/pybadge/pins.c @@ -66,6 +66,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_TFT_DC), MP_ROM_PTR(&pin_PB05) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, diff --git a/ports/atmel-samd/boards/pygamer/board.c b/ports/atmel-samd/boards/pygamer/board.c index dc27ef2a48..9a85e166c4 100644 --- a/ports/atmel-samd/boards/pygamer/board.c +++ b/ports/atmel-samd/boards/pygamer/board.c @@ -71,7 +71,7 @@ uint8_t display_init_sequence[] = { void board_init(void) { busio_spi_obj_t *spi = &displays[0].fourwire_bus.inline_bus; - common_hal_busio_spi_construct(spi, &pin_PB13, &pin_PB15, NULL); + common_hal_busio_spi_construct(spi, &pin_PB13, &pin_PB15, NULL, false); common_hal_busio_spi_never_reset(spi); displayio_fourwire_obj_t *bus = &displays[0].fourwire_bus; diff --git a/ports/atmel-samd/boards/pygamer/pins.c b/ports/atmel-samd/boards/pygamer/pins.c index f81b306a48..191f8a7c6b 100644 --- a/ports/atmel-samd/boards/pygamer/pins.c +++ b/ports/atmel-samd/boards/pygamer/pins.c @@ -71,6 +71,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_JOYSTICK_Y), MP_ROM_PTR(&pin_PB06) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, diff --git a/ports/atmel-samd/boards/pyportal/mpconfigboard.mk b/ports/atmel-samd/boards/pyportal/mpconfigboard.mk index 0a70db50c9..5ac39ee735 100644 --- a/ports/atmel-samd/boards/pyportal/mpconfigboard.mk +++ b/ports/atmel-samd/boards/pyportal/mpconfigboard.mk @@ -9,3 +9,11 @@ CHIP_FAMILY = samd51 QSPI_FLASH_FILESYSTEM = 1 EXTERNAL_FLASH_DEVICES = "W25Q64JVxQ, GD25Q64C" LONGINT_IMPL = MPZ + +# Include these Python libraries in firmware. +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_PortalBase +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Requests +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_ESP32SPI +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Display_Text +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_FakeRequests diff --git a/ports/atmel-samd/boards/pyportal/pins.c b/ports/atmel-samd/boards/pyportal/pins.c index d2c7589ee1..1fa05cc460 100644 --- a/ports/atmel-samd/boards/pyportal/pins.c +++ b/ports/atmel-samd/boards/pyportal/pins.c @@ -78,6 +78,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_SD_CARD_DETECT),MP_ROM_PTR(&pin_PA01) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display) }, diff --git a/ports/atmel-samd/boards/pyportal_titano/mpconfigboard.mk b/ports/atmel-samd/boards/pyportal_titano/mpconfigboard.mk index 2202fca2f7..ad46c79a98 100644 --- a/ports/atmel-samd/boards/pyportal_titano/mpconfigboard.mk +++ b/ports/atmel-samd/boards/pyportal_titano/mpconfigboard.mk @@ -9,3 +9,11 @@ CHIP_FAMILY = samd51 QSPI_FLASH_FILESYSTEM = 1 EXTERNAL_FLASH_DEVICES = "W25Q64JVxQ, GD25Q64C" LONGINT_IMPL = MPZ + +# Include these Python libraries in firmware. +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_PortalBase +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Requests +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_ESP32SPI +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Display_Text +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_FakeRequests diff --git a/ports/atmel-samd/boards/pyportal_titano/pins.c b/ports/atmel-samd/boards/pyportal_titano/pins.c index d2c7589ee1..1fa05cc460 100644 --- a/ports/atmel-samd/boards/pyportal_titano/pins.c +++ b/ports/atmel-samd/boards/pyportal_titano/pins.c @@ -78,6 +78,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_SD_CARD_DETECT),MP_ROM_PTR(&pin_PA01) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display) }, diff --git a/ports/atmel-samd/boards/qtpy_m0/pins.c b/ports/atmel-samd/boards/qtpy_m0/pins.c index 0796838437..477fead9ca 100644 --- a/ports/atmel-samd/boards/qtpy_m0/pins.c +++ b/ports/atmel-samd/boards/qtpy_m0/pins.c @@ -45,6 +45,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_NEOPIXEL_POWER), MP_ROM_PTR(&pin_PA15) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, }; diff --git a/ports/atmel-samd/boards/qtpy_m0_haxpress/pins.c b/ports/atmel-samd/boards/qtpy_m0_haxpress/pins.c index 0796838437..477fead9ca 100644 --- a/ports/atmel-samd/boards/qtpy_m0_haxpress/pins.c +++ b/ports/atmel-samd/boards/qtpy_m0_haxpress/pins.c @@ -45,6 +45,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_NEOPIXEL_POWER), MP_ROM_PTR(&pin_PA15) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, }; diff --git a/ports/atmel-samd/boards/seeeduino_wio_terminal/board.c b/ports/atmel-samd/boards/seeeduino_wio_terminal/board.c index eef1167f5b..62b2299f56 100644 --- a/ports/atmel-samd/boards/seeeduino_wio_terminal/board.c +++ b/ports/atmel-samd/boards/seeeduino_wio_terminal/board.c @@ -51,7 +51,7 @@ uint8_t display_init_sequence[] = { 0xc1, 0x01, 0x10, // Power control SAP[2:0];BT[3:0] 0xc5, 0x02, 0x3e, 0x28, // VCM control 0xc7, 0x01, 0x86, // VCM control2 - 0x36, 0x01, 0x38, // Memory Access Control + 0x36, 0x01, 0xe8, // Memory Access Control 0x37, 0x01, 0x00, // Vertical scroll zero 0x3a, 0x01, 0x55, // COLMOD: Pixel Format Set 0xb1, 0x02, 0x00, 0x18, // Frame Rate Control (In Normal Mode/Full Colors) @@ -66,7 +66,7 @@ uint8_t display_init_sequence[] = { void board_init(void) { busio_spi_obj_t *spi = &displays[0].fourwire_bus.inline_bus; - common_hal_busio_spi_construct(spi, &pin_PB20, &pin_PB19, NULL); + common_hal_busio_spi_construct(spi, &pin_PB20, &pin_PB19, NULL, false); common_hal_busio_spi_never_reset(spi); displayio_fourwire_obj_t *bus = &displays[0].fourwire_bus; @@ -88,7 +88,7 @@ void board_init(void) { 240, // Height 0, // column start 0, // row start - 180, // rotation + 0, // rotation 16, // Color depth false, // Grayscale false, // pixels in a byte share a row. Only valid for depths < 8 @@ -129,6 +129,8 @@ void board_init(void) { common_hal_digitalio_digitalinout_never_reset(&CTR_3V3); common_hal_digitalio_digitalinout_never_reset(&USB_HOST_ENABLE); + // reset pin after fake deep sleep + reset_pin_number(pin_PA18.number); } bool board_requests_safe_mode(void) { @@ -139,4 +141,12 @@ void reset_board(void) { } void board_deinit(void) { + common_hal_displayio_release_displays(); + common_hal_digitalio_digitalinout_deinit(&CTR_5V); + common_hal_digitalio_digitalinout_deinit(&CTR_3V3); + common_hal_digitalio_digitalinout_deinit(&USB_HOST_ENABLE); + + // Turn off RTL8720DN before the deep sleep. + // Pin state is kept during BACKUP sleep. + gpio_set_pin_direction(pin_PA18.number, GPIO_DIRECTION_OUT); } diff --git a/ports/atmel-samd/boards/sensebox_mcu/mpconfigboard.mk b/ports/atmel-samd/boards/sensebox_mcu/mpconfigboard.mk index bdfe26068d..568503afe9 100644 --- a/ports/atmel-samd/boards/sensebox_mcu/mpconfigboard.mk +++ b/ports/atmel-samd/boards/sensebox_mcu/mpconfigboard.mk @@ -11,5 +11,4 @@ LONGINT_IMPL = NONE CIRCUITPY_FULL_BUILD = 0 # There are many pin definitions on this board; it doesn't quite fit on very large translations. -# Remove a couple of modules. -CIRCUITPY_ONEWIREIO = 0 +CIRCUITPY_RAINBOWIO = 0 diff --git a/ports/atmel-samd/boards/sparkfun_qwiic_micro_no_flash/pins.c b/ports/atmel-samd/boards/sparkfun_qwiic_micro_no_flash/pins.c index dee32d5f1a..af365cdaa3 100644 --- a/ports/atmel-samd/boards/sparkfun_qwiic_micro_no_flash/pins.c +++ b/ports/atmel-samd/boards/sparkfun_qwiic_micro_no_flash/pins.c @@ -41,7 +41,8 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { // I2C and Qwiic Connector { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PA08) }, { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PA09) }, - { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) } + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, }; MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/atmel-samd/boards/sparkfun_qwiic_micro_with_flash/pins.c b/ports/atmel-samd/boards/sparkfun_qwiic_micro_with_flash/pins.c index dee32d5f1a..af365cdaa3 100644 --- a/ports/atmel-samd/boards/sparkfun_qwiic_micro_with_flash/pins.c +++ b/ports/atmel-samd/boards/sparkfun_qwiic_micro_with_flash/pins.c @@ -41,7 +41,8 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { // I2C and Qwiic Connector { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PA08) }, { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PA09) }, - { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) } + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, }; MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/atmel-samd/boards/sparkfun_redboard_turbo/pins.c b/ports/atmel-samd/boards/sparkfun_redboard_turbo/pins.c index de81d035d8..8b321e11cf 100755 --- a/ports/atmel-samd/boards/sparkfun_redboard_turbo/pins.c +++ b/ports/atmel-samd/boards/sparkfun_redboard_turbo/pins.c @@ -44,6 +44,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PA12) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, }; diff --git a/ports/atmel-samd/boards/sparkfun_samd51_micromod/mpconfigboard.h b/ports/atmel-samd/boards/sparkfun_samd51_micromod/mpconfigboard.h index 5344e3c1ca..3c4ef44b88 100644 --- a/ports/atmel-samd/boards/sparkfun_samd51_micromod/mpconfigboard.h +++ b/ports/atmel-samd/boards/sparkfun_samd51_micromod/mpconfigboard.h @@ -19,7 +19,7 @@ #define DEFAULT_SPI_BUS_SCK (&pin_PA05) #define DEFAULT_SPI_BUS_MOSI (&pin_PA04) -#define DEFAULT_SPI_BUS_MISO (&pin_PB06) +#define DEFAULT_SPI_BUS_MISO (&pin_PA06) #define DEFAULT_UART_BUS_RX (&pin_PB30) #define DEFAULT_UART_BUS_TX (&pin_PB31) diff --git a/ports/atmel-samd/boards/sparkfun_samd51_thing_plus/pins.c b/ports/atmel-samd/boards/sparkfun_samd51_thing_plus/pins.c index be2b09848c..3e7a2b5548 100644 --- a/ports/atmel-samd/boards/sparkfun_samd51_thing_plus/pins.c +++ b/ports/atmel-samd/boards/sparkfun_samd51_thing_plus/pins.c @@ -33,6 +33,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_PA17) }, { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_PA17) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, }; diff --git a/ports/atmel-samd/boards/stackrduino_m0_pro/pins.c b/ports/atmel-samd/boards/stackrduino_m0_pro/pins.c index b854982500..a8162309e0 100644 --- a/ports/atmel-samd/boards/stackrduino_m0_pro/pins.c +++ b/ports/atmel-samd/boards/stackrduino_m0_pro/pins.c @@ -43,6 +43,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_CHRG_EN), MP_ROM_PTR(&pin_PA13) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, }; diff --git a/ports/atmel-samd/boards/stringcar_m0_express/mpconfigboard.mk b/ports/atmel-samd/boards/stringcar_m0_express/mpconfigboard.mk index 8821f4793a..706797928e 100644 --- a/ports/atmel-samd/boards/stringcar_m0_express/mpconfigboard.mk +++ b/ports/atmel-samd/boards/stringcar_m0_express/mpconfigboard.mk @@ -12,6 +12,6 @@ EXTERNAL_FLASH_DEVICES = AT25SF161 LONGINT_IMPL = MPZ CIRCUITPY_KEYPAD = 0 -CIRCUITPY_ONEWIREIO = 0 +CIRCUITPY_USB_MIDI = 0 CIRCUITPY_BITBANG_APA102 = 1 diff --git a/ports/atmel-samd/boards/trellis_m4_express/pins.c b/ports/atmel-samd/boards/trellis_m4_express/pins.c index 9668d3b0dc..61ca942ce6 100644 --- a/ports/atmel-samd/boards/trellis_m4_express/pins.c +++ b/ports/atmel-samd/boards/trellis_m4_express/pins.c @@ -45,5 +45,6 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_DOTSTAR_CLOCK), MP_ROM_PTR(&pin_PB02) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, }; MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/atmel-samd/boards/ugame10/board.c b/ports/atmel-samd/boards/ugame10/board.c index b732d259db..d75841be54 100644 --- a/ports/atmel-samd/boards/ugame10/board.c +++ b/ports/atmel-samd/boards/ugame10/board.c @@ -72,7 +72,7 @@ uint8_t display_init_sequence[] = { void board_init(void) { displayio_fourwire_obj_t *bus = &displays[0].fourwire_bus; bus->base.type = &displayio_fourwire_type; - busio_spi_obj_t *spi = common_hal_board_create_spi(); + busio_spi_obj_t *spi = common_hal_board_create_spi(0); common_hal_displayio_fourwire_construct(bus, spi, &pin_PA09, // Command or data diff --git a/ports/atmel-samd/common-hal/alarm/SleepMemory.c b/ports/atmel-samd/common-hal/alarm/SleepMemory.c index 8ad3577564..1a8eef3aec 100644 --- a/ports/atmel-samd/common-hal/alarm/SleepMemory.c +++ b/ports/atmel-samd/common-hal/alarm/SleepMemory.c @@ -32,20 +32,24 @@ #include "shared-bindings/nvm/ByteArray.h" void alarm_sleep_memory_reset(void) { - } uint32_t common_hal_alarm_sleep_memory_get_length(alarm_sleep_memory_obj_t *self) { - mp_raise_NotImplementedError(translate("Sleep Memory not available")); - return 0; + return BKUPRAM_SIZE; } bool common_hal_alarm_sleep_memory_set_bytes(alarm_sleep_memory_obj_t *self, uint32_t start_index, const uint8_t *values, uint32_t len) { - mp_raise_NotImplementedError(translate("Sleep Memory not available")); - return false; + if (start_index + len > BKUPRAM_SIZE) { + return false; + } + memcpy((uint8_t *)(BKUPRAM_ADDR + start_index), values, len); + return true; } void common_hal_alarm_sleep_memory_get_bytes(alarm_sleep_memory_obj_t *self, uint32_t start_index, uint8_t *values, uint32_t len) { - mp_raise_NotImplementedError(translate("Sleep Memory not available")); + if (start_index + len > BKUPRAM_SIZE) { + return; + } + memcpy(values, (uint8_t *)(BKUPRAM_ADDR + start_index), len); return; } diff --git a/ports/atmel-samd/common-hal/alarm/SleepMemory.h b/ports/atmel-samd/common-hal/alarm/SleepMemory.h index a922ff324a..5fad5946e2 100644 --- a/ports/atmel-samd/common-hal/alarm/SleepMemory.h +++ b/ports/atmel-samd/common-hal/alarm/SleepMemory.h @@ -31,8 +31,6 @@ typedef struct { mp_obj_base_t base; - uint8_t *start_address; - uint8_t len; } alarm_sleep_memory_obj_t; extern void alarm_sleep_memory_reset(void); diff --git a/ports/atmel-samd/common-hal/alarm/__init__.c b/ports/atmel-samd/common-hal/alarm/__init__.c index 66b42a3062..405bf9d573 100644 --- a/ports/atmel-samd/common-hal/alarm/__init__.c +++ b/ports/atmel-samd/common-hal/alarm/__init__.c @@ -39,62 +39,50 @@ #include "supervisor/port.h" #include "supervisor/workflow.h" +STATIC uint32_t TAMPID = 0; + // Singleton instance of SleepMemory. const alarm_sleep_memory_obj_t alarm_sleep_memory_obj = { .base = { .type = &alarm_sleep_memory_type, }, }; -// TODO: make a custom enum to avoid weird values like PM_SLEEPCFG_SLEEPMODE_BACKUP_Val? -STATIC volatile uint32_t _target; -STATIC bool fake_sleep; -STATIC bool pin_wake; void alarm_reset(void) { // Reset the alarm flag - SAMD_ALARM_FLAG = 0x00; alarm_pin_pinalarm_reset(); alarm_time_timealarm_reset(); } -samd_sleep_source_t alarm_get_wakeup_cause(void) { - // If in light/fake sleep, check modules - if (alarm_pin_pinalarm_woke_this_cycle()) { - return SAMD_WAKEUP_GPIO; - } - if (alarm_time_timealarm_woke_this_cycle()) { - return SAMD_WAKEUP_RTC; - } - if (!fake_sleep && RSTC->RCAUSE.bit.BACKUP) { - // This is checked during rtc_init to cache TAMPID if necessary - if (pin_wake || RTC->MODE0.TAMPID.reg) { - pin_wake = true; - return SAMD_WAKEUP_GPIO; - } - return SAMD_WAKEUP_RTC; - } - return SAMD_WAKEUP_UNDEF; +void alarm_get_wakeup_cause(void) { + // Called from rtc_init, just before SWRST of RTC. It is called + // at an early stage of main(), to save TAMPID from SWRST. Later, + // common_hal_alarm_create_wake_alarm is called to make a wakeup + // alarm from the deep sleep. + + TAMPID = RTC->MODE0.TAMPID.reg; } bool common_hal_alarm_woken_from_sleep(void) { - return alarm_get_wakeup_cause() != SAMD_WAKEUP_UNDEF; + return alarm_pin_pinalarm_woke_this_cycle() || alarm_time_timealarm_woke_this_cycle(); } mp_obj_t common_hal_alarm_create_wake_alarm(void) { - // If woken from deep sleep, create a copy alarm similar to what would have - // been passed in originally. Otherwise, just return none - samd_sleep_source_t cause = alarm_get_wakeup_cause(); - switch (cause) { - case SAMD_WAKEUP_RTC: { - return alarm_time_timealarm_create_wakeup_alarm(); - } - case SAMD_WAKEUP_GPIO: { - return alarm_pin_pinalarm_create_wakeup_alarm(); - } - case SAMD_WAKEUP_UNDEF: - default: - // Not a deep sleep reset. - break; + // Called from main.c on the first start up, just before alarm_reset. + // Return a copy of wakeup alarm from deep sleep / fake deep sleep. + // In case of fake sleep, status should be left in TimeAlarm/PinAlarm. + bool true_deep = RSTC->RCAUSE.bit.BACKUP; + + if (alarm_pin_pinalarm_woke_this_cycle()) { + TAMPID = RTC->MODE0.TAMPID.reg; + RTC->MODE0.TAMPID.reg = TAMPID; // clear register + return alarm_pin_pinalarm_create_wakeup_alarm(TAMPID); + } + if (alarm_time_timealarm_woke_this_cycle() || (true_deep && TAMPID == 0)) { + return alarm_time_timealarm_create_wakeup_alarm(); + } + if (true_deep) { + return alarm_pin_pinalarm_create_wakeup_alarm(TAMPID); } return mp_const_none; } @@ -103,36 +91,31 @@ mp_obj_t common_hal_alarm_create_wake_alarm(void) { STATIC void _setup_sleep_alarms(bool deep_sleep, size_t n_alarms, const mp_obj_t *alarms) { alarm_pin_pinalarm_set_alarms(deep_sleep, n_alarms, alarms); alarm_time_timealarm_set_alarms(deep_sleep, n_alarms, alarms); - fake_sleep = false; } mp_obj_t common_hal_alarm_light_sleep_until_alarms(size_t n_alarms, const mp_obj_t *alarms) { _setup_sleep_alarms(false, n_alarms, alarms); mp_obj_t wake_alarm = mp_const_none; + // This works but achieves same power consumption as time.sleep() + PM->SLEEPCFG.reg = PM_SLEEPCFG_SLEEPMODE_STANDBY; + while (PM->SLEEPCFG.bit.SLEEPMODE != PM_SLEEPCFG_SLEEPMODE_STANDBY_Val) { + } + // STDBYCFG is left to be 0 to retain SYSRAM. Note that, even if + // RAMCFG_OFF is set here, SYSRAM seems to be retained, probably + // because RTC and/or USB keeps sleepwalking. + while (!mp_hal_is_interrupted()) { RUN_BACKGROUND_TASKS; // Detect if interrupt was alarm or ctrl-C interrupt. - if (common_hal_alarm_woken_from_sleep()) { - samd_sleep_source_t cause = alarm_get_wakeup_cause(); - switch (cause) { - case SAMD_WAKEUP_RTC: { - wake_alarm = alarm_time_timealarm_find_triggered_alarm(n_alarms,alarms); - break; - } - case SAMD_WAKEUP_GPIO: { - wake_alarm = alarm_pin_pinalarm_find_triggered_alarm(n_alarms,alarms); - break; - } - default: - // Should not reach this, if all light sleep types are covered correctly - break; - } - shared_alarm_save_wake_alarm(wake_alarm); + if (alarm_time_timealarm_woke_this_cycle()) { + wake_alarm = alarm_time_timealarm_find_triggered_alarm(n_alarms,alarms); + break; + } + if (alarm_pin_pinalarm_woke_this_cycle()) { + wake_alarm = alarm_pin_pinalarm_find_triggered_alarm(n_alarms,alarms); break; } - // ATTEMPT ------------------------------ - // This works but achieves same power consumption as time.sleep() // Clear the FPU interrupt because it can prevent us from sleeping. if (__get_FPSCR() & ~(0x9f)) { @@ -140,27 +123,22 @@ mp_obj_t common_hal_alarm_light_sleep_until_alarms(size_t n_alarms, const mp_obj (void)__get_FPSCR(); } - // Disable RTC interrupts - NVIC_DisableIRQ(RTC_IRQn); - // Set standby power domain stuff - PM->STDBYCFG.reg = PM_STDBYCFG_RAMCFG_OFF; - // Set-up Sleep Mode - PM->SLEEPCFG.reg = PM_SLEEPCFG_SLEEPMODE_STANDBY; - while (PM->SLEEPCFG.bit.SLEEPMODE != PM_SLEEPCFG_SLEEPMODE_STANDBY_Val) { - ; - } - + common_hal_mcu_disable_interrupts(); __DSB(); // Data Synchronization Barrier __WFI(); // Wait For Interrupt - // Enable RTC interrupts - NVIC_EnableIRQ(RTC_IRQn); - // END ATTEMPT ------------------------------ + common_hal_mcu_enable_interrupts(); } + // Restore SLEEPCFG or port_idle_until_interrupt sleeps in STANDBY mode. + PM->SLEEPCFG.reg = PM_SLEEPCFG_SLEEPMODE_IDLE2; + while (PM->SLEEPCFG.bit.SLEEPMODE != PM_SLEEPCFG_SLEEPMODE_IDLE2_Val) { + } + alarm_pin_pinalarm_deinit_alarms(n_alarms, alarms); // after care for alarm_pin_pinalarm_set_alarms + alarm_reset(); + if (mp_hal_is_interrupted()) { return mp_const_none; // Shouldn't be given to python code because exception handling should kick in. } - alarm_reset(); return wake_alarm; } @@ -171,11 +149,12 @@ void common_hal_alarm_set_deep_sleep_alarms(size_t n_alarms, const mp_obj_t *ala void NORETURN common_hal_alarm_enter_deep_sleep(void) { alarm_pin_pinalarm_prepare_for_deep_sleep(); alarm_time_timealarm_prepare_for_deep_sleep(); - _target = RTC->MODE0.COMP[1].reg; - port_disable_tick(); // TODO: Required for SAMD? + // port_disable_tick(); // TODO: Required for SAMD? - // cache alarm flag since backup registers about to be reset - uint32_t _SAMD_ALARM_FLAG = SAMD_ALARM_FLAG; + // cache alarm flag and etc since RTC about to be reset + uint32_t _flag = SAMD_ALARM_FLAG; // RTC->MODE0.BKUP[0].reg + uint32_t _target = RTC->MODE0.COMP[1].reg; + uint32_t _tampctrl = RTC->MODE0.TAMPCTRL.reg; // Clear the FPU interrupt because it can prevent us from sleeping. if (__get_FPSCR() & ~(0x9f)) { @@ -183,57 +162,36 @@ void NORETURN common_hal_alarm_enter_deep_sleep(void) { (void)__get_FPSCR(); } - NVIC_DisableIRQ(RTC_IRQn); + common_hal_mcu_disable_interrupts(); // Must disable the RTC before writing to EVCTRL and TMPCTRL - RTC->MODE0.CTRLA.bit.ENABLE = 0; // Disable the RTC - while (RTC->MODE0.SYNCBUSY.bit.ENABLE) { // Wait for synchronization - ; - } RTC->MODE0.CTRLA.bit.SWRST = 1; // Software reset the RTC while (RTC->MODE0.SYNCBUSY.bit.SWRST) { // Wait for synchronization - ; } RTC->MODE0.CTRLA.reg = RTC_MODE0_CTRLA_PRESCALER_DIV1024 | // Set prescaler to 1024 RTC_MODE0_CTRLA_MODE_COUNT32; // Set RTC to mode 0, 32-bit timer + SAMD_ALARM_FLAG = _flag; // Check if we're setting TimeAlarm - if (_SAMD_ALARM_FLAG & SAMD_ALARM_FLAG_TIME) { - RTC->MODE0.COMP[1].reg = (_target / 1024) * 32; + if (SAMD_ALARM_FLAG_TIME_CHK) { + RTC->MODE0.COMP[1].reg = _target; while (RTC->MODE0.SYNCBUSY.reg) { - ; } - } - // Check if we're setting PinAlarm - if (_SAMD_ALARM_FLAG & SAMD_ALARM_FLAG_PIN) { - RTC->MODE0.TAMPCTRL.bit.DEBNC2 = 1; // Edge triggered when INn is stable for 4 CLK_RTC_DEB periods - RTC->MODE0.TAMPCTRL.bit.TAMLVL2 = 1; // rising edge - // PA02 = IN2 - RTC->MODE0.TAMPCTRL.bit.IN2ACT = 1; // WAKE on IN2 (doesn't save timestamp) - } - // Enable interrupts - NVIC_SetPriority(RTC_IRQn, 0); - NVIC_EnableIRQ(RTC_IRQn); - if (_SAMD_ALARM_FLAG & SAMD_ALARM_FLAG_TIME) { - // Set interrupts for COMPARE1 RTC->MODE0.INTENSET.reg = RTC_MODE0_INTENSET_CMP1; } - if (_SAMD_ALARM_FLAG & SAMD_ALARM_FLAG_PIN) { - // Set interrupts for TAMPER pins + // Check if we're setting PinAlarm + if (SAMD_ALARM_FLAG_PIN_CHK) { + RTC->MODE0.TAMPCTRL.reg = _tampctrl; RTC->MODE0.INTENSET.reg = RTC_MODE0_INTENSET_TAMPER; } + // Enable interrupts + common_hal_mcu_enable_interrupts(); - // Set-up Deep Sleep Mode & RAM retention - PM->BKUPCFG.reg = PM_BKUPCFG_BRAMCFG(0x2); // No RAM retention 0x2 partial:0x1 - while (PM->BKUPCFG.bit.BRAMCFG != 0x2) { // Wait for synchronization - ; - } + // Set-up Deep Sleep Mode with backup RAM retention PM->SLEEPCFG.reg = PM_SLEEPCFG_SLEEPMODE_BACKUP; while (PM->SLEEPCFG.bit.SLEEPMODE != PM_SLEEPCFG_SLEEPMODE_BACKUP_Val) { - ; } RTC->MODE0.CTRLA.bit.ENABLE = 1; // Enable the RTC while (RTC->MODE0.SYNCBUSY.bit.ENABLE) { // Wait for synchronization - ; } __DSB(); // Data Synchronization Barrier @@ -245,16 +203,9 @@ void NORETURN common_hal_alarm_enter_deep_sleep(void) { } } -void common_hal_alarm_pretending_deep_sleep(void) { - // TODO: - // If tamper detect interrupts cannot be used to wake from the Idle tier of sleep, - // This section will need to re-initialize the pins to allow the PORT peripheral - // to generate external interrupts again. See STM32 for reference. - - if (!fake_sleep) { - fake_sleep = true; - } -} +// Default common_hal_alarm_pretending_deep_sleep is defined in +// shared-bindings, which is used here. Note that "pretending" does +// not work on REPL; it only works for main.py (or code.py, ...). void common_hal_alarm_gc_collect(void) { gc_collect_ptr(shared_alarm_get_wake_alarm()); diff --git a/ports/atmel-samd/common-hal/alarm/__init__.h b/ports/atmel-samd/common-hal/alarm/__init__.h index 5e777bdf87..061775e568 100644 --- a/ports/atmel-samd/common-hal/alarm/__init__.h +++ b/ports/atmel-samd/common-hal/alarm/__init__.h @@ -37,6 +37,14 @@ extern const alarm_sleep_memory_obj_t alarm_sleep_memory_obj; #define SAMD_ALARM_FLAG (RTC->MODE0.BKUP[0].reg) #define SAMD_ALARM_FLAG_TIME (_U_(0x1) << 0) #define SAMD_ALARM_FLAG_PIN (_U_(0x1) << 1) + +#define SAMD_ALARM_FLAG_TIME_SET (SAMD_ALARM_FLAG |= SAMD_ALARM_FLAG_TIME) +#define SAMD_ALARM_FLAG_TIME_CLR (SAMD_ALARM_FLAG &= ~SAMD_ALARM_FLAG_TIME) +#define SAMD_ALARM_FLAG_TIME_CHK (SAMD_ALARM_FLAG & SAMD_ALARM_FLAG_TIME) + +#define SAMD_ALARM_FLAG_PIN_SET (SAMD_ALARM_FLAG |= SAMD_ALARM_FLAG_PIN) +#define SAMD_ALARM_FLAG_PIN_CLR (SAMD_ALARM_FLAG &= ~SAMD_ALARM_FLAG_PIN) +#define SAMD_ALARM_FLAG_PIN_CHK (SAMD_ALARM_FLAG & SAMD_ALARM_FLAG_PIN) #endif typedef enum { @@ -46,7 +54,7 @@ typedef enum { } samd_sleep_source_t; extern void alarm_set_wakeup_reason(samd_sleep_source_t reason); -samd_sleep_source_t alarm_get_wakeup_cause(void); +void alarm_get_wakeup_cause(void); extern void alarm_reset(void); #endif // MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_ALARM__INIT__H diff --git a/ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c b/ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c index cfd4a9f893..eda111639b 100644 --- a/ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c +++ b/ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c @@ -38,70 +38,61 @@ // This variable stores whether a PinAlarm woke in light sleep or fake deep sleep // It CANNOT detect if the program woke from deep sleep. -STATIC volatile bool woke_up; -// TODO: replace pinalarm_on with SAMD_ALARM_FLAG bit flags -STATIC volatile bool pinalarm_on; +STATIC volatile bool woke_up = false; +STATIC alarm_pin_pinalarm_obj_t *trig_alarm = NULL; -// TODO: Create tables here reserving IRQ instances, and for the IRQ -// callback to store what pin triggered the interrupt -// STATIC bool reserved_alarms[SOME_VAL]; -// STATIC uint16_t triggered_pins[SOME_VAL]; +// Tamper Pins for deep sleep: IN0:PB00; IN1:PB02; IN2:PA02; IN3:PC00; IN4:PC01; +// wakeup from deep sleep seems to be triggered when these pins go from Hi/Lo to Hi-Z state. +typedef struct { + int n; + const mcu_pin_obj_t *pin; +} samd_tamper_pin_t; -void pin_alarm_callback(uint8_t num) { // parameters can be changed - // TODO: This is responsible for resetting the IRQ (so it doesn't - // go off constantly, and recording what pin was responsible for - // the trigger. This will only work for light sleep/fake deep - // sleep, in conjunction with the find_triggered_alarm function +static samd_tamper_pin_t TAMPER_PINS[] = { + #if defined(PIN_PB00) && !defined(IGNORE_PIN_PB00) + { 0, &pin_PB00 }, + #endif + #if defined(PIN_PB02) && !defined(IGNORE_PIN_PB02) + { 1, &pin_PB02 }, + #endif + #if defined(PIN_PA02) && !defined(IGNORE_PIN_PA02) + { 2, &pin_PA02 }, + #endif + #if defined(PIN_PC00) && !defined(IGNORE_PIN_PC00) + { 3, &pin_PC00 }, + #endif + #if defined(PIN_PC01) && !defined(IGNORE_PIN_PC01) + { 4, &pin_PC01 }, + #endif + { -1, NULL } +}; - if (pinalarm_on) { - // clear flag and interrupt setting +void pin_alarm_callback(uint8_t num) { + // called back with EIC/RTC interrupt + if (!SAMD_ALARM_FLAG_PIN_CHK) { + return; + } + woke_up = true; + // SAMD_ALARM_FLAG_PIN_CLR; + if (RTC->MODE0.INTFLAG.reg & RTC_MODE0_INTFLAG_TAMPER) { // fake deep sleep RTC->MODE0.INTENCLR.reg = RTC_MODE0_INTENCLR_TAMPER; - pinalarm_on = false; - // QUESTION: How to reference the correct EIC? - // set_eic_handler(self->channel, EIC_HANDLER_NO_INTERRUPT); - // turn_off_eic_channel(self->channel); - // reset_pin_number(self->pin); - woke_up = true; + trig_alarm = NULL; + } else { // light sleep + // Turn off sensing for the channel, or level detection will + // be tirggered again. + // If we clear EIC->INTENCLR flag here, cleaning up in deint + // may fail because MCLK to EIC is stopped earlier by + // turn_off_eic_channel. + configure_eic_channel(num, EIC_CONFIG_SENSE0_NONE_Val); + trig_alarm = get_eic_channel_data(num); } } void common_hal_alarm_pin_pinalarm_construct(alarm_pin_pinalarm_obj_t *self, const mcu_pin_obj_t *pin, bool value, bool edge, bool pull) { - // Tamper Pins: IN0:PB00; IN1:PB02; IN2:PA02; IN3:PC00; IN4:PC01; OUT:PB01 - // TODO: Catch edge or level mode if not supported - if (!pin->has_extint) { - mp_raise_RuntimeError(translate("No hardware support on pin")); - } - if (eic_get_enable()) { - if (!eic_channel_free(pin->extint_channel)) { - mp_raise_RuntimeError(translate("A hardware interrupt channel is already in use")); - } - } else { - turn_on_external_interrupt_controller(); - } - - // TODO: determine if pin has an interrupt channel available - // TODO: set pin pull settings, input/output, etc - // QUESTION: can PORT/EVSYS interrupts (lightsleep) coexist with RTC->TAMPER (deepsleep) settings? - // Actual initialization of the interrupt should be delayed until set_alarm - - self->channel = pin->extint_channel; self->pin = pin; self->value = value; + self->edge = edge; self->pull = pull; - - gpio_set_pin_function(pin->number, GPIO_PIN_FUNCTION_A); - if (self->pull) { - if (self->value) { - // detect rising edge means pull down - gpio_set_pin_pull_mode(pin->number, GPIO_PULL_DOWN); - } else { - // detect falling edge means pull up - gpio_set_pin_pull_mode(pin->number, GPIO_PULL_UP); - } - } - set_eic_channel_data(self->channel, (void *)self); - - claim_pin(self->pin); } const mcu_pin_obj_t *common_hal_alarm_pin_pinalarm_get_pin(alarm_pin_pinalarm_obj_t *self) { @@ -113,7 +104,7 @@ bool common_hal_alarm_pin_pinalarm_get_value(alarm_pin_pinalarm_obj_t *self) { } bool common_hal_alarm_pin_pinalarm_get_edge(alarm_pin_pinalarm_obj_t *self) { - return true; + return self->edge; } bool common_hal_alarm_pin_pinalarm_get_pull(alarm_pin_pinalarm_obj_t *self) { @@ -121,9 +112,6 @@ bool common_hal_alarm_pin_pinalarm_get_pull(alarm_pin_pinalarm_obj_t *self) { } bool alarm_pin_pinalarm_woke_this_cycle(void) { - if (pinalarm_on && RTC->MODE0.INTFLAG.bit.TAMPER) { - woke_up = true; - } return woke_up; } @@ -133,145 +121,211 @@ mp_obj_t alarm_pin_pinalarm_find_triggered_alarm(size_t n_alarms, const mp_obj_t continue; } alarm_pin_pinalarm_obj_t *alarm = MP_OBJ_TO_PTR(alarms[i]); - (void)alarm; - - - // TODO: Determine whether any pins have been marked as - // triggering the alarm (using the static vars at - // start of file) and if so return that alarm. + if (alarm == trig_alarm) { + return alarms[i]; + } } - // Return nothing if no matching alarms are found. return mp_const_none; } -mp_obj_t alarm_pin_pinalarm_create_wakeup_alarm(void) { - alarm_pin_pinalarm_obj_t *alarm = m_new_obj(alarm_pin_pinalarm_obj_t); - alarm->base.type = &alarm_pin_pinalarm_type; - // TODO: Extract information about what pin woke the device. - // Because this interrupt occurs in deep sleep, the callback - // cannot be used to store this information. It must be extracted - // from the registers, if possible. It may be impossible to - // obtain, in which case return a dummy value. - return alarm; +mp_obj_t alarm_pin_pinalarm_create_wakeup_alarm(uint32_t TAMPID) { + // Create tamper alarm that caused wakeup from deep sleep + + for (samd_tamper_pin_t *t = TAMPER_PINS; t->n >= 0; t++) { + if (TAMPID & (1 << t->n)) { + alarm_pin_pinalarm_obj_t *alarm = m_new_obj(alarm_pin_pinalarm_obj_t); + alarm->base.type = &alarm_pin_pinalarm_type; + alarm->pin = t->pin; + return alarm; + } + } + return mp_const_none; } void alarm_pin_pinalarm_reset(void) { - // TODO: this is responsible for resetting ALL pinalarms. Make - // sure to clear any reserved tables, deinit both PORT and TAMPER - // settings, etc. If flags are set to indicate this module is in - // use, reset them. - pinalarm_on = false; + SAMD_ALARM_FLAG_PIN_CLR; woke_up = false; - SAMD_ALARM_FLAG &= ~SAMD_ALARM_FLAG_PIN; // clear flag // Disable TAMPER interrupt - RTC->MODE0.INTENCLR.bit.TAMPER = 1; - // Disable TAMPER control - common_hal_mcu_disable_interrupts(); - RTC->MODE0.CTRLA.bit.ENABLE = 0; // Disable the RTC - while (RTC->MODE0.SYNCBUSY.bit.ENABLE) { // Wait for synchronization - ; + RTC->MODE0.INTENCLR.reg = RTC_MODE0_INTENCLR_TAMPER; + if (RTC->MODE0.TAMPCTRL.reg != 0) { + common_hal_mcu_disable_interrupts(); + RTC->MODE0.CTRLA.bit.ENABLE = 0; // Disable the RTC + while (RTC->MODE0.SYNCBUSY.bit.ENABLE) { // Wait for synchronization + } + RTC->MODE0.TAMPCTRL.reg = 0; // reset everything + RTC->MODE0.CTRLA.bit.ENABLE = 1; // Enable the RTC + while (RTC->MODE0.SYNCBUSY.bit.ENABLE) { // Wait for synchronization + } + common_hal_mcu_enable_interrupts(); } - RTC->MODE0.TAMPCTRL.reg = 0; // reset everything - RTC->MODE0.CTRLA.bit.ENABLE = 1; // Enable the RTC - while (RTC->MODE0.SYNCBUSY.bit.ENABLE) { // Wait for synchronization - ; +} + +#define PINALARM_NOERR 0 +#define PINALARM_ERR_NOT_FREE -1 +#define PINALARM_ERR_NOEXTINT -2 +#define PINALARM_ERR_NOCHANNEL -3 +#define PINALARM_ERR_NOTTAMPER -4 + +// Because PinAlarm does not have deinit, pins are furnished just +// before the light sleep here, and deinited after wake-up. +static void pinalarm_set_alarms_light(size_t n_alarms, const mp_obj_t *alarms) { + int err = PINALARM_NOERR; + size_t i; + const mcu_pin_obj_t *pin; + + for (i = 0; i < n_alarms; i++) { + if (!mp_obj_is_type(alarms[i], &alarm_pin_pinalarm_type)) { + continue; + } + alarm_pin_pinalarm_obj_t *alarm = MP_OBJ_TO_PTR(alarms[i]); + pin = alarm->pin; + + if (!pin_number_is_free(pin->number)) { + err = PINALARM_ERR_NOT_FREE; + break; + } + if (!pin->has_extint) { + err = PINALARM_ERR_NOEXTINT; + break; + } + if (eic_get_enable()) { + if (!eic_channel_free(pin->extint_channel)) { + err = PINALARM_ERR_NOCHANNEL; + break; + } + } else { + turn_on_external_interrupt_controller(); + // It is automatically turned-off in turn_off_eic_channel. + } + + SAMD_ALARM_FLAG_PIN_SET; + gpio_set_pin_function(pin->number, GPIO_PIN_FUNCTION_A); + uint32_t sense; + if (alarm->value) { + sense = alarm->edge ? EIC_CONFIG_SENSE0_RISE_Val : EIC_CONFIG_SENSE0_HIGH_Val; + if (alarm->pull) { + // detect rising edge means pull down + gpio_set_pin_pull_mode(pin->number, GPIO_PULL_DOWN); + } + } else { + sense = alarm->edge ? EIC_CONFIG_SENSE0_FALL_Val : EIC_CONFIG_SENSE0_LOW_Val; + if (alarm->pull) { + // detect falling edge means pull up + gpio_set_pin_pull_mode(pin->number, GPIO_PULL_UP); + } + } + + set_eic_channel_data(pin->extint_channel, (void *)alarm); + claim_pin(pin); + set_eic_handler(pin->extint_channel, EIC_HANDLER_ALARM); + turn_on_eic_channel(pin->extint_channel, sense); + } + + if (err == PINALARM_NOERR) { + return; + } + + SAMD_ALARM_FLAG_PIN_CLR; + alarm_pin_pinalarm_deinit_alarms(i, alarms); + + switch (err) { + case PINALARM_ERR_NOT_FREE: + assert_pin_free(pin); + // raise ValueError here + MP_FALLTHROUGH + case PINALARM_ERR_NOEXTINT: + mp_raise_RuntimeError(translate("No hardware support on pin")); + case PINALARM_ERR_NOCHANNEL: + mp_raise_RuntimeError(translate("A hardware interrupt channel is already in use")); + default: + mp_raise_RuntimeError(translate("Unknown reason.")); + } +} + +static void pinalarm_set_alarms_deep(size_t n_alarms, const mp_obj_t *alarms) { + // In case of deep sleep, pin_number_is_free is not checked. + // Errata says that falling edge should be detected for the tamper pins. + samd_tamper_pin_t *t; + uint32_t tampctrl = 0; + + for (size_t i = 0; i < n_alarms; i++) { + if (!mp_obj_is_type(alarms[i], &alarm_pin_pinalarm_type)) { + continue; + } + alarm_pin_pinalarm_obj_t *alarm = MP_OBJ_TO_PTR(alarms[i]); + const mcu_pin_obj_t *pin = alarm->pin; + + for (t = TAMPER_PINS; t->n >= 0; t++) { + if (pin == t->pin) { + break; + } + } + if (t->n < 0) { + mp_raise_ValueError(translate("Pin cannot wake from Deep Sleep")); + } + + // It is strange, but to my experiment, interrupt during sleep + // is triggered on transition from Hi/Lo to Hi-Z state, and + // not on switching from Hi/Lo to Lo/Hi state, regardless of + // TAMLVL value. If tested on non-sleep condition, TAMPID + // reacts either on falling or rising edge, according to + // TAMLVL value as doumented. + tampctrl |= (((1UL << t->n) << 24) | // DEBNCn + ((alarm->value << t->n) << 16) | // TAMLVLn + (1UL << t->n * 2)); // INnACT + + // Tamper pins under the control of RTC are kept in Hi-Z + // state, and pull mode is not effective. + #if 0 + if (alarm->pull) { + if (alarm->value) { + gpio_set_pin_pull_mode(pin->number, GPIO_PULL_DOWN); + } else { + gpio_set_pin_pull_mode(pin->number, GPIO_PULL_UP); + } + } + #endif + } + if (tampctrl == 0) { + return; + } + + SAMD_ALARM_FLAG_PIN_SET; + RTC->MODE0.INTFLAG.reg = RTC_MODE0_INTFLAG_TAMPER; + RTC->MODE0.INTENSET.reg = RTC_MODE0_INTENSET_TAMPER; + common_hal_mcu_disable_interrupts(); + RTC->MODE0.CTRLA.bit.ENABLE = 0; // Disable the RTC + while (RTC->MODE0.SYNCBUSY.bit.ENABLE) { // Wait for synchronization + } + RTC->MODE0.TAMPCTRL.reg = tampctrl; + RTC->MODE0.CTRLA.bit.ENABLE = 1; // Enable the RTC + while (RTC->MODE0.SYNCBUSY.bit.ENABLE) { // Wait for synchronization } common_hal_mcu_enable_interrupts(); } -void alarm_pin_pinalarm_set_alarms(bool deep_sleep, size_t n_alarms, const mp_obj_t *alarms) { - // The outer layer of this loop simply checks if there are any pin - // alarms in the parameter array +void alarm_pin_pinalarm_deinit_alarms(size_t n_alarms, const mp_obj_t *alarms) { for (size_t i = 0; i < n_alarms; i++) { - if (mp_obj_is_type(alarms[i], &alarm_pin_pinalarm_type)) { - alarm_pin_pinalarm_obj_t *alarm = MP_OBJ_TO_PTR(alarms[i]); - gpio_set_pin_function(alarm->pin->number, GPIO_PIN_FUNCTION_A); - if (alarm->pull) { - if (alarm->value) { - // detect rising edge means pull down - gpio_set_pin_pull_mode(alarm->pin->number, GPIO_PULL_DOWN); - } else { - // detect falling edge means pull up - gpio_set_pin_pull_mode(alarm->pin->number, GPIO_PULL_UP); - } - } - if (deep_sleep) { - // Tamper Pins: IN0:PB00; IN1:PB02; IN2:PA02; IN3:PC00; IN4:PC01; OUT:PB01 - // Only these pins can do TAMPER - if ( - #ifdef PIN_PB00 - alarm->pin != &pin_PB00 - #else - true - #endif - #ifdef PIN_PB02 - && alarm->pin != &pin_PB02 - #endif - && alarm->pin != &pin_PA02) { - mp_raise_ValueError(translate("Pin cannot wake from Deep Sleep")); - } - pinalarm_on = true; - SAMD_ALARM_FLAG |= SAMD_ALARM_FLAG_PIN; - - // Set tamper interrupt so deep sleep knows that's the intent - RTC->MODE0.INTENSET.reg = RTC_MODE0_INTENSET_TAMPER; - common_hal_mcu_disable_interrupts(); - RTC->MODE0.CTRLA.bit.ENABLE = 0; // Disable the RTC - while (RTC->MODE0.SYNCBUSY.bit.ENABLE) { // Wait for synchronization - ; - } - // TODO: map requested pin to limited selection of TAMPER pins - // PA02 is n=2: IN2, LVL2, etc... - RTC->MODE0.TAMPCTRL.bit.DEBNC2 = 1; // Edge triggered when INn is stable for 4 CLK_RTC_DEB periods - RTC->MODE0.TAMPCTRL.bit.TAMLVL2 = alarm->value; // rising or falling edge - RTC->MODE0.TAMPCTRL.bit.IN2ACT = 1; // WAKE on IN2 (doesn't save timestamp) - common_hal_mcu_enable_interrupts(); - RTC->MODE0.INTENSET.reg = RTC_MODE0_INTENSET_TAMPER; - RTC->MODE0.CTRLA.bit.ENABLE = 1; // Enable the RTC - while (RTC->MODE0.SYNCBUSY.bit.ENABLE) { // Wait for synchronization - ; - } - // TODO: Set up deep sleep alarms. - // For deep sleep alarms, first check if the - // alarm pin value is valid for RTC->TAMPER. Ensure - // that the PULL and VALUE values are possible to - // implement with TAMPER, and throw value errors if - // not. - // A VM reset will occur before deep sleep - // starts, so either init these settings now and - // protect them with a `never_reset` function, or - // store them all in static variables and only - // actually implement the settings in - // `alarm_pin_pinalarm_prepare_for_deep_sleep` - // below. - } // use else-if here if RTC-TAMPER can wake from IDLE - else { - // Light sleep so turn on EIC channel - set_eic_handler(alarm->channel, EIC_HANDLER_ALARM); - turn_on_eic_channel(alarm->channel, EIC_CONFIG_SENSE0_RISE_Val); - } - - // TODO: Set up light sleep / fake deep sleep alarms. - // PORT/EVSYS should have more valid pin combinations - // than the TAMPER system. Check if there is a valid - // PORT/EVSYS combination, set it up, and reserve it with - // the tables at the start of this file so it can't be - // reused. Also set up IRQ callbacks and any other - // busywork. - - // TODO: Might want to reserve or otherwise interact with - // peripherals/sam_d5x/external_interrupts.c or events.c here - - // TODO: Even if an alarm is being set for deep sleep, it - // still needs to be able to wake from fake deep sleep, - // which is actually just like a light sleep. If the - // RTC Tamper IRQs are capable of waking from IDLE mode, - // this isn't a big deal, and there can be a strict - // if-else statement here. Otherwise, it will need to - // either set PORT and TAMPER IRQs simultaniously, or if that - // isn't possible, make a new function that can shunt fake deep - // sleep setup to common_hal_alarm_pretending_deep_sleep + if (!mp_obj_is_type(alarms[i], &alarm_pin_pinalarm_type)) { + continue; } + alarm_pin_pinalarm_obj_t *alarm = MP_OBJ_TO_PTR(alarms[i]); + const mcu_pin_obj_t *pin = alarm->pin; + + set_eic_handler(pin->extint_channel, EIC_HANDLER_NO_INTERRUPT); + // Set sense = 0 or INTFLAG may be set on reset_pin_number. + configure_eic_channel(pin->extint_channel, EIC_CONFIG_SENSE0_NONE_Val); + turn_off_eic_channel(pin->extint_channel); + reset_pin_number(pin->number); + } +} + +void alarm_pin_pinalarm_set_alarms(bool deep_sleep, size_t n_alarms, const mp_obj_t *alarms) { + trig_alarm = NULL; + if (deep_sleep) { + pinalarm_set_alarms_deep(n_alarms, alarms); + } else { + pinalarm_set_alarms_light(n_alarms, alarms); } } diff --git a/ports/atmel-samd/common-hal/alarm/pin/PinAlarm.h b/ports/atmel-samd/common-hal/alarm/pin/PinAlarm.h index f3cd4cf27b..57dc7d6c65 100644 --- a/ports/atmel-samd/common-hal/alarm/pin/PinAlarm.h +++ b/ports/atmel-samd/common-hal/alarm/pin/PinAlarm.h @@ -34,15 +34,16 @@ typedef struct { mp_obj_base_t base; const mcu_pin_obj_t *pin; bool value; + bool edge; bool pull; - uint8_t channel; } alarm_pin_pinalarm_obj_t; mp_obj_t alarm_pin_pinalarm_find_triggered_alarm(size_t n_alarms, const mp_obj_t *alarms); -mp_obj_t alarm_pin_pinalarm_create_wakeup_alarm(void); +mp_obj_t alarm_pin_pinalarm_create_wakeup_alarm(uint32_t TAMPID); void pin_alarm_callback(uint8_t num); void alarm_pin_pinalarm_reset(void); +void alarm_pin_pinalarm_deinit_alarms(size_t n_alarms, const mp_obj_t *alarms); void alarm_pin_pinalarm_set_alarms(bool deep_sleep, size_t n_alarms, const mp_obj_t *alarms); void alarm_pin_pinalarm_prepare_for_deep_sleep(void); bool alarm_pin_pinalarm_woke_this_cycle(void); diff --git a/ports/atmel-samd/common-hal/alarm/time/TimeAlarm.c b/ports/atmel-samd/common-hal/alarm/time/TimeAlarm.c index 49ce90a0b6..14a7346c17 100644 --- a/ports/atmel-samd/common-hal/alarm/time/TimeAlarm.c +++ b/ports/atmel-samd/common-hal/alarm/time/TimeAlarm.c @@ -26,26 +26,20 @@ #include "py/runtime.h" #include "hpl/pm/hpl_pm_base.h" -// #include #include "shared-bindings/alarm/time/TimeAlarm.h" #include "shared-bindings/time/__init__.h" #include "common-hal/alarm/__init__.h" #include "supervisor/port.h" -STATIC volatile bool woke_up; -STATIC uint32_t deep_sleep_ticks; -// TODO: replace timealarm_on with SAMD_ALARM_FLAG bit flags -STATIC volatile bool timealarm_on; +STATIC volatile bool woke_up = false; +STATIC mp_float_t wakeup_time; void common_hal_alarm_time_timealarm_construct(alarm_time_timealarm_obj_t *self, mp_float_t monotonic_time) { - // TODO: throw a ValueError if the input time exceeds the maximum - // value of the Compare register. This must be calculated from the - // setup values in port.c. Should be ~3 days. Give it some margin. - // - // UPDATE: for deep sleep at least, it's far more than 3 days since - // prescalar is set to 1024. (2^32)/32 seconds so >1500 days? - + // TODO: when issueing light/seep sleep, throw a ValueError if the + // time exceeds the maximum value. For light sleep, max = + // 2**32 / 16384 = 3 days. For deep sleep, max = 2**32 / 32 + // = 1550 days. self->monotonic_time = monotonic_time; } @@ -74,29 +68,30 @@ mp_obj_t alarm_time_timealarm_create_wakeup_alarm(void) { } void time_alarm_callback(void) { - if (timealarm_on) { - RTC->MODE0.INTENCLR.reg = RTC_MODE0_INTENCLR_CMP1; // clear flags + if (SAMD_ALARM_FLAG_TIME_CHK) { + RTC->MODE0.INTENCLR.reg = RTC_MODE0_INTENCLR_CMP1; + // SAMD_ALARM_FLAG_TIME_CLR; woke_up = true; - timealarm_on = false; } } bool alarm_time_timealarm_woke_this_cycle(void) { - if (timealarm_on && (((uint32_t)port_get_raw_ticks(NULL) << 4) > RTC->MODE0.COMP[1].reg)) { - woke_up = true; + if (SAMD_ALARM_FLAG_TIME_CHK) { + mp_float_t now_secs = uint64_to_float(common_hal_time_monotonic_ms()) / 1000.0f; + if (now_secs > wakeup_time) { + woke_up = true; + } } return woke_up; } void alarm_time_timealarm_reset(void) { - timealarm_on = false; + SAMD_ALARM_FLAG_TIME_CLR; woke_up = false; - SAMD_ALARM_FLAG &= ~SAMD_ALARM_FLAG_TIME; // clear flag + RTC->MODE0.INTENCLR.reg = RTC_MODE0_INTENCLR_CMP1; } void alarm_time_timealarm_set_alarms(bool deep_sleep, size_t n_alarms, const mp_obj_t *alarms) { - // Turn on debug control - // RTC->MODE0.DBGCTRL.bit.DBGRUN = 1; // Search through alarms for TimeAlarm instances, and check that there's only one bool timealarm_set = false; alarm_time_timealarm_obj_t *timealarm = MP_OBJ_NULL; @@ -114,55 +109,36 @@ void alarm_time_timealarm_set_alarms(bool deep_sleep, size_t n_alarms, const mp_ return; } - // Compute how long to actually sleep, considering the time now. - mp_float_t now_secs = uint64_to_float(common_hal_time_monotonic_ms()) / 1000.0f; - uint32_t wakeup_in_secs = MAX(0.0f, timealarm->monotonic_time - now_secs); - uint32_t wakeup_in_ticks = wakeup_in_secs * 1024; + // In the true deep sleep case, counter is set again based on + // wakeup_time in alarm_time_timealarm_prepare_for_deep_sleep. + wakeup_time = timealarm->monotonic_time; - // In the deep sleep case, we can't start the timer until the USB delay has finished - // (otherwise it will go off while USB enumerates, and we'll risk entering deep sleep - // without any way to wake up again) - if (deep_sleep) { - deep_sleep_ticks = wakeup_in_ticks; - } else { - deep_sleep_ticks = 0; - } - timealarm_on = true; - // Set COMP1 for fake sleep. This will be read and reset for real deep sleep anyways. - // RTC->MODE0.COMP[1].reg = wakeup_in_ticks; - RTC->MODE0.COMP[1].reg = ((uint32_t)port_get_raw_ticks(NULL) + wakeup_in_ticks) << 4; + // Compute how long to actually sleep, considering the time now. + // At least 1 count = 1/16384 sec is necessary. + mp_float_t now_secs = uint64_to_float(common_hal_time_monotonic_ms()) / 1000.0f; + uint32_t wakeup_in_counts = MAX(1, (uint32_t)((wakeup_time - now_secs) * 16384)); + + + SAMD_ALARM_FLAG_TIME_SET; + RTC->MODE0.COMP[1].reg = RTC->MODE0.COUNT.reg + wakeup_in_counts; while ((RTC->MODE0.SYNCBUSY.reg & (RTC_MODE0_SYNCBUSY_COMP1)) != 0) { } RTC->MODE0.INTFLAG.reg = RTC_MODE0_INTFLAG_CMP1; RTC->MODE0.INTENSET.reg = RTC_MODE0_INTENSET_CMP1; - SAMD_ALARM_FLAG |= SAMD_ALARM_FLAG_TIME; // set TimeAlarm flag - - // This is set for fake sleep. Max fake sleep time is ~72 hours - // True deep sleep isn't limited by this - // port_interrupt_after_ticks(wakeup_in_ticks); - // printf("second t %lu, cmp0 %lu, cmp1 %lu\n", (uint32_t)port_get_raw_ticks(NULL),RTC->MODE0.COMP[0].reg,RTC->MODE0.COMP[1].reg); - // TODO: set up RTC->COMP[1] and create a callback pointing to - // time_alarm_callback. See atmel-samd/supervisor/port.c -> _port_interrupt_after_ticks() - // for how to set this up. I don't know how you do the callback, though. You MUST use - // COMP[1], since port.c uses COMP[0] already and needs to set that for - // things like the USB enumeration delay. - - // If true deep sleep is called, it will either ignore or overwrite the above setup depending on - // whether it is shorter or longer than the USB delay - // printf("set deep alarm finished\n"); - } void alarm_time_timealarm_prepare_for_deep_sleep(void) { - if (deep_sleep_ticks) { - // TODO: set up RTC->COMP[1] again, since it needs to start AFTER the USB enumeration delay. - // Just do the exact same setup as alarm_time_timealarm_set_alarms(). Note, this - // is used for both fake and real deep sleep, so it still needs the callback. - // See STM32 for reference. + // set up RTC->COMP[1] again, since it needs to start AFTER the USB enumeration delay. + // Just do the exact same setup as alarm_time_timealarm_set_alarms(). Note, this + // is used for both fake and real deep sleep, so it still needs the callback. + // See STM32 for reference. + // + // In deep sleep mode, prescaler is set to 1024, so that 1 count = 1/32 s. + // At least 1 count is necessary. - RTC->MODE0.COMP[1].reg = deep_sleep_ticks; - while ((RTC->MODE0.SYNCBUSY.reg & (RTC_MODE0_SYNCBUSY_COMP1)) != 0) { - } - deep_sleep_ticks = 0; + mp_float_t now_secs = uint64_to_float(common_hal_time_monotonic_ms()) / 1000.0f; + uint32_t wakeup_in_counts = MAX(1, (uint32_t)((wakeup_time - now_secs) * 32)); + RTC->MODE0.COMP[1].reg = wakeup_in_counts; + while ((RTC->MODE0.SYNCBUSY.reg & (RTC_MODE0_SYNCBUSY_COMP1)) != 0) { } } diff --git a/ports/atmel-samd/common-hal/audiobusio/PDMIn.c b/ports/atmel-samd/common-hal/audiobusio/PDMIn.c index e6363395a6..e7c00901bf 100644 --- a/ports/atmel-samd/common-hal/audiobusio/PDMIn.c +++ b/ports/atmel-samd/common-hal/audiobusio/PDMIn.c @@ -66,7 +66,7 @@ #endif // Set by interrupt handler when DMA block has finished transferring. -static bool pdmin_dma_block_done; +static volatile bool pdmin_dma_block_done; // Event channel used to trigger interrupt. Set to invalid value EVSYS_SYNCH_NUM when not in use. static uint8_t pdmin_event_channel; @@ -77,6 +77,7 @@ void pdmin_evsys_handler(void) { } void pdmin_reset(void) { + pdmin_dma_block_done = false; pdmin_event_channel = EVSYS_SYNCH_NUM; while (I2S->SYNCBUSY.reg & I2S_SYNCBUSY_ENABLE) {} @@ -409,6 +410,20 @@ uint32_t common_hal_audiobusio_pdmin_record_to_buffer(audiobusio_pdmin_obj_t* se init_event_channel_interrupt(pdmin_event_channel, CORE_GCLK, EVSYS_ID_GEN_DMAC_CH_0 + dma_channel); // Turn on serializer now to get it in sync with DMA. i2s_set_serializer_enable(self->serializer, true); + + #ifdef SAM_D5X_E5X + int irq = pdmin_event_channel < 4 ? EVSYS_0_IRQn + pdmin_event_channel : EVSYS_4_IRQn; + // Only disable and clear on SAMD51 because the SAMD21 shares EVSYS with ticks. + NVIC_DisableIRQ(irq); + NVIC_ClearPendingIRQ(irq); + #endif + + #ifdef SAMD21 + int irq = EVSYS_IRQn; + #endif + + // Don't bother to disable when done. It doesn't hurt to leave it on. + NVIC_EnableIRQ(irq); audio_dma_enable_channel(dma_channel); // Record diff --git a/ports/atmel-samd/common-hal/busio/I2C.c b/ports/atmel-samd/common-hal/busio/I2C.c index 7d77c0d43a..48ee26a9b6 100644 --- a/ports/atmel-samd/common-hal/busio/I2C.c +++ b/ports/atmel-samd/common-hal/busio/I2C.c @@ -190,7 +190,7 @@ void common_hal_busio_i2c_unlock(busio_i2c_obj_t *self) { self->has_lock = false; } -uint8_t common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t addr, +STATIC uint8_t _common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t addr, const uint8_t *data, size_t len, bool transmit_stop_bit) { uint16_t attempts = ATTEMPTS; @@ -216,6 +216,11 @@ uint8_t common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t addr, return MP_EIO; } +uint8_t common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t addr, + const uint8_t *data, size_t len) { + return _common_hal_busio_i2c_write(self, addr, data, len, true); +} + uint8_t common_hal_busio_i2c_read(busio_i2c_obj_t *self, uint16_t addr, uint8_t *data, size_t len) { @@ -242,6 +247,16 @@ uint8_t common_hal_busio_i2c_read(busio_i2c_obj_t *self, uint16_t addr, return MP_EIO; } +uint8_t common_hal_busio_i2c_write_read(busio_i2c_obj_t *self, uint16_t addr, + uint8_t *out_data, size_t out_len, uint8_t *in_data, size_t in_len) { + uint8_t result = _common_hal_busio_i2c_write(self, addr, out_data, out_len, false); + if (result != 0) { + return result; + } + + return common_hal_busio_i2c_read(self, addr, in_data, in_len); +} + void common_hal_busio_i2c_never_reset(busio_i2c_obj_t *self) { never_reset_sercom(self->i2c_desc.device.hw); diff --git a/ports/atmel-samd/common-hal/busio/SPI.c b/ports/atmel-samd/common-hal/busio/SPI.c index 3b60c1d2b4..0f6f38461c 100644 --- a/ports/atmel-samd/common-hal/busio/SPI.c +++ b/ports/atmel-samd/common-hal/busio/SPI.c @@ -44,7 +44,7 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self, const mcu_pin_obj_t *clock, const mcu_pin_obj_t *mosi, - const mcu_pin_obj_t *miso) { + const mcu_pin_obj_t *miso, bool half_duplex) { Sercom *sercom = NULL; uint8_t sercom_index; uint32_t clock_pinmux = 0; @@ -57,6 +57,10 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self, uint8_t miso_pad = 0; uint8_t dopo = 255; + if (half_duplex) { + mp_raise_NotImplementedError(translate("Half duplex SPI is not implemented")); + } + // Ensure the object starts in its deinit state. self->clock_pin = NO_PIN; diff --git a/ports/atmel-samd/common-hal/countio/Counter.c b/ports/atmel-samd/common-hal/countio/Counter.c index e4df55eba6..c68b9e18ef 100644 --- a/ports/atmel-samd/common-hal/countio/Counter.c +++ b/ports/atmel-samd/common-hal/countio/Counter.c @@ -10,14 +10,14 @@ #include "supervisor/shared/translate.h" void common_hal_countio_counter_construct(countio_counter_obj_t *self, - const mcu_pin_obj_t *pin_a) { - if (!pin_a->has_extint) { + const mcu_pin_obj_t *pin, countio_edge_t edge, digitalio_pull_t pull) { + if (!pin->has_extint) { mp_raise_RuntimeError(translate("Pin must support hardware interrupts")); } if (eic_get_enable()) { - if (!eic_channel_free(pin_a->extint_channel)) { + if (!eic_channel_free(pin->extint_channel)) { mp_raise_RuntimeError(translate("A hardware interrupt channel is already in use")); } } else { @@ -25,28 +25,50 @@ void common_hal_countio_counter_construct(countio_counter_obj_t *self, } // These default settings apply when the EIC isn't yet enabled. - self->eic_channel_a = pin_a->extint_channel; + self->eic_channel = pin->extint_channel; - self->pin_a = pin_a->number; + self->pin = pin->number; - gpio_set_pin_function(self->pin_a, GPIO_PIN_FUNCTION_A); - gpio_set_pin_pull_mode(self->pin_a, GPIO_PULL_UP); + gpio_set_pin_function(self->pin, GPIO_PIN_FUNCTION_A); - set_eic_channel_data(self->eic_channel_a, (void *)self); + enum gpio_pull_mode asf_pull = GPIO_PULL_OFF; + switch (pull) { + case PULL_UP: + asf_pull = GPIO_PULL_UP; + break; + case PULL_DOWN: + asf_pull = GPIO_PULL_DOWN; + break; + case PULL_NONE: + default: + break; + } + gpio_set_pin_pull_mode(self->pin, asf_pull); + + set_eic_channel_data(self->eic_channel, (void *)self); self->count = 0; + claim_pin(pin); + set_eic_handler(self->eic_channel, EIC_HANDLER_COUNTER); - claim_pin(pin_a); - - - set_eic_handler(self->eic_channel_a, EIC_HANDLER_COUNTER); - turn_on_eic_channel(self->eic_channel_a, EIC_CONFIG_SENSE0_FALL_Val); - + uint32_t sense_setting = EIC_CONFIG_SENSE0_BOTH_Val; + switch (edge) { + case EDGE_RISE: + sense_setting = EIC_CONFIG_SENSE0_RISE_Val; + break; + case EDGE_FALL: + sense_setting = EIC_CONFIG_SENSE0_FALL_Val; + break; + case EDGE_RISE_AND_FALL: + default: + break; + } + turn_on_eic_channel(self->eic_channel, sense_setting); } bool common_hal_countio_counter_deinited(countio_counter_obj_t *self) { - return self->pin_a == NO_PIN; + return self->pin == NO_PIN; } void common_hal_countio_counter_deinit(countio_counter_obj_t *self) { @@ -54,12 +76,12 @@ void common_hal_countio_counter_deinit(countio_counter_obj_t *self) { return; } - set_eic_handler(self->eic_channel_a, EIC_HANDLER_NO_INTERRUPT); - turn_off_eic_channel(self->eic_channel_a); + set_eic_handler(self->eic_channel, EIC_HANDLER_NO_INTERRUPT); + turn_off_eic_channel(self->eic_channel); - reset_pin_number(self->pin_a); - self->pin_a = NO_PIN; + reset_pin_number(self->pin); + self->pin = NO_PIN; } @@ -72,10 +94,6 @@ void common_hal_countio_counter_set_count(countio_counter_obj_t *self, self->count = new_count; } -void common_hal_countio_counter_reset(countio_counter_obj_t *self) { - self->count = 0; -} - void counter_interrupt_handler(uint8_t channel) { countio_counter_obj_t *self = get_eic_channel_data(channel); diff --git a/ports/atmel-samd/common-hal/countio/Counter.h b/ports/atmel-samd/common-hal/countio/Counter.h index 8af22253f9..a57df9a777 100644 --- a/ports/atmel-samd/common-hal/countio/Counter.h +++ b/ports/atmel-samd/common-hal/countio/Counter.h @@ -8,8 +8,8 @@ typedef struct { mp_obj_base_t base; - uint8_t pin_a; - uint8_t eic_channel_a : 4; + uint8_t pin; + uint8_t eic_channel : 4; mp_int_t count; } countio_counter_obj_t; diff --git a/ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c b/ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c index f973db90b0..4e06b77b56 100644 --- a/ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c +++ b/ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c @@ -54,12 +54,33 @@ #endif static frequencyio_frequencyin_obj_t *active_frequencyins[TC_INST_NUM]; -volatile uint8_t reference_tc = 0xff; +volatile uint8_t reference_tc; #ifdef SAM_D5X_E5X static uint8_t dpll_gclk; + +#if !BOARD_HAS_CRYSTAL +static uint8_t osculp32k_gclk; #endif -void frequencyin_emergency_cancel_capture(uint8_t index) { +#endif + +void frequencyin_reset(void) { + for (uint8_t i = 0; i < TC_INST_NUM; i++) { + active_frequencyins[i] = NULL; + } + + reference_tc = 0xff; + #ifdef SAM_D5X_E5X + dpll_gclk = 0xff; + + #if !BOARD_HAS_CRYSTAL + osculp32k_gclk = 0xff; + #endif + + #endif +} + +static void frequencyin_emergency_cancel_capture(uint8_t index) { frequencyio_frequencyin_obj_t* self = active_frequencyins[index]; NVIC_DisableIRQ(self->TC_IRQ); @@ -93,7 +114,7 @@ void frequencyin_interrupt_handler(uint8_t index) { uint64_t current_ns = common_hal_time_monotonic_ns(); - for (uint8_t i = 0; i <= (TC_INST_NUM - 1); i++) { + for (uint8_t i = 0; i < TC_INST_NUM; i++) { if (active_frequencyins[i] != NULL) { frequencyio_frequencyin_obj_t* self = active_frequencyins[i]; Tc* tc = tc_insts[self->tc_index]; @@ -143,7 +164,7 @@ void frequencyin_interrupt_handler(uint8_t index) { ref_tc->COUNT16.INTFLAG.reg |= TC_INTFLAG_OVF; } -void frequencyin_reference_tc_init() { +static void frequencyin_reference_tc_init(void) { if (reference_tc == 0xff) { return; } @@ -154,9 +175,6 @@ void frequencyin_reference_tc_init() { // use the DPLL we setup so that the reference_tc and freqin_tc(s) // are using the same clock frequency. #ifdef SAM_D5X_E5X - if (dpll_gclk == 0xff) { - frequencyin_samd51_start_dpll(); - } set_timer_handler(true, reference_tc, TC_HANDLER_FREQUENCYIN); turn_on_clocks(true, reference_tc, dpll_gclk); #endif @@ -167,18 +185,18 @@ void frequencyin_reference_tc_init() { #ifdef SAMD21 tc->COUNT16.CTRLA.reg = TC_CTRLA_MODE_COUNT16 | TC_CTRLA_PRESCALER_DIV1; - tc->COUNT16.INTENSET.bit.OVF = 1; + tc->COUNT16.INTENSET.reg = TC_INTENSET_OVF; NVIC_EnableIRQ(TC3_IRQn + reference_tc); #endif #ifdef SAM_D5X_E5X tc->COUNT16.CTRLA.reg = TC_CTRLA_MODE_COUNT16 | TC_CTRLA_PRESCALER_DIV1; - tc->COUNT16.INTENSET.bit.OVF = 1; + tc->COUNT16.INTENSET.reg = TC_INTENSET_OVF; NVIC_EnableIRQ(TC0_IRQn + reference_tc); #endif } -bool frequencyin_reference_tc_enabled() { +static bool frequencyin_reference_tc_enabled(void) { if (reference_tc == 0xff) { return false; } @@ -186,7 +204,7 @@ bool frequencyin_reference_tc_enabled() { return tc->COUNT16.CTRLA.bit.ENABLE; } -void frequencyin_reference_tc_enable(bool enable) { +static void frequencyin_reference_tc_enable(bool enable) { if (reference_tc == 0xff) { return; } @@ -195,56 +213,69 @@ void frequencyin_reference_tc_enable(bool enable) { } #ifdef SAM_D5X_E5X -void frequencyin_samd51_start_dpll() { +static bool frequencyin_samd51_start_dpll(void) { if (clock_get_enabled(0, GCLK_SOURCE_DPLL1)) { - return; + return true; } - uint8_t free_gclk = find_free_gclk(1); - if (free_gclk == 0xff) { - dpll_gclk = 0xff; - return; + dpll_gclk = find_free_gclk(1); + if (dpll_gclk == 0xff) { + return false; } - GCLK->PCHCTRL[OSCCTRL_GCLK_ID_FDPLL1].reg = GCLK_PCHCTRL_CHEN | GCLK_PCHCTRL_GEN(free_gclk); // TC4-7 can only have a max of 100MHz source // DPLL1 frequency equation with [X]OSC32K as source: 98.304MHz = 32768(2999 + 1 + 0/32) // Will also enable the Lock Bypass due to low-frequency sources causing DPLL unlocks // as outlined in the Errata (1.12.1) OSCCTRL->Dpll[1].DPLLRATIO.reg = OSCCTRL_DPLLRATIO_LDRFRAC(0) | OSCCTRL_DPLLRATIO_LDR(2999); -#if BOARD_HAS_CRYSTAL - // we can use XOSC32K directly as the source - OSC32KCTRL->XOSC32K.bit.EN32K = 1; - OSCCTRL->Dpll[1].DPLLCTRLB.reg = OSCCTRL_DPLLCTRLB_REFCLK(1) | OSCCTRL_DPLLCTRLB_LBYPASS; -#else - // can't use OSCULP32K directly; need to setup a GCLK as a reference, - // which must be done in samd/clocks.c to avoid waiting for sync - return; - //OSC32KCTRL->OSCULP32K.bit.EN32K = 1; - //OSCCTRL->Dpll[1].DPLLCTRLB.reg = OSCCTRL_DPLLCTRLB_REFCLK(0); -#endif - OSCCTRL->Dpll[1].DPLLCTRLA.reg = OSCCTRL_DPLLCTRLA_ENABLE; +#if BOARD_HAS_CRYSTAL + // we can use XOSC32K directly as the source. It has already been initialized in clocks.c + OSCCTRL->Dpll[1].DPLLCTRLB.reg = + OSCCTRL_DPLLCTRLB_REFCLK(OSCCTRL_DPLLCTRLB_REFCLK_XOSC32_Val) | OSCCTRL_DPLLCTRLB_LBYPASS; +#else + // We can't use OSCULP32K directly. Set up a GCLK controlled by it + // Then use that GCLK as the reference oscillator for the DPLL. + osculp32k_gclk = find_free_gclk(1); + if (osculp32k_gclk == 0xff) { + return false; + } + enable_clock_generator(osculp32k_gclk, GCLK_GENCTRL_SRC_OSCULP32K_Val, 1); + GCLK->PCHCTRL[OSCCTRL_GCLK_ID_FDPLL1].reg = GCLK_PCHCTRL_CHEN | GCLK_PCHCTRL_GEN(OSCCTRL_GCLK_ID_FDPLL1); + OSCCTRL->Dpll[1].DPLLCTRLB.reg = + OSCCTRL_DPLLCTRLB_REFCLK(OSCCTRL_DPLLCTRLB_REFCLK_GCLK_Val) | OSCCTRL_DPLLCTRLB_LBYPASS; +#endif + + OSCCTRL->Dpll[1].DPLLCTRLA.reg = OSCCTRL_DPLLCTRLA_ENABLE; while (!(OSCCTRL->Dpll[1].DPLLSTATUS.bit.LOCK || OSCCTRL->Dpll[1].DPLLSTATUS.bit.CLKRDY)) {} - enable_clock_generator(free_gclk, GCLK_GENCTRL_SRC_DPLL1_Val, 1); - dpll_gclk = free_gclk; + + enable_clock_generator(dpll_gclk, GCLK_GENCTRL_SRC_DPLL1_Val, 1); + return true; } -void frequencyin_samd51_stop_dpll() { +static void frequencyin_samd51_stop_dpll(void) { if (!clock_get_enabled(0, GCLK_SOURCE_DPLL1)) { return; } - disable_clock_generator(dpll_gclk); + if (dpll_gclk != 0xff) { + disable_clock_generator(dpll_gclk); + dpll_gclk = 0xff; + } + + #if !BOARD_HAS_CRYSTAL + if (osculp32k_gclk != 0xff) { + disable_clock_generator(osculp32k_gclk); + osculp32k_gclk = 0xff; + } + #endif GCLK->PCHCTRL[OSCCTRL_GCLK_ID_FDPLL1].reg = 0; OSCCTRL->Dpll[1].DPLLCTRLA.reg = 0; OSCCTRL->Dpll[1].DPLLRATIO.reg = 0; OSCCTRL->Dpll[1].DPLLCTRLB.reg = 0; - while (OSCCTRL->Dpll[1].DPLLSYNCBUSY.bit.ENABLE) { } - dpll_gclk = 0xff; } #endif @@ -421,7 +452,7 @@ void common_hal_frequencyio_frequencyin_deinit(frequencyio_frequencyin_obj_t* se self->pin = NO_PIN; bool check_active = false; - for (uint8_t i = 0; i <= (TC_INST_NUM - 1); i++) { + for (uint8_t i = 0; i < TC_INST_NUM; i++) { if (active_frequencyins[i] != NULL) { check_active = true; } diff --git a/ports/atmel-samd/common-hal/frequencyio/FrequencyIn.h b/ports/atmel-samd/common-hal/frequencyio/FrequencyIn.h index 53b9f2d2d1..b1d5a58bdb 100644 --- a/ports/atmel-samd/common-hal/frequencyio/FrequencyIn.h +++ b/ports/atmel-samd/common-hal/frequencyio/FrequencyIn.h @@ -46,14 +46,7 @@ typedef struct { } frequencyio_frequencyin_obj_t; void frequencyin_interrupt_handler(uint8_t index); -void frequencyin_emergency_cancel_capture(uint8_t index); -void frequencyin_reference_tc_init(void); -void frequencyin_reference_tc_enable(bool enable); -bool frequencyin_reference_tc_enabled(void); -#ifdef SAM_D5X_E5X -void frequencyin_samd51_start_dpll(void); -void frequencyin_samd51_stop_dpll(void); -#endif +void frequencyin_reset(void); #endif // MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_FREQUENCYIO_FREQUENCYIN_H diff --git a/ports/atmel-samd/common-hal/neopixel_write/__init__.c b/ports/atmel-samd/common-hal/neopixel_write/__init__.c index 754bc97fdf..182b8eee14 100644 --- a/ports/atmel-samd/common-hal/neopixel_write/__init__.c +++ b/ports/atmel-samd/common-hal/neopixel_write/__init__.c @@ -100,7 +100,7 @@ static void neopixel_send_buffer_core(volatile uint32_t *clraddr, uint32_t pinMa ""); } -uint64_t next_start_raw_ticks = 0; +STATIC uint64_t next_start_raw_ticks = 0; void common_hal_neopixel_write(const digitalio_digitalinout_obj_t *digitalinout, uint8_t *pixels, uint32_t numBytes) { // This is adapted directly from the Adafruit NeoPixel library SAMD21G18A code: diff --git a/ports/atmel-samd/common-hal/watchdog/WatchDogTimer.c b/ports/atmel-samd/common-hal/watchdog/WatchDogTimer.c index 2091b7d302..65d238ce75 100644 --- a/ports/atmel-samd/common-hal/watchdog/WatchDogTimer.c +++ b/ports/atmel-samd/common-hal/watchdog/WatchDogTimer.c @@ -58,7 +58,7 @@ STATIC void setup_wdt(watchdog_watchdogtimer_obj_t *self, int setting) { while (WDT->SYNCBUSY.reg) { // Sync CTRL write } - WDT->INTENCLR.bit.EW = 1; // Disable early warning interrupt + WDT->INTENCLR.reg = WDT_INTENCLR_EW; // Disable early warning interrupt WDT->CONFIG.bit.PER = setting; // Set period for chip reset WDT->CTRLA.bit.WEN = 0; // Disable window mode while (WDT->SYNCBUSY.reg) { // Sync CTRL write diff --git a/ports/atmel-samd/mpconfigport.mk b/ports/atmel-samd/mpconfigport.mk index 223a60d796..82cc69728a 100644 --- a/ports/atmel-samd/mpconfigport.mk +++ b/ports/atmel-samd/mpconfigport.mk @@ -2,22 +2,6 @@ # parameters that vary based on chip and/or board. LD_TEMPLATE_FILE = boards/common.template.ld -# Define an equivalent for MICROPY_LONGINT_IMPL, to pass to $(MPY-TOOL) in py/mkrules.mk -# $(MPY-TOOL) needs to know what kind of longint to use (if any) to freeze long integers. -# This should correspond to the MICROPY_LONGINT_IMPL definition in mpconfigport.h. - -ifeq ($(LONGINT_IMPL),NONE) -MPY_TOOL_LONGINT_IMPL = -mlongint-impl=none -endif - -ifeq ($(LONGINT_IMPL),MPZ) -MPY_TOOL_LONGINT_IMPL = -mlongint-impl=mpz -endif - -ifeq ($(LONGINT_IMPL),LONGLONG) -MPY_TOOL_LONGINT_IMPL = -mlongint-impl=longlong -endif - INTERNAL_LIBM = 1 # Number of USB endpoint pairs. @@ -36,6 +20,7 @@ ifeq ($(CHIP_FAMILY),samd21) # fit in 256kB of flash CIRCUITPY_AESIO ?= 0 +CIRCUITPY_ATEXIT ?= 0 CIRCUITPY_AUDIOMIXER ?= 0 CIRCUITPY_BINASCII ?= 0 CIRCUITPY_BITBANGIO ?= 0 @@ -49,6 +34,7 @@ CIRCUITPY_COUNTIO ?= 0 # Not enough RAM for framebuffers CIRCUITPY_FRAMEBUFFERIO ?= 0 CIRCUITPY_FREQUENCYIO ?= 0 +CIRCUITPY_GETPASS ?= 0 CIRCUITPY_GIFIO ?= 0 CIRCUITPY_I2CPERIPHERAL ?= 0 CIRCUITPY_JSON ?= 0 @@ -61,6 +47,14 @@ CIRCUITPY_TOUCHIO_USE_NATIVE ?= 1 CIRCUITPY_ULAB = 0 CIRCUITPY_VECTORIO = 0 +# TODO: In CircuitPython 8.0, turn this back on, after `busio.OneWire` is removed. +# We'd like a smoother transition, but we can't afford the space to have both +# `busio.OneWire` and `onewireio.OneWire` present on these tiny builds. + +ifeq ($(INTERNAL_FLASH_FILESYSTEM),1) +CIRCUITPY_ONEWIREIO ?= 0 +endif + MICROPY_PY_ASYNC_AWAIT = 0 # We don't have room for the fonts for terminalio for ja and ko diff --git a/ports/atmel-samd/supervisor/port.c b/ports/atmel-samd/supervisor/port.c index ccff352443..7be1fdb535 100644 --- a/ports/atmel-samd/supervisor/port.c +++ b/ports/atmel-samd/supervisor/port.c @@ -71,6 +71,10 @@ #include "common-hal/busio/__init__.h" #endif +#if CIRCUITPY_FREQUENCYIO +#include "common-hal/frequencyio/FrequencyIn.h" +#endif + #include "common-hal/microcontroller/Pin.h" #if CIRCUITPY_PULSEIO @@ -382,12 +386,16 @@ void reset_port(void) { audioout_reset(); #endif #if CIRCUITPY_AUDIOBUSIO - // pdmin_reset(); + pdmin_reset(); #endif #if CIRCUITPY_AUDIOBUSIO_I2SOUT i2sout_reset(); #endif + #if CIRCUITPY_FREQUENCYIO + frequencyin_reset(); + #endif + #if CIRCUITPY_TOUCHIO && CIRCUITPY_TOUCHIO_USE_NATIVE touchin_reset(); #endif @@ -399,7 +407,7 @@ void reset_port(void) { #if CIRCUITPY_PWMIO pwmout_reset(); #endif - #if CIRCUITPY_PWMIO || CIRCUITPY_AUDIOIO + #if CIRCUITPY_PWMIO || CIRCUITPY_AUDIOIO || CIRCUITPY_FREQUENCYIO reset_timers(); #endif @@ -490,21 +498,31 @@ uint32_t port_get_saved_word(void) { static volatile uint64_t overflowed_ticks = 0; static uint32_t _get_count(uint64_t *overflow_count) { - #ifdef SAM_D5X_E5X - while ((RTC->MODE0.SYNCBUSY.reg & (RTC_MODE0_SYNCBUSY_COUNTSYNC | RTC_MODE0_SYNCBUSY_COUNT)) != 0) { - } - #endif - // SAMD21 does continuous sync so we don't need to wait here. + while(1) { + // Disable interrupts so we can grab the count and the overflow atomically. + common_hal_mcu_disable_interrupts(); - // Disable interrupts so we can grab the count and the overflow. - common_hal_mcu_disable_interrupts(); - uint32_t count = RTC->MODE0.COUNT.reg; - if (overflow_count != NULL) { - *overflow_count = overflowed_ticks; - } - common_hal_mcu_enable_interrupts(); + #ifdef SAM_D5X_E5X + while ((RTC->MODE0.SYNCBUSY.reg & (RTC_MODE0_SYNCBUSY_COUNTSYNC | RTC_MODE0_SYNCBUSY_COUNT)) != 0) { + } + #endif + // SAMD21 does continuous sync so we don't need to wait here. - return count; + uint32_t count = RTC->MODE0.COUNT.reg; + if (overflow_count != NULL) { + *overflow_count = overflowed_ticks; + } + + bool overflow_pending = RTC->MODE0.INTFLAG.bit.OVF; + + common_hal_mcu_enable_interrupts(); + + if (!overflow_pending) { + return count; + } + + // Try again if overflow hasn't been processed yet. + } } volatile bool _woken_up; diff --git a/ports/broadcom/Makefile b/ports/broadcom/Makefile index 16b44f7501..921d26958a 100644 --- a/ports/broadcom/Makefile +++ b/ports/broadcom/Makefile @@ -31,7 +31,20 @@ include $(TOP)/supervisor/supervisor.mk # Include make rules and variables common across CircuitPython builds. include $(TOP)/py/circuitpy_defns.mk -HAL_DIR=hal/$(MCU_SERIES) +ifeq ($(CHIP_VARIANT), "bcm2711") +CFLAGS += -mcpu=cortex-a72 -DBCM_VERSION=2711 +CROSS_COMPILE = aarch64-none-elf- +SUFFIX = 8 +else ifeq ($(CHIP_VARIANT), "bcm2837") +CFLAGS += -mcpu=cortex-a53 -DBCM_VERSION=2837 +CROSS_COMPILE = aarch64-none-elf- +SUFFIX = 8 +else ifeq ($(CHIP_VARIANT), "bcm2835") +CFLAGS += -mcpu=arm1176jzf-s -DBCM_VERSION=2835 +CROSS_COMPILE = arm-none-eabi- +SUFFIX = +# TODO add 32-bit support for Cortex-A7 in 2836 +endif INC += -I. \ -I../.. \ @@ -69,6 +82,7 @@ SRC_C += bindings/videocore/__init__.c \ peripherals/broadcom/mmu.c \ peripherals/broadcom/vcmailbox.c +SRC_S = peripherals/broadcom/boot$(SUFFIX).s SRC_COMMON_HAL_EXPANDED = $(addprefix shared-bindings/, $(SRC_COMMON_HAL)) \ $(addprefix shared-bindings/, $(SRC_BINDINGS_ENUMS)) \ @@ -82,7 +96,6 @@ SRC_SHARED_MODULE_EXPANDED = $(addprefix shared-bindings/, $(SRC_SHARED_MODULE)) # because a few modules have files both in common-hal/ and shared-modules/. # Doing a $(sort ...) removes duplicates as part of sorting. SRC_COMMON_HAL_SHARED_MODULE_EXPANDED = $(sort $(SRC_COMMON_HAL_EXPANDED) $(SRC_SHARED_MODULE_EXPANDED)) -SRC_S = peripherals/broadcom/boot.s OBJ = $(PY_O) $(SUPERVISOR_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o)) OBJ += $(addprefix $(BUILD)/, $(SRC_COMMON_HAL_SHARED_MODULE_EXPANDED:.c=.o)) @@ -96,15 +109,6 @@ OBJ += $(addprefix $(BUILD)/, $(SRC_MOD:.c=.o)) # BCM CLFAGS CFLAGS += -ffreestanding -nostartfiles -DMICROPY_HW_MCU_NAME="\"$(CHIP_VARIANT)\"" -ifeq ($(CHIP_VARIANT), "bcm2711") -CFLAGS += -mcpu=cortex-a72 -DBCM_VERSION=2711 -CROSS_COMPILE = aarch64-none-elf- -else -CFLAGS += -mcpu=cortex-a53 -DBCM_VERSION=2837 -CROSS_COMPILE = aarch64-none-elf- -# TODO add 32-bit support for Cortex-A7 and ARM1176 -endif - OPTIMIZATION_FLAGS ?= -O3 CFLAGS += $(OPTIMIZATION_FLAGS) @@ -134,40 +138,40 @@ CFLAGS += $(INC) -Wall -Werror -std=gnu11 $(BASE_CFLAGS) $(CFLAGS_MOD) $(COPT) $ SRC_QSTR += $(SRC_C) $(SRC_SUPERVISOR) $(SRC_COMMON_HAL_EXPANDED) $(SRC_SHARED_MODULE_EXPANDED) -LDFLAGS += $(CFLAGS) -T peripherals/broadcom/link.ld -Wl,--gc-sections -Wl,-Map=$@.map # -Wl,--cref +LDFLAGS += $(CFLAGS) -T peripherals/broadcom/link$(SUFFIX).ld -Wl,--gc-sections -Wl,-Map=$@.map # -Wl,--cref # Use toolchain libm if we're not using our own. ifndef INTERNAL_LIBM LIBS += -lm endif -all: $(BUILD)/firmware.kernel8.img $(BUILD)/firmware.disk.img.zip +all: $(BUILD)/firmware.kernel$(SUFFIX).img $(BUILD)/firmware.disk.img.zip %.o: %.c $(CC) $(CFLAGS) -c $< -o $@ -$(BUILD)/kernel8.elf: $(OBJ) +$(BUILD)/kernel$(SUFFIX).elf: $(OBJ) $(STEPECHO) "LINK $@" $(Q)echo $(OBJ) > $(BUILD)/firmware.objs $(Q)$(CC) -o $@ $(LDFLAGS) @$(BUILD)/firmware.objs -Wl,--start-group $(LIBS) -Wl,--end-group -$(BUILD)/kernel8.img: $(BUILD)/kernel8.elf +$(BUILD)/kernel$(SUFFIX).img: $(BUILD)/kernel$(SUFFIX).elf $(STEPECHO) "Create $@" - $(OBJCOPY) -O binary $(BUILD)/kernel8.elf $@ + $(OBJCOPY) -O binary $(BUILD)/kernel$(SUFFIX).elf $@ -$(BUILD)/firmware.kernel8.img: $(BUILD)/kernel8.img +$(BUILD)/firmware.kernel$(SUFFIX).img: $(BUILD)/kernel$(SUFFIX).img $(STEPECHO) "Create $@" $(CP) $^ $@ -$(BUILD)/firmware.disk.img.zip: $(BUILD)/kernel8.img +$(BUILD)/firmware.disk.img.zip: $(BUILD)/kernel$(SUFFIX).img $(STEPECHO) "Create $@" $(Q)dd if=/dev/zero of=$(BUILD)/circuitpython-disk.img bs=1 count=0 seek=256M $(Q)parted -s $(BUILD)/circuitpython-disk.img mktable msdos $(Q)parted -s $(BUILD)/circuitpython-disk.img mkpart primary fat32 0% 100% $(Q)mkfs.fat -F 32 -n BOOT --offset=2048 $(BUILD)/circuitpython-disk.img - $(Q)mcopy -i $(BUILD)/circuitpython-disk.img@@1M config.txt firmware/bootcode.bin firmware/fixup* firmware/start* :: - $(Q)mcopy -i $(BUILD)/circuitpython-disk.img@@1M $(BUILD)/kernel8.img :: + $(Q)mcopy -i $(BUILD)/circuitpython-disk.img@@1M config.txt firmware/bootcode.bin firmware/fixup* firmware/start* firmware/*.dtb :: + $(Q)mcopy -i $(BUILD)/circuitpython-disk.img@@1M $(BUILD)/kernel$(SUFFIX).img :: $(Q)zip $@ $(BUILD)/circuitpython-disk.img $(Q)rm $(BUILD)/circuitpython-disk.img diff --git a/ports/broadcom/boards/diodes_delight_piunora/board.c b/ports/broadcom/boards/diodes_delight_piunora/board.c new file mode 100644 index 0000000000..80bea7f8b6 --- /dev/null +++ b/ports/broadcom/boards/diodes_delight_piunora/board.c @@ -0,0 +1,56 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "supervisor/board.h" +#include "mpconfigboard.h" + +#include "bindings/videocore/Framebuffer.h" +#include "shared-module/displayio/__init__.h" +#include "shared-bindings/framebufferio/FramebufferDisplay.h" + +void board_init(void) { + videocore_framebuffer_obj_t *fb = &allocate_display_bus()->videocore; + fb->base.type = &videocore_framebuffer_type; + common_hal_videocore_framebuffer_construct(fb, 640, 480); + + framebufferio_framebufferdisplay_obj_t *display = &displays[0].framebuffer_display; + display->base.type = &framebufferio_framebufferdisplay_type; + common_hal_framebufferio_framebufferdisplay_construct( + display, + MP_OBJ_FROM_PTR(fb), + 0, + true); +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { +} + +void board_deinit(void) { +} diff --git a/ports/broadcom/boards/diodes_delight_piunora/mpconfigboard.h b/ports/broadcom/boards/diodes_delight_piunora/mpconfigboard.h new file mode 100644 index 0000000000..a3e318bb13 --- /dev/null +++ b/ports/broadcom/boards/diodes_delight_piunora/mpconfigboard.h @@ -0,0 +1,6 @@ +#define MICROPY_HW_BOARD_NAME "Diodes Delight Piunora" + +#define DEFAULT_I2C_BUS_SCL (&pin_GPIO3) +#define DEFAULT_I2C_BUS_SDA (&pin_GPIO2) + +#define MICROPY_HW_NEOPIXEL (&pin_GPIO12) diff --git a/ports/broadcom/boards/diodes_delight_piunora/mpconfigboard.mk b/ports/broadcom/boards/diodes_delight_piunora/mpconfigboard.mk new file mode 100644 index 0000000000..d05bb16028 --- /dev/null +++ b/ports/broadcom/boards/diodes_delight_piunora/mpconfigboard.mk @@ -0,0 +1,6 @@ +USB_VID = 0x1209 +USB_PID = 0xD10D +USB_PRODUCT = "Piunora" +USB_MANUFACTURER = "Diodes Delight" + +CHIP_VARIANT = "bcm2711" diff --git a/ports/broadcom/boards/diodes_delight_piunora/pins.c b/ports/broadcom/boards/diodes_delight_piunora/pins.c new file mode 100644 index 0000000000..c1098d1412 --- /dev/null +++ b/ports/broadcom/boards/diodes_delight_piunora/pins.c @@ -0,0 +1,71 @@ +#include "shared-bindings/board/__init__.h" + +#include "shared-module/displayio/__init__.h" + +STATIC const mp_rom_map_elem_t board_global_dict_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + + { MP_ROM_QSTR(MP_QSTR_GPIO5), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO5) }, + + { MP_ROM_QSTR(MP_QSTR_GPIO4), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO4) }, + + { MP_ROM_QSTR(MP_QSTR_GPIO18), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_GPIO18) }, + + { MP_ROM_QSTR(MP_QSTR_GPIO19), MP_ROM_PTR(&pin_GPIO19) }, + { MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_GPIO19) }, + + { MP_ROM_QSTR(MP_QSTR_GPIO20), MP_ROM_PTR(&pin_GPIO20) }, + { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_GPIO20) }, + + { MP_ROM_QSTR(MP_QSTR_GPIO21), MP_ROM_PTR(&pin_GPIO21) }, + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_GPIO21) }, + + { MP_ROM_QSTR(MP_QSTR_GPIO22), MP_ROM_PTR(&pin_GPIO22) }, + { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_GPIO22) }, + { MP_ROM_QSTR(MP_QSTR_SDA6),MP_ROM_PTR(&pin_GPIO22) }, + + { MP_ROM_QSTR(MP_QSTR_GPIO23), MP_ROM_PTR(&pin_GPIO23) }, + { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_GPIO23) }, + { MP_ROM_QSTR(MP_QSTR_SCL6),MP_ROM_PTR(&pin_GPIO23) }, + + { MP_ROM_QSTR(MP_QSTR_GPIO6), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_SDA4),MP_ROM_PTR(&pin_GPIO6) }, + + { MP_ROM_QSTR(MP_QSTR_GPIO7), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_SCL4),MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_SPI0_CE1),MP_ROM_PTR(&pin_GPIO7) }, + + { MP_ROM_QSTR(MP_QSTR_GPIO8), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_SPI0_CE0),MP_ROM_PTR(&pin_GPIO8) }, + + { MP_ROM_QSTR(MP_QSTR_GPIO10), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_SPI0_MOSI),MP_ROM_PTR(&pin_GPIO10) }, + + { MP_ROM_QSTR(MP_QSTR_GPIO9), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_SPI0_MISO),MP_ROM_PTR(&pin_GPIO9) }, + + { MP_ROM_QSTR(MP_QSTR_GPIO11), MP_ROM_PTR(&pin_GPIO11) }, + { MP_ROM_QSTR(MP_QSTR_D13),MP_ROM_PTR(&pin_GPIO11) }, + { MP_ROM_QSTR(MP_QSTR_SPI0_SCLK),MP_ROM_PTR(&pin_GPIO11) }, + + { MP_ROM_QSTR(MP_QSTR_SDA),MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_SDA1),MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_SCL),MP_ROM_PTR(&pin_GPIO3) }, + + { MP_ROM_QSTR(MP_QSTR_GPIO12), MP_ROM_PTR(&pin_GPIO12) }, + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO12) }, + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display)}, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table); diff --git a/ports/broadcom/boards/raspberrypi_cm4/board.c b/ports/broadcom/boards/raspberrypi_cm4/board.c new file mode 100644 index 0000000000..80bea7f8b6 --- /dev/null +++ b/ports/broadcom/boards/raspberrypi_cm4/board.c @@ -0,0 +1,56 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "supervisor/board.h" +#include "mpconfigboard.h" + +#include "bindings/videocore/Framebuffer.h" +#include "shared-module/displayio/__init__.h" +#include "shared-bindings/framebufferio/FramebufferDisplay.h" + +void board_init(void) { + videocore_framebuffer_obj_t *fb = &allocate_display_bus()->videocore; + fb->base.type = &videocore_framebuffer_type; + common_hal_videocore_framebuffer_construct(fb, 640, 480); + + framebufferio_framebufferdisplay_obj_t *display = &displays[0].framebuffer_display; + display->base.type = &framebufferio_framebufferdisplay_type; + common_hal_framebufferio_framebufferdisplay_construct( + display, + MP_OBJ_FROM_PTR(fb), + 0, + true); +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { +} + +void board_deinit(void) { +} diff --git a/ports/broadcom/boards/raspberrypi_cm4/mpconfigboard.h b/ports/broadcom/boards/raspberrypi_cm4/mpconfigboard.h new file mode 100644 index 0000000000..fbd258577e --- /dev/null +++ b/ports/broadcom/boards/raspberrypi_cm4/mpconfigboard.h @@ -0,0 +1 @@ +#define MICROPY_HW_BOARD_NAME "Raspberry Pi Compute Module 4" diff --git a/ports/broadcom/boards/raspberrypi_cm4/mpconfigboard.mk b/ports/broadcom/boards/raspberrypi_cm4/mpconfigboard.mk new file mode 100644 index 0000000000..ee54efe84b --- /dev/null +++ b/ports/broadcom/boards/raspberrypi_cm4/mpconfigboard.mk @@ -0,0 +1,6 @@ +USB_VID = 0x2E8A +USB_PID = 0x1014 +USB_PRODUCT = "Compute Module 4" +USB_MANUFACTURER = "Raspberry Pi" + +CHIP_VARIANT = "bcm2711" diff --git a/ports/broadcom/boards/raspberrypi_cm4/pins.c b/ports/broadcom/boards/raspberrypi_cm4/pins.c new file mode 100644 index 0000000000..8999066cb3 --- /dev/null +++ b/ports/broadcom/boards/raspberrypi_cm4/pins.c @@ -0,0 +1,48 @@ +#include "shared-bindings/board/__init__.h" + +#include "shared-module/displayio/__init__.h" + +STATIC const mp_rom_map_elem_t board_global_dict_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + + // These match the names used in the CM4 datasheet + { MP_ROM_QSTR(MP_QSTR_ID_SD), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_ID_SC), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_GPIO2), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_GPIO3), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_GPIO4), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_GPIO5), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_GPIO6), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_GPIO7), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_GPIO8), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_GPIO9), MP_ROM_PTR(&pin_GPIO9) }, + + { MP_ROM_QSTR(MP_QSTR_GPIO10), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_GPIO11), MP_ROM_PTR(&pin_GPIO11) }, + { MP_ROM_QSTR(MP_QSTR_GPIO12), MP_ROM_PTR(&pin_GPIO12) }, + { MP_ROM_QSTR(MP_QSTR_GPIO13), MP_ROM_PTR(&pin_GPIO13) }, + { MP_ROM_QSTR(MP_QSTR_GPIO14), MP_ROM_PTR(&pin_GPIO14) }, + { MP_ROM_QSTR(MP_QSTR_GPIO15), MP_ROM_PTR(&pin_GPIO15) }, + + { MP_ROM_QSTR(MP_QSTR_GPIO16), MP_ROM_PTR(&pin_GPIO16) }, + { MP_ROM_QSTR(MP_QSTR_GPIO17), MP_ROM_PTR(&pin_GPIO17) }, + { MP_ROM_QSTR(MP_QSTR_GPIO18), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_GPIO19), MP_ROM_PTR(&pin_GPIO19) }, + { MP_ROM_QSTR(MP_QSTR_GPIO20), MP_ROM_PTR(&pin_GPIO20) }, + { MP_ROM_QSTR(MP_QSTR_GPIO21), MP_ROM_PTR(&pin_GPIO21) }, + { MP_ROM_QSTR(MP_QSTR_GPIO22), MP_ROM_PTR(&pin_GPIO22) }, + { MP_ROM_QSTR(MP_QSTR_GPIO23), MP_ROM_PTR(&pin_GPIO23) }, + { MP_ROM_QSTR(MP_QSTR_GPIO24), MP_ROM_PTR(&pin_GPIO24) }, + { MP_ROM_QSTR(MP_QSTR_GPIO25), MP_ROM_PTR(&pin_GPIO25) }, + { MP_ROM_QSTR(MP_QSTR_GPIO26), MP_ROM_PTR(&pin_GPIO26) }, + { MP_ROM_QSTR(MP_QSTR_GPIO27), MP_ROM_PTR(&pin_GPIO27) }, + + { MP_ROM_QSTR(MP_QSTR_LED_nACT), MP_ROM_PTR(&pin_GPIO42) }, + { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO42) }, + + { MP_ROM_QSTR(MP_QSTR_SDA0), MP_ROM_PTR(&pin_GPIO44) }, + { MP_ROM_QSTR(MP_QSTR_SCL0), MP_ROM_PTR(&pin_GPIO45) }, + + { MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display)}, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table); diff --git a/ports/broadcom/boards/raspberrypi_cm4io/mpconfigboard.h b/ports/broadcom/boards/raspberrypi_cm4io/mpconfigboard.h index 4211568bfa..9acfb32626 100644 --- a/ports/broadcom/boards/raspberrypi_cm4io/mpconfigboard.h +++ b/ports/broadcom/boards/raspberrypi_cm4io/mpconfigboard.h @@ -2,3 +2,5 @@ #define DEFAULT_I2C_BUS_SCL (&pin_GPIO3) #define DEFAULT_I2C_BUS_SDA (&pin_GPIO2) + +#define MICROPY_HW_LED_STATUS (&pin_GPIO42) diff --git a/ports/broadcom/boards/raspberrypi_cm4io/mpconfigboard.mk b/ports/broadcom/boards/raspberrypi_cm4io/mpconfigboard.mk index d430579260..d021462bc6 100644 --- a/ports/broadcom/boards/raspberrypi_cm4io/mpconfigboard.mk +++ b/ports/broadcom/boards/raspberrypi_cm4io/mpconfigboard.mk @@ -1,5 +1,5 @@ USB_VID = 0x2E8A -USB_PID = 0xf000 +USB_PID = 0x1012 USB_PRODUCT = "Compute Module 4 IO Board" USB_MANUFACTURER = "Raspberry Pi" diff --git a/ports/broadcom/boards/raspberrypi_cm4io/pins.c b/ports/broadcom/boards/raspberrypi_cm4io/pins.c index 0dfbe4cbd5..db4eb91710 100644 --- a/ports/broadcom/boards/raspberrypi_cm4io/pins.c +++ b/ports/broadcom/boards/raspberrypi_cm4io/pins.c @@ -57,6 +57,8 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_D26), MP_ROM_PTR(&pin_GPIO26) }, { MP_ROM_QSTR(MP_QSTR_D27), MP_ROM_PTR(&pin_GPIO27) }, + { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO42) }, + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display)}, }; diff --git a/ports/broadcom/boards/raspberrypi_pi4b/mpconfigboard.h b/ports/broadcom/boards/raspberrypi_pi4b/mpconfigboard.h index be77d35ac7..2980b0f9a5 100644 --- a/ports/broadcom/boards/raspberrypi_pi4b/mpconfigboard.h +++ b/ports/broadcom/boards/raspberrypi_pi4b/mpconfigboard.h @@ -2,3 +2,5 @@ #define DEFAULT_I2C_BUS_SCL (&pin_GPIO3) #define DEFAULT_I2C_BUS_SDA (&pin_GPIO2) + +#define MICROPY_HW_LED_STATUS (&pin_GPIO42) diff --git a/ports/broadcom/boards/raspberrypi_pi4b/mpconfigboard.mk b/ports/broadcom/boards/raspberrypi_pi4b/mpconfigboard.mk index 4567e9c15e..2c808931da 100644 --- a/ports/broadcom/boards/raspberrypi_pi4b/mpconfigboard.mk +++ b/ports/broadcom/boards/raspberrypi_pi4b/mpconfigboard.mk @@ -1,6 +1,6 @@ USB_VID = 0x2E8A -USB_PID = 0xF001 +USB_PID = 0x1013 USB_PRODUCT = "Raspberry Pi 4B" USB_MANUFACTURER = "Raspberry Pi" -CHIP_VARIANT = bcm2711 +CHIP_VARIANT = "bcm2711" diff --git a/ports/broadcom/boards/raspberrypi_pi4b/pins.c b/ports/broadcom/boards/raspberrypi_pi4b/pins.c index 0dfbe4cbd5..db4eb91710 100644 --- a/ports/broadcom/boards/raspberrypi_pi4b/pins.c +++ b/ports/broadcom/boards/raspberrypi_pi4b/pins.c @@ -57,6 +57,8 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_D26), MP_ROM_PTR(&pin_GPIO26) }, { MP_ROM_QSTR(MP_QSTR_D27), MP_ROM_PTR(&pin_GPIO27) }, + { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO42) }, + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display)}, }; diff --git a/ports/broadcom/boards/raspberrypi_zero/board.c b/ports/broadcom/boards/raspberrypi_zero/board.c new file mode 100644 index 0000000000..80bea7f8b6 --- /dev/null +++ b/ports/broadcom/boards/raspberrypi_zero/board.c @@ -0,0 +1,56 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "supervisor/board.h" +#include "mpconfigboard.h" + +#include "bindings/videocore/Framebuffer.h" +#include "shared-module/displayio/__init__.h" +#include "shared-bindings/framebufferio/FramebufferDisplay.h" + +void board_init(void) { + videocore_framebuffer_obj_t *fb = &allocate_display_bus()->videocore; + fb->base.type = &videocore_framebuffer_type; + common_hal_videocore_framebuffer_construct(fb, 640, 480); + + framebufferio_framebufferdisplay_obj_t *display = &displays[0].framebuffer_display; + display->base.type = &framebufferio_framebufferdisplay_type; + common_hal_framebufferio_framebufferdisplay_construct( + display, + MP_OBJ_FROM_PTR(fb), + 0, + true); +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { +} + +void board_deinit(void) { +} diff --git a/ports/broadcom/boards/raspberrypi_zero/mpconfigboard.h b/ports/broadcom/boards/raspberrypi_zero/mpconfigboard.h new file mode 100644 index 0000000000..1141520e06 --- /dev/null +++ b/ports/broadcom/boards/raspberrypi_zero/mpconfigboard.h @@ -0,0 +1,6 @@ +#define MICROPY_HW_BOARD_NAME "Raspberry Pi Zero" + +#define DEFAULT_I2C_BUS_SCL (&pin_GPIO3) +#define DEFAULT_I2C_BUS_SDA (&pin_GPIO2) + +#define MICROPY_HW_LED_STATUS (&pin_GPIO47) diff --git a/ports/broadcom/boards/raspberrypi_zero/mpconfigboard.mk b/ports/broadcom/boards/raspberrypi_zero/mpconfigboard.mk new file mode 100644 index 0000000000..74f8511c2d --- /dev/null +++ b/ports/broadcom/boards/raspberrypi_zero/mpconfigboard.mk @@ -0,0 +1,6 @@ +USB_VID = 0x2E8A +USB_PID = 0x100E +USB_PRODUCT = "Zero" +USB_MANUFACTURER = "Raspberry Pi" + +CHIP_VARIANT = "bcm2835" diff --git a/ports/broadcom/boards/raspberrypi_zero/pins.c b/ports/broadcom/boards/raspberrypi_zero/pins.c new file mode 100644 index 0000000000..bb6632b923 --- /dev/null +++ b/ports/broadcom/boards/raspberrypi_zero/pins.c @@ -0,0 +1,62 @@ +#include "shared-bindings/board/__init__.h" + +#include "shared-module/displayio/__init__.h" + +STATIC const mp_rom_map_elem_t board_global_dict_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + // These match the names used in Blinka + { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_GPIO1) }, + + { MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO3) }, + + { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_GPIO6) }, + + { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_CE1), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_CE0), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_GPIO11) }, + { MP_ROM_QSTR(MP_QSTR_SCLK), MP_ROM_PTR(&pin_GPIO11) }, + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO11) }, + + { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_GPIO12) }, + { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_GPIO13) }, + + { MP_ROM_QSTR(MP_QSTR_D14), MP_ROM_PTR(&pin_GPIO14) }, + { MP_ROM_QSTR(MP_QSTR_TXD), MP_ROM_PTR(&pin_GPIO14) }, + { MP_ROM_QSTR(MP_QSTR_D15), MP_ROM_PTR(&pin_GPIO15) }, + { MP_ROM_QSTR(MP_QSTR_RXD), MP_ROM_PTR(&pin_GPIO15) }, + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO14) }, + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO15) }, + + { MP_ROM_QSTR(MP_QSTR_D16), MP_ROM_PTR(&pin_GPIO16) }, + { MP_ROM_QSTR(MP_QSTR_D17), MP_ROM_PTR(&pin_GPIO17) }, + { MP_ROM_QSTR(MP_QSTR_D18), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_D19), MP_ROM_PTR(&pin_GPIO19) }, + { MP_ROM_QSTR(MP_QSTR_MISO_1), MP_ROM_PTR(&pin_GPIO19) }, + { MP_ROM_QSTR(MP_QSTR_D20), MP_ROM_PTR(&pin_GPIO20) }, + { MP_ROM_QSTR(MP_QSTR_MOSI_1), MP_ROM_PTR(&pin_GPIO20) }, + { MP_ROM_QSTR(MP_QSTR_D21), MP_ROM_PTR(&pin_GPIO21) }, + { MP_ROM_QSTR(MP_QSTR_SCLK_1), MP_ROM_PTR(&pin_GPIO21) }, + { MP_ROM_QSTR(MP_QSTR_SCK_1), MP_ROM_PTR(&pin_GPIO21) }, + { MP_ROM_QSTR(MP_QSTR_D22), MP_ROM_PTR(&pin_GPIO22) }, + { MP_ROM_QSTR(MP_QSTR_D23), MP_ROM_PTR(&pin_GPIO23) }, + { MP_ROM_QSTR(MP_QSTR_D24), MP_ROM_PTR(&pin_GPIO24) }, + { MP_ROM_QSTR(MP_QSTR_D25), MP_ROM_PTR(&pin_GPIO25) }, + { MP_ROM_QSTR(MP_QSTR_D26), MP_ROM_PTR(&pin_GPIO26) }, + { MP_ROM_QSTR(MP_QSTR_D27), MP_ROM_PTR(&pin_GPIO27) }, + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display)}, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table); diff --git a/ports/broadcom/boards/raspberrypi_zero2w/mpconfigboard.mk b/ports/broadcom/boards/raspberrypi_zero2w/mpconfigboard.mk index 8ba37dbba7..1479cb3b8c 100644 --- a/ports/broadcom/boards/raspberrypi_zero2w/mpconfigboard.mk +++ b/ports/broadcom/boards/raspberrypi_zero2w/mpconfigboard.mk @@ -1,6 +1,6 @@ USB_VID = 0x2E8A -USB_PID = 0xF002 +USB_PID = 0x1015 USB_PRODUCT = "Raspberry Pi Zero 2W" USB_MANUFACTURER = "Raspberry Pi" -CHIP_VARIANT = rp3a0 +CHIP_VARIANT = "bcm2837" diff --git a/ports/broadcom/boards/raspberrypi_zero_w/board.c b/ports/broadcom/boards/raspberrypi_zero_w/board.c new file mode 100644 index 0000000000..80bea7f8b6 --- /dev/null +++ b/ports/broadcom/boards/raspberrypi_zero_w/board.c @@ -0,0 +1,56 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "supervisor/board.h" +#include "mpconfigboard.h" + +#include "bindings/videocore/Framebuffer.h" +#include "shared-module/displayio/__init__.h" +#include "shared-bindings/framebufferio/FramebufferDisplay.h" + +void board_init(void) { + videocore_framebuffer_obj_t *fb = &allocate_display_bus()->videocore; + fb->base.type = &videocore_framebuffer_type; + common_hal_videocore_framebuffer_construct(fb, 640, 480); + + framebufferio_framebufferdisplay_obj_t *display = &displays[0].framebuffer_display; + display->base.type = &framebufferio_framebufferdisplay_type; + common_hal_framebufferio_framebufferdisplay_construct( + display, + MP_OBJ_FROM_PTR(fb), + 0, + true); +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { +} + +void board_deinit(void) { +} diff --git a/ports/broadcom/boards/raspberrypi_zero_w/mpconfigboard.h b/ports/broadcom/boards/raspberrypi_zero_w/mpconfigboard.h new file mode 100644 index 0000000000..389868f882 --- /dev/null +++ b/ports/broadcom/boards/raspberrypi_zero_w/mpconfigboard.h @@ -0,0 +1,6 @@ +#define MICROPY_HW_BOARD_NAME "Raspberry Pi Zero W" + +#define DEFAULT_I2C_BUS_SCL (&pin_GPIO3) +#define DEFAULT_I2C_BUS_SDA (&pin_GPIO2) + +#define MICROPY_HW_LED_STATUS (&pin_GPIO47) diff --git a/ports/broadcom/boards/raspberrypi_zero_w/mpconfigboard.mk b/ports/broadcom/boards/raspberrypi_zero_w/mpconfigboard.mk new file mode 100644 index 0000000000..24d09e0530 --- /dev/null +++ b/ports/broadcom/boards/raspberrypi_zero_w/mpconfigboard.mk @@ -0,0 +1,6 @@ +USB_VID = 0x2E8A +USB_PID = 0x101E +USB_PRODUCT = "Zero W" +USB_MANUFACTURER = "Raspberry Pi" + +CHIP_VARIANT = "bcm2835" diff --git a/ports/broadcom/boards/raspberrypi_zero_w/pins.c b/ports/broadcom/boards/raspberrypi_zero_w/pins.c new file mode 100644 index 0000000000..bb6632b923 --- /dev/null +++ b/ports/broadcom/boards/raspberrypi_zero_w/pins.c @@ -0,0 +1,62 @@ +#include "shared-bindings/board/__init__.h" + +#include "shared-module/displayio/__init__.h" + +STATIC const mp_rom_map_elem_t board_global_dict_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + // These match the names used in Blinka + { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_GPIO1) }, + + { MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO3) }, + + { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_GPIO6) }, + + { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_CE1), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_CE0), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_GPIO11) }, + { MP_ROM_QSTR(MP_QSTR_SCLK), MP_ROM_PTR(&pin_GPIO11) }, + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO11) }, + + { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_GPIO12) }, + { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_GPIO13) }, + + { MP_ROM_QSTR(MP_QSTR_D14), MP_ROM_PTR(&pin_GPIO14) }, + { MP_ROM_QSTR(MP_QSTR_TXD), MP_ROM_PTR(&pin_GPIO14) }, + { MP_ROM_QSTR(MP_QSTR_D15), MP_ROM_PTR(&pin_GPIO15) }, + { MP_ROM_QSTR(MP_QSTR_RXD), MP_ROM_PTR(&pin_GPIO15) }, + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO14) }, + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO15) }, + + { MP_ROM_QSTR(MP_QSTR_D16), MP_ROM_PTR(&pin_GPIO16) }, + { MP_ROM_QSTR(MP_QSTR_D17), MP_ROM_PTR(&pin_GPIO17) }, + { MP_ROM_QSTR(MP_QSTR_D18), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_D19), MP_ROM_PTR(&pin_GPIO19) }, + { MP_ROM_QSTR(MP_QSTR_MISO_1), MP_ROM_PTR(&pin_GPIO19) }, + { MP_ROM_QSTR(MP_QSTR_D20), MP_ROM_PTR(&pin_GPIO20) }, + { MP_ROM_QSTR(MP_QSTR_MOSI_1), MP_ROM_PTR(&pin_GPIO20) }, + { MP_ROM_QSTR(MP_QSTR_D21), MP_ROM_PTR(&pin_GPIO21) }, + { MP_ROM_QSTR(MP_QSTR_SCLK_1), MP_ROM_PTR(&pin_GPIO21) }, + { MP_ROM_QSTR(MP_QSTR_SCK_1), MP_ROM_PTR(&pin_GPIO21) }, + { MP_ROM_QSTR(MP_QSTR_D22), MP_ROM_PTR(&pin_GPIO22) }, + { MP_ROM_QSTR(MP_QSTR_D23), MP_ROM_PTR(&pin_GPIO23) }, + { MP_ROM_QSTR(MP_QSTR_D24), MP_ROM_PTR(&pin_GPIO24) }, + { MP_ROM_QSTR(MP_QSTR_D25), MP_ROM_PTR(&pin_GPIO25) }, + { MP_ROM_QSTR(MP_QSTR_D26), MP_ROM_PTR(&pin_GPIO26) }, + { MP_ROM_QSTR(MP_QSTR_D27), MP_ROM_PTR(&pin_GPIO27) }, + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display)}, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table); diff --git a/ports/broadcom/common-hal/busio/I2C.c b/ports/broadcom/common-hal/busio/I2C.c index 9726f394d2..e84810cffd 100644 --- a/ports/broadcom/common-hal/busio/I2C.c +++ b/ports/broadcom/common-hal/busio/I2C.c @@ -72,7 +72,8 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, uint8_t sda_alt = 0; for (scl_alt = 0; scl_alt < 6; scl_alt++) { if (scl->functions[scl_alt].type != PIN_FUNCTION_I2C || - i2c_in_use[scl->functions[scl_alt].index]) { + i2c_in_use[scl->functions[scl_alt].index] || + scl->functions[scl_alt].function != I2C_FUNCTION_SCL) { continue; } for (sda_alt = 0; sda_alt < 6; sda_alt++) { @@ -123,7 +124,7 @@ void common_hal_busio_i2c_deinit(busio_i2c_obj_t *self) { } bool common_hal_busio_i2c_probe(busio_i2c_obj_t *self, uint8_t addr) { - uint8_t result = common_hal_busio_i2c_write(self, addr, NULL, 0, true); + uint8_t result = common_hal_busio_i2c_write(self, addr, NULL, 0); return result == 0; } @@ -146,7 +147,7 @@ void common_hal_busio_i2c_unlock(busio_i2c_obj_t *self) { // Discussion of I2C implementation is here: https://github.com/raspberrypi/linux/issues/254 -uint8_t common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t addr, +STATIC uint8_t _common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t addr, const uint8_t *data, size_t len, bool transmit_stop_bit) { COMPLETE_MEMORY_READS; self->peripheral->S_b.DONE = true; @@ -201,6 +202,11 @@ uint8_t common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t addr, return 0; } +uint8_t common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t addr, + const uint8_t *data, size_t len) { + return _common_hal_busio_i2c_write(self, addr, data, len, true); +} + uint8_t common_hal_busio_i2c_read(busio_i2c_obj_t *self, uint16_t addr, uint8_t *data, size_t len) { COMPLETE_MEMORY_READS; @@ -246,6 +252,16 @@ uint8_t common_hal_busio_i2c_read(busio_i2c_obj_t *self, uint16_t addr, return 0; } +uint8_t common_hal_busio_i2c_write_read(busio_i2c_obj_t *self, uint16_t addr, + uint8_t *out_data, size_t out_len, uint8_t *in_data, size_t in_len) { + uint8_t result = _common_hal_busio_i2c_write(self, addr, out_data, out_len, false); + if (result != 0) { + return result; + } + + return common_hal_busio_i2c_read(self, addr, in_data, in_len); +} + void common_hal_busio_i2c_never_reset(busio_i2c_obj_t *self) { never_reset_i2c[self->index] = true; diff --git a/ports/broadcom/common-hal/busio/SPI.c b/ports/broadcom/common-hal/busio/SPI.c index 230bd487e9..feba34521d 100644 --- a/ports/broadcom/common-hal/busio/SPI.c +++ b/ports/broadcom/common-hal/busio/SPI.c @@ -34,28 +34,109 @@ #include "common-hal/microcontroller/Pin.h" #include "shared-bindings/microcontroller/Pin.h" -#define NO_INSTANCE 0xff +#include "peripherals/broadcom/cpu.h" +#include "peripherals/broadcom/defines.h" +#include "peripherals/broadcom/gpio.h" +#include "peripherals/broadcom/pins.h" +#include "peripherals/broadcom/vcmailbox.h" -STATIC bool never_reset_spi[2]; +#if BCM_VERSION == 2711 +#define NUM_SPI (7) +STATIC SPI0_Type *spi[NUM_SPI] = {SPI0, NULL, NULL, SPI3, SPI4, SPI5, SPI6}; +STATIC SPI1_Type *aux_spi[NUM_SPI] = {NULL, SPI1, SPI2, NULL, NULL, NULL, NULL}; +#else +#define NUM_SPI (3) +STATIC SPI0_Type *spi[NUM_SPI] = {SPI0, NULL, NULL}; +STATIC SPI1_Type *aux_spi[NUM_SPI] = {NULL, SPI1, SPI2}; +#endif + +STATIC bool never_reset_spi[NUM_SPI]; +STATIC bool spi_in_use[NUM_SPI]; void reset_spi(void) { - for (size_t i = 0; i < 2; i++) { + for (size_t i = 0; i < NUM_SPI; i++) { if (never_reset_spi[i]) { continue; } - // TODO + if (i == 1 || i == 2) { + if (i == 1) { + AUX->ENABLES_b.SPI_1 = false; + } else { + AUX->ENABLES_b.SPI_2 = false; + } + aux_spi[i]->CNTL0 = 0; + } else { + // Set CS back to default. All 0 except read enable. + spi[i]->CS = SPI0_CS_REN_Msk; + } + + spi_in_use[i] = false; } } void common_hal_busio_spi_construct(busio_spi_obj_t *self, const mcu_pin_obj_t *clock, const mcu_pin_obj_t *mosi, - const mcu_pin_obj_t *miso) { + const mcu_pin_obj_t *miso, bool half_duplex) { + size_t instance_index = NUM_SPI; + BP_Function_Enum clock_alt = 0; + BP_Function_Enum mosi_alt = 0; + BP_Function_Enum miso_alt = 0; + if (half_duplex) { + mp_raise_NotImplementedError(translate("Half duplex SPI is not implemented")); + } + + for (size_t i = 0; i < NUM_SPI; i++) { + if (spi_in_use[i]) { + continue; + } + if (!pin_find_alt(clock, PIN_FUNCTION_SPI, i, SPI_FUNCTION_SCLK, &clock_alt)) { + continue; + } + if (mosi != NULL && !pin_find_alt(mosi, PIN_FUNCTION_SPI, i, SPI_FUNCTION_MOSI, &mosi_alt)) { + continue; + } + if (miso != NULL && !pin_find_alt(miso, PIN_FUNCTION_SPI, i, SPI_FUNCTION_MISO, &miso_alt)) { + continue; + } + instance_index = i; + break; + } + if (instance_index == NUM_SPI) { + mp_raise_ValueError(translate("Invalid pins")); + } + + self->clock = clock; + self->MOSI = mosi; + self->MISO = miso; + self->index = instance_index; + spi_in_use[instance_index] = true; + + + if (instance_index == 1) { + AUX->ENABLES_b.SPI_1 = true; + } else if (instance_index == 2) { + AUX->ENABLES_b.SPI_2 = true; + } + + common_hal_busio_spi_configure(self, 250000, 0, 0, 8); + + COMPLETE_MEMORY_READS; + gpio_set_pull(clock->number, BP_PULL_NONE); + gpio_set_function(clock->number, clock_alt); + if (mosi != NULL) { + gpio_set_pull(mosi->number, BP_PULL_NONE); + gpio_set_function(mosi->number, mosi_alt); + } + if (miso != NULL) { + gpio_set_pull(miso->number, BP_PULL_NONE); + gpio_set_function(miso->number, miso_alt); + } } void common_hal_busio_spi_never_reset(busio_spi_obj_t *self) { - // never_reset_spi[spi_get_index(self->peripheral)] = true; + never_reset_spi[self->index] = true; common_hal_never_reset_pin(self->clock); common_hal_never_reset_pin(self->MOSI); @@ -70,12 +151,22 @@ void common_hal_busio_spi_deinit(busio_spi_obj_t *self) { if (common_hal_busio_spi_deinited(self)) { return; } - // never_reset_spi[spi_get_index(self->peripheral)] = false; + never_reset_spi[self->index] = false; common_hal_reset_pin(self->clock); common_hal_reset_pin(self->MOSI); common_hal_reset_pin(self->MISO); self->clock = NULL; + + if (self->index == 1 || + self->index == 2) { + aux_spi[self->index]->CNTL0_b.ENABLE = false; + if (self->index == 1) { + AUX->ENABLES_b.SPI_1 = false; + } else if (self->index == 2) { + AUX->ENABLES_b.SPI_2 = false; + } + } } bool common_hal_busio_spi_configure(busio_spi_obj_t *self, @@ -87,13 +178,40 @@ bool common_hal_busio_spi_configure(busio_spi_obj_t *self, return true; } - // TODO + if (self->index == 1 || self->index == 2) { + SPI1_Type *p = aux_spi[self->index]; + uint32_t source_clock = vcmailbox_get_clock_rate_measured(VCMAILBOX_CLOCK_CORE); + uint16_t clock_divider = source_clock / baudrate; + if (source_clock % baudrate > 0) { + clock_divider += 2; + } + + p->CNTL0 = (clock_divider / 2 - 1) << SPI1_CNTL0_SPEED_Pos | + SPI1_CNTL0_ENABLE_Msk | + SPI1_CNTL0_MSB_FIRST_Msk | + (polarity == 1? SPI1_CNTL0_INVERT_CLK_Msk : 0) | + (phase == polarity? SPI1_CNTL0_IN_RISING_Msk : SPI1_CNTL0_OUT_RISING_Msk) | + 8 << SPI1_CNTL0_SHIFT_LENGTH_Pos; + p->CNTL1 = SPI1_CNTL1_MSB_FIRST_Msk; + self->real_frequency = source_clock / clock_divider; + } else { + SPI0_Type *p = spi[self->index]; + p->CS = polarity << SPI0_CS_CPOL_Pos | + phase << SPI0_CS_CPHA_Pos; + uint32_t source_clock = vcmailbox_get_clock_rate_measured(VCMAILBOX_CLOCK_CORE); + uint16_t clock_divider = source_clock / baudrate; + if (source_clock % baudrate > 0) { + clock_divider += 2; + } + + p->CLK = clock_divider; + self->real_frequency = source_clock / clock_divider; + } self->polarity = polarity; self->phase = phase; self->bits = bits; self->target_frequency = baudrate; - self->real_frequency = baudrate; // TODO return true; } @@ -115,18 +233,103 @@ void common_hal_busio_spi_unlock(busio_spi_obj_t *self) { self->has_lock = false; } +STATIC void _spi_transfer(SPI0_Type *p, + const uint8_t *data_out, size_t out_len, + uint8_t *data_in, size_t in_len) { + size_t len = MAX(out_len, in_len); + COMPLETE_MEMORY_READS; + p->DLEN = len; + p->CS |= SPI0_CS_TA_Msk | SPI0_CS_CLEAR_Msk; + size_t in = 0; + size_t out = 0; + while (in < len) { + while (out < len && p->CS_b.TXD == 1) { + if (out_len == 1) { + p->FIFO = data_out[0]; + } else { + p->FIFO = data_out[out]; + } + out++; + } + // Wait for data to read (also means data has been sent.) + while (p->CS_b.RXD == 0) { + RUN_BACKGROUND_TASKS; + } + while (p->CS_b.RXD == 1) { + uint8_t data = p->FIFO; + if (data_in != NULL) { + data_in[in] = data; + } else { + (void)data; + } + in++; + } + } + p->CS_b.TA = false; + COMPLETE_MEMORY_READS; +} + +STATIC void _aux_spi_transfer(SPI1_Type *p, + const uint8_t *data_out, size_t out_len, + uint8_t *data_in, size_t in_len) { + size_t len = MAX(out_len, in_len); + p->CNTL0 |= SPI1_CNTL0_CLEAR_FIFOS_Msk; + p->CNTL0 &= ~SPI1_CNTL0_CLEAR_FIFOS_Msk; + size_t in = 0; + size_t out = 0; + while (in < len) { + while (out < len && p->STAT_b.TX_FULL == 0) { + if (out_len == 1) { + p->TXHOLD0 = data_out[0] << 24; + } else { + p->TXHOLD0 = data_out[out] << 24; + } + out++; + } + // Wait for data to read (also means data has been sent.) + while (p->STAT_b.RX_EMPTY == 1) { + RUN_BACKGROUND_TASKS; + } + while (p->STAT_b.RX_EMPTY == 0) { + uint8_t data = p->TXHOLD0; + if (data_in != NULL) { + data_in[in] = data; + } else { + (void)data; + } + in++; + } + } +} + bool common_hal_busio_spi_write(busio_spi_obj_t *self, const uint8_t *data, size_t len) { - return false; + if (self->index == 1 || self->index == 2) { + _aux_spi_transfer(aux_spi[self->index], data, len, NULL, 0); + } else { + _spi_transfer(spi[self->index], data, len, NULL, 0); + } + return true; } bool common_hal_busio_spi_read(busio_spi_obj_t *self, uint8_t *data, size_t len, uint8_t write_value) { - return false; + if (self->index == 1 || self->index == 2) { + _aux_spi_transfer(aux_spi[self->index], &write_value, 1, data, len); + } else { + _spi_transfer(spi[self->index], &write_value, 1, data, len); + } + return true; } -bool common_hal_busio_spi_transfer(busio_spi_obj_t *self, const uint8_t *data_out, uint8_t *data_in, size_t len) { - return false; +bool common_hal_busio_spi_transfer(busio_spi_obj_t *self, + const uint8_t *data_out, uint8_t *data_in, size_t len) { + if (self->index == 1 || self->index == 2) { + _aux_spi_transfer(aux_spi[self->index], data_out, len, data_in, len); + } else { + _spi_transfer(spi[self->index], data_out, len, data_in, len); + } + return true; } uint32_t common_hal_busio_spi_get_frequency(busio_spi_obj_t *self) { diff --git a/ports/broadcom/common-hal/busio/SPI.h b/ports/broadcom/common-hal/busio/SPI.h index 0bdbf2d8e7..d1d5fbaf69 100644 --- a/ports/broadcom/common-hal/busio/SPI.h +++ b/ports/broadcom/common-hal/busio/SPI.h @@ -42,6 +42,7 @@ typedef struct { uint8_t polarity; uint8_t phase; uint8_t bits; + uint8_t index; } busio_spi_obj_t; void reset_spi(void); diff --git a/ports/broadcom/common-hal/busio/UART.c b/ports/broadcom/common-hal/busio/UART.c index 85dc36e755..ff17d5ff1d 100644 --- a/ports/broadcom/common-hal/busio/UART.c +++ b/ports/broadcom/common-hal/busio/UART.c @@ -41,7 +41,14 @@ #define NO_PIN 0xff -#define UART_INST(uart) (((uart) ? uart1 : uart0)) +// UART1 is a different peripheral than the rest so it is hardcoded below. +#if BCM_VERSION == 2711 +#define NUM_UART (6) +STATIC ARM_UART_PL011_Type *uart[NUM_UART] = {UART0, NULL, UART2, UART3, UART4, UART5}; +#else +#define NUM_UART (2) +STATIC ARM_UART_PL011_Type *uart[NUM_UART] = {UART0, NULL}; +#endif typedef enum { STATUS_FREE = 0, @@ -49,29 +56,62 @@ typedef enum { STATUS_NEVER_RESET } uart_status_t; -// The Broadcom chips have two different types of UARTs. UART1 is the "mini-UART" -// that is most available so we've implemented it first. The ARM PL011 UART -// support will be added later. We set NUM_UARTS to 2 here so that we can match -// the indexing even though UART0 isn't supported yet. We currently use this -// UART for debugging so we don't support user use of UART yet. -#define NUM_UARTS 2 - -static uart_status_t uart_status[NUM_UARTS]; +static uart_status_t uart_status[NUM_UART]; +static busio_uart_obj_t *active_uart[NUM_UART]; void reset_uart(void) { - for (uint8_t num = 0; num < NUM_UARTS; num++) { + bool any_pl011_active = false; + for (uint8_t num = 0; num < NUM_UART; num++) { if (uart_status[num] == STATUS_BUSY) { + if (num == 1) { + UART1->IER_b.DATA_READY = false; + UART1->CNTL = 0; + COMPLETE_MEMORY_READS; + AUX->ENABLES_b.UART_1 = false; + } else { + ARM_UART_PL011_Type *pl011 = uart[num]; + pl011->CR = 0; + } + active_uart[num] = NULL; uart_status[num] = STATUS_FREE; + } else { + any_pl011_active = any_pl011_active || (num != 1 && uart_status[num] == STATUS_NEVER_RESET); + } + } + if (!any_pl011_active) { + BP_DisableIRQ(UART_IRQn); + } + COMPLETE_MEMORY_READS; + if (AUX->ENABLES == 0) { + BP_DisableIRQ(AUX_IRQn); + } +} + +STATIC void fetch_all_from_fifo(busio_uart_obj_t *self) { + if (self->uart_id == 1) { + while (UART1->STAT_b.DATA_READY && ringbuf_num_empty(&self->ringbuf) > 0) { + int c = UART1->IO_b.DATA; + if (self->sigint_enabled && c == mp_interrupt_char) { + mp_sched_keyboard_interrupt(); + continue; + } + ringbuf_put(&self->ringbuf, c); + } + } else { + ARM_UART_PL011_Type *pl011 = uart[self->uart_id]; + while (!pl011->FR_b.RXFE && ringbuf_num_empty(&self->ringbuf) > 0) { + int c = pl011->DR_b.DATA; + if (self->sigint_enabled && c == mp_interrupt_char) { + mp_sched_keyboard_interrupt(); + continue; + } + ringbuf_put(&self->ringbuf, c); } } } -static busio_uart_obj_t *active_uarts[NUM_UARTS]; - void UART1_IRQHandler(void) { - while (UART1->STAT_b.DATA_READY && ringbuf_num_empty(&active_uarts[1]->ringbuf) > 0) { - ringbuf_put(&active_uarts[1]->ringbuf, (uint8_t)UART1->IO_b.DATA); - } + fetch_all_from_fifo(active_uart[1]); // We couldn't read all pending data (overrun) so clear the FIFO so that the interrupt // can finish. if (UART1->STAT_b.DATA_READY) { @@ -79,8 +119,39 @@ void UART1_IRQHandler(void) { } } +void pl011_IRQHandler(uint8_t index) { + fetch_all_from_fifo(active_uart[index]); + // Clear the interrupt in case we weren't able to clear it by emptying the + // FIFO. (This won't clear the FIFO.) + ARM_UART_PL011_Type *pl011 = uart[index]; + pl011->ICR = UART0_ICR_RXIC_Msk; +} + +void UART0_IRQHandler(void) { + pl011_IRQHandler(0); +} + +#if BCM_VERSION == 2711 +void UART2_IRQHandler(void) { + pl011_IRQHandler(2); +} +void UART3_IRQHandler(void) { + pl011_IRQHandler(3); +} +void UART4_IRQHandler(void) { + pl011_IRQHandler(4); +} +void UART5_IRQHandler(void) { + pl011_IRQHandler(5); +} +#endif + void common_hal_busio_uart_never_reset(busio_uart_obj_t *self) { uart_status[self->uart_id] = STATUS_NEVER_RESET; + common_hal_never_reset_pin(self->tx_pin); + common_hal_never_reset_pin(self->rx_pin); + common_hal_never_reset_pin(self->cts_pin); + common_hal_never_reset_pin(self->rts_pin); } void common_hal_busio_uart_construct(busio_uart_obj_t *self, @@ -103,14 +174,43 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, mp_raise_NotImplementedError(translate("RS485 Not yet supported on this device")); } - if (tx == &pin_GPIO14) { - if (rx == &pin_GPIO15) { - self->uart_id = 1; + size_t instance_index = NUM_UART; + BP_Function_Enum tx_alt = 0; + BP_Function_Enum rx_alt = 0; + BP_Function_Enum rts_alt = 0; + BP_Function_Enum cts_alt = 0; + for (size_t i = 0; i < NUM_UART; i++) { + if (uart_status[i] != STATUS_FREE) { + continue; } + if (tx != NULL) { + if (!pin_find_alt(tx, PIN_FUNCTION_UART, i, UART_FUNCTION_TXD, &tx_alt)) { + continue; + } + if (rts != NULL && !pin_find_alt(rts, PIN_FUNCTION_UART, i, UART_FUNCTION_RTS, &rts_alt)) { + continue; + } + } + if (rx != NULL) { + if (!pin_find_alt(rx, PIN_FUNCTION_UART, i, UART_FUNCTION_RXD, &rx_alt)) { + continue; + } + if (cts != NULL && !pin_find_alt(cts, PIN_FUNCTION_UART, i, UART_FUNCTION_CTS, &cts_alt)) { + continue; + } + } + instance_index = i; + break; + } + if (instance_index == NUM_UART) { + mp_raise_ValueError(translate("Invalid pins")); } self->rx_pin = rx; self->tx_pin = tx; + self->rts_pin = rts; + self->cts_pin = cts; + self->sigint_enabled = sigint_enabled; if (rx != NULL) { if (receiver_buffer != NULL) { @@ -129,8 +229,11 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, } } + active_uart[self->uart_id] = self; + + ARM_UART_PL011_Type *pl011 = uart[self->uart_id]; + if (self->uart_id == 1) { - active_uarts[1] = self; AUX->ENABLES_b.UART_1 = true; UART1->IER = 0; @@ -145,22 +248,80 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, // Clear interrupts UART1->IIR = 0xff; - uint32_t source_clock = vcmailbox_get_clock_rate_measured(VCMAILBOX_CLOCK_CORE); - UART1->BAUD = ((source_clock / (baudrate * 8)) - 1); + common_hal_busio_uart_set_baudrate(self, baudrate); if (tx != NULL) { UART1->CNTL |= UART1_CNTL_TX_ENABLE_Msk; - gpio_set_pull(14, BP_PULL_NONE); - gpio_set_function(14, GPIO_GPFSEL1_FSEL14_TXD1); } if (rx != NULL) { UART1->CNTL |= UART1_CNTL_RX_ENABLE_Msk; - gpio_set_pull(15, BP_PULL_NONE); - gpio_set_function(15, GPIO_GPFSEL1_FSEL15_RXD1); } + } else { + // Ensure the UART is disabled as we configure it. + pl011->CR_b.UARTEN = false; + pl011->IMSC = 0; + pl011->ICR = 0x3ff; + + common_hal_busio_uart_set_baudrate(self, baudrate); + + uint32_t line_control = UART0_LCR_H_FEN_Msk; + line_control |= (bits - 5) << UART0_LCR_H_WLEN_Pos; + if (stop == 2) { + line_control |= UART0_LCR_H_STP2_Msk; + } + if (parity != BUSIO_UART_PARITY_NONE) { + line_control |= UART0_LCR_H_PEN_Msk; + } + if (parity == BUSIO_UART_PARITY_EVEN) { + line_control |= UART0_LCR_H_EPS_Msk; + } + pl011->LCR_H = line_control; + + uint32_t control = UART0_CR_UARTEN_Msk; + if (tx != NULL) { + control |= UART0_CR_TXE_Msk; + } + if (rx != NULL) { + control |= UART0_CR_RXE_Msk; + } + if (cts != NULL) { + control |= UART0_CR_CTSEN_Msk; + } + if (rts != NULL) { + control |= UART0_CR_RTSEN_Msk; + } + pl011->CR = control; + } + + // Setup the pins after waiting for UART stuff + COMPLETE_MEMORY_READS; + if (tx != NULL) { + gpio_set_pull(tx->number, BP_PULL_NONE); + gpio_set_function(tx->number, tx_alt); + } + if (rx != NULL) { + gpio_set_pull(rx->number, BP_PULL_NONE); + gpio_set_function(rx->number, rx_alt); + } + if (rts != NULL) { + gpio_set_pull(rts->number, BP_PULL_NONE); + gpio_set_function(rts->number, rts_alt); + } + if (cts != NULL) { + gpio_set_pull(cts->number, BP_PULL_NONE); + gpio_set_function(cts->number, cts_alt); + } + + // Turn on interrupts + COMPLETE_MEMORY_READS; + if (self->uart_id == 1) { UART1->IER_b.DATA_READY = true; // Never disable this in case the SPIs are used. They can each be // disabled at the peripheral itself. BP_EnableIRQ(AUX_IRQn); + } else { + pl011->IMSC_b.RXIM = true; + // Never disable this in case the other PL011 UARTs are used. + BP_EnableIRQ(UART_IRQn); } } @@ -176,8 +337,11 @@ void common_hal_busio_uart_deinit(busio_uart_obj_t *self) { UART1->IER_b.DATA_READY = false; UART1->CNTL = 0; AUX->ENABLES_b.UART_1 = false; - active_uarts[1] = NULL; + } else { + ARM_UART_PL011_Type *pl011 = uart[self->uart_id]; + pl011->CR = 0; } + active_uart[self->uart_id] = NULL; ringbuf_free(&self->ringbuf); uart_status[self->uart_id] = STATUS_FREE; common_hal_reset_pin(self->tx_pin); @@ -196,20 +360,46 @@ size_t common_hal_busio_uart_write(busio_uart_obj_t *self, const uint8_t *data, mp_raise_ValueError(translate("No TX pin")); } - if (self->uart_id == 1) { - COMPLETE_MEMORY_READS; - for (size_t i = 0; i < len; i++) { + COMPLETE_MEMORY_READS; + ARM_UART_PL011_Type *pl011 = uart[self->uart_id]; + for (size_t i = 0; i < len; i++) { + if (self->uart_id == 1) { // Wait for the FIFO to have space. while (!UART1->STAT_b.TX_READY) { RUN_BACKGROUND_TASKS; } UART1->IO = data[i]; + } else { + while (pl011->FR_b.TXFF) { + RUN_BACKGROUND_TASKS; + } + pl011->DR_b.DATA = data[i]; } - COMPLETE_MEMORY_READS; - return len; } + // Wait for the data to be shifted out + if (self->uart_id == 1) { + while (!UART1->STAT_b.TX_DONE) { + RUN_BACKGROUND_TASKS; + } + } else { + while (pl011->FR_b.BUSY) { + RUN_BACKGROUND_TASKS; + } + } + COMPLETE_MEMORY_READS; + return len; +} - return 0; +STATIC void disable_interrupt(busio_uart_obj_t *self) { + if (self->uart_id == 1) { + UART1->IER_b.DATA_READY = false; + } +} + +STATIC void enable_interrupt(busio_uart_obj_t *self) { + if (self->uart_id == 1) { + UART1->IER_b.DATA_READY = true; + } } // Read characters. @@ -225,9 +415,7 @@ size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t COMPLETE_MEMORY_READS; // Prevent conflict with uart irq. - if (self->uart_id == 1) { - UART1->IER_b.DATA_READY = false; - } + disable_interrupt(self); // Copy as much received data as available, up to len bytes. size_t total_read = ringbuf_get_n(&self->ringbuf, data, len); @@ -238,14 +426,11 @@ size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t uint64_t start_ticks = supervisor_ticks_ms64(); // Busy-wait until timeout or until we've read enough chars. while (len > 0 && (supervisor_ticks_ms64() - start_ticks < self->timeout_ms)) { - if (UART1->STAT_b.DATA_READY) { - // Read and advance. - data[total_read] = UART1->IO_b.DATA; - - // Adjust the counters. - len--; - total_read++; - + fetch_all_from_fifo(self); + size_t additional_read = ringbuf_get_n(&self->ringbuf, data + total_read, len); + len -= additional_read; + total_read += additional_read; + if (additional_read > 0) { // Reset the timeout on every character read. start_ticks = supervisor_ticks_ms64(); } @@ -260,14 +445,10 @@ size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t // Now that we've emptied the ringbuf some, fill it up with anything in the // FIFO. This ensures that we'll empty the FIFO as much as possible and // reset the interrupt when we catch up. - while (UART1->STAT_b.DATA_READY && ringbuf_num_empty(&self->ringbuf) > 0) { - ringbuf_put(&self->ringbuf, (uint8_t)UART1->IO_b.DATA); - } + fetch_all_from_fifo(self); // Re-enable irq. - if (self->uart_id == 1) { - UART1->IER_b.DATA_READY = true; - } + enable_interrupt(self); COMPLETE_MEMORY_READS; if (total_read == 0) { @@ -283,6 +464,31 @@ uint32_t common_hal_busio_uart_get_baudrate(busio_uart_obj_t *self) { } void common_hal_busio_uart_set_baudrate(busio_uart_obj_t *self, uint32_t baudrate) { + if (self->uart_id == 1) { + uint32_t source_clock = vcmailbox_get_clock_rate_measured(VCMAILBOX_CLOCK_CORE); + UART1->BAUD = ((source_clock / (baudrate * 8)) - 1); + } else { + ARM_UART_PL011_Type *pl011 = uart[self->uart_id]; + bool reenable = false; + if (pl011->CR_b.UARTEN) { + pl011->CR_b.UARTEN = false; + reenable = true; + } + uint32_t source_clock = vcmailbox_get_clock_rate_measured(VCMAILBOX_CLOCK_UART); + uint32_t divisor = 16 * baudrate; + pl011->IBRD = source_clock / divisor; + // The fractional divisor is 64ths. + uint32_t remainder = source_clock % divisor; + uint32_t per_tick = (divisor / 64) + 1; + uint32_t adjust = 0; + if (remainder % per_tick > 0) { + adjust = 1; + } + pl011->FBRD = remainder / per_tick + adjust; + if (reenable) { + pl011->CR_b.UARTEN = true; + } + } self->baudrate = baudrate; } @@ -295,6 +501,7 @@ void common_hal_busio_uart_set_timeout(busio_uart_obj_t *self, mp_float_t timeou } uint32_t common_hal_busio_uart_rx_characters_available(busio_uart_obj_t *self) { + fetch_all_from_fifo(self); return ringbuf_num_filled(&self->ringbuf); } @@ -309,5 +516,5 @@ bool common_hal_busio_uart_ready_to_tx(busio_uart_obj_t *self) { if (self->uart_id == 1) { return UART1->STAT_b.TX_READY; } - return false; + return !uart[self->uart_id]->FR_b.TXFF; } diff --git a/ports/broadcom/common-hal/busio/UART.h b/ports/broadcom/common-hal/busio/UART.h index 8ef4073f8e..0590bc28b6 100644 --- a/ports/broadcom/common-hal/busio/UART.h +++ b/ports/broadcom/common-hal/busio/UART.h @@ -39,6 +39,7 @@ typedef struct { uint8_t uart_id; uint32_t baudrate; uint32_t timeout_ms; + bool sigint_enabled; ringbuf_t ringbuf; } busio_uart_obj_t; diff --git a/ports/broadcom/common-hal/microcontroller/Pin.c b/ports/broadcom/common-hal/microcontroller/Pin.c index d1e5627bcd..82963f5633 100644 --- a/ports/broadcom/common-hal/microcontroller/Pin.c +++ b/ports/broadcom/common-hal/microcontroller/Pin.c @@ -45,11 +45,16 @@ void never_reset_pin_number(uint8_t pin_number) { } void reset_pin_number(uint8_t pin_number) { - gpio_set_function(pin_number, GPIO_FUNCTION_INPUT); pin_in_use[pin_number] = false; never_reset_pin[pin_number] = false; - // Set the pull to match the datasheet. + // Reset JTAG pins back to JTAG. BP_PULL_Enum pull = BP_PULL_NONE; + if (22 <= pin_number && pin_number <= 27) { + gpio_set_function(pin_number, GPIO_FUNCTION_ALT4); + } else { + gpio_set_function(pin_number, GPIO_FUNCTION_INPUT); + } + // Set the pull to match the datasheet. if (pin_number < 9 || (33 < pin_number && pin_number < 37) || pin_number > 45) { @@ -59,17 +64,23 @@ void reset_pin_number(uint8_t pin_number) { pin_number != 44 && pin_number != 45) { // Most pins are pulled low so we only exclude the four pins that aren't - // pulled at all. + // pulled at all. This will also set the JTAG pins 22-27 pull = BP_PULL_DOWN; } gpio_set_pull(pin_number, pull); } void common_hal_never_reset_pin(const mcu_pin_obj_t *pin) { + if (pin == NULL) { + return; + } never_reset_pin_number(pin->number); } void common_hal_reset_pin(const mcu_pin_obj_t *pin) { + if (pin == NULL) { + return; + } reset_pin_number(pin->number); } diff --git a/ports/broadcom/common-hal/microcontroller/__init__.c b/ports/broadcom/common-hal/microcontroller/__init__.c index e6f7b9c737..a1491d9668 100644 --- a/ports/broadcom/common-hal/microcontroller/__init__.c +++ b/ports/broadcom/common-hal/microcontroller/__init__.c @@ -29,6 +29,7 @@ #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/microcontroller/Processor.h" #include "common-hal/microcontroller/__init__.h" +#include "peripherals/broadcom/defines.h" #include "peripherals/broadcom/interrupts.h" #include "mphalport.h" diff --git a/ports/broadcom/common-hal/neopixel_write/__init__.c b/ports/broadcom/common-hal/neopixel_write/__init__.c new file mode 100644 index 0000000000..0cd76ebca9 --- /dev/null +++ b/ports/broadcom/common-hal/neopixel_write/__init__.c @@ -0,0 +1,160 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "shared-bindings/neopixel_write/__init__.h" + +#include "py/runtime.h" + +#include "shared-bindings/microcontroller/__init__.h" +#include "shared-bindings/digitalio/DigitalInOut.h" +#include "shared-bindings/time/__init__.h" + +#include "peripherals/broadcom/cpu.h" + +#include "supervisor/port.h" + +uint64_t next_start_raw_ticks = 0; + +// NeoPixels are 800khz bit streams. Zeroes are 1/3 duty cycle (~416ns) and ones +// are 2/3 duty cycle (~833ns). + +void common_hal_neopixel_write(const digitalio_digitalinout_obj_t *digitalinout, + uint8_t *pixels, uint32_t num_bytes) { + // Wait to make sure we don't append onto the last transmission. This should only be a tick or + // two. + while (port_get_raw_ticks(NULL) < next_start_raw_ticks) { + } + + BP_Function_Enum alt_function = GPIO_FUNCTION_OUTPUT; + uint8_t index = 0; + uint8_t channel = 0; + bool found = false; + for (size_t i = 0; i < NUM_ALT_FUNC; i++) { + const pin_function_t *f = &digitalinout->pin->functions[i]; + if (f->type == PIN_FUNCTION_PWM) { + index = f->index; + channel = f->function; + alt_function = FSEL_VALUES[i]; + found = true; + break; + } + } + if (!found) { + mp_raise_ValueError(translate("NeoPixel not supported on pin")); + return; + } + + // Turn on the PWM clock. The speed is NeoPixel specific. + if (CM_PWM->CS_b.BUSY == 0) { + uint32_t source_clock; + #if BCM_VERSION == 2711 + source_clock = 54000000; + #else + source_clock = 19200000; + #endif + // Three clocks per 800khz bit to get the 1/3 or 2/3 timing. + uint32_t target_clock = 3 * 800000; + uint32_t int_div = source_clock / target_clock; + + CM_PWM->DIV = CM_PCM_DIV_PASSWD_PASSWD << CM_PCM_DIV_PASSWD_Pos | + (int_div) << CM_PCM_DIV_DIVI_Pos; + + CM_PWM->CS = CM_PCM_CS_PASSWD_PASSWD << CM_PCM_CS_PASSWD_Pos | + CM_PCM_CS_SRC_XOSC << CM_PCM_CS_SRC_Pos; + + // Set enable after setting the source to ensure it is stable. + CM_PWM->CS = CM_PCM_CS_PASSWD_PASSWD << CM_PCM_CS_PASSWD_Pos | + CM_PCM_CS_SRC_XOSC << CM_PCM_CS_SRC_Pos | + CM_PCM_CS_ENAB_Msk; + + // Wait for the clock to start up. + COMPLETE_MEMORY_READS; + while (CM_PWM->CS_b.BUSY == 0) { + } + } + + PWM0_Type *pwm = PWM0; + #if BCM_VERSION == 2711 + if (index == 1) { + pwm = PWM1; + } + #else + (void)index; + #endif + + pwm->RNG1 = 24; + pwm->RNG2 = 24; + COMPLETE_MEMORY_READS; + pwm->CTL = PWM0_CTL_CLRF1_Msk; + COMPLETE_MEMORY_READS; + + // Even though we're only transmitting one channel, we enable both. Without + // the second channel enabled, the output is repeated forever. + pwm->CTL = + PWM0_CTL_USEF2_Msk | + PWM0_CTL_MODE2_Msk | + PWM0_CTL_USEF1_Msk | + PWM0_CTL_MODE1_Msk; + + COMPLETE_MEMORY_READS; + pwm->CTL |= PWM0_CTL_PWEN1_Msk | PWM0_CTL_PWEN2_Msk; + + gpio_set_function(digitalinout->pin->number, alt_function); + + for (size_t i = 0; i < num_bytes; i++) { + uint32_t expanded = 0; + for (size_t j = 0; j < 8; j++) { + expanded = expanded >> 3; + if ((pixels[i] & (1 << j)) != 0) { + expanded |= 0xc0000000; + } else { + expanded |= 0x80000000; + } + } + while (pwm->STA_b.FULL1 == 1) { + RUN_BACKGROUND_TASKS; + } + if (channel == 1) { + // Dummy value for the first channel. + pwm->FIF1 = 0x000000; + } + pwm->FIF1 = expanded; + if (channel == 0) { + // Dummy value for the second channel. + pwm->FIF1 = 0x000000; + } + } + // Wait just a little bit so that transmission can start. + common_hal_mcu_delay_us(2); + while (pwm->STA_b.STA1 == 1) { + RUN_BACKGROUND_TASKS; + } + + gpio_set_function(digitalinout->pin->number, GPIO_FUNCTION_OUTPUT); + + // Update the next start. + next_start_raw_ticks = port_get_raw_ticks(NULL) + 1; +} diff --git a/ports/broadcom/common-hal/sdioio/SDCard.c b/ports/broadcom/common-hal/sdioio/SDCard.c index 492d28d6d6..85a84ac213 100644 --- a/ports/broadcom/common-hal/sdioio/SDCard.c +++ b/ports/broadcom/common-hal/sdioio/SDCard.c @@ -37,6 +37,7 @@ #include "supervisor/port.h" #include "supervisor/shared/translate.h" +#include "peripherals/broadcom/cpu.h" #include "peripherals/broadcom/defines.h" #include "peripherals/broadcom/gpio.h" @@ -235,21 +236,29 @@ void common_hal_sdioio_sdcard_construct(sdioio_sdcard_obj_t *self, if (clock != NULL) { gpio_set_function(clock->number, GPIO_GPFSEL4_FSEL48_SD1_CLK); gpio_set_pull(clock->number, BP_PULL_NONE); + self->clock_pin = clock->number; gpio_set_function(command->number, GPIO_GPFSEL4_FSEL49_SD1_CMD); gpio_set_pull(command->number, BP_PULL_UP); + self->command_pin = command->number; gpio_set_function(data[0]->number, GPIO_GPFSEL5_FSEL50_SD1_DAT0); gpio_set_pull(data[0]->number, BP_PULL_UP); + self->data_pins[0] = data[0]->number; gpio_set_function(data[1]->number, GPIO_GPFSEL5_FSEL51_SD1_DAT1); gpio_set_pull(data[1]->number, BP_PULL_UP); + self->data_pins[1] = data[1]->number; gpio_set_function(data[2]->number, GPIO_GPFSEL5_FSEL52_SD1_DAT2); gpio_set_pull(data[2]->number, BP_PULL_UP); + self->data_pins[2] = data[2]->number; gpio_set_function(data[3]->number, GPIO_GPFSEL5_FSEL53_SD1_DAT3); gpio_set_pull(data[3]->number, BP_PULL_UP); + self->data_pins[3] = data[3]->number; } else { // Switch the sdcard to use the old arasan interface. GPIO->EXTRA_MUX_b.SDIO = GPIO_EXTRA_MUX_SDIO_ARASAN; } + COMPLETE_MEMORY_READS; + self->host_info = (sdmmc_host_t) { .flags = SDMMC_HOST_FLAG_1BIT | SDMMC_HOST_FLAG_4BIT | SDMMC_HOST_FLAG_DEINIT_ARG, .slot = 0, @@ -280,9 +289,22 @@ void common_hal_sdioio_sdcard_construct(sdioio_sdcard_obj_t *self, // Start clocking the card. _set_card_clk(0, 400); - sdmmc_card_init(&self->host_info, &self->card_info); + sdmmc_err_t err = SDMMC_ERR_INVALID_RESPONSE; + size_t tries = 3; + while (err == SDMMC_ERR_INVALID_RESPONSE && tries > 0) { + err = sdmmc_card_init(&self->host_info, &self->card_info); + if (err != SDMMC_OK) { + mp_printf(&mp_plat_print, "SD card init failed %d\n", err); + } else if (tries < 3) { + mp_printf(&mp_plat_print, "SD card init success\n"); + } + tries--; + } + + self->init = err == SDMMC_OK; self->capacity = self->card_info.csd.capacity; + COMPLETE_MEMORY_READS; } uint32_t common_hal_sdioio_sdcard_get_count(sdioio_sdcard_obj_t *self) { @@ -297,9 +319,6 @@ uint8_t common_hal_sdioio_sdcard_get_width(sdioio_sdcard_obj_t *self) { return self->num_data; } -STATIC void check_for_deinit(sdioio_sdcard_obj_t *self) { -} - STATIC void check_whole_block(mp_buffer_info_t *bufinfo) { if (bufinfo->len % 512) { mp_raise_ValueError(translate("Buffer length must be a multiple of 512")); @@ -307,14 +326,16 @@ STATIC void check_whole_block(mp_buffer_info_t *bufinfo) { } int common_hal_sdioio_sdcard_writeblocks(sdioio_sdcard_obj_t *self, uint32_t start_block, mp_buffer_info_t *bufinfo) { - check_for_deinit(self); + if (!self->init) { + return -EIO; + } check_whole_block(bufinfo); self->state_programming = true; - // mp_printf(&mp_plat_print, "write %d %d %d %d\n", start_block, bufinfo->len / 512, self->card_info.csd.capacity, self->card_info.csd.sector_size); + COMPLETE_MEMORY_READS; sdmmc_err_t error = sdmmc_write_sectors(&self->card_info, bufinfo->buf, start_block, bufinfo->len / 512); - + COMPLETE_MEMORY_READS; if (error != SDMMC_OK) { mp_printf(&mp_plat_print, "write sectors result %d\n", error); @@ -325,10 +346,14 @@ int common_hal_sdioio_sdcard_writeblocks(sdioio_sdcard_obj_t *self, uint32_t sta } int common_hal_sdioio_sdcard_readblocks(sdioio_sdcard_obj_t *self, uint32_t start_block, mp_buffer_info_t *bufinfo) { - check_for_deinit(self); + if (!self->init) { + return -EIO; + } check_whole_block(bufinfo); + COMPLETE_MEMORY_READS; sdmmc_err_t error = sdmmc_read_sectors(&self->card_info, bufinfo->buf, start_block, bufinfo->len / 512); + COMPLETE_MEMORY_READS; if (error != SDMMC_OK) { mp_printf(&mp_plat_print, "read sectors result %d when reading block %d for %d\n", error, start_block, bufinfo->len / 512); @@ -339,7 +364,9 @@ int common_hal_sdioio_sdcard_readblocks(sdioio_sdcard_obj_t *self, uint32_t star } bool common_hal_sdioio_sdcard_configure(sdioio_sdcard_obj_t *self, uint32_t frequency, uint8_t bits) { - check_for_deinit(self); + if (!self->init) { + return false; + } return true; } @@ -361,7 +388,14 @@ void common_hal_sdioio_sdcard_deinit(sdioio_sdcard_obj_t *self) { self->data_pins[1] = COMMON_HAL_MCU_NO_PIN; self->data_pins[2] = COMMON_HAL_MCU_NO_PIN; self->data_pins[3] = COMMON_HAL_MCU_NO_PIN; + self->init = false; } void common_hal_sdioio_sdcard_never_reset(sdioio_sdcard_obj_t *self) { + never_reset_pin_number(self->command_pin); + never_reset_pin_number(self->clock_pin); + never_reset_pin_number(self->data_pins[0]); + never_reset_pin_number(self->data_pins[1]); + never_reset_pin_number(self->data_pins[2]); + never_reset_pin_number(self->data_pins[3]); } diff --git a/ports/broadcom/common-hal/sdioio/SDCard.h b/ports/broadcom/common-hal/sdioio/SDCard.h index ebd8e13f34..d180bc19a2 100644 --- a/ports/broadcom/common-hal/sdioio/SDCard.h +++ b/ports/broadcom/common-hal/sdioio/SDCard.h @@ -37,6 +37,7 @@ typedef struct { uint8_t num_data; bool state_programming; bool has_lock; + bool init; uint8_t command_pin; uint8_t clock_pin; uint8_t data_pins[4]; diff --git a/ports/broadcom/common-hal/videocore/Framebuffer.c b/ports/broadcom/common-hal/videocore/Framebuffer.c index f5f9654949..18b703b8b6 100644 --- a/ports/broadcom/common-hal/videocore/Framebuffer.c +++ b/ports/broadcom/common-hal/videocore/Framebuffer.c @@ -16,7 +16,13 @@ void common_hal_videocore_framebuffer_construct(videocore_framebuffer_obj_t *sel // TODO: Make the FB twice as tall if double buffering. uint32_t physical_height = height; uint32_t pitch = 0; - self->framebuffer = vcmailbox_get_framebuffer(&virtual_width, &virtual_height, &physical_width, &physical_height, &pitch); + uint32_t bits_per_pixel = 0; + self->framebuffer = vcmailbox_get_framebuffer(&virtual_width, + &virtual_height, + &physical_width, + &physical_height, + &pitch, + &bits_per_pixel); if (self->framebuffer == NULL) { if (gc_alloc_possible()) { mp_raise_ValueError(translate("no fb")); diff --git a/ports/broadcom/firmware b/ports/broadcom/firmware index 6a5207946e..bf96d0eda5 160000 --- a/ports/broadcom/firmware +++ b/ports/broadcom/firmware @@ -1 +1 @@ -Subproject commit 6a5207946edcd45813d1dd1572ca8bd8101b68b6 +Subproject commit bf96d0eda5952595d717fedb797aeb168483e9fa diff --git a/ports/broadcom/mpconfigport.h b/ports/broadcom/mpconfigport.h index dafe432c3c..abd0580999 100644 --- a/ports/broadcom/mpconfigport.h +++ b/ports/broadcom/mpconfigport.h @@ -36,7 +36,11 @@ #define MICROPY_PY_SYS_PLATFORM "BROADCOM" #define MICROPY_PY_BUILTINS_NOTIMPLEMENTED (1) #define MICROPY_PY_FUNCTION_ATTRS (1) +#if BCM_VERSION == 2837 || BCM_VERSION == 2711 #define MICROPY_OBJ_REPR (MICROPY_OBJ_REPR_A) +#elif BCM_VERSION == 2835 +#define MICROPY_OBJ_REPR (MICROPY_OBJ_REPR_C) +#endif #define CIRCUITPY_DEFAULT_STACK_SIZE (0x10000) #define CIRCUITPY_DISPLAY_AREA_BUFFER_SIZE (1920) #define CIRCUITPY_PROCESSOR_COUNT (4) diff --git a/ports/broadcom/mpconfigport.mk b/ports/broadcom/mpconfigport.mk index b17eb12f63..7296461d1f 100644 --- a/ports/broadcom/mpconfigport.mk +++ b/ports/broadcom/mpconfigport.mk @@ -1,58 +1,26 @@ -# Typically the first module to create -CIRCUITPY_MICROCONTROLLER = 1 -# Typically the second module to create -CIRCUITPY_DIGITALIO = 1 -# Other modules: +# All broadcom ports have longints. +LONGINT_IMPL = MPZ + +CIRCUITPY_FULL_BUILD = 1 + +# Modules in FULL_BUILD that we don't support. CIRCUITPY_ANALOGIO = 0 -CIRCUITPY_BUSIO = 1 -CIRCUITPY_ONEWIREIO = 0 -CIRCUITPY_PWMIO = 0 -CIRCUITPY_COUNTIO = 0 -CIRCUITPY_NEOPIXEL_WRITE = 0 -CIRCUITPY_PULSEIO = 0 -CIRCUITPY_OS = 1 -CIRCUITPY_NVM = 0 CIRCUITPY_AUDIOBUSIO = 0 CIRCUITPY_AUDIOIO = 0 -CIRCUITPY_ROTARYIO = 0 -CIRCUITPY_RTC = 0 -CIRCUITPY_SDCARDIO = 0 -CIRCUITPY_SDIOIO = 1 -CIRCUITPY_FRAMEBUFFERIO = 1 +CIRCUITPY_COUNTIO = 0 CIRCUITPY_FREQUENCYIO = 0 CIRCUITPY_I2CPERIPHERAL = 0 -# Requires SPI, PulseIO (stub ok): -CIRCUITPY_DISPLAYIO = 1 - -# These modules are implemented in shared-module/ - they can be included in -# any port once their prerequisites in common-hal are complete. -# Requires DigitalIO: -CIRCUITPY_BITBANGIO = 1 -# Requires DigitalIO -CIRCUITPY_GAMEPAD = 0 -# Requires neopixel_write or SPI (dotstar) -CIRCUITPY_PIXELBUF = 0 -# Requires OS -CIRCUITPY_RANDOM = 1 -# Requires OS, filesystem -CIRCUITPY_STORAGE = 1 -# Requires Microcontroller -CIRCUITPY_TOUCHIO = 0 -# Requires USB -CIRCUITPY_USB = 1 -CIRCUITPY_USB_MSC = 1 -CIRCUITPY_USB_HID = 1 -CIRCUITPY_USB_MIDI = 1 -USB_NUM_ENDPOINT_PAIRS = 8 -# Does nothing without I2C -CIRCUITPY_REQUIRE_I2C_PULLUPS = 0 -# No requirements, but takes extra flash -CIRCUITPY_ULAB = 0 +CIRCUITPY_NVM = 0 +CIRCUITPY_PARALLELDISPLAY = 0 +CIRCUITPY_PULSEIO = 0 +CIRCUITPY_PWMIO = 0 +CIRCUITPY_ROTARYIO = 0 +CIRCUITPY_RTC = 0 +CIRCUITPY_SDIOIO = 1 CIRCUITPY_VIDEOCORE = 1 -CIRCUITPY_ERRNO = 0 - -CIRCUITPY_FULL_BUILD = 0 - INTERNAL_FLASH_FILESYSTEM = 1 + +USB_NUM_ENDPOINT_PAIRS = 8 +USB_HIGHSPEED = 1 diff --git a/ports/broadcom/mphalport.c b/ports/broadcom/mphalport.c index f4bfd8653b..fa7dcaac8e 100644 --- a/ports/broadcom/mphalport.c +++ b/ports/broadcom/mphalport.c @@ -6,7 +6,15 @@ #include "shared-bindings/microcontroller/__init__.h" #include "mphalport.h" +#include "peripherals/broadcom/defines.h" + void mp_hal_delay_us(mp_uint_t delay) { + uint32_t end = SYSTMR->CLO + delay; + // Wait if end is before current time because it must have wrapped. + while (end < SYSTMR->CLO) { + } + while (SYSTMR->CLO < end) { + } } void mp_hal_disable_all_interrupts(void) { @@ -19,6 +27,7 @@ void mp_hal_enable_all_interrupts(void) { mp_uint_t cpu_get_regs_and_sp(mp_uint_t *regs) { size_t sp = 0; + #if defined(__ARM_ARCH) && (__ARM_ARCH >= 8) __asm__ ("mov %[out], sp" : [out] "=r" (sp)); __asm__ ("mov %[out], x19" : [out] "=r" (regs[0])); __asm__ ("mov %[out], x20" : [out] "=r" (regs[1])); @@ -30,5 +39,19 @@ mp_uint_t cpu_get_regs_and_sp(mp_uint_t *regs) { __asm__ ("mov %[out], x26" : [out] "=r" (regs[7])); __asm__ ("mov %[out], x27" : [out] "=r" (regs[8])); __asm__ ("mov %[out], x28" : [out] "=r" (regs[9])); + #else + __asm__ ("mov %[out], sp" : [out] "=r" (sp)); + __asm__ ("mov %[out], r4" : [out] "=r" (regs[0])); + __asm__ ("mov %[out], r5" : [out] "=r" (regs[1])); + __asm__ ("mov %[out], r6" : [out] "=r" (regs[2])); + __asm__ ("mov %[out], r7" : [out] "=r" (regs[3])); + __asm__ ("mov %[out], r8" : [out] "=r" (regs[4])); + __asm__ ("mov %[out], r9" : [out] "=r" (regs[5])); + __asm__ ("mov %[out], r10" : [out] "=r" (regs[6])); + __asm__ ("mov %[out], r11" : [out] "=r" (regs[7])); + __asm__ ("mov %[out], r12" : [out] "=r" (regs[8])); + __asm__ ("mov %[out], r13" : [out] "=r" (regs[9])); + #endif + return sp; } diff --git a/ports/broadcom/mphalport.h b/ports/broadcom/mphalport.h index 1efd931974..d67c9f4a50 100644 --- a/ports/broadcom/mphalport.h +++ b/ports/broadcom/mphalport.h @@ -1,26 +1,51 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2022 Scott Shawcroft + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_BROADCOM_MPHALPORT_H +#define MICROPY_INCLUDED_BROADCOM_MPHALPORT_H + #include #include "py/obj.h" + +#include "supervisor/shared/tick.h" + void mp_hal_delay_ms(mp_uint_t ms); void mp_hal_delay_us(mp_uint_t us); -mp_uint_t mp_hal_ticks_cpu(void); -mp_uint_t mp_hal_ticks_us(void); -mp_uint_t mp_hal_ticks_ms(void); + +#define mp_hal_ticks_ms() ((mp_uint_t)supervisor_ticks_ms32()) void mp_hal_set_interrupt_char(int c); int mp_hal_stdin_rx_chr(void); void mp_hal_stdout_tx_strn(const char *str, size_t len); -typedef enum std_io_t { - MINI_UART = 0, - UART, - UART_QEMU -} std_io_t; - -void uart_init(std_io_t interface); - #ifdef MICROPY_HW_USBHOST #include "usbkbd.h" void usbkbd_setup(); #endif + +#endif // MICROPY_INCLUDED_BROADCOM_MPHALPORT_H diff --git a/ports/broadcom/peripherals b/ports/broadcom/peripherals index 2e7b56bbe9..0837008608 160000 --- a/ports/broadcom/peripherals +++ b/ports/broadcom/peripherals @@ -1 +1 @@ -Subproject commit 2e7b56bbe941311e54fba66f0b32336bfea4388d +Subproject commit 08370086080759ed54ac1136d62d2ad24c6fa267 diff --git a/ports/broadcom/qstrdefsport.h b/ports/broadcom/qstrdefsport.h index ca01f8037c..6b44d1062b 100644 --- a/ports/broadcom/qstrdefsport.h +++ b/ports/broadcom/qstrdefsport.h @@ -26,6 +26,9 @@ // qstrs specific to this port, only needed if they aren't auto-generated +// Prevent uncrustify from modifying these lines. +// *FORMAT-OFF* + // Entries for sys.path Q(/sd) Q(/sd/lib) diff --git a/ports/broadcom/supervisor/internal_flash.c b/ports/broadcom/supervisor/internal_flash.c index 08c10848a8..806d3fb18b 100644 --- a/ports/broadcom/supervisor/internal_flash.c +++ b/ports/broadcom/supervisor/internal_flash.c @@ -60,6 +60,7 @@ void supervisor_flash_init(void) { NULL, NULL, 0, NULL, 8000000); #endif + common_hal_sdioio_sdcard_never_reset(&sd); uint32_t buffer[512 / sizeof(uint32_t)]; mp_buffer_info_t bufinfo; diff --git a/ports/broadcom/supervisor/port.c b/ports/broadcom/supervisor/port.c index ddd24fe540..e036a76cef 100644 --- a/ports/broadcom/supervisor/port.c +++ b/ports/broadcom/supervisor/port.c @@ -106,7 +106,7 @@ void reset_port(void) { audio_dma_reset(); #endif - // reset_all_pins(); + reset_all_pins(); } void reset_to_bootloader(void) { @@ -116,42 +116,57 @@ void reset_to_bootloader(void) { } void reset_cpu(void) { - + // Don't actually reset because we can't store the safe mode info. + // PM->WDOG = 1 << PM_WDOG_TIME_Pos | PM_WDOG_PASSWD_PASSWD << PM_WDOG_PASSWD_Pos; + // PM->RSTC = PM_RSTC_WRCFG_FULL_RESET << PM_RSTC_WRCFG_Pos | PM_RSTC_PASSWD_PASSWD << PM_RSTC_PASSWD_Pos; while (true) { } } bool port_has_fixed_stack(void) { + #ifdef __aarch64__ return true; -} - -uint32_t *port_stack_get_limit(void) { - return (uint32_t *)0x4; -} - -uint32_t *port_stack_get_top(void) { - return (uint32_t *)0x80000; + #else + return false; + #endif } // From the linker script extern uint32_t __bss_end; +extern uint32_t _ld_ram_end; +uint32_t *port_stack_get_limit(void) { + #ifdef __aarch64__ + return (uint32_t *)0x4; + #else + return &__bss_end; + #endif +} + +uint32_t *port_stack_get_top(void) { + #ifdef __aarch64__ + return (uint32_t *)0x80000; + #else + return &_ld_ram_end; + #endif +} + uint32_t *port_heap_get_bottom(void) { return &__bss_end; } uint32_t *port_heap_get_top(void) { // 32M heap - return (uint32_t *)(((uint64_t)&__bss_end) + 32 * 1024 * 1024); + return (uint32_t *)(((size_t)&__bss_end) + 32 * 1024 * 1024); } void port_set_saved_word(uint32_t value) { // NOTE: This doesn't survive pressing the reset button (aka toggling RUN). - // watchdog_hw->scratch[0] = value; + __bss_end = value; + data_clean_and_invalidate(&__bss_end, sizeof(uint32_t)); } uint32_t port_get_saved_word(void) { - // return watchdog_hw->scratch[0]; - return 0; + return __bss_end; } uint64_t port_get_raw_ticks(uint8_t *subticks) { diff --git a/ports/cxd56/common-hal/busio/I2C.c b/ports/cxd56/common-hal/busio/I2C.c index 7b9420fa1b..82b52ca179 100644 --- a/ports/cxd56/common-hal/busio/I2C.c +++ b/ports/cxd56/common-hal/busio/I2C.c @@ -97,7 +97,7 @@ bool common_hal_busio_i2c_probe(busio_i2c_obj_t *self, uint8_t addr) { return I2C_TRANSFER(self->i2c_dev, &msg, 1) < 0 ? false : true; } -uint8_t common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t address, const uint8_t *data, size_t len, bool stop) { +STATIC uint8_t _common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t address, const uint8_t *data, size_t len, bool stop) { struct i2c_msg_s msg; msg.frequency = self->frequency; @@ -108,6 +108,11 @@ uint8_t common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t address, cons return -I2C_TRANSFER(self->i2c_dev, &msg, 1); } +uint8_t common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t addr, + const uint8_t *data, size_t len) { + return _common_hal_busio_i2c_write(self, addr, data, len, true); +} + uint8_t common_hal_busio_i2c_read(busio_i2c_obj_t *self, uint16_t address, uint8_t *data, size_t len) { struct i2c_msg_s msg; @@ -119,6 +124,16 @@ uint8_t common_hal_busio_i2c_read(busio_i2c_obj_t *self, uint16_t address, uint8 return -I2C_TRANSFER(self->i2c_dev, &msg, 1); } +uint8_t common_hal_busio_i2c_write_read(busio_i2c_obj_t *self, uint16_t addr, + uint8_t *out_data, size_t out_len, uint8_t *in_data, size_t in_len) { + uint8_t result = _common_hal_busio_i2c_write(self, addr, out_data, out_len, false); + if (result != 0) { + return result; + } + + return common_hal_busio_i2c_read(self, addr, in_data, in_len); +} + void common_hal_busio_i2c_never_reset(busio_i2c_obj_t *self) { never_reset_pin_number(self->scl_pin->number); never_reset_pin_number(self->sda_pin->number); diff --git a/ports/cxd56/common-hal/busio/SPI.c b/ports/cxd56/common-hal/busio/SPI.c index 922a30f1c2..c248b5cc9a 100644 --- a/ports/cxd56/common-hal/busio/SPI.c +++ b/ports/cxd56/common-hal/busio/SPI.c @@ -35,9 +35,13 @@ #include "shared-bindings/busio/SPI.h" void common_hal_busio_spi_construct(busio_spi_obj_t *self, const mcu_pin_obj_t *clock, - const mcu_pin_obj_t *mosi, const mcu_pin_obj_t *miso) { + const mcu_pin_obj_t *mosi, const mcu_pin_obj_t *miso, bool half_duplex) { int port = -1; + if (half_duplex) { + mp_raise_NotImplementedError(translate("Half duplex SPI is not implemented")); + } + if (clock->number == PIN_SPI4_SCK && (mosi == NULL || mosi->number == PIN_SPI4_MOSI) && (miso == NULL || miso->number == PIN_SPI4_MISO)) { diff --git a/ports/cxd56/mpconfigport.mk b/ports/cxd56/mpconfigport.mk index 865c170aaa..8787c55bcc 100644 --- a/ports/cxd56/mpconfigport.mk +++ b/ports/cxd56/mpconfigport.mk @@ -3,11 +3,6 @@ USB_HIGHSPEED = 1 # Number of USB endpoint pairs. USB_NUM_ENDPOINT_PAIRS = 6 -# Define an equivalent for MICROPY_LONGINT_IMPL, to pass to $(MPY-TOOL) in py/mkrules.mk -# $(MPY-TOOL) needs to know what kind of longint to use (if any) to freeze long integers. -# This should correspond to the MICROPY_LONGINT_IMPL definition in mpconfigport.h. -MPY_TOOL_LONGINT_IMPL = -mlongint-impl=mpz - # Longints can be implemented as mpz, as longlong, or not LONGINT_IMPL = MPZ diff --git a/ports/espressif/CMakeLists.txt b/ports/espressif/CMakeLists.txt index 6ad33282f8..afbb51bbad 100644 --- a/ports/espressif/CMakeLists.txt +++ b/ports/espressif/CMakeLists.txt @@ -6,7 +6,7 @@ set(ENV{IDF_PATH} ${CMAKE_SOURCE_DIR}/esp-idf) # The component list here determines what options we get in menuconfig and what the ninja file # can build. -set(COMPONENTS esptool_py soc driver log main esp-tls mbedtls esp_event esp_adc_cal esp_netif esp_wifi lwip wpa_supplicant freertos) +set(COMPONENTS esptool_py soc driver log main esp-tls mbedtls esp_event esp_adc_cal esp_netif esp_wifi lwip wpa_supplicant freertos bt) include($ENV{IDF_PATH}/tools/cmake/project.cmake) project(circuitpython) diff --git a/ports/espressif/Makefile b/ports/espressif/Makefile index c997dc6a0a..beb0ccd679 100644 --- a/ports/espressif/Makefile +++ b/ports/espressif/Makefile @@ -86,6 +86,16 @@ INC += \ -isystem esp-idf \ -isystem esp-idf/components/app_update/include \ -isystem esp-idf/components/bootloader_support/include \ + -isystem esp-idf/components/bt/include/$(IDF_TARGET)/include \ + -isystem esp-idf/components/bt/host/nimble/esp-hci/include \ + -isystem esp-idf/components/bt/host/nimble/nimble/nimble/controller/include \ + -isystem esp-idf/components/bt/host/nimble/nimble/nimble/host/include \ + -isystem esp-idf/components/bt/host/nimble/nimble/nimble/host/services/gap/include \ + -isystem esp-idf/components/bt/host/nimble/nimble/nimble/include \ + -isystem esp-idf/components/bt/host/nimble/nimble/nimble/host/util/include \ + -isystem esp-idf/components/bt/host/nimble/nimble/porting/nimble/include \ + -isystem esp-idf/components/bt/host/nimble/nimble/porting/npl/freertos/include \ + -isystem esp-idf/components/bt/host/nimble/port/include \ -isystem esp-idf/components/driver/include \ -isystem esp-idf/components/driver/$(IDF_TARGET)/include \ -isystem esp-idf/components/$(IDF_TARGET)/include \ @@ -94,6 +104,7 @@ INC += \ -isystem esp-idf/components/esp_event/include \ -isystem esp-idf/components/esp_hw_support/include \ -isystem esp-idf/components/esp_hw_support/include/soc \ + -isystem esp-idf/components/esp_ipc/include \ -isystem esp-idf/components/esp_netif/include \ -isystem esp-idf/components/esp_pm/include \ -isystem esp-idf/components/esp_ringbuf/include \ @@ -132,6 +143,7 @@ endif CFLAGS += \ -DHAVE_CONFIG_H \ + -DESP_PLATFORM=1 \ -DMBEDTLS_CONFIG_FILE=\"mbedtls/esp_config.h\" \ -DUNITY_INCLUDE_CONFIG_H -DWITH_POSIX @@ -147,7 +159,12 @@ ifeq ($(DEBUG), 1) # CFLAGS += -fno-inline -fno-ipa-sra else CFLAGS += -DNDEBUG -ggdb3 - OPTIMIZATION_FLAGS ?= -O2 + ifeq ($(IDF_TARGET_ARCH),xtensa) + OPTIMIZATION_FLAGS ?= -O2 + else + # RISC-V is larger than xtensa so do -Os for it + OPTIMIZATION_FLAGS ?= -Os + endif # TODO: Test with -flto ### CFLAGS += -flto endif @@ -251,6 +268,10 @@ ifneq ($(CIRCUITPY_USB),0) SRC_C += lib/tinyusb/src/portable/espressif/esp32sx/dcd_esp32sx.c endif +ifneq ($(CIRCUITPY_BLEIO),0) +SRC_C += common-hal/_bleio/ble_events.c +endif + SRC_COMMON_HAL_EXPANDED = \ $(addprefix shared-bindings/, $(SRC_COMMON_HAL)) \ $(addprefix shared-bindings/, $(SRC_BINDINGS_ENUMS)) \ @@ -289,14 +310,25 @@ IDF_PATH = $(realpath ./esp-idf) $(BUILD)/esp-idf: $(Q)$(MKDIR) -p $@ -FLASH_SDKCONFIG = esp-idf-config/sdkconfig-$(CIRCUITPY_ESP_FLASH_SIZE).defaults +TARGET_SDKCONFIG = esp-idf-config/sdkconfig-$(IDF_TARGET).defaults + +UF2_BOOTLOADER ?= $(if $(filter $(IDF_TARGET),esp32s2 esp32s3),1) +ifeq ($(UF2_BOOTLOADER), 1) + FLASH_SDKCONFIG = esp-idf-config/sdkconfig-$(CIRCUITPY_ESP_FLASH_SIZE).defaults +else + FLASH_SDKCONFIG = esp-idf-config/sdkconfig-$(CIRCUITPY_ESP_FLASH_SIZE)-no-uf2.defaults +endif + ifeq ($(DEBUG), 1) DEBUG_SDKCONFIG = esp-idf-config/sdkconfig-debug.defaults else DEBUG_SDKCONFIG = esp-idf-config/sdkconfig-opt.defaults endif -SDKCONFIGS = esp-idf-config/sdkconfig.defaults;$(DEBUG_SDKCONFIG);$(FLASH_SDKCONFIG);boards/$(BOARD)/sdkconfig +SDKCONFIGS := esp-idf-config/sdkconfig.defaults;$(DEBUG_SDKCONFIG);$(FLASH_SDKCONFIG);$(TARGET_SDKCONFIG);boards/$(BOARD)/sdkconfig +ifneq ($(CIRCUITPY_BLEIO),0) + SDKCONFIGS := esp-idf-config/sdkconfig-ble.defaults;$(SDKCONFIGS) +endif # create the config headers $(BUILD)/esp-idf/config/sdkconfig.h: boards/$(BOARD)/sdkconfig | $(BUILD)/esp-idf IDF_PATH=$(IDF_PATH) cmake -S . -B $(BUILD)/esp-idf -DSDKCONFIG=$(BUILD)/esp-idf/sdkconfig -DSDKCONFIG_DEFAULTS="$(SDKCONFIGS)" -DCMAKE_TOOLCHAIN_FILE=$(IDF_PATH)/tools/cmake/toolchain-$(IDF_TARGET).cmake -DIDF_TARGET=$(IDF_TARGET) -GNinja @@ -316,10 +348,11 @@ $(BUILD)/esp-idf/partition_table/partition-table.bin: $(BUILD)/esp-idf/config/sd IDF_PATH=$(IDF_PATH) ninja -C $(BUILD)/esp-idf partition_table/partition-table.bin # run menuconfig and then remove standard settings -menuconfig: $(BUILD)/esp-idf/config +menuconfig: $(BUILD)/esp-idf/config $(BUILD)/esp-idf/config/sdkconfig.h $(Q)ninja -C $(BUILD)/esp-idf menuconfig - $(Q)diff --old-line-format= --unchanged-line-format= esp-idf-config/sdkconfig.defaults $(BUILD)/esp-idf/sdkconfig > $(BUILD)/sdkconfig.diff || true - $(Q)grep -Fvxf $(DEBUG_SDKCONFIG) -f $(FLASH_SDKCONFIG) $(BUILD)/sdkconfig.diff > boards/$(BOARD)/sdkconfig + # Newer versions of the idf will have save-defconfig that will only include non-default values. + # We should use that when available. For now, we sort out everything. + python tools/update_sdkconfig.py --board=$(BOARD) --debug=$(DEBUG) # qstr builds include headers so we need to make sure they are up to date $(HEADER_BUILD)/qstr.split: | $(BUILD)/esp-idf/config/sdkconfig.h @@ -328,6 +361,12 @@ BINARY_WIFI_BLOBS = libcoexist.a libcore.a libespnow.a libmesh.a libnet80211.a l BINARY_BLOBS = esp-idf/components/esp_phy/lib/$(IDF_TARGET)/libphy.a $(addprefix esp-idf/components/esp_wifi/lib/$(IDF_TARGET)/, $(BINARY_WIFI_BLOBS)) ESP_IDF_COMPONENTS_LINK = $(IDF_TARGET_ARCH) app_update bootloader_support driver efuse esp_adc_cal esp_common esp_event esp_hw_support esp_ipc esp_netif esp_pm esp_phy esp_ringbuf esp_rom esp_system esp_timer esp-tls esp_wifi freertos hal heap log lwip mbedtls newlib nvs_flash pthread soc spi_flash vfs wpa_supplicant +ifneq ($(CIRCUITPY_BLEIO),0) + ESP_IDF_COMPONENTS_LINK += bt + BINARY_BLOBS += esp-idf/components/esp_phy/lib/$(IDF_TARGET)/libbtbb.a \ + esp-idf/components/bt/controller/lib_esp32c3_family/$(IDF_TARGET)/libbtdm_app.a +endif + ESP_IDF_COMPONENTS_EXPANDED = $(foreach component, $(ESP_IDF_COMPONENTS_LINK), $(BUILD)/esp-idf/esp-idf/$(component)/lib$(component).a) MBEDTLS_COMPONENTS_LINK = crypto tls x509 @@ -346,6 +385,11 @@ else BOOTLOADER_OFFSET = 0x1000 endif +IDF_CMAKE_TARGETS = \ + bootloader/bootloader.bin \ + esp-idf/esp_system/__ldgen_output_sections.ld \ + $(foreach component, $(ESP_IDF_COMPONENTS_LINK), esp-idf/$(component)/lib$(component).a) + PARTITION_TABLE_OFFSET = 0x8000 FIRMWARE_OFFSET = 0x10000 @@ -355,49 +399,15 @@ FLASH_FLAGS = --flash_mode $(CIRCUITPY_ESP_FLASH_MODE) --flash_freq $(CIRCUITPY_ ESPTOOL_FLAGS ?= --before=default_reset --after=no_reset -ifeq ($(IDF_TARGET),esp32c3) -all: $(BUILD)/firmware.bin -else +ifeq ($(UF2_BOOTLOADER),1) all: $(BUILD)/firmware.bin $(BUILD)/firmware.uf2 +else +all: $(BUILD)/firmware.bin endif .PHONY: esp-idf-stamp esp-idf-stamp: $(BUILD)/esp-idf/config/sdkconfig.h - $(Q)ninja -C $(BUILD)/esp-idf \ - bootloader/bootloader.bin \ - esp-idf/esp_system/__ldgen_output_sections.ld \ - esp-idf/app_update/libapp_update.a \ - esp-idf/bootloader_support/libbootloader_support.a \ - esp-idf/driver/libdriver.a \ - esp-idf/efuse/libefuse.a \ - esp-idf/esp_adc_cal/libesp_adc_cal.a \ - esp-idf/esp_common/libesp_common.a \ - esp-idf/esp_event/libesp_event.a \ - esp-idf/esp_hw_support/libesp_hw_support.a \ - esp-idf/esp_ipc/libesp_ipc.a \ - esp-idf/esp_netif/libesp_netif.a \ - esp-idf/esp_phy/libesp_phy.a \ - esp-idf/esp_pm/libesp_pm.a \ - esp-idf/esp_ringbuf/libesp_ringbuf.a \ - esp-idf/esp_rom/libesp_rom.a \ - esp-idf/esp_system/libesp_system.a \ - esp-idf/esp_timer/libesp_timer.a \ - esp-idf/esp-tls/libesp-tls.a \ - esp-idf/esp_wifi/libesp_wifi.a \ - esp-idf/freertos/libfreertos.a \ - esp-idf/hal/libhal.a \ - esp-idf/heap/libheap.a \ - esp-idf/log/liblog.a \ - esp-idf/lwip/liblwip.a \ - esp-idf/mbedtls/libmbedtls.a \ - esp-idf/newlib/libnewlib.a \ - esp-idf/nvs_flash/libnvs_flash.a \ - esp-idf/pthread/libpthread.a \ - esp-idf/soc/libsoc.a \ - esp-idf/spi_flash/libspi_flash.a \ - esp-idf/vfs/libvfs.a \ - esp-idf/wpa_supplicant/libwpa_supplicant.a \ - esp-idf/$(IDF_TARGET_ARCH)/lib$(IDF_TARGET_ARCH).a + $(Q)ninja -C $(BUILD)/esp-idf $(IDF_CMAKE_TARGETS) $(BUILD)/firmware.elf: $(OBJ) | esp-idf-stamp $(STEPECHO) "LINK $@" @@ -411,9 +421,12 @@ $(BUILD)/circuitpython-firmware.bin: $(BUILD)/firmware.elf | tools/build_memory_ $(BUILD)/firmware.bin: $(BUILD)/circuitpython-firmware.bin | esp-idf-stamp $(Q)$(PYTHON) ../../tools/join_bins.py $@ $(BOOTLOADER_OFFSET) $(BUILD)/esp-idf/bootloader/bootloader.bin $(PARTITION_TABLE_OFFSET) $(BUILD)/esp-idf/partition_table/partition-table.bin $(FIRMWARE_OFFSET) $(BUILD)/circuitpython-firmware.bin +UF2_FAMILY_ID_esp32s2 = 0xbfdd4eee +UF2_FAMILY_ID_esp32s3 = 0xc47e5767 + $(BUILD)/firmware.uf2: $(BUILD)/circuitpython-firmware.bin $(STEPECHO) "Create $@" - $(Q)$(PYTHON) $(TOP)/tools/uf2/utils/uf2conv.py -f 0xbfdd4eee -b 0x0000 -c -o $@ $^ + $(Q)$(PYTHON) $(TOP)/tools/uf2/utils/uf2conv.py -f $(UF2_FAMILY_ID_$(IDF_TARGET)) -b 0x0000 -c -o $@ $^ flash: $(BUILD)/firmware.bin esptool.py --chip $(IDF_TARGET) -p $(PORT) $(ESPTOOL_FLAGS) write_flash $(FLASH_FLAGS) 0x0000 $^ diff --git a/ports/espressif/README.rst b/ports/espressif/README.rst index 7ef0fc5dc6..cea95dea04 100644 --- a/ports/espressif/README.rst +++ b/ports/espressif/README.rst @@ -19,24 +19,24 @@ How this port is organized: - **bindings/** contains some required bindings to the ESP-IDF for exceptions and memory. - **boards/** contains the configuration files for each development board and breakout available on the port. - **common-hal/** contains the port-specific module implementations, used by shared-module and shared-bindings. -- **esp-idf/** contains the Espressif IoT development framework installation, including all the drivers for the port. +- **esp-idf/** contains the Espressif IoT Development Framework installation, including all the drivers for the port. - **modules/** contains information specific to certain Espressif SoC based hardware modules, such as the pins used for flash and RAM on the WROVER and WROOM. - **peripherals/** contains peripheral setup files and peripheral mapping information, sorted by family and sub-variant. Most files in this directory can be generated with the python scripts in **tools/**. - **supervisor/** contains port-specific implementations of internal flash, serial and USB, as well as the **port.c** file, which initializes the port at startup. -- **tools/** includes useful python scripts for debugging and other purposes. +- **tools/** includes useful Python scripts for debugging and other purposes. -At the root level, refer to **mpconfigboard.h** and **mpconfigport.mk** for port specific settings and a list of enabled circuitpython modules. +At the root level, refer to **mpconfigboard.h** and **mpconfigport.mk** for port specific settings and a list of enabled CircuitPython modules. Connecting to the ESP32-C3 --------------------------------------- -**USB Connetion:** +**USB Connection:** On ESP32-C3 REV3 chips, a USB Serial/JTAG Controller is available. Note: This USB connection cannot be used for a ``CIRCUITPY`` drive. Depending on the board you have, the USB port may or may not be connected to native USB. -Following connections need to be made if native USB isn't available on USB port: +The following connections need to be made if native USB isn't available on the USB port: .. csv-table:: :header: GPIO, USB @@ -50,9 +50,9 @@ Connect these pins using a `USB adapter ` **UART Connection:** -A `USB to UART convertor `_ can be used for connecting to ESP32-C3 to get serial console, REPL interface and flashing CircuitPython. +A `USB to UART convertor `_ can be used for connecting to ESP32-C3 to get access to the serial console and REPL and for flashing CircuitPython. -Following connections need to be made in this case. +The following connections need to be made in this case: .. csv-table:: :header: GPIO, UART @@ -69,11 +69,11 @@ This feature is not yet available and currently under development. Connecting to the ESP32-S2 --------------------------------------- -**USB Connetion:** +**USB Connection:** Depending on the board you have, the USB port may or may not be connected to native USB. -Following connections need to be made if native USB isn't available on USB port: +The following connections need to be made if native USB isn't available on the USB port: .. csv-table:: :header: GPIO, USB @@ -87,9 +87,9 @@ Connect these pins using a `USB adapter ` **UART Connection:** -A `USB to UART convertor `_ can be used for connecting to ESP32-S2 to get serial console and flashing CircuitPython. +A `USB to UART convertor `_ can be used for connecting to ESP32-S2 to get access to the serial console and REPL and for flashing CircuitPython. -Following connections need to be made in this case: +The following connections need to be made in this case: .. csv-table:: :header: GPIO, UART @@ -106,11 +106,11 @@ This feature isn't available on ESP32-S2. Connecting to the ESP32-S3 --------------------------------------- -**USB Connetion:** +**USB Connection:** Depending on the board you have, the USB port may or may not be connected to native USB. -Following connections need to be made if native USB isn't available on USB port: +The following connections need to be made if native USB isn't available on the USB port: .. csv-table:: :header: GPIO, USB @@ -124,9 +124,9 @@ Connect these pins using a `USB adapter ` **UART Connection:** -A `USB to UART convertor `_ can be used for connecting to ESP32-S3 to get serial console and flashing CircuitPython. +A `USB to UART convertor `_ can be used for connecting to ESP32-S3 to get access to the serial console and REPL and for flashing CircuitPython. -Following connections need to be made in this case: +The following connections need to be made in this case: .. csv-table:: :header: GPIO, UART @@ -143,9 +143,9 @@ This feature is not yet available and currently under development. Building and flashing --------------------------------------- -Before building or flashing the, you must `install the esp-idf `_. +Before building or flashing the, you must `install the ESP-IDF `_. -Note: This must be re-done every time the esp-idf is updated, but not every time you build. +Note: This must be re-done every time the ESP-IDF is updated, but not every time you build. Run ``cd ports/espressif`` from ``circuitpython/`` to move to the espressif port root, and run: @@ -153,17 +153,17 @@ Run ``cd ports/espressif`` from ``circuitpython/`` to move to the espressif port ./esp-idf/install.sh -After this initial installation, you must add the esp-idf tools to your path. +After this initial installation, you must add the ESP-IDF tools to your path. -Note: This must be re-done every time you open a new bash environment for building or flashing. +Note: This must be re-done every time you open a new shell environment for building or flashing. Run ``cd ports/espressif`` from ``circuitpython/`` to move to the espressif port root, and run: .. code-block:: - . esp-idf/export.sh + ./esp-idf/export.sh -When CircuitPython updates the ESP-IDF to a new release, you may need to run this installation process again. The exact commands used may also vary based on your bash environment. +When CircuitPython updates the ESP-IDF to a new release, you may need to run this installation process again. The exact commands used may also vary based on your shell environment. Building boards is typically done through ``make BOARD=board_id``. The default port is ``tty.SLAB_USBtoUART``, which will only work on certain Mac setups. On most machines, both Mac and Linux, you will need to set the port yourself by running ``ls /dev/tty.usb*`` and selecting the one that only appears when your development board is plugged in. An example make command with the port setting is as follows: @@ -171,7 +171,7 @@ Building boards is typically done through ``make BOARD=board_id``. The default p make BOARD=board_id PORT=/dev/tty.usbserial-1421120 flash -``board_id`` is the unique board identifier in CircuitPython. It is the same as the name of board in ``boards`` directory. +``board_id`` is the unique board identifier in CircuitPython. It is the same as the name of the board in the ``boards`` directory. Debugging --------------------------------------- @@ -180,11 +180,11 @@ TODO: Add documentation for ESP32-C3/S3 JTAG feature. The ESP32-S2 supports JTAG debugging over OpenOCD using a JLink or other probe hardware. The official tutorials can be found on the Espressif website `here `_, but they are mostly for the ESP32-S2 Kaluga, which has built-in debugging. -OpenOCD is automatically installed and added to your bash environment during the esp-idf installation and setup process. You can double check that it is installed by using ``openocd --version``, as per the tutorial. Attach the JTAG probe pins according to the `instructions for JTAG debugging `_ on boards that do not contain an integrated debugger. +OpenOCD is automatically installed and added to your bash environment during the ESP-IDF installation and setup process. You can double check that it is installed by using ``openocd --version``, as per the tutorial. Attach the JTAG probe pins according to the `instructions for JTAG debugging `_ on boards that do not contain an integrated debugger. -Once the debugger is connected physically, you must run OpenOCD with attached configuration files specifying the **interface** (your debugger probe) and either a **target** or a **board** (targets are for SoCs only, and can be used when a full board configuration file doesn't exist). You can find the path location of these files by checking the ``OPENOCD_SCRIPTS`` environmental variable by running ``echo $OPENOCD_SCRIPTS`` in bash. Interfaces will be in the ``interface/`` directory, and targets and boards in the ``target/`` and ``board/`` directories, respectively. +Once the debugger is connected physically, you must run OpenOCD with attached configuration files specifying the **interface** (your debugger probe) and either a **target** or a **board** (targets are for SoCs only, and can be used when a full board configuration file doesn't exist). You can find the location of these files by checking the ``OPENOCD_SCRIPTS`` environmental variable by running ``echo $OPENOCD_SCRIPTS``. Interfaces will be in the ``interface/`` directory, and targets and boards in the ``target/`` and ``board/`` directories, respectively. -**Note:** Unfortunately, there are no board files for the esp32-s2 other than the Kaluga, and the included ``target/esp32s2.cfg`` target file will not work by default on the Jlink for boards like the Saola 1, as the default speed is incorrect. In addition, these files are covered under the GPL and cannot be included in CircuitPython. Thus, you must make a copy of the esp32s2.cfg file yourself and add the following line manually, under ``transport select jtag`` at the start of the file: +**Note:** Unfortunately, there are no board files for the esp32-s2 other than the Kaluga, and the included ``target/esp32s2.cfg`` target file will not work by default on the JLink for boards like the Saola 1, as the default speed is incorrect. In addition, these files are covered under the GPL and cannot be included in CircuitPython. Thus, you must make a copy of the ``esp32s2.cfg`` file yourself and add the following line manually, under ``transport select jtag`` at the start of the file: .. code-block:: @@ -196,7 +196,7 @@ Once this is complete, your final OpenOCD command may look something like this: openocd -f interface/jlink.cfg -f SOMEPATH/copied-esp32s2-saola-1.cfg -Where ``SOMEPATH`` is the location of your copied configuration file (this can be placed in the port/boards directory with a prefix to ignore it with ``.gitignore``, for instance). Interface, target and board config files sourced from espressif only need their paths from the $OPENOCD_SCRIPTS location, you don't need to include their full path. Once OpenOCD is running, connect to GDB with: +Where ``SOMEPATH`` is the location of your copied configuration file (this can be placed in the ``port/boards`` directory with a prefix to ignore it with ``.gitignore``, for instance). Interface, target and board config files sourced from Espressif only need their paths from the $OPENOCD_SCRIPTS location, you don't need to include their full path. Once OpenOCD is running, connect to GDB with: .. code-block:: diff --git a/ports/espressif/boards/adafruit_esp32s2_camera/board.c b/ports/espressif/boards/adafruit_esp32s2_camera/board.c new file mode 100644 index 0000000000..109e9b4b9a --- /dev/null +++ b/ports/espressif/boards/adafruit_esp32s2_camera/board.c @@ -0,0 +1,111 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "supervisor/board.h" +#include "mpconfigboard.h" + +#include "shared-bindings/busio/SPI.h" +#include "shared-bindings/displayio/FourWire.h" +#include "shared-bindings/microcontroller/Pin.h" +#include "shared-module/displayio/__init__.h" +#include "shared-module/displayio/mipi_constants.h" +#include "shared-bindings/board/__init__.h" + +#include "esp_log.h" + +displayio_fourwire_obj_t board_display_obj; + +#define DELAY 0x80 + +uint8_t display_init_sequence[] = { + 0x01, 0 | DELAY, 120, // SWRESET + 0x11, 0 | DELAY, 5, // SLPOUT + 0x36, 1, 0b10100000, // _MADCTL for rotation 0 + 0x3a, 1, 0x55, // COLMOD - 16bit color + 0x21, 0, // _INVON + 0x13, 0, // _NORON + 0x29, 0 | DELAY, 5, // _DISPON +}; + +void board_init(void) { + busio_spi_obj_t *spi = common_hal_board_create_spi(0); + displayio_fourwire_obj_t *bus = &displays[0].fourwire_bus; + bus->base.type = &displayio_fourwire_type; + common_hal_displayio_fourwire_construct(bus, + spi, + &pin_GPIO39, // TFT_DC Command or data + &pin_GPIO40, // TFT_CS Chip select + &pin_GPIO41, // TFT_RESET Reset + 40000000, // Baudrate + 0, // Polarity + 0); // Phase + + // workaround as board_init() is called before reset_port() in main.c + pwmout_reset(); + + displayio_display_obj_t *display = &displays[0].display; + display->base.type = &displayio_display_type; + common_hal_displayio_display_construct( + display, + bus, + 240, // Width (after rotation) + 240, // Height (after rotation) + 80, // column start + 0, // row start + 0, // rotation + 16, // Color depth + false, // Grayscale + false, // Pixels in a byte share a row. Only used for depth < 8 + 1, // bytes per cell. Only valid for depths < 8 + false, // reverse_pixels_in_byte. Only valid for depths < 8 + true, // reverse_pixels_in_word + MIPI_COMMAND_SET_COLUMN_ADDRESS, // Set column command + MIPI_COMMAND_SET_PAGE_ADDRESS, // Set row command + MIPI_COMMAND_WRITE_MEMORY_START, // Write memory command + display_init_sequence, + sizeof(display_init_sequence), + &pin_GPIO38, // backlight pin + NO_BRIGHTNESS_COMMAND, + 1.0f, // brightness (ignored) + true, // auto_brightness + false, // single_byte_bounds + false, // data_as_commands + true, // auto_refresh + 60, // native_frames_per_second + true, // backlight_on_high + false); // not SH1107 +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { +} + +void board_deinit(void) { + common_hal_displayio_release_displays(); +} diff --git a/ports/espressif/boards/adafruit_esp32s2_camera/mpconfigboard.h b/ports/espressif/boards/adafruit_esp32s2_camera/mpconfigboard.h new file mode 100644 index 0000000000..f7f988b861 --- /dev/null +++ b/ports/espressif/boards/adafruit_esp32s2_camera/mpconfigboard.h @@ -0,0 +1,48 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +// Micropython setup + +#define MICROPY_HW_BOARD_NAME "Adafruit Camera" +#define MICROPY_HW_MCU_NAME "ESP32S2" + +#define MICROPY_HW_NEOPIXEL (&pin_GPIO21) +#define MICROPY_HW_NEOPIXEL_COUNT (6) + +#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) + +#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") + +#define AUTORESET_DELAY_MS 500 + +#define DEFAULT_I2C_BUS_SDA (&pin_GPIO33) +#define DEFAULT_I2C_BUS_SCL (&pin_GPIO34) + +#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO35) +#define DEFAULT_SPI_BUS_SCK (&pin_GPIO36) +#define DEFAULT_SPI_BUS_MISO (&pin_GPIO37) + +#define DOUBLE_TAP_PIN (&pin_GPIO42) diff --git a/ports/espressif/boards/adafruit_esp32s2_camera/mpconfigboard.mk b/ports/espressif/boards/adafruit_esp32s2_camera/mpconfigboard.mk new file mode 100644 index 0000000000..d99a431599 --- /dev/null +++ b/ports/espressif/boards/adafruit_esp32s2_camera/mpconfigboard.mk @@ -0,0 +1,19 @@ +USB_VID = 0x239A +USB_PID = 0x8118 +USB_PRODUCT = "Camera" +USB_MANUFACTURER = "Adafruit" + +IDF_TARGET = esp32s2 + +INTERNAL_FLASH_FILESYSTEM = 1 +LONGINT_IMPL = MPZ + +# The default queue depth of 16 overflows on release builds, +# so increase it to 32. +CFLAGS += -DCFG_TUD_TASK_QUEUE_SZ=32 + +CIRCUITPY_ESP_FLASH_MODE=dio +CIRCUITPY_ESP_FLASH_FREQ=40m +CIRCUITPY_ESP_FLASH_SIZE=4MB + +CIRCUITPY_MODULE=wrover diff --git a/ports/espressif/boards/adafruit_esp32s2_camera/pins.c b/ports/espressif/boards/adafruit_esp32s2_camera/pins.c new file mode 100644 index 0000000000..688a555b02 --- /dev/null +++ b/ports/espressif/boards/adafruit_esp32s2_camera/pins.c @@ -0,0 +1,69 @@ +#include "py/objtuple.h" +#include "shared-bindings/board/__init__.h" +#include "shared-module/displayio/__init__.h" + +STATIC const mp_rom_obj_tuple_t camera_data_tuple = { + {&mp_type_tuple}, + 8, + { + MP_ROM_PTR(&pin_GPIO13), + MP_ROM_PTR(&pin_GPIO15), + MP_ROM_PTR(&pin_GPIO16), + MP_ROM_PTR(&pin_GPIO14), + MP_ROM_PTR(&pin_GPIO12), + MP_ROM_PTR(&pin_GPIO10), + MP_ROM_PTR(&pin_GPIO9), + MP_ROM_PTR(&pin_GPIO7), + } +}; + + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO35) }, + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO36) }, + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO37) }, + { MP_ROM_QSTR(MP_QSTR_TFT_BACKLIGHT), MP_ROM_PTR(&pin_GPIO38) }, + { MP_ROM_QSTR(MP_QSTR_TFT_DC), MP_ROM_PTR(&pin_GPIO39) }, + { MP_ROM_QSTR(MP_QSTR_TFT_CS), MP_ROM_PTR(&pin_GPIO40) }, + { MP_ROM_QSTR(MP_QSTR_TFT_RESET), MP_ROM_PTR(&pin_GPIO41) }, + + { MP_ROM_QSTR(MP_QSTR_CARD_CS), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_CARD_POWER), MP_ROM_PTR(&pin_GPIO1) }, + + { MP_ROM_QSTR(MP_QSTR_IRQ), MP_ROM_PTR(&pin_GPIO3) }, + + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO21) }, + + { MP_ROM_QSTR(MP_QSTR_SPEAKER), MP_ROM_PTR(&pin_GPIO45) }, + + { MP_ROM_QSTR(MP_QSTR_BUTTON), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO2) }, + + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO17) }, + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO18) }, + + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO33) }, + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO34) }, + + { MP_ROM_QSTR(MP_QSTR_CAMERA_DATA), MP_ROM_PTR(&camera_data_tuple) }, + + { MP_ROM_QSTR(MP_QSTR_CAMERA_VSYNC), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_CAMERA_HREF), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_CAMERA_DATA9), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_CAMERA_XCLK), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_CAMERA_DATA8), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_CAMERA_DATA7), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_CAMERA_PCLK), MP_ROM_PTR(&pin_GPIO11) }, + { MP_ROM_QSTR(MP_QSTR_CAMERA_DATA6), MP_ROM_PTR(&pin_GPIO12) }, + { MP_ROM_QSTR(MP_QSTR_CAMERA_DATA2), MP_ROM_PTR(&pin_GPIO13) }, + { MP_ROM_QSTR(MP_QSTR_CAMERA_DATA5), MP_ROM_PTR(&pin_GPIO14) }, + { MP_ROM_QSTR(MP_QSTR_CAMERA_DATA3), MP_ROM_PTR(&pin_GPIO15) }, + { MP_ROM_QSTR(MP_QSTR_CAMERA_DATA4), MP_ROM_PTR(&pin_GPIO16) }, + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, + { MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display)}, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/espressif/boards/adafruit_esp32s2_camera/sdkconfig b/ports/espressif/boards/adafruit_esp32s2_camera/sdkconfig new file mode 100644 index 0000000000..9d8bbde967 --- /dev/null +++ b/ports/espressif/boards/adafruit_esp32s2_camera/sdkconfig @@ -0,0 +1,33 @@ +CONFIG_ESP32S2_SPIRAM_SUPPORT=y + +# +# SPI RAM config +# +# CONFIG_SPIRAM_TYPE_AUTO is not set +CONFIG_SPIRAM_TYPE_ESPPSRAM16=y +# CONFIG_SPIRAM_TYPE_ESPPSRAM32 is not set +# CONFIG_SPIRAM_TYPE_ESPPSRAM64 is not set +CONFIG_SPIRAM_SIZE=2097152 + +# +# PSRAM clock and cs IO for ESP32S2 +# +CONFIG_DEFAULT_PSRAM_CLK_IO=30 +CONFIG_DEFAULT_PSRAM_CS_IO=26 +# end of PSRAM clock and cs IO for ESP32S2 + +# CONFIG_SPIRAM_FETCH_INSTRUCTIONS is not set +# CONFIG_SPIRAM_RODATA is not set +# CONFIG_SPIRAM_SPEED_80M is not set +CONFIG_SPIRAM_SPEED_40M=y +# CONFIG_SPIRAM_SPEED_26M is not set +# CONFIG_SPIRAM_SPEED_20M is not set +CONFIG_SPIRAM=y +CONFIG_SPIRAM_BOOT_INIT=y +# CONFIG_SPIRAM_IGNORE_NOTFOUND is not set +CONFIG_SPIRAM_USE_MEMMAP=y +# CONFIG_SPIRAM_USE_CAPS_ALLOC is not set +# CONFIG_SPIRAM_USE_MALLOC is not set +CONFIG_SPIRAM_MEMTEST=y +# CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY is not set +# end of SPI RAM config diff --git a/ports/espressif/boards/adafruit_feather_esp32s2/board.c b/ports/espressif/boards/adafruit_feather_esp32s2/board.c index 5abd1ce1b3..1be9000b3a 100644 --- a/ports/espressif/boards/adafruit_feather_esp32s2/board.c +++ b/ports/espressif/boards/adafruit_feather_esp32s2/board.c @@ -27,11 +27,12 @@ #include "supervisor/board.h" #include "mpconfigboard.h" #include "shared-bindings/microcontroller/Pin.h" +#include "components/driver/include/driver/gpio.h" +#include "components/hal/include/hal/gpio_hal.h" +#include "common-hal/microcontroller/Pin.h" void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); + reset_board(); } bool board_requests_safe_mode(void) { @@ -39,7 +40,9 @@ bool board_requests_safe_mode(void) { } void reset_board(void) { - + // Turn on I2C power by default. + gpio_set_direction(7, GPIO_MODE_DEF_OUTPUT); + gpio_set_level(7, false); } void board_deinit(void) { diff --git a/ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h b/ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h index fcd4a2cf60..2eb3344029 100644 --- a/ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h +++ b/ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h @@ -47,3 +47,5 @@ #define DEFAULT_UART_BUS_RX (&pin_GPIO38) #define DEFAULT_UART_BUS_TX (&pin_GPIO39) + +#define DOUBLE_TAP_PIN (&pin_GPIO34) diff --git a/ports/espressif/boards/adafruit_feather_esp32s2/pins.c b/ports/espressif/boards/adafruit_feather_esp32s2/pins.c index fff95265b5..c9f0e870ed 100644 --- a/ports/espressif/boards/adafruit_feather_esp32s2/pins.c +++ b/ports/espressif/boards/adafruit_feather_esp32s2/pins.c @@ -3,6 +3,8 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + { MP_ROM_QSTR(MP_QSTR_BUTTON), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_BOOT0), MP_ROM_PTR(&pin_GPIO0) }, { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_GPIO0) }, { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO3) }, @@ -14,8 +16,8 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_GPIO5) }, { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_GPIO6) }, - { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_GPIO7) }, { MP_ROM_QSTR(MP_QSTR_I2C_POWER_INVERTED), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_GPIO7) }, { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_GPIO8) }, { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_GPIO8) }, @@ -64,6 +66,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_D39), MP_ROM_PTR(&pin_GPIO39) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) } }; diff --git a/ports/espressif/boards/adafruit_feather_esp32s2/sdkconfig b/ports/espressif/boards/adafruit_feather_esp32s2/sdkconfig index 9d8bbde967..f19afafa3d 100644 --- a/ports/espressif/boards/adafruit_feather_esp32s2/sdkconfig +++ b/ports/espressif/boards/adafruit_feather_esp32s2/sdkconfig @@ -1,5 +1,4 @@ CONFIG_ESP32S2_SPIRAM_SUPPORT=y - # # SPI RAM config # @@ -8,11 +7,12 @@ CONFIG_SPIRAM_TYPE_ESPPSRAM16=y # CONFIG_SPIRAM_TYPE_ESPPSRAM32 is not set # CONFIG_SPIRAM_TYPE_ESPPSRAM64 is not set CONFIG_SPIRAM_SIZE=2097152 +# end of SPI RAM config +CONFIG_DEFAULT_PSRAM_CLK_IO=30 # # PSRAM clock and cs IO for ESP32S2 # -CONFIG_DEFAULT_PSRAM_CLK_IO=30 CONFIG_DEFAULT_PSRAM_CS_IO=26 # end of PSRAM clock and cs IO for ESP32S2 @@ -30,4 +30,8 @@ CONFIG_SPIRAM_USE_MEMMAP=y # CONFIG_SPIRAM_USE_MALLOC is not set CONFIG_SPIRAM_MEMTEST=y # CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY is not set -# end of SPI RAM config +# +# LWIP +# +CONFIG_LWIP_LOCAL_HOSTNAME="espressif" +# end of LWIP diff --git a/ports/espressif/boards/adafruit_feather_esp32s2_tft/board.c b/ports/espressif/boards/adafruit_feather_esp32s2_tft/board.c index adc4ae1b01..74187899ef 100644 --- a/ports/espressif/boards/adafruit_feather_esp32s2_tft/board.c +++ b/ports/espressif/boards/adafruit_feather_esp32s2_tft/board.c @@ -31,6 +31,7 @@ #include "shared-bindings/microcontroller/Pin.h" #include "shared-module/displayio/__init__.h" #include "shared-module/displayio/mipi_constants.h" +#include "shared-bindings/board/__init__.h" displayio_fourwire_obj_t board_display_obj; @@ -45,7 +46,7 @@ uint8_t display_init_sequence[] = { // normal display mode on 0x13, 0, // display and color format settings - 0x36, 1, 0x60, + 0x36, 1, 0x68, 0xB6, 2, 0x0A, 0x82, 0x3A, 1 | DELAY, 0x55, 10, // ST7789V frame rate setting @@ -70,49 +71,33 @@ uint8_t display_init_sequence[] = { void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); - - - busio_spi_obj_t *spi = &displays[0].fourwire_bus.inline_bus; - - common_hal_busio_spi_construct( - spi, - &pin_GPIO36, // CLK - &pin_GPIO35, // MOSI - NULL // MISO not connected - ); - - common_hal_busio_spi_never_reset(spi); - - displayio_fourwire_obj_t* bus = &displays[0].fourwire_bus; + busio_spi_obj_t *spi = common_hal_board_create_spi(0); + displayio_fourwire_obj_t *bus = &displays[0].fourwire_bus; bus->base.type = &displayio_fourwire_type; common_hal_displayio_fourwire_construct( bus, spi, &pin_GPIO39, // DC - &pin_GPIO21, // CS + &pin_GPIO7, // CS &pin_GPIO40, // RST 40000000, // baudrate 0, // polarity 0 // phase ); - displayio_display_obj_t* display = &displays[0].display; + displayio_display_obj_t *display = &displays[0].display; display->base.type = &displayio_display_type; // workaround as board_init() is called before reset_port() in main.c pwmout_reset(); - common_hal_displayio_display_construct( display, bus, 240, // width (after rotation) 135, // height (after rotation) 40, // column start - 52, // row start + 53, // row start 0, // rotation 16, // color depth false, // grayscale @@ -144,9 +129,20 @@ bool board_requests_safe_mode(void) { return false; } -void reset_board(void) { +bool espressif_board_reset_pin_number(gpio_num_t pin_number) { + // Override the I2C/TFT power pin reset to prevent resetting the display. + if (pin_number == 21) { + // Turn on TFT and I2C + gpio_set_direction(21, GPIO_MODE_DEF_OUTPUT); + gpio_set_level(21, true); + return true; + } + return false; +} +void reset_board(void) { } void board_deinit(void) { + // TODO: Should we turn off the display when asleep? } diff --git a/ports/espressif/boards/adafruit_feather_esp32s2_tft/mpconfigboard.h b/ports/espressif/boards/adafruit_feather_esp32s2_tft/mpconfigboard.h index b850b85e01..a68593a308 100644 --- a/ports/espressif/boards/adafruit_feather_esp32s2_tft/mpconfigboard.h +++ b/ports/espressif/boards/adafruit_feather_esp32s2_tft/mpconfigboard.h @@ -47,3 +47,5 @@ #define DEFAULT_UART_BUS_RX (&pin_GPIO2) #define DEFAULT_UART_BUS_TX (&pin_GPIO1) + +#define DOUBLE_TAP_PIN (&pin_GPIO38) diff --git a/ports/espressif/boards/adafruit_feather_esp32s2_tft/pins.c b/ports/espressif/boards/adafruit_feather_esp32s2_tft/pins.c index 8d888ebfe7..fb2f898a18 100644 --- a/ports/espressif/boards/adafruit_feather_esp32s2_tft/pins.c +++ b/ports/espressif/boards/adafruit_feather_esp32s2_tft/pins.c @@ -5,18 +5,14 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS - { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_GPIO1) }, { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO2) }, { MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_GPIO2) }, - { MP_ROM_QSTR(MP_QSTR_R2), MP_ROM_PTR(&pin_GPIO2) }, { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_GPIO5) }, { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_GPIO6) }, - - { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_GPIO8) }, - { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_GPIO8) }, - { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_GPIO9) }, { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_GPIO10) }, { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_GPIO11) }, @@ -26,45 +22,54 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_GPIO13) }, { MP_ROM_QSTR(MP_QSTR_L), MP_ROM_PTR(&pin_GPIO13) }, - { MP_ROM_QSTR(MP_QSTR_D14), MP_ROM_PTR(&pin_GPIO14) }, + { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_GPIO14) }, + { MP_ROM_QSTR(MP_QSTR_D14), MP_ROM_PTR(&pin_GPIO14) }, - { MP_ROM_QSTR(MP_QSTR_D15), MP_ROM_PTR(&pin_GPIO15) }, { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_GPIO15) }, + { MP_ROM_QSTR(MP_QSTR_D15), MP_ROM_PTR(&pin_GPIO15) }, - { MP_ROM_QSTR(MP_QSTR_D16), MP_ROM_PTR(&pin_GPIO16) }, { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO16) }, + { MP_ROM_QSTR(MP_QSTR_D16), MP_ROM_PTR(&pin_GPIO16) }, - { MP_ROM_QSTR(MP_QSTR_D17), MP_ROM_PTR(&pin_GPIO17) }, { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO17) }, + { MP_ROM_QSTR(MP_QSTR_D17), MP_ROM_PTR(&pin_GPIO17) }, - { MP_ROM_QSTR(MP_QSTR_D18), MP_ROM_PTR(&pin_GPIO18) }, { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_D18), MP_ROM_PTR(&pin_GPIO18) }, { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO33) }, { MP_ROM_QSTR(MP_QSTR_NEOPIXEL_POWER), MP_ROM_PTR(&pin_GPIO34) }, - { MP_ROM_QSTR(MP_QSTR_D35), MP_ROM_PTR(&pin_GPIO35) }, + { MP_ROM_QSTR(MP_QSTR_TFT_I2C_POWER), MP_ROM_PTR(&pin_GPIO21) }, + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO35) }, + { MP_ROM_QSTR(MP_QSTR_D35), MP_ROM_PTR(&pin_GPIO35) }, - { MP_ROM_QSTR(MP_QSTR_D36), MP_ROM_PTR(&pin_GPIO36) }, { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO36) }, + { MP_ROM_QSTR(MP_QSTR_D36), MP_ROM_PTR(&pin_GPIO36) }, - { MP_ROM_QSTR(MP_QSTR_D37), MP_ROM_PTR(&pin_GPIO37) }, { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO37) }, + { MP_ROM_QSTR(MP_QSTR_D37), MP_ROM_PTR(&pin_GPIO37) }, - { MP_ROM_QSTR(MP_QSTR_D41), MP_ROM_PTR(&pin_GPIO41) }, { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO41) }, + { MP_ROM_QSTR(MP_QSTR_D41), MP_ROM_PTR(&pin_GPIO41) }, - { MP_ROM_QSTR(MP_QSTR_D42), MP_ROM_PTR(&pin_GPIO42) }, { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO42) }, + { MP_ROM_QSTR(MP_QSTR_D42), MP_ROM_PTR(&pin_GPIO42) }, - { MP_ROM_QSTR(MP_QSTR_TFT_CS), MP_ROM_PTR(&pin_GPIO21) }, + { MP_ROM_QSTR(MP_QSTR_TFT_CS), MP_ROM_PTR(&pin_GPIO7) }, { MP_ROM_QSTR(MP_QSTR_TFT_DC), MP_ROM_PTR(&pin_GPIO39) }, { MP_ROM_QSTR(MP_QSTR_TFT_RESET), MP_ROM_PTR(&pin_GPIO40) }, { MP_ROM_QSTR(MP_QSTR_TFT_BACKLIGHT), MP_ROM_PTR(&pin_GPIO45) }, + { MP_ROM_QSTR(MP_QSTR_BUTTON), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_BOOT0), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, diff --git a/ports/espressif/boards/adafruit_feather_esp32s2_tft/sdkconfig b/ports/espressif/boards/adafruit_feather_esp32s2_tft/sdkconfig index 9d8bbde967..f19afafa3d 100644 --- a/ports/espressif/boards/adafruit_feather_esp32s2_tft/sdkconfig +++ b/ports/espressif/boards/adafruit_feather_esp32s2_tft/sdkconfig @@ -1,5 +1,4 @@ CONFIG_ESP32S2_SPIRAM_SUPPORT=y - # # SPI RAM config # @@ -8,11 +7,12 @@ CONFIG_SPIRAM_TYPE_ESPPSRAM16=y # CONFIG_SPIRAM_TYPE_ESPPSRAM32 is not set # CONFIG_SPIRAM_TYPE_ESPPSRAM64 is not set CONFIG_SPIRAM_SIZE=2097152 +# end of SPI RAM config +CONFIG_DEFAULT_PSRAM_CLK_IO=30 # # PSRAM clock and cs IO for ESP32S2 # -CONFIG_DEFAULT_PSRAM_CLK_IO=30 CONFIG_DEFAULT_PSRAM_CS_IO=26 # end of PSRAM clock and cs IO for ESP32S2 @@ -30,4 +30,8 @@ CONFIG_SPIRAM_USE_MEMMAP=y # CONFIG_SPIRAM_USE_MALLOC is not set CONFIG_SPIRAM_MEMTEST=y # CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY is not set -# end of SPI RAM config +# +# LWIP +# +CONFIG_LWIP_LOCAL_HOSTNAME="espressif" +# end of LWIP diff --git a/ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/board.c b/ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/board.c index 943d91feda..71b381616f 100644 --- a/ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/board.c +++ b/ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/board.c @@ -50,10 +50,6 @@ uint8_t display_init_sequence[] = { */ void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); - // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO43); diff --git a/ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h b/ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h index d2cd01a681..9c759ac1ca 100644 --- a/ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h +++ b/ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h @@ -44,3 +44,5 @@ #define DEFAULT_SPI_BUS_SCK (&pin_GPIO36) #define DEFAULT_SPI_BUS_MOSI (&pin_GPIO35) #define DEFAULT_SPI_BUS_MISO (&pin_GPIO37) + +#define DOUBLE_TAP_PIN (&pin_GPIO34) diff --git a/ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/sdkconfig b/ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/sdkconfig index e69de29bb2..5b9c86dcc3 100644 --- a/ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/sdkconfig +++ b/ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/sdkconfig @@ -0,0 +1,6 @@ +# CONFIG_ESP32S2_SPIRAM_SUPPORT is not set +# +# LWIP +# +CONFIG_LWIP_LOCAL_HOSTNAME="espressif" +# end of LWIP diff --git a/ports/espressif/boards/adafruit_funhouse/board.c b/ports/espressif/boards/adafruit_funhouse/board.c index a4a1d07947..03e967148c 100644 --- a/ports/espressif/boards/adafruit_funhouse/board.c +++ b/ports/espressif/boards/adafruit_funhouse/board.c @@ -50,10 +50,6 @@ uint8_t display_init_sequence[] = { }; void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); - // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO37); @@ -61,7 +57,7 @@ void board_init(void) { #endif /* DEBUG */ busio_spi_obj_t *spi = &displays[0].fourwire_bus.inline_bus; - common_hal_busio_spi_construct(spi, &pin_GPIO36, &pin_GPIO35, NULL); + common_hal_busio_spi_construct(spi, &pin_GPIO36, &pin_GPIO35, NULL, false); common_hal_busio_spi_never_reset(spi); displayio_fourwire_obj_t *bus = &displays[0].fourwire_bus; diff --git a/ports/espressif/boards/adafruit_funhouse/mpconfigboard.h b/ports/espressif/boards/adafruit_funhouse/mpconfigboard.h index 6379147c30..a268020b7c 100644 --- a/ports/espressif/boards/adafruit_funhouse/mpconfigboard.h +++ b/ports/espressif/boards/adafruit_funhouse/mpconfigboard.h @@ -41,3 +41,5 @@ #define DEFAULT_I2C_BUS_SCL (&pin_GPIO33) #define DEFAULT_I2C_BUS_SDA (&pin_GPIO34) + +#define DOUBLE_TAP_PIN (&pin_GPIO38) diff --git a/ports/espressif/boards/adafruit_funhouse/mpconfigboard.mk b/ports/espressif/boards/adafruit_funhouse/mpconfigboard.mk index bcad455108..fb7b969b80 100644 --- a/ports/espressif/boards/adafruit_funhouse/mpconfigboard.mk +++ b/ports/espressif/boards/adafruit_funhouse/mpconfigboard.mk @@ -17,3 +17,10 @@ CIRCUITPY_ESP_FLASH_FREQ=40m CIRCUITPY_ESP_FLASH_SIZE=4MB CIRCUITPY_MODULE=wrover + +# Include these Python libraries in firmware. +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_PortalBase +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_FakeRequests +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Requests +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Display_Text diff --git a/ports/espressif/boards/adafruit_funhouse/pins.c b/ports/espressif/boards/adafruit_funhouse/pins.c index 1904150f35..17c2ac4256 100644 --- a/ports/espressif/boards/adafruit_funhouse/pins.c +++ b/ports/espressif/boards/adafruit_funhouse/pins.c @@ -48,6 +48,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_DEBUG_RX), MP_ROM_PTR(&pin_GPIO38) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display)}, }; MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/espressif/boards/adafruit_funhouse/sdkconfig b/ports/espressif/boards/adafruit_funhouse/sdkconfig index 9d8bbde967..f19afafa3d 100644 --- a/ports/espressif/boards/adafruit_funhouse/sdkconfig +++ b/ports/espressif/boards/adafruit_funhouse/sdkconfig @@ -1,5 +1,4 @@ CONFIG_ESP32S2_SPIRAM_SUPPORT=y - # # SPI RAM config # @@ -8,11 +7,12 @@ CONFIG_SPIRAM_TYPE_ESPPSRAM16=y # CONFIG_SPIRAM_TYPE_ESPPSRAM32 is not set # CONFIG_SPIRAM_TYPE_ESPPSRAM64 is not set CONFIG_SPIRAM_SIZE=2097152 +# end of SPI RAM config +CONFIG_DEFAULT_PSRAM_CLK_IO=30 # # PSRAM clock and cs IO for ESP32S2 # -CONFIG_DEFAULT_PSRAM_CLK_IO=30 CONFIG_DEFAULT_PSRAM_CS_IO=26 # end of PSRAM clock and cs IO for ESP32S2 @@ -30,4 +30,8 @@ CONFIG_SPIRAM_USE_MEMMAP=y # CONFIG_SPIRAM_USE_MALLOC is not set CONFIG_SPIRAM_MEMTEST=y # CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY is not set -# end of SPI RAM config +# +# LWIP +# +CONFIG_LWIP_LOCAL_HOSTNAME="espressif" +# end of LWIP diff --git a/ports/espressif/boards/adafruit_magtag_2.9_grayscale/board.c b/ports/espressif/boards/adafruit_magtag_2.9_grayscale/board.c index 020e6f6a1f..18dd280cea 100644 --- a/ports/espressif/boards/adafruit_magtag_2.9_grayscale/board.c +++ b/ports/espressif/boards/adafruit_magtag_2.9_grayscale/board.c @@ -110,10 +110,6 @@ const uint8_t display_stop_sequence[] = { }; void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); - // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO43); @@ -121,7 +117,7 @@ void board_init(void) { #endif /* DEBUG */ busio_spi_obj_t *spi = &displays[0].fourwire_bus.inline_bus; - common_hal_busio_spi_construct(spi, &pin_GPIO36, &pin_GPIO35, NULL); + common_hal_busio_spi_construct(spi, &pin_GPIO36, &pin_GPIO35, NULL, false); common_hal_busio_spi_never_reset(spi); displayio_fourwire_obj_t *bus = &displays[0].fourwire_bus; @@ -164,7 +160,8 @@ void board_init(void) { false, // busy_state 5.0, // seconds_per_frame false, // always_toggle_chip_select - true); // grayscale + true, // grayscale + false); // two_byte_sequence_length } bool board_requests_safe_mode(void) { @@ -175,6 +172,25 @@ void reset_board(void) { } +bool espressif_board_reset_pin_number(gpio_num_t pin_number) { + // Pin 16 is speaker enable and it's pulled down on the board. We don't want + // to pull it high because then we'll compete with the external pull down. + // So, reset without any pulls internally. + if (pin_number == 16) { + gpio_config_t cfg = { + .pin_bit_mask = BIT64(16), + .mode = GPIO_MODE_DISABLE, + // The pin is externally pulled down, so we don't need to pull it. + .pull_up_en = false, + .pull_down_en = false, + .intr_type = GPIO_INTR_DISABLE, + }; + gpio_config(&cfg); + return true; + } + return false; +} + void board_deinit(void) { displayio_epaperdisplay_obj_t *display = &displays[0].epaper_display; if (display->base.type == &displayio_epaperdisplay_type) { diff --git a/ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h b/ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h index 343bb525f1..ad81cc2ca7 100644 --- a/ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h +++ b/ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h @@ -42,3 +42,5 @@ #define DEFAULT_I2C_BUS_SCL (&pin_GPIO34) #define DEFAULT_I2C_BUS_SDA (&pin_GPIO33) + +#define DOUBLE_TAP_PIN (&pin_GPIO38) diff --git a/ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.mk b/ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.mk index 4acef7fd94..3091d298e9 100644 --- a/ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.mk +++ b/ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.mk @@ -17,3 +17,11 @@ CIRCUITPY_ESP_FLASH_FREQ=40m CIRCUITPY_ESP_FLASH_SIZE=4MB CIRCUITPY_MODULE=wrover + +# Include these Python libraries in firmware. +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_PortalBase +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_FakeRequests +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Requests +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Display_Text +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_LIS3DH diff --git a/ports/espressif/boards/adafruit_magtag_2.9_grayscale/pins.c b/ports/espressif/boards/adafruit_magtag_2.9_grayscale/pins.c index 79b1feb40c..2aa2b11b06 100644 --- a/ports/espressif/boards/adafruit_magtag_2.9_grayscale/pins.c +++ b/ports/espressif/boards/adafruit_magtag_2.9_grayscale/pins.c @@ -53,6 +53,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_GPIO1) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].epaper_display)}, diff --git a/ports/espressif/boards/adafruit_magtag_2.9_grayscale/sdkconfig b/ports/espressif/boards/adafruit_magtag_2.9_grayscale/sdkconfig index 9d8bbde967..f19afafa3d 100644 --- a/ports/espressif/boards/adafruit_magtag_2.9_grayscale/sdkconfig +++ b/ports/espressif/boards/adafruit_magtag_2.9_grayscale/sdkconfig @@ -1,5 +1,4 @@ CONFIG_ESP32S2_SPIRAM_SUPPORT=y - # # SPI RAM config # @@ -8,11 +7,12 @@ CONFIG_SPIRAM_TYPE_ESPPSRAM16=y # CONFIG_SPIRAM_TYPE_ESPPSRAM32 is not set # CONFIG_SPIRAM_TYPE_ESPPSRAM64 is not set CONFIG_SPIRAM_SIZE=2097152 +# end of SPI RAM config +CONFIG_DEFAULT_PSRAM_CLK_IO=30 # # PSRAM clock and cs IO for ESP32S2 # -CONFIG_DEFAULT_PSRAM_CLK_IO=30 CONFIG_DEFAULT_PSRAM_CS_IO=26 # end of PSRAM clock and cs IO for ESP32S2 @@ -30,4 +30,8 @@ CONFIG_SPIRAM_USE_MEMMAP=y # CONFIG_SPIRAM_USE_MALLOC is not set CONFIG_SPIRAM_MEMTEST=y # CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY is not set -# end of SPI RAM config +# +# LWIP +# +CONFIG_LWIP_LOCAL_HOSTNAME="espressif" +# end of LWIP diff --git a/ports/espressif/boards/adafruit_metro_esp32s2/board.c b/ports/espressif/boards/adafruit_metro_esp32s2/board.c index 5abd1ce1b3..6772768da5 100644 --- a/ports/espressif/boards/adafruit_metro_esp32s2/board.c +++ b/ports/espressif/boards/adafruit_metro_esp32s2/board.c @@ -29,9 +29,6 @@ #include "shared-bindings/microcontroller/Pin.h" void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); } bool board_requests_safe_mode(void) { diff --git a/ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h b/ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h index ec992383aa..51d93224a4 100644 --- a/ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h +++ b/ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h @@ -46,3 +46,5 @@ #define DEFAULT_UART_BUS_RX (&pin_GPIO5) #define DEFAULT_UART_BUS_TX (&pin_GPIO6) + +#define DOUBLE_TAP_PIN (&pin_GPIO38) diff --git a/ports/espressif/boards/adafruit_metro_esp32s2/pins.c b/ports/espressif/boards/adafruit_metro_esp32s2/pins.c index 4c393b4f85..0d2777b204 100644 --- a/ports/espressif/boards/adafruit_metro_esp32s2/pins.c +++ b/ports/espressif/boards/adafruit_metro_esp32s2/pins.c @@ -64,6 +64,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_DEBUG_TX), MP_ROM_PTR(&pin_GPIO37) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, }; diff --git a/ports/espressif/boards/adafruit_metro_esp32s2/sdkconfig b/ports/espressif/boards/adafruit_metro_esp32s2/sdkconfig index 80b9a2cf8e..9ad9e6c3bb 100644 --- a/ports/espressif/boards/adafruit_metro_esp32s2/sdkconfig +++ b/ports/espressif/boards/adafruit_metro_esp32s2/sdkconfig @@ -1,5 +1,4 @@ CONFIG_ESP32S2_SPIRAM_SUPPORT=y - # # SPI RAM config # @@ -8,11 +7,12 @@ CONFIG_SPIRAM_TYPE_ESPPSRAM16=y # CONFIG_SPIRAM_TYPE_ESPPSRAM32 is not set # CONFIG_SPIRAM_TYPE_ESPPSRAM64 is not set CONFIG_SPIRAM_SIZE=2097152 +# end of SPI RAM config +CONFIG_DEFAULT_PSRAM_CLK_IO=30 # # PSRAM clock and cs IO for ESP32S2 # -CONFIG_DEFAULT_PSRAM_CLK_IO=30 CONFIG_DEFAULT_PSRAM_CS_IO=26 # end of PSRAM clock and cs IO for ESP32S2 @@ -30,8 +30,6 @@ CONFIG_SPIRAM_USE_MEMMAP=y # CONFIG_SPIRAM_USE_MALLOC is not set CONFIG_SPIRAM_MEMTEST=y # CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY is not set -# end of SPI RAM config - # # LWIP # diff --git a/ports/espressif/boards/adafruit_qtpy_esp32s2/board.c b/ports/espressif/boards/adafruit_qtpy_esp32s2/board.c index 5abd1ce1b3..6772768da5 100644 --- a/ports/espressif/boards/adafruit_qtpy_esp32s2/board.c +++ b/ports/espressif/boards/adafruit_qtpy_esp32s2/board.c @@ -29,9 +29,6 @@ #include "shared-bindings/microcontroller/Pin.h" void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); } bool board_requests_safe_mode(void) { diff --git a/ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h b/ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h index dd8b1a2ac8..4afce4c042 100644 --- a/ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h +++ b/ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h @@ -38,12 +38,19 @@ #define AUTORESET_DELAY_MS 500 -#define DEFAULT_I2C_BUS_SCL (&pin_GPIO6) -#define DEFAULT_I2C_BUS_SDA (&pin_GPIO7) +#define CIRCUITPY_BOARD_I2C (2) +#define CIRCUITPY_BOARD_I2C_PIN {{.scl = &pin_GPIO6, .sda = &pin_GPIO7}, \ + {.scl = &pin_GPIO40, .sda = &pin_GPIO41}} -#define DEFAULT_SPI_BUS_SCK (&pin_GPIO36) -#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO35) -#define DEFAULT_SPI_BUS_MISO (&pin_GPIO37) +#define CIRCUITPY_BOARD_SPI (1) +#define CIRCUITPY_BOARD_SPI_PIN {{.clock = &pin_GPIO36, .mosi = &pin_GPIO35, .miso = &pin_GPIO37}} -#define DEFAULT_UART_BUS_RX (&pin_GPIO16) -#define DEFAULT_UART_BUS_TX (&pin_GPIO5) +#define CIRCUITPY_BOARD_UART (1) +#define CIRCUITPY_BOARD_UART_PIN {{.tx = &pin_GPIO5, .rx = &pin_GPIO16}} + +#define DOUBLE_TAP_PIN (&pin_GPIO10) + +#ifdef DEBUG +#define DEBUG_UART_RX (&pin_GPIO16) +#define DEBUG_UART_TX (&pin_GPIO5) +#endif diff --git a/ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.mk b/ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.mk index 38cdd83779..d415e140cb 100644 --- a/ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.mk +++ b/ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.mk @@ -18,8 +18,3 @@ CIRCUITPY_ESP_FLASH_FREQ=40m CIRCUITPY_ESP_FLASH_SIZE=4MB CIRCUITPY_MODULE=wroom - -FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Requests -FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel -FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_BusDevice -FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Register diff --git a/ports/espressif/boards/adafruit_qtpy_esp32s2/pins.c b/ports/espressif/boards/adafruit_qtpy_esp32s2/pins.c index ac5d2275d0..a1d1b7b50f 100644 --- a/ports/espressif/boards/adafruit_qtpy_esp32s2/pins.c +++ b/ports/espressif/boards/adafruit_qtpy_esp32s2/pins.c @@ -1,59 +1,63 @@ #include "shared-bindings/board/__init__.h" +CIRCUITPY_BOARD_BUS_SINGLETON(stemma_i2c, i2c, 1) + STATIC const mp_rom_map_elem_t board_module_globals_table[] = { CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS - { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_GPIO0) }, { MP_ROM_QSTR(MP_QSTR_BUTTON), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_BOOT0), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_GPIO0) }, - { MP_ROM_QSTR(MP_QSTR_D18), MP_ROM_PTR(&pin_GPIO18) }, { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_D18), MP_ROM_PTR(&pin_GPIO18) }, - { MP_ROM_QSTR(MP_QSTR_D17), MP_ROM_PTR(&pin_GPIO17) }, { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO17) }, + { MP_ROM_QSTR(MP_QSTR_D17), MP_ROM_PTR(&pin_GPIO17) }, - { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_GPIO9) }, { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_GPIO9) }, - { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_GPIO8) }, { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_GPIO8) }, - { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_GPIO7) }, { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_GPIO7) }, { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_GPIO7) }, - { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_GPIO6) }, { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO6) }, - { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_GPIO6) }, - { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_GPIO5) }, { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_GPIO5) }, { MP_ROM_QSTR(MP_QSTR_A6), MP_ROM_PTR(&pin_GPIO5) }, - { MP_ROM_QSTR(MP_QSTR_D16), MP_ROM_PTR(&pin_GPIO16) }, { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO16) }, + { MP_ROM_QSTR(MP_QSTR_D16), MP_ROM_PTR(&pin_GPIO16) }, { MP_ROM_QSTR(MP_QSTR_A7), MP_ROM_PTR(&pin_GPIO16) }, - { MP_ROM_QSTR(MP_QSTR_D35), MP_ROM_PTR(&pin_GPIO35) }, { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO35) }, + { MP_ROM_QSTR(MP_QSTR_D35), MP_ROM_PTR(&pin_GPIO35) }, - { MP_ROM_QSTR(MP_QSTR_D34), MP_ROM_PTR(&pin_GPIO34) }, - { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO34) }, + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO36) }, + { MP_ROM_QSTR(MP_QSTR_D36), MP_ROM_PTR(&pin_GPIO36) }, - { MP_ROM_QSTR(MP_QSTR_D33), MP_ROM_PTR(&pin_GPIO33) }, - { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO33) }, + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO37) }, + { MP_ROM_QSTR(MP_QSTR_D37), MP_ROM_PTR(&pin_GPIO37) }, { MP_ROM_QSTR(MP_QSTR_NEOPIXEL_POWER), MP_ROM_PTR(&pin_GPIO38) }, { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO39) }, - { MP_ROM_QSTR(MP_QSTR_D40), MP_ROM_PTR(&pin_GPIO40) }, { MP_ROM_QSTR(MP_QSTR_SCL1), MP_ROM_PTR(&pin_GPIO40) }, + { MP_ROM_QSTR(MP_QSTR_D40), MP_ROM_PTR(&pin_GPIO40) }, - { MP_ROM_QSTR(MP_QSTR_D41), MP_ROM_PTR(&pin_GPIO41) }, { MP_ROM_QSTR(MP_QSTR_SDA1), MP_ROM_PTR(&pin_GPIO41) }, + { MP_ROM_QSTR(MP_QSTR_D41), MP_ROM_PTR(&pin_GPIO41) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_stemma_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, - { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) } + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, }; MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/espressif/boards/adafruit_qtpy_esp32s2/sdkconfig b/ports/espressif/boards/adafruit_qtpy_esp32s2/sdkconfig index 9d8bbde967..f19afafa3d 100644 --- a/ports/espressif/boards/adafruit_qtpy_esp32s2/sdkconfig +++ b/ports/espressif/boards/adafruit_qtpy_esp32s2/sdkconfig @@ -1,5 +1,4 @@ CONFIG_ESP32S2_SPIRAM_SUPPORT=y - # # SPI RAM config # @@ -8,11 +7,12 @@ CONFIG_SPIRAM_TYPE_ESPPSRAM16=y # CONFIG_SPIRAM_TYPE_ESPPSRAM32 is not set # CONFIG_SPIRAM_TYPE_ESPPSRAM64 is not set CONFIG_SPIRAM_SIZE=2097152 +# end of SPI RAM config +CONFIG_DEFAULT_PSRAM_CLK_IO=30 # # PSRAM clock and cs IO for ESP32S2 # -CONFIG_DEFAULT_PSRAM_CLK_IO=30 CONFIG_DEFAULT_PSRAM_CS_IO=26 # end of PSRAM clock and cs IO for ESP32S2 @@ -30,4 +30,8 @@ CONFIG_SPIRAM_USE_MEMMAP=y # CONFIG_SPIRAM_USE_MALLOC is not set CONFIG_SPIRAM_MEMTEST=y # CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY is not set -# end of SPI RAM config +# +# LWIP +# +CONFIG_LWIP_LOCAL_HOSTNAME="espressif" +# end of LWIP diff --git a/ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/board.c b/ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/board.c new file mode 100644 index 0000000000..ff9418ec86 --- /dev/null +++ b/ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/board.c @@ -0,0 +1,48 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "supervisor/board.h" +#include "mpconfigboard.h" +#include "shared-bindings/microcontroller/Pin.h" + +void board_init(void) { + // Debug UART + #ifdef DEBUG + common_hal_never_reset_pin(&pin_GPIO43); + common_hal_never_reset_pin(&pin_GPIO44); + #endif +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { + +} + +void board_deinit(void) { +} diff --git a/ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.h b/ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.h new file mode 100644 index 0000000000..68a2a482f3 --- /dev/null +++ b/ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.h @@ -0,0 +1,51 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +// Micropython setup + +#define MICROPY_HW_BOARD_NAME "Adafruit QT Py ESP32-S3 no psram" +#define MICROPY_HW_MCU_NAME "ESP32S3" + +#define MICROPY_HW_NEOPIXEL (&pin_GPIO38) +#define CIRCUITPY_STATUS_LED_POWER (&pin_GPIO37) + +#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) + +#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") + +#define AUTORESET_DELAY_MS 500 + +#define CIRCUITPY_BOARD_I2C (2) +#define CIRCUITPY_BOARD_I2C_PIN {{.scl = &pin_GPIO6, .sda = &pin_GPIO7}, \ + {.scl = &pin_GPIO40, .sda = &pin_GPIO41}} + +#define CIRCUITPY_BOARD_SPI (1) +#define CIRCUITPY_BOARD_SPI_PIN {{.clock = &pin_GPIO35, .mosi = &pin_GPIO34, .miso = &pin_GPIO36}} + +#define CIRCUITPY_BOARD_UART (1) +#define CIRCUITPY_BOARD_UART_PIN {{.tx = &pin_GPIO5, .rx = &pin_GPIO16}} + +#define DOUBLE_TAP_PIN (&pin_GPIO10) diff --git a/ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.mk b/ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.mk new file mode 100644 index 0000000000..1156b1b915 --- /dev/null +++ b/ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.mk @@ -0,0 +1,23 @@ +USB_VID = 0x239A +USB_PID = 0x811A + +USB_PRODUCT = "QT Py ESP32S3 no psram" +USB_MANUFACTURER = "Adafruit" + +IDF_TARGET = esp32s3 + +INTERNAL_FLASH_FILESYSTEM = 1 +LONGINT_IMPL = MPZ + +# The default queue depth of 16 overflows on release builds, +# so increase it to 32. +CFLAGS += -DCFG_TUD_TASK_QUEUE_SZ=32 + +CIRCUITPY_ESP_FLASH_MODE=dio +CIRCUITPY_ESP_FLASH_FREQ=80m +CIRCUITPY_ESP_FLASH_SIZE=8MB + +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Requests +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_BusDevice +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Register diff --git a/ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/pins.c b/ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/pins.c new file mode 100644 index 0000000000..c0386232a8 --- /dev/null +++ b/ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/pins.c @@ -0,0 +1,62 @@ +#include "shared-bindings/board/__init__.h" + +CIRCUITPY_BOARD_BUS_SINGLETON(stemma_i2c, i2c, 1) + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + + { MP_ROM_QSTR(MP_QSTR_BUTTON), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_GPIO0) }, + + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_D18), MP_ROM_PTR(&pin_GPIO18) }, + + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO17) }, + { MP_ROM_QSTR(MP_QSTR_D17), MP_ROM_PTR(&pin_GPIO17) }, + + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_GPIO9) }, + + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_GPIO8) }, + + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_GPIO7) }, + + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_GPIO6) }, + + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_A6), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_GPIO5) }, + + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO16) }, + { MP_ROM_QSTR(MP_QSTR_A7), MP_ROM_PTR(&pin_GPIO16) }, + { MP_ROM_QSTR(MP_QSTR_D16), MP_ROM_PTR(&pin_GPIO16) }, + + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO34) }, + { MP_ROM_QSTR(MP_QSTR_D34), MP_ROM_PTR(&pin_GPIO34) }, + + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO35) }, + { MP_ROM_QSTR(MP_QSTR_D35), MP_ROM_PTR(&pin_GPIO35) }, + + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO36) }, + { MP_ROM_QSTR(MP_QSTR_D36), MP_ROM_PTR(&pin_GPIO36) }, + + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL_POWER), MP_ROM_PTR(&pin_GPIO37) }, + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO38) }, + + { MP_ROM_QSTR(MP_QSTR_SCL1), MP_ROM_PTR(&pin_GPIO40) }, + { MP_ROM_QSTR(MP_QSTR_D40), MP_ROM_PTR(&pin_GPIO40) }, + + { MP_ROM_QSTR(MP_QSTR_SDA1), MP_ROM_PTR(&pin_GPIO41) }, + { MP_ROM_QSTR(MP_QSTR_D41), MP_ROM_PTR(&pin_GPIO41) }, + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_stemma_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/sdkconfig b/ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/sdkconfig new file mode 100644 index 0000000000..a162344cfb --- /dev/null +++ b/ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/sdkconfig @@ -0,0 +1,8 @@ +CONFIG_ESP32S3_SPIRAM_SUPPORT=n + +# +# LWIP +# +CONFIG_LWIP_LOCAL_HOSTNAME="espressif-esp32s3" +# end of LWIP + diff --git a/ports/espressif/boards/ai_thinker_esp32-c3s-2m/board.c b/ports/espressif/boards/ai_thinker_esp32-c3s-2m/board.c new file mode 100644 index 0000000000..7dd29fd6f6 --- /dev/null +++ b/ports/espressif/boards/ai_thinker_esp32-c3s-2m/board.c @@ -0,0 +1,70 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 microDev + * Copyright (c) 2021 skieast/Bruce Segal + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "shared-bindings/microcontroller/Pin.h" +#include "supervisor/board.h" + +#include "components/driver/include/driver/gpio.h" +#include "soc/usb_serial_jtag_struct.h" + +void board_init(void) { + // Debug UART + #ifdef DEBUG + common_hal_never_reset_pin(&pin_GPIO20); + common_hal_never_reset_pin(&pin_GPIO21); + #endif + + // This board has LEDs connected to the USB pins + USB_SERIAL_JTAG.conf0.usb_pad_enable = 0; + USB_SERIAL_JTAG.conf0.dp_pullup = 0; +} + +bool board_requests_safe_mode(void) { + return false; +} + +bool espressif_board_reset_pin_number(gpio_num_t pin_number) { + // Pull LEDs down on reset rather than the default up + if (pin_number == 3 || pin_number == 4 || pin_number == 5 || pin_number == 18 || pin_number == 19) { + gpio_config_t cfg = { + .pin_bit_mask = BIT64(pin_number), + .mode = GPIO_MODE_DISABLE, + .pull_up_en = false, + .pull_down_en = true, + .intr_type = GPIO_INTR_DISABLE, + }; + gpio_config(&cfg); + return true; + } + return false; +} + +void reset_board(void) { +} + +void board_deinit(void) { +} diff --git a/ports/espressif/boards/ai_thinker_esp32-c3s-2m/mpconfigboard.h b/ports/espressif/boards/ai_thinker_esp32-c3s-2m/mpconfigboard.h new file mode 100644 index 0000000000..36a0125ca4 --- /dev/null +++ b/ports/espressif/boards/ai_thinker_esp32-c3s-2m/mpconfigboard.h @@ -0,0 +1,47 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 microDev + * Copyright (c) 2021 skieast/Bruce Segal + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +// Board setup +#define MICROPY_HW_BOARD_NAME "AITHinker ESP32-C3S_Kit_2M" +#define MICROPY_HW_MCU_NAME "ESP32-C3" + +// Status LED +#define MICROPY_HW_LED_STATUS (&pin_GPIO19) + +// Default bus pins +#define DEFAULT_UART_BUS_RX (&pin_GPIO20) +#define DEFAULT_UART_BUS_TX (&pin_GPIO21) + +// Serial over UART +#define DEBUG_UART_RX DEFAULT_UART_BUS_RX +#define DEBUG_UART_TX DEFAULT_UART_BUS_TX + +// For entering safe mode +#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO9) + +// Explanation of how a user got into safe mode +#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") diff --git a/ports/espressif/boards/ai_thinker_esp32-c3s-2m/mpconfigboard.mk b/ports/espressif/boards/ai_thinker_esp32-c3s-2m/mpconfigboard.mk new file mode 100644 index 0000000000..6d7a58ea5c --- /dev/null +++ b/ports/espressif/boards/ai_thinker_esp32-c3s-2m/mpconfigboard.mk @@ -0,0 +1,10 @@ +CIRCUITPY_CREATOR_ID = 0x70010001 +CIRCUITPY_CREATION_ID = 0x00100001 + +IDF_TARGET = esp32c3 + +INTERNAL_FLASH_FILESYSTEM = 1 + +CIRCUITPY_ESP_FLASH_MODE=dio +CIRCUITPY_ESP_FLASH_FREQ=80m +CIRCUITPY_ESP_FLASH_SIZE=2MB diff --git a/ports/espressif/boards/ai_thinker_esp32-c3s-2m/pins.c b/ports/espressif/boards/ai_thinker_esp32-c3s-2m/pins.c new file mode 100644 index 0000000000..37e9373202 --- /dev/null +++ b/ports/espressif/boards/ai_thinker_esp32-c3s-2m/pins.c @@ -0,0 +1,72 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 microDev + * Copyright (c) 2021 skieast/Bruce Segal + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + + { MP_ROM_QSTR(MP_QSTR_IO0), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_IO1), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_IO2), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_IO3), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_IO4), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_IO5), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_IO6), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_IO7), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_IO8), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_IO9), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_IO10), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_IO11), MP_ROM_PTR(&pin_GPIO11) }, + { MP_ROM_QSTR(MP_QSTR_IO12), MP_ROM_PTR(&pin_GPIO12) }, + { MP_ROM_QSTR(MP_QSTR_IO13), MP_ROM_PTR(&pin_GPIO13) }, + { MP_ROM_QSTR(MP_QSTR_IO14), MP_ROM_PTR(&pin_GPIO14) }, + { MP_ROM_QSTR(MP_QSTR_IO15), MP_ROM_PTR(&pin_GPIO15) }, + { MP_ROM_QSTR(MP_QSTR_IO16), MP_ROM_PTR(&pin_GPIO16) }, + { MP_ROM_QSTR(MP_QSTR_IO17), MP_ROM_PTR(&pin_GPIO17) }, + { MP_ROM_QSTR(MP_QSTR_IO18), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_IO19), MP_ROM_PTR(&pin_GPIO19) }, + { MP_ROM_QSTR(MP_QSTR_IO20), MP_ROM_PTR(&pin_GPIO20) }, + { MP_ROM_QSTR(MP_QSTR_IO21), MP_ROM_PTR(&pin_GPIO21) }, + + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO20) }, + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO21) }, + + { MP_ROM_QSTR(MP_QSTR_ADC), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_LED_YELLOW), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_LED_WHITE), MP_ROM_PTR(&pin_GPIO19) }, + { MP_ROM_QSTR(MP_QSTR_LED_RED), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_LED_GREEN), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_LED_BLUE), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_BUTTON), MP_ROM_PTR(&pin_GPIO9) }, + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/espressif/boards/ai_thinker_esp32-c3s-2m/sdkconfig b/ports/espressif/boards/ai_thinker_esp32-c3s-2m/sdkconfig new file mode 100644 index 0000000000..60d8719596 --- /dev/null +++ b/ports/espressif/boards/ai_thinker_esp32-c3s-2m/sdkconfig @@ -0,0 +1,5 @@ +# +# LWIP +# +CONFIG_LWIP_LOCAL_HOSTNAME="AIThinker-ESP32C3S-2M" +# end of LWIP diff --git a/ports/espressif/boards/ai_thinker_esp32-c3s/board.c b/ports/espressif/boards/ai_thinker_esp32-c3s/board.c index 83ef690007..7dd29fd6f6 100644 --- a/ports/espressif/boards/ai_thinker_esp32-c3s/board.c +++ b/ports/espressif/boards/ai_thinker_esp32-c3s/board.c @@ -28,28 +28,41 @@ #include "shared-bindings/microcontroller/Pin.h" #include "supervisor/board.h" -void board_init(void) { +#include "components/driver/include/driver/gpio.h" +#include "soc/usb_serial_jtag_struct.h" +void board_init(void) { // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO20); common_hal_never_reset_pin(&pin_GPIO21); #endif - // SPI Flash - common_hal_never_reset_pin(&pin_GPIO11); - common_hal_never_reset_pin(&pin_GPIO12); - common_hal_never_reset_pin(&pin_GPIO13); - common_hal_never_reset_pin(&pin_GPIO14); - common_hal_never_reset_pin(&pin_GPIO15); - common_hal_never_reset_pin(&pin_GPIO16); - common_hal_never_reset_pin(&pin_GPIO17); + // This board has LEDs connected to the USB pins + USB_SERIAL_JTAG.conf0.usb_pad_enable = 0; + USB_SERIAL_JTAG.conf0.dp_pullup = 0; } bool board_requests_safe_mode(void) { return false; } +bool espressif_board_reset_pin_number(gpio_num_t pin_number) { + // Pull LEDs down on reset rather than the default up + if (pin_number == 3 || pin_number == 4 || pin_number == 5 || pin_number == 18 || pin_number == 19) { + gpio_config_t cfg = { + .pin_bit_mask = BIT64(pin_number), + .mode = GPIO_MODE_DISABLE, + .pull_up_en = false, + .pull_down_en = true, + .intr_type = GPIO_INTR_DISABLE, + }; + gpio_config(&cfg); + return true; + } + return false; +} + void reset_board(void) { } diff --git a/ports/espressif/boards/ai_thinker_esp_12k_nodemcu/board.c b/ports/espressif/boards/ai_thinker_esp_12k_nodemcu/board.c index e40b6335bc..0432485111 100644 --- a/ports/espressif/boards/ai_thinker_esp_12k_nodemcu/board.c +++ b/ports/espressif/boards/ai_thinker_esp_12k_nodemcu/board.c @@ -29,10 +29,6 @@ #include "shared-bindings/microcontroller/Pin.h" void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); - // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO43); diff --git a/ports/espressif/boards/ai_thinker_esp_12k_nodemcu/sdkconfig b/ports/espressif/boards/ai_thinker_esp_12k_nodemcu/sdkconfig index 1a86435efc..49ee336ed4 100644 --- a/ports/espressif/boards/ai_thinker_esp_12k_nodemcu/sdkconfig +++ b/ports/espressif/boards/ai_thinker_esp_12k_nodemcu/sdkconfig @@ -1,5 +1,4 @@ CONFIG_ESP32S2_SPIRAM_SUPPORT=y - # # SPI RAM config # @@ -7,12 +6,13 @@ CONFIG_ESP32S2_SPIRAM_SUPPORT=y # CONFIG_SPIRAM_TYPE_ESPPSRAM16 is not set # CONFIG_SPIRAM_TYPE_ESPPSRAM32 is not set CONFIG_SPIRAM_TYPE_ESPPSRAM64=y -CONFIG_SPIRAM_SIZE=4194304 +CONFIG_SPIRAM_SIZE=8388608 +# end of SPI RAM config +CONFIG_DEFAULT_PSRAM_CLK_IO=30 # # PSRAM clock and cs IO for ESP32S2 # -CONFIG_DEFAULT_PSRAM_CLK_IO=30 CONFIG_DEFAULT_PSRAM_CS_IO=26 # end of PSRAM clock and cs IO for ESP32S2 @@ -30,4 +30,8 @@ CONFIG_SPIRAM_USE_MEMMAP=y # CONFIG_SPIRAM_USE_MALLOC is not set CONFIG_SPIRAM_MEMTEST=y # CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY is not set -# end of SPI RAM config +# +# LWIP +# +CONFIG_LWIP_LOCAL_HOSTNAME="espressif" +# end of LWIP diff --git a/ports/espressif/boards/artisense_rd00/board.c b/ports/espressif/boards/artisense_rd00/board.c index 2b18dd7592..ea363f6b54 100644 --- a/ports/espressif/boards/artisense_rd00/board.c +++ b/ports/espressif/boards/artisense_rd00/board.c @@ -29,10 +29,6 @@ #include "shared-bindings/microcontroller/Pin.h" void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); - // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO43); @@ -42,9 +38,6 @@ void board_init(void) { // Crystal common_hal_never_reset_pin(&pin_GPIO15); common_hal_never_reset_pin(&pin_GPIO16); - - // PSRAM - common_hal_never_reset_pin(&pin_GPIO26); } bool board_requests_safe_mode(void) { diff --git a/ports/espressif/boards/artisense_rd00/sdkconfig b/ports/espressif/boards/artisense_rd00/sdkconfig index b5bf2411f7..cd57f0d118 100644 --- a/ports/espressif/boards/artisense_rd00/sdkconfig +++ b/ports/espressif/boards/artisense_rd00/sdkconfig @@ -1,5 +1,4 @@ CONFIG_ESP32S2_SPIRAM_SUPPORT=y - # # SPI RAM config # @@ -8,11 +7,12 @@ CONFIG_SPIRAM_TYPE_ESPPSRAM16=y # CONFIG_SPIRAM_TYPE_ESPPSRAM32 is not set # CONFIG_SPIRAM_TYPE_ESPPSRAM64 is not set CONFIG_SPIRAM_SIZE=2097152 +# end of SPI RAM config +CONFIG_DEFAULT_PSRAM_CLK_IO=30 # # PSRAM clock and cs IO for ESP32S2 # -CONFIG_DEFAULT_PSRAM_CLK_IO=30 CONFIG_DEFAULT_PSRAM_CS_IO=26 # end of PSRAM clock and cs IO for ESP32S2 @@ -30,8 +30,6 @@ CONFIG_SPIRAM_USE_MEMMAP=y # CONFIG_SPIRAM_USE_MALLOC is not set CONFIG_SPIRAM_MEMTEST=y # CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY is not set -# end of SPI RAM config - # # LWIP # diff --git a/ports/espressif/boards/atmegazero_esp32s2/board.c b/ports/espressif/boards/atmegazero_esp32s2/board.c index a0e399b1ef..0432485111 100644 --- a/ports/espressif/boards/atmegazero_esp32s2/board.c +++ b/ports/espressif/boards/atmegazero_esp32s2/board.c @@ -29,24 +29,11 @@ #include "shared-bindings/microcontroller/Pin.h" void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); - // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO43); common_hal_never_reset_pin(&pin_GPIO44); #endif /* DEBUG */ - - // SPI Flash and RAM - common_hal_never_reset_pin(&pin_GPIO26); - common_hal_never_reset_pin(&pin_GPIO27); - common_hal_never_reset_pin(&pin_GPIO28); - common_hal_never_reset_pin(&pin_GPIO29); - common_hal_never_reset_pin(&pin_GPIO30); - common_hal_never_reset_pin(&pin_GPIO31); - common_hal_never_reset_pin(&pin_GPIO32); } bool board_requests_safe_mode(void) { diff --git a/ports/espressif/boards/atmegazero_esp32s2/sdkconfig b/ports/espressif/boards/atmegazero_esp32s2/sdkconfig index f42e0784c4..b528b9f343 100644 --- a/ports/espressif/boards/atmegazero_esp32s2/sdkconfig +++ b/ports/espressif/boards/atmegazero_esp32s2/sdkconfig @@ -1,5 +1,4 @@ CONFIG_ESP32S2_SPIRAM_SUPPORT=y - # # SPI RAM config # @@ -8,11 +7,12 @@ CONFIG_ESP32S2_SPIRAM_SUPPORT=y # CONFIG_SPIRAM_TYPE_ESPPSRAM32 is not set CONFIG_SPIRAM_TYPE_ESPPSRAM64=y CONFIG_SPIRAM_SIZE=8388608 +# end of SPI RAM config +CONFIG_DEFAULT_PSRAM_CLK_IO=30 # # PSRAM clock and cs IO for ESP32S2 # -CONFIG_DEFAULT_PSRAM_CLK_IO=30 CONFIG_DEFAULT_PSRAM_CS_IO=26 # end of PSRAM clock and cs IO for ESP32S2 @@ -30,8 +30,6 @@ CONFIG_SPIRAM_USE_MEMMAP=y # CONFIG_SPIRAM_USE_MALLOC is not set CONFIG_SPIRAM_MEMTEST=y # CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY is not set -# end of SPI RAM config - # # LWIP # diff --git a/ports/espressif/boards/crumpspace_crumps2/board.c b/ports/espressif/boards/crumpspace_crumps2/board.c index e40b6335bc..0432485111 100644 --- a/ports/espressif/boards/crumpspace_crumps2/board.c +++ b/ports/espressif/boards/crumpspace_crumps2/board.c @@ -29,10 +29,6 @@ #include "shared-bindings/microcontroller/Pin.h" void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); - // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO43); diff --git a/ports/espressif/boards/crumpspace_crumps2/sdkconfig b/ports/espressif/boards/crumpspace_crumps2/sdkconfig index 04b487625d..94158d85c5 100644 --- a/ports/espressif/boards/crumpspace_crumps2/sdkconfig +++ b/ports/espressif/boards/crumpspace_crumps2/sdkconfig @@ -1,5 +1,4 @@ CONFIG_ESP32S2_SPIRAM_SUPPORT=y - # # SPI RAM config # @@ -8,11 +7,12 @@ CONFIG_SPIRAM_TYPE_ESPPSRAM16=y # CONFIG_SPIRAM_TYPE_ESPPSRAM32 is not set # CONFIG_SPIRAM_TYPE_ESPPSRAM64 is not set CONFIG_SPIRAM_SIZE=2097152 +# end of SPI RAM config +CONFIG_DEFAULT_PSRAM_CLK_IO=30 # # PSRAM clock and cs IO for ESP32S2 # -CONFIG_DEFAULT_PSRAM_CLK_IO=30 CONFIG_DEFAULT_PSRAM_CS_IO=26 # end of PSRAM clock and cs IO for ESP32S2 @@ -30,8 +30,6 @@ CONFIG_SPIRAM_USE_MEMMAP=y # CONFIG_SPIRAM_USE_MALLOC is not set CONFIG_SPIRAM_MEMTEST=y # CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY is not set -# end of SPI RAM config - # # LWIP # diff --git a/ports/espressif/boards/electroniccats_bastwifi/board.c b/ports/espressif/boards/electroniccats_bastwifi/board.c index e40b6335bc..0432485111 100644 --- a/ports/espressif/boards/electroniccats_bastwifi/board.c +++ b/ports/espressif/boards/electroniccats_bastwifi/board.c @@ -29,10 +29,6 @@ #include "shared-bindings/microcontroller/Pin.h" void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); - // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO43); diff --git a/ports/espressif/boards/electroniccats_bastwifi/sdkconfig b/ports/espressif/boards/electroniccats_bastwifi/sdkconfig index e69de29bb2..5b9c86dcc3 100644 --- a/ports/espressif/boards/electroniccats_bastwifi/sdkconfig +++ b/ports/espressif/boards/electroniccats_bastwifi/sdkconfig @@ -0,0 +1,6 @@ +# CONFIG_ESP32S2_SPIRAM_SUPPORT is not set +# +# LWIP +# +CONFIG_LWIP_LOCAL_HOSTNAME="espressif" +# end of LWIP diff --git a/ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/board.c b/ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/board.c new file mode 100644 index 0000000000..e3b71f4832 --- /dev/null +++ b/ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/board.c @@ -0,0 +1,48 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 microDev + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "shared-bindings/microcontroller/Pin.h" +#include "supervisor/board.h" + +void board_init(void) { + // Debug UART + #ifdef DEBUG + common_hal_never_reset_pin(&pin_GPIO20); + common_hal_never_reset_pin(&pin_GPIO21); + #endif +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { +} + +#if CIRCUITPY_ALARM +void board_deinit(void) { +} +#endif diff --git a/ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.h b/ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.h new file mode 100644 index 0000000000..28c2ea11eb --- /dev/null +++ b/ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.h @@ -0,0 +1,47 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 microDev + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +// Board setup +#define MICROPY_HW_BOARD_NAME "ESP32-C3-DevKitM-1" +#define MICROPY_HW_MCU_NAME "ESP32-C3N4" + +// Status LED +#define MICROPY_HW_NEOPIXEL (&pin_GPIO8) +#define MICROPY_HW_NEOPIXEL_COUNT (1) + +// Default bus pins +#define DEFAULT_UART_BUS_RX (&pin_GPIO20) +#define DEFAULT_UART_BUS_TX (&pin_GPIO21) + +// Serial over UART +#define DEBUG_UART_RX DEFAULT_UART_BUS_RX +#define DEBUG_UART_TX DEFAULT_UART_BUS_TX + +// For entering safe mode +#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO2) + +// Explanation of how a user got into safe mode +#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") diff --git a/ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.mk b/ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.mk new file mode 100644 index 0000000000..b952dacef7 --- /dev/null +++ b/ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.mk @@ -0,0 +1,10 @@ +CIRCUITPY_CREATOR_ID = 0x000C303A +CIRCUITPY_CREATION_ID = 0x00C30001 + +IDF_TARGET = esp32c3 + +INTERNAL_FLASH_FILESYSTEM = 1 + +CIRCUITPY_ESP_FLASH_MODE=dio +CIRCUITPY_ESP_FLASH_FREQ=80m +CIRCUITPY_ESP_FLASH_SIZE=4MB diff --git a/ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/pins.c b/ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/pins.c new file mode 100644 index 0000000000..e948ae3fc8 --- /dev/null +++ b/ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/pins.c @@ -0,0 +1,61 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 microDev + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + + { MP_ROM_QSTR(MP_QSTR_IO0), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_IO1), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_IO2), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_IO3), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_IO4), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_IO5), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_IO6), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_IO7), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_IO8), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_IO9), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_IO10), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_IO18), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_IO19), MP_ROM_PTR(&pin_GPIO19) }, + { MP_ROM_QSTR(MP_QSTR_IO20), MP_ROM_PTR(&pin_GPIO20) }, + { MP_ROM_QSTR(MP_QSTR_IO21), MP_ROM_PTR(&pin_GPIO21) }, + + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO20) }, + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO21) }, + + { MP_ROM_QSTR(MP_QSTR_MTMS), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_MTDI), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_MTCK), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_MTDO), MP_ROM_PTR(&pin_GPIO7) }, + + { MP_ROM_QSTR(MP_QSTR_BUTTON), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO8) }, + + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/sdkconfig b/ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/sdkconfig new file mode 100644 index 0000000000..0e24f8dc77 --- /dev/null +++ b/ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/sdkconfig @@ -0,0 +1,5 @@ +# +# LWIP +# +CONFIG_LWIP_LOCAL_HOSTNAME="ESP32-C3-DevKitM-1" +# end of LWIP diff --git a/ports/espressif/boards/espressif_esp32s2_devkitc_1_n4r2/board.c b/ports/espressif/boards/espressif_esp32s2_devkitc_1_n4r2/board.c new file mode 100644 index 0000000000..0432485111 --- /dev/null +++ b/ports/espressif/boards/espressif_esp32s2_devkitc_1_n4r2/board.c @@ -0,0 +1,48 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "supervisor/board.h" +#include "mpconfigboard.h" +#include "shared-bindings/microcontroller/Pin.h" + +void board_init(void) { + // Debug UART + #ifdef DEBUG + common_hal_never_reset_pin(&pin_GPIO43); + common_hal_never_reset_pin(&pin_GPIO44); + #endif /* DEBUG */ +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { + +} + +void board_deinit(void) { +} diff --git a/ports/espressif/boards/espressif_esp32s2_devkitc_1_n4r2/mpconfigboard.h b/ports/espressif/boards/espressif_esp32s2_devkitc_1_n4r2/mpconfigboard.h new file mode 100644 index 0000000000..66214ed214 --- /dev/null +++ b/ports/espressif/boards/espressif_esp32s2_devkitc_1_n4r2/mpconfigboard.h @@ -0,0 +1,41 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +// Micropython setup + +#define MICROPY_HW_BOARD_NAME "ESP32-S2-DevKitC-1-N4R2" +#define MICROPY_HW_MCU_NAME "ESP32S2" + +#define MICROPY_HW_NEOPIXEL (&pin_GPIO18) + +#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) + +#define DEFAULT_UART_BUS_RX (&pin_GPIO44) +#define DEFAULT_UART_BUS_TX (&pin_GPIO43) + +#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") + +#define AUTORESET_DELAY_MS 500 diff --git a/ports/espressif/boards/espressif_esp32s2_devkitc_1_n4r2/mpconfigboard.mk b/ports/espressif/boards/espressif_esp32s2_devkitc_1_n4r2/mpconfigboard.mk new file mode 100644 index 0000000000..7644ce232c --- /dev/null +++ b/ports/espressif/boards/espressif_esp32s2_devkitc_1_n4r2/mpconfigboard.mk @@ -0,0 +1,17 @@ +USB_VID = 0x239A +USB_PID = 0x80A6 +USB_PRODUCT = "ESP32-S2-DevKitC-1-N4R2" +USB_MANUFACTURER = "Espressif" + +IDF_TARGET = esp32s2 + +INTERNAL_FLASH_FILESYSTEM = 1 +LONGINT_IMPL = MPZ + +# The default queue depth of 16 overflows on release builds, +# so increase it to 32. +CFLAGS += -DCFG_TUD_TASK_QUEUE_SZ=32 + +CIRCUITPY_ESP_FLASH_MODE=dio +CIRCUITPY_ESP_FLASH_FREQ=40m +CIRCUITPY_ESP_FLASH_SIZE=4MB diff --git a/ports/espressif/boards/espressif_esp32s2_devkitc_1_n4r2/pins.c b/ports/espressif/boards/espressif_esp32s2_devkitc_1_n4r2/pins.c new file mode 100644 index 0000000000..435f251c80 --- /dev/null +++ b/ports/espressif/boards/espressif_esp32s2_devkitc_1_n4r2/pins.c @@ -0,0 +1,53 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + + { MP_ROM_QSTR(MP_QSTR_IO0), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_IO1), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_IO2), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_IO3), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_IO4), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_IO5), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_IO6), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_IO7), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_IO8), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_IO9), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_IO10), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_IO11), MP_ROM_PTR(&pin_GPIO11) }, + { MP_ROM_QSTR(MP_QSTR_IO12), MP_ROM_PTR(&pin_GPIO12) }, + { MP_ROM_QSTR(MP_QSTR_IO13), MP_ROM_PTR(&pin_GPIO13) }, + { MP_ROM_QSTR(MP_QSTR_IO14), MP_ROM_PTR(&pin_GPIO14) }, + { MP_ROM_QSTR(MP_QSTR_IO15), MP_ROM_PTR(&pin_GPIO15) }, + { MP_ROM_QSTR(MP_QSTR_IO16), MP_ROM_PTR(&pin_GPIO16) }, + { MP_ROM_QSTR(MP_QSTR_IO17), MP_ROM_PTR(&pin_GPIO17) }, + + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_IO18), MP_ROM_PTR(&pin_GPIO18) }, + + { MP_ROM_QSTR(MP_QSTR_IO19), MP_ROM_PTR(&pin_GPIO19) }, + { MP_ROM_QSTR(MP_QSTR_IO20), MP_ROM_PTR(&pin_GPIO20) }, + { MP_ROM_QSTR(MP_QSTR_IO21), MP_ROM_PTR(&pin_GPIO21) }, + { MP_ROM_QSTR(MP_QSTR_IO26), MP_ROM_PTR(&pin_GPIO26) }, + { MP_ROM_QSTR(MP_QSTR_IO33), MP_ROM_PTR(&pin_GPIO33) }, + { MP_ROM_QSTR(MP_QSTR_IO34), MP_ROM_PTR(&pin_GPIO34) }, + { MP_ROM_QSTR(MP_QSTR_IO35), MP_ROM_PTR(&pin_GPIO35) }, + { MP_ROM_QSTR(MP_QSTR_IO36), MP_ROM_PTR(&pin_GPIO36) }, + { MP_ROM_QSTR(MP_QSTR_IO37), MP_ROM_PTR(&pin_GPIO37) }, + { MP_ROM_QSTR(MP_QSTR_IO38), MP_ROM_PTR(&pin_GPIO38) }, + { MP_ROM_QSTR(MP_QSTR_IO39), MP_ROM_PTR(&pin_GPIO39) }, + { MP_ROM_QSTR(MP_QSTR_IO40), MP_ROM_PTR(&pin_GPIO40) }, + { MP_ROM_QSTR(MP_QSTR_IO41), MP_ROM_PTR(&pin_GPIO41) }, + { MP_ROM_QSTR(MP_QSTR_IO42), MP_ROM_PTR(&pin_GPIO42) }, + + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO43) }, + { MP_ROM_QSTR(MP_QSTR_IO43), MP_ROM_PTR(&pin_GPIO43) }, + + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO44) }, + { MP_ROM_QSTR(MP_QSTR_IO44), MP_ROM_PTR(&pin_GPIO44) }, + + { MP_ROM_QSTR(MP_QSTR_IO45), MP_ROM_PTR(&pin_GPIO45) }, + { MP_ROM_QSTR(MP_QSTR_IO46), MP_ROM_PTR(&pin_GPIO46) }, + +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/espressif/boards/espressif_esp32s2_devkitc_1_n4r2/sdkconfig b/ports/espressif/boards/espressif_esp32s2_devkitc_1_n4r2/sdkconfig new file mode 100644 index 0000000000..926a7813ba --- /dev/null +++ b/ports/espressif/boards/espressif_esp32s2_devkitc_1_n4r2/sdkconfig @@ -0,0 +1,37 @@ +CONFIG_ESP32S2_SPIRAM_SUPPORT=y +# +# SPI RAM config +# +CONFIG_SPIRAM_MODE_QUAD=y +# CONFIG_SPIRAM_MODE_OCT is not set +# CONFIG_SPIRAM_TYPE_AUTO is not set +CONFIG_SPIRAM_TYPE_ESPPSRAM16=y +# CONFIG_SPIRAM_TYPE_ESPPSRAM32 is not set +# CONFIG_SPIRAM_TYPE_ESPPSRAM64 is not set +CONFIG_SPIRAM_SIZE=2097152 +# end of SPI RAM config + +CONFIG_DEFAULT_PSRAM_CLK_IO=30 +# +# PSRAM Clock and CS IO for ESP32S3 +# +CONFIG_DEFAULT_PSRAM_CS_IO=26 +# end of PSRAM Clock and CS IO for ESP32S3 + +# CONFIG_SPIRAM_FETCH_INSTRUCTIONS is not set +# CONFIG_SPIRAM_RODATA is not set +# CONFIG_SPIRAM_SPEED_120M is not set +# CONFIG_SPIRAM_SPEED_80M is not set +CONFIG_SPIRAM_SPEED_40M=y +CONFIG_SPIRAM=y +CONFIG_SPIRAM_BOOT_INIT=y +# CONFIG_SPIRAM_IGNORE_NOTFOUND is not set +CONFIG_SPIRAM_USE_MEMMAP=y +# CONFIG_SPIRAM_USE_CAPS_ALLOC is not set +# CONFIG_SPIRAM_USE_MALLOC is not set +CONFIG_SPIRAM_MEMTEST=y +# +# LWIP +# +CONFIG_LWIP_LOCAL_HOSTNAME="espressif-esp32s2" +# end of LWIP diff --git a/ports/espressif/boards/espressif_esp32s3_box/board.c b/ports/espressif/boards/espressif_esp32s3_box/board.c index dbe64077de..7111c90578 100644 --- a/ports/espressif/boards/espressif_esp32s3_box/board.c +++ b/ports/espressif/boards/espressif_esp32s3_box/board.c @@ -28,30 +28,73 @@ #include "mpconfigboard.h" #include "shared-bindings/microcontroller/Pin.h" +#include "shared-bindings/busio/SPI.h" +#include "shared-bindings/displayio/FourWire.h" +#include "shared-module/displayio/__init__.h" +#include "shared-module/displayio/mipi_constants.h" + +uint8_t display_init_sequence[] = { + 0x01, 0x80, 0x96, // _SWRESET and Delay 150ms + 0x11, 0x80, 0xFF, // _SLPOUT and Delay 500ms + 0x3A, 0x81, 0x55, 0x0A, // _COLMOD and Delay 10ms + 0x36, 0x01, 0x08, // _MADCTL + 0x13, 0x80, 0x0A, // _NORON and Delay 10ms + 0x36, 0x01, 0xC0, // _MADCTL + 0x29, 0x80, 0xFF, // _DISPON and Delay 500ms +}; + void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); + busio_spi_obj_t *spi = &displays[0].fourwire_bus.inline_bus; + common_hal_busio_spi_construct(spi, &pin_GPIO7, &pin_GPIO6, NULL, false); + common_hal_busio_spi_never_reset(spi); + + displayio_fourwire_obj_t *bus = &displays[0].fourwire_bus; + bus->base.type = &displayio_fourwire_type; + common_hal_displayio_fourwire_construct(bus, + spi, + &pin_GPIO4, // TFT_DC Command or data + &pin_GPIO5, // TFT_CS Chip select + &pin_GPIO48, // TFT_RST Reset + 60000000, // Baudrate + 0, // Polarity + 0); // Phase + + displayio_display_obj_t *display = &displays[0].display; + display->base.type = &displayio_display_type; + common_hal_displayio_display_construct(display, + bus, + 320, // Width + 240, // Height + 0, // column start + 0, // row start + 0, // rotation + 16, // Color depth + false, // Grayscale + false, // pixels in a byte share a row. Only valid for depths < 8 + 1, // bytes per cell. Only valid for depths < 8 + false, // reverse_pixels_in_byte. Only valid for depths < 8 + true, // reverse_pixels_in_word + MIPI_COMMAND_SET_COLUMN_ADDRESS, // Set column command + MIPI_COMMAND_SET_PAGE_ADDRESS, // Set row command + MIPI_COMMAND_WRITE_MEMORY_START, // Write memory command + display_init_sequence, + sizeof(display_init_sequence), + &pin_GPIO45, // backlight pin + NO_BRIGHTNESS_COMMAND, + 1.0f, // brightness (ignored) + true, // auto_brightness + false, // single_byte_bounds + false, // data_as_commands + true, // auto_refresh + 60, // native_frames_per_second + true, // backlight_on_high + false); // SH1107_addressing // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO43); common_hal_never_reset_pin(&pin_GPIO44); #endif - - // SPI Flash and RAM - common_hal_never_reset_pin(&pin_GPIO26); - common_hal_never_reset_pin(&pin_GPIO27); - common_hal_never_reset_pin(&pin_GPIO28); - common_hal_never_reset_pin(&pin_GPIO29); - common_hal_never_reset_pin(&pin_GPIO30); - common_hal_never_reset_pin(&pin_GPIO31); - common_hal_never_reset_pin(&pin_GPIO32); - common_hal_never_reset_pin(&pin_GPIO33); - common_hal_never_reset_pin(&pin_GPIO34); - common_hal_never_reset_pin(&pin_GPIO35); - common_hal_never_reset_pin(&pin_GPIO36); - common_hal_never_reset_pin(&pin_GPIO37); } bool board_requests_safe_mode(void) { diff --git a/ports/espressif/boards/espressif_esp32s3_box/mpconfigboard.mk b/ports/espressif/boards/espressif_esp32s3_box/mpconfigboard.mk index 285957b4e8..6664ba8c98 100644 --- a/ports/espressif/boards/espressif_esp32s3_box/mpconfigboard.mk +++ b/ports/espressif/boards/espressif_esp32s3_box/mpconfigboard.mk @@ -1,5 +1,5 @@ USB_VID = 0x303A -USB_PID = 0x7007 +USB_PID = 0x7005 USB_PRODUCT = "ESP32-S3-Box-2.5" USB_MANUFACTURER = "Espressif" diff --git a/ports/espressif/boards/espressif_esp32s3_box/pins.c b/ports/espressif/boards/espressif_esp32s3_box/pins.c index b4fd11a298..73ef15697c 100644 --- a/ports/espressif/boards/espressif_esp32s3_box/pins.c +++ b/ports/espressif/boards/espressif_esp32s3_box/pins.c @@ -1,4 +1,5 @@ #include "shared-bindings/board/__init__.h" +#include "shared-module/displayio/__init__.h" STATIC const mp_rom_map_elem_t board_module_globals_table[] = { CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS @@ -60,5 +61,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { // boot button, also usable as a software button { MP_ROM_QSTR(MP_QSTR_BOOT), MP_ROM_PTR(&pin_GPIO0) }, + + { MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display)} }; MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/espressif/boards/espressif_esp32s3_box/sdkconfig b/ports/espressif/boards/espressif_esp32s3_box/sdkconfig index 73661c9f92..7fcf8ef297 100644 --- a/ports/espressif/boards/espressif_esp32s3_box/sdkconfig +++ b/ports/espressif/boards/espressif_esp32s3_box/sdkconfig @@ -1,9 +1,37 @@ CONFIG_ESP32S3_SPIRAM_SUPPORT=y -CONFIG_LWIP_LOCAL_HOSTNAME="espressif-esp32s3" -CONFIG_SPIRAM_BOOT_INIT=y -CONFIG_SPIRAM_MEMTEST=y +# +# SPI RAM config +# +# CONFIG_SPIRAM_MODE_QUAD is not set CONFIG_SPIRAM_MODE_OCT=y -CONFIG_SPIRAM_SPEED_80M=y CONFIG_SPIRAM_TYPE_AUTO=y -CONFIG_SPIRAM_USE_MALLOC=n +# CONFIG_SPIRAM_TYPE_ESPPSRAM64 is not set +CONFIG_SPIRAM_SIZE=-1 +# end of SPI RAM config + +CONFIG_DEFAULT_PSRAM_CLK_IO=30 +# +# PSRAM Clock and CS IO for ESP32S3 +# +CONFIG_DEFAULT_PSRAM_CS_IO=26 +# end of PSRAM Clock and CS IO for ESP32S3 + +# CONFIG_SPIRAM_FETCH_INSTRUCTIONS is not set +# CONFIG_SPIRAM_RODATA is not set +CONFIG_SPIRAM_SPEED_80M=y +# CONFIG_SPIRAM_SPEED_40M is not set CONFIG_SPIRAM=y +CONFIG_SPIRAM_BOOT_INIT=y +# CONFIG_SPIRAM_IGNORE_NOTFOUND is not set +# CONFIG_SPIRAM_USE_MEMMAP is not set +# CONFIG_SPIRAM_USE_CAPS_ALLOC is not set +CONFIG_SPIRAM_USE_MALLOC=y +CONFIG_SPIRAM_MEMTEST=y +CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=16384 +# CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP is not set +CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL=32768 +# +# LWIP +# +CONFIG_LWIP_LOCAL_HOSTNAME="espressif-esp32s3" +# end of LWIP diff --git a/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/board.c b/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/board.c new file mode 100644 index 0000000000..ff9418ec86 --- /dev/null +++ b/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/board.c @@ -0,0 +1,48 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "supervisor/board.h" +#include "mpconfigboard.h" +#include "shared-bindings/microcontroller/Pin.h" + +void board_init(void) { + // Debug UART + #ifdef DEBUG + common_hal_never_reset_pin(&pin_GPIO43); + common_hal_never_reset_pin(&pin_GPIO44); + #endif +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { + +} + +void board_deinit(void) { +} diff --git a/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h b/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h new file mode 100644 index 0000000000..4c584e96cd --- /dev/null +++ b/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h @@ -0,0 +1,41 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +// Micropython setup + +#define MICROPY_HW_BOARD_NAME "ESP32-S3-DevKitC-1-N8" +#define MICROPY_HW_MCU_NAME "ESP32S3" + +#define MICROPY_HW_NEOPIXEL (&pin_GPIO48) + +#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) + +#define DEFAULT_UART_BUS_RX (&pin_GPIO44) +#define DEFAULT_UART_BUS_TX (&pin_GPIO43) + +#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") + +#define AUTORESET_DELAY_MS 500 diff --git a/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.mk b/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.mk new file mode 100644 index 0000000000..b6ead37eee --- /dev/null +++ b/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.mk @@ -0,0 +1,17 @@ +USB_VID = 0x303A +USB_PID = 0x7003 +USB_PRODUCT = "ESP32-S3-DevKitC-1-N8" +USB_MANUFACTURER = "Espressif" + +IDF_TARGET = esp32s3 + +INTERNAL_FLASH_FILESYSTEM = 1 +LONGINT_IMPL = MPZ + +# The default queue depth of 16 overflows on release builds, +# so increase it to 32. +CFLAGS += -DCFG_TUD_TASK_QUEUE_SZ=32 + +CIRCUITPY_ESP_FLASH_MODE=dio +CIRCUITPY_ESP_FLASH_FREQ=80m +CIRCUITPY_ESP_FLASH_SIZE=8MB diff --git a/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/pins.c b/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/pins.c new file mode 100644 index 0000000000..919deca8b4 --- /dev/null +++ b/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/pins.c @@ -0,0 +1,49 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + + { MP_ROM_QSTR(MP_QSTR_IO0), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_IO1), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_IO2), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_IO3), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_IO4), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_IO5), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_IO6), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_IO7), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_IO8), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_IO9), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_IO10), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_IO11), MP_ROM_PTR(&pin_GPIO11) }, + { MP_ROM_QSTR(MP_QSTR_IO12), MP_ROM_PTR(&pin_GPIO12) }, + { MP_ROM_QSTR(MP_QSTR_IO13), MP_ROM_PTR(&pin_GPIO13) }, + { MP_ROM_QSTR(MP_QSTR_IO14), MP_ROM_PTR(&pin_GPIO14) }, + { MP_ROM_QSTR(MP_QSTR_IO15), MP_ROM_PTR(&pin_GPIO15) }, + { MP_ROM_QSTR(MP_QSTR_IO16), MP_ROM_PTR(&pin_GPIO16) }, + { MP_ROM_QSTR(MP_QSTR_IO17), MP_ROM_PTR(&pin_GPIO17) }, + { MP_ROM_QSTR(MP_QSTR_IO18), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_IO19), MP_ROM_PTR(&pin_GPIO19) }, + { MP_ROM_QSTR(MP_QSTR_IO20), MP_ROM_PTR(&pin_GPIO20) }, + { MP_ROM_QSTR(MP_QSTR_IO21), MP_ROM_PTR(&pin_GPIO21) }, + { MP_ROM_QSTR(MP_QSTR_IO35), MP_ROM_PTR(&pin_GPIO35) }, + { MP_ROM_QSTR(MP_QSTR_IO36), MP_ROM_PTR(&pin_GPIO36) }, + { MP_ROM_QSTR(MP_QSTR_IO37), MP_ROM_PTR(&pin_GPIO37) }, + { MP_ROM_QSTR(MP_QSTR_IO38), MP_ROM_PTR(&pin_GPIO38) }, + { MP_ROM_QSTR(MP_QSTR_IO39), MP_ROM_PTR(&pin_GPIO39) }, + { MP_ROM_QSTR(MP_QSTR_IO40), MP_ROM_PTR(&pin_GPIO40) }, + { MP_ROM_QSTR(MP_QSTR_IO41), MP_ROM_PTR(&pin_GPIO41) }, + { MP_ROM_QSTR(MP_QSTR_IO42), MP_ROM_PTR(&pin_GPIO42) }, + { MP_ROM_QSTR(MP_QSTR_IO43), MP_ROM_PTR(&pin_GPIO43) }, + { MP_ROM_QSTR(MP_QSTR_IO44), MP_ROM_PTR(&pin_GPIO44) }, + { MP_ROM_QSTR(MP_QSTR_IO45), MP_ROM_PTR(&pin_GPIO45) }, + { MP_ROM_QSTR(MP_QSTR_IO46), MP_ROM_PTR(&pin_GPIO46) }, + { MP_ROM_QSTR(MP_QSTR_IO47), MP_ROM_PTR(&pin_GPIO47) }, + { MP_ROM_QSTR(MP_QSTR_IO48), MP_ROM_PTR(&pin_GPIO48) }, + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO48) }, + + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO43) }, + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO44) }, + + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/sdkconfig b/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/sdkconfig new file mode 100644 index 0000000000..a0a61d8392 --- /dev/null +++ b/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/sdkconfig @@ -0,0 +1,6 @@ +# CONFIG_ESP32S3_SPIRAM_SUPPORT is not set +# +# LWIP +# +CONFIG_LWIP_LOCAL_HOSTNAME="espressif-esp32s3" +# end of LWIP diff --git a/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/board.c b/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/board.c new file mode 100644 index 0000000000..ff9418ec86 --- /dev/null +++ b/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/board.c @@ -0,0 +1,48 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "supervisor/board.h" +#include "mpconfigboard.h" +#include "shared-bindings/microcontroller/Pin.h" + +void board_init(void) { + // Debug UART + #ifdef DEBUG + common_hal_never_reset_pin(&pin_GPIO43); + common_hal_never_reset_pin(&pin_GPIO44); + #endif +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { + +} + +void board_deinit(void) { +} diff --git a/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h b/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h new file mode 100644 index 0000000000..eb6cae949f --- /dev/null +++ b/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h @@ -0,0 +1,41 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +// Micropython setup + +#define MICROPY_HW_BOARD_NAME "ESP32-S3-DevKitC-1-N8R2" +#define MICROPY_HW_MCU_NAME "ESP32S3" + +#define MICROPY_HW_NEOPIXEL (&pin_GPIO48) + +#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) + +#define DEFAULT_UART_BUS_RX (&pin_GPIO44) +#define DEFAULT_UART_BUS_TX (&pin_GPIO43) + +#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") + +#define AUTORESET_DELAY_MS 500 diff --git a/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.mk b/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.mk new file mode 100644 index 0000000000..7fff66f5d8 --- /dev/null +++ b/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.mk @@ -0,0 +1,17 @@ +USB_VID = 0x303A +USB_PID = 0x7003 +USB_PRODUCT = "ESP32-S3-DevKitC-1-N8R2" +USB_MANUFACTURER = "Espressif" + +IDF_TARGET = esp32s3 + +INTERNAL_FLASH_FILESYSTEM = 1 +LONGINT_IMPL = MPZ + +# The default queue depth of 16 overflows on release builds, +# so increase it to 32. +CFLAGS += -DCFG_TUD_TASK_QUEUE_SZ=32 + +CIRCUITPY_ESP_FLASH_MODE=dio +CIRCUITPY_ESP_FLASH_FREQ=80m +CIRCUITPY_ESP_FLASH_SIZE=8MB diff --git a/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/pins.c b/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/pins.c new file mode 100644 index 0000000000..919deca8b4 --- /dev/null +++ b/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/pins.c @@ -0,0 +1,49 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + + { MP_ROM_QSTR(MP_QSTR_IO0), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_IO1), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_IO2), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_IO3), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_IO4), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_IO5), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_IO6), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_IO7), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_IO8), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_IO9), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_IO10), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_IO11), MP_ROM_PTR(&pin_GPIO11) }, + { MP_ROM_QSTR(MP_QSTR_IO12), MP_ROM_PTR(&pin_GPIO12) }, + { MP_ROM_QSTR(MP_QSTR_IO13), MP_ROM_PTR(&pin_GPIO13) }, + { MP_ROM_QSTR(MP_QSTR_IO14), MP_ROM_PTR(&pin_GPIO14) }, + { MP_ROM_QSTR(MP_QSTR_IO15), MP_ROM_PTR(&pin_GPIO15) }, + { MP_ROM_QSTR(MP_QSTR_IO16), MP_ROM_PTR(&pin_GPIO16) }, + { MP_ROM_QSTR(MP_QSTR_IO17), MP_ROM_PTR(&pin_GPIO17) }, + { MP_ROM_QSTR(MP_QSTR_IO18), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_IO19), MP_ROM_PTR(&pin_GPIO19) }, + { MP_ROM_QSTR(MP_QSTR_IO20), MP_ROM_PTR(&pin_GPIO20) }, + { MP_ROM_QSTR(MP_QSTR_IO21), MP_ROM_PTR(&pin_GPIO21) }, + { MP_ROM_QSTR(MP_QSTR_IO35), MP_ROM_PTR(&pin_GPIO35) }, + { MP_ROM_QSTR(MP_QSTR_IO36), MP_ROM_PTR(&pin_GPIO36) }, + { MP_ROM_QSTR(MP_QSTR_IO37), MP_ROM_PTR(&pin_GPIO37) }, + { MP_ROM_QSTR(MP_QSTR_IO38), MP_ROM_PTR(&pin_GPIO38) }, + { MP_ROM_QSTR(MP_QSTR_IO39), MP_ROM_PTR(&pin_GPIO39) }, + { MP_ROM_QSTR(MP_QSTR_IO40), MP_ROM_PTR(&pin_GPIO40) }, + { MP_ROM_QSTR(MP_QSTR_IO41), MP_ROM_PTR(&pin_GPIO41) }, + { MP_ROM_QSTR(MP_QSTR_IO42), MP_ROM_PTR(&pin_GPIO42) }, + { MP_ROM_QSTR(MP_QSTR_IO43), MP_ROM_PTR(&pin_GPIO43) }, + { MP_ROM_QSTR(MP_QSTR_IO44), MP_ROM_PTR(&pin_GPIO44) }, + { MP_ROM_QSTR(MP_QSTR_IO45), MP_ROM_PTR(&pin_GPIO45) }, + { MP_ROM_QSTR(MP_QSTR_IO46), MP_ROM_PTR(&pin_GPIO46) }, + { MP_ROM_QSTR(MP_QSTR_IO47), MP_ROM_PTR(&pin_GPIO47) }, + { MP_ROM_QSTR(MP_QSTR_IO48), MP_ROM_PTR(&pin_GPIO48) }, + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO48) }, + + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO43) }, + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO44) }, + + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/sdkconfig b/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/sdkconfig new file mode 100644 index 0000000000..e3a4d6ce68 --- /dev/null +++ b/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/sdkconfig @@ -0,0 +1,37 @@ +CONFIG_ESP32S3_SPIRAM_SUPPORT=y +# +# SPI RAM config +# +CONFIG_SPIRAM_MODE_QUAD=y +# CONFIG_SPIRAM_MODE_OCT is not set +# CONFIG_SPIRAM_TYPE_AUTO is not set +CONFIG_SPIRAM_TYPE_ESPPSRAM16=y +# CONFIG_SPIRAM_TYPE_ESPPSRAM32 is not set +# CONFIG_SPIRAM_TYPE_ESPPSRAM64 is not set +CONFIG_SPIRAM_SIZE=2097152 +# end of SPI RAM config + +CONFIG_DEFAULT_PSRAM_CLK_IO=30 +# +# PSRAM Clock and CS IO for ESP32S3 +# +CONFIG_DEFAULT_PSRAM_CS_IO=26 +# end of PSRAM Clock and CS IO for ESP32S3 + +# CONFIG_SPIRAM_FETCH_INSTRUCTIONS is not set +# CONFIG_SPIRAM_RODATA is not set +# CONFIG_SPIRAM_SPEED_120M is not set +CONFIG_SPIRAM_SPEED_80M=y +# CONFIG_SPIRAM_SPEED_40M is not set +CONFIG_SPIRAM=y +CONFIG_SPIRAM_BOOT_INIT=y +# CONFIG_SPIRAM_IGNORE_NOTFOUND is not set +CONFIG_SPIRAM_USE_MEMMAP=y +# CONFIG_SPIRAM_USE_CAPS_ALLOC is not set +# CONFIG_SPIRAM_USE_MALLOC is not set +CONFIG_SPIRAM_MEMTEST=y +# +# LWIP +# +CONFIG_LWIP_LOCAL_HOSTNAME="espressif-esp32s3" +# end of LWIP diff --git a/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/board.c b/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/board.c new file mode 100644 index 0000000000..ff9418ec86 --- /dev/null +++ b/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/board.c @@ -0,0 +1,48 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "supervisor/board.h" +#include "mpconfigboard.h" +#include "shared-bindings/microcontroller/Pin.h" + +void board_init(void) { + // Debug UART + #ifdef DEBUG + common_hal_never_reset_pin(&pin_GPIO43); + common_hal_never_reset_pin(&pin_GPIO44); + #endif +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { + +} + +void board_deinit(void) { +} diff --git a/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h b/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h new file mode 100644 index 0000000000..f3a2941655 --- /dev/null +++ b/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h @@ -0,0 +1,41 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +// Micropython setup + +#define MICROPY_HW_BOARD_NAME "ESP32-S3-DevKitC-1-N8R8" +#define MICROPY_HW_MCU_NAME "ESP32S3" + +#define MICROPY_HW_NEOPIXEL (&pin_GPIO48) + +#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) + +#define DEFAULT_UART_BUS_RX (&pin_GPIO44) +#define DEFAULT_UART_BUS_TX (&pin_GPIO43) + +#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") + +#define AUTORESET_DELAY_MS 500 diff --git a/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.mk b/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.mk new file mode 100644 index 0000000000..4e65fc940d --- /dev/null +++ b/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.mk @@ -0,0 +1,17 @@ +USB_VID = 0x303A +USB_PID = 0x7003 +USB_PRODUCT = "ESP32-S3-DevKitC-1-N8R8" +USB_MANUFACTURER = "Espressif" + +IDF_TARGET = esp32s3 + +INTERNAL_FLASH_FILESYSTEM = 1 +LONGINT_IMPL = MPZ + +# The default queue depth of 16 overflows on release builds, +# so increase it to 32. +CFLAGS += -DCFG_TUD_TASK_QUEUE_SZ=32 + +CIRCUITPY_ESP_FLASH_MODE=dio +CIRCUITPY_ESP_FLASH_FREQ=80m +CIRCUITPY_ESP_FLASH_SIZE=8MB diff --git a/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/pins.c b/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/pins.c new file mode 100644 index 0000000000..919deca8b4 --- /dev/null +++ b/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/pins.c @@ -0,0 +1,49 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + + { MP_ROM_QSTR(MP_QSTR_IO0), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_IO1), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_IO2), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_IO3), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_IO4), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_IO5), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_IO6), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_IO7), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_IO8), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_IO9), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_IO10), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_IO11), MP_ROM_PTR(&pin_GPIO11) }, + { MP_ROM_QSTR(MP_QSTR_IO12), MP_ROM_PTR(&pin_GPIO12) }, + { MP_ROM_QSTR(MP_QSTR_IO13), MP_ROM_PTR(&pin_GPIO13) }, + { MP_ROM_QSTR(MP_QSTR_IO14), MP_ROM_PTR(&pin_GPIO14) }, + { MP_ROM_QSTR(MP_QSTR_IO15), MP_ROM_PTR(&pin_GPIO15) }, + { MP_ROM_QSTR(MP_QSTR_IO16), MP_ROM_PTR(&pin_GPIO16) }, + { MP_ROM_QSTR(MP_QSTR_IO17), MP_ROM_PTR(&pin_GPIO17) }, + { MP_ROM_QSTR(MP_QSTR_IO18), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_IO19), MP_ROM_PTR(&pin_GPIO19) }, + { MP_ROM_QSTR(MP_QSTR_IO20), MP_ROM_PTR(&pin_GPIO20) }, + { MP_ROM_QSTR(MP_QSTR_IO21), MP_ROM_PTR(&pin_GPIO21) }, + { MP_ROM_QSTR(MP_QSTR_IO35), MP_ROM_PTR(&pin_GPIO35) }, + { MP_ROM_QSTR(MP_QSTR_IO36), MP_ROM_PTR(&pin_GPIO36) }, + { MP_ROM_QSTR(MP_QSTR_IO37), MP_ROM_PTR(&pin_GPIO37) }, + { MP_ROM_QSTR(MP_QSTR_IO38), MP_ROM_PTR(&pin_GPIO38) }, + { MP_ROM_QSTR(MP_QSTR_IO39), MP_ROM_PTR(&pin_GPIO39) }, + { MP_ROM_QSTR(MP_QSTR_IO40), MP_ROM_PTR(&pin_GPIO40) }, + { MP_ROM_QSTR(MP_QSTR_IO41), MP_ROM_PTR(&pin_GPIO41) }, + { MP_ROM_QSTR(MP_QSTR_IO42), MP_ROM_PTR(&pin_GPIO42) }, + { MP_ROM_QSTR(MP_QSTR_IO43), MP_ROM_PTR(&pin_GPIO43) }, + { MP_ROM_QSTR(MP_QSTR_IO44), MP_ROM_PTR(&pin_GPIO44) }, + { MP_ROM_QSTR(MP_QSTR_IO45), MP_ROM_PTR(&pin_GPIO45) }, + { MP_ROM_QSTR(MP_QSTR_IO46), MP_ROM_PTR(&pin_GPIO46) }, + { MP_ROM_QSTR(MP_QSTR_IO47), MP_ROM_PTR(&pin_GPIO47) }, + { MP_ROM_QSTR(MP_QSTR_IO48), MP_ROM_PTR(&pin_GPIO48) }, + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO48) }, + + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO43) }, + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO44) }, + + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/sdkconfig b/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/sdkconfig new file mode 100644 index 0000000000..f508f4a67c --- /dev/null +++ b/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/sdkconfig @@ -0,0 +1,34 @@ +CONFIG_ESP32S3_SPIRAM_SUPPORT=y +# +# SPI RAM config +# +# CONFIG_SPIRAM_MODE_QUAD is not set +CONFIG_SPIRAM_MODE_OCT=y +# CONFIG_SPIRAM_TYPE_AUTO is not set +CONFIG_SPIRAM_TYPE_ESPPSRAM64=y +CONFIG_SPIRAM_SIZE=8388608 +# end of SPI RAM config + +CONFIG_DEFAULT_PSRAM_CLK_IO=30 +# +# PSRAM Clock and CS IO for ESP32S3 +# +CONFIG_DEFAULT_PSRAM_CS_IO=26 +# end of PSRAM Clock and CS IO for ESP32S3 + +# CONFIG_SPIRAM_FETCH_INSTRUCTIONS is not set +# CONFIG_SPIRAM_RODATA is not set +CONFIG_SPIRAM_SPEED_80M=y +# CONFIG_SPIRAM_SPEED_40M is not set +CONFIG_SPIRAM=y +CONFIG_SPIRAM_BOOT_INIT=y +# CONFIG_SPIRAM_IGNORE_NOTFOUND is not set +CONFIG_SPIRAM_USE_MEMMAP=y +# CONFIG_SPIRAM_USE_CAPS_ALLOC is not set +# CONFIG_SPIRAM_USE_MALLOC is not set +CONFIG_SPIRAM_MEMTEST=y +# +# LWIP +# +CONFIG_LWIP_LOCAL_HOSTNAME="espressif-esp32s3" +# end of LWIP diff --git a/ports/espressif/boards/espressif_esp32s3_devkitm_1_n8/board.c b/ports/espressif/boards/espressif_esp32s3_devkitm_1_n8/board.c new file mode 100644 index 0000000000..ff9418ec86 --- /dev/null +++ b/ports/espressif/boards/espressif_esp32s3_devkitm_1_n8/board.c @@ -0,0 +1,48 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "supervisor/board.h" +#include "mpconfigboard.h" +#include "shared-bindings/microcontroller/Pin.h" + +void board_init(void) { + // Debug UART + #ifdef DEBUG + common_hal_never_reset_pin(&pin_GPIO43); + common_hal_never_reset_pin(&pin_GPIO44); + #endif +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { + +} + +void board_deinit(void) { +} diff --git a/ports/espressif/boards/espressif_esp32s3_devkitm_1_n8/mpconfigboard.h b/ports/espressif/boards/espressif_esp32s3_devkitm_1_n8/mpconfigboard.h new file mode 100644 index 0000000000..b1b8170702 --- /dev/null +++ b/ports/espressif/boards/espressif_esp32s3_devkitm_1_n8/mpconfigboard.h @@ -0,0 +1,41 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +// Micropython setup + +#define MICROPY_HW_BOARD_NAME "ESP32-S3-DevKitM-1-N8" +#define MICROPY_HW_MCU_NAME "ESP32S3" + +#define MICROPY_HW_NEOPIXEL (&pin_GPIO48) + +#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) + +#define DEFAULT_UART_BUS_RX (&pin_GPIO44) +#define DEFAULT_UART_BUS_TX (&pin_GPIO43) + +#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") + +#define AUTORESET_DELAY_MS 500 diff --git a/ports/espressif/boards/espressif_esp32s3_devkitm_1_n8/mpconfigboard.mk b/ports/espressif/boards/espressif_esp32s3_devkitm_1_n8/mpconfigboard.mk new file mode 100644 index 0000000000..9558b05576 --- /dev/null +++ b/ports/espressif/boards/espressif_esp32s3_devkitm_1_n8/mpconfigboard.mk @@ -0,0 +1,17 @@ +USB_VID = 0x303A +USB_PID = 0x7007 +USB_PRODUCT = "ESP32-S3-DevKitM-1-N8" +USB_MANUFACTURER = "Espressif" + +IDF_TARGET = esp32s3 + +INTERNAL_FLASH_FILESYSTEM = 1 +LONGINT_IMPL = MPZ + +# The default queue depth of 16 overflows on release builds, +# so increase it to 32. +CFLAGS += -DCFG_TUD_TASK_QUEUE_SZ=32 + +CIRCUITPY_ESP_FLASH_MODE=dio +CIRCUITPY_ESP_FLASH_FREQ=80m +CIRCUITPY_ESP_FLASH_SIZE=8MB diff --git a/ports/espressif/boards/espressif_esp32s3_devkitm_1_n8/pins.c b/ports/espressif/boards/espressif_esp32s3_devkitm_1_n8/pins.c new file mode 100644 index 0000000000..919deca8b4 --- /dev/null +++ b/ports/espressif/boards/espressif_esp32s3_devkitm_1_n8/pins.c @@ -0,0 +1,49 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + + { MP_ROM_QSTR(MP_QSTR_IO0), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_IO1), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_IO2), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_IO3), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_IO4), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_IO5), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_IO6), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_IO7), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_IO8), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_IO9), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_IO10), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_IO11), MP_ROM_PTR(&pin_GPIO11) }, + { MP_ROM_QSTR(MP_QSTR_IO12), MP_ROM_PTR(&pin_GPIO12) }, + { MP_ROM_QSTR(MP_QSTR_IO13), MP_ROM_PTR(&pin_GPIO13) }, + { MP_ROM_QSTR(MP_QSTR_IO14), MP_ROM_PTR(&pin_GPIO14) }, + { MP_ROM_QSTR(MP_QSTR_IO15), MP_ROM_PTR(&pin_GPIO15) }, + { MP_ROM_QSTR(MP_QSTR_IO16), MP_ROM_PTR(&pin_GPIO16) }, + { MP_ROM_QSTR(MP_QSTR_IO17), MP_ROM_PTR(&pin_GPIO17) }, + { MP_ROM_QSTR(MP_QSTR_IO18), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_IO19), MP_ROM_PTR(&pin_GPIO19) }, + { MP_ROM_QSTR(MP_QSTR_IO20), MP_ROM_PTR(&pin_GPIO20) }, + { MP_ROM_QSTR(MP_QSTR_IO21), MP_ROM_PTR(&pin_GPIO21) }, + { MP_ROM_QSTR(MP_QSTR_IO35), MP_ROM_PTR(&pin_GPIO35) }, + { MP_ROM_QSTR(MP_QSTR_IO36), MP_ROM_PTR(&pin_GPIO36) }, + { MP_ROM_QSTR(MP_QSTR_IO37), MP_ROM_PTR(&pin_GPIO37) }, + { MP_ROM_QSTR(MP_QSTR_IO38), MP_ROM_PTR(&pin_GPIO38) }, + { MP_ROM_QSTR(MP_QSTR_IO39), MP_ROM_PTR(&pin_GPIO39) }, + { MP_ROM_QSTR(MP_QSTR_IO40), MP_ROM_PTR(&pin_GPIO40) }, + { MP_ROM_QSTR(MP_QSTR_IO41), MP_ROM_PTR(&pin_GPIO41) }, + { MP_ROM_QSTR(MP_QSTR_IO42), MP_ROM_PTR(&pin_GPIO42) }, + { MP_ROM_QSTR(MP_QSTR_IO43), MP_ROM_PTR(&pin_GPIO43) }, + { MP_ROM_QSTR(MP_QSTR_IO44), MP_ROM_PTR(&pin_GPIO44) }, + { MP_ROM_QSTR(MP_QSTR_IO45), MP_ROM_PTR(&pin_GPIO45) }, + { MP_ROM_QSTR(MP_QSTR_IO46), MP_ROM_PTR(&pin_GPIO46) }, + { MP_ROM_QSTR(MP_QSTR_IO47), MP_ROM_PTR(&pin_GPIO47) }, + { MP_ROM_QSTR(MP_QSTR_IO48), MP_ROM_PTR(&pin_GPIO48) }, + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO48) }, + + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO43) }, + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO44) }, + + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/espressif/boards/espressif_esp32s3_devkitm_1_n8/sdkconfig b/ports/espressif/boards/espressif_esp32s3_devkitm_1_n8/sdkconfig new file mode 100644 index 0000000000..a0a61d8392 --- /dev/null +++ b/ports/espressif/boards/espressif_esp32s3_devkitm_1_n8/sdkconfig @@ -0,0 +1,6 @@ +# CONFIG_ESP32S3_SPIRAM_SUPPORT is not set +# +# LWIP +# +CONFIG_LWIP_LOCAL_HOSTNAME="espressif-esp32s3" +# end of LWIP diff --git a/ports/espressif/boards/espressif_hmi_devkit_1/board.c b/ports/espressif/boards/espressif_hmi_devkit_1/board.c index ff5d9cfb6c..93aa1c0436 100644 --- a/ports/espressif/boards/espressif_hmi_devkit_1/board.c +++ b/ports/espressif/boards/espressif_hmi_devkit_1/board.c @@ -29,10 +29,6 @@ #include "shared-bindings/microcontroller/Pin.h" void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); - // Debug UART common_hal_never_reset_pin(&pin_GPIO43); common_hal_never_reset_pin(&pin_GPIO44); diff --git a/ports/espressif/boards/espressif_hmi_devkit_1/sdkconfig b/ports/espressif/boards/espressif_hmi_devkit_1/sdkconfig index 9d8bbde967..f19afafa3d 100644 --- a/ports/espressif/boards/espressif_hmi_devkit_1/sdkconfig +++ b/ports/espressif/boards/espressif_hmi_devkit_1/sdkconfig @@ -1,5 +1,4 @@ CONFIG_ESP32S2_SPIRAM_SUPPORT=y - # # SPI RAM config # @@ -8,11 +7,12 @@ CONFIG_SPIRAM_TYPE_ESPPSRAM16=y # CONFIG_SPIRAM_TYPE_ESPPSRAM32 is not set # CONFIG_SPIRAM_TYPE_ESPPSRAM64 is not set CONFIG_SPIRAM_SIZE=2097152 +# end of SPI RAM config +CONFIG_DEFAULT_PSRAM_CLK_IO=30 # # PSRAM clock and cs IO for ESP32S2 # -CONFIG_DEFAULT_PSRAM_CLK_IO=30 CONFIG_DEFAULT_PSRAM_CS_IO=26 # end of PSRAM clock and cs IO for ESP32S2 @@ -30,4 +30,8 @@ CONFIG_SPIRAM_USE_MEMMAP=y # CONFIG_SPIRAM_USE_MALLOC is not set CONFIG_SPIRAM_MEMTEST=y # CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY is not set -# end of SPI RAM config +# +# LWIP +# +CONFIG_LWIP_LOCAL_HOSTNAME="espressif" +# end of LWIP diff --git a/ports/espressif/boards/espressif_kaluga_1.3/board.c b/ports/espressif/boards/espressif_kaluga_1.3/board.c index e40b6335bc..0432485111 100644 --- a/ports/espressif/boards/espressif_kaluga_1.3/board.c +++ b/ports/espressif/boards/espressif_kaluga_1.3/board.c @@ -29,10 +29,6 @@ #include "shared-bindings/microcontroller/Pin.h" void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); - // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO43); diff --git a/ports/espressif/boards/espressif_kaluga_1.3/sdkconfig b/ports/espressif/boards/espressif_kaluga_1.3/sdkconfig index 9d8bbde967..f19afafa3d 100644 --- a/ports/espressif/boards/espressif_kaluga_1.3/sdkconfig +++ b/ports/espressif/boards/espressif_kaluga_1.3/sdkconfig @@ -1,5 +1,4 @@ CONFIG_ESP32S2_SPIRAM_SUPPORT=y - # # SPI RAM config # @@ -8,11 +7,12 @@ CONFIG_SPIRAM_TYPE_ESPPSRAM16=y # CONFIG_SPIRAM_TYPE_ESPPSRAM32 is not set # CONFIG_SPIRAM_TYPE_ESPPSRAM64 is not set CONFIG_SPIRAM_SIZE=2097152 +# end of SPI RAM config +CONFIG_DEFAULT_PSRAM_CLK_IO=30 # # PSRAM clock and cs IO for ESP32S2 # -CONFIG_DEFAULT_PSRAM_CLK_IO=30 CONFIG_DEFAULT_PSRAM_CS_IO=26 # end of PSRAM clock and cs IO for ESP32S2 @@ -30,4 +30,8 @@ CONFIG_SPIRAM_USE_MEMMAP=y # CONFIG_SPIRAM_USE_MALLOC is not set CONFIG_SPIRAM_MEMTEST=y # CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY is not set -# end of SPI RAM config +# +# LWIP +# +CONFIG_LWIP_LOCAL_HOSTNAME="espressif" +# end of LWIP diff --git a/ports/espressif/boards/espressif_kaluga_1/board.c b/ports/espressif/boards/espressif_kaluga_1/board.c index e40b6335bc..0432485111 100644 --- a/ports/espressif/boards/espressif_kaluga_1/board.c +++ b/ports/espressif/boards/espressif_kaluga_1/board.c @@ -29,10 +29,6 @@ #include "shared-bindings/microcontroller/Pin.h" void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); - // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO43); diff --git a/ports/espressif/boards/espressif_kaluga_1/sdkconfig b/ports/espressif/boards/espressif_kaluga_1/sdkconfig index 9d8bbde967..f19afafa3d 100644 --- a/ports/espressif/boards/espressif_kaluga_1/sdkconfig +++ b/ports/espressif/boards/espressif_kaluga_1/sdkconfig @@ -1,5 +1,4 @@ CONFIG_ESP32S2_SPIRAM_SUPPORT=y - # # SPI RAM config # @@ -8,11 +7,12 @@ CONFIG_SPIRAM_TYPE_ESPPSRAM16=y # CONFIG_SPIRAM_TYPE_ESPPSRAM32 is not set # CONFIG_SPIRAM_TYPE_ESPPSRAM64 is not set CONFIG_SPIRAM_SIZE=2097152 +# end of SPI RAM config +CONFIG_DEFAULT_PSRAM_CLK_IO=30 # # PSRAM clock and cs IO for ESP32S2 # -CONFIG_DEFAULT_PSRAM_CLK_IO=30 CONFIG_DEFAULT_PSRAM_CS_IO=26 # end of PSRAM clock and cs IO for ESP32S2 @@ -30,4 +30,8 @@ CONFIG_SPIRAM_USE_MEMMAP=y # CONFIG_SPIRAM_USE_MALLOC is not set CONFIG_SPIRAM_MEMTEST=y # CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY is not set -# end of SPI RAM config +# +# LWIP +# +CONFIG_LWIP_LOCAL_HOSTNAME="espressif" +# end of LWIP diff --git a/ports/espressif/boards/espressif_saola_1_wroom/board.c b/ports/espressif/boards/espressif_saola_1_wroom/board.c index e40b6335bc..0432485111 100644 --- a/ports/espressif/boards/espressif_saola_1_wroom/board.c +++ b/ports/espressif/boards/espressif_saola_1_wroom/board.c @@ -29,10 +29,6 @@ #include "shared-bindings/microcontroller/Pin.h" void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); - // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO43); diff --git a/ports/espressif/boards/espressif_saola_1_wroom/sdkconfig b/ports/espressif/boards/espressif_saola_1_wroom/sdkconfig index e69de29bb2..5b9c86dcc3 100644 --- a/ports/espressif/boards/espressif_saola_1_wroom/sdkconfig +++ b/ports/espressif/boards/espressif_saola_1_wroom/sdkconfig @@ -0,0 +1,6 @@ +# CONFIG_ESP32S2_SPIRAM_SUPPORT is not set +# +# LWIP +# +CONFIG_LWIP_LOCAL_HOSTNAME="espressif" +# end of LWIP diff --git a/ports/espressif/boards/espressif_saola_1_wrover/board.c b/ports/espressif/boards/espressif_saola_1_wrover/board.c index e40b6335bc..0432485111 100644 --- a/ports/espressif/boards/espressif_saola_1_wrover/board.c +++ b/ports/espressif/boards/espressif_saola_1_wrover/board.c @@ -29,10 +29,6 @@ #include "shared-bindings/microcontroller/Pin.h" void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); - // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO43); diff --git a/ports/espressif/boards/espressif_saola_1_wrover/sdkconfig b/ports/espressif/boards/espressif_saola_1_wrover/sdkconfig index 9d8bbde967..f19afafa3d 100644 --- a/ports/espressif/boards/espressif_saola_1_wrover/sdkconfig +++ b/ports/espressif/boards/espressif_saola_1_wrover/sdkconfig @@ -1,5 +1,4 @@ CONFIG_ESP32S2_SPIRAM_SUPPORT=y - # # SPI RAM config # @@ -8,11 +7,12 @@ CONFIG_SPIRAM_TYPE_ESPPSRAM16=y # CONFIG_SPIRAM_TYPE_ESPPSRAM32 is not set # CONFIG_SPIRAM_TYPE_ESPPSRAM64 is not set CONFIG_SPIRAM_SIZE=2097152 +# end of SPI RAM config +CONFIG_DEFAULT_PSRAM_CLK_IO=30 # # PSRAM clock and cs IO for ESP32S2 # -CONFIG_DEFAULT_PSRAM_CLK_IO=30 CONFIG_DEFAULT_PSRAM_CS_IO=26 # end of PSRAM clock and cs IO for ESP32S2 @@ -30,4 +30,8 @@ CONFIG_SPIRAM_USE_MEMMAP=y # CONFIG_SPIRAM_USE_MALLOC is not set CONFIG_SPIRAM_MEMTEST=y # CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY is not set -# end of SPI RAM config +# +# LWIP +# +CONFIG_LWIP_LOCAL_HOSTNAME="espressif" +# end of LWIP diff --git a/ports/espressif/boards/franzininho_wifi_wroom/board.c b/ports/espressif/boards/franzininho_wifi_wroom/board.c index e40b6335bc..0432485111 100644 --- a/ports/espressif/boards/franzininho_wifi_wroom/board.c +++ b/ports/espressif/boards/franzininho_wifi_wroom/board.c @@ -29,10 +29,6 @@ #include "shared-bindings/microcontroller/Pin.h" void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); - // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO43); diff --git a/ports/espressif/boards/franzininho_wifi_wroom/sdkconfig b/ports/espressif/boards/franzininho_wifi_wroom/sdkconfig index e69de29bb2..5b9c86dcc3 100644 --- a/ports/espressif/boards/franzininho_wifi_wroom/sdkconfig +++ b/ports/espressif/boards/franzininho_wifi_wroom/sdkconfig @@ -0,0 +1,6 @@ +# CONFIG_ESP32S2_SPIRAM_SUPPORT is not set +# +# LWIP +# +CONFIG_LWIP_LOCAL_HOSTNAME="espressif" +# end of LWIP diff --git a/ports/espressif/boards/franzininho_wifi_wrover/board.c b/ports/espressif/boards/franzininho_wifi_wrover/board.c index e40b6335bc..0432485111 100644 --- a/ports/espressif/boards/franzininho_wifi_wrover/board.c +++ b/ports/espressif/boards/franzininho_wifi_wrover/board.c @@ -29,10 +29,6 @@ #include "shared-bindings/microcontroller/Pin.h" void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); - // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO43); diff --git a/ports/espressif/boards/franzininho_wifi_wrover/sdkconfig b/ports/espressif/boards/franzininho_wifi_wrover/sdkconfig index 9d8bbde967..f19afafa3d 100644 --- a/ports/espressif/boards/franzininho_wifi_wrover/sdkconfig +++ b/ports/espressif/boards/franzininho_wifi_wrover/sdkconfig @@ -1,5 +1,4 @@ CONFIG_ESP32S2_SPIRAM_SUPPORT=y - # # SPI RAM config # @@ -8,11 +7,12 @@ CONFIG_SPIRAM_TYPE_ESPPSRAM16=y # CONFIG_SPIRAM_TYPE_ESPPSRAM32 is not set # CONFIG_SPIRAM_TYPE_ESPPSRAM64 is not set CONFIG_SPIRAM_SIZE=2097152 +# end of SPI RAM config +CONFIG_DEFAULT_PSRAM_CLK_IO=30 # # PSRAM clock and cs IO for ESP32S2 # -CONFIG_DEFAULT_PSRAM_CLK_IO=30 CONFIG_DEFAULT_PSRAM_CS_IO=26 # end of PSRAM clock and cs IO for ESP32S2 @@ -30,4 +30,8 @@ CONFIG_SPIRAM_USE_MEMMAP=y # CONFIG_SPIRAM_USE_MALLOC is not set CONFIG_SPIRAM_MEMTEST=y # CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY is not set -# end of SPI RAM config +# +# LWIP +# +CONFIG_LWIP_LOCAL_HOSTNAME="espressif" +# end of LWIP diff --git a/ports/espressif/boards/gravitech_cucumber_m/board.c b/ports/espressif/boards/gravitech_cucumber_m/board.c index ec84d3209c..16a6af0742 100644 --- a/ports/espressif/boards/gravitech_cucumber_m/board.c +++ b/ports/espressif/boards/gravitech_cucumber_m/board.c @@ -29,10 +29,6 @@ #include "shared-bindings/microcontroller/Pin.h" void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); - // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO43); diff --git a/ports/espressif/boards/gravitech_cucumber_m/pins.c b/ports/espressif/boards/gravitech_cucumber_m/pins.c index a5dd609287..8c89808017 100644 --- a/ports/espressif/boards/gravitech_cucumber_m/pins.c +++ b/ports/espressif/boards/gravitech_cucumber_m/pins.c @@ -6,6 +6,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_IO0), MP_ROM_PTR(&pin_GPIO0) }, { MP_ROM_QSTR(MP_QSTR_IO1), MP_ROM_PTR(&pin_GPIO1) }, { MP_ROM_QSTR(MP_QSTR_IO2), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_LED_INVERTED), MP_ROM_PTR(&pin_GPIO2) }, { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO2) }, { MP_ROM_QSTR(MP_QSTR_IO3), MP_ROM_PTR(&pin_GPIO3) }, { MP_ROM_QSTR(MP_QSTR_IO4), MP_ROM_PTR(&pin_GPIO4) }, diff --git a/ports/espressif/boards/gravitech_cucumber_m/sdkconfig b/ports/espressif/boards/gravitech_cucumber_m/sdkconfig index af73f6d885..7b07033d7b 100644 --- a/ports/espressif/boards/gravitech_cucumber_m/sdkconfig +++ b/ports/espressif/boards/gravitech_cucumber_m/sdkconfig @@ -1,3 +1,4 @@ +# CONFIG_ESP32S2_SPIRAM_SUPPORT is not set # # LWIP # diff --git a/ports/espressif/boards/gravitech_cucumber_ms/board.c b/ports/espressif/boards/gravitech_cucumber_ms/board.c index ec84d3209c..16a6af0742 100644 --- a/ports/espressif/boards/gravitech_cucumber_ms/board.c +++ b/ports/espressif/boards/gravitech_cucumber_ms/board.c @@ -29,10 +29,6 @@ #include "shared-bindings/microcontroller/Pin.h" void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); - // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO43); diff --git a/ports/espressif/boards/gravitech_cucumber_ms/pins.c b/ports/espressif/boards/gravitech_cucumber_ms/pins.c index a1bb25cf14..4aa4429a93 100644 --- a/ports/espressif/boards/gravitech_cucumber_ms/pins.c +++ b/ports/espressif/boards/gravitech_cucumber_ms/pins.c @@ -6,6 +6,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_IO0), MP_ROM_PTR(&pin_GPIO0) }, { MP_ROM_QSTR(MP_QSTR_IO1), MP_ROM_PTR(&pin_GPIO1) }, { MP_ROM_QSTR(MP_QSTR_IO2), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_LED_INVERTED), MP_ROM_PTR(&pin_GPIO2) }, { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO2) }, { MP_ROM_QSTR(MP_QSTR_IO3), MP_ROM_PTR(&pin_GPIO3) }, { MP_ROM_QSTR(MP_QSTR_IO4), MP_ROM_PTR(&pin_GPIO4) }, diff --git a/ports/espressif/boards/gravitech_cucumber_ms/sdkconfig b/ports/espressif/boards/gravitech_cucumber_ms/sdkconfig index cbdd787aa7..b31dd447e1 100644 --- a/ports/espressif/boards/gravitech_cucumber_ms/sdkconfig +++ b/ports/espressif/boards/gravitech_cucumber_ms/sdkconfig @@ -1,3 +1,4 @@ +# CONFIG_ESP32S2_SPIRAM_SUPPORT is not set # # LWIP # diff --git a/ports/espressif/boards/gravitech_cucumber_r/board.c b/ports/espressif/boards/gravitech_cucumber_r/board.c index ec84d3209c..16a6af0742 100644 --- a/ports/espressif/boards/gravitech_cucumber_r/board.c +++ b/ports/espressif/boards/gravitech_cucumber_r/board.c @@ -29,10 +29,6 @@ #include "shared-bindings/microcontroller/Pin.h" void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); - // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO43); diff --git a/ports/espressif/boards/gravitech_cucumber_r/pins.c b/ports/espressif/boards/gravitech_cucumber_r/pins.c index a5dd609287..8c89808017 100644 --- a/ports/espressif/boards/gravitech_cucumber_r/pins.c +++ b/ports/espressif/boards/gravitech_cucumber_r/pins.c @@ -6,6 +6,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_IO0), MP_ROM_PTR(&pin_GPIO0) }, { MP_ROM_QSTR(MP_QSTR_IO1), MP_ROM_PTR(&pin_GPIO1) }, { MP_ROM_QSTR(MP_QSTR_IO2), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_LED_INVERTED), MP_ROM_PTR(&pin_GPIO2) }, { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO2) }, { MP_ROM_QSTR(MP_QSTR_IO3), MP_ROM_PTR(&pin_GPIO3) }, { MP_ROM_QSTR(MP_QSTR_IO4), MP_ROM_PTR(&pin_GPIO4) }, diff --git a/ports/espressif/boards/gravitech_cucumber_r/sdkconfig b/ports/espressif/boards/gravitech_cucumber_r/sdkconfig index 3862b27003..fe0857c4fb 100644 --- a/ports/espressif/boards/gravitech_cucumber_r/sdkconfig +++ b/ports/espressif/boards/gravitech_cucumber_r/sdkconfig @@ -1,5 +1,4 @@ CONFIG_ESP32S2_SPIRAM_SUPPORT=y - # # SPI RAM config # @@ -8,11 +7,12 @@ CONFIG_SPIRAM_TYPE_ESPPSRAM16=y # CONFIG_SPIRAM_TYPE_ESPPSRAM32 is not set # CONFIG_SPIRAM_TYPE_ESPPSRAM64 is not set CONFIG_SPIRAM_SIZE=2097152 +# end of SPI RAM config +CONFIG_DEFAULT_PSRAM_CLK_IO=30 # # PSRAM clock and cs IO for ESP32S2 # -CONFIG_DEFAULT_PSRAM_CLK_IO=30 CONFIG_DEFAULT_PSRAM_CS_IO=26 # end of PSRAM clock and cs IO for ESP32S2 @@ -30,8 +30,6 @@ CONFIG_SPIRAM_USE_MEMMAP=y # CONFIG_SPIRAM_USE_MALLOC is not set CONFIG_SPIRAM_MEMTEST=y # CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY is not set -# end of SPI RAM config - # # LWIP # diff --git a/ports/espressif/boards/gravitech_cucumber_rs/board.c b/ports/espressif/boards/gravitech_cucumber_rs/board.c index ec84d3209c..16a6af0742 100644 --- a/ports/espressif/boards/gravitech_cucumber_rs/board.c +++ b/ports/espressif/boards/gravitech_cucumber_rs/board.c @@ -29,10 +29,6 @@ #include "shared-bindings/microcontroller/Pin.h" void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); - // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO43); diff --git a/ports/espressif/boards/gravitech_cucumber_rs/pins.c b/ports/espressif/boards/gravitech_cucumber_rs/pins.c index a1bb25cf14..4aa4429a93 100644 --- a/ports/espressif/boards/gravitech_cucumber_rs/pins.c +++ b/ports/espressif/boards/gravitech_cucumber_rs/pins.c @@ -6,6 +6,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_IO0), MP_ROM_PTR(&pin_GPIO0) }, { MP_ROM_QSTR(MP_QSTR_IO1), MP_ROM_PTR(&pin_GPIO1) }, { MP_ROM_QSTR(MP_QSTR_IO2), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_LED_INVERTED), MP_ROM_PTR(&pin_GPIO2) }, { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO2) }, { MP_ROM_QSTR(MP_QSTR_IO3), MP_ROM_PTR(&pin_GPIO3) }, { MP_ROM_QSTR(MP_QSTR_IO4), MP_ROM_PTR(&pin_GPIO4) }, diff --git a/ports/espressif/boards/gravitech_cucumber_rs/sdkconfig b/ports/espressif/boards/gravitech_cucumber_rs/sdkconfig index bc8328d1f1..23b3eea78d 100644 --- a/ports/espressif/boards/gravitech_cucumber_rs/sdkconfig +++ b/ports/espressif/boards/gravitech_cucumber_rs/sdkconfig @@ -1,5 +1,4 @@ CONFIG_ESP32S2_SPIRAM_SUPPORT=y - # # SPI RAM config # @@ -8,11 +7,12 @@ CONFIG_SPIRAM_TYPE_ESPPSRAM16=y # CONFIG_SPIRAM_TYPE_ESPPSRAM32 is not set # CONFIG_SPIRAM_TYPE_ESPPSRAM64 is not set CONFIG_SPIRAM_SIZE=2097152 +# end of SPI RAM config +CONFIG_DEFAULT_PSRAM_CLK_IO=30 # # PSRAM clock and cs IO for ESP32S2 # -CONFIG_DEFAULT_PSRAM_CLK_IO=30 CONFIG_DEFAULT_PSRAM_CS_IO=26 # end of PSRAM clock and cs IO for ESP32S2 @@ -30,8 +30,6 @@ CONFIG_SPIRAM_USE_MEMMAP=y # CONFIG_SPIRAM_USE_MALLOC is not set CONFIG_SPIRAM_MEMTEST=y # CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY is not set -# end of SPI RAM config - # # LWIP # diff --git a/ports/espressif/boards/hiibot_iots2/board.c b/ports/espressif/boards/hiibot_iots2/board.c new file mode 100644 index 0000000000..23ba71ed7e --- /dev/null +++ b/ports/espressif/boards/hiibot_iots2/board.c @@ -0,0 +1,165 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "supervisor/board.h" +#include "mpconfigboard.h" +#include "shared-bindings/microcontroller/Pin.h" +#include "shared-module/displayio/__init__.h" +#include "shared-module/displayio/mipi_constants.h" + +#define DELAY 0x80 + +// display init sequence according to LilyGO example app +uint8_t display_init_sequence[] = { + // sw reset + 0x01, 0 | DELAY, 150, + // sleep out + 0x11, 0 | DELAY, 255, + // normal display mode on + 0x13, 0, + // display and color format settings + 0x36, 1, 0x08, + 0xB6, 2, 0x0A, 0x82, + 0x3A, 1 | DELAY, 0x55, 10, + // ST7789V frame rate setting + 0xB2, 5, 0x0C, 0x0C, 0x00, 0x33, 0x33, + // voltages: VGH / VGL + 0xB7, 1, 0x35, + // ST7789V power setting + 0xBB, 1, 0x28, + 0xC0, 1, 0x0C, + 0xC2, 2, 0x01, 0xFF, + 0xC3, 1, 0x10, + 0xC4, 1, 0x20, + 0xC6, 1, 0x0F, + 0xD0, 2, 0xA4, 0xA1, + // ST7789V gamma setting + 0xE0, 14, 0xD0, 0x00, 0x02, 0x07, 0x0A, 0x28, 0x32, 0x44, 0x42, 0x06, 0x0E, 0x12, 0x14, 0x17, + 0xE1, 14, 0xD0, 0x00, 0x02, 0x07, 0x0A, 0x28, 0x31, 0x54, 0x47, 0x0E, 0x1C, 0x17, 0x1B, 0x1E, + 0x21, 0, + // display on + 0x29, 0 | DELAY, 255, +}; + +static void display_init(void) { + busio_spi_obj_t *spi = &displays[0].fourwire_bus.inline_bus; + + common_hal_busio_spi_construct( + spi, + &pin_GPIO34, // CLK + &pin_GPIO33, // MOSI + NULL, // MISO not connected + false); // Not half-duplex + + common_hal_busio_spi_never_reset(spi); + + displayio_fourwire_obj_t *bus = &displays[0].fourwire_bus; + bus->base.type = &displayio_fourwire_type; + + common_hal_displayio_fourwire_construct( + bus, + spi, + &pin_GPIO35, // DC + &pin_GPIO36, // CS + NULL, // NO RST ? + 40000000, // baudrate + 0, // polarity + 0 // phase + ); + + displayio_display_obj_t *display = &displays[0].display; + display->base.type = &displayio_display_type; + + // workaround as board_init() is called before reset_port() in main.c + pwmout_reset(); + + common_hal_displayio_display_construct( + display, + bus, + 240, // width (after rotation) + 135, // height (after rotation) + 52, // column start + 40, // row start + 90, // rotation + 16, // color depth + false, // grayscale + false, // pixels in a byte share a row. Only valid for depths < 8 + 1, // bytes per cell. Only valid for depths < 8 + false, // reverse_pixels_in_byte. Only valid for depths < 8 + true, // reverse_pixels_in_word + MIPI_COMMAND_SET_COLUMN_ADDRESS, // set column command + MIPI_COMMAND_SET_PAGE_ADDRESS, // set row command + MIPI_COMMAND_WRITE_MEMORY_START, // write memory command + display_init_sequence, + sizeof(display_init_sequence), + &pin_GPIO38, // backlight pin + NO_BRIGHTNESS_COMMAND, + 1.0f, // brightness (ignored) + false, // auto_brightness + false, // single_byte_bounds + false, // data_as_commands + true, // auto_refresh + 60, // native_frames_per_second + true, // backlight_on_high + false // SH1107_addressing + ); + + common_hal_never_reset_pin(&pin_GPIO38); // backlight pin +} + +void board_init(void) { + // USB + common_hal_never_reset_pin(&pin_GPIO19); + common_hal_never_reset_pin(&pin_GPIO20); + + // Debug UART + #ifdef DEBUG + common_hal_never_reset_pin(&pin_GPIO43); + common_hal_never_reset_pin(&pin_GPIO44); + #endif + + // SPI Flash and RAM + common_hal_never_reset_pin(&pin_GPIO26); + common_hal_never_reset_pin(&pin_GPIO27); + common_hal_never_reset_pin(&pin_GPIO28); + common_hal_never_reset_pin(&pin_GPIO29); + common_hal_never_reset_pin(&pin_GPIO30); + common_hal_never_reset_pin(&pin_GPIO31); + common_hal_never_reset_pin(&pin_GPIO32); + + // Display + display_init(); +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { +} + +void board_deinit(void) { +} diff --git a/ports/espressif/boards/hiibot_iots2/mpconfigboard.h b/ports/espressif/boards/hiibot_iots2/mpconfigboard.h new file mode 100644 index 0000000000..e847b8ebaa --- /dev/null +++ b/ports/espressif/boards/hiibot_iots2/mpconfigboard.h @@ -0,0 +1,40 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +// Micropython setup + +#define MICROPY_HW_BOARD_NAME "IoTs2" +#define MICROPY_HW_MCU_NAME "ESP32S2" + +#define MICROPY_HW_LED (&pin_GPIO37) +#define MICROPY_HW_NEOPIXEL (&pin_GPIO16) + +#define MICROPY_HW_BUTTON (&pin_GPIO21) +#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO21) + +#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") + +#define AUTORESET_DELAY_MS 500 diff --git a/ports/espressif/boards/hiibot_iots2/mpconfigboard.mk b/ports/espressif/boards/hiibot_iots2/mpconfigboard.mk new file mode 100644 index 0000000000..58a7176119 --- /dev/null +++ b/ports/espressif/boards/hiibot_iots2/mpconfigboard.mk @@ -0,0 +1,18 @@ +USB_VID = 0x303A +USB_PID = 0x80E8 +USB_PRODUCT = "HiiBot IoTs2" +USB_MANUFACTURER = "HiiBot" + +IDF_TARGET = esp32s2 + +INTERNAL_FLASH_FILESYSTEM = 1 +LONGINT_IMPL = MPZ + +# The default queue depth of 16 overflows on release builds, +# so increase it to 32. +CFLAGS += -DCFG_TUD_TASK_QUEUE_SZ=32 + +CIRCUITPY_ESP_FLASH_MODE=qio +CIRCUITPY_ESP_FLASH_FREQ=40m +CIRCUITPY_ESP_FLASH_SIZE=8MB +#CIRCUITPY_ESP_FLASH_SIZE=4MB diff --git a/ports/espressif/boards/hiibot_iots2/pins.c b/ports/espressif/boards/hiibot_iots2/pins.c new file mode 100644 index 0000000000..55e81ef3c5 --- /dev/null +++ b/ports/espressif/boards/hiibot_iots2/pins.c @@ -0,0 +1,77 @@ +#include "shared-bindings/board/__init__.h" +#include "shared-module/displayio/__init__.h" + +STATIC const mp_rom_map_elem_t board_global_dict_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + + { MP_ROM_QSTR(MP_QSTR_IO0), MP_ROM_PTR(&pin_GPIO0) }, + + { MP_ROM_QSTR(MP_QSTR_IO1), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO1) }, // miniI2C + + { MP_ROM_QSTR(MP_QSTR_IO2), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO2) }, // miniI2C + + { MP_ROM_QSTR(MP_QSTR_IO3), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_IO4), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_IO5), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_IO6), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_IO7), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_IO8), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_IO9), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_IO10), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_IO11), MP_ROM_PTR(&pin_GPIO11) }, + { MP_ROM_QSTR(MP_QSTR_IO12), MP_ROM_PTR(&pin_GPIO12) }, + + { MP_ROM_QSTR(MP_QSTR_IO16), MP_ROM_PTR(&pin_GPIO16) }, + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO16) }, + + { MP_ROM_QSTR(MP_QSTR_IO17), MP_ROM_PTR(&pin_GPIO17) }, + { MP_ROM_QSTR(MP_QSTR_DAC1), MP_ROM_PTR(&pin_GPIO17) }, + + { MP_ROM_QSTR(MP_QSTR_IO18), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_DAC2), MP_ROM_PTR(&pin_GPIO18) }, + + { MP_ROM_QSTR(MP_QSTR_IO21), MP_ROM_PTR(&pin_GPIO21) }, + { MP_ROM_QSTR(MP_QSTR_BUTTON), MP_ROM_PTR(&pin_GPIO21) }, + + { MP_ROM_QSTR(MP_QSTR_IO33), MP_ROM_PTR(&pin_GPIO33) }, + { MP_ROM_QSTR(MP_QSTR_TFT_MOSI), MP_ROM_PTR(&pin_GPIO33) }, + + { MP_ROM_QSTR(MP_QSTR_IO34), MP_ROM_PTR(&pin_GPIO34) }, + { MP_ROM_QSTR(MP_QSTR_TFT_SCK), MP_ROM_PTR(&pin_GPIO34) }, + + { MP_ROM_QSTR(MP_QSTR_IO35), MP_ROM_PTR(&pin_GPIO35) }, + { MP_ROM_QSTR(MP_QSTR_TFT_DC), MP_ROM_PTR(&pin_GPIO35) }, + + { MP_ROM_QSTR(MP_QSTR_IO36), MP_ROM_PTR(&pin_GPIO36) }, + { MP_ROM_QSTR(MP_QSTR_TFT_NSS), MP_ROM_PTR(&pin_GPIO36) }, + + { MP_ROM_QSTR(MP_QSTR_IO37), MP_ROM_PTR(&pin_GPIO37) }, + { MP_ROM_QSTR(MP_QSTR_BLUELED), MP_ROM_PTR(&pin_GPIO37) }, + + { MP_ROM_QSTR(MP_QSTR_IO38), MP_ROM_PTR(&pin_GPIO38) }, + { MP_ROM_QSTR(MP_QSTR_TFT_BL), MP_ROM_PTR(&pin_GPIO38) }, + + { MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display) }, + + { MP_ROM_QSTR(MP_QSTR_IO40), MP_ROM_PTR(&pin_GPIO40) }, + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO40) }, + + { MP_ROM_QSTR(MP_QSTR_IO41), MP_ROM_PTR(&pin_GPIO41) }, + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO41) }, + + { MP_ROM_QSTR(MP_QSTR_IO42), MP_ROM_PTR(&pin_GPIO42) }, + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO42) }, + + { MP_ROM_QSTR(MP_QSTR_IO43), MP_ROM_PTR(&pin_GPIO43) }, + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO43) }, + + { MP_ROM_QSTR(MP_QSTR_IO44), MP_ROM_PTR(&pin_GPIO44) }, + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO44) }, + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table); diff --git a/ports/espressif/boards/hiibot_iots2/sdkconfig b/ports/espressif/boards/hiibot_iots2/sdkconfig new file mode 100644 index 0000000000..5ef7020a72 --- /dev/null +++ b/ports/espressif/boards/hiibot_iots2/sdkconfig @@ -0,0 +1,40 @@ +CONFIG_ESP32S2_SPIRAM_SUPPORT=y + +# +# SPI RAM config +# +# CONFIG_SPIRAM_TYPE_AUTO is not set +# CONFIG_SPIRAM_TYPE_ESPPSRAM16=y +# CONFIG_SPIRAM_TYPE_ESPPSRAM32=y +CONFIG_SPIRAM_TYPE_ESPPSRAM64=y +CONFIG_SPIRAM_SIZE=8388608 +# CONFIG_SPIRAM_SIZE=2097152 + +# +# PSRAM clock and cs IO for ESP32S2 +# +CONFIG_DEFAULT_PSRAM_CLK_IO=30 +CONFIG_DEFAULT_PSRAM_CS_IO=26 +# end of PSRAM clock and cs IO for ESP32S2 + +# CONFIG_SPIRAM_FETCH_INSTRUCTIONS is not set +# CONFIG_SPIRAM_RODATA is not set +# CONFIG_SPIRAM_SPEED_80M is not set +CONFIG_SPIRAM_SPEED_40M=y +# CONFIG_SPIRAM_SPEED_26M is not set +# CONFIG_SPIRAM_SPEED_20M is not set +CONFIG_SPIRAM=y +CONFIG_SPIRAM_BOOT_INIT=y +# CONFIG_SPIRAM_IGNORE_NOTFOUND is not set +CONFIG_SPIRAM_USE_MEMMAP=y +# CONFIG_SPIRAM_USE_CAPS_ALLOC is not set +# CONFIG_SPIRAM_USE_MALLOC is not set +CONFIG_SPIRAM_MEMTEST=y +# CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY is not set +# end of SPI RAM config + +# +# LWIP +# +CONFIG_LWIP_LOCAL_HOSTNAME="HiiBot_IoTs2" +# end of LWIP diff --git a/ports/espressif/boards/lilygo_ttgo_t8_s2_st7789/board.c b/ports/espressif/boards/lilygo_ttgo_t8_s2_st7789/board.c index b00a1ed8ed..492c3f8f4d 100644 --- a/ports/espressif/boards/lilygo_ttgo_t8_s2_st7789/board.c +++ b/ports/espressif/boards/lilygo_ttgo_t8_s2_st7789/board.c @@ -71,8 +71,8 @@ static void display_init(void) { spi, &pin_GPIO36, // CLK &pin_GPIO35, // MOSI - NULL // MISO not connected - ); + NULL, // MISO not connected + false); // Not half-duplex common_hal_busio_spi_never_reset(spi); @@ -131,10 +131,6 @@ static void display_init(void) { } void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); - // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO43); diff --git a/ports/espressif/boards/lilygo_ttgo_t8_s2_st7789/sdkconfig b/ports/espressif/boards/lilygo_ttgo_t8_s2_st7789/sdkconfig index 5d52cbff44..8c401a6ff3 100644 --- a/ports/espressif/boards/lilygo_ttgo_t8_s2_st7789/sdkconfig +++ b/ports/espressif/boards/lilygo_ttgo_t8_s2_st7789/sdkconfig @@ -1,29 +1,37 @@ CONFIG_ESP32S2_SPIRAM_SUPPORT=y - # # SPI RAM config # +# CONFIG_SPIRAM_TYPE_AUTO is not set +# CONFIG_SPIRAM_TYPE_ESPPSRAM16 is not set +# CONFIG_SPIRAM_TYPE_ESPPSRAM32 is not set CONFIG_SPIRAM_TYPE_ESPPSRAM64=y CONFIG_SPIRAM_SIZE=8388608 +# end of SPI RAM config +CONFIG_DEFAULT_PSRAM_CLK_IO=30 # # PSRAM clock and cs IO for ESP32S2 # -CONFIG_DEFAULT_PSRAM_CLK_IO=30 CONFIG_DEFAULT_PSRAM_CS_IO=26 # end of PSRAM clock and cs IO for ESP32S2 +# CONFIG_SPIRAM_FETCH_INSTRUCTIONS is not set +# CONFIG_SPIRAM_RODATA is not set +# CONFIG_SPIRAM_SPEED_80M is not set CONFIG_SPIRAM_SPEED_40M=y +# CONFIG_SPIRAM_SPEED_26M is not set +# CONFIG_SPIRAM_SPEED_20M is not set CONFIG_SPIRAM=y CONFIG_SPIRAM_BOOT_INIT=y -CONFIG_SPIRAM_USE_MALLOC=y +# CONFIG_SPIRAM_IGNORE_NOTFOUND is not set CONFIG_SPIRAM_USE_MEMMAP=y +# CONFIG_SPIRAM_USE_CAPS_ALLOC is not set +# CONFIG_SPIRAM_USE_MALLOC is not set CONFIG_SPIRAM_MEMTEST=y -# end of SPI RAM config - +# CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY is not set # # LWIP # CONFIG_LWIP_LOCAL_HOSTNAME="TTGO-T8-ESP32-S2" -CONFIG_LWIP_DNS_SUPPORT_MDNS_QUERIES=y # end of LWIP diff --git a/ports/espressif/boards/lolin_s2_mini/board.c b/ports/espressif/boards/lolin_s2_mini/board.c index a0e399b1ef..0432485111 100644 --- a/ports/espressif/boards/lolin_s2_mini/board.c +++ b/ports/espressif/boards/lolin_s2_mini/board.c @@ -29,24 +29,11 @@ #include "shared-bindings/microcontroller/Pin.h" void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); - // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO43); common_hal_never_reset_pin(&pin_GPIO44); #endif /* DEBUG */ - - // SPI Flash and RAM - common_hal_never_reset_pin(&pin_GPIO26); - common_hal_never_reset_pin(&pin_GPIO27); - common_hal_never_reset_pin(&pin_GPIO28); - common_hal_never_reset_pin(&pin_GPIO29); - common_hal_never_reset_pin(&pin_GPIO30); - common_hal_never_reset_pin(&pin_GPIO31); - common_hal_never_reset_pin(&pin_GPIO32); } bool board_requests_safe_mode(void) { diff --git a/ports/espressif/boards/lolin_s2_mini/sdkconfig b/ports/espressif/boards/lolin_s2_mini/sdkconfig index 126ae31312..deb0dadcb9 100644 --- a/ports/espressif/boards/lolin_s2_mini/sdkconfig +++ b/ports/espressif/boards/lolin_s2_mini/sdkconfig @@ -1,24 +1,24 @@ CONFIG_ESP32S2_SPIRAM_SUPPORT=y - # # SPI RAM config # -# CONFIG_SPIRAM_TYPE_AUTO=y +# CONFIG_SPIRAM_TYPE_AUTO is not set CONFIG_SPIRAM_TYPE_ESPPSRAM16=y # CONFIG_SPIRAM_TYPE_ESPPSRAM32 is not set -# CONFIG_SPIRAM_TYPE_ESPPSRAM64=y +# CONFIG_SPIRAM_TYPE_ESPPSRAM64 is not set CONFIG_SPIRAM_SIZE=2097152 +# end of SPI RAM config +CONFIG_DEFAULT_PSRAM_CLK_IO=30 # # PSRAM clock and cs IO for ESP32S2 # -CONFIG_DEFAULT_PSRAM_CLK_IO=30 CONFIG_DEFAULT_PSRAM_CS_IO=26 # end of PSRAM clock and cs IO for ESP32S2 # CONFIG_SPIRAM_FETCH_INSTRUCTIONS is not set # CONFIG_SPIRAM_RODATA is not set -# CONFIG_SPIRAM_SPEED_80M=y +# CONFIG_SPIRAM_SPEED_80M is not set CONFIG_SPIRAM_SPEED_40M=y # CONFIG_SPIRAM_SPEED_26M is not set # CONFIG_SPIRAM_SPEED_20M is not set @@ -30,8 +30,6 @@ CONFIG_SPIRAM_USE_MEMMAP=y # CONFIG_SPIRAM_USE_MALLOC is not set CONFIG_SPIRAM_MEMTEST=y # CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY is not set -# end of SPI RAM config - # # LWIP # diff --git a/ports/espressif/boards/lolin_s2_pico/board.c b/ports/espressif/boards/lolin_s2_pico/board.c index a0e399b1ef..0432485111 100644 --- a/ports/espressif/boards/lolin_s2_pico/board.c +++ b/ports/espressif/boards/lolin_s2_pico/board.c @@ -29,24 +29,11 @@ #include "shared-bindings/microcontroller/Pin.h" void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); - // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO43); common_hal_never_reset_pin(&pin_GPIO44); #endif /* DEBUG */ - - // SPI Flash and RAM - common_hal_never_reset_pin(&pin_GPIO26); - common_hal_never_reset_pin(&pin_GPIO27); - common_hal_never_reset_pin(&pin_GPIO28); - common_hal_never_reset_pin(&pin_GPIO29); - common_hal_never_reset_pin(&pin_GPIO30); - common_hal_never_reset_pin(&pin_GPIO31); - common_hal_never_reset_pin(&pin_GPIO32); } bool board_requests_safe_mode(void) { diff --git a/ports/espressif/boards/lolin_s2_pico/sdkconfig b/ports/espressif/boards/lolin_s2_pico/sdkconfig index 36e83d7fb5..5ce352a98d 100644 --- a/ports/espressif/boards/lolin_s2_pico/sdkconfig +++ b/ports/espressif/boards/lolin_s2_pico/sdkconfig @@ -1,24 +1,24 @@ CONFIG_ESP32S2_SPIRAM_SUPPORT=y - # # SPI RAM config # -# CONFIG_SPIRAM_TYPE_AUTO=y +# CONFIG_SPIRAM_TYPE_AUTO is not set CONFIG_SPIRAM_TYPE_ESPPSRAM16=y # CONFIG_SPIRAM_TYPE_ESPPSRAM32 is not set -# CONFIG_SPIRAM_TYPE_ESPPSRAM64=y +# CONFIG_SPIRAM_TYPE_ESPPSRAM64 is not set CONFIG_SPIRAM_SIZE=2097152 +# end of SPI RAM config +CONFIG_DEFAULT_PSRAM_CLK_IO=30 # # PSRAM clock and cs IO for ESP32S2 # -CONFIG_DEFAULT_PSRAM_CLK_IO=30 CONFIG_DEFAULT_PSRAM_CS_IO=26 # end of PSRAM clock and cs IO for ESP32S2 # CONFIG_SPIRAM_FETCH_INSTRUCTIONS is not set # CONFIG_SPIRAM_RODATA is not set -# CONFIG_SPIRAM_SPEED_80M=y +# CONFIG_SPIRAM_SPEED_80M is not set CONFIG_SPIRAM_SPEED_40M=y # CONFIG_SPIRAM_SPEED_26M is not set # CONFIG_SPIRAM_SPEED_20M is not set @@ -30,8 +30,6 @@ CONFIG_SPIRAM_USE_MEMMAP=y # CONFIG_SPIRAM_USE_MALLOC is not set CONFIG_SPIRAM_MEMTEST=y # CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY is not set -# end of SPI RAM config - # # LWIP # diff --git a/ports/espressif/boards/microdev_micro_c3/board.c b/ports/espressif/boards/microdev_micro_c3/board.c index 7ffd406cfe..e3b71f4832 100644 --- a/ports/espressif/boards/microdev_micro_c3/board.c +++ b/ports/espressif/boards/microdev_micro_c3/board.c @@ -28,24 +28,11 @@ #include "supervisor/board.h" void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO18); - common_hal_never_reset_pin(&pin_GPIO19); - // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO20); common_hal_never_reset_pin(&pin_GPIO21); #endif - - // SPI Flash - common_hal_never_reset_pin(&pin_GPIO11); - common_hal_never_reset_pin(&pin_GPIO12); - common_hal_never_reset_pin(&pin_GPIO13); - common_hal_never_reset_pin(&pin_GPIO14); - common_hal_never_reset_pin(&pin_GPIO15); - common_hal_never_reset_pin(&pin_GPIO16); - common_hal_never_reset_pin(&pin_GPIO17); } bool board_requests_safe_mode(void) { diff --git a/ports/espressif/boards/microdev_micro_c3/pins.c b/ports/espressif/boards/microdev_micro_c3/pins.c index 84d6efb782..240966404f 100644 --- a/ports/espressif/boards/microdev_micro_c3/pins.c +++ b/ports/espressif/boards/microdev_micro_c3/pins.c @@ -72,6 +72,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO7) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, }; diff --git a/ports/espressif/boards/microdev_micro_s2/board.c b/ports/espressif/boards/microdev_micro_s2/board.c index 52d640618c..0a2b17e001 100644 --- a/ports/espressif/boards/microdev_micro_s2/board.c +++ b/ports/espressif/boards/microdev_micro_s2/board.c @@ -28,31 +28,31 @@ #include "mpconfigboard.h" #include "shared-bindings/microcontroller/Pin.h" -void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); +#include "components/driver/include/driver/gpio.h" +void board_init(void) { // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO43); common_hal_never_reset_pin(&pin_GPIO44); #endif - - // SPI Flash and RAM - common_hal_never_reset_pin(&pin_GPIO26); - common_hal_never_reset_pin(&pin_GPIO27); - common_hal_never_reset_pin(&pin_GPIO28); - common_hal_never_reset_pin(&pin_GPIO29); - common_hal_never_reset_pin(&pin_GPIO30); - common_hal_never_reset_pin(&pin_GPIO31); - common_hal_never_reset_pin(&pin_GPIO32); } bool board_requests_safe_mode(void) { return false; } +bool espressif_board_reset_pin_number(gpio_num_t pin_number) { + // Pin 21 is a high side LED so pull it down to prevent lighting the LED. + if (pin_number == 21) { + gpio_reset_pin(21); + gpio_pullup_dis(21); + gpio_pulldown_en(21); + return true; + } + return false; +} + void reset_board(void) { } diff --git a/ports/espressif/boards/microdev_micro_s2/pins.c b/ports/espressif/boards/microdev_micro_s2/pins.c index faf4a9e473..a382bf8fef 100644 --- a/ports/espressif/boards/microdev_micro_s2/pins.c +++ b/ports/espressif/boards/microdev_micro_s2/pins.c @@ -90,6 +90,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO33) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, }; diff --git a/ports/espressif/boards/microdev_micro_s2/sdkconfig b/ports/espressif/boards/microdev_micro_s2/sdkconfig index b3c5219972..4b617fee71 100644 --- a/ports/espressif/boards/microdev_micro_s2/sdkconfig +++ b/ports/espressif/boards/microdev_micro_s2/sdkconfig @@ -1,5 +1,4 @@ CONFIG_ESP32S2_SPIRAM_SUPPORT=y - # # SPI RAM config # @@ -8,11 +7,12 @@ CONFIG_ESP32S2_SPIRAM_SUPPORT=y # CONFIG_SPIRAM_TYPE_ESPPSRAM32 is not set CONFIG_SPIRAM_TYPE_ESPPSRAM64=y CONFIG_SPIRAM_SIZE=8388608 +# end of SPI RAM config +CONFIG_DEFAULT_PSRAM_CLK_IO=30 # # PSRAM clock and cs IO for ESP32S2 # -CONFIG_DEFAULT_PSRAM_CLK_IO=30 CONFIG_DEFAULT_PSRAM_CS_IO=26 # end of PSRAM clock and cs IO for ESP32S2 @@ -30,8 +30,6 @@ CONFIG_SPIRAM_USE_MEMMAP=y # CONFIG_SPIRAM_USE_MALLOC is not set CONFIG_SPIRAM_MEMTEST=y # CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY is not set -# end of SPI RAM config - # # LWIP # diff --git a/ports/espressif/boards/morpheans_morphesp-240/board.c b/ports/espressif/boards/morpheans_morphesp-240/board.c index aad2f0257a..b15562de38 100644 --- a/ports/espressif/boards/morpheans_morphesp-240/board.c +++ b/ports/espressif/boards/morpheans_morphesp-240/board.c @@ -139,10 +139,6 @@ uint8_t display_init_sequence[] = { void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); - // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO6); @@ -157,8 +153,8 @@ void board_init(void) { spi, &pin_GPIO12, // CLK &pin_GPIO11, // MOSI - NULL // MISO not connected - ); + NULL, // MISO not connected + false); // Not half-duplex common_hal_busio_spi_never_reset(spi); diff --git a/ports/espressif/boards/morpheans_morphesp-240/sdkconfig b/ports/espressif/boards/morpheans_morphesp-240/sdkconfig index 36ada0b0c7..6de15d1556 100644 --- a/ports/espressif/boards/morpheans_morphesp-240/sdkconfig +++ b/ports/espressif/boards/morpheans_morphesp-240/sdkconfig @@ -1,6 +1,6 @@ +# CONFIG_ESP32S2_SPIRAM_SUPPORT is not set # # LWIP # CONFIG_LWIP_LOCAL_HOSTNAME="MORPHESP-240" -CONFIG_LWIP_DNS_SUPPORT_MDNS_QUERIES=y -# end of LWIP \ No newline at end of file +# end of LWIP diff --git a/ports/espressif/boards/muselab_nanoesp32_s2_wroom/board.c b/ports/espressif/boards/muselab_nanoesp32_s2_wroom/board.c index e40b6335bc..0432485111 100644 --- a/ports/espressif/boards/muselab_nanoesp32_s2_wroom/board.c +++ b/ports/espressif/boards/muselab_nanoesp32_s2_wroom/board.c @@ -29,10 +29,6 @@ #include "shared-bindings/microcontroller/Pin.h" void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); - // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO43); diff --git a/ports/espressif/boards/muselab_nanoesp32_s2_wroom/sdkconfig b/ports/espressif/boards/muselab_nanoesp32_s2_wroom/sdkconfig index e69de29bb2..5b9c86dcc3 100644 --- a/ports/espressif/boards/muselab_nanoesp32_s2_wroom/sdkconfig +++ b/ports/espressif/boards/muselab_nanoesp32_s2_wroom/sdkconfig @@ -0,0 +1,6 @@ +# CONFIG_ESP32S2_SPIRAM_SUPPORT is not set +# +# LWIP +# +CONFIG_LWIP_LOCAL_HOSTNAME="espressif" +# end of LWIP diff --git a/ports/espressif/boards/muselab_nanoesp32_s2_wrover/board.c b/ports/espressif/boards/muselab_nanoesp32_s2_wrover/board.c index e40b6335bc..0432485111 100644 --- a/ports/espressif/boards/muselab_nanoesp32_s2_wrover/board.c +++ b/ports/espressif/boards/muselab_nanoesp32_s2_wrover/board.c @@ -29,10 +29,6 @@ #include "shared-bindings/microcontroller/Pin.h" void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); - // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO43); diff --git a/ports/espressif/boards/muselab_nanoesp32_s2_wrover/sdkconfig b/ports/espressif/boards/muselab_nanoesp32_s2_wrover/sdkconfig index e69de29bb2..5b9c86dcc3 100644 --- a/ports/espressif/boards/muselab_nanoesp32_s2_wrover/sdkconfig +++ b/ports/espressif/boards/muselab_nanoesp32_s2_wrover/sdkconfig @@ -0,0 +1,6 @@ +# CONFIG_ESP32S2_SPIRAM_SUPPORT is not set +# +# LWIP +# +CONFIG_LWIP_LOCAL_HOSTNAME="espressif" +# end of LWIP diff --git a/ports/espressif/boards/odt_pixelwing_esp32_s2/board.c b/ports/espressif/boards/odt_pixelwing_esp32_s2/board.c index 5abd1ce1b3..6772768da5 100644 --- a/ports/espressif/boards/odt_pixelwing_esp32_s2/board.c +++ b/ports/espressif/boards/odt_pixelwing_esp32_s2/board.c @@ -29,9 +29,6 @@ #include "shared-bindings/microcontroller/Pin.h" void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); } bool board_requests_safe_mode(void) { diff --git a/ports/espressif/boards/odt_pixelwing_esp32_s2/pins.c b/ports/espressif/boards/odt_pixelwing_esp32_s2/pins.c index f547c28def..4daec42ae4 100644 --- a/ports/espressif/boards/odt_pixelwing_esp32_s2/pins.c +++ b/ports/espressif/boards/odt_pixelwing_esp32_s2/pins.c @@ -12,5 +12,6 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO45) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, }; MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/espressif/boards/odt_pixelwing_esp32_s2/sdkconfig b/ports/espressif/boards/odt_pixelwing_esp32_s2/sdkconfig index f67a257854..17c1995cd3 100644 --- a/ports/espressif/boards/odt_pixelwing_esp32_s2/sdkconfig +++ b/ports/espressif/boards/odt_pixelwing_esp32_s2/sdkconfig @@ -1,5 +1,4 @@ CONFIG_ESP32S2_SPIRAM_SUPPORT=y - # # SPI RAM config # @@ -8,11 +7,12 @@ CONFIG_SPIRAM_TYPE_ESPPSRAM16=y # CONFIG_SPIRAM_TYPE_ESPPSRAM32 is not set # CONFIG_SPIRAM_TYPE_ESPPSRAM64 is not set CONFIG_SPIRAM_SIZE=2097152 +# end of SPI RAM config +CONFIG_DEFAULT_PSRAM_CLK_IO=30 # # PSRAM clock and cs IO for ESP32S2 # -CONFIG_DEFAULT_PSRAM_CLK_IO=30 CONFIG_DEFAULT_PSRAM_CS_IO=26 # end of PSRAM clock and cs IO for ESP32S2 @@ -30,8 +30,6 @@ CONFIG_SPIRAM_USE_MEMMAP=y # CONFIG_SPIRAM_USE_MALLOC is not set CONFIG_SPIRAM_MEMTEST=y # CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY is not set -# end of SPI RAM config - # # LWIP # diff --git a/ports/espressif/boards/targett_module_clip_wroom/board.c b/ports/espressif/boards/targett_module_clip_wroom/board.c index 00b94a0259..66aea4bdd5 100644 --- a/ports/espressif/boards/targett_module_clip_wroom/board.c +++ b/ports/espressif/boards/targett_module_clip_wroom/board.c @@ -29,10 +29,6 @@ #include "shared-bindings/microcontroller/Pin.h" void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); - // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO43); diff --git a/ports/espressif/boards/targett_module_clip_wroom/sdkconfig b/ports/espressif/boards/targett_module_clip_wroom/sdkconfig index e69de29bb2..5b9c86dcc3 100644 --- a/ports/espressif/boards/targett_module_clip_wroom/sdkconfig +++ b/ports/espressif/boards/targett_module_clip_wroom/sdkconfig @@ -0,0 +1,6 @@ +# CONFIG_ESP32S2_SPIRAM_SUPPORT is not set +# +# LWIP +# +CONFIG_LWIP_LOCAL_HOSTNAME="espressif" +# end of LWIP diff --git a/ports/espressif/boards/targett_module_clip_wrover/board.c b/ports/espressif/boards/targett_module_clip_wrover/board.c index 00b94a0259..66aea4bdd5 100644 --- a/ports/espressif/boards/targett_module_clip_wrover/board.c +++ b/ports/espressif/boards/targett_module_clip_wrover/board.c @@ -29,10 +29,6 @@ #include "shared-bindings/microcontroller/Pin.h" void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); - // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO43); diff --git a/ports/espressif/boards/targett_module_clip_wrover/sdkconfig b/ports/espressif/boards/targett_module_clip_wrover/sdkconfig index 9d8bbde967..f19afafa3d 100644 --- a/ports/espressif/boards/targett_module_clip_wrover/sdkconfig +++ b/ports/espressif/boards/targett_module_clip_wrover/sdkconfig @@ -1,5 +1,4 @@ CONFIG_ESP32S2_SPIRAM_SUPPORT=y - # # SPI RAM config # @@ -8,11 +7,12 @@ CONFIG_SPIRAM_TYPE_ESPPSRAM16=y # CONFIG_SPIRAM_TYPE_ESPPSRAM32 is not set # CONFIG_SPIRAM_TYPE_ESPPSRAM64 is not set CONFIG_SPIRAM_SIZE=2097152 +# end of SPI RAM config +CONFIG_DEFAULT_PSRAM_CLK_IO=30 # # PSRAM clock and cs IO for ESP32S2 # -CONFIG_DEFAULT_PSRAM_CLK_IO=30 CONFIG_DEFAULT_PSRAM_CS_IO=26 # end of PSRAM clock and cs IO for ESP32S2 @@ -30,4 +30,8 @@ CONFIG_SPIRAM_USE_MEMMAP=y # CONFIG_SPIRAM_USE_MALLOC is not set CONFIG_SPIRAM_MEMTEST=y # CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY is not set -# end of SPI RAM config +# +# LWIP +# +CONFIG_LWIP_LOCAL_HOSTNAME="espressif" +# end of LWIP diff --git a/ports/espressif/boards/unexpectedmaker_feathers2/board.c b/ports/espressif/boards/unexpectedmaker_feathers2/board.c index a0e399b1ef..0432485111 100644 --- a/ports/espressif/boards/unexpectedmaker_feathers2/board.c +++ b/ports/espressif/boards/unexpectedmaker_feathers2/board.c @@ -29,24 +29,11 @@ #include "shared-bindings/microcontroller/Pin.h" void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); - // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO43); common_hal_never_reset_pin(&pin_GPIO44); #endif /* DEBUG */ - - // SPI Flash and RAM - common_hal_never_reset_pin(&pin_GPIO26); - common_hal_never_reset_pin(&pin_GPIO27); - common_hal_never_reset_pin(&pin_GPIO28); - common_hal_never_reset_pin(&pin_GPIO29); - common_hal_never_reset_pin(&pin_GPIO30); - common_hal_never_reset_pin(&pin_GPIO31); - common_hal_never_reset_pin(&pin_GPIO32); } bool board_requests_safe_mode(void) { diff --git a/ports/espressif/boards/unexpectedmaker_feathers2/pins.c b/ports/espressif/boards/unexpectedmaker_feathers2/pins.c index 66657b2f4f..f731b08688 100644 --- a/ports/espressif/boards/unexpectedmaker_feathers2/pins.c +++ b/ports/espressif/boards/unexpectedmaker_feathers2/pins.c @@ -98,6 +98,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_AMB), MP_ROM_PTR(&pin_GPIO4) }, // Ambient Light Sensor { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, }; diff --git a/ports/espressif/boards/unexpectedmaker_feathers2/sdkconfig b/ports/espressif/boards/unexpectedmaker_feathers2/sdkconfig index c9d44460c5..8d785a6004 100644 --- a/ports/espressif/boards/unexpectedmaker_feathers2/sdkconfig +++ b/ports/espressif/boards/unexpectedmaker_feathers2/sdkconfig @@ -1,5 +1,4 @@ CONFIG_ESP32S2_SPIRAM_SUPPORT=y - # # SPI RAM config # @@ -8,11 +7,12 @@ CONFIG_ESP32S2_SPIRAM_SUPPORT=y # CONFIG_SPIRAM_TYPE_ESPPSRAM32 is not set CONFIG_SPIRAM_TYPE_ESPPSRAM64=y CONFIG_SPIRAM_SIZE=8388608 +# end of SPI RAM config +CONFIG_DEFAULT_PSRAM_CLK_IO=30 # # PSRAM clock and cs IO for ESP32S2 # -CONFIG_DEFAULT_PSRAM_CLK_IO=30 CONFIG_DEFAULT_PSRAM_CS_IO=26 # end of PSRAM clock and cs IO for ESP32S2 @@ -30,8 +30,6 @@ CONFIG_SPIRAM_USE_MEMMAP=y # CONFIG_SPIRAM_USE_MALLOC is not set CONFIG_SPIRAM_MEMTEST=y # CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY is not set -# end of SPI RAM config - # # LWIP # diff --git a/ports/espressif/boards/unexpectedmaker_feathers2_neo/board.c b/ports/espressif/boards/unexpectedmaker_feathers2_neo/board.c index a0e399b1ef..0432485111 100644 --- a/ports/espressif/boards/unexpectedmaker_feathers2_neo/board.c +++ b/ports/espressif/boards/unexpectedmaker_feathers2_neo/board.c @@ -29,24 +29,11 @@ #include "shared-bindings/microcontroller/Pin.h" void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); - // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO43); common_hal_never_reset_pin(&pin_GPIO44); #endif /* DEBUG */ - - // SPI Flash and RAM - common_hal_never_reset_pin(&pin_GPIO26); - common_hal_never_reset_pin(&pin_GPIO27); - common_hal_never_reset_pin(&pin_GPIO28); - common_hal_never_reset_pin(&pin_GPIO29); - common_hal_never_reset_pin(&pin_GPIO30); - common_hal_never_reset_pin(&pin_GPIO31); - common_hal_never_reset_pin(&pin_GPIO32); } bool board_requests_safe_mode(void) { diff --git a/ports/espressif/boards/unexpectedmaker_feathers2_neo/pins.c b/ports/espressif/boards/unexpectedmaker_feathers2_neo/pins.c index 61bf1397a9..43df5d506a 100644 --- a/ports/espressif/boards/unexpectedmaker_feathers2_neo/pins.c +++ b/ports/espressif/boards/unexpectedmaker_feathers2_neo/pins.c @@ -115,6 +115,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_IO21), MP_ROM_PTR(&pin_GPIO21) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, }; diff --git a/ports/espressif/boards/unexpectedmaker_feathers2_neo/sdkconfig b/ports/espressif/boards/unexpectedmaker_feathers2_neo/sdkconfig index 453aeb1d2d..4a5990b91d 100644 --- a/ports/espressif/boards/unexpectedmaker_feathers2_neo/sdkconfig +++ b/ports/espressif/boards/unexpectedmaker_feathers2_neo/sdkconfig @@ -1,18 +1,18 @@ CONFIG_ESP32S2_SPIRAM_SUPPORT=y - # # SPI RAM config # -# CONFIG_SPIRAM_TYPE_AUTO=y +# CONFIG_SPIRAM_TYPE_AUTO is not set CONFIG_SPIRAM_TYPE_ESPPSRAM16=y # CONFIG_SPIRAM_TYPE_ESPPSRAM32 is not set -# CONFIG_SPIRAM_TYPE_ESPPSRAM64=y +# CONFIG_SPIRAM_TYPE_ESPPSRAM64 is not set CONFIG_SPIRAM_SIZE=2097152 +# end of SPI RAM config +CONFIG_DEFAULT_PSRAM_CLK_IO=30 # # PSRAM clock and cs IO for ESP32S2 # -CONFIG_DEFAULT_PSRAM_CLK_IO=30 CONFIG_DEFAULT_PSRAM_CS_IO=26 # end of PSRAM clock and cs IO for ESP32S2 @@ -30,8 +30,6 @@ CONFIG_SPIRAM_USE_MEMMAP=y # CONFIG_SPIRAM_USE_MALLOC is not set CONFIG_SPIRAM_MEMTEST=y # CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY is not set -# end of SPI RAM config - # # LWIP # diff --git a/ports/espressif/boards/unexpectedmaker_feathers2_prerelease/board.c b/ports/espressif/boards/unexpectedmaker_feathers2_prerelease/board.c index a0e399b1ef..0432485111 100644 --- a/ports/espressif/boards/unexpectedmaker_feathers2_prerelease/board.c +++ b/ports/espressif/boards/unexpectedmaker_feathers2_prerelease/board.c @@ -29,24 +29,11 @@ #include "shared-bindings/microcontroller/Pin.h" void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); - // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO43); common_hal_never_reset_pin(&pin_GPIO44); #endif /* DEBUG */ - - // SPI Flash and RAM - common_hal_never_reset_pin(&pin_GPIO26); - common_hal_never_reset_pin(&pin_GPIO27); - common_hal_never_reset_pin(&pin_GPIO28); - common_hal_never_reset_pin(&pin_GPIO29); - common_hal_never_reset_pin(&pin_GPIO30); - common_hal_never_reset_pin(&pin_GPIO31); - common_hal_never_reset_pin(&pin_GPIO32); } bool board_requests_safe_mode(void) { diff --git a/ports/espressif/boards/unexpectedmaker_feathers2_prerelease/pins.c b/ports/espressif/boards/unexpectedmaker_feathers2_prerelease/pins.c index 29ceffcdd5..34485b3ea8 100644 --- a/ports/espressif/boards/unexpectedmaker_feathers2_prerelease/pins.c +++ b/ports/espressif/boards/unexpectedmaker_feathers2_prerelease/pins.c @@ -96,6 +96,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_AMB), MP_ROM_PTR(&pin_GPIO4) }, // Ambient Light Sensor { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, }; diff --git a/ports/espressif/boards/unexpectedmaker_feathers2_prerelease/sdkconfig b/ports/espressif/boards/unexpectedmaker_feathers2_prerelease/sdkconfig index 00e0bb2566..8d785a6004 100644 --- a/ports/espressif/boards/unexpectedmaker_feathers2_prerelease/sdkconfig +++ b/ports/espressif/boards/unexpectedmaker_feathers2_prerelease/sdkconfig @@ -1,5 +1,4 @@ CONFIG_ESP32S2_SPIRAM_SUPPORT=y - # # SPI RAM config # @@ -8,18 +7,17 @@ CONFIG_ESP32S2_SPIRAM_SUPPORT=y # CONFIG_SPIRAM_TYPE_ESPPSRAM32 is not set CONFIG_SPIRAM_TYPE_ESPPSRAM64=y CONFIG_SPIRAM_SIZE=8388608 +# end of SPI RAM config +CONFIG_DEFAULT_PSRAM_CLK_IO=30 # # PSRAM clock and cs IO for ESP32S2 # -CONFIG_DEFAULT_PSRAM_CLK_IO=30 CONFIG_DEFAULT_PSRAM_CS_IO=26 # end of PSRAM clock and cs IO for ESP32S2 -CONFIG_SPIRAM_SPIWP_SD3_PIN=28 # CONFIG_SPIRAM_FETCH_INSTRUCTIONS is not set # CONFIG_SPIRAM_RODATA is not set -# CONFIG_SPIRAM_USE_AHB_DBUS3 is not set # CONFIG_SPIRAM_SPEED_80M is not set CONFIG_SPIRAM_SPEED_40M=y # CONFIG_SPIRAM_SPEED_26M is not set @@ -32,8 +30,6 @@ CONFIG_SPIRAM_USE_MEMMAP=y # CONFIG_SPIRAM_USE_MALLOC is not set CONFIG_SPIRAM_MEMTEST=y # CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY is not set -# end of SPI RAM config - # # LWIP # diff --git a/ports/espressif/boards/unexpectedmaker_feathers3/board.c b/ports/espressif/boards/unexpectedmaker_feathers3/board.c new file mode 100644 index 0000000000..0432485111 --- /dev/null +++ b/ports/espressif/boards/unexpectedmaker_feathers3/board.c @@ -0,0 +1,48 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "supervisor/board.h" +#include "mpconfigboard.h" +#include "shared-bindings/microcontroller/Pin.h" + +void board_init(void) { + // Debug UART + #ifdef DEBUG + common_hal_never_reset_pin(&pin_GPIO43); + common_hal_never_reset_pin(&pin_GPIO44); + #endif /* DEBUG */ +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { + +} + +void board_deinit(void) { +} diff --git a/ports/espressif/boards/unexpectedmaker_feathers3/mpconfigboard.h b/ports/espressif/boards/unexpectedmaker_feathers3/mpconfigboard.h new file mode 100644 index 0000000000..3c9f8f25c1 --- /dev/null +++ b/ports/espressif/boards/unexpectedmaker_feathers3/mpconfigboard.h @@ -0,0 +1,49 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +// Micropython setup + +#define MICROPY_HW_BOARD_NAME "FeatherS3" +#define MICROPY_HW_MCU_NAME "ESP32S3" + +#define MICROPY_HW_NEOPIXEL (&pin_GPIO40) +#define CIRCUITPY_STATUS_LED_POWER (&pin_GPIO39) +#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) +#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") + +#define AUTORESET_DELAY_MS 500 + +#define DEFAULT_I2C_BUS_SCL (&pin_GPIO9) +#define DEFAULT_I2C_BUS_SDA (&pin_GPIO8) + +#define DEFAULT_SPI_BUS_SCK (&pin_GPIO36) +#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO35) +#define DEFAULT_SPI_BUS_MISO (&pin_GPIO37) + +#define DEFAULT_UART_BUS_RX (&pin_GPIO44) +#define DEFAULT_UART_BUS_TX (&pin_GPIO43) + +#define DOUBLE_TAP_PIN (&pin_GPIO47) diff --git a/ports/espressif/boards/unexpectedmaker_feathers3/mpconfigboard.mk b/ports/espressif/boards/unexpectedmaker_feathers3/mpconfigboard.mk new file mode 100644 index 0000000000..866bd15ffa --- /dev/null +++ b/ports/espressif/boards/unexpectedmaker_feathers3/mpconfigboard.mk @@ -0,0 +1,22 @@ +USB_VID = 0x303A +USB_PID = 0x80D7 +USB_PRODUCT = "FeatherS3" +USB_MANUFACTURER = "UnexpectedMaker" + +IDF_TARGET = esp32s3 + +INTERNAL_FLASH_FILESYSTEM = 1 +LONGINT_IMPL = MPZ + +# The default queue depth of 16 overflows on release builds, +# so increase it to 32. +CFLAGS += -DCFG_TUD_TASK_QUEUE_SZ=32 + +CIRCUITPY_ESP_FLASH_MODE=dio +CIRCUITPY_ESP_FLASH_FREQ=80m +CIRCUITPY_ESP_FLASH_SIZE=16MB + +#CIRCUITPY_BITBANG_NEOPIXEL = 1 + +# Include these Python libraries in firmware. +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel diff --git a/ports/espressif/boards/unexpectedmaker_feathers3/pins.c b/ports/espressif/boards/unexpectedmaker_feathers3/pins.c new file mode 100644 index 0000000000..43fdc3c579 --- /dev/null +++ b/ports/espressif/boards/unexpectedmaker_feathers3/pins.c @@ -0,0 +1,120 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + + { MP_ROM_QSTR(MP_QSTR_IO0), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_GPIO0) }, + + { MP_ROM_QSTR(MP_QSTR_IO18), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_D15), MP_ROM_PTR(&pin_GPIO18) }, + + { MP_ROM_QSTR(MP_QSTR_IO17), MP_ROM_PTR(&pin_GPIO17) }, + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO17) }, + { MP_ROM_QSTR(MP_QSTR_D14), MP_ROM_PTR(&pin_GPIO17) }, + + { MP_ROM_QSTR(MP_QSTR_IO14), MP_ROM_PTR(&pin_GPIO14) }, + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO14) }, + { MP_ROM_QSTR(MP_QSTR_D16), MP_ROM_PTR(&pin_GPIO14) }, + + { MP_ROM_QSTR(MP_QSTR_IO12), MP_ROM_PTR(&pin_GPIO12) }, + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_GPIO12) }, + { MP_ROM_QSTR(MP_QSTR_D17), MP_ROM_PTR(&pin_GPIO12) }, + + { MP_ROM_QSTR(MP_QSTR_IO6), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_D18), MP_ROM_PTR(&pin_GPIO6) }, + + { MP_ROM_QSTR(MP_QSTR_IO5), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_D19), MP_ROM_PTR(&pin_GPIO5) }, + + { MP_ROM_QSTR(MP_QSTR_IO36), MP_ROM_PTR(&pin_GPIO36) }, + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO36) }, + { MP_ROM_QSTR(MP_QSTR_D25), MP_ROM_PTR(&pin_GPIO36) }, + + { MP_ROM_QSTR(MP_QSTR_IO35), MP_ROM_PTR(&pin_GPIO35) }, + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO35) }, + { MP_ROM_QSTR(MP_QSTR_D24), MP_ROM_PTR(&pin_GPIO35) }, + + { MP_ROM_QSTR(MP_QSTR_IO37), MP_ROM_PTR(&pin_GPIO37) }, + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO37) }, + { MP_ROM_QSTR(MP_QSTR_D23), MP_ROM_PTR(&pin_GPIO37) }, + + { MP_ROM_QSTR(MP_QSTR_IO44), MP_ROM_PTR(&pin_GPIO44) }, + { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_GPIO44) }, + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO44) }, + + { MP_ROM_QSTR(MP_QSTR_IO43), MP_ROM_PTR(&pin_GPIO43) }, + { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_GPIO43) }, + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO43) }, + + // { MP_ROM_QSTR(MP_QSTR_IO42), MP_ROM_PTR(&pin_GPIO42) }, + // { MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_GPIO42) }, + + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_IO8), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_A11), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_D21), MP_ROM_PTR(&pin_GPIO8) }, + + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_IO9), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_A12), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_D22), MP_ROM_PTR(&pin_GPIO9) }, + + { MP_ROM_QSTR(MP_QSTR_IO33), MP_ROM_PTR(&pin_GPIO33) }, + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_GPIO33) }, + + { MP_ROM_QSTR(MP_QSTR_IO38), MP_ROM_PTR(&pin_GPIO38) }, + { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_GPIO38) }, + + { MP_ROM_QSTR(MP_QSTR_IO1), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_A6), MP_ROM_PTR(&pin_GPIO1) }, + + { MP_ROM_QSTR(MP_QSTR_IO3), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_A7), MP_ROM_PTR(&pin_GPIO3) }, + + { MP_ROM_QSTR(MP_QSTR_IO7), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_A8), MP_ROM_PTR(&pin_GPIO7) }, + + { MP_ROM_QSTR(MP_QSTR_IO10), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_A9), MP_ROM_PTR(&pin_GPIO10) }, + + { MP_ROM_QSTR(MP_QSTR_IO11), MP_ROM_PTR(&pin_GPIO11) }, + { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_GPIO11) }, + { MP_ROM_QSTR(MP_QSTR_A10), MP_ROM_PTR(&pin_GPIO11) }, + + { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO13) }, // Blue LED + + // Battery voltage sense pin + // I really don't know what name to use here. Adafruit use BATTERY & VOLTAGE_MONITOR + // I prefer VBAT or VBAT_SENSE + { MP_ROM_QSTR(MP_QSTR_BATTERY), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_VBAT), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_VBAT_SENSE), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_VOLTAGE_MONITOR), MP_ROM_PTR(&pin_GPIO2) }, + + // 5V present sense pin + { MP_ROM_QSTR(MP_QSTR_VBUS), MP_ROM_PTR(&pin_GPIO34) }, + { MP_ROM_QSTR(MP_QSTR_VBUS_SENSE), MP_ROM_PTR(&pin_GPIO34) }, + + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL_POWER), MP_ROM_PTR(&pin_GPIO39) }, + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO40) }, + + { MP_ROM_QSTR(MP_QSTR_IO4), MP_ROM_PTR(&pin_GPIO4) }, // Ambient Light Sensor + { MP_ROM_QSTR(MP_QSTR_AMB), MP_ROM_PTR(&pin_GPIO4) }, // Ambient Light Sensor + + { MP_ROM_QSTR(MP_QSTR_LDO2), MP_ROM_PTR(&pin_GPIO39) }, // Second LDO Enable control + { MP_ROM_QSTR(MP_QSTR_I39), MP_ROM_PTR(&pin_GPIO39) }, // Second LDO Enable control + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/espressif/boards/unexpectedmaker_feathers3/sdkconfig b/ports/espressif/boards/unexpectedmaker_feathers3/sdkconfig new file mode 100644 index 0000000000..ec989c08fc --- /dev/null +++ b/ports/espressif/boards/unexpectedmaker_feathers3/sdkconfig @@ -0,0 +1,39 @@ +CONFIG_ESP32S3_SPIRAM_SUPPORT=y + +# +# SPI RAM config +# +# CONFIG_SPIRAM_TYPE_AUTO is not set +# CONFIG_SPIRAM_TYPE_ESPPSRAM16 is not set +# CONFIG_SPIRAM_TYPE_ESPPSRAM32 is not set +CONFIG_SPIRAM_TYPE_ESPPSRAM64=y +CONFIG_SPIRAM_SIZE=8388608 + +# +# PSRAM clock and cs IO for ESP32S2 +# +CONFIG_DEFAULT_PSRAM_CLK_IO=30 +CONFIG_DEFAULT_PSRAM_CS_IO=26 +# end of PSRAM clock and cs IO for ESP32S2 + +# CONFIG_SPIRAM_FETCH_INSTRUCTIONS is not set +# CONFIG_SPIRAM_RODATA is not set +CONFIG_SPIRAM_SPEED_80M=y +# CONFIG_SPIRAM_SPEED_40M is not set +# CONFIG_SPIRAM_SPEED_26M is not set +# CONFIG_SPIRAM_SPEED_20M is not set +CONFIG_SPIRAM=y +CONFIG_SPIRAM_BOOT_INIT=y +# CONFIG_SPIRAM_IGNORE_NOTFOUND is not set +CONFIG_SPIRAM_USE_MEMMAP=y +# CONFIG_SPIRAM_USE_CAPS_ALLOC is not set +# CONFIG_SPIRAM_USE_MALLOC is not set +# CONFIG_SPIRAM_MEMTEST=y +# CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY is not set +# end of SPI RAM config + +# +# LWIP +# +CONFIG_LWIP_LOCAL_HOSTNAME="UMFeatherS3" +# end of LWIP diff --git a/ports/espressif/boards/unexpectedmaker_pros3/board.c b/ports/espressif/boards/unexpectedmaker_pros3/board.c new file mode 100644 index 0000000000..0432485111 --- /dev/null +++ b/ports/espressif/boards/unexpectedmaker_pros3/board.c @@ -0,0 +1,48 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "supervisor/board.h" +#include "mpconfigboard.h" +#include "shared-bindings/microcontroller/Pin.h" + +void board_init(void) { + // Debug UART + #ifdef DEBUG + common_hal_never_reset_pin(&pin_GPIO43); + common_hal_never_reset_pin(&pin_GPIO44); + #endif /* DEBUG */ +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { + +} + +void board_deinit(void) { +} diff --git a/ports/espressif/boards/unexpectedmaker_pros3/mpconfigboard.h b/ports/espressif/boards/unexpectedmaker_pros3/mpconfigboard.h new file mode 100644 index 0000000000..8c578e5e49 --- /dev/null +++ b/ports/espressif/boards/unexpectedmaker_pros3/mpconfigboard.h @@ -0,0 +1,49 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +// Micropython setup + +#define MICROPY_HW_BOARD_NAME "ProS3" +#define MICROPY_HW_MCU_NAME "ESP32S3" + +#define MICROPY_HW_NEOPIXEL (&pin_GPIO18) +#define CIRCUITPY_STATUS_LED_POWER (&pin_GPIO17) +#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) +#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") + +#define AUTORESET_DELAY_MS 500 + +#define DEFAULT_I2C_BUS_SCL (&pin_GPIO9) +#define DEFAULT_I2C_BUS_SDA (&pin_GPIO8) + +#define DEFAULT_SPI_BUS_SCK (&pin_GPIO36) +#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO35) +#define DEFAULT_SPI_BUS_MISO (&pin_GPIO37) + +#define DEFAULT_UART_BUS_RX (&pin_GPIO44) +#define DEFAULT_UART_BUS_TX (&pin_GPIO43) + +#define DOUBLE_TAP_PIN (&pin_GPIO47) diff --git a/ports/espressif/boards/unexpectedmaker_pros3/mpconfigboard.mk b/ports/espressif/boards/unexpectedmaker_pros3/mpconfigboard.mk new file mode 100644 index 0000000000..3b50324d3c --- /dev/null +++ b/ports/espressif/boards/unexpectedmaker_pros3/mpconfigboard.mk @@ -0,0 +1,22 @@ +USB_VID = 0x303A +USB_PID = 0x80D4 +USB_PRODUCT = "ProS3" +USB_MANUFACTURER = "UnexpectedMaker" + +IDF_TARGET = esp32s3 + +INTERNAL_FLASH_FILESYSTEM = 1 +LONGINT_IMPL = MPZ + +# The default queue depth of 16 overflows on release builds, +# so increase it to 32. +CFLAGS += -DCFG_TUD_TASK_QUEUE_SZ=32 + +CIRCUITPY_ESP_FLASH_MODE=qio +CIRCUITPY_ESP_FLASH_FREQ=80m +CIRCUITPY_ESP_FLASH_SIZE=16MB + +# CIRCUITPY_BITBANG_NEOPIXEL = 1 + +# Include these Python libraries in firmware. +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel diff --git a/ports/espressif/boards/unexpectedmaker_pros3/pins.c b/ports/espressif/boards/unexpectedmaker_pros3/pins.c new file mode 100644 index 0000000000..bc0ca026f3 --- /dev/null +++ b/ports/espressif/boards/unexpectedmaker_pros3/pins.c @@ -0,0 +1,140 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + + { MP_ROM_QSTR(MP_QSTR_IO0), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_GPIO0) }, + + { MP_ROM_QSTR(MP_QSTR_IO1), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_GPIO1) }, + + { MP_ROM_QSTR(MP_QSTR_IO2), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_GPIO2) }, + + { MP_ROM_QSTR(MP_QSTR_IO3), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_GPIO3) }, + + { MP_ROM_QSTR(MP_QSTR_IO4), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_GPIO4) }, + + { MP_ROM_QSTR(MP_QSTR_IO5), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_GPIO5) }, + + { MP_ROM_QSTR(MP_QSTR_IO6), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_GPIO6) }, + + { MP_ROM_QSTR(MP_QSTR_IO7), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_A6), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_GPIO7) }, + + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_IO8), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_A7), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_GPIO8) }, + + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_IO9), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_A8), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_GPIO9) }, + + + { MP_ROM_QSTR(MP_QSTR_IO12), MP_ROM_PTR(&pin_GPIO12) }, + { MP_ROM_QSTR(MP_QSTR_A11), MP_ROM_PTR(&pin_GPIO12) }, + { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_GPIO12) }, + + { MP_ROM_QSTR(MP_QSTR_IO13), MP_ROM_PTR(&pin_GPIO13) }, + { MP_ROM_QSTR(MP_QSTR_A12), MP_ROM_PTR(&pin_GPIO13) }, + { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_GPIO13) }, + + { MP_ROM_QSTR(MP_QSTR_IO14), MP_ROM_PTR(&pin_GPIO14) }, + { MP_ROM_QSTR(MP_QSTR_A13), MP_ROM_PTR(&pin_GPIO14) }, + { MP_ROM_QSTR(MP_QSTR_D14), MP_ROM_PTR(&pin_GPIO14) }, + + { MP_ROM_QSTR(MP_QSTR_IO15), MP_ROM_PTR(&pin_GPIO15) }, + { MP_ROM_QSTR(MP_QSTR_A14), MP_ROM_PTR(&pin_GPIO15) }, + { MP_ROM_QSTR(MP_QSTR_D15), MP_ROM_PTR(&pin_GPIO15) }, + + { MP_ROM_QSTR(MP_QSTR_IO16), MP_ROM_PTR(&pin_GPIO16) }, + { MP_ROM_QSTR(MP_QSTR_A15), MP_ROM_PTR(&pin_GPIO16) }, + { MP_ROM_QSTR(MP_QSTR_D16), MP_ROM_PTR(&pin_GPIO16) }, + + { MP_ROM_QSTR(MP_QSTR_IO21), MP_ROM_PTR(&pin_GPIO21) }, + { MP_ROM_QSTR(MP_QSTR_D21), MP_ROM_PTR(&pin_GPIO21) }, + + { MP_ROM_QSTR(MP_QSTR_IO34), MP_ROM_PTR(&pin_GPIO34) }, + { MP_ROM_QSTR(MP_QSTR_D34), MP_ROM_PTR(&pin_GPIO34) }, + + { MP_ROM_QSTR(MP_QSTR_IO35), MP_ROM_PTR(&pin_GPIO35) }, + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO35) }, + { MP_ROM_QSTR(MP_QSTR_MO), MP_ROM_PTR(&pin_GPIO35) }, + { MP_ROM_QSTR(MP_QSTR_SDO), MP_ROM_PTR(&pin_GPIO35) }, + { MP_ROM_QSTR(MP_QSTR_D35), MP_ROM_PTR(&pin_GPIO35) }, + + { MP_ROM_QSTR(MP_QSTR_IO37), MP_ROM_PTR(&pin_GPIO37) }, + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO37) }, + { MP_ROM_QSTR(MP_QSTR_MI), MP_ROM_PTR(&pin_GPIO37) }, + { MP_ROM_QSTR(MP_QSTR_SDI), MP_ROM_PTR(&pin_GPIO37) }, + { MP_ROM_QSTR(MP_QSTR_D37), MP_ROM_PTR(&pin_GPIO37) }, + + { MP_ROM_QSTR(MP_QSTR_IO36), MP_ROM_PTR(&pin_GPIO36) }, + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO36) }, + { MP_ROM_QSTR(MP_QSTR_D36), MP_ROM_PTR(&pin_GPIO36) }, + + { MP_ROM_QSTR(MP_QSTR_IO38), MP_ROM_PTR(&pin_GPIO38) }, + { MP_ROM_QSTR(MP_QSTR_D38), MP_ROM_PTR(&pin_GPIO38) }, + + { MP_ROM_QSTR(MP_QSTR_IO39), MP_ROM_PTR(&pin_GPIO39) }, + { MP_ROM_QSTR(MP_QSTR_MTCK), MP_ROM_PTR(&pin_GPIO39) }, + { MP_ROM_QSTR(MP_QSTR_D39), MP_ROM_PTR(&pin_GPIO39) }, + + { MP_ROM_QSTR(MP_QSTR_IO40), MP_ROM_PTR(&pin_GPIO40) }, + { MP_ROM_QSTR(MP_QSTR_MTDO), MP_ROM_PTR(&pin_GPIO40) }, + { MP_ROM_QSTR(MP_QSTR_D40), MP_ROM_PTR(&pin_GPIO40) }, + + { MP_ROM_QSTR(MP_QSTR_IO41), MP_ROM_PTR(&pin_GPIO41) }, + { MP_ROM_QSTR(MP_QSTR_MTDI), MP_ROM_PTR(&pin_GPIO41) }, + { MP_ROM_QSTR(MP_QSTR_D41), MP_ROM_PTR(&pin_GPIO41) }, + + { MP_ROM_QSTR(MP_QSTR_IO42), MP_ROM_PTR(&pin_GPIO42) }, + { MP_ROM_QSTR(MP_QSTR_MTMS), MP_ROM_PTR(&pin_GPIO42) }, + { MP_ROM_QSTR(MP_QSTR_D42), MP_ROM_PTR(&pin_GPIO42) }, + + { MP_ROM_QSTR(MP_QSTR_IO43), MP_ROM_PTR(&pin_GPIO43) }, + { MP_ROM_QSTR(MP_QSTR_D43), MP_ROM_PTR(&pin_GPIO43) }, + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO43) }, + + { MP_ROM_QSTR(MP_QSTR_IO44), MP_ROM_PTR(&pin_GPIO44) }, + { MP_ROM_QSTR(MP_QSTR_D44), MP_ROM_PTR(&pin_GPIO44) }, + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO44) }, + + // Battery voltage sense pin + // I really don't know what name to use here. Adafruit use BATTERY & VOLTAGE_MONITOR + // I prefer VBAT or VBAT_SENSE + { MP_ROM_QSTR(MP_QSTR_BATTERY), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_VBAT), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_VBAT_SENSE), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_VOLTAGE_MONITOR), MP_ROM_PTR(&pin_GPIO10) }, + + // 5V present sense pin + { MP_ROM_QSTR(MP_QSTR_VBUS), MP_ROM_PTR(&pin_GPIO33) }, + { MP_ROM_QSTR(MP_QSTR_VBUS_SENSE), MP_ROM_PTR(&pin_GPIO33) }, + + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL_POWER), MP_ROM_PTR(&pin_GPIO17) }, + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO18) }, + + { MP_ROM_QSTR(MP_QSTR_LDO2), MP_ROM_PTR(&pin_GPIO17) }, // Second LDO Enable control + { MP_ROM_QSTR(MP_QSTR_I17), MP_ROM_PTR(&pin_GPIO17) }, // Second LDO Enable control + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/espressif/boards/unexpectedmaker_pros3/sdkconfig b/ports/espressif/boards/unexpectedmaker_pros3/sdkconfig new file mode 100644 index 0000000000..eeb103fb7d --- /dev/null +++ b/ports/espressif/boards/unexpectedmaker_pros3/sdkconfig @@ -0,0 +1,39 @@ +CONFIG_ESP32S3_SPIRAM_SUPPORT=y + +# +# SPI RAM config +# +# CONFIG_SPIRAM_TYPE_AUTO is not set +# CONFIG_SPIRAM_TYPE_ESPPSRAM16 is not set +# CONFIG_SPIRAM_TYPE_ESPPSRAM32 is not set +CONFIG_SPIRAM_TYPE_ESPPSRAM64=y +CONFIG_SPIRAM_SIZE=8388608 + +# +# PSRAM clock and cs IO for ESP32S2 +# +CONFIG_DEFAULT_PSRAM_CLK_IO=30 +CONFIG_DEFAULT_PSRAM_CS_IO=26 +# end of PSRAM clock and cs IO for ESP32S2 + +# CONFIG_SPIRAM_FETCH_INSTRUCTIONS is not set +# CONFIG_SPIRAM_RODATA is not set +CONFIG_SPIRAM_SPEED_80M=y +# CONFIG_SPIRAM_SPEED_40M is not set +# CONFIG_SPIRAM_SPEED_26M is not set +# CONFIG_SPIRAM_SPEED_20M is not set +CONFIG_SPIRAM=y +CONFIG_SPIRAM_BOOT_INIT=y +# CONFIG_SPIRAM_IGNORE_NOTFOUND is not set +CONFIG_SPIRAM_USE_MEMMAP=y +# CONFIG_SPIRAM_USE_CAPS_ALLOC is not set +# CONFIG_SPIRAM_USE_MALLOC is not set +# CONFIG_SPIRAM_MEMTEST=y +# CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY is not set +# end of SPI RAM config + +# +# LWIP +# +CONFIG_LWIP_LOCAL_HOSTNAME="UMProS3" +# end of LWIP diff --git a/ports/espressif/boards/unexpectedmaker_tinys2/board.c b/ports/espressif/boards/unexpectedmaker_tinys2/board.c index a0e399b1ef..0432485111 100644 --- a/ports/espressif/boards/unexpectedmaker_tinys2/board.c +++ b/ports/espressif/boards/unexpectedmaker_tinys2/board.c @@ -29,24 +29,11 @@ #include "shared-bindings/microcontroller/Pin.h" void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); - // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO43); common_hal_never_reset_pin(&pin_GPIO44); #endif /* DEBUG */ - - // SPI Flash and RAM - common_hal_never_reset_pin(&pin_GPIO26); - common_hal_never_reset_pin(&pin_GPIO27); - common_hal_never_reset_pin(&pin_GPIO28); - common_hal_never_reset_pin(&pin_GPIO29); - common_hal_never_reset_pin(&pin_GPIO30); - common_hal_never_reset_pin(&pin_GPIO31); - common_hal_never_reset_pin(&pin_GPIO32); } bool board_requests_safe_mode(void) { diff --git a/ports/espressif/boards/unexpectedmaker_tinys2/sdkconfig b/ports/espressif/boards/unexpectedmaker_tinys2/sdkconfig index 91447cdc2a..8539cb7519 100644 --- a/ports/espressif/boards/unexpectedmaker_tinys2/sdkconfig +++ b/ports/espressif/boards/unexpectedmaker_tinys2/sdkconfig @@ -1,24 +1,24 @@ CONFIG_ESP32S2_SPIRAM_SUPPORT=y - # # SPI RAM config # -# CONFIG_SPIRAM_TYPE_AUTO=y +# CONFIG_SPIRAM_TYPE_AUTO is not set CONFIG_SPIRAM_TYPE_ESPPSRAM16=y # CONFIG_SPIRAM_TYPE_ESPPSRAM32 is not set -# CONFIG_SPIRAM_TYPE_ESPPSRAM64=y +# CONFIG_SPIRAM_TYPE_ESPPSRAM64 is not set CONFIG_SPIRAM_SIZE=2097152 +# end of SPI RAM config +CONFIG_DEFAULT_PSRAM_CLK_IO=30 # # PSRAM clock and cs IO for ESP32S2 # -CONFIG_DEFAULT_PSRAM_CLK_IO=30 CONFIG_DEFAULT_PSRAM_CS_IO=26 # end of PSRAM clock and cs IO for ESP32S2 # CONFIG_SPIRAM_FETCH_INSTRUCTIONS is not set # CONFIG_SPIRAM_RODATA is not set -# CONFIG_SPIRAM_SPEED_80M=y +# CONFIG_SPIRAM_SPEED_80M is not set CONFIG_SPIRAM_SPEED_40M=y # CONFIG_SPIRAM_SPEED_26M is not set # CONFIG_SPIRAM_SPEED_20M is not set @@ -30,8 +30,6 @@ CONFIG_SPIRAM_USE_MEMMAP=y # CONFIG_SPIRAM_USE_MALLOC is not set CONFIG_SPIRAM_MEMTEST=y # CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY is not set -# end of SPI RAM config - # # LWIP # diff --git a/ports/espressif/boards/unexpectedmaker_tinys3/board.c b/ports/espressif/boards/unexpectedmaker_tinys3/board.c new file mode 100644 index 0000000000..0432485111 --- /dev/null +++ b/ports/espressif/boards/unexpectedmaker_tinys3/board.c @@ -0,0 +1,48 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "supervisor/board.h" +#include "mpconfigboard.h" +#include "shared-bindings/microcontroller/Pin.h" + +void board_init(void) { + // Debug UART + #ifdef DEBUG + common_hal_never_reset_pin(&pin_GPIO43); + common_hal_never_reset_pin(&pin_GPIO44); + #endif /* DEBUG */ +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { + +} + +void board_deinit(void) { +} diff --git a/ports/espressif/boards/unexpectedmaker_tinys3/mpconfigboard.h b/ports/espressif/boards/unexpectedmaker_tinys3/mpconfigboard.h new file mode 100644 index 0000000000..c4853f4709 --- /dev/null +++ b/ports/espressif/boards/unexpectedmaker_tinys3/mpconfigboard.h @@ -0,0 +1,49 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +// Micropython setup + +#define MICROPY_HW_BOARD_NAME "TinyS3" +#define MICROPY_HW_MCU_NAME "ESP32S3" + +#define MICROPY_HW_NEOPIXEL (&pin_GPIO18) +#define CIRCUITPY_STATUS_LED_POWER (&pin_GPIO17) +#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) +#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") + +#define AUTORESET_DELAY_MS 500 + +#define DEFAULT_I2C_BUS_SCL (&pin_GPIO9) +#define DEFAULT_I2C_BUS_SDA (&pin_GPIO8) + +#define DEFAULT_SPI_BUS_SCK (&pin_GPIO36) +#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO35) +#define DEFAULT_SPI_BUS_MISO (&pin_GPIO37) + +#define DEFAULT_UART_BUS_RX (&pin_GPIO44) +#define DEFAULT_UART_BUS_TX (&pin_GPIO43) + +#define DOUBLE_TAP_PIN (&pin_GPIO47) diff --git a/ports/espressif/boards/unexpectedmaker_tinys3/mpconfigboard.mk b/ports/espressif/boards/unexpectedmaker_tinys3/mpconfigboard.mk new file mode 100644 index 0000000000..32a711c257 --- /dev/null +++ b/ports/espressif/boards/unexpectedmaker_tinys3/mpconfigboard.mk @@ -0,0 +1,24 @@ +USB_VID = 0x303A +USB_PID = 0x80D1 +USB_PRODUCT = "TinyS3" +USB_MANUFACTURER = "UnexpectedMaker" + +IDF_TARGET = esp32s3 + +INTERNAL_FLASH_FILESYSTEM = 1 +LONGINT_IMPL = MPZ + +# The default queue depth of 16 overflows on release builds, +# so increase it to 32. +CFLAGS += -DCFG_TUD_TASK_QUEUE_SZ=32 + +CIRCUITPY_ESP_FLASH_MODE=dio +CIRCUITPY_ESP_FLASH_FREQ=80m +CIRCUITPY_ESP_FLASH_SIZE=8MB + +# CIRCUITPY_BITBANG_NEOPIXEL = 1 + +CIRCUITPY_STAGE = 1 + +# Include these Python libraries in firmware. +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel diff --git a/ports/espressif/boards/unexpectedmaker_tinys3/pins.c b/ports/espressif/boards/unexpectedmaker_tinys3/pins.c new file mode 100644 index 0000000000..fcce90494b --- /dev/null +++ b/ports/espressif/boards/unexpectedmaker_tinys3/pins.c @@ -0,0 +1,96 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + + { MP_ROM_QSTR(MP_QSTR_IO0), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_GPIO0) }, + + { MP_ROM_QSTR(MP_QSTR_IO1), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_GPIO1) }, + + { MP_ROM_QSTR(MP_QSTR_IO2), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_GPIO2) }, + + { MP_ROM_QSTR(MP_QSTR_IO3), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_GPIO3) }, + + { MP_ROM_QSTR(MP_QSTR_IO4), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_GPIO4) }, + + { MP_ROM_QSTR(MP_QSTR_IO5), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_GPIO5) }, + + { MP_ROM_QSTR(MP_QSTR_IO6), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_GPIO6) }, + + { MP_ROM_QSTR(MP_QSTR_IO7), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_A6), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_GPIO7) }, + + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_IO8), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_A7), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_GPIO8) }, + + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_IO9), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_A8), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_GPIO9) }, + + { MP_ROM_QSTR(MP_QSTR_IO21), MP_ROM_PTR(&pin_GPIO21) }, + { MP_ROM_QSTR(MP_QSTR_D21), MP_ROM_PTR(&pin_GPIO21) }, + + { MP_ROM_QSTR(MP_QSTR_IO34), MP_ROM_PTR(&pin_GPIO34) }, + { MP_ROM_QSTR(MP_QSTR_D34), MP_ROM_PTR(&pin_GPIO34) }, + + { MP_ROM_QSTR(MP_QSTR_IO35), MP_ROM_PTR(&pin_GPIO35) }, + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO35) }, + { MP_ROM_QSTR(MP_QSTR_MO), MP_ROM_PTR(&pin_GPIO35) }, + { MP_ROM_QSTR(MP_QSTR_SDO), MP_ROM_PTR(&pin_GPIO35) }, + { MP_ROM_QSTR(MP_QSTR_D35), MP_ROM_PTR(&pin_GPIO35) }, + + { MP_ROM_QSTR(MP_QSTR_IO37), MP_ROM_PTR(&pin_GPIO37) }, + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO37) }, + { MP_ROM_QSTR(MP_QSTR_MI), MP_ROM_PTR(&pin_GPIO37) }, + { MP_ROM_QSTR(MP_QSTR_SDI), MP_ROM_PTR(&pin_GPIO37) }, + { MP_ROM_QSTR(MP_QSTR_D37), MP_ROM_PTR(&pin_GPIO37) }, + + { MP_ROM_QSTR(MP_QSTR_IO36), MP_ROM_PTR(&pin_GPIO36) }, + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO36) }, + { MP_ROM_QSTR(MP_QSTR_D36), MP_ROM_PTR(&pin_GPIO36) }, + + { MP_ROM_QSTR(MP_QSTR_IO43), MP_ROM_PTR(&pin_GPIO43) }, + { MP_ROM_QSTR(MP_QSTR_D43), MP_ROM_PTR(&pin_GPIO43) }, + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO43) }, + + { MP_ROM_QSTR(MP_QSTR_IO44), MP_ROM_PTR(&pin_GPIO44) }, + { MP_ROM_QSTR(MP_QSTR_D44), MP_ROM_PTR(&pin_GPIO44) }, + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO44) }, + + // Battery voltage sense pin + // I really don't know what name to use here. Adafruit use BATTERY & VOLTAGE_MONITOR + // I prefer VBAT or VBAT_SENSE + { MP_ROM_QSTR(MP_QSTR_BATTERY), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_VBAT), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_VBAT_SENSE), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_VOLTAGE_MONITOR), MP_ROM_PTR(&pin_GPIO10) }, + + // 5V present sense pin + { MP_ROM_QSTR(MP_QSTR_VBUS), MP_ROM_PTR(&pin_GPIO33) }, + { MP_ROM_QSTR(MP_QSTR_VBUS_SENSE), MP_ROM_PTR(&pin_GPIO33) }, + + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL_POWER), MP_ROM_PTR(&pin_GPIO17) }, + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO18) }, + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/espressif/boards/unexpectedmaker_tinys3/sdkconfig b/ports/espressif/boards/unexpectedmaker_tinys3/sdkconfig new file mode 100644 index 0000000000..0ac438450d --- /dev/null +++ b/ports/espressif/boards/unexpectedmaker_tinys3/sdkconfig @@ -0,0 +1,41 @@ +CONFIG_ESP32S3_SPIRAM_SUPPORT=y + +# +# SPI RAM config +# +# CONFIG_SPIRAM_MODE_OCT is not set +CONFIG_SPIRAM_MODE_QUAD=y +# CONFIG_SPIRAM_TYPE_AUTO is not set +# CONFIG_SPIRAM_TYPE_ESPPSRAM16 is not set +# CONFIG_SPIRAM_TYPE_ESPPSRAM32 is not set +CONFIG_SPIRAM_TYPE_ESPPSRAM64=y +CONFIG_SPIRAM_SIZE=8388608 + +# +# PSRAM clock and cs IO for ESP32S3 +# +CONFIG_DEFAULT_PSRAM_CLK_IO=30 +CONFIG_DEFAULT_PSRAM_CS_IO=26 +# end of PSRAM clock and cs IO for ESP32S3 + +# CONFIG_SPIRAM_FETCH_INSTRUCTIONS is not set +# CONFIG_SPIRAM_RODATA is not set +CONFIG_SPIRAM_SPEED_80M=y +# CONFIG_SPIRAM_SPEED_40M is not set +# CONFIG_SPIRAM_SPEED_26M is not set +# CONFIG_SPIRAM_SPEED_20M is not set +CONFIG_SPIRAM=y +CONFIG_SPIRAM_BOOT_INIT=y +# CONFIG_SPIRAM_IGNORE_NOTFOUND is not set +CONFIG_SPIRAM_USE_MEMMAP=y +# CONFIG_SPIRAM_USE_CAPS_ALLOC is not set +# CONFIG_SPIRAM_USE_MALLOC is not set +# CONFIG_SPIRAM_MEMTEST=y +# CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY is not set +# end of SPI RAM config + +# +# LWIP +# +CONFIG_LWIP_LOCAL_HOSTNAME="UMTinyS3" +# end of LWIP diff --git a/ports/espressif/common-hal/_bleio/Adapter.c b/ports/espressif/common-hal/_bleio/Adapter.c new file mode 100644 index 0000000000..d72f9dbf02 --- /dev/null +++ b/ports/espressif/common-hal/_bleio/Adapter.c @@ -0,0 +1,667 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2018 Dan Halbert for Adafruit Industries + * Copyright (c) 2016 Glenn Ruben Bakke + * Copyright (c) 2018 Artur Pacholec + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include +#include +#include +#include + +#include "py/gc.h" +#include "py/objstr.h" +#include "py/runtime.h" +#include "supervisor/shared/bluetooth/bluetooth.h" +#include "supervisor/shared/safe_mode.h" +#include "supervisor/shared/tick.h" +#include "supervisor/usb.h" +#include "shared-bindings/_bleio/__init__.h" +#include "shared-bindings/_bleio/Adapter.h" +#include "shared-bindings/_bleio/Address.h" +#include "shared-bindings/nvm/ByteArray.h" +#include "shared-bindings/_bleio/Connection.h" +#include "shared-bindings/_bleio/ScanEntry.h" +#include "shared-bindings/time/__init__.h" + +#include "controller/ble_ll_adv.h" +#include "nimble/hci_common.h" +#include "nimble/nimble_port.h" +#include "nimble/nimble_port_freertos.h" +#include "host/ble_gap.h" +#include "host/util/util.h" +#include "services/gap/ble_svc_gap.h" + +#include "common-hal/_bleio/Connection.h" + +#include "esp_bt.h" +#include "esp_nimble_hci.h" + +bleio_connection_internal_t bleio_connections[BLEIO_TOTAL_CONNECTION_COUNT]; + +// static void bluetooth_adapter_background(void *data) { +// supervisor_bluetooth_background(); +// bleio_background(); +// } + +bool ble_active = false; + +static void nimble_host_task(void *param) { + nimble_port_run(); + nimble_port_freertos_deinit(); +} + +static TaskHandle_t cp_task = NULL; + +static void _on_sync(void) { + int rc = ble_hs_util_ensure_addr(0); + assert(rc == 0); + + xTaskNotifyGive(cp_task); +} + +void common_hal_bleio_adapter_set_enabled(bleio_adapter_obj_t *self, bool enabled) { + const bool is_enabled = common_hal_bleio_adapter_get_enabled(self); + + // Don't enable or disable twice + if (is_enabled == enabled) { + return; + } + + if (enabled) { + esp_nimble_hci_and_controller_init(); + nimble_port_init(); + // ble_hs_cfg.reset_cb = blecent_on_reset; + ble_hs_cfg.sync_cb = _on_sync; + // ble_hs_cfg.store_status_cb = ble_store_util_status_rr; + ble_svc_gap_device_name_set("CIRCUITPY"); + + // Clear all of the internal connection objects. + for (size_t i = 0; i < BLEIO_TOTAL_CONNECTION_COUNT; i++) { + bleio_connection_internal_t *connection = &bleio_connections[i]; + // Reset connection. + connection->conn_handle = BLEIO_HANDLE_INVALID; + } + + cp_task = xTaskGetCurrentTaskHandle(); + + nimble_port_freertos_init(nimble_host_task); + // Wait for sync. + ulTaskNotifyTake(pdTRUE, pdMS_TO_TICKS(200)); + } else { + nimble_port_stop(); + } +} + +bool common_hal_bleio_adapter_get_enabled(bleio_adapter_obj_t *self) { + return xTaskGetHandle("ble") != NULL; +} + +bleio_address_obj_t *common_hal_bleio_adapter_get_address(bleio_adapter_obj_t *self) { + uint8_t address_bytes[6]; + uint8_t address_type = BLE_ADDR_RANDOM; + ble_hs_id_infer_auto(0, &address_type); + int result = ble_hs_id_copy_addr(address_type, address_bytes, NULL); + if (result != 0) { + return NULL; + } + + bleio_address_obj_t *address = m_new_obj(bleio_address_obj_t); + address->base.type = &bleio_address_type; + common_hal_bleio_address_construct(address, address_bytes, BLEIO_ADDRESS_TYPE_RANDOM_STATIC); + return address; +} + +bool common_hal_bleio_adapter_set_address(bleio_adapter_obj_t *self, bleio_address_obj_t *address) { + if (address->type != BLEIO_ADDRESS_TYPE_RANDOM_STATIC) { + return false; + } + mp_buffer_info_t bufinfo; + if (!mp_get_buffer(address->bytes, &bufinfo, MP_BUFFER_READ)) { + return false; + } + int result = ble_hs_id_set_rnd(bufinfo.buf); + return result == 0; +} + +mp_obj_str_t *common_hal_bleio_adapter_get_name(bleio_adapter_obj_t *self) { + const char *name = ble_svc_gap_device_name(); + + return mp_obj_new_str(name, strlen(name)); +} + +void common_hal_bleio_adapter_set_name(bleio_adapter_obj_t *self, const char *name) { + ble_svc_gap_device_name_set(name); +} + +static int _scan_event(struct ble_gap_event *event, void *scan_results_in) { + bleio_scanresults_obj_t *scan_results = (bleio_scanresults_obj_t *)scan_results_in; + + if (event->type == BLE_GAP_EVENT_DISC_COMPLETE) { + shared_module_bleio_scanresults_set_done(scan_results, true); + return 0; + } + + if (event->type != BLE_GAP_EVENT_DISC && event->type != BLE_GAP_EVENT_EXT_DISC) { + #if CIRCUITPY_VERBOSE_BLE + mp_printf(&mp_plat_print, "Unsupported scan event %d\n", event->type); + #endif + return 0; + } + + if (event->type == BLE_GAP_EVENT_DISC) { + // Legacy advertisement + struct ble_gap_disc_desc *disc = &event->disc; + bool connectable = disc->event_type == BLE_HCI_ADV_RPT_EVTYPE_ADV_IND || + disc->event_type == BLE_HCI_ADV_RPT_EVTYPE_DIR_IND; + shared_module_bleio_scanresults_append(scan_results, + supervisor_ticks_ms64(), + connectable, + disc->event_type == BLE_HCI_ADV_RPT_EVTYPE_SCAN_RSP, + disc->rssi, + disc->addr.val, + disc->addr.type, + disc->data, + disc->length_data); + } else { + // Extended advertisement + struct ble_gap_ext_disc_desc *disc = &event->ext_disc; + shared_module_bleio_scanresults_append(scan_results, + supervisor_ticks_ms64(), + (disc->props & BLE_HCI_ADV_CONN_MASK) != 0, + (disc->props & BLE_HCI_ADV_SCAN_MASK) != 0, + disc->rssi, + disc->addr.val, + disc->addr.type, + disc->data, + disc->length_data); + } + + return 0; +} + +mp_obj_t common_hal_bleio_adapter_start_scan(bleio_adapter_obj_t *self, uint8_t *prefixes, + size_t prefix_length, bool extended, mp_int_t buffer_size, mp_float_t timeout, + mp_float_t interval, mp_float_t window, mp_int_t minimum_rssi, bool active) { + if (self->scan_results != NULL) { + if (!shared_module_bleio_scanresults_get_done(self->scan_results)) { + mp_raise_bleio_BluetoothError(translate("Scan already in progess. Stop with stop_scan.")); + } + self->scan_results = NULL; + } + + self->scan_results = shared_module_bleio_new_scanresults(buffer_size, prefixes, prefix_length, minimum_rssi); + // size_t max_packet_size = extended ? BLE_HCI_MAX_EXT_ADV_DATA_LEN : BLE_HCI_MAX_ADV_DATA_LEN; + + uint8_t own_addr_type; + struct ble_gap_disc_params disc_params; + + /* Figure out address to use while advertising (no privacy for now) */ + int privacy = 0; + CHECK_NIMBLE_ERROR(ble_hs_id_infer_auto(privacy, &own_addr_type)); + + disc_params.filter_duplicates = 0; + disc_params.passive = !active; + disc_params.itvl = interval / 0.625; + disc_params.window = window / 0.625; + disc_params.filter_policy = 0; + disc_params.limited = 0; + + size_t duration_ms = timeout * 1000; + if (duration_ms == 0) { + duration_ms = BLE_HS_FOREVER; + } + + CHECK_NIMBLE_ERROR(ble_gap_disc(own_addr_type, duration_ms, &disc_params, + _scan_event, self->scan_results)); + + return MP_OBJ_FROM_PTR(self->scan_results); +} + +void common_hal_bleio_adapter_stop_scan(bleio_adapter_obj_t *self) { + if (self->scan_results == NULL) { + return; + } + ble_gap_disc_cancel(); + shared_module_bleio_scanresults_set_done(self->scan_results, true); + self->scan_results = NULL; +} + +STATIC void _convert_address(const bleio_address_obj_t *address, ble_addr_t *nimble_address) { + nimble_address->type = address->type; + mp_buffer_info_t address_buf_info; + mp_get_buffer_raise(address->bytes, &address_buf_info, MP_BUFFER_READ); + memcpy(nimble_address->val, (uint8_t *)address_buf_info.buf, NUM_BLEIO_ADDRESS_BYTES); +} + +STATIC int _mtu_reply(uint16_t conn_handle, + const struct ble_gatt_error *error, + uint16_t mtu, void *arg) { + bleio_connection_internal_t *connection = (bleio_connection_internal_t *)arg; + if (conn_handle != connection->conn_handle || error->status != 0) { + return 0; + } + connection->mtu = mtu; + return 0; +} + +STATIC void _new_connection(uint16_t conn_handle) { + // Set the tx_power for the connection higher than the advertisement. + esp_ble_tx_power_set(conn_handle, ESP_PWR_LVL_N0); + + + // Find an empty connection. One must always be available because the SD has the same + // total connection limit. + bleio_connection_internal_t *connection; + for (size_t i = 0; i < BLEIO_TOTAL_CONNECTION_COUNT; i++) { + connection = &bleio_connections[i]; + if (connection->conn_handle == BLEIO_HANDLE_INVALID) { + break; + } + } + connection->conn_handle = conn_handle; + connection->connection_obj = mp_const_none; + connection->pair_status = PAIR_NOT_PAIRED; + connection->mtu = 0; + + ble_gattc_exchange_mtu(conn_handle, _mtu_reply, connection); + + // Change the callback for the connection. + ble_gap_set_event_cb(conn_handle, bleio_connection_event_cb, connection); +} + +static int _connect_event(struct ble_gap_event *event, void *self_in) { + bleio_adapter_obj_t *self = (bleio_adapter_obj_t *)self_in; + + #if CIRCUITPY_VERBOSE_BLE + mp_printf(&mp_plat_print, "Connect event: %d\n", event->type); + #endif + switch (event->type) { + case BLE_GAP_EVENT_CONNECT: + if (event->connect.status == 0) { + _new_connection(event->connect.conn_handle); + // Set connections objs back to NULL since we have a new + // connection and need a new tuple. + self->connection_objs = NULL; + xTaskNotify(cp_task, event->connect.conn_handle, eSetValueWithOverwrite); + } else { + xTaskNotify(cp_task, -event->connect.status, eSetValueWithOverwrite); + } + break; + + default: + #if CIRCUITPY_VERBOSE_BLE + // For debugging. + mp_printf(&mp_plat_print, "Unhandled connect event: %d\n", event->type); + #endif + break; + } + return 0; +} + +mp_obj_t common_hal_bleio_adapter_connect(bleio_adapter_obj_t *self, bleio_address_obj_t *address, mp_float_t timeout) { + // Stop any active scan. + if (self->scan_results != NULL) { + common_hal_bleio_adapter_stop_scan(self); + } + + struct ble_gap_conn_params conn_params = { + .scan_itvl = MSEC_TO_UNITS(100, UNIT_0_625_MS), + .scan_window = MSEC_TO_UNITS(100, UNIT_0_625_MS), + .itvl_min = MSEC_TO_UNITS(15, UNIT_1_25_MS), + .itvl_max = MSEC_TO_UNITS(300, UNIT_1_25_MS), + .latency = 0, + .supervision_timeout = MSEC_TO_UNITS(4000, UNIT_10_MS), + .min_ce_len = BLE_GAP_INITIAL_CONN_MIN_CE_LEN, + .max_ce_len = BLE_GAP_INITIAL_CONN_MAX_CE_LEN + }; + + uint8_t own_addr_type; + // TODO: Use a resolvable address if the peer has our key. + CHECK_NIMBLE_ERROR(ble_hs_id_infer_auto(false, &own_addr_type)); + + ble_addr_t addr; + _convert_address(address, &addr); + + cp_task = xTaskGetCurrentTaskHandle(); + // Make sure we don't have a pending notification from a previous time. This + // can happen if a previous wait timed out before the notification was given. + xTaskNotifyStateClear(cp_task); + CHECK_NIMBLE_ERROR( + ble_gap_connect(own_addr_type, &addr, + SEC_TO_UNITS(timeout, UNIT_1_MS) + 0.5f, + &conn_params, + _connect_event, self)); + + int error_code; + CHECK_NOTIFY(xTaskNotifyWait(0, 0, (uint32_t *)&error_code, 200)); + // Negative values are error codes, connection handle otherwise. + if (error_code < 0) { + CHECK_BLE_ERROR(-error_code); + } + uint16_t conn_handle = error_code; + + // TODO: If we have keys, then try and encrypt the connection. + + // TODO: Negotiate for better PHY and data lengths since we are the central. These are + // nice-to-haves so ignore any errors. + + // Make the connection object and return it. + for (size_t i = 0; i < BLEIO_TOTAL_CONNECTION_COUNT; i++) { + bleio_connection_internal_t *connection = &bleio_connections[i]; + if (connection->conn_handle == conn_handle) { + connection->is_central = true; + return bleio_connection_new_from_internal(connection); + } + } + + mp_raise_bleio_BluetoothError(translate("Failed to connect: internal error")); + + return mp_const_none; +} + +typedef struct { + struct os_mbuf mbuf; + struct os_mbuf_pkthdr hdr; +} os_mbuf_t; + +STATIC void _wrap_in_mbuf(const uint8_t *data, uint16_t len, os_mbuf_t *buf) { + struct os_mbuf *mbuf = &buf->mbuf; + mbuf->om_data = (uint8_t *)data, + mbuf->om_flags = 0; + mbuf->om_pkthdr_len = 0; + mbuf->om_len = len; + mbuf->om_next.sle_next = NULL; + + buf->hdr.omp_len = len; + + // Setting the pool to NULL will cause frees to fail. Hopefully that failure + // is ignored. + mbuf->om_omp = NULL; +} + +static int _advertising_event(struct ble_gap_event *event, void *self_in) { + bleio_adapter_obj_t *self = (bleio_adapter_obj_t *)self_in; + + #if CIRCUITPY_VERBOSE_BLE + mp_printf(&mp_plat_print, "Advertising event: %d\n", event->type); + #endif + switch (event->type) { + case BLE_GAP_EVENT_CONNECT: + // Spurious connect events can happen. + break; + + case BLE_GAP_EVENT_ADV_COMPLETE: + if (event->adv_complete.reason == NIMBLE_OK) { + _new_connection(event->adv_complete.conn_handle); + // Set connections objs back to NULL since we have a new + // connection and need a new tuple. + self->connection_objs = NULL; + } + // Other statuses indicate timeout or preemption. + common_hal_bleio_adapter_stop_advertising(self); + break; + + default: + #if CIRCUITPY_VERBOSE_BLE + // For debugging. + mp_printf(&mp_plat_print, "Unhandled advertising event: %d\n", event->type); + #endif + break; + } + return 0; +} + +uint32_t _common_hal_bleio_adapter_start_advertising(bleio_adapter_obj_t *self, + bool connectable, bool anonymous, uint32_t timeout, float interval, + const uint8_t *advertising_data, uint16_t advertising_data_len, + const uint8_t *scan_response_data, uint16_t scan_response_data_len, + mp_int_t tx_power, const bleio_address_obj_t *directed_to) { + + if (ble_gap_adv_active() && !self->user_advertising) { + return BLE_HS_EBUSY; + } + + uint32_t rc; + bool extended = advertising_data_len > BLE_ADV_LEGACY_DATA_MAX_LEN || + scan_response_data_len > BLE_ADV_LEGACY_DATA_MAX_LEN; + + ble_addr_t peer; + if (directed_to != NULL) { + _convert_address(directed_to, &peer); + } + + uint8_t own_addr_type; + // Anonymous addresses are still resolvable. (Following what the NRF + // implementation does.) + rc = ble_hs_id_infer_auto(anonymous, &own_addr_type); + if (rc != NIMBLE_OK) { + return rc; + } + + bool high_duty_directed = directed_to != NULL && interval <= 3.5 && timeout <= 1.3; + + struct ble_gap_ext_adv_params adv_params = { + .connectable = connectable, + .scannable = scan_response_data_len > 0, + .directed = directed_to != NULL, + .high_duty_directed = high_duty_directed, + .legacy_pdu = !extended, + .anonymous = anonymous, + .include_tx_power = extended, + .scan_req_notif = false, + .itvl_min = SEC_TO_UNITS(interval, UNIT_0_625_MS) + 0.5f, + .itvl_max = SEC_TO_UNITS(interval, UNIT_0_625_MS) + 0.5f, + .channel_map = 0, + .own_addr_type = own_addr_type, + .peer = peer, + .filter_policy = BLE_HCI_CONN_FILT_NO_WL, + .primary_phy = BLE_HCI_LE_PHY_1M, + .secondary_phy = BLE_HCI_LE_PHY_1M, + .tx_power = tx_power, + .sid = 0, + }; + + // Configure must come before setting payloads. + rc = ble_gap_ext_adv_configure(0, + &adv_params, + NULL, + _advertising_event, self); + if (rc != NIMBLE_OK) { + return rc; + } + + os_mbuf_t buf; + _wrap_in_mbuf(advertising_data, advertising_data_len, &buf); + // This copies the advertising data into buffers to send to the controller. + // Therefore, we don't need to worry about the lifetime of our copy. + rc = ble_gap_ext_adv_set_data(0, &buf.mbuf); + if (rc != NIMBLE_OK) { + return rc; + } + + if (scan_response_data_len > 0) { + _wrap_in_mbuf(scan_response_data, scan_response_data_len, &buf); + // This copies the advertising data into buffers to send to the controller. + // Therefore, we don't need to worry about the lifetime of our copy. + rc = ble_gap_ext_adv_rsp_set_data(0, &buf.mbuf); + if (rc != NIMBLE_OK) { + return rc; + } + } + + rc = ble_gap_ext_adv_start(0, timeout / 10, 0); + if (rc != NIMBLE_OK) { + return rc; + } + + return NIMBLE_OK; +} + +STATIC void check_data_fit(size_t data_len, bool connectable) { + if (data_len > MYNEWT_VAL(BLE_EXT_ADV_MAX_SIZE) || + (connectable && data_len > MYNEWT_VAL(BLE_EXT_ADV_MAX_SIZE))) { + mp_raise_ValueError(translate("Data too large for advertisement packet")); + } +} + +void common_hal_bleio_adapter_start_advertising(bleio_adapter_obj_t *self, bool connectable, + bool anonymous, uint32_t timeout, mp_float_t interval, + mp_buffer_info_t *advertising_data_bufinfo, mp_buffer_info_t *scan_response_data_bufinfo, + mp_int_t tx_power, const bleio_address_obj_t *directed_to) { + if (self->user_advertising) { + mp_raise_bleio_BluetoothError(translate("Already advertising.")); + } else { + // If the user isn't advertising, then the background is. So, stop the + // background advertising so the user can. + common_hal_bleio_adapter_stop_advertising(self); + } + // interval value has already been validated. + + check_data_fit(advertising_data_bufinfo->len, connectable); + check_data_fit(scan_response_data_bufinfo->len, connectable); + + if (advertising_data_bufinfo->len > 31 && scan_response_data_bufinfo->len > 0) { + mp_raise_bleio_BluetoothError(translate("Extended advertisements with scan response not supported.")); + } + + + if (advertising_data_bufinfo->len > 0 && directed_to != NULL) { + mp_raise_bleio_BluetoothError(translate("Data not supported with directed advertising")); + } + + if (anonymous) { + mp_raise_NotImplementedError(NULL); + } + + if (!timeout) { + timeout = BLE_HS_FOREVER; + } else if (timeout > INT32_MAX) { + mp_raise_bleio_BluetoothError(translate("Timeout is too long: Maximum timeout length is %d seconds"), + INT32_MAX / 1000); + } + + CHECK_NIMBLE_ERROR(_common_hal_bleio_adapter_start_advertising(self, connectable, anonymous, timeout, interval, + advertising_data_bufinfo->buf, + advertising_data_bufinfo->len, + scan_response_data_bufinfo->buf, + scan_response_data_bufinfo->len, + tx_power, + directed_to)); + self->user_advertising = true; +} + +void common_hal_bleio_adapter_stop_advertising(bleio_adapter_obj_t *self) { + int err_code = ble_gap_ext_adv_stop(0); + self->user_advertising = false; + + if ((err_code != NIMBLE_OK) && + (err_code != BLE_HS_EALREADY) && + (err_code != BLE_HS_EINVAL)) { + CHECK_NIMBLE_ERROR(err_code); + } +} + +bool common_hal_bleio_adapter_get_advertising(bleio_adapter_obj_t *self) { + return ble_gap_adv_active(); +} + +bool common_hal_bleio_adapter_get_connected(bleio_adapter_obj_t *self) { + for (size_t i = 0; i < BLEIO_TOTAL_CONNECTION_COUNT; i++) { + bleio_connection_internal_t *connection = &bleio_connections[i]; + if (connection->conn_handle != BLEIO_HANDLE_INVALID) { + return true; + } + } + return false; +} + +mp_obj_t common_hal_bleio_adapter_get_connections(bleio_adapter_obj_t *self) { + if (self->connection_objs != NULL) { + return self->connection_objs; + } + size_t total_connected = 0; + mp_obj_t items[BLEIO_TOTAL_CONNECTION_COUNT]; + for (size_t i = 0; i < BLEIO_TOTAL_CONNECTION_COUNT; i++) { + bleio_connection_internal_t *connection = &bleio_connections[i]; + if (connection->conn_handle != BLEIO_HANDLE_INVALID) { + if (connection->connection_obj == mp_const_none) { + connection->connection_obj = bleio_connection_new_from_internal(connection); + } + items[total_connected] = connection->connection_obj; + total_connected++; + } + } + self->connection_objs = mp_obj_new_tuple(total_connected, items); + return self->connection_objs; +} + +void common_hal_bleio_adapter_erase_bonding(bleio_adapter_obj_t *self) { + mp_raise_NotImplementedError(NULL); + // bonding_erase_storage(); +} + +bool common_hal_bleio_adapter_is_bonded_to_central(bleio_adapter_obj_t *self) { + mp_raise_NotImplementedError(NULL); + // return bonding_peripheral_bond_count() > 0; + return false; +} + +void bleio_adapter_gc_collect(bleio_adapter_obj_t *adapter) { + // We divide by size_t so that we can scan each 32-bit aligned value to see + // if it is a pointer. This allows us to change the structs without worrying + // about collecting new pointers. + gc_collect_root((void **)adapter, sizeof(bleio_adapter_obj_t) / (sizeof(size_t))); + gc_collect_root((void **)bleio_connections, sizeof(bleio_connections) / (sizeof(size_t))); +} + +void bleio_adapter_reset(bleio_adapter_obj_t *adapter) { + common_hal_bleio_adapter_stop_scan(adapter); + if (common_hal_bleio_adapter_get_advertising(adapter)) { + common_hal_bleio_adapter_stop_advertising(adapter); + } + + adapter->connection_objs = NULL; + for (size_t i = 0; i < BLEIO_TOTAL_CONNECTION_COUNT; i++) { + bleio_connection_internal_t *connection = &bleio_connections[i]; + // Disconnect all connections cleanly. + if (connection->conn_handle != BLEIO_HANDLE_INVALID) { + common_hal_bleio_connection_disconnect(connection); + } + connection->connection_obj = mp_const_none; + } + + // Wait up to 125 ms (128 ticks) for disconnect to complete. This should be + // greater than most connection intervals. + bool any_connected = false; + uint64_t start_ticks = supervisor_ticks_ms64(); + while (any_connected && supervisor_ticks_ms64() - start_ticks < 128) { + any_connected = false; + for (size_t i = 0; i < BLEIO_TOTAL_CONNECTION_COUNT; i++) { + bleio_connection_internal_t *connection = &bleio_connections[i]; + any_connected |= connection->conn_handle != BLEIO_HANDLE_INVALID; + } + } +} diff --git a/ports/espressif/common-hal/_bleio/Adapter.h b/ports/espressif/common-hal/_bleio/Adapter.h new file mode 100644 index 0000000000..3534c79809 --- /dev/null +++ b/ports/espressif/common-hal/_bleio/Adapter.h @@ -0,0 +1,60 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2018 Dan Halbert for Adafruit Industries + * Copyright (c) 2018 Artur Pacholec + * Copyright (c) 2016 Glenn Ruben Bakke + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_ADAPTER_H +#define MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_ADAPTER_H + +#include "py/obj.h" +#include "py/objtuple.h" + +#include "shared-bindings/_bleio/Connection.h" +#include "shared-bindings/_bleio/ScanResults.h" + +#include "supervisor/background_callback.h" + +#ifndef BLEIO_TOTAL_CONNECTION_COUNT +#define BLEIO_TOTAL_CONNECTION_COUNT 5 +#endif + +#define BLEIO_HANDLE_INVALID 0xffff + +extern bleio_connection_internal_t bleio_connections[BLEIO_TOTAL_CONNECTION_COUNT]; + +typedef struct { + mp_obj_base_t base; + bleio_scanresults_obj_t *scan_results; + mp_obj_t name; + mp_obj_tuple_t *connection_objs; + background_callback_t background_callback; + bool user_advertising; +} bleio_adapter_obj_t; + +void bleio_adapter_gc_collect(bleio_adapter_obj_t *adapter); +void bleio_adapter_reset(bleio_adapter_obj_t *adapter); + +#endif // MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_ADAPTER_H diff --git a/ports/espressif/common-hal/_bleio/Attribute.c b/ports/espressif/common-hal/_bleio/Attribute.c new file mode 100644 index 0000000000..179a3b58aa --- /dev/null +++ b/ports/espressif/common-hal/_bleio/Attribute.c @@ -0,0 +1,29 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Dan Halbert for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "shared-bindings/_bleio/Attribute.h" + +// Convert a _bleio security mode to a ble_gap_conn_sec_mode_t setting. diff --git a/ports/espressif/common-hal/_bleio/Attribute.h b/ports/espressif/common-hal/_bleio/Attribute.h new file mode 100644 index 0000000000..4612b6c6dd --- /dev/null +++ b/ports/espressif/common-hal/_bleio/Attribute.h @@ -0,0 +1,32 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2018 Dan Halbert for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_ATTRIBUTE_H +#define MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_ATTRIBUTE_H + +#include "shared-module/_bleio/Attribute.h" + +#endif // MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_ATTRIBUTE_H diff --git a/ports/espressif/common-hal/_bleio/Characteristic.c b/ports/espressif/common-hal/_bleio/Characteristic.c new file mode 100644 index 0000000000..0344e38df1 --- /dev/null +++ b/ports/espressif/common-hal/_bleio/Characteristic.c @@ -0,0 +1,237 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) Dan Halbert for Adafruit Industries + * Copyright (c) 2018 Artur Pacholec + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include + +#include "py/runtime.h" + +#include "shared-bindings/_bleio/__init__.h" +#include "shared-bindings/_bleio/Characteristic.h" +#include "shared-bindings/_bleio/Descriptor.h" +#include "shared-bindings/_bleio/Service.h" + +#include "common-hal/_bleio/Adapter.h" +// #include "common-hal/_bleio/bonding.h" + +void common_hal_bleio_characteristic_construct(bleio_characteristic_obj_t *self, bleio_service_obj_t *service, + uint16_t handle, bleio_uuid_obj_t *uuid, bleio_characteristic_properties_t props, + bleio_attribute_security_mode_t read_perm, bleio_attribute_security_mode_t write_perm, + mp_int_t max_length, bool fixed_length, mp_buffer_info_t *initial_value_bufinfo, + const char *user_description) { + self->service = service; + self->uuid = uuid; + self->handle = BLEIO_HANDLE_INVALID; + self->cccd_handle = BLEIO_HANDLE_INVALID; + self->sccd_handle = BLEIO_HANDLE_INVALID; + self->props = props; + self->read_perm = read_perm; + self->write_perm = write_perm; + common_hal_bleio_characteristic_set_value(self, initial_value_bufinfo); + + if (gc_alloc_possible()) { + self->descriptor_list = mp_obj_new_list(0, NULL); + } else { + self->descriptor_list = NULL; + } + + self->max_length = max_length; + self->fixed_length = fixed_length; + + if (service->is_remote) { + self->handle = handle; + } else { + common_hal_bleio_service_add_characteristic(self->service, self, initial_value_bufinfo, user_description); + } +} + +mp_obj_tuple_t *common_hal_bleio_characteristic_get_descriptors(bleio_characteristic_obj_t *self) { + if (self->descriptor_list == NULL) { + return mp_const_empty_tuple; + } + return mp_obj_new_tuple(self->descriptor_list->len, self->descriptor_list->items); +} + +bleio_service_obj_t *common_hal_bleio_characteristic_get_service(bleio_characteristic_obj_t *self) { + return self->service; +} + +typedef struct { + TaskHandle_t task; + uint8_t *buf; + uint16_t len; +} _read_info_t; + +STATIC int _read_cb(uint16_t conn_handle, + const struct ble_gatt_error *error, + struct ble_gatt_attr *attr, + void *arg) { + _read_info_t *read_info = (_read_info_t *)arg; + switch (error->status) { + case 0: { + int len = MIN(read_info->len, OS_MBUF_PKTLEN(attr->om)); + os_mbuf_copydata(attr->om, attr->offset, len, read_info->buf); + read_info->len = len; + } + MP_FALLTHROUGH; + + default: + #if CIRCUITPY_VERBOSE_BLE + // For debugging. + mp_printf(&mp_plat_print, "Read status: %d\n", error->status); + #endif + xTaskNotify(read_info->task, error->status, eSetValueWithOverwrite); + break; + } + + return 0; +} + +size_t common_hal_bleio_characteristic_get_value(bleio_characteristic_obj_t *self, uint8_t *buf, size_t len) { + // Do GATT operations only if this characteristic has been added to a registered service. + if (self->handle == BLEIO_HANDLE_INVALID) { + return 0; + } + uint16_t conn_handle = bleio_connection_get_conn_handle(self->service->connection); + if (common_hal_bleio_service_get_is_remote(self->service)) { + _read_info_t read_info = { + .task = xTaskGetCurrentTaskHandle(), + .buf = buf, + .len = len + }; + CHECK_NIMBLE_ERROR(ble_gattc_read(conn_handle, self->handle, _read_cb, &read_info)); + int error_code; + xTaskNotifyWait(0, 0, (uint32_t *)&error_code, 200); + CHECK_BLE_ERROR(error_code); + return read_info.len; + } else { + len = MIN(self->current_value_len, len); + memcpy(buf, self->current_value, len); + return len; + } + + return 0; +} + +size_t common_hal_bleio_characteristic_get_max_length(bleio_characteristic_obj_t *self) { + return self->max_length; +} + +STATIC int _write_cb(uint16_t conn_handle, + const struct ble_gatt_error *error, + struct ble_gatt_attr *attr, + void *arg) { + TaskHandle_t task = (TaskHandle_t)arg; + xTaskNotify(task, error->status, eSetValueWithOverwrite); + + return 0; +} + +void common_hal_bleio_characteristic_set_value(bleio_characteristic_obj_t *self, mp_buffer_info_t *bufinfo) { + if (common_hal_bleio_service_get_is_remote(self->service)) { + uint16_t conn_handle = bleio_connection_get_conn_handle(self->service->connection); + if ((self->props & CHAR_PROP_WRITE_NO_RESPONSE) != 0) { + CHECK_NIMBLE_ERROR(ble_gattc_write_no_rsp_flat(conn_handle, self->handle, bufinfo->buf, bufinfo->len)); + } else { + CHECK_NIMBLE_ERROR(ble_gattc_write_flat(conn_handle, self->handle, bufinfo->buf, bufinfo->len, _write_cb, xTaskGetCurrentTaskHandle())); + int error_code; + xTaskNotifyWait(0, 0, (uint32_t *)&error_code, 200); + CHECK_BLE_ERROR(error_code); + } + } else { + // Validate data length for local characteristics only. + // TODO: Test this once we can get servers going. + if (self->fixed_length && bufinfo->len != self->max_length) { + mp_raise_ValueError(translate("Value length != required fixed length")); + } + if (bufinfo->len > self->max_length) { + mp_raise_ValueError(translate("Value length > max_length")); + } + + if (bufinfo == NULL) { + self->current_value_len = 0; + ble_gatts_chr_updated(self->handle); + return; + } + + self->current_value_len = bufinfo->len; + // If we've already allocated an internal buffer or the provided buffer + // is on the heap, then copy into the internal buffer. + if (self->current_value_alloc > 0 || gc_nbytes(bufinfo->buf) > 0) { + if (self->current_value_alloc < bufinfo->len) { + self->current_value = m_realloc(self->current_value, bufinfo->len); + // Get the number of bytes from the heap because it may be more + // than the len due to gc block size. + self->current_value_alloc = gc_nbytes(self->current_value); + } + memcpy(self->current_value, bufinfo->buf, bufinfo->len); + } else { + // Otherwise, use the provided buffer to delay any heap allocation. + self->current_value = bufinfo->buf; + self->current_value_alloc = 0; + } + + ble_gatts_chr_updated(self->handle); + } +} + +bleio_uuid_obj_t *common_hal_bleio_characteristic_get_uuid(bleio_characteristic_obj_t *self) { + return self->uuid; +} + +bleio_characteristic_properties_t common_hal_bleio_characteristic_get_properties(bleio_characteristic_obj_t *self) { + return self->props; +} + +void common_hal_bleio_characteristic_add_descriptor(bleio_characteristic_obj_t *self, + bleio_descriptor_obj_t *descriptor) { + // TODO: Implement this. + + mp_obj_list_append(MP_OBJ_FROM_PTR(self->descriptor_list), + MP_OBJ_FROM_PTR(descriptor)); +} + +void common_hal_bleio_characteristic_set_cccd(bleio_characteristic_obj_t *self, bool notify, bool indicate) { + if (self->cccd_handle == BLEIO_HANDLE_INVALID) { + mp_raise_bleio_BluetoothError(translate("No CCCD for this Characteristic")); + } + + if (!common_hal_bleio_service_get_is_remote(self->service)) { + mp_raise_bleio_RoleError(translate("Can't set CCCD on local Characteristic")); + } + + const uint16_t conn_handle = bleio_connection_get_conn_handle(self->service->connection); + common_hal_bleio_check_connected(conn_handle); + + uint16_t cccd_value = + (notify ? 1 << 0 : 0) | + (indicate ? 1 << 1: 0); + + CHECK_NIMBLE_ERROR(ble_gattc_write_flat(conn_handle, self->cccd_handle, &cccd_value, 2, _write_cb, xTaskGetCurrentTaskHandle())); + int error_code; + xTaskNotifyWait(0, 0, (uint32_t *)&error_code, 200); + CHECK_BLE_ERROR(error_code); +} diff --git a/ports/espressif/common-hal/_bleio/Characteristic.h b/ports/espressif/common-hal/_bleio/Characteristic.h new file mode 100644 index 0000000000..ed812a9805 --- /dev/null +++ b/ports/espressif/common-hal/_bleio/Characteristic.h @@ -0,0 +1,60 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Dan Halbert for Adafruit Industries + * Copyright (c) 2018 Artur Pacholec + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_CHARACTERISTIC_H +#define MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_CHARACTERISTIC_H + +#include "shared-bindings/_bleio/Attribute.h" +#include "common-hal/_bleio/Descriptor.h" +#include "shared-module/_bleio/Characteristic.h" +#include "common-hal/_bleio/Service.h" +#include "common-hal/_bleio/UUID.h" + +typedef struct _bleio_characteristic_obj { + mp_obj_base_t base; + // Will be MP_OBJ_NULL before being assigned to a Service. + bleio_service_obj_t *service; + bleio_uuid_obj_t *uuid; + uint8_t *current_value; + uint16_t current_value_len; + // Our internal allocation length. If > 0, then current_value is managed by + // this characteristic. + uint16_t current_value_alloc; + uint16_t max_length; + uint16_t def_handle; + uint16_t handle; + bleio_characteristic_properties_t props; + bleio_attribute_security_mode_t read_perm; + bleio_attribute_security_mode_t write_perm; + mp_obj_list_t *descriptor_list; + uint16_t user_desc_handle; + uint16_t cccd_handle; + uint16_t sccd_handle; + bool fixed_length; +} bleio_characteristic_obj_t; + +#endif // MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_CHARACTERISTIC_H diff --git a/ports/espressif/common-hal/_bleio/CharacteristicBuffer.c b/ports/espressif/common-hal/_bleio/CharacteristicBuffer.c new file mode 100644 index 0000000000..fc3d0bbf06 --- /dev/null +++ b/ports/espressif/common-hal/_bleio/CharacteristicBuffer.c @@ -0,0 +1,143 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Dan Halbert for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include +#include + +#include "shared/runtime/interrupt_char.h" +#include "py/ringbuf.h" +#include "py/runtime.h" +#include "py/stream.h" + +#include "shared-bindings/_bleio/__init__.h" +#include "shared-bindings/_bleio/Connection.h" +#include "supervisor/shared/tick.h" +#include "common-hal/_bleio/CharacteristicBuffer.h" +#include "shared-bindings/_bleio/CharacteristicBuffer.h" + +STATIC int characteristic_buffer_on_ble_evt(struct ble_gap_event *event, void *param) { + bleio_characteristic_buffer_obj_t *self = (bleio_characteristic_buffer_obj_t *)param; + switch (event->type) { + case BLE_GAP_EVENT_NOTIFY_RX: { + // A remote service wrote to this characteristic. + + // Must be a notification, and event handle must match the handle for my characteristic. + if (event->notify_rx.indication == 0 && + event->notify_rx.attr_handle == self->characteristic->handle) { + const struct os_mbuf *m = event->notify_rx.om; + while (m != NULL) { + ringbuf_put_n(&self->ringbuf, m->om_data, m->om_len); + m = SLIST_NEXT(m, om_next); + } + } + break; + } + default: + #if CIRCUITPY_VERBOSE_BLE + mp_printf(&mp_plat_print, "Unhandled gap event %d\n", event->type); + #endif + return 0; + break; + } + return 0; +} + +void _common_hal_bleio_characteristic_buffer_construct(bleio_characteristic_buffer_obj_t *self, + bleio_characteristic_obj_t *characteristic, + mp_float_t timeout, + uint8_t *buffer, size_t buffer_size, + void *static_handler_entry) { + self->characteristic = characteristic; + self->timeout_ms = timeout * 1000; + + self->ringbuf.buf = (uint8_t *)buffer; + self->ringbuf.size = buffer_size; + self->ringbuf.iget = 0; + self->ringbuf.iput = 0; + + if (static_handler_entry != NULL) { + ble_event_add_handler_entry((ble_event_handler_entry_t *)static_handler_entry, characteristic_buffer_on_ble_evt, self); + } else { + ble_event_add_handler(characteristic_buffer_on_ble_evt, self); + } +} + +// Assumes that timeout and buffer_size have been validated before call. +void common_hal_bleio_characteristic_buffer_construct(bleio_characteristic_buffer_obj_t *self, + bleio_characteristic_obj_t *characteristic, + mp_float_t timeout, + size_t buffer_size) { + uint8_t *buffer = m_malloc(buffer_size, true); + _common_hal_bleio_characteristic_buffer_construct(self, characteristic, timeout, buffer, buffer_size, NULL); +} + +uint32_t common_hal_bleio_characteristic_buffer_read(bleio_characteristic_buffer_obj_t *self, uint8_t *data, size_t len, int *errcode) { + uint64_t start_ticks = supervisor_ticks_ms64(); + + // Wait for all bytes received or timeout + while ((ringbuf_num_filled(&self->ringbuf) < len) && (supervisor_ticks_ms64() - start_ticks < self->timeout_ms)) { + RUN_BACKGROUND_TASKS; + // Allow user to break out of a timeout with a KeyboardInterrupt. + if (mp_hal_is_interrupted()) { + return 0; + } + } + + uint32_t num_bytes_read = ringbuf_get_n(&self->ringbuf, data, len); + + return num_bytes_read; +} + +// NOTE: The nRF port has protection around these operations because the ringbuf +// is filled from an interrupt. On ESP the ringbuf is filled from the BLE host +// task that won't interrupt us. + +uint32_t common_hal_bleio_characteristic_buffer_rx_characters_available(bleio_characteristic_buffer_obj_t *self) { + return ringbuf_num_filled(&self->ringbuf); +} + +void common_hal_bleio_characteristic_buffer_clear_rx_buffer(bleio_characteristic_buffer_obj_t *self) { + ringbuf_clear(&self->ringbuf); +} + +bool common_hal_bleio_characteristic_buffer_deinited(bleio_characteristic_buffer_obj_t *self) { + return self->characteristic == NULL; +} + +void common_hal_bleio_characteristic_buffer_deinit(bleio_characteristic_buffer_obj_t *self) { + if (!common_hal_bleio_characteristic_buffer_deinited(self)) { + ble_event_remove_handler(characteristic_buffer_on_ble_evt, self); + self->characteristic = NULL; + } +} + +bool common_hal_bleio_characteristic_buffer_connected(bleio_characteristic_buffer_obj_t *self) { + return self->characteristic != NULL && + self->characteristic->service != NULL && + (!self->characteristic->service->is_remote || + (self->characteristic->service->connection != MP_OBJ_NULL && + common_hal_bleio_connection_get_connected(self->characteristic->service->connection))); +} diff --git a/ports/espressif/common-hal/_bleio/CharacteristicBuffer.h b/ports/espressif/common-hal/_bleio/CharacteristicBuffer.h new file mode 100644 index 0000000000..e5247c20f7 --- /dev/null +++ b/ports/espressif/common-hal/_bleio/CharacteristicBuffer.h @@ -0,0 +1,41 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Dan Halbert for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_CHARACTERISTICBUFFER_H +#define MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_CHARACTERISTICBUFFER_H + +#include "py/ringbuf.h" +#include "shared-bindings/_bleio/Characteristic.h" + +typedef struct { + mp_obj_base_t base; + bleio_characteristic_obj_t *characteristic; + uint32_t timeout_ms; + // Ring buffer storing consecutive incoming values. + ringbuf_t ringbuf; +} bleio_characteristic_buffer_obj_t; + +#endif // MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_CHARACTERISTICBUFFER_H diff --git a/ports/espressif/common-hal/_bleio/Connection.c b/ports/espressif/common-hal/_bleio/Connection.c new file mode 100644 index 0000000000..7dbcbd6e5f --- /dev/null +++ b/ports/espressif/common-hal/_bleio/Connection.c @@ -0,0 +1,452 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2018 Dan Halbert for Adafruit Industries + * Copyright (c) 2018 Artur Pacholec + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "shared-bindings/_bleio/Connection.h" + +#include +#include + +#include "shared/runtime/interrupt_char.h" +#include "py/gc.h" +#include "py/objlist.h" +#include "py/objstr.h" +#include "py/qstr.h" +#include "py/runtime.h" +#include "shared-bindings/_bleio/__init__.h" +#include "shared-bindings/_bleio/Adapter.h" +#include "shared-bindings/_bleio/Attribute.h" +#include "shared-bindings/_bleio/Characteristic.h" +#include "shared-bindings/_bleio/Service.h" +#include "shared-bindings/_bleio/UUID.h" +#include "supervisor/shared/tick.h" + +// #include "common-hal/_bleio/bonding.h" + +#include "host/ble_att.h" + +// Give 20 seconds for discovery +#define DISCOVERY_TIMEOUT_MS 20000 + +int bleio_connection_event_cb(struct ble_gap_event *event, void *connection_in) { + bleio_connection_internal_t *connection = (bleio_connection_internal_t *)connection_in; + + switch (event->type) { + case BLE_GAP_EVENT_DISCONNECT: { + connection->conn_handle = BLEIO_HANDLE_INVALID; + connection->pair_status = PAIR_NOT_PAIRED; + + #if CIRCUITPY_VERBOSE_BLE + mp_printf(&mp_plat_print, "disconnected %02x\n", event->disconnect.reason); + #endif + if (connection->connection_obj != mp_const_none) { + bleio_connection_obj_t *obj = connection->connection_obj; + obj->connection = NULL; + obj->disconnect_reason = event->disconnect.reason; + } + + break; + } + + case BLE_GAP_EVENT_PHY_UPDATE_COMPLETE: { + #if CIRCUITPY_VERBOSE_BLE + mp_printf(&mp_plat_print, "TODO connection event: PHY update complete\n"); + #endif + break; + } + + case BLE_GAP_EVENT_CONN_UPDATE: { + #if CIRCUITPY_VERBOSE_BLE + mp_printf(&mp_plat_print, "TODO connection event: connection update\n"); + #endif + break; + } + case BLE_GAP_EVENT_L2CAP_UPDATE_REQ: { + #if CIRCUITPY_VERBOSE_BLE + mp_printf(&mp_plat_print, "TODO connection event: l2cap update request\n"); + #endif + break; + } + + // These events are actually att specific so forward to all registered + // handlers for them. The handlers themselves decide whether an event + // is interesting to them. + case BLE_GAP_EVENT_NOTIFY_RX: + MP_FALLTHROUGH; + case BLE_GAP_EVENT_NOTIFY_TX: + MP_FALLTHROUGH; + case BLE_GAP_EVENT_SUBSCRIBE: + return ble_event_run_handlers(event); + + default: + #if CIRCUITPY_VERBOSE_BLE + mp_printf(&mp_plat_print, "Unhandled connection event: %d\n", event->type); + #endif + return 0; + } + return 0; +} + +bool common_hal_bleio_connection_get_paired(bleio_connection_obj_t *self) { + if (self->connection == NULL) { + return false; + } + return self->connection->pair_status == PAIR_PAIRED; +} + +bool common_hal_bleio_connection_get_connected(bleio_connection_obj_t *self) { + if (self->connection == NULL) { + return false; + } + return self->connection->conn_handle != BLEIO_HANDLE_INVALID; +} + +void common_hal_bleio_connection_disconnect(bleio_connection_internal_t *self) { + ble_gap_terminate(self->conn_handle, BLE_ERR_REM_USER_CONN_TERM); +} + +void common_hal_bleio_connection_pair(bleio_connection_internal_t *self, bool bond) { + // TODO: Implement this. +} + +mp_float_t common_hal_bleio_connection_get_connection_interval(bleio_connection_internal_t *self) { + // TODO: Implement this. + while (self->conn_params_updating && !mp_hal_is_interrupted()) { + RUN_BACKGROUND_TASKS; + } + return 0; +} + +// Return the current negotiated MTU length, minus overhead. +mp_int_t common_hal_bleio_connection_get_max_packet_length(bleio_connection_internal_t *self) { + return (self->mtu == 0 ? BLE_ATT_MTU_DFLT : self->mtu) - 3; +} + +void common_hal_bleio_connection_set_connection_interval(bleio_connection_internal_t *self, mp_float_t new_interval) { + self->conn_params_updating = true; + // TODO: Implement this. +} + +STATIC volatile int _last_discovery_status; +static TaskHandle_t discovery_task = NULL; + +STATIC int _discovered_service_cb(uint16_t conn_handle, + const struct ble_gatt_error *error, + const struct ble_gatt_svc *svc, + void *arg) { + bleio_connection_internal_t *self = (bleio_connection_internal_t *)arg; + + if (error->status != BLE_ERR_SUCCESS) { + // Keep the first error in case it's due to memory. + if (_last_discovery_status == BLE_ERR_SUCCESS) { + _last_discovery_status = error->status; + xTaskNotifyGive(discovery_task); + } + return 0; + } + + // If any of these memory allocations fail, we set _last_discovery_status + // and let the process continue. + if (_last_discovery_status != BLE_ERR_SUCCESS) { + return 0; + } + bleio_service_obj_t *service = m_new_obj(bleio_service_obj_t); + if (service == NULL) { + _last_discovery_status = BLE_ERR_MEM_CAPACITY; + return 0; + } + service->base.type = &bleio_service_type; + + // Initialize several fields at once. + bleio_service_from_connection(service, bleio_connection_new_from_internal(self)); + + service->is_remote = true; + service->start_handle = svc->start_handle; + service->end_handle = svc->end_handle; + service->handle = svc->start_handle; + + bleio_uuid_obj_t *uuid = m_new_obj(bleio_uuid_obj_t); + if (uuid == NULL) { + _last_discovery_status = BLE_ERR_MEM_CAPACITY; + return 0; + } + uuid->base.type = &bleio_uuid_type; + uuid->nimble_ble_uuid = svc->uuid; + service->uuid = uuid; + + mp_obj_list_append(MP_OBJ_FROM_PTR(self->remote_service_list), + MP_OBJ_FROM_PTR(service)); + return 0; +} + +STATIC int _discovered_characteristic_cb(uint16_t conn_handle, + const struct ble_gatt_error *error, + const struct ble_gatt_chr *chr, + void *arg) { + bleio_service_obj_t *service = (bleio_service_obj_t *)arg; + + if (error->status != BLE_ERR_SUCCESS) { + // Keep the first error in case it's due to memory. + if (_last_discovery_status == BLE_ERR_SUCCESS) { + _last_discovery_status = error->status; + xTaskNotifyGive(discovery_task); + } + } + // If any of these memory allocations fail, we set _last_discovery_status + // and let the process continue. + if (_last_discovery_status != BLE_ERR_SUCCESS) { + return 0; + } + + bleio_characteristic_obj_t *characteristic = m_new_obj(bleio_characteristic_obj_t); + if (characteristic == NULL) { + _last_discovery_status = BLE_ERR_MEM_CAPACITY; + return 0; + } + characteristic->base.type = &bleio_characteristic_type; + + // Known characteristic UUID. + bleio_uuid_obj_t *uuid = m_new_obj(bleio_uuid_obj_t); + if (uuid == NULL) { + _last_discovery_status = BLE_ERR_MEM_CAPACITY; + return 0; + } + uuid->base.type = &bleio_uuid_type; + uuid->nimble_ble_uuid = chr->uuid; + + bleio_characteristic_properties_t props = + ((chr->properties & BLE_GATT_CHR_PROP_BROADCAST) != 0 ? CHAR_PROP_BROADCAST : 0) | + ((chr->properties & BLE_GATT_CHR_PROP_INDICATE) != 0 ? CHAR_PROP_INDICATE : 0) | + ((chr->properties & BLE_GATT_CHR_PROP_NOTIFY) != 0 ? CHAR_PROP_NOTIFY : 0) | + ((chr->properties & BLE_GATT_CHR_PROP_READ) != 0 ? CHAR_PROP_READ : 0) | + ((chr->properties & BLE_GATT_CHR_PROP_WRITE) != 0 ? CHAR_PROP_WRITE : 0) | + ((chr->properties & BLE_GATT_CHR_PROP_WRITE_NO_RSP) != 0 ? CHAR_PROP_WRITE_NO_RESPONSE : 0); + + // Call common_hal_bleio_characteristic_construct() to initalize some fields and set up evt handler. + common_hal_bleio_characteristic_construct( + characteristic, service, chr->val_handle, uuid, + props, SECURITY_MODE_OPEN, SECURITY_MODE_OPEN, + 0, false, // max_length, fixed_length: values don't matter for gattc + mp_const_empty_bytes, + NULL); + // Set def_handle directly since it is only used in discovery. + characteristic->def_handle = chr->def_handle; + + mp_obj_list_append(MP_OBJ_FROM_PTR(service->characteristic_list), + MP_OBJ_FROM_PTR(characteristic)); + return 0; +} + +STATIC int _discovered_descriptor_cb(uint16_t conn_handle, + const struct ble_gatt_error *error, + uint16_t chr_val_handle, + const struct ble_gatt_dsc *dsc, + void *arg) { + bleio_characteristic_obj_t *characteristic = (bleio_characteristic_obj_t *)arg; + + if (error->status != BLE_ERR_SUCCESS) { + // Keep the first error in case it's due to memory. + if (_last_discovery_status == BLE_ERR_SUCCESS) { + _last_discovery_status = error->status; + } + xTaskNotifyGive(discovery_task); + } + // If any of these memory allocations fail, we set _last_discovery_status + // and let the process continue. + if (_last_discovery_status != BLE_ERR_SUCCESS) { + return 0; + } + + // Remember handles for certain well-known descriptors. + switch (dsc->uuid.u16.value) { + case 0x2902: + characteristic->cccd_handle = dsc->handle; + break; + + case 0x2903: + characteristic->sccd_handle = dsc->handle; + break; + + case 0x2901: + characteristic->user_desc_handle = dsc->handle; + break; + + default: + break; + } + + bleio_descriptor_obj_t *descriptor = m_new_obj(bleio_descriptor_obj_t); + if (descriptor == NULL) { + _last_discovery_status = BLE_ERR_MEM_CAPACITY; + return 0; + } + descriptor->base.type = &bleio_descriptor_type; + + bleio_uuid_obj_t *uuid = m_new_obj(bleio_uuid_obj_t); + if (uuid == NULL) { + _last_discovery_status = BLE_ERR_MEM_CAPACITY; + return 0; + } + uuid->base.type = &bleio_uuid_type; + uuid->nimble_ble_uuid = dsc->uuid; + + common_hal_bleio_descriptor_construct( + descriptor, characteristic, uuid, + SECURITY_MODE_OPEN, SECURITY_MODE_OPEN, + 0, false, mp_const_empty_bytes); + descriptor->handle = dsc->handle; + + mp_obj_list_append(MP_OBJ_FROM_PTR(characteristic->descriptor_list), + MP_OBJ_FROM_PTR(descriptor)); + return 0; +} + +STATIC void discover_remote_services(bleio_connection_internal_t *self, mp_obj_t service_uuids_whitelist) { + // Start over with an empty list. + self->remote_service_list = mp_obj_new_list(0, NULL); + + discovery_task = xTaskGetCurrentTaskHandle(); + if (service_uuids_whitelist == mp_const_none) { + _last_discovery_status = BLE_ERR_SUCCESS; + CHECK_NIMBLE_ERROR(ble_gattc_disc_all_svcs(self->conn_handle, _discovered_service_cb, self)); + + // Wait for sync. + ulTaskNotifyTake(pdTRUE, pdMS_TO_TICKS(DISCOVERY_TIMEOUT_MS)); + if (_last_discovery_status != BLE_HS_EDONE) { + CHECK_BLE_ERROR(_last_discovery_status); + } + } else { + mp_obj_iter_buf_t iter_buf; + mp_obj_t iterable = mp_getiter(service_uuids_whitelist, &iter_buf); + mp_obj_t uuid_obj; + while ((uuid_obj = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) { + if (!mp_obj_is_type(uuid_obj, &bleio_uuid_type)) { + mp_raise_TypeError(translate("non-UUID found in service_uuids_whitelist")); + } + bleio_uuid_obj_t *uuid = MP_OBJ_TO_PTR(uuid_obj); + + _last_discovery_status = BLE_ERR_SUCCESS; + // Make sure we start with a clean notification state + ulTaskNotifyValueClear(discovery_task, 0xffffffff); + CHECK_NIMBLE_ERROR(ble_gattc_disc_svc_by_uuid(self->conn_handle, &uuid->nimble_ble_uuid.u, + _discovered_service_cb, self)); + // Wait for sync. + CHECK_NOTIFY(ulTaskNotifyTake(pdTRUE, pdMS_TO_TICKS(DISCOVERY_TIMEOUT_MS))); + if (_last_discovery_status != BLE_HS_EDONE) { + CHECK_BLE_ERROR(_last_discovery_status); + } + } + } + + for (size_t i = 0; i < self->remote_service_list->len; i++) { + bleio_service_obj_t *service = MP_OBJ_TO_PTR(self->remote_service_list->items[i]); + + _last_discovery_status = BLE_ERR_SUCCESS; + CHECK_NIMBLE_ERROR(ble_gattc_disc_all_chrs(self->conn_handle, + service->start_handle, + service->end_handle, + _discovered_characteristic_cb, + service)); + + // Wait for sync. + CHECK_NOTIFY(ulTaskNotifyTake(pdTRUE, pdMS_TO_TICKS(DISCOVERY_TIMEOUT_MS))); + if (_last_discovery_status != BLE_HS_EDONE) { + CHECK_BLE_ERROR(_last_discovery_status); + } + + // Got characteristics for this service. Now discover descriptors for each characteristic. + size_t char_list_len = service->characteristic_list->len; + for (size_t char_idx = 0; char_idx < char_list_len; ++char_idx) { + bleio_characteristic_obj_t *characteristic = + MP_OBJ_TO_PTR(service->characteristic_list->items[char_idx]); + // Determine the handle range for the given characteristic's descriptors. + // The end of the range is dictated by the next characteristic or the end + // handle of the service. + const bool last_characteristic = char_idx == char_list_len - 1; + bleio_characteristic_obj_t *next_characteristic = last_characteristic + ? NULL + : MP_OBJ_TO_PTR(service->characteristic_list->items[char_idx + 1]); + + uint16_t end_handle = next_characteristic == NULL + ? service->end_handle + : next_characteristic->def_handle - 1; + + _last_discovery_status = BLE_ERR_SUCCESS; + CHECK_NIMBLE_ERROR(ble_gattc_disc_all_dscs(self->conn_handle, characteristic->handle, + end_handle, + _discovered_descriptor_cb, characteristic)); + // Wait for sync. + ulTaskNotifyTake(pdTRUE, pdMS_TO_TICKS(DISCOVERY_TIMEOUT_MS)); + if (_last_discovery_status != BLE_HS_EDONE) { + CHECK_BLE_ERROR(_last_discovery_status); + } + } + } +} + +mp_obj_tuple_t *common_hal_bleio_connection_discover_remote_services(bleio_connection_obj_t *self, mp_obj_t service_uuids_whitelist) { + discover_remote_services(self->connection, service_uuids_whitelist); + bleio_connection_ensure_connected(self); + // Convert to a tuple and then clear the list so the callee will take ownership. + mp_obj_tuple_t *services_tuple = + mp_obj_new_tuple(self->connection->remote_service_list->len, + self->connection->remote_service_list->items); + mp_obj_list_clear(MP_OBJ_FROM_PTR(self->connection->remote_service_list)); + + return services_tuple; +} + +uint16_t bleio_connection_get_conn_handle(bleio_connection_obj_t *self) { + if (self == NULL || self->connection == NULL) { + return BLEIO_HANDLE_INVALID; + } + return self->connection->conn_handle; +} + +mp_obj_t bleio_connection_new_from_internal(bleio_connection_internal_t *internal) { + if (internal->connection_obj != mp_const_none) { + return internal->connection_obj; + } + bleio_connection_obj_t *connection = m_new_obj(bleio_connection_obj_t); + connection->base.type = &bleio_connection_type; + connection->connection = internal; + internal->connection_obj = connection; + + return MP_OBJ_FROM_PTR(connection); +} + +// Find the connection that uses the given conn_handle. Return NULL if not found. +bleio_connection_internal_t *bleio_conn_handle_to_connection(uint16_t conn_handle) { + bleio_connection_internal_t *connection; + for (size_t i = 0; i < BLEIO_TOTAL_CONNECTION_COUNT; i++) { + connection = &bleio_connections[i]; + if (connection->conn_handle == conn_handle) { + return connection; + } + } + + return NULL; +} diff --git a/ports/espressif/common-hal/_bleio/Connection.h b/ports/espressif/common-hal/_bleio/Connection.h new file mode 100644 index 0000000000..73bfeff19c --- /dev/null +++ b/ports/espressif/common-hal/_bleio/Connection.h @@ -0,0 +1,92 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Dan Halbert for Adafruit Industries + * Copyright (c) 2018 Artur Pacholec + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_CONNECTION_H +#define MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_CONNECTION_H + +#include + +#include "py/obj.h" +#include "py/objlist.h" + +#include "common-hal/_bleio/__init__.h" +// #include "common-hal/_bleio/bonding.h" +#include "shared-module/_bleio/Address.h" +#include "common-hal/_bleio/Service.h" + +#include "host/ble_gap.h" + +typedef enum { + PAIR_NOT_PAIRED, + PAIR_WAITING, + PAIR_PAIRED, +} pair_status_t; + +// We split the Connection object into two so that the internal mechanics can live outside of the +// VM. If it were one object, then we'd risk user code seeing a connection object of theirs be +// reused. +typedef struct { + uint16_t conn_handle; + bool is_central; + // Remote services discovered when this peripheral is acting as a client. + mp_obj_list_t *remote_service_list; + // The advertising data and scan response buffers are held by us, not by the SD, so we must + // maintain them and not change it. If we need to change the contents during advertising, + // there are tricks to get the SD to notice (see DevZone - TBS). + // bonding_keys_t bonding_keys; + // EDIV: Encrypted Diversifier: Identifies LTK during legacy pairing. + uint16_t ediv; + volatile pair_status_t pair_status; + uint8_t sec_status; // Internal security status. + mp_obj_t connection_obj; + volatile bool conn_params_updating; + uint16_t mtu; + // Request that CCCD values for this connection be saved, using sys_attr values. + volatile bool do_bond_cccds; + // Request that security key info for this connection be saved. + volatile bool do_bond_keys; + // Time of setting do_bond_ccds: we delay a bit to consolidate multiple CCCD changes + // into one write. Time is currently in ticks_ms. + uint64_t do_bond_cccds_request_time; +} bleio_connection_internal_t; + +typedef struct { + mp_obj_base_t base; + bleio_connection_internal_t *connection; + // The HCI disconnect reason. + uint8_t disconnect_reason; +} bleio_connection_obj_t; + +void bleio_connection_clear(bleio_connection_internal_t *self); + +int bleio_connection_event_cb(struct ble_gap_event *event, void *connection_in); + +uint16_t bleio_connection_get_conn_handle(bleio_connection_obj_t *self); +mp_obj_t bleio_connection_new_from_internal(bleio_connection_internal_t *connection); +bleio_connection_internal_t *bleio_conn_handle_to_connection(uint16_t conn_handle); + +#endif // MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_CONNECTION_H diff --git a/ports/espressif/common-hal/_bleio/Descriptor.c b/ports/espressif/common-hal/_bleio/Descriptor.c new file mode 100644 index 0000000000..31bdca51b0 --- /dev/null +++ b/ports/espressif/common-hal/_bleio/Descriptor.c @@ -0,0 +1,96 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Dan Halbert for Adafruit Industries + * Copyright (c) 2018 Artur Pacholec + * Copyright (c) 2016 Glenn Ruben Bakke + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "py/runtime.h" + +#include "shared-bindings/_bleio/__init__.h" +#include "shared-bindings/_bleio/Descriptor.h" +#include "shared-bindings/_bleio/Service.h" +#include "shared-bindings/_bleio/UUID.h" + +#include "host/ble_att.h" + +void common_hal_bleio_descriptor_construct(bleio_descriptor_obj_t *self, bleio_characteristic_obj_t *characteristic, bleio_uuid_obj_t *uuid, bleio_attribute_security_mode_t read_perm, bleio_attribute_security_mode_t write_perm, mp_int_t max_length, bool fixed_length, mp_buffer_info_t *initial_value_bufinfo) { + self->characteristic = characteristic; + self->uuid = uuid; + self->handle = BLEIO_HANDLE_INVALID; + self->read_perm = read_perm; + self->write_perm = write_perm; + self->initial_value = mp_obj_new_bytes(initial_value_bufinfo->buf, initial_value_bufinfo->len); + + const mp_int_t max_length_max = BLE_ATT_ATTR_MAX_LEN; + if (max_length < 0 || max_length > max_length_max) { + mp_raise_ValueError_varg(translate("max_length must be 0-%d when fixed_length is %s"), + max_length_max, fixed_length ? "True" : "False"); + } + self->max_length = max_length; + self->fixed_length = fixed_length; +} + +bleio_uuid_obj_t *common_hal_bleio_descriptor_get_uuid(bleio_descriptor_obj_t *self) { + return self->uuid; +} + +bleio_characteristic_obj_t *common_hal_bleio_descriptor_get_characteristic(bleio_descriptor_obj_t *self) { + return self->characteristic; +} + +size_t common_hal_bleio_descriptor_get_value(bleio_descriptor_obj_t *self, uint8_t *buf, size_t len) { + // Do GATT operations only if this descriptor has been registered + if (self->handle != BLEIO_HANDLE_INVALID) { + uint16_t conn_handle = bleio_connection_get_conn_handle(self->characteristic->service->connection); + (void)conn_handle; + } + + // TODO: Implement this. + + return 0; +} + +void common_hal_bleio_descriptor_set_value(bleio_descriptor_obj_t *self, mp_buffer_info_t *bufinfo) { + // TODO: Implement this. + // Do GATT operations only if this descriptor has been registered. + if (self->handle != BLEIO_HANDLE_INVALID) { + // uint16_t conn_handle = bleio_connection_get_conn_handle(self->characteristic->service->connection); + if (common_hal_bleio_service_get_is_remote(self->characteristic->service)) { + // false means WRITE_REQ, not write-no-response + // common_hal_bleio_gattc_write(self->handle, conn_handle, bufinfo, false); + } else { + // Validate data length for local descriptors only. + if (self->fixed_length && bufinfo->len != self->max_length) { + mp_raise_ValueError(translate("Value length != required fixed length")); + } + if (bufinfo->len > self->max_length) { + mp_raise_ValueError(translate("Value length > max_length")); + } + + // common_hal_bleio_gatts_write(self->handle, conn_handle, bufinfo); + } + } + +} diff --git a/ports/espressif/common-hal/_bleio/Descriptor.h b/ports/espressif/common-hal/_bleio/Descriptor.h new file mode 100644 index 0000000000..e52251ce82 --- /dev/null +++ b/ports/espressif/common-hal/_bleio/Descriptor.h @@ -0,0 +1,55 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2018 Dan Halbert for Adafruit Industries + * Copyright (c) 2018 Artur Pacholec + * Copyright (c) 2016 Glenn Ruben Bakke + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_DESCRIPTOR_H +#define MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_DESCRIPTOR_H + +#include "py/obj.h" + +#include "common-hal/_bleio/UUID.h" + +#include "host/ble_gatt.h" + +// Forward declare characteristic because it includes a Descriptor. +struct _bleio_characteristic_obj; + +typedef struct _bleio_descriptor_obj { + mp_obj_base_t base; + // Will be MP_OBJ_NULL before being assigned to a Characteristic. + struct _bleio_characteristic_obj *characteristic; + bleio_uuid_obj_t *uuid; + mp_obj_t initial_value; + uint16_t max_length; + bool fixed_length; + uint16_t handle; + struct ble_gatt_dsc_def def; + bleio_attribute_security_mode_t read_perm; + bleio_attribute_security_mode_t write_perm; +} bleio_descriptor_obj_t; + +#endif // MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_DESCRIPTOR_H diff --git a/ports/espressif/common-hal/_bleio/PacketBuffer.c b/ports/espressif/common-hal/_bleio/PacketBuffer.c new file mode 100644 index 0000000000..4e65bf309c --- /dev/null +++ b/ports/espressif/common-hal/_bleio/PacketBuffer.c @@ -0,0 +1,418 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019-2020 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include +#include + +#include "shared/runtime/interrupt_char.h" +#include "py/runtime.h" +#include "py/stream.h" + +#include "shared-bindings/_bleio/__init__.h" +#include "shared-bindings/_bleio/Connection.h" +#include "shared-bindings/_bleio/PacketBuffer.h" +#include "supervisor/shared/tick.h" + +#include "supervisor/shared/bluetooth/serial.h" + +#include "host/ble_att.h" + +STATIC void write_to_ringbuf(bleio_packet_buffer_obj_t *self, const struct os_mbuf *mbuf) { + size_t len = OS_MBUF_PKTLEN(mbuf); + if (len + sizeof(uint16_t) > ringbuf_capacity(&self->ringbuf)) { + // This shouldn't happen but can if our buffer size was much smaller than + // the writes the client actually makes. + return; + } + // Make room for the new value by dropping the oldest packets first. + while (ringbuf_capacity(&self->ringbuf) - ringbuf_num_filled(&self->ringbuf) < len + sizeof(uint16_t)) { + uint16_t packet_length; + ringbuf_get_n(&self->ringbuf, (uint8_t *)&packet_length, sizeof(uint16_t)); + for (uint16_t i = 0; i < packet_length; i++) { + ringbuf_get(&self->ringbuf); + } + // set an overflow flag? + } + ringbuf_put_n(&self->ringbuf, (uint8_t *)&len, sizeof(uint16_t)); + while (mbuf != NULL) { + ringbuf_put_n(&self->ringbuf, mbuf->om_data, mbuf->om_len); + mbuf = SLIST_NEXT(mbuf, om_next); + } +} + +STATIC int packet_buffer_on_ble_client_evt(struct ble_gap_event *event, void *param); +STATIC int queue_next_write(bleio_packet_buffer_obj_t *self); + +STATIC int _write_cb(uint16_t conn_handle, + const struct ble_gatt_error *error, + struct ble_gatt_attr *attr, + void *arg) { + if (error->status != 0) { + mp_printf(&mp_plat_print, "write failed %d\n", error->status); + } + bleio_packet_buffer_obj_t *self = (bleio_packet_buffer_obj_t *)arg; + queue_next_write(self); + + return 0; +} + +STATIC int queue_next_write(bleio_packet_buffer_obj_t *self) { + // Queue up the next outgoing buffer. We use two, one that has been passed to the SD for + // transmission (when packet_queued is true) and the other is `pending` and can still be + // modified. By primarily appending to the `pending` buffer we can reduce the protocol overhead + // of the lower level link and ATT layers. + self->packet_queued = false; + if (self->pending_size > 0) { + uint16_t conn_handle = self->conn_handle; + int err_code = NIMBLE_OK; + if (self->client) { + if (self->write_type == CHAR_PROP_WRITE_NO_RESPONSE) { + err_code = ble_gattc_write_no_rsp_flat(conn_handle, + self->characteristic->handle, + self->outgoing[self->pending_index], + self->pending_size); + // We don't set packet_queued because we NimBLE will buffer our + // outgoing packets. + } else { + err_code = ble_gattc_write_flat(conn_handle, + self->characteristic->handle, + self->outgoing[self->pending_index], + self->pending_size, + _write_cb, self); + self->pending_index = (self->pending_index + 1) % 2; + self->packet_queued = true; + } + self->pending_size = 0; + } else { + // TODO: Notify because we're the server. + } + if (err_code != NIMBLE_OK) { + // On error, simply skip updating the pending buffers so that the next HVC or WRITE + // complete event triggers another attempt. + return err_code; + } + } + return NIMBLE_OK; +} + +STATIC int packet_buffer_on_ble_client_evt(struct ble_gap_event *event, void *param) { + bleio_packet_buffer_obj_t *self = (bleio_packet_buffer_obj_t *)param; + if (event->type == BLE_GAP_EVENT_DISCONNECT && self->conn_handle == event->disconnect.conn.conn_handle) { + self->conn_handle = BLEIO_HANDLE_INVALID; + } + + switch (event->type) { + case BLE_GAP_EVENT_NOTIFY_RX: { + if (event->notify_rx.conn_handle != self->conn_handle) { + return false; + } + // Must be a notification, and event handle must match the handle for my characteristic. + if (event->notify_rx.attr_handle == self->characteristic->handle) { + write_to_ringbuf(self, event->notify_rx.om); + } + break; + } + default: + return false; + break; + } + return true; +} + +void _common_hal_bleio_packet_buffer_construct( + bleio_packet_buffer_obj_t *self, bleio_characteristic_obj_t *characteristic, + uint32_t *incoming_buffer, size_t incoming_buffer_size, + uint32_t *outgoing_buffer1, uint32_t *outgoing_buffer2, size_t max_packet_size, + void *static_handler_entry) { + self->characteristic = characteristic; + self->client = self->characteristic->service->is_remote; + self->max_packet_size = max_packet_size; + bleio_characteristic_properties_t incoming = self->characteristic->props & (CHAR_PROP_WRITE_NO_RESPONSE | CHAR_PROP_WRITE); + bleio_characteristic_properties_t outgoing = self->characteristic->props & (CHAR_PROP_NOTIFY | CHAR_PROP_INDICATE); + + if (self->client) { + // Swap if we're the client. + bleio_characteristic_properties_t temp = incoming; + incoming = outgoing; + outgoing = temp; + self->conn_handle = bleio_connection_get_conn_handle(MP_OBJ_TO_PTR(self->characteristic->service->connection)); + } else { + self->conn_handle = BLEIO_HANDLE_INVALID; + } + + if (incoming) { + self->ringbuf.buf = (uint8_t *)incoming_buffer; + self->ringbuf.size = incoming_buffer_size; + self->ringbuf.iget = 0; + self->ringbuf.iput = 0; + } + + self->packet_queued = false; + self->pending_index = 0; + self->pending_size = 0; + self->outgoing[0] = outgoing_buffer1; + self->outgoing[1] = outgoing_buffer2; + + if (self->client) { + if (static_handler_entry != NULL) { + ble_event_add_handler_entry((ble_event_handler_entry_t *)static_handler_entry, packet_buffer_on_ble_client_evt, self); + } else { + ble_event_add_handler(packet_buffer_on_ble_client_evt, self); + } + if (incoming) { + // Prefer notify if both are available. + if (incoming & CHAR_PROP_NOTIFY) { + common_hal_bleio_characteristic_set_cccd(self->characteristic, true, false); + } else { + common_hal_bleio_characteristic_set_cccd(self->characteristic, false, true); + } + } + if (outgoing) { + self->write_type = CHAR_PROP_WRITE; + if (outgoing & CHAR_PROP_WRITE_NO_RESPONSE) { + self->write_type = CHAR_PROP_WRITE_NO_RESPONSE; + } + } + } else { + // TODO: Setup for server. + } +} + +void common_hal_bleio_packet_buffer_construct( + bleio_packet_buffer_obj_t *self, bleio_characteristic_obj_t *characteristic, + size_t buffer_size, size_t max_packet_size) { + + // Cap the packet size to our implementation limits. + max_packet_size = MIN(max_packet_size, BLE_ATT_ATTR_MAX_LEN - 3); + + bleio_characteristic_properties_t incoming = characteristic->props & (CHAR_PROP_WRITE_NO_RESPONSE | CHAR_PROP_WRITE); + bleio_characteristic_properties_t outgoing = characteristic->props & (CHAR_PROP_NOTIFY | CHAR_PROP_INDICATE); + if (characteristic->service->is_remote) { + // Swap if we're the client. + bleio_characteristic_properties_t temp = incoming; + incoming = outgoing; + outgoing = temp; + } + size_t incoming_buffer_size = 0; + uint32_t *incoming_buffer = NULL; + if (incoming) { + incoming_buffer_size = buffer_size * (sizeof(uint16_t) + max_packet_size); + incoming_buffer = m_malloc(incoming_buffer_size, false); + } + + uint32_t *outgoing1 = NULL; + uint32_t *outgoing2 = NULL; + if (outgoing) { + outgoing1 = m_malloc(max_packet_size, false); + // Only allocate the second buffer if we are doing writes with responses. + // Without responses, we just write as quickly as we can. + if (outgoing == CHAR_PROP_WRITE) { + outgoing2 = m_malloc(max_packet_size, false); + } + + } + _common_hal_bleio_packet_buffer_construct(self, characteristic, + incoming_buffer, incoming_buffer_size, + outgoing1, outgoing2, max_packet_size, + NULL); +} + +mp_int_t common_hal_bleio_packet_buffer_readinto(bleio_packet_buffer_obj_t *self, uint8_t *data, size_t len) { + if (ringbuf_num_filled(&self->ringbuf) < 2) { + return 0; + } + + // Get packet length, which is in first two bytes of packet. + uint16_t packet_length; + ringbuf_get_n(&self->ringbuf, (uint8_t *)&packet_length, sizeof(uint16_t)); + + mp_int_t ret; + if (packet_length > len) { + // Packet is longer than requested. Return negative of overrun value. + ret = len - packet_length; + // Discard the packet if it's too large. Don't fill data. + while (packet_length--) { + (void)ringbuf_get(&self->ringbuf); + } + } else { + // Read as much as possible, but might be shorter than len. + ringbuf_get_n(&self->ringbuf, data, packet_length); + ret = packet_length; + } + + return ret; +} + +mp_int_t common_hal_bleio_packet_buffer_write(bleio_packet_buffer_obj_t *self, const uint8_t *data, size_t len, uint8_t *header, size_t header_len) { + if (self->outgoing[0] == NULL) { + mp_raise_bleio_BluetoothError(translate("Writes not supported on Characteristic")); + } + if (self->conn_handle == BLEIO_HANDLE_INVALID) { + return -1; + } + mp_int_t outgoing_packet_length = common_hal_bleio_packet_buffer_get_outgoing_packet_length(self); + if (outgoing_packet_length < 0) { + return -1; + } + + mp_int_t total_len = len + header_len; + if (total_len > outgoing_packet_length) { + // Supplied data will not fit in a single BLE packet. + mp_raise_ValueError_varg(translate("Total data to write is larger than %q"), MP_QSTR_outgoing_packet_length); + } + if (total_len > self->max_packet_size) { + // Supplied data will not fit in a single BLE packet. + mp_raise_ValueError_varg(translate("Total data to write is larger than %q"), MP_QSTR_max_packet_size); + } + outgoing_packet_length = MIN(outgoing_packet_length, self->max_packet_size); + + if (len + self->pending_size > (size_t)outgoing_packet_length) { + // No room to append len bytes to packet. Wait until we get a free buffer, + // and keep checking that we haven't been disconnected. + while (self->pending_size != 0 && + self->conn_handle != BLEIO_HANDLE_INVALID && + !mp_hal_is_interrupted()) { + RUN_BACKGROUND_TASKS; + } + } + if (self->conn_handle == BLEIO_HANDLE_INVALID || + mp_hal_is_interrupted()) { + return -1; + } + + size_t num_bytes_written = 0; + + uint32_t *pending = self->outgoing[self->pending_index]; + + if (self->pending_size == 0) { + memcpy(pending, header, header_len); + self->pending_size += header_len; + num_bytes_written += header_len; + } + memcpy(((uint8_t *)pending) + self->pending_size, data, len); + self->pending_size += len; + num_bytes_written += len; + + // If no writes are queued then sneak in this data. + if (!self->packet_queued) { + CHECK_NIMBLE_ERROR(queue_next_write(self)); + } + return num_bytes_written; +} + +mp_int_t common_hal_bleio_packet_buffer_get_incoming_packet_length(bleio_packet_buffer_obj_t *self) { + // If this PacketBuffer is coming from a remote service via NOTIFY or INDICATE + // the maximum size is what can be sent in one + // BLE packet. But we must be connected to know that value. + // + // Otherwise it can be as long as the characteristic + // will permit, whether or not we're connected. + + if (self->characteristic == NULL) { + return -1; + } + + if (self->characteristic->service != NULL && + self->characteristic->service->is_remote && + (common_hal_bleio_characteristic_get_properties(self->characteristic) & + (CHAR_PROP_INDICATE | CHAR_PROP_NOTIFY))) { + // We are talking to a remote service, and data is arriving via NOTIFY or INDICATE. + if (self->conn_handle != BLEIO_HANDLE_INVALID) { + bleio_connection_internal_t *connection = bleio_conn_handle_to_connection(self->conn_handle); + if (connection) { + return common_hal_bleio_connection_get_max_packet_length(connection); + } + } + // There's no current connection, so we don't know the MTU, and + // we can't tell what the largest incoming packet length would be. + return -1; + } + return self->characteristic->max_length; +} + +mp_int_t common_hal_bleio_packet_buffer_get_outgoing_packet_length(bleio_packet_buffer_obj_t *self) { + // If we are sending data via NOTIFY or INDICATE, the maximum size + // is what can be sent in one BLE packet. But we must be connected + // to know that value. + // + // Otherwise it can be as long as the characteristic + // will permit, whether or not we're connected. + + if (self->characteristic == NULL) { + return -1; + } + + if (self->characteristic->service != NULL && + !self->characteristic->service->is_remote && + (common_hal_bleio_characteristic_get_properties(self->characteristic) & + (CHAR_PROP_INDICATE | CHAR_PROP_NOTIFY))) { + // We are sending to a client, via NOTIFY or INDICATE. + if (self->conn_handle != BLEIO_HANDLE_INVALID) { + bleio_connection_internal_t *connection = bleio_conn_handle_to_connection(self->conn_handle); + if (connection) { + return MIN(MIN(common_hal_bleio_connection_get_max_packet_length(connection), + self->max_packet_size), + self->characteristic->max_length); + } + } + // There's no current connection, so we don't know the MTU, and + // we can't tell what the largest outgoing packet length would be. + return -1; + } + // If we are talking to a remote service, we'll be bound by the MTU. (We don't actually + // know the max size of the remote characteristic.) + if (self->characteristic->service != NULL && + self->characteristic->service->is_remote) { + // We are talking to a remote service so we're writing. + if (self->conn_handle != BLEIO_HANDLE_INVALID) { + bleio_connection_internal_t *connection = bleio_conn_handle_to_connection(self->conn_handle); + if (connection) { + return MIN(common_hal_bleio_connection_get_max_packet_length(connection), + self->max_packet_size); + } + } + } + return MIN(self->characteristic->max_length, self->max_packet_size); +} + +void common_hal_bleio_packet_buffer_flush(bleio_packet_buffer_obj_t *self) { + while ((self->pending_size != 0 || + self->packet_queued) && + self->conn_handle != BLEIO_HANDLE_INVALID && + !mp_hal_is_interrupted()) { + RUN_BACKGROUND_TASKS; + } +} + +bool common_hal_bleio_packet_buffer_deinited(bleio_packet_buffer_obj_t *self) { + return self->characteristic == NULL; +} + +void common_hal_bleio_packet_buffer_deinit(bleio_packet_buffer_obj_t *self) { + if (!common_hal_bleio_packet_buffer_deinited(self)) { + ble_event_remove_handler(packet_buffer_on_ble_client_evt, self); + } +} diff --git a/ports/espressif/common-hal/_bleio/PacketBuffer.h b/ports/espressif/common-hal/_bleio/PacketBuffer.h new file mode 100644 index 0000000000..6ecc1a69b2 --- /dev/null +++ b/ports/espressif/common-hal/_bleio/PacketBuffer.h @@ -0,0 +1,52 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019-2020 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_PACKETBUFFER_H +#define MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_PACKETBUFFER_H + +#include "py/ringbuf.h" +#include "shared-bindings/_bleio/Characteristic.h" + +typedef struct { + mp_obj_base_t base; + bleio_characteristic_obj_t *characteristic; + // Ring buffer storing consecutive incoming values. + ringbuf_t ringbuf; + // Two outgoing buffers to alternate between. One will be queued for transmission by the SD and + // the other is waiting to be queued and can be extended. + uint32_t *outgoing[2]; + volatile uint16_t pending_size; + // We remember the conn_handle so we can do a NOTIFY/INDICATE to a client. + // We can find out the conn_handle on a Characteristic write or a CCCD write (but not a read). + volatile uint16_t conn_handle; + uint16_t max_packet_size; + uint8_t pending_index; + uint8_t write_type; + bool client; + bool packet_queued; +} bleio_packet_buffer_obj_t; + +#endif // MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_PACKETBUFFER_H diff --git a/ports/espressif/common-hal/_bleio/Service.c b/ports/espressif/common-hal/_bleio/Service.c new file mode 100644 index 0000000000..7aff2905e3 --- /dev/null +++ b/ports/espressif/common-hal/_bleio/Service.c @@ -0,0 +1,88 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Dan Halbert for Adafruit Industries + * Copyright (c) 2018 Artur Pacholec + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "py/runtime.h" +#include "common-hal/_bleio/__init__.h" +#include "shared-bindings/_bleio/Characteristic.h" +#include "shared-bindings/_bleio/Descriptor.h" +#include "shared-bindings/_bleio/Service.h" +#include "shared-bindings/_bleio/Adapter.h" + +#include "host/ble_gatt.h" + +uint32_t _common_hal_bleio_service_construct(bleio_service_obj_t *self, bleio_uuid_obj_t *uuid, bool is_secondary, mp_obj_list_t *characteristic_list) { + self->handle = 0xFFFF; + self->uuid = uuid; + self->characteristic_list = characteristic_list; + self->is_remote = false; + self->connection = NULL; + self->is_secondary = is_secondary; + return 0; +} + +void common_hal_bleio_service_construct(bleio_service_obj_t *self, bleio_uuid_obj_t *uuid, bool is_secondary) { + mp_raise_NotImplementedError(NULL); + _common_hal_bleio_service_construct(self, uuid, is_secondary, + mp_obj_new_list(0, NULL)); +} + +void bleio_service_from_connection(bleio_service_obj_t *self, mp_obj_t connection) { + self->handle = BLEIO_HANDLE_INVALID; + self->uuid = NULL; + self->characteristic_list = mp_obj_new_list(0, NULL); + self->is_remote = true; + self->is_secondary = false; + self->connection = connection; +} + +bleio_uuid_obj_t *common_hal_bleio_service_get_uuid(bleio_service_obj_t *self) { + return self->uuid; +} + +mp_obj_tuple_t *common_hal_bleio_service_get_characteristics(bleio_service_obj_t *self) { + return mp_obj_new_tuple(self->characteristic_list->len, self->characteristic_list->items); +} + +bool common_hal_bleio_service_get_is_remote(bleio_service_obj_t *self) { + return self->is_remote; +} + +bool common_hal_bleio_service_get_is_secondary(bleio_service_obj_t *self) { + return self->is_secondary; +} + +void common_hal_bleio_service_add_characteristic(bleio_service_obj_t *self, + bleio_characteristic_obj_t *characteristic, + mp_buffer_info_t *initial_value_bufinfo, + const char *user_description) { + + #if CIRCUITPY_VERBOSE_BLE + mp_printf(&mp_plat_print, "Char handle %x user %x cccd %x sccd %x\n", characteristic->handle, characteristic->user_desc_handle, characteristic->cccd_handle, characteristic->sccd_handle); + #endif + + mp_obj_list_append(self->characteristic_list, MP_OBJ_FROM_PTR(characteristic)); +} diff --git a/ports/espressif/common-hal/_bleio/Service.h b/ports/espressif/common-hal/_bleio/Service.h new file mode 100644 index 0000000000..6c1688df30 --- /dev/null +++ b/ports/espressif/common-hal/_bleio/Service.h @@ -0,0 +1,53 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2018 Dan Halbert for Adafruit Industries + * Copyright (c) 2018 Artur Pacholec + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_SERVICE_H +#define MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_SERVICE_H + +#include "py/objlist.h" +#include "common-hal/_bleio/UUID.h" + +typedef struct bleio_service_obj { + mp_obj_base_t base; + // Handle for the local service. + uint16_t handle; + // True if created during discovery. + bool is_remote; + bool is_secondary; + bleio_uuid_obj_t *uuid; + // The connection object is set only when this is a remote service. + // A local service doesn't know the connection. + mp_obj_t connection; + mp_obj_list_t *characteristic_list; + // Range of attribute handles of this remote service. + uint16_t start_handle; + uint16_t end_handle; +} bleio_service_obj_t; + +void bleio_service_from_connection(bleio_service_obj_t *self, mp_obj_t connection); + +#endif // MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_SERVICE_H diff --git a/ports/espressif/common-hal/_bleio/UUID.c b/ports/espressif/common-hal/_bleio/UUID.c new file mode 100644 index 0000000000..8f0866412c --- /dev/null +++ b/ports/espressif/common-hal/_bleio/UUID.c @@ -0,0 +1,69 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2018 Dan Halbert for Adafruit Industries + * Copyright (c) 2018 Artur Pacholec + * Copyright (c) 2016 Glenn Ruben Bakke + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include + +#include "py/runtime.h" +#include "common-hal/_bleio/UUID.h" +#include "shared-bindings/_bleio/UUID.h" +#include "shared-bindings/_bleio/__init__.h" +#include "shared-bindings/_bleio/Adapter.h" + +// If uuid128 is NULL, this is a Bluetooth SIG 16-bit UUID. +// If uuid128 is not NULL, it's a 128-bit (16-byte) UUID, with bytes 12 and 13 zero'd out, where +// the 16-bit part goes. Those 16 bits are passed in uuid16. +void common_hal_bleio_uuid_construct(bleio_uuid_obj_t *self, mp_int_t uuid16, const uint8_t uuid128[16]) { + if (uuid128 == NULL) { + ble_uuid_init_from_buf(&self->nimble_ble_uuid, (uint8_t *)&uuid16, 2); + } else { + ble_uuid_init_from_buf(&self->nimble_ble_uuid, uuid128, 16); + self->nimble_ble_uuid.u128.value[12] = uuid16 & 0xff; + self->nimble_ble_uuid.u128.value[13] = (uuid16 >> 8) & 0xff; + } +} + +uint32_t common_hal_bleio_uuid_get_size(bleio_uuid_obj_t *self) { + return self->nimble_ble_uuid.u.type == BLE_UUID_TYPE_16 ? 16 : 128; +} + +uint32_t common_hal_bleio_uuid_get_uuid16(bleio_uuid_obj_t *self) { + return self->nimble_ble_uuid.u16.value; +} + +void common_hal_bleio_uuid_get_uuid128(bleio_uuid_obj_t *self, uint8_t uuid128[16]) { + memcpy(uuid128, self->nimble_ble_uuid.u128.value, 16); +} + +void common_hal_bleio_uuid_pack_into(bleio_uuid_obj_t *self, uint8_t *buf) { + if (self->nimble_ble_uuid.u.type == BLE_UUID_TYPE_16) { + buf[0] = self->nimble_ble_uuid.u16.value & 0xff; + buf[1] = self->nimble_ble_uuid.u16.value >> 8; + } else { + common_hal_bleio_uuid_get_uuid128(self, buf); + } +} diff --git a/ports/espressif/common-hal/_bleio/UUID.h b/ports/espressif/common-hal/_bleio/UUID.h new file mode 100644 index 0000000000..166088ed96 --- /dev/null +++ b/ports/espressif/common-hal/_bleio/UUID.h @@ -0,0 +1,49 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Dan Halbert for Adafruit Industries + * Copyright (c) 2018 Artur Pacholec + * Copyright (c) 2016 Glenn Ruben Bakke + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_UUID_H +#define MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_UUID_H + +#include "py/obj.h" + +#include "host/ble_uuid.h" + +typedef struct { + mp_obj_base_t base; + // Use the native way of storing UUID's: + // - ble_uuid_t.uuid is a 16-bit uuid. + // - ble_uuid_t.type is BLE_UUID_TYPE_BLE if it's a 16-bit Bluetooth SIG UUID. + // or is BLE_UUID_TYPE_VENDOR_BEGIN and higher, which indexes into a table of registered + // 128-bit UUIDs. + ble_uuid_any_t nimble_ble_uuid; +} bleio_uuid_obj_t; + +void bleio_uuid_construct_from_nrf_ble_uuid(bleio_uuid_obj_t *self, ble_uuid_t *nrf_uuid); +void bleio_uuid_convert_to_nrf_ble_uuid(bleio_uuid_obj_t *self, ble_uuid_t *nrf_uuid); + +#endif // MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_UUID_H diff --git a/ports/espressif/common-hal/_bleio/__init__.c b/ports/espressif/common-hal/_bleio/__init__.c new file mode 100644 index 0000000000..7eba47d6a1 --- /dev/null +++ b/ports/espressif/common-hal/_bleio/__init__.c @@ -0,0 +1,134 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2018 Dan Halbert for Adafruit Industries + * Copyright (c) 2018 Artur Pacholec + * Copyright (c) 2016 Glenn Ruben Bakke + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include + +#include "py/runtime.h" +#include "shared-bindings/_bleio/__init__.h" +#include "shared-bindings/_bleio/Adapter.h" +#include "shared-bindings/_bleio/Characteristic.h" +#include "shared-bindings/_bleio/Connection.h" +#include "shared-bindings/_bleio/Descriptor.h" +#include "shared-bindings/_bleio/Service.h" +#include "shared-bindings/_bleio/UUID.h" +#include "supervisor/shared/bluetooth/bluetooth.h" + +#include "common-hal/_bleio/__init__.h" +// #include "common-hal/_bleio/bonding.h" +#include "common-hal/_bleio/ble_events.h" + +// Turn off BLE on a reset or reload. +void bleio_reset() { + // Set this explicitly to save data. + common_hal_bleio_adapter_obj.base.type = &bleio_adapter_type; + if (!common_hal_bleio_adapter_get_enabled(&common_hal_bleio_adapter_obj)) { + return; + } + + supervisor_stop_bluetooth(); + ble_event_reset(); + bleio_adapter_reset(&common_hal_bleio_adapter_obj); + common_hal_bleio_adapter_set_enabled(&common_hal_bleio_adapter_obj, false); + supervisor_start_bluetooth(); +} + +// The singleton _bleio.Adapter object, bound to _bleio.adapter +// It currently only has properties and no state. Inited by bleio_reset +bleio_adapter_obj_t common_hal_bleio_adapter_obj; + +void bleio_background(void) { +} + +void common_hal_bleio_gc_collect(void) { + bleio_adapter_gc_collect(&common_hal_bleio_adapter_obj); +} + +void check_nimble_error(int rc, const char *file, size_t line) { + if (rc == NIMBLE_OK) { + return; + } + switch (rc) { + case BLE_HS_ENOMEM: + mp_raise_msg(&mp_type_MemoryError, translate("Nimble out of memory")); + return; + case BLE_HS_ETIMEOUT: + mp_raise_msg(&mp_type_TimeoutError, NULL); + return; + case BLE_HS_EINVAL: + mp_raise_ValueError(translate("Invalid BLE parameter")); + return; + case BLE_HS_ENOTCONN: + mp_raise_ConnectionError(translate("Not connected")); + return; + default: + #if CIRCUITPY_VERBOSE_BLE + if (file) { + mp_raise_bleio_BluetoothError(translate("Unknown system firmware error at %s:%d: %d"), file, line, rc); + } + #else + (void)file; + (void)line; + mp_raise_bleio_BluetoothError(translate("Unknown system firmware error: %d"), rc); + #endif + + break; + } +} + +void check_ble_error(int error_code, const char *file, size_t line) { + if (error_code == BLE_ERR_SUCCESS) { + return; + } + switch (error_code) { + default: + #if CIRCUITPY_VERBOSE_BLE + if (file) { + mp_raise_bleio_BluetoothError(translate("Unknown BLE error at %s:%d: %d"), file, line, error_code); + } + #else + (void)file; + (void)line; + mp_raise_bleio_BluetoothError(translate("Unknown BLE error: %d"), error_code); + #endif + + break; + } +} + +void check_notify(BaseType_t result) { + if (result == pdTRUE) { + return; + } + mp_raise_msg(&mp_type_TimeoutError, NULL); +} + +void common_hal_bleio_check_connected(uint16_t conn_handle) { + if (conn_handle == BLEIO_HANDLE_INVALID) { + mp_raise_ConnectionError(translate("Not connected")); + } +} diff --git a/ports/espressif/common-hal/_bleio/__init__.h b/ports/espressif/common-hal/_bleio/__init__.h new file mode 100644 index 0000000000..41e9792603 --- /dev/null +++ b/ports/espressif/common-hal/_bleio/__init__.h @@ -0,0 +1,64 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2018 Dan Halbert for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_INIT_H +#define MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_INIT_H + +#include "FreeRTOS.h" + +void bleio_background(void); + +// typedef struct { +// ble_gap_enc_key_t own_enc; +// ble_gap_enc_key_t peer_enc; +// ble_gap_id_key_t peer_id; +// } bonding_keys_t; + +// We assume variable length data. +// 20 bytes max (23 - 3). +#define GATT_MAX_DATA_LENGTH (BLE_GATT_ATT_MTU_DEFAULT - 3) + +#define NIMBLE_OK (0) + +void check_nimble_error(int rc, const char *file, size_t line); +#define CHECK_NIMBLE_ERROR(rc) check_nimble_error(rc, __FILE__, __LINE__) +void check_ble_error(int error_code, const char *file, size_t line); +#define CHECK_BLE_ERROR(error_code) check_ble_error(error_code, __FILE__, __LINE__) +void check_notify(BaseType_t result); +#define CHECK_NOTIFY(result) check_notify(result) + +#define MSEC_TO_UNITS(TIME, RESOLUTION) (((TIME) * 1000) / (RESOLUTION)) +#define SEC_TO_UNITS(TIME, RESOLUTION) (((TIME) * 1000000) / (RESOLUTION)) +#define UNITS_TO_SEC(TIME, RESOLUTION) (((TIME)*(RESOLUTION)) / 1000000) +// 0.625 msecs (625 usecs) +#define ADV_INTERVAL_UNIT_FLOAT_SECS (0.000625) +// Microseconds is the base unit. The macros above know that. +#define UNIT_0_625_MS (625) +#define UNIT_1_MS (1000) +#define UNIT_1_25_MS (1250) +#define UNIT_10_MS (10000) + +#endif // MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_INIT_H diff --git a/ports/espressif/common-hal/_bleio/ble_events.c b/ports/espressif/common-hal/_bleio/ble_events.c new file mode 100644 index 0000000000..1ccd72cb61 --- /dev/null +++ b/ports/espressif/common-hal/_bleio/ble_events.c @@ -0,0 +1,116 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Dan Halbert for Adafruit Industries + * Copyright (c) 2018 Artur Pacholec + * Copyright (c) 2016 Glenn Ruben Bakke + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "common-hal/_bleio/ble_events.h" + +#include +#include + +#include "py/misc.h" +#include "py/mpstate.h" +#include "py/runtime.h" + +#if CIRCUITPY_SERIAL_BLE && CIRCUITPY_VERBOSE_BLE +#include "supervisor/shared/bluetooth/serial.h" +#endif + +void ble_event_reset(void) { + // Linked list items will be gc'd. + MP_STATE_VM(ble_event_handler_entries) = NULL; +} + +void ble_event_add_handler_entry(ble_event_handler_entry_t *entry, + ble_gap_event_fn *func, void *param) { + ble_event_handler_entry_t *it = MP_STATE_VM(ble_event_handler_entries); + while (it != NULL) { + // If event handler and its corresponding param are already on the list, don't add again. + if ((it->func == func) && (it->param == param)) { + return; + } + it = it->next; + } + entry->next = MP_STATE_VM(ble_event_handler_entries); + entry->param = param; + entry->func = func; + + MP_STATE_VM(ble_event_handler_entries) = entry; +} + +void ble_event_add_handler(ble_gap_event_fn *func, void *param) { + ble_event_handler_entry_t *it = MP_STATE_VM(ble_event_handler_entries); + while (it != NULL) { + // If event handler and its corresponding param are already on the list, don't add again. + if ((it->func == func) && (it->param == param)) { + return; + } + it = it->next; + } + + // Add a new handler to the front of the list + ble_event_handler_entry_t *handler = m_new_ll(ble_event_handler_entry_t, 1); + ble_event_add_handler_entry(handler, func, param); +} + +void ble_event_remove_handler(ble_gap_event_fn *func, void *param) { + ble_event_handler_entry_t *it = MP_STATE_VM(ble_event_handler_entries); + ble_event_handler_entry_t **prev = &MP_STATE_VM(ble_event_handler_entries); + while (it != NULL) { + if ((it->func == func) && (it->param == param)) { + // Splice out the matching handler. + *prev = it->next; + // Clear next of the removed node so it's clearly not in a list. + it->next = NULL; + return; + } + prev = &(it->next); + it = it->next; + } +} + +int ble_event_run_handlers(struct ble_gap_event *event) { + #if CIRCUITPY_SERIAL_BLE && CIRCUITPY_VERBOSE_BLE + ble_serial_disable(); + #endif + + #if CIRCUITPY_VERBOSE_BLE + mp_printf(&mp_plat_print, "BLE GAP event: 0x%04x\n", event->type); + #endif + + ble_event_handler_entry_t *it = MP_STATE_VM(ble_event_handler_entries); + bool done = false; + while (it != NULL) { + // Capture next before calling the function in case it removes itself from the list. + ble_event_handler_entry_t *next = it->next; + done = it->func(event, it->param) || done; + it = next; + } + #if CIRCUITPY_SERIAL_BLE && CIRCUITPY_VERBOSE_BLE + ble_serial_enable(); + #endif + return 0; +} diff --git a/ports/espressif/common-hal/_bleio/ble_events.h b/ports/espressif/common-hal/_bleio/ble_events.h new file mode 100644 index 0000000000..03ff351118 --- /dev/null +++ b/ports/espressif/common-hal/_bleio/ble_events.h @@ -0,0 +1,51 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Dan Halbert for Adafruit Industries + * Copyright (c) 2018 Artur Pacholec + * Copyright (c) 2016 Glenn Ruben Bakke + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL__BLEIO_BLE_EVENTS_H +#define MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL__BLEIO_BLE_EVENTS_H + +#include + +#include "host/ble_gap.h" + +typedef struct ble_event_handler_entry { + struct ble_event_handler_entry *next; + void *param; + ble_gap_event_fn *func; +} ble_event_handler_entry_t; + +void ble_event_reset(void); +void ble_event_add_handler(ble_gap_event_fn *func, void *param); +void ble_event_remove_handler(ble_gap_event_fn *func, void *param); + +// Allow for user provided entries to prevent allocations outside the VM. +void ble_event_add_handler_entry(ble_event_handler_entry_t *entry, ble_gap_event_fn *func, void *param); + +int ble_event_run_handlers(struct ble_gap_event *event); + +#endif // MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL__BLEIO_BLE_EVENTS_H diff --git a/ports/espressif/common-hal/_bleio/bonding.c b/ports/espressif/common-hal/_bleio/bonding.c new file mode 100644 index 0000000000..e7dac3cb33 --- /dev/null +++ b/ports/espressif/common-hal/_bleio/bonding.c @@ -0,0 +1,372 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Dan Halbert for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include +#include +#include + +#include "shared-bindings/_bleio/__init__.h" +#include "shared-bindings/_bleio/Adapter.h" +#include "shared-bindings/nvm/ByteArray.h" +#include "supervisor/shared/tick.h" + +#include "bonding.h" + +// Internal flash area reserved for bonding storage. +#define BONDING_PAGES_START_ADDR CIRCUITPY_BLE_CONFIG_START_ADDR +#define BONDING_PAGES_END_ADDR (CIRCUITPY_BLE_CONFIG_START_ADDR + CIRCUITPY_BLE_CONFIG_SIZE) + +// First and last four bytes are magic bytes for id and version. Data is in between. +// 'BD01' +const uint32_t BONDING_FLAG = ('1' | '0' << 8 | 'D' << 16 | 'B' << 24); + +#define BONDING_DATA_START_ADDR (BONDING_PAGES_START_ADDR + sizeof(BONDING_FLAG)) +#define BONDING_DATA_END_ADDR (BONDING_PAGES_END_ADDR - sizeof(BONDING_FLAG)) + +#define BONDING_START_FLAG_ADDR BONDING_PAGES_START_ADDR +#define BONDING_END_FLAG_ADDR BONDING_DATA_END_ADDR + +// Save both system and user service info. +#define SYS_ATTR_FLAGS (BLE_GATTS_SYS_ATTR_FLAG_SYS_SRVCS | BLE_GATTS_SYS_ATTR_FLAG_USR_SRVCS) + +#if BONDING_DEBUG +void bonding_print_block(bonding_block_t *block) { + printf("at 0x%08lx: is_central: %1d, type: 0x%x, ediv: 0x%04x, data_length: %d\n", + (uint32_t)block, block->is_central, block->type, block->ediv, block->data_length); +} + +void bonding_print_keys(bonding_keys_t *keys) { + for (size_t i = 0; i < sizeof(bonding_keys_t); i++) { + printf("%x", ((uint8_t *)keys)[i]); + } + printf("\n"); +} +#endif + +STATIC size_t compute_block_size(uint16_t data_length) { + // Round data size up to the nearest 32-bit address. + return sizeof(bonding_block_t) + ((data_length + 3) & ~0x3); +} + +void bonding_erase_storage(void) { + // Erase all pages in the bonding area. + for (uint32_t page_address = BONDING_PAGES_START_ADDR; + page_address < BONDING_PAGES_END_ADDR; + page_address += FLASH_PAGE_SIZE) { + // Argument is page number, not address. + sd_flash_page_erase_sync(page_address / FLASH_PAGE_SIZE); + } + // Write marker words at the beginning and the end of the bonding area. + uint32_t flag = BONDING_FLAG; + sd_flash_write_sync((uint32_t *)BONDING_START_FLAG_ADDR, &flag, 1); + sd_flash_write_sync((uint32_t *)BONDING_END_FLAG_ADDR, &flag, 1); +} + +// Given NULL to start or block address, return the address of the next valid block. +// The last block returned is the unused block at the end. +// Return NULL if we have run off the end of the bonding space. + +STATIC bonding_block_t *next_block(bonding_block_t *block) { + while (1) { + // Advance to next block. + if (block == NULL) { + return (bonding_block_t *)BONDING_DATA_START_ADDR; + } else if (block->type == BLOCK_UNUSED) { + // Already at last block (the unused block). + return NULL; + } + + // Advance to next block. + block = (bonding_block_t *)((uint8_t *)block + compute_block_size(block->data_length)); + + if (block >= (bonding_block_t *)BONDING_DATA_END_ADDR) { + // Went past end of bonding space. + return NULL; + } + if (block->type != BLOCK_INVALID) { + // Found an empty or a valid block. + return block; + } + // Invalid block (was erased); try again. + } +} + +// Find the block with given is_central, type and ediv value. +// If type == BLOCK_UNUSED, ediv is ignored and the the sole unused block at the end is returned. +// If not found, return NULL. +STATIC bonding_block_t *find_existing_block(bool is_central, bonding_block_type_t type, uint16_t ediv) { + bonding_block_t *block = NULL; + while (1) { + block = next_block(block); + if (block == NULL) { + return NULL; + } + // If types match, and block is unused, just return it. + // Otherwise check that is_central and ediv match. + if (type == block->type) { + if (type == BLOCK_UNUSED || + (is_central == block->is_central && ediv == block->ediv)) { + return block; + } + } + } +} + +size_t bonding_peripheral_bond_count(void) { + bonding_block_t *block = NULL; + size_t count = 0; + while (1) { + block = next_block(block); + if (block == NULL) { + return count; + } + if (block->type != BLOCK_UNUSED && block->type != BLOCK_INVALID && !block->is_central) { + count++; + } + } +} + +// Get an empty block large enough to store data_length data. +STATIC bonding_block_t *find_unused_block(uint16_t data_length) { + bonding_block_t *unused_block = find_existing_block(true, BLOCK_UNUSED, EDIV_INVALID); + // If no more room, erase all existing blocks and start over. + if (!unused_block || + (uint8_t *)unused_block + compute_block_size(data_length) >= (uint8_t *)BONDING_DATA_END_ADDR) { + bonding_erase_storage(); + unused_block = (bonding_block_t *)BONDING_DATA_START_ADDR; + } + return unused_block; +} + +// Set the header word to all 0's, to mark the block as invalid. +// We don't change data_length, so we can still skip over this block. +STATIC void invalidate_block(bonding_block_t *block) { + uint32_t zero = 0; + sd_flash_write_sync((uint32_t *)block, &zero, 1); +} + +// Write bonding block header. +STATIC void write_block_header(bonding_block_t *dest_block, bonding_block_t *source_block_header) { + sd_flash_write_sync((uint32_t *)dest_block, (uint32_t *)source_block_header, sizeof(bonding_block_t) / 4); +} + +// Write variable-length data at end of bonding block. +STATIC void write_block_data(bonding_block_t *dest_block, uint8_t *data, uint16_t data_length) { + // Minimize the number of writes. Datasheet says no more than two writes per word before erasing again. + + // Start writing after the current header. + uint32_t *flash_word_p = (uint32_t *)((uint8_t *)dest_block + sizeof(bonding_block_t)); + while (1) { + uint32_t word = 0xffffffff; + memcpy(&word, data, data_length >= 4 ? 4 : data_length); + sd_flash_write_sync(flash_word_p, &word, 1); + if (data_length <= 4) { + break; + } + data_length -= 4; + data += 4; + // Increment by word size. + flash_word_p++; + } +} + +STATIC void write_sys_attr_block(bleio_connection_internal_t *connection) { + uint16_t length = 0; + // First find out how big a buffer we need, then fetch the data. + if (sd_ble_gatts_sys_attr_get(connection->conn_handle, NULL, &length, SYS_ATTR_FLAGS) != NRF_SUCCESS) { + return; + } + uint8_t sys_attr[length]; + if (sd_ble_gatts_sys_attr_get(connection->conn_handle, sys_attr, &length, SYS_ATTR_FLAGS) != NRF_SUCCESS) { + return; + } + + // Is there an existing sys_attr block that matches the current sys_attr data? + bonding_block_t *existing_block = + find_existing_block(connection->is_central, BLOCK_SYS_ATTR, connection->ediv); + if (existing_block) { + if (length == existing_block->data_length && + memcmp(sys_attr, existing_block->data, length) == 0) { + // Identical block found. No need to store again. + return; + } + // Data doesn't match. Invalidate block and store a new one. + invalidate_block(existing_block); + } + + bonding_block_t block_header = { + .is_central = connection->is_central, + .type = BLOCK_SYS_ATTR, + .ediv = connection->ediv, + .conn_handle = connection->conn_handle, + .data_length = length, + }; + bonding_block_t *new_block = find_unused_block(length); + write_block_header(new_block, &block_header); + write_block_data(new_block, sys_attr, length); + return; +} + +STATIC void write_keys_block(bleio_connection_internal_t *connection) { + uint16_t const ediv = connection->is_central + ? connection->bonding_keys.peer_enc.master_id.ediv + : connection->bonding_keys.own_enc.master_id.ediv; + + // Is there an existing keys block that matches the ediv? + bonding_block_t *existing_block = find_existing_block(connection->is_central, BLOCK_KEYS, ediv); + if (existing_block) { + if (existing_block->data_length == sizeof(bonding_keys_t) && + memcmp(existing_block->data, &connection->bonding_keys, sizeof(bonding_keys_t)) == 0) { + // Identical block found. No need to store again. + return; + } + // Data doesn't match. Invalidate block and store a new one. + invalidate_block(existing_block); + } + // Invalidate any existing blocks that match the peer address. + existing_block = next_block(NULL); + while (existing_block != NULL) { + if (existing_block->type == BLOCK_KEYS && connection->is_central == existing_block->is_central && + existing_block->data_length == sizeof(bonding_keys_t)) { + const ble_gap_addr_t *existing_peer = &((const bonding_keys_t *)existing_block->data)->peer_id.id_addr_info; + const ble_gap_addr_t *connecting_peer = &connection->bonding_keys.peer_id.id_addr_info; + if (memcmp(existing_peer->addr, connecting_peer->addr, 6) == 0 && + memcmp(existing_block->data, &connection->bonding_keys, sizeof(bonding_keys_t)) != 0) { + // Mismatched block found. Invalidate it. + invalidate_block(existing_block); + } + } + existing_block = next_block(existing_block); + } + + bonding_block_t block_header = { + .is_central = connection->is_central, + .type = BLOCK_KEYS, + .ediv = ediv, + .conn_handle = connection->conn_handle, + .data_length = sizeof(bonding_keys_t), + }; + bonding_block_t *new_block = find_unused_block(sizeof(bonding_keys_t)); + write_block_header(new_block, &block_header); + write_block_data(new_block, (uint8_t *)&connection->bonding_keys, sizeof(bonding_keys_t)); +} + +void bonding_clear_keys(bonding_keys_t *bonding_keys) { + memset((uint8_t *)bonding_keys, 0, sizeof(bonding_keys_t)); +} + +void bonding_reset(void) { + if (BONDING_FLAG != *((uint32_t *)BONDING_START_FLAG_ADDR) || + BONDING_FLAG != *((uint32_t *)BONDING_END_FLAG_ADDR)) { + bonding_erase_storage(); + } +} + +// Write bonding blocks to flash. Requests have been queued during evt handlers. +void bonding_background(void) { + // A paired connection will request that its keys and CCCD values be stored. + // The CCCD store whenever a CCCD value is written. + for (size_t i = 0; i < BLEIO_TOTAL_CONNECTION_COUNT; i++) { + bleio_connection_internal_t *connection = &bleio_connections[i]; + + // Wait at least one second before saving CCCD, to consolidate + // writes that involve multiple CCCDs. For instance, for HID, + // three CCCD's are set in short succession by the HID client. + if (connection->do_bond_cccds) { + uint64_t current_ticks_ms = supervisor_ticks_ms64(); + if (current_ticks_ms - connection->do_bond_cccds_request_time >= 1000) { + write_sys_attr_block(connection); + connection->do_bond_cccds = false; + } + } + + if (connection->do_bond_keys) { + write_keys_block(connection); + connection->do_bond_keys = false; + } + } +} + +bool bonding_load_cccd_info(bool is_central, uint16_t conn_handle, uint16_t ediv) { + bonding_block_t *block = find_existing_block(is_central, BLOCK_SYS_ATTR, ediv); + if (block == NULL) { + return false; + } + + return NRF_SUCCESS == + sd_ble_gatts_sys_attr_set(conn_handle, block->data, block->data_length, SYS_ATTR_FLAGS); +} + +bool bonding_load_keys(bool is_central, uint16_t ediv, bonding_keys_t *bonding_keys) { + bonding_block_t *block = find_existing_block(is_central, BLOCK_KEYS, ediv); + if (block == NULL) { + return false; + } + if (sizeof(bonding_keys_t) != block->data_length) { + // bonding_keys_t is a fixed length, so lengths should match. + return false; + } + + memcpy(bonding_keys, block->data, block->data_length); + return true; +} + +size_t bonding_load_identities(bool is_central, const ble_gap_id_key_t **keys, size_t max_length) { + bonding_block_t *block = NULL; + size_t len = 0; + while (len < max_length) { + block = next_block(block); + if (block == NULL) { + return len; + } + if (block->type != BLOCK_UNUSED && + block->type != BLOCK_INVALID && + block->is_central == is_central) { + if (sizeof(bonding_keys_t) != block->data_length) { + // bonding_keys_t is a fixed length, so lengths should match. + return len; + } + const bonding_keys_t *key_set = (const bonding_keys_t *)block->data; + keys[len] = &key_set->peer_id; + len++; + } + } + return len; +} + +const ble_gap_enc_key_t *bonding_load_peer_encryption_key(bool is_central, const ble_gap_addr_t *peer) { + bonding_block_t *block = next_block(NULL); + while (block != NULL) { + if (block->type == BLOCK_KEYS && block->is_central == is_central) { + const bonding_keys_t *key_set = (const bonding_keys_t *)block->data; + if (memcmp(key_set->peer_id.id_addr_info.addr, peer->addr, 6) == 0) { + return &key_set->peer_enc; + } + } + block = next_block(block); + } + return NULL; +} diff --git a/ports/espressif/common-hal/_bleio/bonding.h b/ports/espressif/common-hal/_bleio/bonding.h new file mode 100644 index 0000000000..9f04f10d4f --- /dev/null +++ b/ports/espressif/common-hal/_bleio/bonding.h @@ -0,0 +1,91 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Dan Halbert for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_BONDING_H +#define MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_BONDING_H + +#include +#include +#include + +#include "common-hal/_bleio/__init__.h" + +#define EDIV_INVALID (0xffff) + +#define BONDING_DEBUG (1) +#if BONDING_DEBUG + #define BONDING_DEBUG_PRINTF(...) printf(__VA_ARGS__) + #define BONDING_DEBUG_PRINT_BLOCK(block) bonding_print_block(block) + #define BONDING_DEBUG_PRINT_KEYS(keys) bonding_print_keys(keys) +#else + #define BONDING_DEBUG_PRINTF(...) + #define BONDING_DEBUG_PRINT_BLOCK(block) + #define BONDING_DEBUG_PRINT_KEYS(keys) +#endif + +// Bonding data is stored in variable-length blocks consecutively in +// erased flash (all 1's). The blocks are 32-bit aligned, though the +// data may be any number of bytes. We hop through the blocks using +// the size field to find the next block. When we hit a word that is +// all 1's, we have reached the end of the blocks. We can write a new +// block there. + +typedef enum { + BLOCK_INVALID = 0, // Ignore this block + BLOCK_KEYS = 1, // Block contains bonding keys. + BLOCK_SYS_ATTR = 2, // Block contains sys_attr values (CCCD settings, etc.). + BLOCK_UNUSED = 0xff, // Initial erased value. +} bonding_block_type_t; + +typedef struct { + bool is_central : 1; // 1 if data is for a central role. + uint16_t reserved : 7; // Not currently used + bonding_block_type_t type : 8; // What kind of data is stored in. + uint16_t ediv; // ediv value; used as a lookup key. + uint16_t conn_handle; // Connection handle: used when a BLOCK_SYS_ATTR is queued to write. + // Not used as a key, etc. + uint16_t data_length; // Length of data in bytes, including ediv, not including padding. + // End of block header. 32-bit boundary here. + uint8_t data[]; // Rest of data in the block. Needs to be 32-bit aligned. + // Block is padded to 32-bit alignment. +} bonding_block_t; + +void bonding_background(void); +void bonding_erase_storage(void); +void bonding_reset(void); +void bonding_clear_keys(bonding_keys_t *bonding_keys); +bool bonding_load_cccd_info(bool is_central, uint16_t conn_handle, uint16_t ediv); +bool bonding_load_keys(bool is_central, uint16_t ediv, bonding_keys_t *bonding_keys); +const ble_gap_enc_key_t *bonding_load_peer_encryption_key(bool is_central, const ble_gap_addr_t *peer); +size_t bonding_load_identities(bool is_central, const ble_gap_id_key_t **keys, size_t max_length); +size_t bonding_peripheral_bond_count(void); + +#if BONDING_DEBUG +void bonding_print_block(bonding_block_t *); +void bonding_print_keys(bonding_keys_t *); +#endif + +#endif // MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_BONDING_H diff --git a/ports/espressif/common-hal/alarm/__init__.c b/ports/espressif/common-hal/alarm/__init__.c index 8d12cb1b09..b24a91a03e 100644 --- a/ports/espressif/common-hal/alarm/__init__.c +++ b/ports/espressif/common-hal/alarm/__init__.c @@ -62,11 +62,6 @@ void alarm_reset(void) { esp_sleep_disable_wakeup_source(ESP_SLEEP_WAKEUP_ALL); } -// This will be reset to false by full resets when bss is cleared. Otherwise, the -// reload is due to CircuitPython and the ESP wakeup cause will be stale. This -// can happen if USB is connected after a deep sleep. -STATIC bool soft_wakeup = false; - STATIC esp_sleep_wakeup_cause_t _get_wakeup_cause(void) { // First check if the modules remember what last woke up if (alarm_pin_pinalarm_woke_this_cycle()) { @@ -80,11 +75,7 @@ STATIC esp_sleep_wakeup_cause_t _get_wakeup_cause(void) { } // If waking from true deep sleep, modules will have lost their state, // so check the deep wakeup cause manually - if (!soft_wakeup) { - soft_wakeup = true; - return esp_sleep_get_wakeup_cause(); - } - return ESP_SLEEP_WAKEUP_UNDEFINED; + return esp_sleep_get_wakeup_cause(); } bool common_hal_alarm_woken_from_sleep(void) { diff --git a/ports/espressif/common-hal/analogio/AnalogOut.c b/ports/espressif/common-hal/analogio/AnalogOut.c index 2c79124759..2b5f9d0b35 100644 --- a/ports/espressif/common-hal/analogio/AnalogOut.c +++ b/ports/espressif/common-hal/analogio/AnalogOut.c @@ -35,7 +35,9 @@ #include "shared-bindings/microcontroller/Pin.h" #include "supervisor/shared/translate.h" +#ifdef CONFIG_IDF_TARGET_ESP32S2 #include "components/driver/include/driver/dac_common.h" +#endif #include "common-hal/microcontroller/Pin.h" @@ -56,7 +58,11 @@ void common_hal_analogio_analogout_construct(analogio_analogout_obj_t *self, } bool common_hal_analogio_analogout_deinited(analogio_analogout_obj_t *self) { + #ifdef CONFIG_IDF_TARGET_ESP32S2 return self->channel == DAC_CHANNEL_MAX; + #else + return false; + #endif } void common_hal_analogio_analogout_deinit(analogio_analogout_obj_t *self) { diff --git a/ports/espressif/common-hal/busio/I2C.c b/ports/espressif/common-hal/busio/I2C.c index 81b23cb3a3..454432ab91 100644 --- a/ports/espressif/common-hal/busio/I2C.c +++ b/ports/espressif/common-hal/busio/I2C.c @@ -136,13 +136,19 @@ void common_hal_busio_i2c_deinit(busio_i2c_obj_t *self) { self->scl_pin = NULL; } -bool common_hal_busio_i2c_probe(busio_i2c_obj_t *self, uint8_t addr) { +static esp_err_t i2c_zero_length_write(busio_i2c_obj_t *self, uint8_t addr, TickType_t timeout) { + // i2c_master_write_to_device() won't do zero-length writes, so we do it by hand. i2c_cmd_handle_t cmd = i2c_cmd_link_create(); i2c_master_start(cmd); i2c_master_write_byte(cmd, addr << 1, true); i2c_master_stop(cmd); - esp_err_t result = i2c_master_cmd_begin(self->i2c_num, cmd, 10); + esp_err_t result = i2c_master_cmd_begin(self->i2c_num, cmd, timeout); i2c_cmd_link_delete(cmd); + return result; +} + +bool common_hal_busio_i2c_probe(busio_i2c_obj_t *self, uint8_t addr) { + esp_err_t result = i2c_zero_length_write(self, addr, 1); return result == ESP_OK; } @@ -163,45 +169,36 @@ void common_hal_busio_i2c_unlock(busio_i2c_obj_t *self) { self->has_lock = false; } -uint8_t common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t addr, - const uint8_t *data, size_t len, bool transmit_stop_bit) { - i2c_cmd_handle_t cmd = i2c_cmd_link_create(); - i2c_master_start(cmd); - i2c_master_write_byte(cmd, addr << 1, true); - i2c_master_write(cmd, (uint8_t *)data, len, true); - if (transmit_stop_bit) { - i2c_master_stop(cmd); +static uint8_t convert_esp_err(esp_err_t result) { + switch (result) { + case ESP_OK: + return 0; + case ESP_FAIL: + return MP_ENODEV; + case ESP_ERR_TIMEOUT: + return MP_ETIMEDOUT; + default: + return MP_EIO; } - esp_err_t result = i2c_master_cmd_begin(self->i2c_num, cmd, 100 /* wait in ticks */); - i2c_cmd_link_delete(cmd); - - if (result == ESP_OK) { - return 0; - } else if (result == ESP_FAIL) { - return MP_ENODEV; - } - return MP_EIO; } -uint8_t common_hal_busio_i2c_read(busio_i2c_obj_t *self, uint16_t addr, - uint8_t *data, size_t len) { - i2c_cmd_handle_t cmd = i2c_cmd_link_create(); - i2c_master_start(cmd); - i2c_master_write_byte(cmd, addr << 1 | 1, true); // | 1 to indicate read - if (len > 1) { - i2c_master_read(cmd, data, len - 1, 0); - } - i2c_master_read_byte(cmd, data + len - 1, 1); - i2c_master_stop(cmd); - esp_err_t result = i2c_master_cmd_begin(self->i2c_num, cmd, 100 /* wait in ticks */); - i2c_cmd_link_delete(cmd); +uint8_t common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t addr, const uint8_t *data, size_t len) { + return convert_esp_err(len == 0 + ? i2c_zero_length_write(self, addr, 100) + : i2c_master_write_to_device(self->i2c_num, (uint8_t)addr, data, len, 100 /* wait in ticks */) + ); +} - if (result == ESP_OK) { - return 0; - } else if (result == ESP_FAIL) { - return MP_ENODEV; - } - return MP_EIO; +uint8_t common_hal_busio_i2c_read(busio_i2c_obj_t *self, uint16_t addr, uint8_t *data, size_t len) { + return convert_esp_err( + i2c_master_read_from_device(self->i2c_num, (uint8_t)addr, data, len, 100 /* wait in ticks */)); +} + +uint8_t common_hal_busio_i2c_write_read(busio_i2c_obj_t *self, uint16_t addr, + uint8_t *out_data, size_t out_len, uint8_t *in_data, size_t in_len) { + return convert_esp_err( + i2c_master_write_read_device(self->i2c_num, (uint8_t)addr, + out_data, out_len, in_data, in_len, 100 /* wait in ticks */)); } void common_hal_busio_i2c_never_reset(busio_i2c_obj_t *self) { diff --git a/ports/espressif/common-hal/busio/SPI.c b/ports/espressif/common-hal/busio/SPI.c index 09c29084ac..0b4b0d7f1a 100644 --- a/ports/espressif/common-hal/busio/SPI.c +++ b/ports/espressif/common-hal/busio/SPI.c @@ -73,7 +73,7 @@ static void set_spi_config(busio_spi_obj_t *self, void common_hal_busio_spi_construct(busio_spi_obj_t *self, const mcu_pin_obj_t *clock, const mcu_pin_obj_t *mosi, - const mcu_pin_obj_t *miso) { + const mcu_pin_obj_t *miso, bool half_duplex) { const spi_bus_config_t bus_config = { .mosi_io_num = mosi != NULL ? mosi->number : -1, @@ -83,6 +83,10 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self, .quadhd_io_num = -1, }; + if (half_duplex) { + mp_raise_NotImplementedError(translate("Half duplex SPI is not implemented")); + } + for (spi_host_device_t host_id = SPI2_HOST; host_id < SOC_SPI_PERIPH_NUM; host_id++) { if (spi_bus_is_free(host_id)) { self->host_id = host_id; diff --git a/ports/espressif/common-hal/countio/Counter.c b/ports/espressif/common-hal/countio/Counter.c index 418a8ae4d4..d18196051f 100644 --- a/ports/espressif/common-hal/countio/Counter.c +++ b/ports/espressif/common-hal/countio/Counter.c @@ -32,7 +32,7 @@ #include "supervisor/shared/translate.h" void common_hal_countio_counter_construct(countio_counter_obj_t *self, - const mcu_pin_obj_t *pin) { + const mcu_pin_obj_t *pin, countio_edge_t edge, digitalio_pull_t pull) { claim_pin(pin); // Prepare configuration for the PCNT unit @@ -41,9 +41,10 @@ void common_hal_countio_counter_construct(countio_counter_obj_t *self, .pulse_gpio_num = pin->number, .ctrl_gpio_num = PCNT_PIN_NOT_USED, .channel = PCNT_CHANNEL_0, - // What to do on the positive / negative edge of pulse input? - .pos_mode = PCNT_COUNT_INC, // Count up on the positive edge - .neg_mode = PCNT_COUNT_DIS, // Keep the counter value on the negative edge + // What to do on the rising / falling edge of pulse input? + // If EDGE_RISE_AND_FALL, both modeswill do PCNT_COUNT_INC. + .pos_mode = (edge == EDGE_FALL) ? PCNT_COUNT_DIS : PCNT_COUNT_INC, // Count up unless only fall + .neg_mode = (edge == EDGE_RISE) ? PCNT_COUNT_DIS : PCNT_COUNT_INC, // Count up unless only rise }; // Initialize PCNT unit @@ -53,6 +54,15 @@ void common_hal_countio_counter_construct(countio_counter_obj_t *self, } self->pin = pin->number; + + gpio_pullup_dis(pin->number); + gpio_pulldown_dis(pin->number); + if (pull == PULL_UP) { + gpio_pullup_en(pin->number); + } else if (pull == PULL_DOWN) { + gpio_pulldown_en(pin->number); + } + self->unit = (pcnt_unit_t)unit; } @@ -79,7 +89,3 @@ void common_hal_countio_counter_set_count(countio_counter_obj_t *self, self->count = new_count; pcnt_counter_clear(self->unit); } - -void common_hal_countio_counter_reset(countio_counter_obj_t *self) { - common_hal_countio_counter_set_count(self, 0); -} diff --git a/ports/espressif/common-hal/digitalio/DigitalInOut.c b/ports/espressif/common-hal/digitalio/DigitalInOut.c index 24c5d5110d..bf52965d28 100644 --- a/ports/espressif/common-hal/digitalio/DigitalInOut.c +++ b/ports/espressif/common-hal/digitalio/DigitalInOut.c @@ -71,7 +71,7 @@ void common_hal_digitalio_digitalinout_deinit(digitalio_digitalinout_obj_t *self void common_hal_digitalio_digitalinout_switch_to_input( digitalio_digitalinout_obj_t *self, digitalio_pull_t pull) { common_hal_digitalio_digitalinout_set_pull(self, pull); - gpio_set_direction(self->pin->number, GPIO_MODE_DEF_INPUT); + gpio_set_direction(self->pin->number, GPIO_MODE_INPUT); } digitalinout_result_t common_hal_digitalio_digitalinout_switch_to_output( @@ -108,11 +108,9 @@ digitalinout_result_t common_hal_digitalio_digitalinout_set_drive_mode( digitalio_digitalinout_obj_t *self, digitalio_drive_mode_t drive_mode) { gpio_num_t number = self->pin->number; - gpio_mode_t mode; + gpio_mode_t mode = GPIO_MODE_OUTPUT; if (drive_mode == DRIVE_MODE_OPEN_DRAIN) { - mode = GPIO_MODE_DEF_OD; - } else { - mode = GPIO_MODE_DEF_OUTPUT; + mode |= GPIO_MODE_OUTPUT_OD; } esp_err_t result = gpio_set_direction(number, mode); if (result != ESP_OK) { diff --git a/ports/espressif/common-hal/microcontroller/Pin.c b/ports/espressif/common-hal/microcontroller/Pin.c index 462fef3ca1..828d85d5ee 100644 --- a/ports/espressif/common-hal/microcontroller/Pin.c +++ b/ports/espressif/common-hal/microcontroller/Pin.c @@ -36,20 +36,6 @@ STATIC uint32_t never_reset_pins[2]; STATIC uint32_t in_use[2]; -STATIC void floating_gpio_reset(gpio_num_t pin_number) { - // This is the same as gpio_reset_pin(), but without the pullup. - // Note that gpio_config resets the iomatrix to GPIO_FUNC as well. - gpio_config_t cfg = { - .pin_bit_mask = BIT64(pin_number), - .mode = GPIO_MODE_DISABLE, - .pull_up_en = false, - .pull_down_en = false, - .intr_type = GPIO_INTR_DISABLE, - }; - gpio_config(&cfg); - PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[pin_number], 0); -} - void never_reset_pin_number(gpio_num_t pin_number) { if (pin_number == NO_PIN) { return; @@ -64,6 +50,52 @@ void common_hal_never_reset_pin(const mcu_pin_obj_t *pin) { never_reset_pin_number(pin->number); } +MP_WEAK bool espressif_board_reset_pin_number(gpio_num_t pin_number) { + return false; +} + +STATIC void _reset_pin(gpio_num_t pin_number) { + #if defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32S3) + // Never ever reset pins used for flash and RAM. + if (26 <= pin_number && pin_number <= 32) { + return; + } + #ifdef CONFIG_SPIRAM_MODE_OCT + // Octal DQ4-DQ7 and DQS/DM + if (33 <= pin_number && pin_number <= 37) { + return; + } + #endif + + #if CIRCUITPY_USB + // Never reset USB pins. + if (pin_number == 19 || pin_number == 20) { + return; + } + #endif + #elif defined(CONFIG_IDF_TARGET_ESP32C3) + // Never ever reset pins used for flash and RAM. + if (11 <= pin_number && pin_number <= 17) { + return; + } + #endif + + // Give the board a chance to reset the pin in a particular way. + if (espressif_board_reset_pin_number(pin_number)) { + return; + } + + gpio_reset_pin(pin_number); + + #ifdef DOUBLE_TAP_PIN + // Pull the double tap pin down so that resets come back to CircuitPython. + if (pin_number == DOUBLE_TAP_PIN->number) { + gpio_pullup_dis(pin_number); + gpio_pulldown_en(pin_number); + } + #endif +} + // Mark pin as free and return it to a quiescent state. void reset_pin_number(gpio_num_t pin_number) { if (pin_number == NO_PIN) { @@ -72,7 +104,7 @@ void reset_pin_number(gpio_num_t pin_number) { never_reset_pins[pin_number / 32] &= ~(1 << pin_number % 32); in_use[pin_number / 32] &= ~(1 << pin_number % 32); - floating_gpio_reset(pin_number); + _reset_pin(pin_number); } void common_hal_mcu_pin_reset_number(uint8_t i) { @@ -93,10 +125,10 @@ void reset_all_pins(void) { (never_reset_pins[i / 32] & (1 << i % 32)) != 0) { continue; } - floating_gpio_reset(i); + _reset_pin(i); } - in_use[0] = 0; - in_use[1] = 0; + in_use[0] = never_reset_pins[0]; + in_use[1] = never_reset_pins[1]; } void claim_pin_number(gpio_num_t pin_number) { diff --git a/ports/espressif/common-hal/microcontroller/Pin.h b/ports/espressif/common-hal/microcontroller/Pin.h index 1a5e66997f..e74346ef65 100644 --- a/ports/espressif/common-hal/microcontroller/Pin.h +++ b/ports/espressif/common-hal/microcontroller/Pin.h @@ -42,4 +42,10 @@ void claim_pin_number(gpio_num_t pin_number); bool pin_number_is_free(gpio_num_t pin_number); void never_reset_pin_number(gpio_num_t pin_number); +// Allow the board to reset a pin in a board-specific way. This can be used +// for LEDs or enable pins to put them in a state beside the default pull-up. +// Return true to indicate that the pin was reset. Returning false will lead to +// the port-default reset behavior. +bool espressif_board_reset_pin_number(gpio_num_t pin_number); + #endif // MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_MICROCONTROLLER_PIN_H diff --git a/ports/espressif/common-hal/microcontroller/Processor.c b/ports/espressif/common-hal/microcontroller/Processor.c index 500d1f6d3e..e4782c30ab 100644 --- a/ports/espressif/common-hal/microcontroller/Processor.c +++ b/ports/espressif/common-hal/microcontroller/Processor.c @@ -60,7 +60,13 @@ float common_hal_mcu_processor_get_voltage(void) { } uint32_t common_hal_mcu_processor_get_frequency(void) { - return 0; + #ifdef CONFIG_IDF_TARGET_ESP32C3 + return CONFIG_ESP32C3_DEFAULT_CPU_FREQ_MHZ * 1000000; + #elif defined(CONFIG_IDF_TARGET_ESP32S2) + return CONFIG_ESP32S2_DEFAULT_CPU_FREQ_MHZ * 1000000; + #elif defined(CONFIG_IDF_TARGET_ESP32S3) + return CONFIG_ESP32S3_DEFAULT_CPU_FREQ_MHZ * 1000000; + #endif } STATIC uint8_t swap_nibbles(uint8_t v) { diff --git a/ports/espressif/common-hal/neopixel_write/__init__.c b/ports/espressif/common-hal/neopixel_write/__init__.c index b63390f155..b140eff4f9 100644 --- a/ports/espressif/common-hal/neopixel_write/__init__.c +++ b/ports/espressif/common-hal/neopixel_write/__init__.c @@ -43,20 +43,23 @@ #include "py/mphal.h" #include "py/runtime.h" #include "shared-bindings/neopixel_write/__init__.h" +#include "supervisor/port.h" #include "components/driver/include/driver/rmt.h" #include "peripherals/rmt.h" -#define WS2812_T0H_NS (350) -#define WS2812_T0L_NS (1000) -#define WS2812_T1H_NS (1000) -#define WS2812_T1L_NS (350) -#define WS2812_RESET_US (280) +// 416 ns is 1/3 of the 1250ns period of a 800khz signal. +#define WS2812_T0H_NS (416) +#define WS2812_T0L_NS (416 * 2) +#define WS2812_T1H_NS (416 * 2) +#define WS2812_T1L_NS (416) static uint32_t ws2812_t0h_ticks = 0; static uint32_t ws2812_t1h_ticks = 0; static uint32_t ws2812_t0l_ticks = 0; static uint32_t ws2812_t1l_ticks = 0; +static uint64_t next_start_raw_ticks = 0; + static void IRAM_ATTR ws2812_rmt_adapter(const void *src, rmt_item32_t *dest, size_t src_size, size_t wanted_num, size_t *translated_size, size_t *item_num) { if (src == NULL || dest == NULL) { @@ -91,7 +94,7 @@ static void IRAM_ATTR ws2812_rmt_adapter(const void *src, rmt_item32_t *dest, si void common_hal_neopixel_write(const digitalio_digitalinout_obj_t *digitalinout, uint8_t *pixels, uint32_t numBytes) { // Reserve channel uint8_t number = digitalinout->pin->number; - rmt_channel_t channel = peripherals_find_and_reserve_rmt(); + rmt_channel_t channel = peripherals_find_and_reserve_rmt(TRANSMIT_MODE); if (channel == RMT_CHANNEL_MAX) { mp_raise_RuntimeError(translate("All timers in use")); } @@ -107,21 +110,29 @@ void common_hal_neopixel_write(const digitalio_digitalinout_obj_t *digitalinout, if (rmt_get_counter_clock(config.channel, &counter_clk_hz) != ESP_OK) { mp_raise_RuntimeError(translate("Could not retrieve clock")); } - float ratio = (float)counter_clk_hz / 1e9; - ws2812_t0h_ticks = (uint32_t)(ratio * WS2812_T0H_NS); - ws2812_t0l_ticks = (uint32_t)(ratio * WS2812_T0L_NS); - ws2812_t1h_ticks = (uint32_t)(ratio * WS2812_T1H_NS); - ws2812_t1l_ticks = (uint32_t)(ratio * WS2812_T1L_NS); + size_t ns_per_tick = 1e9 / counter_clk_hz; + ws2812_t0h_ticks = WS2812_T0H_NS / ns_per_tick; + ws2812_t0l_ticks = WS2812_T0L_NS / ns_per_tick; + ws2812_t1h_ticks = WS2812_T1H_NS / ns_per_tick; + ws2812_t1l_ticks = WS2812_T1L_NS / ns_per_tick; // Initialize automatic timing translator rmt_translator_init(config.channel, ws2812_rmt_adapter); + // Wait to make sure we don't append onto the last transmission. This should only be a tick or + // two. + while (port_get_raw_ticks(NULL) < next_start_raw_ticks) { + } + // Write and wait to finish if (rmt_write_sample(config.channel, pixels, (size_t)numBytes, true) != ESP_OK) { mp_raise_RuntimeError(translate("Input/output error")); } rmt_wait_tx_done(config.channel, pdMS_TO_TICKS(100)); + // Update the next start to +2 ticks. It ensures that we've gone 300+ us. + next_start_raw_ticks = port_get_raw_ticks(NULL) + 2; + // Free channel again peripherals_free_rmt(config.channel); // Swap pin back to GPIO mode diff --git a/ports/espressif/common-hal/pulseio/PulseIn.c b/ports/espressif/common-hal/pulseio/PulseIn.c index 3f5457f84b..1b29032354 100644 --- a/ports/espressif/common-hal/pulseio/PulseIn.c +++ b/ports/espressif/common-hal/pulseio/PulseIn.c @@ -107,7 +107,7 @@ void common_hal_pulseio_pulsein_construct(pulseio_pulsein_obj_t *self, const mcu } // Find a free RMT Channel and configure it - rmt_channel_t channel = peripherals_find_and_reserve_rmt(); + rmt_channel_t channel = peripherals_find_and_reserve_rmt(RECEIVE_MODE); if (channel == RMT_CHANNEL_MAX) { mp_raise_RuntimeError(translate("All timers in use")); } diff --git a/ports/espressif/common-hal/pulseio/PulseOut.c b/ports/espressif/common-hal/pulseio/PulseOut.c index 993fd9452c..773c2bf107 100644 --- a/ports/espressif/common-hal/pulseio/PulseOut.c +++ b/ports/espressif/common-hal/pulseio/PulseOut.c @@ -37,7 +37,7 @@ void common_hal_pulseio_pulseout_construct(pulseio_pulseout_obj_t *self, uint32_t frequency, uint16_t duty_cycle) { - rmt_channel_t channel = peripherals_find_and_reserve_rmt(); + rmt_channel_t channel = peripherals_find_and_reserve_rmt(TRANSMIT_MODE); if (channel == RMT_CHANNEL_MAX) { mp_raise_RuntimeError(translate("All timers in use")); } diff --git a/ports/espressif/common-hal/pwmio/PWMOut.c b/ports/espressif/common-hal/pwmio/PWMOut.c index 71cf5c19d0..9ca39c223b 100644 --- a/ports/espressif/common-hal/pwmio/PWMOut.c +++ b/ports/espressif/common-hal/pwmio/PWMOut.c @@ -32,10 +32,9 @@ #define INDEX_EMPTY 0xFF -STATIC bool not_first_reset = false; STATIC uint32_t reserved_timer_freq[LEDC_TIMER_MAX]; STATIC bool varfreq_timers[LEDC_TIMER_MAX]; -STATIC uint8_t reserved_channels[LEDC_CHANNEL_MAX]; +STATIC uint8_t reserved_channels[LEDC_CHANNEL_MAX] = { [0 ... LEDC_CHANNEL_MAX - 1] = INDEX_EMPTY}; STATIC bool never_reset_tim[LEDC_TIMER_MAX]; STATIC bool never_reset_chan[LEDC_CHANNEL_MAX]; @@ -56,7 +55,7 @@ STATIC uint32_t calculate_duty_cycle(uint32_t frequency) { void pwmout_reset(void) { for (size_t i = 0; i < LEDC_CHANNEL_MAX; i++) { - if (reserved_channels[i] != INDEX_EMPTY && not_first_reset) { + if (reserved_channels[i] != INDEX_EMPTY) { ledc_stop(LEDC_LOW_SPEED_MODE, i, 0); } if (!never_reset_chan[i]) { @@ -72,7 +71,6 @@ void pwmout_reset(void) { varfreq_timers[i] = false; } } - not_first_reset = true; } pwmout_result_t common_hal_pwmio_pwmout_construct(pwmio_pwmout_obj_t *self, diff --git a/ports/espressif/common-hal/ssl/SSLContext.c b/ports/espressif/common-hal/ssl/SSLContext.c index a94c1df1eb..866024bf00 100644 --- a/ports/espressif/common-hal/ssl/SSLContext.c +++ b/ports/espressif/common-hal/ssl/SSLContext.c @@ -29,6 +29,8 @@ #include "bindings/espidf/__init__.h" +#include "components/mbedtls/esp_crt_bundle/include/esp_crt_bundle.h" + #include "py/runtime.h" void common_hal_ssl_sslcontext_construct(ssl_sslcontext_obj_t *self) { @@ -47,6 +49,11 @@ ssl_sslsocket_obj_t *common_hal_ssl_sslcontext_wrap_socket(ssl_sslcontext_obj_t sock->ssl_context = self; sock->sock = socket; + // Create a copy of the ESP-TLS config object and store the server hostname + // Note that ESP-TLS will use common_name for both SNI and verification + memcpy(&sock->ssl_config, &self->ssl_config, sizeof(self->ssl_config)); + sock->ssl_config.common_name = server_hostname; + esp_tls_t *tls_handle = esp_tls_init(); if (tls_handle == NULL) { mp_raise_espidf_MemoryError(); @@ -55,6 +62,28 @@ ssl_sslsocket_obj_t *common_hal_ssl_sslcontext_wrap_socket(ssl_sslcontext_obj_t // TODO: do something with the original socket? Don't call a close on the internal LWIP. - // Should we store server hostname on the socket in case connect is called with an ip? return sock; } + +void common_hal_ssl_sslcontext_load_verify_locations(ssl_sslcontext_obj_t *self, + const char *cadata) { + self->ssl_config.crt_bundle_attach = NULL; + self->ssl_config.use_global_ca_store = false; + self->ssl_config.cacert_buf = (const unsigned char *)cadata; + self->ssl_config.cacert_bytes = strlen(cadata) + 1; +} + +void common_hal_ssl_sslcontext_set_default_verify_paths(ssl_sslcontext_obj_t *self) { + self->ssl_config.crt_bundle_attach = esp_crt_bundle_attach; + self->ssl_config.use_global_ca_store = true; + self->ssl_config.cacert_buf = NULL; + self->ssl_config.cacert_bytes = 0; +} + +bool common_hal_ssl_sslcontext_get_check_hostname(ssl_sslcontext_obj_t *self) { + return !self->ssl_config.skip_common_name; +} + +void common_hal_ssl_sslcontext_set_check_hostname(ssl_sslcontext_obj_t *self, bool value) { + self->ssl_config.skip_common_name = !value; +} diff --git a/ports/espressif/common-hal/ssl/SSLSocket.c b/ports/espressif/common-hal/ssl/SSLSocket.c index f9e13029cc..281e356d77 100644 --- a/ports/espressif/common-hal/ssl/SSLSocket.c +++ b/ports/espressif/common-hal/ssl/SSLSocket.c @@ -55,9 +55,7 @@ void common_hal_ssl_sslsocket_close(ssl_sslsocket_obj_t *self) { void common_hal_ssl_sslsocket_connect(ssl_sslsocket_obj_t *self, const char *host, size_t hostlen, uint32_t port) { - esp_tls_cfg_t *tls_config = NULL; - tls_config = &self->ssl_context->ssl_config; - int result = esp_tls_conn_new_sync(host, hostlen, port, tls_config, self->tls); + int result = esp_tls_conn_new_sync(host, hostlen, port, &self->ssl_config, self->tls); self->sock->connected = result >= 0; if (result < 0) { int esp_tls_code; @@ -66,7 +64,7 @@ void common_hal_ssl_sslsocket_connect(ssl_sslsocket_obj_t *self, if (err == ESP_ERR_MBEDTLS_SSL_SETUP_FAILED) { mp_raise_espidf_MemoryError(); - } else if (ESP_ERR_MBEDTLS_SSL_HANDSHAKE_FAILED) { + } else if (err == ESP_ERR_MBEDTLS_SSL_HANDSHAKE_FAILED) { mp_raise_OSError_msg_varg(translate("Failed SSL handshake")); } else { mp_raise_OSError_msg_varg(translate("Unhandled ESP TLS error %d %d %x %d"), esp_tls_code, flags, err, result); diff --git a/ports/espressif/common-hal/ssl/SSLSocket.h b/ports/espressif/common-hal/ssl/SSLSocket.h index dd1dcda4ac..097f19857b 100644 --- a/ports/espressif/common-hal/ssl/SSLSocket.h +++ b/ports/espressif/common-hal/ssl/SSLSocket.h @@ -39,6 +39,7 @@ typedef struct { socketpool_socket_obj_t *sock; esp_tls_t *tls; ssl_sslcontext_obj_t *ssl_context; + esp_tls_cfg_t ssl_config; } ssl_sslsocket_obj_t; #endif // MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_SSL_SSLSOCKET_H diff --git a/ports/espressif/common-hal/wifi/Radio.c b/ports/espressif/common-hal/wifi/Radio.c index 9e4b7165a4..5d4fcab417 100644 --- a/ports/espressif/common-hal/wifi/Radio.c +++ b/ports/espressif/common-hal/wifi/Radio.c @@ -36,6 +36,7 @@ #include "shared-bindings/ipaddress/IPv4Address.h" #include "shared-bindings/wifi/ScannedNetworks.h" #include "shared-bindings/wifi/AuthMode.h" +#include "shared-bindings/time/__init__.h" #include "shared-module/ipaddress/__init__.h" #include "components/esp_wifi/include/esp_wifi.h" @@ -184,7 +185,7 @@ void common_hal_wifi_radio_stop_station(wifi_radio_obj_t *self) { set_mode_station(self, false); } -void common_hal_wifi_radio_start_ap(wifi_radio_obj_t *self, uint8_t *ssid, size_t ssid_len, uint8_t *password, size_t password_len, uint8_t channel, uint8_t authmode) { +void common_hal_wifi_radio_start_ap(wifi_radio_obj_t *self, uint8_t *ssid, size_t ssid_len, uint8_t *password, size_t password_len, uint8_t channel, uint8_t authmode, uint8_t max_connections) { set_mode_ap(self, true); switch (authmode) { @@ -212,7 +213,12 @@ void common_hal_wifi_radio_start_ap(wifi_radio_obj_t *self, uint8_t *ssid, size_ config->ap.password[password_len] = 0; config->ap.channel = channel; config->ap.authmode = authmode; - config->ap.max_connection = 4; // kwarg? + + if (max_connections < 0 || max_connections > 10) { + mp_raise_ValueError(translate("max_connections must be between 0 and 10")); + } + config->ap.max_connection = max_connections; + esp_wifi_set_config(WIFI_IF_AP, config); } @@ -399,7 +405,8 @@ mp_int_t common_hal_wifi_radio_ping(wifi_radio_obj_t *self, mp_obj_t ip_address, uint32_t received = 0; uint32_t total_time_ms = 0; - while (received == 0 && total_time_ms < timeout_ms && !mp_hal_is_interrupted()) { + uint32_t start_time = common_hal_time_monotonic_ms(); + while (received == 0 && (common_hal_time_monotonic_ms() - start_time < timeout_ms) && !mp_hal_is_interrupted()) { RUN_BACKGROUND_TASKS; esp_ping_get_profile(ping, ESP_PING_PROF_DURATION, &total_time_ms, sizeof(total_time_ms)); esp_ping_get_profile(ping, ESP_PING_PROF_REPLY, &received, sizeof(received)); diff --git a/ports/espressif/esp-idf b/ports/espressif/esp-idf index ddc44956bf..2775b6e213 160000 --- a/ports/espressif/esp-idf +++ b/ports/espressif/esp-idf @@ -1 +1 @@ -Subproject commit ddc44956bf718540d5451e17e1becf6c7dffe5b8 +Subproject commit 2775b6e213a1876dd1abe4923097ca5b437397e3 diff --git a/ports/espressif/esp-idf-config/partitions-2MB-no-uf2.csv b/ports/espressif/esp-idf-config/partitions-2MB-no-uf2.csv new file mode 100644 index 0000000000..869e7ac86e --- /dev/null +++ b/ports/espressif/esp-idf-config/partitions-2MB-no-uf2.csv @@ -0,0 +1,7 @@ +# ESP-IDF Partition Table +# Name, Type, SubType, Offset, Size, Flags +# bootloader.bin,, 0x1000, 32K +# partition table,, 0x8000, 4K +nvs, data, nvs, 0x9000, 20K, +app, app, factory, 0x10000, 1408K, +user_fs, data, fat, 0x170000, 576K, diff --git a/ports/espressif/esp-idf-config/partitions-4MB-no-uf2.csv b/ports/espressif/esp-idf-config/partitions-4MB-no-uf2.csv new file mode 100644 index 0000000000..90bf05ce39 --- /dev/null +++ b/ports/espressif/esp-idf-config/partitions-4MB-no-uf2.csv @@ -0,0 +1,7 @@ +# ESP-IDF Partition Table +# Name, Type, SubType, Offset, Size, Flags +# bootloader.bin,, 0x1000, 32K +# partition table,, 0x8000, 4K +nvs, data, nvs, 0x9000, 20K, +app, app, factory, 0x10000, 2048K, +user_fs, data, fat, 0x210000, 1984K, diff --git a/ports/espressif/esp-idf-config/sdkconfig-16MB.defaults b/ports/espressif/esp-idf-config/sdkconfig-16MB.defaults index 2299feccd8..fac8ba1cad 100644 --- a/ports/espressif/esp-idf-config/sdkconfig-16MB.defaults +++ b/ports/espressif/esp-idf-config/sdkconfig-16MB.defaults @@ -1,9 +1,18 @@ -# No newlines in this file so they are preserved in the board sdkconfig. +# +# Serial flasher config +# # CONFIG_ESPTOOLPY_FLASHSIZE_1MB is not set # CONFIG_ESPTOOLPY_FLASHSIZE_2MB is not set # CONFIG_ESPTOOLPY_FLASHSIZE_4MB is not set # CONFIG_ESPTOOLPY_FLASHSIZE_8MB is not set CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y CONFIG_ESPTOOLPY_FLASHSIZE="16MB" +CONFIG_ESPTOOLPY_FLASHSIZE_DETECT=y +# end of Serial flasher config + CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="esp-idf-config/partitions-16MB.csv" -CONFIG_PARTITION_TABLE_FILENAME="esp-idf-config/partitions-16MB.csv" \ No newline at end of file +# +# Partition Table +# +CONFIG_PARTITION_TABLE_FILENAME="esp-idf-config/partitions-16MB.csv" +# end of Partition Table diff --git a/ports/espressif/esp-idf-config/sdkconfig-2MB-no-uf2.defaults b/ports/espressif/esp-idf-config/sdkconfig-2MB-no-uf2.defaults new file mode 100644 index 0000000000..7c4c4baddd --- /dev/null +++ b/ports/espressif/esp-idf-config/sdkconfig-2MB-no-uf2.defaults @@ -0,0 +1,18 @@ +# +# Serial flasher config +# +# CONFIG_ESPTOOLPY_FLASHSIZE_1MB is not set +CONFIG_ESPTOOLPY_FLASHSIZE_2MB=y +# CONFIG_ESPTOOLPY_FLASHSIZE_4MB is not set +# CONFIG_ESPTOOLPY_FLASHSIZE_8MB is not set +# CONFIG_ESPTOOLPY_FLASHSIZE_16MB is not set +CONFIG_ESPTOOLPY_FLASHSIZE="2MB" +CONFIG_ESPTOOLPY_FLASHSIZE_DETECT=y +# end of Serial flasher config + +CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="esp-idf-config/partitions-2MB-no-uf2.csv" +# +# Partition Table +# +CONFIG_PARTITION_TABLE_FILENAME="esp-idf-config/partitions-2MB-no-uf2.csv" +# end of Partition Table diff --git a/ports/espressif/esp-idf-config/sdkconfig-4MB-no-uf2.defaults b/ports/espressif/esp-idf-config/sdkconfig-4MB-no-uf2.defaults new file mode 100644 index 0000000000..2325a67296 --- /dev/null +++ b/ports/espressif/esp-idf-config/sdkconfig-4MB-no-uf2.defaults @@ -0,0 +1,18 @@ +# +# Serial flasher config +# +# CONFIG_ESPTOOLPY_FLASHSIZE_1MB is not set +# CONFIG_ESPTOOLPY_FLASHSIZE_2MB is not set +CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y +# CONFIG_ESPTOOLPY_FLASHSIZE_8MB is not set +# CONFIG_ESPTOOLPY_FLASHSIZE_16MB is not set +CONFIG_ESPTOOLPY_FLASHSIZE="4MB" +CONFIG_ESPTOOLPY_FLASHSIZE_DETECT=y +# end of Serial flasher config + +CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="esp-idf-config/partitions-4MB-no-uf2.csv" +# +# Partition Table +# +CONFIG_PARTITION_TABLE_FILENAME="esp-idf-config/partitions-4MB-no-uf2.csv" +# end of Partition Table diff --git a/ports/espressif/esp-idf-config/sdkconfig-4MB.defaults b/ports/espressif/esp-idf-config/sdkconfig-4MB.defaults index 4da90d1bcd..69f15ebe7b 100644 --- a/ports/espressif/esp-idf-config/sdkconfig-4MB.defaults +++ b/ports/espressif/esp-idf-config/sdkconfig-4MB.defaults @@ -1,9 +1,18 @@ -# No newlines in this file so they are preserved in the board sdkconfig. +# +# Serial flasher config +# # CONFIG_ESPTOOLPY_FLASHSIZE_1MB is not set # CONFIG_ESPTOOLPY_FLASHSIZE_2MB is not set CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y # CONFIG_ESPTOOLPY_FLASHSIZE_8MB is not set # CONFIG_ESPTOOLPY_FLASHSIZE_16MB is not set CONFIG_ESPTOOLPY_FLASHSIZE="4MB" +CONFIG_ESPTOOLPY_FLASHSIZE_DETECT=y +# end of Serial flasher config + CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="esp-idf-config/partitions-4MB.csv" -CONFIG_PARTITION_TABLE_FILENAME="esp-idf-config/partitions-4MB.csv" \ No newline at end of file +# +# Partition Table +# +CONFIG_PARTITION_TABLE_FILENAME="esp-idf-config/partitions-4MB.csv" +# end of Partition Table diff --git a/ports/espressif/esp-idf-config/sdkconfig-8MB.defaults b/ports/espressif/esp-idf-config/sdkconfig-8MB.defaults index af681c5ea8..b1506206df 100644 --- a/ports/espressif/esp-idf-config/sdkconfig-8MB.defaults +++ b/ports/espressif/esp-idf-config/sdkconfig-8MB.defaults @@ -1,9 +1,18 @@ -# No newlines in this file so they are preserved in the board sdkconfig. +# +# Serial flasher config +# # CONFIG_ESPTOOLPY_FLASHSIZE_1MB is not set # CONFIG_ESPTOOLPY_FLASHSIZE_2MB is not set # CONFIG_ESPTOOLPY_FLASHSIZE_4MB is not set CONFIG_ESPTOOLPY_FLASHSIZE_8MB=y # CONFIG_ESPTOOLPY_FLASHSIZE_16MB is not set CONFIG_ESPTOOLPY_FLASHSIZE="8MB" +CONFIG_ESPTOOLPY_FLASHSIZE_DETECT=y +# end of Serial flasher config + CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="esp-idf-config/partitions-8MB.csv" -CONFIG_PARTITION_TABLE_FILENAME="esp-idf-config/partitions-8MB.csv" \ No newline at end of file +# +# Partition Table +# +CONFIG_PARTITION_TABLE_FILENAME="esp-idf-config/partitions-8MB.csv" +# end of Partition Table diff --git a/ports/espressif/esp-idf-config/sdkconfig-ble.defaults b/ports/espressif/esp-idf-config/sdkconfig-ble.defaults new file mode 100644 index 0000000000..476b6a32d9 --- /dev/null +++ b/ports/espressif/esp-idf-config/sdkconfig-ble.defaults @@ -0,0 +1,171 @@ +# +# Bluetooth +# +CONFIG_BT_ENABLED=y +# end of Bluetooth + +CONFIG_BT_CTRL_MODE_EFF=1 +# +# Bluetooth controller +# +CONFIG_BT_CTRL_BLE_MAX_ACT=10 +CONFIG_BT_CTRL_BLE_MAX_ACT_EFF=10 +CONFIG_BT_CTRL_BLE_STATIC_ACL_TX_BUF_NB=0 +CONFIG_BT_CTRL_PINNED_TO_CORE_0=y +# CONFIG_BT_CTRL_PINNED_TO_CORE_1 is not set +CONFIG_BT_CTRL_PINNED_TO_CORE=0 +CONFIG_BT_CTRL_HCI_MODE_VHCI=y +# CONFIG_BT_CTRL_HCI_MODE_UART_H4 is not set +CONFIG_BT_CTRL_HCI_TL=1 +CONFIG_BT_CTRL_ADV_DUP_FILT_MAX=30 +# CONFIG_BT_CTRL_HW_CCA is not set +CONFIG_BT_CTRL_HW_CCA_EFF=0 +CONFIG_BT_CTRL_CE_LENGTH_TYPE_ORIG=y +# CONFIG_BT_CTRL_CE_LENGTH_TYPE_CE is not set +# CONFIG_BT_CTRL_CE_LENGTH_TYPE_SD is not set +CONFIG_BT_CTRL_CE_LENGTH_TYPE_EFF=0 +CONFIG_BT_CTRL_TX_ANTENNA_INDEX_0=y +# CONFIG_BT_CTRL_TX_ANTENNA_INDEX_1 is not set +CONFIG_BT_CTRL_TX_ANTENNA_INDEX_EFF=0 +CONFIG_BT_CTRL_RX_ANTENNA_INDEX_0=y +# CONFIG_BT_CTRL_RX_ANTENNA_INDEX_1 is not set +CONFIG_BT_CTRL_RX_ANTENNA_INDEX_EFF=0 +# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_N27 is not set +# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_N24 is not set +# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_N21 is not set +# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_N18 is not set +# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_N15 is not set +# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_N12 is not set +# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_N9 is not set +# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_N6 is not set +# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_N3 is not set +# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_N0 is not set +CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_P3=y +# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_P6 is not set +# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_P9 is not set +# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_P12 is not set +# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_P15 is not set +# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_P18 is not set +CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_EFF=10 +CONFIG_BT_CTRL_BLE_ADV_REPORT_FLOW_CTRL_SUPP=y +CONFIG_BT_CTRL_BLE_ADV_REPORT_FLOW_CTRL_NUM=100 +CONFIG_BT_CTRL_BLE_ADV_REPORT_DISCARD_THRSHOLD=20 +# CONFIG_BT_CTRL_BLE_SCAN_DUPL is not set +# CONFIG_BT_CTRL_COEX_PHY_CODED_TX_RX_TLIM_EN is not set +CONFIG_BT_CTRL_COEX_PHY_CODED_TX_RX_TLIM_DIS=y +CONFIG_BT_CTRL_COEX_PHY_CODED_TX_RX_TLIM_EFF=0 +# end of Bluetooth controller + +# CONFIG_BT_CTRL_MODEM_SLEEP is not set +# +# Bluetooth controller +# +CONFIG_BT_CTRL_SLEEP_MODE_EFF=0 +CONFIG_BT_CTRL_SLEEP_CLOCK_EFF=0 +CONFIG_BT_CTRL_HCI_TL_EFF=1 +# CONFIG_BT_CTRL_AGC_RECORRECT_EN is not set +# end of Bluetooth controller + +# CONFIG_BT_BLUEDROID_ENABLED is not set +# +# Bluetooth +# +CONFIG_BT_NIMBLE_ENABLED=y +# CONFIG_BT_CONTROLLER_ONLY is not set +# end of Bluetooth + +CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_INTERNAL=y +# +# NimBLE Options +# +# CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_DEFAULT is not set +# CONFIG_BT_NIMBLE_LOG_LEVEL_NONE is not set +# CONFIG_BT_NIMBLE_LOG_LEVEL_ERROR is not set +# CONFIG_BT_NIMBLE_LOG_LEVEL_WARNING is not set +CONFIG_BT_NIMBLE_LOG_LEVEL_INFO=y +# CONFIG_BT_NIMBLE_LOG_LEVEL_DEBUG is not set +CONFIG_BT_NIMBLE_LOG_LEVEL=1 +CONFIG_BT_NIMBLE_MAX_CONNECTIONS=3 +CONFIG_BT_NIMBLE_MAX_BONDS=3 +CONFIG_BT_NIMBLE_MAX_CCCDS=8 +CONFIG_BT_NIMBLE_L2CAP_COC_MAX_NUM=0 +# CONFIG_BT_NIMBLE_PINNED_TO_CORE_0 is not set +CONFIG_BT_NIMBLE_PINNED_TO_CORE_1=y +CONFIG_BT_NIMBLE_PINNED_TO_CORE=1 +CONFIG_BT_NIMBLE_TASK_STACK_SIZE=4096 +CONFIG_BT_NIMBLE_ROLE_CENTRAL=y +CONFIG_BT_NIMBLE_ROLE_PERIPHERAL=y +CONFIG_BT_NIMBLE_ROLE_BROADCASTER=y +CONFIG_BT_NIMBLE_ROLE_OBSERVER=y +CONFIG_BT_NIMBLE_NVS_PERSIST=y +CONFIG_BT_NIMBLE_SM_LEGACY=y +CONFIG_BT_NIMBLE_SM_SC=y +# CONFIG_BT_NIMBLE_DEBUG is not set +# CONFIG_BT_NIMBLE_SM_SC_DEBUG_KEYS is not set +CONFIG_BT_NIMBLE_SVC_GAP_DEVICE_NAME="nimble" +CONFIG_BT_NIMBLE_GAP_DEVICE_NAME_MAX_LEN=31 +CONFIG_BT_NIMBLE_ATT_PREFERRED_MTU=256 +CONFIG_BT_NIMBLE_SVC_GAP_APPEARANCE=0 +CONFIG_BT_NIMBLE_ACL_BUF_COUNT=20 +CONFIG_BT_NIMBLE_ACL_BUF_SIZE=255 +CONFIG_BT_NIMBLE_HCI_EVT_BUF_SIZE=70 +CONFIG_BT_NIMBLE_HCI_EVT_HI_BUF_COUNT=30 +CONFIG_BT_NIMBLE_HCI_EVT_LO_BUF_COUNT=8 +CONFIG_BT_NIMBLE_MSYS1_BLOCK_COUNT=12 +# CONFIG_BT_NIMBLE_HS_FLOW_CTRL is not set +CONFIG_BT_NIMBLE_RPA_TIMEOUT=900 +# CONFIG_BT_NIMBLE_MESH is not set +CONFIG_BT_NIMBLE_CRYPTO_STACK_MBEDTLS=y +CONFIG_BT_NIMBLE_HS_STOP_TIMEOUT_MS=2000 +# CONFIG_BT_NIMBLE_HOST_BASED_PRIVACY is not set +CONFIG_BT_NIMBLE_ENABLE_CONN_REATTEMPT=y +CONFIG_BT_NIMBLE_MAX_CONN_REATTEMPT=3 +CONFIG_BT_NIMBLE_EXT_ADV=y +CONFIG_BT_NIMBLE_MAX_EXT_ADV_INSTANCES=1 +CONFIG_BT_NIMBLE_MAX_EXT_ADV_DATA_LEN=1650 +CONFIG_BT_NIMBLE_ENABLE_PERIODIC_ADV=y +CONFIG_BT_NIMBLE_MAX_PERIODIC_SYNCS=1 +# CONFIG_BT_NIMBLE_BLUFI_ENABLE is not set +CONFIG_BT_NIMBLE_USE_ESP_TIMER=y +# end of NimBLE Options + +# CONFIG_BLUEDROID_ENABLED is not set +# +# Deprecated options for backward compatibility +# +CONFIG_NIMBLE_ENABLED=y +CONFIG_NIMBLE_MEM_ALLOC_MODE_INTERNAL=y +# CONFIG_NIMBLE_MEM_ALLOC_MODE_DEFAULT is not set +CONFIG_NIMBLE_MAX_CONNECTIONS=3 +CONFIG_NIMBLE_MAX_BONDS=3 +CONFIG_NIMBLE_MAX_CCCDS=8 +CONFIG_NIMBLE_L2CAP_COC_MAX_NUM=0 +CONFIG_NIMBLE_PINNED_TO_CORE_0=y +# CONFIG_NIMBLE_PINNED_TO_CORE_1 is not set +CONFIG_NIMBLE_PINNED_TO_CORE=0 +CONFIG_NIMBLE_TASK_STACK_SIZE=4096 +CONFIG_NIMBLE_ROLE_CENTRAL=y +CONFIG_NIMBLE_ROLE_PERIPHERAL=y +CONFIG_NIMBLE_ROLE_BROADCASTER=y +CONFIG_NIMBLE_ROLE_OBSERVER=y +CONFIG_NIMBLE_NVS_PERSIST=y +CONFIG_NIMBLE_SM_LEGACY=y +CONFIG_NIMBLE_SM_SC=y +# CONFIG_NIMBLE_DEBUG is not set +# CONFIG_NIMBLE_SM_SC_DEBUG_KEYS is not set +CONFIG_NIMBLE_SVC_GAP_DEVICE_NAME="nimble" +CONFIG_NIMBLE_GAP_DEVICE_NAME_MAX_LEN=31 +CONFIG_NIMBLE_ATT_PREFERRED_MTU=256 +CONFIG_NIMBLE_SVC_GAP_APPEARANCE=0 +CONFIG_NIMBLE_ACL_BUF_COUNT=20 +CONFIG_NIMBLE_ACL_BUF_SIZE=255 +CONFIG_NIMBLE_HCI_EVT_BUF_SIZE=70 +CONFIG_NIMBLE_HCI_EVT_HI_BUF_COUNT=30 +CONFIG_NIMBLE_HCI_EVT_LO_BUF_COUNT=8 +CONFIG_NIMBLE_MSYS1_BLOCK_COUNT=12 +# CONFIG_NIMBLE_HS_FLOW_CTRL is not set +CONFIG_NIMBLE_RPA_TIMEOUT=900 +# CONFIG_NIMBLE_MESH is not set +CONFIG_NIMBLE_CRYPTO_STACK_MBEDTLS=y +CONFIG_SW_COEXIST_ENABLE=y +# end of Deprecated options for backward compatibility diff --git a/ports/espressif/esp-idf-config/sdkconfig-debug.defaults b/ports/espressif/esp-idf-config/sdkconfig-debug.defaults index b108532aa2..9d02c62445 100644 --- a/ports/espressif/esp-idf-config/sdkconfig-debug.defaults +++ b/ports/espressif/esp-idf-config/sdkconfig-debug.defaults @@ -1,16 +1,78 @@ -# No newlines in this file so they are preserved in the board sdkconfig. +# +# Bootloader config +# +CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y +# CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_DEBUG is not set +# CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_PERF is not set +# CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_NONE is not set +# end of Bootloader config + +# CONFIG_COMPILER_OPTIMIZATION_DEFAULT is not set +# +# Compiler options +# +CONFIG_COMPILER_OPTIMIZATION_SIZE=y +# CONFIG_COMPILER_OPTIMIZATION_PERF is not set +# CONFIG_COMPILER_OPTIMIZATION_NONE is not set +CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_ENABLE=y +# CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT is not set +# CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE is not set +CONFIG_COMPILER_OPTIMIZATION_ASSERTION_LEVEL=2 +# CONFIG_COMPILER_OPTIMIZATION_CHECKS_SILENT is not set +# end of Compiler options + CONFIG_ESP_ERR_TO_NAME_LOOKUP=y +# +# ESP System Settings +# +CONFIG_ESP_SYSTEM_PANIC_PRINT_HALT=y +# CONFIG_ESP_SYSTEM_PANIC_PRINT_REBOOT is not set +# CONFIG_ESP_SYSTEM_PANIC_SILENT_REBOOT is not set +# CONFIG_ESP_SYSTEM_PANIC_GDBSTUB is not set +# end of ESP System Settings + CONFIG_ESP_CONSOLE_UART_DEFAULT=y # CONFIG_ESP_CONSOLE_USB_CDC is not set # CONFIG_ESP_CONSOLE_UART_CUSTOM is not set # CONFIG_ESP_CONSOLE_NONE is not set CONFIG_ESP_CONSOLE_UART=y +CONFIG_ESP_CONSOLE_MULTIPLE_UART=y CONFIG_ESP_CONSOLE_UART_NUM=0 CONFIG_ESP_CONSOLE_UART_BAUDRATE=115200 -CONFIG_ESP_SYSTEM_PANIC_PRINT_HALT=y -# CONFIG_ESP_SYSTEM_PANIC_PRINT_REBOOT is not set -# CONFIG_ESP_SYSTEM_PANIC_SILENT_REBOOT is not set -# CONFIG_ESP_SYSTEM_PANIC_GDBSTUB is not set -CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_DEBUG=y -CONFIG_COMPILER_OPTIMIZATION_DEFAULT=y -CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_ENABLE=y \ No newline at end of file +# +# FreeRTOS +# +CONFIG_FREERTOS_ASSERT_ON_UNTESTED_FUNCTION=y +CONFIG_FREERTOS_ASSERT_FAIL_ABORT=y +# CONFIG_FREERTOS_ASSERT_FAIL_PRINT_CONTINUE is not set +# CONFIG_FREERTOS_ASSERT_DISABLE is not set +CONFIG_FREERTOS_TASK_FUNCTION_WRAPPER=y +CONFIG_FREERTOS_DEBUG_OCDAWARE=y +# end of FreeRTOS + +CONFIG_HAL_ASSERTION_EQUALS_SYSTEM=y +# +# Hardware Abstraction Layer (HAL) and Low Level (LL) +# +# CONFIG_HAL_ASSERTION_DISABLE is not set +# CONFIG_HAL_ASSERTION_SILIENT is not set +# CONFIG_HAL_ASSERTION_ENABLE is not set +CONFIG_HAL_DEFAULT_ASSERTION_LEVEL=2 +# end of Hardware Abstraction Layer (HAL) and Low Level (LL) + +CONFIG_LWIP_ESP_LWIP_ASSERT=y +# +# Deprecated options for backward compatibility +# +CONFIG_COMPILER_OPTIMIZATION_LEVEL_DEBUG=y +# CONFIG_COMPILER_OPTIMIZATION_LEVEL_RELEASE is not set +CONFIG_OPTIMIZATION_ASSERTIONS_ENABLED=y +# CONFIG_OPTIMIZATION_ASSERTIONS_SILENT is not set +# CONFIG_OPTIMIZATION_ASSERTIONS_DISABLED is not set +CONFIG_OPTIMIZATION_ASSERTION_LEVEL=2 +CONFIG_CONSOLE_UART_DEFAULT=y +# CONFIG_CONSOLE_UART_CUSTOM is not set +# CONFIG_ESP_CONSOLE_UART_NONE is not set +CONFIG_CONSOLE_UART_NUM=0 +CONFIG_CONSOLE_UART_BAUDRATE=115200 +# end of Deprecated options for backward compatibility diff --git a/ports/espressif/esp-idf-config/sdkconfig-esp32c3.defaults b/ports/espressif/esp-idf-config/sdkconfig-esp32c3.defaults new file mode 100644 index 0000000000..a39afeb505 --- /dev/null +++ b/ports/espressif/esp-idf-config/sdkconfig-esp32c3.defaults @@ -0,0 +1,139 @@ +# +# Espressif IoT Development Framework (ESP-IDF) Project Configuration +# +CONFIG_IDF_TARGET_ARCH_RISCV=y +CONFIG_IDF_TARGET="esp32c3" +CONFIG_IDF_TARGET_ESP32C3=y +CONFIG_IDF_FIRMWARE_CHIP_ID=0x0005 +# end of Espressif IoT Development Framework (ESP-IDF) Project Configuration + +CONFIG_SDK_TOOLPREFIX="riscv32-esp-elf-" +# +# Bootloader config +# +CONFIG_BOOTLOADER_OFFSET_IN_FLASH=0x0 +# end of Bootloader config + +# CONFIG_ESP32C3_DEFAULT_CPU_FREQ_80 is not set +# +# ESP32C3-Specific +# +CONFIG_ESP32C3_DEFAULT_CPU_FREQ_160=y +CONFIG_ESP32C3_DEFAULT_CPU_FREQ_MHZ=160 +# CONFIG_ESP32C3_REV_MIN_0 is not set +# CONFIG_ESP32C3_REV_MIN_1 is not set +# CONFIG_ESP32C3_REV_MIN_2 is not set +CONFIG_ESP32C3_REV_MIN_3=y +CONFIG_ESP32C3_REV_MIN=3 +CONFIG_ESP32C3_DEBUG_OCDAWARE=y +# CONFIG_ESP32C3_DEBUG_STUBS_ENABLE is not set +CONFIG_ESP32C3_BROWNOUT_DET=y +CONFIG_ESP32C3_BROWNOUT_DET_LVL_SEL_7=y +# CONFIG_ESP32C3_BROWNOUT_DET_LVL_SEL_6 is not set +# CONFIG_ESP32C3_BROWNOUT_DET_LVL_SEL_5 is not set +# CONFIG_ESP32C3_BROWNOUT_DET_LVL_SEL_4 is not set +# CONFIG_ESP32C3_BROWNOUT_DET_LVL_SEL_3 is not set +# CONFIG_ESP32C3_BROWNOUT_DET_LVL_SEL_2 is not set +CONFIG_ESP32C3_BROWNOUT_DET_LVL=7 +CONFIG_ESP32C3_TIME_SYSCALL_USE_RTC_SYSTIMER=y +# CONFIG_ESP32C3_TIME_SYSCALL_USE_RTC is not set +# CONFIG_ESP32C3_TIME_SYSCALL_USE_SYSTIMER is not set +# CONFIG_ESP32C3_TIME_SYSCALL_USE_NONE is not set +CONFIG_ESP32C3_RTC_CLK_SRC_INT_RC=y +# CONFIG_ESP32C3_RTC_CLK_SRC_EXT_CRYS is not set +# CONFIG_ESP32C3_RTC_CLK_SRC_EXT_OSC is not set +# CONFIG_ESP32C3_RTC_CLK_SRC_INT_8MD256 is not set +CONFIG_ESP32C3_RTC_CLK_CAL_CYCLES=1024 +# CONFIG_ESP32C3_NO_BLOBS is not set +# end of ESP32C3-Specific + +# CONFIG_ESP32C3_UNIVERSAL_MAC_ADDRESSES_TWO is not set +# +# MAC Config +# +CONFIG_ESP32C3_UNIVERSAL_MAC_ADDRESSES_FOUR=y +CONFIG_ESP32C3_UNIVERSAL_MAC_ADDRESSES=4 +# end of MAC Config + +CONFIG_ESP_SLEEP_POWER_DOWN_FLASH=y +# +# Sleep Config +# +CONFIG_ESP_SLEEP_GPIO_RESET_WORKAROUND=y +# end of Sleep Config + +CONFIG_ESP_SYSTEM_SINGLE_CORE_MODE=y +# +# Memory protection +# +CONFIG_ESP_SYSTEM_MEMPROT_DEPCHECK=y +CONFIG_ESP_SYSTEM_MEMPROT_FEATURE=y +CONFIG_ESP_SYSTEM_MEMPROT_FEATURE_LOCK=y +CONFIG_ESP_SYSTEM_MEMPROT_CPU_PREFETCH_PAD_SIZE=16 +CONFIG_ESP_SYSTEM_MEMPROT_MEM_ALIGN_SIZE=512 +# end of Memory protection + +CONFIG_ESP_MAIN_TASK_AFFINITY_CPU0=y +# CONFIG_ESP_MAIN_TASK_AFFINITY_NO_AFFINITY is not set +CONFIG_ESP_MAIN_TASK_AFFINITY=0x0 +# +# Wi-Fi +# +CONFIG_ESP32_WIFI_ENABLED=y +CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM=4 +CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM=8 +# CONFIG_ESP32_WIFI_STATIC_TX_BUFFER is not set +CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER=y +CONFIG_ESP32_WIFI_TX_BUFFER_TYPE=1 +CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM=16 +# CONFIG_ESP32_WIFI_CSI_ENABLED is not set +CONFIG_ESP32_WIFI_AMPDU_TX_ENABLED=y +CONFIG_ESP32_WIFI_TX_BA_WIN=6 +CONFIG_ESP32_WIFI_AMPDU_RX_ENABLED=y +CONFIG_ESP32_WIFI_RX_BA_WIN=6 +# CONFIG_ESP32_WIFI_NVS_ENABLED is not set +CONFIG_ESP32_WIFI_SOFTAP_BEACON_MAX_LEN=752 +CONFIG_ESP32_WIFI_MGMT_SBUF_NUM=32 +CONFIG_ESP32_WIFI_IRAM_OPT=y +CONFIG_ESP32_WIFI_RX_IRAM_OPT=y +# CONFIG_ESP32_WIFI_ENABLE_WPA3_SAE is not set +# CONFIG_ESP_WIFI_EXTERNAL_COEXIST_ENABLE is not set +# end of Wi-Fi + +CONFIG_FREERTOS_UNICORE=y +# +# FreeRTOS +# +CONFIG_FREERTOS_OPTIMIZED_SCHEDULER=y +# end of FreeRTOS + +CONFIG_TOOLPREFIX="riscv32-esp-elf-" +# +# Deprecated options for backward compatibility +# +# CONFIG_ESP32_APPTRACE_DEST_TRAX is not set +CONFIG_ESP32_APPTRACE_DEST_NONE=y +CONFIG_ESP32_APPTRACE_LOCK_ENABLE=y +CONFIG_ESP_SYSTEM_PD_FLASH=y +CONFIG_ESP32C3_LIGHTSLEEP_GPIO_RESET_WORKAROUND=y +CONFIG_ESP32_PHY_CALIBRATION_AND_DATA_STORAGE=y +# CONFIG_ESP32_PHY_INIT_DATA_IN_PARTITION is not set +CONFIG_ESP32_PHY_MAX_WIFI_TX_POWER=20 +CONFIG_ESP32_PHY_MAX_TX_POWER=20 +# CONFIG_ESP32S2_PANIC_PRINT_HALT is not set +# CONFIG_ESP32S2_PANIC_PRINT_REBOOT is not set +CONFIG_ESP32S2_PANIC_SILENT_REBOOT=y +# CONFIG_ESP32S2_PANIC_GDBSTUB is not set +CONFIG_ESP32S2_ALLOW_RTC_FAST_MEM_AS_HEAP=y +CONFIG_ESP32H2_MEMPROT_FEATURE=y +CONFIG_ESP32H2_MEMPROT_FEATURE_LOCK=y +# CONFIG_EXTERNAL_COEX_ENABLE is not set +# CONFIG_ESP32_ENABLE_COREDUMP_TO_FLASH is not set +# CONFIG_ESP32_ENABLE_COREDUMP_TO_UART is not set +CONFIG_ESP32_ENABLE_COREDUMP_TO_NONE=y +CONFIG_ESP32_PTHREAD_TASK_PRIO_DEFAULT=5 +CONFIG_ESP32_PTHREAD_TASK_STACK_SIZE_DEFAULT=3072 +CONFIG_ESP32_PTHREAD_STACK_MIN=768 +CONFIG_ESP32_PTHREAD_TASK_CORE_DEFAULT=-1 +CONFIG_ESP32_PTHREAD_TASK_NAME_DEFAULT="pthread" +# end of Deprecated options for backward compatibility diff --git a/ports/espressif/esp-idf-config/sdkconfig-esp32s2.defaults b/ports/espressif/esp-idf-config/sdkconfig-esp32s2.defaults new file mode 100644 index 0000000000..ac3e909dfc --- /dev/null +++ b/ports/espressif/esp-idf-config/sdkconfig-esp32s2.defaults @@ -0,0 +1,166 @@ +# +# Espressif IoT Development Framework (ESP-IDF) Project Configuration +# +CONFIG_IDF_TARGET_ARCH_XTENSA=y +CONFIG_IDF_TARGET="esp32s2" +CONFIG_IDF_TARGET_ESP32S2=y +CONFIG_IDF_FIRMWARE_CHIP_ID=0x0002 +# end of Espressif IoT Development Framework (ESP-IDF) Project Configuration + +CONFIG_SDK_TOOLPREFIX="xtensa-esp32s2-elf-" +# +# Bootloader config +# +CONFIG_BOOTLOADER_OFFSET_IN_FLASH=0x1000 +# end of Bootloader config + +# CONFIG_ESP32S2_DEFAULT_CPU_FREQ_80 is not set +# +# ESP32S2-specific +# +# CONFIG_ESP32S2_DEFAULT_CPU_FREQ_160 is not set +CONFIG_ESP32S2_DEFAULT_CPU_FREQ_240=y +CONFIG_ESP32S2_DEFAULT_CPU_FREQ_MHZ=240 +# end of ESP32S2-specific + +# CONFIG_ESP32S2_INSTRUCTION_CACHE_8KB is not set +# +# Cache config +# +CONFIG_ESP32S2_INSTRUCTION_CACHE_16KB=y +# CONFIG_ESP32S2_INSTRUCTION_CACHE_LINE_16B is not set +CONFIG_ESP32S2_INSTRUCTION_CACHE_LINE_32B=y +# CONFIG_ESP32S2_DATA_CACHE_0KB is not set +# CONFIG_ESP32S2_DATA_CACHE_8KB is not set +CONFIG_ESP32S2_DATA_CACHE_16KB=y +# CONFIG_ESP32S2_DATA_CACHE_LINE_16B is not set +CONFIG_ESP32S2_DATA_CACHE_LINE_32B=y +# CONFIG_ESP32S2_INSTRUCTION_CACHE_WRAP is not set +# CONFIG_ESP32S2_DATA_CACHE_WRAP is not set +# end of Cache config + +# CONFIG_ESP32S2_TRAX is not set +CONFIG_ESP32S2_TRACEMEM_RESERVE_DRAM=0x0 +# CONFIG_ESP32S2_ULP_COPROC_ENABLED is not set +CONFIG_ESP32S2_ULP_COPROC_RESERVE_MEM=0 +CONFIG_ESP32S2_DEBUG_OCDAWARE=y +# CONFIG_ESP32S2_DEBUG_STUBS_ENABLE is not set +CONFIG_ESP32S2_BROWNOUT_DET=y +CONFIG_ESP32S2_BROWNOUT_DET_LVL_SEL_7=y +# CONFIG_ESP32S2_BROWNOUT_DET_LVL_SEL_6 is not set +# CONFIG_ESP32S2_BROWNOUT_DET_LVL_SEL_5 is not set +# CONFIG_ESP32S2_BROWNOUT_DET_LVL_SEL_4 is not set +# CONFIG_ESP32S2_BROWNOUT_DET_LVL_SEL_3 is not set +# CONFIG_ESP32S2_BROWNOUT_DET_LVL_SEL_2 is not set +# CONFIG_ESP32S2_BROWNOUT_DET_LVL_SEL_1 is not set +CONFIG_ESP32S2_BROWNOUT_DET_LVL=7 +CONFIG_ESP32S2_TIME_SYSCALL_USE_RTC_FRC1=y +# CONFIG_ESP32S2_TIME_SYSCALL_USE_RTC is not set +# CONFIG_ESP32S2_TIME_SYSCALL_USE_FRC1 is not set +# CONFIG_ESP32S2_TIME_SYSCALL_USE_NONE is not set +CONFIG_ESP32S2_RTC_CLK_SRC_INT_RC=y +# CONFIG_ESP32S2_RTC_CLK_SRC_EXT_CRYS is not set +# CONFIG_ESP32S2_RTC_CLK_SRC_EXT_OSC is not set +# CONFIG_ESP32S2_RTC_CLK_SRC_INT_8MD256 is not set +CONFIG_ESP32S2_RTC_CLK_CAL_CYCLES=576 +# CONFIG_ESP32S2_NO_BLOBS is not set +# CONFIG_ESP32S2_KEEP_USB_ALIVE is not set +# CONFIG_ESP32S2_RTCDATA_IN_FAST_MEM is not set +# CONFIG_ESP32S2_USE_FIXED_STATIC_RAM_SIZE is not set +# +# MAC Config +# +# CONFIG_ESP32S2_UNIVERSAL_MAC_ADDRESSES_ONE is not set +CONFIG_ESP32S2_UNIVERSAL_MAC_ADDRESSES_TWO=y +CONFIG_ESP32S2_UNIVERSAL_MAC_ADDRESSES=2 +# end of MAC Config + +CONFIG_ESP_SLEEP_POWER_DOWN_FLASH=y +# +# Sleep Config +# +# CONFIG_ESP_SLEEP_GPIO_RESET_WORKAROUND is not set +# end of Sleep Config + +# +# PHY +# +# CONFIG_ESP_PHY_ENABLE_USB is not set +# end of PHY + +CONFIG_ESP_SYSTEM_SINGLE_CORE_MODE=y +# +# Memory protection +# +CONFIG_ESP_SYSTEM_MEMPROT_FEATURE=y +CONFIG_ESP_SYSTEM_MEMPROT_FEATURE_LOCK=y +CONFIG_ESP_SYSTEM_MEMPROT_CPU_PREFETCH_PAD_SIZE=16 +CONFIG_ESP_SYSTEM_MEMPROT_MEM_ALIGN_SIZE=4 +# end of Memory protection + +CONFIG_ESP_MAIN_TASK_AFFINITY_CPU0=y +# CONFIG_ESP_MAIN_TASK_AFFINITY_NO_AFFINITY is not set +CONFIG_ESP_MAIN_TASK_AFFINITY=0x0 +# +# Wi-Fi +# +CONFIG_ESP32_WIFI_ENABLED=y +CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM=4 +CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM=8 +# CONFIG_ESP32_WIFI_STATIC_TX_BUFFER is not set +CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER=y +CONFIG_ESP32_WIFI_TX_BUFFER_TYPE=1 +CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM=16 +CONFIG_ESP32_WIFI_CACHE_TX_BUFFER_NUM=16 +# CONFIG_ESP32_WIFI_CSI_ENABLED is not set +CONFIG_ESP32_WIFI_AMPDU_TX_ENABLED=y +CONFIG_ESP32_WIFI_TX_BA_WIN=6 +CONFIG_ESP32_WIFI_AMPDU_RX_ENABLED=y +CONFIG_ESP32_WIFI_RX_BA_WIN=6 +# CONFIG_ESP32_WIFI_NVS_ENABLED is not set +CONFIG_ESP32_WIFI_SOFTAP_BEACON_MAX_LEN=752 +CONFIG_ESP32_WIFI_MGMT_SBUF_NUM=32 +CONFIG_ESP32_WIFI_IRAM_OPT=y +CONFIG_ESP32_WIFI_RX_IRAM_OPT=y +# CONFIG_ESP32_WIFI_ENABLE_WPA3_SAE is not set +# CONFIG_ESP_WIFI_EXTERNAL_COEXIST_ENABLE is not set +# end of Wi-Fi + +CONFIG_FREERTOS_UNICORE=y +# +# FreeRTOS +# +CONFIG_FREERTOS_TICK_SUPPORT_CORETIMER=y +CONFIG_FREERTOS_CORETIMER_0=y +# CONFIG_FREERTOS_CORETIMER_1 is not set +CONFIG_FREERTOS_SYSTICK_USES_CCOUNT=y +CONFIG_FREERTOS_OPTIMIZED_SCHEDULER=y +# end of FreeRTOS + +CONFIG_MBEDTLS_HARDWARE_GCM=y +# +# Deprecated options for backward compatibility +# +CONFIG_TOOLPREFIX="xtensa-esp32s2-elf-" +# CONFIG_ESP32_APPTRACE_DEST_TRAX is not set +CONFIG_ESP32_APPTRACE_DEST_NONE=y +CONFIG_ESP32_APPTRACE_LOCK_ENABLE=y +CONFIG_ESP_SYSTEM_PD_FLASH=y +# CONFIG_ESP32C3_LIGHTSLEEP_GPIO_RESET_WORKAROUND is not set +CONFIG_ESP32_PHY_CALIBRATION_AND_DATA_STORAGE=y +# CONFIG_ESP32_PHY_INIT_DATA_IN_PARTITION is not set +CONFIG_ESP32_PHY_MAX_WIFI_TX_POWER=20 +CONFIG_ESP32_PHY_MAX_TX_POWER=20 +CONFIG_ESP32S2_ALLOW_RTC_FAST_MEM_AS_HEAP=y +CONFIG_ESP32H2_MEMPROT_FEATURE=y +CONFIG_ESP32H2_MEMPROT_FEATURE_LOCK=y +# CONFIG_EXTERNAL_COEX_ENABLE is not set +# CONFIG_ESP32_ENABLE_COREDUMP_TO_FLASH is not set +# CONFIG_ESP32_ENABLE_COREDUMP_TO_UART is not set +CONFIG_ESP32_ENABLE_COREDUMP_TO_NONE=y +CONFIG_ESP32_PTHREAD_TASK_PRIO_DEFAULT=5 +CONFIG_ESP32_PTHREAD_TASK_STACK_SIZE_DEFAULT=3072 +CONFIG_ESP32_PTHREAD_STACK_MIN=768 +CONFIG_ESP32_PTHREAD_TASK_CORE_DEFAULT=-1 +CONFIG_ESP32_PTHREAD_TASK_NAME_DEFAULT="pthread" +# end of Deprecated options for backward compatibility diff --git a/ports/espressif/esp-idf-config/sdkconfig-esp32s3.defaults b/ports/espressif/esp-idf-config/sdkconfig-esp32s3.defaults new file mode 100644 index 0000000000..e8583facbe --- /dev/null +++ b/ports/espressif/esp-idf-config/sdkconfig-esp32s3.defaults @@ -0,0 +1,153 @@ +# +# Espressif IoT Development Framework (ESP-IDF) Project Configuration +# +CONFIG_IDF_TARGET_ARCH_XTENSA=y +CONFIG_IDF_TARGET="esp32s3" +CONFIG_IDF_TARGET_ESP32S3=y +CONFIG_IDF_FIRMWARE_CHIP_ID=0x0009 +# end of Espressif IoT Development Framework (ESP-IDF) Project Configuration + +# +# LWIP sdkconfig.defaults override +# +CONFIG_LWIP_MAX_SOCKETS=8 +# end of LWIP sdkconfig.defaults override + +CONFIG_SDK_TOOLPREFIX="xtensa-esp32s3-elf-" +# +# Bootloader config +# +CONFIG_BOOTLOADER_OFFSET_IN_FLASH=0x0 +# end of Bootloader config + +CONFIG_BT_SOC_SUPPORT_5_0=y +# +# ESP32S3-Specific +# +# CONFIG_ESP32S3_DEFAULT_CPU_FREQ_160 is not set +CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240=y +CONFIG_ESP32S3_DEFAULT_CPU_FREQ_MHZ=240 +# end of ESP32S3-Specific + +CONFIG_ESP32S3_INSTRUCTION_CACHE_16KB=y +# +# Cache config +# +# CONFIG_ESP32S3_INSTRUCTION_CACHE_32KB is not set +CONFIG_ESP32S3_INSTRUCTION_CACHE_SIZE=0x4000 +# CONFIG_ESP32S3_INSTRUCTION_CACHE_4WAYS is not set +CONFIG_ESP32S3_INSTRUCTION_CACHE_8WAYS=y +CONFIG_ESP32S3_ICACHE_ASSOCIATED_WAYS=8 +# CONFIG_ESP32S3_INSTRUCTION_CACHE_LINE_16B is not set +CONFIG_ESP32S3_INSTRUCTION_CACHE_LINE_32B=y +CONFIG_ESP32S3_INSTRUCTION_CACHE_LINE_SIZE=32 +# CONFIG_ESP32S3_INSTRUCTION_CACHE_WRAP is not set +# CONFIG_ESP32S3_DATA_CACHE_16KB is not set +CONFIG_ESP32S3_DATA_CACHE_32KB=y +# CONFIG_ESP32S3_DATA_CACHE_64KB is not set +CONFIG_ESP32S3_DATA_CACHE_SIZE=0x8000 +# CONFIG_ESP32S3_DATA_CACHE_4WAYS is not set +CONFIG_ESP32S3_DATA_CACHE_8WAYS=y +CONFIG_ESP32S3_DCACHE_ASSOCIATED_WAYS=8 +# CONFIG_ESP32S3_DATA_CACHE_LINE_16B is not set +CONFIG_ESP32S3_DATA_CACHE_LINE_32B=y +# CONFIG_ESP32S3_DATA_CACHE_LINE_64B is not set +CONFIG_ESP32S3_DATA_CACHE_LINE_SIZE=32 +# CONFIG_ESP32S3_DATA_CACHE_WRAP is not set +# end of Cache config + +# CONFIG_ESP32S3_TRAX is not set +CONFIG_ESP32S3_TRACEMEM_RESERVE_DRAM=0x0 +# CONFIG_ESP32S3_ULP_COPROC_ENABLED is not set +CONFIG_ESP32S3_ULP_COPROC_RESERVE_MEM=0 +# CONFIG_ESP32S3_DEBUG_STUBS_ENABLE is not set +CONFIG_ESP32S3_BROWNOUT_DET=y +CONFIG_ESP32S3_BROWNOUT_DET_LVL_SEL_7=y +# CONFIG_ESP32S3_BROWNOUT_DET_LVL_SEL_6 is not set +# CONFIG_ESP32S3_BROWNOUT_DET_LVL_SEL_5 is not set +# CONFIG_ESP32S3_BROWNOUT_DET_LVL_SEL_4 is not set +# CONFIG_ESP32S3_BROWNOUT_DET_LVL_SEL_3 is not set +# CONFIG_ESP32S3_BROWNOUT_DET_LVL_SEL_2 is not set +# CONFIG_ESP32S3_BROWNOUT_DET_LVL_SEL_1 is not set +CONFIG_ESP32S3_BROWNOUT_DET_LVL=7 +CONFIG_ESP32S3_TIME_SYSCALL_USE_RTC_FRC1=y +# CONFIG_ESP32S3_TIME_SYSCALL_USE_RTC is not set +# CONFIG_ESP32S3_TIME_SYSCALL_USE_FRC1 is not set +# CONFIG_ESP32S3_TIME_SYSCALL_USE_NONE is not set +CONFIG_ESP32S3_RTC_CLK_SRC_INT_RC=y +# CONFIG_ESP32S3_RTC_CLK_SRC_EXT_CRYS is not set +# CONFIG_ESP32S3_RTC_CLK_SRC_EXT_OSC is not set +# CONFIG_ESP32S3_RTC_CLK_SRC_INT_8MD256 is not set +CONFIG_ESP32S3_RTC_CLK_CAL_CYCLES=1024 +CONFIG_ESP32S3_DEEP_SLEEP_WAKEUP_DELAY=2000 +# CONFIG_ESP32S3_NO_BLOBS is not set +# CONFIG_ESP32S3_RTCDATA_IN_FAST_MEM is not set +# CONFIG_ESP32S3_USE_FIXED_STATIC_RAM_SIZE is not set +# +# MAC Config +# +# CONFIG_ESP32S3_UNIVERSAL_MAC_ADDRESSES_TWO is not set +CONFIG_ESP32S3_UNIVERSAL_MAC_ADDRESSES_FOUR=y +CONFIG_ESP32S3_UNIVERSAL_MAC_ADDRESSES=4 +# end of MAC Config + +CONFIG_ESP_SLEEP_GPIO_RESET_WORKAROUND=y + +CONFIG_ESP_PHY_ENABLE_USB=y +# CONFIG_ESP_MAIN_TASK_AFFINITY_CPU0 is not set +CONFIG_ESP_MAIN_TASK_AFFINITY_CPU1=y +# CONFIG_ESP_MAIN_TASK_AFFINITY_NO_AFFINITY is not set +CONFIG_ESP_MAIN_TASK_AFFINITY=0x1 +# +# Wi-Fi +# +CONFIG_ESP32_WIFI_ENABLED=y +CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM=4 +CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM=8 +# CONFIG_ESP32_WIFI_STATIC_TX_BUFFER is not set +CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER=y +CONFIG_ESP32_WIFI_TX_BUFFER_TYPE=1 +CONFIG_ESP32_WIFI_CACHE_TX_BUFFER_NUM=16 +CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM=16 +# CONFIG_ESP32_WIFI_CSI_ENABLED is not set +CONFIG_ESP32_WIFI_AMPDU_TX_ENABLED=y +CONFIG_ESP32_WIFI_TX_BA_WIN=6 +CONFIG_ESP32_WIFI_AMPDU_RX_ENABLED=y +CONFIG_ESP32_WIFI_RX_BA_WIN=6 +# CONFIG_ESP32_WIFI_AMSDU_TX_ENABLED is not set +# CONFIG_ESP32_WIFI_NVS_ENABLED is not set +CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_0=y +# CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_1 is not set +CONFIG_ESP32_WIFI_SOFTAP_BEACON_MAX_LEN=752 +CONFIG_ESP32_WIFI_MGMT_SBUF_NUM=32 +CONFIG_ESP32_WIFI_IRAM_OPT=y +CONFIG_ESP32_WIFI_RX_IRAM_OPT=y +# CONFIG_ESP32_WIFI_ENABLE_WPA3_SAE is not set +# end of Wi-Fi + +# CONFIG_FREERTOS_UNICORE is not set +# +# Deprecated options for backward compatibility +# +CONFIG_TOOLPREFIX="xtensa-esp32s3-elf-" +# CONFIG_ESP32_APPTRACE_DEST_TRAX is not set +CONFIG_ESP32_APPTRACE_DEST_NONE=y +CONFIG_ESP32_APPTRACE_LOCK_ENABLE=y +CONFIG_ESP32C3_LIGHTSLEEP_GPIO_RESET_WORKAROUND=y +CONFIG_ESP32_PHY_CALIBRATION_AND_DATA_STORAGE=y +# CONFIG_ESP32_PHY_INIT_DATA_IN_PARTITION is not set +CONFIG_ESP32_PHY_MAX_WIFI_TX_POWER=20 +CONFIG_ESP32_PHY_MAX_TX_POWER=20 +CONFIG_ESP32S2_ALLOW_RTC_FAST_MEM_AS_HEAP=y +# CONFIG_ESP32_ENABLE_COREDUMP_TO_FLASH is not set +# CONFIG_ESP32_ENABLE_COREDUMP_TO_UART is not set +CONFIG_ESP32_ENABLE_COREDUMP_TO_NONE=y +CONFIG_ESP32_PTHREAD_TASK_PRIO_DEFAULT=5 +CONFIG_ESP32_PTHREAD_TASK_STACK_SIZE_DEFAULT=3072 +CONFIG_ESP32_PTHREAD_STACK_MIN=768 +CONFIG_ESP32_DEFAULT_PTHREAD_CORE_NO_AFFINITY=y +# CONFIG_ESP32_DEFAULT_PTHREAD_CORE_0 is not set +# CONFIG_ESP32_DEFAULT_PTHREAD_CORE_1 is not set +CONFIG_ESP32_PTHREAD_TASK_CORE_DEFAULT=-1 +CONFIG_ESP32_PTHREAD_TASK_NAME_DEFAULT="pthread" +# end of Deprecated options for backward compatibility diff --git a/ports/espressif/esp-idf-config/sdkconfig-opt.defaults b/ports/espressif/esp-idf-config/sdkconfig-opt.defaults index b24996c0f7..273303446e 100644 --- a/ports/espressif/esp-idf-config/sdkconfig-opt.defaults +++ b/ports/espressif/esp-idf-config/sdkconfig-opt.defaults @@ -1,10 +1,86 @@ -# No newlines in this file so they are preserved in the board sdkconfig. +# +# Bootloader config +# +CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y +# CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_DEBUG is not set +# CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_PERF is not set +# CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_NONE is not set +# end of Bootloader config + +# CONFIG_COMPILER_OPTIMIZATION_DEFAULT is not set +# +# Compiler options +# +CONFIG_COMPILER_OPTIMIZATION_SIZE=y +# CONFIG_COMPILER_OPTIMIZATION_PERF is not set +# CONFIG_COMPILER_OPTIMIZATION_NONE is not set +# CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_ENABLE is not set +CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y +# CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE is not set +CONFIG_COMPILER_OPTIMIZATION_ASSERTION_LEVEL=1 +# CONFIG_COMPILER_OPTIMIZATION_CHECKS_SILENT is not set +# end of Compiler options + +CONFIG_ESP32S3_DEBUG_OCDAWARE=y +# +# Common ESP-related +# # CONFIG_ESP_ERR_TO_NAME_LOOKUP is not set -# CONFIG_ESP_CONSOLE_UART_DEFAULT is not set -# CONFIG_CONSOLE_UART_DEFAULT is not set -CONFIG_ESP_CONSOLE_UART_NONE=y -CONFIG_ESP_CONSOLE_NONE=y -CONFIG_ESP_CONSOLE_UART_NUM=-1 -CONFIG_CONSOLE_UART_NUM=-1 +# end of Common ESP-related + # CONFIG_ESP_SYSTEM_PANIC_PRINT_HALT is not set -CONFIG_ESP_SYSTEM_PANIC_SILENT_REBOOT=y \ No newline at end of file +# +# ESP System Settings +# +# CONFIG_ESP_SYSTEM_PANIC_PRINT_REBOOT is not set +CONFIG_ESP_SYSTEM_PANIC_SILENT_REBOOT=y +# CONFIG_ESP_SYSTEM_PANIC_GDBSTUB is not set +# end of ESP System Settings + +# CONFIG_ESP_CONSOLE_UART_DEFAULT is not set +# CONFIG_ESP_CONSOLE_USB_CDC is not set +# CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG is not set +# CONFIG_ESP_CONSOLE_UART_CUSTOM is not set +CONFIG_ESP_CONSOLE_NONE=y +# CONFIG_ESP_CONSOLE_SECONDARY_NONE is not set +CONFIG_ESP_CONSOLE_SECONDARY_USB_SERIAL_JTAG=y +CONFIG_ESP_CONSOLE_MULTIPLE_UART=y +CONFIG_ESP_CONSOLE_UART_NUM=-1 +# +# FreeRTOS +# +CONFIG_FREERTOS_ASSERT_ON_UNTESTED_FUNCTION=y +CONFIG_FREERTOS_ASSERT_FAIL_ABORT=y +# CONFIG_FREERTOS_ASSERT_FAIL_PRINT_CONTINUE is not set +# CONFIG_FREERTOS_ASSERT_DISABLE is not set +CONFIG_FREERTOS_DEBUG_OCDAWARE=y +# end of FreeRTOS + +CONFIG_HAL_ASSERTION_EQUALS_SYSTEM=y +# +# Hardware Abstraction Layer (HAL) and Low Level (LL) +# +# CONFIG_HAL_ASSERTION_DISABLE is not set +# CONFIG_HAL_ASSERTION_SILIENT is not set +CONFIG_HAL_DEFAULT_ASSERTION_LEVEL=1 +# end of Hardware Abstraction Layer (HAL) and Low Level (LL) + +CONFIG_LWIP_ESP_LWIP_ASSERT=y +# +# Deprecated options for backward compatibility +# +# CONFIG_COMPILER_OPTIMIZATION_LEVEL_DEBUG is not set +CONFIG_COMPILER_OPTIMIZATION_LEVEL_RELEASE=y +# CONFIG_OPTIMIZATION_ASSERTIONS_ENABLED is not set +CONFIG_OPTIMIZATION_ASSERTIONS_SILENT=y +# CONFIG_OPTIMIZATION_ASSERTIONS_DISABLED is not set +CONFIG_OPTIMIZATION_ASSERTION_LEVEL=1 +# CONFIG_ESP32S2_PANIC_PRINT_HALT is not set +# CONFIG_ESP32S2_PANIC_PRINT_REBOOT is not set +CONFIG_ESP32S2_PANIC_SILENT_REBOOT=y +# CONFIG_ESP32S2_PANIC_GDBSTUB is not set +# CONFIG_CONSOLE_UART_DEFAULT is not set +# CONFIG_CONSOLE_UART_CUSTOM is not set +CONFIG_ESP_CONSOLE_UART_NONE=y +CONFIG_CONSOLE_UART_NUM=-1 +# end of Deprecated options for backward compatibility diff --git a/ports/espressif/esp-idf-config/sdkconfig.defaults b/ports/espressif/esp-idf-config/sdkconfig.defaults index 67e2594339..f4efac4063 100644 --- a/ports/espressif/esp-idf-config/sdkconfig.defaults +++ b/ports/espressif/esp-idf-config/sdkconfig.defaults @@ -1,127 +1,549 @@ # +# Espressif IoT Development Framework (ESP-IDF) Project Configuration +# +CONFIG_IDF_CMAKE=y +# end of Espressif IoT Development Framework (ESP-IDF) Project Configuration + +# CONFIG_SDK_TOOLCHAIN_SUPPORTS_TIME_WIDE_64_BITS is not set +# +# Build type +# +CONFIG_APP_BUILD_TYPE_APP_2NDBOOT=y +# CONFIG_APP_BUILD_TYPE_ELF_RAM is not set +CONFIG_APP_BUILD_GENERATE_BINARIES=y +CONFIG_APP_BUILD_BOOTLOADER=y +CONFIG_APP_BUILD_USE_FLASH_SECTIONS=y +# end of Build type + +CONFIG_APP_COMPILE_TIME_DATE=y +# +# Application manager +# +# CONFIG_APP_EXCLUDE_PROJECT_VER_VAR is not set +# CONFIG_APP_EXCLUDE_PROJECT_NAME_VAR is not set +# CONFIG_APP_PROJECT_VER_FROM_CONFIG is not set +CONFIG_APP_RETRIEVE_LEN_ELF_SHA=16 +# end of Application manager + +# CONFIG_BOOTLOADER_LOG_LEVEL_NONE is not set +# +# Bootloader config +# +# CONFIG_BOOTLOADER_LOG_LEVEL_ERROR is not set +# CONFIG_BOOTLOADER_LOG_LEVEL_WARN is not set +CONFIG_BOOTLOADER_LOG_LEVEL_INFO=y +# CONFIG_BOOTLOADER_LOG_LEVEL_DEBUG is not set +# CONFIG_BOOTLOADER_LOG_LEVEL_VERBOSE is not set +CONFIG_BOOTLOADER_LOG_LEVEL=3 +# CONFIG_BOOTLOADER_VDDSDIO_BOOST_1_8V is not set +CONFIG_BOOTLOADER_VDDSDIO_BOOST_1_9V=y +# CONFIG_BOOTLOADER_FACTORY_RESET is not set +# CONFIG_BOOTLOADER_APP_TEST is not set +CONFIG_BOOTLOADER_WDT_ENABLE=y +# CONFIG_BOOTLOADER_WDT_DISABLE_IN_USER_CODE is not set +CONFIG_BOOTLOADER_WDT_TIME_MS=9000 +# CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE is not set +# CONFIG_BOOTLOADER_SKIP_VALIDATE_IN_DEEP_SLEEP is not set +# CONFIG_BOOTLOADER_SKIP_VALIDATE_ON_POWER_ON is not set +# CONFIG_BOOTLOADER_SKIP_VALIDATE_ALWAYS is not set +CONFIG_BOOTLOADER_RESERVE_RTC_SIZE=0 +# CONFIG_BOOTLOADER_CUSTOM_RESERVE_RTC is not set +CONFIG_BOOTLOADER_FLASH_XMC_SUPPORT=y +# end of Bootloader config + +CONFIG_SECURE_BOOT_SUPPORTS_RSA=y +# +# Security features +# +CONFIG_SECURE_TARGET_HAS_SECURE_ROM_DL_MODE=y +# CONFIG_SECURE_SIGNED_APPS_NO_SECURE_BOOT is not set +# CONFIG_SECURE_BOOT is not set +# CONFIG_SECURE_FLASH_ENC_ENABLED is not set +# end of Security features + +CONFIG_BOOT_ROM_LOG_ALWAYS_ON=y +# +# Boot ROM Behavior +# +# CONFIG_BOOT_ROM_LOG_ALWAYS_OFF is not set +# CONFIG_BOOT_ROM_LOG_ON_GPIO_HIGH is not set +# CONFIG_BOOT_ROM_LOG_ON_GPIO_LOW is not set +# end of Boot ROM Behavior + +CONFIG_ESPTOOLPY_BAUD_OTHER_VAL=115200 +# # Serial flasher config # +# CONFIG_ESPTOOLPY_NO_STUB is not set +# CONFIG_ESPTOOLPY_OCT_FLASH is not set +# CONFIG_ESPTOOLPY_FLASHMODE_QIO is not set +# CONFIG_ESPTOOLPY_FLASHMODE_QOUT is not set +CONFIG_ESPTOOLPY_FLASHMODE_DIO=y +# CONFIG_ESPTOOLPY_FLASHMODE_DOUT is not set +CONFIG_ESPTOOLPY_FLASH_SAMPLE_MODE_STR=y +CONFIG_ESPTOOLPY_FLASHMODE="dio" +# CONFIG_ESPTOOLPY_FLASHFREQ_120M is not set # CONFIG_ESPTOOLPY_FLASHFREQ_80M is not set CONFIG_ESPTOOLPY_FLASHFREQ_40M=y +# CONFIG_ESPTOOLPY_FLASHFREQ_20M is not set CONFIG_ESPTOOLPY_FLASHFREQ="40m" +CONFIG_ESPTOOLPY_BEFORE_RESET=y +# CONFIG_ESPTOOLPY_BEFORE_NORESET is not set +CONFIG_ESPTOOLPY_BEFORE="default_reset" +CONFIG_ESPTOOLPY_AFTER_RESET=y +# CONFIG_ESPTOOLPY_AFTER_NORESET is not set +CONFIG_ESPTOOLPY_AFTER="hard_reset" +# CONFIG_ESPTOOLPY_MONITOR_BAUD_CONSOLE is not set +# CONFIG_ESPTOOLPY_MONITOR_BAUD_9600B is not set +# CONFIG_ESPTOOLPY_MONITOR_BAUD_57600B is not set +CONFIG_ESPTOOLPY_MONITOR_BAUD_115200B=y +# CONFIG_ESPTOOLPY_MONITOR_BAUD_230400B is not set +# CONFIG_ESPTOOLPY_MONITOR_BAUD_921600B is not set +# CONFIG_ESPTOOLPY_MONITOR_BAUD_2MB is not set +# CONFIG_ESPTOOLPY_MONITOR_BAUD_OTHER is not set +CONFIG_ESPTOOLPY_MONITOR_BAUD_OTHER_VAL=115200 +CONFIG_ESPTOOLPY_MONITOR_BAUD=115200 # end of Serial flasher config +# CONFIG_PARTITION_TABLE_SINGLE_APP is not set # # Partition Table # -# CONFIG_PARTITION_TABLE_SINGLE_APP is not set +# CONFIG_PARTITION_TABLE_SINGLE_APP_LARGE is not set +# CONFIG_PARTITION_TABLE_TWO_OTA is not set CONFIG_PARTITION_TABLE_CUSTOM=y +CONFIG_PARTITION_TABLE_OFFSET=0x8000 +CONFIG_PARTITION_TABLE_MD5=y # end of Partition Table +CONFIG_COMPILER_HIDE_PATHS_MACROS=y # # Compiler options # -# CONFIG_COMPILER_OPTIMIZATION_DEFAULT is not set -CONFIG_COMPILER_OPTIMIZATION_SIZE=y -# CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_ENABLE is not set -CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y +# CONFIG_COMPILER_CXX_EXCEPTIONS is not set +# CONFIG_COMPILER_CXX_RTTI is not set +CONFIG_COMPILER_STACK_CHECK_MODE_NONE=y +# CONFIG_COMPILER_STACK_CHECK_MODE_NORM is not set +# CONFIG_COMPILER_STACK_CHECK_MODE_STRONG is not set +# CONFIG_COMPILER_STACK_CHECK_MODE_ALL is not set +# CONFIG_COMPILER_WARN_WRITE_STRINGS is not set +# CONFIG_COMPILER_DISABLE_GCC8_WARNINGS is not set +# CONFIG_COMPILER_DUMP_RTL_FILES is not set # end of Compiler options +# CONFIG_APPTRACE_DEST_JTAG is not set +# +# Application Level Tracing +# +CONFIG_APPTRACE_DEST_NONE=y +CONFIG_APPTRACE_LOCK_ENABLE=y +# end of Application Level Tracing + +# CONFIG_ADC_FORCE_XPD_FSM is not set +# +# ADC configuration +# +CONFIG_ADC_DISABLE_DAC=y +# end of ADC configuration + +# CONFIG_MCPWM_ISR_IN_IRAM is not set +# +# SPI configuration +# +# CONFIG_SPI_MASTER_IN_IRAM is not set +CONFIG_SPI_MASTER_ISR_IN_IRAM=y +# CONFIG_SPI_SLAVE_IN_IRAM is not set +CONFIG_SPI_SLAVE_ISR_IN_IRAM=y +# end of SPI configuration + +# CONFIG_TWAI_ISR_IN_IRAM is not set +# +# UART configuration +# +# CONFIG_UART_ISR_IN_IRAM is not set +# end of UART configuration + +# CONFIG_GDMA_CTRL_FUNC_IN_IRAM is not set +# +# GDMA Configuration +# +# CONFIG_GDMA_ISR_IRAM_SAFE is not set +# end of GDMA Configuration + +# CONFIG_EFUSE_CUSTOM_TABLE is not set +# +# eFuse Bit Manager +# +# CONFIG_EFUSE_VIRTUAL is not set +CONFIG_EFUSE_MAX_BLK_LEN=256 +# end of eFuse Bit Manager + +CONFIG_ESP_TLS_USING_MBEDTLS=y # # ESP-TLS # +CONFIG_ESP_TLS_USE_DS_PERIPHERAL=y CONFIG_ESP_TLS_SERVER=y +# CONFIG_ESP_TLS_CLIENT_SESSION_TICKETS is not set +# CONFIG_ESP_TLS_SERVER_SESSION_TICKETS is not set +# CONFIG_ESP_TLS_PSK_VERIFICATION is not set +# CONFIG_ESP_TLS_INSECURE is not set # end of ESP-TLS -# -# ESP32S2-specific -# -# CONFIG_ESP32S2_DEFAULT_CPU_FREQ_160 is not set -CONFIG_ESP32S2_DEFAULT_CPU_FREQ_240=y -CONFIG_ESP32S2_DEFAULT_CPU_FREQ_MHZ=240 -# -# Cache config -# -# CONFIG_ESP32S2_INSTRUCTION_CACHE_8KB is not set -CONFIG_ESP32S2_INSTRUCTION_CACHE_16KB=y -# CONFIG_ESP32S2_DATA_CACHE_8KB is not set -CONFIG_ESP32S2_DATA_CACHE_16KB=y -# end of Cache config -# end of ESP32S2-specific - -# -# ESP32S3-specific -# -# CONFIG_ESP32S3_DEFAULT_CPU_FREQ_160 is not set -CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240=y -CONFIG_ESP32S3_DEFAULT_CPU_FREQ_MHZ=240 -# end of ESP32S3-specific - -# -# Common ESP-related -# -CONFIG_ESP_MAIN_TASK_STACK_SIZE=8192 -# CONFIG_ESP_TASK_WDT is not set -# end of Common ESP-related - +# CONFIG_ETH_USE_SPI_ETHERNET is not set # # Ethernet # -# CONFIG_ETH_USE_SPI_ETHERNET is not set +# CONFIG_ETH_USE_OPENETH is not set # end of Ethernet +# CONFIG_ESP_EVENT_LOOP_PROFILING is not set +# +# Event Loop Library +# +CONFIG_ESP_EVENT_POST_FROM_ISR=y +CONFIG_ESP_EVENT_POST_FROM_IRAM_ISR=y +# end of Event Loop Library + +CONFIG_ESP_MAC_ADDR_UNIVERSE_WIFI_STA=y +# +# MAC Config +# +CONFIG_ESP_MAC_ADDR_UNIVERSE_WIFI_AP=y +CONFIG_ESP_MAC_ADDR_UNIVERSE_BT=y +CONFIG_ESP_MAC_ADDR_UNIVERSE_ETH=y +# end of MAC Config + +CONFIG_ESP_SLEEP_RTC_BUS_ISO_WORKAROUND=y +# +# Sleep Config +# +# CONFIG_ESP_SLEEP_PSRAM_LEAKAGE_WORKAROUND is not set +# CONFIG_ESP_SLEEP_FLASH_LEAKAGE_WORKAROUND is not set +# end of Sleep Config + +CONFIG_ESP_IPC_TASK_STACK_SIZE=1536 +# +# IPC (Inter-Processor Call) +# +CONFIG_ESP_IPC_USES_CALLERS_PRIORITY=y +CONFIG_ESP_IPC_ISR_ENABLE=y +# end of IPC (Inter-Processor Call) + +CONFIG_ESP_NETIF_IP_LOST_TIMER_INTERVAL=120 # # ESP NETIF Adapter # +CONFIG_ESP_NETIF_TCPIP_LWIP=y +# CONFIG_ESP_NETIF_LOOPBACK is not set # CONFIG_ESP_NETIF_TCPIP_ADAPTER_COMPATIBLE_LAYER is not set # end of ESP NETIF Adapter +CONFIG_ESP_PHY_CALIBRATION_AND_DATA_STORAGE=y +# +# PHY +# +# CONFIG_ESP_PHY_INIT_DATA_IN_PARTITION is not set +CONFIG_ESP_PHY_MAX_WIFI_TX_POWER=20 +CONFIG_ESP_PHY_MAX_TX_POWER=20 +# end of PHY + +# CONFIG_PM_ENABLE is not set +# +# Power Management +# +CONFIG_PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP=y +CONFIG_PM_POWER_DOWN_TAGMEM_IN_LIGHT_SLEEP=y +# end of Power Management + +# CONFIG_ESP_SYSTEM_GDBSTUB_RUNTIME is not set +# +# ESP System Settings +# +CONFIG_ESP_SYSTEM_RTC_FAST_MEM_AS_HEAP_DEPCHECK=y +CONFIG_ESP_SYSTEM_ALLOW_RTC_FAST_MEM_AS_HEAP=y +# end of ESP System Settings + +CONFIG_ESP_SYSTEM_EVENT_QUEUE_SIZE=32 +CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE=2304 +CONFIG_ESP_MAIN_TASK_STACK_SIZE=8192 +CONFIG_ESP_MINIMAL_SHARED_STACK_SIZE=2048 +CONFIG_ESP_INT_WDT=y +CONFIG_ESP_INT_WDT_TIMEOUT_MS=300 +CONFIG_ESP_INT_WDT_CHECK_CPU1=y +# CONFIG_ESP_TASK_WDT is not set +# CONFIG_ESP_PANIC_HANDLER_IRAM is not set +CONFIG_ESP_SYSTEM_CHECK_INT_LEVEL_4=y +# +# High resolution timer (esp_timer) +# +# CONFIG_ESP_TIMER_PROFILING is not set +CONFIG_ESP_TIME_FUNCS_USE_RTC_TIMER=y +CONFIG_ESP_TIME_FUNCS_USE_ESP_TIMER=y +CONFIG_ESP_TIMER_TASK_STACK_SIZE=3584 +CONFIG_ESP_TIMER_INTERRUPT_LEVEL=1 +# CONFIG_ESP_TIMER_SUPPORTS_ISR_DISPATCH_METHOD is not set +CONFIG_ESP_TIMER_IMPL_SYSTIMER=y +# end of High resolution timer (esp_timer) + +# CONFIG_ESP_WIFI_SLP_IRAM_OPT is not set # # Wi-Fi # -CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM=4 -CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM=8 -CONFIG_ESP32_WIFI_CACHE_TX_BUFFER_NUM=16 -CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM=16 -# CONFIG_ESP32_WIFI_NVS_ENABLED is not set -# CONFIG_ESP32_WIFI_ENABLE_WPA3_SAE is not set +# CONFIG_ESP_WIFI_FTM_ENABLE is not set +# CONFIG_ESP_WIFI_STA_DISCONNECTED_PM_ENABLE is not set +# CONFIG_ESP_WIFI_GCMP_SUPPORT is not set +# CONFIG_ESP_WIFI_GMAC_SUPPORT is not set +CONFIG_ESP_WIFI_SOFTAP_SUPPORT=y # end of Wi-Fi +# CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH is not set +# +# Core dump +# +# CONFIG_ESP_COREDUMP_ENABLE_TO_UART is not set +CONFIG_ESP_COREDUMP_ENABLE_TO_NONE=y +# end of Core dump + +CONFIG_FREERTOS_NO_AFFINITY=0x7FFFFFFF # # FreeRTOS # +CONFIG_FREERTOS_TICK_SUPPORT_SYSTIMER=y +CONFIG_FREERTOS_CORETIMER_SYSTIMER_LVL1=y +# CONFIG_FREERTOS_CORETIMER_SYSTIMER_LVL3 is not set +CONFIG_FREERTOS_SYSTICK_USES_SYSTIMER=y +CONFIG_FREERTOS_HZ=100 +# CONFIG_FREERTOS_CHECK_STACKOVERFLOW_NONE is not set +# CONFIG_FREERTOS_CHECK_STACKOVERFLOW_PTRVAL is not set +CONFIG_FREERTOS_CHECK_STACKOVERFLOW_CANARY=y +# CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK is not set +CONFIG_FREERTOS_INTERRUPT_BACKTRACE=y +CONFIG_FREERTOS_THREAD_LOCAL_STORAGE_POINTERS=1 CONFIG_FREERTOS_IDLE_TASK_STACKSIZE=1536 +CONFIG_FREERTOS_ISR_STACKSIZE=1536 +# CONFIG_FREERTOS_LEGACY_HOOKS is not set +CONFIG_FREERTOS_MAX_TASK_NAME_LEN=16 +CONFIG_FREERTOS_SUPPORT_STATIC_ALLOCATION=y +# CONFIG_FREERTOS_ENABLE_STATIC_TASK_CLEAN_UP is not set +CONFIG_FREERTOS_TIMER_TASK_PRIORITY=1 +CONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH=2048 +CONFIG_FREERTOS_TIMER_QUEUE_LENGTH=10 +CONFIG_FREERTOS_QUEUE_REGISTRY_SIZE=0 +# CONFIG_FREERTOS_USE_TRACE_FACILITY is not set +# CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS is not set +CONFIG_FREERTOS_CHECK_MUTEX_GIVEN_BY_OWNER=y +# CONFIG_FREERTOS_CHECK_PORT_CRITICAL_COMPLIANCE is not set +# CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH is not set +CONFIG_FREERTOS_ENABLE_TASK_SNAPSHOT=y +# CONFIG_FREERTOS_PLACE_SNAPSHOT_FUNS_INTO_FLASH is not set # end of FreeRTOS +CONFIG_HEAP_POISONING_DISABLED=y +# +# Heap memory debugging +# +# CONFIG_HEAP_POISONING_LIGHT is not set +# CONFIG_HEAP_POISONING_COMPREHENSIVE is not set +CONFIG_HEAP_TRACING_OFF=y +# CONFIG_HEAP_TRACING_STANDALONE is not set +# CONFIG_HEAP_TRACING_TOHOST is not set +# CONFIG_HEAP_ABORT_WHEN_ALLOCATION_FAILS is not set +# end of Heap memory debugging + +# CONFIG_LOG_DEFAULT_LEVEL_NONE is not set +# +# Log output +# +# CONFIG_LOG_DEFAULT_LEVEL_ERROR is not set +# CONFIG_LOG_DEFAULT_LEVEL_WARN is not set +CONFIG_LOG_DEFAULT_LEVEL_INFO=y +# CONFIG_LOG_DEFAULT_LEVEL_DEBUG is not set +# CONFIG_LOG_DEFAULT_LEVEL_VERBOSE is not set +CONFIG_LOG_DEFAULT_LEVEL=3 +CONFIG_LOG_MAXIMUM_EQUALS_DEFAULT=y +# CONFIG_LOG_MAXIMUM_LEVEL_DEBUG is not set +# CONFIG_LOG_MAXIMUM_LEVEL_VERBOSE is not set +CONFIG_LOG_MAXIMUM_LEVEL=3 +CONFIG_LOG_COLORS=y +CONFIG_LOG_TIMESTAMP_SOURCE_RTOS=y +# CONFIG_LOG_TIMESTAMP_SOURCE_SYSTEM is not set +# end of Log output + +# CONFIG_LWIP_NETIF_API is not set # # LWIP # +# CONFIG_LWIP_TCPIP_CORE_LOCKING is not set +CONFIG_LWIP_DNS_SUPPORT_MDNS_QUERIES=y +# CONFIG_LWIP_L2_TO_L3_COPY is not set +# CONFIG_LWIP_IRAM_OPTIMIZATION is not set +CONFIG_LWIP_TIMERS_ONDEMAND=y CONFIG_LWIP_MAX_SOCKETS=4 +# CONFIG_LWIP_USE_ONLY_LWIP_SELECT is not set +# CONFIG_LWIP_SO_LINGER is not set +CONFIG_LWIP_SO_REUSE=y +CONFIG_LWIP_SO_REUSE_RXTOALL=y CONFIG_LWIP_SO_RCVBUF=y +# CONFIG_LWIP_NETBUF_RECVINFO is not set +CONFIG_LWIP_IP4_FRAG=y +CONFIG_LWIP_IP6_FRAG=y +# CONFIG_LWIP_IP4_REASSEMBLY is not set +# CONFIG_LWIP_IP6_REASSEMBLY is not set +# CONFIG_LWIP_IP_FORWARD is not set +# CONFIG_LWIP_STATS is not set +# CONFIG_LWIP_ETHARP_TRUST_IP_MAC is not set +CONFIG_LWIP_ESP_GRATUITOUS_ARP=y +CONFIG_LWIP_GARP_TMR_INTERVAL=60 +CONFIG_LWIP_TCPIP_RECVMBOX_SIZE=32 +CONFIG_LWIP_DHCP_DOES_ARP_CHECK=y +# CONFIG_LWIP_DHCP_DISABLE_CLIENT_ID is not set +CONFIG_LWIP_DHCP_DISABLE_VENDOR_CLASS_ID=y +# CONFIG_LWIP_DHCP_RESTORE_LAST_IP is not set +CONFIG_LWIP_DHCP_OPTIONS_LEN=68 +# end of LWIP + +CONFIG_LWIP_DHCPS=y +# +# DHCP server +# +CONFIG_LWIP_DHCPS_LEASE_UNIT=60 +CONFIG_LWIP_DHCPS_MAX_STATION_NUM=8 +# end of DHCP server + +# CONFIG_LWIP_AUTOIP is not set +CONFIG_LWIP_IPV6=y +# CONFIG_LWIP_IPV6_AUTOCONFIG is not set +CONFIG_LWIP_IPV6_NUM_ADDRESSES=3 +# CONFIG_LWIP_IPV6_FORWARD is not set +# CONFIG_LWIP_NETIF_STATUS_CALLBACK is not set +CONFIG_LWIP_NETIF_LOOPBACK=y +CONFIG_LWIP_LOOPBACK_MAX_PBUFS=8 # # TCP # CONFIG_LWIP_MAX_ACTIVE_TCP=4 CONFIG_LWIP_MAX_LISTENING_TCP=4 +CONFIG_LWIP_TCP_HIGH_SPEED_RETRANSMISSION=y +CONFIG_LWIP_TCP_MAXRTX=12 CONFIG_LWIP_TCP_SYNMAXRTX=6 +CONFIG_LWIP_TCP_MSS=1440 +CONFIG_LWIP_TCP_TMR_INTERVAL=250 +CONFIG_LWIP_TCP_MSL=60000 CONFIG_LWIP_TCP_SND_BUF_DEFAULT=2880 CONFIG_LWIP_TCP_WND_DEFAULT=2880 +CONFIG_LWIP_TCP_RECVMBOX_SIZE=6 +CONFIG_LWIP_TCP_QUEUE_OOSEQ=y +# CONFIG_LWIP_TCP_SACK_OUT is not set +# CONFIG_LWIP_TCP_KEEP_CONNECTION_WHEN_IP_CHANGES is not set +CONFIG_LWIP_TCP_OVERSIZE_MSS=y +# CONFIG_LWIP_TCP_OVERSIZE_QUARTER_MSS is not set +# CONFIG_LWIP_TCP_OVERSIZE_DISABLE is not set CONFIG_LWIP_TCP_RTO_TIME=3000 # end of TCP -# end of LWIP +CONFIG_LWIP_MAX_UDP_PCBS=16 +# +# UDP +# +CONFIG_LWIP_UDP_RECVMBOX_SIZE=6 +# end of UDP + +# CONFIG_LWIP_CHECKSUM_CHECK_IP is not set +# +# Checksums +# +# CONFIG_LWIP_CHECKSUM_CHECK_UDP is not set +CONFIG_LWIP_CHECKSUM_CHECK_ICMP=y +# end of Checksums + +CONFIG_LWIP_TCPIP_TASK_STACK_SIZE=3072 +CONFIG_LWIP_TCPIP_TASK_AFFINITY_NO_AFFINITY=y +# CONFIG_LWIP_TCPIP_TASK_AFFINITY_CPU0 is not set +# CONFIG_LWIP_TCPIP_TASK_AFFINITY_CPU1 is not set +CONFIG_LWIP_TCPIP_TASK_AFFINITY=0x7FFFFFFF +# CONFIG_LWIP_PPP_SUPPORT is not set +CONFIG_LWIP_IPV6_MEMP_NUM_ND6_QUEUE=3 +CONFIG_LWIP_IPV6_ND6_NUM_NEIGHBORS=5 +# CONFIG_LWIP_SLIP_SUPPORT is not set +# +# ICMP +# +CONFIG_LWIP_ICMP=y +# CONFIG_LWIP_MULTICAST_PING is not set +# CONFIG_LWIP_BROADCAST_PING is not set +# end of ICMP + +CONFIG_LWIP_MAX_RAW_PCBS=16 +# +# SNTP +# +CONFIG_LWIP_SNTP_MAX_SERVERS=1 +# CONFIG_LWIP_DHCP_GET_NTP_SRV is not set +CONFIG_LWIP_SNTP_UPDATE_DELAY=3600000 +# end of SNTP + +# CONFIG_LWIP_HOOK_TCP_ISN_NONE is not set +# +# Hooks +# +CONFIG_LWIP_HOOK_TCP_ISN_DEFAULT=y +# CONFIG_LWIP_HOOK_TCP_ISN_CUSTOM is not set +CONFIG_LWIP_HOOK_IP6_ROUTE_NONE=y +# CONFIG_LWIP_HOOK_IP6_ROUTE_DEFAULT is not set +# CONFIG_LWIP_HOOK_IP6_ROUTE_CUSTOM is not set +CONFIG_LWIP_HOOK_ND6_GET_GW_NONE=y +# CONFIG_LWIP_HOOK_ND6_GET_GW_DEFAULT is not set +# CONFIG_LWIP_HOOK_ND6_GET_GW_CUSTOM is not set +CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_NONE=y +# CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_DEFAULT is not set +# CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_CUSTOM is not set +# end of Hooks + +# CONFIG_LWIP_DEBUG is not set # # mbedTLS # +CONFIG_MBEDTLS_INTERNAL_MEM_ALLOC=y +# CONFIG_MBEDTLS_DEFAULT_MEM_ALLOC is not set +# CONFIG_MBEDTLS_CUSTOM_MEM_ALLOC is not set +CONFIG_MBEDTLS_ASYMMETRIC_CONTENT_LEN=y +CONFIG_MBEDTLS_SSL_IN_CONTENT_LEN=16384 CONFIG_MBEDTLS_SSL_OUT_CONTENT_LEN=2048 -CONFIG_MBEDTLS_DYNAMIC_BUFFER=y -CONFIG_MBEDTLS_DYNAMIC_FREE_PEER_CERT=y -CONFIG_MBEDTLS_DYNAMIC_FREE_CONFIG_DATA=y -CONFIG_MBEDTLS_DYNAMIC_FREE_CA_CERT=y +# CONFIG_MBEDTLS_DEBUG is not set +# end of mbedTLS + +CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=y # # Certificate Bundle # -CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=y # CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL is not set +# CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_CMN is not set CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_NONE=y CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE=y CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE_PATH="certificates/nina-fw/data/roots.pem" # end of Certificate Bundle + +# CONFIG_MBEDTLS_ECP_RESTARTABLE is not set +# CONFIG_MBEDTLS_CMAC_C is not set +CONFIG_MBEDTLS_HARDWARE_AES=y +CONFIG_MBEDTLS_AES_USE_INTERRUPT=y +CONFIG_MBEDTLS_HARDWARE_MPI=y +CONFIG_MBEDTLS_HARDWARE_SHA=y +CONFIG_MBEDTLS_ROM_MD5=y +# CONFIG_MBEDTLS_ATCA_HW_ECDSA_SIGN is not set +# CONFIG_MBEDTLS_ATCA_HW_ECDSA_VERIFY is not set +CONFIG_MBEDTLS_HAVE_TIME=y +# CONFIG_MBEDTLS_HAVE_TIME_DATE is not set +CONFIG_MBEDTLS_ECDSA_DETERMINISTIC=y +CONFIG_MBEDTLS_SHA512_C=y +CONFIG_MBEDTLS_TLS_SERVER_AND_CLIENT=y +# CONFIG_MBEDTLS_TLS_SERVER_ONLY is not set +# CONFIG_MBEDTLS_TLS_CLIENT_ONLY is not set +# CONFIG_MBEDTLS_TLS_DISABLED is not set +CONFIG_MBEDTLS_TLS_SERVER=y +CONFIG_MBEDTLS_TLS_CLIENT=y +CONFIG_MBEDTLS_TLS_ENABLED=y # # TLS Key Exchange Methods # @@ -130,30 +552,243 @@ CONFIG_MBEDTLS_KEY_EXCHANGE_PSK=y CONFIG_MBEDTLS_KEY_EXCHANGE_DHE_PSK=y CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_PSK=y CONFIG_MBEDTLS_KEY_EXCHANGE_RSA_PSK=y +CONFIG_MBEDTLS_KEY_EXCHANGE_RSA=y +CONFIG_MBEDTLS_KEY_EXCHANGE_DHE_RSA=y +CONFIG_MBEDTLS_KEY_EXCHANGE_ELLIPTIC_CURVE=y +CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_RSA=y +CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA=y +CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA=y +CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_RSA=y # end of TLS Key Exchange Methods + +CONFIG_MBEDTLS_SSL_RENEGOTIATION=y +# CONFIG_MBEDTLS_SSL_PROTO_SSL3 is not set # CONFIG_MBEDTLS_SSL_PROTO_TLS1 is not set # CONFIG_MBEDTLS_SSL_PROTO_TLS1_1 is not set +CONFIG_MBEDTLS_SSL_PROTO_TLS1_2=y +# CONFIG_MBEDTLS_SSL_PROTO_GMTSSL1_1 is not set CONFIG_MBEDTLS_SSL_PROTO_DTLS=y -# CONFIG_MBEDTLS_LARGE_KEY_SOFTWARE_MPI is not set -# end of mbedTLS +CONFIG_MBEDTLS_SSL_ALPN=y +CONFIG_MBEDTLS_CLIENT_SSL_SESSION_TICKETS=y +CONFIG_MBEDTLS_X509_CHECK_KEY_USAGE=y +CONFIG_MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE=y +CONFIG_MBEDTLS_SERVER_SSL_SESSION_TICKETS=y +# +# Symmetric Ciphers +# +CONFIG_MBEDTLS_AES_C=y +# CONFIG_MBEDTLS_CAMELLIA_C is not set +# CONFIG_MBEDTLS_DES_C is not set +CONFIG_MBEDTLS_RC4_DISABLED=y +# CONFIG_MBEDTLS_RC4_ENABLED_NO_DEFAULT is not set +# CONFIG_MBEDTLS_RC4_ENABLED is not set +# CONFIG_MBEDTLS_BLOWFISH_C is not set +# CONFIG_MBEDTLS_XTEA_C is not set +CONFIG_MBEDTLS_CCM_C=y +CONFIG_MBEDTLS_GCM_C=y +# CONFIG_MBEDTLS_NIST_KW_C is not set +# end of Symmetric Ciphers +# CONFIG_MBEDTLS_RIPEMD160_C is not set +# +# Certificates +# +CONFIG_MBEDTLS_PEM_PARSE_C=y +CONFIG_MBEDTLS_PEM_WRITE_C=y +CONFIG_MBEDTLS_X509_CRL_PARSE_C=y +CONFIG_MBEDTLS_X509_CSR_PARSE_C=y +# end of Certificates + +CONFIG_MBEDTLS_ECP_C=y +CONFIG_MBEDTLS_ECDH_C=y +CONFIG_MBEDTLS_ECDSA_C=y +# CONFIG_MBEDTLS_ECJPAKE_C is not set +CONFIG_MBEDTLS_ECP_DP_SECP192R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_SECP224R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_SECP384R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_SECP521R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_SECP192K1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_SECP224K1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_SECP256K1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_BP256R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_BP384R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_BP512R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_CURVE25519_ENABLED=y +CONFIG_MBEDTLS_ECP_NIST_OPTIM=y +# CONFIG_MBEDTLS_POLY1305_C is not set +# CONFIG_MBEDTLS_CHACHA20_C is not set +# CONFIG_MBEDTLS_HKDF_C is not set +# CONFIG_MBEDTLS_THREADING_C is not set +# CONFIG_MBEDTLS_LARGE_KEY_SOFTWARE_MPI is not set +# CONFIG_MBEDTLS_SECURITY_RISKS is not set +# +# Newlib +# +CONFIG_NEWLIB_STDOUT_LINE_ENDING_CRLF=y +# CONFIG_NEWLIB_STDOUT_LINE_ENDING_LF is not set +# CONFIG_NEWLIB_STDOUT_LINE_ENDING_CR is not set +# CONFIG_NEWLIB_STDIN_LINE_ENDING_CRLF is not set +# CONFIG_NEWLIB_STDIN_LINE_ENDING_LF is not set +CONFIG_NEWLIB_STDIN_LINE_ENDING_CR=y +# CONFIG_NEWLIB_NANO_FORMAT is not set +# end of Newlib + +# CONFIG_OPENTHREAD_ENABLED is not set +# +# PThreads +# +CONFIG_PTHREAD_TASK_PRIO_DEFAULT=5 +CONFIG_PTHREAD_TASK_STACK_SIZE_DEFAULT=3072 +CONFIG_PTHREAD_STACK_MIN=768 +CONFIG_PTHREAD_DEFAULT_CORE_NO_AFFINITY=y +# CONFIG_PTHREAD_DEFAULT_CORE_0 is not set +# CONFIG_PTHREAD_DEFAULT_CORE_1 is not set +CONFIG_PTHREAD_TASK_CORE_DEFAULT=-1 +CONFIG_PTHREAD_TASK_NAME_DEFAULT="pthread" +# end of PThreads + +# CONFIG_SPI_FLASH_VERIFY_WRITE is not set # # SPI Flash driver # +# CONFIG_SPI_FLASH_ENABLE_COUNTERS is not set +CONFIG_SPI_FLASH_ROM_DRIVER_PATCH=y +# CONFIG_SPI_FLASH_ROM_IMPL is not set +CONFIG_SPI_FLASH_DANGEROUS_WRITE_ABORTS=y +# CONFIG_SPI_FLASH_DANGEROUS_WRITE_FAILS is not set +# CONFIG_SPI_FLASH_DANGEROUS_WRITE_ALLOWED is not set +# CONFIG_SPI_FLASH_USE_LEGACY_IMPL is not set +# CONFIG_SPI_FLASH_SHARE_SPI1_BUS is not set +# CONFIG_SPI_FLASH_BYPASS_BLOCK_ERASE is not set # CONFIG_SPI_FLASH_YIELD_DURING_ERASE is not set CONFIG_SPI_FLASH_WRITE_CHUNK_SIZE=4096 +# CONFIG_SPI_FLASH_SIZE_OVERRIDE is not set +# CONFIG_SPI_FLASH_CHECK_ERASE_TIMEOUT_DISABLED is not set +# CONFIG_SPI_FLASH_OVERRIDE_CHIP_DRIVER_LIST is not set # end of SPI Flash driver +CONFIG_SPI_FLASH_SUPPORT_ISSI_CHIP=y +# +# Auto-detect flash chips +# +CONFIG_SPI_FLASH_SUPPORT_MXIC_CHIP=y +CONFIG_SPI_FLASH_SUPPORT_GD_CHIP=y +CONFIG_SPI_FLASH_SUPPORT_WINBOND_CHIP=y +CONFIG_SPI_FLASH_SUPPORT_BOYA_CHIP=y +CONFIG_SPI_FLASH_SUPPORT_MXIC_OPI_CHIP=y +# end of Auto-detect flash chips + +CONFIG_SPI_FLASH_ENABLE_ENCRYPTED_READ_WRITE=y +# +# Virtual file system +# +CONFIG_VFS_SUPPORT_IO=y +CONFIG_VFS_SUPPORT_DIR=y +CONFIG_VFS_SUPPORT_SELECT=y +CONFIG_VFS_SUPPRESS_SELECT_DEBUG_OUTPUT=y +CONFIG_VFS_SUPPORT_TERMIOS=y +# end of Virtual file system + +CONFIG_VFS_SEMIHOSTFS_MAX_MOUNT_POINTS=1 +# +# Host File System I/O (Semihosting) +# +CONFIG_VFS_SEMIHOSTFS_HOST_PATH_MAX_LEN=128 +# end of Host File System I/O (Semihosting) + +CONFIG_WPA_MBEDTLS_CRYPTO=y +# +# Supplicant +# +# CONFIG_WPA_WAPI_PSK is not set +# CONFIG_WPA_SUITE_B_192 is not set +# CONFIG_WPA_DEBUG_PRINT is not set +# CONFIG_WPA_TESTING_OPTIONS is not set +# CONFIG_WPA_WPS_STRICT is not set +# CONFIG_WPA_11KV_SUPPORT is not set +# end of Supplicant + +# CONFIG_LEGACY_INCLUDE_COMMON_HEADERS is not set # # Deprecated options for backward compatibility # -# CONFIG_COMPILER_OPTIMIZATION_LEVEL_DEBUG is not set -CONFIG_COMPILER_OPTIMIZATION_LEVEL_RELEASE=y -# CONFIG_OPTIMIZATION_ASSERTIONS_ENABLED is not set -CONFIG_OPTIMIZATION_ASSERTIONS_SILENT=y +# CONFIG_LOG_BOOTLOADER_LEVEL_NONE is not set +# CONFIG_LOG_BOOTLOADER_LEVEL_ERROR is not set +# CONFIG_LOG_BOOTLOADER_LEVEL_WARN is not set +CONFIG_LOG_BOOTLOADER_LEVEL_INFO=y +# CONFIG_LOG_BOOTLOADER_LEVEL_DEBUG is not set +# CONFIG_LOG_BOOTLOADER_LEVEL_VERBOSE is not set +CONFIG_LOG_BOOTLOADER_LEVEL=3 +# CONFIG_APP_ROLLBACK_ENABLE is not set +# CONFIG_FLASH_ENCRYPTION_ENABLED is not set +# CONFIG_FLASHMODE_QIO is not set +# CONFIG_FLASHMODE_QOUT is not set +CONFIG_FLASHMODE_DIO=y +# CONFIG_FLASHMODE_DOUT is not set +# CONFIG_MONITOR_BAUD_9600B is not set +# CONFIG_MONITOR_BAUD_57600B is not set +CONFIG_MONITOR_BAUD_115200B=y +# CONFIG_MONITOR_BAUD_230400B is not set +# CONFIG_MONITOR_BAUD_921600B is not set +# CONFIG_MONITOR_BAUD_2MB is not set +# CONFIG_MONITOR_BAUD_OTHER is not set +CONFIG_MONITOR_BAUD_OTHER_VAL=115200 +CONFIG_MONITOR_BAUD=115200 +# CONFIG_CXX_EXCEPTIONS is not set +CONFIG_STACK_CHECK_NONE=y +# CONFIG_STACK_CHECK_NORM is not set +# CONFIG_STACK_CHECK_STRONG is not set +# CONFIG_STACK_CHECK_ALL is not set +# CONFIG_WARN_WRITE_STRINGS is not set +# CONFIG_DISABLE_GCC8_WARNINGS is not set +CONFIG_ADC2_DISABLE_DAC=y +# CONFIG_EVENT_LOOP_PROFILING is not set +CONFIG_POST_EVENTS_FROM_ISR=y +CONFIG_POST_EVENTS_FROM_IRAM_ISR=y +CONFIG_IPC_TASK_STACK_SIZE=1536 +CONFIG_ESP_SYSTEM_PM_POWER_DOWN_CPU=y +CONFIG_SYSTEM_EVENT_QUEUE_SIZE=32 +CONFIG_SYSTEM_EVENT_TASK_STACK_SIZE=2304 CONFIG_MAIN_TASK_STACK_SIZE=8192 +CONFIG_INT_WDT=y +CONFIG_INT_WDT_TIMEOUT_MS=300 +CONFIG_INT_WDT_CHECK_CPU1=y # CONFIG_TASK_WDT is not set +CONFIG_TIMER_TASK_STACK_SIZE=3584 +# CONFIG_ENABLE_STATIC_TASK_CLEAN_UP_HOOK is not set +CONFIG_TIMER_TASK_PRIORITY=1 +CONFIG_TIMER_TASK_STACK_DEPTH=2048 +CONFIG_TIMER_QUEUE_LENGTH=10 +# CONFIG_L2_TO_L3_COPY is not set +# CONFIG_USE_ONLY_LWIP_SELECT is not set +CONFIG_ESP_GRATUITOUS_ARP=y +CONFIG_GARP_TMR_INTERVAL=60 +CONFIG_TCPIP_RECVMBOX_SIZE=32 +CONFIG_TCP_MAXRTX=12 CONFIG_TCP_SYNMAXRTX=6 +CONFIG_TCP_MSS=1440 +CONFIG_TCP_MSL=60000 CONFIG_TCP_SND_BUF_DEFAULT=2880 CONFIG_TCP_WND_DEFAULT=2880 -# End of deprecated options +CONFIG_TCP_RECVMBOX_SIZE=6 +CONFIG_TCP_QUEUE_OOSEQ=y +# CONFIG_ESP_TCP_KEEP_CONNECTION_WHEN_IP_CHANGES is not set +CONFIG_TCP_OVERSIZE_MSS=y +# CONFIG_TCP_OVERSIZE_QUARTER_MSS is not set +# CONFIG_TCP_OVERSIZE_DISABLE is not set +CONFIG_UDP_RECVMBOX_SIZE=6 +CONFIG_TCPIP_TASK_STACK_SIZE=3072 +CONFIG_TCPIP_TASK_AFFINITY_NO_AFFINITY=y +# CONFIG_TCPIP_TASK_AFFINITY_CPU0 is not set +# CONFIG_TCPIP_TASK_AFFINITY_CPU1 is not set +CONFIG_TCPIP_TASK_AFFINITY=0x7FFFFFFF +# CONFIG_PPP_SUPPORT is not set +CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_ABORTS=y +# CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_FAILS is not set +# CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_ALLOWED is not set +CONFIG_SUPPRESS_SELECT_DEBUG_OUTPUT=y +CONFIG_SUPPORT_TERMIOS=y +CONFIG_SEMIHOSTFS_MAX_MOUNT_POINTS=1 +CONFIG_SEMIHOSTFS_HOST_PATH_MAX_LEN=128 +# end of Deprecated options for backward compatibility diff --git a/ports/espressif/mpconfigport.h b/ports/espressif/mpconfigport.h index 62e37d9374..1c5f1b1463 100644 --- a/ports/espressif/mpconfigport.h +++ b/ports/espressif/mpconfigport.h @@ -35,8 +35,19 @@ #include "py/circuitpy_mpconfig.h" +#if CIRCUITPY_BLEIO +#include "common-hal/_bleio/ble_events.h" +#endif + +#if CIRCUITPY_BLEIO +#define MICROPY_PORT_ROOT_POINTERS \ + CIRCUITPY_COMMON_ROOT_POINTERS \ + ble_event_handler_entry_t *ble_event_handler_entries; +#else #define MICROPY_PORT_ROOT_POINTERS \ CIRCUITPY_COMMON_ROOT_POINTERS +#endif + #define MICROPY_NLR_SETJMP (1) #define CIRCUITPY_DEFAULT_STACK_SIZE 0x6000 @@ -61,4 +72,5 @@ #ifndef CIRCUITPY_I2C_ALLOW_INTERNAL_PULL_UP #define CIRCUITPY_I2C_ALLOW_INTERNAL_PULL_UP (0) #endif + #endif // MICROPY_INCLUDED_ESPRESSIF_MPCONFIGPORT_H diff --git a/ports/espressif/mpconfigport.mk b/ports/espressif/mpconfigport.mk index 21459e01f5..46e5bd3bb7 100644 --- a/ports/espressif/mpconfigport.mk +++ b/ports/espressif/mpconfigport.mk @@ -1,8 +1,3 @@ -# Define an equivalent for MICROPY_LONGINT_IMPL, to pass to $(MPY-TOOL) in py/mkrules.mk -# $(MPY-TOOL) needs to know what kind of longint to use (if any) to freeze long integers. -# This should correspond to the MICROPY_LONGINT_IMPL definition in mpconfigport.h. -MPY_TOOL_LONGINT_IMPL = -mlongint-impl=mpz - # Internal math library is substantially smaller than toolchain one INTERNAL_LIBM = 1 @@ -26,7 +21,7 @@ CIRCUITPY_FRAMEBUFFERIO ?= 1 CIRCUITPY_FREQUENCYIO ?= 1 CIRCUITPY_IMAGECAPTURE ?= 1 CIRCUITPY_I2CPERIPHERAL ?= 1 -CIRCUITPY_RGBMATRIX ?= 0 +CIRCUITPY_RGBMATRIX ?= 1 CIRCUITPY_ROTARYIO ?= 1 CIRCUITPY_NVM ?= 1 CIRCUITPY_PS2IO ?= 1 @@ -41,6 +36,8 @@ CIRCUITPY_MODULE ?= none ifeq ($(IDF_TARGET),esp32c3) CIRCUITPY_USB = 0 CIRCUITPY_ALARM = 0 +CIRCUITPY_BLEIO = 1 +CIRCUITPY_BLEIO_HCI = 0 CIRCUITPY_COUNTIO = 0 CIRCUITPY_ROTARYIO = 0 CIRCUITPY_AUDIOBUSIO = 0 @@ -50,8 +47,14 @@ CIRCUITPY_PARALLELDISPLAY = 0 CIRCUITPY_TOUCHIO ?= 1 CIRCUITPY_TOUCHIO_USE_NATIVE = 0 else ifeq ($(IDF_TARGET),esp32s3) +CIRCUITPY_BLEIO = 1 +CIRCUITPY_BLEIO_HCI = 0 CIRCUITPY_IMAGECAPTURE = 0 CIRCUITPY_PARALLELDISPLAY = 0 +else ifeq ($(IDF_TARGET),esp32s2) +# No BLE on S2 +CIRCUITPY_BLEIO = 0 +CIRCUITPY_BLEIO_HCI = 0 endif # From ESP32-S2/S3 Technical Reference Manual: diff --git a/ports/espressif/peripherals/rmt.c b/ports/espressif/peripherals/rmt.c index 6fbf81f1bd..362bf85748 100644 --- a/ports/espressif/peripherals/rmt.c +++ b/ports/espressif/peripherals/rmt.c @@ -37,8 +37,17 @@ void peripherals_rmt_reset(void) { } } -rmt_channel_t peripherals_find_and_reserve_rmt(void) { - for (size_t i = 0; i < RMT_CHANNEL_MAX; i++) { +rmt_channel_t peripherals_find_and_reserve_rmt(bool mode) { + size_t start_channel = 0; + size_t end_channel = RMT_CHANNEL_MAX; + #if SOC_RMT_CHANNELS_PER_GROUP > 4 + if (mode == RECEIVE_MODE) { + start_channel = 4; + } else { + end_channel = 4; + } + #endif + for (size_t i = start_channel; i < end_channel; i++) { if (!rmt_reserved_channels[i]) { rmt_reserved_channels[i] = true; return i; diff --git a/ports/espressif/peripherals/rmt.h b/ports/espressif/peripherals/rmt.h index 810b331048..24a4383789 100644 --- a/ports/espressif/peripherals/rmt.h +++ b/ports/espressif/peripherals/rmt.h @@ -30,9 +30,11 @@ #include "py/mphal.h" #include "components/driver/include/driver/rmt.h" #include +#define TRANSMIT_MODE true +#define RECEIVE_MODE false void peripherals_rmt_reset(void); -rmt_channel_t peripherals_find_and_reserve_rmt(void); +rmt_channel_t peripherals_find_and_reserve_rmt(bool mode); void peripherals_free_rmt(rmt_channel_t chan); #endif // MICROPY_INCLUDED_ESPRESSIF_PERIPHERALS_RMT_H diff --git a/ports/espressif/supervisor/port.c b/ports/espressif/supervisor/port.c index c8cb344aae..11709eda40 100644 --- a/ports/espressif/supervisor/port.c +++ b/ports/espressif/supervisor/port.c @@ -51,6 +51,8 @@ #include "supervisor/background_callback.h" #include "supervisor/memory.h" #include "supervisor/shared/tick.h" +#include "shared-bindings/microcontroller/__init__.h" +#include "shared-bindings/microcontroller/RunMode.h" #include "shared-bindings/rtc/__init__.h" #include "peripherals/rmt.h" @@ -68,6 +70,10 @@ #include "common-hal/audiobusio/__init__.h" #endif +#if CIRCUITPY_BLEIO +#include "shared-bindings/_bleio/__init__.h" +#endif + #if CIRCUITPY_IMAGECAPTURE #include "cam.h" #endif @@ -77,11 +83,23 @@ #include "esp_debug_helpers.h" +#include "esp_ipc.h" + #ifdef CONFIG_SPIRAM #include "esp32/spiram.h" #endif +// Heap sizes for when there is no external RAM for CircuitPython to use +// exclusively. +#ifdef CONFIG_IDF_TARGET_ESP32S2 #define HEAP_SIZE (48 * 1024) +#endif +#ifdef CONFIG_IDF_TARGET_ESP32S3 +#define HEAP_SIZE (176 * 1024) +#endif +#ifdef CONFIG_IDF_TARGET_ESP32C3 +#define HEAP_SIZE (88 * 1024) +#endif uint32_t *heap; uint32_t heap_size; @@ -93,7 +111,7 @@ TaskHandle_t circuitpython_task = NULL; extern void esp_restart(void) NORETURN; -STATIC void tick_timer_cb(void *arg) { +STATIC void tick_on_cp_core(void *arg) { supervisor_tick(); // CircuitPython's VM is run in a separate FreeRTOS task from timer callbacks. So, we have to @@ -101,6 +119,18 @@ STATIC void tick_timer_cb(void *arg) { xTaskNotifyGive(circuitpython_task); } +// This function may happen on the PRO core when CP is on the APP core. So, make +// sure we run on the CP core. +STATIC void tick_timer_cb(void *arg) { + #if defined(CONFIG_FREERTOS_UNICORE) && CONFIG_FREERTOS_UNICORE + tick_on_cp_core(arg); + #else + // This only blocks until the start of the function. That's ok since the PRO + // core shouldn't care what we do. + esp_ipc_call(CONFIG_ESP_MAIN_TASK_AFFINITY, tick_on_cp_core, NULL); + #endif +} + void sleep_timer_cb(void *arg); safe_mode_t port_init(void) { @@ -253,6 +283,10 @@ void reset_port(void) { watchdog_reset(); #endif + #if CIRCUITPY_BLEIO + bleio_reset(); + #endif + #if CIRCUITPY_WIFI wifi_reset(); #endif @@ -263,6 +297,7 @@ void reset_port(void) { } void reset_to_bootloader(void) { + common_hal_mcu_on_next_reset(RUNMODE_BOOTLOADER); esp_restart(); } diff --git a/ports/espressif/supervisor/usb.c b/ports/espressif/supervisor/usb.c index 7be3e84536..a4f26b366c 100644 --- a/ports/espressif/supervisor/usb.c +++ b/ports/espressif/supervisor/usb.c @@ -109,13 +109,16 @@ void init_usb_hardware(void) { usb_hal_init(&hal); configure_pins(&hal); - (void)xTaskCreateStatic(usb_device_task, + // Pin the USB task to the same core as CircuitPython. This way we leave + // the other core for networking. + (void)xTaskCreateStaticPinnedToCore(usb_device_task, "usbd", USBD_STACK_SIZE, NULL, 5, usb_device_stack, - &usb_device_taskdef); + &usb_device_taskdef, + xPortGetCoreID()); } /** @@ -135,3 +138,10 @@ void tud_cdc_rx_wanted_cb(uint8_t itf, char wanted_char) { mp_sched_keyboard_interrupt(); } } + +void tud_cdc_rx_cb(uint8_t itf) { + (void)itf; + // Workaround for "press any key to enter REPL" response being delayed on espressif. + // Wake main task when any key is pressed. + port_wake_main_task(); +} diff --git a/ports/espressif/tools/generate_all_sdkconfig.py b/ports/espressif/tools/generate_all_sdkconfig.py new file mode 100644 index 0000000000..a3589c34bb --- /dev/null +++ b/ports/espressif/tools/generate_all_sdkconfig.py @@ -0,0 +1,25 @@ +import pathlib +import sys +import shlex +import shutil +import subprocess + +output_dir = pathlib.Path(sys.argv[-1]) +output_dir.mkdir(parents=True, exist_ok=True) + + +def run(cmd): + subprocess.run(shlex.split(cmd), capture_output=True) + + +for board in pathlib.Path("boards/").glob("*/"): + board = board.name + print(board) + run(f"make BOARD={board} DEBUG=1 build-{board}/esp-idf/config/sdkconfig.h") + shutil.copyfile(f"build-{board}/esp-idf/sdkconfig", output_dir / (board + "-debug.sdkconfig")) + # run(f"python tools/update_sdkconfig.py --board={board} --update_all --debug=1") + run(f"make BOARD={board} DEBUG=1 clean") + run(f"make BOARD={board} build-{board}/esp-idf/config/sdkconfig.h") + shutil.copyfile(f"build-{board}/esp-idf/sdkconfig", output_dir / (board + "-opt.sdkconfig")) + # run(f"python tools/update_sdkconfig.py --board={board} --update_all") + run(f"make BOARD={board} clean") diff --git a/ports/espressif/tools/update_sdkconfig.py b/ports/espressif/tools/update_sdkconfig.py new file mode 100644 index 0000000000..e89f7ab00d --- /dev/null +++ b/ports/espressif/tools/update_sdkconfig.py @@ -0,0 +1,194 @@ +"""This script updates the sdkconfigs based on the menuconfig results in a given + build.""" + +import pathlib +import click + +OPT_SETTINGS = [ + "CONFIG_ESP_ERR_TO_NAME_LOOKUP", + "CONFIG_ESP_CONSOLE_", + "CONFIG_CONSOLE_UART_", + "CONFIG_ESP_SYSTEM_PANIC_", + "CONFIG_ESP32S2_PANIC_", + "COMPILER_OPTIMIZATION_", + "CONFIG_ESP32S3_DEBUG_OCDAWARE", + "CONFIG_FREERTOS_ASSERT_", + "CONFIG_FREERTOS_DEBUG_OCDAWARE", + "CONFIG_FREERTOS_TASK_FUNCTION_WRAPPER", + "CONFIG_HAL_ASSERTION_", + "CONFIG_LWIP_ESP_LWIP_ASSERT", + "CONFIG_OPTIMIZATION_ASSERTION_LEVEL", + "CONFIG_OPTIMIZATION_ASSERTIONS_", + "CONFIG_HAL_DEFAULT_ASSERTION_LEVEL", +] + +TARGET_SETTINGS = [ + "CONFIG_IDF_TARGET", + "CONFIG_IDF_FIRMWARE_CHIP_ID", + "CONFIG_BOOTLOADER_OFFSET_IN_FLASH", + "CONFIG_ESP32_", + "CONFIG_ESP32C3_", + "CONFIG_ESP32S2_", + "CONFIG_ESP32S3_", + "CONFIG_ESP32H2_", + "CONFIG_ESP_SLEEP_POWER_DOWN_FLASH", + "CONFIG_ESP_SYSTEM_SINGLE_CORE_MODE", + "CONFIG_ESP_SYSTEM_MEMPROT_", + "CONFIG_ESP_MAIN_TASK_AFFINITY", + "CONFIG_ESP_WIFI_EXTERNAL_COEXIST_ENABLE", + "CONFIG_FREERTOS_UNICORE", + "CONFIG_FREERTOS_TICK_SUPPORT_CORETIMER", + "CONFIG_FREERTOS_CORETIMER_0", + "CONFIG_FREERTOS_CORETIMER_1", + "CONFIG_FREERTOS_SYSTICK_USES_CCOUNT", + "CONFIG_FREERTOS_OPTIMIZED_SCHEDULER", + "CONFIG_MBEDTLS_HARDWARE_GCM", + "CONFIG_ESP_SYSTEM_PD_FLASH", + "CONFIG_EXTERNAL_COEX_ENABLE", + "CONFIG_SDK_TOOLPREFIX", + "CONFIG_TOOLPREFIX", + "ESP_SLEEP_GPIO_RESET_WORKAROUND", + "CONFIG_ESP_PHY_ENABLE_USB", + "CONFIG_BT_SOC_SUPPORT_5_0", +] + +BOARD_SETTINGS = [ + "PSRAM clock and cs IO for ESP32S3", + "CONFIG_SPIRAM", + "CONFIG_DEFAULT_PSRAM_", + "_SPIRAM_SUPPORT", + "CONFIG_LWIP_LOCAL_HOSTNAME", +] + +FLASH_SETTINGS = [ + "CONFIG_ESPTOOLPY_FLASHSIZE", + "CONFIG_PARTITION_TABLE_CUSTOM_FILENAME", + "CONFIG_PARTITION_TABLE_FILENAME", +] + +BLE_SETTINGS = ["CONFIG_BT_", "CONFIG_BLUEDROID_", "CONFIG_NIMBLE_", "CONFIG_SW_COEXIST_ENABLE"] + +# boards/lilygo_ttgo_t8_s2_st7789/sdkconfig +# CONFIG_LWIP_DNS_SUPPORT_MDNS_QUERIES=y + +# boards/morpheans_morphesp-240/sdkconfig +# CONFIG_LWIP_DNS_SUPPORT_MDNS_QUERIES=y + + +def matches_group(line, group): + for setting in group: + if setting in line: + return True + return False + + +def add_group(lines, last_group, current_group): + # TODO: Properly handle nested groups + if last_group != current_group[-1]: + if last_group: + lines.append("# end of " + last_group) + lines.append("") + return None + if current_group: + lines.append("#") + lines.append("# " + current_group[-1]) + lines.append("#") + return current_group[-1] + return last_group + + +@click.command() +@click.option("--debug") +@click.option("--board") +@click.option( + "--update_all", + is_flag=True, + default=False, + help="Updates the sdkconfigs outside of the board directory.", +) +def update(debug, board, update_all): + """Simple program that greets NAME for a total of COUNT times.""" + + board_make = pathlib.Path(f"boards/{board}/mpconfigboard.mk") + for line in board_make.read_text().split("\n"): + if line.startswith("IDF_TARGET"): + target = line.split("=")[1].strip() + elif line.startswith("CIRCUITPY_ESP_FLASH_SIZE"): + flash = line.split("=")[1].strip() + + input_config = pathlib.Path(f"build-{board}/esp-idf/sdkconfig") + default_config = pathlib.Path("esp-idf-config/sdkconfig.defaults") + if debug: + opt_config = pathlib.Path("esp-idf-config/sdkconfig-debug.defaults") + else: + opt_config = pathlib.Path("esp-idf-config/sdkconfig-opt.defaults") + flash_config = pathlib.Path(f"esp-idf-config/sdkconfig-{flash}.defaults") + target_config = pathlib.Path(f"esp-idf-config/sdkconfig-{target}.defaults") + ble_config = pathlib.Path(f"esp-idf-config/sdkconfig-ble.defaults") + board_config = pathlib.Path(f"boards/{board}/sdkconfig") + + defaults = default_config.read_text().split("\n") + defaults.extend(opt_config.read_text().split("\n")) + defaults.extend(flash_config.read_text().split("\n")) + defaults.extend(target_config.read_text().split("\n")) + defaults.extend(ble_config.read_text().split("\n")) + + board_settings = [] + last_board_group = None + flash_settings = [] + last_flash_group = None + opt_settings = [] + last_opt_group = None + target_settings = [] + last_target_group = None + ble_settings = [] + last_ble_group = None + default_settings = [] + last_default_group = None + current_group = [] + for line in input_config.read_text().split("\n"): + if line.startswith("# ") and "CONFIG_" not in line and len(line) > 3: + if line.startswith("# end of"): + current_group.pop() + else: + current_group.append(line[2:]) + elif (not update_all and line not in defaults) or ( + update_all and matches_group(line, BOARD_SETTINGS) + ): + last_board_group = add_group(board_settings, last_board_group, current_group) + board_settings.append(line) + elif update_all: + if matches_group(line, OPT_SETTINGS): + last_opt_group = add_group(opt_settings, last_opt_group, current_group) + opt_settings.append(line) + elif matches_group(line, FLASH_SETTINGS): + last_flash_group = add_group(flash_settings, last_flash_group, current_group) + flash_settings.append(line) + elif matches_group(line, TARGET_SETTINGS): + last_target_group = add_group(target_settings, last_target_group, current_group) + target_settings.append(line) + elif matches_group(line, BLE_SETTINGS): + last_ble_group = add_group(ble_settings, last_ble_group, current_group) + ble_settings.append(line) + elif "CONFIG_" in line: + last_default_group = add_group(default_settings, last_default_group, current_group) + default_settings.append(line) + + add_group(board_settings, last_board_group, current_group) + add_group(opt_settings, last_opt_group, current_group) + add_group(flash_settings, last_flash_group, current_group) + add_group(target_settings, last_target_group, current_group) + add_group(ble_settings, last_ble_group, current_group) + add_group(default_settings, last_default_group, current_group) + + board_config.write_text("\n".join(board_settings)) + if update_all: + flash_config.write_text("\n".join(flash_settings)) + opt_config.write_text("\n".join(opt_settings)) + default_config.write_text("\n".join(default_settings)) + target_config.write_text("\n".join(target_settings)) + ble_config.write_text("\n".join(ble_settings)) + + +if __name__ == "__main__": + update() diff --git a/ports/litex/mpconfigport.mk b/ports/litex/mpconfigport.mk index ce6ed08841..57f5113b69 100644 --- a/ports/litex/mpconfigport.mk +++ b/ports/litex/mpconfigport.mk @@ -1,8 +1,3 @@ -# Define an equivalent for MICROPY_LONGINT_IMPL, to pass to $(MPY-TOOL) in py/mkrules.mk -# $(MPY-TOOL) needs to know what kind of longint to use (if any) to freeze long integers. -# This should correspond to the MICROPY_LONGINT_IMPL definition in mpconfigport.h. -MPY_TOOL_LONGINT_IMPL = -mlongint-impl=mpz - # Internal math library is substantially smaller than toolchain one INTERNAL_LIBM = 1 diff --git a/ports/mimxrt10xx/Makefile b/ports/mimxrt10xx/Makefile index dd691a12e9..0ac74579a7 100644 --- a/ports/mimxrt10xx/Makefile +++ b/ports/mimxrt10xx/Makefile @@ -156,7 +156,7 @@ SRC_C += \ boards/$(BOARD)/flash_config.c \ boards/$(BOARD)/pins.c \ fatfs_port.c \ - lib/tinyusb/src/portable/nxp/transdimension/dcd_transdimension.c \ + lib/tinyusb/src/portable/chipidea/ci_hs/dcd_ci_hs.c \ mphalport.c \ peripherals/mimxrt10xx/$(CHIP_FAMILY)/clocks.c \ peripherals/mimxrt10xx/$(CHIP_FAMILY)/periph.c \ diff --git a/ports/mimxrt10xx/boards/feather_m7_1011/pins.c b/ports/mimxrt10xx/boards/feather_m7_1011/pins.c index 4bd7f13668..93c9d6430d 100644 --- a/ports/mimxrt10xx/boards/feather_m7_1011/pins.c +++ b/ports/mimxrt10xx/boards/feather_m7_1011/pins.c @@ -42,6 +42,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO_00) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, }; diff --git a/ports/mimxrt10xx/boards/metro_m7_1011/pins.c b/ports/mimxrt10xx/boards/metro_m7_1011/pins.c index 0198ed90cc..886909e1dd 100644 --- a/ports/mimxrt10xx/boards/metro_m7_1011/pins.c +++ b/ports/mimxrt10xx/boards/metro_m7_1011/pins.c @@ -53,6 +53,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO_00) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, }; diff --git a/ports/mimxrt10xx/common-hal/busio/I2C.c b/ports/mimxrt10xx/common-hal/busio/I2C.c index 74639d0ef1..77df979e4d 100644 --- a/ports/mimxrt10xx/common-hal/busio/I2C.c +++ b/ports/mimxrt10xx/common-hal/busio/I2C.c @@ -210,7 +210,7 @@ void common_hal_busio_i2c_unlock(busio_i2c_obj_t *self) { self->has_lock = false; } -uint8_t common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t addr, +STATIC uint8_t _common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t addr, const uint8_t *data, size_t len, bool transmit_stop_bit) { lpi2c_master_transfer_t xfer = { 0 }; @@ -227,6 +227,11 @@ uint8_t common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t addr, return MP_EIO; } +uint8_t common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t addr, + const uint8_t *data, size_t len) { + return _common_hal_busio_i2c_write(self, addr, data, len, true); +} + uint8_t common_hal_busio_i2c_read(busio_i2c_obj_t *self, uint16_t addr, uint8_t *data, size_t len) { @@ -243,3 +248,13 @@ uint8_t common_hal_busio_i2c_read(busio_i2c_obj_t *self, uint16_t addr, return MP_EIO; } + +uint8_t common_hal_busio_i2c_write_read(busio_i2c_obj_t *self, uint16_t addr, + uint8_t *out_data, size_t out_len, uint8_t *in_data, size_t in_len) { + uint8_t result = _common_hal_busio_i2c_write(self, addr, out_data, out_len, false); + if (result != 0) { + return result; + } + + return common_hal_busio_i2c_read(self, addr, in_data, in_len); +} diff --git a/ports/mimxrt10xx/common-hal/busio/SPI.c b/ports/mimxrt10xx/common-hal/busio/SPI.c index 88923fe06d..608fae7fbe 100644 --- a/ports/mimxrt10xx/common-hal/busio/SPI.c +++ b/ports/mimxrt10xx/common-hal/busio/SPI.c @@ -75,13 +75,17 @@ void spi_reset(void) { void common_hal_busio_spi_construct(busio_spi_obj_t *self, const mcu_pin_obj_t *clock, const mcu_pin_obj_t *mosi, - const mcu_pin_obj_t *miso) { + const mcu_pin_obj_t *miso, bool half_duplex) { const uint32_t sck_count = MP_ARRAY_SIZE(mcu_spi_sck_list); const uint32_t miso_count = MP_ARRAY_SIZE(mcu_spi_miso_list); const uint32_t mosi_count = MP_ARRAY_SIZE(mcu_spi_mosi_list); bool spi_taken = false; + if (half_duplex) { + mp_raise_NotImplementedError(translate("Half duplex SPI is not implemented")); + } + for (uint i = 0; i < sck_count; i++) { if (mcu_spi_sck_list[i].pin != clock) { continue; diff --git a/ports/mimxrt10xx/mpconfigport.mk b/ports/mimxrt10xx/mpconfigport.mk index ed9446d0e7..e7e7abe141 100644 --- a/ports/mimxrt10xx/mpconfigport.mk +++ b/ports/mimxrt10xx/mpconfigport.mk @@ -1,17 +1,5 @@ LD_FILE = $(FLASH).ld $(CHIP_FAMILY).ld imxrt10xx.ld -ifeq ($(LONGINT_IMPL),NONE) -MPY_TOOL_LONGINT_IMPL = -mlongint-impl=none -endif - -ifeq ($(LONGINT_IMPL),MPZ) -MPY_TOOL_LONGINT_IMPL = -mlongint-impl=mpz -endif - -ifeq ($(LONGINT_IMPL),LONGLONG) -MPY_TOOL_LONGINT_IMPL = -mlongint-impl=longlong -endif - INTERNAL_LIBM = 1 USB_HIGHSPEED = 1 diff --git a/ports/nrf/Makefile b/ports/nrf/Makefile index 04a648a4e2..6db2b547c5 100755 --- a/ports/nrf/Makefile +++ b/ports/nrf/Makefile @@ -239,6 +239,9 @@ SRC_QSTR += $(SRC_C) $(SRC_SUPERVISOR) $(SRC_MOD) $(SRC_COMMON_HAL_EXPANDED) $(S # Sources that only hold QSTRs after pre-processing. SRC_QSTR_PREPROCESSOR += +UF2_FAMILY_ID_nrf52840 = 0xADA52840 +UF2_FAMILY_ID_nrf52833 = 0x621E937A + all: $(BUILD)/firmware.bin $(BUILD)/firmware.uf2 $(BUILD)/firmware.combined.hex @@ -264,7 +267,7 @@ $(BUILD)/firmware.combined.hex: $(BUILD)/firmware.hex $(SOFTDEV_HEX) $(BUILD)/firmware.uf2: $(BUILD)/firmware.hex $(ECHO) "Create $@" - $(PYTHON) $(TOP)/tools/uf2/utils/uf2conv.py -f 0xADA52840 -c -o "$(BUILD)/firmware.uf2" $^ + $(PYTHON) $(TOP)/tools/uf2/utils/uf2conv.py -f $(UF2_FAMILY_ID_$(MCU_CHIP)) -c -o "$(BUILD)/firmware.uf2" $^ diff --git a/shared-module/busio/I2C.h b/ports/nrf/boards/Seeed_XIAO_nRF52840_Sense/board.c similarity index 78% rename from shared-module/busio/I2C.h rename to ports/nrf/boards/Seeed_XIAO_nRF52840_Sense/board.c index e089ea367b..b4070e72dc 100644 --- a/shared-module/busio/I2C.h +++ b/ports/nrf/boards/Seeed_XIAO_nRF52840_Sense/board.c @@ -24,16 +24,18 @@ * THE SOFTWARE. */ -#ifndef MICROPY_INCLUDED_ATMEL_SAMD_SHARED_MODULE_BUSIO_I2C_H -#define MICROPY_INCLUDED_ATMEL_SAMD_SHARED_MODULE_BUSIO_I2C_H +#include "supervisor/board.h" -#include "shared-module/bitbangio/I2C.h" +void board_init(void) { +} -#include "py/obj.h" +bool board_requests_safe_mode(void) { + return false; +} -typedef struct { - mp_obj_base_t base; - bitbangio_i2c_obj_t bitbang; -} busio_i2c_obj_t; +void reset_board(void) { -#endif // MICROPY_INCLUDED_ATMEL_SAMD_SHARED_MODULE_BUSIO_I2C_H +} + +void board_deinit(void) { +} diff --git a/ports/nrf/boards/Seeed_XIAO_nRF52840_Sense/mpconfigboard.h b/ports/nrf/boards/Seeed_XIAO_nRF52840_Sense/mpconfigboard.h new file mode 100644 index 0000000000..8b3dd9ebb8 --- /dev/null +++ b/ports/nrf/boards/Seeed_XIAO_nRF52840_Sense/mpconfigboard.h @@ -0,0 +1,54 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2016 Glenn Ruben Bakke + * Copyright (c) 2018 Dan Halbert for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "nrfx/hal/nrf_gpio.h" + +#define MICROPY_HW_BOARD_NAME "Seeed XIAO nRF52840 Sense" +#define MICROPY_HW_MCU_NAME "nRF52840" + +#define MICROPY_HW_LED_STATUS (&pin_P0_26) + +#if QSPI_FLASH_FILESYSTEM +#define MICROPY_QSPI_DATA0 NRF_GPIO_PIN_MAP(0, 20) +#define MICROPY_QSPI_DATA1 NRF_GPIO_PIN_MAP(0, 24) +#define MICROPY_QSPI_DATA2 NRF_GPIO_PIN_MAP(0, 22) +#define MICROPY_QSPI_DATA3 NRF_GPIO_PIN_MAP(0, 23) +#define MICROPY_QSPI_SCK NRF_GPIO_PIN_MAP(0, 21) +#define MICROPY_QSPI_CS NRF_GPIO_PIN_MAP(0, 25) +#endif + +#define BOARD_HAS_CRYSTAL 1 + +#define DEFAULT_I2C_BUS_SCL (&pin_P0_05) +#define DEFAULT_I2C_BUS_SDA (&pin_P0_04) + +#define DEFAULT_SPI_BUS_SCK (&pin_P1_13) +#define DEFAULT_SPI_BUS_MOSI (&pin_P1_15) +#define DEFAULT_SPI_BUS_MISO (&pin_P1_14) + +#define DEFAULT_UART_BUS_RX (&pin_P1_12) +#define DEFAULT_UART_BUS_TX (&pin_P1_11) diff --git a/ports/nrf/boards/Seeed_XIAO_nRF52840_Sense/mpconfigboard.mk b/ports/nrf/boards/Seeed_XIAO_nRF52840_Sense/mpconfigboard.mk new file mode 100644 index 0000000000..228c5698f0 --- /dev/null +++ b/ports/nrf/boards/Seeed_XIAO_nRF52840_Sense/mpconfigboard.mk @@ -0,0 +1,10 @@ +USB_VID = 0x2886 +USB_PID = 0x0045 +USB_PRODUCT = "Seeed XIAO nRF52840 Sense" +SOFTDEV_VERSION=7.0.1 +USB_MANUFACTURER = "Seeed" + +MCU_CHIP = nrf52840 + +QSPI_FLASH_FILESYSTEM = 1 +EXTERNAL_FLASH_DEVICES = "P25Q16H" diff --git a/ports/nrf/boards/Seeed_XIAO_nRF52840_Sense/pins.c b/ports/nrf/boards/Seeed_XIAO_nRF52840_Sense/pins.c new file mode 100644 index 0000000000..5d2e9226ca --- /dev/null +++ b/ports/nrf/boards/Seeed_XIAO_nRF52840_Sense/pins.c @@ -0,0 +1,59 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_P0_02) }, + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_P0_03) }, + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_P0_28) }, + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_P0_29) }, + { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_P0_04) }, + { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_P0_05) }, + + { MP_ROM_QSTR(MP_QSTR_NFC1), MP_ROM_PTR(&pin_P0_09) }, + { MP_ROM_QSTR(MP_QSTR_NFC2), MP_ROM_PTR(&pin_P0_10) }, + + { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_P0_02) }, + { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_P0_03) }, + { MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_P0_28) }, + { MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_P0_29) }, + { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_P0_04) }, + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_P0_05) }, + { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_P1_11) }, + { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_P1_12) }, + { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_P1_13) }, + { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_P1_14) }, + { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_P1_15) }, + + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_P1_13) }, + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_P1_15) }, + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_P1_14) }, + + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_P1_11) }, + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_P1_12) }, + + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_P0_05) }, + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_P0_04) }, + + { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_P0_26) }, + { MP_ROM_QSTR(MP_QSTR_LED_RED), MP_ROM_PTR(&pin_P0_26) }, + { MP_ROM_QSTR(MP_QSTR_LED_BLUE), MP_ROM_PTR(&pin_P0_06) }, + { MP_ROM_QSTR(MP_QSTR_LED_GREEN), MP_ROM_PTR(&pin_P0_30) }, + + { MP_ROM_QSTR(MP_QSTR_IMU_PWR), MP_ROM_PTR(&pin_P1_08) }, + { MP_ROM_QSTR(MP_QSTR_IMU_SCL), MP_ROM_PTR(&pin_P0_27) }, + { MP_ROM_QSTR(MP_QSTR_IMU_SDA), MP_ROM_PTR(&pin_P0_07) }, + { MP_ROM_QSTR(MP_QSTR_IMU_INT1), MP_ROM_PTR(&pin_P0_11) }, + + { MP_ROM_QSTR(MP_QSTR_MIC_PWR), MP_ROM_PTR(&pin_P1_10) }, + { MP_ROM_QSTR(MP_QSTR_PDM_CLK), MP_ROM_PTR(&pin_P1_00) }, + { MP_ROM_QSTR(MP_QSTR_PDM_DATA), MP_ROM_PTR(&pin_P0_16) }, + + {MP_ROM_QSTR(MP_QSTR_READ_BATT_ENABLE),MP_ROM_PTR(&pin_P0_14)}, + {MP_ROM_QSTR(MP_QSTR_VBATT),MP_ROM_PTR(&pin_P0_31)}, + {MP_ROM_QSTR(MP_QSTR_CHARGE_STATUS),MP_ROM_PTR(&pin_P0_17)}, + + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, +}; + +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/nrf/boards/adafruit_led_glasses_nrf52840/mpconfigboard.mk b/ports/nrf/boards/adafruit_led_glasses_nrf52840/mpconfigboard.mk index 5d90582865..30a4aab232 100644 --- a/ports/nrf/boards/adafruit_led_glasses_nrf52840/mpconfigboard.mk +++ b/ports/nrf/boards/adafruit_led_glasses_nrf52840/mpconfigboard.mk @@ -5,6 +5,7 @@ USB_MANUFACTURER = "Adafruit Industries LLC" MCU_CHIP = nrf52840 - QSPI_FLASH_FILESYSTEM = 1 EXTERNAL_FLASH_DEVICES = "GD25Q16C" + +CIRCUITPY_IS31FL3741 = 1 diff --git a/ports/nrf/boards/adafruit_led_glasses_nrf52840/pins.c b/ports/nrf/boards/adafruit_led_glasses_nrf52840/pins.c index 8bc4ead19b..a53b1359c1 100644 --- a/ports/nrf/boards/adafruit_led_glasses_nrf52840/pins.c +++ b/ports/nrf/boards/adafruit_led_glasses_nrf52840/pins.c @@ -21,6 +21,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_P0_06) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, }; MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/nrf/boards/bluemicro833/board.c b/ports/nrf/boards/bluemicro833/board.c new file mode 100644 index 0000000000..104cea6274 --- /dev/null +++ b/ports/nrf/boards/bluemicro833/board.c @@ -0,0 +1,65 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2018 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "supervisor/board.h" +#include "mpconfigboard.h" +#include "py/obj.h" +#include "peripherals/nrf/pins.h" +#include "supervisor/shared/board.h" + +#include "nrf_gpio.h" + +void board_init(void) { + // "never_reset" the pin here because CircuitPython will try to reset pins after a VM run otherwise. + never_reset_pin_number(POWER_SWITCH_PIN->number); + // Turn on power to sensors and neopixels. + nrf_gpio_cfg(POWER_SWITCH_PIN->number, + NRF_GPIO_PIN_DIR_OUTPUT, + NRF_GPIO_PIN_INPUT_DISCONNECT, + NRF_GPIO_PIN_NOPULL, + NRF_GPIO_PIN_S0S1, + NRF_GPIO_PIN_NOSENSE); + nrf_gpio_pin_write(POWER_SWITCH_PIN->number, true); +} + +void board_deinit(void) { + // Turn off power to sensors and neopixels. + nrf_gpio_cfg(POWER_SWITCH_PIN->number, + NRF_GPIO_PIN_DIR_OUTPUT, + NRF_GPIO_PIN_INPUT_DISCONNECT, + NRF_GPIO_PIN_NOPULL, + NRF_GPIO_PIN_S0S1, + NRF_GPIO_PIN_NOSENSE); + nrf_gpio_pin_write(POWER_SWITCH_PIN->number, false); +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { + +} diff --git a/ports/nrf/boards/bluemicro833/mpconfigboard.h b/ports/nrf/boards/bluemicro833/mpconfigboard.h new file mode 100644 index 0000000000..2340cdc988 --- /dev/null +++ b/ports/nrf/boards/bluemicro833/mpconfigboard.h @@ -0,0 +1,60 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2016 Glenn Ruben Bakke + * Copyright (c) 2018 Dan Halbert for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "nrfx/hal/nrf_gpio.h" + +#define MICROPY_HW_BOARD_NAME "BlueMicro833" +#define MICROPY_HW_MCU_NAME "nRF52833" + +#define MICROPY_HW_NEOPIXEL (&pin_P0_07) +#define MICROPY_HW_LED_STATUS (&pin_P0_25) +#define MICROPY_HW_NEOPIXEL_COUNT (1) + + +#define CIRCUITPY_INTERNAL_NVM_SIZE 0 +#define CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE (60 * 1024) + +#define CIRCUITPY_BLE_CONFIG_SIZE (12 * 1024) + +#define BOARD_HAS_CRYSTAL 1 + +// Take 1k RAM to save 1k flash. +#define CIRCUITPY_PRECOMPUTE_QSTR_ATTR (0) + +// Reduce nRF SoftRadio memory usage +#define BLEIO_VS_UUID_COUNT 10 +#define BLEIO_HVN_TX_QUEUE_SIZE 2 +#define BLEIO_CENTRAL_ROLE_COUNT 2 +#define BLEIO_PERIPH_ROLE_COUNT 2 +#define BLEIO_TOTAL_CONNECTION_COUNT 2 +#define BLEIO_ATTR_TAB_SIZE (BLE_GATTS_ATTR_TAB_SIZE_DEFAULT * 2) + +#define SOFTDEVICE_RAM_SIZE (32 * 1024) + +#define MICROPY_FATFS_EXFAT 0 + +#define POWER_SWITCH_PIN (&pin_P0_12) diff --git a/ports/nrf/boards/bluemicro833/mpconfigboard.mk b/ports/nrf/boards/bluemicro833/mpconfigboard.mk new file mode 100644 index 0000000000..b7594f0d89 --- /dev/null +++ b/ports/nrf/boards/bluemicro833/mpconfigboard.mk @@ -0,0 +1,50 @@ +USB_VID = 0x1D50 +USB_PID = 0x6152 +USB_PRODUCT = "BlueMicro833" +USB_MANUFACTURER = "nrf52.jpconstantineau.com" + +MCU_CHIP = nrf52833 + +INTERNAL_FLASH_FILESYSTEM = 1 + +CIRCUITPY_AESIO = 0 +CIRCUITPY_ALARM = 0 +CIRCUITPY_AUDIOBUSIO = 0 +#CIRCUITPY_AUDIOCORE = 0 +#CIRCUITPY_AUDIOIO = 0 +CIRCUITPY_AUDIOMIXER = 0 +CIRCUITPY_AUDIOMP3 = 0 +CIRCUITPY_BINASCII = 0 +CIRCUITPY_BITBANGIO = 0 +CIRCUITPY_BITMAPTOOLS = 0 +CIRCUITPY_BUILTINS_POW3=0 +CIRCUITPY_BUSDEVICE = 0 +CIRCUITPY_COUNTIO = 0 +CIRCUITPY_DISPLAYIO = 0 +CIRCUITPY_FRAMEBUFFERIO = 0 +CIRCUITPY_FREQUENCYIO = 0 +CIRCUITPY_I2CPERIPHERAL = 0 +CIRCUITPY_JSON = 0 +CIRCUITPY_KEYPAD = 1 +CIRCUITPY_MSGPACK = 0 +#CIRCUITPY_NEOPIXEL_WRITE = 1 +CIRCUITPY_ONEWIREIO = 0 +CIRCUITPY_NVM = 0 +CIRCUITPY_PIXELBUF = 1 +CIRCUITPY_PULSEIO = 1 +CIRCUITPY_RE = 0 +CIRCUITPY_RGBMATRIX = 0 +CIRCUITPY_SDCARDIO = 0 +CIRCUITPY_SYNTHIO = 0 +CIRCUITPY_TOUCHIO = 0 +CIRCUITPY_ULAB = 0 +CIRCUITPY_USB_MIDI = 0 +CIRCUITPY_VECTORIO = 0 + +MICROPY_PY_ASYNC_AWAIT = 0 + +SUPEROPT_GC = 0 +SUPEROPT_VM = 0 + +# Override optimization to keep binary small +OPTIMIZATION_FLAGS = -Os diff --git a/ports/nrf/boards/bluemicro833/pins.c b/ports/nrf/boards/bluemicro833/pins.c new file mode 100644 index 0000000000..e8c8cdcec5 --- /dev/null +++ b/ports/nrf/boards/bluemicro833/pins.c @@ -0,0 +1,70 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + { MP_ROM_QSTR(MP_QSTR_P0_02), MP_ROM_PTR(&pin_P0_02) }, + { MP_ROM_QSTR(MP_QSTR_P0_03), MP_ROM_PTR(&pin_P0_03) }, + { MP_ROM_QSTR(MP_QSTR_P0_04), MP_ROM_PTR(&pin_P0_04) }, + { MP_ROM_QSTR(MP_QSTR_P0_05), MP_ROM_PTR(&pin_P0_05) }, + { MP_ROM_QSTR(MP_QSTR_P0_06), MP_ROM_PTR(&pin_P0_06) }, + { MP_ROM_QSTR(MP_QSTR_P0_07), MP_ROM_PTR(&pin_P0_07) }, + { MP_ROM_QSTR(MP_QSTR_P0_08), MP_ROM_PTR(&pin_P0_08) }, + { MP_ROM_QSTR(MP_QSTR_P0_09), MP_ROM_PTR(&pin_P0_09) }, + { MP_ROM_QSTR(MP_QSTR_P0_10), MP_ROM_PTR(&pin_P0_10) }, + { MP_ROM_QSTR(MP_QSTR_P0_11), MP_ROM_PTR(&pin_P0_11) }, + { MP_ROM_QSTR(MP_QSTR_P0_12), MP_ROM_PTR(&pin_P0_12) }, + { MP_ROM_QSTR(MP_QSTR_P0_13), MP_ROM_PTR(&pin_P0_13) }, + { MP_ROM_QSTR(MP_QSTR_P0_14), MP_ROM_PTR(&pin_P0_14) }, + { MP_ROM_QSTR(MP_QSTR_P0_15), MP_ROM_PTR(&pin_P0_15) }, + { MP_ROM_QSTR(MP_QSTR_P0_16), MP_ROM_PTR(&pin_P0_16) }, + { MP_ROM_QSTR(MP_QSTR_P0_17), MP_ROM_PTR(&pin_P0_17) }, + { MP_ROM_QSTR(MP_QSTR_P0_19), MP_ROM_PTR(&pin_P0_19) }, + { MP_ROM_QSTR(MP_QSTR_P0_20), MP_ROM_PTR(&pin_P0_20) }, + { MP_ROM_QSTR(MP_QSTR_P0_21), MP_ROM_PTR(&pin_P0_21) }, + { MP_ROM_QSTR(MP_QSTR_P0_22), MP_ROM_PTR(&pin_P0_22) }, + { MP_ROM_QSTR(MP_QSTR_P0_23), MP_ROM_PTR(&pin_P0_23) }, + { MP_ROM_QSTR(MP_QSTR_P0_24), MP_ROM_PTR(&pin_P0_24) }, + { MP_ROM_QSTR(MP_QSTR_P0_25), MP_ROM_PTR(&pin_P0_25) }, + { MP_ROM_QSTR(MP_QSTR_P0_26), MP_ROM_PTR(&pin_P0_26) }, + { MP_ROM_QSTR(MP_QSTR_P0_27), MP_ROM_PTR(&pin_P0_27) }, + { MP_ROM_QSTR(MP_QSTR_P0_28), MP_ROM_PTR(&pin_P0_28) }, + { MP_ROM_QSTR(MP_QSTR_P0_29), MP_ROM_PTR(&pin_P0_29) }, + { MP_ROM_QSTR(MP_QSTR_P0_30), MP_ROM_PTR(&pin_P0_30) }, + { MP_ROM_QSTR(MP_QSTR_P0_31), MP_ROM_PTR(&pin_P0_31) }, + { MP_ROM_QSTR(MP_QSTR_P1_00), MP_ROM_PTR(&pin_P1_00) }, + { MP_ROM_QSTR(MP_QSTR_P1_01), MP_ROM_PTR(&pin_P1_01) }, + { MP_ROM_QSTR(MP_QSTR_P1_02), MP_ROM_PTR(&pin_P1_02) }, + { MP_ROM_QSTR(MP_QSTR_P1_03), MP_ROM_PTR(&pin_P1_03) }, + { MP_ROM_QSTR(MP_QSTR_P1_04), MP_ROM_PTR(&pin_P1_04) }, + { MP_ROM_QSTR(MP_QSTR_P1_05), MP_ROM_PTR(&pin_P1_05) }, + { MP_ROM_QSTR(MP_QSTR_P1_06), MP_ROM_PTR(&pin_P1_06) }, + { MP_ROM_QSTR(MP_QSTR_P1_07), MP_ROM_PTR(&pin_P1_07) }, + { MP_ROM_QSTR(MP_QSTR_P1_08), MP_ROM_PTR(&pin_P1_08) }, + { MP_ROM_QSTR(MP_QSTR_P1_09), MP_ROM_PTR(&pin_P1_09) }, + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_P0_02) }, + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_P0_03) }, + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_P0_04) }, + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_P0_05) }, + { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_P0_28) }, + { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_P0_29) }, + { MP_ROM_QSTR(MP_QSTR_A6), MP_ROM_PTR(&pin_P0_30) }, + { MP_ROM_QSTR(MP_QSTR_A7), MP_ROM_PTR(&pin_P0_31) }, + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_P0_15) }, + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_P0_17) }, + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_P0_08) }, + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_P0_06) }, + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_P0_03) }, + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_P0_28) }, + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_P1_05) }, + { MP_ROM_QSTR(MP_QSTR_LED1), MP_ROM_PTR(&pin_P1_04) }, + { MP_ROM_QSTR(MP_QSTR_LED2), MP_ROM_PTR(&pin_P0_25) }, + { MP_ROM_QSTR(MP_QSTR_RED_LED), MP_ROM_PTR(&pin_P1_04) }, + { MP_ROM_QSTR(MP_QSTR_BLUE_LED), MP_ROM_PTR(&pin_P0_25) }, + { MP_ROM_QSTR(MP_QSTR_VCC_ON), MP_ROM_PTR(&pin_P0_12) }, + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_P0_07) }, + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, +}; + +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/nrf/boards/clue_nrf52840_express/board.c b/ports/nrf/boards/clue_nrf52840_express/board.c index 72cea6645d..f2e648f473 100644 --- a/ports/nrf/boards/clue_nrf52840_express/board.c +++ b/ports/nrf/boards/clue_nrf52840_express/board.c @@ -48,7 +48,7 @@ uint8_t display_init_sequence[] = { void board_init(void) { busio_spi_obj_t *spi = &displays[0].fourwire_bus.inline_bus; - common_hal_busio_spi_construct(spi, &pin_P0_14, &pin_P0_15, NULL); + common_hal_busio_spi_construct(spi, &pin_P0_14, &pin_P0_15, NULL, false); common_hal_busio_spi_never_reset(spi); displayio_fourwire_obj_t *bus = &displays[0].fourwire_bus; diff --git a/ports/nrf/boards/clue_nrf52840_express/pins.c b/ports/nrf/boards/clue_nrf52840_express/pins.c index 648477da4a..344e344f5b 100644 --- a/ports/nrf/boards/clue_nrf52840_express/pins.c +++ b/ports/nrf/boards/clue_nrf52840_express/pins.c @@ -107,6 +107,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_TFT_MOSI), MP_ROM_PTR(&pin_P0_15) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, diff --git a/ports/nrf/boards/hiibot_bluefi/board.c b/ports/nrf/boards/hiibot_bluefi/board.c index 89f390cb23..9616596caa 100644 --- a/ports/nrf/boards/hiibot_bluefi/board.c +++ b/ports/nrf/boards/hiibot_bluefi/board.c @@ -48,7 +48,7 @@ uint8_t display_init_sequence[] = { void board_init(void) { busio_spi_obj_t *spi = &displays[0].fourwire_bus.inline_bus; - common_hal_busio_spi_construct(spi, &pin_P0_07, &pin_P1_08, NULL); // SCK, MOSI, MISO + common_hal_busio_spi_construct(spi, &pin_P0_07, &pin_P1_08, NULL, false); // SCK, MOSI, MISO, not half-duplex common_hal_busio_spi_never_reset(spi); displayio_fourwire_obj_t *bus = &displays[0].fourwire_bus; diff --git a/ports/nrf/boards/hiibot_bluefi/pins.c b/ports/nrf/boards/hiibot_bluefi/pins.c index 2a18996c72..ba1910dc9d 100644 --- a/ports/nrf/boards/hiibot_bluefi/pins.c +++ b/ports/nrf/boards/hiibot_bluefi/pins.c @@ -174,6 +174,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_AUDIO), MP_ROM_PTR(&pin_P1_15) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, diff --git a/ports/nrf/boards/makerdiary_nrf52840_m2_devkit/board.c b/ports/nrf/boards/makerdiary_nrf52840_m2_devkit/board.c index 5dab6d1bd6..87c9b2f226 100644 --- a/ports/nrf/boards/makerdiary_nrf52840_m2_devkit/board.c +++ b/ports/nrf/boards/makerdiary_nrf52840_m2_devkit/board.c @@ -49,7 +49,7 @@ uint8_t display_init_sequence[] = { void board_init(void) { busio_spi_obj_t *spi = &displays[0].fourwire_bus.inline_bus; - common_hal_busio_spi_construct(spi, &pin_P0_11, &pin_P0_12, NULL); + common_hal_busio_spi_construct(spi, &pin_P0_11, &pin_P0_12, NULL, false); common_hal_busio_spi_never_reset(spi); displayio_fourwire_obj_t *bus = &displays[0].fourwire_bus; diff --git a/ports/nrf/boards/makerdiary_nrf52840_mdk_usb_dongle/pins.c b/ports/nrf/boards/makerdiary_nrf52840_mdk_usb_dongle/pins.c index da09d86648..4068689377 100644 --- a/ports/nrf/boards/makerdiary_nrf52840_mdk_usb_dongle/pins.c +++ b/ports/nrf/boards/makerdiary_nrf52840_mdk_usb_dongle/pins.c @@ -25,6 +25,8 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_P10), MP_ROM_PTR(&pin_P0_10) }, { MP_ROM_QSTR(MP_QSTR_P18), MP_ROM_PTR(&pin_P0_18) }, // !Reset button. { MP_ROM_QSTR(MP_QSTR_P19), MP_ROM_PTR(&pin_P0_19) }, + { MP_ROM_QSTR(MP_QSTR_P20), MP_ROM_PTR(&pin_P0_20) }, + { MP_ROM_QSTR(MP_QSTR_P21), MP_ROM_PTR(&pin_P0_21) }, { MP_ROM_QSTR(MP_QSTR_P22), MP_ROM_PTR(&pin_P0_22) }, // green led, low is on. { MP_ROM_QSTR(MP_QSTR_P23), MP_ROM_PTR(&pin_P0_23) }, // red led, low is on. { MP_ROM_QSTR(MP_QSTR_P24), MP_ROM_PTR(&pin_P0_24) }, // blue led, low is on. diff --git a/ports/nrf/boards/microbit_v2/mpconfigboard.mk b/ports/nrf/boards/microbit_v2/mpconfigboard.mk index a893acec44..dc47f2be4e 100644 --- a/ports/nrf/boards/microbit_v2/mpconfigboard.mk +++ b/ports/nrf/boards/microbit_v2/mpconfigboard.mk @@ -7,13 +7,11 @@ INTERNAL_FLASH_FILESYSTEM = 1 CIRCUITPY_ALARM = 0 CIRCUITPY_AUDIOMP3 = 0 -CIRCUITPY_BINASCII = 0 CIRCUITPY_BITBANGIO = 0 CIRCUITPY_BUILTINS_POW3=0 CIRCUITPY_BUSDEVICE = 0 CIRCUITPY_COUNTIO = 0 CIRCUITPY_DISPLAYIO = 0 -CIRCUITPY_IS31FL3741 = 0 CIRCUITPY_FRAMEBUFFERIO = 0 CIRCUITPY_FREQUENCYIO = 0 CIRCUITPY_I2CPERIPHERAL = 0 diff --git a/ports/nrf/boards/ohs2020_badge/board.c b/ports/nrf/boards/ohs2020_badge/board.c index 49f85cdecc..dd0a9b2547 100644 --- a/ports/nrf/boards/ohs2020_badge/board.c +++ b/ports/nrf/boards/ohs2020_badge/board.c @@ -48,7 +48,7 @@ uint8_t display_init_sequence[] = { void board_init(void) { busio_spi_obj_t *spi = &displays[0].fourwire_bus.inline_bus; - common_hal_busio_spi_construct(spi, &pin_P0_11, &pin_P0_12, NULL); + common_hal_busio_spi_construct(spi, &pin_P0_11, &pin_P0_12, NULL, false); common_hal_busio_spi_never_reset(spi); displayio_fourwire_obj_t *bus = &displays[0].fourwire_bus; diff --git a/ports/nrf/boards/pca10100/mpconfigboard.mk b/ports/nrf/boards/pca10100/mpconfigboard.mk index 8ae25393f8..59f2b217c3 100644 --- a/ports/nrf/boards/pca10100/mpconfigboard.mk +++ b/ports/nrf/boards/pca10100/mpconfigboard.mk @@ -19,7 +19,6 @@ CIRCUITPY_DISPLAYIO = 0 CIRCUITPY_FRAMEBUFFERIO = 0 CIRCUITPY_FREQUENCYIO = 0 CIRCUITPY_I2CPERIPHERAL = 0 -CIRCUITPY_IS31FL3741 = 0 CIRCUITPY_JSON = 0 CIRCUITPY_KEYPAD = 0 CIRCUITPY_MSGPACK = 0 diff --git a/ports/nrf/boards/simmel/mpconfigboard.mk b/ports/nrf/boards/simmel/mpconfigboard.mk index 85bdca6dc1..67f5dfbd6d 100644 --- a/ports/nrf/boards/simmel/mpconfigboard.mk +++ b/ports/nrf/boards/simmel/mpconfigboard.mk @@ -22,7 +22,6 @@ CIRCUITPY_DISPLAYIO = 0 CIRCUITPY_ERRNO = 0 CIRCUITPY_FRAMEBUFFERIO = 0 CIRCUITPY_GETPASS = 0 -CIRCUITPY_IS31FL3741 = 0 CIRCUITPY_KEYPAD = 0 CIRCUITPY_MSGPACK = 0 CIRCUITPY_NEOPIXEL_WRITE = 0 diff --git a/ports/nrf/boards/sparkfun_nrf52840_mini/pins.c b/ports/nrf/boards/sparkfun_nrf52840_mini/pins.c index a1e2e27cc1..e3188f9bdb 100644 --- a/ports/nrf/boards/sparkfun_nrf52840_mini/pins.c +++ b/ports/nrf/boards/sparkfun_nrf52840_mini/pins.c @@ -50,6 +50,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_QWIIC), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, }; MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/nrf/common-hal/_bleio/CharacteristicBuffer.c b/ports/nrf/common-hal/_bleio/CharacteristicBuffer.c index df389df0f8..5772616ee5 100644 --- a/ports/nrf/common-hal/_bleio/CharacteristicBuffer.c +++ b/ports/nrf/common-hal/_bleio/CharacteristicBuffer.c @@ -158,6 +158,7 @@ bool common_hal_bleio_characteristic_buffer_deinited(bleio_characteristic_buffer void common_hal_bleio_characteristic_buffer_deinit(bleio_characteristic_buffer_obj_t *self) { if (!common_hal_bleio_characteristic_buffer_deinited(self)) { ble_drv_remove_event_handler(characteristic_buffer_on_ble_evt, self); + self->characteristic = NULL; } } diff --git a/ports/nrf/common-hal/_bleio/__init__.h b/ports/nrf/common-hal/_bleio/__init__.h index d94267dd3c..f10001f662 100644 --- a/ports/nrf/common-hal/_bleio/__init__.h +++ b/ports/nrf/common-hal/_bleio/__init__.h @@ -28,7 +28,6 @@ #define MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_INIT_H void bleio_background(void); -void bleio_reset(void); typedef struct { ble_gap_enc_key_t own_enc; diff --git a/ports/nrf/common-hal/busio/I2C.c b/ports/nrf/common-hal/busio/I2C.c index de9417a6cc..322b5f2faa 100644 --- a/ports/nrf/common-hal/busio/I2C.c +++ b/ports/nrf/common-hal/busio/I2C.c @@ -238,7 +238,7 @@ void common_hal_busio_i2c_unlock(busio_i2c_obj_t *self) { self->has_lock = false; } -uint8_t common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t addr, const uint8_t *data, size_t len, bool stopBit) { +STATIC uint8_t _common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t addr, const uint8_t *data, size_t len, bool stopBit) { if (len == 0) { return common_hal_busio_i2c_probe(self, addr) ? 0 : MP_ENODEV; } @@ -266,6 +266,10 @@ uint8_t common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t addr, const u return twi_error_to_mp(err); } +uint8_t common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t addr, const uint8_t *data, size_t len) { + return _common_hal_busio_i2c_write(self, addr, data, len, true); +} + uint8_t common_hal_busio_i2c_read(busio_i2c_obj_t *self, uint16_t addr, uint8_t *data, size_t len) { if (len == 0) { return 0; @@ -292,3 +296,13 @@ uint8_t common_hal_busio_i2c_read(busio_i2c_obj_t *self, uint16_t addr, uint8_t return twi_error_to_mp(err); } + +uint8_t common_hal_busio_i2c_write_read(busio_i2c_obj_t *self, uint16_t addr, + uint8_t *out_data, size_t out_len, uint8_t *in_data, size_t in_len) { + uint8_t result = _common_hal_busio_i2c_write(self, addr, out_data, out_len, false); + if (result != 0) { + return result; + } + + return common_hal_busio_i2c_read(self, addr, in_data, in_len); +} diff --git a/ports/nrf/common-hal/busio/SPI.c b/ports/nrf/common-hal/busio/SPI.c index 55d1c967ac..7258d2149e 100644 --- a/ports/nrf/common-hal/busio/SPI.c +++ b/ports/nrf/common-hal/busio/SPI.c @@ -143,7 +143,12 @@ static nrf_spim_frequency_t baudrate_to_spim_frequency(const uint32_t baudrate) return 0; } -void common_hal_busio_spi_construct(busio_spi_obj_t *self, const mcu_pin_obj_t *clock, const mcu_pin_obj_t *mosi, const mcu_pin_obj_t *miso) { +void common_hal_busio_spi_construct(busio_spi_obj_t *self, const mcu_pin_obj_t *clock, const mcu_pin_obj_t *mosi, const mcu_pin_obj_t *miso, bool half_duplex) { + + if (half_duplex) { + mp_raise_NotImplementedError(translate("Half duplex SPI is not implemented")); + } + // Find a free instance, with most desirable (highest freq and not shared) allocated first. self->spim_peripheral = NULL; for (size_t i = 0; i < MP_ARRAY_SIZE(spim_peripherals); i++) { diff --git a/ports/nrf/common-hal/countio/Counter.c b/ports/nrf/common-hal/countio/Counter.c index b2296a7dcc..32dc6af74b 100644 --- a/ports/nrf/common-hal/countio/Counter.c +++ b/ports/nrf/common-hal/countio/Counter.c @@ -18,45 +18,70 @@ static void _intr_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action) { } void common_hal_countio_counter_construct(countio_counter_obj_t *self, - const mcu_pin_obj_t *pin_a) { + const mcu_pin_obj_t *pin, countio_edge_t edge, digitalio_pull_t pull) { - self->pin_a = pin_a->number; - _countio_objs[self->pin_a] = self; + self->pin = pin->number; + _countio_objs[self->pin] = self; self->count = 0; + nrf_gpiote_polarity_t polarity = NRF_GPIOTE_POLARITY_TOGGLE; + switch (edge) { + case EDGE_RISE: + polarity = NRF_GPIOTE_POLARITY_LOTOHI; + break; + case EDGE_FALL: + polarity = NRF_GPIOTE_POLARITY_HITOLO; + break; + case EDGE_RISE_AND_FALL: + default: + break; + } + + nrf_gpio_pin_pull_t hal_pull = NRF_GPIO_PIN_NOPULL; + switch (pull) { + case PULL_UP: + hal_pull = NRF_GPIO_PIN_PULLUP; + break; + case PULL_DOWN: + hal_pull = NRF_GPIO_PIN_PULLDOWN; + break; + case PULL_NONE: + default: + break; + } + nrfx_gpiote_in_config_t cfg = { - .sense = NRF_GPIOTE_POLARITY_HITOLO, - .pull = NRF_GPIO_PIN_PULLUP, + .sense = polarity, + .pull = hal_pull, .is_watcher = false, .hi_accuracy = true, - .skip_gpio_setup = false + .skip_gpio_setup = false, }; - - nrfx_err_t err = nrfx_gpiote_in_init(self->pin_a, &cfg, _intr_handler); + nrfx_err_t err = nrfx_gpiote_in_init(self->pin, &cfg, _intr_handler); if (err != NRFX_SUCCESS) { mp_raise_RuntimeError(translate("All channels in use")); } - nrfx_gpiote_in_event_enable(self->pin_a, true); + nrfx_gpiote_in_event_enable(self->pin, true); - claim_pin(pin_a); + claim_pin(pin); } bool common_hal_countio_counter_deinited(countio_counter_obj_t *self) { - return self->pin_a == NO_PIN; + return self->pin == NO_PIN; } void common_hal_countio_counter_deinit(countio_counter_obj_t *self) { if (common_hal_countio_counter_deinited(self)) { return; } - _countio_objs[self->pin_a] = NULL; + _countio_objs[self->pin] = NULL; - nrfx_gpiote_in_event_disable(self->pin_a); - nrfx_gpiote_in_uninit(self->pin_a); - reset_pin_number(self->pin_a); - self->pin_a = NO_PIN; + nrfx_gpiote_in_event_disable(self->pin); + nrfx_gpiote_in_uninit(self->pin); + reset_pin_number(self->pin); + self->pin = NO_PIN; } mp_int_t common_hal_countio_counter_get_count(countio_counter_obj_t *self) { @@ -67,7 +92,3 @@ void common_hal_countio_counter_set_count(countio_counter_obj_t *self, mp_int_t new_count) { self->count = new_count; } - -void common_hal_countio_counter_reset(countio_counter_obj_t *self) { - self->count = 0; -} diff --git a/ports/nrf/common-hal/countio/Counter.h b/ports/nrf/common-hal/countio/Counter.h index cf40a63a02..a90bea70d6 100644 --- a/ports/nrf/common-hal/countio/Counter.h +++ b/ports/nrf/common-hal/countio/Counter.h @@ -8,7 +8,7 @@ typedef struct { mp_obj_base_t base; - uint8_t pin_a; + uint8_t pin; mp_int_t count; } countio_counter_obj_t; diff --git a/ports/nrf/mpconfigport.mk b/ports/nrf/mpconfigport.mk index 55ade5562f..1a12c20f2d 100644 --- a/ports/nrf/mpconfigport.mk +++ b/ports/nrf/mpconfigport.mk @@ -2,11 +2,6 @@ # parameters that vary based on chip and/or board. LD_TEMPLATE_FILE = boards/common.template.ld -# Define an equivalent for MICROPY_LONGINT_IMPL, to pass to $(MPY-TOOL) in py/mkrules.mk -# $(MPY-TOOL) needs to know what kind of longint to use (if any) to freeze long integers. -# This should correspond to the MICROPY_LONGINT_IMPL definition in mpconfigport.h. -MPY_TOOL_LONGINT_IMPL = -mlongint-impl=mpz - INTERNAL_LIBM = 1 # Number of USB endpoint pairs. @@ -32,8 +27,6 @@ CIRCUITPY_BLEIO ?= 1 # No I2CPeripheral implementation CIRCUITPY_I2CPERIPHERAL = 0 -CIRCUITPY_IS31FL3741 ?= 1 - CIRCUITPY_RTC ?= 1 # frequencyio not yet implemented diff --git a/ports/nrf/supervisor/port.c b/ports/nrf/supervisor/port.c index a1eb973b83..5c1139271d 100644 --- a/ports/nrf/supervisor/port.c +++ b/ports/nrf/supervisor/port.c @@ -45,7 +45,6 @@ #include "nrf_nvic.h" #include "common-hal/microcontroller/Pin.h" -#include "common-hal/_bleio/__init__.h" #include "common-hal/alarm/time/TimeAlarm.h" #include "common-hal/analogio/AnalogIn.h" #include "common-hal/busio/I2C.h" @@ -59,6 +58,7 @@ #include "common-hal/watchdog/WatchDogTimer.h" #include "common-hal/alarm/__init__.h" +#include "shared-bindings/_bleio/__init__.h" #include "shared-bindings/microcontroller/__init__.h" #include "shared-bindings/rtc/__init__.h" diff --git a/ports/raspberrypi/Makefile b/ports/raspberrypi/Makefile index b63b26d58d..67de654255 100644 --- a/ports/raspberrypi/Makefile +++ b/ports/raspberrypi/Makefile @@ -187,7 +187,7 @@ SRC_SDK := \ src/rp2_common/pico_unique_id/unique_id.c \ SRC_SDK := $(addprefix sdk/, $(SRC_SDK)) -$(patsubst %.c,$(BUILD)/%.o,$(SRC_SDK)): CFLAGS += -Wno-missing-prototypes +$(patsubst %.c,$(BUILD)/%.o,$(SRC_SDK)): CFLAGS += -Wno-missing-prototypes -Wno-undef SRC_C += \ boards/$(BOARD)/board.c \ diff --git a/ports/raspberrypi/bindings/rp2pio/StateMachine.c b/ports/raspberrypi/bindings/rp2pio/StateMachine.c index 0815112c3d..fb13821e35 100644 --- a/ports/raspberrypi/bindings/rp2pio/StateMachine.c +++ b/ports/raspberrypi/bindings/rp2pio/StateMachine.c @@ -78,6 +78,7 @@ //| sideset_pin_count: int = 1, //| initial_sideset_pin_state: int = 0, //| initial_sideset_pin_direction: int = 0x1f, +//| sideset_enable: bool = False, //| exclusive_pin_use: bool = True, //| auto_pull: bool = False, //| pull_threshold: int = 32, @@ -107,9 +108,10 @@ //| :param int initial_set_pin_state: the initial output value for set pins starting at first_set_pin //| :param int initial_set_pin_direction: the initial output direction for set pins starting at first_set_pin //| :param ~microcontroller.Pin first_sideset_pin: the first pin to use with a side set -//| :param int sideset_pin_count: the count of consecutive pins to use with a side set starting at first_sideset_pin +//| :param int sideset_pin_count: the count of consecutive pins to use with a side set starting at first_sideset_pin. Does not include sideset enable //| :param int initial_sideset_pin_state: the initial output value for sideset pins starting at first_sideset_pin //| :param int initial_sideset_pin_direction: the initial output direction for sideset pins starting at first_sideset_pin +//| :param bool sideset_enable: True when the top sideset bit is to enable. This should be used with the ".side_set # opt" directive //| :param ~microcontroller.Pin jmp_pin: the pin which determines the branch taken by JMP PIN instructions //| :param bool exclusive_pin_use: When True, do not share any pins with other state machines. Pins are never shared with other peripherals //| :param bool auto_pull: When True, automatically load data from the tx FIFO into the @@ -147,6 +149,7 @@ STATIC mp_obj_t rp2pio_statemachine_make_new(const mp_obj_type_t *type, size_t n ARG_pull_in_pin_up, ARG_pull_in_pin_down, ARG_first_set_pin, ARG_set_pin_count, ARG_initial_set_pin_state, ARG_initial_set_pin_direction, ARG_first_sideset_pin, ARG_sideset_pin_count, ARG_initial_sideset_pin_state, ARG_initial_sideset_pin_direction, + ARG_sideset_enable, ARG_jmp_pin, ARG_exclusive_pin_use, ARG_auto_pull, ARG_pull_threshold, ARG_out_shift_right, @@ -178,6 +181,8 @@ STATIC mp_obj_t rp2pio_statemachine_make_new(const mp_obj_type_t *type, size_t n { MP_QSTR_initial_sideset_pin_state, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} }, { MP_QSTR_initial_sideset_pin_direction, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0x1f} }, + { MP_QSTR_sideset_enable, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = false} }, + { MP_QSTR_jmp_pin, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} }, { MP_QSTR_exclusive_pin_use, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = true} }, @@ -257,6 +262,7 @@ STATIC mp_obj_t rp2pio_statemachine_make_new(const mp_obj_type_t *type, size_t n first_in_pin, args[ARG_in_pin_count].u_int, args[ARG_pull_in_pin_up].u_int, args[ARG_pull_in_pin_down].u_int, first_set_pin, args[ARG_set_pin_count].u_int, args[ARG_initial_set_pin_state].u_int, args[ARG_initial_set_pin_direction].u_int, first_sideset_pin, args[ARG_sideset_pin_count].u_int, args[ARG_initial_sideset_pin_state].u_int, args[ARG_initial_sideset_pin_direction].u_int, + args[ARG_sideset_enable].u_bool, jmp_pin, 0, args[ARG_exclusive_pin_use].u_bool, @@ -354,7 +360,14 @@ MP_DEFINE_CONST_FUN_OBJ_1(rp2pio_statemachine_stop_obj, rp2pio_statemachine_stop //| def write(self, buffer: ReadableBuffer, *, start: int = 0, end: Optional[int] = None) -> None: //| """Write the data contained in ``buffer`` to the state machine. If the buffer is empty, nothing happens. //| -//| :param ~_typing.ReadableBuffer buffer: Write out the data in this buffer +//| Writes to the FIFO will match the input buffer's element size. For example, bytearray elements +//| will perform 8 bit writes to the PIO FIFO. The RP2040's memory bus will duplicate the value into +//| the other byte positions. So, pulling more data in the PIO assembly will read the duplicated values. +//| +//| To perform 16 or 32 bits writes into the FIFO use an `array.array` with a type code of the desired +//| size. +//| +//| :param ~circuitpython_typing.ReadableBuffer buffer: Write out the data in this buffer //| :param int start: Start of the slice of ``buffer`` to write out: ``buffer[start:end]`` //| :param int end: End of the slice; this index is not included. Defaults to ``len(buffer)``""" //| ... @@ -400,9 +413,17 @@ MP_DEFINE_CONST_FUN_OBJ_KW(rp2pio_statemachine_write_obj, 2, rp2pio_statemachine //| def readinto(self, buffer: WriteableBuffer, *, start: int = 0, end: Optional[int] = None) -> None: //| """Read into ``buffer``. If the number of bytes to read is 0, nothing happens. The buffer -//| include any data added to the fifo even if it was added before this was called. +//| includes any data added to the fifo even if it was added before this was called. //| -//| :param ~_typing.WriteableBuffer buffer: Read data into this buffer +//| Reads from the FIFO will match the input buffer's element size. For example, bytearray elements +//| will perform 8 bit reads from the PIO FIFO. The alignment within the 32 bit value depends on +//| ``in_shift_right``. When ``in_shift_right`` is True, the upper N bits will be read. The lower +//| bits will be read when ``in_shift_right`` is False. +//| +//| To perform 16 or 32 bits writes into the FIFO use an `array.array` with a type code of the desired +//| size. +//| +//| :param ~circuitpython_typing.WriteableBuffer buffer: Read data into this buffer //| :param int start: Start of the slice of ``buffer`` to read into: ``buffer[start:end]`` //| :param int end: End of the slice; this index is not included. Defaults to ``len(buffer)``""" //| ... @@ -450,8 +471,14 @@ MP_DEFINE_CONST_FUN_OBJ_KW(rp2pio_statemachine_readinto_obj, 2, rp2pio_statemach //| may be different. The function will return once both are filled. //| If buffer slice lengths are both 0, nothing happens. //| -//| :param ~_typing.ReadableBuffer buffer_out: Write out the data in this buffer -//| :param ~_typing.WriteableBuffer buffer_in: Read data into this buffer +//| Data transfers to and from the FIFOs will match the corresponding buffer's element size. See +//| `write` and `readinto` for details. +//| +//| To perform 16 or 32 bits writes into the FIFO use an `array.array` with a type code of the desired +//| size. +//| +//| :param ~circuitpython_typing.ReadableBuffer buffer_out: Write out the data in this buffer +//| :param ~circuitpython_typing.WriteableBuffer buffer_in: Read data into this buffer //| :param int out_start: Start of the slice of buffer_out to write out: ``buffer_out[out_start:out_end]`` //| :param int out_end: End of the slice; this index is not included. Defaults to ``len(buffer_out)`` //| :param int in_start: Start of the slice of ``buffer_in`` to read into: ``buffer_in[in_start:in_end]`` diff --git a/ports/raspberrypi/bindings/rp2pio/StateMachine.h b/ports/raspberrypi/bindings/rp2pio/StateMachine.h index effa9c9ce3..3f3b8cf7d8 100644 --- a/ports/raspberrypi/bindings/rp2pio/StateMachine.h +++ b/ports/raspberrypi/bindings/rp2pio/StateMachine.h @@ -44,6 +44,7 @@ void common_hal_rp2pio_statemachine_construct(rp2pio_statemachine_obj_t *self, const mcu_pin_obj_t *first_in_pin, uint8_t in_pin_count, uint32_t pull_pin_up, uint32_t pull_pin_down, const mcu_pin_obj_t *first_set_pin, uint8_t set_pin_count, uint32_t initial_set_pin_state, uint32_t initial_set_pin_direction, const mcu_pin_obj_t *first_sideset_pin, uint8_t sideset_pin_count, uint32_t initial_sideset_pin_state, uint32_t initial_sideset_pin_direction, + bool sideset_enable, const mcu_pin_obj_t *jmp_pin, uint32_t wait_gpio_mask, bool exclusive_pin_use, diff --git a/ports/raspberrypi/boards/adafruit_feather_rp2040/mpconfigboard.mk b/ports/raspberrypi/boards/adafruit_feather_rp2040/mpconfigboard.mk index 84c4adabb7..c77d2d2c13 100644 --- a/ports/raspberrypi/boards/adafruit_feather_rp2040/mpconfigboard.mk +++ b/ports/raspberrypi/boards/adafruit_feather_rp2040/mpconfigboard.mk @@ -6,4 +6,4 @@ USB_MANUFACTURER = "Adafruit" CHIP_VARIANT = RP2040 CHIP_FAMILY = rp2 -EXTERNAL_FLASH_DEVICES = "GD25Q64C" +EXTERNAL_FLASH_DEVICES = "GD25Q64C,W25Q64JVxQ" diff --git a/ports/raspberrypi/boards/adafruit_feather_rp2040/pins.c b/ports/raspberrypi/boards/adafruit_feather_rp2040/pins.c index 6afba676b4..a6bcaea125 100644 --- a/ports/raspberrypi/boards/adafruit_feather_rp2040/pins.c +++ b/ports/raspberrypi/boards/adafruit_feather_rp2040/pins.c @@ -32,6 +32,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO16) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, }; diff --git a/ports/raspberrypi/boards/adafruit_kb2040/mpconfigboard.h b/ports/raspberrypi/boards/adafruit_kb2040/mpconfigboard.h index c01f713e48..e1bfbb01e7 100644 --- a/ports/raspberrypi/boards/adafruit_kb2040/mpconfigboard.h +++ b/ports/raspberrypi/boards/adafruit_kb2040/mpconfigboard.h @@ -8,3 +8,7 @@ #define DEFAULT_UART_BUS_TX (&pin_GPIO0) #define DEFAULT_UART_BUS_RX (&pin_GPIO1) + +#define DEFAULT_SPI_BUS_SCK (&pin_GPIO18) +#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO19) +#define DEFAULT_SPI_BUS_MISO (&pin_GPIO20) diff --git a/ports/raspberrypi/boards/adafruit_kb2040/pins.c b/ports/raspberrypi/boards/adafruit_kb2040/pins.c index e36346a0dd..fcf305d67b 100644 --- a/ports/raspberrypi/boards/adafruit_kb2040/pins.c +++ b/ports/raspberrypi/boards/adafruit_kb2040/pins.c @@ -8,6 +8,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO28) }, { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_GPIO29) }, + { MP_ROM_QSTR(MP_QSTR_CLK), MP_ROM_PTR(&pin_GPIO18) }, { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO18) }, { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO19) }, { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO20) }, @@ -39,6 +40,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO17) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, }; diff --git a/ports/raspberrypi/boards/adafruit_macropad_rp2040/board.c b/ports/raspberrypi/boards/adafruit_macropad_rp2040/board.c index 2d452244f7..7b00ff7ecc 100644 --- a/ports/raspberrypi/boards/adafruit_macropad_rp2040/board.c +++ b/ports/raspberrypi/boards/adafruit_macropad_rp2040/board.c @@ -60,7 +60,7 @@ uint8_t display_init_sequence[] = { void board_init(void) { busio_spi_obj_t *spi = &displays[0].fourwire_bus.inline_bus; - common_hal_busio_spi_construct(spi, &pin_GPIO26, &pin_GPIO27, NULL); + common_hal_busio_spi_construct(spi, &pin_GPIO26, &pin_GPIO27, NULL, false); common_hal_busio_spi_never_reset(spi); displayio_fourwire_obj_t *bus = &displays[0].fourwire_bus; diff --git a/ports/raspberrypi/boards/adafruit_macropad_rp2040/pins.c b/ports/raspberrypi/boards/adafruit_macropad_rp2040/pins.c index 470d4d5371..1abb8469f0 100644 --- a/ports/raspberrypi/boards/adafruit_macropad_rp2040/pins.c +++ b/ports/raspberrypi/boards/adafruit_macropad_rp2040/pins.c @@ -45,6 +45,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO28) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display)} diff --git a/ports/raspberrypi/boards/adafruit_qt2040_trinkey/pins.c b/ports/raspberrypi/boards/adafruit_qt2040_trinkey/pins.c index 98fd7cf56f..1bdf2b35df 100644 --- a/ports/raspberrypi/boards/adafruit_qt2040_trinkey/pins.c +++ b/ports/raspberrypi/boards/adafruit_qt2040_trinkey/pins.c @@ -14,6 +14,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_BUTTON), MP_ROM_PTR(&pin_GPIO12) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, }; MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/raspberrypi/boards/adafruit_qtpy_rp2040/mpconfigboard.h b/ports/raspberrypi/boards/adafruit_qtpy_rp2040/mpconfigboard.h index 5d3795dd5d..f606ab22c4 100644 --- a/ports/raspberrypi/boards/adafruit_qtpy_rp2040/mpconfigboard.h +++ b/ports/raspberrypi/boards/adafruit_qtpy_rp2040/mpconfigboard.h @@ -4,12 +4,12 @@ #define MICROPY_HW_NEOPIXEL (&pin_GPIO12) #define CIRCUITPY_STATUS_LED_POWER (&pin_GPIO11) -#define DEFAULT_I2C_BUS_SCL (&pin_GPIO25) -#define DEFAULT_I2C_BUS_SDA (&pin_GPIO24) +#define CIRCUITPY_BOARD_I2C (2) +#define CIRCUITPY_BOARD_I2C_PIN {{.scl = &pin_GPIO25, .sda = &pin_GPIO24}, \ + {.scl = &pin_GPIO23, .sda = &pin_GPIO22}} -#define DEFAULT_SPI_BUS_SCK (&pin_GPIO6) -#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO3) -#define DEFAULT_SPI_BUS_MISO (&pin_GPIO4) +#define CIRCUITPY_BOARD_SPI (1) +#define CIRCUITPY_BOARD_SPI_PIN {{.clock = &pin_GPIO6, .mosi = &pin_GPIO3, .miso = &pin_GPIO4}} -#define DEFAULT_UART_BUS_RX (&pin_GPIO5) -#define DEFAULT_UART_BUS_TX (&pin_GPIO20) +#define CIRCUITPY_BOARD_UART (1) +#define CIRCUITPY_BOARD_UART_PIN {{.tx = &pin_GPIO20, .rx = &pin_GPIO5}} diff --git a/ports/raspberrypi/boards/adafruit_qtpy_rp2040/pins.c b/ports/raspberrypi/boards/adafruit_qtpy_rp2040/pins.c index 0d6835f48b..082807f577 100644 --- a/ports/raspberrypi/boards/adafruit_qtpy_rp2040/pins.c +++ b/ports/raspberrypi/boards/adafruit_qtpy_rp2040/pins.c @@ -1,5 +1,7 @@ #include "shared-bindings/board/__init__.h" +CIRCUITPY_BOARD_BUS_SINGLETON(stemma_i2c, i2c, 1) + STATIC const mp_rom_map_elem_t board_module_globals_table[] = { CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS @@ -47,5 +49,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, + + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_stemma_i2c_obj) }, }; MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/raspberrypi/boards/challenger_rp2040_lte/pins.c b/ports/raspberrypi/boards/challenger_rp2040_lte/pins.c index 6d1cfbc568..dd2b4d9bda 100644 --- a/ports/raspberrypi/boards/challenger_rp2040_lte/pins.c +++ b/ports/raspberrypi/boards/challenger_rp2040_lte/pins.c @@ -24,6 +24,8 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_GP6), MP_ROM_PTR(&pin_GPIO6) }, { MP_ROM_QSTR(MP_QSTR_SARA_RTS), MP_ROM_PTR(&pin_GPIO7) }, { MP_ROM_QSTR(MP_QSTR_GP7), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_SARA_PWR), MP_ROM_PTR(&pin_GPIO15) }, + { MP_ROM_QSTR(MP_QSTR_GP15), MP_ROM_PTR(&pin_GPIO15) }, // GPIO { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_GPIO12) }, diff --git a/ports/raspberrypi/boards/jpconstantineau_pykey18/board.c b/ports/raspberrypi/boards/jpconstantineau_pykey18/board.c new file mode 100644 index 0000000000..e4e5a8bc57 --- /dev/null +++ b/ports/raspberrypi/boards/jpconstantineau_pykey18/board.c @@ -0,0 +1,45 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "supervisor/board.h" +#include "shared-bindings/microcontroller/Pin.h" +#include "src/rp2_common/hardware_gpio/include/hardware/gpio.h" +#include "supervisor/shared/board.h" + +void board_init(void) { +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { + // turn off any left over LED + board_reset_user_neopixels(&pin_GPIO29, 62); +} + +void board_deinit(void) { +} diff --git a/ports/raspberrypi/boards/jpconstantineau_pykey18/mpconfigboard.h b/ports/raspberrypi/boards/jpconstantineau_pykey18/mpconfigboard.h new file mode 100644 index 0000000000..3394a34a23 --- /dev/null +++ b/ports/raspberrypi/boards/jpconstantineau_pykey18/mpconfigboard.h @@ -0,0 +1,4 @@ +#define MICROPY_HW_BOARD_NAME "PyKey 18 Numpad" +#define MICROPY_HW_MCU_NAME "rp2040" + +#define MICROPY_HW_NEOPIXEL (&pin_GPIO29) diff --git a/ports/raspberrypi/boards/jpconstantineau_pykey18/mpconfigboard.mk b/ports/raspberrypi/boards/jpconstantineau_pykey18/mpconfigboard.mk new file mode 100644 index 0000000000..fbfe913e06 --- /dev/null +++ b/ports/raspberrypi/boards/jpconstantineau_pykey18/mpconfigboard.mk @@ -0,0 +1,11 @@ +USB_VID = 0x1d50 +USB_PID = 0x6153 +USB_PRODUCT = "PyKey18" +USB_MANUFACTURER = "JPConstantineau" + +CHIP_VARIANT = RP2040 +CHIP_FAMILY = rp2 + +EXTERNAL_FLASH_DEVICES = "W25Q16JVxQ" + +CIRCUITPY__EVE = 1 diff --git a/ports/raspberrypi/boards/jpconstantineau_pykey18/pico-sdk-configboard.h b/ports/raspberrypi/boards/jpconstantineau_pykey18/pico-sdk-configboard.h new file mode 100644 index 0000000000..a41131dd22 --- /dev/null +++ b/ports/raspberrypi/boards/jpconstantineau_pykey18/pico-sdk-configboard.h @@ -0,0 +1,4 @@ +// Put board-specific pico-sdk definitions here. This file must exist. + +// Allow extra time for xosc to start. +#define PICO_XOSC_STARTUP_DELAY_MULTIPLIER 64 diff --git a/ports/raspberrypi/boards/jpconstantineau_pykey18/pins.c b/ports/raspberrypi/boards/jpconstantineau_pykey18/pins.c new file mode 100644 index 0000000000..dfa1ae9545 --- /dev/null +++ b/ports/raspberrypi/boards/jpconstantineau_pykey18/pins.c @@ -0,0 +1,24 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + { MP_ROM_QSTR(MP_QSTR_COL1), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_COL2), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_COL3), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_COL4), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_ROW1), MP_ROM_PTR(&pin_GPIO14) }, + { MP_ROM_QSTR(MP_QSTR_ROW2), MP_ROM_PTR(&pin_GPIO15) }, + { MP_ROM_QSTR(MP_QSTR_ROW3), MP_ROM_PTR(&pin_GPIO16) }, + { MP_ROM_QSTR(MP_QSTR_ROW4), MP_ROM_PTR(&pin_GPIO17) }, + { MP_ROM_QSTR(MP_QSTR_ROW5), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_SPEAKER), MP_ROM_PTR(&pin_GPIO21) }, + { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO24) }, + { MP_ROM_QSTR(MP_QSTR_ENCA), MP_ROM_PTR(&pin_GPIO27) }, + { MP_ROM_QSTR(MP_QSTR_ENCB), MP_ROM_PTR(&pin_GPIO28) }, + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO29) }, + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO22) }, + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO23) }, + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/raspberrypi/boards/jpconstantineau_pykey44/board.c b/ports/raspberrypi/boards/jpconstantineau_pykey44/board.c new file mode 100644 index 0000000000..e4e5a8bc57 --- /dev/null +++ b/ports/raspberrypi/boards/jpconstantineau_pykey44/board.c @@ -0,0 +1,45 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "supervisor/board.h" +#include "shared-bindings/microcontroller/Pin.h" +#include "src/rp2_common/hardware_gpio/include/hardware/gpio.h" +#include "supervisor/shared/board.h" + +void board_init(void) { +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { + // turn off any left over LED + board_reset_user_neopixels(&pin_GPIO29, 62); +} + +void board_deinit(void) { +} diff --git a/ports/raspberrypi/boards/jpconstantineau_pykey44/mpconfigboard.h b/ports/raspberrypi/boards/jpconstantineau_pykey44/mpconfigboard.h new file mode 100644 index 0000000000..15f70ae58a --- /dev/null +++ b/ports/raspberrypi/boards/jpconstantineau_pykey44/mpconfigboard.h @@ -0,0 +1,4 @@ +#define MICROPY_HW_BOARD_NAME "PyKey 44 Ergo" +#define MICROPY_HW_MCU_NAME "rp2040" + +#define MICROPY_HW_NEOPIXEL (&pin_GPIO29) diff --git a/ports/raspberrypi/boards/jpconstantineau_pykey44/mpconfigboard.mk b/ports/raspberrypi/boards/jpconstantineau_pykey44/mpconfigboard.mk new file mode 100644 index 0000000000..0e19d10274 --- /dev/null +++ b/ports/raspberrypi/boards/jpconstantineau_pykey44/mpconfigboard.mk @@ -0,0 +1,11 @@ +USB_VID = 0x1d50 +USB_PID = 0x6153 +USB_PRODUCT = "PyKey44" +USB_MANUFACTURER = "JPConstantineau" + +CHIP_VARIANT = RP2040 +CHIP_FAMILY = rp2 + +EXTERNAL_FLASH_DEVICES = "W25Q16JVxQ" + +CIRCUITPY__EVE = 1 diff --git a/ports/raspberrypi/boards/jpconstantineau_pykey44/pico-sdk-configboard.h b/ports/raspberrypi/boards/jpconstantineau_pykey44/pico-sdk-configboard.h new file mode 100644 index 0000000000..a41131dd22 --- /dev/null +++ b/ports/raspberrypi/boards/jpconstantineau_pykey44/pico-sdk-configboard.h @@ -0,0 +1,4 @@ +// Put board-specific pico-sdk definitions here. This file must exist. + +// Allow extra time for xosc to start. +#define PICO_XOSC_STARTUP_DELAY_MULTIPLIER 64 diff --git a/ports/raspberrypi/boards/jpconstantineau_pykey44/pins.c b/ports/raspberrypi/boards/jpconstantineau_pykey44/pins.c new file mode 100644 index 0000000000..b735aad9f7 --- /dev/null +++ b/ports/raspberrypi/boards/jpconstantineau_pykey44/pins.c @@ -0,0 +1,24 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + { MP_ROM_QSTR(MP_QSTR_COL1), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_COL2), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_COL3), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_COL4), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_COL5), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_COL6), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_COL7), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_COL8), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_COL9), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_COL10), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_COL11), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_ROW1), MP_ROM_PTR(&pin_GPIO14) }, + { MP_ROM_QSTR(MP_QSTR_ROW2), MP_ROM_PTR(&pin_GPIO15) }, + { MP_ROM_QSTR(MP_QSTR_ROW3), MP_ROM_PTR(&pin_GPIO16) }, + { MP_ROM_QSTR(MP_QSTR_ROW4), MP_ROM_PTR(&pin_GPIO17) }, + { MP_ROM_QSTR(MP_QSTR_SPEAKER), MP_ROM_PTR(&pin_GPIO21) }, + { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO24) }, + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO29) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/raspberrypi/boards/jpconstantineau_pykey60/mpconfigboard.h b/ports/raspberrypi/boards/jpconstantineau_pykey60/mpconfigboard.h index f96edba2f8..4fc2d4bc14 100644 --- a/ports/raspberrypi/boards/jpconstantineau_pykey60/mpconfigboard.h +++ b/ports/raspberrypi/boards/jpconstantineau_pykey60/mpconfigboard.h @@ -1,4 +1,4 @@ -#define MICROPY_HW_BOARD_NAME "PyKey60" +#define MICROPY_HW_BOARD_NAME "PyKey 60" #define MICROPY_HW_MCU_NAME "rp2040" #define MICROPY_HW_NEOPIXEL (&pin_GPIO29) diff --git a/ports/raspberrypi/boards/jpconstantineau_pykey60/mpconfigboard.mk b/ports/raspberrypi/boards/jpconstantineau_pykey60/mpconfigboard.mk index 263f7ad3b2..b789e70f01 100644 --- a/ports/raspberrypi/boards/jpconstantineau_pykey60/mpconfigboard.mk +++ b/ports/raspberrypi/boards/jpconstantineau_pykey60/mpconfigboard.mk @@ -1,6 +1,6 @@ USB_VID = 0x1d50 USB_PID = 0x6153 -USB_PRODUCT = "Pykey60" +USB_PRODUCT = "PyKey60" USB_MANUFACTURER = "JPConstantineau" CHIP_VARIANT = RP2040 diff --git a/ports/raspberrypi/boards/jpconstantineau_pykey60/pins.c b/ports/raspberrypi/boards/jpconstantineau_pykey60/pins.c index b33373c9a0..033c68034d 100644 --- a/ports/raspberrypi/boards/jpconstantineau_pykey60/pins.c +++ b/ports/raspberrypi/boards/jpconstantineau_pykey60/pins.c @@ -2,7 +2,6 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS - { MP_ROM_QSTR(MP_QSTR_COL1), MP_ROM_PTR(&pin_GPIO0) }, { MP_ROM_QSTR(MP_QSTR_COL2), MP_ROM_PTR(&pin_GPIO1) }, { MP_ROM_QSTR(MP_QSTR_COL3), MP_ROM_PTR(&pin_GPIO2) }, @@ -22,28 +21,15 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_ROW3), MP_ROM_PTR(&pin_GPIO16) }, { MP_ROM_QSTR(MP_QSTR_ROW4), MP_ROM_PTR(&pin_GPIO17) }, { MP_ROM_QSTR(MP_QSTR_ROW5), MP_ROM_PTR(&pin_GPIO18) }, - { MP_ROM_QSTR(MP_QSTR_SPEAKER), MP_ROM_PTR(&pin_GPIO21) }, - { MP_ROM_QSTR(MP_QSTR_GP22), MP_ROM_PTR(&pin_GPIO22) }, - { MP_ROM_QSTR(MP_QSTR_GP23), MP_ROM_PTR(&pin_GPIO23) }, - { MP_ROM_QSTR(MP_QSTR_GP24), MP_ROM_PTR(&pin_GPIO24) }, - { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO24) }, - { MP_ROM_QSTR(MP_QSTR_GP25), MP_ROM_PTR(&pin_GPIO25) }, - { MP_ROM_QSTR(MP_QSTR_GP26), MP_ROM_PTR(&pin_GPIO26) }, - { MP_ROM_QSTR(MP_QSTR_GP27), MP_ROM_PTR(&pin_GPIO27) }, - { MP_ROM_QSTR(MP_QSTR_GP28), MP_ROM_PTR(&pin_GPIO28) }, { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO29) }, - { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO22) }, { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO23) }, - { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO26) }, { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO28) }, { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO27) }, - { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, - }; MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/raspberrypi/boards/jpconstantineau_pykey87/board.c b/ports/raspberrypi/boards/jpconstantineau_pykey87/board.c new file mode 100644 index 0000000000..e4e5a8bc57 --- /dev/null +++ b/ports/raspberrypi/boards/jpconstantineau_pykey87/board.c @@ -0,0 +1,45 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "supervisor/board.h" +#include "shared-bindings/microcontroller/Pin.h" +#include "src/rp2_common/hardware_gpio/include/hardware/gpio.h" +#include "supervisor/shared/board.h" + +void board_init(void) { +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { + // turn off any left over LED + board_reset_user_neopixels(&pin_GPIO29, 62); +} + +void board_deinit(void) { +} diff --git a/ports/raspberrypi/boards/jpconstantineau_pykey87/mpconfigboard.h b/ports/raspberrypi/boards/jpconstantineau_pykey87/mpconfigboard.h new file mode 100644 index 0000000000..aee9ed27e3 --- /dev/null +++ b/ports/raspberrypi/boards/jpconstantineau_pykey87/mpconfigboard.h @@ -0,0 +1,4 @@ +#define MICROPY_HW_BOARD_NAME "PyKey 87 TKL" +#define MICROPY_HW_MCU_NAME "rp2040" + +#define MICROPY_HW_NEOPIXEL (&pin_GPIO29) diff --git a/ports/raspberrypi/boards/jpconstantineau_pykey87/mpconfigboard.mk b/ports/raspberrypi/boards/jpconstantineau_pykey87/mpconfigboard.mk new file mode 100644 index 0000000000..83dcb3df52 --- /dev/null +++ b/ports/raspberrypi/boards/jpconstantineau_pykey87/mpconfigboard.mk @@ -0,0 +1,11 @@ +USB_VID = 0x1d50 +USB_PID = 0x6153 +USB_PRODUCT = "PyKey87" +USB_MANUFACTURER = "JPConstantineau" + +CHIP_VARIANT = RP2040 +CHIP_FAMILY = rp2 + +EXTERNAL_FLASH_DEVICES = "W25Q16JVxQ" + +CIRCUITPY__EVE = 1 diff --git a/ports/raspberrypi/boards/jpconstantineau_pykey87/pico-sdk-configboard.h b/ports/raspberrypi/boards/jpconstantineau_pykey87/pico-sdk-configboard.h new file mode 100644 index 0000000000..a41131dd22 --- /dev/null +++ b/ports/raspberrypi/boards/jpconstantineau_pykey87/pico-sdk-configboard.h @@ -0,0 +1,4 @@ +// Put board-specific pico-sdk definitions here. This file must exist. + +// Allow extra time for xosc to start. +#define PICO_XOSC_STARTUP_DELAY_MULTIPLIER 64 diff --git a/ports/raspberrypi/boards/jpconstantineau_pykey87/pins.c b/ports/raspberrypi/boards/jpconstantineau_pykey87/pins.c new file mode 100644 index 0000000000..63a7826f1d --- /dev/null +++ b/ports/raspberrypi/boards/jpconstantineau_pykey87/pins.c @@ -0,0 +1,37 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + + { MP_ROM_QSTR(MP_QSTR_COL1), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_COL2), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_COL3), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_COL4), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_COL5), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_COL6), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_COL7), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_COL8), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_COL9), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_COL10), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_COL11), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_COL12), MP_ROM_PTR(&pin_GPIO11) }, + { MP_ROM_QSTR(MP_QSTR_COL13), MP_ROM_PTR(&pin_GPIO12) }, + { MP_ROM_QSTR(MP_QSTR_COL14), MP_ROM_PTR(&pin_GPIO13) }, + { MP_ROM_QSTR(MP_QSTR_ROW1), MP_ROM_PTR(&pin_GPIO14) }, + { MP_ROM_QSTR(MP_QSTR_ROW2), MP_ROM_PTR(&pin_GPIO15) }, + { MP_ROM_QSTR(MP_QSTR_ROW3), MP_ROM_PTR(&pin_GPIO16) }, + { MP_ROM_QSTR(MP_QSTR_ROW4), MP_ROM_PTR(&pin_GPIO17) }, + { MP_ROM_QSTR(MP_QSTR_ROW5), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_COL15), MP_ROM_PTR(&pin_GPIO19) }, + { MP_ROM_QSTR(MP_QSTR_COL16), MP_ROM_PTR(&pin_GPIO20) }, + { MP_ROM_QSTR(MP_QSTR_SPEAKER), MP_ROM_PTR(&pin_GPIO21) }, + { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO24) }, + { MP_ROM_QSTR(MP_QSTR_COL17), MP_ROM_PTR(&pin_GPIO25) }, + { MP_ROM_QSTR(MP_QSTR_ROW0), MP_ROM_PTR(&pin_GPIO26) }, + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO29) }, + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO22) }, + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO23) }, + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/raspberrypi/boards/melopero_shake_rp2040/pins.c b/ports/raspberrypi/boards/melopero_shake_rp2040/pins.c index 76ab220216..c3bc3f6d6f 100644 --- a/ports/raspberrypi/boards/melopero_shake_rp2040/pins.c +++ b/ports/raspberrypi/boards/melopero_shake_rp2040/pins.c @@ -34,6 +34,7 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO16) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, }; diff --git a/ports/raspberrypi/boards/odt_cast_away_rp2040/board.c b/ports/raspberrypi/boards/odt_cast_away_rp2040/board.c new file mode 100644 index 0000000000..de6e424ed9 --- /dev/null +++ b/ports/raspberrypi/boards/odt_cast_away_rp2040/board.c @@ -0,0 +1,40 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "supervisor/board.h" + +void board_init(void) { +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { +} + +void board_deinit(void) { +} diff --git a/ports/raspberrypi/boards/odt_cast_away_rp2040/mpconfigboard.h b/ports/raspberrypi/boards/odt_cast_away_rp2040/mpconfigboard.h new file mode 100644 index 0000000000..db2b871bb0 --- /dev/null +++ b/ports/raspberrypi/boards/odt_cast_away_rp2040/mpconfigboard.h @@ -0,0 +1,14 @@ +#define MICROPY_HW_BOARD_NAME "Oak Dev Tech Cast-Away RP2040" +#define MICROPY_HW_MCU_NAME "rp2040" + +#define MICROPY_HW_NEOPIXEL (&pin_GPIO18) + +#define DEFAULT_I2C_BUS_SCL (&pin_GPIO1) +#define DEFAULT_I2C_BUS_SDA (&pin_GPIO0) + +#define DEFAULT_SPI_BUS_SCK (&pin_GPIO2) +#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO3) +#define DEFAULT_SPI_BUS_MISO (&pin_GPIO4) + +#define DEFAULT_UART_BUS_RX (&pin_GPIO14) +#define DEFAULT_UART_BUS_TX (&pin_GPIO15) diff --git a/ports/raspberrypi/boards/odt_cast_away_rp2040/mpconfigboard.mk b/ports/raspberrypi/boards/odt_cast_away_rp2040/mpconfigboard.mk new file mode 100644 index 0000000000..40f3582005 --- /dev/null +++ b/ports/raspberrypi/boards/odt_cast_away_rp2040/mpconfigboard.mk @@ -0,0 +1,11 @@ +USB_VID = 0x1209 +USB_PID = 0x4DF2 +USB_PRODUCT = "CAST AWAY RP2040" +USB_MANUFACTURER = "Oak Dev Tech" + +CHIP_VARIANT = RP2040 +CHIP_FAMILY = rp2 + +EXTERNAL_FLASH_DEVICES = "W25Q16JVxQ" + +CIRCUITPY__EVE = 1 diff --git a/ports/raspberrypi/boards/odt_cast_away_rp2040/pico-sdk-configboard.h b/ports/raspberrypi/boards/odt_cast_away_rp2040/pico-sdk-configboard.h new file mode 100644 index 0000000000..7d1b96b85a --- /dev/null +++ b/ports/raspberrypi/boards/odt_cast_away_rp2040/pico-sdk-configboard.h @@ -0,0 +1,3 @@ +// Put board-specific pico-sdk definitions here. This file must exist. +// Allow extra time for xosc to start. +#define PICO_XOSC_STARTUP_DELAY_MULTIPLIER 64 diff --git a/ports/raspberrypi/boards/odt_cast_away_rp2040/pins.c b/ports/raspberrypi/boards/odt_cast_away_rp2040/pins.c new file mode 100644 index 0000000000..8686f7ae0b --- /dev/null +++ b/ports/raspberrypi/boards/odt_cast_away_rp2040/pins.c @@ -0,0 +1,41 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_global_dict_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + + { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO1) }, + + { MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_GPIO5) }, + + { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_GPIO12) }, + { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_GPIO13) }, + { MP_ROM_QSTR(MP_QSTR_D14), MP_ROM_PTR(&pin_GPIO14) }, + { MP_ROM_QSTR(MP_QSTR_D15), MP_ROM_PTR(&pin_GPIO15) }, + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO14) }, + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO15) }, + { MP_ROM_QSTR(MP_QSTR_D16), MP_ROM_PTR(&pin_GPIO16) }, + { MP_ROM_QSTR(MP_QSTR_D17), MP_ROM_PTR(&pin_GPIO17) }, + + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO18) }, + + { MP_ROM_QSTR(MP_QSTR_D26), MP_ROM_PTR(&pin_GPIO26) }, + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO26) }, + { MP_ROM_QSTR(MP_QSTR_D27), MP_ROM_PTR(&pin_GPIO27) }, + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO27) }, + { MP_ROM_QSTR(MP_QSTR_D28), MP_ROM_PTR(&pin_GPIO28) }, + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO28) }, + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table); diff --git a/ports/raspberrypi/boards/pimoroni_badger2040/board.c b/ports/raspberrypi/boards/pimoroni_badger2040/board.c new file mode 100644 index 0000000000..de6e424ed9 --- /dev/null +++ b/ports/raspberrypi/boards/pimoroni_badger2040/board.c @@ -0,0 +1,40 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "supervisor/board.h" + +void board_init(void) { +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { +} + +void board_deinit(void) { +} diff --git a/ports/raspberrypi/boards/pimoroni_badger2040/mpconfigboard.h b/ports/raspberrypi/boards/pimoroni_badger2040/mpconfigboard.h new file mode 100644 index 0000000000..d169395a7d --- /dev/null +++ b/ports/raspberrypi/boards/pimoroni_badger2040/mpconfigboard.h @@ -0,0 +1,2 @@ +#define MICROPY_HW_BOARD_NAME "Pimoroni Badger 2040" +#define MICROPY_HW_MCU_NAME "rp2040" diff --git a/ports/raspberrypi/boards/pimoroni_badger2040/mpconfigboard.mk b/ports/raspberrypi/boards/pimoroni_badger2040/mpconfigboard.mk new file mode 100644 index 0000000000..7e9c76c030 --- /dev/null +++ b/ports/raspberrypi/boards/pimoroni_badger2040/mpconfigboard.mk @@ -0,0 +1,11 @@ +USB_VID = 0x2E8A +USB_PID = 0x101B +USB_PRODUCT = "Badger 2040" +USB_MANUFACTURER = "Pimoroni" + +CHIP_VARIANT = RP2040 +CHIP_FAMILY = rp2 + +EXTERNAL_FLASH_DEVICES = "W25Q16JVxQ" + +CIRCUITPY__EVE = 1 diff --git a/ports/raspberrypi/boards/pimoroni_badger2040/pico-sdk-configboard.h b/ports/raspberrypi/boards/pimoroni_badger2040/pico-sdk-configboard.h new file mode 100644 index 0000000000..36da55d457 --- /dev/null +++ b/ports/raspberrypi/boards/pimoroni_badger2040/pico-sdk-configboard.h @@ -0,0 +1 @@ +// Put board-specific pico-sdk definitions here. This file must exist. diff --git a/ports/raspberrypi/boards/pimoroni_badger2040/pins.c b/ports/raspberrypi/boards/pimoroni_badger2040/pins.c new file mode 100644 index 0000000000..b2808bb693 --- /dev/null +++ b/ports/raspberrypi/boards/pimoroni_badger2040/pins.c @@ -0,0 +1,44 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_GP0), MP_ROM_PTR(&pin_GPIO0) }, + + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_GP1), MP_ROM_PTR(&pin_GPIO1) }, + + { MP_ROM_QSTR(MP_QSTR_INT), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO5) }, + + { MP_ROM_QSTR(MP_QSTR_3V3_EN), MP_ROM_PTR(&pin_GPIO10) }, + + { MP_ROM_QSTR(MP_QSTR_SW_DOWN), MP_ROM_PTR(&pin_GPIO11) }, + { MP_ROM_QSTR(MP_QSTR_SW_A), MP_ROM_PTR(&pin_GPIO12) }, + { MP_ROM_QSTR(MP_QSTR_SW_B), MP_ROM_PTR(&pin_GPIO13) }, + { MP_ROM_QSTR(MP_QSTR_SW_C), MP_ROM_PTR(&pin_GPIO14) }, + { MP_ROM_QSTR(MP_QSTR_SW_UP), MP_ROM_PTR(&pin_GPIO15) }, + + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO16) }, + { MP_ROM_QSTR(MP_QSTR_INKY_CS), MP_ROM_PTR(&pin_GPIO17) }, + { MP_ROM_QSTR(MP_QSTR_SCLK), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO19) }, + { MP_ROM_QSTR(MP_QSTR_INKY_DC), MP_ROM_PTR(&pin_GPIO20) }, + { MP_ROM_QSTR(MP_QSTR_INKY_RST), MP_ROM_PTR(&pin_GPIO21) }, + + { MP_ROM_QSTR(MP_QSTR_USER_SW), MP_ROM_PTR(&pin_GPIO23) }, + + { MP_ROM_QSTR(MP_QSTR_VBUS_DETECT), MP_ROM_PTR(&pin_GPIO24) }, + { MP_ROM_QSTR(MP_QSTR_USER_LED), MP_ROM_PTR(&pin_GPIO25) }, + { MP_ROM_QSTR(MP_QSTR_INKY_BUSY), MP_ROM_PTR(&pin_GPIO26) }, + { MP_ROM_QSTR(MP_QSTR_VREF_POWER), MP_ROM_PTR(&pin_GPIO27) }, + { MP_ROM_QSTR(MP_QSTR_1V2_REF), MP_ROM_PTR(&pin_GPIO28) }, + { MP_ROM_QSTR(MP_QSTR_VBAT_SENSE), MP_ROM_PTR(&pin_GPIO29) }, + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) } +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/raspberrypi/boards/pimoroni_interstate75/pins.c b/ports/raspberrypi/boards/pimoroni_interstate75/pins.c index 1244f63a22..2460ebc76a 100644 --- a/ports/raspberrypi/boards/pimoroni_interstate75/pins.c +++ b/ports/raspberrypi/boards/pimoroni_interstate75/pins.c @@ -50,5 +50,6 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_CURRENT_SENSE), MP_ROM_PTR(&pin_GPIO29) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, }; MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/raspberrypi/boards/pimoroni_picolipo_16mb/pins.c b/ports/raspberrypi/boards/pimoroni_picolipo_16mb/pins.c index 577b29736e..a89950cca7 100644 --- a/ports/raspberrypi/boards/pimoroni_picolipo_16mb/pins.c +++ b/ports/raspberrypi/boards/pimoroni_picolipo_16mb/pins.c @@ -50,5 +50,6 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_BAT_SENSE), MP_ROM_PTR(&pin_GPIO29) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, }; MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/raspberrypi/boards/pimoroni_picolipo_4mb/pins.c b/ports/raspberrypi/boards/pimoroni_picolipo_4mb/pins.c index 577b29736e..a89950cca7 100644 --- a/ports/raspberrypi/boards/pimoroni_picolipo_4mb/pins.c +++ b/ports/raspberrypi/boards/pimoroni_picolipo_4mb/pins.c @@ -50,5 +50,6 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_BAT_SENSE), MP_ROM_PTR(&pin_GPIO29) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, }; MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/raspberrypi/boards/pimoroni_picosystem/board.c b/ports/raspberrypi/boards/pimoroni_picosystem/board.c index 9f5f6ae6f5..e8458e90d9 100644 --- a/ports/raspberrypi/boards/pimoroni_picosystem/board.c +++ b/ports/raspberrypi/boards/pimoroni_picosystem/board.c @@ -65,7 +65,7 @@ uint8_t display_init_sequence[] = { void board_init(void) { busio_spi_obj_t *spi = &displays[0].fourwire_bus.inline_bus; - common_hal_busio_spi_construct(spi, &pin_GPIO6, &pin_GPIO7, NULL); + common_hal_busio_spi_construct(spi, &pin_GPIO6, &pin_GPIO7, NULL, false); common_hal_busio_spi_never_reset(spi); displayio_fourwire_obj_t *bus = &displays[0].fourwire_bus; diff --git a/ports/raspberrypi/boards/pimoroni_plasma2040/pins.c b/ports/raspberrypi/boards/pimoroni_plasma2040/pins.c index 5f685a3528..5ecc44619a 100644 --- a/ports/raspberrypi/boards/pimoroni_plasma2040/pins.c +++ b/ports/raspberrypi/boards/pimoroni_plasma2040/pins.c @@ -39,5 +39,6 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_CURRENT_SENSE), MP_ROM_PTR(&pin_GPIO29) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, }; MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/raspberrypi/boards/pimoroni_tiny2040/mpconfigboard.h b/ports/raspberrypi/boards/pimoroni_tiny2040/mpconfigboard.h index 4184f35a7a..8059472780 100644 --- a/ports/raspberrypi/boards/pimoroni_tiny2040/mpconfigboard.h +++ b/ports/raspberrypi/boards/pimoroni_tiny2040/mpconfigboard.h @@ -1,4 +1,4 @@ -#define MICROPY_HW_BOARD_NAME "Pimoroni Tiny 2040" +#define MICROPY_HW_BOARD_NAME "Pimoroni Tiny 2040 (8MB)" #define MICROPY_HW_MCU_NAME "rp2040" #define CIRCUITPY_RGB_STATUS_INVERTED_PWM diff --git a/ports/raspberrypi/boards/pimoroni_tiny2040/mpconfigboard.mk b/ports/raspberrypi/boards/pimoroni_tiny2040/mpconfigboard.mk index 7487782237..e63e53ea55 100644 --- a/ports/raspberrypi/boards/pimoroni_tiny2040/mpconfigboard.mk +++ b/ports/raspberrypi/boards/pimoroni_tiny2040/mpconfigboard.mk @@ -1,6 +1,6 @@ USB_VID = 0x16D0 USB_PID = 0x08C7 -USB_PRODUCT = "Tiny 2040" +USB_PRODUCT = "Tiny 2040 (8MB)" USB_MANUFACTURER = "Pimoroni" CHIP_VARIANT = RP2040 diff --git a/ports/raspberrypi/boards/pimoroni_tiny2040_2mb/board.c b/ports/raspberrypi/boards/pimoroni_tiny2040_2mb/board.c new file mode 100644 index 0000000000..de6e424ed9 --- /dev/null +++ b/ports/raspberrypi/boards/pimoroni_tiny2040_2mb/board.c @@ -0,0 +1,40 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "supervisor/board.h" + +void board_init(void) { +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { +} + +void board_deinit(void) { +} diff --git a/ports/raspberrypi/boards/pimoroni_tiny2040_2mb/mpconfigboard.h b/ports/raspberrypi/boards/pimoroni_tiny2040_2mb/mpconfigboard.h new file mode 100644 index 0000000000..9f9219fc60 --- /dev/null +++ b/ports/raspberrypi/boards/pimoroni_tiny2040_2mb/mpconfigboard.h @@ -0,0 +1,7 @@ +#define MICROPY_HW_BOARD_NAME "Pimoroni Tiny 2040 (2MB)" +#define MICROPY_HW_MCU_NAME "rp2040" + +#define CIRCUITPY_RGB_STATUS_INVERTED_PWM +#define CIRCUITPY_RGB_STATUS_R (&pin_GPIO18) +#define CIRCUITPY_RGB_STATUS_G (&pin_GPIO19) +#define CIRCUITPY_RGB_STATUS_B (&pin_GPIO20) diff --git a/ports/raspberrypi/boards/pimoroni_tiny2040_2mb/mpconfigboard.mk b/ports/raspberrypi/boards/pimoroni_tiny2040_2mb/mpconfigboard.mk new file mode 100644 index 0000000000..b92946c130 --- /dev/null +++ b/ports/raspberrypi/boards/pimoroni_tiny2040_2mb/mpconfigboard.mk @@ -0,0 +1,11 @@ +USB_VID = 0x2E8A +USB_PID = 0x1016 +USB_PRODUCT = "Tiny 2040 (2MB)" +USB_MANUFACTURER = "Pimoroni" + +CHIP_VARIANT = RP2040 +CHIP_FAMILY = rp2 + +EXTERNAL_FLASH_DEVICES = "W25Q16JVxQ" + +CIRCUITPY__EVE = 1 diff --git a/ports/raspberrypi/boards/pimoroni_tiny2040_2mb/pico-sdk-configboard.h b/ports/raspberrypi/boards/pimoroni_tiny2040_2mb/pico-sdk-configboard.h new file mode 100644 index 0000000000..36da55d457 --- /dev/null +++ b/ports/raspberrypi/boards/pimoroni_tiny2040_2mb/pico-sdk-configboard.h @@ -0,0 +1 @@ +// Put board-specific pico-sdk definitions here. This file must exist. diff --git a/ports/raspberrypi/boards/pimoroni_tiny2040_2mb/pins.c b/ports/raspberrypi/boards/pimoroni_tiny2040_2mb/pins.c new file mode 100644 index 0000000000..6dd90a90bb --- /dev/null +++ b/ports/raspberrypi/boards/pimoroni_tiny2040_2mb/pins.c @@ -0,0 +1,37 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + + { MP_ROM_QSTR(MP_QSTR_GP0), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_GP1), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_GP2), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_GP3), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_GP4), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_GP5), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_GP6), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_GP7), MP_ROM_PTR(&pin_GPIO7) }, + + { MP_ROM_QSTR(MP_QSTR_LED_R), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_LED_G), MP_ROM_PTR(&pin_GPIO19) }, + { MP_ROM_QSTR(MP_QSTR_LED_B), MP_ROM_PTR(&pin_GPIO20) }, + + { MP_ROM_QSTR(MP_QSTR_USER_SW), MP_ROM_PTR(&pin_GPIO23) }, + + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO26) }, + { MP_ROM_QSTR(MP_QSTR_GP26_A0), MP_ROM_PTR(&pin_GPIO26) }, + { MP_ROM_QSTR(MP_QSTR_GP26), MP_ROM_PTR(&pin_GPIO26) }, + + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO27) }, + { MP_ROM_QSTR(MP_QSTR_GP27_A1), MP_ROM_PTR(&pin_GPIO27) }, + { MP_ROM_QSTR(MP_QSTR_GP27), MP_ROM_PTR(&pin_GPIO27) }, + + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO28) }, + { MP_ROM_QSTR(MP_QSTR_GP28_A2), MP_ROM_PTR(&pin_GPIO28) }, + { MP_ROM_QSTR(MP_QSTR_GP28), MP_ROM_PTR(&pin_GPIO28) }, + + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_GPIO29) }, + { MP_ROM_QSTR(MP_QSTR_GP29_A3), MP_ROM_PTR(&pin_GPIO29) }, + { MP_ROM_QSTR(MP_QSTR_GP29), MP_ROM_PTR(&pin_GPIO29) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/raspberrypi/boards/seeeduino_xiao_rp2040/board.c b/ports/raspberrypi/boards/seeeduino_xiao_rp2040/board.c new file mode 100644 index 0000000000..de6e424ed9 --- /dev/null +++ b/ports/raspberrypi/boards/seeeduino_xiao_rp2040/board.c @@ -0,0 +1,40 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "supervisor/board.h" + +void board_init(void) { +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { +} + +void board_deinit(void) { +} diff --git a/ports/raspberrypi/boards/seeeduino_xiao_rp2040/mpconfigboard.h b/ports/raspberrypi/boards/seeeduino_xiao_rp2040/mpconfigboard.h new file mode 100644 index 0000000000..a0ea3c51a0 --- /dev/null +++ b/ports/raspberrypi/boards/seeeduino_xiao_rp2040/mpconfigboard.h @@ -0,0 +1,15 @@ +#define MICROPY_HW_BOARD_NAME "Seeeduino XIAO RP2040" +#define MICROPY_HW_MCU_NAME "rp2040" + +#define MICROPY_HW_NEOPIXEL (&pin_GPIO12) +#define CIRCUITPY_STATUS_LED_POWER (&pin_GPIO11) + +#define DEFAULT_I2C_BUS_SCL (&pin_GPIO7) +#define DEFAULT_I2C_BUS_SDA (&pin_GPIO6) + +#define DEFAULT_SPI_BUS_SCK (&pin_GPIO2) +#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO3) +#define DEFAULT_SPI_BUS_MISO (&pin_GPIO4) + +#define DEFAULT_UART_BUS_RX (&pin_GPIO1) +#define DEFAULT_UART_BUS_TX (&pin_GPIO0) diff --git a/ports/raspberrypi/boards/seeeduino_xiao_rp2040/mpconfigboard.mk b/ports/raspberrypi/boards/seeeduino_xiao_rp2040/mpconfigboard.mk new file mode 100644 index 0000000000..1540642cd5 --- /dev/null +++ b/ports/raspberrypi/boards/seeeduino_xiao_rp2040/mpconfigboard.mk @@ -0,0 +1,9 @@ +USB_VID = 0x2886 +USB_PID = 0x0042 +USB_PRODUCT = "Seeeduino XIAO RP2040" +USB_MANUFACTURER = "Seeed" + +CHIP_VARIANT = RP2040 +CHIP_FAMILY = rp2 + +EXTERNAL_FLASH_DEVICES = "P25Q16H" diff --git a/ports/raspberrypi/boards/seeeduino_xiao_rp2040/pico-sdk-configboard.h b/ports/raspberrypi/boards/seeeduino_xiao_rp2040/pico-sdk-configboard.h new file mode 100644 index 0000000000..a41131dd22 --- /dev/null +++ b/ports/raspberrypi/boards/seeeduino_xiao_rp2040/pico-sdk-configboard.h @@ -0,0 +1,4 @@ +// Put board-specific pico-sdk definitions here. This file must exist. + +// Allow extra time for xosc to start. +#define PICO_XOSC_STARTUP_DELAY_MULTIPLIER 64 diff --git a/ports/raspberrypi/boards/seeeduino_xiao_rp2040/pins.c b/ports/raspberrypi/boards/seeeduino_xiao_rp2040/pins.c new file mode 100644 index 0000000000..a53cb3f11a --- /dev/null +++ b/ports/raspberrypi/boards/seeeduino_xiao_rp2040/pins.c @@ -0,0 +1,51 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO26) }, + { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_GPIO26) }, + + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO27) }, + { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_GPIO27) }, + + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO28) }, + { MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_GPIO28) }, + + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_GPIO29) }, + { MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_GPIO29) }, + + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_GPIO6) }, + + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_GPIO7) }, + + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_GPIO0) }, + + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_GPIO1) }, + + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_GPIO2) }, + + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_GPIO4) }, + + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_GPIO3) }, + + { MP_ROM_QSTR(MP_QSTR_LED_GREEN), MP_ROM_PTR(&pin_GPIO16) }, + { MP_ROM_QSTR(MP_QSTR_LED_RED), MP_ROM_PTR(&pin_GPIO17) }, + { MP_ROM_QSTR(MP_QSTR_LED_BLUE), MP_ROM_PTR(&pin_GPIO25) }, + { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO25) }, + + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO12) }, + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL_POWER), MP_ROM_PTR(&pin_GPIO11) }, + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/raspberrypi/boards/sparkfun_pro_micro_rp2040/pins.c b/ports/raspberrypi/boards/sparkfun_pro_micro_rp2040/pins.c index bc7cb048de..f4ebe33e8b 100644 --- a/ports/raspberrypi/boards/sparkfun_pro_micro_rp2040/pins.c +++ b/ports/raspberrypi/boards/sparkfun_pro_micro_rp2040/pins.c @@ -40,6 +40,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO25) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, }; diff --git a/ports/raspberrypi/boards/sparkfun_thing_plus_rp2040/pins.c b/ports/raspberrypi/boards/sparkfun_thing_plus_rp2040/pins.c index a72342c86a..22dccc66bb 100644 --- a/ports/raspberrypi/boards/sparkfun_thing_plus_rp2040/pins.c +++ b/ports/raspberrypi/boards/sparkfun_thing_plus_rp2040/pins.c @@ -59,6 +59,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO25) }, // on-board LED (separate/additional from neopixel) { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, }; diff --git a/ports/raspberrypi/boards/waveshare_rp2040_zero/board.c b/ports/raspberrypi/boards/waveshare_rp2040_zero/board.c new file mode 100644 index 0000000000..de6e424ed9 --- /dev/null +++ b/ports/raspberrypi/boards/waveshare_rp2040_zero/board.c @@ -0,0 +1,40 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "supervisor/board.h" + +void board_init(void) { +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { +} + +void board_deinit(void) { +} diff --git a/ports/raspberrypi/boards/waveshare_rp2040_zero/mpconfigboard.h b/ports/raspberrypi/boards/waveshare_rp2040_zero/mpconfigboard.h new file mode 100644 index 0000000000..9979e6dcb6 --- /dev/null +++ b/ports/raspberrypi/boards/waveshare_rp2040_zero/mpconfigboard.h @@ -0,0 +1,7 @@ +#define MICROPY_HW_BOARD_NAME "Waveshare RP2040-Zero" +#define MICROPY_HW_MCU_NAME "rp2040" + +#define DEFAULT_UART_BUS_TX (&pin_GPIO0) +#define DEFAULT_UART_BUS_RX (&pin_GPIO1) + +#define MICROPY_HW_NEOPIXEL (&pin_GPIO16) diff --git a/ports/raspberrypi/boards/waveshare_rp2040_zero/mpconfigboard.mk b/ports/raspberrypi/boards/waveshare_rp2040_zero/mpconfigboard.mk new file mode 100644 index 0000000000..9222a7be7c --- /dev/null +++ b/ports/raspberrypi/boards/waveshare_rp2040_zero/mpconfigboard.mk @@ -0,0 +1,11 @@ +USB_VID = 0x2E8A +USB_PID = 0x101F +USB_PRODUCT = "RP2040-Zero" +USB_MANUFACTURER = "Waveshare Electronics" + +CHIP_VARIANT = RP2040 +CHIP_FAMILY = rp2 + +EXTERNAL_FLASH_DEVICES = "W25Q16JVxQ" + +CIRCUITPY__EVE = 1 diff --git a/ports/raspberrypi/boards/waveshare_rp2040_zero/pico-sdk-configboard.h b/ports/raspberrypi/boards/waveshare_rp2040_zero/pico-sdk-configboard.h new file mode 100644 index 0000000000..36da55d457 --- /dev/null +++ b/ports/raspberrypi/boards/waveshare_rp2040_zero/pico-sdk-configboard.h @@ -0,0 +1 @@ +// Put board-specific pico-sdk definitions here. This file must exist. diff --git a/ports/raspberrypi/boards/waveshare_rp2040_zero/pins.c b/ports/raspberrypi/boards/waveshare_rp2040_zero/pins.c new file mode 100644 index 0000000000..6de9ad478f --- /dev/null +++ b/ports/raspberrypi/boards/waveshare_rp2040_zero/pins.c @@ -0,0 +1,56 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + + { MP_ROM_QSTR(MP_QSTR_GP0), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO0) }, + + { MP_ROM_QSTR(MP_QSTR_GP1), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO1) }, + + { MP_ROM_QSTR(MP_QSTR_GP2), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_GP3), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_GP4), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_GP5), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_GP6), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_GP7), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_GP8), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_GP9), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_GP10), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_GP11), MP_ROM_PTR(&pin_GPIO11) }, + { MP_ROM_QSTR(MP_QSTR_GP12), MP_ROM_PTR(&pin_GPIO12) }, + { MP_ROM_QSTR(MP_QSTR_GP13), MP_ROM_PTR(&pin_GPIO13) }, + { MP_ROM_QSTR(MP_QSTR_GP14), MP_ROM_PTR(&pin_GPIO14) }, + { MP_ROM_QSTR(MP_QSTR_GP15), MP_ROM_PTR(&pin_GPIO15) }, + { MP_ROM_QSTR(MP_QSTR_GP16), MP_ROM_PTR(&pin_GPIO16) }, + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO16) }, + { MP_ROM_QSTR(MP_QSTR_GP17), MP_ROM_PTR(&pin_GPIO17) }, + { MP_ROM_QSTR(MP_QSTR_GP18), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_GP19), MP_ROM_PTR(&pin_GPIO19) }, + { MP_ROM_QSTR(MP_QSTR_GP20), MP_ROM_PTR(&pin_GPIO20) }, + { MP_ROM_QSTR(MP_QSTR_GP21), MP_ROM_PTR(&pin_GPIO21) }, + { MP_ROM_QSTR(MP_QSTR_GP22), MP_ROM_PTR(&pin_GPIO22) }, + { MP_ROM_QSTR(MP_QSTR_GP23), MP_ROM_PTR(&pin_GPIO23) }, + { MP_ROM_QSTR(MP_QSTR_GP24), MP_ROM_PTR(&pin_GPIO24) }, + { MP_ROM_QSTR(MP_QSTR_GP25), MP_ROM_PTR(&pin_GPIO25) }, + + { MP_ROM_QSTR(MP_QSTR_GP26_A0), MP_ROM_PTR(&pin_GPIO26) }, + { MP_ROM_QSTR(MP_QSTR_GP26), MP_ROM_PTR(&pin_GPIO26) }, + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO26) }, + + { MP_ROM_QSTR(MP_QSTR_GP27_A1), MP_ROM_PTR(&pin_GPIO27) }, + { MP_ROM_QSTR(MP_QSTR_GP27), MP_ROM_PTR(&pin_GPIO27) }, + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO27) }, + + { MP_ROM_QSTR(MP_QSTR_GP28_A2), MP_ROM_PTR(&pin_GPIO28) }, + { MP_ROM_QSTR(MP_QSTR_GP28), MP_ROM_PTR(&pin_GPIO28) }, + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO28) }, + + { MP_ROM_QSTR(MP_QSTR_GP29_A3), MP_ROM_PTR(&pin_GPIO29) }, + { MP_ROM_QSTR(MP_QSTR_GP29), MP_ROM_PTR(&pin_GPIO29) }, + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_GPIO29) }, + + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/raspberrypi/common-hal/audiobusio/I2SOut.c b/ports/raspberrypi/common-hal/audiobusio/I2SOut.c index da50e17f42..8432e47a52 100644 --- a/ports/raspberrypi/common-hal/audiobusio/I2SOut.c +++ b/ports/raspberrypi/common-hal/audiobusio/I2SOut.c @@ -127,6 +127,7 @@ void common_hal_audiobusio_i2sout_construct(audiobusio_i2sout_obj_t *self, 0, 0, // in pulls NULL, 0, 0, 0x1f, // set pins bit_clock, 2, 0, 0x1f, // sideset pins + false, // No sideset enable NULL, // jump pin 0, // wait gpio pins true, // exclusive pin use diff --git a/ports/raspberrypi/common-hal/audiobusio/PDMIn.c b/ports/raspberrypi/common-hal/audiobusio/PDMIn.c index f2775c2543..4b5694706f 100644 --- a/ports/raspberrypi/common-hal/audiobusio/PDMIn.c +++ b/ports/raspberrypi/common-hal/audiobusio/PDMIn.c @@ -64,20 +64,21 @@ void common_hal_audiobusio_pdmin_construct(audiobusio_pdmin_obj_t *self, // Use the state machine to manage pins. common_hal_rp2pio_statemachine_construct(&self->state_machine, pdmin, sizeof(pdmin) / sizeof(pdmin[0]), - 44100 * 32 * 2, // Clock at 44.1 khz to warm the DAC up. + sample_rate * 32 * 2, // Frequency based on sample rate NULL, 0, NULL, 1, 0, 0xffffffff, // out pin data_pin, 1, // in pins 0, 0, // in pulls NULL, 0, 0, 0x1f, // set pins clock_pin, 1, 0, 0x1f, // sideset pins + false, // No sideset enable NULL, // jump pin 0, // wait gpio pins true, // exclusive pin use false, 32, false, // out settings false, // Wait for txstall false, 32, true, // in settings - false); // Not user-interruptible + false); // Not user-interruptible. uint32_t actual_frequency = common_hal_rp2pio_statemachine_get_frequency(&self->state_machine); if (actual_frequency < MIN_MIC_CLOCK) { diff --git a/ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c b/ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c index 0654037d66..2f09124f4b 100644 --- a/ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c +++ b/ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c @@ -44,8 +44,6 @@ #include "src/rp2040/hardware_structs/include/hardware/structs/dma.h" #include "src/rp2_common/hardware_pwm/include/hardware/pwm.h" -#define NUM_DMA_TIMERS 4 - // The PWM clock frequency is base_clock_rate / PWM_TOP, typically 125_000_000 / PWM_TOP. // We pick BITS_PER_SAMPLE so we get a clock frequency that is above what would cause aliasing. #define BITS_PER_SAMPLE 10 @@ -207,7 +205,7 @@ void common_hal_audiopwmio_pwmaudioout_play(audiopwmio_pwmaudioout_obj_t *self, uint32_t tx_register = (uint32_t)&pwm_hw->slice[self->left_pwm.slice].cc; if (self->stereo) { // Shift the destination if we are outputting to both PWM channels. - tx_register += self->left_pwm.channel * sizeof(uint16_t); + tx_register += self->left_pwm.ab_channel * sizeof(uint16_t); } self->pacing_timer = pacing_timer; diff --git a/ports/raspberrypi/common-hal/busio/I2C.c b/ports/raspberrypi/common-hal/busio/I2C.c index 96038b4241..516cee2227 100644 --- a/ports/raspberrypi/common-hal/busio/I2C.c +++ b/ports/raspberrypi/common-hal/busio/I2C.c @@ -109,8 +109,11 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, // set up as GPIO by the bitbangio.I2C object. // // Sets pins to open drain, high, and input. + // + // Do not use the default supplied clock stretching timeout here. + // It is too short for some devices. Use the busio timeout instead. shared_module_bitbangio_i2c_construct(&self->bitbangio_i2c, scl, sda, - frequency, timeout); + frequency, BUS_TIMEOUT_US); self->baudrate = i2c_init(self->peripheral, frequency); @@ -142,7 +145,7 @@ void common_hal_busio_i2c_deinit(busio_i2c_obj_t *self) { } bool common_hal_busio_i2c_probe(busio_i2c_obj_t *self, uint8_t addr) { - return common_hal_busio_i2c_write(self, addr, NULL, 0, true) == 0; + return common_hal_busio_i2c_write(self, addr, NULL, 0) == 0; } bool common_hal_busio_i2c_try_lock(busio_i2c_obj_t *self) { @@ -162,7 +165,7 @@ void common_hal_busio_i2c_unlock(busio_i2c_obj_t *self) { self->has_lock = false; } -uint8_t common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t addr, +STATIC uint8_t _common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t addr, const uint8_t *data, size_t len, bool transmit_stop_bit) { if (len == 0) { // The RP2040 I2C peripheral will not perform 0 byte writes. @@ -200,6 +203,11 @@ uint8_t common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t addr, } } +uint8_t common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t addr, + const uint8_t *data, size_t len) { + return _common_hal_busio_i2c_write(self, addr, data, len, true); +} + uint8_t common_hal_busio_i2c_read(busio_i2c_obj_t *self, uint16_t addr, uint8_t *data, size_t len) { int result = i2c_read_timeout_us(self->peripheral, addr, data, len, false, BUS_TIMEOUT_US); @@ -216,6 +224,16 @@ uint8_t common_hal_busio_i2c_read(busio_i2c_obj_t *self, uint16_t addr, } } +uint8_t common_hal_busio_i2c_write_read(busio_i2c_obj_t *self, uint16_t addr, + uint8_t *out_data, size_t out_len, uint8_t *in_data, size_t in_len) { + uint8_t result = _common_hal_busio_i2c_write(self, addr, out_data, out_len, false); + if (result != 0) { + return result; + } + + return common_hal_busio_i2c_read(self, addr, in_data, in_len); +} + void common_hal_busio_i2c_never_reset(busio_i2c_obj_t *self) { never_reset_i2c[i2c_hw_index(self->peripheral)] = true; diff --git a/ports/raspberrypi/common-hal/busio/SPI.c b/ports/raspberrypi/common-hal/busio/SPI.c index 766807f5a9..4a18d62584 100644 --- a/ports/raspberrypi/common-hal/busio/SPI.c +++ b/ports/raspberrypi/common-hal/busio/SPI.c @@ -54,8 +54,13 @@ void reset_spi(void) { void common_hal_busio_spi_construct(busio_spi_obj_t *self, const mcu_pin_obj_t *clock, const mcu_pin_obj_t *mosi, - const mcu_pin_obj_t *miso) { + const mcu_pin_obj_t *miso, bool half_duplex) { size_t instance_index = NO_INSTANCE; + + if (half_duplex) { + mp_raise_NotImplementedError(translate("Half duplex SPI is not implemented")); + } + if (clock->number % 4 == 2) { instance_index = (clock->number / 8) % 2; } @@ -90,7 +95,8 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self, mp_raise_ValueError(translate("SPI peripheral in use")); } - spi_init(self->peripheral, 250000); + self->target_frequency = 250000; + self->real_frequency = spi_init(self->peripheral, self->target_frequency); gpio_set_function(clock->number, GPIO_FUNC_SPI); claim_pin(clock); diff --git a/ports/raspberrypi/common-hal/busio/UART.c b/ports/raspberrypi/common-hal/busio/UART.c index 14935f4046..0e25c57297 100644 --- a/ports/raspberrypi/common-hal/busio/UART.c +++ b/ports/raspberrypi/common-hal/busio/UART.c @@ -120,14 +120,14 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, if (uart_status[uart_id] != STATUS_FREE) { mp_raise_RuntimeError(translate("All UART peripherals are in use")); - } else { - uart_status[uart_id] = STATUS_BUSY; } - + // These may raise exceptions if pins are already in use. self->tx_pin = pin_init(uart_id, tx, 0); self->rx_pin = pin_init(uart_id, rx, 1); self->cts_pin = pin_init(uart_id, cts, 2); self->rts_pin = pin_init(uart_id, rts, 3); + uart_status[uart_id] = STATUS_BUSY; + self->uart = UART_INST(uart_id); self->uart_id = uart_id; diff --git a/ports/raspberrypi/common-hal/countio/Counter.c b/ports/raspberrypi/common-hal/countio/Counter.c index bbf71f996e..0ae773bdf3 100644 --- a/ports/raspberrypi/common-hal/countio/Counter.c +++ b/ports/raspberrypi/common-hal/countio/Counter.c @@ -4,6 +4,8 @@ #include "py/mpstate.h" #include "supervisor/shared/translate.h" +#include "shared-bindings/countio/Edge.h" +#include "shared-bindings/digitalio/Pull.h" #include "common-hal/pwmio/PWMOut.h" #include "src/rp2_common/hardware_gpio/include/hardware/gpio.h" @@ -12,21 +14,25 @@ void common_hal_countio_counter_construct(countio_counter_obj_t *self, - const mcu_pin_obj_t *pin_a) { + const mcu_pin_obj_t *pin, countio_edge_t edge, digitalio_pull_t pull) { - if (pwm_gpio_to_channel(pin_a->number) != PWM_CHAN_B) { + if (pwm_gpio_to_channel(pin->number) != PWM_CHAN_B) { mp_raise_RuntimeError(translate("Pin must be on PWM Channel B")); } - self->pin_a = pin_a->number; - self->slice_num = pwm_gpio_to_slice_num(self->pin_a); + if (edge == EDGE_RISE_AND_FALL) { + mp_raise_NotImplementedError(translate("RISE_AND_FALL not available on this chip")); + } + + self->pin = pin->number; + self->slice_num = pwm_gpio_to_slice_num(self->pin); if (MP_STATE_PORT(counting)[self->slice_num] != NULL) { mp_raise_RuntimeError(translate("PWM slice already in use")); } - uint8_t channel = pwm_gpio_to_channel(self->pin_a); - if (!pwmio_claim_slice_channels(self->slice_num)) { + uint8_t ab_channel = pwm_gpio_to_channel(self->pin); + if (!pwmio_claim_slice_ab_channels(self->slice_num)) { mp_raise_RuntimeError(translate("PWM slice channel A already in use")); } @@ -36,11 +42,12 @@ void common_hal_countio_counter_construct(countio_counter_obj_t *self, irq_set_enabled(PWM_IRQ_WRAP, true); pwm_config cfg = pwm_get_default_config(); - pwm_config_set_clkdiv_mode(&cfg, PWM_DIV_B_RISING); + pwm_config_set_clkdiv_mode(&cfg, edge == EDGE_RISE ? PWM_DIV_B_RISING : PWM_DIV_B_FALLING); pwm_init(self->slice_num, &cfg, false); - gpio_set_function(self->pin_a, GPIO_FUNC_PWM); + gpio_set_function(self->pin, GPIO_FUNC_PWM); + gpio_set_pulls(self->pin, pull == PULL_UP, pull == PULL_DOWN); - claim_pin(pin_a); + claim_pin(pin); MP_STATE_PORT(counting)[self->slice_num] = self; @@ -58,7 +65,7 @@ void reset_countio(void) { } bool common_hal_countio_counter_deinited(countio_counter_obj_t *self) { - return self->pin_a == 0; + return self->pin == 0; } void common_hal_countio_counter_deinit(countio_counter_obj_t *self) { @@ -69,12 +76,12 @@ void common_hal_countio_counter_deinit(countio_counter_obj_t *self) { pwm_set_enabled(self->slice_num, false); pwm_set_irq_enabled(self->slice_num, false); - pwmio_release_slice_channels(self->slice_num); + pwmio_release_slice_ab_channels(self->slice_num); - reset_pin_number(self->pin_a); + reset_pin_number(self->pin); MP_STATE_PORT(counting)[self->slice_num] = NULL; - self->pin_a = 0; + self->pin = 0; self->slice_num = 0; } @@ -90,21 +97,17 @@ void common_hal_countio_counter_set_count(countio_counter_obj_t *self, self->count = new_count; } -void common_hal_countio_counter_reset(countio_counter_obj_t *self) { - pwm_set_counter(self->slice_num, 0); - self->count = 0; -} - void counter_interrupt_handler(void) { uint32_t mask = pwm_get_irq_status_mask(); - uint8_t i = 1, pos = 1; + uint8_t i = 1; + uint8_t pos = 0; while (!(i & mask)) { i = i << 1; ++pos; } - countio_counter_obj_t *self = MP_STATE_PORT(counting)[pos - 1]; + countio_counter_obj_t *self = MP_STATE_PORT(counting)[pos]; if (self != NULL) { pwm_clear_irq(self->slice_num); self->count += 65536; diff --git a/ports/raspberrypi/common-hal/countio/Counter.h b/ports/raspberrypi/common-hal/countio/Counter.h index 7469dd2d00..3355036eed 100644 --- a/ports/raspberrypi/common-hal/countio/Counter.h +++ b/ports/raspberrypi/common-hal/countio/Counter.h @@ -8,7 +8,7 @@ typedef struct { mp_obj_base_t base; - uint8_t pin_a; + uint8_t pin; uint8_t slice_num; mp_int_t count; } countio_counter_obj_t; diff --git a/ports/raspberrypi/common-hal/imagecapture/ParallelImageCapture.c b/ports/raspberrypi/common-hal/imagecapture/ParallelImageCapture.c index 9eabc9f967..45a3766897 100644 --- a/ports/raspberrypi/common-hal/imagecapture/ParallelImageCapture.c +++ b/ports/raspberrypi/common-hal/imagecapture/ParallelImageCapture.c @@ -111,6 +111,7 @@ void common_hal_imagecapture_parallelimagecapture_construct(imagecapture_paralle #else NULL, 0, 0, 0, // sideset pins #endif + false, // No sideset enable NULL, // jump pin (1 << vertical_sync->number) | (1 << horizontal_reference->number) | (1 << data_clock->number), // wait gpio pins true, // exclusive pin use diff --git a/ports/raspberrypi/common-hal/neopixel_write/__init__.c b/ports/raspberrypi/common-hal/neopixel_write/__init__.c index b3d704453c..09388af481 100644 --- a/ports/raspberrypi/common-hal/neopixel_write/__init__.c +++ b/ports/raspberrypi/common-hal/neopixel_write/__init__.c @@ -77,7 +77,8 @@ void common_hal_neopixel_write(const digitalio_digitalinout_obj_t *digitalinout, true, // Wait for txstall. If we don't, then we'll deinit too quickly. false, 32, true, // RX setting we don't use false, // claim pins - false); // Not user-interruptible. + false, // Not user-interruptible. + false); // No sideset enable if (!ok) { // Do nothing. Maybe bitbang? return; @@ -97,6 +98,6 @@ void common_hal_neopixel_write(const digitalio_digitalinout_obj_t *digitalinout, gpio_init(digitalinout->pin->number); common_hal_digitalio_digitalinout_switch_to_output((digitalio_digitalinout_obj_t *)digitalinout, false, DRIVE_MODE_PUSH_PULL); - // Update the next start. - next_start_raw_ticks = port_get_raw_ticks(NULL) + 1; + // Update the next start to +2 ticks. This ensures we give it at least 300us. + next_start_raw_ticks = port_get_raw_ticks(NULL) + 2; } diff --git a/ports/raspberrypi/common-hal/nvm/ByteArray.c b/ports/raspberrypi/common-hal/nvm/ByteArray.c index 6908cbeabf..cc52c88f38 100644 --- a/ports/raspberrypi/common-hal/nvm/ByteArray.c +++ b/ports/raspberrypi/common-hal/nvm/ByteArray.c @@ -31,6 +31,7 @@ #include "py/runtime.h" #include "src/rp2_common/hardware_flash/include/hardware/flash.h" +#include "shared-bindings/microcontroller/__init__.h" extern uint32_t __flash_binary_start; static const uint32_t flash_binary_start = (uint32_t)&__flash_binary_start; @@ -45,23 +46,40 @@ static void write_page(uint32_t page_addr, uint32_t offset, uint32_t len, uint8_ // Write a whole page to flash, buffering it first and then erasing and rewriting it // since we can only write a whole page at a time. if (offset == 0 && len == FLASH_PAGE_SIZE) { + // disable interrupts to prevent core hang on rp2040 + common_hal_mcu_disable_interrupts(); flash_range_program(RMV_OFFSET(page_addr), bytes, FLASH_PAGE_SIZE); + common_hal_mcu_enable_interrupts(); } else { uint8_t buffer[FLASH_PAGE_SIZE]; memcpy(buffer, (uint8_t *)page_addr, FLASH_PAGE_SIZE); memcpy(buffer + offset, bytes, len); + common_hal_mcu_disable_interrupts(); flash_range_program(RMV_OFFSET(page_addr), buffer, FLASH_PAGE_SIZE); + common_hal_mcu_enable_interrupts(); } + } static void erase_and_write_sector(uint32_t address, uint32_t len, uint8_t *bytes) { // Write a whole sector to flash, buffering it first and then erasing and rewriting it // since we can only erase a whole sector at a time. uint8_t buffer[FLASH_SECTOR_SIZE]; + #pragma GCC diagnostic push + #if __GNUC__ >= 11 + // TODO: Update this to a better workaround for GCC 11 when one is provided. + // See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99578#c20 + #pragma GCC diagnostic ignored "-Warray-bounds" + #pragma GCC diagnostic ignored "-Wstringop-overread" + #endif memcpy(buffer, (uint8_t *)CIRCUITPY_INTERNAL_NVM_START_ADDR, FLASH_SECTOR_SIZE); + #pragma GCC diagnostic pop memcpy(buffer + address, bytes, len); + // disable interrupts to prevent core hang on rp2040 + common_hal_mcu_disable_interrupts(); flash_range_erase(RMV_OFFSET(CIRCUITPY_INTERNAL_NVM_START_ADDR), FLASH_SECTOR_SIZE); flash_range_program(RMV_OFFSET(CIRCUITPY_INTERNAL_NVM_START_ADDR), buffer, FLASH_SECTOR_SIZE); + common_hal_mcu_enable_interrupts(); } void common_hal_nvm_bytearray_get_bytes(const nvm_bytearray_obj_t *self, diff --git a/ports/raspberrypi/common-hal/paralleldisplay/ParallelBus.c b/ports/raspberrypi/common-hal/paralleldisplay/ParallelBus.c index 9971474042..2e0ae4def2 100644 --- a/ports/raspberrypi/common-hal/paralleldisplay/ParallelBus.c +++ b/ports/raspberrypi/common-hal/paralleldisplay/ParallelBus.c @@ -99,6 +99,7 @@ void common_hal_paralleldisplay_parallelbus_construct(paralleldisplay_parallelbu NULL, 0, 0, 0, // first in pin, # in pins NULL, 0, 0, 0, // first set pin write, 1, 0, 1, // first sideset pin + false, // No sideset enable NULL, // jump pin 0, // wait gpio pins true, // exclusive pin usage diff --git a/ports/raspberrypi/common-hal/pulseio/PulseIn.c b/ports/raspberrypi/common-hal/pulseio/PulseIn.c index 9d3f614987..e507cd16e8 100644 --- a/ports/raspberrypi/common-hal/pulseio/PulseIn.c +++ b/ports/raspberrypi/common-hal/pulseio/PulseIn.c @@ -73,7 +73,8 @@ void common_hal_pulseio_pulsein_construct(pulseio_pulsein_obj_t *self, false, true, 32, true, // RX auto-push every 32 bits false, // claim pins - false); // Not user-interruptible. + false, // Not user-interruptible. + false); // No sideset enable if (!ok) { mp_raise_RuntimeError(translate("All state machines in use")); diff --git a/ports/raspberrypi/common-hal/pwmio/PWMOut.c b/ports/raspberrypi/common-hal/pwmio/PWMOut.c index 27e9bd4d03..3ef4fb57f3 100644 --- a/ports/raspberrypi/common-hal/pwmio/PWMOut.c +++ b/ports/raspberrypi/common-hal/pwmio/PWMOut.c @@ -42,7 +42,7 @@ uint32_t target_slice_frequencies[NUM_PWM_SLICES]; uint32_t slice_variable_frequency; -#define CHANNELS_PER_SLICE 2 +#define AB_CHANNELS_PER_SLICE 2 static uint32_t channel_use; static uint32_t never_reset_channel; @@ -58,11 +58,11 @@ static uint32_t never_reset_channel; // So 65534 should be the maximum top value, and we'll set CC to be TOP+1 as appropriate. #define MAX_TOP 65534 -static uint32_t _mask(uint8_t slice, uint8_t channel) { - return 1 << (slice * CHANNELS_PER_SLICE + channel); +static uint32_t _mask(uint8_t slice, uint8_t ab_channel) { + return 1 << (slice * AB_CHANNELS_PER_SLICE + ab_channel); } -bool pwmio_claim_slice_channels(uint8_t slice) { +bool pwmio_claim_slice_ab_channels(uint8_t slice) { uint32_t channel_use_mask_a = _mask(slice, 0); uint32_t channel_use_mask_b = _mask(slice, 1); @@ -78,37 +78,37 @@ bool pwmio_claim_slice_channels(uint8_t slice) { return true; } -void pwmio_release_slice_channels(uint8_t slice) { +void pwmio_release_slice_ab_channels(uint8_t slice) { uint32_t channel_mask = _mask(slice, 0); channel_use &= ~channel_mask; channel_mask = _mask(slice, 1); channel_use &= ~channel_mask; } -void pwmout_never_reset(uint8_t slice, uint8_t channel) { - never_reset_channel |= _mask(slice, channel); +void pwmout_never_reset(uint8_t slice, uint8_t ab_channel) { + never_reset_channel |= _mask(slice, ab_channel); } -void pwmout_reset_ok(uint8_t slice, uint8_t channel) { - never_reset_channel &= ~_mask(slice, channel); +void pwmout_reset_ok(uint8_t slice, uint8_t ab_channel) { + never_reset_channel &= ~_mask(slice, ab_channel); } void common_hal_pwmio_pwmout_never_reset(pwmio_pwmout_obj_t *self) { - pwmout_never_reset(self->slice, self->channel); + pwmout_never_reset(self->slice, self->ab_channel); never_reset_pin_number(self->pin->number); } void common_hal_pwmio_pwmout_reset_ok(pwmio_pwmout_obj_t *self) { - pwmout_reset_ok(self->slice, self->channel); + pwmout_reset_ok(self->slice, self->ab_channel); } void pwmout_reset(void) { // Reset all slices for (size_t slice = 0; slice < NUM_PWM_SLICES; slice++) { bool reset = true; - for (size_t channel = 0; channel < CHANNELS_PER_SLICE; channel++) { - uint32_t channel_use_mask = _mask(slice, channel); + for (size_t ab_channel = 0; ab_channel < AB_CHANNELS_PER_SLICE; ab_channel++) { + uint32_t channel_use_mask = _mask(slice, ab_channel); if ((never_reset_channel & channel_use_mask) != 0) { reset = false; continue; @@ -124,8 +124,8 @@ void pwmout_reset(void) { } } -pwmout_result_t pwmout_allocate(uint8_t slice, uint8_t channel, bool variable_frequency, uint32_t frequency) { - uint32_t channel_use_mask = _mask(slice, channel); +pwmout_result_t pwmout_allocate(uint8_t slice, uint8_t ab_channel, bool variable_frequency, uint32_t frequency) { + uint32_t channel_use_mask = _mask(slice, ab_channel); // Check the channel first. if ((channel_use & channel_use_mask) != 0) { @@ -171,15 +171,15 @@ pwmout_result_t common_hal_pwmio_pwmout_construct(pwmio_pwmout_obj_t *self, } uint8_t slice = pwm_gpio_to_slice_num(pin->number); - uint8_t channel = pwm_gpio_to_channel(pin->number); + uint8_t ab_channel = pwm_gpio_to_channel(pin->number); - int r = pwmout_allocate(slice, channel, variable_frequency, frequency); + int r = pwmout_allocate(slice, ab_channel, variable_frequency, frequency); if (r != PWMOUT_OK) { return r; } self->slice = slice; - self->channel = channel; + self->ab_channel = ab_channel; if (target_slice_frequencies[slice] != frequency) { // Reset the counter and compare values. @@ -202,11 +202,11 @@ bool common_hal_pwmio_pwmout_deinited(pwmio_pwmout_obj_t *self) { return self->pin == NULL; } -void pwmout_free(uint8_t slice, uint8_t channel) { - uint32_t channel_mask = _mask(slice, channel); +void pwmout_free(uint8_t slice, uint8_t ab_channel) { + uint32_t channel_mask = _mask(slice, ab_channel); channel_use &= ~channel_mask; never_reset_channel &= ~channel_mask; - uint32_t slice_mask = ((1 << CHANNELS_PER_SLICE) - 1) << (slice * CHANNELS_PER_SLICE); + uint32_t slice_mask = ((1 << AB_CHANNELS_PER_SLICE) - 1) << (slice * AB_CHANNELS_PER_SLICE); if ((channel_use & slice_mask) == 0) { target_slice_frequencies[slice] = 0; slice_variable_frequency &= ~(1 << slice); @@ -218,7 +218,7 @@ void common_hal_pwmio_pwmout_deinit(pwmio_pwmout_obj_t *self) { if (common_hal_pwmio_pwmout_deinited(self)) { return; } - pwmout_free(self->slice, self->channel); + pwmout_free(self->slice, self->ab_channel); reset_pin_number(self->pin->number); self->pin = NULL; } @@ -235,13 +235,13 @@ extern void common_hal_pwmio_pwmout_set_duty_cycle(pwmio_pwmout_obj_t *self, uin compare_count = ((uint32_t)duty * self->top + MAX_TOP / 2) / MAX_TOP; } // compare_count is the CC register value, which should be TOP+1 for 100% duty cycle. - pwm_set_chan_level(self->slice, self->channel, compare_count); + pwm_set_chan_level(self->slice, self->ab_channel, compare_count); // Wait for wrap so that we know our new cc value has been applied. Clear // the internal interrupt and then wait for it to be set. Worst case, we // wait a full cycle. - pwm_hw->intr = 1 << self->channel; - while ((pwm_hw->en & (1 << self->channel)) != 0 && - (pwm_hw->intr & (1 << self->channel)) == 0 && + pwm_hw->intr = 1 << self->slice; + while ((pwm_hw->en & (1 << self->slice)) != 0 && + (pwm_hw->intr & (1 << self->slice)) == 0 && !mp_hal_is_interrupted()) { } } diff --git a/ports/raspberrypi/common-hal/pwmio/PWMOut.h b/ports/raspberrypi/common-hal/pwmio/PWMOut.h index c7707762e4..0d179934d0 100644 --- a/ports/raspberrypi/common-hal/pwmio/PWMOut.h +++ b/ports/raspberrypi/common-hal/pwmio/PWMOut.h @@ -24,8 +24,8 @@ * THE SOFTWARE. */ -#ifndef MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_PWMIO_PWMOUT_H -#define MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_PWMIO_PWMOUT_H +#ifndef MICROPY_INCLUDED_RASPBERRY_PI_COMMON_HAL_PWMIO_PWMOUT_H +#define MICROPY_INCLUDED_RASPBERRY_PI_COMMON_HAL_PWMIO_PWMOUT_H #include "common-hal/microcontroller/Pin.h" @@ -34,8 +34,8 @@ typedef struct { mp_obj_base_t base; const mcu_pin_obj_t *pin; - uint8_t slice; - uint8_t channel; + uint8_t slice; // 0-7 + uint8_t ab_channel; // 0-1: A or B slice channel bool variable_frequency; uint16_t duty_cycle; uint32_t actual_frequency; @@ -46,13 +46,13 @@ void pwmout_reset(void); // Private API for AudioPWMOut. void pwmio_pwmout_set_top(pwmio_pwmout_obj_t *self, uint16_t top); // Private APIs for RGBMatrix -enum pwmout_result_t pwmout_allocate(uint8_t slice, uint8_t channel, bool variable_frequency, uint32_t frequency); -void pwmout_free(uint8_t slice, uint8_t channel); -void pwmout_never_reset(uint8_t slice, uint8_t channel); -void pwmout_reset_ok(uint8_t slice, uint8_t channel); +enum pwmout_result_t pwmout_allocate(uint8_t slice, uint8_t ab_channel, bool variable_frequency, uint32_t frequency); +void pwmout_free(uint8_t slice, uint8_t ab_channel); +void pwmout_never_reset(uint8_t slice, uint8_t ab_channel); +void pwmout_reset_ok(uint8_t slice, uint8_t ab_channel); -// Private API for countio to claim both channels on a slice -bool pwmio_claim_slice_channels(uint8_t slice); -void pwmio_release_slice_channels(uint8_t slice); +// Private API for countio to claim both ab_channels on a slice +bool pwmio_claim_slice_ab_channels(uint8_t slice); +void pwmio_release_slice_ab_channels(uint8_t slice); -#endif // MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_PWMIO_PWMOUT_H +#endif // MICROPY_INCLUDED_RASPBERRY_PI_COMMON_HAL_PWMIO_PWMOUT_H diff --git a/ports/raspberrypi/common-hal/rgbmatrix/RGBMatrix.c b/ports/raspberrypi/common-hal/rgbmatrix/RGBMatrix.c index f150422e3c..d580b4cc6a 100644 --- a/ports/raspberrypi/common-hal/rgbmatrix/RGBMatrix.c +++ b/ports/raspberrypi/common-hal/rgbmatrix/RGBMatrix.c @@ -33,6 +33,7 @@ #include "shared-module/rgbmatrix/RGBMatrix.h" #include "src/rp2_common/hardware_pwm/include/hardware/pwm.h" +#include "src/rp2_common/hardware_irq/include/hardware/irq.h" void *common_hal_rgbmatrix_timer_allocate(rgbmatrix_rgbmatrix_obj_t *self) { // Choose a PWM channel based on the first RGB pin @@ -58,6 +59,8 @@ void common_hal_rgbmatrix_timer_enable(void *ptr) { void common_hal_rgbmatrix_timer_disable(void *ptr) { int8_t slice = ((intptr_t)ptr) & 0xff; pwm_set_enabled(slice, false); + irq_set_enabled(PWM_IRQ_WRAP, false); + pwm_clear_irq(slice); } void common_hal_rgbmatrix_timer_free(void *ptr) { @@ -65,6 +68,8 @@ void common_hal_rgbmatrix_timer_free(void *ptr) { uint8_t slice = value & 0xff; uint8_t channel = value >> 8; pwm_set_enabled(slice, false); + irq_set_enabled(PWM_IRQ_WRAP, false); + pwm_clear_irq(slice); pwmout_free(slice, channel); return; } diff --git a/ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c b/ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c index 1105d357c5..1f15b010f7 100644 --- a/ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c +++ b/ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c @@ -85,6 +85,7 @@ void common_hal_rotaryio_incrementalencoder_construct(rotaryio_incrementalencode 3, 0, // in pulls NULL, 0, 0, 0x1f, // set pins NULL, 0, 0, 0x1f, // sideset pins + false, // No sideset enable NULL, // jump pin 0, // wait gpio pins true, // exclusive pin use diff --git a/ports/raspberrypi/common-hal/rp2pio/StateMachine.c b/ports/raspberrypi/common-hal/rp2pio/StateMachine.c index 4479006d4e..ac5a41652a 100644 --- a/ports/raspberrypi/common-hal/rp2pio/StateMachine.c +++ b/ports/raspberrypi/common-hal/rp2pio/StateMachine.c @@ -164,7 +164,8 @@ bool rp2pio_statemachine_construct(rp2pio_statemachine_obj_t *self, bool wait_for_txstall, bool auto_push, uint8_t push_threshold, bool in_shift_right, bool claim_pins, - bool user_interruptible + bool user_interruptible, + bool sideset_enable ) { // Create a program id that isn't the pointer so we can store it without storing the original object. uint32_t program_id = ~((uint32_t)program); @@ -278,7 +279,11 @@ bool rp2pio_statemachine_construct(rp2pio_statemachine_obj_t *self, sm_config_set_set_pins(&c, first_set_pin->number, set_pin_count); } if (first_sideset_pin != NULL) { - sm_config_set_sideset(&c, sideset_pin_count, false /* optional */, false /* pin direction */); + size_t total_sideset_bits = sideset_pin_count; + if (sideset_enable) { + total_sideset_bits += 1; + } + sm_config_set_sideset(&c, total_sideset_bits, sideset_enable, false /* pin direction */); sm_config_set_sideset_pins(&c, first_sideset_pin->number); } if (jmp_pin != NULL) { @@ -336,6 +341,7 @@ void common_hal_rp2pio_statemachine_construct(rp2pio_statemachine_obj_t *self, uint32_t pull_pin_up, uint32_t pull_pin_down, const mcu_pin_obj_t *first_set_pin, uint8_t set_pin_count, uint32_t initial_set_pin_state, uint32_t initial_set_pin_direction, const mcu_pin_obj_t *first_sideset_pin, uint8_t sideset_pin_count, uint32_t initial_sideset_pin_state, uint32_t initial_sideset_pin_direction, + bool sideset_enable, const mcu_pin_obj_t *jmp_pin, uint32_t wait_gpio_mask, bool exclusive_pin_use, @@ -503,7 +509,8 @@ void common_hal_rp2pio_statemachine_construct(rp2pio_statemachine_obj_t *self, wait_for_txstall, auto_push, push_threshold, in_shift_right, true /* claim pins */, - user_interruptible); + user_interruptible, + sideset_enable); if (!ok) { mp_raise_RuntimeError(translate("All state machines in use")); } @@ -513,7 +520,7 @@ void common_hal_rp2pio_statemachine_restart(rp2pio_statemachine_obj_t *self) { common_hal_rp2pio_statemachine_stop(self); // Reset program counter to the original offset. A JMP is 0x0000 plus // the desired offset, so we can just use self->offset. - pio_sm_exec(self->pio, self->state_machine,self->offset); + pio_sm_exec(self->pio, self->state_machine, self->offset); pio_sm_restart(self->pio, self->state_machine); uint8_t pio_index = pio_get_index(self->pio); uint32_t pins_we_use = _current_sm_pins[pio_index][self->state_machine]; diff --git a/ports/raspberrypi/common-hal/rp2pio/StateMachine.h b/ports/raspberrypi/common-hal/rp2pio/StateMachine.h index f877bdb152..125e0fa68b 100644 --- a/ports/raspberrypi/common-hal/rp2pio/StateMachine.h +++ b/ports/raspberrypi/common-hal/rp2pio/StateMachine.h @@ -75,7 +75,8 @@ bool rp2pio_statemachine_construct(rp2pio_statemachine_obj_t *self, bool wait_for_txstall, bool auto_push, uint8_t push_threshold, bool in_shift_right, bool claim_pins, - bool interruptible); + bool interruptible, + bool sideset_enable); uint8_t rp2pio_statemachine_program_offset(rp2pio_statemachine_obj_t *self); void rp2pio_statemachine_set_wrap(rp2pio_statemachine_obj_t *self, uint wrap_target, uint wrap); diff --git a/ports/raspberrypi/mpconfigport.mk b/ports/raspberrypi/mpconfigport.mk index bc8a26de7b..1dfb345f5d 100644 --- a/ports/raspberrypi/mpconfigport.mk +++ b/ports/raspberrypi/mpconfigport.mk @@ -1,19 +1,3 @@ -# Define an equivalent for MICROPY_LONGINT_IMPL, to pass to $(MPY-TOOL) in py/mkrules.mk -# $(MPY-TOOL) needs to know what kind of longint to use (if any) to freeze long integers. -# This should correspond to the MICROPY_LONGINT_IMPL definition in mpconfigport.h. - -ifeq ($(LONGINT_IMPL),NONE) -MPY_TOOL_LONGINT_IMPL = -mlongint-impl=none -endif - -ifeq ($(LONGINT_IMPL),MPZ) -MPY_TOOL_LONGINT_IMPL = -mlongint-impl=mpz -endif - -ifeq ($(LONGINT_IMPL),LONGLONG) -MPY_TOOL_LONGINT_IMPL = -mlongint-impl=longlong -endif - # All raspberrypi ports have longints. LONGINT_IMPL = MPZ diff --git a/ports/raspberrypi/sdk b/ports/raspberrypi/sdk index bfcbefafc5..2062372d20 160000 --- a/ports/raspberrypi/sdk +++ b/ports/raspberrypi/sdk @@ -1 +1 @@ -Subproject commit bfcbefafc5d2a210551a4d9d80b4303d4ae0adf7 +Subproject commit 2062372d203b372849d573f252cf7c6dc2800c0a diff --git a/ports/stm/Makefile b/ports/stm/Makefile index b5423b62c0..48b0000a65 100755 --- a/ports/stm/Makefile +++ b/ports/stm/Makefile @@ -60,7 +60,7 @@ CROSS_COMPILE = arm-none-eabi- MCU_SERIES_LOWER = $(shell echo $(MCU_SERIES) | tr '[:upper:]' '[:lower:]') MCU_VARIANT_LOWER = $(shell echo $(MCU_VARIANT) | tr '[:upper:]' '[:lower:]') -HAL_DIR=st_driver/STM32$(MCU_SERIES)xx_HAL_Driver +HAL_DIR=st_driver/stm32$(MCU_SERIES_LOWER)xx_hal_driver INC += -I. INC += -I../.. @@ -68,8 +68,8 @@ INC += -I$(BUILD) INC += -I$(BUILD)/genhdr INC += -I./$(HAL_DIR)/Inc INC += -I./$(HAL_DIR)/Inc/Legacy -INC += -I./st_driver/CMSIS/Device/ST/STM32$(MCU_SERIES)xx/Include -INC += -I./st_driver/CMSIS/Include +INC += -I./st_driver/cmsis_device_$(MCU_SERIES_LOWER)/Include +INC += -I./st_driver/CMSIS_5/CMSIS/Core/Include INC += -I./boards INC += -I./boards/$(BOARD) INC += -I./hal_conf @@ -242,7 +242,7 @@ endif SRC_S = \ supervisor/cpu.s \ - st_driver/CMSIS/Device/ST/STM32$(MCU_SERIES)xx/Source/Templates/gcc/startup_$(MCU_VARIANT_LOWER).s + st_driver/cmsis_device_$(MCU_SERIES_LOWER)/Source/Templates/gcc/startup_$(MCU_VARIANT_LOWER).s SRC_COMMON_HAL_EXPANDED = $(addprefix shared-bindings/, $(SRC_COMMON_HAL)) \ $(addprefix shared-bindings/, $(SRC_BINDINGS_ENUMS)) \ diff --git a/ports/stm/boards/espruino_pico/mpconfigboard.mk b/ports/stm/boards/espruino_pico/mpconfigboard.mk index a078b4841a..6e4da86dd7 100644 --- a/ports/stm/boards/espruino_pico/mpconfigboard.mk +++ b/ports/stm/boards/espruino_pico/mpconfigboard.mk @@ -20,6 +20,7 @@ LD_FILE = boards/STM32F401xd_fs.ld CIRCUITPY_AESIO = 0 CIRCUITPY_AUDIOCORE = 0 CIRCUITPY_AUDIOPWMIO = 0 +CIRCUITPY_BLEIO_HCI = 0 CIRCUITPY_BUSDEVICE = 0 CIRCUITPY_BITMAPTOOLS = 0 CIRCUITPY_FRAMEBUFFERIO = 0 diff --git a/ports/stm/boards/feather_stm32f405_express/pins.c b/ports/stm/boards/feather_stm32f405_express/pins.c index b039b0af0c..ade7036d5c 100644 --- a/ports/stm/boards/feather_stm32f405_express/pins.c +++ b/ports/stm/boards/feather_stm32f405_express/pins.c @@ -45,6 +45,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_PC00) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, diff --git a/ports/stm/boards/pyb_nano_v2/mpconfigboard.mk b/ports/stm/boards/pyb_nano_v2/mpconfigboard.mk index 29bfd62620..3ba45e0c5b 100644 --- a/ports/stm/boards/pyb_nano_v2/mpconfigboard.mk +++ b/ports/stm/boards/pyb_nano_v2/mpconfigboard.mk @@ -17,6 +17,7 @@ LD_FILE = boards/STM32F411_fs.ld CIRCUITPY_AUDIOCORE = 0 CIRCUITPY_AUDIOPWMIO = 0 CIRCUITPY_BITMAPTOOLS = 0 +CIRCUITPY_BLEIO_HCI = 0 CIRCUITPY_BUSDEVICE = 0 CIRCUITPY_GIFIO = 0 CIRCUITPY_KEYPAD = 0 diff --git a/ports/stm/boards/sparkfun_stm32_thing_plus/board.c b/ports/stm/boards/sparkfun_stm32_thing_plus/board.c new file mode 100644 index 0000000000..5fca974e9e --- /dev/null +++ b/ports/stm/boards/sparkfun_stm32_thing_plus/board.c @@ -0,0 +1,38 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "supervisor/board.h" +#include "mpconfigboard.h" + +void board_init(void) { +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { +} diff --git a/ports/stm/boards/sparkfun_stm32_thing_plus/mpconfigboard.h b/ports/stm/boards/sparkfun_stm32_thing_plus/mpconfigboard.h new file mode 100644 index 0000000000..b1412d9186 --- /dev/null +++ b/ports/stm/boards/sparkfun_stm32_thing_plus/mpconfigboard.h @@ -0,0 +1,58 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Lucian Copeland for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +// Micropython setup + +#define MICROPY_HW_BOARD_NAME "SparkFun Thing Plus - STM32" +#define MICROPY_HW_MCU_NAME "STM32F405RG" + +#define FLASH_SIZE (0x100000) +#define FLASH_PAGE_SIZE (0x4000) + +#define HSE_VALUE ((uint32_t)12000000U) +#define LSE_VALUE ((uint32_t)32768) +#define BOARD_HAS_LOW_SPEED_CRYSTAL (1) + +// On-board flash +#define SPI_FLASH_MOSI_PIN (&pin_PB05) +#define SPI_FLASH_MISO_PIN (&pin_PB04) +#define SPI_FLASH_SCK_PIN (&pin_PB03) +#define SPI_FLASH_CS_PIN (&pin_PA15) + +// Bootloader only +#ifdef UF2_BOOTLOADER_ENABLED + #define BOARD_VTOR_DEFER (1) // Leave VTOR relocation to bootloader +#endif + +#define DEFAULT_I2C_BUS_SCL (&pin_PB06) +#define DEFAULT_I2C_BUS_SDA (&pin_PB07) + +#define DEFAULT_SPI_BUS_SCK (&pin_PB13) +#define DEFAULT_SPI_BUS_MOSI (&pin_PB15) +#define DEFAULT_SPI_BUS_MISO (&pin_PB14) + +#define DEFAULT_UART_BUS_RX (&pin_PB11) +#define DEFAULT_UART_BUS_TX (&pin_PB10) diff --git a/ports/stm/boards/sparkfun_stm32_thing_plus/mpconfigboard.mk b/ports/stm/boards/sparkfun_stm32_thing_plus/mpconfigboard.mk new file mode 100644 index 0000000000..62d0136be5 --- /dev/null +++ b/ports/stm/boards/sparkfun_stm32_thing_plus/mpconfigboard.mk @@ -0,0 +1,21 @@ +USB_VID = 0X1B4F +USB_PID = 0x0028 + +USB_PRODUCT = "Thing Plus - STM32" +USB_MANUFACTURER = "SparkFun Electronics" + +SPI_FLASH_FILESYSTEM = 1 +EXTERNAL_FLASH_DEVICES = W25Q128JVxM + +MCU_SERIES = F4 +MCU_VARIANT = STM32F405xx +MCU_PACKAGE = LQFP64 + +LD_COMMON = boards/common_default.ld +LD_DEFAULT = boards/STM32F405_default.ld + +# UF2 boot option +LD_BOOT = boards/STM32F405_boot.ld +UF2_OFFSET = 0x8010000 + +CIRCUITPY_RGBMATRIX ?= 1 diff --git a/ports/stm/boards/sparkfun_stm32_thing_plus/pins.c b/ports/stm/boards/sparkfun_stm32_thing_plus/pins.c new file mode 100644 index 0000000000..df7040ce0a --- /dev/null +++ b/ports/stm/boards/sparkfun_stm32_thing_plus/pins.c @@ -0,0 +1,61 @@ +#include "py/objtuple.h" +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_obj_tuple_t sdio_data_tuple = { + {&mp_type_tuple}, + 4, + { + MP_ROM_PTR(&pin_PC08), + MP_ROM_PTR(&pin_PC09), + MP_ROM_PTR(&pin_PC10), + MP_ROM_PTR(&pin_PC11), + } +}; + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA04) }, + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PA05) }, + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PA06) }, + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PA07) }, + { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PC04) }, + { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_PC05) }, + + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_PC07) }, + { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PC06) }, + { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_PB08) }, + { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PB09) }, + { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_PC03) }, + { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_PC02) }, + + { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_PC01) }, + { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_PC01) }, + + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PB07) }, + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PB06) }, + + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PB13) }, + { MP_ROM_QSTR(MP_QSTR_CIPO), MP_ROM_PTR(&pin_PB14) }, + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PB14) }, + { MP_ROM_QSTR(MP_QSTR_COPI), MP_ROM_PTR(&pin_PB15) }, + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PB15) }, + + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PB10) }, + { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_PB10) }, + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PB11) }, + { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_PB11) }, + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, + + { MP_ROM_QSTR(MP_QSTR_SDIO_CLOCK), MP_ROM_PTR(&pin_PC12) }, + { MP_ROM_QSTR(MP_QSTR_SDIO_COMMAND), MP_ROM_PTR(&pin_PD02) }, + { MP_ROM_QSTR(MP_QSTR_SDIO_DATA), MP_ROM_PTR(&sdio_data_tuple) }, + + { MP_ROM_QSTR(MP_QSTR_CAN_RX), MP_ROM_PTR(&pin_PB08) }, + { MP_ROM_QSTR(MP_QSTR_CAN_TX), MP_ROM_PTR(&pin_PB09) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/stm/boards/stm32f411ve_discovery/mpconfigboard.mk b/ports/stm/boards/stm32f411ve_discovery/mpconfigboard.mk index 61e372b2c3..0929841ea5 100644 --- a/ports/stm/boards/stm32f411ve_discovery/mpconfigboard.mk +++ b/ports/stm/boards/stm32f411ve_discovery/mpconfigboard.mk @@ -15,8 +15,7 @@ LD_FILE = boards/STM32F411_fs.ld # Too big for the flash CIRCUITPY_AUDIOCORE = 0 CIRCUITPY_AUDIOPWMIO = 0 -CIRCUITPY_KEYPAD = 0 -CIRCUITPY_MIDI = 0 -CIRCUITPY_MSGPACK = 0 CIRCUITPY_BITMAPTOOLS = 0 +CIRCUITPY_BLEIO_HCI = 0 +CIRCUITPY_MSGPACK = 0 CIRCUITPY_VECTORIO = 0 diff --git a/ports/stm/common-hal/busio/I2C.c b/ports/stm/common-hal/busio/I2C.c index ffad368a2f..5ede538b12 100644 --- a/ports/stm/common-hal/busio/I2C.c +++ b/ports/stm/common-hal/busio/I2C.c @@ -246,7 +246,7 @@ void common_hal_busio_i2c_unlock(busio_i2c_obj_t *self) { self->has_lock = false; } -uint8_t common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t addr, +STATIC uint8_t _common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t addr, const uint8_t *data, size_t len, bool transmit_stop_bit) { HAL_StatusTypeDef result; if (!transmit_stop_bit) { @@ -271,6 +271,11 @@ uint8_t common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t addr, return result == HAL_OK ? 0 : MP_EIO; } +uint8_t common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t addr, + const uint8_t *data, size_t len) { + return _common_hal_busio_i2c_write(self, addr, data, len, true); +} + uint8_t common_hal_busio_i2c_read(busio_i2c_obj_t *self, uint16_t addr, uint8_t *data, size_t len) { if (!self->frame_in_prog) { @@ -288,6 +293,16 @@ uint8_t common_hal_busio_i2c_read(busio_i2c_obj_t *self, uint16_t addr, } } +uint8_t common_hal_busio_i2c_write_read(busio_i2c_obj_t *self, uint16_t addr, + uint8_t *out_data, size_t out_len, uint8_t *in_data, size_t in_len) { + uint8_t result = _common_hal_busio_i2c_write(self, addr, out_data, out_len, false); + if (result != 0) { + return result; + } + + return common_hal_busio_i2c_read(self, addr, in_data, in_len); +} + STATIC void i2c_clock_enable(uint8_t mask) { // Note: hard reset required due to soft reboot issue. #ifdef I2C1 diff --git a/ports/stm/common-hal/busio/SPI.c b/ports/stm/common-hal/busio/SPI.c index 77f2b53706..f7961f8cef 100644 --- a/ports/stm/common-hal/busio/SPI.c +++ b/ports/stm/common-hal/busio/SPI.c @@ -171,7 +171,7 @@ STATIC int check_pins(busio_spi_obj_t *self, void common_hal_busio_spi_construct(busio_spi_obj_t *self, const mcu_pin_obj_t *sck, const mcu_pin_obj_t *mosi, - const mcu_pin_obj_t *miso) { + const mcu_pin_obj_t *miso, bool half_duplex) { int periph_index = check_pins(self, sck, mosi, miso); SPI_TypeDef *SPIx = mcu_spi_banks[periph_index - 1]; @@ -209,7 +209,11 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self, self->handle.Instance = SPIx; self->handle.Init.Mode = SPI_MODE_MASTER; // Direction change only required for RX-only, see RefMan RM0090:884 - self->handle.Init.Direction = (self->mosi == NULL) ? SPI_DIRECTION_2LINES_RXONLY : SPI_DIRECTION_2LINES; + if (half_duplex) { + self->handle.Init.Direction = SPI_DIRECTION_1LINE; + } else { + self->handle.Init.Direction = (self->mosi == NULL) ? SPI_DIRECTION_2LINES_RXONLY : SPI_DIRECTION_2LINES; + } self->handle.Init.DataSize = SPI_DATASIZE_8BIT; self->handle.Init.CLKPolarity = SPI_POLARITY_LOW; self->handle.Init.CLKPhase = SPI_PHASE_1EDGE; @@ -224,6 +228,7 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self, } self->baudrate = (get_busclock(SPIx) / 16); self->prescaler = 16; + self->half_duplex = half_duplex; self->polarity = 0; self->phase = 0; self->bits = 8; @@ -250,7 +255,7 @@ void common_hal_busio_spi_never_reset(busio_spi_obj_t *self) { } bool common_hal_busio_spi_deinited(busio_spi_obj_t *self) { - return self->sck->pin == NULL; + return self->sck == NULL; } void common_hal_busio_spi_deinit(busio_spi_obj_t *self) { @@ -288,6 +293,15 @@ bool common_hal_busio_spi_configure(busio_spi_obj_t *self, self->handle.Init.CLKPolarity = (polarity) ? SPI_POLARITY_HIGH : SPI_POLARITY_LOW; self->handle.Init.CLKPhase = (phase) ? SPI_PHASE_2EDGE : SPI_PHASE_1EDGE; + // Set SCK pull up or down based on SPI CLK Polarity + GPIO_InitTypeDef GPIO_InitStruct = {0}; + GPIO_InitStruct.Pin = pin_mask(self->sck->pin->number); + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = (polarity) ? GPIO_PULLUP : GPIO_PULLDOWN; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = self->sck->altfn_index; + HAL_GPIO_Init(pin_port(self->sck->pin->port), &GPIO_InitStruct); + self->handle.Init.BaudRatePrescaler = stm32_baud_to_spi_div(baudrate, &self->prescaler, get_busclock(self->handle.Instance)); @@ -340,11 +354,13 @@ bool common_hal_busio_spi_write(busio_spi_obj_t *self, bool common_hal_busio_spi_read(busio_spi_obj_t *self, uint8_t *data, size_t len, uint8_t write_value) { - if (self->miso == NULL) { + if (self->miso == NULL && !self->half_duplex) { mp_raise_ValueError(translate("No MISO Pin")); + } else if (self->half_duplex && self->mosi == NULL) { + mp_raise_ValueError(translate("No MOSI Pin")); } HAL_StatusTypeDef result = HAL_OK; - if (self->mosi == NULL) { + if ((!self->half_duplex && self->mosi == NULL) || (self->half_duplex && self->mosi != NULL && self->miso == NULL)) { result = HAL_SPI_Receive(&self->handle, data, (uint16_t)len, HAL_MAX_DELAY); } else { memset(data, write_value, len); diff --git a/ports/stm/common-hal/busio/SPI.h b/ports/stm/common-hal/busio/SPI.h index 6483183678..17026bff77 100644 --- a/ports/stm/common-hal/busio/SPI.h +++ b/ports/stm/common-hal/busio/SPI.h @@ -44,6 +44,7 @@ typedef struct { const mcu_periph_obj_t *nss; uint32_t baudrate; uint16_t prescaler; + bool half_duplex; uint8_t polarity; uint8_t phase; uint8_t bits; diff --git a/ports/stm/common-hal/busio/UART.c b/ports/stm/common-hal/busio/UART.c index d8677126ef..7e35ad86dd 100644 --- a/ports/stm/common-hal/busio/UART.c +++ b/ports/stm/common-hal/busio/UART.c @@ -259,7 +259,7 @@ void common_hal_busio_uart_never_reset(busio_uart_obj_t *self) { } bool common_hal_busio_uart_deinited(busio_uart_obj_t *self) { - return self->tx->pin == NULL && self->rx->pin == NULL; + return self->tx == NULL && self->rx == NULL; } void common_hal_busio_uart_deinit(busio_uart_obj_t *self) { @@ -325,19 +325,22 @@ size_t common_hal_busio_uart_write(busio_uart_obj_t *self, const uint8_t *data, if (self->tx == NULL) { mp_raise_ValueError(translate("No TX pin")); } - bool write_err = false; // write error shouldn't disable interrupts + // Disable UART IRQ to avoid resource hazards in Rx IRQ handler HAL_NVIC_DisableIRQ(self->irq); - HAL_StatusTypeDef ret = HAL_UART_Transmit(&self->handle, (uint8_t *)data, len, HAL_MAX_DELAY); - if (ret != HAL_OK) { - write_err = true; - } - HAL_UART_Receive_IT(&self->handle, &self->rx_char, 1); + HAL_StatusTypeDef ret = HAL_UART_Transmit_IT(&self->handle, (uint8_t *)data, len); HAL_NVIC_EnableIRQ(self->irq); - if (write_err) { + if (HAL_OK == ret) { + HAL_UART_StateTypeDef Status = HAL_UART_GetState(&self->handle); + while ((Status & HAL_UART_STATE_BUSY_TX) == HAL_UART_STATE_BUSY_TX) { + RUN_BACKGROUND_TASKS; + Status = HAL_UART_GetState(&self->handle); + } + } else { mp_raise_ValueError(translate("UART write error")); } + return len; } @@ -359,6 +362,14 @@ void HAL_UART_RxCpltCallback(UART_HandleTypeDef *handle) { } } + #if (1) + // TODO: Implement error handling here + #else + while (HAL_BUSY == errflag) { + errflag = HAL_UART_Receive_IT(handle, &context->rx_char, 1); + } + #endif + return; } } @@ -436,6 +447,10 @@ STATIC void call_hal_irq(int uart_num) { if (context != NULL) { HAL_NVIC_ClearPendingIRQ(context->irq); HAL_UART_IRQHandler(&context->handle); + + if (HAL_UART_ERROR_NONE != context->handle.ErrorCode) { + // TODO: Implement error handling here + } } } diff --git a/ports/stm/mpconfigport.mk b/ports/stm/mpconfigport.mk index 6729a747b5..ba383d41d2 100644 --- a/ports/stm/mpconfigport.mk +++ b/ports/stm/mpconfigport.mk @@ -1,4 +1,3 @@ -MPY_TOOL_LONGINT_IMPL ?= -mlongint-impl=mpz LONGINT_IMPL ?= MPZ INTERNAL_LIBM ?= 1 diff --git a/ports/stm/st_driver b/ports/stm/st_driver deleted file mode 160000 index 1900834751..0000000000 --- a/ports/stm/st_driver +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 1900834751fd6754457874b8c971690bab33e0a7 diff --git a/ports/stm/st_driver/CMSIS_5 b/ports/stm/st_driver/CMSIS_5 new file mode 160000 index 0000000000..0b52176506 --- /dev/null +++ b/ports/stm/st_driver/CMSIS_5 @@ -0,0 +1 @@ +Subproject commit 0b521765067ac87b142cd96b5f578ffb399090cc diff --git a/ports/stm/st_driver/cmsis_device_f0 b/ports/stm/st_driver/cmsis_device_f0 new file mode 160000 index 0000000000..8b86197c7a --- /dev/null +++ b/ports/stm/st_driver/cmsis_device_f0 @@ -0,0 +1 @@ +Subproject commit 8b86197c7ab77ad029c34dc73cf6d4a1e12327d8 diff --git a/ports/stm/st_driver/cmsis_device_f1 b/ports/stm/st_driver/cmsis_device_f1 new file mode 160000 index 0000000000..71ad5b3bf5 --- /dev/null +++ b/ports/stm/st_driver/cmsis_device_f1 @@ -0,0 +1 @@ +Subproject commit 71ad5b3bf5cbb4d35cf8c8726c1b343871f0df0a diff --git a/ports/stm/st_driver/cmsis_device_f2 b/ports/stm/st_driver/cmsis_device_f2 new file mode 160000 index 0000000000..694c49f696 --- /dev/null +++ b/ports/stm/st_driver/cmsis_device_f2 @@ -0,0 +1 @@ +Subproject commit 694c49f696d359f57f23153ab7acf3ac1a43f663 diff --git a/ports/stm/st_driver/cmsis_device_f3 b/ports/stm/st_driver/cmsis_device_f3 new file mode 160000 index 0000000000..167eefd811 --- /dev/null +++ b/ports/stm/st_driver/cmsis_device_f3 @@ -0,0 +1 @@ +Subproject commit 167eefd811de90a58c41e0a32071cdfecede389a diff --git a/ports/stm/st_driver/cmsis_device_f4 b/ports/stm/st_driver/cmsis_device_f4 new file mode 160000 index 0000000000..6fe2c1f498 --- /dev/null +++ b/ports/stm/st_driver/cmsis_device_f4 @@ -0,0 +1 @@ +Subproject commit 6fe2c1f498feda34ee422720ff8b3bd1b4656145 diff --git a/ports/stm/st_driver/cmsis_device_f7 b/ports/stm/st_driver/cmsis_device_f7 new file mode 160000 index 0000000000..d29a89278d --- /dev/null +++ b/ports/stm/st_driver/cmsis_device_f7 @@ -0,0 +1 @@ +Subproject commit d29a89278dad0b89124c008be647f681d5253be4 diff --git a/ports/stm/st_driver/cmsis_device_g0 b/ports/stm/st_driver/cmsis_device_g0 new file mode 160000 index 0000000000..4daf765de5 --- /dev/null +++ b/ports/stm/st_driver/cmsis_device_g0 @@ -0,0 +1 @@ +Subproject commit 4daf765de5c5956df1bb27139e624b5deba270c9 diff --git a/ports/stm/st_driver/cmsis_device_g4 b/ports/stm/st_driver/cmsis_device_g4 new file mode 160000 index 0000000000..371d9ecec9 --- /dev/null +++ b/ports/stm/st_driver/cmsis_device_g4 @@ -0,0 +1 @@ +Subproject commit 371d9ecec9acc4d8b4baad36c8dc60cb9895baf7 diff --git a/ports/stm/st_driver/cmsis_device_h7 b/ports/stm/st_driver/cmsis_device_h7 new file mode 160000 index 0000000000..f5e3a1d5e7 --- /dev/null +++ b/ports/stm/st_driver/cmsis_device_h7 @@ -0,0 +1 @@ +Subproject commit f5e3a1d5e71e6b9278a6d580b7d5ca82c0debd9b diff --git a/ports/stm/st_driver/cmsis_device_l0 b/ports/stm/st_driver/cmsis_device_l0 new file mode 160000 index 0000000000..532d96973e --- /dev/null +++ b/ports/stm/st_driver/cmsis_device_l0 @@ -0,0 +1 @@ +Subproject commit 532d96973e7b2ae5546a2c88cb216429f74f5f5d diff --git a/ports/stm/st_driver/cmsis_device_l1 b/ports/stm/st_driver/cmsis_device_l1 new file mode 160000 index 0000000000..1827333a7f --- /dev/null +++ b/ports/stm/st_driver/cmsis_device_l1 @@ -0,0 +1 @@ +Subproject commit 1827333a7f7822282a6a46e4169596b5fb58cf61 diff --git a/ports/stm/st_driver/cmsis_device_l4 b/ports/stm/st_driver/cmsis_device_l4 new file mode 160000 index 0000000000..aae7f48733 --- /dev/null +++ b/ports/stm/st_driver/cmsis_device_l4 @@ -0,0 +1 @@ +Subproject commit aae7f4873380f77091ef62c461dc7a617b649d8e diff --git a/ports/stm/st_driver/cmsis_device_l5 b/ports/stm/st_driver/cmsis_device_l5 new file mode 160000 index 0000000000..fcf61cd086 --- /dev/null +++ b/ports/stm/st_driver/cmsis_device_l5 @@ -0,0 +1 @@ +Subproject commit fcf61cd086e02c7a1cf7535ffe30622d1f5d36aa diff --git a/ports/stm/st_driver/stm32f0xx_hal_driver b/ports/stm/st_driver/stm32f0xx_hal_driver new file mode 160000 index 0000000000..79307a2f62 --- /dev/null +++ b/ports/stm/st_driver/stm32f0xx_hal_driver @@ -0,0 +1 @@ +Subproject commit 79307a2f629b5959e67656564a8436e0a21e93d0 diff --git a/ports/stm/st_driver/stm32f1xx_hal_driver b/ports/stm/st_driver/stm32f1xx_hal_driver new file mode 160000 index 0000000000..fccac44e18 --- /dev/null +++ b/ports/stm/st_driver/stm32f1xx_hal_driver @@ -0,0 +1 @@ +Subproject commit fccac44e1859e1ad1a38353b46c9ed7587bdb4be diff --git a/ports/stm/st_driver/stm32f2xx_hal_driver b/ports/stm/st_driver/stm32f2xx_hal_driver new file mode 160000 index 0000000000..cc54dd7a90 --- /dev/null +++ b/ports/stm/st_driver/stm32f2xx_hal_driver @@ -0,0 +1 @@ +Subproject commit cc54dd7a903220618b0487970b087f4e34973d1d diff --git a/ports/stm/st_driver/stm32f3xx_hal_driver b/ports/stm/st_driver/stm32f3xx_hal_driver new file mode 160000 index 0000000000..58a240b306 --- /dev/null +++ b/ports/stm/st_driver/stm32f3xx_hal_driver @@ -0,0 +1 @@ +Subproject commit 58a240b30676cb51ee0e09347c6b55a9fc4f7140 diff --git a/ports/stm/st_driver/stm32f4xx_hal_driver b/ports/stm/st_driver/stm32f4xx_hal_driver new file mode 160000 index 0000000000..abb4cd6a27 --- /dev/null +++ b/ports/stm/st_driver/stm32f4xx_hal_driver @@ -0,0 +1 @@ +Subproject commit abb4cd6a27ce4b95dd76d262a13d0e2c688b1f10 diff --git a/ports/stm/st_driver/stm32f7xx_hal_driver b/ports/stm/st_driver/stm32f7xx_hal_driver new file mode 160000 index 0000000000..27458ea876 --- /dev/null +++ b/ports/stm/st_driver/stm32f7xx_hal_driver @@ -0,0 +1 @@ +Subproject commit 27458ea876aabd8fd568c5e2a8a3448f082e2817 diff --git a/ports/stm/st_driver/stm32g0xx_hal_driver b/ports/stm/st_driver/stm32g0xx_hal_driver new file mode 160000 index 0000000000..36ae439581 --- /dev/null +++ b/ports/stm/st_driver/stm32g0xx_hal_driver @@ -0,0 +1 @@ +Subproject commit 36ae43958161cff572db2f88378e81895ec3a337 diff --git a/ports/stm/st_driver/stm32g4xx_hal_driver b/ports/stm/st_driver/stm32g4xx_hal_driver new file mode 160000 index 0000000000..19bed7c9f8 --- /dev/null +++ b/ports/stm/st_driver/stm32g4xx_hal_driver @@ -0,0 +1 @@ +Subproject commit 19bed7c9f84aa74aba98c6d1ea54bed39bd8e61a diff --git a/ports/stm/st_driver/stm32h7xx_hal_driver b/ports/stm/st_driver/stm32h7xx_hal_driver new file mode 160000 index 0000000000..2bfa1cae79 --- /dev/null +++ b/ports/stm/st_driver/stm32h7xx_hal_driver @@ -0,0 +1 @@ +Subproject commit 2bfa1cae79926af47ff79a48757d29a38c9c8978 diff --git a/ports/stm/st_driver/stm32l0xx_hal_driver b/ports/stm/st_driver/stm32l0xx_hal_driver new file mode 160000 index 0000000000..ad9b9fbceb --- /dev/null +++ b/ports/stm/st_driver/stm32l0xx_hal_driver @@ -0,0 +1 @@ +Subproject commit ad9b9fbceb1427078000476dd4cd926603fd5b89 diff --git a/ports/stm/st_driver/stm32l1xx_hal_driver b/ports/stm/st_driver/stm32l1xx_hal_driver new file mode 160000 index 0000000000..919c1714f0 --- /dev/null +++ b/ports/stm/st_driver/stm32l1xx_hal_driver @@ -0,0 +1 @@ +Subproject commit 919c1714f0e605c96e312675d8a14c421881d2ec diff --git a/ports/stm/st_driver/stm32l4xx_hal_driver b/ports/stm/st_driver/stm32l4xx_hal_driver new file mode 160000 index 0000000000..49aacb861d --- /dev/null +++ b/ports/stm/st_driver/stm32l4xx_hal_driver @@ -0,0 +1 @@ +Subproject commit 49aacb861d9f2b4c43238989e7ba19d82c230641 diff --git a/ports/stm/st_driver/stm32l5xx_hal_driver b/ports/stm/st_driver/stm32l5xx_hal_driver new file mode 160000 index 0000000000..4f89168f73 --- /dev/null +++ b/ports/stm/st_driver/stm32l5xx_hal_driver @@ -0,0 +1 @@ +Subproject commit 4f89168f731596308eae3770a63518413f34cf3d diff --git a/ports/unix/Makefile b/ports/unix/Makefile index 344ebdb423..9857ec5f88 100644 --- a/ports/unix/Makefile +++ b/ports/unix/Makefile @@ -13,6 +13,9 @@ include ../../py/mkenv.mk -include mpconfigport.mk include $(VARIANT_DIR)/mpconfigvariant.mk +# Use the default frozen manifest, variants may override this. +FROZEN_MANIFEST ?= variants/manifest.py + # This should be configured by the mpconfigvariant.mk PROG ?= micropython @@ -39,7 +42,7 @@ CFLAGS += $(INC) $(CWARN) -std=gnu99 -DUNIX $(CFLAGS_MOD) $(COPT) -I$(VARIANT_DI # Debugging/Optimization ifdef DEBUG -COPT ?= -O0 +COPT ?= -Og else COPT ?= -Os COPT += -DNDEBUG @@ -256,12 +259,14 @@ SRC_QSTR += $(SRC_C) $(SRC_CXX) $(SHARED_SRC_C) $(EXTMOD_SRC_C) # SRC_QSTR SRC_QSTR_AUTO_DEPS += -ifneq ($(FROZEN_MPY_DIR),) +ifneq ($(FROZEN_MANIFEST),) +# To use frozen code create a manifest.py file with a description of files to +# freeze, then invoke make with FROZEN_MANIFEST=manifest.py (be sure to build from scratch). CFLAGS += -DMICROPY_QSTR_EXTRA_POOL=mp_qstr_frozen_const_pool CFLAGS += -DMICROPY_MODULE_FROZEN_MPY CFLAGS += -DMICROPY_MODULE_FROZEN_STR CFLAGS += -DMPZ_DIG_SIZE=16 # force 16 bits to work on both 32 and 64 bit archs -MPY_CROSS_FLAGS += -mcache-lookup-bc +CFLAGS += -DMICROPY_MODULE_FROZEN_STR endif HASCPP17 = $(shell expr `$(CC) -dumpversion | cut -f1 -d.` \>= 7) @@ -273,9 +278,7 @@ endif CXXFLAGS += $(filter-out -Wmissing-prototypes -Wold-style-definition -std=gnu99 -std=gnu11,$(CFLAGS) $(CXXFLAGS_MOD)) ifeq ($(MICROPY_FORCE_32BIT),1) -RUN_TESTS_MPY_CROSS_FLAGS = --mpy-cross-flags='-mcache-lookup-bc -march=x86' -else -RUN_TESTS_MPY_CROSS_FLAGS = --mpy-cross-flags='-mcache-lookup-bc' +RUN_TESTS_MPY_CROSS_FLAGS = --mpy-cross-flags='-march=x86' endif ifeq ($(CROSS_COMPILE),arm-linux-gnueabi-) diff --git a/ports/unix/coverage.c b/ports/unix/coverage.c index cdab9b8ef4..179181dc83 100644 --- a/ports/unix/coverage.c +++ b/ports/unix/coverage.c @@ -161,7 +161,7 @@ STATIC void pairheap_test(size_t nops, int *ops) { mp_pairheap_init_node(pairheap_lt, &node[i]); } mp_pairheap_t *heap = mp_pairheap_new(pairheap_lt); - printf("create:"); + mp_printf(&mp_plat_print, "create:"); for (size_t i = 0; i < nops; ++i) { if (ops[i] >= 0) { heap = mp_pairheap_push(pairheap_lt, heap, &node[ops[i]]); @@ -175,13 +175,13 @@ STATIC void pairheap_test(size_t nops, int *ops) { ; } } - printf("\npop all:"); + mp_printf(&mp_plat_print, "\npop all:"); while (!mp_pairheap_is_empty(pairheap_lt, heap)) { mp_printf(&mp_plat_print, " %d", mp_pairheap_peek(pairheap_lt, heap) - &node[0]); ; heap = mp_pairheap_pop(pairheap_lt, heap); } - printf("\n"); + mp_printf(&mp_plat_print, "\n"); } // function to run extra tests for things that can't be checked by scripts @@ -527,7 +527,8 @@ STATIC mp_obj_t extra_coverage(void) { // ringbuf { byte buf[100]; - ringbuf_t ringbuf = {buf, sizeof(buf), 0, 0}; + ringbuf_t ringbuf; + ringbuf_init(&ringbuf, &buf[0], sizeof(buf)); mp_printf(&mp_plat_print, "# ringbuf\n"); diff --git a/ports/unix/main.c b/ports/unix/main.c index c1cf6a7ffa..5ebcf9193b 100644 --- a/ports/unix/main.c +++ b/ports/unix/main.c @@ -494,16 +494,10 @@ MP_NOINLINE int main_(int argc, char **argv) { char *home = getenv("HOME"); char *path = getenv("MICROPYPATH"); if (path == NULL) { - #ifdef MICROPY_PY_SYS_PATH_DEFAULT path = MICROPY_PY_SYS_PATH_DEFAULT; - #else - path = "~/.micropython/lib:/usr/lib/micropython"; - #endif } - size_t path_num = 2; // [0] is for current dir (or base dir of the script) - // [1] is for frozen files. - size_t builtin_path_count = path_num; - if (*path == ':') { + size_t path_num = 1; // [0] is for current dir (or base dir of the script) + if (*path == PATHLIST_SEP_CHAR) { path_num++; } for (char *p = path; p != NULL; p = strchr(p, PATHLIST_SEP_CHAR)) { @@ -516,11 +510,9 @@ MP_NOINLINE int main_(int argc, char **argv) { mp_obj_t *path_items; mp_obj_list_get(mp_sys_path, &path_num, &path_items); path_items[0] = MP_OBJ_NEW_QSTR(MP_QSTR_); - // Frozen modules are in their own pseudo-dir, e.g., ".frozen". - path_items[1] = MP_OBJ_NEW_QSTR(MP_FROZEN_FAKE_DIR_QSTR); { char *p = path; - for (mp_uint_t i = builtin_path_count; i < path_num; i++) { + for (mp_uint_t i = 1; i < path_num; i++) { char *p1 = strchr(p, PATHLIST_SEP_CHAR); if (p1 == NULL) { p1 = p + strlen(p); @@ -661,7 +653,7 @@ MP_NOINLINE int main_(int argc, char **argv) { break; } - // Set base dir of the script as first entry in sys.path + // Set base dir of the script as first entry in sys.path. char *p = strrchr(basedir, '/'); path_items[0] = mp_obj_new_str_via_qstr(basedir, p - basedir); free(pathbuf); diff --git a/ports/unix/modos.c b/ports/unix/modos.c index c7386180ae..6241dfa6c3 100644 --- a/ports/unix/modos.c +++ b/ports/unix/modos.c @@ -27,6 +27,7 @@ #include #include +#include #include #include #include @@ -48,6 +49,29 @@ #define USE_STATFS 1 #endif +#if defined(__GLIBC__) && defined(__GLIBC_PREREQ) +#if __GLIBC_PREREQ(2, 25) +#include +#define _HAVE_GETRANDOM +#endif +#endif + +STATIC mp_obj_t mod_os_urandom(mp_obj_t num) { + mp_int_t n = mp_obj_get_int(num); + vstr_t vstr; + vstr_init_len(&vstr, n); + #ifdef _HAVE_GETRANDOM + RAISE_ERRNO(getrandom(vstr.buf, n, 0), errno); + #else + int fd = open("/dev/urandom", O_RDONLY); + RAISE_ERRNO(fd, errno); + RAISE_ERRNO(read(fd, vstr.buf, n), errno); + close(fd); + #endif + return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_os_urandom_obj, mod_os_urandom); + STATIC mp_obj_t mod_os_stat(mp_obj_t path_in) { struct stat sb; const char *path = mp_obj_str_get_str(path_in); @@ -308,6 +332,7 @@ STATIC const mp_rom_map_elem_t mp_module_os_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_uos) }, { MP_ROM_QSTR(MP_QSTR_errno), MP_ROM_PTR(&mod_os_errno_obj) }, { MP_ROM_QSTR(MP_QSTR_stat), MP_ROM_PTR(&mod_os_stat_obj) }, + { MP_ROM_QSTR(MP_QSTR_urandom), MP_ROM_PTR(&mod_os_urandom_obj) }, #if MICROPY_PY_OS_STATVFS { MP_ROM_QSTR(MP_QSTR_statvfs), MP_ROM_PTR(&mod_os_statvfs_obj) }, #endif diff --git a/ports/unix/mpconfigport.h b/ports/unix/mpconfigport.h index da3c71d776..c54fede813 100644 --- a/ports/unix/mpconfigport.h +++ b/ports/unix/mpconfigport.h @@ -80,10 +80,14 @@ #endif #define MICROPY_STREAMS_POSIX_API (1) #define MICROPY_OPT_COMPUTED_GOTO (1) -#ifndef MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE -#define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE (1) +#ifndef MICROPY_OPT_LOAD_ATTR_FAST_PATH +#define MICROPY_OPT_LOAD_ATTR_FAST_PATH (1) +#endif +#ifndef MICROPY_OPT_MAP_LOOKUP_CACHE +#define MICROPY_OPT_MAP_LOOKUP_CACHE (1) #endif #define MICROPY_MODULE_WEAK_LINKS (1) +#define MICROPY_MODULE_OVERRIDE_MAIN_IMPORT (1) #define MICROPY_CAN_OVERRIDE_BUILTINS (1) #define MICROPY_VFS_POSIX_FILE (1) #define MICROPY_PY_FUNCTION_ATTRS (1) @@ -107,6 +111,8 @@ #define MICROPY_PY_ARRAY_SLICE_ASSIGN (1) #define MICROPY_PY_BUILTINS_SLICE_ATTRS (1) #define MICROPY_PY_BUILTINS_SLICE_INDICES (1) +#define MICROPY_PY_SYS_ATEXIT (1) +#define MICROPY_PY_SYS_PATH_ARGV_DEFAULTS (0) #define MICROPY_PY_SYS_EXIT (1) #if MICROPY_PY_SYS_SETTRACE #define MICROPY_PERSISTENT_CODE_SAVE (1) @@ -119,6 +125,9 @@ #define MICROPY_PY_SYS_PLATFORM "linux" #endif #endif +#ifndef MICROPY_PY_SYS_PATH_DEFAULT +#define MICROPY_PY_SYS_PATH_DEFAULT ".frozen:~/.micropython/lib:/usr/lib/micropython" +#endif #define MICROPY_PY_SYS_MAXSIZE (1) #define MICROPY_PY_SYS_STDFILES (1) #define MICROPY_PY_SYS_EXC_INFO (1) diff --git a/ports/unix/variants/coverage/mpconfigvariant.h b/ports/unix/variants/coverage/mpconfigvariant.h index 2ad0d94bc0..f6ebc2087b 100644 --- a/ports/unix/variants/coverage/mpconfigvariant.h +++ b/ports/unix/variants/coverage/mpconfigvariant.h @@ -51,7 +51,6 @@ #define MICROPY_PY_MATH_FACTORIAL (1) #define MICROPY_PY_URANDOM_EXTRA_FUNCS (1) #define MICROPY_PY_IO_BUFFEREDWRITER (1) -#define MICROPY_PY_IO_RESOURCE_STREAM (1) #define MICROPY_PY_UASYNCIO (1) #define MICROPY_PY_URE_DEBUG (1) #define MICROPY_PY_URE_MATCH_GROUPS (1) diff --git a/ports/unix/variants/coverage/mpconfigvariant.mk b/ports/unix/variants/coverage/mpconfigvariant.mk index 7e8aabef5b..59f443e760 100644 --- a/ports/unix/variants/coverage/mpconfigvariant.mk +++ b/ports/unix/variants/coverage/mpconfigvariant.mk @@ -12,15 +12,13 @@ CFLAGS += \ LDFLAGS += -fprofile-arcs -ftest-coverage +FROZEN_MANIFEST ?= $(VARIANT_DIR)/manifest.py USER_C_MODULES = $(TOP)/examples/usercmodule MICROPY_VFS_FAT = 1 MICROPY_VFS_LFS1 = 1 MICROPY_VFS_LFS2 = 1 -FROZEN_DIR=variants/coverage/frzstr -FROZEN_MPY_DIR=variants/coverage/frzmpy - SRC_QRIO := $(patsubst ../../%,%,$(wildcard ../../shared-bindings/qrio/*.c ../../shared-module/qrio/*.c ../../lib/quirc/lib/*.c)) SRC_C += $(SRC_QRIO) diff --git a/ports/unix/variants/minimal/mpconfigvariant.h b/ports/unix/variants/minimal/mpconfigvariant.h index a959a95059..09dc37d1c3 100644 --- a/ports/unix/variants/minimal/mpconfigvariant.h +++ b/ports/unix/variants/minimal/mpconfigvariant.h @@ -55,7 +55,8 @@ #define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_NONE) #define MICROPY_STREAMS_NON_BLOCK (0) #define MICROPY_OPT_COMPUTED_GOTO (0) -#define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE (0) +#define MICROPY_OPT_LOAD_ATTR_FAST_PATH (0) +#define MICROPY_OPT_MAP_LOOKUP_CACHE (0) #define MICROPY_CAN_OVERRIDE_BUILTINS (0) #define MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG (0) #define MICROPY_CPYTHON_COMPAT (0) @@ -87,6 +88,9 @@ #define MICROPY_PY_SYS (1) #define MICROPY_PY_SYS_EXIT (0) #define MICROPY_PY_SYS_PLATFORM "linux" +#ifndef MICROPY_PY_SYS_PATH_DEFAULT +#define MICROPY_PY_SYS_PATH_DEFAULT ".frozen:~/.micropython/lib:/usr/lib/micropython" +#endif #define MICROPY_PY_SYS_MAXSIZE (0) #define MICROPY_PY_SYS_STDFILES (0) #define MICROPY_PY_CMATH (0) diff --git a/py/bc.c b/py/bc.c index ccf503631d..33b94c4a9f 100644 --- a/py/bc.c +++ b/py/bc.c @@ -314,24 +314,10 @@ void mp_setup_code_state(mp_code_state_t *code_state, size_t n_args, size_t n_kw // The following table encodes the number of bytes that a specific opcode // takes up. Some opcodes have an extra byte, defined by MP_BC_MASK_EXTRA_BYTE. -// There are 4 special opcodes that have an extra byte only when -// MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE is enabled (and they take a qstr): -// MP_BC_LOAD_NAME -// MP_BC_LOAD_GLOBAL -// MP_BC_LOAD_ATTR -// MP_BC_STORE_ATTR uint mp_opcode_format(const byte *ip, size_t *opcode_size, bool count_var_uint) { uint f = MP_BC_FORMAT(*ip); const byte *ip_start = ip; if (f == MP_BC_FORMAT_QSTR) { - if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE_DYNAMIC) { - if (*ip == MP_BC_LOAD_NAME - || *ip == MP_BC_LOAD_GLOBAL - || *ip == MP_BC_LOAD_ATTR - || *ip == MP_BC_STORE_ATTR) { - ip += 1; - } - } ip += 3; } else { int extra_byte = (*ip & MP_BC_MASK_EXTRA_BYTE) == 0; diff --git a/py/builtin.h b/py/builtin.h index 2c0437d403..4fa4b08f9d 100644 --- a/py/builtin.h +++ b/py/builtin.h @@ -119,13 +119,8 @@ extern const mp_obj_module_t mp_module_utimeq; extern const mp_obj_module_t mp_module_machine; extern const mp_obj_module_t mp_module_framebuf; extern const mp_obj_module_t mp_module_btree; -extern const mp_obj_module_t ulab_user_cmodule; -extern mp_obj_module_t ulab_fft_module; -extern mp_obj_module_t ulab_filter_module; -extern mp_obj_module_t ulab_linalg_module; -extern mp_obj_module_t ulab_numerical_module; -extern mp_obj_module_t ulab_poly_module; - +extern const mp_obj_module_t mp_module_ubluetooth; +extern const mp_obj_module_t mp_module_uplatform; extern const char MICROPY_PY_BUILTINS_HELP_TEXT[]; diff --git a/py/builtinhelp.c b/py/builtinhelp.c index fc32de5abe..7411c57aae 100644 --- a/py/builtinhelp.c +++ b/py/builtinhelp.c @@ -69,22 +69,18 @@ STATIC void mp_help_add_from_map(mp_obj_t list, const mp_map_t *map) { #if MICROPY_MODULE_FROZEN STATIC void mp_help_add_from_names(mp_obj_t list, const char *name) { while (*name) { - size_t l = strlen(name); + size_t len = strlen(name); // name should end in '.py' and we strip it off - mp_obj_list_append(list, mp_obj_new_str(name, l - 3)); - name += l + 1; + mp_obj_list_append(list, mp_obj_new_str(name, len - 3)); + name += len + 1; } } #endif // These externs were originally declared inside mp_help_print_modules(), // but they triggered -Wnested-externs, so they were moved outside. -#if MICROPY_MODULE_FROZEN_STR -extern const char mp_frozen_str_names[]; -#endif - -#if MICROPY_MODULE_FROZEN_MPY -extern const char mp_frozen_mpy_names[]; +#if MICROPY_MODULE_FROZEN +extern const char mp_frozen_names[]; #endif STATIC void mp_help_print_modules(void) { @@ -92,12 +88,8 @@ STATIC void mp_help_print_modules(void) { mp_help_add_from_map(list, &mp_builtin_module_map); - #if MICROPY_MODULE_FROZEN_STR - mp_help_add_from_names(list, mp_frozen_str_names); - #endif - - #if MICROPY_MODULE_FROZEN_MPY - mp_help_add_from_names(list, mp_frozen_mpy_names); + #if MICROPY_MODULE_FROZEN + mp_help_add_from_names(list, mp_frozen_names); #endif // sort the list so it's printed in alphabetical order diff --git a/py/builtinimport.c b/py/builtinimport.c index ca4b848407..dbacc3d657 100644 --- a/py/builtinimport.c +++ b/py/builtinimport.c @@ -5,6 +5,7 @@ * * SPDX-FileCopyrightText: Copyright (c) 2013-2019 Damien P. George * Copyright (c) 2014 Paul Sokolovsky + * Copyright (c) 2021 Jim Mussared * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -50,7 +51,11 @@ #if MICROPY_ENABLE_EXTERNAL_IMPORT -#define PATH_SEP_CHAR '/' +// Must be a string of one byte. +#define PATH_SEP_CHAR "/" + +// Virtual sys.path entry that maps to the frozen modules. +#define MP_FROZEN_PATH_PREFIX ".frozen/" bool mp_obj_is_package(mp_obj_t module) { mp_obj_t dest[2]; @@ -58,31 +63,33 @@ bool mp_obj_is_package(mp_obj_t module) { return dest[0] != MP_OBJ_NULL; } -// Stat either frozen or normal module by a given path -// (whatever is available, if at all). -STATIC mp_import_stat_t mp_import_stat_any(const char *path) { +// Wrapper for mp_import_stat (which is provided by the port, and typically +// uses mp_vfs_import_stat) to also search frozen modules. Given an exact +// path to a file or directory (e.g. "foo/bar", foo/bar.py" or "foo/bar.mpy"), +// will return whether the path is a file, directory, or doesn't exist. +STATIC mp_import_stat_t stat_path_or_frozen(const char *path) { #if MICROPY_MODULE_FROZEN - if (strncmp(MP_FROZEN_FAKE_DIR_SLASH, - path, - MP_FROZEN_FAKE_DIR_SLASH_LENGTH) == 0) { - mp_import_stat_t st = mp_frozen_stat(path + MP_FROZEN_FAKE_DIR_SLASH_LENGTH); - if (st != MP_IMPORT_STAT_NO_EXIST) { - return st; - } + // Only try and load as a frozen module if it starts with .frozen/. + const int frozen_path_prefix_len = strlen(MP_FROZEN_PATH_PREFIX); + if (strncmp(path, MP_FROZEN_PATH_PREFIX, frozen_path_prefix_len) == 0) { + return mp_find_frozen_module(path + frozen_path_prefix_len, NULL, NULL); } #endif return mp_import_stat(path); } +// Given a path to a .py file, try and find this path as either a .py or .mpy +// in either the filesystem or frozen modules. STATIC mp_import_stat_t stat_file_py_or_mpy(vstr_t *path) { - mp_import_stat_t stat = mp_import_stat_any(vstr_null_terminated_str(path)); + mp_import_stat_t stat = stat_path_or_frozen(vstr_null_terminated_str(path)); if (stat == MP_IMPORT_STAT_FILE) { return stat; } #if MICROPY_PERSISTENT_CODE_LOAD + // Didn't find .py -- try the .mpy instead by inserting an 'm' into the '.py'. vstr_ins_byte(path, path->len - 2, 'm'); - stat = mp_import_stat_any(vstr_null_terminated_str(path)); + stat = stat_path_or_frozen(vstr_null_terminated_str(path)); if (stat == MP_IMPORT_STAT_FILE) { return stat; } @@ -91,8 +98,10 @@ STATIC mp_import_stat_t stat_file_py_or_mpy(vstr_t *path) { return MP_IMPORT_STAT_NO_EXIST; } +// Given an import path (e.g. "foo/bar"), try and find "foo/bar" (a directory) +// or "foo/bar.(m)py" in either the filesystem or frozen modules. STATIC mp_import_stat_t stat_dir_or_file(vstr_t *path) { - mp_import_stat_t stat = mp_import_stat_any(vstr_null_terminated_str(path)); + mp_import_stat_t stat = stat_path_or_frozen(vstr_null_terminated_str(path)); DEBUG_printf("stat %s: %d\n", vstr_str(path), stat); if (stat == MP_IMPORT_STAT_DIR) { return stat; @@ -103,40 +112,41 @@ STATIC mp_import_stat_t stat_dir_or_file(vstr_t *path) { return stat_file_py_or_mpy(path); } -STATIC mp_import_stat_t find_file(const char *file_str, uint file_len, vstr_t *dest) { +// Given a top-level module, try and find it in each of the sys.path entries +// via stat_dir_or_file. +STATIC mp_import_stat_t stat_top_level_dir_or_file(qstr mod_name, vstr_t *dest) { + DEBUG_printf("stat_top_level_dir_or_file: '%s'\n", qstr_str(mod_name)); #if MICROPY_PY_SYS - // extract the list of paths size_t path_num; mp_obj_t *path_items; mp_obj_list_get(mp_sys_path, &path_num, &path_items); - if (path_num == 0) { - #endif - // mp_sys_path is empty, so just use the given file name - vstr_add_strn(dest, file_str, file_len); - return stat_dir_or_file(dest); - #if MICROPY_PY_SYS -} else { - // go through each path looking for a directory or file - for (size_t i = 0; i < path_num; i++) { - vstr_reset(dest); - size_t p_len; - const char *p = mp_obj_str_get_data(path_items[i], &p_len); - if (p_len > 0) { - vstr_add_strn(dest, p, p_len); - vstr_add_char(dest, PATH_SEP_CHAR); + if (path_num > 0) { + // go through each path looking for a directory or file + for (size_t i = 0; i < path_num; i++) { + vstr_reset(dest); + size_t p_len; + const char *p = mp_obj_str_get_data(path_items[i], &p_len); + if (p_len > 0) { + vstr_add_strn(dest, p, p_len); + vstr_add_char(dest, PATH_SEP_CHAR[0]); + } + vstr_add_str(dest, qstr_str(mod_name)); + mp_import_stat_t stat = stat_dir_or_file(dest); + if (stat != MP_IMPORT_STAT_NO_EXIST) { + return stat; + } } - vstr_add_strn(dest, file_str, file_len); - mp_import_stat_t stat = stat_dir_or_file(dest); - if (stat != MP_IMPORT_STAT_NO_EXIST) { - return stat; - } - } - // could not find a directory or file - return MP_IMPORT_STAT_NO_EXIST; -} + // could not find a directory or file + return MP_IMPORT_STAT_NO_EXIST; + } #endif + + // mp_sys_path is empty (or not enabled), so just stat the given path + // directly. + vstr_add_str(dest, qstr_str(mod_name)); + return stat_dir_or_file(dest); } #if MICROPY_MODULE_FROZEN_STR || MICROPY_ENABLE_COMPILER @@ -193,19 +203,17 @@ STATIC void do_execute_raw_code(mp_obj_t module_obj, mp_raw_code_t *raw_code, co STATIC void do_load(mp_obj_t module_obj, vstr_t *file) { #if MICROPY_MODULE_FROZEN || MICROPY_ENABLE_COMPILER || (MICROPY_PERSISTENT_CODE_LOAD && MICROPY_HAS_FILE_READER) - char *file_str = vstr_null_terminated_str(file); + const char *file_str = vstr_null_terminated_str(file); #endif - #if MICROPY_MODULE_FROZEN || MICROPY_MODULE_FROZEN_MPY - if (strncmp(MP_FROZEN_FAKE_DIR_SLASH, - file_str, - MP_FROZEN_FAKE_DIR_SLASH_LENGTH) == 0) { - // If we support frozen modules (either as str or mpy) then try to find the - // requested filename in the list of frozen module filenames. - #if MICROPY_MODULE_FROZEN - void *modref; - int frozen_type = mp_find_frozen_module(file_str + MP_FROZEN_FAKE_DIR_SLASH_LENGTH, file->len - MP_FROZEN_FAKE_DIR_SLASH_LENGTH, &modref); - #endif + // If we support frozen modules (either as str or mpy) then try to find the + // requested filename in the list of frozen module filenames. + #if MICROPY_MODULE_FROZEN + void *modref; + int frozen_type; + const int frozen_path_prefix_len = strlen(MP_FROZEN_PATH_PREFIX); + if (strncmp(file_str, MP_FROZEN_PATH_PREFIX, frozen_path_prefix_len) == 0) { + mp_find_frozen_module(file_str + frozen_path_prefix_len, &frozen_type, &modref); // If we support frozen str modules and the compiler is enabled, and we // found the filename in the list of frozen files, then load and execute it. @@ -220,13 +228,12 @@ STATIC void do_load(mp_obj_t module_obj, vstr_t *file) { // its data) in the list of frozen files, execute it. #if MICROPY_MODULE_FROZEN_MPY if (frozen_type == MP_FROZEN_MPY) { - do_execute_raw_code(module_obj, modref, file_str); + do_execute_raw_code(module_obj, modref, file_str + frozen_path_prefix_len); return; } #endif - } - #endif // MICROPY_MODULE_FROZEN || MICROPY_MODULE_FROZEN_MPY + #endif // MICROPY_MODULE_FROZEN // If we support loading .mpy files then check if the file extension is of // the correct format and, if so, load and execute the file. @@ -251,15 +258,212 @@ STATIC void do_load(mp_obj_t module_obj, vstr_t *file) { #endif } -STATIC void chop_component(const char *start, const char **end) { - const char *p = *end; - while (p > start) { +// Convert a relative (to the current module) import, going up "level" levels, +// into an absolute import. +STATIC void evaluate_relative_import(mp_int_t level, const char **module_name, size_t *module_name_len) { + // What we want to do here is to take the name of the current module, + // remove trailing components, and concatenate the passed-in + // module name. + // For example, level=3, module_name="foo.bar", __name__="a.b.c.d" --> "a.foo.bar" + // "Relative imports use a module's __name__ attribute to determine that + // module's position in the package hierarchy." + // http://legacy.python.org/dev/peps/pep-0328/#relative-imports-and-name + + mp_obj_t current_module_name_obj = mp_obj_dict_get(MP_OBJ_FROM_PTR(mp_globals_get()), MP_OBJ_NEW_QSTR(MP_QSTR___name__)); + assert(current_module_name_obj != MP_OBJ_NULL); + + #if MICROPY_MODULE_OVERRIDE_MAIN_IMPORT && MICROPY_CPYTHON_COMPAT + if (MP_OBJ_QSTR_VALUE(current_module_name_obj) == MP_QSTR___main__) { + // This is a module loaded by -m command-line switch (e.g. unix port), + // and so its __name__ has been set to "__main__". Get its real name + // that we stored during import in the __main__ attribute. + current_module_name_obj = mp_obj_dict_get(MP_OBJ_FROM_PTR(mp_globals_get()), MP_OBJ_NEW_QSTR(MP_QSTR___main__)); + } + #endif + + // If we have a __path__ in the globals dict, then we're a package. + bool is_pkg = mp_map_lookup(&mp_globals_get()->map, MP_OBJ_NEW_QSTR(MP_QSTR___path__), MP_MAP_LOOKUP); + + #if DEBUG_PRINT + DEBUG_printf("Current module/package: "); + mp_obj_print_helper(MICROPY_DEBUG_PRINTER, current_module_name_obj, PRINT_REPR); + DEBUG_printf(", is_package: %d", is_pkg); + DEBUG_printf("\n"); + #endif + + size_t current_module_name_len; + const char *current_module_name = mp_obj_str_get_data(current_module_name_obj, ¤t_module_name_len); + + const char *p = current_module_name + current_module_name_len; + if (is_pkg) { + // If we're evaluating relative to a package, then take off one fewer + // level (i.e. the relative search starts inside the package, rather + // than as a sibling of the package). + --level; + } + + // Walk back 'level' dots (or run out of path). + while (level && p > current_module_name) { if (*--p == '.') { - *end = p; - return; + --level; } } - *end = p; + + // We must have some component left over to import from. + if (p == current_module_name) { + mp_raise_msg(&mp_type_ImportError, MP_ERROR_TEXT("can't perform relative import")); + } + + // New length is len("."). Note: might be one byte + // more than we need if module_name is empty (for the extra . we will + // append). + uint new_module_name_len = (size_t)(p - current_module_name) + 1 + *module_name_len; + char *new_mod = mp_local_alloc(new_module_name_len); + memcpy(new_mod, current_module_name, p - current_module_name); + + // Only append "." if there was one). + if (*module_name_len != 0) { + new_mod[p - current_module_name] = '.'; + memcpy(new_mod + (p - current_module_name) + 1, *module_name, *module_name_len); + } else { + --new_module_name_len; + } + + // Copy into a QSTR. + qstr new_mod_q = qstr_from_strn(new_mod, new_module_name_len); + mp_local_free(new_mod); + + DEBUG_printf("Resolved base name for relative import: '%s'\n", qstr_str(new_mod_q)); + *module_name = qstr_str(new_mod_q); + *module_name_len = new_module_name_len; +} + +// Load a module at the specified absolute path, possibly as a submodule of the given outer module. +// full_mod_name: The full absolute path to this module (e.g. "foo.bar.baz"). +// level_mod_name: The final component of the path (e.g. "baz"). +// outer_module_obj: The parent module (we need to store this module as an +// attribute on it) (or MP_OBJ_NULL for top-level). +// path: The filesystem path where we found the parent module +// (or empty for a top level module). +// override_main: Whether to set the __name__ to "__main__" (and use __main__ +// for the actual path). +STATIC mp_obj_t process_import_at_level(qstr full_mod_name, qstr level_mod_name, mp_obj_t outer_module_obj, vstr_t *path, bool override_main) { + mp_import_stat_t stat = MP_IMPORT_STAT_NO_EXIST; + + // Exact-match of built-in (or already-loaded) takes priority. + mp_obj_t module_obj = mp_module_get_loaded_or_builtin(full_mod_name); + + // Even if we find the module, go through the motions of searching for it + // because we may actually be in the process of importing a sub-module. + // So we need to (re-)find the correct path to be finding the sub-module + // on the next iteration of process_import_at_level. + + if (outer_module_obj == MP_OBJ_NULL) { + DEBUG_printf("Searching for top-level module\n"); + + // First module in the dotted-name; search for a directory or file + // relative to all the locations in sys.path. + stat = stat_top_level_dir_or_file(full_mod_name, path); + + // If the module "foo" doesn't exist on the filesystem, and it's not a + // builtin, try and find "ufoo" as a built-in. (This feature was + // formerly known as "weak links"). + #if MICROPY_MODULE_WEAK_LINKS + if (stat == MP_IMPORT_STAT_NO_EXIST && module_obj == MP_OBJ_NULL) { + char *umodule_buf = vstr_str(path); + umodule_buf[0] = 'u'; + strcpy(umodule_buf + 1, qstr_str(level_mod_name)); + qstr umodule_name = qstr_from_str(umodule_buf); + module_obj = mp_module_get_builtin(umodule_name); + } + #endif + } else { + DEBUG_printf("Searching for sub-module\n"); + + // Add the current part of the module name to the path. + vstr_add_char(path, PATH_SEP_CHAR[0]); + vstr_add_str(path, qstr_str(level_mod_name)); + + // Because it's not top level, we already know which path the parent was found in. + stat = stat_dir_or_file(path); + } + DEBUG_printf("Current path: %.*s\n", (int)vstr_len(path), vstr_str(path)); + + if (module_obj == MP_OBJ_NULL) { + // Not a built-in and not already-loaded. + + if (stat == MP_IMPORT_STAT_NO_EXIST) { + // And the file wasn't found -- fail. + #if MICROPY_ERROR_REPORTING <= MICROPY_ERROR_REPORTING_TERSE + mp_raise_msg(&mp_type_ImportError, MP_ERROR_TEXT("module not found")); + #else + mp_raise_msg_varg(&mp_type_ImportError, MP_ERROR_TEXT("no module named '%q'"), full_mod_name); + #endif + } + + // Not a built-in but found on the filesystem, try and load it. + + DEBUG_printf("Found path: %.*s\n", (int)vstr_len(path), vstr_str(path)); + + // Prepare for loading from the filesystem. Create a new shell module. + module_obj = mp_obj_new_module(full_mod_name); + + #if MICROPY_MODULE_OVERRIDE_MAIN_IMPORT + // If this module is being loaded via -m on unix, then + // override __name__ to "__main__". Do this only for *modules* + // however - packages never have their names replaced, instead + // they're -m'ed using a special __main__ submodule in them. (This all + // apparently is done to not touch the package name itself, which is + // important for future imports). + if (override_main && stat != MP_IMPORT_STAT_DIR) { + mp_obj_module_t *o = MP_OBJ_TO_PTR(module_obj); + mp_obj_dict_store(MP_OBJ_FROM_PTR(o->globals), MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR___main__)); + #if MICROPY_CPYTHON_COMPAT + // Store module as "__main__" in the dictionary of loaded modules (returned by sys.modules). + mp_obj_dict_store(MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_loaded_modules_dict)), MP_OBJ_NEW_QSTR(MP_QSTR___main__), module_obj); + // Store real name in "__main__" attribute. Need this for + // resolving relative imports later. "__main__ was chosen + // semi-randonly, to reuse existing qstr's. + mp_obj_dict_store(MP_OBJ_FROM_PTR(o->globals), MP_OBJ_NEW_QSTR(MP_QSTR___main__), MP_OBJ_NEW_QSTR(full_mod_name)); + #endif + } + #endif // MICROPY_MODULE_OVERRIDE_MAIN_IMPORT + + if (stat == MP_IMPORT_STAT_DIR) { + // Directory -- execute "path/__init__.py". + DEBUG_printf("%.*s is dir\n", (int)vstr_len(path), vstr_str(path)); + // Store the __path__ attribute onto this module. + // https://docs.python.org/3/reference/import.html + // "Specifically, any module that contains a __path__ attribute is considered a package." + mp_store_attr(module_obj, MP_QSTR___path__, mp_obj_new_str(vstr_str(path), vstr_len(path))); + size_t orig_path_len = path->len; + vstr_add_str(path, PATH_SEP_CHAR "__init__.py"); + if (stat_file_py_or_mpy(path) == MP_IMPORT_STAT_FILE) { + do_load(module_obj, path); + } else { + // No-op. Nothing to load. + // mp_warning("%s is imported as namespace package", vstr_str(&path)); + } + // Remove /__init__.py suffix. + path->len = orig_path_len; + } else { // MP_IMPORT_STAT_FILE + // File -- execute "path.(m)py". + do_load(module_obj, path); + // Note: This should be the last component in the import path. If + // there are remaining components then it's an ImportError + // because the current path(the module that was just loaded) is + // not a package. This will be caught on the next iteration + // because the file will not exist. + } + } + + if (outer_module_obj != MP_OBJ_NULL && VERIFY_PTR(MP_OBJ_TO_PTR(outer_module_obj))) { + // If it's a sub-module (not a built-in one), then make it available on + // the parent module. + mp_store_attr(outer_module_obj, level_mod_name, module_obj); + } + + return module_obj; } mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args) { @@ -267,14 +471,28 @@ mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args) { DEBUG_printf("__import__:\n"); for (size_t i = 0; i < n_args; i++) { DEBUG_printf(" "); - mp_obj_print(args[i], PRINT_REPR); + mp_obj_print_helper(MICROPY_DEBUG_PRINTER, args[i], PRINT_REPR); DEBUG_printf("\n"); } #endif - mp_obj_t module_name = args[0]; + // This is the import path, with any leading dots stripped. + // "import foo.bar" --> module_name="foo.bar" + // "from foo.bar import baz" --> module_name="foo.bar" + // "from . import foo" --> module_name="" + // "from ...foo.bar import baz" --> module_name="foo.bar" + mp_obj_t module_name_obj = args[0]; + + // These are the imported names. + // i.e. "from foo.bar import baz, zap" --> fromtuple=("baz", "zap",) + // Note: There's a special case on the Unix port, where this is set to mp_const_false which means that it's __main__. mp_obj_t fromtuple = mp_const_none; + + // Level is the number of leading dots in a relative import. + // i.e. "from . import foo" --> level=1 + // i.e. "from ...foo.bar import baz" --> level=3 mp_int_t level = 0; + if (n_args >= 4) { fromtuple = args[3]; if (n_args >= 5) { @@ -285,226 +503,64 @@ mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args) { } } - size_t mod_len; - const char *mod_str = mp_obj_str_get_data(module_name, &mod_len); + size_t module_name_len; + const char *module_name = mp_obj_str_get_data(module_name_obj, &module_name_len); if (level != 0) { - // What we want to do here is to take name of current module, - // chop trailing components, and concatenate with passed-in - // module name, thus resolving relative import name into absolute. - // This even appears to be correct per - // http://legacy.python.org/dev/peps/pep-0328/#relative-imports-and-name - // "Relative imports use a module's __name__ attribute to determine that - // module's position in the package hierarchy." - level--; - mp_obj_t this_name_q = mp_obj_dict_get(MP_OBJ_FROM_PTR(mp_globals_get()), MP_OBJ_NEW_QSTR(MP_QSTR___name__)); - assert(this_name_q != MP_OBJ_NULL); - #if MICROPY_CPYTHON_COMPAT - if (MP_OBJ_QSTR_VALUE(this_name_q) == MP_QSTR___main__) { - // This is a module run by -m command-line switch, get its real name from backup attribute - this_name_q = mp_obj_dict_get(MP_OBJ_FROM_PTR(mp_globals_get()), MP_OBJ_NEW_QSTR(MP_QSTR___main__)); - } - #endif - mp_map_t *globals_map = &mp_globals_get()->map; - mp_map_elem_t *elem = mp_map_lookup(globals_map, MP_OBJ_NEW_QSTR(MP_QSTR___path__), MP_MAP_LOOKUP); - bool is_pkg = (elem != NULL); - - #if DEBUG_PRINT - DEBUG_printf("Current module/package: "); - mp_obj_print(this_name_q, PRINT_REPR); - DEBUG_printf(", is_package: %d", is_pkg); - DEBUG_printf("\n"); - #endif - - size_t this_name_l; - const char *this_name = mp_obj_str_get_data(this_name_q, &this_name_l); - - const char *p = this_name + this_name_l; - if (!is_pkg) { - // We have module, but relative imports are anchored at package, so - // go there. - chop_component(this_name, &p); - } - - while (level--) { - chop_component(this_name, &p); - } - - // We must have some component left over to import from - if (p == this_name) { - mp_raise_ImportError(MP_ERROR_TEXT("cannot perform relative import")); - } - - uint new_mod_l = (mod_len == 0 ? (size_t)(p - this_name) : (size_t)(p - this_name) + 1 + mod_len); - char *new_mod = mp_local_alloc(new_mod_l); - memcpy(new_mod, this_name, p - this_name); - if (mod_len != 0) { - new_mod[p - this_name] = '.'; - memcpy(new_mod + (p - this_name) + 1, mod_str, mod_len); - } - - qstr new_mod_q = qstr_from_strn(new_mod, new_mod_l); - mp_local_free(new_mod); - DEBUG_printf("Resolved base name for relative import: '%s'\n", qstr_str(new_mod_q)); - module_name = MP_OBJ_NEW_QSTR(new_mod_q); - mod_str = qstr_str(new_mod_q); - mod_len = new_mod_l; + // Turn "foo.bar" into ".foo.bar". + evaluate_relative_import(level, &module_name, &module_name_len); } - if (mod_len == 0) { + if (module_name_len == 0) { mp_raise_ValueError(NULL); } - // check if module already exists - qstr module_name_qstr = mp_obj_str_get_qstr(module_name); - mp_obj_t module_obj = mp_module_get(module_name_qstr); - if (module_obj != MP_OBJ_NULL) { - DEBUG_printf("Module already loaded\n"); - // If it's not a package, return module right away - char *p = strchr(mod_str, '.'); - if (p == NULL) { - return module_obj; - } - // If fromlist is not empty, return leaf module - if (fromtuple != mp_const_none) { - return module_obj; - } - // Otherwise, we need to return top-level package - qstr pkg_name = qstr_from_strn(mod_str, p - mod_str); - return mp_module_get(pkg_name); - } - DEBUG_printf("Module not yet loaded\n"); + DEBUG_printf("Starting module search for '%s'\n", module_name); - uint last = 0; VSTR_FIXED(path, MICROPY_ALLOC_PATH_MAX) - module_obj = MP_OBJ_NULL; mp_obj_t top_module_obj = MP_OBJ_NULL; mp_obj_t outer_module_obj = MP_OBJ_NULL; - uint i; - for (i = 1; i <= mod_len; i++) { - if (i == mod_len || mod_str[i] == '.') { - // create a qstr for the module name up to this depth - qstr mod_name = qstr_from_strn(mod_str, i); - DEBUG_printf("Processing module: %s\n", qstr_str(mod_name)); - DEBUG_printf("Previous path: =%.*s=\n", vstr_len(&path), vstr_str(&path)); - // find the file corresponding to the module name - mp_import_stat_t stat; - if (vstr_len(&path) == 0) { - // first module in the dotted-name; search for a directory or file - DEBUG_printf("Find file =%.*s=\n", vstr_len(&path), vstr_str(&path)); - stat = find_file(mod_str, i, &path); - } else { - // latter module in the dotted-name; append to path - vstr_add_char(&path, PATH_SEP_CHAR); - vstr_add_strn(&path, mod_str + last, i - last); - stat = stat_dir_or_file(&path); - } - DEBUG_printf("Current path: %.*s\n", vstr_len(&path), vstr_str(&path)); + // Search for the end of each component. + size_t current_component_start = 0; + for (size_t i = 1; i <= module_name_len; i++) { + if (i == module_name_len || module_name[i] == '.') { + // The module name up to this depth (e.g. foo.bar.baz). + qstr full_mod_name = qstr_from_strn(module_name, i); + // The current level name (e.g. baz). + qstr level_mod_name = qstr_from_strn(module_name + current_component_start, i - current_component_start); - if (stat == MP_IMPORT_STAT_NO_EXIST) { - // This is just the module name after the previous . - qstr current_module_name = qstr_from_strn(mod_str + last, i - last); - mp_map_elem_t *el = NULL; - if (outer_module_obj == MP_OBJ_NULL) { - el = mp_map_lookup((mp_map_t *)&mp_builtin_module_map, - MP_OBJ_NEW_QSTR(current_module_name), - MP_MAP_LOOKUP); - } else { - el = mp_map_lookup(&((mp_obj_module_t *)outer_module_obj)->globals->map, - MP_OBJ_NEW_QSTR(current_module_name), - MP_MAP_LOOKUP); - } + DEBUG_printf("Processing module: '%s' at level '%s'\n", qstr_str(full_mod_name), qstr_str(level_mod_name)); + DEBUG_printf("Previous path: =%.*s=\n", (int)vstr_len(&path), vstr_str(&path)); - if (el != NULL && mp_obj_is_type(el->value, &mp_type_module)) { - module_obj = el->value; - mp_module_call_init(mod_name, module_obj); - } else { - // couldn't find the file, so fail - #if MICROPY_ERROR_REPORTING <= MICROPY_ERROR_REPORTING_TERSE - mp_raise_ImportError(MP_ERROR_TEXT("module not found")); - #else - mp_raise_msg_varg(&mp_type_ImportError, - MP_ERROR_TEXT("no module named '%q'"), mod_name); - #endif - } - } else { - // found the file, so get the module - module_obj = mp_module_get(mod_name); - } + #if MICROPY_MODULE_OVERRIDE_MAIN_IMPORT + // On unix, if this is being loaded via -m (magic mp_const_false), + // then handle that if it's the final component. + bool override_main = (i == module_name_len && fromtuple == mp_const_false); + #else + bool override_main = false; + #endif - if (module_obj == MP_OBJ_NULL) { - // module not already loaded, so load it! + // Import this module. + mp_obj_t module_obj = process_import_at_level(full_mod_name, level_mod_name, outer_module_obj, &path, override_main); - module_obj = mp_obj_new_module(mod_name); - - // if args[3] (fromtuple) has magic value False, set up - // this module for command-line "-m" option (set module's - // name to __main__ instead of real name). Do this only - // for *modules* however - packages never have their names - // replaced, instead they're -m'ed using a special __main__ - // submodule in them. (This all apparently is done to not - // touch package name itself, which is important for future - // imports). - if (i == mod_len && fromtuple == mp_const_false && stat != MP_IMPORT_STAT_DIR) { - mp_obj_module_t *o = MP_OBJ_TO_PTR(module_obj); - mp_obj_dict_store(MP_OBJ_FROM_PTR(o->globals), MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR___main__)); - #if MICROPY_CPYTHON_COMPAT - // Store module as "__main__" in the dictionary of loaded modules (returned by sys.modules). - mp_obj_dict_store(MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_loaded_modules_dict)), MP_OBJ_NEW_QSTR(MP_QSTR___main__), module_obj); - // Store real name in "__main__" attribute. Chosen semi-randonly, to reuse existing qstr's. - mp_obj_dict_store(MP_OBJ_FROM_PTR(o->globals), MP_OBJ_NEW_QSTR(MP_QSTR___main__), MP_OBJ_NEW_QSTR(mod_name)); - #endif - } - - if (stat == MP_IMPORT_STAT_DIR) { - DEBUG_printf("%.*s is dir\n", vstr_len(&path), vstr_str(&path)); - // https://docs.python.org/3/reference/import.html - // "Specifically, any module that contains a __path__ attribute is considered a package." - mp_store_attr(module_obj, MP_QSTR___path__, mp_obj_new_str(vstr_str(&path), vstr_len(&path))); - size_t orig_path_len = path.len; - vstr_add_char(&path, PATH_SEP_CHAR); - vstr_add_str(&path, "__init__.py"); - if (stat_file_py_or_mpy(&path) != MP_IMPORT_STAT_FILE) { - // mp_warning("%s is imported as namespace package", vstr_str(&path)); - } else { - do_load(module_obj, &path); - } - path.len = orig_path_len; - } else { // MP_IMPORT_STAT_FILE - do_load(module_obj, &path); - // This should be the last component in the import path. If there are - // remaining components then it's an ImportError because the current path - // (the module that was just loaded) is not a package. This will be caught - // on the next iteration because the file will not exist. - } - - // Loading a module thrashes the heap significantly so we explicitly clean up - // afterwards. - gc_collect(); - } - if (outer_module_obj != MP_OBJ_NULL && VERIFY_PTR(MP_OBJ_TO_PTR(outer_module_obj))) { - qstr s = qstr_from_strn(mod_str + last, i - last); - mp_store_attr(outer_module_obj, s, module_obj); - // The above store can cause a dictionary rehash and new allocation. So, - // lets make sure the globals dictionary is still long lived. - mp_obj_module_set_globals(outer_module_obj, - make_dict_long_lived(mp_obj_module_get_globals(outer_module_obj), 10)); - } + // Set this as the parent module, and remember the top-level module if it's the first. outer_module_obj = module_obj; if (top_module_obj == MP_OBJ_NULL) { top_module_obj = module_obj; } - last = i + 1; + + current_component_start = i + 1; } } - // If fromlist is not empty, return leaf module if (fromtuple != mp_const_none) { - return module_obj; + // If fromtuple is not empty, return leaf module + return outer_module_obj; + } else { + // Otherwise, we need to return top-level package + return top_module_obj; } - // Otherwise, we need to return top-level package - return top_module_obj; } #else // MICROPY_ENABLE_EXTERNAL_IMPORT @@ -517,17 +573,19 @@ mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args) { // Check if module already exists, and return it if it does qstr module_name_qstr = mp_obj_str_get_qstr(args[0]); - mp_obj_t module_obj = mp_module_get(module_name_qstr); + mp_obj_t module_obj = mp_module_get_loaded_or_builtin(module_name_qstr); if (module_obj != MP_OBJ_NULL) { return module_obj; } #if MICROPY_MODULE_WEAK_LINKS // Check if there is a weak link to this module - module_obj = mp_module_search_umodule(qstr_str(module_name_qstr)); + char umodule_buf[MICROPY_ALLOC_PATH_MAX]; + umodule_buf[0] = 'u'; + strcpy(umodule_buf + 1, args[0]); + qstr umodule_name_qstr = qstr_from_str(umodule_buf); + module_obj = mp_module_get_loaded_or_builtin(umodule_name_qstr); if (module_obj != MP_OBJ_NULL) { - // Found weak-linked module - mp_module_call_init(module_name_qstr, module_obj); return module_obj; } #endif diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk index e883481675..15828f6616 100644 --- a/py/circuitpy_defns.mk +++ b/py/circuitpy_defns.mk @@ -85,23 +85,6 @@ CFLAGS += -DMICROPY_QSTR_EXTRA_POOL=mp_qstr_frozen_const_pool CFLAGS += -DMICROPY_MODULE_FROZEN_MPY endif - -### -# Propagate longint choice from .mk to C. There's no easy string comparison -# in cpp conditionals, so we #define separate names for each. -ifeq ($(LONGINT_IMPL),NONE) -CFLAGS += -DLONGINT_IMPL_NONE -endif - -ifeq ($(LONGINT_IMPL),MPZ) -CFLAGS += -DLONGINT_IMPL_MPZ -endif - -ifeq ($(LONGINT_IMPL),LONGLONG) -CFLAGS += -DLONGINT_IMPL_LONGLONG -endif - - ### # Select which builtin modules to compile and include. @@ -470,8 +453,7 @@ $(filter $(SRC_PATTERNS), \ _eve/__init__.c \ camera/ImageFormat.c \ canio/Match.c \ - qrio/PixelPolicy.c \ - qrio/QRInfo.c \ + countio/Edge.c \ digitalio/Direction.c \ digitalio/DriveMode.c \ digitalio/Pull.c \ @@ -485,6 +467,8 @@ $(filter $(SRC_PATTERNS), \ msgpack/ExtType.c \ paralleldisplay/__init__.c \ paralleldisplay/ParallelBus.c \ + qrio/PixelPolicy.c \ + qrio/QRInfo.c \ supervisor/RunReason.c \ wifi/AuthMode.c \ wifi/Packet.c \ @@ -524,8 +508,8 @@ SRC_SHARED_MODULE_ALL = \ bitops/__init__.c \ board/__init__.c \ adafruit_bus_device/__init__.c \ - adafruit_bus_device/I2CDevice.c \ - adafruit_bus_device/SPIDevice.c \ + adafruit_bus_device/i2c_device/I2CDevice.c \ + adafruit_bus_device/spi_device/SPIDevice.c \ canio/Match.c \ canio/Message.c \ canio/RemoteTransmissionRequest.c \ @@ -555,6 +539,7 @@ SRC_SHARED_MODULE_ALL = \ ipaddress/IPv4Address.c \ ipaddress/__init__.c \ is31fl3741/IS31FL3741.c \ + is31fl3741/FrameBuffer.c \ is31fl3741/__init__.c \ keypad/__init__.c \ keypad/Event.c \ diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index 6efc341fce..ddac0967bb 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -87,6 +87,7 @@ extern void common_hal_mcu_enable_interrupts(void); #define MICROPY_OPT_COMPUTED_GOTO (1) #define MICROPY_OPT_COMPUTED_GOTO_SAVE_SPACE (CIRCUITPY_COMPUTED_GOTO_SAVE_SPACE) #define MICROPY_OPT_LOAD_ATTR_FAST_PATH (CIRCUITPY_OPT_LOAD_ATTR_FAST_PATH) +#define MICROPY_OPT_MAP_LOOKUP_CACHE (CIRCUITPY_OPT_MAP_LOOKUP_CACHE) #define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE (CIRCUITPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) #define MICROPY_PERSISTENT_CODE_LOAD (1) @@ -259,23 +260,42 @@ typedef long mp_off_t; #error No *_FLASH_FILESYSTEM set! #endif +// Default board buses. + +#ifndef CIRCUITPY_BOARD_I2C +#if defined(DEFAULT_I2C_BUS_SCL) && defined(DEFAULT_I2C_BUS_SDA) +#define CIRCUITPY_BOARD_I2C (1) +#define CIRCUITPY_BOARD_I2C_PIN {{.scl = DEFAULT_I2C_BUS_SCL, .sda = DEFAULT_I2C_BUS_SDA}} +#else +#define CIRCUITPY_BOARD_I2C (0) +#endif +#endif + +#ifndef CIRCUITPY_BOARD_SPI +#if defined(DEFAULT_SPI_BUS_SCK) && defined(DEFAULT_SPI_BUS_MOSI) && defined(DEFAULT_SPI_BUS_MISO) +#define CIRCUITPY_BOARD_SPI (1) +#define CIRCUITPY_BOARD_SPI_PIN {{.clock = DEFAULT_SPI_BUS_SCK, .mosi = DEFAULT_SPI_BUS_MOSI, .miso = DEFAULT_SPI_BUS_MISO}} +#else +#define CIRCUITPY_BOARD_SPI (0) +#endif +#endif + +#ifndef CIRCUITPY_BOARD_UART +#if defined(DEFAULT_UART_BUS_TX) && defined(DEFAULT_UART_BUS_RX) +#define CIRCUITPY_BOARD_UART (1) +#define CIRCUITPY_BOARD_UART_PIN {{.tx = DEFAULT_UART_BUS_TX, .rx = DEFAULT_UART_BUS_RX}} +#define BOARD_UART_ROOT_POINTER mp_obj_t board_uart_bus; +#else +#define CIRCUITPY_BOARD_UART (0) +#define BOARD_UART_ROOT_POINTER +#endif +#else +#define BOARD_UART_ROOT_POINTER mp_obj_t board_uart_bus; +#endif + // These CIRCUITPY_xxx values should all be defined in the *.mk files as being on or off. // So if any are not defined in *.mk, they'll throw an error here. -#if CIRCUITPY_BOARD -#define BOARD_I2C (defined(DEFAULT_I2C_BUS_SDA) && defined(DEFAULT_I2C_BUS_SCL)) -#define BOARD_SPI (defined(DEFAULT_SPI_BUS_SCK) && defined(DEFAULT_SPI_BUS_MISO) && defined(DEFAULT_SPI_BUS_MOSI)) -#define BOARD_UART (defined(DEFAULT_UART_BUS_RX) && defined(DEFAULT_UART_BUS_TX)) -// I2C and SPI are always allocated off the heap. -#if BOARD_UART -#define BOARD_UART_ROOT_POINTER mp_obj_t shared_uart_bus; -#else -#define BOARD_UART_ROOT_POINTER -#endif -#else -#define BOARD_UART_ROOT_POINTER -#endif - #if CIRCUITPY_DISPLAYIO #ifndef CIRCUITPY_DISPLAY_LIMIT #define CIRCUITPY_DISPLAY_LIMIT (1) @@ -337,6 +357,10 @@ extern const struct _mp_obj_module_t nvm_module; #endif #endif +#ifndef ULAB_SUPPORTS_COMPLEX +#define ULAB_SUPPORTS_COMPLEX (0) +#endif + #if CIRCUITPY_ULAB // ulab requires reverse special methods #if defined(MICROPY_PY_REVERSE_SPECIAL_METHODS) && !MICROPY_PY_REVERSE_SPECIAL_METHODS @@ -424,9 +448,9 @@ void supervisor_run_background_tasks_if_tick(void); #define CIRCUITPY_PYSTACK_SIZE 1536 #endif -// Wait this long imediately after startup to see if we are connected to USB. -#ifndef CIRCUITPY_USB_CONNECTED_SLEEP_DELAY -#define CIRCUITPY_USB_CONNECTED_SLEEP_DELAY 5 +// Wait this long before sleeping immediately after startup, to see if we are connected via USB or BLE. +#ifndef CIRCUITPY_WORKFLOW_CONNECTION_SLEEP_DELAY +#define CIRCUITPY_WORKFLOW_CONNECTION_SLEEP_DELAY 5 #endif #ifndef CIRCUITPY_PROCESSOR_COUNT @@ -518,5 +542,16 @@ void supervisor_run_background_tasks_if_tick(void); #define USB_MIDI_EP_NUM_IN (0) #endif +#ifndef MICROPY_WRAP_MP_MAP_LOOKUP +#define MICROPY_WRAP_MP_MAP_LOOKUP PLACE_IN_ITCM +#endif + +#ifndef MICROPY_WRAP_MP_BINARY_OP +#define MICROPY_WRAP_MP_BINARY_OP PLACE_IN_ITCM +#endif + +#ifndef MICROPY_WRAP_MP_EXECUTE_BYTECODE +#define MICROPY_WRAP_MP_EXECUTE_BYTECODE PLACE_IN_ITCM +#endif #endif // __INCLUDED_MPCONFIG_CIRCUITPY_H diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk index 7f0721264b..d47b591a5e 100644 --- a/py/circuitpy_mpconfig.mk +++ b/py/circuitpy_mpconfig.mk @@ -162,13 +162,8 @@ CFLAGS += -DCIRCUITPY_COMPUTED_GOTO_SAVE_SPACE=$(CIRCUITPY_COMPUTED_GOTO_SAVE_SP CIRCUITPY_OPT_LOAD_ATTR_FAST_PATH ?= 1 CFLAGS += -DCIRCUITPY_OPT_LOAD_ATTR_FAST_PATH=$(CIRCUITPY_OPT_LOAD_ATTR_FAST_PATH) -# This is disabled because it changes the bytecode format. We could choose to enable it -# when we go to 8.x, but probably not for 7.1. -CIRCUITPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE ?= 0 -CFLAGS += -DCIRCUITPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE=$(CIRCUITPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) -ifeq ($(CIRCUITPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE),1) -MPY_CROSS_FLAGS += -mcache-lookup-bc -endif +CIRCUITPY_OPT_MAP_LOOKUP_CACHE ?= $(CIRCUITPY_FULL_BUILD) +CFLAGS += -DCIRCUITPY_OPT_MAP_LOOKUP_CACHE=$(CIRCUITPY_OPT_MAP_LOOKUP_CACHE) CIRCUITPY_CONSOLE_UART ?= 0 CFLAGS += -DCIRCUITPY_CONSOLE_UART=$(CIRCUITPY_CONSOLE_UART) @@ -462,3 +457,52 @@ CFLAGS += -DCIRCUITPY_WATCHDOG=$(CIRCUITPY_WATCHDOG) CIRCUITPY_WIFI ?= 0 CFLAGS += -DCIRCUITPY_WIFI=$(CIRCUITPY_WIFI) + +# tinyusb port tailored configuration +CIRCUITPY_TUSB_MEM_ALIGN ?= 4 +CFLAGS += -DCIRCUITPY_TUSB_MEM_ALIGN=$(CIRCUITPY_TUSB_MEM_ALIGN) + +CIRCUITPY_TUSB_ATTR_USBRAM ?= ".bss.usbram" +CFLAGS += -DCIRCUITPY_TUSB_ATTR_USBRAM=$(CIRCUITPY_TUSB_ATTR_USBRAM) + +# Define an equivalent for MICROPY_LONGINT_IMPL, to pass to $(MPY-TOOL) in py/mkrules.mk +# $(MPY-TOOL) needs to know what kind of longint to use (if any) to freeze long integers. +# This should correspond to the MICROPY_LONGINT_IMPL definition in mpconfigport.h. +# +# Also propagate longint choice from .mk to C. There's no easy string comparison +# in cpp conditionals, so we #define separate names for each. + +ifeq ($(LONGINT_IMPL),NONE) +MPY_TOOL_LONGINT_IMPL = -mlongint-impl=none +CFLAGS += -DLONGINT_IMPL_NONE +else ifeq ($(LONGINT_IMPL),MPZ) +MPY_TOOL_LONGINT_IMPL = -mlongint-impl=mpz +CFLAGS += -DLONGINT_IMPL_MPZ +else ifeq ($(LONGINT_IMPL),LONGLONG) +MPY_TOOL_LONGINT_IMPL = -mlongint-impl=longlong +CFLAGS += -DLONGINT_IMPL_LONGLONG +else +$(error LONGINT_IMPL set to surprising value: "$(LONGINT_IMPL)") +endif +MPY_TOOL_FLAGS += $(MPY_TOOL_LONGINT_IMPL) + +### +ifeq ($(LONGINT_IMPL),NONE) +else ifeq ($(LONGINT_IMPL),MPZ) +else ifeq ($(LONGINT_IMPL),LONGLONG) +else +$(error LONGINT_IMPL set to surprising value: "$(LONGINT_IMPL)") +endif + +PREPROCESS_FROZEN_MODULES = PYTHONPATH=$(TOP)/tools/python-semver $(TOP)/tools/preprocess_frozen_modules.py +ifneq ($(FROZEN_MPY_DIRS),) +$(BUILD)/frozen_mpy: $(FROZEN_MPY_DIRS) + $(ECHO) FREEZE $(FROZEN_MPY_DIRS) + $(Q)$(MKDIR) -p $@ + $(Q)$(PREPROCESS_FROZEN_MODULES) -o $@ $(FROZEN_MPY_DIRS) + +$(BUILD)/manifest.py: $(BUILD)/frozen_mpy | $(TOP)/py/circuitpy_mpconfig.mk mpconfigport.mk boards/$(BOARD)/mpconfigboard.mk + $(ECHO) MKMANIFEST $(FROZEN_MPY_DIRS) + (cd $(BUILD)/frozen_mpy && find * -name \*.py -exec printf 'freeze_as_mpy("frozen_mpy", "%s")\n' {} \; )> $@.tmp && mv -f $@.tmp $@ +FROZEN_MANIFEST=$(BUILD)/manifest.py +endif diff --git a/py/compile.c b/py/compile.c index bdedc874e3..e5f341a656 100644 --- a/py/compile.c +++ b/py/compile.c @@ -61,6 +61,12 @@ typedef enum { #undef DEF_RULE_NC } pn_kind_t; +// Whether a mp_parse_node_struct_t that has pns->kind == PN_testlist_comp +// corresponds to a list comprehension or generator. +#define MP_PARSE_NODE_TESTLIST_COMP_HAS_COMP_FOR(pns) \ + (MP_PARSE_NODE_STRUCT_NUM_NODES(pns) == 2 && \ + MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[1], PN_comp_for)) + #define NEED_METHOD_TABLE MICROPY_EMIT_NATIVE #if NEED_METHOD_TABLE @@ -319,25 +325,13 @@ STATIC void compile_delete_id(compiler_t *comp, qstr qst) { } } -STATIC void c_tuple(compiler_t *comp, mp_parse_node_t pn, mp_parse_node_struct_t *pns_list) { - int total = 0; - if (!MP_PARSE_NODE_IS_NULL(pn)) { - compile_node(comp, pn); - total += 1; - } - if (pns_list != NULL) { - int n = MP_PARSE_NODE_STRUCT_NUM_NODES(pns_list); - for (int i = 0; i < n; i++) { - compile_node(comp, pns_list->nodes[i]); - } - total += n; - } - EMIT_ARG(build, total, MP_EMIT_BUILD_TUPLE); -} - STATIC void compile_generic_tuple(compiler_t *comp, mp_parse_node_struct_t *pns) { // a simple tuple expression - c_tuple(comp, MP_PARSE_NODE_NULL, pns); + size_t num_nodes = MP_PARSE_NODE_STRUCT_NUM_NODES(pns); + for (size_t i = 0; i < num_nodes; i++) { + compile_node(comp, pns->nodes[i]); + } + EMIT_ARG(build, num_nodes, MP_EMIT_BUILD_TUPLE); } STATIC void c_if_cond(compiler_t *comp, mp_parse_node_t pn, bool jump_if, int label) { @@ -454,21 +448,14 @@ STATIC void c_assign_atom_expr(compiler_t *comp, mp_parse_node_struct_t *pns, as compile_syntax_error(comp, (mp_parse_node_t)pns, MP_ERROR_TEXT("can't assign to expression")); } -// we need to allow for a caller passing in 1 initial node (node_head) followed by an array of nodes (nodes_tail) -STATIC void c_assign_tuple(compiler_t *comp, mp_parse_node_t node_head, uint num_tail, mp_parse_node_t *nodes_tail) { - uint num_head = (node_head == MP_PARSE_NODE_NULL) ? 0 : 1; - +STATIC void c_assign_tuple(compiler_t *comp, uint num_tail, mp_parse_node_t *nodes_tail) { // look for star expression uint have_star_index = -1; - if (num_head != 0 && MP_PARSE_NODE_IS_STRUCT_KIND(node_head, PN_star_expr)) { - EMIT_ARG(unpack_ex, 0, num_tail); - have_star_index = 0; - } for (uint i = 0; i < num_tail; i++) { if (MP_PARSE_NODE_IS_STRUCT_KIND(nodes_tail[i], PN_star_expr)) { if (have_star_index == (uint)-1) { - EMIT_ARG(unpack_ex, num_head + i, num_tail - i - 1); - have_star_index = num_head + i; + EMIT_ARG(unpack_ex, i, num_tail - i - 1); + have_star_index = i; } else { compile_syntax_error(comp, nodes_tail[i], MP_ERROR_TEXT("multiple *x in assignment")); return; @@ -476,17 +463,10 @@ STATIC void c_assign_tuple(compiler_t *comp, mp_parse_node_t node_head, uint num } } if (have_star_index == (uint)-1) { - EMIT_ARG(unpack_sequence, num_head + num_tail); - } - if (num_head != 0) { - if (0 == have_star_index) { - c_assign(comp, ((mp_parse_node_struct_t *)node_head)->nodes[0], ASSIGN_STORE); - } else { - c_assign(comp, node_head, ASSIGN_STORE); - } + EMIT_ARG(unpack_sequence, num_tail); } for (uint i = 0; i < num_tail; i++) { - if (num_head + i == have_star_index) { + if (i == have_star_index) { c_assign(comp, ((mp_parse_node_struct_t *)nodes_tail[i])->nodes[0], ASSIGN_STORE); } else { c_assign(comp, nodes_tail[i], ASSIGN_STORE); @@ -528,7 +508,7 @@ STATIC void c_assign(compiler_t *comp, mp_parse_node_t pn, assign_kind_t assign_ if (assign_kind != ASSIGN_STORE) { goto cannot_assign; } - c_assign_tuple(comp, MP_PARSE_NODE_NULL, MP_PARSE_NODE_STRUCT_NUM_NODES(pns), pns->nodes); + c_assign_tuple(comp, MP_PARSE_NODE_STRUCT_NUM_NODES(pns), pns->nodes); break; case PN_atom_paren: @@ -553,13 +533,13 @@ STATIC void c_assign(compiler_t *comp, mp_parse_node_t pn, assign_kind_t assign_ } if (MP_PARSE_NODE_IS_NULL(pns->nodes[0])) { // empty list, assignment allowed - c_assign_tuple(comp, MP_PARSE_NODE_NULL, 0, NULL); + c_assign_tuple(comp, 0, NULL); } else if (MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[0], PN_testlist_comp)) { pns = (mp_parse_node_struct_t *)pns->nodes[0]; goto testlist_comp; } else { // brackets around 1 item - c_assign_tuple(comp, pns->nodes[0], 0, NULL); + c_assign_tuple(comp, 1, pns->nodes); } break; @@ -570,27 +550,10 @@ STATIC void c_assign(compiler_t *comp, mp_parse_node_t pn, assign_kind_t assign_ testlist_comp: // lhs is a sequence - if (MP_PARSE_NODE_IS_STRUCT(pns->nodes[1])) { - mp_parse_node_struct_t *pns2 = (mp_parse_node_struct_t *)pns->nodes[1]; - if (MP_PARSE_NODE_STRUCT_KIND(pns2) == PN_testlist_comp_3b) { - // sequence of one item, with trailing comma - assert(MP_PARSE_NODE_IS_NULL(pns2->nodes[0])); - c_assign_tuple(comp, pns->nodes[0], 0, NULL); - } else if (MP_PARSE_NODE_STRUCT_KIND(pns2) == PN_testlist_comp_3c) { - // sequence of many items - uint n = MP_PARSE_NODE_STRUCT_NUM_NODES(pns2); - c_assign_tuple(comp, pns->nodes[0], n, pns2->nodes); - } else if (MP_PARSE_NODE_STRUCT_KIND(pns2) == PN_comp_for) { - goto cannot_assign; - } else { - // sequence with 2 items - goto sequence_with_2_items; - } - } else { - // sequence with 2 items - sequence_with_2_items: - c_assign_tuple(comp, MP_PARSE_NODE_NULL, 2, pns->nodes); + if (MP_PARSE_NODE_TESTLIST_COMP_HAS_COMP_FOR(pns)) { + goto cannot_assign; } + c_assign_tuple(comp, MP_PARSE_NODE_STRUCT_NUM_NODES(pns), pns->nodes); return; } return; @@ -993,32 +956,11 @@ STATIC void c_del_stmt(compiler_t *comp, mp_parse_node_t pn) { } else { assert(MP_PARSE_NODE_IS_STRUCT_KIND(pn, PN_testlist_comp)); mp_parse_node_struct_t *pns = (mp_parse_node_struct_t *)pn; - // TODO perhaps factorise testlist_comp code with other uses of PN_testlist_comp - - if (MP_PARSE_NODE_IS_STRUCT(pns->nodes[1])) { - mp_parse_node_struct_t *pns1 = (mp_parse_node_struct_t *)pns->nodes[1]; - if (MP_PARSE_NODE_STRUCT_KIND(pns1) == PN_testlist_comp_3b) { - // sequence of one item, with trailing comma - assert(MP_PARSE_NODE_IS_NULL(pns1->nodes[0])); - c_del_stmt(comp, pns->nodes[0]); - } else if (MP_PARSE_NODE_STRUCT_KIND(pns1) == PN_testlist_comp_3c) { - // sequence of many items - int n = MP_PARSE_NODE_STRUCT_NUM_NODES(pns1); - c_del_stmt(comp, pns->nodes[0]); - for (int i = 0; i < n; i++) { - c_del_stmt(comp, pns1->nodes[i]); - } - } else if (MP_PARSE_NODE_STRUCT_KIND(pns1) == PN_comp_for) { - goto cannot_delete; - } else { - // sequence with 2 items - goto sequence_with_2_items; - } - } else { - // sequence with 2 items - sequence_with_2_items: - c_del_stmt(comp, pns->nodes[0]); - c_del_stmt(comp, pns->nodes[1]); + if (MP_PARSE_NODE_TESTLIST_COMP_HAS_COMP_FOR(pns)) { + goto cannot_delete; + } + for (size_t i = 0; i < MP_PARSE_NODE_STRUCT_NUM_NODES(pns); ++i) { + c_del_stmt(comp, pns->nodes[i]); } } } else { @@ -2502,31 +2444,16 @@ STATIC void compile_comprehension(compiler_t *comp, mp_parse_node_struct_t *pns, STATIC void compile_atom_paren(compiler_t *comp, mp_parse_node_struct_t *pns) { if (MP_PARSE_NODE_IS_NULL(pns->nodes[0])) { // an empty tuple - c_tuple(comp, MP_PARSE_NODE_NULL, NULL); + EMIT_ARG(build, 0, MP_EMIT_BUILD_TUPLE); } else { assert(MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[0], PN_testlist_comp)); pns = (mp_parse_node_struct_t *)pns->nodes[0]; - assert(!MP_PARSE_NODE_IS_NULL(pns->nodes[1])); - if (MP_PARSE_NODE_IS_STRUCT(pns->nodes[1])) { - mp_parse_node_struct_t *pns2 = (mp_parse_node_struct_t *)pns->nodes[1]; - if (MP_PARSE_NODE_STRUCT_KIND(pns2) == PN_testlist_comp_3b) { - // tuple of one item, with trailing comma - assert(MP_PARSE_NODE_IS_NULL(pns2->nodes[0])); - c_tuple(comp, pns->nodes[0], NULL); - } else if (MP_PARSE_NODE_STRUCT_KIND(pns2) == PN_testlist_comp_3c) { - // tuple of many items - c_tuple(comp, pns->nodes[0], pns2); - } else if (MP_PARSE_NODE_STRUCT_KIND(pns2) == PN_comp_for) { - // generator expression - compile_comprehension(comp, pns, SCOPE_GEN_EXPR); - } else { - // tuple with 2 items - goto tuple_with_2_items; - } + if (MP_PARSE_NODE_TESTLIST_COMP_HAS_COMP_FOR(pns)) { + // generator expression + compile_comprehension(comp, pns, SCOPE_GEN_EXPR); } else { - // tuple with 2 items - tuple_with_2_items: - c_tuple(comp, MP_PARSE_NODE_NULL, pns); + // tuple with N items + compile_generic_tuple(comp, pns); } } } @@ -2537,31 +2464,13 @@ STATIC void compile_atom_bracket(compiler_t *comp, mp_parse_node_struct_t *pns) EMIT_ARG(build, 0, MP_EMIT_BUILD_LIST); } else if (MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[0], PN_testlist_comp)) { mp_parse_node_struct_t *pns2 = (mp_parse_node_struct_t *)pns->nodes[0]; - if (MP_PARSE_NODE_IS_STRUCT(pns2->nodes[1])) { - mp_parse_node_struct_t *pns3 = (mp_parse_node_struct_t *)pns2->nodes[1]; - if (MP_PARSE_NODE_STRUCT_KIND(pns3) == PN_testlist_comp_3b) { - // list of one item, with trailing comma - assert(MP_PARSE_NODE_IS_NULL(pns3->nodes[0])); - compile_node(comp, pns2->nodes[0]); - EMIT_ARG(build, 1, MP_EMIT_BUILD_LIST); - } else if (MP_PARSE_NODE_STRUCT_KIND(pns3) == PN_testlist_comp_3c) { - // list of many items - compile_node(comp, pns2->nodes[0]); - compile_generic_all_nodes(comp, pns3); - EMIT_ARG(build, 1 + MP_PARSE_NODE_STRUCT_NUM_NODES(pns3), MP_EMIT_BUILD_LIST); - } else if (MP_PARSE_NODE_STRUCT_KIND(pns3) == PN_comp_for) { - // list comprehension - compile_comprehension(comp, pns2, SCOPE_LIST_COMP); - } else { - // list with 2 items - goto list_with_2_items; - } + if (MP_PARSE_NODE_TESTLIST_COMP_HAS_COMP_FOR(pns2)) { + // list comprehension + compile_comprehension(comp, pns2, SCOPE_LIST_COMP); } else { - // list with 2 items - list_with_2_items: - compile_node(comp, pns2->nodes[0]); - compile_node(comp, pns2->nodes[1]); - EMIT_ARG(build, 2, MP_EMIT_BUILD_LIST); + // list with N items + compile_generic_all_nodes(comp, pns2); + EMIT_ARG(build, MP_PARSE_NODE_STRUCT_NUM_NODES(pns2), MP_EMIT_BUILD_LIST); } } else { // list with 1 item diff --git a/py/dynruntime.h b/py/dynruntime.h index 0a7eb20397..608cdec097 100644 --- a/py/dynruntime.h +++ b/py/dynruntime.h @@ -141,8 +141,7 @@ static inline mp_obj_t mp_obj_cast_to_native_base_dyn(mp_obj_t self_in, mp_const if (MP_OBJ_FROM_PTR(self_type) == native_type) { return self_in; } - mp_parent_t parent = mp_type_get_parent_slot(self_type); - if (parent != native_type) { + if (self_type->parent != native_type) { // The self_in object is not a direct descendant of native_type, so fail the cast. // This is a very simple version of mp_obj_is_subclass_fast that could be improved. return MP_OBJ_NULL; diff --git a/py/dynruntime.mk b/py/dynruntime.mk index cb5ab845eb..db06d41e73 100644 --- a/py/dynruntime.mk +++ b/py/dynruntime.mk @@ -46,7 +46,6 @@ ifeq ($(ARCH),x86) # x86 CROSS = CFLAGS += -m32 -fno-stack-protector -MPY_CROSS_FLAGS += -mcache-lookup-bc MICROPY_FLOAT_IMPL ?= double else ifeq ($(ARCH),x64) @@ -54,7 +53,6 @@ else ifeq ($(ARCH),x64) # x64 CROSS = CFLAGS += -fno-stack-protector -MPY_CROSS_FLAGS += -mcache-lookup-bc MICROPY_FLOAT_IMPL ?= double else ifeq ($(ARCH),armv7m) diff --git a/py/emitbc.c b/py/emitbc.c index 1d798faf68..8f7b1d5b72 100644 --- a/py/emitbc.c +++ b/py/emitbc.c @@ -560,9 +560,6 @@ void mp_emit_bc_load_global(emit_t *emit, qstr qst, int kind) { MP_STATIC_ASSERT(MP_BC_LOAD_NAME + MP_EMIT_IDOP_GLOBAL_GLOBAL == MP_BC_LOAD_GLOBAL); (void)qst; emit_write_bytecode_byte_qstr(emit, 1, MP_BC_LOAD_NAME + kind, qst); - if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE_DYNAMIC) { - emit_write_bytecode_raw_byte(emit, 0); - } } void mp_emit_bc_load_method(emit_t *emit, qstr qst, bool is_super) { @@ -596,9 +593,6 @@ void mp_emit_bc_attr(emit_t *emit, qstr qst, int kind) { } emit_write_bytecode_byte_qstr(emit, -2, MP_BC_STORE_ATTR, qst); } - if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE_DYNAMIC) { - emit_write_bytecode_raw_byte(emit, 0); - } } void mp_emit_bc_store_local(emit_t *emit, qstr qst, mp_uint_t local_num, int kind) { diff --git a/py/emitnative.c b/py/emitnative.c index c5d9fecb4c..5946fcd341 100644 --- a/py/emitnative.c +++ b/py/emitnative.c @@ -1588,6 +1588,7 @@ STATIC void emit_native_load_subscr(emit_t *emit) { int reg_base = REG_ARG_1; int reg_index = REG_ARG_2; emit_pre_pop_reg_flexible(emit, &vtype_base, ®_base, reg_index, reg_index); + need_reg_single(emit, REG_RET, 0); switch (vtype_base) { case VTYPE_PTR8: { // pointer to 8-bit memory @@ -1651,6 +1652,7 @@ STATIC void emit_native_load_subscr(emit_t *emit) { int reg_index = REG_ARG_2; emit_pre_pop_reg_flexible(emit, &vtype_index, ®_index, REG_ARG_1, REG_ARG_1); emit_pre_pop_reg(emit, &vtype_base, REG_ARG_1); + need_reg_single(emit, REG_RET, 0); if (vtype_index != VTYPE_INT && vtype_index != VTYPE_UINT) { EMIT_NATIVE_VIPER_TYPE_ERROR(emit, MP_ERROR_TEXT("can't load with '%q' index"), vtype_to_qstr(vtype_index)); diff --git a/py/frozenmod.c b/py/frozenmod.c index 6f8191d311..57e9d5df9b 100644 --- a/py/frozenmod.c +++ b/py/frozenmod.c @@ -5,6 +5,7 @@ * * Copyright (c) 2015 Paul Sokolovsky * SPDX-FileCopyrightText: Copyright (c) 2016 Damien P. George + * SPDX-FileCopyrightText: Copyright (c) 2021 Jim Mussared * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -31,6 +32,13 @@ #include "py/lexer.h" #include "py/frozenmod.h" +#if MICROPY_MODULE_FROZEN + +// Null-separated frozen file names. All string-type entries are listed first, +// followed by mpy-type entries. Use mp_frozen_str_sizes to determine how +// many string entries. +extern const char mp_frozen_names[]; + #if MICROPY_MODULE_FROZEN_STR #ifndef MICROPY_MODULE_FROZEN_LEXER @@ -39,129 +47,89 @@ mp_lexer_t *MICROPY_MODULE_FROZEN_LEXER(qstr src_name, const char *str, mp_uint_t len, mp_uint_t free_len); #endif -extern const char mp_frozen_str_names[]; +// Size in bytes of each string entry, followed by a zero (terminator). extern const uint32_t mp_frozen_str_sizes[]; +// Null-separated string content. extern const char mp_frozen_str_content[]; - -// str_len is length of str. *len is set on on output to size of content -const char *mp_find_frozen_str(const char *str, size_t str_len, size_t *len) { - // If the frozen module pseudo dir (e.g., ".frozen/") is a prefix of str, remove it. - if (strncmp(str, MP_FROZEN_FAKE_DIR_SLASH, MP_FROZEN_FAKE_DIR_SLASH_LENGTH) == 0) { - str = str + MP_FROZEN_FAKE_DIR_SLASH_LENGTH; - str_len = str_len - MP_FROZEN_FAKE_DIR_SLASH_LENGTH; - } - - const char *name = mp_frozen_str_names; - - size_t offset = 0; - for (int i = 0; *name != 0; i++) { - size_t l = strlen(name); - if (l == str_len && !memcmp(str, name, l)) { - *len = mp_frozen_str_sizes[i]; - return mp_frozen_str_content + offset; - } - name += l + 1; - offset += mp_frozen_str_sizes[i] + 1; - } - return NULL; -} - -STATIC mp_lexer_t *mp_lexer_frozen_str(const char *str, size_t str_len) { - size_t file_len; - const char *content = mp_find_frozen_str(str, str_len, &file_len); - - if (content == NULL) { - return NULL; - } - - qstr source = qstr_from_strn(str, str_len); - mp_lexer_t *lex = MICROPY_MODULE_FROZEN_LEXER(source, content, file_len, 0); - return lex; -} -#endif +#endif // MICROPY_MODULE_FROZEN_STR #if MICROPY_MODULE_FROZEN_MPY #include "py/emitglue.h" -extern const char mp_frozen_mpy_names[]; extern const mp_raw_code_t *const mp_frozen_mpy_content[]; -STATIC const mp_raw_code_t *mp_find_frozen_mpy(const char *str, size_t str_len) { - const char *name = mp_frozen_mpy_names; - for (size_t i = 0; *name != 0; i++) { - size_t l = strlen(name); - if (l == str_len && !memcmp(str, name, l)) { - return mp_frozen_mpy_content[i]; - } - name += l + 1; - } - return NULL; -} +#endif // MICROPY_MODULE_FROZEN_MPY -#endif - -#if MICROPY_MODULE_FROZEN - -STATIC mp_import_stat_t mp_frozen_stat_helper(const char *name, const char *str) { +// Search for "str" as a frozen entry, returning the stat result +// (no-exist/file/dir), as well as the type (none/str/mpy) and data. +// frozen_type can be NULL if its value isn't needed (and then data is assumed to be NULL). +mp_import_stat_t mp_find_frozen_module(const char *str, int *frozen_type, void **data) { size_t len = strlen(str); + const char *name = mp_frozen_names; + + if (frozen_type != NULL) { + *frozen_type = MP_FROZEN_NONE; + } + + // Count the number of str lengths we have to find how many str entries. + size_t num_str = 0; + #if MICROPY_MODULE_FROZEN_STR && MICROPY_MODULE_FROZEN_MPY + for (const uint32_t *s = mp_frozen_str_sizes; *s != 0; ++s) { + ++num_str; + } + #endif + + for (size_t i = 0; *name != 0; i++) { + size_t entry_len = strlen(name); + if (entry_len >= len && memcmp(str, name, len) == 0) { + // Query is a prefix of the current entry. + if (entry_len == len) { + // Exact match --> file. + + if (frozen_type != NULL) { + #if MICROPY_MODULE_FROZEN_STR + if (i < num_str) { + *frozen_type = MP_FROZEN_STR; + // Use the size table to figure out where this index starts. + size_t offset = 0; + for (size_t j = 0; j < i; ++j) { + offset += mp_frozen_str_sizes[j] + 1; + } + size_t content_len = mp_frozen_str_sizes[i]; + const char *content = &mp_frozen_str_content[offset]; + + // Note: str & len have been updated by find_frozen_entry to strip + // the ".frozen/" prefix (to avoid this being a distinct qstr to + // the original path QSTR in frozen_content.c). + qstr source = qstr_from_strn(str, len); + mp_lexer_t *lex = MICROPY_MODULE_FROZEN_LEXER(source, content, content_len, 0); + *data = lex; + } + #endif + + #if MICROPY_MODULE_FROZEN_MPY + if (i >= num_str) { + *frozen_type = MP_FROZEN_MPY; + // Load the corresponding index as a raw_code, taking + // into account any string entries to offset by. + *data = (void *)mp_frozen_mpy_content[i - num_str]; + } + #endif + } - for (int i = 0; *name != 0; i++) { - size_t l = strlen(name); - if (l >= len && !memcmp(str, name, len)) { - if (name[len] == 0) { return MP_IMPORT_STAT_FILE; } else if (name[len] == '/') { + // Matches up to directory separator, this is a valid + // directory path. return MP_IMPORT_STAT_DIR; } } - name += l + 1; + // Skip null separator. + name += entry_len + 1; } - return MP_IMPORT_STAT_NO_EXIST; -} - -mp_import_stat_t mp_frozen_stat(const char *str) { - mp_import_stat_t stat; - - #if MICROPY_MODULE_FROZEN_STR - stat = mp_frozen_stat_helper(mp_frozen_str_names, str); - if (stat != MP_IMPORT_STAT_NO_EXIST) { - return stat; - } - #endif - - #if MICROPY_MODULE_FROZEN_MPY - stat = mp_frozen_stat_helper(mp_frozen_mpy_names, str); - if (stat != MP_IMPORT_STAT_NO_EXIST) { - return stat; - } - #endif return MP_IMPORT_STAT_NO_EXIST; } -int mp_find_frozen_module(const char *str, size_t len, void **data) { - // If the frozen module pseudo dir (e.g., ".frozen/") is a prefix of str, remove it. - if (strncmp(str, MP_FROZEN_FAKE_DIR_SLASH, MP_FROZEN_FAKE_DIR_SLASH_LENGTH) == 0) { - str = str + MP_FROZEN_FAKE_DIR_SLASH_LENGTH; - len = len - MP_FROZEN_FAKE_DIR_SLASH_LENGTH; - } - - #if MICROPY_MODULE_FROZEN_STR - mp_lexer_t *lex = mp_lexer_frozen_str(str, len); - if (lex != NULL) { - *data = lex; - return MP_FROZEN_STR; - } - #endif - #if MICROPY_MODULE_FROZEN_MPY - const mp_raw_code_t *rc = mp_find_frozen_mpy(str, len); - if (rc != NULL) { - *data = (void *)rc; - return MP_FROZEN_MPY; - } - #endif - return MP_FROZEN_NONE; -} - -#endif +#endif // MICROPY_MODULE_FROZEN diff --git a/py/frozenmod.h b/py/frozenmod.h index 51c86f29f8..0a907b8785 100644 --- a/py/frozenmod.h +++ b/py/frozenmod.h @@ -35,18 +35,6 @@ enum { MP_FROZEN_MPY, }; -// Frozen modules are in a pseudo-directory, so sys.path can control how they're found. -#define MP_FROZEN_FAKE_DIR ".frozen" -#define MP_FROZEN_FAKE_DIR_LENGTH (sizeof(MP_FROZEN_FAKE_DIR) - 1) - -#define MP_FROZEN_FAKE_DIR_SLASH (MP_FROZEN_FAKE_DIR "/") -#define MP_FROZEN_FAKE_DIR_SLASH_LENGTH (sizeof(MP_FROZEN_FAKE_DIR_SLASH) - 1) - -// This should match MP_FROZEN_FAKE_DIR. -#define MP_FROZEN_FAKE_DIR_QSTR MP_QSTR__dot_frozen - -int mp_find_frozen_module(const char *str, size_t len, void **data); -const char *mp_find_frozen_str(const char *str, size_t str_len, size_t *len); -mp_import_stat_t mp_frozen_stat(const char *str); +mp_import_stat_t mp_find_frozen_module(const char *str, int *frozen_type, void **data); #endif // MICROPY_INCLUDED_PY_FROZENMOD_H diff --git a/py/gc.c b/py/gc.c index 69ab969da7..826540d353 100644 --- a/py/gc.c +++ b/py/gc.c @@ -238,6 +238,7 @@ STATIC void gc_mark_subtree(size_t block) { // Start with the block passed in the argument. size_t sp = 0; for (;;) { + MICROPY_GC_HOOK_LOOP // work out number of consecutive blocks in the chain starting with this one size_t n_blocks = 0; do { @@ -247,6 +248,7 @@ STATIC void gc_mark_subtree(size_t block) { // check this block's children void **ptrs = (void **)PTR_FROM_BLOCK(block); for (size_t i = n_blocks * BYTES_PER_BLOCK / sizeof(void *); i > 0; i--, ptrs++) { + MICROPY_GC_HOOK_LOOP void *ptr = *ptrs; if (VERIFY_PTR(ptr)) { // Mark and push this pointer @@ -280,6 +282,7 @@ STATIC void gc_deal_with_stack_overflow(void) { // scan entire memory looking for blocks which have been marked but not their children for (size_t block = 0; block < MP_STATE_MEM(gc_alloc_table_byte_len) * BLOCKS_PER_ATB; block++) { + MICROPY_GC_HOOK_LOOP // trace (again) if mark bit set if (ATB_GET_KIND(block) == AT_MARK) { gc_mark_subtree(block); @@ -295,6 +298,7 @@ STATIC void gc_sweep(void) { // free unmarked heads and their tails int free_tail = 0; for (size_t block = 0; block < MP_STATE_MEM(gc_alloc_table_byte_len) * BLOCKS_PER_ATB; block++) { + MICROPY_GC_HOOK_LOOP switch (ATB_GET_KIND(block)) { case AT_HEAD: #if MICROPY_ENABLE_FINALISER @@ -407,6 +411,7 @@ static void *gc_get_ptr(void **ptrs, int i) { void gc_collect_root(void **ptrs, size_t len) { for (size_t i = 0; i < len; i++) { + MICROPY_GC_HOOK_LOOP void *ptr = gc_get_ptr(ptrs, i); gc_mark(ptr); } diff --git a/py/genlast.py b/py/genlast.py index 0071c7b849..ad44745d97 100644 --- a/py/genlast.py +++ b/py/genlast.py @@ -48,6 +48,7 @@ def preprocess(command, output_dir, fn): process_file(fn, output_dir, output) except Exception as e: print(e, file=sys.stderr) + raise def maybe_preprocess(command, output_dir, fn): @@ -72,6 +73,18 @@ if __name__ == "__main__": # Mac and Windows use 'spawn'. Uncomment this during testing to catch spawn-specific problems on Linux. # multiprocessing.set_start_method("spawn") executor = ProcessPoolExecutor(max_workers=multiprocessing.cpu_count() + 1) - executor.map(maybe_preprocess, itertools.repeat(command), itertools.repeat(output_dir), check) - executor.map(preprocess, itertools.repeat(command), itertools.repeat(output_dir), always) + results = [] + try: + results.extend( + executor.map( + maybe_preprocess, itertools.repeat(command), itertools.repeat(output_dir), check + ) + ) + results.extend( + executor.map( + preprocess, itertools.repeat(command), itertools.repeat(output_dir), always + ) + ) + except subprocess.CalledProcessError: + raise SystemExit(1) executor.shutdown() diff --git a/py/lexer.c b/py/lexer.c index ce48adbfa5..196f9a2644 100644 --- a/py/lexer.c +++ b/py/lexer.c @@ -365,9 +365,16 @@ STATIC void parse_string_literal(mp_lexer_t *lex, bool is_raw, bool is_fstring) // (MicroPython limitation) note: this is completely unaware of // Python syntax and will not handle any expression containing '}' or ':'. // e.g. f'{"}"}' or f'{foo({})}'. - while (!is_end(lex) && !is_char_or(lex, ':', '}')) { + unsigned int nested_bracket_level = 0; + while (!is_end(lex) && (nested_bracket_level != 0 || !is_char_or(lex, ':', '}'))) { + unichar c = CUR_CHAR(lex); + if (c == '[' || c == '{') { + nested_bracket_level += 1; + } else if (c == ']' || c == '}') { + nested_bracket_level -= 1; + } // like the default case at the end of this function, stay 8-bit clean - vstr_add_byte(&lex->fstring_args, CUR_CHAR(lex)); + vstr_add_byte(&lex->fstring_args, c); next_char(lex); } if (lex->fstring_args.buf[lex->fstring_args.len - 1] == '=') { diff --git a/py/makeversionhdr.py b/py/makeversionhdr.py index 12eaa3d3f1..da6f7c9f59 100644 --- a/py/makeversionhdr.py +++ b/py/makeversionhdr.py @@ -1,29 +1,25 @@ """ Generate header file with macros defining MicroPython version info. -This script works with Python 2.6, 2.7, 3.3 and 3.4. +This script works with Python 3.7 and newer """ from __future__ import print_function import sys import os +import pathlib import datetime import subprocess +tools_describe = str(pathlib.Path(__file__).parent.parent / "tools/describe") + def get_version_info_from_git(): - # Python 2.6 doesn't have check_output, so check for that - try: - subprocess.check_output - subprocess.check_call - except AttributeError: - return None - # Note: git describe doesn't work if no tag is available try: git_tag = subprocess.check_output( - ["git", "describe", "--tags", "--dirty", "--always", "--match", "[1-9].*"], + [tools_describe], stderr=subprocess.STDOUT, universal_newlines=True, ).strip() diff --git a/py/map.c b/py/map.c index dc5d4b061a..092adf94ee 100644 --- a/py/map.c +++ b/py/map.c @@ -42,6 +42,27 @@ #define DEBUG_printf(...) (void)0 #endif +#if MICROPY_OPT_MAP_LOOKUP_CACHE +// MP_STATE_VM(map_lookup_cache) provides a cache of index to the last known +// position of that index in any map. On a cache hit, this allows +// short-circuiting the full linear search in the case of an ordered map +// (i.e. all builtin modules and objects' locals dicts), and computation of +// the hash (and potentially some linear probing) in the case of a regular +// map. Note the same cache is shared across all maps. + +// Gets the index into the cache for this index. Shift down by two to remove +// mp_obj_t tag bits. +#define MAP_CACHE_OFFSET(index) ((((uintptr_t)(index)) >> 2) % MICROPY_OPT_MAP_LOOKUP_CACHE_SIZE) +// Gets the map cache entry for the corresponding index. +#define MAP_CACHE_ENTRY(index) (MP_STATE_VM(map_lookup_cache)[MAP_CACHE_OFFSET(index)]) +// Retrieve the mp_obj_t at the location suggested by the cache. +#define MAP_CACHE_GET(map, index) (&(map)->table[MAP_CACHE_ENTRY(index) % (map)->alloc]) +// Update the cache for this index. +#define MAP_CACHE_SET(index, pos) MAP_CACHE_ENTRY(index) = (pos) & 0xff; +#else +#define MAP_CACHE_SET(index, pos) +#endif + // This table of sizes is used to control the growth of hash tables. // The first set of sizes are chosen so the allocation fits exactly in a // 4-word GC block, and it's not so important for these small values to be @@ -134,10 +155,22 @@ STATIC void mp_map_rehash(mp_map_t *map) { // - returns slot, with key non-null and value=MP_OBJ_NULL if it was added // MP_MAP_LOOKUP_REMOVE_IF_FOUND behaviour: // - returns NULL if not found, else the slot if was found in with key null and value non-null -mp_map_elem_t *PLACE_IN_ITCM(mp_map_lookup)(mp_map_t * map, mp_obj_t index, mp_map_lookup_kind_t lookup_kind) { +mp_map_elem_t *MICROPY_WRAP_MP_MAP_LOOKUP(mp_map_lookup)(mp_map_t * map, mp_obj_t index, mp_map_lookup_kind_t lookup_kind) { // If the map is a fixed array then we must only be called for a lookup assert(!map->is_fixed || lookup_kind == MP_MAP_LOOKUP); + #if MICROPY_OPT_MAP_LOOKUP_CACHE + // Try the cache for lookup or add-if-not-found. + if (lookup_kind != MP_MAP_LOOKUP_REMOVE_IF_FOUND && map->alloc) { + mp_map_elem_t *slot = MAP_CACHE_GET(map, index); + // Note: Just comparing key for value equality will have false negatives, but + // these will be handled by the regular path below. + if (slot->key == index) { + return slot; + } + } + #endif + // Work out if we can compare just pointers bool compare_only_ptrs = map->all_keys_are_qstrs; if (compare_only_ptrs) { @@ -174,6 +207,7 @@ mp_map_elem_t *PLACE_IN_ITCM(mp_map_lookup)(mp_map_t * map, mp_obj_t index, mp_m elem->value = value; } #endif + MAP_CACHE_SET(index, elem - map->table); return elem; } } @@ -256,6 +290,7 @@ mp_map_elem_t *PLACE_IN_ITCM(mp_map_lookup)(mp_map_t * map, mp_obj_t index, mp_m } // keep slot->value so that caller can access it if needed } + MAP_CACHE_SET(index, pos); return slot; } diff --git a/py/mkrules.cmake b/py/mkrules.cmake index 9d08017931..cb5fdabf6b 100644 --- a/py/mkrules.cmake +++ b/py/mkrules.cmake @@ -10,6 +10,15 @@ set(MICROPY_QSTRDEFS_COLLECTED "${MICROPY_GENHDR_DIR}/qstrdefs.collected.h") set(MICROPY_QSTRDEFS_PREPROCESSED "${MICROPY_GENHDR_DIR}/qstrdefs.preprocessed.h") set(MICROPY_QSTRDEFS_GENERATED "${MICROPY_GENHDR_DIR}/qstrdefs.generated.h") +# Need to do this before extracting MICROPY_CPP_DEF below. Rest of frozen +# manifest handling is at the end of this file. +if(MICROPY_FROZEN_MANIFEST) + target_compile_definitions(${MICROPY_TARGET} PUBLIC + MICROPY_QSTR_EXTRA_POOL=mp_qstr_frozen_const_pool + MICROPY_MODULE_FROZEN_MPY=\(1\) + ) +endif() + # Provide defaults for preprocessor flags if not already defined if(NOT MICROPY_CPP_FLAGS) get_target_property(MICROPY_CPP_INC ${MICROPY_TARGET} INCLUDE_DIRECTORIES) @@ -120,10 +129,7 @@ if(MICROPY_FROZEN_MANIFEST) ${MICROPY_FROZEN_CONTENT} ) - target_compile_definitions(${MICROPY_TARGET} PUBLIC - MICROPY_QSTR_EXTRA_POOL=mp_qstr_frozen_const_pool - MICROPY_MODULE_FROZEN_MPY=\(1\) - ) + # Note: target_compile_definitions already added earlier. if(NOT MICROPY_LIB_DIR) set(MICROPY_LIB_DIR ${MICROPY_DIR}/../micropython-lib) diff --git a/py/mkrules.mk b/py/mkrules.mk index b121260c07..6bef64fd82 100644 --- a/py/mkrules.mk +++ b/py/mkrules.mk @@ -125,46 +125,18 @@ $(MICROPY_MPYCROSS_DEPENDENCY): $(MAKE) -C $(dir $@) endif -ifneq ($(FROZEN_MANIFEST),) -# to build frozen_content.c from a manifest -$(BUILD)/frozen_content.c: FORCE $(BUILD)/genhdr/qstrdefs.generated.h | $(MICROPY_MPYCROSS_DEPENDENCY) - $(Q)$(MAKE_MANIFEST) -o $@ -v "MPY_DIR=$(TOP)" -v "MPY_LIB_DIR=$(MPY_LIB_DIR)" -v "PORT_DIR=$(shell pwd)" -v "BOARD_DIR=$(BOARD_DIR)" -b "$(BUILD)" $(if $(MPY_CROSS_FLAGS),-f"$(MPY_CROSS_FLAGS)",) --mpy-tool-flags="$(MPY_TOOL_FLAGS)" $(FROZEN_MANIFEST) - ifneq ($(FROZEN_DIR),) -$(error FROZEN_DIR cannot be used in conjunction with FROZEN_MANIFEST) +$(error Support for FROZEN_DIR was removed. Please use manifest.py instead, see https://docs.micropython.org/en/latest/reference/manifest.html) endif ifneq ($(FROZEN_MPY_DIR),) -$(error FROZEN_MPY_DIR cannot be used in conjunction with FROZEN_MANIFEST) -endif +$(error Support for FROZEN_MPY_DIR was removed. Please use manifest.py instead, see https://docs.micropython.org/en/latest/reference/manifest.html) endif -ifneq ($(FROZEN_DIR),) -$(info Warning: FROZEN_DIR is deprecated in favour of FROZEN_MANIFEST) -$(BUILD)/frozen.c: $(wildcard $(FROZEN_DIR)/*) $(HEADER_BUILD) $(FROZEN_EXTRA_DEPS) - $(STEPECHO) "Generating $@" - $(Q)$(MAKE_FROZEN) $(FROZEN_DIR) > $@ -endif - -ifneq ($(FROZEN_MPY_DIRS),) -# Copy all the modules and single python files to freeze to a common area, omitting top-level dirs (the repo names). -# Do any preprocessing necessary: currently, this adds version information, removes examples, and -# non-library .py files in the modules (setup.py and conf.py) -# Then compile .mpy files from all the .py files, placing them in the same directories as the .py files. -$(BUILD)/frozen_mpy: $(FROZEN_MPY_DIRS) - $(ECHO) FREEZE $(FROZEN_MPY_DIRS) - $(Q)$(MKDIR) -p $@ - $(Q)$(PREPROCESS_FROZEN_MODULES) -o $@ $(FROZEN_MPY_DIRS) - $(Q)$(CD) $@ && \ -$(FIND) -L . -type f -name '*.py' | sed 's=^\./==' | \ -xargs -n1 "$(abspath $(MICROPY_MPYCROSS_DEPENDENCY))" $(MPY_CROSS_FLAGS) - -# to build frozen_mpy.c from all .mpy files -# You need to define MPY_TOOL_LONGINT_IMPL in mpconfigport.mk -# if the default will not work (mpz is the default). -$(BUILD)/frozen_mpy.c: $(BUILD)/frozen_mpy $(BUILD)/genhdr/qstrdefs.generated.h $(TOP)/tools/mpy-tool.py - $(STEPECHO) "Creating $@" - $(Q)$(MPY_TOOL) $(MPY_TOOL_LONGINT_IMPL) -f -q $(BUILD)/genhdr/qstrdefs.preprocessed.h $(shell $(FIND) -L $(BUILD)/frozen_mpy -type f -name '*.mpy') > $@ +ifneq ($(FROZEN_MANIFEST),) +# to build frozen_content.c from a manifest +$(BUILD)/frozen_content.c: FORCE $(FROZEN_MANIFEST) $(BUILD)/genhdr/qstrdefs.generated.h | $(MICROPY_MPYCROSS_DEPENDENCY) $(TOP)/tools/makemanifest.py + $(Q)$(MAKE_MANIFEST) -o $@ -v "MPY_DIR=$(TOP)" -v "MPY_LIB_DIR=$(MPY_LIB_DIR)" -v "PORT_DIR=$(shell pwd)" -v "BOARD_DIR=$(BOARD_DIR)" -b "$(BUILD)" $(if $(MPY_CROSS_FLAGS),-f"$(MPY_CROSS_FLAGS)",) --mpy-tool-flags="$(MPY_TOOL_FLAGS)" $(FROZEN_MANIFEST) endif ifneq ($(PROG),) @@ -220,27 +192,6 @@ clean: $(RM) -rf $(BUILD) $(CLEAN_EXTRA) .PHONY: clean -# Clean every non-git file from FROZEN_DIR/FROZEN_MPY_DIR, but making a backup. -# We run rmdir below to avoid empty backup dir (it will silently fail if backup -# is non-empty). -clean-frozen: - if [ -n "$(FROZEN_MPY_DIR)" ]; then \ - backup_dir=$(FROZEN_MPY_DIR).$$(date +%Y%m%dT%H%M%S); mkdir $$backup_dir; \ - cd $(FROZEN_MPY_DIR); git status --ignored -u all -s . | awk ' {print $$2}' \ - | xargs --no-run-if-empty cp --parents -t ../$$backup_dir; \ - rmdir ../$$backup_dir 2>/dev/null || true; \ - git clean -d -f .; \ - fi - - if [ -n "$(FROZEN_DIR)" ]; then \ - backup_dir=$(FROZEN_DIR).$$(date +%Y%m%dT%H%M%S); mkdir $$backup_dir; \ - cd $(FROZEN_DIR); git status --ignored -u all -s . | awk ' {print $$2}' \ - | xargs --no-run-if-empty cp --parents -t ../$$backup_dir; \ - rmdir ../$$backup_dir 2>/dev/null || true; \ - git clean -d -f .; \ - fi -.PHONY: clean-frozen - print-cfg: $(ECHO) "PY_SRC = $(PY_SRC)" $(ECHO) "BUILD = $(BUILD)" diff --git a/py/modbuiltins.c b/py/modbuiltins.c index e56b43047a..ebdbd52dff 100644 --- a/py/modbuiltins.c +++ b/py/modbuiltins.c @@ -786,6 +786,7 @@ STATIC const mp_rom_map_elem_t mp_module_builtins_globals_table[] = { // Extra builtins as defined by a port MICROPY_PORT_BUILTINS + MICROPY_PORT_EXTRA_BUILTINS }; MP_DEFINE_CONST_DICT(mp_module_builtins_globals, mp_module_builtins_globals_table); diff --git a/py/modio.c b/py/modio.c index 18918cf3ce..819a9976a0 100644 --- a/py/modio.c +++ b/py/modio.c @@ -212,61 +212,18 @@ STATIC const mp_obj_type_t mp_type_bufwriter = { }; #endif // MICROPY_PY_IO_BUFFEREDWRITER -#if MICROPY_PY_IO_RESOURCE_STREAM -STATIC mp_obj_t resource_stream(mp_obj_t package_in, mp_obj_t path_in) { - VSTR_FIXED(path_buf, MICROPY_ALLOC_PATH_MAX); - size_t len; - - // As an extension to pkg_resources.resource_stream(), we support - // package parameter being None, the path_in is interpreted as a - // raw path. - if (package_in != mp_const_none) { - // Pass "True" as sentinel value in fromlist to force returning of leaf module - mp_obj_t pkg = mp_import_name(mp_obj_str_get_qstr(package_in), mp_const_true, MP_OBJ_NEW_SMALL_INT(0)); - - mp_obj_t dest[2]; - mp_load_method_maybe(pkg, MP_QSTR___path__, dest); - if (dest[0] == MP_OBJ_NULL) { - mp_raise_TypeError(NULL); - } - - const char *path = mp_obj_str_get_data(dest[0], &len); - vstr_add_strn(&path_buf, path, len); - vstr_add_byte(&path_buf, '/'); - } - - const char *path = mp_obj_str_get_data(path_in, &len); - vstr_add_strn(&path_buf, path, len); - - size_t file_len; - const char *data = mp_find_frozen_str(path_buf.buf, path_buf.len, &file_len); - if (data != NULL) { - mp_obj_stringio_t *o = m_new_obj(mp_obj_stringio_t); - o->base.type = &mp_type_bytesio; - o->vstr = m_new_obj(vstr_t); - vstr_init_fixed_buf(o->vstr, file_len + 1, (char *)data); - o->vstr->len = file_len; - o->pos = 0; - return MP_OBJ_FROM_PTR(o); - } - - mp_obj_t path_out = mp_obj_new_str(path_buf.buf, path_buf.len); - return mp_builtin_open(1, &path_out, (mp_map_t *)&mp_const_empty_map); -} -STATIC MP_DEFINE_CONST_FUN_OBJ_2(resource_stream_obj, resource_stream); -#endif - STATIC const mp_rom_map_elem_t mp_module_io_globals_table[] = { + #if CIRCUITPY + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_io) }, + #else { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_uio) }, + #endif // Note: mp_builtin_open_obj should be defined by port, it's not // part of the core. { MP_ROM_QSTR(MP_QSTR_open), MP_ROM_PTR(&mp_builtin_open_obj) }, #if MICROPY_PY_IO_IOBASE { MP_ROM_QSTR(MP_QSTR_IOBase), MP_ROM_PTR(&mp_type_iobase) }, #endif - #if MICROPY_PY_IO_RESOURCE_STREAM - { MP_ROM_QSTR(MP_QSTR_resource_stream), MP_ROM_PTR(&resource_stream_obj) }, - #endif #if MICROPY_PY_IO_FILEIO { MP_ROM_QSTR(MP_QSTR_FileIO), MP_ROM_PTR(&mp_type_fileio) }, #if MICROPY_CPYTHON_COMPAT diff --git a/py/modsys.c b/py/modsys.c index 6016570933..0ec5de1645 100644 --- a/py/modsys.c +++ b/py/modsys.c @@ -158,7 +158,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_sys_atexit_obj, mp_sys_atexit); #endif #if MICROPY_PY_SYS_SETTRACE -// settrace(tracefunc): Set the system’s trace function. +// settrace(tracefunc): Set the system's trace function. STATIC mp_obj_t mp_sys_settrace(mp_obj_t obj) { return mp_prof_settrace(obj); } diff --git a/py/mpconfig.h b/py/mpconfig.h index 98a11c15ad..d66d615996 100644 --- a/py/mpconfig.h +++ b/py/mpconfig.h @@ -50,6 +50,31 @@ #define CIRCUITPY 0 #endif +// Disable all optional features (i.e. minimal port). +#define MICROPY_CONFIG_ROM_LEVEL_MINIMUM (0) +// Only enable core features (constrained flash, e.g. STM32L072) +#define MICROPY_CONFIG_ROM_LEVEL_CORE_FEATURES (10) +// Enable most common features (small on-device flash, e.g. STM32F411) +#define MICROPY_CONFIG_ROM_LEVEL_BASIC_FEATURES (20) +// Enable convenience features (medium on-device flash, e.g. STM32F405) +#define MICROPY_CONFIG_ROM_LEVEL_EXTRA_FEATURES (30) +// Enable all common features (large/external flash, rp2, unix) +#define MICROPY_CONFIG_ROM_LEVEL_FULL_FEATURES (40) +// Enable everything (e.g. coverage) +#define MICROPY_CONFIG_ROM_LEVEL_EVERYTHING (50) + +// Ports/boards should set this, but default to level=core. +#ifndef MICROPY_CONFIG_ROM_LEVEL +#define MICROPY_CONFIG_ROM_LEVEL (MICROPY_CONFIG_ROM_LEVEL_CORE_FEATURES) +#endif + +// Helper macros for "have at least this level". +#define MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES (MICROPY_CONFIG_ROM_LEVEL >= MICROPY_CONFIG_ROM_LEVEL_CORE_FEATURES) +#define MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_BASIC_FEATURES (MICROPY_CONFIG_ROM_LEVEL >= MICROPY_CONFIG_ROM_LEVEL_BASIC_FEATURES) +#define MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES (MICROPY_CONFIG_ROM_LEVEL >= MICROPY_CONFIG_ROM_LEVEL_EXTRA_FEATURES) +#define MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_FULL_FEATURES (MICROPY_CONFIG_ROM_LEVEL >= MICROPY_CONFIG_ROM_LEVEL_FULL_FEATURES) +#define MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EVERYTHING (MICROPY_CONFIG_ROM_LEVEL >= MICROPY_CONFIG_ROM_LEVEL_EVERYTHING) + // Any options not explicitly set in mpconfigport.h will get default // values below. @@ -144,7 +169,7 @@ // Support automatic GC when reaching allocation threshold, // configurable by gc.threshold(). #ifndef MICROPY_GC_ALLOC_THRESHOLD -#define MICROPY_GC_ALLOC_THRESHOLD (1) +#define MICROPY_GC_ALLOC_THRESHOLD (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif // Number of bytes to allocate initially when creating new chunks to store @@ -243,7 +268,11 @@ // Number of bytes used to store qstr hash #ifndef MICROPY_QSTR_BYTES_IN_HASH +#if MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES #define MICROPY_QSTR_BYTES_IN_HASH (2) +#else +#define MICROPY_QSTR_BYTES_IN_HASH (1) +#endif #endif // Avoid using C stack when making Python function calls. C stack still @@ -385,7 +414,7 @@ // Whether to include the compiler #ifndef MICROPY_ENABLE_COMPILER -#define MICROPY_ENABLE_COMPILER (1) +#define MICROPY_ENABLE_COMPILER (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif // Whether the compiler is dynamically configurable (ie at runtime) @@ -396,49 +425,47 @@ // Configure dynamic compiler macros #if MICROPY_DYNAMIC_COMPILER -#define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE_DYNAMIC (mp_dynamic_compiler.opt_cache_map_lookup_in_bytecode) #define MICROPY_PY_BUILTINS_STR_UNICODE_DYNAMIC (mp_dynamic_compiler.py_builtins_str_unicode) #else -#define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE_DYNAMIC MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE #define MICROPY_PY_BUILTINS_STR_UNICODE_DYNAMIC MICROPY_PY_BUILTINS_STR_UNICODE #endif // Whether to enable constant folding; eg 1+2 rewritten as 3 #ifndef MICROPY_COMP_CONST_FOLDING -#define MICROPY_COMP_CONST_FOLDING (1) +#define MICROPY_COMP_CONST_FOLDING (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif // Whether to enable optimisations for constant literals, eg OrderedDict #ifndef MICROPY_COMP_CONST_LITERAL -#define MICROPY_COMP_CONST_LITERAL (1) +#define MICROPY_COMP_CONST_LITERAL (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif // Whether to enable lookup of constants in modules; eg module.CONST #ifndef MICROPY_COMP_MODULE_CONST -#define MICROPY_COMP_MODULE_CONST (0) +#define MICROPY_COMP_MODULE_CONST (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to enable constant optimisation; id = const(value) #ifndef MICROPY_COMP_CONST -#define MICROPY_COMP_CONST (1) +#define MICROPY_COMP_CONST (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif // Whether to enable optimisation of: a, b = c, d // Costs 124 bytes (Thumb2) #ifndef MICROPY_COMP_DOUBLE_TUPLE_ASSIGN -#define MICROPY_COMP_DOUBLE_TUPLE_ASSIGN (1) +#define MICROPY_COMP_DOUBLE_TUPLE_ASSIGN (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif // Whether to enable optimisation of: a, b, c = d, e, f // Requires MICROPY_COMP_DOUBLE_TUPLE_ASSIGN and costs 68 bytes (Thumb2) #ifndef MICROPY_COMP_TRIPLE_TUPLE_ASSIGN -#define MICROPY_COMP_TRIPLE_TUPLE_ASSIGN (0) +#define MICROPY_COMP_TRIPLE_TUPLE_ASSIGN (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to enable optimisation of: return a if b else c // Costs about 80 bytes (Thumb2) and saves 2 bytes of bytecode for each use #ifndef MICROPY_COMP_RETURN_IF_EXPR -#define MICROPY_COMP_RETURN_IF_EXPR (0) +#define MICROPY_COMP_RETURN_IF_EXPR (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to include parsing of f-string literals @@ -511,23 +538,36 @@ #define MICROPY_OPT_COMPUTED_GOTO_SAVE_SPACE (0) #endif -// Whether to cache result of map lookups in LOAD_NAME, LOAD_GLOBAL, LOAD_ATTR, -// STORE_ATTR bytecodes. Uses 1 byte extra RAM for each of these opcodes and -// uses a bit of extra code ROM, but greatly improves lookup speed. -#ifndef MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE -#define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE (0) +// Optimise the fast path for loading attributes from instance types. Increases +// Thumb2 code size by about 48 bytes. +#ifndef MICROPY_OPT_LOAD_ATTR_FAST_PATH +#define MICROPY_OPT_LOAD_ATTR_FAST_PATH (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) +#endif + +// Use extra RAM to cache map lookups by remembering the likely location of +// the index. Avoids the hash computation on unordered maps, and avoids the +// linear search on ordered (especially in-ROM) maps. Can provide a +10-15% +// performance improvement on benchmarks involving lots of attribute access +// or dictionary lookup. +#ifndef MICROPY_OPT_MAP_LOOKUP_CACHE +#define MICROPY_OPT_MAP_LOOKUP_CACHE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) +#endif + +// How much RAM (in bytes) to use for the map lookup cache. +#ifndef MICROPY_OPT_MAP_LOOKUP_CACHE_SIZE +#define MICROPY_OPT_MAP_LOOKUP_CACHE_SIZE (128) #endif // Whether to use fast versions of bitwise operations (and, or, xor) when the // arguments are both positive. Increases Thumb2 code size by about 250 bytes. #ifndef MICROPY_OPT_MPZ_BITWISE -#define MICROPY_OPT_MPZ_BITWISE (0) +#define MICROPY_OPT_MPZ_BITWISE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether math.factorial is large, fast and recursive (1) or small and slow (0). #ifndef MICROPY_OPT_MATH_FACTORIAL -#define MICROPY_OPT_MATH_FACTORIAL (0) +#define MICROPY_OPT_MATH_FACTORIAL (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif /*****************************************************************************/ @@ -537,7 +577,7 @@ // When disabled, only importing of built-in modules is supported // When enabled, a port must implement mp_import_stat (among other things) #ifndef MICROPY_ENABLE_EXTERNAL_IMPORT -#define MICROPY_ENABLE_EXTERNAL_IMPORT (1) +#define MICROPY_ENABLE_EXTERNAL_IMPORT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif // Whether to use the POSIX reader for importing files @@ -587,9 +627,14 @@ #define MICROPY_ENABLE_GC (0) #endif +// Hook to run code during time consuming garbage collector operations +#ifndef MICROPY_GC_HOOK_LOOP +#define MICROPY_GC_HOOK_LOOP +#endif + // Whether to enable finalisers in the garbage collector (ie call __del__) #ifndef MICROPY_ENABLE_FINALISER -#define MICROPY_ENABLE_FINALISER (0) +#define MICROPY_ENABLE_FINALISER (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to enable a separate allocator for the Python stack. @@ -606,7 +651,7 @@ // Whether to check C stack usage. C stack used for calling Python functions, // etc. Not checking means segfault on overflow. #ifndef MICROPY_STACK_CHECK -#define MICROPY_STACK_CHECK (0) +#define MICROPY_STACK_CHECK (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to measure maximum stack excursion @@ -626,7 +671,7 @@ // Whether to provide the mp_kbd_exception object, and micropython.kbd_intr function #ifndef MICROPY_KBD_EXCEPTION -#define MICROPY_KBD_EXCEPTION (0) +#define MICROPY_KBD_EXCEPTION (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Prefer to raise KeyboardInterrupt asynchronously (from signal or interrupt @@ -637,7 +682,7 @@ // Whether to include REPL helper function #ifndef MICROPY_HELPER_REPL -#define MICROPY_HELPER_REPL (0) +#define MICROPY_HELPER_REPL (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Allow enabling debug prints after each REPL line @@ -647,7 +692,7 @@ // Whether to include emacs-style readline behavior in REPL #ifndef MICROPY_REPL_EMACS_KEYS -#define MICROPY_REPL_EMACS_KEYS (0) +#define MICROPY_REPL_EMACS_KEYS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to include emacs-style word movement/kill readline behavior in REPL. @@ -667,7 +712,7 @@ // Whether to implement auto-indent in REPL #ifndef MICROPY_REPL_AUTO_INDENT -#define MICROPY_REPL_AUTO_INDENT (0) +#define MICROPY_REPL_AUTO_INDENT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether port requires event-driven REPL functions @@ -696,7 +741,7 @@ typedef long long mp_longint_impl_t; // Whether to include information in the byte code to determine source // line number (increases RAM usage, but doesn't slow byte code execution) #ifndef MICROPY_ENABLE_SOURCE_LINE -#define MICROPY_ENABLE_SOURCE_LINE (0) +#define MICROPY_ENABLE_SOURCE_LINE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to include doc strings (increases RAM usage) @@ -714,7 +759,13 @@ typedef long long mp_longint_impl_t; #define MICROPY_ERROR_REPORTING_DETAILED (3) #ifndef MICROPY_ERROR_REPORTING +#if MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_FULL_FEATURES +#define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_DETAILED) +#elif MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES #define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_NORMAL) +#else +#define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_TERSE) +#endif #endif // Whether issue warnings during compiling/execution @@ -770,7 +821,7 @@ typedef double mp_float_t; // TODO: Originally intended as generic category to not // add bunch of once-off options. May need refactoring later #ifndef MICROPY_CPYTHON_COMPAT -#define MICROPY_CPYTHON_COMPAT (1) +#define MICROPY_CPYTHON_COMPAT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif // Perform full checks as done by CPython. Disabling this @@ -779,12 +830,12 @@ typedef double mp_float_t; // grave issues (in other words, only user app should be, // affected, not system). #ifndef MICROPY_FULL_CHECKS -#define MICROPY_FULL_CHECKS (1) +#define MICROPY_FULL_CHECKS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif // Whether POSIX-semantics non-blocking streams are supported #ifndef MICROPY_STREAMS_NON_BLOCK -#define MICROPY_STREAMS_NON_BLOCK (0) +#define MICROPY_STREAMS_NON_BLOCK (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to provide stream functions with POSIX-like signatures @@ -795,17 +846,23 @@ typedef double mp_float_t; // Whether to call __init__ when importing builtin modules for the first time #ifndef MICROPY_MODULE_BUILTIN_INIT -#define MICROPY_MODULE_BUILTIN_INIT (0) +#define MICROPY_MODULE_BUILTIN_INIT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to support module-level __getattr__ (see PEP 562) #ifndef MICROPY_MODULE_GETATTR -#define MICROPY_MODULE_GETATTR (1) +#define MICROPY_MODULE_GETATTR (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif // Whether module weak links are supported #ifndef MICROPY_MODULE_WEAK_LINKS -#define MICROPY_MODULE_WEAK_LINKS (0) +#define MICROPY_MODULE_WEAK_LINKS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) +#endif + +// Whether to enable importing foo.py with __name__ set to '__main__' +// Used by the unix port for the -m flag. +#ifndef MICROPY_MODULE_OVERRIDE_MAIN_IMPORT +#define MICROPY_MODULE_OVERRIDE_MAIN_IMPORT (0) #endif // Whether frozen modules are supported in the form of strings @@ -825,7 +882,7 @@ typedef double mp_float_t; // Whether you can override builtins in the builtins module #ifndef MICROPY_CAN_OVERRIDE_BUILTINS -#define MICROPY_CAN_OVERRIDE_BUILTINS (0) +#define MICROPY_CAN_OVERRIDE_BUILTINS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to check that the "self" argument of a builtin method has the @@ -834,7 +891,7 @@ typedef double mp_float_t; // list.append([], 1). Without this check such calls will have undefined // behaviour (usually segfault) if the first argument is the wrong type. #ifndef MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG -#define MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG (1) +#define MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif // Whether to use internally defined errno's (otherwise system provided ones) @@ -849,7 +906,7 @@ typedef double mp_float_t; // Support for internal scheduler #ifndef MICROPY_ENABLE_SCHEDULER -#define MICROPY_ENABLE_SCHEDULER (0) +#define MICROPY_ENABLE_SCHEDULER (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Maximum number of entries in the scheduler @@ -884,41 +941,41 @@ typedef double mp_float_t; // inheritance makes some C functions inherently recursive, and adds a bit of // code overhead. #ifndef MICROPY_MULTIPLE_INHERITANCE -#define MICROPY_MULTIPLE_INHERITANCE (1) +#define MICROPY_MULTIPLE_INHERITANCE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif // Whether to implement attributes on functions #ifndef MICROPY_PY_FUNCTION_ATTRS -#define MICROPY_PY_FUNCTION_ATTRS (0) +#define MICROPY_PY_FUNCTION_ATTRS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to support the descriptors __get__, __set__, __delete__ // This costs some code size and makes load/store/delete of instance // attributes slower for the classes that use this feature #ifndef MICROPY_PY_DESCRIPTORS -#define MICROPY_PY_DESCRIPTORS (0) +#define MICROPY_PY_DESCRIPTORS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to support class __delattr__ and __setattr__ methods // This costs some code size and makes store/delete of instance // attributes slower for the classes that use this feature #ifndef MICROPY_PY_DELATTR_SETATTR -#define MICROPY_PY_DELATTR_SETATTR (0) +#define MICROPY_PY_DELATTR_SETATTR (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Support for async/await/async for/async with #ifndef MICROPY_PY_ASYNC_AWAIT -#define MICROPY_PY_ASYNC_AWAIT (1) +#define MICROPY_PY_ASYNC_AWAIT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif // Support for literal string interpolation, f-strings (see PEP 498, Python 3.6+) #ifndef MICROPY_PY_FSTRINGS -#define MICROPY_PY_FSTRINGS (0) +#define MICROPY_PY_FSTRINGS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Support for assignment expressions with := (see PEP 572, Python 3.8+) #ifndef MICROPY_PY_ASSIGN_EXPR -#define MICROPY_PY_ASSIGN_EXPR (1) +#define MICROPY_PY_ASSIGN_EXPR (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif // Non-standard .pend_throw() method for generators, allowing for @@ -927,7 +984,7 @@ typedef double mp_float_t; // to generator's .send() or .__next__(). (This is useful to implement // async schedulers.) #ifndef MICROPY_PY_GENERATOR_PEND_THROW -#define MICROPY_PY_GENERATOR_PEND_THROW (1) +#define MICROPY_PY_GENERATOR_PEND_THROW (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif // Issue a warning when comparing str and bytes objects @@ -937,7 +994,7 @@ typedef double mp_float_t; // Whether str object is proper unicode #ifndef MICROPY_PY_BUILTINS_STR_UNICODE -#define MICROPY_PY_BUILTINS_STR_UNICODE (0) +#define MICROPY_PY_BUILTINS_STR_UNICODE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to check for valid UTF-8 when converting bytes to str @@ -947,42 +1004,42 @@ typedef double mp_float_t; // Whether str.center() method provided #ifndef MICROPY_PY_BUILTINS_STR_CENTER -#define MICROPY_PY_BUILTINS_STR_CENTER (0) +#define MICROPY_PY_BUILTINS_STR_CENTER (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether str.count() method provided #ifndef MICROPY_PY_BUILTINS_STR_COUNT -#define MICROPY_PY_BUILTINS_STR_COUNT (1) +#define MICROPY_PY_BUILTINS_STR_COUNT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif // Whether str % (...) formatting operator provided #ifndef MICROPY_PY_BUILTINS_STR_OP_MODULO -#define MICROPY_PY_BUILTINS_STR_OP_MODULO (1) +#define MICROPY_PY_BUILTINS_STR_OP_MODULO (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif // Whether str.partition()/str.rpartition() method provided #ifndef MICROPY_PY_BUILTINS_STR_PARTITION -#define MICROPY_PY_BUILTINS_STR_PARTITION (0) +#define MICROPY_PY_BUILTINS_STR_PARTITION (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether str.splitlines() method provided #ifndef MICROPY_PY_BUILTINS_STR_SPLITLINES -#define MICROPY_PY_BUILTINS_STR_SPLITLINES (0) +#define MICROPY_PY_BUILTINS_STR_SPLITLINES (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to support bytearray object #ifndef MICROPY_PY_BUILTINS_BYTEARRAY -#define MICROPY_PY_BUILTINS_BYTEARRAY (1) +#define MICROPY_PY_BUILTINS_BYTEARRAY (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif // Whether to support dict.fromkeys() class method #ifndef MICROPY_PY_BUILTINS_DICT_FROMKEYS -#define MICROPY_PY_BUILTINS_DICT_FROMKEYS (1) +#define MICROPY_PY_BUILTINS_DICT_FROMKEYS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif // Whether to support memoryview object #ifndef MICROPY_PY_BUILTINS_MEMORYVIEW -#define MICROPY_PY_BUILTINS_MEMORYVIEW (0) +#define MICROPY_PY_BUILTINS_MEMORYVIEW (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to support memoryview.itemsize attribute @@ -992,39 +1049,39 @@ typedef double mp_float_t; // Whether to support set object #ifndef MICROPY_PY_BUILTINS_SET -#define MICROPY_PY_BUILTINS_SET (1) +#define MICROPY_PY_BUILTINS_SET (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif // Whether to support slice subscript operators and slice object #ifndef MICROPY_PY_BUILTINS_SLICE -#define MICROPY_PY_BUILTINS_SLICE (1) +#define MICROPY_PY_BUILTINS_SLICE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif // Whether to support slice attribute read access, // i.e. slice.start, slice.stop, slice.step #ifndef MICROPY_PY_BUILTINS_SLICE_ATTRS -#define MICROPY_PY_BUILTINS_SLICE_ATTRS (0) +#define MICROPY_PY_BUILTINS_SLICE_ATTRS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to support the .indices(len) method on slice objects #ifndef MICROPY_PY_BUILTINS_SLICE_INDICES -#define MICROPY_PY_BUILTINS_SLICE_INDICES (0) +#define MICROPY_PY_BUILTINS_SLICE_INDICES (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to support frozenset object #ifndef MICROPY_PY_BUILTINS_FROZENSET -#define MICROPY_PY_BUILTINS_FROZENSET (0) +#define MICROPY_PY_BUILTINS_FROZENSET (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to support property object #ifndef MICROPY_PY_BUILTINS_PROPERTY -#define MICROPY_PY_BUILTINS_PROPERTY (1) +#define MICROPY_PY_BUILTINS_PROPERTY (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif // Whether to implement the start/stop/step attributes (readback) on // the "range" builtin type. Rarely used, and costs ~60 bytes (x86). #ifndef MICROPY_PY_BUILTINS_RANGE_ATTRS -#define MICROPY_PY_BUILTINS_RANGE_ATTRS (1) +#define MICROPY_PY_BUILTINS_RANGE_ATTRS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif // Whether to support binary ops [only (in)equality is defined] between range @@ -1042,7 +1099,7 @@ typedef double mp_float_t; // Whether to support rounding of integers (incl bignum); eg round(123,-1)=120 #ifndef MICROPY_PY_BUILTINS_ROUND_INT -#define MICROPY_PY_BUILTINS_ROUND_INT (0) +#define MICROPY_PY_BUILTINS_ROUND_INT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to support complete set of special methods for user @@ -1051,7 +1108,7 @@ typedef double mp_float_t; // "Reverse" methods are controlled by // MICROPY_PY_REVERSE_SPECIAL_METHODS below. #ifndef MICROPY_PY_ALL_SPECIAL_METHODS -#define MICROPY_PY_ALL_SPECIAL_METHODS (0) +#define MICROPY_PY_ALL_SPECIAL_METHODS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to support all inplace arithmetic operarion methods @@ -1064,17 +1121,17 @@ typedef double mp_float_t; // (__radd__, etc.). Additionally gated by // MICROPY_PY_ALL_SPECIAL_METHODS. #ifndef MICROPY_PY_REVERSE_SPECIAL_METHODS -#define MICROPY_PY_REVERSE_SPECIAL_METHODS (0) +#define MICROPY_PY_REVERSE_SPECIAL_METHODS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to support compile function #ifndef MICROPY_PY_BUILTINS_COMPILE -#define MICROPY_PY_BUILTINS_COMPILE (0) +#define MICROPY_PY_BUILTINS_COMPILE (MICROPY_ENABLE_COMPILER && MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to support enumerate function(type) #ifndef MICROPY_PY_BUILTINS_ENUMERATE -#define MICROPY_PY_BUILTINS_ENUMERATE (1) +#define MICROPY_PY_BUILTINS_ENUMERATE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif // Whether to support eval and exec functions @@ -1085,43 +1142,43 @@ typedef double mp_float_t; // Whether to support the Python 2 execfile function #ifndef MICROPY_PY_BUILTINS_EXECFILE -#define MICROPY_PY_BUILTINS_EXECFILE (0) +#define MICROPY_PY_BUILTINS_EXECFILE (MICROPY_ENABLE_COMPILER && MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to support filter function(type) #ifndef MICROPY_PY_BUILTINS_FILTER -#define MICROPY_PY_BUILTINS_FILTER (1) +#define MICROPY_PY_BUILTINS_FILTER (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif // Whether to support reversed function(type) #ifndef MICROPY_PY_BUILTINS_REVERSED -#define MICROPY_PY_BUILTINS_REVERSED (1) +#define MICROPY_PY_BUILTINS_REVERSED (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif // Whether to define "NotImplemented" special constant #ifndef MICROPY_PY_BUILTINS_NOTIMPLEMENTED -#define MICROPY_PY_BUILTINS_NOTIMPLEMENTED (0) +#define MICROPY_PY_BUILTINS_NOTIMPLEMENTED (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to provide the built-in input() function. The implementation of this // uses shared/readline, so can only be enabled if the port uses this readline. #ifndef MICROPY_PY_BUILTINS_INPUT -#define MICROPY_PY_BUILTINS_INPUT (0) +#define MICROPY_PY_BUILTINS_INPUT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to support min/max functions #ifndef MICROPY_PY_BUILTINS_MIN_MAX -#define MICROPY_PY_BUILTINS_MIN_MAX (1) +#define MICROPY_PY_BUILTINS_MIN_MAX (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif // Support for calls to pow() with 3 integer arguments #ifndef MICROPY_PY_BUILTINS_POW3 -#define MICROPY_PY_BUILTINS_POW3 (0) +#define MICROPY_PY_BUILTINS_POW3 (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to provide the help function #ifndef MICROPY_PY_BUILTINS_HELP -#define MICROPY_PY_BUILTINS_HELP (0) +#define MICROPY_PY_BUILTINS_HELP (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Use this to configure the help text shown for help(). It should be a @@ -1132,17 +1189,17 @@ typedef double mp_float_t; // Add the ability to list the available modules when executing help('modules') #ifndef MICROPY_PY_BUILTINS_HELP_MODULES -#define MICROPY_PY_BUILTINS_HELP_MODULES (0) +#define MICROPY_PY_BUILTINS_HELP_MODULES (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to set __file__ for imported modules #ifndef MICROPY_PY___FILE__ -#define MICROPY_PY___FILE__ (1) +#define MICROPY_PY___FILE__ (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif // Whether to provide mem-info related functions in micropython module #ifndef MICROPY_PY_MICROPYTHON_MEM_INFO -#define MICROPY_PY_MICROPYTHON_MEM_INFO (0) +#define MICROPY_PY_MICROPYTHON_MEM_INFO (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to provide "micropython.stack_use" function @@ -1159,13 +1216,13 @@ typedef double mp_float_t; // underlying code is shared with "bytearray" builtin type, so to // get real savings, it should be disabled too. #ifndef MICROPY_PY_ARRAY -#define MICROPY_PY_ARRAY (1) +#define MICROPY_PY_ARRAY (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif // Whether to support slice assignments for array (and bytearray). // This is rarely used, but adds ~0.5K of code. #ifndef MICROPY_PY_ARRAY_SLICE_ASSIGN -#define MICROPY_PY_ARRAY_SLICE_ASSIGN (0) +#define MICROPY_PY_ARRAY_SLICE_ASSIGN (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to support nonstandard typecodes "O", "P" and "S" @@ -1177,22 +1234,22 @@ typedef double mp_float_t; // Whether to support attrtuple type (MicroPython extension) // It provides space-efficient tuples with attribute access #ifndef MICROPY_PY_ATTRTUPLE -#define MICROPY_PY_ATTRTUPLE (1) +#define MICROPY_PY_ATTRTUPLE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif // Whether to provide "collections" module #ifndef MICROPY_PY_COLLECTIONS -#define MICROPY_PY_COLLECTIONS (1) +#define MICROPY_PY_COLLECTIONS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif // Whether to provide "ucollections.deque" type #ifndef MICROPY_PY_COLLECTIONS_DEQUE -#define MICROPY_PY_COLLECTIONS_DEQUE (0) +#define MICROPY_PY_COLLECTIONS_DEQUE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to provide "collections.OrderedDict" type #ifndef MICROPY_PY_COLLECTIONS_ORDEREDDICT -#define MICROPY_PY_COLLECTIONS_ORDEREDDICT (0) +#define MICROPY_PY_COLLECTIONS_ORDEREDDICT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to provide the _asdict function for namedtuple @@ -1202,22 +1259,22 @@ typedef double mp_float_t; // Whether to provide "math" module #ifndef MICROPY_PY_MATH -#define MICROPY_PY_MATH (1) +#define MICROPY_PY_MATH (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif // Whether to provide special math functions: math.{erf,erfc,gamma,lgamma} #ifndef MICROPY_PY_MATH_SPECIAL_FUNCTIONS -#define MICROPY_PY_MATH_SPECIAL_FUNCTIONS (0) +#define MICROPY_PY_MATH_SPECIAL_FUNCTIONS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to provide math.factorial function #ifndef MICROPY_PY_MATH_FACTORIAL -#define MICROPY_PY_MATH_FACTORIAL (0) +#define MICROPY_PY_MATH_FACTORIAL (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to provide math.isclose function #ifndef MICROPY_PY_MATH_ISCLOSE -#define MICROPY_PY_MATH_ISCLOSE (0) +#define MICROPY_PY_MATH_ISCLOSE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to provide fix for atan2 Inf handling. @@ -1242,12 +1299,12 @@ typedef double mp_float_t; // Whether to provide "cmath" module #ifndef MICROPY_PY_CMATH -#define MICROPY_PY_CMATH (0) +#define MICROPY_PY_CMATH (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to provide "gc" module #ifndef MICROPY_PY_GC -#define MICROPY_PY_GC (1) +#define MICROPY_PY_GC (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif // Whether to return number of collected objects from gc.collect() @@ -1257,28 +1314,17 @@ typedef double mp_float_t; // Whether to provide "io" module #ifndef MICROPY_PY_IO -#define MICROPY_PY_IO (1) +#define MICROPY_PY_IO (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif // Whether to provide "io.IOBase" class to support user streams #ifndef MICROPY_PY_IO_IOBASE -#define MICROPY_PY_IO_IOBASE (0) -#endif - -// Whether to provide "uio.resource_stream()" function with -// the semantics of CPython's pkg_resources.resource_stream() -// (allows to access binary resources in frozen source packages). -// Note that the same functionality can be achieved in "pure -// Python" by prepocessing binary resources into Python source -// and bytecode-freezing it (with a simple helper module available -// e.g. in micropython-lib). -#ifndef MICROPY_PY_IO_RESOURCE_STREAM -#define MICROPY_PY_IO_RESOURCE_STREAM (0) +#define MICROPY_PY_IO_IOBASE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to provide "io.FileIO" class #ifndef MICROPY_PY_IO_FILEIO -#define MICROPY_PY_IO_FILEIO (0) +#define MICROPY_PY_IO_FILEIO (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to provide "io.BytesIO" class @@ -1293,17 +1339,22 @@ typedef double mp_float_t; // Whether to provide "struct" module #ifndef MICROPY_PY_STRUCT -#define MICROPY_PY_STRUCT (1) +#define MICROPY_PY_STRUCT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) #endif // Whether to provide "sys" module #ifndef MICROPY_PY_SYS -#define MICROPY_PY_SYS (1) +#define MICROPY_PY_SYS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_CORE_FEATURES) +#endif + +// Whether to initialise "sys.path" and "sys.argv" to their defaults in mp_init() +#ifndef MICROPY_PY_SYS_PATH_ARGV_DEFAULTS +#define MICROPY_PY_SYS_PATH_ARGV_DEFAULTS (MICROPY_PY_SYS) #endif // Whether to provide "sys.maxsize" constant #ifndef MICROPY_PY_SYS_MAXSIZE -#define MICROPY_PY_SYS_MAXSIZE (0) +#define MICROPY_PY_SYS_MAXSIZE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to provide "sys.modules" dictionary @@ -1339,18 +1390,18 @@ typedef double mp_float_t; // Whether to provide sys.{stdin,stdout,stderr} objects #ifndef MICROPY_PY_SYS_STDFILES -#define MICROPY_PY_SYS_STDFILES (0) +#define MICROPY_PY_SYS_STDFILES (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to provide sys.{stdin,stdout,stderr}.buffer object // This is implemented per-port #ifndef MICROPY_PY_SYS_STDIO_BUFFER -#define MICROPY_PY_SYS_STDIO_BUFFER (0) +#define MICROPY_PY_SYS_STDIO_BUFFER (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to provide "uerrno" module #ifndef MICROPY_PY_UERRNO -#define MICROPY_PY_UERRNO (0) +#define MICROPY_PY_UERRNO (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to provide the uerrno.errorcode dict @@ -1360,7 +1411,7 @@ typedef double mp_float_t; // Whether to provide "uselect" module (baremetal implementation) #ifndef MICROPY_PY_USELECT -#define MICROPY_PY_USELECT (0) +#define MICROPY_PY_USELECT (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to enable the select() function in the "uselect" module (baremetal @@ -1406,11 +1457,11 @@ typedef double mp_float_t; // Extended modules #ifndef MICROPY_PY_UASYNCIO -#define MICROPY_PY_UASYNCIO (0) +#define MICROPY_PY_UASYNCIO (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif #ifndef MICROPY_PY_UCTYPES -#define MICROPY_PY_UCTYPES (0) +#define MICROPY_PY_UCTYPES (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to provide SHORT, INT, LONG, etc. types in addition to @@ -1420,11 +1471,11 @@ typedef double mp_float_t; #endif #ifndef MICROPY_PY_UZLIB -#define MICROPY_PY_UZLIB (0) +#define MICROPY_PY_UZLIB (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif #ifndef MICROPY_PY_UJSON -#define MICROPY_PY_UJSON (0) +#define MICROPY_PY_UJSON (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to support the "separators" argument to dump, dumps @@ -1437,7 +1488,7 @@ typedef double mp_float_t; #endif #ifndef MICROPY_PY_URE -#define MICROPY_PY_URE (0) +#define MICROPY_PY_URE (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif #ifndef MICROPY_PY_URE_DEBUG @@ -1453,20 +1504,20 @@ typedef double mp_float_t; #endif #ifndef MICROPY_PY_URE_SUB -#define MICROPY_PY_URE_SUB (0) +#define MICROPY_PY_URE_SUB (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif #ifndef MICROPY_PY_UHEAPQ -#define MICROPY_PY_UHEAPQ (0) +#define MICROPY_PY_UHEAPQ (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif -// Optimized heap queue for relative timestamps +// Optimized heap queue for relative timestamps (only used by uasyncio v2) #ifndef MICROPY_PY_UTIMEQ #define MICROPY_PY_UTIMEQ (0) #endif #ifndef MICROPY_PY_UHASHLIB -#define MICROPY_PY_UHASHLIB (0) +#define MICROPY_PY_UHASHLIB (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif #ifndef MICROPY_PY_UHASHLIB_MD5 @@ -1495,25 +1546,70 @@ typedef double mp_float_t; #endif #ifndef MICROPY_PY_UBINASCII -#define MICROPY_PY_UBINASCII (0) +#define MICROPY_PY_UBINASCII (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Depends on MICROPY_PY_UZLIB #ifndef MICROPY_PY_UBINASCII_CRC32 -#define MICROPY_PY_UBINASCII_CRC32 (0) +#define MICROPY_PY_UBINASCII_CRC32 (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif #ifndef MICROPY_PY_URANDOM -#define MICROPY_PY_URANDOM (0) +#define MICROPY_PY_URANDOM (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif // Whether to include: randrange, randint, choice, random, uniform #ifndef MICROPY_PY_URANDOM_EXTRA_FUNCS -#define MICROPY_PY_URANDOM_EXTRA_FUNCS (0) +#define MICROPY_PY_URANDOM_EXTRA_FUNCS (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) +#endif + +#ifndef MICROPY_PY_MACHINE +#define MICROPY_PY_MACHINE (0) +#endif + +// Whether to include: bitstream +#ifndef MICROPY_PY_MACHINE_BITSTREAM +#define MICROPY_PY_MACHINE_BITSTREAM (0) +#endif + +// Whether to include: time_pulse_us +#ifndef MICROPY_PY_MACHINE_PULSE +#define MICROPY_PY_MACHINE_PULSE (0) +#endif + +#ifndef MICROPY_PY_MACHINE_I2C +#define MICROPY_PY_MACHINE_I2C (0) +#endif + +// Whether to provide the "machine.SoftI2C" class +#ifndef MICROPY_PY_MACHINE_SOFTI2C +#define MICROPY_PY_MACHINE_SOFTI2C (0) +#endif + +#ifndef MICROPY_PY_MACHINE_SPI +#define MICROPY_PY_MACHINE_SPI (0) +#endif + +// Whether to provide the "machine.SoftSPI" class +#ifndef MICROPY_PY_MACHINE_SOFTSPI +#define MICROPY_PY_MACHINE_SOFTSPI (0) +#endif + +#ifndef MICROPY_PY_USSL +#define MICROPY_PY_USSL (0) +#endif + +// Whether to add finaliser code to ussl objects +#ifndef MICROPY_PY_USSL_FINALISER +#define MICROPY_PY_USSL_FINALISER (0) +#endif + +#ifndef MICROPY_PY_UWEBSOCKET +#define MICROPY_PY_UWEBSOCKET (0) #endif #ifndef MICROPY_PY_FRAMEBUF -#define MICROPY_PY_FRAMEBUF (0) +#define MICROPY_PY_FRAMEBUF (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES) #endif #ifndef MICROPY_PY_BTREE @@ -1523,6 +1619,12 @@ typedef double mp_float_t; #ifndef MICROPY_HW_ENABLE_USB #define MICROPY_HW_ENABLE_USB (0) #endif + +// Whether to provide the low-level "_onewire" module +#ifndef MICROPY_PY_ONEWIRE +#define MICROPY_PY_ONEWIRE (0) +#endif + /*****************************************************************************/ /* Hooks for a port to add builtins */ @@ -1531,6 +1633,12 @@ typedef double mp_float_t; #define MICROPY_PORT_BUILTINS #endif +// Additional builtin function definitions for extension by command-line, boards or variants. +// See modbuiltins.c:mp_module_builtins_globals_table for format. +#ifndef MICROPY_PORT_EXTRA_BUILTINS +#define MICROPY_PORT_EXTRA_BUILTINS +#endif + // Additional builtin module definitions - see objmodule.c:mp_builtin_module_table for format. #ifndef MICROPY_PORT_BUILTIN_MODULES #define MICROPY_PORT_BUILTIN_MODULES @@ -1549,6 +1657,30 @@ typedef double mp_float_t; /*****************************************************************************/ /* Hooks for a port to wrap functions with attributes */ +#ifndef MICROPY_WRAP_MP_BINARY_OP +#define MICROPY_WRAP_MP_BINARY_OP(f) f +#endif + +#ifndef MICROPY_WRAP_MP_EXECUTE_BYTECODE +#define MICROPY_WRAP_MP_EXECUTE_BYTECODE(f) f +#endif + +#ifndef MICROPY_WRAP_MP_LOAD_GLOBAL +#define MICROPY_WRAP_MP_LOAD_GLOBAL(f) f +#endif + +#ifndef MICROPY_WRAP_MP_LOAD_NAME +#define MICROPY_WRAP_MP_LOAD_NAME(f) f +#endif + +#ifndef MICROPY_WRAP_MP_MAP_LOOKUP +#define MICROPY_WRAP_MP_MAP_LOOKUP(f) f +#endif + +#ifndef MICROPY_WRAP_MP_OBJ_GET_TYPE +#define MICROPY_WRAP_MP_OBJ_GET_TYPE(f) f +#endif + #ifndef MICROPY_WRAP_MP_SCHED_EXCEPTION #define MICROPY_WRAP_MP_SCHED_EXCEPTION(f) f #endif diff --git a/py/mpstate.h b/py/mpstate.h index 964a04f300..bfbc29d55a 100644 --- a/py/mpstate.h +++ b/py/mpstate.h @@ -44,7 +44,6 @@ #if MICROPY_DYNAMIC_COMPILER typedef struct mp_dynamic_compiler_t { uint8_t small_int_bits; // must be <= host small_int_bits - bool opt_cache_map_lookup_in_bytecode; bool py_builtins_str_unicode; uint8_t native_arch; uint8_t nlr_buf_num_regs; @@ -165,9 +164,12 @@ typedef struct _mp_state_vm_t { // dictionary for the __main__ module mp_obj_dict_t dict_main; - // these two lists must be initialised per port, after the call to mp_init + #if MICROPY_PY_SYS + // If MICROPY_PY_SYS_PATH_ARGV_DEFAULTS is not enabled then these two lists + // must be initialised after the call to mp_init. mp_obj_list_t mp_sys_path_obj; mp_obj_list_t mp_sys_argv_obj; + #endif // dictionary for overridden builtins #if MICROPY_CAN_OVERRIDE_BUILTINS @@ -230,6 +232,11 @@ typedef struct _mp_state_vm_t { // This is a global mutex used to make the VM/runtime thread-safe. mp_thread_mutex_t gil_mutex; #endif + + #if MICROPY_OPT_MAP_LOOKUP_CACHE + // See mp_map_lookup. + uint8_t map_lookup_cache[MICROPY_OPT_MAP_LOOKUP_CACHE_SIZE]; + #endif } mp_state_vm_t; // This structure holds state that is specific to a given thread. diff --git a/py/mpz.c b/py/mpz.c index b871b76b7c..b52e05148a 100644 --- a/py/mpz.c +++ b/py/mpz.c @@ -717,6 +717,7 @@ void mpz_set(mpz_t *dest, const mpz_t *src) { void mpz_set_from_int(mpz_t *z, mp_int_t val) { if (val == 0) { + z->neg = 0; z->len = 0; return; } @@ -903,10 +904,6 @@ bool mpz_is_even(const mpz_t *z) { #endif int mpz_cmp(const mpz_t *z1, const mpz_t *z2) { - // to catch comparison of -0 with +0 - if (z1->len == 0 && z2->len == 0) { - return 0; - } int cmp = (int)z2->neg - (int)z1->neg; if (cmp != 0) { return cmp; @@ -1056,7 +1053,9 @@ void mpz_neg_inpl(mpz_t *dest, const mpz_t *z) { if (dest != z) { mpz_set(dest, z); } - dest->neg = 1 - dest->neg; + if (dest->len) { + dest->neg = 1 - dest->neg; + } } /* computes dest = ~z (= -z - 1) @@ -1152,7 +1151,7 @@ void mpz_add_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs) { dest->len = mpn_sub(dest->dig, lhs->dig, lhs->len, rhs->dig, rhs->len); } - dest->neg = lhs->neg; + dest->neg = lhs->neg & !!dest->len; } /* computes dest = lhs - rhs @@ -1176,7 +1175,9 @@ void mpz_sub_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs) { dest->len = mpn_sub(dest->dig, lhs->dig, lhs->len, rhs->dig, rhs->len); } - if (neg) { + if (dest->len == 0) { + dest->neg = 0; + } else if (neg) { dest->neg = 1 - lhs->neg; } else { dest->neg = lhs->neg; @@ -1488,14 +1489,16 @@ void mpz_divmod_inpl(mpz_t *dest_quo, mpz_t *dest_rem, const mpz_t *lhs, const m mpz_need_dig(dest_quo, lhs->len + 1); // +1 necessary? memset(dest_quo->dig, 0, (lhs->len + 1) * sizeof(mpz_dig_t)); + dest_quo->neg = 0; dest_quo->len = 0; mpz_need_dig(dest_rem, lhs->len + 1); // +1 necessary? mpz_set(dest_rem, lhs); mpn_div(dest_rem->dig, &dest_rem->len, rhs->dig, rhs->len, dest_quo->dig, &dest_quo->len); + dest_rem->neg &= !!dest_rem->len; // check signs and do Python style modulo if (lhs->neg != rhs->neg) { - dest_quo->neg = 1; + dest_quo->neg = !!dest_quo->len; if (!mpz_is_zero(dest_rem)) { mpz_t mpzone; mpz_init_from_int(&mpzone, -1); diff --git a/py/mpz.h b/py/mpz.h index ba2db4c308..0fdcf52cff 100644 --- a/py/mpz.h +++ b/py/mpz.h @@ -91,6 +91,7 @@ typedef int8_t mpz_dbl_dig_signed_t; #define MPZ_NUM_DIG_FOR_LL ((sizeof(long long) * 8 + MPZ_DIG_SIZE - 1) / MPZ_DIG_SIZE) typedef struct _mpz_t { + // Zero has neg=0, len=0. Negative zero is not allowed. size_t neg : 1; size_t fixed_dig : 1; size_t alloc : (8 * sizeof(size_t) - 2); @@ -119,7 +120,7 @@ static inline bool mpz_is_zero(const mpz_t *z) { return z->len == 0; } static inline bool mpz_is_neg(const mpz_t *z) { - return z->len != 0 && z->neg != 0; + return z->neg != 0; } int mpz_cmp(const mpz_t *lhs, const mpz_t *rhs); diff --git a/py/obj.c b/py/obj.c index 45f8c96859..cc7f9006e8 100644 --- a/py/obj.c +++ b/py/obj.c @@ -43,7 +43,7 @@ #include "supervisor/shared/stack.h" #include "supervisor/shared/translate.h" -const mp_obj_type_t *mp_obj_get_type(mp_const_obj_t o_in) { +const mp_obj_type_t *MICROPY_WRAP_MP_OBJ_GET_TYPE(mp_obj_get_type)(mp_const_obj_t o_in) { #if MICROPY_OBJ_IMMEDIATE_OBJS && MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_A if (mp_obj_is_obj(o_in)) { diff --git a/py/obj.h b/py/obj.h index 823922ad1a..b31320f7e0 100644 --- a/py/obj.h +++ b/py/obj.h @@ -617,6 +617,7 @@ struct _mp_obj_type_t { // // dest[0] = MP_OBJ_NULL means load // return: for fail, do nothing + // for fail but continue lookup in locals_dict, dest[1] = MP_OBJ_SENTINEL // for attr, dest[0] = value // for method, dest[0] = method, dest[1] = self // diff --git a/py/objexcept.c b/py/objexcept.c index 90a54236d5..fc0787631f 100644 --- a/py/objexcept.c +++ b/py/objexcept.c @@ -104,7 +104,7 @@ mp_obj_t mp_alloc_emergency_exception_buf(mp_obj_t size_in) { #endif #endif // MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF -STATIC mp_obj_exception_t *get_native_exception(mp_obj_t self_in) { +mp_obj_exception_t *mp_obj_exception_get_native(mp_obj_t self_in) { assert(mp_obj_is_exception_instance(self_in)); if (mp_obj_is_native_exception_instance(self_in)) { return MP_OBJ_TO_PTR(self_in); @@ -206,7 +206,7 @@ mp_obj_t mp_obj_exception_make_new(const mp_obj_type_t *type, size_t n_args, siz // Get exception "value" - that is, first argument, or None mp_obj_t mp_obj_exception_get_value(mp_obj_t self_in) { - mp_obj_exception_t *self = get_native_exception(self_in); + mp_obj_exception_t *self = mp_obj_exception_get_native(self_in); if (self->args->len == 0) { return mp_const_none; } else { @@ -543,14 +543,14 @@ bool mp_obj_exception_match(mp_obj_t exc, mp_const_obj_t exc_type) { // traceback handling functions void mp_obj_exception_clear_traceback(mp_obj_t self_in) { - mp_obj_exception_t *self = get_native_exception(self_in); + mp_obj_exception_t *self = mp_obj_exception_get_native(self_in); // just set the traceback to the empty traceback object // we don't want to call any memory management functions here self->traceback = (mp_obj_traceback_t *)&mp_const_empty_traceback_obj; } void mp_obj_exception_add_traceback(mp_obj_t self_in, qstr file, size_t line, qstr block) { - mp_obj_exception_t *self = get_native_exception(self_in); + mp_obj_exception_t *self = mp_obj_exception_get_native(self_in); // Try to allocate memory for the traceback, with fallback to emergency traceback object if (self->traceback == NULL || self->traceback == (mp_obj_traceback_t *)&mp_const_empty_traceback_obj) { @@ -612,7 +612,7 @@ void mp_obj_exception_add_traceback(mp_obj_t self_in, qstr file, size_t line, qs } void mp_obj_exception_get_traceback(mp_obj_t self_in, size_t *n, size_t **values) { - mp_obj_exception_t *self = get_native_exception(self_in); + mp_obj_exception_t *self = mp_obj_exception_get_native(self_in); if (self->traceback == NULL) { *n = 0; diff --git a/py/objexcept.h b/py/objexcept.h index 261885e54d..f28f50f5dc 100644 --- a/py/objexcept.h +++ b/py/objexcept.h @@ -38,6 +38,7 @@ typedef struct _mp_obj_exception_t { void mp_obj_exception_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind); void mp_obj_exception_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest); +mp_obj_exception_t *mp_obj_exception_get_native(mp_obj_t self_in); #define MP_DEFINE_EXCEPTION(exc_name, base_name) \ const mp_obj_type_t mp_type_##exc_name = { \ diff --git a/py/objfun.h b/py/objfun.h index 1571ce7922..aae780b310 100644 --- a/py/objfun.h +++ b/py/objfun.h @@ -39,8 +39,6 @@ typedef struct _mp_obj_fun_bc_t { // the following extra_args array is allocated space to take (in order): // - values of positional default args (if any) // - a single slot for default kw args dict (if it has them) - // - a single slot for var args tuple (if it takes them) - // - a single slot for kw args dict (if it takes them) mp_obj_t extra_args[]; } mp_obj_fun_bc_t; diff --git a/py/objmodule.c b/py/objmodule.c index 238b24be4b..a9d20c7ee5 100644 --- a/py/objmodule.c +++ b/py/objmodule.c @@ -36,6 +36,10 @@ #include "genhdr/moduledefs.h" +#if MICROPY_MODULE_BUILTIN_INIT +STATIC void mp_module_call_init(mp_obj_t module_name, mp_obj_t module_obj); +#endif + STATIC void module_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { (void)kind; mp_obj_module_t *self = MP_OBJ_TO_PTR(self_in); @@ -196,13 +200,14 @@ STATIC const mp_rom_map_elem_t mp_builtin_module_table[] = { // extmod modules - #if MICROPY_PY_UERRNO - #if CIRCUITPY -// CircuitPython: Defined in MICROPY_PORT_BUILTIN_MODULES, so not defined here. -// TODO: move to shared-bindings/ - #else - { MP_ROM_QSTR(MP_QSTR_uerrno), MP_ROM_PTR(&mp_module_uerrno) }, + // Modules included in CircuitPython are registered using MP_REGISTER_MODULE, + // and do not have the "u" prefix. + + #if MICROPY_PY_UASYNCIO && !CIRCUITPY + { MP_ROM_QSTR(MP_QSTR__uasyncio), MP_ROM_PTR(&mp_module_uasyncio) }, #endif + #if MICROPY_PY_UERRNO && !CIRCUITPY + { MP_ROM_QSTR(MP_QSTR_uerrno), MP_ROM_PTR(&mp_module_uerrno) }, #endif #if MICROPY_PY_UCTYPES { MP_ROM_QSTR(MP_QSTR_uctypes), MP_ROM_PTR(&mp_module_uctypes) }, @@ -210,30 +215,15 @@ STATIC const mp_rom_map_elem_t mp_builtin_module_table[] = { #if MICROPY_PY_UZLIB { MP_ROM_QSTR(MP_QSTR_uzlib), MP_ROM_PTR(&mp_module_uzlib) }, #endif - #if MICROPY_PY_UJSON - #if CIRCUITPY -// CircuitPython: Defined in MICROPY_PORT_BUILTIN_MODULES, so not defined here. -// TODO: move to shared-bindings/ - #else + #if MICROPY_PY_UJSON && !CIRCUITPY { MP_ROM_QSTR(MP_QSTR_ujson), MP_ROM_PTR(&mp_module_ujson) }, #endif - #endif #if CIRCUITPY_ULAB - #if CIRCUITPY -// CircuitPython: Defined in MICROPY_PORT_BUILTIN_MODULES, so not defined here. -// TODO: move to shared-bindings/ - #else { MP_ROM_QSTR(MP_QSTR_ulab), MP_ROM_PTR(&ulab_user_cmodule) }, #endif - #endif - #if MICROPY_PY_URE - #if CIRCUITPY -// CircuitPython: Defined in MICROPY_PORT_BUILTIN_MODULES, so not defined here. -// TODO: move to shared-bindings/ - #else + #if MICROPY_PY_URE && !CIRCUITPY { MP_ROM_QSTR(MP_QSTR_ure), MP_ROM_PTR(&mp_module_ure) }, #endif - #endif #if MICROPY_PY_UHEAPQ { MP_ROM_QSTR(MP_QSTR_uheapq), MP_ROM_PTR(&mp_module_uheapq) }, #endif @@ -243,14 +233,9 @@ STATIC const mp_rom_map_elem_t mp_builtin_module_table[] = { #if MICROPY_PY_UHASHLIB { MP_ROM_QSTR(MP_QSTR_hashlib), MP_ROM_PTR(&mp_module_uhashlib) }, #endif - #if MICROPY_PY_UBINASCII - #if CIRCUITPY -// CircuitPython: Defined in MICROPY_PORT_BUILTIN_MODULES, so not defined here. -// TODO: move to shared-bindings/ - #else + #if MICROPY_PY_UBINASCII && !CIRCUITPY { MP_ROM_QSTR(MP_QSTR_ubinascii), MP_ROM_PTR(&mp_module_ubinascii) }, #endif - #endif #if MICROPY_PY_URANDOM { MP_ROM_QSTR(MP_QSTR_urandom), MP_ROM_PTR(&mp_module_urandom) }, #endif @@ -279,47 +264,56 @@ STATIC const mp_rom_map_elem_t mp_builtin_module_table[] = { MP_DEFINE_CONST_MAP(mp_builtin_module_map, mp_builtin_module_table); -// returns MP_OBJ_NULL if not found -mp_obj_t mp_module_get(qstr module_name) { - mp_map_t *mp_loaded_modules_map = &MP_STATE_VM(mp_loaded_modules_dict).map; - // lookup module - mp_map_elem_t *el = mp_map_lookup(mp_loaded_modules_map, MP_OBJ_NEW_QSTR(module_name), MP_MAP_LOOKUP); +// Tries to find a loaded module, otherwise attempts to load a builtin, otherwise MP_OBJ_NULL. +mp_obj_t mp_module_get_loaded_or_builtin(qstr module_name) { + // First try loaded modules. + mp_map_elem_t *elem = mp_map_lookup(&MP_STATE_VM(mp_loaded_modules_dict).map, MP_OBJ_NEW_QSTR(module_name), MP_MAP_LOOKUP); - if (el == NULL) { - // module not found, look for builtin module names - el = mp_map_lookup((mp_map_t *)&mp_builtin_module_map, MP_OBJ_NEW_QSTR(module_name), MP_MAP_LOOKUP); - if (el == NULL) { + if (!elem) { + #if MICROPY_MODULE_WEAK_LINKS + return mp_module_get_builtin(module_name); + #else + // Otherwise try builtin. + elem = mp_map_lookup((mp_map_t *)&mp_builtin_module_map, MP_OBJ_NEW_QSTR(module_name), MP_MAP_LOOKUP); + if (!elem) { return MP_OBJ_NULL; } - mp_module_call_init(module_name, el->value); + + #if MICROPY_MODULE_BUILTIN_INIT + // If found, it's a newly loaded built-in, so init it. + mp_module_call_init(MP_OBJ_NEW_QSTR(module_name), elem->value); + #endif + #endif } - // module found, return it - return el->value; -} - -void mp_module_register(qstr qst, mp_obj_t module) { - mp_map_t *mp_loaded_modules_map = &MP_STATE_VM(mp_loaded_modules_dict).map; - mp_map_lookup(mp_loaded_modules_map, MP_OBJ_NEW_QSTR(qst), MP_MAP_LOOKUP_ADD_IF_NOT_FOUND)->value = module; + return elem->value; } #if MICROPY_MODULE_WEAK_LINKS -// Search for u"foo" in built-in modules, return MP_OBJ_NULL if not found -mp_obj_t mp_module_search_umodule(const char *module_str) { - for (size_t i = 0; i < MP_ARRAY_SIZE(mp_builtin_module_table); ++i) { - const mp_map_elem_t *entry = (const mp_map_elem_t *)&mp_builtin_module_table[i]; - const char *key = qstr_str(MP_OBJ_QSTR_VALUE(entry->key)); - if (key[0] == 'u' && strcmp(&key[1], module_str) == 0) { - return (mp_obj_t)entry->value; - } - +// Tries to find a loaded module, otherwise attempts to load a builtin, otherwise MP_OBJ_NULL. +mp_obj_t mp_module_get_builtin(qstr module_name) { + // Try builtin. + mp_map_elem_t *elem = mp_map_lookup((mp_map_t *)&mp_builtin_module_map, MP_OBJ_NEW_QSTR(module_name), MP_MAP_LOOKUP); + if (!elem) { + return MP_OBJ_NULL; } - return MP_OBJ_NULL; + + #if MICROPY_MODULE_BUILTIN_INIT + // If found, it's a newly loaded built-in, so init it. + mp_module_call_init(MP_OBJ_NEW_QSTR(module_name), elem->value); + #endif + + return elem->value; } #endif #if MICROPY_MODULE_BUILTIN_INIT -void mp_module_call_init(qstr module_name, mp_obj_t module_obj) { +STATIC void mp_module_register(mp_obj_t module_name, mp_obj_t module) { + mp_map_t *mp_loaded_modules_map = &MP_STATE_VM(mp_loaded_modules_dict).map; + mp_map_lookup(mp_loaded_modules_map, module_name, MP_MAP_LOOKUP_ADD_IF_NOT_FOUND)->value = module; +} + +STATIC void mp_module_call_init(mp_obj_t module_name, mp_obj_t module_obj) { // Look for __init__ and call it if it exists mp_obj_t dest[2]; mp_load_method_maybe(module_obj, MP_QSTR___init__, dest); diff --git a/py/objmodule.h b/py/objmodule.h index b9106f524e..5e54dbf3ab 100644 --- a/py/objmodule.h +++ b/py/objmodule.h @@ -30,18 +30,9 @@ extern const mp_map_t mp_builtin_module_map; -mp_obj_t mp_module_get(qstr module_name); -void mp_module_register(qstr qstr, mp_obj_t module); - -mp_obj_t mp_module_search_umodule(const char *module_str); - -#if MICROPY_MODULE_BUILTIN_INIT -void mp_module_call_init(qstr module_name, mp_obj_t module_obj); -#else -static inline void mp_module_call_init(qstr module_name, mp_obj_t module_obj) { - (void)module_name; - (void)module_obj; -} +mp_obj_t mp_module_get_loaded_or_builtin(qstr module_name); +#if MICROPY_MODULE_WEAK_LINKS +mp_obj_t mp_module_get_builtin(qstr module_name); #endif #endif // MICROPY_INCLUDED_PY_OBJMODULE_H diff --git a/py/objtype.c b/py/objtype.c index cf94d300b9..d247987ce2 100644 --- a/py/objtype.c +++ b/py/objtype.c @@ -616,6 +616,7 @@ STATIC void mp_obj_instance_load_attr(mp_obj_t self_in, qstr attr, mp_obj_t *des assert(mp_obj_is_instance_type(mp_obj_get_type(self_in))); mp_obj_instance_t *self = MP_OBJ_TO_PTR(self_in); + // Note: This is fast-path'ed in the VM for the MP_BC_LOAD_ATTR operation. mp_map_elem_t *elem = mp_map_lookup(&self->members, MP_OBJ_NEW_QSTR(attr), MP_MAP_LOOKUP); if (elem != NULL) { // object member, always treated as a value diff --git a/py/parse.c b/py/parse.c index f5f3e774da..dee662b4ec 100644 --- a/py/parse.c +++ b/py/parse.c @@ -802,9 +802,11 @@ STATIC bool fold_constants(parser_t *parser, uint8_t rule_id, size_t num_args) { #endif STATIC void push_result_rule(parser_t *parser, size_t src_line, uint8_t rule_id, size_t num_args) { - // optimise away parenthesis around an expression if possible + // Simplify and optimise certain rules, to reduce memory usage and simplify the compiler. if (rule_id == RULE_atom_paren) { - // there should be just 1 arg for this rule + // Remove parenthesis around a single expression if possible. + // This atom_paren rule always has a single argument, and after this + // optimisation that argument is either NULL or testlist_comp. mp_parse_node_t pn = peek_result(parser, 0); if (MP_PARSE_NODE_IS_NULL(pn)) { // need to keep parenthesis for () @@ -814,6 +816,34 @@ STATIC void push_result_rule(parser_t *parser, size_t src_line, uint8_t rule_id, // parenthesis around a single expression, so it's just the expression return; } + } else if (rule_id == RULE_testlist_comp) { + // The testlist_comp rule can be the sole argument to either atom_parent + // or atom_bracket, for (...) and [...] respectively. + assert(num_args == 2); + mp_parse_node_t pn = peek_result(parser, 0); + if (MP_PARSE_NODE_IS_STRUCT(pn)) { + mp_parse_node_struct_t *pns = (mp_parse_node_struct_t *)pn; + if (MP_PARSE_NODE_STRUCT_KIND(pns) == RULE_testlist_comp_3b) { + // tuple of one item, with trailing comma + pop_result(parser); + --num_args; + } else if (MP_PARSE_NODE_STRUCT_KIND(pns) == RULE_testlist_comp_3c) { + // tuple of many items, convert testlist_comp_3c to testlist_comp + pop_result(parser); + assert(pn == peek_result(parser, 0)); + pns->kind_num_nodes = rule_id | MP_PARSE_NODE_STRUCT_NUM_NODES(pns) << 8; + return; + } else if (MP_PARSE_NODE_STRUCT_KIND(pns) == RULE_comp_for) { + // generator expression + } else { + // tuple with 2 items + } + } else { + // tuple with 2 items + } + } else if (rule_id == RULE_testlist_comp_3c) { + // steal first arg of outer testlist_comp rule + ++num_args; } #if MICROPY_COMP_CONST_FOLDING @@ -833,6 +863,10 @@ STATIC void push_result_rule(parser_t *parser, size_t src_line, uint8_t rule_id, for (size_t i = num_args; i > 0; i--) { pn->nodes[i - 1] = pop_result(parser); } + if (rule_id == RULE_testlist_comp_3c) { + // need to push something non-null to replace stolen first arg of testlist_comp + push_result_node(parser, (mp_parse_node_t)pn); + } push_result_node(parser, (mp_parse_node_t)pn); } diff --git a/py/persistentcode.h b/py/persistentcode.h index 8f459999c2..1c53ca12cf 100644 --- a/py/persistentcode.h +++ b/py/persistentcode.h @@ -41,16 +41,15 @@ #define MPY_FEATURE_ENCODE_ARCH(arch) ((arch) << 2) #define MPY_FEATURE_DECODE_ARCH(feat) ((feat) >> 2) -// The feature flag bits encode the compile-time config options that -// affect the generate bytecode. +// The feature flag bits encode the compile-time config options that affect +// the generate bytecode. Note: position 0 is now unused +// (formerly MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE). #define MPY_FEATURE_FLAGS ( \ - ((MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) << 0) \ - | ((MICROPY_PY_BUILTINS_STR_UNICODE) << 1) \ + ((MICROPY_PY_BUILTINS_STR_UNICODE) << 1) \ ) // This is a version of the flags that can be configured at runtime. #define MPY_FEATURE_FLAGS_DYNAMIC ( \ - ((MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE_DYNAMIC) << 0) \ - | ((MICROPY_PY_BUILTINS_STR_UNICODE_DYNAMIC) << 1) \ + ((MICROPY_PY_BUILTINS_STR_UNICODE_DYNAMIC) << 1) \ ) // Define the host architecture diff --git a/py/profile.c b/py/profile.c index 7d1d7ed659..81c80f1168 100644 --- a/py/profile.c +++ b/py/profile.c @@ -540,9 +540,6 @@ STATIC const byte *mp_prof_opcode_decode(const byte *ip, const mp_uint_t *const_ instruction->qstr_opname = MP_QSTR_LOAD_NAME; instruction->arg = qst; instruction->argobj = MP_OBJ_NEW_QSTR(qst); - if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) { - instruction->argobjex_cache = MP_OBJ_NEW_SMALL_INT(*ip++); - } break; case MP_BC_LOAD_GLOBAL: @@ -550,9 +547,6 @@ STATIC const byte *mp_prof_opcode_decode(const byte *ip, const mp_uint_t *const_ instruction->qstr_opname = MP_QSTR_LOAD_GLOBAL; instruction->arg = qst; instruction->argobj = MP_OBJ_NEW_QSTR(qst); - if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) { - instruction->argobjex_cache = MP_OBJ_NEW_SMALL_INT(*ip++); - } break; case MP_BC_LOAD_ATTR: @@ -560,9 +554,6 @@ STATIC const byte *mp_prof_opcode_decode(const byte *ip, const mp_uint_t *const_ instruction->qstr_opname = MP_QSTR_LOAD_ATTR; instruction->arg = qst; instruction->argobj = MP_OBJ_NEW_QSTR(qst); - if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) { - instruction->argobjex_cache = MP_OBJ_NEW_SMALL_INT(*ip++); - } break; case MP_BC_LOAD_METHOD: @@ -618,9 +609,6 @@ STATIC const byte *mp_prof_opcode_decode(const byte *ip, const mp_uint_t *const_ instruction->qstr_opname = MP_QSTR_STORE_ATTR; instruction->arg = qst; instruction->argobj = MP_OBJ_NEW_QSTR(qst); - if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) { - instruction->argobjex_cache = MP_OBJ_NEW_SMALL_INT(*ip++); - } break; case MP_BC_STORE_SUBSCR: diff --git a/py/py.mk b/py/py.mk index db92ef3c02..13765dee80 100644 --- a/py/py.mk +++ b/py/py.mk @@ -55,7 +55,7 @@ endif ifeq ($(CIRCUITPY_ULAB),1) ULAB_SRCS := $(shell find $(TOP)/extmod/ulab/code -type f -name "*.c") SRC_MOD += $(patsubst $(TOP)/%,%,$(ULAB_SRCS)) -CFLAGS_MOD += -DCIRCUITPY_ULAB=1 -DMODULE_ULAB_ENABLED=1 -iquote $(TOP)/extmod/ulab/code +CFLAGS_MOD += -DCIRCUITPY_ULAB=1 -DMODULE_ULAB_ENABLED=1 -DULAB_HAS_USER_MODULE=0 -iquote $(TOP)/extmod/ulab/code $(BUILD)/extmod/ulab/code/%.o: CFLAGS += -Wno-missing-declarations -Wno-missing-prototypes -Wno-unused-parameter -Wno-float-equal -Wno-sign-compare -Wno-cast-align -Wno-shadow -DCIRCUITPY endif @@ -224,19 +224,6 @@ ifneq ($(FROZEN_MANIFEST),) PY_O += $(BUILD)/$(BUILD)/frozen_content.o endif -# object file for frozen files -ifneq ($(FROZEN_DIR),) -PY_O += $(BUILD)/frozen.o -endif - -# Combine old singular FROZEN_MPY_DIR with new multiple value form. -FROZEN_MPY_DIRS += $(FROZEN_MPY_DIR) - -# object file for frozen bytecode (frozen .mpy files) -ifneq ($(FROZEN_MPY_DIRS),) -PY_O += $(BUILD)/frozen_mpy.o -endif - # Sources that may contain qstrings SRC_QSTR_IGNORE = py/nlr% SRC_QSTR_EMITNATIVE = py/emitn% diff --git a/py/qstr.c b/py/qstr.c index d7b05930f7..41176ec5ab 100644 --- a/py/qstr.c +++ b/py/qstr.c @@ -169,6 +169,12 @@ STATIC qstr qstr_add(mp_uint_t hash, mp_uint_t len, const char *q_ptr) { + (sizeof(const char *) + sizeof(qstr_attr_t)) * new_pool_length; qstr_pool_t *pool = (qstr_pool_t *)m_malloc_maybe(pool_size, true); if (pool == NULL) { + // Keep qstr_last_chunk consistent with qstr_pool_t: qstr_last_chunk is not scanned + // at garbage collection since it's reachable from a qstr_pool_t. And the caller of + // this function expects q_ptr to be stored in a qstr_pool_t so it can be reached + // by the collector. If qstr_pool_t allocation failed, qstr_last_chunk needs to be + // NULL'd. Otherwise it may become a dangling pointer at the next garbage collection. + MP_STATE_VM(qstr_last_chunk) = NULL; QSTR_EXIT(); m_malloc_fail(new_pool_length); } diff --git a/py/qstrdefs.h b/py/qstrdefs.h index 6337399d16..02b87f4ec3 100644 --- a/py/qstrdefs.h +++ b/py/qstrdefs.h @@ -60,6 +60,10 @@ Q() Q() Q(utf-8) +#if MICROPY_MODULE_FROZEN +Q(.frozen) +#endif + #if MICROPY_ENABLE_PYSTACK Q(pystack exhausted) #endif diff --git a/py/ringbuf.c b/py/ringbuf.c index a904a37413..72e164946a 100644 --- a/py/ringbuf.c +++ b/py/ringbuf.c @@ -27,11 +27,20 @@ #include "ringbuf.h" +bool ringbuf_init(ringbuf_t *r, uint8_t *buf, size_t capacity) { + r->heap = false; + r->buf = buf; + r->size = capacity; + r->iget = r->iput = 0; + return r->buf != NULL; +} + // Dynamic initialization. This should be accessible from a root pointer. // capacity is the number of bytes the ring buffer can hold. The actual // size of the buffer is one greater than that, due to how the buffer // handles empty and full statuses. bool ringbuf_alloc(ringbuf_t *r, size_t capacity, bool long_lived) { + r->heap = true; r->buf = gc_alloc(capacity + 1, false, long_lived); r->size = capacity + 1; r->iget = r->iput = 0; @@ -39,7 +48,10 @@ bool ringbuf_alloc(ringbuf_t *r, size_t capacity, bool long_lived) { } void ringbuf_free(ringbuf_t *r) { - gc_free(r->buf); + if (r->heap) { + gc_free(r->buf); + } + r->buf = (uint8_t *)NULL; r->size = 0; ringbuf_clear(r); } @@ -102,7 +114,7 @@ size_t ringbuf_num_filled(ringbuf_t *r) { // If the ring buffer fills up, not all bytes will be written. // Returns how many bytes were successfully written. -size_t ringbuf_put_n(ringbuf_t *r, uint8_t *buf, size_t bufsize) { +size_t ringbuf_put_n(ringbuf_t *r, const uint8_t *buf, size_t bufsize) { for (size_t i = 0; i < bufsize; i++) { if (ringbuf_put(r, buf[i]) < 0) { // If ringbuf is full, give up and return how many bytes diff --git a/py/ringbuf.h b/py/ringbuf.h index 35550d7750..8f7e7b1760 100644 --- a/py/ringbuf.h +++ b/py/ringbuf.h @@ -37,14 +37,13 @@ typedef struct _ringbuf_t { uint32_t size; uint32_t iget; uint32_t iput; + bool heap; } ringbuf_t; // Note that the capacity of the buffer is N-1! -// Static initialization: -// byte buf_array[N]; -// ringbuf_t buf = {buf_array, sizeof(buf_array)}; - +// For static initialization use ringbuf_init() +bool ringbuf_init(ringbuf_t *r, uint8_t *buf, size_t capacity); bool ringbuf_alloc(ringbuf_t *r, size_t capacity, bool long_lived); void ringbuf_free(ringbuf_t *r); size_t ringbuf_capacity(ringbuf_t *r); @@ -53,7 +52,7 @@ int ringbuf_put(ringbuf_t *r, uint8_t v); void ringbuf_clear(ringbuf_t *r); size_t ringbuf_num_empty(ringbuf_t *r); size_t ringbuf_num_filled(ringbuf_t *r); -size_t ringbuf_put_n(ringbuf_t *r, uint8_t *buf, size_t bufsize); +size_t ringbuf_put_n(ringbuf_t *r, const uint8_t *buf, size_t bufsize); size_t ringbuf_get_n(ringbuf_t *r, uint8_t *buf, size_t bufsize); // Note: big-endian. No-op if not enough room available for both bytes. diff --git a/py/runtime.c b/py/runtime.c index 1554a70231..bf44234434 100644 --- a/py/runtime.c +++ b/py/runtime.c @@ -126,6 +126,15 @@ void mp_init(void) { sizeof(MP_STATE_VM(fs_user_mount)) - MICROPY_FATFS_NUM_PERSISTENT); #endif + #if MICROPY_PY_SYS_PATH_ARGV_DEFAULTS + mp_obj_list_init(MP_OBJ_TO_PTR(mp_sys_path), 0); + mp_obj_list_append(mp_sys_path, MP_OBJ_NEW_QSTR(MP_QSTR_)); // current dir (or base dir of the script) + #if MICROPY_MODULE_FROZEN + mp_obj_list_append(mp_sys_path, MP_OBJ_NEW_QSTR(MP_QSTR__dot_frozen)); + #endif + mp_obj_list_init(MP_OBJ_TO_PTR(mp_sys_argv), 0); + #endif + #if MICROPY_PY_SYS_ATEXIT MP_STATE_VM(sys_exitfunc) = mp_const_none; #endif @@ -157,7 +166,7 @@ void mp_deinit(void) { #endif } -mp_obj_t mp_load_name(qstr qst) { +mp_obj_t MICROPY_WRAP_MP_LOAD_NAME(mp_load_name)(qstr qst) { // logic: search locals, globals, builtins DEBUG_OP_printf("load name %s\n", qstr_str(qst)); // If we're at the outer scope (locals == globals), dispatch to load_global right away @@ -170,7 +179,7 @@ mp_obj_t mp_load_name(qstr qst) { return mp_load_global(qst); } -mp_obj_t mp_load_global(qstr qst) { +mp_obj_t MICROPY_WRAP_MP_LOAD_GLOBAL(mp_load_global)(qstr qst) { // logic: search globals, builtins DEBUG_OP_printf("load global %s\n", qstr_str(qst)); mp_map_elem_t *elem = mp_map_lookup(&mp_globals_get()->map, MP_OBJ_NEW_QSTR(qst), MP_MAP_LOOKUP); @@ -310,7 +319,7 @@ mp_obj_t mp_unary_op(mp_unary_op_t op, mp_obj_t arg) { } } -mp_obj_t PLACE_IN_ITCM(mp_binary_op)(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) { +mp_obj_t MICROPY_WRAP_MP_BINARY_OP(mp_binary_op)(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) { DEBUG_OP_printf("binary " UINT_FMT " %q %p %p\n", op, mp_binary_op_method_name[op], lhs, rhs); // TODO correctly distinguish inplace operators for mutable objects @@ -1103,6 +1112,10 @@ void mp_load_method_maybe(mp_obj_t obj, qstr attr, mp_obj_t *dest) { dest[0] = MP_OBJ_NULL; dest[1] = MP_OBJ_NULL; + // Note: the specific case of obj being an instance type is fast-path'ed in the VM + // for the MP_BC_LOAD_ATTR opcode. Instance types handle type->attr and look up directly + // in their member's map. + // get the type const mp_obj_type_t *type = mp_obj_get_type(obj); @@ -1124,7 +1137,14 @@ void mp_load_method_maybe(mp_obj_t obj, qstr attr, mp_obj_t *dest) { if (attr_fun != NULL) { // this type can do its own load, so call it attr_fun(obj, attr, dest); - return; + + // If type->attr has set dest[1] = MP_OBJ_SENTINEL, we should proceed + // with lookups below (i.e. in locals_dict). If not, return right away. + if (dest[1] != MP_OBJ_SENTINEL) { + return; + } + // Clear the fail flag set by type->attr so it's like it never ran. + dest[1] = MP_OBJ_NULL; } if (type->locals_dict != NULL) { // generic method lookup @@ -1135,6 +1155,7 @@ void mp_load_method_maybe(mp_obj_t obj, qstr attr, mp_obj_t *dest) { if (elem != NULL) { mp_convert_member_lookup(obj, type, elem->value, dest); } + return; } } @@ -1426,8 +1447,10 @@ mp_obj_t mp_make_raise_obj(mp_obj_t o) { // create and return a new exception instance by calling o // TODO could have an option to disable traceback, then builtin exceptions (eg TypeError) // could have const instances in ROM which we return here instead - return mp_call_function_n_kw(o, 0, 0, NULL); - } else if (mp_obj_is_exception_instance(o)) { + o = mp_call_function_n_kw(o, 0, 0, NULL); + } + + if (mp_obj_is_exception_instance(o)) { // o is an instance of an exception, so use it as the exception return o; } else { diff --git a/py/runtime.h b/py/runtime.h index f610a04f8a..4a309f3975 100644 --- a/py/runtime.h +++ b/py/runtime.h @@ -95,7 +95,9 @@ NORETURN void mp_arg_error_unimpl_kw(void); mp_int_t mp_arg_validate_int_min(mp_int_t i, mp_int_t min, qstr arg_name); mp_int_t mp_arg_validate_int_max(mp_int_t i, mp_int_t j, qstr arg_name); mp_int_t mp_arg_validate_int_range(mp_int_t i, mp_int_t min, mp_int_t max, qstr arg_name); +#if MICROPY_PY_BUILTINS_FLOAT mp_float_t mp_arg_validate_obj_float_non_negative(mp_obj_t float_in, mp_float_t default_for_null, qstr arg_name); +#endif mp_uint_t mp_arg_validate_length_range(mp_uint_t length, mp_uint_t min, mp_uint_t max, qstr arg_name); mp_obj_t mp_arg_validate_type(mp_obj_t obj, const mp_obj_type_t *type, qstr arg_name); mp_obj_t mp_arg_validate_string(mp_obj_t obj, qstr arg_name); diff --git a/py/showbc.c b/py/showbc.c index e9b43c29e3..1d02b559b0 100644 --- a/py/showbc.c +++ b/py/showbc.c @@ -98,8 +98,8 @@ void mp_bytecode_print(const mp_print_t *print, const void *descr, const byte *i // raw bytecode dump size_t prelude_size = ip - mp_showbc_code_start + n_info + n_cell; - mp_printf(print, "Raw bytecode (code_info_size=" UINT_FMT ", bytecode_size=" UINT_FMT "):\n", - prelude_size, len - prelude_size); + mp_printf(print, "Raw bytecode (code_info_size=%u, bytecode_size=%u):\n", + (unsigned)prelude_size, (unsigned)(len - prelude_size)); for (mp_uint_t i = 0; i < len; i++) { if (i > 0 && i % 16 == 0) { mp_printf(print, "\n"); @@ -208,25 +208,16 @@ const byte *mp_bytecode_print_str(const mp_print_t *print, const byte *ip) { case MP_BC_LOAD_NAME: DECODE_QSTR; mp_printf(print, "LOAD_NAME %s", qstr_str(qst)); - if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) { - mp_printf(print, " (cache=%u)", *ip++); - } break; case MP_BC_LOAD_GLOBAL: DECODE_QSTR; mp_printf(print, "LOAD_GLOBAL %s", qstr_str(qst)); - if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) { - mp_printf(print, " (cache=%u)", *ip++); - } break; case MP_BC_LOAD_ATTR: DECODE_QSTR; mp_printf(print, "LOAD_ATTR %s", qstr_str(qst)); - if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) { - mp_printf(print, " (cache=%u)", *ip++); - } break; case MP_BC_LOAD_METHOD: @@ -270,9 +261,6 @@ const byte *mp_bytecode_print_str(const mp_print_t *print, const byte *ip) { case MP_BC_STORE_ATTR: DECODE_QSTR; mp_printf(print, "STORE_ATTR %s", qstr_str(qst)); - if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) { - mp_printf(print, " (cache=%u)", *ip++); - } break; case MP_BC_STORE_SUBSCR: @@ -531,7 +519,8 @@ const byte *mp_bytecode_print_str(const mp_print_t *print, const byte *ip) { } else if (ip[-1] < MP_BC_STORE_FAST_MULTI + 16) { mp_printf(print, "STORE_FAST " UINT_FMT, (mp_uint_t)ip[-1] - MP_BC_STORE_FAST_MULTI); } else if (ip[-1] < MP_BC_UNARY_OP_MULTI + MP_UNARY_OP_NUM_BYTECODE) { - mp_printf(print, "UNARY_OP " UINT_FMT, (mp_uint_t)ip[-1] - MP_BC_UNARY_OP_MULTI); + mp_uint_t op = ip[-1] - MP_BC_UNARY_OP_MULTI; + mp_printf(print, "UNARY_OP " UINT_FMT " %s", op, qstr_str(mp_unary_op_method_name[op])); } else if (ip[-1] < MP_BC_BINARY_OP_MULTI + MP_BINARY_OP_NUM_BYTECODE) { mp_uint_t op = ip[-1] - MP_BC_BINARY_OP_MULTI; mp_printf(print, "BINARY_OP " UINT_FMT " %s", op, qstr_str(mp_binary_op_method_name[op])); diff --git a/py/vm.c b/py/vm.c index 9ad67bb2e0..63eb7f46d9 100644 --- a/py/vm.c +++ b/py/vm.c @@ -182,30 +182,13 @@ #define TRACE_TICK(current_ip, current_sp, is_exception) #endif // MICROPY_PY_SYS_SETTRACE -#if MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE -static inline mp_map_elem_t *mp_map_cached_lookup(mp_map_t *map, qstr qst, uint8_t *idx_cache) { - size_t idx = *idx_cache; - mp_obj_t key = MP_OBJ_NEW_QSTR(qst); - mp_map_elem_t *elem = NULL; - if (idx < map->alloc && map->table[idx].key == key) { - elem = &map->table[idx]; - } else { - elem = mp_map_lookup(map, key, MP_MAP_LOOKUP); - if (elem != NULL) { - *idx_cache = (elem - &map->table[0]) & 0xff; - } - } - return elem; -} -#endif - // fastn has items in reverse order (fastn[0] is local[0], fastn[-1] is local[1], etc) // sp points to bottom of stack which grows up // returns: // MP_VM_RETURN_NORMAL, sp valid, return value in *sp // MP_VM_RETURN_YIELD, ip, sp valid, yielded value in *sp // MP_VM_RETURN_EXCEPTION, exception in state[0] -mp_vm_return_kind_t PLACE_IN_ITCM(mp_execute_bytecode)(mp_code_state_t *code_state, volatile mp_obj_t inject_exc) { +mp_vm_return_kind_t MICROPY_WRAP_MP_EXECUTE_BYTECODE(mp_execute_bytecode)(mp_code_state_t *code_state, volatile mp_obj_t inject_exc) { #define SELECTIVE_EXC_IP (0) #if SELECTIVE_EXC_IP #define MARK_EXC_IP_SELECTIVE() { code_state->ip = ip; } /* stores ip 1 byte past last opcode */ @@ -373,84 +356,46 @@ dispatch_loop: goto load_check; } - #if !MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE ENTRY(MP_BC_LOAD_NAME): { MARK_EXC_IP_SELECTIVE(); DECODE_QSTR; PUSH(mp_load_name(qst)); DISPATCH(); } - #else - ENTRY(MP_BC_LOAD_NAME): { - MARK_EXC_IP_SELECTIVE(); - DECODE_QSTR; - mp_map_elem_t *elem = mp_map_cached_lookup(&mp_locals_get()->map, qst, (uint8_t*)ip); - mp_obj_t obj; - if (elem != NULL) { - obj = elem->value; - } else { - obj = mp_load_name(qst); - } - PUSH(obj); - ip++; - DISPATCH(); - } - #endif - #if !MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE ENTRY(MP_BC_LOAD_GLOBAL): { MARK_EXC_IP_SELECTIVE(); DECODE_QSTR; PUSH(mp_load_global(qst)); DISPATCH(); } - #else - ENTRY(MP_BC_LOAD_GLOBAL): { - MARK_EXC_IP_SELECTIVE(); - DECODE_QSTR; - mp_map_elem_t *elem = mp_map_cached_lookup(&mp_globals_get()->map, qst, (uint8_t*)ip); - mp_obj_t obj; - if (elem != NULL) { - obj = elem->value; - } else { - obj = mp_load_global(qst); - } - PUSH(obj); - ip++; - DISPATCH(); - } - #endif - #if !MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE - ENTRY(MP_BC_LOAD_ATTR): { - FRAME_UPDATE(); - MARK_EXC_IP_SELECTIVE(); - DECODE_QSTR; - SET_TOP(mp_load_attr(TOP(), qst)); - DISPATCH(); - } - #else ENTRY(MP_BC_LOAD_ATTR): { FRAME_UPDATE(); MARK_EXC_IP_SELECTIVE(); DECODE_QSTR; mp_obj_t top = TOP(); + mp_obj_t obj; + #if MICROPY_OPT_LOAD_ATTR_FAST_PATH + // For the specific case of an instance type, it implements .attr + // and forwards to its members map. Attribute lookups on instance + // types are extremely common, so avoid all the other checks and + // calls that normally happen first. mp_map_elem_t *elem = NULL; if (mp_obj_is_instance_type(mp_obj_get_type(top))) { mp_obj_instance_t *self = MP_OBJ_TO_PTR(top); - elem = mp_map_cached_lookup(&self->members, qst, (uint8_t*)ip); + elem = mp_map_lookup(&self->members, MP_OBJ_NEW_QSTR(qst), MP_MAP_LOOKUP); } - mp_obj_t obj; - if (elem != NULL) { + if (elem) { obj = elem->value; - } else { + } else + #endif + { obj = mp_load_attr(top, qst); } SET_TOP(obj); - ip++; DISPATCH(); } - #endif ENTRY(MP_BC_LOAD_METHOD): { MARK_EXC_IP_SELECTIVE(); @@ -506,7 +451,6 @@ dispatch_loop: DISPATCH(); } - #if !MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE ENTRY(MP_BC_STORE_ATTR): { FRAME_UPDATE(); MARK_EXC_IP_SELECTIVE(); @@ -515,32 +459,6 @@ dispatch_loop: sp -= 2; DISPATCH(); } - #else - // This caching code works with MICROPY_PY_BUILTINS_PROPERTY and/or - // MICROPY_PY_DESCRIPTORS enabled because if the attr exists in - // self->members then it can't be a property or have descriptors. A - // consequence of this is that we can't use MP_MAP_LOOKUP_ADD_IF_NOT_FOUND - // in the fast-path below, because that store could override a property. - ENTRY(MP_BC_STORE_ATTR): { - FRAME_UPDATE(); - MARK_EXC_IP_SELECTIVE(); - DECODE_QSTR; - mp_map_elem_t *elem = NULL; - mp_obj_t top = TOP(); - if (mp_obj_is_instance_type(mp_obj_get_type(top)) && sp[-1] != MP_OBJ_NULL) { - mp_obj_instance_t *self = MP_OBJ_TO_PTR(top); - elem = mp_map_cached_lookup(&self->members, qst, (uint8_t*)ip); - } - if (elem != NULL) { - elem->value = sp[-1]; - } else { - mp_store_attr(sp[0], qst, sp[-1]); - } - sp -= 2; - ip++; - DISPATCH(); - } - #endif ENTRY(MP_BC_STORE_SUBSCR): MARK_EXC_IP_SELECTIVE(); diff --git a/requirements-dev.txt b/requirements-dev.txt index a57794ce1a..eb21bc208b 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -21,3 +21,6 @@ black # for combining the Nordic SoftDevice with CircuitPython intelhex + +# for building & testing natmods +pyelftools diff --git a/requirements-doc.txt b/requirements-doc.txt index cefd7dc51d..ed5bc4c98e 100644 --- a/requirements-doc.txt +++ b/requirements-doc.txt @@ -6,9 +6,10 @@ twine wheel astroid setuptools +setuptools_scm # For sphinx -Sphinx<4 +sphinx>=4.0.0 sphinx-autoapi sphinx-rtd-theme sphinxcontrib-svg2pdfconverter diff --git a/setup.py-stubs b/setup.py-stubs index 3604ee973e..9abfa348a9 100644 --- a/setup.py-stubs +++ b/setup.py-stubs @@ -43,6 +43,7 @@ setup( "root": "..", "relative_to": __file__, "local_scheme": local_scheme, + "git_describe_command": "tools/describe --long", }, zip_safe=False, ) diff --git a/shared-bindings/_bleio/Adapter.c b/shared-bindings/_bleio/Adapter.c index d985b0aecd..baff277b69 100644 --- a/shared-bindings/_bleio/Adapter.c +++ b/shared-bindings/_bleio/Adapter.c @@ -196,8 +196,8 @@ const mp_obj_property_t bleio_adapter_name_obj = { //| .. note:: If you set ``anonymous=True``, then a timeout must be specified. If no timeout is //| specified, then the maximum allowed timeout will be selected automatically. //| -//| :param ~_typing.ReadableBuffer data: advertising data packet bytes -//| :param ~_typing.ReadableBuffer scan_response: scan response data packet bytes. ``None`` if no scan response is needed. +//| :param ~circuitpython_typing.ReadableBuffer data: advertising data packet bytes +//| :param ~circuitpython_typing.ReadableBuffer scan_response: scan response data packet bytes. ``None`` if no scan response is needed. //| :param bool connectable: If `True` then other devices are allowed to connect to this peripheral. //| :param bool anonymous: If `True` then this device's MAC address is randomized before advertising. //| :param int timeout: If set, we will only advertise for this many seconds. Zero means no timeout. @@ -282,7 +282,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_adapter_stop_advertising_obj, bleio_adapt //| """Starts a BLE scan and returns an iterator of results. Advertisements and scan responses are //| filtered and returned separately. //| -//| :param ~_typing.ReadableBuffer prefixes: Sequence of byte string prefixes to filter advertising packets +//| :param ~circuitpython_typing.ReadableBuffer prefixes: Sequence of byte string prefixes to filter advertising packets //| with. A packet without an advertising structure that matches one of the prefixes is //| ignored. Format is one byte for length (n) and n bytes of prefix and can be repeated. //| :param int buffer_size: the maximum number of advertising bytes to buffer. diff --git a/shared-bindings/_bleio/Address.c b/shared-bindings/_bleio/Address.c index 93345d95b0..97322bbb79 100644 --- a/shared-bindings/_bleio/Address.c +++ b/shared-bindings/_bleio/Address.c @@ -42,7 +42,7 @@ //| """Create a new Address object encapsulating the address value. //| The value itself can be one of: //| -//| :param ~_typing.ReadableBuffer address: The address value to encapsulate. A buffer object (bytearray, bytes) of 6 bytes. +//| :param ~circuitpython_typing.ReadableBuffer address: The address value to encapsulate. A buffer object (bytearray, bytes) of 6 bytes. //| :param int address_type: one of the integer values: `PUBLIC`, `RANDOM_STATIC`, //| `RANDOM_PRIVATE_RESOLVABLE`, or `RANDOM_PRIVATE_NON_RESOLVABLE`.""" //| ... diff --git a/shared-bindings/_bleio/Characteristic.c b/shared-bindings/_bleio/Characteristic.c index 3744c610c7..f4c77405d1 100644 --- a/shared-bindings/_bleio/Characteristic.c +++ b/shared-bindings/_bleio/Characteristic.c @@ -67,7 +67,7 @@ //| is 512, or possibly 510 if ``fixed_length`` is False. The default, 20, is the maximum //| number of data bytes that fit in a single BLE 4.x ATT packet. //| :param bool fixed_length: True if the characteristic value is of fixed length. -//| :param ~_typing.ReadableBuffer initial_value: The initial value for this characteristic. If not given, will be +//| :param ~circuitpython_typing.ReadableBuffer initial_value: The initial value for this characteristic. If not given, will be //| filled with zeros. //| :param str user_description: User friendly description of the characteristic //| diff --git a/shared-bindings/_bleio/Descriptor.c b/shared-bindings/_bleio/Descriptor.c index 5a29575ba0..d4dd9372f3 100644 --- a/shared-bindings/_bleio/Descriptor.c +++ b/shared-bindings/_bleio/Descriptor.c @@ -61,7 +61,7 @@ //| is 512, or possibly 510 if ``fixed_length`` is False. The default, 20, is the maximum //| number of data bytes that fit in a single BLE 4.x ATT packet. //| :param bool fixed_length: True if the descriptor value is of fixed length. -//| :param ~_typing.ReadableBuffer initial_value: The initial value for this descriptor. +//| :param ~circuitpython_typing.ReadableBuffer initial_value: The initial value for this descriptor. //| //| :return: the new Descriptor.""" //| ... diff --git a/shared-bindings/_bleio/UUID.c b/shared-bindings/_bleio/UUID.c index 028d21d9d5..4e3154eb03 100644 --- a/shared-bindings/_bleio/UUID.c +++ b/shared-bindings/_bleio/UUID.c @@ -48,7 +48,7 @@ //| temporary 16-bit UUID that can be used in place of the full 128-bit UUID. //| //| :param value: The uuid value to encapsulate -//| :type value: int, ~_typing.ReadableBuffer or str""" +//| :type value: int, ~circuitpython_typing.ReadableBuffer or str""" //| ... //| STATIC mp_obj_t bleio_uuid_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { diff --git a/shared-bindings/_bleio/__init__.h b/shared-bindings/_bleio/__init__.h index 7f251ef188..55b527cfa5 100644 --- a/shared-bindings/_bleio/__init__.h +++ b/shared-bindings/_bleio/__init__.h @@ -54,6 +54,8 @@ extern const mp_obj_type_t mp_type_bleio_BluetoothError; extern const mp_obj_type_t mp_type_bleio_RoleError; extern const mp_obj_type_t mp_type_bleio_SecurityError; +void bleio_reset(void); + extern mp_obj_t bleio_set_adapter(mp_obj_t adapter_obj); NORETURN void mp_raise_bleio_BluetoothError(const compressed_string_t *msg, ...); diff --git a/shared-bindings/_eve/__init__.c b/shared-bindings/_eve/__init__.c index 69300e47e4..13e51cb882 100644 --- a/shared-bindings/_eve/__init__.c +++ b/shared-bindings/_eve/__init__.c @@ -79,7 +79,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(flush_obj, _flush); //| def cc(self, b: ReadableBuffer) -> None: //| """Append bytes to the command FIFO. //| -//| :param ~_typing.ReadableBuffer b: The bytes to add""" +//| :param ~circuitpython_typing.ReadableBuffer b: The bytes to add""" //| ... //| STATIC mp_obj_t _cc(mp_obj_t self, mp_obj_t b) { diff --git a/shared-bindings/_stage/Layer.c b/shared-bindings/_stage/Layer.c index a040ee9ab0..c3c0aa1801 100644 --- a/shared-bindings/_stage/Layer.c +++ b/shared-bindings/_stage/Layer.c @@ -40,9 +40,9 @@ //| //| :param int width: The width of the grid in tiles, or 1 for sprites. //| :param int height: The height of the grid in tiles, or 1 for sprites. -//| :param ~_typing.ReadableBuffer graphic: The graphic data of the tiles. -//| :param ~_typing.ReadableBuffer palette: The color palette to be used. -//| :param ~_typing.ReadableBuffer grid: The contents of the grid map. +//| :param ~circuitpython_typing.ReadableBuffer graphic: The graphic data of the tiles. +//| :param ~circuitpython_typing.ReadableBuffer palette: The color palette to be used. +//| :param ~circuitpython_typing.ReadableBuffer grid: The contents of the grid map. //| //| This class is intended for internal use in the ``stage`` library and //| it shouldn't be used on its own.""" diff --git a/shared-bindings/_stage/Text.c b/shared-bindings/_stage/Text.c index b57f4f0b6a..d6b22171d6 100644 --- a/shared-bindings/_stage/Text.c +++ b/shared-bindings/_stage/Text.c @@ -40,9 +40,9 @@ //| //| :param int width: The width of the grid in tiles, or 1 for sprites. //| :param int height: The height of the grid in tiles, or 1 for sprites. -//| :param ~_typing.ReadableBuffer font: The font data of the characters. -//| :param ~_typing.ReadableBuffer palette: The color palette to be used. -//| :param ~_typing.ReadableBuffer chars: The contents of the character grid. +//| :param ~circuitpython_typing.ReadableBuffer font: The font data of the characters. +//| :param ~circuitpython_typing.ReadableBuffer palette: The color palette to be used. +//| :param ~circuitpython_typing.ReadableBuffer chars: The contents of the character grid. //| //| This class is intended for internal use in the ``stage`` library and //| it shouldn't be used on its own.""" diff --git a/shared-bindings/_stage/__init__.c b/shared-bindings/_stage/__init__.c index 4dfcc796e7..ebaa06898e 100644 --- a/shared-bindings/_stage/__init__.c +++ b/shared-bindings/_stage/__init__.c @@ -48,7 +48,7 @@ //| :param int y1: Bottom edge of the fragment. //| :param layers: A list of the :py:class:`~_stage.Layer` objects. //| :type layers: list[Layer] -//| :param ~_typing.WriteableBuffer buffer: A buffer to use for rendering. +//| :param ~circuitpython_typing.WriteableBuffer buffer: A buffer to use for rendering. //| :param ~displayio.Display display: The display to use. //| :param int scale: How many times should the image be scaled up. //| :param int background: What color to display when nothing is there. diff --git a/shared-bindings/adafruit_bus_device/__init__.c b/shared-bindings/adafruit_bus_device/__init__.c index f25a882557..be2378b154 100644 --- a/shared-bindings/adafruit_bus_device/__init__.c +++ b/shared-bindings/adafruit_bus_device/__init__.c @@ -32,8 +32,8 @@ #include "py/objproperty.h" #include "shared-bindings/adafruit_bus_device/__init__.h" -#include "shared-bindings/adafruit_bus_device/I2CDevice.h" -#include "shared-bindings/adafruit_bus_device/SPIDevice.h" +#include "shared-bindings/adafruit_bus_device/i2c_device/I2CDevice.h" +#include "shared-bindings/adafruit_bus_device/spi_device/SPIDevice.h" STATIC const mp_rom_map_elem_t adafruit_bus_device_i2c_device_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_i2c_device) }, @@ -78,3 +78,5 @@ const mp_obj_module_t adafruit_bus_device_module = { }; MP_REGISTER_MODULE(MP_QSTR_adafruit_bus_device, adafruit_bus_device_module, CIRCUITPY_BUSDEVICE); +MP_REGISTER_MODULE(MP_QSTR_adafruit_bus_device_dot_i2c_device, adafruit_bus_device_i2c_device_module, CIRCUITPY_BUSDEVICE); +MP_REGISTER_MODULE(MP_QSTR_adafruit_bus_device_dot_spi_device, adafruit_bus_device_spi_device_module, CIRCUITPY_BUSDEVICE); diff --git a/shared-bindings/adafruit_bus_device/I2CDevice.c b/shared-bindings/adafruit_bus_device/i2c_device/I2CDevice.c similarity index 98% rename from shared-bindings/adafruit_bus_device/I2CDevice.c rename to shared-bindings/adafruit_bus_device/i2c_device/I2CDevice.c index 98f2640483..327e8e72b4 100644 --- a/shared-bindings/adafruit_bus_device/I2CDevice.c +++ b/shared-bindings/adafruit_bus_device/i2c_device/I2CDevice.c @@ -28,9 +28,9 @@ // busio.I2C class. #include "shared-bindings/microcontroller/Pin.h" -#include "shared-bindings/adafruit_bus_device/I2CDevice.h" +#include "shared-bindings/adafruit_bus_device/i2c_device/I2CDevice.h" #include "shared-bindings/util.h" -#include "shared-module/adafruit_bus_device/I2CDevice.h" +#include "shared-module/adafruit_bus_device/i2c_device/I2CDevice.h" #include "shared/runtime/buffer_helper.h" #include "shared/runtime/context_manager_helpers.h" diff --git a/shared-bindings/adafruit_bus_device/I2CDevice.h b/shared-bindings/adafruit_bus_device/i2c_device/I2CDevice.h similarity index 97% rename from shared-bindings/adafruit_bus_device/I2CDevice.h rename to shared-bindings/adafruit_bus_device/i2c_device/I2CDevice.h index 36a95b6a24..71c169a868 100644 --- a/shared-bindings/adafruit_bus_device/I2CDevice.h +++ b/shared-bindings/adafruit_bus_device/i2c_device/I2CDevice.h @@ -36,7 +36,7 @@ #include "py/obj.h" -#include "shared-module/adafruit_bus_device/I2CDevice.h" +#include "shared-module/adafruit_bus_device/i2c_device/I2CDevice.h" // #include "shared-bindings/busio/I2C.h" // Type object used in Python. Should be shared between ports. diff --git a/shared-bindings/adafruit_bus_device/SPIDevice.c b/shared-bindings/adafruit_bus_device/spi_device/SPIDevice.c similarity index 97% rename from shared-bindings/adafruit_bus_device/SPIDevice.c rename to shared-bindings/adafruit_bus_device/spi_device/SPIDevice.c index aee8882940..2c5708b831 100644 --- a/shared-bindings/adafruit_bus_device/SPIDevice.c +++ b/shared-bindings/adafruit_bus_device/spi_device/SPIDevice.c @@ -25,9 +25,9 @@ */ #include "shared-bindings/microcontroller/Pin.h" -#include "shared-bindings/adafruit_bus_device/SPIDevice.h" +#include "shared-bindings/adafruit_bus_device/spi_device/SPIDevice.h" #include "shared-bindings/util.h" -#include "shared-module/adafruit_bus_device/SPIDevice.h" +#include "shared-module/adafruit_bus_device/spi_device/SPIDevice.h" #include "common-hal/digitalio/DigitalInOut.h" #include "shared-bindings/digitalio/DigitalInOut.h" diff --git a/shared-bindings/adafruit_bus_device/SPIDevice.h b/shared-bindings/adafruit_bus_device/spi_device/SPIDevice.h similarity index 97% rename from shared-bindings/adafruit_bus_device/SPIDevice.h rename to shared-bindings/adafruit_bus_device/spi_device/SPIDevice.h index 43b9377f97..b92a5ebfae 100644 --- a/shared-bindings/adafruit_bus_device/SPIDevice.h +++ b/shared-bindings/adafruit_bus_device/spi_device/SPIDevice.h @@ -36,7 +36,7 @@ #include "py/obj.h" -#include "shared-module/adafruit_bus_device/SPIDevice.h" +#include "shared-module/adafruit_bus_device/spi_device/SPIDevice.h" // Type object used in Python. Should be shared between ports. extern const mp_obj_type_t adafruit_bus_device_spidevice_type; diff --git a/shared-bindings/adafruit_pixelbuf/PixelBuf.c b/shared-bindings/adafruit_pixelbuf/PixelBuf.c index db9f1c01a8..7be059fa6b 100644 --- a/shared-bindings/adafruit_pixelbuf/PixelBuf.c +++ b/shared-bindings/adafruit_pixelbuf/PixelBuf.c @@ -64,8 +64,8 @@ static void parse_byteorder(mp_obj_t byteorder_obj, pixelbuf_byteorder_details_t //| :param str byteorder: Byte order string (such as "RGB", "RGBW" or "PBGR") //| :param float brightness: Brightness (0 to 1.0, default 1.0) //| :param bool auto_write: Whether to automatically write pixels (Default False) -//| :param ~_typing.ReadableBuffer header: Sequence of bytes to always send before pixel values. -//| :param ~_typing.ReadableBuffer trailer: Sequence of bytes to always send after pixel values.""" +//| :param ~circuitpython_typing.ReadableBuffer header: Sequence of bytes to always send before pixel values. +//| :param ~circuitpython_typing.ReadableBuffer trailer: Sequence of bytes to always send after pixel values.""" //| ... //| STATIC mp_obj_t pixelbuf_pixelbuf_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { diff --git a/shared-bindings/aesio/aes.c b/shared-bindings/aesio/aes.c index 232f4bede8..4acadc5ab6 100644 --- a/shared-bindings/aesio/aes.c +++ b/shared-bindings/aesio/aes.c @@ -19,10 +19,10 @@ //| def __init__(self, key: ReadableBuffer, mode: int = 0, iv: Optional[ReadableBuffer] = None, segment_size: int = 8) -> None: //| """Create a new AES state with the given key. //| -//| :param ~_typing.ReadableBuffer key: A 16-, 24-, or 32-byte key +//| :param ~circuitpython_typing.ReadableBuffer key: A 16-, 24-, or 32-byte key //| :param int mode: AES mode to use. One of: `MODE_ECB`, `MODE_CBC`, or //| `MODE_CTR` -//| :param ~_typing.ReadableBuffer iv: Initialization vector to use for CBC or CTR mode +//| :param ~circuitpython_typing.ReadableBuffer iv: Initialization vector to use for CBC or CTR mode //| //| Additional arguments are supported for legacy reasons. //| diff --git a/shared-bindings/alarm/__init__.c b/shared-bindings/alarm/__init__.c index 4160f6a334..340a4ea679 100644 --- a/shared-bindings/alarm/__init__.c +++ b/shared-bindings/alarm/__init__.c @@ -64,8 +64,10 @@ //| This object is the sole instance of `alarm.SleepMemory`.""" //| -//| wake_alarm: Alarm -//| """The most recently triggered alarm. If CircuitPython was sleeping, the alarm the woke it from sleep.""" +//| wake_alarm: Optional[Alarm] +//| """The most recently triggered alarm. If CircuitPython was sleeping, the alarm that woke it from sleep. +//| If no alarm occured since the last hard reset or soft restart, value is ``None``. +//| """ //| // wake_alarm is implemented as a dictionary entry, so there's no code here. @@ -103,7 +105,9 @@ STATIC mp_obj_t alarm_light_sleep_until_alarms(size_t n_args, const mp_obj_t *ar validate_objs_are_alarms(n_args, args); - return common_hal_alarm_light_sleep_until_alarms(n_args, args); + mp_obj_t alarm = common_hal_alarm_light_sleep_until_alarms(n_args, args); + shared_alarm_save_wake_alarm(alarm); + return alarm; } MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(alarm_light_sleep_until_alarms_obj, 1, MP_OBJ_FUN_ARGS_MAX, alarm_light_sleep_until_alarms); @@ -121,11 +125,15 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(alarm_light_sleep_until_alarms_obj, 1, MP_OB //| //| If no alarms are specified, the microcontroller will deep sleep until reset. //| -//| **If CircuitPython is connected to a host computer, the connection will be maintained, -//| and the system will not go into deep sleep.** +//| **If CircuitPython is connected to a host computer via USB or BLE +//| the first time a deep sleep is requested, +//| the connection will be maintained and the system will not go into deep sleep.** //| This allows the user to interrupt an existing program with ctrl-C, //| and to edit the files in CIRCUITPY, which would not be possible in true deep sleep. -//| Thus, to use deep sleep and save significant power, you will need to disconnect from the host. +//| +//| If CircuitPython goes into a true deep sleep, and USB or BLE is reconnected, +//| the next deep sleep will still be a true deep sleep. You must do a hard reset +//| or power-cycle to exit a true deep sleep loop. //| //| Here is skeletal example that deep-sleeps and restarts every 60 seconds: //| diff --git a/shared-bindings/analogio/AnalogIn.c b/shared-bindings/analogio/AnalogIn.c index e1f9f195c8..636c2500bf 100644 --- a/shared-bindings/analogio/AnalogIn.c +++ b/shared-bindings/analogio/AnalogIn.c @@ -126,7 +126,8 @@ const mp_obj_property_t analogio_analogin_value_obj = { //| reference_voltage: float //| """The maximum voltage measurable (also known as the reference voltage) as a -//| `float` in Volts.""" +//| `float` in Volts. Note the ADC value may not scale to the actual voltage linearly +//| at ends of the analog range.""" //| STATIC mp_obj_t analogio_analogin_obj_get_reference_voltage(mp_obj_t self_in) { analogio_analogin_obj_t *self = MP_OBJ_TO_PTR(self_in); diff --git a/shared-bindings/audiobusio/I2SOut.c b/shared-bindings/audiobusio/I2SOut.c index c343df242c..6254f7cde2 100644 --- a/shared-bindings/audiobusio/I2SOut.c +++ b/shared-bindings/audiobusio/I2SOut.c @@ -72,7 +72,6 @@ //| Playing a wave file from flash:: //| //| import board -//| import audioio //| import audiocore //| import audiobusio //| import digitalio @@ -155,7 +154,7 @@ STATIC mp_obj_t audiobusio_i2sout_obj___exit__(size_t n_args, const mp_obj_t *ar STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audiobusio_i2sout___exit___obj, 4, 4, audiobusio_i2sout_obj___exit__); -//| def play(self, sample: _typing.AudioSample, *, loop: bool = False) -> None: +//| def play(self, sample: circuitpython_typing.AudioSample, *, loop: bool = False) -> None: //| """Plays the sample once when loop=False and continuously when loop=True. //| Does not block. Use `playing` to block. //| diff --git a/shared-bindings/audiobusio/__init__.c b/shared-bindings/audiobusio/__init__.c index 0476443768..34ce9ef696 100644 --- a/shared-bindings/audiobusio/__init__.c +++ b/shared-bindings/audiobusio/__init__.c @@ -41,7 +41,7 @@ //| chips in the same circuit. It doesn't include audio interconnect protocols //| such as S/PDIF. //| -//| All libraries change hardware state and should be deinitialized when they +//| All classes change hardware state and should be deinitialized when they //| are no longer needed. To do so, either call :py:meth:`!deinit` or use a //| context manager.""" //| diff --git a/shared-bindings/audiocore/RawSample.c b/shared-bindings/audiocore/RawSample.c index c3af2f30f0..05c5b14b5e 100644 --- a/shared-bindings/audiocore/RawSample.c +++ b/shared-bindings/audiocore/RawSample.c @@ -43,7 +43,7 @@ //| first sample will be for channel 1, the second sample will be for channel two, the third for //| channel 1 and so on. //| -//| :param ~_typing.ReadableBuffer buffer: A buffer with samples +//| :param ~circuitpython_typing.ReadableBuffer buffer: A buffer with samples //| :param int channel_count: The number of channels in the buffer //| :param int sample_rate: The desired playback sample rate //| diff --git a/shared-bindings/audiocore/WaveFile.c b/shared-bindings/audiocore/WaveFile.c index 74ea9fda9f..1a8b5cae11 100644 --- a/shared-bindings/audiocore/WaveFile.c +++ b/shared-bindings/audiocore/WaveFile.c @@ -44,7 +44,7 @@ //| """Load a .wav file for playback with `audioio.AudioOut` or `audiobusio.I2SOut`. //| //| :param typing.BinaryIO file: Already opened wave file -//| :param ~_typing.WriteableBuffer buffer: Optional pre-allocated buffer, +//| :param ~circuitpython_typing.WriteableBuffer buffer: Optional pre-allocated buffer, //| that will be split in half and used for double-buffering of the data. //| The buffer must be 8 to 1024 bytes long. //| If not provided, two 256 byte buffers are initially allocated internally. diff --git a/shared-bindings/audioio/AudioOut.c b/shared-bindings/audioio/AudioOut.c index 80072e9128..2fd4c0c452 100644 --- a/shared-bindings/audioio/AudioOut.c +++ b/shared-bindings/audioio/AudioOut.c @@ -146,7 +146,7 @@ STATIC mp_obj_t audioio_audioout_obj___exit__(size_t n_args, const mp_obj_t *arg STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audioio_audioout___exit___obj, 4, 4, audioio_audioout_obj___exit__); -//| def play(self, sample: _typing.AudioSample, *, loop: bool = False) -> None: +//| def play(self, sample: circuitpython_typing.AudioSample, *, loop: bool = False) -> None: //| """Plays the sample once when loop=False and continuously when loop=True. //| Does not block. Use `playing` to block. //| diff --git a/shared-bindings/audiomixer/Mixer.c b/shared-bindings/audiomixer/Mixer.c index 619e2c095c..3248e649c9 100644 --- a/shared-bindings/audiomixer/Mixer.c +++ b/shared-bindings/audiomixer/Mixer.c @@ -211,7 +211,7 @@ const mp_obj_property_t audiomixer_mixer_voice_obj = { MP_ROM_NONE}, }; -//| def play(self, sample: _typing.AudioSample, *, voice: int = 0, loop: bool = False) -> None: +//| def play(self, sample: circuitpython_typing.AudioSample, *, voice: int = 0, loop: bool = False) -> None: //| """Plays the sample once when loop=False and continuously when loop=True. //| Does not block. Use `playing` to block. //| diff --git a/shared-bindings/audiomixer/MixerVoice.c b/shared-bindings/audiomixer/MixerVoice.c index d3bac8c3de..82b6972864 100644 --- a/shared-bindings/audiomixer/MixerVoice.c +++ b/shared-bindings/audiomixer/MixerVoice.c @@ -57,7 +57,7 @@ STATIC mp_obj_t audiomixer_mixervoice_make_new(const mp_obj_type_t *type, size_t return MP_OBJ_FROM_PTR(self); } -//| def play(self, sample: _typing.AudioSample, *, loop: bool = False) -> None: +//| def play(self, sample: circuitpython_typing.AudioSample, *, loop: bool = False) -> None: //| """Plays the sample once when ``loop=False``, and continuously when ``loop=True``. //| Does not block. Use `playing` to block. //| diff --git a/shared-bindings/audiomp3/MP3Decoder.c b/shared-bindings/audiomp3/MP3Decoder.c index 589751821d..4761feacd8 100644 --- a/shared-bindings/audiomp3/MP3Decoder.c +++ b/shared-bindings/audiomp3/MP3Decoder.c @@ -42,7 +42,7 @@ //| """Load a .mp3 file for playback with `audioio.AudioOut` or `audiobusio.I2SOut`. //| //| :param typing.BinaryIO file: Already opened mp3 file -//| :param ~_typing.WriteableBuffer buffer: Optional pre-allocated buffer, that will be split in half and used for double-buffering of the data. If not provided, two buffers are allocated internally. The specific buffer size required depends on the mp3 file. +//| :param ~circuitpython_typing.WriteableBuffer buffer: Optional pre-allocated buffer, that will be split in half and used for double-buffering of the data. If not provided, two buffers are allocated internally. The specific buffer size required depends on the mp3 file. //| //| //| Playing a mp3 file from flash:: @@ -232,6 +232,22 @@ const mp_obj_property_t audiomp3_mp3file_rms_level_obj = { MP_ROM_NONE}, }; +//| samples_decoded: int +//| """The number of audio samples decoded from the current file. (read only)""" +//| +STATIC mp_obj_t audiomp3_mp3file_obj_get_samples_decoded(mp_obj_t self_in) { + audiomp3_mp3file_obj_t *self = MP_OBJ_TO_PTR(self_in); + check_for_deinit(self); + return MP_OBJ_NEW_SMALL_INT(common_hal_audiomp3_mp3file_get_samples_decoded(self)); +} +MP_DEFINE_CONST_FUN_OBJ_1(audiomp3_mp3file_get_samples_decoded_obj, audiomp3_mp3file_obj_get_samples_decoded); + +const mp_obj_property_t audiomp3_mp3file_samples_decoded_obj = { + .base.type = &mp_type_property, + .proxy = {(mp_obj_t)&audiomp3_mp3file_get_samples_decoded_obj, + MP_ROM_NONE, + MP_ROM_NONE}, +}; STATIC const mp_rom_map_elem_t audiomp3_mp3file_locals_dict_table[] = { // Methods @@ -245,6 +261,7 @@ STATIC const mp_rom_map_elem_t audiomp3_mp3file_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_bits_per_sample), MP_ROM_PTR(&audiomp3_mp3file_bits_per_sample_obj) }, { MP_ROM_QSTR(MP_QSTR_channel_count), MP_ROM_PTR(&audiomp3_mp3file_channel_count_obj) }, { MP_ROM_QSTR(MP_QSTR_rms_level), MP_ROM_PTR(&audiomp3_mp3file_rms_level_obj) }, + { MP_ROM_QSTR(MP_QSTR_samples_decoded), MP_ROM_PTR(&audiomp3_mp3file_samples_decoded_obj) }, }; STATIC MP_DEFINE_CONST_DICT(audiomp3_mp3file_locals_dict, audiomp3_mp3file_locals_dict_table); diff --git a/shared-bindings/audiomp3/MP3Decoder.h b/shared-bindings/audiomp3/MP3Decoder.h index 2428cedf16..e1f4fcff4a 100644 --- a/shared-bindings/audiomp3/MP3Decoder.h +++ b/shared-bindings/audiomp3/MP3Decoder.h @@ -46,5 +46,6 @@ void common_hal_audiomp3_mp3file_set_sample_rate(audiomp3_mp3file_obj_t *self, u uint8_t common_hal_audiomp3_mp3file_get_bits_per_sample(audiomp3_mp3file_obj_t *self); uint8_t common_hal_audiomp3_mp3file_get_channel_count(audiomp3_mp3file_obj_t *self); float common_hal_audiomp3_mp3file_get_rms_level(audiomp3_mp3file_obj_t *self); +uint32_t common_hal_audiomp3_mp3file_get_samples_decoded(audiomp3_mp3file_obj_t *self); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_AUDIOIO_MP3FILE_H diff --git a/shared-bindings/audiopwmio/PWMAudioOut.c b/shared-bindings/audiopwmio/PWMAudioOut.c index cded4a634f..85332d0fac 100644 --- a/shared-bindings/audiopwmio/PWMAudioOut.c +++ b/shared-bindings/audiopwmio/PWMAudioOut.c @@ -148,7 +148,7 @@ STATIC mp_obj_t audiopwmio_pwmaudioout_obj___exit__(size_t n_args, const mp_obj_ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audiopwmio_pwmaudioout___exit___obj, 4, 4, audiopwmio_pwmaudioout_obj___exit__); -//| def play(self, sample: _typing.AudioSample, *, loop: bool = False) -> None: +//| def play(self, sample: circuitpython_typing.AudioSample, *, loop: bool = False) -> None: //| """Plays the sample once when loop=False and continuously when loop=True. //| Does not block. Use `playing` to block. //| diff --git a/shared-bindings/bitbangio/I2C.c b/shared-bindings/bitbangio/I2C.c index b47ace149f..c65b184ca0 100644 --- a/shared-bindings/bitbangio/I2C.c +++ b/shared-bindings/bitbangio/I2C.c @@ -292,8 +292,8 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bitbangio_i2c_writeto_obj, 1, bitbangio_i2c_wr //| The number of bytes read will be the length of ``out_buffer[in_start:in_end]``. //| :param int address: 7-bit device address -//| :param ~_typing.ReadableBuffer out_buffer: buffer containing the bytes to write -//| :param ~_typing.WriteableBuffer in_buffer: buffer to write into +//| :param ~circuitpython_typing.ReadableBuffer out_buffer: buffer containing the bytes to write +//| :param ~circuitpython_typing.WriteableBuffer in_buffer: buffer to write into //| :param int out_start: beginning of ``out_buffer`` slice //| :param int out_end: end of ``out_buffer`` slice; if not specified, use ``len(out_buffer)`` //| :param int in_start: beginning of ``in_buffer`` slice diff --git a/shared-bindings/bitmaptools/__init__.c b/shared-bindings/bitmaptools/__init__.c index ec26eab98e..df6292afec 100644 --- a/shared-bindings/bitmaptools/__init__.c +++ b/shared-bindings/bitmaptools/__init__.c @@ -255,7 +255,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(bitmaptools_rotozoom_obj, 0, bitmaptools_obj_rotozoom // requires at least 2 arguments (destination bitmap and source bitmap) //| -//| def alphablend(dest_bitmap, source_bitmap_1, source_bitmap_2, colorspace: displayio.Colorspace, factor1: float=.5, factor2: float=None): +//| def alphablend(dest_bitmap: displayio.Bitmap , source_bitmap_1: displayio.Bitmap, source_bitmap_2: displayio.Bitmap, colorspace: displayio.Colorspace, factor1: float=.5, factor2: float=None) -> None: //| """Alpha blend the two source bitmaps into the destination. //| //| It is permitted for the destination bitmap to be one of the two diff --git a/shared-bindings/board/__init__.c b/shared-bindings/board/__init__.c index bb273c61a9..8b2738a248 100644 --- a/shared-bindings/board/__init__.c +++ b/shared-bindings/board/__init__.c @@ -28,12 +28,15 @@ #include "py/runtime.h" #include "shared-bindings/board/__init__.h" -#if BOARD_I2C +#if CIRCUITPY_BOARD_I2C #include "shared-bindings/busio/I2C.h" #endif -#if BOARD_SPI +#if CIRCUITPY_BOARD_SPI #include "shared-bindings/busio/SPI.h" #endif +#if CIRCUITPY_BOARD_UART +#include "shared-bindings/busio/UART.h" +#endif //| """Board specific pin names //| @@ -47,84 +50,57 @@ //| """Board ID string. The unique identifier for the board model in //| circuitpython, as well as on circuitpython.org. //| Example: "hallowing_m0_express".""" -//| //| def I2C() -> busio.I2C: -//| """Returns the `busio.I2C` object for the board designated SDA and SCL pins. It is a singleton.""" +//| """Returns the `busio.I2C` object for the board's designated I2C bus(es). +//| The object created is a singleton, and uses the default parameter values for `busio.I2C`.""" //| ... //| - -#if BOARD_I2C -mp_obj_t board_i2c(void) { - mp_obj_t singleton = common_hal_board_get_i2c(); - if (singleton != NULL && !common_hal_busio_i2c_deinited(singleton)) { - return singleton; - } - assert_pin_free(DEFAULT_I2C_BUS_SDA); - assert_pin_free(DEFAULT_I2C_BUS_SCL); - return common_hal_board_create_i2c(); +#if CIRCUITPY_BOARD_I2C +STATIC mp_obj_t board_i2c_0(void) { + return common_hal_board_create_i2c(0); } #else -mp_obj_t board_i2c(void) { +STATIC mp_obj_t board_i2c_0(void) { mp_raise_NotImplementedError_varg(translate("No default %q bus"), MP_QSTR_I2C); return MP_ROM_NONE; } #endif -MP_DEFINE_CONST_FUN_OBJ_0(board_i2c_obj, board_i2c); - +MP_DEFINE_CONST_FUN_OBJ_0(board_i2c_obj, board_i2c_0); //| def SPI() -> busio.SPI: -//| """Returns the `busio.SPI` object for the board designated SCK, MOSI and MISO pins. It is a -//| singleton.""" +//| """Returns the `busio.SPI` object for the board's designated SPI bus(es). +//| The object created is a singleton, and uses the default parameter values for `busio.SPI`.""" //| ... //| -#if BOARD_SPI -mp_obj_t board_spi(void) { - mp_obj_t singleton = common_hal_board_get_spi(); - if (singleton != NULL && !common_hal_busio_spi_deinited(singleton)) { - return singleton; - } - assert_pin_free(DEFAULT_SPI_BUS_SCK); - assert_pin_free(DEFAULT_SPI_BUS_MOSI); - assert_pin_free(DEFAULT_SPI_BUS_MISO); - return common_hal_board_create_spi(); +#if CIRCUITPY_BOARD_SPI +STATIC mp_obj_t board_spi_0(void) { + return common_hal_board_create_spi(0); } #else -mp_obj_t board_spi(void) { +STATIC mp_obj_t board_spi_0(void) { mp_raise_NotImplementedError_varg(translate("No default %q bus"), MP_QSTR_SPI); return MP_ROM_NONE; } #endif -MP_DEFINE_CONST_FUN_OBJ_0(board_spi_obj, board_spi); +MP_DEFINE_CONST_FUN_OBJ_0(board_spi_obj, board_spi_0); //| def UART() -> busio.UART: -//| """Returns the `busio.UART` object for the board designated TX and RX pins. It is a singleton. -//| -//| The object created uses the default parameter values for `busio.UART`. If you need to set -//| parameters that are not changeable after creation, such as ``receiver_buffer_size``, -//| do not use `board.UART()`; instead create a `busio.UART` object explicitly with the -//| desired parameters.""" +//| """Returns the `busio.UART` object for the board's designated UART bus(es). +//| The object created is a singleton, and uses the default parameter values for `busio.UART`.""" //| ... //| -#if BOARD_UART -mp_obj_t board_uart(void) { - mp_obj_t singleton = common_hal_board_get_uart(); - if (singleton != NULL) { - return singleton; - } - - assert_pin_free(DEFAULT_UART_BUS_RX); - assert_pin_free(DEFAULT_UART_BUS_TX); - - return common_hal_board_create_uart(); +#if CIRCUITPY_BOARD_UART +STATIC mp_obj_t board_uart_0(void) { + return common_hal_board_create_uart(0); } #else -mp_obj_t board_uart(void) { +STATIC mp_obj_t board_uart_0(void) { mp_raise_NotImplementedError_varg(translate("No default %q bus"), MP_QSTR_UART); return MP_ROM_NONE; } #endif -MP_DEFINE_CONST_FUN_OBJ_0(board_uart_obj, board_uart); +MP_DEFINE_CONST_FUN_OBJ_0(board_uart_obj, board_uart_0); const mp_obj_module_t board_module = { .base = { &mp_type_module }, diff --git a/shared-bindings/board/__init__.h b/shared-bindings/board/__init__.h index bc4d7df61f..b668e0a04b 100644 --- a/shared-bindings/board/__init__.h +++ b/shared-bindings/board/__init__.h @@ -35,21 +35,29 @@ extern const mp_obj_dict_t board_module_globals; STATIC const MP_DEFINE_STR_OBJ(board_module_id_obj, CIRCUITPY_BOARD_ID); -mp_obj_t common_hal_board_get_i2c(void); -mp_obj_t common_hal_board_create_i2c(void); +bool common_hal_board_is_i2c(mp_obj_t obj); +mp_obj_t common_hal_board_get_i2c(const mp_int_t instance); +mp_obj_t common_hal_board_create_i2c(const mp_int_t instance); +mp_obj_t board_i2c(size_t n_args, const mp_obj_t *args); MP_DECLARE_CONST_FUN_OBJ_0(board_i2c_obj); -mp_obj_t common_hal_board_get_spi(void); -mp_obj_t common_hal_board_create_spi(void); +bool common_hal_board_is_spi(mp_obj_t obj); +mp_obj_t common_hal_board_get_spi(const mp_int_t instance); +mp_obj_t common_hal_board_create_spi(const mp_int_t instance); +mp_obj_t board_spi(size_t n_args, const mp_obj_t *args); MP_DECLARE_CONST_FUN_OBJ_0(board_spi_obj); -mp_obj_t common_hal_board_get_uart(void); -mp_obj_t common_hal_board_create_uart(void); +bool common_hal_board_is_uart(mp_obj_t obj); +mp_obj_t common_hal_board_get_uart(const mp_int_t instance); +mp_obj_t common_hal_board_create_uart(const mp_int_t instance); +mp_obj_t board_uart(size_t n_args, const mp_obj_t *args); MP_DECLARE_CONST_FUN_OBJ_0(board_uart_obj); -mp_obj_t board_i2c(void); -mp_obj_t board_spi(void); -mp_obj_t board_uart(void); +#define CIRCUITPY_BOARD_BUS_SINGLETON(name, bus, instance) \ + STATIC mp_obj_t board_##name(void) { \ + return common_hal_board_create_##bus(instance); \ + } \ + MP_DEFINE_CONST_FUN_OBJ_0(board_##name##_obj, board_##name); #define CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS \ { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_board) }, \ diff --git a/shared-bindings/busio/I2C.c b/shared-bindings/busio/I2C.c index 4aea62a8a5..2d67281df0 100644 --- a/shared-bindings/busio/I2C.c +++ b/shared-bindings/busio/I2C.c @@ -58,10 +58,7 @@ //| :param int frequency: The clock frequency in Hertz //| :param int timeout: The maximum clock stretching timeut - (used only for //| :class:`bitbangio.I2C`; ignored for :class:`busio.I2C`) -//| -//| .. note:: On the nRF52840, only one I2C object may be created, -//| except on the Circuit Playground Bluefruit, which allows two, -//| one for the onboard accelerometer, and one for offboard use.""" +//| """ //| ... //| STATIC mp_obj_t busio_i2c_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { @@ -191,23 +188,6 @@ MP_DEFINE_CONST_FUN_OBJ_1(busio_i2c_unlock_obj, busio_i2c_obj_unlock); //| :param int end: end of buffer slice; if not specified, use ``len(buffer)``""" //| ... //| -// Shared arg parsing for readfrom_into and writeto_then_readfrom. -STATIC void readfrom(busio_i2c_obj_t *self, mp_int_t address, mp_obj_t buffer, int32_t start, mp_int_t end) { - mp_buffer_info_t bufinfo; - mp_get_buffer_raise(buffer, &bufinfo, MP_BUFFER_WRITE); - - size_t length = bufinfo.len; - normalize_buffer_bounds(&start, end, &length); - if (length == 0) { - mp_raise_ValueError(translate("Buffer must be at least length 1")); - } - - uint8_t status = common_hal_busio_i2c_read(self, address, ((uint8_t *)bufinfo.buf) + start, length); - if (status != 0) { - mp_raise_OSError(status); - } -} - STATIC mp_obj_t busio_i2c_readfrom_into(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_address, ARG_buffer, ARG_start, ARG_end }; static const mp_arg_t allowed_args[] = { @@ -219,11 +199,27 @@ STATIC mp_obj_t busio_i2c_readfrom_into(size_t n_args, const mp_obj_t *pos_args, busio_i2c_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); check_for_deinit(self); check_lock(self); + mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - readfrom(self, args[ARG_address].u_int, args[ARG_buffer].u_obj, args[ARG_start].u_int, - args[ARG_end].u_int); + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(args[ARG_buffer].u_obj, &bufinfo, MP_BUFFER_WRITE); + + size_t length = bufinfo.len; + int32_t start = args[ARG_start].u_int; + const int32_t end = args[ARG_end].u_int; + normalize_buffer_bounds(&start, end, &length); + if (length == 0) { + mp_raise_ValueError_varg(translate("%q length must be >= 1"), MP_QSTR_buffer); + } + + uint8_t status = + common_hal_busio_i2c_read(self, args[ARG_address].u_int, ((uint8_t *)bufinfo.buf) + start, length); + if (status != 0) { + mp_raise_OSError(status); + } + return mp_const_none; } MP_DEFINE_CONST_FUN_OBJ_KW(busio_i2c_readfrom_into_obj, 1, busio_i2c_readfrom_into); @@ -247,23 +243,6 @@ MP_DEFINE_CONST_FUN_OBJ_KW(busio_i2c_readfrom_into_obj, 1, busio_i2c_readfrom_in //| """ //| ... //| -// Shared arg parsing for writeto and writeto_then_readfrom. -STATIC void writeto(busio_i2c_obj_t *self, mp_int_t address, mp_obj_t buffer, int32_t start, mp_int_t end, bool stop) { - // get the buffer to write the data from - mp_buffer_info_t bufinfo; - mp_get_buffer_raise(buffer, &bufinfo, MP_BUFFER_READ); - - size_t length = bufinfo.len; - normalize_buffer_bounds(&start, end, &length); - - // do the transfer - uint8_t status = common_hal_busio_i2c_write(self, address, ((uint8_t *)bufinfo.buf) + start, - length, stop); - if (status != 0) { - mp_raise_OSError(status); - } -} - STATIC mp_obj_t busio_i2c_writeto(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_address, ARG_buffer, ARG_start, ARG_end }; static const mp_arg_t allowed_args[] = { @@ -278,8 +257,23 @@ STATIC mp_obj_t busio_i2c_writeto(size_t n_args, const mp_obj_t *pos_args, mp_ma mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - writeto(self, args[ARG_address].u_int, args[ARG_buffer].u_obj, args[ARG_start].u_int, - args[ARG_end].u_int, true); + // get the buffer to write the data from + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(args[ARG_buffer].u_obj, &bufinfo, MP_BUFFER_READ); + + size_t length = bufinfo.len; + int32_t start = args[ARG_start].u_int; + const int32_t end = args[ARG_end].u_int; + normalize_buffer_bounds(&start, end, &length); + + // do the transfer + uint8_t status = + common_hal_busio_i2c_write(self, args[ARG_address].u_int, ((uint8_t *)bufinfo.buf) + start, length); + + if (status != 0) { + mp_raise_OSError(status); + } + return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(busio_i2c_writeto_obj, 1, busio_i2c_writeto); @@ -299,8 +293,8 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(busio_i2c_writeto_obj, 1, busio_i2c_writeto); //| The number of bytes read will be the length of ``out_buffer[in_start:in_end]``. //| :param int address: 7-bit device address -//| :param ~_typing.ReadableBuffer out_buffer: buffer containing the bytes to write -//| :param ~_typing.WriteableBuffer in_buffer: buffer to write into +//| :param ~circuitpython_typing.ReadableBuffer out_buffer: buffer containing the bytes to write +//| :param ~circuitpython_typing.WriteableBuffer in_buffer: buffer to write into //| :param int out_start: beginning of ``out_buffer`` slice //| :param int out_end: end of ``out_buffer`` slice; if not specified, use ``len(out_buffer)`` //| :param int in_start: beginning of ``in_buffer`` slice @@ -314,10 +308,10 @@ STATIC mp_obj_t busio_i2c_writeto_then_readfrom(size_t n_args, const mp_obj_t *p { MP_QSTR_address, MP_ARG_REQUIRED | MP_ARG_INT, {.u_int = 0} }, { MP_QSTR_out_buffer, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, { MP_QSTR_in_buffer, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, - { MP_QSTR_out_start, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} }, - { MP_QSTR_out_end, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = INT_MAX} }, - { MP_QSTR_in_start, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} }, - { MP_QSTR_in_end, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = INT_MAX} }, + { MP_QSTR_out_start, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} }, + { MP_QSTR_out_end, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = INT_MAX} }, + { MP_QSTR_in_start, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} }, + { MP_QSTR_in_end, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = INT_MAX} }, }; busio_i2c_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); check_for_deinit(self); @@ -325,10 +319,30 @@ STATIC mp_obj_t busio_i2c_writeto_then_readfrom(size_t n_args, const mp_obj_t *p mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - writeto(self, args[ARG_address].u_int, args[ARG_out_buffer].u_obj, args[ARG_out_start].u_int, - args[ARG_out_end].u_int, false); - readfrom(self, args[ARG_address].u_int, args[ARG_in_buffer].u_obj, args[ARG_in_start].u_int, - args[ARG_in_end].u_int); + mp_buffer_info_t out_bufinfo; + mp_get_buffer_raise(args[ARG_out_buffer].u_obj, &out_bufinfo, MP_BUFFER_READ); + + size_t out_length = out_bufinfo.len; + int32_t out_start = args[ARG_out_start].u_int; + const int32_t out_end = args[ARG_out_end].u_int; + normalize_buffer_bounds(&out_start, out_end, &out_length); + + mp_buffer_info_t in_bufinfo; + mp_get_buffer_raise(args[ARG_in_buffer].u_obj, &in_bufinfo, MP_BUFFER_WRITE); + + size_t in_length = in_bufinfo.len; + int32_t in_start = args[ARG_in_start].u_int; + const int32_t in_end = args[ARG_in_end].u_int; + normalize_buffer_bounds(&in_start, in_end, &in_length); + if (in_length == 0) { + mp_raise_ValueError_varg(translate("%q length must be >= 1"), MP_QSTR_out_buffer); + } + + uint8_t status = common_hal_busio_i2c_write_read(self, args[ARG_address].u_int, + ((uint8_t *)out_bufinfo.buf) + out_start, out_length,((uint8_t *)in_bufinfo.buf) + in_start, in_length); + if (status != 0) { + mp_raise_OSError(status); + } return mp_const_none; } diff --git a/shared-bindings/busio/I2C.h b/shared-bindings/busio/I2C.h index 08701938c9..0999865fbf 100644 --- a/shared-bindings/busio/I2C.h +++ b/shared-bindings/busio/I2C.h @@ -61,14 +61,17 @@ extern bool common_hal_busio_i2c_probe(busio_i2c_obj_t *self, uint8_t addr); // Write to the device and return 0 on success or an appropriate error code from mperrno.h extern uint8_t common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t address, - const uint8_t *data, size_t len, - bool stop); + const uint8_t *data, size_t len); // Reads memory of the i2c device picking up where it left off and return 0 on // success or an appropriate error code from mperrno.h extern uint8_t common_hal_busio_i2c_read(busio_i2c_obj_t *self, uint16_t address, uint8_t *data, size_t len); +// Do a write and then a read in the same I2C transaction. +uint8_t common_hal_busio_i2c_write_read(busio_i2c_obj_t *self, uint16_t address, + uint8_t *out_data, size_t out_len, uint8_t *in_data, size_t in_len); + // This is used by the supervisor to claim I2C devices indefinitely. extern void common_hal_busio_i2c_never_reset(busio_i2c_obj_t *self); diff --git a/shared-bindings/busio/SPI.c b/shared-bindings/busio/SPI.c index 6cbc05e3e7..df364fcbb9 100644 --- a/shared-bindings/busio/SPI.c +++ b/shared-bindings/busio/SPI.c @@ -53,7 +53,7 @@ //| multiple secondaries can share the `!clock`, `!MOSI` and `!MISO` lines //| and therefore the hardware.)""" //| -//| def __init__(self, clock: microcontroller.Pin, MOSI: Optional[microcontroller.Pin] = None, MISO: Optional[microcontroller.Pin] = None) -> None: +//| def __init__(self, clock: microcontroller.Pin, MOSI: Optional[microcontroller.Pin] = None, MISO: Optional[microcontroller.Pin] = None, half_duplex: bool = False) -> None: //| //| """Construct an SPI object on the given pins. //| @@ -74,7 +74,8 @@ //| //| :param ~microcontroller.Pin clock: the pin to use for the clock. //| :param ~microcontroller.Pin MOSI: the Main Out Selected In pin. -//| :param ~microcontroller.Pin MISO: the Main In Selected Out pin.""" +//| :param ~microcontroller.Pin MISO: the Main In Selected Out pin. +//| :param bool half_duplex: True when MOSI is used for bidirectional data. False when SPI is full-duplex or simplex.""" //| ... //| @@ -84,11 +85,12 @@ STATIC mp_obj_t busio_spi_make_new(const mp_obj_type_t *type, size_t n_args, siz #if CIRCUITPY_BUSIO_SPI busio_spi_obj_t *self = m_new_obj(busio_spi_obj_t); self->base.type = &busio_spi_type; - enum { ARG_clock, ARG_MOSI, ARG_MISO }; + enum { ARG_clock, ARG_MOSI, ARG_MISO, ARG_half_duplex }; static const mp_arg_t allowed_args[] = { { MP_QSTR_clock, MP_ARG_REQUIRED | MP_ARG_OBJ }, { MP_QSTR_MOSI, MP_ARG_OBJ, {.u_obj = mp_const_none} }, { MP_QSTR_MISO, MP_ARG_OBJ, {.u_obj = mp_const_none} }, + { MP_QSTR_half_duplex, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_bool = false} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); @@ -101,7 +103,7 @@ STATIC mp_obj_t busio_spi_make_new(const mp_obj_type_t *type, size_t n_args, siz mp_raise_ValueError(translate("Must provide MISO or MOSI pin")); } - common_hal_busio_spi_construct(self, clock, mosi, miso); + common_hal_busio_spi_construct(self, clock, mosi, miso, args[ARG_half_duplex].u_bool); return MP_OBJ_FROM_PTR(self); #else mp_raise_ValueError(translate("Invalid pins")); diff --git a/shared-bindings/busio/SPI.h b/shared-bindings/busio/SPI.h index f4737da0c0..76166580a0 100644 --- a/shared-bindings/busio/SPI.h +++ b/shared-bindings/busio/SPI.h @@ -38,7 +38,7 @@ extern const mp_obj_type_t busio_spi_type; // Construct an underlying SPI object. extern void common_hal_busio_spi_construct(busio_spi_obj_t *self, const mcu_pin_obj_t *clock, const mcu_pin_obj_t *mosi, - const mcu_pin_obj_t *miso); + const mcu_pin_obj_t *miso, bool half_duplex); extern void common_hal_busio_spi_deinit(busio_spi_obj_t *self); extern bool common_hal_busio_spi_deinited(busio_spi_obj_t *self); diff --git a/shared-bindings/_typing/__init__.pyi b/shared-bindings/circuitpython_typing/__init__.pyi similarity index 100% rename from shared-bindings/_typing/__init__.pyi rename to shared-bindings/circuitpython_typing/__init__.pyi diff --git a/shared-bindings/countio/Counter.c b/shared-bindings/countio/Counter.c index 873da912a6..8582f4497e 100644 --- a/shared-bindings/countio/Counter.c +++ b/shared-bindings/countio/Counter.c @@ -7,47 +7,56 @@ #include "py/runtime0.h" #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/countio/Counter.h" +#include "shared-bindings/countio/Edge.h" #include "shared-bindings/util.h" //| class Counter: -//| """Counter will keep track of the number of falling edge transistions (pulses) on a -//| given pin""" +//| """Count the number of rising- and/or falling-edge transitions on a given pin. +//| """ //| -//| def __init__(self, pin_a: microcontroller.Pin) -> None: -//| """Create a Counter object associated with the given pin. It tracks the number of -//| falling pulses relative when the object is constructed. +//| def __init__(self, pin: microcontroller.Pin, *, edge: Edge = Edge.FALL, pull: Optional[digitalio.Pull]) -> None: +//| """Create a Counter object associated with the given pin that counts +//| rising- and/or falling-edge transitions. At least one of ``rise`` and ``fall`` must be True. +//| The default is to count only falling edges, and is for historical backward compatibility. //| -//| :param ~microcontroller.Pin pin_a: Pin to read pulses from. +//| :param ~microcontroller.Pin pin: pin to monitor +//| :param Edge: which edge transitions to count +//| :param digitalio.Pull: enable a pull-up or pull-down if not None //| //| -//| For example:: +//| For example:: //| -//| import board -//| import countio +//| import board +//| import countio //| -//| pin_counter = countio.Counter(board.D1) -//| #reset the count after 100 counts -//| while True: -//| if pin_counter.count == 100: -//| pin_counter.reset() -//| print(pin_counter.count)""" +//| # Count rising edges only. +//| pin_counter = countio.Counter(board.D1, edge=Edge.RISE) +//| # Reset the count after 100 counts. +//| while True: +//| if pin_counter.count >= 100: +//| pin_counter.reset() +//| print(pin_counter.count) +//| """ +//| ... //| STATIC mp_obj_t countio_counter_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { - enum { ARG_pin_a }; + enum { ARG_pin, ARG_edge, ARG_pull }; static const mp_arg_t allowed_args[] = { - { MP_QSTR_pin_a, MP_ARG_REQUIRED | MP_ARG_OBJ } - + { MP_QSTR_pin, MP_ARG_REQUIRED | MP_ARG_OBJ }, + { MP_QSTR_edge, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = MP_OBJ_FROM_PTR(&edge_FALL_obj) } }, + { MP_QSTR_pull, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - const mcu_pin_obj_t *pin_a = validate_obj_is_free_pin(args[ARG_pin_a].u_obj); - + const mcu_pin_obj_t *pin = validate_obj_is_free_pin(args[ARG_pin].u_obj); + const countio_edge_t edge = validate_edge(args[ARG_edge].u_obj, MP_QSTR_edge); + const digitalio_pull_t pull = validate_pull(args[ARG_pull].u_obj, MP_QSTR_pull); countio_counter_obj_t *self = m_new_obj(countio_counter_obj_t); self->base.type = &countio_counter_type; - common_hal_countio_counter_construct(self, pin_a); + common_hal_countio_counter_construct(self, pin, edge, pull); return MP_OBJ_FROM_PTR(self); } @@ -118,8 +127,7 @@ const mp_obj_property_t countio_counter_count_obj = { STATIC mp_obj_t countio_counter_reset(mp_obj_t self_in) { countio_counter_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); - // set the position to zero for reset - common_hal_countio_counter_reset(self); + common_hal_countio_counter_set_count(self, 0); return mp_const_none; } diff --git a/shared-bindings/countio/Counter.h b/shared-bindings/countio/Counter.h index a9eced41a3..d660cc8f49 100644 --- a/shared-bindings/countio/Counter.h +++ b/shared-bindings/countio/Counter.h @@ -3,16 +3,17 @@ #include "common-hal/microcontroller/Pin.h" #include "common-hal/countio/Counter.h" +#include "shared-bindings/countio/Edge.h" +#include "shared-bindings/digitalio/Pull.h" extern const mp_obj_type_t countio_counter_type; extern void common_hal_countio_counter_construct(countio_counter_obj_t *self, - const mcu_pin_obj_t *pin_a); + const mcu_pin_obj_t *pin, countio_edge_t edge, digitalio_pull_t pull); extern void common_hal_countio_counter_deinit(countio_counter_obj_t *self); extern bool common_hal_countio_counter_deinited(countio_counter_obj_t *self); extern mp_int_t common_hal_countio_counter_get_count(countio_counter_obj_t *self); extern void common_hal_countio_counter_set_count(countio_counter_obj_t *self, mp_int_t new_count); -extern void common_hal_countio_counter_reset(countio_counter_obj_t *self); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_COUNTIO_COUNTER_H diff --git a/shared-bindings/countio/Edge.c b/shared-bindings/countio/Edge.c new file mode 100644 index 0000000000..980b3a3705 --- /dev/null +++ b/shared-bindings/countio/Edge.c @@ -0,0 +1,67 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Dan Halbert for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "py/obj.h" +#include "py/enum.h" +#include "py/runtime.h" + +#include "shared-bindings/countio/Edge.h" + +MAKE_ENUM_VALUE(countio_edge_type, edge, RISE, EDGE_RISE); +MAKE_ENUM_VALUE(countio_edge_type, edge, FALL, EDGE_FALL); +MAKE_ENUM_VALUE(countio_edge_type, edge, RISE_AND_FALL, EDGE_RISE_AND_FALL); + +//| class Edge: +//| """Enumerates which signal transitions can be counted.""" +//| +//| def __init__(self) -> None: +//| """Enum-like class to define which signal transitions to count.""" +//| ... +//| +//| RISE: Edge +//| """Count the rising edges.""" +//| +//| FALL: Edge +//| """Count the falling edges.""" +//| +//| RISE_AND_FALL: Edge +//| """Count the rising and falling edges.""" +//| +MAKE_ENUM_MAP(countio_edge) { + MAKE_ENUM_MAP_ENTRY(edge, RISE), + MAKE_ENUM_MAP_ENTRY(edge, FALL), + MAKE_ENUM_MAP_ENTRY(edge, RISE_AND_FALL), +}; + +STATIC MP_DEFINE_CONST_DICT(countio_edge_locals_dict, countio_edge_locals_table); + +MAKE_PRINTER(countio, countio_edge); + +MAKE_ENUM_TYPE(countio, Edge, countio_edge); + +countio_edge_t validate_edge(mp_obj_t obj, qstr arg_name) { + return cp_enum_value(&countio_edge_type, mp_arg_validate_type(obj, &countio_edge_type, arg_name)); +} diff --git a/shared-bindings/countio/Edge.h b/shared-bindings/countio/Edge.h new file mode 100644 index 0000000000..ca4cddbef3 --- /dev/null +++ b/shared-bindings/countio/Edge.h @@ -0,0 +1,44 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 an Halbertfor Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_COUNTIO_EDGE_H +#define MICROPY_INCLUDED_SHARED_BINDINGS_COUNTIO_EDGE_H + +#include "py/enum.h" +#include "py/obj.h" + +typedef enum _countio_edge_t { + EDGE_RISE, + EDGE_FALL, + EDGE_RISE_AND_FALL, +} countio_edge_t; + +extern const mp_obj_type_t countio_edge_type; +extern const cp_enum_obj_t edge_FALL_obj; + +countio_edge_t validate_edge(mp_obj_t obj, qstr arg_name); + +#endif // MICROPY_INCLUDED_SHARED_BINDINGS_COUNTIO_EDGE_H diff --git a/shared-bindings/countio/__init__.c b/shared-bindings/countio/__init__.c index faa23da9b0..d72ed9fd25 100644 --- a/shared-bindings/countio/__init__.c +++ b/shared-bindings/countio/__init__.c @@ -7,16 +7,12 @@ #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/countio/__init__.h" #include "shared-bindings/countio/Counter.h" +#include "shared-bindings/countio/Edge.h" //| """Support for edge counting //| //| The `countio` module contains logic to read and count edge transistions //| - -//| .. warning:: This module is not available in some SAMD21 (aka M0) builds. See the -//| :ref:`module-support-matrix` for more info. -//| - //| All classes change hardware state and should be deinitialized when they //| are no longer needed if the program continues after use. To do so, either //| call :py:meth:`!deinit` or use a context manager. See @@ -25,7 +21,8 @@ STATIC const mp_rom_map_elem_t countio_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_countio) }, - { MP_ROM_QSTR(MP_QSTR_Counter), MP_ROM_PTR(&countio_counter_type) }, + { MP_ROM_QSTR(MP_QSTR_Counter), MP_ROM_PTR(&countio_counter_type) }, + { MP_ROM_QSTR(MP_QSTR_Edge), MP_ROM_PTR(&countio_edge_type) }, }; STATIC MP_DEFINE_CONST_DICT(countio_module_globals, countio_module_globals_table); diff --git a/shared-bindings/digitalio/DigitalInOut.c b/shared-bindings/digitalio/DigitalInOut.c index cabf500d53..af7defd911 100644 --- a/shared-bindings/digitalio/DigitalInOut.c +++ b/shared-bindings/digitalio/DigitalInOut.c @@ -166,15 +166,7 @@ STATIC mp_obj_t digitalio_digitalinout_switch_to_input(size_t n_args, const mp_o mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - - digitalio_pull_t pull = PULL_NONE; - if (args[ARG_pull].u_rom_obj == MP_ROM_PTR(&digitalio_pull_up_obj)) { - pull = PULL_UP; - } else if (args[ARG_pull].u_rom_obj == MP_ROM_PTR(&digitalio_pull_down_obj)) { - pull = PULL_DOWN; - } - // do the transfer - common_hal_digitalio_digitalinout_switch_to_input(self, pull); + common_hal_digitalio_digitalinout_switch_to_input(self, validate_pull(args[ARG_pull].u_rom_obj, MP_QSTR_pull)); return mp_const_none; } MP_DEFINE_CONST_FUN_OBJ_KW(digitalio_digitalinout_switch_to_input_obj, 1, digitalio_digitalinout_switch_to_input); @@ -320,9 +312,9 @@ STATIC mp_obj_t digitalio_digitalinout_obj_get_pull(mp_obj_t self_in) { } digitalio_pull_t pull = common_hal_digitalio_digitalinout_get_pull(self); if (pull == PULL_UP) { - return (mp_obj_t)&digitalio_pull_up_obj; + return MP_OBJ_FROM_PTR(&digitalio_pull_up_obj); } else if (pull == PULL_DOWN) { - return (mp_obj_t)&digitalio_pull_down_obj; + return MP_OBJ_FROM_PTR(&digitalio_pull_down_obj); } return mp_const_none; } @@ -335,15 +327,8 @@ STATIC mp_obj_t digitalio_digitalinout_obj_set_pull(mp_obj_t self_in, mp_obj_t p mp_raise_AttributeError(translate("Pull not used when direction is output.")); return mp_const_none; } - digitalio_pull_t pull = PULL_NONE; - if (pull_obj == MP_ROM_PTR(&digitalio_pull_up_obj)) { - pull = PULL_UP; - } else if (pull_obj == MP_ROM_PTR(&digitalio_pull_down_obj)) { - pull = PULL_DOWN; - } else if (pull_obj != mp_const_none) { - mp_raise_ValueError(translate("Unsupported pull value.")); - } - common_hal_digitalio_digitalinout_set_pull(self, pull); + + common_hal_digitalio_digitalinout_set_pull(self, validate_pull(pull_obj, MP_QSTR_pull)); return mp_const_none; } MP_DEFINE_CONST_FUN_OBJ_2(digitalio_digitalinout_set_pull_obj, digitalio_digitalinout_obj_set_pull); diff --git a/shared-bindings/digitalio/Pull.c b/shared-bindings/digitalio/Pull.c index 8ded64fb47..4db68dda10 100644 --- a/shared-bindings/digitalio/Pull.c +++ b/shared-bindings/digitalio/Pull.c @@ -24,6 +24,7 @@ * THE SOFTWARE. */ +#include "py/runtime.h" #include "shared-bindings/digitalio/Pull.h" //| class Pull: @@ -72,3 +73,15 @@ const mp_obj_type_t digitalio_pull_type = { .print = digitalio_pull_print, .locals_dict = (mp_obj_dict_t *)&digitalio_pull_locals_dict, }; + +digitalio_pull_t validate_pull(mp_rom_obj_t obj, qstr arg_name) { + if (obj == MP_ROM_PTR(&digitalio_pull_up_obj)) { + return PULL_UP; + } else if (obj == MP_ROM_PTR(&digitalio_pull_down_obj)) { + return PULL_DOWN; + } + if (obj == MP_ROM_NONE) { + return PULL_NONE; + } + mp_raise_TypeError_varg(translate("%q must be of type %q or None"), arg_name, MP_QSTR_Pull); +} diff --git a/shared-bindings/digitalio/Pull.h b/shared-bindings/digitalio/Pull.h index b97e8fb255..f4f6c42690 100644 --- a/shared-bindings/digitalio/Pull.h +++ b/shared-bindings/digitalio/Pull.h @@ -43,4 +43,6 @@ typedef struct { extern const digitalio_pull_obj_t digitalio_pull_up_obj; extern const digitalio_pull_obj_t digitalio_pull_down_obj; +digitalio_pull_t validate_pull(mp_rom_obj_t obj, qstr arg_name); + #endif // MICROPY_INCLUDED_SHARED_BINDINGS_DIGITALIO_PULL_H diff --git a/shared-bindings/displayio/Bitmap.c b/shared-bindings/displayio/Bitmap.c index 526d378812..f8f47d34f4 100644 --- a/shared-bindings/displayio/Bitmap.c +++ b/shared-bindings/displayio/Bitmap.c @@ -222,7 +222,8 @@ STATIC mp_obj_t displayio_bitmap_obj_blit(size_t n_args, const mp_obj_t *pos_arg int16_t x = args[ARG_x].u_int; int16_t y = args[ARG_y].u_int; - displayio_bitmap_t *source = MP_OBJ_TO_PTR(args[ARG_source].u_obj); + displayio_bitmap_t *source = mp_arg_validate_type(args[ARG_source].u_obj, &displayio_bitmap_type, MP_QSTR_source_bitmap); + // ensure that the target bitmap (self) has at least as many `bits_per_value` as the source if (self->bits_per_value < source->bits_per_value) { diff --git a/shared-bindings/displayio/Display.c b/shared-bindings/displayio/Display.c index ca98f9339c..f7b3305439 100644 --- a/shared-bindings/displayio/Display.c +++ b/shared-bindings/displayio/Display.c @@ -84,7 +84,7 @@ //| //| :param display_bus: The bus that the display is connected to //| :type _DisplayBus: FourWire, ParallelBus or I2CDisplay -//| :param ~_typing.ReadableBuffer init_sequence: Byte-packed initialization sequence. +//| :param ~circuitpython_typing.ReadableBuffer init_sequence: Byte-packed initialization sequence. //| :param int width: Width in pixels //| :param int height: Height in pixels //| :param int colstart: The index if the first visible column @@ -444,12 +444,29 @@ const mp_obj_property_t displayio_display_bus_obj = { MP_ROM_NONE}, }; +//| root_group: Group +//| """The root group on the display.""" +//| +//| +STATIC mp_obj_t displayio_display_obj_get_root_group(mp_obj_t self_in) { + displayio_display_obj_t *self = native_display(self_in); + return common_hal_displayio_display_get_root_group(self); +} +MP_DEFINE_CONST_FUN_OBJ_1(displayio_display_get_root_group_obj, displayio_display_obj_get_root_group); + +const mp_obj_property_t displayio_display_root_group_obj = { + .base.type = &mp_type_property, + .proxy = {(mp_obj_t)&displayio_display_get_root_group_obj, + MP_ROM_NONE, + MP_ROM_NONE}, +}; + //| def fill_row(self, y: int, buffer: WriteableBuffer) -> WriteableBuffer: //| """Extract the pixels from a single row //| //| :param int y: The top edge of the area -//| :param ~_typing.WriteableBuffer buffer: The buffer in which to place the pixel data""" +//| :param ~circuitpython_typing.WriteableBuffer buffer: The buffer in which to place the pixel data""" //| ... //| STATIC mp_obj_t displayio_display_obj_fill_row(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { @@ -517,6 +534,7 @@ STATIC const mp_rom_map_elem_t displayio_display_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_height), MP_ROM_PTR(&displayio_display_height_obj) }, { MP_ROM_QSTR(MP_QSTR_rotation), MP_ROM_PTR(&displayio_display_rotation_obj) }, { MP_ROM_QSTR(MP_QSTR_bus), MP_ROM_PTR(&displayio_display_bus_obj) }, + { MP_ROM_QSTR(MP_QSTR_root_group), MP_ROM_PTR(&displayio_display_root_group_obj) }, }; STATIC MP_DEFINE_CONST_DICT(displayio_display_locals_dict, displayio_display_locals_dict_table); diff --git a/shared-bindings/displayio/Display.h b/shared-bindings/displayio/Display.h index 9e0eb64e5f..f193e61d2f 100644 --- a/shared-bindings/displayio/Display.h +++ b/shared-bindings/displayio/Display.h @@ -69,6 +69,6 @@ mp_float_t common_hal_displayio_display_get_brightness(displayio_display_obj_t * bool common_hal_displayio_display_set_brightness(displayio_display_obj_t *self, mp_float_t brightness); mp_obj_t common_hal_displayio_display_get_bus(displayio_display_obj_t *self); - +mp_obj_t common_hal_displayio_display_get_root_group(displayio_display_obj_t *self); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYIO_DISPLAY_H diff --git a/shared-bindings/displayio/EPaperDisplay.c b/shared-bindings/displayio/EPaperDisplay.c index 06245c90ae..aa14594d97 100644 --- a/shared-bindings/displayio/EPaperDisplay.c +++ b/shared-bindings/displayio/EPaperDisplay.c @@ -63,7 +63,7 @@ //| refresh_display_command: int, refresh_time: float = 40, //| busy_pin: Optional[microcontroller.Pin] = None, busy_state: bool = True, //| seconds_per_frame: float = 180, always_toggle_chip_select: bool = False, -//| grayscale: bool = False) -> None: +//| grayscale: bool = False, two_byte_sequence_length: bool = False) -> None: //| """Create a EPaperDisplay object on the given display bus (`displayio.FourWire` or `paralleldisplay.ParallelBus`). //| //| The ``start_sequence`` and ``stop_sequence`` are bitpacked to minimize the ram impact. Every @@ -76,8 +76,8 @@ //| //| :param display_bus: The bus that the display is connected to //| :type _DisplayBus: displayio.FourWire or paralleldisplay.ParallelBus -//| :param ~_typing.ReadableBuffer start_sequence: Byte-packed initialization sequence. -//| :param ~_typing.ReadableBuffer stop_sequence: Byte-packed initialization sequence. +//| :param ~circuitpython_typing.ReadableBuffer start_sequence: Byte-packed initialization sequence. +//| :param ~circuitpython_typing.ReadableBuffer stop_sequence: Byte-packed initialization sequence. //| :param int width: Width in pixels //| :param int height: Height in pixels //| :param int ram_width: RAM width in pixels @@ -100,7 +100,8 @@ //| :param bool busy_state: State of the busy pin when the display is busy //| :param float seconds_per_frame: Minimum number of seconds between screen refreshes //| :param bool always_toggle_chip_select: When True, chip select is toggled every byte -//| :param bool grayscale: When true, the color ram is the low bit of 2-bit grayscale""" +//| :param bool grayscale: When true, the color ram is the low bit of 2-bit grayscale +//| :param bool two_byte_sequence_length: When true, use two bytes to define sequence length""" //| ... //| STATIC mp_obj_t displayio_epaperdisplay_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { @@ -110,7 +111,7 @@ STATIC mp_obj_t displayio_epaperdisplay_make_new(const mp_obj_type_t *type, size ARG_set_current_row_command, ARG_write_black_ram_command, ARG_black_bits_inverted, ARG_write_color_ram_command, ARG_color_bits_inverted, ARG_highlight_color, ARG_refresh_display_command, ARG_refresh_time, ARG_busy_pin, ARG_busy_state, - ARG_seconds_per_frame, ARG_always_toggle_chip_select, ARG_grayscale }; + ARG_seconds_per_frame, ARG_always_toggle_chip_select, ARG_grayscale, ARG_two_byte_sequence_length }; static const mp_arg_t allowed_args[] = { { MP_QSTR_display_bus, MP_ARG_REQUIRED | MP_ARG_OBJ }, { MP_QSTR_start_sequence, MP_ARG_REQUIRED | MP_ARG_OBJ }, @@ -138,6 +139,7 @@ STATIC mp_obj_t displayio_epaperdisplay_make_new(const mp_obj_type_t *type, size { MP_QSTR_seconds_per_frame, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = MP_OBJ_NEW_SMALL_INT(180)} }, { MP_QSTR_always_toggle_chip_select, MP_ARG_BOOL | MP_ARG_KW_ONLY, {.u_bool = false} }, { MP_QSTR_grayscale, MP_ARG_BOOL | MP_ARG_KW_ONLY, {.u_bool = false} }, + { MP_QSTR_two_byte_sequence_length, MP_ARG_BOOL | MP_ARG_KW_ONLY, {.u_bool = false} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); @@ -182,7 +184,7 @@ STATIC mp_obj_t displayio_epaperdisplay_make_new(const mp_obj_type_t *type, size args[ARG_write_black_ram_command].u_int, args[ARG_black_bits_inverted].u_bool, write_color_ram_command, args[ARG_color_bits_inverted].u_bool, highlight_color, args[ARG_refresh_display_command].u_int, refresh_time, busy_pin, args[ARG_busy_state].u_bool, seconds_per_frame, - args[ARG_always_toggle_chip_select].u_bool, args[ARG_grayscale].u_bool + args[ARG_always_toggle_chip_select].u_bool, args[ARG_grayscale].u_bool, args[ARG_two_byte_sequence_length].u_bool ); return self; diff --git a/shared-bindings/displayio/EPaperDisplay.h b/shared-bindings/displayio/EPaperDisplay.h index c23fb27455..ba6dffcb4b 100644 --- a/shared-bindings/displayio/EPaperDisplay.h +++ b/shared-bindings/displayio/EPaperDisplay.h @@ -42,7 +42,7 @@ void common_hal_displayio_epaperdisplay_construct(displayio_epaperdisplay_obj_t uint16_t set_column_window_command, uint16_t set_row_window_command, uint16_t set_current_column_command, uint16_t set_current_row_command, uint16_t write_black_ram_command, bool black_bits_inverted, uint16_t write_color_ram_command, bool color_bits_inverted, uint32_t highlight_color, uint16_t refresh_display_command, mp_float_t refresh_time, - const mcu_pin_obj_t *busy_pin, bool busy_state, mp_float_t seconds_per_frame, bool always_toggle_chip_select, bool grayscale); + const mcu_pin_obj_t *busy_pin, bool busy_state, mp_float_t seconds_per_frame, bool always_toggle_chip_select, bool grayscale, bool two_byte_sequence_length); bool common_hal_displayio_epaperdisplay_refresh(displayio_epaperdisplay_obj_t *self); diff --git a/shared-bindings/displayio/OnDiskBitmap.c b/shared-bindings/displayio/OnDiskBitmap.c index b68fbef992..0564b48fe8 100644 --- a/shared-bindings/displayio/OnDiskBitmap.c +++ b/shared-bindings/displayio/OnDiskBitmap.c @@ -138,8 +138,8 @@ const mp_obj_property_t displayio_ondiskbitmap_height_obj = { //| pixel_shader: Union[ColorConverter, Palette] //| """The image's pixel_shader. The type depends on the underlying -//| bitmap's structure. The pixel shadder can be modified (e.g., to set the -//| transparent pixel or, for paletted images, to update the palette""" +//| bitmap's structure. The pixel shader can be modified (e.g., to set the +//| transparent pixel or, for palette shaded images, to update the palette.)""" //| STATIC mp_obj_t displayio_ondiskbitmap_obj_get_pixel_shader(mp_obj_t self_in) { displayio_ondiskbitmap_t *self = MP_OBJ_TO_PTR(self_in); diff --git a/shared-bindings/displayio/TileGrid.c b/shared-bindings/displayio/TileGrid.c index f031842e3b..4cecd0f0f1 100644 --- a/shared-bindings/displayio/TileGrid.c +++ b/shared-bindings/displayio/TileGrid.c @@ -215,6 +215,66 @@ const mp_obj_property_t displayio_tilegrid_y_obj = { MP_ROM_NONE}, }; +//| width: int +//| """Width of the tilegrid in tiles.""" +//| +STATIC mp_obj_t displayio_tilegrid_obj_get_width(mp_obj_t self_in) { + displayio_tilegrid_t *self = native_tilegrid(self_in); + return MP_OBJ_NEW_SMALL_INT(common_hal_displayio_tilegrid_get_width(self)); +} +MP_DEFINE_CONST_FUN_OBJ_1(displayio_tilegrid_get_width_obj, displayio_tilegrid_obj_get_width); + +const mp_obj_property_t displayio_tilegrid_width_obj = { + .base.type = &mp_type_property, + .proxy = {(mp_obj_t)&displayio_tilegrid_get_width_obj, + MP_ROM_NONE}, +}; + +//| height: int +//| """Height of the tilegrid in tiles.""" +//| +STATIC mp_obj_t displayio_tilegrid_obj_get_height(mp_obj_t self_in) { + displayio_tilegrid_t *self = native_tilegrid(self_in); + return MP_OBJ_NEW_SMALL_INT(common_hal_displayio_tilegrid_get_height(self)); +} +MP_DEFINE_CONST_FUN_OBJ_1(displayio_tilegrid_get_height_obj, displayio_tilegrid_obj_get_height); + +const mp_obj_property_t displayio_tilegrid_height_obj = { + .base.type = &mp_type_property, + .proxy = {(mp_obj_t)&displayio_tilegrid_get_height_obj, + MP_ROM_NONE}, +}; + +//| tile_width: int +//| """Width of a single tile in pixels.""" +//| +STATIC mp_obj_t displayio_tilegrid_obj_get_tile_width(mp_obj_t self_in) { + displayio_tilegrid_t *self = native_tilegrid(self_in); + return MP_OBJ_NEW_SMALL_INT(common_hal_displayio_tilegrid_get_tile_width(self)); +} +MP_DEFINE_CONST_FUN_OBJ_1(displayio_tilegrid_get_tile_width_obj, displayio_tilegrid_obj_get_tile_width); + +const mp_obj_property_t displayio_tilegrid_tile_width_obj = { + .base.type = &mp_type_property, + .proxy = {(mp_obj_t)&displayio_tilegrid_get_tile_width_obj, + MP_ROM_NONE}, +}; + +//| tile_height: int +//| """Height of a single tile in pixels.""" +//| +STATIC mp_obj_t displayio_tilegrid_obj_get_tile_height(mp_obj_t self_in) { + displayio_tilegrid_t *self = native_tilegrid(self_in); + return MP_OBJ_NEW_SMALL_INT(common_hal_displayio_tilegrid_get_tile_height(self)); +} +MP_DEFINE_CONST_FUN_OBJ_1(displayio_tilegrid_get_tile_height_obj, displayio_tilegrid_obj_get_tile_height); + +const mp_obj_property_t displayio_tilegrid_tile_height_obj = { + .base.type = &mp_type_property, + .proxy = {(mp_obj_t)&displayio_tilegrid_get_tile_height_obj, + MP_ROM_NONE}, +}; + //| flip_x: bool //| """If true, the left edge rendered will be the right edge of the right-most tile.""" //| @@ -385,6 +445,10 @@ STATIC const mp_rom_map_elem_t displayio_tilegrid_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_hidden), MP_ROM_PTR(&displayio_tilegrid_hidden_obj) }, { MP_ROM_QSTR(MP_QSTR_x), MP_ROM_PTR(&displayio_tilegrid_x_obj) }, { MP_ROM_QSTR(MP_QSTR_y), MP_ROM_PTR(&displayio_tilegrid_y_obj) }, + { MP_ROM_QSTR(MP_QSTR_width), MP_ROM_PTR(&displayio_tilegrid_width_obj) }, + { MP_ROM_QSTR(MP_QSTR_height), MP_ROM_PTR(&displayio_tilegrid_height_obj) }, + { MP_ROM_QSTR(MP_QSTR_tile_width), MP_ROM_PTR(&displayio_tilegrid_tile_width_obj) }, + { MP_ROM_QSTR(MP_QSTR_tile_height), MP_ROM_PTR(&displayio_tilegrid_tile_height_obj) }, { MP_ROM_QSTR(MP_QSTR_flip_x), MP_ROM_PTR(&displayio_tilegrid_flip_x_obj) }, { MP_ROM_QSTR(MP_QSTR_flip_y), MP_ROM_PTR(&displayio_tilegrid_flip_y_obj) }, { MP_ROM_QSTR(MP_QSTR_transpose_xy), MP_ROM_PTR(&displayio_tilegrid_transpose_xy_obj) }, diff --git a/shared-bindings/displayio/TileGrid.h b/shared-bindings/displayio/TileGrid.h index 7c8d8a605e..2cf0be501c 100644 --- a/shared-bindings/displayio/TileGrid.h +++ b/shared-bindings/displayio/TileGrid.h @@ -56,6 +56,9 @@ void common_hal_displayio_tilegrid_set_transpose_xy(displayio_tilegrid_t *self, uint16_t common_hal_displayio_tilegrid_get_width(displayio_tilegrid_t *self); uint16_t common_hal_displayio_tilegrid_get_height(displayio_tilegrid_t *self); +uint16_t common_hal_displayio_tilegrid_get_tile_width(displayio_tilegrid_t *self); +uint16_t common_hal_displayio_tilegrid_get_tile_height(displayio_tilegrid_t *self); + uint8_t common_hal_displayio_tilegrid_get_tile(displayio_tilegrid_t *self, uint16_t x, uint16_t y); void common_hal_displayio_tilegrid_set_tile(displayio_tilegrid_t *self, uint16_t x, uint16_t y, uint8_t tile_index); diff --git a/shared-bindings/fontio/BuiltinFont.c b/shared-bindings/fontio/BuiltinFont.c index 171a50dab3..fcbde4e80d 100644 --- a/shared-bindings/fontio/BuiltinFont.c +++ b/shared-bindings/fontio/BuiltinFont.c @@ -36,6 +36,25 @@ #include "shared-bindings/util.h" #include "supervisor/shared/translate.h" +//| from typing_extensions import Protocol # for compat with python < 3.8 +//| +//| class FontProtocol(Protocol): +//| """A protocol shared by `BuiltinFont` and classes in ``adafruit_bitmap_font``""" +//| def get_bounding_box(self) -> Union[Tuple[int, int], Tuple[int, int, int, int]]: +//| """Retrieve the maximum bounding box of any glyph in the font. +//| +//| The four element version is ``(width, height, x_offset, y_offset)``. +//| The two element version is ``(width, height)``, in which +//| ``x_offset`` and ``y_offset`` are assumed to be zero.""" +//| pass +//| +//| def get_glyph(self, codepoint: int) -> Optional[Glyph]: +//| """Retrieve the Glyph for a given code point +//| +//| If the code point is not present in the font, `None` is returned.""" +//| pass +//| + //| class BuiltinFont: //| """A font built into CircuitPython""" //| diff --git a/shared-bindings/framebufferio/FramebufferDisplay.c b/shared-bindings/framebufferio/FramebufferDisplay.c index 683e512b3e..acc50d7561 100644 --- a/shared-bindings/framebufferio/FramebufferDisplay.c +++ b/shared-bindings/framebufferio/FramebufferDisplay.c @@ -47,10 +47,10 @@ //| objects in CircuitPython, Display objects live until `displayio.release_displays()` //| is called. This is done so that CircuitPython can use the display itself.""" //| -//| def __init__(self, framebuffer: _typing.FrameBuffer, *, rotation: int = 0, auto_refresh: bool = True) -> None: +//| def __init__(self, framebuffer: circuitpython_typing.FrameBuffer, *, rotation: int = 0, auto_refresh: bool = True) -> None: //| """Create a Display object with the given framebuffer (a buffer, array, ulab.array, etc) //| -//| :param ~_typing.FrameBuffer framebuffer: The framebuffer that the display is connected to +//| :param ~circuitpython_typing.FrameBuffer framebuffer: The framebuffer that the display is connected to //| :param bool auto_refresh: Automatically refresh the screen //| :param int rotation: The rotation of the display in degrees clockwise. Must be in 90 degree increments (0, 90, 180, 270)""" //| ... @@ -298,7 +298,7 @@ const mp_obj_property_t framebufferio_framebufferdisplay_rotation_obj = { MP_ROM_NONE}, }; -//| framebuffer: _typing.FrameBuffer +//| framebuffer: circuitpython_typing.FrameBuffer //| """The framebuffer being used by the display""" //| //| @@ -320,7 +320,7 @@ const mp_obj_property_t framebufferio_framebufferframebuffer_obj = { //| """Extract the pixels from a single row //| //| :param int y: The top edge of the area -//| :param ~_typing.WriteableBuffer buffer: The buffer in which to place the pixel data""" +//| :param ~circuitpython_typing.WriteableBuffer buffer: The buffer in which to place the pixel data""" //| ... //| STATIC mp_obj_t framebufferio_framebufferdisplay_obj_fill_row(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { diff --git a/shared-bindings/i2cperipheral/I2CPeripheral.c b/shared-bindings/i2cperipheral/I2CPeripheral.c index f697646146..b63e8a891b 100644 --- a/shared-bindings/i2cperipheral/I2CPeripheral.c +++ b/shared-bindings/i2cperipheral/I2CPeripheral.c @@ -353,7 +353,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(i2cperipheral_i2c_peripheral_request_read_obj, 1, i2c //| def write(self, buffer: ReadableBuffer) -> int: //| """Write the data contained in buffer. //| -//| :param ~_typing.ReadableBuffer buffer: Write out the data in this buffer +//| :param ~circuitpython_typing.ReadableBuffer buffer: Write out the data in this buffer //| :return: Number of bytes written""" //| ... //| diff --git a/shared-bindings/is31fl3741/FrameBuffer.c b/shared-bindings/is31fl3741/FrameBuffer.c new file mode 100644 index 0000000000..597024500d --- /dev/null +++ b/shared-bindings/is31fl3741/FrameBuffer.c @@ -0,0 +1,312 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Mark Komus + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "py/obj.h" +#include "py/objproperty.h" +#include "py/runtime.h" +#include "py/objarray.h" + +#include "shared-bindings/is31fl3741/IS31FL3741.h" +#include "shared-bindings/is31fl3741/FrameBuffer.h" +#include "shared-bindings/util.h" +#include "shared-module/displayio/__init__.h" +#include "shared-module/framebufferio/__init__.h" +#include "shared-module/framebufferio/FramebufferDisplay.h" +#include "shared-bindings/busio/I2C.h" + +//| class IS31FL3741_FrameBuffer: +//| """Creates an in-memory framebuffer for a IS31FL3741 device.""" +//| +//| def __init__(self, is31: is31fl3741.IS31FL3741, width: int, height: int, mapping: Tuple[int, ...], *, +//| framebuffer: Optional[WriteableBuffer] = None, scale: bool = False, gamma: bool = False) -> None: +//| """Create a IS31FL3741_FrameBuffer object with the given attributes. +//| +//| The framebuffer is in "RGB888" format using 4 bytes per pixel. +//| Bits 24-31 are ignored. The format is in RGB order. +//| +//| If a framebuffer is not passed in, one is allocated and initialized +//| to all black. In any case, the framebuffer can be retrieved +//| by passing the Is31fl3741 object to memoryview(). +//| +//| A Is31fl3741 is often used in conjunction with a +//| `framebufferio.FramebufferDisplay`. +//| +//| :param is31fl3741.IS31FL3741 is31: base IS31FL3741 instance to drive the framebuffer +//| :param int width: width of the display +//| :param int height: height of the display +//| :param Tuple[int, ...] mapping: mapping of matrix locations to LEDs +//| :param Optional[WriteableBuffer] framebuffer: Optional buffer to hold the display +//| :param bool scale: if True display is scaled down by 3 when displayed +//| :param bool gamma: if True apply gamma correction to all LEDs""" +//| ... +//| +STATIC mp_obj_t is31fl3741_FrameBuffer_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { + enum { ARG_is31, ARG_width, ARG_height, ARG_mapping, ARG_framebuffer, ARG_scale, ARG_gamma }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_is31, MP_ARG_OBJ | MP_ARG_REQUIRED }, + { MP_QSTR_width, MP_ARG_INT | MP_ARG_REQUIRED }, + { MP_QSTR_height, MP_ARG_INT | MP_ARG_REQUIRED }, + { MP_QSTR_mapping, MP_ARG_OBJ | MP_ARG_REQUIRED }, + { MP_QSTR_framebuffer, MP_ARG_OBJ | MP_ARG_KW_ONLY, { .u_obj = mp_const_none } }, + { MP_QSTR_scale, MP_ARG_BOOL | MP_ARG_KW_ONLY, { .u_bool = false } }, + { MP_QSTR_gamma, MP_ARG_BOOL | MP_ARG_KW_ONLY, { .u_bool = false } }, + }; + mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; + mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + + is31fl3741_FrameBuffer_obj_t *self = &allocate_display_bus_or_raise()->is31fl3741; + self->base.type = &is31fl3741_FrameBuffer_type; + + if (args[ARG_width].u_int <= 0) { + mp_raise_ValueError(translate("width must be greater than zero")); + } + + self->scale = args[ARG_scale].u_bool; + if (self->scale) { + if (((args[ARG_height].u_int % 3) != 0) || ((args[ARG_width].u_int % 3) != 0)) { + mp_raise_ValueError(translate("Scale dimensions must divide by 3")); + } + + self->scale_width = args[ARG_width].u_int / 3; + self->scale_height = args[ARG_height].u_int / 3; + } else { + self->scale_width = args[ARG_width].u_int; + self->scale_height = args[ARG_height].u_int; + } + + self->auto_gamma = args[ARG_gamma].u_bool; + + mp_obj_t framebuffer = args[ARG_framebuffer].u_obj; + if (framebuffer == mp_const_none) { + int width = args[ARG_width].u_int; + int height = args[ARG_height].u_int; + int bufsize = 4 * width * height; + framebuffer = mp_obj_new_bytearray_of_zeros(bufsize); + } + + common_hal_is31fl3741_FrameBuffer_construct(self, + args[ARG_width].u_int, + args[ARG_height].u_int, + framebuffer, + args[ARG_is31].u_obj, + args[ARG_mapping].u_obj + ); + + return MP_OBJ_FROM_PTR(self); +} + +//| def deinit(self) -> None: +//| """Free the resources associated with this +//| IS31FL3741 instance. After deinitialization, no further operations +//| may be performed.""" +//| ... +//| +STATIC mp_obj_t is31fl3741_FrameBuffer_deinit(mp_obj_t self_in) { + is31fl3741_FrameBuffer_obj_t *self = (is31fl3741_FrameBuffer_obj_t *)self_in; + common_hal_is31fl3741_FrameBuffer_deinit(self); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(is31fl3741_FrameBuffer_deinit_obj, is31fl3741_FrameBuffer_deinit); + +static void check_for_deinit(is31fl3741_FrameBuffer_obj_t *self) { + if (self->framebuffer == NULL) { + raise_deinited_error(); + } +} + +//| brightness: float +//| """In the current implementation, 0.0 turns the display off entirely +//| and any other value up to 1.0 turns the display on fully.""" +//| +STATIC mp_obj_t is31fl3741_FrameBuffer_get_brightness(mp_obj_t self_in) { + is31fl3741_FrameBuffer_obj_t *self = (is31fl3741_FrameBuffer_obj_t *)self_in; + check_for_deinit(self); + uint8_t current = common_hal_is31fl3741_get_current(self->is31fl3741); + + float brightness = (float)current / (float)0xFF; + return mp_obj_new_float(brightness); +} +MP_DEFINE_CONST_FUN_OBJ_1(is31fl3741_FrameBuffer_get_brightness_obj, is31fl3741_FrameBuffer_get_brightness); + +STATIC mp_obj_t is31fl3741_FrameBuffer_set_brightness(mp_obj_t self_in, mp_obj_t value_in) { + is31fl3741_FrameBuffer_obj_t *self = (is31fl3741_FrameBuffer_obj_t *)self_in; + check_for_deinit(self); + mp_float_t brightness = mp_obj_get_float(value_in); + if (brightness < 0.0f || brightness > 1.0f) { + mp_raise_ValueError(translate("Brightness must be 0-1.0")); + } + + uint8_t current = (uint8_t)(brightness * 0xFF); + common_hal_is31fl3741_set_current(self->is31fl3741, current); + + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_2(is31fl3741_FrameBuffer_set_brightness_obj, is31fl3741_FrameBuffer_set_brightness); + +const mp_obj_property_t is31fl3741_FrameBuffer_brightness_obj = { + .base.type = &mp_type_property, + .proxy = {(mp_obj_t)&is31fl3741_FrameBuffer_get_brightness_obj, + (mp_obj_t)&is31fl3741_FrameBuffer_set_brightness_obj, + MP_ROM_NONE}, +}; + +//| def refresh(self) -> None: +//| """Transmits the color data in the buffer to the pixels so that +//| they are shown.""" +//| ... +//| +STATIC mp_obj_t is31fl3741_FrameBuffer_refresh(mp_obj_t self_in) { + is31fl3741_FrameBuffer_obj_t *self = (is31fl3741_FrameBuffer_obj_t *)self_in; + check_for_deinit(self); + common_hal_is31fl3741_FrameBuffer_refresh(self, 0); + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_1(is31fl3741_FrameBuffer_refresh_obj, is31fl3741_FrameBuffer_refresh); + +//| width: int +//| """The width of the display, in pixels""" +//| +STATIC mp_obj_t is31fl3741_FrameBuffer_get_width(mp_obj_t self_in) { + is31fl3741_FrameBuffer_obj_t *self = (is31fl3741_FrameBuffer_obj_t *)self_in; + check_for_deinit(self); + return MP_OBJ_NEW_SMALL_INT(common_hal_is31fl3741_FrameBuffer_get_width(self)); +} +MP_DEFINE_CONST_FUN_OBJ_1(is31fl3741_FrameBuffer_get_width_obj, is31fl3741_FrameBuffer_get_width); +const mp_obj_property_t is31fl3741_FrameBuffer_width_obj = { + .base.type = &mp_type_property, + .proxy = {(mp_obj_t)&is31fl3741_FrameBuffer_get_width_obj, + MP_ROM_NONE, + MP_ROM_NONE}, +}; + +//| height: int +//| """The height of the display, in pixels""" +//| +STATIC mp_obj_t is31fl3741_FrameBuffer_get_height(mp_obj_t self_in) { + is31fl3741_FrameBuffer_obj_t *self = (is31fl3741_FrameBuffer_obj_t *)self_in; + check_for_deinit(self); + return MP_OBJ_NEW_SMALL_INT(common_hal_is31fl3741_FrameBuffer_get_height(self)); +} +MP_DEFINE_CONST_FUN_OBJ_1(is31fl3741_FrameBuffer_get_height_obj, is31fl3741_FrameBuffer_get_height); +const mp_obj_property_t is31fl3741_FrameBuffer_height_obj = { + .base.type = &mp_type_property, + .proxy = {(mp_obj_t)&is31fl3741_FrameBuffer_get_height_obj, + MP_ROM_NONE, + MP_ROM_NONE}, +}; + +STATIC const mp_rom_map_elem_t is31fl3741_FrameBuffer_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&is31fl3741_FrameBuffer_deinit_obj) }, + { MP_ROM_QSTR(MP_QSTR_brightness), MP_ROM_PTR(&is31fl3741_FrameBuffer_brightness_obj) }, + { MP_ROM_QSTR(MP_QSTR_refresh), MP_ROM_PTR(&is31fl3741_FrameBuffer_refresh_obj) }, + { MP_ROM_QSTR(MP_QSTR_width), MP_ROM_PTR(&is31fl3741_FrameBuffer_width_obj) }, + { MP_ROM_QSTR(MP_QSTR_height), MP_ROM_PTR(&is31fl3741_FrameBuffer_height_obj) }, +}; +STATIC MP_DEFINE_CONST_DICT(is31fl3741_FrameBuffer_locals_dict, is31fl3741_FrameBuffer_locals_dict_table); + +STATIC void is31fl3741_FrameBuffer_get_bufinfo(mp_obj_t self_in, mp_buffer_info_t *bufinfo) { + is31fl3741_FrameBuffer_obj_t *self = (is31fl3741_FrameBuffer_obj_t *)self_in; + check_for_deinit(self); + + *bufinfo = self->bufinfo; +} + +STATIC void is31fl3741_FrameBuffer_swapbuffers(mp_obj_t self_in, uint8_t *dirty_row_bitmap) { + common_hal_is31fl3741_FrameBuffer_refresh(self_in, dirty_row_bitmap); +} + +STATIC void is31fl3741_FrameBuffer_deinit_proto(mp_obj_t self_in) { + common_hal_is31fl3741_FrameBuffer_deinit(self_in); +} + +STATIC float is31fl3741_FrameBuffer_get_brightness_proto(mp_obj_t self_in) { + return common_hal_is31fl3741_FrameBuffer_get_paused(self_in) ? 0.0f : 1.0f; +} + +STATIC bool is31fl3741_FrameBuffer_set_brightness_proto(mp_obj_t self_in, mp_float_t value) { + common_hal_is31fl3741_FrameBuffer_set_paused(self_in, value <= 0); + return true; +} + +STATIC int is31fl3741_FrameBuffer_get_width_proto(mp_obj_t self_in) { + return common_hal_is31fl3741_FrameBuffer_get_width(self_in); +} + +STATIC int is31fl3741_FrameBuffer_get_height_proto(mp_obj_t self_in) { + return common_hal_is31fl3741_FrameBuffer_get_height(self_in); +} + +STATIC int is31fl3741_FrameBuffer_get_color_depth_proto(mp_obj_t self_in) { + // The way displayio works depth is used to calculate bytes + // We use an uint32_t for color already so setting to 24 causes + // more changes required + return 32; +} + +STATIC int is31fl3741_FrameBuffer_get_bytes_per_cell_proto(mp_obj_t self_in) { + return 1; +} + +STATIC int is31fl3741_FrameBuffer_get_native_frames_per_second_proto(mp_obj_t self_in) { + return 60; // This was just chosen may vary based on LEDs used? +} + +STATIC const framebuffer_p_t is31fl3741_FrameBuffer_proto = { + MP_PROTO_IMPLEMENT(MP_QSTR_protocol_framebuffer) + .get_bufinfo = is31fl3741_FrameBuffer_get_bufinfo, + .set_brightness = is31fl3741_FrameBuffer_set_brightness_proto, + .get_brightness = is31fl3741_FrameBuffer_get_brightness_proto, + .get_width = is31fl3741_FrameBuffer_get_width_proto, + .get_height = is31fl3741_FrameBuffer_get_height_proto, + .get_color_depth = is31fl3741_FrameBuffer_get_color_depth_proto, + .get_bytes_per_cell = is31fl3741_FrameBuffer_get_bytes_per_cell_proto, + .get_native_frames_per_second = is31fl3741_FrameBuffer_get_native_frames_per_second_proto, + .swapbuffers = is31fl3741_FrameBuffer_swapbuffers, + .deinit = is31fl3741_FrameBuffer_deinit_proto, +}; + +STATIC mp_int_t is31fl3741_FrameBuffer_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags) { + is31fl3741_FrameBuffer_obj_t *self = (is31fl3741_FrameBuffer_obj_t *)self_in; + // a readonly framebuffer would be unusual but not impossible + if ((flags & MP_BUFFER_WRITE) && !(self->bufinfo.typecode & MP_OBJ_ARRAY_TYPECODE_FLAG_RW)) { + return 1; + } + *bufinfo = self->bufinfo; + bufinfo->typecode = 'H'; + return 0; +} + +const mp_obj_type_t is31fl3741_FrameBuffer_type = { + { &mp_type_type }, + .flags = MP_TYPE_FLAG_EXTENDED, + .name = MP_QSTR_is31fl3741, + .locals_dict = (mp_obj_dict_t *)&is31fl3741_FrameBuffer_locals_dict, + .make_new = is31fl3741_FrameBuffer_make_new, + MP_TYPE_EXTENDED_FIELDS( + .buffer_p = { .get_buffer = is31fl3741_FrameBuffer_get_buffer, }, + .protocol = &is31fl3741_FrameBuffer_proto, + ), +}; diff --git a/shared-bindings/is31fl3741/FrameBuffer.h b/shared-bindings/is31fl3741/FrameBuffer.h new file mode 100644 index 0000000000..704913b83c --- /dev/null +++ b/shared-bindings/is31fl3741/FrameBuffer.h @@ -0,0 +1,50 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Mark Komus + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#pragma once + +#include "shared-module/is31fl3741/FrameBuffer.h" +#include "shared-module/is31fl3741/IS31FL3741.h" + +extern const mp_obj_type_t is31fl3741_FrameBuffer_type; + +void common_hal_is31fl3741_FrameBuffer_construct(is31fl3741_FrameBuffer_obj_t *self, int width, int height, mp_obj_t framebuffer, is31fl3741_IS31FL3741_obj_t *is31, mp_obj_t mapping); + +void common_hal_is31fl3741_FrameBuffer_deinit(is31fl3741_FrameBuffer_obj_t *); + +int common_hal_is31fl3741_FrameBuffer_get_width(is31fl3741_FrameBuffer_obj_t *self); +int common_hal_is31fl3741_FrameBuffer_get_height(is31fl3741_FrameBuffer_obj_t *self); + +void common_hal_is31fl3741_FrameBuffer_set_global_current(is31fl3741_FrameBuffer_obj_t *self, uint8_t current); +uint8_t common_hal_is31fl3741_FrameBuffer_get_global_current(is31fl3741_FrameBuffer_obj_t *self); + +void common_hal_is31fl3741_FrameBuffer_set_paused(is31fl3741_FrameBuffer_obj_t *self, bool paused); +bool common_hal_is31fl3741_FrameBuffer_get_paused(is31fl3741_FrameBuffer_obj_t *self); +void common_hal_is31fl3741_FrameBuffer_refresh(is31fl3741_FrameBuffer_obj_t *self, uint8_t *dirtyrows); + +void common_hal_is31fl3741_FrameBuffer_reconstruct(is31fl3741_FrameBuffer_obj_t *self, mp_obj_t framebuffer); + +void is31fl3741_FrameBuffer_collect_ptrs(is31fl3741_FrameBuffer_obj_t *self); diff --git a/shared-bindings/is31fl3741/IS31FL3741.c b/shared-bindings/is31fl3741/IS31FL3741.c index 758dd114a0..46a7f8ac86 100644 --- a/shared-bindings/is31fl3741/IS31FL3741.c +++ b/shared-bindings/is31fl3741/IS31FL3741.c @@ -32,82 +32,38 @@ #include "shared-bindings/is31fl3741/IS31FL3741.h" #include "shared-bindings/util.h" #include "shared-module/displayio/__init__.h" -#include "shared-module/framebufferio/__init__.h" -#include "shared-module/framebufferio/FramebufferDisplay.h" #include "shared-bindings/busio/I2C.h" //| class IS31FL3741: -//| """Displays an in-memory framebuffer to a IS31FL3741 drive display.""" +//| """Driver for an IS31FL3741 device.""" //| - -//| def __init__(self, *, width: int) -> None: +//| def __init__(self, i2c: busio.I2C, *, addr: int = 0x30) -> None: //| """Create a IS31FL3741 object with the given attributes. //| -//| The framebuffer is in "RGB888" format using 4 bytes per pixel. -//| Bits 24-31 are ignored. The format is in RGB order. +//| Designed to work low level or passed to and object such as +//| :class:`~is31fl3741.IS31FL3741_FrameBuffer`. //| -//| If a framebuffer is not passed in, one is allocated and initialized -//| to all black. In any case, the framebuffer can be retrieved -//| by passing the Is31fl3741 object to memoryview(). +//| :param ~busio.I2C i2c: I2C bus the IS31FL3741 is on +//| :param int addr: device address""" +//| ... //| -//| A Is31fl3741 is often used in conjunction with a -//| `framebufferio.FramebufferDisplay`.""" -//| - STATIC mp_obj_t is31fl3741_IS31FL3741_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { - enum { ARG_width, ARG_height, ARG_i2c, ARG_addr, ARG_framebuffer, ARG_mapping, ARG_scale, ARG_gamma }; + enum { ARG_i2c, ARG_addr }; static const mp_arg_t allowed_args[] = { - { MP_QSTR_width, MP_ARG_INT | MP_ARG_REQUIRED | MP_ARG_KW_ONLY }, - { MP_QSTR_height, MP_ARG_INT | MP_ARG_REQUIRED | MP_ARG_KW_ONLY }, - { MP_QSTR_i2c, MP_ARG_OBJ | MP_ARG_REQUIRED | MP_ARG_KW_ONLY }, + { MP_QSTR_i2c, MP_ARG_OBJ | MP_ARG_REQUIRED }, { MP_QSTR_addr, MP_ARG_INT | MP_ARG_KW_ONLY, { .u_int = 0x30 } }, - { MP_QSTR_framebuffer, MP_ARG_OBJ | MP_ARG_KW_ONLY, { .u_obj = mp_const_none } }, - { MP_QSTR_mapping, MP_ARG_OBJ | MP_ARG_KW_ONLY | MP_ARG_REQUIRED }, - { MP_QSTR_scale, MP_ARG_BOOL | MP_ARG_KW_ONLY, { .u_bool = false } }, - { MP_QSTR_gamma, MP_ARG_BOOL | MP_ARG_KW_ONLY, { .u_bool = false } }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); mp_obj_t i2c = mp_arg_validate_type(args[ARG_i2c].u_obj, &busio_i2c_type, MP_QSTR_i2c_bus); - is31fl3741_IS31FL3741_obj_t *self = &allocate_display_bus_or_raise()->is31fl3741; + is31fl3741_IS31FL3741_obj_t *self = m_new_obj(is31fl3741_IS31FL3741_obj_t); self->base.type = &is31fl3741_IS31FL3741_type; - if (args[ARG_width].u_int <= 0) { - mp_raise_ValueError(translate("width must be greater than zero")); - } - - self->scale = args[ARG_scale].u_bool; - if (self->scale) { - if (((args[ARG_height].u_int % 3) != 0) || ((args[ARG_width].u_int % 3) != 0)) { - mp_raise_ValueError(translate("Scale dimensions must divide by 3")); - } - - self->scale_width = args[ARG_width].u_int / 3; - self->scale_height = args[ARG_height].u_int / 3; - } else { - self->scale_width = args[ARG_width].u_int; - self->scale_height = args[ARG_height].u_int; - } - - self->auto_gamma = args[ARG_gamma].u_bool; - - mp_obj_t framebuffer = args[ARG_framebuffer].u_obj; - if (framebuffer == mp_const_none) { - int width = args[ARG_width].u_int; - int height = args[ARG_height].u_int; - int bufsize = 4 * width * height; - framebuffer = mp_obj_new_bytearray_of_zeros(bufsize); - } - common_hal_is31fl3741_IS31FL3741_construct(self, - args[ARG_width].u_int, - args[ARG_height].u_int, - framebuffer, MP_OBJ_TO_PTR(i2c), - args[ARG_addr].u_int, - args[ARG_mapping].u_obj + args[ARG_addr].u_int ); return MP_OBJ_FROM_PTR(self); @@ -124,185 +80,101 @@ STATIC mp_obj_t is31fl3741_IS31FL3741_deinit(mp_obj_t self_in) { common_hal_is31fl3741_IS31FL3741_deinit(self); return mp_const_none; } - STATIC MP_DEFINE_CONST_FUN_OBJ_1(is31fl3741_IS31FL3741_deinit_obj, is31fl3741_IS31FL3741_deinit); -static void check_for_deinit(is31fl3741_IS31FL3741_obj_t *self) { - if (self->framebuffer == NULL) { - raise_deinited_error(); - } -} - -//| brightness: float -//| """In the current implementation, 0.0 turns the display off entirely -//| and any other value up to 1.0 turns the display on fully.""" +//| def reset(self) -> None: +//| """Resets the IS31FL3741 chip.""" +//| ... //| -STATIC mp_obj_t is31fl3741_IS31FL3741_get_brightness(mp_obj_t self_in) { - is31fl3741_IS31FL3741_obj_t *self = (is31fl3741_IS31FL3741_obj_t *)self_in; - check_for_deinit(self); - uint8_t current = common_hal_is31fl3741_IS31FL3741_get_global_current(self); - - float brightness = (float)current / (float)0xFF; - return mp_obj_new_float(brightness); -} -MP_DEFINE_CONST_FUN_OBJ_1(is31fl3741_IS31FL3741_get_brightness_obj, is31fl3741_IS31FL3741_get_brightness); - -STATIC mp_obj_t is31fl3741_IS31FL3741_set_brightness(mp_obj_t self_in, mp_obj_t value_in) { - is31fl3741_IS31FL3741_obj_t *self = (is31fl3741_IS31FL3741_obj_t *)self_in; - check_for_deinit(self); - mp_float_t brightness = mp_obj_get_float(value_in); - if (brightness < 0.0f || brightness > 1.0f) { - mp_raise_ValueError(translate("Brightness must be 0-1.0")); - } - - uint8_t current = (uint8_t)(brightness * 0xFF); - common_hal_is31fl3741_IS31FL3741_set_global_current(self, current); - +STATIC mp_obj_t is31fl3741_IS31FL3741_reset(mp_obj_t self_in) { + is31fl3741_IS31FL3741_obj_t *self = MP_OBJ_TO_PTR(self_in); + common_hal_is31fl3741_send_reset(self); return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_2(is31fl3741_IS31FL3741_set_brightness_obj, is31fl3741_IS31FL3741_set_brightness); +MP_DEFINE_CONST_FUN_OBJ_1(is31fl3741_IS31FL3741_reset_obj, is31fl3741_IS31FL3741_reset); -const mp_obj_property_t is31fl3741_IS31FL3741_brightness_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&is31fl3741_IS31FL3741_get_brightness_obj, - (mp_obj_t)&is31fl3741_IS31FL3741_set_brightness_obj, - MP_ROM_NONE}, -}; - -//| def refresh(self) -> None: -//| """Transmits the color data in the buffer to the pixels so that -//| they are shown.""" -//| ... +//| def enable(self) -> None: +//| """Enables the IS31FL3741 chip.""" +//| ... //| -STATIC mp_obj_t is31fl3741_IS31FL3741_refresh(mp_obj_t self_in) { - is31fl3741_IS31FL3741_obj_t *self = (is31fl3741_IS31FL3741_obj_t *)self_in; - check_for_deinit(self); - common_hal_is31fl3741_IS31FL3741_refresh(self, 0); +STATIC mp_obj_t is31fl3741_IS31FL3741_enable(mp_obj_t self_in) { + is31fl3741_IS31FL3741_obj_t *self = MP_OBJ_TO_PTR(self_in); + common_hal_is31fl3741_send_enable(self); return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_1(is31fl3741_IS31FL3741_refresh_obj, is31fl3741_IS31FL3741_refresh); +MP_DEFINE_CONST_FUN_OBJ_1(is31fl3741_IS31FL3741_enable_obj, is31fl3741_IS31FL3741_enable); -//| width: int -//| """The width of the display, in pixels""" +//| def set_global_current(self, current: int) -> None: +//| """Sets the global current of the IS31FL3741 chip. //| -STATIC mp_obj_t is31fl3741_IS31FL3741_get_width(mp_obj_t self_in) { - is31fl3741_IS31FL3741_obj_t *self = (is31fl3741_IS31FL3741_obj_t *)self_in; - check_for_deinit(self); - return MP_OBJ_NEW_SMALL_INT(common_hal_is31fl3741_IS31FL3741_get_width(self)); +//| :param int current: global current value 0x00 to 0xFF""" +//| ... +//| +STATIC mp_obj_t is31fl3741_IS31FL3741_set_global_current(mp_obj_t self_in, mp_obj_t value) { + is31fl3741_IS31FL3741_obj_t *self = MP_OBJ_TO_PTR(self_in); + mp_int_t current = mp_obj_get_int(value); + common_hal_is31fl3741_set_current(self, current); + return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_1(is31fl3741_IS31FL3741_get_width_obj, is31fl3741_IS31FL3741_get_width); -const mp_obj_property_t is31fl3741_IS31FL3741_width_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&is31fl3741_IS31FL3741_get_width_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_DEFINE_CONST_FUN_OBJ_2(is31fl3741_IS31FL3741_set_global_current_obj, is31fl3741_IS31FL3741_set_global_current); -//| height: int -//| """The height of the display, in pixels""" +//| def set_led(self, led: int, value: int, page: int) -> None: +//| """Resets the IS31FL3741 chip. //| -STATIC mp_obj_t is31fl3741_IS31FL3741_get_height(mp_obj_t self_in) { - is31fl3741_IS31FL3741_obj_t *self = (is31fl3741_IS31FL3741_obj_t *)self_in; - check_for_deinit(self); - return MP_OBJ_NEW_SMALL_INT(common_hal_is31fl3741_IS31FL3741_get_height(self)); +//| :param int led: which LED to set +//| :param int value: value to set the LED to 0x00 to 0xFF +//| :param int page: page to write to 0 or 2. If the LED is a >= 180 +//| the routine will automatically write to page 1 or 3 (instead +//| of 0 or 2)""" +//| ... +//| +STATIC mp_obj_t is31fl3741_IS31FL3741_set_led(size_t n_args, const mp_obj_t *args) { + is31fl3741_IS31FL3741_obj_t *self = MP_OBJ_TO_PTR(args[0]); + mp_int_t led = mp_obj_get_int(args[1]); + mp_int_t value = mp_obj_get_int(args[2]); + mp_int_t page = mp_obj_get_int(args[3]); + common_hal_is31fl3741_set_led(self, led, value, page); + return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_1(is31fl3741_IS31FL3741_get_height_obj, is31fl3741_IS31FL3741_get_height); -const mp_obj_property_t is31fl3741_IS31FL3741_height_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&is31fl3741_IS31FL3741_get_height_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(is31fl3741_IS31FL3741_set_led_obj, 4, 4, is31fl3741_IS31FL3741_set_led); + +//| def write(mapping: Tuple[int, ...], buf: ReadableBuffer) -> None: +//| """Write buf out on the I2C bus to the IS31FL3741. +//| +//| :param ~Tuple[int, ...] mapping: map the pixels in the buffer to the order addressed by the driver chip +//| :param ~_typing.ReadableBuffer buf: The bytes to clock out. No assumption is made about color order""" +//| ... +STATIC mp_obj_t is31fl3741_IS31FL3741_write(mp_obj_t self_in, mp_obj_t mapping, mp_obj_t buffer) { + is31fl3741_IS31FL3741_obj_t *self = MP_OBJ_TO_PTR(self_in); + if (!mp_obj_is_tuple_compatible(mapping)) { + mp_raise_ValueError(translate("Mapping must be a tuple")); + } + + mp_obj_t *map_items; + size_t map_len; + mp_obj_tuple_get(mapping, &map_len, &map_items); + + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(buffer, &bufinfo, MP_BUFFER_READ); + + common_hal_is31fl3741_write(self, map_items, (uint8_t *)bufinfo.buf, bufinfo.len); + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_3(is31fl3741_IS31FL3741_write_obj, is31fl3741_IS31FL3741_write); STATIC const mp_rom_map_elem_t is31fl3741_IS31FL3741_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&is31fl3741_IS31FL3741_deinit_obj) }, - { MP_ROM_QSTR(MP_QSTR_brightness), MP_ROM_PTR(&is31fl3741_IS31FL3741_brightness_obj) }, - { MP_ROM_QSTR(MP_QSTR_refresh), MP_ROM_PTR(&is31fl3741_IS31FL3741_refresh_obj) }, - { MP_ROM_QSTR(MP_QSTR_width), MP_ROM_PTR(&is31fl3741_IS31FL3741_width_obj) }, - { MP_ROM_QSTR(MP_QSTR_height), MP_ROM_PTR(&is31fl3741_IS31FL3741_height_obj) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_write), (mp_obj_t)&is31fl3741_IS31FL3741_write_obj }, + { MP_OBJ_NEW_QSTR(MP_QSTR_reset), (mp_obj_t)&is31fl3741_IS31FL3741_reset_obj }, + { MP_OBJ_NEW_QSTR(MP_QSTR_enable), (mp_obj_t)&is31fl3741_IS31FL3741_enable_obj }, + { MP_OBJ_NEW_QSTR(MP_QSTR_set_global_current), (mp_obj_t)&is31fl3741_IS31FL3741_set_global_current_obj }, + { MP_OBJ_NEW_QSTR(MP_QSTR_set_led), (mp_obj_t)&is31fl3741_IS31FL3741_set_led_obj }, }; STATIC MP_DEFINE_CONST_DICT(is31fl3741_IS31FL3741_locals_dict, is31fl3741_IS31FL3741_locals_dict_table); -STATIC void is31fl3741_IS31FL3741_get_bufinfo(mp_obj_t self_in, mp_buffer_info_t *bufinfo) { - is31fl3741_IS31FL3741_obj_t *self = (is31fl3741_IS31FL3741_obj_t *)self_in; - check_for_deinit(self); - - *bufinfo = self->bufinfo; -} - -STATIC void is31fl3741_IS31FL3741_swapbuffers(mp_obj_t self_in, uint8_t *dirty_row_bitmap) { - common_hal_is31fl3741_IS31FL3741_refresh(self_in, dirty_row_bitmap); -} - -STATIC void is31fl3741_IS31FL3741_deinit_proto(mp_obj_t self_in) { - common_hal_is31fl3741_IS31FL3741_deinit(self_in); -} - -STATIC float is31fl3741_IS31FL3741_get_brightness_proto(mp_obj_t self_in) { - return common_hal_is31fl3741_IS31FL3741_get_paused(self_in) ? 0.0f : 1.0f; -} - -STATIC bool is31fl3741_IS31FL3741_set_brightness_proto(mp_obj_t self_in, mp_float_t value) { - common_hal_is31fl3741_IS31FL3741_set_paused(self_in, value <= 0); - return true; -} - -STATIC int is31fl3741_IS31FL3741_get_width_proto(mp_obj_t self_in) { - return common_hal_is31fl3741_IS31FL3741_get_width(self_in); -} - -STATIC int is31fl3741_IS31FL3741_get_height_proto(mp_obj_t self_in) { - return common_hal_is31fl3741_IS31FL3741_get_height(self_in); -} - -STATIC int is31fl3741_IS31FL3741_get_color_depth_proto(mp_obj_t self_in) { - // The way displayio works depth is used to calculate bytes - // We use an uint32_t for color already so setting to 24 causes - // more changes required - return 32; -} - -STATIC int is31fl3741_IS31FL3741_get_bytes_per_cell_proto(mp_obj_t self_in) { - return 1; -} - -STATIC int is31fl3741_IS31FL3741_get_native_frames_per_second_proto(mp_obj_t self_in) { - return 60; // This was just chosen may vary based on LEDs used? -} - -STATIC const framebuffer_p_t is31fl3741_IS31FL3741_proto = { - MP_PROTO_IMPLEMENT(MP_QSTR_protocol_framebuffer) - .get_bufinfo = is31fl3741_IS31FL3741_get_bufinfo, - .set_brightness = is31fl3741_IS31FL3741_set_brightness_proto, - .get_brightness = is31fl3741_IS31FL3741_get_brightness_proto, - .get_width = is31fl3741_IS31FL3741_get_width_proto, - .get_height = is31fl3741_IS31FL3741_get_height_proto, - .get_color_depth = is31fl3741_IS31FL3741_get_color_depth_proto, - .get_bytes_per_cell = is31fl3741_IS31FL3741_get_bytes_per_cell_proto, - .get_native_frames_per_second = is31fl3741_IS31FL3741_get_native_frames_per_second_proto, - .swapbuffers = is31fl3741_IS31FL3741_swapbuffers, - .deinit = is31fl3741_IS31FL3741_deinit_proto, -}; - -STATIC mp_int_t is31fl3741_IS31FL3741_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags) { - is31fl3741_IS31FL3741_obj_t *self = (is31fl3741_IS31FL3741_obj_t *)self_in; - // a readonly framebuffer would be unusual but not impossible - if ((flags & MP_BUFFER_WRITE) && !(self->bufinfo.typecode & MP_OBJ_ARRAY_TYPECODE_FLAG_RW)) { - return 1; - } - *bufinfo = self->bufinfo; - bufinfo->typecode = 'H'; - return 0; -} - const mp_obj_type_t is31fl3741_IS31FL3741_type = { { &mp_type_type }, - .flags = MP_TYPE_FLAG_EXTENDED, .name = MP_QSTR_is31fl3741, .locals_dict = (mp_obj_dict_t *)&is31fl3741_IS31FL3741_locals_dict, .make_new = is31fl3741_IS31FL3741_make_new, - MP_TYPE_EXTENDED_FIELDS( - .buffer_p = { .get_buffer = is31fl3741_IS31FL3741_get_buffer, }, - .protocol = &is31fl3741_IS31FL3741_proto, - ), }; diff --git a/shared-bindings/is31fl3741/IS31FL3741.h b/shared-bindings/is31fl3741/IS31FL3741.h index 3815f10de0..2b81b01617 100644 --- a/shared-bindings/is31fl3741/IS31FL3741.h +++ b/shared-bindings/is31fl3741/IS31FL3741.h @@ -30,32 +30,20 @@ extern const mp_obj_type_t is31fl3741_IS31FL3741_type; -void common_hal_is31fl3741_IS31FL3741_construct(is31fl3741_IS31FL3741_obj_t *self, int width, int height, mp_obj_t framebuffer, busio_i2c_obj_t *i2c, uint8_t addr, mp_obj_t mapping); +void common_hal_is31fl3741_IS31FL3741_construct(is31fl3741_IS31FL3741_obj_t *self, busio_i2c_obj_t *i2c, uint8_t addr); void common_hal_is31fl3741_IS31FL3741_deinit(is31fl3741_IS31FL3741_obj_t *); -int common_hal_is31fl3741_IS31FL3741_get_width(is31fl3741_IS31FL3741_obj_t *self); -int common_hal_is31fl3741_IS31FL3741_get_height(is31fl3741_IS31FL3741_obj_t *self); +void common_hal_is31fl3741_write(is31fl3741_IS31FL3741_obj_t *is31, const mp_obj_t *mapping, const uint8_t *pixels, size_t numBytes); -void common_hal_displayio_is31fl3741_begin_transaction(is31fl3741_IS31FL3741_obj_t *self); -void common_hal_displayio_is31fl3741_end_transaction(is31fl3741_IS31FL3741_obj_t *self); +void common_hal_is31fl3741_begin_transaction(is31fl3741_IS31FL3741_obj_t *self); +void common_hal_is31fl3741_end_transaction(is31fl3741_IS31FL3741_obj_t *self); -void common_hal_is31fl3741_IS31FL3741_set_global_current(is31fl3741_IS31FL3741_obj_t *self, uint8_t current); -uint8_t common_hal_is31fl3741_IS31FL3741_get_global_current(is31fl3741_IS31FL3741_obj_t *self); - -void common_hal_is31fl3741_IS31FL3741_set_paused(is31fl3741_IS31FL3741_obj_t *self, bool paused); -bool common_hal_is31fl3741_IS31FL3741_get_paused(is31fl3741_IS31FL3741_obj_t *self); -void common_hal_is31fl3741_IS31FL3741_refresh(is31fl3741_IS31FL3741_obj_t *self, uint8_t *dirtyrows); - -void common_hal_is31fl3741_IS31FL3741_reconstruct(is31fl3741_IS31FL3741_obj_t *self, mp_obj_t framebuffer); - -void is31fl3741_IS31FL3741_collect_ptrs(is31fl3741_IS31FL3741_obj_t *self); - -void is31fl3741_send_unlock(busio_i2c_obj_t *i2c, uint8_t addr); -void is31fl3741_set_page(busio_i2c_obj_t *i2c, uint8_t addr, uint8_t p); -void is31fl3741_send_enable(busio_i2c_obj_t *i2c, uint8_t addr); -void is31fl3741_send_reset(busio_i2c_obj_t *i2c, uint8_t addr); -void is31fl3741_set_current(busio_i2c_obj_t *i2c, uint8_t addr, uint8_t current); -uint8_t is31fl3741_get_current(busio_i2c_obj_t *i2c, uint8_t addr); -void is31fl3741_set_led(busio_i2c_obj_t *i2c, uint8_t addr, uint16_t led, uint8_t level, uint8_t page); -void is31fl3741_draw_pixel(busio_i2c_obj_t *i2c, uint8_t addr, int16_t x, int16_t y, uint32_t color, uint16_t *mapping); +void common_hal_is31fl3741_send_unlock(is31fl3741_IS31FL3741_obj_t *self); +void common_hal_is31fl3741_set_page(is31fl3741_IS31FL3741_obj_t *self, uint8_t p); +void common_hal_is31fl3741_send_enable(is31fl3741_IS31FL3741_obj_t *self); +void common_hal_is31fl3741_send_reset(is31fl3741_IS31FL3741_obj_t *self); +void common_hal_is31fl3741_set_current(is31fl3741_IS31FL3741_obj_t *self, uint8_t current); +uint8_t common_hal_is31fl3741_get_current(is31fl3741_IS31FL3741_obj_t *self); +void common_hal_is31fl3741_set_led(is31fl3741_IS31FL3741_obj_t *self, uint16_t led, uint8_t level, uint8_t page); +void common_hal_is31fl3741_draw_pixel(is31fl3741_IS31FL3741_obj_t *self, int16_t x, int16_t y, uint32_t color, uint16_t *mapping); diff --git a/shared-bindings/is31fl3741/__init__.c b/shared-bindings/is31fl3741/__init__.c index 90b9426a4d..605889700c 100644 --- a/shared-bindings/is31fl3741/__init__.c +++ b/shared-bindings/is31fl3741/__init__.c @@ -25,15 +25,19 @@ */ #include +#include #include "py/obj.h" #include "py/runtime.h" +#include "shared-bindings/busio/I2C.h" #include "shared-bindings/is31fl3741/IS31FL3741.h" +#include "shared-bindings/is31fl3741/FrameBuffer.h" STATIC const mp_rom_map_elem_t is31fl3741_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_is31fl3741) }, { MP_ROM_QSTR(MP_QSTR_IS31FL3741), MP_ROM_PTR(&is31fl3741_IS31FL3741_type) }, + { MP_ROM_QSTR(MP_QSTR_IS31FL3741_FrameBuffer), MP_ROM_PTR(&is31fl3741_FrameBuffer_type) }, }; STATIC MP_DEFINE_CONST_DICT(is31fl3741_module_globals, is31fl3741_module_globals_table); diff --git a/shared-bindings/keypad/__init__.c b/shared-bindings/keypad/__init__.c index e12992ec5f..4450e892ca 100644 --- a/shared-bindings/keypad/__init__.c +++ b/shared-bindings/keypad/__init__.c @@ -42,7 +42,7 @@ //| """ //| -STATIC mp_map_elem_t keypad_module_globals_table[] = { +STATIC mp_rom_map_elem_t keypad_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_keypad) }, { MP_ROM_QSTR(MP_QSTR_Event), MP_OBJ_FROM_PTR(&keypad_event_type) }, { MP_ROM_QSTR(MP_QSTR_EventQueue), MP_OBJ_FROM_PTR(&keypad_eventqueue_type) }, @@ -51,7 +51,7 @@ STATIC mp_map_elem_t keypad_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_ShiftRegisterKeys), MP_OBJ_FROM_PTR(&keypad_shiftregisterkeys_type) }, }; -STATIC MP_DEFINE_MUTABLE_DICT(keypad_module_globals, keypad_module_globals_table); +STATIC MP_DEFINE_CONST_DICT(keypad_module_globals, keypad_module_globals_table); const mp_obj_module_t keypad_module = { .base = { &mp_type_module }, diff --git a/shared-bindings/msgpack/__init__.c b/shared-bindings/msgpack/__init__.c index d71ab9a6b9..149f0343a0 100644 --- a/shared-bindings/msgpack/__init__.c +++ b/shared-bindings/msgpack/__init__.c @@ -87,8 +87,8 @@ //| """Ouput object to buffer in msgpack format. //| //| :param object obj: Object to convert to msgpack format. -//| :param ~_typing.WriteableBuffer buffer: buffer to write into -//| :param Optional[~_typing.Callable[[object], None]] default: +//| :param ~circuitpython_typing.WriteableBuffer buffer: buffer to write into +//| :param Optional[~circuitpython_typing.Callable[[object], None]] default: //| function called for python objects that do not have //| a representation in msgpack format. //| """ @@ -118,8 +118,8 @@ MP_DEFINE_CONST_FUN_OBJ_KW(mod_msgpack_pack_obj, 0, mod_msgpack_pack); //| def unpack(buffer: ReadableBuffer, *, ext_hook: Union[Callable[[int, bytes], object], None] = None, use_list: bool=True) -> object: //| """Unpack and return one object from buffer. //| -//| :param ~_typing.ReadableBuffer buffer: buffer to read from -//| :param Optional[~_typing.Callable[[int, bytes], object]] ext_hook: function called for objects in +//| :param ~circuitpython_typing.ReadableBuffer buffer: buffer to read from +//| :param Optional[~circuitpython_typing.Callable[[int, bytes], object]] ext_hook: function called for objects in //| msgpack ext format. //| :param Optional[bool] use_list: return array as list or tuple (use_list=False). //| diff --git a/shared-bindings/neopixel_write/__init__.c b/shared-bindings/neopixel_write/__init__.c index ae30518bd1..a95020ad46 100644 --- a/shared-bindings/neopixel_write/__init__.c +++ b/shared-bindings/neopixel_write/__init__.c @@ -29,8 +29,15 @@ #include "py/mphal.h" #include "py/runtime.h" #include "shared-bindings/digitalio/DigitalInOut.h" +#include "shared-bindings/util.h" #include "supervisor/shared/translate.h" +STATIC void check_for_deinit(digitalio_digitalinout_obj_t *self) { + if (common_hal_digitalio_digitalinout_deinited(self)) { + raise_deinited_error(); + } +} + //| """Low-level neopixel implementation //| //| The `neopixel_write` module contains a helper method to write out bytes in @@ -54,14 +61,19 @@ //| """Write buf out on the given DigitalInOut. //| //| :param ~digitalio.DigitalInOut digitalinout: the DigitalInOut to output with -//| :param ~_typing.ReadableBuffer buf: The bytes to clock out. No assumption is made about color order""" +//| :param ~circuitpython_typing.ReadableBuffer buf: The bytes to clock out. No assumption is made about color order""" //| ... STATIC mp_obj_t neopixel_write_neopixel_write_(mp_obj_t digitalinout_obj, mp_obj_t buf) { if (!mp_obj_is_type(digitalinout_obj, &digitalio_digitalinout_type)) { mp_raise_TypeError_varg(translate("Expected a %q"), digitalio_digitalinout_type.name); } + // Convert parameters into expected types. const digitalio_digitalinout_obj_t *digitalinout = MP_OBJ_TO_PTR(digitalinout_obj); + + // Check to see if the NeoPixel has been deinited before writing to it. + check_for_deinit(digitalinout_obj); + mp_buffer_info_t bufinfo; mp_get_buffer_raise(buf, &bufinfo, MP_BUFFER_READ); // Call platform's neopixel write function with provided buffer and options. diff --git a/shared-bindings/pulseio/PulseOut.c b/shared-bindings/pulseio/PulseOut.c index bf2aaf54ff..ac568231b9 100644 --- a/shared-bindings/pulseio/PulseOut.c +++ b/shared-bindings/pulseio/PulseOut.c @@ -59,7 +59,7 @@ //| import board //| //| # 50% duty cycle at 38kHz. -//| pwm = pulseio.PulseOut(board.LED, frequency=38000, duty_cycle=32768) +//| pulse = pulseio.PulseOut(board.LED, frequency=38000, duty_cycle=32768) //| # on off on off on //| pulses = array.array('H', [65000, 1000, 65000, 65000, 1000]) //| pulse.send(pulses) diff --git a/shared-bindings/sdcardio/SDCard.c b/shared-bindings/sdcardio/SDCard.c index fe487ae7fb..5afca798f6 100644 --- a/shared-bindings/sdcardio/SDCard.c +++ b/shared-bindings/sdcardio/SDCard.c @@ -130,7 +130,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(sdcardio_sdcard_deinit_obj, sdcardio_sdcard_deinit); //| """Read one or more blocks from the card //| //| :param int start_block: The block to start reading from -//| :param ~_typing.WriteableBuffer buf: The buffer to write into. Length must be multiple of 512. +//| :param ~circuitpython_typing.WriteableBuffer buf: The buffer to write into. Length must be multiple of 512. //| //| :return: None""" //| @@ -171,7 +171,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(sdcardio_sdcard_sync_obj, sdcardio_sdcard_sync); //| """Write one or more blocks to the card //| //| :param int start_block: The block to start writing from -//| :param ~_typing.ReadableBuffer buf: The buffer to read from. Length must be multiple of 512. +//| :param ~circuitpython_typing.ReadableBuffer buf: The buffer to read from. Length must be multiple of 512. //| //| :return: None""" //| diff --git a/shared-bindings/sdioio/SDCard.c b/shared-bindings/sdioio/SDCard.c index 6fd38ce24c..c4b23ea594 100644 --- a/shared-bindings/sdioio/SDCard.c +++ b/shared-bindings/sdioio/SDCard.c @@ -165,7 +165,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(sdioio_sdcard_count_obj, sdioio_sdcard_count); //| """Read one or more blocks from the card //| //| :param int start_block: The block to start reading from -//| :param ~_typing.WriteableBuffer buf: The buffer to write into. Length must be multiple of 512. +//| :param ~circuitpython_typing.WriteableBuffer buf: The buffer to write into. Length must be multiple of 512. //| //| :return: None""" STATIC mp_obj_t sdioio_sdcard_readblocks(mp_obj_t self_in, mp_obj_t start_block_in, mp_obj_t buf_in) { @@ -187,7 +187,7 @@ MP_DEFINE_CONST_FUN_OBJ_3(sdioio_sdcard_readblocks_obj, sdioio_sdcard_readblocks //| """Write one or more blocks to the card //| //| :param int start_block: The block to start writing from -//| :param ~_typing.ReadableBuffer buf: The buffer to read from. Length must be multiple of 512. +//| :param ~circuitpython_typing.ReadableBuffer buf: The buffer to read from. Length must be multiple of 512. //| //| :return: None""" //| diff --git a/shared-bindings/ssl/SSLContext.c b/shared-bindings/ssl/SSLContext.c index 885a156edd..2b38768f6a 100644 --- a/shared-bindings/ssl/SSLContext.c +++ b/shared-bindings/ssl/SSLContext.c @@ -29,6 +29,7 @@ #include "py/objtuple.h" #include "py/objlist.h" +#include "py/objproperty.h" #include "py/runtime.h" #include "py/mperrno.h" @@ -51,10 +52,69 @@ STATIC mp_obj_t ssl_sslcontext_make_new(const mp_obj_type_t *type, size_t n_args return MP_OBJ_FROM_PTR(s); } -//| def wrap_socket(sock: socketpool.Socket, *, server_side: bool = False, server_hostname: Optional[str] = None) -> ssl.SSLSocket: -//| """Wraps the socket into a socket-compatible class that handles SSL negotiation. -//| The socket must be of type SOCK_STREAM.""" -//| ... +//| def load_verify_locations(self, cadata: Optional[str] = None) -> None: +//| """Load a set of certification authority (CA) certificates used to validate +//| other peers' certificates.""" +//| + +STATIC mp_obj_t ssl_sslcontext_load_verify_locations(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + enum { ARG_cadata }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_cadata, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} }, + }; + ssl_sslcontext_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); + + mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; + mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + + const char *cadata = mp_obj_str_get_str(args[ARG_cadata].u_obj); + + common_hal_ssl_sslcontext_load_verify_locations(self, cadata); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_KW(ssl_sslcontext_load_verify_locations_obj, 1, ssl_sslcontext_load_verify_locations); + +//| def set_default_verify_paths(self) -> None: +//| """Load a set of default certification authority (CA) certificates.""" +//| + +STATIC mp_obj_t ssl_sslcontext_set_default_verify_paths(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + ssl_sslcontext_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); + + common_hal_ssl_sslcontext_set_default_verify_paths(self); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_KW(ssl_sslcontext_set_default_verify_paths_obj, 1, ssl_sslcontext_set_default_verify_paths); + +//| check_hostname: bool +//| """Whether to match the peer certificate's hostname.""" +//| + +STATIC mp_obj_t ssl_sslcontext_get_check_hostname(mp_obj_t self_in) { + ssl_sslcontext_obj_t *self = MP_OBJ_TO_PTR(self_in); + + return mp_obj_new_bool(common_hal_ssl_sslcontext_get_check_hostname(self)); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(ssl_sslcontext_get_check_hostname_obj, ssl_sslcontext_get_check_hostname); + +STATIC mp_obj_t ssl_sslcontext_set_check_hostname(mp_obj_t self_in, mp_obj_t value) { + ssl_sslcontext_obj_t *self = MP_OBJ_TO_PTR(self_in); + + common_hal_ssl_sslcontext_set_check_hostname(self, mp_obj_is_true(value)); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(ssl_sslcontext_set_check_hostname_obj, ssl_sslcontext_set_check_hostname); + +const mp_obj_property_t ssl_sslcontext_check_hostname_obj = { + .base.type = &mp_type_property, + .proxy = {(mp_obj_t)&ssl_sslcontext_get_check_hostname_obj, + (mp_obj_t)&ssl_sslcontext_set_check_hostname_obj, + MP_ROM_NONE}, +}; + +//| def wrap_socket(self, sock: socketpool.Socket, *, server_side: bool = False, server_hostname: Optional[str] = None) -> ssl.SSLSocket: +//| """Wraps the socket into a socket-compatible class that handles SSL negotiation. +//| The socket must be of type SOCK_STREAM.""" //| STATIC mp_obj_t ssl_sslcontext_wrap_socket(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { @@ -69,7 +129,10 @@ STATIC mp_obj_t ssl_sslcontext_wrap_socket(size_t n_args, const mp_obj_t *pos_ar mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - const char *server_hostname = mp_obj_str_get_str(args[ARG_server_hostname].u_obj); + const char *server_hostname = NULL; + if (args[ARG_server_hostname].u_obj != mp_const_none) { + server_hostname = mp_obj_str_get_str(args[ARG_server_hostname].u_obj); + } bool server_side = args[ARG_server_side].u_bool; if (server_side && server_hostname != NULL) { mp_raise_ValueError(translate("Server side context cannot have hostname")); @@ -83,6 +146,9 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(ssl_sslcontext_wrap_socket_obj, 1, ssl_sslcont STATIC const mp_rom_map_elem_t ssl_sslcontext_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_wrap_socket), MP_ROM_PTR(&ssl_sslcontext_wrap_socket_obj) }, + { MP_ROM_QSTR(MP_QSTR_load_verify_locations), MP_ROM_PTR(&ssl_sslcontext_load_verify_locations_obj) }, + { MP_ROM_QSTR(MP_QSTR_set_default_verify_paths), MP_ROM_PTR(&ssl_sslcontext_set_default_verify_paths_obj) }, + { MP_ROM_QSTR(MP_QSTR_check_hostname), MP_ROM_PTR(&ssl_sslcontext_check_hostname_obj) }, }; STATIC MP_DEFINE_CONST_DICT(ssl_sslcontext_locals_dict, ssl_sslcontext_locals_dict_table); diff --git a/shared-bindings/ssl/SSLContext.h b/shared-bindings/ssl/SSLContext.h index 1e1986a48d..ef04f25d43 100644 --- a/shared-bindings/ssl/SSLContext.h +++ b/shared-bindings/ssl/SSLContext.h @@ -39,4 +39,12 @@ void common_hal_ssl_sslcontext_construct(ssl_sslcontext_obj_t *self); ssl_sslsocket_obj_t *common_hal_ssl_sslcontext_wrap_socket(ssl_sslcontext_obj_t *self, socketpool_socket_obj_t *sock, bool server_side, const char *server_hostname); +void common_hal_ssl_sslcontext_load_verify_locations(ssl_sslcontext_obj_t *self, + const char *cadata); + +void common_hal_ssl_sslcontext_set_default_verify_paths(ssl_sslcontext_obj_t *self); + +bool common_hal_ssl_sslcontext_get_check_hostname(ssl_sslcontext_obj_t *self); +void common_hal_ssl_sslcontext_set_check_hostname(ssl_sslcontext_obj_t *self, bool value); + #endif // MICROPY_INCLUDED_SHARED_BINDINGS_SSL_SSLCONTEXT_H diff --git a/shared-bindings/supervisor/__init__.c b/shared-bindings/supervisor/__init__.c index 35ae63c03d..c69f0e4174 100644 --- a/shared-bindings/supervisor/__init__.c +++ b/shared-bindings/supervisor/__init__.c @@ -33,6 +33,7 @@ #include "shared/runtime/interrupt_char.h" #include "supervisor/shared/autoreload.h" #include "supervisor/shared/bluetooth/bluetooth.h" +#include "supervisor/shared/display.h" #include "supervisor/shared/status_leds.h" #include "supervisor/shared/stack.h" #include "supervisor/shared/traceback.h" @@ -75,16 +76,15 @@ STATIC mp_obj_t supervisor_disable_autoreload(void) { MP_DEFINE_CONST_FUN_OBJ_0(supervisor_disable_autoreload_obj, supervisor_disable_autoreload); //| def set_rgb_status_brightness(brightness: int) -> None: -//| """Set brightness of status neopixel from 0-255 -//| `set_rgb_status_brightness` is called.""" +//| """Set brightness of status RGB LED from 0-255. This will take effect +//| after the current code finishes and the status LED is used to show +//| the finish state.""" //| ... //| STATIC mp_obj_t supervisor_set_rgb_status_brightness(mp_obj_t lvl) { // This must be int. If cast to uint8_t first, will never raise a ValueError. int brightness_int = mp_obj_get_int(lvl); - if (brightness_int < 0 || brightness_int > 255) { - mp_raise_ValueError(translate("Brightness must be between 0 and 255")); - } + mp_arg_validate_int_range(brightness_int, 0, 255, MP_QSTR_brightness); set_status_brightness((uint8_t)brightness_int); return mp_const_none; } @@ -299,6 +299,21 @@ STATIC mp_obj_t supervisor_disable_ble_workflow(void) { } MP_DEFINE_CONST_FUN_OBJ_0(supervisor_disable_ble_workflow_obj, supervisor_disable_ble_workflow); +//| def reset_terminal(x_pixels: int, y_pixels: int) -> None: +//| """Reset the CircuitPython serial terminal with new dimensions.""" +//| ... +//| +STATIC mp_obj_t supervisor_reset_terminal(mp_obj_t x_pixels, mp_obj_t y_pixels) { + #if CIRCUITPY_DISPLAYIO + supervisor_stop_terminal(); + supervisor_start_terminal(mp_obj_get_int(x_pixels), mp_obj_get_int(y_pixels)); + #else + mp_raise_NotImplementedError(NULL); + #endif + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_2(supervisor_reset_terminal_obj, supervisor_reset_terminal); + STATIC const mp_rom_map_elem_t supervisor_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_supervisor) }, { MP_ROM_QSTR(MP_QSTR_enable_autoreload), MP_ROM_PTR(&supervisor_enable_autoreload_obj) }, @@ -312,6 +327,7 @@ STATIC const mp_rom_map_elem_t supervisor_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_ticks_ms), MP_ROM_PTR(&supervisor_ticks_ms_obj) }, { MP_ROM_QSTR(MP_QSTR_get_previous_traceback), MP_ROM_PTR(&supervisor_get_previous_traceback_obj) }, { MP_ROM_QSTR(MP_QSTR_disable_ble_workflow), MP_ROM_PTR(&supervisor_disable_ble_workflow_obj) }, + { MP_ROM_QSTR(MP_QSTR_reset_terminal), MP_ROM_PTR(&supervisor_reset_terminal_obj) }, }; STATIC MP_DEFINE_CONST_DICT(supervisor_module_globals, supervisor_module_globals_table); diff --git a/shared-bindings/synthio/MidiTrack.c b/shared-bindings/synthio/MidiTrack.c index 6ffefd4713..1fb3fdbec1 100644 --- a/shared-bindings/synthio/MidiTrack.c +++ b/shared-bindings/synthio/MidiTrack.c @@ -42,7 +42,7 @@ //| are supported; channel numbers and key velocities are ignored. Up to two notes may be on at the //| same time. //| -//| :param ~_typing.ReadableBuffer buffer: Stream of MIDI events, as stored in a MIDI file track chunk +//| :param ~circuitpython_typing.ReadableBuffer buffer: Stream of MIDI events, as stored in a MIDI file track chunk //| :param int tempo: Tempo of the streamed events, in MIDI ticks per second //| :param int sample_rate: The desired playback sample rate; higher sample rate requires more memory //| diff --git a/shared-bindings/traceback/__init__.c b/shared-bindings/traceback/__init__.c index 6fdb060439..aa21210494 100644 --- a/shared-bindings/traceback/__init__.c +++ b/shared-bindings/traceback/__init__.c @@ -42,7 +42,6 @@ STATIC void traceback_exception_common(mp_print_t *print, mp_obj_t value, mp_obj if (!mp_obj_is_exception_instance(value)) { mp_raise_TypeError(translate("invalid exception")); } - mp_obj_exception_t exc = *(mp_obj_exception_t *)MP_OBJ_TO_PTR(value); mp_int_t limit = 0; bool print_tb = true; @@ -51,13 +50,17 @@ STATIC void traceback_exception_common(mp_print_t *print, mp_obj_t value, mp_obj print_tb = (limit != 0); } + mp_obj_exception_t *exc = mp_obj_exception_get_native(value); + mp_obj_traceback_t *trace_backup = exc->traceback; + if (tb_obj != mp_const_none && print_tb) { - exc.traceback = mp_arg_validate_type(tb_obj, &mp_type_traceback, MP_QSTR_tb); + exc->traceback = mp_arg_validate_type(tb_obj, &mp_type_traceback, MP_QSTR_tb); } else { - exc.traceback = (mp_obj_traceback_t *)&mp_const_empty_traceback_obj; + exc->traceback = (mp_obj_traceback_t *)&mp_const_empty_traceback_obj; } - shared_module_traceback_print_exception(&exc, print, limit); + shared_module_traceback_print_exception(MP_OBJ_TO_PTR(value), print, limit); + exc->traceback = trace_backup; } //| def format_exception(etype: Type[BaseException], value: BaseException, tb: TracebackType, diff --git a/shared-bindings/vectorio/Circle.c b/shared-bindings/vectorio/Circle.c index 43845937c4..9711c53e0d 100644 --- a/shared-bindings/vectorio/Circle.c +++ b/shared-bindings/vectorio/Circle.c @@ -97,6 +97,8 @@ const mp_obj_property_t vectorio_circle_radius_obj = { //| STATIC const mp_rom_map_elem_t vectorio_circle_locals_dict_table[] = { + // Functions + { MP_ROM_QSTR(MP_QSTR_contains), MP_ROM_PTR(&vectorio_vector_shape_contains_obj) }, // Properties { MP_ROM_QSTR(MP_QSTR_radius), MP_ROM_PTR(&vectorio_circle_radius_obj) }, { MP_ROM_QSTR(MP_QSTR_x), MP_ROM_PTR(&vectorio_vector_shape_x_obj) }, diff --git a/shared-bindings/vectorio/Polygon.c b/shared-bindings/vectorio/Polygon.c index d1078b2d2d..dfe50ffd01 100644 --- a/shared-bindings/vectorio/Polygon.c +++ b/shared-bindings/vectorio/Polygon.c @@ -103,6 +103,8 @@ const mp_obj_property_t vectorio_polygon_points_obj = { //| STATIC const mp_rom_map_elem_t vectorio_polygon_locals_dict_table[] = { + // Functions + { MP_ROM_QSTR(MP_QSTR_contains), MP_ROM_PTR(&vectorio_vector_shape_contains_obj) }, // Properties { MP_ROM_QSTR(MP_QSTR_points), MP_ROM_PTR(&vectorio_polygon_points_obj) }, { MP_ROM_QSTR(MP_QSTR_x), MP_ROM_PTR(&vectorio_vector_shape_x_obj) }, diff --git a/shared-bindings/vectorio/Rectangle.c b/shared-bindings/vectorio/Rectangle.c index 287ae9d408..67367eb538 100644 --- a/shared-bindings/vectorio/Rectangle.c +++ b/shared-bindings/vectorio/Rectangle.c @@ -60,6 +60,51 @@ STATIC const vectorio_draw_protocol_t rectangle_draw_protocol = { .draw_protocol_impl = &vectorio_vector_shape_draw_protocol_impl }; +//| width : int +//| """The width of the rectangle in pixels.""" +//| +STATIC mp_obj_t vectorio_rectangle_obj_get_width(mp_obj_t self_in) { + vectorio_rectangle_t *self = MP_OBJ_TO_PTR(self_in); + return mp_obj_new_int(common_hal_vectorio_rectangle_get_width(self)); +} +MP_DEFINE_CONST_FUN_OBJ_1(vectorio_rectangle_get_width_obj, vectorio_rectangle_obj_get_width); + +STATIC mp_obj_t vectorio_rectangle_obj_set_width(mp_obj_t self_in, mp_obj_t width) { + vectorio_rectangle_t *self = MP_OBJ_TO_PTR(self_in); + common_hal_vectorio_rectangle_set_width(self, mp_obj_get_int(width)); + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_2(vectorio_rectangle_set_width_obj, vectorio_rectangle_obj_set_width); + +const mp_obj_property_t vectorio_rectangle_width_obj = { + .base.type = &mp_type_property, + .proxy = {(mp_obj_t)&vectorio_rectangle_get_width_obj, + (mp_obj_t)&vectorio_rectangle_set_width_obj, + MP_ROM_NONE}, +}; + +//| height : int +//| """The height of the rectangle in pixels.""" +//| +STATIC mp_obj_t vectorio_rectangle_obj_get_height(mp_obj_t self_in) { + vectorio_rectangle_t *self = MP_OBJ_TO_PTR(self_in); + return mp_obj_new_int(common_hal_vectorio_rectangle_get_height(self)); +} +MP_DEFINE_CONST_FUN_OBJ_1(vectorio_rectangle_get_height_obj, vectorio_rectangle_obj_get_height); + +STATIC mp_obj_t vectorio_rectangle_obj_set_height(mp_obj_t self_in, mp_obj_t height) { + vectorio_rectangle_t *self = MP_OBJ_TO_PTR(self_in); + common_hal_vectorio_rectangle_set_height(self, mp_obj_get_int(height)); + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_2(vectorio_rectangle_set_height_obj, vectorio_rectangle_obj_set_height); + +const mp_obj_property_t vectorio_rectangle_height_obj = { + .base.type = &mp_type_property, + .proxy = {(mp_obj_t)&vectorio_rectangle_get_height_obj, + (mp_obj_t)&vectorio_rectangle_set_height_obj, + MP_ROM_NONE}, +}; // Documentation for properties inherited from VectorShape. @@ -77,9 +122,13 @@ STATIC const vectorio_draw_protocol_t rectangle_draw_protocol = { //| STATIC const mp_rom_map_elem_t vectorio_rectangle_locals_dict_table[] = { + // Functions + { MP_ROM_QSTR(MP_QSTR_contains), MP_ROM_PTR(&vectorio_vector_shape_contains_obj) }, // Properties { MP_ROM_QSTR(MP_QSTR_x), MP_ROM_PTR(&vectorio_vector_shape_x_obj) }, { MP_ROM_QSTR(MP_QSTR_y), MP_ROM_PTR(&vectorio_vector_shape_y_obj) }, + { MP_ROM_QSTR(MP_QSTR_width), MP_ROM_PTR(&vectorio_rectangle_width_obj) }, + { MP_ROM_QSTR(MP_QSTR_height), MP_ROM_PTR(&vectorio_rectangle_height_obj) }, { MP_ROM_QSTR(MP_QSTR_location), MP_ROM_PTR(&vectorio_vector_shape_location_obj) }, { MP_ROM_QSTR(MP_QSTR_pixel_shader), MP_ROM_PTR(&vectorio_vector_shape_pixel_shader_obj) }, }; diff --git a/shared-bindings/vectorio/Rectangle.h b/shared-bindings/vectorio/Rectangle.h index 24b103c26e..d50b811624 100644 --- a/shared-bindings/vectorio/Rectangle.h +++ b/shared-bindings/vectorio/Rectangle.h @@ -3,10 +3,12 @@ #include "shared-module/vectorio/Rectangle.h" #include "shared-module/displayio/area.h" +#include "shared-module/vectorio/__init__.h" extern const mp_obj_type_t vectorio_rectangle_type; void common_hal_vectorio_rectangle_construct(vectorio_rectangle_t *self, uint32_t width, uint32_t height); +void common_hal_vectorio_rectangle_set_on_dirty(vectorio_rectangle_t *self, vectorio_event_t on_dirty); uint32_t common_hal_vectorio_rectangle_get_pixel(void *rectangle, int16_t x, int16_t y); @@ -14,4 +16,10 @@ void common_hal_vectorio_rectangle_get_area(void *rectangle, displayio_area_t *o mp_obj_t common_hal_vectorio_rectangle_get_draw_protocol(void *rectangle); +int16_t common_hal_vectorio_rectangle_get_width(void *obj); +void common_hal_vectorio_rectangle_set_width(void *obj, int16_t width); + +int16_t common_hal_vectorio_rectangle_get_height(void *obj); +void common_hal_vectorio_rectangle_set_height(void *obj, int16_t height); + #endif // MICROPY_INCLUDED_SHARED_BINDINGS_VECTORIO_RECTANGLE_H diff --git a/shared-bindings/vectorio/VectorShape.c b/shared-bindings/vectorio/VectorShape.c index d5d12ec1cd..3293466cc4 100644 --- a/shared-bindings/vectorio/VectorShape.c +++ b/shared-bindings/vectorio/VectorShape.c @@ -62,6 +62,7 @@ mp_obj_t vectorio_vector_shape_make_new(const mp_obj_t shape, const mp_obj_t pix if (mp_obj_is_type(shape, &vectorio_polygon_type)) { common_hal_vectorio_polygon_set_on_dirty(self->ishape.shape, on_dirty); } else if (mp_obj_is_type(shape, &vectorio_rectangle_type)) { + common_hal_vectorio_rectangle_set_on_dirty(self->ishape.shape, on_dirty); } else if (mp_obj_is_type(shape, &vectorio_circle_type)) { common_hal_vectorio_circle_set_on_dirty(self->ishape.shape, on_dirty); } else { @@ -79,6 +80,21 @@ vectorio_draw_protocol_impl_t vectorio_vector_shape_draw_protocol_impl = { .draw_get_refresh_areas = (draw_get_refresh_areas_fun)vectorio_vector_shape_get_refresh_areas, }; +// Stub checker does not approve of these shared properties. +// x: int +// y: int +// """true if x,y lies inside the shape.""" +// +STATIC mp_obj_t vectorio_vector_shape_obj_contains(mp_obj_t wrapper_shape, mp_obj_t x_obj, mp_obj_t y_obj) { + // Relies on the fact that only vector_shape impl gets matched with a VectorShape. + const vectorio_draw_protocol_t *draw_protocol = mp_proto_get(MP_QSTR_protocol_draw, wrapper_shape); + vectorio_vector_shape_t *self = MP_OBJ_TO_PTR(draw_protocol->draw_get_protocol_self(wrapper_shape)); + + mp_int_t x = mp_obj_get_int(x_obj); + mp_int_t y = mp_obj_get_int(y_obj); + return mp_obj_new_bool(common_hal_vectorio_vector_shape_contains(self, x, y)); +} +MP_DEFINE_CONST_FUN_OBJ_3(vectorio_vector_shape_contains_obj, vectorio_vector_shape_obj_contains); // Stub checker does not approve of these shared properties. // x: int diff --git a/shared-bindings/vectorio/VectorShape.h b/shared-bindings/vectorio/VectorShape.h index 12c7e628ad..959a38dff0 100644 --- a/shared-bindings/vectorio/VectorShape.h +++ b/shared-bindings/vectorio/VectorShape.h @@ -18,6 +18,8 @@ void common_hal_vectorio_vector_shape_construct(vectorio_vector_shape_t *self, vectorio_ishape_t ishape, mp_obj_t pixel_shader, int32_t x, int32_t y); +bool common_hal_vectorio_vector_shape_contains(vectorio_vector_shape_t *self, mp_int_t x, mp_int_t y); + void common_hal_vectorio_vector_shape_set_dirty(void *self); mp_int_t common_hal_vectorio_vector_shape_get_x(vectorio_vector_shape_t *self); @@ -40,5 +42,6 @@ extern const mp_obj_property_t vectorio_vector_shape_x_obj; extern const mp_obj_property_t vectorio_vector_shape_y_obj; extern const mp_obj_property_t vectorio_vector_shape_location_obj; extern const mp_obj_property_t vectorio_vector_shape_pixel_shader_obj; +extern const mp_obj_fun_builtin_fixed_t vectorio_vector_shape_contains_obj; #endif // MICROPY_INCLUDED_SHARED_BINDINGS_VECTORIO_SHAPE_H diff --git a/shared-bindings/wifi/Monitor.c b/shared-bindings/wifi/Monitor.c index a9998e7410..4e5235ea88 100644 --- a/shared-bindings/wifi/Monitor.c +++ b/shared-bindings/wifi/Monitor.c @@ -55,7 +55,7 @@ STATIC mp_obj_t wifi_monitor_make_new(const mp_obj_type_t *type, size_t n_args, mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - if (args[ARG_channel].u_int < 0 || args[ARG_channel].u_int > 13) { + if (args[ARG_channel].u_int < 1 || args[ARG_channel].u_int > 13) { mp_raise_ValueError_varg(translate("%q out of bounds"), MP_QSTR_channel); } @@ -83,7 +83,11 @@ STATIC mp_obj_t wifi_monitor_obj_get_channel(mp_obj_t self_in) { MP_DEFINE_CONST_FUN_OBJ_1(wifi_monitor_get_channel_obj, wifi_monitor_obj_get_channel); STATIC mp_obj_t wifi_monitor_obj_set_channel(mp_obj_t self_in, mp_obj_t channel) { - common_hal_wifi_monitor_set_channel(self_in, mp_obj_get_int(channel)); + mp_int_t c = mp_obj_get_int(channel); + if (c < 1 || c > 13) { + mp_raise_ValueError_varg(translate("%q out of bounds"), MP_QSTR_channel); + } + common_hal_wifi_monitor_set_channel(self_in, c); return mp_const_none; } MP_DEFINE_CONST_FUN_OBJ_2(wifi_monitor_set_channel_obj, wifi_monitor_obj_set_channel); diff --git a/shared-bindings/wifi/Radio.c b/shared-bindings/wifi/Radio.c index 93d92630ca..bb8ef18be1 100644 --- a/shared-bindings/wifi/Radio.c +++ b/shared-bindings/wifi/Radio.c @@ -230,7 +230,8 @@ MP_DEFINE_CONST_FUN_OBJ_1(wifi_radio_stop_station_obj, wifi_radio_stop_station); //| password: ReadableBuffer = b"", //| *, //| channel: Optional[int] = 1, -//| authmode: Optional[AuthMode]) -> None: +//| authmode: Optional[AuthMode], +//| max_connections: Optional[int] = 4) -> None: //| """Starts an Access Point with the specified ssid and password. //| //| If ``channel`` is given, the access point will use that channel unless @@ -239,16 +240,20 @@ MP_DEFINE_CONST_FUN_OBJ_1(wifi_radio_stop_station_obj, wifi_radio_stop_station); //| If ``authmode`` is given, the access point will use that Authentication //| mode. If a password is given, ``authmode`` must not be ``OPEN``. //| If ``authmode`` isn't given, ``OPEN`` will be used when password isn't provided, -//| otherwise ``WPA_WPA2_PSK``.""" +//| otherwise ``WPA_WPA2_PSK``. +//| +//| If ``max_connections`` is given, the access point will allow up to +//| that number of stations to connect.""" //| ... //| STATIC mp_obj_t wifi_radio_start_ap(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { - enum { ARG_ssid, ARG_password, ARG_channel, ARG_authmode }; + enum { ARG_ssid, ARG_password, ARG_channel, ARG_authmode, ARG_max_connections }; static const mp_arg_t allowed_args[] = { { MP_QSTR_ssid, MP_ARG_REQUIRED | MP_ARG_OBJ }, { MP_QSTR_password, MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, { MP_QSTR_channel, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 1} }, { MP_QSTR_authmode, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, + { MP_QSTR_max_connections, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 4} }, }; wifi_radio_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); @@ -283,7 +288,7 @@ STATIC mp_obj_t wifi_radio_start_ap(size_t n_args, const mp_obj_t *pos_args, mp_ authmode = 1; } - common_hal_wifi_radio_start_ap(self, ssid.buf, ssid.len, password.buf, password.len, args[ARG_channel].u_int, authmode); + common_hal_wifi_radio_start_ap(self, ssid.buf, ssid.len, password.buf, password.len, args[ARG_channel].u_int, authmode, args[ARG_max_connections].u_int); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(wifi_radio_start_ap_obj, 1, wifi_radio_start_ap); @@ -304,7 +309,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(wifi_radio_stop_ap_obj, wifi_radio_stop_ap); //| *, //| channel: Optional[int] = 0, //| bssid: Optional[ReadableBuffer] = b"", -//| timeout: Optional[float] = None) -> bool: +//| timeout: Optional[float] = None) -> None: //| """Connects to the given ssid and waits for an ip address. Reconnections are handled //| automatically once one connection succeeds. //| @@ -507,7 +512,7 @@ const mp_obj_property_t wifi_radio_ap_info_obj = { MP_ROM_NONE }, }; -//| def ping(self, ip: ipaddress.IPv4Address, *, timeout: Optional[float] = 0.5) -> float: +//| def ping(self, ip: ipaddress.IPv4Address, *, timeout: Optional[float] = 0.5) -> Optional[float]: //| """Ping an IP to test connectivity. Returns echo time in seconds. //| Returns None when it times out.""" //| ... diff --git a/shared-bindings/wifi/Radio.h b/shared-bindings/wifi/Radio.h index 78a0c333cd..cee9f6ef15 100644 --- a/shared-bindings/wifi/Radio.h +++ b/shared-bindings/wifi/Radio.h @@ -88,7 +88,7 @@ extern void common_hal_wifi_radio_stop_scanning_networks(wifi_radio_obj_t *self) extern void common_hal_wifi_radio_start_station(wifi_radio_obj_t *self); extern void common_hal_wifi_radio_stop_station(wifi_radio_obj_t *self); -extern void common_hal_wifi_radio_start_ap(wifi_radio_obj_t *self, uint8_t *ssid, size_t ssid_len, uint8_t *password, size_t password_len, uint8_t channel, uint8_t authmode); +extern void common_hal_wifi_radio_start_ap(wifi_radio_obj_t *self, uint8_t *ssid, size_t ssid_len, uint8_t *password, size_t password_len, uint8_t channel, uint8_t authmode, uint8_t max_connections); extern void common_hal_wifi_radio_stop_ap(wifi_radio_obj_t *self); extern wifi_radio_error_t common_hal_wifi_radio_connect(wifi_radio_obj_t *self, uint8_t *ssid, size_t ssid_len, uint8_t *password, size_t password_len, uint8_t channel, mp_float_t timeout, uint8_t *bssid, size_t bssid_len); diff --git a/shared-module/_bleio/ScanResults.c b/shared-module/_bleio/ScanResults.c index e5b5525579..1f4dbff310 100644 --- a/shared-module/_bleio/ScanResults.c +++ b/shared-module/_bleio/ScanResults.c @@ -91,9 +91,9 @@ void shared_module_bleio_scanresults_append(bleio_scanresults_obj_t *self, bool connectable, bool scan_response, int8_t rssi, - uint8_t *peer_addr, + const uint8_t *peer_addr, uint8_t addr_type, - uint8_t *data, + const uint8_t *data, uint16_t len) { int32_t packet_size = sizeof(uint8_t) + sizeof(ticks_ms) + sizeof(rssi) + NUM_BLEIO_ADDRESS_BYTES + sizeof(addr_type) + sizeof(len) + len; diff --git a/shared-module/_bleio/ScanResults.h b/shared-module/_bleio/ScanResults.h index fa181aabee..945809c8d9 100644 --- a/shared-module/_bleio/ScanResults.h +++ b/shared-module/_bleio/ScanResults.h @@ -56,9 +56,9 @@ void shared_module_bleio_scanresults_append(bleio_scanresults_obj_t *self, bool connectable, bool scan_result, int8_t rssi, - uint8_t *peer_addr, + const uint8_t *peer_addr, uint8_t addr_type, - uint8_t *data, + const uint8_t *data, uint16_t len); #endif // MICROPY_INCLUDED_SHARED_MODULE_BLEIO_SCANRESULTS_H diff --git a/shared-module/adafruit_bus_device/I2CDevice.c b/shared-module/adafruit_bus_device/i2c_device/I2CDevice.c similarity index 96% rename from shared-module/adafruit_bus_device/I2CDevice.c rename to shared-module/adafruit_bus_device/i2c_device/I2CDevice.c index 942b132c3e..a630f1e2b8 100644 --- a/shared-module/adafruit_bus_device/I2CDevice.c +++ b/shared-module/adafruit_bus_device/i2c_device/I2CDevice.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "shared-bindings/adafruit_bus_device/I2CDevice.h" +#include "shared-bindings/adafruit_bus_device/i2c_device/I2CDevice.h" #include "shared-bindings/busio/I2C.h" #include "py/mperrno.h" #include "py/nlr.h" @@ -79,7 +79,7 @@ void common_hal_adafruit_bus_device_i2cdevice_probe_for_device(adafruit_bus_devi common_hal_adafruit_bus_device_i2cdevice_unlock(self); if (mp_obj_is_subclass_fast(MP_OBJ_FROM_PTR(((mp_obj_base_t *)nlr.ret_val)->type), MP_OBJ_FROM_PTR(&mp_type_OSError))) { - mp_raise_ValueError_varg(translate("No I2C device at address: %x"), self->device_address); + mp_raise_ValueError_varg(translate("No I2C device at address: 0x%x"), self->device_address); } else { /* In case we receive an unrelated exception pass it up */ nlr_raise(MP_OBJ_FROM_PTR(nlr.ret_val)); diff --git a/shared-module/adafruit_bus_device/I2CDevice.h b/shared-module/adafruit_bus_device/i2c_device/I2CDevice.h similarity index 100% rename from shared-module/adafruit_bus_device/I2CDevice.h rename to shared-module/adafruit_bus_device/i2c_device/I2CDevice.h diff --git a/shared-module/adafruit_bus_device/SPIDevice.c b/shared-module/adafruit_bus_device/spi_device/SPIDevice.c similarity index 98% rename from shared-module/adafruit_bus_device/SPIDevice.c rename to shared-module/adafruit_bus_device/spi_device/SPIDevice.c index 20e4e76297..2f4ab4dddf 100644 --- a/shared-module/adafruit_bus_device/SPIDevice.c +++ b/shared-module/adafruit_bus_device/spi_device/SPIDevice.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "shared-bindings/adafruit_bus_device/SPIDevice.h" +#include "shared-bindings/adafruit_bus_device/spi_device/SPIDevice.h" #include "shared-bindings/busio/SPI.h" #include "shared-bindings/digitalio/DigitalInOut.h" #include "py/mperrno.h" diff --git a/shared-module/adafruit_bus_device/SPIDevice.h b/shared-module/adafruit_bus_device/spi_device/SPIDevice.h similarity index 100% rename from shared-module/adafruit_bus_device/SPIDevice.h rename to shared-module/adafruit_bus_device/spi_device/SPIDevice.h diff --git a/shared-module/adafruit_pixelbuf/PixelBuf.c b/shared-module/adafruit_pixelbuf/PixelBuf.c index bfeab4ae04..99980c705e 100644 --- a/shared-module/adafruit_pixelbuf/PixelBuf.c +++ b/shared-module/adafruit_pixelbuf/PixelBuf.c @@ -163,7 +163,7 @@ STATIC void _pixelbuf_parse_color(pixelbuf_pixelbuf_obj_t *self, mp_obj_t color, } if (mp_obj_is_int(color) || mp_obj_is_float(color)) { - mp_int_t value = mp_obj_is_int(color) ? mp_obj_get_int_truncated(color) : mp_obj_get_float(color); + mp_int_t value = mp_obj_is_int(color) ? mp_obj_get_int_truncated(color) : (mp_int_t)mp_obj_get_float(color); *r = value >> 16 & 0xff; *g = (value >> 8) & 0xff; *b = value & 0xff; diff --git a/shared-module/audiomp3/MP3Decoder.c b/shared-module/audiomp3/MP3Decoder.c index 5e1bce5924..2d45313814 100644 --- a/shared-module/audiomp3/MP3Decoder.c +++ b/shared-module/audiomp3/MP3Decoder.c @@ -258,6 +258,7 @@ void common_hal_audiomp3_mp3file_set_file(audiomp3_mp3file_obj_t *self, pyb_file self->channel_count = fi.nChans; self->frame_buffer_size = fi.outputSamps * sizeof(int16_t); self->len = 2 * self->frame_buffer_size; + self->samples_decoded = 0; } void common_hal_audiomp3_mp3file_deinit(audiomp3_mp3file_obj_t *self) { @@ -267,6 +268,7 @@ void common_hal_audiomp3_mp3file_deinit(audiomp3_mp3file_obj_t *self) { self->buffers[0] = NULL; self->buffers[1] = NULL; self->file = NULL; + self->samples_decoded = 0; } bool common_hal_audiomp3_mp3file_deinited(audiomp3_mp3file_obj_t *self) { @@ -302,6 +304,7 @@ void audiomp3_mp3file_reset_buffer(audiomp3_mp3file_obj_t *self, f_lseek(&self->file->fp, 0); self->inbuf_offset = self->inbuf_length; self->eof = 0; + self->samples_decoded = 0; self->other_channel = -1; mp3file_update_inbuf_half(self); mp3file_skip_id3v2(self); @@ -327,6 +330,7 @@ audioio_get_buffer_result_t audiomp3_mp3file_get_buffer(audiomp3_mp3file_obj_t * if (channel == self->other_channel) { *bufptr = (uint8_t *)(self->buffers[self->other_buffer_index] + channel); self->other_channel = -1; + self->samples_decoded += *buffer_length / sizeof(int16_t); return GET_BUFFER_MORE_DATA; } @@ -359,6 +363,7 @@ audioio_get_buffer_result_t audiomp3_mp3file_get_buffer(audiomp3_mp3file_obj_t * self); } + self->samples_decoded += *buffer_length / sizeof(int16_t); return GET_BUFFER_MORE_DATA; } @@ -384,3 +389,7 @@ float common_hal_audiomp3_mp3file_get_rms_level(audiomp3_mp3file_obj_t *self) { } return sqrtf(sumsq) / (self->frame_buffer_size / sizeof(int16_t)); } + +uint32_t common_hal_audiomp3_mp3file_get_samples_decoded(audiomp3_mp3file_obj_t *self) { + return self->samples_decoded; +} diff --git a/shared-module/audiomp3/MP3Decoder.h b/shared-module/audiomp3/MP3Decoder.h index 0f2256a417..17616d4a28 100644 --- a/shared-module/audiomp3/MP3Decoder.h +++ b/shared-module/audiomp3/MP3Decoder.h @@ -54,6 +54,8 @@ typedef struct { int8_t other_channel; int8_t other_buffer_index; + + uint32_t samples_decoded; } audiomp3_mp3file_obj_t; // These are not available from Python because it may be called in an interrupt. @@ -71,4 +73,6 @@ void audiomp3_mp3file_get_buffer_structure(audiomp3_mp3file_obj_t *self, bool si float audiomp3_mp3file_get_rms_level(audiomp3_mp3file_obj_t *self); +uint32_t common_hal_audiomp3_mp3file_get_samples_decoded(audiomp3_mp3file_obj_t *self); + #endif // MICROPY_INCLUDED_SHARED_MODULE_AUDIOIO_MP3FILE_H diff --git a/shared-module/bitbangio/I2C.c b/shared-module/bitbangio/I2C.c index 7d7380e214..eb897e122f 100644 --- a/shared-module/bitbangio/I2C.c +++ b/shared-module/bitbangio/I2C.c @@ -49,9 +49,11 @@ STATIC void scl_release(bitbangio_i2c_obj_t *self) { uint32_t count = self->us_timeout; delay(self); // For clock stretching, wait for the SCL pin to be released, with timeout. + common_hal_digitalio_digitalinout_switch_to_input(&self->scl, PULL_UP); for (; !common_hal_digitalio_digitalinout_get_value(&self->scl) && count; --count) { common_hal_mcu_delay_us(1); } + common_hal_digitalio_digitalinout_switch_to_output(&self->scl, true, DRIVE_MODE_OPEN_DRAIN); // raise exception on timeout if (count == 0) { mp_raise_msg(&mp_type_TimeoutError, translate("Clock stretch too long")); diff --git a/shared-module/board/__init__.c b/shared-module/board/__init__.c index 19d9e7ece0..7bd0d42339 100644 --- a/shared-module/board/__init__.c +++ b/shared-module/board/__init__.c @@ -46,141 +46,200 @@ #include "shared-module/sharpdisplay/SharpMemoryFramebuffer.h" #endif -#if BOARD_I2C +#if CIRCUITPY_BOARD_I2C // Statically allocate the I2C object so it can live past the end of the heap and into the next VM. // That way it can be used by built-in I2CDisplay displays and be accessible through board.I2C(). -STATIC busio_i2c_obj_t i2c_obj; -STATIC mp_obj_t i2c_singleton = NULL; -mp_obj_t common_hal_board_get_i2c(void) { - return i2c_singleton; +typedef struct { + const mcu_pin_obj_t *scl; + const mcu_pin_obj_t *sda; +} board_i2c_pin_t; + +static const board_i2c_pin_t i2c_pin[CIRCUITPY_BOARD_I2C] = CIRCUITPY_BOARD_I2C_PIN; +static busio_i2c_obj_t i2c_obj[CIRCUITPY_BOARD_I2C]; +static bool i2c_obj_created[CIRCUITPY_BOARD_I2C]; + +bool common_hal_board_is_i2c(mp_obj_t obj) { + for (uint8_t instance = 0; instance < CIRCUITPY_BOARD_I2C; instance++) { + if (obj == &i2c_obj[instance]) { + return true; + } + } + return false; } -mp_obj_t common_hal_board_create_i2c(void) { - // All callers have either already verified this or come so early that it can't be otherwise. - assert(i2c_singleton == NULL || common_hal_busio_i2c_deinited(i2c_singleton)); - busio_i2c_obj_t *self = &i2c_obj; +mp_obj_t common_hal_board_get_i2c(const mp_int_t instance) { + return i2c_obj_created[instance] ? &i2c_obj[instance] : NULL; +} + +mp_obj_t common_hal_board_create_i2c(const mp_int_t instance) { + const mp_obj_t singleton = common_hal_board_get_i2c(instance); + if (singleton != NULL && !common_hal_busio_i2c_deinited(singleton)) { + return singleton; + } + + busio_i2c_obj_t *self = &i2c_obj[instance]; self->base.type = &busio_i2c_type; - common_hal_busio_i2c_construct(self, DEFAULT_I2C_BUS_SCL, DEFAULT_I2C_BUS_SDA, 100000, 255); - i2c_singleton = (mp_obj_t)self; - return i2c_singleton; + assert_pin_free(i2c_pin[instance].scl); + assert_pin_free(i2c_pin[instance].sda); + + common_hal_busio_i2c_construct(self, i2c_pin[instance].scl, i2c_pin[instance].sda, 100000, 255); + + i2c_obj_created[instance] = true; + return &i2c_obj[instance]; } #endif - -#if BOARD_SPI +#if CIRCUITPY_BOARD_SPI // Statically allocate the SPI object so it can live past the end of the heap and into the next VM. // That way it can be used by built-in FourWire displays and be accessible through board.SPI(). -STATIC busio_spi_obj_t spi_obj; -STATIC mp_obj_t spi_singleton = NULL; -mp_obj_t common_hal_board_get_spi(void) { - return spi_singleton; +typedef struct { + const mcu_pin_obj_t *clock; + const mcu_pin_obj_t *mosi; + const mcu_pin_obj_t *miso; +} board_spi_pin_t; + +static const board_spi_pin_t spi_pin[CIRCUITPY_BOARD_SPI] = CIRCUITPY_BOARD_SPI_PIN; +static busio_spi_obj_t spi_obj[CIRCUITPY_BOARD_SPI]; +static bool spi_obj_created[CIRCUITPY_BOARD_SPI]; + +bool common_hal_board_is_spi(mp_obj_t obj) { + for (uint8_t instance = 0; instance < CIRCUITPY_BOARD_SPI; instance++) { + if (obj == &spi_obj[instance]) { + return true; + } + } + return false; } -mp_obj_t common_hal_board_create_spi(void) { - // All callers have either already verified this or come so early that it can't be otherwise. - assert(spi_singleton == NULL || common_hal_busio_spi_deinited(spi_singleton)); - busio_spi_obj_t *self = &spi_obj; +mp_obj_t common_hal_board_get_spi(const mp_int_t instance) { + return spi_obj_created[instance] ? &spi_obj[instance] : NULL; +} + +mp_obj_t common_hal_board_create_spi(const mp_int_t instance) { + const mp_obj_t singleton = common_hal_board_get_spi(instance); + if (singleton != NULL && !common_hal_busio_spi_deinited(singleton)) { + return singleton; + } + + busio_spi_obj_t *self = &spi_obj[instance]; self->base.type = &busio_spi_type; - const mcu_pin_obj_t *clock = MP_OBJ_TO_PTR(DEFAULT_SPI_BUS_SCK); - const mcu_pin_obj_t *mosi = MP_OBJ_TO_PTR(DEFAULT_SPI_BUS_MOSI); - const mcu_pin_obj_t *miso = MP_OBJ_TO_PTR(DEFAULT_SPI_BUS_MISO); - common_hal_busio_spi_construct(self, clock, mosi, miso); - spi_singleton = (mp_obj_t)self; - return spi_singleton; + assert_pin_free(spi_pin[instance].clock); + assert_pin_free(spi_pin[instance].mosi); + assert_pin_free(spi_pin[instance].miso); + + common_hal_busio_spi_construct(self, spi_pin[instance].clock, spi_pin[instance].mosi, spi_pin[instance].miso, false); + + spi_obj_created[instance] = true; + return &spi_obj[instance]; } #endif -#if BOARD_UART -mp_obj_t common_hal_board_get_uart(void) { - return MP_STATE_VM(shared_uart_bus); +#if CIRCUITPY_BOARD_UART + +typedef struct { + const mcu_pin_obj_t *tx; + const mcu_pin_obj_t *rx; +} board_uart_pin_t; + +static const board_uart_pin_t uart_pin[CIRCUITPY_BOARD_UART] = CIRCUITPY_BOARD_UART_PIN; +static busio_uart_obj_t uart_obj[CIRCUITPY_BOARD_UART]; +static bool uart_obj_created[CIRCUITPY_BOARD_UART]; + +bool common_hal_board_is_uart(mp_obj_t obj) { + for (uint8_t instance = 0; instance < CIRCUITPY_BOARD_UART; instance++) { + if (obj == &uart_obj[instance]) { + return true; + } + } + return false; } -mp_obj_t common_hal_board_create_uart(void) { - busio_uart_obj_t *self = m_new_ll_obj(busio_uart_obj_t); +mp_obj_t common_hal_board_get_uart(const mp_int_t instance) { + return uart_obj_created[instance] ? &uart_obj[instance] : NULL; +} + +mp_obj_t common_hal_board_create_uart(const mp_int_t instance) { + const mp_obj_t singleton = common_hal_board_get_uart(instance); + if (singleton != NULL && !common_hal_busio_uart_deinited(singleton)) { + return singleton; + } + + busio_uart_obj_t *self = &uart_obj[instance]; self->base.type = &busio_uart_type; - const mcu_pin_obj_t *rx = MP_OBJ_TO_PTR(DEFAULT_UART_BUS_RX); - const mcu_pin_obj_t *tx = MP_OBJ_TO_PTR(DEFAULT_UART_BUS_TX); - #ifdef DEFAULT_UART_BUS_RTS - const mcu_pin_obj_t *rts = MP_OBJ_TO_PTR(DEFAULT_UART_BUS_RTS); - #else - const mcu_pin_obj_t *rts = NULL; - #endif - #ifdef DEFAULT_UART_BUS_CTS - const mcu_pin_obj_t *cts = MP_OBJ_TO_PTR(DEFAULT_UART_BUS_CTS); - #else - const mcu_pin_obj_t *cts = NULL; - #endif - #ifdef DEFAULT_UART_IS_RS485 - const mcu_pin_obj_t *rs485_dir = MP_OBJ_TO_PTR(DEFAULT_UART_BUS_RS485DIR); - #ifdef DEFAULT_UART_RS485_INVERT - const bool rs485_invert = true; - #else - const bool rs485_invert = false; - #endif - #else - const mcu_pin_obj_t *rs485_dir = NULL; - const bool rs485_invert = false; - #endif + MP_STATE_VM(board_uart_bus) = &uart_obj; - common_hal_busio_uart_construct(self, tx, rx, rts, cts, rs485_dir, rs485_invert, - 9600, 8, BUSIO_UART_PARITY_NONE, 1, 1.0f, 64, NULL, false); - MP_STATE_VM(shared_uart_bus) = MP_OBJ_FROM_PTR(self); - return MP_STATE_VM(shared_uart_bus); + assert_pin_free(uart_pin[instance].tx); + assert_pin_free(uart_pin[instance].rx); + + common_hal_busio_uart_construct(self, uart_pin[instance].tx, uart_pin[instance].rx, + NULL, NULL, NULL, false, 9600, 8, BUSIO_UART_PARITY_NONE, 1, 1.0f, 64, NULL, false); + + uart_obj_created[instance] = true; + return &uart_obj[instance]; } #endif -void reset_board_busses(void) { - #if BOARD_I2C - bool display_using_i2c = false; - #if CIRCUITPY_DISPLAYIO - for (uint8_t i = 0; i < CIRCUITPY_DISPLAY_LIMIT; i++) { - if (displays[i].bus_base.type == &displayio_i2cdisplay_type && displays[i].i2cdisplay_bus.bus == i2c_singleton) { - display_using_i2c = true; - break; - } - } - #endif - // make sure I2C lock is not held over a soft reset - if (i2c_singleton != NULL) { - common_hal_busio_i2c_unlock(i2c_singleton); - if (!display_using_i2c) { - common_hal_busio_i2c_deinit(i2c_singleton); - i2c_singleton = NULL; - } - } - #endif - #if BOARD_SPI - bool display_using_spi = false; - #if CIRCUITPY_DISPLAYIO - for (uint8_t i = 0; i < CIRCUITPY_DISPLAY_LIMIT; i++) { - mp_const_obj_t bus_type = displays[i].bus_base.type; - if (bus_type == &displayio_fourwire_type && displays[i].fourwire_bus.bus == spi_singleton) { - display_using_spi = true; - break; - } - #if CIRCUITPY_SHARPDISPLAY - if (displays[i].bus_base.type == &sharpdisplay_framebuffer_type && displays[i].sharpdisplay.bus == spi_singleton) { - display_using_spi = true; - break; +void reset_board_buses(void) { + #if CIRCUITPY_BOARD_I2C + for (uint8_t instance = 0; instance < CIRCUITPY_BOARD_I2C; instance++) { + bool display_using_i2c = false; + #if CIRCUITPY_DISPLAYIO + for (uint8_t i = 0; i < CIRCUITPY_DISPLAY_LIMIT; i++) { + if (displays[i].bus_base.type == &displayio_i2cdisplay_type && displays[i].i2cdisplay_bus.bus == &i2c_obj[instance]) { + display_using_i2c = true; + break; + } } #endif - } - #endif - // make sure SPI lock is not held over a soft reset - if (spi_singleton != NULL) { - common_hal_busio_spi_unlock(spi_singleton); - if (!display_using_spi) { - common_hal_busio_spi_deinit(spi_singleton); - spi_singleton = NULL; + if (i2c_obj_created[instance]) { + // make sure I2C lock is not held over a soft reset + common_hal_busio_i2c_unlock(&i2c_obj[instance]); + if (!display_using_i2c) { + common_hal_busio_i2c_deinit(&i2c_obj[instance]); + i2c_obj_created[instance] = false; + } } } #endif - #if BOARD_UART - MP_STATE_VM(shared_uart_bus) = NULL; + #if CIRCUITPY_BOARD_SPI + for (uint8_t instance = 0; instance < CIRCUITPY_BOARD_SPI; instance++) { + bool display_using_spi = false; + #if CIRCUITPY_DISPLAYIO + for (uint8_t i = 0; i < CIRCUITPY_DISPLAY_LIMIT; i++) { + mp_const_obj_t bus_type = displays[i].bus_base.type; + if (bus_type == &displayio_fourwire_type && displays[i].fourwire_bus.bus == &spi_obj[instance]) { + display_using_spi = true; + break; + } + #if CIRCUITPY_SHARPDISPLAY + if (displays[i].bus_base.type == &sharpdisplay_framebuffer_type && displays[i].sharpdisplay.bus == &spi_obj[instance]) { + display_using_spi = true; + break; + } + #endif + } + #endif + if (spi_obj_created[instance]) { + // make sure SPI lock is not held over a soft reset + common_hal_busio_spi_unlock(&spi_obj[instance]); + if (!display_using_spi) { + common_hal_busio_spi_deinit(&spi_obj[instance]); + spi_obj_created[instance] = false; + } + } + } + #endif + #if CIRCUITPY_BOARD_UART + for (uint8_t instance = 0; instance < CIRCUITPY_BOARD_UART; instance++) { + if (uart_obj_created[instance]) { + common_hal_busio_uart_deinit(&uart_obj[instance]); + uart_obj_created[instance] = false; + } + } #endif } diff --git a/shared-module/board/__init__.h b/shared-module/board/__init__.h index f7eecd4170..8b3723bdda 100644 --- a/shared-module/board/__init__.h +++ b/shared-module/board/__init__.h @@ -27,6 +27,6 @@ #ifndef MICROPY_INCLUDED_SHARED_MODULE_BOARD__INIT__H #define MICROPY_INCLUDED_SHARED_MODULE_BOARD__INIT__H -void reset_board_busses(void); +void reset_board_buses(void); #endif // MICROPY_INCLUDED_SHARED_MODULE_BOARD__INIT__H diff --git a/shared-module/busio/I2C.c b/shared-module/busio/I2C.c deleted file mode 100644 index d3db18e3ad..0000000000 --- a/shared-module/busio/I2C.c +++ /dev/null @@ -1,70 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#include "shared-bindings/busio/I2C.h" -#include "shared-bindings/bitbangio/I2C.h" -#include "py/mperrno.h" -#include "py/nlr.h" - -void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, - const mcu_pin_obj_t *scl, const mcu_pin_obj_t *sda, uint32_t freq, uint32_t timeout) { - shared_module_bitbangio_i2c_construct(&self->bitbang, scl, sda, freq, timeout); -} - -bool common_hal_busio_i2c_deinited(busio_i2c_obj_t *self) { - return shared_module_bitbangio_i2c_deinited(&self->bitbang); -} - -void common_hal_busio_i2c_deinit(busio_i2c_obj_t *self) { - shared_module_bitbangio_i2c_deinit(&self->bitbang); -} - -bool common_hal_busio_i2c_probe(busio_i2c_obj_t *self, uint8_t addr) { - return shared_module_bitbangio_i2c_probe(&self->bitbang, addr); -} - -bool common_hal_busio_i2c_try_lock(busio_i2c_obj_t *self) { - return shared_module_bitbangio_i2c_try_lock(&self->bitbang); -} - -bool common_hal_busio_i2c_has_lock(busio_i2c_obj_t *self) { - return shared_module_bitbangio_i2c_has_lock(&self->bitbang); -} - -void common_hal_busio_i2c_unlock(busio_i2c_obj_t *self) { - shared_module_bitbangio_i2c_unlock(&self->bitbang); -} - -uint8_t common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t addr, - const uint8_t *data, size_t len, bool transmit_stop_bit) { - return shared_module_bitbangio_i2c_write(&self->bitbang, addr, data, len, - transmit_stop_bit); -} - -uint8_t common_hal_busio_i2c_read(busio_i2c_obj_t *self, uint16_t addr, - uint8_t *data, size_t len) { - return shared_module_bitbangio_i2c_read(&self->bitbang, addr, data, len); -} diff --git a/shared-module/displayio/Display.c b/shared-module/displayio/Display.c index 4d41245b3b..579dca49fc 100644 --- a/shared-module/displayio/Display.c +++ b/shared-module/displayio/Display.c @@ -220,6 +220,10 @@ mp_obj_t common_hal_displayio_display_get_bus(displayio_display_obj_t *self) { return self->core.bus; } +mp_obj_t common_hal_displayio_display_get_root_group(displayio_display_obj_t *self) { + return self->core.current_group; +} + STATIC const displayio_area_t *_get_refresh_areas(displayio_display_obj_t *self) { if (self->core.full_refresh) { self->core.area.next = NULL; diff --git a/shared-module/displayio/EPaperDisplay.c b/shared-module/displayio/EPaperDisplay.c index d2190c1b42..b1e998048e 100644 --- a/shared-module/displayio/EPaperDisplay.c +++ b/shared-module/displayio/EPaperDisplay.c @@ -54,7 +54,7 @@ void common_hal_displayio_epaperdisplay_construct(displayio_epaperdisplay_obj_t uint16_t set_column_window_command, uint16_t set_row_window_command, uint16_t set_current_column_command, uint16_t set_current_row_command, uint16_t write_black_ram_command, bool black_bits_inverted, uint16_t write_color_ram_command, bool color_bits_inverted, uint32_t highlight_color, uint16_t refresh_display_command, mp_float_t refresh_time, - const mcu_pin_obj_t *busy_pin, bool busy_state, mp_float_t seconds_per_frame, bool chip_select, bool grayscale) { + const mcu_pin_obj_t *busy_pin, bool busy_state, mp_float_t seconds_per_frame, bool chip_select, bool grayscale, bool two_byte_sequence_length) { if (highlight_color != 0x000000) { self->core.colorspace.tricolor = true; self->core.colorspace.tricolor_hue = displayio_colorconverter_compute_hue(highlight_color); @@ -85,6 +85,7 @@ void common_hal_displayio_epaperdisplay_construct(displayio_epaperdisplay_obj_t self->stop_sequence_len = stop_sequence_len; self->busy.base.type = &mp_type_NoneType; + self->two_byte_sequence_length = two_byte_sequence_length; if (busy_pin != NULL) { self->busy.base.type = &digitalio_digitalinout_type; common_hal_digitalio_digitalinout_construct(&self->busy, busy_pin); @@ -145,8 +146,12 @@ STATIC void send_command_sequence(displayio_epaperdisplay_obj_t *self, const uint8_t *cmd = sequence + i; uint8_t data_size = *(cmd + 1); bool delay = (data_size & DELAY) != 0; - data_size &= ~DELAY; const uint8_t *data = cmd + 2; + data_size &= ~DELAY; + if (self->two_byte_sequence_length) { + data_size = ((data_size & ~DELAY) << 8) + *(cmd + 2); + data = cmd + 3; + } displayio_display_core_begin_transaction(&self->core); self->core.send(self->core.bus, DISPLAY_COMMAND, self->chip_select, cmd, 1); self->core.send(self->core.bus, DISPLAY_DATA, self->chip_select, data, data_size); @@ -164,6 +169,9 @@ STATIC void send_command_sequence(displayio_epaperdisplay_obj_t *self, wait_for_busy(self); } i += 2 + data_size; + if (self->two_byte_sequence_length) { + i++; + } } } diff --git a/shared-module/displayio/EPaperDisplay.h b/shared-module/displayio/EPaperDisplay.h index 65a4dd7743..55feaf964b 100644 --- a/shared-module/displayio/EPaperDisplay.h +++ b/shared-module/displayio/EPaperDisplay.h @@ -57,6 +57,7 @@ typedef struct { bool refreshing; bool grayscale; display_chip_select_behavior_t chip_select; + bool two_byte_sequence_length; } displayio_epaperdisplay_obj_t; void displayio_epaperdisplay_change_refresh_mode_parameters(displayio_epaperdisplay_obj_t *self, diff --git a/shared-module/displayio/I2CDisplay.c b/shared-module/displayio/I2CDisplay.c index 6446e3198f..8fae5d31fd 100644 --- a/shared-module/displayio/I2CDisplay.c +++ b/shared-module/displayio/I2CDisplay.c @@ -112,12 +112,12 @@ void common_hal_displayio_i2cdisplay_send(mp_obj_t obj, display_byte_type_t data command_bytes[2 * i] = 0x80; command_bytes[2 * i + 1] = data[i]; } - common_hal_busio_i2c_write(self->bus, self->address, command_bytes, 2 * data_length, true); + common_hal_busio_i2c_write(self->bus, self->address, command_bytes, 2 * data_length); } else { uint8_t data_bytes[data_length + 1]; data_bytes[0] = 0x40; memcpy(data_bytes + 1, data, data_length); - common_hal_busio_i2c_write(self->bus, self->address, data_bytes, data_length + 1, true); + common_hal_busio_i2c_write(self->bus, self->address, data_bytes, data_length + 1); } } diff --git a/shared-module/displayio/TileGrid.c b/shared-module/displayio/TileGrid.c index dbf2ce545b..fd0547c426 100644 --- a/shared-module/displayio/TileGrid.c +++ b/shared-module/displayio/TileGrid.c @@ -229,6 +229,14 @@ uint16_t common_hal_displayio_tilegrid_get_height(displayio_tilegrid_t *self) { return self->height_in_tiles; } +uint16_t common_hal_displayio_tilegrid_get_tile_width(displayio_tilegrid_t *self) { + return self->tile_width; +} + +uint16_t common_hal_displayio_tilegrid_get_tile_height(displayio_tilegrid_t *self) { + return self->tile_height; +} + uint8_t common_hal_displayio_tilegrid_get_tile(displayio_tilegrid_t *self, uint16_t x, uint16_t y) { uint8_t *tiles = self->tiles; if (self->inline_tiles) { diff --git a/shared-module/displayio/__init__.c b/shared-module/displayio/__init__.c index ff085d45ef..d026d9f766 100644 --- a/shared-module/displayio/__init__.c +++ b/shared-module/displayio/__init__.c @@ -24,7 +24,6 @@ * THE SOFTWARE. */ - #include #include "shared-module/displayio/__init__.h" @@ -143,8 +142,8 @@ void common_hal_displayio_release_displays(void) { common_hal_rgbmatrix_rgbmatrix_deinit(&displays[i].rgbmatrix); #endif #if CIRCUITPY_IS31FL3741 - } else if (bus_type == &is31fl3741_IS31FL3741_type) { - common_hal_is31fl3741_IS31FL3741_deinit(&displays[i].is31fl3741); + } else if (bus_type == &is31fl3741_FrameBuffer_type) { + common_hal_is31fl3741_FrameBuffer_deinit(&displays[i].is31fl3741); #endif #if CIRCUITPY_SHARPDISPLAY } else if (displays[i].bus_base.type == &sharpdisplay_framebuffer_type) { @@ -169,11 +168,11 @@ void reset_displays(void) { if (((size_t)fourwire->bus) < ((size_t)&displays) || ((size_t)fourwire->bus) > ((size_t)&displays + CIRCUITPY_DISPLAY_LIMIT)) { busio_spi_obj_t *original_spi = fourwire->bus; - #if BOARD_SPI - // We don't need to move original_spi if it is the board.SPI object because it is + #if CIRCUITPY_BOARD_SPI + // We don't need to move original_spi if it is a board.SPI object because it is // statically allocated already. (Doing so would also make it impossible to reference in // a subsequent VM run.) - if (original_spi == common_hal_board_get_spi()) { + if (common_hal_board_is_spi(original_spi)) { continue; } #endif @@ -197,11 +196,11 @@ void reset_displays(void) { if (((size_t)i2c->bus) < ((size_t)&displays) || ((size_t)i2c->bus) > ((size_t)&displays + CIRCUITPY_DISPLAY_LIMIT)) { busio_i2c_obj_t *original_i2c = i2c->bus; - #if BOARD_I2C - // We don't need to move original_i2c if it is the board.I2C object because it is + #if CIRCUITPY_BOARD_I2C + // We don't need to move original_i2c if it is a board.I2C object because it is // statically allocated already. (Doing so would also make it impossible to reference in // a subsequent VM run.) - if (original_i2c == common_hal_board_get_i2c()) { + if (common_hal_board_is_i2c(original_i2c)) { continue; } #endif @@ -225,34 +224,33 @@ void reset_displays(void) { } #endif #if CIRCUITPY_IS31FL3741 - } else if (displays[i].is31fl3741.base.type == &is31fl3741_IS31FL3741_type) { - is31fl3741_IS31FL3741_obj_t *is31 = &displays[i].is31fl3741; - if (((uint32_t)is31->i2c) < ((uint32_t)&displays) || - ((uint32_t)is31->i2c) > ((uint32_t)&displays + CIRCUITPY_DISPLAY_LIMIT)) { - busio_i2c_obj_t *original_i2c = is31->i2c; - #if BOARD_I2C + } else if (displays[i].is31fl3741.base.type == &is31fl3741_FrameBuffer_type) { + is31fl3741_FrameBuffer_obj_t *is31fb = &displays[i].is31fl3741; + + if (((uint32_t)is31fb->is31fl3741->i2c) < ((uint32_t)&displays) || + ((uint32_t)is31fb->is31fl3741->i2c) > ((uint32_t)&displays + CIRCUITPY_DISPLAY_LIMIT)) { + #if CIRCUITPY_BOARD_I2C // We don't need to move original_i2c if it is the board.I2C object because it is // statically allocated already. (Doing so would also make it impossible to reference in // a subsequent VM run.) - if (original_i2c == common_hal_board_get_i2c()) { + if (common_hal_board_is_i2c(is31fb->is31fl3741->i2c)) { continue; } #endif - memcpy(&is31->inline_i2c, original_i2c, sizeof(busio_i2c_obj_t)); - is31->i2c = &is31->inline_i2c; - // Check for other displays that use the same i2c bus and swap them too. - /*for (uint8_t j = i + 1; j < CIRCUITPY_DISPLAY_LIMIT; j++) { - if (displays[i].i2cdisplay_bus.base.type == &displayio_i2cdisplay_type && - displays[i].i2cdisplay_bus.bus == original_i2c) { - displays[i].i2cdisplay_bus.bus = &i2c->inline_bus; - } - }*/ + + is31fl3741_IS31FL3741_obj_t *original_is31 = is31fb->is31fl3741; + memcpy(&is31fb->inline_is31fl3741, original_is31, sizeof(is31fl3741_IS31FL3741_obj_t)); + is31fb->is31fl3741 = &is31fb->inline_is31fl3741; + + busio_i2c_obj_t *original_i2c = is31fb->is31fl3741->i2c; + memcpy(&is31fb->is31fl3741->inline_i2c, original_i2c, sizeof(busio_i2c_obj_t)); + is31fb->is31fl3741->i2c = &is31fb->is31fl3741->inline_i2c; } - if (!any_display_uses_this_framebuffer(&is31->base)) { - common_hal_is31fl3741_IS31FL3741_deinit(is31); + if (!any_display_uses_this_framebuffer(&is31fb->base)) { + common_hal_is31fl3741_FrameBuffer_deinit(is31fb); } else { - common_hal_is31fl3741_IS31FL3741_set_paused(is31, true); + common_hal_is31fl3741_FrameBuffer_set_paused(is31fb, true); } #endif #if CIRCUITPY_SHARPDISPLAY @@ -299,8 +297,8 @@ void displayio_gc_collect(void) { } #endif #if CIRCUITPY_IS31FL3741 - if (displays[i].is31fl3741.base.type == &is31fl3741_IS31FL3741_type) { - is31fl3741_IS31FL3741_collect_ptrs(&displays[i].is31fl3741); + if (displays[i].is31fl3741.base.type == &is31fl3741_FrameBuffer_type) { + is31fl3741_FrameBuffer_collect_ptrs(&displays[i].is31fl3741); } #endif #if CIRCUITPY_SHARPDISPLAY diff --git a/shared-module/displayio/__init__.h b/shared-module/displayio/__init__.h index b4133308eb..c1954b146c 100644 --- a/shared-module/displayio/__init__.h +++ b/shared-module/displayio/__init__.h @@ -42,7 +42,7 @@ #include "shared-bindings/rgbmatrix/RGBMatrix.h" #endif #if CIRCUITPY_IS31FL3741 -#include "shared-bindings/is31fl3741/IS31FL3741.h" +#include "shared-bindings/is31fl3741/FrameBuffer.h" #endif #if CIRCUITPY_SHARPDISPLAY #include "shared-module/sharpdisplay/SharpMemoryFramebuffer.h" @@ -63,7 +63,7 @@ typedef struct { rgbmatrix_rgbmatrix_obj_t rgbmatrix; #endif #if CIRCUITPY_IS31FL3741 - is31fl3741_IS31FL3741_obj_t is31fl3741; + is31fl3741_FrameBuffer_obj_t is31fl3741; #endif #if CIRCUITPY_SHARPDISPLAY sharpdisplay_framebuffer_obj_t sharpdisplay; diff --git a/shared-module/displayio/display_core.c b/shared-module/displayio/display_core.c index 114b274fd1..8b2f0bfdf8 100644 --- a/shared-module/displayio/display_core.c +++ b/shared-module/displayio/display_core.c @@ -163,12 +163,16 @@ void displayio_display_core_set_rotation(displayio_display_core_t *self, } bool displayio_display_core_show(displayio_display_core_t *self, displayio_group_t *root_group) { - if (root_group == NULL) { - if (!circuitpython_splash.in_group) { - root_group = &circuitpython_splash; - } else if (self->current_group == &circuitpython_splash) { - return true; - } + + if (root_group == NULL) { // set the display to the REPL, reset REPL position and size + circuitpython_splash.in_group = false; + // force the circuit_python_splash out of any group (Note: could cause problems with the parent group) + circuitpython_splash.x = 0; // reset position in case someone moved it. + circuitpython_splash.y = 0; + + supervisor_start_terminal(self->width, self->height); + + root_group = &circuitpython_splash; } if (root_group == self->current_group) { return true; diff --git a/shared-module/is31fl3741/FrameBuffer.c b/shared-module/is31fl3741/FrameBuffer.c new file mode 100644 index 0000000000..ebe630cacd --- /dev/null +++ b/shared-module/is31fl3741/FrameBuffer.c @@ -0,0 +1,227 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Mark Komus + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include + +#include "py/gc.h" +#include "py/obj.h" +#include "py/objarray.h" +#include "py/objproperty.h" +#include "py/runtime.h" + +#include "shared-module/is31fl3741/allocator.h" +#include "shared-bindings/is31fl3741/IS31FL3741.h" +#include "shared-bindings/is31fl3741/FrameBuffer.h" +#include "shared-bindings/util.h" +#include "shared-module/framebufferio/FramebufferDisplay.h" +#include "shared-bindings/busio/I2C.h" + +void common_hal_is31fl3741_FrameBuffer_construct(is31fl3741_FrameBuffer_obj_t *self, int width, int height, mp_obj_t framebuffer, is31fl3741_IS31FL3741_obj_t *is31, mp_obj_t mapping) { + self->width = width; + self->height = height; + + self->bufsize = sizeof(uint32_t) * width * height; + + self->is31fl3741 = is31; + + common_hal_busio_i2c_never_reset(self->is31fl3741->i2c); + // Our object is statically allocated off the heap so make sure the bus object lives to the end + // of the heap as well. + gc_never_free(self->is31fl3741->i2c); + gc_never_free(self->is31fl3741); + + mp_obj_t *items; + size_t len; + mp_obj_tuple_get(mapping, &len, &items); + + if (len != (size_t)(self->scale_width * self->scale_height * 3)) { + mp_raise_ValueError(translate("LED mappings must match display size")); + } + + self->mapping = common_hal_is31fl3741_allocator_impl(sizeof(uint16_t) * len); + for (size_t i = 0; i < len; i++) { + mp_int_t value = mp_obj_get_int(items[i]); + // We only store up to 16 bits + if (value > 0xFFFF) { + value = 0xFFFF; + } + self->mapping[i] = (uint16_t)value; + } + + common_hal_is31fl3741_FrameBuffer_reconstruct(self, framebuffer); +} + +void common_hal_is31fl3741_FrameBuffer_reconstruct(is31fl3741_FrameBuffer_obj_t *self, mp_obj_t framebuffer) { + self->paused = 1; + + if (framebuffer) { + self->framebuffer = framebuffer; + mp_get_buffer_raise(self->framebuffer, &self->bufinfo, MP_BUFFER_READ); + if (mp_get_buffer(self->framebuffer, &self->bufinfo, MP_BUFFER_RW)) { + self->bufinfo.typecode = 'H' | MP_OBJ_ARRAY_TYPECODE_FLAG_RW; + } else { + self->bufinfo.typecode = 'H'; + } + + // verify that the matrix is big enough + mp_get_index(mp_obj_get_type(self->framebuffer), self->bufinfo.len, MP_OBJ_NEW_SMALL_INT(self->bufsize - 1), false); + } else { + common_hal_is31fl3741_free_impl(self->bufinfo.buf); + + self->framebuffer = NULL; + self->bufinfo.buf = common_hal_is31fl3741_allocator_impl(self->bufsize); + self->bufinfo.len = self->bufsize; + self->bufinfo.typecode = 'H' | MP_OBJ_ARRAY_TYPECODE_FLAG_RW; + } + + common_hal_is31fl3741_begin_transaction(self->is31fl3741); + common_hal_is31fl3741_send_reset(self->is31fl3741); + common_hal_is31fl3741_set_current(self->is31fl3741, 0xFE); + + // set scale (brightness) to max for all LEDs + for (int i = 0; i < 351; i++) { + common_hal_is31fl3741_set_led(self->is31fl3741, i, 0xFF, 2); + } + + common_hal_is31fl3741_send_enable(self->is31fl3741); + common_hal_is31fl3741_end_transaction(self->is31fl3741); + + self->paused = 0; +} + +void common_hal_is31fl3741_FrameBuffer_deinit(is31fl3741_FrameBuffer_obj_t *self) { + common_hal_is31fl3741_end_transaction(self->is31fl3741); // in case we still had a lock + + common_hal_is31fl3741_IS31FL3741_deinit(self->is31fl3741); + + if (self->mapping != 0) { + common_hal_is31fl3741_free_impl(self->mapping); + self->mapping = 0; + } + + self->base.type = NULL; + + // If a framebuffer was passed in to the constructor, NULL the reference + // here so that it will become GC'able + self->framebuffer = NULL; +} + +void common_hal_is31fl3741_FrameBuffer_set_paused(is31fl3741_FrameBuffer_obj_t *self, bool paused) { + self->paused = paused; +} + +bool common_hal_is31fl3741_FrameBuffer_get_paused(is31fl3741_FrameBuffer_obj_t *self) { + return self->paused; +} + +void common_hal_is31fl3741_FrameBuffer_refresh(is31fl3741_FrameBuffer_obj_t *self, uint8_t *dirtyrows) { + if (!self->paused) { + common_hal_is31fl3741_begin_transaction(self->is31fl3741); + + uint8_t dirty_row_flags = 0xFF; // only supports 8 rows gotta fix + + if (self->scale) { + // Based on the Arduino IS31FL3741 driver code + // dirtyrows flag current not implemented for scaled displays + uint32_t *buffer = self->bufinfo.buf; + + for (int x = 0; x < self->scale_width; x++) { + uint32_t *ptr = &buffer[x * 3]; // Entry along top scan line w/x offset + for (int y = 0; y < self->scale_height; y++) { + uint16_t rsum = 0, gsum = 0, bsum = 0; + // Inner x/y loops are row-major on purpose (less pointer math) + for (uint8_t yy = 0; yy < 3; yy++) { + for (uint8_t xx = 0; xx < 3; xx++) { + uint32_t rgb = ptr[xx]; + rsum += rgb >> 16 & 0xFF; + gsum += (rgb >> 8) & 0xFF; + bsum += rgb & 0xFF; + } + ptr += self->width; // Advance one scan line + } + rsum = rsum / 9; + gsum = gsum / 9; + bsum = bsum / 9; + uint32_t color = 0; + if (self->auto_gamma) { + color = (IS31GammaTable[rsum] << 16) + + (IS31GammaTable[gsum] << 8) + + IS31GammaTable[bsum]; + } else { + color = (rsum << 16) + (gsum << 8) + bsum; + } + common_hal_is31fl3741_draw_pixel(self->is31fl3741, x, y, color, self->mapping); + } + } + } else { + uint32_t *buffer = self->bufinfo.buf; + for (int y = 0; y < self->height; y++) { + if ((dirtyrows != 0) && ((y % 8) == 0)) { + dirty_row_flags = *dirtyrows++; + } + + if ((dirty_row_flags >> (y % 8)) & 0x1) { + uint32_t color = 0; + if (self->auto_gamma) { + color = IS31GammaTable[((*buffer) >> 16 & 0xFF)] + + IS31GammaTable[((*buffer) >> 8 & 0xFF)] + + IS31GammaTable[((*buffer) & 0xFF)]; + } else { + color = *buffer; + } + + for (int x = 0; x < self->width; x++) { + common_hal_is31fl3741_draw_pixel(self->is31fl3741, x, y, color, self->mapping); + buffer++; + } + } + } + } + common_hal_is31fl3741_end_transaction(self->is31fl3741); + } +} + +int common_hal_is31fl3741_FrameBuffer_get_width(is31fl3741_FrameBuffer_obj_t *self) { + return self->width; +} + +int common_hal_is31fl3741_FrameBuffer_get_height(is31fl3741_FrameBuffer_obj_t *self) { + return self->height; +} + +void *common_hal_is31fl3741_allocator_impl(size_t sz) { + supervisor_allocation *allocation = allocate_memory(align32_size(sz), false, true); + return allocation ? allocation->ptr : NULL; +} + +void common_hal_is31fl3741_free_impl(void *ptr_in) { + free_memory(allocation_from_ptr(ptr_in)); +} + +void is31fl3741_FrameBuffer_collect_ptrs(is31fl3741_FrameBuffer_obj_t *self) { + gc_collect_ptr(self->framebuffer); + gc_collect_ptr(self->mapping); +} diff --git a/shared-module/is31fl3741/FrameBuffer.h b/shared-module/is31fl3741/FrameBuffer.h new file mode 100644 index 0000000000..6d0258ce40 --- /dev/null +++ b/shared-module/is31fl3741/FrameBuffer.h @@ -0,0 +1,46 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Mark Komus + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#pragma once + +#include "py/obj.h" +#include "lib/protomatter/src/core.h" +#include "shared-module/is31fl3741/IS31FL3741.h" + +extern const mp_obj_type_t is31fl3741_FrameBuffer_type; +typedef struct { + mp_obj_base_t base; + is31fl3741_IS31FL3741_obj_t *is31fl3741; + is31fl3741_IS31FL3741_obj_t inline_is31fl3741; + mp_obj_t framebuffer; + mp_buffer_info_t bufinfo; + uint16_t bufsize, width, height, scale_width, scale_height; + uint16_t *mapping; + uint8_t bit_depth; + bool paused; + bool scale; + bool auto_gamma; +} is31fl3741_FrameBuffer_obj_t; diff --git a/shared-module/is31fl3741/IS31FL3741.c b/shared-module/is31fl3741/IS31FL3741.c index 9d7316e1cd..bb92b5b32c 100644 --- a/shared-module/is31fl3741/IS31FL3741.c +++ b/shared-module/is31fl3741/IS31FL3741.c @@ -32,20 +32,11 @@ #include "py/objproperty.h" #include "py/runtime.h" -#include "shared-module/is31fl3741/allocator.h" #include "shared-bindings/is31fl3741/IS31FL3741.h" -#include "shared-bindings/microcontroller/Pin.h" -#include "shared-bindings/microcontroller/__init__.h" #include "shared-bindings/util.h" -#include "shared-module/framebufferio/FramebufferDisplay.h" #include "shared-bindings/busio/I2C.h" -void common_hal_is31fl3741_IS31FL3741_construct(is31fl3741_IS31FL3741_obj_t *self, int width, int height, mp_obj_t framebuffer, busio_i2c_obj_t *i2c, uint8_t addr, mp_obj_t mapping) { - self->width = width; - self->height = height; - - self->bufsize = sizeof(uint32_t) * width * height; - +void common_hal_is31fl3741_IS31FL3741_construct(is31fl3741_IS31FL3741_obj_t *self, busio_i2c_obj_t *i2c, uint8_t addr) { // Probe the bus to see if a device acknowledges the given address. if (!common_hal_busio_i2c_probe(i2c, addr)) { self->base.type = &mp_type_NoneType; @@ -54,193 +45,35 @@ void common_hal_is31fl3741_IS31FL3741_construct(is31fl3741_IS31FL3741_obj_t *sel self->i2c = i2c; self->device_address = addr; - common_hal_busio_i2c_never_reset(self->i2c); - // Our object is statically allocated off the heap so make sure the bus object lives to the end - // of the heap as well. - gc_never_free(self->i2c); - - mp_obj_t *items; - size_t len; - mp_obj_list_get(mapping, &len, &items); - - if (len != (size_t)(self->scale_width * self->scale_height * 3)) { - mp_raise_ValueError(translate("LED mappings must match display size")); - } - - self->mapping = common_hal_is31fl3741_allocator_impl(sizeof(uint16_t) * len); - for (size_t i = 0; i < len; i++) { - mp_int_t value = mp_obj_get_int(items[i]); - // We only store up to 16 bits - if (value > 0xFFFF) { - value = 0xFFFF; - } - self->mapping[i] = (uint16_t)value; - } - - common_hal_is31fl3741_IS31FL3741_reconstruct(self, framebuffer); -} - -void common_hal_is31fl3741_IS31FL3741_reconstruct(is31fl3741_IS31FL3741_obj_t *self, mp_obj_t framebuffer) { - self->paused = 1; - - if (framebuffer) { - self->framebuffer = framebuffer; - mp_get_buffer_raise(self->framebuffer, &self->bufinfo, MP_BUFFER_READ); - if (mp_get_buffer(self->framebuffer, &self->bufinfo, MP_BUFFER_RW)) { - self->bufinfo.typecode = 'H' | MP_OBJ_ARRAY_TYPECODE_FLAG_RW; - } else { - self->bufinfo.typecode = 'H'; - } - - // verify that the matrix is big enough - mp_get_index(mp_obj_get_type(self->framebuffer), self->bufinfo.len, MP_OBJ_NEW_SMALL_INT(self->bufsize - 1), false); - } else { - common_hal_is31fl3741_free_impl(self->bufinfo.buf); - - self->framebuffer = NULL; - self->bufinfo.buf = common_hal_is31fl3741_allocator_impl(self->bufsize); - self->bufinfo.len = self->bufsize; - self->bufinfo.typecode = 'H' | MP_OBJ_ARRAY_TYPECODE_FLAG_RW; - } - - common_hal_displayio_is31fl3741_begin_transaction(self); - - uint8_t command = 0xFC; // device ID - common_hal_busio_i2c_write(self->i2c, self->device_address, &command, 1, false); - uint8_t data = 0; - common_hal_busio_i2c_read(self->i2c, self->device_address, &data, 1); - - is31fl3741_send_reset(self->i2c, self->device_address); - is31fl3741_send_enable(self->i2c, self->device_address); - is31fl3741_set_current(self->i2c, self->device_address, 0xFF); - - // set scale (brightness) to max for all LEDs - for (int i; i < 351; i++) { - is31fl3741_set_led(self->i2c, self->device_address, i, 0xFF, 2); - } - - common_hal_displayio_is31fl3741_end_transaction(self); - - self->paused = 0; } void common_hal_is31fl3741_IS31FL3741_deinit(is31fl3741_IS31FL3741_obj_t *self) { - common_hal_displayio_is31fl3741_end_transaction(self); // in case we still had a lock + common_hal_is31fl3741_end_transaction(self); // in case we still had a lock if (self->i2c == &self->inline_i2c) { common_hal_busio_i2c_deinit(self->i2c); self->i2c = NULL; } - if (self->mapping != 0) { - common_hal_is31fl3741_free_impl(self->mapping); - self->mapping = 0; - } - self->base.type = NULL; - - // If a framebuffer was passed in to the constructor, NULL the reference - // here so that it will become GC'able - self->framebuffer = NULL; } -void common_hal_is31fl3741_IS31FL3741_set_paused(is31fl3741_IS31FL3741_obj_t *self, bool paused) { - self->paused = paused; -} +void common_hal_is31fl3741_write(is31fl3741_IS31FL3741_obj_t *is31, const mp_obj_t *mapping, const uint8_t *pixels, size_t numBytes) { + common_hal_is31fl3741_begin_transaction(is31); -bool common_hal_is31fl3741_IS31FL3741_get_paused(is31fl3741_IS31FL3741_obj_t *self) { - return self->paused; -} - -void common_hal_is31fl3741_IS31FL3741_set_global_current(is31fl3741_IS31FL3741_obj_t *self, uint8_t current) { - common_hal_displayio_is31fl3741_begin_transaction(self); - is31fl3741_set_current(self->i2c, self->device_address, current); - common_hal_displayio_is31fl3741_end_transaction(self); -} - -uint8_t common_hal_is31fl3741_IS31FL3741_get_global_current(is31fl3741_IS31FL3741_obj_t *self) { - common_hal_displayio_is31fl3741_begin_transaction(self); - uint8_t current = is31fl3741_get_current(self->i2c, self->device_address); - common_hal_displayio_is31fl3741_end_transaction(self); - return current; -} - -void common_hal_is31fl3741_IS31FL3741_refresh(is31fl3741_IS31FL3741_obj_t *self, uint8_t *dirtyrows) { - common_hal_displayio_is31fl3741_begin_transaction(self); - if (!self->paused) { - uint8_t dirty_row_flags = 0xFF; // only supports 8 rows gotta fix - - if (self->scale) { - // Based on the Arduino IS31FL3741 driver code - // dirtyrows flag current not implemented for scaled displays - uint32_t *buffer = self->bufinfo.buf; - - for (int x = 0; x < self->scale_width; x++) { - uint32_t *ptr = &buffer[x * 3]; // Entry along top scan line w/x offset - for (int y = 0; y < self->scale_height; y++) { - uint16_t rsum = 0, gsum = 0, bsum = 0; - // Inner x/y loops are row-major on purpose (less pointer math) - for (uint8_t yy = 0; yy < 3; yy++) { - for (uint8_t xx = 0; xx < 3; xx++) { - uint32_t rgb = ptr[xx]; - rsum += rgb >> 16 & 0xFF; - gsum += (rgb >> 8) & 0xFF; - bsum += rgb & 0xFF; - } - ptr += self->width; // Advance one scan line - } - rsum = rsum / 9; - gsum = gsum / 9; - bsum = bsum / 9; - uint32_t color = 0; - if (self->auto_gamma) { - color = (IS31GammaTable[rsum] << 16) + - (IS31GammaTable[gsum] << 8) + - IS31GammaTable[bsum]; - } else { - color = (rsum << 16) + (gsum << 8) + bsum; - } - is31fl3741_draw_pixel(self->i2c, self->device_address, x, y, color, self->mapping); - } - } - } else { - uint32_t *buffer = self->bufinfo.buf; - for (int y = 0; y < self->height; y++) { - if ((dirtyrows != 0) && ((y % 8) == 0)) { - dirty_row_flags = *dirtyrows++; - } - - if ((dirty_row_flags >> (y % 8)) & 0x1) { - uint32_t color = 0; - if (self->auto_gamma) { - color = IS31GammaTable[((*buffer) >> 16 & 0xFF)] + - IS31GammaTable[((*buffer) >> 8 & 0xFF)] + - IS31GammaTable[((*buffer) & 0xFF)]; - } else { - color = *buffer; - } - - for (int x = 0; x < self->width; x++) { - is31fl3741_draw_pixel(self->i2c, self->device_address, x, y, color, self->mapping); - buffer++; - } - } - } + for (size_t i = 0; i < numBytes; i += 3) { + uint16_t ridx = mp_obj_get_int(mapping[i]); + if (ridx != 65535) { + common_hal_is31fl3741_set_led(is31, ridx, IS31GammaTable[pixels[i]], 0); // red + common_hal_is31fl3741_set_led(is31, mp_obj_get_int(mapping[i + 1]), IS31GammaTable[pixels[i + 1]], 0); // green + common_hal_is31fl3741_set_led(is31, mp_obj_get_int(mapping[i + 2]), IS31GammaTable[pixels[i + 2]], 0); // blue } } - common_hal_displayio_is31fl3741_end_transaction(self); + common_hal_is31fl3741_end_transaction(is31); } -int common_hal_is31fl3741_IS31FL3741_get_width(is31fl3741_IS31FL3741_obj_t *self) { - return self->width; -} - -int common_hal_is31fl3741_IS31FL3741_get_height(is31fl3741_IS31FL3741_obj_t *self) { - return self->height; -} - -void common_hal_displayio_is31fl3741_begin_transaction(is31fl3741_IS31FL3741_obj_t *self) { +void common_hal_is31fl3741_begin_transaction(is31fl3741_IS31FL3741_obj_t *self) { while (!common_hal_busio_i2c_try_lock(self->i2c)) { RUN_BACKGROUND_TASKS; if (mp_hal_is_interrupted()) { @@ -249,94 +82,73 @@ void common_hal_displayio_is31fl3741_begin_transaction(is31fl3741_IS31FL3741_obj } } -void common_hal_displayio_is31fl3741_end_transaction(is31fl3741_IS31FL3741_obj_t *self) { +void common_hal_is31fl3741_end_transaction(is31fl3741_IS31FL3741_obj_t *self) { common_hal_busio_i2c_unlock(self->i2c); } -void *common_hal_is31fl3741_allocator_impl(size_t sz) { - supervisor_allocation *allocation = allocate_memory(align32_size(sz), false, true); - return allocation ? allocation->ptr : NULL; -} +uint8_t is31fl3741_cur_page = 99; // set to invalid page to start -void common_hal_is31fl3741_free_impl(void *ptr_in) { - free_memory(allocation_from_ptr(ptr_in)); -} - -void is31fl3741_IS31FL3741_collect_ptrs(is31fl3741_IS31FL3741_obj_t *self) { - gc_collect_ptr(self->framebuffer); - gc_collect_ptr(self->mapping); -} - -// The following are routines to manipulate the IS31FL3741 chip -// They are not meant to be called by user code but only used -// internally. - -uint8_t cur_page = 99; // set to invalid page to start - -void is31fl3741_send_unlock(busio_i2c_obj_t *i2c, uint8_t addr) { +void common_hal_is31fl3741_send_unlock(is31fl3741_IS31FL3741_obj_t *self) { uint8_t unlock[2] = { 0xFE, 0xC5 }; // unlock command - common_hal_busio_i2c_write(i2c, addr, unlock, 2, true); + common_hal_busio_i2c_write(self->i2c, self->device_address, unlock, 2); } -void is31fl3741_set_page(busio_i2c_obj_t *i2c, uint8_t addr, uint8_t p) { - if (p == cur_page) { +void common_hal_is31fl3741_set_page(is31fl3741_IS31FL3741_obj_t *self, uint8_t p) { + if (p == is31fl3741_cur_page) { return; } - cur_page = p; - is31fl3741_send_unlock(i2c, addr); + is31fl3741_cur_page = p; + common_hal_is31fl3741_send_unlock(self); uint8_t page[2] = { 0xFD, 0x00 }; // page command page[1] = p; - common_hal_busio_i2c_write(i2c, addr, page, 2, true); + common_hal_busio_i2c_write(self->i2c, self->device_address, page, 2); } -void is31fl3741_send_enable(busio_i2c_obj_t *i2c, uint8_t addr) { - is31fl3741_set_page(i2c, addr, 4); +void common_hal_is31fl3741_send_enable(is31fl3741_IS31FL3741_obj_t *self) { + common_hal_is31fl3741_set_page(self, 4); uint8_t enable[2] = { 0x00, 0x01 }; // enable command - common_hal_busio_i2c_write(i2c, addr, enable, 2, true); + common_hal_busio_i2c_write(self->i2c, self->device_address, enable, 2); } -void is31fl3741_send_reset(busio_i2c_obj_t *i2c, uint8_t addr) { - is31fl3741_set_page(i2c, addr, 4); +void common_hal_is31fl3741_send_reset(is31fl3741_IS31FL3741_obj_t *self) { + common_hal_is31fl3741_set_page(self, 4); uint8_t rst[2] = { 0x3F, 0xAE }; // reset command - common_hal_busio_i2c_write(i2c, addr, rst, 2, true); + common_hal_busio_i2c_write(self->i2c, self->device_address, rst, 2); } -void is31fl3741_set_current(busio_i2c_obj_t *i2c, uint8_t addr, uint8_t current) { - is31fl3741_set_page(i2c, addr, 4); +void common_hal_is31fl3741_set_current(is31fl3741_IS31FL3741_obj_t *self, uint8_t current) { + common_hal_is31fl3741_set_page(self, 4); uint8_t gcur[2] = { 0x01, 0x00 }; // global current command gcur[1] = current; - common_hal_busio_i2c_write(i2c, addr, gcur, 2, true); + common_hal_busio_i2c_write(self->i2c, self->device_address, gcur, 2); } -uint8_t is31fl3741_get_current(busio_i2c_obj_t *i2c, uint8_t addr) { - is31fl3741_set_page(i2c, addr, 4); +uint8_t common_hal_is31fl3741_get_current(is31fl3741_IS31FL3741_obj_t *self) { + common_hal_is31fl3741_set_page(self, 4); uint8_t gcur = 0x01; // global current command - common_hal_busio_i2c_write(i2c, addr, &gcur, 1, true); - - uint8_t data = 0; - common_hal_busio_i2c_read(i2c, addr, &data, 1); - return data; + common_hal_busio_i2c_write_read(self->i2c, self->device_address, &gcur, 1, &gcur, 1); + return gcur; } -void is31fl3741_set_led(busio_i2c_obj_t *i2c, uint8_t addr, uint16_t led, uint8_t level, uint8_t page) { +void common_hal_is31fl3741_set_led(is31fl3741_IS31FL3741_obj_t *self, uint16_t led, uint8_t level, uint8_t page) { uint8_t cmd[2] = { 0x00, 0x00 }; if (led < 180) { - is31fl3741_set_page(i2c, addr, page); + common_hal_is31fl3741_set_page(self, page); cmd[0] = (uint8_t)led; } else { - is31fl3741_set_page(i2c, addr, page + 1); + common_hal_is31fl3741_set_page(self, page + 1); cmd[0] = (uint8_t)(led - 180); } cmd[1] = level; - common_hal_busio_i2c_write(i2c, addr, cmd, 2, true); + common_hal_busio_i2c_write(self->i2c, self->device_address, cmd, 2); } -void is31fl3741_draw_pixel(busio_i2c_obj_t *i2c, uint8_t addr, int16_t x, int16_t y, uint32_t color, uint16_t *mapping) { +void common_hal_is31fl3741_draw_pixel(is31fl3741_IS31FL3741_obj_t *self, int16_t x, int16_t y, uint32_t color, uint16_t *mapping) { uint8_t r = color >> 16 & 0xFF; uint8_t g = color >> 8 & 0xFF; uint8_t b = color & 0xFF; @@ -346,8 +158,8 @@ void is31fl3741_draw_pixel(busio_i2c_obj_t *i2c, uint8_t addr, int16_t x, int16_ if (ridx != 65535) { uint16_t gidx = mapping[x1 + 1]; uint16_t bidx = mapping[x1 + 0]; - is31fl3741_set_led(i2c, addr, ridx, r, 0); - is31fl3741_set_led(i2c, addr, gidx, g, 0); - is31fl3741_set_led(i2c, addr, bidx, b, 0); + common_hal_is31fl3741_set_led(self, ridx, r, 0); + common_hal_is31fl3741_set_led(self, gidx, g, 0); + common_hal_is31fl3741_set_led(self, bidx, b, 0); } } diff --git a/shared-module/is31fl3741/IS31FL3741.h b/shared-module/is31fl3741/IS31FL3741.h index c2ccfde849..03f1902c47 100644 --- a/shared-module/is31fl3741/IS31FL3741.h +++ b/shared-module/is31fl3741/IS31FL3741.h @@ -33,17 +33,9 @@ extern const mp_obj_type_t is31fl3741_is31fl3741_type; typedef struct { mp_obj_base_t base; - mp_obj_t framebuffer; - mp_buffer_info_t bufinfo; - uint16_t bufsize, width, height, scale_width, scale_height; busio_i2c_obj_t *i2c; busio_i2c_obj_t inline_i2c; uint8_t device_address; - uint16_t *mapping; - uint8_t bit_depth; - bool paused; - bool scale; - bool auto_gamma; } is31fl3741_IS31FL3741_obj_t; // Gamma correction table diff --git a/shared-module/is31fl3741/__init__.c b/shared-module/is31fl3741/__init__.c index e69de29bb2..c267047eda 100644 --- a/shared-module/is31fl3741/__init__.c +++ b/shared-module/is31fl3741/__init__.c @@ -0,0 +1,25 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Mark Komus + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ diff --git a/shared-module/msgpack/__init__.c b/shared-module/msgpack/__init__.c index 7a6892c51f..e1b98a9f93 100644 --- a/shared-module/msgpack/__init__.c +++ b/shared-module/msgpack/__init__.c @@ -497,6 +497,6 @@ void common_hal_msgpack_pack(mp_obj_t obj, mp_obj_t stream_obj, mp_obj_t default } mp_obj_t common_hal_msgpack_unpack(mp_obj_t stream_obj, mp_obj_t ext_hook, bool use_list) { - msgpack_stream_t stream = get_stream(stream_obj, MP_STREAM_OP_WRITE); + msgpack_stream_t stream = get_stream(stream_obj, MP_STREAM_OP_READ); return unpack(&stream, ext_hook, use_list); } diff --git a/shared-module/rainbowio/__init__.c b/shared-module/rainbowio/__init__.c index a6a2e4974e..b1745c362b 100644 --- a/shared-module/rainbowio/__init__.c +++ b/shared-module/rainbowio/__init__.c @@ -42,5 +42,6 @@ int32_t colorwheel(mp_float_t pos) { shift2 = 0; } int p = (int)(pos * 3); + p = (p < 256) ? p : 255; return (p << shift1) | ((255 - p) << shift2); } diff --git a/shared-module/sdcardio/SDCard.c b/shared-module/sdcardio/SDCard.c index 9eb32d9265..182eb0eed9 100644 --- a/shared-module/sdcardio/SDCard.c +++ b/shared-module/sdcardio/SDCard.c @@ -230,11 +230,18 @@ STATIC const compressed_string_t *init_card(sdcardio_sdcard_obj_t *self) { common_hal_digitalio_digitalinout_set_value(&self->cs, false); + assert(!self->in_cmd25); + self->in_cmd25 = false; // should be false already + // CMD0: init card: should return _R1_IDLE_STATE (allow 5 attempts) { bool reached_idle_state = false; for (int i = 0; i < 5; i++) { - if (cmd(self, 0, 0, NULL, 0, true, true) == R1_IDLE_STATE) { + // do not call cmd with wait=true, because that will return + // prematurely if the idle state is not reached. we can't depend on + // this when the card is not yet in SPI mode + (void)wait_for_ready(self); + if (cmd(self, 0, 0, NULL, 0, true, false) == R1_IDLE_STATE) { reached_idle_state = true; break; } @@ -259,6 +266,7 @@ STATIC const compressed_string_t *init_card(sdcardio_sdcard_obj_t *self) { return result; } } else { + DEBUG_PRINT("Reading card version, response=0x%02x\n", response); return translate("couldn't determine SD card version"); } } diff --git a/shared-module/sharpdisplay/SharpMemoryFramebuffer.c b/shared-module/sharpdisplay/SharpMemoryFramebuffer.c index ba0e0f2d69..285abb1dbe 100644 --- a/shared-module/sharpdisplay/SharpMemoryFramebuffer.c +++ b/shared-module/sharpdisplay/SharpMemoryFramebuffer.c @@ -71,8 +71,8 @@ STATIC bool common_hal_sharpdisplay_framebuffer_get_pixels_in_byte_share_row(sha void common_hal_sharpdisplay_framebuffer_reset(sharpdisplay_framebuffer_obj_t *self) { if (self->bus != &self->inline_bus - #if BOARD_SPI - && self->bus != common_hal_board_get_spi() + #if CIRCUITPY_BOARD_SPI + && !common_hal_board_is_spi(self->bus) #endif ) { memcpy(&self->inline_bus, self->bus, sizeof(busio_spi_obj_t)); diff --git a/shared-module/storage/__init__.c b/shared-module/storage/__init__.c index 620e536ba4..e36d3ec21e 100644 --- a/shared-module/storage/__init__.c +++ b/shared-module/storage/__init__.c @@ -271,7 +271,7 @@ void common_hal_storage_erase_filesystem(void) { usb_disconnect(); #endif mp_hal_delay_ms(1000); - filesystem_init(false, true); // Force a re-format. + (void)filesystem_init(false, true); // Force a re-format. Ignore failure. common_hal_mcu_reset(); // We won't actually get here, since we're resetting. } diff --git a/shared-module/terminalio/Terminal.c b/shared-module/terminalio/Terminal.c index f0a69bde39..fc33533b17 100644 --- a/shared-module/terminalio/Terminal.c +++ b/shared-module/terminalio/Terminal.c @@ -36,7 +36,6 @@ void common_hal_terminalio_terminal_construct(terminalio_terminal_obj_t *self, d self->font = font; self->tilegrid = tilegrid; self->first_row = 0; - for (uint16_t x = 0; x < self->tilegrid->width_in_tiles; x++) { for (uint16_t y = 0; y < self->tilegrid->height_in_tiles; y++) { common_hal_displayio_tilegrid_set_tile(self->tilegrid, x, y, 0); diff --git a/shared-module/vectorio/Rectangle.c b/shared-module/vectorio/Rectangle.c index bcaa0092f8..9092a2e078 100644 --- a/shared-module/vectorio/Rectangle.c +++ b/shared-module/vectorio/Rectangle.c @@ -1,7 +1,9 @@ +#include "shared-module/vectorio/__init__.h" #include "shared-bindings/vectorio/Rectangle.h" #include "shared-module/displayio/area.h" #include "py/runtime.h" +#include "stdlib.h" void common_hal_vectorio_rectangle_construct(vectorio_rectangle_t *self, uint32_t width, uint32_t height) { @@ -9,6 +11,12 @@ void common_hal_vectorio_rectangle_construct(vectorio_rectangle_t *self, uint32_ self->height = height; } +void common_hal_vectorio_rectangle_set_on_dirty(vectorio_rectangle_t *self, vectorio_event_t on_dirty) { + if (self->on_dirty.obj != NULL) { + mp_raise_TypeError(translate("can only be registered in one parent")); + } + self->on_dirty = on_dirty; +} uint32_t common_hal_vectorio_rectangle_get_pixel(void *obj, int16_t x, int16_t y) { vectorio_rectangle_t *self = obj; @@ -32,3 +40,29 @@ mp_obj_t common_hal_vectorio_rectangle_get_draw_protocol(void *rectangle) { vectorio_rectangle_t *self = rectangle; return self->draw_protocol_instance; } + +int16_t common_hal_vectorio_rectangle_get_width(void *obj) { + vectorio_rectangle_t *self = obj; + return self->width; +} + +void common_hal_vectorio_rectangle_set_width(void *obj, int16_t width) { + vectorio_rectangle_t *self = obj; + self->width = abs(width); + if (self->on_dirty.obj != NULL) { + self->on_dirty.event(self->on_dirty.obj); + } +} + +int16_t common_hal_vectorio_rectangle_get_height(void *obj) { + vectorio_rectangle_t *self = obj; + return self->height; +} + +void common_hal_vectorio_rectangle_set_height(void *obj, int16_t height) { + vectorio_rectangle_t *self = obj; + self->height = abs(height); + if (self->on_dirty.obj != NULL) { + self->on_dirty.event(self->on_dirty.obj); + } +} diff --git a/shared-module/vectorio/Rectangle.h b/shared-module/vectorio/Rectangle.h index e3cfbb2676..ec6d2107be 100644 --- a/shared-module/vectorio/Rectangle.h +++ b/shared-module/vectorio/Rectangle.h @@ -4,11 +4,13 @@ #include #include "py/obj.h" +#include "shared-module/vectorio/__init__.h" typedef struct { mp_obj_base_t base; uint16_t width; uint16_t height; + vectorio_event_t on_dirty; mp_obj_t draw_protocol_instance; } vectorio_rectangle_t; diff --git a/shared-module/vectorio/VectorShape.c b/shared-module/vectorio/VectorShape.c index 7899e2710c..04213d36e7 100644 --- a/shared-module/vectorio/VectorShape.c +++ b/shared-module/vectorio/VectorShape.c @@ -4,6 +4,7 @@ #include "shared-module/vectorio/__init__.h" #include "shared-bindings/vectorio/VectorShape.h" +#include "py/misc.h" #include "py/runtime.h" #include "shared-bindings/time/__init__.h" #include "shared-bindings/displayio/ColorConverter.h" @@ -61,15 +62,10 @@ (u32 & 0x2 ? '1' : '0'), \ (u32 & 0x1 ? '1' : '0') - -inline __attribute__((always_inline)) -static int32_t max(int32_t a, int32_t b) { - return a > b ? a : b; -} - -inline __attribute__((always_inline)) -static uint32_t min(uint32_t a, uint32_t b) { - return a < b ? a : b; +static void short_bound_check(mp_int_t i, qstr name) { + if (i < SHRT_MIN || i > SHRT_MAX) { + mp_raise_ValueError_varg(translate("%q must be between %d and %d"), name, SHRT_MIN, SHRT_MAX); + } } inline __attribute__((always_inline)) @@ -124,21 +120,50 @@ static void _get_screen_area(vectorio_vector_shape_t *self, displayio_area_t *ou VECTORIO_SHAPE_DEBUG(" out:{(%5d,%5d), (%5d,%5d)}\n", out_area->x1, out_area->y1, out_area->x2, out_area->y2); } +// Get the target pixel based on the shape's coordinate space +static void screen_to_shape_coordinates(vectorio_vector_shape_t *self, uint16_t x, uint16_t y, int16_t *out_shape_x, int16_t *out_shape_y) { + if (self->absolute_transform->transpose_xy) { + *out_shape_x = y - self->absolute_transform->y - self->absolute_transform->dy * self->x; + *out_shape_y = x - self->absolute_transform->x - self->absolute_transform->dx * self->y; -STATIC -void check_bounds_and_set_x(vectorio_vector_shape_t *self, mp_int_t x) { - if (x < SHRT_MIN || x > SHRT_MAX) { - mp_raise_ValueError_varg(translate("%q must be between %d and %d"), MP_QSTR_x, SHRT_MIN, SHRT_MAX); + VECTORIO_SHAPE_PIXEL_DEBUG(" a(%3d, %3d)", *out_shape_x, *out_shape_y); + if (self->absolute_transform->dx < 1) { + *out_shape_y *= -1; + } + if (self->absolute_transform->dy < 1) { + *out_shape_x *= -1; + } + VECTORIO_SHAPE_PIXEL_DEBUG(" b(%3d, %3d)", *out_shape_x, *out_shape_y); + } else { + *out_shape_x = x - self->absolute_transform->x - self->absolute_transform->dx * self->x; + *out_shape_y = y - self->absolute_transform->y - self->absolute_transform->dy * self->y; + + VECTORIO_SHAPE_PIXEL_DEBUG(" a(%3d, %3d)", *out_shape_x, *out_shape_y); + if (self->absolute_transform->dx < 1) { + *out_shape_x *= -1; + } + if (self->absolute_transform->dy < 1) { + *out_shape_y *= -1; + } + VECTORIO_SHAPE_PIXEL_DEBUG(" b(%3d, %3d)", *out_shape_x, *out_shape_y); + + // It's mirrored via dx. Maybe we need to add support for also separately mirroring? + // if (self->absolute_transform->mirror_x) { + // pixel_to_get_x = (shape_area.x2 - shape_area.x1) - (pixel_to_get_x - shape_area.x1) + shape_area.x1 - 1; + // } + // if (self->absolute_transform->mirror_y) { + // pixel_to_get_y = (shape_area.y2 - shape_area.y1) - (pixel_to_get_y - shape_area.y1) + +shape_area.y1 - 1; + // } } +} + +static void check_bounds_and_set_x(vectorio_vector_shape_t *self, mp_int_t x) { + short_bound_check(x, MP_QSTR_x); self->x = x; } - -STATIC -void check_bounds_and_set_y(vectorio_vector_shape_t *self, mp_int_t y) { - if (y < SHRT_MIN || y > SHRT_MAX) { - mp_raise_ValueError_varg(translate("%q must be between %d and %d"), MP_QSTR_y, SHRT_MIN, SHRT_MAX); - } +static void check_bounds_and_set_y(vectorio_vector_shape_t *self, mp_int_t y) { + short_bound_check(y, MP_QSTR_y); self->y = y; } @@ -195,6 +220,17 @@ void common_hal_vectorio_vector_shape_construct(vectorio_vector_shape_t *self, _get_screen_area(self, &self->current_area); } +bool common_hal_vectorio_vector_shape_contains(vectorio_vector_shape_t *self, mp_int_t x, mp_int_t y) { + VECTORIO_SHAPE_DEBUG("%p contains(%d, %d)", self); + short_bound_check(x, MP_QSTR_x); + short_bound_check(y, MP_QSTR_y); + int16_t shape_x; + int16_t shape_y; + screen_to_shape_coordinates(self, x, y, &shape_x, &shape_y); + bool shape_contains_coordinates = 0 != self->ishape.get_pixel(self->ishape.shape, shape_x, shape_y); + return shape_contains_coordinates; +} + mp_int_t common_hal_vectorio_vector_shape_get_x(vectorio_vector_shape_t *self) { VECTORIO_SHAPE_DEBUG("%p get_x\n", self); @@ -277,7 +313,6 @@ void common_hal_vectorio_vector_shape_set_pixel_shader(vectorio_vector_shape_t * common_hal_vectorio_vector_shape_set_dirty(self); } - bool vectorio_vector_shape_fill_area(vectorio_vector_shape_t *self, const _displayio_colorspace_t *colorspace, const displayio_area_t *area, uint32_t *mask, uint32_t *buffer) { // Shape areas are relative to 0,0. This will allow rotation about a known axis. // The consequence is that the area reported by the shape itself is _relative_ to 0,0. @@ -335,42 +370,10 @@ bool vectorio_vector_shape_fill_area(vectorio_vector_shape_t *self, const _displ } output_pixel.pixel = 0; - // Get the target pixel based on the shape's coordinate space + // Cast input screen coordinates to shape coordinates to pick the pixel to draw int16_t pixel_to_get_x; int16_t pixel_to_get_y; - if (self->absolute_transform->transpose_xy) { - pixel_to_get_x = input_pixel.y - self->absolute_transform->y - self->absolute_transform->dy * self->x; - pixel_to_get_y = input_pixel.x - self->absolute_transform->x - self->absolute_transform->dx * self->y; - - VECTORIO_SHAPE_PIXEL_DEBUG(" a(%3d, %3d)", pixel_to_get_x, pixel_to_get_y); - if (self->absolute_transform->dx < 1) { - pixel_to_get_y *= -1; - } - if (self->absolute_transform->dy < 1) { - pixel_to_get_x *= -1; - } - VECTORIO_SHAPE_PIXEL_DEBUG(" b(%3d, %3d)", pixel_to_get_x, pixel_to_get_y); - } else { - pixel_to_get_x = input_pixel.x - self->absolute_transform->x - self->absolute_transform->dx * self->x; - pixel_to_get_y = input_pixel.y - self->absolute_transform->y - self->absolute_transform->dy * self->y; - - VECTORIO_SHAPE_PIXEL_DEBUG(" a(%3d, %3d)", pixel_to_get_x, pixel_to_get_y); - if (self->absolute_transform->dx < 1) { - pixel_to_get_x *= -1; - } - if (self->absolute_transform->dy < 1) { - pixel_to_get_y *= -1; - } - VECTORIO_SHAPE_PIXEL_DEBUG(" b(%3d, %3d)", pixel_to_get_x, pixel_to_get_y); - - // It's mirrored via dx. Maybe we need to add support for also separately mirroring? - // if (self->absolute_transform->mirror_x) { - // pixel_to_get_x = (shape_area.x2 - shape_area.x1) - (pixel_to_get_x - shape_area.x1) + shape_area.x1 - 1; - // } - // if (self->absolute_transform->mirror_y) { - // pixel_to_get_y = (shape_area.y2 - shape_area.y1) - (pixel_to_get_y - shape_area.y1) + +shape_area.y1 - 1; - // } - } + screen_to_shape_coordinates(self, input_pixel.x, input_pixel.y, &pixel_to_get_x, &pixel_to_get_y); VECTORIO_SHAPE_PIXEL_DEBUG(" get_pixel %p (%3d, %3d) -> ( %3d, %3d )", self->ishape.shape, input_pixel.x, input_pixel.y, pixel_to_get_x, pixel_to_get_y); #ifdef VECTORIO_PERF @@ -411,6 +414,9 @@ bool vectorio_vector_shape_fill_area(vectorio_vector_shape_t *self, const _displ if (colorspace->depth == 16) { VECTORIO_SHAPE_PIXEL_DEBUG(" buffer = %04x 16", output_pixel.pixel); *(((uint16_t *)buffer) + pixel_index) = output_pixel.pixel; + } else if (colorspace->depth == 32) { + VECTORIO_SHAPE_PIXEL_DEBUG(" buffer = %04x 32", output_pixel.pixel); + *(((uint32_t *)buffer) + pixel_index) = output_pixel.pixel; } else if (colorspace->depth == 8) { VECTORIO_SHAPE_PIXEL_DEBUG(" buffer = %02x 8", output_pixel.pixel); *(((uint8_t *)buffer) + pixel_index) = output_pixel.pixel; @@ -440,7 +446,7 @@ bool vectorio_vector_shape_fill_area(vectorio_vector_shape_t *self, const _displ mp_obj_get_type_str(self->ishape.shape), (overlap.x2 - overlap.x1) * (overlap.y2 - overlap.y1), (double)((end - start) / 1000000.0), - (double)(max(1, pixels * (1000000000.0 / (end - start)))), + (double)(MAX(1, pixels * (1000000000.0 / (end - start)))), (double)(pixel_time / 1000.0), (double)(pixel_time / 1000.0 / pixels) ); @@ -498,7 +504,7 @@ displayio_area_t *vectorio_vector_shape_get_refresh_areas(vectorio_vector_shape_ union_size, dirty_size, current_size, overlap_size, (int32_t)union_size - dirty_size - current_size + overlap_size ); - if ((int32_t)union_size - dirty_size - current_size + overlap_size <= min(dirty_size, current_size)) { + if ((int32_t)union_size - dirty_size - current_size + overlap_size <= MIN(dirty_size, current_size)) { // The excluded / non-overlapping area from the disjoint dirty and current areas is smaller // than the smallest area we need to draw. Redrawing the overlapping area would cost more // than just drawing the union disjoint area once. diff --git a/shared/libc/string0.c b/shared/libc/string0.c index fee2c017f8..86e7cc5960 100644 --- a/shared/libc/string0.c +++ b/shared/libc/string0.c @@ -25,6 +25,7 @@ */ #include +#include #include #ifndef likely @@ -68,6 +69,14 @@ void *memcpy(void *dst, const void *src, size_t n) { return dst; } +extern void *__memcpy_chk(void *dest, const void *src, size_t len, size_t slen); +void *__memcpy_chk(void *dest, const void *src, size_t len, size_t slen) { + if (len > slen) { + return NULL; + } + return memcpy(dest, src, len); +} + void *memmove(void *dest, const void *src, size_t n) { if (src < dest && (uint8_t*)dest < (const uint8_t*)src + n) { // need to copy backwards diff --git a/shared/runtime/pyexec.c b/shared/runtime/pyexec.c index 7b44bb15dc..3c42459aba 100644 --- a/shared/runtime/pyexec.c +++ b/shared/runtime/pyexec.c @@ -55,21 +55,21 @@ int pyexec_system_exit = 0; STATIC bool repl_display_debugging_info = 0; #endif -#define EXEC_FLAG_PRINT_EOF (1) -#define EXEC_FLAG_ALLOW_DEBUGGING (2) -#define EXEC_FLAG_IS_REPL (4) -#define EXEC_FLAG_SOURCE_IS_RAW_CODE (8) -#define EXEC_FLAG_SOURCE_IS_VSTR (16) -#define EXEC_FLAG_SOURCE_IS_FILENAME (32) -#define EXEC_FLAG_SOURCE_IS_READER (64) -#define EXEC_FLAG_SOURCE_IS_ATEXIT (128) +#define EXEC_FLAG_PRINT_EOF (1 << 0) +#define EXEC_FLAG_ALLOW_DEBUGGING (1 << 1) +#define EXEC_FLAG_IS_REPL (1 << 2) +#define EXEC_FLAG_SOURCE_IS_RAW_CODE (1 << 3) +#define EXEC_FLAG_SOURCE_IS_VSTR (1 << 4) +#define EXEC_FLAG_SOURCE_IS_FILENAME (1 << 5) +#define EXEC_FLAG_SOURCE_IS_READER (1 << 6) +#define EXEC_FLAG_SOURCE_IS_ATEXIT (1 << 7) // parses, compiles and executes the code in the lexer // frees the lexer before returning // EXEC_FLAG_PRINT_EOF prints 2 EOF chars: 1 after normal output, 1 after exception output // EXEC_FLAG_ALLOW_DEBUGGING allows debugging info to be printed after executing the code // EXEC_FLAG_IS_REPL is used for REPL inputs (flag passed on to mp_compile) -STATIC int parse_compile_execute(const void *source, mp_parse_input_kind_t input_kind, int exec_flags, pyexec_result_t *result) { +STATIC int parse_compile_execute(const void *source, mp_parse_input_kind_t input_kind, mp_uint_t exec_flags, pyexec_result_t *result) { int ret = 0; #if MICROPY_REPL_INFO uint32_t start = 0; @@ -166,6 +166,7 @@ STATIC int parse_compile_execute(const void *source, mp_parse_input_kind_t input if (exec_flags & EXEC_FLAG_PRINT_EOF) { mp_hal_stdout_tx_strn("\x04", 1); } + // check for SystemExit if (mp_obj_is_subclass_fast(MP_OBJ_FROM_PTR(mp_obj_get_type((mp_obj_t)nlr.ret_val)), MP_OBJ_FROM_PTR(&mp_type_SystemExit))) { // at the moment, the value of SystemExit is unused @@ -745,7 +746,7 @@ int pyexec_file(const char *filename, pyexec_result_t *result) { int pyexec_file_if_exists(const char *filename, pyexec_result_t *result) { #if MICROPY_MODULE_FROZEN - if (mp_frozen_stat(filename) == MP_IMPORT_STAT_FILE) { + if (mp_find_frozen_module(filename, NULL, NULL) == MP_IMPORT_STAT_FILE) { return pyexec_frozen_module(filename, result); } #endif @@ -758,7 +759,8 @@ int pyexec_file_if_exists(const char *filename, pyexec_result_t *result) { #if MICROPY_MODULE_FROZEN int pyexec_frozen_module(const char *name, pyexec_result_t *result) { void *frozen_data; - int frozen_type = mp_find_frozen_module(name, strlen(name), &frozen_data); + int frozen_type; + mp_find_frozen_module(name, &frozen_type, &frozen_data); switch (frozen_type) { #if MICROPY_MODULE_FROZEN_STR diff --git a/shared/upytesthelper/upytesthelper.c b/shared/upytesthelper/upytesthelper.c index 326172be65..ce60732424 100644 --- a/shared/upytesthelper/upytesthelper.c +++ b/shared/upytesthelper/upytesthelper.c @@ -94,6 +94,9 @@ void upytest_execute_test(const char *src) { gc_init(heap_start, heap_end); mp_init(); mp_obj_list_init(mp_sys_path, 0); + #if MICROPY_MODULE_FROZEN + mp_obj_list_append(mp_sys_path, MP_OBJ_NEW_QSTR(MP_QSTR__dot_frozen)); + #endif mp_obj_list_init(mp_sys_argv, 0); nlr_buf_t nlr; diff --git a/supervisor/filesystem.h b/supervisor/filesystem.h index c7c951a5e6..6f4faf0b82 100644 --- a/supervisor/filesystem.h +++ b/supervisor/filesystem.h @@ -35,7 +35,7 @@ extern volatile bool filesystem_flush_requested; void filesystem_background(void); void filesystem_tick(void); -void filesystem_init(bool create_allowed, bool force_create); +bool filesystem_init(bool create_allowed, bool force_create); void filesystem_flush(void); bool filesystem_present(void); void filesystem_set_internal_writable_by_usb(bool usb_writable); diff --git a/supervisor/shared/display.c b/supervisor/shared/display.c index a4849a3c58..f991852414 100644 --- a/supervisor/shared/display.c +++ b/supervisor/shared/display.c @@ -61,6 +61,7 @@ void supervisor_start_terminal(uint16_t width_px, uint16_t height_px) { #if CIRCUITPY_TERMINALIO displayio_tilegrid_t *grid = &supervisor_terminal_text_grid; bool tall = height_px > width_px; + bool reset_tiles = false; uint16_t terminal_width_px = tall ? width_px : width_px - blinka_bitmap.width; uint16_t terminal_height_px = tall ? height_px - blinka_bitmap.height : height_px; uint16_t width_in_tiles = terminal_width_px / grid->tile_width; @@ -81,37 +82,48 @@ void supervisor_start_terminal(uint16_t width_px, uint16_t height_px) { uint16_t total_tiles = width_in_tiles * height_in_tiles; + // check if the terminal tile dimensions are the same + if ((grid->width_in_tiles != width_in_tiles) || + (grid->height_in_tiles != height_in_tiles)) { + reset_tiles = true; + } // Reuse the previous allocation if possible if (tilegrid_tiles) { if (get_allocation_length(tilegrid_tiles) != align32_size(total_tiles)) { free_memory(tilegrid_tiles); tilegrid_tiles = NULL; + reset_tiles = true; } } if (!tilegrid_tiles) { tilegrid_tiles = allocate_memory(align32_size(total_tiles), false, true); + reset_tiles = true; if (!tilegrid_tiles) { return; } } - uint8_t *tiles = (uint8_t *)tilegrid_tiles->ptr; - grid->y = tall ? blinka_bitmap.height : 0; - grid->x = tall ? 0 : blinka_bitmap.width; - grid->top_left_y = 0; - if (remaining_pixels > 0) { - grid->y -= (grid->tile_height - remaining_pixels); + if (reset_tiles) { + uint8_t *tiles = (uint8_t *)tilegrid_tiles->ptr; + + grid->y = tall ? blinka_bitmap.height : 0; + grid->x = tall ? 0 : blinka_bitmap.width; + grid->top_left_y = 0; + if (remaining_pixels > 0) { + grid->y -= (grid->tile_height - remaining_pixels); + } + grid->width_in_tiles = width_in_tiles; + grid->height_in_tiles = height_in_tiles; + assert(width_in_tiles > 0); + assert(height_in_tiles > 0); + grid->pixel_width = width_in_tiles * grid->tile_width; + grid->pixel_height = height_in_tiles * grid->tile_height; + grid->tiles = tiles; + + grid->full_change = true; + + common_hal_terminalio_terminal_construct(&supervisor_terminal, grid, &supervisor_terminal_font); } - grid->width_in_tiles = width_in_tiles; - grid->height_in_tiles = height_in_tiles; - assert(width_in_tiles > 0); - assert(height_in_tiles > 0); - grid->pixel_width = width_in_tiles * grid->tile_width; - grid->pixel_height = height_in_tiles * grid->tile_height; - grid->tiles = tiles; - grid->full_change = true; - - common_hal_terminalio_terminal_construct(&supervisor_terminal, grid, &supervisor_terminal_font); #endif circuitpython_splash.scale = scale; diff --git a/supervisor/shared/external_flash/spi_flash.c b/supervisor/shared/external_flash/spi_flash.c index 9444e303a1..b47508e051 100644 --- a/supervisor/shared/external_flash/spi_flash.c +++ b/supervisor/shared/external_flash/spi_flash.c @@ -105,12 +105,12 @@ bool spi_flash_sector_command(uint8_t command, uint32_t address) { bool spi_flash_write_data(uint32_t address, uint8_t *data, uint32_t data_length) { uint8_t request[4] = {CMD_PAGE_PROGRAM, 0x00, 0x00, 0x00}; + common_hal_busio_spi_configure(&supervisor_flash_spi_bus, spi_flash_baudrate, 0, 0, 8); // Write the SPI flash write address into the bytes following the command byte. address_to_bytes(address, request + 1); if (!flash_enable()) { return false; } - common_hal_busio_spi_configure(&supervisor_flash_spi_bus, spi_flash_baudrate, 0, 0, 8); bool status = common_hal_busio_spi_write(&supervisor_flash_spi_bus, request, 4); if (status) { status = common_hal_busio_spi_write(&supervisor_flash_spi_bus, data, data_length); @@ -126,12 +126,12 @@ bool spi_flash_read_data(uint32_t address, uint8_t *data, uint32_t data_length) request[0] = CMD_FAST_READ_DATA; command_length = 5; } + common_hal_busio_spi_configure(&supervisor_flash_spi_bus, spi_flash_baudrate, 0, 0, 8); // Write the SPI flash read address into the bytes following the command byte. address_to_bytes(address, request + 1); if (!flash_enable()) { return false; } - common_hal_busio_spi_configure(&supervisor_flash_spi_bus, spi_flash_baudrate, 0, 0, 8); bool status = common_hal_busio_spi_write(&supervisor_flash_spi_bus, request, command_length); if (status) { status = common_hal_busio_spi_read(&supervisor_flash_spi_bus, data, data_length, 0xff); @@ -144,14 +144,15 @@ void spi_flash_init(void) { cs_pin.base.type = &digitalio_digitalinout_type; common_hal_digitalio_digitalinout_construct(&cs_pin, SPI_FLASH_CS_PIN); - // Set CS high (disabled). common_hal_digitalio_digitalinout_switch_to_output(&cs_pin, true, DRIVE_MODE_PUSH_PULL); common_hal_digitalio_digitalinout_never_reset(&cs_pin); supervisor_flash_spi_bus.base.type = &busio_spi_type; - common_hal_busio_spi_construct(&supervisor_flash_spi_bus, SPI_FLASH_SCK_PIN, SPI_FLASH_MOSI_PIN, SPI_FLASH_MISO_PIN); + common_hal_busio_spi_construct(&supervisor_flash_spi_bus, SPI_FLASH_SCK_PIN, SPI_FLASH_MOSI_PIN, SPI_FLASH_MISO_PIN, false); common_hal_busio_spi_never_reset(&supervisor_flash_spi_bus); + + return; } void spi_flash_init_device(const external_flash_device *device) { @@ -160,4 +161,6 @@ void spi_flash_init_device(const external_flash_device *device) { if (spi_flash_baudrate > SPI_FLASH_MAX_BAUDRATE) { spi_flash_baudrate = SPI_FLASH_MAX_BAUDRATE; } + common_hal_busio_spi_configure(&supervisor_flash_spi_bus, spi_flash_baudrate, 0, 0, 8); + return; } diff --git a/supervisor/shared/filesystem.c b/supervisor/shared/filesystem.c index 2ab64e5dbd..820dbe9783 100644 --- a/supervisor/shared/filesystem.c +++ b/supervisor/shared/filesystem.c @@ -86,7 +86,7 @@ static void make_sample_code_file(FATFS *fatfs) { // we don't make this function static because it needs a lot of stack and we // want it to be executed without using stack within main() function -void filesystem_init(bool create_allowed, bool force_create) { +bool filesystem_init(bool create_allowed, bool force_create) { // init the vfs object fs_user_mount_t *vfs_fat = &_internal_vfs; vfs_fat->blockdev.flags = 0; @@ -102,11 +102,11 @@ void filesystem_init(bool create_allowed, bool force_create) { formats |= FM_EXFAT | FM_FAT32; #endif res = f_mkfs(&vfs_fat->fatfs, formats, 0, working_buf, sizeof(working_buf)); + if (res != FR_OK) { + return false; + } // Flush the new file system to make sure it's repaired immediately. supervisor_flash_flush(); - if (res != FR_OK) { - return; - } // set label #ifdef CIRCUITPY_DRIVE_LABEL @@ -115,13 +115,13 @@ void filesystem_init(bool create_allowed, bool force_create) { res = f_setlabel(&vfs_fat->fatfs, "CIRCUITPY"); #endif if (res != FR_OK) { - return; + return false; } // inhibit file indexing on MacOS res = f_mkdir(&vfs_fat->fatfs, "/.fseventsd"); if (res != FR_OK) { - return; + return false; } make_empty_file(&vfs_fat->fatfs, "/.metadata_never_index"); make_empty_file(&vfs_fat->fatfs, "/.Trashes"); @@ -132,13 +132,13 @@ void filesystem_init(bool create_allowed, bool force_create) { // create empty lib directory res = f_mkdir(&vfs_fat->fatfs, "/lib"); if (res != FR_OK) { - return; + return false; } // and ensure everything is flushed supervisor_flash_flush(); } else if (res != FR_OK) { - return; + return false; } mp_vfs_mount_t *vfs = &_mp_vfs; vfs->str = "/"; @@ -150,6 +150,8 @@ void filesystem_init(bool create_allowed, bool force_create) { // The current directory is used as the boot up directory. // It is set to the internal flash filesystem by default. MP_STATE_PORT(vfs_cur) = vfs; + + return true; } void filesystem_flush(void) { diff --git a/supervisor/shared/safe_mode.c b/supervisor/shared/safe_mode.c index 59b5ab838d..4cb9d7ad61 100644 --- a/supervisor/shared/safe_mode.c +++ b/supervisor/shared/safe_mode.c @@ -175,6 +175,9 @@ void print_safe_mode_message(safe_mode_t reason) { case WATCHDOG_RESET: message = translate("Watchdog timer expired."); break; + case NO_CIRCUITPY: + message = translate("CIRCUITPY drive could not be found or created."); + break; default: break; } diff --git a/supervisor/shared/safe_mode.h b/supervisor/shared/safe_mode.h index 600abd7672..0c8d018bfe 100644 --- a/supervisor/shared/safe_mode.h +++ b/supervisor/shared/safe_mode.h @@ -48,6 +48,7 @@ typedef enum { USB_TOO_MANY_INTERFACE_NAMES, USB_BOOT_DEVICE_NOT_INTERFACE_ZERO, NO_HEAP, + NO_CIRCUITPY, } safe_mode_t; safe_mode_t wait_for_safe_mode_reset(void); diff --git a/supervisor/shared/status_leds.c b/supervisor/shared/status_leds.c index 0c433271fc..07ff9634e9 100644 --- a/supervisor/shared/status_leds.c +++ b/supervisor/shared/status_leds.c @@ -48,6 +48,7 @@ uint8_t rgb_status_brightness = 63; #define MICROPY_HW_NEOPIXEL_COUNT (1) #endif +static uint64_t next_start_raw_ticks; static uint8_t status_neopixel_color[3 * MICROPY_HW_NEOPIXEL_COUNT]; static digitalio_digitalinout_obj_t status_neopixel; @@ -162,7 +163,8 @@ void status_led_init() { common_hal_busio_spi_construct(&status_apa102, MICROPY_HW_APA102_SCK, MICROPY_HW_APA102_MOSI, - NULL); + NULL, + false); #endif #if CIRCUITPY_BITBANG_APA102 shared_module_bitbangio_spi_try_lock(&status_apa102); @@ -218,6 +220,10 @@ void status_led_init() { void status_led_deinit() { #ifdef MICROPY_HW_NEOPIXEL + // Make sure the pin stays low for the reset period. The pin reset may pull + // it up and stop the reset period. + while (port_get_raw_ticks(NULL) < next_start_raw_ticks) { + } common_hal_reset_pin(MICROPY_HW_NEOPIXEL); #elif defined(MICROPY_HW_APA102_MOSI) && defined(MICROPY_HW_APA102_SCK) @@ -265,7 +271,7 @@ void new_status_color(uint32_t rgb) { status_neopixel_color[3 * i + 2] = rgb_adjusted & 0xff; } common_hal_neopixel_write(&status_neopixel, status_neopixel_color, 3 * MICROPY_HW_NEOPIXEL_COUNT); - + next_start_raw_ticks = port_get_raw_ticks(NULL) + 2; #elif defined(MICROPY_HW_APA102_MOSI) && defined(MICROPY_HW_APA102_SCK) for (size_t i = 0; i < MICROPY_HW_APA102_COUNT; i++) { // Skip 4 + offset to skip the header bytes too. @@ -318,12 +324,9 @@ uint32_t color_brightness(uint32_t color, uint8_t brightness) { void set_status_brightness(uint8_t level) { #if CIRCUITPY_STATUS_LED rgb_status_brightness = level; - uint32_t current_color = current_status_color; - // Temporarily change the current color global to force the new_status_color call to update the - // LED. Usually duplicate calls of the same color are ignored without regard to brightness - // changes. - current_status_color = 0; - new_status_color(current_color); + // This is only called by user code and we're never controlling the status + // LED when user code is running. So, we don't need to update the current + // state (there is none.) #endif } diff --git a/supervisor/shared/tick.c b/supervisor/shared/tick.c index 40c1ef11e3..94b9d4d15e 100644 --- a/supervisor/shared/tick.c +++ b/supervisor/shared/tick.c @@ -37,6 +37,10 @@ #include "supervisor/shared/autoreload.h" #include "supervisor/shared/stack.h" +#if CIRCUITPY_BLEIO_HCI +#include "common-hal/_bleio/__init__.h" +#endif + #if CIRCUITPY_DISPLAYIO #include "shared-module/displayio/__init__.h" #endif @@ -69,6 +73,10 @@ static void supervisor_background_tasks(void *unused) { assert_heap_ok(); + #if CIRCUITPY_BLEIO_HCI + bleio_hci_background(); + #endif + #if CIRCUITPY_DISPLAYIO displayio_background(); #endif diff --git a/supervisor/shared/translate.c b/supervisor/shared/translate.c index a14fa5c728..fefda46006 100644 --- a/supervisor/shared/translate.c +++ b/supervisor/shared/translate.c @@ -87,11 +87,13 @@ STATIC int put_utf8(char *buf, int u) { } uint16_t decompress_length(const compressed_string_t *compressed) { - if (compress_max_length_bits <= 8) { - return 1 + (compressed->data >> (8 - compress_max_length_bits)); - } else { - return 1 + ((compressed->data * 256 + compressed->tail[0]) >> (16 - compress_max_length_bits)); - } + #ifndef NO_QSTR + #if (compress_max_length_bits <= 8) + return 1 + (compressed->data >> (8 - compress_max_length_bits)); + #else + return 1 + ((compressed->data * 256 + compressed->tail[0]) >> (16 - compress_max_length_bits)); + #endif + #endif } char *decompress(const compressed_string_t *compressed, char *decompressed) { diff --git a/supervisor/shared/usb/tusb_config.h b/supervisor/shared/usb/tusb_config.h index e75a653244..15d539c450 100644 --- a/supervisor/shared/usb/tusb_config.h +++ b/supervisor/shared/usb/tusb_config.h @@ -96,8 +96,18 @@ extern "C" { // --------------------------------------------------------------------+ // USB RAM PLACEMENT // --------------------------------------------------------------------+ -#define CFG_TUSB_ATTR_USBRAM -#define CFG_TUSB_MEM_ALIGN __attribute__ ((aligned(4))) +#if !defined(CIRCUITPY_TUSB_ATTR_USBRAM) +#define CIRCUITPY_TUSB_ATTR_USBRAM ".bss.usbram" +#endif + +#define CFG_TUSB_ATTR_USBRAM __attribute__((section(CIRCUITPY_TUSB_ATTR_USBRAM))) + + +#if !defined(CIRCUITPY_TUSB_MEM_ALIGN) +#define CIRCUITPY_TUSB_MEM_ALIGN 4 +#endif + +#define CFG_TUSB_MEM_ALIGN __attribute__ ((aligned(CIRCUITPY_TUSB_MEM_ALIGN))) #ifdef __cplusplus diff --git a/supervisor/stub/filesystem.c b/supervisor/stub/filesystem.c index 2b518f4142..650f4d8346 100644 --- a/supervisor/stub/filesystem.c +++ b/supervisor/stub/filesystem.c @@ -26,19 +26,51 @@ #include "supervisor/filesystem.h" -void filesystem_init(bool create_allowed, bool force_create) { + +void filesystem_background(void) { + return; +} + +bool filesystem_init(bool create_allowed, bool force_create) { (void)create_allowed; (void)force_create; + return true; } void filesystem_flush(void) { } +void filesystem_set_internal_writable_by_usb(bool writable) { + (void)writable; + return; +} + +void filesystem_set_writable_by_usb(fs_user_mount_t *vfs, bool usb_writable) { + (void)vfs; + (void)usb_writable; + return; +} + bool filesystem_is_writable_by_python(fs_user_mount_t *vfs) { (void)vfs; return true; } +bool filesystem_is_writable_by_usb(fs_user_mount_t *vfs) { + return true; +} + +void filesystem_set_internal_concurrent_write_protection(bool concurrent_write_protection) { + (void)concurrent_write_protection; + return; +} + +void filesystem_set_concurrent_write_protection(fs_user_mount_t *vfs, bool concurrent_write_protection) { + (void)vfs; + (void)concurrent_write_protection; + return; +} + bool filesystem_present(void) { return false; } diff --git a/supervisor/stub/internal_flash.c b/supervisor/stub/internal_flash.c index 3a4ba935de..23e843c923 100644 --- a/supervisor/stub/internal_flash.c +++ b/supervisor/stub/internal_flash.c @@ -46,7 +46,8 @@ uint32_t supervisor_flash_get_block_count(void) { return 0; } -void supervisor_flash_flush(void) { +void port_internal_flash_flush(void) { + return; } mp_uint_t supervisor_flash_read_blocks(uint8_t *dest, uint32_t block, uint32_t num_blocks) { diff --git a/supervisor/supervisor.mk b/supervisor/supervisor.mk index 3270f76ed1..eed9f4dc47 100644 --- a/supervisor/supervisor.mk +++ b/supervisor/supervisor.mk @@ -5,7 +5,6 @@ SRC_SUPERVISOR = \ supervisor/shared/background_callback.c \ supervisor/shared/board.c \ supervisor/shared/cpu.c \ - supervisor/shared/filesystem.c \ supervisor/shared/flash.c \ supervisor/shared/lock.c \ supervisor/shared/memory.c \ @@ -17,6 +16,12 @@ SRC_SUPERVISOR = \ supervisor/shared/traceback.c \ supervisor/shared/translate.c +ifeq ($(DISABLE_FILESYSTEM),1) +SRC_SUPERVISOR += supervisor/stub/filesystem.c +else +SRC_SUPERVISOR += supervisor/shared/filesystem.c +endif + NO_USB ?= $(wildcard supervisor/usb.c) INTERNAL_FLASH_FILESYSTEM ?= 0 diff --git a/tests/basics/int_big_cmp.py b/tests/basics/int_big_cmp.py index 7cb7412bdf..d7394d3bc8 100644 --- a/tests/basics/int_big_cmp.py +++ b/tests/basics/int_big_cmp.py @@ -1,10 +1,13 @@ # test bignum comparisons i = 1 << 65 +cases = (0, 1, -1, i, -i, i + 1, -(i + 1)) -print(i == 0) -print(i != 0) -print(i < 0) -print(i > 0) -print(i <= 0) -print(i >= 0) +for lhs in cases: + for rhs in cases: + print("{} == {} = {}".format(lhs, rhs, lhs == rhs)) + print("{} != {} = {}".format(lhs, rhs, lhs != rhs)) + print("{} < {} = {}".format(lhs, rhs, lhs < rhs)) + print("{} > {} = {}".format(lhs, rhs, lhs > rhs)) + print("{} <= {} = {}".format(lhs, rhs, lhs <= rhs)) + print("{} >= {} = {}".format(lhs, rhs, lhs >= rhs)) diff --git a/tests/basics/int_big_zeroone.py b/tests/basics/int_big_zeroone.py index 81636724a5..e97369a2db 100644 --- a/tests/basics/int_big_zeroone.py +++ b/tests/basics/int_big_zeroone.py @@ -1,4 +1,4 @@ -# test [0,-0,1,-1] edge cases of bignum +# test [0,1,-1] edge cases of bignum import skip_if skip_if.no_bigint() @@ -16,7 +16,7 @@ print([~c for c in cases]) print([c >> 1 for c in cases]) print([c << 1 for c in cases]) -# comparison of 0/-0/+0 +# comparison of 0 print(long_zero == 0) print(long_neg_zero == 0) print(long_one - 1 == 0) @@ -29,3 +29,40 @@ print(long_neg_zero < 1) print(long_neg_zero < -1) print(long_neg_zero > 1) print(long_neg_zero > -1) + +# generate zeros that involve negative numbers +large = 1 << 70 +large_plus_one = large + 1 +zeros = ( + large - large, + -large + large, + large + -large, + -(large - large), + large - large_plus_one + 1, + -large & (large - large), + -large ^ -large, + -large * (large - large), + (large - large) // -large, + -large // -large_plus_one, + -(large + large) % large, + (large + large) % -large, + -(large + large) % -large, +) +print(zeros) + +# compute arithmetic operations that may have problems with -0 +# (this checks that -0 is never generated in the zeros tuple) +cases = (0, 1, -1) + zeros +for lhs in cases: + print("-{} = {}".format(lhs, -lhs)) + print("~{} = {}".format(lhs, ~lhs)) + print("{} >> 1 = {}".format(lhs, lhs >> 1)) + print("{} << 1 = {}".format(lhs, lhs << 1)) + for rhs in cases: + print("{} == {} = {}".format(lhs, rhs, lhs == rhs)) + print("{} + {} = {}".format(lhs, rhs, lhs + rhs)) + print("{} - {} = {}".format(lhs, rhs, lhs - rhs)) + print("{} * {} = {}".format(lhs, rhs, lhs * rhs)) + print("{} | {} = {}".format(lhs, rhs, lhs | rhs)) + print("{} & {} = {}".format(lhs, rhs, lhs & rhs)) + print("{} ^ {} = {}".format(lhs, rhs, lhs ^ rhs)) diff --git a/tests/basics/string_fstring.py b/tests/basics/string_fstring.py index 4f7225fcad..7e8a97fd30 100644 --- a/tests/basics/string_fstring.py +++ b/tests/basics/string_fstring.py @@ -22,6 +22,13 @@ def foo(a, b): return f'{x}{y}{a}{b}' print(foo(7, 8)) +# ':' character within {...} that should not be interpreted as format specifiers. +print(f"a{[0,1,2][0:2]}") +print(f"a{[0,15,2][0:2][-1]:04x}") + +# Nested '{' and '}' characters. +print(f"a{ {0,1,2}}") + # PEP-0498 specifies that '\\' and '#' must be disallowed explicitly, whereas # MicroPython relies on the syntax error as a result of the substitution. diff --git a/tests/basics/subclass_native_exc_new.py b/tests/basics/subclass_native_exc_new.py new file mode 100644 index 0000000000..c1bd89a6fa --- /dev/null +++ b/tests/basics/subclass_native_exc_new.py @@ -0,0 +1,39 @@ +# test subclassing exceptions and providing __new__ + + +class Dummy(BaseException): + pass + + +class GoodException(BaseException): + def __new__(cls, *args, **kwargs): + print("GoodException __new__") + return Dummy(*args, **kwargs) + + +class BadException(BaseException): + def __new__(cls, *args, **kwargs): + print("BadException __new__") + return 1 + + +try: + raise GoodException("good message") +except BaseException as good: + print(type(good), good.args[0]) + +try: + raise BadException("bad message") +except Exception as bad: + # Should be TypeError 'exceptions must derive from BaseException' + print(type(bad), bad.args[0]) + +try: + + def gen(): + yield + + gen().throw(BadException) +except Exception as genbad: + # Should be TypeError 'exceptions must derive from BaseException' + print(type(genbad), genbad.args[0]) diff --git a/tests/basics/subclass_native_exc_new.py.exp b/tests/basics/subclass_native_exc_new.py.exp new file mode 100644 index 0000000000..65709b2ccf --- /dev/null +++ b/tests/basics/subclass_native_exc_new.py.exp @@ -0,0 +1,6 @@ +GoodException __new__ + good message +BadException __new__ + exceptions must derive from BaseException +BadException __new__ + exceptions must derive from BaseException diff --git a/tests/basics/sys_path.py b/tests/basics/sys_path.py new file mode 100644 index 0000000000..6456e24019 --- /dev/null +++ b/tests/basics/sys_path.py @@ -0,0 +1,16 @@ +# test sys.path + +try: + import usys as sys +except ImportError: + import sys + +# check that this script was executed from a file of the same name +if "__file__" not in globals() or "sys_path.py" not in __file__: + print("SKIP") + raise SystemExit + +# test that sys.path[0] is the directory containing this script +with open(sys.path[0] + "/sys_path.py") as f: + for _ in range(4): + print(f.readline()) diff --git a/tests/circuitpython-manual/audiobusio/i2s_sample_loop.py b/tests/circuitpython-manual/audiobusio/i2s_sample_loop.py index 8b40e916dc..75ed4c7ae6 100644 --- a/tests/circuitpython-manual/audiobusio/i2s_sample_loop.py +++ b/tests/circuitpython-manual/audiobusio/i2s_sample_loop.py @@ -19,7 +19,7 @@ length = 8000 // 440 # signed 16 bit s16 = array.array("h", [0] * length) for i in range(length): - s16[i] = int(math.sin(math.pi * 2 * i / length) * (2 ** 15)) + s16[i] = int(math.sin(math.pi * 2 * i / length) * (2**15)) print(s16[i]) sample = audiocore.RawSample(s16, sample_rate=8000) diff --git a/tests/circuitpython-manual/audiopwmio/single_buffer_loop.py b/tests/circuitpython-manual/audiopwmio/single_buffer_loop.py index 6013892a95..ffacb6f1d6 100644 --- a/tests/circuitpython-manual/audiopwmio/single_buffer_loop.py +++ b/tests/circuitpython-manual/audiopwmio/single_buffer_loop.py @@ -19,21 +19,21 @@ sample_names = ["unsigned 8 bit", "signed 8 bit", "unsigned 16 bit", "signed 16 # unsigned 8 bit u8 = array.array("B", [0] * length) for i in range(length): - u8[i] = int(math.sin(math.pi * 2 * i / length) * (2 ** 7) + 2 ** 7) + u8[i] = int(math.sin(math.pi * 2 * i / length) * (2**7) + 2**7) samples.append(audiocore.RawSample(u8, sample_rate=4000)) # signed 8 bit s8 = array.array("b", [0] * length) for i in range(length): - s8[i] = int(math.sin(math.pi * 2 * i / length) * (2 ** 7)) + s8[i] = int(math.sin(math.pi * 2 * i / length) * (2**7)) samples.append(audiocore.RawSample(s8, sample_rate=16000)) # unsigned 16 bit u16 = array.array("H", [0] * length) for i in range(length): - u16[i] = int(math.sin(math.pi * 2 * i / length) * (2 ** 15) + 2 ** 15) + u16[i] = int(math.sin(math.pi * 2 * i / length) * (2**15) + 2**15) samples.append(audiocore.RawSample(u16, sample_rate=8000)) @@ -41,7 +41,7 @@ samples.append(audiocore.RawSample(u16, sample_rate=8000)) # signed 16 bit s16 = array.array("h", [0] * length) for i in range(length): - s16[i] = int(math.sin(math.pi * 2 * i / length) * (2 ** 15)) + s16[i] = int(math.sin(math.pi * 2 * i / length) * (2**15)) samples.append(audiocore.RawSample(s16, sample_rate=8000)) diff --git a/tests/circuitpython/builtin_submodule.py b/tests/circuitpython/builtin_submodule.py new file mode 100644 index 0000000000..6d266f69b1 --- /dev/null +++ b/tests/circuitpython/builtin_submodule.py @@ -0,0 +1,9 @@ +try: + import ulab +except: + print("SKIP") + raise SystemExit(0) + +import ulab.scipy.linalg + +print(ulab.scipy.linalg) diff --git a/tests/circuitpython/builtin_submodule.py.exp b/tests/circuitpython/builtin_submodule.py.exp new file mode 100644 index 0000000000..6bfad9e9ad --- /dev/null +++ b/tests/circuitpython/builtin_submodule.py.exp @@ -0,0 +1 @@ + diff --git a/tests/circuitpython/traceback_test.py b/tests/circuitpython/traceback_test.py index cb7bf4b2aa..6ae73db6ae 100644 --- a/tests/circuitpython/traceback_test.py +++ b/tests/circuitpython/traceback_test.py @@ -22,4 +22,15 @@ except Exception as exc: traceback.print_exception(None, exc, exc.__traceback__, limit=0) print("\nLimit=-1 Trace:") traceback.print_exception(None, exc, exc.__traceback__, limit=-1) + + +class NonNativeException(Exception): + pass + + +try: + raise NonNativeException("test") +except Exception as e: + print("\nNonNative Trace:") + traceback.print_exception(None, e, e.__traceback__) print("") diff --git a/tests/circuitpython/traceback_test.py.exp b/tests/circuitpython/traceback_test.py.exp index be887f2421..9d5adff172 100644 --- a/tests/circuitpython/traceback_test.py.exp +++ b/tests/circuitpython/traceback_test.py.exp @@ -21,3 +21,8 @@ Traceback (most recent call last): File "circuitpython/traceback_test.py", line 9, in fun Exception: test +NonNative Trace: +Traceback (most recent call last): + File "circuitpython/traceback_test.py", line 32, in +NonNativeException: test + diff --git a/tests/cmdline/cmd_parsetree.py.exp b/tests/cmdline/cmd_parsetree.py.exp index cc8ba82c05..bee4fc99d1 100644 --- a/tests/cmdline/cmd_parsetree.py.exp +++ b/tests/cmdline/cmd_parsetree.py.exp @@ -78,11 +78,11 @@ arg names: 45 STORE_NAME g 48 LOAD_CONST_OBJ \.\+ 50 LOAD_METHOD format -53 LOAD_NAME b (cache=0) -57 CALL_METHOD n=1 nkw=0 -59 STORE_NAME h -62 LOAD_CONST_NONE -63 RETURN_VALUE +53 LOAD_NAME b +56 CALL_METHOD n=1 nkw=0 +58 STORE_NAME h +61 LOAD_CONST_NONE +62 RETURN_VALUE mem: total=\\d\+, current=\\d\+, peak=\\d\+ stack: \\d\+ out of \\d\+ GC: total: \\d\+, used: \\d\+, free: \\d\+ diff --git a/tests/cmdline/cmd_showbc.py b/tests/cmdline/cmd_showbc.py index 3195d41e84..a960c15c4a 100644 --- a/tests/cmdline/cmd_showbc.py +++ b/tests/cmdline/cmd_showbc.py @@ -15,9 +15,9 @@ def f(): c = [1, 2] d = {1, 2} e = {} - f = {1: 2} - g = "a" - h = b"a" + f = {1:2} + g = 'a' + h = b'a' # unary/binary ops i = 1 @@ -59,7 +59,7 @@ def f(): # comprehensions a = (b for c in d if e) a = [b for c in d if e] - a = {b: b for c in d if e} + a = {b:b for c in d if e} # function calls a() @@ -108,10 +108,8 @@ def f(): # closed over variables x = 1 - def closure(): - nonlocal x - a = x + 1 + nonlocal x; a = x + 1 x = 1 del x @@ -128,14 +126,12 @@ def f(): return return 1 - # function with lots of locals def f(): l1 = l2 = l3 = l4 = l5 = l6 = l7 = l8 = l9 = l10 = 1 m1 = m2 = m3 = m4 = m5 = m6 = m7 = m8 = m9 = m10 = 2 l10 + m10 - # functions with default args def f(a=1): pass @@ -143,19 +139,16 @@ def f(a=1): def f(b=2): return b + a - # function which yields def f(): yield yield 1 yield from 1 - # class class Class: pass - # delete name del Class diff --git a/tests/cmdline/cmd_showbc.py.exp b/tests/cmdline/cmd_showbc.py.exp index e13bf0abed..22712b79ee 100644 --- a/tests/cmdline/cmd_showbc.py.exp +++ b/tests/cmdline/cmd_showbc.py.exp @@ -1,13 +1,13 @@ File cmdline/cmd_showbc.py, code block '' (descriptor: \.\+, bytecode @\.\+ bytes) Raw bytecode (code_info_size=\\d\+, bytecode_size=\\d\+): ######## -\.\+51 63 +\.\+63 arg names: (N_STATE 3) (N_EXC_STACK 0) bc=0 line=1 ######## - bc=\\d\+ line=167 + bc=\\d\+ line=160 00 MAKE_FUNCTION \.\+ \\d\+ STORE_NAME f \\d\+ MAKE_FUNCTION \.\+ @@ -45,7 +45,7 @@ Raw bytecode (code_info_size=\\d\+, bytecode_size=\\d\+): (INIT_CELL 16) bc=0 line=1 ######## - bc=\\d\+ line=129 + bc=\\d\+ line=127 00 LOAD_CONST_NONE 01 LOAD_CONST_FALSE 02 BINARY_OP 27 __add__ @@ -92,10 +92,10 @@ Raw bytecode (code_info_size=\\d\+, bytecode_size=\\d\+): 58 BINARY_OP 27 __add__ \\d\+ STORE_FAST 8 \\d\+ LOAD_FAST 0 -\\d\+ UNARY_OP 1 +\\d\+ UNARY_OP 1 __neg__ \\d\+ STORE_FAST 9 \\d\+ LOAD_FAST 0 -\\d\+ UNARY_OP 3 +\\d\+ UNARY_OP 3 \\d\+ STORE_FAST 10 \\d\+ LOAD_FAST 0 \\d\+ LOAD_DEREF 14 @@ -116,14 +116,14 @@ Raw bytecode (code_info_size=\\d\+, bytecode_size=\\d\+): \\d\+ LOAD_DEREF 14 \\d\+ LOAD_FAST 1 \\d\+ BINARY_OP 2 __eq__ -\\d\+ UNARY_OP 3 +\\d\+ UNARY_OP 3 \\d\+ STORE_FAST 10 \\d\+ LOAD_DEREF 14 -\\d\+ LOAD_ATTR c (cache=0) +\\d\+ LOAD_ATTR c \\d\+ STORE_FAST 11 \\d\+ LOAD_FAST 11 \\d\+ LOAD_DEREF 14 -\\d\+ STORE_ATTR c (cache=0) +\\d\+ STORE_ATTR c \\d\+ LOAD_DEREF 14 \\d\+ LOAD_CONST_SMALL_INT 0 \\d\+ LOAD_SUBSCR @@ -233,7 +233,7 @@ Raw bytecode (code_info_size=\\d\+, bytecode_size=\\d\+): \\d\+ LOAD_DEREF 16 \\d\+ POP_TOP \\d\+ JUMP \\d\+ -\\d\+ LOAD_GLOBAL y (cache=0) +\\d\+ LOAD_GLOBAL y \\d\+ POP_TOP \\d\+ JUMP \\d\+ \\d\+ LOAD_DEREF 14 @@ -320,7 +320,7 @@ Raw bytecode (code_info_size=\\d\+, bytecode_size=\\d\+): (N_EXC_STACK 0) bc=0 line=1 ######## - bc=\\d\+ line=136 + bc=\\d\+ line=133 00 LOAD_CONST_SMALL_INT 1 01 DUP_TOP 02 STORE_FAST 0 @@ -376,7 +376,7 @@ arg names: a (N_EXC_STACK 0) (INIT_CELL 0) ######## - bc=\\d\+ line=143 + bc=\\d\+ line=139 00 LOAD_CONST_SMALL_INT 2 01 BUILD_TUPLE 1 03 LOAD_NULL @@ -393,9 +393,9 @@ arg names: (N_STATE 2) (N_EXC_STACK 0) bc=0 line=1 - bc=0 line=149 - bc=3 line=150 - bc=6 line=151 + bc=0 line=144 + bc=3 line=145 + bc=6 line=146 00 LOAD_CONST_NONE 01 YIELD_VALUE 02 POP_TOP @@ -418,13 +418,13 @@ arg names: (N_EXC_STACK 0) bc=0 line=1 ######## - bc=13 line=156 -00 LOAD_NAME __name__ (cache=0) -04 STORE_NAME __module__ -07 LOAD_CONST_STRING 'Class' -10 STORE_NAME __qualname__ -13 LOAD_CONST_NONE -14 RETURN_VALUE + bc=12 line=150 +00 LOAD_NAME __name__ +03 STORE_NAME __module__ +06 LOAD_CONST_STRING 'Class' +09 STORE_NAME __qualname__ +12 LOAD_CONST_NONE +13 RETURN_VALUE File cmdline/cmd_showbc.py, code block 'f' (descriptor: \.\+, bytecode @\.\+ bytes) Raw bytecode (code_info_size=\\d\+, bytecode_size=\\d\+): ######## @@ -433,9 +433,9 @@ arg names: self (N_STATE 4) (N_EXC_STACK 0) bc=0 line=1 - bc=0 line=164 -00 LOAD_GLOBAL super (cache=0) -\\d\+ LOAD_GLOBAL __class__ (cache=0) + bc=0 line=157 +00 LOAD_GLOBAL super +\\d\+ LOAD_GLOBAL __class__ \\d\+ LOAD_FAST 0 \\d\+ LOAD_SUPER_METHOD f \\d\+ CALL_METHOD n=0 nkw=0 @@ -517,7 +517,7 @@ arg names: * (N_EXC_STACK 0) bc=0 line=1 ######## - bc=\\d\+ line=116 + bc=\\d\+ line=114 00 LOAD_DEREF 0 02 LOAD_CONST_SMALL_INT 1 03 BINARY_OP 27 __add__ @@ -536,7 +536,7 @@ arg names: * b (N_EXC_STACK 0) bc=0 line=1 ######## - bc=\\d\+ line=144 + bc=\\d\+ line=140 00 LOAD_FAST 1 01 LOAD_DEREF 0 03 BINARY_OP 27 __add__ diff --git a/tests/cmdline/cmd_verbose.py.exp b/tests/cmdline/cmd_verbose.py.exp index a2fdf1f00d..0edd050c22 100644 --- a/tests/cmdline/cmd_verbose.py.exp +++ b/tests/cmdline/cmd_verbose.py.exp @@ -8,12 +8,12 @@ arg names: (N_EXC_STACK 0) bc=0 line=1 bc=0 line=3 -00 LOAD_NAME print (cache=0) -04 LOAD_CONST_SMALL_INT 1 -05 CALL_FUNCTION n=1 nkw=0 -07 POP_TOP -08 LOAD_CONST_NONE -09 RETURN_VALUE +00 LOAD_NAME print +03 LOAD_CONST_SMALL_INT 1 +04 CALL_FUNCTION n=1 nkw=0 +06 POP_TOP +07 LOAD_CONST_NONE +08 RETURN_VALUE 1 mem: total=\\d\+, current=\\d\+, peak=\\d\+ stack: \\d\+ out of \\d\+ diff --git a/tests/cpydiff/core_fstring_concat.py b/tests/cpydiff/core_fstring_concat.py index fd83527b5c..c2bdb4e666 100644 --- a/tests/cpydiff/core_fstring_concat.py +++ b/tests/cpydiff/core_fstring_concat.py @@ -1,12 +1,13 @@ """ categories: Core -description: f-strings don't support concatenation with adjacent literals if the adjacent literals contain braces +description: f-strings don't support concatenation with adjacent literals if the adjacent literals contain braces or are f-strings cause: MicroPython is optimised for code space. -workaround: Use the + operator between literal strings when either is an f-string +workaround: Use the + operator between literal strings when either or both are f-strings """ -x = 1 -print("aa" f"{x}") -print(f"{x}" "ab") -print("a{}a" f"{x}") -print(f"{x}" "a{}b") +x, y = 1, 2 +print("aa" f"{x}") # works +print(f"{x}" "ab") # works +print("a{}a" f"{x}") # fails +print(f"{x}" "a{}b") # fails +print(f"{x}" f"{y}") # fails diff --git a/tests/cpydiff/core_fstring_parser.py b/tests/cpydiff/core_fstring_parser.py index 6917f3cfa4..22bbc5866e 100644 --- a/tests/cpydiff/core_fstring_parser.py +++ b/tests/cpydiff/core_fstring_parser.py @@ -1,9 +1,9 @@ """ categories: Core -description: f-strings cannot support expressions that require parsing to resolve nested braces +description: f-strings cannot support expressions that require parsing to resolve unbalanced nested braces and brackets cause: MicroPython is optimised for code space. -workaround: Only use simple expressions inside f-strings +workaround: Always use balanced braces and brackets in expressions inside f-strings """ -f'{"hello {} world"}' -f"{repr({})}" +print(f'{"hello { world"}') +print(f'{"hello ] world"}') diff --git a/tests/cpydiff/modules_random_randint.py b/tests/cpydiff/modules_random_randint.py index b05908a157..90607400cd 100644 --- a/tests/cpydiff/modules_random_randint.py +++ b/tests/cpydiff/modules_random_randint.py @@ -8,5 +8,5 @@ workaround: If you need integers larger than native wordsize use the random modu import random -x = random.randint(2 ** 128 - 1, 2 ** 128) +x = random.randint(2**128 - 1, 2**128) print("x={}".format(x)) diff --git a/tests/extmod/uasyncio_gather.py b/tests/extmod/uasyncio_gather.py index 0e2948b07c..6053873dbc 100644 --- a/tests/extmod/uasyncio_gather.py +++ b/tests/extmod/uasyncio_gather.py @@ -22,8 +22,9 @@ async def factorial(name, number): async def task(id): print("start", id) - await asyncio.sleep(0.2) + await asyncio.sleep(0.02) print("end", id) + return id async def gather_task(): @@ -36,12 +37,17 @@ async def main(): # Simple gather with return values print(await asyncio.gather(factorial("A", 2), factorial("B", 3), factorial("C", 4))) + # Test return_exceptions, where one task is cancelled and the other finishes normally + tasks = [asyncio.create_task(task(1)), asyncio.create_task(task(2))] + tasks[0].cancel() + print(await asyncio.gather(*tasks, return_exceptions=True)) + # Cancel a multi gather # TODO doesn't work, Task should not forward cancellation from gather to sub-task # but rather CancelledError should cancel the gather directly, which will then cancel # all sub-tasks explicitly # t = asyncio.create_task(gather_task()) - # await asyncio.sleep(0.1) + # await asyncio.sleep(0.01) # t.cancel() # await asyncio.sleep(0.01) diff --git a/tests/extmod/uasyncio_gather.py.exp b/tests/extmod/uasyncio_gather.py.exp index a37578d7eb..95310bbe1c 100644 --- a/tests/extmod/uasyncio_gather.py.exp +++ b/tests/extmod/uasyncio_gather.py.exp @@ -8,3 +8,6 @@ Task B: factorial(3) = 6 Task C: Compute factorial(4)... Task C: factorial(4) = 24 [2, 6, 24] +start 2 +end 2 +[CancelledError(), 2] diff --git a/tests/extmod/uhashlib_sha1.py b/tests/extmod/uhashlib_sha1.py index a0ad8473a1..e6e6e30dc1 100644 --- a/tests/extmod/uhashlib_sha1.py +++ b/tests/extmod/uhashlib_sha1.py @@ -22,7 +22,7 @@ print(sha1.digest()) sha1 = hashlib.sha1(b"hello") try: - sha1.update(u"world") + sha1.update("world") except TypeError as e: print("TypeError") print(sha1.digest()) diff --git a/tests/extmod/uhashlib_sha256.py b/tests/extmod/uhashlib_sha256.py index ad5aa124cb..5c6dfd0a75 100644 --- a/tests/extmod/uhashlib_sha256.py +++ b/tests/extmod/uhashlib_sha256.py @@ -28,7 +28,7 @@ print(hashlib.sha256(b"\xff" * 56).digest()) sha256 = hashlib.sha256(b"hello") try: - sha256.update(u"world") + sha256.update("world") except TypeError as e: print("TypeError") print(sha256.digest()) diff --git a/tests/extmod/uselect_poll_udp.py b/tests/extmod/uselect_poll_udp.py index f6be262ee0..2a56a122b5 100644 --- a/tests/extmod/uselect_poll_udp.py +++ b/tests/extmod/uselect_poll_udp.py @@ -5,7 +5,9 @@ try: except ImportError: try: import socket, select - except ImportError: + + select.poll # Raises AttributeError for CPython implementations without poll() + except (ImportError, AttributeError): print("SKIP") raise SystemExit diff --git a/tests/float/complex1.py b/tests/float/complex1.py index a510ffc830..139bb0c509 100644 --- a/tests/float/complex1.py +++ b/tests/float/complex1.py @@ -27,15 +27,15 @@ print(1j * 2j) print(1j / 2) print((1j / 2j).real) print(1j / (1 + 2j)) -ans = 0j ** 0 +ans = 0j**0 print("%.5g %.5g" % (ans.real, ans.imag)) -ans = 0j ** 1 +ans = 0j**1 print("%.5g %.5g" % (ans.real, ans.imag)) -ans = 0j ** 0j +ans = 0j**0j print("%.5g %.5g" % (ans.real, ans.imag)) -ans = 1j ** 2.5 +ans = 1j**2.5 print("%.5g %.5g" % (ans.real, ans.imag)) -ans = 1j ** 2.5j +ans = 1j**2.5j print("%.5g %.5g" % (ans.real, ans.imag)) # comparison @@ -116,10 +116,10 @@ except ZeroDivisionError: # zero division via power try: - 0j ** -1 + 0j**-1 except ZeroDivisionError: print("ZeroDivisionError") try: - 0j ** 1j + 0j**1j except ZeroDivisionError: print("ZeroDivisionError") diff --git a/tests/float/float1.py b/tests/float/float1.py index efde5146be..37f8b3face 100644 --- a/tests/float/float1.py +++ b/tests/float/float1.py @@ -88,7 +88,7 @@ except ZeroDivisionError: print("ZeroDivisionError") try: - 0.0 ** -1 + 0.0**-1 except ZeroDivisionError: print("ZeroDivisionError") diff --git a/tests/float/float2int_doubleprec_intbig.py b/tests/float/float2int_doubleprec_intbig.py index 84fa2d2536..1226b39ca9 100644 --- a/tests/float/float2int_doubleprec_intbig.py +++ b/tests/float/float2int_doubleprec_intbig.py @@ -35,8 +35,8 @@ if ll_type != 0: print(int(1418774543.0)) print("%d" % 1418774543.0) if ll_type == 3: - print(int(2.0 ** 100)) - print("%d" % 2.0 ** 100) + print(int(2.0**100)) + print("%d" % 2.0**100) else: print(int(1073741823.0)) print("%d" % 1073741823.0) @@ -44,7 +44,7 @@ else: testpass = True p2_rng = ((30, 63, 1024), (62, 63, 1024))[is_64bit][ll_type] for i in range(0, p2_rng): - bitcnt = len(bin(int(2.0 ** i))) - 3 + bitcnt = len(bin(int(2.0**i))) - 3 if i != bitcnt: print("fail: 2**%u was %u bits long" % (i, bitcnt)) testpass = False @@ -53,7 +53,7 @@ print("power of 2 test: %s" % (testpass and "passed" or "failed")) testpass = True p10_rng = ((9, 18, 23), (18, 18, 23))[is_64bit][ll_type] for i in range(0, p10_rng): - digcnt = len(str(int(10.0 ** i))) - 1 + digcnt = len(str(int(10.0**i))) - 1 if i != digcnt: print("fail: 10**%u was %u digits long" % (i, digcnt)) testpass = False @@ -72,28 +72,28 @@ def fp2int_test(num, name, should_fail): if ll_type != 2: if ll_type == 0: if is_64bit: - neg_bad_fp = -1.00000005 * 2.0 ** 62.0 - pos_bad_fp = 2.0 ** 62.0 - neg_good_fp = -(2.0 ** 62.0) - pos_good_fp = 0.99999993 * 2.0 ** 62.0 + neg_bad_fp = -1.00000005 * 2.0**62.0 + pos_bad_fp = 2.0**62.0 + neg_good_fp = -(2.0**62.0) + pos_good_fp = 0.99999993 * 2.0**62.0 else: - neg_bad_fp = -1.00000005 * 2.0 ** 30.0 - pos_bad_fp = 2.0 ** 30.0 - neg_good_fp = -(2.0 ** 30.0) - pos_good_fp = 0.9999999499 * 2.0 ** 30.0 + neg_bad_fp = -1.00000005 * 2.0**30.0 + pos_bad_fp = 2.0**30.0 + neg_good_fp = -(2.0**30.0) + pos_good_fp = 0.9999999499 * 2.0**30.0 else: - neg_bad_fp = -0.51 * 2.0 ** 64.0 - pos_bad_fp = 2.0 ** 63.0 - neg_good_fp = -(2.0 ** 63.0) - pos_good_fp = 1.9999998 * 2.0 ** 62.0 + neg_bad_fp = -0.51 * 2.0**64.0 + pos_bad_fp = 2.0**63.0 + neg_good_fp = -(2.0**63.0) + pos_good_fp = 1.9999998 * 2.0**62.0 fp2int_test(neg_bad_fp, "neg bad", True) fp2int_test(pos_bad_fp, "pos bad", True) fp2int_test(neg_good_fp, "neg good", False) fp2int_test(pos_good_fp, "pos good", False) else: - fp2int_test(-1.9999999999999981 * 2.0 ** 1023.0, "large neg", False) - fp2int_test(1.9999999999999981 * 2.0 ** 1023.0, "large pos", False) + fp2int_test(-1.9999999999999981 * 2.0**1023.0, "large neg", False) + fp2int_test(1.9999999999999981 * 2.0**1023.0, "large pos", False) fp2int_test(float("inf"), "inf test", True) fp2int_test(float("-inf"), "inf test", True) diff --git a/tests/float/float2int_fp30_intbig.py b/tests/float/float2int_fp30_intbig.py index 75ff52f39d..a1bfe67046 100644 --- a/tests/float/float2int_fp30_intbig.py +++ b/tests/float/float2int_fp30_intbig.py @@ -34,13 +34,13 @@ if ll_type is None: print(int(14187744.0)) print("%d" % 14187744.0) if ll_type == 2: - print(int(2.0 ** 100)) - print("%d" % 2.0 ** 100) + print(int(2.0**100)) + print("%d" % 2.0**100) testpass = True p2_rng = ((30, 63, 127), (62, 63, 127))[is_64bit][ll_type] for i in range(0, p2_rng): - bitcnt = len(bin(int(2.0 ** i))) - 3 + bitcnt = len(bin(int(2.0**i))) - 3 if i != bitcnt: print("fail: 2.**%u was %u bits long" % (i, bitcnt)) testpass = False @@ -50,7 +50,7 @@ print("power of 2 test: %s" % (testpass and "passed" or "failed")) testpass = True p10_rng = 9 for i in range(0, p10_rng): - digcnt = len(str(int(10.0 ** i))) - 1 + digcnt = len(str(int(10.0**i))) - 1 if i != digcnt: print("fail: 10.**%u was %u digits long" % (i, digcnt)) testpass = False @@ -69,28 +69,28 @@ def fp2int_test(num, name, should_fail): if ll_type != 2: if ll_type == 0: if is_64bit: - neg_bad_fp = -1.00000005 * 2.0 ** 62.0 - pos_bad_fp = 2.0 ** 62.0 - neg_good_fp = -(2.0 ** 62.0) - pos_good_fp = 0.99999993 * 2.0 ** 62.0 + neg_bad_fp = -1.00000005 * 2.0**62.0 + pos_bad_fp = 2.0**62.0 + neg_good_fp = -(2.0**62.0) + pos_good_fp = 0.99999993 * 2.0**62.0 else: - neg_bad_fp = -1.00000005 * 2.0 ** 30.0 - pos_bad_fp = 2.0 ** 30.0 - neg_good_fp = -(2.0 ** 30.0) - pos_good_fp = 0.9999999499 * 2.0 ** 30.0 + neg_bad_fp = -1.00000005 * 2.0**30.0 + pos_bad_fp = 2.0**30.0 + neg_good_fp = -(2.0**30.0) + pos_good_fp = 0.9999999499 * 2.0**30.0 else: - neg_bad_fp = -0.51 * 2.0 ** 64.0 - pos_bad_fp = 2.0 ** 63.0 - neg_good_fp = -(2.0 ** 63.0) - pos_good_fp = 1.9999998 * 2.0 ** 62.0 + neg_bad_fp = -0.51 * 2.0**64.0 + pos_bad_fp = 2.0**63.0 + neg_good_fp = -(2.0**63.0) + pos_good_fp = 1.9999998 * 2.0**62.0 fp2int_test(neg_bad_fp, "neg bad", True) fp2int_test(pos_bad_fp, "pos bad", True) fp2int_test(neg_good_fp, "neg good", False) fp2int_test(pos_good_fp, "pos good", False) else: - fp2int_test(-1.999999879 * 2.0 ** 126.0, "large neg", False) - fp2int_test(1.999999879 * 2.0 ** 126.0, "large pos", False) + fp2int_test(-1.999999879 * 2.0**126.0, "large neg", False) + fp2int_test(1.999999879 * 2.0**126.0, "large pos", False) fp2int_test(float("inf"), "inf test", True) fp2int_test(float("-inf"), "inf test", True) diff --git a/tests/float/float2int_intbig.py b/tests/float/float2int_intbig.py index 62aca39634..06b651bb72 100644 --- a/tests/float/float2int_intbig.py +++ b/tests/float/float2int_intbig.py @@ -37,13 +37,13 @@ print(int(14187745.)) print("%d" % 14187745.) # fmt: on if ll_type == 2: - print(int(2.0 ** 100)) - print("%d" % 2.0 ** 100) + print(int(2.0**100)) + print("%d" % 2.0**100) testpass = True p2_rng = ((30, 63, 127), (62, 63, 127))[is_64bit][ll_type] for i in range(0, p2_rng): - bitcnt = len(bin(int(2.0 ** i))) - 3 + bitcnt = len(bin(int(2.0**i))) - 3 if i != bitcnt: print("fail: 2.**%u was %u bits long" % (i, bitcnt)) testpass = False @@ -53,7 +53,7 @@ print("power of 2 test: %s" % (testpass and "passed" or "failed")) testpass = True p10_rng = 9 if (ll_type == 0 and ~is_64bit) else 11 for i in range(0, p10_rng): - digcnt = len(str(int(10.0 ** i))) - 1 + digcnt = len(str(int(10.0**i))) - 1 if i != digcnt: print("fail: 10.**%u was %u digits long" % (i, digcnt)) testpass = False @@ -72,28 +72,28 @@ def fp2int_test(num, name, should_fail): if ll_type != 2: if ll_type == 0: if is_64bit: - neg_bad_fp = -1.00000005 * 2.0 ** 62.0 - pos_bad_fp = 2.0 ** 62.0 - neg_good_fp = -(2.0 ** 62.0) - pos_good_fp = 0.99999993 * 2.0 ** 62.0 + neg_bad_fp = -1.00000005 * 2.0**62.0 + pos_bad_fp = 2.0**62.0 + neg_good_fp = -(2.0**62.0) + pos_good_fp = 0.99999993 * 2.0**62.0 else: - neg_bad_fp = -1.00000005 * 2.0 ** 30.0 - pos_bad_fp = 2.0 ** 30.0 - neg_good_fp = -(2.0 ** 30.0) - pos_good_fp = 0.9999999499 * 2.0 ** 30.0 + neg_bad_fp = -1.00000005 * 2.0**30.0 + pos_bad_fp = 2.0**30.0 + neg_good_fp = -(2.0**30.0) + pos_good_fp = 0.9999999499 * 2.0**30.0 else: - neg_bad_fp = -0.51 * 2.0 ** 64.0 - pos_bad_fp = 2.0 ** 63.0 - neg_good_fp = -(2.0 ** 63.0) - pos_good_fp = 1.9999998 * 2.0 ** 62.0 + neg_bad_fp = -0.51 * 2.0**64.0 + pos_bad_fp = 2.0**63.0 + neg_good_fp = -(2.0**63.0) + pos_good_fp = 1.9999998 * 2.0**62.0 fp2int_test(neg_bad_fp, "neg bad", True) fp2int_test(pos_bad_fp, "pos bad", True) fp2int_test(neg_good_fp, "neg good", False) fp2int_test(pos_good_fp, "pos good", False) else: - fp2int_test(-1.999999879 * 2.0 ** 127.0, "large neg", False) - fp2int_test(1.999999879 * 2.0 ** 127.0, "large pos", False) + fp2int_test(-1.999999879 * 2.0**127.0, "large neg", False) + fp2int_test(1.999999879 * 2.0**127.0, "large pos", False) fp2int_test(float("inf"), "inf test", True) fp2int_test(float("nan"), "NaN test", True) diff --git a/tests/float/inf_nan_arith.py b/tests/float/inf_nan_arith.py index c27e38bc52..d1a6b18872 100644 --- a/tests/float/inf_nan_arith.py +++ b/tests/float/inf_nan_arith.py @@ -14,7 +14,7 @@ for x in values: except ZeroDivisionError: print(" / ZeroDivisionError") try: - print(" ** pow", x ** y, pow(x, y)) + print(" ** pow", x**y, pow(x, y)) except ZeroDivisionError: print(" ** pow ZeroDivisionError") print(" == != < <= > >=", x == y, x != y, x < y, x <= y, x > y, x >= y) diff --git a/tests/float/int_big_float.py b/tests/float/int_big_float.py index 0bd1662186..dc13e8e0dd 100644 --- a/tests/float/int_big_float.py +++ b/tests/float/int_big_float.py @@ -19,7 +19,7 @@ print("%.5g" % (i / 1.2)) print("%.5g" % (i * 1.2j).imag) # negative power should produce float -print("%.5g" % (i ** -1)) +print("%.5g" % (i**-1)) print("%.5g" % ((2 + i - i) ** -3)) try: diff --git a/tests/float/int_divzero.py b/tests/float/int_divzero.py index b311a1dbcf..ef3531bee8 100644 --- a/tests/float/int_divzero.py +++ b/tests/float/int_divzero.py @@ -4,6 +4,6 @@ except ZeroDivisionError: print("ZeroDivisionError") try: - 0 ** -1 + 0**-1 except ZeroDivisionError: print("ZeroDivisionError") diff --git a/tests/float/int_power.py b/tests/float/int_power.py index ba79247a56..bcda0f98ed 100644 --- a/tests/float/int_power.py +++ b/tests/float/int_power.py @@ -1,7 +1,7 @@ # negative power should produce float x = 2 -print(x ** -2) +print(x**-2) x = 3 x **= -2 diff --git a/tests/import/mpy_native.py b/tests/import/mpy_native.py deleted file mode 100644 index bab5f91d53..0000000000 --- a/tests/import/mpy_native.py +++ /dev/null @@ -1,125 +0,0 @@ -# test importing of .mpy files with native code (x64 only) - -import sys, uio - -try: - uio.IOBase - import uos - - uos.mount -except (ImportError, AttributeError): - print("SKIP") - raise SystemExit - -if not (sys.platform == "linux" and sys.maxsize > 2 ** 32): - print("SKIP") - raise SystemExit - - -class UserFile(uio.IOBase): - def __init__(self, data): - self.data = data - self.pos = 0 - - def read(self): - return self.data - - def readinto(self, buf): - n = 0 - while n < len(buf) and self.pos < len(self.data): - buf[n] = self.data[self.pos] - n += 1 - self.pos += 1 - return n - - def ioctl(self, req, arg): - return 0 - - -class UserFS: - def __init__(self, files): - self.files = files - - def mount(self, readonly, mksfs): - pass - - def umount(self): - pass - - def stat(self, path): - if path in self.files: - return (32768, 0, 0, 0, 0, 0, 0, 0, 0, 0) - raise OSError - - def open(self, path, mode): - return UserFile(self.files[path]) - - -# these are the test .mpy files -user_files = { - # bad architecture - "/mod0.mpy": b"C\x05\xff\x00\x10", - # test loading of viper and asm - "/mod1.mpy": ( - b"C\x05\x0b\x1f\x20" # header - b"\x20" # n bytes, bytecode - b"\x00\x08\x02m\x02m" # prelude - b"\x51" # LOAD_CONST_NONE - b"\x63" # RETURN_VALUE - b"\x00\x02" # n_obj, n_raw_code - b"\x22" # n bytes, viper code - b"\x00\x00\x00\x00\x00\x00" # dummy machine code - b"\x00\x00" # qstr0 - b"\x01\x0c\x0aprint" # n_qstr, qstr0 - b"\x00\x00\x00" # scope_flags, n_obj, n_raw_code - b"\x23" # n bytes, asm code - b"\x00\x00\x00\x00\x00\x00\x00\x00" # dummy machine code - b"\x00\x00\x00" # scope_flags, n_pos_args, type_sig - ), - # test loading viper with truncated data - "/mod2.mpy": ( - b"C\x05\x0b\x1f\x20" # header - b"\x20" # n bytes, bytecode - b"\x00\x08\x02m\x02m" # prelude - b"\x51" # LOAD_CONST_NONE - b"\x63" # RETURN_VALUE - b"\x00\x01" # n_obj, n_raw_code - b"\x12" # n bytes(=4), viper code - ), - # test loading viper with additional scope flags and relocation - "/mod3.mpy": ( - b"C\x05\x0b\x1f\x20" # header - b"\x20" # n bytes, bytecode - b"\x00\x08\x02m\x02m" # prelude - b"\x51" # LOAD_CONST_NONE - b"\x63" # RETURN_VALUE - b"\x00\x01" # n_obj, n_raw_code - b"\x12" # n bytes(=4), viper code - b"\x00\x00\x00\x00" # dummy machine code - b"\x00" # n_qstr - b"\x81\x60" # scope_flags: VIPERBSS | VIPERRODATA | VIPERRELOC (0xe0 encoded over two bytes) - b"\x00\x00" # n_obj, n_raw_code - b"\x06rodata" # rodata, 6 bytes - b"\x04" # bss, 4 bytes - b"\x03\x01\x00" # dummy relocation of rodata - ), -} - -# create and mount a user filesystem -uos.mount(UserFS(user_files), "/userfs") -sys.path.append("/userfs") - -# import .mpy files from the user filesystem -for i in range(len(user_files)): - mod = "mod%u" % i - try: - __import__(mod) - print(mod, "OK") - except ValueError as er: - print(mod, "ValueError", er) - except RuntimeError as er: - print(mod, "RuntimeError", er) - -# unmount and undo path addition -uos.umount("/userfs") -sys.path.pop() diff --git a/tests/import/mpy_native.py.exp b/tests/import/mpy_native.py.exp deleted file mode 100644 index 8ebfa81864..0000000000 --- a/tests/import/mpy_native.py.exp +++ /dev/null @@ -1,4 +0,0 @@ -mod0 ValueError incompatible native .mpy architecture -mod1 OK -mod2 RuntimeError Corrupt .mpy file -mod3 OK diff --git a/tests/io/resource_stream.py b/tests/io/resource_stream.py deleted file mode 100644 index 5656205b69..0000000000 --- a/tests/io/resource_stream.py +++ /dev/null @@ -1,15 +0,0 @@ -import uio -import sys - -try: - uio.resource_stream -except AttributeError: - print("SKIP") - raise SystemExit - -buf = uio.resource_stream("data", "file2") -print(buf.read()) - -# resource_stream(None, ...) look ups from current dir, hence sys.path[0] hack -buf = uio.resource_stream(None, sys.path[0] + "/data/file2") -print(buf.read()) diff --git a/tests/io/resource_stream.py.exp b/tests/io/resource_stream.py.exp deleted file mode 100644 index 75404a347a..0000000000 --- a/tests/io/resource_stream.py.exp +++ /dev/null @@ -1,2 +0,0 @@ -1234 -1234 diff --git a/tests/micropython/const.py b/tests/micropython/const.py index 1faf22be9a..1c805a45f9 100644 --- a/tests/micropython/const.py +++ b/tests/micropython/const.py @@ -1,4 +1,5 @@ # test constant optimisation +# This test will only work when MICROPY_COMP_CONST is enabled. from micropython import const diff --git a/tests/micropython/import_mpy_native_gc.py b/tests/micropython/import_mpy_native_gc.py index 9c00f7984d..58291449ce 100644 --- a/tests/micropython/import_mpy_native_gc.py +++ b/tests/micropython/import_mpy_native_gc.py @@ -48,8 +48,8 @@ class UserFS: # Pre-compiled examples/natmod/features0 example for various architectures, keyed # by the required value of sys.implementation.mpy. features0_file_contents = { - # -march=x64 -mcache-lookup-bc - 0xB05: b'C\x05\x0b\x1f \x84b\xe9/\x00\x00\x00SH\x8b\x1ds\x00\x00\x00\xbe\x02\x00\x00\x00\xffS\x18\xbf\x01\x00\x00\x00H\x85\xc0u\x0cH\x8bC \xbe\x02\x00\x00\x00[\xff\xe0H\x0f\xaf\xf8H\xff\xc8\xeb\xe6ATUSH\x8b\x1dA\x00\x00\x00H\x8b\x7f\x08H\x8bk(\xff\xd5H\x8d5 \x00\x00\x00I\x89\xc4H\x8b\x05.\x00\x00\x00\x0f\xb78\xffShL\x89\xe7\xff\xd5H\x8b\x03[]A\\\xc3\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x90\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x84@\x12factorial \x00\x00\r \x01"\xa1\x1c\x01\x1e\xff', + # -march=x64 + 0xA05: b'C\x05\x0a\x1f \x84b\xe9/\x00\x00\x00SH\x8b\x1ds\x00\x00\x00\xbe\x02\x00\x00\x00\xffS\x18\xbf\x01\x00\x00\x00H\x85\xc0u\x0cH\x8bC \xbe\x02\x00\x00\x00[\xff\xe0H\x0f\xaf\xf8H\xff\xc8\xeb\xe6ATUSH\x8b\x1dA\x00\x00\x00H\x8b\x7f\x08L\x8bc(A\xff\xd4H\x8d5\x1f\x00\x00\x00H\x89\xc5H\x8b\x05-\x00\x00\x00\x0f\xb78\xffShH\x89\xefA\xff\xd4H\x8b\x03[]A\\\xc3\x00\x00\x00\x00\x00\x00\x00\x00\x00\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x90\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x84@\x12factorial \x00\x00\r \x01"\xa1\x1c\x01\x1e\xff', # -march=armv7m 0x1605: b"C\x05\x16\x1f \x84\x12\x1a\xe0\x00\x00\x13\xb5\nK\nJ{D\x9cX\x02!\xe3h\x98G\x03F\x01 3\xb9\x02!#i\x01\x93\x02\xb0\xbd\xe8\x10@\x18GXC\x01;\xf4\xe7\x00\xbfj\x00\x00\x00\x00\x00\x00\x00\xf8\xb5\tN\tK~D\xf4X@hgi\xb8G\x05F\x07K\x07I\xf2XyD\x10\x88ck\x98G(F\xb8G h\xf8\xbd6\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x1c\x00\x00\x00\x00\x00\x00\x00\x05\x00\x00\x00\x00\x00\x00\x00\x80\x00\x00\x00\x00\x00\x00\x00\x01\x84\x00\x12factorial \x00\x00\r<\x01>\xa18\x01:\xff", } diff --git a/tests/micropython/import_mpy_native_x64.py b/tests/micropython/import_mpy_native_x64.py index 7597843220..c8379e177a 100644 --- a/tests/micropython/import_mpy_native_x64.py +++ b/tests/micropython/import_mpy_native_x64.py @@ -9,7 +9,7 @@ except (ImportError, AttributeError): print("SKIP") raise SystemExit -if not (sys.platform == "linux" and sys.maxsize > 2 ** 32): +if not (sys.platform == "linux" and sys.maxsize > 2**32): print("SKIP") raise SystemExit @@ -52,11 +52,11 @@ class UserFS: # fmt: off user_files = { # bad architecture - '/mod0.mpy': b'C\x05\xff\x00\x10', + '/mod0.mpy': b'C\x05\xfe\x00\x10', # test loading of viper and asm '/mod1.mpy': ( - b'C\x05\x0b\x1f\x20' # header + b'C\x05\x0a\x1f\x20' # header b'\x20' # n bytes, bytecode b'\x00\x08\x02m\x02m' # prelude @@ -78,7 +78,7 @@ user_files = { # test loading viper with additional scope flags and relocation '/mod2.mpy': ( - b'C\x05\x0b\x1f\x20' # header + b'C\x05\x0a\x1f\x20' # header b'\x20' # n bytes, bytecode b'\x00\x08\x02m\x02m' # prelude diff --git a/tests/micropython/viper_subscr_multi.py b/tests/micropython/viper_subscr_multi.py new file mode 100644 index 0000000000..1561e5534d --- /dev/null +++ b/tests/micropython/viper_subscr_multi.py @@ -0,0 +1,20 @@ +# test viper with multiple subscripts in a single expression + + +@micropython.viper +def f1(b: ptr8): + b[0] += b[1] + + +@micropython.viper +def f2(b: ptr8, i: int): + b[0] += b[i] + + +b = bytearray(b"\x01\x02") +f1(b) +print(b) + +b = bytearray(b"\x01\x02") +f2(b, 1) +print(b) diff --git a/tests/micropython/viper_subscr_multi.py.exp b/tests/micropython/viper_subscr_multi.py.exp new file mode 100644 index 0000000000..a2c298bb16 --- /dev/null +++ b/tests/micropython/viper_subscr_multi.py.exp @@ -0,0 +1,2 @@ +bytearray(b'\x03\x02') +bytearray(b'\x03\x02') diff --git a/tests/misc/non_compliant.py b/tests/misc/non_compliant.py index f745c30e8e..cff1894106 100644 --- a/tests/misc/non_compliant.py +++ b/tests/misc/non_compliant.py @@ -54,8 +54,8 @@ except NotImplementedError: # str(...) with keywords not implemented try: str(b"abc", encoding="utf8") -except NotImplementedError: - print("NotImplementedError") +except TypeError: + print("TypeError") # str.rsplit(None, n) not implemented try: diff --git a/tests/misc/non_compliant.py.exp b/tests/misc/non_compliant.py.exp index 8518828ec3..9348d5959e 100644 --- a/tests/misc/non_compliant.py.exp +++ b/tests/misc/non_compliant.py.exp @@ -5,7 +5,7 @@ NotImplementedError NotImplementedError TypeError, ValueError NotImplementedError -NotImplementedError +TypeError NotImplementedError NotImplementedError NotImplementedError diff --git a/tests/misc/rge_sm.py b/tests/misc/rge_sm.py index f3bb4189f7..00b0a7a021 100644 --- a/tests/misc/rge_sm.py +++ b/tests/misc/rge_sm.py @@ -52,12 +52,12 @@ class RungeKutta(object): # couplings are: g1, g2, g3 of U(1), SU(2), SU(3); yt (top Yukawa), lambda (Higgs quartic) # see arxiv.org/abs/0812.4950, eqs 10-15 sysSM = ( - lambda *a: 41.0 / 96.0 / math.pi ** 2 * a[1] ** 3, # g1 - lambda *a: -19.0 / 96.0 / math.pi ** 2 * a[2] ** 3, # g2 - lambda *a: -42.0 / 96.0 / math.pi ** 2 * a[3] ** 3, # g3 + lambda *a: 41.0 / 96.0 / math.pi**2 * a[1] ** 3, # g1 + lambda *a: -19.0 / 96.0 / math.pi**2 * a[2] ** 3, # g2 + lambda *a: -42.0 / 96.0 / math.pi**2 * a[3] ** 3, # g3 lambda *a: 1.0 / 16.0 - / math.pi ** 2 + / math.pi**2 * ( 9.0 / 2.0 * a[4] ** 3 - 8.0 * a[3] ** 2 * a[4] @@ -66,7 +66,7 @@ sysSM = ( ), # yt lambda *a: 1.0 / 16.0 - / math.pi ** 2 + / math.pi**2 * ( 24.0 * a[5] ** 2 + 12.0 * a[4] ** 2 * a[5] @@ -137,5 +137,5 @@ def singleTraj(system, trajStart, h=0.02, tend=1.0): # initial conditions at M_Z singleTraj( - sysSM, [0.354, 0.654, 1.278, 0.983, 0.131], h=0.5, tend=math.log(10 ** 17) + sysSM, [0.354, 0.654, 1.278, 0.983, 0.131], h=0.5, tend=math.log(10**17) ) # true values diff --git a/tests/perf_bench/bm_chaos.py b/tests/perf_bench/bm_chaos.py index 55d282561f..d0f1337db7 100644 --- a/tests/perf_bench/bm_chaos.py +++ b/tests/perf_bench/bm_chaos.py @@ -15,7 +15,7 @@ class GVector(object): self.z = z def Mag(self): - return math.sqrt(self.x ** 2 + self.y ** 2 + self.z ** 2) + return math.sqrt(self.x**2 + self.y**2 + self.z**2) def dist(self, other): return math.sqrt( diff --git a/tests/perf_bench/bm_fft.py b/tests/perf_bench/bm_fft.py index fb79a9fd28..9a2d03d11b 100644 --- a/tests/perf_bench/bm_fft.py +++ b/tests/perf_bench/bm_fft.py @@ -15,7 +15,7 @@ def transform_radix2(vector, inverse): # Initialization n = len(vector) - levels = int(math.log2(n)) + levels = int(math.log(n) / math.log(2)) coef = (2 if inverse else -2) * cmath.pi / n exptable = [cmath.rect(1, i * coef) for i in range(n // 2)] vector = [vector[reverse(i, levels)] for i in range(n)] # Copy with bit-reversed permutation diff --git a/tests/perf_bench/misc_raytrace.py b/tests/perf_bench/misc_raytrace.py index b51acaccac..a729af99c2 100644 --- a/tests/perf_bench/misc_raytrace.py +++ b/tests/perf_bench/misc_raytrace.py @@ -22,7 +22,7 @@ class Vec: return Vec(self.x * rhs, self.y * rhs, self.z * rhs) def length(self): - return (self.x ** 2 + self.y ** 2 + self.z ** 2) ** 0.5 + return (self.x**2 + self.y**2 + self.z**2) ** 0.5 def normalise(self): l = self.length() @@ -87,12 +87,12 @@ class Sphere: def __init__(self, surface, centre, radius): self.surface = surface self.centre = centre - self.radsq = radius ** 2 + self.radsq = radius**2 def intersect(self, ray): v = self.centre - ray.p b = v.dot(ray.d) - det = b ** 2 - v.dot(v) + self.radsq + det = b**2 - v.dot(v) + self.radsq if det > 0: det **= 0.5 t1 = b - det @@ -180,7 +180,7 @@ def trace_ray(scene, ray, depth): if ndotl > 0: col += light_col * surf.diffuse * ndotl if ldotv > 0: - col += light_col * surf.specular * ldotv ** surf.spec_idx + col += light_col * surf.specular * ldotv**surf.spec_idx # Reflections if depth > 0 and surf.reflect > 0: diff --git a/tests/pyboard.py b/tests/pyboard.py index 582a1f894f..616773a313 120000 --- a/tests/pyboard.py +++ b/tests/pyboard.py @@ -1 +1 @@ -../tools/cpboard.py +../tools/cpboard.py \ No newline at end of file diff --git a/tests/run-natmodtests.py b/tests/run-natmodtests.py index f88ca0b788..a957fbb6b6 100755 --- a/tests/run-natmodtests.py +++ b/tests/run-natmodtests.py @@ -9,9 +9,6 @@ import subprocess import sys import argparse -sys.path.append("../tools") -import pyboard - # Paths for host executables CPYTHON3 = os.getenv("MICROPY_CPYTHON3", "python3") MICROPYTHON = os.getenv("MICROPY_MICROPYTHON", "../ports/unix/micropython-coverage") @@ -178,6 +175,10 @@ def main(): target_truth = TargetSubprocess([CPYTHON3]) if args.pyboard: + global pyboard + sys.path.append("../tools") + import pyboard + target = TargetPyboard(pyboard.Pyboard(args.device)) else: target = TargetSubprocess([MICROPYTHON]) diff --git a/tests/run-perfbench.py b/tests/run-perfbench.py index bcdbe69abb..5f299281fd 100755 --- a/tests/run-perfbench.py +++ b/tests/run-perfbench.py @@ -33,8 +33,8 @@ def compute_stats(lst): avg += x var += x * x avg /= len(lst) - var = max(0, var / len(lst) - avg ** 2) - return avg, var ** 0.5 + var = max(0, var / len(lst) - avg**2) + return avg, var**0.5 def run_script_on_target(target, script): @@ -201,7 +201,7 @@ def compute_diff(file1, file2, diff_score): sd1 *= av1 / 100 # convert from percent sd to absolute sd sd2 *= av2 / 100 # convert from percent sd to absolute sd av_diff = av2 - av1 - sd_diff = (sd1 ** 2 + sd2 ** 2) ** 0.5 + sd_diff = (sd1**2 + sd2**2) ** 0.5 percent = 100 * av_diff / av1 percent_sd = 100 * sd_diff / av1 print( diff --git a/tests/run-tests.py b/tests/run-tests.py index 34372590a2..a6d08aabb3 100755 --- a/tests/run-tests.py +++ b/tests/run-tests.py @@ -112,7 +112,7 @@ def run_micropython(pyb, args, test_file, is_special=False): def get(required=False): rv = b"" while True: - ready = select.select([emulator], [], [], 0.02) + ready = select.select([emulator], [], [emulator], 0.02) if ready[0] == [emulator]: rv += os.read(emulator, 1024) else: @@ -150,8 +150,8 @@ def run_micropython(pyb, args, test_file, is_special=False): p.kill() except ProcessLookupError: pass - os.close(emulator) os.close(subterminal) + os.close(emulator) else: output_mupy = subprocess.check_output( args + [test_file], stderr=subprocess.STDOUT @@ -757,9 +757,7 @@ the last matching regex is used: cmd_parser.add_argument( "--via-mpy", action="store_true", help="compile .py files to .mpy first" ) - cmd_parser.add_argument( - "--mpy-cross-flags", default="-mcache-lookup-bc", help="flags to pass to mpy-cross" - ) + cmd_parser.add_argument("--mpy-cross-flags", default="", help="flags to pass to mpy-cross") cmd_parser.add_argument( "--keep-path", action="store_true", help="do not clear MICROPYPATH when running tests" ) @@ -871,7 +869,7 @@ the last matching regex is used: if not args.keep_path: # clear search path to make sure tests use only builtin modules and those in extmod - os.environ["MICROPYPATH"] = os.pathsep + base_path("../extmod") + os.environ["MICROPYPATH"] = os.pathsep + ".frozen" + os.pathsep + base_path("../extmod") try: os.makedirs(args.result_dir, exist_ok=True) diff --git a/tests/unix/extra_coverage.py b/tests/unix/extra_coverage.py index b4808993a7..8ea27cbf2f 100644 --- a/tests/unix/extra_coverage.py +++ b/tests/unix/extra_coverage.py @@ -89,12 +89,6 @@ try: except ZeroDivisionError: print("ZeroDivisionError") -# test loading a resource from a frozen string -import uio - -buf = uio.resource_stream("frzstr_pkg2", "mod.py") -print(buf.read(21)) - # test for MP_QSTR_NULL regression from frzqstr import returns_NULL diff --git a/tests/unix/extra_coverage.py.exp b/tests/unix/extra_coverage.py.exp index 4cce80a412..fb97e5a6b7 100644 --- a/tests/unix/extra_coverage.py.exp +++ b/tests/unix/extra_coverage.py.exp @@ -29,25 +29,29 @@ RuntimeError: ame__ mport -builtins micropython _thread aesio -array binascii bitmaptools btree -cexample cmath collections cppexample -displayio errno ffi framebuf -gc gifio hashlib json -math qrio rainbowio re -sys termios traceback ubinascii -uctypes uerrno uheapq uio -ujson ulab uos urandom -ure uselect ustruct utime -utimeq uzlib +builtins micropython _asyncio _thread +_uasyncio aesio array binascii +bitmaptools btree cexample cmath +collections cppexample displayio errno +ffi framebuf gc gifio +hashlib json math qrio +rainbowio re sys termios +traceback ubinascii uctypes uerrno +uheapq uio ujson ulab +ulab.fft ulab.linalg ulab.numpy ulab.scipy +ulab.scipy.linalg ulab.scipy.optimize +ulab.scipy.signal ulab.scipy.special +ulab.utils uos urandom ure +uselect ustruct utime utimeq +uzlib ime utime utimeq -argv byteorder exc_info exit -getsizeof implementation maxsize modules -path platform stderr stdin -stdout version version_info +argv atexit byteorder exc_info +exit getsizeof implementation maxsize +modules path platform stderr +stdin stdout version version_info ementation # attrtuple (start=1, stop=2, step=3) @@ -165,15 +169,14 @@ cpp None frzstr1 frzstr1.py frzmpy1 -.frozen/frzmpy1.py +frzmpy1.py frzstr_pkg1.__init__ frzstr_pkg1/__init__.py 1 frzmpy_pkg1.__init__ -.frozen/frzmpy_pkg1/__init__.py 1 +frzmpy_pkg1/__init__.py 1 frzstr_pkg2.mod 1 frzmpy_pkg2.mod 1 ZeroDivisionError -b'# test frozen package' NULL diff --git a/tools/autobuild/build-boards.sh b/tools/autobuild/build-boards.sh new file mode 100755 index 0000000000..4b5259b667 --- /dev/null +++ b/tools/autobuild/build-boards.sh @@ -0,0 +1,116 @@ +#!/bin/bash +# +# The functions in this file can be run independently to build boards. +# For example: +# +# $ source build-boards.sh +# $ MICROPY_AUTOBUILD_MAKE=make build_rp2_boards -latest /tmp + +function build_board { + # check/get parameters + if [ $# -lt 4 ]; then + echo "usage: $0 " + return 1 + fi + + board_json=$1 + fw_tag=$2 + dest_dir=$3 + shift + shift + shift + + board=$(echo $board_json | awk -F '/' '{ print $2 }') + descr=$(cat $board_json | python3 -c "import json,sys; print(json.load(sys.stdin).get('id', '$board'))") + build_dir=/tmp/micropython-build-$board + + echo "building $descr $board" + $MICROPY_AUTOBUILD_MAKE BOARD=$board BUILD=$build_dir && ( + for ext in $@; do + dest=$dest_dir/$descr$fw_tag.$ext + if [ -r $build_dir/firmware.$ext ]; then + mv $build_dir/firmware.$ext $dest + else + # esp32 has micropython.elf and micropython.map + mv $build_dir/micropython.$ext $dest + fi + done + ) + rm -rf $build_dir +} + +function build_boards { + # check/get parameters + if [ $# -lt 4 ]; then + echo "usage: $0 " + return 1 + fi + + check_file=$1 + shift + + # check we are in the correct directory + if [ ! -r $check_file ]; then + echo "must be in directory containing $check_file" + return 1 + fi + + # build all boards that have a board.json file + for board_json in $(find boards/ -name board.json | sort); do + build_board $board_json $@ + done +} + +function build_esp32_boards { + # check/get parameters + if [ $# != 2 ]; then + echo "usage: $0 " + return 1 + fi + + fw_tag=$1 + dest_dir=$2 + + # check we are in the correct directory + if [ ! -r modesp32.c ]; then + echo "must be in esp32 directory" + return 1 + fi + + # build the boards, based on the IDF version + for board_json in $(find boards/ -name board.json | sort); do + mcu=$(cat $board_json | python3 -c "import json,sys; print(json.load(sys.stdin).get('mcu', 'unknown'))") + if idf.py --version | grep -q v4.2; then + if [ $mcu = esp32 ]; then + # build standard esp32-based boards with IDF v4.2 + if echo $board_json | grep -q GENERIC; then + # traditionally, GENERIC and GENERIC_SPIRAM boards used manifest_release.py + MICROPY_AUTOBUILD_MAKE="$MICROPY_AUTOBUILD_MAKE FROZEN_MANIFEST=$(pwd)/boards/manifest_release.py" build_board $board_json $fw_tag $dest_dir bin elf map + else + build_board $board_json $fw_tag $dest_dir bin elf map + fi + fi + else + if [ $mcu != esp32 ]; then + # build esp32-s2/s3/c3 based boards with IDF v4.4+ + build_board $board_json $fw_tag $dest_dir bin elf map + fi + fi + done +} + +function build_mimxrt_boards { + build_boards modmimxrt.c $1 $2 bin hex +} + +function build_rp2_boards { + build_boards modrp2.c $1 $2 uf2 +} + +function build_samd_boards { + build_boards samd_soc.c $1 $2 uf2 +} + +function build_stm32_boards { + build_boards modpyb.c $1 $2 dfu hex +} diff --git a/tools/autobuild/build-downloads.py b/tools/autobuild/build-downloads.py new file mode 100755 index 0000000000..0f532e8bf0 --- /dev/null +++ b/tools/autobuild/build-downloads.py @@ -0,0 +1,58 @@ +#!/usr/bin/env python3 + +import glob +import json +import os +import sys + + +def main(repo_path, output_path): + boards_index = [] + board_ids = set() + + for board_json in glob.glob(os.path.join(repo_path, "ports/*/boards/*/board.json")): + # Relative path to the board directory (e.g. "ports/stm32/boards/PYBV11"). + board_dir = os.path.dirname(board_json) + # Relative path to the port (e.g. "ports/stm32") + port_dir = os.path.dirname(os.path.dirname(board_dir)) + + with open(board_json, "r") as f: + blob = json.load(f) + + # Use "id" if specified, otherwise default to board dir (e.g. "PYBV11"). + # We allow boards to override ID for the historical build names. + blob["id"] = blob.get("id", os.path.basename(board_dir)) + + # Check for duplicate board IDs. + if blob["id"] in board_ids: + print("Duplicate board ID: '{}'".format(blob["id"]), file=sys.stderr) + board_ids.add(blob["id"]) + + # Add in default fields. + blob["port"] = os.path.basename(port_dir) + blob["build"] = os.path.basename(board_dir) + boards_index.append(blob) + + # Create the board markdown, which is the concatenation of the + # default "board.md" file (if exists), as well as any flashing + # instructions. + board_markdown = os.path.join(board_dir, "board.md") + with open(os.path.join(output_path, blob["id"] + ".md"), "w") as f: + if os.path.exists(board_markdown): + with open(board_markdown, "r") as fin: + f.write(fin.read()) + + if blob["deploy"]: + f.write("\n\n## Installation instructions\n") + for deploy in blob["deploy"]: + with open(os.path.join(board_dir, deploy), "r") as fin: + f.write(fin.read()) + + # Write the full index for the website to load. + with open(os.path.join(output_path, "index.json"), "w") as f: + json.dump(boards_index, f, indent=4, sort_keys=True) + f.write("\n") + + +if __name__ == "__main__": + main(sys.argv[1], sys.argv[2]) diff --git a/tools/build_board_info.py b/tools/build_board_info.py old mode 100644 new mode 100755 index dde59e7e43..364bcefe7b --- a/tools/build_board_info.py +++ b/tools/build_board_info.py @@ -32,6 +32,7 @@ DFU = ("dfu",) BIN_DFU = ("bin", "dfu") COMBINED_HEX = ("combined.hex",) KERNEL8_IMG = ("disk.img.zip", "kernel8.img") +KERNEL_IMG = ("disk.img.zip", "kernel.img") # Default extensions extension_by_port = { @@ -69,7 +70,12 @@ extension_by_board = { "meowbit_v121": UF2, # esp32c3 "ai_thinker_esp32-c3s": BIN, + "ai_thinker_esp32-c3s-2m": BIN, + "espressif_esp32c3_devkitm_1_n4": BIN, "microdev_micro_c3": BIN, + # broadcom + "raspberrypi_zero": KERNEL_IMG, + "raspberrypi_zero_w": KERNEL_IMG, } language_allow_list = set( @@ -89,6 +95,7 @@ language_allow_list = set( "pt_BR", "ru", "sv", + "tr", "zh_Latn_pinyin", ] ) @@ -160,10 +167,10 @@ def get_version_info(): def get_current_info(): - response = github.get("/repos/adafruit/circuitpython-org/git/refs/heads/master") + response = github.get("/repos/adafruit/circuitpython-org/git/refs/heads/main") if not response.ok: print(response.text) - raise RuntimeError("cannot get master sha") + raise RuntimeError("cannot get main sha") commit_sha = response.json()["object"]["sha"] response = github.get( @@ -235,7 +242,7 @@ def create_pr(changes, updated, git_info, user): pr_info = { "title": pr_title, "head": user + ":" + branch_name, - "base": "master", + "base": "main", "body": message, "maintainer_can_modify": True, } diff --git a/tools/build_memory_info.py b/tools/build_memory_info.py old mode 100644 new mode 100755 diff --git a/tools/chart_code_size.py b/tools/chart_code_size.py index 2328edd72f..cefe3b8094 100644 --- a/tools/chart_code_size.py +++ b/tools/chart_code_size.py @@ -446,7 +446,7 @@ def do_all_the_things(elf_filename): if "size" not in symbol: print(symbol) size = symbol["size"] / 8 - square_size = size ** 0.5 + square_size = size**0.5 if text_width_ish > square_size: w = text_width_ish h = size / text_width_ish diff --git a/tools/ci_check_duplicate_usb_vid_pid.py b/tools/ci_check_duplicate_usb_vid_pid.py index 6f15a28c46..51eac31f03 100644 --- a/tools/ci_check_duplicate_usb_vid_pid.py +++ b/tools/ci_check_duplicate_usb_vid_pid.py @@ -51,6 +51,15 @@ DEFAULT_IGNORELIST = [ "unexpectedmaker_feathers2_prerelease", "espressif_kaluga_1", "espressif_kaluga_1.3", + "espressif_esp32s2_devkitc_1_n4r2", + "espressif_esp32s3_devkitc_1_n8", + "espressif_esp32s3_devkitc_1_n8r2", + "espressif_esp32s3_devkitc_1_n8r8", + "espressif_saola_1_wrover", + "jpconstantineau_pykey18", + "jpconstantineau_pykey44", + "jpconstantineau_pykey60", + "jpconstantineau_pykey87", ] cli_parser = argparse.ArgumentParser(description="USB VID/PID Duplicate Checker") diff --git a/tools/ci_fetch_deps.py b/tools/ci_fetch_deps.py index 8e450e7b57..d31b0d47aa 100644 --- a/tools/ci_fetch_deps.py +++ b/tools/ci_fetch_deps.py @@ -22,7 +22,7 @@ port_deps = { "lib/tinyusb/", "data/nvm.toml/", ], - "broadcom": ["lib/tinyusb/"], + "broadcom": ["extmod/ulab/", "lib/tinyusb/"], "cxd56": ["extmod/ulab/", "lib/tinyusb/"], "espressif": ["extmod/ulab/", "lib/tinyusb/", "lib/protomatter/", "lib/quirc/"], "litex": ["extmod/ulab/", "lib/tinyusb/"], @@ -64,7 +64,7 @@ run("Submodule status", "git submodule status") submodules = [] if target == "test": - submodules = ["extmod/", "lib/", "tools/"] + submodules = ["extmod/", "lib/", "tools/", "extmod/ulab", "lib/berkeley-db-1.xx"] elif target == "docs": submodules = ["extmod/ulab/"] elif target == "mpy-cross-mac": @@ -73,8 +73,7 @@ elif target == "windows": # This builds one board from a number of ports so fill out a bunch of submodules submodules = ["extmod/", "lib/", "tools/", "ports/", "data/nvm.toml/"] elif target == "website": - # No submodules needed. - pass + submodules = ["tools/adabot/"] else: p = list(pathlib.Path(".").glob(f"ports/*/boards/{target}/mpconfigboard.mk")) if not p: diff --git a/tools/ci_set_matrix.py b/tools/ci_set_matrix.py index 2f74fbec04..efb4427e7e 100644 --- a/tools/ci_set_matrix.py +++ b/tools/ci_set_matrix.py @@ -34,6 +34,11 @@ PORT_TO_ARCH = { "stm": "arm", } +IGNORE = [ + "tools/ci_set_matrix.py", + "tools/ci_check_duplicate_usb_vid_pid.py", +] + changed_files = {} try: changed_files = json.loads(os.environ["CHANGED_FILES"]) @@ -63,8 +68,8 @@ def set_boards_to_build(build_all): if not build_all: boards_to_build = set() - board_pattern = re.compile(r"^ports\/[^/]+\/boards\/([^/]+)\/") - port_pattern = re.compile(r"^ports\/([^/]+)\/") + board_pattern = re.compile(r"^ports/[^/]+/boards/([^/]+)/") + port_pattern = re.compile(r"^ports/([^/]+)/") for p in changed_files: # See if it is board specific board_matches = board_pattern.search(p) @@ -81,6 +86,14 @@ def set_boards_to_build(build_all): boards_to_build.update(port_to_boards[port]) continue + # Check the ignore list to see if the file isn't used on board builds. + if p in IGNORE: + continue + + # Boards don't run tests so ignore those as well. + if p.startswith("tests"): + continue + # Otherwise build it all boards_to_build = all_board_ids break @@ -107,7 +120,7 @@ def set_docs_to_build(build_all): doc_match = build_all if not build_all: doc_pattern = re.compile( - r"^(?:docs|(?:(?:extmod\/ulab|ports\/\w+\/bindings|shared-bindings)\S+\.c|conf\.py|tools\/extract_pyi\.py|requirements-doc\.txt)$)|(?:-stubs|\.(?:md|MD|rst|RST))$" + r"^(?:docs|extmod/ulab|(?:(?:ports/\w+/bindings|shared-bindings)\S+\.c|conf\.py|tools/extract_pyi\.py|requirements-doc\.txt)$)|(?:-stubs|\.(?:md|MD|rst|RST))$" ) for p in changed_files: if doc_pattern.search(p): diff --git a/tools/codeformat.py b/tools/codeformat.py index c98b34b17a..edefbc8ddc 100644 --- a/tools/codeformat.py +++ b/tools/codeformat.py @@ -40,7 +40,6 @@ PATHS = [ # C "main.c", "devices/**/*.[ch]", - "drivers/bus/*.[ch]", "extmod/*.[ch]", "shared/netutils/*.[ch]", "shared/timeutils/*.[ch]", diff --git a/tools/convert_release_notes.py b/tools/convert_release_notes.py index 964a7fc376..0ebccf96d7 100644 --- a/tools/convert_release_notes.py +++ b/tools/convert_release_notes.py @@ -16,9 +16,8 @@ html = mistune.create_markdown() print() print("HTML") print("=====================================") -print('From the GitHub release page:\n
') +print('

From the GitHub release page:

\n') print(html(source)) -print("
") class AdafruitBBCodeRenderer(mistune.renderers.BaseRenderer): @@ -59,10 +58,13 @@ class AdafruitBBCodeRenderer(mistune.renderers.BaseRenderer): return "[b]{}[/b]".format(text) def emphasis(self, text): - return "[b]{}[/b]".format(text) + return "[i]{}[/i]".format(text) def strong(self, text): - return "[i]{}[/i]".format(text) + return "[b]{}[/b]".format(text) + + def finalize(self, data): + return "".join(data) bbcode = mistune.create_markdown(renderer=AdafruitBBCodeRenderer()) @@ -70,6 +72,5 @@ bbcode = mistune.create_markdown(renderer=AdafruitBBCodeRenderer()) print() print("BBCode") print("=====================================") -print("From the [url=]GitHub release page[/url]:\n[quote]") +print("[i]From the [url=]GitHub release page[/url]:[/i]\n") print(bbcode(source)) -print("[/quote]") diff --git a/tools/describe b/tools/describe new file mode 100755 index 0000000000..7fd624abe3 --- /dev/null +++ b/tools/describe @@ -0,0 +1,3 @@ +#!/bin/sh +# Add any supplied arguments. +git describe --first-parent --dirty --tags --always --match "[1-9].*" "$@" diff --git a/tools/dfu.py b/tools/dfu.py index 4dcb4fdca7..244629d60b 100644 --- a/tools/dfu.py +++ b/tools/dfu.py @@ -25,7 +25,7 @@ def consume(fmt, data, names): def cstring(string): - return string.split("\0", 1)[0] + return string.split(b"\0", 1)[0] def compute_crc(data): diff --git a/tools/extract_pyi.py b/tools/extract_pyi.py index 1bd51ca7a8..d35e09a2e0 100644 --- a/tools/extract_pyi.py +++ b/tools/extract_pyi.py @@ -244,7 +244,7 @@ def convert_folder(top_level, stub_directory): if imports["typing"]: import_lines.append("from typing import " + ", ".join(imports["typing"])) if imports["cpy_typing"]: - import_lines.append("from _typing import " + ", ".join(imports["cpy_typing"])) + import_lines.append("from circuitpython_typing import " + ", ".join(imports["cpy_typing"])) import_lines.extend(f"import {m}" for m in imports["modules"]) import_body = "\n".join(import_lines) m = re.match(r'(\s*""".*?""")', stub_contents, flags=re.DOTALL) diff --git a/tools/makemanifest.py b/tools/makemanifest.py index 7897a83c6e..8cdc3eb774 100644 --- a/tools/makemanifest.py +++ b/tools/makemanifest.py @@ -201,8 +201,6 @@ def freeze_internal(kind, path, script, opt): if not os.path.isdir(path): raise FreezeError("freeze path must be a directory: {}".format(path)) if script is None and kind == KIND_AS_STR: - if any(f[0] == KIND_AS_STR for f in manifest_list): - raise FreezeError("can only freeze one str directory") manifest_list.append((KIND_AS_STR, path, script, opt)) elif script is None or isinstance(script, str) and script.find(".") == -1: # Recursively search `path` for files to freeze, optionally restricted @@ -235,6 +233,73 @@ def freeze_internal(kind, path, script, opt): manifest_list.append((kind, path, script, opt)) +# Formerly make-frozen.py. +# This generates: +# - MP_FROZEN_STR_NAMES macro +# - mp_frozen_str_sizes +# - mp_frozen_str_content +def generate_frozen_str_content(paths): + def module_name(f): + return f + + modules = [] + output = [b"#include \n"] + + for path in paths: + root = path.rstrip("/") + root_len = len(root) + + for dirpath, dirnames, filenames in os.walk(root): + for f in filenames: + fullpath = dirpath + "/" + f + st = os.stat(fullpath) + modules.append((path, fullpath[root_len + 1 :], st)) + + output.append(b"#define MP_FROZEN_STR_NAMES \\\n") + for _path, f, st in modules: + m = module_name(f) + output.append(b'"%s\\0" \\\n' % m.encode()) + output.append(b"\n") + + output.append(b"const uint32_t mp_frozen_str_sizes[] = { ") + + for _path, f, st in modules: + output.append(b"%d, " % st.st_size) + output.append(b"0 };\n") + + output.append(b"const char mp_frozen_str_content[] = {\n") + for path, f, st in modules: + data = open(path + "/" + f, "rb").read() + + # We need to properly escape the script data to create a C string. + # When C parses hex characters of the form \x00 it keeps parsing the hex + # data until it encounters a non-hex character. Thus one must create + # strings of the form "data\x01" "abc" to properly encode this kind of + # data. We could just encode all characters as hex digits but it's nice + # to be able to read the resulting C code as ASCII when possible. + + data = bytearray(data) # so Python2 extracts each byte as an integer + esc_dict = {ord("\n"): b"\\n", ord("\r"): b"\\r", ord('"'): b'\\"', ord("\\"): b"\\\\"} + output.append(b'"') + break_str = False + for c in data: + try: + output.append(esc_dict[c]) + except KeyError: + if 32 <= c <= 126: + if break_str: + output.append(b'" "') + break_str = False + output.append(chr(c).encode()) + else: + output.append(b"\\x%02x" % c) + break_str = True + output.append(b'\\0"\n') + + output.append(b'"\\0"\n};\n\n') + return b"".join(output) + + def main(): # Parse arguments import argparse @@ -264,7 +329,6 @@ def main(): sys.exit(1) # Get paths to tools - MAKE_FROZEN = VARS["MPY_DIR"] + "/tools/make-frozen.py" MPY_CROSS = VARS["MPY_DIR"] + "/mpy-cross/mpy-cross" if sys.platform == "win32": MPY_CROSS += ".exe" @@ -327,10 +391,7 @@ def main(): return # Freeze paths as strings - res, output_str = system([sys.executable, MAKE_FROZEN] + str_paths) - if res != 0: - print("error freezing strings {}: {}".format(str_paths, output_str)) - sys.exit(1) + output_str = generate_frozen_str_content(str_paths) # Freeze .mpy files if mpy_files: @@ -347,7 +408,7 @@ def main(): ) if res != 0: print("error freezing mpy {}:".format(mpy_files)) - print(str(output_mpy, "utf8")) + print(output_mpy.decode()) sys.exit(1) else: output_mpy = ( @@ -356,8 +417,8 @@ def main(): b"const qstr_pool_t mp_qstr_frozen_const_pool = {\n" b" (qstr_pool_t*)&mp_qstr_const_pool, MP_QSTRnumber_of, 0, 0\n" b"};\n" - b'const char mp_frozen_mpy_names[1] = {"\\0"};\n' - b"const mp_raw_code_t *const mp_frozen_mpy_content[1] = {NULL};\n" + b'const char mp_frozen_names[] = { MP_FROZEN_STR_NAMES "\\0"};\n' + b"const mp_raw_code_t *const mp_frozen_mpy_content[] = {NULL};\n" ) # Generate output diff --git a/tools/merge_micropython.py b/tools/merge_micropython.py index 620d6896d2..ce3736ddb7 100644 --- a/tools/merge_micropython.py +++ b/tools/merge_micropython.py @@ -172,7 +172,6 @@ top_delete = [ "README.md", "CODEOFCONDUCT.md", "CODECONVENTIONS.md", - "examples", ] for t in top_delete: try: diff --git a/tools/mpy-tool.py b/tools/mpy-tool.py index 05a9db48da..32b064d35f 100755 --- a/tools/mpy-tool.py +++ b/tools/mpy-tool.py @@ -113,14 +113,6 @@ def mp_opcode_format(bytecode, ip, count_var_uint): ip_start = ip f = (0x000003A4 >> (2 * ((opcode) >> 4))) & 3 if f == MP_BC_FORMAT_QSTR: - if config.MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE: - if ( - opcode == MP_BC_LOAD_NAME - or opcode == MP_BC_LOAD_GLOBAL - or opcode == MP_BC_LOAD_ATTR - or opcode == MP_BC_STORE_ATTR - ): - ip += 1 ip += 3 else: extra_byte = (opcode & MP_BC_MASK_EXTRA_BYTE) == 0 @@ -421,10 +413,7 @@ class RawCodeBytecode(RawCode): "// frozen bytecode for file %s, scope %s%s" % (self.source_file.str, parent_name, self.simple_name.str) ) - print("STATIC ", end="") - if not config.MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE: - print("const ", end="") - print("byte fun_data_%s[%u] = {" % (self.escaped_name, len(self.bytecode))) + print("STATIC const byte fun_data_%s[%u] = {" % (self.escaped_name, len(self.bytecode))) print(" ", end="") for i in range(self.ip2): print(" 0x%02x," % self.bytecode[i], end="") @@ -779,7 +768,6 @@ def read_mpy(filename): raise Exception("incompatible .mpy version") feature_byte = header[2] qw_size = read_uint(f) - config.MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE = (feature_byte & 1) != 0 config.MICROPY_PY_BUILTINS_STR_UNICODE = (feature_byte & 2) != 0 mpy_native_arch = feature_byte >> 2 if mpy_native_arch != MP_NATIVE_ARCH_NONE: @@ -818,14 +806,6 @@ def freeze_mpy(base_qstrs, raw_codes): print('#include "py/nativeglue.h"') print() - print( - "#if MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE != %u" - % config.MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE - ) - print('#error "incompatible MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE"') - print("#endif") - print() - print("#if MICROPY_LONGINT_IMPL != %u" % config.MICROPY_LONGINT_IMPL) print('#error "incompatible MICROPY_LONGINT_IMPL"') print("#endif") @@ -899,7 +879,11 @@ def freeze_mpy(base_qstrs, raw_codes): rc.freeze(rc.source_file.str.replace("/", "_")[:-3] + "_") print() - print("const char mp_frozen_mpy_names[] = {") + print("const char mp_frozen_names[] = {") + print("#ifdef MP_FROZEN_STR_NAMES") + # makemanifest.py might also include some frozen string content. + print("MP_FROZEN_STR_NAMES") + print("#endif") for rc in raw_codes: module_name = rc.source_file.str print('"%s\\0"' % module_name) @@ -933,11 +917,7 @@ def merge_mpy(raw_codes, output_file): header = bytearray(5) header[0] = ord("C") header[1] = config.MPY_VERSION - header[2] = ( - config.native_arch << 2 - | config.MICROPY_PY_BUILTINS_STR_UNICODE << 1 - | config.MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE - ) + header[2] = config.native_arch << 2 | config.MICROPY_PY_BUILTINS_STR_UNICODE << 1 header[3] = config.mp_small_int_bits header[4] = 32 # qstr_win_size merged_mpy.extend(header) diff --git a/tools/mpy_cross_all.py b/tools/mpy_cross_all.py index 9c217400fb..1a2c612943 100755 --- a/tools/mpy_cross_all.py +++ b/tools/mpy_cross_all.py @@ -11,13 +11,13 @@ import os.path argparser = argparse.ArgumentParser(description="Compile all .py files to .mpy recursively") argparser.add_argument("-o", "--out", help="output directory (default: input dir)") argparser.add_argument("--target", help="select MicroPython target config") -argparser.add_argument( - "-mcache-lookup-bc", action="store_true", help="cache map lookups in the bytecode" -) argparser.add_argument("dir", help="input directory") args = argparser.parse_args() -TARGET_OPTS = {"unix": "-mcache-lookup-bc", "baremetal": ""} +TARGET_OPTS = { + "unix": "", + "baremetal": "", +} args.dir = args.dir.rstrip("/") diff --git a/tools/mpy_ld.py b/tools/mpy_ld.py index daa9eabca4..54df98ef07 100755 --- a/tools/mpy_ld.py +++ b/tools/mpy_ld.py @@ -48,7 +48,6 @@ MP_CODE_NATIVE_VIPER = 4 MP_SCOPE_FLAG_VIPERRELOC = 0x20 MP_SCOPE_FLAG_VIPERRODATA = 0x40 MP_SCOPE_FLAG_VIPERBSS = 0x80 -MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE = 1 MICROPY_PY_BUILTINS_STR_UNICODE = 2 MP_SMALL_INT_BITS = 31 QSTR_WINDOW_SIZE = 32 @@ -118,9 +117,7 @@ class ArchData: ARCH_DATA = { "x86": ArchData( "EM_386", - MP_NATIVE_ARCH_X86 << 2 - | MICROPY_PY_BUILTINS_STR_UNICODE - | MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE, + MP_NATIVE_ARCH_X86 << 2 | MICROPY_PY_BUILTINS_STR_UNICODE, 2, 4, (R_386_PC32, R_386_GOT32, R_386_GOT32X), @@ -128,9 +125,7 @@ ARCH_DATA = { ), "x64": ArchData( "EM_X86_64", - MP_NATIVE_ARCH_X64 << 2 - | MICROPY_PY_BUILTINS_STR_UNICODE - | MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE, + MP_NATIVE_ARCH_X64 << 2 | MICROPY_PY_BUILTINS_STR_UNICODE, 2, 8, (R_X86_64_GOTPCREL, R_X86_64_REX_GOTPCRELX), diff --git a/tools/preprocess_frozen_modules.py b/tools/preprocess_frozen_modules.py index 294df317bc..30263d2e02 100755 --- a/tools/preprocess_frozen_modules.py +++ b/tools/preprocess_frozen_modules.py @@ -49,7 +49,12 @@ def copy_and_process(in_dir, out_dir): # Skip library examples directory and subfolders. relative_path_parts = Path(root).relative_to(in_dir).parts - if relative_path_parts and relative_path_parts[0] in ["examples", "docs", "tests"]: + if relative_path_parts and relative_path_parts[0] in [ + "examples", + "docs", + "tests", + "utils", + ]: del subdirs[:] continue diff --git a/tools/uf2 b/tools/uf2 index adbb8c7260..1421ca7fe7 160000 --- a/tools/uf2 +++ b/tools/uf2 @@ -1 +1 @@ -Subproject commit adbb8c7260f938e810eb37f2287f8e1a055ff402 +Subproject commit 1421ca7fe72a2b173b08be05f9042b79409e783a diff --git a/tools/uf2conv.py b/tools/uf2conv.py deleted file mode 100755 index d67a55224c..0000000000 --- a/tools/uf2conv.py +++ /dev/null @@ -1,369 +0,0 @@ -#!/usr/bin/env python3 - -# Microsoft UF2 -# -# The MIT License (MIT) -# -# Copyright (c) Microsoft Corporation -# -# All rights reserved. -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. - -import sys -import struct -import subprocess -import re -import os -import os.path -import argparse - - -UF2_MAGIC_START0 = 0x0A324655 # "UF2\n" -UF2_MAGIC_START1 = 0x9E5D5157 # Randomly selected -UF2_MAGIC_END = 0x0AB16F30 # Ditto - -families = { - "SAMD21": 0x68ED2B88, - "SAMD51": 0x55114460, - "NRF52": 0x1B57745F, - "STM32F1": 0x5EE21072, - "STM32F4": 0x57755A57, - "ATMEGA32": 0x16573617, -} - -INFO_FILE = "/INFO_UF2.TXT" - -appstartaddr = 0x2000 -familyid = 0x0 - - -def is_uf2(buf): - w = struct.unpack(" 476: - assert False, "Invalid UF2 data size at " + ptr - newaddr = hd[3] - if curraddr == None: - appstartaddr = newaddr - curraddr = newaddr - padding = newaddr - curraddr - if padding < 0: - assert False, "Block out of order at " + ptr - if padding > 10 * 1024 * 1024: - assert False, "More than 10M of padding needed at " + ptr - if padding % 4 != 0: - assert False, "Non-word padding size at " + ptr - while padding > 0: - padding -= 4 - outp += b"\x00\x00\x00\x00" - outp += block[32 : 32 + datalen] - curraddr = newaddr + datalen - return outp - - -def convert_to_carray(file_content): - outp = "const unsigned char bindata[] __attribute__((aligned(16))) = {" - for i in range(len(file_content)): - if i % 16 == 0: - outp += "\n" - outp += "0x%02x, " % ord(file_content[i]) - outp += "\n};\n" - return outp - - -def convert_to_uf2(file_content): - global familyid - datapadding = b"" - while len(datapadding) < 512 - 256 - 32 - 4: - datapadding += b"\x00\x00\x00\x00" - numblocks = (len(file_content) + 255) // 256 - outp = b"" - for blockno in range(numblocks): - ptr = 256 * blockno - chunk = file_content[ptr : ptr + 256] - flags = 0x0 - if familyid: - flags |= 0x2000 - hd = struct.pack( - b"= 3 and words[1] == "2" and words[2] == "FAT": - drives.append(words[0]) - else: - rootpath = "/media" - if sys.platform == "darwin": - rootpath = "/Volumes" - elif sys.platform == "linux": - tmp = rootpath + "/" + os.environ["USER"] - if os.path.isdir(tmp): - rootpath = tmp - for d in os.listdir(rootpath): - drives.append(os.path.join(rootpath, d)) - - def has_info(d): - try: - return os.path.isfile(d + INFO_FILE) - except: - return False - - return list(filter(has_info, drives)) - - -def board_id(path): - with open(path + INFO_FILE, mode="r") as file: - file_content = file.read() - return re.search("Board-ID: ([^\r\n]*)", file_content).group(1) - - -def list_drives(): - for d in get_drives(): - print(d, board_id(d)) - - -def write_file(name, buf): - with open(name, "wb") as f: - f.write(buf) - print("Wrote %d bytes to %s." % (len(buf), name)) - - -def main(): - global appstartaddr, familyid - - def error(msg): - print(msg) - sys.exit(1) - - parser = argparse.ArgumentParser(description="Convert to UF2 or flash directly.") - parser.add_argument( - "input", metavar="INPUT", type=str, nargs="?", help="input file (HEX, BIN or UF2)" - ) - parser.add_argument( - "-b", - "--base", - dest="base", - type=str, - default="0x2000", - help="set base address of application for BIN format (default: 0x2000)", - ) - parser.add_argument( - "-o", - "--output", - metavar="FILE", - dest="output", - type=str, - help='write output to named file; defaults to "flash.uf2" or "flash.bin" where sensible', - ) - parser.add_argument("-d", "--device", dest="device_path", help="select a device path to flash") - parser.add_argument("-l", "--list", action="store_true", help="list connected devices") - parser.add_argument("-c", "--convert", action="store_true", help="do not flash, just convert") - parser.add_argument( - "-f", - "--family", - dest="family", - type=str, - default="0x0", - help="specify familyID - number or name (default: 0x0)", - ) - parser.add_argument( - "-C", "--carray", action="store_true", help="convert binary file to a C array, not UF2" - ) - args = parser.parse_args() - appstartaddr = int(args.base, 0) - - if args.family.upper() in families: - familyid = families[args.family.upper()] - else: - try: - familyid = int(args.family, 0) - except ValueError: - error("Family ID needs to be a number or one of: " + ", ".join(families.keys())) - - if args.list: - list_drives() - else: - if not args.input: - error("Need input file") - with open(args.input, mode="rb") as f: - inpbuf = f.read() - from_uf2 = is_uf2(inpbuf) - ext = "uf2" - if from_uf2: - outbuf = convert_from_uf2(inpbuf) - ext = "bin" - elif is_hex(inpbuf): - outbuf = convert_from_hex_to_uf2(inpbuf.decode("utf-8")) - elif args.carray: - outbuf = convert_to_carray(inpbuf) - ext = "h" - else: - outbuf = convert_to_uf2(inpbuf) - print( - "Converting to %s, output size: %d, start address: 0x%x" - % (ext, len(outbuf), appstartaddr) - ) - if args.convert: - drives = [] - if args.output == None: - args.output = "flash." + ext - else: - drives = get_drives() - - if args.output: - write_file(args.output, outbuf) - else: - if len(drives) == 0: - error("No drive to deploy.") - for d in drives: - print("Flashing %s (%s)" % (d, board_id(d))) - write_file(d + "/NEW.UF2", outbuf) - - -if __name__ == "__main__": - main() diff --git a/tools/upip.py b/tools/upip.py index 95cd8d5cc7..70afe36a45 100644 --- a/tools/upip.py +++ b/tools/upip.py @@ -192,9 +192,13 @@ def fatal(msg, exc=None): def install_pkg(pkg_spec, install_path): - data = get_pkg_metadata(pkg_spec) + package = pkg_spec.split("==") + data = get_pkg_metadata(package[0]) - latest_ver = data["info"]["version"] + if len(package) == 1: + latest_ver = data["info"]["version"] + else: + latest_ver = package[1] packages = data["releases"][latest_ver] del data gc.collect() @@ -258,6 +262,8 @@ def get_install_path(): if install_path is None: # sys.path[0] is current module's path install_path = sys.path[1] + if install_path == ".frozen": + install_path = sys.path[2] install_path = expandhome(install_path) return install_path @@ -277,11 +283,11 @@ upip - Simple PyPI package manager for MicroPython Usage: micropython -m upip install [-p ] ... | -r import upip; upip.install(package_or_list, []) -If is not given, packages will be installed into sys.path[1] -(can be set from MICROPYPATH environment variable, if current system -supports that).""" +If isn't given, packages will be installed to sys.path[1], or +sys.path[2] if the former is .frozen (path can be set from MICROPYPATH +environment variable if supported).""" ) - print("Current value of sys.path[1]:", sys.path[1]) + print("Default install path:", get_install_path()) print( """\