diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 90cf8954d3..eb20569030 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -145,6 +145,10 @@ jobs: 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 + with: + python-version: 3.8 - name: Install dependencies run: | brew install gettext diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 65d5feb68e..7fa71f1e66 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -17,8 +17,8 @@ jobs: - name: Install deps run: | sudo apt-add-repository -y -u ppa:pybricks/ppa - sudo apt-get install -y black gettext uncrustify - pip3 install -r requirements-dev.txt + sudo apt-get install -y gettext uncrustify + pip3 install black polib pyyaml - name: Populate selected submodules run: git submodule update --init extmod/ulab - name: Set PY @@ -28,3 +28,12 @@ jobs: path: ~/.cache/pre-commit key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }} - uses: pre-commit/action@v1.1.0 + - name: Make patch + if: failure() + run: git diff > ~/pre-commit.patch + - name: Upload patch + if: failure() + uses: actions/upload-artifact@v2 + with: + name: patch + path: ~/pre-commit.patch diff --git a/.gitmodules b/.gitmodules index b261d8f408..e26d3dd76b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,17 +4,13 @@ [submodule "lib/axtls"] path = lib/axtls - url = https://github.com/pfalcon/axtls - branch = micropython + url = https://github.com/micropython/axtls.git [submodule "lib/libffi"] path = lib/libffi url = https://github.com/atgreen/libffi [submodule "lib/berkeley-db-1.xx"] path = lib/berkeley-db-1.xx url = https://github.com/pfalcon/berkeley-db-1.xx -[submodule "lib/uzlib"] - path = lib/uzlib - url = https://github.com/pfalcon/uzlib [submodule "tools/uf2"] path = tools/uf2 url = https://github.com/Microsoft/uf2.git diff --git a/.readthedocs.yml b/.readthedocs.yml index 3f66351ce7..770888b79e 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -8,6 +8,11 @@ version: 2 +build: + os: ubuntu-20.04 + tools: + python: "3.9" + submodules: include: - extmod/ulab @@ -16,6 +21,5 @@ formats: - pdf python: - version: 3 install: - requirements: docs/requirements.txt diff --git a/LICENSE b/LICENSE index 3193eb8cec..5b5c37f7d1 100644 --- a/LICENSE +++ b/LICENSE @@ -19,3 +19,67 @@ 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. + +-------------------------------------------------------------------------------- + +Unless specified otherwise (see below), the above license and copyright applies +to all files in this repository. + +Individual files may include additional copyright holders. + +The various ports of MicroPython may include third-party software that is +licensed under different terms. These licenses are summarised in the tree +below, please refer to these files and directories for further license and +copyright information. Note that (L)GPL-licensed code listed below is only +used during the build process and is not part of the compiled source code. + +/ (MIT) + /drivers + /cc3000 (BSD-3-clause) + /cc3100 (BSD-3-clause) + /wiznet5k (BSD-3-clause) + /lib + /asf4 (Apache-2.0) + /axtls (BSD-3-clause) + /config + /scripts + /config (GPL-2.0-or-later) + /Rules.mak (GPL-2.0) + /berkeley-db-1xx (BSD-4-clause) + /btstack (See btstack/LICENSE) + /cmsis (BSD-3-clause) + /crypto-algorithms (NONE) + /libhydrogen (ISC) + /littlefs (BSD-3-clause) + /lwip (BSD-3-clause) + /mynewt-nimble (Apache-2.0) + /nrfx (BSD-3-clause) + /nxp_driver (BSD-3-Clause) + /oofatfs (BSD-1-clause) + /pico-sdk (BSD-3-clause) + /re15 (BSD-3-clause) + /stm32lib (BSD-3-clause) + /tinytest (BSD-3-clause) + /tinyusb (MIT) + /uzlib (Zlib) + /logo (uses OFL-1.1) + /ports + /cc3200 + /hal (BSD-3-clause) + /simplelink (BSD-3-clause) + /FreeRTOS (GPL-2.0 with FreeRTOS exception) + /stm32 + /usbd*.c (MCD-ST Liberty SW License Agreement V2) + /stm32_it.* (MIT + BSD-3-clause) + /system_stm32*.c (MIT + BSD-3-clause) + /boards + /startup_stm32*.s (BSD-3-clause) + /*/stm32*.h (BSD-3-clause) + /usbdev (MCD-ST Liberty SW License Agreement V2) + /usbhost (MCD-ST Liberty SW License Agreement V2) + /teensy + /core (PJRC.COM) + /zephyr + /src (Apache-2.0) + /tools + /dfu.py (LGPL-3.0-only) diff --git a/conf.py b/conf.py index 0dac441b0d..80b031ce05 100644 --- a/conf.py +++ b/conf.py @@ -209,6 +209,7 @@ exclude_patterns = ["**/build*", "ports/stm/ref", "ports/unix", "py", + "shared/*", "shared-bindings/util.*", "shared-module", "supervisor", diff --git a/devices/ble_hci/common-hal/_bleio/Adapter.c b/devices/ble_hci/common-hal/_bleio/Adapter.c index 04231a4a76..e7340621f9 100644 --- a/devices/ble_hci/common-hal/_bleio/Adapter.c +++ b/devices/ble_hci/common-hal/_bleio/Adapter.c @@ -666,8 +666,17 @@ uint32_t _common_hal_bleio_adapter_start_advertising(bleio_adapter_obj_t *self, } } - // Peer address, which we don't use (no directed advertising). - bt_addr_le_t empty_addr = { 0 }; + // Peer address, for directed advertising + bt_addr_le_t peer_addr = { 0 }; + + // Copy peer address, if supplied. + if (directed_to) { + mp_buffer_info_t bufinfo; + if (mp_get_buffer(directed_to->bytes, &bufinfo, MP_BUFFER_READ)) { + peer_addr.type = directed_to->type; + memcpy(&peer_addr.a.val, bufinfo.buf, sizeof(peer_addr.a.val)); + } + } bool extended = advertising_data_len > self->max_adv_data_len || scan_response_data_len > self->max_adv_data_len; @@ -696,7 +705,7 @@ uint32_t _common_hal_bleio_adapter_start_advertising(bleio_adapter_obj_t *self, interval_units, // max interval 0b111, // channel map: channels 37, 38, 39 anonymous ? BT_ADDR_LE_RANDOM : BT_ADDR_LE_PUBLIC, - &empty_addr, // peer_addr, + &peer_addr, // peer_addr, 0x00, // filter policy: no filter DEFAULT_TX_POWER, BT_HCI_LE_EXT_SCAN_PHY_1M, // Secondary PHY to use @@ -746,7 +755,7 @@ uint32_t _common_hal_bleio_adapter_start_advertising(bleio_adapter_obj_t *self, interval_units, // max interval adv_type, anonymous ? BT_ADDR_LE_RANDOM : BT_ADDR_LE_PUBLIC, - &empty_addr, + &peer_addr, 0b111, // channel map: channels 37, 38, 39 0x00 // filter policy: no filter )); diff --git a/devices/ble_hci/common-hal/_bleio/CharacteristicBuffer.c b/devices/ble_hci/common-hal/_bleio/CharacteristicBuffer.c index 8be1abef1f..bb6b8788b6 100644 --- a/devices/ble_hci/common-hal/_bleio/CharacteristicBuffer.c +++ b/devices/ble_hci/common-hal/_bleio/CharacteristicBuffer.c @@ -27,7 +27,7 @@ #include #include -#include "lib/utils/interrupt_char.h" +#include "shared/runtime/interrupt_char.h" #include "py/runtime.h" #include "py/stream.h" diff --git a/devices/ble_hci/common-hal/_bleio/Connection.c b/devices/ble_hci/common-hal/_bleio/Connection.c index fd041ca002..9531231506 100644 --- a/devices/ble_hci/common-hal/_bleio/Connection.c +++ b/devices/ble_hci/common-hal/_bleio/Connection.c @@ -32,7 +32,7 @@ #include #include -#include "lib/utils/interrupt_char.h" +#include "shared/runtime/interrupt_char.h" #include "py/gc.h" #include "py/objlist.h" #include "py/objstr.h" diff --git a/devices/ble_hci/common-hal/_bleio/PacketBuffer.c b/devices/ble_hci/common-hal/_bleio/PacketBuffer.c index 2c1989b4e0..7380d7ed4f 100644 --- a/devices/ble_hci/common-hal/_bleio/PacketBuffer.c +++ b/devices/ble_hci/common-hal/_bleio/PacketBuffer.c @@ -27,7 +27,7 @@ #include #include -#include "lib/utils/interrupt_char.h" +#include "shared/runtime/interrupt_char.h" #include "py/runtime.h" #include "py/stream.h" diff --git a/docs/README.md b/docs/README.md index 19c81a2fa3..1ad4ca802e 100644 --- a/docs/README.md +++ b/docs/README.md @@ -13,12 +13,9 @@ Building the documentation locally If you're making changes to the documentation, you should build the documentation locally so that you can preview your changes. -Install Sphinx, recommonmark, and optionally (for the RTD-styling), sphinx_rtd_theme, -preferably in a virtualenv: +Install the necessary packages, preferably in a virtualenv, in `circuitpython/`: - pip install sphinx - pip install recommonmark - pip install sphinx_rtd_theme + pip install -r requirements-doc.txt In `circuitpython/`, build the docs: diff --git a/docs/design_guide.rst b/docs/design_guide.rst index 8c3c8cc842..fdb8f9b019 100644 --- a/docs/design_guide.rst +++ b/docs/design_guide.rst @@ -99,7 +99,7 @@ For example, a user can then use ``deinit()```:: import board import time - led = digitalio.DigitalInOut(board.D13) + led = digitalio.DigitalInOut(board.LED) led.direction = digitalio.Direction.OUTPUT for i in range(10): @@ -119,7 +119,7 @@ Alternatively, using a ``with`` statement ensures that the hardware is deinitial import board import time - with digitalio.DigitalInOut(board.D13) as led: + with digitalio.DigitalInOut(board.LED) as led: led.direction = digitalio.Direction.OUTPUT for i in range(10): diff --git a/docs/library/uasyncio.rst b/docs/library/asyncio.rst similarity index 97% rename from docs/library/uasyncio.rst rename to docs/library/asyncio.rst index 10170fee85..87417f55e2 100644 --- a/docs/library/uasyncio.rst +++ b/docs/library/asyncio.rst @@ -222,6 +222,14 @@ TCP stream connections This is a coroutine, and a MicroPython extension. +.. method:: Stream.readexactly(n) + + Read exactly *n* bytes and return them as a bytes object. + + Raises an ``EOFError`` exception if the stream ends before reading *n* bytes. + + This is a coroutine. + .. method:: Stream.readline() Read a line and return it. diff --git a/docs/library/btree.rst b/docs/library/btree.rst index 66a3c0e34b..e160ebe13d 100644 --- a/docs/library/btree.rst +++ b/docs/library/btree.rst @@ -24,7 +24,7 @@ Example:: # First, we need to open a stream which holds a database # This is usually a file, but can be in-memory database - # using uio.BytesIO, a raw flash partition, etc. + # using io.BytesIO, a raw flash partition, etc. # Oftentimes, you want to create a database file if it doesn't # exist and open if it exists. Idiom below takes care of this. # DO NOT open database with "a+b" access mode. diff --git a/docs/library/builtins.rst b/docs/library/builtins.rst index c7f983010e..8532dc2531 100644 --- a/docs/library/builtins.rst +++ b/docs/library/builtins.rst @@ -1,5 +1,5 @@ -Builtin functions and exceptions -================================ +:mod:`builtins` -- builtin functions and exceptions +=================================================== All builtin functions and exceptions are described here. They are also available via ``builtins`` module. diff --git a/docs/library/uctypes.rst b/docs/library/ctypes.rst similarity index 99% rename from docs/library/uctypes.rst rename to docs/library/ctypes.rst index 9e15c4c178..803ddacdce 100644 --- a/docs/library/uctypes.rst +++ b/docs/library/ctypes.rst @@ -1,8 +1,6 @@ :mod:`uctypes` -- access binary data in a structured way ======================================================== -.. include:: ../templates/unsupported_in_circuitpython.inc - .. module:: uctypes :synopsis: access binary data in a structured way diff --git a/docs/library/framebuf.rst b/docs/library/framebuf.rst index a9cbc2fc47..42b5c9e732 100644 --- a/docs/library/framebuf.rst +++ b/docs/library/framebuf.rst @@ -105,16 +105,23 @@ Other methods Shift the contents of the FrameBuffer by the given vector. This may leave a footprint of the previous colors in the FrameBuffer. -.. method:: FrameBuffer.blit(fbuf, x, y[, key]) +.. method:: FrameBuffer.blit(fbuf, x, y, key=-1, palette=None) Draw another FrameBuffer on top of the current one at the given coordinates. If *key* is specified then it should be a color integer and the corresponding color will be considered transparent: all pixels with that color value will not be drawn. - This method works between FrameBuffer instances utilising different formats, - but the resulting colors may be unexpected due to the mismatch in color - formats. + The *palette* argument enables blitting between FrameBuffers with differing + formats. Typical usage is to render a monochrome or grayscale glyph/icon to + a color display. The *palette* is a FrameBuffer instance whose format is + that of the current FrameBuffer. The *palette* height is one pixel and its + pixel width is the number of colors in the source FrameBuffer. The *palette* + for an N-bit source needs 2**N pixels; the *palette* for a monochrome source + would have 2 pixels representing background and foreground colors. The + application assigns a color to each pixel in the *palette*. The color of the + current pixel will be that of that *palette* pixel whose x position is the + color of the corresponding source pixel. Constants --------- diff --git a/docs/library/uheapq.rst b/docs/library/heapq.rst similarity index 89% rename from docs/library/uheapq.rst rename to docs/library/heapq.rst index 6ee79fcc19..7269422847 100644 --- a/docs/library/uheapq.rst +++ b/docs/library/heapq.rst @@ -1,9 +1,9 @@ -:mod:`uheapq` -- heap queue algorithm -===================================== +:mod:`heapq` -- heap queue algorithm +==================================== .. include:: ../templates/unsupported_in_circuitpython.inc -.. module:: uheapq +.. module:: heapq :synopsis: heap queue algorithm |see_cpython_module| :mod:`cpython:heapq`. diff --git a/docs/library/index.rst b/docs/library/index.rst index 9a7f9afd84..5d8dd3118f 100644 --- a/docs/library/index.rst +++ b/docs/library/index.rst @@ -18,15 +18,14 @@ These libraries are not enabled on CircuitPython builds with limited flash memory, usually on non-Express builds: ``binascii``, ``errno``, ``json``, ``re``. -These libraries are not currently enabled in any CircuitPython build, but may be in the future, -with the ``u`` prefix dropped: -``uctypes``, ``uhashlib``, ``uzlib``. +These libraries are not currently enabled in any CircuitPython build, but may be in the future: +``ctypes``, ``hashlib``, ``zlib``. .. toctree:: :maxdepth: 1 builtins.rst - uheapq.rst + heapq.rst array.rst binascii.rst collections.rst @@ -37,10 +36,10 @@ with the ``u`` prefix dropped: json.rst re.rst sys.rst - uasyncio.rst - uctypes.rst - uselect.rst - uzlib.rst + asyncio.rst + ctypes.rst + select.rst + zlib.rst Omitted functions in the ``string`` library ------------------------------------------- diff --git a/docs/library/uselect.rst b/docs/library/select.rst similarity index 84% rename from docs/library/uselect.rst rename to docs/library/select.rst index cb7818dc06..84792bc53a 100644 --- a/docs/library/uselect.rst +++ b/docs/library/select.rst @@ -1,9 +1,9 @@ -:mod:`uselect` -- wait for events on a set of streams -======================================================================== +:mod:`select` -- wait for events on a set of streams +==================================================== .. include:: ../templates/unsupported_in_circuitpython.inc -.. module:: uselect +.. module:: select :synopsis: wait for events on a set of streams |see_cpython_module| :mod:`cpython:select`. @@ -37,15 +37,15 @@ Methods Register ``stream`` *obj* for polling. *eventmask* is logical OR of: - * ``uselect.POLLIN`` - data available for reading - * ``uselect.POLLOUT`` - more data can be written + * ``select.POLLIN`` - data available for reading + * ``select.POLLOUT`` - more data can be written - Note that flags like ``uselect.POLLHUP`` and ``uselect.POLLERR`` are + Note that flags like ``select.POLLHUP`` and ``select.POLLERR`` are *not* valid as input eventmask (these are unsolicited events which will be returned from `poll()` regardless of whether they are asked for). This semantics is per POSIX. - *eventmask* defaults to ``uselect.POLLIN | uselect.POLLOUT``. + *eventmask* defaults to ``select.POLLIN | select.POLLOUT``. It is OK to call this function multiple times for the same *obj*. Successive calls will update *obj*'s eventmask to the value of @@ -69,8 +69,8 @@ Methods Returns list of (``obj``, ``event``, ...) tuples. There may be other elements in tuple, depending on a platform and version, so don't assume that its size is 2. The ``event`` element specifies which events happened with a stream and - is a combination of ``uselect.POLL*`` constants described above. Note that - flags ``uselect.POLLHUP`` and ``uselect.POLLERR`` can be returned at any time + is a combination of ``select.POLL*`` constants described above. Note that + flags ``select.POLLHUP`` and ``select.POLLERR`` can be returned at any time (even if were not asked for), and must be acted on accordingly (the corresponding stream unregistered from poll and likely closed), because otherwise all further invocations of `poll()` may return immediately with diff --git a/docs/library/uzlib.rst b/docs/library/zlib.rst similarity index 94% rename from docs/library/uzlib.rst rename to docs/library/zlib.rst index 9a6c471f76..8f69f4b7c8 100644 --- a/docs/library/uzlib.rst +++ b/docs/library/zlib.rst @@ -1,9 +1,9 @@ -:mod:`uzlib` -- zlib decompression -================================== +:mod:`zlib` -- zlib decompression +================================= .. include:: ../templates/unsupported_in_circuitpython.inc -.. module:: uzlib +.. module:: zlib :synopsis: zlib decompression |see_cpython_module| :mod:`cpython:zlib`. diff --git a/docs/troubleshooting.rst b/docs/troubleshooting.rst index d78c1a4568..7fad2aac18 100644 --- a/docs/troubleshooting.rst +++ b/docs/troubleshooting.rst @@ -11,32 +11,35 @@ If your host computer starts complaining that your ``CIRCUITPY`` drive is corrup or files cannot be overwritten or deleted, then you will have to erase it completely. When CircuitPython restarts it will create a fresh empty ``CIRCUITPY`` filesystem. -This often happens on Windows when the ``CIRCUITPY`` disk is not safely ejected +Corruption often happens on Windows when the ``CIRCUITPY`` disk is not safely ejected before being reset by the button or being disconnected from USB. This can also happen on Linux and Mac OSX but it's less likely. .. caution:: To erase and re-create ``CIRCUITPY`` (for example, to correct a corrupted filesystem), follow one of the procedures below. It's important to note that **any files stored on the** - ``CIRCUITPY`` **drive will be erased**. + ``CIRCUITPY`` **drive will be erased. Back up your code if possible before continuing!** -**For boards with** ``CIRCUITPY`` **stored on a separate SPI flash chip, -such as Feather M0 Express, Metro M0 Express and Circuit Playground Express:** +REPL Erase Method +^^^^^^^^^^^^^^^^^ +This is the recommended method of erasing your board. If you are having trouble accessing the +``CIRCUITPY`` drive or the REPL, consider first putting your board into +`safe mode `_. +**To erase any board if you have access to the REPL:** -#. Download the appropriate flash .erase uf2 from `the Adafruit_SPIFlash repo `_. -#. Double-click the reset button. -#. Copy the appropriate .uf2 to the xxxBOOT drive. -#. The on-board NeoPixel will turn blue, indicating the erase has started. -#. After about 15 seconds, the NexoPixel will start flashing green. If it flashes red, the erase failed. -#. Double-click again and load the appropriate `CircuitPython .uf2 `_. +#. Connect to the CircuitPython REPL using a terminal program. +#. Type ``import storage`` into the REPL. +#. Then, type ``storage.erase_filesystem()`` into the REPL. +#. The ``CIRCUITPY`` drive will be erased and the board will restart with an empty ``CIRCUITPY`` drive. -**For boards without SPI flash, such as Feather M0 Proto, Gemma M0 and, Trinket M0:** +Erase File Method +^^^^^^^^^^^^^^^^^ +**If you do not have access to the REPL, you may still have options to erase your board.** -#. Download the appropriate erase .uf2 from `the Learn repo `_. -#. Double-click the reset button. -#. Copy the appropriate .uf2 to the xxxBOOT drive. -#. The boot LED will start pulsing again, and the xxxBOOT drive will appear again. -#. Load the appropriate `CircuitPython .uf2 `_. +The `Erase CIRCUITPY Without Access to the REPL `_ +section of the Troubleshooting page in the Welcome to CircuitPython guide covers the non-REPL +erase process for various boards. Visit the guide, find the process that applies to your board, +and follow the instructions to erase your board. ValueError: Incompatible ``.mpy`` file. --------------------------------------- diff --git a/examples/natmod/btree/btree_c.c b/examples/natmod/btree/btree_c.c index a58a38e11e..5e8a34ac40 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, false); + void *ptr = m_malloc(n); 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, false); + void *ptr = m_malloc(n * m); // memory already cleared by conservative GC return ptr; } diff --git a/examples/natmod/features2/main.c b/examples/natmod/features2/main.c index 60c48b0f72..1a39700dc4 100644 --- a/examples/natmod/features2/main.c +++ b/examples/natmod/features2/main.c @@ -46,7 +46,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(add_d_obj, add_d); // to use but has access to the globals dict of the module via self->globals. STATIC mp_obj_t productf(mp_obj_fun_bc_t *self, size_t n_args, size_t n_kw, mp_obj_t *args) { // Check number of arguments is valid - mp_arg_check_num_mp(n_args, n_kw, 1, 1, false); + mp_arg_check_num(n_args, n_kw, 1, 1, false); // Extract buffer pointer and verify typecode mp_buffer_info_t bufinfo; diff --git a/examples/usercmodule/cexample/examplemodule.c b/examples/usercmodule/cexample/examplemodule.c index f608823c9e..49ebc7aaaf 100644 --- a/examples/usercmodule/cexample/examplemodule.c +++ b/examples/usercmodule/cexample/examplemodule.c @@ -31,4 +31,7 @@ const mp_obj_module_t example_user_cmodule = { }; // Register the module to make it available in Python. -MP_REGISTER_MODULE(MP_QSTR_cexample, example_user_cmodule, MODULE_CEXAMPLE_ENABLED); +// Note: the "1" in the third argument means this module is always enabled. +// This "1" can be optionally replaced with a macro like MODULE_CEXAMPLE_ENABLED +// which can then be used to conditionally enable this module. +MP_REGISTER_MODULE(MP_QSTR_cexample, example_user_cmodule, 1); diff --git a/examples/usercmodule/cexample/micropython.cmake b/examples/usercmodule/cexample/micropython.cmake new file mode 100644 index 0000000000..ba076a16b2 --- /dev/null +++ b/examples/usercmodule/cexample/micropython.cmake @@ -0,0 +1,15 @@ +# Create an INTERFACE library for our C module. +add_library(usermod_cexample INTERFACE) + +# Add our source files to the lib +target_sources(usermod_cexample INTERFACE + ${CMAKE_CURRENT_LIST_DIR}/examplemodule.c +) + +# Add the current directory as an include directory. +target_include_directories(usermod_cexample INTERFACE + ${CMAKE_CURRENT_LIST_DIR} +) + +# Link our INTERFACE library to the usermod target. +target_link_libraries(usermod INTERFACE usermod_cexample) diff --git a/examples/usercmodule/cppexample/examplemodule.c b/examples/usercmodule/cppexample/examplemodule.c index ceb588bef6..dfb7856837 100644 --- a/examples/usercmodule/cppexample/examplemodule.c +++ b/examples/usercmodule/cppexample/examplemodule.c @@ -22,4 +22,7 @@ const mp_obj_module_t cppexample_user_cmodule = { }; // Register the module to make it available in Python. -MP_REGISTER_MODULE(MP_QSTR_cppexample, cppexample_user_cmodule, MODULE_CPPEXAMPLE_ENABLED); +// Note: the "1" in the third argument means this module is always enabled. +// This "1" can be optionally replaced with a macro like MODULE_CPPEXAMPLE_ENABLED +// which can then be used to conditionally enable this module. +MP_REGISTER_MODULE(MP_QSTR_cppexample, cppexample_user_cmodule, 1); diff --git a/examples/usercmodule/cppexample/micropython.cmake b/examples/usercmodule/cppexample/micropython.cmake new file mode 100644 index 0000000000..6da972c94e --- /dev/null +++ b/examples/usercmodule/cppexample/micropython.cmake @@ -0,0 +1,16 @@ +# Create an INTERFACE library for our CPP module. +add_library(usermod_cppexample INTERFACE) + +# Add our source files to the library. +target_sources(usermod_cppexample INTERFACE + ${CMAKE_CURRENT_LIST_DIR}/example.cpp + ${CMAKE_CURRENT_LIST_DIR}/examplemodule.c +) + +# Add the current directory as an include directory. +target_include_directories(usermod_cppexample INTERFACE + ${CMAKE_CURRENT_LIST_DIR} +) + +# Link our INTERFACE library to the usermod target. +target_link_libraries(usermod INTERFACE usermod_cppexample) diff --git a/examples/usercmodule/micropython.cmake b/examples/usercmodule/micropython.cmake new file mode 100644 index 0000000000..b9802401fa --- /dev/null +++ b/examples/usercmodule/micropython.cmake @@ -0,0 +1,10 @@ +# This top-level micropython.cmake is responsible for listing +# the individual modules we want to include. +# Paths are absolute, and ${CMAKE_CURRENT_LIST_DIR} can be +# used to prefix subdirectories. + +# Add the C example. +include(${CMAKE_CURRENT_LIST_DIR}/cexample/micropython.cmake) + +# Add the CPP example. +include(${CMAKE_CURRENT_LIST_DIR}/cppexample/micropython.cmake) diff --git a/extmod/axtls-include/axtls_os_port.h b/extmod/axtls-include/axtls_os_port.h new file mode 100644 index 0000000000..ef2683acfc --- /dev/null +++ b/extmod/axtls-include/axtls_os_port.h @@ -0,0 +1,55 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 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 + * 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 AXTLS_OS_PORT_H +#define AXTLS_OS_PORT_H + +#include +#include "py/stream.h" +#include "lib/crypto-algorithms/sha256.h" + +#define SSL_CTX_MUTEX_INIT(mutex) +#define SSL_CTX_MUTEX_DESTROY(mutex) +#define SSL_CTX_LOCK(mutex) +#define SSL_CTX_UNLOCK(mutex) + +#define SOCKET_READ(s, buf, size) mp_stream_posix_read((void *)s, buf, size) +#define SOCKET_WRITE(s, buf, size) mp_stream_posix_write((void *)s, buf, size) +#define SOCKET_CLOSE(A) UNUSED +#define SOCKET_ERRNO() errno + +#define SHA256_CTX CRYAL_SHA256_CTX +#define SHA256_Init(ctx) sha256_init(ctx) +#define SHA256_Update(ctx, buf, size) sha256_update(ctx, buf, size) +#define SHA256_Final(hash, ctx) sha256_final(ctx, hash) + +#define TTY_FLUSH() + +#ifdef WDEV_HWRNG +// For esp8266 port: use the hardware RNG. +#define PLATFORM_RNG_U8() (*WDEV_HWRNG) +#endif + +#endif // AXTLS_OS_PORT_H diff --git a/extmod/extmod.cmake b/extmod/extmod.cmake index a54047519d..c6b45b0d3e 100644 --- a/extmod/extmod.cmake +++ b/extmod/extmod.cmake @@ -4,8 +4,9 @@ set(MICROPY_EXTMOD_DIR "${MICROPY_DIR}/extmod") set(MICROPY_OOFATFS_DIR "${MICROPY_DIR}/lib/oofatfs") set(MICROPY_SOURCE_EXTMOD - ${MICROPY_DIR}/lib/embed/abort_.c - ${MICROPY_DIR}/lib/utils/printf.c + ${MICROPY_DIR}/shared/libc/abort_.c + ${MICROPY_DIR}/shared/libc/printf.c + ${MICROPY_EXTMOD_DIR}/machine_bitstream.c ${MICROPY_EXTMOD_DIR}/machine_i2c.c ${MICROPY_EXTMOD_DIR}/machine_mem.c ${MICROPY_EXTMOD_DIR}/machine_pulse.c diff --git a/extmod/extmod.mk b/extmod/extmod.mk index 5e12ee75d4..4cdeaedaf9 100644 --- a/extmod/extmod.mk +++ b/extmod/extmod.mk @@ -157,7 +157,7 @@ LWIP_DIR = lib/lwip/src INC += -I$(TOP)/$(LWIP_DIR)/include CFLAGS_MOD += -DMICROPY_PY_LWIP=1 $(BUILD)/$(LWIP_DIR)/core/ipv4/dhcp.o: CFLAGS_MOD += -Wno-address -SRC_MOD += extmod/modlwip.c lib/netutils/netutils.c +SRC_MOD += extmod/modlwip.c shared/netutils/netutils.c SRC_MOD += $(addprefix $(LWIP_DIR)/,\ apps/mdns/mdns.c \ core/def.c \ diff --git a/extmod/modframebuf.c b/extmod/modframebuf.c index 6168e86843..fa07b69522 100644 --- a/extmod/modframebuf.c +++ b/extmod/modframebuf.c @@ -244,8 +244,8 @@ STATIC void fill_rect(const mp_obj_framebuf_t *fb, int x, int y, int w, int h, u formats[fb->format].fill_rect(fb, x, y, xend - x, yend - y, col); } -STATIC mp_obj_t framebuf_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { - mp_arg_check_num(n_args, kw_args, 4, 5, false); +STATIC mp_obj_t framebuf_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { + mp_arg_check_num(n_args, n_kw, 4, 5, false); mp_obj_framebuf_t *o = m_new_obj(mp_obj_framebuf_t); o->base.type = type; @@ -481,6 +481,10 @@ STATIC mp_obj_t framebuf_blit(size_t n_args, const mp_obj_t *args) { if (n_args > 4) { key = mp_obj_get_int(args[4]); } + mp_obj_framebuf_t *palette = NULL; + if (n_args > 5 && args[5] != mp_const_none) { + palette = MP_OBJ_TO_PTR(mp_obj_cast_to_native_base(args[5], MP_OBJ_FROM_PTR(&mp_type_framebuf))); + } if ( (x >= self->width) || @@ -504,6 +508,9 @@ STATIC mp_obj_t framebuf_blit(size_t n_args, const mp_obj_t *args) { int cx1 = x1; for (int cx0 = x0; cx0 < x0end; ++cx0) { uint32_t col = getpixel(source, cx1, y1); + if (palette) { + col = getpixel(palette, col, 0); + } if (col != (uint32_t)key) { setpixel(self, cx0, y0, col); } @@ -513,7 +520,7 @@ STATIC mp_obj_t framebuf_blit(size_t n_args, const mp_obj_t *args) { } return mp_const_none; } -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(framebuf_blit_obj, 4, 5, framebuf_blit); +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(framebuf_blit_obj, 4, 6, framebuf_blit); STATIC mp_obj_t framebuf_scroll(mp_obj_t self_in, mp_obj_t xstep_in, mp_obj_t ystep_in) { mp_obj_framebuf_t *self = native_framebuf(self_in); diff --git a/extmod/moduasyncio.c b/extmod/moduasyncio.c index ff1558fae6..1f5cc618d0 100644 --- a/extmod/moduasyncio.c +++ b/extmod/moduasyncio.c @@ -31,6 +31,9 @@ #if MICROPY_PY_UASYNCIO +// Used when task cannot be guaranteed to be non-NULL. +#define TASK_PAIRHEAP(task) ((task) ? &(task)->pairheap : NULL) + #define TASK_STATE_RUNNING_NOT_WAITED_ON (mp_const_true) #define TASK_STATE_DONE_NOT_WAITED_ON (mp_const_none) #define TASK_STATE_DONE_WAS_WAITED_ON (mp_const_false) @@ -55,7 +58,7 @@ typedef struct _mp_obj_task_queue_t { 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, const mp_obj_t *args, mp_map_t *kw_args); +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); /******************************************************************************/ // Ticks for task ordering in pairing heap @@ -81,9 +84,9 @@ STATIC int task_lt(mp_pairheap_t *n1, mp_pairheap_t *n2) { /******************************************************************************/ // TaskQueue class -STATIC mp_obj_t task_queue_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { +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) { (void)args; - mp_arg_check_num(n_args, kw_args, 0, 0, false); + mp_arg_check_num(n_args, n_kw, 0, 0, false); mp_obj_task_queue_t *self = m_new_obj(mp_obj_task_queue_t); self->base.type = type; self->heap = (mp_obj_task_t *)mp_pairheap_new(task_lt); @@ -110,7 +113,7 @@ STATIC mp_obj_t task_queue_push_sorted(size_t n_args, const mp_obj_t *args) { assert(mp_obj_is_small_int(args[2])); task->ph_key = args[2]; } - self->heap = (mp_obj_task_t *)mp_pairheap_push(task_lt, &self->heap->pairheap, &task->pairheap); + self->heap = (mp_obj_task_t *)mp_pairheap_push(task_lt, TASK_PAIRHEAP(self->heap), TASK_PAIRHEAP(task)); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(task_queue_push_sorted_obj, 2, 3, task_queue_push_sorted); @@ -156,8 +159,8 @@ STATIC const mp_obj_type_t task_queue_type = { // This is the core uasyncio context with cur_task, _task_queue and CancelledError. STATIC mp_obj_t uasyncio_context = MP_OBJ_NULL; -STATIC mp_obj_t task_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { - mp_arg_check_num(n_args, kw_args, 1, 2, false); +STATIC mp_obj_t task_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { + mp_arg_check_num(n_args, n_kw, 1, 2, false); mp_obj_task_t *self = m_new_obj(mp_obj_task_t); self->pairheap.base.type = type; mp_pairheap_init_node(task_lt, &self->pairheap); diff --git a/extmod/modubinascii.c b/extmod/modubinascii.c index 01a3c62f6c..b11b8bf8a8 100644 --- a/extmod/modubinascii.c +++ b/extmod/modubinascii.c @@ -205,7 +205,7 @@ 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/src/tinf.h" +#include "lib/uzlib/tinf.h" STATIC mp_obj_t mod_binascii_crc32(size_t n_args, const mp_obj_t *args) { mp_buffer_info_t bufinfo; @@ -235,3 +235,5 @@ const mp_obj_module_t mp_module_ubinascii = { .base = { &mp_type_module }, .globals = (mp_obj_dict_t *)&mp_module_binascii_globals, }; + +MP_REGISTER_MODULE(MP_QSTR_binascii, mp_module_ubinascii, MICROPY_PY_UBINASCII); diff --git a/extmod/moductypes.c b/extmod/moductypes.c index 3f7d543a72..265cbd6d5d 100644 --- a/extmod/moductypes.c +++ b/extmod/moductypes.c @@ -74,8 +74,8 @@ STATIC NORETURN void syntax_error(void) { mp_raise_TypeError(MP_ERROR_TEXT("syntax error in uctypes descriptor")); } -STATIC mp_obj_t uctypes_struct_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { - mp_arg_check_num(n_args, kw_args, 2, 3, false); +STATIC mp_obj_t uctypes_struct_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { + mp_arg_check_num(n_args, n_kw, 2, 3, false); mp_obj_uctypes_struct_t *o = m_new_obj(mp_obj_uctypes_struct_t); o->base.type = type; o->addr = (void *)(uintptr_t)mp_obj_int_get_truncated(args[0]); diff --git a/extmod/moduhashlib.c b/extmod/moduhashlib.c index 0dfd2c790a..741f43c74c 100644 --- a/extmod/moduhashlib.c +++ b/extmod/moduhashlib.c @@ -21,7 +21,7 @@ #if MICROPY_SSL_MBEDTLS #include "mbedtls/sha256.h" #else -#include "crypto-algorithms/sha256.h" +#include "lib/crypto-algorithms/sha256.h" #endif #endif @@ -106,11 +106,10 @@ static void check_not_unicode(const mp_obj_t arg) { } #if MICROPY_PY_UHASHLIB_SHA256 -#include "crypto-algorithms/sha256.c" -#endif +#include "lib/crypto-algorithms/sha256.c" -STATIC mp_obj_t uhashlib_sha256_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { - mp_arg_check_num(n_args, kw_args, 0, 1, false); +STATIC mp_obj_t uhashlib_sha256_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { + mp_arg_check_num(n_args, n_kw, 0, 1, false); mp_obj_hash_t *o = m_new_obj_var(mp_obj_hash_t, char, sizeof(CRYAL_SHA256_CTX)); o->base.type = type; o->final = false; @@ -160,6 +159,8 @@ STATIC const mp_obj_type_t uhashlib_sha256_type = { }; #endif +#endif + #if MICROPY_PY_UHASHLIB_SHA1 STATIC mp_obj_t uhashlib_sha1_update(mp_obj_t self_in, mp_obj_t arg); diff --git a/extmod/modujson.c b/extmod/modujson.c index a9d231785a..9a4db7c273 100644 --- a/extmod/modujson.c +++ b/extmod/modujson.c @@ -17,6 +17,62 @@ #if MICROPY_PY_UJSON +#if MICROPY_PY_UJSON_SEPARATORS + +enum { + DUMP_MODE_TO_STRING = 1, + DUMP_MODE_TO_STREAM = 2, +}; + +STATIC mp_obj_t mod_ujson_dump_helper(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args, unsigned int mode) { + enum { ARG_separators }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_separators, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_rom_obj = MP_ROM_NONE} }, + }; + + mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; + mp_arg_parse_all(n_args - mode, pos_args + mode, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + + mp_print_ext_t print_ext; + + if (args[ARG_separators].u_obj == mp_const_none) { + print_ext.item_separator = ", "; + print_ext.key_separator = ": "; + } else { + mp_obj_t *items; + mp_obj_get_array_fixed_n(args[ARG_separators].u_obj, 2, &items); + print_ext.item_separator = mp_obj_str_get_str(items[0]); + print_ext.key_separator = mp_obj_str_get_str(items[1]); + } + + if (mode == DUMP_MODE_TO_STRING) { + // dumps(obj) + vstr_t vstr; + vstr_init_print(&vstr, 8, &print_ext.base); + mp_obj_print_helper(&print_ext.base, pos_args[0], PRINT_JSON); + return mp_obj_new_str_from_vstr(&mp_type_str, &vstr); + } else { + // dump(obj, stream) + print_ext.base.data = MP_OBJ_TO_PTR(pos_args[1]); + print_ext.base.print_strn = mp_stream_write_adaptor; + mp_get_stream_raise(pos_args[1], MP_STREAM_OP_WRITE); + mp_obj_print_helper(&print_ext.base, pos_args[0], PRINT_JSON); + return mp_const_none; + } +} + +STATIC mp_obj_t mod_ujson_dump(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + return mod_ujson_dump_helper(n_args, pos_args, kw_args, DUMP_MODE_TO_STREAM); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_KW(mod_ujson_dump_obj, 2, mod_ujson_dump); + +STATIC mp_obj_t mod_ujson_dumps(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + return mod_ujson_dump_helper(n_args, pos_args, kw_args, DUMP_MODE_TO_STRING); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_KW(mod_ujson_dumps_obj, 1, mod_ujson_dumps); + +#else + STATIC mp_obj_t mod_ujson_dump(mp_obj_t obj, mp_obj_t stream) { mp_get_stream_raise(stream, MP_STREAM_OP_WRITE); mp_print_t print = {MP_OBJ_TO_PTR(stream), mp_stream_write_adaptor}; @@ -33,6 +89,7 @@ STATIC mp_obj_t mod_ujson_dumps(mp_obj_t obj) { return mp_obj_new_str_from_vstr(&mp_type_str, &vstr); } STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_ujson_dumps_obj, mod_ujson_dumps); +#endif #define JSON_DEBUG(...) (void)0 // #define JSON_DEBUG(...) mp_printf(&mp_plat_print __VA_OPT__(,) __VA_ARGS__) @@ -375,4 +432,6 @@ const mp_obj_module_t mp_module_ujson = { .globals = (mp_obj_dict_t *)&mp_module_ujson_globals, }; +MP_REGISTER_MODULE(MP_QSTR_json, mp_module_ujson, MICROPY_PY_UJSON); + #endif // MICROPY_PY_UJSON diff --git a/extmod/modure.c b/extmod/modure.c index 7fd7b09395..cca74a7267 100644 --- a/extmod/modure.c +++ b/extmod/modure.c @@ -16,7 +16,7 @@ #define re1_5_stack_chk() MP_STACK_CHECK() -#include "re1.5/re1.5.h" +#include "lib/re1.5/re1.5.h" #if MICROPY_PY_URE_DEBUG #define FLAG_DEBUG 0x1000 @@ -49,7 +49,7 @@ STATIC mp_obj_t match_group(mp_obj_t self_in, mp_obj_t no_in) { mp_obj_match_t *self = MP_OBJ_TO_PTR(self_in); mp_int_t no = mp_obj_get_int(no_in); if (no < 0 || no >= self->num_matches) { - mp_raise_arg1(&mp_type_IndexError, no_in); + mp_raise_type_arg(&mp_type_IndexError, no_in); } const char *start = self->caps[no * 2]; @@ -88,7 +88,7 @@ STATIC void match_span_helper(size_t n_args, const mp_obj_t *args, mp_obj_t span if (n_args == 2) { no = mp_obj_get_int(args[1]); if (no < 0 || no >= self->num_matches) { - mp_raise_arg1(&mp_type_IndexError, args[1]); + mp_raise_type_arg(&mp_type_IndexError, args[1]); } } @@ -345,7 +345,7 @@ STATIC mp_obj_t re_sub_helper(size_t n_args, const mp_obj_t *args) { } if (match_no >= (unsigned int)match->num_matches) { - mp_raise_arg1(&mp_type_IndexError, MP_OBJ_NEW_SMALL_INT(match_no)); + mp_raise_type_arg(&mp_type_IndexError, MP_OBJ_NEW_SMALL_INT(match_no)); } const char *start_match = match->caps[match_no * 2]; @@ -469,17 +469,19 @@ const mp_obj_module_t mp_module_ure = { .base = { &mp_type_module }, .globals = (mp_obj_dict_t *)&mp_module_re_globals, }; + +MP_REGISTER_MODULE(MP_QSTR_re, mp_module_ure, MICROPY_PY_URE); #endif // Source files #include'd here to make sure they're compiled in // only if module is enabled by config setting. #define re1_5_fatal(x) assert(!x) -#include "re1.5/compilecode.c" +#include "lib/re1.5/compilecode.c" #if MICROPY_PY_URE_DEBUG -#include "re1.5/dumpcode.c" +#include "lib/re1.5/dumpcode.c" #endif -#include "re1.5/recursiveloop.c" -#include "re1.5/charclass.c" +#include "lib/re1.5/recursiveloop.c" +#include "lib/re1.5/charclass.c" #endif // MICROPY_PY_URE diff --git a/extmod/moduselect.c b/extmod/moduselect.c index 3c66d69e32..1b9617fca9 100644 --- a/extmod/moduselect.c +++ b/extmod/moduselect.c @@ -87,6 +87,7 @@ STATIC mp_uint_t poll_map_poll(mp_map_t *poll_map, size_t *rwx_num) { return n_ready; } +#if MICROPY_PY_USELECT_SELECT // select(rlist, wlist, xlist[, timeout]) STATIC mp_obj_t select_select(size_t n_args, const mp_obj_t *args) { // get array data from tuple/list arguments @@ -153,6 +154,7 @@ STATIC mp_obj_t select_select(size_t n_args, const mp_obj_t *args) { } } MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_select_select_obj, 3, 4, select_select); +#endif // MICROPY_PY_USELECT_SELECT typedef struct _mp_obj_poll_t { mp_obj_base_t base; @@ -335,7 +337,9 @@ MP_DEFINE_CONST_FUN_OBJ_0(mp_select_poll_obj, select_poll); STATIC const mp_rom_map_elem_t mp_module_select_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_uselect) }, + #if MICROPY_PY_USELECT_SELECT { MP_ROM_QSTR(MP_QSTR_select), MP_ROM_PTR(&mp_select_select_obj) }, + #endif { MP_ROM_QSTR(MP_QSTR_poll), MP_ROM_PTR(&mp_select_poll_obj) }, { MP_ROM_QSTR(MP_QSTR_POLLIN), MP_ROM_INT(MP_STREAM_POLL_RD) }, { MP_ROM_QSTR(MP_QSTR_POLLOUT), MP_ROM_INT(MP_STREAM_POLL_WR) }, diff --git a/extmod/modutimeq.c b/extmod/modutimeq.c index b6b9fa44b5..495675ad1d 100644 --- a/extmod/modutimeq.c +++ b/extmod/modutimeq.c @@ -55,8 +55,8 @@ STATIC bool time_less_than(struct qentry *item, struct qentry *parent) { return res && res < (MODULO / 2); } -STATIC mp_obj_t utimeq_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { - mp_arg_check_num(n_args, kw_args, 1, 1, false); +STATIC mp_obj_t utimeq_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { + mp_arg_check_num(n_args, n_kw, 1, 1, false); mp_uint_t alloc = mp_obj_get_int(args[0]); mp_obj_utimeq_t *o = m_new_obj_var(mp_obj_utimeq_t, struct qentry, alloc); o->base.type = type; diff --git a/extmod/moduzlib.c b/extmod/moduzlib.c index fe6faf6d04..7f2dad476f 100644 --- a/extmod/moduzlib.c +++ b/extmod/moduzlib.c @@ -15,7 +15,7 @@ #if MICROPY_PY_UZLIB #define UZLIB_CONF_PARANOID_CHECKS (1) -#include "../lib/uzlib/src/tinf.h" +#include "lib/uzlib/tinf.h" #if 0 // print debugging info #define DEBUG_printf DEBUG_printf @@ -48,8 +48,8 @@ STATIC int read_src_stream(TINF_DATA *data) { return c; } -STATIC mp_obj_t decompio_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { - mp_arg_check_num(n_args, kw_args, 1, 2, false); +STATIC mp_obj_t decompio_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { + mp_arg_check_num(n_args, n_kw, 1, 2, false); mp_get_stream_raise(args[0], MP_STREAM_OP_READ); mp_obj_decompio_t *o = m_new_obj(mp_obj_decompio_t); o->base.type = type; @@ -186,7 +186,7 @@ STATIC mp_obj_t mod_uzlib_decompress(size_t n_args, const mp_obj_t *args) { return res; error: - mp_raise_arg1(&mp_type_ValueError, MP_OBJ_NEW_SMALL_INT(st)); + mp_raise_type_arg(&mp_type_ValueError, MP_OBJ_NEW_SMALL_INT(st)); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_uzlib_decompress_obj, 1, 3, mod_uzlib_decompress); @@ -209,10 +209,10 @@ const mp_obj_module_t mp_module_uzlib = { // only if module is enabled by config setting. #pragma GCC diagnostic ignored "-Wsign-compare" -#include "../lib/uzlib/src/tinflate.c" -#include "../lib/uzlib/src/tinfzlib.c" -#include "../lib/uzlib/src/tinfgzip.c" -#include "../lib/uzlib/src/adler32.c" -#include "../lib/uzlib/src/crc32.c" +#include "lib/uzlib/tinflate.c" +#include "lib/uzlib/tinfzlib.c" +#include "lib/uzlib/tinfgzip.c" +#include "lib/uzlib/adler32.c" +#include "lib/uzlib/crc32.c" #endif // MICROPY_PY_UZLIB diff --git a/extmod/uasyncio/stream.py b/extmod/uasyncio/stream.py index 3a68881da3..af3b8feab3 100644 --- a/extmod/uasyncio/stream.py +++ b/extmod/uasyncio/stream.py @@ -79,8 +79,8 @@ async def open_connection(host, port): from uerrno import EINPROGRESS import usocket as socket - ai = socket.getaddrinfo(host, port)[0] # TODO this is blocking! - s = socket.socket() + ai = socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM)[0] # TODO this is blocking! + s = socket.socket(ai[0], ai[1], ai[2]) s.setblocking(False) ss = Stream(s) try: @@ -107,15 +107,7 @@ class Server: async def wait_closed(self): await self.task - async def _serve(self, cb, host, port, backlog): - import usocket as socket - - ai = socket.getaddrinfo(host, port)[0] # TODO this is blocking! - s = socket.socket() - s.setblocking(False) - s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) - s.bind(ai[-1]) - s.listen(backlog) + async def _serve(self, s, cb): # Accept incoming connections while True: try: @@ -137,9 +129,20 @@ class Server: # Helper function to start a TCP stream server, running as a new task # TODO could use an accept-callback on socket read activity instead of creating a task async def start_server(cb, host, port, backlog=5): - s = Server() - s.task = core.create_task(s._serve(cb, host, port, backlog)) - return s + import usocket as socket + + # Create and bind server socket. + host = socket.getaddrinfo(host, port)[0] # TODO this is blocking! + s = socket.socket() + s.setblocking(False) + s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) + s.bind(host[-1]) + s.listen(backlog) + + # Create and return server object and task. + srv = Server() + srv.task = core.create_task(srv._serve(s, cb)) + return srv ################################################################################ diff --git a/extmod/ulab b/extmod/ulab index 8d93ddeaf3..b913d064e5 160000 --- a/extmod/ulab +++ b/extmod/ulab @@ -1 +1 @@ -Subproject commit 8d93ddeaf3548d5466cee0a392a4ee89f07ce2e5 +Subproject commit b913d064e525f674d0219524988e6d9d834fe09c diff --git a/extmod/utime_mphal.c b/extmod/utime_mphal.c index 0501724a67..0d6437a920 100644 --- a/extmod/utime_mphal.c +++ b/extmod/utime_mphal.c @@ -27,7 +27,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(mp_utime_sleep_obj, time_sleep); STATIC mp_obj_t time_sleep_ms(mp_obj_t arg) { mp_int_t ms = mp_obj_get_int(arg); - if (ms > 0) { + if (ms >= 0) { mp_hal_delay_ms(ms); } return mp_const_none; diff --git a/extmod/vfs.c b/extmod/vfs.c index b3eeb4e4cf..7aa82a6082 100644 --- a/extmod/vfs.c +++ b/extmod/vfs.c @@ -150,7 +150,7 @@ STATIC mp_obj_t mp_vfs_autodetect(mp_obj_t bdev_obj) { #if MICROPY_VFS_LFS1 if (memcmp(&buf[32], "littlefs", 8) == 0) { // LFS1 - mp_obj_t vfs = mp_type_vfs_lfs1.make_new(&mp_type_vfs_lfs1, 1, &bdev_obj, NULL); + mp_obj_t vfs = mp_type_vfs_lfs1.make_new(&mp_type_vfs_lfs1, 1, 0, &bdev_obj); nlr_pop(); return vfs; } @@ -158,7 +158,7 @@ STATIC mp_obj_t mp_vfs_autodetect(mp_obj_t bdev_obj) { #if MICROPY_VFS_LFS2 if (memcmp(&buf[0], "littlefs", 8) == 0) { // LFS2 - mp_obj_t vfs = mp_type_vfs_lfs2.make_new(&mp_type_vfs_lfs2, 1, &bdev_obj, NULL); + mp_obj_t vfs = mp_type_vfs_lfs2.make_new(&mp_type_vfs_lfs2, 1, 0, &bdev_obj); nlr_pop(); return vfs; } @@ -171,7 +171,7 @@ STATIC mp_obj_t mp_vfs_autodetect(mp_obj_t bdev_obj) { #endif #if MICROPY_VFS_FAT - return mp_fat_vfs_type.make_new(&mp_fat_vfs_type, 1, &bdev_obj, NULL); + return mp_fat_vfs_type.make_new(&mp_fat_vfs_type, 1, 0, &bdev_obj); #endif // no filesystem found diff --git a/extmod/vfs_fat.c b/extmod/vfs_fat.c index f232fd6a80..208cf101f9 100644 --- a/extmod/vfs_fat.c +++ b/extmod/vfs_fat.c @@ -18,7 +18,7 @@ #include "py/mperrno.h" #include "lib/oofatfs/ff.h" #include "extmod/vfs_fat.h" -#include "lib/timeutils/timeutils.h" +#include "shared/timeutils/timeutils.h" #include "supervisor/filesystem.h" #include "supervisor/shared/translate.h" @@ -45,8 +45,8 @@ STATIC mp_import_stat_t fat_vfs_import_stat(void *vfs_in, const char *path) { return MP_IMPORT_STAT_NO_EXIST; } -STATIC mp_obj_t fat_vfs_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { - mp_arg_check_num(n_args, kw_args, 1, 1, false); +STATIC mp_obj_t fat_vfs_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { + mp_arg_check_num(n_args, n_kw, 1, 1, false); // create new object fs_user_mount_t *vfs = m_new_obj(fs_user_mount_t); @@ -88,7 +88,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(fat_vfs_del_obj, fat_vfs_del); STATIC mp_obj_t fat_vfs_mkfs(mp_obj_t bdev_in) { // create new object - fs_user_mount_t *vfs = MP_OBJ_TO_PTR(fat_vfs_make_new(&mp_fat_vfs_type, 1, &bdev_in, NULL)); + fs_user_mount_t *vfs = MP_OBJ_TO_PTR(fat_vfs_make_new(&mp_fat_vfs_type, 1, 0, &bdev_in)); // make the filesystem uint8_t working_buf[FF_MAX_SS]; diff --git a/extmod/vfs_fat_file.c b/extmod/vfs_fat_file.c index 2f005e4d15..17b142b95a 100644 --- a/extmod/vfs_fat_file.c +++ b/extmod/vfs_fat_file.c @@ -209,9 +209,9 @@ STATIC mp_obj_t file_open(fs_user_mount_t *vfs, const mp_obj_type_t *type, mp_ar return MP_OBJ_FROM_PTR(o); } -STATIC mp_obj_t file_obj_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { +STATIC mp_obj_t file_obj_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { mp_arg_val_t arg_vals[FILE_OPEN_NUM_ARGS]; - mp_arg_parse_all(n_args, args, kw_args, FILE_OPEN_NUM_ARGS, file_open_args, arg_vals); + mp_arg_parse_all_kw_array(n_args, n_kw, args, FILE_OPEN_NUM_ARGS, file_open_args, arg_vals); return file_open(NULL, type, arg_vals); } diff --git a/extmod/vfs_lfs.c b/extmod/vfs_lfs.c index dd78269a46..f6a9a24623 100644 --- a/extmod/vfs_lfs.c +++ b/extmod/vfs_lfs.c @@ -26,7 +26,7 @@ #include "py/runtime.h" #include "py/mphal.h" -#include "lib/timeutils/timeutils.h" +#include "shared/timeutils/timeutils.h" #include "extmod/vfs.h" #include "extmod/vfs_lfs.h" diff --git a/extmod/vfs_lfsx.c b/extmod/vfs_lfsx.c index 38a1daea20..872d7f8428 100644 --- a/extmod/vfs_lfsx.c +++ b/extmod/vfs_lfsx.c @@ -34,7 +34,7 @@ #include "py/objstr.h" #include "py/mperrno.h" #include "extmod/vfs.h" -#include "lib/timeutils/timeutils.h" +#include "shared/timeutils/timeutils.h" STATIC int MP_VFS_LFSx(dev_ioctl)(const struct LFSx_API (config) * c, int cmd, int arg, bool must_return_int) { mp_obj_t ret = mp_vfs_blockdev_ioctl(c->context, cmd, arg); @@ -113,9 +113,9 @@ const char *MP_VFS_LFSx(make_path)(MP_OBJ_VFS_LFSx * self, mp_obj_t path_in) { return path; } -STATIC mp_obj_t MP_VFS_LFSx(make_new)(const mp_obj_type_t * type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +STATIC mp_obj_t MP_VFS_LFSx(make_new)(const mp_obj_type_t * type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { mp_arg_val_t args[MP_ARRAY_SIZE(lfs_make_allowed_args)]; - mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(lfs_make_allowed_args), lfs_make_allowed_args, args); + mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(lfs_make_allowed_args), lfs_make_allowed_args, args); MP_OBJ_VFS_LFSx *self = m_new0(MP_OBJ_VFS_LFSx, 1); self->base.type = type; diff --git a/extmod/vfs_posix.c b/extmod/vfs_posix.c index f885e126ff..1d0aa09664 100644 --- a/extmod/vfs_posix.c +++ b/extmod/vfs_posix.c @@ -71,8 +71,8 @@ STATIC mp_import_stat_t mp_vfs_posix_import_stat(void *self_in, const char *path return MP_IMPORT_STAT_NO_EXIST; } -STATIC mp_obj_t vfs_posix_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { - mp_arg_check_num(n_args, kw_args, 0, 1, false); +STATIC mp_obj_t vfs_posix_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { + mp_arg_check_num(n_args, n_kw, 0, 1, false); mp_obj_vfs_posix_t *vfs = m_new_obj(mp_obj_vfs_posix_t); vfs->base.type = type; diff --git a/extmod/vfs_posix_file.c b/extmod/vfs_posix_file.c index 17aac97e15..8837fdbbd6 100644 --- a/extmod/vfs_posix_file.c +++ b/extmod/vfs_posix_file.c @@ -89,14 +89,14 @@ mp_obj_t mp_vfs_posix_file_open(const mp_obj_type_t *type, mp_obj_t file_in, mp_ return MP_OBJ_FROM_PTR(o); } -STATIC mp_obj_t vfs_posix_file_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { +STATIC mp_obj_t vfs_posix_file_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { static const mp_arg_t allowed_args[] = { { MP_QSTR_file, MP_ARG_OBJ | MP_ARG_REQUIRED, {.u_rom_obj = MP_ROM_NONE} }, { MP_QSTR_mode, MP_ARG_OBJ, {.u_rom_obj = MP_ROM_QSTR(MP_QSTR_r)} }, }; mp_arg_val_t arg_vals[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args, args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, arg_vals); + mp_arg_parse_all_kw_array(n_args, n_kw, args, MP_ARRAY_SIZE(allowed_args), allowed_args, arg_vals); return mp_vfs_posix_file_open(type, arg_vals[0].u_obj, arg_vals[1].u_obj); } diff --git a/frozen/circuitpython-stage b/frozen/circuitpython-stage index d0f1c46d7f..2c89a32906 160000 --- a/frozen/circuitpython-stage +++ b/frozen/circuitpython-stage @@ -1 +1 @@ -Subproject commit d0f1c46d7f879cd60562ee69900d619499d4d206 +Subproject commit 2c89a329063848bcd7dba6af6fb6c9d6036dd4f2 diff --git a/lib/README.md b/lib/README.md index e719821bfc..fd7cba910a 100644 --- a/lib/README.md +++ b/lib/README.md @@ -1,2 +1,3 @@ -This directory contains standard, low-level C libraries with emphasis on -being independent and efficient. They can be used by any port. +This directory contains third-party, low-level C libraries and SDKs. +Libraries that do not target any specific platform are generally chosen +based on them being independent and efficient. diff --git a/lib/axtls b/lib/axtls index 43a6e6bd3b..531cab9c27 160000 --- a/lib/axtls +++ b/lib/axtls @@ -1 +1 @@ -Subproject commit 43a6e6bd3bbc03dc501e16b89fba0ef042ed3ea0 +Subproject commit 531cab9c278c947d268bd4c94ecab9153a961b43 diff --git a/extmod/crypto-algorithms/sha256.c b/lib/crypto-algorithms/sha256.c similarity index 97% rename from extmod/crypto-algorithms/sha256.c rename to lib/crypto-algorithms/sha256.c index 4960589000..1d9484586b 100644 --- a/extmod/crypto-algorithms/sha256.c +++ b/lib/crypto-algorithms/sha256.c @@ -15,6 +15,7 @@ /*************************** HEADER FILES ***************************/ #include +#include #include #include "sha256.h" @@ -47,7 +48,7 @@ static void sha256_transform(CRYAL_SHA256_CTX *ctx, const BYTE data[]) WORD a, b, c, d, e, f, g, h, i, j, t1, t2, m[64]; for (i = 0, j = 0; i < 16; ++i, j += 4) - m[i] = (data[j] << 24) | (data[j + 1] << 16) | (data[j + 2] << 8) | (data[j + 3]); + m[i] = ((uint32_t)data[j] << 24) | (data[j + 1] << 16) | (data[j + 2] << 8) | (data[j + 3]); for ( ; i < 64; ++i) m[i] = SIG1(m[i - 2]) + m[i - 7] + SIG0(m[i - 15]) + m[i - 16]; diff --git a/extmod/crypto-algorithms/sha256.h b/lib/crypto-algorithms/sha256.h similarity index 100% rename from extmod/crypto-algorithms/sha256.h rename to lib/crypto-algorithms/sha256.h diff --git a/extmod/re1.5/charclass.c b/lib/re1.5/charclass.c similarity index 100% rename from extmod/re1.5/charclass.c rename to lib/re1.5/charclass.c diff --git a/extmod/re1.5/compilecode.c b/lib/re1.5/compilecode.c similarity index 100% rename from extmod/re1.5/compilecode.c rename to lib/re1.5/compilecode.c diff --git a/extmod/re1.5/dumpcode.c b/lib/re1.5/dumpcode.c similarity index 100% rename from extmod/re1.5/dumpcode.c rename to lib/re1.5/dumpcode.c diff --git a/extmod/re1.5/re1.5.h b/lib/re1.5/re1.5.h similarity index 100% rename from extmod/re1.5/re1.5.h rename to lib/re1.5/re1.5.h diff --git a/extmod/re1.5/recursiveloop.c b/lib/re1.5/recursiveloop.c similarity index 100% rename from extmod/re1.5/recursiveloop.c rename to lib/re1.5/recursiveloop.c diff --git a/lib/uzlib b/lib/uzlib deleted file mode 160000 index 27e4f4c15b..0000000000 --- a/lib/uzlib +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 27e4f4c15ba30c2cfc89575159e8efb50f95037e diff --git a/lib/uzlib/adler32.c b/lib/uzlib/adler32.c new file mode 100644 index 0000000000..1f1759493b --- /dev/null +++ b/lib/uzlib/adler32.c @@ -0,0 +1,78 @@ +/* + * Adler-32 checksum + * + * Copyright (c) 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. + */ + +/* + * Adler-32 algorithm taken from the zlib source, which is + * Copyright (C) 1995-1998 Jean-loup Gailly and Mark Adler + */ + +#include "tinf.h" + +#define A32_BASE 65521 +#define A32_NMAX 5552 + +uint32_t uzlib_adler32(const void *data, unsigned int length, uint32_t prev_sum /* 1 */) +{ + const unsigned char *buf = (const unsigned char *)data; + + unsigned int s1 = prev_sum & 0xffff; + unsigned int s2 = prev_sum >> 16; + + while (length > 0) + { + int k = length < A32_NMAX ? length : A32_NMAX; + int i; + + for (i = k / 16; i; --i, buf += 16) + { + s1 += buf[0]; s2 += s1; s1 += buf[1]; s2 += s1; + s1 += buf[2]; s2 += s1; s1 += buf[3]; s2 += s1; + s1 += buf[4]; s2 += s1; s1 += buf[5]; s2 += s1; + s1 += buf[6]; s2 += s1; s1 += buf[7]; s2 += s1; + + s1 += buf[8]; s2 += s1; s1 += buf[9]; s2 += s1; + s1 += buf[10]; s2 += s1; s1 += buf[11]; s2 += s1; + s1 += buf[12]; s2 += s1; s1 += buf[13]; s2 += s1; + s1 += buf[14]; s2 += s1; s1 += buf[15]; s2 += s1; + } + + for (i = k % 16; i; --i) { s1 += *buf++; s2 += s1; } + + s1 %= A32_BASE; + s2 %= A32_BASE; + + length -= k; + } + + return (s2 << 16) | s1; +} diff --git a/lib/uzlib/crc32.c b/lib/uzlib/crc32.c new file mode 100644 index 0000000000..e24c643b6a --- /dev/null +++ b/lib/uzlib/crc32.c @@ -0,0 +1,63 @@ +/* + * 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 + */ + +#include "tinf.h" + +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 */ +uint32_t 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*/; +} diff --git a/lib/uzlib/defl_static.h b/lib/uzlib/defl_static.h new file mode 100644 index 0000000000..292734d773 --- /dev/null +++ b/lib/uzlib/defl_static.h @@ -0,0 +1,45 @@ +/* + * Copyright (c) uzlib authors + * + * 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. + */ + +/* This files contains type declaration and prototypes for defl_static.c. + They may be altered/distinct from the originals used in PuTTY source + code. */ + +struct Outbuf { + unsigned char *outbuf; + int outlen, outsize; + unsigned long outbits; + int noutbits; + int comp_disabled; +}; + +void outbits(struct Outbuf *out, unsigned long bits, int nbits); +void zlib_start_block(struct Outbuf *ctx); +void zlib_finish_block(struct Outbuf *ctx); +void zlib_literal(struct Outbuf *ectx, unsigned char c); +void zlib_match(struct Outbuf *ectx, int distance, int len); diff --git a/lib/uzlib/tinf.h b/lib/uzlib/tinf.h new file mode 100644 index 0000000000..ae6e1c4073 --- /dev/null +++ b/lib/uzlib/tinf.h @@ -0,0 +1,3 @@ +/* Compatibility header for the original tinf lib/older versions of uzlib. + Note: may be removed in the future, please migrate to uzlib.h. */ +#include "uzlib.h" diff --git a/lib/uzlib/tinf_compat.h b/lib/uzlib/tinf_compat.h new file mode 100644 index 0000000000..f763804bd9 --- /dev/null +++ b/lib/uzlib/tinf_compat.h @@ -0,0 +1,9 @@ +/* This header contains compatibility defines for the original tinf API + and uzlib 2.x and below API. These defines are deprecated and going + to be removed in the future, so applications should migrate to new + uzlib API. */ +#define TINF_DATA struct uzlib_uncomp + +#define destSize dest_size +#define destStart dest_start +#define readSource source_read_cb diff --git a/lib/uzlib/tinfgzip.c b/lib/uzlib/tinfgzip.c new file mode 100644 index 0000000000..22b000df9a --- /dev/null +++ b/lib/uzlib/tinfgzip.c @@ -0,0 +1,110 @@ +/* + * uzlib - tiny deflate/inflate library (deflate, gzip, zlib) + * + * Copyright (c) 2003 by Joergen Ibsen / Jibz + * All Rights Reserved + * + * http://www.ibsensoftware.com/ + * + * Copyright (c) 2014-2018 by Paul Sokolovsky + * + * 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. + */ + +#include "tinf.h" + +#define FTEXT 1 +#define FHCRC 2 +#define FEXTRA 4 +#define FNAME 8 +#define FCOMMENT 16 + +void tinf_skip_bytes(TINF_DATA *d, int num); +uint16_t tinf_get_uint16(TINF_DATA *d); + +void tinf_skip_bytes(TINF_DATA *d, int num) +{ + while (num--) uzlib_get_byte(d); +} + +uint16_t tinf_get_uint16(TINF_DATA *d) +{ + unsigned int v = uzlib_get_byte(d); + v = (uzlib_get_byte(d) << 8) | v; + return v; +} + +int uzlib_gzip_parse_header(TINF_DATA *d) +{ + unsigned char flg; + + /* -- check format -- */ + + /* check id bytes */ + if (uzlib_get_byte(d) != 0x1f || uzlib_get_byte(d) != 0x8b) return TINF_DATA_ERROR; + + /* check method is deflate */ + if (uzlib_get_byte(d) != 8) return TINF_DATA_ERROR; + + /* get flag byte */ + flg = uzlib_get_byte(d); + + /* check that reserved bits are zero */ + if (flg & 0xe0) return TINF_DATA_ERROR; + + /* -- find start of compressed data -- */ + + /* skip rest of base header of 10 bytes */ + tinf_skip_bytes(d, 6); + + /* skip extra data if present */ + if (flg & FEXTRA) + { + unsigned int xlen = tinf_get_uint16(d); + tinf_skip_bytes(d, xlen); + } + + /* skip file name if present */ + if (flg & FNAME) { while (uzlib_get_byte(d)); } + + /* skip file comment if present */ + if (flg & FCOMMENT) { while (uzlib_get_byte(d)); } + + /* check header crc if present */ + if (flg & FHCRC) + { + /*unsigned int hcrc =*/ tinf_get_uint16(d); + + // TODO: Check! +// if (hcrc != (tinf_crc32(src, start - src) & 0x0000ffff)) +// return TINF_DATA_ERROR; + } + + /* initialize for crc32 checksum */ + d->checksum_type = TINF_CHKSUM_CRC; + d->checksum = ~0; + + return TINF_OK; +} diff --git a/lib/uzlib/tinflate.c b/lib/uzlib/tinflate.c new file mode 100644 index 0000000000..045952c755 --- /dev/null +++ b/lib/uzlib/tinflate.c @@ -0,0 +1,659 @@ +/* + * uzlib - tiny deflate/inflate library (deflate, gzip, zlib) + * + * Copyright (c) 2003 by Joergen Ibsen / Jibz + * All Rights Reserved + * http://www.ibsensoftware.com/ + * + * Copyright (c) 2014-2018 by Paul Sokolovsky + * + * 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. + */ + +#include +#include "tinf.h" + +#define UZLIB_DUMP_ARRAY(heading, arr, size) \ + { \ + printf("%s", heading); \ + for (int i = 0; i < size; ++i) { \ + printf(" %d", (arr)[i]); \ + } \ + printf("\n"); \ + } + +uint32_t tinf_get_le_uint32(TINF_DATA *d); +uint32_t tinf_get_be_uint32(TINF_DATA *d); + +/* --------------------------------------------------- * + * -- uninitialized global data (static structures) -- * + * --------------------------------------------------- */ + +#ifdef RUNTIME_BITS_TABLES + +/* extra bits and base tables for length codes */ +unsigned char length_bits[30]; +unsigned short length_base[30]; + +/* extra bits and base tables for distance codes */ +unsigned char dist_bits[30]; +unsigned short dist_base[30]; + +#else + +const unsigned char length_bits[30] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 1, 1, 2, 2, 2, 2, + 3, 3, 3, 3, 4, 4, 4, 4, + 5, 5, 5, 5 +}; +const unsigned short length_base[30] = { + 3, 4, 5, 6, 7, 8, 9, 10, + 11, 13, 15, 17, 19, 23, 27, 31, + 35, 43, 51, 59, 67, 83, 99, 115, + 131, 163, 195, 227, 258 +}; + +const unsigned char dist_bits[30] = { + 0, 0, 0, 0, 1, 1, 2, 2, + 3, 3, 4, 4, 5, 5, 6, 6, + 7, 7, 8, 8, 9, 9, 10, 10, + 11, 11, 12, 12, 13, 13 +}; +const unsigned short dist_base[30] = { + 1, 2, 3, 4, 5, 7, 9, 13, + 17, 25, 33, 49, 65, 97, 129, 193, + 257, 385, 513, 769, 1025, 1537, 2049, 3073, + 4097, 6145, 8193, 12289, 16385, 24577 +}; + +#endif + +/* special ordering of code length codes */ +const unsigned char clcidx[] = { + 16, 17, 18, 0, 8, 7, 9, 6, + 10, 5, 11, 4, 12, 3, 13, 2, + 14, 1, 15 +}; + +/* ----------------------- * + * -- utility functions -- * + * ----------------------- */ + +#ifdef RUNTIME_BITS_TABLES +/* build extra bits and base tables */ +static void tinf_build_bits_base(unsigned char *bits, unsigned short *base, int delta, int first) +{ + int i, sum; + + /* build bits table */ + for (i = 0; i < delta; ++i) bits[i] = 0; + for (i = 0; i < 30 - delta; ++i) bits[i + delta] = i / delta; + + /* build base table */ + for (sum = first, i = 0; i < 30; ++i) + { + base[i] = sum; + sum += 1 << bits[i]; + } +} +#endif + +/* build the fixed huffman trees */ +static void tinf_build_fixed_trees(TINF_TREE *lt, TINF_TREE *dt) +{ + int i; + + /* build fixed length tree */ + for (i = 0; i < 7; ++i) lt->table[i] = 0; + + lt->table[7] = 24; + lt->table[8] = 152; + lt->table[9] = 112; + + for (i = 0; i < 24; ++i) lt->trans[i] = 256 + i; + for (i = 0; i < 144; ++i) lt->trans[24 + i] = i; + for (i = 0; i < 8; ++i) lt->trans[24 + 144 + i] = 280 + i; + for (i = 0; i < 112; ++i) lt->trans[24 + 144 + 8 + i] = 144 + i; + + /* build fixed distance tree */ + for (i = 0; i < 5; ++i) dt->table[i] = 0; + + dt->table[5] = 32; + + for (i = 0; i < 32; ++i) dt->trans[i] = i; +} + +/* given an array of code lengths, build a tree */ +static void tinf_build_tree(TINF_TREE *t, const unsigned char *lengths, unsigned int num) +{ + unsigned short offs[16]; + unsigned int i, sum; + + /* clear code length count table */ + for (i = 0; i < 16; ++i) t->table[i] = 0; + + /* scan symbol lengths, and sum code length counts */ + for (i = 0; i < num; ++i) t->table[lengths[i]]++; + + #if UZLIB_CONF_DEBUG_LOG >= 2 + UZLIB_DUMP_ARRAY("codelen counts:", t->table, TINF_ARRAY_SIZE(t->table)); + #endif + + /* In the lengths array, 0 means unused code. So, t->table[0] now contains + number of unused codes. But table's purpose is to contain # of codes of + particular length, and there're 0 codes of length 0. */ + t->table[0] = 0; + + /* compute offset table for distribution sort */ + for (sum = 0, i = 0; i < 16; ++i) + { + offs[i] = sum; + sum += t->table[i]; + } + + #if UZLIB_CONF_DEBUG_LOG >= 2 + UZLIB_DUMP_ARRAY("codelen offsets:", offs, TINF_ARRAY_SIZE(offs)); + #endif + + /* create code->symbol translation table (symbols sorted by code) */ + for (i = 0; i < num; ++i) + { + if (lengths[i]) t->trans[offs[lengths[i]]++] = i; + } +} + +/* ---------------------- * + * -- decode functions -- * + * ---------------------- */ + +unsigned char uzlib_get_byte(TINF_DATA *d) +{ + /* If end of source buffer is not reached, return next byte from source + buffer. */ + if (d->source < d->source_limit) { + return *d->source++; + } + + /* Otherwise if there's callback and we haven't seen EOF yet, try to + read next byte using it. (Note: the callback can also update ->source + and ->source_limit). */ + if (d->readSource && !d->eof) { + int val = d->readSource(d); + if (val >= 0) { + return (unsigned char)val; + } + } + + /* Otherwise, we hit EOF (either from ->readSource() or from exhaustion + of the buffer), and it will be "sticky", i.e. further calls to this + function will end up here too. */ + d->eof = true; + + return 0; +} + +uint32_t tinf_get_le_uint32(TINF_DATA *d) +{ + uint32_t val = 0; + int i; + for (i = 4; i--;) { + val = val >> 8 | ((uint32_t)uzlib_get_byte(d)) << 24; + } + return val; +} + +uint32_t tinf_get_be_uint32(TINF_DATA *d) +{ + uint32_t val = 0; + int i; + for (i = 4; i--;) { + val = val << 8 | uzlib_get_byte(d); + } + return val; +} + +/* get one bit from source stream */ +static int tinf_getbit(TINF_DATA *d) +{ + unsigned int bit; + + /* check if tag is empty */ + if (!d->bitcount--) + { + /* load next tag */ + d->tag = uzlib_get_byte(d); + d->bitcount = 7; + } + + /* shift bit out of tag */ + bit = d->tag & 0x01; + d->tag >>= 1; + + return bit; +} + +/* read a num bit value from a stream and add base */ +static unsigned int tinf_read_bits(TINF_DATA *d, int num, int base) +{ + unsigned int val = 0; + + /* read num bits */ + if (num) + { + unsigned int limit = 1 << (num); + unsigned int mask; + + for (mask = 1; mask < limit; mask *= 2) + if (tinf_getbit(d)) val += mask; + } + + return val + base; +} + +/* given a data stream and a tree, decode a symbol */ +static int tinf_decode_symbol(TINF_DATA *d, TINF_TREE *t) +{ + int sum = 0, cur = 0, len = 0; + + /* get more bits while code value is above sum */ + do { + + cur = 2*cur + tinf_getbit(d); + + if (++len == TINF_ARRAY_SIZE(t->table)) { + return TINF_DATA_ERROR; + } + + sum += t->table[len]; + cur -= t->table[len]; + + } while (cur >= 0); + + sum += cur; + #if UZLIB_CONF_PARANOID_CHECKS + if (sum < 0 || sum >= TINF_ARRAY_SIZE(t->trans)) { + return TINF_DATA_ERROR; + } + #endif + + return t->trans[sum]; +} + +/* given a data stream, decode dynamic trees from it */ +static int tinf_decode_trees(TINF_DATA *d, TINF_TREE *lt, TINF_TREE *dt) +{ + /* code lengths for 288 literal/len symbols and 32 dist symbols */ + unsigned char lengths[288+32]; + unsigned int hlit, hdist, hclen, hlimit; + unsigned int i, num, length; + + /* get 5 bits HLIT (257-286) */ + hlit = tinf_read_bits(d, 5, 257); + + /* get 5 bits HDIST (1-32) */ + hdist = tinf_read_bits(d, 5, 1); + + /* get 4 bits HCLEN (4-19) */ + hclen = tinf_read_bits(d, 4, 4); + + for (i = 0; i < 19; ++i) lengths[i] = 0; + + /* read code lengths for code length alphabet */ + for (i = 0; i < hclen; ++i) + { + /* get 3 bits code length (0-7) */ + unsigned int clen = tinf_read_bits(d, 3, 0); + + lengths[clcidx[i]] = clen; + } + + /* build code length tree, temporarily use length tree */ + tinf_build_tree(lt, lengths, 19); + + /* decode code lengths for the dynamic trees */ + hlimit = hlit + hdist; + for (num = 0; num < hlimit; ) + { + int sym = tinf_decode_symbol(d, lt); + unsigned char fill_value = 0; + int lbits, lbase = 3; + + /* error decoding */ + if (sym < 0) return sym; + + switch (sym) + { + case 16: + /* copy previous code length 3-6 times (read 2 bits) */ + if (num == 0) return TINF_DATA_ERROR; + fill_value = lengths[num - 1]; + lbits = 2; + break; + case 17: + /* repeat code length 0 for 3-10 times (read 3 bits) */ + lbits = 3; + break; + case 18: + /* repeat code length 0 for 11-138 times (read 7 bits) */ + lbits = 7; + lbase = 11; + break; + default: + /* values 0-15 represent the actual code lengths */ + lengths[num++] = sym; + /* continue the for loop */ + continue; + } + + /* special code length 16-18 are handled here */ + length = tinf_read_bits(d, lbits, lbase); + if (num + length > hlimit) return TINF_DATA_ERROR; + for (; length; --length) + { + lengths[num++] = fill_value; + } + } + + #if UZLIB_CONF_DEBUG_LOG >= 2 + printf("lit code lengths (%d):", hlit); + UZLIB_DUMP_ARRAY("", lengths, hlit); + printf("dist code lengths (%d):", hdist); + UZLIB_DUMP_ARRAY("", lengths + hlit, hdist); + #endif + + #if UZLIB_CONF_PARANOID_CHECKS + /* Check that there's "end of block" symbol */ + if (lengths[256] == 0) { + return TINF_DATA_ERROR; + } + #endif + + /* build dynamic trees */ + tinf_build_tree(lt, lengths, hlit); + tinf_build_tree(dt, lengths + hlit, hdist); + + return TINF_OK; +} + +/* ----------------------------- * + * -- block inflate functions -- * + * ----------------------------- */ + +/* given a stream and two trees, inflate next byte of output */ +static int tinf_inflate_block_data(TINF_DATA *d, TINF_TREE *lt, TINF_TREE *dt) +{ + if (d->curlen == 0) { + unsigned int offs; + int dist; + int sym = tinf_decode_symbol(d, lt); + //printf("huff sym: %02x\n", sym); + + if (d->eof) { + return TINF_DATA_ERROR; + } + + /* literal byte */ + if (sym < 256) { + TINF_PUT(d, sym); + return TINF_OK; + } + + /* end of block */ + if (sym == 256) { + return TINF_DONE; + } + + /* substring from sliding dictionary */ + sym -= 257; + if (sym >= 29) { + return TINF_DATA_ERROR; + } + + /* possibly get more bits from length code */ + d->curlen = tinf_read_bits(d, length_bits[sym], length_base[sym]); + + dist = tinf_decode_symbol(d, dt); + if (dist >= 30) { + return TINF_DATA_ERROR; + } + + /* possibly get more bits from distance code */ + offs = tinf_read_bits(d, dist_bits[dist], dist_base[dist]); + + /* calculate and validate actual LZ offset to use */ + if (d->dict_ring) { + if (offs > d->dict_size) { + return TINF_DICT_ERROR; + } + /* Note: unlike full-dest-in-memory case below, we don't + try to catch offset which points to not yet filled + part of the dictionary here. Doing so would require + keeping another variable to track "filled in" size + of the dictionary. Appearance of such an offset cannot + lead to accessing memory outside of the dictionary + buffer, and clients which don't want to leak unrelated + information, should explicitly initialize dictionary + buffer passed to uzlib. */ + + d->lzOff = d->dict_idx - offs; + if (d->lzOff < 0) { + d->lzOff += d->dict_size; + } + } else { + /* catch trying to point before the start of dest buffer */ + if (offs > (unsigned int)(d->dest - d->destStart)) { + return TINF_DATA_ERROR; + } + d->lzOff = -offs; + } + } + + /* copy next byte from dict substring */ + if (d->dict_ring) { + TINF_PUT(d, d->dict_ring[d->lzOff]); + if ((unsigned)++d->lzOff == d->dict_size) { + d->lzOff = 0; + } + } else { + d->dest[0] = d->dest[d->lzOff]; + d->dest++; + } + d->curlen--; + return TINF_OK; +} + +/* inflate next byte from uncompressed block of data */ +static int tinf_inflate_uncompressed_block(TINF_DATA *d) +{ + if (d->curlen == 0) { + unsigned int length, invlength; + + /* get length */ + length = uzlib_get_byte(d); + length += 256 * uzlib_get_byte(d); + /* get one's complement of length */ + invlength = uzlib_get_byte(d); + invlength += 256 * uzlib_get_byte(d); + /* check length */ + if (length != (~invlength & 0x0000ffff)) return TINF_DATA_ERROR; + + /* increment length to properly return TINF_DONE below, without + producing data at the same time */ + d->curlen = length + 1; + + /* make sure we start next block on a byte boundary */ + d->bitcount = 0; + } + + if (--d->curlen == 0) { + return TINF_DONE; + } + + unsigned char c = uzlib_get_byte(d); + TINF_PUT(d, c); + return TINF_OK; +} + +/* ---------------------- * + * -- public functions -- * + * ---------------------- */ + +/* initialize global (static) data */ +void uzlib_init(void) +{ +#ifdef RUNTIME_BITS_TABLES + /* build extra bits and base tables */ + tinf_build_bits_base(length_bits, length_base, 4, 3); + tinf_build_bits_base(dist_bits, dist_base, 2, 1); + + /* fix a special case */ + length_bits[28] = 0; + length_base[28] = 258; +#endif +} + +/* initialize decompression structure */ +void uzlib_uncompress_init(TINF_DATA *d, void *dict, unsigned int dictLen) +{ + d->eof = 0; + d->bitcount = 0; + d->bfinal = 0; + d->btype = -1; + d->dict_size = dictLen; + d->dict_ring = dict; + d->dict_idx = 0; + d->curlen = 0; +} + +/* inflate next output bytes from compressed stream */ +int uzlib_uncompress(TINF_DATA *d) +{ + do { + int res; + + /* start a new block */ + if (d->btype == -1) { +next_blk: + /* read final block flag */ + d->bfinal = tinf_getbit(d); + /* read block type (2 bits) */ + d->btype = tinf_read_bits(d, 2, 0); + + #if UZLIB_CONF_DEBUG_LOG >= 1 + printf("Started new block: type=%d final=%d\n", d->btype, d->bfinal); + #endif + + if (d->btype == 1) { + /* build fixed huffman trees */ + tinf_build_fixed_trees(&d->ltree, &d->dtree); + } else if (d->btype == 2) { + /* decode trees from stream */ + res = tinf_decode_trees(d, &d->ltree, &d->dtree); + if (res != TINF_OK) { + return res; + } + } + } + + /* process current block */ + switch (d->btype) + { + case 0: + /* decompress uncompressed block */ + res = tinf_inflate_uncompressed_block(d); + break; + case 1: + case 2: + /* decompress block with fixed/dynamic huffman trees */ + /* trees were decoded previously, so it's the same routine for both */ + res = tinf_inflate_block_data(d, &d->ltree, &d->dtree); + break; + default: + return TINF_DATA_ERROR; + } + + if (res == TINF_DONE && !d->bfinal) { + /* the block has ended (without producing more data), but we + can't return without data, so start procesing next block */ + goto next_blk; + } + + if (res != TINF_OK) { + return res; + } + + } while (d->dest < d->dest_limit); + + return TINF_OK; +} + +/* inflate next output bytes from compressed stream, updating + checksum, and at the end of stream, verify it */ +int uzlib_uncompress_chksum(TINF_DATA *d) +{ + int res; + unsigned char *data = d->dest; + + res = uzlib_uncompress(d); + + if (res < 0) return res; + + switch (d->checksum_type) { + + case TINF_CHKSUM_ADLER: + d->checksum = uzlib_adler32(data, d->dest - data, d->checksum); + break; + + case TINF_CHKSUM_CRC: + d->checksum = uzlib_crc32(data, d->dest - data, d->checksum); + break; + } + + if (res == TINF_DONE) { + unsigned int val; + + switch (d->checksum_type) { + + case TINF_CHKSUM_ADLER: + val = tinf_get_be_uint32(d); + if (d->checksum != val) { + return TINF_CHKSUM_ERROR; + } + break; + + case TINF_CHKSUM_CRC: + val = tinf_get_le_uint32(d); + if (~d->checksum != val) { + return TINF_CHKSUM_ERROR; + } + // Uncompressed size. TODO: Check + val = tinf_get_le_uint32(d); + break; + } + } + + return res; +} diff --git a/lib/uzlib/tinfzlib.c b/lib/uzlib/tinfzlib.c new file mode 100644 index 0000000000..5cb8852fcc --- /dev/null +++ b/lib/uzlib/tinfzlib.c @@ -0,0 +1,66 @@ +/* + * uzlib - tiny deflate/inflate library (deflate, gzip, zlib) + * + * Copyright (c) 2003 by Joergen Ibsen / Jibz + * All Rights Reserved + * + * http://www.ibsensoftware.com/ + * + * Copyright (c) 2014-2018 by Paul Sokolovsky + * + * 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. + */ + +#include "tinf.h" + +int uzlib_zlib_parse_header(TINF_DATA *d) +{ + unsigned char cmf, flg; + + /* -- get header bytes -- */ + + cmf = uzlib_get_byte(d); + flg = uzlib_get_byte(d); + + /* -- check format -- */ + + /* check checksum */ + if ((256*cmf + flg) % 31) return TINF_DATA_ERROR; + + /* check method is deflate */ + if ((cmf & 0x0f) != 8) return TINF_DATA_ERROR; + + /* check window size is valid */ + if ((cmf >> 4) > 7) return TINF_DATA_ERROR; + + /* check there is no preset dictionary */ + if (flg & 0x20) return TINF_DATA_ERROR; + + /* initialize for adler32 checksum */ + d->checksum_type = TINF_CHKSUM_ADLER; + d->checksum = 1; + + return cmf >> 4; +} diff --git a/lib/uzlib/uzlib.h b/lib/uzlib/uzlib.h new file mode 100644 index 0000000000..3a4a1ad160 --- /dev/null +++ b/lib/uzlib/uzlib.h @@ -0,0 +1,169 @@ +/* + * uzlib - tiny deflate/inflate library (deflate, gzip, zlib) + * + * Copyright (c) 2003 by Joergen Ibsen / Jibz + * All Rights Reserved + * http://www.ibsensoftware.com/ + * + * Copyright (c) 2014-2018 by Paul Sokolovsky + * + * 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. + */ + +#ifndef UZLIB_H_INCLUDED +#define UZLIB_H_INCLUDED + +#include +#include +#include + +#include "defl_static.h" + +#include "uzlib_conf.h" +#if UZLIB_CONF_DEBUG_LOG +#include +#endif + +/* calling convention */ +#ifndef TINFCC + #ifdef __WATCOMC__ + #define TINFCC __cdecl + #else + #define TINFCC + #endif +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* ok status, more data produced */ +#define TINF_OK 0 +/* end of compressed stream reached */ +#define TINF_DONE 1 +#define TINF_DATA_ERROR (-3) +#define TINF_CHKSUM_ERROR (-4) +#define TINF_DICT_ERROR (-5) + +/* checksum types */ +#define TINF_CHKSUM_NONE 0 +#define TINF_CHKSUM_ADLER 1 +#define TINF_CHKSUM_CRC 2 + +/* helper macros */ +#define TINF_ARRAY_SIZE(arr) (sizeof(arr) / sizeof(*(arr))) + +/* data structures */ + +typedef struct { + unsigned short table[16]; /* table of code length counts */ + unsigned short trans[288]; /* code -> symbol translation table */ +} TINF_TREE; + +struct uzlib_uncomp { + /* Pointer to the next byte in the input buffer */ + const unsigned char *source; + /* Pointer to the next byte past the input buffer (source_limit = source + len) */ + const unsigned char *source_limit; + /* If source_limit == NULL, or source >= source_limit, this function + will be used to read next byte from source stream. The function may + also return -1 in case of EOF (or irrecoverable error). Note that + besides returning the next byte, it may also update source and + source_limit fields, thus allowing for buffered operation. */ + int (*source_read_cb)(struct uzlib_uncomp *uncomp); + + unsigned int tag; + unsigned int bitcount; + + /* Destination (output) buffer start */ + unsigned char *dest_start; + /* Current pointer in dest buffer */ + unsigned char *dest; + /* Pointer past the end of the dest buffer, similar to source_limit */ + unsigned char *dest_limit; + + /* Accumulating checksum */ + unsigned int checksum; + char checksum_type; + bool eof; + + int btype; + int bfinal; + unsigned int curlen; + int lzOff; + unsigned char *dict_ring; + unsigned int dict_size; + unsigned int dict_idx; + + TINF_TREE ltree; /* dynamic length/symbol tree */ + TINF_TREE dtree; /* dynamic distance tree */ +}; + +#include "tinf_compat.h" + +#define TINF_PUT(d, c) \ + { \ + *d->dest++ = c; \ + if (d->dict_ring) { d->dict_ring[d->dict_idx++] = c; if (d->dict_idx == d->dict_size) d->dict_idx = 0; } \ + } + +unsigned char TINFCC uzlib_get_byte(TINF_DATA *d); + +/* Decompression API */ + +void TINFCC uzlib_init(void); +void TINFCC uzlib_uncompress_init(TINF_DATA *d, void *dict, unsigned int dictLen); +int TINFCC uzlib_uncompress(TINF_DATA *d); +int TINFCC uzlib_uncompress_chksum(TINF_DATA *d); + +int TINFCC uzlib_zlib_parse_header(TINF_DATA *d); +int TINFCC uzlib_gzip_parse_header(TINF_DATA *d); + +/* Compression API */ + +typedef const uint8_t *uzlib_hash_entry_t; + +struct uzlib_comp { + struct Outbuf out; + + uzlib_hash_entry_t *hash_table; + unsigned int hash_bits; + unsigned int dict_size; +}; + +void TINFCC uzlib_compress(struct uzlib_comp *c, const uint8_t *src, unsigned slen); + +/* Checksum API */ + +/* prev_sum is previous value for incremental computation, 1 initially */ +uint32_t TINFCC uzlib_adler32(const void *data, unsigned int length, uint32_t prev_sum); +/* crc is previous value for incremental computation, 0xffffffff initially */ +uint32_t TINFCC uzlib_crc32(const void *data, unsigned int length, uint32_t crc); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* UZLIB_H_INCLUDED */ diff --git a/lib/uzlib/uzlib_conf.h b/lib/uzlib/uzlib_conf.h new file mode 100644 index 0000000000..d6c9407157 --- /dev/null +++ b/lib/uzlib/uzlib_conf.h @@ -0,0 +1,22 @@ +/* + * uzlib - tiny deflate/inflate library (deflate, gzip, zlib) + * + * Copyright (c) 2014-2018 by Paul Sokolovsky + */ + +#ifndef UZLIB_CONF_H_INCLUDED +#define UZLIB_CONF_H_INCLUDED + +#ifndef UZLIB_CONF_DEBUG_LOG +/* Debug logging level 0, 1, 2, etc. */ +#define UZLIB_CONF_DEBUG_LOG 0 +#endif + +#ifndef UZLIB_CONF_PARANOID_CHECKS +/* Perform extra checks on the input stream, even if they aren't proven + to be strictly required (== lack of them wasn't proven to lead to + crashes). */ +#define UZLIB_CONF_PARANOID_CHECKS 0 +#endif + +#endif /* UZLIB_CONF_H_INCLUDED */ diff --git a/locale/ID.po b/locale/ID.po index 88e1aa5407..8df69bdff3 100644 --- a/locale/ID.po +++ b/locale/ID.po @@ -110,10 +110,6 @@ msgstr "" msgid "%q length must be >= 1" msgstr "" -#: shared-bindings/vectorio/Polygon.c -msgid "%q list must be a list" -msgstr "daftar %q harus berupa daftar" - #: py/argcheck.c msgid "%q must <= %d" msgstr "" @@ -151,12 +147,12 @@ msgstr "%q harus berupa tuple dengan panjang 2" msgid "%q must be between %d and %d" msgstr "" -#: ports/atmel-samd/common-hal/busio/UART.c -msgid "%q must be power of 2" +#: py/argcheck.c +msgid "%q must be of type %q" msgstr "" -#: py/argcheck.c -msgid "%q must of type %q" +#: ports/atmel-samd/common-hal/busio/UART.c +msgid "%q must be power of 2" msgstr "" #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c @@ -172,6 +168,10 @@ msgstr "pin %q tidak valid" msgid "%q should be an int" msgstr "%q harus berupa int" +#: shared-bindings/usb_hid/Device.c +msgid "%q with a report ID of 0 must be of length 1" +msgstr "" + #: py/bc.c py/objnamedtuple.c msgid "%q() takes %d positional arguments but %d were given" msgstr "%q() mengambil posisi argumen %d tapi %d yang diberikan" @@ -354,6 +354,7 @@ msgstr "pow() 3-arg tidak didukung" msgid "64 bit types" msgstr "" +#: 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" @@ -376,7 +377,9 @@ msgstr "Jenis alamat di luar batas" msgid "All CAN peripherals are in use" msgstr "" -#: ports/espressif/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c +#: 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 "Semua perangkat I2C sedang digunakan" @@ -558,6 +561,10 @@ msgstr "" msgid "Bit depth must be multiple of 8." msgstr "Kedalaman bit harus kelipatan 8." +#: 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 "" @@ -628,6 +635,10 @@ msgstr "Penyangga harus memiliki panjang setidaknya 1" msgid "Buffer too short by %d bytes" msgstr "Buffer terlalu pendek untuk %d byte" +#: 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 @@ -794,10 +805,6 @@ msgstr "Peregangan clock terlalu panjang" msgid "Clock unit in use" msgstr "Clock unit sedang digunakan" -#: shared-bindings/_pew/PewPew.c -msgid "Column entry must be digitalio.DigitalInOut" -msgstr "Entri kolom harus digitalio.DigitalInOut" - #: 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" @@ -974,36 +981,9 @@ msgstr "" #: 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 -#: shared-bindings/terminalio/Terminal.c msgid "Expected a %q" msgstr "Diharapkan %q" -#: shared-bindings/_bleio/CharacteristicBuffer.c -#: shared-bindings/_bleio/Descriptor.c shared-bindings/_bleio/PacketBuffer.c -msgid "Expected a Characteristic" -msgstr "Diharapkan sebuah Karakteristik" - -#: shared-bindings/_bleio/Adapter.c -msgid "Expected a DigitalInOut" -msgstr "" - -#: shared-bindings/_bleio/Characteristic.c -msgid "Expected a Service" -msgstr "Diharapkan sebuah Layanan" - -#: shared-bindings/_bleio/Adapter.c -msgid "Expected a UART" -msgstr "" - -#: shared-bindings/_bleio/Characteristic.c shared-bindings/_bleio/Descriptor.c -#: shared-bindings/_bleio/Service.c -msgid "Expected a UUID" -msgstr "Diharapkan sebuah UUID" - -#: shared-bindings/_bleio/Adapter.c -msgid "Expected an Address" -msgstr "Diharapkan sebuah Alamat" - #: shared-bindings/alarm/__init__.c msgid "Expected an alarm" msgstr "" @@ -1321,8 +1301,11 @@ msgstr "Frekuensi PWM tidak valid" msgid "Invalid Pin" msgstr "" -#: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c -#: py/moduerrno.c shared-module/rgbmatrix/RGBMatrix.c +#: 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 "Argumen tidak valid" @@ -1370,10 +1353,6 @@ msgstr "File tidak valid" msgid "Invalid format chunk size" msgstr "Ukuran potongan format tidak valid" -#: ports/espressif/common-hal/busio/I2C.c -msgid "Invalid frequency" -msgstr "" - #: supervisor/shared/safe_mode.c msgid "Invalid memory access." msgstr "Akses memori tidak valid." @@ -1414,6 +1393,7 @@ msgstr "Pin untuk channel kanan tidak valid" #: 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 @@ -1632,6 +1612,10 @@ msgstr "Tidak ada pin TX" msgid "No available clocks" msgstr "Tidak ada clocks yang tersedia" +#: 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 "Tidak ada koneksi: panjang tidak dapat ditentukan" @@ -1652,6 +1636,7 @@ msgstr "Tidak ada perangkat keras acak yang tersedia" msgid "No hardware support on clk pin" msgstr "Tidak ada dukungan perangkat keras pada pin 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" @@ -1796,6 +1781,11 @@ msgstr "" 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 @@ -1868,6 +1858,7 @@ msgstr "Periferal sedang digunakan" msgid "Permission denied" msgstr "Izin ditolak" +#: 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 "" @@ -1920,10 +1911,13 @@ msgstr "" "konstruktor" #: ports/raspberrypi/common-hal/imagecapture/ParallelImageCapture.c -#: ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c msgid "Pins must be sequential" msgstr "Pin harus berurutan" +#: 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 "" @@ -1974,6 +1968,7 @@ msgstr "" msgid "Pull not used when direction is output." msgstr "Pull tidak digunakan saat arah output." +#: ports/atmel-samd/common-hal/watchdog/WatchDogTimer.c #: ports/raspberrypi/common-hal/watchdog/WatchDogTimer.c msgid "RAISE mode is not implemented" msgstr "" @@ -2051,10 +2046,6 @@ msgstr "" msgid "Right channel unsupported" msgstr "Channel Kanan tidak didukung" -#: shared-bindings/_pew/PewPew.c -msgid "Row entry must be digitalio.DigitalInOut" -msgstr "Entri baris harus digitalio.DigitalInOut" - #: main.c msgid "Running in safe mode! Not running saved code.\n" msgstr "" @@ -2125,6 +2116,7 @@ msgstr "" 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 "" @@ -2227,6 +2219,10 @@ msgstr "Tingkat sampel dari sampel tidak cocok dengan mixer" msgid "The sample's signedness does not match the mixer's" msgstr "signedness dari sampel tidak cocok dengan mixer" +#: 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 " @@ -2279,6 +2275,7 @@ msgstr "Terlalu banyak tampilan" 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" @@ -2471,6 +2468,7 @@ msgstr "Tegangan baca habis waktu" msgid "WARNING: Your code filename has two extensions\n" msgstr "PERINGATAN: Nama file kode anda mempunyai dua ekstensi\n" +#: 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" @@ -2497,16 +2495,10 @@ msgstr "" msgid "" "Welcome to Adafruit CircuitPython %s!\n" "\n" -"Please visit learn.adafruit.com/category/circuitpython for project guides.\n" +"Visit circuitpython.org for more information.\n" "\n" -"To list built-in modules please do `help(\"modules\")`.\n" +"To list built-in modules type `help(\"modules\")`.\n" msgstr "" -"Selamat datang ke Adafruit CircuitPython %s!\n" -"\n" -"Silahkan kunjungi learn.adafruit.com/category/circuitpython untuk panduan " -"project.\n" -"\n" -"Untuk menampilkan modul built-in silahkan ketik `help(\"modules\")`.\n" #: shared-bindings/wifi/Radio.c msgid "WiFi password must be between 8 and 63 characters" @@ -2549,10 +2541,6 @@ msgstr "__new__ arg harus berupa user-type" msgid "a bytes-like object is required" msgstr "sebuah objek menyerupai byte (bytes-like) dibutuhkan" -#: lib/embed/abort_.c -msgid "abort() called" -msgstr "abort() dipanggil" - #: shared-bindings/i2cperipheral/I2CPeripheral.c msgid "address out of bounds" msgstr "alamat di luar batas" @@ -2700,10 +2688,6 @@ msgstr "" msgid "buffer too small for requested bytes" msgstr "" -#: shared-bindings/_pew/PewPew.c -msgid "buttons must be digitalio.DigitalInOut" -msgstr "" - #: shared-bindings/adafruit_pixelbuf/PixelBuf.c msgid "byteorder is not a string" msgstr "" @@ -3052,6 +3036,10 @@ msgstr "" msgid "division by zero" msgstr "" +#: ports/espressif/common-hal/rotaryio/IncrementalEncoder.c +msgid "divisor must be 4" +msgstr "" + #: py/objdeque.c msgid "empty" msgstr "" @@ -3133,26 +3121,6 @@ msgstr "argumen keyword ekstra telah diberikan" msgid "extra positional arguments given" msgstr "argumen posisi ekstra telah diberikan" -#: py/parse.c -msgid "f-string expression part cannot include a '#'" -msgstr "" - -#: py/parse.c -msgid "f-string expression part cannot include a backslash" -msgstr "" - -#: py/parse.c -msgid "f-string: empty expression not allowed" -msgstr "" - -#: py/parse.c -msgid "f-string: expecting '}'" -msgstr "" - -#: py/parse.c -msgid "f-string: single '}' is not allowed" -msgstr "" - #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c #: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c msgid "file must be a file opened in byte mode" @@ -3413,10 +3381,6 @@ msgstr "" msgid "int() arg 2 must be >= 2 and <= 36" msgstr "" -#: py/objstr.c -msgid "integer required" -msgstr "" - #: extmod/ulab/code/numpy/approx.c msgid "interp is defined for 1D iterables of equal length" msgstr "" @@ -3430,10 +3394,6 @@ msgstr "" msgid "invalid architecture" msgstr "" -#: lib/netutils/netutils.c -msgid "invalid arguments" -msgstr "argumen-argumen tidak valid" - #: shared-bindings/bitmaptools/__init__.c #, c-format msgid "invalid bits_per_pixel %d, must be, 1, 2, 4, 8, 16, 24, or 32" @@ -3490,7 +3450,7 @@ msgstr "" msgid "invalid syntax for number" msgstr "" -#: py/objexcept.c shared-bindings/traceback/__init__.c +#: py/objexcept.c msgid "invalid traceback" msgstr "" @@ -3971,11 +3931,13 @@ msgstr "" msgid "pow() with 3 arguments requires integers" msgstr "" +#: ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_nopsram/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/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 @@ -3994,6 +3956,8 @@ msgstr "" #: 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 @@ -4037,7 +4001,7 @@ msgid "queue overflow" msgstr "antrian meluap (overflow)" #: py/parse.c -msgid "raw f-strings are not implemented" +msgid "raw f-strings are not supported" msgstr "" #: extmod/ulab/code/numpy/fft/fft_tools.c @@ -4098,7 +4062,7 @@ msgstr "nilai sampling keluar dari jangkauan" msgid "schedule queue full" msgstr "" -#: lib/utils/pyexec.c py/builtinimport.c +#: py/builtinimport.c msgid "script compilation not supported" msgstr "kompilasi script tidak didukung" @@ -4246,6 +4210,7 @@ msgstr "" 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 @@ -4374,7 +4339,7 @@ msgid "unicode name escapes" msgstr "" #: py/parse.c -msgid "unindent does not match any outer indentation level" +msgid "unindent doesn't match any outer indent level" msgstr "" #: py/objstr.c @@ -4528,6 +4493,49 @@ msgstr "zi harus berjenis float" msgid "zi must be of shape (n_section, 2)" msgstr "" +#, c-format +#~ msgid "" +#~ "Welcome to Adafruit CircuitPython %s!\n" +#~ "\n" +#~ "Please visit learn.adafruit.com/category/circuitpython for project " +#~ "guides.\n" +#~ "\n" +#~ "To list built-in modules please do `help(\"modules\")`.\n" +#~ msgstr "" +#~ "Selamat datang ke Adafruit CircuitPython %s!\n" +#~ "\n" +#~ "Silahkan kunjungi learn.adafruit.com/category/circuitpython untuk panduan " +#~ "project.\n" +#~ "\n" +#~ "Untuk menampilkan modul built-in silahkan ketik `help(\"modules\")`.\n" + +#~ msgid "abort() called" +#~ msgstr "abort() dipanggil" + +#~ msgid "invalid arguments" +#~ msgstr "argumen-argumen tidak valid" + +#~ msgid "%q list must be a list" +#~ msgstr "daftar %q harus berupa daftar" + +#~ msgid "Column entry must be digitalio.DigitalInOut" +#~ msgstr "Entri kolom harus digitalio.DigitalInOut" + +#~ msgid "Expected a Characteristic" +#~ msgstr "Diharapkan sebuah Karakteristik" + +#~ msgid "Expected a Service" +#~ msgstr "Diharapkan sebuah Layanan" + +#~ msgid "Expected a UUID" +#~ msgstr "Diharapkan sebuah UUID" + +#~ msgid "Expected an Address" +#~ msgstr "Diharapkan sebuah Alamat" + +#~ msgid "Row entry must be digitalio.DigitalInOut" +#~ msgstr "Entri baris harus digitalio.DigitalInOut" + #~ msgid "ParallelBus not yet supported" #~ msgstr "ParallelBus belum didukung" diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index 647cf04044..e39fef97e7 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -103,18 +103,14 @@ msgstr "" msgid "%q length must be >= 1" msgstr "" -#: shared-bindings/vectorio/Polygon.c -msgid "%q list must be a list" -msgstr "" - -#: py/argcheck.c -msgid "%q must <= %d" -msgstr "" - #: py/argcheck.c msgid "%q must be %d-%d" msgstr "" +#: py/argcheck.c shared-bindings/gifio/GifWriter.c +msgid "%q must be <= %d" +msgstr "" + #: py/argcheck.c msgid "%q must be >= %d" msgstr "" @@ -144,12 +140,12 @@ msgstr "" msgid "%q must be between %d and %d" msgstr "" -#: ports/atmel-samd/common-hal/busio/UART.c -msgid "%q must be power of 2" +#: py/argcheck.c +msgid "%q must be of type %q" msgstr "" -#: py/argcheck.c -msgid "%q must of type %q" +#: ports/atmel-samd/common-hal/busio/UART.c +msgid "%q must be power of 2" msgstr "" #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c @@ -165,6 +161,10 @@ msgstr "" msgid "%q should be an int" msgstr "" +#: shared-bindings/usb_hid/Device.c +msgid "%q with a report ID of 0 must be of length 1" +msgstr "" + #: py/bc.c py/objnamedtuple.c msgid "%q() takes %d positional arguments but %d were given" msgstr "" @@ -347,6 +347,7 @@ msgstr "" msgid "64 bit types" msgstr "" +#: 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" @@ -369,7 +370,9 @@ msgstr "" msgid "All CAN peripherals are in use" msgstr "" -#: ports/espressif/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c +#: 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 "" @@ -549,6 +552,10 @@ msgstr "" msgid "Bit depth must be multiple of 8." 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 "" @@ -619,6 +626,10 @@ msgstr "" 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 @@ -777,10 +788,6 @@ msgstr "" msgid "Clock unit in use" msgstr "" -#: shared-bindings/_pew/PewPew.c -msgid "Column entry must be digitalio.DigitalInOut" -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" @@ -956,36 +963,9 @@ msgstr "" #: 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 -#: shared-bindings/terminalio/Terminal.c msgid "Expected a %q" msgstr "" -#: shared-bindings/_bleio/CharacteristicBuffer.c -#: shared-bindings/_bleio/Descriptor.c shared-bindings/_bleio/PacketBuffer.c -msgid "Expected a Characteristic" -msgstr "" - -#: shared-bindings/_bleio/Adapter.c -msgid "Expected a DigitalInOut" -msgstr "" - -#: shared-bindings/_bleio/Characteristic.c -msgid "Expected a Service" -msgstr "" - -#: shared-bindings/_bleio/Adapter.c -msgid "Expected a UART" -msgstr "" - -#: shared-bindings/_bleio/Characteristic.c shared-bindings/_bleio/Descriptor.c -#: shared-bindings/_bleio/Service.c -msgid "Expected a UUID" -msgstr "" - -#: shared-bindings/_bleio/Adapter.c -msgid "Expected an Address" -msgstr "" - #: shared-bindings/alarm/__init__.c msgid "Expected an alarm" msgstr "" @@ -1301,8 +1281,11 @@ msgstr "" msgid "Invalid Pin" msgstr "" -#: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c -#: py/moduerrno.c shared-module/rgbmatrix/RGBMatrix.c +#: 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 "" @@ -1350,10 +1333,6 @@ msgstr "" msgid "Invalid format chunk size" msgstr "" -#: ports/espressif/common-hal/busio/I2C.c -msgid "Invalid frequency" -msgstr "" - #: supervisor/shared/safe_mode.c msgid "Invalid memory access." msgstr "" @@ -1394,6 +1373,7 @@ msgstr "" #: 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 @@ -1612,6 +1592,10 @@ msgstr "" 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 "" @@ -1632,6 +1616,7 @@ msgstr "" 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" @@ -1771,6 +1756,11 @@ msgstr "" 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 @@ -1841,6 +1831,7 @@ msgstr "" 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 "" @@ -1890,10 +1881,13 @@ msgid "" msgstr "" #: ports/raspberrypi/common-hal/imagecapture/ParallelImageCapture.c -#: ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.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 "" @@ -1942,6 +1936,7 @@ msgstr "" 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 "" @@ -2019,10 +2014,6 @@ msgstr "" msgid "Right channel unsupported" msgstr "" -#: shared-bindings/_pew/PewPew.c -msgid "Row entry must be digitalio.DigitalInOut" -msgstr "" - #: main.c msgid "Running in safe mode! Not running saved code.\n" msgstr "" @@ -2091,6 +2082,7 @@ msgstr "" 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 "" @@ -2193,6 +2185,10 @@ msgstr "" 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 " @@ -2245,6 +2241,7 @@ msgstr "" 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" @@ -2435,6 +2432,7 @@ msgstr "" 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" @@ -2461,9 +2459,9 @@ msgstr "" msgid "" "Welcome to Adafruit CircuitPython %s!\n" "\n" -"Please visit learn.adafruit.com/category/circuitpython for project guides.\n" +"Visit circuitpython.org for more information.\n" "\n" -"To list built-in modules please do `help(\"modules\")`.\n" +"To list built-in modules type `help(\"modules\")`.\n" msgstr "" #: shared-bindings/wifi/Radio.c @@ -2507,10 +2505,6 @@ msgstr "" msgid "a bytes-like object is required" msgstr "" -#: lib/embed/abort_.c -msgid "abort() called" -msgstr "" - #: shared-bindings/i2cperipheral/I2CPeripheral.c msgid "address out of bounds" msgstr "" @@ -2658,10 +2652,6 @@ msgstr "" msgid "buffer too small for requested bytes" msgstr "" -#: shared-bindings/_pew/PewPew.c -msgid "buttons must be digitalio.DigitalInOut" -msgstr "" - #: shared-bindings/adafruit_pixelbuf/PixelBuf.c msgid "byteorder is not a string" msgstr "" @@ -3010,6 +3000,10 @@ msgstr "" msgid "division by zero" msgstr "" +#: ports/espressif/common-hal/rotaryio/IncrementalEncoder.c +msgid "divisor must be 4" +msgstr "" + #: py/objdeque.c msgid "empty" msgstr "" @@ -3091,28 +3085,9 @@ msgstr "" msgid "extra positional arguments given" msgstr "" -#: py/parse.c -msgid "f-string expression part cannot include a '#'" -msgstr "" - -#: py/parse.c -msgid "f-string expression part cannot include a backslash" -msgstr "" - -#: py/parse.c -msgid "f-string: empty expression not allowed" -msgstr "" - -#: py/parse.c -msgid "f-string: expecting '}'" -msgstr "" - -#: py/parse.c -msgid "f-string: single '}' is not allowed" -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 "" @@ -3371,10 +3346,6 @@ msgstr "" msgid "int() arg 2 must be >= 2 and <= 36" msgstr "" -#: py/objstr.c -msgid "integer required" -msgstr "" - #: extmod/ulab/code/numpy/approx.c msgid "interp is defined for 1D iterables of equal length" msgstr "" @@ -3388,10 +3359,6 @@ msgstr "" msgid "invalid architecture" msgstr "" -#: lib/netutils/netutils.c -msgid "invalid arguments" -msgstr "" - #: shared-bindings/bitmaptools/__init__.c #, c-format msgid "invalid bits_per_pixel %d, must be, 1, 2, 4, 8, 16, 24, or 32" @@ -3448,7 +3415,7 @@ msgstr "" msgid "invalid syntax for number" msgstr "" -#: py/objexcept.c shared-bindings/traceback/__init__.c +#: py/objexcept.c msgid "invalid traceback" msgstr "" @@ -3928,11 +3895,13 @@ msgstr "" msgid "pow() with 3 arguments requires integers" msgstr "" +#: ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_nopsram/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/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 @@ -3951,6 +3920,8 @@ msgstr "" #: 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 @@ -3994,7 +3965,7 @@ msgid "queue overflow" msgstr "" #: py/parse.c -msgid "raw f-strings are not implemented" +msgid "raw f-strings are not supported" msgstr "" #: extmod/ulab/code/numpy/fft/fft_tools.c @@ -4055,7 +4026,7 @@ msgstr "" msgid "schedule queue full" msgstr "" -#: lib/utils/pyexec.c py/builtinimport.c +#: py/builtinimport.c msgid "script compilation not supported" msgstr "" @@ -4203,6 +4174,7 @@ msgstr "" 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 @@ -4331,7 +4303,7 @@ msgid "unicode name escapes" msgstr "" #: py/parse.c -msgid "unindent does not match any outer indentation level" +msgid "unindent doesn't match any outer indent level" msgstr "" #: py/objstr.c @@ -4374,6 +4346,10 @@ msgstr "" msgid "unsupported Xtensa instruction '%s' with %d arguments" msgstr "" +#: shared-module/gifio/GifWriter.c +msgid "unsupported colorspace for GifWriter" +msgstr "" + #: py/objstr.c #, c-format msgid "unsupported format character '%c' (0x%x) at index %d" diff --git a/locale/cs.po b/locale/cs.po index 95bc1c51dd..1e351aa3ec 100644 --- a/locale/cs.po +++ b/locale/cs.po @@ -106,10 +106,6 @@ msgstr "" msgid "%q length must be >= 1" msgstr "" -#: shared-bindings/vectorio/Polygon.c -msgid "%q list must be a list" -msgstr "Seznam %q musí být seznam" - #: py/argcheck.c msgid "%q must <= %d" msgstr "" @@ -147,12 +143,12 @@ msgstr "%q musí být n-tice délky 2" msgid "%q must be between %d and %d" msgstr "" -#: ports/atmel-samd/common-hal/busio/UART.c -msgid "%q must be power of 2" +#: py/argcheck.c +msgid "%q must be of type %q" msgstr "" -#: py/argcheck.c -msgid "%q must of type %q" +#: ports/atmel-samd/common-hal/busio/UART.c +msgid "%q must be power of 2" msgstr "" #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c @@ -168,6 +164,10 @@ msgstr "Pin %q není platný" msgid "%q should be an int" 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 "" + #: py/bc.c py/objnamedtuple.c msgid "%q() takes %d positional arguments but %d were given" msgstr "%q() vyžaduje %d pozičních argumentů, ale %d jich bylo zadáno" @@ -350,6 +350,7 @@ msgstr "" msgid "64 bit types" msgstr "" +#: 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" @@ -372,7 +373,9 @@ msgstr "" msgid "All CAN peripherals are in use" msgstr "" -#: ports/espressif/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c +#: 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 "" @@ -552,6 +555,10 @@ msgstr "" msgid "Bit depth must be multiple of 8." 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 "" @@ -622,6 +629,10 @@ msgstr "" 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 @@ -780,10 +791,6 @@ msgstr "" msgid "Clock unit in use" msgstr "" -#: shared-bindings/_pew/PewPew.c -msgid "Column entry must be digitalio.DigitalInOut" -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" @@ -959,36 +966,9 @@ msgstr "" #: 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 -#: shared-bindings/terminalio/Terminal.c msgid "Expected a %q" msgstr "" -#: shared-bindings/_bleio/CharacteristicBuffer.c -#: shared-bindings/_bleio/Descriptor.c shared-bindings/_bleio/PacketBuffer.c -msgid "Expected a Characteristic" -msgstr "" - -#: shared-bindings/_bleio/Adapter.c -msgid "Expected a DigitalInOut" -msgstr "" - -#: shared-bindings/_bleio/Characteristic.c -msgid "Expected a Service" -msgstr "" - -#: shared-bindings/_bleio/Adapter.c -msgid "Expected a UART" -msgstr "" - -#: shared-bindings/_bleio/Characteristic.c shared-bindings/_bleio/Descriptor.c -#: shared-bindings/_bleio/Service.c -msgid "Expected a UUID" -msgstr "" - -#: shared-bindings/_bleio/Adapter.c -msgid "Expected an Address" -msgstr "" - #: shared-bindings/alarm/__init__.c msgid "Expected an alarm" msgstr "" @@ -1304,8 +1284,11 @@ msgstr "" msgid "Invalid Pin" msgstr "" -#: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c -#: py/moduerrno.c shared-module/rgbmatrix/RGBMatrix.c +#: 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 "" @@ -1353,10 +1336,6 @@ msgstr "" msgid "Invalid format chunk size" msgstr "" -#: ports/espressif/common-hal/busio/I2C.c -msgid "Invalid frequency" -msgstr "" - #: supervisor/shared/safe_mode.c msgid "Invalid memory access." msgstr "" @@ -1397,6 +1376,7 @@ msgstr "" #: 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 @@ -1615,6 +1595,10 @@ msgstr "" 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 "" @@ -1635,6 +1619,7 @@ msgstr "" 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" @@ -1774,6 +1759,11 @@ msgstr "" 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 @@ -1844,6 +1834,7 @@ msgstr "" 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 "" @@ -1893,10 +1884,13 @@ msgid "" msgstr "" #: ports/raspberrypi/common-hal/imagecapture/ParallelImageCapture.c -#: ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.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 "" @@ -1945,6 +1939,7 @@ msgstr "" 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 "" @@ -2022,10 +2017,6 @@ msgstr "" msgid "Right channel unsupported" msgstr "" -#: shared-bindings/_pew/PewPew.c -msgid "Row entry must be digitalio.DigitalInOut" -msgstr "" - #: main.c msgid "Running in safe mode! Not running saved code.\n" msgstr "" @@ -2094,6 +2085,7 @@ msgstr "" 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 "" @@ -2196,6 +2188,10 @@ msgstr "" 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 " @@ -2248,6 +2244,7 @@ msgstr "" 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" @@ -2438,6 +2435,7 @@ msgstr "" 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" @@ -2464,9 +2462,9 @@ msgstr "" msgid "" "Welcome to Adafruit CircuitPython %s!\n" "\n" -"Please visit learn.adafruit.com/category/circuitpython for project guides.\n" +"Visit circuitpython.org for more information.\n" "\n" -"To list built-in modules please do `help(\"modules\")`.\n" +"To list built-in modules type `help(\"modules\")`.\n" msgstr "" #: shared-bindings/wifi/Radio.c @@ -2510,10 +2508,6 @@ msgstr "" msgid "a bytes-like object is required" msgstr "" -#: lib/embed/abort_.c -msgid "abort() called" -msgstr "" - #: shared-bindings/i2cperipheral/I2CPeripheral.c msgid "address out of bounds" msgstr "" @@ -2661,10 +2655,6 @@ msgstr "" msgid "buffer too small for requested bytes" msgstr "" -#: shared-bindings/_pew/PewPew.c -msgid "buttons must be digitalio.DigitalInOut" -msgstr "" - #: shared-bindings/adafruit_pixelbuf/PixelBuf.c msgid "byteorder is not a string" msgstr "" @@ -3013,6 +3003,10 @@ msgstr "" msgid "division by zero" msgstr "" +#: ports/espressif/common-hal/rotaryio/IncrementalEncoder.c +msgid "divisor must be 4" +msgstr "" + #: py/objdeque.c msgid "empty" msgstr "" @@ -3094,26 +3088,6 @@ msgstr "" msgid "extra positional arguments given" msgstr "" -#: py/parse.c -msgid "f-string expression part cannot include a '#'" -msgstr "" - -#: py/parse.c -msgid "f-string expression part cannot include a backslash" -msgstr "" - -#: py/parse.c -msgid "f-string: empty expression not allowed" -msgstr "" - -#: py/parse.c -msgid "f-string: expecting '}'" -msgstr "" - -#: py/parse.c -msgid "f-string: single '}' is not allowed" -msgstr "" - #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c #: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c msgid "file must be a file opened in byte mode" @@ -3374,10 +3348,6 @@ msgstr "" msgid "int() arg 2 must be >= 2 and <= 36" msgstr "" -#: py/objstr.c -msgid "integer required" -msgstr "" - #: extmod/ulab/code/numpy/approx.c msgid "interp is defined for 1D iterables of equal length" msgstr "" @@ -3391,10 +3361,6 @@ msgstr "" msgid "invalid architecture" msgstr "" -#: lib/netutils/netutils.c -msgid "invalid arguments" -msgstr "" - #: shared-bindings/bitmaptools/__init__.c #, c-format msgid "invalid bits_per_pixel %d, must be, 1, 2, 4, 8, 16, 24, or 32" @@ -3451,7 +3417,7 @@ msgstr "" msgid "invalid syntax for number" msgstr "" -#: py/objexcept.c shared-bindings/traceback/__init__.c +#: py/objexcept.c msgid "invalid traceback" msgstr "" @@ -3931,11 +3897,13 @@ msgstr "" msgid "pow() with 3 arguments requires integers" msgstr "" +#: ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_nopsram/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/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 @@ -3954,6 +3922,8 @@ msgstr "" #: 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 @@ -3997,7 +3967,7 @@ msgid "queue overflow" msgstr "" #: py/parse.c -msgid "raw f-strings are not implemented" +msgid "raw f-strings are not supported" msgstr "" #: extmod/ulab/code/numpy/fft/fft_tools.c @@ -4058,7 +4028,7 @@ msgstr "" msgid "schedule queue full" msgstr "" -#: lib/utils/pyexec.c py/builtinimport.c +#: py/builtinimport.c msgid "script compilation not supported" msgstr "" @@ -4206,6 +4176,7 @@ msgstr "" 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 @@ -4334,7 +4305,7 @@ msgid "unicode name escapes" msgstr "" #: py/parse.c -msgid "unindent does not match any outer indentation level" +msgid "unindent doesn't match any outer indent level" msgstr "" #: py/objstr.c @@ -4488,6 +4459,9 @@ msgstr "" msgid "zi must be of shape (n_section, 2)" msgstr "" +#~ msgid "%q list must be a list" +#~ msgstr "Seznam %q musí být seznam" + #~ msgid "%q indices must be integers, not %q" #~ msgstr "Indexy %q musí být celá čísla, ne %q" diff --git a/locale/de_DE.po b/locale/de_DE.po index abd2a98aac..0e66aa0f11 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -111,10 +111,6 @@ msgstr "" msgid "%q length must be >= 1" msgstr "" -#: shared-bindings/vectorio/Polygon.c -msgid "%q list must be a list" -msgstr "%q Liste muss eine Liste sein" - #: py/argcheck.c msgid "%q must <= %d" msgstr "" @@ -152,12 +148,12 @@ msgstr "%q muss ein Tupel der Länge 2 sein" msgid "%q must be between %d and %d" msgstr "" -#: ports/atmel-samd/common-hal/busio/UART.c -msgid "%q must be power of 2" +#: py/argcheck.c +msgid "%q must be of type %q" msgstr "" -#: py/argcheck.c -msgid "%q must of type %q" +#: ports/atmel-samd/common-hal/busio/UART.c +msgid "%q must be power of 2" msgstr "" #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c @@ -173,6 +169,10 @@ msgstr "%q Pin ungültig" msgid "%q should be an int" msgstr "%q sollte ein integer sein" +#: shared-bindings/usb_hid/Device.c +msgid "%q with a report ID of 0 must be of length 1" +msgstr "" + #: py/bc.c py/objnamedtuple.c msgid "%q() takes %d positional arguments but %d were given" msgstr "" @@ -356,6 +356,7 @@ msgstr "3-arg pow() wird nicht unterstützt" msgid "64 bit types" msgstr "64 bit Typen" +#: 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" @@ -378,7 +379,9 @@ msgstr "Adresstyp außerhalb des zulässigen Bereichs" msgid "All CAN peripherals are in use" msgstr "Alle CAN Schnittstellen sind in Benutzung" -#: ports/espressif/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c +#: 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 "Alle I2C-Peripheriegeräte sind in Benutzung" @@ -560,6 +563,10 @@ msgstr "Bittiefe muss zwischen 1 und 6 liegen, nicht %d" msgid "Bit depth must be multiple of 8." msgstr "Bit depth muss ein Vielfaches von 8 sein." +#: 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 "Sowohl RX als auch TX sind zu Flusssteuerung erforderlich" @@ -630,6 +637,10 @@ msgstr "Der Puffer muss eine Mindestenslänge von 1 haben" msgid "Buffer too short by %d bytes" msgstr "Puffer um %d Bytes zu kurz" +#: 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 @@ -790,10 +801,6 @@ msgstr "Clock stretch zu lang" msgid "Clock unit in use" msgstr "Clock unit wird benutzt" -#: shared-bindings/_pew/PewPew.c -msgid "Column entry must be digitalio.DigitalInOut" -msgstr "Spalteneintrag muss digitalio.DigitalInOut sein" - #: 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" @@ -971,36 +978,9 @@ msgstr "Error: Bind Fehler" #: 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 -#: shared-bindings/terminalio/Terminal.c msgid "Expected a %q" msgstr "Erwartet ein(e) %q" -#: shared-bindings/_bleio/CharacteristicBuffer.c -#: shared-bindings/_bleio/Descriptor.c shared-bindings/_bleio/PacketBuffer.c -msgid "Expected a Characteristic" -msgstr "Characteristic wird erwartet" - -#: shared-bindings/_bleio/Adapter.c -msgid "Expected a DigitalInOut" -msgstr "DigitanInOut wird erwartet" - -#: shared-bindings/_bleio/Characteristic.c -msgid "Expected a Service" -msgstr "Ein Service wird erwartet" - -#: shared-bindings/_bleio/Adapter.c -msgid "Expected a UART" -msgstr "UART wird erwartet" - -#: shared-bindings/_bleio/Characteristic.c shared-bindings/_bleio/Descriptor.c -#: shared-bindings/_bleio/Service.c -msgid "Expected a UUID" -msgstr "Eine UUID wird erwartet" - -#: shared-bindings/_bleio/Adapter.c -msgid "Expected an Address" -msgstr "Erwartet eine Adresse" - #: shared-bindings/alarm/__init__.c msgid "Expected an alarm" msgstr "Alarm erwartet" @@ -1321,8 +1301,11 @@ msgstr "Ungültige PWM Frequenz" msgid "Invalid Pin" msgstr "Ungültiger Pin" -#: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c -#: py/moduerrno.c shared-module/rgbmatrix/RGBMatrix.c +#: 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 "Ungültiges Argument" @@ -1370,10 +1353,6 @@ msgstr "Ungültige Datei" msgid "Invalid format chunk size" msgstr "Ungültige format chunk size" -#: ports/espressif/common-hal/busio/I2C.c -msgid "Invalid frequency" -msgstr "Ungültige Frequenz" - #: supervisor/shared/safe_mode.c msgid "Invalid memory access." msgstr "Ungültiger Speicherzugriff." @@ -1414,6 +1393,7 @@ msgstr "Ungültiger Pin für rechten Kanal" #: 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 @@ -1633,6 +1613,10 @@ msgstr "Kein TX Pin" msgid "No available clocks" msgstr "Keine Taktgeber verfügbar" +#: 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 "Keine Verbindung: Länge kann nicht bestimmt werden" @@ -1653,6 +1637,7 @@ msgstr "Kein hardware random verfügbar" msgid "No hardware support on clk pin" msgstr "Keine Hardwareunterstützung am clk Pin" +#: 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" @@ -1798,6 +1783,11 @@ msgstr "" 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 @@ -1868,6 +1858,7 @@ msgstr "" msgid "Permission denied" msgstr "Zugang verweigert" +#: 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 "" @@ -1920,10 +1911,13 @@ msgstr "" "allow_inefficient = True an den Konstruktor" #: ports/raspberrypi/common-hal/imagecapture/ParallelImageCapture.c -#: ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.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 "" @@ -1974,6 +1968,7 @@ msgstr "Das Programm ist zu groß" msgid "Pull not used when direction is output." msgstr "Pull wird nicht verwendet, wenn die Richtung output ist." +#: ports/atmel-samd/common-hal/watchdog/WatchDogTimer.c #: ports/raspberrypi/common-hal/watchdog/WatchDogTimer.c msgid "RAISE mode is not implemented" msgstr "" @@ -2051,10 +2046,6 @@ msgstr "" msgid "Right channel unsupported" msgstr "Rechter Kanal wird nicht unterstützt" -#: shared-bindings/_pew/PewPew.c -msgid "Row entry must be digitalio.DigitalInOut" -msgstr "Zeileneintrag muss ein digitalio.DigitalInOut sein" - #: main.c msgid "Running in safe mode! Not running saved code.\n" msgstr "Sicherheitsmodus aktiv! Gespeicherter Code wird nicht ausgeführt\n" @@ -2123,6 +2114,7 @@ msgstr "" 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 "" @@ -2227,6 +2219,10 @@ msgid "The sample's signedness does not match the mixer's" msgstr "" "Die Art des Vorzeichens des Samples stimmt nicht mit dem des Mixers überein" +#: 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 " @@ -2251,7 +2247,7 @@ msgstr "Die Kachelbreite muss die Bitmap-Breite genau teilen" #: shared-bindings/alarm/time/TimeAlarm.c msgid "Time is in the past." -msgstr "" +msgstr "Zeit liegt in der Vergangenheit" #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format @@ -2278,8 +2274,9 @@ msgstr "Zu viele displays" #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Total data to write is larger than %q" -msgstr "" +msgstr "Gesamte zu schreibende Datenmenge ist größer als %q" +#: 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" @@ -2315,19 +2312,19 @@ msgstr "UART-Schreibfehler" #: shared-module/usb_hid/Device.c msgid "USB busy" -msgstr "" +msgstr "USB beschäftigt" #: supervisor/shared/safe_mode.c msgid "USB devices need more endpoints than are available." -msgstr "" +msgstr "USB Geräte brauchen mehr Endpunkte als verfügbar sind" #: supervisor/shared/safe_mode.c msgid "USB devices specify too many interface names." -msgstr "" +msgstr "USB Geräte haben zu viele Schnittstellennamen festgelegt" #: shared-module/usb_hid/Device.c msgid "USB error" -msgstr "" +msgstr "USB Fehler" #: shared-bindings/_bleio/UUID.c msgid "UUID integer value must be 0-0xffff" @@ -2376,7 +2373,7 @@ msgstr "Schreiben in nvm nicht möglich." #: shared-bindings/alarm/SleepMemory.c msgid "Unable to write to sleep_memory." -msgstr "" +msgstr "Schreiben in sleep_memory nicht möglich." #: ports/nrf/common-hal/_bleio/UUID.c msgid "Unexpected nrfx uuid type" @@ -2390,7 +2387,7 @@ msgstr "" #: shared-bindings/wifi/Radio.c #, c-format msgid "Unknown failure %d" -msgstr "" +msgstr "Unbekannter Fehler %d" #: ports/nrf/common-hal/_bleio/__init__.c #, c-format @@ -2409,7 +2406,7 @@ msgstr "Unbekannter Sicherheitsfehler: 0x%04x" #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown system firmware error: %04x" -msgstr "" +msgstr "Unbekannter Systemfirmware Fehler: %04x" #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #, c-format @@ -2450,7 +2447,7 @@ msgstr "Nicht unterstützter Pull-Wert." #: ports/espressif/common-hal/dualbank/__init__.c msgid "Update Failed" -msgstr "" +msgstr "Update fehlgeschlagen" #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c @@ -2464,7 +2461,7 @@ msgstr "Länge des Wertes > max_length" #: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c msgid "Version was invalid" -msgstr "" +msgstr "Version ist ungültig" #: ports/stm/common-hal/microcontroller/Processor.c msgid "Voltage read timed out" @@ -2475,6 +2472,7 @@ msgid "WARNING: Your code filename has two extensions\n" msgstr "" "WARNUNG: Der Dateiname deines Programms hat zwei Dateityperweiterungen\n" +#: 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" @@ -2503,16 +2501,10 @@ msgstr "Watchdog timer abgelaufen." msgid "" "Welcome to Adafruit CircuitPython %s!\n" "\n" -"Please visit learn.adafruit.com/category/circuitpython for project guides.\n" +"Visit circuitpython.org for more information.\n" "\n" -"To list built-in modules please do `help(\"modules\")`.\n" +"To list built-in modules type `help(\"modules\")`.\n" msgstr "" -"Willkommen bei Adafruit CircuitPython %s!\n" -"\n" -"Projektleitfäden findest du auf learn.adafruit.com/category/circuitpython \n" -"\n" -"Um die integrierten Module aufzulisten, führe bitte `help(\"modules\")` " -"aus.\n" #: shared-bindings/wifi/Radio.c msgid "WiFi password must be between 8 and 63 characters" @@ -2520,7 +2512,7 @@ msgstr "WiFi Passwort muss zwischen 8 und 63 Zeichen lang sein" #: main.c msgid "Woken up by alarm.\n" -msgstr "" +msgstr "Aufgeweckt durch Alarm.\n" #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Writes not supported on Characteristic" @@ -2528,7 +2520,7 @@ msgstr "Schreiben nicht unterstüzt für diese Charakteristik" #: supervisor/shared/safe_mode.c msgid "You are in safe mode because:\n" -msgstr "" +msgstr "Du bist im abgesicherten Modus weil:\n" #: supervisor/shared/safe_mode.c msgid "" @@ -2537,7 +2529,7 @@ msgstr "" #: supervisor/shared/safe_mode.c msgid "You requested starting safe mode by " -msgstr "Du hast das Starten im Sicherheitsmodus ausgelöst durch " +msgstr "Du hast das Starten im abgesicherten Modus ausgelöst durch " #: py/objtype.c msgid "__init__() should return None" @@ -2555,21 +2547,17 @@ msgstr "__new__ arg muss user-type sein" msgid "a bytes-like object is required" msgstr "ein Byte-ähnliches Objekt ist erforderlich" -#: lib/embed/abort_.c -msgid "abort() called" -msgstr "abort() wurde aufgerufen" - #: shared-bindings/i2cperipheral/I2CPeripheral.c msgid "address out of bounds" msgstr "Adresse außerhalb der Grenzen" #: shared-bindings/i2cperipheral/I2CPeripheral.c msgid "addresses is empty" -msgstr "adresses ist leer" +msgstr "addresses ist leer" #: py/compile.c msgid "annotation must be an identifier" -msgstr "" +msgstr "Die Annotation muss ein Bezeichner sein" #: py/modbuiltins.c msgid "arg is an empty sequence" @@ -2577,7 +2565,7 @@ msgstr "arg ist eine leere Sequenz" #: py/objobject.c msgid "arg must be user-type" -msgstr "" +msgstr "arg muss ein Nutzer-Typ sein" #: extmod/ulab/code/numpy/numerical.c msgid "argsort argument must be an ndarray" @@ -2593,7 +2581,7 @@ msgstr "Argument hat falschen Typ" #: py/compile.c msgid "argument name reused" -msgstr "" +msgstr "Name des Arguments wiederverwendet" #: py/argcheck.c shared-bindings/_stage/__init__.c #: shared-bindings/digitalio/DigitalInOut.c @@ -2610,7 +2598,7 @@ msgstr "Argumente müssen ndarrays sein" #: extmod/ulab/code/ndarray.c msgid "array and index length must be equal" -msgstr "" +msgstr "Array- und Indexlänge müssen gleich sein" #: py/objarray.c shared-bindings/alarm/SleepMemory.c #: shared-bindings/nvm/ByteArray.c @@ -2619,11 +2607,11 @@ msgstr "Array/Bytes auf der rechten Seite erforderlich" #: extmod/ulab/code/numpy/numerical.c msgid "attempt to get (arg)min/(arg)max of empty sequence" -msgstr "" +msgstr "Versuch (arg)min/(arg)max einer leeren Sequenz zu holen" #: extmod/ulab/code/numpy/numerical.c msgid "attempt to get argmin/argmax of an empty sequence" -msgstr "Sie haben versucht argmin/argmax von einer leeren Sequenz zu bekommen" +msgstr "Sie haben versucht argmin/argmax einer leeren Sequenz zu erhalten" #: py/objstr.c msgid "attributes not supported yet" @@ -2631,19 +2619,19 @@ msgstr "Attribute werden noch nicht unterstützt" #: extmod/ulab/code/numpy/numerical.c msgid "axis is out of bounds" -msgstr "" +msgstr "Achse außerhalb des Wertebereichs" #: extmod/ulab/code/numpy/numerical.c extmod/ulab/code/ulab_tools.c msgid "axis must be None, or an integer" -msgstr "" +msgstr "Achse muss Nichts, oder ein Integer sein" #: extmod/ulab/code/numpy/numerical.c msgid "axis too long" -msgstr "" +msgstr "Achse zu lang" #: shared-bindings/bitmaptools/__init__.c msgid "background value out of range of target" -msgstr "" +msgstr "Hintergrundwert außerhalb des Zielbereichs" #: py/builtinevex.c msgid "bad compile mode" @@ -2667,11 +2655,11 @@ msgstr "Der binäre Operator %q ist nicht implementiert" #: extmod/modurandom.c msgid "bits must be 32 or less" -msgstr "" +msgstr "bits müssen 32 oder kleiner sein" #: shared-bindings/busio/UART.c msgid "bits must be in range 5 to 9" -msgstr "" +msgstr "bits müssen zwischen 5 und 9 liegen" #: shared-bindings/audiomixer/Mixer.c msgid "bits_per_sample must be 8 or 16" @@ -2683,11 +2671,11 @@ msgstr "Zweig ist außerhalb der Reichweite" #: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c msgid "buffer is smaller than requested size" -msgstr "" +msgstr "Der Puffer ist kleiner als die angefragte Größe" #: extmod/ulab/code/ulab_create.c extmod/ulab/code/utils/utils.c msgid "buffer size must be a multiple of element size" -msgstr "" +msgstr "Die Puffergröße muss ein vielfaches der Elementgröße sein" #: shared-module/struct/__init__.c msgid "buffer size must match format" @@ -2704,11 +2692,7 @@ msgstr "Der Puffer ist zu klein" #: shared-bindings/socketpool/Socket.c shared-bindings/ssl/SSLSocket.c msgid "buffer too small for requested bytes" -msgstr "" - -#: shared-bindings/_pew/PewPew.c -msgid "buttons must be digitalio.DigitalInOut" -msgstr "Tasten müssen digitalio.DigitalInOut sein" +msgstr "Der Puffer ist zu klein für die angefragten Bytes" #: shared-bindings/adafruit_pixelbuf/PixelBuf.c msgid "byteorder is not a string" @@ -2759,7 +2743,7 @@ msgstr "kann keinem Ausdruck zuweisen" #: extmod/moduasyncio.c msgid "can't cancel self" -msgstr "" +msgstr "kann self nicht abbrechen" #: py/obj.c py/objint.c shared-bindings/i2cperipheral/I2CPeripheral.c #: shared-module/adafruit_pixelbuf/PixelBuf.c @@ -2768,7 +2752,7 @@ msgstr "kann %q nicht zu %q konvertieren" #: py/runtime.c msgid "can't convert %q to int" -msgstr "" +msgstr "kann %q nicht nach int konvertieren" #: py/obj.c #, c-format @@ -2873,7 +2857,7 @@ msgstr "" #: extmod/ulab/code/ndarray.c msgid "cannot assign new shape" -msgstr "" +msgstr "Kann neue shape nicht zuweisen" #: extmod/ulab/code/ndarray_operators.c msgid "cannot cast output with casting rule" @@ -2897,7 +2881,7 @@ msgstr "kann keinen relativen Import durchführen" #: extmod/moductypes.c msgid "cannot unambiguously get sizeof scalar" -msgstr "" +msgstr "Kann nicht eindeutig die Größe (sizeof) des Skalars ermitteln" #: py/emitnative.c msgid "casting" @@ -2921,11 +2905,11 @@ msgstr "Kreis kann nur in einem Elternteil registriert werden" #: shared-bindings/bitmaptools/__init__.c msgid "clip point must be (x,y) tuple" -msgstr "" +msgstr "clip Punkt muss ein (x,y) Tupel sein" #: shared-bindings/msgpack/ExtType.c msgid "code outside range 0~127" -msgstr "" +msgstr "code außerhalb des Wertebereichs 0~127" #: shared-bindings/displayio/Palette.c msgid "color buffer must be 3 bytes (RGB) or 4 bytes (RGB + pad byte)" @@ -2951,7 +2935,7 @@ msgstr "Farbe sollte ein int sein" #: py/emitnative.c msgid "comparison of int and uint" -msgstr "" +msgstr "Vergleich von int und uint" #: py/objcomplex.c msgid "complex division by zero" @@ -2991,28 +2975,28 @@ msgstr "Vandermonde-Matrix konnte nicht invertiert werden" #: shared-module/sdcardio/SDCard.c msgid "couldn't determine SD card version" -msgstr "" +msgstr "Konnte SD-Karten Version nicht ermitteln" #: extmod/ulab/code/numpy/numerical.c msgid "cross is defined for 1D arrays of length 3" -msgstr "" +msgstr "cross ist definiert für 1-Dimensionale Arrays der Länge 3" #: extmod/ulab/code/scipy/optimize/optimize.c msgid "data must be iterable" -msgstr "" +msgstr "data muss iterierbar sein" #: extmod/ulab/code/scipy/optimize/optimize.c msgid "data must be of equal length" -msgstr "" +msgstr "data muss von gleicher Länge sein" #: ports/atmel-samd/common-hal/imagecapture/ParallelImageCapture.c #, c-format msgid "data pin #%d in use" -msgstr "" +msgstr "Datenpin #%d ist in Benutzung" #: extmod/ulab/code/ndarray.c msgid "data type not understood" -msgstr "" +msgstr "Datentyp nicht verstanden" #: py/parsenum.c msgid "decimal numbers not supported" @@ -3070,6 +3054,10 @@ msgstr "" msgid "division by zero" msgstr "Division durch Null" +#: ports/espressif/common-hal/rotaryio/IncrementalEncoder.c +msgid "divisor must be 4" +msgstr "" + #: py/objdeque.c msgid "empty" msgstr "leer" @@ -3151,26 +3139,6 @@ msgstr "Es wurden zusätzliche Schlüsselwort-Argumente angegeben" msgid "extra positional arguments given" msgstr "Es wurden zusätzliche Argumente ohne Schlüsselwort angegeben" -#: py/parse.c -msgid "f-string expression part cannot include a '#'" -msgstr "f-string expression Teil kann kein '#' beinhalten" - -#: py/parse.c -msgid "f-string expression part cannot include a backslash" -msgstr "Die f-String expression darf keinen Backslash enthalten" - -#: py/parse.c -msgid "f-string: empty expression not allowed" -msgstr "f-string: leere expression nicht erlaubt" - -#: py/parse.c -msgid "f-string: expecting '}'" -msgstr "f-string: erwartet '}'" - -#: py/parse.c -msgid "f-string: single '}' is not allowed" -msgstr "f-string: einzelne '}' nicht erlaubt" - #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c #: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c msgid "file must be a file opened in byte mode" @@ -3222,7 +3190,7 @@ msgstr "float zu groß" #: py/nativeglue.c msgid "float unsupported" -msgstr "" +msgstr "float (Gleitkommazahlen) nicht unterstützt" #: shared-bindings/_stage/Text.c msgid "font must be 2048 bytes long" @@ -3374,7 +3342,7 @@ msgstr "" #: extmod/ulab/code/ulab_create.c msgid "input argument must be an integer, a tuple, or a list" -msgstr "" +msgstr "das Eingabeargument muss ein Integer, Tupel oder eine Liste sein" #: extmod/ulab/code/numpy/fft/fft_tools.c msgid "input array length must be power of 2" @@ -3382,7 +3350,7 @@ msgstr "Die Länge des Eingabearrays muss eine Potenz von 2 sein" #: extmod/ulab/code/ulab_create.c msgid "input arrays are not compatible" -msgstr "" +msgstr "Eingabe-Arrays sind nicht kompatibel" #: extmod/ulab/code/numpy/poly.c msgid "input data must be an iterable" @@ -3411,7 +3379,7 @@ msgstr "" #: extmod/ulab/code/scipy/signal/signal.c msgid "input must be one-dimensional" -msgstr "" +msgstr "die Eingabe muss ein-Dimensional sein" #: extmod/ulab/code/ulab_tools.c msgid "input must be square matrix" @@ -3433,10 +3401,6 @@ msgstr "" msgid "int() arg 2 must be >= 2 and <= 36" msgstr "int() arg 2 muss >= 2 und <= 36 sein" -#: py/objstr.c -msgid "integer required" -msgstr "integer erforderlich" - #: extmod/ulab/code/numpy/approx.c msgid "interp is defined for 1D iterables of equal length" msgstr "" @@ -3448,11 +3412,7 @@ msgstr "Das Intervall muss im Bereich %s-%s sein" #: py/compile.c msgid "invalid architecture" -msgstr "" - -#: lib/netutils/netutils.c -msgid "invalid arguments" -msgstr "ungültige argumente" +msgstr "ungültige Architektur" #: shared-bindings/bitmaptools/__init__.c #, c-format @@ -3510,7 +3470,7 @@ msgstr "ungültige Syntax für integer mit Basis %d" msgid "invalid syntax for number" msgstr "ungültige Syntax für number" -#: py/objexcept.c shared-bindings/traceback/__init__.c +#: py/objexcept.c msgid "invalid traceback" msgstr "" @@ -4000,11 +3960,13 @@ 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_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_nopsram/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/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 @@ -4023,6 +3985,8 @@ msgstr "pow() mit 3 Argumenten erfordert Integer" #: 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 @@ -4066,8 +4030,8 @@ msgid "queue overflow" msgstr "Warteschlangenüberlauf" #: py/parse.c -msgid "raw f-strings are not implemented" -msgstr "rohe F-Strings sind nicht implementiert" +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" @@ -4129,7 +4093,7 @@ msgstr "Abtastrate außerhalb der Reichweite" msgid "schedule queue full" msgstr "" -#: lib/utils/pyexec.c py/builtinimport.c +#: py/builtinimport.c msgid "script compilation not supported" msgstr "kompilieren von Skripten nicht unterstützt" @@ -4278,6 +4242,7 @@ msgstr "" msgid "time.struct_time() takes a 9-sequence" msgstr "time.struct_time() nimmt eine 9-Sequenz an" +#: 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 @@ -4290,7 +4255,7 @@ msgstr "Das Zeitlimit muss 0,0-100,0 Sekunden betragen" #: ports/nrf/common-hal/_bleio/Adapter.c msgid "timeout must be < 655.35 secs" -msgstr "" +msgstr "timeout muss kleiner als 655.35 Sekunden sein" #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "timeout must be >= 0.0" @@ -4318,7 +4283,7 @@ msgstr "zu viele Argumente mit dem angegebenen Format" #: extmod/ulab/code/ndarray.c extmod/ulab/code/ulab_create.c msgid "too many dimensions" -msgstr "" +msgstr "zu viele Dimensionen" #: extmod/ulab/code/ndarray.c msgid "too many indices" @@ -4408,10 +4373,8 @@ msgid "unicode name escapes" msgstr "Unicode Name ausgebrochen (escaped)" #: py/parse.c -msgid "unindent does not match any outer indentation level" +msgid "unindent doesn't match any outer indent level" msgstr "" -"Einrückung entspricht keiner äußeren Einrückungsebene. Bitte Leerzeichen am " -"Zeilenanfang kontrollieren" #: py/objstr.c #, c-format @@ -4477,7 +4440,7 @@ msgstr "Wert muss in %d Byte(s) passen" #: shared-bindings/bitmaptools/__init__.c msgid "value out of range of target" -msgstr "" +msgstr "Wert außerhalb des Zielbereiches" #: shared-bindings/displayio/Bitmap.c msgid "value_count must be > 0" @@ -4485,24 +4448,24 @@ msgstr "value_count muss größer als 0 sein" #: ports/espressif/common-hal/watchdog/WatchDogTimer.c msgid "watchdog not initialized" -msgstr "" +msgstr "watchdog nicht initialisiert" #: shared-bindings/watchdog/WatchDogTimer.c msgid "watchdog timeout must be greater than 0" -msgstr "" +msgstr "watchdog Zeitlimit muss größer als 0 sein" #: shared-bindings/bitops/__init__.c #, c-format msgid "width must be from 2 to 8 (inclusive), not %d" -msgstr "" +msgstr "breite muss zwischen (inklusive) 2 und 8 liegen, nicht %d" #: shared-bindings/rgbmatrix/RGBMatrix.c msgid "width must be greater than zero" -msgstr "" +msgstr "breite muss größer als 0 sein" #: ports/espressif/common-hal/wifi/Radio.c msgid "wifi is not enabled" -msgstr "" +msgstr "wifi ist nicht aktiviert" #: shared-bindings/_bleio/Adapter.c msgid "window must be <= interval" @@ -4510,11 +4473,11 @@ msgstr "Fenster muss <= Intervall sein" #: extmod/ulab/code/numpy/numerical.c msgid "wrong axis index" -msgstr "" +msgstr "falscher Achsenindex" #: extmod/ulab/code/ulab_create.c msgid "wrong axis specified" -msgstr "" +msgstr "falsche Achse gewählt" #: extmod/ulab/code/numpy/compare.c extmod/ulab/code/numpy/vector.c msgid "wrong input type" @@ -4538,7 +4501,7 @@ msgstr "x Wert außerhalb der Grenzen" #: ports/espressif/common-hal/audiobusio/__init__.c msgid "xTaskCreate failed" -msgstr "" +msgstr "xTaskCreate fehlgeschlagen" #: shared-bindings/displayio/Shape.c msgid "y should be an int" @@ -4554,16 +4517,98 @@ msgstr "Nullschritt" #: extmod/ulab/code/scipy/signal/signal.c msgid "zi must be an ndarray" -msgstr "" +msgstr "zi muss ein ndarray sein" #: extmod/ulab/code/scipy/signal/signal.c msgid "zi must be of float type" -msgstr "" +msgstr "zi muss eine Gleitkommazahl sein" #: extmod/ulab/code/scipy/signal/signal.c msgid "zi must be of shape (n_section, 2)" msgstr "" +#, c-format +#~ msgid "" +#~ "Welcome to Adafruit CircuitPython %s!\n" +#~ "\n" +#~ "Please visit learn.adafruit.com/category/circuitpython for project " +#~ "guides.\n" +#~ "\n" +#~ "To list built-in modules please do `help(\"modules\")`.\n" +#~ msgstr "" +#~ "Willkommen bei Adafruit CircuitPython %s!\n" +#~ "\n" +#~ "Projektleitfäden findest du auf learn.adafruit.com/category/" +#~ "circuitpython \n" +#~ "\n" +#~ "Um die integrierten Module aufzulisten, führe bitte `help(\"modules\")` " +#~ "aus.\n" + +#~ msgid "integer required" +#~ msgstr "integer erforderlich" + +#~ msgid "abort() called" +#~ msgstr "abort() wurde aufgerufen" + +#~ msgid "f-string expression part cannot include a '#'" +#~ msgstr "f-string expression Teil kann kein '#' beinhalten" + +#~ msgid "f-string expression part cannot include a backslash" +#~ msgstr "Die f-String expression darf keinen Backslash enthalten" + +#~ msgid "f-string: empty expression not allowed" +#~ msgstr "f-string: leere expression nicht erlaubt" + +#~ msgid "f-string: expecting '}'" +#~ msgstr "f-string: erwartet '}'" + +#~ msgid "f-string: single '}' is not allowed" +#~ msgstr "f-string: einzelne '}' nicht erlaubt" + +#~ msgid "invalid arguments" +#~ msgstr "ungültige argumente" + +#~ msgid "raw f-strings are not implemented" +#~ msgstr "rohe F-Strings sind nicht implementiert" + +#~ msgid "unindent does not match any outer indentation level" +#~ msgstr "" +#~ "Einrückung entspricht keiner äußeren Einrückungsebene. Bitte Leerzeichen " +#~ "am Zeilenanfang kontrollieren" + +#~ msgid "%q list must be a list" +#~ msgstr "%q Liste muss eine Liste sein" + +#~ msgid "Column entry must be digitalio.DigitalInOut" +#~ msgstr "Spalteneintrag muss digitalio.DigitalInOut sein" + +#~ msgid "Expected a Characteristic" +#~ msgstr "Characteristic wird erwartet" + +#~ msgid "Expected a DigitalInOut" +#~ msgstr "DigitanInOut wird erwartet" + +#~ msgid "Expected a Service" +#~ msgstr "Ein Service wird erwartet" + +#~ msgid "Expected a UART" +#~ msgstr "UART wird erwartet" + +#~ msgid "Expected a UUID" +#~ msgstr "Eine UUID wird erwartet" + +#~ msgid "Expected an Address" +#~ msgstr "Erwartet eine Adresse" + +#~ msgid "Row entry must be digitalio.DigitalInOut" +#~ msgstr "Zeileneintrag muss ein digitalio.DigitalInOut sein" + +#~ msgid "buttons must be digitalio.DigitalInOut" +#~ msgstr "Tasten müssen digitalio.DigitalInOut sein" + +#~ msgid "Invalid frequency" +#~ msgstr "Ungültige Frequenz" + #~ msgid "Data 0 pin must be byte aligned." #~ msgstr "Data 0 Pin muss Byte aligned sein." diff --git a/locale/el.po b/locale/el.po index 27b497e26a..5772201fe4 100644 --- a/locale/el.po +++ b/locale/el.po @@ -103,10 +103,6 @@ msgstr "" msgid "%q length must be >= 1" msgstr "" -#: shared-bindings/vectorio/Polygon.c -msgid "%q list must be a list" -msgstr "" - #: py/argcheck.c msgid "%q must <= %d" msgstr "" @@ -144,12 +140,12 @@ msgstr "" msgid "%q must be between %d and %d" msgstr "" -#: ports/atmel-samd/common-hal/busio/UART.c -msgid "%q must be power of 2" +#: py/argcheck.c +msgid "%q must be of type %q" msgstr "" -#: py/argcheck.c -msgid "%q must of type %q" +#: ports/atmel-samd/common-hal/busio/UART.c +msgid "%q must be power of 2" msgstr "" #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c @@ -165,6 +161,10 @@ msgstr "" msgid "%q should be an int" msgstr "" +#: shared-bindings/usb_hid/Device.c +msgid "%q with a report ID of 0 must be of length 1" +msgstr "" + #: py/bc.c py/objnamedtuple.c msgid "%q() takes %d positional arguments but %d were given" msgstr "" @@ -347,6 +347,7 @@ msgstr "" msgid "64 bit types" msgstr "" +#: 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" @@ -369,7 +370,9 @@ msgstr "" msgid "All CAN peripherals are in use" msgstr "" -#: ports/espressif/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c +#: 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 "" @@ -549,6 +552,10 @@ msgstr "" msgid "Bit depth must be multiple of 8." 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 "" @@ -619,6 +626,10 @@ msgstr "" 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 @@ -777,10 +788,6 @@ msgstr "" msgid "Clock unit in use" msgstr "" -#: shared-bindings/_pew/PewPew.c -msgid "Column entry must be digitalio.DigitalInOut" -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" @@ -956,36 +963,9 @@ msgstr "" #: 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 -#: shared-bindings/terminalio/Terminal.c msgid "Expected a %q" msgstr "" -#: shared-bindings/_bleio/CharacteristicBuffer.c -#: shared-bindings/_bleio/Descriptor.c shared-bindings/_bleio/PacketBuffer.c -msgid "Expected a Characteristic" -msgstr "" - -#: shared-bindings/_bleio/Adapter.c -msgid "Expected a DigitalInOut" -msgstr "" - -#: shared-bindings/_bleio/Characteristic.c -msgid "Expected a Service" -msgstr "" - -#: shared-bindings/_bleio/Adapter.c -msgid "Expected a UART" -msgstr "" - -#: shared-bindings/_bleio/Characteristic.c shared-bindings/_bleio/Descriptor.c -#: shared-bindings/_bleio/Service.c -msgid "Expected a UUID" -msgstr "" - -#: shared-bindings/_bleio/Adapter.c -msgid "Expected an Address" -msgstr "" - #: shared-bindings/alarm/__init__.c msgid "Expected an alarm" msgstr "" @@ -1301,8 +1281,11 @@ msgstr "" msgid "Invalid Pin" msgstr "" -#: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c -#: py/moduerrno.c shared-module/rgbmatrix/RGBMatrix.c +#: 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 "" @@ -1350,10 +1333,6 @@ msgstr "" msgid "Invalid format chunk size" msgstr "" -#: ports/espressif/common-hal/busio/I2C.c -msgid "Invalid frequency" -msgstr "" - #: supervisor/shared/safe_mode.c msgid "Invalid memory access." msgstr "" @@ -1394,6 +1373,7 @@ msgstr "" #: 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 @@ -1612,6 +1592,10 @@ msgstr "" 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 "" @@ -1632,6 +1616,7 @@ msgstr "" 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" @@ -1771,6 +1756,11 @@ msgstr "" 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 @@ -1841,6 +1831,7 @@ msgstr "" 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 "" @@ -1890,10 +1881,13 @@ msgid "" msgstr "" #: ports/raspberrypi/common-hal/imagecapture/ParallelImageCapture.c -#: ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.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 "" @@ -1942,6 +1936,7 @@ msgstr "" 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 "" @@ -2019,10 +2014,6 @@ msgstr "" msgid "Right channel unsupported" msgstr "" -#: shared-bindings/_pew/PewPew.c -msgid "Row entry must be digitalio.DigitalInOut" -msgstr "" - #: main.c msgid "Running in safe mode! Not running saved code.\n" msgstr "" @@ -2091,6 +2082,7 @@ msgstr "" 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 "" @@ -2193,6 +2185,10 @@ msgstr "" 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 " @@ -2245,6 +2241,7 @@ msgstr "" 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" @@ -2435,6 +2432,7 @@ msgstr "" 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" @@ -2461,9 +2459,9 @@ msgstr "" msgid "" "Welcome to Adafruit CircuitPython %s!\n" "\n" -"Please visit learn.adafruit.com/category/circuitpython for project guides.\n" +"Visit circuitpython.org for more information.\n" "\n" -"To list built-in modules please do `help(\"modules\")`.\n" +"To list built-in modules type `help(\"modules\")`.\n" msgstr "" #: shared-bindings/wifi/Radio.c @@ -2507,10 +2505,6 @@ msgstr "" msgid "a bytes-like object is required" msgstr "" -#: lib/embed/abort_.c -msgid "abort() called" -msgstr "" - #: shared-bindings/i2cperipheral/I2CPeripheral.c msgid "address out of bounds" msgstr "" @@ -2658,10 +2652,6 @@ msgstr "" msgid "buffer too small for requested bytes" msgstr "" -#: shared-bindings/_pew/PewPew.c -msgid "buttons must be digitalio.DigitalInOut" -msgstr "" - #: shared-bindings/adafruit_pixelbuf/PixelBuf.c msgid "byteorder is not a string" msgstr "" @@ -3010,6 +3000,10 @@ msgstr "" msgid "division by zero" msgstr "" +#: ports/espressif/common-hal/rotaryio/IncrementalEncoder.c +msgid "divisor must be 4" +msgstr "" + #: py/objdeque.c msgid "empty" msgstr "" @@ -3091,26 +3085,6 @@ msgstr "" msgid "extra positional arguments given" msgstr "" -#: py/parse.c -msgid "f-string expression part cannot include a '#'" -msgstr "" - -#: py/parse.c -msgid "f-string expression part cannot include a backslash" -msgstr "" - -#: py/parse.c -msgid "f-string: empty expression not allowed" -msgstr "" - -#: py/parse.c -msgid "f-string: expecting '}'" -msgstr "" - -#: py/parse.c -msgid "f-string: single '}' is not allowed" -msgstr "" - #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c #: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c msgid "file must be a file opened in byte mode" @@ -3371,10 +3345,6 @@ msgstr "" msgid "int() arg 2 must be >= 2 and <= 36" msgstr "" -#: py/objstr.c -msgid "integer required" -msgstr "" - #: extmod/ulab/code/numpy/approx.c msgid "interp is defined for 1D iterables of equal length" msgstr "" @@ -3388,10 +3358,6 @@ msgstr "" msgid "invalid architecture" msgstr "" -#: lib/netutils/netutils.c -msgid "invalid arguments" -msgstr "" - #: shared-bindings/bitmaptools/__init__.c #, c-format msgid "invalid bits_per_pixel %d, must be, 1, 2, 4, 8, 16, 24, or 32" @@ -3448,7 +3414,7 @@ msgstr "" msgid "invalid syntax for number" msgstr "" -#: py/objexcept.c shared-bindings/traceback/__init__.c +#: py/objexcept.c msgid "invalid traceback" msgstr "" @@ -3928,11 +3894,13 @@ msgstr "" msgid "pow() with 3 arguments requires integers" msgstr "" +#: ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_nopsram/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/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 @@ -3951,6 +3919,8 @@ msgstr "" #: 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 @@ -3994,7 +3964,7 @@ msgid "queue overflow" msgstr "" #: py/parse.c -msgid "raw f-strings are not implemented" +msgid "raw f-strings are not supported" msgstr "" #: extmod/ulab/code/numpy/fft/fft_tools.c @@ -4055,7 +4025,7 @@ msgstr "" msgid "schedule queue full" msgstr "" -#: lib/utils/pyexec.c py/builtinimport.c +#: py/builtinimport.c msgid "script compilation not supported" msgstr "" @@ -4203,6 +4173,7 @@ msgstr "" 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 @@ -4331,7 +4302,7 @@ msgid "unicode name escapes" msgstr "" #: py/parse.c -msgid "unindent does not match any outer indentation level" +msgid "unindent doesn't match any outer indent level" msgstr "" #: py/objstr.c diff --git a/locale/en_GB.po b/locale/en_GB.po index 96bf006a40..aac0bb6186 100644 --- a/locale/en_GB.po +++ b/locale/en_GB.po @@ -112,10 +112,6 @@ msgstr "%q length must be %d-%d" msgid "%q length must be >= 1" msgstr "%q length must be >= 1" -#: shared-bindings/vectorio/Polygon.c -msgid "%q list must be a list" -msgstr "%q list must be a list" - #: py/argcheck.c msgid "%q must <= %d" msgstr "%q must <= %d" @@ -153,14 +149,14 @@ msgstr "%q must be a tuple of length 2" msgid "%q must be between %d and %d" msgstr "%q must be between %d and %d" +#: py/argcheck.c +msgid "%q must be of type %q" +msgstr "" + #: ports/atmel-samd/common-hal/busio/UART.c msgid "%q must be power of 2" msgstr "%q must be power of 2" -#: py/argcheck.c -msgid "%q must of type %q" -msgstr "%q must of type %q" - #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #: shared-bindings/canio/Match.c msgid "%q out of range" @@ -174,6 +170,10 @@ msgstr "%q pin invalid" msgid "%q should be an int" msgstr "%q should be an int" +#: shared-bindings/usb_hid/Device.c +msgid "%q with a report ID of 0 must be of length 1" +msgstr "" + #: py/bc.c py/objnamedtuple.c msgid "%q() takes %d positional arguments but %d were given" msgstr "%q() takes %d positional arguments but %d were given" @@ -356,6 +356,7 @@ msgstr "3-arg pow() not supported" msgid "64 bit types" msgstr "64 bit types" +#: 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" @@ -378,7 +379,9 @@ msgstr "Address type out of range" msgid "All CAN peripherals are in use" msgstr "All CAN peripherals are in use" -#: ports/espressif/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c +#: 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 "All I2C peripherals are in use" @@ -560,6 +563,10 @@ msgstr "Bit depth must be from 1 to 6 inclusive, not %d" msgid "Bit depth must be multiple of 8." msgstr "Bit depth must be multiple of 8." +#: 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 "Both RX and TX required for flow control" @@ -630,6 +637,10 @@ msgstr "Buffer must be at least length 1" msgid "Buffer too short by %d bytes" msgstr "Buffer too short by %d bytes" +#: 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 @@ -788,10 +799,6 @@ msgstr "Clock stretch too long" msgid "Clock unit in use" msgstr "Clock unit in use" -#: shared-bindings/_pew/PewPew.c -msgid "Column entry must be digitalio.DigitalInOut" -msgstr "Column entry must be digitalio.DigitalInOut" - #: 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" @@ -969,36 +976,9 @@ msgstr "Error: Failure to bind" #: 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 -#: shared-bindings/terminalio/Terminal.c msgid "Expected a %q" msgstr "Expected a %q" -#: shared-bindings/_bleio/CharacteristicBuffer.c -#: shared-bindings/_bleio/Descriptor.c shared-bindings/_bleio/PacketBuffer.c -msgid "Expected a Characteristic" -msgstr "Expected a Characteristic" - -#: shared-bindings/_bleio/Adapter.c -msgid "Expected a DigitalInOut" -msgstr "Expected a DigitalInOut" - -#: shared-bindings/_bleio/Characteristic.c -msgid "Expected a Service" -msgstr "Expected a service" - -#: shared-bindings/_bleio/Adapter.c -msgid "Expected a UART" -msgstr "Expected a UART" - -#: shared-bindings/_bleio/Characteristic.c shared-bindings/_bleio/Descriptor.c -#: shared-bindings/_bleio/Service.c -msgid "Expected a UUID" -msgstr "Expected a UUID" - -#: shared-bindings/_bleio/Adapter.c -msgid "Expected an Address" -msgstr "Expected an address" - #: shared-bindings/alarm/__init__.c msgid "Expected an alarm" msgstr "Expected an alarm" @@ -1316,8 +1296,11 @@ msgstr "Invalid PWM frequency" msgid "Invalid Pin" msgstr "Invalid pin" -#: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c -#: py/moduerrno.c shared-module/rgbmatrix/RGBMatrix.c +#: 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 "Invalid argument" @@ -1365,10 +1348,6 @@ msgstr "Invalid file" msgid "Invalid format chunk size" msgstr "Invalid format chunk size" -#: ports/espressif/common-hal/busio/I2C.c -msgid "Invalid frequency" -msgstr "Invalid frequency" - #: supervisor/shared/safe_mode.c msgid "Invalid memory access." msgstr "Invalid memory access." @@ -1409,6 +1388,7 @@ msgstr "Invalid pin for right channel" #: 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 @@ -1627,6 +1607,10 @@ msgstr "No TX pin" msgid "No available clocks" msgstr "No available clocks" +#: 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 "No connection: length cannot be determined" @@ -1647,6 +1631,7 @@ msgstr "No hardware random available" msgid "No hardware support on clk pin" msgstr "No hardware support on clk pin" +#: 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" @@ -1790,6 +1775,11 @@ msgstr "" msgid "Only one TouchAlarm can be set in deep sleep." msgstr "Only one TouchAlarm can be set in deep sleep." +#: 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 @@ -1862,6 +1852,7 @@ msgstr "Peripheral in use" msgid "Permission denied" msgstr "Permission denied" +#: 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 "Pin cannot wake from Deep Sleep" @@ -1914,10 +1905,13 @@ msgstr "" "constructor" #: ports/raspberrypi/common-hal/imagecapture/ParallelImageCapture.c -#: ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c msgid "Pins must be sequential" msgstr "Pins must be sequential" +#: 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 "Pins must share PWM slice" @@ -1966,6 +1960,7 @@ msgstr "Program too large" msgid "Pull not used when direction is output." msgstr "Pull not used when direction is output." +#: ports/atmel-samd/common-hal/watchdog/WatchDogTimer.c #: ports/raspberrypi/common-hal/watchdog/WatchDogTimer.c msgid "RAISE mode is not implemented" msgstr "RAISE mode is not implemented" @@ -2043,10 +2038,6 @@ msgstr "Requested resource not found" msgid "Right channel unsupported" msgstr "Right channel unsupported" -#: shared-bindings/_pew/PewPew.c -msgid "Row entry must be digitalio.DigitalInOut" -msgstr "Row entry must be digitalio. DigitalInOut" - #: main.c msgid "Running in safe mode! Not running saved code.\n" msgstr "Running in safe mode! Not running saved code.\n" @@ -2115,6 +2106,7 @@ msgstr "Side set pin count must be between 1 and 5" msgid "Size not supported" msgstr "Size not supported" +#: ports/atmel-samd/common-hal/alarm/SleepMemory.c #: ports/raspberrypi/common-hal/alarm/SleepMemory.c msgid "Sleep Memory not available" msgstr "Sleep Memory not available" @@ -2224,6 +2216,10 @@ msgstr "The sample's sample rate does not match the mixer's" msgid "The sample's signedness does not match the mixer's" msgstr "The sample's signedness does not match the mixer's" +#: 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 " @@ -2276,6 +2272,7 @@ msgstr "Too many displays" msgid "Total data to write is larger than %q" msgstr "Total data to write is larger than %q" +#: 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" @@ -2468,6 +2465,7 @@ msgstr "Voltage read timed out" msgid "WARNING: Your code filename has two extensions\n" msgstr "WARNING: Your code filename has two extensions\n" +#: 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" @@ -2494,15 +2492,10 @@ msgstr "WatchDog timer expired." msgid "" "Welcome to Adafruit CircuitPython %s!\n" "\n" -"Please visit learn.adafruit.com/category/circuitpython for project guides.\n" +"Visit circuitpython.org for more information.\n" "\n" -"To list built-in modules please do `help(\"modules\")`.\n" +"To list built-in modules type `help(\"modules\")`.\n" msgstr "" -"Welcome to Adafruit CircuitPython %s!\n" -"\n" -"Please visit learn.adafruit.com/category/circuitpython for project guides.\n" -"\n" -"To list built-in modules please do `help(\"modules\")`.\n" #: shared-bindings/wifi/Radio.c msgid "WiFi password must be between 8 and 63 characters" @@ -2546,10 +2539,6 @@ msgstr "__new__ arg must be a user-type" msgid "a bytes-like object is required" msgstr "a bytes-like object is required" -#: lib/embed/abort_.c -msgid "abort() called" -msgstr "abort() called" - #: shared-bindings/i2cperipheral/I2CPeripheral.c msgid "address out of bounds" msgstr "address out of bounds" @@ -2697,10 +2686,6 @@ msgstr "Buffer too small" msgid "buffer too small for requested bytes" msgstr "Buffer too small for requested bytes" -#: shared-bindings/_pew/PewPew.c -msgid "buttons must be digitalio.DigitalInOut" -msgstr "Buttons must be digitalio.DigitalInOut" - #: shared-bindings/adafruit_pixelbuf/PixelBuf.c msgid "byteorder is not a string" msgstr "Byteorder is not a string" @@ -3052,6 +3037,10 @@ msgstr "divide by zero" msgid "division by zero" msgstr "division by zero" +#: ports/espressif/common-hal/rotaryio/IncrementalEncoder.c +msgid "divisor must be 4" +msgstr "" + #: py/objdeque.c msgid "empty" msgstr "empty" @@ -3133,26 +3122,6 @@ msgstr "extra keyword arguments given" msgid "extra positional arguments given" msgstr "extra positional arguments given" -#: py/parse.c -msgid "f-string expression part cannot include a '#'" -msgstr "f-string expression part cannot include a '#'" - -#: py/parse.c -msgid "f-string expression part cannot include a backslash" -msgstr "f-string expression part cannot include a backslash" - -#: py/parse.c -msgid "f-string: empty expression not allowed" -msgstr "f-string: empty expression not allowed" - -#: py/parse.c -msgid "f-string: expecting '}'" -msgstr "f-string: expecting '}'" - -#: py/parse.c -msgid "f-string: single '}' is not allowed" -msgstr "f-string: single '}' is not allowed" - #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c #: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c msgid "file must be a file opened in byte mode" @@ -3413,10 +3382,6 @@ msgstr "inputs are not iterable" msgid "int() arg 2 must be >= 2 and <= 36" msgstr "int() arg 2 must be >= 2 and <= 36" -#: py/objstr.c -msgid "integer required" -msgstr "integer required" - #: extmod/ulab/code/numpy/approx.c msgid "interp is defined for 1D iterables of equal length" msgstr "interp is defined for 1D iterables of equal length" @@ -3430,10 +3395,6 @@ msgstr "interval must be in range %s-%s" msgid "invalid architecture" msgstr "invalid architecture" -#: lib/netutils/netutils.c -msgid "invalid arguments" -msgstr "invalid arguments" - #: shared-bindings/bitmaptools/__init__.c #, c-format msgid "invalid bits_per_pixel %d, must be, 1, 2, 4, 8, 16, 24, or 32" @@ -3490,7 +3451,7 @@ msgstr "invalid syntax for integer with base %d" msgid "invalid syntax for number" msgstr "invalid syntax for number" -#: py/objexcept.c shared-bindings/traceback/__init__.c +#: py/objexcept.c msgid "invalid traceback" msgstr "invalid traceback" @@ -3970,11 +3931,13 @@ 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_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_nopsram/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/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 @@ -3993,6 +3956,8 @@ msgstr "pow() with 3 arguments requires integers" #: 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 @@ -4036,8 +4001,8 @@ msgid "queue overflow" msgstr "queue overflow" #: py/parse.c -msgid "raw f-strings are not implemented" -msgstr "raw f-strings are not implemented" +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" @@ -4099,7 +4064,7 @@ msgstr "sampling rate out of range" msgid "schedule queue full" msgstr "schedule queue full" -#: lib/utils/pyexec.c py/builtinimport.c +#: py/builtinimport.c msgid "script compilation not supported" msgstr "script compilation not supported" @@ -4247,6 +4212,7 @@ msgstr "tile must be greater than zero" msgid "time.struct_time() takes a 9-sequence" msgstr "time.struct_time() takes a 9-sequence" +#: 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 @@ -4375,8 +4341,8 @@ msgid "unicode name escapes" msgstr "unicode name escapes" #: py/parse.c -msgid "unindent does not match any outer indentation level" -msgstr "unindent does not match any outer indentation level" +msgid "unindent doesn't match any outer indent level" +msgstr "" #: py/objstr.c #, c-format @@ -4529,6 +4495,88 @@ 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)" +#, c-format +#~ msgid "" +#~ "Welcome to Adafruit CircuitPython %s!\n" +#~ "\n" +#~ "Please visit learn.adafruit.com/category/circuitpython for project " +#~ "guides.\n" +#~ "\n" +#~ "To list built-in modules please do `help(\"modules\")`.\n" +#~ msgstr "" +#~ "Welcome to Adafruit CircuitPython %s!\n" +#~ "\n" +#~ "Please visit learn.adafruit.com/category/circuitpython for project " +#~ "guides.\n" +#~ "\n" +#~ "To list built-in modules please do `help(\"modules\")`.\n" + +#~ msgid "integer required" +#~ msgstr "integer required" + +#~ msgid "abort() called" +#~ msgstr "abort() called" + +#~ msgid "f-string expression part cannot include a '#'" +#~ msgstr "f-string expression part cannot include a '#'" + +#~ msgid "f-string expression part cannot include a backslash" +#~ msgstr "f-string expression part cannot include a backslash" + +#~ msgid "f-string: empty expression not allowed" +#~ msgstr "f-string: empty expression not allowed" + +#~ msgid "f-string: expecting '}'" +#~ msgstr "f-string: expecting '}'" + +#~ msgid "f-string: single '}' is not allowed" +#~ msgstr "f-string: single '}' is not allowed" + +#~ msgid "invalid arguments" +#~ msgstr "invalid arguments" + +#~ msgid "raw f-strings are not implemented" +#~ msgstr "raw f-strings are not implemented" + +#~ msgid "unindent does not match any outer indentation level" +#~ msgstr "unindent does not match any outer indentation level" + +#~ msgid "%q list must be a list" +#~ msgstr "%q list must be a list" + +#~ msgid "%q must of type %q" +#~ msgstr "%q must of type %q" + +#~ msgid "Column entry must be digitalio.DigitalInOut" +#~ msgstr "Column entry must be digitalio.DigitalInOut" + +#~ msgid "Expected a Characteristic" +#~ msgstr "Expected a Characteristic" + +#~ msgid "Expected a DigitalInOut" +#~ msgstr "Expected a DigitalInOut" + +#~ msgid "Expected a Service" +#~ msgstr "Expected a service" + +#~ msgid "Expected a UART" +#~ msgstr "Expected a UART" + +#~ msgid "Expected a UUID" +#~ msgstr "Expected a UUID" + +#~ msgid "Expected an Address" +#~ msgstr "Expected an address" + +#~ msgid "Row entry must be digitalio.DigitalInOut" +#~ msgstr "Row entry must be digitalio. DigitalInOut" + +#~ msgid "buttons must be digitalio.DigitalInOut" +#~ msgstr "Buttons must be digitalio.DigitalInOut" + +#~ msgid "Invalid frequency" +#~ msgstr "Invalid frequency" + #~ msgid "Data 0 pin must be byte aligned." #~ msgstr "Data 0 pin must be byte aligned." diff --git a/locale/en_US.po b/locale/en_US.po index de9fa6347d..f17de07148 100644 --- a/locale/en_US.po +++ b/locale/en_US.po @@ -2943,7 +2943,7 @@ msgstr "" msgid "schedule stack full" msgstr "" -#: lib/utils/pyexec.c py/builtinimport.c +#: shared/runtime/pyexec.c py/builtinimport.c msgid "script compilation not supported" msgstr "" diff --git a/locale/en_x_pirate.po b/locale/en_x_pirate.po index 40b0b314c4..09ad3c890f 100644 --- a/locale/en_x_pirate.po +++ b/locale/en_x_pirate.po @@ -2950,7 +2950,7 @@ msgstr "" msgid "schedule stack full" msgstr "" -#: lib/utils/pyexec.c py/builtinimport.c +#: shared/runtime/pyexec.c py/builtinimport.c msgid "script compilation not supported" msgstr "" diff --git a/locale/es.po b/locale/es.po index 18e0bb309d..68fa901f89 100644 --- a/locale/es.po +++ b/locale/es.po @@ -114,10 +114,6 @@ msgstr "" msgid "%q length must be >= 1" msgstr "" -#: shared-bindings/vectorio/Polygon.c -msgid "%q list must be a list" -msgstr "%q lista debe ser una lista" - #: py/argcheck.c msgid "%q must <= %d" msgstr "%q debe ser <= %d" @@ -155,14 +151,14 @@ msgstr "%q debe ser una tupla de longitud 2" msgid "%q must be between %d and %d" msgstr "%q debe estar entre %d y %d" +#: py/argcheck.c +msgid "%q must be of type %q" +msgstr "" + #: ports/atmel-samd/common-hal/busio/UART.c msgid "%q must be power of 2" msgstr "" -#: py/argcheck.c -msgid "%q must of type %q" -msgstr "%q debe ser de tipo %q" - #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #: shared-bindings/canio/Match.c msgid "%q out of range" @@ -176,6 +172,10 @@ msgstr "pin inválido %q" msgid "%q should be an int" msgstr "%q debe ser un int" +#: shared-bindings/usb_hid/Device.c +msgid "%q with a report ID of 0 must be of length 1" +msgstr "" + #: py/bc.c py/objnamedtuple.c msgid "%q() takes %d positional arguments but %d were given" msgstr "%q() toma %d argumentos posicionales pero %d fueron dados" @@ -358,6 +358,7 @@ msgstr "pow() con 3 argumentos no soportado" msgid "64 bit types" msgstr "tipos de 64 bit" +#: 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" @@ -380,7 +381,9 @@ msgstr "Tipo de dirección fuera de rango" msgid "All CAN peripherals are in use" msgstr "Todos los periféricos CAN están en uso" -#: ports/espressif/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c +#: 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 "Todos los periféricos I2C están siendo usados" @@ -564,6 +567,10 @@ msgstr "Bit depth tiene que ser de 1 a 6 inclusivo, no %d" msgid "Bit depth must be multiple of 8." msgstr "Bits depth debe ser múltiplo de 8." +#: 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 "Ambos RX y TX requeridos para control de flujo" @@ -635,6 +642,10 @@ msgstr "Buffer debe ser de longitud 1 como minimo" msgid "Buffer too short by %d bytes" msgstr "Búffer muy corto por %d bytes" +#: 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 @@ -797,10 +808,6 @@ msgstr "Estirado de reloj demasiado largo" msgid "Clock unit in use" msgstr "Clock unit está siendo utilizado" -#: shared-bindings/_pew/PewPew.c -msgid "Column entry must be digitalio.DigitalInOut" -msgstr "Entrada de columna debe ser digitalio.DigitalInOut" - #: 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" @@ -979,36 +986,9 @@ msgstr "Error: fallo al vincular" #: 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 -#: shared-bindings/terminalio/Terminal.c msgid "Expected a %q" msgstr "Se espera un %q" -#: shared-bindings/_bleio/CharacteristicBuffer.c -#: shared-bindings/_bleio/Descriptor.c shared-bindings/_bleio/PacketBuffer.c -msgid "Expected a Characteristic" -msgstr "Se esperaba una Característica" - -#: shared-bindings/_bleio/Adapter.c -msgid "Expected a DigitalInOut" -msgstr "Se espera un DigitalInOut" - -#: shared-bindings/_bleio/Characteristic.c -msgid "Expected a Service" -msgstr "Se esperaba un servicio" - -#: shared-bindings/_bleio/Adapter.c -msgid "Expected a UART" -msgstr "Se espera un UART" - -#: shared-bindings/_bleio/Characteristic.c shared-bindings/_bleio/Descriptor.c -#: shared-bindings/_bleio/Service.c -msgid "Expected a UUID" -msgstr "Se esperaba un UUID" - -#: shared-bindings/_bleio/Adapter.c -msgid "Expected an Address" -msgstr "Se esperaba una dirección" - #: shared-bindings/alarm/__init__.c msgid "Expected an alarm" msgstr "Un objecto alarm era esperado" @@ -1334,8 +1314,11 @@ msgstr "Frecuencia PWM inválida" msgid "Invalid Pin" msgstr "Pin inválido" -#: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c -#: py/moduerrno.c shared-module/rgbmatrix/RGBMatrix.c +#: 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 "Argumento inválido" @@ -1383,10 +1366,6 @@ msgstr "Archivo inválido" msgid "Invalid format chunk size" msgstr "Formato de fragmento de formato no válido" -#: ports/espressif/common-hal/busio/I2C.c -msgid "Invalid frequency" -msgstr "Frecuencia inválida" - #: supervisor/shared/safe_mode.c msgid "Invalid memory access." msgstr "Acceso a memoria no válido." @@ -1427,6 +1406,7 @@ msgstr "Pin inválido para canal derecho" #: 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 @@ -1649,6 +1629,10 @@ msgstr "Sin pin TX" msgid "No available clocks" msgstr "Relojes no disponibles" +#: 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 "Sin conexión: no se puede determinar la longitud" @@ -1669,6 +1653,7 @@ msgstr "No hay hardware random disponible" msgid "No hardware support on clk pin" msgstr "Sin soporte de hardware en el pin 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" @@ -1814,6 +1799,11 @@ msgstr "" msgid "Only one TouchAlarm can be set in deep sleep." msgstr "Solamente una TouchAlarm puede ser configurada durante deep sleep." +#: 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 @@ -1886,6 +1876,7 @@ msgstr "Periférico en uso" msgid "Permission denied" msgstr "Permiso denegado" +#: 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 "El Pin no se puede despertar de un sueño profundo" @@ -1938,10 +1929,13 @@ msgstr "" "constructor" #: ports/raspberrypi/common-hal/imagecapture/ParallelImageCapture.c -#: ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c msgid "Pins must be sequential" msgstr "Los pines deben estar en orden secuencial" +#: 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 "Los pines deben compartir la división PWM" @@ -1993,6 +1987,7 @@ msgstr "Programa demasiado grande" msgid "Pull not used when direction is output." msgstr "Pull no se usa cuando la dirección es output." +#: ports/atmel-samd/common-hal/watchdog/WatchDogTimer.c #: ports/raspberrypi/common-hal/watchdog/WatchDogTimer.c msgid "RAISE mode is not implemented" msgstr "El modo RAISE no esta implementado" @@ -2070,10 +2065,6 @@ msgstr "Recurso solicitado no encontrado" msgid "Right channel unsupported" msgstr "Canal derecho no soportado" -#: shared-bindings/_pew/PewPew.c -msgid "Row entry must be digitalio.DigitalInOut" -msgstr "La entrada de la fila debe ser digitalio.DigitalInOut" - #: main.c msgid "Running in safe mode! Not running saved code.\n" msgstr "" @@ -2143,6 +2134,7 @@ msgstr "El conteo de pines de Side set debe estar entre 1 y 5" msgid "Size not supported" msgstr "Sin capacidades para el tamaño" +#: ports/atmel-samd/common-hal/alarm/SleepMemory.c #: ports/raspberrypi/common-hal/alarm/SleepMemory.c msgid "Sleep Memory not available" msgstr "Memoria de sueño no disponible" @@ -2253,6 +2245,10 @@ msgstr "El sample rate del sample no iguala al del mixer" msgid "The sample's signedness does not match the mixer's" msgstr "El signo del sample no iguala al del mixer" +#: 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 " @@ -2307,6 +2303,7 @@ msgstr "Muchos displays" msgid "Total data to write is larger than %q" msgstr "La cantidad total de datos es mas grande que %q" +#: 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" @@ -2499,6 +2496,7 @@ msgstr "Tiempo de espera agotado para lectura de voltaje" msgid "WARNING: Your code filename has two extensions\n" msgstr "ADVERTENCIA: El nombre de archivo de tu código tiene dos extensiones\n" +#: 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" @@ -2528,16 +2526,10 @@ msgstr "Temporizador de perro guardián expirado." msgid "" "Welcome to Adafruit CircuitPython %s!\n" "\n" -"Please visit learn.adafruit.com/category/circuitpython for project guides.\n" +"Visit circuitpython.org for more information.\n" "\n" -"To list built-in modules please do `help(\"modules\")`.\n" +"To list built-in modules type `help(\"modules\")`.\n" msgstr "" -"Bienvenido a Adafruit CircuitPython %s!\n" -"\n" -"Visita learn.adafruit.com/category/circuitpython para obtener guías de " -"proyectos.\n" -"\n" -"Para listar los módulos incorporados por favor haga `help(\"modules\")`.\n" #: shared-bindings/wifi/Radio.c msgid "WiFi password must be between 8 and 63 characters" @@ -2582,10 +2574,6 @@ msgstr "__new__ arg debe ser un user-type" msgid "a bytes-like object is required" msgstr "se requiere un objeto bytes-like" -#: lib/embed/abort_.c -msgid "abort() called" -msgstr "se llamó abort()" - #: shared-bindings/i2cperipheral/I2CPeripheral.c msgid "address out of bounds" msgstr "address fuera de límites" @@ -2733,10 +2721,6 @@ msgstr "buffer demasiado pequeño" msgid "buffer too small for requested bytes" msgstr "búfer muy pequeño para los bytes solicitados" -#: shared-bindings/_pew/PewPew.c -msgid "buttons must be digitalio.DigitalInOut" -msgstr "los botones necesitan ser digitalio.DigitalInOut" - #: shared-bindings/adafruit_pixelbuf/PixelBuf.c msgid "byteorder is not a string" msgstr "byteorder no es una cadena" @@ -3092,6 +3076,10 @@ msgstr "divide por cero" msgid "division by zero" msgstr "división por cero" +#: ports/espressif/common-hal/rotaryio/IncrementalEncoder.c +msgid "divisor must be 4" +msgstr "" + #: py/objdeque.c msgid "empty" msgstr "vacío" @@ -3173,26 +3161,6 @@ msgstr "argumento(s) por palabra clave adicionales fueron dados" msgid "extra positional arguments given" msgstr "argumento posicional adicional dado" -#: py/parse.c -msgid "f-string expression part cannot include a '#'" -msgstr "La parte de expresión f-string no puede incluir un '#'" - -#: py/parse.c -msgid "f-string expression part cannot include a backslash" -msgstr "La parte de expresión f-string no puede incluir una barra invertida" - -#: py/parse.c -msgid "f-string: empty expression not allowed" -msgstr "cadena-f: expresión vacía no permitida" - -#: py/parse.c -msgid "f-string: expecting '}'" -msgstr "f-string: esperando '}'" - -#: py/parse.c -msgid "f-string: single '}' is not allowed" -msgstr "cadena-f: solo '}' no está permitido" - #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c #: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c msgid "file must be a file opened in byte mode" @@ -3453,10 +3421,6 @@ msgstr "Entradas no son iterables" msgid "int() arg 2 must be >= 2 and <= 36" msgstr "int() arg 2 debe ser >= 2 y <= 36" -#: py/objstr.c -msgid "integer required" -msgstr "Entero requerido" - #: extmod/ulab/code/numpy/approx.c msgid "interp is defined for 1D iterables of equal length" msgstr "interp está definido para iterables 1D de igual tamaño" @@ -3470,10 +3434,6 @@ msgstr "el intervalo debe ser der rango %s-%s" msgid "invalid architecture" msgstr "arquitectura inválida" -#: lib/netutils/netutils.c -msgid "invalid arguments" -msgstr "argumentos inválidos" - #: shared-bindings/bitmaptools/__init__.c #, c-format msgid "invalid bits_per_pixel %d, must be, 1, 2, 4, 8, 16, 24, or 32" @@ -3530,7 +3490,7 @@ msgstr "sintaxis inválida para entero con base %d" msgid "invalid syntax for number" msgstr "sintaxis inválida para número" -#: py/objexcept.c shared-bindings/traceback/__init__.c +#: py/objexcept.c msgid "invalid traceback" msgstr "" @@ -4017,11 +3977,13 @@ 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_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_nopsram/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/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 @@ -4040,6 +4002,8 @@ msgstr "pow() con 3 argumentos requiere enteros" #: 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 @@ -4083,8 +4047,8 @@ msgid "queue overflow" msgstr "desbordamiento de cola(queue)" #: py/parse.c -msgid "raw f-strings are not implemented" -msgstr "no está implementado cadenas-f sin procesar" +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" @@ -4146,7 +4110,7 @@ msgstr "frecuencia de muestreo fuera de rango" msgid "schedule queue full" msgstr "cola de planificación llena" -#: lib/utils/pyexec.c py/builtinimport.c +#: py/builtinimport.c msgid "script compilation not supported" msgstr "script de compilación no soportado" @@ -4294,6 +4258,7 @@ msgstr "tile debe sera mas grande que cero" msgid "time.struct_time() takes a 9-sequence" msgstr "time.struct_time() toma un sequencio 9" +#: 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 @@ -4423,8 +4388,8 @@ msgid "unicode name escapes" msgstr "nombre en unicode escapa" #: py/parse.c -msgid "unindent does not match any outer indentation level" -msgstr "sangría no coincide con ningún nivel exterior" +msgid "unindent doesn't match any outer indent level" +msgstr "" #: py/objstr.c #, c-format @@ -4577,6 +4542,88 @@ 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)" +#, c-format +#~ msgid "" +#~ "Welcome to Adafruit CircuitPython %s!\n" +#~ "\n" +#~ "Please visit learn.adafruit.com/category/circuitpython for project " +#~ "guides.\n" +#~ "\n" +#~ "To list built-in modules please do `help(\"modules\")`.\n" +#~ msgstr "" +#~ "Bienvenido a Adafruit CircuitPython %s!\n" +#~ "\n" +#~ "Visita learn.adafruit.com/category/circuitpython para obtener guías de " +#~ "proyectos.\n" +#~ "\n" +#~ "Para listar los módulos incorporados por favor haga `help(\"modules\")`.\n" + +#~ msgid "integer required" +#~ msgstr "Entero requerido" + +#~ msgid "abort() called" +#~ msgstr "se llamó abort()" + +#~ msgid "f-string expression part cannot include a '#'" +#~ msgstr "La parte de expresión f-string no puede incluir un '#'" + +#~ msgid "f-string expression part cannot include a backslash" +#~ msgstr "La parte de expresión f-string no puede incluir una barra invertida" + +#~ msgid "f-string: empty expression not allowed" +#~ msgstr "cadena-f: expresión vacía no permitida" + +#~ msgid "f-string: expecting '}'" +#~ msgstr "f-string: esperando '}'" + +#~ msgid "f-string: single '}' is not allowed" +#~ msgstr "cadena-f: solo '}' no está permitido" + +#~ msgid "invalid arguments" +#~ msgstr "argumentos inválidos" + +#~ msgid "raw f-strings are not implemented" +#~ msgstr "no está implementado cadenas-f sin procesar" + +#~ msgid "unindent does not match any outer indentation level" +#~ msgstr "sangría no coincide con ningún nivel exterior" + +#~ msgid "%q list must be a list" +#~ msgstr "%q lista debe ser una lista" + +#~ msgid "%q must of type %q" +#~ msgstr "%q debe ser de tipo %q" + +#~ msgid "Column entry must be digitalio.DigitalInOut" +#~ msgstr "Entrada de columna debe ser digitalio.DigitalInOut" + +#~ msgid "Expected a Characteristic" +#~ msgstr "Se esperaba una Característica" + +#~ msgid "Expected a DigitalInOut" +#~ msgstr "Se espera un DigitalInOut" + +#~ msgid "Expected a Service" +#~ msgstr "Se esperaba un servicio" + +#~ msgid "Expected a UART" +#~ msgstr "Se espera un UART" + +#~ msgid "Expected a UUID" +#~ msgstr "Se esperaba un UUID" + +#~ msgid "Expected an Address" +#~ msgstr "Se esperaba una dirección" + +#~ msgid "Row entry must be digitalio.DigitalInOut" +#~ msgstr "La entrada de la fila debe ser digitalio.DigitalInOut" + +#~ msgid "buttons must be digitalio.DigitalInOut" +#~ msgstr "los botones necesitan ser digitalio.DigitalInOut" + +#~ msgid "Invalid frequency" +#~ msgstr "Frecuencia inválida" + #~ msgid "Data 0 pin must be byte aligned." #~ msgstr "El pin de datos 0 debe ser alineado a byte." diff --git a/locale/fil.po b/locale/fil.po index 493a79c232..20f52780c1 100644 --- a/locale/fil.po +++ b/locale/fil.po @@ -104,10 +104,6 @@ msgstr "" msgid "%q length must be >= 1" msgstr "" -#: shared-bindings/vectorio/Polygon.c -msgid "%q list must be a list" -msgstr "" - #: py/argcheck.c msgid "%q must <= %d" msgstr "" @@ -146,12 +142,12 @@ msgstr "" msgid "%q must be between %d and %d" msgstr "" -#: ports/atmel-samd/common-hal/busio/UART.c -msgid "%q must be power of 2" +#: py/argcheck.c +msgid "%q must be of type %q" msgstr "" -#: py/argcheck.c -msgid "%q must of type %q" +#: ports/atmel-samd/common-hal/busio/UART.c +msgid "%q must be power of 2" msgstr "" #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c @@ -168,6 +164,10 @@ msgstr "" msgid "%q should be an int" msgstr "y ay dapat int" +#: shared-bindings/usb_hid/Device.c +msgid "%q with a report ID of 0 must be of length 1" +msgstr "" + #: py/bc.c py/objnamedtuple.c msgid "%q() takes %d positional arguments but %d were given" msgstr "" @@ -351,6 +351,7 @@ msgstr "3-arg pow() hindi suportado" msgid "64 bit types" msgstr "" +#: 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" @@ -373,7 +374,9 @@ msgstr "" msgid "All CAN peripherals are in use" msgstr "" -#: ports/espressif/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c +#: 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 "Lahat ng I2C peripherals ginagamit" @@ -556,6 +559,10 @@ msgstr "" msgid "Bit depth must be multiple of 8." msgstr "Bit depth ay dapat multiple ng 8." +#: 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 "" @@ -626,6 +633,10 @@ msgstr "Buffer dapat ay hindi baba sa 1 na haba" 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 @@ -786,10 +797,6 @@ msgstr "Masyadong mahaba ang Clock stretch" msgid "Clock unit in use" msgstr "Clock unit ginagamit" -#: shared-bindings/_pew/PewPew.c -msgid "Column entry must be digitalio.DigitalInOut" -msgstr "" - #: shared-bindings/displayio/FourWire.c shared-bindings/displayio/I2CDisplay.c #: shared-bindings/paralleldisplay/ParallelBus.c #, fuzzy @@ -969,38 +976,9 @@ msgstr "" #: 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 -#: shared-bindings/terminalio/Terminal.c msgid "Expected a %q" msgstr "Umasa ng %q" -#: shared-bindings/_bleio/CharacteristicBuffer.c -#: shared-bindings/_bleio/Descriptor.c shared-bindings/_bleio/PacketBuffer.c -#, fuzzy -msgid "Expected a Characteristic" -msgstr "Hindi mabasa and Characteristic." - -#: shared-bindings/_bleio/Adapter.c -msgid "Expected a DigitalInOut" -msgstr "" - -#: shared-bindings/_bleio/Characteristic.c -msgid "Expected a Service" -msgstr "" - -#: shared-bindings/_bleio/Adapter.c -msgid "Expected a UART" -msgstr "" - -#: shared-bindings/_bleio/Characteristic.c shared-bindings/_bleio/Descriptor.c -#: shared-bindings/_bleio/Service.c -#, fuzzy -msgid "Expected a UUID" -msgstr "Umasa ng %q" - -#: shared-bindings/_bleio/Adapter.c -msgid "Expected an Address" -msgstr "" - #: shared-bindings/alarm/__init__.c msgid "Expected an alarm" msgstr "" @@ -1318,8 +1296,11 @@ msgstr "Mali ang PWM frequency" msgid "Invalid Pin" msgstr "" -#: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c -#: py/moduerrno.c shared-module/rgbmatrix/RGBMatrix.c +#: 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 "Maling argumento" @@ -1367,10 +1348,6 @@ msgstr "Mali ang file" msgid "Invalid format chunk size" msgstr "Mali ang format ng chunk size" -#: ports/espressif/common-hal/busio/I2C.c -msgid "Invalid frequency" -msgstr "" - #: supervisor/shared/safe_mode.c msgid "Invalid memory access." msgstr "" @@ -1411,6 +1388,7 @@ msgstr "Mali ang pin para sa kanang channel" #: 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 @@ -1629,6 +1607,10 @@ msgstr "Walang TX pin" 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 "" @@ -1649,6 +1631,7 @@ msgstr "Walang magagamit na hardware random" 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" @@ -1791,6 +1774,11 @@ msgstr "" 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 @@ -1862,6 +1850,7 @@ msgstr "" msgid "Permission denied" msgstr "Walang pahintulot" +#: 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 "" @@ -1911,10 +1900,13 @@ msgid "" msgstr "" #: ports/raspberrypi/common-hal/imagecapture/ParallelImageCapture.c -#: ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.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 "" @@ -1963,6 +1955,7 @@ msgstr "" msgid "Pull not used when direction is output." msgstr "Pull hindi ginagamit kapag ang direksyon ay output." +#: ports/atmel-samd/common-hal/watchdog/WatchDogTimer.c #: ports/raspberrypi/common-hal/watchdog/WatchDogTimer.c msgid "RAISE mode is not implemented" msgstr "" @@ -2041,10 +2034,6 @@ msgstr "" msgid "Right channel unsupported" msgstr "Hindi supportado ang kanang channel" -#: shared-bindings/_pew/PewPew.c -msgid "Row entry must be digitalio.DigitalInOut" -msgstr "" - #: main.c msgid "Running in safe mode! Not running saved code.\n" msgstr "Tumatakbo sa safe mode! Hindi tumatakbo ang nai-save na code.\n" @@ -2113,6 +2102,7 @@ msgstr "" 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 "" @@ -2215,6 +2205,10 @@ msgstr "Ang sample rate ng sample ay hindi tugma sa mixer" msgid "The sample's signedness does not match the mixer's" msgstr "Ang signedness ng sample hindi tugma sa mixer" +#: 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 " @@ -2267,6 +2261,7 @@ msgstr "" 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" @@ -2459,6 +2454,7 @@ msgstr "" msgid "WARNING: Your code filename has two extensions\n" msgstr "BABALA: Ang pangalan ng file ay may dalawang extension\n" +#: 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" @@ -2485,16 +2481,10 @@ msgstr "" msgid "" "Welcome to Adafruit CircuitPython %s!\n" "\n" -"Please visit learn.adafruit.com/category/circuitpython for project guides.\n" +"Visit circuitpython.org for more information.\n" "\n" -"To list built-in modules please do `help(\"modules\")`.\n" +"To list built-in modules type `help(\"modules\")`.\n" msgstr "" -"Mabuhay sa Adafruit CircuitPython %s!\n" -"\n" -"Mangyaring bisitahin ang learn.adafruit.com/category/circuitpython para sa " -"project guides.\n" -"\n" -"Para makita ang listahan ng modules, `help(“modules”)`.\n" #: shared-bindings/wifi/Radio.c msgid "WiFi password must be between 8 and 63 characters" @@ -2537,10 +2527,6 @@ msgstr "__new__ arg ay dapat na user-type" msgid "a bytes-like object is required" msgstr "a bytes-like object ay kailangan" -#: lib/embed/abort_.c -msgid "abort() called" -msgstr "abort() tinawag" - #: shared-bindings/i2cperipheral/I2CPeripheral.c msgid "address out of bounds" msgstr "wala sa sakop ang address" @@ -2689,10 +2675,6 @@ msgstr "masyadong maliit ang buffer" msgid "buffer too small for requested bytes" msgstr "" -#: shared-bindings/_pew/PewPew.c -msgid "buttons must be digitalio.DigitalInOut" -msgstr "" - #: shared-bindings/adafruit_pixelbuf/PixelBuf.c msgid "byteorder is not a string" msgstr "" @@ -3051,6 +3033,10 @@ msgstr "" msgid "division by zero" msgstr "dibisyon ng zero" +#: ports/espressif/common-hal/rotaryio/IncrementalEncoder.c +msgid "divisor must be 4" +msgstr "" + #: py/objdeque.c msgid "empty" msgstr "walang laman" @@ -3133,26 +3119,6 @@ msgstr "dagdag na keyword argument na ibinigay" msgid "extra positional arguments given" msgstr "dagdag na positional argument na ibinigay" -#: py/parse.c -msgid "f-string expression part cannot include a '#'" -msgstr "" - -#: py/parse.c -msgid "f-string expression part cannot include a backslash" -msgstr "" - -#: py/parse.c -msgid "f-string: empty expression not allowed" -msgstr "" - -#: py/parse.c -msgid "f-string: expecting '}'" -msgstr "" - -#: py/parse.c -msgid "f-string: single '}' is not allowed" -msgstr "" - #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c #: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c msgid "file must be a file opened in byte mode" @@ -3414,10 +3380,6 @@ msgstr "" msgid "int() arg 2 must be >= 2 and <= 36" msgstr "int() arg 2 ay dapat >=2 at <= 36" -#: py/objstr.c -msgid "integer required" -msgstr "kailangan ng int" - #: extmod/ulab/code/numpy/approx.c msgid "interp is defined for 1D iterables of equal length" msgstr "" @@ -3431,10 +3393,6 @@ msgstr "" msgid "invalid architecture" msgstr "" -#: lib/netutils/netutils.c -msgid "invalid arguments" -msgstr "mali ang mga argumento" - #: shared-bindings/bitmaptools/__init__.c #, c-format msgid "invalid bits_per_pixel %d, must be, 1, 2, 4, 8, 16, 24, or 32" @@ -3491,7 +3449,7 @@ msgstr "maling sintaks sa integer na may base %d" msgid "invalid syntax for number" msgstr "maling sintaks sa number" -#: py/objexcept.c shared-bindings/traceback/__init__.c +#: py/objexcept.c msgid "invalid traceback" msgstr "" @@ -3977,11 +3935,13 @@ 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_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_nopsram/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/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 @@ -4000,6 +3960,8 @@ msgstr "pow() na may 3 argumento kailangan ng integers" #: 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 @@ -4043,7 +4005,7 @@ msgid "queue overflow" msgstr "puno na ang pila (overflow)" #: py/parse.c -msgid "raw f-strings are not implemented" +msgid "raw f-strings are not supported" msgstr "" #: extmod/ulab/code/numpy/fft/fft_tools.c @@ -4106,7 +4068,7 @@ msgstr "pagpili ng rate wala sa sakop" msgid "schedule queue full" msgstr "" -#: lib/utils/pyexec.c py/builtinimport.c +#: py/builtinimport.c msgid "script compilation not supported" msgstr "script kompilasyon hindi supportado" @@ -4255,6 +4217,7 @@ msgstr "" msgid "time.struct_time() takes a 9-sequence" msgstr "time.struct_time() kumukuha ng 9-sequence" +#: 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 @@ -4384,8 +4347,8 @@ msgid "unicode name escapes" msgstr "unicode name escapes" #: py/parse.c -msgid "unindent does not match any outer indentation level" -msgstr "unindent hindi tugma sa indentation level sa labas" +msgid "unindent doesn't match any outer indent level" +msgstr "" #: py/objstr.c #, c-format @@ -4540,6 +4503,42 @@ msgstr "" msgid "zi must be of shape (n_section, 2)" msgstr "" +#, c-format +#~ msgid "" +#~ "Welcome to Adafruit CircuitPython %s!\n" +#~ "\n" +#~ "Please visit learn.adafruit.com/category/circuitpython for project " +#~ "guides.\n" +#~ "\n" +#~ "To list built-in modules please do `help(\"modules\")`.\n" +#~ msgstr "" +#~ "Mabuhay sa Adafruit CircuitPython %s!\n" +#~ "\n" +#~ "Mangyaring bisitahin ang learn.adafruit.com/category/circuitpython para " +#~ "sa project guides.\n" +#~ "\n" +#~ "Para makita ang listahan ng modules, `help(“modules”)`.\n" + +#~ msgid "integer required" +#~ msgstr "kailangan ng int" + +#~ msgid "abort() called" +#~ msgstr "abort() tinawag" + +#~ msgid "invalid arguments" +#~ msgstr "mali ang mga argumento" + +#~ msgid "unindent does not match any outer indentation level" +#~ msgstr "unindent hindi tugma sa indentation level sa labas" + +#, fuzzy +#~ msgid "Expected a Characteristic" +#~ msgstr "Hindi mabasa and Characteristic." + +#, fuzzy +#~ msgid "Expected a UUID" +#~ msgstr "Umasa ng %q" + #~ msgid "no available NIC" #~ msgstr "walang magagamit na NIC" diff --git a/locale/fr.po b/locale/fr.po index 16a67658de..ed03aff738 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -114,10 +114,6 @@ msgstr "" msgid "%q length must be >= 1" msgstr "" -#: shared-bindings/vectorio/Polygon.c -msgid "%q list must be a list" -msgstr "La liste %q doit être une liste" - #: py/argcheck.c msgid "%q must <= %d" msgstr "" @@ -155,14 +151,14 @@ msgstr "%q doit être un tuple de longueur 2" msgid "%q must be between %d and %d" msgstr "" +#: py/argcheck.c +msgid "%q must be of type %q" +msgstr "" + #: ports/atmel-samd/common-hal/busio/UART.c msgid "%q must be power of 2" msgstr "%q doit être une puissance de 2" -#: py/argcheck.c -msgid "%q must of type %q" -msgstr "%q doit être de type %q" - #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #: shared-bindings/canio/Match.c msgid "%q out of range" @@ -176,6 +172,10 @@ msgstr "broche %q invalide" msgid "%q should be an int" msgstr "%q doit être un chiffre entier (int)" +#: shared-bindings/usb_hid/Device.c +msgid "%q with a report ID of 0 must be of length 1" +msgstr "" + #: py/bc.c py/objnamedtuple.c msgid "%q() takes %d positional arguments but %d were given" msgstr "%q() prend %d paramètres positionnels mais %d ont été donnés" @@ -358,6 +358,7 @@ msgstr "pow() non supporté avec 3 paramètres" msgid "64 bit types" msgstr "types à 64 bit" +#: 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" @@ -380,7 +381,9 @@ msgstr "Type d'adresse hors portée" msgid "All CAN peripherals are in use" msgstr "Tous les périphériques CAN sont utilisés" -#: ports/espressif/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c +#: 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 "Tous les périphériques I2C sont utilisés" @@ -566,6 +569,10 @@ msgstr "Bit depth doit être entre 1 et 6 inclusivement, et non %d" msgid "Bit depth must be multiple of 8." msgstr "La profondeur de bit doit être un multiple de 8." +#: 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 "RX et TX requis pour le contrôle de flux" @@ -636,6 +643,10 @@ msgstr "Le tampon doit être de longueur au moins 1" msgid "Buffer too short by %d bytes" msgstr "Tampon trop court de %d octets" +#: 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 @@ -803,10 +814,6 @@ msgstr "Période de l'horloge trop longue" msgid "Clock unit in use" msgstr "Horloge en cours d'utilisation" -#: shared-bindings/_pew/PewPew.c -msgid "Column entry must be digitalio.DigitalInOut" -msgstr "L'entrée 'Column' doit être un digitalio.DigitalInOut" - #: 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" @@ -985,36 +992,9 @@ msgstr "Erreur : Impossible de lier" #: 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 -#: shared-bindings/terminalio/Terminal.c msgid "Expected a %q" msgstr "Attendu un %q" -#: shared-bindings/_bleio/CharacteristicBuffer.c -#: shared-bindings/_bleio/Descriptor.c shared-bindings/_bleio/PacketBuffer.c -msgid "Expected a Characteristic" -msgstr "Une 'Characteristic' est attendue" - -#: shared-bindings/_bleio/Adapter.c -msgid "Expected a DigitalInOut" -msgstr "Un 'DigitalInOut' est attendu" - -#: shared-bindings/_bleio/Characteristic.c -msgid "Expected a Service" -msgstr "Un Service est attendu" - -#: shared-bindings/_bleio/Adapter.c -msgid "Expected a UART" -msgstr "Un UART est attendu" - -#: shared-bindings/_bleio/Characteristic.c shared-bindings/_bleio/Descriptor.c -#: shared-bindings/_bleio/Service.c -msgid "Expected a UUID" -msgstr "Un UUID est attendu" - -#: shared-bindings/_bleio/Adapter.c -msgid "Expected an Address" -msgstr "Un Address est attendu" - #: shared-bindings/alarm/__init__.c msgid "Expected an alarm" msgstr "Une alarme était prévue" @@ -1344,8 +1324,11 @@ msgstr "Fréquence de PWM invalide" msgid "Invalid Pin" msgstr "Broche invalide" -#: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c -#: py/moduerrno.c shared-module/rgbmatrix/RGBMatrix.c +#: 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 "Paramètre invalide" @@ -1393,10 +1376,6 @@ msgstr "Fichier invalide" msgid "Invalid format chunk size" msgstr "Taille de bloc de formatage invalide" -#: ports/espressif/common-hal/busio/I2C.c -msgid "Invalid frequency" -msgstr "Fréquence non valide" - #: supervisor/shared/safe_mode.c msgid "Invalid memory access." msgstr "Accès à la mémoire invalide." @@ -1437,6 +1416,7 @@ msgstr "Broche invalide pour le canal droit" #: 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 @@ -1657,6 +1637,10 @@ msgstr "Pas de broche TX" msgid "No available clocks" msgstr "Pas d'horloge disponible" +#: 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 "Pas de connexion : la longueur ne peut pas être déterminée" @@ -1677,6 +1661,7 @@ msgstr "Aucunes source de valeurs aléatoire matérielle disponible" msgid "No hardware support on clk pin" msgstr "Pas de support matériel sur la broche 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" @@ -1822,6 +1807,11 @@ msgstr "" msgid "Only one TouchAlarm can be set in deep sleep." msgstr "Seulement une TouchAlarm peu être réglée en someil profond." +#: 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 @@ -1896,6 +1886,7 @@ msgstr "Périphérique en utilisation" msgid "Permission denied" msgstr "Permission refusée" +#: 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 "" @@ -1948,10 +1939,13 @@ msgstr "" "= True au constructeur" #: ports/raspberrypi/common-hal/imagecapture/ParallelImageCapture.c -#: ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c msgid "Pins must be sequential" msgstr "Les broches doivent être séquentielles" +#: 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 "Les broches doivent partager la tranche PWM" @@ -2003,6 +1997,7 @@ msgstr "Programme trop grand" msgid "Pull not used when direction is output." msgstr "Le tirage 'pull' n'est pas utilisé quand la direction est 'output'." +#: ports/atmel-samd/common-hal/watchdog/WatchDogTimer.c #: ports/raspberrypi/common-hal/watchdog/WatchDogTimer.c msgid "RAISE mode is not implemented" msgstr "Mode RAISE n'est pas implémenté" @@ -2080,10 +2075,6 @@ msgstr "Resource demandée non trouvée" msgid "Right channel unsupported" msgstr "Canal droit non supporté" -#: shared-bindings/_pew/PewPew.c -msgid "Row entry must be digitalio.DigitalInOut" -msgstr "L'entrée de ligne 'Row' doit être un digitalio.DigitalInOut" - #: main.c msgid "Running in safe mode! Not running saved code.\n" msgstr "Mode sans-échec ! Le code sauvegardé n'est pas éxecuté.\n" @@ -2152,6 +2143,7 @@ msgstr "Nombre de broches Side configurées doit être entre 1 et 5" msgid "Size not supported" msgstr "Taille n'est pas supportée" +#: ports/atmel-samd/common-hal/alarm/SleepMemory.c #: ports/raspberrypi/common-hal/alarm/SleepMemory.c msgid "Sleep Memory not available" msgstr "" @@ -2255,6 +2247,10 @@ msgstr "L'échantillonage de l'échantillon ne correspond pas à celui du mixer" msgid "The sample's signedness does not match the mixer's" msgstr "Le signe de l'échantillon ne correspond pas à celui du mixer" +#: 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 " @@ -2307,6 +2303,7 @@ msgstr "Trop d'affichages" msgid "Total data to write is larger than %q" msgstr "Quantité de données à écrire est plus que %q" +#: 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" @@ -2503,6 +2500,7 @@ msgstr "La lecture de la tension a expiré" msgid "WARNING: Your code filename has two extensions\n" msgstr "ATTENTION : le nom de fichier de votre code a deux extensions\n" +#: 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" @@ -2533,15 +2531,10 @@ msgstr "Le minuteur Watchdog a expiré." msgid "" "Welcome to Adafruit CircuitPython %s!\n" "\n" -"Please visit learn.adafruit.com/category/circuitpython for project guides.\n" +"Visit circuitpython.org for more information.\n" "\n" -"To list built-in modules please do `help(\"modules\")`.\n" +"To list built-in modules type `help(\"modules\")`.\n" msgstr "" -"Bienvenue sur Adafruit CircuitPython %s !\n" -"\n" -"Visitez learn.adafruit.com/category/circuitpython pour les guides.\n" -"\n" -"Pour lister les modules inclus, tapez `help(\"modules\")`.\n" #: shared-bindings/wifi/Radio.c msgid "WiFi password must be between 8 and 63 characters" @@ -2584,10 +2577,6 @@ msgstr "l'argument __new__ doit être d'un type défini par l'utilisateur" msgid "a bytes-like object is required" msgstr "un objet 'bytes-like' est requis" -#: lib/embed/abort_.c -msgid "abort() called" -msgstr "abort() appelé" - #: shared-bindings/i2cperipheral/I2CPeripheral.c msgid "address out of bounds" msgstr "adresse hors limites" @@ -2735,10 +2724,6 @@ msgstr "tampon trop petit" msgid "buffer too small for requested bytes" msgstr "tampon trop petit pour le nombre d'octets demandé" -#: shared-bindings/_pew/PewPew.c -msgid "buttons must be digitalio.DigitalInOut" -msgstr "les boutons doivent être des digitalio.DigitalInOut" - #: shared-bindings/adafruit_pixelbuf/PixelBuf.c msgid "byteorder is not a string" msgstr "byteorder n'est pas une chaîne" @@ -3098,6 +3083,10 @@ msgstr "" msgid "division by zero" msgstr "division par zéro" +#: ports/espressif/common-hal/rotaryio/IncrementalEncoder.c +msgid "divisor must be 4" +msgstr "" + #: py/objdeque.c msgid "empty" msgstr "vide" @@ -3179,28 +3168,6 @@ msgstr "argument(s) nommé(s) supplémentaire(s) donné(s)" msgid "extra positional arguments given" msgstr "argument(s) positionnel(s) supplémentaire(s) donné(s)" -#: py/parse.c -msgid "f-string expression part cannot include a '#'" -msgstr "La partie d'expression de chaîne f ne peut pas inclure de '#'" - -#: py/parse.c -msgid "f-string expression part cannot include a backslash" -msgstr "" -"La partie d'expression de chaîne f ne peut pas inclure de barre oblique " -"inverse" - -#: py/parse.c -msgid "f-string: empty expression not allowed" -msgstr "f-string : expression vide non autorisée" - -#: py/parse.c -msgid "f-string: expecting '}'" -msgstr "f-string : attend '}'" - -#: py/parse.c -msgid "f-string: single '}' is not allowed" -msgstr "f-string : single '}' n'est pas autorisé" - #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c #: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c msgid "file must be a file opened in byte mode" @@ -3462,10 +3429,6 @@ msgstr "les entrées ne sont pas itérables" msgid "int() arg 2 must be >= 2 and <= 36" msgstr "l'argument 2 de int() doit être >=2 et <=36" -#: py/objstr.c -msgid "integer required" -msgstr "entier requis" - #: extmod/ulab/code/numpy/approx.c msgid "interp is defined for 1D iterables of equal length" msgstr "" @@ -3479,10 +3442,6 @@ msgstr "interval doit être dans la portée %s-%s" msgid "invalid architecture" msgstr "architecture invalide" -#: lib/netutils/netutils.c -msgid "invalid arguments" -msgstr "arguments invalides" - #: shared-bindings/bitmaptools/__init__.c #, c-format msgid "invalid bits_per_pixel %d, must be, 1, 2, 4, 8, 16, 24, or 32" @@ -3539,7 +3498,7 @@ msgstr "syntaxe invalide pour un entier de base %d" msgid "invalid syntax for number" msgstr "syntaxe invalide pour un nombre" -#: py/objexcept.c shared-bindings/traceback/__init__.c +#: py/objexcept.c msgid "invalid traceback" msgstr "" @@ -4028,11 +3987,13 @@ 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_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_nopsram/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/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 @@ -4051,6 +4012,8 @@ msgstr "pow() avec 3 arguments nécessite des entiers" #: 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 @@ -4094,8 +4057,8 @@ msgid "queue overflow" msgstr "dépassement de file" #: py/parse.c -msgid "raw f-strings are not implemented" -msgstr "les chaînes f brutes ne sont pas implémentées" +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" @@ -4157,7 +4120,7 @@ msgstr "taux d'échantillonage hors bornes" msgid "schedule queue full" msgstr "file de schédule pleine" -#: lib/utils/pyexec.c py/builtinimport.c +#: py/builtinimport.c msgid "script compilation not supported" msgstr "compilation de script non supportée" @@ -4306,6 +4269,7 @@ msgstr "tile doit être plus que zéro" msgid "time.struct_time() takes a 9-sequence" msgstr "time.struct_time() prend une séquence de longueur 9" +#: 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 @@ -4434,8 +4398,8 @@ msgid "unicode name escapes" msgstr "échappements de nom unicode" #: py/parse.c -msgid "unindent does not match any outer indentation level" -msgstr "la désindentation ne correspond à aucune indentation précédente" +msgid "unindent doesn't match any outer indent level" +msgstr "" #: py/objstr.c #, c-format @@ -4588,6 +4552,89 @@ 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)" +#, c-format +#~ msgid "" +#~ "Welcome to Adafruit CircuitPython %s!\n" +#~ "\n" +#~ "Please visit learn.adafruit.com/category/circuitpython for project " +#~ "guides.\n" +#~ "\n" +#~ "To list built-in modules please do `help(\"modules\")`.\n" +#~ msgstr "" +#~ "Bienvenue sur Adafruit CircuitPython %s !\n" +#~ "\n" +#~ "Visitez learn.adafruit.com/category/circuitpython pour les guides.\n" +#~ "\n" +#~ "Pour lister les modules inclus, tapez `help(\"modules\")`.\n" + +#~ msgid "integer required" +#~ msgstr "entier requis" + +#~ msgid "abort() called" +#~ msgstr "abort() appelé" + +#~ msgid "f-string expression part cannot include a '#'" +#~ msgstr "La partie d'expression de chaîne f ne peut pas inclure de '#'" + +#~ msgid "f-string expression part cannot include a backslash" +#~ msgstr "" +#~ "La partie d'expression de chaîne f ne peut pas inclure de barre oblique " +#~ "inverse" + +#~ msgid "f-string: empty expression not allowed" +#~ msgstr "f-string : expression vide non autorisée" + +#~ msgid "f-string: expecting '}'" +#~ msgstr "f-string : attend '}'" + +#~ msgid "f-string: single '}' is not allowed" +#~ msgstr "f-string : single '}' n'est pas autorisé" + +#~ msgid "invalid arguments" +#~ msgstr "arguments invalides" + +#~ msgid "raw f-strings are not implemented" +#~ msgstr "les chaînes f brutes ne sont pas implémentées" + +#~ msgid "unindent does not match any outer indentation level" +#~ msgstr "la désindentation ne correspond à aucune indentation précédente" + +#~ msgid "%q list must be a list" +#~ msgstr "La liste %q doit être une liste" + +#~ msgid "%q must of type %q" +#~ msgstr "%q doit être de type %q" + +#~ msgid "Column entry must be digitalio.DigitalInOut" +#~ msgstr "L'entrée 'Column' doit être un digitalio.DigitalInOut" + +#~ msgid "Expected a Characteristic" +#~ msgstr "Une 'Characteristic' est attendue" + +#~ msgid "Expected a DigitalInOut" +#~ msgstr "Un 'DigitalInOut' est attendu" + +#~ msgid "Expected a Service" +#~ msgstr "Un Service est attendu" + +#~ msgid "Expected a UART" +#~ msgstr "Un UART est attendu" + +#~ msgid "Expected a UUID" +#~ msgstr "Un UUID est attendu" + +#~ msgid "Expected an Address" +#~ msgstr "Un Address est attendu" + +#~ msgid "Row entry must be digitalio.DigitalInOut" +#~ msgstr "L'entrée de ligne 'Row' doit être un digitalio.DigitalInOut" + +#~ msgid "buttons must be digitalio.DigitalInOut" +#~ msgstr "les boutons doivent être des digitalio.DigitalInOut" + +#~ msgid "Invalid frequency" +#~ msgstr "Fréquence non valide" + #~ msgid "Data 0 pin must be byte aligned." #~ msgstr "La broche Data 0 doit être aligné sur l'octet." diff --git a/locale/hi.po b/locale/hi.po index 3769cdbb7f..b585507a3b 100644 --- a/locale/hi.po +++ b/locale/hi.po @@ -103,10 +103,6 @@ msgstr "" msgid "%q length must be >= 1" msgstr "" -#: shared-bindings/vectorio/Polygon.c -msgid "%q list must be a list" -msgstr "" - #: py/argcheck.c msgid "%q must <= %d" msgstr "" @@ -144,12 +140,12 @@ msgstr "" msgid "%q must be between %d and %d" msgstr "" -#: ports/atmel-samd/common-hal/busio/UART.c -msgid "%q must be power of 2" +#: py/argcheck.c +msgid "%q must be of type %q" msgstr "" -#: py/argcheck.c -msgid "%q must of type %q" +#: ports/atmel-samd/common-hal/busio/UART.c +msgid "%q must be power of 2" msgstr "" #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c @@ -165,6 +161,10 @@ msgstr "" msgid "%q should be an int" msgstr "" +#: shared-bindings/usb_hid/Device.c +msgid "%q with a report ID of 0 must be of length 1" +msgstr "" + #: py/bc.c py/objnamedtuple.c msgid "%q() takes %d positional arguments but %d were given" msgstr "" @@ -347,6 +347,7 @@ msgstr "" msgid "64 bit types" msgstr "" +#: 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" @@ -369,7 +370,9 @@ msgstr "" msgid "All CAN peripherals are in use" msgstr "" -#: ports/espressif/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c +#: 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 "" @@ -549,6 +552,10 @@ msgstr "" msgid "Bit depth must be multiple of 8." 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 "" @@ -619,6 +626,10 @@ msgstr "" 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 @@ -777,10 +788,6 @@ msgstr "" msgid "Clock unit in use" msgstr "" -#: shared-bindings/_pew/PewPew.c -msgid "Column entry must be digitalio.DigitalInOut" -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" @@ -956,36 +963,9 @@ msgstr "" #: 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 -#: shared-bindings/terminalio/Terminal.c msgid "Expected a %q" msgstr "" -#: shared-bindings/_bleio/CharacteristicBuffer.c -#: shared-bindings/_bleio/Descriptor.c shared-bindings/_bleio/PacketBuffer.c -msgid "Expected a Characteristic" -msgstr "" - -#: shared-bindings/_bleio/Adapter.c -msgid "Expected a DigitalInOut" -msgstr "" - -#: shared-bindings/_bleio/Characteristic.c -msgid "Expected a Service" -msgstr "" - -#: shared-bindings/_bleio/Adapter.c -msgid "Expected a UART" -msgstr "" - -#: shared-bindings/_bleio/Characteristic.c shared-bindings/_bleio/Descriptor.c -#: shared-bindings/_bleio/Service.c -msgid "Expected a UUID" -msgstr "" - -#: shared-bindings/_bleio/Adapter.c -msgid "Expected an Address" -msgstr "" - #: shared-bindings/alarm/__init__.c msgid "Expected an alarm" msgstr "" @@ -1301,8 +1281,11 @@ msgstr "" msgid "Invalid Pin" msgstr "" -#: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c -#: py/moduerrno.c shared-module/rgbmatrix/RGBMatrix.c +#: 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 "" @@ -1350,10 +1333,6 @@ msgstr "" msgid "Invalid format chunk size" msgstr "" -#: ports/espressif/common-hal/busio/I2C.c -msgid "Invalid frequency" -msgstr "" - #: supervisor/shared/safe_mode.c msgid "Invalid memory access." msgstr "" @@ -1394,6 +1373,7 @@ msgstr "" #: 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 @@ -1612,6 +1592,10 @@ msgstr "" 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 "" @@ -1632,6 +1616,7 @@ msgstr "" 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" @@ -1771,6 +1756,11 @@ msgstr "" 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 @@ -1841,6 +1831,7 @@ msgstr "" 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 "" @@ -1890,10 +1881,13 @@ msgid "" msgstr "" #: ports/raspberrypi/common-hal/imagecapture/ParallelImageCapture.c -#: ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.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 "" @@ -1942,6 +1936,7 @@ msgstr "" 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 "" @@ -2019,10 +2014,6 @@ msgstr "" msgid "Right channel unsupported" msgstr "" -#: shared-bindings/_pew/PewPew.c -msgid "Row entry must be digitalio.DigitalInOut" -msgstr "" - #: main.c msgid "Running in safe mode! Not running saved code.\n" msgstr "" @@ -2091,6 +2082,7 @@ msgstr "" 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 "" @@ -2193,6 +2185,10 @@ msgstr "" 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 " @@ -2245,6 +2241,7 @@ msgstr "" 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" @@ -2435,6 +2432,7 @@ msgstr "" 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" @@ -2461,9 +2459,9 @@ msgstr "" msgid "" "Welcome to Adafruit CircuitPython %s!\n" "\n" -"Please visit learn.adafruit.com/category/circuitpython for project guides.\n" +"Visit circuitpython.org for more information.\n" "\n" -"To list built-in modules please do `help(\"modules\")`.\n" +"To list built-in modules type `help(\"modules\")`.\n" msgstr "" #: shared-bindings/wifi/Radio.c @@ -2507,10 +2505,6 @@ msgstr "" msgid "a bytes-like object is required" msgstr "" -#: lib/embed/abort_.c -msgid "abort() called" -msgstr "" - #: shared-bindings/i2cperipheral/I2CPeripheral.c msgid "address out of bounds" msgstr "" @@ -2658,10 +2652,6 @@ msgstr "" msgid "buffer too small for requested bytes" msgstr "" -#: shared-bindings/_pew/PewPew.c -msgid "buttons must be digitalio.DigitalInOut" -msgstr "" - #: shared-bindings/adafruit_pixelbuf/PixelBuf.c msgid "byteorder is not a string" msgstr "" @@ -3010,6 +3000,10 @@ msgstr "" msgid "division by zero" msgstr "" +#: ports/espressif/common-hal/rotaryio/IncrementalEncoder.c +msgid "divisor must be 4" +msgstr "" + #: py/objdeque.c msgid "empty" msgstr "" @@ -3091,26 +3085,6 @@ msgstr "" msgid "extra positional arguments given" msgstr "" -#: py/parse.c -msgid "f-string expression part cannot include a '#'" -msgstr "" - -#: py/parse.c -msgid "f-string expression part cannot include a backslash" -msgstr "" - -#: py/parse.c -msgid "f-string: empty expression not allowed" -msgstr "" - -#: py/parse.c -msgid "f-string: expecting '}'" -msgstr "" - -#: py/parse.c -msgid "f-string: single '}' is not allowed" -msgstr "" - #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c #: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c msgid "file must be a file opened in byte mode" @@ -3371,10 +3345,6 @@ msgstr "" msgid "int() arg 2 must be >= 2 and <= 36" msgstr "" -#: py/objstr.c -msgid "integer required" -msgstr "" - #: extmod/ulab/code/numpy/approx.c msgid "interp is defined for 1D iterables of equal length" msgstr "" @@ -3388,10 +3358,6 @@ msgstr "" msgid "invalid architecture" msgstr "" -#: lib/netutils/netutils.c -msgid "invalid arguments" -msgstr "" - #: shared-bindings/bitmaptools/__init__.c #, c-format msgid "invalid bits_per_pixel %d, must be, 1, 2, 4, 8, 16, 24, or 32" @@ -3448,7 +3414,7 @@ msgstr "" msgid "invalid syntax for number" msgstr "" -#: py/objexcept.c shared-bindings/traceback/__init__.c +#: py/objexcept.c msgid "invalid traceback" msgstr "" @@ -3928,11 +3894,13 @@ msgstr "" msgid "pow() with 3 arguments requires integers" msgstr "" +#: ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_nopsram/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/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 @@ -3951,6 +3919,8 @@ msgstr "" #: 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 @@ -3994,7 +3964,7 @@ msgid "queue overflow" msgstr "" #: py/parse.c -msgid "raw f-strings are not implemented" +msgid "raw f-strings are not supported" msgstr "" #: extmod/ulab/code/numpy/fft/fft_tools.c @@ -4055,7 +4025,7 @@ msgstr "" msgid "schedule queue full" msgstr "" -#: lib/utils/pyexec.c py/builtinimport.c +#: py/builtinimport.c msgid "script compilation not supported" msgstr "" @@ -4203,6 +4173,7 @@ msgstr "" 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 @@ -4331,7 +4302,7 @@ msgid "unicode name escapes" msgstr "" #: py/parse.c -msgid "unindent does not match any outer indentation level" +msgid "unindent doesn't match any outer indent level" msgstr "" #: py/objstr.c diff --git a/locale/it_IT.po b/locale/it_IT.po index 6d8485747b..86fda99477 100644 --- a/locale/it_IT.po +++ b/locale/it_IT.po @@ -112,10 +112,6 @@ msgstr "" msgid "%q length must be >= 1" msgstr "" -#: shared-bindings/vectorio/Polygon.c -msgid "%q list must be a list" -msgstr "lista %q deve essere una lista" - #: py/argcheck.c msgid "%q must <= %d" msgstr "" @@ -154,12 +150,12 @@ msgstr "%q deve essere una tupla di lunghezza 2" msgid "%q must be between %d and %d" msgstr "" -#: ports/atmel-samd/common-hal/busio/UART.c -msgid "%q must be power of 2" +#: py/argcheck.c +msgid "%q must be of type %q" msgstr "" -#: py/argcheck.c -msgid "%q must of type %q" +#: ports/atmel-samd/common-hal/busio/UART.c +msgid "%q must be power of 2" msgstr "" #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c @@ -175,6 +171,10 @@ msgstr "%q pin non valido" msgid "%q should be an int" msgstr "%q dovrebbe essere un int" +#: shared-bindings/usb_hid/Device.c +msgid "%q with a report ID of 0 must be of length 1" +msgstr "" + #: py/bc.c py/objnamedtuple.c msgid "%q() takes %d positional arguments but %d were given" msgstr "%q() prende %d argomenti posizionali ma ne sono stati forniti %d" @@ -358,6 +358,7 @@ msgstr "pow() con tre argmomenti non supportata" msgid "64 bit types" msgstr "Tipo 64 bits" +#: 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" @@ -380,7 +381,9 @@ msgstr "Tipo di indirizzo fuori intervallo" msgid "All CAN peripherals are in use" msgstr "Tutte le periferiche CAN sono in uso" -#: ports/espressif/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c +#: 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 "Tutte le periferiche I2C sono in uso" @@ -564,6 +567,10 @@ msgstr "La profondità dei bit deve essere inclusiva da 1 a 6, non %d" msgid "Bit depth must be multiple of 8." msgstr "La profondità di bit deve essere un multiplo di 8." +#: 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 "Sia RX che TX richiedono il controllo del flow" @@ -634,6 +641,10 @@ msgstr "Il buffer deve essere lungo almeno 1" msgid "Buffer too short by %d bytes" msgstr "Buffer troppo piccolo di %d bytes" +#: 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 @@ -794,10 +805,6 @@ msgstr "Orologio e troppo allungato" msgid "Clock unit in use" msgstr "Unità di clock in uso" -#: shared-bindings/_pew/PewPew.c -msgid "Column entry must be digitalio.DigitalInOut" -msgstr "" - #: shared-bindings/displayio/FourWire.c shared-bindings/displayio/I2CDisplay.c #: shared-bindings/paralleldisplay/ParallelBus.c #, fuzzy @@ -976,38 +983,9 @@ msgstr "" #: 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 -#: shared-bindings/terminalio/Terminal.c msgid "Expected a %q" msgstr "Atteso un %q" -#: shared-bindings/_bleio/CharacteristicBuffer.c -#: shared-bindings/_bleio/Descriptor.c shared-bindings/_bleio/PacketBuffer.c -#, fuzzy -msgid "Expected a Characteristic" -msgstr "Non è possibile aggiungere Characteristic." - -#: shared-bindings/_bleio/Adapter.c -msgid "Expected a DigitalInOut" -msgstr "" - -#: shared-bindings/_bleio/Characteristic.c -msgid "Expected a Service" -msgstr "" - -#: shared-bindings/_bleio/Adapter.c -msgid "Expected a UART" -msgstr "" - -#: shared-bindings/_bleio/Characteristic.c shared-bindings/_bleio/Descriptor.c -#: shared-bindings/_bleio/Service.c -#, fuzzy -msgid "Expected a UUID" -msgstr "Atteso un %q" - -#: shared-bindings/_bleio/Adapter.c -msgid "Expected an Address" -msgstr "" - #: shared-bindings/alarm/__init__.c msgid "Expected an alarm" msgstr "" @@ -1325,8 +1303,11 @@ msgstr "Frequenza PWM non valida" msgid "Invalid Pin" msgstr "" -#: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c -#: py/moduerrno.c shared-module/rgbmatrix/RGBMatrix.c +#: 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 "Argomento non valido" @@ -1376,10 +1357,6 @@ msgstr "File non valido" msgid "Invalid format chunk size" msgstr "" -#: ports/espressif/common-hal/busio/I2C.c -msgid "Invalid frequency" -msgstr "" - #: supervisor/shared/safe_mode.c msgid "Invalid memory access." msgstr "" @@ -1420,6 +1397,7 @@ msgstr "Pin non valido per il canale destro" #: 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 @@ -1640,6 +1618,10 @@ msgstr "Nessun pin TX" msgid "No available clocks" msgstr "Nessun orologio a disposizione" +#: 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 "" @@ -1660,6 +1642,7 @@ msgstr "Nessun generatore hardware di numeri casuali disponibile" 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" @@ -1803,6 +1786,11 @@ msgstr "" 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 @@ -1878,6 +1866,7 @@ msgstr "" msgid "Permission denied" msgstr "Permesso negato" +#: 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 "" @@ -1927,10 +1916,13 @@ msgid "" msgstr "" #: ports/raspberrypi/common-hal/imagecapture/ParallelImageCapture.c -#: ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.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 "" @@ -1980,6 +1972,7 @@ msgstr "" 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 "" @@ -2058,10 +2051,6 @@ msgstr "" msgid "Right channel unsupported" msgstr "Canale destro non supportato" -#: shared-bindings/_pew/PewPew.c -msgid "Row entry must be digitalio.DigitalInOut" -msgstr "" - #: main.c msgid "Running in safe mode! Not running saved code.\n" msgstr "Modalità sicura in esecuzione! Codice salvato non in esecuzione.\n" @@ -2132,6 +2121,7 @@ msgstr "" 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 "" @@ -2234,6 +2224,10 @@ msgstr "" 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 " @@ -2286,6 +2280,7 @@ msgstr "Troppi schermi" 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" @@ -2478,6 +2473,7 @@ msgstr "" msgid "WARNING: Your code filename has two extensions\n" msgstr "ATTENZIONE: Il nome del sorgente ha due estensioni\n" +#: 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" @@ -2504,9 +2500,9 @@ msgstr "" msgid "" "Welcome to Adafruit CircuitPython %s!\n" "\n" -"Please visit learn.adafruit.com/category/circuitpython for project guides.\n" +"Visit circuitpython.org for more information.\n" "\n" -"To list built-in modules please do `help(\"modules\")`.\n" +"To list built-in modules type `help(\"modules\")`.\n" msgstr "" #: shared-bindings/wifi/Radio.c @@ -2550,10 +2546,6 @@ msgstr "" msgid "a bytes-like object is required" msgstr "un oggetto byte-like è richiesto" -#: lib/embed/abort_.c -msgid "abort() called" -msgstr "abort() chiamato" - #: shared-bindings/i2cperipheral/I2CPeripheral.c msgid "address out of bounds" msgstr "indirizzo fuori limite" @@ -2704,10 +2696,6 @@ msgstr "buffer troppo piccolo" msgid "buffer too small for requested bytes" msgstr "" -#: shared-bindings/_pew/PewPew.c -msgid "buttons must be digitalio.DigitalInOut" -msgstr "" - #: shared-bindings/adafruit_pixelbuf/PixelBuf.c msgid "byteorder is not a string" msgstr "" @@ -3062,6 +3050,10 @@ msgstr "" msgid "division by zero" msgstr "divisione per zero" +#: ports/espressif/common-hal/rotaryio/IncrementalEncoder.c +msgid "divisor must be 4" +msgstr "" + #: py/objdeque.c msgid "empty" msgstr "vuoto" @@ -3144,26 +3136,6 @@ msgstr "argomento nominato aggiuntivo fornito" msgid "extra positional arguments given" msgstr "argomenti posizonali extra dati" -#: py/parse.c -msgid "f-string expression part cannot include a '#'" -msgstr "" - -#: py/parse.c -msgid "f-string expression part cannot include a backslash" -msgstr "" - -#: py/parse.c -msgid "f-string: empty expression not allowed" -msgstr "" - -#: py/parse.c -msgid "f-string: expecting '}'" -msgstr "" - -#: py/parse.c -msgid "f-string: single '}' is not allowed" -msgstr "" - #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c #: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c msgid "file must be a file opened in byte mode" @@ -3425,10 +3397,6 @@ msgstr "" msgid "int() arg 2 must be >= 2 and <= 36" msgstr "il secondo argomanto di int() deve essere >= 2 e <= 36" -#: py/objstr.c -msgid "integer required" -msgstr "intero richiesto" - #: extmod/ulab/code/numpy/approx.c msgid "interp is defined for 1D iterables of equal length" msgstr "" @@ -3442,10 +3410,6 @@ msgstr "" msgid "invalid architecture" msgstr "" -#: lib/netutils/netutils.c -msgid "invalid arguments" -msgstr "argomenti non validi" - #: shared-bindings/bitmaptools/__init__.c #, c-format msgid "invalid bits_per_pixel %d, must be, 1, 2, 4, 8, 16, 24, or 32" @@ -3502,7 +3466,7 @@ msgstr "sintassi invalida per l'intero con base %d" msgid "invalid syntax for number" msgstr "sintassi invalida per il numero" -#: py/objexcept.c shared-bindings/traceback/__init__.c +#: py/objexcept.c msgid "invalid traceback" msgstr "" @@ -3993,11 +3957,13 @@ 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_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_nopsram/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/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 @@ -4016,6 +3982,8 @@ msgstr "pow() con 3 argomenti richiede interi" #: 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 @@ -4059,7 +4027,7 @@ msgid "queue overflow" msgstr "overflow della coda" #: py/parse.c -msgid "raw f-strings are not implemented" +msgid "raw f-strings are not supported" msgstr "" #: extmod/ulab/code/numpy/fft/fft_tools.c @@ -4122,7 +4090,7 @@ msgstr "frequenza di campionamento fuori intervallo" msgid "schedule queue full" msgstr "" -#: lib/utils/pyexec.c py/builtinimport.c +#: py/builtinimport.c msgid "script compilation not supported" msgstr "compilazione dello scrip non suportata" @@ -4271,6 +4239,7 @@ msgstr "" 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 @@ -4400,7 +4369,7 @@ msgid "unicode name escapes" msgstr "" #: py/parse.c -msgid "unindent does not match any outer indentation level" +msgid "unindent doesn't match any outer indent level" msgstr "" #: py/objstr.c @@ -4556,6 +4525,26 @@ msgstr "" msgid "zi must be of shape (n_section, 2)" msgstr "" +#~ msgid "integer required" +#~ msgstr "intero richiesto" + +#~ msgid "abort() called" +#~ msgstr "abort() chiamato" + +#~ msgid "invalid arguments" +#~ msgstr "argomenti non validi" + +#~ msgid "%q list must be a list" +#~ msgstr "lista %q deve essere una lista" + +#, fuzzy +#~ msgid "Expected a Characteristic" +#~ msgstr "Non è possibile aggiungere Characteristic." + +#, fuzzy +#~ msgid "Expected a UUID" +#~ msgstr "Atteso un %q" + #, fuzzy #~ msgid "no available NIC" #~ msgstr "busio.UART non ancora implementato" diff --git a/locale/ja.po b/locale/ja.po index 4f570cf418..6e1f3454ae 100644 --- a/locale/ja.po +++ b/locale/ja.po @@ -108,10 +108,6 @@ msgstr "" msgid "%q length must be >= 1" msgstr "" -#: shared-bindings/vectorio/Polygon.c -msgid "%q list must be a list" -msgstr "%q リストはリストでなければなりません" - #: py/argcheck.c msgid "%q must <= %d" msgstr "" @@ -149,12 +145,12 @@ msgstr "%qは長さ2のタプルでなければなりません" msgid "%q must be between %d and %d" msgstr "" -#: ports/atmel-samd/common-hal/busio/UART.c -msgid "%q must be power of 2" +#: py/argcheck.c +msgid "%q must be of type %q" msgstr "" -#: py/argcheck.c -msgid "%q must of type %q" +#: ports/atmel-samd/common-hal/busio/UART.c +msgid "%q must be power of 2" msgstr "" #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c @@ -170,6 +166,10 @@ msgstr "%q ピンは無効" msgid "%q should be an int" msgstr "%qはint型でなければなりません" +#: shared-bindings/usb_hid/Device.c +msgid "%q with a report ID of 0 must be of length 1" +msgstr "" + #: py/bc.c py/objnamedtuple.c msgid "%q() takes %d positional arguments but %d were given" msgstr "%q() は %d 個の位置引数を取りますが、%d 個与えられました" @@ -352,6 +352,7 @@ msgstr "引数3つのpow()は非対応" msgid "64 bit types" msgstr "" +#: 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" @@ -374,7 +375,9 @@ msgstr "address_typeが範囲外" msgid "All CAN peripherals are in use" msgstr "全てのCAN周辺機器が使用中" -#: ports/espressif/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c +#: 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 "全てのI2C周辺機器が使用中" @@ -556,6 +559,10 @@ msgstr "" msgid "Bit depth must be multiple of 8." msgstr "ビット深度は8の倍数でなければなりません" +#: 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 "フロー制御のためRXとTXの両方が必要" @@ -626,6 +633,10 @@ msgstr "バッファ長は少なくとも1以上でなければなりません" msgid "Buffer too short by %d bytes" msgstr "バッファが %d バイト足りません" +#: 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 @@ -786,10 +797,6 @@ msgstr "クロックのストレッチが長すぎ" msgid "Clock unit in use" msgstr "クロックユニットは使用中" -#: shared-bindings/_pew/PewPew.c -msgid "Column entry must be digitalio.DigitalInOut" -msgstr "Columnの要素は digitalio.DigitalInOut でなければなりません" - #: 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" @@ -965,36 +972,9 @@ msgstr "" #: 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 -#: shared-bindings/terminalio/Terminal.c msgid "Expected a %q" msgstr "%qが必要" -#: shared-bindings/_bleio/CharacteristicBuffer.c -#: shared-bindings/_bleio/Descriptor.c shared-bindings/_bleio/PacketBuffer.c -msgid "Expected a Characteristic" -msgstr "Characteristicが必要" - -#: shared-bindings/_bleio/Adapter.c -msgid "Expected a DigitalInOut" -msgstr "DigitalInOutが必要" - -#: shared-bindings/_bleio/Characteristic.c -msgid "Expected a Service" -msgstr "Serviceが必要" - -#: shared-bindings/_bleio/Adapter.c -msgid "Expected a UART" -msgstr "UARTが必要" - -#: shared-bindings/_bleio/Characteristic.c shared-bindings/_bleio/Descriptor.c -#: shared-bindings/_bleio/Service.c -msgid "Expected a UUID" -msgstr "UUIDが必要" - -#: shared-bindings/_bleio/Adapter.c -msgid "Expected an Address" -msgstr "Addressが必要" - #: shared-bindings/alarm/__init__.c msgid "Expected an alarm" msgstr "" @@ -1312,8 +1292,11 @@ msgstr "無効なPWM周波数" msgid "Invalid Pin" msgstr "" -#: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c -#: py/moduerrno.c shared-module/rgbmatrix/RGBMatrix.c +#: 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 "不正な引数" @@ -1361,10 +1344,6 @@ msgstr "不正なファイル" msgid "Invalid format chunk size" msgstr "フォーマットチャンクのサイズが不正" -#: ports/espressif/common-hal/busio/I2C.c -msgid "Invalid frequency" -msgstr "不正な周波数" - #: supervisor/shared/safe_mode.c msgid "Invalid memory access." msgstr "不正なメモリアクセス" @@ -1405,6 +1384,7 @@ msgstr "右チャネルのピンが不正" #: 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 @@ -1623,6 +1603,10 @@ msgstr "TXピンがありません" 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 "接続なし: 長さが決定できません" @@ -1643,6 +1627,7 @@ msgstr "利用可能なハードウェア乱数なし" msgid "No hardware support on clk pin" 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" @@ -1784,6 +1769,11 @@ msgstr "" 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 @@ -1855,6 +1845,7 @@ msgstr "" 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 "" @@ -1904,10 +1895,13 @@ msgid "" msgstr "" #: ports/raspberrypi/common-hal/imagecapture/ParallelImageCapture.c -#: ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.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 "" @@ -1956,6 +1950,7 @@ msgstr "" msgid "Pull not used when direction is output." msgstr "方向がoutputのときpullは使われません" +#: ports/atmel-samd/common-hal/watchdog/WatchDogTimer.c #: ports/raspberrypi/common-hal/watchdog/WatchDogTimer.c msgid "RAISE mode is not implemented" msgstr "" @@ -2033,10 +2028,6 @@ msgstr "" msgid "Right channel unsupported" msgstr "右チャネルは非対応" -#: shared-bindings/_pew/PewPew.c -msgid "Row entry must be digitalio.DigitalInOut" -msgstr "Rowの各要素は digitalio.DigitalInOut でなければなりません" - #: main.c msgid "Running in safe mode! Not running saved code.\n" msgstr "セーフモードで実行中! 保存されたコードは実行していません。\n" @@ -2105,6 +2096,7 @@ msgstr "" 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 "" @@ -2207,6 +2199,10 @@ msgstr "サンプルレートがサンプルとミキサーで一致しません 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 " @@ -2259,6 +2255,7 @@ msgstr "" 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" @@ -2450,6 +2447,7 @@ msgstr "電圧読み取りがタイムアウト" 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" @@ -2476,9 +2474,9 @@ msgstr "" msgid "" "Welcome to Adafruit CircuitPython %s!\n" "\n" -"Please visit learn.adafruit.com/category/circuitpython for project guides.\n" +"Visit circuitpython.org for more information.\n" "\n" -"To list built-in modules please do `help(\"modules\")`.\n" +"To list built-in modules type `help(\"modules\")`.\n" msgstr "" #: shared-bindings/wifi/Radio.c @@ -2522,10 +2520,6 @@ msgstr "__new__の引数はユーザ型でなければなりません" msgid "a bytes-like object is required" msgstr "bytes-likeオブジェクトが必要" -#: lib/embed/abort_.c -msgid "abort() called" -msgstr "abort()が呼ばれました" - #: shared-bindings/i2cperipheral/I2CPeripheral.c msgid "address out of bounds" msgstr "アドレスが範囲外" @@ -2673,10 +2667,6 @@ msgstr "" msgid "buffer too small for requested bytes" msgstr "" -#: shared-bindings/_pew/PewPew.c -msgid "buttons must be digitalio.DigitalInOut" -msgstr "buttonsはdigitalio.DigitalInOutでなければなりません" - #: shared-bindings/adafruit_pixelbuf/PixelBuf.c msgid "byteorder is not a string" msgstr "byteorderが文字列ではありません" @@ -3029,6 +3019,10 @@ msgstr "" msgid "division by zero" msgstr "ゼロ除算 (division by zero)" +#: ports/espressif/common-hal/rotaryio/IncrementalEncoder.c +msgid "divisor must be 4" +msgstr "" + #: py/objdeque.c msgid "empty" msgstr "" @@ -3110,26 +3104,6 @@ msgstr "余分なキーワード引数があります" msgid "extra positional arguments given" msgstr "余分な位置引数が与えられました" -#: py/parse.c -msgid "f-string expression part cannot include a '#'" -msgstr "f-文字列の表現部は '#' を持てません" - -#: py/parse.c -msgid "f-string expression part cannot include a backslash" -msgstr "f-文字列の表現部はバックスラッシュを持てません" - -#: py/parse.c -msgid "f-string: empty expression not allowed" -msgstr "f-文字列: 空の表現は許されません" - -#: py/parse.c -msgid "f-string: expecting '}'" -msgstr "f-string: '}'が必要" - -#: py/parse.c -msgid "f-string: single '}' is not allowed" -msgstr "f-string: 1つだけの'}'は許されません" - #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c #: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c msgid "file must be a file opened in byte mode" @@ -3391,10 +3365,6 @@ msgstr "" msgid "int() arg 2 must be >= 2 and <= 36" msgstr "int()の第2引数は2以上36以下でなければなりません" -#: py/objstr.c -msgid "integer required" -msgstr "整数が必要" - #: extmod/ulab/code/numpy/approx.c msgid "interp is defined for 1D iterables of equal length" msgstr "" @@ -3408,10 +3378,6 @@ msgstr "intervalは%s-%sの範囲でなければなりません" msgid "invalid architecture" msgstr "" -#: lib/netutils/netutils.c -msgid "invalid arguments" -msgstr "不正な引数" - #: shared-bindings/bitmaptools/__init__.c #, c-format msgid "invalid bits_per_pixel %d, must be, 1, 2, 4, 8, 16, 24, or 32" @@ -3468,7 +3434,7 @@ msgstr "" msgid "invalid syntax for number" msgstr "数字として不正な構文" -#: py/objexcept.c shared-bindings/traceback/__init__.c +#: py/objexcept.c msgid "invalid traceback" msgstr "" @@ -3950,11 +3916,13 @@ msgstr "pow()の3つ目の引数は0にできません" msgid "pow() with 3 arguments requires integers" msgstr "pow()の第3引数には整数が必要" +#: ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_nopsram/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/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 @@ -3973,6 +3941,8 @@ msgstr "pow()の第3引数には整数が必要" #: 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 @@ -4016,8 +3986,8 @@ msgid "queue overflow" msgstr "キューがオーバーフローしました" #: py/parse.c -msgid "raw f-strings are not implemented" -msgstr "raw f-文字列は実装されていません" +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" @@ -4078,7 +4048,7 @@ msgstr "サンプリングレートが範囲外" msgid "schedule queue full" msgstr "" -#: lib/utils/pyexec.c py/builtinimport.c +#: py/builtinimport.c msgid "script compilation not supported" msgstr "スクリプトのコンパイルは非対応" @@ -4226,6 +4196,7 @@ msgstr "" msgid "time.struct_time() takes a 9-sequence" msgstr "time.struct_time()は9要素のシーケンスを受け取ります" +#: 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 @@ -4354,8 +4325,8 @@ msgid "unicode name escapes" msgstr "" #: py/parse.c -msgid "unindent does not match any outer indentation level" -msgstr "インデントの解除が、外側のどのインデントにも一致していません" +msgid "unindent doesn't match any outer indent level" +msgstr "" #: py/objstr.c #, c-format @@ -4508,6 +4479,69 @@ msgstr "ziはfloat値でなければなりません" msgid "zi must be of shape (n_section, 2)" msgstr "" +#~ msgid "integer required" +#~ msgstr "整数が必要" + +#~ msgid "abort() called" +#~ msgstr "abort()が呼ばれました" + +#~ msgid "f-string expression part cannot include a '#'" +#~ msgstr "f-文字列の表現部は '#' を持てません" + +#~ msgid "f-string expression part cannot include a backslash" +#~ msgstr "f-文字列の表現部はバックスラッシュを持てません" + +#~ msgid "f-string: empty expression not allowed" +#~ msgstr "f-文字列: 空の表現は許されません" + +#~ msgid "f-string: expecting '}'" +#~ msgstr "f-string: '}'が必要" + +#~ msgid "f-string: single '}' is not allowed" +#~ msgstr "f-string: 1つだけの'}'は許されません" + +#~ msgid "invalid arguments" +#~ msgstr "不正な引数" + +#~ msgid "raw f-strings are not implemented" +#~ msgstr "raw f-文字列は実装されていません" + +#~ msgid "unindent does not match any outer indentation level" +#~ msgstr "インデントの解除が、外側のどのインデントにも一致していません" + +#~ msgid "%q list must be a list" +#~ msgstr "%q リストはリストでなければなりません" + +#~ msgid "Column entry must be digitalio.DigitalInOut" +#~ msgstr "Columnの要素は digitalio.DigitalInOut でなければなりません" + +#~ msgid "Expected a Characteristic" +#~ msgstr "Characteristicが必要" + +#~ msgid "Expected a DigitalInOut" +#~ msgstr "DigitalInOutが必要" + +#~ msgid "Expected a Service" +#~ msgstr "Serviceが必要" + +#~ msgid "Expected a UART" +#~ msgstr "UARTが必要" + +#~ msgid "Expected a UUID" +#~ msgstr "UUIDが必要" + +#~ msgid "Expected an Address" +#~ msgstr "Addressが必要" + +#~ msgid "Row entry must be digitalio.DigitalInOut" +#~ msgstr "Rowの各要素は digitalio.DigitalInOut でなければなりません" + +#~ msgid "buttons must be digitalio.DigitalInOut" +#~ msgstr "buttonsはdigitalio.DigitalInOutでなければなりません" + +#~ msgid "Invalid frequency" +#~ msgstr "不正な周波数" + #~ msgid "ParallelBus not yet supported" #~ msgstr "ParallelBusにはまだ対応していません" diff --git a/locale/ko.po b/locale/ko.po index 95c6ae5af9..ad4ee0a2e2 100644 --- a/locale/ko.po +++ b/locale/ko.po @@ -104,10 +104,6 @@ msgstr "" msgid "%q length must be >= 1" msgstr "" -#: shared-bindings/vectorio/Polygon.c -msgid "%q list must be a list" -msgstr "" - #: py/argcheck.c msgid "%q must <= %d" msgstr "" @@ -145,12 +141,12 @@ msgstr "" msgid "%q must be between %d and %d" msgstr "" -#: ports/atmel-samd/common-hal/busio/UART.c -msgid "%q must be power of 2" +#: py/argcheck.c +msgid "%q must be of type %q" msgstr "" -#: py/argcheck.c -msgid "%q must of type %q" +#: ports/atmel-samd/common-hal/busio/UART.c +msgid "%q must be power of 2" msgstr "" #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c @@ -166,6 +162,10 @@ msgstr "" msgid "%q should be an int" msgstr "%q 는 정수(int) 여야합니다" +#: shared-bindings/usb_hid/Device.c +msgid "%q with a report ID of 0 must be of length 1" +msgstr "" + #: py/bc.c py/objnamedtuple.c msgid "%q() takes %d positional arguments but %d were given" msgstr "" @@ -348,6 +348,7 @@ msgstr "" msgid "64 bit types" msgstr "" +#: 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" @@ -370,7 +371,9 @@ msgstr "" msgid "All CAN peripherals are in use" msgstr "" -#: ports/espressif/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c +#: 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 "사용중인 모든 I2C주변 기기" @@ -552,6 +555,10 @@ msgstr "" msgid "Bit depth must be multiple of 8." 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 "" @@ -622,6 +629,10 @@ msgstr "잘못된 크기의 버퍼. >1 여야합니다" 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 @@ -780,10 +791,6 @@ msgstr "" msgid "Clock unit in use" msgstr "" -#: shared-bindings/_pew/PewPew.c -msgid "Column entry must be digitalio.DigitalInOut" -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" @@ -959,36 +966,9 @@ msgstr "" #: 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 -#: shared-bindings/terminalio/Terminal.c msgid "Expected a %q" msgstr "%q 이 예상되었습니다." -#: shared-bindings/_bleio/CharacteristicBuffer.c -#: shared-bindings/_bleio/Descriptor.c shared-bindings/_bleio/PacketBuffer.c -msgid "Expected a Characteristic" -msgstr "특성(Characteristic)이 예상되었습니다." - -#: shared-bindings/_bleio/Adapter.c -msgid "Expected a DigitalInOut" -msgstr "" - -#: shared-bindings/_bleio/Characteristic.c -msgid "Expected a Service" -msgstr "" - -#: shared-bindings/_bleio/Adapter.c -msgid "Expected a UART" -msgstr "" - -#: shared-bindings/_bleio/Characteristic.c shared-bindings/_bleio/Descriptor.c -#: shared-bindings/_bleio/Service.c -msgid "Expected a UUID" -msgstr "UUID이 예상되었습니다." - -#: shared-bindings/_bleio/Adapter.c -msgid "Expected an Address" -msgstr "" - #: shared-bindings/alarm/__init__.c msgid "Expected an alarm" msgstr "" @@ -1304,8 +1284,11 @@ msgstr "" msgid "Invalid Pin" msgstr "" -#: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c -#: py/moduerrno.c shared-module/rgbmatrix/RGBMatrix.c +#: 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 "" @@ -1353,10 +1336,6 @@ msgstr "파일이 유효하지 않습니다" msgid "Invalid format chunk size" msgstr "형식 청크 크기가 잘못되었습니다" -#: ports/espressif/common-hal/busio/I2C.c -msgid "Invalid frequency" -msgstr "" - #: supervisor/shared/safe_mode.c msgid "Invalid memory access." msgstr "" @@ -1397,6 +1376,7 @@ msgstr "오른쪽 채널 핀이 잘못되었습니다" #: 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 @@ -1615,6 +1595,10 @@ msgstr "" 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 "" @@ -1635,6 +1619,7 @@ msgstr "" 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" @@ -1774,6 +1759,11 @@ msgstr "" 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 @@ -1844,6 +1834,7 @@ msgstr "" 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 "" @@ -1893,10 +1884,13 @@ msgid "" msgstr "" #: ports/raspberrypi/common-hal/imagecapture/ParallelImageCapture.c -#: ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.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 "" @@ -1945,6 +1939,7 @@ msgstr "" 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 "" @@ -2022,10 +2017,6 @@ msgstr "" msgid "Right channel unsupported" msgstr "" -#: shared-bindings/_pew/PewPew.c -msgid "Row entry must be digitalio.DigitalInOut" -msgstr "" - #: main.c msgid "Running in safe mode! Not running saved code.\n" msgstr "" @@ -2094,6 +2085,7 @@ msgstr "" 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 "" @@ -2196,6 +2188,10 @@ msgstr "" 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 " @@ -2248,6 +2244,7 @@ msgstr "" 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" @@ -2439,6 +2436,7 @@ msgstr "" 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" @@ -2465,9 +2463,9 @@ msgstr "" msgid "" "Welcome to Adafruit CircuitPython %s!\n" "\n" -"Please visit learn.adafruit.com/category/circuitpython for project guides.\n" +"Visit circuitpython.org for more information.\n" "\n" -"To list built-in modules please do `help(\"modules\")`.\n" +"To list built-in modules type `help(\"modules\")`.\n" msgstr "" #: shared-bindings/wifi/Radio.c @@ -2511,10 +2509,6 @@ msgstr "" msgid "a bytes-like object is required" msgstr "" -#: lib/embed/abort_.c -msgid "abort() called" -msgstr "" - #: shared-bindings/i2cperipheral/I2CPeripheral.c msgid "address out of bounds" msgstr "" @@ -2662,10 +2656,6 @@ msgstr "" msgid "buffer too small for requested bytes" msgstr "" -#: shared-bindings/_pew/PewPew.c -msgid "buttons must be digitalio.DigitalInOut" -msgstr "" - #: shared-bindings/adafruit_pixelbuf/PixelBuf.c msgid "byteorder is not a string" msgstr "" @@ -3014,6 +3004,10 @@ msgstr "" msgid "division by zero" msgstr "" +#: ports/espressif/common-hal/rotaryio/IncrementalEncoder.c +msgid "divisor must be 4" +msgstr "" + #: py/objdeque.c msgid "empty" msgstr "" @@ -3095,26 +3089,6 @@ msgstr "" msgid "extra positional arguments given" msgstr "" -#: py/parse.c -msgid "f-string expression part cannot include a '#'" -msgstr "" - -#: py/parse.c -msgid "f-string expression part cannot include a backslash" -msgstr "" - -#: py/parse.c -msgid "f-string: empty expression not allowed" -msgstr "" - -#: py/parse.c -msgid "f-string: expecting '}'" -msgstr "" - -#: py/parse.c -msgid "f-string: single '}' is not allowed" -msgstr "" - #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c #: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c msgid "file must be a file opened in byte mode" @@ -3375,10 +3349,6 @@ msgstr "" msgid "int() arg 2 must be >= 2 and <= 36" msgstr "" -#: py/objstr.c -msgid "integer required" -msgstr "정수가 필요합니다" - #: extmod/ulab/code/numpy/approx.c msgid "interp is defined for 1D iterables of equal length" msgstr "" @@ -3392,10 +3362,6 @@ msgstr "" msgid "invalid architecture" msgstr "" -#: lib/netutils/netutils.c -msgid "invalid arguments" -msgstr "" - #: shared-bindings/bitmaptools/__init__.c #, c-format msgid "invalid bits_per_pixel %d, must be, 1, 2, 4, 8, 16, 24, or 32" @@ -3452,7 +3418,7 @@ msgstr "구문(syntax)가 정수가 유효하지 않습니다" msgid "invalid syntax for number" msgstr "숫자에 대한 구문(syntax)가 유효하지 않습니다" -#: py/objexcept.c shared-bindings/traceback/__init__.c +#: py/objexcept.c msgid "invalid traceback" msgstr "" @@ -3932,11 +3898,13 @@ msgstr "" msgid "pow() with 3 arguments requires integers" msgstr "" +#: ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_nopsram/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/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 @@ -3955,6 +3923,8 @@ msgstr "" #: 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 @@ -3998,7 +3968,7 @@ msgid "queue overflow" msgstr "" #: py/parse.c -msgid "raw f-strings are not implemented" +msgid "raw f-strings are not supported" msgstr "" #: extmod/ulab/code/numpy/fft/fft_tools.c @@ -4059,7 +4029,7 @@ msgstr "" msgid "schedule queue full" msgstr "" -#: lib/utils/pyexec.c py/builtinimport.c +#: py/builtinimport.c msgid "script compilation not supported" msgstr "" @@ -4207,6 +4177,7 @@ msgstr "" 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 @@ -4335,7 +4306,7 @@ msgid "unicode name escapes" msgstr "" #: py/parse.c -msgid "unindent does not match any outer indentation level" +msgid "unindent doesn't match any outer indent level" msgstr "" #: py/objstr.c @@ -4489,6 +4460,15 @@ msgstr "" msgid "zi must be of shape (n_section, 2)" msgstr "" +#~ msgid "integer required" +#~ msgstr "정수가 필요합니다" + +#~ msgid "Expected a Characteristic" +#~ msgstr "특성(Characteristic)이 예상되었습니다." + +#~ msgid "Expected a UUID" +#~ msgstr "UUID이 예상되었습니다." + #~ msgid "Length must be an int" #~ msgstr "길이는 정수(int) 여야합니다" diff --git a/locale/nl.po b/locale/nl.po index b9b4d9ab1e..b513129c33 100644 --- a/locale/nl.po +++ b/locale/nl.po @@ -106,10 +106,6 @@ msgstr "" msgid "%q length must be >= 1" msgstr "" -#: shared-bindings/vectorio/Polygon.c -msgid "%q list must be a list" -msgstr "%q lijst moet een lijst zijn" - #: py/argcheck.c msgid "%q must <= %d" msgstr "" @@ -147,12 +143,12 @@ msgstr "%q moet een tuple van lengte 2 zijn" msgid "%q must be between %d and %d" msgstr "" -#: ports/atmel-samd/common-hal/busio/UART.c -msgid "%q must be power of 2" +#: py/argcheck.c +msgid "%q must be of type %q" msgstr "" -#: py/argcheck.c -msgid "%q must of type %q" +#: ports/atmel-samd/common-hal/busio/UART.c +msgid "%q must be power of 2" msgstr "" #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c @@ -168,6 +164,10 @@ msgstr "%q pin onjuist" msgid "%q should be an int" msgstr "%q moet een int zijn" +#: shared-bindings/usb_hid/Device.c +msgid "%q with a report ID of 0 must be of length 1" +msgstr "" + #: py/bc.c py/objnamedtuple.c msgid "%q() takes %d positional arguments but %d were given" msgstr "%q() verwacht %d positionele argumenten maar kreeg %d" @@ -350,6 +350,7 @@ msgstr "3-arg pow() niet ondersteund" msgid "64 bit types" msgstr "" +#: 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" @@ -372,7 +373,9 @@ msgstr "Adres type buiten bereik" msgid "All CAN peripherals are in use" msgstr "Alle CAN-peripherals zijn in gebruik" -#: ports/espressif/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c +#: 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 "Alle I2C peripherals zijn in gebruik" @@ -554,6 +557,10 @@ msgstr "Bitdiepte moet tussen 1 en 6 liggen, niet %d" msgid "Bit depth must be multiple of 8." msgstr "Bit diepte moet een meervoud van 8 zijn." +#: 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 "RX en TX zijn beide vereist voor stroomregeling" @@ -624,6 +631,10 @@ msgstr "Buffer moet op zijn minst lengte 1 zijn" msgid "Buffer too short by %d bytes" msgstr "Buffer is %d bytes te klein" +#: 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 @@ -784,10 +795,6 @@ msgstr "Clock stretch is te lang" msgid "Clock unit in use" msgstr "Clock unit in gebruik" -#: shared-bindings/_pew/PewPew.c -msgid "Column entry must be digitalio.DigitalInOut" -msgstr "Column entry moet digitalio.DigitalInOut zijn" - #: 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" @@ -965,36 +972,9 @@ msgstr "" #: 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 -#: shared-bindings/terminalio/Terminal.c msgid "Expected a %q" msgstr "Verwacht een %q" -#: shared-bindings/_bleio/CharacteristicBuffer.c -#: shared-bindings/_bleio/Descriptor.c shared-bindings/_bleio/PacketBuffer.c -msgid "Expected a Characteristic" -msgstr "Verwachtte een Characteristic" - -#: shared-bindings/_bleio/Adapter.c -msgid "Expected a DigitalInOut" -msgstr "Verwachtte een DigitalInOut" - -#: shared-bindings/_bleio/Characteristic.c -msgid "Expected a Service" -msgstr "Verwachtte een Service" - -#: shared-bindings/_bleio/Adapter.c -msgid "Expected a UART" -msgstr "Verwachtte een UART" - -#: shared-bindings/_bleio/Characteristic.c shared-bindings/_bleio/Descriptor.c -#: shared-bindings/_bleio/Service.c -msgid "Expected a UUID" -msgstr "Verwachtte een UUID" - -#: shared-bindings/_bleio/Adapter.c -msgid "Expected an Address" -msgstr "Verwachtte een adres" - #: shared-bindings/alarm/__init__.c msgid "Expected an alarm" msgstr "Verwachtte een alarm" @@ -1313,8 +1293,11 @@ msgstr "Ongeldige PWM frequentie" msgid "Invalid Pin" msgstr "Ongeldige Pin" -#: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c -#: py/moduerrno.c shared-module/rgbmatrix/RGBMatrix.c +#: 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 "Ongeldig argument" @@ -1362,10 +1345,6 @@ msgstr "Ongeldig bestand" msgid "Invalid format chunk size" msgstr "Ongeldig formaat stuk grootte" -#: ports/espressif/common-hal/busio/I2C.c -msgid "Invalid frequency" -msgstr "Onjuiste frequentie" - #: supervisor/shared/safe_mode.c msgid "Invalid memory access." msgstr "Ongeldig geheugen adres." @@ -1406,6 +1385,7 @@ msgstr "Ongeldige pin voor rechter kanaal" #: 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 @@ -1624,6 +1604,10 @@ msgstr "Geen TX pin" msgid "No available clocks" msgstr "Geen klokken beschikbaar" +#: 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 "Geen verbinding: lengte kan niet worden bepaald" @@ -1644,6 +1628,7 @@ msgstr "Geen hardware random beschikbaar" msgid "No hardware support on clk pin" msgstr "Geen hardware ondersteuning beschikbaar op clk pin" +#: 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" @@ -1789,6 +1774,11 @@ msgstr "" 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 @@ -1862,6 +1852,7 @@ msgstr "" msgid "Permission denied" msgstr "Toegang geweigerd" +#: 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 "" @@ -1914,10 +1905,13 @@ msgstr "" "allow_inefficient=True aan de constructor" #: ports/raspberrypi/common-hal/imagecapture/ParallelImageCapture.c -#: ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.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 "" @@ -1968,6 +1962,7 @@ msgstr "" msgid "Pull not used when direction is output." msgstr "Pull niet gebruikt wanneer de richting output is." +#: ports/atmel-samd/common-hal/watchdog/WatchDogTimer.c #: ports/raspberrypi/common-hal/watchdog/WatchDogTimer.c msgid "RAISE mode is not implemented" msgstr "" @@ -2045,10 +2040,6 @@ msgstr "" msgid "Right channel unsupported" msgstr "Rechter kanaal niet ondersteund" -#: shared-bindings/_pew/PewPew.c -msgid "Row entry must be digitalio.DigitalInOut" -msgstr "Rij invoeging moet digitalio.DigitalInOut zijn" - #: main.c msgid "Running in safe mode! Not running saved code.\n" msgstr "Draaiende in veilige modus! Opgeslagen code wordt niet uitgevoerd.\n" @@ -2117,6 +2108,7 @@ msgstr "" msgid "Size not supported" msgstr "Afmeting niet ondersteund" +#: ports/atmel-samd/common-hal/alarm/SleepMemory.c #: ports/raspberrypi/common-hal/alarm/SleepMemory.c msgid "Sleep Memory not available" msgstr "" @@ -2219,6 +2211,10 @@ msgstr "De sample's sample rate komt niet overeen met die van de mixer" msgid "The sample's signedness does not match the mixer's" msgstr "De sample's signature komt niet overeen met die van de mixer" +#: 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 " @@ -2271,6 +2267,7 @@ msgstr "Teveel beeldschermen" 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" @@ -2463,6 +2460,7 @@ msgstr "Voltage lees time-out" msgid "WARNING: Your code filename has two extensions\n" msgstr "WAARSCHUWING: De bestandsnaam van de code heeft twee extensies\n" +#: 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" @@ -2493,15 +2491,10 @@ msgstr "Watchdog-timer verstreken." msgid "" "Welcome to Adafruit CircuitPython %s!\n" "\n" -"Please visit learn.adafruit.com/category/circuitpython for project guides.\n" +"Visit circuitpython.org for more information.\n" "\n" -"To list built-in modules please do `help(\"modules\")`.\n" +"To list built-in modules type `help(\"modules\")`.\n" msgstr "" -"Welkom bij Adafruit CircuitPython %s!\n" -"\n" -"Bezoek learn.adafruit.com/category/circuitpython voor projectgidsen.\n" -"\n" -"Voor een lijst van ingebouwde modules, gebruik `help(\"modules\")`.\n" #: shared-bindings/wifi/Radio.c msgid "WiFi password must be between 8 and 63 characters" @@ -2544,10 +2537,6 @@ msgstr "__new__ arg moet een user-type zijn" msgid "a bytes-like object is required" msgstr "een bytes-achtig object is vereist" -#: lib/embed/abort_.c -msgid "abort() called" -msgstr "abort() aangeroepen" - #: shared-bindings/i2cperipheral/I2CPeripheral.c msgid "address out of bounds" msgstr "adres buiten bereik" @@ -2695,10 +2684,6 @@ msgstr "buffer te klein" msgid "buffer too small for requested bytes" msgstr "buffer te klein voor gevraagde bytes" -#: shared-bindings/_pew/PewPew.c -msgid "buttons must be digitalio.DigitalInOut" -msgstr "buttons moeten digitalio.DigitalInOut zijn" - #: shared-bindings/adafruit_pixelbuf/PixelBuf.c msgid "byteorder is not a string" msgstr "byteorder is geen string" @@ -3051,6 +3036,10 @@ msgstr "" msgid "division by zero" msgstr "deling door nul" +#: ports/espressif/common-hal/rotaryio/IncrementalEncoder.c +msgid "divisor must be 4" +msgstr "" + #: py/objdeque.c msgid "empty" msgstr "leeg" @@ -3132,26 +3121,6 @@ msgstr "extra keyword argumenten gegeven" msgid "extra positional arguments given" msgstr "extra positionele argumenten gegeven" -#: py/parse.c -msgid "f-string expression part cannot include a '#'" -msgstr "f-string expressie deel kan geen '#' bevatten" - -#: py/parse.c -msgid "f-string expression part cannot include a backslash" -msgstr "f-string expressie deel kan geen backslash bevatten" - -#: py/parse.c -msgid "f-string: empty expression not allowed" -msgstr "f-string: lege expressie niet toegestaan" - -#: py/parse.c -msgid "f-string: expecting '}'" -msgstr "f-string: verwacht '}'" - -#: py/parse.c -msgid "f-string: single '}' is not allowed" -msgstr "f-string: enkele '}' is niet toegestaan" - #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c #: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c msgid "file must be a file opened in byte mode" @@ -3413,10 +3382,6 @@ msgstr "invoer is niet itereerbaar" msgid "int() arg 2 must be >= 2 and <= 36" msgstr "int() argument 2 moet >=2 en <= 36 zijn" -#: py/objstr.c -msgid "integer required" -msgstr "integer vereist" - #: extmod/ulab/code/numpy/approx.c msgid "interp is defined for 1D iterables of equal length" msgstr "" @@ -3430,10 +3395,6 @@ msgstr "interval moet binnen bereik %s-%s vallen" msgid "invalid architecture" msgstr "" -#: lib/netutils/netutils.c -msgid "invalid arguments" -msgstr "ongeldige argumenten" - #: shared-bindings/bitmaptools/__init__.c #, c-format msgid "invalid bits_per_pixel %d, must be, 1, 2, 4, 8, 16, 24, or 32" @@ -3490,7 +3451,7 @@ msgstr "ongeldige syntax voor integer met grondtal %d" msgid "invalid syntax for number" msgstr "ongeldige syntax voor nummer" -#: py/objexcept.c shared-bindings/traceback/__init__.c +#: py/objexcept.c msgid "invalid traceback" msgstr "" @@ -3974,11 +3935,13 @@ 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_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_nopsram/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/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 @@ -3997,6 +3960,8 @@ msgstr "pow() met 3 argumenten vereist integers" #: 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 @@ -4040,8 +4005,8 @@ msgid "queue overflow" msgstr "wachtrij overloop" #: py/parse.c -msgid "raw f-strings are not implemented" -msgstr "ruwe f-strings zijn niet geïmplementeerd" +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" @@ -4103,7 +4068,7 @@ msgstr "bemonsteringssnelheid buiten bereik" msgid "schedule queue full" msgstr "" -#: lib/utils/pyexec.c py/builtinimport.c +#: py/builtinimport.c msgid "script compilation not supported" msgstr "scriptcompilatie wordt niet ondersteund" @@ -4251,6 +4216,7 @@ msgstr "" msgid "time.struct_time() takes a 9-sequence" msgstr "time.struct_time() accepteert een 9-rij" +#: 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 @@ -4379,8 +4345,8 @@ msgid "unicode name escapes" msgstr "op naam gebaseerde unicode escapes zijn niet geïmplementeerd" #: py/parse.c -msgid "unindent does not match any outer indentation level" -msgstr "inspringing komt niet overeen met hoger gelegen inspringingsniveaus" +msgid "unindent doesn't match any outer indent level" +msgstr "" #: py/objstr.c #, c-format @@ -4533,6 +4499,84 @@ msgstr "zi moet van type float zijn" msgid "zi must be of shape (n_section, 2)" msgstr "zi moet vorm (n_section, 2) hebben" +#, c-format +#~ msgid "" +#~ "Welcome to Adafruit CircuitPython %s!\n" +#~ "\n" +#~ "Please visit learn.adafruit.com/category/circuitpython for project " +#~ "guides.\n" +#~ "\n" +#~ "To list built-in modules please do `help(\"modules\")`.\n" +#~ msgstr "" +#~ "Welkom bij Adafruit CircuitPython %s!\n" +#~ "\n" +#~ "Bezoek learn.adafruit.com/category/circuitpython voor projectgidsen.\n" +#~ "\n" +#~ "Voor een lijst van ingebouwde modules, gebruik `help(\"modules\")`.\n" + +#~ msgid "integer required" +#~ msgstr "integer vereist" + +#~ msgid "abort() called" +#~ msgstr "abort() aangeroepen" + +#~ msgid "f-string expression part cannot include a '#'" +#~ msgstr "f-string expressie deel kan geen '#' bevatten" + +#~ msgid "f-string expression part cannot include a backslash" +#~ msgstr "f-string expressie deel kan geen backslash bevatten" + +#~ msgid "f-string: empty expression not allowed" +#~ msgstr "f-string: lege expressie niet toegestaan" + +#~ msgid "f-string: expecting '}'" +#~ msgstr "f-string: verwacht '}'" + +#~ msgid "f-string: single '}' is not allowed" +#~ msgstr "f-string: enkele '}' is niet toegestaan" + +#~ msgid "invalid arguments" +#~ msgstr "ongeldige argumenten" + +#~ msgid "raw f-strings are not implemented" +#~ msgstr "ruwe f-strings zijn niet geïmplementeerd" + +#~ msgid "unindent does not match any outer indentation level" +#~ msgstr "inspringing komt niet overeen met hoger gelegen inspringingsniveaus" + +#~ msgid "%q list must be a list" +#~ msgstr "%q lijst moet een lijst zijn" + +#~ msgid "Column entry must be digitalio.DigitalInOut" +#~ msgstr "Column entry moet digitalio.DigitalInOut zijn" + +#~ msgid "Expected a Characteristic" +#~ msgstr "Verwachtte een Characteristic" + +#~ msgid "Expected a DigitalInOut" +#~ msgstr "Verwachtte een DigitalInOut" + +#~ msgid "Expected a Service" +#~ msgstr "Verwachtte een Service" + +#~ msgid "Expected a UART" +#~ msgstr "Verwachtte een UART" + +#~ msgid "Expected a UUID" +#~ msgstr "Verwachtte een UUID" + +#~ msgid "Expected an Address" +#~ msgstr "Verwachtte een adres" + +#~ msgid "Row entry must be digitalio.DigitalInOut" +#~ msgstr "Rij invoeging moet digitalio.DigitalInOut zijn" + +#~ msgid "buttons must be digitalio.DigitalInOut" +#~ msgstr "buttons moeten digitalio.DigitalInOut zijn" + +#~ msgid "Invalid frequency" +#~ msgstr "Onjuiste frequentie" + #~ msgid "ParallelBus not yet supported" #~ msgstr "ParallelBus nog niet ondersteund" diff --git a/locale/pl.po b/locale/pl.po index 6e548d79df..b5124d367b 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -108,10 +108,6 @@ msgstr "" msgid "%q length must be >= 1" msgstr "" -#: shared-bindings/vectorio/Polygon.c -msgid "%q list must be a list" -msgstr "" - #: py/argcheck.c msgid "%q must <= %d" msgstr "" @@ -149,12 +145,12 @@ msgstr "%q musi być krotką o długości 2" msgid "%q must be between %d and %d" msgstr "" -#: ports/atmel-samd/common-hal/busio/UART.c -msgid "%q must be power of 2" +#: py/argcheck.c +msgid "%q must be of type %q" msgstr "" -#: py/argcheck.c -msgid "%q must of type %q" +#: ports/atmel-samd/common-hal/busio/UART.c +msgid "%q must be power of 2" msgstr "" #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c @@ -170,6 +166,10 @@ msgstr "nieprawidłowy pin %q" msgid "%q should be an int" msgstr "%q powinno być typu int" +#: shared-bindings/usb_hid/Device.c +msgid "%q with a report ID of 0 must be of length 1" +msgstr "" + #: py/bc.c py/objnamedtuple.c msgid "%q() takes %d positional arguments but %d were given" msgstr "%q() bierze %d argumentów pozycyjnych, lecz podano %d" @@ -352,6 +352,7 @@ msgstr "3-argumentowy pow() jest niewspierany" msgid "64 bit types" msgstr "" +#: 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" @@ -374,7 +375,9 @@ msgstr "Typ adresu poza zakresem" msgid "All CAN peripherals are in use" msgstr "" -#: ports/espressif/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c +#: 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 "Wszystkie peryferia I2C w użyciu" @@ -556,6 +559,10 @@ msgstr "" msgid "Bit depth must be multiple of 8." msgstr "Głębia musi być wielokrotnością 8." +#: 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 "Do kontroli przepływu wymagane są zarówno RX, jak i TX" @@ -626,6 +633,10 @@ msgstr "Bufor musi mieć długość 1 lub więcej" msgid "Buffer too short by %d bytes" msgstr "Bufor za krótki o %d bajtów" +#: 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 @@ -784,10 +795,6 @@ msgstr "Rozciągnięcie zegara zbyt duże" msgid "Clock unit in use" msgstr "Jednostka zegara w użyciu" -#: shared-bindings/_pew/PewPew.c -msgid "Column entry must be digitalio.DigitalInOut" -msgstr "Kolumny muszą być typu digitalio.DigitalInOut" - #: 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" @@ -965,36 +972,9 @@ msgstr "" #: 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 -#: shared-bindings/terminalio/Terminal.c msgid "Expected a %q" msgstr "Oczekiwano %q" -#: shared-bindings/_bleio/CharacteristicBuffer.c -#: shared-bindings/_bleio/Descriptor.c shared-bindings/_bleio/PacketBuffer.c -msgid "Expected a Characteristic" -msgstr "Oczekiwano charakterystyki" - -#: shared-bindings/_bleio/Adapter.c -msgid "Expected a DigitalInOut" -msgstr "Oczekiwano DigitalInOut" - -#: shared-bindings/_bleio/Characteristic.c -msgid "Expected a Service" -msgstr "" - -#: shared-bindings/_bleio/Adapter.c -msgid "Expected a UART" -msgstr "" - -#: shared-bindings/_bleio/Characteristic.c shared-bindings/_bleio/Descriptor.c -#: shared-bindings/_bleio/Service.c -msgid "Expected a UUID" -msgstr "Oczekiwano UUID" - -#: shared-bindings/_bleio/Adapter.c -msgid "Expected an Address" -msgstr "Oczekiwano adresu" - #: shared-bindings/alarm/__init__.c msgid "Expected an alarm" msgstr "" @@ -1312,8 +1292,11 @@ msgstr "Zła częstotliwość PWM" msgid "Invalid Pin" msgstr "" -#: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c -#: py/moduerrno.c shared-module/rgbmatrix/RGBMatrix.c +#: 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 "Zły argument" @@ -1361,10 +1344,6 @@ msgstr "Zły plik" msgid "Invalid format chunk size" msgstr "Zła wielkość fragmentu formatu" -#: ports/espressif/common-hal/busio/I2C.c -msgid "Invalid frequency" -msgstr "Nieprawidłowa częstotliwość" - #: supervisor/shared/safe_mode.c msgid "Invalid memory access." msgstr "Nieprawidłowy dostęp do pamięci." @@ -1405,6 +1384,7 @@ msgstr "Zła nóżka dla prawego kanału" #: 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 @@ -1623,6 +1603,10 @@ msgstr "Brak nóżki TX" msgid "No available clocks" msgstr "Brak wolnych zegarów" +#: 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 "Brak połączenia: nie można ustalić długości" @@ -1643,6 +1627,7 @@ msgstr "Brak generatora liczb losowych" 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" @@ -1782,6 +1767,11 @@ msgstr "" 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 @@ -1852,6 +1842,7 @@ msgstr "" msgid "Permission denied" msgstr "Odmowa dostępu" +#: 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 "" @@ -1901,10 +1892,13 @@ msgid "" msgstr "" #: ports/raspberrypi/common-hal/imagecapture/ParallelImageCapture.c -#: ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.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 "" @@ -1953,6 +1947,7 @@ msgstr "" msgid "Pull not used when direction is output." msgstr "Podciągnięcie nieużywane w trybie wyjścia." +#: ports/atmel-samd/common-hal/watchdog/WatchDogTimer.c #: ports/raspberrypi/common-hal/watchdog/WatchDogTimer.c msgid "RAISE mode is not implemented" msgstr "" @@ -2030,10 +2025,6 @@ msgstr "Nie znaleziono żądanego zasobu" msgid "Right channel unsupported" msgstr "Prawy kanał jest niewspierany" -#: shared-bindings/_pew/PewPew.c -msgid "Row entry must be digitalio.DigitalInOut" -msgstr "Rzędy muszą być digitalio.DigitalInOut" - #: main.c msgid "Running in safe mode! Not running saved code.\n" msgstr "Uruchomiony tryb bezpieczeństwa! Zapisany kod nie jest uruchamiany.\n" @@ -2102,6 +2093,7 @@ msgstr "" 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 "" @@ -2204,6 +2196,10 @@ msgstr "Sample rate nie pasuje do miksera" msgid "The sample's signedness does not match the mixer's" msgstr "Znak nie pasuje do miksera" +#: 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 " @@ -2256,6 +2252,7 @@ msgstr "Zbyt wiele wyświetlaczy" 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" @@ -2446,6 +2443,7 @@ msgstr "" msgid "WARNING: Your code filename has two extensions\n" msgstr "UWAGA: Nazwa pliku ma dwa rozszerzenia\n" +#: 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" @@ -2472,16 +2470,10 @@ msgstr "" msgid "" "Welcome to Adafruit CircuitPython %s!\n" "\n" -"Please visit learn.adafruit.com/category/circuitpython for project guides.\n" +"Visit circuitpython.org for more information.\n" "\n" -"To list built-in modules please do `help(\"modules\")`.\n" +"To list built-in modules type `help(\"modules\")`.\n" msgstr "" -"Witamy w Adafruit CircuitPython %s!\n" -"\n" -"Aby zapoznać się z przewodnikami do projektu, odwiedź stronę learn.adafruit." -"com/category/circuitpython.\n" -"\n" -"Aby wyświetlić listę wbudowanych modułów, wpisz `help(\"modules\")`.\n" #: shared-bindings/wifi/Radio.c msgid "WiFi password must be between 8 and 63 characters" @@ -2524,10 +2516,6 @@ msgstr "Argument __new__ musi być typu użytkownika" msgid "a bytes-like object is required" msgstr "wymagany obiekt typu bytes" -#: lib/embed/abort_.c -msgid "abort() called" -msgstr "Wywołano abort()" - #: shared-bindings/i2cperipheral/I2CPeripheral.c msgid "address out of bounds" msgstr "adres poza zakresem" @@ -2675,10 +2663,6 @@ msgstr "zbyt mały bufor" msgid "buffer too small for requested bytes" msgstr "" -#: shared-bindings/_pew/PewPew.c -msgid "buttons must be digitalio.DigitalInOut" -msgstr "buttons musi być digitalio.DigitalInOut" - #: shared-bindings/adafruit_pixelbuf/PixelBuf.c msgid "byteorder is not a string" msgstr "" @@ -3028,6 +3012,10 @@ msgstr "" msgid "division by zero" msgstr "dzielenie przez zero" +#: ports/espressif/common-hal/rotaryio/IncrementalEncoder.c +msgid "divisor must be 4" +msgstr "" + #: py/objdeque.c msgid "empty" msgstr "puste" @@ -3109,26 +3097,6 @@ msgstr "nadmiarowe argumenty nazwane" msgid "extra positional arguments given" msgstr "nadmiarowe argumenty pozycyjne" -#: py/parse.c -msgid "f-string expression part cannot include a '#'" -msgstr "" - -#: py/parse.c -msgid "f-string expression part cannot include a backslash" -msgstr "" - -#: py/parse.c -msgid "f-string: empty expression not allowed" -msgstr "" - -#: py/parse.c -msgid "f-string: expecting '}'" -msgstr "" - -#: py/parse.c -msgid "f-string: single '}' is not allowed" -msgstr "" - #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c #: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c msgid "file must be a file opened in byte mode" @@ -3389,10 +3357,6 @@ msgstr "" msgid "int() arg 2 must be >= 2 and <= 36" msgstr "argument 2 do int() busi być pomiędzy 2 a 36" -#: py/objstr.c -msgid "integer required" -msgstr "wymagana liczba całkowita" - #: extmod/ulab/code/numpy/approx.c msgid "interp is defined for 1D iterables of equal length" msgstr "" @@ -3406,10 +3370,6 @@ msgstr "interwał musi mieścić się w zakresie %s-%s" msgid "invalid architecture" msgstr "" -#: lib/netutils/netutils.c -msgid "invalid arguments" -msgstr "złe arguemnty" - #: shared-bindings/bitmaptools/__init__.c #, c-format msgid "invalid bits_per_pixel %d, must be, 1, 2, 4, 8, 16, 24, or 32" @@ -3466,7 +3426,7 @@ msgstr "zła składnia dla liczby całkowitej w bazie %d" msgid "invalid syntax for number" msgstr "zła składnia dla liczby" -#: py/objexcept.c shared-bindings/traceback/__init__.c +#: py/objexcept.c msgid "invalid traceback" msgstr "" @@ -3947,11 +3907,13 @@ 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_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_nopsram/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/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 @@ -3970,6 +3932,8 @@ msgstr "trzyargumentowe pow() wymaga liczb całkowitych" #: 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 @@ -4013,7 +3977,7 @@ msgid "queue overflow" msgstr "przepełnienie kolejki" #: py/parse.c -msgid "raw f-strings are not implemented" +msgid "raw f-strings are not supported" msgstr "" #: extmod/ulab/code/numpy/fft/fft_tools.c @@ -4075,7 +4039,7 @@ msgstr "częstotliwość próbkowania poza zakresem" msgid "schedule queue full" msgstr "" -#: lib/utils/pyexec.c py/builtinimport.c +#: py/builtinimport.c msgid "script compilation not supported" msgstr "kompilowanie skryptów nieobsługiwane" @@ -4223,6 +4187,7 @@ msgstr "" msgid "time.struct_time() takes a 9-sequence" msgstr "time.struct_time() wymaga 9-elementowej sekwencji" +#: 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 @@ -4351,8 +4316,8 @@ msgid "unicode name escapes" msgstr "nazwy unicode" #: py/parse.c -msgid "unindent does not match any outer indentation level" -msgstr "wcięcie nie pasuje do żadnego wcześniejszego wcięcia" +msgid "unindent doesn't match any outer indent level" +msgstr "" #: py/objstr.c #, c-format @@ -4505,6 +4470,58 @@ msgstr "" msgid "zi must be of shape (n_section, 2)" msgstr "" +#, c-format +#~ msgid "" +#~ "Welcome to Adafruit CircuitPython %s!\n" +#~ "\n" +#~ "Please visit learn.adafruit.com/category/circuitpython for project " +#~ "guides.\n" +#~ "\n" +#~ "To list built-in modules please do `help(\"modules\")`.\n" +#~ msgstr "" +#~ "Witamy w Adafruit CircuitPython %s!\n" +#~ "\n" +#~ "Aby zapoznać się z przewodnikami do projektu, odwiedź stronę learn." +#~ "adafruit.com/category/circuitpython.\n" +#~ "\n" +#~ "Aby wyświetlić listę wbudowanych modułów, wpisz `help(\"modules\")`.\n" + +#~ msgid "integer required" +#~ msgstr "wymagana liczba całkowita" + +#~ msgid "abort() called" +#~ msgstr "Wywołano abort()" + +#~ msgid "invalid arguments" +#~ msgstr "złe arguemnty" + +#~ msgid "unindent does not match any outer indentation level" +#~ msgstr "wcięcie nie pasuje do żadnego wcześniejszego wcięcia" + +#~ msgid "Column entry must be digitalio.DigitalInOut" +#~ msgstr "Kolumny muszą być typu digitalio.DigitalInOut" + +#~ msgid "Expected a Characteristic" +#~ msgstr "Oczekiwano charakterystyki" + +#~ msgid "Expected a DigitalInOut" +#~ msgstr "Oczekiwano DigitalInOut" + +#~ msgid "Expected a UUID" +#~ msgstr "Oczekiwano UUID" + +#~ msgid "Expected an Address" +#~ msgstr "Oczekiwano adresu" + +#~ msgid "Row entry must be digitalio.DigitalInOut" +#~ msgstr "Rzędy muszą być digitalio.DigitalInOut" + +#~ msgid "buttons must be digitalio.DigitalInOut" +#~ msgstr "buttons musi być digitalio.DigitalInOut" + +#~ msgid "Invalid frequency" +#~ msgstr "Nieprawidłowa częstotliwość" + #~ msgid "ParallelBus not yet supported" #~ msgstr "ParallelBus nie jest jeszcze obsługiwany" diff --git a/locale/pt_BR.po b/locale/pt_BR.po index 1d7b4fc0fc..1f7f0c3eb9 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-09-24 01:40+0000\n" +"PO-Revision-Date: 2021-11-05 04:07+0000\n" "Last-Translator: Wellington Terumi Uemura \n" "Language-Team: \n" "Language: pt_BR\n" @@ -112,10 +112,6 @@ msgstr "o comprimento %q deve ser %d-%d" msgid "%q length must be >= 1" msgstr "o comprimento %q deve ser >=1" -#: shared-bindings/vectorio/Polygon.c -msgid "%q list must be a list" -msgstr "A lista %q deve ser uma lista" - #: py/argcheck.c msgid "%q must <= %d" msgstr "o %q deve ser <= %d" @@ -153,14 +149,14 @@ msgstr "%q deve ser uma tupla de comprimento 2" msgid "%q must be between %d and %d" msgstr "%q deve estar entre %d e %d" +#: py/argcheck.c +msgid "%q must be of type %q" +msgstr "%q deve ser do tipo %q" + #: ports/atmel-samd/common-hal/busio/UART.c msgid "%q must be power of 2" msgstr "%q deve ser a potência de 2" -#: py/argcheck.c -msgid "%q must of type %q" -msgstr "o %q deve ser do tipo %q" - #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #: shared-bindings/canio/Match.c msgid "%q out of range" @@ -174,6 +170,10 @@ msgstr "%q pino inválido" msgid "%q should be an int" msgstr "%q deve ser um int" +#: shared-bindings/usb_hid/Device.c +msgid "%q with a report ID of 0 must be of length 1" +msgstr "%q com um relatório com ID de 0 deve ter comprimento 1" + #: py/bc.c py/objnamedtuple.c msgid "%q() takes %d positional arguments but %d were given" msgstr "%q() recebe %d argumentos posicionais, porém %d foram informados" @@ -360,6 +360,7 @@ msgstr "3-arg pow() não compatível" msgid "64 bit types" msgstr "Tipos 64 bit" +#: 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" @@ -382,7 +383,9 @@ msgstr "O tipo do endereço está fora do alcance" msgid "All CAN peripherals are in use" msgstr "Todos os periféricos CAN estão em uso" -#: ports/espressif/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c +#: 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 "Todos os periféricos I2C estão em uso" @@ -567,6 +570,12 @@ msgstr "A profundidade dos bits deve ser de 1 até 6 inclusive, porém não %d" msgid "Bit depth must be multiple of 8." msgstr "A profundidade de bits deve ser o múltiplo de 8." +#: supervisor/shared/safe_mode.c +msgid "Boot device must be first device (interface #0)." +msgstr "" +"O dispositivo de inicialização deve ser o primeiro dispositivo (interface " +"#0)." + #: ports/mimxrt10xx/common-hal/busio/UART.c msgid "Both RX and TX required for flow control" msgstr "Ambos os RX e TX são necessários para o controle do fluxo" @@ -637,6 +646,10 @@ msgstr "O comprimento do buffer deve ter pelo menos 1" msgid "Buffer too short by %d bytes" msgstr "O buffer é muito curto em %d bytes" +#: ports/espressif/common-hal/imagecapture/ParallelImageCapture.c +msgid "Buffers must be same size" +msgstr "Os buffers devem ter o mesmo tamanho" + #: ports/atmel-samd/common-hal/paralleldisplay/ParallelBus.c #: ports/espressif/common-hal/paralleldisplay/ParallelBus.c #: ports/nrf/common-hal/paralleldisplay/ParallelBus.c @@ -801,10 +814,6 @@ msgstr "Clock se estendeu por tempo demais" msgid "Clock unit in use" msgstr "Unidade de Clock em uso" -#: shared-bindings/_pew/PewPew.c -msgid "Column entry must be digitalio.DigitalInOut" -msgstr "A entrada da coluna deve ser digitalio.DigitalInOut" - #: 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" @@ -981,36 +990,9 @@ msgstr "Erro: Falha na vinculação" #: 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 -#: shared-bindings/terminalio/Terminal.c msgid "Expected a %q" msgstr "Esperado um" -#: shared-bindings/_bleio/CharacteristicBuffer.c -#: shared-bindings/_bleio/Descriptor.c shared-bindings/_bleio/PacketBuffer.c -msgid "Expected a Characteristic" -msgstr "Uma característica é necessária" - -#: shared-bindings/_bleio/Adapter.c -msgid "Expected a DigitalInOut" -msgstr "Espera-se um DigitalInOut" - -#: shared-bindings/_bleio/Characteristic.c -msgid "Expected a Service" -msgstr "Esperava um Serviço" - -#: shared-bindings/_bleio/Adapter.c -msgid "Expected a UART" -msgstr "Espera-se uma UART" - -#: shared-bindings/_bleio/Characteristic.c shared-bindings/_bleio/Descriptor.c -#: shared-bindings/_bleio/Service.c -msgid "Expected a UUID" -msgstr "Um UUID é necessário" - -#: shared-bindings/_bleio/Adapter.c -msgid "Expected an Address" -msgstr "Um endereço esperado" - #: shared-bindings/alarm/__init__.c msgid "Expected an alarm" msgstr "Um alarme era esperado" @@ -1335,8 +1317,11 @@ msgstr "Frequência PWM inválida" msgid "Invalid Pin" msgstr "Pino inválido" -#: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c -#: py/moduerrno.c shared-module/rgbmatrix/RGBMatrix.c +#: 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 "Argumento inválido" @@ -1384,10 +1369,6 @@ msgstr "Arquivo inválido" msgid "Invalid format chunk size" msgstr "Tamanho do pedaço de formato inválido" -#: ports/espressif/common-hal/busio/I2C.c -msgid "Invalid frequency" -msgstr "Frequência inválida" - #: supervisor/shared/safe_mode.c msgid "Invalid memory access." msgstr "O acesso da memória é inválido." @@ -1428,6 +1409,7 @@ msgstr "Pino inválido para canal direito" #: 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 @@ -1646,6 +1628,10 @@ msgstr "Nenhum pino TX" msgid "No available clocks" msgstr "Nenhum clock disponível" +#: ports/espressif/common-hal/imagecapture/ParallelImageCapture.c +msgid "No capture in progress" +msgstr "Não há nenhuma captura em andamento" + #: shared-bindings/_bleio/PacketBuffer.c msgid "No connection: length cannot be determined" msgstr "Sem conexão: o comprimento não pode ser determinado" @@ -1666,6 +1652,7 @@ msgstr "Nenhum hardware aleatório está disponível" msgid "No hardware support on clk pin" msgstr "Sem suporte de hardware no pino de clock" +#: 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" @@ -1812,6 +1799,11 @@ msgstr "" msgid "Only one TouchAlarm can be set in deep sleep." msgstr "Apenas um TouchAlarm pode ser colocado em deep sleep." +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c +msgid "Only one address is allowed" +msgstr "Apenas um endereço é permitido" + +#: 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 @@ -1886,6 +1878,7 @@ msgstr "O periférico está em uso" msgid "Permission denied" msgstr "Permissão negada" +#: 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 "O pinto não pode acordar do deep sleep" @@ -1938,10 +1931,13 @@ msgstr "" "construtor" #: ports/raspberrypi/common-hal/imagecapture/ParallelImageCapture.c -#: ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c msgid "Pins must be sequential" msgstr "Os pinos devem ser sequenciais" +#: ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c +msgid "Pins must be sequential GPIO pins" +msgstr "Pinos devem ser pinos GPIO sequenciais" + #: ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c msgid "Pins must share PWM slice" msgstr "Os pinos devem compartilhar a fatia do PWM" @@ -1995,6 +1991,7 @@ msgstr "O programa é muito grande" msgid "Pull not used when direction is output." msgstr "O Pull não foi usado quando a direção for gerada." +#: ports/atmel-samd/common-hal/watchdog/WatchDogTimer.c #: ports/raspberrypi/common-hal/watchdog/WatchDogTimer.c msgid "RAISE mode is not implemented" msgstr "O modo RAISE não foi implementado" @@ -2072,10 +2069,6 @@ msgstr "O recurso solicitado não foi encontrado" msgid "Right channel unsupported" msgstr "Canal direito não suportado" -#: shared-bindings/_pew/PewPew.c -msgid "Row entry must be digitalio.DigitalInOut" -msgstr "A entrada da linha deve ser digitalio.DigitalInOut" - #: main.c msgid "Running in safe mode! Not running saved code.\n" msgstr "Rodando em modo seguro! O código salvo não está em execução.\n" @@ -2145,6 +2138,7 @@ msgstr "" msgid "Size not supported" msgstr "O tamanho não é suportado" +#: ports/atmel-samd/common-hal/alarm/SleepMemory.c #: ports/raspberrypi/common-hal/alarm/SleepMemory.c msgid "Sleep Memory not available" msgstr "Sleep memory não está disponível" @@ -2256,6 +2250,10 @@ msgstr "A taxa de amostragem da amostra não coincide com a do mixer" msgid "The sample's signedness does not match the mixer's" msgstr "A amostragem \"signedness\" não coincide com a do mixer" +#: shared-module/imagecapture/ParallelImageCapture.c +msgid "This microcontroller does not support continuous capture." +msgstr "Este microcontrolador não tem suporte para captura contínua." + #: shared-module/paralleldisplay/ParallelBus.c msgid "" "This microcontroller only supports data0=, not data_pins=, because it " @@ -2312,6 +2310,7 @@ msgstr "Exibições demais" msgid "Total data to write is larger than %q" msgstr "O total dos dados que serão escritos é maior do que %q" +#: 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" @@ -2505,6 +2504,7 @@ msgstr "O tempo limite de leitura da tensão expirou" msgid "WARNING: Your code filename has two extensions\n" msgstr "AVISO: Seu arquivo de código tem duas extensões\n" +#: 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" @@ -2535,16 +2535,15 @@ msgstr "O temporizador Watchdog expirou." msgid "" "Welcome to Adafruit CircuitPython %s!\n" "\n" -"Please visit learn.adafruit.com/category/circuitpython for project guides.\n" +"Visit circuitpython.org for more information.\n" "\n" -"To list built-in modules please do `help(\"modules\")`.\n" +"To list built-in modules type `help(\"modules\")`.\n" msgstr "" "Bem-vindo ao Adafruit CircuitPython %s!\n" "\n" -"Para obter guias de projeto, visite learn.adafruit.com/category/" -"circuitpython.\n" +"Visite o site circuitpython.org para obter mais informações.\n" "\n" -"Para listar os módulos internos, faça `help(\"modules\")`.\n" +"Para listar os módulos existente digite `help(\"modules\")`.\n" #: shared-bindings/wifi/Radio.c msgid "WiFi password must be between 8 and 63 characters" @@ -2589,10 +2588,6 @@ msgstr "O argumento __new__ deve ser um tipo usuário" msgid "a bytes-like object is required" msgstr "é necessário objetos tipo bytes" -#: lib/embed/abort_.c -msgid "abort() called" -msgstr "abort() chamado" - #: shared-bindings/i2cperipheral/I2CPeripheral.c msgid "address out of bounds" msgstr "endereço fora dos limites" @@ -2740,10 +2735,6 @@ msgstr "o buffer é muito pequeno" msgid "buffer too small for requested bytes" msgstr "o buffer é pequeno demais para os bytes requisitados" -#: shared-bindings/_pew/PewPew.c -msgid "buttons must be digitalio.DigitalInOut" -msgstr "os botões devem ser digitalio.DigitalInOut" - #: shared-bindings/adafruit_pixelbuf/PixelBuf.c msgid "byteorder is not a string" msgstr "a ordem dos bytes não é uma cadeia de caracteres" @@ -3101,6 +3092,10 @@ msgstr "divido por zero" msgid "division by zero" msgstr "divisão por zero" +#: ports/espressif/common-hal/rotaryio/IncrementalEncoder.c +msgid "divisor must be 4" +msgstr "o divisor deve ser 4" + #: py/objdeque.c msgid "empty" msgstr "vazio" @@ -3182,26 +3177,6 @@ msgstr "argumentos extras de palavras-chave passados" msgid "extra positional arguments given" msgstr "argumentos extra posicionais passados" -#: py/parse.c -msgid "f-string expression part cannot include a '#'" -msgstr "A parte da expressão f-string não pode incluir um '#'" - -#: py/parse.c -msgid "f-string expression part cannot include a backslash" -msgstr "A parte da expressão f-string não pode incluir uma barra invertida" - -#: py/parse.c -msgid "f-string: empty expression not allowed" -msgstr "f-string: expressão vazia não é permitida" - -#: py/parse.c -msgid "f-string: expecting '}'" -msgstr "f-string: esperando '}'" - -#: py/parse.c -msgid "f-string: single '}' is not allowed" -msgstr "f-string: um único '}' não é permitido" - #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c #: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c msgid "file must be a file opened in byte mode" @@ -3463,10 +3438,6 @@ msgstr "as entradas não são iteráveis" msgid "int() arg 2 must be >= 2 and <= 36" msgstr "int() arg 2 deve ser >= 2 e <= 36" -#: py/objstr.c -msgid "integer required" -msgstr "inteiro requerido" - #: extmod/ulab/code/numpy/approx.c msgid "interp is defined for 1D iterables of equal length" msgstr "o interp é definido para iteráveis 1D com comprimento igual" @@ -3480,10 +3451,6 @@ msgstr "o intervalo deve estar entre %s-%s" msgid "invalid architecture" msgstr "arquitetura inválida" -#: lib/netutils/netutils.c -msgid "invalid arguments" -msgstr "argumentos inválidos" - #: shared-bindings/bitmaptools/__init__.c #, c-format msgid "invalid bits_per_pixel %d, must be, 1, 2, 4, 8, 16, 24, or 32" @@ -3540,7 +3507,7 @@ msgstr "sintaxe inválida para o número inteiro com base %d" msgid "invalid syntax for number" msgstr "sintaxe inválida para o número" -#: py/objexcept.c shared-bindings/traceback/__init__.c +#: py/objexcept.c msgid "invalid traceback" msgstr "rastreamento inválido" @@ -4030,11 +3997,13 @@ 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_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_nopsram/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/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 @@ -4053,6 +4022,8 @@ msgstr "o pow() com 3 argumentos requer números inteiros" #: 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 @@ -4096,8 +4067,8 @@ msgid "queue overflow" msgstr "estouro de fila" #: py/parse.c -msgid "raw f-strings are not implemented" -msgstr "o f-strings bruto não estão implementados" +msgid "raw f-strings are not supported" +msgstr "os f-strings brutos não são suportados" #: extmod/ulab/code/numpy/fft/fft_tools.c msgid "real and imaginary parts must be of equal length" @@ -4159,7 +4130,7 @@ msgstr "Taxa de amostragem fora do intervalo" msgid "schedule queue full" msgstr "fila de espera cheia" -#: lib/utils/pyexec.c py/builtinimport.c +#: py/builtinimport.c msgid "script compilation not supported" msgstr "compilação de script não suportada" @@ -4307,6 +4278,7 @@ msgstr "o bloco deve ser maior que zero" msgid "time.struct_time() takes a 9-sequence" msgstr "time.struct_time() leva uma sequência com 9" +#: 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 @@ -4435,8 +4407,8 @@ msgid "unicode name escapes" msgstr "escapar o nome unicode" #: py/parse.c -msgid "unindent does not match any outer indentation level" -msgstr "o unindent não coincide com nenhum nível de recuo externo" +msgid "unindent doesn't match any outer indent level" +msgstr "sem indentação não corresponde com nenhum nível de indentação exterior" #: py/objstr.c #, c-format @@ -4589,6 +4561,88 @@ 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)" +#, c-format +#~ msgid "" +#~ "Welcome to Adafruit CircuitPython %s!\n" +#~ "\n" +#~ "Please visit learn.adafruit.com/category/circuitpython for project " +#~ "guides.\n" +#~ "\n" +#~ "To list built-in modules please do `help(\"modules\")`.\n" +#~ msgstr "" +#~ "Bem-vindo ao Adafruit CircuitPython %s!\n" +#~ "\n" +#~ "Para obter guias de projeto, visite learn.adafruit.com/category/" +#~ "circuitpython.\n" +#~ "\n" +#~ "Para listar os módulos internos, faça `help(\"modules\")`.\n" + +#~ msgid "integer required" +#~ msgstr "inteiro requerido" + +#~ msgid "abort() called" +#~ msgstr "abort() chamado" + +#~ msgid "f-string expression part cannot include a '#'" +#~ msgstr "A parte da expressão f-string não pode incluir um '#'" + +#~ msgid "f-string expression part cannot include a backslash" +#~ msgstr "A parte da expressão f-string não pode incluir uma barra invertida" + +#~ msgid "f-string: empty expression not allowed" +#~ msgstr "f-string: expressão vazia não é permitida" + +#~ msgid "f-string: expecting '}'" +#~ msgstr "f-string: esperando '}'" + +#~ msgid "f-string: single '}' is not allowed" +#~ msgstr "f-string: um único '}' não é permitido" + +#~ msgid "invalid arguments" +#~ msgstr "argumentos inválidos" + +#~ msgid "raw f-strings are not implemented" +#~ msgstr "o f-strings bruto não estão implementados" + +#~ msgid "unindent does not match any outer indentation level" +#~ msgstr "o unindent não coincide com nenhum nível de recuo externo" + +#~ msgid "%q list must be a list" +#~ msgstr "A lista %q deve ser uma lista" + +#~ msgid "%q must of type %q" +#~ msgstr "o %q deve ser do tipo %q" + +#~ msgid "Column entry must be digitalio.DigitalInOut" +#~ msgstr "A entrada da coluna deve ser digitalio.DigitalInOut" + +#~ msgid "Expected a Characteristic" +#~ msgstr "Uma característica é necessária" + +#~ msgid "Expected a DigitalInOut" +#~ msgstr "Espera-se um DigitalInOut" + +#~ msgid "Expected a Service" +#~ msgstr "Esperava um Serviço" + +#~ msgid "Expected a UART" +#~ msgstr "Espera-se uma UART" + +#~ msgid "Expected a UUID" +#~ msgstr "Um UUID é necessário" + +#~ msgid "Expected an Address" +#~ msgstr "Um endereço esperado" + +#~ msgid "Row entry must be digitalio.DigitalInOut" +#~ msgstr "A entrada da linha deve ser digitalio.DigitalInOut" + +#~ msgid "buttons must be digitalio.DigitalInOut" +#~ msgstr "os botões devem ser digitalio.DigitalInOut" + +#~ msgid "Invalid frequency" +#~ msgstr "Frequência inválida" + #~ msgid "Data 0 pin must be byte aligned." #~ msgstr "O pino de dados 0 deve ser alinhado por bytes." diff --git a/locale/sv.po b/locale/sv.po index a1564433e6..e13fb1c2fa 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-09-25 07:37+0000\n" +"PO-Revision-Date: 2021-11-05 04:07+0000\n" "Last-Translator: Jonny Bergdahl \n" "Language-Team: LANGUAGE \n" "Language: sv\n" @@ -111,10 +111,6 @@ msgstr "längden på %q måste vara %d-%d" msgid "%q length must be >= 1" msgstr "längden på %q måste vara >= 1" -#: shared-bindings/vectorio/Polygon.c -msgid "%q list must be a list" -msgstr "%q-listan måste vara en lista" - #: py/argcheck.c msgid "%q must <= %d" msgstr "%q måste vara <=%d" @@ -152,14 +148,14 @@ msgstr "%q måste vara en tuple av längd 2" msgid "%q must be between %d and %d" msgstr "%q måste vara mellan %d och %d" +#: py/argcheck.c +msgid "%q must be of type %q" +msgstr "%q måste vara av typen %q" + #: ports/atmel-samd/common-hal/busio/UART.c msgid "%q must be power of 2" msgstr "%q måste vara en potens av 2" -#: py/argcheck.c -msgid "%q must of type %q" -msgstr "%q måste av typen %q" - #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #: shared-bindings/canio/Match.c msgid "%q out of range" @@ -173,6 +169,10 @@ msgstr "Pinne %q ogiltig" msgid "%q should be an int" msgstr "%q ska vara en int" +#: shared-bindings/usb_hid/Device.c +msgid "%q with a report ID of 0 must be of length 1" +msgstr "%q med report-ID 0 måste ha längd 1" + #: py/bc.c py/objnamedtuple.c msgid "%q() takes %d positional arguments but %d were given" msgstr "% q() tar %d positionsargument men %d gavs" @@ -355,6 +355,7 @@ msgstr "3-arguments pow() stöds inte" msgid "64 bit types" msgstr "64-bitars typer" +#: 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" @@ -377,7 +378,9 @@ msgstr "Adresstyp utanför intervallet" msgid "All CAN peripherals are in use" msgstr "All I2C-kringutrustning används" -#: ports/espressif/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c +#: 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 "All I2C-kringutrustning används" @@ -559,6 +562,10 @@ msgstr "Bitdjup måste vara inom 1 till 6, inte %d" msgid "Bit depth must be multiple of 8." msgstr "Bitdjup måste vara multipel av 8." +#: supervisor/shared/safe_mode.c +msgid "Boot device must be first device (interface #0)." +msgstr "Startenheten måste vara den första enheten (gränssnitt #0)." + #: ports/mimxrt10xx/common-hal/busio/UART.c msgid "Both RX and TX required for flow control" msgstr "Både RX och TX krävs för handskakning" @@ -629,6 +636,10 @@ msgstr "Bufferten måste ha minst längd 1" msgid "Buffer too short by %d bytes" msgstr "Buffert är %d bytes för kort" +#: ports/espressif/common-hal/imagecapture/ParallelImageCapture.c +msgid "Buffers must be same size" +msgstr "Buffertarna måste ha samma storlek" + #: ports/atmel-samd/common-hal/paralleldisplay/ParallelBus.c #: ports/espressif/common-hal/paralleldisplay/ParallelBus.c #: ports/nrf/common-hal/paralleldisplay/ParallelBus.c @@ -790,10 +801,6 @@ msgstr "Klockförlängning för lång" msgid "Clock unit in use" msgstr "Klockenhet används" -#: shared-bindings/_pew/PewPew.c -msgid "Column entry must be digitalio.DigitalInOut" -msgstr "Kolumnposten måste vara digitalio. DigitalInOut" - #: 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" @@ -971,36 +978,9 @@ msgstr "Fel: Bind misslyckades" #: 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 -#: shared-bindings/terminalio/Terminal.c msgid "Expected a %q" msgstr "Förväntade %q" -#: shared-bindings/_bleio/CharacteristicBuffer.c -#: shared-bindings/_bleio/Descriptor.c shared-bindings/_bleio/PacketBuffer.c -msgid "Expected a Characteristic" -msgstr "Förväntade en karaktäristik" - -#: shared-bindings/_bleio/Adapter.c -msgid "Expected a DigitalInOut" -msgstr "Förväntar en DigitalInOut" - -#: shared-bindings/_bleio/Characteristic.c -msgid "Expected a Service" -msgstr "Förväntade en tjänst" - -#: shared-bindings/_bleio/Adapter.c -msgid "Expected a UART" -msgstr "Förväntar en UART" - -#: shared-bindings/_bleio/Characteristic.c shared-bindings/_bleio/Descriptor.c -#: shared-bindings/_bleio/Service.c -msgid "Expected a UUID" -msgstr "Förväntade en UUID" - -#: shared-bindings/_bleio/Adapter.c -msgid "Expected an Address" -msgstr "Förväntade en adress" - #: shared-bindings/alarm/__init__.c msgid "Expected an alarm" msgstr "Förväntade ett larm" @@ -1320,8 +1300,11 @@ msgstr "Ogiltig PWM-frekvens" msgid "Invalid Pin" msgstr "Ogiltig pinne" -#: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c -#: py/moduerrno.c shared-module/rgbmatrix/RGBMatrix.c +#: 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 "Ogiltigt argument" @@ -1369,10 +1352,6 @@ msgstr "Felaktig fil" msgid "Invalid format chunk size" msgstr "Ogiltig formatsegmentstorlek" -#: ports/espressif/common-hal/busio/I2C.c -msgid "Invalid frequency" -msgstr "Ogiltig frekvens" - #: supervisor/shared/safe_mode.c msgid "Invalid memory access." msgstr "Ogiltig minnesåtkomst." @@ -1413,6 +1392,7 @@ msgstr "Ogiltig pinne för höger kanal" #: 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 @@ -1632,6 +1612,10 @@ msgstr "Ingen TX-pinne" msgid "No available clocks" msgstr "Inga tillgängliga klockor" +#: ports/espressif/common-hal/imagecapture/ParallelImageCapture.c +msgid "No capture in progress" +msgstr "Ingen insamling pågår" + #: shared-bindings/_bleio/PacketBuffer.c msgid "No connection: length cannot be determined" msgstr "Ingen anslutning: längden kan inte bestämmas" @@ -1652,6 +1636,7 @@ msgstr "Ingen hårdvaru-random tillgänglig" msgid "No hardware support on clk pin" msgstr "Inget hårdvarustöd på clk-pinne" +#: 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" @@ -1796,6 +1781,11 @@ msgstr "" msgid "Only one TouchAlarm can be set in deep sleep." msgstr "Endast ett TouchAlarm kan ställas in för djupsömn." +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c +msgid "Only one address is allowed" +msgstr "Endast en adress är tillåten" + +#: 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 @@ -1868,6 +1858,7 @@ msgstr "Periferi i bruk" msgid "Permission denied" msgstr "Åtkomst nekad" +#: 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 "Pinnen kan inte väcka från djup sömn" @@ -1920,10 +1911,13 @@ msgstr "" "konstruktorn" #: ports/raspberrypi/common-hal/imagecapture/ParallelImageCapture.c -#: ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c msgid "Pins must be sequential" msgstr "Pinnarna måste vara i sekvens" +#: ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c +msgid "Pins must be sequential GPIO pins" +msgstr "Pins måste vara sekventiella GPIO-pinnar" + #: ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c msgid "Pins must share PWM slice" msgstr "Pinnar måste dela PWM-segment" @@ -1974,6 +1968,7 @@ msgstr "Programmet är för stort" msgid "Pull not used when direction is output." msgstr "Pull används inte när riktningen är output." +#: ports/atmel-samd/common-hal/watchdog/WatchDogTimer.c #: ports/raspberrypi/common-hal/watchdog/WatchDogTimer.c msgid "RAISE mode is not implemented" msgstr "RAISE-läge är inte implementerat" @@ -2051,10 +2046,6 @@ msgstr "Begärd resurs hittades inte" msgid "Right channel unsupported" msgstr "Höger kanal stöds inte" -#: shared-bindings/_pew/PewPew.c -msgid "Row entry must be digitalio.DigitalInOut" -msgstr "Radvärdet måste vara digitalio.DigitalInOut" - #: main.c msgid "Running in safe mode! Not running saved code.\n" msgstr "Kör i säkert läge! Sparad kod körs inte.\n" @@ -2123,6 +2114,7 @@ msgstr "Sido-setets antal pinnar måste vara mellan 1 och 5" msgid "Size not supported" msgstr "Storleken stöds inte" +#: ports/atmel-samd/common-hal/alarm/SleepMemory.c #: ports/raspberrypi/common-hal/alarm/SleepMemory.c msgid "Sleep Memory not available" msgstr "Sömnminne inte tillgängligt" @@ -2233,6 +2225,10 @@ msgstr "Samplingens frekvens matchar inte mixerns" msgid "The sample's signedness does not match the mixer's" msgstr "Samplingens signerad/osignerad stämmer inte med mixern" +#: shared-module/imagecapture/ParallelImageCapture.c +msgid "This microcontroller does not support continuous capture." +msgstr "Den här mikrokontrollern stöder inte kontinuerlig insamling." + #: shared-module/paralleldisplay/ParallelBus.c msgid "" "This microcontroller only supports data0=, not data_pins=, because it " @@ -2287,6 +2283,7 @@ msgstr "För många displayer" msgid "Total data to write is larger than %q" msgstr "Totala data att skriva är större än %q" +#: 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" @@ -2479,6 +2476,7 @@ msgstr "Avläsning av spänning tog för lång tid" msgid "WARNING: Your code filename has two extensions\n" msgstr "VARNING: Ditt filnamn för kod har två tillägg\n" +#: 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" @@ -2506,15 +2504,15 @@ msgstr "Watchdog-timern har löpt ut." msgid "" "Welcome to Adafruit CircuitPython %s!\n" "\n" -"Please visit learn.adafruit.com/category/circuitpython for project guides.\n" +"Visit circuitpython.org for more information.\n" "\n" -"To list built-in modules please do `help(\"modules\")`.\n" +"To list built-in modules type `help(\"modules\")`.\n" msgstr "" "Välkommen till Adafruit CircuitPython %s!\n" "\n" -"Besök learning.adafruit.com/category/circuitpython för projektguider.\n" +"Besök circuitpython.org för mer information.\n" "\n" -"För att lista inbyggda moduler, ange `help(\"modules\")`.\n" +"För att lista inbyggda moduler skriver du `help(\"modules\")`.\n" #: shared-bindings/wifi/Radio.c msgid "WiFi password must be between 8 and 63 characters" @@ -2559,10 +2557,6 @@ msgstr "__new__ arg måste vara en användartyp" msgid "a bytes-like object is required" msgstr "ett bytesliknande objekt krävs" -#: lib/embed/abort_.c -msgid "abort() called" -msgstr "abort() anropad" - #: shared-bindings/i2cperipheral/I2CPeripheral.c msgid "address out of bounds" msgstr "adress utanför gränsen" @@ -2710,10 +2704,6 @@ msgstr "buffert för liten" msgid "buffer too small for requested bytes" msgstr "buffert för liten för begärd längd" -#: shared-bindings/_pew/PewPew.c -msgid "buttons must be digitalio.DigitalInOut" -msgstr "buttons måste vara digitalio.DigitalInOut" - #: shared-bindings/adafruit_pixelbuf/PixelBuf.c msgid "byteorder is not a string" msgstr "byteorder är inte en sträng" @@ -3067,6 +3057,10 @@ msgstr "division med noll" msgid "division by zero" msgstr "division med noll" +#: ports/espressif/common-hal/rotaryio/IncrementalEncoder.c +msgid "divisor must be 4" +msgstr "divisor måste vara 4" + #: py/objdeque.c msgid "empty" msgstr "tom" @@ -3148,26 +3142,6 @@ msgstr "extra keyword-argument angivna" msgid "extra positional arguments given" msgstr "extra positions-argument angivna" -#: py/parse.c -msgid "f-string expression part cannot include a '#'" -msgstr "f-stränguttrycksdelen kan inte innehålla en '#'" - -#: py/parse.c -msgid "f-string expression part cannot include a backslash" -msgstr "f-string-uttrycksdelen kan inte innehålla ett omvänt snedstreck" - -#: py/parse.c -msgid "f-string: empty expression not allowed" -msgstr "f-sträng: tomt uttryck inte tillåten" - -#: py/parse.c -msgid "f-string: expecting '}'" -msgstr "f-string: förväntat '}'" - -#: py/parse.c -msgid "f-string: single '}' is not allowed" -msgstr "f-string: singel '}' är inte tillåten" - #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c #: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c msgid "file must be a file opened in byte mode" @@ -3428,10 +3402,6 @@ msgstr "indata är inte iterbara" msgid "int() arg 2 must be >= 2 and <= 36" msgstr "int() arg 2 måste vara >= 2 och <= 36" -#: py/objstr.c -msgid "integer required" -msgstr "heltal krävs" - #: extmod/ulab/code/numpy/approx.c msgid "interp is defined for 1D iterables of equal length" msgstr "interp är definierad för 1D-iterabla med samma längd" @@ -3445,10 +3415,6 @@ msgstr "interval måste vara i intervallet %s-%s" msgid "invalid architecture" msgstr "ogiltig arkitektur" -#: lib/netutils/netutils.c -msgid "invalid arguments" -msgstr "ogiltiga argument" - #: shared-bindings/bitmaptools/__init__.c #, c-format msgid "invalid bits_per_pixel %d, must be, 1, 2, 4, 8, 16, 24, or 32" @@ -3505,7 +3471,7 @@ msgstr "ogiltig syntax för heltal med bas %d" msgid "invalid syntax for number" msgstr "ogiltig syntax för tal" -#: py/objexcept.c shared-bindings/traceback/__init__.c +#: py/objexcept.c msgid "invalid traceback" msgstr "Ogilitig källspårning" @@ -3989,11 +3955,13 @@ 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_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_nopsram/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/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 @@ -4012,6 +3980,8 @@ msgstr "pow() med 3 argument kräver heltal" #: 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 @@ -4055,8 +4025,8 @@ msgid "queue overflow" msgstr "köstorlek överskreds" #: py/parse.c -msgid "raw f-strings are not implemented" -msgstr "råa f-strängar inte implementerade" +msgid "raw f-strings are not supported" +msgstr "råa f-strängar stöds inte" #: extmod/ulab/code/numpy/fft/fft_tools.c msgid "real and imaginary parts must be of equal length" @@ -4118,7 +4088,7 @@ msgstr "samplingsfrekvens utanför räckvidden" msgid "schedule queue full" msgstr "schemakön full" -#: lib/utils/pyexec.c py/builtinimport.c +#: py/builtinimport.c msgid "script compilation not supported" msgstr "skriptkompilering stöds inte" @@ -4266,6 +4236,7 @@ msgstr "tile måste vara större än noll" msgid "time.struct_time() takes a 9-sequence" msgstr "time.struct_time() kräver en 9-sekvens" +#: 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 @@ -4394,8 +4365,8 @@ msgid "unicode name escapes" msgstr "unicode-namn flyr" #: py/parse.c -msgid "unindent does not match any outer indentation level" -msgstr "indentering inte matchar någon yttre indenteringsnivå" +msgid "unindent doesn't match any outer indent level" +msgstr "avindentering matchar inte någon yttre indentering" #: py/objstr.c #, c-format @@ -4548,6 +4519,87 @@ 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)" +#, c-format +#~ msgid "" +#~ "Welcome to Adafruit CircuitPython %s!\n" +#~ "\n" +#~ "Please visit learn.adafruit.com/category/circuitpython for project " +#~ "guides.\n" +#~ "\n" +#~ "To list built-in modules please do `help(\"modules\")`.\n" +#~ msgstr "" +#~ "Välkommen till Adafruit CircuitPython %s!\n" +#~ "\n" +#~ "Besök learning.adafruit.com/category/circuitpython för projektguider.\n" +#~ "\n" +#~ "För att lista inbyggda moduler, ange `help(\"modules\")`.\n" + +#~ msgid "integer required" +#~ msgstr "heltal krävs" + +#~ msgid "abort() called" +#~ msgstr "abort() anropad" + +#~ msgid "f-string expression part cannot include a '#'" +#~ msgstr "f-stränguttrycksdelen kan inte innehålla en '#'" + +#~ msgid "f-string expression part cannot include a backslash" +#~ msgstr "f-string-uttrycksdelen kan inte innehålla ett omvänt snedstreck" + +#~ msgid "f-string: empty expression not allowed" +#~ msgstr "f-sträng: tomt uttryck inte tillåten" + +#~ msgid "f-string: expecting '}'" +#~ msgstr "f-string: förväntat '}'" + +#~ msgid "f-string: single '}' is not allowed" +#~ msgstr "f-string: singel '}' är inte tillåten" + +#~ msgid "invalid arguments" +#~ msgstr "ogiltiga argument" + +#~ msgid "raw f-strings are not implemented" +#~ msgstr "råa f-strängar inte implementerade" + +#~ msgid "unindent does not match any outer indentation level" +#~ msgstr "indentering inte matchar någon yttre indenteringsnivå" + +#~ msgid "%q list must be a list" +#~ msgstr "%q-listan måste vara en lista" + +#~ msgid "%q must of type %q" +#~ msgstr "%q måste av typen %q" + +#~ msgid "Column entry must be digitalio.DigitalInOut" +#~ msgstr "Kolumnposten måste vara digitalio. DigitalInOut" + +#~ msgid "Expected a Characteristic" +#~ msgstr "Förväntade en karaktäristik" + +#~ msgid "Expected a DigitalInOut" +#~ msgstr "Förväntar en DigitalInOut" + +#~ msgid "Expected a Service" +#~ msgstr "Förväntade en tjänst" + +#~ msgid "Expected a UART" +#~ msgstr "Förväntar en UART" + +#~ msgid "Expected a UUID" +#~ msgstr "Förväntade en UUID" + +#~ msgid "Expected an Address" +#~ msgstr "Förväntade en adress" + +#~ msgid "Row entry must be digitalio.DigitalInOut" +#~ msgstr "Radvärdet måste vara digitalio.DigitalInOut" + +#~ msgid "buttons must be digitalio.DigitalInOut" +#~ msgstr "buttons måste vara digitalio.DigitalInOut" + +#~ msgid "Invalid frequency" +#~ msgstr "Ogiltig frekvens" + #~ msgid "Data 0 pin must be byte aligned." #~ msgstr "Datapinne 0 måste vara byte-justerad." diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index 64a2f9dbf7..15d0d303f6 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -7,7 +7,7 @@ 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-10-01 02:38+0000\n" +"PO-Revision-Date: 2021-11-05 04:07+0000\n" "Last-Translator: hexthat \n" "Language-Team: Chinese Hanyu Pinyin\n" "Language: zh_Latn_pinyin\n" @@ -113,10 +113,6 @@ msgstr "%q cháng dù bì xū wéi %d-%d" msgid "%q length must be >= 1" msgstr "%q cháng dù bì xū >= 1" -#: shared-bindings/vectorio/Polygon.c -msgid "%q list must be a list" -msgstr "%q lièbiǎo bìxū shì lièbiǎo" - #: py/argcheck.c msgid "%q must <= %d" msgstr "%q bì xū <= %d" @@ -154,14 +150,14 @@ msgstr "%q bìxū shì chángdù wèi 2 de yuán zǔ" msgid "%q must be between %d and %d" msgstr "%q bì xū zài %d hé %d zhī jiān" +#: py/argcheck.c +msgid "%q must be of type %q" +msgstr "%q bì xū shì lèi xíng %q" + #: ports/atmel-samd/common-hal/busio/UART.c msgid "%q must be power of 2" msgstr "%q bì xū shì 2 de gōng lǜ" -#: py/argcheck.c -msgid "%q must of type %q" -msgstr "%q bì xū lèi xíng %q" - #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #: shared-bindings/canio/Match.c msgid "%q out of range" @@ -175,6 +171,10 @@ msgstr "%q yǐn jiǎo wúxiào" msgid "%q should be an int" msgstr "%q yīnggāi shì yīgè int" +#: shared-bindings/usb_hid/Device.c +msgid "%q with a report ID of 0 must be of length 1" +msgstr "%q yǔ bào gào ID 0 bì xū shì cháng dù 1" + #: py/bc.c py/objnamedtuple.c msgid "%q() takes %d positional arguments but %d were given" msgstr "%q() cǎiyòng %d wèizhì cānshù, dàn gěi chū %d" @@ -357,6 +357,7 @@ msgstr "bù zhīchí 3-arg pow()" msgid "64 bit types" msgstr "64 wèi lèi xíng" +#: 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" @@ -379,7 +380,9 @@ msgstr "Dìzhǐ lèixíng chāochū fànwéi" msgid "All CAN peripherals are in use" msgstr "suǒ yǒu CAN wài shè dōu zài shǐ yòng zhōng" -#: ports/espressif/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c +#: 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 "Suǒyǒu I2C wàiwéi qì zhèngzài shǐyòng" @@ -561,6 +564,10 @@ msgstr "wèi shēn dù bì xū bāo hán 1 dào 6, ér bù shì %d" msgid "Bit depth must be multiple of 8." msgstr "Bǐtè shēndù bìxū shì 8 bèi yǐshàng." +#: supervisor/shared/safe_mode.c +msgid "Boot device must be first device (interface #0)." +msgstr "yǐn dǎo shè bèi bì xū shì dì yī tái shè bèi (jiē kǒu #0)." + #: ports/mimxrt10xx/common-hal/busio/UART.c msgid "Both RX and TX required for flow control" msgstr "liú liàng kòng zhì suǒ xū de RX hé TX" @@ -631,6 +638,10 @@ msgstr "Huǎnchōng qū bìxū zhìshǎo chángdù 1" 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" + #: ports/atmel-samd/common-hal/paralleldisplay/ParallelBus.c #: ports/espressif/common-hal/paralleldisplay/ParallelBus.c #: ports/nrf/common-hal/paralleldisplay/ParallelBus.c @@ -791,10 +802,6 @@ msgstr "Shízhōng shēnzhǎn tài zhǎng" msgid "Clock unit in use" msgstr "Shǐyòng shízhōng dānwèi" -#: shared-bindings/_pew/PewPew.c -msgid "Column entry must be digitalio.DigitalInOut" -msgstr "Liè tiáomù bìxū shì digitalio.DigitalInOut" - #: 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" @@ -971,36 +978,9 @@ msgstr "cuò wù: bǎng dìng shī bài" #: 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 -#: shared-bindings/terminalio/Terminal.c msgid "Expected a %q" msgstr "Yùqí %q" -#: shared-bindings/_bleio/CharacteristicBuffer.c -#: shared-bindings/_bleio/Descriptor.c shared-bindings/_bleio/PacketBuffer.c -msgid "Expected a Characteristic" -msgstr "Yùqí de tèdiǎn" - -#: shared-bindings/_bleio/Adapter.c -msgid "Expected a DigitalInOut" -msgstr "yù qī shù zì huà" - -#: shared-bindings/_bleio/Characteristic.c -msgid "Expected a Service" -msgstr "Yùqí fúwù" - -#: shared-bindings/_bleio/Adapter.c -msgid "Expected a UART" -msgstr "qī dài UART" - -#: shared-bindings/_bleio/Characteristic.c shared-bindings/_bleio/Descriptor.c -#: shared-bindings/_bleio/Service.c -msgid "Expected a UUID" -msgstr "Yùqí UUID" - -#: shared-bindings/_bleio/Adapter.c -msgid "Expected an Address" -msgstr "Qídài yīgè dìzhǐ" - #: shared-bindings/alarm/__init__.c msgid "Expected an alarm" msgstr "yù qī yǒu jǐng bào" @@ -1323,8 +1303,11 @@ msgstr "Wúxiào de PWM pínlǜ" msgid "Invalid Pin" msgstr "wú xiào yǐn jiǎo" -#: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c -#: py/moduerrno.c shared-module/rgbmatrix/RGBMatrix.c +#: 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 "Wúxiào de cānshù" @@ -1372,10 +1355,6 @@ msgstr "Wúxiào de wénjiàn" msgid "Invalid format chunk size" msgstr "Géshì kuài dàxiǎo wúxiào" -#: ports/espressif/common-hal/busio/I2C.c -msgid "Invalid frequency" -msgstr "Wúxiào de pínlǜ" - #: supervisor/shared/safe_mode.c msgid "Invalid memory access." msgstr "Wúxiào de nèicún fǎngwèn." @@ -1416,6 +1395,7 @@ msgstr "Yòuxián tōngdào yǐn jiǎo wúxiào" #: 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 @@ -1635,6 +1615,10 @@ msgstr "Wèi zhǎodào TX yǐn jiǎo" msgid "No available clocks" msgstr "Méiyǒu kěyòng de shízhōng" +#: ports/espressif/common-hal/imagecapture/ParallelImageCapture.c +msgid "No capture in progress" +msgstr "zhèng zài jìn xíng zhōng de wèi bǔ huò" + #: shared-bindings/_bleio/PacketBuffer.c msgid "No connection: length cannot be determined" msgstr "Wú liánjiē: Wúfǎ quèdìng chángdù" @@ -1655,6 +1639,7 @@ msgstr "Méiyǒu kěyòng de yìngjiàn suíjī" msgid "No hardware support on clk pin" msgstr "Shízhōng yǐn jiǎo wú yìngjiàn zhīchí" +#: 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" @@ -1799,6 +1784,11 @@ msgstr "" msgid "Only one TouchAlarm can be set in deep sleep." msgstr "zhǐ yǒu yí gè chù mō bì kě yǐ shè zhì zài shēn dù shuì mián." +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c +msgid "Only one address is allowed" +msgstr "zhǐ yǔn xǔ yí gè dì zhǐ" + +#: 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 @@ -1870,6 +1860,7 @@ msgstr "shǐ yòng zhōng de wài shè" msgid "Permission denied" msgstr "Quánxiàn bèi jùjué" +#: 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 "yǐn jiǎo wú fǎ cóng shēn dù shuì mián zhōng huàn xǐng" @@ -1922,10 +1913,13 @@ msgstr "" "gěigòuzào hánshù" #: ports/raspberrypi/common-hal/imagecapture/ParallelImageCapture.c -#: ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c msgid "Pins must be sequential" msgstr "yǐn jiǎo bì xū shì lián xù de" +#: ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c +msgid "Pins must be sequential GPIO pins" +msgstr "yǐn jiǎo bì xū shì lián xù de GPIO yǐn jiǎo" + #: ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c msgid "Pins must share PWM slice" msgstr "yǐn jiǎo bì xū gòng xiǎng PWM qiē piàn" @@ -1976,6 +1970,7 @@ msgstr "chéng xù tài dà" msgid "Pull not used when direction is output." msgstr "Fāngxiàng shūchū shí Pull méiyǒu shǐyòng." +#: ports/atmel-samd/common-hal/watchdog/WatchDogTimer.c #: ports/raspberrypi/common-hal/watchdog/WatchDogTimer.c msgid "RAISE mode is not implemented" msgstr "wèi shí xiàn tí shēng mó shì" @@ -2053,10 +2048,6 @@ msgstr "wèi zhǎo dào qǐng qiú de zī yuán" msgid "Right channel unsupported" msgstr "Bù zhīchí yòu tōngdào" -#: shared-bindings/_pew/PewPew.c -msgid "Row entry must be digitalio.DigitalInOut" -msgstr "Xíng xiàng bìxū shì digitalio.DigitalInOut" - #: main.c msgid "Running in safe mode! Not running saved code.\n" msgstr "Zài ānquán móshì xià yùnxíng! Bù yùnxíng yǐ bǎocún de dàimǎ.\n" @@ -2125,6 +2116,7 @@ msgstr "cè miàn shè zhì yǐn jiǎo shù bì xū jiè yú 1 hé 5 zhī jiān" msgid "Size not supported" msgstr "bù zhī chí dà xiǎo" +#: ports/atmel-samd/common-hal/alarm/SleepMemory.c #: ports/raspberrypi/common-hal/alarm/SleepMemory.c msgid "Sleep Memory not available" msgstr "shuì mián jì yì bù kě yòng" @@ -2234,6 +2226,10 @@ msgstr "Yàngběn de yàngběn sùdù yǔ hǔn yīn qì de xiāngchà bù pǐpè msgid "The sample's signedness does not match the mixer's" msgstr "Yàngběn de qiānmíng yǔ hǔn yīn qì de qiānmíng bù pǐpèi" +#: shared-module/imagecapture/ParallelImageCapture.c +msgid "This microcontroller does not support continuous capture." +msgstr "cǐ wēi kòng zhì qì bù zhī chí lián xù bǔ huò." + #: shared-module/paralleldisplay/ParallelBus.c msgid "" "This microcontroller only supports data0=, not data_pins=, because it " @@ -2288,6 +2284,7 @@ msgstr "Xiǎnshì tài duō" msgid "Total data to write is larger than %q" msgstr "yào biān xiě de zǒng shù jù dà yú %q" +#: 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" @@ -2480,6 +2477,7 @@ msgstr "Diànyā dòu qǔ chāoshí" msgid "WARNING: Your code filename has two extensions\n" msgstr "Jǐnggào: Nǐ de dàimǎ wénjiàn míng yǒu liǎng gè kuòzhǎn míng\n" +#: 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" @@ -2507,16 +2505,15 @@ msgstr "Kān mén gǒu dìngshí qì yǐ guòqí." msgid "" "Welcome to Adafruit CircuitPython %s!\n" "\n" -"Please visit learn.adafruit.com/category/circuitpython for project guides.\n" +"Visit circuitpython.org for more information.\n" "\n" -"To list built-in modules please do `help(\"modules\")`.\n" +"To list built-in modules type `help(\"modules\")`.\n" msgstr "" -"Huānyíng lái dào Adafruit CircuitPython%s!\n" +"huān yíng lái dào ā dá shuǐ guǒ diàn lù Python %s!\n" "\n" -"Qǐng fǎngwèn learn.Adafruit.Com/category/circuitpython yǐ huòqǔ xiàngmù " -"zhǐnán.\n" +"fǎng wèn circuitpython.org le jiě gèng duō xìn xī.\n" "\n" -"Yào liè chū nèizhì mókuài, qǐng zhíxíng `help(“modules”)`\n" +"liè chū nèi zhì mó kuài jiàn rù `help(\"modules\")`.\n" #: shared-bindings/wifi/Radio.c msgid "WiFi password must be between 8 and 63 characters" @@ -2561,10 +2558,6 @@ msgstr "__new__ cānshù bìxū shì yònghù lèixíng" msgid "a bytes-like object is required" msgstr "xūyào yīgè zì jié lèi duìxiàng" -#: lib/embed/abort_.c -msgid "abort() called" -msgstr "abort() diàoyòng" - #: shared-bindings/i2cperipheral/I2CPeripheral.c msgid "address out of bounds" msgstr "dìzhǐ chāochū biānjiè" @@ -2712,10 +2705,6 @@ msgstr "huǎnchōng qū tài xiǎo" msgid "buffer too small for requested bytes" msgstr "huǎn chōng qū tài xiǎo, duì yú qǐng qiú de zì jié" -#: shared-bindings/_pew/PewPew.c -msgid "buttons must be digitalio.DigitalInOut" -msgstr "ànniǔ bìxū shì digitalio.DigitalInOut" - #: shared-bindings/adafruit_pixelbuf/PixelBuf.c msgid "byteorder is not a string" msgstr "byteorder bùshì zìfú chuàn" @@ -3070,6 +3059,10 @@ msgstr "chú yǐ líng" msgid "division by zero" msgstr "bèi líng chú" +#: ports/espressif/common-hal/rotaryio/IncrementalEncoder.c +msgid "divisor must be 4" +msgstr "èr chóng zòu bì xū shì 4" + #: py/objdeque.c msgid "empty" msgstr "kòngxián" @@ -3151,26 +3144,6 @@ msgstr "éwài de guānjiàn cí cānshù" msgid "extra positional arguments given" msgstr "gěi chūle éwài de wèizhì cānshù" -#: py/parse.c -msgid "f-string expression part cannot include a '#'" -msgstr "f-string biǎodá shì bùfèn bùnéng bāohán '#'" - -#: py/parse.c -msgid "f-string expression part cannot include a backslash" -msgstr "f-string biǎodá shì bùfèn bùnéng bāohán fǎn xié gāng" - -#: py/parse.c -msgid "f-string: empty expression not allowed" -msgstr "f-string: bù yǔnxǔ shǐyòng kōng biǎodá shì" - -#: py/parse.c -msgid "f-string: expecting '}'" -msgstr "f-string: qídài '}'" - -#: py/parse.c -msgid "f-string: single '}' is not allowed" -msgstr "f-string: bù yǔnxǔ shǐyòng dāngè '}'" - #: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c #: shared-bindings/displayio/OnDiskBitmap.c shared-bindings/synthio/__init__.c msgid "file must be a file opened in byte mode" @@ -3431,10 +3404,6 @@ msgstr "shū rù bù kě yí dòng" msgid "int() arg 2 must be >= 2 and <= 36" msgstr "zhěngshù() cānshù 2 bìxū > = 2 qiě <= 36" -#: py/objstr.c -msgid "integer required" -msgstr "xūyào zhěngshù" - #: extmod/ulab/code/numpy/approx.c msgid "interp is defined for 1D iterables of equal length" msgstr "zhōng jiān wéi cháng dù xiāng děng de 1D kě yì jiāo qì dìng yì" @@ -3448,10 +3417,6 @@ msgstr "Jiàngé bìxū zài %s-%s fànwéi nèi" msgid "invalid architecture" msgstr "wú xiào de jià gòu" -#: lib/netutils/netutils.c -msgid "invalid arguments" -msgstr "wúxiào de cānshù" - #: shared-bindings/bitmaptools/__init__.c #, c-format msgid "invalid bits_per_pixel %d, must be, 1, 2, 4, 8, 16, 24, or 32" @@ -3508,7 +3473,7 @@ msgstr "jīshù wèi %d de zhěng shǔ de yǔfǎ wúxiào" msgid "invalid syntax for number" msgstr "wúxiào de hàomǎ yǔfǎ" -#: py/objexcept.c shared-bindings/traceback/__init__.c +#: py/objexcept.c msgid "invalid traceback" msgstr "wú xiào zhuī sù" @@ -3989,11 +3954,13 @@ 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_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_nopsram/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/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 @@ -4012,6 +3979,8 @@ msgstr "pow() yǒu 3 cānshù xūyào zhěngshù" #: 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 @@ -4055,8 +4024,8 @@ msgid "queue overflow" msgstr "duìliè yìchū" #: py/parse.c -msgid "raw f-strings are not implemented" -msgstr "wèi zhíxíng yuánshǐ f-strings" +msgid "raw f-strings are not supported" +msgstr "bù zhī chí yuán shǐ f-strings" #: extmod/ulab/code/numpy/fft/fft_tools.c msgid "real and imaginary parts must be of equal length" @@ -4118,7 +4087,7 @@ msgstr "qǔyàng lǜ chāochū fànwéi" msgid "schedule queue full" msgstr "shí jiān biǎo duì liè yǐ mǎn" -#: lib/utils/pyexec.c py/builtinimport.c +#: py/builtinimport.c msgid "script compilation not supported" msgstr "bù zhīchí jiǎoběn biānyì" @@ -4266,6 +4235,7 @@ msgstr "cí tiē bì xū dà yú líng" msgid "time.struct_time() takes a 9-sequence" msgstr "time.struct_time() xūyào 9 xùliè" +#: 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 @@ -4394,8 +4364,8 @@ msgid "unicode name escapes" msgstr "unicode míngchēng táoyì" #: py/parse.c -msgid "unindent does not match any outer indentation level" -msgstr "bùsuō jìn yǔ rènhé wàibù suō jìn jíbié dōu bù pǐpèi" +msgid "unindent doesn't match any outer indent level" +msgstr "dān dù bù pǐ pèi rèn hé wài bù āo hén shuǐ píng" #: py/objstr.c #, c-format @@ -4548,6 +4518,88 @@ 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)" +#, c-format +#~ msgid "" +#~ "Welcome to Adafruit CircuitPython %s!\n" +#~ "\n" +#~ "Please visit learn.adafruit.com/category/circuitpython for project " +#~ "guides.\n" +#~ "\n" +#~ "To list built-in modules please do `help(\"modules\")`.\n" +#~ msgstr "" +#~ "Huānyíng lái dào Adafruit CircuitPython%s!\n" +#~ "\n" +#~ "Qǐng fǎngwèn learn.Adafruit.Com/category/circuitpython yǐ huòqǔ xiàngmù " +#~ "zhǐnán.\n" +#~ "\n" +#~ "Yào liè chū nèizhì mókuài, qǐng zhíxíng `help(“modules”)`\n" + +#~ msgid "integer required" +#~ msgstr "xūyào zhěngshù" + +#~ msgid "abort() called" +#~ msgstr "abort() diàoyòng" + +#~ msgid "f-string expression part cannot include a '#'" +#~ msgstr "f-string biǎodá shì bùfèn bùnéng bāohán '#'" + +#~ msgid "f-string expression part cannot include a backslash" +#~ msgstr "f-string biǎodá shì bùfèn bùnéng bāohán fǎn xié gāng" + +#~ msgid "f-string: empty expression not allowed" +#~ msgstr "f-string: bù yǔnxǔ shǐyòng kōng biǎodá shì" + +#~ msgid "f-string: expecting '}'" +#~ msgstr "f-string: qídài '}'" + +#~ msgid "f-string: single '}' is not allowed" +#~ msgstr "f-string: bù yǔnxǔ shǐyòng dāngè '}'" + +#~ msgid "invalid arguments" +#~ msgstr "wúxiào de cānshù" + +#~ msgid "raw f-strings are not implemented" +#~ msgstr "wèi zhíxíng yuánshǐ f-strings" + +#~ msgid "unindent does not match any outer indentation level" +#~ msgstr "bùsuō jìn yǔ rènhé wàibù suō jìn jíbié dōu bù pǐpèi" + +#~ msgid "%q list must be a list" +#~ msgstr "%q lièbiǎo bìxū shì lièbiǎo" + +#~ msgid "%q must of type %q" +#~ msgstr "%q bì xū lèi xíng %q" + +#~ msgid "Column entry must be digitalio.DigitalInOut" +#~ msgstr "Liè tiáomù bìxū shì digitalio.DigitalInOut" + +#~ msgid "Expected a Characteristic" +#~ msgstr "Yùqí de tèdiǎn" + +#~ msgid "Expected a DigitalInOut" +#~ msgstr "yù qī shù zì huà" + +#~ msgid "Expected a Service" +#~ msgstr "Yùqí fúwù" + +#~ msgid "Expected a UART" +#~ msgstr "qī dài UART" + +#~ msgid "Expected a UUID" +#~ msgstr "Yùqí UUID" + +#~ msgid "Expected an Address" +#~ msgstr "Qídài yīgè dìzhǐ" + +#~ msgid "Row entry must be digitalio.DigitalInOut" +#~ msgstr "Xíng xiàng bìxū shì digitalio.DigitalInOut" + +#~ msgid "buttons must be digitalio.DigitalInOut" +#~ msgstr "ànniǔ bìxū shì digitalio.DigitalInOut" + +#~ msgid "Invalid frequency" +#~ msgstr "Wúxiào de pínlǜ" + #~ msgid "Data 0 pin must be byte aligned." #~ msgstr "shù jù 0 yǐn jiǎo bì xū àn zì jié duì qí." diff --git a/main.c b/main.c index 2f39b0eb37..32ece4bbea 100755 --- a/main.c +++ b/main.c @@ -40,8 +40,8 @@ #include "py/gc.h" #include "py/stackctrl.h" -#include "lib/mp-readline/readline.h" -#include "lib/utils/pyexec.h" +#include "shared/readline/readline.h" +#include "shared/runtime/pyexec.h" #include "background.h" #include "mpconfigboard.h" @@ -635,7 +635,7 @@ STATIC bool run_code_py(safe_mode_t safe_mode) { return skip_repl; } -FIL* boot_output_file; +vstr_t *boot_output; STATIC void __attribute__ ((noinline)) run_boot_py(safe_mode_t safe_mode) { // If not in safe mode, run boot before initing USB and capture output in a file. @@ -645,67 +645,12 @@ STATIC void __attribute__ ((noinline)) run_boot_py(safe_mode_t safe_mode) { && safe_mode == NO_SAFE_MODE && MP_STATE_VM(vfs_mount_table) != NULL; - static const char * const boot_py_filenames[] = STRING_LIST("boot.py", "boot.txt"); - bool skip_boot_output = false; - #ifdef CIRCUITPY_BOOT_OUTPUT_FILE - FIL file_pointer; - #endif - - if (ok_to_run) { - - #ifdef CIRCUITPY_BOOT_OUTPUT_FILE - boot_output_file = &file_pointer; - - // Get the base filesystem. - FATFS *fs = &((fs_user_mount_t *) MP_STATE_VM(vfs_mount_table)->obj)->fatfs; - - bool have_boot_py = first_existing_file_in_list(boot_py_filenames) != NULL; - - // If there's no boot.py file that might write some changing output, - // read the existing copy of CIRCUITPY_BOOT_OUTPUT_FILE and see if its contents - // match the version info we would print anyway. If so, skip writing CIRCUITPY_BOOT_OUTPUT_FILE. - // This saves wear and tear on the flash and also prevents filesystem damage if power is lost - // during the write, which may happen due to bobbling the power connector or weak power. - - static const size_t NUM_CHARS_TO_COMPARE = 160; - if (!have_boot_py && f_open(fs, boot_output_file, CIRCUITPY_BOOT_OUTPUT_FILE, FA_READ) == FR_OK) { - - char file_contents[NUM_CHARS_TO_COMPARE]; - UINT chars_read = 0; - f_read(boot_output_file, file_contents, NUM_CHARS_TO_COMPARE, &chars_read); - f_close(boot_output_file); - skip_boot_output = - // + 2 accounts for \r\n. - chars_read == strlen(MICROPY_FULL_VERSION_INFO) + 2 && - strncmp(file_contents, MICROPY_FULL_VERSION_INFO, strlen(MICROPY_FULL_VERSION_INFO)) == 0; - } - - if (!skip_boot_output) { - // Wait 1.5 seconds before opening CIRCUITPY_BOOT_OUTPUT_FILE for write, - // in case power is momentary or will fail shortly due to, say a low, battery. - if (common_hal_mcu_processor_get_reset_reason() == RESET_REASON_POWER_ON) { - mp_hal_delay_ms(1500); - } - // USB isn't up, so we can write the file. - filesystem_set_internal_writable_by_usb(false); - f_open(fs, boot_output_file, CIRCUITPY_BOOT_OUTPUT_FILE, FA_WRITE | FA_CREATE_ALWAYS); - - // Switch the filesystem back to non-writable by Python now instead of later, - // since boot.py might change it back to writable. - filesystem_set_internal_writable_by_usb(true); - - // Write version info to boot_out.txt. - mp_hal_stdout_tx_str(MICROPY_FULL_VERSION_INFO); - // Write the board ID (board directory and ID on circuitpython.org) - mp_hal_stdout_tx_str("\r\n" "Board ID:"); - mp_hal_stdout_tx_str(CIRCUITPY_BOARD_ID); - mp_hal_stdout_tx_str("\r\n"); - } - #endif - - filesystem_flush(); + if (!ok_to_run) { + return; } + static const char * const boot_py_filenames[] = STRING_LIST("boot.py", "boot.txt"); + // Do USB setup even if boot.py is not run. supervisor_allocation* heap = allocate_remaining_memory(); @@ -716,20 +661,55 @@ STATIC void __attribute__ ((noinline)) run_boot_py(safe_mode_t safe_mode) { usb_set_defaults(); #endif - pyexec_result_t result = {0, MP_OBJ_NULL, 0}; - if (ok_to_run) { - bool found_boot = maybe_run_list(boot_py_filenames, &result); - (void) found_boot; + #ifdef CIRCUITPY_BOOT_OUTPUT_FILE + vstr_t boot_text; + vstr_init(&boot_text, 512); + boot_output = &boot_text; + #endif - #ifdef CIRCUITPY_BOOT_OUTPUT_FILE - if (!skip_boot_output) { - f_close(boot_output_file); - filesystem_flush(); + // Write version info + mp_printf(&mp_plat_print, "%s\nBoard ID:%s\n", MICROPY_FULL_VERSION_INFO, CIRCUITPY_BOARD_ID); + + pyexec_result_t result = {0, MP_OBJ_NULL, 0}; + + bool found_boot = maybe_run_list(boot_py_filenames, &result); + (void) found_boot; + + + #ifdef CIRCUITPY_BOOT_OUTPUT_FILE + // Get the base filesystem. + fs_user_mount_t *vfs = (fs_user_mount_t *) MP_STATE_VM(vfs_mount_table)->obj; + FATFS *fs = &vfs->fatfs; + + boot_output = NULL; + bool write_boot_output = (common_hal_mcu_processor_get_reset_reason() == RESET_REASON_POWER_ON); + FIL boot_output_file; + if (f_open(fs, &boot_output_file, CIRCUITPY_BOOT_OUTPUT_FILE, FA_READ) == FR_OK) { + char *file_contents = m_new(char, boot_text.alloc); + UINT chars_read; + if (f_read(&boot_output_file, file_contents, 1+boot_text.len, &chars_read) == FR_OK) { + write_boot_output = + (chars_read != boot_text.len) || (memcmp(boot_text.buf, file_contents, chars_read) != 0); } - boot_output_file = NULL; - #endif + // no need to f_close the file } + if (write_boot_output) { + // Wait 1 second before opening CIRCUITPY_BOOT_OUTPUT_FILE for write, + // in case power is momentary or will fail shortly due to, say a low, battery. + mp_hal_delay_ms(1000); + + // USB isn't up, so we can write the file. + // operating at the oofatfs (f_open) layer means the usb concurrent write permission + // is not even checked! + f_open(fs, &boot_output_file, CIRCUITPY_BOOT_OUTPUT_FILE, FA_WRITE | FA_CREATE_ALWAYS); + UINT chars_written; + f_write(&boot_output_file, boot_text.buf, boot_text.len, &chars_written); + f_close(&boot_output_file); + filesystem_flush(); + } + #endif + #if CIRCUITPY_USB // Some data needs to be carried over from the USB settings in boot.py // to the next VM, while the heap is still available. diff --git a/mpy-cross/Makefile.static-mingw b/mpy-cross/Makefile.static-mingw index f5bc861779..bcd2b6a9f2 100644 --- a/mpy-cross/Makefile.static-mingw +++ b/mpy-cross/Makefile.static-mingw @@ -2,7 +2,7 @@ # # SPDX-License-Identifier: MIT -PROG=mpy-cross.static.exe +PROG=mpy-cross.static CROSS_COMPILE = x86_64-w64-mingw32- BUILD=build-static-mingw STATIC_BUILD=1 diff --git a/mpy-cross/gccollect.c b/mpy-cross/gccollect.c index 2172bb36b7..79c47f3b68 100644 --- a/mpy-cross/gccollect.c +++ b/mpy-cross/gccollect.c @@ -8,7 +8,7 @@ #include "py/mpstate.h" #include "py/gc.h" -#include "lib/utils/gchelper.h" +#include "shared/runtime/gchelper.h" #if MICROPY_ENABLE_GC diff --git a/mpy-cross/mpconfigport.h b/mpy-cross/mpconfigport.h index aacfeabdda..50c77a1186 100644 --- a/mpy-cross/mpconfigport.h +++ b/mpy-cross/mpconfigport.h @@ -41,7 +41,9 @@ #define MICROPY_READER_POSIX (1) #define MICROPY_ENABLE_RUNTIME (0) #define MICROPY_ENABLE_GC (1) +#ifndef __EMSCRIPTEN__ #define MICROPY_STACK_CHECK (1) +#endif #define MICROPY_HELPER_LEXER_UNIX (1) #define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_MPZ) #define MICROPY_ENABLE_SOURCE_LINE (1) @@ -54,6 +56,7 @@ #define MICROPY_PY_ASYNC_AWAIT (1) #define MICROPY_USE_INTERNAL_PRINTF (0) +#define MICROPY_PY_FSTRINGS (1) #define MICROPY_PY_BUILTINS_STR_UNICODE (1) #if !(defined(MICROPY_GCREGS_SETJMP) || defined(__x86_64__) || defined(__i386__) || defined(__thumb2__) || defined(__thumb__) || defined(__arm__)) diff --git a/mpy-cross/mpy-cross.mk b/mpy-cross/mpy-cross.mk index f84afef1da..642fe9b5aa 100644 --- a/mpy-cross/mpy-cross.mk +++ b/mpy-cross/mpy-cross.mk @@ -69,7 +69,7 @@ endif SRC_C += \ main.c \ gccollect.c \ - lib/utils/gchelper_generic.c \ + shared/runtime/gchelper_generic.c \ supervisor/stub/safe_mode.c \ supervisor/stub/stack.c \ supervisor/shared/translate.c diff --git a/mpy-cross/mpy-cross.vcxproj b/mpy-cross/mpy-cross.vcxproj index 7151ab5e99..e70b29ae14 100644 --- a/mpy-cross/mpy-cross.vcxproj +++ b/mpy-cross/mpy-cross.vcxproj @@ -89,7 +89,7 @@ - + MICROPY_GCREGS_SETJMP diff --git a/ports/atmel-samd/Makefile b/ports/atmel-samd/Makefile index 810d86581b..7b61bae267 100644 --- a/ports/atmel-samd/Makefile +++ b/ports/atmel-samd/Makefile @@ -60,7 +60,7 @@ HAL_DIR=hal/$(MCU_SERIES) INC += -I. \ -I../.. \ -I../lib/mp-readline \ - -I../lib/timeutils \ + -I../shared/timeutils \ -Iasf4/$(CHIP_FAMILY) \ -Iasf4/$(CHIP_FAMILY)/hal/include \ -Iasf4/$(CHIP_FAMILY)/hal/utils/include \ @@ -364,11 +364,11 @@ OBJ += $(addprefix $(BUILD)/, $(SRC_MOD:.c=.o)) SRC_QSTR += $(HEADER_BUILD)/sdiodata.h $(HEADER_BUILD)/sdiodata.h: tools/mksdiodata.py | $(HEADER_BUILD) - $(Q)$(PYTHON3) $< > $@ + $(Q)$(PYTHON) $< > $@ SRC_QSTR += $(HEADER_BUILD)/candata.h $(HEADER_BUILD)/candata.h: tools/mkcandata.py | $(HEADER_BUILD) - $(Q)$(PYTHON3) $< > $@ + $(Q)$(PYTHON) $< > $@ SRC_QSTR += $(SRC_C) $(SRC_SUPERVISOR) $(SRC_COMMON_HAL_EXPANDED) $(SRC_SHARED_MODULE_EXPANDED) # Sources that only hold QSTRs after pre-processing. @@ -380,7 +380,7 @@ $(BUILD)/firmware.elf: $(OBJ) $(GENERATED_LD_FILE) $(STEPECHO) "LINK $@" $(Q)echo $(OBJ) > $(BUILD)/firmware.objs $(Q)$(CC) -o $@ $(LDFLAGS) @$(BUILD)/firmware.objs -Wl,--start-group $(LIBS) -Wl,--end-group - $(Q)$(SIZE) $@ | $(PYTHON3) $(TOP)/tools/build_memory_info.py $(GENERATED_LD_FILE) + $(Q)$(SIZE) $@ | $(PYTHON) $(TOP)/tools/build_memory_info.py $(GENERATED_LD_FILE) $(BUILD)/firmware.bin: $(BUILD)/firmware.elf $(STEPECHO) "Create $@" @@ -388,7 +388,7 @@ $(BUILD)/firmware.bin: $(BUILD)/firmware.elf $(BUILD)/firmware.uf2: $(BUILD)/firmware.bin $(STEPECHO) "Create $@" - $(Q)$(PYTHON3) $(TOP)/tools/uf2/utils/uf2conv.py -b $(BOOTLOADER_SIZE) -c -o $@ $^ + $(Q)$(PYTHON) $(TOP)/tools/uf2/utils/uf2conv.py -b $(BOOTLOADER_SIZE) -c -o $@ $^ include $(TOP)/py/mkrules.mk diff --git a/ports/atmel-samd/audio_dma.c b/ports/atmel-samd/audio_dma.c index d7ec9dcd07..4dbb0a0006 100644 --- a/ports/atmel-samd/audio_dma.c +++ b/ports/atmel-samd/audio_dma.c @@ -396,7 +396,7 @@ STATIC void dma_callback_fun(void *arg) { } } -void audio_evsys_handler(void) { +void audio_dma_evsys_handler(void) { for (uint8_t i = 0; i < AUDIO_DMA_CHANNEL_COUNT; i++) { audio_dma_t *dma = audio_dma_state[i]; if (dma == NULL) { diff --git a/ports/atmel-samd/audio_dma.h b/ports/atmel-samd/audio_dma.h index 0b5f35c71b..cc41b0ae78 100644 --- a/ports/atmel-samd/audio_dma.h +++ b/ports/atmel-samd/audio_dma.h @@ -101,6 +101,6 @@ void audio_dma_background(void); uint8_t find_sync_event_channel_raise(void); -void audio_evsys_handler(void); +void audio_dma_evsys_handler(void); #endif // MICROPY_INCLUDED_ATMEL_SAMD_AUDIO_DMA_H diff --git a/ports/atmel-samd/bindings/samd/__init__.c b/ports/atmel-samd/bindings/samd/__init__.c index 207a6d52e6..b5c618108d 100644 --- a/ports/atmel-samd/bindings/samd/__init__.c +++ b/ports/atmel-samd/bindings/samd/__init__.c @@ -57,3 +57,5 @@ const mp_obj_module_t samd_module = { .base = { &mp_type_module }, .globals = (mp_obj_dict_t *)&samd_module_globals, }; + +MP_REGISTER_MODULE(MP_QSTR_samd, samd_module, CIRCUITPY_SAMD); diff --git a/ports/atmel-samd/boards/dynalora_usb/mpconfigboard.mk b/ports/atmel-samd/boards/dynalora_usb/mpconfigboard.mk index 3c88b60a37..a2e06fe617 100644 --- a/ports/atmel-samd/boards/dynalora_usb/mpconfigboard.mk +++ b/ports/atmel-samd/boards/dynalora_usb/mpconfigboard.mk @@ -17,4 +17,3 @@ CIRCUITPY_SDCARDIO = 1 FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_RFM9x -FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_SD diff --git a/ports/atmel-samd/boards/pybadge/mpconfigboard.mk b/ports/atmel-samd/boards/pybadge/mpconfigboard.mk index b5fda72f90..7f4278c90d 100644 --- a/ports/atmel-samd/boards/pybadge/mpconfigboard.mk +++ b/ports/atmel-samd/boards/pybadge/mpconfigboard.mk @@ -12,6 +12,7 @@ LONGINT_IMPL = MPZ CIRCUITPY_AESIO = 0 CIRCUITPY_GAMEPADSHIFT = 1 +CIRCUITPY_GIFIO = 0 CIRCUITPY_STAGE = 1 FROZEN_MPY_DIRS += $(TOP)/frozen/circuitpython-stage/pybadge diff --git a/ports/atmel-samd/boards/pycubed/board.c b/ports/atmel-samd/boards/pycubed/board.c index 2777b9031c..41e4655102 100644 --- a/ports/atmel-samd/boards/pycubed/board.c +++ b/ports/atmel-samd/boards/pycubed/board.c @@ -24,25 +24,12 @@ * THE SOFTWARE. */ - -#include - #include "supervisor/board.h" -#include "py/mpconfig.h" -#include "shared-bindings/nvm/ByteArray.h" +#include "mpconfigboard.h" #include "common-hal/microcontroller/Pin.h" #include "hal/include/hal_gpio.h" #include "shared-bindings/pwmio/PWMOut.h" -nvm_bytearray_obj_t bootcnt = { - .base = { - .type = &nvm_bytearray_type - }, - .len = (uint32_t)8192, - .start_address = (uint8_t *)(0x00080000 - 8192) -}; - - void board_init(void) { pwmio_pwmout_obj_t pwm; common_hal_pwmio_pwmout_construct(&pwm, &pin_PA23, 4096, 2, false); @@ -54,8 +41,7 @@ bool board_requests_safe_mode(void) { } void reset_board(void) { - uint8_t value_out = 0; - common_hal_nvm_bytearray_get_bytes(&bootcnt,0,1,&value_out); - ++value_out; - common_hal_nvm_bytearray_set_bytes(&bootcnt,0,&value_out,1); +} + +void board_deinit(void) { } diff --git a/ports/atmel-samd/boards/pycubed/mpconfigboard.h b/ports/atmel-samd/boards/pycubed/mpconfigboard.h index 3df0afd6b5..2d4d489d21 100644 --- a/ports/atmel-samd/boards/pycubed/mpconfigboard.h +++ b/ports/atmel-samd/boards/pycubed/mpconfigboard.h @@ -15,6 +15,9 @@ // External flash W25Q80DV #define EXTERNAL_FLASH_QSPI_DUAL +#define CIRCUITPY_DRIVE_LABEL "PYCUBED" +#define CIRCUITPY_BOOT_COUNTER 1 + #define BOARD_HAS_CRYSTAL 1 #define DEFAULT_I2C_BUS_SCL (&pin_PB13) diff --git a/ports/atmel-samd/boards/pycubed/mpconfigboard.mk b/ports/atmel-samd/boards/pycubed/mpconfigboard.mk index 3eda028754..347462919f 100644 --- a/ports/atmel-samd/boards/pycubed/mpconfigboard.mk +++ b/ports/atmel-samd/boards/pycubed/mpconfigboard.mk @@ -10,17 +10,25 @@ QSPI_FLASH_FILESYSTEM = 1 EXTERNAL_FLASH_DEVICES = W25Q80DV LONGINT_IMPL = MPZ -CIRCUITPY_DRIVE_LABEL = "PYCUBED" +CIRCUITPY_ULAB = 1 +CIRCUITPY_BINASCII = 1 +CIRCUITPY_SDCARDIO = 1 +CIRCUITPY_JSON = 1 +CIRCUITPY_MSGPACK = 1 +CIRCUITPY_ALARM = 1 -# Not needed. +# no SAMD51 support... yet ;) +# CIRCUITPY_DUALBANK=1 + +# Not needed CIRCUITPY_AUDIOBUSIO = 0 -CIRCUITPY_BITMAPTOOLS = 0 CIRCUITPY_DISPLAYIO = 0 CIRCUITPY_FRAMEBUFFERIO = 0 CIRCUITPY_KEYPAD = 0 CIRCUITPY_RGBMATRIX = 0 CIRCUITPY_PS2IO = 0 +CIRCUITPY_BLEIO_HCI=0 +CIRCUITPY_BLEIO=0 FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Register -FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_SD diff --git a/ports/atmel-samd/boards/pycubed_mram/board.c b/ports/atmel-samd/boards/pycubed_mram/board.c index 2777b9031c..41e4655102 100644 --- a/ports/atmel-samd/boards/pycubed_mram/board.c +++ b/ports/atmel-samd/boards/pycubed_mram/board.c @@ -24,25 +24,12 @@ * THE SOFTWARE. */ - -#include - #include "supervisor/board.h" -#include "py/mpconfig.h" -#include "shared-bindings/nvm/ByteArray.h" +#include "mpconfigboard.h" #include "common-hal/microcontroller/Pin.h" #include "hal/include/hal_gpio.h" #include "shared-bindings/pwmio/PWMOut.h" -nvm_bytearray_obj_t bootcnt = { - .base = { - .type = &nvm_bytearray_type - }, - .len = (uint32_t)8192, - .start_address = (uint8_t *)(0x00080000 - 8192) -}; - - void board_init(void) { pwmio_pwmout_obj_t pwm; common_hal_pwmio_pwmout_construct(&pwm, &pin_PA23, 4096, 2, false); @@ -54,8 +41,7 @@ bool board_requests_safe_mode(void) { } void reset_board(void) { - uint8_t value_out = 0; - common_hal_nvm_bytearray_get_bytes(&bootcnt,0,1,&value_out); - ++value_out; - common_hal_nvm_bytearray_set_bytes(&bootcnt,0,&value_out,1); +} + +void board_deinit(void) { } diff --git a/ports/atmel-samd/boards/pycubed_mram/mpconfigboard.h b/ports/atmel-samd/boards/pycubed_mram/mpconfigboard.h index f7dfbae3a2..bd45a814fb 100644 --- a/ports/atmel-samd/boards/pycubed_mram/mpconfigboard.h +++ b/ports/atmel-samd/boards/pycubed_mram/mpconfigboard.h @@ -15,6 +15,9 @@ #define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE) +#define CIRCUITPY_DRIVE_LABEL "PYCUBED" +#define CIRCUITPY_BOOT_COUNTER 1 + #define BOARD_HAS_CRYSTAL 1 #define DEFAULT_I2C_BUS_SCL (&pin_PB13) diff --git a/ports/atmel-samd/boards/pycubed_mram/mpconfigboard.mk b/ports/atmel-samd/boards/pycubed_mram/mpconfigboard.mk index ccf3050d11..ac8af21dcb 100644 --- a/ports/atmel-samd/boards/pycubed_mram/mpconfigboard.mk +++ b/ports/atmel-samd/boards/pycubed_mram/mpconfigboard.mk @@ -10,17 +10,25 @@ QSPI_FLASH_FILESYSTEM = 1 EXTERNAL_FLASH_DEVICES = MR2xH40 LONGINT_IMPL = MPZ -CIRCUITPY_DRIVE_LABEL = "PYCUBED" +CIRCUITPY_ULAB = 1 +CIRCUITPY_BINASCII = 1 +CIRCUITPY_SDCARDIO = 1 +CIRCUITPY_JSON = 1 +CIRCUITPY_MSGPACK = 1 +CIRCUITPY_ALARM = 1 -# Not needed. +# no SAMD51 support... yet ;) +# CIRCUITPY_DUALBANK=1 + +# Not needed CIRCUITPY_AUDIOBUSIO = 0 -CIRCUITPY_BITMAPTOOLS = 0 CIRCUITPY_DISPLAYIO = 0 CIRCUITPY_FRAMEBUFFERIO = 0 CIRCUITPY_KEYPAD = 0 CIRCUITPY_RGBMATRIX = 0 CIRCUITPY_PS2IO = 0 +CIRCUITPY_BLEIO_HCI=0 +CIRCUITPY_BLEIO=0 FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Register -FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_SD diff --git a/ports/atmel-samd/boards/pycubed_mram_v05/board.c b/ports/atmel-samd/boards/pycubed_mram_v05/board.c index 032ad7b2e7..41e4655102 100644 --- a/ports/atmel-samd/boards/pycubed_mram_v05/board.c +++ b/ports/atmel-samd/boards/pycubed_mram_v05/board.c @@ -42,3 +42,6 @@ bool board_requests_safe_mode(void) { void reset_board(void) { } + +void board_deinit(void) { +} diff --git a/ports/atmel-samd/boards/pycubed_mram_v05/mpconfigboard.mk b/ports/atmel-samd/boards/pycubed_mram_v05/mpconfigboard.mk index 2da146ae46..ac8af21dcb 100644 --- a/ports/atmel-samd/boards/pycubed_mram_v05/mpconfigboard.mk +++ b/ports/atmel-samd/boards/pycubed_mram_v05/mpconfigboard.mk @@ -15,9 +15,9 @@ CIRCUITPY_BINASCII = 1 CIRCUITPY_SDCARDIO = 1 CIRCUITPY_JSON = 1 CIRCUITPY_MSGPACK = 1 +CIRCUITPY_ALARM = 1 # no SAMD51 support... yet ;) -# CIRCUITPY_ALARM = 1 # CIRCUITPY_DUALBANK=1 # Not needed diff --git a/ports/atmel-samd/boards/pycubed_v05/board.c b/ports/atmel-samd/boards/pycubed_v05/board.c index 032ad7b2e7..41e4655102 100644 --- a/ports/atmel-samd/boards/pycubed_v05/board.c +++ b/ports/atmel-samd/boards/pycubed_v05/board.c @@ -42,3 +42,6 @@ bool board_requests_safe_mode(void) { void reset_board(void) { } + +void board_deinit(void) { +} diff --git a/ports/atmel-samd/boards/pycubed_v05/mpconfigboard.mk b/ports/atmel-samd/boards/pycubed_v05/mpconfigboard.mk index 95916db076..923ab2eaae 100644 --- a/ports/atmel-samd/boards/pycubed_v05/mpconfigboard.mk +++ b/ports/atmel-samd/boards/pycubed_v05/mpconfigboard.mk @@ -16,9 +16,9 @@ CIRCUITPY_BINASCII = 1 CIRCUITPY_SDCARDIO = 1 CIRCUITPY_JSON = 1 CIRCUITPY_MSGPACK = 1 +CIRCUITPY_ALARM = 1 # no SAMD51 support... yet ;) -# CIRCUITPY_ALARM = 1 # CIRCUITPY_DUALBANK=1 # Not needed diff --git a/ports/atmel-samd/boards/pygamer/mpconfigboard.mk b/ports/atmel-samd/boards/pygamer/mpconfigboard.mk index 5b5a84bb78..408efc9dc0 100644 --- a/ports/atmel-samd/boards/pygamer/mpconfigboard.mk +++ b/ports/atmel-samd/boards/pygamer/mpconfigboard.mk @@ -12,6 +12,7 @@ LONGINT_IMPL = MPZ CIRCUITPY_AESIO = 0 CIRCUITPY_GAMEPADSHIFT = 1 +CIRCUITPY_GIFIO = 0 CIRCUITPY_STAGE = 1 FROZEN_MPY_DIRS += $(TOP)/frozen/circuitpython-stage/pygamer diff --git a/ports/atmel-samd/boards/seeeduino_xiao_kb/board.c b/ports/atmel-samd/boards/seeeduino_xiao_kb/board.c new file mode 100644 index 0000000000..7af05ba45a --- /dev/null +++ b/ports/atmel-samd/boards/seeeduino_xiao_kb/board.c @@ -0,0 +1,39 @@ +/* + * 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" +#include "hal/include/hal_gpio.h" + +void board_init(void) { +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { +} diff --git a/ports/atmel-samd/boards/seeeduino_xiao_kb/mpconfigboard.h b/ports/atmel-samd/boards/seeeduino_xiao_kb/mpconfigboard.h new file mode 100644 index 0000000000..85a3ec36c0 --- /dev/null +++ b/ports/atmel-samd/boards/seeeduino_xiao_kb/mpconfigboard.h @@ -0,0 +1,7 @@ +#define MICROPY_HW_BOARD_NAME "Seeeduino XIAO KB" +#define MICROPY_HW_MCU_NAME "samd21g18" + + +// USB is always used internally so skip the pin objects for it. +#define IGNORE_PIN_PA24 1 +#define IGNORE_PIN_PA25 1 diff --git a/ports/atmel-samd/boards/seeeduino_xiao_kb/mpconfigboard.mk b/ports/atmel-samd/boards/seeeduino_xiao_kb/mpconfigboard.mk new file mode 100644 index 0000000000..7a67048e0b --- /dev/null +++ b/ports/atmel-samd/boards/seeeduino_xiao_kb/mpconfigboard.mk @@ -0,0 +1,35 @@ +USB_VID = 0x2886 +USB_PID = 0x802F +# VID & PID Provided by Seeed +USB_PRODUCT = "Seeeduino XIAO KB" +USB_MANUFACTURER = "Seeed" + +CHIP_VARIANT = SAMD21G18A +CHIP_FAMILY = samd21 + +INTERNAL_FLASH_FILESYSTEM = 1 +LONGINT_IMPL = NONE +CIRCUITPY_FULL_BUILD = 0 + +# A number of modules are removed +# Many I/O functions are not available or not used in a keyboard +# CIRCUITPY_ANALOGIO = 1 # Needed for potentiometer input (mouse) +CIRCUITPY_AUDIOCORE = 0 +CIRCUITPY_BUSIO = 0 # Needed for I2C, SPI and UART - removed that for keyboards... +CIRCUITPY_PULSEIO = 0 +# CIRCUITPY_PWMIO = 1 # only needed for speaker or LED PWM functions. Takes 2314 bytes. +CIRCUITPY_RTC = 0 +CIRCUITPY_MATH = 0 +#CIRCUITPY_RANDOM = 0 +CIRCUITPY_ONEWIREIO = 0 +#CIRCUITPY_NEOPIXEL_WRITE = 1 # Needed fo RGB LEDs +#CIRCUITPY_RAINBOWIO = 1 # Needed fo RGB LEDs +# These are used in a keyboard or computer input device. +CIRCUITPY_ROTARYIO = 1 +CIRCUITPY_KEYPAD = 1 +CIRCUITPY_USB_HID = 1 +CIRCUITPY_USB_MIDI = 1 + +# Include these Python libraries in firmware. +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_HID +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel diff --git a/ports/atmel-samd/boards/seeeduino_xiao_kb/pins.c b/ports/atmel-samd/boards/seeeduino_xiao_kb/pins.c new file mode 100644 index 0000000000..e2c10330a9 --- /dev/null +++ b/ports/atmel-samd/boards/seeeduino_xiao_kb/pins.c @@ -0,0 +1,38 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_global_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_board_id), MP_ROM_PTR(&board_module_id_obj) }, + + // Analog pins + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA02) }, + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PA04) }, + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PA10) }, + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PA11) }, + { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PA08) }, + { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_PA09) }, + { MP_ROM_QSTR(MP_QSTR_A6), MP_ROM_PTR(&pin_PB08) }, + { MP_ROM_QSTR(MP_QSTR_A7), MP_ROM_PTR(&pin_PB09) }, + { MP_ROM_QSTR(MP_QSTR_A8), MP_ROM_PTR(&pin_PA07) }, + { MP_ROM_QSTR(MP_QSTR_A9), MP_ROM_PTR(&pin_PA05) }, + { MP_ROM_QSTR(MP_QSTR_A10), MP_ROM_PTR(&pin_PA06) }, + + // Digital pins + { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_PA02) }, + { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_PA04) }, + { MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_PA10) }, + { MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_PA11) }, + { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_PA08) }, + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_PA09) }, + { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PB08) }, + { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_PB09) }, + { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_PA07) }, + { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_PA05) }, + { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PA06) }, + { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_PA17) }, + + // LED pins + { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_PA17) }, // status + { MP_ROM_QSTR(MP_QSTR_BLUE_LED), MP_ROM_PTR(&pin_PA17) }, + +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table); diff --git a/ports/atmel-samd/boards/sensebox_mcu/mpconfigboard.mk b/ports/atmel-samd/boards/sensebox_mcu/mpconfigboard.mk index f59483a608..bdfe26068d 100644 --- a/ports/atmel-samd/boards/sensebox_mcu/mpconfigboard.mk +++ b/ports/atmel-samd/boards/sensebox_mcu/mpconfigboard.mk @@ -13,4 +13,3 @@ 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/xinabox_cs11/mpconfigboard.mk b/ports/atmel-samd/boards/xinabox_cs11/mpconfigboard.mk index e0bec4e623..2723e17827 100644 --- a/ports/atmel-samd/boards/xinabox_cs11/mpconfigboard.mk +++ b/ports/atmel-samd/boards/xinabox_cs11/mpconfigboard.mk @@ -22,6 +22,3 @@ CIRCUITPY_TOUCHIO=0 CIRCUITPY_USB_MIDI=0 CIRCUITPY_RTC=0 CIRCUITPY_SDCARDIO=1 - -# Include these Python libraries in firmware. -FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_SD diff --git a/ports/atmel-samd/common-hal/alarm/SleepMemory.c b/ports/atmel-samd/common-hal/alarm/SleepMemory.c new file mode 100644 index 0000000000..cb3b1b3aa9 --- /dev/null +++ b/ports/atmel-samd/common-hal/alarm/SleepMemory.c @@ -0,0 +1,50 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 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. + */ + +#include + +#include "py/runtime.h" +#include "common-hal/alarm/SleepMemory.h" +#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; +} + +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; +} + +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")); + return; +} diff --git a/ports/atmel-samd/common-hal/alarm/SleepMemory.h b/ports/atmel-samd/common-hal/alarm/SleepMemory.h new file mode 100644 index 0000000000..a922ff324a --- /dev/null +++ b/ports/atmel-samd/common-hal/alarm/SleepMemory.h @@ -0,0 +1,40 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 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. + */ + +#ifndef MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_ALARM_SLEEPMEMORY_H +#define MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_ALARM_SLEEPMEMORY_H + +#include "py/obj.h" + +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); + +#endif // MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_ALARM_SLEEPMEMORY_H diff --git a/ports/atmel-samd/common-hal/alarm/__init__.c b/ports/atmel-samd/common-hal/alarm/__init__.c new file mode 100644 index 0000000000..66b42a3062 --- /dev/null +++ b/ports/atmel-samd/common-hal/alarm/__init__.c @@ -0,0 +1,261 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 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. + */ + +#include "py/gc.h" +#include "py/obj.h" +#include "py/objtuple.h" +#include "py/runtime.h" + +#include "shared-bindings/alarm/__init__.h" +#include "shared-bindings/alarm/SleepMemory.h" +#include "shared-bindings/alarm/pin/PinAlarm.h" +#include "shared-bindings/alarm/time/TimeAlarm.h" +#include "shared-bindings/microcontroller/__init__.h" +#include "shared/runtime/interrupt_char.h" +#include "samd/external_interrupts.h" +#include "supervisor/port.h" +#include "supervisor/workflow.h" + +// 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; +} + +bool common_hal_alarm_woken_from_sleep(void) { + return alarm_get_wakeup_cause() != SAMD_WAKEUP_UNDEF; +} + +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; + } + return mp_const_none; +} + +// Set up light sleep or deep sleep alarms. +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; + + 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); + 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)) { + __set_FPSCR(__get_FPSCR() & ~(0x9f)); + (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) { + ; + } + + __DSB(); // Data Synchronization Barrier + __WFI(); // Wait For Interrupt + // Enable RTC interrupts + NVIC_EnableIRQ(RTC_IRQn); + // END ATTEMPT ------------------------------ + } + 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; +} + +void common_hal_alarm_set_deep_sleep_alarms(size_t n_alarms, const mp_obj_t *alarms) { + _setup_sleep_alarms(true, n_alarms, alarms); +} + +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? + + // cache alarm flag since backup registers about to be reset + uint32_t _SAMD_ALARM_FLAG = SAMD_ALARM_FLAG; + + // Clear the FPU interrupt because it can prevent us from sleeping. + if (__get_FPSCR() & ~(0x9f)) { + __set_FPSCR(__get_FPSCR() & ~(0x9f)); + (void)__get_FPSCR(); + } + + NVIC_DisableIRQ(RTC_IRQn); + // 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 + + // Check if we're setting TimeAlarm + if (_SAMD_ALARM_FLAG & SAMD_ALARM_FLAG_TIME) { + RTC->MODE0.COMP[1].reg = (_target / 1024) * 32; + 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 + RTC->MODE0.INTENSET.reg = RTC_MODE0_INTENSET_TAMPER; + } + + // 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 + ; + } + 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 + __WFI(); // Wait For Interrupt + + // The above shuts down RAM and triggers a reset, so we should never hit this + while (1) { + ; + } +} + +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; + } +} + +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 new file mode 100644 index 0000000000..5e777bdf87 --- /dev/null +++ b/ports/atmel-samd/common-hal/alarm/__init__.h @@ -0,0 +1,52 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 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. + */ + +#ifndef MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_ALARM__INIT__H +#define MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_ALARM__INIT__H + +#include "common-hal/alarm/SleepMemory.h" + +extern const alarm_sleep_memory_obj_t alarm_sleep_memory_obj; + +// This is the first byte of the BKUP register bank. +// We use it to store which alarms are set. +#ifndef SAMD_ALARM_FLAG +#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) +#endif + +typedef enum { + SAMD_WAKEUP_UNDEF, + SAMD_WAKEUP_GPIO, + SAMD_WAKEUP_RTC +} samd_sleep_source_t; + +extern void alarm_set_wakeup_reason(samd_sleep_source_t reason); +samd_sleep_source_t 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 new file mode 100644 index 0000000000..2e1d596c39 --- /dev/null +++ b/ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c @@ -0,0 +1,276 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 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. + */ + +#include "py/runtime.h" +#include "samd/external_interrupts.h" +#include "eic_handler.h" +#include "atmel_start_pins.h" +#include "hal/include/hal_gpio.h" +// #include + +#include "shared-bindings/alarm/pin/PinAlarm.h" +#include "shared-bindings/microcontroller/__init__.h" +#include "shared-bindings/microcontroller/Pin.h" +#include "common-hal/alarm/__init__.h" + +// 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; + +// 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]; + +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 + + if (pinalarm_on) { + // clear flag and interrupt setting + 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; + } +} + +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->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) { + return self->pin; +} + +bool common_hal_alarm_pin_pinalarm_get_value(alarm_pin_pinalarm_obj_t *self) { + return self->value; +} + +bool common_hal_alarm_pin_pinalarm_get_edge(alarm_pin_pinalarm_obj_t *self) { + return true; +} + +bool common_hal_alarm_pin_pinalarm_get_pull(alarm_pin_pinalarm_obj_t *self) { + return self->pull; +} + +bool alarm_pin_pinalarm_woke_this_cycle(void) { + if (pinalarm_on && RTC->MODE0.INTFLAG.bit.TAMPER) { + woke_up = true; + } + return woke_up; +} + +mp_obj_t alarm_pin_pinalarm_find_triggered_alarm(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)) { + 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. + } + // 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; +} + +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; + 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.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(); +} + +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 + 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 (alarm->pin != &pin_PB00 && alarm->pin != &pin_PB02 && + 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 + } + } +} + +void alarm_pin_pinalarm_prepare_for_deep_sleep(void) { + // TODO: This function is called after the VM reset, right before + // the program actually enters deep sleep. If the VM reset + // (see port_reset) resets any pins/EVSYS settings/RTC values + // needed by the pinalarms, this function is responsible for setting them + // back up again. +} diff --git a/ports/atmel-samd/common-hal/alarm/pin/PinAlarm.h b/ports/atmel-samd/common-hal/alarm/pin/PinAlarm.h new file mode 100644 index 0000000000..f3cd4cf27b --- /dev/null +++ b/ports/atmel-samd/common-hal/alarm/pin/PinAlarm.h @@ -0,0 +1,50 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 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. + */ + +#ifndef MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_ALARM_PINALARM_H +#define MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_ALARM_PINALARM_H + +#include "py/obj.h" +#include "py/objtuple.h" + +typedef struct { + mp_obj_base_t base; + const mcu_pin_obj_t *pin; + bool value; + 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); + +void pin_alarm_callback(uint8_t num); +void alarm_pin_pinalarm_reset(void); +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); + +#endif // MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_ALARM_PINALARM_H diff --git a/ports/atmel-samd/common-hal/alarm/time/TimeAlarm.c b/ports/atmel-samd/common-hal/alarm/time/TimeAlarm.c new file mode 100644 index 0000000000..49ce90a0b6 --- /dev/null +++ b/ports/atmel-samd/common-hal/alarm/time/TimeAlarm.c @@ -0,0 +1,168 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 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. + */ + +#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; + +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? + + self->monotonic_time = monotonic_time; +} + +mp_float_t common_hal_alarm_time_timealarm_get_monotonic_time(alarm_time_timealarm_obj_t *self) { + return self->monotonic_time; +} + +mp_obj_t alarm_time_timealarm_find_triggered_alarm(size_t n_alarms, const mp_obj_t *alarms) { + // TODO: this function currently assumes you can only have a single TimeAlarm + // If you want to support more, it will need to somehow detect which one went off. + for (size_t i = 0; i < n_alarms; i++) { + if (mp_obj_is_type(alarms[i], &alarm_time_timealarm_type)) { + return alarms[i]; + } + } + return mp_const_none; +} + +mp_obj_t alarm_time_timealarm_create_wakeup_alarm(void) { + alarm_time_timealarm_obj_t *timer = m_new_obj(alarm_time_timealarm_obj_t); + timer->base.type = &alarm_time_timealarm_type; + // TODO: Set monotonic_time based on the RTC state. + // Or don't, most of the other ports don't have this either. + timer->monotonic_time = 0.0f; + return timer; +} + +void time_alarm_callback(void) { + if (timealarm_on) { + RTC->MODE0.INTENCLR.reg = RTC_MODE0_INTENCLR_CMP1; // clear flags + 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; + } + return woke_up; +} + +void alarm_time_timealarm_reset(void) { + timealarm_on = false; + woke_up = false; + SAMD_ALARM_FLAG &= ~SAMD_ALARM_FLAG_TIME; // clear flag +} + +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; + for (size_t i = 0; i < n_alarms; i++) { + if (!mp_obj_is_type(alarms[i], &alarm_time_timealarm_type)) { + continue; + } + if (timealarm_set) { + mp_raise_ValueError(translate("Only one alarm.time alarm can be set.")); + } + timealarm = MP_OBJ_TO_PTR(alarms[i]); + timealarm_set = true; + } + if (!timealarm_set) { + 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 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; + 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. + + RTC->MODE0.COMP[1].reg = deep_sleep_ticks; + while ((RTC->MODE0.SYNCBUSY.reg & (RTC_MODE0_SYNCBUSY_COMP1)) != 0) { + } + deep_sleep_ticks = 0; + } +} diff --git a/ports/atmel-samd/common-hal/alarm/time/TimeAlarm.h b/ports/atmel-samd/common-hal/alarm/time/TimeAlarm.h new file mode 100644 index 0000000000..a6102dee6b --- /dev/null +++ b/ports/atmel-samd/common-hal/alarm/time/TimeAlarm.h @@ -0,0 +1,46 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 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. + */ + +#ifndef MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_ALARM_TIMEALARM_H +#define MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_ALARM_TIMEALARM_H + +#include "py/obj.h" + +typedef struct { + mp_obj_base_t base; + mp_float_t monotonic_time; // values compatible with time.monotonic_time() +} alarm_time_timealarm_obj_t; + +mp_obj_t alarm_time_timealarm_find_triggered_alarm(size_t n_alarms, const mp_obj_t *alarms); +mp_obj_t alarm_time_timealarm_create_wakeup_alarm(void); +void time_alarm_callback(void); +bool alarm_time_timealarm_woke_this_cycle(void); +void alarm_time_timealarm_set_alarms(bool deep_sleep, size_t n_alarms, const mp_obj_t *alarms); +void alarm_time_timealarm_reset(void); + +void alarm_time_timealarm_prepare_for_deep_sleep(void); + +#endif // MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_ALARM_TIMEALARM_H diff --git a/ports/atmel-samd/common-hal/alarm/touch/TouchAlarm.c b/ports/atmel-samd/common-hal/alarm/touch/TouchAlarm.c new file mode 100644 index 0000000000..88c73726ee --- /dev/null +++ b/ports/atmel-samd/common-hal/alarm/touch/TouchAlarm.c @@ -0,0 +1,32 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 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. + */ + +#include "shared-bindings/alarm/touch/TouchAlarm.h" +#include "shared-bindings/microcontroller/__init__.h" + +void common_hal_alarm_touch_touchalarm_construct(alarm_touch_touchalarm_obj_t *self, const mcu_pin_obj_t *pin) { + mp_raise_NotImplementedError(translate("Touch alarms not available")); +} diff --git a/ports/atmel-samd/common-hal/alarm/touch/TouchAlarm.h b/ports/atmel-samd/common-hal/alarm/touch/TouchAlarm.h new file mode 100644 index 0000000000..d7f0f8cf1d --- /dev/null +++ b/ports/atmel-samd/common-hal/alarm/touch/TouchAlarm.h @@ -0,0 +1,35 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 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. + */ + +#ifndef MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_ALARM_TOUCHALARM_H +#define MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_ALARM_TOUCHALARM_H + +typedef struct { + mp_obj_base_t base; + const mcu_pin_obj_t *pin; +} alarm_touch_touchalarm_obj_t; + +#endif // MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_ALARM_TOUCHALARM_H diff --git a/ports/atmel-samd/common-hal/analogio/AnalogOut.c b/ports/atmel-samd/common-hal/analogio/AnalogOut.c index 1fa67dc9a1..91782387b8 100644 --- a/ports/atmel-samd/common-hal/analogio/AnalogOut.c +++ b/ports/atmel-samd/common-hal/analogio/AnalogOut.c @@ -85,8 +85,8 @@ void common_hal_analogio_analogout_construct(analogio_analogout_obj_t *self, _pm_enable_bus_clock(PM_BUS_APBC, DAC); #endif - // SAMD21: This clock should be <= 12 MHz, per datasheet section 47.6.3. - // SAMD51: This clock should be <= 350kHz, per datasheet table 37-6. + // SAMD21: This clock should be <= 350 kHz, per datasheet table 36-7. + // SAMD51: This clock should be <= 12 MHz, per datasheet section 47.6.3. _gclk_enable_channel(DAC_GCLK_ID, CONF_GCLK_DAC_SRC); // Don't double init the DAC on the SAMD51 when both outputs are in use. We use the free state diff --git a/ports/atmel-samd/common-hal/audiobusio/PDMIn.c b/ports/atmel-samd/common-hal/audiobusio/PDMIn.c index 6ea70e39dc..e00d69c848 100644 --- a/ports/atmel-samd/common-hal/audiobusio/PDMIn.c +++ b/ports/atmel-samd/common-hal/audiobusio/PDMIn.c @@ -35,6 +35,7 @@ #include "common-hal/audiobusio/PDMIn.h" #include "shared-bindings/analogio/AnalogOut.h" #include "shared-bindings/audiobusio/PDMIn.h" +#include "shared-bindings/microcontroller/__init__.h" #include "shared-bindings/microcontroller/Pin.h" #include "supervisor/shared/translate.h" @@ -64,7 +65,20 @@ #define SERCTRL(name) I2S_RXCTRL_ ## name #endif +// Set by interrupt handler when DMA block has finished transferring. +static 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; + +void pdmin_evsys_handler(void) { + if (pdmin_event_channel < EVSYS_SYNCH_NUM && event_interrupt_active(pdmin_event_channel)) { + pdmin_dma_block_done = true; + } +} + void pdmin_reset(void) { + pdmin_event_channel = EVSYS_SYNCH_NUM; + while (I2S->SYNCBUSY.reg & I2S_SYNCBUSY_ENABLE) {} I2S->INTENCLR.reg = I2S_INTENCLR_MASK; I2S->INTFLAG.reg = I2S_INTFLAG_MASK; @@ -368,7 +382,8 @@ static uint16_t filter_sample(uint32_t pdm_samples[4]) { uint32_t common_hal_audiobusio_pdmin_record_to_buffer(audiobusio_pdmin_obj_t* self, uint16_t* output_buffer, uint32_t output_buffer_length) { uint8_t dma_channel = dma_allocate_channel(); - uint8_t event_channel = find_sync_event_channel_raise(); + pdmin_event_channel = find_sync_event_channel_raise(); + pdmin_dma_block_done = false; // We allocate two buffers on the stack to use for double buffering. const uint8_t samples_per_buffer = SAMPLES_PER_BUFFER; @@ -391,7 +406,7 @@ uint32_t common_hal_audiobusio_pdmin_record_to_buffer(audiobusio_pdmin_obj_t* se #endif dma_configure(dma_channel, trigger_source, true); - init_event_channel_interrupt(event_channel, CORE_GCLK, EVSYS_ID_GEN_DMAC_CH_0 + dma_channel); + 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); audio_dma_enable_channel(dma_channel); @@ -402,23 +417,12 @@ uint32_t common_hal_audiobusio_pdmin_record_to_buffer(audiobusio_pdmin_obj_t* se uint32_t remaining_samples_needed = output_buffer_length; while (values_output < output_buffer_length) { - if (event_interrupt_overflow(event_channel)) { - // Looks like we aren't keeping up. We shouldn't skip a buffer so stop early. - break; - } - // Wait for the next buffer to fill - uint32_t wait_counts = 0; - #ifdef SAMD21 - #define MAX_WAIT_COUNTS 1000 - #endif - #ifdef SAM_D5X_E5X - #define MAX_WAIT_COUNTS 6000 - #endif - // If wait_counts exceeds the max count, buffer has probably stopped filling; - // DMA may have missed an I2S trigger event. - while (!event_interrupt_active(event_channel) && ++wait_counts < MAX_WAIT_COUNTS) { + while (!pdmin_dma_block_done) { RUN_BACKGROUND_TASKS; } + common_hal_mcu_disable_interrupts(); + pdmin_dma_block_done = false; + common_hal_mcu_enable_interrupts(); // The mic is running all the time, so we don't need to wait the usual 10msec or 100msec // for it to start up. @@ -430,6 +434,7 @@ uint32_t common_hal_audiobusio_pdmin_record_to_buffer(audiobusio_pdmin_obj_t* se buffer = second_buffer; descriptor = &second_descriptor; } + // Decimate and filter the buffer that was just filled. uint32_t samples_gathered = descriptor->BTCNT.reg / words_per_sample; // Don't run off the end of output buffer. Process only as many as needed. @@ -472,7 +477,8 @@ uint32_t common_hal_audiobusio_pdmin_record_to_buffer(audiobusio_pdmin_obj_t* se } } - disable_event_channel(event_channel); + disable_event_channel(pdmin_event_channel); + pdmin_event_channel = EVSYS_SYNCH_NUM; // Invalid event_channel. dma_free_channel(dma_channel); // Turn off serializer, but leave clock on, to avoid mic startup delay. i2s_set_serializer_enable(self->serializer, false); @@ -481,5 +487,4 @@ uint32_t common_hal_audiobusio_pdmin_record_to_buffer(audiobusio_pdmin_obj_t* se } void common_hal_audiobusio_pdmin_record_to_file(audiobusio_pdmin_obj_t* self, uint8_t* buffer, uint32_t length) { - } diff --git a/ports/atmel-samd/common-hal/audiobusio/PDMIn.h b/ports/atmel-samd/common-hal/audiobusio/PDMIn.h index 5c4d4feea0..7f00886d29 100644 --- a/ports/atmel-samd/common-hal/audiobusio/PDMIn.h +++ b/ports/atmel-samd/common-hal/audiobusio/PDMIn.h @@ -46,6 +46,8 @@ typedef struct { void pdmin_reset(void); +void pdmin_evsys_handler(void); + void pdmin_background(void); #endif // MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_AUDIOBUSIO_AUDIOOUT_H diff --git a/ports/atmel-samd/common-hal/busio/I2C.c b/ports/atmel-samd/common-hal/busio/I2C.c index 39aa6c9e97..7d77c0d43a 100644 --- a/ports/atmel-samd/common-hal/busio/I2C.c +++ b/ports/atmel-samd/common-hal/busio/I2C.c @@ -36,7 +36,7 @@ #include "shared-bindings/microcontroller/__init__.h" #include "supervisor/shared/translate.h" -#include "common-hal/busio/SPI.h" // for never_reset_sercom +#include "common-hal/busio/__init__.h" // Number of times to try to send packet if failed. #define ATTEMPTS 2 diff --git a/ports/atmel-samd/common-hal/busio/SPI.c b/ports/atmel-samd/common-hal/busio/SPI.c index 884c3e0414..3b60c1d2b4 100644 --- a/ports/atmel-samd/common-hal/busio/SPI.c +++ b/ports/atmel-samd/common-hal/busio/SPI.c @@ -32,7 +32,9 @@ #include "peripheral_clk_config.h" #include "supervisor/board.h" +#include "common-hal/busio/__init__.h" #include "common-hal/microcontroller/Pin.h" + #include "hal/include/hal_gpio.h" #include "hal/include/hal_spi_m_sync.h" #include "hal/include/hpl_spi_m_sync.h" @@ -40,43 +42,6 @@ #include "samd/dma.h" #include "samd/sercom.h" -bool never_reset_sercoms[SERCOM_INST_NUM]; - -void never_reset_sercom(Sercom *sercom) { - // Reset all SERCOMs except the ones being used by on-board devices. - Sercom *sercom_instances[SERCOM_INST_NUM] = SERCOM_INSTS; - for (int i = 0; i < SERCOM_INST_NUM; i++) { - if (sercom_instances[i] == sercom) { - never_reset_sercoms[i] = true; - break; - } - } -} - -void allow_reset_sercom(Sercom *sercom) { - // Reset all SERCOMs except the ones being used by on-board devices. - Sercom *sercom_instances[SERCOM_INST_NUM] = SERCOM_INSTS; - for (int i = 0; i < SERCOM_INST_NUM; i++) { - if (sercom_instances[i] == sercom) { - never_reset_sercoms[i] = false; - break; - } - } -} - -void reset_sercoms(void) { - // Reset all SERCOMs except the ones being used by on-board devices. - Sercom *sercom_instances[SERCOM_INST_NUM] = SERCOM_INSTS; - for (int i = 0; i < SERCOM_INST_NUM; i++) { - if (never_reset_sercoms[i]) { - continue; - } - // SWRST is same for all modes of SERCOMs. - sercom_instances[i]->SPI.CTRLA.bit.SWRST = 1; - } -} - - 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) { diff --git a/ports/atmel-samd/common-hal/busio/SPI.h b/ports/atmel-samd/common-hal/busio/SPI.h index 27bbfdeb3a..2fced6d642 100644 --- a/ports/atmel-samd/common-hal/busio/SPI.h +++ b/ports/atmel-samd/common-hal/busio/SPI.h @@ -42,8 +42,4 @@ typedef struct { uint8_t MISO_pin; } busio_spi_obj_t; -void reset_sercoms(void); -void never_reset_sercom(Sercom *sercom); - - #endif // MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_BUSIO_SPI_H diff --git a/ports/atmel-samd/common-hal/busio/UART.c b/ports/atmel-samd/common-hal/busio/UART.c index c33bf6f440..194f1c0217 100644 --- a/ports/atmel-samd/common-hal/busio/UART.c +++ b/ports/atmel-samd/common-hal/busio/UART.c @@ -28,7 +28,7 @@ #include "shared-bindings/busio/UART.h" #include "mpconfigport.h" -#include "lib/utils/interrupt_char.h" +#include "shared/runtime/interrupt_char.h" #include "py/gc.h" #include "py/mperrno.h" #include "py/runtime.h" @@ -45,7 +45,7 @@ #include "samd/sercom.h" -#include "common-hal/busio/SPI.h" // for never_reset_sercom +#include "common-hal/busio/__init__.h" #define UART_DEBUG(...) (void)0 // #define UART_DEBUG(...) mp_printf(&mp_plat_print __VA_OPT__(,) __VA_ARGS__) diff --git a/ports/atmel-samd/common-hal/busio/__init__.c b/ports/atmel-samd/common-hal/busio/__init__.c index 41761b6743..8ec549e931 100644 --- a/ports/atmel-samd/common-hal/busio/__init__.c +++ b/ports/atmel-samd/common-hal/busio/__init__.c @@ -1 +1,63 @@ -// No busio module functions. +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2016 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. + */ + +#include "samd/sercom.h" + +static bool never_reset_sercoms[SERCOM_INST_NUM]; + +void never_reset_sercom(Sercom *sercom) { + // Reset all SERCOMs except the ones being used by on-board devices. + Sercom *sercom_instances[SERCOM_INST_NUM] = SERCOM_INSTS; + for (int i = 0; i < SERCOM_INST_NUM; i++) { + if (sercom_instances[i] == sercom) { + never_reset_sercoms[i] = true; + break; + } + } +} + +void allow_reset_sercom(Sercom *sercom) { + // Reset all SERCOMs except the ones being used by on-board devices. + Sercom *sercom_instances[SERCOM_INST_NUM] = SERCOM_INSTS; + for (int i = 0; i < SERCOM_INST_NUM; i++) { + if (sercom_instances[i] == sercom) { + never_reset_sercoms[i] = false; + break; + } + } +} + +void reset_sercoms(void) { + // Reset all SERCOMs except the ones being used by on-board devices. + Sercom *sercom_instances[SERCOM_INST_NUM] = SERCOM_INSTS; + for (int i = 0; i < SERCOM_INST_NUM; i++) { + if (never_reset_sercoms[i]) { + continue; + } + // SWRST is same for all modes of SERCOMs. + sercom_instances[i]->SPI.CTRLA.bit.SWRST = 1; + } +} diff --git a/ports/atmel-samd/common-hal/busio/__init__.h b/ports/atmel-samd/common-hal/busio/__init__.h new file mode 100644 index 0000000000..ded88f113d --- /dev/null +++ b/ports/atmel-samd/common-hal/busio/__init__.h @@ -0,0 +1,35 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2016 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_ATMEL_SAMD_COMMON_HAL_BUSIO_INIT_H +#define MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_BUSIO_INIT_H + +void reset_sercoms(void); +void allow_reset_sercom(Sercom *sercom); +void never_reset_sercom(Sercom *sercom); + + +#endif // MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_BUSIO_INIT_H diff --git a/ports/atmel-samd/common-hal/canio/Listener.c b/ports/atmel-samd/common-hal/canio/Listener.c index ce09764757..e171ae5193 100644 --- a/ports/atmel-samd/common-hal/canio/Listener.c +++ b/ports/atmel-samd/common-hal/canio/Listener.c @@ -30,7 +30,7 @@ #include "py/obj.h" #include "py/runtime.h" -#include "lib/utils/interrupt_char.h" +#include "shared/runtime/interrupt_char.h" #include "common-hal/canio/__init__.h" #include "common-hal/canio/Listener.h" diff --git a/ports/atmel-samd/common-hal/i2cperipheral/I2CPeripheral.c b/ports/atmel-samd/common-hal/i2cperipheral/I2CPeripheral.c index 961fde8439..e1849a6b15 100644 --- a/ports/atmel-samd/common-hal/i2cperipheral/I2CPeripheral.c +++ b/ports/atmel-samd/common-hal/i2cperipheral/I2CPeripheral.c @@ -27,7 +27,7 @@ #include "shared-bindings/i2cperipheral/I2CPeripheral.h" #include "common-hal/busio/I2C.h" -#include "lib/utils/interrupt_char.h" +#include "shared/runtime/interrupt_char.h" #include "py/mperrno.h" #include "py/mphal.h" #include "py/runtime.h" diff --git a/ports/atmel-samd/common-hal/imagecapture/ParallelImageCapture.c b/ports/atmel-samd/common-hal/imagecapture/ParallelImageCapture.c index f3284f0c32..8e41f50d8d 100644 --- a/ports/atmel-samd/common-hal/imagecapture/ParallelImageCapture.c +++ b/ports/atmel-samd/common-hal/imagecapture/ParallelImageCapture.c @@ -27,8 +27,8 @@ #include "py/obj.h" #include "py/runtime.h" -#include "lib/utils/context_manager_helpers.h" -#include "lib/utils/interrupt_char.h" +#include "shared/runtime/context_manager_helpers.h" +#include "shared/runtime/interrupt_char.h" #include "shared-bindings/imagecapture/ParallelImageCapture.h" #include "shared-bindings/microcontroller/__init__.h" @@ -151,14 +151,14 @@ static void setup_dma(DmacDescriptor *descriptor, size_t count, uint32_t *buffer descriptor->DESCADDR.reg = 0; } -#include - -void common_hal_imagecapture_parallelimagecapture_capture(imagecapture_parallelimagecapture_obj_t *self, void *buffer, size_t bufsize) { +void common_hal_imagecapture_parallelimagecapture_singleshot_capture(imagecapture_parallelimagecapture_obj_t *self, mp_obj_t buffer) { + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(buffer, &bufinfo, MP_BUFFER_RW); uint8_t dma_channel = dma_allocate_channel(); - uint32_t *dest = buffer; - size_t count = bufsize / 4; // PCC receives 4 bytes (2 pixels) at a time + uint32_t *dest = bufinfo.buf; + size_t count = bufinfo.len / 4; // PCC receives 4 bytes (2 pixels) at a time turn_on_event_system(); diff --git a/ports/atmel-samd/common-hal/microcontroller/__init__.c b/ports/atmel-samd/common-hal/microcontroller/__init__.c index 751f4dcab7..983af7a647 100644 --- a/ports/atmel-samd/common-hal/microcontroller/__init__.c +++ b/ports/atmel-samd/common-hal/microcontroller/__init__.c @@ -103,6 +103,17 @@ const nvm_bytearray_obj_t common_hal_mcu_nvm_obj = { }; #endif +#if CIRCUITPY_WATCHDOG +// The singleton watchdog.WatchDogTimer object. +watchdog_watchdogtimer_obj_t common_hal_mcu_watchdogtimer_obj = { + .base = { + .type = &watchdog_watchdogtimer_type, + }, + .timeout = 0.0f, + .mode = WATCHDOGMODE_NONE, +}; +#endif + // This maps MCU pin names to pin objects. STATIC const mp_rom_map_elem_t mcu_pin_global_dict_table[] = { #if defined(PIN_PA00) && !defined(IGNORE_PIN_PA00) diff --git a/ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c b/ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c index 2a30142ab3..dc9cf65334 100644 --- a/ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c +++ b/ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c @@ -67,7 +67,7 @@ void common_hal_rotaryio_incrementalencoder_construct(rotaryio_incrementalencode set_eic_channel_data(self->eic_channel_b, (void *)self); self->position = 0; - self->quarter_count = 0; + self->sub_count = 0; shared_module_softencoder_state_init(self, ((uint8_t)gpio_get_pin_level(self->pin_a) << 1) | diff --git a/ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.h b/ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.h index 2560997a97..f9223ddc7c 100644 --- a/ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.h +++ b/ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.h @@ -38,7 +38,8 @@ typedef struct { uint8_t eic_channel_a; uint8_t eic_channel_b; uint8_t state; // - int8_t quarter_count; // count intermediate transitions between detents + int8_t sub_count; // count intermediate transitions between detents + int8_t divisor; // Number of quadrature edges required per count mp_int_t position; } rotaryio_incrementalencoder_obj_t; diff --git a/ports/atmel-samd/common-hal/rtc/RTC.c b/ports/atmel-samd/common-hal/rtc/RTC.c index 3517f31aa5..65d7d94220 100644 --- a/ports/atmel-samd/common-hal/rtc/RTC.c +++ b/ports/atmel-samd/common-hal/rtc/RTC.c @@ -33,7 +33,7 @@ #include "py/obj.h" #include "py/runtime.h" -#include "lib/timeutils/timeutils.h" +#include "shared/timeutils/timeutils.h" #include "shared-bindings/rtc/__init__.h" #include "supervisor/port.h" #include "supervisor/shared/translate.h" diff --git a/ports/atmel-samd/common-hal/watchdog/WatchDogMode.c b/ports/atmel-samd/common-hal/watchdog/WatchDogMode.c new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ports/atmel-samd/common-hal/watchdog/WatchDogTimer.c b/ports/atmel-samd/common-hal/watchdog/WatchDogTimer.c new file mode 100644 index 0000000000..329242887c --- /dev/null +++ b/ports/atmel-samd/common-hal/watchdog/WatchDogTimer.c @@ -0,0 +1,105 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Jeff Epler 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 "py/runtime.h" + +#include "shared-bindings/watchdog/__init__.h" +#include "shared-bindings/watchdog/WatchDogTimer.h" +#include "common-hal/watchdog/WatchDogTimer.h" + +#include "component/wdt.h" + +void common_hal_watchdog_feed(watchdog_watchdogtimer_obj_t *self) { + WDT->CLEAR.reg = WDT_CLEAR_CLEAR_KEY; +} + +void common_hal_watchdog_deinit(watchdog_watchdogtimer_obj_t *self) { + if (self->mode == WATCHDOGMODE_RESET) { + mp_raise_RuntimeError(translate("WatchDogTimer cannot be deinitialized once mode is set to RESET")); + } else { + self->mode = WATCHDOGMODE_NONE; + } +} + +mp_float_t common_hal_watchdog_get_timeout(watchdog_watchdogtimer_obj_t *self) { + return self->timeout; +} + +void setup_wdt(watchdog_watchdogtimer_obj_t *self, int setting) { + OSC32KCTRL->OSCULP32K.bit.EN1K = 1; // Enable out 1K (for WDT) + + // disable watchdog for config + WDT->CTRLA.reg = 0; + while (WDT->SYNCBUSY.reg) { // Sync CTRL write + } + + WDT->INTENCLR.bit.EW = 1; // 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 + } + common_hal_watchdog_feed(self); // Clear watchdog interval + WDT->CTRLA.bit.ENABLE = 1; // Start watchdog now! + while (WDT->SYNCBUSY.reg) { + } +} + +void common_hal_watchdog_set_timeout(watchdog_watchdogtimer_obj_t *self, mp_float_t new_timeout) { + int wdt_cycles = (int)(new_timeout * 1024); + if (wdt_cycles < 8) { + wdt_cycles = 8; + } + if (wdt_cycles > 16384) { + mp_raise_ValueError(translate("timeout duration exceeded the maximum supported value")); + } + // ceil(log2(n)) = 32 - __builtin_clz(n - 1) when n > 1 (if int is 32 bits) + int log2_wdt_cycles = (sizeof(int) * CHAR_BIT) - __builtin_clz(wdt_cycles - 1); + int setting = log2_wdt_cycles - 3; // CYC8_Val is 0 + float timeout = (8 << setting) / 1024.f; + + if (self->mode == WATCHDOGMODE_RESET) { + setup_wdt(self, setting); + } + self->timeout = timeout; +} + +watchdog_watchdogmode_t common_hal_watchdog_get_mode(watchdog_watchdogtimer_obj_t *self) { + return self->mode; +} + +void common_hal_watchdog_set_mode(watchdog_watchdogtimer_obj_t *self, watchdog_watchdogmode_t new_mode) { + if (self->mode != new_mode) { + if (new_mode == WATCHDOGMODE_RAISE) { + mp_raise_NotImplementedError(translate("RAISE mode is not implemented")); + } else if (new_mode == WATCHDOGMODE_NONE) { + common_hal_watchdog_deinit(self); + } + self->mode = new_mode; + common_hal_watchdog_set_timeout(self, self->timeout); + } +} diff --git a/ports/atmel-samd/common-hal/watchdog/WatchDogTimer.h b/ports/atmel-samd/common-hal/watchdog/WatchDogTimer.h new file mode 100644 index 0000000000..ce34f0b8ab --- /dev/null +++ b/ports/atmel-samd/common-hal/watchdog/WatchDogTimer.h @@ -0,0 +1,43 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 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. + */ + +#ifndef MICROPY_INCLUDED_RASPBERRYPI_COMMON_HAL_WATCHDOG_WATCHDOGTIMER_H +#define MICROPY_INCLUDED_RASPBERRYPI_COMMON_HAL_WATCHDOG_WATCHDOGTIMER_H + +#include "py/obj.h" +#include "shared-bindings/watchdog/WatchDogMode.h" +#include "shared-bindings/watchdog/WatchDogTimer.h" + +struct _watchdog_watchdogtimer_obj_t { + mp_obj_base_t base; + mp_float_t timeout; + watchdog_watchdogmode_t mode; +}; + +// This needs to be called in order to disable the watchdog +// void watchdog_reset(void); + +#endif // MICROPY_INCLUDED_RASPBERRYPI_COMMON_HAL_WATCHDOG_WATCHDOGTIMER_H diff --git a/ports/atmel-samd/common-hal/watchdog/__init__.c b/ports/atmel-samd/common-hal/watchdog/__init__.c new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ports/atmel-samd/eic_handler.c b/ports/atmel-samd/eic_handler.c index 226dafc765..48824031c0 100644 --- a/ports/atmel-samd/eic_handler.c +++ b/ports/atmel-samd/eic_handler.c @@ -29,6 +29,7 @@ #include "common-hal/rotaryio/IncrementalEncoder.h" #include "common-hal/countio/Counter.h" #include "shared-bindings/microcontroller/__init__.h" +#include "common-hal/alarm/pin/PinAlarm.h" // #include "samd/external_interrupts.h" #include "eic_handler.h" @@ -66,6 +67,12 @@ void shared_eic_handler(uint8_t channel) { break; #endif + #if CIRCUITPY_ALARM + case EIC_HANDLER_ALARM: + pin_alarm_callback(channel); + break; + #endif + default: break; } diff --git a/ports/atmel-samd/eic_handler.h b/ports/atmel-samd/eic_handler.h index 08da7ea34d..d73ef2a0f7 100644 --- a/ports/atmel-samd/eic_handler.h +++ b/ports/atmel-samd/eic_handler.h @@ -31,6 +31,7 @@ #define EIC_HANDLER_INCREMENTAL_ENCODER 0x2 #define EIC_HANDLER_PS2 0x3 #define EIC_HANDLER_COUNTER 0x04 +#define EIC_HANDLER_ALARM 0x05 void set_eic_handler(uint8_t channel, uint8_t eic_handler); void shared_eic_handler(uint8_t channel); diff --git a/ports/atmel-samd/fatfs_port.c b/ports/atmel-samd/fatfs_port.c index e6eee20495..58a0ef0d72 100644 --- a/ports/atmel-samd/fatfs_port.c +++ b/ports/atmel-samd/fatfs_port.c @@ -28,7 +28,7 @@ #include "py/runtime.h" #include "lib/oofatfs/ff.h" /* FatFs lower layer API */ #include "lib/oofatfs/diskio.h" /* FatFs lower layer API */ -#include "lib/timeutils/timeutils.h" +#include "shared/timeutils/timeutils.h" #if CIRCUITPY_RTC #include "shared-bindings/rtc/RTC.h" diff --git a/ports/atmel-samd/mpconfigport.mk b/ports/atmel-samd/mpconfigport.mk index 8994f0f52a..1652032311 100644 --- a/ports/atmel-samd/mpconfigport.mk +++ b/ports/atmel-samd/mpconfigport.mk @@ -49,6 +49,7 @@ CIRCUITPY_COUNTIO ?= 0 # Not enough RAM for framebuffers CIRCUITPY_FRAMEBUFFERIO ?= 0 CIRCUITPY_FREQUENCYIO ?= 0 +CIRCUITPY_GIFIO ?= 0 CIRCUITPY_I2CPERIPHERAL ?= 0 CIRCUITPY_JSON ?= 0 CIRCUITPY_KEYPAD ?= 0 @@ -98,10 +99,13 @@ CIRCUITPY_TOUCHIO_USE_NATIVE = 0 # The ?='s allow overriding in mpconfigboard.mk. + +CIRCUITPY_ALARM ?= 0 CIRCUITPY_PS2IO ?= 1 CIRCUITPY_SAMD ?= 1 CIRCUITPY_RGBMATRIX ?= $(CIRCUITPY_FULL_BUILD) CIRCUITPY_FRAMEBUFFERIO ?= $(CIRCUITPY_FULL_BUILD) +CIRCUITPY_WATCHDOG ?= 1 endif # samd51 ###################################################################### diff --git a/ports/atmel-samd/mphalport.c b/ports/atmel-samd/mphalport.c index 5ebce1a857..e196312ca3 100644 --- a/ports/atmel-samd/mphalport.c +++ b/ports/atmel-samd/mphalport.c @@ -26,8 +26,8 @@ #include -#include "lib/mp-readline/readline.h" -#include "lib/utils/interrupt_char.h" +#include "shared/readline/readline.h" +#include "shared/runtime/interrupt_char.h" #include "py/mphal.h" #include "py/mpstate.h" #include "py/runtime.h" diff --git a/ports/atmel-samd/supervisor/port.c b/ports/atmel-samd/supervisor/port.c index 4b0775ea91..d2211d4c8f 100644 --- a/ports/atmel-samd/supervisor/port.c +++ b/ports/atmel-samd/supervisor/port.c @@ -53,18 +53,48 @@ #error Unknown chip family #endif +#if CIRCUITPY_ANALOGIO #include "common-hal/analogio/AnalogIn.h" #include "common-hal/analogio/AnalogOut.h" +#endif + +#if CIRCUITPY_AUDIOBUSIO #include "common-hal/audiobusio/PDMIn.h" #include "common-hal/audiobusio/I2SOut.h" +#endif + +#if CIRCUITPY_AUDIOIO #include "common-hal/audioio/AudioOut.h" -#include "common-hal/busio/SPI.h" +#endif + +#if CIRCUITPY_BUSIO +#include "common-hal/busio/__init__.h" +#endif + #include "common-hal/microcontroller/Pin.h" + +#if CIRCUITPY_PULSEIO #include "common-hal/pulseio/PulseIn.h" #include "common-hal/pulseio/PulseOut.h" +#endif + +#if CIRCUITPY_PWMIO #include "common-hal/pwmio/PWMOut.h" +#endif + +#if CIRCUITPY_PS2IO #include "common-hal/ps2io/Ps2.h" +#endif + +#if CIRCUITPY_RTC #include "common-hal/rtc/RTC.h" +#endif + +#if CIRCUITPY_ALARM +#include "common-hal/alarm/__init__.h" +#include "common-hal/alarm/time/TimeAlarm.h" +#include "common-hal/alarm/pin/PinAlarm.h" +#endif #if CIRCUITPY_TOUCHIO_USE_NATIVE #include "common-hal/touchio/TouchIn.h" @@ -191,6 +221,10 @@ static void rtc_init(void) { #endif #ifdef SAM_D5X_E5X hri_mclk_set_APBAMASK_RTC_bit(MCLK); + #if CIRCUITPY_ALARM + // Cache TAMPID for wake up cause + (void)alarm_get_wakeup_cause(); + #endif RTC->MODE0.CTRLA.bit.SWRST = true; while (RTC->MODE0.SYNCBUSY.bit.SWRST != 0) { } @@ -488,6 +522,18 @@ void RTC_Handler(void) { // Do things common to all ports when the tick occurs supervisor_tick(); } + #if CIRCUITPY_ALARM + if (intflag & RTC_MODE0_INTFLAG_CMP1) { + // Likely TimeAlarm fake sleep wake + time_alarm_callback(); + RTC->MODE0.INTFLAG.reg = RTC_MODE0_INTFLAG_CMP1; + } + if (intflag & RTC_MODE0_INTFLAG_TAMPER) { + // Likely PinAlarm fake sleep wake + pin_alarm_callback(1); // TODO: set channel? + RTC->MODE0.INTFLAG.reg = RTC_MODE0_INTFLAG_TAMPER; + } + #endif #endif if (intflag & RTC_MODE0_INTFLAG_CMP0) { // Clear the interrupt because we may have hit a sleep @@ -516,8 +562,13 @@ void evsyshandler_common(void) { supervisor_tick(); } #endif + #if CIRCUITPY_AUDIOIO || CIRCUITPY_AUDIOBUSIO - audio_evsys_handler(); + audio_dma_evsys_handler(); + #endif + + #if CIRCUITPY_AUDIOBUSIO + pdmin_evsys_handler(); #endif } diff --git a/ports/atmel-samd/supervisor/qspi_flash.c b/ports/atmel-samd/supervisor/qspi_flash.c index 304a2e1b8b..5adb40e737 100644 --- a/ports/atmel-samd/supervisor/qspi_flash.c +++ b/ports/atmel-samd/supervisor/qspi_flash.c @@ -243,7 +243,7 @@ void spi_flash_init(void) { // The QSPI is only connected to one set of pins in the SAMD51 so we can hard code it. #ifdef EXTERNAL_FLASH_QSPI_SINGLE - uint32_t pins[] = {PIN_PA08, PIN_PB10, PIN_PB11}; + uint32_t pins[] = {PIN_PA08, PIN_PA09, PIN_PA10, PIN_PA11, PIN_PB10, PIN_PB11}; #elif defined(EXTERNAL_FLASH_QSPI_DUAL) uint32_t pins[] = {PIN_PA08, PIN_PA09, PIN_PB10, PIN_PB11}; #else diff --git a/ports/cxd56/Makefile b/ports/cxd56/Makefile index 73c9fe5822..073d2d59ce 100644 --- a/ports/cxd56/Makefile +++ b/ports/cxd56/Makefile @@ -89,7 +89,7 @@ INC += \ -I. \ -I../.. \ -I../lib/mp-readline \ - -I../lib/timeutils \ + -I../shared/timeutils \ -I../../lib/tinyusb/src \ -I../../supervisor/shared/usb \ -Iboards/$(BOARD) \ diff --git a/ports/cxd56/fatfs_port.c b/ports/cxd56/fatfs_port.c index a58465b983..e672b095b7 100644 --- a/ports/cxd56/fatfs_port.c +++ b/ports/cxd56/fatfs_port.c @@ -28,7 +28,7 @@ #include "py/runtime.h" #include "lib/oofatfs/ff.h" /* FatFs lower layer API */ #include "lib/oofatfs/diskio.h" /* FatFs lower layer API */ -#include "lib/timeutils/timeutils.h" +#include "shared/timeutils/timeutils.h" #if CIRCUITPY_RTC #include "shared-bindings/rtc/RTC.h" diff --git a/ports/cxd56/mphalport.h b/ports/cxd56/mphalport.h index ba5ca39b97..3327b523fa 100644 --- a/ports/cxd56/mphalport.h +++ b/ports/cxd56/mphalport.h @@ -29,7 +29,7 @@ #include -#include "lib/utils/interrupt_char.h" +#include "shared/runtime/interrupt_char.h" #include "supervisor/shared/tick.h" #define mp_hal_ticks_ms() ((mp_uint_t)supervisor_ticks_ms32()) diff --git a/ports/espressif/Makefile b/ports/espressif/Makefile index b2f350c7c7..9a928b40f4 100644 --- a/ports/espressif/Makefile +++ b/ports/espressif/Makefile @@ -218,7 +218,8 @@ SRC_C += \ boards/$(BOARD)/board.c \ boards/$(BOARD)/pins.c \ modules/$(CIRCUITPY_MODULE).c \ - lib/netutils/netutils.c \ + shared/netutils/netutils.c \ + peripherals/i2c.c \ peripherals/rmt.c \ peripherals/timer.c \ peripherals/$(IDF_TARGET)/pins.c @@ -399,14 +400,14 @@ $(BUILD)/firmware.elf: $(OBJ) | esp-idf-stamp $(BUILD)/circuitpython-firmware.bin: $(BUILD)/firmware.elf | tools/build_memory_info.py $(STEPECHO) "Create $@" $(Q)esptool.py --chip $(IDF_TARGET) elf2image $(FLASH_FLAGS) --elf-sha256-offset 0xb0 -o $@ $^ - $(Q)$(PYTHON3) tools/build_memory_info.py $< $(BUILD)/esp-idf/sdkconfig $@ + $(Q)$(PYTHON) tools/build_memory_info.py $< $(BUILD)/esp-idf/sdkconfig $@ $(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 $(BUILD)/firmware.uf2: $(BUILD)/circuitpython-firmware.bin $(STEPECHO) "Create $@" - $(Q)$(PYTHON3) $(TOP)/tools/uf2/utils/uf2conv.py -f 0xbfdd4eee -b 0x0000 -c -o $@ $^ + $(Q)$(PYTHON) $(TOP)/tools/uf2/utils/uf2conv.py -f 0xbfdd4eee -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/bindings/espidf/__init__.c b/ports/espressif/bindings/espidf/__init__.c index c7d5768cd3..9076294d53 100644 --- a/ports/espressif/bindings/espidf/__init__.c +++ b/ports/espressif/bindings/espidf/__init__.c @@ -208,3 +208,5 @@ void raise_esp_error(esp_err_t err) { } mp_raise_msg_varg(exception_type, translate("%s error 0x%x"), group, err); } + +MP_REGISTER_MODULE(MP_QSTR_espidf, espidf_module, CIRCUITPY_ESPIDF); diff --git a/ports/espressif/boards/adafruit_feather_esp32s2/board.c b/ports/espressif/boards/adafruit_feather_esp32s2/board.c new file mode 100644 index 0000000000..5abd1ce1b3 --- /dev/null +++ b/ports/espressif/boards/adafruit_feather_esp32s2/board.c @@ -0,0 +1,46 @@ +/* + * 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) { + // USB + common_hal_never_reset_pin(&pin_GPIO19); + common_hal_never_reset_pin(&pin_GPIO20); +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { + +} + +void board_deinit(void) { +} diff --git a/ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h b/ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h new file mode 100644 index 0000000000..fcd4a2cf60 --- /dev/null +++ b/ports/espressif/boards/adafruit_feather_esp32s2/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 "Adafruit Feather ESP32S2" +#define MICROPY_HW_MCU_NAME "ESP32S2" + +#define MICROPY_HW_NEOPIXEL (&pin_GPIO33) +#define CIRCUITPY_STATUS_LED_POWER (&pin_GPIO21) + +#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_GPIO4) +#define DEFAULT_I2C_BUS_SDA (&pin_GPIO3) + +#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_GPIO38) +#define DEFAULT_UART_BUS_TX (&pin_GPIO39) diff --git a/ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.mk b/ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.mk new file mode 100644 index 0000000000..3f2fee9cf4 --- /dev/null +++ b/ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.mk @@ -0,0 +1,19 @@ +USB_VID = 0x239A +USB_PID = 0x80EC +USB_PRODUCT = "Adafruit Feather ESP32S2" +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=wroom diff --git a/ports/espressif/boards/adafruit_feather_esp32s2/pins.c b/ports/espressif/boards/adafruit_feather_esp32s2/pins.c new file mode 100644 index 0000000000..ef7a55d14c --- /dev/null +++ b/ports/espressif/boards/adafruit_feather_esp32s2/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_D0), MP_ROM_PTR(&pin_GPIO0) }, + + { MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO3) }, + + { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_SCL), 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_I2C_POWER), MP_ROM_PTR(&pin_GPIO7) }, + + { 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) }, + { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_GPIO12) }, + + { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO13) }, + { 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_A4), 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_D16), MP_ROM_PTR(&pin_GPIO16) }, + { MP_ROM_QSTR(MP_QSTR_A2), 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_D18), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO18) }, + + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL_POWER), MP_ROM_PTR(&pin_GPIO21) }, + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO33) }, + + { 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_D36), MP_ROM_PTR(&pin_GPIO36) }, + { MP_ROM_QSTR(MP_QSTR_SCK), 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_D38), MP_ROM_PTR(&pin_GPIO38) }, + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO38) }, + + { MP_ROM_QSTR(MP_QSTR_D39), MP_ROM_PTR(&pin_GPIO39) }, + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO39) }, + + { 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/adafruit_feather_esp32s2/sdkconfig b/ports/espressif/boards/adafruit_feather_esp32s2/sdkconfig new file mode 100644 index 0000000000..9d8bbde967 --- /dev/null +++ b/ports/espressif/boards/adafruit_feather_esp32s2/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_nopsram/mpconfigboard.mk b/ports/espressif/boards/adafruit_feather_esp32s2_nopsram/mpconfigboard.mk index fd8a37c18a..0360849ac4 100644 --- a/ports/espressif/boards/adafruit_feather_esp32s2_nopsram/mpconfigboard.mk +++ b/ports/espressif/boards/adafruit_feather_esp32s2_nopsram/mpconfigboard.mk @@ -1,5 +1,5 @@ USB_VID = 0x239A -USB_PID = 0x80EC +USB_PID = 0x8FFF USB_PRODUCT = "Feather ESP32S2 no PSRAM" USB_MANUFACTURER = "Adafruit" diff --git a/ports/espressif/boards/ai_thinker_esp32-c3s/board.c b/ports/espressif/boards/ai_thinker_esp32-c3s/board.c new file mode 100644 index 0000000000..3d392892e3 --- /dev/null +++ b/ports/espressif/boards/ai_thinker_esp32-c3s/board.c @@ -0,0 +1,56 @@ +/* + * 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" + +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); +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { +} + +void board_deinit(void) { +} diff --git a/ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h b/ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h new file mode 100644 index 0000000000..026e06312a --- /dev/null +++ b/ports/espressif/boards/ai_thinker_esp32-c3s/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" +#define MICROPY_HW_MCU_NAME "ESP32-C3FN4" + +// 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/mpconfigboard.mk b/ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.mk new file mode 100644 index 0000000000..3a83ab500b --- /dev/null +++ b/ports/espressif/boards/ai_thinker_esp32-c3s/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=qio +CIRCUITPY_ESP_FLASH_FREQ=80m +CIRCUITPY_ESP_FLASH_SIZE=4MB diff --git a/ports/espressif/boards/ai_thinker_esp32-c3s/pins.c b/ports/espressif/boards/ai_thinker_esp32-c3s/pins.c new file mode 100644 index 0000000000..37e9373202 --- /dev/null +++ b/ports/espressif/boards/ai_thinker_esp32-c3s/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/sdkconfig b/ports/espressif/boards/ai_thinker_esp32-c3s/sdkconfig new file mode 100644 index 0000000000..88467d9c9e --- /dev/null +++ b/ports/espressif/boards/ai_thinker_esp32-c3s/sdkconfig @@ -0,0 +1,5 @@ +# +# LWIP +# +CONFIG_LWIP_LOCAL_HOSTNAME="AIThinker-ESP32C3S" +# end of LWIP diff --git a/ports/espressif/boards/lolin_s2_mini/pins.c b/ports/espressif/boards/lolin_s2_mini/pins.c index c73149597d..a4b18c4e9b 100644 --- a/ports/espressif/boards/lolin_s2_mini/pins.c +++ b/ports/espressif/boards/lolin_s2_mini/pins.c @@ -86,5 +86,6 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_IO45), MP_ROM_PTR(&pin_GPIO45) },// GPIO45 { MP_ROM_QSTR(MP_QSTR_IO46), MP_ROM_PTR(&pin_GPIO46) },// GPIO46 */ + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, // board singleton implicit from schematic/shield standard }; MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/espressif/boards/lolin_s2_pico/board.c b/ports/espressif/boards/lolin_s2_pico/board.c new file mode 100644 index 0000000000..a0e399b1ef --- /dev/null +++ b/ports/espressif/boards/lolin_s2_pico/board.c @@ -0,0 +1,61 @@ +/* + * 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) { + // 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) { + return false; +} + +void reset_board(void) { + +} + +void board_deinit(void) { +} diff --git a/ports/espressif/boards/lolin_s2_pico/mpconfigboard.h b/ports/espressif/boards/lolin_s2_pico/mpconfigboard.h new file mode 100644 index 0000000000..408b15ac16 --- /dev/null +++ b/ports/espressif/boards/lolin_s2_pico/mpconfigboard.h @@ -0,0 +1,42 @@ +/* + * 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 "S2Pico" +#define MICROPY_HW_MCU_NAME "ESP32S2-S2FN4R2" // from Wemos MP + +#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) // JST SH Connector Pin 3 NOT STEMMA QT / Feather pinout +#define DEFAULT_I2C_BUS_SDA (&pin_GPIO8) // JST SH Connector Pin 2 NOT STEMMA QT / Feather pinout + +#define DEFAULT_SPI_BUS_SCK (&pin_GPIO36) // no SPI labels on S2 Pico, def from schematic +#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO35) // no SPI labels on S2 Pico, def from schematic +#define DEFAULT_SPI_BUS_MISO (&pin_GPIO37) // no SPI labels on S2 Pico, def from schematic diff --git a/ports/espressif/boards/lolin_s2_pico/mpconfigboard.mk b/ports/espressif/boards/lolin_s2_pico/mpconfigboard.mk new file mode 100644 index 0000000000..b060be0261 --- /dev/null +++ b/ports/espressif/boards/lolin_s2_pico/mpconfigboard.mk @@ -0,0 +1,21 @@ +USB_VID = 0x303A +USB_PID = 0x80C6 +USB_PRODUCT = "S2 Pico" +USB_MANUFACTURER = "Lolin" + +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=80m +CIRCUITPY_ESP_FLASH_SIZE=4MB + + +# Include these Python libraries in firmware. +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel diff --git a/ports/espressif/boards/lolin_s2_pico/pins.c b/ports/espressif/boards/lolin_s2_pico/pins.c new file mode 100644 index 0000000000..5c3f1f4db5 --- /dev/null +++ b/ports/espressif/boards/lolin_s2_pico/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 + + // Not broken out - Button + { MP_ROM_QSTR(MP_QSTR_IO0), MP_ROM_PTR(&pin_GPIO0) }, // RTC_GPIO0,GPIO0 + + // S2 Pico Board top, left, top-bottom + { MP_ROM_QSTR(MP_QSTR_IO1), MP_ROM_PTR(&pin_GPIO1) }, // RTC_GPIO1,GPIO1,TOUCH1,ADC1_CH0 + { MP_ROM_QSTR(MP_QSTR_IO2), MP_ROM_PTR(&pin_GPIO2) }, // RTC_GPIO2,GPIO2,TOUCH2,ADC1_CH1 + { MP_ROM_QSTR(MP_QSTR_IO3), MP_ROM_PTR(&pin_GPIO3) }, // RTC_GPIO3,GPIO3,TOUCH3,ADC1_CH2 + { MP_ROM_QSTR(MP_QSTR_IO4), MP_ROM_PTR(&pin_GPIO4) }, // RTC_GPIO4,GPIO4,TOUCH4,ADC1_CH3 + { MP_ROM_QSTR(MP_QSTR_IO5), MP_ROM_PTR(&pin_GPIO5) }, // RTC_GPIO5,GPIO5,TOUCH5,ADC1_CH4 + { MP_ROM_QSTR(MP_QSTR_IO6), MP_ROM_PTR(&pin_GPIO6) }, // RTC_GPIO6,GPIO6,TOUCH6,ADC1_CH5 + { MP_ROM_QSTR(MP_QSTR_IO7), MP_ROM_PTR(&pin_GPIO7) }, // RTC_GPIO7,GPIO7,TOUCH7,ADC1_CH6 + + // JST SH Connector + { MP_ROM_QSTR(MP_QSTR_IO8), MP_ROM_PTR(&pin_GPIO8) }, // RTC_GPIO8,GPIO8,TOUCH8,ADC1_CH7 + { MP_ROM_QSTR(MP_QSTR_IO9), MP_ROM_PTR(&pin_GPIO9) }, // RTC_GPIO8,GPIO8,TOUCH8,ADC1_CH7 + + // Not broken out - LED + { MP_ROM_QSTR(MP_QSTR_IO10), MP_ROM_PTR(&pin_GPIO10) },// RTC_GPIO10,GPIO10,TOUCH10,ADC1_CH9,FSPICS0,FSPIIO4 + + // S2 Pico Board top, right, bottom-top + { MP_ROM_QSTR(MP_QSTR_IO11), MP_ROM_PTR(&pin_GPIO11) },// RTC_GPIO11,GPIO11,TOUCH11,ADC2_CH0,FSPID,FSPIIO5 + { MP_ROM_QSTR(MP_QSTR_IO12), MP_ROM_PTR(&pin_GPIO12) },// RTC_GPIO12,GPIO12,TOUCH12,ADC2_CH1,FSPICLK,FSPIIO6 + { MP_ROM_QSTR(MP_QSTR_IO13), MP_ROM_PTR(&pin_GPIO13) },// RTC_GPIO13,GPIO13,TOUCH13,ADC2_CH2,FSPIQ,FSPIIO7 + { MP_ROM_QSTR(MP_QSTR_IO14), MP_ROM_PTR(&pin_GPIO14) },// RTC_GPIO14,GPIO14,TOUCH14,ADC2_CH3,FSPIWP,FSPIDQS + { MP_ROM_QSTR(MP_QSTR_IO15), MP_ROM_PTR(&pin_GPIO15) },// XTAL_32K_P: RTC_GPIO15,GPIO15,U0RTS,ADC2_CH4,XTAL_32K_P + { MP_ROM_QSTR(MP_QSTR_IO16), MP_ROM_PTR(&pin_GPIO16) },// XTAL_32K_N: RTC_GPIO16,GPIO16,U0CTS,ADC2_CH5,XTAL_32K_N + { MP_ROM_QSTR(MP_QSTR_IO17), MP_ROM_PTR(&pin_GPIO17) },// DAC_1: RTC_GPIO17,GPIO17,U1TXD,ADC2_CH6,DAC_1 + + // Not broken out - SSD1306 reset + { MP_ROM_QSTR(MP_QSTR_IO18), MP_ROM_PTR(&pin_GPIO18) },// DAC_2: RTC_GPIO18,GPIO18,U1RXD,ADC2_CH7,DAC_2,CLK_OUT3 + + { MP_ROM_QSTR(MP_QSTR_IO21), MP_ROM_PTR(&pin_GPIO21) },// RTC_GPIO21,GPIO21 + { MP_ROM_QSTR(MP_QSTR_IO33), MP_ROM_PTR(&pin_GPIO33) },// SPIIO4,GPIO33,FSPIHD + { MP_ROM_QSTR(MP_QSTR_IO34), MP_ROM_PTR(&pin_GPIO34) },// SPIIO5,GPIO34,FSPICS0 + { MP_ROM_QSTR(MP_QSTR_IO35), MP_ROM_PTR(&pin_GPIO35) },// SPIIO6,GPIO35,FSPID + { MP_ROM_QSTR(MP_QSTR_IO36), MP_ROM_PTR(&pin_GPIO36) },// SPIIO7,GPIO36,FSPICLK + { MP_ROM_QSTR(MP_QSTR_IO37), MP_ROM_PTR(&pin_GPIO37) },// SPIDQS,GPIO37,FSPIQ + { MP_ROM_QSTR(MP_QSTR_IO38), MP_ROM_PTR(&pin_GPIO38) },// GPIO38,FSPIWP + + { MP_ROM_QSTR(MP_QSTR_BUTTON), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_LCD_RST), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_SS), MP_ROM_PTR(&pin_GPIO34) }, // Not labelled on booard, on schematic + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO35) },// Not labelled on booard, on schematic + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO36) }, // Not labelled on booard, on schematic + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO37) },// Not labelled on booard, on schematic + { 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/espressif/boards/lolin_s2_pico/sdkconfig b/ports/espressif/boards/lolin_s2_pico/sdkconfig new file mode 100644 index 0000000000..36e83d7fb5 --- /dev/null +++ b/ports/espressif/boards/lolin_s2_pico/sdkconfig @@ -0,0 +1,39 @@ +CONFIG_ESP32S2_SPIRAM_SUPPORT=y + +# +# SPI RAM config +# +# CONFIG_SPIRAM_TYPE_AUTO=y +CONFIG_SPIRAM_TYPE_ESPPSRAM16=y +# CONFIG_SPIRAM_TYPE_ESPPSRAM32 is not set +# CONFIG_SPIRAM_TYPE_ESPPSRAM64=y +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=y +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="Lolin-S2Pico" +# end of LWIP diff --git a/ports/espressif/boards/microdev_micro_c3/board.c b/ports/espressif/boards/microdev_micro_c3/board.c new file mode 100644 index 0000000000..183740a7c3 --- /dev/null +++ b/ports/espressif/boards/microdev_micro_c3/board.c @@ -0,0 +1,58 @@ +/* + * 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" + +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) { + return false; +} + +void reset_board(void) { +} + +void board_deinit(void) { +} diff --git a/ports/espressif/boards/microdev_micro_c3/mpconfigboard.h b/ports/espressif/boards/microdev_micro_c3/mpconfigboard.h new file mode 100644 index 0000000000..c1d9e1b0b2 --- /dev/null +++ b/ports/espressif/boards/microdev_micro_c3/mpconfigboard.h @@ -0,0 +1,54 @@ +/* + * 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 "MicroDev microC3" +#define MICROPY_HW_MCU_NAME "ESP32-C3FN4" + +// Status LED +#define MICROPY_HW_NEOPIXEL (&pin_GPIO7) +#define MICROPY_HW_NEOPIXEL_COUNT (2) + +// Default bus pins +#define DEFAULT_I2C_BUS_SCL (&pin_GPIO4) +#define DEFAULT_I2C_BUS_SDA (&pin_GPIO5) + +#define DEFAULT_SPI_BUS_SCK (&pin_GPIO1) +#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO2) +#define DEFAULT_SPI_BUS_MISO (&pin_GPIO3) + +#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/microdev_micro_c3/mpconfigboard.mk b/ports/espressif/boards/microdev_micro_c3/mpconfigboard.mk new file mode 100644 index 0000000000..12bd7358b8 --- /dev/null +++ b/ports/espressif/boards/microdev_micro_c3/mpconfigboard.mk @@ -0,0 +1,10 @@ +CIRCUITPY_CREATOR_ID = 0x6d446576 +CIRCUITPY_CREATION_ID = 0x006d4333 + +IDF_TARGET = esp32c3 + +INTERNAL_FLASH_FILESYSTEM = 1 + +CIRCUITPY_ESP_FLASH_MODE=qio +CIRCUITPY_ESP_FLASH_FREQ=80m +CIRCUITPY_ESP_FLASH_SIZE=4MB diff --git a/ports/espressif/boards/microdev_micro_c3/pins.c b/ports/espressif/boards/microdev_micro_c3/pins.c new file mode 100644 index 0000000000..84d6efb782 --- /dev/null +++ b/ports/espressif/boards/microdev_micro_c3/pins.c @@ -0,0 +1,78 @@ +/* + * 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_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_SCL), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO5) }, + + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO3) }, + + { 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_LED), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_BUTTON), MP_ROM_PTR(&pin_GPIO9) }, + { 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_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/microdev_micro_c3/sdkconfig b/ports/espressif/boards/microdev_micro_c3/sdkconfig new file mode 100644 index 0000000000..f6f038a77c --- /dev/null +++ b/ports/espressif/boards/microdev_micro_c3/sdkconfig @@ -0,0 +1,5 @@ +# +# LWIP +# +CONFIG_LWIP_LOCAL_HOSTNAME="MicroDev-microC3" +# end of LWIP diff --git a/ports/espressif/common-hal/busio/I2C.c b/ports/espressif/common-hal/busio/I2C.c index be80538582..81b23cb3a3 100644 --- a/ports/espressif/common-hal/busio/I2C.c +++ b/ports/espressif/common-hal/busio/I2C.c @@ -34,26 +34,6 @@ #include "shared-bindings/microcontroller/Pin.h" #include "supervisor/shared/translate.h" -typedef enum { - STATUS_FREE = 0, - STATUS_IN_USE, - STATUS_NEVER_RESET -} i2c_status_t; - -static i2c_status_t i2c_status[I2C_NUM_MAX]; - -void never_reset_i2c(i2c_port_t num) { - i2c_status[num] = STATUS_NEVER_RESET; -} - -void i2c_reset(void) { - for (i2c_port_t num = 0; num < I2C_NUM_MAX; num++) { - if (i2c_status[num] == STATUS_IN_USE) { - i2c_status[num] = STATUS_FREE; - } - } -} - 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 frequency, uint32_t timeout) { // Pins 45 and 46 are "strapping" pins that impact start up behavior. They usually need to @@ -99,21 +79,16 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, } self->sda_pin = sda; self->scl_pin = scl; - self->i2c_num = I2C_NUM_MAX; - for (i2c_port_t num = 0; num < I2C_NUM_MAX; num++) { - if (i2c_status[num] == STATUS_FREE) { - self->i2c_num = num; - } - } + self->i2c_num = peripherals_i2c_get_free_num(); + if (self->i2c_num == I2C_NUM_MAX) { mp_raise_ValueError(translate("All I2C peripherals are in use")); } - i2c_status[self->i2c_num] = STATUS_IN_USE; // Delete any previous driver. i2c_driver_delete(self->i2c_num); - i2c_config_t i2c_conf = { + const i2c_config_t i2c_conf = { .mode = I2C_MODE_MASTER, .sda_io_num = self->sda_pin->number, .scl_io_num = self->scl_pin->number, @@ -129,16 +104,15 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, .clk_speed = frequency, } }; - if (i2c_param_config(self->i2c_num, &i2c_conf) != ESP_OK) { - mp_raise_ValueError(translate("Invalid frequency")); - } - if (i2c_driver_install(self->i2c_num, - I2C_MODE_MASTER, - 0, - 0, - 0) != ESP_OK) { - mp_raise_OSError(MP_EIO); + // Initialize I2C. + esp_err_t err = peripherals_i2c_init(self->i2c_num, &i2c_conf); + if (err != ESP_OK) { + if (err == ESP_FAIL) { + mp_raise_OSError(MP_EIO); + } else { + mp_raise_ValueError(translate("Invalid argument")); + } } claim_pin(sda); @@ -154,14 +128,12 @@ void common_hal_busio_i2c_deinit(busio_i2c_obj_t *self) { return; } - i2c_driver_delete(self->i2c_num); + peripherals_i2c_deinit(self->i2c_num); common_hal_reset_pin(self->sda_pin); common_hal_reset_pin(self->scl_pin); self->sda_pin = NULL; self->scl_pin = NULL; - - i2c_status[self->i2c_num] = STATUS_FREE; } bool common_hal_busio_i2c_probe(busio_i2c_obj_t *self, uint8_t addr) { diff --git a/ports/espressif/common-hal/busio/I2C.h b/ports/espressif/common-hal/busio/I2C.h index a44c414505..e3e60c07be 100644 --- a/ports/espressif/common-hal/busio/I2C.h +++ b/ports/espressif/common-hal/busio/I2C.h @@ -34,6 +34,8 @@ #include "freertos/semphr.h" #include "py/obj.h" +#include "peripherals/i2c.h" + typedef struct { mp_obj_base_t base; const mcu_pin_obj_t *scl_pin; @@ -43,6 +45,4 @@ typedef struct { bool has_lock; } busio_i2c_obj_t; -void i2c_reset(void); - #endif // MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BUSIO_I2C_H diff --git a/ports/espressif/common-hal/busio/UART.c b/ports/espressif/common-hal/busio/UART.c index 52cf5cfa3b..5aac1635af 100644 --- a/ports/espressif/common-hal/busio/UART.c +++ b/ports/espressif/common-hal/busio/UART.c @@ -30,7 +30,7 @@ #include "components/driver/include/driver/uart.h" #include "mpconfigport.h" -#include "lib/utils/interrupt_char.h" +#include "shared/runtime/interrupt_char.h" #include "py/gc.h" #include "py/mperrno.h" #include "py/runtime.h" diff --git a/ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c b/ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c new file mode 100644 index 0000000000..d073a8a362 --- /dev/null +++ b/ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c @@ -0,0 +1,125 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 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/i2cperipheral/I2CPeripheral.h" + +#include "py/mperrno.h" +#include "py/runtime.h" + +#include "common-hal/i2cperipheral/I2CPeripheral.h" + +void common_hal_i2cperipheral_i2c_peripheral_construct(i2cperipheral_i2c_peripheral_obj_t *self, + const mcu_pin_obj_t *scl, const mcu_pin_obj_t *sda, + uint8_t *addresses, unsigned int num_addresses, bool smbus) { + // Pins 45 and 46 are "strapping" pins that impact start up behavior. They usually need to + // be pulled-down so pulling them up for I2C is a bad idea. To make this hard, we don't + // support I2C on these pins. + // Also 46 is input-only so it'll never work. + if (scl->number == 45 || scl->number == 46 || sda->number == 45 || sda->number == 46) { + mp_raise_ValueError(translate("Invalid pins")); + } + + if (num_addresses > 1) { + mp_raise_ValueError(translate("Only one address is allowed")); + } + self->addresses = addresses; + self->num_addresses = num_addresses; + + self->sda_pin = sda; + self->scl_pin = scl; + self->i2c_num = peripherals_i2c_get_free_num(); + + if (self->i2c_num == I2C_NUM_MAX) { + mp_raise_ValueError(translate("All I2C peripherals are in use")); + } + + const i2c_config_t i2c_conf = { + .mode = I2C_MODE_SLAVE, + .sda_io_num = self->sda_pin->number, + .scl_io_num = self->scl_pin->number, + .sda_pullup_en = GPIO_PULLUP_ENABLE, + .scl_pullup_en = GPIO_PULLUP_ENABLE, + .slave.addr_10bit_en = 0, + .slave.slave_addr = self->addresses[0], + }; + + // Initialize I2C. + esp_err_t err = peripherals_i2c_init(self->i2c_num, &i2c_conf); + if (err != ESP_OK) { + if (err == ESP_FAIL) { + mp_raise_OSError(MP_EIO); + } else { + mp_raise_ValueError(translate("Invalid argument")); + } + } + + claim_pin(sda); + claim_pin(scl); +} + +bool common_hal_i2cperipheral_i2c_peripheral_deinited(i2cperipheral_i2c_peripheral_obj_t *self) { + return self->sda_pin == NULL; +} + +void common_hal_i2cperipheral_i2c_peripheral_deinit(i2cperipheral_i2c_peripheral_obj_t *self) { + if (common_hal_i2cperipheral_i2c_peripheral_deinited(self)) { + return; + } + + peripherals_i2c_deinit(self->i2c_num); + + common_hal_reset_pin(self->sda_pin); + common_hal_reset_pin(self->scl_pin); + self->sda_pin = NULL; + self->scl_pin = NULL; +} + +int common_hal_i2cperipheral_i2c_peripheral_is_addressed(i2cperipheral_i2c_peripheral_obj_t *self, + uint8_t *address, bool *is_read, bool *is_restart) { + *address = self->addresses[0]; + *is_read = true; + *is_restart = false; + return 1; +} + +int common_hal_i2cperipheral_i2c_peripheral_read_byte(i2cperipheral_i2c_peripheral_obj_t *self, uint8_t *data) { + i2c_slave_read_buffer(self->i2c_num, data, 128, 0); + return 1; +} + +int common_hal_i2cperipheral_i2c_peripheral_write_byte(i2cperipheral_i2c_peripheral_obj_t *self, uint8_t data) { + i2c_reset_tx_fifo(self->i2c_num); + i2c_slave_write_buffer(self->i2c_num, &data, 128, 0); + return 1; +} + +void common_hal_i2cperipheral_i2c_peripheral_ack(i2cperipheral_i2c_peripheral_obj_t *self, bool ack) { + +} + +void common_hal_i2cperipheral_i2c_peripheral_close(i2cperipheral_i2c_peripheral_obj_t *self) { + +} diff --git a/ports/espressif/common-hal/i2cperipheral/I2CPeripheral.h b/ports/espressif/common-hal/i2cperipheral/I2CPeripheral.h new file mode 100644 index 0000000000..d3b324b39a --- /dev/null +++ b/ports/espressif/common-hal/i2cperipheral/I2CPeripheral.h @@ -0,0 +1,43 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 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. + */ + +#ifndef MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BUSIO_I2C_PERIPHERAL_H +#define MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BUSIO_I2C_PERIPHERAL_H + +#include "py/obj.h" +#include "peripherals/i2c.h" +#include "common-hal/microcontroller/Pin.h" + +typedef struct { + mp_obj_base_t base; + i2c_port_t i2c_num; + uint8_t *addresses; + uint8_t num_addresses; + const mcu_pin_obj_t *scl_pin; + const mcu_pin_obj_t *sda_pin; +} i2cperipheral_i2c_peripheral_obj_t; + +#endif // MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BUSIO_I2C_PERIPHERAL_H diff --git a/ports/espressif/common-hal/i2cperipheral/__init__.c b/ports/espressif/common-hal/i2cperipheral/__init__.c new file mode 100644 index 0000000000..c67511c536 --- /dev/null +++ b/ports/espressif/common-hal/i2cperipheral/__init__.c @@ -0,0 +1 @@ +// No i2cperipheral module functions. diff --git a/ports/espressif/common-hal/imagecapture/ParallelImageCapture.c b/ports/espressif/common-hal/imagecapture/ParallelImageCapture.c index 67932804f7..b167b5c734 100644 --- a/ports/espressif/common-hal/imagecapture/ParallelImageCapture.c +++ b/ports/espressif/common-hal/imagecapture/ParallelImageCapture.c @@ -79,6 +79,11 @@ void common_hal_imagecapture_parallelimagecapture_construct(imagecapture_paralle } void common_hal_imagecapture_parallelimagecapture_deinit(imagecapture_parallelimagecapture_obj_t *self) { + cam_deinit(); + + self->buffer1 = NULL; + self->buffer2 = NULL; + reset_pin_number(self->data_clock); self->data_clock = NO_PIN; @@ -102,30 +107,73 @@ bool common_hal_imagecapture_parallelimagecapture_deinited(imagecapture_parallel return self->data_clock == NO_PIN; } -void common_hal_imagecapture_parallelimagecapture_capture(imagecapture_parallelimagecapture_obj_t *self, void *buffer, size_t bufsize) { - size_t size = bufsize / 2; // count is in pixels - if (size != self->config.size || buffer != self->config.frame1_buffer) { - cam_deinit(); - self->config.size = bufsize / 2; // count is in pixels(?) - self->config.frame1_buffer = buffer; - - cam_init(&self->config); - } else { - cam_give(buffer); +void common_hal_imagecapture_parallelimagecapture_continuous_capture_start(imagecapture_parallelimagecapture_obj_t *self, mp_obj_t buffer1, mp_obj_t buffer2) { + if (buffer1 == self->buffer1 && buffer2 == self->buffer2) { + return; } + + mp_buffer_info_t bufinfo1, bufinfo2 = {}; + mp_get_buffer_raise(buffer1, &bufinfo1, MP_BUFFER_RW); + if (buffer2 != mp_const_none) { + mp_get_buffer_raise(buffer2, &bufinfo2, MP_BUFFER_RW); + if (bufinfo1.len != bufinfo2.len) { + mp_raise_ValueError(translate("Buffers must be same size")); + } + } + + self->buffer1 = buffer1; + self->buffer2 = buffer2; + + + cam_deinit(); + self->config.size = bufinfo1.len / 2; // count is in pixels + self->config.frame1_buffer = bufinfo1.buf; + self->config.frame2_buffer = bufinfo2.buf; + self->buffer_to_give = NULL; + + cam_init(&self->config); cam_start(); +} + +void common_hal_imagecapture_parallelimagecapture_continuous_capture_stop(imagecapture_parallelimagecapture_obj_t *self) { + cam_deinit(); + self->buffer1 = self->buffer2 = NULL; + self->buffer_to_give = NULL; +} + +STATIC void common_hal_imagecapture_parallelimagecapture_continuous_capture_give_frame(imagecapture_parallelimagecapture_obj_t *self) { + if (self->buffer_to_give) { + cam_give(self->buffer_to_give); + self->buffer_to_give = NULL; + } +} + +mp_obj_t common_hal_imagecapture_parallelimagecapture_continuous_capture_get_frame(imagecapture_parallelimagecapture_obj_t *self) { + if (self->buffer1 == NULL) { + mp_raise_RuntimeError(translate("No capture in progress")); + } + common_hal_imagecapture_parallelimagecapture_continuous_capture_give_frame(self); while (!cam_ready()) { RUN_BACKGROUND_TASKS; if (mp_hal_is_interrupted()) { - self->config.size = 0; // force re-init next time - cam_stop(); - return; + return mp_const_none; } } - uint8_t *unused; - cam_take(&unused); // this just "returns" buffer + cam_take(&self->buffer_to_give); - cam_stop(); + if (self->buffer_to_give == self->config.frame1_buffer) { + return self->buffer1; + } + if (self->buffer_to_give == self->config.frame2_buffer) { + return self->buffer2; + } + + return mp_const_none; // should be unreachable +} + +void common_hal_imagecapture_parallelimagecapture_singleshot_capture(imagecapture_parallelimagecapture_obj_t *self, mp_obj_t buffer) { + common_hal_imagecapture_parallelimagecapture_continuous_capture_start(self, buffer, mp_const_none); + common_hal_imagecapture_parallelimagecapture_continuous_capture_get_frame(self); } diff --git a/ports/espressif/common-hal/imagecapture/ParallelImageCapture.h b/ports/espressif/common-hal/imagecapture/ParallelImageCapture.h index 4dd65bc904..45f7a2734e 100644 --- a/ports/espressif/common-hal/imagecapture/ParallelImageCapture.h +++ b/ports/espressif/common-hal/imagecapture/ParallelImageCapture.h @@ -26,6 +26,7 @@ #pragma once +#include "py/obj.h" #include "shared-bindings/imagecapture/ParallelImageCapture.h" #include "cam.h" @@ -36,4 +37,6 @@ struct imagecapture_parallelimagecapture_obj { gpio_num_t vertical_sync; gpio_num_t horizontal_reference; uint8_t data_count; + mp_obj_t buffer1, buffer2; + uint8_t *buffer_to_give; }; diff --git a/ports/espressif/common-hal/rotaryio/IncrementalEncoder.c b/ports/espressif/common-hal/rotaryio/IncrementalEncoder.c index 59fa54880a..b36c79b4f6 100644 --- a/ports/espressif/common-hal/rotaryio/IncrementalEncoder.c +++ b/ports/espressif/common-hal/rotaryio/IncrementalEncoder.c @@ -84,3 +84,13 @@ void common_hal_rotaryio_incrementalencoder_set_position(rotaryio_incrementalenc self->position = new_position; pcnt_counter_clear(self->unit); } + +mp_int_t common_hal_rotaryio_incrementalencoder_get_divisor(rotaryio_incrementalencoder_obj_t *self) { + return 4; +} + +void common_hal_rotaryio_incrementalencoder_set_divisor(rotaryio_incrementalencoder_obj_t *self, mp_int_t divisor) { + if (divisor != 4) { + mp_raise_ValueError(translate("divisor must be 4")); + } +} diff --git a/ports/espressif/common-hal/socketpool/Socket.c b/ports/espressif/common-hal/socketpool/Socket.c index 0ffc311229..c16be01998 100644 --- a/ports/espressif/common-hal/socketpool/Socket.c +++ b/ports/espressif/common-hal/socketpool/Socket.c @@ -27,7 +27,7 @@ #include "shared-bindings/socketpool/Socket.h" #include "bindings/espidf/__init__.h" -#include "lib/utils/interrupt_char.h" +#include "shared/runtime/interrupt_char.h" #include "py/mperrno.h" #include "py/runtime.h" #include "supervisor/shared/tick.h" diff --git a/ports/espressif/common-hal/ssl/SSLSocket.c b/ports/espressif/common-hal/ssl/SSLSocket.c index d24e3bb145..f9e13029cc 100644 --- a/ports/espressif/common-hal/ssl/SSLSocket.c +++ b/ports/espressif/common-hal/ssl/SSLSocket.c @@ -30,7 +30,7 @@ #include "shared-bindings/ssl/SSLContext.h" #include "bindings/espidf/__init__.h" -#include "lib/utils/interrupt_char.h" +#include "shared/runtime/interrupt_char.h" #include "py/mperrno.h" #include "py/runtime.h" #include "supervisor/shared/tick.h" diff --git a/ports/espressif/common-hal/watchdog/WatchDogTimer.c b/ports/espressif/common-hal/watchdog/WatchDogTimer.c index f17a037ff4..729ab5815a 100644 --- a/ports/espressif/common-hal/watchdog/WatchDogTimer.c +++ b/ports/espressif/common-hal/watchdog/WatchDogTimer.c @@ -34,7 +34,7 @@ void esp_task_wdt_isr_user_handler(void) { mp_obj_exception_clear_traceback(MP_OBJ_FROM_PTR(&mp_watchdog_timeout_exception)); - MP_STATE_VM(mp_pending_exception) = &mp_watchdog_timeout_exception; + MP_STATE_THREAD(mp_pending_exception) = &mp_watchdog_timeout_exception; #if MICROPY_ENABLE_SCHEDULER if (MP_STATE_VM(sched_state) == MP_SCHED_IDLE) { MP_STATE_VM(sched_state) = MP_SCHED_PENDING; diff --git a/ports/espressif/common-hal/wifi/Radio.c b/ports/espressif/common-hal/wifi/Radio.c index 9d48ff1257..d3849b28b2 100644 --- a/ports/espressif/common-hal/wifi/Radio.c +++ b/ports/espressif/common-hal/wifi/Radio.c @@ -30,7 +30,7 @@ #include #include "common-hal/wifi/__init__.h" -#include "lib/utils/interrupt_char.h" +#include "shared/runtime/interrupt_char.h" #include "py/gc.h" #include "py/runtime.h" #include "shared-bindings/ipaddress/IPv4Address.h" diff --git a/ports/espressif/common-hal/wifi/ScannedNetworks.c b/ports/espressif/common-hal/wifi/ScannedNetworks.c index 62ef62b7f5..25c2da0473 100644 --- a/ports/espressif/common-hal/wifi/ScannedNetworks.c +++ b/ports/espressif/common-hal/wifi/ScannedNetworks.c @@ -28,7 +28,7 @@ #include -#include "lib/utils/interrupt_char.h" +#include "shared/runtime/interrupt_char.h" #include "py/gc.h" #include "py/objstr.h" #include "py/runtime.h" diff --git a/ports/espressif/mpconfigport.mk b/ports/espressif/mpconfigport.mk index bcd08aefe3..a7b69e0933 100644 --- a/ports/espressif/mpconfigport.mk +++ b/ports/espressif/mpconfigport.mk @@ -25,7 +25,7 @@ CIRCUITPY_DUALBANK ?= 1 CIRCUITPY_FRAMEBUFFERIO ?= 1 CIRCUITPY_FREQUENCYIO ?= 1 CIRCUITPY_IMAGECAPTURE ?= 1 -CIRCUITPY_I2CPERIPHERAL ?= 0 +CIRCUITPY_I2CPERIPHERAL ?= 1 CIRCUITPY_RGBMATRIX ?= 1 CIRCUITPY_ROTARYIO ?= 1 CIRCUITPY_NVM ?= 1 diff --git a/ports/espressif/mphalport.h b/ports/espressif/mphalport.h index 6550b8c212..7ff8129903 100644 --- a/ports/espressif/mphalport.h +++ b/ports/espressif/mphalport.h @@ -30,7 +30,7 @@ #include #include -#include "lib/utils/interrupt_char.h" +#include "shared/runtime/interrupt_char.h" #include "py/mpconfig.h" #include "supervisor/shared/tick.h" diff --git a/ports/espressif/peripherals/i2c.c b/ports/espressif/peripherals/i2c.c new file mode 100644 index 0000000000..7a85349f96 --- /dev/null +++ b/ports/espressif/peripherals/i2c.c @@ -0,0 +1,83 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 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 "peripherals/i2c.h" + +typedef enum { + STATUS_FREE = 0, + STATUS_IN_USE, + STATUS_NEVER_RESET +} i2c_status_t; + +static i2c_status_t i2c_status[I2C_NUM_MAX]; + +void i2c_reset(void) { + for (i2c_port_t num = 0; num < I2C_NUM_MAX; num++) { + if (i2c_status[num] == STATUS_IN_USE) { + i2c_driver_delete(num); + i2c_status[num] = STATUS_FREE; + } + } +} + +void never_reset_i2c(i2c_port_t num) { + i2c_status[num] = STATUS_NEVER_RESET; +} + +esp_err_t peripherals_i2c_init(i2c_port_t num, const i2c_config_t *i2c_conf) { + esp_err_t err = i2c_param_config(num, i2c_conf); + if (err != ESP_OK) { + return err; + } + size_t rx_buf_len = 0; + size_t tx_buf_len = 0; + if (i2c_conf->mode == I2C_MODE_SLAVE) { + rx_buf_len = 256; + tx_buf_len = 256; + } + return i2c_driver_install(num, i2c_conf->mode, rx_buf_len, tx_buf_len, 0); +} + +void peripherals_i2c_deinit(i2c_port_t num) { + i2c_reset_rx_fifo(num); + i2c_reset_tx_fifo(num); + i2c_driver_delete(num); + i2c_status[num] = STATUS_FREE; +} + +i2c_port_t peripherals_i2c_get_free_num(void) { + i2c_port_t i2c_num = I2C_NUM_MAX; + for (i2c_port_t num = 0; num < I2C_NUM_MAX; num++) { + if (i2c_status[num] == STATUS_FREE) { + i2c_num = num; + break; + } + } + if (i2c_num != I2C_NUM_MAX) { + i2c_status[i2c_num] = STATUS_IN_USE; + } + return i2c_num; +} diff --git a/ports/espressif/peripherals/i2c.h b/ports/espressif/peripherals/i2c.h new file mode 100644 index 0000000000..4e7946d177 --- /dev/null +++ b/ports/espressif/peripherals/i2c.h @@ -0,0 +1,38 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 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. + */ + +#ifndef MICROPY_INCLUDED_ESPRESSIF_PERIPHERALS_I2C_HANDLER_H +#define MICROPY_INCLUDED_ESPRESSIF_PERIPHERALS_I2C_HANDLER_H + +#include "driver/i2c.h" + +extern void i2c_reset(void); +extern void never_reset_i2c(i2c_port_t num); +extern esp_err_t peripherals_i2c_init(i2c_port_t num, const i2c_config_t *i2c_conf); +extern void peripherals_i2c_deinit(i2c_port_t num); +extern i2c_port_t peripherals_i2c_get_free_num(void); + +#endif // MICROPY_INCLUDED_ESPRESSIF_PERIPHERALS_I2C_HANDLER_H diff --git a/ports/espressif/supervisor/usb.c b/ports/espressif/supervisor/usb.c index c55c209b4a..fa9d09fa44 100644 --- a/ports/espressif/supervisor/usb.c +++ b/ports/espressif/supervisor/usb.c @@ -29,8 +29,8 @@ #include "supervisor/usb.h" #include "supervisor/esp_port.h" #include "supervisor/port.h" -#include "lib/utils/interrupt_char.h" -#include "lib/mp-readline/readline.h" +#include "shared/runtime/interrupt_char.h" +#include "shared/readline/readline.h" #include "hal/gpio_ll.h" #include "soc/usb_periph.h" @@ -127,7 +127,7 @@ void tud_cdc_rx_wanted_cb(uint8_t itf, char wanted_char) { // CircuitPython's VM is run in a separate FreeRTOS task from TinyUSB. // So, we must notify the other task when a CTRL-C is received. port_wake_main_task(); - // Workaround for using lib/utils/interrupt_char.c + // Workaround for using shared/runtime/interrupt_char.c // Compare mp_interrupt_char with wanted_char and ignore if not matched if (mp_interrupt_char == wanted_char) { tud_cdc_read_flush(); // flush read fifo diff --git a/ports/litex/Makefile b/ports/litex/Makefile index b4bc135dca..e483832fc1 100644 --- a/ports/litex/Makefile +++ b/ports/litex/Makefile @@ -169,7 +169,7 @@ all: $(BUILD)/firmware.bin $(BUILD)/firmware.dfu $(BUILD)/firmware.elf: $(OBJ) $(STEPECHO) "LINK $@" $(Q)$(CC) -o $@ $(LDFLAGS) $^ -Wl,--start-group $(LIBS) -Wl,--end-group - $(Q)$(SIZE) $@ | $(PYTHON3) $(TOP)/tools/build_memory_info.py $(LD_FILE) + $(Q)$(SIZE) $@ | $(PYTHON) $(TOP)/tools/build_memory_info.py $(LD_FILE) $(BUILD)/firmware.bin: $(BUILD)/firmware.elf $(STEPECHO) "Create $@" @@ -183,7 +183,7 @@ $(BUILD)/firmware.hex: $(BUILD)/firmware.elf $(BUILD)/firmware.dfu: $(BUILD)/firmware.bin $(ECHO) "Create $@" - $(PYTHON3) $(TOP)/tools/dfu.py -b $^ -D 0x1209:0x5bf0 "$(BUILD)/firmware.dfu" + $(PYTHON) $(TOP)/tools/dfu.py -b $^ -D 0x1209:0x5bf0 "$(BUILD)/firmware.dfu" include $(TOP)/py/mkrules.mk diff --git a/ports/litex/mphalport.h b/ports/litex/mphalport.h index 62c8e0bab3..780bd25f9a 100644 --- a/ports/litex/mphalport.h +++ b/ports/litex/mphalport.h @@ -30,7 +30,7 @@ #include #include -#include "lib/utils/interrupt_char.h" +#include "shared/runtime/interrupt_char.h" #include "py/mpconfig.h" #include "supervisor/shared/tick.h" diff --git a/ports/litex/supervisor/usb.c b/ports/litex/supervisor/usb.c index b626aaf496..87c9f6dee4 100644 --- a/ports/litex/supervisor/usb.c +++ b/ports/litex/supervisor/usb.c @@ -26,8 +26,8 @@ */ #include "supervisor/usb.h" -#include "lib/utils/interrupt_char.h" -#include "lib/mp-readline/readline.h" +#include "shared/runtime/interrupt_char.h" +#include "shared/readline/readline.h" void init_usb_hardware(void) { diff --git a/ports/mimxrt10xx/Makefile b/ports/mimxrt10xx/Makefile index 310b5d6f31..f330cddf14 100644 --- a/ports/mimxrt10xx/Makefile +++ b/ports/mimxrt10xx/Makefile @@ -60,7 +60,7 @@ INC += \ -I. \ -I../.. \ -I../lib/mp-readline \ - -I../lib/timeutils \ + -I../shared/timeutils \ -I../../lib/tinyusb/src \ -I../../supervisor/shared/usb \ -I$(BUILD) \ @@ -207,7 +207,7 @@ $(BUILD)/firmware.bin: $(BUILD)/firmware.elf $(BUILD)/firmware.uf2: $(BUILD)/firmware.elf $(STEPECHO) "Create $@" $(Q)$(OBJCOPY) -O binary -j .text -j .ARM.exidx -j .data -j .itcm -j .dtcm_data $^ $@-binpart - $(Q)$(PYTHON3) $(TOP)/tools/uf2/utils/uf2conv.py -b $(BOOTLOADER_SIZE) -f MIMXRT10XX -c -o $@ $@-binpart + $(Q)$(PYTHON) $(TOP)/tools/uf2/utils/uf2conv.py -b $(BOOTLOADER_SIZE) -f MIMXRT10XX -c -o $@ $@-binpart $(Q)rm $@-binpart $(BUILD)/firmware.hex: $(BUILD)/firmware.elf diff --git a/ports/mimxrt10xx/common-hal/busio/UART.c b/ports/mimxrt10xx/common-hal/busio/UART.c index ec0296156a..16c4ba77e4 100644 --- a/ports/mimxrt10xx/common-hal/busio/UART.c +++ b/ports/mimxrt10xx/common-hal/busio/UART.c @@ -30,7 +30,7 @@ #include "shared-bindings/busio/UART.h" #include "mpconfigport.h" -#include "lib/utils/interrupt_char.h" +#include "shared/runtime/interrupt_char.h" #include "supervisor/shared/tick.h" #include "py/gc.h" #include "py/mperrno.h" @@ -345,7 +345,10 @@ size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t // if we timed out, stop the transfer if (self->rx_ongoing) { + uint32_t recvd = 0; + LPUART_TransferGetReceiveCount(self->uart, &self->handle, &recvd); LPUART_TransferAbortReceive(self->uart, &self->handle); + return recvd; } // No data left, we got it all @@ -355,7 +358,11 @@ size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t // The only place we can reliably tell how many bytes have been received is from the current // wp in the handle (because the abort nukes rxDataSize, and reading it before abort is a race.) - return self->handle.rxData - data; + if (self->handle.rxData > data) { + return self->handle.rxData - data; + } else { + return len; + } } // Write characters. diff --git a/ports/mimxrt10xx/common-hal/rtc/RTC.c b/ports/mimxrt10xx/common-hal/rtc/RTC.c index aabe2b09f2..8619a7eaec 100644 --- a/ports/mimxrt10xx/common-hal/rtc/RTC.c +++ b/ports/mimxrt10xx/common-hal/rtc/RTC.c @@ -29,7 +29,7 @@ #include "py/obj.h" #include "py/runtime.h" -#include "lib/timeutils/timeutils.h" +#include "shared/timeutils/timeutils.h" #include "shared-bindings/rtc/__init__.h" #include "supervisor/shared/translate.h" diff --git a/ports/mimxrt10xx/fatfs_port.c b/ports/mimxrt10xx/fatfs_port.c index e6eee20495..58a0ef0d72 100644 --- a/ports/mimxrt10xx/fatfs_port.c +++ b/ports/mimxrt10xx/fatfs_port.c @@ -28,7 +28,7 @@ #include "py/runtime.h" #include "lib/oofatfs/ff.h" /* FatFs lower layer API */ #include "lib/oofatfs/diskio.h" /* FatFs lower layer API */ -#include "lib/timeutils/timeutils.h" +#include "shared/timeutils/timeutils.h" #if CIRCUITPY_RTC #include "shared-bindings/rtc/RTC.h" diff --git a/ports/nrf/Makefile b/ports/nrf/Makefile index 01050324f5..acd1509297 100755 --- a/ports/nrf/Makefile +++ b/ports/nrf/Makefile @@ -239,7 +239,7 @@ $(BUILD)/firmware.elf: $(OBJ) $(GENERATED_LD_FILE) $(STEPECHO) "LINK $@" $(Q)echo $(OBJ) > $(BUILD)/firmware.objs $(Q)$(CC) -o $@ $(LDFLAGS) @$(BUILD)/firmware.objs -Wl,--start-group $(LIBS) -Wl,--end-group - $(Q)$(SIZE) $@ | $(PYTHON3) $(TOP)/tools/build_memory_info.py $(GENERATED_LD_FILE) + $(Q)$(SIZE) $@ | $(PYTHON) $(TOP)/tools/build_memory_info.py $(GENERATED_LD_FILE) $(BUILD)/firmware.bin: $(BUILD)/firmware.elf $(STEPECHO) "Create $@" @@ -257,7 +257,7 @@ $(BUILD)/firmware.combined.hex: $(BUILD)/firmware.hex $(SOFTDEV_HEX) $(BUILD)/firmware.uf2: $(BUILD)/firmware.hex $(ECHO) "Create $@" - $(PYTHON3) $(TOP)/tools/uf2/utils/uf2conv.py -f 0xADA52840 -c -o "$(BUILD)/firmware.uf2" $^ + $(PYTHON) $(TOP)/tools/uf2/utils/uf2conv.py -f 0xADA52840 -c -o "$(BUILD)/firmware.uf2" $^ diff --git a/ports/nrf/boards/makerdiary_m60_keyboard/pins.c b/ports/nrf/boards/makerdiary_m60_keyboard/pins.c index 9ee0a06e59..485b968f4a 100644 --- a/ports/nrf/boards/makerdiary_m60_keyboard/pins.c +++ b/ports/nrf/boards/makerdiary_m60_keyboard/pins.c @@ -36,6 +36,12 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_BTN), MP_ROM_PTR(&pin_P0_27) }, + { MP_ROM_QSTR(MP_QSTR_CHARGING), MP_ROM_PTR(&pin_P0_03) }, + { MP_ROM_QSTR(MP_QSTR_VOLTAGE_MONITOR), MP_ROM_PTR(&pin_P0_02) }, + { MP_ROM_QSTR(MP_QSTR_BATTERY), MP_ROM_PTR(&pin_P0_02) }, + + { MP_ROM_QSTR(MP_QSTR_RGB_POWER), MP_ROM_PTR(&pin_P1_04) }, + // { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) } }; diff --git a/ports/nrf/boards/pca10100/mpconfigboard.h b/ports/nrf/boards/pca10100/mpconfigboard.h index 20d9d9aeb3..1456f29949 100644 --- a/ports/nrf/boards/pca10100/mpconfigboard.h +++ b/ports/nrf/boards/pca10100/mpconfigboard.h @@ -27,7 +27,7 @@ #include "nrfx/hal/nrf_gpio.h" -#define MICROPY_HW_BOARD_NAME "PCA10100 nRF52833 Dongle" +#define MICROPY_HW_BOARD_NAME "PCA10100 nRF52833 DK" #define MICROPY_HW_MCU_NAME "nRF52833" #define MICROPY_HW_LED_STATUS (&pin_P0_13) diff --git a/ports/nrf/boards/simmel/mpconfigboard.mk b/ports/nrf/boards/simmel/mpconfigboard.mk index 82fc68a235..df67271445 100644 --- a/ports/nrf/boards/simmel/mpconfigboard.mk +++ b/ports/nrf/boards/simmel/mpconfigboard.mk @@ -28,6 +28,7 @@ CIRCUITPY_NVM = 0 CIRCUITPY_PIXELBUF = 0 CIRCUITPY_PULSEIO = 0 CIRCUITPY_PWMIO = 1 +# Deliberately excluded for other reasons than code space, see #5534 CIRCUITPY_RAINBOWIO = 0 CIRCUITPY_RGBMATRIX = 0 CIRCUITPY_ROTARYIO = 0 diff --git a/ports/nrf/common-hal/_bleio/CharacteristicBuffer.c b/ports/nrf/common-hal/_bleio/CharacteristicBuffer.c index ca37f41c1a..d45bd89f3d 100644 --- a/ports/nrf/common-hal/_bleio/CharacteristicBuffer.c +++ b/ports/nrf/common-hal/_bleio/CharacteristicBuffer.c @@ -31,7 +31,7 @@ #include "ble_gatts.h" #include "nrf_nvic.h" -#include "lib/utils/interrupt_char.h" +#include "shared/runtime/interrupt_char.h" #include "py/runtime.h" #include "py/stream.h" diff --git a/ports/nrf/common-hal/_bleio/Connection.c b/ports/nrf/common-hal/_bleio/Connection.c index b94ad09e6a..0d8d8c32f0 100644 --- a/ports/nrf/common-hal/_bleio/Connection.c +++ b/ports/nrf/common-hal/_bleio/Connection.c @@ -34,7 +34,7 @@ #include "ble_drv.h" #include "ble_hci.h" #include "nrf_soc.h" -#include "lib/utils/interrupt_char.h" +#include "shared/runtime/interrupt_char.h" #include "py/gc.h" #include "py/objlist.h" #include "py/objstr.h" diff --git a/ports/nrf/common-hal/_bleio/PacketBuffer.c b/ports/nrf/common-hal/_bleio/PacketBuffer.c index ee786c8292..f7d35cbdb5 100644 --- a/ports/nrf/common-hal/_bleio/PacketBuffer.c +++ b/ports/nrf/common-hal/_bleio/PacketBuffer.c @@ -31,7 +31,7 @@ #include "ble_gatts.h" #include "nrf_nvic.h" -#include "lib/utils/interrupt_char.h" +#include "shared/runtime/interrupt_char.h" #include "py/runtime.h" #include "py/stream.h" @@ -356,9 +356,12 @@ mp_int_t common_hal_bleio_packet_buffer_write(bleio_packet_buffer_obj_t *self, c if (self->conn_handle == BLE_CONN_HANDLE_INVALID) { return -1; } - uint16_t outgoing_packet_length = common_hal_bleio_packet_buffer_get_outgoing_packet_length(self); + mp_int_t outgoing_packet_length = common_hal_bleio_packet_buffer_get_outgoing_packet_length(self); + if (outgoing_packet_length < 0) { + return -1; + } - uint16_t total_len = len + header_len; + 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); @@ -369,7 +372,7 @@ mp_int_t common_hal_bleio_packet_buffer_write(bleio_packet_buffer_obj_t *self, c } outgoing_packet_length = MIN(outgoing_packet_length, self->max_packet_size); - if (len + self->pending_size > outgoing_packet_length) { + 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 && diff --git a/ports/nrf/common-hal/busio/UART.c b/ports/nrf/common-hal/busio/UART.c index 4e7fd3079e..132f5d9272 100644 --- a/ports/nrf/common-hal/busio/UART.c +++ b/ports/nrf/common-hal/busio/UART.c @@ -27,7 +27,7 @@ #include "shared-bindings/microcontroller/__init__.h" #include "shared-bindings/busio/UART.h" -#include "lib/utils/interrupt_char.h" +#include "shared/runtime/interrupt_char.h" #include "py/mpconfig.h" #include "py/gc.h" #include "py/mperrno.h" diff --git a/ports/nrf/common-hal/rotaryio/IncrementalEncoder.h b/ports/nrf/common-hal/rotaryio/IncrementalEncoder.h index 3693131056..86fbe5475f 100644 --- a/ports/nrf/common-hal/rotaryio/IncrementalEncoder.h +++ b/ports/nrf/common-hal/rotaryio/IncrementalEncoder.h @@ -36,7 +36,8 @@ typedef struct { uint8_t pin_a; uint8_t pin_b; uint8_t state; // - int8_t quarter_count; // count intermediate transitions between detents + int8_t sub_count; // count intermediate transitions between detents + int8_t divisor; // Number of quadrature edges required per count mp_int_t position; } rotaryio_incrementalencoder_obj_t; diff --git a/ports/nrf/common-hal/rtc/RTC.c b/ports/nrf/common-hal/rtc/RTC.c index 24825a979f..074079cd6b 100644 --- a/ports/nrf/common-hal/rtc/RTC.c +++ b/ports/nrf/common-hal/rtc/RTC.c @@ -28,7 +28,7 @@ #include "py/obj.h" #include "py/runtime.h" -#include "lib/timeutils/timeutils.h" +#include "shared/timeutils/timeutils.h" #include "shared-bindings/rtc/__init__.h" #include "supervisor/port.h" #include "supervisor/shared/translate.h" diff --git a/ports/nrf/common-hal/watchdog/WatchDogTimer.c b/ports/nrf/common-hal/watchdog/WatchDogTimer.c index 1798c52609..cd7aa449bf 100644 --- a/ports/nrf/common-hal/watchdog/WatchDogTimer.c +++ b/ports/nrf/common-hal/watchdog/WatchDogTimer.c @@ -62,7 +62,7 @@ STATIC void watchdogtimer_timer_event_handler(nrf_timer_event_t event_type, void nrfx_timer_pause(timer); self->mode = WATCHDOGMODE_NONE; mp_obj_exception_clear_traceback(MP_OBJ_FROM_PTR(&mp_watchdog_timeout_exception)); - MP_STATE_VM(mp_pending_exception) = &mp_watchdog_timeout_exception; + MP_STATE_THREAD(mp_pending_exception) = &mp_watchdog_timeout_exception; #if MICROPY_ENABLE_SCHEDULER if (MP_STATE_VM(sched_state) == MP_SCHED_IDLE) { MP_STATE_VM(sched_state) = MP_SCHED_PENDING; diff --git a/ports/nrf/fatfs_port.c b/ports/nrf/fatfs_port.c index f2644adbd3..5882864bbe 100644 --- a/ports/nrf/fatfs_port.c +++ b/ports/nrf/fatfs_port.c @@ -26,7 +26,7 @@ #include "py/runtime.h" #include "lib/oofatfs/ff.h" -#include "lib/timeutils/timeutils.h" +#include "shared/timeutils/timeutils.h" #include "shared-bindings/rtc/RTC.h" #include "shared-bindings/time/__init__.h" diff --git a/ports/nrf/mphalport.h b/ports/nrf/mphalport.h index 2b13f82db1..a93d998855 100644 --- a/ports/nrf/mphalport.h +++ b/ports/nrf/mphalport.h @@ -30,7 +30,7 @@ #include #include -#include "lib/utils/interrupt_char.h" +#include "shared/runtime/interrupt_char.h" #include "nrfx_uarte.h" #include "py/mpconfig.h" #include "supervisor/shared/tick.h" diff --git a/ports/nrf/supervisor/usb.c b/ports/nrf/supervisor/usb.c index 3ca9b8365d..6031cced50 100644 --- a/ports/nrf/supervisor/usb.c +++ b/ports/nrf/supervisor/usb.c @@ -27,8 +27,8 @@ #include "nrfx.h" #include "nrfx_power.h" #include "supervisor/usb.h" -#include "lib/utils/interrupt_char.h" -#include "lib/mp-readline/readline.h" +#include "shared/runtime/interrupt_char.h" +#include "shared/readline/readline.h" #include "lib/tinyusb/src/device/usbd.h" #include "supervisor/background_callback.h" diff --git a/ports/raspberrypi/Makefile b/ports/raspberrypi/Makefile index ffab1fbcd0..2739bf6547 100644 --- a/ports/raspberrypi/Makefile +++ b/ports/raspberrypi/Makefile @@ -60,7 +60,7 @@ HAL_DIR=hal/$(MCU_SERIES) INC += -I. \ -I../.. \ -I../lib/mp-readline \ - -I../lib/timeutils \ + -I../shared/timeutils \ -Iboards/$(BOARD) \ -Iboards/ \ -isystem sdk/ \ @@ -198,7 +198,7 @@ SRC_C += \ audio_dma.c \ background.c \ peripherals/pins.c \ - extmod/crypto-algorithms/sha256.c \ + lib/crypto-algorithms/sha256.c \ fatfs_port.c \ lib/tinyusb/src/portable/raspberrypi/rp2040/dcd_rp2040.c \ lib/tinyusb/src/portable/raspberrypi/rp2040/rp2040_usb.c \ @@ -249,7 +249,7 @@ $(BUILD)/boot2_padded_checksummed.o: $(BUILD)/boot2_padded_checksummed.S $(BUILD)/boot2_padded_checksummed.S: $(BUILD)/boot2.bin $(STEPECHO) "PAD_CHECKSUM $<" - $(Q)$(PYTHON3) sdk/src/rp2_common/boot_stage2/pad_checksum -s 0xffffffff $< $@ + $(Q)$(PYTHON) sdk/src/rp2_common/boot_stage2/pad_checksum -s 0xffffffff $< $@ $(BUILD)/boot2.bin: $(BUILD)/boot2.elf $(STEPECHO) "OBJCOPY $<" @@ -258,11 +258,11 @@ $(BUILD)/boot2.bin: $(BUILD)/boot2.elf $(BUILD)/stage2.c: stage2.c.jinja gen_stage2.py | $(BUILD)/ $(STEPECHO) "GEN $<" - $(Q)$(PYTHON3) gen_stage2.py $< $@ $(EXTERNAL_FLASH_DEVICES) + $(Q)$(PYTHON) gen_stage2.py $< $@ $(EXTERNAL_FLASH_DEVICES) $(HEADER_BUILD)/flash_info.h: flash_info.h.jinja gen_stage2.py | $(HEADER_BUILD)/ $(STEPECHO) "GEN $<" - $(Q)$(PYTHON3) gen_stage2.py $< $@ $(EXTERNAL_FLASH_DEVICES) + $(Q)$(PYTHON) gen_stage2.py $< $@ $(EXTERNAL_FLASH_DEVICES) $(BUILD)/supervisor/internal_flash.o: $(HEADER_BUILD)/flash_info.h @@ -280,7 +280,7 @@ $(BUILD)/firmware.elf: $(OBJ) link.ld $(Q)echo $(OBJ) > $(BUILD)/firmware.objs $(Q)echo $(PICO_LDFLAGS) > $(BUILD)/firmware.ldflags $(Q)$(CC) -o $@ $(CFLAGS) @$(BUILD)/firmware.ldflags -Wl,-T,link.ld -Wl,-Map=$@.map -Wl,-cref -Wl,--gc-sections @$(BUILD)/firmware.objs - $(Q)$(SIZE) $@ | $(PYTHON3) $(TOP)/tools/build_memory_info.py link.ld + $(Q)$(SIZE) $@ | $(PYTHON) $(TOP)/tools/build_memory_info.py link.ld $(BUILD)/firmware.bin: $(BUILD)/firmware.elf $(STEPECHO) "Create $@" @@ -288,7 +288,7 @@ $(BUILD)/firmware.bin: $(BUILD)/firmware.elf $(BUILD)/firmware.uf2: $(BUILD)/firmware.bin $(STEPECHO) "Create $@" - $(Q)$(PYTHON3) $(TOP)/tools/uf2/utils/uf2conv.py -f 0xe48bff56 -b 0x10000000 -c -o $@ $^ + $(Q)$(PYTHON) $(TOP)/tools/uf2/utils/uf2conv.py -f 0xe48bff56 -b 0x10000000 -c -o $@ $^ include $(TOP)/py/mkrules.mk diff --git a/ports/raspberrypi/bindings/rp2pio/StateMachine.c b/ports/raspberrypi/bindings/rp2pio/StateMachine.c index 3dffc39363..39b975ff8d 100644 --- a/ports/raspberrypi/bindings/rp2pio/StateMachine.c +++ b/ports/raspberrypi/bindings/rp2pio/StateMachine.c @@ -33,9 +33,9 @@ #include "bindings/rp2pio/StateMachine.h" #include "shared-bindings/util.h" -#include "lib/utils/buffer_helper.h" -#include "lib/utils/context_manager_helpers.h" -#include "lib/utils/interrupt_char.h" +#include "shared/runtime/buffer_helper.h" +#include "shared/runtime/context_manager_helpers.h" +#include "shared/runtime/interrupt_char.h" #include "py/binary.h" #include "py/mperrno.h" #include "py/objproperty.h" @@ -138,7 +138,7 @@ //| ... //| -STATIC mp_obj_t rp2pio_statemachine_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +STATIC mp_obj_t rp2pio_statemachine_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { rp2pio_statemachine_obj_t *self = m_new_obj(rp2pio_statemachine_obj_t); self->base.type = &rp2pio_statemachine_type; enum { ARG_program, ARG_frequency, ARG_init, @@ -191,7 +191,7 @@ STATIC mp_obj_t rp2pio_statemachine_make_new(const mp_obj_type_t *type, size_t n { MP_QSTR_user_interruptible, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = true} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); mp_buffer_info_t bufinfo; mp_get_buffer_raise(args[ARG_program].u_obj, &bufinfo, MP_BUFFER_READ); diff --git a/ports/raspberrypi/bindings/rp2pio/__init__.c b/ports/raspberrypi/bindings/rp2pio/__init__.c index 68f7cf3019..b3b45dc923 100644 --- a/ports/raspberrypi/bindings/rp2pio/__init__.c +++ b/ports/raspberrypi/bindings/rp2pio/__init__.c @@ -58,3 +58,5 @@ const mp_obj_module_t rp2pio_module = { .base = { &mp_type_module }, .globals = (mp_obj_dict_t *)&rp2pio_module_globals, }; + +MP_REGISTER_MODULE(MP_QSTR_rp2pio, rp2pio_module, CIRCUITPY_RP2PIO); diff --git a/ports/raspberrypi/boards/adafruit_kb2040/board.c b/ports/raspberrypi/boards/adafruit_kb2040/board.c new file mode 100644 index 0000000000..eac54ce460 --- /dev/null +++ b/ports/raspberrypi/boards/adafruit_kb2040/board.c @@ -0,0 +1,43 @@ +/* + * 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" + +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/adafruit_kb2040/mpconfigboard.h b/ports/raspberrypi/boards/adafruit_kb2040/mpconfigboard.h new file mode 100644 index 0000000000..c01f713e48 --- /dev/null +++ b/ports/raspberrypi/boards/adafruit_kb2040/mpconfigboard.h @@ -0,0 +1,10 @@ +#define MICROPY_HW_BOARD_NAME "Adafruit KB2040" +#define MICROPY_HW_MCU_NAME "rp2040" + +#define MICROPY_HW_NEOPIXEL (&pin_GPIO17) + +#define DEFAULT_I2C_BUS_SDA (&pin_GPIO12) +#define DEFAULT_I2C_BUS_SCL (&pin_GPIO13) + +#define DEFAULT_UART_BUS_TX (&pin_GPIO0) +#define DEFAULT_UART_BUS_RX (&pin_GPIO1) diff --git a/ports/raspberrypi/boards/adafruit_kb2040/mpconfigboard.mk b/ports/raspberrypi/boards/adafruit_kb2040/mpconfigboard.mk new file mode 100644 index 0000000000..f9e1e2cf15 --- /dev/null +++ b/ports/raspberrypi/boards/adafruit_kb2040/mpconfigboard.mk @@ -0,0 +1,9 @@ +USB_VID = 0x239A +USB_PID = 0x8106 +USB_PRODUCT = "KB2040" +USB_MANUFACTURER = "Adafruit" + +CHIP_VARIANT = RP2040 +CHIP_FAMILY = rp2 + +EXTERNAL_FLASH_DEVICES = "W25Q64JVxQ" diff --git a/ports/raspberrypi/boards/adafruit_kb2040/pico-sdk-configboard.h b/ports/raspberrypi/boards/adafruit_kb2040/pico-sdk-configboard.h new file mode 100644 index 0000000000..a41131dd22 --- /dev/null +++ b/ports/raspberrypi/boards/adafruit_kb2040/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/adafruit_kb2040/pins.c b/ports/raspberrypi/boards/adafruit_kb2040/pins.c new file mode 100644 index 0000000000..0bd2dda728 --- /dev/null +++ b/ports/raspberrypi/boards/adafruit_kb2040/pins.c @@ -0,0 +1,45 @@ +#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_A1), MP_ROM_PTR(&pin_GPIO27) }, + { 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_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) }, + + { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO1) }, + + { MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_D3), 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_D8), 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) }, + { MP_ROM_QSTR(MP_QSTR_BUTTON), MP_ROM_PTR(&pin_GPIO11) }, + + { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_GPIO12) }, + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO12) }, + + { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_GPIO13) }, + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO13) }, + + { 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_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/adafruit_qt2040_trinkey/mpconfigboard.mk b/ports/raspberrypi/boards/adafruit_qt2040_trinkey/mpconfigboard.mk index da4706a177..5f07632b4f 100644 --- a/ports/raspberrypi/boards/adafruit_qt2040_trinkey/mpconfigboard.mk +++ b/ports/raspberrypi/boards/adafruit_qt2040_trinkey/mpconfigboard.mk @@ -1,5 +1,5 @@ USB_VID = 0x239A -USB_PID = 0x8106 +USB_PID = 0x810A USB_PRODUCT = "QT2040 Trinkey" USB_MANUFACTURER = "Adafruit" diff --git a/ports/raspberrypi/boards/cytron_maker_pi_rp2040/pins.c b/ports/raspberrypi/boards/cytron_maker_pi_rp2040/pins.c index 8aedbc928d..d4d776f04f 100644 --- a/ports/raspberrypi/boards/cytron_maker_pi_rp2040/pins.c +++ b/ports/raspberrypi/boards/cytron_maker_pi_rp2040/pins.c @@ -3,7 +3,9 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO0) }, { 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) }, @@ -42,9 +44,6 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_BUZZER), MP_ROM_PTR(&pin_GPIO22) }, { MP_ROM_QSTR(MP_QSTR_GP22), MP_ROM_PTR(&pin_GPIO22) }, - { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO25) }, - { 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) }, diff --git a/ports/raspberrypi/boards/jpconstantineau_pykey60/mpconfigboard.h b/ports/raspberrypi/boards/jpconstantineau_pykey60/mpconfigboard.h index f4ccde3fca..f96edba2f8 100644 --- a/ports/raspberrypi/boards/jpconstantineau_pykey60/mpconfigboard.h +++ b/ports/raspberrypi/boards/jpconstantineau_pykey60/mpconfigboard.h @@ -1,2 +1,4 @@ #define MICROPY_HW_BOARD_NAME "PyKey60" #define MICROPY_HW_MCU_NAME "rp2040" + +#define MICROPY_HW_NEOPIXEL (&pin_GPIO29) diff --git a/ports/raspberrypi/boards/jpconstantineau_pykey60/pico-sdk-configboard.h b/ports/raspberrypi/boards/jpconstantineau_pykey60/pico-sdk-configboard.h index 36da55d457..a41131dd22 100644 --- a/ports/raspberrypi/boards/jpconstantineau_pykey60/pico-sdk-configboard.h +++ b/ports/raspberrypi/boards/jpconstantineau_pykey60/pico-sdk-configboard.h @@ -1 +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/melopero_shake_rp2040/pins.c b/ports/raspberrypi/boards/melopero_shake_rp2040/pins.c index 8d5be961e0..76ab220216 100644 --- a/ports/raspberrypi/boards/melopero_shake_rp2040/pins.c +++ b/ports/raspberrypi/boards/melopero_shake_rp2040/pins.c @@ -25,6 +25,10 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_D11), 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_D17), MP_ROM_PTR(&pin_GPIO17) }, + + { MP_ROM_QSTR(MP_QSTR_BATTERY), MP_ROM_PTR(&pin_GPIO17) }, + { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO13) }, { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO16) }, diff --git a/ports/raspberrypi/boards/pimoroni_picosystem/board.c b/ports/raspberrypi/boards/pimoroni_picosystem/board.c index de6e424ed9..9f5f6ae6f5 100644 --- a/ports/raspberrypi/boards/pimoroni_picosystem/board.c +++ b/ports/raspberrypi/boards/pimoroni_picosystem/board.c @@ -25,8 +25,93 @@ */ #include "supervisor/board.h" +#include "mpconfigboard.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" +#include "supervisor/shared/board.h" + +displayio_fourwire_obj_t board_display_obj; + +#define DELAY 0x80 + +uint8_t display_init_sequence[] = { + 0x01, 0 | DELAY, 150, // SWRESET + + 0x36, 1, 0x04, // MADCTL + 0x35, 1, 0x00, // TEON + 0xB2, 5, 0x0c, 0x0c, 0x00, 0x33, 0x33, // FRMCTR2 + 0x3A, 1, 0x05, // COLMOD + 0xB7, 1, 0x14, // GCTRL + 0xBB, 1, 0x37, // VCOMS + 0xC0, 1, 0x2c, // LCMCTRL + 0xC2, 1, 0x01, // VDVVRHEN + 0xC3, 1, 0x12, // VRHS + 0xC4, 1, 0x20, // VDVS + 0xD0, 2, 0xa4, 0xa1, // PWRCTRL1 + 0xC6, 1, 0x0f, // FRCTRL2 + 0xE0, 14, 0xd0, 0x04, 0x0d, 0x11, 0x13, 0x2b, 0x3f, 0x54, 0x4c, 0x18, 0x0d, 0x0b, 0x1f, 0x23, // GMCTRP1 + 0xE1, 14, 0xd0, 0x04, 0x0c, 0x11, 0x13, 0x2c, 0x3f, 0x44, 0x51, 0x2f, 0x1f, 0x1f, 0x20, 0x23, // GMCTRN1 + 0x21, 0, // INVON + + 0x11, 0 | DELAY, 255, // SLPOUT + 0x29, 0 | DELAY, 100, // DISPON + + 0x2a, 4, 0x00, 0, 0x00, 0xfe, // CASET + 0x2b, 4, 0x00, 0, 0x00, 0xfe, // RASET + 0x2c, 0, // RAMWR +}; 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_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_GPIO9, // TFT_DC Command or data + &pin_GPIO5, // TFT_CS Chip select + &pin_GPIO4, // 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, + 240, // 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_bytes_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_GPIO12, // 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 +} + +void board_deinit(void) { } bool board_requests_safe_mode(void) { @@ -35,6 +120,3 @@ bool board_requests_safe_mode(void) { void reset_board(void) { } - -void board_deinit(void) { -} diff --git a/ports/raspberrypi/boards/pimoroni_picosystem/mpconfigboard.mk b/ports/raspberrypi/boards/pimoroni_picosystem/mpconfigboard.mk index f00fb64cc9..8dca786a5e 100644 --- a/ports/raspberrypi/boards/pimoroni_picosystem/mpconfigboard.mk +++ b/ports/raspberrypi/boards/pimoroni_picosystem/mpconfigboard.mk @@ -9,3 +9,10 @@ CHIP_FAMILY = rp2 EXTERNAL_FLASH_DEVICES = "W25Q128JVxQ" CIRCUITPY__EVE = 1 + +CIRCUITPY_KEYPAD = 1 +CIRCUITPY_STAGE = 1 + +CIRCUITPY_AUDIOIO = 1 + +FROZEN_MPY_DIRS += $(TOP)/frozen/circuitpython-stage/picosystem diff --git a/ports/raspberrypi/boards/pimoroni_picosystem/pins.c b/ports/raspberrypi/boards/pimoroni_picosystem/pins.c index bfd51225fb..5aa96d6237 100644 --- a/ports/raspberrypi/boards/pimoroni_picosystem/pins.c +++ b/ports/raspberrypi/boards/pimoroni_picosystem/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 @@ -41,5 +42,8 @@ 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_UART), MP_ROM_PTR(&board_uart_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/raspberrypi/boards/solderparty_rp2040_stamp/board.c b/ports/raspberrypi/boards/solderparty_rp2040_stamp/board.c new file mode 100644 index 0000000000..de6e424ed9 --- /dev/null +++ b/ports/raspberrypi/boards/solderparty_rp2040_stamp/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/solderparty_rp2040_stamp/mpconfigboard.h b/ports/raspberrypi/boards/solderparty_rp2040_stamp/mpconfigboard.h new file mode 100644 index 0000000000..7229e398a2 --- /dev/null +++ b/ports/raspberrypi/boards/solderparty_rp2040_stamp/mpconfigboard.h @@ -0,0 +1,2 @@ +#define MICROPY_HW_BOARD_NAME "RP2040 Stamp" +#define MICROPY_HW_MCU_NAME "rp2040" diff --git a/ports/raspberrypi/boards/solderparty_rp2040_stamp/mpconfigboard.mk b/ports/raspberrypi/boards/solderparty_rp2040_stamp/mpconfigboard.mk new file mode 100644 index 0000000000..e2b4118761 --- /dev/null +++ b/ports/raspberrypi/boards/solderparty_rp2040_stamp/mpconfigboard.mk @@ -0,0 +1,17 @@ +USB_VID = 0x1209 +USB_PID = 0xA182 +USB_PRODUCT = "RP2040 Stamp" +USB_MANUFACTURER = "Solder Party" + +CHIP_VARIANT = RP2040 +CHIP_FAMILY = rp2 + +EXTERNAL_FLASH_DEVICES = "GD25Q64C" + +CIRCUITPY__EVE = 1 + +FROZEN_MPY_DIRS += $(TOP)/ports/raspberrypi/boards/solderparty_rp2040_stamp +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_BusDevice +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_HID +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Register diff --git a/ports/raspberrypi/boards/solderparty_rp2040_stamp/pico-sdk-configboard.h b/ports/raspberrypi/boards/solderparty_rp2040_stamp/pico-sdk-configboard.h new file mode 100644 index 0000000000..36da55d457 --- /dev/null +++ b/ports/raspberrypi/boards/solderparty_rp2040_stamp/pico-sdk-configboard.h @@ -0,0 +1 @@ +// Put board-specific pico-sdk definitions here. This file must exist. diff --git a/ports/raspberrypi/boards/solderparty_rp2040_stamp/pins.c b/ports/raspberrypi/boards/solderparty_rp2040_stamp/pins.c new file mode 100644 index 0000000000..98f88a6831 --- /dev/null +++ b/ports/raspberrypi/boards/solderparty_rp2040_stamp/pins.c @@ -0,0 +1,52 @@ +#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_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_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_NEOPIXEL), 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_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/raspberrypi/boards/solderparty_rp2040_stamp/stamp_carrier_board.py b/ports/raspberrypi/boards/solderparty_rp2040_stamp/stamp_carrier_board.py new file mode 100644 index 0000000000..a001e5be8f --- /dev/null +++ b/ports/raspberrypi/boards/solderparty_rp2040_stamp/stamp_carrier_board.py @@ -0,0 +1,49 @@ +from board import * +import busio + + +_SPI = None +_UART = None +_I2C = None + + +SCL = GP5 +SDA = GP4 +SCK = GP18 +CIPO = GP16 +MISO = GP16 +COPI = GP19 +MOSI = GP19 +CS = GP17 +TX = GP0 +RX = GP1 +LED = GP20 +VOLTAGE_MONITOR = A0 +BATTERY = A0 + + +def SPI(): + global _SPI + + if not _SPI: + _SPI = busio.SPI(SCK, COPI, CIPO) + + return _SPI + + +def UART(): + global _UART + + if not _UART: + _UART = busio.UART(TX, RX) + + return _UART + + +def I2C(): + global _I2C + + if not _I2C: + _I2C = busio.I2C(SCL, SDA) + + return _I2C diff --git a/ports/raspberrypi/common-hal/alarm/__init__.c b/ports/raspberrypi/common-hal/alarm/__init__.c index 7f22242e9f..0d6734568b 100644 --- a/ports/raspberrypi/common-hal/alarm/__init__.c +++ b/ports/raspberrypi/common-hal/alarm/__init__.c @@ -28,7 +28,7 @@ #include "py/obj.h" #include "py/objtuple.h" #include "py/runtime.h" -#include "lib/utils/interrupt_char.h" +#include "shared/runtime/interrupt_char.h" #include "shared-bindings/alarm/__init__.h" #include "shared-bindings/alarm/SleepMemory.h" diff --git a/ports/raspberrypi/common-hal/alarm/time/TimeAlarm.c b/ports/raspberrypi/common-hal/alarm/time/TimeAlarm.c index 4302e9e8cd..65c2b680d8 100644 --- a/ports/raspberrypi/common-hal/alarm/time/TimeAlarm.c +++ b/ports/raspberrypi/common-hal/alarm/time/TimeAlarm.c @@ -29,7 +29,7 @@ #include "shared-bindings/alarm/time/TimeAlarm.h" #include "shared-bindings/time/__init__.h" -#include "lib/timeutils/timeutils.h" +#include "shared/timeutils/timeutils.h" #include "hardware/gpio.h" #include "hardware/rtc.h" diff --git a/ports/raspberrypi/common-hal/busio/SPI.c b/ports/raspberrypi/common-hal/busio/SPI.c index ab295c4ff1..766807f5a9 100644 --- a/ports/raspberrypi/common-hal/busio/SPI.c +++ b/ports/raspberrypi/common-hal/busio/SPI.c @@ -26,7 +26,7 @@ #include "shared-bindings/busio/SPI.h" -#include "lib/utils/interrupt_char.h" +#include "shared/runtime/interrupt_char.h" #include "py/mperrno.h" #include "py/runtime.h" diff --git a/ports/raspberrypi/common-hal/busio/UART.c b/ports/raspberrypi/common-hal/busio/UART.c index e7ba64b098..14935f4046 100644 --- a/ports/raspberrypi/common-hal/busio/UART.c +++ b/ports/raspberrypi/common-hal/busio/UART.c @@ -30,7 +30,7 @@ #include "py/mperrno.h" #include "py/runtime.h" #include "supervisor/shared/tick.h" -#include "lib/utils/interrupt_char.h" +#include "shared/runtime/interrupt_char.h" #include "common-hal/microcontroller/Pin.h" #include "src/rp2_common/hardware_irq/include/hardware/irq.h" diff --git a/ports/raspberrypi/common-hal/imagecapture/ParallelImageCapture.c b/ports/raspberrypi/common-hal/imagecapture/ParallelImageCapture.c index 1d0355d1c0..280c87e234 100644 --- a/ports/raspberrypi/common-hal/imagecapture/ParallelImageCapture.c +++ b/ports/raspberrypi/common-hal/imagecapture/ParallelImageCapture.c @@ -27,8 +27,8 @@ #include "py/obj.h" #include "py/runtime.h" -#include "lib/utils/context_manager_helpers.h" -#include "lib/utils/interrupt_char.h" +#include "shared/runtime/context_manager_helpers.h" +#include "shared/runtime/interrupt_char.h" #include "bindings/rp2pio/StateMachine.h" #include "bindings/rp2pio/__init__.h" @@ -137,7 +137,10 @@ bool common_hal_imagecapture_parallelimagecapture_deinited(imagecapture_parallel return common_hal_rp2pio_statemachine_deinited(&self->state_machine); } -void common_hal_imagecapture_parallelimagecapture_capture(imagecapture_parallelimagecapture_obj_t *self, void *buffer, size_t bufsize) { +void common_hal_imagecapture_parallelimagecapture_singleshot_capture(imagecapture_parallelimagecapture_obj_t *self, mp_obj_t buffer) { + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(buffer, &bufinfo, MP_BUFFER_RW); + PIO pio = self->state_machine.pio; uint sm = self->state_machine.state_machine; uint8_t offset = rp2pio_statemachine_program_offset(&self->state_machine); @@ -149,7 +152,7 @@ void common_hal_imagecapture_parallelimagecapture_capture(imagecapture_paralleli pio_sm_exec(pio, sm, pio_encode_jmp(offset)); pio_sm_set_enabled(pio, sm, true); - common_hal_rp2pio_statemachine_readinto(&self->state_machine, buffer, bufsize, 4); + common_hal_rp2pio_statemachine_readinto(&self->state_machine, bufinfo.buf, bufinfo.len, 4); pio_sm_set_enabled(pio, sm, false); } diff --git a/ports/raspberrypi/common-hal/os/__init__.c b/ports/raspberrypi/common-hal/os/__init__.c index 3352cef122..25fe317abe 100644 --- a/ports/raspberrypi/common-hal/os/__init__.c +++ b/ports/raspberrypi/common-hal/os/__init__.c @@ -30,7 +30,7 @@ #include "py/objtuple.h" #include "py/qstr.h" -#include "extmod/crypto-algorithms/sha256.h" +#include "lib/crypto-algorithms/sha256.h" #include "hardware/structs/rosc.h" diff --git a/ports/raspberrypi/common-hal/pulseio/PulseIn.c b/ports/raspberrypi/common-hal/pulseio/PulseIn.c index 4e9b56a1a1..53dfa008b8 100644 --- a/ports/raspberrypi/common-hal/pulseio/PulseIn.c +++ b/ports/raspberrypi/common-hal/pulseio/PulseIn.c @@ -165,6 +165,8 @@ void common_hal_pulseio_pulsein_interrupt(pulseio_pulsein_obj_t *self) { pio_sm_init(self->state_machine.pio, self->state_machine.state_machine, self->state_machine.offset, &self->state_machine.sm_config); pio_sm_restart(self->state_machine.pio,self->state_machine.state_machine); pio_sm_set_enabled(self->state_machine.pio, self->state_machine.state_machine, true); + self->buf_index = 0; + self->start = 0; } } void common_hal_pulseio_pulsein_resume(pulseio_pulsein_obj_t *self, diff --git a/ports/raspberrypi/common-hal/pwmio/PWMOut.c b/ports/raspberrypi/common-hal/pwmio/PWMOut.c index 25590a1332..27e9bd4d03 100644 --- a/ports/raspberrypi/common-hal/pwmio/PWMOut.c +++ b/ports/raspberrypi/common-hal/pwmio/PWMOut.c @@ -26,7 +26,7 @@ #include -#include "lib/utils/interrupt_char.h" +#include "shared/runtime/interrupt_char.h" #include "py/runtime.h" #include "common-hal/pwmio/PWMOut.h" #include "shared-bindings/pwmio/PWMOut.h" diff --git a/ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c b/ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c index 7849130ff7..649c9421e0 100644 --- a/ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c +++ b/ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c @@ -68,12 +68,12 @@ void common_hal_rotaryio_incrementalencoder_construct(rotaryio_incrementalencode pins[1] = MP_OBJ_FROM_PTR(pin_a); self->swapped = false; if (!common_hal_rp2pio_pins_are_sequential(2, pins)) { - mp_raise_RuntimeError(translate("Pins must be sequential")); + mp_raise_RuntimeError(translate("Pins must be sequential GPIO pins")); } } self->position = 0; - self->quarter_count = 0; + self->sub_count = 0; common_hal_rp2pio_statemachine_construct(&self->state_machine, encoder, MP_ARRAY_SIZE(encoder), diff --git a/ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.h b/ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.h index 6745d95a1c..812ba09821 100644 --- a/ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.h +++ b/ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.h @@ -35,7 +35,8 @@ typedef struct { mp_obj_base_t base; rp2pio_statemachine_obj_t state_machine; uint8_t state; // - int8_t quarter_count; // count intermediate transitions between detents + int8_t sub_count; // count intermediate transitions between detents + int8_t divisor; // Number of quadrature edges required per count bool swapped; // Did the pins need to be swapped to be sequential? mp_int_t position; } rotaryio_incrementalencoder_obj_t; diff --git a/ports/raspberrypi/common-hal/rp2pio/StateMachine.c b/ports/raspberrypi/common-hal/rp2pio/StateMachine.c index c35adc21e2..27672f0de0 100644 --- a/ports/raspberrypi/common-hal/rp2pio/StateMachine.c +++ b/ports/raspberrypi/common-hal/rp2pio/StateMachine.c @@ -37,7 +37,7 @@ #include "src/rp2040/hardware_structs/include/hardware/structs/iobank0.h" #include "src/rp2_common/hardware_irq/include/hardware/irq.h" -#include "lib/utils/interrupt_char.h" +#include "shared/runtime/interrupt_char.h" #include "py/obj.h" #include "py/objproperty.h" #include "py/runtime.h" diff --git a/ports/raspberrypi/fatfs_port.c b/ports/raspberrypi/fatfs_port.c index e6eee20495..58a0ef0d72 100644 --- a/ports/raspberrypi/fatfs_port.c +++ b/ports/raspberrypi/fatfs_port.c @@ -28,7 +28,7 @@ #include "py/runtime.h" #include "lib/oofatfs/ff.h" /* FatFs lower layer API */ #include "lib/oofatfs/diskio.h" /* FatFs lower layer API */ -#include "lib/timeutils/timeutils.h" +#include "shared/timeutils/timeutils.h" #if CIRCUITPY_RTC #include "shared-bindings/rtc/RTC.h" diff --git a/ports/raspberrypi/mphalport.c b/ports/raspberrypi/mphalport.c index 89b597bc74..51d82a0514 100644 --- a/ports/raspberrypi/mphalport.c +++ b/ports/raspberrypi/mphalport.c @@ -26,8 +26,8 @@ #include -#include "lib/mp-readline/readline.h" -#include "lib/utils/interrupt_char.h" +#include "shared/readline/readline.h" +#include "shared/runtime/interrupt_char.h" #include "py/mphal.h" #include "py/mpstate.h" #include "py/runtime.h" diff --git a/ports/stm/Makefile b/ports/stm/Makefile index 1de7ed5c82..b5423b62c0 100755 --- a/ports/stm/Makefile +++ b/ports/stm/Makefile @@ -111,6 +111,7 @@ CFLAGS += -Wno-undef -Wno-shadow -Wno-cast-align $(ADD_CFLAGS) CFLAGS += -mthumb -mabi=aapcs-linux # Arm core selection +MCU_FLAGS_L4 = -mcpu=cortex-m4 MCU_FLAGS_F4 = -mcpu=cortex-m4 MCU_FLAGS_F7 = -mcpu=cortex-m7 MCU_FLAGS_H7 = -mcpu=cortex-m7 @@ -161,6 +162,13 @@ CFLAGS += \ -DCFG_TUD_MIDI_RX_BUFSIZE=128 \ -DCFG_TUD_MIDI_TX_BUFSIZE=128 +ifdef CIRCUITPY_USB_VENDOR +CFLAGS += \ + -DCFG_TUD_VENDOR_RX_BUFSIZE=1024 \ + -DCFG_TUD_VENDOR_TX_BUFSIZE=1024 +endif + + SRC_STM32 = $(addprefix $(HAL_DIR)/Src/stm32$(MCU_SERIES_LOWER)xx_,\ hal.c \ hal_adc.c \ @@ -207,7 +215,7 @@ endif # Need this to avoid UART linker problems. TODO: rewrite to use registered callbacks. # Does not exist for F4 and lower -ifeq ($(MCU_VARIANT),$(filter $(MCU_VARIANT),STM32F765xx STM32F767xx STM32F769xx STM32H743xx)) +ifeq ($(MCU_VARIANT),$(filter $(MCU_VARIANT),STM32F765xx STM32F767xx STM32F769xx STM32H743xx STM32L4R5xx)) SRC_STM32 += $(HAL_DIR)/Src/stm32$(MCU_SERIES_LOWER)xx_hal_uart_ex.c endif @@ -282,7 +290,7 @@ $(BUILD)/firmware.elf: $(OBJ) $(STEPECHO) "LINK $@" $(Q)echo $^ > $(BUILD)/firmware.objs $(Q)$(CC) -o $@ $(LDFLAGS) @$(BUILD)/firmware.objs -Wl,--start-group $(LIBS) -Wl,--end-group - $(Q)$(SIZE) $@ | $(PYTHON3) $(TOP)/tools/build_memory_info.py $(LD_FILE) + $(Q)$(SIZE) $@ | $(PYTHON) $(TOP)/tools/build_memory_info.py $(LD_FILE) $(BUILD)/firmware.bin: $(BUILD)/firmware.elf $(STEPECHO) "Create $@" @@ -294,7 +302,7 @@ $(BUILD)/firmware.hex: $(BUILD)/firmware.elf $(BUILD)/firmware.uf2: $(BUILD)/firmware.hex $(ECHO) "Create $@" - $(PYTHON3) $(TOP)/tools/uf2/utils/uf2conv.py -f 0x57755a57 -b $(BOOTLOADER_OFFSET) -c -o "$(BUILD)/firmware.uf2" $^ + $(PYTHON) $(TOP)/tools/uf2/utils/uf2conv.py -f 0x57755a57 -b $(BOOTLOADER_OFFSET) -c -o "$(BUILD)/firmware.uf2" $^ flash: $(BUILD)/firmware.bin $(ECHO) "Writing $< to the board" diff --git a/ports/stm/boards/STM32L4R5_boot.ld b/ports/stm/boards/STM32L4R5_boot.ld new file mode 100644 index 0000000000..16204205e6 --- /dev/null +++ b/ports/stm/boards/STM32L4R5_boot.ld @@ -0,0 +1,26 @@ +/* + GNU linker script for STM32L4R5 with bootloader +*/ + +/* Specify the memory areas */ +MEMORY +{ + FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 2048K /* entire flash */ + FLASH_ISR (rx) : ORIGIN = 0x08010000, LENGTH = 4K /* ISR vector. Kind of wasteful. */ + FLASH_FIRMWARE (rx) : ORIGIN = 0x08011000, LENGTH = 1024K-128K-64K-4K /* For now, limit to 1MB so that bank switching is still possible. */ + FLASH_FS (rw) : ORIGIN = 0x080e0000, LENGTH = 128K + RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 640K +} + +/* produce a link error if there is not this amount of RAM for these sections */ +_minimum_stack_size = 24K; +_minimum_heap_size = 16K; + +/* Define the top end of the stack. The stack is full descending so begins just + above last byte of RAM. Note that EABI requires the stack to be 8-byte + aligned for a call. */ +_estack = ORIGIN(RAM) + LENGTH(RAM); + +/* RAM extents for the garbage collector */ +_ram_start = ORIGIN(RAM); +_ram_end = ORIGIN(RAM) + LENGTH(RAM); diff --git a/ports/stm/boards/STM32L4R5_default.ld b/ports/stm/boards/STM32L4R5_default.ld new file mode 100644 index 0000000000..1f6e04f6be --- /dev/null +++ b/ports/stm/boards/STM32L4R5_default.ld @@ -0,0 +1,29 @@ +/* + GNU linker script for STM32L4R5 with filesystem +*/ + +/* Specify the memory areas */ +MEMORY +{ + FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 2048K /* entire flash */ + FLASH_ISR (rx) : ORIGIN = 0x08000000, LENGTH = 4K /* ISR vector. Kind of wasteful. */ + FLASH_FIRMWARE (rx) : ORIGIN = 0x08001000, LENGTH = 1024K-128K-4K /* For now, limit to 1MB so that bank switching is still possible. */ + FLASH_FS (rw) : ORIGIN = 0x080e0000, LENGTH = 128K + RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 640K +} + +/* produce a link error if there is not this amount of RAM for these sections */ +_minimum_stack_size = 24K; +_minimum_heap_size = 16K; + +/* Define tho top end of the stack. The stack is full descending so begins just + above last byte of RAM. Note that EABI requires the stack to be 8-byte + aligned for a call. */ +_estack = ORIGIN(RAM) + LENGTH(RAM); + +/* RAM extents for the garbage collector */ +_ram_start = ORIGIN(RAM); +_ram_end = ORIGIN(RAM) + LENGTH(RAM); + +/* ensure the firmware is within bounds */ +ASSERT ( (ORIGIN(FLASH_FIRMWARE) + LENGTH(FLASH_FIRMWARE)) <= (ORIGIN(FLASH)+LENGTH(FLASH)), "FLASH_FIRMWARE out of bounds" ); diff --git a/ports/stm/boards/espruino_pico/mpconfigboard.mk b/ports/stm/boards/espruino_pico/mpconfigboard.mk index 851357b4d6..a078b4841a 100644 --- a/ports/stm/boards/espruino_pico/mpconfigboard.mk +++ b/ports/stm/boards/espruino_pico/mpconfigboard.mk @@ -23,6 +23,7 @@ CIRCUITPY_AUDIOPWMIO = 0 CIRCUITPY_BUSDEVICE = 0 CIRCUITPY_BITMAPTOOLS = 0 CIRCUITPY_FRAMEBUFFERIO = 0 +CIRCUITPY_GIFIO = 0 CIRCUITPY_KEYPAD = 0 CIRCUITPY_MIDI = 0 CIRCUITPY_MSGPACK = 0 diff --git a/ports/stm/boards/meowbit_v121/mpconfigboard.mk b/ports/stm/boards/meowbit_v121/mpconfigboard.mk index ed96e99871..589f0bce10 100644 --- a/ports/stm/boards/meowbit_v121/mpconfigboard.mk +++ b/ports/stm/boards/meowbit_v121/mpconfigboard.mk @@ -22,6 +22,7 @@ LD_FILE = boards/STM32F401xe_boot.ld CIRCUITPY_AESIO = 0 CIRCUITPY_BLEIO_HCI = 0 +CIRCUITPY_GIFIO = 0 CIRCUITPY_ULAB = 0 CIRCUITPY_STAGE = 1 diff --git a/ports/stm/boards/pyb_nano_v2/mpconfigboard.mk b/ports/stm/boards/pyb_nano_v2/mpconfigboard.mk index 9f6a02c8d0..74ce665a5b 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_KEYPAD = 0 +CIRCUITPY_GIFIO = 0 CIRCUITPY_MIDI = 0 CIRCUITPY_MSGPACK = 0 CIRCUITPY_BITMAPTOOLS = 0 diff --git a/ports/stm/boards/swan_r5/board.c b/ports/stm/boards/swan_r5/board.c new file mode 100644 index 0000000000..7c0e3c44cd --- /dev/null +++ b/ports/stm/boards/swan_r5/board.c @@ -0,0 +1,64 @@ +/* + * 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" + +#include "stm32l4xx.h" +#include "stm32l4r5xx.h" + +void initialize_discharge_pin(void) { + /* Initialize the 3V3 discharge to be OFF and the output power to be ON */ + __HAL_RCC_GPIOE_CLK_ENABLE(); + GPIO_InitTypeDef GPIO_InitStruct; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_LOW; + GPIO_InitStruct.Pin = GPIO_PIN_6; + HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); + HAL_GPIO_WritePin(GPIOE, GPIO_PIN_6, GPIO_PIN_SET); + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStruct.Pin = GPIO_PIN_4; + HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); + HAL_GPIO_WritePin(GPIOE, GPIO_PIN_4, GPIO_PIN_SET); +} + +void board_init(void) { + // enable the debugger while sleeping. Todo move somewhere more central (kind of generally useful in a debug build) + SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_SLEEP); + + // Set tick interrupt priority, default HAL value is intentionally invalid + // Without this, USB does not function. + HAL_InitTick((1UL << __NVIC_PRIO_BITS) - 1UL); +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { + initialize_discharge_pin(); +} diff --git a/ports/stm/boards/swan_r5/mpconfigboard.h b/ports/stm/boards/swan_r5/mpconfigboard.h new file mode 100644 index 0000000000..da07d6530b --- /dev/null +++ b/ports/stm/boards/swan_r5/mpconfigboard.h @@ -0,0 +1,66 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Blues Wireless Contributors. + * + * 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 "Swan R5" +#define MICROPY_HW_MCU_NAME "STM32L4R5ZIY6" + +// todo - not sure why this isn't the default for this port +#define MICROPY_PY_SYS_PLATFORM MICROPY_HW_BOARD_NAME + + +#define STM32L4R5XX +#define BOARD_SWAN_R5 + + +// The flash size is defined in the STM32L4xx HAL (but not for the F4) +// #define FLASH_SIZE (0x200000) +// #define FLASH_PAGE_SIZE (0x1000) + +#define LSE_VALUE ((uint32_t)32768) +#define BOARD_HAS_LOW_SPEED_CRYSTAL (1) +#define BOARD_HAS_HIGH_SPEED_CRYSTAL (0) + + +// Bootloader only +#ifdef UF2_BOOTLOADER_ENABLED + #define BOARD_VTOR_DEFER (1) // Leave VTOR relocation to bootloader +#endif + +#define BOARD_NO_VBUS_SENSE (1) +#define BOARD_NO_USB_OTG_ID_SENSE (1) + +#define DEFAULT_I2C_BUS_SCL (&pin_PB06) +#define DEFAULT_I2C_BUS_SDA (&pin_PB07) + +#define DEFAULT_SPI_BUS_SS (&pin_PD00) +#define DEFAULT_SPI_BUS_SCK (&pin_PD01) +#define DEFAULT_SPI_BUS_MOSI (&pin_PB15) +#define DEFAULT_SPI_BUS_MISO (&pin_PB14) + +#define DEFAULT_UART_BUS_RX (&pin_PA10) +#define DEFAULT_UART_BUS_TX (&pin_PA09) diff --git a/ports/stm/boards/swan_r5/mpconfigboard.mk b/ports/stm/boards/swan_r5/mpconfigboard.mk new file mode 100644 index 0000000000..24b73e332d --- /dev/null +++ b/ports/stm/boards/swan_r5/mpconfigboard.mk @@ -0,0 +1,73 @@ +USB_VID = 0x30A4 +USB_PID = 0x02 +USB_PRODUCT = "Swan R5" +USB_MANUFACTURER = "Blues Inc." + +INTERNAL_FLASH_FILESYSTEM = 1 + +MCU_SERIES = L4 +MCU_VARIANT = STM32L4R5xx +MCU_PACKAGE = WLCSP144 + +LD_COMMON = boards/common_default.ld +LD_DEFAULT = boards/STM32L4R5_default.ld +# UF2 boot option +LD_BOOT = boards/STM32L4R5_boot.ld +UF2_OFFSET = 0x8010000 + +# Turn all of the below off while trying to get the thing to run +# These modules are implemented in ports//common-hal: + +# Typically the first module to create +CIRCUITPY_MICROCONTROLLER = 1 +CIRCUITPY_ALARM = 1 + +# Typically the second module to create +CIRCUITPY_DIGITALIO = 1 +# Other modules: + +CIRCUITPY_OS = 1 +CIRCUITPY_STORAGE = 1 +CIRCUITPY_USB_MSC = 1 +CIRCUITPY_UDB_CDC = 1 +CIRCUITPY_USB_VENDOR = 1 +CIRCUITPY_NVM = 0 + +CIRCUITPY_ANALOGIO = 1 +CIRCUITPY_BUSIO = 1 +CIRCUITPY_NEOPIXEL_WRITE = 0 +CIRCUITPY_PULSEIO = 1 +CIRCUITPY_PWMIO = 1 +CIRCUITPY_AUDIOPWMIO = 1 +CIRCUITPY_CANIO = 0 +CIRCUITPY_AUDIOBUSIO = 0 +CIRCUITPY_I2CPERIPHERAL = 0 +# Requires SPI, PulseIO (stub ok): +CIRCUITPY_DISPLAYIO = 0 + +# 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_GAMEPADSHIFT = 1 +# Requires neopixel_write or SPI (dotstar) +CIRCUITPY_PIXELBUF = 0 +# Requires OS +CIRCUITPY_RANDOM = 1 +# Requires Microcontroller +CIRCUITPY_TOUCHIO = 1 +# Requires USB +CIRCUITPY_USB_HID = 0 +CIRCUITPY_USB_MIDI = 0 +# Does nothing without I2C +CIRCUITPY_REQUIRE_I2C_PULLUPS = 0 +# No requirements, but takes extra flash +CIRCUITPY_ULAB = 1 +# requires SPI +CIRCUITPY_SDCARDIO = 0 +CIRCUITPY_BLEIO_HCI = 0 +CIRCUITPY_BLEIO = 0 +CIRCUITPY_BUSDEVICE = 0 +CIRCUITPY_KEYPAD = 1 +CIRCUITPY_RGBMATRIX = 0 diff --git a/ports/stm/boards/swan_r5/pins.c b/ports/stm/boards/swan_r5/pins.c new file mode 100644 index 0000000000..2f37e3b055 --- /dev/null +++ b/ports/stm/boards/swan_r5/pins.c @@ -0,0 +1,50 @@ +#include "py/objtuple.h" +#include "shared-bindings/board/__init__.h" + +// Core Feather Pins +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR_ENABLE_3V3), MP_ROM_PTR(&pin_PE04) }, + { MP_ROM_QSTR(MP_QSTR_DISCHARGE_3V3), MP_ROM_PTR(&pin_PE06) }, + { MP_ROM_QSTR(MP_QSTR_DISABLE_DISCHARGING), MP_ROM_TRUE }, + { MP_ROM_QSTR(MP_QSTR_ENABLE_DISCHARGING), MP_ROM_FALSE }, + + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA03) }, + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PA01) }, + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PC03) }, + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PC01) }, + { 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_VOLTAGE_MONITOR), MP_ROM_PTR(&pin_PA00) }, + { MP_ROM_QSTR(MP_QSTR_BUTTON_USR), MP_ROM_PTR(&pin_PC13) }, + { MP_ROM_QSTR(MP_QSTR_SWITCH), MP_ROM_PTR(&pin_PE04) }, + { MP_ROM_QSTR(MP_QSTR_BUTTON), MP_ROM_PTR(&pin_PB02) }, // boot button, but looks like it's wired to GND on the schematic + + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_PE11) }, + { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PE09) }, + { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_PD15) }, + { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PA04) }, // DAC1 output also + { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_PA07) }, + { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_PA06) }, + + { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_PE02) }, + { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_PA05) }, // DAC1 output also + + { 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_DAC1), MP_ROM_PTR(&pin_PA04) }, // D10 + { MP_ROM_QSTR(MP_QSTR_DAC2), MP_ROM_PTR(&pin_PA05) }, // D13 + + { MP_ROM_QSTR(MP_QSTR_SS), MP_ROM_PTR(&pin_PD00) }, + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PD01) }, + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PB14) }, + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PB15) }, + + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PA09) }, + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PA10) }, + + { 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/stm/boards/swan_r5/tests/analog_output.py b/ports/stm/boards/swan_r5/tests/analog_output.py new file mode 100644 index 0000000000..6af931e65d --- /dev/null +++ b/ports/stm/boards/swan_r5/tests/analog_output.py @@ -0,0 +1,85 @@ +import board +import analogio +import digitalio + + +def test_dac_analog(p_in, p_out): + print(f"Running dac analog test with pin {p_in} as input and {p_out} as output\n") + pin_in = analogio.AnalogIn(p_in) + pin_out = analogio.AnalogOut(p_out) + + for v in range(0, 65536, 4096): + pin_out.value = v + print(f"Value {v} read as {pin_in.value}") + + pin_in.deinit() + pin_out.deinit() + + +def test_dac_digital(p_in, p_out): + print(f"Running dac digital test with pin {p_in} as input and {p_out} as output") + pin_in = digitalio.DigitalInOut(p_in) + pin_out = analogio.AnalogOut(p_out) + + for v in range(0, 65536, 4096): + pin_out.value = v + print(f"Value {v} read as {pin_in.value}") + + pin_in.deinit() + pin_out.deinit() + + +def test_dual(pair1, pair2): + # verifies that the DACs can be set independently + print(f"Running pair test\n") + pin1_in = analogio.AnalogIn(pair1[0]) + pin1_out = analogio.AnalogOut(pair1[1]) + pin2_in = analogio.AnalogIn(pair2[0]) + pin2_out = analogio.AnalogOut(pair2[1]) + + for v in range(0, 65536, 4096): + v2 = 65535 - v + pin1_out.value = v + pin2_out.value = v2 + print(f"Pair1: Value {v} read as {pin1_in.value}") + print(f"Pair2: Value {v2} read as {pin2_in.value}") + + pin1_in.deinit() + pin1_out.deinit() + pin2_in.deinit() + pin2_out.deinit() + + +def test_analog_hilo(p_in, p_out): + print(f"Running analog hilo test with pin {p_in} as input and {p_out} as output") + pin_in = analogio.AnalogIn(p_in) + pin_out = digitalio.DigitalInOut(p_out) + pin_out.switch_to_output() + + for v in (False, True, False, True): + pin_out.value = v + print(f"Value {v} read as {pin_in.value}") + + pin_in.deinit() + pin_out.deinit() + + +def test_pair(pair): + # FIXME: test_analog_hilo works fine alone, but fails when the other dac functions are executed + test_analog_hilo(*pair) + test_dac_analog(*pair) + test_dac_digital(*pair) + + +def main(): + pair1 = (board.A3, board.DAC1) + pair2 = (board.A2, board.DAC2) + print("running DAC1 tests") + test_pair(pair1) + print("running DAC2 tests") + test_pair(pair2) + print("running dual DAC tests") + test_dual(pair1, pair2) + + +main() diff --git a/ports/stm/boards/swan_r5/tests/board_voltage.py b/ports/stm/boards/swan_r5/tests/board_voltage.py new file mode 100644 index 0000000000..6191067fde --- /dev/null +++ b/ports/stm/boards/swan_r5/tests/board_voltage.py @@ -0,0 +1,148 @@ +# SPDX-FileCopyrightText: 2018 Shawn Hymel for Adafruit Industries +# +# SPDX-License-Identifier: MIT + +print("pins test") + +""" +`adafruit_boardtest.boardtest_gpio` +==================================================== +Toggles all available GPIO on a board. Verify their operation with an LED, +multimeter, another microcontroller, etc. + +Run this script as its own main.py to individually run the test, or compile +with mpy-cross and call from separate test script. + +* Author(s): Shawn Hymel for Adafruit Industries + +Implementation Notes +-------------------- + +**Software and Dependencies:** + +* Adafruit CircuitPython firmware for the supported boards: + https://github.com/adafruit/circuitpython/releases + +""" + +import time + +import board +import digitalio +import supervisor + +__version__ = "0.0.0-auto.0" +__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_BoardTest.git" + +# Constants +LED_ON_DELAY_TIME = 0.2 # Seconds +LED_OFF_DELAY_TIME = 0.2 # Seconds +LED_PIN_NAMES = ["L", "LED", "RED_LED", "GREEN_LED", "BLUE_LED"] + +# Test result strings +PASS = "PASS" +FAIL = "FAIL" +NA = "N/A" + +# Determine if given value is a number +def _is_number(val): + try: + float(val) + return True + except ValueError: + return False + + +# Release pins +def _deinit_pins(gpios): + for g in gpios: + g.deinit() + + +# Toggle IO pins while waiting for answer +def _toggle_wait(pin_gpios): + + timestamp = time.monotonic() + led_state = False + failed = [] + for pg in pin_gpios: + (pin, gpio) = pg + print("Is pin %s toggling? [y/n]" % pin) + done = False + while not done: + if led_state: + if time.monotonic() > timestamp + LED_ON_DELAY_TIME: + led_state = False + timestamp = time.monotonic() + else: + if time.monotonic() > timestamp + LED_OFF_DELAY_TIME: + led_state = True + timestamp = time.monotonic() + + gpio.value = led_state + if supervisor.runtime.serial_bytes_available: + answer = input() + if bool(answer == "y"): + done = True + elif bool(answer == "n"): + failed += pin + done = True + return failed + + +def buildPin(pin): + gpio = digitalio.DigitalInOut(pin) + return gpio + + +def run_test(pins): + + """ + Toggles all available GPIO on and off repeatedly. + + :param list[str] pins: list of pins to run the test on + :return: tuple(str, list[str]): test result followed by list of pins tested + """ + + # Create a list of analog GPIO pins + analog_pins = [p for p in pins if p[0] == "A" and _is_number(p[1])] + + # Create a list of digital GPIO + digital_pins = [p for p in pins if p[0] == "D" and _is_number(p[1])] + + # Toggle LEDs if we find any + gpio_pins = analog_pins + digital_pins + + if gpio_pins: + + # Print out the LEDs found + print("GPIO pins found:", end=" ") + for pin in gpio_pins: + print(pin, end=" ") + print("\n") + + # Create a list of IO objects for us to toggle + gpios = [buildPin(getattr(board, p)) for p in gpio_pins] + + print("built GPIOs") + # Set all IO to output + for gpio in gpios: + gpio.direction = digitalio.Direction.OUTPUT + + # Toggle pins while waiting for user to verify LEDs blinking + result = _toggle_wait(zip(gpio_pins, gpios)) + + # Release pins + _deinit_pins(gpios) + + if result: + return FAIL, gpio_pins + + return PASS, gpio_pins + + # Else (no pins found) + print("No GPIO pins found") + return NA, [] + + +run_test([p for p in dir(board)]) diff --git a/ports/stm/boards/swan_r5/tests/button.py b/ports/stm/boards/swan_r5/tests/button.py new file mode 100644 index 0000000000..4f00254ddb --- /dev/null +++ b/ports/stm/boards/swan_r5/tests/button.py @@ -0,0 +1,22 @@ +import board +import digitalio +import time + + +def monitor_button(pin, callback): + with digitalio.DigitalInOut(pin) as button: + newstate = not button.value # state is inverted + state = not newstate # ensure change reported to start with + while callback(newstate, newstate != state): + state = newstate + newstate = button.value + time.sleep(0.01) + + +def print_changes(state, changed): + if changed: + print(f"button pressed {state}") + return True + + +monitor_button(board.BUTTON_USR, print_changes) diff --git a/ports/stm/boards/swan_r5/tests/enable_3v3.py b/ports/stm/boards/swan_r5/tests/enable_3v3.py new file mode 100644 index 0000000000..ba955c4f58 --- /dev/null +++ b/ports/stm/boards/swan_r5/tests/enable_3v3.py @@ -0,0 +1,35 @@ +# Background: I have a Swan R5 board running circuit python +# And I import the "board" module +import board +import digitalio +import supervisor +import time + +# Scenario: Enable 3V3 pin defintiion +# Then the symbol "board.ENABLE_3V3" is defined +assert board.ENABLE_3V3 is not None + +# Scenario: Discharge 3V3 definition +# Then the symbol "board.DISCHARGE_3V3" is defined +assert board.DISCHARGE_3V3 is not None +# And the symbol "board.DISABLE_DISCHARGING" is defined to be "True" +assert board.DISABLE_DISCHARGING is not None and board.DISABLE_DISCHARGING == True +# And the symbol "board.ENABLE_DISCHARGING" is defined to be "False" +assert board.ENABLE_DISCHARGING is not None and board.ENABLE_DISCHARGING == False + +# Scenario: Toggle ENBLE_3V3 +# Given I have a LED connected between the 3V3 and GND pins +# And ENABLE_3V3 is configured for output +_3v3 = digitalio.DigitalInOut(board.ENABLE_3V3) +_3v3.direction = digitalio.Direction.OUTPUT +# When I run code to toggle the pin at 0.5Hz +# Then I see the LED switch on and off at 0.5Hz +print("Toggling 3V3. Press a key to stop.") + +while not supervisor.runtime.serial_bytes_available: + _3v3.value = True + time.sleep(1.0) + _3v3.value = False + time.sleep(1.0) + +print("Toggling stopped.") diff --git a/ports/stm/boards/swan_r5/tests/i2c_scan.py b/ports/stm/boards/swan_r5/tests/i2c_scan.py new file mode 100644 index 0000000000..8e3ef557d1 --- /dev/null +++ b/ports/stm/boards/swan_r5/tests/i2c_scan.py @@ -0,0 +1,20 @@ +import board +import busio + +i2c = busio.I2C(board.SCL, board.SDA) +count = 0 + +# Wait for I2C lock +while not i2c.try_lock(): + pass + +# Scan for devices on the I2C bus +print("Scanning I2C bus") +for x in i2c.scan(): + print(hex(x)) + count += 1 + +print("%d device(s) found on I2C bus" % count) + +# Release the I2C bus +i2c.unlock() diff --git a/ports/stm/boards/swan_r5/tests/pwnio.py b/ports/stm/boards/swan_r5/tests/pwnio.py new file mode 100644 index 0000000000..71888d867b --- /dev/null +++ b/ports/stm/boards/swan_r5/tests/pwnio.py @@ -0,0 +1,17 @@ +import time +import pwmio + + +def fade(pin): + led = pwmio.PWMOut(pin, frequency=5000, duty_cycle=0) + # LED setup for QT Py M0: + # led = pwmio.PWMOut(board.SCK, frequency=5000, duty_cycle=0) + + while True: + for i in range(100): + # PWM LED up and down + if i < 50: + led.duty_cycle = int(i * 2 * 65535 / 100) # Up + else: + led.duty_cycle = 65535 - int((i - 50) * 2 * 65535 / 100) # Down + time.sleep(0.01) diff --git a/ports/stm/boards/swan_r5/tests/spi_bme680_smoke_test.py b/ports/stm/boards/swan_r5/tests/spi_bme680_smoke_test.py new file mode 100644 index 0000000000..01e98bfd31 --- /dev/null +++ b/ports/stm/boards/swan_r5/tests/spi_bme680_smoke_test.py @@ -0,0 +1,58 @@ +import board +import busio +import digitalio + +cs = digitalio.DigitalInOut(board.SS) +cs.direction = digitalio.Direction.OUTPUT +cs.value = True + +BME680_SPI_REGISTER = 0x73 +BME680_CHIPID_REGISTER = 0xD0 +BME680_CHIPID = 0x61 +SPI_HERZ = 0x500000 + +spi = busio.SPI(board.SCK, MISO=board.MISO, MOSI=board.MOSI) + + +def readByte(addr): + value = -1 + while not spi.try_lock(): + pass + try: + spi.configure(baudrate=500000, phase=0, polarity=0) + + cs.value = False + result = bytearray(1) + result[0] = addr | 0x80 + spi.write(result) + spi.readinto(result) + value = result[0] + return value + finally: + spi.unlock() + cs.value = True + + +def writeByte(addr, value): + while not spi.try_lock(): + pass + try: + spi.configure(baudrate=500000, phase=0, polarity=0) + + cs.value = False + result = bytearray(2) + result[0] = addr & ~0x80 + result[1] = value + spi.write(result) + finally: + spi.unlock() + + +# put the device in the correct mode to read the ID +reg = readByte(BME680_SPI_REGISTER) +if (reg & 16) != 0: + writeByte(BME680_SPI_REGISTER, reg & ~16) + +id = readByte(BME680_CHIPID_REGISTER) + +print(f"id is {id}, expected {BME680_CHIPID}") diff --git a/ports/stm/boards/swan_r5/tests/uart.py b/ports/stm/boards/swan_r5/tests/uart.py new file mode 100644 index 0000000000..a8dbc272a8 --- /dev/null +++ b/ports/stm/boards/swan_r5/tests/uart.py @@ -0,0 +1,37 @@ +import board +import busio +import digitalio +import usb_cdc +import time + +while not usb_cdc.console.in_waiting: + time.sleep(0.1) + +print("USART test") + +# For most CircuitPython boards: +led = digitalio.DigitalInOut(board.LED) +# For QT Py M0: +# led = digitalio.DigitalInOut(board.SCK) +led.direction = digitalio.Direction.OUTPUT + +uart = busio.UART(board.TX, board.RX, baudrate=9600) + +while True: + data = uart.read(32) # read up to 32 bytes + # print(data) # this is a bytearray type + + if data is not None: + led.value = True + + # convert bytearray to string + data_string = "*".join([chr(b) for b in data]) + print(data_string, end="") + + led.value = False + + if usb_cdc.console.in_waiting: + data = usb_cdc.console.read() + data_string = "*".join([chr(b) for b in data]) + print("writing " + data_string) + uart.write(data) diff --git a/ports/stm/boards/swan_r5/tests/urandom.py b/ports/stm/boards/swan_r5/tests/urandom.py new file mode 100644 index 0000000000..25ff655596 --- /dev/null +++ b/ports/stm/boards/swan_r5/tests/urandom.py @@ -0,0 +1,10 @@ +import os + + +def main(): + print("Random number test") + r = os.urandom(32) + print(f"urandom TRNG string is {r}") + + +main() diff --git a/ports/stm/boards/system_stm32l4xx.c b/ports/stm/boards/system_stm32l4xx.c new file mode 100644 index 0000000000..3890fc0895 --- /dev/null +++ b/ports/stm/boards/system_stm32l4xx.c @@ -0,0 +1,375 @@ +/* + * Taken from ST Cube library and modified. See below for original header. + * + * Modifications copyright (c) 2021 Blues Wireless Contributors + * + * 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. + */ + +/** + ****************************************************************************** + * @file system_stm32l4xx.c + * @author MCD Application Team + * @brief CMSIS Cortex-M4 Device Peripheral Access Layer System Source File + * + * This file provides two functions and one global variable to be called from + * user application: + * - SystemInit(): This function is called at startup just after reset and + * before branch to main program. This call is made inside + * the "startup_stm32l4xx.s" file. + * + * - SystemCoreClock variable: Contains the core clock (HCLK), it can be used + * by the user application to setup the SysTick + * timer or configure other parameters. + * + * - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must + * be called whenever the core clock is changed + * during program execution. + * + * After each device reset the MSI (4 MHz) is used as system clock source. + * Then SystemInit() function is called, in "startup_stm32l4xx.s" file, to + * configure the system clock before to branch to main program. + * + * This file configures the system clock as follows: + *============================================================================= + *----------------------------------------------------------------------------- + * System Clock source | MSI + *----------------------------------------------------------------------------- + * SYSCLK(Hz) | 4000000 + *----------------------------------------------------------------------------- + * HCLK(Hz) | 4000000 + *----------------------------------------------------------------------------- + * AHB Prescaler | 1 + *----------------------------------------------------------------------------- + * APB1 Prescaler | 1 + *----------------------------------------------------------------------------- + * APB2 Prescaler | 1 + *----------------------------------------------------------------------------- + * PLL_M | 1 + *----------------------------------------------------------------------------- + * PLL_N | 8 + *----------------------------------------------------------------------------- + * PLL_P | 7 + *----------------------------------------------------------------------------- + * PLL_Q | 2 + *----------------------------------------------------------------------------- + * PLL_R | 2 + *----------------------------------------------------------------------------- + * PLLSAI1_P | NA + *----------------------------------------------------------------------------- + * PLLSAI1_Q | NA + *----------------------------------------------------------------------------- + * PLLSAI1_R | NA + *----------------------------------------------------------------------------- + * PLLSAI2_P | NA + *----------------------------------------------------------------------------- + * PLLSAI2_Q | NA + *----------------------------------------------------------------------------- + * PLLSAI2_R | NA + *----------------------------------------------------------------------------- + * Require 48MHz for USB OTG FS, | Disabled + * SDIO and RNG clock | + *----------------------------------------------------------------------------- + *============================================================================= + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2017 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under Apache License, Version 2.0, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/Apache-2.0 + * + ****************************************************************************** + */ + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup stm32l4xx_system + * @{ + */ + +/** @addtogroup STM32L4xx_System_Private_Includes + * @{ + */ + +#include "stm32l4xx.h" +#include + +/** + * @} + */ + +/** @addtogroup STM32L4xx_System_Private_TypesDefinitions + * @{ + */ + +/** + * @} + */ + +/** @addtogroup STM32L4xx_System_Private_Defines + * @{ + */ + +#if !defined(HSE_VALUE) + #define HSE_VALUE 8000000U /*!< Value of the External oscillator in Hz */ +#endif /* HSE_VALUE */ + +#if !defined(MSI_VALUE) + #define MSI_VALUE 4000000U /*!< Value of the Internal oscillator in Hz*/ +#endif /* MSI_VALUE */ + +#if !defined(HSI_VALUE) + #define HSI_VALUE 16000000U /*!< Value of the Internal oscillator in Hz*/ +#endif /* HSI_VALUE */ + +/* Note: Following vector table addresses must be defined in line with linker + configuration. */ +/*!< Uncomment the following line if you need to relocate the vector table + anywhere in Flash or Sram, else the vector table is kept at the automatic + remap of boot address selected */ +/* #define USER_VECT_TAB_ADDRESS */ + +#if defined(USER_VECT_TAB_ADDRESS) +/*!< Uncomment the following line if you need to relocate your vector Table + in Sram else user remap will be done in Flash. */ +/* #define VECT_TAB_SRAM */ + +#if defined(VECT_TAB_SRAM) +#define VECT_TAB_BASE_ADDRESS SRAM1_BASE /*!< Vector Table base address field. + This value must be a multiple of 0x200. */ +#define VECT_TAB_OFFSET 0x00000000U /*!< Vector Table base offset field. + This value must be a multiple of 0x200. */ +#else +#define VECT_TAB_BASE_ADDRESS FLASH_BASE /*!< Vector Table base address field. + This value must be a multiple of 0x200. */ +#define VECT_TAB_OFFSET 0x00000000U /*!< Vector Table base offset field. + This value must be a multiple of 0x200. */ +#endif /* VECT_TAB_SRAM */ +#endif /* USER_VECT_TAB_ADDRESS */ + +/******************************************************************************/ +/** + * @} + */ + +/** @addtogroup STM32L4xx_System_Private_Macros + * @{ + */ + +/** + * @} + */ + +/** @addtogroup STM32L4xx_System_Private_Variables + * @{ + */ +/* The SystemCoreClock variable is updated in three ways: + 1) by calling CMSIS function SystemCoreClockUpdate() + 2) by calling HAL API function HAL_RCC_GetHCLKFreq() + 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency + Note: If you use this function to configure the system clock; then there + is no need to call the 2 first functions listed above, since SystemCoreClock + variable is updated automatically. + */ +uint32_t SystemCoreClock = 4000000U; + +const uint8_t AHBPrescTable[16] = {0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 1U, 2U, 3U, 4U, 6U, 7U, 8U, 9U}; +const uint8_t APBPrescTable[8] = {0U, 0U, 0U, 0U, 1U, 2U, 3U, 4U}; +const uint32_t MSIRangeTable[12] = {100000U, 200000U, 400000U, 800000U, 1000000U, 2000000U, \ + 4000000U, 8000000U, 16000000U, 24000000U, 32000000U, 48000000U}; +/** + * @} + */ + +/** @addtogroup STM32L4xx_System_Private_FunctionPrototypes + * @{ + */ + +/** + * @} + */ + +/** @addtogroup STM32L4xx_System_Private_Functions + * @{ + */ + +/** + * @brief Setup the microcontroller system. + * @retval None + */ + +void SystemInit(void) { + + /* FPU settings ------------------------------------------------------------*/ + #if (__FPU_PRESENT == 1) && (__FPU_USED == 1) + SCB->CPACR |= ((3UL << 20U) | (3UL << 22U)); /* set CP10 and CP11 Full Access */ + #endif + + /* Reset the RCC clock configuration to the default reset state ------------*/ + /* Set MSION bit */ + RCC->CR |= RCC_CR_MSION; + + /* Reset CFGR register */ + RCC->CFGR = 0x00000000U; + + /* Reset HSEON, CSSON , HSION, and PLLON bits */ + RCC->CR &= 0xEAF6FFFFU; + + /* Reset PLLCFGR register */ + RCC->PLLCFGR = 0x00001000U; + + /* Reset HSEBYP bit */ + RCC->CR &= 0xFFFBFFFFU; + + /* Disable all interrupts */ + RCC->CIER = 0x00000000U; + + #if !(BOARD_VTOR_DEFER) // only set VTOR if the bootloader hasn't already + #if defined(USER_VECT_TAB_ADDRESS) + /* Configure the Vector Table location -------------------------------------*/ + SCB->VTOR = VECT_TAB_BASE_ADDRESS | VECT_TAB_OFFSET; + #endif + #endif +} + +/** + * @brief Update SystemCoreClock variable according to Clock Register Values. + * The SystemCoreClock variable contains the core clock (HCLK), it can + * be used by the user application to setup the SysTick timer or configure + * other parameters. + * + * @note Each time the core clock (HCLK) changes, this function must be called + * to update SystemCoreClock variable value. Otherwise, any configuration + * based on this variable will be incorrect. + * + * @note - The system frequency computed by this function is not the real + * frequency in the chip. It is calculated based on the predefined + * constant and the selected clock source: + * + * - If SYSCLK source is MSI, SystemCoreClock will contain the MSI_VALUE(*) + * + * - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(**) + * + * - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(***) + * + * - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(***) + * or HSI_VALUE(*) or MSI_VALUE(*) multiplied/divided by the PLL factors. + * + * (*) MSI_VALUE is a constant defined in stm32l4xx_hal.h file (default value + * 4 MHz) but the real value may vary depending on the variations + * in voltage and temperature. + * + * (**) HSI_VALUE is a constant defined in stm32l4xx_hal.h file (default value + * 16 MHz) but the real value may vary depending on the variations + * in voltage and temperature. + * + * (***) HSE_VALUE is a constant defined in stm32l4xx_hal.h file (default value + * 8 MHz), user has to ensure that HSE_VALUE is same as the real + * frequency of the crystal used. Otherwise, this function may + * have wrong result. + * + * - The result of this function could be not correct when using fractional + * value for HSE crystal. + * + * @retval None + */ +void SystemCoreClockUpdate(void) { + uint32_t tmp, msirange, pllvco, pllsource, pllm, pllr; + + /* Get MSI Range frequency--------------------------------------------------*/ + if ((RCC->CR & RCC_CR_MSIRGSEL) == 0U) { /* MSISRANGE from RCC_CSR applies */ + msirange = (RCC->CSR & RCC_CSR_MSISRANGE) >> 8U; + } else { /* MSIRANGE from RCC_CR applies */ + msirange = (RCC->CR & RCC_CR_MSIRANGE) >> 4U; + } + /*MSI frequency range in HZ*/ + msirange = MSIRangeTable[msirange]; + + /* Get SYSCLK source -------------------------------------------------------*/ + switch (RCC->CFGR & RCC_CFGR_SWS) + { + case 0x00: /* MSI used as system clock source */ + SystemCoreClock = msirange; + break; + + case 0x04: /* HSI used as system clock source */ + SystemCoreClock = HSI_VALUE; + break; + + case 0x08: /* HSE used as system clock source */ + SystemCoreClock = HSE_VALUE; + break; + + case 0x0C: /* PLL used as system clock source */ + /* PLL_VCO = (HSE_VALUE or HSI_VALUE or MSI_VALUE/ PLLM) * PLLN + SYSCLK = PLL_VCO / PLLR + */ + pllsource = (RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC); + pllm = ((RCC->PLLCFGR & RCC_PLLCFGR_PLLM) >> 4U) + 1U; + + switch (pllsource) + { + case 0x02: /* HSI used as PLL clock source */ + pllvco = (HSI_VALUE / pllm); + break; + + case 0x03: /* HSE used as PLL clock source */ + pllvco = (HSE_VALUE / pllm); + break; + + default: /* MSI used as PLL clock source */ + pllvco = (msirange / pllm); + break; + } + pllvco = pllvco * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 8U); + pllr = (((RCC->PLLCFGR & RCC_PLLCFGR_PLLR) >> 25U) + 1U) * 2U; + SystemCoreClock = pllvco / pllr; + break; + + default: + SystemCoreClock = msirange; + break; + } + /* Compute HCLK clock frequency --------------------------------------------*/ + /* Get HCLK prescaler */ + tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4U)]; + /* HCLK clock frequency */ + SystemCoreClock >>= tmp; +} + + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/ports/stm/common-hal/alarm/SleepMemory.c b/ports/stm/common-hal/alarm/SleepMemory.c index dc19222d63..d8fa88785e 100644 --- a/ports/stm/common-hal/alarm/SleepMemory.c +++ b/ports/stm/common-hal/alarm/SleepMemory.c @@ -31,8 +31,17 @@ #include STM32_HAL_H -#define STM_BKPSRAM_SIZE 0x1000 -#define STM_BKPSRAM_START BKPSRAM_BASE +#if CPY_STM32L4 + #define __HAL_RCC_BKPSRAM_CLK_ENABLE() + #define STM_BKPSRAM_SIZE 0 + #define STM_BKPSRAM_START 0 + #define HAL_PWREx_EnableBkUpReg() +// backup RAM disabled for now. Will have the backup region at the top of SRAM3 which is retained. +#else + #define STM_BKPSRAM_SIZE 0x1000 + #define STM_BKPSRAM_START BKPSRAM_BASE +#endif + STATIC bool initialized = false; diff --git a/ports/stm/common-hal/alarm/__init__.c b/ports/stm/common-hal/alarm/__init__.c index 3ec546f52b..466c2d5199 100644 --- a/ports/stm/common-hal/alarm/__init__.c +++ b/ports/stm/common-hal/alarm/__init__.c @@ -28,7 +28,7 @@ #include "py/obj.h" #include "py/objtuple.h" #include "py/runtime.h" -#include "lib/utils/interrupt_char.h" +#include "shared/runtime/interrupt_char.h" #include "shared-bindings/alarm/__init__.h" #include "shared-bindings/alarm/SleepMemory.h" diff --git a/ports/stm/common-hal/analogio/AnalogIn.c b/ports/stm/common-hal/analogio/AnalogIn.c index 35010ac7c5..ed2575493e 100644 --- a/ports/stm/common-hal/analogio/AnalogIn.c +++ b/ports/stm/common-hal/analogio/AnalogIn.c @@ -31,10 +31,20 @@ #include "shared-bindings/microcontroller/Pin.h" +#if CPY_STM32L4 +#include "stm32l4xx_hal.h" +#include "stm32l4xx_ll_gpio.h" +#include "stm32l4xx_ll_adc.h" +#include "stm32l4xx_ll_bus.h" +#define ADC_SAMPLETIME ADC_SAMPLETIME_24CYCLES_5 +#define LL_APB2_GRP1_PERIPH_ADC1 LL_AHB2_GRP1_PERIPH_ADC +#else #include "stm32f4xx_hal.h" #include "stm32f4xx_ll_gpio.h" #include "stm32f4xx_ll_adc.h" #include "stm32f4xx_ll_bus.h" +#define ADC_SAMPLETIME ADC_SAMPLETIME_15CYCLES +#endif void common_hal_analogio_analogin_construct(analogio_analogin_obj_t *self, const mcu_pin_obj_t *pin) { @@ -73,6 +83,55 @@ void common_hal_analogio_analogin_deinit(analogio_analogin_obj_t *self) { self->pin = NULL; } +uint32_t adc_channel(uint32_t channel) { + #if CPY_STM32L4 + switch (channel) { + case 0: + return ADC_CHANNEL_0; + case 1: + return ADC_CHANNEL_1; + case 2: + return ADC_CHANNEL_2; + case 3: + return ADC_CHANNEL_3; + case 4: + return ADC_CHANNEL_4; + case 5: + return ADC_CHANNEL_5; + case 6: + return ADC_CHANNEL_6; + case 7: + return ADC_CHANNEL_7; + case 8: + return ADC_CHANNEL_8; + case 9: + return ADC_CHANNEL_9; + case 10: + return ADC_CHANNEL_10; + case 11: + return ADC_CHANNEL_11; + case 12: + return ADC_CHANNEL_12; + case 13: + return ADC_CHANNEL_13; + case 14: + return ADC_CHANNEL_14; + case 15: + return ADC_CHANNEL_15; + case 16: + return ADC_CHANNEL_16; + case 17: + return ADC_CHANNEL_17; + case 18: + return ADC_CHANNEL_18; + default: + return 0; + } + #else + return channel; + #endif +} + uint16_t common_hal_analogio_analogin_get_value(analogio_analogin_obj_t *self) { // Something else might have used the ADC in a different way, // so we completely re-initialize it. @@ -80,6 +139,9 @@ uint16_t common_hal_analogio_analogin_get_value(analogio_analogin_obj_t *self) { if (self->pin->adc_unit & 0x01) { ADCx = ADC1; + #if CPY_STM32L4 + __HAL_RCC_ADC_CLK_ENABLE(); + #endif } else if (self->pin->adc_unit == 0x04) { #ifdef ADC3 ADCx = ADC3; @@ -92,8 +154,8 @@ uint16_t common_hal_analogio_analogin_get_value(analogio_analogin_obj_t *self) { // LL_GPIO_PIN_0 // HAL Implementation - ADC_HandleTypeDef AdcHandle; - ADC_ChannelConfTypeDef sConfig; + ADC_HandleTypeDef AdcHandle = {}; + ADC_ChannelConfTypeDef sConfig = {}; AdcHandle.Instance = ADCx; AdcHandle.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV2; @@ -102,20 +164,42 @@ uint16_t common_hal_analogio_analogin_get_value(analogio_analogin_obj_t *self) { AdcHandle.Init.ContinuousConvMode = DISABLE; AdcHandle.Init.DiscontinuousConvMode = DISABLE; AdcHandle.Init.NbrOfDiscConversion = 0; + AdcHandle.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE; AdcHandle.Init.ExternalTrigConv = ADC_SOFTWARE_START; AdcHandle.Init.DataAlign = ADC_DATAALIGN_RIGHT; AdcHandle.Init.NbrOfConversion = 1; AdcHandle.Init.DMAContinuousRequests = DISABLE; AdcHandle.Init.EOCSelection = ADC_EOC_SINGLE_CONV; - HAL_ADC_Init(&AdcHandle); + #ifdef ADC_OVR_DATA_OVERWRITTEN + AdcHandle.Init.Overrun = ADC_OVR_DATA_OVERWRITTEN; /* DR register is overwritten with the last conversion result in case of overrun */ + #endif - sConfig.Channel = (uint32_t)self->pin->adc_channel; // ADC_CHANNEL_0 <-normal iteration, not mask + if (HAL_ADC_Init(&AdcHandle) != HAL_OK) { + return 0; + } + + sConfig.Channel = adc_channel(self->pin->adc_channel); // ADC_CHANNEL_0 <-normal iteration, not mask sConfig.Rank = 1; - sConfig.SamplingTime = ADC_SAMPLETIME_15CYCLES; // Taken from micropython - HAL_ADC_ConfigChannel(&AdcHandle, &sConfig); - - HAL_ADC_Start(&AdcHandle); + sConfig.SamplingTime = ADC_SAMPLETIME; + #if CPY_STM32L4 + sConfig.SingleDiff = ADC_SINGLE_ENDED; /* Single-ended input channel */ + sConfig.OffsetNumber = ADC_OFFSET_NONE; /* No offset subtraction */ + if (!IS_ADC_CHANNEL(&AdcHandle, sConfig.Channel)) { + return 0; + } + #endif + if (HAL_ADC_ConfigChannel(&AdcHandle, &sConfig) != HAL_OK) { + return 0; + } + #if CPY_STM32L4 + if (HAL_ADCEx_Calibration_Start(&AdcHandle, ADC_SINGLE_ENDED) != HAL_OK) { + return 0; + } + #endif + if (HAL_ADC_Start(&AdcHandle) != HAL_OK) { + return 0; + } HAL_ADC_PollForConversion(&AdcHandle,1); uint16_t value = (uint16_t)HAL_ADC_GetValue(&AdcHandle); HAL_ADC_Stop(&AdcHandle); diff --git a/ports/stm/common-hal/analogio/AnalogOut.c b/ports/stm/common-hal/analogio/AnalogOut.c index 1a3817a35d..0320b1f99b 100644 --- a/ports/stm/common-hal/analogio/AnalogOut.c +++ b/ports/stm/common-hal/analogio/AnalogOut.c @@ -37,7 +37,14 @@ #include "common-hal/microcontroller/Pin.h" -#include "stm32f4xx_hal.h" +#include STM32_HAL_H + +#ifndef __HAL_RCC_DAC_CLK_ENABLE +#define __HAL_RCC_DAC_CLK_ENABLE __HAL_RCC_DAC1_CLK_ENABLE +#endif +#ifndef __HAL_RCC_DAC_CLK_DISABLE +#define __HAL_RCC_DAC_CLK_DISABLE __HAL_RCC_DAC1_CLK_DISABLE +#endif // DAC is shared between both channels. #if HAS_DAC diff --git a/ports/stm/common-hal/analogio/AnalogOut.h b/ports/stm/common-hal/analogio/AnalogOut.h index 3c208a6118..d0b08c95e9 100644 --- a/ports/stm/common-hal/analogio/AnalogOut.h +++ b/ports/stm/common-hal/analogio/AnalogOut.h @@ -31,7 +31,11 @@ #include "common-hal/microcontroller/Pin.h" #include "py/obj.h" +#if CPY_STM32L4 +#include "stm32l4xx_hal.h" +#else #include "stm32f4xx_hal.h" +#endif #include "peripherals/periph.h" typedef struct { diff --git a/ports/stm/common-hal/busio/I2C.c b/ports/stm/common-hal/busio/I2C.c index db6d86c342..ffad368a2f 100644 --- a/ports/stm/common-hal/busio/I2C.c +++ b/ports/stm/common-hal/busio/I2C.c @@ -50,6 +50,13 @@ #ifndef CPY_I2CSTANDARD_TIMINGR #define CPY_I2CSTANDARD_TIMINGR 0x307075B1 #endif +#elif (CPY_STM32L4) +#ifndef CPY_I2CFAST_TIMINGR +#define CPY_I2CFAST_TIMINGR 0x00B03FDB +#endif +#ifndef CPY_I2CSTANDARD_TIMINGR +#define CPY_I2CSTANDARD_TIMINGR 0x307075B1 +#endif #endif // Arrays use 0 based numbering: I2C1 is stored at index 0 @@ -142,7 +149,7 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, i2c_assign_irq(self, I2Cx); // Handle the HAL handle differences - #if (CPY_STM32H7 || CPY_STM32F7) + #if (CPY_STM32H7 || CPY_STM32F7 || CPY_STM32L4) if (frequency == 400000) { self->handle.Init.Timing = CPY_I2CFAST_TIMINGR; } else if (frequency == 100000) { diff --git a/ports/stm/common-hal/busio/SPI.c b/ports/stm/common-hal/busio/SPI.c index 2f26a01cba..77f2b53706 100644 --- a/ports/stm/common-hal/busio/SPI.c +++ b/ports/stm/common-hal/busio/SPI.c @@ -58,7 +58,7 @@ STATIC uint32_t get_busclock(SPI_TypeDef *instance) { } else { return HAL_RCCEx_GetPeriphCLKFreq(RCC_PERIPHCLK_SPI6); } - #elif (CPY_STM32F4 || CPY_STM32F7) + #elif (CPY_STM32F4 || CPY_STM32F7 || CPY_STM32L4) // SPI2 and 3 are on PCLK1, if they exist. #ifdef SPI2 if (instance == SPI2) { diff --git a/ports/stm/common-hal/busio/UART.c b/ports/stm/common-hal/busio/UART.c index 621cce6cfd..d8677126ef 100644 --- a/ports/stm/common-hal/busio/UART.c +++ b/ports/stm/common-hal/busio/UART.c @@ -29,8 +29,8 @@ #include "shared-bindings/busio/UART.h" #include "mpconfigport.h" -#include "lib/mp-readline/readline.h" -#include "lib/utils/interrupt_char.h" +#include "shared/readline/readline.h" +#include "shared/runtime/interrupt_char.h" #include "py/gc.h" #include "py/mperrno.h" #include "py/runtime.h" diff --git a/ports/stm/common-hal/canio/CAN.h b/ports/stm/common-hal/canio/CAN.h index 16bb8fd1e4..3592e9b3db 100644 --- a/ports/stm/common-hal/canio/CAN.h +++ b/ports/stm/common-hal/canio/CAN.h @@ -33,8 +33,7 @@ #include "common-hal/canio/__init__.h" #include "shared-module/canio/Message.h" -#include "stm32f4xx_hal.h" -#include "stm32f4xx_hal_can.h" +#include STM32_HAL_H #define FILTER_BANK_COUNT (28) diff --git a/ports/stm/common-hal/canio/Listener.c b/ports/stm/common-hal/canio/Listener.c index dc819180f9..69c196b78d 100644 --- a/ports/stm/common-hal/canio/Listener.c +++ b/ports/stm/common-hal/canio/Listener.c @@ -30,7 +30,7 @@ #include "py/obj.h" #include "py/runtime.h" -#include "lib/utils/interrupt_char.h" +#include "shared/runtime/interrupt_char.h" #include "common-hal/canio/__init__.h" #include "common-hal/canio/Listener.h" diff --git a/ports/stm/common-hal/digitalio/DigitalInOut.c b/ports/stm/common-hal/digitalio/DigitalInOut.c index fbefdb79ab..39c72b73c9 100644 --- a/ports/stm/common-hal/digitalio/DigitalInOut.c +++ b/ports/stm/common-hal/digitalio/DigitalInOut.c @@ -37,6 +37,10 @@ #include "stm32f7xx_ll_gpio.h" #elif (CPY_STM32F4) #include "stm32f4xx_ll_gpio.h" +#elif (CPY_STM32L4) +#include "stm32l4xx_ll_gpio.h" +#else + #error unknown MCU for DigitalInOut #endif void common_hal_digitalio_digitalinout_never_reset( diff --git a/ports/stm/common-hal/microcontroller/Pin.c b/ports/stm/common-hal/microcontroller/Pin.c index fa03a7a210..9d6c8ec71a 100644 --- a/ports/stm/common-hal/microcontroller/Pin.c +++ b/ports/stm/common-hal/microcontroller/Pin.c @@ -33,7 +33,7 @@ #if defined(TFBGA216) GPIO_TypeDef *ports[] = {GPIOA, GPIOB, GPIOC, GPIOD, GPIOE, GPIOF, GPIOG, GPIOH, GPIOI, GPIOJ, GPIOK}; -#elif defined(LQFP144) +#elif defined(LQFP144) || defined(WLCSP144) GPIO_TypeDef *ports[] = {GPIOA, GPIOB, GPIOC, GPIOD, GPIOE, GPIOF, GPIOG}; #elif defined(LQFP100_f4) || (LQFP100_x7) GPIO_TypeDef *ports[] = {GPIOA, GPIOB, GPIOC, GPIOD, GPIOE}; @@ -41,6 +41,8 @@ GPIO_TypeDef *ports[] = {GPIOA, GPIOB, GPIOC, GPIOD, GPIOE}; GPIO_TypeDef *ports[] = {GPIOA, GPIOB, GPIOC, GPIOD}; #elif defined(UFQFPN48) GPIO_TypeDef *ports[] = {GPIOA, GPIOB, GPIOC}; +#else + #error Unknown package type #endif diff --git a/ports/stm/common-hal/nvm/ByteArray.c b/ports/stm/common-hal/nvm/ByteArray.c index 6ef2eb3928..1a24b09eb4 100644 --- a/ports/stm/common-hal/nvm/ByteArray.c +++ b/ports/stm/common-hal/nvm/ByteArray.c @@ -26,8 +26,7 @@ #include "common-hal/nvm/ByteArray.h" -#include "stm32f4xx_hal.h" - +#include STM32_HAL_H #include "supervisor/shared/stack.h" #include diff --git a/ports/stm/common-hal/pulseio/PulseIn.c b/ports/stm/common-hal/pulseio/PulseIn.c index 27ef978dac..70e1851939 100644 --- a/ports/stm/common-hal/pulseio/PulseIn.c +++ b/ports/stm/common-hal/pulseio/PulseIn.c @@ -62,7 +62,11 @@ STATIC void pulsein_exti_event_handler(uint8_t num) { uint32_t current_count = tim_handle.Instance->CNT; // Interrupt register must be cleared manually + #if CPY_STM32L4 + EXTI->PR1 = 1 << num; + #else EXTI->PR = 1 << num; + #endif pulseio_pulsein_obj_t *self = callback_obj_ref[num]; if (!self) { diff --git a/ports/stm/hal_conf/stm32f4xx_hal_conf.h b/ports/stm/hal_conf/stm32f4xx_hal_conf.h index 7fb3b77e5a..7c308eae22 100644 --- a/ports/stm/hal_conf/stm32f4xx_hal_conf.h +++ b/ports/stm/hal_conf/stm32f4xx_hal_conf.h @@ -386,6 +386,7 @@ void assert_failed(uint8_t *file, uint32_t line); #define CPY_STM32F4 1 #define CPY_STM32F7 0 #define CPY_STM32H7 0 +#define CPY_STM32L4 0 #endif /* __STM32F4xx_HAL_CONF_H */ diff --git a/ports/stm/hal_conf/stm32f7xx_hal_conf.h b/ports/stm/hal_conf/stm32f7xx_hal_conf.h index 72cb60e447..a409e5c125 100644 --- a/ports/stm/hal_conf/stm32f7xx_hal_conf.h +++ b/ports/stm/hal_conf/stm32f7xx_hal_conf.h @@ -391,6 +391,8 @@ void assert_failed(uint8_t *file, uint32_t line); #define CPY_STM32F4 0 #define CPY_STM32F7 1 #define CPY_STM32H7 0 +#define CPY_STM32L4 0 + #endif /* __STM32F7xx_HAL_CONF_H */ diff --git a/ports/stm/hal_conf/stm32h7xx_hal_conf.h b/ports/stm/hal_conf/stm32h7xx_hal_conf.h index 630e63b8f5..81ff1749c6 100644 --- a/ports/stm/hal_conf/stm32h7xx_hal_conf.h +++ b/ports/stm/hal_conf/stm32h7xx_hal_conf.h @@ -436,6 +436,8 @@ void assert_failed(uint8_t *file, uint32_t line); #define CPY_STM32F4 0 #define CPY_STM32F7 0 #define CPY_STM32H7 1 +#define CPY_STM32L4 0 + #endif /* __STM32H7xx_HAL_CONF_H */ diff --git a/ports/stm/hal_conf/stm32l4xx_hal_conf.h b/ports/stm/hal_conf/stm32l4xx_hal_conf.h new file mode 100644 index 0000000000..65b712fc2b --- /dev/null +++ b/ports/stm/hal_conf/stm32l4xx_hal_conf.h @@ -0,0 +1,480 @@ +/** + ****************************************************************************** + * @file stm32l4xx_hal_conf.h + * @author MCD Application Team + * @brief HAL configuration template file. + * This file should be copied to the application folder and renamed + * to stm32l4xx_hal_conf.h. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2017 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +#include "stm32_hal_conf.h" + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef STM32L4xx_HAL_CONF_H +#define STM32L4xx_HAL_CONF_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ + +/* ########################## Module Selection ############################## */ +/** + * @brief This is the list of modules to be used in the HAL driver + */ +#define HAL_MODULE_ENABLED +#define HAL_ADC_MODULE_ENABLED +#define HAL_CAN_MODULE_ENABLED +/* #define HAL_CAN_LEGACY_MODULE_ENABLED */ +#define HAL_COMP_MODULE_ENABLED +#define HAL_CORTEX_MODULE_ENABLED +#define HAL_CRC_MODULE_ENABLED +#define HAL_CRYP_MODULE_ENABLED +#define HAL_DAC_MODULE_ENABLED +#define HAL_DCMI_MODULE_ENABLED +#define HAL_DFSDM_MODULE_ENABLED +#define HAL_DMA_MODULE_ENABLED +#define HAL_DMA2D_MODULE_ENABLED +#define HAL_DSI_MODULE_ENABLED +#define HAL_EXTI_MODULE_ENABLED +#define HAL_FIREWALL_MODULE_ENABLED +#define HAL_FLASH_MODULE_ENABLED +#define HAL_GFXMMU_MODULE_ENABLED +#define HAL_GPIO_MODULE_ENABLED +#define HAL_HASH_MODULE_ENABLED +#define HAL_HCD_MODULE_ENABLED +#define HAL_I2C_MODULE_ENABLED +#define HAL_IRDA_MODULE_ENABLED +#define HAL_IWDG_MODULE_ENABLED +#define HAL_LCD_MODULE_ENABLED +#define HAL_LPTIM_MODULE_ENABLED +#define HAL_LTDC_MODULE_ENABLED +#define HAL_MMC_MODULE_ENABLED +#define HAL_NAND_MODULE_ENABLED +#define HAL_NOR_MODULE_ENABLED +#define HAL_OPAMP_MODULE_ENABLED +#define HAL_OSPI_MODULE_ENABLED +#define HAL_PCD_MODULE_ENABLED +#define HAL_PWR_MODULE_ENABLED +#define HAL_QSPI_MODULE_ENABLED +#define HAL_RCC_MODULE_ENABLED +#define HAL_RNG_MODULE_ENABLED +#define HAL_RTC_MODULE_ENABLED +#define HAL_SAI_MODULE_ENABLED +#define HAL_SD_MODULE_ENABLED +#define HAL_SMARTCARD_MODULE_ENABLED +#define HAL_SMBUS_MODULE_ENABLED +#define HAL_SPI_MODULE_ENABLED +#define HAL_SRAM_MODULE_ENABLED +#define HAL_SWPMI_MODULE_ENABLED +#define HAL_TIM_MODULE_ENABLED +#define HAL_TSC_MODULE_ENABLED +#define HAL_UART_MODULE_ENABLED +#define HAL_USART_MODULE_ENABLED +#define HAL_WWDG_MODULE_ENABLED + + +/* ########################## Oscillator Values adaptation ####################*/ +/** + * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSE is used as system clock source, directly or through the PLL). + */ +#if !defined(HSE_VALUE) + #define HSE_VALUE 8000000U /*!< Value of the External oscillator in Hz */ +#endif /* HSE_VALUE */ + +#if !defined(HSE_STARTUP_TIMEOUT) + #define HSE_STARTUP_TIMEOUT 100U /*!< Time out for HSE start up, in ms */ +#endif /* HSE_STARTUP_TIMEOUT */ + +/** + * @brief Internal Multiple Speed oscillator (MSI) default value. + * This value is the default MSI range value after Reset. + */ +#if !defined(MSI_VALUE) + #define MSI_VALUE 4000000U /*!< Value of the Internal oscillator in Hz*/ +#endif /* MSI_VALUE */ + +/** + * @brief Internal High Speed oscillator (HSI) value. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSI is used as system clock source, directly or through the PLL). + */ +#if !defined(HSI_VALUE) + #define HSI_VALUE 16000000U /*!< Value of the Internal oscillator in Hz*/ +#endif /* HSI_VALUE */ + +/** + * @brief Internal High Speed oscillator (HSI48) value for USB FS, SDMMC and RNG. + * This internal oscillator is mainly dedicated to provide a high precision clock to + * the USB peripheral by means of a special Clock Recovery System (CRS) circuitry. + * When the CRS is not used, the HSI48 RC oscillator runs on it default frequency + * which is subject to manufacturing process variations. + */ +#if !defined(HSI48_VALUE) + #define HSI48_VALUE 48000000U /*!< Value of the Internal High Speed oscillator for USB FS/SDMMC/RNG in Hz. + The real value my vary depending on manufacturing process variations.*/ +#endif /* HSI48_VALUE */ + +/** + * @brief Internal Low Speed oscillator (LSI) value. + */ +#if !defined(LSI_VALUE) + #define LSI_VALUE 32000U /*!< LSI Typical Value in Hz*/ +#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz + The real value may vary depending on the variations + in voltage and temperature.*/ +/** + * @brief External Low Speed oscillator (LSE) value. + * This value is used by the UART, RTC HAL module to compute the system frequency + */ +#if !defined(LSE_VALUE) + #define LSE_VALUE 32768U /*!< Value of the External oscillator in Hz*/ +#endif /* LSE_VALUE */ + +#if !defined(LSE_STARTUP_TIMEOUT) + #define LSE_STARTUP_TIMEOUT 5000U /*!< Time out for LSE start up, in ms */ +#endif /* HSE_STARTUP_TIMEOUT */ + +/** + * @brief External clock source for SAI1 peripheral + * This value is used by the RCC HAL module to compute the SAI1 & SAI2 clock source + * frequency. + */ +#if !defined(EXTERNAL_SAI1_CLOCK_VALUE) + #define EXTERNAL_SAI1_CLOCK_VALUE 48000U /*!< Value of the SAI1 External clock source in Hz*/ +#endif /* EXTERNAL_SAI1_CLOCK_VALUE */ + +/** + * @brief External clock source for SAI2 peripheral + * This value is used by the RCC HAL module to compute the SAI1 & SAI2 clock source + * frequency. + */ +#if !defined(EXTERNAL_SAI2_CLOCK_VALUE) + #define EXTERNAL_SAI2_CLOCK_VALUE 48000U /*!< Value of the SAI2 External clock source in Hz*/ +#endif /* EXTERNAL_SAI2_CLOCK_VALUE */ + +/* Tip: To avoid modifying this file each time you need to use different HSE, + === you can define the HSE value in your toolchain compiler preprocessor. */ + +/* ########################### System Configuration ######################### */ +/** + * @brief This is the HAL system configuration section + */ +#define VDD_VALUE 3300U /*!< Value of VDD in mv */ +#define TICK_INT_PRIORITY 0x0FU /*!< tick interrupt priority */ +#define USE_RTOS 0U +#define PREFETCH_ENABLE 0U +#define INSTRUCTION_CACHE_ENABLE 1U +#define DATA_CACHE_ENABLE 1U + +/* ########################## Assert Selection ############################## */ +/** + * @brief Uncomment the line below to expanse the "assert_param" macro in the + * HAL drivers code + */ +/* #define USE_FULL_ASSERT 1U */ + +/* ################## Register callback feature configuration ############### */ +/** + * @brief Set below the peripheral configuration to "1U" to add the support + * of HAL callback registration/deregistration feature for the HAL + * driver(s). This allows user application to provide specific callback + * functions thanks to HAL_PPP_RegisterCallback() rather than overwriting + * the default weak callback functions (see each stm32l4xx_hal_ppp.h file + * for possible callback identifiers defined in HAL_PPP_CallbackIDTypeDef + * for each PPP peripheral). + */ +#define USE_HAL_ADC_REGISTER_CALLBACKS 0U +#define USE_HAL_CAN_REGISTER_CALLBACKS 0U +#define USE_HAL_COMP_REGISTER_CALLBACKS 0U +#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U +#define USE_HAL_DAC_REGISTER_CALLBACKS 0U +#define USE_HAL_DCMI_REGISTER_CALLBACKS 0U +#define USE_HAL_DFSDM_REGISTER_CALLBACKS 0U +#define USE_HAL_DMA2D_REGISTER_CALLBACKS 0U +#define USE_HAL_DSI_REGISTER_CALLBACKS 0U +#define USE_HAL_GFXMMU_REGISTER_CALLBACKS 0U +#define USE_HAL_HASH_REGISTER_CALLBACKS 0U +#define USE_HAL_HCD_REGISTER_CALLBACKS 0U +#define USE_HAL_I2C_REGISTER_CALLBACKS 0U +#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U +#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U +#define USE_HAL_LTDC_REGISTER_CALLBACKS 0U +#define USE_HAL_MMC_REGISTER_CALLBACKS 0U +#define USE_HAL_OPAMP_REGISTER_CALLBACKS 0U +#define USE_HAL_OSPI_REGISTER_CALLBACKS 0U +#define USE_HAL_PCD_REGISTER_CALLBACKS 0U +#define USE_HAL_QSPI_REGISTER_CALLBACKS 0U +#define USE_HAL_RNG_REGISTER_CALLBACKS 0U +#define USE_HAL_RTC_REGISTER_CALLBACKS 0U +#define USE_HAL_SAI_REGISTER_CALLBACKS 0U +#define USE_HAL_SD_REGISTER_CALLBACKS 0U +#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U +#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U +#define USE_HAL_SPI_REGISTER_CALLBACKS 0U +#define USE_HAL_SWPMI_REGISTER_CALLBACKS 0U +#define USE_HAL_TIM_REGISTER_CALLBACKS 0U +#define USE_HAL_TSC_REGISTER_CALLBACKS 0U +#define USE_HAL_UART_REGISTER_CALLBACKS 0U +#define USE_HAL_USART_REGISTER_CALLBACKS 0U +#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U + +/* ################## SPI peripheral configuration ########################## */ + +/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver + * Activated: CRC code is present inside driver + * Deactivated: CRC code cleaned from driver + */ + +#define USE_SPI_CRC 1U + +/* Includes ------------------------------------------------------------------*/ +/** + * @brief Include module's header file + */ + +#ifdef HAL_RCC_MODULE_ENABLED + #include "stm32l4xx_hal_rcc.h" +#endif /* HAL_RCC_MODULE_ENABLED */ + +#ifdef HAL_GPIO_MODULE_ENABLED + #include "stm32l4xx_hal_gpio.h" +#endif /* HAL_GPIO_MODULE_ENABLED */ + +#ifdef HAL_DMA_MODULE_ENABLED + #include "stm32l4xx_hal_dma.h" +#endif /* HAL_DMA_MODULE_ENABLED */ + +#ifdef HAL_DFSDM_MODULE_ENABLED + #include "stm32l4xx_hal_dfsdm.h" +#endif /* HAL_DFSDM_MODULE_ENABLED */ + +#ifdef HAL_CORTEX_MODULE_ENABLED + #include "stm32l4xx_hal_cortex.h" +#endif /* HAL_CORTEX_MODULE_ENABLED */ + +#ifdef HAL_ADC_MODULE_ENABLED + #include "stm32l4xx_hal_adc.h" +#endif /* HAL_ADC_MODULE_ENABLED */ + +#ifdef HAL_CAN_MODULE_ENABLED + #include "stm32l4xx_hal_can.h" +#endif /* HAL_CAN_MODULE_ENABLED */ + +#ifdef HAL_CAN_LEGACY_MODULE_ENABLED + #include "Legacy/stm32l4xx_hal_can_legacy.h" +#endif /* HAL_CAN_LEGACY_MODULE_ENABLED */ + +#ifdef HAL_COMP_MODULE_ENABLED + #include "stm32l4xx_hal_comp.h" +#endif /* HAL_COMP_MODULE_ENABLED */ + +#ifdef HAL_CRC_MODULE_ENABLED + #include "stm32l4xx_hal_crc.h" +#endif /* HAL_CRC_MODULE_ENABLED */ + +#ifdef HAL_CRYP_MODULE_ENABLED + #include "stm32l4xx_hal_cryp.h" +#endif /* HAL_CRYP_MODULE_ENABLED */ + +#ifdef HAL_DAC_MODULE_ENABLED + #include "stm32l4xx_hal_dac.h" +#endif /* HAL_DAC_MODULE_ENABLED */ + +#ifdef HAL_DCMI_MODULE_ENABLED + #include "stm32l4xx_hal_dcmi.h" +#endif /* HAL_DCMI_MODULE_ENABLED */ + +#ifdef HAL_DMA2D_MODULE_ENABLED + #include "stm32l4xx_hal_dma2d.h" +#endif /* HAL_DMA2D_MODULE_ENABLED */ + +#ifdef HAL_DSI_MODULE_ENABLED + #include "stm32l4xx_hal_dsi.h" +#endif /* HAL_DSI_MODULE_ENABLED */ + +#ifdef HAL_EXTI_MODULE_ENABLED + #include "stm32l4xx_hal_exti.h" +#endif /* HAL_EXTI_MODULE_ENABLED */ + +#ifdef HAL_GFXMMU_MODULE_ENABLED + #include "stm32l4xx_hal_gfxmmu.h" +#endif /* HAL_GFXMMU_MODULE_ENABLED */ + +#ifdef HAL_FIREWALL_MODULE_ENABLED + #include "stm32l4xx_hal_firewall.h" +#endif /* HAL_FIREWALL_MODULE_ENABLED */ + +#ifdef HAL_FLASH_MODULE_ENABLED + #include "stm32l4xx_hal_flash.h" +#endif /* HAL_FLASH_MODULE_ENABLED */ + +#ifdef HAL_HASH_MODULE_ENABLED + #include "stm32l4xx_hal_hash.h" +#endif /* HAL_HASH_MODULE_ENABLED */ + +#ifdef HAL_HCD_MODULE_ENABLED + #include "stm32l4xx_hal_hcd.h" +#endif /* HAL_HCD_MODULE_ENABLED */ + +#ifdef HAL_I2C_MODULE_ENABLED + #include "stm32l4xx_hal_i2c.h" +#endif /* HAL_I2C_MODULE_ENABLED */ + +#ifdef HAL_IRDA_MODULE_ENABLED + #include "stm32l4xx_hal_irda.h" +#endif /* HAL_IRDA_MODULE_ENABLED */ + +#ifdef HAL_IWDG_MODULE_ENABLED + #include "stm32l4xx_hal_iwdg.h" +#endif /* HAL_IWDG_MODULE_ENABLED */ + +#ifdef HAL_LCD_MODULE_ENABLED + #include "stm32l4xx_hal_lcd.h" +#endif /* HAL_LCD_MODULE_ENABLED */ + +#ifdef HAL_LPTIM_MODULE_ENABLED + #include "stm32l4xx_hal_lptim.h" +#endif /* HAL_LPTIM_MODULE_ENABLED */ + +#ifdef HAL_LTDC_MODULE_ENABLED + #include "stm32l4xx_hal_ltdc.h" +#endif /* HAL_LTDC_MODULE_ENABLED */ + +#ifdef HAL_MMC_MODULE_ENABLED + #include "stm32l4xx_hal_mmc.h" +#endif /* HAL_MMC_MODULE_ENABLED */ + +#ifdef HAL_NAND_MODULE_ENABLED + #include "stm32l4xx_hal_nand.h" +#endif /* HAL_NAND_MODULE_ENABLED */ + +#ifdef HAL_NOR_MODULE_ENABLED + #include "stm32l4xx_hal_nor.h" +#endif /* HAL_NOR_MODULE_ENABLED */ + +#ifdef HAL_OPAMP_MODULE_ENABLED + #include "stm32l4xx_hal_opamp.h" +#endif /* HAL_OPAMP_MODULE_ENABLED */ + +#ifdef HAL_OSPI_MODULE_ENABLED + #include "stm32l4xx_hal_ospi.h" +#endif /* HAL_OSPI_MODULE_ENABLED */ + +#ifdef HAL_PCD_MODULE_ENABLED + #include "stm32l4xx_hal_pcd.h" +#endif /* HAL_PCD_MODULE_ENABLED */ + +#ifdef HAL_PWR_MODULE_ENABLED + #include "stm32l4xx_hal_pwr.h" +#endif /* HAL_PWR_MODULE_ENABLED */ + +#ifdef HAL_QSPI_MODULE_ENABLED + #include "stm32l4xx_hal_qspi.h" +#endif /* HAL_QSPI_MODULE_ENABLED */ + +#ifdef HAL_RNG_MODULE_ENABLED + #include "stm32l4xx_hal_rng.h" +#endif /* HAL_RNG_MODULE_ENABLED */ + +#ifdef HAL_RTC_MODULE_ENABLED + #include "stm32l4xx_hal_rtc.h" +#endif /* HAL_RTC_MODULE_ENABLED */ + +#ifdef HAL_SAI_MODULE_ENABLED + #include "stm32l4xx_hal_sai.h" +#endif /* HAL_SAI_MODULE_ENABLED */ + +#ifdef HAL_SD_MODULE_ENABLED + #include "stm32l4xx_hal_sd.h" +#endif /* HAL_SD_MODULE_ENABLED */ + +#ifdef HAL_SMARTCARD_MODULE_ENABLED + #include "stm32l4xx_hal_smartcard.h" +#endif /* HAL_SMARTCARD_MODULE_ENABLED */ + +#ifdef HAL_SMBUS_MODULE_ENABLED + #include "stm32l4xx_hal_smbus.h" +#endif /* HAL_SMBUS_MODULE_ENABLED */ + +#ifdef HAL_SPI_MODULE_ENABLED + #include "stm32l4xx_hal_spi.h" +#endif /* HAL_SPI_MODULE_ENABLED */ + +#ifdef HAL_SRAM_MODULE_ENABLED + #include "stm32l4xx_hal_sram.h" +#endif /* HAL_SRAM_MODULE_ENABLED */ + +#ifdef HAL_SWPMI_MODULE_ENABLED + #include "stm32l4xx_hal_swpmi.h" +#endif /* HAL_SWPMI_MODULE_ENABLED */ + +#ifdef HAL_TIM_MODULE_ENABLED + #include "stm32l4xx_hal_tim.h" +#endif /* HAL_TIM_MODULE_ENABLED */ + +#ifdef HAL_TSC_MODULE_ENABLED + #include "stm32l4xx_hal_tsc.h" +#endif /* HAL_TSC_MODULE_ENABLED */ + +#ifdef HAL_UART_MODULE_ENABLED + #include "stm32l4xx_hal_uart.h" +#endif /* HAL_UART_MODULE_ENABLED */ + +#ifdef HAL_USART_MODULE_ENABLED + #include "stm32l4xx_hal_usart.h" +#endif /* HAL_USART_MODULE_ENABLED */ + +#ifdef HAL_WWDG_MODULE_ENABLED + #include "stm32l4xx_hal_wwdg.h" +#endif /* HAL_WWDG_MODULE_ENABLED */ + +/* Exported macro ------------------------------------------------------------*/ +#ifdef USE_FULL_ASSERT +/** + * @brief The assert_param macro is used for function's parameters check. + * @param expr: If expr is false, it calls assert_failed function + * which reports the name of the source file and the source + * line number of the call that failed. + * If expr is true, it returns no value. + * @retval None + */ + #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) +/* Exported functions ------------------------------------------------------- */ +void assert_failed(uint8_t *file, uint32_t line); +#else + #define assert_param(expr) ((void)0U) +#endif /* USE_FULL_ASSERT */ + +#ifdef __cplusplus +} +#endif + +// CircuitPython specific conditionals. Using a value is better than checking +// defined because undefined variable happen when a file isn't included when it +// should have been. +#define CPY_STM32F4 0 +#define CPY_STM32F7 0 +#define CPY_STM32H7 0 +#define CPY_STM32L4 1 + +#endif /* STM32L4xx_HAL_CONF_H */ + + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/ports/stm/mpconfigport.h b/ports/stm/mpconfigport.h index 4ac8c20eae..94fccd53e9 100644 --- a/ports/stm/mpconfigport.h +++ b/ports/stm/mpconfigport.h @@ -51,6 +51,9 @@ extern uint8_t _ld_default_stack_size; #ifndef BOARD_NO_VBUS_SENSE #define BOARD_NO_VBUS_SENSE (0) #endif +#ifndef BOARD_NO_USB_OTG_ID_SENSE +#define BOARD_NO_USB_OTG_ID_SENSE (0) +#endif // Peripheral implementation counts #define MAX_UART 10 diff --git a/ports/stm/mpconfigport.mk b/ports/stm/mpconfigport.mk index 16c098841c..6729a747b5 100644 --- a/ports/stm/mpconfigport.mk +++ b/ports/stm/mpconfigport.mk @@ -62,4 +62,22 @@ ifeq ($(MCU_SERIES),F7) USB_NUM_ENDPOINT_PAIRS = 6 endif +ifeq ($(MCU_SERIES),L4) + # Not yet implemented common-hal modules: + CIRCUITPY_ANALOGIO ?= 0 + CIRCUITPY_AUDIOBUSIO ?= 0 + CIRCUITPY_AUDIOIO ?= 0 + CIRCUITPY_COUNTIO ?= 0 + CIRCUITPY_FREQUENCYIO ?= 0 + CIRCUITPY_I2CPERIPHERAL ?= 0 + CIRCUITPY_NEOPIXEL_WRITE ?= 0 + CIRCUITPY_NVM ?= 0 + CIRCUITPY_ROTARYIO ?= 0 + CIRCUITPY_RTC ?= 0 + # todo - this varies between devices in the series + # This slide deck https://www.st.com/content/ccc/resource/training/technical/product_training/98/89/c8/6c/3e/e9/49/79/STM32L4_Peripheral_USB.pdf/files/STM32L4_Peripheral_USB.pdf/jcr:content/translations/en.STM32L4_Peripheral_USB.pdf + # cites 16 endpoints, 8 endpoint pairs, while section 3.39 of the L4R5 datasheet states 6 endpoint pairs. + USB_NUM_ENDPOINT_PAIRS = 6 +endif + CIRCUITPY_PARALLELDISPLAY := 0 diff --git a/ports/stm/packages/WLCSP144.c b/ports/stm/packages/WLCSP144.c new file mode 100644 index 0000000000..a08d160863 --- /dev/null +++ b/ports/stm/packages/WLCSP144.c @@ -0,0 +1,159 @@ +#include "shared-bindings/microcontroller/__init__.h" +#include "common-hal/microcontroller/Pin.h" +#include "py/obj.h" + +STATIC const mp_rom_map_elem_t mcu_pin_globals_table[] = { +// Pins 1-36 + { MP_ROM_QSTR(MP_QSTR_PE02), MP_ROM_PTR(&pin_PE02) }, + { MP_ROM_QSTR(MP_QSTR_PE03), MP_ROM_PTR(&pin_PE03) }, + { MP_ROM_QSTR(MP_QSTR_PE04), MP_ROM_PTR(&pin_PE04) }, + { MP_ROM_QSTR(MP_QSTR_PE05), MP_ROM_PTR(&pin_PE05) }, + { MP_ROM_QSTR(MP_QSTR_PE06), MP_ROM_PTR(&pin_PE06) }, + /* VBAT -------------------------------------------*/ + { MP_ROM_QSTR(MP_QSTR_PC13), MP_ROM_PTR(&pin_PC13) }, + // PC14 OSC32_IN ----------------------------------*/ + // PC15 OSC32_OUT ---------------------------------*/ + { MP_ROM_QSTR(MP_QSTR_PF00), MP_ROM_PTR(&pin_PF00) }, + { MP_ROM_QSTR(MP_QSTR_PF01), MP_ROM_PTR(&pin_PF01) }, + { MP_ROM_QSTR(MP_QSTR_PF02), MP_ROM_PTR(&pin_PF02) }, + { MP_ROM_QSTR(MP_QSTR_PF03), MP_ROM_PTR(&pin_PF03) }, + { MP_ROM_QSTR(MP_QSTR_PF04), MP_ROM_PTR(&pin_PF04) }, + { MP_ROM_QSTR(MP_QSTR_PF05), MP_ROM_PTR(&pin_PF05) }, + // VSS --------------------------------------------*/ + // VDD --------------------------------------------*/ + { MP_ROM_QSTR(MP_QSTR_PF06), MP_ROM_PTR(&pin_PF06) }, + { MP_ROM_QSTR(MP_QSTR_PF07), MP_ROM_PTR(&pin_PF07) }, + { MP_ROM_QSTR(MP_QSTR_PF08), MP_ROM_PTR(&pin_PF08) }, + { MP_ROM_QSTR(MP_QSTR_PF09), MP_ROM_PTR(&pin_PF09) }, + { MP_ROM_QSTR(MP_QSTR_PF10), MP_ROM_PTR(&pin_PF10) }, + // PH0 OSC_IN -------------------------------------*/ + // PH1 OSC_OUT ------------------------------------*/ + // NRST -------------------------------------------*/ + { MP_ROM_QSTR(MP_QSTR_PC00), MP_ROM_PTR(&pin_PC00) }, + { MP_ROM_QSTR(MP_QSTR_PC01), MP_ROM_PTR(&pin_PC01) }, + { MP_ROM_QSTR(MP_QSTR_PC02), MP_ROM_PTR(&pin_PC02) }, + { MP_ROM_QSTR(MP_QSTR_PC03), MP_ROM_PTR(&pin_PC03) }, + // VDD --------------------------------------------*/ + // VSSA -------------------------------------------*/ + // VREF+ ------------------------------------------*/ + // VDDA -------------------------------------------*/ + { MP_ROM_QSTR(MP_QSTR_PA00), MP_ROM_PTR(&pin_PA00) }, + { MP_ROM_QSTR(MP_QSTR_PA01), MP_ROM_PTR(&pin_PA01) }, + { MP_ROM_QSTR(MP_QSTR_PA02), MP_ROM_PTR(&pin_PA02) }, + +// Pins 37-72 + { MP_ROM_QSTR(MP_QSTR_PA03), MP_ROM_PTR(&pin_PA03) }, + // VSS --------------------------------------------*/ + // VDD --------------------------------------------*/ + { MP_ROM_QSTR(MP_QSTR_PA04), MP_ROM_PTR(&pin_PA04) }, + { MP_ROM_QSTR(MP_QSTR_PA05), MP_ROM_PTR(&pin_PA05) }, + { MP_ROM_QSTR(MP_QSTR_PA06), MP_ROM_PTR(&pin_PA06) }, + { MP_ROM_QSTR(MP_QSTR_PA07), MP_ROM_PTR(&pin_PA07) }, + { MP_ROM_QSTR(MP_QSTR_PC04), MP_ROM_PTR(&pin_PC04) }, + { MP_ROM_QSTR(MP_QSTR_PC05), MP_ROM_PTR(&pin_PC05) }, + { MP_ROM_QSTR(MP_QSTR_PB00), MP_ROM_PTR(&pin_PB00) }, + { MP_ROM_QSTR(MP_QSTR_PB01), MP_ROM_PTR(&pin_PB01) }, + { MP_ROM_QSTR(MP_QSTR_PB02), MP_ROM_PTR(&pin_PB02) }, + { MP_ROM_QSTR(MP_QSTR_PF11), MP_ROM_PTR(&pin_PF11) }, + { MP_ROM_QSTR(MP_QSTR_PF12), MP_ROM_PTR(&pin_PF12) }, + // VSS --------------------------------------------*/ + // VDD --------------------------------------------*/ + { MP_ROM_QSTR(MP_QSTR_PF13), MP_ROM_PTR(&pin_PF13) }, + { MP_ROM_QSTR(MP_QSTR_PF14), MP_ROM_PTR(&pin_PF14) }, + { MP_ROM_QSTR(MP_QSTR_PF15), MP_ROM_PTR(&pin_PF15) }, + { MP_ROM_QSTR(MP_QSTR_PG00), MP_ROM_PTR(&pin_PG00) }, + { MP_ROM_QSTR(MP_QSTR_PG01), MP_ROM_PTR(&pin_PG01) }, + { MP_ROM_QSTR(MP_QSTR_PE07), MP_ROM_PTR(&pin_PE07) }, + { MP_ROM_QSTR(MP_QSTR_PE08), MP_ROM_PTR(&pin_PE08) }, + { MP_ROM_QSTR(MP_QSTR_PE09), MP_ROM_PTR(&pin_PE09) }, + // VSS --------------------------------------------*/ + // VDD --------------------------------------------*/ + { MP_ROM_QSTR(MP_QSTR_PE10), MP_ROM_PTR(&pin_PE10) }, + { MP_ROM_QSTR(MP_QSTR_PE11), MP_ROM_PTR(&pin_PE11) }, + { MP_ROM_QSTR(MP_QSTR_PE12), MP_ROM_PTR(&pin_PE12) }, + { MP_ROM_QSTR(MP_QSTR_PE13), MP_ROM_PTR(&pin_PE13) }, + { MP_ROM_QSTR(MP_QSTR_PE14), MP_ROM_PTR(&pin_PE14) }, + { MP_ROM_QSTR(MP_QSTR_PE15), MP_ROM_PTR(&pin_PE15) }, + { MP_ROM_QSTR(MP_QSTR_PB10), MP_ROM_PTR(&pin_PB10) }, + { MP_ROM_QSTR(MP_QSTR_PB11), MP_ROM_PTR(&pin_PB11) }, + // VCAP1 ------------------------------------------*/ + // VDD --------------------------------------------*/ + +// Pins 73-108 + { MP_ROM_QSTR(MP_QSTR_PB12), MP_ROM_PTR(&pin_PB12) }, + { MP_ROM_QSTR(MP_QSTR_PB13), MP_ROM_PTR(&pin_PB13) }, + { MP_ROM_QSTR(MP_QSTR_PB14), MP_ROM_PTR(&pin_PB14) }, + { MP_ROM_QSTR(MP_QSTR_PB15), MP_ROM_PTR(&pin_PB15) }, + { MP_ROM_QSTR(MP_QSTR_PD08), MP_ROM_PTR(&pin_PD08) }, + { MP_ROM_QSTR(MP_QSTR_PD09), MP_ROM_PTR(&pin_PD09) }, + { MP_ROM_QSTR(MP_QSTR_PD10), MP_ROM_PTR(&pin_PD10) }, + { MP_ROM_QSTR(MP_QSTR_PD11), MP_ROM_PTR(&pin_PD11) }, + { MP_ROM_QSTR(MP_QSTR_PD12), MP_ROM_PTR(&pin_PD12) }, + { MP_ROM_QSTR(MP_QSTR_PD13), MP_ROM_PTR(&pin_PD13) }, + // VSS --------------------------------------------*/ + // VDD --------------------------------------------*/ + { MP_ROM_QSTR(MP_QSTR_PD14), MP_ROM_PTR(&pin_PD14) }, + { MP_ROM_QSTR(MP_QSTR_PD15), MP_ROM_PTR(&pin_PD15) }, + { MP_ROM_QSTR(MP_QSTR_PG02), MP_ROM_PTR(&pin_PG02) }, + { MP_ROM_QSTR(MP_QSTR_PG03), MP_ROM_PTR(&pin_PG03) }, + { MP_ROM_QSTR(MP_QSTR_PG04), MP_ROM_PTR(&pin_PG04) }, + { MP_ROM_QSTR(MP_QSTR_PG05), MP_ROM_PTR(&pin_PG05) }, + { MP_ROM_QSTR(MP_QSTR_PG06), MP_ROM_PTR(&pin_PG06) }, + { MP_ROM_QSTR(MP_QSTR_PG07), MP_ROM_PTR(&pin_PG07) }, + { MP_ROM_QSTR(MP_QSTR_PG08), MP_ROM_PTR(&pin_PG08) }, + // VSS --------------------------------------------*/ + // VDD or VDD_USB (F412, F446) --------------------*/ + { MP_ROM_QSTR(MP_QSTR_PC06), MP_ROM_PTR(&pin_PC06) }, + { MP_ROM_QSTR(MP_QSTR_PC07), MP_ROM_PTR(&pin_PC07) }, + { MP_ROM_QSTR(MP_QSTR_PC08), MP_ROM_PTR(&pin_PC08) }, + { MP_ROM_QSTR(MP_QSTR_PC09), MP_ROM_PTR(&pin_PC09) }, + { MP_ROM_QSTR(MP_QSTR_PA08), MP_ROM_PTR(&pin_PA08) }, + { MP_ROM_QSTR(MP_QSTR_PA09), MP_ROM_PTR(&pin_PA09) }, + { MP_ROM_QSTR(MP_QSTR_PA10), MP_ROM_PTR(&pin_PA10) }, + { MP_ROM_QSTR(MP_QSTR_PA11), MP_ROM_PTR(&pin_PA11) }, + { MP_ROM_QSTR(MP_QSTR_PA12), MP_ROM_PTR(&pin_PA12) }, + { MP_ROM_QSTR(MP_QSTR_PA13), MP_ROM_PTR(&pin_PA13) }, + // VCAP2 ------------------------------------------*/ + // VSS --------------------------------------------*/ + // VDD --------------------------------------------*/ + +// Pins 109-144 + { MP_ROM_QSTR(MP_QSTR_PA14), MP_ROM_PTR(&pin_PA14) }, + { MP_ROM_QSTR(MP_QSTR_PA15), MP_ROM_PTR(&pin_PA15) }, + { MP_ROM_QSTR(MP_QSTR_PC10), MP_ROM_PTR(&pin_PC10) }, + { MP_ROM_QSTR(MP_QSTR_PC11), MP_ROM_PTR(&pin_PC11) }, + { MP_ROM_QSTR(MP_QSTR_PC12), MP_ROM_PTR(&pin_PC12) }, + { MP_ROM_QSTR(MP_QSTR_PD00), MP_ROM_PTR(&pin_PD00) }, + { MP_ROM_QSTR(MP_QSTR_PD01), MP_ROM_PTR(&pin_PD01) }, + { MP_ROM_QSTR(MP_QSTR_PD02), MP_ROM_PTR(&pin_PD02) }, + { MP_ROM_QSTR(MP_QSTR_PD03), MP_ROM_PTR(&pin_PD03) }, + { MP_ROM_QSTR(MP_QSTR_PD04), MP_ROM_PTR(&pin_PD04) }, + { MP_ROM_QSTR(MP_QSTR_PD05), MP_ROM_PTR(&pin_PD05) }, + // VSS --------------------------------------------*/ + // VDD --------------------------------------------*/ + { MP_ROM_QSTR(MP_QSTR_PD06), MP_ROM_PTR(&pin_PD06) }, + { MP_ROM_QSTR(MP_QSTR_PD07), MP_ROM_PTR(&pin_PD07) }, + { MP_ROM_QSTR(MP_QSTR_PG09), MP_ROM_PTR(&pin_PG09) }, + { MP_ROM_QSTR(MP_QSTR_PG10), MP_ROM_PTR(&pin_PG10) }, + { MP_ROM_QSTR(MP_QSTR_PG11), MP_ROM_PTR(&pin_PG11) }, + { MP_ROM_QSTR(MP_QSTR_PG12), MP_ROM_PTR(&pin_PG12) }, + { MP_ROM_QSTR(MP_QSTR_PG13), MP_ROM_PTR(&pin_PG13) }, + { MP_ROM_QSTR(MP_QSTR_PG14), MP_ROM_PTR(&pin_PG14) }, + // VSS --------------------------------------------*/ + // VDD --------------------------------------------*/ + { MP_ROM_QSTR(MP_QSTR_PG15), MP_ROM_PTR(&pin_PG15) }, + { MP_ROM_QSTR(MP_QSTR_PB03), MP_ROM_PTR(&pin_PB03) }, + { MP_ROM_QSTR(MP_QSTR_PB04), MP_ROM_PTR(&pin_PB04) }, + { MP_ROM_QSTR(MP_QSTR_PB05), MP_ROM_PTR(&pin_PB05) }, + { MP_ROM_QSTR(MP_QSTR_PB06), MP_ROM_PTR(&pin_PB06) }, + { MP_ROM_QSTR(MP_QSTR_PB07), MP_ROM_PTR(&pin_PB07) }, + // BOOT0 ------------------------------------------*/ + { MP_ROM_QSTR(MP_QSTR_PB08), MP_ROM_PTR(&pin_PB08) }, + { MP_ROM_QSTR(MP_QSTR_PB09), MP_ROM_PTR(&pin_PB09) }, + { MP_ROM_QSTR(MP_QSTR_PE00), MP_ROM_PTR(&pin_PE00) }, + { MP_ROM_QSTR(MP_QSTR_PE01), MP_ROM_PTR(&pin_PE01) }, + // PDR_ON -----------------------------------------*/ + // VDD --------------------------------------------*/ + +}; +MP_DEFINE_CONST_DICT(mcu_pin_globals, mcu_pin_globals_table); diff --git a/ports/stm/peripherals/exti.c b/ports/stm/peripherals/exti.c index 3ba943a208..a161898491 100644 --- a/ports/stm/peripherals/exti.c +++ b/ports/stm/peripherals/exti.c @@ -123,6 +123,9 @@ void EXTI4_IRQHandler(void) { stm_exti_callback[4](4); } +#ifdef STM32L4 +#define PR PR1 +#endif void EXTI9_5_IRQHandler(void) { uint32_t pending = EXTI->PR; for (uint i = 5; i <= 9; i++) { @@ -140,5 +143,9 @@ void EXTI15_10_IRQHandler(void) { } } } +#ifdef STM32L4 +#undef PR +#endif + #endif diff --git a/ports/stm/peripherals/periph.h b/ports/stm/peripherals/periph.h index d9e65c2172..3957eb5280 100644 --- a/ports/stm/peripherals/periph.h +++ b/ports/stm/peripherals/periph.h @@ -91,6 +91,13 @@ typedef struct { // Foundation Lines +#ifdef STM32L4R5xx +#define HAS_DAC 1 +#define HAS_TRNG 1 +#define HAS_BASIC_TIM 1 +#include "stm32l4/stm32l4r5xx/periph.h" +#endif + #ifdef STM32F405xx #define HAS_DAC 1 #define HAS_TRNG 1 diff --git a/ports/stm/peripherals/pins.h b/ports/stm/peripherals/pins.h index 4a516864b0..5a808e00ea 100644 --- a/ports/stm/peripherals/pins.h +++ b/ports/stm/peripherals/pins.h @@ -85,6 +85,9 @@ extern const mp_obj_type_t mcu_pin_type; #ifdef STM32F412Zx #include "stm32f4/stm32f412zx/pins.h" #endif +#ifdef STM32L4R5xx +#include "stm32l4/stm32l4r5xx/pins.h" +#endif #ifdef STM32F405xx #include "stm32f4/stm32f405xx/pins.h" #endif diff --git a/ports/stm/peripherals/rtc.c b/ports/stm/peripherals/rtc.c index 5f8f05b2bf..13cda1aac8 100644 --- a/ports/stm/peripherals/rtc.c +++ b/ports/stm/peripherals/rtc.c @@ -31,7 +31,7 @@ #include "py/gc.h" #include "py/obj.h" #include "py/runtime.h" -#include "lib/timeutils/timeutils.h" +#include "shared/timeutils/timeutils.h" // Default period for ticks is 1/1024 second #define TICK_DIVISOR 1024 diff --git a/ports/stm/peripherals/stm32l4/clocks.c b/ports/stm/peripherals/stm32l4/clocks.c new file mode 100644 index 0000000000..4419f751d4 --- /dev/null +++ b/ports/stm/peripherals/stm32l4/clocks.c @@ -0,0 +1,110 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Blues Wireless Contributors + * + * 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 "stm32l4xx_hal.h" +#include "supervisor/shared/safe_mode.h" +#include + +// L4 Series +#ifdef STM32L4R5xx +#include "stm32l4/stm32l4r5xx/clocks.h" +#else +#error Please add other MCUs here so that they are not silently ignored due to #define typos +#endif + +#if BOARD_HAS_HIGH_SPEED_CRYSTAL +#error HSE support needs to be added for the L4 family. +#elif !BOARD_HAS_LOW_SPEED_CRYSTAL + #error LSE clock source required +#endif + +void Error_Handler(void) { + for (;;) { + + } +} + +#define HAL_CHECK(x) if (x != HAL_OK) Error_Handler() + +void stm32_peripherals_clocks_init(void) { + + RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; + RCC_OscInitTypeDef RCC_OscInitStruct = {0}; + RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; + + // Configure LSE Drive + HAL_PWR_EnableBkUpAccess(); + __HAL_RCC_LSEDRIVE_CONFIG(RCC_LSEDRIVE_LOW); + __HAL_RCC_PWR_CLK_ENABLE(); + + /** Configure the main internal regulator output voltage + */ + if (HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1_BOOST) != HAL_OK) { + Error_Handler(); + } + + + /* Activate PLL with MSI , stabilizied via PLL by LSE */ + RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSE | RCC_OSCILLATORTYPE_MSI; + RCC_OscInitStruct.MSIState = RCC_MSI_ON; + RCC_OscInitStruct.LSEState = RCC_LSE_ON; + RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_11; + RCC_OscInitStruct.MSICalibrationValue = RCC_MSICALIBRATION_DEFAULT; + RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; + RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_MSI; + RCC_OscInitStruct.PLL.PLLM = 6; + RCC_OscInitStruct.PLL.PLLN = 30; + RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV5; + RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV2; + RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV2; + HAL_CHECK(HAL_RCC_OscConfig(&RCC_OscInitStruct)); + + /* Enable MSI Auto-calibration through LSE */ + HAL_RCCEx_EnableMSIPLLMode(); + + /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 + clocks dividers */ + RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2); + RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; + // Avoid overshoot and start with HCLK 60 MHz + RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; + RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; + RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; + HAL_CHECK(HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_3)); + + /* AHB prescaler divider at 1 as second step */ + RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK; + RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; + HAL_CHECK(HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5)); + + /* Select MSI output as USB clock source */ + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_USB | RCC_PERIPHCLK_RTC | RCC_PERIPHCLK_ADC; + PeriphClkInitStruct.UsbClockSelection = RCC_USBCLKSOURCE_MSI; + PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSE; + PeriphClkInitStruct.AdcClockSelection = RCC_ADCCLKSOURCE_SYSCLK; + HAL_CHECK(HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct)); + +} diff --git a/ports/stm/peripherals/stm32l4/stm32l4r5xx/clocks.h b/ports/stm/peripherals/stm32l4/stm32l4r5xx/clocks.h new file mode 100644 index 0000000000..ef4a866c68 --- /dev/null +++ b/ports/stm/peripherals/stm32l4/stm32l4r5xx/clocks.h @@ -0,0 +1,67 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Blues Wireless Contributors + * + * 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 "stm32l4xx_hal.h" + +// Chip: STM32L4R5 +// Line Type: Foundation Line +// Speed: 120MHz (MAX) + +// Defaults: +#ifndef CPY_CLK_VSCALE +#define CPY_CLK_VSCALE (PWR_REGULATOR_VOLTAGE_SCALE1_BOOST) // up to 120MHz +#endif +#ifndef CPY_CLK_PLLM +#define CPY_CLK_PLLM (12) +#endif +#ifndef CPY_CLK_PLLN +#define CPY_CLK_PLLN (60) +#endif +#ifndef CPY_CLK_PLLP +#define CPY_CLK_PLLP (RCC_PLLP_DIV2) +#endif +#ifndef CPY_CLK_PLLQ +#define CPY_CLK_PLLQ (2) +#endif +#ifndef CPY_CLK_AHBDIV +#define CPY_CLK_AHBDIV (RCC_SYSCLK_DIV1) +#endif +#ifndef CPY_CLK_APB1DIV +#define CPY_CLK_APB1DIV (RCC_HCLK_DIV1) +#endif +#ifndef CPY_CLK_APB2DIV +#define CPY_CLK_APB2DIV (RCC_HCLK_DIV1) +#endif +#ifndef CPY_CLK_FLASH_LATENCY +#define CPY_CLK_FLASH_LATENCY (FLASH_LATENCY_5) +#endif +#ifndef CPY_CLK_USB_USES_AUDIOPLL +#define CPY_CLK_USB_USES_AUDIOPLL (0) +#endif + +#ifndef BOARD_HAS_HIGH_SPEED_CRYSTAL +#define BOARD_HAS_HIGH_SPEED_CRYSTAL (1) +#endif diff --git a/ports/stm/peripherals/stm32l4/stm32l4r5xx/gpio.c b/ports/stm/peripherals/stm32l4/stm32l4r5xx/gpio.c new file mode 100644 index 0000000000..e8b805dcec --- /dev/null +++ b/ports/stm/peripherals/stm32l4/stm32l4r5xx/gpio.c @@ -0,0 +1,60 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Blues Wireless Contributors + * + * 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 "peripherals/gpio.h" +#include "common-hal/microcontroller/Pin.h" + +void stm32_peripherals_gpio_init(void) { + // Enable all GPIO for now + __HAL_RCC_GPIOA_CLK_ENABLE(); + __HAL_RCC_GPIOB_CLK_ENABLE(); + __HAL_RCC_GPIOC_CLK_ENABLE(); + __HAL_RCC_GPIOD_CLK_ENABLE(); + __HAL_RCC_GPIOE_CLK_ENABLE(); + __HAL_RCC_GPIOF_CLK_ENABLE(); + __HAL_RCC_GPIOG_CLK_ENABLE(); + + // These ports are not used on the Swan R5 but may need to be enabeld on other boards + // __HAL_RCC_GPIOH_CLK_ENABLE(); + // __HAL_RCC_GPIOI_CLK_ENABLE(); + + // Never reset pins + never_reset_pin_number(2,14); // PC14 OSC32_IN + never_reset_pin_number(2,15); // PC15 OSC32_OUT + never_reset_pin_number(0,13); // PA13 SWDIO + never_reset_pin_number(0,14); // PA14 SWCLK + // never_reset_pin_number(0,15); //PA15 JTDI + // never_reset_pin_number(1,3); //PB3 JTDO + // never_reset_pin_number(1,4); //PB4 JTRST + + // Port H is not included in GPIO port array + // never_reset_pin_number(5,0); //PH0 JTDO + // never_reset_pin_number(5,1); //PH1 JTRST +} + +void stm32l4_peripherals_status_led(uint8_t led, uint8_t state) { + +} diff --git a/ports/stm/peripherals/stm32l4/stm32l4r5xx/periph.c b/ports/stm/peripherals/stm32l4/stm32l4r5xx/periph.c new file mode 100644 index 0000000000..32da56f222 --- /dev/null +++ b/ports/stm/peripherals/stm32l4/stm32l4r5xx/periph.c @@ -0,0 +1,283 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Blues Wireless Contributors + * + * 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/mphal.h" +#include "peripherals/pins.h" +#include "peripherals/periph.h" + +I2C_TypeDef *mcu_i2c_banks[I2C_BANK_ARRAY_LEN] = {I2C1, I2C2, I2C3, I2C4}; + +const mcu_periph_obj_t mcu_i2c_sda_list[I2C_SDA_ARRAY_LEN] = { + PERIPH(3, 4, &pin_PB04), + PERIPH(1, 4, &pin_PB07), + PERIPH(4, 5, &pin_PB07), + PERIPH(1, 4, &pin_PB09), + PERIPH(4, 3, &pin_PB11), + PERIPH(2, 4, &pin_PB11), + PERIPH(2, 4, &pin_PB14), + PERIPH(3, 4, &pin_PC01), + PERIPH(3, 6, &pin_PC09), + PERIPH(4, 4, &pin_PD13), + PERIPH(2, 4, &pin_PF00), + PERIPH(4, 4, &pin_PF15), + PERIPH(3, 4, &pin_PG08), + PERIPH(1, 4, &pin_PG13), + PERIPH(2, 4, &pin_PH05), + PERIPH(3, 4, &pin_PH08), +}; + +const mcu_periph_obj_t mcu_i2c_scl_list[I2C_SCL_ARRAY_LEN] = { + PERIPH(1, 4, &pin_PB06), + PERIPH(1, 4, &pin_PG14), + PERIPH(3, 4, &pin_PA07), + PERIPH(4, 5, &pin_PB06), + PERIPH(1, 4, &pin_PB08), + PERIPH(4, 3, &pin_PB10), + PERIPH(2, 4, &pin_PB10), + PERIPH(2, 4, &pin_PB13), + PERIPH(3, 4, &pin_PC00), + PERIPH(4, 4, &pin_PD12), + PERIPH(2, 4, &pin_PF01), + PERIPH(4, 4, &pin_PF14), + PERIPH(3, 4, &pin_PG07), + PERIPH(2, 4, &pin_PH04), + PERIPH(3, 4, &pin_PH07), +}; + +SPI_TypeDef *mcu_spi_banks[SPI_BANK_ARRAY_LEN] = {SPI1, SPI2, SPI3}; + +const mcu_periph_obj_t mcu_spi_sck_list[SPI_SCK_ARRAY_LEN] = { + PERIPH(1, 5, &pin_PA01), + PERIPH(1, 5, &pin_PA05), + PERIPH(2, 3, &pin_PA09), + PERIPH(1, 5, &pin_PB03), + PERIPH(3, 6, &pin_PB03), + PERIPH(2, 5, &pin_PB10), + PERIPH(2, 5, &pin_PB13), + PERIPH(3, 6, &pin_PC10), + PERIPH(2, 5, &pin_PD01), + PERIPH(2, 3, &pin_PD03), + PERIPH(1, 5, &pin_PE13), + PERIPH(1, 5, &pin_PG02), + PERIPH(3, 6, &pin_PG09), + PERIPH(2, 5, &pin_PI01), +}; +const mcu_periph_obj_t mcu_spi_mosi_list[SPI_MOSI_ARRAY_LEN] = { + PERIPH(1, 5, &pin_PA07), + PERIPH(1, 5, &pin_PA12), + PERIPH(1, 5, &pin_PB05), + PERIPH(3, 6, &pin_PB05), + PERIPH(2, 5, &pin_PB15), + PERIPH(2, 3, &pin_PC01), + PERIPH(2, 5, &pin_PC03), + PERIPH(3, 6, &pin_PC12), + PERIPH(2, 5, &pin_PD04), + PERIPH(3, 5, &pin_PD06), + PERIPH(1, 5, &pin_PE15), + PERIPH(1, 5, &pin_PG04), + PERIPH(3, 6, &pin_PG11), + PERIPH(2, 5, &pin_PI03), +}; +const mcu_periph_obj_t mcu_spi_miso_list[SPI_MISO_ARRAY_LEN] = { + PERIPH(1, 5, &pin_PA06), + PERIPH(1, 5, &pin_PA11), + PERIPH(1, 5, &pin_PB04), + PERIPH(3, 6, &pin_PB04), + PERIPH(2, 5, &pin_PB14), + PERIPH(2, 5, &pin_PC02), + PERIPH(3, 6, &pin_PC11), + PERIPH(2, 5, &pin_PD03), + PERIPH(1, 5, &pin_PE14), + PERIPH(1, 5, &pin_PG03), + PERIPH(3, 6, &pin_PG10), + PERIPH(2, 5, &pin_PI02), +}; +const mcu_periph_obj_t mcu_spi_nss_list[SPI_NSS_ARRAY_LEN] = { + PERIPH(1, 5, &pin_PA04), + PERIPH(3, 6, &pin_PA04), + PERIPH(1, 5, &pin_PA15), + PERIPH(3, 6, &pin_PA15), + PERIPH(1, 5, &pin_PB00), + PERIPH(2, 5, &pin_PB09), + PERIPH(2, 5, &pin_PB12), + PERIPH(2, 5, &pin_PD00), + PERIPH(1, 5, &pin_PE12), + PERIPH(1, 5, &pin_PG05), + PERIPH(3, 6, &pin_PG12), + PERIPH(2, 5, &pin_PI00), +}; + +// todo - add LPUART? +USART_TypeDef *mcu_uart_banks[MAX_UART] = {USART1, USART2, USART3, UART4, UART5}; +bool mcu_uart_has_usart[MAX_UART] = {true, true, true, false, false}; + +const mcu_periph_obj_t mcu_uart_tx_list[UART_TX_ARRAY_LEN] = { + PERIPH(4, 9, &pin_PA00), + PERIPH(2, 7, &pin_PA02), + PERIPH(1, 7, &pin_PA09), + PERIPH(1, 7, &pin_PB06), + PERIPH(3, 7, &pin_PB10), + PERIPH(3, 7, &pin_PC04), + PERIPH(3, 7, &pin_PC10), + PERIPH(4, 9, &pin_PC10), + PERIPH(5, 9, &pin_PC12), + PERIPH(2, 7, &pin_PD05), + PERIPH(3, 7, &pin_PD08), + PERIPH(1, 7, &pin_PG09), +}; +const mcu_periph_obj_t mcu_uart_rx_list[UART_RX_ARRAY_LEN] = { + PERIPH(4, 9, &pin_PA01), + PERIPH(2, 7, &pin_PA03), + PERIPH(1, 7, &pin_PA10), + PERIPH(2, 3, &pin_PA15), + PERIPH(1, 7, &pin_PB07), + PERIPH(3, 7, &pin_PB11), + PERIPH(3, 7, &pin_PC05), + PERIPH(3, 7, &pin_PC11), + PERIPH(4, 9, &pin_PC11), + PERIPH(5, 9, &pin_PD02), + PERIPH(2, 7, &pin_PD06), + PERIPH(3, 7, &pin_PD09), + PERIPH(1, 7, &pin_PG10), +}; + +// Timers +// TIM6 and TIM7 are basic timers that are only used by DAC, and don't have pins +TIM_TypeDef *mcu_tim_banks[TIM_BANK_ARRAY_LEN] = {TIM1, TIM2, TIM3, TIM4, TIM5, NULL, NULL, TIM8, /*TIM9*/ NULL, NULL, NULL, NULL, NULL, NULL, TIM15, TIM16, TIM17}; + +const mcu_tim_pin_obj_t mcu_tim_pin_list[TIM_PIN_ARRAY_LEN] = { + TIM(2, 1, 1, &pin_PA00), + TIM(5, 2, 1, &pin_PA00), + TIM(2, 1, 2, &pin_PA01), + TIM(5, 2, 2, &pin_PA01), + TIM(2, 1, 3, &pin_PA02), + TIM(5, 2, 3, &pin_PA02), + TIM(15, 15, 1, &pin_PA02), + TIM(2, 1, 4, &pin_PA03), + TIM(5, 2, 4, &pin_PA03), + TIM(15, 15, 2, &pin_PA03), + TIM(2, 1, 1, &pin_PA05), + TIM(3, 2, 1, &pin_PA06), + TIM(16, 15, 1, &pin_PA06), + TIM(3, 2, 2, &pin_PA07), + // TIM(17, 15, 1, &pin_PA07), // peripheral indices are 1 based, stored 0-based with 4 bits available. + TIM(1, 1, 1, &pin_PA08), + TIM(1, 1, 2, &pin_PA09), + TIM(1, 1, 3, &pin_PA10), + TIM(1, 1, 4, &pin_PA11), + TIM(2, 1, 1, &pin_PA15), + TIM(3, 2, 3, &pin_PB00), + TIM(3, 2, 4, &pin_PB01), + TIM(2, 1, 2, &pin_PB03), + TIM(3, 2, 1, &pin_PB04), + TIM(3, 2, 2, &pin_PB05), + TIM(4, 2, 1, &pin_PB06), + TIM(4, 2, 2, &pin_PB07), + TIM(4, 2, 3, &pin_PB08), + TIM(16, 15, 1, &pin_PB08), + TIM(4, 2, 4, &pin_PB09), + // TIM(17, 15, 1, &pin_PB09), // peripheral indices are 1 based, stored 0-based with 4 bits available. + TIM(2, 1, 3, &pin_PB10), + TIM(2, 1, 4, &pin_PB11), + TIM(15, 15, 1, &pin_PB14), + TIM(15, 15, 2, &pin_PB15), + TIM(3, 2, 1, &pin_PC06), + TIM(8, 3, 1, &pin_PC06), + TIM(3, 2, 2, &pin_PC07), + TIM(8, 3, 2, &pin_PC07), + TIM(3, 2, 3, &pin_PC08), + TIM(8, 3, 3, &pin_PC08), + TIM(3, 2, 4, &pin_PC09), + TIM(8, 3, 4, &pin_PC09), + TIM(4, 2, 1, &pin_PD12), + TIM(4, 2, 2, &pin_PD13), + TIM(4, 2, 3, &pin_PD14), + TIM(4, 2, 4, &pin_PD15), + TIM(16, 15, 1, &pin_PE00), + // TIM(17, 15, 1, &pin_PE01), // peripheral indices are 1 based, stored 0-based with 4 bits available. + TIM(3, 2, 1, &pin_PE03), + TIM(3, 2, 2, &pin_PE04), + TIM(3, 2, 3, &pin_PE05), + TIM(3, 2, 4, &pin_PE06), + TIM(1, 1, 1, &pin_PE09), + TIM(1, 1, 2, &pin_PE11), + TIM(1, 1, 3, &pin_PE13), + TIM(1, 1, 4, &pin_PE14), + TIM(5, 2, 1, &pin_PF06), + TIM(5, 2, 2, &pin_PF07), + TIM(5, 2, 3, &pin_PF08), + TIM(5, 2, 4, &pin_PF09), + TIM(15, 15, 1, &pin_PF09), + TIM(15, 15, 2, &pin_PF10), + TIM(15, 15, 1, &pin_PG10), + TIM(15, 15, 2, &pin_PG11), + TIM(5, 2, 1, &pin_PH10), + TIM(5, 2, 2, &pin_PH11), + TIM(5, 2, 3, &pin_PH12), + TIM(5, 2, 4, &pin_PI00), + TIM(8, 3, 4, &pin_PI02), + TIM(8, 3, 1, &pin_PI05), + TIM(8, 3, 2, &pin_PI06), + TIM(8, 3, 3, &pin_PI07), +}; +// SDIO +// SDIO_TypeDef *mcu_sdio_banks[1] = {SDIO}; +// todo - the L4 has a SDMMC pripheral +const mcu_periph_obj_t mcu_sdio_clock_list[1] = { + PERIPH(1, 12, &pin_PC12), +}; +const mcu_periph_obj_t mcu_sdio_command_list[1] = { + PERIPH(1, 12, &pin_PD02), +}; +const mcu_periph_obj_t mcu_sdio_data0_list[1] = { + PERIPH(1, 12, &pin_PC08), +}; +const mcu_periph_obj_t mcu_sdio_data1_list[1] = { + PERIPH(1, 12, &pin_PC09), +}; +const mcu_periph_obj_t mcu_sdio_data2_list[1] = { + PERIPH(1, 12, &pin_PC10), +}; +const mcu_periph_obj_t mcu_sdio_data3_list[1] = { + PERIPH(1, 12, &pin_PC11), +}; + +// CAN +CAN_TypeDef *mcu_can_banks[] = {CAN1}; + +const mcu_periph_obj_t mcu_can_tx_list[4] = { + PERIPH(1, 10, &pin_PA12), + PERIPH(1, 10, &pin_PB09), + PERIPH(1, 10, &pin_PD01), + PERIPH(1, 10, &pin_PH13), +}; +const mcu_periph_obj_t mcu_can_rx_list[4] = { + PERIPH(1, 10, &pin_PA11), + PERIPH(1, 10, &pin_PB08), + PERIPH(1, 10, &pin_PD00), + PERIPH(1, 10, &pin_PI09), +}; diff --git a/ports/stm/peripherals/stm32l4/stm32l4r5xx/periph.h b/ports/stm/peripherals/stm32l4/stm32l4r5xx/periph.h new file mode 100644 index 0000000000..d28b6c8ea3 --- /dev/null +++ b/ports/stm/peripherals/stm32l4/stm32l4r5xx/periph.h @@ -0,0 +1,80 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Blues Wireless Contributors + * + * 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_STM32_PERIPHERALS_STM32L4R5XX_PERIPH_H +#define MICROPY_INCLUDED_STM32_PERIPHERALS_STM32L4R5XX_PERIPH_H + +// I2C +#define I2C_BANK_ARRAY_LEN 4 +#define I2C_SDA_ARRAY_LEN 16 +#define I2C_SCL_ARRAY_LEN 15 +extern I2C_TypeDef *mcu_i2c_banks[I2C_BANK_ARRAY_LEN]; +extern const mcu_periph_obj_t mcu_i2c_sda_list[I2C_SDA_ARRAY_LEN]; +extern const mcu_periph_obj_t mcu_i2c_scl_list[I2C_SCL_ARRAY_LEN]; + +// SPI +#define SPI_BANK_ARRAY_LEN 3 +#define SPI_SCK_ARRAY_LEN 14 +#define SPI_MOSI_ARRAY_LEN 14 +#define SPI_MISO_ARRAY_LEN 12 +#define SPI_NSS_ARRAY_LEN 12 +extern SPI_TypeDef *mcu_spi_banks[SPI_BANK_ARRAY_LEN]; +extern const mcu_periph_obj_t mcu_spi_sck_list[SPI_SCK_ARRAY_LEN]; +extern const mcu_periph_obj_t mcu_spi_mosi_list[SPI_MOSI_ARRAY_LEN]; +extern const mcu_periph_obj_t mcu_spi_miso_list[SPI_MISO_ARRAY_LEN]; +extern const mcu_periph_obj_t mcu_spi_nss_list[SPI_NSS_ARRAY_LEN]; + +// UART +#define UART_TX_ARRAY_LEN 12 +#define UART_RX_ARRAY_LEN 13 +extern USART_TypeDef *mcu_uart_banks[MAX_UART]; +extern bool mcu_uart_has_usart[MAX_UART]; +extern const mcu_periph_obj_t mcu_uart_tx_list[UART_TX_ARRAY_LEN]; +extern const mcu_periph_obj_t mcu_uart_rx_list[UART_RX_ARRAY_LEN]; + +// Timers +#define TIM_BANK_ARRAY_LEN 17 +#define TIM_PIN_ARRAY_LEN (73 - 3) +extern TIM_TypeDef *mcu_tim_banks[TIM_BANK_ARRAY_LEN]; +extern const mcu_tim_pin_obj_t mcu_tim_pin_list[TIM_PIN_ARRAY_LEN]; + +// SDIO +// extern SDIO_TypeDef *mcu_sdio_banks[1]; + +// extern const mcu_periph_obj_t mcu_sdio_clock_list[1]; +// extern const mcu_periph_obj_t mcu_sdio_command_list[1]; +// extern const mcu_periph_obj_t mcu_sdio_data0_list[1]; +// extern const mcu_periph_obj_t mcu_sdio_data1_list[1]; +// extern const mcu_periph_obj_t mcu_sdio_data2_list[1]; +// extern const mcu_periph_obj_t mcu_sdio_data3_list[1]; + +// CAN +extern CAN_TypeDef *mcu_can_banks[1]; +extern const mcu_periph_obj_t mcu_can_tx_list[4]; +extern const mcu_periph_obj_t mcu_can_rx_list[4]; + + +#endif // MICROPY_INCLUDED_STM32_PERIPHERALS_STM32L4R5XX_PERIPH_H diff --git a/ports/stm/peripherals/stm32l4/stm32l4r5xx/pins.c b/ports/stm/peripherals/stm32l4/stm32l4r5xx/pins.c new file mode 100644 index 0000000000..e6ef178c52 --- /dev/null +++ b/ports/stm/peripherals/stm32l4/stm32l4r5xx/pins.c @@ -0,0 +1,172 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Blues Wireless Contributors + * + * 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/mphal.h" +#include "peripherals/pins.h" + +#include STM32_HAL_H + +const mcu_pin_obj_t pin_PA00 = PIN(0, 0, ADC_INPUT(ADC_1,5)); +const mcu_pin_obj_t pin_PA01 = PIN(0, 1, ADC_INPUT(ADC_1,6)); +const mcu_pin_obj_t pin_PA02 = PIN(0, 2, ADC_INPUT(ADC_1,7)); +const mcu_pin_obj_t pin_PA03 = PIN(0, 3, ADC_INPUT(ADC_1,8)); +const mcu_pin_obj_t pin_PA04 = PIN(0, 4, ADC_INPUT(ADC_1,9)); +const mcu_pin_obj_t pin_PA05 = PIN(0, 5, ADC_INPUT(ADC_1,10)); +const mcu_pin_obj_t pin_PA06 = PIN(0, 6, ADC_INPUT(ADC_1,11)); +const mcu_pin_obj_t pin_PA07 = PIN(0, 7, ADC_INPUT(ADC_1,12)); +const mcu_pin_obj_t pin_PA08 = PIN(0, 8, NO_ADC); +const mcu_pin_obj_t pin_PA09 = PIN(0, 9, NO_ADC); +const mcu_pin_obj_t pin_PA10 = PIN(0, 10, NO_ADC); +const mcu_pin_obj_t pin_PA11 = PIN(0, 11, NO_ADC); +const mcu_pin_obj_t pin_PA12 = PIN(0, 12, NO_ADC); +const mcu_pin_obj_t pin_PA13 = PIN(0, 13, NO_ADC); +const mcu_pin_obj_t pin_PA14 = PIN(0, 14, NO_ADC); +const mcu_pin_obj_t pin_PA15 = PIN(0, 15, NO_ADC); +const mcu_pin_obj_t pin_PB00 = PIN(1, 0, ADC_INPUT(ADC_1,15)); +const mcu_pin_obj_t pin_PB01 = PIN(1, 1, ADC_INPUT(ADC_1,16)); +const mcu_pin_obj_t pin_PB02 = PIN(1, 2, NO_ADC); +const mcu_pin_obj_t pin_PB03 = PIN(1, 3, NO_ADC); +const mcu_pin_obj_t pin_PB04 = PIN(1, 4, NO_ADC); +const mcu_pin_obj_t pin_PB05 = PIN(1, 5, NO_ADC); +const mcu_pin_obj_t pin_PB06 = PIN(1, 6, NO_ADC); +const mcu_pin_obj_t pin_PB07 = PIN(1, 7, NO_ADC); +const mcu_pin_obj_t pin_PB08 = PIN(1, 8, NO_ADC); +const mcu_pin_obj_t pin_PB09 = PIN(1, 9, NO_ADC); +const mcu_pin_obj_t pin_PB10 = PIN(1, 10, NO_ADC); +const mcu_pin_obj_t pin_PB11 = PIN(1, 11, NO_ADC); +const mcu_pin_obj_t pin_PB12 = PIN(1, 12, NO_ADC); +const mcu_pin_obj_t pin_PB13 = PIN(1, 13, NO_ADC); +const mcu_pin_obj_t pin_PB14 = PIN(1, 14, NO_ADC); +const mcu_pin_obj_t pin_PB15 = PIN(1, 15, NO_ADC); +const mcu_pin_obj_t pin_PC00 = PIN(2, 0, ADC_INPUT(ADC_1,1)); +const mcu_pin_obj_t pin_PC01 = PIN(2, 1, ADC_INPUT(ADC_1,2)); +const mcu_pin_obj_t pin_PC02 = PIN(2, 2, ADC_INPUT(ADC_1,3)); +const mcu_pin_obj_t pin_PC03 = PIN(2, 3, ADC_INPUT(ADC_1,4)); +const mcu_pin_obj_t pin_PC04 = PIN(2, 4, ADC_INPUT(ADC_1,13)); +const mcu_pin_obj_t pin_PC05 = PIN(2, 5, ADC_INPUT(ADC_1,14)); +const mcu_pin_obj_t pin_PC06 = PIN(2, 6, NO_ADC); +const mcu_pin_obj_t pin_PC07 = PIN(2, 7, NO_ADC); +const mcu_pin_obj_t pin_PC08 = PIN(2, 8, NO_ADC); +const mcu_pin_obj_t pin_PC09 = PIN(2, 9, NO_ADC); +const mcu_pin_obj_t pin_PC10 = PIN(2, 10, NO_ADC); +const mcu_pin_obj_t pin_PC11 = PIN(2, 11, NO_ADC); +const mcu_pin_obj_t pin_PC12 = PIN(2, 12, NO_ADC); +const mcu_pin_obj_t pin_PC13 = PIN(2, 13, NO_ADC); +const mcu_pin_obj_t pin_PC14 = PIN(2, 14, NO_ADC); +const mcu_pin_obj_t pin_PC15 = PIN(2, 15, NO_ADC); +const mcu_pin_obj_t pin_PD00 = PIN(3, 0, NO_ADC); +const mcu_pin_obj_t pin_PD01 = PIN(3, 1, NO_ADC); +const mcu_pin_obj_t pin_PD02 = PIN(3, 2, NO_ADC); +const mcu_pin_obj_t pin_PD03 = PIN(3, 3, NO_ADC); +const mcu_pin_obj_t pin_PD04 = PIN(3, 4, NO_ADC); +const mcu_pin_obj_t pin_PD05 = PIN(3, 5, NO_ADC); +const mcu_pin_obj_t pin_PD06 = PIN(3, 6, NO_ADC); +const mcu_pin_obj_t pin_PD07 = PIN(3, 7, NO_ADC); +const mcu_pin_obj_t pin_PD08 = PIN(3, 8, NO_ADC); +const mcu_pin_obj_t pin_PD09 = PIN(3, 9, NO_ADC); +const mcu_pin_obj_t pin_PD10 = PIN(3, 10, NO_ADC); +const mcu_pin_obj_t pin_PD11 = PIN(3, 11, NO_ADC); +const mcu_pin_obj_t pin_PD12 = PIN(3, 12, NO_ADC); +const mcu_pin_obj_t pin_PD13 = PIN(3, 13, NO_ADC); +const mcu_pin_obj_t pin_PD14 = PIN(3, 14, NO_ADC); +const mcu_pin_obj_t pin_PD15 = PIN(3, 15, NO_ADC); +const mcu_pin_obj_t pin_PE00 = PIN(4, 0, NO_ADC); +const mcu_pin_obj_t pin_PE01 = PIN(4, 1, NO_ADC); +const mcu_pin_obj_t pin_PE02 = PIN(4, 2, NO_ADC); +const mcu_pin_obj_t pin_PE03 = PIN(4, 3, NO_ADC); +const mcu_pin_obj_t pin_PE04 = PIN(4, 4, NO_ADC); +const mcu_pin_obj_t pin_PE05 = PIN(4, 5, NO_ADC); +const mcu_pin_obj_t pin_PE06 = PIN(4, 6, NO_ADC); +const mcu_pin_obj_t pin_PE07 = PIN(4, 7, NO_ADC); +const mcu_pin_obj_t pin_PE08 = PIN(4, 8, NO_ADC); +const mcu_pin_obj_t pin_PE09 = PIN(4, 9, NO_ADC); +const mcu_pin_obj_t pin_PE10 = PIN(4, 10, NO_ADC); +const mcu_pin_obj_t pin_PE11 = PIN(4, 11, NO_ADC); +const mcu_pin_obj_t pin_PE12 = PIN(4, 12, NO_ADC); +const mcu_pin_obj_t pin_PE13 = PIN(4, 13, NO_ADC); +const mcu_pin_obj_t pin_PE14 = PIN(4, 14, NO_ADC); +const mcu_pin_obj_t pin_PE15 = PIN(4, 15, NO_ADC); +const mcu_pin_obj_t pin_PF00 = PIN(5, 0, NO_ADC); +const mcu_pin_obj_t pin_PF01 = PIN(5, 1, NO_ADC); +const mcu_pin_obj_t pin_PF02 = PIN(5, 2, NO_ADC); +const mcu_pin_obj_t pin_PF03 = PIN(5, 3, NO_ADC); +const mcu_pin_obj_t pin_PF04 = PIN(5, 4, NO_ADC); +const mcu_pin_obj_t pin_PF05 = PIN(5, 5, NO_ADC); +const mcu_pin_obj_t pin_PF06 = PIN(5, 6, NO_ADC); +const mcu_pin_obj_t pin_PF07 = PIN(5, 7, NO_ADC); +const mcu_pin_obj_t pin_PF08 = PIN(5, 8, NO_ADC); +const mcu_pin_obj_t pin_PF09 = PIN(5, 9, NO_ADC); +const mcu_pin_obj_t pin_PF10 = PIN(5, 10, NO_ADC); +const mcu_pin_obj_t pin_PF11 = PIN(5, 11, NO_ADC); +const mcu_pin_obj_t pin_PF12 = PIN(5, 12, NO_ADC); +const mcu_pin_obj_t pin_PF13 = PIN(5, 13, NO_ADC); +const mcu_pin_obj_t pin_PF14 = PIN(5, 14, NO_ADC); +const mcu_pin_obj_t pin_PF15 = PIN(5, 15, NO_ADC); +const mcu_pin_obj_t pin_PG00 = PIN(6, 0, NO_ADC); +const mcu_pin_obj_t pin_PG01 = PIN(6, 1, NO_ADC); +const mcu_pin_obj_t pin_PG02 = PIN(6, 2, NO_ADC); +const mcu_pin_obj_t pin_PG03 = PIN(6, 3, NO_ADC); +const mcu_pin_obj_t pin_PG04 = PIN(6, 4, NO_ADC); +const mcu_pin_obj_t pin_PG05 = PIN(6, 5, NO_ADC); +const mcu_pin_obj_t pin_PG06 = PIN(6, 6, NO_ADC); +const mcu_pin_obj_t pin_PG07 = PIN(6, 7, NO_ADC); +const mcu_pin_obj_t pin_PG08 = PIN(6, 8, NO_ADC); +const mcu_pin_obj_t pin_PG09 = PIN(6, 9, NO_ADC); +const mcu_pin_obj_t pin_PG10 = PIN(6, 10, NO_ADC); +const mcu_pin_obj_t pin_PG11 = PIN(6, 11, NO_ADC); +const mcu_pin_obj_t pin_PG12 = PIN(6, 12, NO_ADC); +const mcu_pin_obj_t pin_PG13 = PIN(6, 13, NO_ADC); +const mcu_pin_obj_t pin_PG14 = PIN(6, 14, NO_ADC); +const mcu_pin_obj_t pin_PG15 = PIN(6, 15, NO_ADC); +const mcu_pin_obj_t pin_PH00 = PIN(7, 0, NO_ADC); +const mcu_pin_obj_t pin_PH01 = PIN(7, 1, NO_ADC); +const mcu_pin_obj_t pin_PH02 = PIN(7, 2, NO_ADC); +const mcu_pin_obj_t pin_PH03 = PIN(7, 3, NO_ADC); +const mcu_pin_obj_t pin_PH04 = PIN(7, 4, NO_ADC); +const mcu_pin_obj_t pin_PH05 = PIN(7, 5, NO_ADC); +const mcu_pin_obj_t pin_PH06 = PIN(7, 6, NO_ADC); +const mcu_pin_obj_t pin_PH07 = PIN(7, 7, NO_ADC); +const mcu_pin_obj_t pin_PH08 = PIN(7, 8, NO_ADC); +const mcu_pin_obj_t pin_PH09 = PIN(7, 9, NO_ADC); +const mcu_pin_obj_t pin_PH10 = PIN(7, 10, NO_ADC); +const mcu_pin_obj_t pin_PH11 = PIN(7, 11, NO_ADC); +const mcu_pin_obj_t pin_PH12 = PIN(7, 12, NO_ADC); +const mcu_pin_obj_t pin_PH13 = PIN(7, 13, NO_ADC); +const mcu_pin_obj_t pin_PH14 = PIN(7, 14, NO_ADC); +const mcu_pin_obj_t pin_PH15 = PIN(7, 15, NO_ADC); +const mcu_pin_obj_t pin_PI00 = PIN(8, 0, NO_ADC); +const mcu_pin_obj_t pin_PI01 = PIN(8, 1, NO_ADC); +const mcu_pin_obj_t pin_PI02 = PIN(8, 2, NO_ADC); +const mcu_pin_obj_t pin_PI03 = PIN(8, 3, NO_ADC); +const mcu_pin_obj_t pin_PI04 = PIN(8, 4, NO_ADC); +const mcu_pin_obj_t pin_PI05 = PIN(8, 5, NO_ADC); +const mcu_pin_obj_t pin_PI06 = PIN(8, 6, NO_ADC); +const mcu_pin_obj_t pin_PI07 = PIN(8, 7, NO_ADC); +const mcu_pin_obj_t pin_PI08 = PIN(8, 8, NO_ADC); +const mcu_pin_obj_t pin_PI09 = PIN(8, 9, NO_ADC); +const mcu_pin_obj_t pin_PI10 = PIN(8, 10, NO_ADC); +const mcu_pin_obj_t pin_PI11 = PIN(8, 11, NO_ADC); diff --git a/ports/stm/peripherals/stm32l4/stm32l4r5xx/pins.h b/ports/stm/peripherals/stm32l4/stm32l4r5xx/pins.h new file mode 100644 index 0000000000..86416cab31 --- /dev/null +++ b/ports/stm/peripherals/stm32l4/stm32l4r5xx/pins.h @@ -0,0 +1,171 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Blues Wireless Contributors + * + * 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_STM32_PERIPHERALS_STM32L4R5XX_PINS_H +#define MICROPY_INCLUDED_STM32_PERIPHERALS_STM32L4R5XX_PINS_H + +extern const mcu_pin_obj_t pin_PA00; +extern const mcu_pin_obj_t pin_PA01; +extern const mcu_pin_obj_t pin_PA02; +extern const mcu_pin_obj_t pin_PA03; +extern const mcu_pin_obj_t pin_PA04; +extern const mcu_pin_obj_t pin_PA05; +extern const mcu_pin_obj_t pin_PA06; +extern const mcu_pin_obj_t pin_PA07; +extern const mcu_pin_obj_t pin_PA08; +extern const mcu_pin_obj_t pin_PA09; +extern const mcu_pin_obj_t pin_PA10; +extern const mcu_pin_obj_t pin_PA11; +extern const mcu_pin_obj_t pin_PA12; +extern const mcu_pin_obj_t pin_PA13; +extern const mcu_pin_obj_t pin_PA14; +extern const mcu_pin_obj_t pin_PA15; +extern const mcu_pin_obj_t pin_PB00; +extern const mcu_pin_obj_t pin_PB01; +extern const mcu_pin_obj_t pin_PB02; +extern const mcu_pin_obj_t pin_PB03; +extern const mcu_pin_obj_t pin_PB04; +extern const mcu_pin_obj_t pin_PB05; +extern const mcu_pin_obj_t pin_PB06; +extern const mcu_pin_obj_t pin_PB07; +extern const mcu_pin_obj_t pin_PB08; +extern const mcu_pin_obj_t pin_PB09; +extern const mcu_pin_obj_t pin_PB10; +extern const mcu_pin_obj_t pin_PB11; +extern const mcu_pin_obj_t pin_PB12; +extern const mcu_pin_obj_t pin_PB13; +extern const mcu_pin_obj_t pin_PB14; +extern const mcu_pin_obj_t pin_PB15; +extern const mcu_pin_obj_t pin_PC00; +extern const mcu_pin_obj_t pin_PC01; +extern const mcu_pin_obj_t pin_PC02; +extern const mcu_pin_obj_t pin_PC03; +extern const mcu_pin_obj_t pin_PC04; +extern const mcu_pin_obj_t pin_PC05; +extern const mcu_pin_obj_t pin_PC06; +extern const mcu_pin_obj_t pin_PC07; +extern const mcu_pin_obj_t pin_PC08; +extern const mcu_pin_obj_t pin_PC09; +extern const mcu_pin_obj_t pin_PC10; +extern const mcu_pin_obj_t pin_PC11; +extern const mcu_pin_obj_t pin_PC12; +extern const mcu_pin_obj_t pin_PC13; +extern const mcu_pin_obj_t pin_PC14; +extern const mcu_pin_obj_t pin_PC15; +extern const mcu_pin_obj_t pin_PD00; +extern const mcu_pin_obj_t pin_PD01; +extern const mcu_pin_obj_t pin_PD02; +extern const mcu_pin_obj_t pin_PD03; +extern const mcu_pin_obj_t pin_PD04; +extern const mcu_pin_obj_t pin_PD05; +extern const mcu_pin_obj_t pin_PD06; +extern const mcu_pin_obj_t pin_PD07; +extern const mcu_pin_obj_t pin_PD08; +extern const mcu_pin_obj_t pin_PD09; +extern const mcu_pin_obj_t pin_PD10; +extern const mcu_pin_obj_t pin_PD11; +extern const mcu_pin_obj_t pin_PD12; +extern const mcu_pin_obj_t pin_PD13; +extern const mcu_pin_obj_t pin_PD14; +extern const mcu_pin_obj_t pin_PD15; +extern const mcu_pin_obj_t pin_PE00; +extern const mcu_pin_obj_t pin_PE01; +extern const mcu_pin_obj_t pin_PE02; +extern const mcu_pin_obj_t pin_PE03; +extern const mcu_pin_obj_t pin_PE04; +extern const mcu_pin_obj_t pin_PE05; +extern const mcu_pin_obj_t pin_PE06; +extern const mcu_pin_obj_t pin_PE07; +extern const mcu_pin_obj_t pin_PE08; +extern const mcu_pin_obj_t pin_PE09; +extern const mcu_pin_obj_t pin_PE10; +extern const mcu_pin_obj_t pin_PE11; +extern const mcu_pin_obj_t pin_PE12; +extern const mcu_pin_obj_t pin_PE13; +extern const mcu_pin_obj_t pin_PE14; +extern const mcu_pin_obj_t pin_PE15; +extern const mcu_pin_obj_t pin_PF00; +extern const mcu_pin_obj_t pin_PF01; +extern const mcu_pin_obj_t pin_PF02; +extern const mcu_pin_obj_t pin_PF03; +extern const mcu_pin_obj_t pin_PF04; +extern const mcu_pin_obj_t pin_PF05; +extern const mcu_pin_obj_t pin_PF06; +extern const mcu_pin_obj_t pin_PF07; +extern const mcu_pin_obj_t pin_PF08; +extern const mcu_pin_obj_t pin_PF09; +extern const mcu_pin_obj_t pin_PF10; +extern const mcu_pin_obj_t pin_PF11; +extern const mcu_pin_obj_t pin_PF12; +extern const mcu_pin_obj_t pin_PF13; +extern const mcu_pin_obj_t pin_PF14; +extern const mcu_pin_obj_t pin_PF15; +extern const mcu_pin_obj_t pin_PG00; +extern const mcu_pin_obj_t pin_PG01; +extern const mcu_pin_obj_t pin_PG02; +extern const mcu_pin_obj_t pin_PG03; +extern const mcu_pin_obj_t pin_PG04; +extern const mcu_pin_obj_t pin_PG05; +extern const mcu_pin_obj_t pin_PG06; +extern const mcu_pin_obj_t pin_PG07; +extern const mcu_pin_obj_t pin_PG08; +extern const mcu_pin_obj_t pin_PG09; +extern const mcu_pin_obj_t pin_PG10; +extern const mcu_pin_obj_t pin_PG11; +extern const mcu_pin_obj_t pin_PG12; +extern const mcu_pin_obj_t pin_PG13; +extern const mcu_pin_obj_t pin_PG14; +extern const mcu_pin_obj_t pin_PG15; +extern const mcu_pin_obj_t pin_PH00; +extern const mcu_pin_obj_t pin_PH01; +extern const mcu_pin_obj_t pin_PH02; +extern const mcu_pin_obj_t pin_PH03; +extern const mcu_pin_obj_t pin_PH04; +extern const mcu_pin_obj_t pin_PH05; +extern const mcu_pin_obj_t pin_PH06; +extern const mcu_pin_obj_t pin_PH07; +extern const mcu_pin_obj_t pin_PH08; +extern const mcu_pin_obj_t pin_PH09; +extern const mcu_pin_obj_t pin_PH10; +extern const mcu_pin_obj_t pin_PH11; +extern const mcu_pin_obj_t pin_PH12; +extern const mcu_pin_obj_t pin_PH13; +extern const mcu_pin_obj_t pin_PH14; +extern const mcu_pin_obj_t pin_PH15; +extern const mcu_pin_obj_t pin_PI00; +extern const mcu_pin_obj_t pin_PI01; +extern const mcu_pin_obj_t pin_PI02; +extern const mcu_pin_obj_t pin_PI03; +extern const mcu_pin_obj_t pin_PI04; +extern const mcu_pin_obj_t pin_PI05; +extern const mcu_pin_obj_t pin_PI06; +extern const mcu_pin_obj_t pin_PI07; +extern const mcu_pin_obj_t pin_PI08; +extern const mcu_pin_obj_t pin_PI09; +extern const mcu_pin_obj_t pin_PI10; +extern const mcu_pin_obj_t pin_PI11; + +#endif // MICROPY_INCLUDED_STM32_PERIPHERALS_STM32L4R5XX_PINS_H diff --git a/ports/stm/peripherals/timers.c b/ports/stm/peripherals/timers.c index 24060678e4..f0054648fc 100644 --- a/ports/stm/peripherals/timers.c +++ b/ports/stm/peripherals/timers.c @@ -122,17 +122,29 @@ static size_t irq_map[] = { NULL_IRQ, #endif #ifdef TIM15 + #ifdef STM32L4 + TIM1_BRK_TIM15_IRQn, + #else TIM15_IRQn, + #endif #else NULL_IRQ, #endif #ifdef TIM16 + #ifdef STM32L4 + TIM1_UP_TIM16_IRQn, + #else TIM16_IRQn, + #endif #else NULL_IRQ, #endif #ifdef TIM17 + #ifdef STM32L4 + TIM1_TRG_COM_TIM17_IRQn + #else TIM17_IRQn, + #endif #else NULL_IRQ, #endif diff --git a/ports/stm/supervisor/internal_flash.c b/ports/stm/supervisor/internal_flash.c index 5600810138..8d8ca2e0e1 100644 --- a/ports/stm/supervisor/internal_flash.c +++ b/ports/stm/supervisor/internal_flash.c @@ -94,6 +94,16 @@ STATIC const flash_layout_t flash_layout[] = { }; STATIC uint8_t _flash_cache[0x20000] __attribute__((aligned(4))); +#elif defined(STM32L4) +// todo - the L4 devices can have different flash sizes and different page sizes +// depending upon the dual bank configuration +// This is hardcoded for the Swan R5. When support for other devices is needed more conditionals will be required +// to differentiate. +STATIC const flash_layout_t flash_layout[] = { + { 0x08000000, 0x1000, 256 }, +}; +STATIC uint8_t _flash_cache[0x1000] __attribute__((aligned(4))); + #else #error Unsupported processor #endif @@ -125,10 +135,23 @@ STATIC uint32_t get_bank(uint32_t addr) { } #endif -// Return the sector of a given flash address. uint32_t flash_get_sector_info(uint32_t addr, uint32_t *start_addr, uint32_t *size) { if (addr >= flash_layout[0].base_address) { uint32_t sector_index = 0; + if (MP_ARRAY_SIZE(flash_layout) == 1) { + sector_index = (addr - flash_layout[0].base_address) / flash_layout[0].sector_size; + if (sector_index >= flash_layout[0].sector_count) { + return 0; + } + if (start_addr) { + *start_addr = flash_layout[0].base_address + (sector_index * flash_layout[0].sector_size); + } + if (size) { + *size = flash_layout[0].sector_size; + } + return sector_index; + } + for (uint8_t i = 0; i < MP_ARRAY_SIZE(flash_layout); ++i) { for (uint8_t j = 0; j < flash_layout[i].sector_count; ++j) { uint32_t sector_start_next = flash_layout[i].base_address @@ -147,7 +170,7 @@ uint32_t flash_get_sector_info(uint32_t addr, uint32_t *start_addr, uint32_t *si } } } - return 0; + return 0; // todo dangerous - shouldn't this raise an exception? } void supervisor_flash_init(void) { @@ -169,22 +192,34 @@ void port_internal_flash_flush(void) { #if defined(STM32H7) __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_ALL_ERRORS_BANK1 | FLASH_FLAG_ALL_ERRORS_BANK2); #else - __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR | - FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR | FLASH_FLAG_PGSERR); + #ifndef FLASH_FLAG_ALL_ERRORS + #define FLASH_FLAG_ALL_ERRORS FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR | FLASH_FLAG_PGPERR | FLASH_FLAG_PGSERR + #endif + __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_ALL_ERRORS); #endif // set up for erase - FLASH_EraseInitTypeDef EraseInitStruct; + FLASH_EraseInitTypeDef EraseInitStruct = {}; + #if CPY_STM32L4 + EraseInitStruct.TypeErase = TYPEERASE_PAGES; + EraseInitStruct.Banks = FLASH_BANK_1; + #else EraseInitStruct.TypeErase = TYPEERASE_SECTORS; EraseInitStruct.VoltageRange = VOLTAGE_RANGE_3; // voltage range needs to be 2.7V to 3.6V + #endif // get the sector information uint32_t sector_size; uint32_t sector_start_addr = 0xffffffff; #if defined(STM32H7) EraseInitStruct.Banks = get_bank(_cache_flash_addr); #endif + #if CPY_STM32L4 + EraseInitStruct.Page = flash_get_sector_info(_cache_flash_addr, §or_start_addr, §or_size); + EraseInitStruct.NbPages = 1; + #else EraseInitStruct.Sector = flash_get_sector_info(_cache_flash_addr, §or_start_addr, §or_size); EraseInitStruct.NbSectors = 1; + #endif if (sector_size > sizeof(_flash_cache) || sector_start_addr == 0xffffffff) { reset_into_safe_mode(FLASH_WRITE_FAIL); } @@ -217,6 +252,19 @@ void port_internal_flash_flush(void) { cache_addr += 8; sector_start_addr += 32; } + #elif CPY_STM32L4 + // program the flash word by word + for (uint32_t i = 0; i < sector_size / 8; i++) { + if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_DOUBLEWORD, sector_start_addr, + *(uint64_t *)cache_addr) != HAL_OK) { + // error occurred during flash write + HAL_FLASH_Lock(); // lock the flash + reset_into_safe_mode(FLASH_WRITE_FAIL); + } + // RAM memory is by word (4 byte), but flash memory is by byte + cache_addr += 2; + sector_start_addr += 8; + } #else // STM32F4 // program the flash word by word @@ -236,6 +284,7 @@ void port_internal_flash_flush(void) { // lock the flash HAL_FLASH_Lock(); } + } static uint32_t convert_block_to_flash_addr(uint32_t block) { diff --git a/ports/stm/supervisor/internal_flash.h b/ports/stm/supervisor/internal_flash.h index 106ff6c540..4df4e9ddbc 100644 --- a/ports/stm/supervisor/internal_flash.h +++ b/ports/stm/supervisor/internal_flash.h @@ -86,6 +86,12 @@ #define INTERNAL_FLASH_FILESYSTEM_START_ADDR 0x08020000 #endif +#ifdef STM32L4R5xx +#define STM32_FLASH_SIZE 0x100000 // 1MB // for now just use the first bank +#define INTERNAL_FLASH_FILESYSTEM_SIZE 0x20000 // 128KiB +#define INTERNAL_FLASH_FILESYSTEM_START_ADDR 0x080e0000 +#endif + #define INTERNAL_FLASH_FILESYSTEM_NUM_BLOCKS (INTERNAL_FLASH_FILESYSTEM_SIZE / FILESYSTEM_BLOCK_SIZE) #define STM32_FLASH_OFFSET 0x8000000 // All STM32 chips map to this flash location diff --git a/ports/stm/supervisor/port.c b/ports/stm/supervisor/port.c index 9dc6eeb870..a158ade6eb 100644 --- a/ports/stm/supervisor/port.c +++ b/ports/stm/supervisor/port.c @@ -29,7 +29,7 @@ #include "supervisor/background_callback.h" #include "supervisor/board.h" #include "supervisor/port.h" -#include "lib/timeutils/timeutils.h" +#include "shared/timeutils/timeutils.h" #include "common-hal/microcontroller/Pin.h" #include "shared-bindings/microcontroller/__init__.h" @@ -177,7 +177,7 @@ safe_mode_t port_init(void) { HAL_Init(); // Turns on SysTick __HAL_RCC_SYSCFG_CLK_ENABLE(); - #if CPY_STM32F4 + #if CPY_STM32F4 || CPY_STM32L4 __HAL_RCC_PWR_CLK_ENABLE(); HAL_PWR_EnableBkUpAccess(); diff --git a/ports/stm/supervisor/usb.c b/ports/stm/supervisor/usb.c index 906d07f737..882f74e8bc 100644 --- a/ports/stm/supervisor/usb.c +++ b/ports/stm/supervisor/usb.c @@ -27,8 +27,8 @@ #include "supervisor/usb.h" -#include "lib/utils/interrupt_char.h" -#include "lib/mp-readline/readline.h" +#include "shared/runtime/interrupt_char.h" +#include "shared/readline/readline.h" #include "lib/tinyusb/src/device/usbd.h" #include "py/mpconfig.h" @@ -43,6 +43,11 @@ STATIC void init_usb_vbus_sense(void) { // Deactivate VBUS Sensing B USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBDEN; + #if (BOARD_NO_USB_OTG_ID_SENSE) + USB_OTG_FS->GUSBCFG &= ~USB_OTG_GUSBCFG_FHMOD; + USB_OTG_FS->GUSBCFG |= USB_OTG_GUSBCFG_FDMOD; + #endif + // B-peripheral session valid override enable USB_OTG_FS->GOTGCTL |= USB_OTG_GOTGCTL_BVALOEN; USB_OTG_FS->GOTGCTL |= USB_OTG_GOTGCTL_BVALOVAL; @@ -63,6 +68,12 @@ STATIC void init_usb_vbus_sense(void) { } void init_usb_hardware(void) { + + /* Enable USB power on Pwrctrl CR2 register */ + #ifdef PWR_CR2_USV + HAL_PWREx_EnableVddUSB(); + #endif + // TODO: if future chips overload this with options, move to peripherals management. GPIO_InitTypeDef GPIO_InitStruct = {0}; @@ -80,7 +91,7 @@ void init_usb_hardware(void) { GPIO_InitStruct.Pull = GPIO_NOPULL; #if CPY_STM32H7 GPIO_InitStruct.Alternate = GPIO_AF10_OTG1_FS; - #elif CPY_STM32F4 || CPY_STM32F7 + #elif CPY_STM32F4 || CPY_STM32F7 || CPY_STM32L4 GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS; #endif HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); @@ -100,18 +111,20 @@ void init_usb_hardware(void) { #endif /* This for ID line debug */ + #if !(BOARD_NO_USB_OTG_ID_SENSE) GPIO_InitStruct.Pin = GPIO_PIN_10; GPIO_InitStruct.Mode = GPIO_MODE_AF_OD; GPIO_InitStruct.Pull = GPIO_PULLUP; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; #if CPY_STM32H7 GPIO_InitStruct.Alternate = GPIO_AF10_OTG1_FS; - #elif CPY_STM32F4 || CPY_STM32F7 + #elif CPY_STM32F4 || CPY_STM32F7 || CPY_STM32L4 GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS; #endif HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); never_reset_pin_number(0, 10); claim_pin(0, 10); + #endif #ifdef STM32F412Zx /* Configure POWER_SWITCH IO pin (F412 ONLY)*/ @@ -131,6 +144,7 @@ void init_usb_hardware(void) { __HAL_RCC_USB_OTG_FS_CLK_ENABLE(); #endif + init_usb_vbus_sense(); } diff --git a/ports/stm/tools/examples/stm32f405.csv b/ports/stm/tools/examples/stm32f405.csv index 2602db8775..20043f5855 100644 --- a/ports/stm/tools/examples/stm32f405.csv +++ b/ports/stm/tools/examples/stm32f405.csv @@ -1,142 +1,142 @@ Port,,AF0,AF1,AF2,AF3,AF4,AF5,AF6,AF7,AF8,AF9,AF10,AF11,AF12,AF13,AF14,AF15, ,,SYS,TIM1/2,TIM3/4/5,TIM8/9/10/11,I2C1/2/3,SPI1/SPI2/I2S2/I2S2ext,SPI3/I2Sext/I2S3,USART1/2/3/I2S3ext,UART4/5/USART6,CAN1/CAN2/TIM12/13/14,OTG_FS/OTG_HS,ETH,FSMC/SDIO/OTG_FS,DCMI,,,ADC -PortA,PA0,,TIM2_CH1/TIM2_ETR,TIM5_CH1,TIM8_ETR,,,,USART2_CTS,UART4_TX,,,ETH_MII_CRS,,,,EVENTOUT,ADC123_IN0 -PortA,PA1,,TIM2_CH2,TIM5_CH2,,,,,USART2_RTS,UART4_RX,,,ETH_MII_RX_CLK/ETH_RMII_REF_CLK,,,,EVENTOUT,ADC123_IN1 -PortA,PA2,,TIM2_CH3,TIM5_CH3,TIM9_CH1,,,,USART2_TX,,,,ETH_MDIO,,,,EVENTOUT,ADC123_IN2 -PortA,PA3,,TIM2_CH4,TIM5_CH4,TIM9_CH2,,,,USART2_RX,,,OTG_HS_ULPI_D0,ETH_MII_COL,,,,EVENTOUT,ADC123_IN3 -PortA,PA4,,,,,,SPI1_NSS,SPI3_NSS/I2S3_WS,USART2_CK,,,,,OTG_HS_SOF,DCMI_HSYNC,,EVENTOUT,ADC12_IN4 -PortA,PA5,,TIM2_CH1/TIM2_ETR,,TIM8_CH1N,,SPI1_SCK,,,,,OTG_HS_ULPI_CK,,,,,EVENTOUT,ADC12_IN5 -PortA,PA6,,TIM1_BKIN,TIM3_CH1,TIM8_BKIN,,SPI1_MISO,,,,TIM13_CH1,,,,DCMI_PIXCK,,EVENTOUT,ADC12_IN6 -PortA,PA7,,TIM1_CH1N,TIM3_CH2,TIM8_CH1N,,SPI1_MOSI,,,,TIM14_CH1,,ETH_MII_RX_DV/ETH_RMII_CRS_DV,,,,EVENTOUT,ADC12_IN7 -PortA,PA8,MCO1,TIM1_CH1,,,I2C3_SCL,,,USART1_CK,,,OTG_FS_SOF,,,,,EVENTOUT, -PortA,PA9,,TIM1_CH2,,,I2C3_SMBA,,,USART1_TX,,,,,,DCMI_D0,,EVENTOUT, -PortA,PA10,,TIM1_CH3,,,,,,USART1_RX,,,OTG_FS_ID,,,DCMI_D1,,EVENTOUT, -PortA,PA11,,TIM1_CH4,,,,,,USART1_CTS,,CAN1_RX,OTG_FS_DM,,,,,EVENTOUT, -PortA,PA12,,TIM1_ETR,,,,,,USART1_RTS,,CAN1_TX,OTG_FS_DP,,,,,EVENTOUT, -PortA,PA13,JTMS/SWDIO,,,,,,,,,,,,,,,EVENTOUT, -PortA,PA14,JTCK/SWCLK,,,,,,,,,,,,,,,EVENTOUT, -PortA,PA15,JTDI,TIM2_CH1/TIM2_ETR,,,,SPI1_NSS,SPI3_NSS/I2S3_WS,,,,,,,,,EVENTOUT, -PortB,PB0,,TIM1_CH2N,TIM3_CH3,TIM8_CH2N,,,,,,,OTG_HS_ULPI_D1,ETH_MII_RXD2,,,,EVENTOUT,ADC12_IN8 -PortB,PB1,,TIM1_CH3N,TIM3_CH4,TIM8_CH3N,,,,,,,OTG_HS_ULPI_D2,ETH_MII_RXD3,,,,EVENTOUT,ADC12_IN9 -PortB,PB2,,,,,,,,,,,,,,,,EVENTOUT, -PortB,PB3,JTDO/TRACESWO,TIM2_CH2,,,,SPI1_SCK,SPI3_SCK/I2S3_CK,,,,,,,,,EVENTOUT, -PortB,PB4,NJTRST,,TIM3_CH1,,,SPI1_MISO,SPI3_MISO,I2S3ext_SD,,,,,,,,EVENTOUT, -PortB,PB5,,,TIM3_CH2,,I2C1_SMBA,SPI1_MOSI,SPI3_MOSI/I2S3_SD,,,CAN2_RX,OTG_HS_ULPI_D7,ETH_PPS_OUT,,DCMI_D10,,EVENTOUT, -PortB,PB6,,,TIM4_CH1,,I2C1_SCL,,,USART1_TX,,CAN2_TX,,,,DCMI_D5,,EVENTOUT, -PortB,PB7,,,TIM4_CH2,,I2C1_SDA,,,USART1_RX,,,,,FSMC_NL,DCMI_VSYNC,,EVENTOUT, -PortB,PB8,,,TIM4_CH3,TIM10_CH1,I2C1_SCL,,,,,CAN1_RX,,ETH_MII_TXD3,SDIO_D4,DCMI_D6,,EVENTOUT, -PortB,PB9,,,TIM4_CH4,TIM11_CH1,I2C1_SDA,SPI2_NSS/I2S2_WS,,,,CAN1_TX,,,SDIO_D5,DCMI_D7,,EVENTOUT, -PortB,PB10,,TIM2_CH3,,,I2C2_SCL,SPI2_SCK/I2S2_CK,,USART3_TX,,,OTG_HS_ULPI_D3,ETH_MII_RX_ER,,,,EVENTOUT, -PortB,PB11,,TIM2_CH4,,,I2C2_SDA,,,USART3_RX,,,OTG_HS_ULPI_D4,ETH_MII_TX_EN/ETH_RMII_TX_EN,,,,EVENTOUT, -PortB,PB12,,TIM1_BKIN,,,I2C2_SMBA,SPI2_NSS/I2S2_WS,,USART3_CK,,CAN2_RX,OTG_HS_ULPI_D5,ETH_MII_TXD0/ETH_RMII_TXD0,OTG_HS_ID,,,EVENTOUT, -PortB,PB13,,TIM1_CH1N,,,,SPI2_SCK/I2S2_CK,,USART3_CTS,,CAN2_TX,OTG_HS_ULPI_D6,ETH_MII_TXD1/ETH_RMII_TXD1,,,,EVENTOUT, -PortB,PB14,,TIM1_CH2N,,TIM8_CH2N,,SPI2_MISO,I2S2ext_SD,USART3_RTS,,TIM12_CH1,,,OTG_HS_DM,,,EVENTOUT, -PortB,PB15,RTC_REFIN,TIM1_CH3N,,TIM8_CH3N,,SPI2_MOSI/I2S2_SD,,,,TIM12_CH2,,,OTG_HS_DP,,,EVENTOUT, -PortC,PC0,,,,,,,,,,,OTG_HS_ULPI_STP,,,,,EVENTOUT,ADC123_IN10 -PortC,PC1,,,,,,,,,,,,ETH_MDC,,,,EVENTOUT,ADC123_IN11 -PortC,PC2,,,,,,SPI2_MISO,I2S2ext_SD,,,,OTG_HS_ULPI_DIR,ETH_MII_TXD2,,,,EVENTOUT,ADC123_IN12 -PortC,PC3,,,,,,SPI2_MOSI/I2S2_SD,,,,,OTG_HS_ULPI_NXT,ETH_MII_TX_CLK,,,,EVENTOUT,ADC123_IN13 -PortC,PC4,,,,,,,,,,,,ETH_MII_RXD0/ETH_RMII_RXD0,,,,EVENTOUT,ADC123_IN14 -PortC,PC5,,,,,,,,,,,,ETH_MII_RXD1/ETH_RMII_RXD1,,,,EVENTOUT,ADC123_IN15 -PortC,PC6,,,TIM3_CH1,TIM8_CH1,,I2S2_MCK,,,USART6_TX,,,,SDIO_D6,DCMI_D0,,EVENTOUT, -PortC,PC7,,,TIM3_CH2,TIM8_CH2,,,I2S3_MCK,,USART6_RX,,,,SDIO_D7,DCMI_D1,,EVENTOUT, -PortC,PC8,,,TIM3_CH3,TIM8_CH3,,,,,USART6_CK,,,,SDIO_D0,DCMI_D2,,EVENTOUT, -PortC,PC9,MCO2,,TIM3_CH4,TIM8_CH4,I2C3_SDA,I2S_CKIN,,,,,,,SDIO_D1,DCMI_D3,,EVENTOUT, -PortC,PC10,,,,,,,SPI3_SCK/I2S3_CK,USART3_TX,UART4_TX,,,,SDIO_D2,DCMI_D8,,EVENTOUT, -PortC,PC11,,,,,,I2S3ext_SD,SPI3_MISO,USART3_RX,UART4_RX,,,,SDIO_D3,DCMI_D4,,EVENTOUT, -PortC,PC12,,,,,,,SPI3_MOSI/I2S3_SD,USART3_CK,UART5_TX,,,,SDIO_CK,DCMI_D9,,EVENTOUT, -PortC,PC13,,,,,,,,,,,,,,,,EVENTOUT, -PortC,PC14,,,,,,,,,,,,,,,,EVENTOUT, -PortC,PC15,,,,,,,,,,,,,,,,EVENTOUT, -PortD,PD0,,,,,,,,,,CAN1_RX,,,FSMC_D2,,,EVENTOUT, -PortD,PD1,,,,,,,,,,CAN1_TX,,,FSMC_D3,,,EVENTOUT, -PortD,PD2,,,TIM3_ETR,,,,,,UART5_RX,,,,SDIO_CMD,DCMI_D11,,EVENTOUT, -PortD,PD3,,,,,,,,USART2_CTS,,,,,FSMC_CLK,,,EVENTOUT, -PortD,PD4,,,,,,,,USART2_RTS,,,,,FSMC_NOE,,,EVENTOUT, -PortD,PD5,,,,,,,,USART2_TX,,,,,FSMC_NWE,,,EVENTOUT, -PortD,PD6,,,,,,,,USART2_RX,,,,,FSMC_NWAIT,,,EVENTOUT, -PortD,PD7,,,,,,,,USART2_CK,,,,,FSMC_NE1/FSMC_NCE2,,,EVENTOUT, -PortD,PD8,,,,,,,,USART3_TX,,,,,FSMC_D13,,,EVENTOUT, -PortD,PD9,,,,,,,,USART3_RX,,,,,FSMC_D14,,,EVENTOUT, -PortD,PD10,,,,,,,,USART3_CK,,,,,FSMC_D15,,,EVENTOUT, -PortD,PD11,,,,,,,,USART3_CTS,,,,,FSMC_A16,,,EVENTOUT, -PortD,PD12,,,TIM4_CH1,,,,,USART3_RTS,,,,,FSMC_A17,,,EVENTOUT, -PortD,PD13,,,TIM4_CH2,,,,,,,,,,FSMC_A18,,,EVENTOUT, -PortD,PD14,,,TIM4_CH3,,,,,,,,,,FSMC_D0,,,EVENTOUT, -PortD,PD15,,,TIM4_CH4,,,,,,,,,,FSMC_D1,,,EVENTOUT, -PortE,PE0,,,TIM4_ETR,,,,,,,,,,FSMC_NBL0,DCMI_D2,,EVENTOUT, -PortE,PE1,,,,,,,,,,,,,FSMC_NBL1,DCMI_D3,,EVENTOUT, -PortE,PE2,TRACECLK,,,,,,,,,,,ETH_MII_TXD3,FSMC_A23,,,EVENTOUT, -PortE,PE3,TRACED0,,,,,,,,,,,,FSMC_A19,,,EVENTOUT, -PortE,PE4,TRACED1,,,,,,,,,,,,FSMC_A20,DCMI_D4,,EVENTOUT, -PortE,PE5,TRACED2,,,TIM9_CH1,,,,,,,,,FSMC_A21,DCMI_D6,,EVENTOUT, -PortE,PE6,TRACED3,,,TIM9_CH2,,,,,,,,,FSMC_A22,DCMI_D7,,EVENTOUT, -PortE,PE7,,TIM1_ETR,,,,,,,,,,,FSMC_D4,,,EVENTOUT, -PortE,PE8,,TIM1_CH1N,,,,,,,,,,,FSMC_D5,,,EVENTOUT, -PortE,PE9,,TIM1_CH1,,,,,,,,,,,FSMC_D6,,,EVENTOUT, -PortE,PE10,,TIM1_CH2N,,,,,,,,,,,FSMC_D7,,,EVENTOUT, -PortE,PE11,,TIM1_CH2,,,,,,,,,,,FSMC_D8,,,EVENTOUT, -PortE,PE12,,TIM1_CH3N,,,,,,,,,,,FSMC_D9,,,EVENTOUT, -PortE,PE13,,TIM1_CH3,,,,,,,,,,,FSMC_D10,,,EVENTOUT, -PortE,PE14,,TIM1_CH4,,,,,,,,,,,FSMC_D11,,,EVENTOUT, -PortE,PE15,,TIM1_BKIN,,,,,,,,,,,FSMC_D12,,,EVENTOUT, -PortF,PF0,,,,,I2C2_SDA,,,,,,,,FSMC_A0,,,EVENTOUT, -PortF,PF1,,,,,I2C2_SCL,,,,,,,,FSMC_A1,,,EVENTOUT, -PortF,PF2,,,,,I2C2_SMBA,,,,,,,,FSMC_A2,,,EVENTOUT, -PortF,PF3,,,,,,,,,,,,,FSMC_A3,,,EVENTOUT,ADC3_IN9 -PortF,PF4,,,,,,,,,,,,,FSMC_A4,,,EVENTOUT,ADC3_IN14 -PortF,PF5,,,,,,,,,,,,,FSMC_A5,,,EVENTOUT,ADC3_IN15 -PortF,PF6,,,,TIM10_CH1,,,,,,,,,FSMC_NIORD,,,EVENTOUT,ADC3_IN4 -PortF,PF7,,,,TIM11_CH1,,,,,,,,,FSMC_NREG,,,EVENTOUT,ADC3_IN5 -PortF,PF8,,,,,,,,,,TIM13_CH1,,,FSMC_NIOWR,,,EVENTOUT,ADC3_IN6 -PortF,PF9,,,,,,,,,,TIM14_CH1,,,FSMC_CD,,,EVENTOUT,ADC3_IN7 -PortF,PF10,,,,,,,,,,,,,FSMC_INTR,,,EVENTOUT,ADC3_IN8 -PortF,PF11,,,,,,,,,,,,,,DCMI_D12,,EVENTOUT, -PortF,PF12,,,,,,,,,,,,,FSMC_A6,,,EVENTOUT, -PortF,PF13,,,,,,,,,,,,,FSMC_A7,,,EVENTOUT, -PortF,PF14,,,,,,,,,,,,,FSMC_A8,,,EVENTOUT, -PortF,PF15,,,,,,,,,,,,,FSMC_A9,,,EVENTOUT, -PortG,PG0,,,,,,,,,,,,,FSMC_A10,,,EVENTOUT, -PortG,PG1,,,,,,,,,,,,,FSMC_A11,,,EVENTOUT, -PortG,PG2,,,,,,,,,,,,,FSMC_A12,,,EVENTOUT, -PortG,PG3,,,,,,,,,,,,,FSMC_A13,,,EVENTOUT, -PortG,PG4,,,,,,,,,,,,,FSMC_A14,,,EVENTOUT, -PortG,PG5,,,,,,,,,,,,,FSMC_A15,,,EVENTOUT, -PortG,PG6,,,,,,,,,,,,,FSMC_INT2,,,EVENTOUT, -PortG,PG7,,,,,,,,,USART6_CK,,,,FSMC_INT3,,,EVENTOUT, -PortG,PG8,,,,,,,,,USART6_RTS,,,ETH_PPS_OUT,,,,EVENTOUT, -PortG,PG9,,,,,,,,,USART6_RX,,,,FSMC_NE2/FSMC_NCE3,,,EVENTOUT, -PortG,PG10,,,,,,,,,,,,,FSMC_NCE4_1/FSMC_NE3,,,EVENTOUT, -PortG,PG11,,,,,,,,,,,,ETH_MII_TX_EN/ETH_RMII_TX_EN,FSMC_NCE4_2,,,EVENTOUT, -PortG,PG12,,,,,,,,,USART6_RTS,,,,FSMC_NE4,,,EVENTOUT, -PortG,PG13,,,,,,,,,USART6_CTS,,,ETH_MII_TXD0/ETH_RMII_TXD0,FSMC_A24,,,EVENTOUT, -PortG,PG14,,,,,,,,,USART6_TX,,,ETH_MII_TXD1/ETH_RMII_TXD1,FSMC_A25,,,EVENTOUT, -PortG,PG15,,,,,,,,,USART6_CTS,,,,,DCMI_D13,,EVENTOUT, -PortH,PH0,,,,,,,,,,,,,,,,EVENTOUT, -PortH,PH1,,,,,,,,,,,,,,,,EVENTOUT, -PortH,PH2,,,,,,,,,,,,ETH_MII_CRS,,,,EVENTOUT, -PortH,PH3,,,,,,,,,,,,ETH_MII_COL,,,,EVENTOUT, -PortH,PH4,,,,,I2C2_SCL,,,,,,OTG_HS_ULPI_NXT,,,,,EVENTOUT, -PortH,PH5,,,,,I2C2_SDA,,,,,,,,,,,EVENTOUT, -PortH,PH6,,,,,I2C2_SMBA,,,,,TIM12_CH1,,ETH_MII_RXD2,,,,EVENTOUT, -PortH,PH7,,,,,I2C3_SCL,,,,,,,ETH_MII_RXD3,,,,EVENTOUT, -PortH,PH8,,,,,I2C3_SDA,,,,,,,,,DCMI_HSYNC,,EVENTOUT, -PortH,PH9,,,,,I2C3_SMBA,,,,,TIM12_CH2,,,,DCMI_D0,,EVENTOUT, -PortH,PH10,,,TIM5_CH1,,,,,,,,,,,DCMI_D1,,EVENTOUT, -PortH,PH11,,,TIM5_CH2,,,,,,,,,,,DCMI_D2,,EVENTOUT, -PortH,PH12,,,TIM5_CH3,,,,,,,,,,,DCMI_D3,,EVENTOUT, -PortH,PH13,,,,TIM8_CH1N,,,,,,CAN1_TX,,,,,,EVENTOUT, -PortH,PH14,,,,TIM8_CH2N,,,,,,,,,,DCMI_D4,,EVENTOUT, -PortH,PH15,,,,TIM8_CH3N,,,,,,,,,,DCMI_D11,,EVENTOUT, -PortI,PI0,,,TIM5_CH4,,,SPI2_NSS/I2S2_WS,,,,,,,,DCMI_D13,,EVENTOUT, -PortI,PI1,,,,,,SPI2_SCK/I2S2_CK,,,,,,,,DCMI_D8,,EVENTOUT, -PortI,PI2,,,,TIM8_CH4,,SPI2_MISO,I2S2ext_SD,,,,,,,DCMI_D9,,EVENTOUT, -PortI,PI3,,,,TIM8_ETR,,SPI2_MOSI/I2S2_SD,,,,,,,,DCMI_D10,,EVENTOUT, -PortI,PI4,,,,TIM8_BKIN,,,,,,,,,,DCMI_D5,,EVENTOUT, -PortI,PI5,,,,TIM8_CH1,,,,,,,,,,DCMI_VSYNC,,EVENTOUT, -PortI,PI6,,,,TIM8_CH2,,,,,,,,,,DCMI_D6,,EVENTOUT, -PortI,PI7,,,,TIM8_CH3,,,,,,,,,,DCMI_D7,,EVENTOUT, -PortI,PI8,,,,,,,,,,,,,,,,EVENTOUT, -PortI,PI9,,,,,,,,,,CAN1_RX,,,,,,EVENTOUT, -PortI,PI10,,,,,,,,,,,,ETH_MII_RX_ER,,,,EVENTOUT, -PortI,PI11,,,,,,,,,,,OTG_HS_ULPI_DIR,,,,,EVENTOUT, +PA0,,TIM2_CH1/TIM2_ETR,TIM5_CH1,TIM8_ETR,,,,USART2_CTS,UART4_TX,,,ETH_MII_CRS,,,,EVENTOUT,ADC123_IN0 +PA1,,TIM2_CH2,TIM5_CH2,,,,,USART2_RTS,UART4_RX,,,ETH_MII_RX_CLK/ETH_RMII_REF_CLK,,,,EVENTOUT,ADC123_IN1 +PA2,,TIM2_CH3,TIM5_CH3,TIM9_CH1,,,,USART2_TX,,,,ETH_MDIO,,,,EVENTOUT,ADC123_IN2 +PA3,,TIM2_CH4,TIM5_CH4,TIM9_CH2,,,,USART2_RX,,,OTG_HS_ULPI_D0,ETH_MII_COL,,,,EVENTOUT,ADC123_IN3 +PA4,,,,,,SPI1_NSS,SPI3_NSS/I2S3_WS,USART2_CK,,,,,OTG_HS_SOF,DCMI_HSYNC,,EVENTOUT,ADC12_IN4 +PA5,,TIM2_CH1/TIM2_ETR,,TIM8_CH1N,,SPI1_SCK,,,,,OTG_HS_ULPI_CK,,,,,EVENTOUT,ADC12_IN5 +PA6,,TIM1_BKIN,TIM3_CH1,TIM8_BKIN,,SPI1_MISO,,,,TIM13_CH1,,,,DCMI_PIXCK,,EVENTOUT,ADC12_IN6 +PA7,,TIM1_CH1N,TIM3_CH2,TIM8_CH1N,,SPI1_MOSI,,,,TIM14_CH1,,ETH_MII_RX_DV/ETH_RMII_CRS_DV,,,,EVENTOUT,ADC12_IN7 +PA8,MCO1,TIM1_CH1,,,I2C3_SCL,,,USART1_CK,,,OTG_FS_SOF,,,,,EVENTOUT, +PA9,,TIM1_CH2,,,I2C3_SMBA,,,USART1_TX,,,,,,DCMI_D0,,EVENTOUT, +PA10,,TIM1_CH3,,,,,,USART1_RX,,,OTG_FS_ID,,,DCMI_D1,,EVENTOUT, +PA11,,TIM1_CH4,,,,,,USART1_CTS,,CAN1_RX,OTG_FS_DM,,,,,EVENTOUT, +PA12,,TIM1_ETR,,,,,,USART1_RTS,,CAN1_TX,OTG_FS_DP,,,,,EVENTOUT, +PA13,JTMS/SWDIO,,,,,,,,,,,,,,,EVENTOUT, +PA14,JTCK/SWCLK,,,,,,,,,,,,,,,EVENTOUT, +PA15,JTDI,TIM2_CH1/TIM2_ETR,,,,SPI1_NSS,SPI3_NSS/I2S3_WS,,,,,,,,,EVENTOUT, +PB0,,TIM1_CH2N,TIM3_CH3,TIM8_CH2N,,,,,,,OTG_HS_ULPI_D1,ETH_MII_RXD2,,,,EVENTOUT,ADC12_IN8 +PB1,,TIM1_CH3N,TIM3_CH4,TIM8_CH3N,,,,,,,OTG_HS_ULPI_D2,ETH_MII_RXD3,,,,EVENTOUT,ADC12_IN9 +PB2,,,,,,,,,,,,,,,,EVENTOUT, +PB3,JTDO/TRACESWO,TIM2_CH2,,,,SPI1_SCK,SPI3_SCK/I2S3_CK,,,,,,,,,EVENTOUT, +PB4,NJTRST,,TIM3_CH1,,,SPI1_MISO,SPI3_MISO,I2S3ext_SD,,,,,,,,EVENTOUT, +PB5,,,TIM3_CH2,,I2C1_SMBA,SPI1_MOSI,SPI3_MOSI/I2S3_SD,,,CAN2_RX,OTG_HS_ULPI_D7,ETH_PPS_OUT,,DCMI_D10,,EVENTOUT, +PB6,,,TIM4_CH1,,I2C1_SCL,,,USART1_TX,,CAN2_TX,,,,DCMI_D5,,EVENTOUT, +PB7,,,TIM4_CH2,,I2C1_SDA,,,USART1_RX,,,,,FSMC_NL,DCMI_VSYNC,,EVENTOUT, +PB8,,,TIM4_CH3,TIM10_CH1,I2C1_SCL,,,,,CAN1_RX,,ETH_MII_TXD3,SDIO_D4,DCMI_D6,,EVENTOUT, +PB9,,,TIM4_CH4,TIM11_CH1,I2C1_SDA,SPI2_NSS/I2S2_WS,,,,CAN1_TX,,,SDIO_D5,DCMI_D7,,EVENTOUT, +PB10,,TIM2_CH3,,,I2C2_SCL,SPI2_SCK/I2S2_CK,,USART3_TX,,,OTG_HS_ULPI_D3,ETH_MII_RX_ER,,,,EVENTOUT, +PB11,,TIM2_CH4,,,I2C2_SDA,,,USART3_RX,,,OTG_HS_ULPI_D4,ETH_MII_TX_EN/ETH_RMII_TX_EN,,,,EVENTOUT, +PB12,,TIM1_BKIN,,,I2C2_SMBA,SPI2_NSS/I2S2_WS,,USART3_CK,,CAN2_RX,OTG_HS_ULPI_D5,ETH_MII_TXD0/ETH_RMII_TXD0,OTG_HS_ID,,,EVENTOUT, +PB13,,TIM1_CH1N,,,,SPI2_SCK/I2S2_CK,,USART3_CTS,,CAN2_TX,OTG_HS_ULPI_D6,ETH_MII_TXD1/ETH_RMII_TXD1,,,,EVENTOUT, +PB14,,TIM1_CH2N,,TIM8_CH2N,,SPI2_MISO,I2S2ext_SD,USART3_RTS,,TIM12_CH1,,,OTG_HS_DM,,,EVENTOUT, +PB15,RTC_REFIN,TIM1_CH3N,,TIM8_CH3N,,SPI2_MOSI/I2S2_SD,,,,TIM12_CH2,,,OTG_HS_DP,,,EVENTOUT, +PC0,,,,,,,,,,,OTG_HS_ULPI_STP,,,,,EVENTOUT,ADC123_IN10 +PC1,,,,,,,,,,,,ETH_MDC,,,,EVENTOUT,ADC123_IN11 +PC2,,,,,,SPI2_MISO,I2S2ext_SD,,,,OTG_HS_ULPI_DIR,ETH_MII_TXD2,,,,EVENTOUT,ADC123_IN12 +PC3,,,,,,SPI2_MOSI/I2S2_SD,,,,,OTG_HS_ULPI_NXT,ETH_MII_TX_CLK,,,,EVENTOUT,ADC123_IN13 +PC4,,,,,,,,,,,,ETH_MII_RXD0/ETH_RMII_RXD0,,,,EVENTOUT,ADC123_IN14 +PC5,,,,,,,,,,,,ETH_MII_RXD1/ETH_RMII_RXD1,,,,EVENTOUT,ADC123_IN15 +PC6,,,TIM3_CH1,TIM8_CH1,,I2S2_MCK,,,USART6_TX,,,,SDIO_D6,DCMI_D0,,EVENTOUT, +PC7,,,TIM3_CH2,TIM8_CH2,,,I2S3_MCK,,USART6_RX,,,,SDIO_D7,DCMI_D1,,EVENTOUT, +PC8,,,TIM3_CH3,TIM8_CH3,,,,,USART6_CK,,,,SDIO_D0,DCMI_D2,,EVENTOUT, +PC9,MCO2,,TIM3_CH4,TIM8_CH4,I2C3_SDA,I2S_CKIN,,,,,,,SDIO_D1,DCMI_D3,,EVENTOUT, +PC10,,,,,,,SPI3_SCK/I2S3_CK,USART3_TX,UART4_TX,,,,SDIO_D2,DCMI_D8,,EVENTOUT, +PC11,,,,,,I2S3ext_SD,SPI3_MISO,USART3_RX,UART4_RX,,,,SDIO_D3,DCMI_D4,,EVENTOUT, +PC12,,,,,,,SPI3_MOSI/I2S3_SD,USART3_CK,UART5_TX,,,,SDIO_CK,DCMI_D9,,EVENTOUT, +PC13,,,,,,,,,,,,,,,,EVENTOUT, +PC14,,,,,,,,,,,,,,,,EVENTOUT, +PC15,,,,,,,,,,,,,,,,EVENTOUT, +PD0,,,,,,,,,,CAN1_RX,,,FSMC_D2,,,EVENTOUT, +PD1,,,,,,,,,,CAN1_TX,,,FSMC_D3,,,EVENTOUT, +PD2,,,TIM3_ETR,,,,,,UART5_RX,,,,SDIO_CMD,DCMI_D11,,EVENTOUT, +PD3,,,,,,,,USART2_CTS,,,,,FSMC_CLK,,,EVENTOUT, +PD4,,,,,,,,USART2_RTS,,,,,FSMC_NOE,,,EVENTOUT, +PD5,,,,,,,,USART2_TX,,,,,FSMC_NWE,,,EVENTOUT, +PD6,,,,,,,,USART2_RX,,,,,FSMC_NWAIT,,,EVENTOUT, +PD7,,,,,,,,USART2_CK,,,,,FSMC_NE1/FSMC_NCE2,,,EVENTOUT, +PD8,,,,,,,,USART3_TX,,,,,FSMC_D13,,,EVENTOUT, +PD9,,,,,,,,USART3_RX,,,,,FSMC_D14,,,EVENTOUT, +PD10,,,,,,,,USART3_CK,,,,,FSMC_D15,,,EVENTOUT, +PD11,,,,,,,,USART3_CTS,,,,,FSMC_A16,,,EVENTOUT, +PD12,,,TIM4_CH1,,,,,USART3_RTS,,,,,FSMC_A17,,,EVENTOUT, +PD13,,,TIM4_CH2,,,,,,,,,,FSMC_A18,,,EVENTOUT, +PD14,,,TIM4_CH3,,,,,,,,,,FSMC_D0,,,EVENTOUT, +PD15,,,TIM4_CH4,,,,,,,,,,FSMC_D1,,,EVENTOUT, +PE0,,,TIM4_ETR,,,,,,,,,,FSMC_NBL0,DCMI_D2,,EVENTOUT, +PE1,,,,,,,,,,,,,FSMC_NBL1,DCMI_D3,,EVENTOUT, +PE2,TRACECLK,,,,,,,,,,,ETH_MII_TXD3,FSMC_A23,,,EVENTOUT, +PE3,TRACED0,,,,,,,,,,,,FSMC_A19,,,EVENTOUT, +PE4,TRACED1,,,,,,,,,,,,FSMC_A20,DCMI_D4,,EVENTOUT, +PE5,TRACED2,,,TIM9_CH1,,,,,,,,,FSMC_A21,DCMI_D6,,EVENTOUT, +PE6,TRACED3,,,TIM9_CH2,,,,,,,,,FSMC_A22,DCMI_D7,,EVENTOUT, +PE7,,TIM1_ETR,,,,,,,,,,,FSMC_D4,,,EVENTOUT, +PE8,,TIM1_CH1N,,,,,,,,,,,FSMC_D5,,,EVENTOUT, +PE9,,TIM1_CH1,,,,,,,,,,,FSMC_D6,,,EVENTOUT, +PE10,,TIM1_CH2N,,,,,,,,,,,FSMC_D7,,,EVENTOUT, +PE11,,TIM1_CH2,,,,,,,,,,,FSMC_D8,,,EVENTOUT, +PE12,,TIM1_CH3N,,,,,,,,,,,FSMC_D9,,,EVENTOUT, +PE13,,TIM1_CH3,,,,,,,,,,,FSMC_D10,,,EVENTOUT, +PE14,,TIM1_CH4,,,,,,,,,,,FSMC_D11,,,EVENTOUT, +PE15,,TIM1_BKIN,,,,,,,,,,,FSMC_D12,,,EVENTOUT, +PF0,,,,,I2C2_SDA,,,,,,,,FSMC_A0,,,EVENTOUT, +PF1,,,,,I2C2_SCL,,,,,,,,FSMC_A1,,,EVENTOUT, +PF2,,,,,I2C2_SMBA,,,,,,,,FSMC_A2,,,EVENTOUT, +PF3,,,,,,,,,,,,,FSMC_A3,,,EVENTOUT,ADC3_IN9 +PF4,,,,,,,,,,,,,FSMC_A4,,,EVENTOUT,ADC3_IN14 +PF5,,,,,,,,,,,,,FSMC_A5,,,EVENTOUT,ADC3_IN15 +PF6,,,,TIM10_CH1,,,,,,,,,FSMC_NIORD,,,EVENTOUT,ADC3_IN4 +PF7,,,,TIM11_CH1,,,,,,,,,FSMC_NREG,,,EVENTOUT,ADC3_IN5 +PF8,,,,,,,,,,TIM13_CH1,,,FSMC_NIOWR,,,EVENTOUT,ADC3_IN6 +PF9,,,,,,,,,,TIM14_CH1,,,FSMC_CD,,,EVENTOUT,ADC3_IN7 +PF10,,,,,,,,,,,,,FSMC_INTR,,,EVENTOUT,ADC3_IN8 +PF11,,,,,,,,,,,,,,DCMI_D12,,EVENTOUT, +PF12,,,,,,,,,,,,,FSMC_A6,,,EVENTOUT, +PF13,,,,,,,,,,,,,FSMC_A7,,,EVENTOUT, +PF14,,,,,,,,,,,,,FSMC_A8,,,EVENTOUT, +PF15,,,,,,,,,,,,,FSMC_A9,,,EVENTOUT, +PG0,,,,,,,,,,,,,FSMC_A10,,,EVENTOUT, +PG1,,,,,,,,,,,,,FSMC_A11,,,EVENTOUT, +PG2,,,,,,,,,,,,,FSMC_A12,,,EVENTOUT, +PG3,,,,,,,,,,,,,FSMC_A13,,,EVENTOUT, +PG4,,,,,,,,,,,,,FSMC_A14,,,EVENTOUT, +PG5,,,,,,,,,,,,,FSMC_A15,,,EVENTOUT, +PG6,,,,,,,,,,,,,FSMC_INT2,,,EVENTOUT, +PG7,,,,,,,,,USART6_CK,,,,FSMC_INT3,,,EVENTOUT, +PG8,,,,,,,,,USART6_RTS,,,ETH_PPS_OUT,,,,EVENTOUT, +PG9,,,,,,,,,USART6_RX,,,,FSMC_NE2/FSMC_NCE3,,,EVENTOUT, +PG10,,,,,,,,,,,,,FSMC_NCE4_1/FSMC_NE3,,,EVENTOUT, +PG11,,,,,,,,,,,,ETH_MII_TX_EN/ETH_RMII_TX_EN,FSMC_NCE4_2,,,EVENTOUT, +PG12,,,,,,,,,USART6_RTS,,,,FSMC_NE4,,,EVENTOUT, +PG13,,,,,,,,,USART6_CTS,,,ETH_MII_TXD0/ETH_RMII_TXD0,FSMC_A24,,,EVENTOUT, +PG14,,,,,,,,,USART6_TX,,,ETH_MII_TXD1/ETH_RMII_TXD1,FSMC_A25,,,EVENTOUT, +PG15,,,,,,,,,USART6_CTS,,,,,DCMI_D13,,EVENTOUT, +PH0,,,,,,,,,,,,,,,,EVENTOUT, +PH1,,,,,,,,,,,,,,,,EVENTOUT, +PH2,,,,,,,,,,,,ETH_MII_CRS,,,,EVENTOUT, +PH3,,,,,,,,,,,,ETH_MII_COL,,,,EVENTOUT, +PH4,,,,,I2C2_SCL,,,,,,OTG_HS_ULPI_NXT,,,,,EVENTOUT, +PH5,,,,,I2C2_SDA,,,,,,,,,,,EVENTOUT, +PH6,,,,,I2C2_SMBA,,,,,TIM12_CH1,,ETH_MII_RXD2,,,,EVENTOUT, +PH7,,,,,I2C3_SCL,,,,,,,ETH_MII_RXD3,,,,EVENTOUT, +PH8,,,,,I2C3_SDA,,,,,,,,,DCMI_HSYNC,,EVENTOUT, +PH9,,,,,I2C3_SMBA,,,,,TIM12_CH2,,,,DCMI_D0,,EVENTOUT, +PH10,,,TIM5_CH1,,,,,,,,,,,DCMI_D1,,EVENTOUT, +PH11,,,TIM5_CH2,,,,,,,,,,,DCMI_D2,,EVENTOUT, +PH12,,,TIM5_CH3,,,,,,,,,,,DCMI_D3,,EVENTOUT, +PH13,,,,TIM8_CH1N,,,,,,CAN1_TX,,,,,,EVENTOUT, +PH14,,,,TIM8_CH2N,,,,,,,,,,DCMI_D4,,EVENTOUT, +PH15,,,,TIM8_CH3N,,,,,,,,,,DCMI_D11,,EVENTOUT, +PI0,,,TIM5_CH4,,,SPI2_NSS/I2S2_WS,,,,,,,,DCMI_D13,,EVENTOUT, +PI1,,,,,,SPI2_SCK/I2S2_CK,,,,,,,,DCMI_D8,,EVENTOUT, +PI2,,,,TIM8_CH4,,SPI2_MISO,I2S2ext_SD,,,,,,,DCMI_D9,,EVENTOUT, +PI3,,,,TIM8_ETR,,SPI2_MOSI/I2S2_SD,,,,,,,,DCMI_D10,,EVENTOUT, +PI4,,,,TIM8_BKIN,,,,,,,,,,DCMI_D5,,EVENTOUT, +PI5,,,,TIM8_CH1,,,,,,,,,,DCMI_VSYNC,,EVENTOUT, +PI6,,,,TIM8_CH2,,,,,,,,,,DCMI_D6,,EVENTOUT, +PI7,,,,TIM8_CH3,,,,,,,,,,DCMI_D7,,EVENTOUT, +PI8,,,,,,,,,,,,,,,,EVENTOUT, +PI9,,,,,,,,,,CAN1_RX,,,,,,EVENTOUT, +PI10,,,,,,,,,,,,ETH_MII_RX_ER,,,,EVENTOUT, +PI11,,,,,,,,,,,OTG_HS_ULPI_DIR,,,,,EVENTOUT, diff --git a/ports/stm/tools/examples/stm32l4r5zi.csv b/ports/stm/tools/examples/stm32l4r5zi.csv new file mode 100644 index 0000000000..37683c751f --- /dev/null +++ b/ports/stm/tools/examples/stm32l4r5zi.csv @@ -0,0 +1,141 @@ +Port,,AF0,AF1,AF2,AF3,AF4,AF5,AF6,AF7,AF8,AF9,AF10,AF11,AF12,AF13,AF14,AF15 +PA0,-,TIM2_CH1,TIM5_CH1,TIM8_ETR,-,-,-,USART2_CTS_NSS,,UART4_TX,-,-,-,-,SAI1_EXTCLK,TIM2_ETR,EVENTOUT +PA1,-,TIM2_CH2,TIM5_CH2,-,I2C1_SMBA,SPI1_SCK,-,USART2_RTS_DE,,UART4_RX,-,OCTOSPIM_P1_DQS,-,-,-,TIM15_CH1N,EVENTOUT +PA2,-,TIM2_CH3,TIM5_CH3,-,-,-,-,USART2_TX,,LPUART1_TX,-,OCTOSPIM_P1_NCS,-,-,SAI2_EXTCLK,TIM15_CH1,EVENTOUT +PA3,-,TIM2_CH4,TIM5_CH4,SAI1_CK1,-,-,-,USART2_RX,,LPUART1_RX,-,OCTOSPIM_P1_CLK,-,-,SAI1_MCLK_A,TIM15_CH2,EVENTOUT +PA4,-,-,-,OCTOSPIM_P1_NCS,-,SPI1_NSS,SPI3_NSS,USART2_CK,,-,-,DCMI_HSYNC,-,-,SAI1_FS_B,LPTIM2_OUT,EVENTOUT +PA5,-,TIM2_CH1,TIM2_ETR,TIM8_CH1N,-,SPI1_SCK,-,-,,-,-,-,-,-,-,LPTIM2_ETR,EVENTOUT +PA6,-,TIM1_BKIN,TIM3_CH1,TIM8_BKIN,DCMI_PIXCLK,SPI1_MISO,-,USART3_CTS_NSS,,LPUART1_CTS,-,OCTOSPIM_P1_IO3,-,TIM1_BKIN,TIM8_BKIN,TIM16_CH1,EVENTOUT +PA7,-,TIM1_CH1N,TIM3_CH2,TIM8_CH1N,I2C3_SCL,SPI1_MOSI,-,-,,-,-,OCTOSPIM_P1_IO2,-,-,-,TIM17_CH1,EVENTOUT +PA8,MCO,TIM1_CH1,-,SAI1_CK2,-,-,-,USART1_CK,,-,-,OTG_FS_SOF,-,-,SAI1_SCK_A,LPTIM2_OUT,EVENTOUT +PA9,-,TIM1_CH2,-,SPI2_SCK,-,DCMI_D0,-,USART1_TX,,-,-,-,-,-,SAI1_FS_A,TIM15_BKIN,EVENTOUT +PA10,-,TIM1_CH3,-,SAI1_D1,-,DCMI_D1,-,USART1_RX,,-,-,OTG_FS_ID,-,-,SAI1_SD_A,TIM17_BKIN,EVENTOUT +PA11,-,TIM1_CH4,TIM1_BKIN2,-,-,SPI1_MISO,-,USART1_CTS_NSS,,-,CAN1_RX,OTG_FS_DM,-,TIM1_BKIN2,-,-,EVENTOUT +PA12,-,TIM1_ETR,-,-,-,SPI1_MOSI,-,USART1_RTS_DE,,-,CAN1_TX,OTG_FS_DP,-,-,-,-,EVENTOUT +PA13,JTMS/SWDIO,IR_OUT,-,-,-,-,-,-,,-,-,OTG_FS_NOE,-,-,SAI1_SD_B,-,EVENTOUT +PA14,JTCK/SWCLK,LPTIM1_OUT,-,-,I2C1_SMBA,I2C4_SMBA,-,-,,-,-,OTG_FS_SOF,-,-,SAI1_FS_B,-,EVENTOUT +PA15,JTDI,TIM2_CH1,TIM2_ETR,USART2_RX,-,SPI1_NSS,SPI3_NSS,USART3_RTS_DE,,UART4_RTS_DE,TSC_G3_IO1,-,-,-,SAI2_FS_B,-,EVENTOUT +PB0,-,TIM1_CH2N,TIM3_CH3,TIM8_CH2N,-,SPI1_NSS,-,USART3_CK,,-,-,OCTOSPIM_P1_IO1,-,COMP1_OUT,SAI1_EXTCLK,-,EVENTOUT +PB1,-,TIM1_CH3N,TIM3_CH4,TIM8_CH3N,-,-,DFSDM1_DATIN0,USART3_RTS_DE,,LPUART1_RTS_DE,-,OCTOSPIM_P1_IO0,-,-,-,LPTIM2_IN1,EVENTOUT +PB2,RTC_OUT,LPTIM1_OUT,-,-,I2C3_SMBA,-,DFSDM1_CKIN0,-,,-,-,OCTOSPIM_P1_DQS,LCD_B1,-,-,-,EVENTOUT +PB3,JTDO/TRACESWO,TIM2_CH2,-,-,-,SPI1_SCK,SPI3_SCK,USART1_RTS_DE,,-,-,OTG_FS_CRS_SYNC,-,-,SAI1_SCK_B,-,EVENTOUT +PB4,NJTRST,-,TIM3_CH1,-,I2C3_SDA,SPI1_MISO,SPI3_MISO,USART1_CTS_NSS,,UART5_RTS_DE,TSC_G2_IO1,DCMI_D12,-,-,SAI1_MCLK_B,TIM17_BKIN,EVENTOUT +PB5,-,LPTIM1_IN1,TIM3_CH2,-,I2C1_SMBA,SPI1_MOSI,SPI3_MOSI,USART1_CK,,UART5_CTS,TSC_G2_IO2,DCMI_D10,-,COMP2_OUT,SAI1_SD_B,TIM16_BKIN,EVENTOUT +PB6,-,LPTIM1_ETR,TIM4_CH1,TIM8_BKIN2,I2C1_SCL,I2C4_SCL,DFSDM1_DATIN5,USART1_TX,,-,TSC_G2_IO3,DCMI_D5,-,TIM8_BKIN2,SAI1_FS_B,TIM16_CH1N,EVENTOUT +PB7,-,LPTIM1_IN2,TIM4_CH2,TIM8_BKIN,I2C1_SDA,I2C4_SDA,DFSDM1_CKIN5,USART1_RX,,UART4_CTS,TSC_G2_IO4,DCMI_VSYNC,DSI_TE,FMC_NL,TIM8_BKIN,TIM17_CH1N,EVENTOUT +PB8,-,-,TIM4_CH3,SAI1_CK1,I2C1_SCL,DFSDM1_CKOUT,DFSDM1_DATIN6,-,,SDMMC1_CKIN,CAN1_RX,DCMI_D6,LCD_B1,SDMMC1_D4,SAI1_MCLK_A,TIM16_CH1,EVENTOUT +PB9,-,IR_OUT,TIM4_CH4,SAI1_D2,I2C1_SDA,SPI2_NSS,DFSDM1_CKIN6,-,,SDMMC1_CDIR,CAN1_TX,DCMI_D7,-,SDMMC1_D5,SAI1_FS_A,TIM17_CH1,EVENTOUT +PB10,-,TIM2_CH3,-,I2C4_SCL,I2C2_SCL,SPI2_SCK,DFSDM1_DATIN7,USART3_TX,,LPUART1_RX,TSC_SYNC,OCTOSPIM_P1_CLK,-,COMP1_OUT,SAI1_SCK_A,-,EVENTOUT +PB11,-,TIM2_CH4,-,I2C4_SDA,I2C2_SDA,-,DFSDM1_CKIN7,USART3_RX,,LPUART1_TX,-,OCTOSPIM_P1_NCS,DSI_TE,COMP2_OUT,-,-,EVENTOUT +PB12,-,TIM1_BKIN,-,TIM1_BKIN,I2C2_SMBA,SPI2_NSS,DFSDM1_DATIN1,USART3_CK,,LPUART1_RTS_DE,TSC_G1_IO1,-,-,-,SAI2_FS_A,TIM15_BKIN,EVENTOUT +PB13,-,TIM1_CH1N,-,-,I2C2_SCL,SPI2_SCK,DFSDM1_CKIN1,USART3_CTS_NSS,,LPUART1_CTS,TSC_G1_IO2,-,-,-,SAI2_SCK_A,TIM15_CH1N,EVENTOUT +PB14,-,TIM1_CH2N,-,TIM8_CH2N,I2C2_SDA,SPI2_MISO,DFSDM1_DATIN2,USART3_RTS_DE,,-,TSC_G1_IO3,-,-,-,SAI2_MCLK_A,TIM15_CH1,EVENTOUT +PB15,RTC_REFIN,TIM1_CH3N,-,TIM8_CH3N,-,SPI2_MOSI,DFSDM1_CKIN2,-,,-,TSC_G1_IO4,-,-,-,SAI2_SD_A,TIM15_CH2,EVENTOUT +PC0,-,LPTIM1_IN1,-,-,I2C3_SCL,-,DFSDM1_DATIN4,-,,LPUART1_RX,-,-,-,-,SAI2_FS_A,LPTIM2_IN1,EVENTOUT +PC1,TRACED0,LPTIM1_OUT,-,SPI2_MOSI,I2C3_SDA,-,DFSDM1_CKIN4,-,,LPUART1_TX,-,OCTOSPIM_P1_IO4,-,-,SAI1_SD_A,-,EVENTOUT +PC2,-,LPTIM1_IN2,-,-,-,SPI2_MISO,DFSDM1_CKOUT,-,,-,-,OCTOSPIM_P1_IO5,-,-,-,-,EVENTOUT +PC3,-,LPTIM1_ETR,-,SAI1_D1,-,SPI2_MOSI,-,-,,-,-,OCTOSPIM_P1_IO6,-,-,SAI1_SD_A,LPTIM2_ETR,EVENTOUT +PC4,-,-,-,-,-,-,-,USART3_TX,,-,-,OCTOSPIM_P1_IO7,-,-,-,-,EVENTOUT +PC5,-,-,-,SAI1_D3,-,-,-,USART3_RX,,-,-,-,-,-,-,-,EVENTOUT +PC6,-,-,TIM3_CH1,TIM8_CH1,-,-,DFSDM1_CKIN3,-,,SDMMC1_D0DIR,TSC_G4_IO1,DCMI_D0,LCD_R0,SDMMC1_D6,SAI2_MCLK_A,-,EVENTOUT +PC7,-,-,TIM3_CH2,TIM8_CH2,-,-,DFSDM1_DATIN3,-,,SDMMC1_D123DIR,TSC_G4_IO2,DCMI_D1,LCD_R1,SDMMC1_D7,SAI2_MCLK_B,-,EVENTOUT +PC8,-,-,TIM3_CH3,TIM8_CH3,-,-,-,-,,-,TSC_G4_IO3,DCMI_D2,-,SDMMC1_D0,-,-,EVENTOUT +PC9,TRACED0,TIM8_BKIN2,TIM3_CH4,TIM8_CH4,DCMI_D3,-,I2C3_SDA,-,,-,TSC_G4_IO4,OTG_FS_NOE,-,SDMMC1_D1,SAI2_EXTCLK,TIM8_BKIN2,EVENTOUT +PC10,TRACED1,-,-,-,-,-,SPI3_SCK,USART3_TX,,UART4_TX,TSC_G3_IO2,DCMI_D8,-,SDMMC1_D2,SAI2_SCK_B,-,EVENTOUT +PC11,-,-,-,-,DCMI_D2,OCTOSPIM_P1_NCS,SPI3_MISO,USART3_RX,,UART4_RX,TSC_G3_IO3,DCMI_D4,-,SDMMC1_D3,SAI2_MCLK_B,-,EVENTOUT +PC12,TRACED3,-,-,-,-,-,SPI3_MOSI,USART3_CK,,UART5_TX,TSC_G3_IO4,DCMI_D9,-,SDMMC1_CK,SAI2_SD_B,-,EVENTOUT +PC13,-,-,-,-,-,-,-,-,,-,-,-,-,-,-,-,EVENTOUT +PC14,-,-,-,-,-,-,-,-,,-,-,-,-,-,-,-,EVENTOUT +PC15,-,-,-,-,-,-,-,-,,-,-,-,-,-,-,-,EVENTOUT +PD0,-,-,-,-,-,SPI2_NSS,DFSDM1_DATIN7,-,,-,CAN1_RX,-,LCD_B4,FMC_D2,-,-,EVENTOUT +PD1,-,-,-,-,-,SPI2_SCK,DFSDM1_CKIN7,-,,-,CAN1_TX,-,LCD_B5,FMC_D3,-,-,EVENTOUT +PD2,TRACED2,-,TIM3_ETR,-,-,-,-,USART3_RTS_DE,,UART5_RX,TSC_SYNC,DCMI_D11,-,SDMMC1_CMD,-,-,EVENTOUT +PD3,-,-,-,SPI2_SCK,DCMI_D5,SPI2_MISO,DFSDM1_DATIN0,USART2_CTS_NSS,,-,-,OCTOSPIM_P2_NCS,LCD_CLK,FMC_CLK,-,-,EVENTOUT +PD4,-,-,-,-,-,SPI2_MOSI,DFSDM1_CKIN0,USART2_RTS_DE,,-,-,OCTOSPIM_P1_IO4,-,FMC_NOE,-,-,EVENTOUT +PD5,-,-,-,-,-,-,-,USART2_TX,,-,-,OCTOSPIM_P1_IO5,-,FMC_NWE,-,-,EVENTOUT +PD6,-,-,-,SAI1_D1,DCMI_D10,SPI3_MOSI,DFSDM1_DATIN1,USART2_RX,,-,-,OCTOSPIM_P1_IO6,LCD_DE,FMC_NWAIT,SAI1_SD_A,-,EVENTOUT +PD7,-,-,-,-,-,-,DFSDM1_CKIN1,USART2_CK,,-,-,OCTOSPIM_P1_IO7,-,FMC_NCE/FMC_NE1,-,-,EVENTOUT +PD8,-,-,-,-,-,-,-,USART3_TX,,-,-,DCMI_HSYNC,LCD_R3,FMC_D13,-,-,EVENTOUT +PD9,-,-,-,-,-,-,-,USART3_RX,,-,-,DCMI_PIXCLK,LCD_R4,FMC_D14,SAI2_MCLK_A,-,EVENTOUT +PD10,-,-,-,-,-,-,-,USART3_CK,,-,TSC_G6_IO1,-,LCD_R5,FMC_D15,SAI2_SCK_A,-,EVENTOUT +PD11,-,-,-,-,I2C4_SMBA,-,-,USART3_CTS_NSS,,-,TSC_G6_IO2,-,LCD_R6,FMC_A16,SAI2_SD_A,LPTIM2_ETR,EVENTOUT +PD12,-,-,TIM4_CH1,-,I2C4_SCL,-,-,USART3_RTS_DE,,-,TSC_G6_IO3,-,LCD_R7,FMC_A17,SAI2_FS_A,LPTIM2_IN1,EVENTOUT +PD13,-,-,TIM4_CH2,-,I2C4_SDA,-,-,-,,-,TSC_G6_IO4,-,-,FMC_A18,-,LPTIM2_OUT,EVENTOUT +PD14,-,-,TIM4_CH3,-,-,-,-,-,,-,-,-,LCD_B2,FMC_D0,-,-,EVENTOUT +PD15,-,-,TIM4_CH4,-,-,-,-,-,,-,-,-,LCD_B3,FMC_D1,-,-,EVENTOUT +PE0,-,-,TIM4_ETR,-,-,-,-,-,,-,-,DCMI_D2,LCD_HSYNC,FMC_NBL0,-,TIM16_CH1,EVENTOUT +PE1,-,-,-,-,-,-,-,-,,-,-,DCMI_D3,LCD_VSYNC,FMC_NBL1,-,TIM17_CH1,EVENTOUT +PE2,TRACECK,-,TIM3_ETR,SAI1_CK1,-,-,-,-,,-,TSC_G7_IO1,-,LCD_R0,FMC_A23,SAI1_MCLK_A,-,EVENTOUT +PE3,TRACED0,-,TIM3_CH1,OCTOSPIM_P1_DQS,-,-,-,-,,-,TSC_G7_IO2,-,LCD_R1,FMC_A19,SAI1_SD_B,-,EVENTOUT +PE4,TRACED1,-,TIM3_CH2,SAI1_D2,-,-,DFSDM1_DATIN3,-,,-,TSC_G7_IO3,DCMI_D4,LCD_B0,FMC_A20,SAI1_FS_A,-,EVENTOUT +PE5,TRACED2,-,TIM3_CH3,SAI1_CK2,-,-,DFSDM1_CKIN3,-,,-,TSC_G7_IO4,DCMI_D6,LCD_G0,FMC_A21,SAI1_SCK_A,-,EVENTOUT +PE6,TRACED3,-,TIM3_CH4,SAI1_D1,-,-,-,-,,-,-,DCMI_D7,LCD_G1,FMC_A22,SAI1_SD_A,-,EVENTOUT +PE7,-,TIM1_ETR,-,-,-,-,DFSDM1_DATIN2,-,,-,-,-,LCD_B6,FMC_D4,SAI1_SD_B,-,EVENTOUT +PE8,-,TIM1_CH1N,-,-,-,-,DFSDM1_CKIN2,-,,-,-,-,LCD_B7,FMC_D5,SAI1_SCK_B,-,EVENTOUT +PE9,-,TIM1_CH1,-,-,-,-,DFSDM1_CKOUT,-,,-,-,-,LCD_G2,FMC_D6,SAI1_FS_B,-,EVENTOUT +PE10,-,TIM1_CH2N,-,-,-,-,DFSDM1_DATIN4,-,,-,TSC_G5_IO1,OCTOSPIM_P1_CLK,LCD_G3,FMC_D7,SAI1_MCLK_B,-,EVENTOUT +PE11,-,TIM1_CH2,-,-,-,-,DFSDM1_CKIN4,-,,-,TSC_G5_IO2,OCTOSPIM_P1_NCS,LCD_G4,FMC_D8,-,-,EVENTOUT +PE12,-,TIM1_CH3N,-,-,-,SPI1_NSS,DFSDM1_DATIN5,-,,-,TSC_G5_IO3,OCTOSPIM_1_IO0,LCD_G5,FMC_D9,-,-,EVENTOUT +PE13,-,TIM1_CH3,-,-,-,SPI1_SCK,DFSDM1_CKIN5,-,,-,TSC_G5_IO4,OCTOSPIM_P1_IO1,LCD_G6,FMC_D10,-,-,EVENTOUT +PE14,-,TIM1_CH4,TIM1_BKIN2,TIM1_BKIN2,-,SPI1_MISO,-,-,,-,-,OCTOSPIM_P1_IO2,LCD_G7,FMC_D11,-,-,EVENTOUT +PE15,-,TIM1_BKIN,-,TIM1_BKIN,-,SPI1_MOSI,-,-,,-,-,OCTOSPIM_P1_IO3,LCD_R2,FMC_D12,-,-,EVENTOUT +PF0,-,-,-,-,I2C2_SDA,OCTOSPIM_P2_IO0,-,-,,-,-,-,-,FMC_A0,-,-,EVENTOUT +PF1,-,-,-,-,I2C2_SCL,OCTOSPIM_P2_IO1,-,-,,-,-,-,-,FMC_A1,-,-,EVENTOUT +PF2,-,-,-,-,I2C2_SMBA,OCTOSPIM_P2_IO2,-,-,,-,-,-,-,FMC_A2,-,-,EVENTOUT +PF3,-,-,-,-,-,OCTOSPIM_P2_IO3,-,-,,-,-,-,-,FMC_A3,-,-,EVENTOUT +PF4,-,-,-,-,-,OCTOSPIM_P2_CLK,-,-,,-,-,-,-,FMC_A4,-,-,EVENTOUT +PF5,-,-,-,-,-,-,-,-,,-,-,-,-,FMC_A5,-,-,EVENTOUT +PF6,-,TIM5_ETR,TIM5_CH1,-,-,-,-,-,,-,-,OCTOSPIM_P1_IO3,-,-,SAI1_SD_B,-,EVENTOUT +PF7,-,-,TIM5_CH2,-,-,-,-,-,,-,-,OCTOSPIM_P1_IO2,-,-,SAI1_MCLK_B,-,EVENTOUT +PF8,-,-,TIM5_CH3,-,-,-,-,-,,-,-,OCTOSPIM_P1_IO0,-,-,SAI1_SCK_B,-,EVENTOUT +PF9,-,-,TIM5_CH4,-,-,-,-,-,,-,-,OCTOSPIM_P1_IO1,-,-,SAI1_FS_B,TIM15_CH1,EVENTOUT +PF10,-,-,-,OCTOSPIM_P1_CLK,-,-,DFSDM1_CKOUT,-,,-,-,DCMI_D11,-,-,SAI1_D3,TIM15_CH2,EVENTOUT +PF11,-,-,-,-,-,-,-,-,,-,LCD_DE,DCMI_D12,DSI_TE,-,-,-,EVENTOUT +PF12,-,-,-,-,-,OCTOSPIM_P2_DQS,-,-,,-,-,-,LCD_B0,FMC_A6,-,-,EVENTOUT +PF13,-,-,-,-,I2C4_SMBA,-,DFSDM1_DATIN6,-,,-,-,-,LCD_B1,FMC_A7,-,-,EVENTOUT +PF14,-,-,-,-,I2C4_SCL,-,DFSDM1_CKIN6,-,,-,TSC_G8_IO1,-,LCD_G0,FMC_A8,-,-,EVENTOUT +PF15,-,-,-,-,I2C4_SDA,-,-,-,,-,TSC_G8_IO2,-,LCD_G1,FMC_A9,-,-,EVENTOUT +PG0,-,-,-,-,-,OCTOSPIM_P2_IO4,-,-,,-,TSC_G8_IO3,-,-,FMC_A10,-,-,EVENTOUT +PG1,-,-,-,-,-,OCTOSPIM_P2_IO5,-,-,,-,TSC_G8_IO4,-,-,FMC_A11,-,-,EVENTOUT +PG2,-,-,-,-,-,SPI1_SCK,-,-,,-,-,-,-,FMC_A12,SAI2_SCK_B,-,EVENTOUT +PG3,-,-,-,-,-,SPI1_MISO,-,-,,-,-,-,-,FMC_A13,SAI2_FS_B,-,EVENTOUT +PG4,-,-,-,-,-,SPI1_MOSI,-,-,,-,-,-,-,FMC_A14,SAI2_MCLK_B,-,EVENTOUT +PG5,-,-,-,-,-,SPI1_NSS,-,-,,LPUART1_CTS,-,-,-,FMC_A15,SAI2_SD_B,-,EVENTOUT +PG6,-,-,-,OCTOSPIM_P1_DQS,I2C3_SMBA,-,-,-,,LPUART1_RTS_DE,LCD_R1,-,DSI_TE,-,-,-,EVENTOUT +PG7,-,-,-,SAI1_CK1,I2C3_SCL,OCTOSPIM_P2_DQS,DFSDM1_CKOUT,-,,LPUART1_TX,-,-,-,FMC_INT,SAI1_MCLK_A,-,EVENTOUT +PG8,-,-,-,-,I2C3_SDA,-,-,-,,LPUART1_RX,-,-,-,-,-,-,EVENTOUT +PG9,-,-,-,-,-,OCTOSPIM_P2_IO6,SPI3_SCK,USART1_TX,,-,-,-,-,FMC_NCE/FMC_NE2,SAI2_SCK_A,TIM15_CH1N,EVENTOUT +PG10,-,LPTIM1_IN1,-,-,-,OCTOSPIM_P2_IO7,SPI3_MISO,USART1_RX,,-,-,-,-,FMC_NE3,SAI2_FS_A,TIM15_CH1,EVENTOUT +PG11,-,LPTIM1_IN2,-,OCTOSPIM_P1_IO5,-,-,SPI3_MOSI,USART1_CTS_NSS,,-,-,-,-,-,SAI2_MCLK_A,TIM15_CH2,EVENTOUT +PG12,-,LPTIM1_ETR,-,-,-,OCTOSPIM_P2_NCS,SPI3_NSS,USART1_RTS_DE,,-,-,-,-,FMC_NE4,SAI2_SD_A,-,EVENTOUT +PG13,-,-,-,-,I2C1_SDA,-,-,USART1_CK,,-,-,-,LCD_R0,FMC_A24,-,-,EVENTOUT +PG14,-,-,-,-,I2C1_SCL,-,-,-,,-,-,-,LCD_R1,FMC_A25,-,-,EVENTOUT +PG15,-,LPTIM1_OUT,-,-,I2C1_SMBA,OCTOSPIM_P2_DQS,-,-,,-,-,DCMI_D13,-,-,-,-,EVENTOUT +PH0,-,-,-,-,-,-,-,-,,-,-,-,-,-,-,-,EVENTOUT +PH1,-,-,-,-,-,-,-,-,,-,-,-,-,-,-,-,EVENTOUT +PH2,-,-,-,OCTOSPIM_P1_IO4,-,-,-,-,,-,-,-,-,-,-,-,EVENTOUT +PH3,-,-,-,-,-,-,-,-,,-,-,-,-,-,-,-,EVENTOUT +PH4,-,-,-,-,I2C2_SCL,OCTOSPIM_P2_DQS,-,-,,-,-,-,-,-,-,-,EVENTOUT +PH5,-,-,-,-,I2C2_SDA,-,-,-,,-,-,DCMI_PIXCLK,-,-,-,-,EVENTOUT +PH6,-,-,-,-,I2C2_SMBA,OCTOSPIM_P2_CLK,-,-,,-,-,DCMI_D8,-,-,-,-,EVENTOUT +PH7,-,-,-,-,I2C3_SCL,-,-,-,,-,-,DCMI_D9,-,-,-,-,EVENTOUT +PH8,-,-,-,-,I2C3_SDA,OCTOSPIM_P2_IO3,-,-,,-,-,DCMI_HSYNC,-,-,-,-,EVENTOUT +PH9,-,-,-,-,I2C3_SMBA,OCTOSPIM_P2_IO4,-,-,,-,-,DCMI_D0,-,-,-,-,EVENTOUT +PH10,-,-,TIM5_CH1,-,-,OCTOSPIM_P2_IO5,-,-,,-,-,DCMI_D1,-,-,-,-,EVENTOUT +PH11,-,-,TIM5_CH2,-,-,OCTOSPIM_P2_IO6,-,-,,-,-,DCMI_D2,-,-,-,-,EVENTOUT +PH12,-,-,TIM5_CH3,-,-,OCTOSPIM_P2_IO7,-,-,,-,-,DCMI_D3,-,-,-,-,EVENTOUT +PH13,-,-,-,TIM8_CH1N,-,-,-,-,,-,CAN1_TX,-,-,-,-,-,EVENTOUT +PH14,-,-,-,TIM8_CH2N,-,-,-,-,,-,-,DCMI_D4,-,-,-,-,EVENTOUT +PH15,-,-,-,TIM8_CH3N,-,OCTOSPIM_P2_IO6,-,-,,-,-,DCMI_D11,-,-,-,-,EVENTOUT +PI0,-,-,TIM5_CH4,OCTOSPIM_P1_IO5,-,SPI2_NSS,-,-,,-,-,DCMI_D13,-,-,-,-,EVENTOUT +PI1,-,-,-,-,-,SPI2_SCK,-,-,,-,-,DCMI_D8,-,-,-,-,EVENTOUT +PI2,-,-,-,TIM8_CH4,-,SPI2_MISO,-,-,,-,-,DCMI_D9,-,-,-,-,EVENTOUT +PI3,-,-,-,TIM8_ETR,-,SPI2_MOSI,-,-,,-,-,DCMI_D10,-,-,-,-,EVENTOUT +PI4,-,-,-,TIM8_BKIN,-,-,-,-,,-,-,DCMI_D5,-,-,-,-,EVENTOUT +PI5,-,-,-,TIM8_CH1,-,OCTOSPIM_P2_NCS,-,-,,-,-,DCMI_VSYNC,-,-,-,-,EVENTOUT +PI6,-,-,-,TIM8_CH2,-,OCTOSPIM_P2_CLK,-,-,,-,-,DCMI_D6,-,-,-,-,EVENTOUT +PI7,-,-,-,TIM8_CH3,-,-,-,-,,-,-,DCMI_D7,-,-,-,-,EVENTOUT +PI8,-,-,-,-,-,OCTOSPIM_P2_NCS,-,-,,-,-,DCMI_D12,-,-,-,-,EVENTOUT +PI9,-,-,-,-,-,OCTOSPIM_P2_IO2,-,-,,-,CAN1_RX,-,-,-,-,-,EVENTOUT +PI10,-,-,-,-,-,OCTOSPIM_P2_IO1,-,-,,-,-,-,-,-,-,-,EVENTOUT +PI11,-,-,-,-,-,OCTOSPIM_P2_IO0,-,-,,-,-,-,-,-,-,-,EVENTOUT diff --git a/ports/stm/tools/parse_af_csv.py b/ports/stm/tools/parse_af_csv.py index 38608b5dac..3e48d4145d 100644 --- a/ports/stm/tools/parse_af_csv.py +++ b/ports/stm/tools/parse_af_csv.py @@ -25,7 +25,7 @@ import csv import sys -# Use: parse_af_csf.py Filename.csv -pins-only +# Use: parse_af_csv.py Filename.csv -pins-only # Designed for use with .csv files from Micropython, or in identical format # created via Datasheet peripheral tables with a Sheets program. # @@ -70,6 +70,7 @@ with open(sys.argv[1]) as csv_file: ["SPI", "SCK"], ["SPI", "MOSI"], ["SPI", "MISO"], + ["SPI", "NSS"], ["UART", "TX"], ["UART", "RX"], ] @@ -86,22 +87,22 @@ with open(sys.argv[1]) as csv_file: # Each line is a list of strings for row in csv_reader: altfn = 0 - pin = row[1] - if len(pin) < 4: + pin = row[0] + if len(pin) < 4: # add additional leading 0 to pin number after port pin = pin[:2] + "0" + pin[2:] for col in row: array_index = 0 # Evaluate the string for every possible todo entry for item in todo: - evaluate_periph(col, outlist[array_index], item[0], item[1], altfn - 2, pin) + evaluate_periph(col, outlist[array_index], item[0], item[1], altfn - 1, pin) # UART special case, run again for USART variant if item[0] == "UART": evaluate_periph( - col, outlist[array_index], "USART", item[1], altfn - 2, pin + col, outlist[array_index], "USART", item[1], altfn - 1, pin ) array_index += 1 # TIM special case - evaluate_tim(col, outlist[-1], altfn - 2, pin) + evaluate_tim(col, outlist[-1], altfn - 1, pin) altfn += 1 line_count += 1 @@ -139,10 +140,10 @@ with open(sys.argv[1]) as csv_file: for row in csv_reader: altfn = 0 - pin = row[1] + pin = row[0] if len(pin) < 4: pin = pin[:2] + "0" + pin[2:] - outlist.append([pin, str(ord(row[1][1:2]) - 65), row[1][2:4]]) + outlist.append([pin, str(ord(pin[1:2]) - 65), pin[2:4]]) line_count += 1 for line in outlist: @@ -159,4 +160,4 @@ with open(sys.argv[1]) as csv_file: for line in outlist: print("extern const mcu_pin_obj_t pin_" + line[0] + ";") - print(f"Processed {line_count} lines.") + print("Processed %d lines." % line_count) diff --git a/ports/unix/Makefile b/ports/unix/Makefile index ec60d8d2ad..344ebdb423 100644 --- a/ports/unix/Makefile +++ b/ports/unix/Makefile @@ -112,9 +112,9 @@ endif endif ifeq ($(MICROPY_USE_READLINE),1) -INC += -I$(TOP)/lib/mp-readline +INC += -I$(TOP)/shared/readline CFLAGS_MOD += -DMICROPY_USE_READLINE=1 -LIB_SRC_C_EXTRA += mp-readline/readline.c +SHARED_SRC_C_EXTRA += readline/readline.c endif ifeq ($(MICROPY_PY_TERMIOS),1) CFLAGS_MOD += -DMICROPY_PY_TERMIOS=1 @@ -129,6 +129,62 @@ CFLAGS_MOD += -DMICROPY_PY_THREAD=1 -DMICROPY_PY_THREAD_GIL=0 LDFLAGS_MOD += $(LIBPTHREAD) endif +# If the variant enables it, enable modbluetooth. +ifeq ($(MICROPY_PY_BLUETOOTH),1) + +HAVE_LIBUSB := $(shell (which pkg-config > /dev/null && pkg-config --exists libusb-1.0) 2>/dev/null && echo '1') + +# Only one stack can be enabled. +ifeq ($(MICROPY_BLUETOOTH_NIMBLE),1) +ifeq ($(MICROPY_BLUETOOTH_BTSTACK),1) +$(error Cannot enable both NimBLE and BTstack at the same time) +endif +endif + +# Default to btstack, but a variant (or make command line) can set NimBLE +# explicitly (which is always via H4 UART). +ifneq ($(MICROPY_BLUETOOTH_NIMBLE),1) +ifneq ($(MICROPY_BLUETOOTH_BTSTACK),1) +MICROPY_BLUETOOTH_BTSTACK ?= 1 +endif +endif + +CFLAGS_MOD += -DMICROPY_PY_BLUETOOTH=1 +CFLAGS_MOD += -DMICROPY_PY_BLUETOOTH_ENABLE_CENTRAL_MODE=1 + +ifeq ($(MICROPY_BLUETOOTH_BTSTACK),1) + +# Figure out which BTstack transport to use. +ifeq ($(MICROPY_BLUETOOTH_BTSTACK_H4),1) +ifeq ($(MICROPY_BLUETOOTH_BTSTACK_USB),1) +$(error Cannot enable BTstack support for USB and H4 UART at the same time) +endif +else +ifeq ($(HAVE_LIBUSB),1) +# Default to btstack-over-usb. +MICROPY_BLUETOOTH_BTSTACK_USB ?= 1 +else +# Fallback to HCI controller via a H4 UART (e.g. Zephyr on nRF) over a /dev/tty serial port. +MICROPY_BLUETOOTH_BTSTACK_H4 ?= 1 +endif +endif + +# BTstack is enabled. +GIT_SUBMODULES += lib/btstack +include $(TOP)/extmod/btstack/btstack.mk +SRC_BTSTACK += lib/btstack/platform/embedded/btstack_run_loop_embedded.c + +else + +# NimBLE is enabled. +GIT_SUBMODULES += lib/mynewt-nimble +CFLAGS_MOD += -DMICROPY_PY_BLUETOOTH_ENABLE_L2CAP_CHANNELS=1 +include $(TOP)/extmod/nimble/nimble.mk + +endif + +endif + ifeq ($(MICROPY_PY_FFI),1) ifeq ($(MICROPY_STANDALONE),1) @@ -178,10 +234,10 @@ SRC_C += \ $(SRC_MOD) \ $(wildcard $(VARIANT_DIR)/*.c) -LIB_SRC_C += $(addprefix lib/,\ - $(LIB_SRC_C_EXTRA) \ +SHARED_SRC_C += $(addprefix shared/,\ + runtime/gchelper_generic.c \ timeutils/timeutils.c \ - utils/gchelper_generic.c \ + $(SHARED_SRC_C_EXTRA) \ ) SRC_CXX += \ @@ -190,11 +246,12 @@ SRC_CXX += \ OBJ = $(PY_O) OBJ += $(addprefix $(BUILD)/, $(SRC_C:.c=.o)) OBJ += $(addprefix $(BUILD)/, $(SRC_CXX:.cpp=.o)) -OBJ += $(addprefix $(BUILD)/, $(LIB_SRC_C:.c=.o)) +OBJ += $(addprefix $(BUILD)/, $(SHARED_SRC_C:.c=.o)) OBJ += $(addprefix $(BUILD)/, $(EXTMOD_SRC_C:.c=.o)) +OBJ += $(addprefix $(BUILD)/, $(LIB_SRC_C:.c=.o)) # List of sources for qstr extraction -SRC_QSTR += $(SRC_C) $(SRC_CXX) $(LIB_SRC_C) $(EXTMOD_SRC_C) +SRC_QSTR += $(SRC_C) $(SRC_CXX) $(SHARED_SRC_C) $(EXTMOD_SRC_C) # Append any auto-generated sources that are needed by sources listed in # SRC_QSTR SRC_QSTR_AUTO_DEPS += @@ -221,6 +278,17 @@ else RUN_TESTS_MPY_CROSS_FLAGS = --mpy-cross-flags='-mcache-lookup-bc' endif +ifeq ($(CROSS_COMPILE),arm-linux-gnueabi-) +# Force disable error text compression when compiling for ARM as the compiler +# cannot optimise out the giant strcmp list generated for MP_MATCH_COMPRESSED. +# Checked on: +# arm-linux-gnueabi-gcc (Ubuntu/Linaro 7.5.0-3ubuntu1~18.04) 7.5.0 +# arm-linux-gnueabi-gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0 +# See https://github.com/micropython/micropython/pull/7659 for details. +$(info Detected arm-linux-gnueabi-gcc. Disabling error message compression.) +MICROPY_ROM_TEXT_COMPRESSION = 0 +endif + include $(TOP)/py/mkrules.mk .PHONY: test test_full diff --git a/ports/unix/displayio_colorspace_only.c b/ports/unix/displayio_colorspace_only.c new file mode 100644 index 0000000000..40325ec76a --- /dev/null +++ b/ports/unix/displayio_colorspace_only.c @@ -0,0 +1,90 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Jeff Epler 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/enum.h" +#include "py/obj.h" +#include "py/runtime.h" + +#include "shared-bindings/displayio/__init__.h" + +MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, RGB888, DISPLAYIO_COLORSPACE_RGB888); +MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, RGB565, DISPLAYIO_COLORSPACE_RGB565); +MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, RGB565_SWAPPED, DISPLAYIO_COLORSPACE_RGB565_SWAPPED); +MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, RGB555, DISPLAYIO_COLORSPACE_RGB555); +MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, RGB555_SWAPPED, DISPLAYIO_COLORSPACE_RGB555_SWAPPED); +MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, BGR565, DISPLAYIO_COLORSPACE_BGR565); +MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, BGR565_SWAPPED, DISPLAYIO_COLORSPACE_BGR565_SWAPPED); +MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, BGR555, DISPLAYIO_COLORSPACE_BGR555); +MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, BGR555_SWAPPED, DISPLAYIO_COLORSPACE_BGR555_SWAPPED); +MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, L8, DISPLAYIO_COLORSPACE_L8); + +//| class Colorspace: +//| """The colorspace for a `ColorConverter` to operate in""" +//| +//| RGB888: Colorspace +//| """The standard 24-bit colorspace. Bits 0-7 are blue, 8-15 are green, and 16-24 are red. (0xRRGGBB)""" +//| +//| RGB565: Colorspace +//| """The standard 16-bit colorspace. Bits 0-4 are blue, bits 5-10 are green, and 11-15 are red (0bRRRRRGGGGGGBBBBB)""" +//| +//| RGB565_SWAPPED: Colorspace +//| """The swapped 16-bit colorspace. First, the high and low 8 bits of the number are swapped, then they are interpreted as for RGB565""" +//| +//| RGB555: Colorspace +//| """The standard 15-bit colorspace. Bits 0-4 are blue, bits 5-9 are green, and 11-14 are red. The top bit is ignored. (0bxRRRRRGGGGGBBBBB)""" +//| +//| RGB555_SWAPPED: Colorspace +//| """The swapped 15-bit colorspace. First, the high and low 8 bits of the number are swapped, then they are interpreted as for RGB555""" +//| +MAKE_ENUM_MAP(displayio_colorspace) { + MAKE_ENUM_MAP_ENTRY(displayio_colorspace, RGB888), + MAKE_ENUM_MAP_ENTRY(displayio_colorspace, RGB565), + MAKE_ENUM_MAP_ENTRY(displayio_colorspace, RGB565_SWAPPED), + MAKE_ENUM_MAP_ENTRY(displayio_colorspace, RGB555), + MAKE_ENUM_MAP_ENTRY(displayio_colorspace, RGB555_SWAPPED), + MAKE_ENUM_MAP_ENTRY(displayio_colorspace, BGR565), + MAKE_ENUM_MAP_ENTRY(displayio_colorspace, BGR565_SWAPPED), + MAKE_ENUM_MAP_ENTRY(displayio_colorspace, BGR555), + MAKE_ENUM_MAP_ENTRY(displayio_colorspace, BGR555_SWAPPED), + MAKE_ENUM_MAP_ENTRY(displayio_colorspace, L8), +}; +STATIC MP_DEFINE_CONST_DICT(displayio_colorspace_locals_dict, displayio_colorspace_locals_table); + +MAKE_PRINTER(displayio, displayio_colorspace); +MAKE_ENUM_TYPE(displayio, ColorSpace, displayio_colorspace); + +STATIC const mp_rom_map_elem_t displayio_module_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_displayio) }, + { MP_ROM_QSTR(MP_QSTR_Colorspace), MP_ROM_PTR(&displayio_colorspace_type) }, +}; +STATIC MP_DEFINE_CONST_DICT(displayio_module_globals, displayio_module_globals_table); + +const mp_obj_module_t displayio_module = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t *)&displayio_module_globals, +}; + +MP_REGISTER_MODULE(MP_QSTR_displayio, displayio_module, CIRCUITPY_DISPLAYIO_COLORSPACE_ONLY); diff --git a/ports/unix/gccollect.c b/ports/unix/gccollect.c index 5e438b258b..d9ac53d7f8 100644 --- a/ports/unix/gccollect.c +++ b/ports/unix/gccollect.c @@ -29,7 +29,7 @@ #include "py/mpstate.h" #include "py/gc.h" -#include "lib/utils/gchelper.h" +#include "shared/runtime/gchelper.h" #if MICROPY_ENABLE_GC diff --git a/ports/unix/input.c b/ports/unix/input.c index f85bb177f0..d66487a7af 100644 --- a/ports/unix/input.c +++ b/ports/unix/input.c @@ -35,7 +35,7 @@ #include "input.h" #if MICROPY_USE_READLINE == 1 -#include "lib/mp-readline/readline.h" +#include "shared/readline/readline.h" #endif #if MICROPY_USE_READLINE == 0 diff --git a/ports/unix/main.c b/ports/unix/main.c index 55bdc22082..c1cf6a7ffa 100644 --- a/ports/unix/main.c +++ b/ports/unix/main.c @@ -158,7 +158,7 @@ STATIC int execute_from_lexer(int source_kind, const void *source, mp_parse_inpu } #if MICROPY_USE_READLINE == 1 -#include "lib/mp-readline/readline.h" +#include "shared/readline/readline.h" #else STATIC char *strjoin(const char *s1, int sep_char, const char *s2) { int l1 = strlen(s1); diff --git a/ports/unix/modffi.c b/ports/unix/modffi.c index 81dcb57d5d..d1966c51f0 100644 --- a/ports/unix/modffi.c +++ b/ports/unix/modffi.c @@ -36,6 +36,7 @@ #include "py/binary.h" #include "py/mperrno.h" #include "py/objint.h" +#include "py/gc.h" #include "supervisor/shared/translate.h" @@ -102,6 +103,7 @@ typedef struct _mp_obj_fficallback_t { void *func; ffi_closure *clo; char rettype; + mp_obj_t pyfunc; ffi_cif cif; ffi_type *params[]; } mp_obj_fficallback_t; @@ -268,19 +270,69 @@ STATIC mp_obj_t mod_ffi_func(mp_obj_t rettype, mp_obj_t addr_in, mp_obj_t argtyp } MP_DEFINE_CONST_FUN_OBJ_3(mod_ffi_func_obj, mod_ffi_func); -STATIC void call_py_func(ffi_cif *cif, void *ret, void **args, void *func) { +STATIC void call_py_func(ffi_cif *cif, void *ret, void **args, void *user_data) { mp_obj_t pyargs[cif->nargs]; + mp_obj_fficallback_t *o = user_data; + mp_obj_t pyfunc = o->pyfunc; + for (uint i = 0; i < cif->nargs; i++) { pyargs[i] = mp_obj_new_int(*(mp_int_t *)args[i]); } - mp_obj_t res = mp_call_function_n_kw(MP_OBJ_FROM_PTR(func), cif->nargs, 0, pyargs); + mp_obj_t res = mp_call_function_n_kw(pyfunc, cif->nargs, 0, pyargs); if (res != mp_const_none) { *(ffi_arg *)ret = mp_obj_int_get_truncated(res); } } -STATIC mp_obj_t mod_ffi_callback(mp_obj_t rettype_in, mp_obj_t func_in, mp_obj_t paramtypes_in) { +STATIC void call_py_func_with_lock(ffi_cif *cif, void *ret, void **args, void *user_data) { + mp_obj_t pyargs[cif->nargs]; + mp_obj_fficallback_t *o = user_data; + mp_obj_t pyfunc = o->pyfunc; + nlr_buf_t nlr; + + #if MICROPY_ENABLE_SCHEDULER + mp_sched_lock(); + #endif + gc_lock(); + + if (nlr_push(&nlr) == 0) { + for (uint i = 0; i < cif->nargs; i++) { + pyargs[i] = mp_obj_new_int(*(mp_int_t *)args[i]); + } + mp_obj_t res = mp_call_function_n_kw(pyfunc, cif->nargs, 0, pyargs); + + if (res != mp_const_none) { + *(ffi_arg *)ret = mp_obj_int_get_truncated(res); + } + nlr_pop(); + } else { + // Uncaught exception + mp_printf(MICROPY_ERROR_PRINTER, "Uncaught exception in FFI callback\n"); + mp_obj_print_exception(MICROPY_ERROR_PRINTER, MP_OBJ_FROM_PTR(nlr.ret_val)); + } + + gc_unlock(); + #if MICROPY_ENABLE_SCHEDULER + mp_sched_unlock(); + #endif +} + +STATIC mp_obj_t mod_ffi_callback(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + // first 3 args are positional: retttype, func, paramtypes. + mp_obj_t rettype_in = pos_args[0]; + mp_obj_t func_in = pos_args[1]; + mp_obj_t paramtypes_in = pos_args[2]; + + // arg parsing is used only for additional kwargs + enum { ARG_lock }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_lock, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = false} }, + }; + mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; + mp_arg_parse_all(n_args - 3, pos_args + 3, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + bool lock_in = args[ARG_lock].u_bool; + const char *rettype = mp_obj_str_get_str(rettype_in); mp_int_t nparams = MP_OBJ_SMALL_INT_VALUE(mp_obj_len_maybe(paramtypes_in)); @@ -290,6 +342,7 @@ STATIC mp_obj_t mod_ffi_callback(mp_obj_t rettype_in, mp_obj_t func_in, mp_obj_t o->clo = ffi_closure_alloc(sizeof(ffi_closure), &o->func); o->rettype = *rettype; + o->pyfunc = func_in; mp_obj_iter_buf_t iter_buf; mp_obj_t iterable = mp_getiter(paramtypes_in, &iter_buf); @@ -304,14 +357,15 @@ STATIC mp_obj_t mod_ffi_callback(mp_obj_t rettype_in, mp_obj_t func_in, mp_obj_t mp_raise_ValueError(MP_ERROR_TEXT("Error in ffi_prep_cif")); } - res = ffi_prep_closure_loc(o->clo, &o->cif, call_py_func, MP_OBJ_TO_PTR(func_in), o->func); + res = ffi_prep_closure_loc(o->clo, &o->cif, + lock_in? call_py_func_with_lock: call_py_func, o, o->func); if (res != FFI_OK) { mp_raise_ValueError(MP_ERROR_TEXT("ffi_prep_closure_loc")); } return MP_OBJ_FROM_PTR(o); } -MP_DEFINE_CONST_FUN_OBJ_3(mod_ffi_callback_obj, mod_ffi_callback); +MP_DEFINE_CONST_FUN_OBJ_KW(mod_ffi_callback_obj, 3, mod_ffi_callback); STATIC mp_obj_t ffimod_var(mp_obj_t self_in, mp_obj_t vartype_in, mp_obj_t symname_in) { mp_obj_ffimod_t *self = MP_OBJ_TO_PTR(self_in); @@ -343,9 +397,9 @@ STATIC mp_obj_t ffimod_addr(mp_obj_t self_in, mp_obj_t symname_in) { } MP_DEFINE_CONST_FUN_OBJ_2(ffimod_addr_obj, ffimod_addr); -STATIC mp_obj_t ffimod_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { +STATIC mp_obj_t ffimod_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { (void)n_args; - (void)kw_args; + (void)n_kw; const char *fname = NULL; if (args[0] != mp_const_none) { @@ -501,10 +555,22 @@ STATIC void fficallback_print(const mp_print_t *print, mp_obj_t self_in, mp_prin mp_printf(print, "", self->func); } +STATIC mp_obj_t fficallback_cfun(mp_obj_t self_in) { + mp_obj_fficallback_t *self = MP_OBJ_TO_PTR(self_in); + return mp_obj_new_int_from_ull((uintptr_t)self->func); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(fficallback_cfun_obj, fficallback_cfun); + +STATIC const mp_rom_map_elem_t fficallback_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_cfun), MP_ROM_PTR(&fficallback_cfun_obj) } +}; +STATIC MP_DEFINE_CONST_DICT(fficallback_locals_dict, fficallback_locals_dict_table); + STATIC const mp_obj_type_t fficallback_type = { { &mp_type_type }, .name = MP_QSTR_fficallback, .print = fficallback_print, + .locals_dict = (mp_obj_dict_t *)&fficallback_locals_dict }; // FFI variable @@ -554,7 +620,7 @@ STATIC const mp_obj_type_t opaque_type = { */ STATIC mp_obj_t mod_ffi_open(size_t n_args, const mp_obj_t *args) { - return ffimod_make_new(&ffimod_type, n_args, args, NULL); + return ffimod_make_new(&ffimod_type, n_args, 0, args); } MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_ffi_open_obj, 1, 2, mod_ffi_open); diff --git a/ports/unix/modjni.c b/ports/unix/modjni.c index bf039c0b71..bd151050ea 100644 --- a/ports/unix/modjni.c +++ b/ports/unix/modjni.c @@ -102,9 +102,9 @@ STATIC void check_exception(void) { mp_obj_t py_e = new_jobject(exc); JJ1(ExceptionClear); if (JJ(IsInstanceOf, exc, IndexException_class)) { - mp_raise_arg1(&mp_type_IndexError, py_e); + mp_raise_type_arg(&mp_type_IndexError, py_e); } - mp_raise_arg1(&mp_type_Exception, py_e); + mp_raise_type_arg(&mp_type_Exception, py_e); } } diff --git a/ports/unix/mpconfigport.h b/ports/unix/mpconfigport.h index 166825ab81..da3c71d776 100644 --- a/ports/unix/mpconfigport.h +++ b/ports/unix/mpconfigport.h @@ -89,6 +89,7 @@ #define MICROPY_PY_FUNCTION_ATTRS (1) #define MICROPY_PY_DESCRIPTORS (1) #define MICROPY_PY_DELATTR_SETATTR (1) +#define MICROPY_PY_FSTRINGS (1) #define MICROPY_PY_BUILTINS_STR_UNICODE (1) #define MICROPY_PY_BUILTINS_STR_CENTER (1) #define MICROPY_PY_BUILTINS_STR_PARTITION (1) diff --git a/ports/unix/mphalport.h b/ports/unix/mphalport.h index 5d3e2a2482..9242bef1ad 100644 --- a/ports/unix/mphalport.h +++ b/ports/unix/mphalport.h @@ -54,7 +54,7 @@ static inline int mp_hal_readline(vstr_t *vstr, const char *p) { #elif MICROPY_PY_BUILTINS_INPUT && MICROPY_USE_READLINE == 1 #include "py/misc.h" -#include "lib/mp-readline/readline.h" +#include "shared/readline/readline.h" // For built-in input() we need to wrap the standard readline() to enable raw mode #define mp_hal_readline mp_hal_readline static inline int mp_hal_readline(vstr_t *vstr, const char *p) { diff --git a/ports/unix/mpthreadport.c b/ports/unix/mpthreadport.c index fe4030f08d..6a0ce59377 100644 --- a/ports/unix/mpthreadport.c +++ b/ports/unix/mpthreadport.c @@ -39,7 +39,7 @@ #include #include -#include "lib/utils/gchelper.h" +#include "shared/runtime/gchelper.h" // Some platforms don't have SIGRTMIN but if we do have it, use it to avoid // potential conflict with other uses of the more commonly used SIGUSR1. diff --git a/ports/unix/unix_mphal.c b/ports/unix/unix_mphal.c index fceff68284..9d50652e39 100644 --- a/ports/unix/unix_mphal.c +++ b/ports/unix/unix_mphal.c @@ -53,7 +53,7 @@ STATIC void sighandler(int signum) { sigprocmask(SIG_SETMASK, &mask, NULL); nlr_raise(MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception))); #else - if (MP_STATE_VM(mp_pending_exception) == MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception))) { + if (MP_STATE_MAIN_THREAD(mp_pending_exception) == MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception))) { // this is the second time we are called, so die straight away exit(1); } diff --git a/ports/unix/variants/coverage/mpconfigvariant.mk b/ports/unix/variants/coverage/mpconfigvariant.mk index e5d0f7e2d3..e614cd411e 100644 --- a/ports/unix/variants/coverage/mpconfigvariant.mk +++ b/ports/unix/variants/coverage/mpconfigvariant.mk @@ -27,5 +27,10 @@ SRC_C += $(SRC_QRIO) CFLAGS += -DCIRCUITPY_QRIO=1 $(BUILD)/lib/quirc/lib/%.o: CFLAGS += -Wno-shadow -Wno-sign-compare -include shared-module/qrio/quirc_alloc.h +SRC_GIFIO := $(patsubst ../../%,%,$(wildcard ../../shared-bindings/gifio/*.c ../../shared-module/gifio/*.c)) shared/runtime/context_manager_helpers.c displayio_colorspace_only.c shared-module/displayio/ColorConverter.c shared-bindings/util.c +SRC_C += $(SRC_GIFIO) + +CFLAGS += -DCIRCUITPY_GIFIO=1 -DCIRCUITPY_DISPLAYIO_COLORSPACE_ONLY=1 + SRC_C += coverage.c SRC_CXX += coveragecpp.cpp diff --git a/ports/unix/variants/dev/mpconfigvariant.h b/ports/unix/variants/dev/mpconfigvariant.h index 7c3e84cc44..54ad993236 100644 --- a/ports/unix/variants/dev/mpconfigvariant.h +++ b/ports/unix/variants/dev/mpconfigvariant.h @@ -31,6 +31,8 @@ #define MICROPY_VFS (1) #define MICROPY_VFS_POSIX (1) +#define MICROPY_PY_BUILTINS_HELP (1) +#define MICROPY_PY_BUILTINS_HELP_MODULES (1) #define MICROPY_PY_SYS_SETTRACE (1) #define MICROPY_PY_UOS_VFS (1) #define MICROPY_PY_URANDOM_EXTRA_FUNCS (1) diff --git a/ports/unix/variants/standard/mpconfigvariant.h b/ports/unix/variants/standard/mpconfigvariant.h index 2868f949cc..3cdcfa8e9b 100644 --- a/ports/unix/variants/standard/mpconfigvariant.h +++ b/ports/unix/variants/standard/mpconfigvariant.h @@ -23,3 +23,6 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ + +#define MICROPY_PY_BUILTINS_HELP (1) +#define MICROPY_PY_BUILTINS_HELP_MODULES (1) diff --git a/py/argcheck.c b/py/argcheck.c index a2b5f63f33..c2066a7c39 100644 --- a/py/argcheck.c +++ b/py/argcheck.c @@ -77,14 +77,6 @@ void mp_arg_check_num_sig(size_t n_args, size_t n_kw, uint32_t sig) { } } -inline void mp_arg_check_num(size_t n_args, mp_map_t *kw_args, size_t n_args_min, size_t n_args_max, bool takes_kw) { - size_t n_kw = 0; - if (kw_args != NULL) { - n_kw = kw_args->used; - } - mp_arg_check_num_sig(n_args, n_kw, MP_OBJ_FUN_MAKE_SIG(n_args_min, n_args_max, takes_kw)); -} - inline void mp_arg_check_num_kw_array(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, bool takes_kw) { mp_arg_check_num_sig(n_args, n_kw, MP_OBJ_FUN_MAKE_SIG(n_args_min, n_args_max, takes_kw)); } @@ -173,7 +165,7 @@ 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 max, qstr arg_name) { if (i > max) { - mp_raise_ValueError_varg(translate("%q must <= %d"), arg_name, max); + mp_raise_ValueError_varg(translate("%q must be <= %d"), arg_name, max); } return i; } @@ -204,7 +196,7 @@ mp_uint_t mp_arg_validate_length_range(mp_uint_t length, mp_uint_t min, mp_uint_ mp_obj_t mp_arg_validate_type(mp_obj_t obj, const mp_obj_type_t *type, qstr arg_name) { if (!mp_obj_is_type(obj, type)) { - mp_raise_TypeError_varg(translate("%q must of type %q"), arg_name, type->name); + mp_raise_TypeError_varg(translate("%q must be of type %q"), arg_name, type->name); } return obj; } diff --git a/py/bc.h b/py/bc.h index 410ca800c8..e901f7bb34 100644 --- a/py/bc.h +++ b/py/bc.h @@ -128,7 +128,9 @@ #define MP_BC_PRELUDE_SIG_DECODE(ip) \ size_t n_state, n_exc_stack, scope_flags, n_pos_args, n_kwonly_args, n_def_pos_args; \ - MP_BC_PRELUDE_SIG_DECODE_INTO(ip, n_state, n_exc_stack, scope_flags, n_pos_args, n_kwonly_args, n_def_pos_args) + MP_BC_PRELUDE_SIG_DECODE_INTO(ip, n_state, n_exc_stack, scope_flags, n_pos_args, n_kwonly_args, n_def_pos_args); \ + (void)n_state; (void)n_exc_stack; (void)scope_flags; \ + (void)n_pos_args; (void)n_kwonly_args; (void)n_def_pos_args #define MP_BC_PRELUDE_SIZE_ENCODE(I, C, out_byte, out_env) \ do { \ @@ -163,7 +165,8 @@ #define MP_BC_PRELUDE_SIZE_DECODE(ip) \ size_t n_info, n_cell; \ - MP_BC_PRELUDE_SIZE_DECODE_INTO(ip, n_info, n_cell) + MP_BC_PRELUDE_SIZE_DECODE_INTO(ip, n_info, n_cell); \ + (void)n_info; (void)n_cell // Sentinel value for mp_code_state_t.exc_sp_idx #define MP_CODE_STATE_EXC_SP_IDX_SENTINEL ((uint16_t)-1) diff --git a/py/binary.c b/py/binary.c index d700ab3848..06f0157567 100644 --- a/py/binary.c +++ b/py/binary.c @@ -212,7 +212,7 @@ long long mp_binary_get_int(size_t size, bool is_signed, bool big_endian, const delta = 1; } - long long val = 0; + unsigned long long val = 0; if (is_signed && *src & 0x80) { val = -1; } diff --git a/py/builtinhelp.c b/py/builtinhelp.c index 35bd3d3bca..fc32de5abe 100644 --- a/py/builtinhelp.c +++ b/py/builtinhelp.c @@ -176,7 +176,7 @@ STATIC mp_obj_t mp_builtin_help(size_t n_args, const mp_obj_t *args) { if (n_args == 0) { // print a general help message. Translate only works on single strings on one line. mp_cprintf(MP_PYTHON_PRINTER, - translate("Welcome to Adafruit CircuitPython %s!\n\nPlease visit learn.adafruit.com/category/circuitpython for project guides.\n\nTo list built-in modules please do `help(\"modules\")`.\n"), + translate("Welcome to Adafruit CircuitPython %s!\n\nVisit circuitpython.org for more information.\n\nTo list built-in modules type `help(\"modules\")`.\n"), MICROPY_GIT_TAG); } else { // try to print something sensible about the given object diff --git a/py/builtinimport.c b/py/builtinimport.c index d49ef2a9d5..5baef16d86 100644 --- a/py/builtinimport.c +++ b/py/builtinimport.c @@ -153,7 +153,7 @@ STATIC void do_load_from_lexer(mp_obj_t module_obj, mp_lexer_t *lex) { } #endif -#if MICROPY_PERSISTENT_CODE_LOAD || MICROPY_MODULE_FROZEN_MPY +#if (MICROPY_HAS_FILE_READER && MICROPY_PERSISTENT_CODE_LOAD) || MICROPY_MODULE_FROZEN_MPY STATIC void do_execute_raw_code(mp_obj_t module_obj, mp_raw_code_t *raw_code, const char *source_name) { (void)source_name; #if MICROPY_PY___FILE__ diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk index 836f3c7af1..c258317d18 100644 --- a/py/circuitpy_defns.mk +++ b/py/circuitpy_defns.mk @@ -197,6 +197,9 @@ endif ifeq ($(CIRCUITPY_GETPASS),1) SRC_PATTERNS += getpass/% endif +ifeq ($(CIRCUITPY_GIFIO),1) +SRC_PATTERNS += gifio/% +endif ifeq ($(CIRCUITPY_GNSS),1) SRC_PATTERNS += gnss/% endif @@ -465,7 +468,9 @@ $(filter $(SRC_PATTERNS), \ digitalio/Direction.c \ digitalio/DriveMode.c \ digitalio/Pull.c \ + displayio/Colorspace.c \ fontio/Glyph.c \ + imagecapture/ParallelImageCapture.c \ math/__init__.c \ microcontroller/ResetReason.c \ microcontroller/RunMode.c \ @@ -535,6 +540,9 @@ SRC_SHARED_MODULE_ALL = \ gamepadshift/GamePadShift.c \ gamepadshift/__init__.c \ getpass/__init__.c \ + gifio/__init__.c \ + gifio/GifWriter.c \ + imagecapture/ParallelImageCapture.c \ ipaddress/IPv4Address.c \ ipaddress/__init__.c \ keypad/__init__.c \ @@ -680,17 +688,17 @@ endif endif SRC_CIRCUITPY_COMMON = \ - lib/libc/string0.c \ - lib/mp-readline/readline.c \ + shared/libc/string0.c \ + shared/readline/readline.c \ lib/oofatfs/ff.c \ lib/oofatfs/ffunicode.c \ - lib/timeutils/timeutils.c \ - lib/utils/buffer_helper.c \ - lib/utils/context_manager_helpers.c \ - lib/utils/interrupt_char.c \ - lib/utils/pyexec.c \ - lib/utils/stdout_helpers.c \ - lib/utils/sys_stdio_mphal.c + shared/timeutils/timeutils.c \ + shared/runtime/buffer_helper.c \ + shared/runtime/context_manager_helpers.c \ + shared/runtime/interrupt_char.c \ + shared/runtime/pyexec.c \ + shared/runtime/stdout_helpers.c \ + shared/runtime/sys_stdio_mphal.c ifeq ($(CIRCUITPY_QRIO),1) SRC_CIRCUITPY_COMMON += lib/quirc/lib/decode.c lib/quirc/lib/identify.c lib/quirc/lib/quirc.c lib/quirc/lib/version_db.c @@ -706,7 +714,7 @@ GENERATED_LD_FILE = $(BUILD)/$(notdir $(patsubst %.template.ld,%.ld,$(LD_TEMPLAT # because it may include other template files. $(GENERATED_LD_FILE): $(BUILD)/ld_defines.pp boards/*.template.ld $(STEPECHO) "GEN $@" - $(Q)$(PYTHON3) $(TOP)/tools/gen_ld_files.py --defines $< --out_dir $(BUILD) boards/*.template.ld + $(Q)$(PYTHON) $(TOP)/tools/gen_ld_files.py --defines $< --out_dir $(BUILD) boards/*.template.ld endif .PHONY: check-release-needs-clean-build diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index 2ec0d2a849..3c6d5c6110 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -77,6 +77,8 @@ #define MICROPY_NONSTANDARD_TYPECODES (0) #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_CACHE_MAP_LOOKUP_IN_BYTECODE (CIRCUITPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) #define MICROPY_PERSISTENT_CODE_LOAD (1) #define MICROPY_PY_ARRAY (1) @@ -194,7 +196,7 @@ typedef long mp_off_t; #define MICROPY_CPYTHON_COMPAT (CIRCUITPY_FULL_BUILD) #endif #define MICROPY_PY_BUILTINS_POW3 (CIRCUITPY_BUILTINS_POW3) -#define MICROPY_COMP_FSTRING_LITERAL (MICROPY_CPYTHON_COMPAT) +#define MICROPY_PY_FSTRINGS (MICROPY_CPYTHON_COMPAT) #define MICROPY_MODULE_WEAK_LINKS (0) #define MICROPY_PY_ALL_SPECIAL_METHODS (CIRCUITPY_FULL_BUILD) #ifndef MICROPY_PY_BUILTINS_COMPLEX @@ -244,26 +246,16 @@ typedef long mp_off_t; // 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_BINASCII -#define MICROPY_PY_UBINASCII CIRCUITPY_BINASCII -#define BINASCII_MODULE { MP_ROM_QSTR(MP_QSTR_binascii), MP_ROM_PTR(&mp_module_ubinascii) }, -#else -#define BINASCII_MODULE -#endif - #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 @@ -276,23 +268,6 @@ typedef long mp_off_t; #define CIRCUITPY_DISPLAY_LIMIT (0) #endif -#if CIRCUITPY_ERRNO -#define MICROPY_PY_UERRNO (1) -// Uses about 80 bytes. -#define MICROPY_PY_UERRNO_ERRORCODE (1) -#define ERRNO_MODULE { MP_ROM_QSTR(MP_QSTR_errno), MP_ROM_PTR(&mp_module_uerrno) }, -#else -#define ERRNO_MODULE -# - #endif - -#if CIRCUITPY_ESPIDF -extern const struct _mp_obj_module_t espidf_module; -#define ESPIDF_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_espidf),(mp_obj_t)&espidf_module }, -#else -#define ESPIDF_MODULE -#endif - #if CIRCUITPY_GAMEPADSHIFT // Scan gamepad every 32ms #define CIRCUITPY_GAMEPAD_TICKS 0x1f @@ -301,18 +276,6 @@ extern const struct _mp_obj_module_t espidf_module; #define GAMEPAD_ROOT_POINTERS #endif -#if CIRCUITPY_JSON -#define MICROPY_PY_UJSON (1) -#define MICROPY_PY_IO (1) -#define JSON_MODULE { MP_ROM_QSTR(MP_QSTR_json), MP_ROM_PTR(&mp_module_ujson) }, -#else -#ifndef MICROPY_PY_IO -// We don't need MICROPY_PY_IO unless someone else wants it. -#define MICROPY_PY_IO (0) -#endif -#define JSON_MODULE -#endif - #if CIRCUITPY_KEYPAD #define KEYPAD_ROOT_POINTERS mp_obj_t keypad_scanners_linked_list; #else @@ -331,83 +294,51 @@ extern const struct _mp_obj_module_t espidf_module; extern const struct _mp_obj_module_t nvm_module; #endif -#if CIRCUITPY_OS -extern const struct _mp_obj_module_t os_module; -#define OS_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_os), (mp_obj_t)&os_module }, -#define OS_MODULE_ALT_NAME { MP_OBJ_NEW_QSTR(MP_QSTR__os), (mp_obj_t)&os_module }, +// Following modules are implemented in either extmod or py directory. + +#define MICROPY_PY_UBINASCII CIRCUITPY_BINASCII + +#define MICROPY_PY_UERRNO CIRCUITPY_ERRNO +// Uses about 80 bytes. +#define MICROPY_PY_UERRNO_ERRORCODE CIRCUITPY_ERRNO + +#define MICROPY_PY_URE CIRCUITPY_RE + +#if CIRCUITPY_JSON +#define MICROPY_PY_UJSON (1) +#define MICROPY_PY_IO (1) #else -#define OS_MODULE -#define OS_MODULE_ALT_NAME +#ifndef MICROPY_PY_IO +// We don't need MICROPY_PY_IO unless someone else wants it. +#define MICROPY_PY_IO (0) +#endif #endif -#if CIRCUITPY_RE -#define MICROPY_PY_URE (1) -#define RE_MODULE { MP_ROM_QSTR(MP_QSTR_re), MP_ROM_PTR(&mp_module_ure) }, -#else -#define RE_MODULE -#endif - -#if CIRCUITPY_RP2PIO -extern const struct _mp_obj_module_t rp2pio_module; -#define RP2PIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_rp2pio),(mp_obj_t)&rp2pio_module }, -#else -#define RP2PIO_MODULE -#endif - -#if CIRCUITPY_SAMD -extern const struct _mp_obj_module_t samd_module; -#define SAMD_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_samd),(mp_obj_t)&samd_module }, -#else -#define SAMD_MODULE -#endif - -#if CIRCUITPY_TIME -extern const struct _mp_obj_module_t time_module; -#define TIME_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_time), (mp_obj_t)&time_module }, -#define TIME_MODULE_ALT_NAME { MP_OBJ_NEW_QSTR(MP_QSTR__time), (mp_obj_t)&time_module }, -#else -#define TIME_MODULE -#define TIME_MODULE_ALT_NAME -#endif - -#if defined(CIRCUITPY_ULAB) && CIRCUITPY_ULAB +#if CIRCUITPY_ULAB // ulab requires reverse special methods #if defined(MICROPY_PY_REVERSE_SPECIAL_METHODS) && !MICROPY_PY_REVERSE_SPECIAL_METHODS #error "ulab requires MICROPY_PY_REVERSE_SPECIAL_METHODS" #endif -#define ULAB_MODULE \ - { MP_ROM_QSTR(MP_QSTR_ulab), MP_ROM_PTR(&ulab_user_cmodule) }, -#else -#define ULAB_MODULE #endif // Define certain native modules with weak links so they can be replaced with Python // implementations. This list may grow over time. -#define MICROPY_PORT_BUILTIN_MODULE_WEAK_LINKS \ - OS_MODULE \ - TIME_MODULE \ + +#define MICROPY_PORT_BUILTIN_MODULE_WEAK_LINKS // Native modules that are weak links can be accessed directly // by prepending their name with an underscore. This list should correspond to // MICROPY_PORT_BUILTIN_MODULE_WEAK_LINKS, assuming you want the native modules // to be accessible when overriden. -#define MICROPY_PORT_BUILTIN_MODULE_ALT_NAMES \ - OS_MODULE_ALT_NAME \ - TIME_MODULE_ALT_NAME \ + +#define MICROPY_PORT_BUILTIN_MODULE_ALT_NAMES // This is an inclusive list that should correspond to the CIRCUITPY_XXX list above, // including dependencies. // Some of these definitions will be blank depending on what is turned on and off. // Some are omitted because they're in MICROPY_PORT_BUILTIN_MODULE_WEAK_LINKS above. -#define MICROPY_PORT_BUILTIN_MODULES_STRONG_LINKS \ - BINASCII_MODULE \ - ERRNO_MODULE \ - ESPIDF_MODULE \ - JSON_MODULE \ - RE_MODULE \ - RP2PIO_MODULE \ - SAMD_MODULE \ +#define MICROPY_PORT_BUILTIN_MODULES_STRONG_LINKS // The following modules are defined in their respective __init__.c file in the // shared-bindings directory using MP_REGISTER_MODULE. diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk index 51e6fb8a11..04f0778290 100644 --- a/py/circuitpy_mpconfig.mk +++ b/py/circuitpy_mpconfig.mk @@ -145,6 +145,17 @@ CFLAGS += -DCIRCUITPY_DIGITALIO=$(CIRCUITPY_DIGITALIO) CIRCUITPY_COMPUTED_GOTO_SAVE_SPACE ?= 0 CFLAGS += -DCIRCUITPY_COMPUTED_GOTO_SAVE_SPACE=$(CIRCUITPY_COMPUTED_GOTO_SAVE_SPACE) +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_CONSOLE_UART ?= 0 CFLAGS += -DCIRCUITPY_CONSOLE_UART=$(CIRCUITPY_CONSOLE_UART) @@ -203,6 +214,13 @@ CFLAGS += -DCIRCUITPY_GAMEPADSHIFT=$(CIRCUITPY_GAMEPADSHIFT) CIRCUITPY_GETPASS ?= $(CIRCUITPY_FULL_BUILD) CFLAGS += -DCIRCUITPY_GETPASS=$(CIRCUITPY_GETPASS) +ifeq ($(CIRCUITPY_DISPLAYIO),1) +CIRCUITPY_GIFIO ?= $(CIRCUITPY_FULL_BUILD) +else +CIRCUITPY_GIFIO ?= 0 +endif +CFLAGS += -DCIRCUITPY_GIFIO=$(CIRCUITPY_GIFIO) + CIRCUITPY_GNSS ?= 0 CFLAGS += -DCIRCUITPY_GNSS=$(CIRCUITPY_GNSS) diff --git a/py/dynruntime.h b/py/dynruntime.h index 2ba344e6c8..0a7eb20397 100644 --- a/py/dynruntime.h +++ b/py/dynruntime.h @@ -188,10 +188,7 @@ static inline mp_obj_t mp_obj_len_dyn(mp_obj_t o) { #define mp_call_function_n_kw(fun, n_args, n_kw, args) \ (mp_fun_table.call_function_n_kw((fun), (n_args) | ((n_kw) << 8), args)) -#define mp_arg_check_num(n_args, kw_args, n_args_min, n_args_max, takes_kw) \ - (mp_fun_table.arg_check_num_sig((n_args), (kw_args) ? kw_args->used : 0, MP_OBJ_FUN_MAKE_SIG((n_args_min), (n_args_max), (takes_kw)))) - -#define mp_arg_check_num_mp(n_args, n_kw, n_args_min, n_args_max, takes_kw) \ +#define mp_arg_check_num(n_args, n_kw, n_args_min, n_args_max, takes_kw) \ (mp_fun_table.arg_check_num_sig((n_args), (n_kw), MP_OBJ_FUN_MAKE_SIG((n_args_min), (n_args_max), (takes_kw)))) #define MP_DYNRUNTIME_INIT_ENTRY \ @@ -223,6 +220,7 @@ static inline mp_obj_t mp_obj_len_dyn(mp_obj_t o) { #define mp_obj_new_exception_arg1(e_type, arg) (mp_obj_new_exception_arg1_dyn((e_type), (arg))) #define nlr_raise(o) (mp_raise_dyn(o)) +#define mp_raise_type_arg(type, arg) (mp_raise_dyn(mp_obj_new_exception_arg1_dyn((type), (arg)))) #define mp_raise_msg(type, msg) (mp_fun_table.raise_msg_str((type), (msg))) #define mp_raise_OSError(er) (mp_raise_OSError_dyn(er)) #define mp_raise_NotImplementedError(msg) (mp_raise_msg(&mp_type_NotImplementedError, (msg))) diff --git a/py/emitnative.c b/py/emitnative.c index 1fa8c631e4..c5d9fecb4c 100644 --- a/py/emitnative.c +++ b/py/emitnative.c @@ -869,10 +869,13 @@ STATIC void need_reg_single(emit_t *emit, int reg_needed, int skip_stack_pos) { } } +// Ensures all unsettled registers that hold Python values are copied to the +// concrete Python stack. All registers are then free to use. STATIC void need_reg_all(emit_t *emit) { for (int i = 0; i < emit->stack_size; i++) { stack_info_t *si = &emit->stack_info[i]; if (si->kind == STACK_REG) { + DEBUG_printf(" reg(%u) to local(%u)\n", si->data.u_reg, emit->stack_start + i); si->kind = STACK_VALUE; emit_native_mov_state_reg(emit, emit->stack_start + i, si->data.u_reg); } @@ -899,23 +902,21 @@ STATIC vtype_kind_t load_reg_stack_imm(emit_t *emit, int reg_dest, const stack_i } } +// Copies all unsettled registers and immediates that are Python values into the +// concrete Python stack. This ensures the concrete Python stack holds valid +// values for the current stack_size. +// This function may clobber REG_TEMP1. STATIC void need_stack_settled(emit_t *emit) { DEBUG_printf(" need_stack_settled; stack_size=%d\n", emit->stack_size); - for (int i = 0; i < emit->stack_size; i++) { - stack_info_t *si = &emit->stack_info[i]; - if (si->kind == STACK_REG) { - DEBUG_printf(" reg(%u) to local(%u)\n", si->data.u_reg, emit->stack_start + i); - si->kind = STACK_VALUE; - emit_native_mov_state_reg(emit, emit->stack_start + i, si->data.u_reg); - } - } + need_reg_all(emit); for (int i = 0; i < emit->stack_size; i++) { stack_info_t *si = &emit->stack_info[i]; if (si->kind == STACK_IMM) { DEBUG_printf(" imm(" INT_FMT ") to local(%u)\n", si->data.u_imm, emit->stack_start + i); si->kind = STACK_VALUE; - si->vtype = load_reg_stack_imm(emit, REG_TEMP0, si, false); - emit_native_mov_state_reg(emit, emit->stack_start + i, REG_TEMP0); + // using REG_TEMP1 to avoid clobbering REG_TEMP0 (aka REG_RET) + si->vtype = load_reg_stack_imm(emit, REG_TEMP1, si, false); + emit_native_mov_state_reg(emit, emit->stack_start + i, REG_TEMP1); } } } diff --git a/py/lexer.c b/py/lexer.c index c6506ebcee..ce48adbfa5 100644 --- a/py/lexer.c +++ b/py/lexer.c @@ -64,7 +64,7 @@ STATIC bool is_char_or3(mp_lexer_t *lex, byte c1, byte c2, byte c3) { return lex->chr0 == c1 || lex->chr0 == c2 || lex->chr0 == c3; } -#if MICROPY_COMP_FSTRING_LITERAL +#if MICROPY_PY_FSTRINGS STATIC bool is_char_or4(mp_lexer_t *lex, byte c1, byte c2, byte c3, byte c4) { return lex->chr0 == c1 || lex->chr0 == c2 || lex->chr0 == c3 || lex->chr0 == c4; } @@ -113,10 +113,10 @@ STATIC bool is_following_odigit(mp_lexer_t *lex) { STATIC bool is_string_or_bytes(mp_lexer_t *lex) { return is_char_or(lex, '\'', '\"') - #if MICROPY_COMP_FSTRING_LITERAL + #if MICROPY_PY_FSTRINGS || (is_char_or4(lex, 'r', 'u', 'b', 'f') && is_char_following_or(lex, '\'', '\"')) - || ((is_char_and(lex, 'r', 'f') || is_char_and(lex, 'f', 'r')) - && is_char_following_following_or(lex, '\'', '\"')) + || (((is_char_and(lex, 'r', 'f') || is_char_and(lex, 'f', 'r')) + && is_char_following_following_or(lex, '\'', '\"'))) #else || (is_char_or3(lex, 'r', 'u', 'b') && is_char_following_or(lex, '\'', '\"')) #endif @@ -133,31 +133,6 @@ STATIC bool is_tail_of_identifier(mp_lexer_t *lex) { return is_head_of_identifier(lex) || is_digit(lex); } -#if MICROPY_COMP_FSTRING_LITERAL -STATIC void swap_char_banks(mp_lexer_t *lex) { - if (lex->vstr_postfix_processing) { - lex->chr3 = lex->chr0; - lex->chr4 = lex->chr1; - lex->chr5 = lex->chr2; - lex->chr0 = lex->vstr_postfix.buf[0]; - lex->chr1 = lex->vstr_postfix.buf[1]; - lex->chr2 = lex->vstr_postfix.buf[2]; - - lex->vstr_postfix_idx = 3; - } else { - // blindly reset to the "backup" bank when done postfix processing - // this restores control to the mp_reader - lex->chr0 = lex->chr3; - lex->chr1 = lex->chr4; - lex->chr2 = lex->chr5; - // willfully ignoring setting chr3-5 here - WARNING consider those garbage data now - - vstr_reset(&lex->vstr_postfix); - lex->vstr_postfix_idx = 0; - } -} -#endif - STATIC void next_char(mp_lexer_t *lex) { if (lex->chr0 == '\n') { // a new line @@ -171,15 +146,29 @@ STATIC void next_char(mp_lexer_t *lex) { ++lex->column; } + // shift the input queue forward lex->chr0 = lex->chr1; lex->chr1 = lex->chr2; - #if MICROPY_COMP_FSTRING_LITERAL - if (lex->vstr_postfix_processing) { - if (lex->vstr_postfix_idx == lex->vstr_postfix.len) { - lex->chr2 = '\0'; + // and add the next byte from either the fstring args or the reader + #if MICROPY_PY_FSTRINGS + if (lex->fstring_args_idx) { + // if there are saved chars, then we're currently injecting fstring args + if (lex->fstring_args_idx < lex->fstring_args.len) { + lex->chr2 = lex->fstring_args.buf[lex->fstring_args_idx++]; } else { - lex->chr2 = lex->vstr_postfix.buf[lex->vstr_postfix_idx++]; + // no more fstring arg bytes + lex->chr2 = '\0'; + } + + if (lex->chr0 == '\0') { + // consumed all fstring data, restore saved input queue + lex->chr0 = lex->chr0_saved; + lex->chr1 = lex->chr1_saved; + lex->chr2 = lex->chr2_saved; + // stop consuming fstring arg data + vstr_reset(&lex->fstring_args); + lex->fstring_args_idx = 0; } } else #endif @@ -200,13 +189,6 @@ STATIC void next_char(mp_lexer_t *lex) { if (lex->chr2 == MP_LEXER_EOF && lex->chr1 != MP_LEXER_EOF && lex->chr1 != '\n') { lex->chr2 = '\n'; } - - #if MICROPY_COMP_FSTRING_LITERAL - if (lex->vstr_postfix_processing && lex->chr0 == '\0') { - lex->vstr_postfix_processing = false; - swap_char_banks(lex); - } - #endif } STATIC void indent_push(mp_lexer_t *lex, size_t indent) { @@ -351,9 +333,14 @@ STATIC void parse_string_literal(mp_lexer_t *lex, bool is_raw, bool is_fstring) } size_t n_closing = 0; - #if MICROPY_COMP_FSTRING_LITERAL - bool in_expression = false; - bool expression_eat = true; + #if MICROPY_PY_FSTRINGS + if (is_fstring) { + // assume there's going to be interpolation, so prep the injection data + // fstring_args_idx==0 && len(fstring_args)>0 means we're extracting the args. + // only when fstring_args_idx>0 will we consume the arg data + // note: lex->fstring_args will be empty already (it's reset when finished) + vstr_add_str(&lex->fstring_args, ".format("); + } #endif while (!is_end(lex) && (num_quotes > 1 || !is_char(lex, '\n')) && n_closing < num_quotes) { @@ -362,53 +349,38 @@ STATIC void parse_string_literal(mp_lexer_t *lex, bool is_raw, bool is_fstring) vstr_add_char(&lex->vstr, CUR_CHAR(lex)); } else { n_closing = 0; - #if MICROPY_COMP_FSTRING_LITERAL - if (is_fstring && is_char(lex, '{')) { - vstr_add_char(&lex->vstr, CUR_CHAR(lex)); - in_expression = !in_expression; - expression_eat = in_expression; - - if (lex->vstr_postfix.len == 0) { - vstr_add_str(&lex->vstr_postfix, ".format("); - } + #if MICROPY_PY_FSTRINGS + while (is_fstring && is_char(lex, '{')) { next_char(lex); - continue; - } - - if (is_fstring && is_char(lex, '}')) { - vstr_add_char(&lex->vstr, CUR_CHAR(lex)); - - if (in_expression) { - in_expression = false; - vstr_add_char(&lex->vstr_postfix, ','); - } - - next_char(lex); - continue; - } - - if (in_expression) { - // throw errors for illegal chars inside f-string expressions - if (is_char(lex, '#')) { - lex->tok_kind = MP_TOKEN_FSTRING_COMMENT; - return; - } else if (is_char(lex, '\\')) { - lex->tok_kind = MP_TOKEN_FSTRING_BACKSLASH; - return; - } else if (is_char(lex, ':')) { - expression_eat = false; - } - - unichar c = CUR_CHAR(lex); - if (expression_eat) { - vstr_add_char(&lex->vstr_postfix, c); + if (is_char(lex, '{')) { + // "{{" is passed through unchanged to be handled by str.format + vstr_add_byte(&lex->vstr, '{'); + next_char(lex); } else { - vstr_add_char(&lex->vstr, c); + // remember the start of this argument (if we need it for f'{a=}'). + size_t i = lex->fstring_args.len; + // extract characters inside the { until we reach the + // format specifier or closing }. + // (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, ':', '}')) { + // like the default case at the end of this function, stay 8-bit clean + vstr_add_byte(&lex->fstring_args, CUR_CHAR(lex)); + next_char(lex); + } + if (lex->fstring_args.buf[lex->fstring_args.len - 1] == '=') { + // if the last character of the arg was '=', then inject "arg=" before the '{'. + // f'{a=}' --> 'a={}'.format(a) + vstr_add_strn(&lex->vstr, lex->fstring_args.buf + i, lex->fstring_args.len - i); + // remove the trailing '=' + lex->fstring_args.len--; + } + // comma-separate args + vstr_add_byte(&lex->fstring_args, ','); } - - next_char(lex); - continue; + vstr_add_byte(&lex->vstr, '{'); } #endif @@ -565,12 +537,20 @@ STATIC bool skip_whitespace(mp_lexer_t *lex, bool stop_at_newline) { } void mp_lexer_to_next(mp_lexer_t *lex) { - #if MICROPY_COMP_FSTRING_LITERAL - if (lex->vstr_postfix.len && !lex->vstr_postfix_processing) { - // end format call injection - vstr_add_char(&lex->vstr_postfix, ')'); - lex->vstr_postfix_processing = true; - swap_char_banks(lex); + #if MICROPY_PY_FSTRINGS + if (lex->fstring_args.len && lex->fstring_args_idx == 0) { + // moving onto the next token means the literal string is complete. + // switch into injecting the format args. + vstr_add_byte(&lex->fstring_args, ')'); + lex->chr0_saved = lex->chr0; + lex->chr1_saved = lex->chr1; + lex->chr2_saved = lex->chr2; + lex->chr0 = lex->fstring_args.buf[0]; + lex->chr1 = lex->fstring_args.buf[1]; + lex->chr2 = lex->fstring_args.buf[2]; + // we've already extracted 3 chars, but setting this non-zero also + // means we'll start consuming the fstring data + lex->fstring_args_idx = 3; } #endif @@ -625,19 +605,11 @@ void mp_lexer_to_next(mp_lexer_t *lex) { // MP_TOKEN_END is used to indicate that this is the first string token lex->tok_kind = MP_TOKEN_END; - #if MICROPY_COMP_FSTRING_LITERAL - bool saw_normal = false, saw_fstring = false; - #endif - // Loop to accumulate string/bytes literals do { // parse type codes bool is_raw = false; - #if MICROPY_COMP_FSTRING_LITERAL bool is_fstring = false; - #else - const bool is_fstring = false; - #endif mp_token_kind_t kind = MP_TOKEN_STRING; int n_char = 0; if (is_char(lex, 'u')) { @@ -656,31 +628,23 @@ void mp_lexer_to_next(mp_lexer_t *lex) { kind = MP_TOKEN_BYTES; n_char = 2; } - #if MICROPY_COMP_FSTRING_LITERAL + #if MICROPY_PY_FSTRINGS if (is_char_following(lex, 'f')) { + // raw-f-strings unsupported, immediately return (invalid) token. lex->tok_kind = MP_TOKEN_FSTRING_RAW; break; } - } else if (is_char(lex, 'f')) { + #endif + } + #if MICROPY_PY_FSTRINGS + else if (is_char(lex, 'f')) { if (is_char_following(lex, 'r')) { + // raw-f-strings unsupported, immediately return (invalid) token. lex->tok_kind = MP_TOKEN_FSTRING_RAW; break; } n_char = 1; is_fstring = true; - #endif - } - - #if MICROPY_COMP_FSTRING_LITERAL - if (is_fstring) { - saw_fstring = true; - } else { - saw_normal = true; - } - - if (saw_fstring && saw_normal) { - // Can't concatenate f-string with normal string - break; } #endif @@ -860,8 +824,8 @@ mp_lexer_t *mp_lexer_new(qstr src_name, mp_reader_t reader) { lex->num_indent_level = 1; lex->indent_level = m_new(uint16_t, lex->alloc_indent_level); vstr_init(&lex->vstr, 32); - #if MICROPY_COMP_FSTRING_LITERAL - vstr_init(&lex->vstr_postfix, 0); + #if MICROPY_PY_FSTRINGS + vstr_init(&lex->fstring_args, 0); #endif // store sentinel for first indentation level @@ -916,6 +880,9 @@ void mp_lexer_free(mp_lexer_t *lex) { if (lex) { lex->reader.close(lex->reader.data); vstr_clear(&lex->vstr); + #if MICROPY_PY_FSTRINGS + vstr_clear(&lex->fstring_args); + #endif m_del(uint16_t, lex->indent_level, lex->alloc_indent_level); m_del_obj(mp_lexer_t, lex); } diff --git a/py/lexer.h b/py/lexer.h index 8f9960877c..bcc1c04a68 100644 --- a/py/lexer.h +++ b/py/lexer.h @@ -44,12 +44,8 @@ typedef enum _mp_token_kind_t { MP_TOKEN_INVALID, MP_TOKEN_DEDENT_MISMATCH, MP_TOKEN_LONELY_STRING_OPEN, - #if MICROPY_COMP_FSTRING_LITERAL - MP_TOKEN_FSTRING_BACKSLASH, - MP_TOKEN_FSTRING_COMMENT, - MP_TOKEN_FSTRING_UNCLOSED, - MP_TOKEN_FSTRING_UNOPENED, - MP_TOKEN_FSTRING_EMPTY_EXP, + #if MICROPY_PY_FSTRINGS + MP_TOKEN_MALFORMED_FSTRING, MP_TOKEN_FSTRING_RAW, #endif @@ -166,8 +162,8 @@ typedef struct _mp_lexer_t { mp_reader_t reader; // stream source unichar chr0, chr1, chr2; // current cached characters from source - #if MICROPY_COMP_FSTRING_LITERAL - unichar chr3, chr4, chr5; // current cached characters from alt source + #if MICROPY_PY_FSTRINGS + unichar chr0_saved, chr1_saved, chr2_saved; // current cached characters from alt source #endif size_t line; // current source line @@ -184,10 +180,9 @@ typedef struct _mp_lexer_t { size_t tok_column; // token source column mp_token_kind_t tok_kind; // token kind vstr_t vstr; // token data - #if MICROPY_COMP_FSTRING_LITERAL - vstr_t vstr_postfix; // postfix to apply to string - bool vstr_postfix_processing; - uint16_t vstr_postfix_idx; + #if MICROPY_PY_FSTRINGS + vstr_t fstring_args; // extracted arguments to pass to .format() + size_t fstring_args_idx; // how many bytes of fstring_args have been read #endif } mp_lexer_t; diff --git a/py/makeqstrdefs.py b/py/makeqstrdefs.py index bebbebab20..f035ed5745 100644 --- a/py/makeqstrdefs.py +++ b/py/makeqstrdefs.py @@ -79,7 +79,7 @@ def preprocess(): for source in sources: if source.endswith(".cpp"): cxxsources.append(source) - else: + elif source.endswith(".c"): csources.append(source) try: os.makedirs(os.path.dirname(args.output[0])) diff --git a/py/makeversionhdr.py b/py/makeversionhdr.py index a89eb35e15..12eaa3d3f1 100644 --- a/py/makeversionhdr.py +++ b/py/makeversionhdr.py @@ -23,7 +23,7 @@ def get_version_info_from_git(): # Note: git describe doesn't work if no tag is available try: git_tag = subprocess.check_output( - ["git", "describe", "--dirty", "--always", "--tags", "--match", "[1-9].*"], + ["git", "describe", "--tags", "--dirty", "--always", "--match", "[1-9].*"], stderr=subprocess.STDOUT, universal_newlines=True, ).strip() @@ -107,7 +107,7 @@ def make_version_header(filename): #define MICROPY_VERSION_MINOR (%s) #define MICROPY_VERSION_MICRO (%s) #define MICROPY_VERSION_STRING "%s" -#define MICROPY_FULL_VERSION_INFO ("Adafruit CircuitPython " MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE "; " MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME) +#define MICROPY_FULL_VERSION_INFO "Adafruit CircuitPython " MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE "; " MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME """ % ( git_tag, git_hash, diff --git a/py/misc.h b/py/misc.h index 99fadde696..8f2d3a187a 100644 --- a/py/misc.h +++ b/py/misc.h @@ -57,6 +57,7 @@ typedef unsigned int uint; // Round-up integer division #define MP_CEIL_DIVIDE(a, b) (((a) + (b) - 1) / (b)) +#define MP_ROUND_DIVIDE(a, b) (((a) + (b) / 2) / (b)) /** memory allocation ******************************************/ diff --git a/py/mkenv.mk b/py/mkenv.mk index ab17a98f67..e2cdb2ddb6 100644 --- a/py/mkenv.mk +++ b/py/mkenv.mk @@ -46,16 +46,13 @@ CD = cd CP = cp FIND = find MKDIR = mkdir -PYTHON = python -# Set default python interpreters -PYTHON2 ?= $(which python2 || which python2.7) -PYTHON3 ?= python3 +PYTHON = python3 RM = rm RSYNC = rsync SED = sed TOUCH = touch # Linux has 'nproc', macOS has 'sysctl -n hw.logicalcpu', this is cross-platform -NPROC = $(PYTHON3) -c 'import multiprocessing as mp; print(mp.cpu_count())' +NPROC = $(PYTHON) -c 'import multiprocessing as mp; print(mp.cpu_count())' AS = $(CROSS_COMPILE)as CC = $(CROSS_COMPILE)gcc @@ -67,14 +64,17 @@ SIZE = $(CROSS_COMPILE)size STRIP = $(CROSS_COMPILE)strip AR = $(CROSS_COMPILE)ar -MAKE_FROZEN = $(PYTHON3) $(TOP)/tools/make-frozen.py -MPY_CROSS = $(TOP)/mpy-cross/mpy-cross -MPY_TOOL = $(PYTHON3) $(TOP)/tools/mpy-tool.py +MAKE_MANIFEST = $(PYTHON) $(TOP)/tools/makemanifest.py +MAKE_FROZEN = $(PYTHON) $(TOP)/tools/make-frozen.py +MPY_TOOL = $(PYTHON) $(TOP)/tools/mpy-tool.py PREPROCESS_FROZEN_MODULES = PYTHONPATH=$(TOP)/tools/python-semver $(TOP)/tools/preprocess_frozen_modules.py MPY_LIB_DIR = $(TOP)/../micropython-lib -MPY_LIB_DIR = $(TOP)/../micropython-lib +ifeq ($(MICROPY_MPYCROSS),) +MICROPY_MPYCROSS = $(TOP)/mpy-cross/mpy-cross +MICROPY_MPYCROSS_DEPENDENCY = $(MICROPY_MPYCROSS) +endif all: .PHONY: all diff --git a/py/mkrules.cmake b/py/mkrules.cmake index 7589255b20..9d08017931 100644 --- a/py/mkrules.cmake +++ b/py/mkrules.cmake @@ -129,11 +129,27 @@ if(MICROPY_FROZEN_MANIFEST) set(MICROPY_LIB_DIR ${MICROPY_DIR}/../micropython-lib) endif() + # If MICROPY_MPYCROSS is not explicitly defined in the environment (which + # is what makemanifest.py will use) then create an mpy-cross dependency + # to automatically build mpy-cross if needed. + set(MICROPY_MPYCROSS $ENV{MICROPY_MPYCROSS}) + if(NOT MICROPY_MPYCROSS) + set(MICROPY_MPYCROSS_DEPENDENCY ${MICROPY_DIR}/mpy-cross/mpy-cross) + if(NOT MICROPY_MAKE_EXECUTABLE) + set(MICROPY_MAKE_EXECUTABLE make) + endif() + add_custom_command( + OUTPUT ${MICROPY_MPYCROSS_DEPENDENCY} + COMMAND ${MICROPY_MAKE_EXECUTABLE} -C ${MICROPY_DIR}/mpy-cross + ) + endif() + add_custom_command( OUTPUT ${MICROPY_FROZEN_CONTENT} COMMAND ${Python3_EXECUTABLE} ${MICROPY_DIR}/tools/makemanifest.py -o ${MICROPY_FROZEN_CONTENT} -v "MPY_DIR=${MICROPY_DIR}" -v "MPY_LIB_DIR=${MICROPY_LIB_DIR}" -v "PORT_DIR=${MICROPY_PORT_DIR}" -v "BOARD_DIR=${MICROPY_BOARD_DIR}" -b "${CMAKE_BINARY_DIR}" -f${MICROPY_CROSS_FLAGS} ${MICROPY_FROZEN_MANIFEST} DEPENDS MICROPY_FORCE_BUILD ${MICROPY_QSTRDEFS_GENERATED} + ${MICROPY_MPYCROSS_DEPENDENCY} VERBATIM ) endif() diff --git a/py/mkrules.mk b/py/mkrules.mk index 50f35ffb22..b121260c07 100644 --- a/py/mkrules.mk +++ b/py/mkrules.mk @@ -95,14 +95,14 @@ $(OBJ): | $(HEADER_BUILD)/qstrdefs.enum.h $(HEADER_BUILD)/mpversion.h # - if anything in QSTR_GLOBAL_DEPENDENCIES is newer, then process all source files ($^) # - else, if list of newer prerequisites ($?) is not empty, then process just these ($?) # - else, process all source files ($^) [this covers "make -B" which can set $? to empty] -$(HEADER_BUILD)/qstr.split: $(SRC_QSTR) $(SRC_QSTR_PREPROCESSOR) $(QSTR_GLOBAL_DEPENDENCIES) | $(HEADER_BUILD)/mpversion.h $(PY_SRC)/genlast.py +$(HEADER_BUILD)/qstr.split: $(SRC_QSTR) $(SRC_QSTR_PREPROCESSOR) $(QSTR_GLOBAL_DEPENDENCIES) $(HEADER_BUILD)/moduledefs.h | $(HEADER_BUILD)/mpversion.h $(PY_SRC)/genlast.py $(STEPECHO) "GEN $@" - $(Q)$(PYTHON3) $(PY_SRC)/genlast.py $(HEADER_BUILD)/qstr $(if $(filter $?,$(QSTR_GLOBAL_DEPENDENCIES)),$^,$(if $?,$?,$^)) -- $(SRC_QSTR_PREPROCESSOR) -- $(CPP) $(QSTR_GEN_EXTRA_CFLAGS) $(CFLAGS) + $(Q)$(PYTHON) $(PY_SRC)/genlast.py $(HEADER_BUILD)/qstr $(if $(filter $?,$(QSTR_GLOBAL_DEPENDENCIES)),$^,$(if $?,$?,$^)) -- $(SRC_QSTR_PREPROCESSOR) -- $(CPP) $(QSTR_GEN_EXTRA_CFLAGS) $(CFLAGS) $(Q)$(TOUCH) $@ $(QSTR_DEFS_COLLECTED): $(HEADER_BUILD)/qstr.split $(PY_SRC)/makeqstrdefs.py $(STEPECHO) "GEN $@" - $(Q)$(PYTHON3) $(PY_SRC)/makeqstrdefs.py cat - $(HEADER_BUILD)/qstr $(QSTR_DEFS_COLLECTED) + $(Q)$(PYTHON) $(PY_SRC)/makeqstrdefs.py cat - $(HEADER_BUILD)/qstr $(QSTR_DEFS_COLLECTED) # $(sort $(var)) removes duplicates # @@ -117,6 +117,28 @@ $(OBJ_DIRS): $(HEADER_BUILD): $(Q)$(MKDIR) -p $@ + $(MKDIR) -p $@ + +ifneq ($(MICROPY_MPYCROSS_DEPENDENCY),) +# to automatically build mpy-cross, if needed +$(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) +endif + +ifneq ($(FROZEN_MPY_DIR),) +$(error FROZEN_MPY_DIR cannot be used in conjunction with FROZEN_MANIFEST) +endif +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) @@ -125,11 +147,6 @@ $(BUILD)/frozen.c: $(wildcard $(FROZEN_DIR)/*) $(HEADER_BUILD) $(FROZEN_EXTRA_DE endif ifneq ($(FROZEN_MPY_DIRS),) -# to build the MicroPython cross compiler -# Currently not used, because the wrong mpy-cross may be left over from a previous build. Build by hand to make sure. -$(MPY_CROSS): $(TOP)/py/*.[ch] $(TOP)/mpy-cross/*.[ch] $(TOP)/mpy-cross/fmode.c - $(Q)$(MAKE) -C $(TOP)/mpy-cross - # 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) @@ -140,7 +157,7 @@ $(BUILD)/frozen_mpy: $(FROZEN_MPY_DIRS) $(Q)$(PREPROCESS_FROZEN_MODULES) -o $@ $(FROZEN_MPY_DIRS) $(Q)$(CD) $@ && \ $(FIND) -L . -type f -name '*.py' | sed 's=^\./==' | \ -xargs -n1 "$(abspath $(MPY_CROSS))" $(MPY_CROSS_FLAGS) +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 @@ -153,6 +170,13 @@ endif ifneq ($(PROG),) # Build a standalone executable (unix does this) +# The executable should have an .exe extension for builds targetting 'pure' +# Windows, i.e. msvc or mingw builds, but not when using msys or cygwin's gcc. +COMPILER_TARGET := $(shell $(CC) -dumpmachine) +ifneq (,$(findstring mingw,$(COMPILER_TARGET))) +PROG := $(PROG).exe +endif + all: $(PROG) $(PROG): $(OBJ) @@ -161,9 +185,9 @@ $(PROG): $(OBJ) # we may want to compile using Thumb, but link with non-Thumb libc. $(Q)$(CC) -o $@ $^ $(LIB) $(LDFLAGS) ifdef STRIP_CIRCUITPYTHON - $(Q)$(STRIP) $(STRIPFLAGS_EXTRA) $(PROG) + $(Q)$(STRIP) $(STRIPFLAGS_EXTRA) $@ endif - $(Q)$(SIZE) $$(find $(BUILD) -path "$(BUILD)/build/frozen*.o") $(PROG) + $(Q)$(SIZE) $$(find $(BUILD) -path "$(BUILD)/build/frozen*.o") $@ clean: clean-prog clean-prog: @@ -176,6 +200,7 @@ endif submodules: $(ECHO) "Updating submodules: $(GIT_SUBMODULES)" ifneq ($(GIT_SUBMODULES),) + $(Q)git submodule sync $(addprefix $(TOP)/,$(GIT_SUBMODULES)) $(Q)git submodule update --init $(addprefix $(TOP)/,$(GIT_SUBMODULES)) endif .PHONY: submodules diff --git a/py/modbuiltins.c b/py/modbuiltins.c index f5ab07c404..e56b43047a 100644 --- a/py/modbuiltins.c +++ b/py/modbuiltins.c @@ -232,7 +232,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_hex_obj, mp_builtin_hex); #if MICROPY_PY_BUILTINS_INPUT #include "py/mphal.h" -#include "lib/mp-readline/readline.h" +#include "shared/readline/readline.h" // A port can define mp_hal_readline if they want to use a custom function here #ifndef mp_hal_readline @@ -324,7 +324,7 @@ STATIC mp_obj_t mp_builtin_next(size_t n_args, const mp_obj_t *args) { if (n_args == 1) { mp_obj_t ret = mp_iternext_allow_raise(args[0]); if (ret == MP_OBJ_STOP_ITERATION) { - mp_raise_type(&mp_type_StopIteration); + mp_raise_StopIteration(MP_STATE_THREAD(stop_iteration_arg)); } else { return ret; } @@ -338,7 +338,7 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_next_obj, 1, 2, mp_builtin_next); STATIC mp_obj_t mp_builtin_next(mp_obj_t o) { mp_obj_t ret = mp_iternext_allow_raise(o); if (ret == MP_OBJ_STOP_ITERATION) { - mp_raise_type(&mp_type_StopIteration); + mp_raise_StopIteration(MP_STATE_THREAD(stop_iteration_arg)); } else { return ret; } @@ -553,7 +553,7 @@ STATIC mp_obj_t mp_builtin_sorted(size_t n_args, const mp_obj_t *args, mp_map_t if (n_args > 1) { mp_raise_TypeError(MP_ERROR_TEXT("must use keyword argument for key function")); } - mp_obj_t self = mp_type_list.make_new(&mp_type_list, 1, args, NULL); + mp_obj_t self = mp_type_list.make_new(&mp_type_list, 1, 0, args); mp_obj_list_sort(1, &self, kwargs); return self; diff --git a/py/modio.c b/py/modio.c index a5a565955d..18918cf3ce 100644 --- a/py/modio.c +++ b/py/modio.c @@ -46,11 +46,11 @@ STATIC const mp_obj_type_t mp_type_iobase; STATIC const mp_obj_base_t iobase_singleton = {&mp_type_iobase}; -STATIC mp_obj_t iobase_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { +STATIC mp_obj_t iobase_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { (void)type; (void)n_args; + (void)n_kw; (void)args; - (void)kw_args; return MP_OBJ_FROM_PTR(&iobase_singleton); } @@ -122,8 +122,8 @@ typedef struct _mp_obj_bufwriter_t { byte buf[0]; } mp_obj_bufwriter_t; -STATIC mp_obj_t bufwriter_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { - mp_arg_check_num(n_args, kw_args, 2, 2, false); +STATIC mp_obj_t bufwriter_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { + mp_arg_check_num(n_args, n_kw, 2, 2, false); size_t alloc = mp_obj_get_int(args[1]); mp_obj_bufwriter_t *o = m_new_obj_var(mp_obj_bufwriter_t, byte, alloc); o->base.type = type; diff --git a/py/modsys.c b/py/modsys.c index 484e29f411..6016570933 100644 --- a/py/modsys.c +++ b/py/modsys.c @@ -113,9 +113,9 @@ STATIC const MP_DEFINE_STR_OBJ(mp_sys_platform_obj, MICROPY_PY_SYS_PLATFORM); // exit([retval]): raise SystemExit, with optional argument given to the exception STATIC mp_obj_t mp_sys_exit(size_t n_args, const mp_obj_t *args) { if (n_args == 0) { - nlr_raise(mp_obj_new_exception(&mp_type_SystemExit)); + mp_raise_type(&mp_type_SystemExit); } else { - mp_raise_arg1(&mp_type_SystemExit, args[0]); + mp_raise_type_arg(&mp_type_SystemExit, args[0]); } } MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_sys_exit_obj, 0, 1, mp_sys_exit); diff --git a/py/modthread.c b/py/modthread.c index fd52b9dfb5..333d750a36 100644 --- a/py/modthread.c +++ b/py/modthread.c @@ -176,6 +176,8 @@ STATIC void *thread_entry(void *args_in) { // The GC starts off unlocked on this thread. ts.gc_lock_depth = 0; + ts.mp_pending_exception = MP_OBJ_NULL; + // set locals and globals from the calling context mp_locals_set(args->dict_locals); mp_globals_set(args->dict_globals); @@ -186,7 +188,6 @@ STATIC void *thread_entry(void *args_in) { mp_thread_start(); // TODO set more thread-specific state here: - // mp_pending_exception? (root pointer) // cur_exception (root pointer) DEBUG_printf("[thread] start ts=%p args=%p stack=%p\n", &ts, &args, MP_STATE_THREAD(stack_top)); diff --git a/py/moduerrno.c b/py/moduerrno.c index d13028e73a..56d903f115 100644 --- a/py/moduerrno.c +++ b/py/moduerrno.c @@ -105,6 +105,8 @@ const mp_obj_module_t mp_module_uerrno = { .globals = (mp_obj_dict_t *)&mp_module_uerrno_globals, }; +MP_REGISTER_MODULE(MP_QSTR_errno, mp_module_uerrno, MICROPY_PY_UERRNO); + qstr mp_errno_to_str(mp_obj_t errno_val) { // Otherwise, return the Exxxx string for that error code #if MICROPY_PY_UERRNO_ERRORCODE diff --git a/py/mpconfig.h b/py/mpconfig.h index 973900053f..98a11c15ad 100644 --- a/py/mpconfig.h +++ b/py/mpconfig.h @@ -495,7 +495,8 @@ /* Optimisations */ // Whether to use computed gotos in the VM, or a switch -// Computed gotos are roughly 10% faster, and increase VM code size by a little +// Computed gotos are roughly 10% faster, and increase VM code size by a little, +// e.g. ~1kiB on Cortex M4. // Note: enabling this will use the gcc-specific extensions of ranged designated // initialisers and addresses of labels, which are not part of the C99 standard. #ifndef MICROPY_OPT_COMPUTED_GOTO @@ -910,6 +911,11 @@ typedef double mp_float_t; #define MICROPY_PY_ASYNC_AWAIT (1) #endif +// Support for literal string interpolation, f-strings (see PEP 498, Python 3.6+) +#ifndef MICROPY_PY_FSTRINGS +#define MICROPY_PY_FSTRINGS (0) +#endif + // Support for assignment expressions with := (see PEP 572, Python 3.8+) #ifndef MICROPY_PY_ASSIGN_EXPR #define MICROPY_PY_ASSIGN_EXPR (1) @@ -1098,7 +1104,7 @@ typedef double mp_float_t; #endif // Whether to provide the built-in input() function. The implementation of this -// uses mp-readline, so can only be enabled if the port uses this readline. +// 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) #endif @@ -1357,6 +1363,13 @@ typedef double mp_float_t; #define MICROPY_PY_USELECT (0) #endif +// Whether to enable the select() function in the "uselect" module (baremetal +// implementation). This is present for compatibility but can be disabled to +// save space. +#ifndef MICROPY_PY_USELECT_SELECT +#define MICROPY_PY_USELECT_SELECT (1) +#endif + // Whether to provide "utime" module functions implementation // in terms of mp_hal_* functions. #ifndef MICROPY_PY_UTIME_MP_HAL @@ -1414,6 +1427,11 @@ typedef double mp_float_t; #define MICROPY_PY_UJSON (0) #endif +// Whether to support the "separators" argument to dump, dumps +#ifndef MICROPY_PY_UJSON_SEPARATORS +#define MICROPY_PY_UJSON_SEPARATORS (1) +#endif + #ifndef CIRCUITPY_ULAB #define CIRCUITPY_ULAB (0) #endif diff --git a/py/mperrno.h b/py/mperrno.h index 0c25b6329c..f9819169e0 100644 --- a/py/mperrno.h +++ b/py/mperrno.h @@ -82,6 +82,7 @@ #define MP_EHOSTUNREACH (113) // No route to host #define MP_EALREADY (114) // Operation already in progress #define MP_EINPROGRESS (115) // Operation now in progress +#define MP_ECANCELED (125) // Operation canceled #else @@ -137,6 +138,7 @@ #define MP_EHOSTUNREACH EHOSTUNREACH #define MP_EALREADY EALREADY #define MP_EINPROGRESS EINPROGRESS +#define MP_ECANCELED ECANCELED #endif diff --git a/py/mpprint.h b/py/mpprint.h index 9284935f96..616f21a91e 100644 --- a/py/mpprint.h +++ b/py/mpprint.h @@ -52,6 +52,14 @@ typedef struct _mp_print_t { mp_print_strn_t print_strn; } mp_print_t; +typedef struct _mp_print_ext_t { + mp_print_t base; + const char *item_separator; + const char *key_separator; +}mp_print_ext_t; + +#define MP_PRINT_GET_EXT(print) ((mp_print_ext_t *)print) + // All (non-debug) prints go through one of the two interfaces below. // 1) Wrapper for platform print function, which wraps MP_PLAT_PRINT_STRN. extern const mp_print_t mp_plat_print; diff --git a/py/mpstate.h b/py/mpstate.h index 38f1f5188d..2f9dafd925 100644 --- a/py/mpstate.h +++ b/py/mpstate.h @@ -152,9 +152,6 @@ typedef struct _mp_state_vm_t { // dictionary with loaded modules (may be exposed as sys.modules) mp_obj_dict_t mp_loaded_modules_dict; - // pending exception object (MP_OBJ_NULL if not pending) - volatile mp_obj_t mp_pending_exception; - #if MICROPY_ENABLE_SCHEDULER mp_sched_item_t sched_queue[MICROPY_SCHEDULER_DEPTH]; #endif @@ -273,6 +270,12 @@ typedef struct _mp_state_thread_t { nlr_buf_t *nlr_top; + // pending exception object (MP_OBJ_NULL if not pending) + volatile mp_obj_t mp_pending_exception; + + // If MP_OBJ_STOP_ITERATION is propagated then this holds its argument. + mp_obj_t stop_iteration_arg; + #if MICROPY_PY_SYS_SETTRACE mp_obj_t prof_trace_callback; bool prof_callback_is_executing; @@ -292,12 +295,13 @@ extern mp_state_ctx_t mp_state_ctx; #define MP_STATE_VM(x) (mp_state_ctx.vm.x) #define MP_STATE_MEM(x) (mp_state_ctx.mem.x) +#define MP_STATE_MAIN_THREAD(x) (mp_state_ctx.thread.x) #if MICROPY_PY_THREAD extern mp_state_thread_t *mp_thread_get_state(void); #define MP_STATE_THREAD(x) (mp_thread_get_state()->x) #else -#define MP_STATE_THREAD(x) (mp_state_ctx.thread.x) +#define MP_STATE_THREAD(x) MP_STATE_MAIN_THREAD(x) #endif #endif // MICROPY_INCLUDED_PY_MPSTATE_H diff --git a/py/mpz.c b/py/mpz.c index d7a19f65c4..b871b76b7c 100644 --- a/py/mpz.c +++ b/py/mpz.c @@ -745,7 +745,7 @@ void mpz_set_from_ll(mpz_t *z, long long val, bool is_signed) { unsigned long long uval; if (is_signed && val < 0) { z->neg = 1; - uval = -val; + uval = -(unsigned long long)val; } else { z->neg = 0; uval = val; diff --git a/py/obj.c b/py/obj.c index fa3cd0c51c..45f8c96859 100644 --- a/py/obj.c +++ b/py/obj.c @@ -29,7 +29,7 @@ #include #include -#include "lib/utils/interrupt_char.h" +#include "shared/runtime/interrupt_char.h" #include "py/obj.h" #include "py/objtype.h" #include "py/objint.h" diff --git a/py/obj.h b/py/obj.h index a043154ada..823922ad1a 100644 --- a/py/obj.h +++ b/py/obj.h @@ -539,7 +539,7 @@ typedef struct _mp_obj_iter_buf_t { struct _mp_buffer_info_t; typedef void (*mp_print_fun_t)(const mp_print_t *print, mp_obj_t o, mp_print_kind_t kind); -typedef mp_obj_t (*mp_make_new_fun_t)(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args); +typedef mp_obj_t (*mp_make_new_fun_t)(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args); typedef mp_obj_t (*mp_call_fun_t)(mp_obj_t fun, size_t n_args, size_t n_kw, const mp_obj_t *args); typedef mp_obj_t (*mp_unary_op_fun_t)(mp_unary_op_t op, mp_obj_t); typedef mp_obj_t (*mp_binary_op_fun_t)(mp_binary_op_t op, mp_obj_t, mp_obj_t); @@ -847,7 +847,6 @@ extern mp_float_t uint64_to_float(uint64_t ui64); extern uint64_t float_to_uint64(float f); #endif mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args); #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_NONE #define mp_obj_new_exception_msg(exc_type, msg) mp_obj_new_exception(exc_type) @@ -895,9 +894,11 @@ bool mp_obj_is_callable(mp_obj_t o_in); mp_obj_t mp_obj_equal_not_equal(mp_binary_op_t op, mp_obj_t o1, mp_obj_t o2); bool mp_obj_equal(mp_obj_t o1, mp_obj_t o2); +// returns true if o is bool, small int or long int static inline bool mp_obj_is_integer(mp_const_obj_t o) { return mp_obj_is_int(o) || mp_obj_is_bool(o); -} // returns true if o is bool, small int or long int +} + mp_int_t mp_obj_get_int(mp_const_obj_t arg); mp_int_t mp_obj_get_int_truncated(mp_const_obj_t arg); bool mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value); @@ -938,9 +939,13 @@ 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_t mp_obj_exception_get_traceback_obj(mp_obj_t self_in); mp_obj_t mp_obj_exception_get_value(mp_obj_t self_in); -mp_obj_t mp_obj_exception_make_new(const mp_obj_type_t *type_in, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args); +mp_obj_t mp_obj_exception_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args); mp_obj_t mp_alloc_emergency_exception_buf(mp_obj_t size_in); void mp_init_emergency_exception_buf(void); +static inline mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg) { + assert(exc_type->make_new == mp_obj_exception_make_new); + return mp_obj_exception_make_new(exc_type, 1, 0, &arg); +} // str bool mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); @@ -1021,7 +1026,7 @@ typedef struct _mp_obj_dict_t { mp_obj_base_t base; mp_map_t map; } mp_obj_dict_t; -mp_obj_t mp_obj_dict_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args); +mp_obj_t mp_obj_dict_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args); void mp_obj_dict_init(mp_obj_dict_t *dict, size_t n_args); size_t mp_obj_dict_len(mp_obj_t self_in); mp_obj_t mp_obj_dict_get(mp_obj_t self_in, mp_obj_t index); diff --git a/py/objarray.c b/py/objarray.c index eea1a97c1d..b71687fb35 100644 --- a/py/objarray.c +++ b/py/objarray.c @@ -169,9 +169,9 @@ STATIC mp_obj_t array_construct(char typecode, mp_obj_t initializer) { #endif #if MICROPY_PY_ARRAY -STATIC mp_obj_t array_make_new(const mp_obj_type_t *type_in, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { +STATIC mp_obj_t array_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { (void)type_in; - mp_arg_check_num(n_args, kw_args, 1, 2, false); + mp_arg_check_num(n_args, n_kw, 1, 2, false); // get typecode const char *typecode = mp_obj_str_get_str(args[0]); @@ -187,9 +187,9 @@ STATIC mp_obj_t array_make_new(const mp_obj_type_t *type_in, size_t n_args, cons #endif #if MICROPY_PY_BUILTINS_BYTEARRAY -STATIC mp_obj_t bytearray_make_new(const mp_obj_type_t *type_in, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { +STATIC mp_obj_t bytearray_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { (void)type_in; - mp_arg_check_num(n_args, kw_args, 0, 3, false); + mp_arg_check_num(n_args, n_kw, 0, 3, false); if (n_args == 0) { // no args: construct an empty bytearray @@ -218,13 +218,13 @@ mp_obj_t mp_obj_new_memoryview(byte typecode, size_t nitems, void *items) { return MP_OBJ_FROM_PTR(self); } -STATIC mp_obj_t memoryview_make_new(const mp_obj_type_t *type_in, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { +STATIC mp_obj_t memoryview_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { (void)type_in; // TODO possibly allow memoryview constructor to take start/stop so that one // can do memoryview(b, 4, 8) instead of memoryview(b)[4:8] (uses less RAM) - mp_arg_check_num(n_args, kw_args, 1, 1, false); + mp_arg_check_num(n_args, n_kw, 1, 1, false); mp_buffer_info_t bufinfo; mp_get_buffer_raise(args[0], &bufinfo, MP_BUFFER_READ); @@ -704,7 +704,7 @@ STATIC mp_obj_t array_decode(size_t n_args, const mp_obj_t *args) { args = new_args; n_args++; } - return mp_obj_str_make_new(&mp_type_str, n_args, args, NULL); + return mp_obj_str_make_new(&mp_type_str, n_args, 0, args); } MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(array_decode_obj, 1, 3, array_decode); #endif diff --git a/py/objbool.c b/py/objbool.c index c1f1d8f359..13d10ffae3 100644 --- a/py/objbool.c +++ b/py/objbool.c @@ -60,9 +60,9 @@ STATIC void bool_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_ } } -STATIC mp_obj_t bool_make_new(const mp_obj_type_t *type_in, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { +STATIC mp_obj_t bool_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { (void)type_in; - mp_arg_check_num(n_args, kw_args, 0, 1, false); + mp_arg_check_num(n_args, n_kw, 0, 1, false); if (n_args == 0) { return mp_const_false; diff --git a/py/objcomplex.c b/py/objcomplex.c index f8f8c5807d..b37b059d59 100644 --- a/py/objcomplex.c +++ b/py/objcomplex.c @@ -75,9 +75,9 @@ STATIC void complex_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_ } } -STATIC mp_obj_t complex_make_new(const mp_obj_type_t *type_in, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { +STATIC mp_obj_t complex_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { (void)type_in; - mp_arg_check_num(n_args, kw_args, 0, 2, false); + mp_arg_check_num(n_args, n_kw, 0, 2, false); switch (n_args) { case 0: diff --git a/py/objdeque.c b/py/objdeque.c index ae0bde4578..2d29d71e3b 100644 --- a/py/objdeque.c +++ b/py/objdeque.c @@ -44,8 +44,8 @@ typedef struct _mp_obj_deque_t { #define FLAG_CHECK_OVERFLOW 1 } mp_obj_deque_t; -STATIC mp_obj_t deque_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { - mp_arg_check_num(n_args, kw_args, 2, 3, false); +STATIC mp_obj_t deque_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { + mp_arg_check_num(n_args, n_kw, 2, 3, false); /* Initialization from existing sequence is not supported, so an empty tuple must be passed as such. */ diff --git a/py/objdict.c b/py/objdict.c index bb06989b90..5f233741fa 100644 --- a/py/objdict.c +++ b/py/objdict.c @@ -72,8 +72,15 @@ STATIC mp_map_elem_t *dict_iter_next(mp_obj_dict_t *dict, size_t *cur) { STATIC void dict_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { mp_obj_dict_t *self = MP_OBJ_TO_PTR(self_in); bool first = true; + const char *item_separator = ", "; + const char *key_separator = ": "; if (!(MICROPY_PY_UJSON && kind == PRINT_JSON)) { kind = PRINT_REPR; + } else { + #if MICROPY_PY_UJSON_SEPARATORS + item_separator = MP_PRINT_GET_EXT(print)->item_separator; + key_separator = MP_PRINT_GET_EXT(print)->key_separator; + #endif } if (MICROPY_PY_COLLECTIONS_ORDEREDDICT && self->base.type != &mp_type_dict && kind != PRINT_JSON) { mp_printf(print, "%q(", self->base.type->name); @@ -83,7 +90,7 @@ STATIC void dict_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_ mp_map_elem_t *next = NULL; while ((next = dict_iter_next(self, &cur)) != NULL) { if (!first) { - mp_print_str(print, ", "); + mp_print_str(print, item_separator); } first = false; bool add_quote = MICROPY_PY_UJSON && kind == PRINT_JSON && !mp_obj_is_str_or_bytes(next->key); @@ -94,7 +101,7 @@ STATIC void dict_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_ if (add_quote) { mp_print_str(print, "\""); } - mp_print_str(print, ": "); + mp_print_str(print, key_separator); mp_obj_print_helper(print, next->value, kind); } mp_print_str(print, "}"); @@ -103,7 +110,7 @@ STATIC void dict_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_ } } -mp_obj_t mp_obj_dict_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { +mp_obj_t mp_obj_dict_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { mp_obj_t dict_out = mp_obj_new_dict(0); mp_obj_dict_t *dict = MP_OBJ_TO_PTR(dict_out); dict->base.type = type; @@ -112,12 +119,11 @@ mp_obj_t mp_obj_dict_make_new(const mp_obj_type_t *type, size_t n_args, const mp dict->map.is_ordered = 1; } #endif - if (n_args > 0 || kw_args != NULL) { - mp_obj_t args2[2] = {dict_out, NULL}; // args[0] is always valid, even if it's not a positional arg - if (n_args > 0) { - args2[1] = args[0]; - } - dict_update(n_args + 1, args2, kw_args); // dict_update will check that n_args + 1 == 1 or 2 + if (n_args > 0 || n_kw > 0) { + mp_obj_t args2[2] = {dict_out, args[0]}; // args[0] is always valid, even if it's not a positional arg + mp_map_t kwargs; + mp_map_init_fixed_table(&kwargs, n_kw, args + n_args); + dict_update(n_args + 1, args2, &kwargs); // dict_update will check that n_args + 1 == 1 or 2 } return dict_out; } @@ -193,7 +199,7 @@ mp_obj_t mp_obj_dict_get(mp_obj_t self_in, mp_obj_t index) { mp_obj_dict_t *self = MP_OBJ_TO_PTR(self_in); mp_map_elem_t *elem = mp_map_lookup(&self->map, index, MP_MAP_LOOKUP); if (elem == NULL) { - mp_raise_arg1(&mp_type_KeyError, index); + mp_raise_type_arg(&mp_type_KeyError, index); } else { return elem->value; } @@ -209,7 +215,7 @@ STATIC mp_obj_t dict_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { mp_obj_dict_t *self = MP_OBJ_TO_PTR(self_in); mp_map_elem_t *elem = mp_map_lookup(&self->map, index, MP_MAP_LOOKUP); if (elem == NULL) { - mp_raise_arg1(&mp_type_KeyError, index); + mp_raise_type_arg(&mp_type_KeyError, index); } else { return elem->value; } @@ -298,7 +304,7 @@ STATIC mp_obj_t dict_get_helper(size_t n_args, const mp_obj_t *args, mp_map_look if (elem == NULL || elem->value == MP_OBJ_NULL) { if (n_args == 2) { if (lookup_kind == MP_MAP_LOOKUP_REMOVE_IF_FOUND) { - mp_raise_arg1(&mp_type_KeyError, args[1]); + mp_raise_type_arg(&mp_type_KeyError, args[1]); } else { value = mp_const_none; } @@ -362,7 +368,7 @@ STATIC mp_obj_t dict_update(size_t n_args, const mp_obj_t *args, mp_map_t *kwarg mp_obj_dict_t *self = MP_OBJ_TO_PTR(args[0]); mp_ensure_not_fixed(self); - mp_arg_check_num(n_args, kwargs, 1, 2, true); + mp_arg_check_num(n_args, kwargs->used, 1, 2, true); if (n_args == 2) { // given a positional argument diff --git a/py/objenumerate.c b/py/objenumerate.c index a79d81f2be..c18ac1dd80 100644 --- a/py/objenumerate.c +++ b/py/objenumerate.c @@ -39,7 +39,7 @@ typedef struct _mp_obj_enumerate_t { STATIC mp_obj_t enumerate_iternext(mp_obj_t self_in); -STATIC mp_obj_t enumerate_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { +STATIC mp_obj_t enumerate_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { #if MICROPY_CPYTHON_COMPAT static const mp_arg_t allowed_args[] = { { MP_QSTR_iterable, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, @@ -50,7 +50,7 @@ STATIC mp_obj_t enumerate_make_new(const mp_obj_type_t *type, size_t n_args, con struct { mp_arg_val_t iterable, start; } arg_vals; - mp_arg_parse_all(n_args, args, kw_args, + mp_arg_parse_all_kw_array(n_args, n_kw, args, MP_ARRAY_SIZE(allowed_args), allowed_args, (mp_arg_val_t *)&arg_vals); // create enumerate object @@ -59,7 +59,7 @@ STATIC mp_obj_t enumerate_make_new(const mp_obj_type_t *type, size_t n_args, con o->iter = mp_getiter(arg_vals.iterable.u_obj, NULL); o->cur = arg_vals.start.u_int; #else - (void)kw_args; + (void)n_kw; mp_obj_enumerate_t *o = m_new_obj(mp_obj_enumerate_t); o->base.type = type; o->iter = mp_getiter(args[0], NULL); diff --git a/py/objexcept.c b/py/objexcept.c index e572225bbc..c7e5cb7675 100644 --- a/py/objexcept.c +++ b/py/objexcept.c @@ -104,6 +104,15 @@ 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) { + assert(mp_obj_is_exception_instance(self_in)); + if (mp_obj_is_native_exception_instance(self_in)) { + return MP_OBJ_TO_PTR(self_in); + } else { + return MP_OBJ_TO_PTR(((mp_obj_instance_t *)MP_OBJ_TO_PTR(self_in))->subobj[0]); + } +} + void mp_obj_exception_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) { mp_obj_exception_t *o = MP_OBJ_TO_PTR(o_in); mp_print_kind_t k = kind & ~PRINT_EXC_SUBCLASS; @@ -121,21 +130,22 @@ void mp_obj_exception_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kin mp_print_str(print, ""); return; } - if (mp_obj_is_small_int(o->args->items[0]) && - mp_obj_is_subclass_fast(MP_OBJ_FROM_PTR(o->base.type), MP_OBJ_FROM_PTR(&mp_type_OSError)) && - o->args->len <= 2) { - // try to provide a nice OSError error message + #if MICROPY_PY_UERRNO + // try to provide a nice OSError error message + if (o->base.type == &mp_type_OSError && o->args->len > 0 && o->args->len < 3 && mp_obj_is_small_int(o->args->items[0])) { char decompressed[50]; const char *msg = mp_common_errno_to_str(o->args->items[0], decompressed, sizeof(decompressed)); if (msg != NULL) { mp_printf(print, "[Errno " INT_FMT "] %s", MP_OBJ_SMALL_INT_VALUE(o->args->items[0]), msg); - // if second arg exists, it is filename. - if (o->args->len == 2) { - mp_printf(print, ": '%s'", mp_obj_str_get_str(o->args->items[1])); + if (o->args->len > 1) { + mp_print_str(print, ": "); + mp_obj_print_helper(print, o->args->items[1], PRINT_STR); } return; } } + #endif + if (o->args->len == 1) { mp_obj_print_helper(print, o->args->items[0], PRINT_STR); return; @@ -145,8 +155,8 @@ void mp_obj_exception_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kin mp_obj_tuple_print(print, MP_OBJ_FROM_PTR(o->args), kind); } -mp_obj_t mp_obj_exception_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { - mp_arg_check_num(n_args, kw_args, 0, MP_OBJ_FUN_ARGS_MAX, false); +mp_obj_t mp_obj_exception_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { + mp_arg_check_num(n_args, n_kw, 0, MP_OBJ_FUN_ARGS_MAX, false); // Try to allocate memory for the exception, with fallback to emergency exception object mp_obj_exception_t *o_exc = m_new_obj_maybe(mp_obj_exception_t); @@ -204,7 +214,7 @@ mp_obj_t mp_obj_exception_make_new(const mp_obj_type_t *type, size_t n_args, con // 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 = MP_OBJ_TO_PTR(self_in); + mp_obj_exception_t *self = get_native_exception(self_in); if (self->args->len == 0) { return mp_const_none; } else { @@ -367,15 +377,9 @@ mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type) { return mp_obj_exception_make_new(exc_type, 0, 0, NULL); } -// "Optimized" version for common(?) case of having 1 exception arg -mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg) { - assert(exc_type->make_new == mp_obj_exception_make_new); - return mp_obj_exception_make_new(exc_type, 1, &arg, NULL); -} - mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, size_t n_args, const mp_obj_t *args) { assert(exc_type->make_new == mp_obj_exception_make_new); - return exc_type->make_new(exc_type, n_args, args, NULL); + return exc_type->make_new(exc_type, n_args, 0, args); } #if MICROPY_ERROR_REPORTING != MICROPY_ERROR_REPORTING_NONE @@ -477,7 +481,7 @@ mp_obj_t mp_obj_new_exception_msg_vlist(const mp_obj_type_t *exc_type, const com o_str->base.type = &mp_type_str; o_str->hash = qstr_compute_hash(o_str->data, o_str->len); mp_obj_t arg = MP_OBJ_FROM_PTR(o_str); - return mp_obj_exception_make_new(exc_type, 1, &arg, NULL); + return mp_obj_exception_make_new(exc_type, 1, 0, &arg); } mp_obj_t mp_obj_new_exception_msg_str(const mp_obj_type_t *exc_type, const char *msg) { @@ -513,7 +517,7 @@ mp_obj_t mp_obj_new_exception_msg_str(const mp_obj_type_t *exc_type, const char o_str->base.type = &mp_type_str; o_str->hash = qstr_compute_hash(o_str->data, o_str->len); mp_obj_t arg = MP_OBJ_FROM_PTR(o_str); - return mp_obj_exception_make_new(exc_type, 1, &arg, NULL); + return mp_obj_exception_make_new(exc_type, 1, 0, &arg); } // return true if the given object is an exception type @@ -546,25 +550,15 @@ bool mp_obj_exception_match(mp_obj_t exc, mp_const_obj_t exc_type) { // traceback handling functions -#define GET_NATIVE_EXCEPTION(self, self_in) \ - /* make sure self_in is an exception instance */ \ - assert(mp_obj_is_exception_instance(self_in)); \ - mp_obj_exception_t *self; \ - if (mp_obj_is_native_exception_instance(self_in)) { \ - self = MP_OBJ_TO_PTR(self_in); \ - } else { \ - self = MP_OBJ_TO_PTR(((mp_obj_instance_t *)MP_OBJ_TO_PTR(self_in))->subobj[0]); \ - } - void mp_obj_exception_clear_traceback(mp_obj_t self_in) { - GET_NATIVE_EXCEPTION(self, self_in); + mp_obj_exception_t *self = get_native_exception(self_in); // just set the traceback to the null object // we don't want to call any memory management functions here self->traceback->data = NULL; } void mp_obj_exception_add_traceback(mp_obj_t self_in, qstr file, size_t line, qstr block) { - GET_NATIVE_EXCEPTION(self, self_in); + mp_obj_exception_t *self = get_native_exception(self_in); // append this traceback info to traceback data // if memory allocation fails (eg because gc is locked), just return @@ -617,7 +611,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) { - GET_NATIVE_EXCEPTION(self, self_in); + mp_obj_exception_t *self = get_native_exception(self_in); if (self->traceback->data == NULL) { *n = 0; @@ -686,7 +680,7 @@ STATIC mp_obj_t code_make_new(qstr file, qstr block) { mp_obj_new_bytearray(0, NULL), // co_lnotab }; - return namedtuple_make_new((const mp_obj_type_t *)&code_type_obj, 15, elems, NULL); + return namedtuple_make_new((const mp_obj_type_t *)&code_type_obj, 15, 0, elems); } STATIC const mp_obj_namedtuple_type_t frame_type_obj = { @@ -731,7 +725,7 @@ STATIC mp_obj_t frame_make_new(mp_obj_t f_code, int f_lineno) { mp_const_none, // f_trace }; - return namedtuple_make_new((const mp_obj_type_t *)&frame_type_obj, 8, elems, NULL); + return namedtuple_make_new((const mp_obj_type_t *)&frame_type_obj, 8, 0, elems); } STATIC const mp_obj_namedtuple_type_t traceback_type_obj = { @@ -771,7 +765,7 @@ STATIC mp_obj_t traceback_from_values(size_t *values, mp_obj_t tb_next) { tb_next, }; - return namedtuple_make_new((const mp_obj_type_t *)&traceback_type_obj, 4, elems, NULL); + return namedtuple_make_new((const mp_obj_type_t *)&traceback_type_obj, 4, 0, elems); }; mp_obj_t mp_obj_exception_get_traceback_obj(mp_obj_t self_in) { diff --git a/py/objfilter.c b/py/objfilter.c index a06a71bf01..c034df28e6 100644 --- a/py/objfilter.c +++ b/py/objfilter.c @@ -34,8 +34,8 @@ typedef struct _mp_obj_filter_t { mp_obj_t iter; } mp_obj_filter_t; -STATIC mp_obj_t filter_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { - mp_arg_check_num(n_args, kw_args, 2, 2, false); +STATIC mp_obj_t filter_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { + mp_arg_check_num(n_args, n_kw, 2, 2, false); mp_obj_filter_t *o = m_new_obj(mp_obj_filter_t); o->base.type = type; o->fun = args[0]; diff --git a/py/objfloat.c b/py/objfloat.c index 7ca89d9176..6d1d10188c 100644 --- a/py/objfloat.c +++ b/py/objfloat.c @@ -121,9 +121,9 @@ STATIC void float_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t } } -STATIC mp_obj_t float_make_new(const mp_obj_type_t *type_in, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { +STATIC mp_obj_t float_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { (void)type_in; - mp_arg_check_num(n_args, kw_args, 0, 1, false); + mp_arg_check_num(n_args, n_kw, 0, 1, false); switch (n_args) { case 0: diff --git a/py/objfun.c b/py/objfun.c index 23698ad95c..55c3fbbb06 100644 --- a/py/objfun.c +++ b/py/objfun.c @@ -54,7 +54,7 @@ STATIC mp_obj_t fun_builtin_0_call(mp_obj_t self_in, size_t n_args, size_t n_kw, (void)args; assert(mp_obj_is_type(self_in, &mp_type_fun_builtin_0)); mp_obj_fun_builtin_fixed_t *self = MP_OBJ_TO_PTR(self_in); - mp_arg_check_num_kw_array(n_args, n_kw, 0, 0, false); + mp_arg_check_num(n_args, n_kw, 0, 0, false); return self->fun._0(); } @@ -71,7 +71,7 @@ const mp_obj_type_t mp_type_fun_builtin_0 = { STATIC mp_obj_t fun_builtin_1_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { assert(mp_obj_is_type(self_in, &mp_type_fun_builtin_1)); mp_obj_fun_builtin_fixed_t *self = MP_OBJ_TO_PTR(self_in); - mp_arg_check_num_kw_array(n_args, n_kw, 1, 1, false); + mp_arg_check_num(n_args, n_kw, 1, 1, false); return self->fun._1(args[0]); } @@ -88,7 +88,7 @@ const mp_obj_type_t mp_type_fun_builtin_1 = { STATIC mp_obj_t fun_builtin_2_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { assert(mp_obj_is_type(self_in, &mp_type_fun_builtin_2)); mp_obj_fun_builtin_fixed_t *self = MP_OBJ_TO_PTR(self_in); - mp_arg_check_num_kw_array(n_args, n_kw, 2, 2, false); + mp_arg_check_num(n_args, n_kw, 2, 2, false); return self->fun._2(args[0], args[1]); } @@ -105,7 +105,7 @@ const mp_obj_type_t mp_type_fun_builtin_2 = { STATIC mp_obj_t fun_builtin_3_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { assert(mp_obj_is_type(self_in, &mp_type_fun_builtin_3)); mp_obj_fun_builtin_fixed_t *self = MP_OBJ_TO_PTR(self_in); - mp_arg_check_num_kw_array(n_args, n_kw, 3, 3, false); + mp_arg_check_num(n_args, n_kw, 3, 3, false); return self->fun._3(args[0], args[1], args[2]); } @@ -208,7 +208,8 @@ STATIC void dump_args(const mp_obj_t *a, size_t sz) { const uint8_t *ip = bytecode; \ size_t n_exc_stack, scope_flags, n_pos_args, n_kwonly_args, n_def_args; \ MP_BC_PRELUDE_SIG_DECODE_INTO(ip, n_state_out_var, n_exc_stack, scope_flags, n_pos_args, n_kwonly_args, n_def_args); \ - \ + (void)scope_flags; (void)n_pos_args; (void)n_kwonly_args; (void)n_def_args; \ + \ /* state size in bytes */ \ state_size_out_var = n_state_out_var * sizeof(mp_obj_t) \ + n_exc_stack * sizeof(mp_exc_stack_t); \ @@ -507,7 +508,7 @@ STATIC mp_uint_t convert_obj_for_inline_asm(mp_obj_t obj) { STATIC mp_obj_t fun_asm_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { mp_obj_fun_asm_t *self = self_in; - mp_arg_check_num_kw_array(n_args, n_kw, self->n_args, self->n_args, false); + mp_arg_check_num(n_args, n_kw, self->n_args, self->n_args, false); const void *fun = MICROPY_MAKE_POINTER_CALLABLE(self->fun_data); diff --git a/py/objgenerator.c b/py/objgenerator.c index f7bf235848..4066c1c566 100644 --- a/py/objgenerator.c +++ b/py/objgenerator.c @@ -199,8 +199,9 @@ mp_vm_return_kind_t mp_obj_gen_resume(mp_obj_t self_in, mp_obj_t send_value, mp_ mp_check_self(mp_obj_is_type(self_in, &mp_type_gen_instance)); mp_obj_gen_instance_t *self = MP_OBJ_TO_PTR(self_in); if (self->code_state.ip == 0) { - // Trying to resume already stopped generator - *ret_val = MP_OBJ_STOP_ITERATION; + // Trying to resume an already stopped generator. + // This is an optimised "raise StopIteration(None)". + *ret_val = mp_const_none; return MP_VM_RETURN_NORMAL; } @@ -259,6 +260,7 @@ mp_vm_return_kind_t mp_obj_gen_resume(mp_obj_t self_in, mp_obj_t send_value, mp_ // subsequent next() may re-execute statements after last yield // again and again, leading to side effects. self->code_state.ip = 0; + // This is an optimised "raise StopIteration(*ret_val)". *ret_val = *self->code_state.sp; break; @@ -283,16 +285,20 @@ mp_vm_return_kind_t mp_obj_gen_resume(mp_obj_t self_in, mp_obj_t send_value, mp_ return ret_kind; } -STATIC mp_obj_t gen_resume_and_raise(mp_obj_t self_in, mp_obj_t send_value, mp_obj_t throw_value) { +STATIC mp_obj_t gen_resume_and_raise(mp_obj_t self_in, mp_obj_t send_value, mp_obj_t throw_value, bool raise_stop_iteration) { mp_obj_t ret; switch (mp_obj_gen_resume(self_in, send_value, throw_value, &ret)) { case MP_VM_RETURN_NORMAL: default: - // Optimize return w/o value in case generator is used in for loop - if (ret == mp_const_none || ret == MP_OBJ_STOP_ITERATION) { - return MP_OBJ_STOP_ITERATION; + // A normal return is a StopIteration, either raise it or return + // MP_OBJ_STOP_ITERATION as an optimisation. + if (ret == mp_const_none) { + ret = MP_OBJ_NULL; + } + if (raise_stop_iteration) { + mp_raise_StopIteration(ret); } else { - nlr_raise(mp_obj_new_exception_arg1(&mp_type_StopIteration, ret)); + return mp_make_stop_iteration(ret); } case MP_VM_RETURN_YIELD: @@ -311,16 +317,11 @@ STATIC mp_obj_t gen_instance_iternext(mp_obj_t self_in) { mp_raise_TypeError(MP_ERROR_TEXT("'coroutine' object is not an iterator")); } #endif - return gen_resume_and_raise(self_in, mp_const_none, MP_OBJ_NULL); + return gen_resume_and_raise(self_in, mp_const_none, MP_OBJ_NULL, false); } STATIC mp_obj_t gen_instance_send(mp_obj_t self_in, mp_obj_t send_value) { - mp_obj_t ret = gen_resume_and_raise(self_in, send_value, MP_OBJ_NULL); - if (ret == MP_OBJ_STOP_ITERATION) { - mp_raise_type(&mp_type_StopIteration); - } else { - return ret; - } + return gen_resume_and_raise(self_in, send_value, MP_OBJ_NULL, true); } STATIC MP_DEFINE_CONST_FUN_OBJ_2(gen_instance_send_obj, gen_instance_send); @@ -357,12 +358,7 @@ STATIC mp_obj_t gen_instance_throw(size_t n_args, const mp_obj_t *args) { exc = args[2]; } - mp_obj_t ret = gen_resume_and_raise(args[0], mp_const_none, exc); - if (ret == MP_OBJ_STOP_ITERATION) { - mp_raise_type(&mp_type_StopIteration); - } else { - return ret; - } + return gen_resume_and_raise(args[0], mp_const_none, exc, true); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(gen_instance_throw_obj, 2, 4, gen_instance_throw); diff --git a/py/objgetitemiter.c b/py/objgetitemiter.c index d41767b4a2..098e7da557 100644 --- a/py/objgetitemiter.c +++ b/py/objgetitemiter.c @@ -48,7 +48,6 @@ STATIC mp_obj_t it_iternext(mp_obj_t self_in) { // an exception was raised mp_obj_type_t *t = (mp_obj_type_t *)((mp_obj_base_t *)nlr.ret_val)->type; if (t == &mp_type_StopIteration || t == &mp_type_IndexError) { - // return MP_OBJ_STOP_ITERATION instead of raising return MP_OBJ_STOP_ITERATION; } else { // re-raise exception diff --git a/py/objint.c b/py/objint.c index fd7b74a14a..50bcbf56f8 100644 --- a/py/objint.c +++ b/py/objint.c @@ -42,9 +42,9 @@ #endif // This dispatcher function is expected to be independent of the implementation of long int -STATIC mp_obj_t mp_obj_int_make_new(const mp_obj_type_t *type_in, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { +STATIC mp_obj_t mp_obj_int_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { (void)type_in; - mp_arg_check_num(n_args, kw_args, 0, 2, false); + mp_arg_check_num(n_args, n_kw, 0, 2, false); switch (n_args) { case 0: @@ -108,14 +108,14 @@ STATIC mp_fp_as_int_class_t mp_classify_fp_as_int(mp_float_t val) { #if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_DOUBLE e |= u.i[MP_ENDIANNESS_BIG] != 0; #endif - if ((e & ~(1 << MP_FLOAT_SIGN_SHIFT_I32)) == 0) { + if ((e & ~(1U << MP_FLOAT_SIGN_SHIFT_I32)) == 0) { // handle case of -0 (when sign is set but rest of bits are zero) e = 0; } else { - e += ((1 << MP_FLOAT_EXP_BITS) - 1) << MP_FLOAT_EXP_SHIFT_I32; + e += ((1U << MP_FLOAT_EXP_BITS) - 1) << MP_FLOAT_EXP_SHIFT_I32; } } else { - e &= ~((1 << MP_FLOAT_EXP_SHIFT_I32) - 1); + e &= ~((1U << MP_FLOAT_EXP_SHIFT_I32) - 1); } // 8 * sizeof(uintptr_t) counts the number of bits for a small int // TODO provide a way to configure this properly diff --git a/py/objlist.c b/py/objlist.c index 41e4a5ef16..9b0e0edaa7 100644 --- a/py/objlist.c +++ b/py/objlist.c @@ -46,13 +46,18 @@ STATIC mp_obj_t list_pop(size_t n_args, const mp_obj_t *args); STATIC void list_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) { mp_obj_list_t *o = MP_OBJ_TO_PTR(o_in); + const char *item_separator = ", "; if (!(MICROPY_PY_UJSON && kind == PRINT_JSON)) { kind = PRINT_REPR; + } else { + #if MICROPY_PY_UJSON_SEPARATORS + item_separator = MP_PRINT_GET_EXT(print)->item_separator; + #endif } mp_print_str(print, "["); for (size_t i = 0; i < o->len; i++) { if (i > 0) { - mp_print_str(print, ", "); + mp_print_str(print, item_separator); } mp_obj_print_helper(print, o->items[i], kind); } @@ -73,9 +78,9 @@ mp_obj_t mp_obj_new_list_from_iter(mp_obj_t iterable) { return list_extend_from_iter(list, iterable); } -STATIC mp_obj_t list_make_new(const mp_obj_type_t *type_in, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { +STATIC mp_obj_t list_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { (void)type_in; - mp_arg_check_num(n_args, kw_args, 0, 1, false); + mp_arg_check_num(n_args, n_kw, 0, 1, false); switch (n_args) { case 0: diff --git a/py/objmap.c b/py/objmap.c index 262c32bf7d..dc1dc1387d 100644 --- a/py/objmap.c +++ b/py/objmap.c @@ -36,8 +36,8 @@ typedef struct _mp_obj_map_t { mp_obj_t iters[]; } mp_obj_map_t; -STATIC mp_obj_t map_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { - mp_arg_check_num(n_args, kw_args, 2, MP_OBJ_FUN_ARGS_MAX, false); +STATIC mp_obj_t map_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { + mp_arg_check_num(n_args, n_kw, 2, MP_OBJ_FUN_ARGS_MAX, false); mp_obj_map_t *o = m_new_obj_var(mp_obj_map_t, mp_obj_t, n_args - 1); o->base.type = type; o->n_iters = n_args - 1; diff --git a/py/objnamedtuple.c b/py/objnamedtuple.c index 9c21c4dd0a..c970d1afba 100644 --- a/py/objnamedtuple.c +++ b/py/objnamedtuple.c @@ -100,13 +100,9 @@ void namedtuple_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { } } -mp_obj_t namedtuple_make_new(const mp_obj_type_t *type_in, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { +mp_obj_t namedtuple_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { const mp_obj_namedtuple_type_t *type = (const mp_obj_namedtuple_type_t *)type_in; size_t num_fields = type->n_fields; - size_t n_kw = 0; - if (kw_args != NULL) { - n_kw = kw_args->used; - } if (n_args + n_kw != num_fields) { #if MICROPY_ERROR_REPORTING <= MICROPY_ERROR_REPORTING_TERSE mp_arg_error_terse_mismatch(); @@ -130,26 +126,25 @@ mp_obj_t namedtuple_make_new(const mp_obj_type_t *type_in, size_t n_args, const // Fill in the remaining slots with the keyword args memset(&tuple->items[n_args], 0, sizeof(mp_obj_t) * n_kw); - for (size_t i = 0; i < n_kw; i++) { - qstr kw = mp_obj_str_get_qstr(kw_args->table[i].key); + for (size_t i = n_args; i < n_args + 2 * n_kw; i += 2) { + qstr kw = mp_obj_str_get_qstr(args[i]); size_t id = mp_obj_namedtuple_find_field(type, kw); if (id == (size_t)-1) { #if MICROPY_ERROR_REPORTING <= MICROPY_ERROR_REPORTING_TERSE mp_arg_error_terse_mismatch(); #else - mp_raise_TypeError_varg( - MP_ERROR_TEXT("unexpected keyword argument '%q'"), kw); + mp_raise_msg_varg(&mp_type_TypeError, MP_ERROR_TEXT("unexpected keyword argument '%q'"), kw); #endif } if (tuple->items[id] != MP_OBJ_NULL) { #if MICROPY_ERROR_REPORTING <= MICROPY_ERROR_REPORTING_TERSE mp_arg_error_terse_mismatch(); #else - mp_raise_TypeError_varg( + mp_raise_msg_varg(&mp_type_TypeError, MP_ERROR_TEXT("function got multiple values for argument '%q'"), kw); #endif } - tuple->items[id] = kw_args->table[i].value; + tuple->items[id] = args[i + 1]; } return MP_OBJ_FROM_PTR(tuple); diff --git a/py/objnamedtuple.h b/py/objnamedtuple.h index e39f569908..4ebefb9d3a 100644 --- a/py/objnamedtuple.h +++ b/py/objnamedtuple.h @@ -51,7 +51,7 @@ void namedtuple_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t ki size_t mp_obj_namedtuple_find_field(const mp_obj_namedtuple_type_t *type, qstr name); void namedtuple_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest); mp_obj_namedtuple_type_t *mp_obj_new_namedtuple_base(size_t n_fields, mp_obj_t *fields); -mp_obj_t namedtuple_make_new(const mp_obj_type_t *type_in, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args); +mp_obj_t namedtuple_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args); #endif // MICROPY_PY_COLLECTIONS diff --git a/py/objobject.c b/py/objobject.c index 0fdaf0f2b3..d9c75faff9 100644 --- a/py/objobject.c +++ b/py/objobject.c @@ -35,9 +35,9 @@ typedef struct _mp_obj_object_t { mp_obj_base_t base; } mp_obj_object_t; -STATIC mp_obj_t object_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { +STATIC mp_obj_t object_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { (void)args; - mp_arg_check_num(n_args, kw_args, 0, 0, false); + mp_arg_check_num(n_args, n_kw, 0, 0, false); mp_obj_object_t *o = m_new_obj(mp_obj_object_t); o->base.type = type; return MP_OBJ_FROM_PTR(o); diff --git a/py/objproperty.c b/py/objproperty.c index 32c50f5b94..ebb70014a4 100644 --- a/py/objproperty.c +++ b/py/objproperty.c @@ -33,7 +33,7 @@ #if MICROPY_PY_BUILTINS_PROPERTY -STATIC mp_obj_t property_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { +STATIC mp_obj_t property_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { enum { ARG_fget, ARG_fset, ARG_fdel, ARG_doc }; static const mp_arg_t allowed_args[] = { { MP_QSTR_, MP_ARG_OBJ, {.u_rom_obj = MP_ROM_NONE} }, @@ -42,7 +42,7 @@ STATIC mp_obj_t property_make_new(const mp_obj_type_t *type, size_t n_args, cons { MP_QSTR_doc, MP_ARG_OBJ, {.u_rom_obj = MP_ROM_NONE} }, }; mp_arg_val_t vals[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args, args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, vals); + mp_arg_parse_all_kw_array(n_args, n_kw, args, MP_ARRAY_SIZE(allowed_args), allowed_args, vals); mp_obj_property_t *o = m_new_obj(mp_obj_property_t); o->base.type = type; diff --git a/py/objrange.c b/py/objrange.c index 331b9b8bd9..b23ab23bd7 100644 --- a/py/objrange.c +++ b/py/objrange.c @@ -94,8 +94,8 @@ STATIC void range_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind } } -STATIC mp_obj_t range_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { - mp_arg_check_num(n_args, kw_args, 1, 3, false); +STATIC mp_obj_t range_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { + mp_arg_check_num(n_args, n_kw, 1, 3, false); mp_obj_range_t *o = m_new_obj(mp_obj_range_t); o->base.type = type; diff --git a/py/objreversed.c b/py/objreversed.c index 6226c50f8a..fe517cc37f 100644 --- a/py/objreversed.c +++ b/py/objreversed.c @@ -37,8 +37,8 @@ typedef struct _mp_obj_reversed_t { mp_uint_t cur_index; // current index, plus 1; 0=no more, 1=last one (index 0) } mp_obj_reversed_t; -STATIC mp_obj_t reversed_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { - mp_arg_check_num(n_args, kw_args, 1, 1, false); +STATIC mp_obj_t reversed_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { + mp_arg_check_num(n_args, n_kw, 1, 1, false); // check if __reversed__ exists, and if so delegate to it mp_obj_t dest[2]; diff --git a/py/objset.c b/py/objset.c index 064cbc8d55..d7dda6ba59 100644 --- a/py/objset.c +++ b/py/objset.c @@ -101,8 +101,8 @@ STATIC void set_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t #endif } -STATIC mp_obj_t set_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { - mp_arg_check_num(n_args, kw_args, 0, 1, false); +STATIC mp_obj_t set_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { + mp_arg_check_num(n_args, n_kw, 0, 1, false); switch (n_args) { case 0: { @@ -294,7 +294,7 @@ STATIC mp_obj_t set_issubset_internal(mp_obj_t self_in, mp_obj_t other_in, bool if (is_set_or_frozenset(self_in)) { self = MP_OBJ_TO_PTR(self_in); } else { - self = MP_OBJ_TO_PTR(set_make_new(&mp_type_set, 1, &self_in, NULL)); + self = MP_OBJ_TO_PTR(set_make_new(&mp_type_set, 1, 0, &self_in)); cleanup_self = true; } @@ -303,7 +303,7 @@ STATIC mp_obj_t set_issubset_internal(mp_obj_t self_in, mp_obj_t other_in, bool if (is_set_or_frozenset(other_in)) { other = MP_OBJ_TO_PTR(other_in); } else { - other = MP_OBJ_TO_PTR(set_make_new(&mp_type_set, 1, &other_in, NULL)); + other = MP_OBJ_TO_PTR(set_make_new(&mp_type_set, 1, 0, &other_in)); cleanup_other = true; } mp_obj_t out = mp_const_true; @@ -374,7 +374,7 @@ STATIC mp_obj_t set_remove(mp_obj_t self_in, mp_obj_t item) { check_set(self_in); mp_obj_set_t *self = MP_OBJ_TO_PTR(self_in); if (mp_set_lookup(&self->set, item, MP_MAP_LOOKUP_REMOVE_IF_FOUND) == MP_OBJ_NULL) { - mp_raise_arg1(&mp_type_KeyError, item); + mp_raise_type_arg(&mp_type_KeyError, item); } return mp_const_none; } diff --git a/py/objslice.c b/py/objslice.c index 0b214c4c1a..142f62fdac 100644 --- a/py/objslice.c +++ b/py/objslice.c @@ -90,12 +90,12 @@ STATIC void slice_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { #if MICROPY_PY_BUILTINS_SLICE_ATTRS STATIC mp_obj_t slice_make_new(const mp_obj_type_t *type, - size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { + size_t n_args, size_t n_kw, const mp_obj_t *args) { if (type != &mp_type_slice) { mp_raise_NotImplementedError(MP_ERROR_TEXT("Cannot subclass slice")); } // check number of arguments - mp_arg_check_num(n_args, kw_args, 1, 3, false); + mp_arg_check_num(n_args, n_kw, 1, 3, false); // 1st argument is the pin mp_obj_t start = mp_const_none; diff --git a/py/objstr.c b/py/objstr.c index ed49eba172..3d45383bb3 100644 --- a/py/objstr.c +++ b/py/objstr.c @@ -141,14 +141,8 @@ STATIC void str_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t } } -mp_obj_t mp_obj_str_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { - #if MICROPY_CPYTHON_COMPAT - if (kw_args != NULL && kw_args->used != 0) { - mp_arg_error_unimpl_kw(); - } - #endif - - mp_arg_check_num(n_args, kw_args, 0, 3, false); +mp_obj_t mp_obj_str_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { + mp_arg_check_num(n_args, n_kw, 0, 3, false); switch (n_args) { case 0: @@ -199,15 +193,15 @@ mp_obj_t mp_obj_str_make_new(const mp_obj_type_t *type, size_t n_args, const mp_ } } -STATIC mp_obj_t bytes_make_new(const mp_obj_type_t *type_in, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { +STATIC mp_obj_t bytes_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { (void)type_in; #if MICROPY_CPYTHON_COMPAT - if (kw_args != NULL && kw_args->used != 0) { + if (n_kw) { mp_arg_error_unimpl_kw(); } #else - (void)kw_args; + (void)n_kw; #endif if (n_args == 0) { @@ -489,7 +483,7 @@ STATIC mp_obj_t str_join(mp_obj_t self_in, mp_obj_t arg) { if (!mp_obj_is_type(arg, &mp_type_list) && !mp_obj_is_type(arg, &mp_type_tuple)) { // arg is not a list nor a tuple, try to convert it to a list // TODO: Try to optimize? - arg = mp_type_list.make_new(&mp_type_list, 1, &arg, NULL); + arg = mp_type_list.make_new(&mp_type_list, 1, 0, &arg); } mp_obj_get_array(arg, &seq_len, &seq_items); @@ -1107,7 +1101,7 @@ STATIC vstr_t mp_obj_str_format_helper(const char *str, const char *top, int *ar field_name = lookup; mp_map_elem_t *key_elem = mp_map_lookup(kwargs, field_q, MP_MAP_LOOKUP); if (key_elem == NULL) { - mp_raise_arg1(&mp_type_KeyError, field_q); + mp_raise_type_arg(&mp_type_KeyError, field_q); } arg = key_elem->value; } @@ -1562,7 +1556,7 @@ STATIC mp_obj_t str_modulo_format(mp_obj_t pattern, size_t n_args, const mp_obj_ char ch = mp_obj_get_int(arg); mp_print_strn(&print, &ch, 1, flags, ' ', width); } else { - mp_raise_TypeError(MP_ERROR_TEXT("integer required")); + mp_raise_TypeError(MP_ERROR_TEXT("%%c requires int or char")); } break; @@ -1935,7 +1929,7 @@ STATIC mp_obj_t bytes_decode(size_t n_args, const mp_obj_t *args) { args = new_args; n_args++; } - return mp_obj_str_make_new(&mp_type_str, n_args, args, NULL); + return mp_obj_str_make_new(&mp_type_str, n_args, 0, args); } MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bytes_decode_obj, 1, 3, bytes_decode); @@ -1948,7 +1942,7 @@ STATIC mp_obj_t str_encode(size_t n_args, const mp_obj_t *args) { args = new_args; n_args++; } - return bytes_make_new(NULL, n_args, args, NULL); + return bytes_make_new(NULL, n_args, 0, args); } MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_encode_obj, 1, 3, str_encode); #endif diff --git a/py/objstr.h b/py/objstr.h index 74b48c1c71..8031839146 100644 --- a/py/objstr.h +++ b/py/objstr.h @@ -61,7 +61,7 @@ const byte *mp_obj_str_get_data_no_check(mp_obj_t self_in, size_t *len); else { str_len = ((mp_obj_str_t *)MP_OBJ_TO_PTR(str_obj_in))->len; str_data = ((mp_obj_str_t *)MP_OBJ_TO_PTR(str_obj_in))->data; } #endif -mp_obj_t mp_obj_str_make_new(const mp_obj_type_t *type_in, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args); +mp_obj_t mp_obj_str_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args); void mp_str_print_json(const mp_print_t *print, const byte *str_data, size_t str_len); mp_obj_t mp_obj_str_format(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs); mp_obj_t mp_obj_str_split(size_t n_args, const mp_obj_t *args); diff --git a/py/objstringio.c b/py/objstringio.c index 9bf95440ba..336a041baf 100644 --- a/py/objstringio.c +++ b/py/objstringio.c @@ -186,8 +186,8 @@ STATIC mp_obj_stringio_t *stringio_new(const mp_obj_type_t *type) { return o; } -STATIC mp_obj_t stringio_make_new(const mp_obj_type_t *type_in, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { - (void)kw_args; // TODO check kw_args->used == 0 +STATIC mp_obj_t stringio_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { + mp_arg_check_num(n_args, n_kw, 0, 1, false); mp_uint_t sz = 16; bool initdata = false; diff --git a/py/objtuple.c b/py/objtuple.c index 0fc50c53fd..55957b68bf 100644 --- a/py/objtuple.c +++ b/py/objtuple.c @@ -40,15 +40,19 @@ void mp_obj_tuple_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) { mp_obj_tuple_t *o = MP_OBJ_TO_PTR(o_in); + const char *item_separator = ", "; if (MICROPY_PY_UJSON && kind == PRINT_JSON) { mp_print_str(print, "["); + #if MICROPY_PY_UJSON_SEPARATORS + item_separator = MP_PRINT_GET_EXT(print)->item_separator; + #endif } else { mp_print_str(print, "("); kind = PRINT_REPR; } for (size_t i = 0; i < o->len; i++) { if (i > 0) { - mp_print_str(print, ", "); + mp_print_str(print, item_separator); } mp_obj_print_helper(print, o->items[i], kind); } @@ -62,10 +66,10 @@ void mp_obj_tuple_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t } } -STATIC mp_obj_t mp_obj_tuple_make_new(const mp_obj_type_t *type_in, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { +STATIC mp_obj_t mp_obj_tuple_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { (void)type_in; - mp_arg_check_num(n_args, kw_args, 0, 1, false); + mp_arg_check_num(n_args, n_kw, 0, 1, false); switch (n_args) { case 0: diff --git a/py/objtype.c b/py/objtype.c index b692760997..962f59eb55 100644 --- a/py/objtype.c +++ b/py/objtype.c @@ -48,7 +48,7 @@ #define ENABLE_SPECIAL_ACCESSORS \ (MICROPY_PY_DESCRIPTORS || MICROPY_PY_DELATTR_SETATTR || MICROPY_PY_BUILTINS_PROPERTY) -STATIC mp_obj_t static_class_method_make_new(const mp_obj_type_t *self_in, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args); +STATIC mp_obj_t static_class_method_make_new(const mp_obj_type_t *self, size_t n_args, size_t n_kw, const mp_obj_t *args); /******************************************************************************/ // instance object @@ -95,9 +95,24 @@ STATIC mp_obj_t native_base_init_wrapper(size_t n_args, const mp_obj_t *pos_args mp_obj_instance_t *self = MP_OBJ_TO_PTR(pos_args[0]); const mp_obj_type_t *native_base = NULL; instance_count_native_bases(self->base.type, &native_base); - self->subobj[0] = native_base->make_new(native_base, n_args - 1, pos_args + 1, kw_args); + + size_t n_kw = kw_args ? kw_args->used : 0; + + // consume the type object + pos_args++; + n_args--; + + mp_obj_t *args2 = m_new(mp_obj_t, n_args + 2 * n_kw); + // copy in args + memcpy(args2, pos_args, n_args * sizeof(mp_obj_t)); + // copy in kwargs + memcpy(args2 + n_args, kw_args->table, 2 * n_kw * sizeof(mp_obj_t)); + self->subobj[0] = native_base->make_new(native_base, n_args, n_kw, args2); + m_del(mp_obj_t, args2, n_args + 2 * n_kw); + return mp_const_none; } + STATIC MP_DEFINE_CONST_FUN_OBJ_KW(native_base_init_wrapper_obj, 1, native_base_init_wrapper); #if !MICROPY_CPYTHON_COMPAT @@ -294,7 +309,7 @@ STATIC void instance_print(const mp_print_t *print, mp_obj_t self_in, mp_print_k mp_printf(print, "<%q object at %p>", mp_obj_get_type_qstr(self_in), self); } -mp_obj_t mp_obj_instance_make_new(const mp_obj_type_t *self, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { +mp_obj_t mp_obj_instance_make_new(const mp_obj_type_t *self, size_t n_args, size_t n_kw, const mp_obj_t *args) { assert(mp_obj_is_instance_type(self)); // look for __new__ function @@ -310,10 +325,6 @@ mp_obj_t mp_obj_instance_make_new(const mp_obj_type_t *self, size_t n_args, cons const mp_obj_type_t *native_base = NULL; mp_obj_instance_t *o; - size_t n_kw = 0; - if (kw_args != 0) { - n_kw = kw_args->used; - } if (init_fn[0] == MP_OBJ_NULL || init_fn[0] == MP_OBJ_SENTINEL) { // Either there is no __new__() method defined or there is a native // constructor. In both cases create a blank instance. @@ -335,11 +346,7 @@ mp_obj_t mp_obj_instance_make_new(const mp_obj_type_t *self, size_t n_args, cons // TODO(tannewt): Could this be on the stack? It's deleted below. mp_obj_t *args2 = m_new(mp_obj_t, 1 + n_args + 2 * n_kw); args2[0] = MP_OBJ_FROM_PTR(self); - memcpy(args2 + 1, args, n_args * sizeof(mp_obj_t)); - if (kw_args) { - // copy in kwargs - memcpy(args2 + 1 + n_args, kw_args->table, 2 * n_kw * sizeof(mp_obj_t)); - } + memcpy(args2 + 1, args, (n_args + 2 * n_kw) * sizeof(mp_obj_t)); new_ret = mp_call_function_n_kw(init_fn[0], n_args + 1, n_kw, args2); m_del(mp_obj_t, args2, 1 + n_args + 2 * n_kw); } @@ -365,7 +372,7 @@ mp_obj_t mp_obj_instance_make_new(const mp_obj_type_t *self, size_t n_args, cons mp_obj_class_lookup(&lookup, self); if (init_fn[0] != MP_OBJ_NULL) { mp_obj_t init_ret; - if (n_args == 0 && kw_args == NULL) { + if (n_args == 0 && n_kw == 0) { init_ret = mp_call_method_n_kw(0, 0, init_fn); } else { // TODO(tannewt): Could this be on the stack? It's deleted below. @@ -373,8 +380,7 @@ mp_obj_t mp_obj_instance_make_new(const mp_obj_type_t *self, size_t n_args, cons args2[0] = init_fn[0]; args2[1] = init_fn[1]; // copy in kwargs - memcpy(args2 + 2, args, n_args * sizeof(mp_obj_t)); - memcpy(args2 + 2 + n_args, kw_args->table, 2 * n_kw * sizeof(mp_obj_t)); + memcpy(args2 + 2, args, (n_args + 2 * n_kw) * sizeof(mp_obj_t)); init_ret = mp_call_method_n_kw(n_args, n_kw, args2); m_del(mp_obj_t, args2, 2 + n_args + 2 * n_kw); } @@ -391,7 +397,7 @@ mp_obj_t mp_obj_instance_make_new(const mp_obj_type_t *self, size_t n_args, cons // If the type had a native base that was not explicitly initialised // (constructed) by the Python __init__() method then construct it now. if (native_base != NULL && o->subobj[0] == MP_OBJ_FROM_PTR(&native_base_init_wrapper_obj)) { - o->subobj[0] = native_base->make_new(native_base, n_args, args, kw_args); + o->subobj[0] = native_base->make_new(native_base, n_args, n_kw, args); } return MP_OBJ_FROM_PTR(o); @@ -1009,10 +1015,10 @@ STATIC void type_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_ mp_printf(print, "", self->name); } -STATIC mp_obj_t type_make_new(const mp_obj_type_t *type_in, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { +STATIC mp_obj_t type_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { (void)type_in; - mp_arg_check_num(n_args, kw_args, 1, 3, false); + mp_arg_check_num(n_args, n_kw, 1, 3, false); switch (n_args) { case 1: @@ -1042,10 +1048,7 @@ STATIC mp_obj_t type_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp #endif } - // create a map directly from the given args array and make a new instance - mp_map_t kw_args; - mp_map_init_fixed_table(&kw_args, n_kw, args + n_args); - mp_obj_t o = self->make_new(self, n_args, args, &kw_args); + mp_obj_t o = self->make_new(self, n_args, n_kw, args); // return new instance return o; @@ -1269,7 +1272,7 @@ mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict) // __new__ slot exists; check if it is a function if (mp_obj_is_fun(elem->value)) { // __new__ is a function, wrap it in a staticmethod decorator - elem->value = static_class_method_make_new(&mp_type_staticmethod, 1, &elem->value, NULL); + elem->value = static_class_method_make_new(&mp_type_staticmethod, 1, 0, &elem->value); } } @@ -1295,11 +1298,11 @@ STATIC void super_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind mp_print_str(print, ">"); } -STATIC mp_obj_t super_make_new(const mp_obj_type_t *type_in, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { +STATIC mp_obj_t super_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { (void)type_in; // 0 arguments are turned into 2 in the compiler // 1 argument is not yet implemented - mp_arg_check_num(n_args, kw_args, 2, 2, false); + mp_arg_check_num(n_args, n_kw, 2, 2, false); if (!mp_obj_is_type(args[0], &mp_type_type)) { mp_raise_TypeError(MP_ERROR_TEXT("first argument to super() must be type")); } @@ -1511,10 +1514,10 @@ mp_obj_t mp_obj_cast_to_native_base(mp_obj_t self_in, mp_const_obj_t native_type /******************************************************************************/ // staticmethod and classmethod types (probably should go in a different file) -STATIC mp_obj_t static_class_method_make_new(const mp_obj_type_t *self, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { +STATIC mp_obj_t static_class_method_make_new(const mp_obj_type_t *self, size_t n_args, size_t n_kw, const mp_obj_t *args) { assert(self == &mp_type_staticmethod || self == &mp_type_classmethod); - mp_arg_check_num(n_args, kw_args, 1, 1, false); + mp_arg_check_num(n_args, n_kw, 1, 1, false); mp_obj_static_class_method_t *o = m_new_obj(mp_obj_static_class_method_t); *o = (mp_obj_static_class_method_t) {{self}, args[0]}; diff --git a/py/objtype.h b/py/objtype.h index 072c39d3e7..17b8048c19 100644 --- a/py/objtype.h +++ b/py/objtype.h @@ -51,7 +51,7 @@ mp_obj_t mp_obj_instance_call(mp_obj_t self_in, size_t n_args, size_t n_kw, cons #define mp_obj_is_instance_type(type) ((type)->make_new == mp_obj_instance_make_new) #define mp_obj_is_native_type(type) ((type)->make_new != mp_obj_instance_make_new) // this needs to be exposed for the above macros to work correctly -mp_obj_t mp_obj_instance_make_new(const mp_obj_type_t *self_in, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args); +mp_obj_t mp_obj_instance_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args); // this needs to be exposed for mp_getiter mp_obj_t mp_obj_instance_getiter(mp_obj_t self_in, mp_obj_iter_buf_t *iter_buf); diff --git a/py/objzip.c b/py/objzip.c index 111f6bf5ec..91716493d6 100644 --- a/py/objzip.c +++ b/py/objzip.c @@ -36,8 +36,8 @@ typedef struct _mp_obj_zip_t { mp_obj_t iters[]; } mp_obj_zip_t; -STATIC mp_obj_t zip_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { - mp_arg_check_num(n_args, kw_args, 0, MP_OBJ_FUN_ARGS_MAX, false); +STATIC mp_obj_t zip_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { + mp_arg_check_num(n_args, n_kw, 0, MP_OBJ_FUN_ARGS_MAX, false); mp_obj_zip_t *o = m_new_obj_var(mp_obj_zip_t, mp_obj_t, n_args); o->base.type = type; diff --git a/py/parse.c b/py/parse.c index 689125f117..f5f3e774da 100644 --- a/py/parse.c +++ b/py/parse.c @@ -1172,57 +1172,23 @@ mp_parse_tree_t mp_parse(mp_lexer_t *lex, mp_parse_input_kind_t input_kind) { ) { syntax_error:; mp_obj_t exc; - switch (lex->tok_kind) { - case MP_TOKEN_INDENT: - exc = mp_obj_new_exception_msg(&mp_type_IndentationError, - MP_ERROR_TEXT("unexpected indent")); - break; - case MP_TOKEN_DEDENT_MISMATCH: - exc = mp_obj_new_exception_msg(&mp_type_IndentationError, - MP_ERROR_TEXT("unindent does not match any outer indentation level")); - break; - #if MICROPY_COMP_FSTRING_LITERAL - #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_DETAILED - case MP_TOKEN_FSTRING_BACKSLASH: - exc = mp_obj_new_exception_msg(&mp_type_SyntaxError, - MP_ERROR_TEXT("f-string expression part cannot include a backslash")); - break; - case MP_TOKEN_FSTRING_COMMENT: - exc = mp_obj_new_exception_msg(&mp_type_SyntaxError, - MP_ERROR_TEXT("f-string expression part cannot include a '#'")); - break; - case MP_TOKEN_FSTRING_UNCLOSED: - exc = mp_obj_new_exception_msg(&mp_type_SyntaxError, - MP_ERROR_TEXT("f-string: expecting '}'")); - break; - case MP_TOKEN_FSTRING_UNOPENED: - exc = mp_obj_new_exception_msg(&mp_type_SyntaxError, - MP_ERROR_TEXT("f-string: single '}' is not allowed")); - break; - case MP_TOKEN_FSTRING_EMPTY_EXP: - exc = mp_obj_new_exception_msg(&mp_type_SyntaxError, - MP_ERROR_TEXT("f-string: empty expression not allowed")); - break; - case MP_TOKEN_FSTRING_RAW: - exc = mp_obj_new_exception_msg(&mp_type_NotImplementedError, - MP_ERROR_TEXT("raw f-strings are not implemented")); - break; - #else - case MP_TOKEN_FSTRING_BACKSLASH: - case MP_TOKEN_FSTRING_COMMENT: - case MP_TOKEN_FSTRING_UNCLOSED: - case MP_TOKEN_FSTRING_UNOPENED: - case MP_TOKEN_FSTRING_EMPTY_EXP: - case MP_TOKEN_FSTRING_RAW: - exc = mp_obj_new_exception_msg(&mp_type_SyntaxError, - MP_ERROR_TEXT("malformed f-string")); - break; - #endif - #endif - default: - exc = mp_obj_new_exception_msg(&mp_type_SyntaxError, - MP_ERROR_TEXT("invalid syntax")); - break; + if (lex->tok_kind == MP_TOKEN_INDENT) { + exc = mp_obj_new_exception_msg(&mp_type_IndentationError, + MP_ERROR_TEXT("unexpected indent")); + } else if (lex->tok_kind == MP_TOKEN_DEDENT_MISMATCH) { + exc = mp_obj_new_exception_msg(&mp_type_IndentationError, + MP_ERROR_TEXT("unindent doesn't match any outer indent level")); + #if MICROPY_PY_FSTRINGS + } else if (lex->tok_kind == MP_TOKEN_MALFORMED_FSTRING) { + exc = mp_obj_new_exception_msg(&mp_type_SyntaxError, + MP_ERROR_TEXT("malformed f-string")); + } else if (lex->tok_kind == MP_TOKEN_FSTRING_RAW) { + exc = mp_obj_new_exception_msg(&mp_type_SyntaxError, + MP_ERROR_TEXT("raw f-strings are not supported")); + #endif + } else { + exc = mp_obj_new_exception_msg(&mp_type_SyntaxError, + MP_ERROR_TEXT("invalid syntax")); } // add traceback to give info about file name and location // we don't have a 'block' name, so just pass the NULL qstr to indicate this diff --git a/py/profile.c b/py/profile.c index 2e59b97703..7d1d7ed659 100644 --- a/py/profile.c +++ b/py/profile.c @@ -297,7 +297,7 @@ STATIC mp_obj_t mp_prof_callback_invoke(mp_obj_t callback, prof_callback_args_t mp_prof_is_executing = false; - if (MP_STATE_VM(mp_pending_exception) != MP_OBJ_NULL) { + if (MP_STATE_THREAD(mp_pending_exception) != MP_OBJ_NULL) { mp_handle_pending(true); } return top; diff --git a/py/py.mk b/py/py.mk index 7c3eaf4f46..0db1d43cfe 100644 --- a/py/py.mk +++ b/py/py.mk @@ -210,8 +210,8 @@ PY_EXTMOD_O_BASENAME = \ extmod/vfs_fat_file.o \ extmod/vfs_lfs.o \ extmod/utime_mphal.o \ - lib/embed/abort_.o \ - lib/utils/printf.o \ + shared/libc/abort_.o \ + shared/libc/printf.o \ # prepend the build destination prefix to the py object files PY_CORE_O = $(addprefix $(BUILD)/, $(PY_CORE_O_BASENAME)) @@ -251,14 +251,7 @@ FORCE: $(HEADER_BUILD)/mpversion.h: FORCE | $(HEADER_BUILD) $(STEPECHO) "GEN $@" - $(Q)$(PYTHON3) $(PY_SRC)/makeversionhdr.py $@ - -# build a list of registered modules for py/objmodule.c. -$(HEADER_BUILD)/moduledefs.h: $(SRC_QSTR) $(QSTR_GLOBAL_DEPENDENCIES) | $(HEADER_BUILD)/mpversion.h - @$(STEPECHO) "GEN $@" - $(Q)$(PYTHON3) $(PY_SRC)/makemoduledefs.py --vpath="., $(TOP), $(USER_C_MODULES)" $(SRC_QSTR) > $@ - -SRC_QSTR += $(HEADER_BUILD)/moduledefs.h + $(Q)$(PYTHON) $(PY_SRC)/makeversionhdr.py $@ # mpconfigport.mk is optional, but changes to it may drastically change # overall config, so they need to be caught @@ -274,7 +267,7 @@ $(HEADER_BUILD)/qstrdefs.preprocessed.h: $(PY_QSTR_DEFS) $(QSTR_DEFS) $(QSTR_DEF # qstr data $(HEADER_BUILD)/qstrdefs.enum.h: $(PY_SRC)/makeqstrdata.py $(HEADER_BUILD)/qstrdefs.preprocessed.h $(STEPECHO) "GEN $@" - $(Q)$(PYTHON3) $(PY_SRC)/makeqstrdata.py $(HEADER_BUILD)/qstrdefs.preprocessed.h > $@ + $(Q)$(PYTHON) $(PY_SRC)/makeqstrdata.py $(HEADER_BUILD)/qstrdefs.preprocessed.h > $@ # Adding an order only dependency on $(HEADER_BUILD) causes $(HEADER_BUILD) to get # created before we run the script to generate the .h @@ -282,19 +275,20 @@ $(HEADER_BUILD)/qstrdefs.enum.h: $(PY_SRC)/makeqstrdata.py $(HEADER_BUILD)/qstrd # the lines in "" and then unwrap after the preprocessor is finished. $(HEADER_BUILD)/qstrdefs.generated.h: $(PY_SRC)/makeqstrdata.py $(HEADER_BUILD)/$(TRANSLATION).mo $(HEADER_BUILD)/qstrdefs.preprocessed.h $(STEPECHO) "GEN $@" - $(Q)$(PYTHON3) $(PY_SRC)/makeqstrdata.py --compression_filename $(HEADER_BUILD)/compression.generated.h --translation $(HEADER_BUILD)/$(TRANSLATION).mo $(HEADER_BUILD)/qstrdefs.preprocessed.h > $@ + $(Q)$(PYTHON) $(PY_SRC)/makeqstrdata.py --compression_filename $(HEADER_BUILD)/compression.generated.h --translation $(HEADER_BUILD)/$(TRANSLATION).mo $(HEADER_BUILD)/qstrdefs.preprocessed.h > $@ $(PY_BUILD)/qstr.o: $(HEADER_BUILD)/qstrdefs.generated.h -# Standard C functions like memset need to be compiled with special flags so -# the compiler does not optimise these functions in terms of themselves. -CFLAGS_BUILTIN ?= -ffreestanding -fno-builtin -fno-lto -$(BUILD)/lib/libc/string0.o: CFLAGS += $(CFLAGS_BUILTIN) + +# build a list of registered modules for py/objmodule.c. +$(HEADER_BUILD)/moduledefs.h: $(SRC_QSTR) $(QSTR_GLOBAL_DEPENDENCIES) | $(HEADER_BUILD)/mpversion.h + @$(ECHO) "GEN $@" + $(Q)$(PYTHON) $(PY_SRC)/makemoduledefs.py --vpath="., $(TOP), $(USER_C_MODULES)" $(SRC_QSTR) > $@ # Standard C functions like memset need to be compiled with special flags so # the compiler does not optimise these functions in terms of themselves. CFLAGS_BUILTIN ?= -ffreestanding -fno-builtin -fno-lto -$(BUILD)/lib/libc/string0.o: CFLAGS += $(CFLAGS_BUILTIN) +$(BUILD)/shared/libc/string0.o: CFLAGS += $(CFLAGS_BUILTIN) # Force nlr code to always be compiled with space-saving optimisation so # that the function preludes are of a minimal and predictable form. diff --git a/py/pystack.c b/py/pystack.c index c48437aa74..43dfd4ed6c 100644 --- a/py/pystack.c +++ b/py/pystack.c @@ -43,8 +43,7 @@ void *mp_pystack_alloc(size_t n_bytes) { #endif if (MP_STATE_THREAD(pystack_cur) + n_bytes > MP_STATE_THREAD(pystack_end)) { // out of memory in the pystack - mp_raise_arg1(&mp_type_RuntimeError, - MP_OBJ_NEW_QSTR(MP_QSTR_pystack_space_exhausted)); + mp_raise_type_arg(&mp_type_RuntimeError, MP_OBJ_NEW_QSTR(MP_QSTR_pystack_space_exhausted)); } void *ptr = MP_STATE_THREAD(pystack_cur); MP_STATE_THREAD(pystack_cur) += n_bytes; diff --git a/py/reload.c b/py/reload.c index 9f20004690..996826b930 100644 --- a/py/reload.c +++ b/py/reload.c @@ -22,7 +22,7 @@ #include "py/mpstate.h" void mp_raise_reload_exception(void) { - MP_STATE_VM(mp_pending_exception) = MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_reload_exception)); + MP_STATE_THREAD(mp_pending_exception) = MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_reload_exception)); #if MICROPY_ENABLE_SCHEDULER if (MP_STATE_VM(sched_state) == MP_SCHED_IDLE) { MP_STATE_VM(sched_state) = MP_SCHED_PENDING; diff --git a/py/runtime.c b/py/runtime.c index 55f26021ab..ac02f7074c 100644 --- a/py/runtime.c +++ b/py/runtime.c @@ -65,7 +65,7 @@ void mp_init(void) { qstr_init(); // no pending exceptions to start with - MP_STATE_VM(mp_pending_exception) = MP_OBJ_NULL; + MP_STATE_THREAD(mp_pending_exception) = MP_OBJ_NULL; #if MICROPY_ENABLE_SCHEDULER MP_STATE_VM(sched_state) = MP_SCHED_IDLE; MP_STATE_VM(sched_idx) = 0; @@ -287,6 +287,12 @@ mp_obj_t mp_unary_op(mp_unary_op_t op, mp_obj_t arg) { return result; } } + if (op == MP_UNARY_OP_BOOL) { + // Type doesn't have unary_op (or didn't handle MP_UNARY_OP_BOOL), + // so is implicitly True as this code path is impossible to reach + // if arg==mp_const_none. + return mp_const_true; + } // With MP_UNARY_OP_INT, mp_unary_op() becomes a fallback for mp_obj_get_int(). // In this case provide a more focused error message to not confuse, e.g. chr(1.0) #if MICROPY_ERROR_REPORTING <= MICROPY_ERROR_REPORTING_TERSE @@ -393,7 +399,7 @@ mp_obj_t PLACE_IN_ITCM(mp_binary_op)(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t r goto generic_binary_op; } else { // use standard precision - lhs_val <<= rhs_val; + lhs_val = (mp_uint_t)lhs_val << rhs_val; } break; } @@ -1275,6 +1281,7 @@ mp_obj_t mp_iternext_allow_raise(mp_obj_t o_in) { const mp_obj_type_t *type = mp_obj_get_type(o_in); mp_fun_1_t iternext = mp_type_get_iternext_slot(type); if (iternext != NULL) { + MP_STATE_THREAD(stop_iteration_arg) = MP_OBJ_NULL; return iternext(o_in); } else { // check for __next__ method @@ -1301,6 +1308,7 @@ mp_obj_t mp_iternext(mp_obj_t o_in) { const mp_obj_type_t *type = mp_obj_get_type(o_in); mp_fun_1_t iternext = mp_type_get_iternext_slot(type); if (iternext != NULL) { + MP_STATE_THREAD(stop_iteration_arg) = MP_OBJ_NULL; return iternext(o_in); } else { // check for __next__ method @@ -1315,7 +1323,7 @@ mp_obj_t mp_iternext(mp_obj_t o_in) { return ret; } else { if (mp_obj_is_subclass_fast(MP_OBJ_FROM_PTR(((mp_obj_base_t *)nlr.ret_val)->type), MP_OBJ_FROM_PTR(&mp_type_StopIteration))) { - return MP_OBJ_STOP_ITERATION; + return mp_make_stop_iteration(mp_obj_exception_get_value(MP_OBJ_FROM_PTR(nlr.ret_val))); } else { nlr_jump(nlr.ret_val); } @@ -1331,7 +1339,6 @@ mp_obj_t mp_iternext(mp_obj_t o_in) { } } -// TODO: Unclear what to do with StopIterarion exception here. mp_vm_return_kind_t mp_resume(mp_obj_t self_in, mp_obj_t send_value, mp_obj_t throw_value, mp_obj_t *ret_val) { assert((send_value != MP_OBJ_NULL) ^ (throw_value != MP_OBJ_NULL)); const mp_obj_type_t *type = mp_obj_get_type(self_in); @@ -1342,13 +1349,18 @@ mp_vm_return_kind_t mp_resume(mp_obj_t self_in, mp_obj_t send_value, mp_obj_t th mp_fun_1_t iternext = mp_type_get_iternext_slot(type); if (iternext != NULL && send_value == mp_const_none) { + MP_STATE_THREAD(stop_iteration_arg) = MP_OBJ_NULL; mp_obj_t ret = iternext(self_in); *ret_val = ret; if (ret != MP_OBJ_STOP_ITERATION) { return MP_VM_RETURN_YIELD; } else { - // Emulate raise StopIteration() - // Special case, handled in vm.c + // The generator is finished. + // This is an optimised "raise StopIteration(*ret_val)". + *ret_val = MP_STATE_THREAD(stop_iteration_arg); + if (*ret_val == MP_OBJ_NULL) { + *ret_val = mp_const_none; + } return MP_VM_RETURN_NORMAL; } } @@ -1568,10 +1580,6 @@ NORETURN void m_malloc_fail(size_t num_bytes) { MP_ERROR_TEXT("memory allocation failed, allocating %u bytes"), (uint)num_bytes); } -NORETURN void mp_raise_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg) { - nlr_raise(mp_obj_new_exception_arg1(exc_type, arg)); -} - #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_NONE NORETURN void mp_raise_type(const mp_obj_type_t *exc_type) { @@ -1665,10 +1673,6 @@ NORETURN void mp_raise_TypeError_varg(const compressed_string_t *fmt, ...) { va_end(argptr); } -NORETURN void mp_raise_OSError(int errno_) { - mp_raise_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(errno_)); -} - NORETURN void mp_raise_OSError_msg(const compressed_string_t *msg) { mp_raise_msg(&mp_type_OSError, msg); } @@ -1693,7 +1697,7 @@ NORETURN void mp_raise_ConnectionError(const compressed_string_t *msg) { } NORETURN void mp_raise_BrokenPipeError(void) { - mp_raise_arg1(&mp_type_BrokenPipeError, MP_OBJ_NEW_SMALL_INT(MP_EPIPE)); + mp_raise_type_arg(&mp_type_BrokenPipeError, MP_OBJ_NEW_SMALL_INT(MP_EPIPE)); } NORETURN void mp_raise_NotImplementedError(const compressed_string_t *msg) { @@ -1707,6 +1711,7 @@ NORETURN void mp_raise_NotImplementedError_varg(const compressed_string_t *fmt, va_end(argptr); } + NORETURN void mp_raise_OverflowError_varg(const compressed_string_t *fmt, ...) { va_list argptr; va_start(argptr,fmt); @@ -1718,6 +1723,22 @@ NORETURN void mp_raise_MpyError(const compressed_string_t *msg) { mp_raise_msg(&mp_type_MpyError, msg); } +NORETURN void mp_raise_type_arg(const mp_obj_type_t *exc_type, mp_obj_t arg) { + nlr_raise(mp_obj_new_exception_arg1(exc_type, arg)); +} + +NORETURN void mp_raise_StopIteration(mp_obj_t arg) { + if (arg == MP_OBJ_NULL) { + mp_raise_type(&mp_type_StopIteration); + } else { + mp_raise_type_arg(&mp_type_StopIteration, arg); + } +} + +NORETURN void mp_raise_OSError(int errno_) { + mp_raise_type_arg(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(errno_)); +} + #endif #if MICROPY_STACK_CHECK || MICROPY_ENABLE_PYSTACK diff --git a/py/runtime.h b/py/runtime.h index b93f484ec8..f610a04f8a 100644 --- a/py/runtime.h +++ b/py/runtime.h @@ -84,8 +84,9 @@ bool mp_sched_schedule(mp_obj_t function, mp_obj_t arg); int mp_print_mp_int(const mp_print_t *print, mp_obj_t x, int base, int base_char, int flags, char fill, int width, int prec); void mp_arg_check_num_sig(size_t n_args, size_t n_kw, uint32_t sig); -void mp_arg_check_num(size_t n_args, mp_map_t *kw_args, size_t n_args_min, size_t n_args_max, bool takes_kw); -void mp_arg_check_num_kw_array(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, bool takes_kw); +static inline void mp_arg_check_num(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, bool takes_kw) { + mp_arg_check_num_sig(n_args, n_kw, MP_OBJ_FUN_MAKE_SIG(n_args_min, n_args_max, takes_kw)); +} void mp_arg_parse_all(size_t n_pos, const mp_obj_t *pos, mp_map_t *kws, size_t n_allowed, const mp_arg_t *allowed, mp_arg_val_t *out_vals); void mp_arg_parse_all_kw_array(size_t n_pos, size_t n_kw, const mp_obj_t *args, size_t n_allowed, const mp_arg_t *allowed, mp_arg_val_t *out_vals); NORETURN void mp_arg_error_terse_mismatch(void); @@ -165,6 +166,11 @@ mp_obj_t mp_iternext_allow_raise(mp_obj_t o); // may return MP_OBJ_STOP_ITERATIO mp_obj_t mp_iternext(mp_obj_t o); // will always return MP_OBJ_STOP_ITERATION instead of raising StopIteration(...) mp_vm_return_kind_t mp_resume(mp_obj_t self_in, mp_obj_t send_value, mp_obj_t throw_value, mp_obj_t *ret_val); +static inline mp_obj_t mp_make_stop_iteration(mp_obj_t o) { + MP_STATE_THREAD(stop_iteration_arg) = o; + return MP_OBJ_STOP_ITERATION; +} + mp_obj_t mp_make_raise_obj(mp_obj_t o); mp_obj_t mp_import_name(qstr name, mp_obj_t fromlist, mp_obj_t level); @@ -183,9 +189,7 @@ NORETURN void mp_raise_NotImplementedError_no_msg(void); #define mp_raise_NotImplementedError(msg) mp_raise_NotImplementedError_no_msg() #else #define mp_raise_type(exc_type) mp_raise_msg(exc_type, NULL) -#if !(defined(MICROPY_ENABLE_DYNRUNTIME) && MICROPY_ENABLE_DYNRUNTIME) -NORETURN void mp_raise_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); -#endif +NORETURN void mp_raise_type_arg(const mp_obj_type_t *exc_type, mp_obj_t arg); NORETURN void mp_raise_msg(const mp_obj_type_t *exc_type, const compressed_string_t *msg); NORETURN void mp_raise_msg_varg(const mp_obj_type_t *exc_type, const compressed_string_t *fmt, ...); NORETURN void mp_raise_msg_vlist(const mp_obj_type_t *exc_type, const compressed_string_t *fmt, va_list argptr); @@ -200,6 +204,7 @@ NORETURN void mp_raise_RuntimeError(const compressed_string_t *msg); NORETURN void mp_raise_ImportError(const compressed_string_t *msg); NORETURN void mp_raise_IndexError(const compressed_string_t *msg); NORETURN void mp_raise_IndexError_varg(const compressed_string_t *msg, ...); +NORETURN void mp_raise_StopIteration(mp_obj_t arg); NORETURN void mp_raise_OSError(int errno_); NORETURN void mp_raise_OSError_errno_str(int errno_, mp_obj_t str); NORETURN void mp_raise_OSError_msg(const compressed_string_t *msg); diff --git a/py/scheduler.c b/py/scheduler.c index 733722e46a..8e150f41ed 100644 --- a/py/scheduler.c +++ b/py/scheduler.c @@ -28,8 +28,10 @@ #include "py/runtime.h" +// Schedules an exception on the main thread (for exceptions "thrown" by async +// sources such as interrupts and UNIX signal handlers). void MICROPY_WRAP_MP_SCHED_EXCEPTION(mp_sched_exception)(mp_obj_t exc) { - MP_STATE_VM(mp_pending_exception) = exc; + MP_STATE_MAIN_THREAD(mp_pending_exception) = exc; #if MICROPY_ENABLE_SCHEDULER if (MP_STATE_VM(sched_state) == MP_SCHED_IDLE) { MP_STATE_VM(sched_state) = MP_SCHED_PENDING; @@ -66,9 +68,9 @@ void mp_handle_pending(bool raise_exc) { mp_uint_t atomic_state = MICROPY_BEGIN_ATOMIC_SECTION(); // Re-check state is still pending now that we're in the atomic section. if (MP_STATE_VM(sched_state) == MP_SCHED_PENDING) { - mp_obj_t obj = MP_STATE_VM(mp_pending_exception); + mp_obj_t obj = MP_STATE_THREAD(mp_pending_exception); if (obj != MP_OBJ_NULL) { - MP_STATE_VM(mp_pending_exception) = MP_OBJ_NULL; + MP_STATE_THREAD(mp_pending_exception) = MP_OBJ_NULL; if (!mp_sched_num_pending()) { MP_STATE_VM(sched_state) = MP_SCHED_IDLE; } @@ -115,7 +117,7 @@ void mp_sched_unlock(void) { assert(MP_STATE_VM(sched_state) < 0); if (++MP_STATE_VM(sched_state) == 0) { // vm became unlocked - if (MP_STATE_VM(mp_pending_exception) != MP_OBJ_NULL || mp_sched_num_pending()) { + if (MP_STATE_THREAD(mp_pending_exception) != MP_OBJ_NULL || mp_sched_num_pending()) { MP_STATE_VM(sched_state) = MP_SCHED_PENDING; } else { MP_STATE_VM(sched_state) = MP_SCHED_IDLE; @@ -148,9 +150,9 @@ bool MICROPY_WRAP_MP_SCHED_SCHEDULE(mp_sched_schedule)(mp_obj_t function, mp_obj // A variant of this is inlined in the VM at the pending exception check void mp_handle_pending(bool raise_exc) { - if (MP_STATE_VM(mp_pending_exception) != MP_OBJ_NULL) { - mp_obj_t obj = MP_STATE_VM(mp_pending_exception); - MP_STATE_VM(mp_pending_exception) = MP_OBJ_NULL; + if (MP_STATE_THREAD(mp_pending_exception) != MP_OBJ_NULL) { + mp_obj_t obj = MP_STATE_THREAD(mp_pending_exception); + MP_STATE_THREAD(mp_pending_exception) = MP_OBJ_NULL; if (raise_exc) { nlr_raise(obj); } diff --git a/py/showbc.c b/py/showbc.c index 284f134433..e9b43c29e3 100644 --- a/py/showbc.c +++ b/py/showbc.c @@ -174,7 +174,7 @@ const byte *mp_bytecode_print_str(const mp_print_t *print, const byte *ip) { num--; } do { - num = (num * 128) | (*ip & 0x7f); + num = ((mp_uint_t)num << 7) | (*ip & 0x7f); } while ((*ip++ & 0x80) != 0); mp_printf(print, "LOAD_CONST_SMALL_INT " INT_FMT, num); break; diff --git a/py/smallint.h b/py/smallint.h index be70cc78b9..2fcd3fb296 100644 --- a/py/smallint.h +++ b/py/smallint.h @@ -37,7 +37,7 @@ #if MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_A || MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_C #define MP_SMALL_INT_MIN ((mp_int_t)(((mp_int_t)MP_OBJ_WORD_MSBIT_HIGH) >> 1)) -#define MP_SMALL_INT_FITS(n) ((((n) ^ ((n) << 1)) & MP_OBJ_WORD_MSBIT_HIGH) == 0) +#define MP_SMALL_INT_FITS(n) ((((n) ^ ((mp_uint_t)(n) << 1)) & MP_OBJ_WORD_MSBIT_HIGH) == 0) // Mask to truncate mp_int_t to positive value #define MP_SMALL_INT_POSITIVE_MASK ~(MP_OBJ_WORD_MSBIT_HIGH | (MP_OBJ_WORD_MSBIT_HIGH >> 1)) diff --git a/py/vm.c b/py/vm.c index b3919a493c..9ad67bb2e0 100644 --- a/py/vm.c +++ b/py/vm.c @@ -324,7 +324,7 @@ dispatch_loop: DISPATCH(); ENTRY(MP_BC_LOAD_CONST_SMALL_INT): { - mp_int_t num = 0; + mp_uint_t num = 0; if ((ip[0] & 0x40) != 0) { // Number is negative num--; @@ -1269,16 +1269,9 @@ yield: PUSH(ret_value); goto yield; } else if (ret_kind == MP_VM_RETURN_NORMAL) { - // Pop exhausted gen - sp--; - if (ret_value == MP_OBJ_STOP_ITERATION) { - // Optimize StopIteration - // TODO: get StopIteration's value - PUSH(mp_const_none); - } else { - PUSH(ret_value); - } - + // The generator has finished, and returned a value via StopIteration + // Replace exhausted generator with the returned value + SET_TOP(ret_value); // If we injected GeneratorExit downstream, then even // if it was swallowed, we re-raise GeneratorExit GENERATOR_EXIT_IF_NEEDED(t_exc); @@ -1387,9 +1380,9 @@ pending_exception_check: // Re-check state is still pending now that we're in the atomic section. if (MP_STATE_VM(sched_state) == MP_SCHED_PENDING) { MARK_EXC_IP_SELECTIVE(); - mp_obj_t obj = MP_STATE_VM(mp_pending_exception); + mp_obj_t obj = MP_STATE_THREAD(mp_pending_exception); if (obj != MP_OBJ_NULL) { - MP_STATE_VM(mp_pending_exception) = MP_OBJ_NULL; + MP_STATE_THREAD(mp_pending_exception) = MP_OBJ_NULL; if (!mp_sched_num_pending()) { MP_STATE_VM(sched_state) = MP_SCHED_IDLE; } @@ -1403,10 +1396,10 @@ pending_exception_check: } #else // This is an inlined variant of mp_handle_pending - if (MP_STATE_VM(mp_pending_exception) != MP_OBJ_NULL) { + if (MP_STATE_THREAD(mp_pending_exception) != MP_OBJ_NULL) { MARK_EXC_IP_SELECTIVE(); - mp_obj_t obj = MP_STATE_VM(mp_pending_exception); - MP_STATE_VM(mp_pending_exception) = MP_OBJ_NULL; + mp_obj_t obj = MP_STATE_THREAD(mp_pending_exception); + MP_STATE_THREAD(mp_pending_exception) = MP_OBJ_NULL; RAISE(obj); } #endif diff --git a/shared-bindings/_bleio/Adapter.c b/shared-bindings/_bleio/Adapter.c index c126ee79f2..d985b0aecd 100644 --- a/shared-bindings/_bleio/Adapter.c +++ b/shared-bindings/_bleio/Adapter.c @@ -81,7 +81,7 @@ //| """ //| ... //| -STATIC mp_obj_t bleio_adapter_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +STATIC mp_obj_t bleio_adapter_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { #if CIRCUITPY_BLEIO_HCI bleio_adapter_obj_t *self = common_hal_bleio_allocate_adapter_or_raise(); @@ -93,19 +93,12 @@ STATIC mp_obj_t bleio_adapter_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(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - busio_uart_obj_t *uart = args[ARG_uart].u_obj; - if (!mp_obj_is_type(uart, &busio_uart_type)) { - mp_raise_ValueError(translate("Expected a UART")); - } + busio_uart_obj_t *uart = mp_arg_validate_type(args[ARG_uart].u_obj, &busio_uart_type, MP_QSTR_uart); - digitalio_digitalinout_obj_t *rts = args[ARG_rts].u_obj; - digitalio_digitalinout_obj_t *cts = args[ARG_cts].u_obj; - if (!mp_obj_is_type(rts, &digitalio_digitalinout_type) || - !mp_obj_is_type(cts, &digitalio_digitalinout_type)) { - mp_raise_ValueError(translate("Expected a DigitalInOut")); - } + digitalio_digitalinout_obj_t *rts = mp_arg_validate_type(args[ARG_rts].u_obj, &digitalio_digitalinout_type, MP_QSTR_rts); + digitalio_digitalinout_obj_t *cts = mp_arg_validate_type(args[ARG_cts].u_obj, &digitalio_digitalinout_type, MP_QSTR_cts); // Will enable the adapter. common_hal_bleio_adapter_construct_hci_uart(self, uart, rts, cts); @@ -225,7 +218,7 @@ STATIC mp_obj_t bleio_adapter_start_advertising(mp_uint_t n_args, const mp_obj_t { MP_QSTR_timeout, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} }, { MP_QSTR_interval, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, { MP_QSTR_tx_power, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} }, - { MP_QSTR_directed_to, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, + { MP_QSTR_directed_to, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; @@ -257,13 +250,12 @@ STATIC mp_obj_t bleio_adapter_start_advertising(mp_uint_t n_args, const mp_obj_t mp_raise_bleio_BluetoothError(translate("Cannot have scan responses for extended, connectable advertisements.")); } - bleio_address_obj_t *address = MP_OBJ_TO_PTR(args[ARG_directed_to].u_obj); - if (address != NULL && !connectable) { - mp_raise_bleio_BluetoothError(translate("Only connectable advertisements can be directed")); - } - - if (address != NULL && !mp_obj_is_type(address, &bleio_address_type)) { - mp_raise_TypeError(translate("Expected an Address")); + const bleio_address_obj_t *address = NULL; + if (args[ARG_directed_to].u_obj != mp_const_none) { + if (!connectable) { + mp_raise_bleio_BluetoothError(translate("Only connectable advertisements can be directed")); + } + address = mp_arg_validate_type(args[ARG_directed_to].u_obj, &bleio_address_type, MP_QSTR_directed_to); } common_hal_bleio_adapter_start_advertising(self, connectable, anonymous, timeout, interval, @@ -271,7 +263,7 @@ STATIC mp_obj_t bleio_adapter_start_advertising(mp_uint_t n_args, const mp_obj_t return mp_const_none; } -STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_adapter_start_advertising_obj, 2, bleio_adapter_start_advertising); +STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_adapter_start_advertising_obj, 1, bleio_adapter_start_advertising); //| def stop_advertising(self) -> None: //| """Stop sending advertising packets.""" @@ -447,16 +439,12 @@ STATIC mp_obj_t bleio_adapter_connect(mp_uint_t n_args, const mp_obj_t *pos_args 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); - if (!mp_obj_is_type(args[ARG_address].u_obj, &bleio_address_type)) { - mp_raise_TypeError(translate("Expected an Address")); - } - - bleio_address_obj_t *address = MP_OBJ_TO_PTR(args[ARG_address].u_obj); + bleio_address_obj_t *address = mp_arg_validate_type(args[ARG_address].u_obj, &bleio_address_type, MP_QSTR_address); mp_float_t timeout = mp_obj_get_float(args[ARG_timeout].u_obj); return common_hal_bleio_adapter_connect(self, address, timeout); } -STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_adapter_connect_obj, 2, bleio_adapter_connect); +STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_adapter_connect_obj, 1, bleio_adapter_connect); //| def erase_bonding(self) -> None: //| """Erase all bonding information stored in flash memory.""" diff --git a/shared-bindings/_bleio/Address.c b/shared-bindings/_bleio/Address.c index 73bf0119c6..93345d95b0 100644 --- a/shared-bindings/_bleio/Address.c +++ b/shared-bindings/_bleio/Address.c @@ -47,7 +47,7 @@ //| `RANDOM_PRIVATE_RESOLVABLE`, or `RANDOM_PRIVATE_NON_RESOLVABLE`.""" //| ... //| -STATIC mp_obj_t bleio_address_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +STATIC mp_obj_t bleio_address_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_address, ARG_address_type }; static const mp_arg_t allowed_args[] = { { MP_QSTR_address, MP_ARG_OBJ | MP_ARG_REQUIRED }, @@ -55,7 +55,7 @@ STATIC mp_obj_t bleio_address_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(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); bleio_address_obj_t *self = m_new_obj(bleio_address_obj_t); self->base.type = &bleio_address_type; diff --git a/shared-bindings/_bleio/Characteristic.c b/shared-bindings/_bleio/Characteristic.c index b6b6ee69d4..3744c610c7 100644 --- a/shared-bindings/_bleio/Characteristic.c +++ b/shared-bindings/_bleio/Characteristic.c @@ -94,15 +94,9 @@ STATIC mp_obj_t bleio_characteristic_add_to_service(size_t n_args, const mp_obj_ 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 mp_obj_t service_obj = args[ARG_service].u_obj; - if (!mp_obj_is_type(service_obj, &bleio_service_type)) { - mp_raise_TypeError(translate("Expected a Service")); - } + bleio_service_obj_t *service = mp_arg_validate_type(args[ARG_service].u_obj, &bleio_service_type, MP_QSTR_service); - const mp_obj_t uuid_obj = args[ARG_uuid].u_obj; - if (!mp_obj_is_type(uuid_obj, &bleio_uuid_type)) { - mp_raise_TypeError(translate("Expected a UUID")); - } + bleio_uuid_obj_t *uuid = mp_arg_validate_type(args[ARG_uuid].u_obj, &bleio_uuid_type, MP_QSTR_uuid); const bleio_characteristic_properties_t properties = args[ARG_properties].u_int; if (properties & ~CHAR_PROP_ALL) { @@ -149,14 +143,14 @@ STATIC mp_obj_t bleio_characteristic_add_to_service(size_t n_args, const mp_obj_ // Range checking on max_length arg is done by the common_hal layer, because // it may vary depending on underlying BLE implementation. common_hal_bleio_characteristic_construct( - characteristic, MP_OBJ_TO_PTR(service_obj), 0, MP_OBJ_TO_PTR(uuid_obj), + characteristic, service, 0, uuid, properties, read_perm, write_perm, max_length, fixed_length, &initial_value_bufinfo, user_description); return MP_OBJ_FROM_PTR(characteristic); } -STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_characteristic_add_to_service_fun_obj, 3, bleio_characteristic_add_to_service); +STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_characteristic_add_to_service_fun_obj, 1, bleio_characteristic_add_to_service); STATIC MP_DEFINE_CONST_CLASSMETHOD_OBJ(bleio_characteristic_add_to_service_obj, MP_ROM_PTR(&bleio_characteristic_add_to_service_fun_obj)); diff --git a/shared-bindings/_bleio/CharacteristicBuffer.c b/shared-bindings/_bleio/CharacteristicBuffer.c index 9765be816e..81562028e7 100644 --- a/shared-bindings/_bleio/CharacteristicBuffer.c +++ b/shared-bindings/_bleio/CharacteristicBuffer.c @@ -57,7 +57,7 @@ STATIC void raise_error_if_not_connected(bleio_characteristic_buffer_obj_t *self //| Must be >= 1.""" //| ... //| -STATIC mp_obj_t bleio_characteristic_buffer_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +STATIC mp_obj_t bleio_characteristic_buffer_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_characteristic, ARG_timeout, ARG_buffer_size, }; static const mp_arg_t allowed_args[] = { { MP_QSTR_characteristic, MP_ARG_REQUIRED | MP_ARG_OBJ }, @@ -66,9 +66,9 @@ STATIC mp_obj_t bleio_characteristic_buffer_make_new(const mp_obj_type_t *type, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - const mp_obj_t characteristic = args[ARG_characteristic].u_obj; + bleio_characteristic_obj_t *characteristic = mp_arg_validate_type(args[ARG_characteristic].u_obj, &bleio_characteristic_type, MP_QSTR_characteristic); mp_float_t timeout = mp_obj_get_float(args[ARG_timeout].u_obj); if (timeout < 0.0f) { @@ -80,14 +80,10 @@ STATIC mp_obj_t bleio_characteristic_buffer_make_new(const mp_obj_type_t *type, mp_raise_ValueError_varg(translate("%q must be >= 1"), MP_QSTR_buffer_size); } - if (!mp_obj_is_type(characteristic, &bleio_characteristic_type)) { - mp_raise_TypeError(translate("Expected a Characteristic")); - } - bleio_characteristic_buffer_obj_t *self = m_new_obj(bleio_characteristic_buffer_obj_t); self->base.type = &bleio_characteristic_buffer_type; - common_hal_bleio_characteristic_buffer_construct(self, MP_OBJ_TO_PTR(characteristic), timeout, buffer_size); + common_hal_bleio_characteristic_buffer_construct(self, characteristic, timeout, buffer_size); return MP_OBJ_FROM_PTR(self); } diff --git a/shared-bindings/_bleio/Descriptor.c b/shared-bindings/_bleio/Descriptor.c index c8a1c87149..5a29575ba0 100644 --- a/shared-bindings/_bleio/Descriptor.c +++ b/shared-bindings/_bleio/Descriptor.c @@ -84,15 +84,9 @@ STATIC mp_obj_t bleio_descriptor_add_to_characteristic(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); - const mp_obj_t characteristic_obj = args[ARG_characteristic].u_obj; - if (!mp_obj_is_type(characteristic_obj, &bleio_characteristic_type)) { - mp_raise_TypeError(translate("Expected a Characteristic")); - } + bleio_characteristic_obj_t *characteristic = mp_arg_validate_type(args[ARG_characteristic].u_obj, &bleio_characteristic_type, MP_QSTR_characteristic); - const mp_obj_t uuid_obj = args[ARG_uuid].u_obj; - if (!mp_obj_is_type(uuid_obj, &bleio_uuid_type)) { - mp_raise_TypeError(translate("Expected a UUID")); - } + bleio_uuid_obj_t *uuid = mp_arg_validate_type(args[ARG_uuid].u_obj, &bleio_uuid_type, MP_QSTR_uuid); const bleio_attribute_security_mode_t read_perm = args[ARG_read_perm].u_int; common_hal_bleio_attribute_security_mode_check_valid(read_perm); @@ -128,15 +122,15 @@ STATIC mp_obj_t bleio_descriptor_add_to_characteristic(size_t n_args, const mp_o // Range checking on max_length arg is done by the common_hal layer, because // it may vary depending on underlying BLE implementation. common_hal_bleio_descriptor_construct( - descriptor, MP_OBJ_TO_PTR(characteristic_obj), MP_OBJ_TO_PTR(uuid_obj), + descriptor, characteristic, uuid, read_perm, write_perm, max_length, fixed_length, &initial_value_bufinfo); - common_hal_bleio_characteristic_add_descriptor(characteristic_obj, descriptor); + common_hal_bleio_characteristic_add_descriptor(characteristic, descriptor); return MP_OBJ_FROM_PTR(descriptor); } -STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_descriptor_add_to_characteristic_fun_obj, 3, bleio_descriptor_add_to_characteristic); +STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_descriptor_add_to_characteristic_fun_obj, 1, bleio_descriptor_add_to_characteristic); STATIC MP_DEFINE_CONST_CLASSMETHOD_OBJ(bleio_descriptor_add_to_characteristic_obj, MP_ROM_PTR(&bleio_descriptor_add_to_characteristic_fun_obj)); //| uuid: UUID diff --git a/shared-bindings/_bleio/PacketBuffer.c b/shared-bindings/_bleio/PacketBuffer.c index ebd69e6cfa..aa6c860a60 100644 --- a/shared-bindings/_bleio/PacketBuffer.c +++ b/shared-bindings/_bleio/PacketBuffer.c @@ -60,7 +60,7 @@ //| (Remote characteristics may not have the correct length.)""" //| ... //| -STATIC mp_obj_t bleio_packet_buffer_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +STATIC mp_obj_t bleio_packet_buffer_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_characteristic, ARG_buffer_size, ARG_max_packet_size }; static const mp_arg_t allowed_args[] = { { MP_QSTR_characteristic, MP_ARG_REQUIRED | MP_ARG_OBJ }, @@ -69,19 +69,15 @@ STATIC mp_obj_t bleio_packet_buffer_make_new(const mp_obj_type_t *type, size_t n }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - const mp_obj_t characteristic = args[ARG_characteristic].u_obj; + bleio_characteristic_obj_t *characteristic = mp_arg_validate_type(args[ARG_characteristic].u_obj, &bleio_characteristic_type, MP_QSTR_characteristic); const mp_int_t buffer_size = args[ARG_buffer_size].u_int; if (buffer_size < 1) { mp_raise_ValueError_varg(translate("%q must be >= 1"), MP_QSTR_buffer_size); } - if (!mp_obj_is_type(characteristic, &bleio_characteristic_type)) { - mp_raise_TypeError(translate("Expected a Characteristic")); - } - size_t max_packet_size = common_hal_bleio_characteristic_get_max_length(characteristic); if (args[ARG_max_packet_size].u_obj != mp_const_none) { max_packet_size = mp_obj_get_int(args[ARG_max_packet_size].u_obj); @@ -90,7 +86,7 @@ STATIC mp_obj_t bleio_packet_buffer_make_new(const mp_obj_type_t *type, size_t n bleio_packet_buffer_obj_t *self = m_new_obj(bleio_packet_buffer_obj_t); self->base.type = &bleio_packet_buffer_type; - common_hal_bleio_packet_buffer_construct(self, MP_OBJ_TO_PTR(characteristic), buffer_size, max_packet_size); + common_hal_bleio_packet_buffer_construct(self, characteristic, buffer_size, max_packet_size); return MP_OBJ_FROM_PTR(self); } diff --git a/shared-bindings/_bleio/ScanEntry.c b/shared-bindings/_bleio/ScanEntry.c index 531986f349..5a0f6eb1be 100644 --- a/shared-bindings/_bleio/ScanEntry.c +++ b/shared-bindings/_bleio/ScanEntry.c @@ -72,7 +72,7 @@ STATIC mp_obj_t bleio_scanentry_matches(mp_uint_t n_args, const mp_obj_t *pos_ar mp_get_buffer_raise(args[ARG_prefixes].u_obj, &bufinfo, MP_BUFFER_READ); return mp_obj_new_bool(common_hal_bleio_scanentry_matches(self, bufinfo.buf, bufinfo.len, match_all)); } -STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_scanentry_matches_obj, 2, bleio_scanentry_matches); +STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_scanentry_matches_obj, 1, bleio_scanentry_matches); //| address: Address //| """The address of the device (read-only), of type `_bleio.Address`.""" diff --git a/shared-bindings/_bleio/Service.c b/shared-bindings/_bleio/Service.c index 4427371017..ff1d8c9e21 100644 --- a/shared-bindings/_bleio/Service.c +++ b/shared-bindings/_bleio/Service.c @@ -48,7 +48,7 @@ //| :return: the new Service""" //| ... //| -STATIC mp_obj_t bleio_service_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +STATIC mp_obj_t bleio_service_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_uuid, ARG_secondary }; static const mp_arg_t allowed_args[] = { { MP_QSTR_uuid, MP_ARG_REQUIRED | MP_ARG_OBJ }, @@ -56,19 +56,16 @@ STATIC mp_obj_t bleio_service_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(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - const mp_obj_t uuid_obj = args[ARG_uuid].u_obj; - if (!mp_obj_is_type(uuid_obj, &bleio_uuid_type)) { - mp_raise_TypeError(translate("Expected a UUID")); - } + bleio_uuid_obj_t *uuid = mp_arg_validate_type(args[ARG_uuid].u_obj, &bleio_uuid_type, MP_QSTR_uuid); const bool is_secondary = args[ARG_secondary].u_bool; bleio_service_obj_t *service = m_new_obj(bleio_service_obj_t); service->base.type = &bleio_service_type; - common_hal_bleio_service_construct(service, MP_OBJ_TO_PTR(uuid_obj), is_secondary); + common_hal_bleio_service_construct(service, uuid, is_secondary); return MP_OBJ_FROM_PTR(service); } diff --git a/shared-bindings/_bleio/UUID.c b/shared-bindings/_bleio/UUID.c index a575e382cc..028d21d9d5 100644 --- a/shared-bindings/_bleio/UUID.c +++ b/shared-bindings/_bleio/UUID.c @@ -51,13 +51,13 @@ //| :type value: int, ~_typing.ReadableBuffer or str""" //| ... //| -STATIC mp_obj_t bleio_uuid_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { - mp_arg_check_num(n_args, kw_args, 1, 1, false); +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) { + mp_arg_check_num(n_args, n_kw, 1, 1, false); bleio_uuid_obj_t *self = m_new_obj(bleio_uuid_obj_t); self->base.type = type; - const mp_obj_t value = pos_args[0]; + const mp_obj_t value = all_args[0]; uint8_t uuid128[16]; if (mp_obj_is_int(value)) { @@ -214,7 +214,7 @@ STATIC mp_obj_t bleio_uuid_pack_into(mp_uint_t n_args, const mp_obj_t *pos_args, common_hal_bleio_uuid_pack_into(self, bufinfo.buf + offset); return mp_const_none; } -STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_uuid_pack_into_obj, 2, bleio_uuid_pack_into); +STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_uuid_pack_into_obj, 1, bleio_uuid_pack_into); STATIC const mp_rom_map_elem_t bleio_uuid_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_uuid16), MP_ROM_PTR(&bleio_uuid_uuid16_obj) }, diff --git a/shared-bindings/_eve/__init__.c b/shared-bindings/_eve/__init__.c index 001c1d3197..69300e47e4 100644 --- a/shared-bindings/_eve/__init__.c +++ b/shared-bindings/_eve/__init__.c @@ -1078,7 +1078,7 @@ STATIC const mp_rom_map_elem_t _EVE_locals_dict_table[] = { }; STATIC MP_DEFINE_CONST_DICT(_EVE_locals_dict, _EVE_locals_dict_table); -STATIC mp_obj_t _EVE_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { +STATIC mp_obj_t _EVE_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { // mp_arg_check_num(n_args, kw_args, 1, 1, false); mp_obj__EVE_t *o = m_new_obj(mp_obj__EVE_t); o->base.type = &_EVE_type; diff --git a/shared-bindings/_pew/PewPew.c b/shared-bindings/_pew/PewPew.c index 2441e3ba5e..4015d31161 100644 --- a/shared-bindings/_pew/PewPew.c +++ b/shared-bindings/_pew/PewPew.c @@ -62,9 +62,7 @@ //| buttons are connected to rows of the matrix).""" //| ... //| -STATIC mp_obj_t pewpew_make_new(const mp_obj_type_t *type, size_t n_args, - const mp_obj_t *pos_args, mp_map_t *kw_args) { - mp_arg_check_num(n_args, kw_args, 4, 4, true); +STATIC mp_obj_t pewpew_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_buffer, ARG_rows, ARG_cols, ARG_buttons }; static const mp_arg_t allowed_args[] = { { MP_QSTR_buffer, MP_ARG_OBJ | MP_ARG_REQUIRED }, @@ -73,7 +71,7 @@ STATIC mp_obj_t pewpew_make_new(const mp_obj_type_t *type, size_t n_args, { MP_QSTR_buttons, MP_ARG_OBJ | MP_ARG_REQUIRED }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args, pos_args, kw_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_buffer_info_t bufinfo; @@ -92,31 +90,20 @@ STATIC mp_obj_t pewpew_make_new(const mp_obj_type_t *type, size_t n_args, } for (size_t i = 0; i < rows_size; ++i) { - if (!mp_obj_is_type(rows[i], &digitalio_digitalinout_type)) { - mp_raise_TypeError(translate("Row entry must be digitalio.DigitalInOut")); - } - digitalio_digitalinout_obj_t *pin = MP_OBJ_TO_PTR(rows[i]); + digitalio_digitalinout_obj_t *pin = mp_arg_validate_type(rows[i], &digitalio_digitalinout_type, MP_QSTR_rows); if (common_hal_digitalio_digitalinout_deinited(pin)) { raise_deinited_error(); } } for (size_t i = 0; i < cols_size; ++i) { - if (!mp_obj_is_type(cols[i], &digitalio_digitalinout_type)) { - mp_raise_TypeError(translate("Column entry must be digitalio.DigitalInOut")); - } - digitalio_digitalinout_obj_t *pin = MP_OBJ_TO_PTR(cols[i]); + digitalio_digitalinout_obj_t *pin = mp_arg_validate_type(cols[i], &digitalio_digitalinout_type, MP_QSTR_cols); if (common_hal_digitalio_digitalinout_deinited(pin)) { raise_deinited_error(); } } - if (!mp_obj_is_type(args[ARG_buttons].u_obj, - &digitalio_digitalinout_type)) { - mp_raise_TypeError(translate("buttons must be digitalio.DigitalInOut")); - } - digitalio_digitalinout_obj_t *buttons = MP_OBJ_TO_PTR( - args[ARG_buttons].u_obj); + digitalio_digitalinout_obj_t *buttons = mp_arg_validate_type(args[ARG_buttons].u_obj, &digitalio_digitalinout_type, MP_QSTR_buttons); if (common_hal_digitalio_digitalinout_deinited(buttons)) { raise_deinited_error(); } diff --git a/shared-bindings/_stage/Layer.c b/shared-bindings/_stage/Layer.c index 51ed5c3bf6..a040ee9ab0 100644 --- a/shared-bindings/_stage/Layer.c +++ b/shared-bindings/_stage/Layer.c @@ -49,8 +49,8 @@ //| ... //| STATIC mp_obj_t layer_make_new(const mp_obj_type_t *type, size_t n_args, - const mp_obj_t *args, mp_map_t *kw_args) { - mp_arg_check_num(n_args, kw_args, 4, 5, false); + size_t n_kw, const mp_obj_t *args) { + mp_arg_check_num(n_args, n_kw, 4, 5, false); layer_obj_t *self = m_new_obj(layer_obj_t); self->base.type = type; diff --git a/shared-bindings/_stage/Text.c b/shared-bindings/_stage/Text.c index 55b60953b6..b57f4f0b6a 100644 --- a/shared-bindings/_stage/Text.c +++ b/shared-bindings/_stage/Text.c @@ -49,8 +49,8 @@ //| ... //| STATIC mp_obj_t text_make_new(const mp_obj_type_t *type, size_t n_args, - const mp_obj_t *args, mp_map_t *kw_args) { - mp_arg_check_num(n_args, kw_args, 5, 5, false); + size_t n_kw, const mp_obj_t *args) { + mp_arg_check_num(n_args, n_kw, 5, 5, false); text_obj_t *self = m_new_obj(text_obj_t); self->base.type = type; diff --git a/shared-bindings/_stage/__init__.c b/shared-bindings/_stage/__init__.c index 1d5c06c862..4dfcc796e7 100644 --- a/shared-bindings/_stage/__init__.c +++ b/shared-bindings/_stage/__init__.c @@ -81,21 +81,17 @@ STATIC mp_obj_t stage_render(size_t n_args, const mp_obj_t *args) { mp_raise_TypeError(translate("argument num/types mismatch")); } displayio_display_obj_t *display = MP_OBJ_TO_PTR(native_display); - uint8_t scale = 1; - if (n_args > 7) { - scale = mp_obj_get_int(args[7]); - } + uint8_t scale = mp_obj_get_int(args[7]); + int16_t vx = mp_obj_get_int(args[8]); + int16_t vy = mp_obj_get_int(args[9]); uint16_t background = 0; - if (n_args > 8) { - background = mp_obj_get_int(args[8]); - } - render_stage(x0, y0, x1, y1, layers, layers_size, buffer, buffer_size, - display, scale, background); + render_stage(x0, y0, x1, y1, vx, vy, layers, layers_size, + buffer, buffer_size, display, scale, background); return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(stage_render_obj, 7, 8, stage_render); +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(stage_render_obj, 10, 10, stage_render); STATIC const mp_rom_map_elem_t stage_module_globals_table[] = { diff --git a/shared-bindings/adafruit_bus_device/I2CDevice.c b/shared-bindings/adafruit_bus_device/I2CDevice.c index 12c836396d..98f2640483 100644 --- a/shared-bindings/adafruit_bus_device/I2CDevice.c +++ b/shared-bindings/adafruit_bus_device/I2CDevice.c @@ -32,8 +32,8 @@ #include "shared-bindings/util.h" #include "shared-module/adafruit_bus_device/I2CDevice.h" -#include "lib/utils/buffer_helper.h" -#include "lib/utils/context_manager_helpers.h" +#include "shared/runtime/buffer_helper.h" +#include "shared/runtime/context_manager_helpers.h" #include "py/runtime.h" #include "py/smallint.h" #include "supervisor/shared/translate.h" @@ -63,10 +63,11 @@ //| device.readinto(bytes_read) //| # A second transaction //| with device: -//| device.write(bytes_read)""" +//| device.write(bytes_read) +//| """ //| ... //| -STATIC mp_obj_t adafruit_bus_device_i2cdevice_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +STATIC mp_obj_t adafruit_bus_device_i2cdevice_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { adafruit_bus_device_i2cdevice_obj_t *self = m_new_obj(adafruit_bus_device_i2cdevice_obj_t); self->base.type = &adafruit_bus_device_i2cdevice_type; enum { ARG_i2c, ARG_device_address, ARG_probe }; @@ -76,7 +77,7 @@ STATIC mp_obj_t adafruit_bus_device_i2cdevice_make_new(const mp_obj_type_t *type { MP_QSTR_probe, MP_ARG_BOOL, {.u_bool = true} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, 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 = args[ARG_i2c].u_obj; @@ -109,16 +110,18 @@ STATIC mp_obj_t adafruit_bus_device_i2cdevice_obj___exit__(size_t n_args, const } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(adafruit_bus_device_i2cdevice___exit___obj, 4, 4, adafruit_bus_device_i2cdevice_obj___exit__); -//| def readinto(self, buf: WriteableBuffer, *, start: int = 0, end: Optional[int] = None) -> None: -//| """Read into ``buf`` from the device. The number of bytes read will be the -//| length of ``buf``. -//| If ``start`` or ``end`` is provided, then the buffer will be sliced -//| as if ``buf[start:end]``. This will not cause an allocation like -//| ``buf[start:end]`` will so it saves memory. +//| import sys +//| def readinto(self, buffer: WriteableBuffer, *, start: int = 0, end: int = sys.maxsize) -> None: +//| """Read into ``buffer`` from the device. //| -//| :param bytearray buf: buffer to write into -//| :param int start: Index to start writing at -//| :param int end: Index to write up to but not include; if None, use ``len(buf)``""" +//| If ``start`` or ``end`` is provided, then the buffer will be sliced +//| as if ``buffer[start:end]`` were passed. +//| The number of bytes read will be the length of ``buffer[start:end]``. +//| +//| :param WriteableBuffer buffer: read bytes into this buffer +//| :param int start: beginning of buffer slice +//| :param int end: end of buffer slice; if not specified, use ``len(buffer)`` +//| """ //| ... //| STATIC mp_obj_t adafruit_bus_device_i2cdevice_readinto(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { @@ -152,17 +155,19 @@ STATIC mp_obj_t adafruit_bus_device_i2cdevice_readinto(size_t n_args, const mp_o return mp_const_none; } -STATIC MP_DEFINE_CONST_FUN_OBJ_KW(adafruit_bus_device_i2cdevice_readinto_obj, 2, adafruit_bus_device_i2cdevice_readinto); +STATIC MP_DEFINE_CONST_FUN_OBJ_KW(adafruit_bus_device_i2cdevice_readinto_obj, 1, adafruit_bus_device_i2cdevice_readinto); -//| def write(self, buf: ReadableBuffer, *, start: int = 0, end: Optional[int] = None) -> None: +//| import sys +//| def write(self, buffer: ReadableBuffer, *, start: int = 0, end: int = sys.maxsize) -> None: //| """Write the bytes from ``buffer`` to the device, then transmit a stop bit. -//| If ``start`` or ``end`` is provided, then the buffer will be sliced -//| as if ``buffer[start:end]``. This will not cause an allocation like -//| ``buffer[start:end]`` will so it saves memory. //| -//| :param bytearray buf: buffer containing the bytes to write -//| :param int start: Index to start writing from -//| :param int end: Index to read up to but not include; if None, use ``len(buf)`` +//| If ``start`` or ``end`` is provided, then the buffer will be sliced +//| as if ``buffer[start:end]`` were passed, but without copying the data. +//| The number of bytes written will be the length of ``buffer[start:end]``. +//| +//| :param ReadableBuffer buffer: write out bytes from this buffer +//| :param int start: beginning of buffer slice +//| :param int end: end of buffer slice; if not specified, use ``len(buffer)`` //| """ //| ... //| @@ -196,28 +201,28 @@ STATIC mp_obj_t adafruit_bus_device_i2cdevice_write(size_t n_args, const mp_obj_ return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_KW(adafruit_bus_device_i2cdevice_write_obj, 2, adafruit_bus_device_i2cdevice_write); +MP_DEFINE_CONST_FUN_OBJ_KW(adafruit_bus_device_i2cdevice_write_obj, 1, adafruit_bus_device_i2cdevice_write); -//| def write_then_readinto(self, out_buffer: WriteableBuffer, in_buffer: ReadableBuffer, *, out_start: int = 0, out_end: Optional[int] = None, in_start: int = 0, in_end: Optional[int] = None) -> None: +//| import sys +//| def write_then_readinto(self, out_buffer: ReadableBuffer, in_buffer: WriteableBuffer, *, out_start: int = 0, out_end: int = sys.maxsize, in_start: int = 0, in_end: int = sys.maxsize) -> None: //| """Write the bytes from ``out_buffer`` to the device, then immediately -//| reads into ``in_buffer`` from the device. The number of bytes read -//| will be the length of ``in_buffer``. -//| If ``out_start`` or ``out_end`` is provided, then the output buffer -//| will be sliced as if ``out_buffer[out_start:out_end]``. This will -//| not cause an allocation like ``buffer[out_start:out_end]`` will so -//| it saves memory. -//| If ``in_start`` or ``in_end`` is provided, then the input buffer -//| will be sliced as if ``in_buffer[in_start:in_end]``. This will not -//| cause an allocation like ``in_buffer[in_start:in_end]`` will so -//| it saves memory. +//| reads into ``in_buffer`` from the device. //| -//| :param bytearray out_buffer: buffer containing the bytes to write -//| :param bytearray in_buffer: buffer containing the bytes to read into -//| :param int out_start: Index to start writing from -//| :param int out_end: Index to read up to but not include; if None, use ``len(out_buffer)`` -//| :param int in_start: Index to start writing at -//| :param int in_end: Index to write up to but not include; if None, use ``len(in_buffer)`` +//| If ``out_start`` or ``out_end`` is provided, then the buffer will be sliced +//| as if ``out_buffer[out_start:out_end]`` were passed, but without copying the data. +//| The number of bytes written will be the length of ``out_buffer[out_start:out_end]``. +//| +//| If ``in_start`` or ``in_end`` is provided, then the input buffer will be sliced +//| as if ``in_buffer[in_start:in_end]`` were passed, +//| The number of bytes read will be the length of ``out_buffer[in_start:in_end]``. +//| +//| :param ReadableBuffer out_buffer: write out bytes from this buffer +//| :param WriteableBuffer in_buffer: read bytes into this buffer +//| :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 +//| :param int in_end: end of ``in_buffer slice``; if not specified, use ``len(in_buffer)`` //| """ //| ... //| @@ -263,7 +268,7 @@ STATIC mp_obj_t adafruit_bus_device_i2cdevice_write_then_readinto(size_t n_args, return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_KW(adafruit_bus_device_i2cdevice_write_then_readinto_obj, 3, adafruit_bus_device_i2cdevice_write_then_readinto); +MP_DEFINE_CONST_FUN_OBJ_KW(adafruit_bus_device_i2cdevice_write_then_readinto_obj, 1, adafruit_bus_device_i2cdevice_write_then_readinto); STATIC const mp_rom_map_elem_t adafruit_bus_device_i2cdevice_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&adafruit_bus_device_i2cdevice___enter___obj) }, diff --git a/shared-bindings/adafruit_bus_device/SPIDevice.c b/shared-bindings/adafruit_bus_device/SPIDevice.c index 3fc308f583..aee8882940 100644 --- a/shared-bindings/adafruit_bus_device/SPIDevice.c +++ b/shared-bindings/adafruit_bus_device/SPIDevice.c @@ -32,8 +32,8 @@ #include "shared-bindings/digitalio/DigitalInOut.h" -#include "lib/utils/buffer_helper.h" -#include "lib/utils/context_manager_helpers.h" +#include "shared/runtime/buffer_helper.h" +#include "shared/runtime/context_manager_helpers.h" #include "py/runtime.h" #include "supervisor/shared/translate.h" @@ -71,7 +71,7 @@ //| spi.write(bytes_read)""" //| ... //| -STATIC mp_obj_t adafruit_bus_device_spidevice_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +STATIC mp_obj_t adafruit_bus_device_spidevice_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { adafruit_bus_device_spidevice_obj_t *self = m_new_obj(adafruit_bus_device_spidevice_obj_t); self->base.type = &adafruit_bus_device_spidevice_type; enum { ARG_spi, ARG_chip_select, ARG_cs_active_value, ARG_baudrate, ARG_polarity, ARG_phase, ARG_extra_clocks }; @@ -85,7 +85,7 @@ STATIC mp_obj_t adafruit_bus_device_spidevice_make_new(const mp_obj_type_t *type { MP_QSTR_extra_clocks, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); busio_spi_obj_t *spi = args[ARG_spi].u_obj; diff --git a/shared-bindings/adafruit_pixelbuf/PixelBuf.c b/shared-bindings/adafruit_pixelbuf/PixelBuf.c index 930f758b30..db9f1c01a8 100644 --- a/shared-bindings/adafruit_pixelbuf/PixelBuf.c +++ b/shared-bindings/adafruit_pixelbuf/PixelBuf.c @@ -68,8 +68,7 @@ static void parse_byteorder(mp_obj_t byteorder_obj, pixelbuf_byteorder_details_t //| :param ~_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, const mp_obj_t *pos_args, mp_map_t *kw_args) { - mp_arg_check_num(n_args, kw_args, 1, MP_OBJ_FUN_ARGS_MAX, true); +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) { enum { ARG_size, ARG_byteorder, ARG_brightness, ARG_auto_write, ARG_header, ARG_trailer }; static const mp_arg_t allowed_args[] = { { MP_QSTR_size, MP_ARG_REQUIRED | MP_ARG_INT }, @@ -80,7 +79,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_make_new(const mp_obj_type_t *type, size_t n_a { MP_QSTR_trailer, 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(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); pixelbuf_byteorder_details_t byteorder_details; parse_byteorder(args[ARG_byteorder].u_obj, &byteorder_details); diff --git a/shared-bindings/aesio/aes.c b/shared-bindings/aesio/aes.c index f39e99d943..152785c584 100644 --- a/shared-bindings/aesio/aes.c +++ b/shared-bindings/aesio/aes.c @@ -37,8 +37,7 @@ //| STATIC mp_obj_t aesio_aes_make_new(const mp_obj_type_t *type, size_t n_args, - const mp_obj_t *pos_args, - mp_map_t *kw_args) { + size_t n_kw, const mp_obj_t *all_args) { (void)type; enum { ARG_key, ARG_mode, ARG_IV, ARG_counter, ARG_segment_size }; static const mp_arg_t allowed_args[] = { @@ -50,7 +49,7 @@ STATIC mp_obj_t aesio_aes_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(n_args, pos_args, kw_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); aesio_aes_obj_t *self = m_new_obj(aesio_aes_obj_t); diff --git a/shared-bindings/alarm/__init__.c b/shared-bindings/alarm/__init__.c index 2f5e36148b..5d3c1a15f0 100644 --- a/shared-bindings/alarm/__init__.c +++ b/shared-bindings/alarm/__init__.c @@ -151,7 +151,7 @@ STATIC mp_obj_t alarm_exit_and_deep_sleep_until_alarms(size_t n_args, const mp_o common_hal_alarm_set_deep_sleep_alarms(n_args, args); // Raise an exception, which will be processed in main.c. - mp_raise_arg1(&mp_type_DeepSleepRequest, NULL); + mp_raise_type_arg(&mp_type_DeepSleepRequest, NULL); // Doesn't get here. return mp_const_none; diff --git a/shared-bindings/alarm/pin/PinAlarm.c b/shared-bindings/alarm/pin/PinAlarm.c index 3fe7a2bd59..50bdfa00de 100644 --- a/shared-bindings/alarm/pin/PinAlarm.c +++ b/shared-bindings/alarm/pin/PinAlarm.c @@ -60,7 +60,7 @@ //| """ //| ... //| -STATIC mp_obj_t alarm_pin_pinalarm_make_new(const mp_obj_type_t *type, mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +STATIC mp_obj_t alarm_pin_pinalarm_make_new(const mp_obj_type_t *type, mp_uint_t n_args, size_t n_kw, const mp_obj_t *all_args) { alarm_pin_pinalarm_obj_t *self = m_new_obj(alarm_pin_pinalarm_obj_t); self->base.type = &alarm_pin_pinalarm_type; enum { ARG_pin, ARG_value, ARG_edge, ARG_pull }; @@ -71,7 +71,7 @@ STATIC mp_obj_t alarm_pin_pinalarm_make_new(const mp_obj_type_t *type, mp_uint_t { MP_QSTR_pull, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = false} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(0, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, 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 = validate_obj_is_free_pin(args[ARG_pin].u_obj); diff --git a/shared-bindings/alarm/time/TimeAlarm.c b/shared-bindings/alarm/time/TimeAlarm.c index be2d8d0409..2fdd6218bb 100644 --- a/shared-bindings/alarm/time/TimeAlarm.c +++ b/shared-bindings/alarm/time/TimeAlarm.c @@ -57,7 +57,7 @@ mp_obj_t MP_WEAK rtc_get_time_source_time(void) { //| ... //| STATIC mp_obj_t alarm_time_timealarm_make_new(const mp_obj_type_t *type, - mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + size_t n_args, size_t n_kw, const mp_obj_t *all_args) { alarm_time_timealarm_obj_t *self = m_new_obj(alarm_time_timealarm_obj_t); self->base.type = &alarm_time_timealarm_type; @@ -68,7 +68,7 @@ STATIC mp_obj_t alarm_time_timealarm_make_new(const mp_obj_type_t *type, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); bool have_monotonic = args[ARG_monotonic_time].u_obj != mp_const_none; bool have_epoch = args[ARG_epoch_time].u_obj != mp_const_none; diff --git a/shared-bindings/alarm/touch/TouchAlarm.c b/shared-bindings/alarm/touch/TouchAlarm.c index 827c175089..60b3f97c18 100644 --- a/shared-bindings/alarm/touch/TouchAlarm.c +++ b/shared-bindings/alarm/touch/TouchAlarm.c @@ -43,7 +43,7 @@ //| ... //| STATIC mp_obj_t alarm_touch_touchalarm_make_new(const mp_obj_type_t *type, - mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + size_t n_args, size_t n_kw, const mp_obj_t *all_args) { alarm_touch_touchalarm_obj_t *self = m_new_obj(alarm_touch_touchalarm_obj_t); self->base.type = &alarm_touch_touchalarm_type; @@ -53,7 +53,7 @@ STATIC mp_obj_t alarm_touch_touchalarm_make_new(const mp_obj_type_t *type, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, 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 = validate_obj_is_free_pin(args[ARG_pin].u_obj); diff --git a/shared-bindings/analogio/AnalogIn.c b/shared-bindings/analogio/AnalogIn.c index 6a92447d60..e1f9f195c8 100644 --- a/shared-bindings/analogio/AnalogIn.c +++ b/shared-bindings/analogio/AnalogIn.c @@ -26,7 +26,7 @@ #include -#include "lib/utils/context_manager_helpers.h" +#include "shared/runtime/context_manager_helpers.h" #include "py/binary.h" #include "py/mphal.h" #include "py/nlr.h" @@ -56,9 +56,9 @@ //| ... //| STATIC mp_obj_t analogio_analogin_make_new(const mp_obj_type_t *type, - mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { + mp_uint_t n_args, size_t n_kw, const mp_obj_t *args) { // check number of arguments - mp_arg_check_num(n_args, kw_args, 1, 1, false); + mp_arg_check_num(n_args, n_kw, 1, 1, false); // 1st argument is the pin const mcu_pin_obj_t *pin = validate_obj_is_free_pin(args[0]); diff --git a/shared-bindings/analogio/AnalogOut.c b/shared-bindings/analogio/AnalogOut.c index 5af04d3ee6..aad298ba07 100644 --- a/shared-bindings/analogio/AnalogOut.c +++ b/shared-bindings/analogio/AnalogOut.c @@ -27,7 +27,7 @@ #include #include -#include "lib/utils/context_manager_helpers.h" +#include "shared/runtime/context_manager_helpers.h" #include "py/objproperty.h" #include "py/runtime.h" @@ -53,9 +53,9 @@ //| :param ~microcontroller.Pin pin: the pin to output to""" //| ... //| -STATIC mp_obj_t analogio_analogout_make_new(const mp_obj_type_t *type, mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { +STATIC mp_obj_t analogio_analogout_make_new(const mp_obj_type_t *type, mp_uint_t n_args, size_t n_kw, const mp_obj_t *args) { // check arguments - mp_arg_check_num(n_args, kw_args, 1, 1, false); + mp_arg_check_num(n_args, n_kw, 1, 1, false); const mcu_pin_obj_t *pin = validate_obj_is_free_pin(args[0]); diff --git a/shared-bindings/audiobusio/I2SOut.c b/shared-bindings/audiobusio/I2SOut.c index bad178cfd2..c343df242c 100644 --- a/shared-bindings/audiobusio/I2SOut.c +++ b/shared-bindings/audiobusio/I2SOut.c @@ -26,7 +26,7 @@ #include -#include "lib/utils/context_manager_helpers.h" +#include "shared/runtime/context_manager_helpers.h" #include "py/binary.h" #include "py/objproperty.h" #include "py/runtime.h" @@ -90,7 +90,7 @@ //| print("stopped")""" //| ... //| -STATIC mp_obj_t audiobusio_i2sout_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +STATIC mp_obj_t audiobusio_i2sout_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { #if !CIRCUITPY_AUDIOBUSIO_I2SOUT mp_raise_NotImplementedError(translate("I2SOut not available")); return NULL; // Not reachable. @@ -103,7 +103,7 @@ STATIC mp_obj_t audiobusio_i2sout_make_new(const mp_obj_type_t *type, size_t n_a { MP_QSTR_left_justified, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_bool = false} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, 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 *bit_clock = validate_obj_is_free_pin(args[ARG_bit_clock].u_obj); const mcu_pin_obj_t *word_select = validate_obj_is_free_pin(args[ARG_word_select].u_obj); diff --git a/shared-bindings/audiobusio/PDMIn.c b/shared-bindings/audiobusio/PDMIn.c index f18ed4dd70..201b6abcec 100644 --- a/shared-bindings/audiobusio/PDMIn.c +++ b/shared-bindings/audiobusio/PDMIn.c @@ -26,7 +26,7 @@ #include -#include "lib/utils/context_manager_helpers.h" +#include "shared/runtime/context_manager_helpers.h" #include "py/binary.h" #include "py/mphal.h" #include "py/objproperty.h" @@ -83,7 +83,7 @@ //| mic.record(b, len(b))""" //| ... //| -STATIC mp_obj_t audiobusio_pdmin_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +STATIC mp_obj_t audiobusio_pdmin_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { #if !CIRCUITPY_AUDIOBUSIO_PDMIN mp_raise_NotImplementedError(translate("PDMIn not available")); #else @@ -101,7 +101,7 @@ STATIC mp_obj_t audiobusio_pdmin_make_new(const mp_obj_type_t *type, size_t n_ar static const float STARTUP_DELAY_DEFAULT = 0.110F; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, 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 *clock_pin = validate_obj_is_free_pin(args[ARG_clock_pin].u_obj); const mcu_pin_obj_t *data_pin = validate_obj_is_free_pin(args[ARG_data_pin].u_obj); diff --git a/shared-bindings/audiocore/RawSample.c b/shared-bindings/audiocore/RawSample.c index cc1904ea30..c3af2f30f0 100644 --- a/shared-bindings/audiocore/RawSample.c +++ b/shared-bindings/audiocore/RawSample.c @@ -26,7 +26,7 @@ #include -#include "lib/utils/context_manager_helpers.h" +#include "shared/runtime/context_manager_helpers.h" #include "py/binary.h" #include "py/objproperty.h" #include "py/runtime.h" @@ -69,7 +69,7 @@ //| dac.stop()""" //| ... //| -STATIC mp_obj_t audioio_rawsample_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +STATIC mp_obj_t audioio_rawsample_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_buffer, ARG_channel_count, ARG_sample_rate }; static const mp_arg_t allowed_args[] = { { MP_QSTR_buffer, MP_ARG_OBJ | MP_ARG_REQUIRED }, @@ -77,7 +77,7 @@ STATIC mp_obj_t audioio_rawsample_make_new(const mp_obj_type_t *type, size_t n_a { MP_QSTR_sample_rate, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 8000} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); audioio_rawsample_obj_t *self = m_new_obj(audioio_rawsample_obj_t); self->base.type = &audioio_rawsample_type; diff --git a/shared-bindings/audiocore/WaveFile.c b/shared-bindings/audiocore/WaveFile.c index c46976229e..74ea9fda9f 100644 --- a/shared-bindings/audiocore/WaveFile.c +++ b/shared-bindings/audiocore/WaveFile.c @@ -26,7 +26,7 @@ #include -#include "lib/utils/context_manager_helpers.h" +#include "shared/runtime/context_manager_helpers.h" #include "py/objproperty.h" #include "py/runtime.h" #include "shared-bindings/audiocore/WaveFile.h" @@ -72,8 +72,8 @@ //| print("stopped")""" //| ... //| -STATIC mp_obj_t audioio_wavefile_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { - mp_arg_check_num(n_args, kw_args, 1, 2, false); +STATIC mp_obj_t audioio_wavefile_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { + mp_arg_check_num(n_args, n_kw, 1, 2, false); audioio_wavefile_obj_t *self = m_new_obj(audioio_wavefile_obj_t); self->base.type = &audioio_wavefile_type; diff --git a/shared-bindings/audioio/AudioOut.c b/shared-bindings/audioio/AudioOut.c index 1dcfaaf618..80072e9128 100644 --- a/shared-bindings/audioio/AudioOut.c +++ b/shared-bindings/audioio/AudioOut.c @@ -26,7 +26,7 @@ #include -#include "lib/utils/context_manager_helpers.h" +#include "shared/runtime/context_manager_helpers.h" #include "py/binary.h" #include "py/objproperty.h" #include "py/runtime.h" @@ -90,7 +90,7 @@ //| print("stopped")""" //| ... //| -STATIC mp_obj_t audioio_audioout_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +STATIC mp_obj_t audioio_audioout_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_left_channel, ARG_right_channel, ARG_quiescent_value }; static const mp_arg_t allowed_args[] = { { MP_QSTR_left_channel, MP_ARG_OBJ | MP_ARG_REQUIRED }, @@ -98,7 +98,7 @@ STATIC mp_obj_t audioio_audioout_make_new(const mp_obj_type_t *type, size_t n_ar { MP_QSTR_quiescent_value, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 0x8000} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, 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 *left_channel_pin = validate_obj_is_free_pin(args[ARG_left_channel].u_obj); const mcu_pin_obj_t *right_channel_pin = validate_obj_is_free_pin_or_none(args[ARG_right_channel].u_obj); diff --git a/shared-bindings/audiomixer/Mixer.c b/shared-bindings/audiomixer/Mixer.c index f603671620..619e2c095c 100644 --- a/shared-bindings/audiomixer/Mixer.c +++ b/shared-bindings/audiomixer/Mixer.c @@ -29,7 +29,7 @@ #include -#include "lib/utils/context_manager_helpers.h" +#include "shared/runtime/context_manager_helpers.h" #include "py/binary.h" #include "py/objproperty.h" #include "py/runtime.h" @@ -78,7 +78,7 @@ //| print("stopped")""" //| ... //| -STATIC mp_obj_t audiomixer_mixer_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +STATIC mp_obj_t audiomixer_mixer_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_voice_count, ARG_buffer_size, ARG_channel_count, ARG_bits_per_sample, ARG_samples_signed, ARG_sample_rate }; static const mp_arg_t allowed_args[] = { { MP_QSTR_voice_count, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 2} }, @@ -89,7 +89,7 @@ STATIC mp_obj_t audiomixer_mixer_make_new(const mp_obj_type_t *type, size_t n_ar { MP_QSTR_sample_rate, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 8000} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); mp_int_t voice_count = args[ARG_voice_count].u_int; if (voice_count < 1 || voice_count > 255) { diff --git a/shared-bindings/audiomixer/MixerVoice.c b/shared-bindings/audiomixer/MixerVoice.c index 10548f51ef..d3bac8c3de 100644 --- a/shared-bindings/audiomixer/MixerVoice.c +++ b/shared-bindings/audiomixer/MixerVoice.c @@ -28,7 +28,7 @@ #include -#include "lib/utils/context_manager_helpers.h" +#include "shared/runtime/context_manager_helpers.h" #include "py/binary.h" #include "py/objproperty.h" #include "py/runtime.h" @@ -47,7 +47,8 @@ //| ... //| // TODO: support mono or stereo voices -STATIC mp_obj_t audiomixer_mixervoice_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +STATIC mp_obj_t audiomixer_mixervoice_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { + mp_arg_check_num(n_args, n_kw, 0, 0, false); audiomixer_mixervoice_obj_t *self = m_new_obj(audiomixer_mixervoice_obj_t); self->base.type = &audiomixer_mixervoice_type; diff --git a/shared-bindings/audiomp3/MP3Decoder.c b/shared-bindings/audiomp3/MP3Decoder.c index 1b89b87a5c..589751821d 100644 --- a/shared-bindings/audiomp3/MP3Decoder.c +++ b/shared-bindings/audiomp3/MP3Decoder.c @@ -27,7 +27,7 @@ #include -#include "lib/utils/context_manager_helpers.h" +#include "shared/runtime/context_manager_helpers.h" #include "py/objproperty.h" #include "py/runtime.h" #include "shared-bindings/audiomp3/MP3Decoder.h" @@ -67,8 +67,8 @@ //| print("stopped")""" //| ... //| -STATIC mp_obj_t audiomp3_mp3file_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { - mp_arg_check_num(n_args, kw_args, 1, 2, false); +STATIC mp_obj_t audiomp3_mp3file_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { + mp_arg_check_num(n_args, n_kw, 1, 2, false); audiomp3_mp3file_obj_t *self = m_new_obj(audiomp3_mp3file_obj_t); self->base.type = &audiomp3_mp3file_type; diff --git a/shared-bindings/audiopwmio/PWMAudioOut.c b/shared-bindings/audiopwmio/PWMAudioOut.c index adb29f8f78..cded4a634f 100644 --- a/shared-bindings/audiopwmio/PWMAudioOut.c +++ b/shared-bindings/audiopwmio/PWMAudioOut.c @@ -26,7 +26,7 @@ #include -#include "lib/utils/context_manager_helpers.h" +#include "shared/runtime/context_manager_helpers.h" #include "py/binary.h" #include "py/objproperty.h" #include "py/runtime.h" @@ -93,7 +93,7 @@ //| print("stopped")""" //| ... //| -STATIC mp_obj_t audiopwmio_pwmaudioout_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +STATIC mp_obj_t audiopwmio_pwmaudioout_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_left_channel, ARG_right_channel, ARG_quiescent_value }; static const mp_arg_t allowed_args[] = { { MP_QSTR_left_channel, MP_ARG_OBJ | MP_ARG_REQUIRED }, @@ -101,7 +101,7 @@ STATIC mp_obj_t audiopwmio_pwmaudioout_make_new(const mp_obj_type_t *type, size_ { MP_QSTR_quiescent_value, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 0x8000} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, 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 *left_channel_pin = validate_obj_is_free_pin(args[ARG_left_channel].u_obj); const mcu_pin_obj_t *right_channel_pin = validate_obj_is_free_pin_or_none(args[ARG_right_channel].u_obj); diff --git a/shared-bindings/bitbangio/I2C.c b/shared-bindings/bitbangio/I2C.c index 9f39e84061..b47ace149f 100644 --- a/shared-bindings/bitbangio/I2C.c +++ b/shared-bindings/bitbangio/I2C.c @@ -31,8 +31,8 @@ #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/util.h" -#include "lib/utils/buffer_helper.h" -#include "lib/utils/context_manager_helpers.h" +#include "shared/runtime/buffer_helper.h" +#include "shared/runtime/context_manager_helpers.h" #include "py/mperrno.h" #include "py/runtime.h" #include "supervisor/shared/translate.h" @@ -59,7 +59,7 @@ //| :param int timeout: The maximum clock stretching timeout in microseconds""" //| ... //| -STATIC mp_obj_t bitbangio_i2c_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +STATIC mp_obj_t bitbangio_i2c_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_scl, ARG_sda, ARG_frequency, ARG_timeout }; static const mp_arg_t allowed_args[] = { { MP_QSTR_scl, MP_ARG_REQUIRED | MP_ARG_OBJ }, @@ -68,7 +68,7 @@ STATIC mp_obj_t bitbangio_i2c_make_new(const mp_obj_type_t *type, size_t n_args, { MP_QSTR_timeout, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 255} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, 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 *scl = validate_obj_is_free_pin(args[ARG_scl].u_obj); const mcu_pin_obj_t *sda = validate_obj_is_free_pin(args[ARG_sda].u_obj); @@ -165,7 +165,8 @@ STATIC mp_obj_t bitbangio_i2c_obj_unlock(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(bitbangio_i2c_unlock_obj, bitbangio_i2c_obj_unlock); -//| def readfrom_into(self, address: int, buffer: WriteableBuffer, *, start: int = 0, end: Optional[int] = None) -> None: +//| import sys +//| def readfrom_into(self, address: int, buffer: WriteableBuffer, *, start: int = 0, end: int = sys.maxsize) -> None: //| """Read into ``buffer`` from the device selected by ``address``. //| The number of bytes read will be the length of ``buffer``. //| At least one byte must be read. @@ -175,7 +176,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(bitbangio_i2c_unlock_obj, bitbangio_i2c_obj_unlock); //| ``buf[start:end]`` will so it saves memory. //| //| :param int address: 7-bit device address -//| :param ~_typing.WriteableBuffer buffer: buffer to write into +//| :param WriteableBuffer buffer: buffer to write into //| :param int start: Index to start writing at //| :param int end: Index to write up to but not include""" //| ... @@ -215,24 +216,26 @@ STATIC mp_obj_t bitbangio_i2c_readfrom_into(size_t n_args, const mp_obj_t *pos_a args[ARG_end].u_int); return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_KW(bitbangio_i2c_readfrom_into_obj, 3, bitbangio_i2c_readfrom_into); +MP_DEFINE_CONST_FUN_OBJ_KW(bitbangio_i2c_readfrom_into_obj, 1, bitbangio_i2c_readfrom_into); -//| def writeto(self, address: int, buffer: ReadableBuffer, *, start: int = 0, end: Optional[int] = None) -> None: +//| import sys +//| def writeto(self, address: int, buffer: ReadableBuffer, *, start: int = 0, end: int = sys.maxsize) -> None: //| """Write the bytes from ``buffer`` to the device selected by ``address`` and then transmits a //| stop bit. Use `writeto_then_readfrom` when needing a write, no stop and repeated start //| before a read. //| //| If ``start`` or ``end`` is provided, then the buffer will be sliced -//| as if ``buffer[start:end]``. This will not cause an allocation like -//| ``buffer[start:end]`` will so it saves memory. +//| as if ``buffer[start:end]`` were passed, but without copying the data. +//| The number of bytes written will be the length of ``buffer[start:end]``. //| //| Writing a buffer or slice of length zero is permitted, as it can be used //| to poll for the existence of a device. //| //| :param int address: 7-bit device address -//| :param ~_typing.ReadableBuffer buffer: buffer containing the bytes to write -//| :param int start: Index to start writing from -//| :param int end: Index to read up to but not include""" +//| :param ReadableBuffer buffer: buffer containing the bytes to write +//| :param int start: beginning of buffer slice +//| :param int end: end of buffer slice; if not specified, use ``len(buffer)`` +//| """ //| ... //| // Shared arg parsing for writeto and writeto_then_readfrom. @@ -274,22 +277,29 @@ STATIC mp_obj_t bitbangio_i2c_writeto(size_t n_args, const mp_obj_t *pos_args, m STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bitbangio_i2c_writeto_obj, 1, bitbangio_i2c_writeto); -//| def writeto_then_readfrom(self, address: int, out_buffer: ReadableBuffer, in_buffer: ReadableBuffer, *, out_start: int = 0, out_end: Optional[int] = None, in_start: int = 0, in_end: Optional[int] = None) -> None: +//| import sys +//| def writeto_then_readfrom(self, address: int, out_buffer: ReadableBuffer, in_buffer: ReadableBuffer, *, out_start: int = 0, out_end: int = sys.maxsize, in_start: int = 0, in_end: int = sys.maxsize) -> None: //| """Write the bytes from ``out_buffer`` to the device selected by ``address``, generate no stop //| bit, generate a repeated start and read into ``in_buffer``. ``out_buffer`` and //| ``in_buffer`` can be the same buffer because they are used sequentially. //| -//| If ``start`` or ``end`` is provided, then the corresponding buffer will be sliced -//| as if ``buffer[start:end]``. This will not cause an allocation like ``buf[start:end]`` -//| will so it saves memory. +//| If ``out_start`` or ``out_end`` is provided, then the buffer will be sliced +//| as if ``out_buffer[out_start:out_end]`` were passed, but without copying the data. +//| The number of bytes written will be the length of ``out_buffer[start:end]``. //| +//| If ``in_start`` or ``in_end`` is provided, then the input buffer will be sliced +//| as if ``in_buffer[in_start:in_end]`` were passed, +//| 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 int out_start: Index to start writing from -//| :param int out_end: Index to read up to but not include. Defaults to ``len(buffer)`` -//| :param int in_start: Index to start writing at -//| :param int in_end: Index to write up to but not include. Defaults to ``len(buffer)``""" +//| :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 +//| :param int in_end: end of ``in_buffer slice``; if not specified, use ``len(in_buffer)`` +//| """ +//| ... //| STATIC mp_obj_t bitbangio_i2c_writeto_then_readfrom(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_address, ARG_out_buffer, ARG_in_buffer, ARG_out_start, ARG_out_end, ARG_in_start, ARG_in_end }; @@ -315,7 +325,7 @@ STATIC mp_obj_t bitbangio_i2c_writeto_then_readfrom(size_t n_args, const mp_obj_ return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_KW(bitbangio_i2c_writeto_then_readfrom_obj, 3, bitbangio_i2c_writeto_then_readfrom); +MP_DEFINE_CONST_FUN_OBJ_KW(bitbangio_i2c_writeto_then_readfrom_obj, 1, bitbangio_i2c_writeto_then_readfrom); STATIC const mp_rom_map_elem_t bitbangio_i2c_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&bitbangio_i2c_deinit_obj) }, diff --git a/shared-bindings/bitbangio/SPI.c b/shared-bindings/bitbangio/SPI.c index 0f8cb59a60..1f8f3ac136 100644 --- a/shared-bindings/bitbangio/SPI.c +++ b/shared-bindings/bitbangio/SPI.c @@ -33,8 +33,8 @@ #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/util.h" -#include "lib/utils/buffer_helper.h" -#include "lib/utils/context_manager_helpers.h" +#include "shared/runtime/buffer_helper.h" +#include "shared/runtime/context_manager_helpers.h" #include "py/mperrno.h" #include "py/runtime.h" #include "supervisor/shared/translate.h" @@ -70,7 +70,7 @@ //| // TODO(tannewt): Support LSB SPI. -STATIC mp_obj_t bitbangio_spi_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +STATIC mp_obj_t bitbangio_spi_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_clock, ARG_MOSI, ARG_MISO, ARG_baudrate, ARG_polarity, ARG_phase, ARG_bits, ARG_firstbit }; static const mp_arg_t allowed_args[] = { { MP_QSTR_clock, MP_ARG_REQUIRED | MP_ARG_OBJ }, @@ -78,7 +78,7 @@ STATIC mp_obj_t bitbangio_spi_make_new(const mp_obj_type_t *type, size_t n_args, { MP_QSTR_MISO, MP_ARG_OBJ, {.u_obj = mp_const_none} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, 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 *clock = validate_obj_is_free_pin(args[ARG_clock].u_obj); const mcu_pin_obj_t *mosi = validate_obj_is_free_pin_or_none(args[ARG_MOSI].u_obj); @@ -224,18 +224,23 @@ STATIC mp_obj_t bitbangio_spi_write(mp_obj_t self_in, mp_obj_t wr_buf) { MP_DEFINE_CONST_FUN_OBJ_2(bitbangio_spi_write_obj, bitbangio_spi_write); -//| def readinto(self, buffer: WriteableBuffer, *, start: int = 0, end: Optional[int] = None, write_value: int = 0) -> None: +//| import sys +//| def readinto(self, buffer: WriteableBuffer, *, start: int = 0, end: int = sys.maxsize, write_value: int = 0) -> None: //| """Read into ``buffer`` while writing ``write_value`` for each byte read. //| The SPI object must be locked. //| If the number of bytes to read is 0, nothing happens. //| -//| :param bytearray 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)`` -//| :param int write_value: Value to write while reading.""" +//| If ``start`` or ``end`` is provided, then the buffer will be sliced +//| as if ``buffer[start:end]`` were passed. +//| The number of bytes read will be the length of ``buffer[start:end]``. +//| +//| :param WriteableBuffer buffer: read bytes into this buffer +//| :param int start: beginning of buffer slice +//| :param int end: end of buffer slice; if not specified, use ``len(buffer)`` +//| :param int write_value: value to write while reading +//| """ //| ... //| - STATIC mp_obj_t bitbangio_spi_readinto(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_buffer, ARG_start, ARG_end, ARG_write_value }; static const mp_arg_t allowed_args[] = { @@ -266,28 +271,39 @@ STATIC mp_obj_t bitbangio_spi_readinto(size_t n_args, const mp_obj_t *pos_args, } return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_KW(bitbangio_spi_readinto_obj, 2, bitbangio_spi_readinto); +MP_DEFINE_CONST_FUN_OBJ_KW(bitbangio_spi_readinto_obj, 1, bitbangio_spi_readinto); -//| def write_readinto(self, buffer_out: ReadableBuffer, buffer_in: ReadableBuffer, *, out_start: int = 0, out_end: Optional[int] = None, in_start: int = 0, in_end: Optional[int] = None) -> None: -//| """Write out the data in ``buffer_out`` while simultaneously reading data into ``buffer_in``. +//| import sys +//| def write_readinto(self, out_buffer: ReadableBuffer, in_buffer: WriteableBuffer, *, out_start: int = 0, out_end: int = sys.maxsize, in_start: int = 0, in_end: int = sys.maxsize) -> None: +//| """Write out the data in ``out_buffer`` while simultaneously reading data into ``in_buffer``. //| The SPI object must be locked. -//| The lengths of the slices defined by ``buffer_out[out_start:out_end]`` and ``buffer_in[in_start:in_end]`` -//| must be equal. +//| +//| If ``out_start`` or ``out_end`` is provided, then the buffer will be sliced +//| as if ``out_buffer[out_start:out_end]`` were passed, but without copying the data. +//| The number of bytes written will be the length of ``out_buffer[out_start:out_end]``. +//| +//| If ``in_start`` or ``in_end`` is provided, then the input buffer will be sliced +//| as if ``in_buffer[in_start:in_end]`` were passed, +//| The number of bytes read will be the length of ``out_buffer[in_start:in_end]``. +//| +//| The lengths of the slices defined by ``out_buffer[out_start:out_end]`` +//| and ``in_buffer[in_start:in_end]`` must be equal. //| 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 -//| :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]`` -//| :param int in_end: End of the slice; this index is not included. Defaults to ``len(buffer_in)``""" +//| :param ReadableBuffer out_buffer: write out bytes from this buffer +//| :param WriteableBuffer in_buffer: read bytes into this buffer +//| :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 +//| :param int in_end: end of ``in_buffer slice``; if not specified, use ``len(in_buffer)`` +//| """ //| ... //| STATIC mp_obj_t bitbangio_spi_write_readinto(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { - enum { ARG_buffer_out, ARG_buffer_in, ARG_out_start, ARG_out_end, ARG_in_start, ARG_in_end }; + enum { ARG_out_buffer, ARG_in_buffer, ARG_out_start, ARG_out_end, ARG_in_start, ARG_in_end }; static const mp_arg_t allowed_args[] = { - { MP_QSTR_buffer_out, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, - { MP_QSTR_buffer_in, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, + { 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} }, @@ -301,13 +317,13 @@ STATIC mp_obj_t bitbangio_spi_write_readinto(size_t n_args, const mp_obj_t *pos_ mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); mp_buffer_info_t buf_out_info; - mp_get_buffer_raise(args[ARG_buffer_out].u_obj, &buf_out_info, MP_BUFFER_READ); + mp_get_buffer_raise(args[ARG_out_buffer].u_obj, &buf_out_info, MP_BUFFER_READ); int32_t out_start = args[ARG_out_start].u_int; size_t out_length = buf_out_info.len; normalize_buffer_bounds(&out_start, args[ARG_out_end].u_int, &out_length); mp_buffer_info_t buf_in_info; - mp_get_buffer_raise(args[ARG_buffer_in].u_obj, &buf_in_info, MP_BUFFER_WRITE); + mp_get_buffer_raise(args[ARG_in_buffer].u_obj, &buf_in_info, MP_BUFFER_WRITE); int32_t in_start = args[ARG_in_start].u_int; size_t in_length = buf_in_info.len; normalize_buffer_bounds(&in_start, args[ARG_in_end].u_int, &in_length); @@ -329,7 +345,7 @@ STATIC mp_obj_t bitbangio_spi_write_readinto(size_t n_args, const mp_obj_t *pos_ } return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_KW(bitbangio_spi_write_readinto_obj, 2, bitbangio_spi_write_readinto); +MP_DEFINE_CONST_FUN_OBJ_KW(bitbangio_spi_write_readinto_obj, 1, bitbangio_spi_write_readinto); STATIC const mp_rom_map_elem_t bitbangio_spi_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&bitbangio_spi_deinit_obj) }, diff --git a/shared-bindings/bitmaptools/__init__.c b/shared-bindings/bitmaptools/__init__.c index 4e14a061f0..ad814e8881 100644 --- a/shared-bindings/bitmaptools/__init__.c +++ b/shared-bindings/bitmaptools/__init__.c @@ -463,10 +463,7 @@ STATIC mp_obj_t bitmaptools_arrayblit(size_t n_args, const mp_obj_t *pos_args, m mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - if (!mp_obj_is_type(args[ARG_bitmap].u_obj, &displayio_bitmap_type)) { - mp_raise_TypeError(NULL); - } - displayio_bitmap_t *bitmap = MP_OBJ_TO_PTR(args[ARG_bitmap].u_obj); + displayio_bitmap_t *bitmap = mp_arg_validate_type(args[ARG_bitmap].u_obj, &displayio_bitmap_type, MP_QSTR_bitmap); mp_buffer_info_t bufinfo; mp_get_buffer_raise(args[ARG_data].u_obj, &bufinfo, MP_BUFFER_READ); @@ -533,15 +530,9 @@ STATIC mp_obj_t bitmaptools_readinto(size_t n_args, const mp_obj_t *pos_args, mp mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - if (!mp_obj_is_type(args[ARG_bitmap].u_obj, &displayio_bitmap_type)) { - mp_raise_TypeError(NULL); - } - displayio_bitmap_t *bitmap = MP_OBJ_TO_PTR(args[ARG_bitmap].u_obj); + displayio_bitmap_t *bitmap = mp_arg_validate_type(args[ARG_bitmap].u_obj, &displayio_bitmap_type, MP_QSTR_bitmap); - if (!mp_obj_is_type(args[ARG_file].u_obj, &mp_type_fileio)) { - mp_raise_TypeError(NULL); - } - pyb_file_obj_t *file = MP_OBJ_TO_PTR(args[ARG_file].u_obj); + pyb_file_obj_t *file = mp_arg_validate_type(args[ARG_file].u_obj, &mp_type_fileio, MP_QSTR_file); int element_size = args[ARG_element_size].u_int; if (element_size != 1 && element_size != 2 && element_size != 4) { diff --git a/shared-bindings/bitops/__init__.c b/shared-bindings/bitops/__init__.c index d9849da917..5b455dcb0f 100644 --- a/shared-bindings/bitops/__init__.c +++ b/shared-bindings/bitops/__init__.c @@ -86,7 +86,7 @@ STATIC mp_obj_t bit_transpose(size_t n_args, const mp_obj_t *pos_args, mp_map_t common_hal_bitops_bit_transpose(output_bufinfo.buf, input_bufinfo.buf, inlen, width); return args[ARG_output].u_obj; } -STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bitops_bit_transpose_obj, 1, bit_transpose); +STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bitops_bit_transpose_obj, 0, bit_transpose); STATIC const mp_rom_map_elem_t bitops_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_bitops) }, diff --git a/shared-bindings/busio/I2C.c b/shared-bindings/busio/I2C.c index 344dad8acc..d8951cb565 100644 --- a/shared-bindings/busio/I2C.c +++ b/shared-bindings/busio/I2C.c @@ -31,8 +31,8 @@ #include "shared-bindings/busio/I2C.h" #include "shared-bindings/util.h" -#include "lib/utils/buffer_helper.h" -#include "lib/utils/context_manager_helpers.h" +#include "shared/runtime/buffer_helper.h" +#include "shared/runtime/context_manager_helpers.h" #include "py/runtime.h" #include "supervisor/shared/translate.h" @@ -64,7 +64,7 @@ //| 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, const mp_obj_t *pos_args, mp_map_t *kw_args) { +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) { busio_i2c_obj_t *self = m_new_obj(busio_i2c_obj_t); self->base.type = &busio_i2c_type; enum { ARG_scl, ARG_sda, ARG_frequency, ARG_timeout }; @@ -75,7 +75,7 @@ STATIC mp_obj_t busio_i2c_make_new(const mp_obj_type_t *type, size_t n_args, con { MP_QSTR_timeout, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 255} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, 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 *scl = validate_obj_is_free_pin(args[ARG_scl].u_obj); const mcu_pin_obj_t *sda = validate_obj_is_free_pin(args[ARG_sda].u_obj); @@ -176,19 +176,19 @@ STATIC mp_obj_t busio_i2c_obj_unlock(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(busio_i2c_unlock_obj, busio_i2c_obj_unlock); -//| def readfrom_into(self, address: int, buffer: WriteableBuffer, *, start: int = 0, end: Optional[int] = None) -> None: +//| import sys +//| def readfrom_into(self, address: int, buffer: WriteableBuffer, *, start: int = 0, end: int = sys.maxsize) -> None: //| """Read into ``buffer`` from the device selected by ``address``. -//| The number of bytes read will be the length of ``buffer``. //| At least one byte must be read. //| //| If ``start`` or ``end`` is provided, then the buffer will be sliced -//| as if ``buffer[start:end]``. This will not cause an allocation like -//| ``buf[start:end]`` will so it saves memory. +//| as if ``buffer[start:end]`` were passed, but without copying the data. +//| The number of bytes read will be the length of ``buffer[start:end]``. //| //| :param int address: 7-bit device address -//| :param ~_typing.WriteableBuffer buffer: buffer to write into -//| :param int start: Index to start writing at -//| :param int end: Index to write up to but not include. Defaults to ``len(buffer)``""" +//| :param WriteableBuffer buffer: buffer to write into +//| :param int start: beginning of buffer slice +//| :param int end: end of buffer slice; if not specified, use ``len(buffer)``""" //| ... //| // Shared arg parsing for readfrom_into and writeto_then_readfrom. @@ -226,23 +226,25 @@ STATIC mp_obj_t busio_i2c_readfrom_into(size_t n_args, const mp_obj_t *pos_args, args[ARG_end].u_int); return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_KW(busio_i2c_readfrom_into_obj, 3, busio_i2c_readfrom_into); +MP_DEFINE_CONST_FUN_OBJ_KW(busio_i2c_readfrom_into_obj, 1, busio_i2c_readfrom_into); -//| def writeto(self, address: int, buffer: ReadableBuffer, *, start: int = 0, end: Optional[int] = None) -> None: +//| import sys +//| def writeto(self, address: int, buffer: ReadableBuffer, *, start: int = 0, end: int = sys.maxsize) -> None: //| """Write the bytes from ``buffer`` to the device selected by ``address`` and //| then transmit a stop bit. //| //| If ``start`` or ``end`` is provided, then the buffer will be sliced -//| as if ``buffer[start:end]``. This will not cause an allocation like -//| ``buffer[start:end]`` will so it saves memory. +//| as if ``buffer[start:end]`` were passed, but without copying the data. +//| The number of bytes written will be the length of ``buffer[start:end]``. //| //| Writing a buffer or slice of length zero is permitted, as it can be used //| to poll for the existence of a device. //| //| :param int address: 7-bit device address -//| :param ~_typing.ReadableBuffer buffer: buffer containing the bytes to write -//| :param int start: Index to start writing from -//| :param int end: Index to read up to but not include. Defaults to ``len(buffer)``""" +//| :param ReadableBuffer buffer: buffer containing the bytes to write +//| :param int start: beginning of buffer slice +//| :param int end: end of buffer slice; if not specified, use ``len(buffer)`` +//| """ //| ... //| // Shared arg parsing for writeto and writeto_then_readfrom. @@ -282,22 +284,28 @@ STATIC mp_obj_t busio_i2c_writeto(size_t n_args, const mp_obj_t *pos_args, mp_ma } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(busio_i2c_writeto_obj, 1, busio_i2c_writeto); -//| def writeto_then_readfrom(self, address: int, out_buffer: ReadableBuffer, in_buffer: WriteableBuffer, *, out_start: int = 0, out_end: Optional[int] = None, in_start: int = 0, in_end: Optional[int] = None) -> None: +//| import sys +//| def writeto_then_readfrom(self, address: int, out_buffer: ReadableBuffer, in_buffer: WriteableBuffer, *, out_start: int = 0, out_end: int = sys.maxsize, in_start: int = 0, in_end: int = sys.maxsize) -> None: //| """Write the bytes from ``out_buffer`` to the device selected by ``address``, generate no stop //| bit, generate a repeated start and read into ``in_buffer``. ``out_buffer`` and //| ``in_buffer`` can be the same buffer because they are used sequentially. //| -//| If ``start`` or ``end`` is provided, then the corresponding buffer will be sliced -//| as if ``buffer[start:end]``. This will not cause an allocation like ``buf[start:end]`` -//| will so it saves memory. +//| If ``out_start`` or ``out_end`` is provided, then the buffer will be sliced +//| as if ``out_buffer[out_start:out_end]`` were passed, but without copying the data. +//| The number of bytes written will be the length of ``out_buffer[start:end]``. //| +//| If ``in_start`` or ``in_end`` is provided, then the input buffer will be sliced +//| as if ``in_buffer[in_start:in_end]`` were passed, +//| 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 int out_start: Index to start writing from -//| :param int out_end: Index to read up to but not include. Defaults to ``len(buffer)`` -//| :param int in_start: Index to start writing at -//| :param int in_end: Index to write up to but not include. Defaults to ``len(buffer)``""" +//| :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 +//| :param int in_end: end of ``in_buffer slice``; if not specified, use ``len(in_buffer)`` +//| """ //| ... //| STATIC mp_obj_t busio_i2c_writeto_then_readfrom(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { @@ -324,7 +332,7 @@ STATIC mp_obj_t busio_i2c_writeto_then_readfrom(size_t n_args, const mp_obj_t *p return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_KW(busio_i2c_writeto_then_readfrom_obj, 3, busio_i2c_writeto_then_readfrom); +MP_DEFINE_CONST_FUN_OBJ_KW(busio_i2c_writeto_then_readfrom_obj, 1, busio_i2c_writeto_then_readfrom); STATIC const mp_rom_map_elem_t busio_i2c_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&busio_i2c_deinit_obj) }, diff --git a/shared-bindings/busio/SPI.c b/shared-bindings/busio/SPI.c index a611d8e1d5..b2cf90f2cc 100644 --- a/shared-bindings/busio/SPI.c +++ b/shared-bindings/busio/SPI.c @@ -33,8 +33,8 @@ #include "shared-bindings/busio/SPI.h" #include "shared-bindings/util.h" -#include "lib/utils/buffer_helper.h" -#include "lib/utils/context_manager_helpers.h" +#include "shared/runtime/buffer_helper.h" +#include "shared/runtime/context_manager_helpers.h" #include "py/mperrno.h" #include "py/objproperty.h" #include "py/runtime.h" @@ -80,7 +80,7 @@ // TODO(tannewt): Support LSB SPI. -STATIC mp_obj_t busio_spi_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +STATIC mp_obj_t busio_spi_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { #if CIRCUITPY_BUSIO_SPI busio_spi_obj_t *self = m_new_obj(busio_spi_obj_t); self->base.type = &busio_spi_type; @@ -91,7 +91,7 @@ STATIC mp_obj_t busio_spi_make_new(const mp_obj_type_t *type, size_t n_args, con { MP_QSTR_MISO, MP_ARG_OBJ, {.u_obj = mp_const_none} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, 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 *clock = validate_obj_is_free_pin(args[ARG_clock].u_obj); const mcu_pin_obj_t *mosi = validate_obj_is_free_pin_or_none(args[ARG_MOSI].u_obj); @@ -237,13 +237,19 @@ STATIC mp_obj_t busio_spi_obj_unlock(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(busio_spi_unlock_obj, busio_spi_obj_unlock); -//| def write(self, buffer: ReadableBuffer, *, start: int = 0, end: Optional[int] = None) -> None: +//| import sys +//| def write(self, buffer: ReadableBuffer, *, start: int = 0, end: int = sys.maxsize) -> None: //| """Write the data contained in ``buffer``. The SPI object must be locked. //| If the buffer is empty, nothing happens. //| -//| :param ~_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)``""" +//| If ``start`` or ``end`` is provided, then the buffer will be sliced +//| as if ``buffer[start:end]`` were passed, but without copying the data. +//| The number of bytes written will be the length of ``buffer[start:end]``. +//| +//| :param ReadableBuffer buffer: write out bytes from this buffer +//| :param int start: beginning of buffer slice +//| :param int end: end of buffer slice; if not specified, use ``len(buffer)`` +//| """ //| ... //| @@ -276,18 +282,24 @@ STATIC mp_obj_t busio_spi_write(size_t n_args, const mp_obj_t *pos_args, mp_map_ } return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_KW(busio_spi_write_obj, 2, busio_spi_write); +MP_DEFINE_CONST_FUN_OBJ_KW(busio_spi_write_obj, 1, busio_spi_write); -//| def readinto(self, buffer: WriteableBuffer, *, start: int = 0, end: Optional[int] = None, write_value: int = 0) -> None: +//| import sys +//| def readinto(self, buffer: WriteableBuffer, *, start: int = 0, end: int = sys.maxsize, write_value: int = 0) -> None: //| """Read into ``buffer`` while writing ``write_value`` for each byte read. //| The SPI object must be locked. //| If the number of bytes to read is 0, nothing happens. //| -//| :param ~_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)`` -//| :param int write_value: Value to write while reading. (Usually ignored.)""" +//| If ``start`` or ``end`` is provided, then the buffer will be sliced +//| as if ``buffer[start:end]`` were passed. +//| The number of bytes read will be the length of ``buffer[start:end]``. +//| +//| :param WriteableBuffer buffer: read bytes into this buffer +//| :param int start: beginning of buffer slice +//| :param int end: end of buffer slice; if not specified, use ``len(buffer)`` +//| :param int write_value: value to write while reading +//| """ //| ... //| @@ -321,29 +333,40 @@ STATIC mp_obj_t busio_spi_readinto(size_t n_args, const mp_obj_t *pos_args, mp_m } return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_KW(busio_spi_readinto_obj, 2, busio_spi_readinto); +MP_DEFINE_CONST_FUN_OBJ_KW(busio_spi_readinto_obj, 1, busio_spi_readinto); -//| def write_readinto(self, buffer_out: ReadableBuffer, buffer_in: WriteableBuffer, *, out_start: int = 0, out_end: Optional[int] = None, in_start: int = 0, in_end: Optional[int] = None) -> None: -//| """Write out the data in ``buffer_out`` while simultaneously reading data into ``buffer_in``. +//| import sys +//| def write_readinto(self, out_buffer: ReadableBuffer, in_buffer: WriteableBuffer, *, out_start: int = 0, out_end: int = sys.maxsize, in_start: int = 0, in_end: int = sys.maxsize) -> None: +//| """Write out the data in ``out_buffer`` while simultaneously reading data into ``in_buffer``. //| The SPI object must be locked. -//| The lengths of the slices defined by ``buffer_out[out_start:out_end]`` and ``buffer_in[in_start:in_end]`` -//| must be equal. +//| +//| If ``out_start`` or ``out_end`` is provided, then the buffer will be sliced +//| as if ``out_buffer[out_start:out_end]`` were passed, but without copying the data. +//| The number of bytes written will be the length of ``out_buffer[out_start:out_end]``. +//| +//| If ``in_start`` or ``in_end`` is provided, then the input buffer will be sliced +//| as if ``in_buffer[in_start:in_end]`` were passed, +//| The number of bytes read will be the length of ``out_buffer[in_start:in_end]``. +//| +//| The lengths of the slices defined by ``out_buffer[out_start:out_end]`` +//| and ``in_buffer[in_start:in_end]`` must be equal. //| 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 -//| :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]`` -//| :param int in_end: End of the slice; this index is not included. Defaults to ``len(buffer_in)``""" +//| :param ReadableBuffer out_buffer: write out bytes from this buffer +//| :param WriteableBuffer in_buffer: read bytes into this buffer +//| :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 +//| :param int in_end: end of ``in_buffer slice``; if not specified, use ``len(in_buffer)`` +//| """ //| ... //| STATIC mp_obj_t busio_spi_write_readinto(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { - enum { ARG_buffer_out, ARG_buffer_in, ARG_out_start, ARG_out_end, ARG_in_start, ARG_in_end }; + enum { ARG_out_buffer, ARG_in_buffer, ARG_out_start, ARG_out_end, ARG_in_start, ARG_in_end }; static const mp_arg_t allowed_args[] = { - { MP_QSTR_buffer_out, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, - { MP_QSTR_buffer_in, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, + { 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} }, @@ -356,13 +379,13 @@ STATIC mp_obj_t busio_spi_write_readinto(size_t n_args, const mp_obj_t *pos_args mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); mp_buffer_info_t buf_out_info; - mp_get_buffer_raise(args[ARG_buffer_out].u_obj, &buf_out_info, MP_BUFFER_READ); + mp_get_buffer_raise(args[ARG_out_buffer].u_obj, &buf_out_info, MP_BUFFER_READ); int32_t out_start = args[ARG_out_start].u_int; size_t out_length = buf_out_info.len; normalize_buffer_bounds(&out_start, args[ARG_out_end].u_int, &out_length); mp_buffer_info_t buf_in_info; - mp_get_buffer_raise(args[ARG_buffer_in].u_obj, &buf_in_info, MP_BUFFER_WRITE); + mp_get_buffer_raise(args[ARG_in_buffer].u_obj, &buf_in_info, MP_BUFFER_WRITE); int32_t in_start = args[ARG_in_start].u_int; size_t in_length = buf_in_info.len; normalize_buffer_bounds(&in_start, args[ARG_in_end].u_int, &in_length); @@ -384,7 +407,7 @@ STATIC mp_obj_t busio_spi_write_readinto(size_t n_args, const mp_obj_t *pos_args } return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_KW(busio_spi_write_readinto_obj, 2, busio_spi_write_readinto); +MP_DEFINE_CONST_FUN_OBJ_KW(busio_spi_write_readinto_obj, 1, busio_spi_write_readinto); //| frequency: int //| """The actual SPI bus frequency. This may not match the frequency requested diff --git a/shared-bindings/busio/UART.c b/shared-bindings/busio/UART.c index efb0643d0b..a46ab6826e 100644 --- a/shared-bindings/busio/UART.c +++ b/shared-bindings/busio/UART.c @@ -30,8 +30,8 @@ #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/util.h" -#include "lib/utils/context_manager_helpers.h" -#include "lib/utils/interrupt_char.h" +#include "shared/runtime/context_manager_helpers.h" +#include "shared/runtime/interrupt_char.h" #include "py/ioctl.h" #include "py/objproperty.h" @@ -80,7 +80,7 @@ STATIC void validate_timeout(mp_float_t timeout) { } #endif // CIRCUITPY_BUSIO_UART -STATIC mp_obj_t busio_uart_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +STATIC mp_obj_t busio_uart_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { #if CIRCUITPY_BUSIO_UART // Always initially allocate the UART object within the long-lived heap. // This is needed to avoid crashes with certain UART implementations which @@ -105,7 +105,7 @@ STATIC mp_obj_t busio_uart_make_new(const mp_obj_type_t *type, size_t n_args, co { MP_QSTR_rs485_invert, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = false } }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, 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 *rx = validate_obj_is_free_pin_or_none(args[ARG_rx].u_obj); const mcu_pin_obj_t *tx = validate_obj_is_free_pin_or_none(args[ARG_tx].u_obj); diff --git a/shared-bindings/camera/Camera.c b/shared-bindings/camera/Camera.c index a588965005..b7187ecbbf 100644 --- a/shared-bindings/camera/Camera.c +++ b/shared-bindings/camera/Camera.c @@ -61,7 +61,7 @@ //| """Initialize camera.""" //| ... //| -STATIC mp_obj_t camera_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +STATIC mp_obj_t camera_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *all_args, mp_map_t *kw_args) { camera_obj_t *self = m_new_obj(camera_obj_t); self->base.type = &camera_type; // No arguments @@ -116,7 +116,7 @@ STATIC mp_obj_t camera_obj_take_picture(size_t n_args, const mp_obj_t *pos_args, return MP_OBJ_NEW_SMALL_INT(common_hal_camera_take_picture(self, (uint8_t *)bufinfo.buf, bufinfo.len, args[ARG_width].u_int, args[ARG_height].u_int, format)); } -MP_DEFINE_CONST_FUN_OBJ_KW(camera_take_picture_obj, 2, camera_obj_take_picture); +MP_DEFINE_CONST_FUN_OBJ_KW(camera_take_picture_obj, 1, camera_obj_take_picture); STATIC const mp_rom_map_elem_t camera_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&camera_deinit_obj) }, diff --git a/shared-bindings/canio/CAN.c b/shared-bindings/canio/CAN.c index a6f78b2b50..1efd3a0930 100644 --- a/shared-bindings/canio/CAN.c +++ b/shared-bindings/canio/CAN.c @@ -63,7 +63,7 @@ //| """ //| ... //| -STATIC mp_obj_t canio_can_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +STATIC mp_obj_t canio_can_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_tx, ARG_rx, ARG_baudrate, ARG_loopback, ARG_silent, ARG_auto_restart, NUM_ARGS }; static const mp_arg_t allowed_args[] = { { MP_QSTR_tx, MP_ARG_OBJ | MP_ARG_REQUIRED }, @@ -76,7 +76,7 @@ STATIC mp_obj_t canio_can_make_new(const mp_obj_type_t *type, size_t n_args, con mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; MP_STATIC_ASSERT(MP_ARRAY_SIZE(allowed_args) == NUM_ARGS); - mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); mcu_pin_obj_t *rx_pin = validate_obj_is_free_pin_or_none(args[ARG_rx].u_obj); mcu_pin_obj_t *tx_pin = validate_obj_is_free_pin_or_none(args[ARG_tx].u_obj); diff --git a/shared-bindings/canio/Match.c b/shared-bindings/canio/Match.c index 7e9e137127..e8379d3eda 100644 --- a/shared-bindings/canio/Match.c +++ b/shared-bindings/canio/Match.c @@ -42,7 +42,7 @@ //| only standard ids are matched.""" //| -STATIC mp_obj_t canio_match_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +STATIC mp_obj_t canio_match_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_id, ARG_mask, ARG_extended, NUM_ARGS }; static const mp_arg_t allowed_args[] = { { MP_QSTR_id, MP_ARG_INT | MP_ARG_REQUIRED }, @@ -52,7 +52,7 @@ STATIC mp_obj_t canio_match_make_new(const mp_obj_type_t *type, size_t n_args, c mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; MP_STATIC_ASSERT(MP_ARRAY_SIZE(allowed_args) == NUM_ARGS); - mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); int id_bits = args[ARG_extended].u_bool ? 0x1fffffff : 0x7ff; int id = args[ARG_id].u_int; diff --git a/shared-bindings/canio/Message.c b/shared-bindings/canio/Message.c index e773b8d3a4..8ed1352dcc 100644 --- a/shared-bindings/canio/Message.c +++ b/shared-bindings/canio/Message.c @@ -42,7 +42,7 @@ //| """ //| ... //| -STATIC mp_obj_t canio_message_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +STATIC mp_obj_t canio_message_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_id, ARG_data, ARG_extended, NUM_ARGS }; static const mp_arg_t allowed_args[] = { { MP_QSTR_id, MP_ARG_INT | MP_ARG_REQUIRED }, @@ -52,7 +52,7 @@ STATIC mp_obj_t canio_message_make_new(const mp_obj_type_t *type, size_t n_args, mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; MP_STATIC_ASSERT(MP_ARRAY_SIZE(allowed_args) == NUM_ARGS); - mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); mp_buffer_info_t data; mp_get_buffer_raise(args[ARG_data].u_obj, &data, MP_BUFFER_READ); diff --git a/shared-bindings/canio/RemoteTransmissionRequest.c b/shared-bindings/canio/RemoteTransmissionRequest.c index 7d12063a0d..3267cf914d 100644 --- a/shared-bindings/canio/RemoteTransmissionRequest.c +++ b/shared-bindings/canio/RemoteTransmissionRequest.c @@ -42,7 +42,7 @@ //| """ //| ... //| -STATIC mp_obj_t canio_remote_transmission_request_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +STATIC mp_obj_t canio_remote_transmission_request_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_id, ARG_length, ARG_extended, NUM_ARGS }; static const mp_arg_t allowed_args[] = { { MP_QSTR_id, MP_ARG_INT | MP_ARG_REQUIRED }, @@ -52,7 +52,7 @@ STATIC mp_obj_t canio_remote_transmission_request_make_new(const mp_obj_type_t * mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; MP_STATIC_ASSERT(MP_ARRAY_SIZE(allowed_args) == NUM_ARGS); - mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); int length = args[ARG_length].u_int; if (length < 0 || length > 8) { diff --git a/shared-bindings/countio/Counter.c b/shared-bindings/countio/Counter.c index 8d84cfb70f..873da912a6 100644 --- a/shared-bindings/countio/Counter.c +++ b/shared-bindings/countio/Counter.c @@ -1,7 +1,7 @@ #include -#include "lib/utils/context_manager_helpers.h" +#include "shared/runtime/context_manager_helpers.h" #include "py/objproperty.h" #include "py/runtime.h" #include "py/runtime0.h" @@ -32,14 +32,14 @@ //| 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, const mp_obj_t *pos_args, mp_map_t *kw_args) { +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 }; static const mp_arg_t allowed_args[] = { { MP_QSTR_pin_a, MP_ARG_REQUIRED | MP_ARG_OBJ } }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, 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); diff --git a/shared-bindings/digitalio/DigitalInOut.c b/shared-bindings/digitalio/DigitalInOut.c index fc9e0362cd..ff5c494ea8 100644 --- a/shared-bindings/digitalio/DigitalInOut.c +++ b/shared-bindings/digitalio/DigitalInOut.c @@ -27,7 +27,7 @@ #include #include -#include "lib/utils/context_manager_helpers.h" +#include "shared/runtime/context_manager_helpers.h" #include "py/nlr.h" #include "py/objtype.h" @@ -59,8 +59,8 @@ //| ... //| STATIC mp_obj_t digitalio_digitalinout_make_new(const mp_obj_type_t *type, - mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { - mp_arg_check_num(n_args, kw_args, 1, 1, false); + size_t n_args, size_t n_kw, const mp_obj_t *args) { + mp_arg_check_num(n_args, n_kw, 1, 1, false); digitalio_digitalinout_obj_t *self = m_new_obj(digitalio_digitalinout_obj_t); self->base.type = &digitalio_digitalinout_type; diff --git a/shared-bindings/digitalio/Direction.c b/shared-bindings/digitalio/Direction.c index 0c2448ca9a..e7ebd0cfcc 100644 --- a/shared-bindings/digitalio/Direction.c +++ b/shared-bindings/digitalio/Direction.c @@ -27,7 +27,7 @@ #include #include -#include "lib/utils/context_manager_helpers.h" +#include "shared/runtime/context_manager_helpers.h" #include "py/nlr.h" #include "py/objtype.h" diff --git a/shared-bindings/digitalio/__init__.c b/shared-bindings/digitalio/__init__.c index 39b569253b..e3f4e9992d 100644 --- a/shared-bindings/digitalio/__init__.c +++ b/shared-bindings/digitalio/__init__.c @@ -50,9 +50,9 @@ //| For example:: //| //| import digitalio -//| from board import * +//| import board //| -//| pin = digitalio.DigitalInOut(D13) +//| pin = digitalio.DigitalInOut(board.LED) //| print(pin.value) //| //| This example will initialize the the device, read @@ -61,11 +61,11 @@ //| //| Here is blinky:: //| -//| import digitalio -//| from board import * //| import time +//| import digitalio +//| import board //| -//| led = digitalio.DigitalInOut(D13) +//| led = digitalio.DigitalInOut(board.LED) //| led.direction = digitalio.Direction.OUTPUT //| while True: //| led.value = True diff --git a/shared-bindings/displayio/Bitmap.c b/shared-bindings/displayio/Bitmap.c index b56991c0c2..5a1e12189a 100644 --- a/shared-bindings/displayio/Bitmap.c +++ b/shared-bindings/displayio/Bitmap.c @@ -29,7 +29,7 @@ #include -#include "lib/utils/context_manager_helpers.h" +#include "shared/runtime/context_manager_helpers.h" #include "py/binary.h" #include "py/objproperty.h" #include "py/runtime.h" @@ -63,11 +63,11 @@ //| :param int value_count: The number of possible pixel values.""" //| ... //| -STATIC mp_obj_t displayio_bitmap_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { - mp_arg_check_num(n_args, kw_args, 3, 3, false); - uint32_t width = mp_obj_get_int(pos_args[0]); - uint32_t height = mp_obj_get_int(pos_args[1]); - uint32_t value_count = mp_obj_get_int(pos_args[2]); +STATIC mp_obj_t displayio_bitmap_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { + mp_arg_check_num(n_args, n_kw, 3, 3, false); + uint32_t width = mp_obj_get_int(all_args[0]); + uint32_t height = mp_obj_get_int(all_args[1]); + uint32_t value_count = mp_obj_get_int(all_args[2]); uint32_t bits = 1; if (value_count == 0) { @@ -285,8 +285,7 @@ STATIC mp_obj_t displayio_bitmap_obj_blit(size_t n_args, const mp_obj_t *pos_arg return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_KW(displayio_bitmap_blit_obj, 4, displayio_bitmap_obj_blit); -// `displayio_bitmap_obj_blit` requires at least 4 arguments +MP_DEFINE_CONST_FUN_OBJ_KW(displayio_bitmap_blit_obj, 1, displayio_bitmap_obj_blit); //| def fill(self, value: int) -> None: //| """Fills the bitmap with the supplied palette index value.""" diff --git a/shared-bindings/displayio/ColorConverter.c b/shared-bindings/displayio/ColorConverter.c index 7c1e87efeb..2f40d8bd36 100644 --- a/shared-bindings/displayio/ColorConverter.c +++ b/shared-bindings/displayio/ColorConverter.c @@ -28,12 +28,11 @@ #include -#include "lib/utils/context_manager_helpers.h" +#include "shared/runtime/context_manager_helpers.h" #include "py/binary.h" #include "py/enum.h" #include "py/objproperty.h" #include "py/runtime.h" -#include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/util.h" #include "supervisor/shared/translate.h" @@ -48,7 +47,7 @@ //| ... //| -STATIC mp_obj_t displayio_colorconverter_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +STATIC mp_obj_t displayio_colorconverter_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_dither, ARG_input_colorspace }; static const mp_arg_t allowed_args[] = { @@ -56,7 +55,7 @@ STATIC mp_obj_t displayio_colorconverter_make_new(const mp_obj_type_t *type, siz { MP_QSTR_input_colorspace, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = (void *)&displayio_colorspace_RGB888_obj} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); displayio_colorconverter_t *self = m_new_obj(displayio_colorconverter_t); self->base.type = &displayio_colorconverter_type; diff --git a/shared-bindings/displayio/ColorConverter.h b/shared-bindings/displayio/ColorConverter.h index 018db92c96..12fa8da20f 100644 --- a/shared-bindings/displayio/ColorConverter.h +++ b/shared-bindings/displayio/ColorConverter.h @@ -36,6 +36,7 @@ extern const mp_obj_type_t displayio_colorconverter_type; void common_hal_displayio_colorconverter_construct(displayio_colorconverter_t *self, bool dither, displayio_colorspace_t input_colorspace); void common_hal_displayio_colorconverter_convert(displayio_colorconverter_t *colorconverter, const _displayio_colorspace_t *colorspace, uint32_t input_color, uint32_t *output_color); +uint32_t displayio_colorconverter_convert_pixel(displayio_colorspace_t colorspace, uint32_t pixel); void common_hal_displayio_colorconverter_set_dither(displayio_colorconverter_t *self, bool dither); bool common_hal_displayio_colorconverter_get_dither(displayio_colorconverter_t *self); diff --git a/shared-bindings/displayio/Colorspace.c b/shared-bindings/displayio/Colorspace.c new file mode 100644 index 0000000000..3692dc29bc --- /dev/null +++ b/shared-bindings/displayio/Colorspace.c @@ -0,0 +1,77 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Jeff Epler 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/enum.h" +#include "py/obj.h" +#include "py/runtime.h" + +#include "shared-bindings/displayio/__init__.h" + +MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, RGB888, DISPLAYIO_COLORSPACE_RGB888); +MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, RGB565, DISPLAYIO_COLORSPACE_RGB565); +MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, RGB565_SWAPPED, DISPLAYIO_COLORSPACE_RGB565_SWAPPED); +MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, RGB555, DISPLAYIO_COLORSPACE_RGB555); +MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, RGB555_SWAPPED, DISPLAYIO_COLORSPACE_RGB555_SWAPPED); +MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, BGR565, DISPLAYIO_COLORSPACE_BGR565); +MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, BGR565_SWAPPED, DISPLAYIO_COLORSPACE_BGR565_SWAPPED); +MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, BGR555, DISPLAYIO_COLORSPACE_BGR555); +MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, BGR555_SWAPPED, DISPLAYIO_COLORSPACE_BGR555_SWAPPED); +MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, L8, DISPLAYIO_COLORSPACE_L8); + +//| class Colorspace: +//| """The colorspace for a `ColorConverter` to operate in""" +//| +//| RGB888: Colorspace +//| """The standard 24-bit colorspace. Bits 0-7 are blue, 8-15 are green, and 16-24 are red. (0xRRGGBB)""" +//| +//| RGB565: Colorspace +//| """The standard 16-bit colorspace. Bits 0-4 are blue, bits 5-10 are green, and 11-15 are red (0bRRRRRGGGGGGBBBBB)""" +//| +//| RGB565_SWAPPED: Colorspace +//| """The swapped 16-bit colorspace. First, the high and low 8 bits of the number are swapped, then they are interpreted as for RGB565""" +//| +//| RGB555: Colorspace +//| """The standard 15-bit colorspace. Bits 0-4 are blue, bits 5-9 are green, and 11-14 are red. The top bit is ignored. (0bxRRRRRGGGGGBBBBB)""" +//| +//| RGB555_SWAPPED: Colorspace +//| """The swapped 15-bit colorspace. First, the high and low 8 bits of the number are swapped, then they are interpreted as for RGB555""" +//| +MAKE_ENUM_MAP(displayio_colorspace) { + MAKE_ENUM_MAP_ENTRY(displayio_colorspace, RGB888), + MAKE_ENUM_MAP_ENTRY(displayio_colorspace, RGB565), + MAKE_ENUM_MAP_ENTRY(displayio_colorspace, RGB565_SWAPPED), + MAKE_ENUM_MAP_ENTRY(displayio_colorspace, RGB555), + MAKE_ENUM_MAP_ENTRY(displayio_colorspace, RGB555_SWAPPED), + MAKE_ENUM_MAP_ENTRY(displayio_colorspace, BGR565), + MAKE_ENUM_MAP_ENTRY(displayio_colorspace, BGR565_SWAPPED), + MAKE_ENUM_MAP_ENTRY(displayio_colorspace, BGR555), + MAKE_ENUM_MAP_ENTRY(displayio_colorspace, BGR555_SWAPPED), + MAKE_ENUM_MAP_ENTRY(displayio_colorspace, L8), +}; +STATIC MP_DEFINE_CONST_DICT(displayio_colorspace_locals_dict, displayio_colorspace_locals_table); + +MAKE_PRINTER(displayio, displayio_colorspace); +MAKE_ENUM_TYPE(displayio, ColorSpace, displayio_colorspace); diff --git a/shared-bindings/displayio/Display.c b/shared-bindings/displayio/Display.c index 9796c1c4d7..ca98f9339c 100644 --- a/shared-bindings/displayio/Display.c +++ b/shared-bindings/displayio/Display.c @@ -28,7 +28,7 @@ #include -#include "lib/utils/context_manager_helpers.h" +#include "shared/runtime/context_manager_helpers.h" #include "py/binary.h" #include "py/objproperty.h" #include "py/objtype.h" @@ -115,7 +115,7 @@ //| ... //| STATIC mp_obj_t displayio_display_make_new(const mp_obj_type_t *type, size_t n_args, - const mp_obj_t *pos_args, mp_map_t *kw_args) { + size_t n_kw, const mp_obj_t *all_args) { enum { ARG_display_bus, ARG_init_sequence, ARG_width, ARG_height, ARG_colstart, ARG_rowstart, ARG_rotation, ARG_color_depth, ARG_grayscale, ARG_pixels_in_byte_share_row, ARG_bytes_per_cell, ARG_reverse_pixels_in_byte, ARG_reverse_bytes_in_word, @@ -154,7 +154,7 @@ STATIC mp_obj_t displayio_display_make_new(const mp_obj_type_t *type, size_t n_a { MP_QSTR_SH1107_addressing, MP_ARG_BOOL | MP_ARG_KW_ONLY, {.u_bool = false} } }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); mp_obj_t display_bus = args[ARG_display_bus].u_obj; diff --git a/shared-bindings/displayio/EPaperDisplay.c b/shared-bindings/displayio/EPaperDisplay.c index afe1321251..06245c90ae 100644 --- a/shared-bindings/displayio/EPaperDisplay.c +++ b/shared-bindings/displayio/EPaperDisplay.c @@ -28,7 +28,7 @@ #include -#include "lib/utils/context_manager_helpers.h" +#include "shared/runtime/context_manager_helpers.h" #include "py/binary.h" #include "py/objproperty.h" #include "py/objtype.h" @@ -103,7 +103,7 @@ //| :param bool grayscale: When true, the color ram is the low bit of 2-bit grayscale""" //| ... //| -STATIC mp_obj_t displayio_epaperdisplay_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +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) { enum { ARG_display_bus, ARG_start_sequence, ARG_stop_sequence, ARG_width, ARG_height, ARG_ram_width, ARG_ram_height, ARG_colstart, ARG_rowstart, ARG_rotation, ARG_set_column_window_command, ARG_set_row_window_command, ARG_set_current_column_command, @@ -140,7 +140,7 @@ STATIC mp_obj_t displayio_epaperdisplay_make_new(const mp_obj_type_t *type, size { MP_QSTR_grayscale, MP_ARG_BOOL | MP_ARG_KW_ONLY, {.u_bool = false} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); mp_obj_t display_bus = args[ARG_display_bus].u_obj; @@ -240,7 +240,7 @@ STATIC mp_obj_t displayio_epaperdisplay_update_refresh_mode(size_t n_args, const displayio_epaperdisplay_change_refresh_mode_parameters(self, &start_sequence, seconds_per_frame); return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_KW(displayio_epaperdisplay_update_refresh_mode_obj, 3, displayio_epaperdisplay_update_refresh_mode); +MP_DEFINE_CONST_FUN_OBJ_KW(displayio_epaperdisplay_update_refresh_mode_obj, 1, displayio_epaperdisplay_update_refresh_mode); //| def refresh(self) -> None: //| """Refreshes the display immediately or raises an exception if too soon. Use diff --git a/shared-bindings/displayio/FourWire.c b/shared-bindings/displayio/FourWire.c index 2145425342..801b988a8a 100644 --- a/shared-bindings/displayio/FourWire.c +++ b/shared-bindings/displayio/FourWire.c @@ -28,10 +28,11 @@ #include -#include "lib/utils/context_manager_helpers.h" +#include "shared/runtime/context_manager_helpers.h" #include "py/binary.h" #include "py/objproperty.h" #include "py/runtime.h" +#include "shared-bindings/busio/SPI.h" #include "shared-bindings/displayio/Group.h" #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/util.h" @@ -60,7 +61,7 @@ //| or second (1). Rising or falling depends on clock polarity.""" //| ... //| -STATIC mp_obj_t displayio_fourwire_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +STATIC mp_obj_t displayio_fourwire_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_spi_bus, ARG_command, ARG_chip_select, ARG_reset, ARG_baudrate, ARG_polarity, ARG_phase }; static const mp_arg_t allowed_args[] = { { MP_QSTR_spi_bus, MP_ARG_REQUIRED | MP_ARG_OBJ }, @@ -72,13 +73,14 @@ STATIC mp_obj_t displayio_fourwire_make_new(const mp_obj_type_t *type, size_t n_ { MP_QSTR_phase, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); mcu_pin_obj_t *command = validate_obj_is_free_pin(args[ARG_command].u_obj); mcu_pin_obj_t *chip_select = validate_obj_is_free_pin(args[ARG_chip_select].u_obj); mcu_pin_obj_t *reset = validate_obj_is_free_pin_or_none(args[ARG_reset].u_obj); - mp_obj_t spi = args[ARG_spi_bus].u_obj; + mp_obj_t spi = mp_arg_validate_type(args[ARG_spi_bus].u_obj, &busio_spi_type, MP_QSTR_spi_bus); + displayio_fourwire_obj_t *self = &allocate_display_bus_or_raise()->fourwire_bus; self->base.type = &displayio_fourwire_type; @@ -149,7 +151,7 @@ STATIC mp_obj_t displayio_fourwire_obj_send(size_t n_args, const mp_obj_t *pos_a return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_KW(displayio_fourwire_send_obj, 3, displayio_fourwire_obj_send); +MP_DEFINE_CONST_FUN_OBJ_KW(displayio_fourwire_send_obj, 1, displayio_fourwire_obj_send); STATIC const mp_rom_map_elem_t displayio_fourwire_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_reset), MP_ROM_PTR(&displayio_fourwire_reset_obj) }, diff --git a/shared-bindings/displayio/Group.c b/shared-bindings/displayio/Group.c index b706b627c4..33329e5ece 100644 --- a/shared-bindings/displayio/Group.c +++ b/shared-bindings/displayio/Group.c @@ -28,7 +28,7 @@ #include -#include "lib/utils/context_manager_helpers.h" +#include "shared/runtime/context_manager_helpers.h" #include "py/binary.h" #include "py/objproperty.h" #include "py/objtype.h" @@ -47,7 +47,7 @@ //| :param int y: Initial y position within the parent.""" //| ... //| -STATIC mp_obj_t displayio_group_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +STATIC mp_obj_t displayio_group_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_scale, ARG_x, ARG_y }; static const mp_arg_t allowed_args[] = { { MP_QSTR_scale, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 1} }, @@ -55,7 +55,7 @@ STATIC mp_obj_t displayio_group_make_new(const mp_obj_type_t *type, size_t n_arg { MP_QSTR_y, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 0} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); mp_int_t scale = args[ARG_scale].u_int; if (scale < 1) { diff --git a/shared-bindings/displayio/I2CDisplay.c b/shared-bindings/displayio/I2CDisplay.c index d304374664..d87b5f8bb0 100644 --- a/shared-bindings/displayio/I2CDisplay.c +++ b/shared-bindings/displayio/I2CDisplay.c @@ -29,11 +29,12 @@ #include #include -#include "lib/utils/context_manager_helpers.h" +#include "shared/runtime/context_manager_helpers.h" #include "py/binary.h" #include "py/objproperty.h" #include "py/runtime.h" #include "shared-bindings/microcontroller/Pin.h" +#include "shared-bindings/busio/I2C.h" #include "shared-bindings/util.h" #include "shared-module/displayio/__init__.h" #include "supervisor/shared/translate.h" @@ -55,7 +56,7 @@ //| :param microcontroller.Pin reset: Reset pin. When None only software reset can be used""" //| ... //| -STATIC mp_obj_t displayio_i2cdisplay_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +STATIC mp_obj_t displayio_i2cdisplay_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_i2c_bus, ARG_device_address, ARG_reset }; static const mp_arg_t allowed_args[] = { { MP_QSTR_i2c_bus, MP_ARG_REQUIRED | MP_ARG_OBJ }, @@ -63,11 +64,11 @@ STATIC mp_obj_t displayio_i2cdisplay_make_new(const mp_obj_type_t *type, size_t { MP_QSTR_reset, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = mp_const_none} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); mcu_pin_obj_t *reset = validate_obj_is_free_pin_or_none(args[ARG_reset].u_obj); - mp_obj_t i2c = args[ARG_i2c_bus].u_obj; + mp_obj_t i2c = mp_arg_validate_type(args[ARG_i2c_bus].u_obj, &busio_i2c_type, MP_QSTR_i2c_bus); displayio_i2cdisplay_obj_t *self = &allocate_display_bus_or_raise()->i2cdisplay_bus; self->base.type = &displayio_i2cdisplay_type; diff --git a/shared-bindings/displayio/OnDiskBitmap.c b/shared-bindings/displayio/OnDiskBitmap.c index 32249a3ddf..b68fbef992 100644 --- a/shared-bindings/displayio/OnDiskBitmap.c +++ b/shared-bindings/displayio/OnDiskBitmap.c @@ -80,9 +80,9 @@ //| """ //| ... //| -STATIC mp_obj_t displayio_ondiskbitmap_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { - mp_arg_check_num(n_args, kw_args, 1, 1, false); - mp_obj_t arg = pos_args[0]; +STATIC mp_obj_t displayio_ondiskbitmap_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { + mp_arg_check_num(n_args, n_kw, 1, 1, false); + mp_obj_t arg = all_args[0]; if (mp_obj_is_str(arg)) { arg = mp_call_function_2(MP_OBJ_FROM_PTR(&mp_builtin_open_obj), arg, MP_ROM_QSTR(MP_QSTR_rb)); diff --git a/shared-bindings/displayio/Palette.c b/shared-bindings/displayio/Palette.c index 1834341daf..ad6d7c319a 100644 --- a/shared-bindings/displayio/Palette.c +++ b/shared-bindings/displayio/Palette.c @@ -28,7 +28,7 @@ #include -#include "lib/utils/context_manager_helpers.h" +#include "shared/runtime/context_manager_helpers.h" #include "py/binary.h" #include "py/objproperty.h" #include "py/runtime.h" @@ -49,13 +49,13 @@ // TODO(tannewt): Add support for other color formats. // TODO(tannewt): Add support for 8-bit alpha blending. //| -STATIC mp_obj_t displayio_palette_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +STATIC mp_obj_t displayio_palette_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_color_count }; static const mp_arg_t allowed_args[] = { { MP_QSTR_color_count, MP_ARG_REQUIRED | MP_ARG_INT }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); displayio_palette_t *self = m_new_obj(displayio_palette_t); self->base.type = &displayio_palette_type; @@ -122,7 +122,7 @@ STATIC mp_obj_t palette_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t val // Convert a tuple or list to a bytearray. if (mp_obj_is_type(value, &mp_type_tuple) || mp_obj_is_type(value, &mp_type_list)) { - value = mp_type_bytes.make_new(&mp_type_bytes, 1, &value, NULL); + value = mp_type_bytes.make_new(&mp_type_bytes, 1, 0, &value); } uint32_t color; diff --git a/shared-bindings/displayio/Shape.c b/shared-bindings/displayio/Shape.c index 0126df8858..f39e7820a9 100644 --- a/shared-bindings/displayio/Shape.c +++ b/shared-bindings/displayio/Shape.c @@ -47,7 +47,7 @@ //| :param bool mirror_y: When true the top boundary is mirrored to the bottom.""" //| ... //| -STATIC mp_obj_t displayio_shape_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +STATIC mp_obj_t displayio_shape_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_mirror_x, ARG_mirror_y }; static const mp_arg_t allowed_args[] = { { MP_QSTR_width, MP_ARG_REQUIRED | MP_ARG_INT }, @@ -56,7 +56,7 @@ STATIC mp_obj_t displayio_shape_make_new(const mp_obj_type_t *type, size_t n_arg { MP_QSTR_mirror_y, MP_ARG_BOOL | MP_ARG_KW_ONLY, {.u_bool = false} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); mp_int_t width = args[ARG_width].u_int; if (width < 1) { diff --git a/shared-bindings/displayio/TileGrid.c b/shared-bindings/displayio/TileGrid.c index 1c6e6efda3..f031842e3b 100644 --- a/shared-bindings/displayio/TileGrid.c +++ b/shared-bindings/displayio/TileGrid.c @@ -28,7 +28,7 @@ #include -#include "lib/utils/context_manager_helpers.h" +#include "shared/runtime/context_manager_helpers.h" #include "py/binary.h" #include "py/objproperty.h" #include "py/objtype.h" @@ -65,7 +65,7 @@ //| :param int x: Initial x position of the left edge within the parent. //| :param int y: Initial y position of the top edge within the parent.""" //| -STATIC mp_obj_t displayio_tilegrid_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +STATIC mp_obj_t displayio_tilegrid_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_bitmap, ARG_pixel_shader, ARG_width, ARG_height, ARG_tile_width, ARG_tile_height, ARG_default_tile, ARG_x, ARG_y }; static const mp_arg_t allowed_args[] = { { MP_QSTR_bitmap, MP_ARG_REQUIRED | MP_ARG_OBJ }, @@ -79,7 +79,7 @@ STATIC mp_obj_t displayio_tilegrid_make_new(const mp_obj_type_t *type, size_t n_ { MP_QSTR_y, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 0} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); mp_obj_t bitmap = args[ARG_bitmap].u_obj; diff --git a/shared-bindings/displayio/__init__.c b/shared-bindings/displayio/__init__.c index 7ac2a84903..5588dc83e9 100644 --- a/shared-bindings/displayio/__init__.c +++ b/shared-bindings/displayio/__init__.c @@ -69,50 +69,6 @@ STATIC mp_obj_t displayio_release_displays(void) { } MP_DEFINE_CONST_FUN_OBJ_0(displayio_release_displays_obj, displayio_release_displays); -MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, RGB888, DISPLAYIO_COLORSPACE_RGB888); -MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, RGB565, DISPLAYIO_COLORSPACE_RGB565); -MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, RGB565_SWAPPED, DISPLAYIO_COLORSPACE_RGB565_SWAPPED); -MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, RGB555, DISPLAYIO_COLORSPACE_RGB555); -MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, RGB555_SWAPPED, DISPLAYIO_COLORSPACE_RGB555_SWAPPED); -MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, BGR565, DISPLAYIO_COLORSPACE_BGR565); -MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, BGR565_SWAPPED, DISPLAYIO_COLORSPACE_BGR565_SWAPPED); -MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, BGR555, DISPLAYIO_COLORSPACE_BGR555); -MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, BGR555_SWAPPED, DISPLAYIO_COLORSPACE_BGR555_SWAPPED); - -//| class Colorspace: -//| """The colorspace for a `ColorConverter` to operate in""" -//| -//| RGB888: Colorspace -//| """The standard 24-bit colorspace. Bits 0-7 are blue, 8-15 are green, and 16-24 are red. (0xRRGGBB)""" -//| -//| RGB565: Colorspace -//| """The standard 16-bit colorspace. Bits 0-4 are blue, bits 5-10 are green, and 11-15 are red (0bRRRRRGGGGGGBBBBB)""" -//| -//| RGB565_SWAPPED: Colorspace -//| """The swapped 16-bit colorspace. First, the high and low 8 bits of the number are swapped, then they are interpreted as for RGB565""" -//| -//| RGB555: Colorspace -//| """The standard 15-bit colorspace. Bits 0-4 are blue, bits 5-9 are green, and 11-14 are red. The top bit is ignored. (0bxRRRRRGGGGGBBBBB)""" -//| -//| RGB555_SWAPPED: Colorspace -//| """The swapped 15-bit colorspace. First, the high and low 8 bits of the number are swapped, then they are interpreted as for RGB555""" -//| -MAKE_ENUM_MAP(displayio_colorspace) { - MAKE_ENUM_MAP_ENTRY(displayio_colorspace, RGB888), - MAKE_ENUM_MAP_ENTRY(displayio_colorspace, RGB565), - MAKE_ENUM_MAP_ENTRY(displayio_colorspace, RGB565_SWAPPED), - MAKE_ENUM_MAP_ENTRY(displayio_colorspace, RGB555), - MAKE_ENUM_MAP_ENTRY(displayio_colorspace, RGB555_SWAPPED), - MAKE_ENUM_MAP_ENTRY(displayio_colorspace, BGR565), - MAKE_ENUM_MAP_ENTRY(displayio_colorspace, BGR565_SWAPPED), - MAKE_ENUM_MAP_ENTRY(displayio_colorspace, BGR555), - MAKE_ENUM_MAP_ENTRY(displayio_colorspace, BGR555_SWAPPED), -}; -STATIC MP_DEFINE_CONST_DICT(displayio_colorspace_locals_dict, displayio_colorspace_locals_table); - -MAKE_PRINTER(displayio, displayio_colorspace); -MAKE_ENUM_TYPE(displayio, ColorSpace, displayio_colorspace); - STATIC const mp_rom_map_elem_t displayio_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_displayio) }, @@ -135,7 +91,6 @@ STATIC const mp_rom_map_elem_t displayio_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_release_displays), MP_ROM_PTR(&displayio_release_displays_obj) }, }; - STATIC MP_DEFINE_CONST_DICT(displayio_module_globals, displayio_module_globals_table); const mp_obj_module_t displayio_module = { diff --git a/shared-bindings/displayio/__init__.h b/shared-bindings/displayio/__init__.h index 938fcf3d98..b297e4d755 100644 --- a/shared-bindings/displayio/__init__.h +++ b/shared-bindings/displayio/__init__.h @@ -40,7 +40,7 @@ typedef enum { CHIP_SELECT_TOGGLE_EVERY_BYTE } display_chip_select_behavior_t; -typedef enum { +typedef enum displayio_colorspace { DISPLAYIO_COLORSPACE_RGB888, DISPLAYIO_COLORSPACE_RGB565, DISPLAYIO_COLORSPACE_RGB555, @@ -50,6 +50,7 @@ typedef enum { DISPLAYIO_COLORSPACE_BGR555, DISPLAYIO_COLORSPACE_BGR565_SWAPPED, DISPLAYIO_COLORSPACE_BGR555_SWAPPED, + DISPLAYIO_COLORSPACE_L8, } displayio_colorspace_t; typedef bool (*display_bus_bus_reset)(mp_obj_t bus); diff --git a/shared-bindings/fontio/BuiltinFont.c b/shared-bindings/fontio/BuiltinFont.c index e8b66c5e5c..171a50dab3 100644 --- a/shared-bindings/fontio/BuiltinFont.c +++ b/shared-bindings/fontio/BuiltinFont.c @@ -28,7 +28,7 @@ #include -#include "lib/utils/context_manager_helpers.h" +#include "shared/runtime/context_manager_helpers.h" #include "py/binary.h" #include "py/objproperty.h" #include "py/runtime.h" diff --git a/shared-bindings/framebufferio/FramebufferDisplay.c b/shared-bindings/framebufferio/FramebufferDisplay.c index 9ffb25ba6e..683e512b3e 100644 --- a/shared-bindings/framebufferio/FramebufferDisplay.c +++ b/shared-bindings/framebufferio/FramebufferDisplay.c @@ -29,7 +29,7 @@ #include -#include "lib/utils/context_manager_helpers.h" +#include "shared/runtime/context_manager_helpers.h" #include "py/binary.h" #include "py/objproperty.h" #include "py/objtype.h" @@ -55,7 +55,7 @@ //| :param int rotation: The rotation of the display in degrees clockwise. Must be in 90 degree increments (0, 90, 180, 270)""" //| ... //| -STATIC mp_obj_t framebufferio_framebufferdisplay_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +STATIC mp_obj_t framebufferio_framebufferdisplay_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_framebuffer, ARG_rotation, ARG_auto_refresh, NUM_ARGS }; static const mp_arg_t allowed_args[] = { { MP_QSTR_framebuffer, MP_ARG_REQUIRED | MP_ARG_OBJ }, @@ -64,7 +64,7 @@ STATIC mp_obj_t framebufferio_framebufferdisplay_make_new(const mp_obj_type_t *t }; MP_STATIC_ASSERT(MP_ARRAY_SIZE(allowed_args) == NUM_ARGS); mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); mp_obj_t framebuffer = args[ARG_framebuffer].u_obj; diff --git a/shared-bindings/frequencyio/FrequencyIn.c b/shared-bindings/frequencyio/FrequencyIn.c index 43c1738da8..f8ab1b955e 100644 --- a/shared-bindings/frequencyio/FrequencyIn.c +++ b/shared-bindings/frequencyio/FrequencyIn.c @@ -26,7 +26,7 @@ #include -#include "lib/utils/context_manager_helpers.h" +#include "shared/runtime/context_manager_helpers.h" #include "py/objproperty.h" #include "py/runtime.h" #include "py/runtime0.h" @@ -71,9 +71,8 @@ //| frequency.clear()""" //| ... //| -STATIC mp_obj_t frequencyio_frequencyin_make_new(const mp_obj_type_t *type, size_t n_args, - const mp_obj_t *pos_args, mp_map_t *kw_args) { - mp_arg_check_num(n_args, kw_args, 1, 1, true); +STATIC mp_obj_t frequencyio_frequencyin_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { + mp_arg_check_num(n_args, n_kw, 1, 1, true); frequencyio_frequencyin_obj_t *self = m_new_obj(frequencyio_frequencyin_obj_t); self->base.type = &frequencyio_frequencyin_type; @@ -83,7 +82,7 @@ STATIC mp_obj_t frequencyio_frequencyin_make_new(const mp_obj_type_t *type, size { MP_QSTR_capture_period, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 10} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); mcu_pin_obj_t *pin = validate_obj_is_free_pin(args[ARG_pin].u_obj); diff --git a/shared-bindings/frequencyio/__init__.c b/shared-bindings/frequencyio/__init__.c index 02f19de65d..ffbb7af771 100644 --- a/shared-bindings/frequencyio/__init__.c +++ b/shared-bindings/frequencyio/__init__.c @@ -46,11 +46,11 @@ //| //| For example:: //| -//| import frequencyio //| import time -//| from board import * +//| import frequencyio +//| import board //| -//| frequency = frequencyio.FrequencyIn(D13) +//| frequency = frequencyio.FrequencyIn(board.D11) //| frequency.capture_period = 15 //| time.sleep(0.1) //| diff --git a/shared-bindings/gamepadshift/GamePadShift.c b/shared-bindings/gamepadshift/GamePadShift.c index a232683c96..1c43eeac7b 100644 --- a/shared-bindings/gamepadshift/GamePadShift.c +++ b/shared-bindings/gamepadshift/GamePadShift.c @@ -50,7 +50,7 @@ //| ... //| STATIC mp_obj_t gamepadshift_make_new(const mp_obj_type_t *type, size_t n_args, - const mp_obj_t *pos_args, mp_map_t *kw_args) { + size_t n_kw, const mp_obj_t *all_args) { enum { ARG_clock, ARG_data, ARG_latch }; static const mp_arg_t allowed_args[] = { @@ -59,7 +59,7 @@ STATIC mp_obj_t gamepadshift_make_new(const mp_obj_type_t *type, size_t n_args, { MP_QSTR_latch, MP_ARG_REQUIRED | MP_ARG_OBJ}, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args, pos_args, kw_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); digitalio_digitalinout_obj_t *clock_pin = assert_digitalinout(args[ARG_clock].u_obj); diff --git a/shared-bindings/gifio/GifWriter.c b/shared-bindings/gifio/GifWriter.c new file mode 100644 index 0000000000..11dd43becd --- /dev/null +++ b/shared-bindings/gifio/GifWriter.c @@ -0,0 +1,161 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Jeff Epler 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" +#if MICROPY_VFS +#include "extmod/vfs.h" +#endif +#include "py/runtime.h" +#include "shared-bindings/gifio/GifWriter.h" +#include "shared-module/gifio/GifWriter.h" +#include "shared/runtime/context_manager_helpers.h" + +//| class GifWriter: +//| def __init__(self, file: Union[typing.BinaryIO, str], width:int, height:int, colorspace: displayio.Colorspace, loop:bool=True, dither:bool=False) -> None: +//| """Construct a GifWriter object +//| +//| :param file: Either a file open in bytes mode, or the name of a file to open in bytes mode. +//| :param width: The width of the image. All frames must have the same width. +//| :param height: The height of the image. All frames must have the same height. +//| :param colorspace: The colorspace of the image. All frames must have the same colorspace. The supported colorspaces are ``RGB565``, ``BGR565``, ``RGB565_SWAPPED``, ``BGR565_SWAPPED``, and ``L8`` (greyscale) +//| :param loop: If True, the GIF is marked for looping playback +//| :param dither: If True, and the image is in color, a simple ordered dither is applied. +//| """ +//| ... +//| +static mp_obj_t gifio_gifwriter_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { + enum { ARG_file, ARG_width, ARG_height, ARG_colorspace, ARG_loop, ARG_dither }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_file, MP_ARG_OBJ | MP_ARG_REQUIRED, {.u_obj = NULL} }, + { MP_QSTR_width, MP_ARG_INT | MP_ARG_REQUIRED, {.u_int = 0} }, + { MP_QSTR_height, MP_ARG_INT | MP_ARG_REQUIRED, {.u_int = 0} }, + { MP_QSTR_colorspace, MP_ARG_OBJ | MP_ARG_REQUIRED, {.u_obj = NULL} }, + { MP_QSTR_loop, MP_ARG_BOOL, { .u_bool = true } }, + { MP_QSTR_dither, MP_ARG_BOOL, { .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 file = args[ARG_file].u_obj; + bool own_file = false; + if (mp_obj_is_str(file)) { + file = mp_call_function_2(MP_OBJ_FROM_PTR(&mp_builtin_open_obj), file, MP_OBJ_NEW_QSTR(MP_QSTR_wb)); + own_file = true; + } + + gifio_gifwriter_t *self = m_new_obj(gifio_gifwriter_t); + self->base.type = &gifio_gifwriter_type; + shared_module_gifio_gifwriter_construct( + self, + file, + args[ARG_width].u_int, + args[ARG_height].u_int, + (displayio_colorspace_t)cp_enum_value(&displayio_colorspace_type, args[ARG_colorspace].u_obj), + args[ARG_loop].u_bool, + args[ARG_dither].u_bool, + own_file); + + return self; +} + + +//| def __enter__(self) -> GifWriter: +//| """No-op used by Context Managers.""" +//| ... +// Provided by context manager helper. + +//| def __exit__(self) -> None: +//| """Automatically deinitializes the hardware when exiting a context. See +//| :ref:`lifetime-and-contextmanagers` for more info.""" +//| ... +//| +static mp_obj_t gifio_gifwriter___exit__(size_t n_args, const mp_obj_t *args) { + gifio_gifwriter_t *self = MP_OBJ_TO_PTR(args[0]); + shared_module_gifio_gifwriter_deinit(self); + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(gifio_gifwriter___exit___obj, 4, 4, gifio_gifwriter___exit__); + +//| def deinit(self) -> None: +//| """Close the underlying file.""" +//| ... +//| +static mp_obj_t gifio_gifwriter_deinit(mp_obj_t self_in) { + gifio_gifwriter_t *self = MP_OBJ_TO_PTR(self_in); + shared_module_gifio_gifwriter_deinit(self); + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_1(gifio_gifwriter_deinit_obj, gifio_gifwriter_deinit); + +//| def add_frame(self, bitmap: ReadableBuffer, delay: float = 0.1) -> None: +//| """Add a frame to the GIF. +//| +//| :param bitmap: The frame data +//| :param delay: The frame delay in seconds. The GIF format rounds this to the nearest 1/100 second, and the largest permitted value is 655 seconds. +//| """ +//| ... +static mp_obj_t gifio_gifwriter_add_frame(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + enum { ARG_bitmap, ARG_delay }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_bitmap, MP_ARG_OBJ | MP_ARG_REQUIRED, {.u_obj = NULL} }, + { MP_QSTR_delay, MP_ARG_OBJ, {.u_obj = NULL} }, + }; + 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); + + gifio_gifwriter_t *self = MP_OBJ_TO_PTR(pos_args[0]); + shared_module_gifio_gifwriter_check_for_deinit(self); + + + mp_float_t delay = mp_arg_validate_obj_float_non_negative(args[ARG_delay].u_obj, MICROPY_FLOAT_CONST(0.1), MP_QSTR_delay); + if (delay > MICROPY_FLOAT_CONST(655.)) { + mp_raise_ValueError_varg(translate("%q must be <= %d"), MP_QSTR_delay, 655); + } + + int delay_centiseconds = (int)(delay * 100); + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(args[ARG_bitmap].u_obj, &bufinfo, MP_BUFFER_READ); + shared_module_gifio_gifwriter_add_frame(self, &bufinfo, delay_centiseconds); + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_KW(gifio_gifwriter_add_frame_obj, 1, gifio_gifwriter_add_frame); + +STATIC const mp_rom_map_elem_t gifio_gifwriter_locals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_GifWriter) }, + { MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&default___enter___obj) }, + { MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&gifio_gifwriter___exit___obj) }, + { MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&gifio_gifwriter_deinit_obj) }, + { MP_ROM_QSTR(MP_QSTR_add_frame), MP_ROM_PTR(&gifio_gifwriter_add_frame_obj) }, +}; + +STATIC MP_DEFINE_CONST_DICT(gifio_gifwriter_locals, gifio_gifwriter_locals_table); + +const mp_obj_type_t gifio_gifwriter_type = { + { &mp_type_type }, + .name = MP_QSTR_GifWriter, + .make_new = gifio_gifwriter_make_new, + .locals_dict = (mp_obj_dict_t *)&gifio_gifwriter_locals, +}; diff --git a/shared-bindings/gifio/GifWriter.h b/shared-bindings/gifio/GifWriter.h new file mode 100644 index 0000000000..601bd78679 --- /dev/null +++ b/shared-bindings/gifio/GifWriter.h @@ -0,0 +1,41 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Jeff Epler 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" + +#pragma once + +typedef struct gifio_gifwriter gifio_gifwriter_t; +typedef enum displayio_colorspace displayio_colorspace_t; + +extern const mp_obj_type_t gifio_gifwriter_type; + +void shared_module_gifio_gifwriter_construct(gifio_gifwriter_t *self, mp_obj_t *file, int width, int height, displayio_colorspace_t colorspace, bool loop, bool dither, bool own_file); +void shared_module_gifio_gifwriter_check_for_deinit(gifio_gifwriter_t *self); +bool shared_module_gifio_gifwriter_deinited(gifio_gifwriter_t *self); +void shared_module_gifio_gifwriter_deinit(gifio_gifwriter_t *self); +void shared_module_gifio_gifwriter_add_frame(gifio_gifwriter_t *self, const mp_buffer_info_t *buf, int16_t delay); +void shared_module_gifio_gifwriter_close(gifio_gifwriter_t *self); diff --git a/shared-bindings/gifio/__init__.c b/shared-bindings/gifio/__init__.c new file mode 100644 index 0000000000..317eebce9b --- /dev/null +++ b/shared-bindings/gifio/__init__.c @@ -0,0 +1,47 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Jeff Epler 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/runtime.h" +#include "py/mphal.h" +#include "shared-bindings/gifio/GifWriter.h" +#include "shared-bindings/util.h" + +//| """Access GIF-format images +//| """ +//| +STATIC const mp_rom_map_elem_t gifio_module_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_gifio) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_GifWriter), MP_ROM_PTR(&gifio_gifwriter_type)}, +}; + +STATIC MP_DEFINE_CONST_DICT(gifio_module_globals, gifio_module_globals_table); + +const mp_obj_module_t gifio_module = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t *)&gifio_module_globals, +}; + +MP_REGISTER_MODULE(MP_QSTR_gifio, gifio_module, CIRCUITPY_GIFIO); diff --git a/shared-bindings/gifio/__init__.h b/shared-bindings/gifio/__init__.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/shared-bindings/gnss/GNSS.c b/shared-bindings/gnss/GNSS.c index cd4b097bcf..e304f0a0a2 100644 --- a/shared-bindings/gnss/GNSS.c +++ b/shared-bindings/gnss/GNSS.c @@ -37,7 +37,7 @@ //| :param system: satellite system to use""" //| ... //| -STATIC mp_obj_t gnss_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +STATIC mp_obj_t gnss_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { gnss_obj_t *self = m_new_obj(gnss_obj_t); self->base.type = &gnss_type; enum { ARG_system }; @@ -45,7 +45,7 @@ STATIC mp_obj_t gnss_make_new(const mp_obj_type_t *type, size_t n_args, const mp { MP_QSTR_system, MP_ARG_REQUIRED | MP_ARG_OBJ }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); unsigned long selection = 0; if (mp_obj_is_type(args[ARG_system].u_obj, &gnss_satellitesystem_type)) { diff --git a/shared-bindings/gnss/GNSS.h b/shared-bindings/gnss/GNSS.h index 60069a90a9..dca640b690 100644 --- a/shared-bindings/gnss/GNSS.h +++ b/shared-bindings/gnss/GNSS.h @@ -9,7 +9,7 @@ #include "shared-bindings/gnss/SatelliteSystem.h" #include "shared-bindings/gnss/PositionFix.h" -#include "lib/timeutils/timeutils.h" +#include "shared/timeutils/timeutils.h" extern const mp_obj_type_t gnss_type; diff --git a/shared-bindings/i2cperipheral/I2CPeripheral.c b/shared-bindings/i2cperipheral/I2CPeripheral.c index ac136d7e18..f697646146 100644 --- a/shared-bindings/i2cperipheral/I2CPeripheral.c +++ b/shared-bindings/i2cperipheral/I2CPeripheral.c @@ -29,9 +29,9 @@ #include "shared-bindings/time/__init__.h" #include "shared-bindings/util.h" -#include "lib/utils/buffer_helper.h" -#include "lib/utils/context_manager_helpers.h" -#include "lib/utils/interrupt_char.h" +#include "shared/runtime/buffer_helper.h" +#include "shared/runtime/context_manager_helpers.h" +#include "shared/runtime/interrupt_char.h" #include "py/mperrno.h" #include "py/mphal.h" @@ -63,7 +63,7 @@ STATIC mp_obj_t mp_obj_new_i2cperipheral_i2c_peripheral_request(i2cperipheral_i2 //| :param bool smbus: Use SMBUS timings if the hardware supports it""" //| ... //| -STATIC mp_obj_t i2cperipheral_i2c_peripheral_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +STATIC mp_obj_t i2cperipheral_i2c_peripheral_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { i2cperipheral_i2c_peripheral_obj_t *self = m_new_obj(i2cperipheral_i2c_peripheral_obj_t); self->base.type = &i2cperipheral_i2c_peripheral_type; enum { ARG_scl, ARG_sda, ARG_addresses, ARG_smbus }; @@ -74,7 +74,7 @@ STATIC mp_obj_t i2cperipheral_i2c_peripheral_make_new(const mp_obj_type_t *type, { MP_QSTR_smbus, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = false} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, 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 *scl = validate_obj_is_free_pin(args[ARG_scl].u_obj); const mcu_pin_obj_t *sda = validate_obj_is_free_pin(args[ARG_sda].u_obj); @@ -237,8 +237,8 @@ const mp_obj_type_t i2cperipheral_i2c_peripheral_type = { //| :param is_read: True if the main peripheral is requesting data //| :param is_restart: Repeated Start Condition""" //| -STATIC mp_obj_t i2cperipheral_i2c_peripheral_request_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { - mp_arg_check_num(n_args, kw_args, 4, 4, false); +STATIC mp_obj_t i2cperipheral_i2c_peripheral_request_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { + mp_arg_check_num(n_args, n_kw, 4, 4, false); return mp_obj_new_i2cperipheral_i2c_peripheral_request(args[0], mp_obj_get_int(args[1]), mp_obj_is_true(args[2]), mp_obj_is_true(args[3])); } diff --git a/shared-bindings/imagecapture/ParallelImageCapture.c b/shared-bindings/imagecapture/ParallelImageCapture.c index 59a6f256e6..a98c72e208 100644 --- a/shared-bindings/imagecapture/ParallelImageCapture.c +++ b/shared-bindings/imagecapture/ParallelImageCapture.c @@ -25,9 +25,10 @@ */ #include "py/obj.h" +#include "py/objproperty.h" #include "py/runtime.h" -#include "lib/utils/context_manager_helpers.h" +#include "shared/runtime/context_manager_helpers.h" #include "shared-bindings/imagecapture/ParallelImageCapture.h" #include "shared-bindings/microcontroller/Pin.h" @@ -53,7 +54,7 @@ //| """ //| ... //| -STATIC mp_obj_t imagecapture_parallelimagecapture_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +STATIC mp_obj_t imagecapture_parallelimagecapture_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_data_pins, ARG_clock, ARG_vsync, ARG_href, NUM_ARGS }; static const mp_arg_t allowed_args[] = { @@ -64,7 +65,7 @@ STATIC mp_obj_t imagecapture_parallelimagecapture_make_new(const mp_obj_type_t * }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; MP_STATIC_ASSERT(MP_ARRAY_SIZE(allowed_args) == NUM_ARGS); - mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); uint8_t pins[32]; uint8_t pin_count; @@ -82,19 +83,69 @@ STATIC mp_obj_t imagecapture_parallelimagecapture_make_new(const mp_obj_type_t * return self; } -//| def capture(self, buffer: WriteableBuffer, width: int, height: int, bpp: int=16) -> None: -//| """Capture a single frame into the given buffer""" +//| def capture(self, buffer: WriteableBuffer) -> WriteableBuffer: +//| """Capture a single frame into the given buffer. +//| +//| This will stop a continuous-mode capture, if one is in progress.""" //| ... //| STATIC mp_obj_t imagecapture_parallelimagecapture_capture(mp_obj_t self_in, mp_obj_t buffer) { imagecapture_parallelimagecapture_obj_t *self = (imagecapture_parallelimagecapture_obj_t *)self_in; - mp_buffer_info_t bufinfo; - mp_get_buffer_raise(buffer, &bufinfo, MP_BUFFER_RW); - common_hal_imagecapture_parallelimagecapture_capture(self, bufinfo.buf, bufinfo.len); + common_hal_imagecapture_parallelimagecapture_singleshot_capture(self, buffer); + + return buffer; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_2(imagecapture_parallelimagecapture_capture_obj, imagecapture_parallelimagecapture_capture); + +//| def continuous_capture_start(self, buffer1: WriteableBuffer, buffer2: WriteableBuffer, /) -> None: +//| """Begin capturing into the given buffers in the background. +//| +//| Call `continuous_capture_get_frame` to get the next available +//| frame, and `continuous_capture_stop` to stop capturing. +//| +//| Until `continuous_capture_stop` (or `deinit`) is called, the +//| `ParallelImageCapture` object keeps references to ``buffer1`` and +//| ``buffer2``, so the objects will not be garbage collected.""" +//| ... +//| +STATIC mp_obj_t imagecapture_parallelimagecapture_continuous_capture_start(mp_obj_t self_in, mp_obj_t buffer1, mp_obj_t buffer2) { + imagecapture_parallelimagecapture_obj_t *self = (imagecapture_parallelimagecapture_obj_t *)self_in; + common_hal_imagecapture_parallelimagecapture_continuous_capture_start(self, buffer1, buffer2); return mp_const_none; } -STATIC MP_DEFINE_CONST_FUN_OBJ_2(imagecapture_parallelimagecapture_capture_obj, imagecapture_parallelimagecapture_capture); +STATIC MP_DEFINE_CONST_FUN_OBJ_3(imagecapture_parallelimagecapture_continuous_capture_start_obj, imagecapture_parallelimagecapture_continuous_capture_start); + +//| def continuous_capture_get_frame(self) -> WriteableBuffer: +//| """Return the next available frame, one of the two buffers passed to `continuous_capture_start`""" +//| ... +//| +STATIC mp_obj_t imagecapture_parallelimagecapture_continuous_capture_get_frame(mp_obj_t self_in) { + imagecapture_parallelimagecapture_obj_t *self = (imagecapture_parallelimagecapture_obj_t *)self_in; + return common_hal_imagecapture_parallelimagecapture_continuous_capture_get_frame(self); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(imagecapture_parallelimagecapture_continuous_capture_get_frame_obj, imagecapture_parallelimagecapture_continuous_capture_get_frame); + + + +//| def continuous_capture_stop(self) -> None: +//| """Stop continuous capture. +//| +//| Calling this method also causes the object to release its +//| references to the buffers passed to `continuous_capture_start`, +//| potentially allowing the objects to be garbage collected.""" +//| ... +//| +STATIC mp_obj_t imagecapture_parallelimagecapture_continuous_capture_stop(mp_obj_t self_in) { + imagecapture_parallelimagecapture_obj_t *self = (imagecapture_parallelimagecapture_obj_t *)self_in; + common_hal_imagecapture_parallelimagecapture_continuous_capture_stop(self); + + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(imagecapture_parallelimagecapture_continuous_capture_stop_obj, imagecapture_parallelimagecapture_continuous_capture_stop); + + + //| def deinit(self) -> None: //| """Deinitialize this instance""" @@ -134,6 +185,9 @@ STATIC const mp_rom_map_elem_t imagecapture_parallelimagecapture_locals_dict_tab { MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&imagecapture_parallelimagecapture___exit___obj) }, { MP_ROM_QSTR(MP_QSTR_capture), MP_ROM_PTR(&imagecapture_parallelimagecapture_capture_obj) }, + { MP_ROM_QSTR(MP_QSTR_continuous_capture_start), MP_ROM_PTR(&imagecapture_parallelimagecapture_continuous_capture_start_obj) }, + { MP_ROM_QSTR(MP_QSTR_continuous_capture_stop), MP_ROM_PTR(&imagecapture_parallelimagecapture_continuous_capture_stop_obj) }, + { MP_ROM_QSTR(MP_QSTR_continuous_capture_get_frame), MP_ROM_PTR(&imagecapture_parallelimagecapture_continuous_capture_get_frame_obj) }, }; STATIC MP_DEFINE_CONST_DICT(imagecapture_parallelimagecapture_locals_dict, imagecapture_parallelimagecapture_locals_dict_table); diff --git a/shared-bindings/imagecapture/ParallelImageCapture.h b/shared-bindings/imagecapture/ParallelImageCapture.h index bcd827aa23..72ddc23f65 100644 --- a/shared-bindings/imagecapture/ParallelImageCapture.h +++ b/shared-bindings/imagecapture/ParallelImageCapture.h @@ -40,4 +40,7 @@ void common_hal_imagecapture_parallelimagecapture_construct(imagecapture_paralle const mcu_pin_obj_t *horizontal_sync); void common_hal_imagecapture_parallelimagecapture_deinit(imagecapture_parallelimagecapture_obj_t *self); bool common_hal_imagecapture_parallelimagecapture_deinited(imagecapture_parallelimagecapture_obj_t *self); -void common_hal_imagecapture_parallelimagecapture_capture(imagecapture_parallelimagecapture_obj_t *self, void *buffer, size_t bufsize); +void common_hal_imagecapture_parallelimagecapture_singleshot_capture(imagecapture_parallelimagecapture_obj_t *self, mp_obj_t buffer); +void common_hal_imagecapture_parallelimagecapture_continuous_capture_start(imagecapture_parallelimagecapture_obj_t *self, mp_obj_t buffer1, mp_obj_t buffer2); +void common_hal_imagecapture_parallelimagecapture_continuous_capture_stop(imagecapture_parallelimagecapture_obj_t *self); +mp_obj_t common_hal_imagecapture_parallelimagecapture_continuous_capture_get_frame(imagecapture_parallelimagecapture_obj_t *self); diff --git a/shared-bindings/ipaddress/IPv4Address.c b/shared-bindings/ipaddress/IPv4Address.c index 213df1704a..f62e373937 100644 --- a/shared-bindings/ipaddress/IPv4Address.c +++ b/shared-bindings/ipaddress/IPv4Address.c @@ -45,14 +45,14 @@ //| The value itself can either be bytes or a string formatted address.""" //| ... //| -STATIC mp_obj_t ipaddress_ipv4address_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +STATIC mp_obj_t ipaddress_ipv4address_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_address }; static const mp_arg_t allowed_args[] = { { MP_QSTR_address, MP_ARG_OBJ | MP_ARG_REQUIRED }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); const mp_obj_t address = args[ARG_address].u_obj; diff --git a/shared-bindings/keypad/Event.c b/shared-bindings/keypad/Event.c index 9218f76ccd..fda44d3521 100644 --- a/shared-bindings/keypad/Event.c +++ b/shared-bindings/keypad/Event.c @@ -42,7 +42,7 @@ //| """ //| ... //| -STATIC mp_obj_t keypad_event_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +STATIC mp_obj_t keypad_event_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { keypad_event_obj_t *self = m_new_obj(keypad_event_obj_t); self->base.type = &keypad_event_type; enum { ARG_key_number, ARG_pressed, ARG_timestamp }; @@ -52,7 +52,7 @@ STATIC mp_obj_t keypad_event_make_new(const mp_obj_type_t *type, size_t n_args, { MP_QSTR_timestamp, MP_ARG_OBJ, {.u_obj = mp_const_none} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); const mp_uint_t key_number = (mp_uint_t)mp_arg_validate_int_min(args[ARG_key_number].u_int, 0, MP_QSTR_key_number); @@ -171,7 +171,7 @@ STATIC mp_obj_t keypad_event_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_ob //| ... //| STATIC mp_obj_t keypad_event_unary_op(mp_unary_op_t op, mp_obj_t self_in) { - keypad_event_obj_t *self = MP_OBJ_TO_PTR(self); + keypad_event_obj_t *self = MP_OBJ_TO_PTR(self_in); switch (op) { case MP_UNARY_OP_HASH: { const mp_int_t key_number = common_hal_keypad_event_get_key_number(self); diff --git a/shared-bindings/keypad/KeyMatrix.c b/shared-bindings/keypad/KeyMatrix.c index dbb4ac6822..61462464c5 100644 --- a/shared-bindings/keypad/KeyMatrix.c +++ b/shared-bindings/keypad/KeyMatrix.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "lib/utils/context_manager_helpers.h" +#include "shared/runtime/context_manager_helpers.h" #include "py/binary.h" #include "py/objproperty.h" #include "py/runtime.h" @@ -62,7 +62,7 @@ //| """ //| ... -STATIC mp_obj_t keypad_keymatrix_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +STATIC mp_obj_t keypad_keymatrix_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { keypad_keymatrix_obj_t *self = m_new_obj(keypad_keymatrix_obj_t); self->base.type = &keypad_keymatrix_type; enum { ARG_row_pins, ARG_column_pins, ARG_columns_to_anodes, ARG_interval, ARG_max_events }; @@ -74,7 +74,7 @@ STATIC mp_obj_t keypad_keymatrix_make_new(const mp_obj_type_t *type, size_t n_ar { MP_QSTR_max_events, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 64} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); mp_obj_t row_pins = args[ARG_row_pins].u_obj; // mp_obj_len() will be >= 0. diff --git a/shared-bindings/keypad/Keys.c b/shared-bindings/keypad/Keys.c index dc533a2e2b..47a906a144 100644 --- a/shared-bindings/keypad/Keys.c +++ b/shared-bindings/keypad/Keys.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "lib/utils/context_manager_helpers.h" +#include "shared/runtime/context_manager_helpers.h" #include "py/binary.h" #include "py/objproperty.h" #include "py/runtime.h" @@ -63,7 +63,7 @@ //| """ //| ... -STATIC mp_obj_t keypad_keys_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +STATIC mp_obj_t keypad_keys_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { keypad_keys_obj_t *self = m_new_obj(keypad_keys_obj_t); self->base.type = &keypad_keys_type; enum { ARG_pins, ARG_value_when_pressed, ARG_pull, ARG_interval, ARG_max_events }; @@ -75,7 +75,7 @@ STATIC mp_obj_t keypad_keys_make_new(const mp_obj_type_t *type, size_t n_args, c { MP_QSTR_max_events, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 64} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); mp_obj_t pins = args[ARG_pins].u_obj; validate_no_duplicate_pins(pins, MP_QSTR_row_pins); diff --git a/shared-bindings/keypad/ShiftRegisterKeys.c b/shared-bindings/keypad/ShiftRegisterKeys.c index c81e127601..68d7e27673 100644 --- a/shared-bindings/keypad/ShiftRegisterKeys.c +++ b/shared-bindings/keypad/ShiftRegisterKeys.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "lib/utils/context_manager_helpers.h" +#include "shared/runtime/context_manager_helpers.h" #include "py/binary.h" #include "py/objproperty.h" #include "py/runtime.h" @@ -69,7 +69,7 @@ //| """ //| ... -STATIC mp_obj_t keypad_shiftregisterkeys_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +STATIC mp_obj_t keypad_shiftregisterkeys_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { keypad_shiftregisterkeys_obj_t *self = m_new_obj(keypad_shiftregisterkeys_obj_t); self->base.type = &keypad_shiftregisterkeys_type; enum { ARG_clock, ARG_data, ARG_latch, ARG_value_to_latch, ARG_key_count, ARG_value_when_pressed, ARG_interval, ARG_max_events }; @@ -84,7 +84,7 @@ STATIC mp_obj_t keypad_shiftregisterkeys_make_new(const mp_obj_type_t *type, siz { MP_QSTR_max_events, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 64} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); mcu_pin_obj_t *clock = validate_obj_is_free_pin(args[ARG_clock].u_obj); mcu_pin_obj_t *data = validate_obj_is_free_pin(args[ARG_data].u_obj); diff --git a/shared-bindings/memorymonitor/AllocationAlarm.c b/shared-bindings/memorymonitor/AllocationAlarm.c index f7684b51a7..b54645225a 100644 --- a/shared-bindings/memorymonitor/AllocationAlarm.c +++ b/shared-bindings/memorymonitor/AllocationAlarm.c @@ -56,13 +56,13 @@ //| """ //| ... //| -STATIC mp_obj_t memorymonitor_allocationalarm_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +STATIC mp_obj_t memorymonitor_allocationalarm_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *all_args, mp_map_t *kw_args) { enum { ARG_minimum_block_count }; static const mp_arg_t allowed_args[] = { { MP_QSTR_minimum_block_count, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 1} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); mp_int_t minimum_block_count = args[ARG_minimum_block_count].u_int; if (minimum_block_count < 1) { mp_raise_ValueError_varg(translate("%q must be >= 1"), MP_QSTR_minimum_block_count); diff --git a/shared-bindings/memorymonitor/AllocationSize.c b/shared-bindings/memorymonitor/AllocationSize.c index 642dc49d34..5679b30c3f 100644 --- a/shared-bindings/memorymonitor/AllocationSize.c +++ b/shared-bindings/memorymonitor/AllocationSize.c @@ -63,7 +63,7 @@ //| """ //| ... //| -STATIC mp_obj_t memorymonitor_allocationsize_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +STATIC mp_obj_t memorymonitor_allocationsize_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *all_args, mp_map_t *kw_args) { memorymonitor_allocationsize_obj_t *self = m_new_obj(memorymonitor_allocationsize_obj_t); self->base.type = &memorymonitor_allocationsize_type; diff --git a/shared-bindings/msgpack/ExtType.c b/shared-bindings/msgpack/ExtType.c index 236b977424..892dd91696 100644 --- a/shared-bindings/msgpack/ExtType.c +++ b/shared-bindings/msgpack/ExtType.c @@ -36,7 +36,7 @@ //| :param int code: type code in range 0~127. //| :param bytes data: representation.""" //| -STATIC mp_obj_t mod_msgpack_exttype_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +STATIC mp_obj_t mod_msgpack_exttype_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { mod_msgpack_extype_obj_t *self = m_new_obj(mod_msgpack_extype_obj_t); self->base.type = &mod_msgpack_exttype_type; enum { ARG_code, ARG_data }; @@ -45,7 +45,7 @@ STATIC mp_obj_t mod_msgpack_exttype_make_new(const mp_obj_type_t *type, size_t n { MP_QSTR_data, MP_ARG_OBJ | MP_ARG_REQUIRED }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); int code = args[ARG_code].u_int; if (code < 0 || code > 127) { diff --git a/shared-bindings/msgpack/__init__.c b/shared-bindings/msgpack/__init__.c index 65d5558e60..d71ab9a6b9 100644 --- a/shared-bindings/msgpack/__init__.c +++ b/shared-bindings/msgpack/__init__.c @@ -112,7 +112,7 @@ STATIC mp_obj_t mod_msgpack_pack(size_t n_args, const mp_obj_t *pos_args, mp_map common_hal_msgpack_pack(args[ARG_obj].u_obj, args[ARG_buffer].u_obj, handler); return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_KW(mod_msgpack_pack_obj, 1, mod_msgpack_pack); +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: @@ -144,7 +144,7 @@ STATIC mp_obj_t mod_msgpack_unpack(size_t n_args, const mp_obj_t *pos_args, mp_m return common_hal_msgpack_unpack(args[ARG_buffer].u_obj, hook, args[ARG_use_list].u_bool); } -MP_DEFINE_CONST_FUN_OBJ_KW(mod_msgpack_unpack_obj, 1, mod_msgpack_unpack); +MP_DEFINE_CONST_FUN_OBJ_KW(mod_msgpack_unpack_obj, 0, mod_msgpack_unpack); STATIC const mp_rom_map_elem_t msgpack_module_globals_table[] = { diff --git a/shared-bindings/onewireio/OneWire.c b/shared-bindings/onewireio/OneWire.c index 406b421fd1..a167c86cc8 100644 --- a/shared-bindings/onewireio/OneWire.c +++ b/shared-bindings/onewireio/OneWire.c @@ -26,7 +26,7 @@ #include -#include "lib/utils/context_manager_helpers.h" +#include "shared/runtime/context_manager_helpers.h" #include "py/objproperty.h" #include "py/runtime.h" #include "py/runtime0.h" @@ -57,13 +57,13 @@ //| print(onewire.read_bit())""" //| ... //| -STATIC mp_obj_t onewireio_onewire_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +STATIC mp_obj_t onewireio_onewire_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 }; static const mp_arg_t allowed_args[] = { { MP_QSTR_pin, MP_ARG_REQUIRED | MP_ARG_OBJ }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, 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 = validate_obj_is_free_pin(args[ARG_pin].u_obj); onewireio_onewire_obj_t *self = m_new_obj(onewireio_onewire_obj_t); diff --git a/shared-bindings/os/__init__.c b/shared-bindings/os/__init__.c index 798f3c361f..fc246582fd 100644 --- a/shared-bindings/os/__init__.c +++ b/shared-bindings/os/__init__.c @@ -247,3 +247,5 @@ const mp_obj_module_t os_module = { .base = { &mp_type_module }, .globals = (mp_obj_dict_t *)&os_module_globals, }; + +MP_REGISTER_MODULE(MP_QSTR_os, os_module, CIRCUITPY_OS); diff --git a/shared-bindings/paralleldisplay/ParallelBus.c b/shared-bindings/paralleldisplay/ParallelBus.c index 57bf0974bf..782848d9b6 100644 --- a/shared-bindings/paralleldisplay/ParallelBus.c +++ b/shared-bindings/paralleldisplay/ParallelBus.c @@ -28,7 +28,7 @@ #include -#include "lib/utils/context_manager_helpers.h" +#include "shared/runtime/context_manager_helpers.h" #include "py/binary.h" #include "py/objproperty.h" #include "py/runtime.h" @@ -61,7 +61,7 @@ //| :param int frequency: The communication frequency in Hz for the display on the bus""" //| ... //| -STATIC mp_obj_t paralleldisplay_parallelbus_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +STATIC mp_obj_t paralleldisplay_parallelbus_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_data0, ARG_data_pins, ARG_command, ARG_chip_select, ARG_write, ARG_read, ARG_reset, ARG_frequency }; static const mp_arg_t allowed_args[] = { { MP_QSTR_data0, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = mp_const_none } }, @@ -74,7 +74,7 @@ STATIC mp_obj_t paralleldisplay_parallelbus_make_new(const mp_obj_type_t *type, { MP_QSTR_frequency, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 30000000 } }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); mcu_pin_obj_t *command = validate_obj_is_free_pin(args[ARG_command].u_obj); mcu_pin_obj_t *chip_select = validate_obj_is_free_pin(args[ARG_chip_select].u_obj); diff --git a/shared-bindings/ps2io/Ps2.c b/shared-bindings/ps2io/Ps2.c index 7f6f910726..a0fb6d607b 100644 --- a/shared-bindings/ps2io/Ps2.c +++ b/shared-bindings/ps2io/Ps2.c @@ -27,7 +27,7 @@ #include -#include "lib/utils/context_manager_helpers.h" +#include "shared/runtime/context_manager_helpers.h" #include "py/objproperty.h" #include "py/runtime.h" #include "py/runtime0.h" @@ -67,14 +67,14 @@ //| print(kbd.sendcmd(0x01))""" //| ... //| -STATIC mp_obj_t ps2io_ps2_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +STATIC mp_obj_t ps2io_ps2_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_datapin, ARG_clkpin }; static const mp_arg_t allowed_args[] = { { MP_QSTR_datapin, MP_ARG_REQUIRED | MP_ARG_OBJ }, { MP_QSTR_clkpin, MP_ARG_REQUIRED | MP_ARG_OBJ }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, 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 *clkpin = validate_obj_is_free_pin(args[ARG_clkpin].u_obj); const mcu_pin_obj_t *datapin = validate_obj_is_free_pin(args[ARG_datapin].u_obj); diff --git a/shared-bindings/pulseio/PulseIn.c b/shared-bindings/pulseio/PulseIn.c index eb7a24927a..13721c8106 100644 --- a/shared-bindings/pulseio/PulseIn.c +++ b/shared-bindings/pulseio/PulseIn.c @@ -26,7 +26,7 @@ #include -#include "lib/utils/context_manager_helpers.h" +#include "shared/runtime/context_manager_helpers.h" #include "py/objproperty.h" #include "py/runtime.h" #include "py/runtime0.h" @@ -76,7 +76,7 @@ //| pulses.resume(80)""" //| ... //| -STATIC mp_obj_t pulseio_pulsein_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +STATIC mp_obj_t pulseio_pulsein_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, ARG_maxlen, ARG_idle_state }; static const mp_arg_t allowed_args[] = { { MP_QSTR_pin, MP_ARG_REQUIRED | MP_ARG_OBJ }, @@ -84,7 +84,7 @@ STATIC mp_obj_t pulseio_pulsein_make_new(const mp_obj_type_t *type, size_t n_arg { MP_QSTR_idle_state, MP_ARG_BOOL, {.u_bool = false} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, 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 = validate_obj_is_free_pin(args[ARG_pin].u_obj); pulseio_pulsein_obj_t *self = m_new_obj(pulseio_pulsein_obj_t); diff --git a/shared-bindings/pulseio/PulseOut.c b/shared-bindings/pulseio/PulseOut.c index 88d7eb40e0..bf2aaf54ff 100644 --- a/shared-bindings/pulseio/PulseOut.c +++ b/shared-bindings/pulseio/PulseOut.c @@ -26,7 +26,7 @@ #include -#include "lib/utils/context_manager_helpers.h" +#include "shared/runtime/context_manager_helpers.h" #include "py/objproperty.h" #include "py/runtime.h" @@ -59,7 +59,7 @@ //| import board //| //| # 50% duty cycle at 38kHz. -//| pwm = pulseio.PulseOut(board.D13, frequency=38000, duty_cycle=32768) +//| pwm = 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) @@ -69,7 +69,7 @@ //| pulse.send(pulses)""" //| ... //| -STATIC mp_obj_t pulseio_pulseout_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +STATIC mp_obj_t pulseio_pulseout_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, ARG_frequency, ARG_duty_cycle}; static const mp_arg_t allowed_args[] = { { MP_QSTR_pin, MP_ARG_REQUIRED | MP_ARG_OBJ }, @@ -77,7 +77,7 @@ STATIC mp_obj_t pulseio_pulseout_make_new(const mp_obj_type_t *type, size_t n_ar { MP_QSTR_duty_cycle, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 1 << 15} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, 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 = args[ARG_pin].u_obj; mp_int_t frequency = args[ARG_frequency].u_int; diff --git a/shared-bindings/pwmio/PWMOut.c b/shared-bindings/pwmio/PWMOut.c index e34b27ad4a..1c0110653b 100644 --- a/shared-bindings/pwmio/PWMOut.c +++ b/shared-bindings/pwmio/PWMOut.c @@ -26,7 +26,7 @@ #include -#include "lib/utils/context_manager_helpers.h" +#include "shared/runtime/context_manager_helpers.h" #include "py/objproperty.h" #include "py/runtime.h" @@ -86,13 +86,29 @@ void common_hal_pwmio_pwmout_raise_error(pwmout_result_t result) { //| :param int frequency: The target frequency in Hertz (32-bit) //| :param bool variable_frequency: True if the frequency will change over time //| -//| Simple LED fade:: +//| +//| Simple LED on:: //| //| import pwmio //| import board //| -//| pwm = pwmio.PWMOut(board.D13) # output on D13 -//| pwm.duty_cycle = 2 ** 15 # Cycles the pin with 50% duty cycle (half of 2 ** 16) at the default 500hz +//| pwm = pwmio.PWMOut(board.LED) +//| +//| while True: +//| pwm.duty_cycle = 2 ** 15 # Cycles the pin with 50% duty cycle (half of 2 ** 16) at the default 500hz +//| +//| PWM LED fade:: +//| +//| import pwmio +//| import board +//| +//| pwm = pwmio.PWMOut(board.LED) # output on LED pin with default of 500Hz +//| +//| while True: +//| for cycle in range(0, 65535): # Cycles through the full PWM range from 0 to 65535 +//| pwm.duty_cycle = cycle # Cycles the LED pin duty cycle through the range of values +//| for cycle in range(65534, 0, -1): # Cycles through the PWM range backwards from 65534 to 0 +//| pwm.duty_cycle = cycle # Cycles the LED pin duty cycle through the range of values //| //| PWM at specific frequency (servos and motors):: //| @@ -100,7 +116,7 @@ void common_hal_pwmio_pwmout_raise_error(pwmout_result_t result) { //| import board //| //| pwm = pwmio.PWMOut(board.D13, frequency=50) -//| pwm.duty_cycle = 2 ** 15 # Cycles the pin with 50% duty cycle (half of 2 ** 16) at 50hz +//| pwm.duty_cycle = 2 ** 15 # Cycles the pin with 50% duty cycle (half of 2 ** 16) at 50hz //| //| Variable frequency (usually tones):: //| @@ -114,7 +130,7 @@ void common_hal_pwmio_pwmout_raise_error(pwmout_result_t result) { //| time.sleep(0.1)""" //| ... //| -STATIC mp_obj_t pwmio_pwmout_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { +STATIC mp_obj_t pwmio_pwmout_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { enum { ARG_pin, ARG_duty_cycle, ARG_frequency, ARG_variable_frequency }; static const mp_arg_t allowed_args[] = { { MP_QSTR_pin, MP_ARG_REQUIRED | MP_ARG_OBJ, }, @@ -123,7 +139,7 @@ STATIC mp_obj_t pwmio_pwmout_make_new(const mp_obj_type_t *type, size_t n_args, { MP_QSTR_variable_frequency, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = false} }, }; mp_arg_val_t parsed_args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args, args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, parsed_args); + mp_arg_parse_all_kw_array(n_args, n_kw, args, MP_ARRAY_SIZE(allowed_args), allowed_args, parsed_args); const mcu_pin_obj_t *pin = validate_obj_is_free_pin(parsed_args[ARG_pin].u_obj); diff --git a/shared-bindings/pwmio/__init__.c b/shared-bindings/pwmio/__init__.c index 6c9e63a35f..c9f7a50155 100644 --- a/shared-bindings/pwmio/__init__.c +++ b/shared-bindings/pwmio/__init__.c @@ -45,11 +45,11 @@ //| //| For example:: //| -//| import pwmio //| import time -//| from board import * +//| import pwmio +//| import board //| -//| pwm = pwmio.PWMOut(D13) +//| pwm = pwmio.PWMOut(board.LED) //| pwm.duty_cycle = 2 ** 15 //| time.sleep(0.1) //| diff --git a/shared-bindings/qrio/QRDecoder.c b/shared-bindings/qrio/QRDecoder.c index 73a5d64694..c8382de42e 100644 --- a/shared-bindings/qrio/QRDecoder.c +++ b/shared-bindings/qrio/QRDecoder.c @@ -42,14 +42,14 @@ //| """ //| ... -STATIC mp_obj_t qrio_qrdecoder_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +STATIC mp_obj_t qrio_qrdecoder_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args_in) { enum { ARG_width, ARG_height }; static const mp_arg_t allowed_args[] = { { MP_QSTR_width, MP_ARG_INT | MP_ARG_REQUIRED, {.u_int = 0} }, { MP_QSTR_height, MP_ARG_INT | MP_ARG_REQUIRED, {.u_int = 0} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + mp_arg_parse_all_kw_array(n_args, n_kw, args_in, MP_ARRAY_SIZE(allowed_args), allowed_args, args); qrio_qrdecoder_obj_t *self = m_new_obj(qrio_qrdecoder_obj_t); self->base.type = &qrio_qrdecoder_type_obj; @@ -88,7 +88,7 @@ STATIC mp_obj_t qrio_qrdecoder_decode(size_t n_args, const mp_obj_t *pos_args, m return shared_module_qrio_qrdecoder_decode(self, &bufinfo, policy); } -MP_DEFINE_CONST_FUN_OBJ_KW(qrio_qrdecoder_decode_obj, 2, qrio_qrdecoder_decode); +MP_DEFINE_CONST_FUN_OBJ_KW(qrio_qrdecoder_decode_obj, 1, qrio_qrdecoder_decode); //| width: int //| """The width of image the decoder expects""" diff --git a/shared-bindings/rgbmatrix/RGBMatrix.c b/shared-bindings/rgbmatrix/RGBMatrix.c index 0db1a5ebbc..12fd1e15cc 100644 --- a/shared-bindings/rgbmatrix/RGBMatrix.c +++ b/shared-bindings/rgbmatrix/RGBMatrix.c @@ -170,7 +170,7 @@ STATIC void preflight_pins_or_throw(uint8_t clock_pin, uint8_t *rgb_pins, uint8_ //| `framebufferio.FramebufferDisplay`.""" //| -STATIC mp_obj_t rgbmatrix_rgbmatrix_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +STATIC mp_obj_t rgbmatrix_rgbmatrix_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_bit_depth, ARG_rgb_list, ARG_addr_list, ARG_clock_pin, ARG_latch_pin, ARG_output_enable_pin, ARG_doublebuffer, ARG_framebuffer, ARG_height, ARG_tile, ARG_serpentine }; static const mp_arg_t allowed_args[] = { @@ -188,7 +188,7 @@ STATIC mp_obj_t rgbmatrix_rgbmatrix_make_new(const mp_obj_type_t *type, size_t n { MP_QSTR_serpentine, MP_ARG_BOOL | MP_ARG_KW_ONLY, { .u_bool = true } }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); rgbmatrix_rgbmatrix_obj_t *self = &allocate_display_bus_or_raise()->rgbmatrix; self->base.type = &rgbmatrix_RGBMatrix_type; diff --git a/shared-bindings/rotaryio/IncrementalEncoder.c b/shared-bindings/rotaryio/IncrementalEncoder.c index cf9814df24..ef218ba024 100644 --- a/shared-bindings/rotaryio/IncrementalEncoder.c +++ b/shared-bindings/rotaryio/IncrementalEncoder.c @@ -26,7 +26,7 @@ #include -#include "lib/utils/context_manager_helpers.h" +#include "shared/runtime/context_manager_helpers.h" #include "py/objproperty.h" #include "py/runtime.h" #include "py/runtime0.h" @@ -37,13 +37,14 @@ //| class IncrementalEncoder: //| """IncrementalEncoder determines the relative rotational position based on two series of pulses.""" //| -//| def __init__(self, pin_a: microcontroller.Pin, pin_b: microcontroller.Pin) -> None: +//| def __init__(self, pin_a: microcontroller.Pin, pin_b: microcontroller.Pin, divisor: int = 4) -> None: //| """Create an IncrementalEncoder object associated with the given pins. It tracks the positional //| state of an incremental rotary encoder (also known as a quadrature encoder.) Position is //| relative to the position when the object is contructed. //| //| :param ~microcontroller.Pin pin_a: First pin to read pulses from. //| :param ~microcontroller.Pin pin_b: Second pin to read pulses from. +//| :param int divisor: The divisor of the quadrature signal. //| //| For example:: //| @@ -60,14 +61,15 @@ //| last_position = position""" //| ... //| -STATIC mp_obj_t rotaryio_incrementalencoder_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { - enum { ARG_pin_a, ARG_pin_b }; +STATIC mp_obj_t rotaryio_incrementalencoder_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, ARG_pin_b, ARG_divisor }; static const mp_arg_t allowed_args[] = { { MP_QSTR_pin_a, MP_ARG_REQUIRED | MP_ARG_OBJ }, { MP_QSTR_pin_b, MP_ARG_REQUIRED | MP_ARG_OBJ }, + { MP_QSTR_divisor, MP_ARG_INT, { .u_int = 4 } }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, 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_b = validate_obj_is_free_pin(args[ARG_pin_b].u_obj); @@ -77,6 +79,7 @@ STATIC mp_obj_t rotaryio_incrementalencoder_make_new(const mp_obj_type_t *type, common_hal_rotaryio_incrementalencoder_construct(self, pin_a, pin_b); + common_hal_rotaryio_incrementalencoder_set_divisor(self, args[ARG_divisor].u_int); return MP_OBJ_FROM_PTR(self); } @@ -116,9 +119,38 @@ STATIC mp_obj_t rotaryio_incrementalencoder_obj___exit__(size_t n_args, const mp STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(rotaryio_incrementalencoder___exit___obj, 4, 4, rotaryio_incrementalencoder_obj___exit__); +//| divisor: int +//| """The divisor of the quadrature signal. Use 1 for encoders without +//| detents, or encoders with 4 detents per cycle. Use 2 for encoders with 2 +//| detents per cycle. Use 4 for encoders with 1 detent per cycle.""" +//| +STATIC mp_obj_t rotaryio_incrementalencoder_obj_get_divisor(mp_obj_t self_in) { + rotaryio_incrementalencoder_obj_t *self = MP_OBJ_TO_PTR(self_in); + check_for_deinit(self); + + return mp_obj_new_int(common_hal_rotaryio_incrementalencoder_get_divisor(self)); +} +MP_DEFINE_CONST_FUN_OBJ_1(rotaryio_incrementalencoder_get_divisor_obj, rotaryio_incrementalencoder_obj_get_divisor); + +STATIC mp_obj_t rotaryio_incrementalencoder_obj_set_divisor(mp_obj_t self_in, mp_obj_t new_divisor) { + rotaryio_incrementalencoder_obj_t *self = MP_OBJ_TO_PTR(self_in); + check_for_deinit(self); + + common_hal_rotaryio_incrementalencoder_set_divisor(self, mp_obj_get_int(new_divisor)); + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_2(rotaryio_incrementalencoder_set_divisor_obj, rotaryio_incrementalencoder_obj_set_divisor); + +const mp_obj_property_t rotaryio_incrementalencoder_divisor_obj = { + .base.type = &mp_type_property, + .proxy = {(mp_obj_t)&rotaryio_incrementalencoder_get_divisor_obj, + (mp_obj_t)&rotaryio_incrementalencoder_set_divisor_obj, + MP_ROM_NONE}, +}; + //| position: int //| """The current position in terms of pulses. The number of pulses per rotation is defined by the -//| specific hardware.""" +//| specific hardware and by the divisor.""" //| STATIC mp_obj_t rotaryio_incrementalencoder_obj_get_position(mp_obj_t self_in) { rotaryio_incrementalencoder_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -150,6 +182,7 @@ STATIC const mp_rom_map_elem_t rotaryio_incrementalencoder_locals_dict_table[] = { MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&default___enter___obj) }, { MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&rotaryio_incrementalencoder___exit___obj) }, { MP_ROM_QSTR(MP_QSTR_position), MP_ROM_PTR(&rotaryio_incrementalencoder_position_obj) }, + { MP_ROM_QSTR(MP_QSTR_divisor), MP_ROM_PTR(&rotaryio_incrementalencoder_divisor_obj) }, }; STATIC MP_DEFINE_CONST_DICT(rotaryio_incrementalencoder_locals_dict, rotaryio_incrementalencoder_locals_dict_table); diff --git a/shared-bindings/rotaryio/IncrementalEncoder.h b/shared-bindings/rotaryio/IncrementalEncoder.h index 51bf7bd9f6..45551c3e41 100644 --- a/shared-bindings/rotaryio/IncrementalEncoder.h +++ b/shared-bindings/rotaryio/IncrementalEncoder.h @@ -39,5 +39,8 @@ extern bool common_hal_rotaryio_incrementalencoder_deinited(rotaryio_incremental extern mp_int_t common_hal_rotaryio_incrementalencoder_get_position(rotaryio_incrementalencoder_obj_t *self); extern void common_hal_rotaryio_incrementalencoder_set_position(rotaryio_incrementalencoder_obj_t *self, mp_int_t new_position); +extern mp_int_t common_hal_rotaryio_incrementalencoder_get_divisor(rotaryio_incrementalencoder_obj_t *self); +extern void common_hal_rotaryio_incrementalencoder_set_divisor(rotaryio_incrementalencoder_obj_t *self, + mp_int_t new_divisor); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_ROTARYIO_INCREMENTALENCODER_H diff --git a/shared-bindings/rtc/RTC.c b/shared-bindings/rtc/RTC.c index 9247cbb16c..f52871c7da 100644 --- a/shared-bindings/rtc/RTC.c +++ b/shared-bindings/rtc/RTC.c @@ -30,7 +30,7 @@ #include "py/obj.h" #include "py/objproperty.h" #include "py/runtime.h" -#include "lib/timeutils/timeutils.h" +#include "shared/timeutils/timeutils.h" #include "shared-bindings/rtc/__init__.h" #include "shared-bindings/rtc/RTC.h" #include "shared-bindings/time/__init__.h" @@ -45,9 +45,9 @@ const rtc_rtc_obj_t rtc_rtc_obj = {{&rtc_rtc_type}}; //| """This class represents the onboard Real Time Clock. It is a singleton and will always return the same instance.""" //| ... //| -STATIC mp_obj_t rtc_rtc_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { +STATIC mp_obj_t rtc_rtc_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { // No arguments - mp_arg_check_num(n_args, kw_args, 0, 0, false); + mp_arg_check_num(n_args, n_kw, 0, 0, false); // return constant object return (mp_obj_t)&rtc_rtc_obj; diff --git a/shared-bindings/rtc/RTC.h b/shared-bindings/rtc/RTC.h index 02bf54f501..ede824fa2a 100644 --- a/shared-bindings/rtc/RTC.h +++ b/shared-bindings/rtc/RTC.h @@ -31,7 +31,7 @@ #include #include "py/obj.h" -#include "lib/timeutils/timeutils.h" +#include "shared/timeutils/timeutils.h" extern void common_hal_rtc_get_time(timeutils_struct_time_t *tm); extern void common_hal_rtc_set_time(timeutils_struct_time_t *tm); diff --git a/shared-bindings/sdcardio/SDCard.c b/shared-bindings/sdcardio/SDCard.c index 612203b56d..14cf5f5b0d 100644 --- a/shared-bindings/sdcardio/SDCard.c +++ b/shared-bindings/sdcardio/SDCard.c @@ -76,17 +76,16 @@ //| storage.mount(vfs, '/sd') //| os.listdir('/sd')""" -STATIC mp_obj_t sdcardio_sdcard_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { - enum { ARG_spi, ARG_cs, ARG_baudrate, ARG_sdio, NUM_ARGS }; +STATIC mp_obj_t sdcardio_sdcard_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { + enum { ARG_spi, ARG_cs, ARG_baudrate, NUM_ARGS }; static const mp_arg_t allowed_args[] = { { MP_QSTR_spi, MP_ARG_OBJ, {.u_obj = mp_const_none } }, { MP_QSTR_cs, MP_ARG_OBJ, {.u_obj = mp_const_none } }, { MP_QSTR_baudrate, MP_ARG_INT, {.u_int = 8000000} }, - { MP_QSTR_sdio, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_int = 8000000} }, }; MP_STATIC_ASSERT(MP_ARRAY_SIZE(allowed_args) == NUM_ARGS); mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); busio_spi_obj_t *spi = validate_obj_is_spi_bus(args[ARG_spi].u_obj); mcu_pin_obj_t *cs = validate_obj_is_free_pin(args[ARG_cs].u_obj); @@ -150,6 +149,23 @@ mp_obj_t sdcardio_sdcard_readblocks(mp_obj_t self_in, mp_obj_t start_block_in, m MP_DEFINE_CONST_FUN_OBJ_3(sdcardio_sdcard_readblocks_obj, sdcardio_sdcard_readblocks); +//| def sync(self) -> None: +//| """Ensure all blocks written are actually committed to the SD card +//| +//| :return: None""" +//| ... +mp_obj_t sdcardio_sdcard_sync(mp_obj_t self_in) { + sdcardio_sdcard_obj_t *self = (sdcardio_sdcard_obj_t *)self_in; + int result = common_hal_sdcardio_sdcard_sync(self); + if (result < 0) { + mp_raise_OSError(-result); + } + return mp_const_none; +} + +MP_DEFINE_CONST_FUN_OBJ_1(sdcardio_sdcard_sync_obj, sdcardio_sdcard_sync); + + //| def writeblocks(self, start_block: int, buf: ReadableBuffer) -> None: //| //| """Write one or more blocks to the card @@ -177,6 +193,7 @@ STATIC const mp_rom_map_elem_t sdcardio_sdcard_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_count), MP_ROM_PTR(&sdcardio_sdcard_count_obj) }, { MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&sdcardio_sdcard_deinit_obj) }, { MP_ROM_QSTR(MP_QSTR_readblocks), MP_ROM_PTR(&sdcardio_sdcard_readblocks_obj) }, + { MP_ROM_QSTR(MP_QSTR_sync), MP_ROM_PTR(&sdcardio_sdcard_sync_obj) }, { MP_ROM_QSTR(MP_QSTR_writeblocks), MP_ROM_PTR(&sdcardio_sdcard_writeblocks_obj) }, }; STATIC MP_DEFINE_CONST_DICT(sdcardio_sdcard_locals_dict, sdcardio_sdcard_locals_dict_table); diff --git a/shared-bindings/sdioio/SDCard.c b/shared-bindings/sdioio/SDCard.c index aab43b54bd..e03d180d7a 100644 --- a/shared-bindings/sdioio/SDCard.c +++ b/shared-bindings/sdioio/SDCard.c @@ -33,8 +33,8 @@ #include "shared-bindings/sdioio/SDCard.h" #include "shared-bindings/util.h" -#include "lib/utils/buffer_helper.h" -#include "lib/utils/context_manager_helpers.h" +#include "shared/runtime/buffer_helper.h" +#include "shared/runtime/context_manager_helpers.h" #include "py/mperrno.h" #include "py/objproperty.h" #include "py/runtime.h" @@ -78,7 +78,7 @@ //| ... //| -STATIC mp_obj_t sdioio_sdcard_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +STATIC mp_obj_t sdioio_sdcard_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { sdioio_sdcard_obj_t *self = m_new_obj(sdioio_sdcard_obj_t); self->base.type = &sdioio_SDCard_type; enum { ARG_clock, ARG_command, ARG_data, ARG_frequency, NUM_ARGS }; @@ -91,7 +91,7 @@ STATIC mp_obj_t sdioio_sdcard_make_new(const mp_obj_type_t *type, size_t n_args, MP_STATIC_ASSERT(MP_ARRAY_SIZE(allowed_args) == NUM_ARGS); mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, 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 *clock = validate_obj_is_free_pin(args[ARG_clock].u_obj); const mcu_pin_obj_t *command = validate_obj_is_free_pin(args[ARG_command].u_obj); diff --git a/shared-bindings/sharpdisplay/SharpMemoryFramebuffer.c b/shared-bindings/sharpdisplay/SharpMemoryFramebuffer.c index a9aed31970..8e9050d018 100644 --- a/shared-bindings/sharpdisplay/SharpMemoryFramebuffer.c +++ b/shared-bindings/sharpdisplay/SharpMemoryFramebuffer.c @@ -33,7 +33,7 @@ #include "shared-module/displayio/__init__.h" #include "shared-module/sharpdisplay/SharpMemoryFramebuffer.h" -STATIC mp_obj_t sharpdisplay_framebuffer_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +STATIC mp_obj_t sharpdisplay_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_spi_bus, ARG_chip_select, ARG_width, ARG_height, ARG_baudrate, NUM_ARGS }; static const mp_arg_t allowed_args[] = { { MP_QSTR_spi_bus, MP_ARG_OBJ | MP_ARG_REQUIRED, {.u_obj = MP_OBJ_NULL} }, @@ -45,7 +45,7 @@ STATIC mp_obj_t sharpdisplay_framebuffer_make_new(const mp_obj_type_t *type, siz mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; MP_STATIC_ASSERT(MP_ARRAY_SIZE(allowed_args) == NUM_ARGS); - mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); mcu_pin_obj_t *chip_select = validate_obj_is_free_pin(args[ARG_chip_select].u_obj); busio_spi_obj_t *spi = validate_obj_is_spi_bus(args[ARG_spi_bus].u_obj); diff --git a/shared-bindings/socketpool/Socket.c b/shared-bindings/socketpool/Socket.c index 4ab4f2de4d..2dd832f490 100644 --- a/shared-bindings/socketpool/Socket.c +++ b/shared-bindings/socketpool/Socket.c @@ -30,13 +30,13 @@ #include #include -#include "lib/utils/context_manager_helpers.h" +#include "shared/runtime/context_manager_helpers.h" #include "py/objtuple.h" #include "py/objlist.h" #include "py/runtime.h" #include "py/mperrno.h" -#include "lib/netutils/netutils.h" +#include "shared/netutils/netutils.h" //| class Socket: //| """TCP, UDP and RAW socket. Cannot be created directly. Instead, call diff --git a/shared-bindings/socketpool/SocketPool.c b/shared-bindings/socketpool/SocketPool.c index bd6a2b44f9..f427c759a4 100644 --- a/shared-bindings/socketpool/SocketPool.c +++ b/shared-bindings/socketpool/SocketPool.c @@ -44,8 +44,8 @@ //| a pool of sockets provided by the underlying OS.""" //| -STATIC mp_obj_t socketpool_socketpool_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { - mp_arg_check_num(n_args, kw_args, 1, 1, false); +STATIC mp_obj_t socketpool_socketpool_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { + mp_arg_check_num(n_args, n_kw, 1, 1, false); socketpool_socketpool_obj_t *s = m_new_obj_with_finaliser(socketpool_socketpool_obj_t); s->base.type = &socketpool_socketpool_type; @@ -66,22 +66,27 @@ STATIC mp_obj_t socketpool_socketpool_make_new(const mp_obj_type_t *type, size_t //| """Create a new socket //| //| :param ~int family: AF_INET or AF_INET6 -//| :param ~int type: SOCK_STREAM, SOCK_DGRAM or SOCK_RAW""" +//| :param ~int type: SOCK_STREAM, SOCK_DGRAM or SOCK_RAW +//| +//| The ``proto`` (protocol) and ``fileno`` arguments available in ``socket.socket()`` +//| in CPython are not supported. +//| """ //| ... //| - STATIC mp_obj_t socketpool_socketpool_socket(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { - mp_arg_check_num(n_args, kw_args, 0, 5, false); + enum { ARG_family, ARG_type }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_family, MP_ARG_INT, {.u_int = SOCKETPOOL_AF_INET} }, + { MP_QSTR_type, MP_ARG_INT, {.u_int = SOCKETPOOL_SOCK_STREAM} }, + }; + socketpool_socketpool_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); + + socketpool_socketpool_addressfamily_t family = args[ARG_family].u_int; + socketpool_socketpool_sock_t type = args[ARG_type].u_int; - socketpool_socketpool_obj_t *self = pos_args[0]; - socketpool_socketpool_addressfamily_t family = SOCKETPOOL_AF_INET; - socketpool_socketpool_sock_t type = SOCKETPOOL_SOCK_STREAM; - if (n_args >= 2) { - family = mp_obj_get_int(pos_args[1]); - if (n_args >= 3) { - type = mp_obj_get_int(pos_args[2]); - } - } return common_hal_socketpool_socket(self, family, type); } MP_DEFINE_CONST_FUN_OBJ_KW(socketpool_socketpool_socket_obj, 1, socketpool_socketpool_socket); @@ -94,7 +99,6 @@ MP_DEFINE_CONST_FUN_OBJ_KW(socketpool_socketpool_socket_obj, 1, socketpool_socke //| as a tuple.""" //| ... //| - STATIC mp_obj_t socketpool_socketpool_getaddrinfo(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_host, ARG_port, ARG_family, ARG_type, ARG_proto, ARG_flags }; static const mp_arg_t allowed_args[] = { @@ -137,7 +141,7 @@ STATIC mp_obj_t socketpool_socketpool_getaddrinfo(size_t n_args, const mp_obj_t tuple->items[4] = MP_OBJ_FROM_PTR(sockaddr); return mp_obj_new_list(1, (mp_obj_t *)&tuple); } -STATIC MP_DEFINE_CONST_FUN_OBJ_KW(socketpool_socketpool_getaddrinfo_obj, 3, socketpool_socketpool_getaddrinfo); +STATIC MP_DEFINE_CONST_FUN_OBJ_KW(socketpool_socketpool_getaddrinfo_obj, 1, socketpool_socketpool_getaddrinfo); STATIC const mp_rom_map_elem_t socketpool_socketpool_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_socket), MP_ROM_PTR(&socketpool_socketpool_socket_obj) }, diff --git a/shared-bindings/ssl/SSLContext.c b/shared-bindings/ssl/SSLContext.c index 4a3dafb981..885a156edd 100644 --- a/shared-bindings/ssl/SSLContext.c +++ b/shared-bindings/ssl/SSLContext.c @@ -40,8 +40,8 @@ //| rather than all of them.""" //| -STATIC mp_obj_t ssl_sslcontext_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { - mp_arg_check_num(n_args, kw_args, 0, 1, false); +STATIC mp_obj_t ssl_sslcontext_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { + mp_arg_check_num(n_args, n_kw, 0, 1, false); ssl_sslcontext_obj_t *s = m_new_obj(ssl_sslcontext_obj_t); s->base.type = &ssl_sslcontext_type; @@ -79,7 +79,7 @@ STATIC mp_obj_t ssl_sslcontext_wrap_socket(size_t n_args, const mp_obj_t *pos_ar return common_hal_ssl_sslcontext_wrap_socket(self, sock, server_side, server_hostname); } -STATIC MP_DEFINE_CONST_FUN_OBJ_KW(ssl_sslcontext_wrap_socket_obj, 2, ssl_sslcontext_wrap_socket); +STATIC MP_DEFINE_CONST_FUN_OBJ_KW(ssl_sslcontext_wrap_socket_obj, 1, ssl_sslcontext_wrap_socket); 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) }, diff --git a/shared-bindings/ssl/SSLSocket.c b/shared-bindings/ssl/SSLSocket.c index 341033d09e..9e25d7f25f 100644 --- a/shared-bindings/ssl/SSLSocket.c +++ b/shared-bindings/ssl/SSLSocket.c @@ -29,13 +29,13 @@ #include #include -#include "lib/utils/context_manager_helpers.h" +#include "shared/runtime/context_manager_helpers.h" #include "py/objtuple.h" #include "py/objlist.h" #include "py/runtime.h" #include "py/mperrno.h" -#include "lib/netutils/netutils.h" +#include "shared/netutils/netutils.h" //| class SSLSocket: //| """Implements TLS security on a subset of `socketpool.Socket` functions. Cannot be created diff --git a/shared-bindings/storage/__init__.c b/shared-bindings/storage/__init__.c index ddd2b9a1a9..c5769b56b5 100644 --- a/shared-bindings/storage/__init__.c +++ b/shared-bindings/storage/__init__.c @@ -48,26 +48,30 @@ //| //| This is the CircuitPython analog to the UNIX ``mount`` command. //| -//| :param bool readonly: True when the filesystem should be readonly to CircuitPython.""" +//| :param VfsFat filesystem: The filesystem to mount. +//| :param str mount_path: Where to mount the filesystem. +//| :param bool readonly: True when the filesystem should be readonly to CircuitPython. +//| """ //| ... //| mp_obj_t storage_mount(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { - enum { ARG_readonly }; + enum { ARG_filesystem, ARG_mount_path, ARG_readonly }; static const mp_arg_t allowed_args[] = { + { MP_QSTR_filesystem, MP_ARG_OBJ | MP_ARG_REQUIRED }, + { MP_QSTR_mount_path, MP_ARG_OBJ | MP_ARG_REQUIRED }, { MP_QSTR_readonly, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = false} }, }; - // parse args mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args - 2, pos_args + 2, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); // get the mount point - const char *mnt_str = mp_obj_str_get_str(pos_args[1]); + const char *mnt_str = mp_obj_str_get_str(args[ARG_mount_path].u_obj); // Make sure we're given an object we can mount. // TODO(tannewt): Make sure we have all the methods we need to operating it // as a file system. - mp_obj_t vfs_obj = pos_args[0]; + mp_obj_t vfs_obj = args[ARG_filesystem].u_obj; mp_obj_t dest[2]; mp_load_method_maybe(vfs_obj, MP_QSTR_mount, dest); if (dest[0] == MP_OBJ_NULL) { @@ -78,7 +82,7 @@ mp_obj_t storage_mount(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_arg return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_KW(storage_mount_obj, 2, storage_mount); +MP_DEFINE_CONST_FUN_OBJ_KW(storage_mount_obj, 0, storage_mount); //| def umount(mount: Union[str, VfsFat]) -> None: //| """Unmounts the given filesystem object or if *mount* is a path, then unmount @@ -101,6 +105,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(storage_umount_obj, storage_umount); //| def remount(mount_path: str, readonly: bool = False, *, disable_concurrent_write_protection: bool = False) -> None: //| """Remounts the given path with new parameters. //| +//| :param str mount_path: The path to remount. //| :param bool readonly: True when the filesystem should be readonly to CircuitPython. //| :param bool disable_concurrent_write_protection: When True, the check that makes sure the //| underlying filesystem data is written by one computer is disabled. Disabling the protection @@ -109,24 +114,23 @@ MP_DEFINE_CONST_FUN_OBJ_1(storage_umount_obj, storage_umount); //| ... //| mp_obj_t storage_remount(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { - enum { ARG_readonly, ARG_disable_concurrent_write_protection }; + enum { ARG_mount_path, ARG_readonly, ARG_disable_concurrent_write_protection }; static const mp_arg_t allowed_args[] = { + { MP_QSTR_mount_path, MP_ARG_OBJ | MP_ARG_REQUIRED }, { MP_QSTR_readonly, MP_ARG_BOOL, {.u_bool = false} }, { MP_QSTR_disable_concurrent_write_protection, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = false} }, }; - // get the mount point - const char *mnt_str = mp_obj_str_get_str(pos_args[0]); - - // parse args 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); + mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + + const char *mnt_str = mp_obj_str_get_str(args[ARG_mount_path].u_obj); common_hal_storage_remount(mnt_str, args[ARG_readonly].u_bool, args[ARG_disable_concurrent_write_protection].u_bool); return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_KW(storage_remount_obj, 1, storage_remount); +MP_DEFINE_CONST_FUN_OBJ_KW(storage_remount_obj, 0, storage_remount); //| def getmount(mount_path: str) -> VfsFat: //| """Retrieves the mount object associated with the mount path""" diff --git a/shared-bindings/supervisor/__init__.c b/shared-bindings/supervisor/__init__.c index 28565fd2ea..35ae63c03d 100644 --- a/shared-bindings/supervisor/__init__.c +++ b/shared-bindings/supervisor/__init__.c @@ -30,7 +30,7 @@ #include "py/reload.h" #include "py/objstr.h" -#include "lib/utils/interrupt_char.h" +#include "shared/runtime/interrupt_char.h" #include "supervisor/shared/autoreload.h" #include "supervisor/shared/bluetooth/bluetooth.h" #include "supervisor/shared/status_leds.h" diff --git a/shared-bindings/synthio/MidiTrack.c b/shared-bindings/synthio/MidiTrack.c index 81d53b6b82..6ffefd4713 100644 --- a/shared-bindings/synthio/MidiTrack.c +++ b/shared-bindings/synthio/MidiTrack.c @@ -26,7 +26,7 @@ #include -#include "lib/utils/context_manager_helpers.h" +#include "shared/runtime/context_manager_helpers.h" #include "py/binary.h" #include "py/objproperty.h" #include "py/runtime.h" @@ -63,7 +63,7 @@ //| print("stopped")""" //| ... //| -STATIC mp_obj_t synthio_miditrack_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +STATIC mp_obj_t synthio_miditrack_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_buffer, ARG_tempo, ARG_sample_rate }; static const mp_arg_t allowed_args[] = { { MP_QSTR_buffer, MP_ARG_OBJ | MP_ARG_REQUIRED }, @@ -71,7 +71,7 @@ STATIC mp_obj_t synthio_miditrack_make_new(const mp_obj_type_t *type, size_t n_a { MP_QSTR_sample_rate, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 11025} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); mp_buffer_info_t bufinfo; mp_get_buffer_raise(args[ARG_buffer].u_obj, &bufinfo, MP_BUFFER_READ); diff --git a/shared-bindings/terminalio/Terminal.c b/shared-bindings/terminalio/Terminal.c index 35c4ac00e4..cdeca59164 100644 --- a/shared-bindings/terminalio/Terminal.c +++ b/shared-bindings/terminalio/Terminal.c @@ -46,27 +46,23 @@ //| ... //| -STATIC mp_obj_t terminalio_terminal_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +STATIC mp_obj_t terminalio_terminal_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_tilegrid, ARG_font }; static const mp_arg_t allowed_args[] = { { MP_QSTR_tilegrid, MP_ARG_REQUIRED | MP_ARG_OBJ }, { MP_QSTR_font, MP_ARG_REQUIRED | MP_ARG_OBJ }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - mp_obj_t tilegrid = args[ARG_tilegrid].u_obj; - if (!mp_obj_is_type(tilegrid, &displayio_tilegrid_type)) { - mp_raise_TypeError_varg(translate("Expected a %q"), displayio_tilegrid_type.name); - } + displayio_tilegrid_t *tilegrid = mp_arg_validate_type(args[ARG_tilegrid].u_obj, &displayio_tilegrid_type, MP_QSTR_tilegrid); + + fontio_builtinfont_t *font = mp_arg_validate_type(args[ARG_font].u_obj, &fontio_builtinfont_type, MP_QSTR_font); - mp_obj_t font = args[ARG_font].u_obj; - if (!mp_obj_is_type(font, &fontio_builtinfont_type)) { - mp_raise_TypeError_varg(translate("Expected a %q"), fontio_builtinfont_type.name); - } terminalio_terminal_obj_t *self = m_new_obj(terminalio_terminal_obj_t); self->base.type = &terminalio_terminal_type; - common_hal_terminalio_terminal_construct(self, MP_OBJ_TO_PTR(tilegrid), MP_OBJ_TO_PTR(font)); + + common_hal_terminalio_terminal_construct(self, tilegrid, font); return MP_OBJ_FROM_PTR(self); } diff --git a/shared-bindings/time/__init__.c b/shared-bindings/time/__init__.c index cc8689ca33..971d381ede 100644 --- a/shared-bindings/time/__init__.c +++ b/shared-bindings/time/__init__.c @@ -31,7 +31,7 @@ #include "py/obj.h" #include "py/objnamedtuple.h" #include "py/runtime.h" -#include "lib/timeutils/timeutils.h" +#include "shared/timeutils/timeutils.h" #include "shared-bindings/rtc/__init__.h" #include "shared-bindings/time/__init__.h" #include "supervisor/shared/translate.h" @@ -39,12 +39,26 @@ //| """time and timing related functions //| //| The `time` module is a strict subset of the CPython `cpython:time` module. So, code -//| written in MicroPython will work in CPython but not necessarily the other +//| using `time` written in CircuitPython will work in CPython but not necessarily the other //| way around.""" //| //| def monotonic() -> float: //| """Returns an always increasing value of time with an unknown reference -//| point. Only use it to compare against other values from `monotonic`. +//| point. Only use it to compare against other values from `time.monotonic()`. +//| +//| On most boards, `time.monotonic()` converts a 64-bit millisecond tick counter +//| to a float. Floats on most boards are encoded in 30 bits internally, with +//| effectively 22 bits of precision. The float returned by `time.monotonic()` will +//| accurately represent time to millisecond precision only up to 2**22 milliseconds +//| (about 1.165 hours). +//| At that point it will start losing precision, and its value will change only +//| every second millisecond. At 2**23 milliseconds it will change every fourth +//| millisecond, and so forth. +//| +//| If you need more consistent precision, use `time.monotonic_ns()`, or `supervisor.ticks_ms()`. +//| `time.monotonic_ns()` is not available on boards without long integer support. +//| `supervisor.ticks_ms()` uses intervals of a millisecond, but wraps around, and is not +//| CPython-compatible. //| //| :return: the current monotonic time //| :rtype: float""" @@ -79,15 +93,15 @@ STATIC mp_obj_t time_sleep(mp_obj_t seconds_o) { MP_DEFINE_CONST_FUN_OBJ_1(time_sleep_obj, time_sleep); #if MICROPY_PY_COLLECTIONS -mp_obj_t struct_time_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { - mp_arg_check_num(n_args, kw_args, 1, 1, false); +mp_obj_t struct_time_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { + mp_arg_check_num(n_args, n_kw, 1, 1, false); size_t len; mp_obj_t *items; mp_obj_get_array(args[0], &len, &items); if (len != 9) { mp_raise_TypeError(translate("time.struct_time() takes a 9-sequence")); } - return namedtuple_make_new(type, len, items, NULL); + return namedtuple_make_new(type, len, 0, items); } //| class struct_time: @@ -159,7 +173,7 @@ mp_obj_t struct_time_from_tm(timeutils_struct_time_t *tm) { mp_obj_new_int(-1), // tm_isdst is not supported }; - return namedtuple_make_new((const mp_obj_type_t *)&struct_time_type_obj, 9, elems, NULL); + return namedtuple_make_new((const mp_obj_type_t *)&struct_time_type_obj, 9, 0, elems); }; void struct_time_to_tm(mp_obj_t t, timeutils_struct_time_t *tm) { @@ -216,7 +230,8 @@ STATIC mp_obj_t time_time(void) { MP_DEFINE_CONST_FUN_OBJ_0(time_time_obj, time_time); //| def monotonic_ns() -> int: -//| """Return the time of the monotonic clock, cannot go backward, in nanoseconds. +//| """Return the time of the monotonic clock, which cannot go backward, in nanoseconds. +//| Not available on boards without long integer support. //| //| :return: the current time //| :rtype: int""" @@ -330,3 +345,5 @@ const mp_obj_module_t time_module = { .base = { &mp_type_module }, .globals = (mp_obj_dict_t *)&time_module_globals, }; + +MP_REGISTER_MODULE(MP_QSTR_time, time_module, CIRCUITPY_TIME); diff --git a/shared-bindings/time/__init__.h b/shared-bindings/time/__init__.h index 4e716e9dfd..dba8229f26 100644 --- a/shared-bindings/time/__init__.h +++ b/shared-bindings/time/__init__.h @@ -30,7 +30,7 @@ #include #include -#include "lib/timeutils/timeutils.h" +#include "shared/timeutils/timeutils.h" extern mp_obj_t struct_time_from_tm(timeutils_struct_time_t *tm); extern void struct_time_to_tm(mp_obj_t t, timeutils_struct_time_t *tm); diff --git a/shared-bindings/touchio/TouchIn.c b/shared-bindings/touchio/TouchIn.c index 1879e80077..537ae29776 100644 --- a/shared-bindings/touchio/TouchIn.c +++ b/shared-bindings/touchio/TouchIn.c @@ -27,7 +27,7 @@ #include #include -#include "lib/utils/context_manager_helpers.h" +#include "shared/runtime/context_manager_helpers.h" #include "py/binary.h" #include "py/mphal.h" #include "py/nlr.h" @@ -59,9 +59,9 @@ //| ... //| STATIC mp_obj_t touchio_touchin_make_new(const mp_obj_type_t *type, - mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { + size_t n_args, size_t n_kw, const mp_obj_t *args) { // check number of arguments - mp_arg_check_num(n_args, kw_args, 1, 1, false); + mp_arg_check_num(n_args, n_kw, 1, 1, false); // 1st argument is the pin const mcu_pin_obj_t *pin = validate_obj_is_free_pin(args[0]); diff --git a/shared-bindings/traceback/__init__.c b/shared-bindings/traceback/__init__.c index 37ef921cca..7079148ba0 100644 --- a/shared-bindings/traceback/__init__.c +++ b/shared-bindings/traceback/__init__.c @@ -52,10 +52,7 @@ STATIC void traceback_exception_common(mp_print_t *print, mp_obj_t value, mp_obj } if (tb_obj != mp_const_none && print_tb) { - if (!mp_obj_is_type(tb_obj, &mp_type_traceback)) { - mp_raise_TypeError(translate("invalid traceback")); - } - exc.traceback = MP_OBJ_TO_PTR(tb_obj); + 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; } @@ -105,7 +102,7 @@ STATIC mp_obj_t traceback_format_exception(size_t n_args, const mp_obj_t *pos_ar return mp_obj_new_str_from_vstr(&mp_type_str, &vstr); } -STATIC MP_DEFINE_CONST_FUN_OBJ_KW(traceback_format_exception_obj, 3, traceback_format_exception); +STATIC MP_DEFINE_CONST_FUN_OBJ_KW(traceback_format_exception_obj, 0, traceback_format_exception); //| def print_exception(etype: Type[BaseException], value: BaseException, tb: TracebackType, //| limit: Optional[int] = None, file: Optional[io.FileIO] = None, chain: Optional[bool] = True) -> None: @@ -155,7 +152,7 @@ STATIC mp_obj_t traceback_print_exception(size_t n_args, const mp_obj_t *pos_arg traceback_exception_common(&print, args[ARG_value].u_obj, args[ARG_tb].u_obj, args[ARG_limit].u_obj); return mp_const_none; } -STATIC MP_DEFINE_CONST_FUN_OBJ_KW(traceback_print_exception_obj, 3, traceback_print_exception); +STATIC MP_DEFINE_CONST_FUN_OBJ_KW(traceback_print_exception_obj, 0, traceback_print_exception); STATIC const mp_rom_map_elem_t traceback_module_globals_table[] = { // module name diff --git a/shared-bindings/usb_hid/Device.c b/shared-bindings/usb_hid/Device.c index 44f3216b01..fe490091d7 100644 --- a/shared-bindings/usb_hid/Device.c +++ b/shared-bindings/usb_hid/Device.c @@ -50,7 +50,8 @@ //| Use a size of ``0`` for a report that is not an OUT report. //| "OUT" is with respect to the host. //| -//| ``report_ids``, ``in_report_lengths``, and ``out_report_lengths`` must all be the same length. +//| ``report_ids``, ``in_report_lengths``, and ``out_report_lengths`` must all have the +//| same number of elements. //| //| Here is an example of a `Device` with a descriptor that specifies two report IDs, 3 and 4. //| Report ID 3 sends an IN report of length 5, and receives an OUT report of length 6. @@ -81,7 +82,7 @@ //| Uses Report ID 3 for its IN report.""" //| -STATIC mp_obj_t usb_hid_device_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +STATIC mp_obj_t usb_hid_device_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { usb_hid_device_obj_t *self = m_new_obj(usb_hid_device_obj_t); self->base.type = &usb_hid_device_type; enum { ARG_report_descriptor, ARG_usage_page, ARG_usage, ARG_report_ids, ARG_in_report_lengths, ARG_out_report_lengths }; @@ -95,7 +96,7 @@ STATIC mp_obj_t usb_hid_device_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(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); mp_buffer_info_t descriptor_bufinfo; mp_get_buffer_raise(args[ARG_report_descriptor].u_obj, &descriptor_bufinfo, MP_BUFFER_READ); @@ -136,7 +137,7 @@ STATIC mp_obj_t usb_hid_device_make_new(const mp_obj_type_t *type, size_t n_args // It's not the actual argument that's out of range, but its elements. // But the error message is close enough. MP_OBJ_SMALL_INT_VALUE(mp_obj_subscr(report_ids, i_obj, MP_OBJ_SENTINEL)), - 1, 255, MP_QSTR_report_ids); + 0, 255, MP_QSTR_report_ids); in_report_lengths_array[i] = (uint8_t)mp_arg_validate_int_range( MP_OBJ_SMALL_INT_VALUE(mp_obj_subscr(in_report_lengths, i_obj, MP_OBJ_SENTINEL)), @@ -147,6 +148,10 @@ STATIC mp_obj_t usb_hid_device_make_new(const mp_obj_type_t *type, size_t n_args 0, 255, MP_QSTR_out_report_lengths); } + if (report_ids_array[0] == 0 && report_ids_count > 1) { + mp_raise_ValueError_varg(translate("%q with a report ID of 0 must be of length 1"), MP_QSTR_report_ids); + } + common_hal_usb_hid_device_construct( self, descriptor, usage_page, usage, report_ids_count, report_ids_array, in_report_lengths_array, out_report_lengths_array); return (mp_obj_t)self; @@ -185,10 +190,10 @@ STATIC mp_obj_t usb_hid_device_send_report(size_t n_args, const mp_obj_t *pos_ar common_hal_usb_hid_device_send_report(self, ((uint8_t *)bufinfo.buf), bufinfo.len, report_id); return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_KW(usb_hid_device_send_report_obj, 2, usb_hid_device_send_report); +MP_DEFINE_CONST_FUN_OBJ_KW(usb_hid_device_send_report_obj, 1, usb_hid_device_send_report); //| def get_last_received_report(self, report_id: Optional[int] = None) -> bytes: -//| """Get the last received HID OUT report for the given report ID. +//| """Get the last received HID OUT or feature report for the given report ID. //| The report ID may be omitted if there is no report ID, or only one report ID. //| Return `None` if nothing received. //| """ diff --git a/shared-bindings/usb_hid/__init__.c b/shared-bindings/usb_hid/__init__.c index d1b4357dc1..3922ded03c 100644 --- a/shared-bindings/usb_hid/__init__.c +++ b/shared-bindings/usb_hid/__init__.c @@ -40,6 +40,11 @@ //| """Tuple of all active HID device interfaces. //| The default set of devices is ``Device.KEYBOARD, Device.MOUSE, Device.CONSUMER_CONTROL``, //| On boards where `usb_hid` is disabled by default, `devices` is an empty tuple. +//| +//| If a boot device is enabled by `usb_hid.enable()`, *and* the host has requested a boot device, +//| the `devices` tuple is **replaced** when ``code.py`` starts with a single-element tuple +//| containing a `Device` that describes the boot device chosen (keyboard or mouse). +//| The request for a boot device overrides any other HID devices. //| """ //| @@ -60,7 +65,7 @@ STATIC mp_obj_t usb_hid_disable(void) { } MP_DEFINE_CONST_FUN_OBJ_0(usb_hid_disable_obj, usb_hid_disable); -//| def enable(devices: Optional[Sequence[Device]]) -> None: +//| def enable(devices: Optional[Sequence[Device]], boot_device: int = 0) -> None: //| """Specify which USB HID devices that will be available. //| Can be called in ``boot.py``, before USB is connected. //| @@ -68,15 +73,53 @@ MP_DEFINE_CONST_FUN_OBJ_0(usb_hid_disable_obj, usb_hid_disable); //| If `devices` is empty, HID is disabled. The order of the ``Devices`` //| may matter to the host. For instance, for MacOS, put the mouse device //| before any Gamepad or Digitizer HID device or else it will not work. +//| :param int boot_device: If non-zero, inform the host that support for a +//| a boot HID device is available. +//| If ``boot_device=1``, a boot keyboard is available. +//| If ``boot_device=2``, a boot mouse is available. No other values are allowed. +//| See below. //| //| If you enable too many devices at once, you will run out of USB endpoints. //| The number of available endpoints varies by microcontroller. //| CircuitPython will go into safe mode after running ``boot.py`` to inform you if //| not enough endpoints are available. +//| +//| **Boot Devices** +//| +//| Boot devices implement a fixed, predefined report descriptor, defined in +//| https://www.usb.org/sites/default/files/hid1_12.pdf, Appendix B. A USB host +//| can request to use the boot device if the USB device says it is available. +//| Usually only a BIOS or other kind of limited-functionality +//| host needs boot keyboard support. +//| +//| For example, to make a boot keyboard available, you can use this code:: +//| +//| usb_hid.enable((Device.KEYBOARD), boot_device=1) # 1 for a keyboard +//| +//| If the host requests the boot keyboard, the report descriptor provided by `Device.KEYBOARD` +//| will be ignored, and the predefined report descriptor will be used. +//| But if the host does not request the boot keyboard, +//| the descriptor provided by `Device.KEYBOARD` will be used. +//| +//| The HID boot device must usually be the first or only device presented by CircuitPython. +//| The HID device will be USB interface number 0. +//| To make sure it is the first device, disable other USB devices, including CDC and MSC (CIRCUITPY). +//| If you specify a non-zero ``boot_device``, and it is not the first device, CircuitPython +//| will enter safe mode to report this error. //| """ //| ... //| -STATIC mp_obj_t usb_hid_enable(mp_obj_t devices) { +STATIC mp_obj_t usb_hid_enable(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + enum { ARG_devices, ARG_boot_device }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_devices, MP_ARG_REQUIRED | MP_ARG_OBJ }, + { MP_QSTR_boot_device, MP_ARG_INT, {.u_int = 0} }, + }; + + mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; + mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + + mp_obj_t devices = args[ARG_devices].u_obj; const mp_int_t len = mp_obj_get_int(mp_obj_len(devices)); for (mp_int_t i = 0; i < len; i++) { mp_obj_t item = mp_obj_subscr(devices, MP_OBJ_NEW_SMALL_INT(i), MP_OBJ_SENTINEL); @@ -85,21 +128,44 @@ STATIC mp_obj_t usb_hid_enable(mp_obj_t devices) { } } - if (!common_hal_usb_hid_enable(devices)) { + uint8_t boot_device = + (uint8_t)mp_arg_validate_int_range(args[ARG_boot_device].u_int, 0, 2, MP_QSTR_boot_device); + + if (!common_hal_usb_hid_enable(devices, boot_device)) { mp_raise_RuntimeError(translate("Cannot change USB devices now")); } return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_1(usb_hid_enable_obj, usb_hid_enable); +MP_DEFINE_CONST_FUN_OBJ_KW(usb_hid_enable_obj, 1, usb_hid_enable); + +//| def get_boot_device() -> int: +//| """ +//| :return: the boot device requested by the host, if any. +//| Returns 0 if the host did not request a boot device, or if `usb_hid.enable()` +//| was called with ``boot_device=0``, the default, which disables boot device support. +//| If the host did request a boot device, +//| returns the value of ``boot_device`` set in `usb_hid.enable()`: +//| ``1`` for a boot keyboard, or ``2`` for boot mouse. +//| However, the standard devices provided by CircuitPython, `Device.KEYBOARD` and `Device.MOUSE`, +//| describe reports that match the boot device reports, so you don't need to check this +//| if you are using those devices. +//| :rtype int: +//| """ +//| +STATIC mp_obj_t usb_hid_get_boot_device(void) { + return MP_OBJ_NEW_SMALL_INT(common_hal_usb_hid_get_boot_device()); +} +MP_DEFINE_CONST_FUN_OBJ_0(usb_hid_get_boot_device_obj, usb_hid_get_boot_device); // usb_hid.devices is set once the usb devices are determined, after boot.py runs. STATIC mp_map_elem_t usb_hid_module_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_usb_hid) }, - { MP_ROM_QSTR(MP_QSTR_Device), MP_OBJ_FROM_PTR(&usb_hid_device_type) }, - { MP_ROM_QSTR(MP_QSTR_devices), mp_const_none }, - { MP_ROM_QSTR(MP_QSTR_disable), MP_OBJ_FROM_PTR(&usb_hid_disable_obj) }, - { MP_ROM_QSTR(MP_QSTR_enable), MP_OBJ_FROM_PTR(&usb_hid_enable_obj) }, + { MP_ROM_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_usb_hid) }, + { MP_ROM_QSTR(MP_QSTR_Device), MP_OBJ_FROM_PTR(&usb_hid_device_type) }, + { MP_ROM_QSTR(MP_QSTR_devices), mp_const_none }, + { MP_ROM_QSTR(MP_QSTR_disable), MP_OBJ_FROM_PTR(&usb_hid_disable_obj) }, + { MP_ROM_QSTR(MP_QSTR_enable), MP_OBJ_FROM_PTR(&usb_hid_enable_obj) }, + { MP_ROM_QSTR(MP_QSTR_get_boot_device), MP_OBJ_FROM_PTR(&usb_hid_get_boot_device_obj) }, }; STATIC MP_DEFINE_MUTABLE_DICT(usb_hid_module_globals, usb_hid_module_globals_table); diff --git a/shared-bindings/usb_hid/__init__.h b/shared-bindings/usb_hid/__init__.h index d5fc7743a3..feaeed2545 100644 --- a/shared-bindings/usb_hid/__init__.h +++ b/shared-bindings/usb_hid/__init__.h @@ -36,6 +36,7 @@ extern mp_obj_tuple_t common_hal_usb_hid_devices; void usb_hid_set_devices(mp_obj_t devices); bool common_hal_usb_hid_disable(void); -bool common_hal_usb_hid_enable(const mp_obj_t devices_seq); +bool common_hal_usb_hid_enable(const mp_obj_t devices_seq, uint8_t boot_device); +uint8_t common_hal_usb_hid_get_boot_device(void); #endif // SHARED_BINDINGS_USB_HID_H diff --git a/shared-bindings/vectorio/Circle.c b/shared-bindings/vectorio/Circle.c index abcbccd856..43845937c4 100644 --- a/shared-bindings/vectorio/Circle.c +++ b/shared-bindings/vectorio/Circle.c @@ -20,7 +20,7 @@ //| :param int x: Initial x position of the axis. //| :param int y: Initial y position of the axis.""" //| -static mp_obj_t vectorio_circle_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +static mp_obj_t vectorio_circle_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_pixel_shader, ARG_radius, ARG_x, ARG_y }; static const mp_arg_t allowed_args[] = { { MP_QSTR_pixel_shader, MP_ARG_OBJ | MP_ARG_KW_ONLY | MP_ARG_REQUIRED }, @@ -29,7 +29,7 @@ static mp_obj_t vectorio_circle_make_new(const mp_obj_type_t *type, size_t n_arg { MP_QSTR_y, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 0} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); mp_int_t radius = args[ARG_radius].u_int; if (radius < 1) { diff --git a/shared-bindings/vectorio/Polygon.c b/shared-bindings/vectorio/Polygon.c index 8ce19eb8db..d1078b2d2d 100644 --- a/shared-bindings/vectorio/Polygon.c +++ b/shared-bindings/vectorio/Polygon.c @@ -27,7 +27,7 @@ //| :param int x: Initial screen x position of the 0,0 origin in the points list. //| :param int y: Initial screen y position of the 0,0 origin in the points list.""" //| -static mp_obj_t vectorio_polygon_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +static mp_obj_t vectorio_polygon_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_pixel_shader, ARG_points_list, ARG_x, ARG_y }; static const mp_arg_t allowed_args[] = { { MP_QSTR_pixel_shader, MP_ARG_OBJ | MP_ARG_KW_ONLY | MP_ARG_REQUIRED }, @@ -36,16 +36,14 @@ static mp_obj_t vectorio_polygon_make_new(const mp_obj_type_t *type, size_t n_ar { MP_QSTR_y, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 0} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - if (!mp_obj_is_type(args[ARG_points_list].u_obj, &mp_type_list)) { - mp_raise_TypeError_varg(translate("%q list must be a list"), MP_QSTR_point); - } + mp_obj_t points_list = mp_arg_validate_type(args[ARG_points_list].u_obj, &mp_type_list, MP_QSTR_points); vectorio_polygon_t *self = m_new_obj(vectorio_polygon_t); self->base.type = &vectorio_polygon_type; - common_hal_vectorio_polygon_construct(self, args[ARG_points_list].u_obj); + common_hal_vectorio_polygon_construct(self, points_list); // VectorShape parts mp_obj_t pixel_shader = args[ARG_pixel_shader].u_obj; diff --git a/shared-bindings/vectorio/Rectangle.c b/shared-bindings/vectorio/Rectangle.c index 176cbaba7c..287ae9d408 100644 --- a/shared-bindings/vectorio/Rectangle.c +++ b/shared-bindings/vectorio/Rectangle.c @@ -19,7 +19,7 @@ //| :param int x: Initial x position of the top left corner. //| :param int y: Initial y position of the top left corner.""" //| -static mp_obj_t vectorio_rectangle_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +static mp_obj_t vectorio_rectangle_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_pixel_shader, ARG_width, ARG_height, ARG_x, ARG_y }; static const mp_arg_t allowed_args[] = { { MP_QSTR_pixel_shader, MP_ARG_OBJ | MP_ARG_KW_ONLY | MP_ARG_REQUIRED }, @@ -29,7 +29,7 @@ static mp_obj_t vectorio_rectangle_make_new(const mp_obj_type_t *type, size_t n_ { MP_QSTR_y, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 0} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); mp_int_t width = args[ARG_width].u_int; if (width < 1) { diff --git a/shared-bindings/vectorio/VectorShape.c b/shared-bindings/vectorio/VectorShape.c index c9cbf0a114..d5d12ec1cd 100644 --- a/shared-bindings/vectorio/VectorShape.c +++ b/shared-bindings/vectorio/VectorShape.c @@ -10,7 +10,7 @@ #include -#include "lib/utils/context_manager_helpers.h" +#include "shared/runtime/context_manager_helpers.h" #include "py/binary.h" #include "py/objproperty.h" diff --git a/shared-bindings/watchdog/__init__.h b/shared-bindings/watchdog/__init__.h index b5a0ad71d1..0921141129 100644 --- a/shared-bindings/watchdog/__init__.h +++ b/shared-bindings/watchdog/__init__.h @@ -27,6 +27,9 @@ #ifndef MICROPY_INCLUDED_SHARED_BINDINGS_WATCHDOG___INIT___H #define MICROPY_INCLUDED_SHARED_BINDINGS_WATCHDOG___INIT___H +#include "py/obj.h" +#include "py/objexcept.h" + extern const mp_obj_module_t watchdog_module; extern mp_obj_exception_t mp_watchdog_timeout_exception; extern const mp_obj_type_t mp_type_WatchDogTimeout; diff --git a/shared-module/_bleio/ScanResults.c b/shared-module/_bleio/ScanResults.c index 25ce387d07..e5b5525579 100644 --- a/shared-module/_bleio/ScanResults.c +++ b/shared-module/_bleio/ScanResults.c @@ -28,7 +28,7 @@ #include -#include "lib/utils/interrupt_char.h" +#include "shared/runtime/interrupt_char.h" #include "py/objstr.h" #include "py/runtime.h" #include "shared-bindings/_bleio/ScanEntry.h" diff --git a/shared-module/_stage/Layer.c b/shared-module/_stage/Layer.c index df2b27fa13..6d06e7261f 100644 --- a/shared-module/_stage/Layer.c +++ b/shared-module/_stage/Layer.c @@ -29,7 +29,7 @@ // Get the color of the pixel on the layer. -uint16_t get_layer_pixel(layer_obj_t *layer, uint16_t x, uint16_t y) { +uint16_t get_layer_pixel(layer_obj_t *layer, int16_t x, int16_t y) { // Shift by the layer's position offset. x -= layer->x; diff --git a/shared-module/_stage/Layer.h b/shared-module/_stage/Layer.h index 17d101263f..4233847641 100644 --- a/shared-module/_stage/Layer.h +++ b/shared-module/_stage/Layer.h @@ -43,6 +43,6 @@ typedef struct { uint8_t rotation; } layer_obj_t; -uint16_t get_layer_pixel(layer_obj_t *layer, uint16_t x, uint16_t y); +uint16_t get_layer_pixel(layer_obj_t *layer, int16_t x, int16_t y); #endif // MICROPY_INCLUDED_SHARED_MODULE__STAGE_LAYER diff --git a/shared-module/_stage/Text.c b/shared-module/_stage/Text.c index 91223f5258..a803b85de4 100644 --- a/shared-module/_stage/Text.c +++ b/shared-module/_stage/Text.c @@ -29,7 +29,7 @@ // Get the color of the pixel on the text. -uint16_t get_text_pixel(text_obj_t *text, uint16_t x, uint16_t y) { +uint16_t get_text_pixel(text_obj_t *text, int16_t x, int16_t y) { // Shift by the text's position offset. x -= text->x; diff --git a/shared-module/_stage/Text.h b/shared-module/_stage/Text.h index b263fc7108..dd75465d17 100644 --- a/shared-module/_stage/Text.h +++ b/shared-module/_stage/Text.h @@ -41,6 +41,6 @@ typedef struct { uint8_t width, height; } text_obj_t; -uint16_t get_text_pixel(text_obj_t *text, uint16_t x, uint16_t y); +uint16_t get_text_pixel(text_obj_t *text, int16_t x, int16_t y); #endif // MICROPY_INCLUDED_SHARED_MODULE__STAGE_TEXT diff --git a/shared-module/_stage/__init__.c b/shared-module/_stage/__init__.c index 06a12aa0a7..7ec640bc6e 100644 --- a/shared-module/_stage/__init__.c +++ b/shared-module/_stage/__init__.c @@ -31,7 +31,10 @@ #include "shared-bindings/_stage/Text.h" -void render_stage(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, +void render_stage( + uint16_t x0, uint16_t y0, + uint16_t x1, uint16_t y1, + int16_t vx, int16_t vy, mp_obj_t *layers, size_t layers_size, uint16_t *buffer, size_t buffer_size, displayio_display_obj_t *display, @@ -39,13 +42,14 @@ void render_stage(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, displayio_area_t area; - area.x1 = x0; - area.y1 = y0; - area.x2 = x1; - area.y2 = y1; + area.x1 = x0 * scale; + area.y1 = y0 * scale; + area.x2 = x1 * scale; + area.y2 = y1 * scale; displayio_display_core_set_region_to_update( &display->core, display->set_column_command, display->set_row_command, - NO_COMMAND, NO_COMMAND, display->data_as_commands, false, &area, display->SH1107_addressing); + NO_COMMAND, NO_COMMAND, display->data_as_commands, false, &area, + display->SH1107_addressing); while (!displayio_display_core_begin_transaction(&display->core)) { RUN_BACKGROUND_TASKS; @@ -54,9 +58,9 @@ void render_stage(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, CHIP_SELECT_TOGGLE_EVERY_BYTE, &display->write_ram_command, 1); size_t index = 0; - for (uint16_t y = y0; y < y1; ++y) { + for (int16_t y = y0 + vy; y < y1 + vy; ++y) { for (uint8_t yscale = 0; yscale < scale; ++yscale) { - for (uint16_t x = x0; x < x1; ++x) { + for (int16_t x = x0 + vx; x < x1 + vx; ++x) { uint16_t c = TRANSPARENT; for (size_t layer = 0; layer < layers_size; ++layer) { layer_obj_t *obj = MP_OBJ_TO_PTR(layers[layer]); diff --git a/shared-module/_stage/__init__.h b/shared-module/_stage/__init__.h index 5cbaa235b6..596752bee5 100644 --- a/shared-module/_stage/__init__.h +++ b/shared-module/_stage/__init__.h @@ -34,7 +34,10 @@ #define TRANSPARENT (0x1ff8) -void render_stage(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, +void render_stage( + uint16_t x0, uint16_t y0, + uint16_t x1, uint16_t y1, + int16_t vx, int16_t vy, mp_obj_t *layers, size_t layers_size, uint16_t *buffer, size_t buffer_size, displayio_display_obj_t *display, diff --git a/shared-module/adafruit_bus_device/I2CDevice.c b/shared-module/adafruit_bus_device/I2CDevice.c index 51c5073a74..942b132c3e 100644 --- a/shared-module/adafruit_bus_device/I2CDevice.c +++ b/shared-module/adafruit_bus_device/I2CDevice.c @@ -29,7 +29,7 @@ #include "py/mperrno.h" #include "py/nlr.h" #include "py/runtime.h" -#include "lib/utils/interrupt_char.h" +#include "shared/runtime/interrupt_char.h" void common_hal_adafruit_bus_device_i2cdevice_construct(adafruit_bus_device_i2cdevice_obj_t *self, mp_obj_t *i2c, uint8_t device_address) { self->i2c = i2c; diff --git a/shared-module/atexit/__init__.h b/shared-module/atexit/__init__.h index befccb3ea8..d88d066ded 100644 --- a/shared-module/atexit/__init__.h +++ b/shared-module/atexit/__init__.h @@ -28,7 +28,7 @@ #define MICROPY_INCLUDED_SHARED_MODULE_ATEXIT___INIT___H #include "py/obj.h" -#include "lib/utils/pyexec.h" +#include "shared/runtime/pyexec.h" typedef struct _atexit_callback_t { size_t n_pos, n_kw; diff --git a/shared-module/displayio/ColorConverter.c b/shared-module/displayio/ColorConverter.c index be5b7d31a7..228d63d03b 100644 --- a/shared-module/displayio/ColorConverter.c +++ b/shared-module/displayio/ColorConverter.c @@ -145,15 +145,10 @@ void common_hal_displayio_colorconverter_make_opaque(displayio_colorconverter_t self->transparent_color = NO_TRANSPARENT_COLOR; } -void displayio_colorconverter_convert(displayio_colorconverter_t *self, const _displayio_colorspace_t *colorspace, const displayio_input_pixel_t *input_pixel, displayio_output_pixel_t *output_color) { - uint32_t pixel = input_pixel->pixel; - if (self->transparent_color == pixel) { - output_color->opaque = false; - return; - } - - switch (self->input_colorspace) { +// Convert a single input pixel to RGB888 +uint32_t displayio_colorconverter_convert_pixel(displayio_colorspace_t colorspace, uint32_t pixel) { + switch (colorspace) { case DISPLAYIO_COLORSPACE_RGB565_SWAPPED: pixel = __builtin_bswap16(pixel); MP_FALLTHROUGH; @@ -198,10 +193,31 @@ void displayio_colorconverter_convert(displayio_colorconverter_t *self, const _d } break; + default: case DISPLAYIO_COLORSPACE_RGB888: break; + + case DISPLAYIO_COLORSPACE_L8: { + uint32_t l8 = pixel & 0xff; + pixel = l8 * 0x010101; + } + break; } + return pixel; +} + +void displayio_colorconverter_convert(displayio_colorconverter_t *self, const _displayio_colorspace_t *colorspace, const displayio_input_pixel_t *input_pixel, displayio_output_pixel_t *output_color) { + uint32_t pixel = input_pixel->pixel; + + if (self->transparent_color == pixel) { + output_color->opaque = false; + return; + } + + pixel = displayio_colorconverter_convert_pixel(self->input_colorspace, pixel); + + if (self->dither) { uint8_t randr = (displayio_colorconverter_dither_noise_2(input_pixel->tile_x,input_pixel->tile_y)); uint8_t randg = (displayio_colorconverter_dither_noise_2(input_pixel->tile_x + 33,input_pixel->tile_y)); diff --git a/shared-module/displayio/__init__.c b/shared-module/displayio/__init__.c index d264531c99..e4a4965368 100644 --- a/shared-module/displayio/__init__.c +++ b/shared-module/displayio/__init__.c @@ -3,7 +3,7 @@ #include "shared-module/displayio/__init__.h" -#include "lib/utils/interrupt_char.h" +#include "shared/runtime/interrupt_char.h" #include "py/reload.h" #include "py/runtime.h" #include "shared-bindings/board/__init__.h" diff --git a/shared-module/fontio/BuiltinFont.c b/shared-module/fontio/BuiltinFont.c index b77a6a1c8b..cb5b7f9cb1 100644 --- a/shared-module/fontio/BuiltinFont.c +++ b/shared-module/fontio/BuiltinFont.c @@ -75,5 +75,5 @@ mp_obj_t common_hal_fontio_builtinfont_get_glyph(const fontio_builtinfont_t *sel MP_OBJ_NEW_SMALL_INT(self->width), MP_OBJ_NEW_SMALL_INT(0) }; - return namedtuple_make_new((const mp_obj_type_t *)&fontio_glyph_type, 8, field_values, NULL); + return namedtuple_make_new((const mp_obj_type_t *)&fontio_glyph_type, 8, 0, field_values); } diff --git a/shared-module/getpass/__init__.c b/shared-module/getpass/__init__.c index f7ab96c378..8f16d75b53 100644 --- a/shared-module/getpass/__init__.c +++ b/shared-module/getpass/__init__.c @@ -25,7 +25,7 @@ */ #include "py/mphal.h" -#include "lib/mp-readline/readline.h" +#include "shared/readline/readline.h" #include "shared-module/getpass/__init__.h" mp_obj_t shared_module_getpass_getpass(const char *prompt, mp_print_t *print) { diff --git a/shared-module/gifio/GifWriter.c b/shared-module/gifio/GifWriter.c new file mode 100644 index 0000000000..f8c2c7d3ce --- /dev/null +++ b/shared-module/gifio/GifWriter.c @@ -0,0 +1,283 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Jeff Epler for Adafruit Industries + * Copyright (c) 2013-2021 Ibrahim Abdelkader + * Copyright (c) 2013-2021 Kwabena W. Agyeman + * + * 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/runtime.h" + +#include "shared-module/gifio/GifWriter.h" +#include "shared-bindings/gifio/GifWriter.h" +#include "shared-bindings/displayio/ColorConverter.h" +#include "shared-bindings/util.h" + +#define BLOCK_SIZE (126) // (2^7) - 2 // (DO NOT CHANGE!) + +static void handle_error(gifio_gifwriter_t *self) { + if (self->error != 0) { + mp_raise_OSError(self->error); + } +} + +static void flush_data(gifio_gifwriter_t *self) { + if (self->cur == 0) { + return; + } + int error = 0; + self->file_proto->write(self->file, self->data, self->cur, &error); + self->cur = 0; + if (error != 0) { + self->error = error; + } +} + +// These "write" calls _MUST_ have enough buffer space available! This is +// ensured by allocating the proper buffer size in construct. +static void write_data(gifio_gifwriter_t *self, const void *data, size_t size) { + assert(self->cur + size <= self->size); + memcpy(self->data + self->cur, data, size); + self->cur += size; +} + +static void write_byte(gifio_gifwriter_t *self, uint8_t value) { + write_data(self, &value, sizeof(value)); +} + +static void write_long(gifio_gifwriter_t *self, uint32_t value) { + write_data(self, &value, sizeof(value)); +} + +static void write_word(gifio_gifwriter_t *self, uint16_t value) { + write_data(self, &value, sizeof(value)); +} + +void shared_module_gifio_gifwriter_construct(gifio_gifwriter_t *self, mp_obj_t *file, int width, int height, displayio_colorspace_t colorspace, bool loop, bool dither, bool own_file) { + self->file = file; + self->file_proto = mp_proto_get_or_throw(MP_QSTR_protocol_stream, file); + if (self->file_proto->is_text) { + mp_raise_TypeError(translate("file must be a file opened in byte mode")); + } + self->width = width; + self->height = height; + self->colorspace = colorspace; + self->dither = dither; + self->own_file = own_file; + + size_t nblocks = (width * height + 125) / 126; + self->size = nblocks * 128 + 4; + self->data = gc_alloc(self->size, 0, false); + self->cur = 0; + self->error = 0; + + write_data(self, "GIF89a", 6); + write_word(self, width); + write_word(self, height); + write_data(self, (uint8_t []) {0xF6, 0x00, 0x00}, 3); + + switch (colorspace) { + case DISPLAYIO_COLORSPACE_RGB565: + case DISPLAYIO_COLORSPACE_RGB565_SWAPPED: + case DISPLAYIO_COLORSPACE_BGR565: + case DISPLAYIO_COLORSPACE_BGR565_SWAPPED: + case DISPLAYIO_COLORSPACE_L8: + break; + + default: + mp_raise_TypeError(translate("unsupported colorspace for GifWriter")); + } + + bool color = (colorspace != DISPLAYIO_COLORSPACE_L8); + + bool bgr = (colorspace == DISPLAYIO_COLORSPACE_BGR565 || colorspace == DISPLAYIO_COLORSPACE_BGR565_SWAPPED); + self->byteswap = (colorspace == DISPLAYIO_COLORSPACE_RGB565_SWAPPED || colorspace == DISPLAYIO_COLORSPACE_BGR565_SWAPPED); + + if (color) { + for (int i = 0; i < 128; i++) { + int red = (int)(((((i & 0x60) >> 5) * 255) + 1.5) / 3); + int green = (int)(((((i & 0x1C) >> 2) * 255) + 3.5) / 7); + int blue = (int)((((i & 0x3) * 255) + 1.5) / 3); + if (bgr) { + write_data(self, (uint8_t []) {blue, red, green}, 3); + } else { + write_data(self, (uint8_t []) {red, green, blue}, 3); + } + } + } else { + for (int i = 0; i < 128; i++) { + int gray = (int)(((i * 255) + 63.5) / 127); + write_data(self, (uint8_t []) {gray, gray, gray}, 3); + } + } + + if (loop) { + write_data(self, (uint8_t []) {'!', 0xFF, 0x0B}, 3); + write_data(self, "NETSCAPE2.0", 11); + write_data(self, (uint8_t []) {0x03, 0x01, 0x00, 0x00, 0x00}, 5); + } + + flush_data(self); + handle_error(self); +} + +bool shared_module_gifio_gifwriter_deinited(gifio_gifwriter_t *self) { + return !self->file; +} + +void shared_module_gifio_gifwriter_check_for_deinit(gifio_gifwriter_t *self) { + if (shared_module_gifio_gifwriter_deinited(self)) { + raise_deinited_error(); + } +} + +void shared_module_gifio_gifwriter_deinit(gifio_gifwriter_t *self) { + if (!shared_module_gifio_gifwriter_deinited(self)) { + shared_module_gifio_gifwriter_close(self); + } +} + +static const uint8_t rb_bayer[4][4] = { + { 0, 33, 8, 42}, + {50, 16, 58, 25}, + {12, 46, 4, 37}, + {63, 29, 54, 21} +}; + +static const uint8_t g_bayer[4][4] = { + { 0, 16, 4, 20}, + {24, 8, 28, 12}, + { 6, 22, 2, 18}, + {31, 14, 26, 10} +}; + +void shared_module_gifio_gifwriter_add_frame(gifio_gifwriter_t *self, const mp_buffer_info_t *bufinfo, int16_t delay) { + if (delay) { + write_data(self, (uint8_t []) {'!', 0xF9, 0x04, 0x04}, 4); + write_word(self, delay); + write_word(self, 0); // end + } + + write_byte(self, 0x2C); + write_long(self, 0); + write_word(self, self->width); + write_word(self, self->height); + write_data(self, (uint8_t []) {0x00, 0x07}, 2); // 7-bits + + int pixel_count = self->width * self->height; + int blocks = (pixel_count + BLOCK_SIZE - 1) / BLOCK_SIZE; + + uint8_t *data = self->data + self->cur; + + if (self->colorspace == DISPLAYIO_COLORSPACE_L8) { + mp_get_index(&mp_type_memoryview, bufinfo->len, MP_OBJ_NEW_SMALL_INT(pixel_count - 1), false); + + uint8_t *pixels = bufinfo->buf; + for (int i = 0; i < blocks; i++) { + assert(pixel_count >= 0); + int block_size = MIN(BLOCK_SIZE, pixel_count); + pixel_count -= block_size; + *data++ = 1 + block_size; + *data++ = 0x80; + for (int j = 0; j < block_size; j++) { + *data++ = (*pixels++) >> 1; + } + } + } else if (!self->dither) { + mp_get_index(&mp_type_memoryview, bufinfo->len, MP_OBJ_NEW_SMALL_INT(2 * pixel_count - 1), false); + + uint16_t *pixels = bufinfo->buf; + for (int i = 0; i < blocks; i++) { + int block_size = MIN(BLOCK_SIZE, pixel_count); + pixel_count -= block_size; + + *data++ = 1 + block_size; + *data++ = 0x80; + for (int j = 0; j < block_size; j++) { + int pixel = *pixels++; + if (self->byteswap) { + pixel = __builtin_bswap16(pixel); + } + int red = (pixel >> (11 + (5 - 2))) & 0x3; + int green = (pixel >> (5 + (6 - 3))) & 0x7; + int blue = (pixel >> (0 + (5 - 2))) & 0x3; + *data++ = (red << 5) | (green << 2) | blue; + } + } + } else { + mp_get_index(&mp_type_memoryview, bufinfo->len, MP_OBJ_NEW_SMALL_INT(2 * pixel_count - 1), false); + + uint16_t *pixels = bufinfo->buf; + int x = 0, y = 0; + for (int i = 0; i < blocks; i++) { + int block_size = MIN(BLOCK_SIZE, pixel_count); + pixel_count -= block_size; + + *data++ = 1 + block_size; + *data++ = 0x80; + for (int j = 0; j < block_size; j++) { + int pixel = *pixels++; + if (self->byteswap) { + pixel = __builtin_bswap16(pixel); + } + int red = (pixel >> 8) & 0xf8; + int green = (pixel >> 3) & 0xfc; + int blue = (pixel << 3) & 0xf8; + + red = MAX(0, red - rb_bayer[x % 4][y % 4]); + green = MAX(0, green - g_bayer[x % 4][(y + 2) % 4]); + blue = MAX(0, blue - rb_bayer[(x + 2) % 4][y % 4]); + x++; + if (x == self->width) { + x = 0; + y++; + } + + *data++ = ((red >> 1) & 0x60) | ((green >> 3) & 0x1c) | (blue >> 6); + } + } + } + + self->cur = data - self->data; + + write_data(self, (uint8_t []) {0x01, 0x81, 0x00}, 3); // end code + flush_data(self); + handle_error(self); +} + +void shared_module_gifio_gifwriter_close(gifio_gifwriter_t *self) { + write_byte(self, ';'); + flush_data(self); + + int error = 0; + self->file_proto->ioctl(self->file, self->own_file ? MP_STREAM_CLOSE : MP_STREAM_FLUSH, 0, &error); + self->file = NULL; + + if (error != 0) { + self->error = error; + } + handle_error(self); +} diff --git a/shared-module/gifio/GifWriter.h b/shared-module/gifio/GifWriter.h new file mode 100644 index 0000000000..5ed57bb022 --- /dev/null +++ b/shared-module/gifio/GifWriter.h @@ -0,0 +1,45 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Jeff Epler 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. + */ + +#pragma once + +#include "py/obj.h" +#include "py/stream.h" +#include "shared-bindings/displayio/__init__.h" + +typedef struct gifio_gifwriter { + mp_obj_base_t base; + mp_obj_t *file; + const mp_stream_p_t *file_proto; + displayio_colorspace_t colorspace; + int width, height; + int error; + uint8_t *data; + size_t cur, size; + bool own_file; + bool byteswap; + bool dither; +} gifio_gifwriter_t; diff --git a/shared-module/gifio/__init__.c b/shared-module/gifio/__init__.c new file mode 100644 index 0000000000..e69de29bb2 diff --git a/shared-module/gifio/__init__.h b/shared-module/gifio/__init__.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/shared-module/imagecapture/ParallelImageCapture.c b/shared-module/imagecapture/ParallelImageCapture.c new file mode 100644 index 0000000000..346bc76479 --- /dev/null +++ b/shared-module/imagecapture/ParallelImageCapture.c @@ -0,0 +1,44 @@ +/* + * This file is part of the Micro Python 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. + */ + +#include "shared-bindings/imagecapture/ParallelImageCapture.h" +#include "py/runtime.h" + +// If the continuous-capture mode isn't supported, then this default (weak) implementation will raise exceptions for you +__attribute__((weak)) +void common_hal_imagecapture_parallelimagecapture_continuous_capture_start(imagecapture_parallelimagecapture_obj_t *self, mp_obj_t buffer1, mp_obj_t buffer2) { + mp_raise_NotImplementedError(translate("This microcontroller does not support continuous capture.")); +} + +__attribute__((weak)) +void common_hal_imagecapture_parallelimagecapture_continuous_capture_stop(imagecapture_parallelimagecapture_obj_t *self) { + mp_raise_NotImplementedError(translate("This microcontroller does not support continuous capture.")); +} + +__attribute__((weak)) +mp_obj_t common_hal_imagecapture_parallelimagecapture_continuous_capture_get_frame(imagecapture_parallelimagecapture_obj_t *self) { + mp_raise_NotImplementedError(translate("This microcontroller does not support continuous capture.")); +} diff --git a/shared-module/qrio/QRDecoder.c b/shared-module/qrio/QRDecoder.c index 227f3b39b4..26a609f215 100644 --- a/shared-module/qrio/QRDecoder.c +++ b/shared-module/qrio/QRDecoder.c @@ -130,7 +130,7 @@ mp_obj_t shared_module_qrio_qrdecoder_decode(qrdecoder_qrdecoder_obj_t *self, co mp_obj_new_bytes(self->data.payload, self->data.payload_len), data_type(self->data.data_type), }; - mp_obj_t code_obj = namedtuple_make_new((const mp_obj_type_t *)&qrio_qrinfo_type_obj, 2, elems, NULL); + mp_obj_t code_obj = namedtuple_make_new((const mp_obj_type_t *)&qrio_qrinfo_type_obj, 2, 0, elems); mp_obj_list_append(result, code_obj); } return result; diff --git a/shared-module/rotaryio/IncrementalEncoder.c b/shared-module/rotaryio/IncrementalEncoder.c index 330895606e..89dea01cfe 100644 --- a/shared-module/rotaryio/IncrementalEncoder.c +++ b/shared-module/rotaryio/IncrementalEncoder.c @@ -30,26 +30,25 @@ void shared_module_softencoder_state_init(rotaryio_incrementalencoder_obj_t *self, uint8_t quiescent_state) { self->state = quiescent_state; - self->quarter_count = 0; + self->sub_count = 0; common_hal_rotaryio_incrementalencoder_set_position(self, 0); } void shared_module_softencoder_state_update(rotaryio_incrementalencoder_obj_t *self, uint8_t new_state) { - #define BAD 7 static const int8_t transitions[16] = { 0, // 00 -> 00 no movement -1, // 00 -> 01 3/4 ccw (11 detent) or 1/4 ccw (00 at detent) +1, // 00 -> 10 3/4 cw or 1/4 cw - BAD, // 00 -> 11 non-Gray-code transition + 0, // 00 -> 11 non-Gray-code transition +1, // 01 -> 00 2/4 or 4/4 cw 0, // 01 -> 01 no movement - BAD, // 01 -> 10 non-Gray-code transition + 0, // 01 -> 10 non-Gray-code transition -1, // 01 -> 11 4/4 or 2/4 ccw -1, // 10 -> 00 2/4 or 4/4 ccw - BAD, // 10 -> 01 non-Gray-code transition + 0, // 10 -> 01 non-Gray-code transition 0, // 10 -> 10 no movement +1, // 10 -> 11 4/4 or 2/4 cw - BAD, // 11 -> 00 non-Gray-code transition + 0, // 11 -> 00 non-Gray-code transition +1, // 11 -> 01 1/4 or 3/4 cw -1, // 11 -> 10 1/4 or 3/4 ccw 0, // 11 -> 11 no movement @@ -59,20 +58,16 @@ void shared_module_softencoder_state_update(rotaryio_incrementalencoder_obj_t *s int idx = (self->state << 2) | new_state; self->state = new_state; - int8_t quarter_incr = transitions[idx]; - if (quarter_incr == BAD) { - // Missed a transition. We don't know which way we're going, so do nothing. - return; - } + int8_t sub_incr = transitions[idx]; - self->quarter_count += quarter_incr; + self->sub_count += sub_incr; - if (self->quarter_count >= 4) { + if (self->sub_count >= self->divisor) { self->position += 1; - self->quarter_count = 0; - } else if (self->quarter_count <= -4) { + self->sub_count = 0; + } else if (self->sub_count <= -self->divisor) { self->position -= 1; - self->quarter_count = 0; + self->sub_count = 0; } } @@ -83,4 +78,12 @@ mp_int_t common_hal_rotaryio_incrementalencoder_get_position(rotaryio_incrementa void common_hal_rotaryio_incrementalencoder_set_position(rotaryio_incrementalencoder_obj_t *self, mp_int_t position) { self->position = position; } + +mp_int_t common_hal_rotaryio_incrementalencoder_get_divisor(rotaryio_incrementalencoder_obj_t *self) { + return self->divisor; +} + +void common_hal_rotaryio_incrementalencoder_set_divisor(rotaryio_incrementalencoder_obj_t *self, mp_int_t divisor) { + self->divisor = divisor; +} #endif diff --git a/shared-module/sdcardio/SDCard.c b/shared-module/sdcardio/SDCard.c index c3263fa0dc..f5ab97ebe5 100644 --- a/shared-module/sdcardio/SDCard.c +++ b/shared-module/sdcardio/SDCard.c @@ -93,19 +93,53 @@ static uint8_t CRC7(const uint8_t *data, uint8_t n) { } #define READY_TIMEOUT_NS (300 * 1000 * 1000) // 300ms -STATIC void wait_for_ready(sdcardio_sdcard_obj_t *self) { +STATIC int wait_for_ready(sdcardio_sdcard_obj_t *self) { uint64_t deadline = common_hal_time_monotonic_ns() + READY_TIMEOUT_NS; while (common_hal_time_monotonic_ns() < deadline) { uint8_t b; common_hal_busio_spi_read(self->bus, &b, 1, 0xff); if (b == 0xff) { - break; + return 0; } } + return -ETIMEDOUT; +} + +// Note: this is never called while "in cmd25" (in fact, it's only used by `exit_cmd25`) +STATIC bool cmd_nodata(sdcardio_sdcard_obj_t *self, int cmd, int response) { + uint8_t cmdbuf[2] = {cmd, 0xff}; + + assert(!self->in_cmd25); + + common_hal_busio_spi_write(self->bus, cmdbuf, sizeof(cmdbuf)); + + // Wait for the response (response[7] == response) + for (int i = 0; i < CMD_TIMEOUT; i++) { + common_hal_busio_spi_read(self->bus, cmdbuf, 1, 0xff); + if (cmdbuf[0] == response) { + return 0; + } + } + return -EIO; +} + + +STATIC int exit_cmd25(sdcardio_sdcard_obj_t *self) { + if (self->in_cmd25) { + DEBUG_PRINT("exit cmd25\n"); + self->in_cmd25 = false; + return cmd_nodata(self, TOKEN_STOP_TRAN, 0); + } + return 0; } // In Python API, defaults are response=None, data_block=True, wait=True STATIC int cmd(sdcardio_sdcard_obj_t *self, int cmd, int arg, void *response_buf, size_t response_len, bool data_block, bool wait) { + int r = exit_cmd25(self); + if (r < 0) { + return r; + } + DEBUG_PRINT("cmd % 3d [%02x] arg=% 11d [%08x] len=%d%s%s\n", cmd, cmd, arg, arg, response_len, data_block ? " data" : "", wait ? " wait" : ""); uint8_t cmdbuf[6]; cmdbuf[0] = cmd | 0x40; @@ -116,7 +150,10 @@ STATIC int cmd(sdcardio_sdcard_obj_t *self, int cmd, int arg, void *response_buf cmdbuf[5] = CRC7(cmdbuf, 5); if (wait) { - wait_for_ready(self); + r = wait_for_ready(self); + if (r < 0) { + return r; + } } common_hal_busio_spi_write(self->bus, cmdbuf, sizeof(cmdbuf)); @@ -161,21 +198,6 @@ STATIC int block_cmd(sdcardio_sdcard_obj_t *self, int cmd_, int block, void *res return cmd(self, cmd_, block * self->cdv, response_buf, response_len, true, true); } -STATIC bool cmd_nodata(sdcardio_sdcard_obj_t *self, int cmd, int response) { - uint8_t cmdbuf[2] = {cmd, 0xff}; - - common_hal_busio_spi_write(self->bus, cmdbuf, sizeof(cmdbuf)); - - // Wait for the response (response[7] == response) - for (int i = 0; i < CMD_TIMEOUT; i++) { - common_hal_busio_spi_read(self->bus, cmdbuf, 1, 0xff); - if (cmdbuf[0] == response) { - return 0; - } - } - return -EIO; -} - STATIC const compressed_string_t *init_card_v1(sdcardio_sdcard_obj_t *self) { for (int i = 0; i < CMD_TIMEOUT; i++) { if (cmd(self, 41, 0, NULL, 0, true, true) == 0) { @@ -298,6 +320,7 @@ void common_hal_sdcardio_sdcard_deinit(sdcardio_sdcard_obj_t *self) { if (!self->bus) { return; } + common_hal_sdcardio_sdcard_sync(self); self->bus = 0; common_hal_digitalio_digitalinout_deinit(&self->cs); } @@ -423,37 +446,43 @@ STATIC int _write(sdcardio_sdcard_obj_t *self, uint8_t token, void *buf, size_t STATIC int writeblocks(sdcardio_sdcard_obj_t *self, uint32_t start_block, mp_buffer_info_t *buf) { common_hal_sdcardio_check_for_deinit(self); uint32_t nblocks = buf->len / 512; - if (nblocks == 1) { - // Use CMD24 to write a single block - int r = block_cmd(self, 24, start_block, NULL, 0, true, true); - if (r < 0) { - return r; - } - r = _write(self, TOKEN_DATA, buf->buf, buf->len); - if (r < 0) { - return r; - } - } else { + + DEBUG_PRINT("cmd25? %d next_block %d start_block %d\n", self->in_cmd25, self->next_block, start_block); + + if (!self->in_cmd25 || start_block != self->next_block) { + DEBUG_PRINT("entering CMD25 at %d\n", (int)start_block); // Use CMD25 to write multiple block int r = block_cmd(self, 25, start_block, NULL, 0, true, true); if (r < 0) { return r; } - - uint8_t *ptr = buf->buf; - while (nblocks--) { - r = _write(self, TOKEN_CMD25, ptr, 512); - if (r < 0) { - return r; - } - ptr += 512; - } - - cmd_nodata(self, TOKEN_STOP_TRAN, 0); + self->in_cmd25 = true; } + + self->next_block = start_block; + + uint8_t *ptr = buf->buf; + while (nblocks--) { + int r = _write(self, TOKEN_CMD25, ptr, 512); + if (r < 0) { + self->in_cmd25 = false; + return r; + } + self->next_block++; + ptr += 512; + } + return 0; } +int common_hal_sdcardio_sdcard_sync(sdcardio_sdcard_obj_t *self) { + common_hal_sdcardio_check_for_deinit(self); + lock_and_configure_bus(self); + int r = exit_cmd25(self); + extraclock_and_unlock_bus(self); + return r; +} + int common_hal_sdcardio_sdcard_writeblocks(sdcardio_sdcard_obj_t *self, uint32_t start_block, mp_buffer_info_t *buf) { common_hal_sdcardio_check_for_deinit(self); if (buf->len % 512 != 0) { diff --git a/shared-module/sdcardio/SDCard.h b/shared-module/sdcardio/SDCard.h index 76c906029f..f76bbf5549 100644 --- a/shared-module/sdcardio/SDCard.h +++ b/shared-module/sdcardio/SDCard.h @@ -41,6 +41,8 @@ typedef struct { int cdv; int baudrate; uint32_t sectors; + uint32_t next_block; + bool in_cmd25; } sdcardio_sdcard_obj_t; void common_hal_sdcardio_sdcard_construct(sdcardio_sdcard_obj_t *self, busio_spi_obj_t *spi, mcu_pin_obj_t *cs, int baudrate); @@ -48,4 +50,5 @@ void common_hal_sdcardio_sdcard_deinit(sdcardio_sdcard_obj_t *self); void common_hal_sdcardio_sdcard_check_for_deinit(sdcardio_sdcard_obj_t *self); int common_hal_sdcardio_sdcard_get_blockcount(sdcardio_sdcard_obj_t *self); int common_hal_sdcardio_sdcard_readblocks(sdcardio_sdcard_obj_t *self, uint32_t start_block, mp_buffer_info_t *buf); +int common_hal_sdcardio_sdcard_sync(sdcardio_sdcard_obj_t *self); int common_hal_sdcardio_sdcard_writeblocks(sdcardio_sdcard_obj_t *self, uint32_t start_block, mp_buffer_info_t *buf); diff --git a/shared-module/usb_cdc/Serial.c b/shared-module/usb_cdc/Serial.c index 3ffb22cc3d..3b402bf70c 100644 --- a/shared-module/usb_cdc/Serial.c +++ b/shared-module/usb_cdc/Serial.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "lib/utils/interrupt_char.h" +#include "shared/runtime/interrupt_char.h" #include "shared-module/usb_cdc/Serial.h" #include "supervisor/shared/tick.h" diff --git a/shared-module/usb_cdc/__init__.c b/shared-module/usb_cdc/__init__.c index 5881ec4c32..9961d6d53f 100644 --- a/shared-module/usb_cdc/__init__.c +++ b/shared-module/usb_cdc/__init__.c @@ -35,6 +35,11 @@ #include "tusb.h" +#if CIRCUITPY_USB_VENDOR +// todo - this doesn't feel like it should be here. +#include "supervisor/memory.h" +#endif + #if CFG_TUD_CDC != 2 #error CFG_TUD_CDC must be exactly 2 #endif @@ -259,3 +264,154 @@ bool common_hal_usb_cdc_enable(bool console, bool data) { return true; } + +#if CIRCUITPY_USB_VENDOR +#include "usb_vendor_descriptors.h" + +#define BOS_TOTAL_LEN (TUD_BOS_DESC_LEN + TUD_BOS_WEBUSB_DESC_LEN + TUD_BOS_MICROSOFT_OS_DESC_LEN) + +#define MS_OS_20_DESC_LEN 0xB2 + +// BOS Descriptor is required for webUSB +uint8_t const desc_bos[] = +{ + // total length, number of device caps + TUD_BOS_DESCRIPTOR(BOS_TOTAL_LEN, 2), + + // Vendor Code, iLandingPage + TUD_BOS_WEBUSB_DESCRIPTOR(VENDOR_REQUEST_WEBUSB, 1), + + // Microsoft OS 2.0 descriptor + TUD_BOS_MS_OS_20_DESCRIPTOR(MS_OS_20_DESC_LEN, VENDOR_REQUEST_MICROSOFT) +}; + +uint8_t const *tud_descriptor_bos_cb(void) { + return desc_bos; +} + +#define MS_OS_20_ITF_NUM_MAGIC 0x5b +#define MS_OS_20_ITF_NUM_OFFSET 22 + +const uint8_t ms_os_20_descriptor_template[] = +{ + // 10 Set header: length, type, windows version, total length + U16_TO_U8S_LE(0x000A), U16_TO_U8S_LE(MS_OS_20_SET_HEADER_DESCRIPTOR), U32_TO_U8S_LE(0x06030000), U16_TO_U8S_LE(MS_OS_20_DESC_LEN), + + // 8 Configuration subset header: length, type, configuration index, reserved, configuration total length + U16_TO_U8S_LE(0x0008), U16_TO_U8S_LE(MS_OS_20_SUBSET_HEADER_CONFIGURATION), 0, 0, U16_TO_U8S_LE(MS_OS_20_DESC_LEN - 0x0A), + + // 8 Function Subset header: length, type, first interface, reserved, subset length + U16_TO_U8S_LE(0x0008), U16_TO_U8S_LE(MS_OS_20_SUBSET_HEADER_FUNCTION), /* 22 */ MS_OS_20_ITF_NUM_MAGIC, 0, U16_TO_U8S_LE(MS_OS_20_DESC_LEN - 0x0A - 0x08), + + // 20 MS OS 2.0 Compatible ID descriptor: length, type, compatible ID, sub compatible ID + U16_TO_U8S_LE(0x0014), U16_TO_U8S_LE(MS_OS_20_FEATURE_COMPATBLE_ID), 'W', 'I', 'N', 'U', 'S', 'B', 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // sub-compatible + + // MS OS 2.0 Registry property descriptor: length, type + U16_TO_U8S_LE(MS_OS_20_DESC_LEN - 0x0A - 0x08 - 0x08 - 0x14), U16_TO_U8S_LE(MS_OS_20_FEATURE_REG_PROPERTY), + U16_TO_U8S_LE(0x0007), U16_TO_U8S_LE(0x002A), // wPropertyDataType, wPropertyNameLength and PropertyName "DeviceInterfaceGUIDs\0" in UTF-16 + 'D', 0x00, 'e', 0x00, 'v', 0x00, 'i', 0x00, 'c', 0x00, 'e', 0x00, 'I', 0x00, 'n', 0x00, 't', 0x00, 'e', 0x00, + 'r', 0x00, 'f', 0x00, 'a', 0x00, 'c', 0x00, 'e', 0x00, 'G', 0x00, 'U', 0x00, 'I', 0x00, 'D', 0x00, 's', 0x00, 0x00, 0x00, + U16_TO_U8S_LE(0x0050), // wPropertyDataLength + // bPropertyData: “{975F44D9-0D08-43FD-8B3E-127CA8AFFF9D}”. + '{', 0x00, '9', 0x00, '7', 0x00, '5', 0x00, 'F', 0x00, '4', 0x00, '4', 0x00, 'D', 0x00, '9', 0x00, '-', 0x00, + '0', 0x00, 'D', 0x00, '0', 0x00, '8', 0x00, '-', 0x00, '4', 0x00, '3', 0x00, 'F', 0x00, 'D', 0x00, '-', 0x00, + '8', 0x00, 'B', 0x00, '3', 0x00, 'E', 0x00, '-', 0x00, '1', 0x00, '2', 0x00, '7', 0x00, 'C', 0x00, 'A', 0x00, + '8', 0x00, 'A', 0x00, 'F', 0x00, 'F', 0x00, 'F', 0x00, '9', 0x00, 'D', 0x00, '}', 0x00, 0x00, 0x00, 0x00, 0x00 +}; + +TU_VERIFY_STATIC(sizeof(ms_os_20_descriptor_template) == MS_OS_20_DESC_LEN, "Incorrect size"); + +static const uint8_t usb_vendor_descriptor_template[] = { + // Vendor Descriptor + 0x09, // 0 bLength + 0x04, // 1 bDescriptorType (Interface) + 0xFF, // 2 bInterfaceNumber [SET AT RUNTIME] +#define VENDOR_INTERFACE_INDEX 2 + 0x00, // 3 bAlternateSetting + 0x02, // 4 bNumEndpoints 2 + 0xFF, // 5 bInterfaceClass: Vendor Specific + 0x00, // 6 bInterfaceSubClass: NONE + 0x00, // 7 bInterfaceProtocol: NONE + 0xFF, // 8 iInterface (String Index) +#define VENDOR_INTERFACE_STRING_INDEX 8 + + // Vendor OUT Endpoint Descriptor + 0x07, // 9 bLength + 0x05, // 10 bDescriptorType (Endpoint) + 0xFF, // 11 bEndpointAddress (IN/D2H) [SET AT RUNTIME: number] +#define VENDOR_OUT_ENDPOINT_INDEX 11 + 0x02, // 12 bmAttributes (Bulk) + #if USB_HIGHSPEED + 0x00, 0x02, // 13,14 wMaxPacketSize 512 + #else + 0x40, 0x00, // 13,14 wMaxPacketSize 64 + #endif + 0x0, // 15 bInterval 0 + + // Vendor IN Endpoint Descriptor + 0x07, // 16 bLength + 0x05, // 17 bDescriptorType (Endpoint) + 0xFF, // 18 bEndpointAddress (IN/D2H) [SET AT RUNTIME: 0x80 | number] +#define VENDOR_IN_ENDPOINT_INDEX 18 + 0x02, // 19 bmAttributes (Bulk) + 0x40, 0x00, // 20, 21 wMaxPacketSize 64 + 0x0 // 22 bInterval 0 +}; + +static const char vendor_interface_name[] = USB_INTERFACE_NAME " WebUSB"; + + +bool usb_vendor_enabled(void) { + return usb_cdc_console_enabled(); +} + +size_t usb_vendor_descriptor_length(void) { + return sizeof(usb_vendor_descriptor_template); +} + +static supervisor_allocation *ms_os_20_descriptor_allocation; + +size_t vendor_ms_os_20_descriptor_length() { + return sizeof(ms_os_20_descriptor_template); +} +uint8_t const *vendor_ms_os_20_descriptor() { + return (uint8_t *)ms_os_20_descriptor_allocation->ptr; +} + + +size_t usb_vendor_add_descriptor(uint8_t *descriptor_buf, descriptor_counts_t *descriptor_counts, uint8_t *current_interface_string) { + + if (ms_os_20_descriptor_template[MS_OS_20_ITF_NUM_OFFSET] == MS_OS_20_ITF_NUM_MAGIC) { + ms_os_20_descriptor_allocation = + allocate_memory(align32_size(sizeof(ms_os_20_descriptor_template)), + /*high_address*/ false, /*movable*/ false); + uint8_t *ms_os_20_descriptor_buf = (uint8_t *)ms_os_20_descriptor_allocation->ptr; + memcpy(ms_os_20_descriptor_buf, ms_os_20_descriptor_template, sizeof(ms_os_20_descriptor_template)); + ms_os_20_descriptor_buf[MS_OS_20_ITF_NUM_OFFSET] = descriptor_counts->current_interface; + ms_os_20_descriptor_buf[VENDOR_IN_ENDPOINT_INDEX] = 0x80 | descriptor_counts->current_endpoint; + ms_os_20_descriptor_buf[VENDOR_OUT_ENDPOINT_INDEX] = descriptor_counts->current_endpoint; + } + + memcpy(descriptor_buf, usb_vendor_descriptor_template, sizeof(usb_vendor_descriptor_template)); + + descriptor_buf[VENDOR_INTERFACE_INDEX] = descriptor_counts->current_interface; + descriptor_counts->current_interface++; + + descriptor_buf[VENDOR_IN_ENDPOINT_INDEX] = 0x80 | descriptor_counts->current_endpoint; + descriptor_counts->num_in_endpoints++; + descriptor_buf[VENDOR_OUT_ENDPOINT_INDEX] = descriptor_counts->current_endpoint; + descriptor_counts->num_out_endpoints++; + descriptor_counts->current_endpoint++; + + usb_add_interface_string(*current_interface_string, vendor_interface_name); + descriptor_buf[VENDOR_INTERFACE_STRING_INDEX] = *current_interface_string; + (*current_interface_string)++; + + return sizeof(usb_vendor_descriptor_template); +} + + + + +#endif diff --git a/shared-module/usb_cdc/__init__.h b/shared-module/usb_cdc/__init__.h index 5195c964e2..87dabf05db 100644 --- a/shared-module/usb_cdc/__init__.h +++ b/shared-module/usb_cdc/__init__.h @@ -39,4 +39,13 @@ void usb_cdc_set_defaults(void); size_t usb_cdc_descriptor_length(void); size_t usb_cdc_add_descriptor(uint8_t *descriptor_buf, descriptor_counts_t *descriptor_counts, uint8_t *current_interface_string, bool console); +#if CIRCUITPY_USB_VENDOR +bool usb_vendor_enabled(void); +size_t usb_vendor_descriptor_length(void); +size_t usb_vendor_add_descriptor(uint8_t *descriptor_buf, descriptor_counts_t *descriptor_counts, uint8_t *current_interface_string); + +size_t vendor_ms_os_20_descriptor_length(void); +uint8_t const *vendor_ms_os_20_descriptor(void); +#endif + #endif /* SHARED_MODULE_USB_CDC___INIT___H */ diff --git a/shared-module/usb_hid/Device.c b/shared-module/usb_hid/Device.c index 71c6dea7af..de34d60d0a 100644 --- a/shared-module/usb_hid/Device.c +++ b/shared-module/usb_hid/Device.c @@ -244,7 +244,7 @@ void common_hal_usb_hid_device_send_report(usb_hid_device_obj_t *self, uint8_t * } mp_obj_t common_hal_usb_hid_device_get_last_received_report(usb_hid_device_obj_t *self, uint8_t report_id) { - // report_id has already been validated for this deveice. + // report_id has already been validated for this device. size_t id_idx = get_report_id_idx(self, report_id); return mp_obj_new_bytes(self->out_report_buffers[id_idx], self->out_report_lengths[id_idx]); } @@ -266,11 +266,11 @@ void usb_hid_device_create_report_buffers(usb_hid_device_obj_t *self) { } -// Callbacks invoked when we received Get_Report request through control endpoint +// Callback invoked when we receive Get_Report request through control endpoint uint16_t tud_hid_get_report_cb(uint8_t itf, uint8_t report_id, hid_report_type_t report_type, uint8_t *buffer, uint16_t reqlen) { (void)itf; - // only support Input Report - if (report_type != HID_REPORT_TYPE_INPUT) { + // Support Input Report and Feature Report + if (report_type != HID_REPORT_TYPE_INPUT && report_type != HID_REPORT_TYPE_FEATURE) { return 0; } @@ -289,14 +289,14 @@ uint16_t tud_hid_get_report_cb(uint8_t itf, uint8_t report_id, hid_report_type_t return 0; } -// Callbacks invoked when we received Set_Report request through control endpoint +// Callback invoked when we receive Set_Report request through control endpoint void tud_hid_set_report_cb(uint8_t itf, uint8_t report_id, hid_report_type_t report_type, uint8_t const *buffer, uint16_t bufsize) { (void)itf; if (report_type == HID_REPORT_TYPE_INVALID) { report_id = buffer[0]; buffer++; bufsize--; - } else if (report_type != HID_REPORT_TYPE_OUTPUT) { + } else if (report_type != HID_REPORT_TYPE_OUTPUT && report_type != HID_REPORT_TYPE_FEATURE) { return; } diff --git a/shared-module/usb_hid/__init__.c b/shared-module/usb_hid/__init__.c index efe37662ee..89a05c77b3 100644 --- a/shared-module/usb_hid/__init__.c +++ b/shared-module/usb_hid/__init__.c @@ -31,7 +31,7 @@ #include "py/gc.h" #include "py/runtime.h" #include "shared-bindings/usb_hid/__init__.h" -#include "shared-module/usb_hid/Device.h" +#include "shared-bindings/usb_hid/Device.h" #include "supervisor/memory.h" #include "supervisor/usb.h" @@ -44,7 +44,9 @@ static const uint8_t usb_hid_descriptor_template[] = { 0x02, // 4 bNumEndpoints 2 0x03, // 5 bInterfaceClass: HID 0x00, // 6 bInterfaceSubClass: NOBOOT +#define HID_DESCRIPTOR_SUBCLASS_INDEX (6) 0x00, // 7 bInterfaceProtocol: NONE +#define HID_DESCRIPTOR_INTERFACE_PROTOCOL_INDEX (7) 0xFF, // 8 iInterface (String Index) [SET AT RUNTIME] #define HID_DESCRIPTOR_INTERFACE_STRING_INDEX (8) @@ -81,6 +83,14 @@ static usb_hid_device_obj_t hid_devices[MAX_HID_DEVICES]; // If 0, USB HID is disabled. static mp_int_t num_hid_devices; +// Which boot device is available? 0: no boot devices, 1: boot keyboard, 2: boot mouse. +// This value is set by usb_hid.enable(), and used to build the HID interface descriptor. +// The value is remembered here from boot.py to code.py. +static uint8_t hid_boot_device; + +// Whether a boot device was requested by a SET_PROTOCOL request from the host. +static bool hid_boot_device_requested; + // This tuple is store in usb_hid.devices. static mp_obj_tuple_t *hid_devices_tuple; @@ -96,13 +106,56 @@ static mp_obj_tuple_t default_hid_devices_tuple = { }, }; +// These describe the standard descriptors used for boot keyboard and mouse, which don't use report IDs. +// When the host requests a boot device, replace whatever HID devices were enabled with a tuple +// containing just one of these, since the host is uninterested in other devices. +// The driver code will then use the proper report length and send_report() will not send a report ID. +static const usb_hid_device_obj_t boot_keyboard_obj = { + .base = { + .type = &usb_hid_device_type, + }, + .report_descriptor = NULL, + .report_descriptor_length = 0, + .usage_page = 0x01, + .usage = 0x06, + .num_report_ids = 1, + .report_ids = { 0, }, + .in_report_lengths = { 8, }, + .out_report_lengths = { 1, }, +}; + +static const usb_hid_device_obj_t boot_mouse_obj = { + .base = { + .type = &usb_hid_device_type, + }, + .report_descriptor = NULL, + .report_descriptor_length = 0, + .usage_page = 0x01, + .usage = 0x02, + .num_report_ids = 1, + .report_ids = { 0, }, + .in_report_lengths = { 4, }, + .out_report_lengths = { 0, }, +}; + bool usb_hid_enabled(void) { return num_hid_devices > 0; } +uint8_t usb_hid_boot_device(void) { + return hid_boot_device; +} + +// Returns 1 or 2 if host requested a boot device and boot protocol was enabled in the interface descriptor. +uint8_t common_hal_usb_hid_get_boot_device(void) { + return hid_boot_device_requested ? hid_boot_device : 0; +} + void usb_hid_set_defaults(void) { + hid_boot_device = 0; + hid_boot_device_requested = false; common_hal_usb_hid_enable( - CIRCUITPY_USB_HID_ENABLED_DEFAULT ? &default_hid_devices_tuple : mp_const_empty_tuple); + CIRCUITPY_USB_HID_ENABLED_DEFAULT ? &default_hid_devices_tuple : mp_const_empty_tuple, 0); } // This is the interface descriptor, not the report descriptor. @@ -113,12 +166,17 @@ size_t usb_hid_descriptor_length(void) { static const char usb_hid_interface_name[] = USB_INTERFACE_NAME " HID"; // This is the interface descriptor, not the report descriptor. -size_t usb_hid_add_descriptor(uint8_t *descriptor_buf, descriptor_counts_t *descriptor_counts, uint8_t *current_interface_string, uint16_t report_descriptor_length) { +size_t usb_hid_add_descriptor(uint8_t *descriptor_buf, descriptor_counts_t *descriptor_counts, uint8_t *current_interface_string, uint16_t report_descriptor_length, uint8_t boot_device) { memcpy(descriptor_buf, usb_hid_descriptor_template, sizeof(usb_hid_descriptor_template)); descriptor_buf[HID_DESCRIPTOR_INTERFACE_INDEX] = descriptor_counts->current_interface; descriptor_counts->current_interface++; + if (boot_device > 0) { + descriptor_buf[HID_DESCRIPTOR_SUBCLASS_INDEX] = 1; // BOOT protocol (device) available. + descriptor_buf[HID_DESCRIPTOR_INTERFACE_PROTOCOL_INDEX] = boot_device; // 1: keyboard, 2: mouse + } + usb_add_interface_string(*current_interface_string, usb_hid_interface_name); descriptor_buf[HID_DESCRIPTOR_INTERFACE_STRING_INDEX] = *current_interface_string; (*current_interface_string)++; @@ -151,10 +209,10 @@ static void usb_hid_set_devices_from_hid_devices(void) { } bool common_hal_usb_hid_disable(void) { - return common_hal_usb_hid_enable(mp_const_empty_tuple); + return common_hal_usb_hid_enable(mp_const_empty_tuple, 0); } -bool common_hal_usb_hid_enable(const mp_obj_t devices) { +bool common_hal_usb_hid_enable(const mp_obj_t devices, uint8_t boot_device) { // We can't change the devices once we're connected. if (tud_connected()) { return false; @@ -167,6 +225,8 @@ bool common_hal_usb_hid_enable(const mp_obj_t devices) { num_hid_devices = num_devices; + hid_boot_device = boot_device; + // Remember the devices in static storage so they live across VMs. for (mp_int_t i = 0; i < num_hid_devices; i++) { // devices has already been validated to contain only usb_hid_device_obj_t objects. @@ -182,6 +242,17 @@ bool common_hal_usb_hid_enable(const mp_obj_t devices) { // Called when HID devices are ready to be used, when code.py or the REPL starts running. void usb_hid_setup_devices(void) { + + // If the host requested a boot device, replace the current list of devices + // with a single-element tuple containing the proper boot device. + if (hid_boot_device_requested) { + memcpy(&hid_devices[0], + // Will be 1 (keyboard) or 2 (mouse). + hid_boot_device == 1 ? &boot_keyboard_obj : &boot_mouse_obj, + sizeof(usb_hid_device_obj_t)); + num_hid_devices = 1; + } + usb_hid_set_devices_from_hid_devices(); // Create report buffers on the heap. @@ -272,9 +343,15 @@ bool usb_hid_get_device_with_report_id(uint8_t report_id, usb_hid_device_obj_t * return false; } -// Invoked when GET HID REPORT DESCRIPTOR is received. -// Application return pointer to descriptor +// Callback invoked when we receive a GET HID REPORT DESCRIPTOR +// Application returns pointer to descriptor // Descriptor contents must exist long enough for transfer to complete uint8_t const *tud_hid_descriptor_report_cb(uint8_t itf) { return (uint8_t *)hid_report_descriptor_allocation->ptr; } + +// Callback invoked when we receive a SET_PROTOCOL request. +// Protocol is either HID_PROTOCOL_BOOT (0) or HID_PROTOCOL_REPORT (1) +void tud_hid_set_protocol_cb(uint8_t instance, uint8_t protocol) { + hid_boot_device_requested = (protocol == HID_PROTOCOL_BOOT); +} diff --git a/shared-module/usb_hid/__init__.h b/shared-module/usb_hid/__init__.h index 6d85b50e9f..1a33540321 100644 --- a/shared-module/usb_hid/__init__.h +++ b/shared-module/usb_hid/__init__.h @@ -33,9 +33,10 @@ extern usb_hid_device_obj_t usb_hid_devices[]; bool usb_hid_enabled(void); +uint8_t usb_hid_boot_device(void); void usb_hid_set_defaults(void); -size_t usb_hid_add_descriptor(uint8_t *descriptor_buf, descriptor_counts_t *descriptor_counts, uint8_t *current_interface_string, uint16_t report_descriptor_length); +size_t usb_hid_add_descriptor(uint8_t *descriptor_buf, descriptor_counts_t *descriptor_counts, uint8_t *current_interface_string, uint16_t report_descriptor_length, uint8_t boot_device); size_t usb_hid_descriptor_length(void); size_t usb_hid_report_descriptor_length(void); diff --git a/shared/README.md b/shared/README.md new file mode 100644 index 0000000000..073187b249 --- /dev/null +++ b/shared/README.md @@ -0,0 +1,3 @@ +This directory contains libraries, utilities and helper code developed +specifically for this project. The code is intended to be portable and +usable by any port. diff --git a/lib/embed/__errno.c b/shared/libc/__errno.c similarity index 100% rename from lib/embed/__errno.c rename to shared/libc/__errno.c diff --git a/lib/embed/abort_.c b/shared/libc/abort_.c similarity index 100% rename from lib/embed/abort_.c rename to shared/libc/abort_.c diff --git a/lib/utils/printf.c b/shared/libc/printf.c similarity index 100% rename from lib/utils/printf.c rename to shared/libc/printf.c diff --git a/lib/libc/string0.c b/shared/libc/string0.c similarity index 100% rename from lib/libc/string0.c rename to shared/libc/string0.c diff --git a/lib/memzip/README.md b/shared/memzip/README.md similarity index 84% rename from lib/memzip/README.md rename to shared/memzip/README.md index c4e31a1170..9aa12a94c8 100644 --- a/lib/memzip/README.md +++ b/shared/memzip/README.md @@ -10,13 +10,13 @@ a C file which contains the data from the zip file. A typical addition to a makefile would look like: ``` SRC_C += \ - lib/memzip/import.c \ - lib/memzip/lexermemzip.c \ - lib/memzip/memzip.c \ + shared/memzip/import.c \ + shared/memzip/lexermemzip.c \ + shared/memzip/memzip.c \ OBJ += $(BUILD)/memzip-files.o -MAKE_MEMZIP = ../lib/memzip/make-memzip.py +MAKE_MEMZIP = ../shared/memzip/make-memzip.py $(BUILD)/memzip-files.o: $(BUILD)/memzip-files.c $(call compile_c) diff --git a/lib/memzip/import.c b/shared/memzip/import.c similarity index 100% rename from lib/memzip/import.c rename to shared/memzip/import.c diff --git a/lib/memzip/lexermemzip.c b/shared/memzip/lexermemzip.c similarity index 100% rename from lib/memzip/lexermemzip.c rename to shared/memzip/lexermemzip.c diff --git a/lib/memzip/make-memzip.py b/shared/memzip/make-memzip.py similarity index 100% rename from lib/memzip/make-memzip.py rename to shared/memzip/make-memzip.py diff --git a/lib/memzip/memzip.c b/shared/memzip/memzip.c similarity index 100% rename from lib/memzip/memzip.c rename to shared/memzip/memzip.c diff --git a/lib/memzip/memzip.h b/shared/memzip/memzip.h similarity index 100% rename from lib/memzip/memzip.h rename to shared/memzip/memzip.h diff --git a/lib/netutils/dhcpserver.c b/shared/netutils/dhcpserver.c similarity index 99% rename from lib/netutils/dhcpserver.c rename to shared/netutils/dhcpserver.c index 7f97ee6e46..9db42b3fd9 100644 --- a/lib/netutils/dhcpserver.c +++ b/shared/netutils/dhcpserver.c @@ -35,7 +35,7 @@ #if MICROPY_PY_LWIP -#include "lib/netutils/dhcpserver.h" +#include "shared/netutils/dhcpserver.h" #include "lwip/udp.h" #define DHCPDISCOVER (1) diff --git a/lib/netutils/dhcpserver.h b/shared/netutils/dhcpserver.h similarity index 100% rename from lib/netutils/dhcpserver.h rename to shared/netutils/dhcpserver.h diff --git a/lib/netutils/netutils.c b/shared/netutils/netutils.c similarity index 98% rename from lib/netutils/netutils.c rename to shared/netutils/netutils.c index 24a6fac99a..fe92e8bafb 100644 --- a/lib/netutils/netutils.c +++ b/shared/netutils/netutils.c @@ -30,7 +30,7 @@ #include #include "py/runtime.h" -#include "lib/netutils/netutils.h" +#include "shared/netutils/netutils.h" #include "supervisor/shared/translate.h" // Takes an array with a raw IPv4 address and returns something like '192.168.0.1'. diff --git a/lib/netutils/netutils.h b/shared/netutils/netutils.h similarity index 100% rename from lib/netutils/netutils.h rename to shared/netutils/netutils.h diff --git a/lib/netutils/trace.c b/shared/netutils/trace.c similarity index 99% rename from lib/netutils/trace.c rename to shared/netutils/trace.c index 1610966c2d..a6dfb42c28 100644 --- a/lib/netutils/trace.c +++ b/shared/netutils/trace.c @@ -25,7 +25,7 @@ */ #include "py/mphal.h" -#include "lib/netutils/netutils.h" +#include "shared/netutils/netutils.h" static uint32_t get_be16(const uint8_t *buf) { return buf[0] << 8 | buf[1]; diff --git a/lib/mp-readline/readline.c b/shared/readline/readline.c similarity index 99% rename from lib/mp-readline/readline.c rename to shared/readline/readline.c index b47204abac..23183342a7 100644 --- a/lib/mp-readline/readline.c +++ b/shared/readline/readline.c @@ -31,7 +31,7 @@ #include "py/mpstate.h" #include "py/repl.h" #include "py/mphal.h" -#include "lib/mp-readline/readline.h" +#include "shared/readline/readline.h" #if 0 // print debugging info #define DEBUG_PRINT (1) diff --git a/lib/mp-readline/readline.h b/shared/readline/readline.h similarity index 100% rename from lib/mp-readline/readline.h rename to shared/readline/readline.h diff --git a/lib/utils/buffer_helper.c b/shared/runtime/buffer_helper.c similarity index 97% rename from lib/utils/buffer_helper.c rename to shared/runtime/buffer_helper.c index a4008225d6..facd05eaf0 100644 --- a/lib/utils/buffer_helper.c +++ b/shared/runtime/buffer_helper.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "lib/utils/buffer_helper.h" +#include "shared/runtime/buffer_helper.h" void normalize_buffer_bounds(int32_t *start, int32_t end, size_t *length) { if (end < 0) { diff --git a/lib/utils/buffer_helper.h b/shared/runtime/buffer_helper.h similarity index 100% rename from lib/utils/buffer_helper.h rename to shared/runtime/buffer_helper.h diff --git a/lib/utils/context_manager_helpers.c b/shared/runtime/context_manager_helpers.c similarity index 96% rename from lib/utils/context_manager_helpers.c rename to shared/runtime/context_manager_helpers.c index 2614856160..d489ce994b 100644 --- a/lib/utils/context_manager_helpers.c +++ b/shared/runtime/context_manager_helpers.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "lib/utils/context_manager_helpers.h" +#include "shared/runtime/context_manager_helpers.h" #include "py/obj.h" diff --git a/lib/utils/context_manager_helpers.h b/shared/runtime/context_manager_helpers.h similarity index 100% rename from lib/utils/context_manager_helpers.h rename to shared/runtime/context_manager_helpers.h diff --git a/lib/utils/gchelper.h b/shared/runtime/gchelper.h similarity index 100% rename from lib/utils/gchelper.h rename to shared/runtime/gchelper.h diff --git a/lib/utils/gchelper_generic.c b/shared/runtime/gchelper_generic.c similarity index 99% rename from lib/utils/gchelper_generic.c rename to shared/runtime/gchelper_generic.c index 3e7e33ab18..dcd35f9c7e 100644 --- a/lib/utils/gchelper_generic.c +++ b/shared/runtime/gchelper_generic.c @@ -28,7 +28,7 @@ #include "py/mpstate.h" #include "py/gc.h" -#include "lib/utils/gchelper.h" +#include "shared/runtime/gchelper.h" #if MICROPY_ENABLE_GC diff --git a/lib/utils/gchelper_m0.s b/shared/runtime/gchelper_m0.s similarity index 100% rename from lib/utils/gchelper_m0.s rename to shared/runtime/gchelper_m0.s diff --git a/lib/utils/gchelper_m3.s b/shared/runtime/gchelper_m3.s similarity index 100% rename from lib/utils/gchelper_m3.s rename to shared/runtime/gchelper_m3.s diff --git a/lib/utils/gchelper_native.c b/shared/runtime/gchelper_native.c similarity index 97% rename from lib/utils/gchelper_native.c rename to shared/runtime/gchelper_native.c index 6bf386b519..1e4af9c844 100644 --- a/lib/utils/gchelper_native.c +++ b/shared/runtime/gchelper_native.c @@ -28,7 +28,7 @@ #include "py/mpstate.h" #include "py/gc.h" -#include "lib/utils/gchelper.h" +#include "shared/runtime/gchelper.h" #if MICROPY_ENABLE_GC diff --git a/lib/utils/interrupt_char.c b/shared/runtime/interrupt_char.c similarity index 96% rename from lib/utils/interrupt_char.c rename to shared/runtime/interrupt_char.c index c751c4e52c..4ac099f41e 100644 --- a/lib/utils/interrupt_char.c +++ b/shared/runtime/interrupt_char.c @@ -37,7 +37,7 @@ void mp_hal_set_interrupt_char(int c) { // Check to see if we've been CTRL-C'ed by autoreload or the user. bool mp_hal_is_interrupted(void) { - return MP_STATE_VM(mp_pending_exception) != NULL; + return MP_STATE_THREAD(mp_pending_exception) != NULL; } #endif diff --git a/lib/utils/interrupt_char.h b/shared/runtime/interrupt_char.h similarity index 100% rename from lib/utils/interrupt_char.h rename to shared/runtime/interrupt_char.h diff --git a/lib/utils/mpirq.c b/shared/runtime/mpirq.c similarity index 99% rename from lib/utils/mpirq.c rename to shared/runtime/mpirq.c index 02139f24dc..8e474bf5a2 100644 --- a/lib/utils/mpirq.c +++ b/shared/runtime/mpirq.c @@ -29,7 +29,7 @@ #include "py/runtime.h" #include "py/gc.h" -#include "lib/utils/mpirq.h" +#include "shared/runtime/mpirq.h" #if MICROPY_ENABLE_SCHEDULER diff --git a/lib/utils/mpirq.h b/shared/runtime/mpirq.h similarity index 100% rename from lib/utils/mpirq.h rename to shared/runtime/mpirq.h diff --git a/lib/utils/pyexec.c b/shared/runtime/pyexec.c similarity index 99% rename from lib/utils/pyexec.c rename to shared/runtime/pyexec.c index fe52fc645b..e611131f6b 100644 --- a/lib/utils/pyexec.c +++ b/shared/runtime/pyexec.c @@ -40,8 +40,8 @@ #include "irq.h" #include "usb.h" #endif -#include "lib/mp-readline/readline.h" -#include "lib/utils/pyexec.h" +#include "shared/readline/readline.h" +#include "shared/runtime/pyexec.h" #include "genhdr/mpversion.h" #if CIRCUITPY_ATEXIT diff --git a/lib/utils/pyexec.h b/shared/runtime/pyexec.h similarity index 100% rename from lib/utils/pyexec.h rename to shared/runtime/pyexec.h diff --git a/lib/utils/semihosting.c b/shared/runtime/semihosting.c similarity index 100% rename from lib/utils/semihosting.c rename to shared/runtime/semihosting.c diff --git a/shared/runtime/semihosting.h b/shared/runtime/semihosting.h new file mode 100644 index 0000000000..d053a03eda --- /dev/null +++ b/shared/runtime/semihosting.h @@ -0,0 +1,51 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2018 Ayke van Laethem + * + * 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_LIB_UTILS_SEMIHOSTING_H +#define MICROPY_INCLUDED_LIB_UTILS_SEMIHOSTING_H + +/* + +To use semi-hosting for a replacement UART: +- Add lib/semihosting/semihosting.c to the Makefile sources. +- Call mp_semihosting_init() in main(), around the time UART is initialized. +- Replace mp_hal_stdin_rx_chr and similar in mphalport.c with the semihosting equivalent. +- Include lib/semihosting/semihosting.h in the relevant files. + +Then make sure the debugger is attached and enables semihosting. In OpenOCD this is +done with ARM semihosting enable followed by reset. The terminal will need further +configuration to work with MicroPython (bash: stty raw -echo). + +*/ + +#include +#include + +void mp_semihosting_init(); +int mp_semihosting_rx_char(); +uint32_t mp_semihosting_tx_strn(const char *str, size_t len); +uint32_t mp_semihosting_tx_strn_cooked(const char *str, size_t len); + +#endif // MICROPY_INCLUDED_LIB_UTILS_SEMIHOSTING_H diff --git a/lib/utils/stdout_helpers.c b/shared/runtime/stdout_helpers.c similarity index 100% rename from lib/utils/stdout_helpers.c rename to shared/runtime/stdout_helpers.c diff --git a/lib/utils/sys_stdio_mphal.c b/shared/runtime/sys_stdio_mphal.c similarity index 100% rename from lib/utils/sys_stdio_mphal.c rename to shared/runtime/sys_stdio_mphal.c diff --git a/lib/timeutils/timeutils.c b/shared/timeutils/timeutils.c similarity index 95% rename from lib/timeutils/timeutils.c rename to shared/timeutils/timeutils.c index e77daeb707..d1a10a4c93 100644 --- a/lib/timeutils/timeutils.c +++ b/shared/timeutils/timeutils.c @@ -27,7 +27,7 @@ #include "py/obj.h" -#include "lib/timeutils/timeutils.h" +#include "shared/timeutils/timeutils.h" // LEAPOCH corresponds to 2000-03-01, which is a mod-400 year, immediately // after Feb 29. We calculate seconds as a signed integer relative to that. @@ -213,3 +213,10 @@ mp_uint_t timeutils_mktime_2000(mp_uint_t year, mp_int_t month, mp_int_t mday, } return timeutils_seconds_since_2000(year, month, mday, hours, minutes, seconds); } + +// Calculate the weekday from the date. +// The result is zero based with 0 = Monday. +// by Michael Keith and Tom Craver, 1990. +int timeutils_calc_weekday(int y, int m, int d) { + return ((d += m < 3 ? y-- : y - 2, 23 * m / 9 + d + 4 + y / 4 - y / 100 + y / 400) + 6) % 7; +} diff --git a/lib/timeutils/timeutils.h b/shared/timeutils/timeutils.h similarity index 98% rename from lib/timeutils/timeutils.h rename to shared/timeutils/timeutils.h index ac93e108a3..bfed13d3a4 100644 --- a/lib/timeutils/timeutils.h +++ b/shared/timeutils/timeutils.h @@ -100,4 +100,6 @@ static inline int64_t timeutils_nanoseconds_since_epoch_to_nanoseconds_since_197 #endif +int timeutils_calc_weekday(int y, int m, int d); + #endif // MICROPY_INCLUDED_LIB_TIMEUTILS_TIMEUTILS_H diff --git a/lib/upytesthelper/upytesthelper.c b/shared/upytesthelper/upytesthelper.c similarity index 100% rename from lib/upytesthelper/upytesthelper.c rename to shared/upytesthelper/upytesthelper.c diff --git a/lib/upytesthelper/upytesthelper.h b/shared/upytesthelper/upytesthelper.h similarity index 100% rename from lib/upytesthelper/upytesthelper.h rename to shared/upytesthelper/upytesthelper.h diff --git a/supervisor/serial.h b/supervisor/serial.h index 391a874e48..a9f45a8e38 100644 --- a/supervisor/serial.h +++ b/supervisor/serial.h @@ -34,9 +34,9 @@ #include "py/mpconfig.h" #ifdef CIRCUITPY_BOOT_OUTPUT_FILE -#include "lib/oofatfs/ff.h" +#include "py/misc.h" -extern FIL *boot_output_file; +extern vstr_t *boot_output; #endif void serial_early_init(void); diff --git a/supervisor/shared/bluetooth/file_transfer.c b/supervisor/shared/bluetooth/file_transfer.c index 03806ca5e1..d1841c87d0 100644 --- a/supervisor/shared/bluetooth/file_transfer.c +++ b/supervisor/shared/bluetooth/file_transfer.c @@ -28,7 +28,7 @@ #include "extmod/vfs.h" #include "extmod/vfs_fat.h" -#include "lib/timeutils/timeutils.h" +#include "shared/timeutils/timeutils.h" #include "shared-bindings/_bleio/__init__.h" #include "shared-bindings/_bleio/Adapter.h" @@ -525,18 +525,33 @@ STATIC uint8_t _process_mkdir(const uint8_t *raw_buf, size_t command_len) { return ANY_COMMAND; } +STATIC void send_listdir_entry_header(const struct listdir_entry *entry, mp_int_t max_packet_size) { + mp_int_t response_size = sizeof(struct listdir_entry); + if (max_packet_size >= response_size) { + common_hal_bleio_packet_buffer_write(&_transfer_packet_buffer, (const uint8_t *)entry, response_size, NULL, 0); + return; + } + // Split into 16 + 12 size packets to fit into 20 byte minimum packet size. + common_hal_bleio_packet_buffer_write(&_transfer_packet_buffer, (const uint8_t *)entry, 16, NULL, 0); + common_hal_bleio_packet_buffer_write(&_transfer_packet_buffer, ((const uint8_t *)entry) + 16, response_size - 16, NULL, 0); +} + STATIC uint8_t _process_listdir(uint8_t *raw_buf, size_t command_len) { const struct listdir_command *command = (struct listdir_command *)raw_buf; struct listdir_entry *entry = (struct listdir_entry *)raw_buf; size_t header_size = sizeof(struct listdir_command); - size_t response_size = sizeof(struct listdir_entry); + mp_int_t max_packet_size = common_hal_bleio_packet_buffer_get_outgoing_packet_length(&_transfer_packet_buffer); + if (max_packet_size < 0) { + // -1 means we're disconnected + return ANY_COMMAND; + } // We reuse the command buffer so that we can produce long packets without // making the stack large. if (command->path_length > (COMMAND_SIZE - header_size - 1)) { // -1 for the null we'll write // TODO: throw away any more packets of path. entry->command = LISTDIR_ENTRY; entry->status = STATUS_ERROR; - common_hal_bleio_packet_buffer_write(&_transfer_packet_buffer, (const uint8_t *)entry, response_size, NULL, 0); + send_listdir_entry_header(entry, max_packet_size); return ANY_COMMAND; } // We need to receive another packet to have the full path. @@ -560,7 +575,7 @@ STATIC uint8_t _process_listdir(uint8_t *raw_buf, size_t command_len) { if (res != FR_OK) { entry->status = STATUS_ERROR_NO_FILE; - common_hal_bleio_packet_buffer_write(&_transfer_packet_buffer, (const uint8_t *)entry, response_size, NULL, 0); + send_listdir_entry_header(entry, max_packet_size); return ANY_COMMAND; } FILINFO file_info; @@ -594,7 +609,7 @@ STATIC uint8_t _process_listdir(uint8_t *raw_buf, size_t command_len) { size_t name_length = strlen(file_info.fname); entry->path_length = name_length; - common_hal_bleio_packet_buffer_write(&_transfer_packet_buffer, (const uint8_t *)entry, response_size, NULL, 0); + send_listdir_entry_header(entry, max_packet_size); size_t fn_offset = 0; while (fn_offset < name_length) { size_t fn_size = MIN(name_length - fn_offset, 4); @@ -607,7 +622,7 @@ STATIC uint8_t _process_listdir(uint8_t *raw_buf, size_t command_len) { entry->entry_number = entry->entry_count; entry->flags = 0; entry->file_size = 0; - common_hal_bleio_packet_buffer_write(&_transfer_packet_buffer, (const uint8_t *)entry, response_size, NULL, 0); + send_listdir_entry_header(entry, max_packet_size); return ANY_COMMAND; } diff --git a/supervisor/shared/external_flash/devices.h.jinja b/supervisor/shared/external_flash/devices.h.jinja index b200b75dca..7cad90df8a 100644 --- a/supervisor/shared/external_flash/devices.h.jinja +++ b/supervisor/shared/external_flash/devices.h.jinja @@ -41,6 +41,9 @@ .supports_qspi_writes = {{ device["32_qspi_write"] | lower() }}, \ .write_status_register_split = {{ device.write_status_register_split | lower() }}, \ .single_status_byte = {{ (device.quad_enable_status_byte == 1) | lower() }}, \ + .no_ready_bit = {{ (device.no_ready_bit == 1) | lower() }}, \ + .no_erase_cmd = {{ (device.no_erase_cmd == 1) | lower() }}, \ + .no_reset_cmd = {{ (device.no_reset_cmd == 1) | lower() }}, \ } {% endfor %} diff --git a/supervisor/shared/flash.c b/supervisor/shared/flash.c index 0e5dd0f200..bc7c1876dc 100644 --- a/supervisor/shared/flash.c +++ b/supervisor/shared/flash.c @@ -38,9 +38,9 @@ const mp_obj_type_t supervisor_flash_type; STATIC const mp_obj_base_t supervisor_flash_obj = {&supervisor_flash_type}; -STATIC mp_obj_t supervisor_flash_obj_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { +STATIC mp_obj_t supervisor_flash_obj_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { // check arguments - mp_arg_check_num(n_args, kw_args, 0, 0, false); + mp_arg_check_num(n_args, n_kw, 0, 0, false); // return singleton object return (mp_obj_t)&supervisor_flash_obj; diff --git a/supervisor/shared/memory.c b/supervisor/shared/memory.c index cf7dbf7ed7..ff0382fc17 100644 --- a/supervisor/shared/memory.c +++ b/supervisor/shared/memory.c @@ -52,6 +52,10 @@ enum { + 1 // hid_report_descriptor_allocation + 1 // hid_devices_allocation #endif + + #if CIRCUITPY_USB_VENDOR + + 1 // usb_vendor_add_descriptor + #endif , CIRCUITPY_SUPERVISOR_MOVABLE_ALLOC_COUNT = diff --git a/supervisor/shared/micropython.c b/supervisor/shared/micropython.c index 76ac2bf5b7..6c850f9b00 100644 --- a/supervisor/shared/micropython.c +++ b/supervisor/shared/micropython.c @@ -59,9 +59,14 @@ void mp_hal_stdout_tx_strn(const char *str, size_t len) { toggle_tx_led(); #ifdef CIRCUITPY_BOOT_OUTPUT_FILE - if (boot_output_file != NULL) { - UINT bytes_written = 0; - f_write(boot_output_file, str, len, &bytes_written); + if (boot_output != NULL) { + // Ensure boot_out.txt is capped at 1 filesystem block and ends with a newline + if (len + boot_output->len > 508) { + vstr_add_str(boot_output, "...\n"); + boot_output = NULL; + } else { + vstr_add_strn(boot_output, str, len); + } } #endif diff --git a/supervisor/shared/safe_mode.c b/supervisor/shared/safe_mode.c index 646467ce39..59b5ab838d 100644 --- a/supervisor/shared/safe_mode.c +++ b/supervisor/shared/safe_mode.c @@ -169,6 +169,9 @@ void print_safe_mode_message(safe_mode_t reason) { case USB_TOO_MANY_INTERFACE_NAMES: message = translate("USB devices specify too many interface names."); break; + case USB_BOOT_DEVICE_NOT_INTERFACE_ZERO: + message = translate("Boot device must be first device (interface #0)."); + break; case WATCHDOG_RESET: message = translate("Watchdog timer expired."); break; diff --git a/supervisor/shared/safe_mode.h b/supervisor/shared/safe_mode.h index 01aed37d63..600abd7672 100644 --- a/supervisor/shared/safe_mode.h +++ b/supervisor/shared/safe_mode.h @@ -46,6 +46,7 @@ typedef enum { WATCHDOG_RESET, USB_TOO_MANY_ENDPOINTS, USB_TOO_MANY_INTERFACE_NAMES, + USB_BOOT_DEVICE_NOT_INTERFACE_ZERO, NO_HEAP, } safe_mode_t; diff --git a/supervisor/shared/status_leds.h b/supervisor/shared/status_leds.h index 4a55922845..f41ff71c68 100644 --- a/supervisor/shared/status_leds.h +++ b/supervisor/shared/status_leds.h @@ -30,7 +30,7 @@ #include #include -#include "lib/utils/pyexec.h" +#include "shared/runtime/pyexec.h" #include "supervisor/port.h" #include "py/mpconfig.h" diff --git a/supervisor/shared/tick.c b/supervisor/shared/tick.c index 397151ccc8..4ce884d7e1 100644 --- a/supervisor/shared/tick.c +++ b/supervisor/shared/tick.c @@ -26,7 +26,7 @@ #include "supervisor/shared/tick.h" -#include "lib/utils/interrupt_char.h" +#include "shared/runtime/interrupt_char.h" #include "py/mpstate.h" #include "py/runtime.h" #include "supervisor/linker.h" diff --git a/supervisor/shared/usb/usb.c b/supervisor/shared/usb/usb.c index 8333f662b5..815773fa2c 100644 --- a/supervisor/shared/usb/usb.c +++ b/supervisor/shared/usb/usb.c @@ -32,8 +32,8 @@ #include "supervisor/serial.h" #include "supervisor/usb.h" #include "supervisor/shared/workflow.h" -#include "lib/utils/interrupt_char.h" -#include "lib/mp-readline/readline.h" +#include "shared/runtime/interrupt_char.h" +#include "shared/readline/readline.h" #if CIRCUITPY_STORAGE #include "shared-module/storage/__init__.h" @@ -54,13 +54,23 @@ #include "tusb.h" #if CIRCUITPY_USB_VENDOR +#include "usb_vendor_descriptors.h" // The WebUSB support being conditionally added to this file is based on the // tinyusb demo examples/device/webusb_serial. -extern const tusb_desc_webusb_url_t desc_webusb_url; - static bool web_serial_connected = false; + +#define URL "www.tinyusb.org/examples/webusb-serial" + +const tusb_desc_webusb_url_t desc_webusb_url = +{ + .bLength = 3 + sizeof(URL) - 1, + .bDescriptorType = 3, // WEBUSB URL type + .bScheme = 1, // 0: http, 1: https + .url = URL +}; + #endif bool usb_enabled(void) { @@ -253,10 +263,11 @@ bool tud_vendor_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_requ case VENDOR_REQUEST_MICROSOFT: if (request->wIndex == 7) { // Get Microsoft OS 2.0 compatible descriptor + // let's just hope the target architecture always has the same endianness uint16_t total_len; - memcpy(&total_len, desc_ms_os_20 + 8, 2); + memcpy(&total_len, vendor_ms_os_20_descriptor() + 8, 2); - return tud_control_xfer(rhport, request, (void *)desc_ms_os_20, total_len); + return tud_control_xfer(rhport, request, (void *)vendor_ms_os_20_descriptor(), total_len); } else { return false; } @@ -289,7 +300,7 @@ bool tud_vendor_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_requ // Only called when console is enabled. void tud_cdc_rx_wanted_cb(uint8_t itf, char wanted_char) { - // Workaround for using lib/utils/interrupt_char.c + // Workaround for using shared/runtime/interrupt_char.c // Compare mp_interrupt_char with wanted_char and ignore if not matched if (mp_interrupt_char == wanted_char) { tud_cdc_n_read_flush(itf); // flush read fifo diff --git a/supervisor/shared/usb/usb_desc.c b/supervisor/shared/usb/usb_desc.c index bad0d84523..9fe1eadd4e 100644 --- a/supervisor/shared/usb/usb_desc.c +++ b/supervisor/shared/usb/usb_desc.c @@ -170,6 +170,13 @@ static void usb_build_configuration_descriptor(void) { } #endif + #if CIRCUITPY_USB_VENDOR + if (usb_vendor_enabled()) { + total_descriptor_length += usb_vendor_descriptor_length(); + } + #endif + + // Now we now how big the configuration descriptor will be, so we can allocate space for it. configuration_descriptor_allocation = allocate_memory(align32_size(total_descriptor_length), @@ -221,9 +228,14 @@ static void usb_build_configuration_descriptor(void) { #if CIRCUITPY_USB_HID if (usb_hid_enabled()) { + if (usb_hid_boot_device() > 0 && descriptor_counts.current_interface > 0) { + // Hosts using boot devices generally to expect them to be at interface zero, + // and will not work properly otherwise. + reset_into_safe_mode(USB_BOOT_DEVICE_NOT_INTERFACE_ZERO); + } descriptor_buf_remaining += usb_hid_add_descriptor( descriptor_buf_remaining, &descriptor_counts, ¤t_interface_string, - usb_hid_report_descriptor_length()); + usb_hid_report_descriptor_length(), usb_hid_boot_device()); } #endif @@ -235,6 +247,13 @@ static void usb_build_configuration_descriptor(void) { } #endif + #if CIRCUITPY_USB_VENDOR + if (usb_vendor_enabled()) { + descriptor_buf_remaining += usb_vendor_add_descriptor( + descriptor_buf_remaining, &descriptor_counts, ¤t_interface_string); + } + #endif + // Now we know how many interfaces have been used. configuration_descriptor[CONFIG_NUM_INTERFACES_INDEX] = descriptor_counts.current_interface; diff --git a/supervisor/shared/usb/usb_vendor_descriptors.h b/supervisor/shared/usb/usb_vendor_descriptors.h new file mode 100644 index 0000000000..0b41c09d34 --- /dev/null +++ b/supervisor/shared/usb/usb_vendor_descriptors.h @@ -0,0 +1,39 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2019 Ha Thach (tinyusb.org) + * + * 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 USB_DESCRIPTORS_H_ +#define USB_DESCRIPTORS_H_ + +#include + +enum +{ + VENDOR_REQUEST_WEBUSB = 1, + VENDOR_REQUEST_MICROSOFT = 2 +}; + +size_t vendor_ms_os_20_descriptor_length(void); +uint8_t const *vendor_ms_os_20_descriptor(void); + +#endif /* USB_DESCRIPTORS_H_ */ diff --git a/supervisor/supervisor.mk b/supervisor/supervisor.mk index 7484c56092..6789ab32ea 100644 --- a/supervisor/supervisor.mk +++ b/supervisor/supervisor.mk @@ -65,7 +65,7 @@ else $(HEADER_BUILD)/devices.h : ../../supervisor/shared/external_flash/devices.h.jinja ../../tools/gen_nvm_devices.py | $(HEADER_BUILD) $(STEPECHO) "GEN $@" $(Q)install -d $(BUILD)/genhdr - $(Q)$(PYTHON3) ../../tools/gen_nvm_devices.py $< $@ + $(Q)$(PYTHON) ../../tools/gen_nvm_devices.py $< $@ $(BUILD)/supervisor/shared/external_flash/external_flash.o: $(HEADER_BUILD)/devices.h @@ -185,7 +185,7 @@ CIRCUITPY_DISPLAY_FONT ?= "../../tools/fonts/ter-u12n.bdf" $(BUILD)/autogen_display_resources.c: ../../tools/gen_display_resources.py $(HEADER_BUILD)/qstrdefs.generated.h Makefile | $(HEADER_BUILD) $(STEPECHO) "GEN $@" $(Q)install -d $(BUILD)/genhdr - $(Q)$(PYTHON3) ../../tools/gen_display_resources.py \ + $(Q)$(PYTHON) ../../tools/gen_display_resources.py \ --font $(CIRCUITPY_DISPLAY_FONT) \ --sample_file $(HEADER_BUILD)/qstrdefs.generated.h \ --output_c_file $(BUILD)/autogen_display_resources.c diff --git a/tests/basics/errno1.py b/tests/basics/errno1.py index cef5326b4a..d9a895a972 100644 --- a/tests/basics/errno1.py +++ b/tests/basics/errno1.py @@ -11,10 +11,11 @@ print(type(uerrno.EIO)) # check that errors are rendered in a nice way msg = str(OSError(uerrno.EIO)) -print(msg[:7], msg[msg.find(']'):]) - -msg = str(OSError(uerrno.ENOBUFS)) -print(msg[:7], msg[msg.find(']'):]) +print(msg[:7], msg[-5:]) +msg = str(OSError(uerrno.EIO, "details")) +print(msg[:7], msg[-14:]) +msg = str(OSError(uerrno.EIO, "details", "more details")) +print(msg[:1], msg[-28:]) # check that unknown errno is still rendered print(str(OSError(9999))) diff --git a/tests/basics/errno1.py.exp b/tests/basics/errno1.py.exp index b550468985..ac3619161f 100644 --- a/tests/basics/errno1.py.exp +++ b/tests/basics/errno1.py.exp @@ -1,5 +1,6 @@ -[Errno ] Input/output error -[Errno ] ENOBUFS +[Errno error +[Errno error: details +( , 'details', 'more details') 9999 uerrno diff --git a/tests/basics/gen_yield_from_stopped.py b/tests/basics/gen_yield_from_stopped.py index 468679b615..82feefed08 100644 --- a/tests/basics/gen_yield_from_stopped.py +++ b/tests/basics/gen_yield_from_stopped.py @@ -16,3 +16,15 @@ try: next(run()) except StopIteration: print("StopIteration") + + +# Where "f" is a native generator +def run(): + print((yield from f)) + + +f = zip() +try: + next(run()) +except StopIteration: + print("StopIteration") diff --git a/tests/basics/stopiteration.py b/tests/basics/stopiteration.py new file mode 100644 index 0000000000..d4719c9bc3 --- /dev/null +++ b/tests/basics/stopiteration.py @@ -0,0 +1,63 @@ +# test StopIteration interaction with generators + +try: + enumerate, exec +except: + print("SKIP") + raise SystemExit + + +def get_stop_iter_arg(msg, code): + try: + exec(code) + print("FAIL") + except StopIteration as er: + print(msg, er.args) + + +class A: + def __iter__(self): + return self + + def __next__(self): + raise StopIteration(42) + + +class B: + def __getitem__(self, index): + # argument to StopIteration should get ignored + raise StopIteration(42) + + +def gen(x): + return x + yield + + +def gen2(x): + try: + yield + except ValueError: + pass + return x + + +get_stop_iter_arg("next", "next(A())") +get_stop_iter_arg("iter", "next(iter(B()))") +get_stop_iter_arg("enumerate", "next(enumerate(A()))") +get_stop_iter_arg("map", "next(map(lambda x:x, A()))") +get_stop_iter_arg("zip", "next(zip(A()))") +g = gen(None) +get_stop_iter_arg("generator0", "next(g)") +get_stop_iter_arg("generator1", "next(g)") +g = gen(42) +get_stop_iter_arg("generator0", "next(g)") +get_stop_iter_arg("generator1", "next(g)") +get_stop_iter_arg("send", "gen(None).send(None)") +get_stop_iter_arg("send", "gen(42).send(None)") +g = gen2(None) +next(g) +get_stop_iter_arg("throw", "g.throw(ValueError)") +g = gen2(42) +next(g) +get_stop_iter_arg("throw", "g.throw(ValueError)") diff --git a/tests/basics/string_fstring.py b/tests/basics/string_fstring.py new file mode 100644 index 0000000000..4f7225fcad --- /dev/null +++ b/tests/basics/string_fstring.py @@ -0,0 +1,51 @@ +def f(): + return 4 +def g(_): + return 5 +def h(): + return 6 + +print(f'no interpolation') +print(f"no interpolation") +print(f"""no interpolation""") + +x, y = 1, 2 +print(f'{x}') +print(f'{x:08x}') +print(f'a {x} b {y} c') +print(f'a {x:08x} b {y} c') + +print(f'a {"hello"} b') +print(f'a {f() + g("foo") + h()} b') + +def foo(a, b): + return f'{x}{y}{a}{b}' +print(foo(7, 8)) + +# PEP-0498 specifies that '\\' and '#' must be disallowed explicitly, whereas +# MicroPython relies on the syntax error as a result of the substitution. + +print(f"\\") +print(f'#') +try: + eval("f'{\}'") +except SyntaxError: + print('SyntaxError') +try: + eval("f'{#}'") +except SyntaxError: + print('SyntaxError') + + +# PEP-0498 specifies that handling of double braces '{{' or '}}' should +# behave like str.format. +print(f'{{}}') +print(f'{{{4*10}}}', '{40}') + +# A single closing brace, unlike str.format should raise a syntax error. +# MicroPython instead raises ValueError at runtime from the substitution. +try: + eval("f'{{}'") +except (ValueError, SyntaxError): + # MicroPython incorrectly raises ValueError here. + print('SyntaxError') diff --git a/tests/basics/string_fstring_debug.py b/tests/basics/string_fstring_debug.py new file mode 100644 index 0000000000..76a448ca06 --- /dev/null +++ b/tests/basics/string_fstring_debug.py @@ -0,0 +1,23 @@ +# test f-string debug feature {x=} + + +def f(): + return 4 + + +def g(_): + return 5 + + +def h(): + return 6 + + +x, y = 1, 2 +print(f"{x=}") +print(f"{x=:08x}") +print(f"a {x=} b {y} c") +print(f"a {x=:08x} b {y} c") + +print(f'a {f() + g("foo") + h()=} b') +print(f'a {f() + g("foo") + h()=:08x} b') diff --git a/tests/basics/string_fstring_debug.py.exp b/tests/basics/string_fstring_debug.py.exp new file mode 100644 index 0000000000..563030f400 --- /dev/null +++ b/tests/basics/string_fstring_debug.py.exp @@ -0,0 +1,6 @@ +x=1 +x=00000001 +a x=1 b 2 c +a x=00000001 b 2 c +a f() + g("foo") + h()=15 b +a f() + g("foo") + h()=0000000f b diff --git a/tests/basics/string_pep498_fstring.py b/tests/basics/string_pep498_fstring.py index c645a730c6..82a2ca38e4 100644 --- a/tests/basics/string_pep498_fstring.py +++ b/tests/basics/string_pep498_fstring.py @@ -103,7 +103,7 @@ assert f'result={foo()}' == 'result={result}'.format(result=foo()) x = 10 y = 'hi' -assert (f'h' f'i') == 'hi' +#assert (f'h' f'i') == 'hi' #assert (f'h' 'i') == 'hi' #assert ('h' f'i') == 'hi' assert f'{x:^4}' == ' 10 ' diff --git a/tests/basics/subclass_native3.py b/tests/basics/subclass_native3.py index ac5aabfed7..0c45c4924f 100644 --- a/tests/basics/subclass_native3.py +++ b/tests/basics/subclass_native3.py @@ -34,6 +34,26 @@ print(MyStopIteration().value) print(MyStopIteration(1).value) +class Iter: + def __iter__(self): + return self + + def __next__(self): + # This exception will stop the "yield from", with a value of 3 + raise MyStopIteration(3) + + +def gen(): + print((yield from Iter())) + return 4 + + +try: + next(gen()) +except StopIteration as er: + print(er.args) + + class MyOSError(OSError): pass diff --git a/tests/basics/unary_op.py b/tests/basics/unary_op.py index bd78a20d0d..2239e2b206 100644 --- a/tests/basics/unary_op.py +++ b/tests/basics/unary_op.py @@ -23,5 +23,12 @@ print(not A()) # check user instances derived from builtins class B(int): pass print(not B()) +print(True if B() else False) class C(list): pass print(not C()) +print(True if C() else False) +# type doesn't define unary_op +class D(type): pass +d = D("foo", (), {}) +print(not d) +print(True if d else False) diff --git a/tests/circuitpython-manual/audiopwmio/wavefile_pause_resume.py b/tests/circuitpython-manual/audiopwmio/wavefile_pause_resume.py index 27912d3217..7b444aa997 100644 --- a/tests/circuitpython-manual/audiopwmio/wavefile_pause_resume.py +++ b/tests/circuitpython-manual/audiopwmio/wavefile_pause_resume.py @@ -3,7 +3,6 @@ import audiopwmio import board import digitalio import time -import math import os trigger = digitalio.DigitalInOut(board.D4) diff --git a/tests/circuitpython-manual/audiopwmio/wavefile_playback.py b/tests/circuitpython-manual/audiopwmio/wavefile_playback.py index 0adbf2b19c..a7de8c90ca 100644 --- a/tests/circuitpython-manual/audiopwmio/wavefile_playback.py +++ b/tests/circuitpython-manual/audiopwmio/wavefile_playback.py @@ -3,7 +3,6 @@ import audiopwmio import board import digitalio import time -import math import os trigger = digitalio.DigitalInOut(board.D4) diff --git a/tests/cmdline/cmd_parsetree.py b/tests/cmdline/cmd_parsetree.py index 50da369543..483ea89373 100644 --- a/tests/cmdline/cmd_parsetree.py +++ b/tests/cmdline/cmd_parsetree.py @@ -10,3 +10,4 @@ d = b"bytes" e = b"a very long bytes that will not be interned" f = 123456789012345678901234567890 g = 123 +h = f"fstring: '{b}'" diff --git a/tests/cmdline/cmd_parsetree.py.exp b/tests/cmdline/cmd_parsetree.py.exp index abf547bc03..cc8ba82c05 100644 --- a/tests/cmdline/cmd_parsetree.py.exp +++ b/tests/cmdline/cmd_parsetree.py.exp @@ -1,6 +1,6 @@ ---------------- -[ 4] \(rule\|file_input_2\)(1) (n=9) - tok(10) +[ 4] \(rule\|file_input_2\)(1) (n=10) + tok(6) [ 4] \(rule\|for_stmt\)(22) (n=4) id(i) [ 4] \(rule\|atom_paren\)(45) (n=1) @@ -9,7 +9,7 @@ NULL [ 6] \(rule\|expr_stmt\)(5) (n=2) id(a) - tok(20) + tok(16) [ 7] \(rule\|expr_stmt\)(5) (n=2) id(b) str(str) @@ -28,6 +28,16 @@ [ 12] \(rule\|expr_stmt\)(5) (n=2) id(g) int(123) +[ 13] \(rule\|expr_stmt\)(5) (n=2) + id(h) +[ 13] \(rule\|atom_expr_normal\)(44) (n=2) +[ 13] literal const(\.\+) +[ 13] \(rule\|atom_expr_trailers\)(142) (n=2) +[ 13] \(rule\|trailer_period\)(50) (n=1) + id(format) +[ 13] \(rule\|trailer_paren\)(48) (n=1) +[ 13] \(rule\|arglist\)(164) (n=1) + id(b) ---------------- File cmdline/cmd_parsetree.py, code block '' (descriptor: \.\+, bytecode @\.\+ bytes) Raw bytecode (code_info_size=\\d\+, bytecode_size=\\d\+): @@ -46,6 +56,7 @@ arg names: bc=32 line=10 bc=37 line=11 bc=42 line=12 + bc=48 line=13 00 BUILD_TUPLE 0 02 GET_ITER_STACK 03 FOR_ITER 12 @@ -65,8 +76,13 @@ arg names: 39 STORE_NAME f 42 LOAD_CONST_SMALL_INT 123 45 STORE_NAME g -48 LOAD_CONST_NONE -49 RETURN_VALUE +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 mem: total=\\d\+, current=\\d\+, peak=\\d\+ stack: \\d\+ out of \\d\+ GC: total: \\d\+, used: \\d\+, free: \\d\+ diff --git a/tests/cpydiff/core_fstring_concat.py b/tests/cpydiff/core_fstring_concat.py new file mode 100644 index 0000000000..fd83527b5c --- /dev/null +++ b/tests/cpydiff/core_fstring_concat.py @@ -0,0 +1,12 @@ +""" +categories: Core +description: f-strings don't support concatenation with adjacent literals if the adjacent literals contain braces +cause: MicroPython is optimised for code space. +workaround: Use the + operator between literal strings when either is an f-string +""" + +x = 1 +print("aa" f"{x}") +print(f"{x}" "ab") +print("a{}a" f"{x}") +print(f"{x}" "a{}b") diff --git a/tests/cpydiff/core_fstring_parser.py b/tests/cpydiff/core_fstring_parser.py new file mode 100644 index 0000000000..6917f3cfa4 --- /dev/null +++ b/tests/cpydiff/core_fstring_parser.py @@ -0,0 +1,9 @@ +""" +categories: Core +description: f-strings cannot support expressions that require parsing to resolve nested braces +cause: MicroPython is optimised for code space. +workaround: Only use simple expressions inside f-strings +""" + +f'{"hello {} world"}' +f"{repr({})}" diff --git a/tests/cpydiff/core_fstring_raw.py b/tests/cpydiff/core_fstring_raw.py new file mode 100644 index 0000000000..84e265f70f --- /dev/null +++ b/tests/cpydiff/core_fstring_raw.py @@ -0,0 +1,8 @@ +""" +categories: Core +description: Raw f-strings are not supported +cause: MicroPython is optimised for code space. +workaround: Unknown +""" + +rf"hello" diff --git a/tests/cpydiff/core_fstring_repr.py b/tests/cpydiff/core_fstring_repr.py new file mode 100644 index 0000000000..fcadcbf1b9 --- /dev/null +++ b/tests/cpydiff/core_fstring_repr.py @@ -0,0 +1,18 @@ +""" +categories: Core +description: f-strings don't support the !r, !s, and !a conversions +cause: MicroPython is optimised for code space. +workaround: Use repr(), str(), and ascii() explictly. +""" + + +class X: + def __repr__(self): + return "repr" + + def __str__(self): + return "str" + + +print(f"{X()!r}") +print(f"{X()!s}") diff --git a/tests/cpydiff/modules_struct_whitespace_in_format.py b/tests/cpydiff/modules_struct_whitespace_in_format.py new file mode 100644 index 0000000000..a882b38569 --- /dev/null +++ b/tests/cpydiff/modules_struct_whitespace_in_format.py @@ -0,0 +1,13 @@ +""" +categories: Modules,struct +description: Struct pack with whitespace in format, whitespace ignored by CPython, error on uPy +cause: MicroPython is optimised for code size. +workaround: Don't use spaces in format strings. +""" +import struct + +try: + print(struct.pack("b b", 1, 2)) + print("Should have worked") +except: + print("struct.error") diff --git a/tests/extmod/framebuf_palette.py b/tests/extmod/framebuf_palette.py new file mode 100644 index 0000000000..84db834c15 --- /dev/null +++ b/tests/extmod/framebuf_palette.py @@ -0,0 +1,35 @@ +# Test blit between different color spaces +try: + import framebuf, usys +except ImportError: + print("SKIP") + raise SystemExit + +# Monochrome glyph/icon +w = 8 +h = 8 +cbuf = bytearray(w * h // 8) +fbc = framebuf.FrameBuffer(cbuf, w, h, framebuf.MONO_HLSB) +fbc.line(0, 0, 7, 7, 1) + +# RGB565 destination +wd = 16 +hd = 16 +dest = bytearray(wd * hd * 2) +fbd = framebuf.FrameBuffer(dest, wd, hd, framebuf.RGB565) + +wp = 2 +bg = 0x1234 +fg = 0xF800 +pal = bytearray(wp * 2) +palette = framebuf.FrameBuffer(pal, wp, 1, framebuf.RGB565) +palette.pixel(0, 0, bg) +palette.pixel(1, 0, fg) + +fbd.blit(fbc, 0, 0, -1, palette) + +print(fbd.pixel(0, 0) == fg) +print(fbd.pixel(7, 7) == fg) +print(fbd.pixel(8, 8) == 0) # Ouside blit +print(fbd.pixel(0, 1) == bg) +print(fbd.pixel(1, 0) == bg) diff --git a/tests/extmod/framebuf_palette.py.exp b/tests/extmod/framebuf_palette.py.exp new file mode 100644 index 0000000000..2e883c51de --- /dev/null +++ b/tests/extmod/framebuf_palette.py.exp @@ -0,0 +1,5 @@ +True +True +True +True +True diff --git a/tests/extmod/uasyncio_heaplock.py b/tests/extmod/uasyncio_heaplock.py index 771d3f0d97..3a92d36c9f 100644 --- a/tests/extmod/uasyncio_heaplock.py +++ b/tests/extmod/uasyncio_heaplock.py @@ -29,15 +29,15 @@ async def task(id, n, t): async def main(): - t1 = asyncio.create_task(task(1, 4, 10)) - t2 = asyncio.create_task(task(2, 4, 25)) + t1 = asyncio.create_task(task(1, 4, 20)) + t2 = asyncio.create_task(task(2, 2, 50)) micropython.heap_lock() print("start") await asyncio.sleep_ms(1) print("sleep") - await asyncio.sleep_ms(100) + await asyncio.sleep_ms(70) print("finish") micropython.heap_unlock() diff --git a/tests/extmod/uasyncio_heaplock.py.exp b/tests/extmod/uasyncio_heaplock.py.exp index a967cc3197..68c6366c6f 100644 --- a/tests/extmod/uasyncio_heaplock.py.exp +++ b/tests/extmod/uasyncio_heaplock.py.exp @@ -6,6 +6,4 @@ sleep 1 2 2 1 1 3 -2 2 -2 3 finish diff --git a/tests/extmod/ujson_dump_separators.py b/tests/extmod/ujson_dump_separators.py new file mode 100644 index 0000000000..e19b99a26d --- /dev/null +++ b/tests/extmod/ujson_dump_separators.py @@ -0,0 +1,62 @@ +try: + from uio import StringIO + import ujson as json +except: + try: + from io import StringIO + import json + except ImportError: + print("SKIP") + raise SystemExit + +for sep in [ + None, + (", ", ": "), + (",", ": "), + (",", ":"), + [", ", ": "], + [",", ": "], + [",", ":"], +]: + s = StringIO() + json.dump(False, s, separators=sep) + print(s.getvalue()) + + s = StringIO() + json.dump({"a": (2, [3, None])}, s, separators=sep) + print(s.getvalue()) + + # dump to a small-int not allowed + try: + json.dump(123, 1, separators=sep) + except (AttributeError, OSError): # CPython and uPy have different errors + print("Exception") + + # dump to an object not allowed + try: + json.dump(123, {}, separators=sep) + except (AttributeError, OSError): # CPython and uPy have different errors + print("Exception") + + +try: + s = StringIO() + json.dump(False, s, separators={"a": 1}) +except (TypeError, ValueError): # CPython and uPy have different errors + print("Exception") + +# invalid separator types +for sep in [1, object()]: + try: + s = StringIO() + json.dump(False, s, separators=sep) + except TypeError: + print("Exception") + +# too many/ not enough separators +for sep in [(), (",", ":", "?"), (",",), []]: + try: + s = StringIO() + json.dump(False, s, separators=sep) + except ValueError: + print("Exception") diff --git a/tests/extmod/ujson_dumps_separators.py b/tests/extmod/ujson_dumps_separators.py new file mode 100644 index 0000000000..efb541fe8b --- /dev/null +++ b/tests/extmod/ujson_dumps_separators.py @@ -0,0 +1,60 @@ +try: + import ujson as json +except ImportError: + try: + import json + except ImportError: + print("SKIP") + raise SystemExit + +for sep in [ + None, + (", ", ": "), + (",", ": "), + (",", ":"), + [", ", ": "], + [",", ": "], + [",", ":"], +]: + print(json.dumps(False, separators=sep)) + print(json.dumps(True, separators=sep)) + print(json.dumps(None, separators=sep)) + print(json.dumps(1, separators=sep)) + print(json.dumps("abc", separators=sep)) + print(json.dumps("\x00\x01\x7e", separators=sep)) + print(json.dumps([], separators=sep)) + print(json.dumps([1], separators=sep)) + print(json.dumps([1, 2], separators=sep)) + print(json.dumps([1, True], separators=sep)) + print(json.dumps((), separators=sep)) + print(json.dumps((1,), separators=sep)) + print(json.dumps((1, 2), separators=sep)) + print(json.dumps((1, (2, 3)), separators=sep)) + print(json.dumps({}, separators=sep)) + print(json.dumps({"a": 1}, separators=sep)) + print(json.dumps({"a": (2, [3, None])}, separators=sep)) + print(json.dumps('"quoted"', separators=sep)) + print(json.dumps("space\n\r\tspace", separators=sep)) + print(json.dumps({None: -1}, separators=sep)) + print(json.dumps({False: 0}, separators=sep)) + print(json.dumps({True: 1}, separators=sep)) + print(json.dumps({1: 2}, separators=sep)) + +try: + json.dumps(False, separators={"a": 1}) +except (TypeError, ValueError): # CPython and uPy have different errors + print("Exception") + +# invalid separator types +for sep in [1, object()]: + try: + json.dumps(False, separators=sep) + except TypeError: + print("Exception") + +# too many/ not enough separators +for sep in [(), (",", ":", "?"), (",",), []]: + try: + json.dumps(False, separators=sep) + except ValueError: + print("Exception") diff --git a/tests/extmod/vfs_fat_finaliser.py b/tests/extmod/vfs_fat_finaliser.py index b4ec8f89d2..c2f5966963 100644 --- a/tests/extmod/vfs_fat_finaliser.py +++ b/tests/extmod/vfs_fat_finaliser.py @@ -56,6 +56,13 @@ micropython.heap_unlock() # Here we test that the finaliser is actually called during a garbage collection. import gc +# Do a large number of single-block allocations to move the GC head forwards, +# ensuring that the files are allocated from never-before-used blocks and +# therefore couldn't possibly have any references to them left behind on +# the stack. +for i in range(1024): + [] + N = 4 for i in range(N): n = "x%d" % i diff --git a/tests/feature_check/fstring.py b/tests/feature_check/fstring.py new file mode 100644 index 0000000000..14792bce0a --- /dev/null +++ b/tests/feature_check/fstring.py @@ -0,0 +1,3 @@ +# check whether f-strings (PEP-498) are supported +a = 1 +print(f"a={a}") diff --git a/tests/feature_check/fstring.py.exp b/tests/feature_check/fstring.py.exp new file mode 100644 index 0000000000..73cdb8bcc8 --- /dev/null +++ b/tests/feature_check/fstring.py.exp @@ -0,0 +1 @@ +a=1 diff --git a/tests/micropython/native_misc.py b/tests/micropython/native_misc.py index 7c5415375e..f5ef807fe1 100644 --- a/tests/micropython/native_misc.py +++ b/tests/micropython/native_misc.py @@ -38,3 +38,13 @@ def f(a): f(False) f(True) + + +# stack settling in branch +@micropython.native +def f(a): + print(1, 2, 3, 4 if a else 5) + + +f(False) +f(True) diff --git a/tests/micropython/native_misc.py.exp b/tests/micropython/native_misc.py.exp index b3e1389ef7..8eec04228f 100644 --- a/tests/micropython/native_misc.py.exp +++ b/tests/micropython/native_misc.py.exp @@ -4,3 +4,5 @@ 6 True False +1 2 3 5 +1 2 3 4 diff --git a/tests/pybnative/while.py b/tests/pybnative/while.py index 0f397dd377..10625e8717 100644 --- a/tests/pybnative/while.py +++ b/tests/pybnative/while.py @@ -1,4 +1,4 @@ -import pyb +import time, pyb @micropython.native @@ -8,7 +8,7 @@ def f(led, n, d): while i < n: print(i) led.toggle() - pyb.delay(d) + time.sleep_ms(d) i += 1 led.off() diff --git a/tests/run-multitests.py b/tests/run-multitests.py index b4afc1e526..34389e4292 100755 --- a/tests/run-multitests.py +++ b/tests/run-multitests.py @@ -46,6 +46,16 @@ class multitest: print("NEXT") multitest.flush() @staticmethod + def broadcast(msg): + print("BROADCAST", msg) + multitest.flush() + @staticmethod + def wait(msg): + msg = "BROADCAST " + msg + while True: + if sys.stdin.readline().rstrip() == msg: + return + @staticmethod def globals(**gs): for g in gs: print("SET {{}} = {{!r}}".format(g, gs[g])) @@ -126,14 +136,12 @@ class PyInstanceSubProcess(PyInstance): def start_script(self, script): self.popen = subprocess.Popen( - self.argv, + self.argv + ["-c", script], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, env=self.env, ) - self.popen.stdin.write(script) - self.popen.stdin.close() self.finished = False def stop(self): @@ -141,7 +149,7 @@ class PyInstanceSubProcess(PyInstance): self.popen.terminate() def readline(self): - sel = select.select([self.popen.stdout.raw], [], [], 0.1) + sel = select.select([self.popen.stdout.raw], [], [], 0.001) if not sel[0]: self.finished = self.popen.poll() is not None return None, None @@ -152,6 +160,10 @@ class PyInstanceSubProcess(PyInstance): else: return str(out.rstrip(), "ascii"), None + def write(self, data): + self.popen.stdin.write(data) + self.popen.stdin.flush() + def is_finished(self): return self.finished @@ -220,6 +232,9 @@ class PyInstancePyboard(PyInstance): err = None return str(out.rstrip(), "ascii"), err + def write(self, data): + self.pyb.serial.write(data) + def is_finished(self): return self.finished @@ -318,7 +333,12 @@ def run_test_on_instances(test_file, num_instances, instances): last_read_time[idx] = time.time() if out is not None and not any(m in out for m in IGNORE_OUTPUT_MATCHES): trace_instance_output(idx, out) - output[idx].append(out) + if out.startswith("BROADCAST "): + for instance2 in instances: + if instance2 is not instance: + instance2.write(bytes(out, "ascii") + b"\r\n") + else: + output[idx].append(out) if err is not None: trace_instance_output(idx, err) output[idx].append(err) diff --git a/tests/run-tests.py b/tests/run-tests.py index f33822cb9b..4315b5eaaf 100755 --- a/tests/run-tests.py +++ b/tests/run-tests.py @@ -299,6 +299,7 @@ def run_tests(pyb, tests, args, result_dir, num_threads=1): skip_const = False skip_revops = False skip_io_module = False + skip_fstring = False skip_endian = False has_complex = True has_coverage = False @@ -357,6 +358,11 @@ def run_tests(pyb, tests, args, result_dir, num_threads=1): if output != b"uio\n": skip_io_module = True + # Check if fstring feature is enabled, and skip such tests if it doesn't + output = run_feature_check(pyb, args, base_path, "fstring.py") + if output != b"a=1\n": + skip_fstring = True + # Check if emacs repl is supported, and skip such tests if it's not t = run_feature_check(pyb, args, base_path, "repl_emacs_check.py") if "True" not in str(t, "ascii"): @@ -552,6 +558,7 @@ def run_tests(pyb, tests, args, result_dir, num_threads=1): is_async = test_name.startswith(("async_", "uasyncio_")) is_const = test_name.startswith("const") is_io_module = test_name.startswith("io_") + is_fstring = test_name.startswith("string_fstring") skip_it = test_file in skip_tests skip_it |= skip_native and is_native @@ -564,6 +571,7 @@ def run_tests(pyb, tests, args, result_dir, num_threads=1): skip_it |= skip_const and is_const skip_it |= skip_revops and "reverse_op" in test_name skip_it |= skip_io_module and is_io_module + skip_it |= skip_fstring and is_fstring if args.list_tests: if not skip_it: diff --git a/tests/unix/extra_coverage.py.exp b/tests/unix/extra_coverage.py.exp index 2cf48de142..3a1e7f280b 100644 --- a/tests/unix/extra_coverage.py.exp +++ b/tests/unix/extra_coverage.py.exp @@ -30,13 +30,15 @@ ame__ mport builtins micropython _thread array -btree cexample cmath collections -cppexample ffi framebuf gc -hashlib math qrio sys -termios ubinascii uctypes uerrno -uheapq uio ujson ulab -uos urandom ure uselect -ustruct utime utimeq uzlib +binascii btree cexample cmath +collections cppexample displayio errno +ffi framebuf gc gifio +hashlib json math qrio +re sys termios ubinascii +uctypes uerrno uheapq uio +ujson ulab uos urandom +ure uselect ustruct utime +utimeq uzlib ime utime utimeq diff --git a/tools/build_board_info.py b/tools/build_board_info.py index de25015dd0..9c57dc64ab 100644 --- a/tools/build_board_info.py +++ b/tools/build_board_info.py @@ -65,6 +65,9 @@ extension_by_board = { "microbit_v2": COMBINED_HEX, # stm32 "meowbit_v121": UF2, + # esp32c3 + "ai_thinker_esp32-c3s": BIN, + "microdev_micro_c3": BIN, } language_allow_list = set( diff --git a/tools/ci_set_matrix.py b/tools/ci_set_matrix.py index 09c7311220..f4c036ca2a 100644 --- a/tools/ci_set_matrix.py +++ b/tools/ci_set_matrix.py @@ -62,8 +62,8 @@ def set_boards_to_build(build_all): if not build_all: boards_to_build = set() - board_pattern = re.compile(r"^ports\/\w+\/boards\/(\w+)\/") - port_pattern = re.compile(r"^ports\/(\w+)\/") + 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) @@ -88,7 +88,12 @@ def set_boards_to_build(build_all): arch_to_boards = {"arm": [], "riscv": [], "espressif": []} for board in boards_to_build: print(" ", board) - arch = PORT_TO_ARCH[board_to_port[board]] + port = board_to_port.get(board) + # A board can appear due to its _deletion_ (rare) + # if this happens it's not in `board_to_port`. + if not port: + continue + arch = PORT_TO_ARCH[port] arch_to_boards[arch].append(board) # Set the step outputs for each architecture diff --git a/tools/codeformat.py b/tools/codeformat.py index 863c27fdf5..1a7ea14c09 100644 --- a/tools/codeformat.py +++ b/tools/codeformat.py @@ -41,9 +41,9 @@ PATHS = [ "devices/**/*.[ch]", "drivers/bus/*.[ch]", "extmod/*.[ch]", - "lib/netutils/*.[ch]", - "lib/timeutils/*.[ch]", - "lib/utils/*.[ch]", + "shared/netutils/*.[ch]", + "shared/timeutils/*.[ch]", + "shared/runtime/*.[ch]", "mpy-cross/**/*.[ch]", "ports/**/*.[ch]", "py/**/*.[ch]", diff --git a/tools/gc_activity.md b/tools/gc_activity.md index 686d9b6b7b..b9fcb94188 100644 --- a/tools/gc_activity.md +++ b/tools/gc_activity.md @@ -45,7 +45,7 @@ main.c:298 main 5 blocks main.c:311 main 289 blocks main.c:211 start_mp 14 blocks main.c:196 maybe_run 14 blocks - ../lib/utils/pyexec.c:501 pyexec_file 14 blocks + ../shared/runtime/pyexec.c:501 pyexec_file 14 blocks main.c:352 mp_lexer_new_from_file 14 blocks ../py/../extmod/vfs_fat_lexer.c:80 fat_vfs_lexer_new_from_file 14 blocks ../py/qstr.c:184 qstr_from_str 14 blocks @@ -54,8 +54,8 @@ main.c:311 main 289 blocks ../py/qstr.c:146 qstr_add 6 blocks main.c:220 start_mp 275 blocks main.c:196 maybe_run 275 blocks - ../lib/utils/pyexec.c:508 pyexec_file 275 blocks - ../lib/utils/pyexec.c:82 parse_compile_execute 4 blocks + ../shared/runtime/pyexec.c:508 pyexec_file 275 blocks + ../shared/runtime/pyexec.c:82 parse_compile_execute 4 blocks ../py/compile.c:3511 mp_compile 3 blocks ../py/compile.c:3451 mp_compile_to_raw_code 3 blocks ../py/compile.c:3092 compile_scope 3 blocks @@ -63,7 +63,7 @@ main.c:311 main 289 blocks ../py/compile.c:3513 mp_compile 1 blocks ../py/emitglue.c:131 mp_make_function_from_raw_code 1 blocks ../py/objfun.c:364 mp_obj_new_fun_bc 1 blocks - ../lib/utils/pyexec.c:88 parse_compile_execute 271 blocks + ../shared/runtime/pyexec.c:88 parse_compile_execute 271 blocks ../py/runtime.c:551 mp_call_function_0 271 blocks ../py/runtime.c:577 mp_call_function_n_kw 271 blocks ../py/objfun.c:275 fun_bc_call 271 blocks @@ -185,7 +185,7 @@ main.c:311 main 289 blocks ../py/map.c:283 mp_map_lookup 2 blocks ../py/map.c:130 mp_map_rehash 2 blocks main.c:321 main 2 blocks - ../lib/utils/pyexec.c:374 pyexec_friendly_repl 2 blocks + ../shared/runtime/pyexec.c:374 pyexec_friendly_repl 2 blocks ../py/vstr.c:46 vstr_init 2 blocks 296 total blocks ``` diff --git a/tools/insert-usb-ids.py b/tools/insert-usb-ids.py index f63059ca1b..b0843ab3ee 100644 --- a/tools/insert-usb-ids.py +++ b/tools/insert-usb-ids.py @@ -12,6 +12,7 @@ import sys import re import string +config_prefix = "MICROPY_HW_USB_" needed_keys = ("USB_PID_CDC_MSC", "USB_PID_CDC_HID", "USB_PID_CDC", "USB_VID") @@ -20,10 +21,10 @@ def parse_usb_ids(filename): for line in open(filename).readlines(): line = line.rstrip("\r\n") match = re.match("^#define\s+(\w+)\s+\(0x([0-9A-Fa-f]+)\)$", line) - if match and match.group(1).startswith("USBD_"): - key = match.group(1).replace("USBD", "USB") + if match and match.group(1).startswith(config_prefix): + key = match.group(1).replace(config_prefix, "USB_") val = match.group(2) - print("key =", key, "val =", val) + # print("key =", key, "val =", val) if key in needed_keys: rv[key] = val for k in needed_keys: diff --git a/tools/makemanifest.py b/tools/makemanifest.py index 51de01dd8a..7897a83c6e 100644 --- a/tools/makemanifest.py +++ b/tools/makemanifest.py @@ -248,6 +248,7 @@ def main(): "-f", "--mpy-cross-flags", default="", help="flags to pass to mpy-cross" ) cmd_parser.add_argument("-v", "--var", action="append", help="variables to substitute") + cmd_parser.add_argument("--mpy-tool-flags", default="", help="flags to pass to mpy-tool") cmd_parser.add_argument("files", nargs="+", help="input manifest list") args = cmd_parser.parse_args() @@ -341,6 +342,7 @@ def main(): "-q", args.build_dir + "/genhdr/qstrdefs.preprocessed.h", ] + + args.mpy_tool_flags.split() + mpy_files ) if res != 0: diff --git a/tools/pyboard.py b/tools/pyboard.py index 3fca47b0b7..a43a4d0574 100755 --- a/tools/pyboard.py +++ b/tools/pyboard.py @@ -637,20 +637,40 @@ def main(): help="seconds to wait for USB connected board to become available", ) group = cmd_parser.add_mutually_exclusive_group() + group.add_argument( + "--soft-reset", + default=True, + action="store_true", + help="Whether to perform a soft reset when connecting to the board [default]", + ) + group.add_argument( + "--no-soft-reset", + action="store_false", + dest="soft_reset", + ) + group = cmd_parser.add_mutually_exclusive_group() group.add_argument( "--follow", action="store_true", + default=None, help="follow the output after running the scripts [default if no scripts given]", ) group.add_argument( "--no-follow", + action="store_false", + dest="follow", + ) + group = cmd_parser.add_mutually_exclusive_group() + group.add_argument( + "--exclusive", action="store_true", - help="Do not follow the output after running the scripts.", + default=True, + help="Open the serial device for exclusive access [default]", ) group.add_argument( "--no-exclusive", - action="store_true", - help="Do not try to open the serial device for exclusive access.", + action="store_false", + dest="exclusive", ) cmd_parser.add_argument( "-f", @@ -665,7 +685,7 @@ def main(): # open the connection to the pyboard try: pyb = Pyboard( - args.device, args.baudrate, args.user, args.password, args.wait, not args.no_exclusive + args.device, args.baudrate, args.user, args.password, args.wait, args.exclusive ) except PyboardError as er: print(er) @@ -676,7 +696,7 @@ def main(): # we must enter raw-REPL mode to execute commands # this will do a soft-reset of the board try: - pyb.enter_raw_repl() + pyb.enter_raw_repl(args.soft_reset) except PyboardError as er: print(er) pyb.close() @@ -684,13 +704,13 @@ def main(): def execbuffer(buf): try: - if args.no_follow: - pyb.exec_raw_no_follow(buf) - ret_err = None - else: + if args.follow is None or args.follow: ret, ret_err = pyb.exec_raw( buf, timeout=None, data_consumer=stdout_write_bytes ) + else: + pyb.exec_raw_no_follow(buf) + ret_err = None except PyboardError as er: print(er) pyb.close() diff --git a/tools/tinytest-codegen.py b/tools/tinytest-codegen.py index 2000c6a566..5c14bf2d5b 100755 --- a/tools/tinytest-codegen.py +++ b/tools/tinytest-codegen.py @@ -120,6 +120,9 @@ exclude_tests = ( "misc/sys_settrace_loop.py", "misc/sys_settrace_generator.py", "misc/sys_settrace_features.py", + # don't have f-string + "basics/string_fstring.py", + "basics/string_fstring_debug.py", ) output = [] diff --git a/tools/uncrustify.cfg b/tools/uncrustify.cfg index 80542b903e..88127112e8 100644 --- a/tools/uncrustify.cfg +++ b/tools/uncrustify.cfg @@ -1409,11 +1409,11 @@ nl_start_of_file = ignore # ignore/add/remove/force nl_start_of_file_min = 0 # unsigned number # Add or remove newline at the end of the file. -nl_end_of_file = ignore # ignore/add/remove/force +nl_end_of_file = force # ignore/add/remove/force # The minimum number of newlines at the end of the file (only used if # nl_end_of_file is 'add' or 'force'). -nl_end_of_file_min = 0 # unsigned number +nl_end_of_file_min = 1 # unsigned number # Add or remove newline between '=' and '{'. nl_assign_brace = ignore # ignore/add/remove/force