diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f37df27f45..b6feaafdca 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,6 +12,10 @@ on: check_suite: types: [rerequested] +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + jobs: test: runs-on: ubuntu-20.04 diff --git a/.github/workflows/ports_windows.yml b/.github/workflows/ports_windows.yml index 6339746066..cb78632e83 100644 --- a/.github/workflows/ports_windows.yml +++ b/.github/workflows/ports_windows.yml @@ -12,6 +12,10 @@ on: - 'ports/unix/**' - 'ports/windows/**' +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + jobs: build: runs-on: windows-2019 diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 02db3b2c61..52e2d2b714 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -8,6 +8,10 @@ on: pull_request: push: +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + jobs: pre-commit: runs-on: ubuntu-20.04 diff --git a/.gitmodules b/.gitmodules index 34f948480f..8d6723e288 100644 --- a/.gitmodules +++ b/.gitmodules @@ -149,7 +149,7 @@ [submodule "ports/espressif/esp-idf"] path = ports/espressif/esp-idf url = https://github.com/adafruit/esp-idf.git - branch = release/v4.4 + branch = circuitpython-v4.4 [submodule "ports/espressif/certificates/nina-fw"] path = ports/espressif/certificates/nina-fw url = https://github.com/adafruit/nina-fw.git diff --git a/devices/ble_hci/common-hal/_bleio/__init__.h b/devices/ble_hci/common-hal/_bleio/__init__.h index f9caf7c5b5..5c9bbcc979 100644 --- a/devices/ble_hci/common-hal/_bleio/__init__.h +++ b/devices/ble_hci/common-hal/_bleio/__init__.h @@ -35,7 +35,6 @@ #include "hci.h" void bleio_hci_background(void); -void bleio_reset(void); typedef struct { // ble_gap_enc_key_t own_enc; diff --git a/extmod/modubinascii.c b/extmod/modubinascii.c index b11b8bf8a8..7157be31fa 100644 --- a/extmod/modubinascii.c +++ b/extmod/modubinascii.c @@ -1,5 +1,6 @@ // Copyright (c) 2014 Paul Sokolovsky // SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors) +// SPDX-FileCopyrightText: 2022 Beat Ludin for Adafruit Industries // // SPDX-License-Identifier: MIT @@ -204,19 +205,78 @@ STATIC mp_obj_t mod_binascii_b2a_base64(mp_obj_t data) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_binascii_b2a_base64_obj, mod_binascii_b2a_base64); -#if MICROPY_PY_UBINASCII_CRC32 -#include "lib/uzlib/tinf.h" +/* + * CRC32 checksum + * + * Copyright (c) 1998-2003 by Joergen Ibsen / Jibz + * All Rights Reserved + * + * http://www.ibsensoftware.com/ + * + * This software is provided 'as-is', without any express + * or implied warranty. In no event will the authors be + * held liable for any damages arising from the use of + * this software. + * + * Permission is granted to anyone to use this software + * for any purpose, including commercial applications, + * and to alter it and redistribute it freely, subject to + * the following restrictions: + * + * 1. The origin of this software must not be + * misrepresented; you must not claim that you + * wrote the original software. If you use this + * software in a product, an acknowledgment in + * the product documentation would be appreciated + * but is not required. + * + * 2. Altered source versions must be plainly marked + * as such, and must not be misrepresented as + * being the original software. + * + * 3. This notice may not be removed or altered from + * any source distribution. + */ + +/* + * CRC32 algorithm taken from the zlib source, which is + * Copyright (C) 1995-1998 Jean-loup Gailly and Mark Adler + */ + + +static const unsigned int tinf_crc32tab[16] = { + 0x00000000, 0x1db71064, 0x3b6e20c8, 0x26d930ac, 0x76dc4190, + 0x6b6b51f4, 0x4db26158, 0x5005713c, 0xedb88320, 0xf00f9344, + 0xd6d6a3e8, 0xcb61b38c, 0x9b64c2b0, 0x86d3d2d4, 0xa00ae278, + 0xbdbdf21c +}; + +/* crc is previous value for incremental computation, 0xffffffff initially */ +static uint32_t from_uzlib_crc32(const void *data, unsigned int length, uint32_t crc) { + const unsigned char *buf = (const unsigned char *)data; + unsigned int i; + + for (i = 0; i < length; ++i) + { + crc ^= buf[i]; + crc = tinf_crc32tab[crc & 0x0f] ^ (crc >> 4); + crc = tinf_crc32tab[crc & 0x0f] ^ (crc >> 4); + } + + // return value suitable for passing in next time, for final value invert it + return crc /* ^ 0xffffffff*/; +} STATIC mp_obj_t mod_binascii_crc32(size_t n_args, const mp_obj_t *args) { mp_buffer_info_t bufinfo; check_not_unicode(args[0]); mp_get_buffer_raise(args[0], &bufinfo, MP_BUFFER_READ); uint32_t crc = (n_args > 1) ? mp_obj_get_int_truncated(args[1]) : 0; - crc = uzlib_crc32(bufinfo.buf, bufinfo.len, crc ^ 0xffffffff); + crc = from_uzlib_crc32(bufinfo.buf, bufinfo.len, crc ^ 0xffffffff); return mp_obj_new_int_from_uint(crc ^ 0xffffffff); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_binascii_crc32_obj, 1, 2, mod_binascii_crc32); -#endif + STATIC const mp_rom_map_elem_t mp_module_binascii_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_binascii) }, @@ -224,9 +284,7 @@ STATIC const mp_rom_map_elem_t mp_module_binascii_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_unhexlify), MP_ROM_PTR(&mod_binascii_unhexlify_obj) }, { MP_ROM_QSTR(MP_QSTR_a2b_base64), MP_ROM_PTR(&mod_binascii_a2b_base64_obj) }, { MP_ROM_QSTR(MP_QSTR_b2a_base64), MP_ROM_PTR(&mod_binascii_b2a_base64_obj) }, - #if MICROPY_PY_UBINASCII_CRC32 { MP_ROM_QSTR(MP_QSTR_crc32), MP_ROM_PTR(&mod_binascii_crc32_obj) }, - #endif }; STATIC MP_DEFINE_CONST_DICT(mp_module_binascii_globals, mp_module_binascii_globals_table); diff --git a/extmod/vfs_fat_file.c b/extmod/vfs_fat_file.c index 17b142b95a..65ee5f9024 100644 --- a/extmod/vfs_fat_file.c +++ b/extmod/vfs_fat_file.c @@ -139,39 +139,58 @@ STATIC const mp_arg_t file_open_args[] = { STATIC mp_obj_t file_open(fs_user_mount_t *vfs, const mp_obj_type_t *type, mp_arg_val_t *args) { int mode = 0; const char *mode_s = mp_obj_str_get_str(args[1].u_obj); - // TODO make sure only one of r, w, x, a, and b, t are specified + uint32_t rwxa_count = 0; + uint32_t bt_count = 0; + uint32_t plus_count = 0; + bool bad_mode = false; while (*mode_s) { switch (*mode_s++) { case 'r': mode |= FA_READ; + rwxa_count++; break; case 'w': mode |= FA_WRITE | FA_CREATE_ALWAYS; + rwxa_count++; break; case 'x': mode |= FA_WRITE | FA_CREATE_NEW; + rwxa_count++; break; case 'a': mode |= FA_WRITE | FA_OPEN_ALWAYS; + rwxa_count++; break; case '+': mode |= FA_READ | FA_WRITE; + plus_count++; break; #if MICROPY_PY_IO_FILEIO case 'b': + bt_count++; type = &mp_type_vfs_fat_fileio; break; #endif case 't': + bt_count++; type = &mp_type_vfs_fat_textio; break; + default: + bad_mode = true; + break; } } + + if (rwxa_count != 1 || plus_count > 1 || bt_count > 1 || bad_mode) { + mp_raise_ValueError(translate("Invalid mode")); + } + assert(vfs != NULL); if ((mode & FA_WRITE) != 0 && !filesystem_is_writable_by_python(vfs)) { mp_raise_OSError(MP_EROFS); } + pyb_file_obj_t *o = m_new_obj_with_finaliser(pyb_file_obj_t); o->base.type = type; diff --git a/locale/ID.po b/locale/ID.po index 8e9ffa9e40..77f7a39070 100644 --- a/locale/ID.po +++ b/locale/ID.po @@ -107,7 +107,7 @@ msgstr "indeks %q harus bilangan bulat, bukan %s" msgid "%q length must be %d-%d" msgstr "%q panjang harus %d-%d" -#: shared-bindings/usb_hid/Device.c +#: shared-bindings/busio/I2C.c shared-bindings/usb_hid/Device.c msgid "%q length must be >= 1" msgstr "%q panjang harus >= 1" @@ -454,6 +454,7 @@ msgstr "Semua timer untuk pin ini sedang digunakan" msgid "All timers in use" msgstr "Semua timer sedang digunakan" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Already advertising." msgstr "Sudah disebarkan." @@ -640,7 +641,7 @@ msgstr "Panjang buffer harus kelipatan 512" msgid "Buffer must be a multiple of 512 bytes" msgstr "" -#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c +#: shared-bindings/bitbangio/I2C.c msgid "Buffer must be at least length 1" msgstr "Penyangga harus memiliki panjang setidaknya 1" @@ -927,10 +928,12 @@ msgstr "Data 0 pin harus byte disejajarkan" msgid "Data chunk must follow fmt chunk" msgstr "Potongan data harus mengikuti fmt chunk" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data not supported with directed advertising" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data too large for advertisement packet" msgstr "Data terlalu besar untuk paket advertisment" @@ -1011,6 +1014,7 @@ msgstr "" msgid "Expected tuple of length %d, got %d" msgstr "Diharapkan tuple dengan panjang %d, didapatkan %d" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Extended advertisements with scan response not supported." msgstr "Penyebaran yang diperluas dengan respon pindai tidak didukung." @@ -1064,6 +1068,7 @@ msgstr "" msgid "Failed to buffer the sample" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Failed to connect: internal error" msgstr "Gagal terhubung: kesalahan internal" @@ -1297,6 +1302,7 @@ msgstr "Nilai Unit ADC tidak valid" msgid "Invalid AuthMode" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c msgid "Invalid BLE parameter" msgstr "" @@ -1391,6 +1397,10 @@ msgstr "Ukuran potongan format tidak valid" msgid "Invalid memory access." msgstr "Akses memori tidak valid." +#: extmod/vfs_fat_file.c +msgid "Invalid mode" +msgstr "" + #: ports/espressif/common-hal/wifi/Radio.c msgid "Invalid multicast MAC address" msgstr "" @@ -1519,6 +1529,10 @@ msgstr "Pin MISO gagal inisialisasi." msgid "MOSI pin init failed." msgstr "Pin MOSI gagal inisialisasi." +#: shared-bindings/is31fl3741/__init__.c +msgid "Mapping must be a tuple" +msgstr "" + #: shared-module/displayio/Shape.c #, c-format msgid "Maximum x value when mirrored is %d" @@ -1601,6 +1615,10 @@ msgstr "" msgid "Name too long" msgstr "Nama terlalu panjang" +#: ports/espressif/common-hal/_bleio/__init__.c +msgid "Nimble out of memory" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "Tidak ada CCCD untuk Karakteristik ini" @@ -1623,7 +1641,7 @@ msgstr "" #: shared-module/adafruit_bus_device/i2c_device/I2CDevice.c #, c-format -msgid "No I2C device at address: %x" +msgid "No I2C device at address: 0x%x" msgstr "" #: ports/espressif/common-hal/busio/SPI.c @@ -1748,6 +1766,7 @@ msgstr "" msgid "Not a valid IP string" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -2141,6 +2160,7 @@ msgstr "Nilai sampel terlalu tinggi. Nilai harus kurang dari %d" msgid "Scale dimensions must divide by 3" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Scan already in progess. Stop with stop_scan." msgstr "Pindai sudah dalam proses. Hentikan dengan stop_scan." @@ -2299,6 +2319,7 @@ msgstr "Lebar ubin harus persis membagi lebar bitmap" msgid "Time is in the past." msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2321,6 +2342,7 @@ msgstr "Terlalu banyak tampilan bus" msgid "Too many displays" msgstr "Terlalu banyak tampilan" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Total data to write is larger than %q" msgstr "" @@ -2452,11 +2474,21 @@ msgstr "Alasan yang tidak diketahui." msgid "Unknown security error: 0x%04x" msgstr "Kesalahan keamanan tidak dikenal: 0x%04x" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error at %s:%d: %d" +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown system firmware error: %04x" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error: %d" +msgstr "" + #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #, c-format msgid "Unmatched number of items on RHS (expected %d, got %d)." @@ -2496,11 +2528,13 @@ msgstr "Operasi yang tidak didukung" msgid "Update Failed" msgstr "" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length != required fixed length" msgstr "Panjang nilai != Panjang tetap yang dibutuhkan" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length > max_length" @@ -2558,6 +2592,7 @@ msgstr "" msgid "Woken up by alarm.\n" msgstr "" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Writes not supported on Characteristic" msgstr "Menulis tidak didukung pada Karakteristik" @@ -3625,6 +3660,7 @@ msgstr "" msgid "matrix is not positive definite" msgstr "" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c #, c-format @@ -4030,6 +4066,7 @@ msgstr "" msgid "pow() with 3 arguments requires integers" msgstr "" +#: ports/espressif/boards/adafruit_esp32s2_camera/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tft/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h @@ -4037,15 +4074,18 @@ msgstr "" #: ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h +#: ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h #: ports/espressif/boards/atmegazero_esp32s2/mpconfigboard.h #: ports/espressif/boards/crumpspace_crumps2/mpconfigboard.h #: ports/espressif/boards/electroniccats_bastwifi/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_box/mpconfigboard.h -#: ports/espressif/boards/espressif_esp32s3_devkitc_1/mpconfigboard.h -#: ports/espressif/boards/espressif_esp32s3_devkitc_1_nopsram/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h #: ports/espressif/boards/espressif_hmi_devkit_1/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1.3/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1/mpconfigboard.h @@ -4071,7 +4111,10 @@ msgstr "" #: ports/espressif/boards/unexpectedmaker_feathers2/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_neo/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_prerelease/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_feathers3/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_pros3/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_tinys2/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_tinys3/mpconfigboard.h msgid "pressing boot button at start up.\n" msgstr "" diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index 121eac2049..3603079e8e 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -99,7 +99,7 @@ msgstr "" msgid "%q length must be %d-%d" msgstr "" -#: shared-bindings/usb_hid/Device.c +#: shared-bindings/busio/I2C.c shared-bindings/usb_hid/Device.c msgid "%q length must be >= 1" msgstr "" @@ -446,6 +446,7 @@ msgstr "" msgid "All timers in use" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Already advertising." msgstr "" @@ -630,7 +631,7 @@ msgstr "" msgid "Buffer must be a multiple of 512 bytes" msgstr "" -#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c +#: shared-bindings/bitbangio/I2C.c msgid "Buffer must be at least length 1" msgstr "" @@ -908,10 +909,12 @@ msgstr "" msgid "Data chunk must follow fmt chunk" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data not supported with directed advertising" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data too large for advertisement packet" msgstr "" @@ -992,6 +995,7 @@ msgstr "" msgid "Expected tuple of length %d, got %d" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Extended advertisements with scan response not supported." msgstr "" @@ -1045,6 +1049,7 @@ msgstr "" msgid "Failed to buffer the sample" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Failed to connect: internal error" msgstr "" @@ -1276,6 +1281,7 @@ msgstr "" msgid "Invalid AuthMode" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c msgid "Invalid BLE parameter" msgstr "" @@ -1370,6 +1376,10 @@ msgstr "" msgid "Invalid memory access." msgstr "" +#: extmod/vfs_fat_file.c +msgid "Invalid mode" +msgstr "" + #: ports/espressif/common-hal/wifi/Radio.c msgid "Invalid multicast MAC address" msgstr "" @@ -1498,6 +1508,10 @@ msgstr "" msgid "MOSI pin init failed." msgstr "" +#: shared-bindings/is31fl3741/__init__.c +msgid "Mapping must be a tuple" +msgstr "" + #: shared-module/displayio/Shape.c #, c-format msgid "Maximum x value when mirrored is %d" @@ -1580,6 +1594,10 @@ msgstr "" msgid "Name too long" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +msgid "Nimble out of memory" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "" @@ -1602,7 +1620,7 @@ msgstr "" #: shared-module/adafruit_bus_device/i2c_device/I2CDevice.c #, c-format -msgid "No I2C device at address: %x" +msgid "No I2C device at address: 0x%x" msgstr "" #: ports/espressif/common-hal/busio/SPI.c @@ -1727,6 +1745,7 @@ msgstr "" msgid "Not a valid IP string" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -2106,6 +2125,7 @@ msgstr "" msgid "Scale dimensions must divide by 3" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Scan already in progess. Stop with stop_scan." msgstr "" @@ -2264,6 +2284,7 @@ msgstr "" msgid "Time is in the past." msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2286,6 +2307,7 @@ msgstr "" msgid "Too many displays" msgstr "" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Total data to write is larger than %q" msgstr "" @@ -2417,11 +2439,21 @@ msgstr "" msgid "Unknown security error: 0x%04x" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error at %s:%d: %d" +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown system firmware error: %04x" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error: %d" +msgstr "" + #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #, c-format msgid "Unmatched number of items on RHS (expected %d, got %d)." @@ -2459,11 +2491,13 @@ msgstr "" msgid "Update Failed" msgstr "" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length != required fixed length" msgstr "" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length > max_length" @@ -2521,6 +2555,7 @@ msgstr "" msgid "Woken up by alarm.\n" msgstr "" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Writes not supported on Characteristic" msgstr "" @@ -3588,6 +3623,7 @@ msgstr "" msgid "matrix is not positive definite" msgstr "" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c #, c-format @@ -3992,6 +4028,7 @@ msgstr "" msgid "pow() with 3 arguments requires integers" msgstr "" +#: ports/espressif/boards/adafruit_esp32s2_camera/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tft/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h @@ -3999,15 +4036,18 @@ msgstr "" #: ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h +#: ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h #: ports/espressif/boards/atmegazero_esp32s2/mpconfigboard.h #: ports/espressif/boards/crumpspace_crumps2/mpconfigboard.h #: ports/espressif/boards/electroniccats_bastwifi/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_box/mpconfigboard.h -#: ports/espressif/boards/espressif_esp32s3_devkitc_1/mpconfigboard.h -#: ports/espressif/boards/espressif_esp32s3_devkitc_1_nopsram/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h #: ports/espressif/boards/espressif_hmi_devkit_1/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1.3/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1/mpconfigboard.h @@ -4033,7 +4073,10 @@ msgstr "" #: ports/espressif/boards/unexpectedmaker_feathers2/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_neo/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_prerelease/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_feathers3/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_pros3/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_tinys2/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_tinys3/mpconfigboard.h msgid "pressing boot button at start up.\n" msgstr "" diff --git a/locale/cs.po b/locale/cs.po index 25fb7a2dfd..e1ce62f940 100644 --- a/locale/cs.po +++ b/locale/cs.po @@ -106,7 +106,7 @@ msgstr "Indexy %q musí být celá čísla, nikoli %s" msgid "%q length must be %d-%d" msgstr "%q délka musí být %d-%d" -#: shared-bindings/usb_hid/Device.c +#: shared-bindings/busio/I2C.c shared-bindings/usb_hid/Device.c msgid "%q length must be >= 1" msgstr "%q délka musí být >= 1" @@ -453,6 +453,7 @@ msgstr "" msgid "All timers in use" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Already advertising." msgstr "" @@ -639,7 +640,7 @@ msgstr "" msgid "Buffer must be a multiple of 512 bytes" msgstr "" -#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c +#: shared-bindings/bitbangio/I2C.c msgid "Buffer must be at least length 1" msgstr "" @@ -917,10 +918,12 @@ msgstr "" msgid "Data chunk must follow fmt chunk" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data not supported with directed advertising" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data too large for advertisement packet" msgstr "" @@ -1001,6 +1004,7 @@ msgstr "" msgid "Expected tuple of length %d, got %d" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Extended advertisements with scan response not supported." msgstr "" @@ -1054,6 +1058,7 @@ msgstr "" msgid "Failed to buffer the sample" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Failed to connect: internal error" msgstr "" @@ -1285,6 +1290,7 @@ msgstr "" msgid "Invalid AuthMode" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c msgid "Invalid BLE parameter" msgstr "" @@ -1379,6 +1385,10 @@ msgstr "" msgid "Invalid memory access." msgstr "" +#: extmod/vfs_fat_file.c +msgid "Invalid mode" +msgstr "" + #: ports/espressif/common-hal/wifi/Radio.c msgid "Invalid multicast MAC address" msgstr "" @@ -1507,6 +1517,10 @@ msgstr "" msgid "MOSI pin init failed." msgstr "" +#: shared-bindings/is31fl3741/__init__.c +msgid "Mapping must be a tuple" +msgstr "" + #: shared-module/displayio/Shape.c #, c-format msgid "Maximum x value when mirrored is %d" @@ -1589,6 +1603,10 @@ msgstr "" msgid "Name too long" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +msgid "Nimble out of memory" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "" @@ -1611,7 +1629,7 @@ msgstr "" #: shared-module/adafruit_bus_device/i2c_device/I2CDevice.c #, c-format -msgid "No I2C device at address: %x" +msgid "No I2C device at address: 0x%x" msgstr "" #: ports/espressif/common-hal/busio/SPI.c @@ -1736,6 +1754,7 @@ msgstr "" msgid "Not a valid IP string" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -2117,6 +2136,7 @@ msgstr "" msgid "Scale dimensions must divide by 3" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Scan already in progess. Stop with stop_scan." msgstr "" @@ -2275,6 +2295,7 @@ msgstr "" msgid "Time is in the past." msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2297,6 +2318,7 @@ msgstr "" msgid "Too many displays" msgstr "" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Total data to write is larger than %q" msgstr "" @@ -2428,11 +2450,21 @@ msgstr "" msgid "Unknown security error: 0x%04x" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error at %s:%d: %d" +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown system firmware error: %04x" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error: %d" +msgstr "" + #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #, c-format msgid "Unmatched number of items on RHS (expected %d, got %d)." @@ -2470,11 +2502,13 @@ msgstr "" msgid "Update Failed" msgstr "" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length != required fixed length" msgstr "" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length > max_length" @@ -2532,6 +2566,7 @@ msgstr "" msgid "Woken up by alarm.\n" msgstr "" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Writes not supported on Characteristic" msgstr "" @@ -3599,6 +3634,7 @@ msgstr "" msgid "matrix is not positive definite" msgstr "" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c #, c-format @@ -4003,6 +4039,7 @@ msgstr "" msgid "pow() with 3 arguments requires integers" msgstr "" +#: ports/espressif/boards/adafruit_esp32s2_camera/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tft/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h @@ -4010,15 +4047,18 @@ msgstr "" #: ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h +#: ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h #: ports/espressif/boards/atmegazero_esp32s2/mpconfigboard.h #: ports/espressif/boards/crumpspace_crumps2/mpconfigboard.h #: ports/espressif/boards/electroniccats_bastwifi/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_box/mpconfigboard.h -#: ports/espressif/boards/espressif_esp32s3_devkitc_1/mpconfigboard.h -#: ports/espressif/boards/espressif_esp32s3_devkitc_1_nopsram/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h #: ports/espressif/boards/espressif_hmi_devkit_1/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1.3/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1/mpconfigboard.h @@ -4044,7 +4084,10 @@ msgstr "" #: ports/espressif/boards/unexpectedmaker_feathers2/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_neo/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_prerelease/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_feathers3/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_pros3/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_tinys2/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_tinys3/mpconfigboard.h msgid "pressing boot button at start up.\n" msgstr "" diff --git a/locale/de_DE.po b/locale/de_DE.po index b57b2bc6c2..21bf4b7f41 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -107,7 +107,7 @@ msgstr "%q Indizes müssen Integer sein, nicht %s" msgid "%q length must be %d-%d" msgstr "" -#: shared-bindings/usb_hid/Device.c +#: shared-bindings/busio/I2C.c shared-bindings/usb_hid/Device.c msgid "%q length must be >= 1" msgstr "" @@ -455,6 +455,7 @@ msgstr "Alle timer für diesen Pin werden bereits benutzt" msgid "All timers in use" msgstr "Alle timer werden benutzt" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Already advertising." msgstr "Bereits am anbieten (advertising)." @@ -641,7 +642,7 @@ msgstr "Die Pufferlänge muss ein vielfaches von 512 sein" msgid "Buffer must be a multiple of 512 bytes" msgstr "Der Puffer muss ein vielfaches von 512 bytes sein" -#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c +#: shared-bindings/bitbangio/I2C.c msgid "Buffer must be at least length 1" msgstr "Der Puffer muss eine Mindestenslänge von 1 haben" @@ -923,10 +924,12 @@ msgstr "Data 0 pin muss am Byte ausgerichtet sein" msgid "Data chunk must follow fmt chunk" msgstr "Dem fmt Block muss ein Datenblock folgen" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data not supported with directed advertising" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data too large for advertisement packet" msgstr "Zu vielen Daten für das advertisement packet" @@ -1007,6 +1010,7 @@ msgstr "Alarm erwartet" msgid "Expected tuple of length %d, got %d" msgstr "Habe ein Tupel der Länge %d erwartet aber %d erhalten" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Extended advertisements with scan response not supported." msgstr "" @@ -1061,6 +1065,7 @@ msgstr "Zuweisung des Wifi Scan Speichers ist fehlgeschlagen" msgid "Failed to buffer the sample" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Failed to connect: internal error" msgstr "Verbindung fehlgeschlagen: interner Fehler" @@ -1296,6 +1301,7 @@ msgstr "Ungültiger ADC-Einheitenwert" msgid "Invalid AuthMode" msgstr "Ungültiges AuthMode" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c msgid "Invalid BLE parameter" msgstr "Ungültiges BLE Parameter" @@ -1390,6 +1396,10 @@ msgstr "Ungültige format chunk size" msgid "Invalid memory access." msgstr "Ungültiger Speicherzugriff." +#: extmod/vfs_fat_file.c +msgid "Invalid mode" +msgstr "" + #: ports/espressif/common-hal/wifi/Radio.c msgid "Invalid multicast MAC address" msgstr "" @@ -1518,6 +1528,10 @@ msgstr "MISO pin Initialisierung fehlgeschlagen." msgid "MOSI pin init failed." msgstr "MOSI pin Initialisierung fehlgeschlagen." +#: shared-bindings/is31fl3741/__init__.c +msgid "Mapping must be a tuple" +msgstr "" + #: shared-module/displayio/Shape.c #, c-format msgid "Maximum x value when mirrored is %d" @@ -1601,6 +1615,10 @@ msgstr "NVS Fehler" msgid "Name too long" msgstr "Name zu lang" +#: ports/espressif/common-hal/_bleio/__init__.c +msgid "Nimble out of memory" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "Kein CCCD für diese Charakteristik" @@ -1623,7 +1641,7 @@ msgstr "" #: shared-module/adafruit_bus_device/i2c_device/I2CDevice.c #, c-format -msgid "No I2C device at address: %x" +msgid "No I2C device at address: 0x%x" msgstr "" #: ports/espressif/common-hal/busio/SPI.c @@ -1748,6 +1766,7 @@ msgstr "" msgid "Not a valid IP string" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -2138,6 +2157,7 @@ msgstr "Abtastrate zu hoch. Wert muss unter %d liegen" msgid "Scale dimensions must divide by 3" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Scan already in progess. Stop with stop_scan." msgstr "Scannen Sie bereits in Bearbeitung. Stoppen Sie mit stop_scan." @@ -2298,6 +2318,7 @@ msgstr "Die Kachelbreite muss die Bitmap-Breite genau teilen" msgid "Time is in the past." msgstr "Zeit liegt in der Vergangenheit" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2321,6 +2342,7 @@ msgstr "Zu viele Display Busse" msgid "Too many displays" msgstr "Zu viele displays" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Total data to write is larger than %q" msgstr "Gesamte zu schreibende Datenmenge ist größer als %q" @@ -2452,11 +2474,21 @@ msgstr "Unbekannter Grund." msgid "Unknown security error: 0x%04x" msgstr "Unbekannter Sicherheitsfehler: 0x%04x" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error at %s:%d: %d" +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown system firmware error: %04x" msgstr "Unbekannter Systemfirmware Fehler: %04x" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error: %d" +msgstr "" + #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #, c-format msgid "Unmatched number of items on RHS (expected %d, got %d)." @@ -2498,11 +2530,13 @@ msgstr "Nicht unterstützte Operation" msgid "Update Failed" msgstr "Update fehlgeschlagen" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length != required fixed length" msgstr "Wert Länge != Erforderliche feste Länge" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length > max_length" @@ -2563,6 +2597,7 @@ msgstr "WiFi Passwort muss zwischen 8 und 63 Zeichen lang sein" msgid "Woken up by alarm.\n" msgstr "Aufgeweckt durch Alarm.\n" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Writes not supported on Characteristic" msgstr "Schreiben nicht unterstüzt für diese Charakteristik" @@ -3650,6 +3685,7 @@ msgstr "Mathe-Domain-Fehler" msgid "matrix is not positive definite" msgstr "Matrix ist nicht positiv definitiv" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c #, c-format @@ -4058,6 +4094,7 @@ msgstr "pow() drittes Argument darf nicht 0 sein" msgid "pow() with 3 arguments requires integers" msgstr "pow() mit 3 Argumenten erfordert Integer" +#: ports/espressif/boards/adafruit_esp32s2_camera/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tft/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h @@ -4065,15 +4102,18 @@ msgstr "pow() mit 3 Argumenten erfordert Integer" #: ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h +#: ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h #: ports/espressif/boards/atmegazero_esp32s2/mpconfigboard.h #: ports/espressif/boards/crumpspace_crumps2/mpconfigboard.h #: ports/espressif/boards/electroniccats_bastwifi/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_box/mpconfigboard.h -#: ports/espressif/boards/espressif_esp32s3_devkitc_1/mpconfigboard.h -#: ports/espressif/boards/espressif_esp32s3_devkitc_1_nopsram/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h #: ports/espressif/boards/espressif_hmi_devkit_1/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1.3/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1/mpconfigboard.h @@ -4099,7 +4139,10 @@ msgstr "pow() mit 3 Argumenten erfordert Integer" #: ports/espressif/boards/unexpectedmaker_feathers2/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_neo/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_prerelease/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_feathers3/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_pros3/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_tinys2/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_tinys3/mpconfigboard.h msgid "pressing boot button at start up.\n" msgstr "" diff --git a/locale/el.po b/locale/el.po index aec64bb7cf..7ff6ea0789 100644 --- a/locale/el.po +++ b/locale/el.po @@ -99,7 +99,7 @@ msgstr "" msgid "%q length must be %d-%d" msgstr "" -#: shared-bindings/usb_hid/Device.c +#: shared-bindings/busio/I2C.c shared-bindings/usb_hid/Device.c msgid "%q length must be >= 1" msgstr "" @@ -446,6 +446,7 @@ msgstr "" msgid "All timers in use" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Already advertising." msgstr "" @@ -630,7 +631,7 @@ msgstr "" msgid "Buffer must be a multiple of 512 bytes" msgstr "" -#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c +#: shared-bindings/bitbangio/I2C.c msgid "Buffer must be at least length 1" msgstr "" @@ -908,10 +909,12 @@ msgstr "" msgid "Data chunk must follow fmt chunk" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data not supported with directed advertising" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data too large for advertisement packet" msgstr "" @@ -992,6 +995,7 @@ msgstr "" msgid "Expected tuple of length %d, got %d" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Extended advertisements with scan response not supported." msgstr "" @@ -1045,6 +1049,7 @@ msgstr "" msgid "Failed to buffer the sample" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Failed to connect: internal error" msgstr "" @@ -1276,6 +1281,7 @@ msgstr "" msgid "Invalid AuthMode" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c msgid "Invalid BLE parameter" msgstr "" @@ -1370,6 +1376,10 @@ msgstr "" msgid "Invalid memory access." msgstr "" +#: extmod/vfs_fat_file.c +msgid "Invalid mode" +msgstr "" + #: ports/espressif/common-hal/wifi/Radio.c msgid "Invalid multicast MAC address" msgstr "" @@ -1498,6 +1508,10 @@ msgstr "" msgid "MOSI pin init failed." msgstr "" +#: shared-bindings/is31fl3741/__init__.c +msgid "Mapping must be a tuple" +msgstr "" + #: shared-module/displayio/Shape.c #, c-format msgid "Maximum x value when mirrored is %d" @@ -1580,6 +1594,10 @@ msgstr "" msgid "Name too long" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +msgid "Nimble out of memory" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "" @@ -1602,7 +1620,7 @@ msgstr "" #: shared-module/adafruit_bus_device/i2c_device/I2CDevice.c #, c-format -msgid "No I2C device at address: %x" +msgid "No I2C device at address: 0x%x" msgstr "" #: ports/espressif/common-hal/busio/SPI.c @@ -1727,6 +1745,7 @@ msgstr "" msgid "Not a valid IP string" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -2106,6 +2125,7 @@ msgstr "" msgid "Scale dimensions must divide by 3" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Scan already in progess. Stop with stop_scan." msgstr "" @@ -2264,6 +2284,7 @@ msgstr "" msgid "Time is in the past." msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2286,6 +2307,7 @@ msgstr "" msgid "Too many displays" msgstr "" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Total data to write is larger than %q" msgstr "" @@ -2417,11 +2439,21 @@ msgstr "" msgid "Unknown security error: 0x%04x" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error at %s:%d: %d" +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown system firmware error: %04x" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error: %d" +msgstr "" + #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #, c-format msgid "Unmatched number of items on RHS (expected %d, got %d)." @@ -2459,11 +2491,13 @@ msgstr "" msgid "Update Failed" msgstr "" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length != required fixed length" msgstr "" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length > max_length" @@ -2521,6 +2555,7 @@ msgstr "" msgid "Woken up by alarm.\n" msgstr "" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Writes not supported on Characteristic" msgstr "" @@ -3588,6 +3623,7 @@ msgstr "" msgid "matrix is not positive definite" msgstr "" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c #, c-format @@ -3992,6 +4028,7 @@ msgstr "" msgid "pow() with 3 arguments requires integers" msgstr "" +#: ports/espressif/boards/adafruit_esp32s2_camera/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tft/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h @@ -3999,15 +4036,18 @@ msgstr "" #: ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h +#: ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h #: ports/espressif/boards/atmegazero_esp32s2/mpconfigboard.h #: ports/espressif/boards/crumpspace_crumps2/mpconfigboard.h #: ports/espressif/boards/electroniccats_bastwifi/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_box/mpconfigboard.h -#: ports/espressif/boards/espressif_esp32s3_devkitc_1/mpconfigboard.h -#: ports/espressif/boards/espressif_esp32s3_devkitc_1_nopsram/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h #: ports/espressif/boards/espressif_hmi_devkit_1/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1.3/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1/mpconfigboard.h @@ -4033,7 +4073,10 @@ msgstr "" #: ports/espressif/boards/unexpectedmaker_feathers2/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_neo/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_prerelease/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_feathers3/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_pros3/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_tinys2/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_tinys3/mpconfigboard.h msgid "pressing boot button at start up.\n" msgstr "" diff --git a/locale/en_GB.po b/locale/en_GB.po index 5e54a91d83..832ce988cc 100644 --- a/locale/en_GB.po +++ b/locale/en_GB.po @@ -108,7 +108,7 @@ msgstr "%q indices must be integers, not %s" msgid "%q length must be %d-%d" msgstr "%q length must be %d-%d" -#: shared-bindings/usb_hid/Device.c +#: shared-bindings/busio/I2C.c shared-bindings/usb_hid/Device.c msgid "%q length must be >= 1" msgstr "%q length must be >= 1" @@ -455,6 +455,7 @@ msgstr "All timers for this pin are in use" msgid "All timers in use" msgstr "All timers in use" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Already advertising." msgstr "Already advertising." @@ -641,7 +642,7 @@ msgstr "Buffer length must be a multiple of 512" msgid "Buffer must be a multiple of 512 bytes" msgstr "Buffer must be a multiple of 512 bytes" -#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c +#: shared-bindings/bitbangio/I2C.c msgid "Buffer must be at least length 1" msgstr "Buffer must be at least length 1" @@ -921,10 +922,12 @@ msgstr "Data 0 pin must be byte aligned" msgid "Data chunk must follow fmt chunk" msgstr "Data chunk must follow fmt chunk" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data not supported with directed advertising" msgstr "Data not supported with directed advertising" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data too large for advertisement packet" msgstr "Data too large for advertisement packet" @@ -1005,6 +1008,7 @@ msgstr "Expected an alarm" msgid "Expected tuple of length %d, got %d" msgstr "Expected tuple of length %d, got %d" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Extended advertisements with scan response not supported." msgstr "Extended advertisements with scan response not supported." @@ -1058,6 +1062,7 @@ msgstr "Failed to allocate WiFi scan memory" msgid "Failed to buffer the sample" msgstr "Failed to buffer the sample" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Failed to connect: internal error" msgstr "Failed to connect: internal error" @@ -1291,6 +1296,7 @@ msgstr "Invalid ADC unit value" msgid "Invalid AuthMode" msgstr "Invalid AuthMode" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c msgid "Invalid BLE parameter" msgstr "Invalid BLE parameter" @@ -1385,6 +1391,10 @@ msgstr "Invalid format chunk size" msgid "Invalid memory access." msgstr "Invalid memory access." +#: extmod/vfs_fat_file.c +msgid "Invalid mode" +msgstr "" + #: ports/espressif/common-hal/wifi/Radio.c msgid "Invalid multicast MAC address" msgstr "" @@ -1513,6 +1523,10 @@ msgstr "MISO pin init failed." msgid "MOSI pin init failed." msgstr "MOSI pin init failed." +#: shared-bindings/is31fl3741/__init__.c +msgid "Mapping must be a tuple" +msgstr "" + #: shared-module/displayio/Shape.c #, c-format msgid "Maximum x value when mirrored is %d" @@ -1595,6 +1609,10 @@ msgstr "NVS Error" msgid "Name too long" msgstr "Name too long" +#: ports/espressif/common-hal/_bleio/__init__.c +msgid "Nimble out of memory" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "No CCCD for this Characteristic" @@ -1617,8 +1635,8 @@ msgstr "No DMA pacing timer found" #: shared-module/adafruit_bus_device/i2c_device/I2CDevice.c #, c-format -msgid "No I2C device at address: %x" -msgstr "No I2C device at address: %x" +msgid "No I2C device at address: 0x%x" +msgstr "" #: ports/espressif/common-hal/busio/SPI.c #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c @@ -1742,6 +1760,7 @@ msgstr "Nordic system firmware out of memory" msgid "Not a valid IP string" msgstr "Not a valid IP string" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -2130,6 +2149,7 @@ msgstr "Sample rate too high. It must be less than %d" msgid "Scale dimensions must divide by 3" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Scan already in progess. Stop with stop_scan." msgstr "Scan already in progess. Stop with stop_scan." @@ -2295,6 +2315,7 @@ msgstr "Tile width must exactly divide bitmap width" msgid "Time is in the past." msgstr "Time is in the past." +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2317,6 +2338,7 @@ msgstr "Too many display busses" msgid "Too many displays" msgstr "Too many displays" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Total data to write is larger than %q" msgstr "Total data to write is larger than %q" @@ -2448,11 +2470,21 @@ msgstr "Unknown reason." msgid "Unknown security error: 0x%04x" msgstr "Unknown security error: 0x%04x" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error at %s:%d: %d" +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown system firmware error: %04x" msgstr "Unknown system firmware error: %04x" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error: %d" +msgstr "" + #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #, c-format msgid "Unmatched number of items on RHS (expected %d, got %d)." @@ -2492,11 +2524,13 @@ msgstr "Unsupported operation" msgid "Update Failed" msgstr "Update failed" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length != required fixed length" msgstr "Value length != required fixed length" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length > max_length" @@ -2554,6 +2588,7 @@ msgstr "WiFi password must be between 8 and 63 characters" msgid "Woken up by alarm.\n" msgstr "Woken up by alarm.\n" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Writes not supported on Characteristic" msgstr "Writes not supported on Characteristic" @@ -3625,6 +3660,7 @@ msgstr "math domain error" msgid "matrix is not positive definite" msgstr "matrix is not positive definite" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c #, c-format @@ -4029,6 +4065,7 @@ msgstr "pow() 3rd argument cannot be 0" msgid "pow() with 3 arguments requires integers" msgstr "pow() with 3 arguments requires integers" +#: ports/espressif/boards/adafruit_esp32s2_camera/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tft/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h @@ -4036,15 +4073,18 @@ msgstr "pow() with 3 arguments requires integers" #: ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h +#: ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h #: ports/espressif/boards/atmegazero_esp32s2/mpconfigboard.h #: ports/espressif/boards/crumpspace_crumps2/mpconfigboard.h #: ports/espressif/boards/electroniccats_bastwifi/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_box/mpconfigboard.h -#: ports/espressif/boards/espressif_esp32s3_devkitc_1/mpconfigboard.h -#: ports/espressif/boards/espressif_esp32s3_devkitc_1_nopsram/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h #: ports/espressif/boards/espressif_hmi_devkit_1/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1.3/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1/mpconfigboard.h @@ -4070,7 +4110,10 @@ msgstr "pow() with 3 arguments requires integers" #: ports/espressif/boards/unexpectedmaker_feathers2/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_neo/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_prerelease/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_feathers3/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_pros3/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_tinys2/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_tinys3/mpconfigboard.h msgid "pressing boot button at start up.\n" msgstr "pressing boot button at start up.\n" @@ -4626,6 +4669,10 @@ 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 "No I2C device at address: %x" +#~ msgstr "No I2C device at address: %x" + #~ msgid "Unsupported pull value." #~ msgstr "Unsupported pull value." diff --git a/locale/es.po b/locale/es.po index 15b32afa1d..fe988daa8a 100644 --- a/locale/es.po +++ b/locale/es.po @@ -110,7 +110,7 @@ msgstr "%q indices deben ser enteros, no %s" msgid "%q length must be %d-%d" msgstr "" -#: shared-bindings/usb_hid/Device.c +#: shared-bindings/busio/I2C.c shared-bindings/usb_hid/Device.c msgid "%q length must be >= 1" msgstr "" @@ -459,6 +459,7 @@ msgstr "Todos los timers para este pin están siendo utilizados" msgid "All timers in use" msgstr "Todos los timers en uso" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Already advertising." msgstr "Ya se encuentra publicando." @@ -646,7 +647,7 @@ msgstr "El tamaño del búfer debe ser múltiplo de 512" msgid "Buffer must be a multiple of 512 bytes" msgstr "Búfer deber ser un múltiplo de 512 bytes" -#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c +#: shared-bindings/bitbangio/I2C.c msgid "Buffer must be at least length 1" msgstr "Buffer debe ser de longitud 1 como minimo" @@ -930,10 +931,12 @@ msgstr "El pin Data 0 debe estar alineado a bytes" msgid "Data chunk must follow fmt chunk" msgstr "Trozo de datos debe seguir fmt chunk" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data not supported with directed advertising" msgstr "Datos sin capacidad de anuncio dirigido" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data too large for advertisement packet" msgstr "Data es muy grande para el paquete de anuncio" @@ -1015,6 +1018,7 @@ msgstr "Un objecto alarm era esperado" msgid "Expected tuple of length %d, got %d" msgstr "Se esperaba un tuple de %d, se obtuvo %d" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Extended advertisements with scan response not supported." msgstr "No se admiten anuncios extendidos con respuesta de escaneo." @@ -1068,6 +1072,7 @@ msgstr "Fallo al tomar memoria para búsqueda wifi" msgid "Failed to buffer the sample" msgstr "Fallo al hacer el búfer de la muestra" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Failed to connect: internal error" msgstr "Error al conectar: error interno" @@ -1309,6 +1314,7 @@ msgstr "Valor de unidad de ADC no válido" msgid "Invalid AuthMode" msgstr "AuthMode invalido" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c msgid "Invalid BLE parameter" msgstr "Parámetro BLE invalido" @@ -1403,6 +1409,10 @@ msgstr "Formato de fragmento de formato no válido" msgid "Invalid memory access." msgstr "Acceso a memoria no válido." +#: extmod/vfs_fat_file.c +msgid "Invalid mode" +msgstr "" + #: ports/espressif/common-hal/wifi/Radio.c msgid "Invalid multicast MAC address" msgstr "" @@ -1531,6 +1541,10 @@ msgstr "MISO pin init fallido." msgid "MOSI pin init failed." msgstr "MOSI pin init fallido." +#: shared-bindings/is31fl3741/__init__.c +msgid "Mapping must be a tuple" +msgstr "" + #: shared-module/displayio/Shape.c #, c-format msgid "Maximum x value when mirrored is %d" @@ -1617,6 +1631,10 @@ msgstr "Error NVS" msgid "Name too long" msgstr "Nombre muy largo" +#: ports/espressif/common-hal/_bleio/__init__.c +msgid "Nimble out of memory" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "No hay CCCD para esta característica" @@ -1639,8 +1657,8 @@ msgstr "timer por establecedor de paso DMA no encontrado" #: shared-module/adafruit_bus_device/i2c_device/I2CDevice.c #, c-format -msgid "No I2C device at address: %x" -msgstr "No hay dispositivo I2C en la dirección: %x" +msgid "No I2C device at address: 0x%x" +msgstr "" #: ports/espressif/common-hal/busio/SPI.c #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c @@ -1764,6 +1782,7 @@ msgstr "El firmware del sistema Nordic no tiene memoria" msgid "Not a valid IP string" msgstr "No es una cadena de IP válida" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -2158,6 +2177,7 @@ msgstr "Frecuencia de muestreo demasiado alta. Debe ser menor a %d" msgid "Scale dimensions must divide by 3" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Scan already in progess. Stop with stop_scan." msgstr "Escaneo en progreso. Usa stop_scan para detener." @@ -2324,6 +2344,7 @@ msgstr "Ancho del Tile debe dividir exactamente el ancho de mapa de bits" msgid "Time is in the past." msgstr "Tiempo suministrado esta en el pasado." +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2348,6 +2369,7 @@ msgstr "Demasiados buses de pantalla" msgid "Too many displays" msgstr "Muchos displays" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Total data to write is larger than %q" msgstr "La cantidad total de datos es mas grande que %q" @@ -2479,11 +2501,21 @@ msgstr "Razón desconocida." msgid "Unknown security error: 0x%04x" msgstr "Error de seguridad desconocido: 0x%04x" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error at %s:%d: %d" +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown system firmware error: %04x" msgstr "Error desconocido en el firmware sistema: %04x" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error: %d" +msgstr "" + #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #, c-format msgid "Unmatched number of items on RHS (expected %d, got %d)." @@ -2523,11 +2555,13 @@ msgstr "Operación no soportada" msgid "Update Failed" msgstr "La actualización fallo" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length != required fixed length" msgstr "Tamaño del valor != del tamaño fijo requerido" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length > max_length" @@ -2588,6 +2622,7 @@ msgstr "La clave de WiFi debe ser entre 8 y 63 caracteres" msgid "Woken up by alarm.\n" msgstr "Despertado por la alarma.\n" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Writes not supported on Characteristic" msgstr "Escrituras no admitidas en Characteristic" @@ -3667,6 +3702,7 @@ msgstr "error de dominio matemático" msgid "matrix is not positive definite" msgstr "matrix no es definida positiva" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c #, c-format @@ -4075,6 +4111,7 @@ msgstr "el 3er argumento de pow() no puede ser 0" msgid "pow() with 3 arguments requires integers" msgstr "pow() con 3 argumentos requiere enteros" +#: ports/espressif/boards/adafruit_esp32s2_camera/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tft/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h @@ -4082,15 +4119,18 @@ msgstr "pow() con 3 argumentos requiere enteros" #: ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h +#: ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h #: ports/espressif/boards/atmegazero_esp32s2/mpconfigboard.h #: ports/espressif/boards/crumpspace_crumps2/mpconfigboard.h #: ports/espressif/boards/electroniccats_bastwifi/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_box/mpconfigboard.h -#: ports/espressif/boards/espressif_esp32s3_devkitc_1/mpconfigboard.h -#: ports/espressif/boards/espressif_esp32s3_devkitc_1_nopsram/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h #: ports/espressif/boards/espressif_hmi_devkit_1/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1.3/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1/mpconfigboard.h @@ -4116,7 +4156,10 @@ msgstr "pow() con 3 argumentos requiere enteros" #: ports/espressif/boards/unexpectedmaker_feathers2/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_neo/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_prerelease/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_feathers3/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_pros3/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_tinys2/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_tinys3/mpconfigboard.h msgid "pressing boot button at start up.\n" msgstr "presionando botón de arranque al inicio.\n" @@ -4673,6 +4716,10 @@ 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 "No I2C device at address: %x" +#~ msgstr "No hay dispositivo I2C en la dirección: %x" + #~ msgid "Unsupported pull value." #~ msgstr "valor pull no soportado." diff --git a/locale/fil.po b/locale/fil.po index 5d2a737d7f..1b5b337a48 100644 --- a/locale/fil.po +++ b/locale/fil.po @@ -100,7 +100,7 @@ msgstr "%q indeks ay dapat integers, hindi %s" msgid "%q length must be %d-%d" msgstr "" -#: shared-bindings/usb_hid/Device.c +#: shared-bindings/busio/I2C.c shared-bindings/usb_hid/Device.c msgid "%q length must be >= 1" msgstr "" @@ -451,6 +451,7 @@ msgstr "Lahat ng timers para sa pin na ito ay ginagamit" msgid "All timers in use" msgstr "Lahat ng timer ginagamit" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Already advertising." msgstr "" @@ -637,7 +638,7 @@ msgstr "" msgid "Buffer must be a multiple of 512 bytes" msgstr "" -#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c +#: shared-bindings/bitbangio/I2C.c msgid "Buffer must be at least length 1" msgstr "Buffer dapat ay hindi baba sa 1 na haba" @@ -919,10 +920,12 @@ msgstr "graphic ay dapat 2048 bytes ang haba" msgid "Data chunk must follow fmt chunk" msgstr "Dapat sunurin ng Data chunk ang fmt chunk" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data not supported with directed advertising" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c #, fuzzy msgid "Data too large for advertisement packet" @@ -1005,6 +1008,7 @@ msgstr "" msgid "Expected tuple of length %d, got %d" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Extended advertisements with scan response not supported." msgstr "" @@ -1058,6 +1062,7 @@ msgstr "" msgid "Failed to buffer the sample" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Failed to connect: internal error" msgstr "" @@ -1291,6 +1296,7 @@ msgstr "" msgid "Invalid AuthMode" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c msgid "Invalid BLE parameter" msgstr "" @@ -1385,6 +1391,10 @@ msgstr "Mali ang format ng chunk size" msgid "Invalid memory access." msgstr "" +#: extmod/vfs_fat_file.c +msgid "Invalid mode" +msgstr "" + #: ports/espressif/common-hal/wifi/Radio.c msgid "Invalid multicast MAC address" msgstr "" @@ -1513,6 +1523,10 @@ msgstr "Hindi ma-initialize ang MISO pin." msgid "MOSI pin init failed." msgstr "Hindi ma-initialize ang MOSI pin." +#: shared-bindings/is31fl3741/__init__.c +msgid "Mapping must be a tuple" +msgstr "" + #: shared-module/displayio/Shape.c #, c-format msgid "Maximum x value when mirrored is %d" @@ -1595,6 +1609,10 @@ msgstr "" msgid "Name too long" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +msgid "Nimble out of memory" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "" @@ -1617,7 +1635,7 @@ msgstr "" #: shared-module/adafruit_bus_device/i2c_device/I2CDevice.c #, c-format -msgid "No I2C device at address: %x" +msgid "No I2C device at address: 0x%x" msgstr "" #: ports/espressif/common-hal/busio/SPI.c @@ -1742,6 +1760,7 @@ msgstr "" msgid "Not a valid IP string" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c #, fuzzy @@ -2126,6 +2145,7 @@ msgstr "Sample rate ay masyadong mataas. Ito ay dapat hindi hiigit sa %d" msgid "Scale dimensions must divide by 3" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Scan already in progess. Stop with stop_scan." msgstr "" @@ -2284,6 +2304,7 @@ msgstr "" msgid "Time is in the past." msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2306,6 +2327,7 @@ msgstr "" msgid "Too many displays" msgstr "" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Total data to write is larger than %q" msgstr "" @@ -2438,11 +2460,21 @@ msgstr "" msgid "Unknown security error: 0x%04x" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error at %s:%d: %d" +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown system firmware error: %04x" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error: %d" +msgstr "" + #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #, c-format msgid "Unmatched number of items on RHS (expected %d, got %d)." @@ -2481,11 +2513,13 @@ msgstr "Hindi sinusuportahang operasyon" msgid "Update Failed" msgstr "" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length != required fixed length" msgstr "" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length > max_length" @@ -2543,6 +2577,7 @@ msgstr "" msgid "Woken up by alarm.\n" msgstr "" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Writes not supported on Characteristic" msgstr "" @@ -3627,6 +3662,7 @@ msgstr "may pagkakamali sa math domain" msgid "matrix is not positive definite" msgstr "" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c #, c-format @@ -4033,6 +4069,7 @@ msgstr "pow() 3rd argument ay hindi maaring 0" msgid "pow() with 3 arguments requires integers" msgstr "pow() na may 3 argumento kailangan ng integers" +#: ports/espressif/boards/adafruit_esp32s2_camera/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tft/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h @@ -4040,15 +4077,18 @@ msgstr "pow() na may 3 argumento kailangan ng integers" #: ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h +#: ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h #: ports/espressif/boards/atmegazero_esp32s2/mpconfigboard.h #: ports/espressif/boards/crumpspace_crumps2/mpconfigboard.h #: ports/espressif/boards/electroniccats_bastwifi/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_box/mpconfigboard.h -#: ports/espressif/boards/espressif_esp32s3_devkitc_1/mpconfigboard.h -#: ports/espressif/boards/espressif_esp32s3_devkitc_1_nopsram/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h #: ports/espressif/boards/espressif_hmi_devkit_1/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1.3/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1/mpconfigboard.h @@ -4074,7 +4114,10 @@ msgstr "pow() na may 3 argumento kailangan ng integers" #: ports/espressif/boards/unexpectedmaker_feathers2/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_neo/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_prerelease/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_feathers3/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_pros3/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_tinys2/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_tinys3/mpconfigboard.h msgid "pressing boot button at start up.\n" msgstr "" diff --git a/locale/fr.po b/locale/fr.po index dd9b524aed..21fa76e498 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -110,7 +110,7 @@ msgstr "les indices %q doivent être des entiers, pas %s" msgid "%q length must be %d-%d" msgstr "La longueur de %q doit être %d-%d" -#: shared-bindings/usb_hid/Device.c +#: shared-bindings/busio/I2C.c shared-bindings/usb_hid/Device.c msgid "%q length must be >= 1" msgstr "La longueur de %q doit être >= 1" @@ -457,6 +457,7 @@ msgstr "Tous les minuteurs pour cette broche sont utilisés" msgid "All timers in use" msgstr "Tous les minuteurs sont utilisés" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Already advertising." msgstr "S'annonce déjà." @@ -647,7 +648,7 @@ msgstr "La longueur de la mémoire tampon doit être un multiple de 512" msgid "Buffer must be a multiple of 512 bytes" msgstr "La mémoire tampon doit être un multiple de 512" -#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c +#: shared-bindings/bitbangio/I2C.c msgid "Buffer must be at least length 1" msgstr "Le tampon doit être de longueur au moins 1" @@ -936,10 +937,12 @@ msgstr "La broche 'Data 0' doit être aligné sur l'octet" msgid "Data chunk must follow fmt chunk" msgstr "Un bloc de données doit suivre un bloc fmt" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data not supported with directed advertising" msgstr "Les données ne sont pas supportées avec les annonces directes" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data too large for advertisement packet" msgstr "Données trop volumineuses pour un paquet d'avertissement" @@ -1022,6 +1025,7 @@ msgstr "Une alarme était prévue" msgid "Expected tuple of length %d, got %d" msgstr "Tuple de longueur %d attendu, obtenu %d" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Extended advertisements with scan response not supported." msgstr "" @@ -1076,6 +1080,7 @@ msgstr "Impossible d'allouer la mémoire pour le scan wifi" msgid "Failed to buffer the sample" msgstr "Échec du tamponage de l'échantillon" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Failed to connect: internal error" msgstr "Impossible de se connecter : erreur interne" @@ -1322,6 +1327,7 @@ msgstr "Valeur d'unité ADC non valide" msgid "Invalid AuthMode" msgstr "AuthMode invalide" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c msgid "Invalid BLE parameter" msgstr "Paramètre BLE invalide" @@ -1416,6 +1422,10 @@ msgstr "Taille de bloc de formatage invalide" msgid "Invalid memory access." msgstr "Accès à la mémoire invalide." +#: extmod/vfs_fat_file.c +msgid "Invalid mode" +msgstr "" + #: ports/espressif/common-hal/wifi/Radio.c msgid "Invalid multicast MAC address" msgstr "Adresse MAC multicast invalide" @@ -1544,6 +1554,10 @@ msgstr "Échec de l'initialization de la broche MISO." msgid "MOSI pin init failed." msgstr "Échec de l'initialization de la broche MOSI." +#: shared-bindings/is31fl3741/__init__.c +msgid "Mapping must be a tuple" +msgstr "" + #: shared-module/displayio/Shape.c #, c-format msgid "Maximum x value when mirrored is %d" @@ -1628,6 +1642,10 @@ msgstr "Erreur NVS" msgid "Name too long" msgstr "Nom trop long" +#: ports/espressif/common-hal/_bleio/__init__.c +msgid "Nimble out of memory" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "Pas de CCCD pour cette caractéristique" @@ -1650,8 +1668,8 @@ msgstr "Aucun minuteur de rythme DMA trouvé" #: shared-module/adafruit_bus_device/i2c_device/I2CDevice.c #, c-format -msgid "No I2C device at address: %x" -msgstr "Pas de dispositif I2C à l'adresse : %x" +msgid "No I2C device at address: 0x%x" +msgstr "" #: ports/espressif/common-hal/busio/SPI.c #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c @@ -1775,6 +1793,7 @@ msgstr "Logiciel systême Nordic hors de mémoire" msgid "Not a valid IP string" msgstr "Chaîne IP non valide" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -2170,6 +2189,7 @@ msgstr "Taux d'échantillonage trop élevé. Doit être inférieur à %d" msgid "Scale dimensions must divide by 3" msgstr "La dimension d'échelle doit être un multiple de 3" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Scan already in progess. Stop with stop_scan." msgstr "Scan déjà en cours. Arrêtez avec stop_scan." @@ -2339,6 +2359,7 @@ msgstr "La largeur de la tuile doit diviser exactement la largeur de l'image" msgid "Time is in the past." msgstr "L'heure est dans le passé." +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2361,6 +2382,7 @@ msgstr "Trop de bus d'affichage" msgid "Too many displays" msgstr "Trop d'affichages" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Total data to write is larger than %q" msgstr "Quantité de données à écrire est plus que %q" @@ -2495,11 +2517,21 @@ msgstr "Raison inconnue." msgid "Unknown security error: 0x%04x" msgstr "Erreur de sécurité inconnue : 0x%04x" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error at %s:%d: %d" +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown system firmware error: %04x" msgstr "Faute inconnue du logiciel systême : %04x" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error: %d" +msgstr "" + #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #, c-format msgid "Unmatched number of items on RHS (expected %d, got %d)." @@ -2540,11 +2572,13 @@ msgstr "Opération non supportée" msgid "Update Failed" msgstr "Mise-à-jour échouée" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length != required fixed length" msgstr "Longueur de valeur != Longueur fixe requise" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length > max_length" @@ -2611,6 +2645,7 @@ msgstr "Le mot de passe WiFi doit faire entre 8 et 63 caractères" msgid "Woken up by alarm.\n" msgstr "Réveil par alarme.\n" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Writes not supported on Characteristic" msgstr "Écritures non supporté vers les Characteristic" @@ -3697,6 +3732,7 @@ msgstr "erreur de domaine math" msgid "matrix is not positive definite" msgstr "la matrice n'est pas définie positive" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c #, c-format @@ -4106,6 +4142,7 @@ msgstr "le 3e argument de pow() ne peut être 0" msgid "pow() with 3 arguments requires integers" msgstr "pow() avec 3 arguments nécessite des entiers" +#: ports/espressif/boards/adafruit_esp32s2_camera/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tft/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h @@ -4113,15 +4150,18 @@ msgstr "pow() avec 3 arguments nécessite des entiers" #: ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h +#: ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h #: ports/espressif/boards/atmegazero_esp32s2/mpconfigboard.h #: ports/espressif/boards/crumpspace_crumps2/mpconfigboard.h #: ports/espressif/boards/electroniccats_bastwifi/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_box/mpconfigboard.h -#: ports/espressif/boards/espressif_esp32s3_devkitc_1/mpconfigboard.h -#: ports/espressif/boards/espressif_esp32s3_devkitc_1_nopsram/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h #: ports/espressif/boards/espressif_hmi_devkit_1/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1.3/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1/mpconfigboard.h @@ -4147,7 +4187,10 @@ msgstr "pow() avec 3 arguments nécessite des entiers" #: ports/espressif/boards/unexpectedmaker_feathers2/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_neo/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_prerelease/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_feathers3/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_pros3/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_tinys2/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_tinys3/mpconfigboard.h msgid "pressing boot button at start up.\n" msgstr "bouton boot appuyé lors du démarrage.\n" @@ -4704,6 +4747,10 @@ 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 "No I2C device at address: %x" +#~ msgstr "Pas de dispositif I2C à l'adresse : %x" + #~ msgid "Unsupported pull value." #~ msgstr "Valeur de tirage 'pull' non supportée." diff --git a/locale/hi.po b/locale/hi.po index 7b2ad4a3ef..89f83c652d 100644 --- a/locale/hi.po +++ b/locale/hi.po @@ -99,7 +99,7 @@ msgstr "" msgid "%q length must be %d-%d" msgstr "" -#: shared-bindings/usb_hid/Device.c +#: shared-bindings/busio/I2C.c shared-bindings/usb_hid/Device.c msgid "%q length must be >= 1" msgstr "" @@ -446,6 +446,7 @@ msgstr "" msgid "All timers in use" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Already advertising." msgstr "" @@ -630,7 +631,7 @@ msgstr "" msgid "Buffer must be a multiple of 512 bytes" msgstr "" -#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c +#: shared-bindings/bitbangio/I2C.c msgid "Buffer must be at least length 1" msgstr "" @@ -908,10 +909,12 @@ msgstr "" msgid "Data chunk must follow fmt chunk" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data not supported with directed advertising" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data too large for advertisement packet" msgstr "" @@ -992,6 +995,7 @@ msgstr "" msgid "Expected tuple of length %d, got %d" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Extended advertisements with scan response not supported." msgstr "" @@ -1045,6 +1049,7 @@ msgstr "" msgid "Failed to buffer the sample" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Failed to connect: internal error" msgstr "" @@ -1276,6 +1281,7 @@ msgstr "" msgid "Invalid AuthMode" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c msgid "Invalid BLE parameter" msgstr "" @@ -1370,6 +1376,10 @@ msgstr "" msgid "Invalid memory access." msgstr "" +#: extmod/vfs_fat_file.c +msgid "Invalid mode" +msgstr "" + #: ports/espressif/common-hal/wifi/Radio.c msgid "Invalid multicast MAC address" msgstr "" @@ -1498,6 +1508,10 @@ msgstr "" msgid "MOSI pin init failed." msgstr "" +#: shared-bindings/is31fl3741/__init__.c +msgid "Mapping must be a tuple" +msgstr "" + #: shared-module/displayio/Shape.c #, c-format msgid "Maximum x value when mirrored is %d" @@ -1580,6 +1594,10 @@ msgstr "" msgid "Name too long" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +msgid "Nimble out of memory" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "" @@ -1602,7 +1620,7 @@ msgstr "" #: shared-module/adafruit_bus_device/i2c_device/I2CDevice.c #, c-format -msgid "No I2C device at address: %x" +msgid "No I2C device at address: 0x%x" msgstr "" #: ports/espressif/common-hal/busio/SPI.c @@ -1727,6 +1745,7 @@ msgstr "" msgid "Not a valid IP string" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -2106,6 +2125,7 @@ msgstr "" msgid "Scale dimensions must divide by 3" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Scan already in progess. Stop with stop_scan." msgstr "" @@ -2264,6 +2284,7 @@ msgstr "" msgid "Time is in the past." msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2286,6 +2307,7 @@ msgstr "" msgid "Too many displays" msgstr "" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Total data to write is larger than %q" msgstr "" @@ -2417,11 +2439,21 @@ msgstr "" msgid "Unknown security error: 0x%04x" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error at %s:%d: %d" +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown system firmware error: %04x" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error: %d" +msgstr "" + #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #, c-format msgid "Unmatched number of items on RHS (expected %d, got %d)." @@ -2459,11 +2491,13 @@ msgstr "" msgid "Update Failed" msgstr "" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length != required fixed length" msgstr "" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length > max_length" @@ -2521,6 +2555,7 @@ msgstr "" msgid "Woken up by alarm.\n" msgstr "" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Writes not supported on Characteristic" msgstr "" @@ -3588,6 +3623,7 @@ msgstr "" msgid "matrix is not positive definite" msgstr "" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c #, c-format @@ -3992,6 +4028,7 @@ msgstr "" msgid "pow() with 3 arguments requires integers" msgstr "" +#: ports/espressif/boards/adafruit_esp32s2_camera/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tft/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h @@ -3999,15 +4036,18 @@ msgstr "" #: ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h +#: ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h #: ports/espressif/boards/atmegazero_esp32s2/mpconfigboard.h #: ports/espressif/boards/crumpspace_crumps2/mpconfigboard.h #: ports/espressif/boards/electroniccats_bastwifi/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_box/mpconfigboard.h -#: ports/espressif/boards/espressif_esp32s3_devkitc_1/mpconfigboard.h -#: ports/espressif/boards/espressif_esp32s3_devkitc_1_nopsram/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h #: ports/espressif/boards/espressif_hmi_devkit_1/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1.3/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1/mpconfigboard.h @@ -4033,7 +4073,10 @@ msgstr "" #: ports/espressif/boards/unexpectedmaker_feathers2/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_neo/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_prerelease/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_feathers3/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_pros3/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_tinys2/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_tinys3/mpconfigboard.h msgid "pressing boot button at start up.\n" msgstr "" diff --git a/locale/it_IT.po b/locale/it_IT.po index 6c5007f00c..5b2b8c2675 100644 --- a/locale/it_IT.po +++ b/locale/it_IT.po @@ -108,7 +108,7 @@ msgstr "gli indici %q devono essere interi, non %s" msgid "%q length must be %d-%d" msgstr "" -#: shared-bindings/usb_hid/Device.c +#: shared-bindings/busio/I2C.c shared-bindings/usb_hid/Device.c msgid "%q length must be >= 1" msgstr "" @@ -458,6 +458,7 @@ msgstr "Tutti i timer per questo pin sono in uso" msgid "All timers in use" msgstr "Tutti i timer utilizzati" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Already advertising." msgstr "" @@ -645,7 +646,7 @@ msgstr "La lunghezza del buffer deve essere un multiplo di 512" msgid "Buffer must be a multiple of 512 bytes" msgstr "Il buffer deve essere un multiplo di 512 bytes" -#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c +#: shared-bindings/bitbangio/I2C.c msgid "Buffer must be at least length 1" msgstr "Il buffer deve essere lungo almeno 1" @@ -927,10 +928,12 @@ msgstr "graphic deve essere lunga 2048 byte" msgid "Data chunk must follow fmt chunk" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data not supported with directed advertising" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c #, fuzzy msgid "Data too large for advertisement packet" @@ -1012,6 +1015,7 @@ msgstr "" msgid "Expected tuple of length %d, got %d" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Extended advertisements with scan response not supported." msgstr "" @@ -1065,6 +1069,7 @@ msgstr "" msgid "Failed to buffer the sample" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Failed to connect: internal error" msgstr "" @@ -1298,6 +1303,7 @@ msgstr "" msgid "Invalid AuthMode" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c msgid "Invalid BLE parameter" msgstr "" @@ -1394,6 +1400,10 @@ msgstr "" msgid "Invalid memory access." msgstr "" +#: extmod/vfs_fat_file.c +msgid "Invalid mode" +msgstr "" + #: ports/espressif/common-hal/wifi/Radio.c msgid "Invalid multicast MAC address" msgstr "" @@ -1523,6 +1533,10 @@ msgstr "inizializzazione del pin MISO fallita." msgid "MOSI pin init failed." msgstr "inizializzazione del pin MOSI fallita." +#: shared-bindings/is31fl3741/__init__.c +msgid "Mapping must be a tuple" +msgstr "" + #: shared-module/displayio/Shape.c #, c-format msgid "Maximum x value when mirrored is %d" @@ -1606,6 +1620,10 @@ msgstr "" msgid "Name too long" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +msgid "Nimble out of memory" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "" @@ -1628,7 +1646,7 @@ msgstr "" #: shared-module/adafruit_bus_device/i2c_device/I2CDevice.c #, c-format -msgid "No I2C device at address: %x" +msgid "No I2C device at address: 0x%x" msgstr "" #: ports/espressif/common-hal/busio/SPI.c @@ -1753,6 +1771,7 @@ msgstr "" msgid "Not a valid IP string" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c #, fuzzy @@ -2145,6 +2164,7 @@ msgstr "" msgid "Scale dimensions must divide by 3" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Scan already in progess. Stop with stop_scan." msgstr "" @@ -2303,6 +2323,7 @@ msgstr "" msgid "Time is in the past." msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2325,6 +2346,7 @@ msgstr "" msgid "Too many displays" msgstr "Troppi schermi" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Total data to write is larger than %q" msgstr "" @@ -2457,11 +2479,21 @@ msgstr "" msgid "Unknown security error: 0x%04x" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error at %s:%d: %d" +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown system firmware error: %04x" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error: %d" +msgstr "" + #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #, c-format msgid "Unmatched number of items on RHS (expected %d, got %d)." @@ -2500,11 +2532,13 @@ msgstr "Operazione non supportata" msgid "Update Failed" msgstr "" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length != required fixed length" msgstr "" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length > max_length" @@ -2562,6 +2596,7 @@ msgstr "" msgid "Woken up by alarm.\n" msgstr "" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Writes not supported on Characteristic" msgstr "" @@ -3645,6 +3680,7 @@ msgstr "errore di dominio matematico" msgid "matrix is not positive definite" msgstr "" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c #, c-format @@ -4055,6 +4091,7 @@ msgstr "il terzo argomento di pow() non può essere 0" msgid "pow() with 3 arguments requires integers" msgstr "pow() con 3 argomenti richiede interi" +#: ports/espressif/boards/adafruit_esp32s2_camera/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tft/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h @@ -4062,15 +4099,18 @@ msgstr "pow() con 3 argomenti richiede interi" #: ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h +#: ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h #: ports/espressif/boards/atmegazero_esp32s2/mpconfigboard.h #: ports/espressif/boards/crumpspace_crumps2/mpconfigboard.h #: ports/espressif/boards/electroniccats_bastwifi/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_box/mpconfigboard.h -#: ports/espressif/boards/espressif_esp32s3_devkitc_1/mpconfigboard.h -#: ports/espressif/boards/espressif_esp32s3_devkitc_1_nopsram/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h #: ports/espressif/boards/espressif_hmi_devkit_1/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1.3/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1/mpconfigboard.h @@ -4096,7 +4136,10 @@ msgstr "pow() con 3 argomenti richiede interi" #: ports/espressif/boards/unexpectedmaker_feathers2/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_neo/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_prerelease/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_feathers3/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_pros3/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_tinys2/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_tinys3/mpconfigboard.h msgid "pressing boot button at start up.\n" msgstr "" diff --git a/locale/ja.po b/locale/ja.po index 56e524a99d..586429649e 100644 --- a/locale/ja.po +++ b/locale/ja.po @@ -104,7 +104,7 @@ msgstr "" msgid "%q length must be %d-%d" msgstr "" -#: shared-bindings/usb_hid/Device.c +#: shared-bindings/busio/I2C.c shared-bindings/usb_hid/Device.c msgid "%q length must be >= 1" msgstr "" @@ -451,6 +451,7 @@ msgstr "このピン用の全てのタイマが使用中" msgid "All timers in use" msgstr "全てのタイマーが使用中" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Already advertising." msgstr "すでにアドバータイズ中" @@ -637,7 +638,7 @@ msgstr "バッファ長は512の倍数でなければなりません" msgid "Buffer must be a multiple of 512 bytes" msgstr "バッファは512の倍数でなければなりません" -#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c +#: shared-bindings/bitbangio/I2C.c msgid "Buffer must be at least length 1" msgstr "バッファ長は少なくとも1以上でなければなりません" @@ -917,10 +918,12 @@ msgstr "Data 0 ピンは、バイト整列されていなければなりませ msgid "Data chunk must follow fmt chunk" msgstr "fmtチャンクの後にdataチャンクが続かなければなりません" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data not supported with directed advertising" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data too large for advertisement packet" msgstr "データが、アドバタイズメントパケットには大きすぎます" @@ -1001,6 +1004,7 @@ msgstr "" msgid "Expected tuple of length %d, got %d" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Extended advertisements with scan response not supported." msgstr "" @@ -1054,6 +1058,7 @@ msgstr "" msgid "Failed to buffer the sample" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Failed to connect: internal error" msgstr "接続失敗: 内部エラー" @@ -1287,6 +1292,7 @@ msgstr "不正なADCユニット値" msgid "Invalid AuthMode" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c msgid "Invalid BLE parameter" msgstr "" @@ -1381,6 +1387,10 @@ msgstr "フォーマットチャンクのサイズが不正" msgid "Invalid memory access." msgstr "不正なメモリアクセス" +#: extmod/vfs_fat_file.c +msgid "Invalid mode" +msgstr "" + #: ports/espressif/common-hal/wifi/Radio.c msgid "Invalid multicast MAC address" msgstr "" @@ -1509,6 +1519,10 @@ msgstr "MISOピン初期化に失敗" msgid "MOSI pin init failed." msgstr "MOSIピン初期化に失敗" +#: shared-bindings/is31fl3741/__init__.c +msgid "Mapping must be a tuple" +msgstr "" + #: shared-module/displayio/Shape.c #, c-format msgid "Maximum x value when mirrored is %d" @@ -1591,6 +1605,10 @@ msgstr "" msgid "Name too long" msgstr "名前が長すぎます" +#: ports/espressif/common-hal/_bleio/__init__.c +msgid "Nimble out of memory" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "" @@ -1613,7 +1631,7 @@ msgstr "" #: shared-module/adafruit_bus_device/i2c_device/I2CDevice.c #, c-format -msgid "No I2C device at address: %x" +msgid "No I2C device at address: 0x%x" msgstr "" #: ports/espressif/common-hal/busio/SPI.c @@ -1738,6 +1756,7 @@ msgstr "" msgid "Not a valid IP string" msgstr "不正なIP文字列です" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -2120,6 +2139,7 @@ msgstr "サンプルレートは%d以下でなければなりません" msgid "Scale dimensions must divide by 3" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Scan already in progess. Stop with stop_scan." msgstr "既にスキャン進行中。stop_scanで停止してください" @@ -2278,6 +2298,7 @@ msgstr "タイルの幅はビットマップの幅を割り切れる値でなけ msgid "Time is in the past." msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2300,6 +2321,7 @@ msgstr "" msgid "Too many displays" msgstr "" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Total data to write is larger than %q" msgstr "" @@ -2432,11 +2454,21 @@ msgstr "理由不明" msgid "Unknown security error: 0x%04x" msgstr "不明なセキュリティエラー: 0x%04x" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error at %s:%d: %d" +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown system firmware error: %04x" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error: %d" +msgstr "" + #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #, c-format msgid "Unmatched number of items on RHS (expected %d, got %d)." @@ -2474,11 +2506,13 @@ msgstr "非対応の操作" msgid "Update Failed" msgstr "" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length != required fixed length" msgstr "" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length > max_length" @@ -2536,6 +2570,7 @@ msgstr "WiFiパスワードは8〜63文字でなければなりません" msgid "Woken up by alarm.\n" msgstr "" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Writes not supported on Characteristic" msgstr "" @@ -3608,6 +3643,7 @@ msgstr "定義域エラー" msgid "matrix is not positive definite" msgstr "正定値行列ではありません" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c #, c-format @@ -4014,6 +4050,7 @@ msgstr "pow()の3つ目の引数は0にできません" msgid "pow() with 3 arguments requires integers" msgstr "pow()の第3引数には整数が必要" +#: ports/espressif/boards/adafruit_esp32s2_camera/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tft/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h @@ -4021,15 +4058,18 @@ msgstr "pow()の第3引数には整数が必要" #: ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h +#: ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h #: ports/espressif/boards/atmegazero_esp32s2/mpconfigboard.h #: ports/espressif/boards/crumpspace_crumps2/mpconfigboard.h #: ports/espressif/boards/electroniccats_bastwifi/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_box/mpconfigboard.h -#: ports/espressif/boards/espressif_esp32s3_devkitc_1/mpconfigboard.h -#: ports/espressif/boards/espressif_esp32s3_devkitc_1_nopsram/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h #: ports/espressif/boards/espressif_hmi_devkit_1/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1.3/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1/mpconfigboard.h @@ -4055,7 +4095,10 @@ msgstr "pow()の第3引数には整数が必要" #: ports/espressif/boards/unexpectedmaker_feathers2/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_neo/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_prerelease/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_feathers3/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_pros3/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_tinys2/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_tinys3/mpconfigboard.h msgid "pressing boot button at start up.\n" msgstr "" diff --git a/locale/ko.po b/locale/ko.po index fc35104af5..fd0e94e82c 100644 --- a/locale/ko.po +++ b/locale/ko.po @@ -100,7 +100,7 @@ msgstr "%q 인덱스는 %s 가 아닌 정수 여야합니다" msgid "%q length must be %d-%d" msgstr "" -#: shared-bindings/usb_hid/Device.c +#: shared-bindings/busio/I2C.c shared-bindings/usb_hid/Device.c msgid "%q length must be >= 1" msgstr "" @@ -447,6 +447,7 @@ msgstr "핀의 모든 타이머가 사용 중입니다" msgid "All timers in use" msgstr "모든 타이머가 사용 중입니다" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Already advertising." msgstr "" @@ -633,7 +634,7 @@ msgstr "" msgid "Buffer must be a multiple of 512 bytes" msgstr "" -#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c +#: shared-bindings/bitbangio/I2C.c msgid "Buffer must be at least length 1" msgstr "잘못된 크기의 버퍼. >1 여야합니다" @@ -911,10 +912,12 @@ msgstr "" msgid "Data chunk must follow fmt chunk" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data not supported with directed advertising" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data too large for advertisement packet" msgstr "광고 (브로드 캐스트) 패킷에 대한 데이터가 너무 큽니다" @@ -995,6 +998,7 @@ msgstr "" msgid "Expected tuple of length %d, got %d" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Extended advertisements with scan response not supported." msgstr "" @@ -1048,6 +1052,7 @@ msgstr "" msgid "Failed to buffer the sample" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Failed to connect: internal error" msgstr "" @@ -1279,6 +1284,7 @@ msgstr "" msgid "Invalid AuthMode" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c msgid "Invalid BLE parameter" msgstr "" @@ -1373,6 +1379,10 @@ msgstr "형식 청크 크기가 잘못되었습니다" msgid "Invalid memory access." msgstr "" +#: extmod/vfs_fat_file.c +msgid "Invalid mode" +msgstr "" + #: ports/espressif/common-hal/wifi/Radio.c msgid "Invalid multicast MAC address" msgstr "" @@ -1501,6 +1511,10 @@ msgstr "" msgid "MOSI pin init failed." msgstr "" +#: shared-bindings/is31fl3741/__init__.c +msgid "Mapping must be a tuple" +msgstr "" + #: shared-module/displayio/Shape.c #, c-format msgid "Maximum x value when mirrored is %d" @@ -1583,6 +1597,10 @@ msgstr "" msgid "Name too long" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +msgid "Nimble out of memory" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "" @@ -1605,7 +1623,7 @@ msgstr "" #: shared-module/adafruit_bus_device/i2c_device/I2CDevice.c #, c-format -msgid "No I2C device at address: %x" +msgid "No I2C device at address: 0x%x" msgstr "" #: ports/espressif/common-hal/busio/SPI.c @@ -1730,6 +1748,7 @@ msgstr "" msgid "Not a valid IP string" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -2109,6 +2128,7 @@ msgstr "" msgid "Scale dimensions must divide by 3" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Scan already in progess. Stop with stop_scan." msgstr "" @@ -2267,6 +2287,7 @@ msgstr "" msgid "Time is in the past." msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2289,6 +2310,7 @@ msgstr "" msgid "Too many displays" msgstr "" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Total data to write is larger than %q" msgstr "" @@ -2421,11 +2443,21 @@ msgstr "" msgid "Unknown security error: 0x%04x" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error at %s:%d: %d" +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown system firmware error: %04x" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error: %d" +msgstr "" + #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #, c-format msgid "Unmatched number of items on RHS (expected %d, got %d)." @@ -2463,11 +2495,13 @@ msgstr "" msgid "Update Failed" msgstr "" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length != required fixed length" msgstr "" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length > max_length" @@ -2525,6 +2559,7 @@ msgstr "" msgid "Woken up by alarm.\n" msgstr "" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Writes not supported on Characteristic" msgstr "" @@ -3592,6 +3627,7 @@ msgstr "" msgid "matrix is not positive definite" msgstr "" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c #, c-format @@ -3996,6 +4032,7 @@ msgstr "" msgid "pow() with 3 arguments requires integers" msgstr "" +#: ports/espressif/boards/adafruit_esp32s2_camera/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tft/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h @@ -4003,15 +4040,18 @@ msgstr "" #: ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h +#: ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h #: ports/espressif/boards/atmegazero_esp32s2/mpconfigboard.h #: ports/espressif/boards/crumpspace_crumps2/mpconfigboard.h #: ports/espressif/boards/electroniccats_bastwifi/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_box/mpconfigboard.h -#: ports/espressif/boards/espressif_esp32s3_devkitc_1/mpconfigboard.h -#: ports/espressif/boards/espressif_esp32s3_devkitc_1_nopsram/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h #: ports/espressif/boards/espressif_hmi_devkit_1/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1.3/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1/mpconfigboard.h @@ -4037,7 +4077,10 @@ msgstr "" #: ports/espressif/boards/unexpectedmaker_feathers2/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_neo/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_prerelease/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_feathers3/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_pros3/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_tinys2/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_tinys3/mpconfigboard.h msgid "pressing boot button at start up.\n" msgstr "" diff --git a/locale/nl.po b/locale/nl.po index e83c1e2618..43329340f1 100644 --- a/locale/nl.po +++ b/locale/nl.po @@ -102,7 +102,7 @@ msgstr "%q indexen moeten integers zijn, niet %s" msgid "%q length must be %d-%d" msgstr "" -#: shared-bindings/usb_hid/Device.c +#: shared-bindings/busio/I2C.c shared-bindings/usb_hid/Device.c msgid "%q length must be >= 1" msgstr "" @@ -449,6 +449,7 @@ msgstr "Alle timers voor deze pin zijn in gebruik" msgid "All timers in use" msgstr "Alle timers zijn in gebruik" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Already advertising." msgstr "Advertising is al bezig." @@ -635,7 +636,7 @@ msgstr "Buffer lengte moet een veelvoud van 512 zijn" msgid "Buffer must be a multiple of 512 bytes" msgstr "Buffer moet een veelvoud van 512 bytes zijn" -#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c +#: shared-bindings/bitbangio/I2C.c msgid "Buffer must be at least length 1" msgstr "Buffer moet op zijn minst lengte 1 zijn" @@ -917,10 +918,12 @@ msgstr "Data 0 pin moet byte uitgelijnd zijn" msgid "Data chunk must follow fmt chunk" msgstr "Data chunk moet gevolgd worden door fmt chunk" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data not supported with directed advertising" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data too large for advertisement packet" msgstr "Data te groot voor advertisement pakket" @@ -1001,6 +1004,7 @@ msgstr "Verwachtte een alarm" msgid "Expected tuple of length %d, got %d" msgstr "Verwachtte een tuple met lengte %d, maar kreeg %d" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Extended advertisements with scan response not supported." msgstr "Extended advertisements met scan antwoord niet ondersteund." @@ -1054,6 +1058,7 @@ msgstr "Kon WiFi scan geheugen niet toewijzen" msgid "Failed to buffer the sample" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Failed to connect: internal error" msgstr "Verbinding mislukt: interne fout" @@ -1288,6 +1293,7 @@ msgstr "Ongeldige ADC Unit waarde" msgid "Invalid AuthMode" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c msgid "Invalid BLE parameter" msgstr "" @@ -1382,6 +1388,10 @@ msgstr "Ongeldig formaat stuk grootte" msgid "Invalid memory access." msgstr "Ongeldig geheugen adres." +#: extmod/vfs_fat_file.c +msgid "Invalid mode" +msgstr "" + #: ports/espressif/common-hal/wifi/Radio.c msgid "Invalid multicast MAC address" msgstr "" @@ -1510,6 +1520,10 @@ msgstr "MISO pin init mislukt." msgid "MOSI pin init failed." msgstr "MOSI pin init mislukt." +#: shared-bindings/is31fl3741/__init__.c +msgid "Mapping must be a tuple" +msgstr "" + #: shared-module/displayio/Shape.c #, c-format msgid "Maximum x value when mirrored is %d" @@ -1592,6 +1606,10 @@ msgstr "NVS-fout" msgid "Name too long" msgstr "Naam te lang" +#: ports/espressif/common-hal/_bleio/__init__.c +msgid "Nimble out of memory" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "Geen CCCD voor deze Characteristic" @@ -1614,8 +1632,8 @@ msgstr "" #: shared-module/adafruit_bus_device/i2c_device/I2CDevice.c #, c-format -msgid "No I2C device at address: %x" -msgstr "Geen I2C-apparaat op adres: %x" +msgid "No I2C device at address: 0x%x" +msgstr "" #: ports/espressif/common-hal/busio/SPI.c #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c @@ -1739,6 +1757,7 @@ msgstr "" msgid "Not a valid IP string" msgstr "Geen geldige IP string" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -2132,6 +2151,7 @@ msgstr "Sample rate is te hoog. Moet minder dan %d zijn" msgid "Scale dimensions must divide by 3" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Scan already in progess. Stop with stop_scan." msgstr "Scan wordt al uitvoerd. Stop met stop_scan." @@ -2290,6 +2310,7 @@ msgstr "Tile breedte moet exact de bitmap breedte verdelen" msgid "Time is in the past." msgstr "Tijdstip ligt in het verleden." +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2312,6 +2333,7 @@ msgstr "Teveel beeldscherm bussen" msgid "Too many displays" msgstr "Teveel beeldschermen" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Total data to write is larger than %q" msgstr "" @@ -2443,11 +2465,21 @@ msgstr "Onbekende reden." msgid "Unknown security error: 0x%04x" msgstr "Onbekende veiligheidsfout: 0x%04x" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error at %s:%d: %d" +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown system firmware error: %04x" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error: %d" +msgstr "" + #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #, c-format msgid "Unmatched number of items on RHS (expected %d, got %d)." @@ -2487,11 +2519,13 @@ msgstr "Niet-ondersteunde operatie" msgid "Update Failed" msgstr "Update Mislukt" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length != required fixed length" msgstr "Waarde lengte != vereist vaste lengte" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length > max_length" @@ -2553,6 +2587,7 @@ msgstr "WiFi wachtwoord moet tussen 8 en 63 karakters bevatten" msgid "Woken up by alarm.\n" msgstr "Gewekt door alarm.\n" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Writes not supported on Characteristic" msgstr "Schrijven niet ondersteund op Characteristic" @@ -3628,6 +3663,7 @@ msgstr "fout in het wiskundig domein (math domain error)" msgid "matrix is not positive definite" msgstr "matrix is niet positief-definiet" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c #, c-format @@ -4033,6 +4069,7 @@ msgstr "derde argument van pow() mag geen 0 zijn" msgid "pow() with 3 arguments requires integers" msgstr "pow() met 3 argumenten vereist integers" +#: ports/espressif/boards/adafruit_esp32s2_camera/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tft/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h @@ -4040,15 +4077,18 @@ msgstr "pow() met 3 argumenten vereist integers" #: ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h +#: ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h #: ports/espressif/boards/atmegazero_esp32s2/mpconfigboard.h #: ports/espressif/boards/crumpspace_crumps2/mpconfigboard.h #: ports/espressif/boards/electroniccats_bastwifi/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_box/mpconfigboard.h -#: ports/espressif/boards/espressif_esp32s3_devkitc_1/mpconfigboard.h -#: ports/espressif/boards/espressif_esp32s3_devkitc_1_nopsram/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h #: ports/espressif/boards/espressif_hmi_devkit_1/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1.3/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1/mpconfigboard.h @@ -4074,7 +4114,10 @@ msgstr "pow() met 3 argumenten vereist integers" #: ports/espressif/boards/unexpectedmaker_feathers2/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_neo/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_prerelease/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_feathers3/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_pros3/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_tinys2/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_tinys3/mpconfigboard.h msgid "pressing boot button at start up.\n" msgstr "druk bootknop in bij opstarten.\n" @@ -4630,6 +4673,10 @@ 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 "No I2C device at address: %x" +#~ msgstr "Geen I2C-apparaat op adres: %x" + #~ msgid "Unsupported pull value." #~ msgstr "Niet-ondersteunde pull-waarde." diff --git a/locale/pl.po b/locale/pl.po index a9f4460ba8..c74e9d7fc2 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -104,7 +104,7 @@ msgstr "%q indeks musi być liczbą całkowitą, a nie %s" msgid "%q length must be %d-%d" msgstr "" -#: shared-bindings/usb_hid/Device.c +#: shared-bindings/busio/I2C.c shared-bindings/usb_hid/Device.c msgid "%q length must be >= 1" msgstr "" @@ -451,6 +451,7 @@ msgstr "Wszystkie timery tej nóżki w użyciu" msgid "All timers in use" msgstr "Wszystkie timery w użyciu" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Already advertising." msgstr "" @@ -637,7 +638,7 @@ msgstr "Długość bufora musi być wielokrotnością 512" msgid "Buffer must be a multiple of 512 bytes" msgstr "Bufor musi być wielokrotnością 512 bajtów" -#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c +#: shared-bindings/bitbangio/I2C.c msgid "Buffer must be at least length 1" msgstr "Bufor musi mieć długość 1 lub więcej" @@ -917,10 +918,12 @@ msgstr "Nóżka data 0 musi być wyrównana do bajtu" msgid "Data chunk must follow fmt chunk" msgstr "Fragment danych musi następować po fragmencie fmt" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data not supported with directed advertising" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data too large for advertisement packet" msgstr "Zbyt dużo danych pakietu rozgłoszeniowego" @@ -1001,6 +1004,7 @@ msgstr "" msgid "Expected tuple of length %d, got %d" msgstr "Oczekiwano krotkę długości %d, otrzymano %d" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Extended advertisements with scan response not supported." msgstr "" @@ -1054,6 +1058,7 @@ msgstr "" msgid "Failed to buffer the sample" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Failed to connect: internal error" msgstr "Nie udało się połączyć: błąd wewnętrzny" @@ -1287,6 +1292,7 @@ msgstr "" msgid "Invalid AuthMode" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c msgid "Invalid BLE parameter" msgstr "" @@ -1381,6 +1387,10 @@ msgstr "Zła wielkość fragmentu formatu" msgid "Invalid memory access." msgstr "Nieprawidłowy dostęp do pamięci." +#: extmod/vfs_fat_file.c +msgid "Invalid mode" +msgstr "" + #: ports/espressif/common-hal/wifi/Radio.c msgid "Invalid multicast MAC address" msgstr "" @@ -1509,6 +1519,10 @@ msgstr "Nie powiodło się ustawienie pinu MISO." msgid "MOSI pin init failed." msgstr "Nie powiodło się ustawienie pinu MOSI." +#: shared-bindings/is31fl3741/__init__.c +msgid "Mapping must be a tuple" +msgstr "" + #: shared-module/displayio/Shape.c #, c-format msgid "Maximum x value when mirrored is %d" @@ -1591,6 +1605,10 @@ msgstr "" msgid "Name too long" msgstr "Za długa nazwa" +#: ports/espressif/common-hal/_bleio/__init__.c +msgid "Nimble out of memory" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "" @@ -1613,7 +1631,7 @@ msgstr "" #: shared-module/adafruit_bus_device/i2c_device/I2CDevice.c #, c-format -msgid "No I2C device at address: %x" +msgid "No I2C device at address: 0x%x" msgstr "" #: ports/espressif/common-hal/busio/SPI.c @@ -1738,6 +1756,7 @@ msgstr "" msgid "Not a valid IP string" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -2117,6 +2136,7 @@ msgstr "Zbyt wysoka częstotliwość próbkowania. Musi być mniejsza niż %d" msgid "Scale dimensions must divide by 3" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Scan already in progess. Stop with stop_scan." msgstr "Skanuj już w toku. Zatrzymaj za pomocą stop_scan." @@ -2275,6 +2295,7 @@ msgstr "Szerokość bitmapy musi być wielokrotnością szerokości kafelka" msgid "Time is in the past." msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2297,6 +2318,7 @@ msgstr "Zbyt wiele magistrali" msgid "Too many displays" msgstr "Zbyt wiele wyświetlaczy" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Total data to write is larger than %q" msgstr "" @@ -2428,11 +2450,21 @@ msgstr "" msgid "Unknown security error: 0x%04x" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error at %s:%d: %d" +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown system firmware error: %04x" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error: %d" +msgstr "" + #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #, c-format msgid "Unmatched number of items on RHS (expected %d, got %d)." @@ -2470,11 +2502,13 @@ msgstr "Zła operacja" msgid "Update Failed" msgstr "" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length != required fixed length" msgstr "" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length > max_length" @@ -2532,6 +2566,7 @@ msgstr "" msgid "Woken up by alarm.\n" msgstr "" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Writes not supported on Characteristic" msgstr "" @@ -3600,6 +3635,7 @@ msgstr "błąd domeny" msgid "matrix is not positive definite" msgstr "" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c #, c-format @@ -4005,6 +4041,7 @@ msgstr "trzeci argument pow() nie może być 0" msgid "pow() with 3 arguments requires integers" msgstr "trzyargumentowe pow() wymaga liczb całkowitych" +#: ports/espressif/boards/adafruit_esp32s2_camera/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tft/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h @@ -4012,15 +4049,18 @@ msgstr "trzyargumentowe pow() wymaga liczb całkowitych" #: ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h +#: ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h #: ports/espressif/boards/atmegazero_esp32s2/mpconfigboard.h #: ports/espressif/boards/crumpspace_crumps2/mpconfigboard.h #: ports/espressif/boards/electroniccats_bastwifi/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_box/mpconfigboard.h -#: ports/espressif/boards/espressif_esp32s3_devkitc_1/mpconfigboard.h -#: ports/espressif/boards/espressif_esp32s3_devkitc_1_nopsram/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h #: ports/espressif/boards/espressif_hmi_devkit_1/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1.3/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1/mpconfigboard.h @@ -4046,7 +4086,10 @@ msgstr "trzyargumentowe pow() wymaga liczb całkowitych" #: ports/espressif/boards/unexpectedmaker_feathers2/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_neo/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_prerelease/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_feathers3/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_pros3/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_tinys2/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_tinys3/mpconfigboard.h msgid "pressing boot button at start up.\n" msgstr "" diff --git a/locale/pt_BR.po b/locale/pt_BR.po index 317b409726..1ae47a86a3 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: 2022-01-03 05:53+0000\n" +"PO-Revision-Date: 2022-01-31 05:55+0000\n" "Last-Translator: Wellington Terumi Uemura \n" "Language-Team: \n" "Language: pt_BR\n" @@ -14,7 +14,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=n > 1;\n" -"X-Generator: Weblate 4.10.1\n" +"X-Generator: Weblate 4.11-dev\n" #: main.c msgid "" @@ -108,7 +108,7 @@ msgstr "Os índices %q devem ser inteiros, e não %s" msgid "%q length must be %d-%d" msgstr "o comprimento %q deve ser %d-%d" -#: shared-bindings/usb_hid/Device.c +#: shared-bindings/busio/I2C.c shared-bindings/usb_hid/Device.c msgid "%q length must be >= 1" msgstr "o comprimento %q deve ser >=1" @@ -459,6 +459,7 @@ msgstr "Todos os temporizadores para este pino estão em uso" msgid "All timers in use" msgstr "Todos os temporizadores em uso" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Already advertising." msgstr "Já está anunciando." @@ -650,7 +651,7 @@ msgstr "O comprimento do Buffer deve ser um múltiplo de 512" msgid "Buffer must be a multiple of 512 bytes" msgstr "O buffer deve ser um múltiplo de 512 bytes" -#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c +#: shared-bindings/bitbangio/I2C.c msgid "Buffer must be at least length 1" msgstr "O comprimento do buffer deve ter pelo menos 1" @@ -935,10 +936,12 @@ msgstr "O pino de dados 0 deve ser alinhado por bytes" msgid "Data chunk must follow fmt chunk" msgstr "Pedaço de dados deve seguir o pedaço de cortes" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data not supported with directed advertising" msgstr "Os dados não são compatíveis com publicidade direcionada" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data too large for advertisement packet" msgstr "Os dados são grandes demais para o pacote de publicidade" @@ -1019,6 +1022,7 @@ msgstr "Um alarme era esperado" msgid "Expected tuple of length %d, got %d" msgstr "Tupla esperada com comprimento %d, obteve %d" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Extended advertisements with scan response not supported." msgstr "Anúncios estendidos não compatíveis com a resposta da varredura." @@ -1072,6 +1076,7 @@ msgstr "Houve uma falha na alocação da memória para a varredura do Wifi" msgid "Failed to buffer the sample" msgstr "Houve uma falha ao fazer uma memória prévia (buffer) da amostra" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Failed to connect: internal error" msgstr "Falha ao conectar: erro interno" @@ -1313,6 +1318,7 @@ msgstr "Valor inválido da unidade ADC" msgid "Invalid AuthMode" msgstr "AuthMode inválido" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c msgid "Invalid BLE parameter" msgstr "Parâmetro BLE inválido" @@ -1407,6 +1413,10 @@ msgstr "Tamanho do pedaço de formato inválido" msgid "Invalid memory access." msgstr "O acesso da memória é inválido." +#: extmod/vfs_fat_file.c +msgid "Invalid mode" +msgstr "Modo inválido" + #: ports/espressif/common-hal/wifi/Radio.c msgid "Invalid multicast MAC address" msgstr "Endereço MAC multicast inválido" @@ -1535,6 +1545,10 @@ msgstr "A inicialização do pino MISO falhou." msgid "MOSI pin init failed." msgstr "Inicialização do pino MOSI falhou." +#: shared-bindings/is31fl3741/__init__.c +msgid "Mapping must be a tuple" +msgstr "" + #: shared-module/displayio/Shape.c #, c-format msgid "Maximum x value when mirrored is %d" @@ -1617,6 +1631,10 @@ msgstr "Erro NVS" msgid "Name too long" msgstr "Nome muito longo" +#: ports/espressif/common-hal/_bleio/__init__.c +msgid "Nimble out of memory" +msgstr "Ágil fora da memória" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "Não há nenhum CCCD para esta característica" @@ -1639,8 +1657,8 @@ msgstr "Nenhum temporizador DMA foi encontrado" #: shared-module/adafruit_bus_device/i2c_device/I2CDevice.c #, c-format -msgid "No I2C device at address: %x" -msgstr "Nenhum dispositivo I2C no endereço: %x" +msgid "No I2C device at address: 0x%x" +msgstr "" #: ports/espressif/common-hal/busio/SPI.c #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c @@ -1766,6 +1784,7 @@ msgstr "O firmware do sistema nórdico está sem memória" msgid "Not a valid IP string" msgstr "Não é uma sequência válida de IP" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -2162,6 +2181,7 @@ msgstr "Taxa de amostragem muito alta. Deve ser menor que %d" msgid "Scale dimensions must divide by 3" msgstr "As dimensões da escala devem ser poder ser divididas por 3" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Scan already in progess. Stop with stop_scan." msgstr "O escaneamento já está em andamento. Interrompa com stop_scan." @@ -2332,6 +2352,7 @@ msgstr "A largura do bloco deve dividir exatamente com a largura do bitmap" msgid "Time is in the past." msgstr "O tempo está no passado." +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2356,6 +2377,7 @@ msgstr "Muitos barramentos estão sendo exibidos" msgid "Too many displays" msgstr "Exibições demais" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Total data to write is larger than %q" msgstr "O total dos dados que serão escritos é maior do que %q" @@ -2488,11 +2510,21 @@ msgstr "Motivo desconhecido." msgid "Unknown security error: 0x%04x" msgstr "Erro de segurança desconhecido: 0x%04x" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error at %s:%d: %d" +msgstr "Ocorreu um erro desconhecido no firmware do sistema em %s:%d: %d" + #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown system firmware error: %04x" msgstr "Erro desconhecido do firmware: %04x" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error: %d" +msgstr "Ocorreu um erro desconhecido no firmware do sistema: %d" + #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #, c-format msgid "Unmatched number of items on RHS (expected %d, got %d)." @@ -2532,11 +2564,13 @@ msgstr "Operação não suportada" msgid "Update Failed" msgstr "A atualização falou" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length != required fixed length" msgstr "Comprimento do valor != comprimento fixo necessário" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length > max_length" @@ -2603,6 +2637,7 @@ msgstr "A senha do Wi-Fi deve ter entre 8 e 63 caracteres" msgid "Woken up by alarm.\n" msgstr "Foi despertado através do alarme.\n" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Writes not supported on Characteristic" msgstr "A escrita não é compatível na Característica" @@ -2862,7 +2897,7 @@ msgstr "não é possível converter implicitamente o objeto '%q' para %q" #: extmod/ulab/code/numpy/vector.c msgid "can't convert complex to float" -msgstr "" +msgstr "não foi possível converter complexo em flutuante" #: py/obj.c msgid "can't convert to %q" @@ -2964,11 +2999,11 @@ msgstr "não pode lançar a saída com a regra de fundição" #: extmod/ulab/code/ndarray.c msgid "cannot convert complex to dtype" -msgstr "" +msgstr "não foi possível converter complexo em dtype" #: extmod/ulab/code/ndarray.c msgid "cannot convert complex type" -msgstr "" +msgstr "não foi possível converter o tipo complexo" #: py/objtype.c msgid "cannot create '%q' instances" @@ -3168,7 +3203,7 @@ msgstr "o divisor deve ser 4" #: extmod/ulab/code/numpy/vector.c msgid "dtype must be float, or complex" -msgstr "" +msgstr "dtype deve ser flutuante ou complexo" #: py/objdeque.c msgid "empty" @@ -3340,7 +3375,7 @@ msgstr "A função é definida apenas para ndarrays" #: extmod/ulab/code/numpy/carray/carray.c msgid "function is implemented for ndarrays only" -msgstr "" +msgstr "a função está implementada apenas para ndarrays" #: py/argcheck.c #, c-format @@ -3474,7 +3509,7 @@ msgstr "os dados da entrada devem ser iteráveis" #: extmod/ulab/code/numpy/vector.c msgid "input dtype must be float or complex" -msgstr "" +msgstr "o tipo da entrada dtype deve ser flutuante ou complexo" #: extmod/ulab/code/numpy/linalg/linalg.c msgid "input matrix is asymmetric" @@ -3487,7 +3522,7 @@ msgstr "a matriz da entrada é singular" #: extmod/ulab/code/numpy/carray/carray.c msgid "input must be a 1D ndarray" -msgstr "" +msgstr "a entrada deve ser um 1D ndarray" #: extmod/ulab/code/scipy/linalg/linalg.c extmod/ulab/code/user/user.c msgid "input must be a dense ndarray" @@ -3503,7 +3538,7 @@ msgstr "a entrada deve ser um ndarray" #: extmod/ulab/code/numpy/carray/carray.c msgid "input must be an ndarray, or a scalar" -msgstr "" +msgstr "a entrada deve ser um ndarray ou um escalar" #: extmod/ulab/code/scipy/signal/signal.c msgid "input must be one-dimensional" @@ -3685,6 +3720,7 @@ msgstr "erro de domínio matemático" msgid "matrix is not positive definite" msgstr "a matriz não é definitiva positiva" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c #, c-format @@ -3882,7 +3918,7 @@ msgstr "argumentos insuficientes para o formato da string" #: extmod/ulab/code/numpy/carray/carray_tools.c msgid "not implemented for complex dtype" -msgstr "" +msgstr "não foi implementado para dtype complexo" #: extmod/ulab/code/numpy/create.c msgid "number of points must be at least 2" @@ -4096,6 +4132,7 @@ msgstr "O terceiro argumento pow() não pode ser 0" msgid "pow() with 3 arguments requires integers" msgstr "o pow() com 3 argumentos requer números inteiros" +#: ports/espressif/boards/adafruit_esp32s2_camera/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tft/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h @@ -4103,15 +4140,18 @@ msgstr "o pow() com 3 argumentos requer números inteiros" #: ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h +#: ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h #: ports/espressif/boards/atmegazero_esp32s2/mpconfigboard.h #: ports/espressif/boards/crumpspace_crumps2/mpconfigboard.h #: ports/espressif/boards/electroniccats_bastwifi/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_box/mpconfigboard.h -#: ports/espressif/boards/espressif_esp32s3_devkitc_1/mpconfigboard.h -#: ports/espressif/boards/espressif_esp32s3_devkitc_1_nopsram/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h #: ports/espressif/boards/espressif_hmi_devkit_1/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1.3/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1/mpconfigboard.h @@ -4137,7 +4177,10 @@ msgstr "o pow() com 3 argumentos requer números inteiros" #: ports/espressif/boards/unexpectedmaker_feathers2/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_neo/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_prerelease/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_feathers3/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_pros3/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_tinys2/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_tinys3/mpconfigboard.h msgid "pressing boot button at start up.\n" msgstr "pressionando o botão de boot na inicialização.\n" @@ -4647,7 +4690,7 @@ msgstr "tipo da entrada incorreta" #: extmod/ulab/code/numpy/transform.c msgid "wrong length of condition array" -msgstr "" +msgstr "comprimento errado na condição da matriz" #: extmod/ulab/code/numpy/create.c py/objarray.c py/objstr.c msgid "wrong number of arguments" @@ -4693,6 +4736,10 @@ 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 "No I2C device at address: %x" +#~ msgstr "Nenhum dispositivo I2C no endereço: %x" + #~ msgid "Unsupported pull value." #~ msgstr "O valor pull não é compatível." diff --git a/locale/ru.po b/locale/ru.po index af6e5c3822..a0bb99fc09 100644 --- a/locale/ru.po +++ b/locale/ru.po @@ -111,7 +111,7 @@ msgstr "Индексы %q должны быть целыми числами, а msgid "%q length must be %d-%d" msgstr "Длинна %q должна быть %d-%d" -#: shared-bindings/usb_hid/Device.c +#: shared-bindings/busio/I2C.c shared-bindings/usb_hid/Device.c msgid "%q length must be >= 1" msgstr "Длинна %q должна быть >= 1" @@ -458,6 +458,7 @@ msgstr "Все таймеры для этого Пина уже использу msgid "All timers in use" msgstr "Все таймеры уже используются" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Already advertising." msgstr "Уже объявляемся (advertising)." @@ -648,7 +649,7 @@ msgstr "Размер буфера должен быть кратен 512" msgid "Buffer must be a multiple of 512 bytes" msgstr "Буфер должен быть кратен 512" -#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c +#: shared-bindings/bitbangio/I2C.c msgid "Buffer must be at least length 1" msgstr "Буфер должен быть размером не менее 1" @@ -935,10 +936,12 @@ msgstr "Вывод data 0 должен быть выровнен по байта msgid "Data chunk must follow fmt chunk" msgstr "Блок данных должен следовать за блоком fmt" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data not supported with directed advertising" msgstr "Данные не поддерживаются направленным объявлением" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data too large for advertisement packet" msgstr "Данные слишком велики для пакета объявления" @@ -1021,6 +1024,7 @@ msgstr "Ожидался сигнал" msgid "Expected tuple of length %d, got %d" msgstr "Ожидался кортеж длины %d, получен %d" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Extended advertisements with scan response not supported." msgstr "Расширенные объявления с ответом сканирования не поддерживаются." @@ -1074,6 +1078,7 @@ msgstr "Не удалось выделить память для сканиро msgid "Failed to buffer the sample" msgstr "Не удалось выполнить буферизацию образца" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Failed to connect: internal error" msgstr "Не удалось подключиться: внутренняя ошибка" @@ -1319,6 +1324,7 @@ msgstr "Недопустимое значение единицы АЦП" msgid "Invalid AuthMode" msgstr "Недопустимый AuthMode" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c msgid "Invalid BLE parameter" msgstr "Недопустимый параметр BLE" @@ -1413,6 +1419,10 @@ msgstr "Неверный размер блока формата" msgid "Invalid memory access." msgstr "Неправильный доступ к памяти." +#: extmod/vfs_fat_file.c +msgid "Invalid mode" +msgstr "" + #: ports/espressif/common-hal/wifi/Radio.c msgid "Invalid multicast MAC address" msgstr "Неверный MAC-адрес multicast" @@ -1541,6 +1551,10 @@ msgstr "Не удалось инициализировать вывод MISO." msgid "MOSI pin init failed." msgstr "Не удалось инициализировать вывод MOSI." +#: shared-bindings/is31fl3741/__init__.c +msgid "Mapping must be a tuple" +msgstr "" + #: shared-module/displayio/Shape.c #, c-format msgid "Maximum x value when mirrored is %d" @@ -1625,6 +1639,10 @@ msgstr "Ошибка NVS" msgid "Name too long" msgstr "Имя слишком длинное" +#: ports/espressif/common-hal/_bleio/__init__.c +msgid "Nimble out of memory" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "Нет CCCD для этой Characteristic" @@ -1647,8 +1665,8 @@ msgstr "" #: shared-module/adafruit_bus_device/i2c_device/I2CDevice.c #, c-format -msgid "No I2C device at address: %x" -msgstr "Нет устройства I2C по адресу: %x" +msgid "No I2C device at address: 0x%x" +msgstr "" #: ports/espressif/common-hal/busio/SPI.c #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c @@ -1774,6 +1792,7 @@ msgstr "" msgid "Not a valid IP string" msgstr "Недействительная строка IP" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -2161,6 +2180,7 @@ msgstr "" msgid "Scale dimensions must divide by 3" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Scan already in progess. Stop with stop_scan." msgstr "" @@ -2319,6 +2339,7 @@ msgstr "" msgid "Time is in the past." msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2341,6 +2362,7 @@ msgstr "" msgid "Too many displays" msgstr "" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Total data to write is larger than %q" msgstr "" @@ -2472,11 +2494,21 @@ msgstr "" msgid "Unknown security error: 0x%04x" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error at %s:%d: %d" +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown system firmware error: %04x" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error: %d" +msgstr "" + #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #, c-format msgid "Unmatched number of items on RHS (expected %d, got %d)." @@ -2514,11 +2546,13 @@ msgstr "" msgid "Update Failed" msgstr "" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length != required fixed length" msgstr "" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length > max_length" @@ -2576,6 +2610,7 @@ msgstr "" msgid "Woken up by alarm.\n" msgstr "" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Writes not supported on Characteristic" msgstr "" @@ -3643,6 +3678,7 @@ msgstr "" msgid "matrix is not positive definite" msgstr "" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c #, c-format @@ -4047,6 +4083,7 @@ msgstr "" msgid "pow() with 3 arguments requires integers" msgstr "" +#: ports/espressif/boards/adafruit_esp32s2_camera/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tft/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h @@ -4054,15 +4091,18 @@ msgstr "" #: ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h +#: ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h #: ports/espressif/boards/atmegazero_esp32s2/mpconfigboard.h #: ports/espressif/boards/crumpspace_crumps2/mpconfigboard.h #: ports/espressif/boards/electroniccats_bastwifi/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_box/mpconfigboard.h -#: ports/espressif/boards/espressif_esp32s3_devkitc_1/mpconfigboard.h -#: ports/espressif/boards/espressif_esp32s3_devkitc_1_nopsram/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h #: ports/espressif/boards/espressif_hmi_devkit_1/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1.3/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1/mpconfigboard.h @@ -4088,7 +4128,10 @@ msgstr "" #: ports/espressif/boards/unexpectedmaker_feathers2/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_neo/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_prerelease/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_feathers3/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_pros3/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_tinys2/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_tinys3/mpconfigboard.h msgid "pressing boot button at start up.\n" msgstr "" @@ -4642,3 +4685,7 @@ msgstr "zi должно быть типа float" #: extmod/ulab/code/scipy/signal/signal.c msgid "zi must be of shape (n_section, 2)" msgstr "zi должен иметь форму (n_section, 2)" + +#, c-format +#~ msgid "No I2C device at address: %x" +#~ msgstr "Нет устройства I2C по адресу: %x" diff --git a/locale/sv.po b/locale/sv.po index 74c57e7946..a27427a08a 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: 2022-01-03 05:53+0000\n" +"PO-Revision-Date: 2022-02-02 20:18+0000\n" "Last-Translator: Jonny Bergdahl \n" "Language-Team: LANGUAGE \n" "Language: sv\n" @@ -14,7 +14,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Generator: Weblate 4.10.1\n" +"X-Generator: Weblate 4.11-dev\n" #: main.c msgid "" @@ -107,7 +107,7 @@ msgstr "Indexet %q måste vara ett heltal, inte %s" msgid "%q length must be %d-%d" msgstr "längden på %q måste vara %d-%d" -#: shared-bindings/usb_hid/Device.c +#: shared-bindings/busio/I2C.c shared-bindings/usb_hid/Device.c msgid "%q length must be >= 1" msgstr "längden på %q måste vara >= 1" @@ -454,6 +454,7 @@ msgstr "Alla timers för denna pinne är i bruk" msgid "All timers in use" msgstr "Alla timers används" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Already advertising." msgstr "Annonserar redan." @@ -640,7 +641,7 @@ msgstr "Buffertlängd måste vara en multipel av 512" msgid "Buffer must be a multiple of 512 bytes" msgstr "Bufferten måste vara en multipel av 512 byte" -#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c +#: shared-bindings/bitbangio/I2C.c msgid "Buffer must be at least length 1" msgstr "Bufferten måste ha minst längd 1" @@ -923,10 +924,12 @@ msgstr "Datapinne 0 måste vara bytejusterad" msgid "Data chunk must follow fmt chunk" msgstr "Datasegmentet måste följa fmt-segmentet" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data not supported with directed advertising" msgstr "Data stöds inte med riktad annonsering" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data too large for advertisement packet" msgstr "Data för stor för annonseringspaket" @@ -1007,6 +1010,7 @@ msgstr "Förväntade ett larm" msgid "Expected tuple of length %d, got %d" msgstr "Förväntad tupel med längd %d, fick %d" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Extended advertisements with scan response not supported." msgstr "Utökad annonsering i kombination med skanningssvar stöds inte." @@ -1060,6 +1064,7 @@ msgstr "Det gick inte att allokera minne för WiFi-scanning" msgid "Failed to buffer the sample" msgstr "Det gick inte att buffra samplingen" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Failed to connect: internal error" msgstr "Det gick inte att ansluta: internt fel" @@ -1295,6 +1300,7 @@ msgstr "Ogiltigt ADC-enhetsvärde" msgid "Invalid AuthMode" msgstr "Ogiltig AuthMode" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c msgid "Invalid BLE parameter" msgstr "Ogiltig BLE-parameter" @@ -1389,6 +1395,10 @@ msgstr "Ogiltig formatsegmentstorlek" msgid "Invalid memory access." msgstr "Ogiltig minnesåtkomst." +#: extmod/vfs_fat_file.c +msgid "Invalid mode" +msgstr "Ogiltigt läge" + #: ports/espressif/common-hal/wifi/Radio.c msgid "Invalid multicast MAC address" msgstr "Ogiltig MAC-adress för multicast" @@ -1517,6 +1527,10 @@ msgstr "init för MISO-pinne misslyckades." msgid "MOSI pin init failed." msgstr "init för MOSI-pinne misslyckades." +#: shared-bindings/is31fl3741/__init__.c +msgid "Mapping must be a tuple" +msgstr "" + #: shared-module/displayio/Shape.c #, c-format msgid "Maximum x value when mirrored is %d" @@ -1600,6 +1614,10 @@ msgstr "NVS-fel" msgid "Name too long" msgstr "Name är för långt" +#: ports/espressif/common-hal/_bleio/__init__.c +msgid "Nimble out of memory" +msgstr "Nimble har inget minne kvar" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "Ingen CCCD för denna karaktäristik" @@ -1622,8 +1640,8 @@ msgstr "Ingen DMA pacing timer hittades" #: shared-module/adafruit_bus_device/i2c_device/I2CDevice.c #, c-format -msgid "No I2C device at address: %x" -msgstr "Ingen I2C-enhet på adress: %x" +msgid "No I2C device at address: 0x%x" +msgstr "Ingen I2C-enhet på adress: 0x%x" #: ports/espressif/common-hal/busio/SPI.c #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c @@ -1747,6 +1765,7 @@ msgstr "Nordic systemfirmware fick slut på minne" msgid "Not a valid IP string" msgstr "Inte en giltig IP-sträng" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -2138,6 +2157,7 @@ msgstr "Samplingsfrekvensen är för hög. Den måste vara mindre än %d" msgid "Scale dimensions must divide by 3" msgstr "Skaldimension måste vara delbar med 3" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Scan already in progess. Stop with stop_scan." msgstr "Skanning pågår redan. Avsluta med stop_scan." @@ -2306,6 +2326,7 @@ msgstr "Tile-bredd måste vara jämnt delbar med bredd på bitmap" msgid "Time is in the past." msgstr "Tid har passerats." +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2328,6 +2349,7 @@ msgstr "För många display-bussar" msgid "Too many displays" msgstr "För många displayer" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Total data to write is larger than %q" msgstr "Totala data att skriva är större än %q" @@ -2459,11 +2481,21 @@ msgstr "Okänd anledning." msgid "Unknown security error: 0x%04x" msgstr "Okänt säkerhetsfel: 0x%04x" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error at %s:%d: %d" +msgstr "Okänt fel i systemets firmware vid %s:%d: %d" + #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown system firmware error: %04x" msgstr "Okänt systemfirmwarefel: %04x" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error: %d" +msgstr "Okänt fel i systemets firmware: %d" + #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #, c-format msgid "Unmatched number of items on RHS (expected %d, got %d)." @@ -2503,11 +2535,13 @@ msgstr "Åtgärd som inte stöds" msgid "Update Failed" msgstr "Uppdateringen misslyckades" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length != required fixed length" msgstr "Värdets längde ! = krävd fast längd" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length > max_length" @@ -2571,6 +2605,7 @@ msgstr "WiFi-lösenord måste vara mellan 8 och 63 tecken" msgid "Woken up by alarm.\n" msgstr "Vaknade av larm.\n" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Writes not supported on Characteristic" msgstr "Skrivning stöds inte på karaktäristik" @@ -2830,7 +2865,7 @@ msgstr "kan inte konvertera '%q' objekt implicit till %q" #: extmod/ulab/code/numpy/vector.c msgid "can't convert complex to float" -msgstr "" +msgstr "kan inte konvertera complex till float" #: py/obj.c msgid "can't convert to %q" @@ -2930,11 +2965,11 @@ msgstr "kan inte casta utdata med regel" #: extmod/ulab/code/ndarray.c msgid "cannot convert complex to dtype" -msgstr "" +msgstr "kan inte konvertera komplex till dtype" #: extmod/ulab/code/ndarray.c msgid "cannot convert complex type" -msgstr "" +msgstr "kan inte konvertera complex typer" #: py/objtype.c msgid "cannot create '%q' instances" @@ -3132,7 +3167,7 @@ msgstr "divisor måste vara 4" #: extmod/ulab/code/numpy/vector.c msgid "dtype must be float, or complex" -msgstr "" +msgstr "dtype måste vara float eller complex" #: py/objdeque.c msgid "empty" @@ -3304,7 +3339,7 @@ msgstr "funktionen är enbart definierad för ndarray" #: extmod/ulab/code/numpy/carray/carray.c msgid "function is implemented for ndarrays only" -msgstr "" +msgstr "funktionen är bara implementerad för ndarrays" #: py/argcheck.c #, c-format @@ -3437,7 +3472,7 @@ msgstr "indata måste vara en iterable" #: extmod/ulab/code/numpy/vector.c msgid "input dtype must be float or complex" -msgstr "" +msgstr "indatatyp måste vara float eller complex" #: extmod/ulab/code/numpy/linalg/linalg.c msgid "input matrix is asymmetric" @@ -3450,7 +3485,7 @@ msgstr "indatamatrisen är singulär" #: extmod/ulab/code/numpy/carray/carray.c msgid "input must be a 1D ndarray" -msgstr "" +msgstr "indata måste vara en 1D ndarray" #: extmod/ulab/code/scipy/linalg/linalg.c extmod/ulab/code/user/user.c msgid "input must be a dense ndarray" @@ -3466,7 +3501,7 @@ msgstr "indata måste vara en ndarray" #: extmod/ulab/code/numpy/carray/carray.c msgid "input must be an ndarray, or a scalar" -msgstr "" +msgstr "indata måste vara en ndarray eller en scalar" #: extmod/ulab/code/scipy/signal/signal.c msgid "input must be one-dimensional" @@ -3648,6 +3683,7 @@ msgstr "matematikdomänfel" msgid "matrix is not positive definite" msgstr "matrisen är inte positiv bestämd" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c #, c-format @@ -3843,7 +3879,7 @@ msgstr "inte tillräckligt med argument för formatsträng" #: extmod/ulab/code/numpy/carray/carray_tools.c msgid "not implemented for complex dtype" -msgstr "" +msgstr "inte implementerat för complex dtype" #: extmod/ulab/code/numpy/create.c msgid "number of points must be at least 2" @@ -4053,6 +4089,7 @@ msgstr "pow() 3: e argument kan inte vara 0" msgid "pow() with 3 arguments requires integers" msgstr "pow() med 3 argument kräver heltal" +#: ports/espressif/boards/adafruit_esp32s2_camera/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tft/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h @@ -4060,15 +4097,18 @@ msgstr "pow() med 3 argument kräver heltal" #: ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h +#: ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h #: ports/espressif/boards/atmegazero_esp32s2/mpconfigboard.h #: ports/espressif/boards/crumpspace_crumps2/mpconfigboard.h #: ports/espressif/boards/electroniccats_bastwifi/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_box/mpconfigboard.h -#: ports/espressif/boards/espressif_esp32s3_devkitc_1/mpconfigboard.h -#: ports/espressif/boards/espressif_esp32s3_devkitc_1_nopsram/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h #: ports/espressif/boards/espressif_hmi_devkit_1/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1.3/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1/mpconfigboard.h @@ -4094,7 +4134,10 @@ msgstr "pow() med 3 argument kräver heltal" #: ports/espressif/boards/unexpectedmaker_feathers2/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_neo/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_prerelease/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_feathers3/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_pros3/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_tinys2/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_tinys3/mpconfigboard.h msgid "pressing boot button at start up.\n" msgstr "trycka på startknappen vid start.\n" @@ -4604,7 +4647,7 @@ msgstr "fel indatatyp" #: extmod/ulab/code/numpy/transform.c msgid "wrong length of condition array" -msgstr "" +msgstr "fel längd på villkorsmatrisen" #: extmod/ulab/code/numpy/create.c py/objarray.c py/objstr.c msgid "wrong number of arguments" @@ -4650,6 +4693,10 @@ 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 "No I2C device at address: %x" +#~ msgstr "Ingen I2C-enhet på adress: %x" + #~ msgid "Unsupported pull value." #~ msgstr "Ogiltigt Pull-värde." diff --git a/locale/tr.po b/locale/tr.po index 2ff9f016bf..5408aa2823 100644 --- a/locale/tr.po +++ b/locale/tr.po @@ -110,7 +110,7 @@ msgstr "%q indeksleri integer olmalı, %s değil" msgid "%q length must be %d-%d" msgstr "%q boyutları %d-%d olmalıdır" -#: shared-bindings/usb_hid/Device.c +#: shared-bindings/busio/I2C.c shared-bindings/usb_hid/Device.c msgid "%q length must be >= 1" msgstr "%q boyutu >=1 olmalıdır" @@ -459,6 +459,7 @@ msgstr "Bu pin için tüm zamanlayıcılar kullanımda" msgid "All timers in use" msgstr "Tüm zamanlayıcılar kullanımda" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Already advertising." msgstr "Halihazırda duyuruluyor." @@ -645,7 +646,7 @@ msgstr "" msgid "Buffer must be a multiple of 512 bytes" msgstr "" -#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c +#: shared-bindings/bitbangio/I2C.c msgid "Buffer must be at least length 1" msgstr "" @@ -923,10 +924,12 @@ msgstr "" msgid "Data chunk must follow fmt chunk" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data not supported with directed advertising" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data too large for advertisement packet" msgstr "" @@ -1007,6 +1010,7 @@ msgstr "" msgid "Expected tuple of length %d, got %d" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Extended advertisements with scan response not supported." msgstr "" @@ -1060,6 +1064,7 @@ msgstr "" msgid "Failed to buffer the sample" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Failed to connect: internal error" msgstr "" @@ -1291,6 +1296,7 @@ msgstr "" msgid "Invalid AuthMode" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c msgid "Invalid BLE parameter" msgstr "" @@ -1385,6 +1391,10 @@ msgstr "" msgid "Invalid memory access." msgstr "" +#: extmod/vfs_fat_file.c +msgid "Invalid mode" +msgstr "" + #: ports/espressif/common-hal/wifi/Radio.c msgid "Invalid multicast MAC address" msgstr "" @@ -1513,6 +1523,10 @@ msgstr "" msgid "MOSI pin init failed." msgstr "" +#: shared-bindings/is31fl3741/__init__.c +msgid "Mapping must be a tuple" +msgstr "" + #: shared-module/displayio/Shape.c #, c-format msgid "Maximum x value when mirrored is %d" @@ -1595,6 +1609,10 @@ msgstr "" msgid "Name too long" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +msgid "Nimble out of memory" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "" @@ -1617,7 +1635,7 @@ msgstr "" #: shared-module/adafruit_bus_device/i2c_device/I2CDevice.c #, c-format -msgid "No I2C device at address: %x" +msgid "No I2C device at address: 0x%x" msgstr "" #: ports/espressif/common-hal/busio/SPI.c @@ -1742,6 +1760,7 @@ msgstr "" msgid "Not a valid IP string" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -2124,6 +2143,7 @@ msgstr "" msgid "Scale dimensions must divide by 3" msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Scan already in progess. Stop with stop_scan." msgstr "" @@ -2282,6 +2302,7 @@ msgstr "" msgid "Time is in the past." msgstr "" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2304,6 +2325,7 @@ msgstr "" msgid "Too many displays" msgstr "" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Total data to write is larger than %q" msgstr "" @@ -2435,11 +2457,21 @@ msgstr "" msgid "Unknown security error: 0x%04x" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error at %s:%d: %d" +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown system firmware error: %04x" msgstr "" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error: %d" +msgstr "" + #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #, c-format msgid "Unmatched number of items on RHS (expected %d, got %d)." @@ -2477,11 +2509,13 @@ msgstr "" msgid "Update Failed" msgstr "" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length != required fixed length" msgstr "" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length > max_length" @@ -2539,6 +2573,7 @@ msgstr "" msgid "Woken up by alarm.\n" msgstr "" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Writes not supported on Characteristic" msgstr "" @@ -3606,6 +3641,7 @@ msgstr "" msgid "matrix is not positive definite" msgstr "" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c #, c-format @@ -4010,6 +4046,7 @@ msgstr "" msgid "pow() with 3 arguments requires integers" msgstr "" +#: ports/espressif/boards/adafruit_esp32s2_camera/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tft/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h @@ -4017,15 +4054,18 @@ msgstr "" #: ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h +#: ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h #: ports/espressif/boards/atmegazero_esp32s2/mpconfigboard.h #: ports/espressif/boards/crumpspace_crumps2/mpconfigboard.h #: ports/espressif/boards/electroniccats_bastwifi/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_box/mpconfigboard.h -#: ports/espressif/boards/espressif_esp32s3_devkitc_1/mpconfigboard.h -#: ports/espressif/boards/espressif_esp32s3_devkitc_1_nopsram/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h #: ports/espressif/boards/espressif_hmi_devkit_1/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1.3/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1/mpconfigboard.h @@ -4051,7 +4091,10 @@ msgstr "" #: ports/espressif/boards/unexpectedmaker_feathers2/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_neo/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_prerelease/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_feathers3/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_pros3/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_tinys2/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_tinys3/mpconfigboard.h msgid "pressing boot button at start up.\n" msgstr "" diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index ec39c2cba6..fa0bf0fa41 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -109,7 +109,7 @@ msgstr "%q suǒyǐn bìxū shì zhěngshù, ér bùshì %s" msgid "%q length must be %d-%d" msgstr "%q cháng dù bì xū wéi %d-%d" -#: shared-bindings/usb_hid/Device.c +#: shared-bindings/busio/I2C.c shared-bindings/usb_hid/Device.c msgid "%q length must be >= 1" msgstr "%q cháng dù bì xū >= 1" @@ -457,6 +457,7 @@ msgstr "cǐ yǐnjiǎo de suǒyǒu jìshíqì dōu zài shǐyòng zhōng" msgid "All timers in use" msgstr "suǒyǒu jìshí qì dōu zài shǐyòng zhōng" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Already advertising." msgstr "Mùqián zhèngzài guǎngbō." @@ -647,7 +648,7 @@ msgstr "Huǎnchōngqū chángdù bìxū wéi 512 de bèishù" msgid "Buffer must be a multiple of 512 bytes" msgstr "Huǎnchōngqū bìxū shì 512 zìjié de bèishù" -#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c +#: shared-bindings/bitbangio/I2C.c msgid "Buffer must be at least length 1" msgstr "Huǎnchōng qū bìxū zhìshǎo chángdù wéi 1" @@ -930,10 +931,12 @@ msgstr "Shùjù 0 de yǐn jiǎo bìxū shì zì jié duìqí" msgid "Data chunk must follow fmt chunk" msgstr "Shùjù kuài bìxū zūnxún fmt qū kuài" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data not supported with directed advertising" msgstr "bù zhī chí dìng xiàng guǎng gào de shù jù" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Data too large for advertisement packet" msgstr "Guǎnggào bāo de shùjù tài dà" @@ -1015,6 +1018,7 @@ msgstr "yù qī yǒu jǐng bào" msgid "Expected tuple of length %d, got %d" msgstr "Qīwàng de chángdù wèi %d de yuán zǔ, dédào %d" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Extended advertisements with scan response not supported." msgstr "Bù zhīchí dài yǒu sǎomiáo xiǎngyìng de kuòzhǎn guǎngbò." @@ -1068,6 +1072,7 @@ msgstr "Wúfǎ fēnpèi wifi sǎomiáo nèicún" msgid "Failed to buffer the sample" msgstr "wèi néng huǎn chōng yàng běn" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Failed to connect: internal error" msgstr "Liánjiē shībài: Nèibù cuòwù" @@ -1309,6 +1314,7 @@ msgstr "Wúxiào de ADC dānwèi zhí" msgid "Invalid AuthMode" msgstr "wú xiào AuthMode" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c msgid "Invalid BLE parameter" msgstr "wú xiào BLE cān shù" @@ -1403,6 +1409,10 @@ msgstr "Géshì kuài dàxiǎo wúxiào" msgid "Invalid memory access." msgstr "Wúxiào de nèicún fǎngwèn." +#: extmod/vfs_fat_file.c +msgid "Invalid mode" +msgstr "" + #: ports/espressif/common-hal/wifi/Radio.c msgid "Invalid multicast MAC address" msgstr "wú xiào de duō bō MAC dì zhǐ" @@ -1531,6 +1541,10 @@ msgstr "MISO yǐn jiǎo chūshǐhuà shībài." msgid "MOSI pin init failed." msgstr "MOSI yǐn jiǎo shūrù shībài." +#: shared-bindings/is31fl3741/__init__.c +msgid "Mapping must be a tuple" +msgstr "" + #: shared-module/displayio/Shape.c #, c-format msgid "Maximum x value when mirrored is %d" @@ -1614,6 +1628,10 @@ msgstr "NVS cuò wù" msgid "Name too long" msgstr "Míngchēng tài zhǎng" +#: ports/espressif/common-hal/_bleio/__init__.c +msgid "Nimble out of memory" +msgstr "" + #: ports/nrf/common-hal/_bleio/Characteristic.c msgid "No CCCD for this Characteristic" msgstr "Zhège tèzhēng méiyǒu CCCD" @@ -1636,8 +1654,8 @@ msgstr "wèi zhǎo dào DMA qǐ bó qì" #: shared-module/adafruit_bus_device/i2c_device/I2CDevice.c #, c-format -msgid "No I2C device at address: %x" -msgstr "dì zhǐ wú I2C shè bèi: %x" +msgid "No I2C device at address: 0x%x" +msgstr "" #: ports/espressif/common-hal/busio/SPI.c #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c @@ -1761,6 +1779,7 @@ msgstr "běi ōu xì tǒng gù jiàn chū nèi cún" msgid "Not a valid IP string" msgstr "Wúxiào de IP zìfú chuàn" +#: ports/espressif/common-hal/_bleio/__init__.c #: ports/nrf/common-hal/_bleio/__init__.c #: shared-bindings/_bleio/CharacteristicBuffer.c msgid "Not connected" @@ -2151,6 +2170,7 @@ msgstr "Cǎiyàng lǜ tài gāo. Tā bìxū xiǎoyú %d" msgid "Scale dimensions must divide by 3" msgstr "bǐ lì chǐ cùn bì xū chú yǐ 3" +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c msgid "Scan already in progess. Stop with stop_scan." msgstr "Zhèngzài jìn háng sǎomiáo. Shǐyòng stop_scan tíngzhǐ." @@ -2318,6 +2338,7 @@ msgstr "Píng pū kuāndù bìxū huàfēn wèi tú kuāndù" msgid "Time is in the past." msgstr "shí jiān yǐ jīng guò qù." +#: ports/espressif/common-hal/_bleio/Adapter.c #: ports/nrf/common-hal/_bleio/Adapter.c #, c-format msgid "Timeout is too long: Maximum timeout length is %d seconds" @@ -2340,6 +2361,7 @@ msgstr "Xiǎnshì zǒngxiàn tài duōle" msgid "Too many displays" msgstr "Xiǎnshì tài duō" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Total data to write is larger than %q" msgstr "yào biān xiě de zǒng shù jù dà yú %q" @@ -2471,11 +2493,21 @@ msgstr "Yuányīn bùmíng." msgid "Unknown security error: 0x%04x" msgstr "Wèizhī de ānquán cuòwù: 0x%04x" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error at %s:%d: %d" +msgstr "" + #: ports/nrf/common-hal/_bleio/__init__.c #, c-format msgid "Unknown system firmware error: %04x" msgstr "wèi zhī xì tǒng gù jiàn cuò wù: %04x" +#: ports/espressif/common-hal/_bleio/__init__.c +#, c-format +msgid "Unknown system firmware error: %d" +msgstr "" + #: shared-bindings/adafruit_pixelbuf/PixelBuf.c #, c-format msgid "Unmatched number of items on RHS (expected %d, got %d)." @@ -2515,11 +2547,13 @@ msgstr "Bù zhīchí de cāozuò" msgid "Update Failed" msgstr "gēng xīn shī bài" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length != required fixed length" msgstr "Zhí chángdù != Suǒ xū de gùdìng chángdù" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c msgid "Value length > max_length" @@ -2583,6 +2617,7 @@ msgstr "WiFi mìmǎ bìxū jiè yú 8 dào 63 gè zìfú zhī jiān" msgid "Woken up by alarm.\n" msgstr "bèi jǐng bào chǎo xǐng.\n" +#: ports/espressif/common-hal/_bleio/PacketBuffer.c #: ports/nrf/common-hal/_bleio/PacketBuffer.c msgid "Writes not supported on Characteristic" msgstr "Tèzhēng bù zhīchí xiě rù" @@ -3659,6 +3694,7 @@ msgstr "shùxué yù cuòwù" msgid "matrix is not positive definite" msgstr "jǔzhèn bùshì zhèngdìng de" +#: ports/espressif/common-hal/_bleio/Descriptor.c #: ports/nrf/common-hal/_bleio/Characteristic.c #: ports/nrf/common-hal/_bleio/Descriptor.c #, c-format @@ -4063,6 +4099,7 @@ msgstr "pow() 3 cān shǔ bùnéng wéi 0" msgid "pow() with 3 arguments requires integers" msgstr "pow() yǒu 3 cānshù xūyào zhěngshù" +#: ports/espressif/boards/adafruit_esp32s2_camera/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tft/mpconfigboard.h #: ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h @@ -4070,15 +4107,18 @@ msgstr "pow() yǒu 3 cānshù xūyào zhěngshù" #: ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h #: ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h +#: ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h #: ports/espressif/boards/atmegazero_esp32s2/mpconfigboard.h #: ports/espressif/boards/crumpspace_crumps2/mpconfigboard.h #: ports/espressif/boards/electroniccats_bastwifi/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.h #: ports/espressif/boards/espressif_esp32s3_box/mpconfigboard.h -#: ports/espressif/boards/espressif_esp32s3_devkitc_1/mpconfigboard.h -#: ports/espressif/boards/espressif_esp32s3_devkitc_1_nopsram/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h +#: ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h #: ports/espressif/boards/espressif_hmi_devkit_1/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1.3/mpconfigboard.h #: ports/espressif/boards/espressif_kaluga_1/mpconfigboard.h @@ -4104,7 +4144,10 @@ msgstr "pow() yǒu 3 cānshù xūyào zhěngshù" #: ports/espressif/boards/unexpectedmaker_feathers2/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_neo/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_feathers2_prerelease/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_feathers3/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_pros3/mpconfigboard.h #: ports/espressif/boards/unexpectedmaker_tinys2/mpconfigboard.h +#: ports/espressif/boards/unexpectedmaker_tinys3/mpconfigboard.h msgid "pressing boot button at start up.\n" msgstr "Zài qǐdòng shí àn qǐdòng ànniǔ.\n" @@ -4663,6 +4706,10 @@ 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 "No I2C device at address: %x" +#~ msgstr "dì zhǐ wú I2C shè bèi: %x" + #~ msgid "Unsupported pull value." #~ msgstr "Bù zhīchí de lādòng zhí." diff --git a/main.c b/main.c index 555e8fafb4..b4537b1d69 100644 --- a/main.c +++ b/main.c @@ -290,10 +290,10 @@ STATIC void cleanup_after_vm(supervisor_allocation *heap, mp_obj_t exception) { keypad_reset(); #endif - // reset_board_busses() first because it may release pins from the never_reset state, so that + // reset_board_buses() first because it may release pins from the never_reset state, so that // reset_port() can reset them. #if CIRCUITPY_BOARD - reset_board_busses(); + reset_board_buses(); #endif reset_port(); reset_board(); @@ -838,7 +838,7 @@ int __attribute__((used)) main(void) { // By default our internal flash is readonly to local python code and // writable over USB. Set it here so that boot.py can change it. filesystem_set_internal_concurrent_write_protection(true); - filesystem_set_internal_writable_by_usb(true); + filesystem_set_internal_writable_by_usb(CIRCUITPY_USB == 1); run_boot_py(safe_mode); diff --git a/ports/atmel-samd/boards/aloriumtech_evo_m51/pins.c b/ports/atmel-samd/boards/aloriumtech_evo_m51/pins.c index 35cc41b557..d6a2979d9e 100644 --- a/ports/atmel-samd/boards/aloriumtech_evo_m51/pins.c +++ b/ports/atmel-samd/boards/aloriumtech_evo_m51/pins.c @@ -53,6 +53,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_BATTERY), MP_ROM_PTR(&pin_PB01) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, diff --git a/ports/atmel-samd/boards/arduino_mkrzero/mpconfigboard.mk b/ports/atmel-samd/boards/arduino_mkrzero/mpconfigboard.mk index eea3a27f13..2c8910a66a 100644 --- a/ports/atmel-samd/boards/arduino_mkrzero/mpconfigboard.mk +++ b/ports/atmel-samd/boards/arduino_mkrzero/mpconfigboard.mk @@ -9,3 +9,5 @@ CHIP_FAMILY = samd21 INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE CIRCUITPY_FULL_BUILD = 0 + +CIRCUITPY_ONEWIREIO = 0 diff --git a/ports/atmel-samd/boards/blm_badge/pins.c b/ports/atmel-samd/boards/blm_badge/pins.c index 6da6f0e9db..993abae2b8 100644 --- a/ports/atmel-samd/boards/blm_badge/pins.c +++ b/ports/atmel-samd/boards/blm_badge/pins.c @@ -44,5 +44,6 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_PA03) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, }; MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/atmel-samd/boards/capablerobot_usbhub/pins.c b/ports/atmel-samd/boards/capablerobot_usbhub/pins.c index 02bb347fe0..d82517890f 100644 --- a/ports/atmel-samd/boards/capablerobot_usbhub/pins.c +++ b/ports/atmel-samd/boards/capablerobot_usbhub/pins.c @@ -33,6 +33,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PB23) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, }; diff --git a/ports/atmel-samd/boards/cp_sapling_m0/pins.c b/ports/atmel-samd/boards/cp_sapling_m0/pins.c index c830f86aa8..effb33ffe0 100644 --- a/ports/atmel-samd/boards/cp_sapling_m0/pins.c +++ b/ports/atmel-samd/boards/cp_sapling_m0/pins.c @@ -35,6 +35,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_PA15) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, }; MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/atmel-samd/boards/cp_sapling_m0_revb/pins.c b/ports/atmel-samd/boards/cp_sapling_m0_revb/pins.c index 93eefbdf8f..8524648651 100644 --- a/ports/atmel-samd/boards/cp_sapling_m0_revb/pins.c +++ b/ports/atmel-samd/boards/cp_sapling_m0_revb/pins.c @@ -50,6 +50,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_PA15) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, }; diff --git a/ports/atmel-samd/boards/cp_sapling_m0_spiflash/pins.c b/ports/atmel-samd/boards/cp_sapling_m0_spiflash/pins.c index c830f86aa8..effb33ffe0 100644 --- a/ports/atmel-samd/boards/cp_sapling_m0_spiflash/pins.c +++ b/ports/atmel-samd/boards/cp_sapling_m0_spiflash/pins.c @@ -35,6 +35,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_PA15) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, }; MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/atmel-samd/boards/datum_imu/mpconfigboard.mk b/ports/atmel-samd/boards/datum_imu/mpconfigboard.mk index 9c3b642330..90076481da 100644 --- a/ports/atmel-samd/boards/datum_imu/mpconfigboard.mk +++ b/ports/atmel-samd/boards/datum_imu/mpconfigboard.mk @@ -9,3 +9,5 @@ CHIP_FAMILY = samd21 INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE CIRCUITPY_FULL_BUILD = 0 + +CIRCUITPY_ONEWIREIO = 0 diff --git a/ports/atmel-samd/boards/hallowing_m0_express/board.c b/ports/atmel-samd/boards/hallowing_m0_express/board.c index dfa60a5da6..aace060b01 100644 --- a/ports/atmel-samd/boards/hallowing_m0_express/board.c +++ b/ports/atmel-samd/boards/hallowing_m0_express/board.c @@ -71,7 +71,7 @@ uint8_t display_init_sequence[] = { void board_init(void) { displayio_fourwire_obj_t *bus = &displays[0].fourwire_bus; bus->base.type = &displayio_fourwire_type; - busio_spi_obj_t *spi = common_hal_board_create_spi(); + busio_spi_obj_t *spi = common_hal_board_create_spi(0); common_hal_busio_spi_never_reset(spi); common_hal_displayio_fourwire_construct(bus, spi, diff --git a/ports/atmel-samd/boards/hallowing_m0_express/pins.c b/ports/atmel-samd/boards/hallowing_m0_express/pins.c index 842832c392..576936a4aa 100644 --- a/ports/atmel-samd/boards/hallowing_m0_express/pins.c +++ b/ports/atmel-samd/boards/hallowing_m0_express/pins.c @@ -63,6 +63,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_ACCELEROMETER_INTERRUPT), MP_ROM_PTR(&pin_PA14) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, diff --git a/ports/atmel-samd/boards/hallowing_m4_express/pins.c b/ports/atmel-samd/boards/hallowing_m4_express/pins.c index 9c5a007be0..105206ba8e 100644 --- a/ports/atmel-samd/boards/hallowing_m4_express/pins.c +++ b/ports/atmel-samd/boards/hallowing_m4_express/pins.c @@ -67,6 +67,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_CAP_PIN), MP_ROM_PTR(&pin_PA15) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, diff --git a/ports/atmel-samd/boards/matrixportal_m4/pins.c b/ports/atmel-samd/boards/matrixportal_m4/pins.c index 09957ba682..205cd6f3c6 100644 --- a/ports/atmel-samd/boards/matrixportal_m4/pins.c +++ b/ports/atmel-samd/boards/matrixportal_m4/pins.c @@ -58,6 +58,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_L),MP_ROM_PTR(&pin_PA14) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, }; diff --git a/ports/atmel-samd/boards/monster_m4sk/pins.c b/ports/atmel-samd/boards/monster_m4sk/pins.c index 8de94e2d70..9f5369c574 100644 --- a/ports/atmel-samd/boards/monster_m4sk/pins.c +++ b/ports/atmel-samd/boards/monster_m4sk/pins.c @@ -48,6 +48,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_LEFT_TFT_DC), MP_ROM_PTR(&pin_PB22) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display)}, { MP_ROM_QSTR(MP_QSTR_RIGHT_DISPLAY), MP_ROM_PTR(&displays[0].display)} diff --git a/ports/atmel-samd/boards/openbook_m4/board.c b/ports/atmel-samd/boards/openbook_m4/board.c index 1ff83b95b7..660c514e83 100644 --- a/ports/atmel-samd/boards/openbook_m4/board.c +++ b/ports/atmel-samd/boards/openbook_m4/board.c @@ -98,7 +98,8 @@ void board_init(void) { false, // busy_state 5, // seconds_per_frame false, // chip_select (don't always toggle chip select) - false); // grayscale + false, // grayscale + false); // two_byte_sequence_length } bool board_requests_safe_mode(void) { diff --git a/ports/atmel-samd/boards/pybadge/pins.c b/ports/atmel-samd/boards/pybadge/pins.c index eb8aa81241..49a48447a6 100644 --- a/ports/atmel-samd/boards/pybadge/pins.c +++ b/ports/atmel-samd/boards/pybadge/pins.c @@ -66,6 +66,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_TFT_DC), MP_ROM_PTR(&pin_PB05) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, diff --git a/ports/atmel-samd/boards/pygamer/pins.c b/ports/atmel-samd/boards/pygamer/pins.c index f81b306a48..191f8a7c6b 100644 --- a/ports/atmel-samd/boards/pygamer/pins.c +++ b/ports/atmel-samd/boards/pygamer/pins.c @@ -71,6 +71,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_JOYSTICK_Y), MP_ROM_PTR(&pin_PB06) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, diff --git a/ports/atmel-samd/boards/pyportal/pins.c b/ports/atmel-samd/boards/pyportal/pins.c index d2c7589ee1..1fa05cc460 100644 --- a/ports/atmel-samd/boards/pyportal/pins.c +++ b/ports/atmel-samd/boards/pyportal/pins.c @@ -78,6 +78,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_SD_CARD_DETECT),MP_ROM_PTR(&pin_PA01) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display) }, diff --git a/ports/atmel-samd/boards/pyportal_titano/pins.c b/ports/atmel-samd/boards/pyportal_titano/pins.c index d2c7589ee1..1fa05cc460 100644 --- a/ports/atmel-samd/boards/pyportal_titano/pins.c +++ b/ports/atmel-samd/boards/pyportal_titano/pins.c @@ -78,6 +78,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_SD_CARD_DETECT),MP_ROM_PTR(&pin_PA01) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display) }, diff --git a/ports/atmel-samd/boards/qtpy_m0/pins.c b/ports/atmel-samd/boards/qtpy_m0/pins.c index 0796838437..477fead9ca 100644 --- a/ports/atmel-samd/boards/qtpy_m0/pins.c +++ b/ports/atmel-samd/boards/qtpy_m0/pins.c @@ -45,6 +45,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_NEOPIXEL_POWER), MP_ROM_PTR(&pin_PA15) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, }; diff --git a/ports/atmel-samd/boards/qtpy_m0_haxpress/pins.c b/ports/atmel-samd/boards/qtpy_m0_haxpress/pins.c index 0796838437..477fead9ca 100644 --- a/ports/atmel-samd/boards/qtpy_m0_haxpress/pins.c +++ b/ports/atmel-samd/boards/qtpy_m0_haxpress/pins.c @@ -45,6 +45,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_NEOPIXEL_POWER), MP_ROM_PTR(&pin_PA15) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, }; diff --git a/ports/atmel-samd/boards/seeeduino_xiao/mpconfigboard.mk b/ports/atmel-samd/boards/seeeduino_xiao/mpconfigboard.mk index d11bd0cc28..676f2bca3a 100644 --- a/ports/atmel-samd/boards/seeeduino_xiao/mpconfigboard.mk +++ b/ports/atmel-samd/boards/seeeduino_xiao/mpconfigboard.mk @@ -9,4 +9,5 @@ CHIP_FAMILY = samd21 INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE CIRCUITPY_FULL_BUILD = 0 -CIRCUITPY_ONEWIRE = 0 + +CIRCUITPY_ONEWIREIO = 0 diff --git a/ports/atmel-samd/boards/sensebox_mcu/mpconfigboard.mk b/ports/atmel-samd/boards/sensebox_mcu/mpconfigboard.mk index bdfe26068d..f59483a608 100644 --- a/ports/atmel-samd/boards/sensebox_mcu/mpconfigboard.mk +++ b/ports/atmel-samd/boards/sensebox_mcu/mpconfigboard.mk @@ -13,3 +13,4 @@ CIRCUITPY_FULL_BUILD = 0 # There are many pin definitions on this board; it doesn't quite fit on very large translations. # Remove a couple of modules. CIRCUITPY_ONEWIREIO = 0 +CIRCUITPY_RAINBOWIO = 0 diff --git a/ports/atmel-samd/boards/sparkfun_qwiic_micro_no_flash/pins.c b/ports/atmel-samd/boards/sparkfun_qwiic_micro_no_flash/pins.c index dee32d5f1a..af365cdaa3 100644 --- a/ports/atmel-samd/boards/sparkfun_qwiic_micro_no_flash/pins.c +++ b/ports/atmel-samd/boards/sparkfun_qwiic_micro_no_flash/pins.c @@ -41,7 +41,8 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { // I2C and Qwiic Connector { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PA08) }, { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PA09) }, - { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) } + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, }; MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/atmel-samd/boards/sparkfun_qwiic_micro_with_flash/pins.c b/ports/atmel-samd/boards/sparkfun_qwiic_micro_with_flash/pins.c index dee32d5f1a..af365cdaa3 100644 --- a/ports/atmel-samd/boards/sparkfun_qwiic_micro_with_flash/pins.c +++ b/ports/atmel-samd/boards/sparkfun_qwiic_micro_with_flash/pins.c @@ -41,7 +41,8 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { // I2C and Qwiic Connector { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PA08) }, { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PA09) }, - { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) } + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, }; MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/atmel-samd/boards/sparkfun_redboard_turbo/pins.c b/ports/atmel-samd/boards/sparkfun_redboard_turbo/pins.c index de81d035d8..8b321e11cf 100755 --- a/ports/atmel-samd/boards/sparkfun_redboard_turbo/pins.c +++ b/ports/atmel-samd/boards/sparkfun_redboard_turbo/pins.c @@ -44,6 +44,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PA12) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, }; diff --git a/ports/atmel-samd/boards/sparkfun_samd21_dev/mpconfigboard.mk b/ports/atmel-samd/boards/sparkfun_samd21_dev/mpconfigboard.mk index b8ac2dc256..8d1de11be7 100644 --- a/ports/atmel-samd/boards/sparkfun_samd21_dev/mpconfigboard.mk +++ b/ports/atmel-samd/boards/sparkfun_samd21_dev/mpconfigboard.mk @@ -9,3 +9,5 @@ CHIP_FAMILY = samd21 INTERNAL_FLASH_FILESYSTEM = 1 LONGINT_IMPL = NONE CIRCUITPY_FULL_BUILD = 0 + +CIRCUITPY_ONEWIREIO = 0 diff --git a/ports/atmel-samd/boards/sparkfun_samd51_thing_plus/pins.c b/ports/atmel-samd/boards/sparkfun_samd51_thing_plus/pins.c index be2b09848c..3e7a2b5548 100644 --- a/ports/atmel-samd/boards/sparkfun_samd51_thing_plus/pins.c +++ b/ports/atmel-samd/boards/sparkfun_samd51_thing_plus/pins.c @@ -33,6 +33,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_PA17) }, { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_PA17) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, }; diff --git a/ports/atmel-samd/boards/stackrduino_m0_pro/pins.c b/ports/atmel-samd/boards/stackrduino_m0_pro/pins.c index b854982500..a8162309e0 100644 --- a/ports/atmel-samd/boards/stackrduino_m0_pro/pins.c +++ b/ports/atmel-samd/boards/stackrduino_m0_pro/pins.c @@ -43,6 +43,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_CHRG_EN), MP_ROM_PTR(&pin_PA13) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, }; diff --git a/ports/atmel-samd/boards/stringcar_m0_express/mpconfigboard.mk b/ports/atmel-samd/boards/stringcar_m0_express/mpconfigboard.mk index 8821f4793a..8274c71243 100644 --- a/ports/atmel-samd/boards/stringcar_m0_express/mpconfigboard.mk +++ b/ports/atmel-samd/boards/stringcar_m0_express/mpconfigboard.mk @@ -13,5 +13,6 @@ LONGINT_IMPL = MPZ CIRCUITPY_KEYPAD = 0 CIRCUITPY_ONEWIREIO = 0 +CIRCUITPY_USB_MIDI = 0 CIRCUITPY_BITBANG_APA102 = 1 diff --git a/ports/atmel-samd/boards/trellis_m4_express/pins.c b/ports/atmel-samd/boards/trellis_m4_express/pins.c index 9668d3b0dc..61ca942ce6 100644 --- a/ports/atmel-samd/boards/trellis_m4_express/pins.c +++ b/ports/atmel-samd/boards/trellis_m4_express/pins.c @@ -45,5 +45,6 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_DOTSTAR_CLOCK), MP_ROM_PTR(&pin_PB02) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, }; MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/atmel-samd/boards/ugame10/board.c b/ports/atmel-samd/boards/ugame10/board.c index b732d259db..d75841be54 100644 --- a/ports/atmel-samd/boards/ugame10/board.c +++ b/ports/atmel-samd/boards/ugame10/board.c @@ -72,7 +72,7 @@ uint8_t display_init_sequence[] = { void board_init(void) { displayio_fourwire_obj_t *bus = &displays[0].fourwire_bus; bus->base.type = &displayio_fourwire_type; - busio_spi_obj_t *spi = common_hal_board_create_spi(); + busio_spi_obj_t *spi = common_hal_board_create_spi(0); common_hal_displayio_fourwire_construct(bus, spi, &pin_PA09, // Command or data diff --git a/ports/atmel-samd/common-hal/busio/I2C.c b/ports/atmel-samd/common-hal/busio/I2C.c index 7d77c0d43a..48ee26a9b6 100644 --- a/ports/atmel-samd/common-hal/busio/I2C.c +++ b/ports/atmel-samd/common-hal/busio/I2C.c @@ -190,7 +190,7 @@ void common_hal_busio_i2c_unlock(busio_i2c_obj_t *self) { self->has_lock = false; } -uint8_t common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t addr, +STATIC uint8_t _common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t addr, const uint8_t *data, size_t len, bool transmit_stop_bit) { uint16_t attempts = ATTEMPTS; @@ -216,6 +216,11 @@ uint8_t common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t addr, return MP_EIO; } +uint8_t common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t addr, + const uint8_t *data, size_t len) { + return _common_hal_busio_i2c_write(self, addr, data, len, true); +} + uint8_t common_hal_busio_i2c_read(busio_i2c_obj_t *self, uint16_t addr, uint8_t *data, size_t len) { @@ -242,6 +247,16 @@ uint8_t common_hal_busio_i2c_read(busio_i2c_obj_t *self, uint16_t addr, return MP_EIO; } +uint8_t common_hal_busio_i2c_write_read(busio_i2c_obj_t *self, uint16_t addr, + uint8_t *out_data, size_t out_len, uint8_t *in_data, size_t in_len) { + uint8_t result = _common_hal_busio_i2c_write(self, addr, out_data, out_len, false); + if (result != 0) { + return result; + } + + return common_hal_busio_i2c_read(self, addr, in_data, in_len); +} + void common_hal_busio_i2c_never_reset(busio_i2c_obj_t *self) { never_reset_sercom(self->i2c_desc.device.hw); diff --git a/ports/atmel-samd/common-hal/neopixel_write/__init__.c b/ports/atmel-samd/common-hal/neopixel_write/__init__.c index 754bc97fdf..182b8eee14 100644 --- a/ports/atmel-samd/common-hal/neopixel_write/__init__.c +++ b/ports/atmel-samd/common-hal/neopixel_write/__init__.c @@ -100,7 +100,7 @@ static void neopixel_send_buffer_core(volatile uint32_t *clraddr, uint32_t pinMa ""); } -uint64_t next_start_raw_ticks = 0; +STATIC uint64_t next_start_raw_ticks = 0; void common_hal_neopixel_write(const digitalio_digitalinout_obj_t *digitalinout, uint8_t *pixels, uint32_t numBytes) { // This is adapted directly from the Adafruit NeoPixel library SAMD21G18A code: diff --git a/ports/atmel-samd/mpconfigport.mk b/ports/atmel-samd/mpconfigport.mk index c4d2133c9a..f91657d0d2 100644 --- a/ports/atmel-samd/mpconfigport.mk +++ b/ports/atmel-samd/mpconfigport.mk @@ -20,6 +20,7 @@ ifeq ($(CHIP_FAMILY),samd21) # fit in 256kB of flash CIRCUITPY_AESIO ?= 0 +CIRCUITPY_ATEXIT ?= 0 CIRCUITPY_AUDIOMIXER ?= 0 CIRCUITPY_BINASCII ?= 0 CIRCUITPY_BITBANGIO ?= 0 @@ -33,6 +34,7 @@ CIRCUITPY_COUNTIO ?= 0 # Not enough RAM for framebuffers CIRCUITPY_FRAMEBUFFERIO ?= 0 CIRCUITPY_FREQUENCYIO ?= 0 +CIRCUITPY_GETPASS ?= 0 CIRCUITPY_GIFIO ?= 0 CIRCUITPY_I2CPERIPHERAL ?= 0 CIRCUITPY_JSON ?= 0 diff --git a/ports/broadcom/common-hal/busio/I2C.c b/ports/broadcom/common-hal/busio/I2C.c index 8e135ab4d7..e84810cffd 100644 --- a/ports/broadcom/common-hal/busio/I2C.c +++ b/ports/broadcom/common-hal/busio/I2C.c @@ -124,7 +124,7 @@ void common_hal_busio_i2c_deinit(busio_i2c_obj_t *self) { } bool common_hal_busio_i2c_probe(busio_i2c_obj_t *self, uint8_t addr) { - uint8_t result = common_hal_busio_i2c_write(self, addr, NULL, 0, true); + uint8_t result = common_hal_busio_i2c_write(self, addr, NULL, 0); return result == 0; } @@ -147,7 +147,7 @@ void common_hal_busio_i2c_unlock(busio_i2c_obj_t *self) { // Discussion of I2C implementation is here: https://github.com/raspberrypi/linux/issues/254 -uint8_t common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t addr, +STATIC uint8_t _common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t addr, const uint8_t *data, size_t len, bool transmit_stop_bit) { COMPLETE_MEMORY_READS; self->peripheral->S_b.DONE = true; @@ -202,6 +202,11 @@ uint8_t common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t addr, return 0; } +uint8_t common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t addr, + const uint8_t *data, size_t len) { + return _common_hal_busio_i2c_write(self, addr, data, len, true); +} + uint8_t common_hal_busio_i2c_read(busio_i2c_obj_t *self, uint16_t addr, uint8_t *data, size_t len) { COMPLETE_MEMORY_READS; @@ -247,6 +252,16 @@ uint8_t common_hal_busio_i2c_read(busio_i2c_obj_t *self, uint16_t addr, return 0; } +uint8_t common_hal_busio_i2c_write_read(busio_i2c_obj_t *self, uint16_t addr, + uint8_t *out_data, size_t out_len, uint8_t *in_data, size_t in_len) { + uint8_t result = _common_hal_busio_i2c_write(self, addr, out_data, out_len, false); + if (result != 0) { + return result; + } + + return common_hal_busio_i2c_read(self, addr, in_data, in_len); +} + void common_hal_busio_i2c_never_reset(busio_i2c_obj_t *self) { never_reset_i2c[self->index] = true; diff --git a/ports/cxd56/common-hal/busio/I2C.c b/ports/cxd56/common-hal/busio/I2C.c index 7b9420fa1b..82b52ca179 100644 --- a/ports/cxd56/common-hal/busio/I2C.c +++ b/ports/cxd56/common-hal/busio/I2C.c @@ -97,7 +97,7 @@ bool common_hal_busio_i2c_probe(busio_i2c_obj_t *self, uint8_t addr) { return I2C_TRANSFER(self->i2c_dev, &msg, 1) < 0 ? false : true; } -uint8_t common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t address, const uint8_t *data, size_t len, bool stop) { +STATIC uint8_t _common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t address, const uint8_t *data, size_t len, bool stop) { struct i2c_msg_s msg; msg.frequency = self->frequency; @@ -108,6 +108,11 @@ uint8_t common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t address, cons return -I2C_TRANSFER(self->i2c_dev, &msg, 1); } +uint8_t common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t addr, + const uint8_t *data, size_t len) { + return _common_hal_busio_i2c_write(self, addr, data, len, true); +} + uint8_t common_hal_busio_i2c_read(busio_i2c_obj_t *self, uint16_t address, uint8_t *data, size_t len) { struct i2c_msg_s msg; @@ -119,6 +124,16 @@ uint8_t common_hal_busio_i2c_read(busio_i2c_obj_t *self, uint16_t address, uint8 return -I2C_TRANSFER(self->i2c_dev, &msg, 1); } +uint8_t common_hal_busio_i2c_write_read(busio_i2c_obj_t *self, uint16_t addr, + uint8_t *out_data, size_t out_len, uint8_t *in_data, size_t in_len) { + uint8_t result = _common_hal_busio_i2c_write(self, addr, out_data, out_len, false); + if (result != 0) { + return result; + } + + return common_hal_busio_i2c_read(self, addr, in_data, in_len); +} + void common_hal_busio_i2c_never_reset(busio_i2c_obj_t *self) { never_reset_pin_number(self->scl_pin->number); never_reset_pin_number(self->sda_pin->number); diff --git a/ports/espressif/CMakeLists.txt b/ports/espressif/CMakeLists.txt index 6ad33282f8..afbb51bbad 100644 --- a/ports/espressif/CMakeLists.txt +++ b/ports/espressif/CMakeLists.txt @@ -6,7 +6,7 @@ set(ENV{IDF_PATH} ${CMAKE_SOURCE_DIR}/esp-idf) # The component list here determines what options we get in menuconfig and what the ninja file # can build. -set(COMPONENTS esptool_py soc driver log main esp-tls mbedtls esp_event esp_adc_cal esp_netif esp_wifi lwip wpa_supplicant freertos) +set(COMPONENTS esptool_py soc driver log main esp-tls mbedtls esp_event esp_adc_cal esp_netif esp_wifi lwip wpa_supplicant freertos bt) include($ENV{IDF_PATH}/tools/cmake/project.cmake) project(circuitpython) diff --git a/ports/espressif/Makefile b/ports/espressif/Makefile index 36d4726ddf..d95812ad63 100644 --- a/ports/espressif/Makefile +++ b/ports/espressif/Makefile @@ -86,6 +86,16 @@ INC += \ -isystem esp-idf \ -isystem esp-idf/components/app_update/include \ -isystem esp-idf/components/bootloader_support/include \ + -isystem esp-idf/components/bt/include/$(IDF_TARGET)/include \ + -isystem esp-idf/components/bt/host/nimble/esp-hci/include \ + -isystem esp-idf/components/bt/host/nimble/nimble/nimble/controller/include \ + -isystem esp-idf/components/bt/host/nimble/nimble/nimble/host/include \ + -isystem esp-idf/components/bt/host/nimble/nimble/nimble/host/services/gap/include \ + -isystem esp-idf/components/bt/host/nimble/nimble/nimble/include \ + -isystem esp-idf/components/bt/host/nimble/nimble/nimble/host/util/include \ + -isystem esp-idf/components/bt/host/nimble/nimble/porting/nimble/include \ + -isystem esp-idf/components/bt/host/nimble/nimble/porting/npl/freertos/include \ + -isystem esp-idf/components/bt/host/nimble/port/include \ -isystem esp-idf/components/driver/include \ -isystem esp-idf/components/driver/$(IDF_TARGET)/include \ -isystem esp-idf/components/$(IDF_TARGET)/include \ @@ -94,6 +104,7 @@ INC += \ -isystem esp-idf/components/esp_event/include \ -isystem esp-idf/components/esp_hw_support/include \ -isystem esp-idf/components/esp_hw_support/include/soc \ + -isystem esp-idf/components/esp_ipc/include \ -isystem esp-idf/components/esp_netif/include \ -isystem esp-idf/components/esp_pm/include \ -isystem esp-idf/components/esp_ringbuf/include \ @@ -132,6 +143,7 @@ endif CFLAGS += \ -DHAVE_CONFIG_H \ + -DESP_PLATFORM=1 \ -DMBEDTLS_CONFIG_FILE=\"mbedtls/esp_config.h\" \ -DUNITY_INCLUDE_CONFIG_H -DWITH_POSIX @@ -147,7 +159,12 @@ ifeq ($(DEBUG), 1) # CFLAGS += -fno-inline -fno-ipa-sra else CFLAGS += -DNDEBUG -ggdb3 - OPTIMIZATION_FLAGS ?= -O2 + ifeq ($(IDF_TARGET_ARCH),xtensa) + OPTIMIZATION_FLAGS ?= -O2 + else + # RISC-V is larger than xtensa so do -Os for it + OPTIMIZATION_FLAGS ?= -Os + endif # TODO: Test with -flto ### CFLAGS += -flto endif @@ -297,8 +314,10 @@ else DEBUG_SDKCONFIG = esp-idf-config/sdkconfig-opt.defaults endif -SDKCONFIGS = esp-idf-config/sdkconfig.defaults;$(DEBUG_SDKCONFIG);$(FLASH_SDKCONFIG);$(TARGET_SDKCONFIG);boards/$(BOARD)/sdkconfig - +SDKCONFIGS := esp-idf-config/sdkconfig.defaults;$(DEBUG_SDKCONFIG);$(FLASH_SDKCONFIG);$(TARGET_SDKCONFIG);boards/$(BOARD)/sdkconfig +ifneq ($(CIRCUITPY_BLEIO),0) + SDKCONFIGS := esp-idf-config/sdkconfig-ble.defaults;$(SDKCONFIGS) +endif # create the config headers $(BUILD)/esp-idf/config/sdkconfig.h: boards/$(BOARD)/sdkconfig | $(BUILD)/esp-idf IDF_PATH=$(IDF_PATH) cmake -S . -B $(BUILD)/esp-idf -DSDKCONFIG=$(BUILD)/esp-idf/sdkconfig -DSDKCONFIG_DEFAULTS="$(SDKCONFIGS)" -DCMAKE_TOOLCHAIN_FILE=$(IDF_PATH)/tools/cmake/toolchain-$(IDF_TARGET).cmake -DIDF_TARGET=$(IDF_TARGET) -GNinja @@ -331,6 +350,12 @@ BINARY_WIFI_BLOBS = libcoexist.a libcore.a libespnow.a libmesh.a libnet80211.a l BINARY_BLOBS = esp-idf/components/esp_phy/lib/$(IDF_TARGET)/libphy.a $(addprefix esp-idf/components/esp_wifi/lib/$(IDF_TARGET)/, $(BINARY_WIFI_BLOBS)) ESP_IDF_COMPONENTS_LINK = $(IDF_TARGET_ARCH) app_update bootloader_support driver efuse esp_adc_cal esp_common esp_event esp_hw_support esp_ipc esp_netif esp_pm esp_phy esp_ringbuf esp_rom esp_system esp_timer esp-tls esp_wifi freertos hal heap log lwip mbedtls newlib nvs_flash pthread soc spi_flash vfs wpa_supplicant +ifneq ($(CIRCUITPY_BLEIO),0) + ESP_IDF_COMPONENTS_LINK += bt + BINARY_BLOBS += esp-idf/components/esp_phy/lib/$(IDF_TARGET)/libbtbb.a \ + esp-idf/components/bt/controller/lib_esp32c3_family/$(IDF_TARGET)/libbtdm_app.a +endif + ESP_IDF_COMPONENTS_EXPANDED = $(foreach component, $(ESP_IDF_COMPONENTS_LINK), $(BUILD)/esp-idf/esp-idf/$(component)/lib$(component).a) MBEDTLS_COMPONENTS_LINK = crypto tls x509 @@ -349,6 +374,11 @@ else BOOTLOADER_OFFSET = 0x1000 endif +IDF_CMAKE_TARGETS = \ + bootloader/bootloader.bin \ + esp-idf/esp_system/__ldgen_output_sections.ld \ + $(foreach component, $(ESP_IDF_COMPONENTS_LINK), esp-idf/$(component)/lib$(component).a) + PARTITION_TABLE_OFFSET = 0x8000 FIRMWARE_OFFSET = 0x10000 @@ -366,41 +396,7 @@ endif .PHONY: esp-idf-stamp esp-idf-stamp: $(BUILD)/esp-idf/config/sdkconfig.h - $(Q)ninja -C $(BUILD)/esp-idf \ - bootloader/bootloader.bin \ - esp-idf/esp_system/__ldgen_output_sections.ld \ - esp-idf/app_update/libapp_update.a \ - esp-idf/bootloader_support/libbootloader_support.a \ - esp-idf/driver/libdriver.a \ - esp-idf/efuse/libefuse.a \ - esp-idf/esp_adc_cal/libesp_adc_cal.a \ - esp-idf/esp_common/libesp_common.a \ - esp-idf/esp_event/libesp_event.a \ - esp-idf/esp_hw_support/libesp_hw_support.a \ - esp-idf/esp_ipc/libesp_ipc.a \ - esp-idf/esp_netif/libesp_netif.a \ - esp-idf/esp_phy/libesp_phy.a \ - esp-idf/esp_pm/libesp_pm.a \ - esp-idf/esp_ringbuf/libesp_ringbuf.a \ - esp-idf/esp_rom/libesp_rom.a \ - esp-idf/esp_system/libesp_system.a \ - esp-idf/esp_timer/libesp_timer.a \ - esp-idf/esp-tls/libesp-tls.a \ - esp-idf/esp_wifi/libesp_wifi.a \ - esp-idf/freertos/libfreertos.a \ - esp-idf/hal/libhal.a \ - esp-idf/heap/libheap.a \ - esp-idf/log/liblog.a \ - esp-idf/lwip/liblwip.a \ - esp-idf/mbedtls/libmbedtls.a \ - esp-idf/newlib/libnewlib.a \ - esp-idf/nvs_flash/libnvs_flash.a \ - esp-idf/pthread/libpthread.a \ - esp-idf/soc/libsoc.a \ - esp-idf/spi_flash/libspi_flash.a \ - esp-idf/vfs/libvfs.a \ - esp-idf/wpa_supplicant/libwpa_supplicant.a \ - esp-idf/$(IDF_TARGET_ARCH)/lib$(IDF_TARGET_ARCH).a + $(Q)ninja -C $(BUILD)/esp-idf $(IDF_CMAKE_TARGETS) $(BUILD)/firmware.elf: $(OBJ) | esp-idf-stamp $(STEPECHO) "LINK $@" diff --git a/ports/espressif/README.rst b/ports/espressif/README.rst index 7ef0fc5dc6..cea95dea04 100644 --- a/ports/espressif/README.rst +++ b/ports/espressif/README.rst @@ -19,24 +19,24 @@ How this port is organized: - **bindings/** contains some required bindings to the ESP-IDF for exceptions and memory. - **boards/** contains the configuration files for each development board and breakout available on the port. - **common-hal/** contains the port-specific module implementations, used by shared-module and shared-bindings. -- **esp-idf/** contains the Espressif IoT development framework installation, including all the drivers for the port. +- **esp-idf/** contains the Espressif IoT Development Framework installation, including all the drivers for the port. - **modules/** contains information specific to certain Espressif SoC based hardware modules, such as the pins used for flash and RAM on the WROVER and WROOM. - **peripherals/** contains peripheral setup files and peripheral mapping information, sorted by family and sub-variant. Most files in this directory can be generated with the python scripts in **tools/**. - **supervisor/** contains port-specific implementations of internal flash, serial and USB, as well as the **port.c** file, which initializes the port at startup. -- **tools/** includes useful python scripts for debugging and other purposes. +- **tools/** includes useful Python scripts for debugging and other purposes. -At the root level, refer to **mpconfigboard.h** and **mpconfigport.mk** for port specific settings and a list of enabled circuitpython modules. +At the root level, refer to **mpconfigboard.h** and **mpconfigport.mk** for port specific settings and a list of enabled CircuitPython modules. Connecting to the ESP32-C3 --------------------------------------- -**USB Connetion:** +**USB Connection:** On ESP32-C3 REV3 chips, a USB Serial/JTAG Controller is available. Note: This USB connection cannot be used for a ``CIRCUITPY`` drive. Depending on the board you have, the USB port may or may not be connected to native USB. -Following connections need to be made if native USB isn't available on USB port: +The following connections need to be made if native USB isn't available on the USB port: .. csv-table:: :header: GPIO, USB @@ -50,9 +50,9 @@ Connect these pins using a `USB adapter ` **UART Connection:** -A `USB to UART convertor `_ can be used for connecting to ESP32-C3 to get serial console, REPL interface and flashing CircuitPython. +A `USB to UART convertor `_ can be used for connecting to ESP32-C3 to get access to the serial console and REPL and for flashing CircuitPython. -Following connections need to be made in this case. +The following connections need to be made in this case: .. csv-table:: :header: GPIO, UART @@ -69,11 +69,11 @@ This feature is not yet available and currently under development. Connecting to the ESP32-S2 --------------------------------------- -**USB Connetion:** +**USB Connection:** Depending on the board you have, the USB port may or may not be connected to native USB. -Following connections need to be made if native USB isn't available on USB port: +The following connections need to be made if native USB isn't available on the USB port: .. csv-table:: :header: GPIO, USB @@ -87,9 +87,9 @@ Connect these pins using a `USB adapter ` **UART Connection:** -A `USB to UART convertor `_ can be used for connecting to ESP32-S2 to get serial console and flashing CircuitPython. +A `USB to UART convertor `_ can be used for connecting to ESP32-S2 to get access to the serial console and REPL and for flashing CircuitPython. -Following connections need to be made in this case: +The following connections need to be made in this case: .. csv-table:: :header: GPIO, UART @@ -106,11 +106,11 @@ This feature isn't available on ESP32-S2. Connecting to the ESP32-S3 --------------------------------------- -**USB Connetion:** +**USB Connection:** Depending on the board you have, the USB port may or may not be connected to native USB. -Following connections need to be made if native USB isn't available on USB port: +The following connections need to be made if native USB isn't available on the USB port: .. csv-table:: :header: GPIO, USB @@ -124,9 +124,9 @@ Connect these pins using a `USB adapter ` **UART Connection:** -A `USB to UART convertor `_ can be used for connecting to ESP32-S3 to get serial console and flashing CircuitPython. +A `USB to UART convertor `_ can be used for connecting to ESP32-S3 to get access to the serial console and REPL and for flashing CircuitPython. -Following connections need to be made in this case: +The following connections need to be made in this case: .. csv-table:: :header: GPIO, UART @@ -143,9 +143,9 @@ This feature is not yet available and currently under development. Building and flashing --------------------------------------- -Before building or flashing the, you must `install the esp-idf `_. +Before building or flashing the, you must `install the ESP-IDF `_. -Note: This must be re-done every time the esp-idf is updated, but not every time you build. +Note: This must be re-done every time the ESP-IDF is updated, but not every time you build. Run ``cd ports/espressif`` from ``circuitpython/`` to move to the espressif port root, and run: @@ -153,17 +153,17 @@ Run ``cd ports/espressif`` from ``circuitpython/`` to move to the espressif port ./esp-idf/install.sh -After this initial installation, you must add the esp-idf tools to your path. +After this initial installation, you must add the ESP-IDF tools to your path. -Note: This must be re-done every time you open a new bash environment for building or flashing. +Note: This must be re-done every time you open a new shell environment for building or flashing. Run ``cd ports/espressif`` from ``circuitpython/`` to move to the espressif port root, and run: .. code-block:: - . esp-idf/export.sh + ./esp-idf/export.sh -When CircuitPython updates the ESP-IDF to a new release, you may need to run this installation process again. The exact commands used may also vary based on your bash environment. +When CircuitPython updates the ESP-IDF to a new release, you may need to run this installation process again. The exact commands used may also vary based on your shell environment. Building boards is typically done through ``make BOARD=board_id``. The default port is ``tty.SLAB_USBtoUART``, which will only work on certain Mac setups. On most machines, both Mac and Linux, you will need to set the port yourself by running ``ls /dev/tty.usb*`` and selecting the one that only appears when your development board is plugged in. An example make command with the port setting is as follows: @@ -171,7 +171,7 @@ Building boards is typically done through ``make BOARD=board_id``. The default p make BOARD=board_id PORT=/dev/tty.usbserial-1421120 flash -``board_id`` is the unique board identifier in CircuitPython. It is the same as the name of board in ``boards`` directory. +``board_id`` is the unique board identifier in CircuitPython. It is the same as the name of the board in the ``boards`` directory. Debugging --------------------------------------- @@ -180,11 +180,11 @@ TODO: Add documentation for ESP32-C3/S3 JTAG feature. The ESP32-S2 supports JTAG debugging over OpenOCD using a JLink or other probe hardware. The official tutorials can be found on the Espressif website `here `_, but they are mostly for the ESP32-S2 Kaluga, which has built-in debugging. -OpenOCD is automatically installed and added to your bash environment during the esp-idf installation and setup process. You can double check that it is installed by using ``openocd --version``, as per the tutorial. Attach the JTAG probe pins according to the `instructions for JTAG debugging `_ on boards that do not contain an integrated debugger. +OpenOCD is automatically installed and added to your bash environment during the ESP-IDF installation and setup process. You can double check that it is installed by using ``openocd --version``, as per the tutorial. Attach the JTAG probe pins according to the `instructions for JTAG debugging `_ on boards that do not contain an integrated debugger. -Once the debugger is connected physically, you must run OpenOCD with attached configuration files specifying the **interface** (your debugger probe) and either a **target** or a **board** (targets are for SoCs only, and can be used when a full board configuration file doesn't exist). You can find the path location of these files by checking the ``OPENOCD_SCRIPTS`` environmental variable by running ``echo $OPENOCD_SCRIPTS`` in bash. Interfaces will be in the ``interface/`` directory, and targets and boards in the ``target/`` and ``board/`` directories, respectively. +Once the debugger is connected physically, you must run OpenOCD with attached configuration files specifying the **interface** (your debugger probe) and either a **target** or a **board** (targets are for SoCs only, and can be used when a full board configuration file doesn't exist). You can find the location of these files by checking the ``OPENOCD_SCRIPTS`` environmental variable by running ``echo $OPENOCD_SCRIPTS``. Interfaces will be in the ``interface/`` directory, and targets and boards in the ``target/`` and ``board/`` directories, respectively. -**Note:** Unfortunately, there are no board files for the esp32-s2 other than the Kaluga, and the included ``target/esp32s2.cfg`` target file will not work by default on the Jlink for boards like the Saola 1, as the default speed is incorrect. In addition, these files are covered under the GPL and cannot be included in CircuitPython. Thus, you must make a copy of the esp32s2.cfg file yourself and add the following line manually, under ``transport select jtag`` at the start of the file: +**Note:** Unfortunately, there are no board files for the esp32-s2 other than the Kaluga, and the included ``target/esp32s2.cfg`` target file will not work by default on the JLink for boards like the Saola 1, as the default speed is incorrect. In addition, these files are covered under the GPL and cannot be included in CircuitPython. Thus, you must make a copy of the ``esp32s2.cfg`` file yourself and add the following line manually, under ``transport select jtag`` at the start of the file: .. code-block:: @@ -196,7 +196,7 @@ Once this is complete, your final OpenOCD command may look something like this: openocd -f interface/jlink.cfg -f SOMEPATH/copied-esp32s2-saola-1.cfg -Where ``SOMEPATH`` is the location of your copied configuration file (this can be placed in the port/boards directory with a prefix to ignore it with ``.gitignore``, for instance). Interface, target and board config files sourced from espressif only need their paths from the $OPENOCD_SCRIPTS location, you don't need to include their full path. Once OpenOCD is running, connect to GDB with: +Where ``SOMEPATH`` is the location of your copied configuration file (this can be placed in the ``port/boards`` directory with a prefix to ignore it with ``.gitignore``, for instance). Interface, target and board config files sourced from Espressif only need their paths from the $OPENOCD_SCRIPTS location, you don't need to include their full path. Once OpenOCD is running, connect to GDB with: .. code-block:: diff --git a/ports/espressif/boards/adafruit_esp32s2_camera/board.c b/ports/espressif/boards/adafruit_esp32s2_camera/board.c new file mode 100644 index 0000000000..e9eef0dcbc --- /dev/null +++ b/ports/espressif/boards/adafruit_esp32s2_camera/board.c @@ -0,0 +1,111 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "supervisor/board.h" +#include "mpconfigboard.h" + +#include "shared-bindings/busio/SPI.h" +#include "shared-bindings/displayio/FourWire.h" +#include "shared-bindings/microcontroller/Pin.h" +#include "shared-module/displayio/__init__.h" +#include "shared-module/displayio/mipi_constants.h" +#include "shared-bindings/board/__init__.h" + +#include "esp_log.h" + +displayio_fourwire_obj_t board_display_obj; + +#define DELAY 0x80 + +uint8_t display_init_sequence[] = { + 0x01, 0 | DELAY, 150, // SWRESET + 0x11, 0 | DELAY, 255, // SLPOUT + 0x36, 1, 0b10100000, // _MADCTL for rotation 0 + 0x3a, 1, 0x55, // COLMOD - 16bit color + 0x21, 0 | DELAY, 10, // _INVON + 0x13, 0 | DELAY, 10, // _NORON + 0x29, 0 | DELAY, 255, // _DISPON +}; + +void board_init(void) { + busio_spi_obj_t *spi = common_hal_board_create_spi(0); + displayio_fourwire_obj_t *bus = &displays[0].fourwire_bus; + bus->base.type = &displayio_fourwire_type; + common_hal_displayio_fourwire_construct(bus, + spi, + &pin_GPIO39, // TFT_DC Command or data + &pin_GPIO40, // TFT_CS Chip select + &pin_GPIO41, // TFT_RESET Reset + 5000000, // Baudrate + 0, // Polarity + 0); // Phase + + // workaround as board_init() is called before reset_port() in main.c + pwmout_reset(); + + displayio_display_obj_t *display = &displays[0].display; + display->base.type = &displayio_display_type; + common_hal_displayio_display_construct( + display, + bus, + 240, // Width (after rotation) + 240, // Height (after rotation) + 80, // column start + 0, // row start + 0, // rotation + 16, // Color depth + false, // Grayscale + false, // Pixels in a byte share a row. Only used for depth < 8 + 1, // bytes per cell. Only valid for depths < 8 + false, // reverse_pixels_in_byte. Only valid for depths < 8 + true, // reverse_pixels_in_word + MIPI_COMMAND_SET_COLUMN_ADDRESS, // Set column command + MIPI_COMMAND_SET_PAGE_ADDRESS, // Set row command + MIPI_COMMAND_WRITE_MEMORY_START, // Write memory command + display_init_sequence, + sizeof(display_init_sequence), + &pin_GPIO38, // backlight pin + NO_BRIGHTNESS_COMMAND, + 1.0f, // brightness (ignored) + true, // auto_brightness + false, // single_byte_bounds + false, // data_as_commands + true, // auto_refresh + 60, // native_frames_per_second + true, // backlight_on_high + false); // not SH1107 +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { +} + +void board_deinit(void) { + common_hal_displayio_release_displays(); +} diff --git a/ports/espressif/boards/adafruit_esp32s2_camera/mpconfigboard.h b/ports/espressif/boards/adafruit_esp32s2_camera/mpconfigboard.h new file mode 100644 index 0000000000..f7f988b861 --- /dev/null +++ b/ports/espressif/boards/adafruit_esp32s2_camera/mpconfigboard.h @@ -0,0 +1,48 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +// Micropython setup + +#define MICROPY_HW_BOARD_NAME "Adafruit Camera" +#define MICROPY_HW_MCU_NAME "ESP32S2" + +#define MICROPY_HW_NEOPIXEL (&pin_GPIO21) +#define MICROPY_HW_NEOPIXEL_COUNT (6) + +#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) + +#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") + +#define AUTORESET_DELAY_MS 500 + +#define DEFAULT_I2C_BUS_SDA (&pin_GPIO33) +#define DEFAULT_I2C_BUS_SCL (&pin_GPIO34) + +#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO35) +#define DEFAULT_SPI_BUS_SCK (&pin_GPIO36) +#define DEFAULT_SPI_BUS_MISO (&pin_GPIO37) + +#define DOUBLE_TAP_PIN (&pin_GPIO42) diff --git a/ports/espressif/boards/adafruit_esp32s2_camera/mpconfigboard.mk b/ports/espressif/boards/adafruit_esp32s2_camera/mpconfigboard.mk new file mode 100644 index 0000000000..d99a431599 --- /dev/null +++ b/ports/espressif/boards/adafruit_esp32s2_camera/mpconfigboard.mk @@ -0,0 +1,19 @@ +USB_VID = 0x239A +USB_PID = 0x8118 +USB_PRODUCT = "Camera" +USB_MANUFACTURER = "Adafruit" + +IDF_TARGET = esp32s2 + +INTERNAL_FLASH_FILESYSTEM = 1 +LONGINT_IMPL = MPZ + +# The default queue depth of 16 overflows on release builds, +# so increase it to 32. +CFLAGS += -DCFG_TUD_TASK_QUEUE_SZ=32 + +CIRCUITPY_ESP_FLASH_MODE=dio +CIRCUITPY_ESP_FLASH_FREQ=40m +CIRCUITPY_ESP_FLASH_SIZE=4MB + +CIRCUITPY_MODULE=wrover diff --git a/ports/espressif/boards/adafruit_esp32s2_camera/pins.c b/ports/espressif/boards/adafruit_esp32s2_camera/pins.c new file mode 100644 index 0000000000..63e656d4ed --- /dev/null +++ b/ports/espressif/boards/adafruit_esp32s2_camera/pins.c @@ -0,0 +1,67 @@ +#include "py/objtuple.h" +#include "shared-bindings/board/__init__.h" +#include "shared-module/displayio/__init__.h" + +STATIC const mp_rom_obj_tuple_t camera_data_tuple = { + {&mp_type_tuple}, + 8, + { + MP_ROM_PTR(&pin_GPIO13), + MP_ROM_PTR(&pin_GPIO15), + MP_ROM_PTR(&pin_GPIO16), + MP_ROM_PTR(&pin_GPIO14), + MP_ROM_PTR(&pin_GPIO12), + MP_ROM_PTR(&pin_GPIO10), + MP_ROM_PTR(&pin_GPIO9), + MP_ROM_PTR(&pin_GPIO7), + } +}; + + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + + { MP_ROM_QSTR(MP_QSTR_TFT_MOSI), MP_ROM_PTR(&pin_GPIO35) }, + { MP_ROM_QSTR(MP_QSTR_TFT_SCK), MP_ROM_PTR(&pin_GPIO36) }, + { MP_ROM_QSTR(MP_QSTR_TFT_BACKLIGHT), MP_ROM_PTR(&pin_GPIO38) }, + { MP_ROM_QSTR(MP_QSTR_TFT_DC), MP_ROM_PTR(&pin_GPIO39) }, + { MP_ROM_QSTR(MP_QSTR_TFT_CS), MP_ROM_PTR(&pin_GPIO40) }, + { MP_ROM_QSTR(MP_QSTR_TFT_RESET), MP_ROM_PTR(&pin_GPIO41) }, + + { MP_ROM_QSTR(MP_QSTR_CARD_CS), MP_ROM_PTR(&pin_GPIO4) }, + + { MP_ROM_QSTR(MP_QSTR_IRQ), MP_ROM_PTR(&pin_GPIO3) }, + + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO21) }, + + { MP_ROM_QSTR(MP_QSTR_SPEAKER), MP_ROM_PTR(&pin_GPIO45) }, + + { MP_ROM_QSTR(MP_QSTR_BUTTON), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO2) }, + + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO17) }, + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO18) }, + + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO33) }, + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO34) }, + + { MP_ROM_QSTR(MP_QSTR_CAMERA_DATA), MP_ROM_PTR(&camera_data_tuple) }, + + { MP_ROM_QSTR(MP_QSTR_CAMERA_VSYNC), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_CAMERA_HREF), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_CAMERA_DATA9), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_CAMERA_XCLK), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_CAMERA_DATA8), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_CAMERA_DATA7), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_CAMERA_PCLK), MP_ROM_PTR(&pin_GPIO11) }, + { MP_ROM_QSTR(MP_QSTR_CAMERA_DATA6), MP_ROM_PTR(&pin_GPIO12) }, + { MP_ROM_QSTR(MP_QSTR_CAMERA_DATA2), MP_ROM_PTR(&pin_GPIO13) }, + { MP_ROM_QSTR(MP_QSTR_CAMERA_DATA5), MP_ROM_PTR(&pin_GPIO14) }, + { MP_ROM_QSTR(MP_QSTR_CAMERA_DATA3), MP_ROM_PTR(&pin_GPIO15) }, + { MP_ROM_QSTR(MP_QSTR_CAMERA_DATA4), MP_ROM_PTR(&pin_GPIO16) }, + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, + { MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display)}, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/espressif/boards/adafruit_esp32s2_camera/sdkconfig b/ports/espressif/boards/adafruit_esp32s2_camera/sdkconfig new file mode 100644 index 0000000000..9d8bbde967 --- /dev/null +++ b/ports/espressif/boards/adafruit_esp32s2_camera/sdkconfig @@ -0,0 +1,33 @@ +CONFIG_ESP32S2_SPIRAM_SUPPORT=y + +# +# SPI RAM config +# +# CONFIG_SPIRAM_TYPE_AUTO is not set +CONFIG_SPIRAM_TYPE_ESPPSRAM16=y +# CONFIG_SPIRAM_TYPE_ESPPSRAM32 is not set +# CONFIG_SPIRAM_TYPE_ESPPSRAM64 is not set +CONFIG_SPIRAM_SIZE=2097152 + +# +# PSRAM clock and cs IO for ESP32S2 +# +CONFIG_DEFAULT_PSRAM_CLK_IO=30 +CONFIG_DEFAULT_PSRAM_CS_IO=26 +# end of PSRAM clock and cs IO for ESP32S2 + +# CONFIG_SPIRAM_FETCH_INSTRUCTIONS is not set +# CONFIG_SPIRAM_RODATA is not set +# CONFIG_SPIRAM_SPEED_80M is not set +CONFIG_SPIRAM_SPEED_40M=y +# CONFIG_SPIRAM_SPEED_26M is not set +# CONFIG_SPIRAM_SPEED_20M is not set +CONFIG_SPIRAM=y +CONFIG_SPIRAM_BOOT_INIT=y +# CONFIG_SPIRAM_IGNORE_NOTFOUND is not set +CONFIG_SPIRAM_USE_MEMMAP=y +# CONFIG_SPIRAM_USE_CAPS_ALLOC is not set +# CONFIG_SPIRAM_USE_MALLOC is not set +CONFIG_SPIRAM_MEMTEST=y +# CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY is not set +# end of SPI RAM config diff --git a/ports/espressif/boards/adafruit_feather_esp32s2/board.c b/ports/espressif/boards/adafruit_feather_esp32s2/board.c index 93aff5067d..8918870a8e 100644 --- a/ports/espressif/boards/adafruit_feather_esp32s2/board.c +++ b/ports/espressif/boards/adafruit_feather_esp32s2/board.c @@ -28,11 +28,14 @@ #include "mpconfigboard.h" #include "shared-bindings/microcontroller/Pin.h" #include "components/driver/include/driver/gpio.h" +#include "components/hal/include/hal/gpio_hal.h" +#include "common-hal/microcontroller/Pin.h" void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); + // Turn on I2C + common_hal_never_reset_pin(&pin_GPIO7); + gpio_set_direction(7, GPIO_MODE_DEF_OUTPUT); + gpio_set_level(7, false); } bool board_requests_safe_mode(void) { diff --git a/ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h b/ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h index fcd4a2cf60..2eb3344029 100644 --- a/ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h +++ b/ports/espressif/boards/adafruit_feather_esp32s2/mpconfigboard.h @@ -47,3 +47,5 @@ #define DEFAULT_UART_BUS_RX (&pin_GPIO38) #define DEFAULT_UART_BUS_TX (&pin_GPIO39) + +#define DOUBLE_TAP_PIN (&pin_GPIO34) diff --git a/ports/espressif/boards/adafruit_feather_esp32s2/pins.c b/ports/espressif/boards/adafruit_feather_esp32s2/pins.c index 5029d82231..c9f0e870ed 100644 --- a/ports/espressif/boards/adafruit_feather_esp32s2/pins.c +++ b/ports/espressif/boards/adafruit_feather_esp32s2/pins.c @@ -66,6 +66,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_D39), MP_ROM_PTR(&pin_GPIO39) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) } }; diff --git a/ports/espressif/boards/adafruit_feather_esp32s2_tft/board.c b/ports/espressif/boards/adafruit_feather_esp32s2_tft/board.c index 68e4171948..ce1aa4ae98 100644 --- a/ports/espressif/boards/adafruit_feather_esp32s2_tft/board.c +++ b/ports/espressif/boards/adafruit_feather_esp32s2_tft/board.c @@ -71,10 +71,6 @@ uint8_t display_init_sequence[] = { void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); - // I2C/TFT power pin common_hal_never_reset_pin(&pin_GPIO21); @@ -82,7 +78,7 @@ void board_init(void) { gpio_set_direction(21, GPIO_MODE_DEF_OUTPUT); gpio_set_level(21, true); - busio_spi_obj_t *spi = common_hal_board_create_spi(); + busio_spi_obj_t *spi = common_hal_board_create_spi(0); displayio_fourwire_obj_t *bus = &displays[0].fourwire_bus; bus->base.type = &displayio_fourwire_type; diff --git a/ports/espressif/boards/adafruit_feather_esp32s2_tft/mpconfigboard.h b/ports/espressif/boards/adafruit_feather_esp32s2_tft/mpconfigboard.h index b850b85e01..a68593a308 100644 --- a/ports/espressif/boards/adafruit_feather_esp32s2_tft/mpconfigboard.h +++ b/ports/espressif/boards/adafruit_feather_esp32s2_tft/mpconfigboard.h @@ -47,3 +47,5 @@ #define DEFAULT_UART_BUS_RX (&pin_GPIO2) #define DEFAULT_UART_BUS_TX (&pin_GPIO1) + +#define DOUBLE_TAP_PIN (&pin_GPIO38) diff --git a/ports/espressif/boards/adafruit_feather_esp32s2_tft/pins.c b/ports/espressif/boards/adafruit_feather_esp32s2_tft/pins.c index cdb2f79f8e..f3b1c30a0d 100644 --- a/ports/espressif/boards/adafruit_feather_esp32s2_tft/pins.c +++ b/ports/espressif/boards/adafruit_feather_esp32s2_tft/pins.c @@ -69,6 +69,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_BOOT0), MP_ROM_PTR(&pin_GPIO0) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, diff --git a/ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/board.c b/ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/board.c index 943d91feda..71b381616f 100644 --- a/ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/board.c +++ b/ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/board.c @@ -50,10 +50,6 @@ uint8_t display_init_sequence[] = { */ void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); - // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO43); diff --git a/ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h b/ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h index d2cd01a681..9c759ac1ca 100644 --- a/ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h +++ b/ports/espressif/boards/adafruit_feather_esp32s2_tftback_nopsram/mpconfigboard.h @@ -44,3 +44,5 @@ #define DEFAULT_SPI_BUS_SCK (&pin_GPIO36) #define DEFAULT_SPI_BUS_MOSI (&pin_GPIO35) #define DEFAULT_SPI_BUS_MISO (&pin_GPIO37) + +#define DOUBLE_TAP_PIN (&pin_GPIO34) diff --git a/ports/espressif/boards/adafruit_funhouse/board.c b/ports/espressif/boards/adafruit_funhouse/board.c index a4a1d07947..34e74c45f9 100644 --- a/ports/espressif/boards/adafruit_funhouse/board.c +++ b/ports/espressif/boards/adafruit_funhouse/board.c @@ -50,10 +50,6 @@ uint8_t display_init_sequence[] = { }; void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); - // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO37); diff --git a/ports/espressif/boards/adafruit_funhouse/mpconfigboard.h b/ports/espressif/boards/adafruit_funhouse/mpconfigboard.h index 6379147c30..a268020b7c 100644 --- a/ports/espressif/boards/adafruit_funhouse/mpconfigboard.h +++ b/ports/espressif/boards/adafruit_funhouse/mpconfigboard.h @@ -41,3 +41,5 @@ #define DEFAULT_I2C_BUS_SCL (&pin_GPIO33) #define DEFAULT_I2C_BUS_SDA (&pin_GPIO34) + +#define DOUBLE_TAP_PIN (&pin_GPIO38) diff --git a/ports/espressif/boards/adafruit_funhouse/pins.c b/ports/espressif/boards/adafruit_funhouse/pins.c index 1904150f35..17c2ac4256 100644 --- a/ports/espressif/boards/adafruit_funhouse/pins.c +++ b/ports/espressif/boards/adafruit_funhouse/pins.c @@ -48,6 +48,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_DEBUG_RX), MP_ROM_PTR(&pin_GPIO38) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display)}, }; MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/espressif/boards/adafruit_magtag_2.9_grayscale/board.c b/ports/espressif/boards/adafruit_magtag_2.9_grayscale/board.c index 020e6f6a1f..56564e375e 100644 --- a/ports/espressif/boards/adafruit_magtag_2.9_grayscale/board.c +++ b/ports/espressif/boards/adafruit_magtag_2.9_grayscale/board.c @@ -110,10 +110,6 @@ const uint8_t display_stop_sequence[] = { }; void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); - // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO43); @@ -164,7 +160,8 @@ void board_init(void) { false, // busy_state 5.0, // seconds_per_frame false, // always_toggle_chip_select - true); // grayscale + true, // grayscale + false); // two_byte_sequence_length } bool board_requests_safe_mode(void) { diff --git a/ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h b/ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h index 343bb525f1..ad81cc2ca7 100644 --- a/ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h +++ b/ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h @@ -42,3 +42,5 @@ #define DEFAULT_I2C_BUS_SCL (&pin_GPIO34) #define DEFAULT_I2C_BUS_SDA (&pin_GPIO33) + +#define DOUBLE_TAP_PIN (&pin_GPIO38) diff --git a/ports/espressif/boards/adafruit_magtag_2.9_grayscale/pins.c b/ports/espressif/boards/adafruit_magtag_2.9_grayscale/pins.c index 79b1feb40c..2aa2b11b06 100644 --- a/ports/espressif/boards/adafruit_magtag_2.9_grayscale/pins.c +++ b/ports/espressif/boards/adafruit_magtag_2.9_grayscale/pins.c @@ -53,6 +53,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_GPIO1) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].epaper_display)}, diff --git a/ports/espressif/boards/adafruit_metro_esp32s2/board.c b/ports/espressif/boards/adafruit_metro_esp32s2/board.c index 5abd1ce1b3..6772768da5 100644 --- a/ports/espressif/boards/adafruit_metro_esp32s2/board.c +++ b/ports/espressif/boards/adafruit_metro_esp32s2/board.c @@ -29,9 +29,6 @@ #include "shared-bindings/microcontroller/Pin.h" void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); } bool board_requests_safe_mode(void) { diff --git a/ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h b/ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h index ec992383aa..51d93224a4 100644 --- a/ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h +++ b/ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h @@ -46,3 +46,5 @@ #define DEFAULT_UART_BUS_RX (&pin_GPIO5) #define DEFAULT_UART_BUS_TX (&pin_GPIO6) + +#define DOUBLE_TAP_PIN (&pin_GPIO38) diff --git a/ports/espressif/boards/adafruit_metro_esp32s2/pins.c b/ports/espressif/boards/adafruit_metro_esp32s2/pins.c index 4c393b4f85..0d2777b204 100644 --- a/ports/espressif/boards/adafruit_metro_esp32s2/pins.c +++ b/ports/espressif/boards/adafruit_metro_esp32s2/pins.c @@ -64,6 +64,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_DEBUG_TX), MP_ROM_PTR(&pin_GPIO37) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, }; diff --git a/ports/espressif/boards/adafruit_qtpy_esp32s2/board.c b/ports/espressif/boards/adafruit_qtpy_esp32s2/board.c index 5abd1ce1b3..6772768da5 100644 --- a/ports/espressif/boards/adafruit_qtpy_esp32s2/board.c +++ b/ports/espressif/boards/adafruit_qtpy_esp32s2/board.c @@ -29,9 +29,6 @@ #include "shared-bindings/microcontroller/Pin.h" void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); } bool board_requests_safe_mode(void) { diff --git a/ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h b/ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h index dd8b1a2ac8..7ae713c4bb 100644 --- a/ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h +++ b/ports/espressif/boards/adafruit_qtpy_esp32s2/mpconfigboard.h @@ -38,12 +38,17 @@ #define AUTORESET_DELAY_MS 500 -#define DEFAULT_I2C_BUS_SCL (&pin_GPIO6) -#define DEFAULT_I2C_BUS_SDA (&pin_GPIO7) +#define CIRCUITPY_BOARD_I2C (2) +#define CIRCUITPY_BOARD_I2C_PIN {{.scl = &pin_GPIO6, .sda = &pin_GPIO7}, \ + {.scl = &pin_GPIO40, .sda = &pin_GPIO41}} -#define DEFAULT_SPI_BUS_SCK (&pin_GPIO36) -#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO35) -#define DEFAULT_SPI_BUS_MISO (&pin_GPIO37) +#define CIRCUITPY_BOARD_SPI (1) +#define CIRCUITPY_BOARD_SPI_PIN {{.clock = &pin_GPIO36, .mosi = &pin_GPIO35, .miso = &pin_GPIO37}} -#define DEFAULT_UART_BUS_RX (&pin_GPIO16) -#define DEFAULT_UART_BUS_TX (&pin_GPIO5) +#define CIRCUITPY_BOARD_UART (1) +#define CIRCUITPY_BOARD_UART_PIN {{.tx = &pin_GPIO5, .rx = &pin_GPIO16}} + +#define DOUBLE_TAP_PIN (&pin_GPIO10) + +#define DEBUG_UART_RX (&pin_GPIO16) +#define DEBUG_UART_TX (&pin_GPIO5) diff --git a/ports/espressif/boards/adafruit_qtpy_esp32s2/pins.c b/ports/espressif/boards/adafruit_qtpy_esp32s2/pins.c index 67bc486170..a1d1b7b50f 100644 --- a/ports/espressif/boards/adafruit_qtpy_esp32s2/pins.c +++ b/ports/espressif/boards/adafruit_qtpy_esp32s2/pins.c @@ -1,5 +1,7 @@ #include "shared-bindings/board/__init__.h" +CIRCUITPY_BOARD_BUS_SINGLETON(stemma_i2c, i2c, 1) + STATIC const mp_rom_map_elem_t board_module_globals_table[] = { CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS @@ -25,7 +27,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO6) }, { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_GPIO6) }, - { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_GPIO6) }, { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO5) }, { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_GPIO5) }, @@ -54,7 +56,8 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_D41), MP_ROM_PTR(&pin_GPIO41) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_stemma_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, - { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) } + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, }; MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/board.c b/ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/board.c new file mode 100644 index 0000000000..ff9418ec86 --- /dev/null +++ b/ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/board.c @@ -0,0 +1,48 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "supervisor/board.h" +#include "mpconfigboard.h" +#include "shared-bindings/microcontroller/Pin.h" + +void board_init(void) { + // Debug UART + #ifdef DEBUG + common_hal_never_reset_pin(&pin_GPIO43); + common_hal_never_reset_pin(&pin_GPIO44); + #endif +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { + +} + +void board_deinit(void) { +} diff --git a/ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.h b/ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.h new file mode 100644 index 0000000000..68a2a482f3 --- /dev/null +++ b/ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.h @@ -0,0 +1,51 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +// Micropython setup + +#define MICROPY_HW_BOARD_NAME "Adafruit QT Py ESP32-S3 no psram" +#define MICROPY_HW_MCU_NAME "ESP32S3" + +#define MICROPY_HW_NEOPIXEL (&pin_GPIO38) +#define CIRCUITPY_STATUS_LED_POWER (&pin_GPIO37) + +#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) + +#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") + +#define AUTORESET_DELAY_MS 500 + +#define CIRCUITPY_BOARD_I2C (2) +#define CIRCUITPY_BOARD_I2C_PIN {{.scl = &pin_GPIO6, .sda = &pin_GPIO7}, \ + {.scl = &pin_GPIO40, .sda = &pin_GPIO41}} + +#define CIRCUITPY_BOARD_SPI (1) +#define CIRCUITPY_BOARD_SPI_PIN {{.clock = &pin_GPIO35, .mosi = &pin_GPIO34, .miso = &pin_GPIO36}} + +#define CIRCUITPY_BOARD_UART (1) +#define CIRCUITPY_BOARD_UART_PIN {{.tx = &pin_GPIO5, .rx = &pin_GPIO16}} + +#define DOUBLE_TAP_PIN (&pin_GPIO10) diff --git a/ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.mk b/ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.mk new file mode 100644 index 0000000000..1156b1b915 --- /dev/null +++ b/ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/mpconfigboard.mk @@ -0,0 +1,23 @@ +USB_VID = 0x239A +USB_PID = 0x811A + +USB_PRODUCT = "QT Py ESP32S3 no psram" +USB_MANUFACTURER = "Adafruit" + +IDF_TARGET = esp32s3 + +INTERNAL_FLASH_FILESYSTEM = 1 +LONGINT_IMPL = MPZ + +# The default queue depth of 16 overflows on release builds, +# so increase it to 32. +CFLAGS += -DCFG_TUD_TASK_QUEUE_SZ=32 + +CIRCUITPY_ESP_FLASH_MODE=dio +CIRCUITPY_ESP_FLASH_FREQ=80m +CIRCUITPY_ESP_FLASH_SIZE=8MB + +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Requests +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_BusDevice +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Register diff --git a/ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/pins.c b/ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/pins.c new file mode 100644 index 0000000000..c0386232a8 --- /dev/null +++ b/ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/pins.c @@ -0,0 +1,62 @@ +#include "shared-bindings/board/__init__.h" + +CIRCUITPY_BOARD_BUS_SINGLETON(stemma_i2c, i2c, 1) + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + + { MP_ROM_QSTR(MP_QSTR_BUTTON), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_GPIO0) }, + + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_D18), MP_ROM_PTR(&pin_GPIO18) }, + + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO17) }, + { MP_ROM_QSTR(MP_QSTR_D17), MP_ROM_PTR(&pin_GPIO17) }, + + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_GPIO9) }, + + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_GPIO8) }, + + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_GPIO7) }, + + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_GPIO6) }, + + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_A6), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_GPIO5) }, + + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO16) }, + { MP_ROM_QSTR(MP_QSTR_A7), MP_ROM_PTR(&pin_GPIO16) }, + { MP_ROM_QSTR(MP_QSTR_D16), MP_ROM_PTR(&pin_GPIO16) }, + + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO34) }, + { MP_ROM_QSTR(MP_QSTR_D34), MP_ROM_PTR(&pin_GPIO34) }, + + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO35) }, + { MP_ROM_QSTR(MP_QSTR_D35), MP_ROM_PTR(&pin_GPIO35) }, + + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO36) }, + { MP_ROM_QSTR(MP_QSTR_D36), MP_ROM_PTR(&pin_GPIO36) }, + + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL_POWER), MP_ROM_PTR(&pin_GPIO37) }, + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO38) }, + + { MP_ROM_QSTR(MP_QSTR_SCL1), MP_ROM_PTR(&pin_GPIO40) }, + { MP_ROM_QSTR(MP_QSTR_D40), MP_ROM_PTR(&pin_GPIO40) }, + + { MP_ROM_QSTR(MP_QSTR_SDA1), MP_ROM_PTR(&pin_GPIO41) }, + { MP_ROM_QSTR(MP_QSTR_D41), MP_ROM_PTR(&pin_GPIO41) }, + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_stemma_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/sdkconfig b/ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/sdkconfig new file mode 100644 index 0000000000..a162344cfb --- /dev/null +++ b/ports/espressif/boards/adafruit_qtpy_esp32s3_nopsram/sdkconfig @@ -0,0 +1,8 @@ +CONFIG_ESP32S3_SPIRAM_SUPPORT=n + +# +# LWIP +# +CONFIG_LWIP_LOCAL_HOSTNAME="espressif-esp32s3" +# end of LWIP + diff --git a/ports/espressif/boards/ai_thinker_esp32-c3s/board.c b/ports/espressif/boards/ai_thinker_esp32-c3s/board.c index 83ef690007..f9cb98aa8f 100644 --- a/ports/espressif/boards/ai_thinker_esp32-c3s/board.c +++ b/ports/espressif/boards/ai_thinker_esp32-c3s/board.c @@ -29,21 +29,11 @@ #include "supervisor/board.h" void board_init(void) { - // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO20); common_hal_never_reset_pin(&pin_GPIO21); #endif - - // SPI Flash - common_hal_never_reset_pin(&pin_GPIO11); - common_hal_never_reset_pin(&pin_GPIO12); - common_hal_never_reset_pin(&pin_GPIO13); - common_hal_never_reset_pin(&pin_GPIO14); - common_hal_never_reset_pin(&pin_GPIO15); - common_hal_never_reset_pin(&pin_GPIO16); - common_hal_never_reset_pin(&pin_GPIO17); } bool board_requests_safe_mode(void) { diff --git a/ports/espressif/boards/ai_thinker_esp_12k_nodemcu/board.c b/ports/espressif/boards/ai_thinker_esp_12k_nodemcu/board.c index e40b6335bc..0432485111 100644 --- a/ports/espressif/boards/ai_thinker_esp_12k_nodemcu/board.c +++ b/ports/espressif/boards/ai_thinker_esp_12k_nodemcu/board.c @@ -29,10 +29,6 @@ #include "shared-bindings/microcontroller/Pin.h" void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); - // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO43); diff --git a/ports/espressif/boards/artisense_rd00/board.c b/ports/espressif/boards/artisense_rd00/board.c index 2b18dd7592..ea363f6b54 100644 --- a/ports/espressif/boards/artisense_rd00/board.c +++ b/ports/espressif/boards/artisense_rd00/board.c @@ -29,10 +29,6 @@ #include "shared-bindings/microcontroller/Pin.h" void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); - // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO43); @@ -42,9 +38,6 @@ void board_init(void) { // Crystal common_hal_never_reset_pin(&pin_GPIO15); common_hal_never_reset_pin(&pin_GPIO16); - - // PSRAM - common_hal_never_reset_pin(&pin_GPIO26); } bool board_requests_safe_mode(void) { diff --git a/ports/espressif/boards/atmegazero_esp32s2/board.c b/ports/espressif/boards/atmegazero_esp32s2/board.c index a0e399b1ef..0432485111 100644 --- a/ports/espressif/boards/atmegazero_esp32s2/board.c +++ b/ports/espressif/boards/atmegazero_esp32s2/board.c @@ -29,24 +29,11 @@ #include "shared-bindings/microcontroller/Pin.h" void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); - // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO43); common_hal_never_reset_pin(&pin_GPIO44); #endif /* DEBUG */ - - // SPI Flash and RAM - common_hal_never_reset_pin(&pin_GPIO26); - common_hal_never_reset_pin(&pin_GPIO27); - common_hal_never_reset_pin(&pin_GPIO28); - common_hal_never_reset_pin(&pin_GPIO29); - common_hal_never_reset_pin(&pin_GPIO30); - common_hal_never_reset_pin(&pin_GPIO31); - common_hal_never_reset_pin(&pin_GPIO32); } bool board_requests_safe_mode(void) { diff --git a/ports/espressif/boards/crumpspace_crumps2/board.c b/ports/espressif/boards/crumpspace_crumps2/board.c index e40b6335bc..0432485111 100644 --- a/ports/espressif/boards/crumpspace_crumps2/board.c +++ b/ports/espressif/boards/crumpspace_crumps2/board.c @@ -29,10 +29,6 @@ #include "shared-bindings/microcontroller/Pin.h" void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); - // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO43); diff --git a/ports/espressif/boards/electroniccats_bastwifi/board.c b/ports/espressif/boards/electroniccats_bastwifi/board.c index e40b6335bc..0432485111 100644 --- a/ports/espressif/boards/electroniccats_bastwifi/board.c +++ b/ports/espressif/boards/electroniccats_bastwifi/board.c @@ -29,10 +29,6 @@ #include "shared-bindings/microcontroller/Pin.h" void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); - // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO43); diff --git a/ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/board.c b/ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/board.c new file mode 100644 index 0000000000..e3b71f4832 --- /dev/null +++ b/ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/board.c @@ -0,0 +1,48 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 microDev + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "shared-bindings/microcontroller/Pin.h" +#include "supervisor/board.h" + +void board_init(void) { + // Debug UART + #ifdef DEBUG + common_hal_never_reset_pin(&pin_GPIO20); + common_hal_never_reset_pin(&pin_GPIO21); + #endif +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { +} + +#if CIRCUITPY_ALARM +void board_deinit(void) { +} +#endif diff --git a/ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.h b/ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.h new file mode 100644 index 0000000000..28c2ea11eb --- /dev/null +++ b/ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.h @@ -0,0 +1,47 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 microDev + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +// Board setup +#define MICROPY_HW_BOARD_NAME "ESP32-C3-DevKitM-1" +#define MICROPY_HW_MCU_NAME "ESP32-C3N4" + +// Status LED +#define MICROPY_HW_NEOPIXEL (&pin_GPIO8) +#define MICROPY_HW_NEOPIXEL_COUNT (1) + +// Default bus pins +#define DEFAULT_UART_BUS_RX (&pin_GPIO20) +#define DEFAULT_UART_BUS_TX (&pin_GPIO21) + +// Serial over UART +#define DEBUG_UART_RX DEFAULT_UART_BUS_RX +#define DEBUG_UART_TX DEFAULT_UART_BUS_TX + +// For entering safe mode +#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO2) + +// Explanation of how a user got into safe mode +#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") diff --git a/ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.mk b/ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.mk new file mode 100644 index 0000000000..b952dacef7 --- /dev/null +++ b/ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/mpconfigboard.mk @@ -0,0 +1,10 @@ +CIRCUITPY_CREATOR_ID = 0x000C303A +CIRCUITPY_CREATION_ID = 0x00C30001 + +IDF_TARGET = esp32c3 + +INTERNAL_FLASH_FILESYSTEM = 1 + +CIRCUITPY_ESP_FLASH_MODE=dio +CIRCUITPY_ESP_FLASH_FREQ=80m +CIRCUITPY_ESP_FLASH_SIZE=4MB diff --git a/ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/pins.c b/ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/pins.c new file mode 100644 index 0000000000..e948ae3fc8 --- /dev/null +++ b/ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/pins.c @@ -0,0 +1,61 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 microDev + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + + { MP_ROM_QSTR(MP_QSTR_IO0), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_IO1), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_IO2), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_IO3), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_IO4), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_IO5), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_IO6), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_IO7), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_IO8), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_IO9), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_IO10), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_IO18), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_IO19), MP_ROM_PTR(&pin_GPIO19) }, + { MP_ROM_QSTR(MP_QSTR_IO20), MP_ROM_PTR(&pin_GPIO20) }, + { MP_ROM_QSTR(MP_QSTR_IO21), MP_ROM_PTR(&pin_GPIO21) }, + + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO20) }, + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO21) }, + + { MP_ROM_QSTR(MP_QSTR_MTMS), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_MTDI), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_MTCK), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_MTDO), MP_ROM_PTR(&pin_GPIO7) }, + + { MP_ROM_QSTR(MP_QSTR_BUTTON), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO8) }, + + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/sdkconfig b/ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/sdkconfig new file mode 100644 index 0000000000..0e24f8dc77 --- /dev/null +++ b/ports/espressif/boards/espressif_esp32c3_devkitm_1_n4/sdkconfig @@ -0,0 +1,5 @@ +# +# LWIP +# +CONFIG_LWIP_LOCAL_HOSTNAME="ESP32-C3-DevKitM-1" +# end of LWIP diff --git a/ports/espressif/boards/espressif_esp32s3_box/board.c b/ports/espressif/boards/espressif_esp32s3_box/board.c index c425c5c24e..ad76c60ddd 100644 --- a/ports/espressif/boards/espressif_esp32s3_box/board.c +++ b/ports/espressif/boards/espressif_esp32s3_box/board.c @@ -90,29 +90,11 @@ void board_init(void) { true, // backlight_on_high false); // SH1107_addressing - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); - // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO43); common_hal_never_reset_pin(&pin_GPIO44); #endif - - // SPI Flash and RAM - common_hal_never_reset_pin(&pin_GPIO26); - common_hal_never_reset_pin(&pin_GPIO27); - common_hal_never_reset_pin(&pin_GPIO28); - common_hal_never_reset_pin(&pin_GPIO29); - common_hal_never_reset_pin(&pin_GPIO30); - common_hal_never_reset_pin(&pin_GPIO31); - common_hal_never_reset_pin(&pin_GPIO32); - common_hal_never_reset_pin(&pin_GPIO33); - common_hal_never_reset_pin(&pin_GPIO34); - common_hal_never_reset_pin(&pin_GPIO35); - common_hal_never_reset_pin(&pin_GPIO36); - common_hal_never_reset_pin(&pin_GPIO37); } bool board_requests_safe_mode(void) { diff --git a/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/board.c b/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/board.c index dd24db581b..ff9418ec86 100644 --- a/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/board.c +++ b/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/board.c @@ -29,24 +29,11 @@ #include "shared-bindings/microcontroller/Pin.h" void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); - // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO43); common_hal_never_reset_pin(&pin_GPIO44); #endif - - // SPI Flash and RAM - common_hal_never_reset_pin(&pin_GPIO26); - common_hal_never_reset_pin(&pin_GPIO27); - common_hal_never_reset_pin(&pin_GPIO28); - common_hal_never_reset_pin(&pin_GPIO29); - common_hal_never_reset_pin(&pin_GPIO30); - common_hal_never_reset_pin(&pin_GPIO31); - common_hal_never_reset_pin(&pin_GPIO32); } bool board_requests_safe_mode(void) { diff --git a/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h b/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h index b13ccd1ffe..4c584e96cd 100644 --- a/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h +++ b/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/mpconfigboard.h @@ -29,10 +29,13 @@ #define MICROPY_HW_BOARD_NAME "ESP32-S3-DevKitC-1-N8" #define MICROPY_HW_MCU_NAME "ESP32S3" -#define MICROPY_HW_NEOPIXEL (&pin_GPIO48) +#define MICROPY_HW_NEOPIXEL (&pin_GPIO48) -#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) +#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) + +#define DEFAULT_UART_BUS_RX (&pin_GPIO44) +#define DEFAULT_UART_BUS_TX (&pin_GPIO43) #define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") -#define AUTORESET_DELAY_MS 500 +#define AUTORESET_DELAY_MS 500 diff --git a/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/pins.c b/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/pins.c index b1d515c306..919deca8b4 100644 --- a/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/pins.c +++ b/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8/pins.c @@ -30,16 +30,20 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_IO37), MP_ROM_PTR(&pin_GPIO37) }, { MP_ROM_QSTR(MP_QSTR_IO38), MP_ROM_PTR(&pin_GPIO38) }, { MP_ROM_QSTR(MP_QSTR_IO39), MP_ROM_PTR(&pin_GPIO39) }, + { MP_ROM_QSTR(MP_QSTR_IO40), MP_ROM_PTR(&pin_GPIO40) }, { MP_ROM_QSTR(MP_QSTR_IO41), MP_ROM_PTR(&pin_GPIO41) }, { MP_ROM_QSTR(MP_QSTR_IO42), MP_ROM_PTR(&pin_GPIO42) }, { MP_ROM_QSTR(MP_QSTR_IO43), MP_ROM_PTR(&pin_GPIO43) }, - { MP_ROM_QSTR(MP_QSTR_TXD0), MP_ROM_PTR(&pin_GPIO43) }, { MP_ROM_QSTR(MP_QSTR_IO44), MP_ROM_PTR(&pin_GPIO44) }, - { MP_ROM_QSTR(MP_QSTR_TXD1), MP_ROM_PTR(&pin_GPIO44) }, { MP_ROM_QSTR(MP_QSTR_IO45), MP_ROM_PTR(&pin_GPIO45) }, { MP_ROM_QSTR(MP_QSTR_IO46), MP_ROM_PTR(&pin_GPIO46) }, { MP_ROM_QSTR(MP_QSTR_IO47), MP_ROM_PTR(&pin_GPIO47) }, { MP_ROM_QSTR(MP_QSTR_IO48), MP_ROM_PTR(&pin_GPIO48) }, { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO48) }, + + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO43) }, + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO44) }, + + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, }; MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/board.c b/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/board.c index dd24db581b..ff9418ec86 100644 --- a/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/board.c +++ b/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/board.c @@ -29,24 +29,11 @@ #include "shared-bindings/microcontroller/Pin.h" void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); - // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO43); common_hal_never_reset_pin(&pin_GPIO44); #endif - - // SPI Flash and RAM - common_hal_never_reset_pin(&pin_GPIO26); - common_hal_never_reset_pin(&pin_GPIO27); - common_hal_never_reset_pin(&pin_GPIO28); - common_hal_never_reset_pin(&pin_GPIO29); - common_hal_never_reset_pin(&pin_GPIO30); - common_hal_never_reset_pin(&pin_GPIO31); - common_hal_never_reset_pin(&pin_GPIO32); } bool board_requests_safe_mode(void) { diff --git a/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h b/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h index 514ca2e2bc..eb6cae949f 100644 --- a/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h +++ b/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/mpconfigboard.h @@ -29,10 +29,13 @@ #define MICROPY_HW_BOARD_NAME "ESP32-S3-DevKitC-1-N8R2" #define MICROPY_HW_MCU_NAME "ESP32S3" -#define MICROPY_HW_NEOPIXEL (&pin_GPIO48) +#define MICROPY_HW_NEOPIXEL (&pin_GPIO48) -#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) +#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) + +#define DEFAULT_UART_BUS_RX (&pin_GPIO44) +#define DEFAULT_UART_BUS_TX (&pin_GPIO43) #define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") -#define AUTORESET_DELAY_MS 500 +#define AUTORESET_DELAY_MS 500 diff --git a/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/pins.c b/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/pins.c index b1d515c306..919deca8b4 100644 --- a/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/pins.c +++ b/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r2/pins.c @@ -30,16 +30,20 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_IO37), MP_ROM_PTR(&pin_GPIO37) }, { MP_ROM_QSTR(MP_QSTR_IO38), MP_ROM_PTR(&pin_GPIO38) }, { MP_ROM_QSTR(MP_QSTR_IO39), MP_ROM_PTR(&pin_GPIO39) }, + { MP_ROM_QSTR(MP_QSTR_IO40), MP_ROM_PTR(&pin_GPIO40) }, { MP_ROM_QSTR(MP_QSTR_IO41), MP_ROM_PTR(&pin_GPIO41) }, { MP_ROM_QSTR(MP_QSTR_IO42), MP_ROM_PTR(&pin_GPIO42) }, { MP_ROM_QSTR(MP_QSTR_IO43), MP_ROM_PTR(&pin_GPIO43) }, - { MP_ROM_QSTR(MP_QSTR_TXD0), MP_ROM_PTR(&pin_GPIO43) }, { MP_ROM_QSTR(MP_QSTR_IO44), MP_ROM_PTR(&pin_GPIO44) }, - { MP_ROM_QSTR(MP_QSTR_TXD1), MP_ROM_PTR(&pin_GPIO44) }, { MP_ROM_QSTR(MP_QSTR_IO45), MP_ROM_PTR(&pin_GPIO45) }, { MP_ROM_QSTR(MP_QSTR_IO46), MP_ROM_PTR(&pin_GPIO46) }, { MP_ROM_QSTR(MP_QSTR_IO47), MP_ROM_PTR(&pin_GPIO47) }, { MP_ROM_QSTR(MP_QSTR_IO48), MP_ROM_PTR(&pin_GPIO48) }, { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO48) }, + + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO43) }, + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO44) }, + + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, }; MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/board.c b/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/board.c index b9558bfbdf..ff9418ec86 100644 --- a/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/board.c +++ b/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/board.c @@ -29,30 +29,11 @@ #include "shared-bindings/microcontroller/Pin.h" void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); - // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO43); common_hal_never_reset_pin(&pin_GPIO44); #endif - - - // SPI Flash and RAM - common_hal_never_reset_pin(&pin_GPIO26); - common_hal_never_reset_pin(&pin_GPIO27); - common_hal_never_reset_pin(&pin_GPIO28); - common_hal_never_reset_pin(&pin_GPIO29); - common_hal_never_reset_pin(&pin_GPIO30); - common_hal_never_reset_pin(&pin_GPIO31); - common_hal_never_reset_pin(&pin_GPIO32); - common_hal_never_reset_pin(&pin_GPIO33); - common_hal_never_reset_pin(&pin_GPIO34); - common_hal_never_reset_pin(&pin_GPIO35); - common_hal_never_reset_pin(&pin_GPIO36); - common_hal_never_reset_pin(&pin_GPIO37); } bool board_requests_safe_mode(void) { diff --git a/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h b/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h index 45fd3268b2..f3a2941655 100644 --- a/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h +++ b/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/mpconfigboard.h @@ -29,10 +29,13 @@ #define MICROPY_HW_BOARD_NAME "ESP32-S3-DevKitC-1-N8R8" #define MICROPY_HW_MCU_NAME "ESP32S3" -#define MICROPY_HW_NEOPIXEL (&pin_GPIO48) +#define MICROPY_HW_NEOPIXEL (&pin_GPIO48) -#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) +#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) + +#define DEFAULT_UART_BUS_RX (&pin_GPIO44) +#define DEFAULT_UART_BUS_TX (&pin_GPIO43) #define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") -#define AUTORESET_DELAY_MS 500 +#define AUTORESET_DELAY_MS 500 diff --git a/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/pins.c b/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/pins.c index b1d515c306..919deca8b4 100644 --- a/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/pins.c +++ b/ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8/pins.c @@ -30,16 +30,20 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_IO37), MP_ROM_PTR(&pin_GPIO37) }, { MP_ROM_QSTR(MP_QSTR_IO38), MP_ROM_PTR(&pin_GPIO38) }, { MP_ROM_QSTR(MP_QSTR_IO39), MP_ROM_PTR(&pin_GPIO39) }, + { MP_ROM_QSTR(MP_QSTR_IO40), MP_ROM_PTR(&pin_GPIO40) }, { MP_ROM_QSTR(MP_QSTR_IO41), MP_ROM_PTR(&pin_GPIO41) }, { MP_ROM_QSTR(MP_QSTR_IO42), MP_ROM_PTR(&pin_GPIO42) }, { MP_ROM_QSTR(MP_QSTR_IO43), MP_ROM_PTR(&pin_GPIO43) }, - { MP_ROM_QSTR(MP_QSTR_TXD0), MP_ROM_PTR(&pin_GPIO43) }, { MP_ROM_QSTR(MP_QSTR_IO44), MP_ROM_PTR(&pin_GPIO44) }, - { MP_ROM_QSTR(MP_QSTR_TXD1), MP_ROM_PTR(&pin_GPIO44) }, { MP_ROM_QSTR(MP_QSTR_IO45), MP_ROM_PTR(&pin_GPIO45) }, { MP_ROM_QSTR(MP_QSTR_IO46), MP_ROM_PTR(&pin_GPIO46) }, { MP_ROM_QSTR(MP_QSTR_IO47), MP_ROM_PTR(&pin_GPIO47) }, { MP_ROM_QSTR(MP_QSTR_IO48), MP_ROM_PTR(&pin_GPIO48) }, { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO48) }, + + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO43) }, + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO44) }, + + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, }; MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/espressif/boards/espressif_hmi_devkit_1/board.c b/ports/espressif/boards/espressif_hmi_devkit_1/board.c index ff5d9cfb6c..93aa1c0436 100644 --- a/ports/espressif/boards/espressif_hmi_devkit_1/board.c +++ b/ports/espressif/boards/espressif_hmi_devkit_1/board.c @@ -29,10 +29,6 @@ #include "shared-bindings/microcontroller/Pin.h" void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); - // Debug UART common_hal_never_reset_pin(&pin_GPIO43); common_hal_never_reset_pin(&pin_GPIO44); diff --git a/ports/espressif/boards/espressif_kaluga_1.3/board.c b/ports/espressif/boards/espressif_kaluga_1.3/board.c index e40b6335bc..0432485111 100644 --- a/ports/espressif/boards/espressif_kaluga_1.3/board.c +++ b/ports/espressif/boards/espressif_kaluga_1.3/board.c @@ -29,10 +29,6 @@ #include "shared-bindings/microcontroller/Pin.h" void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); - // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO43); diff --git a/ports/espressif/boards/espressif_kaluga_1/board.c b/ports/espressif/boards/espressif_kaluga_1/board.c index e40b6335bc..0432485111 100644 --- a/ports/espressif/boards/espressif_kaluga_1/board.c +++ b/ports/espressif/boards/espressif_kaluga_1/board.c @@ -29,10 +29,6 @@ #include "shared-bindings/microcontroller/Pin.h" void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); - // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO43); diff --git a/ports/espressif/boards/espressif_saola_1_wroom/board.c b/ports/espressif/boards/espressif_saola_1_wroom/board.c index e40b6335bc..0432485111 100644 --- a/ports/espressif/boards/espressif_saola_1_wroom/board.c +++ b/ports/espressif/boards/espressif_saola_1_wroom/board.c @@ -29,10 +29,6 @@ #include "shared-bindings/microcontroller/Pin.h" void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); - // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO43); diff --git a/ports/espressif/boards/espressif_saola_1_wrover/board.c b/ports/espressif/boards/espressif_saola_1_wrover/board.c index e40b6335bc..0432485111 100644 --- a/ports/espressif/boards/espressif_saola_1_wrover/board.c +++ b/ports/espressif/boards/espressif_saola_1_wrover/board.c @@ -29,10 +29,6 @@ #include "shared-bindings/microcontroller/Pin.h" void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); - // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO43); diff --git a/ports/espressif/boards/franzininho_wifi_wroom/board.c b/ports/espressif/boards/franzininho_wifi_wroom/board.c index e40b6335bc..0432485111 100644 --- a/ports/espressif/boards/franzininho_wifi_wroom/board.c +++ b/ports/espressif/boards/franzininho_wifi_wroom/board.c @@ -29,10 +29,6 @@ #include "shared-bindings/microcontroller/Pin.h" void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); - // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO43); diff --git a/ports/espressif/boards/franzininho_wifi_wrover/board.c b/ports/espressif/boards/franzininho_wifi_wrover/board.c index e40b6335bc..0432485111 100644 --- a/ports/espressif/boards/franzininho_wifi_wrover/board.c +++ b/ports/espressif/boards/franzininho_wifi_wrover/board.c @@ -29,10 +29,6 @@ #include "shared-bindings/microcontroller/Pin.h" void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); - // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO43); diff --git a/ports/espressif/boards/gravitech_cucumber_m/board.c b/ports/espressif/boards/gravitech_cucumber_m/board.c index ec84d3209c..16a6af0742 100644 --- a/ports/espressif/boards/gravitech_cucumber_m/board.c +++ b/ports/espressif/boards/gravitech_cucumber_m/board.c @@ -29,10 +29,6 @@ #include "shared-bindings/microcontroller/Pin.h" void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); - // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO43); diff --git a/ports/espressif/boards/gravitech_cucumber_ms/board.c b/ports/espressif/boards/gravitech_cucumber_ms/board.c index ec84d3209c..16a6af0742 100644 --- a/ports/espressif/boards/gravitech_cucumber_ms/board.c +++ b/ports/espressif/boards/gravitech_cucumber_ms/board.c @@ -29,10 +29,6 @@ #include "shared-bindings/microcontroller/Pin.h" void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); - // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO43); diff --git a/ports/espressif/boards/gravitech_cucumber_r/board.c b/ports/espressif/boards/gravitech_cucumber_r/board.c index ec84d3209c..16a6af0742 100644 --- a/ports/espressif/boards/gravitech_cucumber_r/board.c +++ b/ports/espressif/boards/gravitech_cucumber_r/board.c @@ -29,10 +29,6 @@ #include "shared-bindings/microcontroller/Pin.h" void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); - // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO43); diff --git a/ports/espressif/boards/gravitech_cucumber_rs/board.c b/ports/espressif/boards/gravitech_cucumber_rs/board.c index ec84d3209c..16a6af0742 100644 --- a/ports/espressif/boards/gravitech_cucumber_rs/board.c +++ b/ports/espressif/boards/gravitech_cucumber_rs/board.c @@ -29,10 +29,6 @@ #include "shared-bindings/microcontroller/Pin.h" void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); - // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO43); diff --git a/ports/espressif/boards/lilygo_ttgo_t8_s2_st7789/board.c b/ports/espressif/boards/lilygo_ttgo_t8_s2_st7789/board.c index b00a1ed8ed..38fba815e5 100644 --- a/ports/espressif/boards/lilygo_ttgo_t8_s2_st7789/board.c +++ b/ports/espressif/boards/lilygo_ttgo_t8_s2_st7789/board.c @@ -131,10 +131,6 @@ static void display_init(void) { } void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); - // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO43); diff --git a/ports/espressif/boards/lolin_s2_mini/board.c b/ports/espressif/boards/lolin_s2_mini/board.c index a0e399b1ef..0432485111 100644 --- a/ports/espressif/boards/lolin_s2_mini/board.c +++ b/ports/espressif/boards/lolin_s2_mini/board.c @@ -29,24 +29,11 @@ #include "shared-bindings/microcontroller/Pin.h" void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); - // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO43); common_hal_never_reset_pin(&pin_GPIO44); #endif /* DEBUG */ - - // SPI Flash and RAM - common_hal_never_reset_pin(&pin_GPIO26); - common_hal_never_reset_pin(&pin_GPIO27); - common_hal_never_reset_pin(&pin_GPIO28); - common_hal_never_reset_pin(&pin_GPIO29); - common_hal_never_reset_pin(&pin_GPIO30); - common_hal_never_reset_pin(&pin_GPIO31); - common_hal_never_reset_pin(&pin_GPIO32); } bool board_requests_safe_mode(void) { diff --git a/ports/espressif/boards/lolin_s2_pico/board.c b/ports/espressif/boards/lolin_s2_pico/board.c index a0e399b1ef..0432485111 100644 --- a/ports/espressif/boards/lolin_s2_pico/board.c +++ b/ports/espressif/boards/lolin_s2_pico/board.c @@ -29,24 +29,11 @@ #include "shared-bindings/microcontroller/Pin.h" void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); - // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO43); common_hal_never_reset_pin(&pin_GPIO44); #endif /* DEBUG */ - - // SPI Flash and RAM - common_hal_never_reset_pin(&pin_GPIO26); - common_hal_never_reset_pin(&pin_GPIO27); - common_hal_never_reset_pin(&pin_GPIO28); - common_hal_never_reset_pin(&pin_GPIO29); - common_hal_never_reset_pin(&pin_GPIO30); - common_hal_never_reset_pin(&pin_GPIO31); - common_hal_never_reset_pin(&pin_GPIO32); } bool board_requests_safe_mode(void) { diff --git a/ports/espressif/boards/microdev_micro_c3/board.c b/ports/espressif/boards/microdev_micro_c3/board.c index 7ffd406cfe..e3b71f4832 100644 --- a/ports/espressif/boards/microdev_micro_c3/board.c +++ b/ports/espressif/boards/microdev_micro_c3/board.c @@ -28,24 +28,11 @@ #include "supervisor/board.h" void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO18); - common_hal_never_reset_pin(&pin_GPIO19); - // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO20); common_hal_never_reset_pin(&pin_GPIO21); #endif - - // SPI Flash - common_hal_never_reset_pin(&pin_GPIO11); - common_hal_never_reset_pin(&pin_GPIO12); - common_hal_never_reset_pin(&pin_GPIO13); - common_hal_never_reset_pin(&pin_GPIO14); - common_hal_never_reset_pin(&pin_GPIO15); - common_hal_never_reset_pin(&pin_GPIO16); - common_hal_never_reset_pin(&pin_GPIO17); } bool board_requests_safe_mode(void) { diff --git a/ports/espressif/boards/microdev_micro_c3/pins.c b/ports/espressif/boards/microdev_micro_c3/pins.c index 84d6efb782..240966404f 100644 --- a/ports/espressif/boards/microdev_micro_c3/pins.c +++ b/ports/espressif/boards/microdev_micro_c3/pins.c @@ -72,6 +72,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO7) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, }; diff --git a/ports/espressif/boards/microdev_micro_s2/board.c b/ports/espressif/boards/microdev_micro_s2/board.c index 52d640618c..6ba5d975d7 100644 --- a/ports/espressif/boards/microdev_micro_s2/board.c +++ b/ports/espressif/boards/microdev_micro_s2/board.c @@ -29,24 +29,11 @@ #include "shared-bindings/microcontroller/Pin.h" void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); - // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO43); common_hal_never_reset_pin(&pin_GPIO44); #endif - - // SPI Flash and RAM - common_hal_never_reset_pin(&pin_GPIO26); - common_hal_never_reset_pin(&pin_GPIO27); - common_hal_never_reset_pin(&pin_GPIO28); - common_hal_never_reset_pin(&pin_GPIO29); - common_hal_never_reset_pin(&pin_GPIO30); - common_hal_never_reset_pin(&pin_GPIO31); - common_hal_never_reset_pin(&pin_GPIO32); } bool board_requests_safe_mode(void) { diff --git a/ports/espressif/boards/microdev_micro_s2/pins.c b/ports/espressif/boards/microdev_micro_s2/pins.c index faf4a9e473..a382bf8fef 100644 --- a/ports/espressif/boards/microdev_micro_s2/pins.c +++ b/ports/espressif/boards/microdev_micro_s2/pins.c @@ -90,6 +90,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO33) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, }; diff --git a/ports/espressif/boards/morpheans_morphesp-240/board.c b/ports/espressif/boards/morpheans_morphesp-240/board.c index aad2f0257a..ace1778766 100644 --- a/ports/espressif/boards/morpheans_morphesp-240/board.c +++ b/ports/espressif/boards/morpheans_morphesp-240/board.c @@ -139,10 +139,6 @@ uint8_t display_init_sequence[] = { void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); - // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO6); diff --git a/ports/espressif/boards/muselab_nanoesp32_s2_wroom/board.c b/ports/espressif/boards/muselab_nanoesp32_s2_wroom/board.c index e40b6335bc..0432485111 100644 --- a/ports/espressif/boards/muselab_nanoesp32_s2_wroom/board.c +++ b/ports/espressif/boards/muselab_nanoesp32_s2_wroom/board.c @@ -29,10 +29,6 @@ #include "shared-bindings/microcontroller/Pin.h" void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); - // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO43); diff --git a/ports/espressif/boards/muselab_nanoesp32_s2_wrover/board.c b/ports/espressif/boards/muselab_nanoesp32_s2_wrover/board.c index e40b6335bc..0432485111 100644 --- a/ports/espressif/boards/muselab_nanoesp32_s2_wrover/board.c +++ b/ports/espressif/boards/muselab_nanoesp32_s2_wrover/board.c @@ -29,10 +29,6 @@ #include "shared-bindings/microcontroller/Pin.h" void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); - // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO43); diff --git a/ports/espressif/boards/odt_pixelwing_esp32_s2/board.c b/ports/espressif/boards/odt_pixelwing_esp32_s2/board.c index 5abd1ce1b3..6772768da5 100644 --- a/ports/espressif/boards/odt_pixelwing_esp32_s2/board.c +++ b/ports/espressif/boards/odt_pixelwing_esp32_s2/board.c @@ -29,9 +29,6 @@ #include "shared-bindings/microcontroller/Pin.h" void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); } bool board_requests_safe_mode(void) { diff --git a/ports/espressif/boards/odt_pixelwing_esp32_s2/pins.c b/ports/espressif/boards/odt_pixelwing_esp32_s2/pins.c index f547c28def..4daec42ae4 100644 --- a/ports/espressif/boards/odt_pixelwing_esp32_s2/pins.c +++ b/ports/espressif/boards/odt_pixelwing_esp32_s2/pins.c @@ -12,5 +12,6 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO45) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, }; MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/espressif/boards/targett_module_clip_wroom/board.c b/ports/espressif/boards/targett_module_clip_wroom/board.c index 00b94a0259..66aea4bdd5 100644 --- a/ports/espressif/boards/targett_module_clip_wroom/board.c +++ b/ports/espressif/boards/targett_module_clip_wroom/board.c @@ -29,10 +29,6 @@ #include "shared-bindings/microcontroller/Pin.h" void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); - // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO43); diff --git a/ports/espressif/boards/targett_module_clip_wrover/board.c b/ports/espressif/boards/targett_module_clip_wrover/board.c index 00b94a0259..66aea4bdd5 100644 --- a/ports/espressif/boards/targett_module_clip_wrover/board.c +++ b/ports/espressif/boards/targett_module_clip_wrover/board.c @@ -29,10 +29,6 @@ #include "shared-bindings/microcontroller/Pin.h" void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); - // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO43); diff --git a/ports/espressif/boards/unexpectedmaker_feathers2/board.c b/ports/espressif/boards/unexpectedmaker_feathers2/board.c index a0e399b1ef..0432485111 100644 --- a/ports/espressif/boards/unexpectedmaker_feathers2/board.c +++ b/ports/espressif/boards/unexpectedmaker_feathers2/board.c @@ -29,24 +29,11 @@ #include "shared-bindings/microcontroller/Pin.h" void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); - // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO43); common_hal_never_reset_pin(&pin_GPIO44); #endif /* DEBUG */ - - // SPI Flash and RAM - common_hal_never_reset_pin(&pin_GPIO26); - common_hal_never_reset_pin(&pin_GPIO27); - common_hal_never_reset_pin(&pin_GPIO28); - common_hal_never_reset_pin(&pin_GPIO29); - common_hal_never_reset_pin(&pin_GPIO30); - common_hal_never_reset_pin(&pin_GPIO31); - common_hal_never_reset_pin(&pin_GPIO32); } bool board_requests_safe_mode(void) { diff --git a/ports/espressif/boards/unexpectedmaker_feathers2/pins.c b/ports/espressif/boards/unexpectedmaker_feathers2/pins.c index 66657b2f4f..f731b08688 100644 --- a/ports/espressif/boards/unexpectedmaker_feathers2/pins.c +++ b/ports/espressif/boards/unexpectedmaker_feathers2/pins.c @@ -98,6 +98,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_AMB), MP_ROM_PTR(&pin_GPIO4) }, // Ambient Light Sensor { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, }; diff --git a/ports/espressif/boards/unexpectedmaker_feathers2_neo/board.c b/ports/espressif/boards/unexpectedmaker_feathers2_neo/board.c index a0e399b1ef..0432485111 100644 --- a/ports/espressif/boards/unexpectedmaker_feathers2_neo/board.c +++ b/ports/espressif/boards/unexpectedmaker_feathers2_neo/board.c @@ -29,24 +29,11 @@ #include "shared-bindings/microcontroller/Pin.h" void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); - // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO43); common_hal_never_reset_pin(&pin_GPIO44); #endif /* DEBUG */ - - // SPI Flash and RAM - common_hal_never_reset_pin(&pin_GPIO26); - common_hal_never_reset_pin(&pin_GPIO27); - common_hal_never_reset_pin(&pin_GPIO28); - common_hal_never_reset_pin(&pin_GPIO29); - common_hal_never_reset_pin(&pin_GPIO30); - common_hal_never_reset_pin(&pin_GPIO31); - common_hal_never_reset_pin(&pin_GPIO32); } bool board_requests_safe_mode(void) { diff --git a/ports/espressif/boards/unexpectedmaker_feathers2_neo/pins.c b/ports/espressif/boards/unexpectedmaker_feathers2_neo/pins.c index 61bf1397a9..43df5d506a 100644 --- a/ports/espressif/boards/unexpectedmaker_feathers2_neo/pins.c +++ b/ports/espressif/boards/unexpectedmaker_feathers2_neo/pins.c @@ -115,6 +115,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_IO21), MP_ROM_PTR(&pin_GPIO21) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, }; diff --git a/ports/espressif/boards/unexpectedmaker_feathers2_prerelease/board.c b/ports/espressif/boards/unexpectedmaker_feathers2_prerelease/board.c index a0e399b1ef..0432485111 100644 --- a/ports/espressif/boards/unexpectedmaker_feathers2_prerelease/board.c +++ b/ports/espressif/boards/unexpectedmaker_feathers2_prerelease/board.c @@ -29,24 +29,11 @@ #include "shared-bindings/microcontroller/Pin.h" void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); - // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO43); common_hal_never_reset_pin(&pin_GPIO44); #endif /* DEBUG */ - - // SPI Flash and RAM - common_hal_never_reset_pin(&pin_GPIO26); - common_hal_never_reset_pin(&pin_GPIO27); - common_hal_never_reset_pin(&pin_GPIO28); - common_hal_never_reset_pin(&pin_GPIO29); - common_hal_never_reset_pin(&pin_GPIO30); - common_hal_never_reset_pin(&pin_GPIO31); - common_hal_never_reset_pin(&pin_GPIO32); } bool board_requests_safe_mode(void) { diff --git a/ports/espressif/boards/unexpectedmaker_feathers2_prerelease/pins.c b/ports/espressif/boards/unexpectedmaker_feathers2_prerelease/pins.c index 29ceffcdd5..34485b3ea8 100644 --- a/ports/espressif/boards/unexpectedmaker_feathers2_prerelease/pins.c +++ b/ports/espressif/boards/unexpectedmaker_feathers2_prerelease/pins.c @@ -96,6 +96,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_AMB), MP_ROM_PTR(&pin_GPIO4) }, // Ambient Light Sensor { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, }; diff --git a/ports/espressif/boards/unexpectedmaker_feathers3/board.c b/ports/espressif/boards/unexpectedmaker_feathers3/board.c new file mode 100644 index 0000000000..0432485111 --- /dev/null +++ b/ports/espressif/boards/unexpectedmaker_feathers3/board.c @@ -0,0 +1,48 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "supervisor/board.h" +#include "mpconfigboard.h" +#include "shared-bindings/microcontroller/Pin.h" + +void board_init(void) { + // Debug UART + #ifdef DEBUG + common_hal_never_reset_pin(&pin_GPIO43); + common_hal_never_reset_pin(&pin_GPIO44); + #endif /* DEBUG */ +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { + +} + +void board_deinit(void) { +} diff --git a/ports/espressif/boards/unexpectedmaker_feathers3/mpconfigboard.h b/ports/espressif/boards/unexpectedmaker_feathers3/mpconfigboard.h new file mode 100644 index 0000000000..3c9f8f25c1 --- /dev/null +++ b/ports/espressif/boards/unexpectedmaker_feathers3/mpconfigboard.h @@ -0,0 +1,49 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +// Micropython setup + +#define MICROPY_HW_BOARD_NAME "FeatherS3" +#define MICROPY_HW_MCU_NAME "ESP32S3" + +#define MICROPY_HW_NEOPIXEL (&pin_GPIO40) +#define CIRCUITPY_STATUS_LED_POWER (&pin_GPIO39) +#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) +#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") + +#define AUTORESET_DELAY_MS 500 + +#define DEFAULT_I2C_BUS_SCL (&pin_GPIO9) +#define DEFAULT_I2C_BUS_SDA (&pin_GPIO8) + +#define DEFAULT_SPI_BUS_SCK (&pin_GPIO36) +#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO35) +#define DEFAULT_SPI_BUS_MISO (&pin_GPIO37) + +#define DEFAULT_UART_BUS_RX (&pin_GPIO44) +#define DEFAULT_UART_BUS_TX (&pin_GPIO43) + +#define DOUBLE_TAP_PIN (&pin_GPIO47) diff --git a/ports/espressif/boards/unexpectedmaker_feathers3/mpconfigboard.mk b/ports/espressif/boards/unexpectedmaker_feathers3/mpconfigboard.mk new file mode 100644 index 0000000000..866bd15ffa --- /dev/null +++ b/ports/espressif/boards/unexpectedmaker_feathers3/mpconfigboard.mk @@ -0,0 +1,22 @@ +USB_VID = 0x303A +USB_PID = 0x80D7 +USB_PRODUCT = "FeatherS3" +USB_MANUFACTURER = "UnexpectedMaker" + +IDF_TARGET = esp32s3 + +INTERNAL_FLASH_FILESYSTEM = 1 +LONGINT_IMPL = MPZ + +# The default queue depth of 16 overflows on release builds, +# so increase it to 32. +CFLAGS += -DCFG_TUD_TASK_QUEUE_SZ=32 + +CIRCUITPY_ESP_FLASH_MODE=dio +CIRCUITPY_ESP_FLASH_FREQ=80m +CIRCUITPY_ESP_FLASH_SIZE=16MB + +#CIRCUITPY_BITBANG_NEOPIXEL = 1 + +# Include these Python libraries in firmware. +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel diff --git a/ports/espressif/boards/unexpectedmaker_feathers3/pins.c b/ports/espressif/boards/unexpectedmaker_feathers3/pins.c new file mode 100644 index 0000000000..988610edf2 --- /dev/null +++ b/ports/espressif/boards/unexpectedmaker_feathers3/pins.c @@ -0,0 +1,120 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + + { MP_ROM_QSTR(MP_QSTR_IO0), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_GPIO0) }, + + { MP_ROM_QSTR(MP_QSTR_IO18), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_D15), MP_ROM_PTR(&pin_GPIO18) }, + + { MP_ROM_QSTR(MP_QSTR_IO17), MP_ROM_PTR(&pin_GPIO17) }, + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO17) }, + { MP_ROM_QSTR(MP_QSTR_D14), MP_ROM_PTR(&pin_GPIO17) }, + + { MP_ROM_QSTR(MP_QSTR_IO14), MP_ROM_PTR(&pin_GPIO14) }, + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO14) }, + { MP_ROM_QSTR(MP_QSTR_D16), MP_ROM_PTR(&pin_GPIO14) }, + + { MP_ROM_QSTR(MP_QSTR_IO12), MP_ROM_PTR(&pin_GPIO12) }, + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_GPIO12) }, + { MP_ROM_QSTR(MP_QSTR_D17), MP_ROM_PTR(&pin_GPIO12) }, + + { MP_ROM_QSTR(MP_QSTR_IO6), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_D18), MP_ROM_PTR(&pin_GPIO6) }, + + { MP_ROM_QSTR(MP_QSTR_IO5), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_D19), MP_ROM_PTR(&pin_GPIO5) }, + + { MP_ROM_QSTR(MP_QSTR_IO36), MP_ROM_PTR(&pin_GPIO36) }, + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO36) }, + { MP_ROM_QSTR(MP_QSTR_D25), MP_ROM_PTR(&pin_GPIO36) }, + + { MP_ROM_QSTR(MP_QSTR_IO35), MP_ROM_PTR(&pin_GPIO35) }, + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO35) }, + { MP_ROM_QSTR(MP_QSTR_D24), MP_ROM_PTR(&pin_GPIO35) }, + + { MP_ROM_QSTR(MP_QSTR_IO37), MP_ROM_PTR(&pin_GPIO37) }, + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO37) }, + { MP_ROM_QSTR(MP_QSTR_D23), MP_ROM_PTR(&pin_GPIO37) }, + + { MP_ROM_QSTR(MP_QSTR_IO44), MP_ROM_PTR(&pin_GPIO44) }, + { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_GPIO44) }, + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO44) }, + + { MP_ROM_QSTR(MP_QSTR_IO43), MP_ROM_PTR(&pin_GPIO43) }, + { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_GPIO43) }, + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO43) }, + + // { MP_ROM_QSTR(MP_QSTR_IO42), MP_ROM_PTR(&pin_GPIO42) }, + // { MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_GPIO42) }, + + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_IO8), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_A11), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_D21), MP_ROM_PTR(&pin_GPIO8) }, + + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_IO9), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_A12), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_D22), MP_ROM_PTR(&pin_GPIO9) }, + + { MP_ROM_QSTR(MP_QSTR_IO33), MP_ROM_PTR(&pin_GPIO33) }, + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_GPIO33) }, + + { MP_ROM_QSTR(MP_QSTR_IO38), MP_ROM_PTR(&pin_GPIO38) }, + { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_GPIO38) }, + + { MP_ROM_QSTR(MP_QSTR_IO1), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_A6), MP_ROM_PTR(&pin_GPIO1) }, + + { MP_ROM_QSTR(MP_QSTR_IO3), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_A7), MP_ROM_PTR(&pin_GPIO3) }, + + { MP_ROM_QSTR(MP_QSTR_IO7), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_A8), MP_ROM_PTR(&pin_GPIO7) }, + + { MP_ROM_QSTR(MP_QSTR_IO10), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_A9), MP_ROM_PTR(&pin_GPIO10) }, + + { MP_ROM_QSTR(MP_QSTR_IO11), MP_ROM_PTR(&pin_GPIO11) }, + { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_GPIO11) }, + { MP_ROM_QSTR(MP_QSTR_A10), MP_ROM_PTR(&pin_GPIO11) }, + + { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO13) }, // Blue LED + + // Battery voltage sense pin + // I really don't know what name to use here. Adafruit use BATTERY & VOLTAGE_MONITOR + // I prefer VBAT or VBAT_SENSE + { MP_ROM_QSTR(MP_QSTR_BATTERY), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_VBAT), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_VBAT_SENSE), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_VOLTAGE_MONITOR), MP_ROM_PTR(&pin_GPIO2) }, + + // 5V present sense pin + { MP_ROM_QSTR(MP_QSTR_VBUS), MP_ROM_PTR(&pin_GPIO34) }, + { MP_ROM_QSTR(MP_QSTR_VBUS_SENSE), MP_ROM_PTR(&pin_GPIO34) }, + + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL_POWER), MP_ROM_PTR(&pin_GPIO39) }, + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO40) }, + + { MP_ROM_QSTR(MP_QSTR_IO4), MP_ROM_PTR(&pin_GPIO4) }, // Ambient Light Sensor + { MP_ROM_QSTR(MP_QSTR_AMB), MP_ROM_PTR(&pin_GPIO4) }, // Ambient Light Sensor + + { MP_ROM_QSTR(MP_QSTR_LDO2), MP_ROM_PTR(&pin_GPIO39) }, // Second LDO Enable control + { MP_ROM_QSTR(MP_QSTR_I39), MP_ROM_PTR(&pin_GPIO39) }, // Second LDO Enable control + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/espressif/boards/unexpectedmaker_feathers3/sdkconfig b/ports/espressif/boards/unexpectedmaker_feathers3/sdkconfig new file mode 100644 index 0000000000..ec989c08fc --- /dev/null +++ b/ports/espressif/boards/unexpectedmaker_feathers3/sdkconfig @@ -0,0 +1,39 @@ +CONFIG_ESP32S3_SPIRAM_SUPPORT=y + +# +# SPI RAM config +# +# CONFIG_SPIRAM_TYPE_AUTO is not set +# CONFIG_SPIRAM_TYPE_ESPPSRAM16 is not set +# CONFIG_SPIRAM_TYPE_ESPPSRAM32 is not set +CONFIG_SPIRAM_TYPE_ESPPSRAM64=y +CONFIG_SPIRAM_SIZE=8388608 + +# +# PSRAM clock and cs IO for ESP32S2 +# +CONFIG_DEFAULT_PSRAM_CLK_IO=30 +CONFIG_DEFAULT_PSRAM_CS_IO=26 +# end of PSRAM clock and cs IO for ESP32S2 + +# CONFIG_SPIRAM_FETCH_INSTRUCTIONS is not set +# CONFIG_SPIRAM_RODATA is not set +CONFIG_SPIRAM_SPEED_80M=y +# CONFIG_SPIRAM_SPEED_40M is not set +# CONFIG_SPIRAM_SPEED_26M is not set +# CONFIG_SPIRAM_SPEED_20M is not set +CONFIG_SPIRAM=y +CONFIG_SPIRAM_BOOT_INIT=y +# CONFIG_SPIRAM_IGNORE_NOTFOUND is not set +CONFIG_SPIRAM_USE_MEMMAP=y +# CONFIG_SPIRAM_USE_CAPS_ALLOC is not set +# CONFIG_SPIRAM_USE_MALLOC is not set +# CONFIG_SPIRAM_MEMTEST=y +# CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY is not set +# end of SPI RAM config + +# +# LWIP +# +CONFIG_LWIP_LOCAL_HOSTNAME="UMFeatherS3" +# end of LWIP diff --git a/ports/espressif/boards/unexpectedmaker_pros3/board.c b/ports/espressif/boards/unexpectedmaker_pros3/board.c new file mode 100644 index 0000000000..0432485111 --- /dev/null +++ b/ports/espressif/boards/unexpectedmaker_pros3/board.c @@ -0,0 +1,48 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "supervisor/board.h" +#include "mpconfigboard.h" +#include "shared-bindings/microcontroller/Pin.h" + +void board_init(void) { + // Debug UART + #ifdef DEBUG + common_hal_never_reset_pin(&pin_GPIO43); + common_hal_never_reset_pin(&pin_GPIO44); + #endif /* DEBUG */ +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { + +} + +void board_deinit(void) { +} diff --git a/ports/espressif/boards/unexpectedmaker_pros3/mpconfigboard.h b/ports/espressif/boards/unexpectedmaker_pros3/mpconfigboard.h new file mode 100644 index 0000000000..8c578e5e49 --- /dev/null +++ b/ports/espressif/boards/unexpectedmaker_pros3/mpconfigboard.h @@ -0,0 +1,49 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +// Micropython setup + +#define MICROPY_HW_BOARD_NAME "ProS3" +#define MICROPY_HW_MCU_NAME "ESP32S3" + +#define MICROPY_HW_NEOPIXEL (&pin_GPIO18) +#define CIRCUITPY_STATUS_LED_POWER (&pin_GPIO17) +#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) +#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") + +#define AUTORESET_DELAY_MS 500 + +#define DEFAULT_I2C_BUS_SCL (&pin_GPIO9) +#define DEFAULT_I2C_BUS_SDA (&pin_GPIO8) + +#define DEFAULT_SPI_BUS_SCK (&pin_GPIO36) +#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO35) +#define DEFAULT_SPI_BUS_MISO (&pin_GPIO37) + +#define DEFAULT_UART_BUS_RX (&pin_GPIO44) +#define DEFAULT_UART_BUS_TX (&pin_GPIO43) + +#define DOUBLE_TAP_PIN (&pin_GPIO47) diff --git a/ports/espressif/boards/unexpectedmaker_pros3/mpconfigboard.mk b/ports/espressif/boards/unexpectedmaker_pros3/mpconfigboard.mk new file mode 100644 index 0000000000..3b50324d3c --- /dev/null +++ b/ports/espressif/boards/unexpectedmaker_pros3/mpconfigboard.mk @@ -0,0 +1,22 @@ +USB_VID = 0x303A +USB_PID = 0x80D4 +USB_PRODUCT = "ProS3" +USB_MANUFACTURER = "UnexpectedMaker" + +IDF_TARGET = esp32s3 + +INTERNAL_FLASH_FILESYSTEM = 1 +LONGINT_IMPL = MPZ + +# The default queue depth of 16 overflows on release builds, +# so increase it to 32. +CFLAGS += -DCFG_TUD_TASK_QUEUE_SZ=32 + +CIRCUITPY_ESP_FLASH_MODE=qio +CIRCUITPY_ESP_FLASH_FREQ=80m +CIRCUITPY_ESP_FLASH_SIZE=16MB + +# CIRCUITPY_BITBANG_NEOPIXEL = 1 + +# Include these Python libraries in firmware. +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel diff --git a/ports/espressif/boards/unexpectedmaker_pros3/pins.c b/ports/espressif/boards/unexpectedmaker_pros3/pins.c new file mode 100644 index 0000000000..b9b03e853a --- /dev/null +++ b/ports/espressif/boards/unexpectedmaker_pros3/pins.c @@ -0,0 +1,140 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + + { MP_ROM_QSTR(MP_QSTR_IO0), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_GPIO0) }, + + { MP_ROM_QSTR(MP_QSTR_IO1), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_GPIO1) }, + + { MP_ROM_QSTR(MP_QSTR_IO2), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_GPIO2) }, + + { MP_ROM_QSTR(MP_QSTR_IO3), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_GPIO3) }, + + { MP_ROM_QSTR(MP_QSTR_IO4), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_GPIO4) }, + + { MP_ROM_QSTR(MP_QSTR_IO5), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_GPIO5) }, + + { MP_ROM_QSTR(MP_QSTR_IO6), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_GPIO6) }, + + { MP_ROM_QSTR(MP_QSTR_IO7), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_A6), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_GPIO7) }, + + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_IO8), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_A7), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_GPIO8) }, + + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_IO9), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_A8), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_GPIO9) }, + + + { MP_ROM_QSTR(MP_QSTR_IO12), MP_ROM_PTR(&pin_GPIO12) }, + { MP_ROM_QSTR(MP_QSTR_A11), MP_ROM_PTR(&pin_GPIO12) }, + { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_GPIO12) }, + + { MP_ROM_QSTR(MP_QSTR_IO13), MP_ROM_PTR(&pin_GPIO13) }, + { MP_ROM_QSTR(MP_QSTR_A12), MP_ROM_PTR(&pin_GPIO13) }, + { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_GPIO13) }, + + { MP_ROM_QSTR(MP_QSTR_IO14), MP_ROM_PTR(&pin_GPIO14) }, + { MP_ROM_QSTR(MP_QSTR_A13), MP_ROM_PTR(&pin_GPIO14) }, + { MP_ROM_QSTR(MP_QSTR_D14), MP_ROM_PTR(&pin_GPIO14) }, + + { MP_ROM_QSTR(MP_QSTR_IO15), MP_ROM_PTR(&pin_GPIO15) }, + { MP_ROM_QSTR(MP_QSTR_A14), MP_ROM_PTR(&pin_GPIO15) }, + { MP_ROM_QSTR(MP_QSTR_D15), MP_ROM_PTR(&pin_GPIO15) }, + + { MP_ROM_QSTR(MP_QSTR_IO16), MP_ROM_PTR(&pin_GPIO16) }, + { MP_ROM_QSTR(MP_QSTR_A15), MP_ROM_PTR(&pin_GPIO16) }, + { MP_ROM_QSTR(MP_QSTR_D16), MP_ROM_PTR(&pin_GPIO16) }, + + { MP_ROM_QSTR(MP_QSTR_IO21), MP_ROM_PTR(&pin_GPIO21) }, + { MP_ROM_QSTR(MP_QSTR_D21), MP_ROM_PTR(&pin_GPIO21) }, + + { MP_ROM_QSTR(MP_QSTR_IO34), MP_ROM_PTR(&pin_GPIO34) }, + { MP_ROM_QSTR(MP_QSTR_D34), MP_ROM_PTR(&pin_GPIO34) }, + + { MP_ROM_QSTR(MP_QSTR_IO35), MP_ROM_PTR(&pin_GPIO35) }, + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO35) }, + { MP_ROM_QSTR(MP_QSTR_MO), MP_ROM_PTR(&pin_GPIO35) }, + { MP_ROM_QSTR(MP_QSTR_SDO), MP_ROM_PTR(&pin_GPIO35) }, + { MP_ROM_QSTR(MP_QSTR_D35), MP_ROM_PTR(&pin_GPIO35) }, + + { MP_ROM_QSTR(MP_QSTR_IO37), MP_ROM_PTR(&pin_GPIO37) }, + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO37) }, + { MP_ROM_QSTR(MP_QSTR_MI), MP_ROM_PTR(&pin_GPIO37) }, + { MP_ROM_QSTR(MP_QSTR_SDI), MP_ROM_PTR(&pin_GPIO37) }, + { MP_ROM_QSTR(MP_QSTR_D37), MP_ROM_PTR(&pin_GPIO37) }, + + { MP_ROM_QSTR(MP_QSTR_IO36), MP_ROM_PTR(&pin_GPIO36) }, + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO36) }, + { MP_ROM_QSTR(MP_QSTR_D36), MP_ROM_PTR(&pin_GPIO36) }, + + { MP_ROM_QSTR(MP_QSTR_IO38), MP_ROM_PTR(&pin_GPIO38) }, + { MP_ROM_QSTR(MP_QSTR_D38), MP_ROM_PTR(&pin_GPIO38) }, + + { MP_ROM_QSTR(MP_QSTR_IO39), MP_ROM_PTR(&pin_GPIO39) }, + { MP_ROM_QSTR(MP_QSTR_MTCK), MP_ROM_PTR(&pin_GPIO39) }, + { MP_ROM_QSTR(MP_QSTR_D39), MP_ROM_PTR(&pin_GPIO39) }, + + { MP_ROM_QSTR(MP_QSTR_IO40), MP_ROM_PTR(&pin_GPIO40) }, + { MP_ROM_QSTR(MP_QSTR_MTDO), MP_ROM_PTR(&pin_GPIO40) }, + { MP_ROM_QSTR(MP_QSTR_D40), MP_ROM_PTR(&pin_GPIO40) }, + + { MP_ROM_QSTR(MP_QSTR_IO41), MP_ROM_PTR(&pin_GPIO41) }, + { MP_ROM_QSTR(MP_QSTR_MTDI), MP_ROM_PTR(&pin_GPIO41) }, + { MP_ROM_QSTR(MP_QSTR_D41), MP_ROM_PTR(&pin_GPIO41) }, + + { MP_ROM_QSTR(MP_QSTR_IO42), MP_ROM_PTR(&pin_GPIO42) }, + { MP_ROM_QSTR(MP_QSTR_MTMS), MP_ROM_PTR(&pin_GPIO42) }, + { MP_ROM_QSTR(MP_QSTR_D42), MP_ROM_PTR(&pin_GPIO42) }, + + { MP_ROM_QSTR(MP_QSTR_IO43), MP_ROM_PTR(&pin_GPIO43) }, + { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_GPIO43) }, + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO43) }, + + { MP_ROM_QSTR(MP_QSTR_IO44), MP_ROM_PTR(&pin_GPIO44) }, + { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_GPIO44) }, + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO44) }, + + // Battery voltage sense pin + // I really don't know what name to use here. Adafruit use BATTERY & VOLTAGE_MONITOR + // I prefer VBAT or VBAT_SENSE + { MP_ROM_QSTR(MP_QSTR_BATTERY), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_VBAT), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_VBAT_SENSE), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_VOLTAGE_MONITOR), MP_ROM_PTR(&pin_GPIO10) }, + + // 5V present sense pin + { MP_ROM_QSTR(MP_QSTR_VBUS), MP_ROM_PTR(&pin_GPIO33) }, + { MP_ROM_QSTR(MP_QSTR_VBUS_SENSE), MP_ROM_PTR(&pin_GPIO33) }, + + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL_POWER), MP_ROM_PTR(&pin_GPIO17) }, + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO18) }, + + { MP_ROM_QSTR(MP_QSTR_LDO2), MP_ROM_PTR(&pin_GPIO17) }, // Second LDO Enable control + { MP_ROM_QSTR(MP_QSTR_I17), MP_ROM_PTR(&pin_GPIO17) }, // Second LDO Enable control + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/espressif/boards/unexpectedmaker_pros3/sdkconfig b/ports/espressif/boards/unexpectedmaker_pros3/sdkconfig new file mode 100644 index 0000000000..eeb103fb7d --- /dev/null +++ b/ports/espressif/boards/unexpectedmaker_pros3/sdkconfig @@ -0,0 +1,39 @@ +CONFIG_ESP32S3_SPIRAM_SUPPORT=y + +# +# SPI RAM config +# +# CONFIG_SPIRAM_TYPE_AUTO is not set +# CONFIG_SPIRAM_TYPE_ESPPSRAM16 is not set +# CONFIG_SPIRAM_TYPE_ESPPSRAM32 is not set +CONFIG_SPIRAM_TYPE_ESPPSRAM64=y +CONFIG_SPIRAM_SIZE=8388608 + +# +# PSRAM clock and cs IO for ESP32S2 +# +CONFIG_DEFAULT_PSRAM_CLK_IO=30 +CONFIG_DEFAULT_PSRAM_CS_IO=26 +# end of PSRAM clock and cs IO for ESP32S2 + +# CONFIG_SPIRAM_FETCH_INSTRUCTIONS is not set +# CONFIG_SPIRAM_RODATA is not set +CONFIG_SPIRAM_SPEED_80M=y +# CONFIG_SPIRAM_SPEED_40M is not set +# CONFIG_SPIRAM_SPEED_26M is not set +# CONFIG_SPIRAM_SPEED_20M is not set +CONFIG_SPIRAM=y +CONFIG_SPIRAM_BOOT_INIT=y +# CONFIG_SPIRAM_IGNORE_NOTFOUND is not set +CONFIG_SPIRAM_USE_MEMMAP=y +# CONFIG_SPIRAM_USE_CAPS_ALLOC is not set +# CONFIG_SPIRAM_USE_MALLOC is not set +# CONFIG_SPIRAM_MEMTEST=y +# CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY is not set +# end of SPI RAM config + +# +# LWIP +# +CONFIG_LWIP_LOCAL_HOSTNAME="UMProS3" +# end of LWIP diff --git a/ports/espressif/boards/unexpectedmaker_tinys2/board.c b/ports/espressif/boards/unexpectedmaker_tinys2/board.c index a0e399b1ef..0432485111 100644 --- a/ports/espressif/boards/unexpectedmaker_tinys2/board.c +++ b/ports/espressif/boards/unexpectedmaker_tinys2/board.c @@ -29,24 +29,11 @@ #include "shared-bindings/microcontroller/Pin.h" void board_init(void) { - // USB - common_hal_never_reset_pin(&pin_GPIO19); - common_hal_never_reset_pin(&pin_GPIO20); - // Debug UART #ifdef DEBUG common_hal_never_reset_pin(&pin_GPIO43); common_hal_never_reset_pin(&pin_GPIO44); #endif /* DEBUG */ - - // SPI Flash and RAM - common_hal_never_reset_pin(&pin_GPIO26); - common_hal_never_reset_pin(&pin_GPIO27); - common_hal_never_reset_pin(&pin_GPIO28); - common_hal_never_reset_pin(&pin_GPIO29); - common_hal_never_reset_pin(&pin_GPIO30); - common_hal_never_reset_pin(&pin_GPIO31); - common_hal_never_reset_pin(&pin_GPIO32); } bool board_requests_safe_mode(void) { diff --git a/ports/espressif/boards/unexpectedmaker_tinys3/board.c b/ports/espressif/boards/unexpectedmaker_tinys3/board.c new file mode 100644 index 0000000000..0432485111 --- /dev/null +++ b/ports/espressif/boards/unexpectedmaker_tinys3/board.c @@ -0,0 +1,48 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "supervisor/board.h" +#include "mpconfigboard.h" +#include "shared-bindings/microcontroller/Pin.h" + +void board_init(void) { + // Debug UART + #ifdef DEBUG + common_hal_never_reset_pin(&pin_GPIO43); + common_hal_never_reset_pin(&pin_GPIO44); + #endif /* DEBUG */ +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { + +} + +void board_deinit(void) { +} diff --git a/ports/espressif/boards/unexpectedmaker_tinys3/mpconfigboard.h b/ports/espressif/boards/unexpectedmaker_tinys3/mpconfigboard.h new file mode 100644 index 0000000000..c4853f4709 --- /dev/null +++ b/ports/espressif/boards/unexpectedmaker_tinys3/mpconfigboard.h @@ -0,0 +1,49 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +// Micropython setup + +#define MICROPY_HW_BOARD_NAME "TinyS3" +#define MICROPY_HW_MCU_NAME "ESP32S3" + +#define MICROPY_HW_NEOPIXEL (&pin_GPIO18) +#define CIRCUITPY_STATUS_LED_POWER (&pin_GPIO17) +#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) +#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") + +#define AUTORESET_DELAY_MS 500 + +#define DEFAULT_I2C_BUS_SCL (&pin_GPIO9) +#define DEFAULT_I2C_BUS_SDA (&pin_GPIO8) + +#define DEFAULT_SPI_BUS_SCK (&pin_GPIO36) +#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO35) +#define DEFAULT_SPI_BUS_MISO (&pin_GPIO37) + +#define DEFAULT_UART_BUS_RX (&pin_GPIO44) +#define DEFAULT_UART_BUS_TX (&pin_GPIO43) + +#define DOUBLE_TAP_PIN (&pin_GPIO47) diff --git a/ports/espressif/boards/unexpectedmaker_tinys3/mpconfigboard.mk b/ports/espressif/boards/unexpectedmaker_tinys3/mpconfigboard.mk new file mode 100644 index 0000000000..32a711c257 --- /dev/null +++ b/ports/espressif/boards/unexpectedmaker_tinys3/mpconfigboard.mk @@ -0,0 +1,24 @@ +USB_VID = 0x303A +USB_PID = 0x80D1 +USB_PRODUCT = "TinyS3" +USB_MANUFACTURER = "UnexpectedMaker" + +IDF_TARGET = esp32s3 + +INTERNAL_FLASH_FILESYSTEM = 1 +LONGINT_IMPL = MPZ + +# The default queue depth of 16 overflows on release builds, +# so increase it to 32. +CFLAGS += -DCFG_TUD_TASK_QUEUE_SZ=32 + +CIRCUITPY_ESP_FLASH_MODE=dio +CIRCUITPY_ESP_FLASH_FREQ=80m +CIRCUITPY_ESP_FLASH_SIZE=8MB + +# CIRCUITPY_BITBANG_NEOPIXEL = 1 + +CIRCUITPY_STAGE = 1 + +# Include these Python libraries in firmware. +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel diff --git a/ports/espressif/boards/unexpectedmaker_tinys3/pins.c b/ports/espressif/boards/unexpectedmaker_tinys3/pins.c new file mode 100644 index 0000000000..f1c429bf99 --- /dev/null +++ b/ports/espressif/boards/unexpectedmaker_tinys3/pins.c @@ -0,0 +1,96 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + + { MP_ROM_QSTR(MP_QSTR_IO0), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_GPIO0) }, + + { MP_ROM_QSTR(MP_QSTR_IO1), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_GPIO1) }, + + { MP_ROM_QSTR(MP_QSTR_IO2), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_GPIO2) }, + + { MP_ROM_QSTR(MP_QSTR_IO3), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_GPIO3) }, + + { MP_ROM_QSTR(MP_QSTR_IO4), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_GPIO4) }, + + { MP_ROM_QSTR(MP_QSTR_IO5), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_GPIO5) }, + + { MP_ROM_QSTR(MP_QSTR_IO6), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_GPIO6) }, + + { MP_ROM_QSTR(MP_QSTR_IO7), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_A6), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_GPIO7) }, + + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_IO8), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_A7), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_GPIO8) }, + + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_IO9), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_A8), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_GPIO9) }, + + { MP_ROM_QSTR(MP_QSTR_IO21), MP_ROM_PTR(&pin_GPIO21) }, + { MP_ROM_QSTR(MP_QSTR_D21), MP_ROM_PTR(&pin_GPIO21) }, + + { MP_ROM_QSTR(MP_QSTR_IO34), MP_ROM_PTR(&pin_GPIO34) }, + { MP_ROM_QSTR(MP_QSTR_D34), MP_ROM_PTR(&pin_GPIO34) }, + + { MP_ROM_QSTR(MP_QSTR_IO35), MP_ROM_PTR(&pin_GPIO35) }, + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO35) }, + { MP_ROM_QSTR(MP_QSTR_MO), MP_ROM_PTR(&pin_GPIO35) }, + { MP_ROM_QSTR(MP_QSTR_SDO), MP_ROM_PTR(&pin_GPIO35) }, + { MP_ROM_QSTR(MP_QSTR_D35), MP_ROM_PTR(&pin_GPIO35) }, + + { MP_ROM_QSTR(MP_QSTR_IO37), MP_ROM_PTR(&pin_GPIO37) }, + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO37) }, + { MP_ROM_QSTR(MP_QSTR_MI), MP_ROM_PTR(&pin_GPIO37) }, + { MP_ROM_QSTR(MP_QSTR_SDI), MP_ROM_PTR(&pin_GPIO37) }, + { MP_ROM_QSTR(MP_QSTR_D37), MP_ROM_PTR(&pin_GPIO37) }, + + { MP_ROM_QSTR(MP_QSTR_IO36), MP_ROM_PTR(&pin_GPIO36) }, + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO36) }, + { MP_ROM_QSTR(MP_QSTR_D36), MP_ROM_PTR(&pin_GPIO36) }, + + { MP_ROM_QSTR(MP_QSTR_IO43), MP_ROM_PTR(&pin_GPIO43) }, + { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_GPIO43) }, + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO43) }, + + { MP_ROM_QSTR(MP_QSTR_IO44), MP_ROM_PTR(&pin_GPIO44) }, + { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_GPIO44) }, + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO44) }, + + // Battery voltage sense pin + // I really don't know what name to use here. Adafruit use BATTERY & VOLTAGE_MONITOR + // I prefer VBAT or VBAT_SENSE + { MP_ROM_QSTR(MP_QSTR_BATTERY), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_VBAT), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_VBAT_SENSE), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_VOLTAGE_MONITOR), MP_ROM_PTR(&pin_GPIO10) }, + + // 5V present sense pin + { MP_ROM_QSTR(MP_QSTR_VBUS), MP_ROM_PTR(&pin_GPIO33) }, + { MP_ROM_QSTR(MP_QSTR_VBUS_SENSE), MP_ROM_PTR(&pin_GPIO33) }, + + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL_POWER), MP_ROM_PTR(&pin_GPIO17) }, + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO18) }, + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/espressif/boards/unexpectedmaker_tinys3/sdkconfig b/ports/espressif/boards/unexpectedmaker_tinys3/sdkconfig new file mode 100644 index 0000000000..0ac438450d --- /dev/null +++ b/ports/espressif/boards/unexpectedmaker_tinys3/sdkconfig @@ -0,0 +1,41 @@ +CONFIG_ESP32S3_SPIRAM_SUPPORT=y + +# +# SPI RAM config +# +# CONFIG_SPIRAM_MODE_OCT is not set +CONFIG_SPIRAM_MODE_QUAD=y +# CONFIG_SPIRAM_TYPE_AUTO is not set +# CONFIG_SPIRAM_TYPE_ESPPSRAM16 is not set +# CONFIG_SPIRAM_TYPE_ESPPSRAM32 is not set +CONFIG_SPIRAM_TYPE_ESPPSRAM64=y +CONFIG_SPIRAM_SIZE=8388608 + +# +# PSRAM clock and cs IO for ESP32S3 +# +CONFIG_DEFAULT_PSRAM_CLK_IO=30 +CONFIG_DEFAULT_PSRAM_CS_IO=26 +# end of PSRAM clock and cs IO for ESP32S3 + +# CONFIG_SPIRAM_FETCH_INSTRUCTIONS is not set +# CONFIG_SPIRAM_RODATA is not set +CONFIG_SPIRAM_SPEED_80M=y +# CONFIG_SPIRAM_SPEED_40M is not set +# CONFIG_SPIRAM_SPEED_26M is not set +# CONFIG_SPIRAM_SPEED_20M is not set +CONFIG_SPIRAM=y +CONFIG_SPIRAM_BOOT_INIT=y +# CONFIG_SPIRAM_IGNORE_NOTFOUND is not set +CONFIG_SPIRAM_USE_MEMMAP=y +# CONFIG_SPIRAM_USE_CAPS_ALLOC is not set +# CONFIG_SPIRAM_USE_MALLOC is not set +# CONFIG_SPIRAM_MEMTEST=y +# CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY is not set +# end of SPI RAM config + +# +# LWIP +# +CONFIG_LWIP_LOCAL_HOSTNAME="UMTinyS3" +# end of LWIP diff --git a/ports/espressif/common-hal/_bleio/Adapter.c b/ports/espressif/common-hal/_bleio/Adapter.c new file mode 100644 index 0000000000..288a908546 --- /dev/null +++ b/ports/espressif/common-hal/_bleio/Adapter.c @@ -0,0 +1,572 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2018 Dan Halbert for Adafruit Industries + * Copyright (c) 2016 Glenn Ruben Bakke + * Copyright (c) 2018 Artur Pacholec + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include +#include +#include +#include + +#include "py/gc.h" +#include "py/objstr.h" +#include "py/runtime.h" +#include "supervisor/shared/bluetooth/bluetooth.h" +#include "supervisor/shared/safe_mode.h" +#include "supervisor/shared/tick.h" +#include "supervisor/usb.h" +#include "shared-bindings/_bleio/__init__.h" +#include "shared-bindings/_bleio/Adapter.h" +#include "shared-bindings/_bleio/Address.h" +#include "shared-bindings/nvm/ByteArray.h" +#include "shared-bindings/_bleio/Connection.h" +#include "shared-bindings/_bleio/ScanEntry.h" +#include "shared-bindings/time/__init__.h" + +#include "controller/ble_ll_adv.h" +#include "nimble/hci_common.h" +#include "nimble/nimble_port.h" +#include "nimble/nimble_port_freertos.h" +#include "host/ble_gap.h" +#include "host/util/util.h" +#include "services/gap/ble_svc_gap.h" + +#include "common-hal/_bleio/Connection.h" + +#include "esp_bt.h" +#include "esp_nimble_hci.h" + +bleio_connection_internal_t bleio_connections[BLEIO_TOTAL_CONNECTION_COUNT]; + +// static void bluetooth_adapter_background(void *data) { +// supervisor_bluetooth_background(); +// bleio_background(); +// } + +bool ble_active = false; + +static void nimble_host_task(void *param) { + nimble_port_run(); + nimble_port_freertos_deinit(); +} + +static TaskHandle_t cp_task = NULL; + +static void _on_sync(void) { + int rc = ble_hs_util_ensure_addr(0); + assert(rc == 0); + + xTaskNotifyGive(cp_task); +} + +void common_hal_bleio_adapter_set_enabled(bleio_adapter_obj_t *self, bool enabled) { + const bool is_enabled = common_hal_bleio_adapter_get_enabled(self); + + // Don't enable or disable twice + if (is_enabled == enabled) { + return; + } + + if (enabled) { + esp_nimble_hci_and_controller_init(); + nimble_port_init(); + // ble_hs_cfg.reset_cb = blecent_on_reset; + ble_hs_cfg.sync_cb = _on_sync; + // ble_hs_cfg.store_status_cb = ble_store_util_status_rr; + ble_svc_gap_device_name_set("CIRCUITPY"); + + // Clear all of the internal connection objects. + for (size_t i = 0; i < BLEIO_TOTAL_CONNECTION_COUNT; i++) { + bleio_connection_internal_t *connection = &bleio_connections[i]; + // Reset connection. + connection->conn_handle = BLEIO_HANDLE_INVALID; + } + + cp_task = xTaskGetCurrentTaskHandle(); + + nimble_port_freertos_init(nimble_host_task); + // Wait for sync. + ulTaskNotifyTake(pdTRUE, pdMS_TO_TICKS(200)); + } else { + nimble_port_stop(); + } +} + +bool common_hal_bleio_adapter_get_enabled(bleio_adapter_obj_t *self) { + return xTaskGetHandle("ble") != NULL; +} + +bleio_address_obj_t *common_hal_bleio_adapter_get_address(bleio_adapter_obj_t *self) { + uint8_t address_bytes[6]; + uint8_t address_type = BLE_ADDR_RANDOM; + ble_hs_id_infer_auto(0, &address_type); + int result = ble_hs_id_copy_addr(address_type, address_bytes, NULL); + if (result != 0) { + return NULL; + } + + bleio_address_obj_t *address = m_new_obj(bleio_address_obj_t); + address->base.type = &bleio_address_type; + common_hal_bleio_address_construct(address, address_bytes, BLEIO_ADDRESS_TYPE_RANDOM_STATIC); + return address; +} + +bool common_hal_bleio_adapter_set_address(bleio_adapter_obj_t *self, bleio_address_obj_t *address) { + if (address->type != BLEIO_ADDRESS_TYPE_RANDOM_STATIC) { + return false; + } + mp_buffer_info_t bufinfo; + if (!mp_get_buffer(address->bytes, &bufinfo, MP_BUFFER_READ)) { + return false; + } + int result = ble_hs_id_set_rnd(bufinfo.buf); + return result == 0; +} + +mp_obj_str_t *common_hal_bleio_adapter_get_name(bleio_adapter_obj_t *self) { + const char *name = ble_svc_gap_device_name(); + + return mp_obj_new_str(name, strlen(name)); +} + +void common_hal_bleio_adapter_set_name(bleio_adapter_obj_t *self, const char *name) { + ble_svc_gap_device_name_set(name); +} + +static int _scan_event(struct ble_gap_event *event, void *scan_results_in) { + bleio_scanresults_obj_t *scan_results = (bleio_scanresults_obj_t *)scan_results_in; + + if (event->type == BLE_GAP_EVENT_DISC_COMPLETE) { + shared_module_bleio_scanresults_set_done(scan_results, true); + return 0; + } + + if (event->type != BLE_GAP_EVENT_DISC && event->type != BLE_GAP_EVENT_EXT_DISC) { + #if CIRCUITPY_VERBOSE_BLE + mp_printf(&mp_plat_print, "Unsupported scan event %d\n", event->type); + #endif + return 0; + } + + if (event->type == BLE_GAP_EVENT_DISC) { + // Legacy advertisement + struct ble_gap_disc_desc *disc = &event->disc; + bool connectable = disc->event_type == BLE_HCI_ADV_RPT_EVTYPE_ADV_IND || + disc->event_type == BLE_HCI_ADV_RPT_EVTYPE_DIR_IND; + shared_module_bleio_scanresults_append(scan_results, + supervisor_ticks_ms64(), + connectable, + disc->event_type == BLE_HCI_ADV_RPT_EVTYPE_SCAN_RSP, + disc->rssi, + disc->addr.val, + disc->addr.type, + disc->data, + disc->length_data); + } else { + // Extended advertisement + struct ble_gap_ext_disc_desc *disc = &event->ext_disc; + shared_module_bleio_scanresults_append(scan_results, + supervisor_ticks_ms64(), + (disc->props & BLE_HCI_ADV_CONN_MASK) != 0, + (disc->props & BLE_HCI_ADV_SCAN_MASK) != 0, + disc->rssi, + disc->addr.val, + disc->addr.type, + disc->data, + disc->length_data); + } + + return 0; +} + +mp_obj_t common_hal_bleio_adapter_start_scan(bleio_adapter_obj_t *self, uint8_t *prefixes, + size_t prefix_length, bool extended, mp_int_t buffer_size, mp_float_t timeout, + mp_float_t interval, mp_float_t window, mp_int_t minimum_rssi, bool active) { + if (self->scan_results != NULL) { + if (!shared_module_bleio_scanresults_get_done(self->scan_results)) { + mp_raise_bleio_BluetoothError(translate("Scan already in progess. Stop with stop_scan.")); + } + self->scan_results = NULL; + } + + self->scan_results = shared_module_bleio_new_scanresults(buffer_size, prefixes, prefix_length, minimum_rssi); + // size_t max_packet_size = extended ? BLE_HCI_MAX_EXT_ADV_DATA_LEN : BLE_HCI_MAX_ADV_DATA_LEN; + + uint8_t own_addr_type; + struct ble_gap_disc_params disc_params; + + /* Figure out address to use while advertising (no privacy for now) */ + int privacy = 0; + CHECK_NIMBLE_ERROR(ble_hs_id_infer_auto(privacy, &own_addr_type)); + + disc_params.filter_duplicates = 0; + disc_params.passive = !active; + disc_params.itvl = interval / 0.625; + disc_params.window = window / 0.625; + disc_params.filter_policy = 0; + disc_params.limited = 0; + + size_t duration_ms = timeout * 1000; + if (duration_ms == 0) { + duration_ms = BLE_HS_FOREVER; + } + + CHECK_NIMBLE_ERROR(ble_gap_disc(own_addr_type, duration_ms, &disc_params, + _scan_event, self->scan_results)); + + return MP_OBJ_FROM_PTR(self->scan_results); +} + +void common_hal_bleio_adapter_stop_scan(bleio_adapter_obj_t *self) { + if (self->scan_results == NULL) { + return; + } + ble_gap_disc_cancel(); + shared_module_bleio_scanresults_set_done(self->scan_results, true); + self->scan_results = NULL; +} + +STATIC void _convert_address(const bleio_address_obj_t *address, ble_addr_t *nimble_address) { + nimble_address->type = address->type; + mp_buffer_info_t address_buf_info; + mp_get_buffer_raise(address->bytes, &address_buf_info, MP_BUFFER_READ); + memcpy(nimble_address->val, (uint8_t *)address_buf_info.buf, NUM_BLEIO_ADDRESS_BYTES); +} + +STATIC void _new_connection(uint16_t conn_handle) { + // Set the tx_power for the connection higher than the advertisement. + esp_ble_tx_power_set(conn_handle, ESP_PWR_LVL_N0); + + + // Find an empty connection. One must always be available because the SD has the same + // total connection limit. + bleio_connection_internal_t *connection; + for (size_t i = 0; i < BLEIO_TOTAL_CONNECTION_COUNT; i++) { + connection = &bleio_connections[i]; + if (connection->conn_handle == BLEIO_HANDLE_INVALID) { + break; + } + } + connection->conn_handle = conn_handle; + connection->connection_obj = mp_const_none; + connection->pair_status = PAIR_NOT_PAIRED; + connection->mtu = 0; + + // Change the callback for the connection. + ble_gap_set_event_cb(conn_handle, bleio_connection_event_cb, connection); +} + +mp_obj_t common_hal_bleio_adapter_connect(bleio_adapter_obj_t *self, bleio_address_obj_t *address, mp_float_t timeout) { + mp_raise_NotImplementedError(NULL); + + mp_raise_bleio_BluetoothError(translate("Failed to connect: internal error")); + + return mp_const_none; +} + +typedef struct { + struct os_mbuf mbuf; + struct os_mbuf_pkthdr hdr; +} os_mbuf_t; + +STATIC void _wrap_in_mbuf(const uint8_t *data, uint16_t len, os_mbuf_t *buf) { + struct os_mbuf *mbuf = &buf->mbuf; + mbuf->om_data = (uint8_t *)data, + mbuf->om_flags = 0; + mbuf->om_pkthdr_len = 0; + mbuf->om_len = len; + mbuf->om_next.sle_next = NULL; + + buf->hdr.omp_len = len; + + // Setting the pool to NULL will cause frees to fail. Hopefully that failure + // is ignored. + mbuf->om_omp = NULL; +} + +static int _advertising_event(struct ble_gap_event *event, void *self_in) { + bleio_adapter_obj_t *self = (bleio_adapter_obj_t *)self_in; + + #if CIRCUITPY_VERBOSE_BLE + mp_printf(&mp_plat_print, "Advertising event: %d\n", event->type); + #endif + switch (event->type) { + case BLE_GAP_EVENT_CONNECT: + // Spurious connect events can happen. + break; + + case BLE_GAP_EVENT_ADV_COMPLETE: + if (event->adv_complete.reason == NIMBLE_OK) { + _new_connection(event->adv_complete.conn_handle); + // Set connections objs back to NULL since we have a new + // connection and need a new tuple. + self->connection_objs = NULL; + } + // Other statuses indicate timeout or preemption. + common_hal_bleio_adapter_stop_advertising(self); + break; + + default: + #if CIRCUITPY_VERBOSE_BLE + // For debugging. + mp_printf(&mp_plat_print, "Unhandled advertising event: %d\n", event->type); + #endif + break; + } + return 0; +} + +uint32_t _common_hal_bleio_adapter_start_advertising(bleio_adapter_obj_t *self, + bool connectable, bool anonymous, uint32_t timeout, float interval, + const uint8_t *advertising_data, uint16_t advertising_data_len, + const uint8_t *scan_response_data, uint16_t scan_response_data_len, + mp_int_t tx_power, const bleio_address_obj_t *directed_to) { + + if (ble_gap_adv_active() && !self->user_advertising) { + return BLE_HS_EBUSY; + } + + uint32_t rc; + bool extended = advertising_data_len > BLE_ADV_LEGACY_DATA_MAX_LEN || + scan_response_data_len > BLE_ADV_LEGACY_DATA_MAX_LEN; + + ble_addr_t peer; + if (directed_to != NULL) { + _convert_address(directed_to, &peer); + } + + uint8_t own_addr_type; + // Anonymous addresses are still resolvable. (Following what the NRF + // implementation does.) + rc = ble_hs_id_infer_auto(anonymous, &own_addr_type); + if (rc != NIMBLE_OK) { + return rc; + } + + bool high_duty_directed = directed_to != NULL && interval <= 3.5 && timeout <= 1.3; + + struct ble_gap_ext_adv_params adv_params = { + .connectable = connectable, + .scannable = scan_response_data_len > 0, + .directed = directed_to != NULL, + .high_duty_directed = high_duty_directed, + .legacy_pdu = !extended, + .anonymous = anonymous, + .include_tx_power = extended, + .scan_req_notif = false, + .itvl_min = SEC_TO_UNITS(interval, UNIT_0_625_MS) + 0.5f, + .itvl_max = SEC_TO_UNITS(interval, UNIT_0_625_MS) + 0.5f, + .channel_map = 0, + .own_addr_type = own_addr_type, + .peer = peer, + .filter_policy = BLE_HCI_CONN_FILT_NO_WL, + .primary_phy = BLE_HCI_LE_PHY_1M, + .secondary_phy = BLE_HCI_LE_PHY_1M, + .tx_power = tx_power, + .sid = 0, + }; + + // Configure must come before setting payloads. + rc = ble_gap_ext_adv_configure(0, + &adv_params, + NULL, + _advertising_event, self); + if (rc != NIMBLE_OK) { + return rc; + } + + os_mbuf_t buf; + _wrap_in_mbuf(advertising_data, advertising_data_len, &buf); + // This copies the advertising data into buffers to send to the controller. + // Therefore, we don't need to worry about the lifetime of our copy. + rc = ble_gap_ext_adv_set_data(0, &buf.mbuf); + if (rc != NIMBLE_OK) { + return rc; + } + + if (scan_response_data_len > 0) { + _wrap_in_mbuf(scan_response_data, scan_response_data_len, &buf); + // This copies the advertising data into buffers to send to the controller. + // Therefore, we don't need to worry about the lifetime of our copy. + rc = ble_gap_ext_adv_rsp_set_data(0, &buf.mbuf); + if (rc != NIMBLE_OK) { + return rc; + } + } + + rc = ble_gap_ext_adv_start(0, timeout / 10, 0); + if (rc != NIMBLE_OK) { + return rc; + } + + return NIMBLE_OK; +} + +STATIC void check_data_fit(size_t data_len, bool connectable) { + if (data_len > MYNEWT_VAL(BLE_EXT_ADV_MAX_SIZE) || + (connectable && data_len > MYNEWT_VAL(BLE_EXT_ADV_MAX_SIZE))) { + mp_raise_ValueError(translate("Data too large for advertisement packet")); + } +} + +void common_hal_bleio_adapter_start_advertising(bleio_adapter_obj_t *self, bool connectable, + bool anonymous, uint32_t timeout, mp_float_t interval, + mp_buffer_info_t *advertising_data_bufinfo, mp_buffer_info_t *scan_response_data_bufinfo, + mp_int_t tx_power, const bleio_address_obj_t *directed_to) { + if (self->user_advertising) { + mp_raise_bleio_BluetoothError(translate("Already advertising.")); + } else { + // If the user isn't advertising, then the background is. So, stop the + // background advertising so the user can. + common_hal_bleio_adapter_stop_advertising(self); + } + // interval value has already been validated. + + check_data_fit(advertising_data_bufinfo->len, connectable); + check_data_fit(scan_response_data_bufinfo->len, connectable); + + if (advertising_data_bufinfo->len > 31 && scan_response_data_bufinfo->len > 0) { + mp_raise_bleio_BluetoothError(translate("Extended advertisements with scan response not supported.")); + } + + + if (advertising_data_bufinfo->len > 0 && directed_to != NULL) { + mp_raise_bleio_BluetoothError(translate("Data not supported with directed advertising")); + } + + if (anonymous) { + mp_raise_NotImplementedError(NULL); + } + + if (!timeout) { + timeout = BLE_HS_FOREVER; + } else if (timeout > INT32_MAX) { + mp_raise_bleio_BluetoothError(translate("Timeout is too long: Maximum timeout length is %d seconds"), + INT32_MAX / 1000); + } + + CHECK_NIMBLE_ERROR(_common_hal_bleio_adapter_start_advertising(self, connectable, anonymous, timeout, interval, + advertising_data_bufinfo->buf, + advertising_data_bufinfo->len, + scan_response_data_bufinfo->buf, + scan_response_data_bufinfo->len, + tx_power, + directed_to)); + self->user_advertising = true; +} + +void common_hal_bleio_adapter_stop_advertising(bleio_adapter_obj_t *self) { + int err_code = ble_gap_ext_adv_stop(0); + self->user_advertising = false; + + if ((err_code != NIMBLE_OK) && + (err_code != BLE_HS_EALREADY) && + (err_code != BLE_HS_EINVAL)) { + CHECK_NIMBLE_ERROR(err_code); + } +} + +bool common_hal_bleio_adapter_get_advertising(bleio_adapter_obj_t *self) { + return ble_gap_adv_active(); +} + +bool common_hal_bleio_adapter_get_connected(bleio_adapter_obj_t *self) { + for (size_t i = 0; i < BLEIO_TOTAL_CONNECTION_COUNT; i++) { + bleio_connection_internal_t *connection = &bleio_connections[i]; + if (connection->conn_handle != BLEIO_HANDLE_INVALID) { + return true; + } + } + return false; +} + +mp_obj_t common_hal_bleio_adapter_get_connections(bleio_adapter_obj_t *self) { + if (self->connection_objs != NULL) { + return self->connection_objs; + } + size_t total_connected = 0; + mp_obj_t items[BLEIO_TOTAL_CONNECTION_COUNT]; + for (size_t i = 0; i < BLEIO_TOTAL_CONNECTION_COUNT; i++) { + bleio_connection_internal_t *connection = &bleio_connections[i]; + if (connection->conn_handle != BLEIO_HANDLE_INVALID) { + if (connection->connection_obj == mp_const_none) { + connection->connection_obj = bleio_connection_new_from_internal(connection); + } + items[total_connected] = connection->connection_obj; + total_connected++; + } + } + self->connection_objs = mp_obj_new_tuple(total_connected, items); + return self->connection_objs; +} + +void common_hal_bleio_adapter_erase_bonding(bleio_adapter_obj_t *self) { + mp_raise_NotImplementedError(NULL); + // bonding_erase_storage(); +} + +bool common_hal_bleio_adapter_is_bonded_to_central(bleio_adapter_obj_t *self) { + mp_raise_NotImplementedError(NULL); + // return bonding_peripheral_bond_count() > 0; + return false; +} + +void bleio_adapter_gc_collect(bleio_adapter_obj_t *adapter) { + // We divide by size_t so that we can scan each 32-bit aligned value to see + // if it is a pointer. This allows us to change the structs without worrying + // about collecting new pointers. + gc_collect_root((void **)adapter, sizeof(bleio_adapter_obj_t) / (sizeof(size_t))); + gc_collect_root((void **)bleio_connections, sizeof(bleio_connections) / (sizeof(size_t))); +} + +void bleio_adapter_reset(bleio_adapter_obj_t *adapter) { + common_hal_bleio_adapter_stop_scan(adapter); + if (common_hal_bleio_adapter_get_advertising(adapter)) { + common_hal_bleio_adapter_stop_advertising(adapter); + } + + adapter->connection_objs = NULL; + for (size_t i = 0; i < BLEIO_TOTAL_CONNECTION_COUNT; i++) { + bleio_connection_internal_t *connection = &bleio_connections[i]; + // Disconnect all connections cleanly. + if (connection->conn_handle != BLEIO_HANDLE_INVALID) { + common_hal_bleio_connection_disconnect(connection); + } + connection->connection_obj = mp_const_none; + } + + // Wait up to 125 ms (128 ticks) for disconnect to complete. This should be + // greater than most connection intervals. + bool any_connected = false; + uint64_t start_ticks = supervisor_ticks_ms64(); + while (any_connected && supervisor_ticks_ms64() - start_ticks < 128) { + any_connected = false; + for (size_t i = 0; i < BLEIO_TOTAL_CONNECTION_COUNT; i++) { + bleio_connection_internal_t *connection = &bleio_connections[i]; + any_connected |= connection->conn_handle != BLEIO_HANDLE_INVALID; + } + } +} diff --git a/ports/espressif/common-hal/_bleio/Adapter.h b/ports/espressif/common-hal/_bleio/Adapter.h new file mode 100644 index 0000000000..3534c79809 --- /dev/null +++ b/ports/espressif/common-hal/_bleio/Adapter.h @@ -0,0 +1,60 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2018 Dan Halbert for Adafruit Industries + * Copyright (c) 2018 Artur Pacholec + * Copyright (c) 2016 Glenn Ruben Bakke + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_ADAPTER_H +#define MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_ADAPTER_H + +#include "py/obj.h" +#include "py/objtuple.h" + +#include "shared-bindings/_bleio/Connection.h" +#include "shared-bindings/_bleio/ScanResults.h" + +#include "supervisor/background_callback.h" + +#ifndef BLEIO_TOTAL_CONNECTION_COUNT +#define BLEIO_TOTAL_CONNECTION_COUNT 5 +#endif + +#define BLEIO_HANDLE_INVALID 0xffff + +extern bleio_connection_internal_t bleio_connections[BLEIO_TOTAL_CONNECTION_COUNT]; + +typedef struct { + mp_obj_base_t base; + bleio_scanresults_obj_t *scan_results; + mp_obj_t name; + mp_obj_tuple_t *connection_objs; + background_callback_t background_callback; + bool user_advertising; +} bleio_adapter_obj_t; + +void bleio_adapter_gc_collect(bleio_adapter_obj_t *adapter); +void bleio_adapter_reset(bleio_adapter_obj_t *adapter); + +#endif // MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_ADAPTER_H diff --git a/ports/espressif/common-hal/_bleio/Attribute.c b/ports/espressif/common-hal/_bleio/Attribute.c new file mode 100644 index 0000000000..179a3b58aa --- /dev/null +++ b/ports/espressif/common-hal/_bleio/Attribute.c @@ -0,0 +1,29 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Dan Halbert for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "shared-bindings/_bleio/Attribute.h" + +// Convert a _bleio security mode to a ble_gap_conn_sec_mode_t setting. diff --git a/shared-module/busio/I2C.h b/ports/espressif/common-hal/_bleio/Attribute.h similarity index 74% rename from shared-module/busio/I2C.h rename to ports/espressif/common-hal/_bleio/Attribute.h index e089ea367b..4612b6c6dd 100644 --- a/shared-module/busio/I2C.h +++ b/ports/espressif/common-hal/_bleio/Attribute.h @@ -3,7 +3,7 @@ * * The MIT License (MIT) * - * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries + * Copyright (c) 2018 Dan Halbert for Adafruit Industries * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -24,16 +24,9 @@ * THE SOFTWARE. */ -#ifndef MICROPY_INCLUDED_ATMEL_SAMD_SHARED_MODULE_BUSIO_I2C_H -#define MICROPY_INCLUDED_ATMEL_SAMD_SHARED_MODULE_BUSIO_I2C_H +#ifndef MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_ATTRIBUTE_H +#define MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_ATTRIBUTE_H -#include "shared-module/bitbangio/I2C.h" +#include "shared-module/_bleio/Attribute.h" -#include "py/obj.h" - -typedef struct { - mp_obj_base_t base; - bitbangio_i2c_obj_t bitbang; -} busio_i2c_obj_t; - -#endif // MICROPY_INCLUDED_ATMEL_SAMD_SHARED_MODULE_BUSIO_I2C_H +#endif // MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_ATTRIBUTE_H diff --git a/ports/espressif/common-hal/_bleio/Characteristic.c b/ports/espressif/common-hal/_bleio/Characteristic.c new file mode 100644 index 0000000000..161e17ea1a --- /dev/null +++ b/ports/espressif/common-hal/_bleio/Characteristic.c @@ -0,0 +1,127 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) Dan Halbert for Adafruit Industries + * Copyright (c) 2018 Artur Pacholec + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include + +#include "py/runtime.h" + +#include "shared-bindings/_bleio/__init__.h" +#include "shared-bindings/_bleio/Characteristic.h" +#include "shared-bindings/_bleio/Descriptor.h" +#include "shared-bindings/_bleio/Service.h" + +#include "common-hal/_bleio/Adapter.h" +// #include "common-hal/_bleio/bonding.h" + +void common_hal_bleio_characteristic_construct(bleio_characteristic_obj_t *self, bleio_service_obj_t *service, + uint16_t handle, bleio_uuid_obj_t *uuid, bleio_characteristic_properties_t props, + bleio_attribute_security_mode_t read_perm, bleio_attribute_security_mode_t write_perm, + mp_int_t max_length, bool fixed_length, mp_buffer_info_t *initial_value_bufinfo, + const char *user_description) { + mp_raise_NotImplementedError(NULL); + self->service = service; + self->uuid = uuid; + self->handle = BLEIO_HANDLE_INVALID; + self->props = props; + self->read_perm = read_perm; + self->write_perm = write_perm; + self->initial_value_len = 0; + self->initial_value = NULL; + if (initial_value_bufinfo != NULL) { + // Copy the initial value if it's on the heap. Otherwise it's internal and we may not be able + // to allocate. + self->initial_value_len = initial_value_bufinfo->len; + if (gc_alloc_possible()) { + if (gc_nbytes(initial_value_bufinfo->buf) > 0) { + uint8_t *initial_value = m_malloc(self->initial_value_len, false); + memcpy(initial_value, initial_value_bufinfo->buf, self->initial_value_len); + self->initial_value = initial_value; + } else { + self->initial_value = initial_value_bufinfo->buf; + } + self->descriptor_list = mp_obj_new_list(0, NULL); + } else { + self->initial_value = initial_value_bufinfo->buf; + self->descriptor_list = NULL; + } + } + + // const mp_int_t max_length_max = fixed_length ? BLE_GATTS_FIX_ATTR_LEN_MAX : BLE_GATTS_VAR_ATTR_LEN_MAX; + // if (max_length < 0 || max_length > max_length_max) { + // mp_raise_ValueError_varg(translate("max_length must be 0-%d when fixed_length is %s"), + // max_length_max, fixed_length ? "True" : "False"); + // } + // TODO: Implement this. + self->max_length = max_length; + self->fixed_length = fixed_length; + + if (service->is_remote) { + self->handle = handle; + } else { + common_hal_bleio_service_add_characteristic(self->service, self, initial_value_bufinfo, user_description); + } +} + +mp_obj_tuple_t *common_hal_bleio_characteristic_get_descriptors(bleio_characteristic_obj_t *self) { + if (self->descriptor_list == NULL) { + return mp_const_empty_tuple; + } + return mp_obj_new_tuple(self->descriptor_list->len, self->descriptor_list->items); +} + +bleio_service_obj_t *common_hal_bleio_characteristic_get_service(bleio_characteristic_obj_t *self) { + return self->service; +} + +size_t common_hal_bleio_characteristic_get_value(bleio_characteristic_obj_t *self, uint8_t *buf, size_t len) { + // TODO: Implement this. + return 0; +} + +size_t common_hal_bleio_characteristic_get_max_length(bleio_characteristic_obj_t *self) { + return self->max_length; +} + +void common_hal_bleio_characteristic_set_value(bleio_characteristic_obj_t *self, mp_buffer_info_t *bufinfo) { + // TODO: Implement this. +} + +bleio_uuid_obj_t *common_hal_bleio_characteristic_get_uuid(bleio_characteristic_obj_t *self) { + return self->uuid; +} + +bleio_characteristic_properties_t common_hal_bleio_characteristic_get_properties(bleio_characteristic_obj_t *self) { + return self->props; +} + +void common_hal_bleio_characteristic_add_descriptor(bleio_characteristic_obj_t *self, bleio_descriptor_obj_t *descriptor) { + // TODO: Implement this. +} + +void common_hal_bleio_characteristic_set_cccd(bleio_characteristic_obj_t *self, bool notify, bool indicate) { + // TODO: Implement this. +} diff --git a/ports/espressif/common-hal/_bleio/Characteristic.h b/ports/espressif/common-hal/_bleio/Characteristic.h new file mode 100644 index 0000000000..57195ea265 --- /dev/null +++ b/ports/espressif/common-hal/_bleio/Characteristic.h @@ -0,0 +1,56 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Dan Halbert for Adafruit Industries + * Copyright (c) 2018 Artur Pacholec + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_CHARACTERISTIC_H +#define MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_CHARACTERISTIC_H + +#include "shared-bindings/_bleio/Attribute.h" +#include "common-hal/_bleio/Descriptor.h" +#include "shared-module/_bleio/Characteristic.h" +#include "common-hal/_bleio/Service.h" +#include "common-hal/_bleio/UUID.h" + +typedef struct _bleio_characteristic_obj { + mp_obj_base_t base; + // Will be MP_OBJ_NULL before being assigned to a Service. + bleio_service_obj_t *service; + bleio_uuid_obj_t *uuid; + const uint8_t *initial_value; + uint16_t initial_value_len; + uint16_t max_length; + uint16_t handle; + bleio_characteristic_properties_t props; + bleio_attribute_security_mode_t read_perm; + bleio_attribute_security_mode_t write_perm; + mp_obj_list_t *descriptor_list; + uint16_t user_desc_handle; + uint16_t cccd_handle; + uint16_t sccd_handle; + bool fixed_length; +} bleio_characteristic_obj_t; + +#endif // MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_CHARACTERISTIC_H diff --git a/ports/espressif/common-hal/_bleio/CharacteristicBuffer.c b/ports/espressif/common-hal/_bleio/CharacteristicBuffer.c new file mode 100644 index 0000000000..bc6619cef4 --- /dev/null +++ b/ports/espressif/common-hal/_bleio/CharacteristicBuffer.c @@ -0,0 +1,95 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Dan Halbert for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include +#include + +#include "shared/runtime/interrupt_char.h" +#include "py/runtime.h" +#include "py/stream.h" + +#include "shared-bindings/_bleio/__init__.h" +#include "shared-bindings/_bleio/Connection.h" +#include "supervisor/shared/tick.h" +#include "common-hal/_bleio/CharacteristicBuffer.h" +#include "shared-bindings/_bleio/CharacteristicBuffer.h" + +void _common_hal_bleio_characteristic_buffer_construct(bleio_characteristic_buffer_obj_t *self, + bleio_characteristic_obj_t *characteristic, + mp_float_t timeout, + uint8_t *buffer, size_t buffer_size, + void *static_handler_entry) { + + mp_raise_NotImplementedError(NULL); + + self->characteristic = characteristic; + self->timeout_ms = timeout * 1000; + + self->ringbuf.buf = (uint8_t *)buffer; + self->ringbuf.size = buffer_size; + self->ringbuf.iget = 0; + self->ringbuf.iput = 0; + +} + +// Assumes that timeout and buffer_size have been validated before call. +void common_hal_bleio_characteristic_buffer_construct(bleio_characteristic_buffer_obj_t *self, + bleio_characteristic_obj_t *characteristic, + mp_float_t timeout, + size_t buffer_size) { + uint8_t *buffer = m_malloc(buffer_size, true); + _common_hal_bleio_characteristic_buffer_construct(self, characteristic, timeout, buffer, buffer_size, NULL); +} + +uint32_t common_hal_bleio_characteristic_buffer_read(bleio_characteristic_buffer_obj_t *self, uint8_t *data, size_t len, int *errcode) { + // TODO: Implement this. + return 0; +} + +uint32_t common_hal_bleio_characteristic_buffer_rx_characters_available(bleio_characteristic_buffer_obj_t *self) { + // TODO: Implement this. + return 0; +} + +void common_hal_bleio_characteristic_buffer_clear_rx_buffer(bleio_characteristic_buffer_obj_t *self) { + // TODO: Implement this. +} + +bool common_hal_bleio_characteristic_buffer_deinited(bleio_characteristic_buffer_obj_t *self) { + return self->characteristic == NULL; +} + +void common_hal_bleio_characteristic_buffer_deinit(bleio_characteristic_buffer_obj_t *self) { + // TODO: Implement this. +} + +bool common_hal_bleio_characteristic_buffer_connected(bleio_characteristic_buffer_obj_t *self) { + return self->characteristic != NULL && + self->characteristic->service != NULL && + (!self->characteristic->service->is_remote || + (self->characteristic->service->connection != MP_OBJ_NULL && + common_hal_bleio_connection_get_connected(self->characteristic->service->connection))); +} diff --git a/ports/espressif/common-hal/_bleio/CharacteristicBuffer.h b/ports/espressif/common-hal/_bleio/CharacteristicBuffer.h new file mode 100644 index 0000000000..e5247c20f7 --- /dev/null +++ b/ports/espressif/common-hal/_bleio/CharacteristicBuffer.h @@ -0,0 +1,41 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Dan Halbert for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_CHARACTERISTICBUFFER_H +#define MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_CHARACTERISTICBUFFER_H + +#include "py/ringbuf.h" +#include "shared-bindings/_bleio/Characteristic.h" + +typedef struct { + mp_obj_base_t base; + bleio_characteristic_obj_t *characteristic; + uint32_t timeout_ms; + // Ring buffer storing consecutive incoming values. + ringbuf_t ringbuf; +} bleio_characteristic_buffer_obj_t; + +#endif // MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_CHARACTERISTICBUFFER_H diff --git a/ports/espressif/common-hal/_bleio/Connection.c b/ports/espressif/common-hal/_bleio/Connection.c new file mode 100644 index 0000000000..a3668073a8 --- /dev/null +++ b/ports/espressif/common-hal/_bleio/Connection.c @@ -0,0 +1,166 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2018 Dan Halbert for Adafruit Industries + * Copyright (c) 2018 Artur Pacholec + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "shared-bindings/_bleio/Connection.h" + +#include +#include + +#include "shared/runtime/interrupt_char.h" +#include "py/gc.h" +#include "py/objlist.h" +#include "py/objstr.h" +#include "py/qstr.h" +#include "py/runtime.h" +#include "shared-bindings/_bleio/__init__.h" +#include "shared-bindings/_bleio/Adapter.h" +#include "shared-bindings/_bleio/Attribute.h" +#include "shared-bindings/_bleio/Characteristic.h" +#include "shared-bindings/_bleio/Service.h" +#include "shared-bindings/_bleio/UUID.h" +#include "supervisor/shared/tick.h" + +// #include "common-hal/_bleio/bonding.h" + +#include "host/ble_att.h" + +int bleio_connection_event_cb(struct ble_gap_event *event, void *connection_in) { + bleio_connection_internal_t *connection = (bleio_connection_internal_t *)connection_in; + + switch (event->type) { + case BLE_GAP_EVENT_DISCONNECT: { + connection->conn_handle = BLEIO_HANDLE_INVALID; + connection->pair_status = PAIR_NOT_PAIRED; + + #if CIRCUITPY_VERBOSE_BLE + mp_printf(&mp_plat_print, "disconnected %02x\n", event->disconnect.reason); + #endif + if (connection->connection_obj != mp_const_none) { + bleio_connection_obj_t *obj = connection->connection_obj; + obj->connection = NULL; + obj->disconnect_reason = event->disconnect.reason; + } + + break; + } + + case BLE_GAP_EVENT_PHY_UPDATE_COMPLETE: { + break; + } + + default: + #if CIRCUITPY_VERBOSE_BLE + mp_printf(&mp_plat_print, "Unhandled connection event: %d\n", event->type); + #endif + return 0; + } + return 0; +} + +bool common_hal_bleio_connection_get_paired(bleio_connection_obj_t *self) { + if (self->connection == NULL) { + return false; + } + return self->connection->pair_status == PAIR_PAIRED; +} + +bool common_hal_bleio_connection_get_connected(bleio_connection_obj_t *self) { + if (self->connection == NULL) { + return false; + } + return self->connection->conn_handle != BLEIO_HANDLE_INVALID; +} + +void common_hal_bleio_connection_disconnect(bleio_connection_internal_t *self) { + // TODO: Implement this. +} + +void common_hal_bleio_connection_pair(bleio_connection_internal_t *self, bool bond) { + // TODO: Implement this. +} + +mp_float_t common_hal_bleio_connection_get_connection_interval(bleio_connection_internal_t *self) { + // TODO: Implement this. + while (self->conn_params_updating && !mp_hal_is_interrupted()) { + RUN_BACKGROUND_TASKS; + } + return 0; +} + +// Return the current negotiated MTU length, minus overhead. +mp_int_t common_hal_bleio_connection_get_max_packet_length(bleio_connection_internal_t *self) { + return (self->mtu == 0 ? BLE_ATT_MTU_DFLT : self->mtu) - 3; +} + +void common_hal_bleio_connection_set_connection_interval(bleio_connection_internal_t *self, mp_float_t new_interval) { + self->conn_params_updating = true; + // TODO: Implement this. +} + +mp_obj_tuple_t *common_hal_bleio_connection_discover_remote_services(bleio_connection_obj_t *self, mp_obj_t service_uuids_whitelist) { + bleio_connection_ensure_connected(self); + // Convert to a tuple and then clear the list so the callee will take ownership. + mp_obj_tuple_t *services_tuple = + mp_obj_new_tuple(self->connection->remote_service_list->len, + self->connection->remote_service_list->items); + mp_obj_list_clear(MP_OBJ_FROM_PTR(self->connection->remote_service_list)); + + // TODO: Implement this. + return services_tuple; +} + +uint16_t bleio_connection_get_conn_handle(bleio_connection_obj_t *self) { + if (self == NULL || self->connection == NULL) { + return BLEIO_HANDLE_INVALID; + } + return self->connection->conn_handle; +} + +mp_obj_t bleio_connection_new_from_internal(bleio_connection_internal_t *internal) { + if (internal->connection_obj != mp_const_none) { + return internal->connection_obj; + } + bleio_connection_obj_t *connection = m_new_obj(bleio_connection_obj_t); + connection->base.type = &bleio_connection_type; + connection->connection = internal; + internal->connection_obj = connection; + + return MP_OBJ_FROM_PTR(connection); +} + +// Find the connection that uses the given conn_handle. Return NULL if not found. +bleio_connection_internal_t *bleio_conn_handle_to_connection(uint16_t conn_handle) { + bleio_connection_internal_t *connection; + for (size_t i = 0; i < BLEIO_TOTAL_CONNECTION_COUNT; i++) { + connection = &bleio_connections[i]; + if (connection->conn_handle == conn_handle) { + return connection; + } + } + + return NULL; +} diff --git a/ports/espressif/common-hal/_bleio/Connection.h b/ports/espressif/common-hal/_bleio/Connection.h new file mode 100644 index 0000000000..73bfeff19c --- /dev/null +++ b/ports/espressif/common-hal/_bleio/Connection.h @@ -0,0 +1,92 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Dan Halbert for Adafruit Industries + * Copyright (c) 2018 Artur Pacholec + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_CONNECTION_H +#define MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_CONNECTION_H + +#include + +#include "py/obj.h" +#include "py/objlist.h" + +#include "common-hal/_bleio/__init__.h" +// #include "common-hal/_bleio/bonding.h" +#include "shared-module/_bleio/Address.h" +#include "common-hal/_bleio/Service.h" + +#include "host/ble_gap.h" + +typedef enum { + PAIR_NOT_PAIRED, + PAIR_WAITING, + PAIR_PAIRED, +} pair_status_t; + +// We split the Connection object into two so that the internal mechanics can live outside of the +// VM. If it were one object, then we'd risk user code seeing a connection object of theirs be +// reused. +typedef struct { + uint16_t conn_handle; + bool is_central; + // Remote services discovered when this peripheral is acting as a client. + mp_obj_list_t *remote_service_list; + // The advertising data and scan response buffers are held by us, not by the SD, so we must + // maintain them and not change it. If we need to change the contents during advertising, + // there are tricks to get the SD to notice (see DevZone - TBS). + // bonding_keys_t bonding_keys; + // EDIV: Encrypted Diversifier: Identifies LTK during legacy pairing. + uint16_t ediv; + volatile pair_status_t pair_status; + uint8_t sec_status; // Internal security status. + mp_obj_t connection_obj; + volatile bool conn_params_updating; + uint16_t mtu; + // Request that CCCD values for this connection be saved, using sys_attr values. + volatile bool do_bond_cccds; + // Request that security key info for this connection be saved. + volatile bool do_bond_keys; + // Time of setting do_bond_ccds: we delay a bit to consolidate multiple CCCD changes + // into one write. Time is currently in ticks_ms. + uint64_t do_bond_cccds_request_time; +} bleio_connection_internal_t; + +typedef struct { + mp_obj_base_t base; + bleio_connection_internal_t *connection; + // The HCI disconnect reason. + uint8_t disconnect_reason; +} bleio_connection_obj_t; + +void bleio_connection_clear(bleio_connection_internal_t *self); + +int bleio_connection_event_cb(struct ble_gap_event *event, void *connection_in); + +uint16_t bleio_connection_get_conn_handle(bleio_connection_obj_t *self); +mp_obj_t bleio_connection_new_from_internal(bleio_connection_internal_t *connection); +bleio_connection_internal_t *bleio_conn_handle_to_connection(uint16_t conn_handle); + +#endif // MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_CONNECTION_H diff --git a/ports/espressif/common-hal/_bleio/Descriptor.c b/ports/espressif/common-hal/_bleio/Descriptor.c new file mode 100644 index 0000000000..016626dbf9 --- /dev/null +++ b/ports/espressif/common-hal/_bleio/Descriptor.c @@ -0,0 +1,97 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Dan Halbert for Adafruit Industries + * Copyright (c) 2018 Artur Pacholec + * Copyright (c) 2016 Glenn Ruben Bakke + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "py/runtime.h" + +#include "shared-bindings/_bleio/__init__.h" +#include "shared-bindings/_bleio/Descriptor.h" +#include "shared-bindings/_bleio/Service.h" +#include "shared-bindings/_bleio/UUID.h" + +#include "host/ble_att.h" + +void common_hal_bleio_descriptor_construct(bleio_descriptor_obj_t *self, bleio_characteristic_obj_t *characteristic, bleio_uuid_obj_t *uuid, bleio_attribute_security_mode_t read_perm, bleio_attribute_security_mode_t write_perm, mp_int_t max_length, bool fixed_length, mp_buffer_info_t *initial_value_bufinfo) { + mp_raise_NotImplementedError(NULL); + self->characteristic = characteristic; + self->uuid = uuid; + self->handle = BLEIO_HANDLE_INVALID; + self->read_perm = read_perm; + self->write_perm = write_perm; + self->initial_value = mp_obj_new_bytes(initial_value_bufinfo->buf, initial_value_bufinfo->len); + + const mp_int_t max_length_max = BLE_ATT_ATTR_MAX_LEN; + if (max_length < 0 || max_length > max_length_max) { + mp_raise_ValueError_varg(translate("max_length must be 0-%d when fixed_length is %s"), + max_length_max, fixed_length ? "True" : "False"); + } + self->max_length = max_length; + self->fixed_length = fixed_length; +} + +bleio_uuid_obj_t *common_hal_bleio_descriptor_get_uuid(bleio_descriptor_obj_t *self) { + return self->uuid; +} + +bleio_characteristic_obj_t *common_hal_bleio_descriptor_get_characteristic(bleio_descriptor_obj_t *self) { + return self->characteristic; +} + +size_t common_hal_bleio_descriptor_get_value(bleio_descriptor_obj_t *self, uint8_t *buf, size_t len) { + // Do GATT operations only if this descriptor has been registered + if (self->handle != BLEIO_HANDLE_INVALID) { + uint16_t conn_handle = bleio_connection_get_conn_handle(self->characteristic->service->connection); + (void)conn_handle; + } + + // TODO: Implement this. + + return 0; +} + +void common_hal_bleio_descriptor_set_value(bleio_descriptor_obj_t *self, mp_buffer_info_t *bufinfo) { + // TODO: Implement this. + // Do GATT operations only if this descriptor has been registered. + if (self->handle != BLEIO_HANDLE_INVALID) { + // uint16_t conn_handle = bleio_connection_get_conn_handle(self->characteristic->service->connection); + if (common_hal_bleio_service_get_is_remote(self->characteristic->service)) { + // false means WRITE_REQ, not write-no-response + // common_hal_bleio_gattc_write(self->handle, conn_handle, bufinfo, false); + } else { + // Validate data length for local descriptors only. + if (self->fixed_length && bufinfo->len != self->max_length) { + mp_raise_ValueError(translate("Value length != required fixed length")); + } + if (bufinfo->len > self->max_length) { + mp_raise_ValueError(translate("Value length > max_length")); + } + + // common_hal_bleio_gatts_write(self->handle, conn_handle, bufinfo); + } + } + +} diff --git a/ports/espressif/common-hal/_bleio/Descriptor.h b/ports/espressif/common-hal/_bleio/Descriptor.h new file mode 100644 index 0000000000..4a2b298ca2 --- /dev/null +++ b/ports/espressif/common-hal/_bleio/Descriptor.h @@ -0,0 +1,52 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2018 Dan Halbert for Adafruit Industries + * Copyright (c) 2018 Artur Pacholec + * Copyright (c) 2016 Glenn Ruben Bakke + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_DESCRIPTOR_H +#define MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_DESCRIPTOR_H + +#include "py/obj.h" + +#include "common-hal/_bleio/UUID.h" + +// Forward declare characteristic because it includes a Descriptor. +struct _bleio_characteristic_obj; + +typedef struct _bleio_descriptor_obj { + mp_obj_base_t base; + // Will be MP_OBJ_NULL before being assigned to a Characteristic. + struct _bleio_characteristic_obj *characteristic; + bleio_uuid_obj_t *uuid; + mp_obj_t initial_value; + uint16_t max_length; + bool fixed_length; + uint16_t handle; + bleio_attribute_security_mode_t read_perm; + bleio_attribute_security_mode_t write_perm; +} bleio_descriptor_obj_t; + +#endif // MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_DESCRIPTOR_H diff --git a/ports/espressif/common-hal/_bleio/PacketBuffer.c b/ports/espressif/common-hal/_bleio/PacketBuffer.c new file mode 100644 index 0000000000..b318ad27d7 --- /dev/null +++ b/ports/espressif/common-hal/_bleio/PacketBuffer.c @@ -0,0 +1,275 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019-2020 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include +#include + +#include "shared/runtime/interrupt_char.h" +#include "py/runtime.h" +#include "py/stream.h" + +#include "shared-bindings/_bleio/__init__.h" +#include "shared-bindings/_bleio/Connection.h" +#include "shared-bindings/_bleio/PacketBuffer.h" +#include "supervisor/shared/tick.h" + +#include "supervisor/shared/bluetooth/serial.h" + +#include "host/ble_att.h" + +void _common_hal_bleio_packet_buffer_construct( + bleio_packet_buffer_obj_t *self, bleio_characteristic_obj_t *characteristic, + uint32_t *incoming_buffer, size_t incoming_buffer_size, + uint32_t *outgoing_buffer1, uint32_t *outgoing_buffer2, size_t max_packet_size, + void *static_handler_entry) { + + mp_raise_NotImplementedError(NULL); + self->characteristic = characteristic; + self->client = self->characteristic->service->is_remote; + self->max_packet_size = max_packet_size; + bleio_characteristic_properties_t incoming = self->characteristic->props & (CHAR_PROP_WRITE_NO_RESPONSE | CHAR_PROP_WRITE); + bleio_characteristic_properties_t outgoing = self->characteristic->props & (CHAR_PROP_NOTIFY | CHAR_PROP_INDICATE); + + if (self->client) { + // Swap if we're the client. + bleio_characteristic_properties_t temp = incoming; + incoming = outgoing; + outgoing = temp; + self->conn_handle = bleio_connection_get_conn_handle(MP_OBJ_TO_PTR(self->characteristic->service->connection)); + } else { + self->conn_handle = BLEIO_HANDLE_INVALID; + } + + if (incoming) { + self->ringbuf.buf = (uint8_t *)incoming_buffer; + self->ringbuf.size = incoming_buffer_size; + self->ringbuf.iget = 0; + self->ringbuf.iput = 0; + } + + self->packet_queued = false; + self->pending_index = 0; + self->pending_size = 0; + self->outgoing[0] = outgoing_buffer1; + self->outgoing[1] = outgoing_buffer2; + +} + +void common_hal_bleio_packet_buffer_construct( + bleio_packet_buffer_obj_t *self, bleio_characteristic_obj_t *characteristic, + size_t buffer_size, size_t max_packet_size) { + + // Cap the packet size to our implementation limits. + max_packet_size = MIN(max_packet_size, BLE_ATT_ATTR_MAX_LEN - 3); + + bleio_characteristic_properties_t incoming = characteristic->props & (CHAR_PROP_WRITE_NO_RESPONSE | CHAR_PROP_WRITE); + bleio_characteristic_properties_t outgoing = characteristic->props & (CHAR_PROP_NOTIFY | CHAR_PROP_INDICATE); + if (characteristic->service->is_remote) { + // Swap if we're the client. + bleio_characteristic_properties_t temp = incoming; + incoming = outgoing; + outgoing = temp; + } + size_t incoming_buffer_size = 0; + uint32_t *incoming_buffer = NULL; + if (incoming) { + incoming_buffer_size = buffer_size * (sizeof(uint16_t) + max_packet_size); + incoming_buffer = m_malloc(incoming_buffer_size, false); + } + + uint32_t *outgoing1 = NULL; + uint32_t *outgoing2 = NULL; + if (outgoing) { + outgoing1 = m_malloc(max_packet_size, false); + outgoing2 = m_malloc(max_packet_size, false); + } + _common_hal_bleio_packet_buffer_construct(self, characteristic, + incoming_buffer, incoming_buffer_size, + outgoing1, outgoing2, max_packet_size, + NULL); +} + +mp_int_t common_hal_bleio_packet_buffer_readinto(bleio_packet_buffer_obj_t *self, uint8_t *data, size_t len) { + if (ringbuf_num_filled(&self->ringbuf) < 2) { + return 0; + } + + // Copy received data. Lock out write interrupt handler while copying. + // TODO: Implement this. + return 0; +} + +mp_int_t common_hal_bleio_packet_buffer_write(bleio_packet_buffer_obj_t *self, const uint8_t *data, size_t len, uint8_t *header, size_t header_len) { + if (self->outgoing[0] == NULL) { + mp_raise_bleio_BluetoothError(translate("Writes not supported on Characteristic")); + } + if (self->conn_handle == BLEIO_HANDLE_INVALID) { + return -1; + } + mp_int_t outgoing_packet_length = common_hal_bleio_packet_buffer_get_outgoing_packet_length(self); + if (outgoing_packet_length < 0) { + return -1; + } + + mp_int_t total_len = len + header_len; + if (total_len > outgoing_packet_length) { + // Supplied data will not fit in a single BLE packet. + mp_raise_ValueError_varg(translate("Total data to write is larger than %q"), MP_QSTR_outgoing_packet_length); + } + if (total_len > self->max_packet_size) { + // Supplied data will not fit in a single BLE packet. + mp_raise_ValueError_varg(translate("Total data to write is larger than %q"), MP_QSTR_max_packet_size); + } + outgoing_packet_length = MIN(outgoing_packet_length, self->max_packet_size); + + if (len + self->pending_size > (size_t)outgoing_packet_length) { + // No room to append len bytes to packet. Wait until we get a free buffer, + // and keep checking that we haven't been disconnected. + while (self->pending_size != 0 && + self->conn_handle != BLEIO_HANDLE_INVALID && + !mp_hal_is_interrupted()) { + RUN_BACKGROUND_TASKS; + } + } + if (self->conn_handle == BLEIO_HANDLE_INVALID || + mp_hal_is_interrupted()) { + return -1; + } + + size_t num_bytes_written = 0; + + uint32_t *pending = self->outgoing[self->pending_index]; + + if (self->pending_size == 0) { + memcpy(pending, header, header_len); + self->pending_size += header_len; + num_bytes_written += header_len; + } + memcpy(((uint8_t *)pending) + self->pending_size, data, len); + self->pending_size += len; + num_bytes_written += len; + + // TODO: Implement this. + + // If no writes are queued then sneak in this data. + if (!self->packet_queued) { + } + return num_bytes_written; +} + +mp_int_t common_hal_bleio_packet_buffer_get_incoming_packet_length(bleio_packet_buffer_obj_t *self) { + // If this PacketBuffer is coming from a remote service via NOTIFY or INDICATE + // the maximum size is what can be sent in one + // BLE packet. But we must be connected to know that value. + // + // Otherwise it can be as long as the characteristic + // will permit, whether or not we're connected. + + if (self->characteristic == NULL) { + return -1; + } + + if (self->characteristic->service != NULL && + self->characteristic->service->is_remote && + (common_hal_bleio_characteristic_get_properties(self->characteristic) & + (CHAR_PROP_INDICATE | CHAR_PROP_NOTIFY))) { + // We are talking to a remote service, and data is arriving via NOTIFY or INDICATE. + if (self->conn_handle != BLEIO_HANDLE_INVALID) { + bleio_connection_internal_t *connection = bleio_conn_handle_to_connection(self->conn_handle); + if (connection) { + return common_hal_bleio_connection_get_max_packet_length(connection); + } + } + // There's no current connection, so we don't know the MTU, and + // we can't tell what the largest incoming packet length would be. + return -1; + } + return self->characteristic->max_length; +} + +mp_int_t common_hal_bleio_packet_buffer_get_outgoing_packet_length(bleio_packet_buffer_obj_t *self) { + // If we are sending data via NOTIFY or INDICATE, the maximum size + // is what can be sent in one BLE packet. But we must be connected + // to know that value. + // + // Otherwise it can be as long as the characteristic + // will permit, whether or not we're connected. + + if (self->characteristic == NULL) { + return -1; + } + + if (self->characteristic->service != NULL && + !self->characteristic->service->is_remote && + (common_hal_bleio_characteristic_get_properties(self->characteristic) & + (CHAR_PROP_INDICATE | CHAR_PROP_NOTIFY))) { + // We are sending to a client, via NOTIFY or INDICATE. + if (self->conn_handle != BLEIO_HANDLE_INVALID) { + bleio_connection_internal_t *connection = bleio_conn_handle_to_connection(self->conn_handle); + if (connection) { + return MIN(MIN(common_hal_bleio_connection_get_max_packet_length(connection), + self->max_packet_size), + self->characteristic->max_length); + } + } + // There's no current connection, so we don't know the MTU, and + // we can't tell what the largest outgoing packet length would be. + return -1; + } + // If we are talking to a remote service, we'll be bound by the MTU. (We don't actually + // know the max size of the remote characteristic.) + if (self->characteristic->service != NULL && + self->characteristic->service->is_remote) { + // We are talking to a remote service so we're writing. + if (self->conn_handle != BLEIO_HANDLE_INVALID) { + bleio_connection_internal_t *connection = bleio_conn_handle_to_connection(self->conn_handle); + if (connection) { + return MIN(common_hal_bleio_connection_get_max_packet_length(connection), + self->max_packet_size); + } + } + } + return MIN(self->characteristic->max_length, self->max_packet_size); +} + +void common_hal_bleio_packet_buffer_flush(bleio_packet_buffer_obj_t *self) { + while ((self->pending_size != 0 || + self->packet_queued) && + self->conn_handle != BLEIO_HANDLE_INVALID && + !mp_hal_is_interrupted()) { + RUN_BACKGROUND_TASKS; + } +} + +bool common_hal_bleio_packet_buffer_deinited(bleio_packet_buffer_obj_t *self) { + return self->characteristic == NULL; +} + +void common_hal_bleio_packet_buffer_deinit(bleio_packet_buffer_obj_t *self) { + if (!common_hal_bleio_packet_buffer_deinited(self)) { + } + // TODO: Implement this. +} diff --git a/ports/espressif/common-hal/_bleio/PacketBuffer.h b/ports/espressif/common-hal/_bleio/PacketBuffer.h new file mode 100644 index 0000000000..6ecc1a69b2 --- /dev/null +++ b/ports/espressif/common-hal/_bleio/PacketBuffer.h @@ -0,0 +1,52 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019-2020 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_PACKETBUFFER_H +#define MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_PACKETBUFFER_H + +#include "py/ringbuf.h" +#include "shared-bindings/_bleio/Characteristic.h" + +typedef struct { + mp_obj_base_t base; + bleio_characteristic_obj_t *characteristic; + // Ring buffer storing consecutive incoming values. + ringbuf_t ringbuf; + // Two outgoing buffers to alternate between. One will be queued for transmission by the SD and + // the other is waiting to be queued and can be extended. + uint32_t *outgoing[2]; + volatile uint16_t pending_size; + // We remember the conn_handle so we can do a NOTIFY/INDICATE to a client. + // We can find out the conn_handle on a Characteristic write or a CCCD write (but not a read). + volatile uint16_t conn_handle; + uint16_t max_packet_size; + uint8_t pending_index; + uint8_t write_type; + bool client; + bool packet_queued; +} bleio_packet_buffer_obj_t; + +#endif // MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_PACKETBUFFER_H diff --git a/ports/espressif/common-hal/_bleio/Service.c b/ports/espressif/common-hal/_bleio/Service.c new file mode 100644 index 0000000000..beaf930136 --- /dev/null +++ b/ports/espressif/common-hal/_bleio/Service.c @@ -0,0 +1,94 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Dan Halbert for Adafruit Industries + * Copyright (c) 2018 Artur Pacholec + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "py/runtime.h" +#include "common-hal/_bleio/__init__.h" +#include "shared-bindings/_bleio/Characteristic.h" +#include "shared-bindings/_bleio/Descriptor.h" +#include "shared-bindings/_bleio/Service.h" +#include "shared-bindings/_bleio/Adapter.h" + +#include "host/ble_gatt.h" + +uint32_t _common_hal_bleio_service_construct(bleio_service_obj_t *self, bleio_uuid_obj_t *uuid, bool is_secondary, mp_obj_list_t *characteristic_list) { + self->handle = 0xFFFF; + self->uuid = uuid; + self->characteristic_list = characteristic_list; + self->is_remote = false; + self->connection = NULL; + self->is_secondary = is_secondary; + + // uint8_t service_type = BLE_GATT_SVC_TYPE_PRIMARY; + // if (is_secondary) { + // service_type = BLE_GATT_SVC_TYPE_SECONDARY; + // } + + return 0; +} + +void common_hal_bleio_service_construct(bleio_service_obj_t *self, bleio_uuid_obj_t *uuid, bool is_secondary) { + mp_raise_NotImplementedError(NULL); + _common_hal_bleio_service_construct(self, uuid, is_secondary, + mp_obj_new_list(0, NULL)); +} + +void bleio_service_from_connection(bleio_service_obj_t *self, mp_obj_t connection) { + self->handle = 0xFFFF; + self->uuid = NULL; + self->characteristic_list = mp_obj_new_list(0, NULL); + self->is_remote = true; + self->is_secondary = false; + self->connection = connection; +} + +bleio_uuid_obj_t *common_hal_bleio_service_get_uuid(bleio_service_obj_t *self) { + return self->uuid; +} + +mp_obj_tuple_t *common_hal_bleio_service_get_characteristics(bleio_service_obj_t *self) { + return mp_obj_new_tuple(self->characteristic_list->len, self->characteristic_list->items); +} + +bool common_hal_bleio_service_get_is_remote(bleio_service_obj_t *self) { + return self->is_remote; +} + +bool common_hal_bleio_service_get_is_secondary(bleio_service_obj_t *self) { + return self->is_secondary; +} + +void common_hal_bleio_service_add_characteristic(bleio_service_obj_t *self, + bleio_characteristic_obj_t *characteristic, + mp_buffer_info_t *initial_value_bufinfo, + const char *user_description) { + + #if CIRCUITPY_VERBOSE_BLE + mp_printf(&mp_plat_print, "Char handle %x user %x cccd %x sccd %x\n", characteristic->handle, characteristic->user_desc_handle, characteristic->cccd_handle, characteristic->sccd_handle); + #endif + + mp_obj_list_append(self->characteristic_list, MP_OBJ_FROM_PTR(characteristic)); +} diff --git a/ports/espressif/common-hal/_bleio/Service.h b/ports/espressif/common-hal/_bleio/Service.h new file mode 100644 index 0000000000..6c1688df30 --- /dev/null +++ b/ports/espressif/common-hal/_bleio/Service.h @@ -0,0 +1,53 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2018 Dan Halbert for Adafruit Industries + * Copyright (c) 2018 Artur Pacholec + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_SERVICE_H +#define MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_SERVICE_H + +#include "py/objlist.h" +#include "common-hal/_bleio/UUID.h" + +typedef struct bleio_service_obj { + mp_obj_base_t base; + // Handle for the local service. + uint16_t handle; + // True if created during discovery. + bool is_remote; + bool is_secondary; + bleio_uuid_obj_t *uuid; + // The connection object is set only when this is a remote service. + // A local service doesn't know the connection. + mp_obj_t connection; + mp_obj_list_t *characteristic_list; + // Range of attribute handles of this remote service. + uint16_t start_handle; + uint16_t end_handle; +} bleio_service_obj_t; + +void bleio_service_from_connection(bleio_service_obj_t *self, mp_obj_t connection); + +#endif // MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_SERVICE_H diff --git a/ports/espressif/common-hal/_bleio/UUID.c b/ports/espressif/common-hal/_bleio/UUID.c new file mode 100644 index 0000000000..8f0866412c --- /dev/null +++ b/ports/espressif/common-hal/_bleio/UUID.c @@ -0,0 +1,69 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2018 Dan Halbert for Adafruit Industries + * Copyright (c) 2018 Artur Pacholec + * Copyright (c) 2016 Glenn Ruben Bakke + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include + +#include "py/runtime.h" +#include "common-hal/_bleio/UUID.h" +#include "shared-bindings/_bleio/UUID.h" +#include "shared-bindings/_bleio/__init__.h" +#include "shared-bindings/_bleio/Adapter.h" + +// If uuid128 is NULL, this is a Bluetooth SIG 16-bit UUID. +// If uuid128 is not NULL, it's a 128-bit (16-byte) UUID, with bytes 12 and 13 zero'd out, where +// the 16-bit part goes. Those 16 bits are passed in uuid16. +void common_hal_bleio_uuid_construct(bleio_uuid_obj_t *self, mp_int_t uuid16, const uint8_t uuid128[16]) { + if (uuid128 == NULL) { + ble_uuid_init_from_buf(&self->nimble_ble_uuid, (uint8_t *)&uuid16, 2); + } else { + ble_uuid_init_from_buf(&self->nimble_ble_uuid, uuid128, 16); + self->nimble_ble_uuid.u128.value[12] = uuid16 & 0xff; + self->nimble_ble_uuid.u128.value[13] = (uuid16 >> 8) & 0xff; + } +} + +uint32_t common_hal_bleio_uuid_get_size(bleio_uuid_obj_t *self) { + return self->nimble_ble_uuid.u.type == BLE_UUID_TYPE_16 ? 16 : 128; +} + +uint32_t common_hal_bleio_uuid_get_uuid16(bleio_uuid_obj_t *self) { + return self->nimble_ble_uuid.u16.value; +} + +void common_hal_bleio_uuid_get_uuid128(bleio_uuid_obj_t *self, uint8_t uuid128[16]) { + memcpy(uuid128, self->nimble_ble_uuid.u128.value, 16); +} + +void common_hal_bleio_uuid_pack_into(bleio_uuid_obj_t *self, uint8_t *buf) { + if (self->nimble_ble_uuid.u.type == BLE_UUID_TYPE_16) { + buf[0] = self->nimble_ble_uuid.u16.value & 0xff; + buf[1] = self->nimble_ble_uuid.u16.value >> 8; + } else { + common_hal_bleio_uuid_get_uuid128(self, buf); + } +} diff --git a/ports/espressif/common-hal/_bleio/UUID.h b/ports/espressif/common-hal/_bleio/UUID.h new file mode 100644 index 0000000000..166088ed96 --- /dev/null +++ b/ports/espressif/common-hal/_bleio/UUID.h @@ -0,0 +1,49 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Dan Halbert for Adafruit Industries + * Copyright (c) 2018 Artur Pacholec + * Copyright (c) 2016 Glenn Ruben Bakke + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_UUID_H +#define MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_UUID_H + +#include "py/obj.h" + +#include "host/ble_uuid.h" + +typedef struct { + mp_obj_base_t base; + // Use the native way of storing UUID's: + // - ble_uuid_t.uuid is a 16-bit uuid. + // - ble_uuid_t.type is BLE_UUID_TYPE_BLE if it's a 16-bit Bluetooth SIG UUID. + // or is BLE_UUID_TYPE_VENDOR_BEGIN and higher, which indexes into a table of registered + // 128-bit UUIDs. + ble_uuid_any_t nimble_ble_uuid; +} bleio_uuid_obj_t; + +void bleio_uuid_construct_from_nrf_ble_uuid(bleio_uuid_obj_t *self, ble_uuid_t *nrf_uuid); +void bleio_uuid_convert_to_nrf_ble_uuid(bleio_uuid_obj_t *self, ble_uuid_t *nrf_uuid); + +#endif // MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_UUID_H diff --git a/ports/espressif/common-hal/_bleio/__init__.c b/ports/espressif/common-hal/_bleio/__init__.c new file mode 100644 index 0000000000..bd10b0a519 --- /dev/null +++ b/ports/espressif/common-hal/_bleio/__init__.c @@ -0,0 +1,99 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2018 Dan Halbert for Adafruit Industries + * Copyright (c) 2018 Artur Pacholec + * Copyright (c) 2016 Glenn Ruben Bakke + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include + +#include "py/runtime.h" +#include "shared-bindings/_bleio/__init__.h" +#include "shared-bindings/_bleio/Adapter.h" +#include "shared-bindings/_bleio/Characteristic.h" +#include "shared-bindings/_bleio/Connection.h" +#include "shared-bindings/_bleio/Descriptor.h" +#include "shared-bindings/_bleio/Service.h" +#include "shared-bindings/_bleio/UUID.h" +#include "supervisor/shared/bluetooth/bluetooth.h" + +#include "common-hal/_bleio/__init__.h" +// #include "common-hal/_bleio/bonding.h" + +// Turn off BLE on a reset or reload. +void bleio_reset() { + // Set this explicitly to save data. + common_hal_bleio_adapter_obj.base.type = &bleio_adapter_type; + if (!common_hal_bleio_adapter_get_enabled(&common_hal_bleio_adapter_obj)) { + return; + } + + supervisor_stop_bluetooth(); + bleio_adapter_reset(&common_hal_bleio_adapter_obj); + common_hal_bleio_adapter_set_enabled(&common_hal_bleio_adapter_obj, false); + supervisor_start_bluetooth(); +} + +// The singleton _bleio.Adapter object, bound to _bleio.adapter +// It currently only has properties and no state. Inited by bleio_reset +bleio_adapter_obj_t common_hal_bleio_adapter_obj; + +void bleio_background(void) { +} + +void common_hal_bleio_gc_collect(void) { + bleio_adapter_gc_collect(&common_hal_bleio_adapter_obj); +} + +void check_nimble_error(int rc, const char *file, size_t line) { + if (rc == NIMBLE_OK) { + return; + } + switch (rc) { + case BLE_HS_ENOMEM: + mp_raise_msg(&mp_type_MemoryError, translate("Nimble out of memory")); + return; + case BLE_HS_ETIMEOUT: + mp_raise_msg(&mp_type_TimeoutError, NULL); + return; + case BLE_HS_EINVAL: + mp_raise_ValueError(translate("Invalid BLE parameter")); + return; + case BLE_HS_ENOTCONN: + mp_raise_ConnectionError(translate("Not connected")); + return; + default: + #if CIRCUITPY_VERBOSE_BLE + if (file) { + mp_raise_bleio_BluetoothError(translate("Unknown system firmware error at %s:%d: %d"), file, line, rc); + } + #else + (void)file; + (void)line; + mp_raise_bleio_BluetoothError(translate("Unknown system firmware error: %d"), rc); + #endif + + break; + } +} diff --git a/ports/espressif/common-hal/_bleio/__init__.h b/ports/espressif/common-hal/_bleio/__init__.h new file mode 100644 index 0000000000..6c32bd5d4e --- /dev/null +++ b/ports/espressif/common-hal/_bleio/__init__.h @@ -0,0 +1,57 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2018 Dan Halbert for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_INIT_H +#define MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_INIT_H + +void bleio_background(void); + +// typedef struct { +// ble_gap_enc_key_t own_enc; +// ble_gap_enc_key_t peer_enc; +// ble_gap_id_key_t peer_id; +// } bonding_keys_t; + +// We assume variable length data. +// 20 bytes max (23 - 3). +#define GATT_MAX_DATA_LENGTH (BLE_GATT_ATT_MTU_DEFAULT - 3) + +#define NIMBLE_OK (0) + +void check_nimble_error(int rc, const char *file, size_t line); +#define CHECK_NIMBLE_ERROR(rc) check_nimble_error(rc, __FILE__, __LINE__) + +#define MSEC_TO_UNITS(TIME, RESOLUTION) (((TIME) * 1000) / (RESOLUTION)) +#define SEC_TO_UNITS(TIME, RESOLUTION) (((TIME) * 1000000) / (RESOLUTION)) +#define UNITS_TO_SEC(TIME, RESOLUTION) (((TIME)*(RESOLUTION)) / 1000000) +// 0.625 msecs (625 usecs) +#define ADV_INTERVAL_UNIT_FLOAT_SECS (0.000625) +// Microseconds is the base unit. The macros above know that. +#define UNIT_0_625_MS (625) +#define UNIT_1_25_MS (1250) +#define UNIT_10_MS (10000) + +#endif // MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_INIT_H diff --git a/ports/espressif/common-hal/_bleio/bonding.c b/ports/espressif/common-hal/_bleio/bonding.c new file mode 100644 index 0000000000..e7dac3cb33 --- /dev/null +++ b/ports/espressif/common-hal/_bleio/bonding.c @@ -0,0 +1,372 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Dan Halbert for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include +#include +#include + +#include "shared-bindings/_bleio/__init__.h" +#include "shared-bindings/_bleio/Adapter.h" +#include "shared-bindings/nvm/ByteArray.h" +#include "supervisor/shared/tick.h" + +#include "bonding.h" + +// Internal flash area reserved for bonding storage. +#define BONDING_PAGES_START_ADDR CIRCUITPY_BLE_CONFIG_START_ADDR +#define BONDING_PAGES_END_ADDR (CIRCUITPY_BLE_CONFIG_START_ADDR + CIRCUITPY_BLE_CONFIG_SIZE) + +// First and last four bytes are magic bytes for id and version. Data is in between. +// 'BD01' +const uint32_t BONDING_FLAG = ('1' | '0' << 8 | 'D' << 16 | 'B' << 24); + +#define BONDING_DATA_START_ADDR (BONDING_PAGES_START_ADDR + sizeof(BONDING_FLAG)) +#define BONDING_DATA_END_ADDR (BONDING_PAGES_END_ADDR - sizeof(BONDING_FLAG)) + +#define BONDING_START_FLAG_ADDR BONDING_PAGES_START_ADDR +#define BONDING_END_FLAG_ADDR BONDING_DATA_END_ADDR + +// Save both system and user service info. +#define SYS_ATTR_FLAGS (BLE_GATTS_SYS_ATTR_FLAG_SYS_SRVCS | BLE_GATTS_SYS_ATTR_FLAG_USR_SRVCS) + +#if BONDING_DEBUG +void bonding_print_block(bonding_block_t *block) { + printf("at 0x%08lx: is_central: %1d, type: 0x%x, ediv: 0x%04x, data_length: %d\n", + (uint32_t)block, block->is_central, block->type, block->ediv, block->data_length); +} + +void bonding_print_keys(bonding_keys_t *keys) { + for (size_t i = 0; i < sizeof(bonding_keys_t); i++) { + printf("%x", ((uint8_t *)keys)[i]); + } + printf("\n"); +} +#endif + +STATIC size_t compute_block_size(uint16_t data_length) { + // Round data size up to the nearest 32-bit address. + return sizeof(bonding_block_t) + ((data_length + 3) & ~0x3); +} + +void bonding_erase_storage(void) { + // Erase all pages in the bonding area. + for (uint32_t page_address = BONDING_PAGES_START_ADDR; + page_address < BONDING_PAGES_END_ADDR; + page_address += FLASH_PAGE_SIZE) { + // Argument is page number, not address. + sd_flash_page_erase_sync(page_address / FLASH_PAGE_SIZE); + } + // Write marker words at the beginning and the end of the bonding area. + uint32_t flag = BONDING_FLAG; + sd_flash_write_sync((uint32_t *)BONDING_START_FLAG_ADDR, &flag, 1); + sd_flash_write_sync((uint32_t *)BONDING_END_FLAG_ADDR, &flag, 1); +} + +// Given NULL to start or block address, return the address of the next valid block. +// The last block returned is the unused block at the end. +// Return NULL if we have run off the end of the bonding space. + +STATIC bonding_block_t *next_block(bonding_block_t *block) { + while (1) { + // Advance to next block. + if (block == NULL) { + return (bonding_block_t *)BONDING_DATA_START_ADDR; + } else if (block->type == BLOCK_UNUSED) { + // Already at last block (the unused block). + return NULL; + } + + // Advance to next block. + block = (bonding_block_t *)((uint8_t *)block + compute_block_size(block->data_length)); + + if (block >= (bonding_block_t *)BONDING_DATA_END_ADDR) { + // Went past end of bonding space. + return NULL; + } + if (block->type != BLOCK_INVALID) { + // Found an empty or a valid block. + return block; + } + // Invalid block (was erased); try again. + } +} + +// Find the block with given is_central, type and ediv value. +// If type == BLOCK_UNUSED, ediv is ignored and the the sole unused block at the end is returned. +// If not found, return NULL. +STATIC bonding_block_t *find_existing_block(bool is_central, bonding_block_type_t type, uint16_t ediv) { + bonding_block_t *block = NULL; + while (1) { + block = next_block(block); + if (block == NULL) { + return NULL; + } + // If types match, and block is unused, just return it. + // Otherwise check that is_central and ediv match. + if (type == block->type) { + if (type == BLOCK_UNUSED || + (is_central == block->is_central && ediv == block->ediv)) { + return block; + } + } + } +} + +size_t bonding_peripheral_bond_count(void) { + bonding_block_t *block = NULL; + size_t count = 0; + while (1) { + block = next_block(block); + if (block == NULL) { + return count; + } + if (block->type != BLOCK_UNUSED && block->type != BLOCK_INVALID && !block->is_central) { + count++; + } + } +} + +// Get an empty block large enough to store data_length data. +STATIC bonding_block_t *find_unused_block(uint16_t data_length) { + bonding_block_t *unused_block = find_existing_block(true, BLOCK_UNUSED, EDIV_INVALID); + // If no more room, erase all existing blocks and start over. + if (!unused_block || + (uint8_t *)unused_block + compute_block_size(data_length) >= (uint8_t *)BONDING_DATA_END_ADDR) { + bonding_erase_storage(); + unused_block = (bonding_block_t *)BONDING_DATA_START_ADDR; + } + return unused_block; +} + +// Set the header word to all 0's, to mark the block as invalid. +// We don't change data_length, so we can still skip over this block. +STATIC void invalidate_block(bonding_block_t *block) { + uint32_t zero = 0; + sd_flash_write_sync((uint32_t *)block, &zero, 1); +} + +// Write bonding block header. +STATIC void write_block_header(bonding_block_t *dest_block, bonding_block_t *source_block_header) { + sd_flash_write_sync((uint32_t *)dest_block, (uint32_t *)source_block_header, sizeof(bonding_block_t) / 4); +} + +// Write variable-length data at end of bonding block. +STATIC void write_block_data(bonding_block_t *dest_block, uint8_t *data, uint16_t data_length) { + // Minimize the number of writes. Datasheet says no more than two writes per word before erasing again. + + // Start writing after the current header. + uint32_t *flash_word_p = (uint32_t *)((uint8_t *)dest_block + sizeof(bonding_block_t)); + while (1) { + uint32_t word = 0xffffffff; + memcpy(&word, data, data_length >= 4 ? 4 : data_length); + sd_flash_write_sync(flash_word_p, &word, 1); + if (data_length <= 4) { + break; + } + data_length -= 4; + data += 4; + // Increment by word size. + flash_word_p++; + } +} + +STATIC void write_sys_attr_block(bleio_connection_internal_t *connection) { + uint16_t length = 0; + // First find out how big a buffer we need, then fetch the data. + if (sd_ble_gatts_sys_attr_get(connection->conn_handle, NULL, &length, SYS_ATTR_FLAGS) != NRF_SUCCESS) { + return; + } + uint8_t sys_attr[length]; + if (sd_ble_gatts_sys_attr_get(connection->conn_handle, sys_attr, &length, SYS_ATTR_FLAGS) != NRF_SUCCESS) { + return; + } + + // Is there an existing sys_attr block that matches the current sys_attr data? + bonding_block_t *existing_block = + find_existing_block(connection->is_central, BLOCK_SYS_ATTR, connection->ediv); + if (existing_block) { + if (length == existing_block->data_length && + memcmp(sys_attr, existing_block->data, length) == 0) { + // Identical block found. No need to store again. + return; + } + // Data doesn't match. Invalidate block and store a new one. + invalidate_block(existing_block); + } + + bonding_block_t block_header = { + .is_central = connection->is_central, + .type = BLOCK_SYS_ATTR, + .ediv = connection->ediv, + .conn_handle = connection->conn_handle, + .data_length = length, + }; + bonding_block_t *new_block = find_unused_block(length); + write_block_header(new_block, &block_header); + write_block_data(new_block, sys_attr, length); + return; +} + +STATIC void write_keys_block(bleio_connection_internal_t *connection) { + uint16_t const ediv = connection->is_central + ? connection->bonding_keys.peer_enc.master_id.ediv + : connection->bonding_keys.own_enc.master_id.ediv; + + // Is there an existing keys block that matches the ediv? + bonding_block_t *existing_block = find_existing_block(connection->is_central, BLOCK_KEYS, ediv); + if (existing_block) { + if (existing_block->data_length == sizeof(bonding_keys_t) && + memcmp(existing_block->data, &connection->bonding_keys, sizeof(bonding_keys_t)) == 0) { + // Identical block found. No need to store again. + return; + } + // Data doesn't match. Invalidate block and store a new one. + invalidate_block(existing_block); + } + // Invalidate any existing blocks that match the peer address. + existing_block = next_block(NULL); + while (existing_block != NULL) { + if (existing_block->type == BLOCK_KEYS && connection->is_central == existing_block->is_central && + existing_block->data_length == sizeof(bonding_keys_t)) { + const ble_gap_addr_t *existing_peer = &((const bonding_keys_t *)existing_block->data)->peer_id.id_addr_info; + const ble_gap_addr_t *connecting_peer = &connection->bonding_keys.peer_id.id_addr_info; + if (memcmp(existing_peer->addr, connecting_peer->addr, 6) == 0 && + memcmp(existing_block->data, &connection->bonding_keys, sizeof(bonding_keys_t)) != 0) { + // Mismatched block found. Invalidate it. + invalidate_block(existing_block); + } + } + existing_block = next_block(existing_block); + } + + bonding_block_t block_header = { + .is_central = connection->is_central, + .type = BLOCK_KEYS, + .ediv = ediv, + .conn_handle = connection->conn_handle, + .data_length = sizeof(bonding_keys_t), + }; + bonding_block_t *new_block = find_unused_block(sizeof(bonding_keys_t)); + write_block_header(new_block, &block_header); + write_block_data(new_block, (uint8_t *)&connection->bonding_keys, sizeof(bonding_keys_t)); +} + +void bonding_clear_keys(bonding_keys_t *bonding_keys) { + memset((uint8_t *)bonding_keys, 0, sizeof(bonding_keys_t)); +} + +void bonding_reset(void) { + if (BONDING_FLAG != *((uint32_t *)BONDING_START_FLAG_ADDR) || + BONDING_FLAG != *((uint32_t *)BONDING_END_FLAG_ADDR)) { + bonding_erase_storage(); + } +} + +// Write bonding blocks to flash. Requests have been queued during evt handlers. +void bonding_background(void) { + // A paired connection will request that its keys and CCCD values be stored. + // The CCCD store whenever a CCCD value is written. + for (size_t i = 0; i < BLEIO_TOTAL_CONNECTION_COUNT; i++) { + bleio_connection_internal_t *connection = &bleio_connections[i]; + + // Wait at least one second before saving CCCD, to consolidate + // writes that involve multiple CCCDs. For instance, for HID, + // three CCCD's are set in short succession by the HID client. + if (connection->do_bond_cccds) { + uint64_t current_ticks_ms = supervisor_ticks_ms64(); + if (current_ticks_ms - connection->do_bond_cccds_request_time >= 1000) { + write_sys_attr_block(connection); + connection->do_bond_cccds = false; + } + } + + if (connection->do_bond_keys) { + write_keys_block(connection); + connection->do_bond_keys = false; + } + } +} + +bool bonding_load_cccd_info(bool is_central, uint16_t conn_handle, uint16_t ediv) { + bonding_block_t *block = find_existing_block(is_central, BLOCK_SYS_ATTR, ediv); + if (block == NULL) { + return false; + } + + return NRF_SUCCESS == + sd_ble_gatts_sys_attr_set(conn_handle, block->data, block->data_length, SYS_ATTR_FLAGS); +} + +bool bonding_load_keys(bool is_central, uint16_t ediv, bonding_keys_t *bonding_keys) { + bonding_block_t *block = find_existing_block(is_central, BLOCK_KEYS, ediv); + if (block == NULL) { + return false; + } + if (sizeof(bonding_keys_t) != block->data_length) { + // bonding_keys_t is a fixed length, so lengths should match. + return false; + } + + memcpy(bonding_keys, block->data, block->data_length); + return true; +} + +size_t bonding_load_identities(bool is_central, const ble_gap_id_key_t **keys, size_t max_length) { + bonding_block_t *block = NULL; + size_t len = 0; + while (len < max_length) { + block = next_block(block); + if (block == NULL) { + return len; + } + if (block->type != BLOCK_UNUSED && + block->type != BLOCK_INVALID && + block->is_central == is_central) { + if (sizeof(bonding_keys_t) != block->data_length) { + // bonding_keys_t is a fixed length, so lengths should match. + return len; + } + const bonding_keys_t *key_set = (const bonding_keys_t *)block->data; + keys[len] = &key_set->peer_id; + len++; + } + } + return len; +} + +const ble_gap_enc_key_t *bonding_load_peer_encryption_key(bool is_central, const ble_gap_addr_t *peer) { + bonding_block_t *block = next_block(NULL); + while (block != NULL) { + if (block->type == BLOCK_KEYS && block->is_central == is_central) { + const bonding_keys_t *key_set = (const bonding_keys_t *)block->data; + if (memcmp(key_set->peer_id.id_addr_info.addr, peer->addr, 6) == 0) { + return &key_set->peer_enc; + } + } + block = next_block(block); + } + return NULL; +} diff --git a/ports/espressif/common-hal/_bleio/bonding.h b/ports/espressif/common-hal/_bleio/bonding.h new file mode 100644 index 0000000000..9f04f10d4f --- /dev/null +++ b/ports/espressif/common-hal/_bleio/bonding.h @@ -0,0 +1,91 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Dan Halbert for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_BONDING_H +#define MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_BONDING_H + +#include +#include +#include + +#include "common-hal/_bleio/__init__.h" + +#define EDIV_INVALID (0xffff) + +#define BONDING_DEBUG (1) +#if BONDING_DEBUG + #define BONDING_DEBUG_PRINTF(...) printf(__VA_ARGS__) + #define BONDING_DEBUG_PRINT_BLOCK(block) bonding_print_block(block) + #define BONDING_DEBUG_PRINT_KEYS(keys) bonding_print_keys(keys) +#else + #define BONDING_DEBUG_PRINTF(...) + #define BONDING_DEBUG_PRINT_BLOCK(block) + #define BONDING_DEBUG_PRINT_KEYS(keys) +#endif + +// Bonding data is stored in variable-length blocks consecutively in +// erased flash (all 1's). The blocks are 32-bit aligned, though the +// data may be any number of bytes. We hop through the blocks using +// the size field to find the next block. When we hit a word that is +// all 1's, we have reached the end of the blocks. We can write a new +// block there. + +typedef enum { + BLOCK_INVALID = 0, // Ignore this block + BLOCK_KEYS = 1, // Block contains bonding keys. + BLOCK_SYS_ATTR = 2, // Block contains sys_attr values (CCCD settings, etc.). + BLOCK_UNUSED = 0xff, // Initial erased value. +} bonding_block_type_t; + +typedef struct { + bool is_central : 1; // 1 if data is for a central role. + uint16_t reserved : 7; // Not currently used + bonding_block_type_t type : 8; // What kind of data is stored in. + uint16_t ediv; // ediv value; used as a lookup key. + uint16_t conn_handle; // Connection handle: used when a BLOCK_SYS_ATTR is queued to write. + // Not used as a key, etc. + uint16_t data_length; // Length of data in bytes, including ediv, not including padding. + // End of block header. 32-bit boundary here. + uint8_t data[]; // Rest of data in the block. Needs to be 32-bit aligned. + // Block is padded to 32-bit alignment. +} bonding_block_t; + +void bonding_background(void); +void bonding_erase_storage(void); +void bonding_reset(void); +void bonding_clear_keys(bonding_keys_t *bonding_keys); +bool bonding_load_cccd_info(bool is_central, uint16_t conn_handle, uint16_t ediv); +bool bonding_load_keys(bool is_central, uint16_t ediv, bonding_keys_t *bonding_keys); +const ble_gap_enc_key_t *bonding_load_peer_encryption_key(bool is_central, const ble_gap_addr_t *peer); +size_t bonding_load_identities(bool is_central, const ble_gap_id_key_t **keys, size_t max_length); +size_t bonding_peripheral_bond_count(void); + +#if BONDING_DEBUG +void bonding_print_block(bonding_block_t *); +void bonding_print_keys(bonding_keys_t *); +#endif + +#endif // MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BLEIO_BONDING_H diff --git a/ports/espressif/common-hal/busio/I2C.c b/ports/espressif/common-hal/busio/I2C.c index 81b23cb3a3..454432ab91 100644 --- a/ports/espressif/common-hal/busio/I2C.c +++ b/ports/espressif/common-hal/busio/I2C.c @@ -136,13 +136,19 @@ void common_hal_busio_i2c_deinit(busio_i2c_obj_t *self) { self->scl_pin = NULL; } -bool common_hal_busio_i2c_probe(busio_i2c_obj_t *self, uint8_t addr) { +static esp_err_t i2c_zero_length_write(busio_i2c_obj_t *self, uint8_t addr, TickType_t timeout) { + // i2c_master_write_to_device() won't do zero-length writes, so we do it by hand. i2c_cmd_handle_t cmd = i2c_cmd_link_create(); i2c_master_start(cmd); i2c_master_write_byte(cmd, addr << 1, true); i2c_master_stop(cmd); - esp_err_t result = i2c_master_cmd_begin(self->i2c_num, cmd, 10); + esp_err_t result = i2c_master_cmd_begin(self->i2c_num, cmd, timeout); i2c_cmd_link_delete(cmd); + return result; +} + +bool common_hal_busio_i2c_probe(busio_i2c_obj_t *self, uint8_t addr) { + esp_err_t result = i2c_zero_length_write(self, addr, 1); return result == ESP_OK; } @@ -163,45 +169,36 @@ void common_hal_busio_i2c_unlock(busio_i2c_obj_t *self) { self->has_lock = false; } -uint8_t common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t addr, - const uint8_t *data, size_t len, bool transmit_stop_bit) { - i2c_cmd_handle_t cmd = i2c_cmd_link_create(); - i2c_master_start(cmd); - i2c_master_write_byte(cmd, addr << 1, true); - i2c_master_write(cmd, (uint8_t *)data, len, true); - if (transmit_stop_bit) { - i2c_master_stop(cmd); +static uint8_t convert_esp_err(esp_err_t result) { + switch (result) { + case ESP_OK: + return 0; + case ESP_FAIL: + return MP_ENODEV; + case ESP_ERR_TIMEOUT: + return MP_ETIMEDOUT; + default: + return MP_EIO; } - esp_err_t result = i2c_master_cmd_begin(self->i2c_num, cmd, 100 /* wait in ticks */); - i2c_cmd_link_delete(cmd); - - if (result == ESP_OK) { - return 0; - } else if (result == ESP_FAIL) { - return MP_ENODEV; - } - return MP_EIO; } -uint8_t common_hal_busio_i2c_read(busio_i2c_obj_t *self, uint16_t addr, - uint8_t *data, size_t len) { - i2c_cmd_handle_t cmd = i2c_cmd_link_create(); - i2c_master_start(cmd); - i2c_master_write_byte(cmd, addr << 1 | 1, true); // | 1 to indicate read - if (len > 1) { - i2c_master_read(cmd, data, len - 1, 0); - } - i2c_master_read_byte(cmd, data + len - 1, 1); - i2c_master_stop(cmd); - esp_err_t result = i2c_master_cmd_begin(self->i2c_num, cmd, 100 /* wait in ticks */); - i2c_cmd_link_delete(cmd); +uint8_t common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t addr, const uint8_t *data, size_t len) { + return convert_esp_err(len == 0 + ? i2c_zero_length_write(self, addr, 100) + : i2c_master_write_to_device(self->i2c_num, (uint8_t)addr, data, len, 100 /* wait in ticks */) + ); +} - if (result == ESP_OK) { - return 0; - } else if (result == ESP_FAIL) { - return MP_ENODEV; - } - return MP_EIO; +uint8_t common_hal_busio_i2c_read(busio_i2c_obj_t *self, uint16_t addr, uint8_t *data, size_t len) { + return convert_esp_err( + i2c_master_read_from_device(self->i2c_num, (uint8_t)addr, data, len, 100 /* wait in ticks */)); +} + +uint8_t common_hal_busio_i2c_write_read(busio_i2c_obj_t *self, uint16_t addr, + uint8_t *out_data, size_t out_len, uint8_t *in_data, size_t in_len) { + return convert_esp_err( + i2c_master_write_read_device(self->i2c_num, (uint8_t)addr, + out_data, out_len, in_data, in_len, 100 /* wait in ticks */)); } void common_hal_busio_i2c_never_reset(busio_i2c_obj_t *self) { diff --git a/ports/espressif/common-hal/microcontroller/Pin.c b/ports/espressif/common-hal/microcontroller/Pin.c index 4648fec64d..1683ea6acc 100644 --- a/ports/espressif/common-hal/microcontroller/Pin.c +++ b/ports/espressif/common-hal/microcontroller/Pin.c @@ -36,20 +36,6 @@ STATIC uint32_t never_reset_pins[2]; STATIC uint32_t in_use[2]; -STATIC void floating_gpio_reset(gpio_num_t pin_number) { - // This is the same as gpio_reset_pin(), but without the pullup. - // Note that gpio_config resets the iomatrix to GPIO_FUNC as well. - gpio_config_t cfg = { - .pin_bit_mask = BIT64(pin_number), - .mode = GPIO_MODE_DISABLE, - .pull_up_en = false, - .pull_down_en = false, - .intr_type = GPIO_INTR_DISABLE, - }; - gpio_config(&cfg); - PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[pin_number], 0); -} - void never_reset_pin_number(gpio_num_t pin_number) { if (pin_number == NO_PIN) { return; @@ -64,6 +50,43 @@ void common_hal_never_reset_pin(const mcu_pin_obj_t *pin) { never_reset_pin_number(pin->number); } +STATIC void _reset_pin(gpio_num_t pin_number) { + #if defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32S3) + // Never ever reset pins used for flash and RAM. + if (26 <= pin_number && pin_number <= 32) { + return; + } + #ifdef CONFIG_SPIRAM_MODE_OCT + // Octal DQ4-DQ7 and DQS/DM + if (33 <= pin_number && pin_number <= 37) { + return; + } + #endif + + #if CIRCUITPY_USB + // Never reset USB pins. + if (pin_number == 19 || pin_number == 20) { + return; + } + #endif + #elif defined(CONFIG_IDF_TARGET_ESP32C3) + // Never ever reset pins used for flash and RAM. + if (11 <= pin_number && pin_number <= 17) { + return; + } + #endif + + gpio_reset_pin(pin_number); + + #ifdef DOUBLE_TAP_PIN + // Pull the double tap pin down so that resets come back to CircuitPython. + if (pin_number == DOUBLE_TAP_PIN->number) { + gpio_pullup_dis(pin_number); + gpio_pulldown_en(pin_number); + } + #endif +} + // Mark pin as free and return it to a quiescent state. void reset_pin_number(gpio_num_t pin_number) { if (pin_number == NO_PIN) { @@ -72,7 +95,7 @@ void reset_pin_number(gpio_num_t pin_number) { never_reset_pins[pin_number / 32] &= ~(1 << pin_number % 32); in_use[pin_number / 32] &= ~(1 << pin_number % 32); - floating_gpio_reset(pin_number); + _reset_pin(pin_number); } void common_hal_mcu_pin_reset_number(uint8_t i) { @@ -93,7 +116,7 @@ void reset_all_pins(void) { (never_reset_pins[i / 32] & (1 << i % 32)) != 0) { continue; } - floating_gpio_reset(i); + _reset_pin(i); } in_use[0] = never_reset_pins[0]; in_use[1] = never_reset_pins[1]; diff --git a/ports/espressif/common-hal/microcontroller/Processor.c b/ports/espressif/common-hal/microcontroller/Processor.c index 500d1f6d3e..e4782c30ab 100644 --- a/ports/espressif/common-hal/microcontroller/Processor.c +++ b/ports/espressif/common-hal/microcontroller/Processor.c @@ -60,7 +60,13 @@ float common_hal_mcu_processor_get_voltage(void) { } uint32_t common_hal_mcu_processor_get_frequency(void) { - return 0; + #ifdef CONFIG_IDF_TARGET_ESP32C3 + return CONFIG_ESP32C3_DEFAULT_CPU_FREQ_MHZ * 1000000; + #elif defined(CONFIG_IDF_TARGET_ESP32S2) + return CONFIG_ESP32S2_DEFAULT_CPU_FREQ_MHZ * 1000000; + #elif defined(CONFIG_IDF_TARGET_ESP32S3) + return CONFIG_ESP32S3_DEFAULT_CPU_FREQ_MHZ * 1000000; + #endif } STATIC uint8_t swap_nibbles(uint8_t v) { diff --git a/ports/espressif/common-hal/neopixel_write/__init__.c b/ports/espressif/common-hal/neopixel_write/__init__.c index b63390f155..b140eff4f9 100644 --- a/ports/espressif/common-hal/neopixel_write/__init__.c +++ b/ports/espressif/common-hal/neopixel_write/__init__.c @@ -43,20 +43,23 @@ #include "py/mphal.h" #include "py/runtime.h" #include "shared-bindings/neopixel_write/__init__.h" +#include "supervisor/port.h" #include "components/driver/include/driver/rmt.h" #include "peripherals/rmt.h" -#define WS2812_T0H_NS (350) -#define WS2812_T0L_NS (1000) -#define WS2812_T1H_NS (1000) -#define WS2812_T1L_NS (350) -#define WS2812_RESET_US (280) +// 416 ns is 1/3 of the 1250ns period of a 800khz signal. +#define WS2812_T0H_NS (416) +#define WS2812_T0L_NS (416 * 2) +#define WS2812_T1H_NS (416 * 2) +#define WS2812_T1L_NS (416) static uint32_t ws2812_t0h_ticks = 0; static uint32_t ws2812_t1h_ticks = 0; static uint32_t ws2812_t0l_ticks = 0; static uint32_t ws2812_t1l_ticks = 0; +static uint64_t next_start_raw_ticks = 0; + static void IRAM_ATTR ws2812_rmt_adapter(const void *src, rmt_item32_t *dest, size_t src_size, size_t wanted_num, size_t *translated_size, size_t *item_num) { if (src == NULL || dest == NULL) { @@ -91,7 +94,7 @@ static void IRAM_ATTR ws2812_rmt_adapter(const void *src, rmt_item32_t *dest, si void common_hal_neopixel_write(const digitalio_digitalinout_obj_t *digitalinout, uint8_t *pixels, uint32_t numBytes) { // Reserve channel uint8_t number = digitalinout->pin->number; - rmt_channel_t channel = peripherals_find_and_reserve_rmt(); + rmt_channel_t channel = peripherals_find_and_reserve_rmt(TRANSMIT_MODE); if (channel == RMT_CHANNEL_MAX) { mp_raise_RuntimeError(translate("All timers in use")); } @@ -107,21 +110,29 @@ void common_hal_neopixel_write(const digitalio_digitalinout_obj_t *digitalinout, if (rmt_get_counter_clock(config.channel, &counter_clk_hz) != ESP_OK) { mp_raise_RuntimeError(translate("Could not retrieve clock")); } - float ratio = (float)counter_clk_hz / 1e9; - ws2812_t0h_ticks = (uint32_t)(ratio * WS2812_T0H_NS); - ws2812_t0l_ticks = (uint32_t)(ratio * WS2812_T0L_NS); - ws2812_t1h_ticks = (uint32_t)(ratio * WS2812_T1H_NS); - ws2812_t1l_ticks = (uint32_t)(ratio * WS2812_T1L_NS); + size_t ns_per_tick = 1e9 / counter_clk_hz; + ws2812_t0h_ticks = WS2812_T0H_NS / ns_per_tick; + ws2812_t0l_ticks = WS2812_T0L_NS / ns_per_tick; + ws2812_t1h_ticks = WS2812_T1H_NS / ns_per_tick; + ws2812_t1l_ticks = WS2812_T1L_NS / ns_per_tick; // Initialize automatic timing translator rmt_translator_init(config.channel, ws2812_rmt_adapter); + // Wait to make sure we don't append onto the last transmission. This should only be a tick or + // two. + while (port_get_raw_ticks(NULL) < next_start_raw_ticks) { + } + // Write and wait to finish if (rmt_write_sample(config.channel, pixels, (size_t)numBytes, true) != ESP_OK) { mp_raise_RuntimeError(translate("Input/output error")); } rmt_wait_tx_done(config.channel, pdMS_TO_TICKS(100)); + // Update the next start to +2 ticks. It ensures that we've gone 300+ us. + next_start_raw_ticks = port_get_raw_ticks(NULL) + 2; + // Free channel again peripherals_free_rmt(config.channel); // Swap pin back to GPIO mode diff --git a/ports/espressif/common-hal/pulseio/PulseIn.c b/ports/espressif/common-hal/pulseio/PulseIn.c index 3f5457f84b..1b29032354 100644 --- a/ports/espressif/common-hal/pulseio/PulseIn.c +++ b/ports/espressif/common-hal/pulseio/PulseIn.c @@ -107,7 +107,7 @@ void common_hal_pulseio_pulsein_construct(pulseio_pulsein_obj_t *self, const mcu } // Find a free RMT Channel and configure it - rmt_channel_t channel = peripherals_find_and_reserve_rmt(); + rmt_channel_t channel = peripherals_find_and_reserve_rmt(RECEIVE_MODE); if (channel == RMT_CHANNEL_MAX) { mp_raise_RuntimeError(translate("All timers in use")); } diff --git a/ports/espressif/common-hal/pulseio/PulseOut.c b/ports/espressif/common-hal/pulseio/PulseOut.c index 993fd9452c..773c2bf107 100644 --- a/ports/espressif/common-hal/pulseio/PulseOut.c +++ b/ports/espressif/common-hal/pulseio/PulseOut.c @@ -37,7 +37,7 @@ void common_hal_pulseio_pulseout_construct(pulseio_pulseout_obj_t *self, uint32_t frequency, uint16_t duty_cycle) { - rmt_channel_t channel = peripherals_find_and_reserve_rmt(); + rmt_channel_t channel = peripherals_find_and_reserve_rmt(TRANSMIT_MODE); if (channel == RMT_CHANNEL_MAX) { mp_raise_RuntimeError(translate("All timers in use")); } diff --git a/ports/espressif/esp-idf b/ports/espressif/esp-idf index 6db2ebd789..2775b6e213 160000 --- a/ports/espressif/esp-idf +++ b/ports/espressif/esp-idf @@ -1 +1 @@ -Subproject commit 6db2ebd7897be544ad0f169871db4b13b4c0941e +Subproject commit 2775b6e213a1876dd1abe4923097ca5b437397e3 diff --git a/ports/espressif/esp-idf-config/sdkconfig-ble.defaults b/ports/espressif/esp-idf-config/sdkconfig-ble.defaults new file mode 100644 index 0000000000..476b6a32d9 --- /dev/null +++ b/ports/espressif/esp-idf-config/sdkconfig-ble.defaults @@ -0,0 +1,171 @@ +# +# Bluetooth +# +CONFIG_BT_ENABLED=y +# end of Bluetooth + +CONFIG_BT_CTRL_MODE_EFF=1 +# +# Bluetooth controller +# +CONFIG_BT_CTRL_BLE_MAX_ACT=10 +CONFIG_BT_CTRL_BLE_MAX_ACT_EFF=10 +CONFIG_BT_CTRL_BLE_STATIC_ACL_TX_BUF_NB=0 +CONFIG_BT_CTRL_PINNED_TO_CORE_0=y +# CONFIG_BT_CTRL_PINNED_TO_CORE_1 is not set +CONFIG_BT_CTRL_PINNED_TO_CORE=0 +CONFIG_BT_CTRL_HCI_MODE_VHCI=y +# CONFIG_BT_CTRL_HCI_MODE_UART_H4 is not set +CONFIG_BT_CTRL_HCI_TL=1 +CONFIG_BT_CTRL_ADV_DUP_FILT_MAX=30 +# CONFIG_BT_CTRL_HW_CCA is not set +CONFIG_BT_CTRL_HW_CCA_EFF=0 +CONFIG_BT_CTRL_CE_LENGTH_TYPE_ORIG=y +# CONFIG_BT_CTRL_CE_LENGTH_TYPE_CE is not set +# CONFIG_BT_CTRL_CE_LENGTH_TYPE_SD is not set +CONFIG_BT_CTRL_CE_LENGTH_TYPE_EFF=0 +CONFIG_BT_CTRL_TX_ANTENNA_INDEX_0=y +# CONFIG_BT_CTRL_TX_ANTENNA_INDEX_1 is not set +CONFIG_BT_CTRL_TX_ANTENNA_INDEX_EFF=0 +CONFIG_BT_CTRL_RX_ANTENNA_INDEX_0=y +# CONFIG_BT_CTRL_RX_ANTENNA_INDEX_1 is not set +CONFIG_BT_CTRL_RX_ANTENNA_INDEX_EFF=0 +# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_N27 is not set +# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_N24 is not set +# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_N21 is not set +# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_N18 is not set +# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_N15 is not set +# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_N12 is not set +# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_N9 is not set +# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_N6 is not set +# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_N3 is not set +# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_N0 is not set +CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_P3=y +# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_P6 is not set +# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_P9 is not set +# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_P12 is not set +# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_P15 is not set +# CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_P18 is not set +CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL_EFF=10 +CONFIG_BT_CTRL_BLE_ADV_REPORT_FLOW_CTRL_SUPP=y +CONFIG_BT_CTRL_BLE_ADV_REPORT_FLOW_CTRL_NUM=100 +CONFIG_BT_CTRL_BLE_ADV_REPORT_DISCARD_THRSHOLD=20 +# CONFIG_BT_CTRL_BLE_SCAN_DUPL is not set +# CONFIG_BT_CTRL_COEX_PHY_CODED_TX_RX_TLIM_EN is not set +CONFIG_BT_CTRL_COEX_PHY_CODED_TX_RX_TLIM_DIS=y +CONFIG_BT_CTRL_COEX_PHY_CODED_TX_RX_TLIM_EFF=0 +# end of Bluetooth controller + +# CONFIG_BT_CTRL_MODEM_SLEEP is not set +# +# Bluetooth controller +# +CONFIG_BT_CTRL_SLEEP_MODE_EFF=0 +CONFIG_BT_CTRL_SLEEP_CLOCK_EFF=0 +CONFIG_BT_CTRL_HCI_TL_EFF=1 +# CONFIG_BT_CTRL_AGC_RECORRECT_EN is not set +# end of Bluetooth controller + +# CONFIG_BT_BLUEDROID_ENABLED is not set +# +# Bluetooth +# +CONFIG_BT_NIMBLE_ENABLED=y +# CONFIG_BT_CONTROLLER_ONLY is not set +# end of Bluetooth + +CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_INTERNAL=y +# +# NimBLE Options +# +# CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_DEFAULT is not set +# CONFIG_BT_NIMBLE_LOG_LEVEL_NONE is not set +# CONFIG_BT_NIMBLE_LOG_LEVEL_ERROR is not set +# CONFIG_BT_NIMBLE_LOG_LEVEL_WARNING is not set +CONFIG_BT_NIMBLE_LOG_LEVEL_INFO=y +# CONFIG_BT_NIMBLE_LOG_LEVEL_DEBUG is not set +CONFIG_BT_NIMBLE_LOG_LEVEL=1 +CONFIG_BT_NIMBLE_MAX_CONNECTIONS=3 +CONFIG_BT_NIMBLE_MAX_BONDS=3 +CONFIG_BT_NIMBLE_MAX_CCCDS=8 +CONFIG_BT_NIMBLE_L2CAP_COC_MAX_NUM=0 +# CONFIG_BT_NIMBLE_PINNED_TO_CORE_0 is not set +CONFIG_BT_NIMBLE_PINNED_TO_CORE_1=y +CONFIG_BT_NIMBLE_PINNED_TO_CORE=1 +CONFIG_BT_NIMBLE_TASK_STACK_SIZE=4096 +CONFIG_BT_NIMBLE_ROLE_CENTRAL=y +CONFIG_BT_NIMBLE_ROLE_PERIPHERAL=y +CONFIG_BT_NIMBLE_ROLE_BROADCASTER=y +CONFIG_BT_NIMBLE_ROLE_OBSERVER=y +CONFIG_BT_NIMBLE_NVS_PERSIST=y +CONFIG_BT_NIMBLE_SM_LEGACY=y +CONFIG_BT_NIMBLE_SM_SC=y +# CONFIG_BT_NIMBLE_DEBUG is not set +# CONFIG_BT_NIMBLE_SM_SC_DEBUG_KEYS is not set +CONFIG_BT_NIMBLE_SVC_GAP_DEVICE_NAME="nimble" +CONFIG_BT_NIMBLE_GAP_DEVICE_NAME_MAX_LEN=31 +CONFIG_BT_NIMBLE_ATT_PREFERRED_MTU=256 +CONFIG_BT_NIMBLE_SVC_GAP_APPEARANCE=0 +CONFIG_BT_NIMBLE_ACL_BUF_COUNT=20 +CONFIG_BT_NIMBLE_ACL_BUF_SIZE=255 +CONFIG_BT_NIMBLE_HCI_EVT_BUF_SIZE=70 +CONFIG_BT_NIMBLE_HCI_EVT_HI_BUF_COUNT=30 +CONFIG_BT_NIMBLE_HCI_EVT_LO_BUF_COUNT=8 +CONFIG_BT_NIMBLE_MSYS1_BLOCK_COUNT=12 +# CONFIG_BT_NIMBLE_HS_FLOW_CTRL is not set +CONFIG_BT_NIMBLE_RPA_TIMEOUT=900 +# CONFIG_BT_NIMBLE_MESH is not set +CONFIG_BT_NIMBLE_CRYPTO_STACK_MBEDTLS=y +CONFIG_BT_NIMBLE_HS_STOP_TIMEOUT_MS=2000 +# CONFIG_BT_NIMBLE_HOST_BASED_PRIVACY is not set +CONFIG_BT_NIMBLE_ENABLE_CONN_REATTEMPT=y +CONFIG_BT_NIMBLE_MAX_CONN_REATTEMPT=3 +CONFIG_BT_NIMBLE_EXT_ADV=y +CONFIG_BT_NIMBLE_MAX_EXT_ADV_INSTANCES=1 +CONFIG_BT_NIMBLE_MAX_EXT_ADV_DATA_LEN=1650 +CONFIG_BT_NIMBLE_ENABLE_PERIODIC_ADV=y +CONFIG_BT_NIMBLE_MAX_PERIODIC_SYNCS=1 +# CONFIG_BT_NIMBLE_BLUFI_ENABLE is not set +CONFIG_BT_NIMBLE_USE_ESP_TIMER=y +# end of NimBLE Options + +# CONFIG_BLUEDROID_ENABLED is not set +# +# Deprecated options for backward compatibility +# +CONFIG_NIMBLE_ENABLED=y +CONFIG_NIMBLE_MEM_ALLOC_MODE_INTERNAL=y +# CONFIG_NIMBLE_MEM_ALLOC_MODE_DEFAULT is not set +CONFIG_NIMBLE_MAX_CONNECTIONS=3 +CONFIG_NIMBLE_MAX_BONDS=3 +CONFIG_NIMBLE_MAX_CCCDS=8 +CONFIG_NIMBLE_L2CAP_COC_MAX_NUM=0 +CONFIG_NIMBLE_PINNED_TO_CORE_0=y +# CONFIG_NIMBLE_PINNED_TO_CORE_1 is not set +CONFIG_NIMBLE_PINNED_TO_CORE=0 +CONFIG_NIMBLE_TASK_STACK_SIZE=4096 +CONFIG_NIMBLE_ROLE_CENTRAL=y +CONFIG_NIMBLE_ROLE_PERIPHERAL=y +CONFIG_NIMBLE_ROLE_BROADCASTER=y +CONFIG_NIMBLE_ROLE_OBSERVER=y +CONFIG_NIMBLE_NVS_PERSIST=y +CONFIG_NIMBLE_SM_LEGACY=y +CONFIG_NIMBLE_SM_SC=y +# CONFIG_NIMBLE_DEBUG is not set +# CONFIG_NIMBLE_SM_SC_DEBUG_KEYS is not set +CONFIG_NIMBLE_SVC_GAP_DEVICE_NAME="nimble" +CONFIG_NIMBLE_GAP_DEVICE_NAME_MAX_LEN=31 +CONFIG_NIMBLE_ATT_PREFERRED_MTU=256 +CONFIG_NIMBLE_SVC_GAP_APPEARANCE=0 +CONFIG_NIMBLE_ACL_BUF_COUNT=20 +CONFIG_NIMBLE_ACL_BUF_SIZE=255 +CONFIG_NIMBLE_HCI_EVT_BUF_SIZE=70 +CONFIG_NIMBLE_HCI_EVT_HI_BUF_COUNT=30 +CONFIG_NIMBLE_HCI_EVT_LO_BUF_COUNT=8 +CONFIG_NIMBLE_MSYS1_BLOCK_COUNT=12 +# CONFIG_NIMBLE_HS_FLOW_CTRL is not set +CONFIG_NIMBLE_RPA_TIMEOUT=900 +# CONFIG_NIMBLE_MESH is not set +CONFIG_NIMBLE_CRYPTO_STACK_MBEDTLS=y +CONFIG_SW_COEXIST_ENABLE=y +# end of Deprecated options for backward compatibility diff --git a/ports/espressif/esp-idf-config/sdkconfig-debug.defaults b/ports/espressif/esp-idf-config/sdkconfig-debug.defaults index 381483a8b9..9d02c62445 100644 --- a/ports/espressif/esp-idf-config/sdkconfig-debug.defaults +++ b/ports/espressif/esp-idf-config/sdkconfig-debug.defaults @@ -1,17 +1,17 @@ # # Bootloader config # -# CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE is not set -CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_DEBUG=y +CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y +# CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_DEBUG is not set # CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_PERF is not set # CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_NONE is not set # end of Bootloader config -CONFIG_COMPILER_OPTIMIZATION_DEFAULT=y +# CONFIG_COMPILER_OPTIMIZATION_DEFAULT is not set # # Compiler options # -# CONFIG_COMPILER_OPTIMIZATION_SIZE is not set +CONFIG_COMPILER_OPTIMIZATION_SIZE=y # CONFIG_COMPILER_OPTIMIZATION_PERF is not set # CONFIG_COMPILER_OPTIMIZATION_NONE is not set CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_ENABLE=y diff --git a/ports/espressif/esp-idf-config/sdkconfig-esp32s3.defaults b/ports/espressif/esp-idf-config/sdkconfig-esp32s3.defaults index e655f4ceb1..9b1c9f4263 100644 --- a/ports/espressif/esp-idf-config/sdkconfig-esp32s3.defaults +++ b/ports/espressif/esp-idf-config/sdkconfig-esp32s3.defaults @@ -14,7 +14,7 @@ CONFIG_SDK_TOOLPREFIX="xtensa-esp32s3-elf-" CONFIG_BOOTLOADER_OFFSET_IN_FLASH=0x0 # end of Bootloader config -# CONFIG_ESP32S3_DEFAULT_CPU_FREQ_80 is not set +CONFIG_BT_SOC_SUPPORT_5_0=y # # ESP32S3-Specific # diff --git a/ports/espressif/mpconfigport.mk b/ports/espressif/mpconfigport.mk index 0f297b9989..46e5bd3bb7 100644 --- a/ports/espressif/mpconfigport.mk +++ b/ports/espressif/mpconfigport.mk @@ -36,6 +36,8 @@ CIRCUITPY_MODULE ?= none ifeq ($(IDF_TARGET),esp32c3) CIRCUITPY_USB = 0 CIRCUITPY_ALARM = 0 +CIRCUITPY_BLEIO = 1 +CIRCUITPY_BLEIO_HCI = 0 CIRCUITPY_COUNTIO = 0 CIRCUITPY_ROTARYIO = 0 CIRCUITPY_AUDIOBUSIO = 0 @@ -45,8 +47,14 @@ CIRCUITPY_PARALLELDISPLAY = 0 CIRCUITPY_TOUCHIO ?= 1 CIRCUITPY_TOUCHIO_USE_NATIVE = 0 else ifeq ($(IDF_TARGET),esp32s3) +CIRCUITPY_BLEIO = 1 +CIRCUITPY_BLEIO_HCI = 0 CIRCUITPY_IMAGECAPTURE = 0 CIRCUITPY_PARALLELDISPLAY = 0 +else ifeq ($(IDF_TARGET),esp32s2) +# No BLE on S2 +CIRCUITPY_BLEIO = 0 +CIRCUITPY_BLEIO_HCI = 0 endif # From ESP32-S2/S3 Technical Reference Manual: diff --git a/ports/espressif/peripherals/rmt.c b/ports/espressif/peripherals/rmt.c index 6fbf81f1bd..362bf85748 100644 --- a/ports/espressif/peripherals/rmt.c +++ b/ports/espressif/peripherals/rmt.c @@ -37,8 +37,17 @@ void peripherals_rmt_reset(void) { } } -rmt_channel_t peripherals_find_and_reserve_rmt(void) { - for (size_t i = 0; i < RMT_CHANNEL_MAX; i++) { +rmt_channel_t peripherals_find_and_reserve_rmt(bool mode) { + size_t start_channel = 0; + size_t end_channel = RMT_CHANNEL_MAX; + #if SOC_RMT_CHANNELS_PER_GROUP > 4 + if (mode == RECEIVE_MODE) { + start_channel = 4; + } else { + end_channel = 4; + } + #endif + for (size_t i = start_channel; i < end_channel; i++) { if (!rmt_reserved_channels[i]) { rmt_reserved_channels[i] = true; return i; diff --git a/ports/espressif/peripherals/rmt.h b/ports/espressif/peripherals/rmt.h index 810b331048..24a4383789 100644 --- a/ports/espressif/peripherals/rmt.h +++ b/ports/espressif/peripherals/rmt.h @@ -30,9 +30,11 @@ #include "py/mphal.h" #include "components/driver/include/driver/rmt.h" #include +#define TRANSMIT_MODE true +#define RECEIVE_MODE false void peripherals_rmt_reset(void); -rmt_channel_t peripherals_find_and_reserve_rmt(void); +rmt_channel_t peripherals_find_and_reserve_rmt(bool mode); void peripherals_free_rmt(rmt_channel_t chan); #endif // MICROPY_INCLUDED_ESPRESSIF_PERIPHERALS_RMT_H diff --git a/ports/espressif/supervisor/port.c b/ports/espressif/supervisor/port.c index d6eb32b395..11709eda40 100644 --- a/ports/espressif/supervisor/port.c +++ b/ports/espressif/supervisor/port.c @@ -51,6 +51,8 @@ #include "supervisor/background_callback.h" #include "supervisor/memory.h" #include "supervisor/shared/tick.h" +#include "shared-bindings/microcontroller/__init__.h" +#include "shared-bindings/microcontroller/RunMode.h" #include "shared-bindings/rtc/__init__.h" #include "peripherals/rmt.h" @@ -68,6 +70,10 @@ #include "common-hal/audiobusio/__init__.h" #endif +#if CIRCUITPY_BLEIO +#include "shared-bindings/_bleio/__init__.h" +#endif + #if CIRCUITPY_IMAGECAPTURE #include "cam.h" #endif @@ -77,6 +83,8 @@ #include "esp_debug_helpers.h" +#include "esp_ipc.h" + #ifdef CONFIG_SPIRAM #include "esp32/spiram.h" #endif @@ -103,7 +111,7 @@ TaskHandle_t circuitpython_task = NULL; extern void esp_restart(void) NORETURN; -STATIC void tick_timer_cb(void *arg) { +STATIC void tick_on_cp_core(void *arg) { supervisor_tick(); // CircuitPython's VM is run in a separate FreeRTOS task from timer callbacks. So, we have to @@ -111,6 +119,18 @@ STATIC void tick_timer_cb(void *arg) { xTaskNotifyGive(circuitpython_task); } +// This function may happen on the PRO core when CP is on the APP core. So, make +// sure we run on the CP core. +STATIC void tick_timer_cb(void *arg) { + #if defined(CONFIG_FREERTOS_UNICORE) && CONFIG_FREERTOS_UNICORE + tick_on_cp_core(arg); + #else + // This only blocks until the start of the function. That's ok since the PRO + // core shouldn't care what we do. + esp_ipc_call(CONFIG_ESP_MAIN_TASK_AFFINITY, tick_on_cp_core, NULL); + #endif +} + void sleep_timer_cb(void *arg); safe_mode_t port_init(void) { @@ -263,6 +283,10 @@ void reset_port(void) { watchdog_reset(); #endif + #if CIRCUITPY_BLEIO + bleio_reset(); + #endif + #if CIRCUITPY_WIFI wifi_reset(); #endif @@ -273,6 +297,7 @@ void reset_port(void) { } void reset_to_bootloader(void) { + common_hal_mcu_on_next_reset(RUNMODE_BOOTLOADER); esp_restart(); } diff --git a/ports/espressif/tools/update_sdkconfig.py b/ports/espressif/tools/update_sdkconfig.py index ce174fd12a..e89f7ab00d 100644 --- a/ports/espressif/tools/update_sdkconfig.py +++ b/ports/espressif/tools/update_sdkconfig.py @@ -49,6 +49,7 @@ TARGET_SETTINGS = [ "CONFIG_TOOLPREFIX", "ESP_SLEEP_GPIO_RESET_WORKAROUND", "CONFIG_ESP_PHY_ENABLE_USB", + "CONFIG_BT_SOC_SUPPORT_5_0", ] BOARD_SETTINGS = [ @@ -65,6 +66,8 @@ FLASH_SETTINGS = [ "CONFIG_PARTITION_TABLE_FILENAME", ] +BLE_SETTINGS = ["CONFIG_BT_", "CONFIG_BLUEDROID_", "CONFIG_NIMBLE_", "CONFIG_SW_COEXIST_ENABLE"] + # boards/lilygo_ttgo_t8_s2_st7789/sdkconfig # CONFIG_LWIP_DNS_SUPPORT_MDNS_QUERIES=y @@ -80,16 +83,17 @@ def matches_group(line, group): def add_group(lines, last_group, current_group): - if last_group != current_group: + # TODO: Properly handle nested groups + if last_group != current_group[-1]: if last_group: lines.append("# end of " + last_group) lines.append("") return None if current_group: lines.append("#") - lines.append("# " + current_group) + lines.append("# " + current_group[-1]) lines.append("#") - return current_group + return current_group[-1] return last_group @@ -120,12 +124,14 @@ def update(debug, board, update_all): opt_config = pathlib.Path("esp-idf-config/sdkconfig-opt.defaults") flash_config = pathlib.Path(f"esp-idf-config/sdkconfig-{flash}.defaults") target_config = pathlib.Path(f"esp-idf-config/sdkconfig-{target}.defaults") + ble_config = pathlib.Path(f"esp-idf-config/sdkconfig-ble.defaults") board_config = pathlib.Path(f"boards/{board}/sdkconfig") defaults = default_config.read_text().split("\n") defaults.extend(opt_config.read_text().split("\n")) defaults.extend(flash_config.read_text().split("\n")) defaults.extend(target_config.read_text().split("\n")) + defaults.extend(ble_config.read_text().split("\n")) board_settings = [] last_board_group = None @@ -135,15 +141,17 @@ def update(debug, board, update_all): last_opt_group = None target_settings = [] last_target_group = None + ble_settings = [] + last_ble_group = None default_settings = [] last_default_group = None - current_group = None + current_group = [] for line in input_config.read_text().split("\n"): if line.startswith("# ") and "CONFIG_" not in line and len(line) > 3: if line.startswith("# end of"): - current_group = None + current_group.pop() else: - current_group = line[2:] + current_group.append(line[2:]) elif (not update_all and line not in defaults) or ( update_all and matches_group(line, BOARD_SETTINGS) ): @@ -159,6 +167,9 @@ def update(debug, board, update_all): elif matches_group(line, TARGET_SETTINGS): last_target_group = add_group(target_settings, last_target_group, current_group) target_settings.append(line) + elif matches_group(line, BLE_SETTINGS): + last_ble_group = add_group(ble_settings, last_ble_group, current_group) + ble_settings.append(line) elif "CONFIG_" in line: last_default_group = add_group(default_settings, last_default_group, current_group) default_settings.append(line) @@ -167,6 +178,7 @@ def update(debug, board, update_all): add_group(opt_settings, last_opt_group, current_group) add_group(flash_settings, last_flash_group, current_group) add_group(target_settings, last_target_group, current_group) + add_group(ble_settings, last_ble_group, current_group) add_group(default_settings, last_default_group, current_group) board_config.write_text("\n".join(board_settings)) @@ -175,6 +187,7 @@ def update(debug, board, update_all): opt_config.write_text("\n".join(opt_settings)) default_config.write_text("\n".join(default_settings)) target_config.write_text("\n".join(target_settings)) + ble_config.write_text("\n".join(ble_settings)) if __name__ == "__main__": diff --git a/ports/mimxrt10xx/boards/feather_m7_1011/pins.c b/ports/mimxrt10xx/boards/feather_m7_1011/pins.c index 4bd7f13668..93c9d6430d 100644 --- a/ports/mimxrt10xx/boards/feather_m7_1011/pins.c +++ b/ports/mimxrt10xx/boards/feather_m7_1011/pins.c @@ -42,6 +42,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO_00) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, }; diff --git a/ports/mimxrt10xx/boards/metro_m7_1011/pins.c b/ports/mimxrt10xx/boards/metro_m7_1011/pins.c index 0198ed90cc..886909e1dd 100644 --- a/ports/mimxrt10xx/boards/metro_m7_1011/pins.c +++ b/ports/mimxrt10xx/boards/metro_m7_1011/pins.c @@ -53,6 +53,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO_00) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, }; diff --git a/ports/mimxrt10xx/common-hal/busio/I2C.c b/ports/mimxrt10xx/common-hal/busio/I2C.c index 74639d0ef1..77df979e4d 100644 --- a/ports/mimxrt10xx/common-hal/busio/I2C.c +++ b/ports/mimxrt10xx/common-hal/busio/I2C.c @@ -210,7 +210,7 @@ void common_hal_busio_i2c_unlock(busio_i2c_obj_t *self) { self->has_lock = false; } -uint8_t common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t addr, +STATIC uint8_t _common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t addr, const uint8_t *data, size_t len, bool transmit_stop_bit) { lpi2c_master_transfer_t xfer = { 0 }; @@ -227,6 +227,11 @@ uint8_t common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t addr, return MP_EIO; } +uint8_t common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t addr, + const uint8_t *data, size_t len) { + return _common_hal_busio_i2c_write(self, addr, data, len, true); +} + uint8_t common_hal_busio_i2c_read(busio_i2c_obj_t *self, uint16_t addr, uint8_t *data, size_t len) { @@ -243,3 +248,13 @@ uint8_t common_hal_busio_i2c_read(busio_i2c_obj_t *self, uint16_t addr, return MP_EIO; } + +uint8_t common_hal_busio_i2c_write_read(busio_i2c_obj_t *self, uint16_t addr, + uint8_t *out_data, size_t out_len, uint8_t *in_data, size_t in_len) { + uint8_t result = _common_hal_busio_i2c_write(self, addr, out_data, out_len, false); + if (result != 0) { + return result; + } + + return common_hal_busio_i2c_read(self, addr, in_data, in_len); +} diff --git a/ports/nrf/boards/adafruit_led_glasses_nrf52840/mpconfigboard.mk b/ports/nrf/boards/adafruit_led_glasses_nrf52840/mpconfigboard.mk index 5d90582865..30a4aab232 100644 --- a/ports/nrf/boards/adafruit_led_glasses_nrf52840/mpconfigboard.mk +++ b/ports/nrf/boards/adafruit_led_glasses_nrf52840/mpconfigboard.mk @@ -5,6 +5,7 @@ USB_MANUFACTURER = "Adafruit Industries LLC" MCU_CHIP = nrf52840 - QSPI_FLASH_FILESYSTEM = 1 EXTERNAL_FLASH_DEVICES = "GD25Q16C" + +CIRCUITPY_IS31FL3741 = 1 diff --git a/ports/nrf/boards/adafruit_led_glasses_nrf52840/pins.c b/ports/nrf/boards/adafruit_led_glasses_nrf52840/pins.c index 8bc4ead19b..a53b1359c1 100644 --- a/ports/nrf/boards/adafruit_led_glasses_nrf52840/pins.c +++ b/ports/nrf/boards/adafruit_led_glasses_nrf52840/pins.c @@ -21,6 +21,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_P0_06) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, }; MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/nrf/boards/bluemicro833/mpconfigboard.mk b/ports/nrf/boards/bluemicro833/mpconfigboard.mk index 71ae39ee80..b7594f0d89 100644 --- a/ports/nrf/boards/bluemicro833/mpconfigboard.mk +++ b/ports/nrf/boards/bluemicro833/mpconfigboard.mk @@ -24,7 +24,6 @@ CIRCUITPY_DISPLAYIO = 0 CIRCUITPY_FRAMEBUFFERIO = 0 CIRCUITPY_FREQUENCYIO = 0 CIRCUITPY_I2CPERIPHERAL = 0 -CIRCUITPY_IS31FL3741 = 0 CIRCUITPY_JSON = 0 CIRCUITPY_KEYPAD = 1 CIRCUITPY_MSGPACK = 0 diff --git a/ports/nrf/boards/clue_nrf52840_express/pins.c b/ports/nrf/boards/clue_nrf52840_express/pins.c index 648477da4a..344e344f5b 100644 --- a/ports/nrf/boards/clue_nrf52840_express/pins.c +++ b/ports/nrf/boards/clue_nrf52840_express/pins.c @@ -107,6 +107,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_TFT_MOSI), MP_ROM_PTR(&pin_P0_15) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, diff --git a/ports/nrf/boards/hiibot_bluefi/pins.c b/ports/nrf/boards/hiibot_bluefi/pins.c index 2a18996c72..ba1910dc9d 100644 --- a/ports/nrf/boards/hiibot_bluefi/pins.c +++ b/ports/nrf/boards/hiibot_bluefi/pins.c @@ -174,6 +174,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_AUDIO), MP_ROM_PTR(&pin_P1_15) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, diff --git a/ports/nrf/boards/microbit_v2/mpconfigboard.mk b/ports/nrf/boards/microbit_v2/mpconfigboard.mk index a893acec44..dc47f2be4e 100644 --- a/ports/nrf/boards/microbit_v2/mpconfigboard.mk +++ b/ports/nrf/boards/microbit_v2/mpconfigboard.mk @@ -7,13 +7,11 @@ INTERNAL_FLASH_FILESYSTEM = 1 CIRCUITPY_ALARM = 0 CIRCUITPY_AUDIOMP3 = 0 -CIRCUITPY_BINASCII = 0 CIRCUITPY_BITBANGIO = 0 CIRCUITPY_BUILTINS_POW3=0 CIRCUITPY_BUSDEVICE = 0 CIRCUITPY_COUNTIO = 0 CIRCUITPY_DISPLAYIO = 0 -CIRCUITPY_IS31FL3741 = 0 CIRCUITPY_FRAMEBUFFERIO = 0 CIRCUITPY_FREQUENCYIO = 0 CIRCUITPY_I2CPERIPHERAL = 0 diff --git a/ports/nrf/boards/pca10100/mpconfigboard.mk b/ports/nrf/boards/pca10100/mpconfigboard.mk index 8ae25393f8..59f2b217c3 100644 --- a/ports/nrf/boards/pca10100/mpconfigboard.mk +++ b/ports/nrf/boards/pca10100/mpconfigboard.mk @@ -19,7 +19,6 @@ CIRCUITPY_DISPLAYIO = 0 CIRCUITPY_FRAMEBUFFERIO = 0 CIRCUITPY_FREQUENCYIO = 0 CIRCUITPY_I2CPERIPHERAL = 0 -CIRCUITPY_IS31FL3741 = 0 CIRCUITPY_JSON = 0 CIRCUITPY_KEYPAD = 0 CIRCUITPY_MSGPACK = 0 diff --git a/ports/nrf/boards/simmel/mpconfigboard.mk b/ports/nrf/boards/simmel/mpconfigboard.mk index 85bdca6dc1..67f5dfbd6d 100644 --- a/ports/nrf/boards/simmel/mpconfigboard.mk +++ b/ports/nrf/boards/simmel/mpconfigboard.mk @@ -22,7 +22,6 @@ CIRCUITPY_DISPLAYIO = 0 CIRCUITPY_ERRNO = 0 CIRCUITPY_FRAMEBUFFERIO = 0 CIRCUITPY_GETPASS = 0 -CIRCUITPY_IS31FL3741 = 0 CIRCUITPY_KEYPAD = 0 CIRCUITPY_MSGPACK = 0 CIRCUITPY_NEOPIXEL_WRITE = 0 diff --git a/ports/nrf/boards/sparkfun_nrf52840_mini/pins.c b/ports/nrf/boards/sparkfun_nrf52840_mini/pins.c index a1e2e27cc1..e3188f9bdb 100644 --- a/ports/nrf/boards/sparkfun_nrf52840_mini/pins.c +++ b/ports/nrf/boards/sparkfun_nrf52840_mini/pins.c @@ -50,6 +50,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_QWIIC), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, }; MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/nrf/common-hal/_bleio/__init__.h b/ports/nrf/common-hal/_bleio/__init__.h index d94267dd3c..f10001f662 100644 --- a/ports/nrf/common-hal/_bleio/__init__.h +++ b/ports/nrf/common-hal/_bleio/__init__.h @@ -28,7 +28,6 @@ #define MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_INIT_H void bleio_background(void); -void bleio_reset(void); typedef struct { ble_gap_enc_key_t own_enc; diff --git a/ports/nrf/common-hal/busio/I2C.c b/ports/nrf/common-hal/busio/I2C.c index de9417a6cc..322b5f2faa 100644 --- a/ports/nrf/common-hal/busio/I2C.c +++ b/ports/nrf/common-hal/busio/I2C.c @@ -238,7 +238,7 @@ void common_hal_busio_i2c_unlock(busio_i2c_obj_t *self) { self->has_lock = false; } -uint8_t common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t addr, const uint8_t *data, size_t len, bool stopBit) { +STATIC uint8_t _common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t addr, const uint8_t *data, size_t len, bool stopBit) { if (len == 0) { return common_hal_busio_i2c_probe(self, addr) ? 0 : MP_ENODEV; } @@ -266,6 +266,10 @@ uint8_t common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t addr, const u return twi_error_to_mp(err); } +uint8_t common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t addr, const uint8_t *data, size_t len) { + return _common_hal_busio_i2c_write(self, addr, data, len, true); +} + uint8_t common_hal_busio_i2c_read(busio_i2c_obj_t *self, uint16_t addr, uint8_t *data, size_t len) { if (len == 0) { return 0; @@ -292,3 +296,13 @@ uint8_t common_hal_busio_i2c_read(busio_i2c_obj_t *self, uint16_t addr, uint8_t return twi_error_to_mp(err); } + +uint8_t common_hal_busio_i2c_write_read(busio_i2c_obj_t *self, uint16_t addr, + uint8_t *out_data, size_t out_len, uint8_t *in_data, size_t in_len) { + uint8_t result = _common_hal_busio_i2c_write(self, addr, out_data, out_len, false); + if (result != 0) { + return result; + } + + return common_hal_busio_i2c_read(self, addr, in_data, in_len); +} diff --git a/ports/nrf/mpconfigport.mk b/ports/nrf/mpconfigport.mk index 6f432c55ae..1a12c20f2d 100644 --- a/ports/nrf/mpconfigport.mk +++ b/ports/nrf/mpconfigport.mk @@ -27,8 +27,6 @@ CIRCUITPY_BLEIO ?= 1 # No I2CPeripheral implementation CIRCUITPY_I2CPERIPHERAL = 0 -CIRCUITPY_IS31FL3741 ?= 1 - CIRCUITPY_RTC ?= 1 # frequencyio not yet implemented diff --git a/ports/nrf/supervisor/port.c b/ports/nrf/supervisor/port.c index a1eb973b83..5c1139271d 100644 --- a/ports/nrf/supervisor/port.c +++ b/ports/nrf/supervisor/port.c @@ -45,7 +45,6 @@ #include "nrf_nvic.h" #include "common-hal/microcontroller/Pin.h" -#include "common-hal/_bleio/__init__.h" #include "common-hal/alarm/time/TimeAlarm.h" #include "common-hal/analogio/AnalogIn.h" #include "common-hal/busio/I2C.h" @@ -59,6 +58,7 @@ #include "common-hal/watchdog/WatchDogTimer.h" #include "common-hal/alarm/__init__.h" +#include "shared-bindings/_bleio/__init__.h" #include "shared-bindings/microcontroller/__init__.h" #include "shared-bindings/rtc/__init__.h" diff --git a/ports/raspberrypi/Makefile b/ports/raspberrypi/Makefile index b63b26d58d..67de654255 100644 --- a/ports/raspberrypi/Makefile +++ b/ports/raspberrypi/Makefile @@ -187,7 +187,7 @@ SRC_SDK := \ src/rp2_common/pico_unique_id/unique_id.c \ SRC_SDK := $(addprefix sdk/, $(SRC_SDK)) -$(patsubst %.c,$(BUILD)/%.o,$(SRC_SDK)): CFLAGS += -Wno-missing-prototypes +$(patsubst %.c,$(BUILD)/%.o,$(SRC_SDK)): CFLAGS += -Wno-missing-prototypes -Wno-undef SRC_C += \ boards/$(BOARD)/board.c \ diff --git a/ports/raspberrypi/boards/adafruit_feather_rp2040/mpconfigboard.mk b/ports/raspberrypi/boards/adafruit_feather_rp2040/mpconfigboard.mk index 84c4adabb7..c77d2d2c13 100644 --- a/ports/raspberrypi/boards/adafruit_feather_rp2040/mpconfigboard.mk +++ b/ports/raspberrypi/boards/adafruit_feather_rp2040/mpconfigboard.mk @@ -6,4 +6,4 @@ USB_MANUFACTURER = "Adafruit" CHIP_VARIANT = RP2040 CHIP_FAMILY = rp2 -EXTERNAL_FLASH_DEVICES = "GD25Q64C" +EXTERNAL_FLASH_DEVICES = "GD25Q64C,W25Q64JVxQ" diff --git a/ports/raspberrypi/boards/adafruit_feather_rp2040/pins.c b/ports/raspberrypi/boards/adafruit_feather_rp2040/pins.c index 6afba676b4..a6bcaea125 100644 --- a/ports/raspberrypi/boards/adafruit_feather_rp2040/pins.c +++ b/ports/raspberrypi/boards/adafruit_feather_rp2040/pins.c @@ -32,6 +32,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO16) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, }; diff --git a/ports/raspberrypi/boards/adafruit_kb2040/pins.c b/ports/raspberrypi/boards/adafruit_kb2040/pins.c index 34e13fb6c7..fcf305d67b 100644 --- a/ports/raspberrypi/boards/adafruit_kb2040/pins.c +++ b/ports/raspberrypi/boards/adafruit_kb2040/pins.c @@ -40,6 +40,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO17) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, }; diff --git a/ports/raspberrypi/boards/adafruit_macropad_rp2040/pins.c b/ports/raspberrypi/boards/adafruit_macropad_rp2040/pins.c index 470d4d5371..1abb8469f0 100644 --- a/ports/raspberrypi/boards/adafruit_macropad_rp2040/pins.c +++ b/ports/raspberrypi/boards/adafruit_macropad_rp2040/pins.c @@ -45,6 +45,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO28) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display)} diff --git a/ports/raspberrypi/boards/adafruit_qt2040_trinkey/pins.c b/ports/raspberrypi/boards/adafruit_qt2040_trinkey/pins.c index 98fd7cf56f..1bdf2b35df 100644 --- a/ports/raspberrypi/boards/adafruit_qt2040_trinkey/pins.c +++ b/ports/raspberrypi/boards/adafruit_qt2040_trinkey/pins.c @@ -14,6 +14,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_BUTTON), MP_ROM_PTR(&pin_GPIO12) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, }; MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/raspberrypi/boards/adafruit_qtpy_rp2040/mpconfigboard.h b/ports/raspberrypi/boards/adafruit_qtpy_rp2040/mpconfigboard.h index 5d3795dd5d..f606ab22c4 100644 --- a/ports/raspberrypi/boards/adafruit_qtpy_rp2040/mpconfigboard.h +++ b/ports/raspberrypi/boards/adafruit_qtpy_rp2040/mpconfigboard.h @@ -4,12 +4,12 @@ #define MICROPY_HW_NEOPIXEL (&pin_GPIO12) #define CIRCUITPY_STATUS_LED_POWER (&pin_GPIO11) -#define DEFAULT_I2C_BUS_SCL (&pin_GPIO25) -#define DEFAULT_I2C_BUS_SDA (&pin_GPIO24) +#define CIRCUITPY_BOARD_I2C (2) +#define CIRCUITPY_BOARD_I2C_PIN {{.scl = &pin_GPIO25, .sda = &pin_GPIO24}, \ + {.scl = &pin_GPIO23, .sda = &pin_GPIO22}} -#define DEFAULT_SPI_BUS_SCK (&pin_GPIO6) -#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO3) -#define DEFAULT_SPI_BUS_MISO (&pin_GPIO4) +#define CIRCUITPY_BOARD_SPI (1) +#define CIRCUITPY_BOARD_SPI_PIN {{.clock = &pin_GPIO6, .mosi = &pin_GPIO3, .miso = &pin_GPIO4}} -#define DEFAULT_UART_BUS_RX (&pin_GPIO5) -#define DEFAULT_UART_BUS_TX (&pin_GPIO20) +#define CIRCUITPY_BOARD_UART (1) +#define CIRCUITPY_BOARD_UART_PIN {{.tx = &pin_GPIO20, .rx = &pin_GPIO5}} diff --git a/ports/raspberrypi/boards/adafruit_qtpy_rp2040/pins.c b/ports/raspberrypi/boards/adafruit_qtpy_rp2040/pins.c index 0d6835f48b..082807f577 100644 --- a/ports/raspberrypi/boards/adafruit_qtpy_rp2040/pins.c +++ b/ports/raspberrypi/boards/adafruit_qtpy_rp2040/pins.c @@ -1,5 +1,7 @@ #include "shared-bindings/board/__init__.h" +CIRCUITPY_BOARD_BUS_SINGLETON(stemma_i2c, i2c, 1) + STATIC const mp_rom_map_elem_t board_module_globals_table[] = { CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS @@ -47,5 +49,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, + + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_stemma_i2c_obj) }, }; MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/raspberrypi/boards/jpconstantineau_pykey18/pins.c b/ports/raspberrypi/boards/jpconstantineau_pykey18/pins.c index 3cd5d5843e..dfa1ae9545 100644 --- a/ports/raspberrypi/boards/jpconstantineau_pykey18/pins.c +++ b/ports/raspberrypi/boards/jpconstantineau_pykey18/pins.c @@ -19,5 +19,6 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO22) }, { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO23) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, }; MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/raspberrypi/boards/jpconstantineau_pykey87/pins.c b/ports/raspberrypi/boards/jpconstantineau_pykey87/pins.c index cd5612f45b..63a7826f1d 100644 --- a/ports/raspberrypi/boards/jpconstantineau_pykey87/pins.c +++ b/ports/raspberrypi/boards/jpconstantineau_pykey87/pins.c @@ -32,5 +32,6 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO22) }, { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO23) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, }; MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/raspberrypi/boards/melopero_shake_rp2040/pins.c b/ports/raspberrypi/boards/melopero_shake_rp2040/pins.c index 76ab220216..c3bc3f6d6f 100644 --- a/ports/raspberrypi/boards/melopero_shake_rp2040/pins.c +++ b/ports/raspberrypi/boards/melopero_shake_rp2040/pins.c @@ -34,6 +34,7 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO16) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, }; diff --git a/ports/raspberrypi/boards/pimoroni_interstate75/pins.c b/ports/raspberrypi/boards/pimoroni_interstate75/pins.c index 1244f63a22..2460ebc76a 100644 --- a/ports/raspberrypi/boards/pimoroni_interstate75/pins.c +++ b/ports/raspberrypi/boards/pimoroni_interstate75/pins.c @@ -50,5 +50,6 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_CURRENT_SENSE), MP_ROM_PTR(&pin_GPIO29) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, }; MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/raspberrypi/boards/pimoroni_picolipo_16mb/pins.c b/ports/raspberrypi/boards/pimoroni_picolipo_16mb/pins.c index 577b29736e..a89950cca7 100644 --- a/ports/raspberrypi/boards/pimoroni_picolipo_16mb/pins.c +++ b/ports/raspberrypi/boards/pimoroni_picolipo_16mb/pins.c @@ -50,5 +50,6 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_BAT_SENSE), MP_ROM_PTR(&pin_GPIO29) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, }; MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/raspberrypi/boards/pimoroni_picolipo_4mb/pins.c b/ports/raspberrypi/boards/pimoroni_picolipo_4mb/pins.c index 577b29736e..a89950cca7 100644 --- a/ports/raspberrypi/boards/pimoroni_picolipo_4mb/pins.c +++ b/ports/raspberrypi/boards/pimoroni_picolipo_4mb/pins.c @@ -50,5 +50,6 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_BAT_SENSE), MP_ROM_PTR(&pin_GPIO29) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, }; MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/raspberrypi/boards/pimoroni_plasma2040/pins.c b/ports/raspberrypi/boards/pimoroni_plasma2040/pins.c index 5f685a3528..5ecc44619a 100644 --- a/ports/raspberrypi/boards/pimoroni_plasma2040/pins.c +++ b/ports/raspberrypi/boards/pimoroni_plasma2040/pins.c @@ -39,5 +39,6 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_CURRENT_SENSE), MP_ROM_PTR(&pin_GPIO29) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, }; MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/raspberrypi/boards/sparkfun_pro_micro_rp2040/pins.c b/ports/raspberrypi/boards/sparkfun_pro_micro_rp2040/pins.c index bc7cb048de..f4ebe33e8b 100644 --- a/ports/raspberrypi/boards/sparkfun_pro_micro_rp2040/pins.c +++ b/ports/raspberrypi/boards/sparkfun_pro_micro_rp2040/pins.c @@ -40,6 +40,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO25) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, }; diff --git a/ports/raspberrypi/boards/sparkfun_thing_plus_rp2040/pins.c b/ports/raspberrypi/boards/sparkfun_thing_plus_rp2040/pins.c index a72342c86a..22dccc66bb 100644 --- a/ports/raspberrypi/boards/sparkfun_thing_plus_rp2040/pins.c +++ b/ports/raspberrypi/boards/sparkfun_thing_plus_rp2040/pins.c @@ -59,6 +59,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO25) }, // on-board LED (separate/additional from neopixel) { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, }; diff --git a/ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c b/ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c index 4b4c365385..2f09124f4b 100644 --- a/ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c +++ b/ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c @@ -44,8 +44,6 @@ #include "src/rp2040/hardware_structs/include/hardware/structs/dma.h" #include "src/rp2_common/hardware_pwm/include/hardware/pwm.h" -#define NUM_DMA_TIMERS 4 - // The PWM clock frequency is base_clock_rate / PWM_TOP, typically 125_000_000 / PWM_TOP. // We pick BITS_PER_SAMPLE so we get a clock frequency that is above what would cause aliasing. #define BITS_PER_SAMPLE 10 diff --git a/ports/raspberrypi/common-hal/busio/I2C.c b/ports/raspberrypi/common-hal/busio/I2C.c index 87c78814c2..516cee2227 100644 --- a/ports/raspberrypi/common-hal/busio/I2C.c +++ b/ports/raspberrypi/common-hal/busio/I2C.c @@ -145,7 +145,7 @@ void common_hal_busio_i2c_deinit(busio_i2c_obj_t *self) { } bool common_hal_busio_i2c_probe(busio_i2c_obj_t *self, uint8_t addr) { - return common_hal_busio_i2c_write(self, addr, NULL, 0, true) == 0; + return common_hal_busio_i2c_write(self, addr, NULL, 0) == 0; } bool common_hal_busio_i2c_try_lock(busio_i2c_obj_t *self) { @@ -165,7 +165,7 @@ void common_hal_busio_i2c_unlock(busio_i2c_obj_t *self) { self->has_lock = false; } -uint8_t common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t addr, +STATIC uint8_t _common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t addr, const uint8_t *data, size_t len, bool transmit_stop_bit) { if (len == 0) { // The RP2040 I2C peripheral will not perform 0 byte writes. @@ -203,6 +203,11 @@ uint8_t common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t addr, } } +uint8_t common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t addr, + const uint8_t *data, size_t len) { + return _common_hal_busio_i2c_write(self, addr, data, len, true); +} + uint8_t common_hal_busio_i2c_read(busio_i2c_obj_t *self, uint16_t addr, uint8_t *data, size_t len) { int result = i2c_read_timeout_us(self->peripheral, addr, data, len, false, BUS_TIMEOUT_US); @@ -219,6 +224,16 @@ uint8_t common_hal_busio_i2c_read(busio_i2c_obj_t *self, uint16_t addr, } } +uint8_t common_hal_busio_i2c_write_read(busio_i2c_obj_t *self, uint16_t addr, + uint8_t *out_data, size_t out_len, uint8_t *in_data, size_t in_len) { + uint8_t result = _common_hal_busio_i2c_write(self, addr, out_data, out_len, false); + if (result != 0) { + return result; + } + + return common_hal_busio_i2c_read(self, addr, in_data, in_len); +} + void common_hal_busio_i2c_never_reset(busio_i2c_obj_t *self) { never_reset_i2c[i2c_hw_index(self->peripheral)] = true; diff --git a/ports/raspberrypi/common-hal/neopixel_write/__init__.c b/ports/raspberrypi/common-hal/neopixel_write/__init__.c index da7bf7c19f..09388af481 100644 --- a/ports/raspberrypi/common-hal/neopixel_write/__init__.c +++ b/ports/raspberrypi/common-hal/neopixel_write/__init__.c @@ -98,6 +98,6 @@ void common_hal_neopixel_write(const digitalio_digitalinout_obj_t *digitalinout, gpio_init(digitalinout->pin->number); common_hal_digitalio_digitalinout_switch_to_output((digitalio_digitalinout_obj_t *)digitalinout, false, DRIVE_MODE_PUSH_PULL); - // Update the next start. - next_start_raw_ticks = port_get_raw_ticks(NULL) + 1; + // Update the next start to +2 ticks. This ensures we give it at least 300us. + next_start_raw_ticks = port_get_raw_ticks(NULL) + 2; } diff --git a/ports/raspberrypi/sdk b/ports/raspberrypi/sdk index bfcbefafc5..2062372d20 160000 --- a/ports/raspberrypi/sdk +++ b/ports/raspberrypi/sdk @@ -1 +1 @@ -Subproject commit bfcbefafc5d2a210551a4d9d80b4303d4ae0adf7 +Subproject commit 2062372d203b372849d573f252cf7c6dc2800c0a diff --git a/ports/stm/boards/feather_stm32f405_express/pins.c b/ports/stm/boards/feather_stm32f405_express/pins.c index b039b0af0c..ade7036d5c 100644 --- a/ports/stm/boards/feather_stm32f405_express/pins.c +++ b/ports/stm/boards/feather_stm32f405_express/pins.c @@ -45,6 +45,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_PC00) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, diff --git a/ports/stm/boards/sparkfun_stm32_thing_plus/pins.c b/ports/stm/boards/sparkfun_stm32_thing_plus/pins.c index 3c1d41b42a..df7040ce0a 100644 --- a/ports/stm/boards/sparkfun_stm32_thing_plus/pins.c +++ b/ports/stm/boards/sparkfun_stm32_thing_plus/pins.c @@ -47,6 +47,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_PB11) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_STEMMA_I2C), MP_ROM_PTR(&board_i2c_obj) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, diff --git a/ports/stm/common-hal/busio/I2C.c b/ports/stm/common-hal/busio/I2C.c index ffad368a2f..5ede538b12 100644 --- a/ports/stm/common-hal/busio/I2C.c +++ b/ports/stm/common-hal/busio/I2C.c @@ -246,7 +246,7 @@ void common_hal_busio_i2c_unlock(busio_i2c_obj_t *self) { self->has_lock = false; } -uint8_t common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t addr, +STATIC uint8_t _common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t addr, const uint8_t *data, size_t len, bool transmit_stop_bit) { HAL_StatusTypeDef result; if (!transmit_stop_bit) { @@ -271,6 +271,11 @@ uint8_t common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t addr, return result == HAL_OK ? 0 : MP_EIO; } +uint8_t common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t addr, + const uint8_t *data, size_t len) { + return _common_hal_busio_i2c_write(self, addr, data, len, true); +} + uint8_t common_hal_busio_i2c_read(busio_i2c_obj_t *self, uint16_t addr, uint8_t *data, size_t len) { if (!self->frame_in_prog) { @@ -288,6 +293,16 @@ uint8_t common_hal_busio_i2c_read(busio_i2c_obj_t *self, uint16_t addr, } } +uint8_t common_hal_busio_i2c_write_read(busio_i2c_obj_t *self, uint16_t addr, + uint8_t *out_data, size_t out_len, uint8_t *in_data, size_t in_len) { + uint8_t result = _common_hal_busio_i2c_write(self, addr, out_data, out_len, false); + if (result != 0) { + return result; + } + + return common_hal_busio_i2c_read(self, addr, in_data, in_len); +} + STATIC void i2c_clock_enable(uint8_t mask) { // Note: hard reset required due to soft reboot issue. #ifdef I2C1 diff --git a/ports/stm/common-hal/busio/SPI.c b/ports/stm/common-hal/busio/SPI.c index 77f2b53706..047d59556d 100644 --- a/ports/stm/common-hal/busio/SPI.c +++ b/ports/stm/common-hal/busio/SPI.c @@ -250,7 +250,7 @@ void common_hal_busio_spi_never_reset(busio_spi_obj_t *self) { } bool common_hal_busio_spi_deinited(busio_spi_obj_t *self) { - return self->sck->pin == NULL; + return self->sck == NULL; } void common_hal_busio_spi_deinit(busio_spi_obj_t *self) { diff --git a/ports/stm/common-hal/busio/UART.c b/ports/stm/common-hal/busio/UART.c index d8677126ef..dc37a4e7c8 100644 --- a/ports/stm/common-hal/busio/UART.c +++ b/ports/stm/common-hal/busio/UART.c @@ -259,7 +259,7 @@ void common_hal_busio_uart_never_reset(busio_uart_obj_t *self) { } bool common_hal_busio_uart_deinited(busio_uart_obj_t *self) { - return self->tx->pin == NULL && self->rx->pin == NULL; + return self->tx == NULL && self->rx == NULL; } void common_hal_busio_uart_deinit(busio_uart_obj_t *self) { diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk index 06399673a2..98ac148975 100644 --- a/py/circuitpy_defns.mk +++ b/py/circuitpy_defns.mk @@ -543,6 +543,7 @@ SRC_SHARED_MODULE_ALL = \ ipaddress/IPv4Address.c \ ipaddress/__init__.c \ is31fl3741/IS31FL3741.c \ + is31fl3741/FrameBuffer.c \ is31fl3741/__init__.c \ keypad/__init__.c \ keypad/Event.c \ diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index 7ffb5b7e13..2893df46ec 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -259,23 +259,42 @@ typedef long mp_off_t; #error No *_FLASH_FILESYSTEM set! #endif +// Default board buses. + +#ifndef CIRCUITPY_BOARD_I2C +#if defined(DEFAULT_I2C_BUS_SCL) && defined(DEFAULT_I2C_BUS_SDA) +#define CIRCUITPY_BOARD_I2C (1) +#define CIRCUITPY_BOARD_I2C_PIN {{.scl = DEFAULT_I2C_BUS_SCL, .sda = DEFAULT_I2C_BUS_SDA}} +#else +#define CIRCUITPY_BOARD_I2C (0) +#endif +#endif + +#ifndef CIRCUITPY_BOARD_SPI +#if defined(DEFAULT_SPI_BUS_SCK) && defined(DEFAULT_SPI_BUS_MOSI) && defined(DEFAULT_SPI_BUS_MISO) +#define CIRCUITPY_BOARD_SPI (1) +#define CIRCUITPY_BOARD_SPI_PIN {{.clock = DEFAULT_SPI_BUS_SCK, .mosi = DEFAULT_SPI_BUS_MOSI, .miso = DEFAULT_SPI_BUS_MISO}} +#else +#define CIRCUITPY_BOARD_SPI (0) +#endif +#endif + +#ifndef CIRCUITPY_BOARD_UART +#if defined(DEFAULT_UART_BUS_TX) && defined(DEFAULT_UART_BUS_RX) +#define CIRCUITPY_BOARD_UART (1) +#define CIRCUITPY_BOARD_UART_PIN {{.tx = DEFAULT_UART_BUS_TX, .rx = DEFAULT_UART_BUS_RX}} +#define BOARD_UART_ROOT_POINTER mp_obj_t board_uart_bus; +#else +#define CIRCUITPY_BOARD_UART (0) +#define BOARD_UART_ROOT_POINTER +#endif +#else +#define BOARD_UART_ROOT_POINTER mp_obj_t board_uart_bus; +#endif + // These CIRCUITPY_xxx values should all be defined in the *.mk files as being on or off. // So if any are not defined in *.mk, they'll throw an error here. -#if CIRCUITPY_BOARD -#define BOARD_I2C (defined(DEFAULT_I2C_BUS_SDA) && defined(DEFAULT_I2C_BUS_SCL)) -#define BOARD_SPI (defined(DEFAULT_SPI_BUS_SCK) && defined(DEFAULT_SPI_BUS_MISO) && defined(DEFAULT_SPI_BUS_MOSI)) -#define BOARD_UART (defined(DEFAULT_UART_BUS_RX) && defined(DEFAULT_UART_BUS_TX)) -// I2C and SPI are always allocated off the heap. -#if BOARD_UART -#define BOARD_UART_ROOT_POINTER mp_obj_t shared_uart_bus; -#else -#define BOARD_UART_ROOT_POINTER -#endif -#else -#define BOARD_UART_ROOT_POINTER -#endif - #if CIRCUITPY_DISPLAYIO #ifndef CIRCUITPY_DISPLAY_LIMIT #define CIRCUITPY_DISPLAY_LIMIT (1) diff --git a/py/modio.c b/py/modio.c index 18918cf3ce..23374578cf 100644 --- a/py/modio.c +++ b/py/modio.c @@ -257,7 +257,11 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(resource_stream_obj, resource_stream); #endif STATIC const mp_rom_map_elem_t mp_module_io_globals_table[] = { + #if CIRCUITPY + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_io) }, + #else { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_uio) }, + #endif // Note: mp_builtin_open_obj should be defined by port, it's not // part of the core. { MP_ROM_QSTR(MP_QSTR_open), MP_ROM_PTR(&mp_builtin_open_obj) }, diff --git a/py/ringbuf.c b/py/ringbuf.c index 2003cc97d5..72e164946a 100644 --- a/py/ringbuf.c +++ b/py/ringbuf.c @@ -114,7 +114,7 @@ size_t ringbuf_num_filled(ringbuf_t *r) { // If the ring buffer fills up, not all bytes will be written. // Returns how many bytes were successfully written. -size_t ringbuf_put_n(ringbuf_t *r, uint8_t *buf, size_t bufsize) { +size_t ringbuf_put_n(ringbuf_t *r, const uint8_t *buf, size_t bufsize) { for (size_t i = 0; i < bufsize; i++) { if (ringbuf_put(r, buf[i]) < 0) { // If ringbuf is full, give up and return how many bytes diff --git a/py/ringbuf.h b/py/ringbuf.h index 6ed72dcf1a..8f7e7b1760 100644 --- a/py/ringbuf.h +++ b/py/ringbuf.h @@ -52,7 +52,7 @@ int ringbuf_put(ringbuf_t *r, uint8_t v); void ringbuf_clear(ringbuf_t *r); size_t ringbuf_num_empty(ringbuf_t *r); size_t ringbuf_num_filled(ringbuf_t *r); -size_t ringbuf_put_n(ringbuf_t *r, uint8_t *buf, size_t bufsize); +size_t ringbuf_put_n(ringbuf_t *r, const uint8_t *buf, size_t bufsize); size_t ringbuf_get_n(ringbuf_t *r, uint8_t *buf, size_t bufsize); // Note: big-endian. No-op if not enough room available for both bytes. diff --git a/shared-bindings/_bleio/__init__.h b/shared-bindings/_bleio/__init__.h index 7f251ef188..55b527cfa5 100644 --- a/shared-bindings/_bleio/__init__.h +++ b/shared-bindings/_bleio/__init__.h @@ -54,6 +54,8 @@ extern const mp_obj_type_t mp_type_bleio_BluetoothError; extern const mp_obj_type_t mp_type_bleio_RoleError; extern const mp_obj_type_t mp_type_bleio_SecurityError; +void bleio_reset(void); + extern mp_obj_t bleio_set_adapter(mp_obj_t adapter_obj); NORETURN void mp_raise_bleio_BluetoothError(const compressed_string_t *msg, ...); diff --git a/shared-bindings/audiobusio/I2SOut.c b/shared-bindings/audiobusio/I2SOut.c index c9910427f3..6254f7cde2 100644 --- a/shared-bindings/audiobusio/I2SOut.c +++ b/shared-bindings/audiobusio/I2SOut.c @@ -72,7 +72,6 @@ //| Playing a wave file from flash:: //| //| import board -//| import audioio //| import audiocore //| import audiobusio //| import digitalio diff --git a/shared-bindings/board/__init__.c b/shared-bindings/board/__init__.c index bb273c61a9..8b2738a248 100644 --- a/shared-bindings/board/__init__.c +++ b/shared-bindings/board/__init__.c @@ -28,12 +28,15 @@ #include "py/runtime.h" #include "shared-bindings/board/__init__.h" -#if BOARD_I2C +#if CIRCUITPY_BOARD_I2C #include "shared-bindings/busio/I2C.h" #endif -#if BOARD_SPI +#if CIRCUITPY_BOARD_SPI #include "shared-bindings/busio/SPI.h" #endif +#if CIRCUITPY_BOARD_UART +#include "shared-bindings/busio/UART.h" +#endif //| """Board specific pin names //| @@ -47,84 +50,57 @@ //| """Board ID string. The unique identifier for the board model in //| circuitpython, as well as on circuitpython.org. //| Example: "hallowing_m0_express".""" -//| //| def I2C() -> busio.I2C: -//| """Returns the `busio.I2C` object for the board designated SDA and SCL pins. It is a singleton.""" +//| """Returns the `busio.I2C` object for the board's designated I2C bus(es). +//| The object created is a singleton, and uses the default parameter values for `busio.I2C`.""" //| ... //| - -#if BOARD_I2C -mp_obj_t board_i2c(void) { - mp_obj_t singleton = common_hal_board_get_i2c(); - if (singleton != NULL && !common_hal_busio_i2c_deinited(singleton)) { - return singleton; - } - assert_pin_free(DEFAULT_I2C_BUS_SDA); - assert_pin_free(DEFAULT_I2C_BUS_SCL); - return common_hal_board_create_i2c(); +#if CIRCUITPY_BOARD_I2C +STATIC mp_obj_t board_i2c_0(void) { + return common_hal_board_create_i2c(0); } #else -mp_obj_t board_i2c(void) { +STATIC mp_obj_t board_i2c_0(void) { mp_raise_NotImplementedError_varg(translate("No default %q bus"), MP_QSTR_I2C); return MP_ROM_NONE; } #endif -MP_DEFINE_CONST_FUN_OBJ_0(board_i2c_obj, board_i2c); - +MP_DEFINE_CONST_FUN_OBJ_0(board_i2c_obj, board_i2c_0); //| def SPI() -> busio.SPI: -//| """Returns the `busio.SPI` object for the board designated SCK, MOSI and MISO pins. It is a -//| singleton.""" +//| """Returns the `busio.SPI` object for the board's designated SPI bus(es). +//| The object created is a singleton, and uses the default parameter values for `busio.SPI`.""" //| ... //| -#if BOARD_SPI -mp_obj_t board_spi(void) { - mp_obj_t singleton = common_hal_board_get_spi(); - if (singleton != NULL && !common_hal_busio_spi_deinited(singleton)) { - return singleton; - } - assert_pin_free(DEFAULT_SPI_BUS_SCK); - assert_pin_free(DEFAULT_SPI_BUS_MOSI); - assert_pin_free(DEFAULT_SPI_BUS_MISO); - return common_hal_board_create_spi(); +#if CIRCUITPY_BOARD_SPI +STATIC mp_obj_t board_spi_0(void) { + return common_hal_board_create_spi(0); } #else -mp_obj_t board_spi(void) { +STATIC mp_obj_t board_spi_0(void) { mp_raise_NotImplementedError_varg(translate("No default %q bus"), MP_QSTR_SPI); return MP_ROM_NONE; } #endif -MP_DEFINE_CONST_FUN_OBJ_0(board_spi_obj, board_spi); +MP_DEFINE_CONST_FUN_OBJ_0(board_spi_obj, board_spi_0); //| def UART() -> busio.UART: -//| """Returns the `busio.UART` object for the board designated TX and RX pins. It is a singleton. -//| -//| The object created uses the default parameter values for `busio.UART`. If you need to set -//| parameters that are not changeable after creation, such as ``receiver_buffer_size``, -//| do not use `board.UART()`; instead create a `busio.UART` object explicitly with the -//| desired parameters.""" +//| """Returns the `busio.UART` object for the board's designated UART bus(es). +//| The object created is a singleton, and uses the default parameter values for `busio.UART`.""" //| ... //| -#if BOARD_UART -mp_obj_t board_uart(void) { - mp_obj_t singleton = common_hal_board_get_uart(); - if (singleton != NULL) { - return singleton; - } - - assert_pin_free(DEFAULT_UART_BUS_RX); - assert_pin_free(DEFAULT_UART_BUS_TX); - - return common_hal_board_create_uart(); +#if CIRCUITPY_BOARD_UART +STATIC mp_obj_t board_uart_0(void) { + return common_hal_board_create_uart(0); } #else -mp_obj_t board_uart(void) { +STATIC mp_obj_t board_uart_0(void) { mp_raise_NotImplementedError_varg(translate("No default %q bus"), MP_QSTR_UART); return MP_ROM_NONE; } #endif -MP_DEFINE_CONST_FUN_OBJ_0(board_uart_obj, board_uart); +MP_DEFINE_CONST_FUN_OBJ_0(board_uart_obj, board_uart_0); const mp_obj_module_t board_module = { .base = { &mp_type_module }, diff --git a/shared-bindings/board/__init__.h b/shared-bindings/board/__init__.h index bc4d7df61f..b668e0a04b 100644 --- a/shared-bindings/board/__init__.h +++ b/shared-bindings/board/__init__.h @@ -35,21 +35,29 @@ extern const mp_obj_dict_t board_module_globals; STATIC const MP_DEFINE_STR_OBJ(board_module_id_obj, CIRCUITPY_BOARD_ID); -mp_obj_t common_hal_board_get_i2c(void); -mp_obj_t common_hal_board_create_i2c(void); +bool common_hal_board_is_i2c(mp_obj_t obj); +mp_obj_t common_hal_board_get_i2c(const mp_int_t instance); +mp_obj_t common_hal_board_create_i2c(const mp_int_t instance); +mp_obj_t board_i2c(size_t n_args, const mp_obj_t *args); MP_DECLARE_CONST_FUN_OBJ_0(board_i2c_obj); -mp_obj_t common_hal_board_get_spi(void); -mp_obj_t common_hal_board_create_spi(void); +bool common_hal_board_is_spi(mp_obj_t obj); +mp_obj_t common_hal_board_get_spi(const mp_int_t instance); +mp_obj_t common_hal_board_create_spi(const mp_int_t instance); +mp_obj_t board_spi(size_t n_args, const mp_obj_t *args); MP_DECLARE_CONST_FUN_OBJ_0(board_spi_obj); -mp_obj_t common_hal_board_get_uart(void); -mp_obj_t common_hal_board_create_uart(void); +bool common_hal_board_is_uart(mp_obj_t obj); +mp_obj_t common_hal_board_get_uart(const mp_int_t instance); +mp_obj_t common_hal_board_create_uart(const mp_int_t instance); +mp_obj_t board_uart(size_t n_args, const mp_obj_t *args); MP_DECLARE_CONST_FUN_OBJ_0(board_uart_obj); -mp_obj_t board_i2c(void); -mp_obj_t board_spi(void); -mp_obj_t board_uart(void); +#define CIRCUITPY_BOARD_BUS_SINGLETON(name, bus, instance) \ + STATIC mp_obj_t board_##name(void) { \ + return common_hal_board_create_##bus(instance); \ + } \ + MP_DEFINE_CONST_FUN_OBJ_0(board_##name##_obj, board_##name); #define CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS \ { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_board) }, \ diff --git a/shared-bindings/busio/I2C.c b/shared-bindings/busio/I2C.c index 19b205e4ca..2d67281df0 100644 --- a/shared-bindings/busio/I2C.c +++ b/shared-bindings/busio/I2C.c @@ -58,10 +58,7 @@ //| :param int frequency: The clock frequency in Hertz //| :param int timeout: The maximum clock stretching timeut - (used only for //| :class:`bitbangio.I2C`; ignored for :class:`busio.I2C`) -//| -//| .. note:: On the nRF52840, only one I2C object may be created, -//| except on the Circuit Playground Bluefruit, which allows two, -//| one for the onboard accelerometer, and one for offboard use.""" +//| """ //| ... //| STATIC mp_obj_t busio_i2c_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { @@ -191,23 +188,6 @@ MP_DEFINE_CONST_FUN_OBJ_1(busio_i2c_unlock_obj, busio_i2c_obj_unlock); //| :param int end: end of buffer slice; if not specified, use ``len(buffer)``""" //| ... //| -// Shared arg parsing for readfrom_into and writeto_then_readfrom. -STATIC void readfrom(busio_i2c_obj_t *self, mp_int_t address, mp_obj_t buffer, int32_t start, mp_int_t end) { - mp_buffer_info_t bufinfo; - mp_get_buffer_raise(buffer, &bufinfo, MP_BUFFER_WRITE); - - size_t length = bufinfo.len; - normalize_buffer_bounds(&start, end, &length); - if (length == 0) { - mp_raise_ValueError(translate("Buffer must be at least length 1")); - } - - uint8_t status = common_hal_busio_i2c_read(self, address, ((uint8_t *)bufinfo.buf) + start, length); - if (status != 0) { - mp_raise_OSError(status); - } -} - STATIC mp_obj_t busio_i2c_readfrom_into(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_address, ARG_buffer, ARG_start, ARG_end }; static const mp_arg_t allowed_args[] = { @@ -219,11 +199,27 @@ STATIC mp_obj_t busio_i2c_readfrom_into(size_t n_args, const mp_obj_t *pos_args, busio_i2c_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); check_for_deinit(self); check_lock(self); + mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - readfrom(self, args[ARG_address].u_int, args[ARG_buffer].u_obj, args[ARG_start].u_int, - args[ARG_end].u_int); + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(args[ARG_buffer].u_obj, &bufinfo, MP_BUFFER_WRITE); + + size_t length = bufinfo.len; + int32_t start = args[ARG_start].u_int; + const int32_t end = args[ARG_end].u_int; + normalize_buffer_bounds(&start, end, &length); + if (length == 0) { + mp_raise_ValueError_varg(translate("%q length must be >= 1"), MP_QSTR_buffer); + } + + uint8_t status = + common_hal_busio_i2c_read(self, args[ARG_address].u_int, ((uint8_t *)bufinfo.buf) + start, length); + if (status != 0) { + mp_raise_OSError(status); + } + return mp_const_none; } MP_DEFINE_CONST_FUN_OBJ_KW(busio_i2c_readfrom_into_obj, 1, busio_i2c_readfrom_into); @@ -247,23 +243,6 @@ MP_DEFINE_CONST_FUN_OBJ_KW(busio_i2c_readfrom_into_obj, 1, busio_i2c_readfrom_in //| """ //| ... //| -// Shared arg parsing for writeto and writeto_then_readfrom. -STATIC void writeto(busio_i2c_obj_t *self, mp_int_t address, mp_obj_t buffer, int32_t start, mp_int_t end, bool stop) { - // get the buffer to write the data from - mp_buffer_info_t bufinfo; - mp_get_buffer_raise(buffer, &bufinfo, MP_BUFFER_READ); - - size_t length = bufinfo.len; - normalize_buffer_bounds(&start, end, &length); - - // do the transfer - uint8_t status = common_hal_busio_i2c_write(self, address, ((uint8_t *)bufinfo.buf) + start, - length, stop); - if (status != 0) { - mp_raise_OSError(status); - } -} - STATIC mp_obj_t busio_i2c_writeto(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_address, ARG_buffer, ARG_start, ARG_end }; static const mp_arg_t allowed_args[] = { @@ -278,8 +257,23 @@ STATIC mp_obj_t busio_i2c_writeto(size_t n_args, const mp_obj_t *pos_args, mp_ma mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - writeto(self, args[ARG_address].u_int, args[ARG_buffer].u_obj, args[ARG_start].u_int, - args[ARG_end].u_int, true); + // get the buffer to write the data from + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(args[ARG_buffer].u_obj, &bufinfo, MP_BUFFER_READ); + + size_t length = bufinfo.len; + int32_t start = args[ARG_start].u_int; + const int32_t end = args[ARG_end].u_int; + normalize_buffer_bounds(&start, end, &length); + + // do the transfer + uint8_t status = + common_hal_busio_i2c_write(self, args[ARG_address].u_int, ((uint8_t *)bufinfo.buf) + start, length); + + if (status != 0) { + mp_raise_OSError(status); + } + return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(busio_i2c_writeto_obj, 1, busio_i2c_writeto); @@ -314,10 +308,10 @@ STATIC mp_obj_t busio_i2c_writeto_then_readfrom(size_t n_args, const mp_obj_t *p { MP_QSTR_address, MP_ARG_REQUIRED | MP_ARG_INT, {.u_int = 0} }, { MP_QSTR_out_buffer, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, { MP_QSTR_in_buffer, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, - { MP_QSTR_out_start, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} }, - { MP_QSTR_out_end, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = INT_MAX} }, - { MP_QSTR_in_start, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} }, - { MP_QSTR_in_end, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = INT_MAX} }, + { MP_QSTR_out_start, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} }, + { MP_QSTR_out_end, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = INT_MAX} }, + { MP_QSTR_in_start, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} }, + { MP_QSTR_in_end, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = INT_MAX} }, }; busio_i2c_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); check_for_deinit(self); @@ -325,10 +319,30 @@ STATIC mp_obj_t busio_i2c_writeto_then_readfrom(size_t n_args, const mp_obj_t *p mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - writeto(self, args[ARG_address].u_int, args[ARG_out_buffer].u_obj, args[ARG_out_start].u_int, - args[ARG_out_end].u_int, false); - readfrom(self, args[ARG_address].u_int, args[ARG_in_buffer].u_obj, args[ARG_in_start].u_int, - args[ARG_in_end].u_int); + mp_buffer_info_t out_bufinfo; + mp_get_buffer_raise(args[ARG_out_buffer].u_obj, &out_bufinfo, MP_BUFFER_READ); + + size_t out_length = out_bufinfo.len; + int32_t out_start = args[ARG_out_start].u_int; + const int32_t out_end = args[ARG_out_end].u_int; + normalize_buffer_bounds(&out_start, out_end, &out_length); + + mp_buffer_info_t in_bufinfo; + mp_get_buffer_raise(args[ARG_in_buffer].u_obj, &in_bufinfo, MP_BUFFER_WRITE); + + size_t in_length = in_bufinfo.len; + int32_t in_start = args[ARG_in_start].u_int; + const int32_t in_end = args[ARG_in_end].u_int; + normalize_buffer_bounds(&in_start, in_end, &in_length); + if (in_length == 0) { + mp_raise_ValueError_varg(translate("%q length must be >= 1"), MP_QSTR_out_buffer); + } + + uint8_t status = common_hal_busio_i2c_write_read(self, args[ARG_address].u_int, + ((uint8_t *)out_bufinfo.buf) + out_start, out_length,((uint8_t *)in_bufinfo.buf) + in_start, in_length); + if (status != 0) { + mp_raise_OSError(status); + } return mp_const_none; } diff --git a/shared-bindings/busio/I2C.h b/shared-bindings/busio/I2C.h index 08701938c9..0999865fbf 100644 --- a/shared-bindings/busio/I2C.h +++ b/shared-bindings/busio/I2C.h @@ -61,14 +61,17 @@ extern bool common_hal_busio_i2c_probe(busio_i2c_obj_t *self, uint8_t addr); // Write to the device and return 0 on success or an appropriate error code from mperrno.h extern uint8_t common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t address, - const uint8_t *data, size_t len, - bool stop); + const uint8_t *data, size_t len); // Reads memory of the i2c device picking up where it left off and return 0 on // success or an appropriate error code from mperrno.h extern uint8_t common_hal_busio_i2c_read(busio_i2c_obj_t *self, uint16_t address, uint8_t *data, size_t len); +// Do a write and then a read in the same I2C transaction. +uint8_t common_hal_busio_i2c_write_read(busio_i2c_obj_t *self, uint16_t address, + uint8_t *out_data, size_t out_len, uint8_t *in_data, size_t in_len); + // This is used by the supervisor to claim I2C devices indefinitely. extern void common_hal_busio_i2c_never_reset(busio_i2c_obj_t *self); diff --git a/shared-bindings/displayio/Display.c b/shared-bindings/displayio/Display.c index 1b750eb934..f7b3305439 100644 --- a/shared-bindings/displayio/Display.c +++ b/shared-bindings/displayio/Display.c @@ -444,6 +444,23 @@ const mp_obj_property_t displayio_display_bus_obj = { MP_ROM_NONE}, }; +//| root_group: Group +//| """The root group on the display.""" +//| +//| +STATIC mp_obj_t displayio_display_obj_get_root_group(mp_obj_t self_in) { + displayio_display_obj_t *self = native_display(self_in); + return common_hal_displayio_display_get_root_group(self); +} +MP_DEFINE_CONST_FUN_OBJ_1(displayio_display_get_root_group_obj, displayio_display_obj_get_root_group); + +const mp_obj_property_t displayio_display_root_group_obj = { + .base.type = &mp_type_property, + .proxy = {(mp_obj_t)&displayio_display_get_root_group_obj, + MP_ROM_NONE, + MP_ROM_NONE}, +}; + //| def fill_row(self, y: int, buffer: WriteableBuffer) -> WriteableBuffer: //| """Extract the pixels from a single row @@ -517,6 +534,7 @@ STATIC const mp_rom_map_elem_t displayio_display_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_height), MP_ROM_PTR(&displayio_display_height_obj) }, { MP_ROM_QSTR(MP_QSTR_rotation), MP_ROM_PTR(&displayio_display_rotation_obj) }, { MP_ROM_QSTR(MP_QSTR_bus), MP_ROM_PTR(&displayio_display_bus_obj) }, + { MP_ROM_QSTR(MP_QSTR_root_group), MP_ROM_PTR(&displayio_display_root_group_obj) }, }; STATIC MP_DEFINE_CONST_DICT(displayio_display_locals_dict, displayio_display_locals_dict_table); diff --git a/shared-bindings/displayio/Display.h b/shared-bindings/displayio/Display.h index 9e0eb64e5f..f193e61d2f 100644 --- a/shared-bindings/displayio/Display.h +++ b/shared-bindings/displayio/Display.h @@ -69,6 +69,6 @@ mp_float_t common_hal_displayio_display_get_brightness(displayio_display_obj_t * bool common_hal_displayio_display_set_brightness(displayio_display_obj_t *self, mp_float_t brightness); mp_obj_t common_hal_displayio_display_get_bus(displayio_display_obj_t *self); - +mp_obj_t common_hal_displayio_display_get_root_group(displayio_display_obj_t *self); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYIO_DISPLAY_H diff --git a/shared-bindings/displayio/EPaperDisplay.c b/shared-bindings/displayio/EPaperDisplay.c index 64f7031f4d..aa14594d97 100644 --- a/shared-bindings/displayio/EPaperDisplay.c +++ b/shared-bindings/displayio/EPaperDisplay.c @@ -63,7 +63,7 @@ //| refresh_display_command: int, refresh_time: float = 40, //| busy_pin: Optional[microcontroller.Pin] = None, busy_state: bool = True, //| seconds_per_frame: float = 180, always_toggle_chip_select: bool = False, -//| grayscale: bool = False) -> None: +//| grayscale: bool = False, two_byte_sequence_length: bool = False) -> None: //| """Create a EPaperDisplay object on the given display bus (`displayio.FourWire` or `paralleldisplay.ParallelBus`). //| //| The ``start_sequence`` and ``stop_sequence`` are bitpacked to minimize the ram impact. Every @@ -100,7 +100,8 @@ //| :param bool busy_state: State of the busy pin when the display is busy //| :param float seconds_per_frame: Minimum number of seconds between screen refreshes //| :param bool always_toggle_chip_select: When True, chip select is toggled every byte -//| :param bool grayscale: When true, the color ram is the low bit of 2-bit grayscale""" +//| :param bool grayscale: When true, the color ram is the low bit of 2-bit grayscale +//| :param bool two_byte_sequence_length: When true, use two bytes to define sequence length""" //| ... //| STATIC mp_obj_t displayio_epaperdisplay_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { @@ -110,7 +111,7 @@ STATIC mp_obj_t displayio_epaperdisplay_make_new(const mp_obj_type_t *type, size ARG_set_current_row_command, ARG_write_black_ram_command, ARG_black_bits_inverted, ARG_write_color_ram_command, ARG_color_bits_inverted, ARG_highlight_color, ARG_refresh_display_command, ARG_refresh_time, ARG_busy_pin, ARG_busy_state, - ARG_seconds_per_frame, ARG_always_toggle_chip_select, ARG_grayscale }; + ARG_seconds_per_frame, ARG_always_toggle_chip_select, ARG_grayscale, ARG_two_byte_sequence_length }; static const mp_arg_t allowed_args[] = { { MP_QSTR_display_bus, MP_ARG_REQUIRED | MP_ARG_OBJ }, { MP_QSTR_start_sequence, MP_ARG_REQUIRED | MP_ARG_OBJ }, @@ -138,6 +139,7 @@ STATIC mp_obj_t displayio_epaperdisplay_make_new(const mp_obj_type_t *type, size { MP_QSTR_seconds_per_frame, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = MP_OBJ_NEW_SMALL_INT(180)} }, { MP_QSTR_always_toggle_chip_select, MP_ARG_BOOL | MP_ARG_KW_ONLY, {.u_bool = false} }, { MP_QSTR_grayscale, MP_ARG_BOOL | MP_ARG_KW_ONLY, {.u_bool = false} }, + { MP_QSTR_two_byte_sequence_length, MP_ARG_BOOL | MP_ARG_KW_ONLY, {.u_bool = false} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); @@ -182,7 +184,7 @@ STATIC mp_obj_t displayio_epaperdisplay_make_new(const mp_obj_type_t *type, size args[ARG_write_black_ram_command].u_int, args[ARG_black_bits_inverted].u_bool, write_color_ram_command, args[ARG_color_bits_inverted].u_bool, highlight_color, args[ARG_refresh_display_command].u_int, refresh_time, busy_pin, args[ARG_busy_state].u_bool, seconds_per_frame, - args[ARG_always_toggle_chip_select].u_bool, args[ARG_grayscale].u_bool + args[ARG_always_toggle_chip_select].u_bool, args[ARG_grayscale].u_bool, args[ARG_two_byte_sequence_length].u_bool ); return self; diff --git a/shared-bindings/displayio/EPaperDisplay.h b/shared-bindings/displayio/EPaperDisplay.h index c23fb27455..ba6dffcb4b 100644 --- a/shared-bindings/displayio/EPaperDisplay.h +++ b/shared-bindings/displayio/EPaperDisplay.h @@ -42,7 +42,7 @@ void common_hal_displayio_epaperdisplay_construct(displayio_epaperdisplay_obj_t uint16_t set_column_window_command, uint16_t set_row_window_command, uint16_t set_current_column_command, uint16_t set_current_row_command, uint16_t write_black_ram_command, bool black_bits_inverted, uint16_t write_color_ram_command, bool color_bits_inverted, uint32_t highlight_color, uint16_t refresh_display_command, mp_float_t refresh_time, - const mcu_pin_obj_t *busy_pin, bool busy_state, mp_float_t seconds_per_frame, bool always_toggle_chip_select, bool grayscale); + const mcu_pin_obj_t *busy_pin, bool busy_state, mp_float_t seconds_per_frame, bool always_toggle_chip_select, bool grayscale, bool two_byte_sequence_length); bool common_hal_displayio_epaperdisplay_refresh(displayio_epaperdisplay_obj_t *self); diff --git a/shared-bindings/is31fl3741/FrameBuffer.c b/shared-bindings/is31fl3741/FrameBuffer.c new file mode 100644 index 0000000000..597024500d --- /dev/null +++ b/shared-bindings/is31fl3741/FrameBuffer.c @@ -0,0 +1,312 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Mark Komus + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "py/obj.h" +#include "py/objproperty.h" +#include "py/runtime.h" +#include "py/objarray.h" + +#include "shared-bindings/is31fl3741/IS31FL3741.h" +#include "shared-bindings/is31fl3741/FrameBuffer.h" +#include "shared-bindings/util.h" +#include "shared-module/displayio/__init__.h" +#include "shared-module/framebufferio/__init__.h" +#include "shared-module/framebufferio/FramebufferDisplay.h" +#include "shared-bindings/busio/I2C.h" + +//| class IS31FL3741_FrameBuffer: +//| """Creates an in-memory framebuffer for a IS31FL3741 device.""" +//| +//| def __init__(self, is31: is31fl3741.IS31FL3741, width: int, height: int, mapping: Tuple[int, ...], *, +//| framebuffer: Optional[WriteableBuffer] = None, scale: bool = False, gamma: bool = False) -> None: +//| """Create a IS31FL3741_FrameBuffer object with the given attributes. +//| +//| The framebuffer is in "RGB888" format using 4 bytes per pixel. +//| Bits 24-31 are ignored. The format is in RGB order. +//| +//| If a framebuffer is not passed in, one is allocated and initialized +//| to all black. In any case, the framebuffer can be retrieved +//| by passing the Is31fl3741 object to memoryview(). +//| +//| A Is31fl3741 is often used in conjunction with a +//| `framebufferio.FramebufferDisplay`. +//| +//| :param is31fl3741.IS31FL3741 is31: base IS31FL3741 instance to drive the framebuffer +//| :param int width: width of the display +//| :param int height: height of the display +//| :param Tuple[int, ...] mapping: mapping of matrix locations to LEDs +//| :param Optional[WriteableBuffer] framebuffer: Optional buffer to hold the display +//| :param bool scale: if True display is scaled down by 3 when displayed +//| :param bool gamma: if True apply gamma correction to all LEDs""" +//| ... +//| +STATIC mp_obj_t is31fl3741_FrameBuffer_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { + enum { ARG_is31, ARG_width, ARG_height, ARG_mapping, ARG_framebuffer, ARG_scale, ARG_gamma }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_is31, MP_ARG_OBJ | MP_ARG_REQUIRED }, + { MP_QSTR_width, MP_ARG_INT | MP_ARG_REQUIRED }, + { MP_QSTR_height, MP_ARG_INT | MP_ARG_REQUIRED }, + { MP_QSTR_mapping, MP_ARG_OBJ | MP_ARG_REQUIRED }, + { MP_QSTR_framebuffer, MP_ARG_OBJ | MP_ARG_KW_ONLY, { .u_obj = mp_const_none } }, + { MP_QSTR_scale, MP_ARG_BOOL | MP_ARG_KW_ONLY, { .u_bool = false } }, + { MP_QSTR_gamma, MP_ARG_BOOL | MP_ARG_KW_ONLY, { .u_bool = false } }, + }; + mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; + mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + + is31fl3741_FrameBuffer_obj_t *self = &allocate_display_bus_or_raise()->is31fl3741; + self->base.type = &is31fl3741_FrameBuffer_type; + + if (args[ARG_width].u_int <= 0) { + mp_raise_ValueError(translate("width must be greater than zero")); + } + + self->scale = args[ARG_scale].u_bool; + if (self->scale) { + if (((args[ARG_height].u_int % 3) != 0) || ((args[ARG_width].u_int % 3) != 0)) { + mp_raise_ValueError(translate("Scale dimensions must divide by 3")); + } + + self->scale_width = args[ARG_width].u_int / 3; + self->scale_height = args[ARG_height].u_int / 3; + } else { + self->scale_width = args[ARG_width].u_int; + self->scale_height = args[ARG_height].u_int; + } + + self->auto_gamma = args[ARG_gamma].u_bool; + + mp_obj_t framebuffer = args[ARG_framebuffer].u_obj; + if (framebuffer == mp_const_none) { + int width = args[ARG_width].u_int; + int height = args[ARG_height].u_int; + int bufsize = 4 * width * height; + framebuffer = mp_obj_new_bytearray_of_zeros(bufsize); + } + + common_hal_is31fl3741_FrameBuffer_construct(self, + args[ARG_width].u_int, + args[ARG_height].u_int, + framebuffer, + args[ARG_is31].u_obj, + args[ARG_mapping].u_obj + ); + + return MP_OBJ_FROM_PTR(self); +} + +//| def deinit(self) -> None: +//| """Free the resources associated with this +//| IS31FL3741 instance. After deinitialization, no further operations +//| may be performed.""" +//| ... +//| +STATIC mp_obj_t is31fl3741_FrameBuffer_deinit(mp_obj_t self_in) { + is31fl3741_FrameBuffer_obj_t *self = (is31fl3741_FrameBuffer_obj_t *)self_in; + common_hal_is31fl3741_FrameBuffer_deinit(self); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(is31fl3741_FrameBuffer_deinit_obj, is31fl3741_FrameBuffer_deinit); + +static void check_for_deinit(is31fl3741_FrameBuffer_obj_t *self) { + if (self->framebuffer == NULL) { + raise_deinited_error(); + } +} + +//| brightness: float +//| """In the current implementation, 0.0 turns the display off entirely +//| and any other value up to 1.0 turns the display on fully.""" +//| +STATIC mp_obj_t is31fl3741_FrameBuffer_get_brightness(mp_obj_t self_in) { + is31fl3741_FrameBuffer_obj_t *self = (is31fl3741_FrameBuffer_obj_t *)self_in; + check_for_deinit(self); + uint8_t current = common_hal_is31fl3741_get_current(self->is31fl3741); + + float brightness = (float)current / (float)0xFF; + return mp_obj_new_float(brightness); +} +MP_DEFINE_CONST_FUN_OBJ_1(is31fl3741_FrameBuffer_get_brightness_obj, is31fl3741_FrameBuffer_get_brightness); + +STATIC mp_obj_t is31fl3741_FrameBuffer_set_brightness(mp_obj_t self_in, mp_obj_t value_in) { + is31fl3741_FrameBuffer_obj_t *self = (is31fl3741_FrameBuffer_obj_t *)self_in; + check_for_deinit(self); + mp_float_t brightness = mp_obj_get_float(value_in); + if (brightness < 0.0f || brightness > 1.0f) { + mp_raise_ValueError(translate("Brightness must be 0-1.0")); + } + + uint8_t current = (uint8_t)(brightness * 0xFF); + common_hal_is31fl3741_set_current(self->is31fl3741, current); + + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_2(is31fl3741_FrameBuffer_set_brightness_obj, is31fl3741_FrameBuffer_set_brightness); + +const mp_obj_property_t is31fl3741_FrameBuffer_brightness_obj = { + .base.type = &mp_type_property, + .proxy = {(mp_obj_t)&is31fl3741_FrameBuffer_get_brightness_obj, + (mp_obj_t)&is31fl3741_FrameBuffer_set_brightness_obj, + MP_ROM_NONE}, +}; + +//| def refresh(self) -> None: +//| """Transmits the color data in the buffer to the pixels so that +//| they are shown.""" +//| ... +//| +STATIC mp_obj_t is31fl3741_FrameBuffer_refresh(mp_obj_t self_in) { + is31fl3741_FrameBuffer_obj_t *self = (is31fl3741_FrameBuffer_obj_t *)self_in; + check_for_deinit(self); + common_hal_is31fl3741_FrameBuffer_refresh(self, 0); + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_1(is31fl3741_FrameBuffer_refresh_obj, is31fl3741_FrameBuffer_refresh); + +//| width: int +//| """The width of the display, in pixels""" +//| +STATIC mp_obj_t is31fl3741_FrameBuffer_get_width(mp_obj_t self_in) { + is31fl3741_FrameBuffer_obj_t *self = (is31fl3741_FrameBuffer_obj_t *)self_in; + check_for_deinit(self); + return MP_OBJ_NEW_SMALL_INT(common_hal_is31fl3741_FrameBuffer_get_width(self)); +} +MP_DEFINE_CONST_FUN_OBJ_1(is31fl3741_FrameBuffer_get_width_obj, is31fl3741_FrameBuffer_get_width); +const mp_obj_property_t is31fl3741_FrameBuffer_width_obj = { + .base.type = &mp_type_property, + .proxy = {(mp_obj_t)&is31fl3741_FrameBuffer_get_width_obj, + MP_ROM_NONE, + MP_ROM_NONE}, +}; + +//| height: int +//| """The height of the display, in pixels""" +//| +STATIC mp_obj_t is31fl3741_FrameBuffer_get_height(mp_obj_t self_in) { + is31fl3741_FrameBuffer_obj_t *self = (is31fl3741_FrameBuffer_obj_t *)self_in; + check_for_deinit(self); + return MP_OBJ_NEW_SMALL_INT(common_hal_is31fl3741_FrameBuffer_get_height(self)); +} +MP_DEFINE_CONST_FUN_OBJ_1(is31fl3741_FrameBuffer_get_height_obj, is31fl3741_FrameBuffer_get_height); +const mp_obj_property_t is31fl3741_FrameBuffer_height_obj = { + .base.type = &mp_type_property, + .proxy = {(mp_obj_t)&is31fl3741_FrameBuffer_get_height_obj, + MP_ROM_NONE, + MP_ROM_NONE}, +}; + +STATIC const mp_rom_map_elem_t is31fl3741_FrameBuffer_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&is31fl3741_FrameBuffer_deinit_obj) }, + { MP_ROM_QSTR(MP_QSTR_brightness), MP_ROM_PTR(&is31fl3741_FrameBuffer_brightness_obj) }, + { MP_ROM_QSTR(MP_QSTR_refresh), MP_ROM_PTR(&is31fl3741_FrameBuffer_refresh_obj) }, + { MP_ROM_QSTR(MP_QSTR_width), MP_ROM_PTR(&is31fl3741_FrameBuffer_width_obj) }, + { MP_ROM_QSTR(MP_QSTR_height), MP_ROM_PTR(&is31fl3741_FrameBuffer_height_obj) }, +}; +STATIC MP_DEFINE_CONST_DICT(is31fl3741_FrameBuffer_locals_dict, is31fl3741_FrameBuffer_locals_dict_table); + +STATIC void is31fl3741_FrameBuffer_get_bufinfo(mp_obj_t self_in, mp_buffer_info_t *bufinfo) { + is31fl3741_FrameBuffer_obj_t *self = (is31fl3741_FrameBuffer_obj_t *)self_in; + check_for_deinit(self); + + *bufinfo = self->bufinfo; +} + +STATIC void is31fl3741_FrameBuffer_swapbuffers(mp_obj_t self_in, uint8_t *dirty_row_bitmap) { + common_hal_is31fl3741_FrameBuffer_refresh(self_in, dirty_row_bitmap); +} + +STATIC void is31fl3741_FrameBuffer_deinit_proto(mp_obj_t self_in) { + common_hal_is31fl3741_FrameBuffer_deinit(self_in); +} + +STATIC float is31fl3741_FrameBuffer_get_brightness_proto(mp_obj_t self_in) { + return common_hal_is31fl3741_FrameBuffer_get_paused(self_in) ? 0.0f : 1.0f; +} + +STATIC bool is31fl3741_FrameBuffer_set_brightness_proto(mp_obj_t self_in, mp_float_t value) { + common_hal_is31fl3741_FrameBuffer_set_paused(self_in, value <= 0); + return true; +} + +STATIC int is31fl3741_FrameBuffer_get_width_proto(mp_obj_t self_in) { + return common_hal_is31fl3741_FrameBuffer_get_width(self_in); +} + +STATIC int is31fl3741_FrameBuffer_get_height_proto(mp_obj_t self_in) { + return common_hal_is31fl3741_FrameBuffer_get_height(self_in); +} + +STATIC int is31fl3741_FrameBuffer_get_color_depth_proto(mp_obj_t self_in) { + // The way displayio works depth is used to calculate bytes + // We use an uint32_t for color already so setting to 24 causes + // more changes required + return 32; +} + +STATIC int is31fl3741_FrameBuffer_get_bytes_per_cell_proto(mp_obj_t self_in) { + return 1; +} + +STATIC int is31fl3741_FrameBuffer_get_native_frames_per_second_proto(mp_obj_t self_in) { + return 60; // This was just chosen may vary based on LEDs used? +} + +STATIC const framebuffer_p_t is31fl3741_FrameBuffer_proto = { + MP_PROTO_IMPLEMENT(MP_QSTR_protocol_framebuffer) + .get_bufinfo = is31fl3741_FrameBuffer_get_bufinfo, + .set_brightness = is31fl3741_FrameBuffer_set_brightness_proto, + .get_brightness = is31fl3741_FrameBuffer_get_brightness_proto, + .get_width = is31fl3741_FrameBuffer_get_width_proto, + .get_height = is31fl3741_FrameBuffer_get_height_proto, + .get_color_depth = is31fl3741_FrameBuffer_get_color_depth_proto, + .get_bytes_per_cell = is31fl3741_FrameBuffer_get_bytes_per_cell_proto, + .get_native_frames_per_second = is31fl3741_FrameBuffer_get_native_frames_per_second_proto, + .swapbuffers = is31fl3741_FrameBuffer_swapbuffers, + .deinit = is31fl3741_FrameBuffer_deinit_proto, +}; + +STATIC mp_int_t is31fl3741_FrameBuffer_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags) { + is31fl3741_FrameBuffer_obj_t *self = (is31fl3741_FrameBuffer_obj_t *)self_in; + // a readonly framebuffer would be unusual but not impossible + if ((flags & MP_BUFFER_WRITE) && !(self->bufinfo.typecode & MP_OBJ_ARRAY_TYPECODE_FLAG_RW)) { + return 1; + } + *bufinfo = self->bufinfo; + bufinfo->typecode = 'H'; + return 0; +} + +const mp_obj_type_t is31fl3741_FrameBuffer_type = { + { &mp_type_type }, + .flags = MP_TYPE_FLAG_EXTENDED, + .name = MP_QSTR_is31fl3741, + .locals_dict = (mp_obj_dict_t *)&is31fl3741_FrameBuffer_locals_dict, + .make_new = is31fl3741_FrameBuffer_make_new, + MP_TYPE_EXTENDED_FIELDS( + .buffer_p = { .get_buffer = is31fl3741_FrameBuffer_get_buffer, }, + .protocol = &is31fl3741_FrameBuffer_proto, + ), +}; diff --git a/shared-bindings/is31fl3741/FrameBuffer.h b/shared-bindings/is31fl3741/FrameBuffer.h new file mode 100644 index 0000000000..704913b83c --- /dev/null +++ b/shared-bindings/is31fl3741/FrameBuffer.h @@ -0,0 +1,50 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Mark Komus + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#pragma once + +#include "shared-module/is31fl3741/FrameBuffer.h" +#include "shared-module/is31fl3741/IS31FL3741.h" + +extern const mp_obj_type_t is31fl3741_FrameBuffer_type; + +void common_hal_is31fl3741_FrameBuffer_construct(is31fl3741_FrameBuffer_obj_t *self, int width, int height, mp_obj_t framebuffer, is31fl3741_IS31FL3741_obj_t *is31, mp_obj_t mapping); + +void common_hal_is31fl3741_FrameBuffer_deinit(is31fl3741_FrameBuffer_obj_t *); + +int common_hal_is31fl3741_FrameBuffer_get_width(is31fl3741_FrameBuffer_obj_t *self); +int common_hal_is31fl3741_FrameBuffer_get_height(is31fl3741_FrameBuffer_obj_t *self); + +void common_hal_is31fl3741_FrameBuffer_set_global_current(is31fl3741_FrameBuffer_obj_t *self, uint8_t current); +uint8_t common_hal_is31fl3741_FrameBuffer_get_global_current(is31fl3741_FrameBuffer_obj_t *self); + +void common_hal_is31fl3741_FrameBuffer_set_paused(is31fl3741_FrameBuffer_obj_t *self, bool paused); +bool common_hal_is31fl3741_FrameBuffer_get_paused(is31fl3741_FrameBuffer_obj_t *self); +void common_hal_is31fl3741_FrameBuffer_refresh(is31fl3741_FrameBuffer_obj_t *self, uint8_t *dirtyrows); + +void common_hal_is31fl3741_FrameBuffer_reconstruct(is31fl3741_FrameBuffer_obj_t *self, mp_obj_t framebuffer); + +void is31fl3741_FrameBuffer_collect_ptrs(is31fl3741_FrameBuffer_obj_t *self); diff --git a/shared-bindings/is31fl3741/IS31FL3741.c b/shared-bindings/is31fl3741/IS31FL3741.c index 758dd114a0..46a7f8ac86 100644 --- a/shared-bindings/is31fl3741/IS31FL3741.c +++ b/shared-bindings/is31fl3741/IS31FL3741.c @@ -32,82 +32,38 @@ #include "shared-bindings/is31fl3741/IS31FL3741.h" #include "shared-bindings/util.h" #include "shared-module/displayio/__init__.h" -#include "shared-module/framebufferio/__init__.h" -#include "shared-module/framebufferio/FramebufferDisplay.h" #include "shared-bindings/busio/I2C.h" //| class IS31FL3741: -//| """Displays an in-memory framebuffer to a IS31FL3741 drive display.""" +//| """Driver for an IS31FL3741 device.""" //| - -//| def __init__(self, *, width: int) -> None: +//| def __init__(self, i2c: busio.I2C, *, addr: int = 0x30) -> None: //| """Create a IS31FL3741 object with the given attributes. //| -//| The framebuffer is in "RGB888" format using 4 bytes per pixel. -//| Bits 24-31 are ignored. The format is in RGB order. +//| Designed to work low level or passed to and object such as +//| :class:`~is31fl3741.IS31FL3741_FrameBuffer`. //| -//| If a framebuffer is not passed in, one is allocated and initialized -//| to all black. In any case, the framebuffer can be retrieved -//| by passing the Is31fl3741 object to memoryview(). +//| :param ~busio.I2C i2c: I2C bus the IS31FL3741 is on +//| :param int addr: device address""" +//| ... //| -//| A Is31fl3741 is often used in conjunction with a -//| `framebufferio.FramebufferDisplay`.""" -//| - STATIC mp_obj_t is31fl3741_IS31FL3741_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { - enum { ARG_width, ARG_height, ARG_i2c, ARG_addr, ARG_framebuffer, ARG_mapping, ARG_scale, ARG_gamma }; + enum { ARG_i2c, ARG_addr }; static const mp_arg_t allowed_args[] = { - { MP_QSTR_width, MP_ARG_INT | MP_ARG_REQUIRED | MP_ARG_KW_ONLY }, - { MP_QSTR_height, MP_ARG_INT | MP_ARG_REQUIRED | MP_ARG_KW_ONLY }, - { MP_QSTR_i2c, MP_ARG_OBJ | MP_ARG_REQUIRED | MP_ARG_KW_ONLY }, + { MP_QSTR_i2c, MP_ARG_OBJ | MP_ARG_REQUIRED }, { MP_QSTR_addr, MP_ARG_INT | MP_ARG_KW_ONLY, { .u_int = 0x30 } }, - { MP_QSTR_framebuffer, MP_ARG_OBJ | MP_ARG_KW_ONLY, { .u_obj = mp_const_none } }, - { MP_QSTR_mapping, MP_ARG_OBJ | MP_ARG_KW_ONLY | MP_ARG_REQUIRED }, - { MP_QSTR_scale, MP_ARG_BOOL | MP_ARG_KW_ONLY, { .u_bool = false } }, - { MP_QSTR_gamma, MP_ARG_BOOL | MP_ARG_KW_ONLY, { .u_bool = false } }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); mp_obj_t i2c = mp_arg_validate_type(args[ARG_i2c].u_obj, &busio_i2c_type, MP_QSTR_i2c_bus); - is31fl3741_IS31FL3741_obj_t *self = &allocate_display_bus_or_raise()->is31fl3741; + is31fl3741_IS31FL3741_obj_t *self = m_new_obj(is31fl3741_IS31FL3741_obj_t); self->base.type = &is31fl3741_IS31FL3741_type; - if (args[ARG_width].u_int <= 0) { - mp_raise_ValueError(translate("width must be greater than zero")); - } - - self->scale = args[ARG_scale].u_bool; - if (self->scale) { - if (((args[ARG_height].u_int % 3) != 0) || ((args[ARG_width].u_int % 3) != 0)) { - mp_raise_ValueError(translate("Scale dimensions must divide by 3")); - } - - self->scale_width = args[ARG_width].u_int / 3; - self->scale_height = args[ARG_height].u_int / 3; - } else { - self->scale_width = args[ARG_width].u_int; - self->scale_height = args[ARG_height].u_int; - } - - self->auto_gamma = args[ARG_gamma].u_bool; - - mp_obj_t framebuffer = args[ARG_framebuffer].u_obj; - if (framebuffer == mp_const_none) { - int width = args[ARG_width].u_int; - int height = args[ARG_height].u_int; - int bufsize = 4 * width * height; - framebuffer = mp_obj_new_bytearray_of_zeros(bufsize); - } - common_hal_is31fl3741_IS31FL3741_construct(self, - args[ARG_width].u_int, - args[ARG_height].u_int, - framebuffer, MP_OBJ_TO_PTR(i2c), - args[ARG_addr].u_int, - args[ARG_mapping].u_obj + args[ARG_addr].u_int ); return MP_OBJ_FROM_PTR(self); @@ -124,185 +80,101 @@ STATIC mp_obj_t is31fl3741_IS31FL3741_deinit(mp_obj_t self_in) { common_hal_is31fl3741_IS31FL3741_deinit(self); return mp_const_none; } - STATIC MP_DEFINE_CONST_FUN_OBJ_1(is31fl3741_IS31FL3741_deinit_obj, is31fl3741_IS31FL3741_deinit); -static void check_for_deinit(is31fl3741_IS31FL3741_obj_t *self) { - if (self->framebuffer == NULL) { - raise_deinited_error(); - } -} - -//| brightness: float -//| """In the current implementation, 0.0 turns the display off entirely -//| and any other value up to 1.0 turns the display on fully.""" +//| def reset(self) -> None: +//| """Resets the IS31FL3741 chip.""" +//| ... //| -STATIC mp_obj_t is31fl3741_IS31FL3741_get_brightness(mp_obj_t self_in) { - is31fl3741_IS31FL3741_obj_t *self = (is31fl3741_IS31FL3741_obj_t *)self_in; - check_for_deinit(self); - uint8_t current = common_hal_is31fl3741_IS31FL3741_get_global_current(self); - - float brightness = (float)current / (float)0xFF; - return mp_obj_new_float(brightness); -} -MP_DEFINE_CONST_FUN_OBJ_1(is31fl3741_IS31FL3741_get_brightness_obj, is31fl3741_IS31FL3741_get_brightness); - -STATIC mp_obj_t is31fl3741_IS31FL3741_set_brightness(mp_obj_t self_in, mp_obj_t value_in) { - is31fl3741_IS31FL3741_obj_t *self = (is31fl3741_IS31FL3741_obj_t *)self_in; - check_for_deinit(self); - mp_float_t brightness = mp_obj_get_float(value_in); - if (brightness < 0.0f || brightness > 1.0f) { - mp_raise_ValueError(translate("Brightness must be 0-1.0")); - } - - uint8_t current = (uint8_t)(brightness * 0xFF); - common_hal_is31fl3741_IS31FL3741_set_global_current(self, current); - +STATIC mp_obj_t is31fl3741_IS31FL3741_reset(mp_obj_t self_in) { + is31fl3741_IS31FL3741_obj_t *self = MP_OBJ_TO_PTR(self_in); + common_hal_is31fl3741_send_reset(self); return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_2(is31fl3741_IS31FL3741_set_brightness_obj, is31fl3741_IS31FL3741_set_brightness); +MP_DEFINE_CONST_FUN_OBJ_1(is31fl3741_IS31FL3741_reset_obj, is31fl3741_IS31FL3741_reset); -const mp_obj_property_t is31fl3741_IS31FL3741_brightness_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&is31fl3741_IS31FL3741_get_brightness_obj, - (mp_obj_t)&is31fl3741_IS31FL3741_set_brightness_obj, - MP_ROM_NONE}, -}; - -//| def refresh(self) -> None: -//| """Transmits the color data in the buffer to the pixels so that -//| they are shown.""" -//| ... +//| def enable(self) -> None: +//| """Enables the IS31FL3741 chip.""" +//| ... //| -STATIC mp_obj_t is31fl3741_IS31FL3741_refresh(mp_obj_t self_in) { - is31fl3741_IS31FL3741_obj_t *self = (is31fl3741_IS31FL3741_obj_t *)self_in; - check_for_deinit(self); - common_hal_is31fl3741_IS31FL3741_refresh(self, 0); +STATIC mp_obj_t is31fl3741_IS31FL3741_enable(mp_obj_t self_in) { + is31fl3741_IS31FL3741_obj_t *self = MP_OBJ_TO_PTR(self_in); + common_hal_is31fl3741_send_enable(self); return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_1(is31fl3741_IS31FL3741_refresh_obj, is31fl3741_IS31FL3741_refresh); +MP_DEFINE_CONST_FUN_OBJ_1(is31fl3741_IS31FL3741_enable_obj, is31fl3741_IS31FL3741_enable); -//| width: int -//| """The width of the display, in pixels""" +//| def set_global_current(self, current: int) -> None: +//| """Sets the global current of the IS31FL3741 chip. //| -STATIC mp_obj_t is31fl3741_IS31FL3741_get_width(mp_obj_t self_in) { - is31fl3741_IS31FL3741_obj_t *self = (is31fl3741_IS31FL3741_obj_t *)self_in; - check_for_deinit(self); - return MP_OBJ_NEW_SMALL_INT(common_hal_is31fl3741_IS31FL3741_get_width(self)); +//| :param int current: global current value 0x00 to 0xFF""" +//| ... +//| +STATIC mp_obj_t is31fl3741_IS31FL3741_set_global_current(mp_obj_t self_in, mp_obj_t value) { + is31fl3741_IS31FL3741_obj_t *self = MP_OBJ_TO_PTR(self_in); + mp_int_t current = mp_obj_get_int(value); + common_hal_is31fl3741_set_current(self, current); + return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_1(is31fl3741_IS31FL3741_get_width_obj, is31fl3741_IS31FL3741_get_width); -const mp_obj_property_t is31fl3741_IS31FL3741_width_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&is31fl3741_IS31FL3741_get_width_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_DEFINE_CONST_FUN_OBJ_2(is31fl3741_IS31FL3741_set_global_current_obj, is31fl3741_IS31FL3741_set_global_current); -//| height: int -//| """The height of the display, in pixels""" +//| def set_led(self, led: int, value: int, page: int) -> None: +//| """Resets the IS31FL3741 chip. //| -STATIC mp_obj_t is31fl3741_IS31FL3741_get_height(mp_obj_t self_in) { - is31fl3741_IS31FL3741_obj_t *self = (is31fl3741_IS31FL3741_obj_t *)self_in; - check_for_deinit(self); - return MP_OBJ_NEW_SMALL_INT(common_hal_is31fl3741_IS31FL3741_get_height(self)); +//| :param int led: which LED to set +//| :param int value: value to set the LED to 0x00 to 0xFF +//| :param int page: page to write to 0 or 2. If the LED is a >= 180 +//| the routine will automatically write to page 1 or 3 (instead +//| of 0 or 2)""" +//| ... +//| +STATIC mp_obj_t is31fl3741_IS31FL3741_set_led(size_t n_args, const mp_obj_t *args) { + is31fl3741_IS31FL3741_obj_t *self = MP_OBJ_TO_PTR(args[0]); + mp_int_t led = mp_obj_get_int(args[1]); + mp_int_t value = mp_obj_get_int(args[2]); + mp_int_t page = mp_obj_get_int(args[3]); + common_hal_is31fl3741_set_led(self, led, value, page); + return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_1(is31fl3741_IS31FL3741_get_height_obj, is31fl3741_IS31FL3741_get_height); -const mp_obj_property_t is31fl3741_IS31FL3741_height_obj = { - .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&is31fl3741_IS31FL3741_get_height_obj, - MP_ROM_NONE, - MP_ROM_NONE}, -}; +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(is31fl3741_IS31FL3741_set_led_obj, 4, 4, is31fl3741_IS31FL3741_set_led); + +//| def write(mapping: Tuple[int, ...], buf: ReadableBuffer) -> None: +//| """Write buf out on the I2C bus to the IS31FL3741. +//| +//| :param ~Tuple[int, ...] mapping: map the pixels in the buffer to the order addressed by the driver chip +//| :param ~_typing.ReadableBuffer buf: The bytes to clock out. No assumption is made about color order""" +//| ... +STATIC mp_obj_t is31fl3741_IS31FL3741_write(mp_obj_t self_in, mp_obj_t mapping, mp_obj_t buffer) { + is31fl3741_IS31FL3741_obj_t *self = MP_OBJ_TO_PTR(self_in); + if (!mp_obj_is_tuple_compatible(mapping)) { + mp_raise_ValueError(translate("Mapping must be a tuple")); + } + + mp_obj_t *map_items; + size_t map_len; + mp_obj_tuple_get(mapping, &map_len, &map_items); + + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(buffer, &bufinfo, MP_BUFFER_READ); + + common_hal_is31fl3741_write(self, map_items, (uint8_t *)bufinfo.buf, bufinfo.len); + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_3(is31fl3741_IS31FL3741_write_obj, is31fl3741_IS31FL3741_write); STATIC const mp_rom_map_elem_t is31fl3741_IS31FL3741_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&is31fl3741_IS31FL3741_deinit_obj) }, - { MP_ROM_QSTR(MP_QSTR_brightness), MP_ROM_PTR(&is31fl3741_IS31FL3741_brightness_obj) }, - { MP_ROM_QSTR(MP_QSTR_refresh), MP_ROM_PTR(&is31fl3741_IS31FL3741_refresh_obj) }, - { MP_ROM_QSTR(MP_QSTR_width), MP_ROM_PTR(&is31fl3741_IS31FL3741_width_obj) }, - { MP_ROM_QSTR(MP_QSTR_height), MP_ROM_PTR(&is31fl3741_IS31FL3741_height_obj) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_write), (mp_obj_t)&is31fl3741_IS31FL3741_write_obj }, + { MP_OBJ_NEW_QSTR(MP_QSTR_reset), (mp_obj_t)&is31fl3741_IS31FL3741_reset_obj }, + { MP_OBJ_NEW_QSTR(MP_QSTR_enable), (mp_obj_t)&is31fl3741_IS31FL3741_enable_obj }, + { MP_OBJ_NEW_QSTR(MP_QSTR_set_global_current), (mp_obj_t)&is31fl3741_IS31FL3741_set_global_current_obj }, + { MP_OBJ_NEW_QSTR(MP_QSTR_set_led), (mp_obj_t)&is31fl3741_IS31FL3741_set_led_obj }, }; STATIC MP_DEFINE_CONST_DICT(is31fl3741_IS31FL3741_locals_dict, is31fl3741_IS31FL3741_locals_dict_table); -STATIC void is31fl3741_IS31FL3741_get_bufinfo(mp_obj_t self_in, mp_buffer_info_t *bufinfo) { - is31fl3741_IS31FL3741_obj_t *self = (is31fl3741_IS31FL3741_obj_t *)self_in; - check_for_deinit(self); - - *bufinfo = self->bufinfo; -} - -STATIC void is31fl3741_IS31FL3741_swapbuffers(mp_obj_t self_in, uint8_t *dirty_row_bitmap) { - common_hal_is31fl3741_IS31FL3741_refresh(self_in, dirty_row_bitmap); -} - -STATIC void is31fl3741_IS31FL3741_deinit_proto(mp_obj_t self_in) { - common_hal_is31fl3741_IS31FL3741_deinit(self_in); -} - -STATIC float is31fl3741_IS31FL3741_get_brightness_proto(mp_obj_t self_in) { - return common_hal_is31fl3741_IS31FL3741_get_paused(self_in) ? 0.0f : 1.0f; -} - -STATIC bool is31fl3741_IS31FL3741_set_brightness_proto(mp_obj_t self_in, mp_float_t value) { - common_hal_is31fl3741_IS31FL3741_set_paused(self_in, value <= 0); - return true; -} - -STATIC int is31fl3741_IS31FL3741_get_width_proto(mp_obj_t self_in) { - return common_hal_is31fl3741_IS31FL3741_get_width(self_in); -} - -STATIC int is31fl3741_IS31FL3741_get_height_proto(mp_obj_t self_in) { - return common_hal_is31fl3741_IS31FL3741_get_height(self_in); -} - -STATIC int is31fl3741_IS31FL3741_get_color_depth_proto(mp_obj_t self_in) { - // The way displayio works depth is used to calculate bytes - // We use an uint32_t for color already so setting to 24 causes - // more changes required - return 32; -} - -STATIC int is31fl3741_IS31FL3741_get_bytes_per_cell_proto(mp_obj_t self_in) { - return 1; -} - -STATIC int is31fl3741_IS31FL3741_get_native_frames_per_second_proto(mp_obj_t self_in) { - return 60; // This was just chosen may vary based on LEDs used? -} - -STATIC const framebuffer_p_t is31fl3741_IS31FL3741_proto = { - MP_PROTO_IMPLEMENT(MP_QSTR_protocol_framebuffer) - .get_bufinfo = is31fl3741_IS31FL3741_get_bufinfo, - .set_brightness = is31fl3741_IS31FL3741_set_brightness_proto, - .get_brightness = is31fl3741_IS31FL3741_get_brightness_proto, - .get_width = is31fl3741_IS31FL3741_get_width_proto, - .get_height = is31fl3741_IS31FL3741_get_height_proto, - .get_color_depth = is31fl3741_IS31FL3741_get_color_depth_proto, - .get_bytes_per_cell = is31fl3741_IS31FL3741_get_bytes_per_cell_proto, - .get_native_frames_per_second = is31fl3741_IS31FL3741_get_native_frames_per_second_proto, - .swapbuffers = is31fl3741_IS31FL3741_swapbuffers, - .deinit = is31fl3741_IS31FL3741_deinit_proto, -}; - -STATIC mp_int_t is31fl3741_IS31FL3741_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags) { - is31fl3741_IS31FL3741_obj_t *self = (is31fl3741_IS31FL3741_obj_t *)self_in; - // a readonly framebuffer would be unusual but not impossible - if ((flags & MP_BUFFER_WRITE) && !(self->bufinfo.typecode & MP_OBJ_ARRAY_TYPECODE_FLAG_RW)) { - return 1; - } - *bufinfo = self->bufinfo; - bufinfo->typecode = 'H'; - return 0; -} - const mp_obj_type_t is31fl3741_IS31FL3741_type = { { &mp_type_type }, - .flags = MP_TYPE_FLAG_EXTENDED, .name = MP_QSTR_is31fl3741, .locals_dict = (mp_obj_dict_t *)&is31fl3741_IS31FL3741_locals_dict, .make_new = is31fl3741_IS31FL3741_make_new, - MP_TYPE_EXTENDED_FIELDS( - .buffer_p = { .get_buffer = is31fl3741_IS31FL3741_get_buffer, }, - .protocol = &is31fl3741_IS31FL3741_proto, - ), }; diff --git a/shared-bindings/is31fl3741/IS31FL3741.h b/shared-bindings/is31fl3741/IS31FL3741.h index 3815f10de0..2b81b01617 100644 --- a/shared-bindings/is31fl3741/IS31FL3741.h +++ b/shared-bindings/is31fl3741/IS31FL3741.h @@ -30,32 +30,20 @@ extern const mp_obj_type_t is31fl3741_IS31FL3741_type; -void common_hal_is31fl3741_IS31FL3741_construct(is31fl3741_IS31FL3741_obj_t *self, int width, int height, mp_obj_t framebuffer, busio_i2c_obj_t *i2c, uint8_t addr, mp_obj_t mapping); +void common_hal_is31fl3741_IS31FL3741_construct(is31fl3741_IS31FL3741_obj_t *self, busio_i2c_obj_t *i2c, uint8_t addr); void common_hal_is31fl3741_IS31FL3741_deinit(is31fl3741_IS31FL3741_obj_t *); -int common_hal_is31fl3741_IS31FL3741_get_width(is31fl3741_IS31FL3741_obj_t *self); -int common_hal_is31fl3741_IS31FL3741_get_height(is31fl3741_IS31FL3741_obj_t *self); +void common_hal_is31fl3741_write(is31fl3741_IS31FL3741_obj_t *is31, const mp_obj_t *mapping, const uint8_t *pixels, size_t numBytes); -void common_hal_displayio_is31fl3741_begin_transaction(is31fl3741_IS31FL3741_obj_t *self); -void common_hal_displayio_is31fl3741_end_transaction(is31fl3741_IS31FL3741_obj_t *self); +void common_hal_is31fl3741_begin_transaction(is31fl3741_IS31FL3741_obj_t *self); +void common_hal_is31fl3741_end_transaction(is31fl3741_IS31FL3741_obj_t *self); -void common_hal_is31fl3741_IS31FL3741_set_global_current(is31fl3741_IS31FL3741_obj_t *self, uint8_t current); -uint8_t common_hal_is31fl3741_IS31FL3741_get_global_current(is31fl3741_IS31FL3741_obj_t *self); - -void common_hal_is31fl3741_IS31FL3741_set_paused(is31fl3741_IS31FL3741_obj_t *self, bool paused); -bool common_hal_is31fl3741_IS31FL3741_get_paused(is31fl3741_IS31FL3741_obj_t *self); -void common_hal_is31fl3741_IS31FL3741_refresh(is31fl3741_IS31FL3741_obj_t *self, uint8_t *dirtyrows); - -void common_hal_is31fl3741_IS31FL3741_reconstruct(is31fl3741_IS31FL3741_obj_t *self, mp_obj_t framebuffer); - -void is31fl3741_IS31FL3741_collect_ptrs(is31fl3741_IS31FL3741_obj_t *self); - -void is31fl3741_send_unlock(busio_i2c_obj_t *i2c, uint8_t addr); -void is31fl3741_set_page(busio_i2c_obj_t *i2c, uint8_t addr, uint8_t p); -void is31fl3741_send_enable(busio_i2c_obj_t *i2c, uint8_t addr); -void is31fl3741_send_reset(busio_i2c_obj_t *i2c, uint8_t addr); -void is31fl3741_set_current(busio_i2c_obj_t *i2c, uint8_t addr, uint8_t current); -uint8_t is31fl3741_get_current(busio_i2c_obj_t *i2c, uint8_t addr); -void is31fl3741_set_led(busio_i2c_obj_t *i2c, uint8_t addr, uint16_t led, uint8_t level, uint8_t page); -void is31fl3741_draw_pixel(busio_i2c_obj_t *i2c, uint8_t addr, int16_t x, int16_t y, uint32_t color, uint16_t *mapping); +void common_hal_is31fl3741_send_unlock(is31fl3741_IS31FL3741_obj_t *self); +void common_hal_is31fl3741_set_page(is31fl3741_IS31FL3741_obj_t *self, uint8_t p); +void common_hal_is31fl3741_send_enable(is31fl3741_IS31FL3741_obj_t *self); +void common_hal_is31fl3741_send_reset(is31fl3741_IS31FL3741_obj_t *self); +void common_hal_is31fl3741_set_current(is31fl3741_IS31FL3741_obj_t *self, uint8_t current); +uint8_t common_hal_is31fl3741_get_current(is31fl3741_IS31FL3741_obj_t *self); +void common_hal_is31fl3741_set_led(is31fl3741_IS31FL3741_obj_t *self, uint16_t led, uint8_t level, uint8_t page); +void common_hal_is31fl3741_draw_pixel(is31fl3741_IS31FL3741_obj_t *self, int16_t x, int16_t y, uint32_t color, uint16_t *mapping); diff --git a/shared-bindings/is31fl3741/__init__.c b/shared-bindings/is31fl3741/__init__.c index 90b9426a4d..605889700c 100644 --- a/shared-bindings/is31fl3741/__init__.c +++ b/shared-bindings/is31fl3741/__init__.c @@ -25,15 +25,19 @@ */ #include +#include #include "py/obj.h" #include "py/runtime.h" +#include "shared-bindings/busio/I2C.h" #include "shared-bindings/is31fl3741/IS31FL3741.h" +#include "shared-bindings/is31fl3741/FrameBuffer.h" STATIC const mp_rom_map_elem_t is31fl3741_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_is31fl3741) }, { MP_ROM_QSTR(MP_QSTR_IS31FL3741), MP_ROM_PTR(&is31fl3741_IS31FL3741_type) }, + { MP_ROM_QSTR(MP_QSTR_IS31FL3741_FrameBuffer), MP_ROM_PTR(&is31fl3741_FrameBuffer_type) }, }; STATIC MP_DEFINE_CONST_DICT(is31fl3741_module_globals, is31fl3741_module_globals_table); diff --git a/shared-bindings/neopixel_write/__init__.c b/shared-bindings/neopixel_write/__init__.c index 6895813db5..a95020ad46 100644 --- a/shared-bindings/neopixel_write/__init__.c +++ b/shared-bindings/neopixel_write/__init__.c @@ -29,8 +29,15 @@ #include "py/mphal.h" #include "py/runtime.h" #include "shared-bindings/digitalio/DigitalInOut.h" +#include "shared-bindings/util.h" #include "supervisor/shared/translate.h" +STATIC void check_for_deinit(digitalio_digitalinout_obj_t *self) { + if (common_hal_digitalio_digitalinout_deinited(self)) { + raise_deinited_error(); + } +} + //| """Low-level neopixel implementation //| //| The `neopixel_write` module contains a helper method to write out bytes in @@ -60,8 +67,13 @@ STATIC mp_obj_t neopixel_write_neopixel_write_(mp_obj_t digitalinout_obj, mp_obj if (!mp_obj_is_type(digitalinout_obj, &digitalio_digitalinout_type)) { mp_raise_TypeError_varg(translate("Expected a %q"), digitalio_digitalinout_type.name); } + // Convert parameters into expected types. const digitalio_digitalinout_obj_t *digitalinout = MP_OBJ_TO_PTR(digitalinout_obj); + + // Check to see if the NeoPixel has been deinited before writing to it. + check_for_deinit(digitalinout_obj); + mp_buffer_info_t bufinfo; mp_get_buffer_raise(buf, &bufinfo, MP_BUFFER_READ); // Call platform's neopixel write function with provided buffer and options. diff --git a/shared-bindings/pulseio/PulseOut.c b/shared-bindings/pulseio/PulseOut.c index bf2aaf54ff..ac568231b9 100644 --- a/shared-bindings/pulseio/PulseOut.c +++ b/shared-bindings/pulseio/PulseOut.c @@ -59,7 +59,7 @@ //| import board //| //| # 50% duty cycle at 38kHz. -//| pwm = pulseio.PulseOut(board.LED, frequency=38000, duty_cycle=32768) +//| pulse = pulseio.PulseOut(board.LED, frequency=38000, duty_cycle=32768) //| # on off on off on //| pulses = array.array('H', [65000, 1000, 65000, 65000, 1000]) //| pulse.send(pulses) diff --git a/shared-bindings/supervisor/__init__.c b/shared-bindings/supervisor/__init__.c index 35ae63c03d..e7c4479d2a 100644 --- a/shared-bindings/supervisor/__init__.c +++ b/shared-bindings/supervisor/__init__.c @@ -33,6 +33,7 @@ #include "shared/runtime/interrupt_char.h" #include "supervisor/shared/autoreload.h" #include "supervisor/shared/bluetooth/bluetooth.h" +#include "supervisor/shared/display.h" #include "supervisor/shared/status_leds.h" #include "supervisor/shared/stack.h" #include "supervisor/shared/traceback.h" @@ -299,6 +300,21 @@ STATIC mp_obj_t supervisor_disable_ble_workflow(void) { } MP_DEFINE_CONST_FUN_OBJ_0(supervisor_disable_ble_workflow_obj, supervisor_disable_ble_workflow); +//| def reset_terminal(x_pixels: int, y_pixels: int) -> None: +//| """Reset the CircuitPython serial terminal with new dimensions.""" +//| ... +//| +STATIC mp_obj_t supervisor_reset_terminal(mp_obj_t x_pixels, mp_obj_t y_pixels) { + #if CIRCUITPY_DISPLAYIO + supervisor_stop_terminal(); + supervisor_start_terminal(mp_obj_get_int(x_pixels), mp_obj_get_int(y_pixels)); + #else + mp_raise_NotImplementedError(NULL); + #endif + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_2(supervisor_reset_terminal_obj, supervisor_reset_terminal); + STATIC const mp_rom_map_elem_t supervisor_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_supervisor) }, { MP_ROM_QSTR(MP_QSTR_enable_autoreload), MP_ROM_PTR(&supervisor_enable_autoreload_obj) }, @@ -312,6 +328,7 @@ STATIC const mp_rom_map_elem_t supervisor_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_ticks_ms), MP_ROM_PTR(&supervisor_ticks_ms_obj) }, { MP_ROM_QSTR(MP_QSTR_get_previous_traceback), MP_ROM_PTR(&supervisor_get_previous_traceback_obj) }, { MP_ROM_QSTR(MP_QSTR_disable_ble_workflow), MP_ROM_PTR(&supervisor_disable_ble_workflow_obj) }, + { MP_ROM_QSTR(MP_QSTR_reset_terminal), MP_ROM_PTR(&supervisor_reset_terminal_obj) }, }; STATIC MP_DEFINE_CONST_DICT(supervisor_module_globals, supervisor_module_globals_table); diff --git a/shared-bindings/wifi/Radio.c b/shared-bindings/wifi/Radio.c index 93d92630ca..7701b1ff33 100644 --- a/shared-bindings/wifi/Radio.c +++ b/shared-bindings/wifi/Radio.c @@ -304,7 +304,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(wifi_radio_stop_ap_obj, wifi_radio_stop_ap); //| *, //| channel: Optional[int] = 0, //| bssid: Optional[ReadableBuffer] = b"", -//| timeout: Optional[float] = None) -> bool: +//| timeout: Optional[float] = None) -> None: //| """Connects to the given ssid and waits for an ip address. Reconnections are handled //| automatically once one connection succeeds. //| @@ -507,7 +507,7 @@ const mp_obj_property_t wifi_radio_ap_info_obj = { MP_ROM_NONE }, }; -//| def ping(self, ip: ipaddress.IPv4Address, *, timeout: Optional[float] = 0.5) -> float: +//| def ping(self, ip: ipaddress.IPv4Address, *, timeout: Optional[float] = 0.5) -> Optional[float]: //| """Ping an IP to test connectivity. Returns echo time in seconds. //| Returns None when it times out.""" //| ... diff --git a/shared-module/_bleio/ScanResults.c b/shared-module/_bleio/ScanResults.c index e5b5525579..1f4dbff310 100644 --- a/shared-module/_bleio/ScanResults.c +++ b/shared-module/_bleio/ScanResults.c @@ -91,9 +91,9 @@ void shared_module_bleio_scanresults_append(bleio_scanresults_obj_t *self, bool connectable, bool scan_response, int8_t rssi, - uint8_t *peer_addr, + const uint8_t *peer_addr, uint8_t addr_type, - uint8_t *data, + const uint8_t *data, uint16_t len) { int32_t packet_size = sizeof(uint8_t) + sizeof(ticks_ms) + sizeof(rssi) + NUM_BLEIO_ADDRESS_BYTES + sizeof(addr_type) + sizeof(len) + len; diff --git a/shared-module/_bleio/ScanResults.h b/shared-module/_bleio/ScanResults.h index fa181aabee..945809c8d9 100644 --- a/shared-module/_bleio/ScanResults.h +++ b/shared-module/_bleio/ScanResults.h @@ -56,9 +56,9 @@ void shared_module_bleio_scanresults_append(bleio_scanresults_obj_t *self, bool connectable, bool scan_result, int8_t rssi, - uint8_t *peer_addr, + const uint8_t *peer_addr, uint8_t addr_type, - uint8_t *data, + const uint8_t *data, uint16_t len); #endif // MICROPY_INCLUDED_SHARED_MODULE_BLEIO_SCANRESULTS_H diff --git a/shared-module/adafruit_bus_device/i2c_device/I2CDevice.c b/shared-module/adafruit_bus_device/i2c_device/I2CDevice.c index 0b430d1ea2..a630f1e2b8 100644 --- a/shared-module/adafruit_bus_device/i2c_device/I2CDevice.c +++ b/shared-module/adafruit_bus_device/i2c_device/I2CDevice.c @@ -79,7 +79,7 @@ void common_hal_adafruit_bus_device_i2cdevice_probe_for_device(adafruit_bus_devi common_hal_adafruit_bus_device_i2cdevice_unlock(self); if (mp_obj_is_subclass_fast(MP_OBJ_FROM_PTR(((mp_obj_base_t *)nlr.ret_val)->type), MP_OBJ_FROM_PTR(&mp_type_OSError))) { - mp_raise_ValueError_varg(translate("No I2C device at address: %x"), self->device_address); + mp_raise_ValueError_varg(translate("No I2C device at address: 0x%x"), self->device_address); } else { /* In case we receive an unrelated exception pass it up */ nlr_raise(MP_OBJ_FROM_PTR(nlr.ret_val)); diff --git a/shared-module/bitbangio/I2C.c b/shared-module/bitbangio/I2C.c index 7d7380e214..eb897e122f 100644 --- a/shared-module/bitbangio/I2C.c +++ b/shared-module/bitbangio/I2C.c @@ -49,9 +49,11 @@ STATIC void scl_release(bitbangio_i2c_obj_t *self) { uint32_t count = self->us_timeout; delay(self); // For clock stretching, wait for the SCL pin to be released, with timeout. + common_hal_digitalio_digitalinout_switch_to_input(&self->scl, PULL_UP); for (; !common_hal_digitalio_digitalinout_get_value(&self->scl) && count; --count) { common_hal_mcu_delay_us(1); } + common_hal_digitalio_digitalinout_switch_to_output(&self->scl, true, DRIVE_MODE_OPEN_DRAIN); // raise exception on timeout if (count == 0) { mp_raise_msg(&mp_type_TimeoutError, translate("Clock stretch too long")); diff --git a/shared-module/board/__init__.c b/shared-module/board/__init__.c index 19d9e7ece0..65441025f4 100644 --- a/shared-module/board/__init__.c +++ b/shared-module/board/__init__.c @@ -46,141 +46,200 @@ #include "shared-module/sharpdisplay/SharpMemoryFramebuffer.h" #endif -#if BOARD_I2C +#if CIRCUITPY_BOARD_I2C // Statically allocate the I2C object so it can live past the end of the heap and into the next VM. // That way it can be used by built-in I2CDisplay displays and be accessible through board.I2C(). -STATIC busio_i2c_obj_t i2c_obj; -STATIC mp_obj_t i2c_singleton = NULL; -mp_obj_t common_hal_board_get_i2c(void) { - return i2c_singleton; +typedef struct { + const mcu_pin_obj_t *scl; + const mcu_pin_obj_t *sda; +} board_i2c_pin_t; + +static const board_i2c_pin_t i2c_pin[CIRCUITPY_BOARD_I2C] = CIRCUITPY_BOARD_I2C_PIN; +static busio_i2c_obj_t i2c_obj[CIRCUITPY_BOARD_I2C]; +static bool i2c_obj_created[CIRCUITPY_BOARD_I2C]; + +bool common_hal_board_is_i2c(mp_obj_t obj) { + for (uint8_t instance = 0; instance < CIRCUITPY_BOARD_I2C; instance++) { + if (obj == &i2c_obj[instance]) { + return true; + } + } + return false; } -mp_obj_t common_hal_board_create_i2c(void) { - // All callers have either already verified this or come so early that it can't be otherwise. - assert(i2c_singleton == NULL || common_hal_busio_i2c_deinited(i2c_singleton)); - busio_i2c_obj_t *self = &i2c_obj; +mp_obj_t common_hal_board_get_i2c(const mp_int_t instance) { + return i2c_obj_created[instance] ? &i2c_obj[instance] : NULL; +} + +mp_obj_t common_hal_board_create_i2c(const mp_int_t instance) { + const mp_obj_t singleton = common_hal_board_get_i2c(instance); + if (singleton != NULL && !common_hal_busio_i2c_deinited(singleton)) { + return singleton; + } + + busio_i2c_obj_t *self = &i2c_obj[instance]; self->base.type = &busio_i2c_type; - common_hal_busio_i2c_construct(self, DEFAULT_I2C_BUS_SCL, DEFAULT_I2C_BUS_SDA, 100000, 255); - i2c_singleton = (mp_obj_t)self; - return i2c_singleton; + assert_pin_free(i2c_pin[instance].scl); + assert_pin_free(i2c_pin[instance].sda); + + common_hal_busio_i2c_construct(self, i2c_pin[instance].scl, i2c_pin[instance].sda, 100000, 255); + + i2c_obj_created[instance] = true; + return &i2c_obj[instance]; } #endif - -#if BOARD_SPI +#if CIRCUITPY_BOARD_SPI // Statically allocate the SPI object so it can live past the end of the heap and into the next VM. // That way it can be used by built-in FourWire displays and be accessible through board.SPI(). -STATIC busio_spi_obj_t spi_obj; -STATIC mp_obj_t spi_singleton = NULL; -mp_obj_t common_hal_board_get_spi(void) { - return spi_singleton; +typedef struct { + const mcu_pin_obj_t *clock; + const mcu_pin_obj_t *mosi; + const mcu_pin_obj_t *miso; +} board_spi_pin_t; + +static const board_spi_pin_t spi_pin[CIRCUITPY_BOARD_SPI] = CIRCUITPY_BOARD_SPI_PIN; +static busio_spi_obj_t spi_obj[CIRCUITPY_BOARD_SPI]; +static bool spi_obj_created[CIRCUITPY_BOARD_SPI]; + +bool common_hal_board_is_spi(mp_obj_t obj) { + for (uint8_t instance = 0; instance < CIRCUITPY_BOARD_SPI; instance++) { + if (obj == &spi_obj[instance]) { + return true; + } + } + return false; } -mp_obj_t common_hal_board_create_spi(void) { - // All callers have either already verified this or come so early that it can't be otherwise. - assert(spi_singleton == NULL || common_hal_busio_spi_deinited(spi_singleton)); - busio_spi_obj_t *self = &spi_obj; +mp_obj_t common_hal_board_get_spi(const mp_int_t instance) { + return spi_obj_created[instance] ? &spi_obj[instance] : NULL; +} + +mp_obj_t common_hal_board_create_spi(const mp_int_t instance) { + const mp_obj_t singleton = common_hal_board_get_spi(instance); + if (singleton != NULL && !common_hal_busio_spi_deinited(singleton)) { + return singleton; + } + + busio_spi_obj_t *self = &spi_obj[instance]; self->base.type = &busio_spi_type; - const mcu_pin_obj_t *clock = MP_OBJ_TO_PTR(DEFAULT_SPI_BUS_SCK); - const mcu_pin_obj_t *mosi = MP_OBJ_TO_PTR(DEFAULT_SPI_BUS_MOSI); - const mcu_pin_obj_t *miso = MP_OBJ_TO_PTR(DEFAULT_SPI_BUS_MISO); - common_hal_busio_spi_construct(self, clock, mosi, miso); - spi_singleton = (mp_obj_t)self; - return spi_singleton; + assert_pin_free(spi_pin[instance].clock); + assert_pin_free(spi_pin[instance].mosi); + assert_pin_free(spi_pin[instance].miso); + + common_hal_busio_spi_construct(self, spi_pin[instance].clock, spi_pin[instance].mosi, spi_pin[instance].miso); + + spi_obj_created[instance] = true; + return &spi_obj[instance]; } #endif -#if BOARD_UART -mp_obj_t common_hal_board_get_uart(void) { - return MP_STATE_VM(shared_uart_bus); +#if CIRCUITPY_BOARD_UART + +typedef struct { + const mcu_pin_obj_t *tx; + const mcu_pin_obj_t *rx; +} board_uart_pin_t; + +static const board_uart_pin_t uart_pin[CIRCUITPY_BOARD_UART] = CIRCUITPY_BOARD_UART_PIN; +static busio_uart_obj_t uart_obj[CIRCUITPY_BOARD_UART]; +static bool uart_obj_created[CIRCUITPY_BOARD_UART]; + +bool common_hal_board_is_uart(mp_obj_t obj) { + for (uint8_t instance = 0; instance < CIRCUITPY_BOARD_UART; instance++) { + if (obj == &uart_obj[instance]) { + return true; + } + } + return false; } -mp_obj_t common_hal_board_create_uart(void) { - busio_uart_obj_t *self = m_new_ll_obj(busio_uart_obj_t); +mp_obj_t common_hal_board_get_uart(const mp_int_t instance) { + return uart_obj_created[instance] ? &uart_obj[instance] : NULL; +} + +mp_obj_t common_hal_board_create_uart(const mp_int_t instance) { + const mp_obj_t singleton = common_hal_board_get_uart(instance); + if (singleton != NULL && !common_hal_busio_uart_deinited(singleton)) { + return singleton; + } + + busio_uart_obj_t *self = &uart_obj[instance]; self->base.type = &busio_uart_type; - const mcu_pin_obj_t *rx = MP_OBJ_TO_PTR(DEFAULT_UART_BUS_RX); - const mcu_pin_obj_t *tx = MP_OBJ_TO_PTR(DEFAULT_UART_BUS_TX); - #ifdef DEFAULT_UART_BUS_RTS - const mcu_pin_obj_t *rts = MP_OBJ_TO_PTR(DEFAULT_UART_BUS_RTS); - #else - const mcu_pin_obj_t *rts = NULL; - #endif - #ifdef DEFAULT_UART_BUS_CTS - const mcu_pin_obj_t *cts = MP_OBJ_TO_PTR(DEFAULT_UART_BUS_CTS); - #else - const mcu_pin_obj_t *cts = NULL; - #endif - #ifdef DEFAULT_UART_IS_RS485 - const mcu_pin_obj_t *rs485_dir = MP_OBJ_TO_PTR(DEFAULT_UART_BUS_RS485DIR); - #ifdef DEFAULT_UART_RS485_INVERT - const bool rs485_invert = true; - #else - const bool rs485_invert = false; - #endif - #else - const mcu_pin_obj_t *rs485_dir = NULL; - const bool rs485_invert = false; - #endif + MP_STATE_VM(board_uart_bus) = &uart_obj; - common_hal_busio_uart_construct(self, tx, rx, rts, cts, rs485_dir, rs485_invert, - 9600, 8, BUSIO_UART_PARITY_NONE, 1, 1.0f, 64, NULL, false); - MP_STATE_VM(shared_uart_bus) = MP_OBJ_FROM_PTR(self); - return MP_STATE_VM(shared_uart_bus); + assert_pin_free(uart_pin[instance].tx); + assert_pin_free(uart_pin[instance].rx); + + common_hal_busio_uart_construct(self, uart_pin[instance].tx, uart_pin[instance].rx, + NULL, NULL, NULL, false, 9600, 8, BUSIO_UART_PARITY_NONE, 1, 1.0f, 64, NULL, false); + + uart_obj_created[instance] = true; + return &uart_obj[instance]; } #endif -void reset_board_busses(void) { - #if BOARD_I2C - bool display_using_i2c = false; - #if CIRCUITPY_DISPLAYIO - for (uint8_t i = 0; i < CIRCUITPY_DISPLAY_LIMIT; i++) { - if (displays[i].bus_base.type == &displayio_i2cdisplay_type && displays[i].i2cdisplay_bus.bus == i2c_singleton) { - display_using_i2c = true; - break; - } - } - #endif - // make sure I2C lock is not held over a soft reset - if (i2c_singleton != NULL) { - common_hal_busio_i2c_unlock(i2c_singleton); - if (!display_using_i2c) { - common_hal_busio_i2c_deinit(i2c_singleton); - i2c_singleton = NULL; - } - } - #endif - #if BOARD_SPI - bool display_using_spi = false; - #if CIRCUITPY_DISPLAYIO - for (uint8_t i = 0; i < CIRCUITPY_DISPLAY_LIMIT; i++) { - mp_const_obj_t bus_type = displays[i].bus_base.type; - if (bus_type == &displayio_fourwire_type && displays[i].fourwire_bus.bus == spi_singleton) { - display_using_spi = true; - break; - } - #if CIRCUITPY_SHARPDISPLAY - if (displays[i].bus_base.type == &sharpdisplay_framebuffer_type && displays[i].sharpdisplay.bus == spi_singleton) { - display_using_spi = true; - break; +void reset_board_buses(void) { + #if CIRCUITPY_BOARD_I2C + for (uint8_t instance = 0; instance < CIRCUITPY_BOARD_I2C; instance++) { + bool display_using_i2c = false; + #if CIRCUITPY_DISPLAYIO + for (uint8_t i = 0; i < CIRCUITPY_DISPLAY_LIMIT; i++) { + if (displays[i].bus_base.type == &displayio_i2cdisplay_type && displays[i].i2cdisplay_bus.bus == &i2c_obj[instance]) { + display_using_i2c = true; + break; + } } #endif - } - #endif - // make sure SPI lock is not held over a soft reset - if (spi_singleton != NULL) { - common_hal_busio_spi_unlock(spi_singleton); - if (!display_using_spi) { - common_hal_busio_spi_deinit(spi_singleton); - spi_singleton = NULL; + if (i2c_obj_created[instance]) { + // make sure I2C lock is not held over a soft reset + common_hal_busio_i2c_unlock(&i2c_obj[instance]); + if (!display_using_i2c) { + common_hal_busio_i2c_deinit(&i2c_obj[instance]); + i2c_obj_created[instance] = false; + } } } #endif - #if BOARD_UART - MP_STATE_VM(shared_uart_bus) = NULL; + #if CIRCUITPY_BOARD_SPI + for (uint8_t instance = 0; instance < CIRCUITPY_BOARD_SPI; instance++) { + bool display_using_spi = false; + #if CIRCUITPY_DISPLAYIO + for (uint8_t i = 0; i < CIRCUITPY_DISPLAY_LIMIT; i++) { + mp_const_obj_t bus_type = displays[i].bus_base.type; + if (bus_type == &displayio_fourwire_type && displays[i].fourwire_bus.bus == &spi_obj[instance]) { + display_using_spi = true; + break; + } + #if CIRCUITPY_SHARPDISPLAY + if (displays[i].bus_base.type == &sharpdisplay_framebuffer_type && displays[i].sharpdisplay.bus == &spi_obj[instance]) { + display_using_spi = true; + break; + } + #endif + } + #endif + if (spi_obj_created[instance]) { + // make sure SPI lock is not held over a soft reset + common_hal_busio_spi_unlock(&spi_obj[instance]); + if (!display_using_spi) { + common_hal_busio_spi_deinit(&spi_obj[instance]); + spi_obj_created[instance] = false; + } + } + } + #endif + #if CIRCUITPY_BOARD_UART + for (uint8_t instance = 0; instance < CIRCUITPY_BOARD_UART; instance++) { + if (uart_obj_created[instance]) { + common_hal_busio_uart_deinit(&uart_obj[instance]); + uart_obj_created[instance] = false; + } + } #endif } diff --git a/shared-module/board/__init__.h b/shared-module/board/__init__.h index f7eecd4170..8b3723bdda 100644 --- a/shared-module/board/__init__.h +++ b/shared-module/board/__init__.h @@ -27,6 +27,6 @@ #ifndef MICROPY_INCLUDED_SHARED_MODULE_BOARD__INIT__H #define MICROPY_INCLUDED_SHARED_MODULE_BOARD__INIT__H -void reset_board_busses(void); +void reset_board_buses(void); #endif // MICROPY_INCLUDED_SHARED_MODULE_BOARD__INIT__H diff --git a/shared-module/busio/I2C.c b/shared-module/busio/I2C.c deleted file mode 100644 index d3db18e3ad..0000000000 --- a/shared-module/busio/I2C.c +++ /dev/null @@ -1,70 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#include "shared-bindings/busio/I2C.h" -#include "shared-bindings/bitbangio/I2C.h" -#include "py/mperrno.h" -#include "py/nlr.h" - -void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, - const mcu_pin_obj_t *scl, const mcu_pin_obj_t *sda, uint32_t freq, uint32_t timeout) { - shared_module_bitbangio_i2c_construct(&self->bitbang, scl, sda, freq, timeout); -} - -bool common_hal_busio_i2c_deinited(busio_i2c_obj_t *self) { - return shared_module_bitbangio_i2c_deinited(&self->bitbang); -} - -void common_hal_busio_i2c_deinit(busio_i2c_obj_t *self) { - shared_module_bitbangio_i2c_deinit(&self->bitbang); -} - -bool common_hal_busio_i2c_probe(busio_i2c_obj_t *self, uint8_t addr) { - return shared_module_bitbangio_i2c_probe(&self->bitbang, addr); -} - -bool common_hal_busio_i2c_try_lock(busio_i2c_obj_t *self) { - return shared_module_bitbangio_i2c_try_lock(&self->bitbang); -} - -bool common_hal_busio_i2c_has_lock(busio_i2c_obj_t *self) { - return shared_module_bitbangio_i2c_has_lock(&self->bitbang); -} - -void common_hal_busio_i2c_unlock(busio_i2c_obj_t *self) { - shared_module_bitbangio_i2c_unlock(&self->bitbang); -} - -uint8_t common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t addr, - const uint8_t *data, size_t len, bool transmit_stop_bit) { - return shared_module_bitbangio_i2c_write(&self->bitbang, addr, data, len, - transmit_stop_bit); -} - -uint8_t common_hal_busio_i2c_read(busio_i2c_obj_t *self, uint16_t addr, - uint8_t *data, size_t len) { - return shared_module_bitbangio_i2c_read(&self->bitbang, addr, data, len); -} diff --git a/shared-module/displayio/Display.c b/shared-module/displayio/Display.c index 4d41245b3b..579dca49fc 100644 --- a/shared-module/displayio/Display.c +++ b/shared-module/displayio/Display.c @@ -220,6 +220,10 @@ mp_obj_t common_hal_displayio_display_get_bus(displayio_display_obj_t *self) { return self->core.bus; } +mp_obj_t common_hal_displayio_display_get_root_group(displayio_display_obj_t *self) { + return self->core.current_group; +} + STATIC const displayio_area_t *_get_refresh_areas(displayio_display_obj_t *self) { if (self->core.full_refresh) { self->core.area.next = NULL; diff --git a/shared-module/displayio/EPaperDisplay.c b/shared-module/displayio/EPaperDisplay.c index d2190c1b42..b1e998048e 100644 --- a/shared-module/displayio/EPaperDisplay.c +++ b/shared-module/displayio/EPaperDisplay.c @@ -54,7 +54,7 @@ void common_hal_displayio_epaperdisplay_construct(displayio_epaperdisplay_obj_t uint16_t set_column_window_command, uint16_t set_row_window_command, uint16_t set_current_column_command, uint16_t set_current_row_command, uint16_t write_black_ram_command, bool black_bits_inverted, uint16_t write_color_ram_command, bool color_bits_inverted, uint32_t highlight_color, uint16_t refresh_display_command, mp_float_t refresh_time, - const mcu_pin_obj_t *busy_pin, bool busy_state, mp_float_t seconds_per_frame, bool chip_select, bool grayscale) { + const mcu_pin_obj_t *busy_pin, bool busy_state, mp_float_t seconds_per_frame, bool chip_select, bool grayscale, bool two_byte_sequence_length) { if (highlight_color != 0x000000) { self->core.colorspace.tricolor = true; self->core.colorspace.tricolor_hue = displayio_colorconverter_compute_hue(highlight_color); @@ -85,6 +85,7 @@ void common_hal_displayio_epaperdisplay_construct(displayio_epaperdisplay_obj_t self->stop_sequence_len = stop_sequence_len; self->busy.base.type = &mp_type_NoneType; + self->two_byte_sequence_length = two_byte_sequence_length; if (busy_pin != NULL) { self->busy.base.type = &digitalio_digitalinout_type; common_hal_digitalio_digitalinout_construct(&self->busy, busy_pin); @@ -145,8 +146,12 @@ STATIC void send_command_sequence(displayio_epaperdisplay_obj_t *self, const uint8_t *cmd = sequence + i; uint8_t data_size = *(cmd + 1); bool delay = (data_size & DELAY) != 0; - data_size &= ~DELAY; const uint8_t *data = cmd + 2; + data_size &= ~DELAY; + if (self->two_byte_sequence_length) { + data_size = ((data_size & ~DELAY) << 8) + *(cmd + 2); + data = cmd + 3; + } displayio_display_core_begin_transaction(&self->core); self->core.send(self->core.bus, DISPLAY_COMMAND, self->chip_select, cmd, 1); self->core.send(self->core.bus, DISPLAY_DATA, self->chip_select, data, data_size); @@ -164,6 +169,9 @@ STATIC void send_command_sequence(displayio_epaperdisplay_obj_t *self, wait_for_busy(self); } i += 2 + data_size; + if (self->two_byte_sequence_length) { + i++; + } } } diff --git a/shared-module/displayio/EPaperDisplay.h b/shared-module/displayio/EPaperDisplay.h index 65a4dd7743..55feaf964b 100644 --- a/shared-module/displayio/EPaperDisplay.h +++ b/shared-module/displayio/EPaperDisplay.h @@ -57,6 +57,7 @@ typedef struct { bool refreshing; bool grayscale; display_chip_select_behavior_t chip_select; + bool two_byte_sequence_length; } displayio_epaperdisplay_obj_t; void displayio_epaperdisplay_change_refresh_mode_parameters(displayio_epaperdisplay_obj_t *self, diff --git a/shared-module/displayio/I2CDisplay.c b/shared-module/displayio/I2CDisplay.c index 6446e3198f..8fae5d31fd 100644 --- a/shared-module/displayio/I2CDisplay.c +++ b/shared-module/displayio/I2CDisplay.c @@ -112,12 +112,12 @@ void common_hal_displayio_i2cdisplay_send(mp_obj_t obj, display_byte_type_t data command_bytes[2 * i] = 0x80; command_bytes[2 * i + 1] = data[i]; } - common_hal_busio_i2c_write(self->bus, self->address, command_bytes, 2 * data_length, true); + common_hal_busio_i2c_write(self->bus, self->address, command_bytes, 2 * data_length); } else { uint8_t data_bytes[data_length + 1]; data_bytes[0] = 0x40; memcpy(data_bytes + 1, data, data_length); - common_hal_busio_i2c_write(self->bus, self->address, data_bytes, data_length + 1, true); + common_hal_busio_i2c_write(self->bus, self->address, data_bytes, data_length + 1); } } diff --git a/shared-module/displayio/__init__.c b/shared-module/displayio/__init__.c index ff085d45ef..d026d9f766 100644 --- a/shared-module/displayio/__init__.c +++ b/shared-module/displayio/__init__.c @@ -24,7 +24,6 @@ * THE SOFTWARE. */ - #include #include "shared-module/displayio/__init__.h" @@ -143,8 +142,8 @@ void common_hal_displayio_release_displays(void) { common_hal_rgbmatrix_rgbmatrix_deinit(&displays[i].rgbmatrix); #endif #if CIRCUITPY_IS31FL3741 - } else if (bus_type == &is31fl3741_IS31FL3741_type) { - common_hal_is31fl3741_IS31FL3741_deinit(&displays[i].is31fl3741); + } else if (bus_type == &is31fl3741_FrameBuffer_type) { + common_hal_is31fl3741_FrameBuffer_deinit(&displays[i].is31fl3741); #endif #if CIRCUITPY_SHARPDISPLAY } else if (displays[i].bus_base.type == &sharpdisplay_framebuffer_type) { @@ -169,11 +168,11 @@ void reset_displays(void) { if (((size_t)fourwire->bus) < ((size_t)&displays) || ((size_t)fourwire->bus) > ((size_t)&displays + CIRCUITPY_DISPLAY_LIMIT)) { busio_spi_obj_t *original_spi = fourwire->bus; - #if BOARD_SPI - // We don't need to move original_spi if it is the board.SPI object because it is + #if CIRCUITPY_BOARD_SPI + // We don't need to move original_spi if it is a board.SPI object because it is // statically allocated already. (Doing so would also make it impossible to reference in // a subsequent VM run.) - if (original_spi == common_hal_board_get_spi()) { + if (common_hal_board_is_spi(original_spi)) { continue; } #endif @@ -197,11 +196,11 @@ void reset_displays(void) { if (((size_t)i2c->bus) < ((size_t)&displays) || ((size_t)i2c->bus) > ((size_t)&displays + CIRCUITPY_DISPLAY_LIMIT)) { busio_i2c_obj_t *original_i2c = i2c->bus; - #if BOARD_I2C - // We don't need to move original_i2c if it is the board.I2C object because it is + #if CIRCUITPY_BOARD_I2C + // We don't need to move original_i2c if it is a board.I2C object because it is // statically allocated already. (Doing so would also make it impossible to reference in // a subsequent VM run.) - if (original_i2c == common_hal_board_get_i2c()) { + if (common_hal_board_is_i2c(original_i2c)) { continue; } #endif @@ -225,34 +224,33 @@ void reset_displays(void) { } #endif #if CIRCUITPY_IS31FL3741 - } else if (displays[i].is31fl3741.base.type == &is31fl3741_IS31FL3741_type) { - is31fl3741_IS31FL3741_obj_t *is31 = &displays[i].is31fl3741; - if (((uint32_t)is31->i2c) < ((uint32_t)&displays) || - ((uint32_t)is31->i2c) > ((uint32_t)&displays + CIRCUITPY_DISPLAY_LIMIT)) { - busio_i2c_obj_t *original_i2c = is31->i2c; - #if BOARD_I2C + } else if (displays[i].is31fl3741.base.type == &is31fl3741_FrameBuffer_type) { + is31fl3741_FrameBuffer_obj_t *is31fb = &displays[i].is31fl3741; + + if (((uint32_t)is31fb->is31fl3741->i2c) < ((uint32_t)&displays) || + ((uint32_t)is31fb->is31fl3741->i2c) > ((uint32_t)&displays + CIRCUITPY_DISPLAY_LIMIT)) { + #if CIRCUITPY_BOARD_I2C // We don't need to move original_i2c if it is the board.I2C object because it is // statically allocated already. (Doing so would also make it impossible to reference in // a subsequent VM run.) - if (original_i2c == common_hal_board_get_i2c()) { + if (common_hal_board_is_i2c(is31fb->is31fl3741->i2c)) { continue; } #endif - memcpy(&is31->inline_i2c, original_i2c, sizeof(busio_i2c_obj_t)); - is31->i2c = &is31->inline_i2c; - // Check for other displays that use the same i2c bus and swap them too. - /*for (uint8_t j = i + 1; j < CIRCUITPY_DISPLAY_LIMIT; j++) { - if (displays[i].i2cdisplay_bus.base.type == &displayio_i2cdisplay_type && - displays[i].i2cdisplay_bus.bus == original_i2c) { - displays[i].i2cdisplay_bus.bus = &i2c->inline_bus; - } - }*/ + + is31fl3741_IS31FL3741_obj_t *original_is31 = is31fb->is31fl3741; + memcpy(&is31fb->inline_is31fl3741, original_is31, sizeof(is31fl3741_IS31FL3741_obj_t)); + is31fb->is31fl3741 = &is31fb->inline_is31fl3741; + + busio_i2c_obj_t *original_i2c = is31fb->is31fl3741->i2c; + memcpy(&is31fb->is31fl3741->inline_i2c, original_i2c, sizeof(busio_i2c_obj_t)); + is31fb->is31fl3741->i2c = &is31fb->is31fl3741->inline_i2c; } - if (!any_display_uses_this_framebuffer(&is31->base)) { - common_hal_is31fl3741_IS31FL3741_deinit(is31); + if (!any_display_uses_this_framebuffer(&is31fb->base)) { + common_hal_is31fl3741_FrameBuffer_deinit(is31fb); } else { - common_hal_is31fl3741_IS31FL3741_set_paused(is31, true); + common_hal_is31fl3741_FrameBuffer_set_paused(is31fb, true); } #endif #if CIRCUITPY_SHARPDISPLAY @@ -299,8 +297,8 @@ void displayio_gc_collect(void) { } #endif #if CIRCUITPY_IS31FL3741 - if (displays[i].is31fl3741.base.type == &is31fl3741_IS31FL3741_type) { - is31fl3741_IS31FL3741_collect_ptrs(&displays[i].is31fl3741); + if (displays[i].is31fl3741.base.type == &is31fl3741_FrameBuffer_type) { + is31fl3741_FrameBuffer_collect_ptrs(&displays[i].is31fl3741); } #endif #if CIRCUITPY_SHARPDISPLAY diff --git a/shared-module/displayio/__init__.h b/shared-module/displayio/__init__.h index b4133308eb..c1954b146c 100644 --- a/shared-module/displayio/__init__.h +++ b/shared-module/displayio/__init__.h @@ -42,7 +42,7 @@ #include "shared-bindings/rgbmatrix/RGBMatrix.h" #endif #if CIRCUITPY_IS31FL3741 -#include "shared-bindings/is31fl3741/IS31FL3741.h" +#include "shared-bindings/is31fl3741/FrameBuffer.h" #endif #if CIRCUITPY_SHARPDISPLAY #include "shared-module/sharpdisplay/SharpMemoryFramebuffer.h" @@ -63,7 +63,7 @@ typedef struct { rgbmatrix_rgbmatrix_obj_t rgbmatrix; #endif #if CIRCUITPY_IS31FL3741 - is31fl3741_IS31FL3741_obj_t is31fl3741; + is31fl3741_FrameBuffer_obj_t is31fl3741; #endif #if CIRCUITPY_SHARPDISPLAY sharpdisplay_framebuffer_obj_t sharpdisplay; diff --git a/shared-module/displayio/display_core.c b/shared-module/displayio/display_core.c index 114b274fd1..78e946823b 100644 --- a/shared-module/displayio/display_core.c +++ b/shared-module/displayio/display_core.c @@ -163,12 +163,15 @@ void displayio_display_core_set_rotation(displayio_display_core_t *self, } bool displayio_display_core_show(displayio_display_core_t *self, displayio_group_t *root_group) { - if (root_group == NULL) { - if (!circuitpython_splash.in_group) { - root_group = &circuitpython_splash; - } else if (self->current_group == &circuitpython_splash) { - return true; - } + + if (root_group == NULL) { // set the display to the REPL, reset REPL position and size + circuitpython_splash.in_group = false; + // force the circuit_python_splash out of any group (Note: could cause problems with the parent group) + circuitpython_splash.x = 0; // reset position in case someone moved it. + circuitpython_splash.y = 0; + supervisor_stop_terminal(); + supervisor_start_terminal(self->width, self->height); + root_group = &circuitpython_splash; } if (root_group == self->current_group) { return true; diff --git a/shared-module/is31fl3741/FrameBuffer.c b/shared-module/is31fl3741/FrameBuffer.c new file mode 100644 index 0000000000..ebe630cacd --- /dev/null +++ b/shared-module/is31fl3741/FrameBuffer.c @@ -0,0 +1,227 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Mark Komus + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include + +#include "py/gc.h" +#include "py/obj.h" +#include "py/objarray.h" +#include "py/objproperty.h" +#include "py/runtime.h" + +#include "shared-module/is31fl3741/allocator.h" +#include "shared-bindings/is31fl3741/IS31FL3741.h" +#include "shared-bindings/is31fl3741/FrameBuffer.h" +#include "shared-bindings/util.h" +#include "shared-module/framebufferio/FramebufferDisplay.h" +#include "shared-bindings/busio/I2C.h" + +void common_hal_is31fl3741_FrameBuffer_construct(is31fl3741_FrameBuffer_obj_t *self, int width, int height, mp_obj_t framebuffer, is31fl3741_IS31FL3741_obj_t *is31, mp_obj_t mapping) { + self->width = width; + self->height = height; + + self->bufsize = sizeof(uint32_t) * width * height; + + self->is31fl3741 = is31; + + common_hal_busio_i2c_never_reset(self->is31fl3741->i2c); + // Our object is statically allocated off the heap so make sure the bus object lives to the end + // of the heap as well. + gc_never_free(self->is31fl3741->i2c); + gc_never_free(self->is31fl3741); + + mp_obj_t *items; + size_t len; + mp_obj_tuple_get(mapping, &len, &items); + + if (len != (size_t)(self->scale_width * self->scale_height * 3)) { + mp_raise_ValueError(translate("LED mappings must match display size")); + } + + self->mapping = common_hal_is31fl3741_allocator_impl(sizeof(uint16_t) * len); + for (size_t i = 0; i < len; i++) { + mp_int_t value = mp_obj_get_int(items[i]); + // We only store up to 16 bits + if (value > 0xFFFF) { + value = 0xFFFF; + } + self->mapping[i] = (uint16_t)value; + } + + common_hal_is31fl3741_FrameBuffer_reconstruct(self, framebuffer); +} + +void common_hal_is31fl3741_FrameBuffer_reconstruct(is31fl3741_FrameBuffer_obj_t *self, mp_obj_t framebuffer) { + self->paused = 1; + + if (framebuffer) { + self->framebuffer = framebuffer; + mp_get_buffer_raise(self->framebuffer, &self->bufinfo, MP_BUFFER_READ); + if (mp_get_buffer(self->framebuffer, &self->bufinfo, MP_BUFFER_RW)) { + self->bufinfo.typecode = 'H' | MP_OBJ_ARRAY_TYPECODE_FLAG_RW; + } else { + self->bufinfo.typecode = 'H'; + } + + // verify that the matrix is big enough + mp_get_index(mp_obj_get_type(self->framebuffer), self->bufinfo.len, MP_OBJ_NEW_SMALL_INT(self->bufsize - 1), false); + } else { + common_hal_is31fl3741_free_impl(self->bufinfo.buf); + + self->framebuffer = NULL; + self->bufinfo.buf = common_hal_is31fl3741_allocator_impl(self->bufsize); + self->bufinfo.len = self->bufsize; + self->bufinfo.typecode = 'H' | MP_OBJ_ARRAY_TYPECODE_FLAG_RW; + } + + common_hal_is31fl3741_begin_transaction(self->is31fl3741); + common_hal_is31fl3741_send_reset(self->is31fl3741); + common_hal_is31fl3741_set_current(self->is31fl3741, 0xFE); + + // set scale (brightness) to max for all LEDs + for (int i = 0; i < 351; i++) { + common_hal_is31fl3741_set_led(self->is31fl3741, i, 0xFF, 2); + } + + common_hal_is31fl3741_send_enable(self->is31fl3741); + common_hal_is31fl3741_end_transaction(self->is31fl3741); + + self->paused = 0; +} + +void common_hal_is31fl3741_FrameBuffer_deinit(is31fl3741_FrameBuffer_obj_t *self) { + common_hal_is31fl3741_end_transaction(self->is31fl3741); // in case we still had a lock + + common_hal_is31fl3741_IS31FL3741_deinit(self->is31fl3741); + + if (self->mapping != 0) { + common_hal_is31fl3741_free_impl(self->mapping); + self->mapping = 0; + } + + self->base.type = NULL; + + // If a framebuffer was passed in to the constructor, NULL the reference + // here so that it will become GC'able + self->framebuffer = NULL; +} + +void common_hal_is31fl3741_FrameBuffer_set_paused(is31fl3741_FrameBuffer_obj_t *self, bool paused) { + self->paused = paused; +} + +bool common_hal_is31fl3741_FrameBuffer_get_paused(is31fl3741_FrameBuffer_obj_t *self) { + return self->paused; +} + +void common_hal_is31fl3741_FrameBuffer_refresh(is31fl3741_FrameBuffer_obj_t *self, uint8_t *dirtyrows) { + if (!self->paused) { + common_hal_is31fl3741_begin_transaction(self->is31fl3741); + + uint8_t dirty_row_flags = 0xFF; // only supports 8 rows gotta fix + + if (self->scale) { + // Based on the Arduino IS31FL3741 driver code + // dirtyrows flag current not implemented for scaled displays + uint32_t *buffer = self->bufinfo.buf; + + for (int x = 0; x < self->scale_width; x++) { + uint32_t *ptr = &buffer[x * 3]; // Entry along top scan line w/x offset + for (int y = 0; y < self->scale_height; y++) { + uint16_t rsum = 0, gsum = 0, bsum = 0; + // Inner x/y loops are row-major on purpose (less pointer math) + for (uint8_t yy = 0; yy < 3; yy++) { + for (uint8_t xx = 0; xx < 3; xx++) { + uint32_t rgb = ptr[xx]; + rsum += rgb >> 16 & 0xFF; + gsum += (rgb >> 8) & 0xFF; + bsum += rgb & 0xFF; + } + ptr += self->width; // Advance one scan line + } + rsum = rsum / 9; + gsum = gsum / 9; + bsum = bsum / 9; + uint32_t color = 0; + if (self->auto_gamma) { + color = (IS31GammaTable[rsum] << 16) + + (IS31GammaTable[gsum] << 8) + + IS31GammaTable[bsum]; + } else { + color = (rsum << 16) + (gsum << 8) + bsum; + } + common_hal_is31fl3741_draw_pixel(self->is31fl3741, x, y, color, self->mapping); + } + } + } else { + uint32_t *buffer = self->bufinfo.buf; + for (int y = 0; y < self->height; y++) { + if ((dirtyrows != 0) && ((y % 8) == 0)) { + dirty_row_flags = *dirtyrows++; + } + + if ((dirty_row_flags >> (y % 8)) & 0x1) { + uint32_t color = 0; + if (self->auto_gamma) { + color = IS31GammaTable[((*buffer) >> 16 & 0xFF)] + + IS31GammaTable[((*buffer) >> 8 & 0xFF)] + + IS31GammaTable[((*buffer) & 0xFF)]; + } else { + color = *buffer; + } + + for (int x = 0; x < self->width; x++) { + common_hal_is31fl3741_draw_pixel(self->is31fl3741, x, y, color, self->mapping); + buffer++; + } + } + } + } + common_hal_is31fl3741_end_transaction(self->is31fl3741); + } +} + +int common_hal_is31fl3741_FrameBuffer_get_width(is31fl3741_FrameBuffer_obj_t *self) { + return self->width; +} + +int common_hal_is31fl3741_FrameBuffer_get_height(is31fl3741_FrameBuffer_obj_t *self) { + return self->height; +} + +void *common_hal_is31fl3741_allocator_impl(size_t sz) { + supervisor_allocation *allocation = allocate_memory(align32_size(sz), false, true); + return allocation ? allocation->ptr : NULL; +} + +void common_hal_is31fl3741_free_impl(void *ptr_in) { + free_memory(allocation_from_ptr(ptr_in)); +} + +void is31fl3741_FrameBuffer_collect_ptrs(is31fl3741_FrameBuffer_obj_t *self) { + gc_collect_ptr(self->framebuffer); + gc_collect_ptr(self->mapping); +} diff --git a/shared-module/is31fl3741/FrameBuffer.h b/shared-module/is31fl3741/FrameBuffer.h new file mode 100644 index 0000000000..6d0258ce40 --- /dev/null +++ b/shared-module/is31fl3741/FrameBuffer.h @@ -0,0 +1,46 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Mark Komus + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#pragma once + +#include "py/obj.h" +#include "lib/protomatter/src/core.h" +#include "shared-module/is31fl3741/IS31FL3741.h" + +extern const mp_obj_type_t is31fl3741_FrameBuffer_type; +typedef struct { + mp_obj_base_t base; + is31fl3741_IS31FL3741_obj_t *is31fl3741; + is31fl3741_IS31FL3741_obj_t inline_is31fl3741; + mp_obj_t framebuffer; + mp_buffer_info_t bufinfo; + uint16_t bufsize, width, height, scale_width, scale_height; + uint16_t *mapping; + uint8_t bit_depth; + bool paused; + bool scale; + bool auto_gamma; +} is31fl3741_FrameBuffer_obj_t; diff --git a/shared-module/is31fl3741/IS31FL3741.c b/shared-module/is31fl3741/IS31FL3741.c index 9d7316e1cd..bb92b5b32c 100644 --- a/shared-module/is31fl3741/IS31FL3741.c +++ b/shared-module/is31fl3741/IS31FL3741.c @@ -32,20 +32,11 @@ #include "py/objproperty.h" #include "py/runtime.h" -#include "shared-module/is31fl3741/allocator.h" #include "shared-bindings/is31fl3741/IS31FL3741.h" -#include "shared-bindings/microcontroller/Pin.h" -#include "shared-bindings/microcontroller/__init__.h" #include "shared-bindings/util.h" -#include "shared-module/framebufferio/FramebufferDisplay.h" #include "shared-bindings/busio/I2C.h" -void common_hal_is31fl3741_IS31FL3741_construct(is31fl3741_IS31FL3741_obj_t *self, int width, int height, mp_obj_t framebuffer, busio_i2c_obj_t *i2c, uint8_t addr, mp_obj_t mapping) { - self->width = width; - self->height = height; - - self->bufsize = sizeof(uint32_t) * width * height; - +void common_hal_is31fl3741_IS31FL3741_construct(is31fl3741_IS31FL3741_obj_t *self, busio_i2c_obj_t *i2c, uint8_t addr) { // Probe the bus to see if a device acknowledges the given address. if (!common_hal_busio_i2c_probe(i2c, addr)) { self->base.type = &mp_type_NoneType; @@ -54,193 +45,35 @@ void common_hal_is31fl3741_IS31FL3741_construct(is31fl3741_IS31FL3741_obj_t *sel self->i2c = i2c; self->device_address = addr; - common_hal_busio_i2c_never_reset(self->i2c); - // Our object is statically allocated off the heap so make sure the bus object lives to the end - // of the heap as well. - gc_never_free(self->i2c); - - mp_obj_t *items; - size_t len; - mp_obj_list_get(mapping, &len, &items); - - if (len != (size_t)(self->scale_width * self->scale_height * 3)) { - mp_raise_ValueError(translate("LED mappings must match display size")); - } - - self->mapping = common_hal_is31fl3741_allocator_impl(sizeof(uint16_t) * len); - for (size_t i = 0; i < len; i++) { - mp_int_t value = mp_obj_get_int(items[i]); - // We only store up to 16 bits - if (value > 0xFFFF) { - value = 0xFFFF; - } - self->mapping[i] = (uint16_t)value; - } - - common_hal_is31fl3741_IS31FL3741_reconstruct(self, framebuffer); -} - -void common_hal_is31fl3741_IS31FL3741_reconstruct(is31fl3741_IS31FL3741_obj_t *self, mp_obj_t framebuffer) { - self->paused = 1; - - if (framebuffer) { - self->framebuffer = framebuffer; - mp_get_buffer_raise(self->framebuffer, &self->bufinfo, MP_BUFFER_READ); - if (mp_get_buffer(self->framebuffer, &self->bufinfo, MP_BUFFER_RW)) { - self->bufinfo.typecode = 'H' | MP_OBJ_ARRAY_TYPECODE_FLAG_RW; - } else { - self->bufinfo.typecode = 'H'; - } - - // verify that the matrix is big enough - mp_get_index(mp_obj_get_type(self->framebuffer), self->bufinfo.len, MP_OBJ_NEW_SMALL_INT(self->bufsize - 1), false); - } else { - common_hal_is31fl3741_free_impl(self->bufinfo.buf); - - self->framebuffer = NULL; - self->bufinfo.buf = common_hal_is31fl3741_allocator_impl(self->bufsize); - self->bufinfo.len = self->bufsize; - self->bufinfo.typecode = 'H' | MP_OBJ_ARRAY_TYPECODE_FLAG_RW; - } - - common_hal_displayio_is31fl3741_begin_transaction(self); - - uint8_t command = 0xFC; // device ID - common_hal_busio_i2c_write(self->i2c, self->device_address, &command, 1, false); - uint8_t data = 0; - common_hal_busio_i2c_read(self->i2c, self->device_address, &data, 1); - - is31fl3741_send_reset(self->i2c, self->device_address); - is31fl3741_send_enable(self->i2c, self->device_address); - is31fl3741_set_current(self->i2c, self->device_address, 0xFF); - - // set scale (brightness) to max for all LEDs - for (int i; i < 351; i++) { - is31fl3741_set_led(self->i2c, self->device_address, i, 0xFF, 2); - } - - common_hal_displayio_is31fl3741_end_transaction(self); - - self->paused = 0; } void common_hal_is31fl3741_IS31FL3741_deinit(is31fl3741_IS31FL3741_obj_t *self) { - common_hal_displayio_is31fl3741_end_transaction(self); // in case we still had a lock + common_hal_is31fl3741_end_transaction(self); // in case we still had a lock if (self->i2c == &self->inline_i2c) { common_hal_busio_i2c_deinit(self->i2c); self->i2c = NULL; } - if (self->mapping != 0) { - common_hal_is31fl3741_free_impl(self->mapping); - self->mapping = 0; - } - self->base.type = NULL; - - // If a framebuffer was passed in to the constructor, NULL the reference - // here so that it will become GC'able - self->framebuffer = NULL; } -void common_hal_is31fl3741_IS31FL3741_set_paused(is31fl3741_IS31FL3741_obj_t *self, bool paused) { - self->paused = paused; -} +void common_hal_is31fl3741_write(is31fl3741_IS31FL3741_obj_t *is31, const mp_obj_t *mapping, const uint8_t *pixels, size_t numBytes) { + common_hal_is31fl3741_begin_transaction(is31); -bool common_hal_is31fl3741_IS31FL3741_get_paused(is31fl3741_IS31FL3741_obj_t *self) { - return self->paused; -} - -void common_hal_is31fl3741_IS31FL3741_set_global_current(is31fl3741_IS31FL3741_obj_t *self, uint8_t current) { - common_hal_displayio_is31fl3741_begin_transaction(self); - is31fl3741_set_current(self->i2c, self->device_address, current); - common_hal_displayio_is31fl3741_end_transaction(self); -} - -uint8_t common_hal_is31fl3741_IS31FL3741_get_global_current(is31fl3741_IS31FL3741_obj_t *self) { - common_hal_displayio_is31fl3741_begin_transaction(self); - uint8_t current = is31fl3741_get_current(self->i2c, self->device_address); - common_hal_displayio_is31fl3741_end_transaction(self); - return current; -} - -void common_hal_is31fl3741_IS31FL3741_refresh(is31fl3741_IS31FL3741_obj_t *self, uint8_t *dirtyrows) { - common_hal_displayio_is31fl3741_begin_transaction(self); - if (!self->paused) { - uint8_t dirty_row_flags = 0xFF; // only supports 8 rows gotta fix - - if (self->scale) { - // Based on the Arduino IS31FL3741 driver code - // dirtyrows flag current not implemented for scaled displays - uint32_t *buffer = self->bufinfo.buf; - - for (int x = 0; x < self->scale_width; x++) { - uint32_t *ptr = &buffer[x * 3]; // Entry along top scan line w/x offset - for (int y = 0; y < self->scale_height; y++) { - uint16_t rsum = 0, gsum = 0, bsum = 0; - // Inner x/y loops are row-major on purpose (less pointer math) - for (uint8_t yy = 0; yy < 3; yy++) { - for (uint8_t xx = 0; xx < 3; xx++) { - uint32_t rgb = ptr[xx]; - rsum += rgb >> 16 & 0xFF; - gsum += (rgb >> 8) & 0xFF; - bsum += rgb & 0xFF; - } - ptr += self->width; // Advance one scan line - } - rsum = rsum / 9; - gsum = gsum / 9; - bsum = bsum / 9; - uint32_t color = 0; - if (self->auto_gamma) { - color = (IS31GammaTable[rsum] << 16) + - (IS31GammaTable[gsum] << 8) + - IS31GammaTable[bsum]; - } else { - color = (rsum << 16) + (gsum << 8) + bsum; - } - is31fl3741_draw_pixel(self->i2c, self->device_address, x, y, color, self->mapping); - } - } - } else { - uint32_t *buffer = self->bufinfo.buf; - for (int y = 0; y < self->height; y++) { - if ((dirtyrows != 0) && ((y % 8) == 0)) { - dirty_row_flags = *dirtyrows++; - } - - if ((dirty_row_flags >> (y % 8)) & 0x1) { - uint32_t color = 0; - if (self->auto_gamma) { - color = IS31GammaTable[((*buffer) >> 16 & 0xFF)] + - IS31GammaTable[((*buffer) >> 8 & 0xFF)] + - IS31GammaTable[((*buffer) & 0xFF)]; - } else { - color = *buffer; - } - - for (int x = 0; x < self->width; x++) { - is31fl3741_draw_pixel(self->i2c, self->device_address, x, y, color, self->mapping); - buffer++; - } - } - } + for (size_t i = 0; i < numBytes; i += 3) { + uint16_t ridx = mp_obj_get_int(mapping[i]); + if (ridx != 65535) { + common_hal_is31fl3741_set_led(is31, ridx, IS31GammaTable[pixels[i]], 0); // red + common_hal_is31fl3741_set_led(is31, mp_obj_get_int(mapping[i + 1]), IS31GammaTable[pixels[i + 1]], 0); // green + common_hal_is31fl3741_set_led(is31, mp_obj_get_int(mapping[i + 2]), IS31GammaTable[pixels[i + 2]], 0); // blue } } - common_hal_displayio_is31fl3741_end_transaction(self); + common_hal_is31fl3741_end_transaction(is31); } -int common_hal_is31fl3741_IS31FL3741_get_width(is31fl3741_IS31FL3741_obj_t *self) { - return self->width; -} - -int common_hal_is31fl3741_IS31FL3741_get_height(is31fl3741_IS31FL3741_obj_t *self) { - return self->height; -} - -void common_hal_displayio_is31fl3741_begin_transaction(is31fl3741_IS31FL3741_obj_t *self) { +void common_hal_is31fl3741_begin_transaction(is31fl3741_IS31FL3741_obj_t *self) { while (!common_hal_busio_i2c_try_lock(self->i2c)) { RUN_BACKGROUND_TASKS; if (mp_hal_is_interrupted()) { @@ -249,94 +82,73 @@ void common_hal_displayio_is31fl3741_begin_transaction(is31fl3741_IS31FL3741_obj } } -void common_hal_displayio_is31fl3741_end_transaction(is31fl3741_IS31FL3741_obj_t *self) { +void common_hal_is31fl3741_end_transaction(is31fl3741_IS31FL3741_obj_t *self) { common_hal_busio_i2c_unlock(self->i2c); } -void *common_hal_is31fl3741_allocator_impl(size_t sz) { - supervisor_allocation *allocation = allocate_memory(align32_size(sz), false, true); - return allocation ? allocation->ptr : NULL; -} +uint8_t is31fl3741_cur_page = 99; // set to invalid page to start -void common_hal_is31fl3741_free_impl(void *ptr_in) { - free_memory(allocation_from_ptr(ptr_in)); -} - -void is31fl3741_IS31FL3741_collect_ptrs(is31fl3741_IS31FL3741_obj_t *self) { - gc_collect_ptr(self->framebuffer); - gc_collect_ptr(self->mapping); -} - -// The following are routines to manipulate the IS31FL3741 chip -// They are not meant to be called by user code but only used -// internally. - -uint8_t cur_page = 99; // set to invalid page to start - -void is31fl3741_send_unlock(busio_i2c_obj_t *i2c, uint8_t addr) { +void common_hal_is31fl3741_send_unlock(is31fl3741_IS31FL3741_obj_t *self) { uint8_t unlock[2] = { 0xFE, 0xC5 }; // unlock command - common_hal_busio_i2c_write(i2c, addr, unlock, 2, true); + common_hal_busio_i2c_write(self->i2c, self->device_address, unlock, 2); } -void is31fl3741_set_page(busio_i2c_obj_t *i2c, uint8_t addr, uint8_t p) { - if (p == cur_page) { +void common_hal_is31fl3741_set_page(is31fl3741_IS31FL3741_obj_t *self, uint8_t p) { + if (p == is31fl3741_cur_page) { return; } - cur_page = p; - is31fl3741_send_unlock(i2c, addr); + is31fl3741_cur_page = p; + common_hal_is31fl3741_send_unlock(self); uint8_t page[2] = { 0xFD, 0x00 }; // page command page[1] = p; - common_hal_busio_i2c_write(i2c, addr, page, 2, true); + common_hal_busio_i2c_write(self->i2c, self->device_address, page, 2); } -void is31fl3741_send_enable(busio_i2c_obj_t *i2c, uint8_t addr) { - is31fl3741_set_page(i2c, addr, 4); +void common_hal_is31fl3741_send_enable(is31fl3741_IS31FL3741_obj_t *self) { + common_hal_is31fl3741_set_page(self, 4); uint8_t enable[2] = { 0x00, 0x01 }; // enable command - common_hal_busio_i2c_write(i2c, addr, enable, 2, true); + common_hal_busio_i2c_write(self->i2c, self->device_address, enable, 2); } -void is31fl3741_send_reset(busio_i2c_obj_t *i2c, uint8_t addr) { - is31fl3741_set_page(i2c, addr, 4); +void common_hal_is31fl3741_send_reset(is31fl3741_IS31FL3741_obj_t *self) { + common_hal_is31fl3741_set_page(self, 4); uint8_t rst[2] = { 0x3F, 0xAE }; // reset command - common_hal_busio_i2c_write(i2c, addr, rst, 2, true); + common_hal_busio_i2c_write(self->i2c, self->device_address, rst, 2); } -void is31fl3741_set_current(busio_i2c_obj_t *i2c, uint8_t addr, uint8_t current) { - is31fl3741_set_page(i2c, addr, 4); +void common_hal_is31fl3741_set_current(is31fl3741_IS31FL3741_obj_t *self, uint8_t current) { + common_hal_is31fl3741_set_page(self, 4); uint8_t gcur[2] = { 0x01, 0x00 }; // global current command gcur[1] = current; - common_hal_busio_i2c_write(i2c, addr, gcur, 2, true); + common_hal_busio_i2c_write(self->i2c, self->device_address, gcur, 2); } -uint8_t is31fl3741_get_current(busio_i2c_obj_t *i2c, uint8_t addr) { - is31fl3741_set_page(i2c, addr, 4); +uint8_t common_hal_is31fl3741_get_current(is31fl3741_IS31FL3741_obj_t *self) { + common_hal_is31fl3741_set_page(self, 4); uint8_t gcur = 0x01; // global current command - common_hal_busio_i2c_write(i2c, addr, &gcur, 1, true); - - uint8_t data = 0; - common_hal_busio_i2c_read(i2c, addr, &data, 1); - return data; + common_hal_busio_i2c_write_read(self->i2c, self->device_address, &gcur, 1, &gcur, 1); + return gcur; } -void is31fl3741_set_led(busio_i2c_obj_t *i2c, uint8_t addr, uint16_t led, uint8_t level, uint8_t page) { +void common_hal_is31fl3741_set_led(is31fl3741_IS31FL3741_obj_t *self, uint16_t led, uint8_t level, uint8_t page) { uint8_t cmd[2] = { 0x00, 0x00 }; if (led < 180) { - is31fl3741_set_page(i2c, addr, page); + common_hal_is31fl3741_set_page(self, page); cmd[0] = (uint8_t)led; } else { - is31fl3741_set_page(i2c, addr, page + 1); + common_hal_is31fl3741_set_page(self, page + 1); cmd[0] = (uint8_t)(led - 180); } cmd[1] = level; - common_hal_busio_i2c_write(i2c, addr, cmd, 2, true); + common_hal_busio_i2c_write(self->i2c, self->device_address, cmd, 2); } -void is31fl3741_draw_pixel(busio_i2c_obj_t *i2c, uint8_t addr, int16_t x, int16_t y, uint32_t color, uint16_t *mapping) { +void common_hal_is31fl3741_draw_pixel(is31fl3741_IS31FL3741_obj_t *self, int16_t x, int16_t y, uint32_t color, uint16_t *mapping) { uint8_t r = color >> 16 & 0xFF; uint8_t g = color >> 8 & 0xFF; uint8_t b = color & 0xFF; @@ -346,8 +158,8 @@ void is31fl3741_draw_pixel(busio_i2c_obj_t *i2c, uint8_t addr, int16_t x, int16_ if (ridx != 65535) { uint16_t gidx = mapping[x1 + 1]; uint16_t bidx = mapping[x1 + 0]; - is31fl3741_set_led(i2c, addr, ridx, r, 0); - is31fl3741_set_led(i2c, addr, gidx, g, 0); - is31fl3741_set_led(i2c, addr, bidx, b, 0); + common_hal_is31fl3741_set_led(self, ridx, r, 0); + common_hal_is31fl3741_set_led(self, gidx, g, 0); + common_hal_is31fl3741_set_led(self, bidx, b, 0); } } diff --git a/shared-module/is31fl3741/IS31FL3741.h b/shared-module/is31fl3741/IS31FL3741.h index c2ccfde849..03f1902c47 100644 --- a/shared-module/is31fl3741/IS31FL3741.h +++ b/shared-module/is31fl3741/IS31FL3741.h @@ -33,17 +33,9 @@ extern const mp_obj_type_t is31fl3741_is31fl3741_type; typedef struct { mp_obj_base_t base; - mp_obj_t framebuffer; - mp_buffer_info_t bufinfo; - uint16_t bufsize, width, height, scale_width, scale_height; busio_i2c_obj_t *i2c; busio_i2c_obj_t inline_i2c; uint8_t device_address; - uint16_t *mapping; - uint8_t bit_depth; - bool paused; - bool scale; - bool auto_gamma; } is31fl3741_IS31FL3741_obj_t; // Gamma correction table diff --git a/shared-module/is31fl3741/__init__.c b/shared-module/is31fl3741/__init__.c index e69de29bb2..c267047eda 100644 --- a/shared-module/is31fl3741/__init__.c +++ b/shared-module/is31fl3741/__init__.c @@ -0,0 +1,25 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Mark Komus + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ diff --git a/shared-module/sharpdisplay/SharpMemoryFramebuffer.c b/shared-module/sharpdisplay/SharpMemoryFramebuffer.c index ba0e0f2d69..285abb1dbe 100644 --- a/shared-module/sharpdisplay/SharpMemoryFramebuffer.c +++ b/shared-module/sharpdisplay/SharpMemoryFramebuffer.c @@ -71,8 +71,8 @@ STATIC bool common_hal_sharpdisplay_framebuffer_get_pixels_in_byte_share_row(sha void common_hal_sharpdisplay_framebuffer_reset(sharpdisplay_framebuffer_obj_t *self) { if (self->bus != &self->inline_bus - #if BOARD_SPI - && self->bus != common_hal_board_get_spi() + #if CIRCUITPY_BOARD_SPI + && !common_hal_board_is_spi(self->bus) #endif ) { memcpy(&self->inline_bus, self->bus, sizeof(busio_spi_obj_t)); diff --git a/supervisor/shared/external_flash/spi_flash.c b/supervisor/shared/external_flash/spi_flash.c index 9444e303a1..fdff71ea97 100644 --- a/supervisor/shared/external_flash/spi_flash.c +++ b/supervisor/shared/external_flash/spi_flash.c @@ -105,12 +105,12 @@ bool spi_flash_sector_command(uint8_t command, uint32_t address) { bool spi_flash_write_data(uint32_t address, uint8_t *data, uint32_t data_length) { uint8_t request[4] = {CMD_PAGE_PROGRAM, 0x00, 0x00, 0x00}; + common_hal_busio_spi_configure(&supervisor_flash_spi_bus, spi_flash_baudrate, 0, 0, 8); // Write the SPI flash write address into the bytes following the command byte. address_to_bytes(address, request + 1); if (!flash_enable()) { return false; } - common_hal_busio_spi_configure(&supervisor_flash_spi_bus, spi_flash_baudrate, 0, 0, 8); bool status = common_hal_busio_spi_write(&supervisor_flash_spi_bus, request, 4); if (status) { status = common_hal_busio_spi_write(&supervisor_flash_spi_bus, data, data_length); @@ -126,12 +126,12 @@ bool spi_flash_read_data(uint32_t address, uint8_t *data, uint32_t data_length) request[0] = CMD_FAST_READ_DATA; command_length = 5; } + common_hal_busio_spi_configure(&supervisor_flash_spi_bus, spi_flash_baudrate, 0, 0, 8); // Write the SPI flash read address into the bytes following the command byte. address_to_bytes(address, request + 1); if (!flash_enable()) { return false; } - common_hal_busio_spi_configure(&supervisor_flash_spi_bus, spi_flash_baudrate, 0, 0, 8); bool status = common_hal_busio_spi_write(&supervisor_flash_spi_bus, request, command_length); if (status) { status = common_hal_busio_spi_read(&supervisor_flash_spi_bus, data, data_length, 0xff); @@ -144,7 +144,6 @@ void spi_flash_init(void) { cs_pin.base.type = &digitalio_digitalinout_type; common_hal_digitalio_digitalinout_construct(&cs_pin, SPI_FLASH_CS_PIN); - // Set CS high (disabled). common_hal_digitalio_digitalinout_switch_to_output(&cs_pin, true, DRIVE_MODE_PUSH_PULL); common_hal_digitalio_digitalinout_never_reset(&cs_pin); @@ -152,6 +151,8 @@ void spi_flash_init(void) { supervisor_flash_spi_bus.base.type = &busio_spi_type; common_hal_busio_spi_construct(&supervisor_flash_spi_bus, SPI_FLASH_SCK_PIN, SPI_FLASH_MOSI_PIN, SPI_FLASH_MISO_PIN); common_hal_busio_spi_never_reset(&supervisor_flash_spi_bus); + + return; } void spi_flash_init_device(const external_flash_device *device) { @@ -160,4 +161,6 @@ void spi_flash_init_device(const external_flash_device *device) { if (spi_flash_baudrate > SPI_FLASH_MAX_BAUDRATE) { spi_flash_baudrate = SPI_FLASH_MAX_BAUDRATE; } + common_hal_busio_spi_configure(&supervisor_flash_spi_bus, spi_flash_baudrate, 0, 0, 8); + return; } diff --git a/supervisor/shared/status_leds.c b/supervisor/shared/status_leds.c index 0c433271fc..6c7cde28cc 100644 --- a/supervisor/shared/status_leds.c +++ b/supervisor/shared/status_leds.c @@ -48,6 +48,7 @@ uint8_t rgb_status_brightness = 63; #define MICROPY_HW_NEOPIXEL_COUNT (1) #endif +static uint64_t next_start_raw_ticks; static uint8_t status_neopixel_color[3 * MICROPY_HW_NEOPIXEL_COUNT]; static digitalio_digitalinout_obj_t status_neopixel; @@ -218,6 +219,10 @@ void status_led_init() { void status_led_deinit() { #ifdef MICROPY_HW_NEOPIXEL + // Make sure the pin stays low for the reset period. The pin reset may pull + // it up and stop the reset period. + while (port_get_raw_ticks(NULL) < next_start_raw_ticks) { + } common_hal_reset_pin(MICROPY_HW_NEOPIXEL); #elif defined(MICROPY_HW_APA102_MOSI) && defined(MICROPY_HW_APA102_SCK) @@ -265,7 +270,7 @@ void new_status_color(uint32_t rgb) { status_neopixel_color[3 * i + 2] = rgb_adjusted & 0xff; } common_hal_neopixel_write(&status_neopixel, status_neopixel_color, 3 * MICROPY_HW_NEOPIXEL_COUNT); - + next_start_raw_ticks = port_get_raw_ticks(NULL) + 2; #elif defined(MICROPY_HW_APA102_MOSI) && defined(MICROPY_HW_APA102_SCK) for (size_t i = 0; i < MICROPY_HW_APA102_COUNT; i++) { // Skip 4 + offset to skip the header bytes too. diff --git a/tests/circuitpython-manual/audiobusio/i2s_sample_loop.py b/tests/circuitpython-manual/audiobusio/i2s_sample_loop.py index 8b40e916dc..75ed4c7ae6 100644 --- a/tests/circuitpython-manual/audiobusio/i2s_sample_loop.py +++ b/tests/circuitpython-manual/audiobusio/i2s_sample_loop.py @@ -19,7 +19,7 @@ length = 8000 // 440 # signed 16 bit s16 = array.array("h", [0] * length) for i in range(length): - s16[i] = int(math.sin(math.pi * 2 * i / length) * (2 ** 15)) + s16[i] = int(math.sin(math.pi * 2 * i / length) * (2**15)) print(s16[i]) sample = audiocore.RawSample(s16, sample_rate=8000) diff --git a/tests/circuitpython-manual/audiopwmio/single_buffer_loop.py b/tests/circuitpython-manual/audiopwmio/single_buffer_loop.py index 6013892a95..ffacb6f1d6 100644 --- a/tests/circuitpython-manual/audiopwmio/single_buffer_loop.py +++ b/tests/circuitpython-manual/audiopwmio/single_buffer_loop.py @@ -19,21 +19,21 @@ sample_names = ["unsigned 8 bit", "signed 8 bit", "unsigned 16 bit", "signed 16 # unsigned 8 bit u8 = array.array("B", [0] * length) for i in range(length): - u8[i] = int(math.sin(math.pi * 2 * i / length) * (2 ** 7) + 2 ** 7) + u8[i] = int(math.sin(math.pi * 2 * i / length) * (2**7) + 2**7) samples.append(audiocore.RawSample(u8, sample_rate=4000)) # signed 8 bit s8 = array.array("b", [0] * length) for i in range(length): - s8[i] = int(math.sin(math.pi * 2 * i / length) * (2 ** 7)) + s8[i] = int(math.sin(math.pi * 2 * i / length) * (2**7)) samples.append(audiocore.RawSample(s8, sample_rate=16000)) # unsigned 16 bit u16 = array.array("H", [0] * length) for i in range(length): - u16[i] = int(math.sin(math.pi * 2 * i / length) * (2 ** 15) + 2 ** 15) + u16[i] = int(math.sin(math.pi * 2 * i / length) * (2**15) + 2**15) samples.append(audiocore.RawSample(u16, sample_rate=8000)) @@ -41,7 +41,7 @@ samples.append(audiocore.RawSample(u16, sample_rate=8000)) # signed 16 bit s16 = array.array("h", [0] * length) for i in range(length): - s16[i] = int(math.sin(math.pi * 2 * i / length) * (2 ** 15)) + s16[i] = int(math.sin(math.pi * 2 * i / length) * (2**15)) samples.append(audiocore.RawSample(s16, sample_rate=8000)) diff --git a/tests/cpydiff/modules_random_randint.py b/tests/cpydiff/modules_random_randint.py index b05908a157..90607400cd 100644 --- a/tests/cpydiff/modules_random_randint.py +++ b/tests/cpydiff/modules_random_randint.py @@ -8,5 +8,5 @@ workaround: If you need integers larger than native wordsize use the random modu import random -x = random.randint(2 ** 128 - 1, 2 ** 128) +x = random.randint(2**128 - 1, 2**128) print("x={}".format(x)) diff --git a/tests/extmod/uhashlib_sha1.py b/tests/extmod/uhashlib_sha1.py index a0ad8473a1..e6e6e30dc1 100644 --- a/tests/extmod/uhashlib_sha1.py +++ b/tests/extmod/uhashlib_sha1.py @@ -22,7 +22,7 @@ print(sha1.digest()) sha1 = hashlib.sha1(b"hello") try: - sha1.update(u"world") + sha1.update("world") except TypeError as e: print("TypeError") print(sha1.digest()) diff --git a/tests/extmod/uhashlib_sha256.py b/tests/extmod/uhashlib_sha256.py index ad5aa124cb..5c6dfd0a75 100644 --- a/tests/extmod/uhashlib_sha256.py +++ b/tests/extmod/uhashlib_sha256.py @@ -28,7 +28,7 @@ print(hashlib.sha256(b"\xff" * 56).digest()) sha256 = hashlib.sha256(b"hello") try: - sha256.update(u"world") + sha256.update("world") except TypeError as e: print("TypeError") print(sha256.digest()) diff --git a/tests/float/complex1.py b/tests/float/complex1.py index a510ffc830..139bb0c509 100644 --- a/tests/float/complex1.py +++ b/tests/float/complex1.py @@ -27,15 +27,15 @@ print(1j * 2j) print(1j / 2) print((1j / 2j).real) print(1j / (1 + 2j)) -ans = 0j ** 0 +ans = 0j**0 print("%.5g %.5g" % (ans.real, ans.imag)) -ans = 0j ** 1 +ans = 0j**1 print("%.5g %.5g" % (ans.real, ans.imag)) -ans = 0j ** 0j +ans = 0j**0j print("%.5g %.5g" % (ans.real, ans.imag)) -ans = 1j ** 2.5 +ans = 1j**2.5 print("%.5g %.5g" % (ans.real, ans.imag)) -ans = 1j ** 2.5j +ans = 1j**2.5j print("%.5g %.5g" % (ans.real, ans.imag)) # comparison @@ -116,10 +116,10 @@ except ZeroDivisionError: # zero division via power try: - 0j ** -1 + 0j**-1 except ZeroDivisionError: print("ZeroDivisionError") try: - 0j ** 1j + 0j**1j except ZeroDivisionError: print("ZeroDivisionError") diff --git a/tests/float/float1.py b/tests/float/float1.py index efde5146be..37f8b3face 100644 --- a/tests/float/float1.py +++ b/tests/float/float1.py @@ -88,7 +88,7 @@ except ZeroDivisionError: print("ZeroDivisionError") try: - 0.0 ** -1 + 0.0**-1 except ZeroDivisionError: print("ZeroDivisionError") diff --git a/tests/float/float2int_doubleprec_intbig.py b/tests/float/float2int_doubleprec_intbig.py index 84fa2d2536..1226b39ca9 100644 --- a/tests/float/float2int_doubleprec_intbig.py +++ b/tests/float/float2int_doubleprec_intbig.py @@ -35,8 +35,8 @@ if ll_type != 0: print(int(1418774543.0)) print("%d" % 1418774543.0) if ll_type == 3: - print(int(2.0 ** 100)) - print("%d" % 2.0 ** 100) + print(int(2.0**100)) + print("%d" % 2.0**100) else: print(int(1073741823.0)) print("%d" % 1073741823.0) @@ -44,7 +44,7 @@ else: testpass = True p2_rng = ((30, 63, 1024), (62, 63, 1024))[is_64bit][ll_type] for i in range(0, p2_rng): - bitcnt = len(bin(int(2.0 ** i))) - 3 + bitcnt = len(bin(int(2.0**i))) - 3 if i != bitcnt: print("fail: 2**%u was %u bits long" % (i, bitcnt)) testpass = False @@ -53,7 +53,7 @@ print("power of 2 test: %s" % (testpass and "passed" or "failed")) testpass = True p10_rng = ((9, 18, 23), (18, 18, 23))[is_64bit][ll_type] for i in range(0, p10_rng): - digcnt = len(str(int(10.0 ** i))) - 1 + digcnt = len(str(int(10.0**i))) - 1 if i != digcnt: print("fail: 10**%u was %u digits long" % (i, digcnt)) testpass = False @@ -72,28 +72,28 @@ def fp2int_test(num, name, should_fail): if ll_type != 2: if ll_type == 0: if is_64bit: - neg_bad_fp = -1.00000005 * 2.0 ** 62.0 - pos_bad_fp = 2.0 ** 62.0 - neg_good_fp = -(2.0 ** 62.0) - pos_good_fp = 0.99999993 * 2.0 ** 62.0 + neg_bad_fp = -1.00000005 * 2.0**62.0 + pos_bad_fp = 2.0**62.0 + neg_good_fp = -(2.0**62.0) + pos_good_fp = 0.99999993 * 2.0**62.0 else: - neg_bad_fp = -1.00000005 * 2.0 ** 30.0 - pos_bad_fp = 2.0 ** 30.0 - neg_good_fp = -(2.0 ** 30.0) - pos_good_fp = 0.9999999499 * 2.0 ** 30.0 + neg_bad_fp = -1.00000005 * 2.0**30.0 + pos_bad_fp = 2.0**30.0 + neg_good_fp = -(2.0**30.0) + pos_good_fp = 0.9999999499 * 2.0**30.0 else: - neg_bad_fp = -0.51 * 2.0 ** 64.0 - pos_bad_fp = 2.0 ** 63.0 - neg_good_fp = -(2.0 ** 63.0) - pos_good_fp = 1.9999998 * 2.0 ** 62.0 + neg_bad_fp = -0.51 * 2.0**64.0 + pos_bad_fp = 2.0**63.0 + neg_good_fp = -(2.0**63.0) + pos_good_fp = 1.9999998 * 2.0**62.0 fp2int_test(neg_bad_fp, "neg bad", True) fp2int_test(pos_bad_fp, "pos bad", True) fp2int_test(neg_good_fp, "neg good", False) fp2int_test(pos_good_fp, "pos good", False) else: - fp2int_test(-1.9999999999999981 * 2.0 ** 1023.0, "large neg", False) - fp2int_test(1.9999999999999981 * 2.0 ** 1023.0, "large pos", False) + fp2int_test(-1.9999999999999981 * 2.0**1023.0, "large neg", False) + fp2int_test(1.9999999999999981 * 2.0**1023.0, "large pos", False) fp2int_test(float("inf"), "inf test", True) fp2int_test(float("-inf"), "inf test", True) diff --git a/tests/float/float2int_fp30_intbig.py b/tests/float/float2int_fp30_intbig.py index 75ff52f39d..a1bfe67046 100644 --- a/tests/float/float2int_fp30_intbig.py +++ b/tests/float/float2int_fp30_intbig.py @@ -34,13 +34,13 @@ if ll_type is None: print(int(14187744.0)) print("%d" % 14187744.0) if ll_type == 2: - print(int(2.0 ** 100)) - print("%d" % 2.0 ** 100) + print(int(2.0**100)) + print("%d" % 2.0**100) testpass = True p2_rng = ((30, 63, 127), (62, 63, 127))[is_64bit][ll_type] for i in range(0, p2_rng): - bitcnt = len(bin(int(2.0 ** i))) - 3 + bitcnt = len(bin(int(2.0**i))) - 3 if i != bitcnt: print("fail: 2.**%u was %u bits long" % (i, bitcnt)) testpass = False @@ -50,7 +50,7 @@ print("power of 2 test: %s" % (testpass and "passed" or "failed")) testpass = True p10_rng = 9 for i in range(0, p10_rng): - digcnt = len(str(int(10.0 ** i))) - 1 + digcnt = len(str(int(10.0**i))) - 1 if i != digcnt: print("fail: 10.**%u was %u digits long" % (i, digcnt)) testpass = False @@ -69,28 +69,28 @@ def fp2int_test(num, name, should_fail): if ll_type != 2: if ll_type == 0: if is_64bit: - neg_bad_fp = -1.00000005 * 2.0 ** 62.0 - pos_bad_fp = 2.0 ** 62.0 - neg_good_fp = -(2.0 ** 62.0) - pos_good_fp = 0.99999993 * 2.0 ** 62.0 + neg_bad_fp = -1.00000005 * 2.0**62.0 + pos_bad_fp = 2.0**62.0 + neg_good_fp = -(2.0**62.0) + pos_good_fp = 0.99999993 * 2.0**62.0 else: - neg_bad_fp = -1.00000005 * 2.0 ** 30.0 - pos_bad_fp = 2.0 ** 30.0 - neg_good_fp = -(2.0 ** 30.0) - pos_good_fp = 0.9999999499 * 2.0 ** 30.0 + neg_bad_fp = -1.00000005 * 2.0**30.0 + pos_bad_fp = 2.0**30.0 + neg_good_fp = -(2.0**30.0) + pos_good_fp = 0.9999999499 * 2.0**30.0 else: - neg_bad_fp = -0.51 * 2.0 ** 64.0 - pos_bad_fp = 2.0 ** 63.0 - neg_good_fp = -(2.0 ** 63.0) - pos_good_fp = 1.9999998 * 2.0 ** 62.0 + neg_bad_fp = -0.51 * 2.0**64.0 + pos_bad_fp = 2.0**63.0 + neg_good_fp = -(2.0**63.0) + pos_good_fp = 1.9999998 * 2.0**62.0 fp2int_test(neg_bad_fp, "neg bad", True) fp2int_test(pos_bad_fp, "pos bad", True) fp2int_test(neg_good_fp, "neg good", False) fp2int_test(pos_good_fp, "pos good", False) else: - fp2int_test(-1.999999879 * 2.0 ** 126.0, "large neg", False) - fp2int_test(1.999999879 * 2.0 ** 126.0, "large pos", False) + fp2int_test(-1.999999879 * 2.0**126.0, "large neg", False) + fp2int_test(1.999999879 * 2.0**126.0, "large pos", False) fp2int_test(float("inf"), "inf test", True) fp2int_test(float("-inf"), "inf test", True) diff --git a/tests/float/float2int_intbig.py b/tests/float/float2int_intbig.py index 62aca39634..06b651bb72 100644 --- a/tests/float/float2int_intbig.py +++ b/tests/float/float2int_intbig.py @@ -37,13 +37,13 @@ print(int(14187745.)) print("%d" % 14187745.) # fmt: on if ll_type == 2: - print(int(2.0 ** 100)) - print("%d" % 2.0 ** 100) + print(int(2.0**100)) + print("%d" % 2.0**100) testpass = True p2_rng = ((30, 63, 127), (62, 63, 127))[is_64bit][ll_type] for i in range(0, p2_rng): - bitcnt = len(bin(int(2.0 ** i))) - 3 + bitcnt = len(bin(int(2.0**i))) - 3 if i != bitcnt: print("fail: 2.**%u was %u bits long" % (i, bitcnt)) testpass = False @@ -53,7 +53,7 @@ print("power of 2 test: %s" % (testpass and "passed" or "failed")) testpass = True p10_rng = 9 if (ll_type == 0 and ~is_64bit) else 11 for i in range(0, p10_rng): - digcnt = len(str(int(10.0 ** i))) - 1 + digcnt = len(str(int(10.0**i))) - 1 if i != digcnt: print("fail: 10.**%u was %u digits long" % (i, digcnt)) testpass = False @@ -72,28 +72,28 @@ def fp2int_test(num, name, should_fail): if ll_type != 2: if ll_type == 0: if is_64bit: - neg_bad_fp = -1.00000005 * 2.0 ** 62.0 - pos_bad_fp = 2.0 ** 62.0 - neg_good_fp = -(2.0 ** 62.0) - pos_good_fp = 0.99999993 * 2.0 ** 62.0 + neg_bad_fp = -1.00000005 * 2.0**62.0 + pos_bad_fp = 2.0**62.0 + neg_good_fp = -(2.0**62.0) + pos_good_fp = 0.99999993 * 2.0**62.0 else: - neg_bad_fp = -1.00000005 * 2.0 ** 30.0 - pos_bad_fp = 2.0 ** 30.0 - neg_good_fp = -(2.0 ** 30.0) - pos_good_fp = 0.9999999499 * 2.0 ** 30.0 + neg_bad_fp = -1.00000005 * 2.0**30.0 + pos_bad_fp = 2.0**30.0 + neg_good_fp = -(2.0**30.0) + pos_good_fp = 0.9999999499 * 2.0**30.0 else: - neg_bad_fp = -0.51 * 2.0 ** 64.0 - pos_bad_fp = 2.0 ** 63.0 - neg_good_fp = -(2.0 ** 63.0) - pos_good_fp = 1.9999998 * 2.0 ** 62.0 + neg_bad_fp = -0.51 * 2.0**64.0 + pos_bad_fp = 2.0**63.0 + neg_good_fp = -(2.0**63.0) + pos_good_fp = 1.9999998 * 2.0**62.0 fp2int_test(neg_bad_fp, "neg bad", True) fp2int_test(pos_bad_fp, "pos bad", True) fp2int_test(neg_good_fp, "neg good", False) fp2int_test(pos_good_fp, "pos good", False) else: - fp2int_test(-1.999999879 * 2.0 ** 127.0, "large neg", False) - fp2int_test(1.999999879 * 2.0 ** 127.0, "large pos", False) + fp2int_test(-1.999999879 * 2.0**127.0, "large neg", False) + fp2int_test(1.999999879 * 2.0**127.0, "large pos", False) fp2int_test(float("inf"), "inf test", True) fp2int_test(float("nan"), "NaN test", True) diff --git a/tests/float/inf_nan_arith.py b/tests/float/inf_nan_arith.py index c27e38bc52..d1a6b18872 100644 --- a/tests/float/inf_nan_arith.py +++ b/tests/float/inf_nan_arith.py @@ -14,7 +14,7 @@ for x in values: except ZeroDivisionError: print(" / ZeroDivisionError") try: - print(" ** pow", x ** y, pow(x, y)) + print(" ** pow", x**y, pow(x, y)) except ZeroDivisionError: print(" ** pow ZeroDivisionError") print(" == != < <= > >=", x == y, x != y, x < y, x <= y, x > y, x >= y) diff --git a/tests/float/int_big_float.py b/tests/float/int_big_float.py index 0bd1662186..dc13e8e0dd 100644 --- a/tests/float/int_big_float.py +++ b/tests/float/int_big_float.py @@ -19,7 +19,7 @@ print("%.5g" % (i / 1.2)) print("%.5g" % (i * 1.2j).imag) # negative power should produce float -print("%.5g" % (i ** -1)) +print("%.5g" % (i**-1)) print("%.5g" % ((2 + i - i) ** -3)) try: diff --git a/tests/float/int_divzero.py b/tests/float/int_divzero.py index b311a1dbcf..ef3531bee8 100644 --- a/tests/float/int_divzero.py +++ b/tests/float/int_divzero.py @@ -4,6 +4,6 @@ except ZeroDivisionError: print("ZeroDivisionError") try: - 0 ** -1 + 0**-1 except ZeroDivisionError: print("ZeroDivisionError") diff --git a/tests/float/int_power.py b/tests/float/int_power.py index ba79247a56..bcda0f98ed 100644 --- a/tests/float/int_power.py +++ b/tests/float/int_power.py @@ -1,7 +1,7 @@ # negative power should produce float x = 2 -print(x ** -2) +print(x**-2) x = 3 x **= -2 diff --git a/tests/import/mpy_native.py b/tests/import/mpy_native.py index bab5f91d53..db7881df43 100644 --- a/tests/import/mpy_native.py +++ b/tests/import/mpy_native.py @@ -11,7 +11,7 @@ except (ImportError, AttributeError): print("SKIP") raise SystemExit -if not (sys.platform == "linux" and sys.maxsize > 2 ** 32): +if not (sys.platform == "linux" and sys.maxsize > 2**32): print("SKIP") raise SystemExit diff --git a/tests/micropython/import_mpy_native_x64.py b/tests/micropython/import_mpy_native_x64.py index 7597843220..c0203cb61c 100644 --- a/tests/micropython/import_mpy_native_x64.py +++ b/tests/micropython/import_mpy_native_x64.py @@ -9,7 +9,7 @@ except (ImportError, AttributeError): print("SKIP") raise SystemExit -if not (sys.platform == "linux" and sys.maxsize > 2 ** 32): +if not (sys.platform == "linux" and sys.maxsize > 2**32): print("SKIP") raise SystemExit diff --git a/tests/misc/rge_sm.py b/tests/misc/rge_sm.py index f3bb4189f7..00b0a7a021 100644 --- a/tests/misc/rge_sm.py +++ b/tests/misc/rge_sm.py @@ -52,12 +52,12 @@ class RungeKutta(object): # couplings are: g1, g2, g3 of U(1), SU(2), SU(3); yt (top Yukawa), lambda (Higgs quartic) # see arxiv.org/abs/0812.4950, eqs 10-15 sysSM = ( - lambda *a: 41.0 / 96.0 / math.pi ** 2 * a[1] ** 3, # g1 - lambda *a: -19.0 / 96.0 / math.pi ** 2 * a[2] ** 3, # g2 - lambda *a: -42.0 / 96.0 / math.pi ** 2 * a[3] ** 3, # g3 + lambda *a: 41.0 / 96.0 / math.pi**2 * a[1] ** 3, # g1 + lambda *a: -19.0 / 96.0 / math.pi**2 * a[2] ** 3, # g2 + lambda *a: -42.0 / 96.0 / math.pi**2 * a[3] ** 3, # g3 lambda *a: 1.0 / 16.0 - / math.pi ** 2 + / math.pi**2 * ( 9.0 / 2.0 * a[4] ** 3 - 8.0 * a[3] ** 2 * a[4] @@ -66,7 +66,7 @@ sysSM = ( ), # yt lambda *a: 1.0 / 16.0 - / math.pi ** 2 + / math.pi**2 * ( 24.0 * a[5] ** 2 + 12.0 * a[4] ** 2 * a[5] @@ -137,5 +137,5 @@ def singleTraj(system, trajStart, h=0.02, tend=1.0): # initial conditions at M_Z singleTraj( - sysSM, [0.354, 0.654, 1.278, 0.983, 0.131], h=0.5, tend=math.log(10 ** 17) + sysSM, [0.354, 0.654, 1.278, 0.983, 0.131], h=0.5, tend=math.log(10**17) ) # true values diff --git a/tests/perf_bench/bm_chaos.py b/tests/perf_bench/bm_chaos.py index 55d282561f..d0f1337db7 100644 --- a/tests/perf_bench/bm_chaos.py +++ b/tests/perf_bench/bm_chaos.py @@ -15,7 +15,7 @@ class GVector(object): self.z = z def Mag(self): - return math.sqrt(self.x ** 2 + self.y ** 2 + self.z ** 2) + return math.sqrt(self.x**2 + self.y**2 + self.z**2) def dist(self, other): return math.sqrt( diff --git a/tests/perf_bench/misc_raytrace.py b/tests/perf_bench/misc_raytrace.py index b51acaccac..a729af99c2 100644 --- a/tests/perf_bench/misc_raytrace.py +++ b/tests/perf_bench/misc_raytrace.py @@ -22,7 +22,7 @@ class Vec: return Vec(self.x * rhs, self.y * rhs, self.z * rhs) def length(self): - return (self.x ** 2 + self.y ** 2 + self.z ** 2) ** 0.5 + return (self.x**2 + self.y**2 + self.z**2) ** 0.5 def normalise(self): l = self.length() @@ -87,12 +87,12 @@ class Sphere: def __init__(self, surface, centre, radius): self.surface = surface self.centre = centre - self.radsq = radius ** 2 + self.radsq = radius**2 def intersect(self, ray): v = self.centre - ray.p b = v.dot(ray.d) - det = b ** 2 - v.dot(v) + self.radsq + det = b**2 - v.dot(v) + self.radsq if det > 0: det **= 0.5 t1 = b - det @@ -180,7 +180,7 @@ def trace_ray(scene, ray, depth): if ndotl > 0: col += light_col * surf.diffuse * ndotl if ldotv > 0: - col += light_col * surf.specular * ldotv ** surf.spec_idx + col += light_col * surf.specular * ldotv**surf.spec_idx # Reflections if depth > 0 and surf.reflect > 0: diff --git a/tests/run-perfbench.py b/tests/run-perfbench.py index bcdbe69abb..5f299281fd 100755 --- a/tests/run-perfbench.py +++ b/tests/run-perfbench.py @@ -33,8 +33,8 @@ def compute_stats(lst): avg += x var += x * x avg /= len(lst) - var = max(0, var / len(lst) - avg ** 2) - return avg, var ** 0.5 + var = max(0, var / len(lst) - avg**2) + return avg, var**0.5 def run_script_on_target(target, script): @@ -201,7 +201,7 @@ def compute_diff(file1, file2, diff_score): sd1 *= av1 / 100 # convert from percent sd to absolute sd sd2 *= av2 / 100 # convert from percent sd to absolute sd av_diff = av2 - av1 - sd_diff = (sd1 ** 2 + sd2 ** 2) ** 0.5 + sd_diff = (sd1**2 + sd2**2) ** 0.5 percent = 100 * av_diff / av1 percent_sd = 100 * sd_diff / av1 print( diff --git a/tools/build_board_info.py b/tools/build_board_info.py index 9f3d09bd88..9058c733ab 100755 --- a/tools/build_board_info.py +++ b/tools/build_board_info.py @@ -70,6 +70,7 @@ extension_by_board = { "meowbit_v121": UF2, # esp32c3 "ai_thinker_esp32-c3s": BIN, + "espressif_esp32c3_devkitm_1_n4": BIN, "microdev_micro_c3": BIN, # broadcom "raspberrypi_zero": KERNEL_IMG, diff --git a/tools/chart_code_size.py b/tools/chart_code_size.py index 2328edd72f..cefe3b8094 100644 --- a/tools/chart_code_size.py +++ b/tools/chart_code_size.py @@ -446,7 +446,7 @@ def do_all_the_things(elf_filename): if "size" not in symbol: print(symbol) size = symbol["size"] / 8 - square_size = size ** 0.5 + square_size = size**0.5 if text_width_ish > square_size: w = text_width_ish h = size / text_width_ish