diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 65d5feb68e..7fa71f1e66 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -17,8 +17,8 @@ jobs: - name: Install deps run: | sudo apt-add-repository -y -u ppa:pybricks/ppa - sudo apt-get install -y black gettext uncrustify - pip3 install -r requirements-dev.txt + sudo apt-get install -y gettext uncrustify + pip3 install black polib pyyaml - name: Populate selected submodules run: git submodule update --init extmod/ulab - name: Set PY @@ -28,3 +28,12 @@ jobs: path: ~/.cache/pre-commit key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }} - uses: pre-commit/action@v1.1.0 + - name: Make patch + if: failure() + run: git diff > ~/pre-commit.patch + - name: Upload patch + if: failure() + uses: actions/upload-artifact@v2 + with: + name: patch + path: ~/pre-commit.patch diff --git a/extmod/modubinascii.c b/extmod/modubinascii.c index 01a3c62f6c..c21ae8bc80 100644 --- a/extmod/modubinascii.c +++ b/extmod/modubinascii.c @@ -235,3 +235,5 @@ const mp_obj_module_t mp_module_ubinascii = { .base = { &mp_type_module }, .globals = (mp_obj_dict_t *)&mp_module_binascii_globals, }; + +MP_REGISTER_MODULE(MP_QSTR_binascii, mp_module_ubinascii, MICROPY_PY_UBINASCII); diff --git a/extmod/modujson.c b/extmod/modujson.c index a9d231785a..57d72b3bea 100644 --- a/extmod/modujson.c +++ b/extmod/modujson.c @@ -375,4 +375,6 @@ const mp_obj_module_t mp_module_ujson = { .globals = (mp_obj_dict_t *)&mp_module_ujson_globals, }; +MP_REGISTER_MODULE(MP_QSTR_json, mp_module_ujson, MICROPY_PY_UJSON); + #endif // MICROPY_PY_UJSON diff --git a/extmod/modure.c b/extmod/modure.c index 7fd7b09395..18a28d3628 100644 --- a/extmod/modure.c +++ b/extmod/modure.c @@ -469,6 +469,8 @@ const mp_obj_module_t mp_module_ure = { .base = { &mp_type_module }, .globals = (mp_obj_dict_t *)&mp_module_re_globals, }; + +MP_REGISTER_MODULE(MP_QSTR_re, mp_module_ure, MICROPY_PY_URE); #endif // Source files #include'd here to make sure they're compiled in diff --git a/frozen/circuitpython-stage b/frozen/circuitpython-stage index d0f1c46d7f..2c89a32906 160000 --- a/frozen/circuitpython-stage +++ b/frozen/circuitpython-stage @@ -1 +1 @@ -Subproject commit d0f1c46d7f879cd60562ee69900d619499d4d206 +Subproject commit 2c89a329063848bcd7dba6af6fb6c9d6036dd4f2 diff --git a/locale/ID.po b/locale/ID.po index 88e1aa5407..a9286da991 100644 --- a/locale/ID.po +++ b/locale/ID.po @@ -172,6 +172,10 @@ msgstr "pin %q tidak valid" msgid "%q should be an int" msgstr "%q harus berupa int" +#: shared-bindings/usb_hid/Device.c +msgid "%q with a report ID of 0 must be of length 1" +msgstr "" + #: py/bc.c py/objnamedtuple.c msgid "%q() takes %d positional arguments but %d were given" msgstr "%q() mengambil posisi argumen %d tapi %d yang diberikan" @@ -376,7 +380,9 @@ msgstr "Jenis alamat di luar batas" msgid "All CAN peripherals are in use" msgstr "" -#: ports/espressif/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c +#: ports/espressif/common-hal/busio/I2C.c +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c +#: ports/nrf/common-hal/busio/I2C.c msgid "All I2C peripherals are in use" msgstr "Semua perangkat I2C sedang digunakan" @@ -1321,8 +1327,11 @@ msgstr "Frekuensi PWM tidak valid" msgid "Invalid Pin" msgstr "" -#: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c -#: py/moduerrno.c shared-module/rgbmatrix/RGBMatrix.c +#: ports/espressif/bindings/espidf/__init__.c +#: ports/espressif/common-hal/busio/I2C.c +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c +#: ports/espressif/esp_error.c py/moduerrno.c +#: shared-module/rgbmatrix/RGBMatrix.c msgid "Invalid argument" msgstr "Argumen tidak valid" @@ -1370,10 +1379,6 @@ msgstr "File tidak valid" msgid "Invalid format chunk size" msgstr "Ukuran potongan format tidak valid" -#: ports/espressif/common-hal/busio/I2C.c -msgid "Invalid frequency" -msgstr "" - #: supervisor/shared/safe_mode.c msgid "Invalid memory access." msgstr "Akses memori tidak valid." @@ -1414,6 +1419,7 @@ msgstr "Pin untuk channel kanan tidak valid" #: ports/espressif/common-hal/busio/SPI.c #: ports/espressif/common-hal/busio/UART.c #: ports/espressif/common-hal/canio/CAN.c +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c #: ports/mimxrt10xx/common-hal/busio/I2C.c #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/nrf/common-hal/busio/I2C.c #: ports/raspberrypi/common-hal/busio/I2C.c @@ -1796,6 +1802,10 @@ msgstr "" msgid "Only one TouchAlarm can be set in deep sleep." msgstr "" +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c +msgid "Only one address is allowed" +msgstr "" + #: ports/espressif/common-hal/alarm/time/TimeAlarm.c #: ports/nrf/common-hal/alarm/time/TimeAlarm.c #: ports/raspberrypi/common-hal/alarm/time/TimeAlarm.c @@ -1920,10 +1930,13 @@ msgstr "" "konstruktor" #: ports/raspberrypi/common-hal/imagecapture/ParallelImageCapture.c -#: ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c msgid "Pins must be sequential" msgstr "Pin harus berurutan" +#: ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c +msgid "Pins must be sequential GPIO pins" +msgstr "" + #: ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c msgid "Pins must share PWM slice" msgstr "" @@ -3976,6 +3989,7 @@ msgstr "" #: ports/espressif/boards/adafruit_funhouse/mpconfigboard.h #: ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h +#: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h #: ports/espressif/boards/atmegazero_esp32s2/mpconfigboard.h @@ -3994,6 +4008,7 @@ msgstr "" #: ports/espressif/boards/gravitech_cucumber_rs/mpconfigboard.h #: ports/espressif/boards/lilygo_ttgo_t8_s2_st7789/mpconfigboard.h #: ports/espressif/boards/lolin_s2_mini/mpconfigboard.h +#: ports/espressif/boards/microdev_micro_c3/mpconfigboard.h #: ports/espressif/boards/microdev_micro_s2/mpconfigboard.h #: ports/espressif/boards/morpheans_morphesp-240/mpconfigboard.h #: ports/espressif/boards/muselab_nanoesp32_s2_wroom/mpconfigboard.h diff --git a/locale/cs.po b/locale/cs.po index 95bc1c51dd..654dbf2e35 100644 --- a/locale/cs.po +++ b/locale/cs.po @@ -168,6 +168,10 @@ msgstr "Pin %q není platný" msgid "%q should be an int" msgstr "%q by měl být int" +#: shared-bindings/usb_hid/Device.c +msgid "%q with a report ID of 0 must be of length 1" +msgstr "" + #: py/bc.c py/objnamedtuple.c msgid "%q() takes %d positional arguments but %d were given" msgstr "%q() vyžaduje %d pozičních argumentů, ale %d jich bylo zadáno" @@ -372,7 +376,9 @@ msgstr "" msgid "All CAN peripherals are in use" msgstr "" -#: ports/espressif/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c +#: ports/espressif/common-hal/busio/I2C.c +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c +#: ports/nrf/common-hal/busio/I2C.c msgid "All I2C peripherals are in use" msgstr "" @@ -1304,8 +1310,11 @@ msgstr "" msgid "Invalid Pin" msgstr "" -#: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c -#: py/moduerrno.c shared-module/rgbmatrix/RGBMatrix.c +#: ports/espressif/bindings/espidf/__init__.c +#: ports/espressif/common-hal/busio/I2C.c +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c +#: ports/espressif/esp_error.c py/moduerrno.c +#: shared-module/rgbmatrix/RGBMatrix.c msgid "Invalid argument" msgstr "" @@ -1353,10 +1362,6 @@ msgstr "" msgid "Invalid format chunk size" msgstr "" -#: ports/espressif/common-hal/busio/I2C.c -msgid "Invalid frequency" -msgstr "" - #: supervisor/shared/safe_mode.c msgid "Invalid memory access." msgstr "" @@ -1397,6 +1402,7 @@ msgstr "" #: ports/espressif/common-hal/busio/SPI.c #: ports/espressif/common-hal/busio/UART.c #: ports/espressif/common-hal/canio/CAN.c +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c #: ports/mimxrt10xx/common-hal/busio/I2C.c #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/nrf/common-hal/busio/I2C.c #: ports/raspberrypi/common-hal/busio/I2C.c @@ -1774,6 +1780,10 @@ msgstr "" msgid "Only one TouchAlarm can be set in deep sleep." msgstr "" +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c +msgid "Only one address is allowed" +msgstr "" + #: ports/espressif/common-hal/alarm/time/TimeAlarm.c #: ports/nrf/common-hal/alarm/time/TimeAlarm.c #: ports/raspberrypi/common-hal/alarm/time/TimeAlarm.c @@ -1893,10 +1903,13 @@ msgid "" msgstr "" #: ports/raspberrypi/common-hal/imagecapture/ParallelImageCapture.c -#: ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c msgid "Pins must be sequential" msgstr "" +#: ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c +msgid "Pins must be sequential GPIO pins" +msgstr "" + #: ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c msgid "Pins must share PWM slice" msgstr "" @@ -3936,6 +3949,7 @@ msgstr "" #: ports/espressif/boards/adafruit_funhouse/mpconfigboard.h #: ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h +#: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h #: ports/espressif/boards/atmegazero_esp32s2/mpconfigboard.h @@ -3954,6 +3968,7 @@ msgstr "" #: ports/espressif/boards/gravitech_cucumber_rs/mpconfigboard.h #: ports/espressif/boards/lilygo_ttgo_t8_s2_st7789/mpconfigboard.h #: ports/espressif/boards/lolin_s2_mini/mpconfigboard.h +#: ports/espressif/boards/microdev_micro_c3/mpconfigboard.h #: ports/espressif/boards/microdev_micro_s2/mpconfigboard.h #: ports/espressif/boards/morpheans_morphesp-240/mpconfigboard.h #: ports/espressif/boards/muselab_nanoesp32_s2_wroom/mpconfigboard.h diff --git a/locale/de_DE.po b/locale/de_DE.po index abd2a98aac..e631cc163d 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -173,6 +173,10 @@ msgstr "%q Pin ungültig" msgid "%q should be an int" msgstr "%q sollte ein integer sein" +#: shared-bindings/usb_hid/Device.c +msgid "%q with a report ID of 0 must be of length 1" +msgstr "" + #: py/bc.c py/objnamedtuple.c msgid "%q() takes %d positional arguments but %d were given" msgstr "" @@ -378,7 +382,9 @@ msgstr "Adresstyp außerhalb des zulässigen Bereichs" msgid "All CAN peripherals are in use" msgstr "Alle CAN Schnittstellen sind in Benutzung" -#: ports/espressif/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c +#: ports/espressif/common-hal/busio/I2C.c +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c +#: ports/nrf/common-hal/busio/I2C.c msgid "All I2C peripherals are in use" msgstr "Alle I2C-Peripheriegeräte sind in Benutzung" @@ -1321,8 +1327,11 @@ msgstr "Ungültige PWM Frequenz" msgid "Invalid Pin" msgstr "Ungültiger Pin" -#: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c -#: py/moduerrno.c shared-module/rgbmatrix/RGBMatrix.c +#: ports/espressif/bindings/espidf/__init__.c +#: ports/espressif/common-hal/busio/I2C.c +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c +#: ports/espressif/esp_error.c py/moduerrno.c +#: shared-module/rgbmatrix/RGBMatrix.c msgid "Invalid argument" msgstr "Ungültiges Argument" @@ -1370,10 +1379,6 @@ msgstr "Ungültige Datei" msgid "Invalid format chunk size" msgstr "Ungültige format chunk size" -#: ports/espressif/common-hal/busio/I2C.c -msgid "Invalid frequency" -msgstr "Ungültige Frequenz" - #: supervisor/shared/safe_mode.c msgid "Invalid memory access." msgstr "Ungültiger Speicherzugriff." @@ -1414,6 +1419,7 @@ msgstr "Ungültiger Pin für rechten Kanal" #: ports/espressif/common-hal/busio/SPI.c #: ports/espressif/common-hal/busio/UART.c #: ports/espressif/common-hal/canio/CAN.c +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c #: ports/mimxrt10xx/common-hal/busio/I2C.c #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/nrf/common-hal/busio/I2C.c #: ports/raspberrypi/common-hal/busio/I2C.c @@ -1798,6 +1804,10 @@ msgstr "" msgid "Only one TouchAlarm can be set in deep sleep." msgstr "" +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c +msgid "Only one address is allowed" +msgstr "" + #: ports/espressif/common-hal/alarm/time/TimeAlarm.c #: ports/nrf/common-hal/alarm/time/TimeAlarm.c #: ports/raspberrypi/common-hal/alarm/time/TimeAlarm.c @@ -1920,10 +1930,13 @@ msgstr "" "allow_inefficient = True an den Konstruktor" #: ports/raspberrypi/common-hal/imagecapture/ParallelImageCapture.c -#: ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c msgid "Pins must be sequential" msgstr "" +#: ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c +msgid "Pins must be sequential GPIO pins" +msgstr "" + #: ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c msgid "Pins must share PWM slice" msgstr "" @@ -4005,6 +4018,7 @@ msgstr "pow() mit 3 Argumenten erfordert Integer" #: ports/espressif/boards/adafruit_funhouse/mpconfigboard.h #: ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h +#: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h #: ports/espressif/boards/atmegazero_esp32s2/mpconfigboard.h @@ -4023,6 +4037,7 @@ msgstr "pow() mit 3 Argumenten erfordert Integer" #: ports/espressif/boards/gravitech_cucumber_rs/mpconfigboard.h #: ports/espressif/boards/lilygo_ttgo_t8_s2_st7789/mpconfigboard.h #: ports/espressif/boards/lolin_s2_mini/mpconfigboard.h +#: ports/espressif/boards/microdev_micro_c3/mpconfigboard.h #: ports/espressif/boards/microdev_micro_s2/mpconfigboard.h #: ports/espressif/boards/morpheans_morphesp-240/mpconfigboard.h #: ports/espressif/boards/muselab_nanoesp32_s2_wroom/mpconfigboard.h @@ -4564,6 +4579,9 @@ msgstr "" msgid "zi must be of shape (n_section, 2)" msgstr "" +#~ msgid "Invalid frequency" +#~ msgstr "Ungültige Frequenz" + #~ msgid "Data 0 pin must be byte aligned." #~ msgstr "Data 0 Pin muss Byte aligned sein." diff --git a/locale/el.po b/locale/el.po index 27b497e26a..4de3dfd155 100644 --- a/locale/el.po +++ b/locale/el.po @@ -165,6 +165,10 @@ msgstr "" msgid "%q should be an int" msgstr "" +#: shared-bindings/usb_hid/Device.c +msgid "%q with a report ID of 0 must be of length 1" +msgstr "" + #: py/bc.c py/objnamedtuple.c msgid "%q() takes %d positional arguments but %d were given" msgstr "" @@ -369,7 +373,9 @@ msgstr "" msgid "All CAN peripherals are in use" msgstr "" -#: ports/espressif/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c +#: ports/espressif/common-hal/busio/I2C.c +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c +#: ports/nrf/common-hal/busio/I2C.c msgid "All I2C peripherals are in use" msgstr "" @@ -1301,8 +1307,11 @@ msgstr "" msgid "Invalid Pin" msgstr "" -#: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c -#: py/moduerrno.c shared-module/rgbmatrix/RGBMatrix.c +#: ports/espressif/bindings/espidf/__init__.c +#: ports/espressif/common-hal/busio/I2C.c +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c +#: ports/espressif/esp_error.c py/moduerrno.c +#: shared-module/rgbmatrix/RGBMatrix.c msgid "Invalid argument" msgstr "" @@ -1350,10 +1359,6 @@ msgstr "" msgid "Invalid format chunk size" msgstr "" -#: ports/espressif/common-hal/busio/I2C.c -msgid "Invalid frequency" -msgstr "" - #: supervisor/shared/safe_mode.c msgid "Invalid memory access." msgstr "" @@ -1394,6 +1399,7 @@ msgstr "" #: ports/espressif/common-hal/busio/SPI.c #: ports/espressif/common-hal/busio/UART.c #: ports/espressif/common-hal/canio/CAN.c +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c #: ports/mimxrt10xx/common-hal/busio/I2C.c #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/nrf/common-hal/busio/I2C.c #: ports/raspberrypi/common-hal/busio/I2C.c @@ -1771,6 +1777,10 @@ msgstr "" msgid "Only one TouchAlarm can be set in deep sleep." msgstr "" +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c +msgid "Only one address is allowed" +msgstr "" + #: ports/espressif/common-hal/alarm/time/TimeAlarm.c #: ports/nrf/common-hal/alarm/time/TimeAlarm.c #: ports/raspberrypi/common-hal/alarm/time/TimeAlarm.c @@ -1890,10 +1900,13 @@ msgid "" msgstr "" #: ports/raspberrypi/common-hal/imagecapture/ParallelImageCapture.c -#: ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c msgid "Pins must be sequential" msgstr "" +#: ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c +msgid "Pins must be sequential GPIO pins" +msgstr "" + #: ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c msgid "Pins must share PWM slice" msgstr "" @@ -3933,6 +3946,7 @@ msgstr "" #: ports/espressif/boards/adafruit_funhouse/mpconfigboard.h #: ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h +#: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h #: ports/espressif/boards/atmegazero_esp32s2/mpconfigboard.h @@ -3951,6 +3965,7 @@ msgstr "" #: ports/espressif/boards/gravitech_cucumber_rs/mpconfigboard.h #: ports/espressif/boards/lilygo_ttgo_t8_s2_st7789/mpconfigboard.h #: ports/espressif/boards/lolin_s2_mini/mpconfigboard.h +#: ports/espressif/boards/microdev_micro_c3/mpconfigboard.h #: ports/espressif/boards/microdev_micro_s2/mpconfigboard.h #: ports/espressif/boards/morpheans_morphesp-240/mpconfigboard.h #: ports/espressif/boards/muselab_nanoesp32_s2_wroom/mpconfigboard.h diff --git a/locale/en_GB.po b/locale/en_GB.po index 96bf006a40..833d375c4a 100644 --- a/locale/en_GB.po +++ b/locale/en_GB.po @@ -174,6 +174,10 @@ msgstr "%q pin invalid" msgid "%q should be an int" msgstr "%q should be an int" +#: shared-bindings/usb_hid/Device.c +msgid "%q with a report ID of 0 must be of length 1" +msgstr "" + #: py/bc.c py/objnamedtuple.c msgid "%q() takes %d positional arguments but %d were given" msgstr "%q() takes %d positional arguments but %d were given" @@ -378,7 +382,9 @@ msgstr "Address type out of range" msgid "All CAN peripherals are in use" msgstr "All CAN peripherals are in use" -#: ports/espressif/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c +#: ports/espressif/common-hal/busio/I2C.c +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c +#: ports/nrf/common-hal/busio/I2C.c msgid "All I2C peripherals are in use" msgstr "All I2C peripherals are in use" @@ -1316,8 +1322,11 @@ msgstr "Invalid PWM frequency" msgid "Invalid Pin" msgstr "Invalid pin" -#: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c -#: py/moduerrno.c shared-module/rgbmatrix/RGBMatrix.c +#: ports/espressif/bindings/espidf/__init__.c +#: ports/espressif/common-hal/busio/I2C.c +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c +#: ports/espressif/esp_error.c py/moduerrno.c +#: shared-module/rgbmatrix/RGBMatrix.c msgid "Invalid argument" msgstr "Invalid argument" @@ -1365,10 +1374,6 @@ msgstr "Invalid file" msgid "Invalid format chunk size" msgstr "Invalid format chunk size" -#: ports/espressif/common-hal/busio/I2C.c -msgid "Invalid frequency" -msgstr "Invalid frequency" - #: supervisor/shared/safe_mode.c msgid "Invalid memory access." msgstr "Invalid memory access." @@ -1409,6 +1414,7 @@ msgstr "Invalid pin for right channel" #: ports/espressif/common-hal/busio/SPI.c #: ports/espressif/common-hal/busio/UART.c #: ports/espressif/common-hal/canio/CAN.c +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c #: ports/mimxrt10xx/common-hal/busio/I2C.c #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/nrf/common-hal/busio/I2C.c #: ports/raspberrypi/common-hal/busio/I2C.c @@ -1790,6 +1796,10 @@ msgstr "" msgid "Only one TouchAlarm can be set in deep sleep." msgstr "Only one TouchAlarm can be set in deep sleep." +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c +msgid "Only one address is allowed" +msgstr "" + #: ports/espressif/common-hal/alarm/time/TimeAlarm.c #: ports/nrf/common-hal/alarm/time/TimeAlarm.c #: ports/raspberrypi/common-hal/alarm/time/TimeAlarm.c @@ -1914,10 +1924,13 @@ msgstr "" "constructor" #: ports/raspberrypi/common-hal/imagecapture/ParallelImageCapture.c -#: ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c msgid "Pins must be sequential" msgstr "Pins must be sequential" +#: ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c +msgid "Pins must be sequential GPIO pins" +msgstr "" + #: ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c msgid "Pins must share PWM slice" msgstr "Pins must share PWM slice" @@ -3975,6 +3988,7 @@ msgstr "pow() with 3 arguments requires integers" #: ports/espressif/boards/adafruit_funhouse/mpconfigboard.h #: ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h +#: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h #: ports/espressif/boards/atmegazero_esp32s2/mpconfigboard.h @@ -3993,6 +4007,7 @@ msgstr "pow() with 3 arguments requires integers" #: ports/espressif/boards/gravitech_cucumber_rs/mpconfigboard.h #: ports/espressif/boards/lilygo_ttgo_t8_s2_st7789/mpconfigboard.h #: ports/espressif/boards/lolin_s2_mini/mpconfigboard.h +#: ports/espressif/boards/microdev_micro_c3/mpconfigboard.h #: ports/espressif/boards/microdev_micro_s2/mpconfigboard.h #: ports/espressif/boards/morpheans_morphesp-240/mpconfigboard.h #: ports/espressif/boards/muselab_nanoesp32_s2_wroom/mpconfigboard.h @@ -4529,6 +4544,9 @@ msgstr "zi must be of float type" msgid "zi must be of shape (n_section, 2)" msgstr "zi must be of shape (n_section, 2)" +#~ msgid "Invalid frequency" +#~ msgstr "Invalid frequency" + #~ msgid "Data 0 pin must be byte aligned." #~ msgstr "Data 0 pin must be byte aligned." diff --git a/locale/es.po b/locale/es.po index 18e0bb309d..84c58bca27 100644 --- a/locale/es.po +++ b/locale/es.po @@ -176,6 +176,10 @@ msgstr "pin inválido %q" msgid "%q should be an int" msgstr "%q debe ser un int" +#: shared-bindings/usb_hid/Device.c +msgid "%q with a report ID of 0 must be of length 1" +msgstr "" + #: py/bc.c py/objnamedtuple.c msgid "%q() takes %d positional arguments but %d were given" msgstr "%q() toma %d argumentos posicionales pero %d fueron dados" @@ -380,7 +384,9 @@ msgstr "Tipo de dirección fuera de rango" msgid "All CAN peripherals are in use" msgstr "Todos los periféricos CAN están en uso" -#: ports/espressif/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c +#: ports/espressif/common-hal/busio/I2C.c +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c +#: ports/nrf/common-hal/busio/I2C.c msgid "All I2C peripherals are in use" msgstr "Todos los periféricos I2C están siendo usados" @@ -1334,8 +1340,11 @@ msgstr "Frecuencia PWM inválida" msgid "Invalid Pin" msgstr "Pin inválido" -#: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c -#: py/moduerrno.c shared-module/rgbmatrix/RGBMatrix.c +#: ports/espressif/bindings/espidf/__init__.c +#: ports/espressif/common-hal/busio/I2C.c +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c +#: ports/espressif/esp_error.c py/moduerrno.c +#: shared-module/rgbmatrix/RGBMatrix.c msgid "Invalid argument" msgstr "Argumento inválido" @@ -1383,10 +1392,6 @@ msgstr "Archivo inválido" msgid "Invalid format chunk size" msgstr "Formato de fragmento de formato no válido" -#: ports/espressif/common-hal/busio/I2C.c -msgid "Invalid frequency" -msgstr "Frecuencia inválida" - #: supervisor/shared/safe_mode.c msgid "Invalid memory access." msgstr "Acceso a memoria no válido." @@ -1427,6 +1432,7 @@ msgstr "Pin inválido para canal derecho" #: ports/espressif/common-hal/busio/SPI.c #: ports/espressif/common-hal/busio/UART.c #: ports/espressif/common-hal/canio/CAN.c +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c #: ports/mimxrt10xx/common-hal/busio/I2C.c #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/nrf/common-hal/busio/I2C.c #: ports/raspberrypi/common-hal/busio/I2C.c @@ -1814,6 +1820,10 @@ msgstr "" msgid "Only one TouchAlarm can be set in deep sleep." msgstr "Solamente una TouchAlarm puede ser configurada durante deep sleep." +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c +msgid "Only one address is allowed" +msgstr "" + #: ports/espressif/common-hal/alarm/time/TimeAlarm.c #: ports/nrf/common-hal/alarm/time/TimeAlarm.c #: ports/raspberrypi/common-hal/alarm/time/TimeAlarm.c @@ -1938,10 +1948,13 @@ msgstr "" "constructor" #: ports/raspberrypi/common-hal/imagecapture/ParallelImageCapture.c -#: ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c msgid "Pins must be sequential" msgstr "Los pines deben estar en orden secuencial" +#: ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c +msgid "Pins must be sequential GPIO pins" +msgstr "" + #: ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c msgid "Pins must share PWM slice" msgstr "Los pines deben compartir la división PWM" @@ -4022,6 +4035,7 @@ msgstr "pow() con 3 argumentos requiere enteros" #: ports/espressif/boards/adafruit_funhouse/mpconfigboard.h #: ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h +#: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h #: ports/espressif/boards/atmegazero_esp32s2/mpconfigboard.h @@ -4040,6 +4054,7 @@ msgstr "pow() con 3 argumentos requiere enteros" #: ports/espressif/boards/gravitech_cucumber_rs/mpconfigboard.h #: ports/espressif/boards/lilygo_ttgo_t8_s2_st7789/mpconfigboard.h #: ports/espressif/boards/lolin_s2_mini/mpconfigboard.h +#: ports/espressif/boards/microdev_micro_c3/mpconfigboard.h #: ports/espressif/boards/microdev_micro_s2/mpconfigboard.h #: ports/espressif/boards/morpheans_morphesp-240/mpconfigboard.h #: ports/espressif/boards/muselab_nanoesp32_s2_wroom/mpconfigboard.h @@ -4577,6 +4592,9 @@ msgstr "zi debe ser de tipo flotante" msgid "zi must be of shape (n_section, 2)" msgstr "zi debe ser una forma (n_section,2)" +#~ msgid "Invalid frequency" +#~ msgstr "Frecuencia inválida" + #~ msgid "Data 0 pin must be byte aligned." #~ msgstr "El pin de datos 0 debe ser alineado a byte." diff --git a/locale/fil.po b/locale/fil.po index 493a79c232..a0f378fb27 100644 --- a/locale/fil.po +++ b/locale/fil.po @@ -168,6 +168,10 @@ msgstr "" msgid "%q should be an int" msgstr "y ay dapat int" +#: shared-bindings/usb_hid/Device.c +msgid "%q with a report ID of 0 must be of length 1" +msgstr "" + #: py/bc.c py/objnamedtuple.c msgid "%q() takes %d positional arguments but %d were given" msgstr "" @@ -373,7 +377,9 @@ msgstr "" msgid "All CAN peripherals are in use" msgstr "" -#: ports/espressif/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c +#: ports/espressif/common-hal/busio/I2C.c +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c +#: ports/nrf/common-hal/busio/I2C.c msgid "All I2C peripherals are in use" msgstr "Lahat ng I2C peripherals ginagamit" @@ -1318,8 +1324,11 @@ msgstr "Mali ang PWM frequency" msgid "Invalid Pin" msgstr "" -#: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c -#: py/moduerrno.c shared-module/rgbmatrix/RGBMatrix.c +#: ports/espressif/bindings/espidf/__init__.c +#: ports/espressif/common-hal/busio/I2C.c +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c +#: ports/espressif/esp_error.c py/moduerrno.c +#: shared-module/rgbmatrix/RGBMatrix.c msgid "Invalid argument" msgstr "Maling argumento" @@ -1367,10 +1376,6 @@ msgstr "Mali ang file" msgid "Invalid format chunk size" msgstr "Mali ang format ng chunk size" -#: ports/espressif/common-hal/busio/I2C.c -msgid "Invalid frequency" -msgstr "" - #: supervisor/shared/safe_mode.c msgid "Invalid memory access." msgstr "" @@ -1411,6 +1416,7 @@ msgstr "Mali ang pin para sa kanang channel" #: ports/espressif/common-hal/busio/SPI.c #: ports/espressif/common-hal/busio/UART.c #: ports/espressif/common-hal/canio/CAN.c +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c #: ports/mimxrt10xx/common-hal/busio/I2C.c #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/nrf/common-hal/busio/I2C.c #: ports/raspberrypi/common-hal/busio/I2C.c @@ -1791,6 +1797,10 @@ msgstr "" msgid "Only one TouchAlarm can be set in deep sleep." msgstr "" +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c +msgid "Only one address is allowed" +msgstr "" + #: ports/espressif/common-hal/alarm/time/TimeAlarm.c #: ports/nrf/common-hal/alarm/time/TimeAlarm.c #: ports/raspberrypi/common-hal/alarm/time/TimeAlarm.c @@ -1911,10 +1921,13 @@ msgid "" msgstr "" #: ports/raspberrypi/common-hal/imagecapture/ParallelImageCapture.c -#: ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c msgid "Pins must be sequential" msgstr "" +#: ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c +msgid "Pins must be sequential GPIO pins" +msgstr "" + #: ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c msgid "Pins must share PWM slice" msgstr "" @@ -3982,6 +3995,7 @@ msgstr "pow() na may 3 argumento kailangan ng integers" #: ports/espressif/boards/adafruit_funhouse/mpconfigboard.h #: ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h +#: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h #: ports/espressif/boards/atmegazero_esp32s2/mpconfigboard.h @@ -4000,6 +4014,7 @@ msgstr "pow() na may 3 argumento kailangan ng integers" #: ports/espressif/boards/gravitech_cucumber_rs/mpconfigboard.h #: ports/espressif/boards/lilygo_ttgo_t8_s2_st7789/mpconfigboard.h #: ports/espressif/boards/lolin_s2_mini/mpconfigboard.h +#: ports/espressif/boards/microdev_micro_c3/mpconfigboard.h #: ports/espressif/boards/microdev_micro_s2/mpconfigboard.h #: ports/espressif/boards/morpheans_morphesp-240/mpconfigboard.h #: ports/espressif/boards/muselab_nanoesp32_s2_wroom/mpconfigboard.h diff --git a/locale/fr.po b/locale/fr.po index 16a67658de..08c6683c59 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -176,6 +176,10 @@ msgstr "broche %q invalide" msgid "%q should be an int" msgstr "%q doit être un chiffre entier (int)" +#: shared-bindings/usb_hid/Device.c +msgid "%q with a report ID of 0 must be of length 1" +msgstr "" + #: py/bc.c py/objnamedtuple.c msgid "%q() takes %d positional arguments but %d were given" msgstr "%q() prend %d paramètres positionnels mais %d ont été donnés" @@ -380,7 +384,9 @@ msgstr "Type d'adresse hors portée" msgid "All CAN peripherals are in use" msgstr "Tous les périphériques CAN sont utilisés" -#: ports/espressif/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c +#: ports/espressif/common-hal/busio/I2C.c +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c +#: ports/nrf/common-hal/busio/I2C.c msgid "All I2C peripherals are in use" msgstr "Tous les périphériques I2C sont utilisés" @@ -1344,8 +1350,11 @@ msgstr "Fréquence de PWM invalide" msgid "Invalid Pin" msgstr "Broche invalide" -#: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c -#: py/moduerrno.c shared-module/rgbmatrix/RGBMatrix.c +#: ports/espressif/bindings/espidf/__init__.c +#: ports/espressif/common-hal/busio/I2C.c +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c +#: ports/espressif/esp_error.c py/moduerrno.c +#: shared-module/rgbmatrix/RGBMatrix.c msgid "Invalid argument" msgstr "Paramètre invalide" @@ -1393,10 +1402,6 @@ msgstr "Fichier invalide" msgid "Invalid format chunk size" msgstr "Taille de bloc de formatage invalide" -#: ports/espressif/common-hal/busio/I2C.c -msgid "Invalid frequency" -msgstr "Fréquence non valide" - #: supervisor/shared/safe_mode.c msgid "Invalid memory access." msgstr "Accès à la mémoire invalide." @@ -1437,6 +1442,7 @@ msgstr "Broche invalide pour le canal droit" #: ports/espressif/common-hal/busio/SPI.c #: ports/espressif/common-hal/busio/UART.c #: ports/espressif/common-hal/canio/CAN.c +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c #: ports/mimxrt10xx/common-hal/busio/I2C.c #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/nrf/common-hal/busio/I2C.c #: ports/raspberrypi/common-hal/busio/I2C.c @@ -1822,6 +1828,10 @@ msgstr "" msgid "Only one TouchAlarm can be set in deep sleep." msgstr "Seulement une TouchAlarm peu être réglée en someil profond." +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c +msgid "Only one address is allowed" +msgstr "" + #: ports/espressif/common-hal/alarm/time/TimeAlarm.c #: ports/nrf/common-hal/alarm/time/TimeAlarm.c #: ports/raspberrypi/common-hal/alarm/time/TimeAlarm.c @@ -1948,10 +1958,13 @@ msgstr "" "= True au constructeur" #: ports/raspberrypi/common-hal/imagecapture/ParallelImageCapture.c -#: ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c msgid "Pins must be sequential" msgstr "Les broches doivent être séquentielles" +#: ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c +msgid "Pins must be sequential GPIO pins" +msgstr "" + #: ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c msgid "Pins must share PWM slice" msgstr "Les broches doivent partager la tranche PWM" @@ -4033,6 +4046,7 @@ msgstr "pow() avec 3 arguments nécessite des entiers" #: ports/espressif/boards/adafruit_funhouse/mpconfigboard.h #: ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h +#: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h #: ports/espressif/boards/atmegazero_esp32s2/mpconfigboard.h @@ -4051,6 +4065,7 @@ msgstr "pow() avec 3 arguments nécessite des entiers" #: ports/espressif/boards/gravitech_cucumber_rs/mpconfigboard.h #: ports/espressif/boards/lilygo_ttgo_t8_s2_st7789/mpconfigboard.h #: ports/espressif/boards/lolin_s2_mini/mpconfigboard.h +#: ports/espressif/boards/microdev_micro_c3/mpconfigboard.h #: ports/espressif/boards/microdev_micro_s2/mpconfigboard.h #: ports/espressif/boards/morpheans_morphesp-240/mpconfigboard.h #: ports/espressif/boards/muselab_nanoesp32_s2_wroom/mpconfigboard.h @@ -4588,6 +4603,9 @@ msgstr "zi doit être de type float" msgid "zi must be of shape (n_section, 2)" msgstr "zi doit être de forme (n_section, 2)" +#~ msgid "Invalid frequency" +#~ msgstr "Fréquence non valide" + #~ msgid "Data 0 pin must be byte aligned." #~ msgstr "La broche Data 0 doit être aligné sur l'octet." diff --git a/locale/hi.po b/locale/hi.po index 3769cdbb7f..547ae61bd8 100644 --- a/locale/hi.po +++ b/locale/hi.po @@ -165,6 +165,10 @@ msgstr "" msgid "%q should be an int" msgstr "" +#: shared-bindings/usb_hid/Device.c +msgid "%q with a report ID of 0 must be of length 1" +msgstr "" + #: py/bc.c py/objnamedtuple.c msgid "%q() takes %d positional arguments but %d were given" msgstr "" @@ -369,7 +373,9 @@ msgstr "" msgid "All CAN peripherals are in use" msgstr "" -#: ports/espressif/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c +#: ports/espressif/common-hal/busio/I2C.c +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c +#: ports/nrf/common-hal/busio/I2C.c msgid "All I2C peripherals are in use" msgstr "" @@ -1301,8 +1307,11 @@ msgstr "" msgid "Invalid Pin" msgstr "" -#: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c -#: py/moduerrno.c shared-module/rgbmatrix/RGBMatrix.c +#: ports/espressif/bindings/espidf/__init__.c +#: ports/espressif/common-hal/busio/I2C.c +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c +#: ports/espressif/esp_error.c py/moduerrno.c +#: shared-module/rgbmatrix/RGBMatrix.c msgid "Invalid argument" msgstr "" @@ -1350,10 +1359,6 @@ msgstr "" msgid "Invalid format chunk size" msgstr "" -#: ports/espressif/common-hal/busio/I2C.c -msgid "Invalid frequency" -msgstr "" - #: supervisor/shared/safe_mode.c msgid "Invalid memory access." msgstr "" @@ -1394,6 +1399,7 @@ msgstr "" #: ports/espressif/common-hal/busio/SPI.c #: ports/espressif/common-hal/busio/UART.c #: ports/espressif/common-hal/canio/CAN.c +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c #: ports/mimxrt10xx/common-hal/busio/I2C.c #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/nrf/common-hal/busio/I2C.c #: ports/raspberrypi/common-hal/busio/I2C.c @@ -1771,6 +1777,10 @@ msgstr "" msgid "Only one TouchAlarm can be set in deep sleep." msgstr "" +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c +msgid "Only one address is allowed" +msgstr "" + #: ports/espressif/common-hal/alarm/time/TimeAlarm.c #: ports/nrf/common-hal/alarm/time/TimeAlarm.c #: ports/raspberrypi/common-hal/alarm/time/TimeAlarm.c @@ -1890,10 +1900,13 @@ msgid "" msgstr "" #: ports/raspberrypi/common-hal/imagecapture/ParallelImageCapture.c -#: ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c msgid "Pins must be sequential" msgstr "" +#: ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c +msgid "Pins must be sequential GPIO pins" +msgstr "" + #: ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c msgid "Pins must share PWM slice" msgstr "" @@ -3933,6 +3946,7 @@ msgstr "" #: ports/espressif/boards/adafruit_funhouse/mpconfigboard.h #: ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h +#: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h #: ports/espressif/boards/atmegazero_esp32s2/mpconfigboard.h @@ -3951,6 +3965,7 @@ msgstr "" #: ports/espressif/boards/gravitech_cucumber_rs/mpconfigboard.h #: ports/espressif/boards/lilygo_ttgo_t8_s2_st7789/mpconfigboard.h #: ports/espressif/boards/lolin_s2_mini/mpconfigboard.h +#: ports/espressif/boards/microdev_micro_c3/mpconfigboard.h #: ports/espressif/boards/microdev_micro_s2/mpconfigboard.h #: ports/espressif/boards/morpheans_morphesp-240/mpconfigboard.h #: ports/espressif/boards/muselab_nanoesp32_s2_wroom/mpconfigboard.h diff --git a/locale/it_IT.po b/locale/it_IT.po index 6d8485747b..c4765eea85 100644 --- a/locale/it_IT.po +++ b/locale/it_IT.po @@ -175,6 +175,10 @@ msgstr "%q pin non valido" msgid "%q should be an int" msgstr "%q dovrebbe essere un int" +#: shared-bindings/usb_hid/Device.c +msgid "%q with a report ID of 0 must be of length 1" +msgstr "" + #: py/bc.c py/objnamedtuple.c msgid "%q() takes %d positional arguments but %d were given" msgstr "%q() prende %d argomenti posizionali ma ne sono stati forniti %d" @@ -380,7 +384,9 @@ msgstr "Tipo di indirizzo fuori intervallo" msgid "All CAN peripherals are in use" msgstr "Tutte le periferiche CAN sono in uso" -#: ports/espressif/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c +#: ports/espressif/common-hal/busio/I2C.c +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c +#: ports/nrf/common-hal/busio/I2C.c msgid "All I2C peripherals are in use" msgstr "Tutte le periferiche I2C sono in uso" @@ -1325,8 +1331,11 @@ msgstr "Frequenza PWM non valida" msgid "Invalid Pin" msgstr "" -#: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c -#: py/moduerrno.c shared-module/rgbmatrix/RGBMatrix.c +#: ports/espressif/bindings/espidf/__init__.c +#: ports/espressif/common-hal/busio/I2C.c +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c +#: ports/espressif/esp_error.c py/moduerrno.c +#: shared-module/rgbmatrix/RGBMatrix.c msgid "Invalid argument" msgstr "Argomento non valido" @@ -1376,10 +1385,6 @@ msgstr "File non valido" msgid "Invalid format chunk size" msgstr "" -#: ports/espressif/common-hal/busio/I2C.c -msgid "Invalid frequency" -msgstr "" - #: supervisor/shared/safe_mode.c msgid "Invalid memory access." msgstr "" @@ -1420,6 +1425,7 @@ msgstr "Pin non valido per il canale destro" #: ports/espressif/common-hal/busio/SPI.c #: ports/espressif/common-hal/busio/UART.c #: ports/espressif/common-hal/canio/CAN.c +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c #: ports/mimxrt10xx/common-hal/busio/I2C.c #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/nrf/common-hal/busio/I2C.c #: ports/raspberrypi/common-hal/busio/I2C.c @@ -1803,6 +1809,10 @@ msgstr "" msgid "Only one TouchAlarm can be set in deep sleep." msgstr "" +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c +msgid "Only one address is allowed" +msgstr "" + #: ports/espressif/common-hal/alarm/time/TimeAlarm.c #: ports/nrf/common-hal/alarm/time/TimeAlarm.c #: ports/raspberrypi/common-hal/alarm/time/TimeAlarm.c @@ -1927,10 +1937,13 @@ msgid "" msgstr "" #: ports/raspberrypi/common-hal/imagecapture/ParallelImageCapture.c -#: ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c msgid "Pins must be sequential" msgstr "" +#: ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c +msgid "Pins must be sequential GPIO pins" +msgstr "" + #: ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c msgid "Pins must share PWM slice" msgstr "" @@ -3998,6 +4011,7 @@ msgstr "pow() con 3 argomenti richiede interi" #: ports/espressif/boards/adafruit_funhouse/mpconfigboard.h #: ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h +#: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h #: ports/espressif/boards/atmegazero_esp32s2/mpconfigboard.h @@ -4016,6 +4030,7 @@ msgstr "pow() con 3 argomenti richiede interi" #: ports/espressif/boards/gravitech_cucumber_rs/mpconfigboard.h #: ports/espressif/boards/lilygo_ttgo_t8_s2_st7789/mpconfigboard.h #: ports/espressif/boards/lolin_s2_mini/mpconfigboard.h +#: ports/espressif/boards/microdev_micro_c3/mpconfigboard.h #: ports/espressif/boards/microdev_micro_s2/mpconfigboard.h #: ports/espressif/boards/morpheans_morphesp-240/mpconfigboard.h #: ports/espressif/boards/muselab_nanoesp32_s2_wroom/mpconfigboard.h diff --git a/locale/ja.po b/locale/ja.po index 4f570cf418..d16f7bcc2e 100644 --- a/locale/ja.po +++ b/locale/ja.po @@ -170,6 +170,10 @@ msgstr "%q ピンは無効" msgid "%q should be an int" msgstr "%qはint型でなければなりません" +#: shared-bindings/usb_hid/Device.c +msgid "%q with a report ID of 0 must be of length 1" +msgstr "" + #: py/bc.c py/objnamedtuple.c msgid "%q() takes %d positional arguments but %d were given" msgstr "%q() は %d 個の位置引数を取りますが、%d 個与えられました" @@ -374,7 +378,9 @@ msgstr "address_typeが範囲外" msgid "All CAN peripherals are in use" msgstr "全てのCAN周辺機器が使用中" -#: ports/espressif/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c +#: ports/espressif/common-hal/busio/I2C.c +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c +#: ports/nrf/common-hal/busio/I2C.c msgid "All I2C peripherals are in use" msgstr "全てのI2C周辺機器が使用中" @@ -1312,8 +1318,11 @@ msgstr "無効なPWM周波数" msgid "Invalid Pin" msgstr "" -#: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c -#: py/moduerrno.c shared-module/rgbmatrix/RGBMatrix.c +#: ports/espressif/bindings/espidf/__init__.c +#: ports/espressif/common-hal/busio/I2C.c +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c +#: ports/espressif/esp_error.c py/moduerrno.c +#: shared-module/rgbmatrix/RGBMatrix.c msgid "Invalid argument" msgstr "不正な引数" @@ -1361,10 +1370,6 @@ msgstr "不正なファイル" msgid "Invalid format chunk size" msgstr "フォーマットチャンクのサイズが不正" -#: ports/espressif/common-hal/busio/I2C.c -msgid "Invalid frequency" -msgstr "不正な周波数" - #: supervisor/shared/safe_mode.c msgid "Invalid memory access." msgstr "不正なメモリアクセス" @@ -1405,6 +1410,7 @@ msgstr "右チャネルのピンが不正" #: ports/espressif/common-hal/busio/SPI.c #: ports/espressif/common-hal/busio/UART.c #: ports/espressif/common-hal/canio/CAN.c +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c #: ports/mimxrt10xx/common-hal/busio/I2C.c #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/nrf/common-hal/busio/I2C.c #: ports/raspberrypi/common-hal/busio/I2C.c @@ -1784,6 +1790,10 @@ msgstr "" msgid "Only one TouchAlarm can be set in deep sleep." msgstr "" +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c +msgid "Only one address is allowed" +msgstr "" + #: ports/espressif/common-hal/alarm/time/TimeAlarm.c #: ports/nrf/common-hal/alarm/time/TimeAlarm.c #: ports/raspberrypi/common-hal/alarm/time/TimeAlarm.c @@ -1904,10 +1914,13 @@ msgid "" msgstr "" #: ports/raspberrypi/common-hal/imagecapture/ParallelImageCapture.c -#: ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c msgid "Pins must be sequential" msgstr "" +#: ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c +msgid "Pins must be sequential GPIO pins" +msgstr "" + #: ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c msgid "Pins must share PWM slice" msgstr "" @@ -3955,6 +3968,7 @@ msgstr "pow()の第3引数には整数が必要" #: ports/espressif/boards/adafruit_funhouse/mpconfigboard.h #: ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h +#: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h #: ports/espressif/boards/atmegazero_esp32s2/mpconfigboard.h @@ -3973,6 +3987,7 @@ msgstr "pow()の第3引数には整数が必要" #: ports/espressif/boards/gravitech_cucumber_rs/mpconfigboard.h #: ports/espressif/boards/lilygo_ttgo_t8_s2_st7789/mpconfigboard.h #: ports/espressif/boards/lolin_s2_mini/mpconfigboard.h +#: ports/espressif/boards/microdev_micro_c3/mpconfigboard.h #: ports/espressif/boards/microdev_micro_s2/mpconfigboard.h #: ports/espressif/boards/morpheans_morphesp-240/mpconfigboard.h #: ports/espressif/boards/muselab_nanoesp32_s2_wroom/mpconfigboard.h @@ -4508,6 +4523,9 @@ msgstr "ziはfloat値でなければなりません" msgid "zi must be of shape (n_section, 2)" msgstr "" +#~ msgid "Invalid frequency" +#~ msgstr "不正な周波数" + #~ msgid "ParallelBus not yet supported" #~ msgstr "ParallelBusにはまだ対応していません" diff --git a/locale/ko.po b/locale/ko.po index 95c6ae5af9..30ff4b20f1 100644 --- a/locale/ko.po +++ b/locale/ko.po @@ -166,6 +166,10 @@ msgstr "" msgid "%q should be an int" msgstr "%q 는 정수(int) 여야합니다" +#: shared-bindings/usb_hid/Device.c +msgid "%q with a report ID of 0 must be of length 1" +msgstr "" + #: py/bc.c py/objnamedtuple.c msgid "%q() takes %d positional arguments but %d were given" msgstr "" @@ -370,7 +374,9 @@ msgstr "" msgid "All CAN peripherals are in use" msgstr "" -#: ports/espressif/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c +#: ports/espressif/common-hal/busio/I2C.c +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c +#: ports/nrf/common-hal/busio/I2C.c msgid "All I2C peripherals are in use" msgstr "사용중인 모든 I2C주변 기기" @@ -1304,8 +1310,11 @@ msgstr "" msgid "Invalid Pin" msgstr "" -#: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c -#: py/moduerrno.c shared-module/rgbmatrix/RGBMatrix.c +#: ports/espressif/bindings/espidf/__init__.c +#: ports/espressif/common-hal/busio/I2C.c +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c +#: ports/espressif/esp_error.c py/moduerrno.c +#: shared-module/rgbmatrix/RGBMatrix.c msgid "Invalid argument" msgstr "" @@ -1353,10 +1362,6 @@ msgstr "파일이 유효하지 않습니다" msgid "Invalid format chunk size" msgstr "형식 청크 크기가 잘못되었습니다" -#: ports/espressif/common-hal/busio/I2C.c -msgid "Invalid frequency" -msgstr "" - #: supervisor/shared/safe_mode.c msgid "Invalid memory access." msgstr "" @@ -1397,6 +1402,7 @@ msgstr "오른쪽 채널 핀이 잘못되었습니다" #: ports/espressif/common-hal/busio/SPI.c #: ports/espressif/common-hal/busio/UART.c #: ports/espressif/common-hal/canio/CAN.c +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c #: ports/mimxrt10xx/common-hal/busio/I2C.c #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/nrf/common-hal/busio/I2C.c #: ports/raspberrypi/common-hal/busio/I2C.c @@ -1774,6 +1780,10 @@ msgstr "" msgid "Only one TouchAlarm can be set in deep sleep." msgstr "" +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c +msgid "Only one address is allowed" +msgstr "" + #: ports/espressif/common-hal/alarm/time/TimeAlarm.c #: ports/nrf/common-hal/alarm/time/TimeAlarm.c #: ports/raspberrypi/common-hal/alarm/time/TimeAlarm.c @@ -1893,10 +1903,13 @@ msgid "" msgstr "" #: ports/raspberrypi/common-hal/imagecapture/ParallelImageCapture.c -#: ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c msgid "Pins must be sequential" msgstr "" +#: ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c +msgid "Pins must be sequential GPIO pins" +msgstr "" + #: ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c msgid "Pins must share PWM slice" msgstr "" @@ -3937,6 +3950,7 @@ msgstr "" #: ports/espressif/boards/adafruit_funhouse/mpconfigboard.h #: ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h +#: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h #: ports/espressif/boards/atmegazero_esp32s2/mpconfigboard.h @@ -3955,6 +3969,7 @@ msgstr "" #: ports/espressif/boards/gravitech_cucumber_rs/mpconfigboard.h #: ports/espressif/boards/lilygo_ttgo_t8_s2_st7789/mpconfigboard.h #: ports/espressif/boards/lolin_s2_mini/mpconfigboard.h +#: ports/espressif/boards/microdev_micro_c3/mpconfigboard.h #: ports/espressif/boards/microdev_micro_s2/mpconfigboard.h #: ports/espressif/boards/morpheans_morphesp-240/mpconfigboard.h #: ports/espressif/boards/muselab_nanoesp32_s2_wroom/mpconfigboard.h diff --git a/locale/nl.po b/locale/nl.po index b9b4d9ab1e..682a9dd9b6 100644 --- a/locale/nl.po +++ b/locale/nl.po @@ -168,6 +168,10 @@ msgstr "%q pin onjuist" msgid "%q should be an int" msgstr "%q moet een int zijn" +#: shared-bindings/usb_hid/Device.c +msgid "%q with a report ID of 0 must be of length 1" +msgstr "" + #: py/bc.c py/objnamedtuple.c msgid "%q() takes %d positional arguments but %d were given" msgstr "%q() verwacht %d positionele argumenten maar kreeg %d" @@ -372,7 +376,9 @@ msgstr "Adres type buiten bereik" msgid "All CAN peripherals are in use" msgstr "Alle CAN-peripherals zijn in gebruik" -#: ports/espressif/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c +#: ports/espressif/common-hal/busio/I2C.c +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c +#: ports/nrf/common-hal/busio/I2C.c msgid "All I2C peripherals are in use" msgstr "Alle I2C peripherals zijn in gebruik" @@ -1313,8 +1319,11 @@ msgstr "Ongeldige PWM frequentie" msgid "Invalid Pin" msgstr "Ongeldige Pin" -#: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c -#: py/moduerrno.c shared-module/rgbmatrix/RGBMatrix.c +#: ports/espressif/bindings/espidf/__init__.c +#: ports/espressif/common-hal/busio/I2C.c +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c +#: ports/espressif/esp_error.c py/moduerrno.c +#: shared-module/rgbmatrix/RGBMatrix.c msgid "Invalid argument" msgstr "Ongeldig argument" @@ -1362,10 +1371,6 @@ msgstr "Ongeldig bestand" msgid "Invalid format chunk size" msgstr "Ongeldig formaat stuk grootte" -#: ports/espressif/common-hal/busio/I2C.c -msgid "Invalid frequency" -msgstr "Onjuiste frequentie" - #: supervisor/shared/safe_mode.c msgid "Invalid memory access." msgstr "Ongeldig geheugen adres." @@ -1406,6 +1411,7 @@ msgstr "Ongeldige pin voor rechter kanaal" #: ports/espressif/common-hal/busio/SPI.c #: ports/espressif/common-hal/busio/UART.c #: ports/espressif/common-hal/canio/CAN.c +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c #: ports/mimxrt10xx/common-hal/busio/I2C.c #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/nrf/common-hal/busio/I2C.c #: ports/raspberrypi/common-hal/busio/I2C.c @@ -1789,6 +1795,10 @@ msgstr "" msgid "Only one TouchAlarm can be set in deep sleep." msgstr "" +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c +msgid "Only one address is allowed" +msgstr "" + #: ports/espressif/common-hal/alarm/time/TimeAlarm.c #: ports/nrf/common-hal/alarm/time/TimeAlarm.c #: ports/raspberrypi/common-hal/alarm/time/TimeAlarm.c @@ -1914,10 +1924,13 @@ msgstr "" "allow_inefficient=True aan de constructor" #: ports/raspberrypi/common-hal/imagecapture/ParallelImageCapture.c -#: ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c msgid "Pins must be sequential" msgstr "" +#: ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c +msgid "Pins must be sequential GPIO pins" +msgstr "" + #: ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c msgid "Pins must share PWM slice" msgstr "" @@ -3979,6 +3992,7 @@ msgstr "pow() met 3 argumenten vereist integers" #: ports/espressif/boards/adafruit_funhouse/mpconfigboard.h #: ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h +#: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h #: ports/espressif/boards/atmegazero_esp32s2/mpconfigboard.h @@ -3997,6 +4011,7 @@ msgstr "pow() met 3 argumenten vereist integers" #: ports/espressif/boards/gravitech_cucumber_rs/mpconfigboard.h #: ports/espressif/boards/lilygo_ttgo_t8_s2_st7789/mpconfigboard.h #: ports/espressif/boards/lolin_s2_mini/mpconfigboard.h +#: ports/espressif/boards/microdev_micro_c3/mpconfigboard.h #: ports/espressif/boards/microdev_micro_s2/mpconfigboard.h #: ports/espressif/boards/morpheans_morphesp-240/mpconfigboard.h #: ports/espressif/boards/muselab_nanoesp32_s2_wroom/mpconfigboard.h @@ -4533,6 +4548,9 @@ msgstr "zi moet van type float zijn" msgid "zi must be of shape (n_section, 2)" msgstr "zi moet vorm (n_section, 2) hebben" +#~ msgid "Invalid frequency" +#~ msgstr "Onjuiste frequentie" + #~ msgid "ParallelBus not yet supported" #~ msgstr "ParallelBus nog niet ondersteund" diff --git a/locale/pl.po b/locale/pl.po index 6e548d79df..4ac976018f 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -170,6 +170,10 @@ msgstr "nieprawidłowy pin %q" msgid "%q should be an int" msgstr "%q powinno być typu int" +#: shared-bindings/usb_hid/Device.c +msgid "%q with a report ID of 0 must be of length 1" +msgstr "" + #: py/bc.c py/objnamedtuple.c msgid "%q() takes %d positional arguments but %d were given" msgstr "%q() bierze %d argumentów pozycyjnych, lecz podano %d" @@ -374,7 +378,9 @@ msgstr "Typ adresu poza zakresem" msgid "All CAN peripherals are in use" msgstr "" -#: ports/espressif/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c +#: ports/espressif/common-hal/busio/I2C.c +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c +#: ports/nrf/common-hal/busio/I2C.c msgid "All I2C peripherals are in use" msgstr "Wszystkie peryferia I2C w użyciu" @@ -1312,8 +1318,11 @@ msgstr "Zła częstotliwość PWM" msgid "Invalid Pin" msgstr "" -#: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c -#: py/moduerrno.c shared-module/rgbmatrix/RGBMatrix.c +#: ports/espressif/bindings/espidf/__init__.c +#: ports/espressif/common-hal/busio/I2C.c +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c +#: ports/espressif/esp_error.c py/moduerrno.c +#: shared-module/rgbmatrix/RGBMatrix.c msgid "Invalid argument" msgstr "Zły argument" @@ -1361,10 +1370,6 @@ msgstr "Zły plik" msgid "Invalid format chunk size" msgstr "Zła wielkość fragmentu formatu" -#: ports/espressif/common-hal/busio/I2C.c -msgid "Invalid frequency" -msgstr "Nieprawidłowa częstotliwość" - #: supervisor/shared/safe_mode.c msgid "Invalid memory access." msgstr "Nieprawidłowy dostęp do pamięci." @@ -1405,6 +1410,7 @@ msgstr "Zła nóżka dla prawego kanału" #: ports/espressif/common-hal/busio/SPI.c #: ports/espressif/common-hal/busio/UART.c #: ports/espressif/common-hal/canio/CAN.c +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c #: ports/mimxrt10xx/common-hal/busio/I2C.c #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/nrf/common-hal/busio/I2C.c #: ports/raspberrypi/common-hal/busio/I2C.c @@ -1782,6 +1788,10 @@ msgstr "" msgid "Only one TouchAlarm can be set in deep sleep." msgstr "" +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c +msgid "Only one address is allowed" +msgstr "" + #: ports/espressif/common-hal/alarm/time/TimeAlarm.c #: ports/nrf/common-hal/alarm/time/TimeAlarm.c #: ports/raspberrypi/common-hal/alarm/time/TimeAlarm.c @@ -1901,10 +1911,13 @@ msgid "" msgstr "" #: ports/raspberrypi/common-hal/imagecapture/ParallelImageCapture.c -#: ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c msgid "Pins must be sequential" msgstr "" +#: ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c +msgid "Pins must be sequential GPIO pins" +msgstr "" + #: ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c msgid "Pins must share PWM slice" msgstr "" @@ -3952,6 +3965,7 @@ msgstr "trzyargumentowe pow() wymaga liczb całkowitych" #: ports/espressif/boards/adafruit_funhouse/mpconfigboard.h #: ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h +#: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h #: ports/espressif/boards/atmegazero_esp32s2/mpconfigboard.h @@ -3970,6 +3984,7 @@ msgstr "trzyargumentowe pow() wymaga liczb całkowitych" #: ports/espressif/boards/gravitech_cucumber_rs/mpconfigboard.h #: ports/espressif/boards/lilygo_ttgo_t8_s2_st7789/mpconfigboard.h #: ports/espressif/boards/lolin_s2_mini/mpconfigboard.h +#: ports/espressif/boards/microdev_micro_c3/mpconfigboard.h #: ports/espressif/boards/microdev_micro_s2/mpconfigboard.h #: ports/espressif/boards/morpheans_morphesp-240/mpconfigboard.h #: ports/espressif/boards/muselab_nanoesp32_s2_wroom/mpconfigboard.h @@ -4505,6 +4520,9 @@ msgstr "" msgid "zi must be of shape (n_section, 2)" msgstr "" +#~ msgid "Invalid frequency" +#~ msgstr "Nieprawidłowa częstotliwość" + #~ msgid "ParallelBus not yet supported" #~ msgstr "ParallelBus nie jest jeszcze obsługiwany" diff --git a/locale/pt_BR.po b/locale/pt_BR.po index 1d7b4fc0fc..d914f773d3 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -6,7 +6,7 @@ msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-01-04 12:55-0600\n" -"PO-Revision-Date: 2021-09-24 01:40+0000\n" +"PO-Revision-Date: 2021-10-08 16:30+0000\n" "Last-Translator: Wellington Terumi Uemura \n" "Language-Team: \n" "Language: pt_BR\n" @@ -174,6 +174,10 @@ msgstr "%q pino inválido" msgid "%q should be an int" msgstr "%q deve ser um int" +#: shared-bindings/usb_hid/Device.c +msgid "%q with a report ID of 0 must be of length 1" +msgstr "%q com um relatório com ID de 0 deve ter comprimento 1" + #: py/bc.c py/objnamedtuple.c msgid "%q() takes %d positional arguments but %d were given" msgstr "%q() recebe %d argumentos posicionais, porém %d foram informados" @@ -382,7 +386,9 @@ msgstr "O tipo do endereço está fora do alcance" msgid "All CAN peripherals are in use" msgstr "Todos os periféricos CAN estão em uso" -#: ports/espressif/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c +#: ports/espressif/common-hal/busio/I2C.c +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c +#: ports/nrf/common-hal/busio/I2C.c msgid "All I2C peripherals are in use" msgstr "Todos os periféricos I2C estão em uso" @@ -1335,8 +1341,11 @@ msgstr "Frequência PWM inválida" msgid "Invalid Pin" msgstr "Pino inválido" -#: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c -#: py/moduerrno.c shared-module/rgbmatrix/RGBMatrix.c +#: ports/espressif/bindings/espidf/__init__.c +#: ports/espressif/common-hal/busio/I2C.c +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c +#: ports/espressif/esp_error.c py/moduerrno.c +#: shared-module/rgbmatrix/RGBMatrix.c msgid "Invalid argument" msgstr "Argumento inválido" @@ -1384,10 +1393,6 @@ msgstr "Arquivo inválido" msgid "Invalid format chunk size" msgstr "Tamanho do pedaço de formato inválido" -#: ports/espressif/common-hal/busio/I2C.c -msgid "Invalid frequency" -msgstr "Frequência inválida" - #: supervisor/shared/safe_mode.c msgid "Invalid memory access." msgstr "O acesso da memória é inválido." @@ -1428,6 +1433,7 @@ msgstr "Pino inválido para canal direito" #: ports/espressif/common-hal/busio/SPI.c #: ports/espressif/common-hal/busio/UART.c #: ports/espressif/common-hal/canio/CAN.c +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c #: ports/mimxrt10xx/common-hal/busio/I2C.c #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/nrf/common-hal/busio/I2C.c #: ports/raspberrypi/common-hal/busio/I2C.c @@ -1812,6 +1818,10 @@ msgstr "" msgid "Only one TouchAlarm can be set in deep sleep." msgstr "Apenas um TouchAlarm pode ser colocado em deep sleep." +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c +msgid "Only one address is allowed" +msgstr "Apenas um endereço é permitido" + #: ports/espressif/common-hal/alarm/time/TimeAlarm.c #: ports/nrf/common-hal/alarm/time/TimeAlarm.c #: ports/raspberrypi/common-hal/alarm/time/TimeAlarm.c @@ -1938,10 +1948,13 @@ msgstr "" "construtor" #: ports/raspberrypi/common-hal/imagecapture/ParallelImageCapture.c -#: ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c msgid "Pins must be sequential" msgstr "Os pinos devem ser sequenciais" +#: ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c +msgid "Pins must be sequential GPIO pins" +msgstr "Pinos devem ser pinos GPIO sequenciais" + #: ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c msgid "Pins must share PWM slice" msgstr "Os pinos devem compartilhar a fatia do PWM" @@ -4035,6 +4048,7 @@ msgstr "o pow() com 3 argumentos requer números inteiros" #: ports/espressif/boards/adafruit_funhouse/mpconfigboard.h #: ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h +#: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h #: ports/espressif/boards/atmegazero_esp32s2/mpconfigboard.h @@ -4053,6 +4067,7 @@ msgstr "o pow() com 3 argumentos requer números inteiros" #: ports/espressif/boards/gravitech_cucumber_rs/mpconfigboard.h #: ports/espressif/boards/lilygo_ttgo_t8_s2_st7789/mpconfigboard.h #: ports/espressif/boards/lolin_s2_mini/mpconfigboard.h +#: ports/espressif/boards/microdev_micro_c3/mpconfigboard.h #: ports/espressif/boards/microdev_micro_s2/mpconfigboard.h #: ports/espressif/boards/morpheans_morphesp-240/mpconfigboard.h #: ports/espressif/boards/muselab_nanoesp32_s2_wroom/mpconfigboard.h @@ -4589,6 +4604,9 @@ msgstr "zi deve ser de um tipo float" msgid "zi must be of shape (n_section, 2)" msgstr "zi deve estar na forma (n_section, 2)" +#~ msgid "Invalid frequency" +#~ msgstr "Frequência inválida" + #~ msgid "Data 0 pin must be byte aligned." #~ msgstr "O pino de dados 0 deve ser alinhado por bytes." diff --git a/locale/sv.po b/locale/sv.po index a1564433e6..5eb124d035 100644 --- a/locale/sv.po +++ b/locale/sv.po @@ -6,7 +6,7 @@ msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2021-01-04 12:55-0600\n" -"PO-Revision-Date: 2021-09-25 07:37+0000\n" +"PO-Revision-Date: 2021-10-08 16:52+0000\n" "Last-Translator: Jonny Bergdahl \n" "Language-Team: LANGUAGE \n" "Language: sv\n" @@ -173,6 +173,10 @@ msgstr "Pinne %q ogiltig" msgid "%q should be an int" msgstr "%q ska vara en int" +#: shared-bindings/usb_hid/Device.c +msgid "%q with a report ID of 0 must be of length 1" +msgstr "%q med report-ID 0 måste ha längd 1" + #: py/bc.c py/objnamedtuple.c msgid "%q() takes %d positional arguments but %d were given" msgstr "% q() tar %d positionsargument men %d gavs" @@ -377,7 +381,9 @@ msgstr "Adresstyp utanför intervallet" msgid "All CAN peripherals are in use" msgstr "All I2C-kringutrustning används" -#: ports/espressif/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c +#: ports/espressif/common-hal/busio/I2C.c +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c +#: ports/nrf/common-hal/busio/I2C.c msgid "All I2C peripherals are in use" msgstr "All I2C-kringutrustning används" @@ -1320,8 +1326,11 @@ msgstr "Ogiltig PWM-frekvens" msgid "Invalid Pin" msgstr "Ogiltig pinne" -#: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c -#: py/moduerrno.c shared-module/rgbmatrix/RGBMatrix.c +#: ports/espressif/bindings/espidf/__init__.c +#: ports/espressif/common-hal/busio/I2C.c +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c +#: ports/espressif/esp_error.c py/moduerrno.c +#: shared-module/rgbmatrix/RGBMatrix.c msgid "Invalid argument" msgstr "Ogiltigt argument" @@ -1369,10 +1378,6 @@ msgstr "Felaktig fil" msgid "Invalid format chunk size" msgstr "Ogiltig formatsegmentstorlek" -#: ports/espressif/common-hal/busio/I2C.c -msgid "Invalid frequency" -msgstr "Ogiltig frekvens" - #: supervisor/shared/safe_mode.c msgid "Invalid memory access." msgstr "Ogiltig minnesåtkomst." @@ -1413,6 +1418,7 @@ msgstr "Ogiltig pinne för höger kanal" #: ports/espressif/common-hal/busio/SPI.c #: ports/espressif/common-hal/busio/UART.c #: ports/espressif/common-hal/canio/CAN.c +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c #: ports/mimxrt10xx/common-hal/busio/I2C.c #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/nrf/common-hal/busio/I2C.c #: ports/raspberrypi/common-hal/busio/I2C.c @@ -1796,6 +1802,10 @@ msgstr "" msgid "Only one TouchAlarm can be set in deep sleep." msgstr "Endast ett TouchAlarm kan ställas in för djupsömn." +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c +msgid "Only one address is allowed" +msgstr "Endast en adress är tillåten" + #: ports/espressif/common-hal/alarm/time/TimeAlarm.c #: ports/nrf/common-hal/alarm/time/TimeAlarm.c #: ports/raspberrypi/common-hal/alarm/time/TimeAlarm.c @@ -1920,10 +1930,13 @@ msgstr "" "konstruktorn" #: ports/raspberrypi/common-hal/imagecapture/ParallelImageCapture.c -#: ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c msgid "Pins must be sequential" msgstr "Pinnarna måste vara i sekvens" +#: ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c +msgid "Pins must be sequential GPIO pins" +msgstr "Pins måste vara sekventiella GPIO-pinnar" + #: ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c msgid "Pins must share PWM slice" msgstr "Pinnar måste dela PWM-segment" @@ -3994,6 +4007,7 @@ msgstr "pow() med 3 argument kräver heltal" #: ports/espressif/boards/adafruit_funhouse/mpconfigboard.h #: ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h +#: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h #: ports/espressif/boards/atmegazero_esp32s2/mpconfigboard.h @@ -4012,6 +4026,7 @@ msgstr "pow() med 3 argument kräver heltal" #: ports/espressif/boards/gravitech_cucumber_rs/mpconfigboard.h #: ports/espressif/boards/lilygo_ttgo_t8_s2_st7789/mpconfigboard.h #: ports/espressif/boards/lolin_s2_mini/mpconfigboard.h +#: ports/espressif/boards/microdev_micro_c3/mpconfigboard.h #: ports/espressif/boards/microdev_micro_s2/mpconfigboard.h #: ports/espressif/boards/morpheans_morphesp-240/mpconfigboard.h #: ports/espressif/boards/muselab_nanoesp32_s2_wroom/mpconfigboard.h @@ -4548,6 +4563,9 @@ msgstr "zi måste vara av typ float" msgid "zi must be of shape (n_section, 2)" msgstr "zi måste vara i formen (n_section, 2)" +#~ msgid "Invalid frequency" +#~ msgstr "Ogiltig frekvens" + #~ msgid "Data 0 pin must be byte aligned." #~ msgstr "Datapinne 0 måste vara byte-justerad." diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index 64a2f9dbf7..ac5607f822 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -175,6 +175,10 @@ msgstr "%q yǐn jiǎo wúxiào" msgid "%q should be an int" msgstr "%q yīnggāi shì yīgè int" +#: shared-bindings/usb_hid/Device.c +msgid "%q with a report ID of 0 must be of length 1" +msgstr "" + #: py/bc.c py/objnamedtuple.c msgid "%q() takes %d positional arguments but %d were given" msgstr "%q() cǎiyòng %d wèizhì cānshù, dàn gěi chū %d" @@ -379,7 +383,9 @@ msgstr "Dìzhǐ lèixíng chāochū fànwéi" msgid "All CAN peripherals are in use" msgstr "suǒ yǒu CAN wài shè dōu zài shǐ yòng zhōng" -#: ports/espressif/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c +#: ports/espressif/common-hal/busio/I2C.c +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c +#: ports/nrf/common-hal/busio/I2C.c msgid "All I2C peripherals are in use" msgstr "Suǒyǒu I2C wàiwéi qì zhèngzài shǐyòng" @@ -1323,8 +1329,11 @@ msgstr "Wúxiào de PWM pínlǜ" msgid "Invalid Pin" msgstr "wú xiào yǐn jiǎo" -#: ports/espressif/bindings/espidf/__init__.c ports/espressif/esp_error.c -#: py/moduerrno.c shared-module/rgbmatrix/RGBMatrix.c +#: ports/espressif/bindings/espidf/__init__.c +#: ports/espressif/common-hal/busio/I2C.c +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c +#: ports/espressif/esp_error.c py/moduerrno.c +#: shared-module/rgbmatrix/RGBMatrix.c msgid "Invalid argument" msgstr "Wúxiào de cānshù" @@ -1372,10 +1381,6 @@ msgstr "Wúxiào de wénjiàn" msgid "Invalid format chunk size" msgstr "Géshì kuài dàxiǎo wúxiào" -#: ports/espressif/common-hal/busio/I2C.c -msgid "Invalid frequency" -msgstr "Wúxiào de pínlǜ" - #: supervisor/shared/safe_mode.c msgid "Invalid memory access." msgstr "Wúxiào de nèicún fǎngwèn." @@ -1416,6 +1421,7 @@ msgstr "Yòuxián tōngdào yǐn jiǎo wúxiào" #: ports/espressif/common-hal/busio/SPI.c #: ports/espressif/common-hal/busio/UART.c #: ports/espressif/common-hal/canio/CAN.c +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c #: ports/mimxrt10xx/common-hal/busio/I2C.c #: ports/mimxrt10xx/common-hal/busio/SPI.c ports/nrf/common-hal/busio/I2C.c #: ports/raspberrypi/common-hal/busio/I2C.c @@ -1799,6 +1805,10 @@ msgstr "" msgid "Only one TouchAlarm can be set in deep sleep." msgstr "zhǐ yǒu yí gè chù mō bì kě yǐ shè zhì zài shēn dù shuì mián." +#: ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c +msgid "Only one address is allowed" +msgstr "" + #: ports/espressif/common-hal/alarm/time/TimeAlarm.c #: ports/nrf/common-hal/alarm/time/TimeAlarm.c #: ports/raspberrypi/common-hal/alarm/time/TimeAlarm.c @@ -1922,10 +1932,13 @@ msgstr "" "gěigòuzào hánshù" #: ports/raspberrypi/common-hal/imagecapture/ParallelImageCapture.c -#: ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c msgid "Pins must be sequential" msgstr "yǐn jiǎo bì xū shì lián xù de" +#: ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c +msgid "Pins must be sequential GPIO pins" +msgstr "" + #: ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c msgid "Pins must share PWM slice" msgstr "yǐn jiǎo bì xū gòng xiǎng PWM qiē piàn" @@ -3994,6 +4007,7 @@ msgstr "pow() yǒu 3 cānshù xūyào zhěngshù" #: ports/espressif/boards/adafruit_funhouse/mpconfigboard.h #: ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h #: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h +#: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h #: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h #: ports/espressif/boards/artisense_rd00/mpconfigboard.h #: ports/espressif/boards/atmegazero_esp32s2/mpconfigboard.h @@ -4012,6 +4026,7 @@ msgstr "pow() yǒu 3 cānshù xūyào zhěngshù" #: ports/espressif/boards/gravitech_cucumber_rs/mpconfigboard.h #: ports/espressif/boards/lilygo_ttgo_t8_s2_st7789/mpconfigboard.h #: ports/espressif/boards/lolin_s2_mini/mpconfigboard.h +#: ports/espressif/boards/microdev_micro_c3/mpconfigboard.h #: ports/espressif/boards/microdev_micro_s2/mpconfigboard.h #: ports/espressif/boards/morpheans_morphesp-240/mpconfigboard.h #: ports/espressif/boards/muselab_nanoesp32_s2_wroom/mpconfigboard.h @@ -4548,6 +4563,9 @@ msgstr "zi bìxū wèi fú diǎn xíng" msgid "zi must be of shape (n_section, 2)" msgstr "zi bìxū jùyǒu xíngzhuàng (n_section,2)" +#~ msgid "Invalid frequency" +#~ msgstr "Wúxiào de pínlǜ" + #~ msgid "Data 0 pin must be byte aligned." #~ msgstr "shù jù 0 yǐn jiǎo bì xū àn zì jié duì qí." diff --git a/ports/atmel-samd/bindings/samd/__init__.c b/ports/atmel-samd/bindings/samd/__init__.c index 207a6d52e6..b5c618108d 100644 --- a/ports/atmel-samd/bindings/samd/__init__.c +++ b/ports/atmel-samd/bindings/samd/__init__.c @@ -57,3 +57,5 @@ const mp_obj_module_t samd_module = { .base = { &mp_type_module }, .globals = (mp_obj_dict_t *)&samd_module_globals, }; + +MP_REGISTER_MODULE(MP_QSTR_samd, samd_module, CIRCUITPY_SAMD); diff --git a/ports/atmel-samd/boards/seeeduino_xiao_kb/board.c b/ports/atmel-samd/boards/seeeduino_xiao_kb/board.c new file mode 100644 index 0000000000..7af05ba45a --- /dev/null +++ b/ports/atmel-samd/boards/seeeduino_xiao_kb/board.c @@ -0,0 +1,39 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "supervisor/board.h" +#include "mpconfigboard.h" +#include "hal/include/hal_gpio.h" + +void board_init(void) { +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { +} diff --git a/ports/atmel-samd/boards/seeeduino_xiao_kb/mpconfigboard.h b/ports/atmel-samd/boards/seeeduino_xiao_kb/mpconfigboard.h new file mode 100644 index 0000000000..85a3ec36c0 --- /dev/null +++ b/ports/atmel-samd/boards/seeeduino_xiao_kb/mpconfigboard.h @@ -0,0 +1,7 @@ +#define MICROPY_HW_BOARD_NAME "Seeeduino XIAO KB" +#define MICROPY_HW_MCU_NAME "samd21g18" + + +// USB is always used internally so skip the pin objects for it. +#define IGNORE_PIN_PA24 1 +#define IGNORE_PIN_PA25 1 diff --git a/ports/atmel-samd/boards/seeeduino_xiao_kb/mpconfigboard.mk b/ports/atmel-samd/boards/seeeduino_xiao_kb/mpconfigboard.mk new file mode 100644 index 0000000000..7a67048e0b --- /dev/null +++ b/ports/atmel-samd/boards/seeeduino_xiao_kb/mpconfigboard.mk @@ -0,0 +1,35 @@ +USB_VID = 0x2886 +USB_PID = 0x802F +# VID & PID Provided by Seeed +USB_PRODUCT = "Seeeduino XIAO KB" +USB_MANUFACTURER = "Seeed" + +CHIP_VARIANT = SAMD21G18A +CHIP_FAMILY = samd21 + +INTERNAL_FLASH_FILESYSTEM = 1 +LONGINT_IMPL = NONE +CIRCUITPY_FULL_BUILD = 0 + +# A number of modules are removed +# Many I/O functions are not available or not used in a keyboard +# CIRCUITPY_ANALOGIO = 1 # Needed for potentiometer input (mouse) +CIRCUITPY_AUDIOCORE = 0 +CIRCUITPY_BUSIO = 0 # Needed for I2C, SPI and UART - removed that for keyboards... +CIRCUITPY_PULSEIO = 0 +# CIRCUITPY_PWMIO = 1 # only needed for speaker or LED PWM functions. Takes 2314 bytes. +CIRCUITPY_RTC = 0 +CIRCUITPY_MATH = 0 +#CIRCUITPY_RANDOM = 0 +CIRCUITPY_ONEWIREIO = 0 +#CIRCUITPY_NEOPIXEL_WRITE = 1 # Needed fo RGB LEDs +#CIRCUITPY_RAINBOWIO = 1 # Needed fo RGB LEDs +# These are used in a keyboard or computer input device. +CIRCUITPY_ROTARYIO = 1 +CIRCUITPY_KEYPAD = 1 +CIRCUITPY_USB_HID = 1 +CIRCUITPY_USB_MIDI = 1 + +# Include these Python libraries in firmware. +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_HID +FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel diff --git a/ports/atmel-samd/boards/seeeduino_xiao_kb/pins.c b/ports/atmel-samd/boards/seeeduino_xiao_kb/pins.c new file mode 100644 index 0000000000..e2c10330a9 --- /dev/null +++ b/ports/atmel-samd/boards/seeeduino_xiao_kb/pins.c @@ -0,0 +1,38 @@ +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_global_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_board_id), MP_ROM_PTR(&board_module_id_obj) }, + + // Analog pins + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA02) }, + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PA04) }, + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PA10) }, + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PA11) }, + { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PA08) }, + { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_PA09) }, + { MP_ROM_QSTR(MP_QSTR_A6), MP_ROM_PTR(&pin_PB08) }, + { MP_ROM_QSTR(MP_QSTR_A7), MP_ROM_PTR(&pin_PB09) }, + { MP_ROM_QSTR(MP_QSTR_A8), MP_ROM_PTR(&pin_PA07) }, + { MP_ROM_QSTR(MP_QSTR_A9), MP_ROM_PTR(&pin_PA05) }, + { MP_ROM_QSTR(MP_QSTR_A10), MP_ROM_PTR(&pin_PA06) }, + + // Digital pins + { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_PA02) }, + { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_PA04) }, + { MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_PA10) }, + { MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_PA11) }, + { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_PA08) }, + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_PA09) }, + { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PB08) }, + { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_PB09) }, + { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_PA07) }, + { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_PA05) }, + { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PA06) }, + { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_PA17) }, + + // LED pins + { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_PA17) }, // status + { MP_ROM_QSTR(MP_QSTR_BLUE_LED), MP_ROM_PTR(&pin_PA17) }, + +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table); diff --git a/ports/atmel-samd/common-hal/analogio/AnalogOut.c b/ports/atmel-samd/common-hal/analogio/AnalogOut.c index 1fa67dc9a1..91782387b8 100644 --- a/ports/atmel-samd/common-hal/analogio/AnalogOut.c +++ b/ports/atmel-samd/common-hal/analogio/AnalogOut.c @@ -85,8 +85,8 @@ void common_hal_analogio_analogout_construct(analogio_analogout_obj_t *self, _pm_enable_bus_clock(PM_BUS_APBC, DAC); #endif - // SAMD21: This clock should be <= 12 MHz, per datasheet section 47.6.3. - // SAMD51: This clock should be <= 350kHz, per datasheet table 37-6. + // SAMD21: This clock should be <= 350 kHz, per datasheet table 36-7. + // SAMD51: This clock should be <= 12 MHz, per datasheet section 47.6.3. _gclk_enable_channel(DAC_GCLK_ID, CONF_GCLK_DAC_SRC); // Don't double init the DAC on the SAMD51 when both outputs are in use. We use the free state diff --git a/ports/atmel-samd/common-hal/microcontroller/Pin.c b/ports/atmel-samd/common-hal/microcontroller/Pin.c index 41cfff763e..1460ece59e 100644 --- a/ports/atmel-samd/common-hal/microcontroller/Pin.c +++ b/ports/atmel-samd/common-hal/microcontroller/Pin.c @@ -52,7 +52,9 @@ void reset_all_pins(void) { uint32_t pin_mask[PORT_COUNT] = PORT_OUT_IMPLEMENTED; // Do not full reset USB lines. + #if CIRCUITPY_USB pin_mask[0] &= ~(PORT_PA24 | PORT_PA25); + #endif // Do not reset SWD when a debugger is present. if (DSU->STATUSB.bit.DBGPRES == 1) { diff --git a/ports/espressif/Makefile b/ports/espressif/Makefile index b2f350c7c7..c26f2ebffb 100644 --- a/ports/espressif/Makefile +++ b/ports/espressif/Makefile @@ -219,6 +219,7 @@ SRC_C += \ boards/$(BOARD)/pins.c \ modules/$(CIRCUITPY_MODULE).c \ lib/netutils/netutils.c \ + peripherals/i2c.c \ peripherals/rmt.c \ peripherals/timer.c \ peripherals/$(IDF_TARGET)/pins.c diff --git a/ports/espressif/bindings/espidf/__init__.c b/ports/espressif/bindings/espidf/__init__.c index c7d5768cd3..9076294d53 100644 --- a/ports/espressif/bindings/espidf/__init__.c +++ b/ports/espressif/bindings/espidf/__init__.c @@ -208,3 +208,5 @@ void raise_esp_error(esp_err_t err) { } mp_raise_msg_varg(exception_type, translate("%s error 0x%x"), group, err); } + +MP_REGISTER_MODULE(MP_QSTR_espidf, espidf_module, CIRCUITPY_ESPIDF); diff --git a/ports/espressif/boards/ai_thinker_esp32-c3s/board.c b/ports/espressif/boards/ai_thinker_esp32-c3s/board.c new file mode 100644 index 0000000000..3d392892e3 --- /dev/null +++ b/ports/espressif/boards/ai_thinker_esp32-c3s/board.c @@ -0,0 +1,56 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 microDev + * Copyright (c) 2021 skieast/Bruce Segal + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "shared-bindings/microcontroller/Pin.h" + +void board_init(void) { + + // Debug UART + #ifdef DEBUG + common_hal_never_reset_pin(&pin_GPIO20); + common_hal_never_reset_pin(&pin_GPIO21); + #endif + + // SPI Flash + common_hal_never_reset_pin(&pin_GPIO11); + common_hal_never_reset_pin(&pin_GPIO12); + common_hal_never_reset_pin(&pin_GPIO13); + common_hal_never_reset_pin(&pin_GPIO14); + common_hal_never_reset_pin(&pin_GPIO15); + common_hal_never_reset_pin(&pin_GPIO16); + common_hal_never_reset_pin(&pin_GPIO17); +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { +} + +void board_deinit(void) { +} diff --git a/ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h b/ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h new file mode 100644 index 0000000000..026e06312a --- /dev/null +++ b/ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h @@ -0,0 +1,47 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 microDev + * Copyright (c) 2021 skieast/Bruce Segal + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +// Board setup +#define MICROPY_HW_BOARD_NAME "AITHinker ESP32-C3S_Kit" +#define MICROPY_HW_MCU_NAME "ESP32-C3FN4" + +// Status LED +#define MICROPY_HW_LED_STATUS (&pin_GPIO19) + +// Default bus pins +#define DEFAULT_UART_BUS_RX (&pin_GPIO20) +#define DEFAULT_UART_BUS_TX (&pin_GPIO21) + +// Serial over UART +#define DEBUG_UART_RX DEFAULT_UART_BUS_RX +#define DEBUG_UART_TX DEFAULT_UART_BUS_TX + +// For entering safe mode +#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO9) + +// Explanation of how a user got into safe mode +#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") diff --git a/ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.mk b/ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.mk new file mode 100644 index 0000000000..3a83ab500b --- /dev/null +++ b/ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.mk @@ -0,0 +1,10 @@ +CIRCUITPY_CREATOR_ID = 0x70010001 +CIRCUITPY_CREATION_ID = 0x00100001 + +IDF_TARGET = esp32c3 + +INTERNAL_FLASH_FILESYSTEM = 1 + +CIRCUITPY_ESP_FLASH_MODE=qio +CIRCUITPY_ESP_FLASH_FREQ=80m +CIRCUITPY_ESP_FLASH_SIZE=4MB diff --git a/ports/espressif/boards/ai_thinker_esp32-c3s/pins.c b/ports/espressif/boards/ai_thinker_esp32-c3s/pins.c new file mode 100644 index 0000000000..37e9373202 --- /dev/null +++ b/ports/espressif/boards/ai_thinker_esp32-c3s/pins.c @@ -0,0 +1,72 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 microDev + * Copyright (c) 2021 skieast/Bruce Segal + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + + { MP_ROM_QSTR(MP_QSTR_IO0), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_IO1), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_IO2), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_IO3), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_IO4), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_IO5), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_IO6), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_IO7), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_IO8), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_IO9), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_IO10), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_IO11), MP_ROM_PTR(&pin_GPIO11) }, + { MP_ROM_QSTR(MP_QSTR_IO12), MP_ROM_PTR(&pin_GPIO12) }, + { MP_ROM_QSTR(MP_QSTR_IO13), MP_ROM_PTR(&pin_GPIO13) }, + { MP_ROM_QSTR(MP_QSTR_IO14), MP_ROM_PTR(&pin_GPIO14) }, + { MP_ROM_QSTR(MP_QSTR_IO15), MP_ROM_PTR(&pin_GPIO15) }, + { MP_ROM_QSTR(MP_QSTR_IO16), MP_ROM_PTR(&pin_GPIO16) }, + { MP_ROM_QSTR(MP_QSTR_IO17), MP_ROM_PTR(&pin_GPIO17) }, + { MP_ROM_QSTR(MP_QSTR_IO18), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_IO19), MP_ROM_PTR(&pin_GPIO19) }, + { MP_ROM_QSTR(MP_QSTR_IO20), MP_ROM_PTR(&pin_GPIO20) }, + { MP_ROM_QSTR(MP_QSTR_IO21), MP_ROM_PTR(&pin_GPIO21) }, + + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO20) }, + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO21) }, + + { MP_ROM_QSTR(MP_QSTR_ADC), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_LED_YELLOW), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_LED_WHITE), MP_ROM_PTR(&pin_GPIO19) }, + { MP_ROM_QSTR(MP_QSTR_LED_RED), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_LED_GREEN), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_LED_BLUE), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_BUTTON), MP_ROM_PTR(&pin_GPIO9) }, + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/espressif/boards/ai_thinker_esp32-c3s/sdkconfig b/ports/espressif/boards/ai_thinker_esp32-c3s/sdkconfig new file mode 100644 index 0000000000..88467d9c9e --- /dev/null +++ b/ports/espressif/boards/ai_thinker_esp32-c3s/sdkconfig @@ -0,0 +1,5 @@ +# +# LWIP +# +CONFIG_LWIP_LOCAL_HOSTNAME="AIThinker-ESP32C3S" +# end of LWIP diff --git a/ports/espressif/boards/microdev_micro_c3/board.c b/ports/espressif/boards/microdev_micro_c3/board.c new file mode 100644 index 0000000000..183740a7c3 --- /dev/null +++ b/ports/espressif/boards/microdev_micro_c3/board.c @@ -0,0 +1,58 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 microDev + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "shared-bindings/microcontroller/Pin.h" + +void board_init(void) { + // USB + common_hal_never_reset_pin(&pin_GPIO18); + common_hal_never_reset_pin(&pin_GPIO19); + + // Debug UART + #ifdef DEBUG + common_hal_never_reset_pin(&pin_GPIO20); + common_hal_never_reset_pin(&pin_GPIO21); + #endif + + // SPI Flash + common_hal_never_reset_pin(&pin_GPIO11); + common_hal_never_reset_pin(&pin_GPIO12); + common_hal_never_reset_pin(&pin_GPIO13); + common_hal_never_reset_pin(&pin_GPIO14); + common_hal_never_reset_pin(&pin_GPIO15); + common_hal_never_reset_pin(&pin_GPIO16); + common_hal_never_reset_pin(&pin_GPIO17); +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { +} + +void board_deinit(void) { +} diff --git a/ports/espressif/boards/microdev_micro_c3/mpconfigboard.h b/ports/espressif/boards/microdev_micro_c3/mpconfigboard.h new file mode 100644 index 0000000000..c1d9e1b0b2 --- /dev/null +++ b/ports/espressif/boards/microdev_micro_c3/mpconfigboard.h @@ -0,0 +1,54 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 microDev + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +// Board setup +#define MICROPY_HW_BOARD_NAME "MicroDev microC3" +#define MICROPY_HW_MCU_NAME "ESP32-C3FN4" + +// Status LED +#define MICROPY_HW_NEOPIXEL (&pin_GPIO7) +#define MICROPY_HW_NEOPIXEL_COUNT (2) + +// Default bus pins +#define DEFAULT_I2C_BUS_SCL (&pin_GPIO4) +#define DEFAULT_I2C_BUS_SDA (&pin_GPIO5) + +#define DEFAULT_SPI_BUS_SCK (&pin_GPIO1) +#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO2) +#define DEFAULT_SPI_BUS_MISO (&pin_GPIO3) + +#define DEFAULT_UART_BUS_RX (&pin_GPIO20) +#define DEFAULT_UART_BUS_TX (&pin_GPIO21) + +// Serial over UART +#define DEBUG_UART_RX DEFAULT_UART_BUS_RX +#define DEBUG_UART_TX DEFAULT_UART_BUS_TX + +// For entering safe mode +#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO9) + +// Explanation of how a user got into safe mode +#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n") diff --git a/ports/espressif/boards/microdev_micro_c3/mpconfigboard.mk b/ports/espressif/boards/microdev_micro_c3/mpconfigboard.mk new file mode 100644 index 0000000000..12bd7358b8 --- /dev/null +++ b/ports/espressif/boards/microdev_micro_c3/mpconfigboard.mk @@ -0,0 +1,10 @@ +CIRCUITPY_CREATOR_ID = 0x6d446576 +CIRCUITPY_CREATION_ID = 0x006d4333 + +IDF_TARGET = esp32c3 + +INTERNAL_FLASH_FILESYSTEM = 1 + +CIRCUITPY_ESP_FLASH_MODE=qio +CIRCUITPY_ESP_FLASH_FREQ=80m +CIRCUITPY_ESP_FLASH_SIZE=4MB diff --git a/ports/espressif/boards/microdev_micro_c3/pins.c b/ports/espressif/boards/microdev_micro_c3/pins.c new file mode 100644 index 0000000000..84d6efb782 --- /dev/null +++ b/ports/espressif/boards/microdev_micro_c3/pins.c @@ -0,0 +1,78 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 microDev + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "shared-bindings/board/__init__.h" + +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS + + { MP_ROM_QSTR(MP_QSTR_IO0), MP_ROM_PTR(&pin_GPIO0) }, + { MP_ROM_QSTR(MP_QSTR_IO1), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_IO2), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_IO3), MP_ROM_PTR(&pin_GPIO3) }, + { MP_ROM_QSTR(MP_QSTR_IO4), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_IO5), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_IO6), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_IO7), MP_ROM_PTR(&pin_GPIO7) }, + { MP_ROM_QSTR(MP_QSTR_IO8), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_IO9), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_IO10), MP_ROM_PTR(&pin_GPIO10) }, + { MP_ROM_QSTR(MP_QSTR_IO11), MP_ROM_PTR(&pin_GPIO11) }, + { MP_ROM_QSTR(MP_QSTR_IO12), MP_ROM_PTR(&pin_GPIO12) }, + { MP_ROM_QSTR(MP_QSTR_IO13), MP_ROM_PTR(&pin_GPIO13) }, + { MP_ROM_QSTR(MP_QSTR_IO14), MP_ROM_PTR(&pin_GPIO14) }, + { MP_ROM_QSTR(MP_QSTR_IO15), MP_ROM_PTR(&pin_GPIO15) }, + { MP_ROM_QSTR(MP_QSTR_IO16), MP_ROM_PTR(&pin_GPIO16) }, + { MP_ROM_QSTR(MP_QSTR_IO17), MP_ROM_PTR(&pin_GPIO17) }, + { MP_ROM_QSTR(MP_QSTR_IO18), MP_ROM_PTR(&pin_GPIO18) }, + { MP_ROM_QSTR(MP_QSTR_IO19), MP_ROM_PTR(&pin_GPIO19) }, + { MP_ROM_QSTR(MP_QSTR_IO20), MP_ROM_PTR(&pin_GPIO20) }, + { MP_ROM_QSTR(MP_QSTR_IO21), MP_ROM_PTR(&pin_GPIO21) }, + + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO20) }, + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO21) }, + + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO5) }, + + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO1) }, + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO2) }, + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO3) }, + + { MP_ROM_QSTR(MP_QSTR_MTMS), MP_ROM_PTR(&pin_GPIO4) }, + { MP_ROM_QSTR(MP_QSTR_MTDI), MP_ROM_PTR(&pin_GPIO5) }, + { MP_ROM_QSTR(MP_QSTR_MTCK), MP_ROM_PTR(&pin_GPIO6) }, + { MP_ROM_QSTR(MP_QSTR_MTDO), MP_ROM_PTR(&pin_GPIO7) }, + + { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_BUTTON), MP_ROM_PTR(&pin_GPIO9) }, + { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO7) }, + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/espressif/boards/microdev_micro_c3/sdkconfig b/ports/espressif/boards/microdev_micro_c3/sdkconfig new file mode 100644 index 0000000000..f6f038a77c --- /dev/null +++ b/ports/espressif/boards/microdev_micro_c3/sdkconfig @@ -0,0 +1,5 @@ +# +# LWIP +# +CONFIG_LWIP_LOCAL_HOSTNAME="MicroDev-microC3" +# end of LWIP diff --git a/ports/espressif/common-hal/busio/I2C.c b/ports/espressif/common-hal/busio/I2C.c index be80538582..81b23cb3a3 100644 --- a/ports/espressif/common-hal/busio/I2C.c +++ b/ports/espressif/common-hal/busio/I2C.c @@ -34,26 +34,6 @@ #include "shared-bindings/microcontroller/Pin.h" #include "supervisor/shared/translate.h" -typedef enum { - STATUS_FREE = 0, - STATUS_IN_USE, - STATUS_NEVER_RESET -} i2c_status_t; - -static i2c_status_t i2c_status[I2C_NUM_MAX]; - -void never_reset_i2c(i2c_port_t num) { - i2c_status[num] = STATUS_NEVER_RESET; -} - -void i2c_reset(void) { - for (i2c_port_t num = 0; num < I2C_NUM_MAX; num++) { - if (i2c_status[num] == STATUS_IN_USE) { - i2c_status[num] = STATUS_FREE; - } - } -} - void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, const mcu_pin_obj_t *scl, const mcu_pin_obj_t *sda, uint32_t frequency, uint32_t timeout) { // Pins 45 and 46 are "strapping" pins that impact start up behavior. They usually need to @@ -99,21 +79,16 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, } self->sda_pin = sda; self->scl_pin = scl; - self->i2c_num = I2C_NUM_MAX; - for (i2c_port_t num = 0; num < I2C_NUM_MAX; num++) { - if (i2c_status[num] == STATUS_FREE) { - self->i2c_num = num; - } - } + self->i2c_num = peripherals_i2c_get_free_num(); + if (self->i2c_num == I2C_NUM_MAX) { mp_raise_ValueError(translate("All I2C peripherals are in use")); } - i2c_status[self->i2c_num] = STATUS_IN_USE; // Delete any previous driver. i2c_driver_delete(self->i2c_num); - i2c_config_t i2c_conf = { + const i2c_config_t i2c_conf = { .mode = I2C_MODE_MASTER, .sda_io_num = self->sda_pin->number, .scl_io_num = self->scl_pin->number, @@ -129,16 +104,15 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, .clk_speed = frequency, } }; - if (i2c_param_config(self->i2c_num, &i2c_conf) != ESP_OK) { - mp_raise_ValueError(translate("Invalid frequency")); - } - if (i2c_driver_install(self->i2c_num, - I2C_MODE_MASTER, - 0, - 0, - 0) != ESP_OK) { - mp_raise_OSError(MP_EIO); + // Initialize I2C. + esp_err_t err = peripherals_i2c_init(self->i2c_num, &i2c_conf); + if (err != ESP_OK) { + if (err == ESP_FAIL) { + mp_raise_OSError(MP_EIO); + } else { + mp_raise_ValueError(translate("Invalid argument")); + } } claim_pin(sda); @@ -154,14 +128,12 @@ void common_hal_busio_i2c_deinit(busio_i2c_obj_t *self) { return; } - i2c_driver_delete(self->i2c_num); + peripherals_i2c_deinit(self->i2c_num); common_hal_reset_pin(self->sda_pin); common_hal_reset_pin(self->scl_pin); self->sda_pin = NULL; self->scl_pin = NULL; - - i2c_status[self->i2c_num] = STATUS_FREE; } bool common_hal_busio_i2c_probe(busio_i2c_obj_t *self, uint8_t addr) { diff --git a/ports/espressif/common-hal/busio/I2C.h b/ports/espressif/common-hal/busio/I2C.h index a44c414505..e3e60c07be 100644 --- a/ports/espressif/common-hal/busio/I2C.h +++ b/ports/espressif/common-hal/busio/I2C.h @@ -34,6 +34,8 @@ #include "freertos/semphr.h" #include "py/obj.h" +#include "peripherals/i2c.h" + typedef struct { mp_obj_base_t base; const mcu_pin_obj_t *scl_pin; @@ -43,6 +45,4 @@ typedef struct { bool has_lock; } busio_i2c_obj_t; -void i2c_reset(void); - #endif // MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BUSIO_I2C_H diff --git a/ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c b/ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c new file mode 100644 index 0000000000..d073a8a362 --- /dev/null +++ b/ports/espressif/common-hal/i2cperipheral/I2CPeripheral.c @@ -0,0 +1,125 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 microDev + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "shared-bindings/i2cperipheral/I2CPeripheral.h" + +#include "py/mperrno.h" +#include "py/runtime.h" + +#include "common-hal/i2cperipheral/I2CPeripheral.h" + +void common_hal_i2cperipheral_i2c_peripheral_construct(i2cperipheral_i2c_peripheral_obj_t *self, + const mcu_pin_obj_t *scl, const mcu_pin_obj_t *sda, + uint8_t *addresses, unsigned int num_addresses, bool smbus) { + // Pins 45 and 46 are "strapping" pins that impact start up behavior. They usually need to + // be pulled-down so pulling them up for I2C is a bad idea. To make this hard, we don't + // support I2C on these pins. + // Also 46 is input-only so it'll never work. + if (scl->number == 45 || scl->number == 46 || sda->number == 45 || sda->number == 46) { + mp_raise_ValueError(translate("Invalid pins")); + } + + if (num_addresses > 1) { + mp_raise_ValueError(translate("Only one address is allowed")); + } + self->addresses = addresses; + self->num_addresses = num_addresses; + + self->sda_pin = sda; + self->scl_pin = scl; + self->i2c_num = peripherals_i2c_get_free_num(); + + if (self->i2c_num == I2C_NUM_MAX) { + mp_raise_ValueError(translate("All I2C peripherals are in use")); + } + + const i2c_config_t i2c_conf = { + .mode = I2C_MODE_SLAVE, + .sda_io_num = self->sda_pin->number, + .scl_io_num = self->scl_pin->number, + .sda_pullup_en = GPIO_PULLUP_ENABLE, + .scl_pullup_en = GPIO_PULLUP_ENABLE, + .slave.addr_10bit_en = 0, + .slave.slave_addr = self->addresses[0], + }; + + // Initialize I2C. + esp_err_t err = peripherals_i2c_init(self->i2c_num, &i2c_conf); + if (err != ESP_OK) { + if (err == ESP_FAIL) { + mp_raise_OSError(MP_EIO); + } else { + mp_raise_ValueError(translate("Invalid argument")); + } + } + + claim_pin(sda); + claim_pin(scl); +} + +bool common_hal_i2cperipheral_i2c_peripheral_deinited(i2cperipheral_i2c_peripheral_obj_t *self) { + return self->sda_pin == NULL; +} + +void common_hal_i2cperipheral_i2c_peripheral_deinit(i2cperipheral_i2c_peripheral_obj_t *self) { + if (common_hal_i2cperipheral_i2c_peripheral_deinited(self)) { + return; + } + + peripherals_i2c_deinit(self->i2c_num); + + common_hal_reset_pin(self->sda_pin); + common_hal_reset_pin(self->scl_pin); + self->sda_pin = NULL; + self->scl_pin = NULL; +} + +int common_hal_i2cperipheral_i2c_peripheral_is_addressed(i2cperipheral_i2c_peripheral_obj_t *self, + uint8_t *address, bool *is_read, bool *is_restart) { + *address = self->addresses[0]; + *is_read = true; + *is_restart = false; + return 1; +} + +int common_hal_i2cperipheral_i2c_peripheral_read_byte(i2cperipheral_i2c_peripheral_obj_t *self, uint8_t *data) { + i2c_slave_read_buffer(self->i2c_num, data, 128, 0); + return 1; +} + +int common_hal_i2cperipheral_i2c_peripheral_write_byte(i2cperipheral_i2c_peripheral_obj_t *self, uint8_t data) { + i2c_reset_tx_fifo(self->i2c_num); + i2c_slave_write_buffer(self->i2c_num, &data, 128, 0); + return 1; +} + +void common_hal_i2cperipheral_i2c_peripheral_ack(i2cperipheral_i2c_peripheral_obj_t *self, bool ack) { + +} + +void common_hal_i2cperipheral_i2c_peripheral_close(i2cperipheral_i2c_peripheral_obj_t *self) { + +} diff --git a/ports/espressif/common-hal/i2cperipheral/I2CPeripheral.h b/ports/espressif/common-hal/i2cperipheral/I2CPeripheral.h new file mode 100644 index 0000000000..d3b324b39a --- /dev/null +++ b/ports/espressif/common-hal/i2cperipheral/I2CPeripheral.h @@ -0,0 +1,43 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 microDev + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BUSIO_I2C_PERIPHERAL_H +#define MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BUSIO_I2C_PERIPHERAL_H + +#include "py/obj.h" +#include "peripherals/i2c.h" +#include "common-hal/microcontroller/Pin.h" + +typedef struct { + mp_obj_base_t base; + i2c_port_t i2c_num; + uint8_t *addresses; + uint8_t num_addresses; + const mcu_pin_obj_t *scl_pin; + const mcu_pin_obj_t *sda_pin; +} i2cperipheral_i2c_peripheral_obj_t; + +#endif // MICROPY_INCLUDED_ESPRESSIF_COMMON_HAL_BUSIO_I2C_PERIPHERAL_H diff --git a/ports/espressif/common-hal/i2cperipheral/__init__.c b/ports/espressif/common-hal/i2cperipheral/__init__.c new file mode 100644 index 0000000000..c67511c536 --- /dev/null +++ b/ports/espressif/common-hal/i2cperipheral/__init__.c @@ -0,0 +1 @@ +// No i2cperipheral module functions. diff --git a/ports/espressif/mpconfigport.mk b/ports/espressif/mpconfigport.mk index bcd08aefe3..a7b69e0933 100644 --- a/ports/espressif/mpconfigport.mk +++ b/ports/espressif/mpconfigport.mk @@ -25,7 +25,7 @@ CIRCUITPY_DUALBANK ?= 1 CIRCUITPY_FRAMEBUFFERIO ?= 1 CIRCUITPY_FREQUENCYIO ?= 1 CIRCUITPY_IMAGECAPTURE ?= 1 -CIRCUITPY_I2CPERIPHERAL ?= 0 +CIRCUITPY_I2CPERIPHERAL ?= 1 CIRCUITPY_RGBMATRIX ?= 1 CIRCUITPY_ROTARYIO ?= 1 CIRCUITPY_NVM ?= 1 diff --git a/ports/espressif/peripherals/i2c.c b/ports/espressif/peripherals/i2c.c new file mode 100644 index 0000000000..7a85349f96 --- /dev/null +++ b/ports/espressif/peripherals/i2c.c @@ -0,0 +1,83 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 microDev + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "peripherals/i2c.h" + +typedef enum { + STATUS_FREE = 0, + STATUS_IN_USE, + STATUS_NEVER_RESET +} i2c_status_t; + +static i2c_status_t i2c_status[I2C_NUM_MAX]; + +void i2c_reset(void) { + for (i2c_port_t num = 0; num < I2C_NUM_MAX; num++) { + if (i2c_status[num] == STATUS_IN_USE) { + i2c_driver_delete(num); + i2c_status[num] = STATUS_FREE; + } + } +} + +void never_reset_i2c(i2c_port_t num) { + i2c_status[num] = STATUS_NEVER_RESET; +} + +esp_err_t peripherals_i2c_init(i2c_port_t num, const i2c_config_t *i2c_conf) { + esp_err_t err = i2c_param_config(num, i2c_conf); + if (err != ESP_OK) { + return err; + } + size_t rx_buf_len = 0; + size_t tx_buf_len = 0; + if (i2c_conf->mode == I2C_MODE_SLAVE) { + rx_buf_len = 256; + tx_buf_len = 256; + } + return i2c_driver_install(num, i2c_conf->mode, rx_buf_len, tx_buf_len, 0); +} + +void peripherals_i2c_deinit(i2c_port_t num) { + i2c_reset_rx_fifo(num); + i2c_reset_tx_fifo(num); + i2c_driver_delete(num); + i2c_status[num] = STATUS_FREE; +} + +i2c_port_t peripherals_i2c_get_free_num(void) { + i2c_port_t i2c_num = I2C_NUM_MAX; + for (i2c_port_t num = 0; num < I2C_NUM_MAX; num++) { + if (i2c_status[num] == STATUS_FREE) { + i2c_num = num; + break; + } + } + if (i2c_num != I2C_NUM_MAX) { + i2c_status[i2c_num] = STATUS_IN_USE; + } + return i2c_num; +} diff --git a/ports/espressif/peripherals/i2c.h b/ports/espressif/peripherals/i2c.h new file mode 100644 index 0000000000..4e7946d177 --- /dev/null +++ b/ports/espressif/peripherals/i2c.h @@ -0,0 +1,38 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2020 microDev + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_ESPRESSIF_PERIPHERALS_I2C_HANDLER_H +#define MICROPY_INCLUDED_ESPRESSIF_PERIPHERALS_I2C_HANDLER_H + +#include "driver/i2c.h" + +extern void i2c_reset(void); +extern void never_reset_i2c(i2c_port_t num); +extern esp_err_t peripherals_i2c_init(i2c_port_t num, const i2c_config_t *i2c_conf); +extern void peripherals_i2c_deinit(i2c_port_t num); +extern i2c_port_t peripherals_i2c_get_free_num(void); + +#endif // MICROPY_INCLUDED_ESPRESSIF_PERIPHERALS_I2C_HANDLER_H diff --git a/ports/nrf/boards/makerdiary_m60_keyboard/pins.c b/ports/nrf/boards/makerdiary_m60_keyboard/pins.c index 9ee0a06e59..485b968f4a 100644 --- a/ports/nrf/boards/makerdiary_m60_keyboard/pins.c +++ b/ports/nrf/boards/makerdiary_m60_keyboard/pins.c @@ -36,6 +36,12 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_BTN), MP_ROM_PTR(&pin_P0_27) }, + { MP_ROM_QSTR(MP_QSTR_CHARGING), MP_ROM_PTR(&pin_P0_03) }, + { MP_ROM_QSTR(MP_QSTR_VOLTAGE_MONITOR), MP_ROM_PTR(&pin_P0_02) }, + { MP_ROM_QSTR(MP_QSTR_BATTERY), MP_ROM_PTR(&pin_P0_02) }, + + { MP_ROM_QSTR(MP_QSTR_RGB_POWER), MP_ROM_PTR(&pin_P1_04) }, + // { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) } }; diff --git a/ports/nrf/boards/pca10100/mpconfigboard.h b/ports/nrf/boards/pca10100/mpconfigboard.h index 20d9d9aeb3..1456f29949 100644 --- a/ports/nrf/boards/pca10100/mpconfigboard.h +++ b/ports/nrf/boards/pca10100/mpconfigboard.h @@ -27,7 +27,7 @@ #include "nrfx/hal/nrf_gpio.h" -#define MICROPY_HW_BOARD_NAME "PCA10100 nRF52833 Dongle" +#define MICROPY_HW_BOARD_NAME "PCA10100 nRF52833 DK" #define MICROPY_HW_MCU_NAME "nRF52833" #define MICROPY_HW_LED_STATUS (&pin_P0_13) diff --git a/ports/raspberrypi/bindings/rp2pio/__init__.c b/ports/raspberrypi/bindings/rp2pio/__init__.c index 68f7cf3019..b3b45dc923 100644 --- a/ports/raspberrypi/bindings/rp2pio/__init__.c +++ b/ports/raspberrypi/bindings/rp2pio/__init__.c @@ -58,3 +58,5 @@ const mp_obj_module_t rp2pio_module = { .base = { &mp_type_module }, .globals = (mp_obj_dict_t *)&rp2pio_module_globals, }; + +MP_REGISTER_MODULE(MP_QSTR_rp2pio, rp2pio_module, CIRCUITPY_RP2PIO); diff --git a/ports/raspberrypi/boards/pimoroni_picosystem/board.c b/ports/raspberrypi/boards/pimoroni_picosystem/board.c index de6e424ed9..9f5f6ae6f5 100644 --- a/ports/raspberrypi/boards/pimoroni_picosystem/board.c +++ b/ports/raspberrypi/boards/pimoroni_picosystem/board.c @@ -25,8 +25,93 @@ */ #include "supervisor/board.h" +#include "mpconfigboard.h" +#include "shared-bindings/busio/SPI.h" +#include "shared-bindings/displayio/FourWire.h" +#include "shared-module/displayio/__init__.h" +#include "shared-module/displayio/mipi_constants.h" +#include "supervisor/shared/board.h" + +displayio_fourwire_obj_t board_display_obj; + +#define DELAY 0x80 + +uint8_t display_init_sequence[] = { + 0x01, 0 | DELAY, 150, // SWRESET + + 0x36, 1, 0x04, // MADCTL + 0x35, 1, 0x00, // TEON + 0xB2, 5, 0x0c, 0x0c, 0x00, 0x33, 0x33, // FRMCTR2 + 0x3A, 1, 0x05, // COLMOD + 0xB7, 1, 0x14, // GCTRL + 0xBB, 1, 0x37, // VCOMS + 0xC0, 1, 0x2c, // LCMCTRL + 0xC2, 1, 0x01, // VDVVRHEN + 0xC3, 1, 0x12, // VRHS + 0xC4, 1, 0x20, // VDVS + 0xD0, 2, 0xa4, 0xa1, // PWRCTRL1 + 0xC6, 1, 0x0f, // FRCTRL2 + 0xE0, 14, 0xd0, 0x04, 0x0d, 0x11, 0x13, 0x2b, 0x3f, 0x54, 0x4c, 0x18, 0x0d, 0x0b, 0x1f, 0x23, // GMCTRP1 + 0xE1, 14, 0xd0, 0x04, 0x0c, 0x11, 0x13, 0x2c, 0x3f, 0x44, 0x51, 0x2f, 0x1f, 0x1f, 0x20, 0x23, // GMCTRN1 + 0x21, 0, // INVON + + 0x11, 0 | DELAY, 255, // SLPOUT + 0x29, 0 | DELAY, 100, // DISPON + + 0x2a, 4, 0x00, 0, 0x00, 0xfe, // CASET + 0x2b, 4, 0x00, 0, 0x00, 0xfe, // RASET + 0x2c, 0, // RAMWR +}; void board_init(void) { + busio_spi_obj_t *spi = &displays[0].fourwire_bus.inline_bus; + common_hal_busio_spi_construct(spi, &pin_GPIO6, &pin_GPIO7, NULL); + common_hal_busio_spi_never_reset(spi); + + displayio_fourwire_obj_t *bus = &displays[0].fourwire_bus; + bus->base.type = &displayio_fourwire_type; + common_hal_displayio_fourwire_construct(bus, + spi, + &pin_GPIO9, // TFT_DC Command or data + &pin_GPIO5, // TFT_CS Chip select + &pin_GPIO4, // TFT_RST Reset + 60000000, // Baudrate + 0, // Polarity + 0); // Phase + + displayio_display_obj_t *display = &displays[0].display; + display->base.type = &displayio_display_type; + common_hal_displayio_display_construct(display, + bus, + 240, // Width + 240, // Height + 0, // column start + 0, // row start + 0, // rotation + 16, // Color depth + false, // Grayscale + false, // pixels in a byte share a row. Only valid for depths < 8 + 1, // bytes per cell. Only valid for depths < 8 + false, // reverse_pixels_in_byte. Only valid for depths < 8 + true, // reverse_bytes_in_word + MIPI_COMMAND_SET_COLUMN_ADDRESS, // Set column command + MIPI_COMMAND_SET_PAGE_ADDRESS, // Set row command + MIPI_COMMAND_WRITE_MEMORY_START, // Write memory command + display_init_sequence, + sizeof(display_init_sequence), + &pin_GPIO12, // backlight pin + NO_BRIGHTNESS_COMMAND, + 1.0f, // brightness (ignored) + true, // auto_brightness + false, // single_byte_bounds + false, // data_as_commands + true, // auto_refresh + 60, // native_frames_per_second + true, // backlight_on_high + false); // SH1107_addressing +} + +void board_deinit(void) { } bool board_requests_safe_mode(void) { @@ -35,6 +120,3 @@ bool board_requests_safe_mode(void) { void reset_board(void) { } - -void board_deinit(void) { -} diff --git a/ports/raspberrypi/boards/pimoroni_picosystem/mpconfigboard.mk b/ports/raspberrypi/boards/pimoroni_picosystem/mpconfigboard.mk index f00fb64cc9..8dca786a5e 100644 --- a/ports/raspberrypi/boards/pimoroni_picosystem/mpconfigboard.mk +++ b/ports/raspberrypi/boards/pimoroni_picosystem/mpconfigboard.mk @@ -9,3 +9,10 @@ CHIP_FAMILY = rp2 EXTERNAL_FLASH_DEVICES = "W25Q128JVxQ" CIRCUITPY__EVE = 1 + +CIRCUITPY_KEYPAD = 1 +CIRCUITPY_STAGE = 1 + +CIRCUITPY_AUDIOIO = 1 + +FROZEN_MPY_DIRS += $(TOP)/frozen/circuitpython-stage/picosystem diff --git a/ports/raspberrypi/boards/pimoroni_picosystem/pins.c b/ports/raspberrypi/boards/pimoroni_picosystem/pins.c index bfd51225fb..5aa96d6237 100644 --- a/ports/raspberrypi/boards/pimoroni_picosystem/pins.c +++ b/ports/raspberrypi/boards/pimoroni_picosystem/pins.c @@ -1,4 +1,5 @@ #include "shared-bindings/board/__init__.h" +#include "shared-module/displayio/__init__.h" STATIC const mp_rom_map_elem_t board_module_globals_table[] = { CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS @@ -41,5 +42,8 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, + + { MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display)} }; + MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c b/ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c index 7849130ff7..00cf54b221 100644 --- a/ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c +++ b/ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c @@ -68,7 +68,7 @@ void common_hal_rotaryio_incrementalencoder_construct(rotaryio_incrementalencode pins[1] = MP_OBJ_FROM_PTR(pin_a); self->swapped = false; if (!common_hal_rp2pio_pins_are_sequential(2, pins)) { - mp_raise_RuntimeError(translate("Pins must be sequential")); + mp_raise_RuntimeError(translate("Pins must be sequential GPIO pins")); } } diff --git a/ports/stm/Makefile b/ports/stm/Makefile index 1de7ed5c82..c691044f27 100755 --- a/ports/stm/Makefile +++ b/ports/stm/Makefile @@ -111,6 +111,7 @@ CFLAGS += -Wno-undef -Wno-shadow -Wno-cast-align $(ADD_CFLAGS) CFLAGS += -mthumb -mabi=aapcs-linux # Arm core selection +MCU_FLAGS_L4 = -mcpu=cortex-m4 MCU_FLAGS_F4 = -mcpu=cortex-m4 MCU_FLAGS_F7 = -mcpu=cortex-m7 MCU_FLAGS_H7 = -mcpu=cortex-m7 @@ -161,6 +162,13 @@ CFLAGS += \ -DCFG_TUD_MIDI_RX_BUFSIZE=128 \ -DCFG_TUD_MIDI_TX_BUFSIZE=128 +ifdef CIRCUITPY_USB_VENDOR +CFLAGS += \ + -DCFG_TUD_VENDOR_RX_BUFSIZE=1024 \ + -DCFG_TUD_VENDOR_TX_BUFSIZE=1024 +endif + + SRC_STM32 = $(addprefix $(HAL_DIR)/Src/stm32$(MCU_SERIES_LOWER)xx_,\ hal.c \ hal_adc.c \ @@ -207,7 +215,7 @@ endif # Need this to avoid UART linker problems. TODO: rewrite to use registered callbacks. # Does not exist for F4 and lower -ifeq ($(MCU_VARIANT),$(filter $(MCU_VARIANT),STM32F765xx STM32F767xx STM32F769xx STM32H743xx)) +ifeq ($(MCU_VARIANT),$(filter $(MCU_VARIANT),STM32F765xx STM32F767xx STM32F769xx STM32H743xx STM32L4R5xx)) SRC_STM32 += $(HAL_DIR)/Src/stm32$(MCU_SERIES_LOWER)xx_hal_uart_ex.c endif diff --git a/ports/stm/boards/STM32L4R5_boot.ld b/ports/stm/boards/STM32L4R5_boot.ld new file mode 100644 index 0000000000..16204205e6 --- /dev/null +++ b/ports/stm/boards/STM32L4R5_boot.ld @@ -0,0 +1,26 @@ +/* + GNU linker script for STM32L4R5 with bootloader +*/ + +/* Specify the memory areas */ +MEMORY +{ + FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 2048K /* entire flash */ + FLASH_ISR (rx) : ORIGIN = 0x08010000, LENGTH = 4K /* ISR vector. Kind of wasteful. */ + FLASH_FIRMWARE (rx) : ORIGIN = 0x08011000, LENGTH = 1024K-128K-64K-4K /* For now, limit to 1MB so that bank switching is still possible. */ + FLASH_FS (rw) : ORIGIN = 0x080e0000, LENGTH = 128K + RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 640K +} + +/* produce a link error if there is not this amount of RAM for these sections */ +_minimum_stack_size = 24K; +_minimum_heap_size = 16K; + +/* Define the top end of the stack. The stack is full descending so begins just + above last byte of RAM. Note that EABI requires the stack to be 8-byte + aligned for a call. */ +_estack = ORIGIN(RAM) + LENGTH(RAM); + +/* RAM extents for the garbage collector */ +_ram_start = ORIGIN(RAM); +_ram_end = ORIGIN(RAM) + LENGTH(RAM); diff --git a/ports/stm/boards/STM32L4R5_default.ld b/ports/stm/boards/STM32L4R5_default.ld new file mode 100644 index 0000000000..1f6e04f6be --- /dev/null +++ b/ports/stm/boards/STM32L4R5_default.ld @@ -0,0 +1,29 @@ +/* + GNU linker script for STM32L4R5 with filesystem +*/ + +/* Specify the memory areas */ +MEMORY +{ + FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 2048K /* entire flash */ + FLASH_ISR (rx) : ORIGIN = 0x08000000, LENGTH = 4K /* ISR vector. Kind of wasteful. */ + FLASH_FIRMWARE (rx) : ORIGIN = 0x08001000, LENGTH = 1024K-128K-4K /* For now, limit to 1MB so that bank switching is still possible. */ + FLASH_FS (rw) : ORIGIN = 0x080e0000, LENGTH = 128K + RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 640K +} + +/* produce a link error if there is not this amount of RAM for these sections */ +_minimum_stack_size = 24K; +_minimum_heap_size = 16K; + +/* Define tho top end of the stack. The stack is full descending so begins just + above last byte of RAM. Note that EABI requires the stack to be 8-byte + aligned for a call. */ +_estack = ORIGIN(RAM) + LENGTH(RAM); + +/* RAM extents for the garbage collector */ +_ram_start = ORIGIN(RAM); +_ram_end = ORIGIN(RAM) + LENGTH(RAM); + +/* ensure the firmware is within bounds */ +ASSERT ( (ORIGIN(FLASH_FIRMWARE) + LENGTH(FLASH_FIRMWARE)) <= (ORIGIN(FLASH)+LENGTH(FLASH)), "FLASH_FIRMWARE out of bounds" ); diff --git a/ports/stm/boards/swan_r5/board.c b/ports/stm/boards/swan_r5/board.c new file mode 100644 index 0000000000..7c0e3c44cd --- /dev/null +++ b/ports/stm/boards/swan_r5/board.c @@ -0,0 +1,64 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "supervisor/board.h" +#include "mpconfigboard.h" + +#include "stm32l4xx.h" +#include "stm32l4r5xx.h" + +void initialize_discharge_pin(void) { + /* Initialize the 3V3 discharge to be OFF and the output power to be ON */ + __HAL_RCC_GPIOE_CLK_ENABLE(); + GPIO_InitTypeDef GPIO_InitStruct; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_LOW; + GPIO_InitStruct.Pin = GPIO_PIN_6; + HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); + HAL_GPIO_WritePin(GPIOE, GPIO_PIN_6, GPIO_PIN_SET); + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStruct.Pin = GPIO_PIN_4; + HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); + HAL_GPIO_WritePin(GPIOE, GPIO_PIN_4, GPIO_PIN_SET); +} + +void board_init(void) { + // enable the debugger while sleeping. Todo move somewhere more central (kind of generally useful in a debug build) + SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_SLEEP); + + // Set tick interrupt priority, default HAL value is intentionally invalid + // Without this, USB does not function. + HAL_InitTick((1UL << __NVIC_PRIO_BITS) - 1UL); +} + +bool board_requests_safe_mode(void) { + return false; +} + +void reset_board(void) { + initialize_discharge_pin(); +} diff --git a/ports/stm/boards/swan_r5/mpconfigboard.h b/ports/stm/boards/swan_r5/mpconfigboard.h new file mode 100644 index 0000000000..da07d6530b --- /dev/null +++ b/ports/stm/boards/swan_r5/mpconfigboard.h @@ -0,0 +1,66 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Blues Wireless Contributors. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +// Micropython setup + +#define MICROPY_HW_BOARD_NAME "Swan R5" +#define MICROPY_HW_MCU_NAME "STM32L4R5ZIY6" + +// todo - not sure why this isn't the default for this port +#define MICROPY_PY_SYS_PLATFORM MICROPY_HW_BOARD_NAME + + +#define STM32L4R5XX +#define BOARD_SWAN_R5 + + +// The flash size is defined in the STM32L4xx HAL (but not for the F4) +// #define FLASH_SIZE (0x200000) +// #define FLASH_PAGE_SIZE (0x1000) + +#define LSE_VALUE ((uint32_t)32768) +#define BOARD_HAS_LOW_SPEED_CRYSTAL (1) +#define BOARD_HAS_HIGH_SPEED_CRYSTAL (0) + + +// Bootloader only +#ifdef UF2_BOOTLOADER_ENABLED + #define BOARD_VTOR_DEFER (1) // Leave VTOR relocation to bootloader +#endif + +#define BOARD_NO_VBUS_SENSE (1) +#define BOARD_NO_USB_OTG_ID_SENSE (1) + +#define DEFAULT_I2C_BUS_SCL (&pin_PB06) +#define DEFAULT_I2C_BUS_SDA (&pin_PB07) + +#define DEFAULT_SPI_BUS_SS (&pin_PD00) +#define DEFAULT_SPI_BUS_SCK (&pin_PD01) +#define DEFAULT_SPI_BUS_MOSI (&pin_PB15) +#define DEFAULT_SPI_BUS_MISO (&pin_PB14) + +#define DEFAULT_UART_BUS_RX (&pin_PA10) +#define DEFAULT_UART_BUS_TX (&pin_PA09) diff --git a/ports/stm/boards/swan_r5/mpconfigboard.mk b/ports/stm/boards/swan_r5/mpconfigboard.mk new file mode 100644 index 0000000000..24b73e332d --- /dev/null +++ b/ports/stm/boards/swan_r5/mpconfigboard.mk @@ -0,0 +1,73 @@ +USB_VID = 0x30A4 +USB_PID = 0x02 +USB_PRODUCT = "Swan R5" +USB_MANUFACTURER = "Blues Inc." + +INTERNAL_FLASH_FILESYSTEM = 1 + +MCU_SERIES = L4 +MCU_VARIANT = STM32L4R5xx +MCU_PACKAGE = WLCSP144 + +LD_COMMON = boards/common_default.ld +LD_DEFAULT = boards/STM32L4R5_default.ld +# UF2 boot option +LD_BOOT = boards/STM32L4R5_boot.ld +UF2_OFFSET = 0x8010000 + +# Turn all of the below off while trying to get the thing to run +# These modules are implemented in ports//common-hal: + +# Typically the first module to create +CIRCUITPY_MICROCONTROLLER = 1 +CIRCUITPY_ALARM = 1 + +# Typically the second module to create +CIRCUITPY_DIGITALIO = 1 +# Other modules: + +CIRCUITPY_OS = 1 +CIRCUITPY_STORAGE = 1 +CIRCUITPY_USB_MSC = 1 +CIRCUITPY_UDB_CDC = 1 +CIRCUITPY_USB_VENDOR = 1 +CIRCUITPY_NVM = 0 + +CIRCUITPY_ANALOGIO = 1 +CIRCUITPY_BUSIO = 1 +CIRCUITPY_NEOPIXEL_WRITE = 0 +CIRCUITPY_PULSEIO = 1 +CIRCUITPY_PWMIO = 1 +CIRCUITPY_AUDIOPWMIO = 1 +CIRCUITPY_CANIO = 0 +CIRCUITPY_AUDIOBUSIO = 0 +CIRCUITPY_I2CPERIPHERAL = 0 +# Requires SPI, PulseIO (stub ok): +CIRCUITPY_DISPLAYIO = 0 + +# These modules are implemented in shared-module/ - they can be included in +# any port once their prerequisites in common-hal are complete. +# Requires DigitalIO: +CIRCUITPY_BITBANGIO = 1 +# Requires DigitalIO +CIRCUITPY_GAMEPADSHIFT = 1 +# Requires neopixel_write or SPI (dotstar) +CIRCUITPY_PIXELBUF = 0 +# Requires OS +CIRCUITPY_RANDOM = 1 +# Requires Microcontroller +CIRCUITPY_TOUCHIO = 1 +# Requires USB +CIRCUITPY_USB_HID = 0 +CIRCUITPY_USB_MIDI = 0 +# Does nothing without I2C +CIRCUITPY_REQUIRE_I2C_PULLUPS = 0 +# No requirements, but takes extra flash +CIRCUITPY_ULAB = 1 +# requires SPI +CIRCUITPY_SDCARDIO = 0 +CIRCUITPY_BLEIO_HCI = 0 +CIRCUITPY_BLEIO = 0 +CIRCUITPY_BUSDEVICE = 0 +CIRCUITPY_KEYPAD = 1 +CIRCUITPY_RGBMATRIX = 0 diff --git a/ports/stm/boards/swan_r5/pins.c b/ports/stm/boards/swan_r5/pins.c new file mode 100644 index 0000000000..2f37e3b055 --- /dev/null +++ b/ports/stm/boards/swan_r5/pins.c @@ -0,0 +1,50 @@ +#include "py/objtuple.h" +#include "shared-bindings/board/__init__.h" + +// Core Feather Pins +STATIC const mp_rom_map_elem_t board_module_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR_ENABLE_3V3), MP_ROM_PTR(&pin_PE04) }, + { MP_ROM_QSTR(MP_QSTR_DISCHARGE_3V3), MP_ROM_PTR(&pin_PE06) }, + { MP_ROM_QSTR(MP_QSTR_DISABLE_DISCHARGING), MP_ROM_TRUE }, + { MP_ROM_QSTR(MP_QSTR_ENABLE_DISCHARGING), MP_ROM_FALSE }, + + { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA03) }, + { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PA01) }, + { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PC03) }, + { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PC01) }, + { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PC04) }, + { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_PC05) }, + { MP_ROM_QSTR(MP_QSTR_VOLTAGE_MONITOR), MP_ROM_PTR(&pin_PA00) }, + { MP_ROM_QSTR(MP_QSTR_BUTTON_USR), MP_ROM_PTR(&pin_PC13) }, + { MP_ROM_QSTR(MP_QSTR_SWITCH), MP_ROM_PTR(&pin_PE04) }, + { MP_ROM_QSTR(MP_QSTR_BUTTON), MP_ROM_PTR(&pin_PB02) }, // boot button, but looks like it's wired to GND on the schematic + + { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_PE11) }, + { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PE09) }, + { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_PD15) }, + { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PA04) }, // DAC1 output also + { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_PA07) }, + { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_PA06) }, + + { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_PE02) }, + { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_PA05) }, // DAC1 output also + + { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PB07) }, + { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PB06) }, + + { MP_ROM_QSTR(MP_QSTR_DAC1), MP_ROM_PTR(&pin_PA04) }, // D10 + { MP_ROM_QSTR(MP_QSTR_DAC2), MP_ROM_PTR(&pin_PA05) }, // D13 + + { MP_ROM_QSTR(MP_QSTR_SS), MP_ROM_PTR(&pin_PD00) }, + { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PD01) }, + { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PB14) }, + { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PB15) }, + + { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PA09) }, + { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PA10) }, + + { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, + { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, + { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, +}; +MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/stm/boards/swan_r5/tests/analog_output.py b/ports/stm/boards/swan_r5/tests/analog_output.py new file mode 100644 index 0000000000..6af931e65d --- /dev/null +++ b/ports/stm/boards/swan_r5/tests/analog_output.py @@ -0,0 +1,85 @@ +import board +import analogio +import digitalio + + +def test_dac_analog(p_in, p_out): + print(f"Running dac analog test with pin {p_in} as input and {p_out} as output\n") + pin_in = analogio.AnalogIn(p_in) + pin_out = analogio.AnalogOut(p_out) + + for v in range(0, 65536, 4096): + pin_out.value = v + print(f"Value {v} read as {pin_in.value}") + + pin_in.deinit() + pin_out.deinit() + + +def test_dac_digital(p_in, p_out): + print(f"Running dac digital test with pin {p_in} as input and {p_out} as output") + pin_in = digitalio.DigitalInOut(p_in) + pin_out = analogio.AnalogOut(p_out) + + for v in range(0, 65536, 4096): + pin_out.value = v + print(f"Value {v} read as {pin_in.value}") + + pin_in.deinit() + pin_out.deinit() + + +def test_dual(pair1, pair2): + # verifies that the DACs can be set independently + print(f"Running pair test\n") + pin1_in = analogio.AnalogIn(pair1[0]) + pin1_out = analogio.AnalogOut(pair1[1]) + pin2_in = analogio.AnalogIn(pair2[0]) + pin2_out = analogio.AnalogOut(pair2[1]) + + for v in range(0, 65536, 4096): + v2 = 65535 - v + pin1_out.value = v + pin2_out.value = v2 + print(f"Pair1: Value {v} read as {pin1_in.value}") + print(f"Pair2: Value {v2} read as {pin2_in.value}") + + pin1_in.deinit() + pin1_out.deinit() + pin2_in.deinit() + pin2_out.deinit() + + +def test_analog_hilo(p_in, p_out): + print(f"Running analog hilo test with pin {p_in} as input and {p_out} as output") + pin_in = analogio.AnalogIn(p_in) + pin_out = digitalio.DigitalInOut(p_out) + pin_out.switch_to_output() + + for v in (False, True, False, True): + pin_out.value = v + print(f"Value {v} read as {pin_in.value}") + + pin_in.deinit() + pin_out.deinit() + + +def test_pair(pair): + # FIXME: test_analog_hilo works fine alone, but fails when the other dac functions are executed + test_analog_hilo(*pair) + test_dac_analog(*pair) + test_dac_digital(*pair) + + +def main(): + pair1 = (board.A3, board.DAC1) + pair2 = (board.A2, board.DAC2) + print("running DAC1 tests") + test_pair(pair1) + print("running DAC2 tests") + test_pair(pair2) + print("running dual DAC tests") + test_dual(pair1, pair2) + + +main() diff --git a/ports/stm/boards/swan_r5/tests/board_voltage.py b/ports/stm/boards/swan_r5/tests/board_voltage.py new file mode 100644 index 0000000000..6191067fde --- /dev/null +++ b/ports/stm/boards/swan_r5/tests/board_voltage.py @@ -0,0 +1,148 @@ +# SPDX-FileCopyrightText: 2018 Shawn Hymel for Adafruit Industries +# +# SPDX-License-Identifier: MIT + +print("pins test") + +""" +`adafruit_boardtest.boardtest_gpio` +==================================================== +Toggles all available GPIO on a board. Verify their operation with an LED, +multimeter, another microcontroller, etc. + +Run this script as its own main.py to individually run the test, or compile +with mpy-cross and call from separate test script. + +* Author(s): Shawn Hymel for Adafruit Industries + +Implementation Notes +-------------------- + +**Software and Dependencies:** + +* Adafruit CircuitPython firmware for the supported boards: + https://github.com/adafruit/circuitpython/releases + +""" + +import time + +import board +import digitalio +import supervisor + +__version__ = "0.0.0-auto.0" +__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_BoardTest.git" + +# Constants +LED_ON_DELAY_TIME = 0.2 # Seconds +LED_OFF_DELAY_TIME = 0.2 # Seconds +LED_PIN_NAMES = ["L", "LED", "RED_LED", "GREEN_LED", "BLUE_LED"] + +# Test result strings +PASS = "PASS" +FAIL = "FAIL" +NA = "N/A" + +# Determine if given value is a number +def _is_number(val): + try: + float(val) + return True + except ValueError: + return False + + +# Release pins +def _deinit_pins(gpios): + for g in gpios: + g.deinit() + + +# Toggle IO pins while waiting for answer +def _toggle_wait(pin_gpios): + + timestamp = time.monotonic() + led_state = False + failed = [] + for pg in pin_gpios: + (pin, gpio) = pg + print("Is pin %s toggling? [y/n]" % pin) + done = False + while not done: + if led_state: + if time.monotonic() > timestamp + LED_ON_DELAY_TIME: + led_state = False + timestamp = time.monotonic() + else: + if time.monotonic() > timestamp + LED_OFF_DELAY_TIME: + led_state = True + timestamp = time.monotonic() + + gpio.value = led_state + if supervisor.runtime.serial_bytes_available: + answer = input() + if bool(answer == "y"): + done = True + elif bool(answer == "n"): + failed += pin + done = True + return failed + + +def buildPin(pin): + gpio = digitalio.DigitalInOut(pin) + return gpio + + +def run_test(pins): + + """ + Toggles all available GPIO on and off repeatedly. + + :param list[str] pins: list of pins to run the test on + :return: tuple(str, list[str]): test result followed by list of pins tested + """ + + # Create a list of analog GPIO pins + analog_pins = [p for p in pins if p[0] == "A" and _is_number(p[1])] + + # Create a list of digital GPIO + digital_pins = [p for p in pins if p[0] == "D" and _is_number(p[1])] + + # Toggle LEDs if we find any + gpio_pins = analog_pins + digital_pins + + if gpio_pins: + + # Print out the LEDs found + print("GPIO pins found:", end=" ") + for pin in gpio_pins: + print(pin, end=" ") + print("\n") + + # Create a list of IO objects for us to toggle + gpios = [buildPin(getattr(board, p)) for p in gpio_pins] + + print("built GPIOs") + # Set all IO to output + for gpio in gpios: + gpio.direction = digitalio.Direction.OUTPUT + + # Toggle pins while waiting for user to verify LEDs blinking + result = _toggle_wait(zip(gpio_pins, gpios)) + + # Release pins + _deinit_pins(gpios) + + if result: + return FAIL, gpio_pins + + return PASS, gpio_pins + + # Else (no pins found) + print("No GPIO pins found") + return NA, [] + + +run_test([p for p in dir(board)]) diff --git a/ports/stm/boards/swan_r5/tests/button.py b/ports/stm/boards/swan_r5/tests/button.py new file mode 100644 index 0000000000..4f00254ddb --- /dev/null +++ b/ports/stm/boards/swan_r5/tests/button.py @@ -0,0 +1,22 @@ +import board +import digitalio +import time + + +def monitor_button(pin, callback): + with digitalio.DigitalInOut(pin) as button: + newstate = not button.value # state is inverted + state = not newstate # ensure change reported to start with + while callback(newstate, newstate != state): + state = newstate + newstate = button.value + time.sleep(0.01) + + +def print_changes(state, changed): + if changed: + print(f"button pressed {state}") + return True + + +monitor_button(board.BUTTON_USR, print_changes) diff --git a/ports/stm/boards/swan_r5/tests/enable_3v3.py b/ports/stm/boards/swan_r5/tests/enable_3v3.py new file mode 100644 index 0000000000..ba955c4f58 --- /dev/null +++ b/ports/stm/boards/swan_r5/tests/enable_3v3.py @@ -0,0 +1,35 @@ +# Background: I have a Swan R5 board running circuit python +# And I import the "board" module +import board +import digitalio +import supervisor +import time + +# Scenario: Enable 3V3 pin defintiion +# Then the symbol "board.ENABLE_3V3" is defined +assert board.ENABLE_3V3 is not None + +# Scenario: Discharge 3V3 definition +# Then the symbol "board.DISCHARGE_3V3" is defined +assert board.DISCHARGE_3V3 is not None +# And the symbol "board.DISABLE_DISCHARGING" is defined to be "True" +assert board.DISABLE_DISCHARGING is not None and board.DISABLE_DISCHARGING == True +# And the symbol "board.ENABLE_DISCHARGING" is defined to be "False" +assert board.ENABLE_DISCHARGING is not None and board.ENABLE_DISCHARGING == False + +# Scenario: Toggle ENBLE_3V3 +# Given I have a LED connected between the 3V3 and GND pins +# And ENABLE_3V3 is configured for output +_3v3 = digitalio.DigitalInOut(board.ENABLE_3V3) +_3v3.direction = digitalio.Direction.OUTPUT +# When I run code to toggle the pin at 0.5Hz +# Then I see the LED switch on and off at 0.5Hz +print("Toggling 3V3. Press a key to stop.") + +while not supervisor.runtime.serial_bytes_available: + _3v3.value = True + time.sleep(1.0) + _3v3.value = False + time.sleep(1.0) + +print("Toggling stopped.") diff --git a/ports/stm/boards/swan_r5/tests/i2c_scan.py b/ports/stm/boards/swan_r5/tests/i2c_scan.py new file mode 100644 index 0000000000..8e3ef557d1 --- /dev/null +++ b/ports/stm/boards/swan_r5/tests/i2c_scan.py @@ -0,0 +1,20 @@ +import board +import busio + +i2c = busio.I2C(board.SCL, board.SDA) +count = 0 + +# Wait for I2C lock +while not i2c.try_lock(): + pass + +# Scan for devices on the I2C bus +print("Scanning I2C bus") +for x in i2c.scan(): + print(hex(x)) + count += 1 + +print("%d device(s) found on I2C bus" % count) + +# Release the I2C bus +i2c.unlock() diff --git a/ports/stm/boards/swan_r5/tests/pwnio.py b/ports/stm/boards/swan_r5/tests/pwnio.py new file mode 100644 index 0000000000..71888d867b --- /dev/null +++ b/ports/stm/boards/swan_r5/tests/pwnio.py @@ -0,0 +1,17 @@ +import time +import pwmio + + +def fade(pin): + led = pwmio.PWMOut(pin, frequency=5000, duty_cycle=0) + # LED setup for QT Py M0: + # led = pwmio.PWMOut(board.SCK, frequency=5000, duty_cycle=0) + + while True: + for i in range(100): + # PWM LED up and down + if i < 50: + led.duty_cycle = int(i * 2 * 65535 / 100) # Up + else: + led.duty_cycle = 65535 - int((i - 50) * 2 * 65535 / 100) # Down + time.sleep(0.01) diff --git a/ports/stm/boards/swan_r5/tests/spi_bme680_smoke_test.py b/ports/stm/boards/swan_r5/tests/spi_bme680_smoke_test.py new file mode 100644 index 0000000000..01e98bfd31 --- /dev/null +++ b/ports/stm/boards/swan_r5/tests/spi_bme680_smoke_test.py @@ -0,0 +1,58 @@ +import board +import busio +import digitalio + +cs = digitalio.DigitalInOut(board.SS) +cs.direction = digitalio.Direction.OUTPUT +cs.value = True + +BME680_SPI_REGISTER = 0x73 +BME680_CHIPID_REGISTER = 0xD0 +BME680_CHIPID = 0x61 +SPI_HERZ = 0x500000 + +spi = busio.SPI(board.SCK, MISO=board.MISO, MOSI=board.MOSI) + + +def readByte(addr): + value = -1 + while not spi.try_lock(): + pass + try: + spi.configure(baudrate=500000, phase=0, polarity=0) + + cs.value = False + result = bytearray(1) + result[0] = addr | 0x80 + spi.write(result) + spi.readinto(result) + value = result[0] + return value + finally: + spi.unlock() + cs.value = True + + +def writeByte(addr, value): + while not spi.try_lock(): + pass + try: + spi.configure(baudrate=500000, phase=0, polarity=0) + + cs.value = False + result = bytearray(2) + result[0] = addr & ~0x80 + result[1] = value + spi.write(result) + finally: + spi.unlock() + + +# put the device in the correct mode to read the ID +reg = readByte(BME680_SPI_REGISTER) +if (reg & 16) != 0: + writeByte(BME680_SPI_REGISTER, reg & ~16) + +id = readByte(BME680_CHIPID_REGISTER) + +print(f"id is {id}, expected {BME680_CHIPID}") diff --git a/ports/stm/boards/swan_r5/tests/uart.py b/ports/stm/boards/swan_r5/tests/uart.py new file mode 100644 index 0000000000..a8dbc272a8 --- /dev/null +++ b/ports/stm/boards/swan_r5/tests/uart.py @@ -0,0 +1,37 @@ +import board +import busio +import digitalio +import usb_cdc +import time + +while not usb_cdc.console.in_waiting: + time.sleep(0.1) + +print("USART test") + +# For most CircuitPython boards: +led = digitalio.DigitalInOut(board.LED) +# For QT Py M0: +# led = digitalio.DigitalInOut(board.SCK) +led.direction = digitalio.Direction.OUTPUT + +uart = busio.UART(board.TX, board.RX, baudrate=9600) + +while True: + data = uart.read(32) # read up to 32 bytes + # print(data) # this is a bytearray type + + if data is not None: + led.value = True + + # convert bytearray to string + data_string = "*".join([chr(b) for b in data]) + print(data_string, end="") + + led.value = False + + if usb_cdc.console.in_waiting: + data = usb_cdc.console.read() + data_string = "*".join([chr(b) for b in data]) + print("writing " + data_string) + uart.write(data) diff --git a/ports/stm/boards/swan_r5/tests/urandom.py b/ports/stm/boards/swan_r5/tests/urandom.py new file mode 100644 index 0000000000..25ff655596 --- /dev/null +++ b/ports/stm/boards/swan_r5/tests/urandom.py @@ -0,0 +1,10 @@ +import os + + +def main(): + print("Random number test") + r = os.urandom(32) + print(f"urandom TRNG string is {r}") + + +main() diff --git a/ports/stm/boards/system_stm32l4xx.c b/ports/stm/boards/system_stm32l4xx.c new file mode 100644 index 0000000000..3890fc0895 --- /dev/null +++ b/ports/stm/boards/system_stm32l4xx.c @@ -0,0 +1,375 @@ +/* + * Taken from ST Cube library and modified. See below for original header. + * + * Modifications copyright (c) 2021 Blues Wireless Contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +/** + ****************************************************************************** + * @file system_stm32l4xx.c + * @author MCD Application Team + * @brief CMSIS Cortex-M4 Device Peripheral Access Layer System Source File + * + * This file provides two functions and one global variable to be called from + * user application: + * - SystemInit(): This function is called at startup just after reset and + * before branch to main program. This call is made inside + * the "startup_stm32l4xx.s" file. + * + * - SystemCoreClock variable: Contains the core clock (HCLK), it can be used + * by the user application to setup the SysTick + * timer or configure other parameters. + * + * - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must + * be called whenever the core clock is changed + * during program execution. + * + * After each device reset the MSI (4 MHz) is used as system clock source. + * Then SystemInit() function is called, in "startup_stm32l4xx.s" file, to + * configure the system clock before to branch to main program. + * + * This file configures the system clock as follows: + *============================================================================= + *----------------------------------------------------------------------------- + * System Clock source | MSI + *----------------------------------------------------------------------------- + * SYSCLK(Hz) | 4000000 + *----------------------------------------------------------------------------- + * HCLK(Hz) | 4000000 + *----------------------------------------------------------------------------- + * AHB Prescaler | 1 + *----------------------------------------------------------------------------- + * APB1 Prescaler | 1 + *----------------------------------------------------------------------------- + * APB2 Prescaler | 1 + *----------------------------------------------------------------------------- + * PLL_M | 1 + *----------------------------------------------------------------------------- + * PLL_N | 8 + *----------------------------------------------------------------------------- + * PLL_P | 7 + *----------------------------------------------------------------------------- + * PLL_Q | 2 + *----------------------------------------------------------------------------- + * PLL_R | 2 + *----------------------------------------------------------------------------- + * PLLSAI1_P | NA + *----------------------------------------------------------------------------- + * PLLSAI1_Q | NA + *----------------------------------------------------------------------------- + * PLLSAI1_R | NA + *----------------------------------------------------------------------------- + * PLLSAI2_P | NA + *----------------------------------------------------------------------------- + * PLLSAI2_Q | NA + *----------------------------------------------------------------------------- + * PLLSAI2_R | NA + *----------------------------------------------------------------------------- + * Require 48MHz for USB OTG FS, | Disabled + * SDIO and RNG clock | + *----------------------------------------------------------------------------- + *============================================================================= + ****************************************************************************** + * @attention + * + *

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

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

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

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +#include "stm32_hal_conf.h" + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef STM32L4xx_HAL_CONF_H +#define STM32L4xx_HAL_CONF_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ + +/* ########################## Module Selection ############################## */ +/** + * @brief This is the list of modules to be used in the HAL driver + */ +#define HAL_MODULE_ENABLED +#define HAL_ADC_MODULE_ENABLED +#define HAL_CAN_MODULE_ENABLED +/* #define HAL_CAN_LEGACY_MODULE_ENABLED */ +#define HAL_COMP_MODULE_ENABLED +#define HAL_CORTEX_MODULE_ENABLED +#define HAL_CRC_MODULE_ENABLED +#define HAL_CRYP_MODULE_ENABLED +#define HAL_DAC_MODULE_ENABLED +#define HAL_DCMI_MODULE_ENABLED +#define HAL_DFSDM_MODULE_ENABLED +#define HAL_DMA_MODULE_ENABLED +#define HAL_DMA2D_MODULE_ENABLED +#define HAL_DSI_MODULE_ENABLED +#define HAL_EXTI_MODULE_ENABLED +#define HAL_FIREWALL_MODULE_ENABLED +#define HAL_FLASH_MODULE_ENABLED +#define HAL_GFXMMU_MODULE_ENABLED +#define HAL_GPIO_MODULE_ENABLED +#define HAL_HASH_MODULE_ENABLED +#define HAL_HCD_MODULE_ENABLED +#define HAL_I2C_MODULE_ENABLED +#define HAL_IRDA_MODULE_ENABLED +#define HAL_IWDG_MODULE_ENABLED +#define HAL_LCD_MODULE_ENABLED +#define HAL_LPTIM_MODULE_ENABLED +#define HAL_LTDC_MODULE_ENABLED +#define HAL_MMC_MODULE_ENABLED +#define HAL_NAND_MODULE_ENABLED +#define HAL_NOR_MODULE_ENABLED +#define HAL_OPAMP_MODULE_ENABLED +#define HAL_OSPI_MODULE_ENABLED +#define HAL_PCD_MODULE_ENABLED +#define HAL_PWR_MODULE_ENABLED +#define HAL_QSPI_MODULE_ENABLED +#define HAL_RCC_MODULE_ENABLED +#define HAL_RNG_MODULE_ENABLED +#define HAL_RTC_MODULE_ENABLED +#define HAL_SAI_MODULE_ENABLED +#define HAL_SD_MODULE_ENABLED +#define HAL_SMARTCARD_MODULE_ENABLED +#define HAL_SMBUS_MODULE_ENABLED +#define HAL_SPI_MODULE_ENABLED +#define HAL_SRAM_MODULE_ENABLED +#define HAL_SWPMI_MODULE_ENABLED +#define HAL_TIM_MODULE_ENABLED +#define HAL_TSC_MODULE_ENABLED +#define HAL_UART_MODULE_ENABLED +#define HAL_USART_MODULE_ENABLED +#define HAL_WWDG_MODULE_ENABLED + + +/* ########################## Oscillator Values adaptation ####################*/ +/** + * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSE is used as system clock source, directly or through the PLL). + */ +#if !defined(HSE_VALUE) + #define HSE_VALUE 8000000U /*!< Value of the External oscillator in Hz */ +#endif /* HSE_VALUE */ + +#if !defined(HSE_STARTUP_TIMEOUT) + #define HSE_STARTUP_TIMEOUT 100U /*!< Time out for HSE start up, in ms */ +#endif /* HSE_STARTUP_TIMEOUT */ + +/** + * @brief Internal Multiple Speed oscillator (MSI) default value. + * This value is the default MSI range value after Reset. + */ +#if !defined(MSI_VALUE) + #define MSI_VALUE 4000000U /*!< Value of the Internal oscillator in Hz*/ +#endif /* MSI_VALUE */ + +/** + * @brief Internal High Speed oscillator (HSI) value. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSI is used as system clock source, directly or through the PLL). + */ +#if !defined(HSI_VALUE) + #define HSI_VALUE 16000000U /*!< Value of the Internal oscillator in Hz*/ +#endif /* HSI_VALUE */ + +/** + * @brief Internal High Speed oscillator (HSI48) value for USB FS, SDMMC and RNG. + * This internal oscillator is mainly dedicated to provide a high precision clock to + * the USB peripheral by means of a special Clock Recovery System (CRS) circuitry. + * When the CRS is not used, the HSI48 RC oscillator runs on it default frequency + * which is subject to manufacturing process variations. + */ +#if !defined(HSI48_VALUE) + #define HSI48_VALUE 48000000U /*!< Value of the Internal High Speed oscillator for USB FS/SDMMC/RNG in Hz. + The real value my vary depending on manufacturing process variations.*/ +#endif /* HSI48_VALUE */ + +/** + * @brief Internal Low Speed oscillator (LSI) value. + */ +#if !defined(LSI_VALUE) + #define LSI_VALUE 32000U /*!< LSI Typical Value in Hz*/ +#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz + The real value may vary depending on the variations + in voltage and temperature.*/ +/** + * @brief External Low Speed oscillator (LSE) value. + * This value is used by the UART, RTC HAL module to compute the system frequency + */ +#if !defined(LSE_VALUE) + #define LSE_VALUE 32768U /*!< Value of the External oscillator in Hz*/ +#endif /* LSE_VALUE */ + +#if !defined(LSE_STARTUP_TIMEOUT) + #define LSE_STARTUP_TIMEOUT 5000U /*!< Time out for LSE start up, in ms */ +#endif /* HSE_STARTUP_TIMEOUT */ + +/** + * @brief External clock source for SAI1 peripheral + * This value is used by the RCC HAL module to compute the SAI1 & SAI2 clock source + * frequency. + */ +#if !defined(EXTERNAL_SAI1_CLOCK_VALUE) + #define EXTERNAL_SAI1_CLOCK_VALUE 48000U /*!< Value of the SAI1 External clock source in Hz*/ +#endif /* EXTERNAL_SAI1_CLOCK_VALUE */ + +/** + * @brief External clock source for SAI2 peripheral + * This value is used by the RCC HAL module to compute the SAI1 & SAI2 clock source + * frequency. + */ +#if !defined(EXTERNAL_SAI2_CLOCK_VALUE) + #define EXTERNAL_SAI2_CLOCK_VALUE 48000U /*!< Value of the SAI2 External clock source in Hz*/ +#endif /* EXTERNAL_SAI2_CLOCK_VALUE */ + +/* Tip: To avoid modifying this file each time you need to use different HSE, + === you can define the HSE value in your toolchain compiler preprocessor. */ + +/* ########################### System Configuration ######################### */ +/** + * @brief This is the HAL system configuration section + */ +#define VDD_VALUE 3300U /*!< Value of VDD in mv */ +#define TICK_INT_PRIORITY 0x0FU /*!< tick interrupt priority */ +#define USE_RTOS 0U +#define PREFETCH_ENABLE 0U +#define INSTRUCTION_CACHE_ENABLE 1U +#define DATA_CACHE_ENABLE 1U + +/* ########################## Assert Selection ############################## */ +/** + * @brief Uncomment the line below to expanse the "assert_param" macro in the + * HAL drivers code + */ +/* #define USE_FULL_ASSERT 1U */ + +/* ################## Register callback feature configuration ############### */ +/** + * @brief Set below the peripheral configuration to "1U" to add the support + * of HAL callback registration/deregistration feature for the HAL + * driver(s). This allows user application to provide specific callback + * functions thanks to HAL_PPP_RegisterCallback() rather than overwriting + * the default weak callback functions (see each stm32l4xx_hal_ppp.h file + * for possible callback identifiers defined in HAL_PPP_CallbackIDTypeDef + * for each PPP peripheral). + */ +#define USE_HAL_ADC_REGISTER_CALLBACKS 0U +#define USE_HAL_CAN_REGISTER_CALLBACKS 0U +#define USE_HAL_COMP_REGISTER_CALLBACKS 0U +#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U +#define USE_HAL_DAC_REGISTER_CALLBACKS 0U +#define USE_HAL_DCMI_REGISTER_CALLBACKS 0U +#define USE_HAL_DFSDM_REGISTER_CALLBACKS 0U +#define USE_HAL_DMA2D_REGISTER_CALLBACKS 0U +#define USE_HAL_DSI_REGISTER_CALLBACKS 0U +#define USE_HAL_GFXMMU_REGISTER_CALLBACKS 0U +#define USE_HAL_HASH_REGISTER_CALLBACKS 0U +#define USE_HAL_HCD_REGISTER_CALLBACKS 0U +#define USE_HAL_I2C_REGISTER_CALLBACKS 0U +#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U +#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U +#define USE_HAL_LTDC_REGISTER_CALLBACKS 0U +#define USE_HAL_MMC_REGISTER_CALLBACKS 0U +#define USE_HAL_OPAMP_REGISTER_CALLBACKS 0U +#define USE_HAL_OSPI_REGISTER_CALLBACKS 0U +#define USE_HAL_PCD_REGISTER_CALLBACKS 0U +#define USE_HAL_QSPI_REGISTER_CALLBACKS 0U +#define USE_HAL_RNG_REGISTER_CALLBACKS 0U +#define USE_HAL_RTC_REGISTER_CALLBACKS 0U +#define USE_HAL_SAI_REGISTER_CALLBACKS 0U +#define USE_HAL_SD_REGISTER_CALLBACKS 0U +#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U +#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U +#define USE_HAL_SPI_REGISTER_CALLBACKS 0U +#define USE_HAL_SWPMI_REGISTER_CALLBACKS 0U +#define USE_HAL_TIM_REGISTER_CALLBACKS 0U +#define USE_HAL_TSC_REGISTER_CALLBACKS 0U +#define USE_HAL_UART_REGISTER_CALLBACKS 0U +#define USE_HAL_USART_REGISTER_CALLBACKS 0U +#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U + +/* ################## SPI peripheral configuration ########################## */ + +/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver + * Activated: CRC code is present inside driver + * Deactivated: CRC code cleaned from driver + */ + +#define USE_SPI_CRC 1U + +/* Includes ------------------------------------------------------------------*/ +/** + * @brief Include module's header file + */ + +#ifdef HAL_RCC_MODULE_ENABLED + #include "stm32l4xx_hal_rcc.h" +#endif /* HAL_RCC_MODULE_ENABLED */ + +#ifdef HAL_GPIO_MODULE_ENABLED + #include "stm32l4xx_hal_gpio.h" +#endif /* HAL_GPIO_MODULE_ENABLED */ + +#ifdef HAL_DMA_MODULE_ENABLED + #include "stm32l4xx_hal_dma.h" +#endif /* HAL_DMA_MODULE_ENABLED */ + +#ifdef HAL_DFSDM_MODULE_ENABLED + #include "stm32l4xx_hal_dfsdm.h" +#endif /* HAL_DFSDM_MODULE_ENABLED */ + +#ifdef HAL_CORTEX_MODULE_ENABLED + #include "stm32l4xx_hal_cortex.h" +#endif /* HAL_CORTEX_MODULE_ENABLED */ + +#ifdef HAL_ADC_MODULE_ENABLED + #include "stm32l4xx_hal_adc.h" +#endif /* HAL_ADC_MODULE_ENABLED */ + +#ifdef HAL_CAN_MODULE_ENABLED + #include "stm32l4xx_hal_can.h" +#endif /* HAL_CAN_MODULE_ENABLED */ + +#ifdef HAL_CAN_LEGACY_MODULE_ENABLED + #include "Legacy/stm32l4xx_hal_can_legacy.h" +#endif /* HAL_CAN_LEGACY_MODULE_ENABLED */ + +#ifdef HAL_COMP_MODULE_ENABLED + #include "stm32l4xx_hal_comp.h" +#endif /* HAL_COMP_MODULE_ENABLED */ + +#ifdef HAL_CRC_MODULE_ENABLED + #include "stm32l4xx_hal_crc.h" +#endif /* HAL_CRC_MODULE_ENABLED */ + +#ifdef HAL_CRYP_MODULE_ENABLED + #include "stm32l4xx_hal_cryp.h" +#endif /* HAL_CRYP_MODULE_ENABLED */ + +#ifdef HAL_DAC_MODULE_ENABLED + #include "stm32l4xx_hal_dac.h" +#endif /* HAL_DAC_MODULE_ENABLED */ + +#ifdef HAL_DCMI_MODULE_ENABLED + #include "stm32l4xx_hal_dcmi.h" +#endif /* HAL_DCMI_MODULE_ENABLED */ + +#ifdef HAL_DMA2D_MODULE_ENABLED + #include "stm32l4xx_hal_dma2d.h" +#endif /* HAL_DMA2D_MODULE_ENABLED */ + +#ifdef HAL_DSI_MODULE_ENABLED + #include "stm32l4xx_hal_dsi.h" +#endif /* HAL_DSI_MODULE_ENABLED */ + +#ifdef HAL_EXTI_MODULE_ENABLED + #include "stm32l4xx_hal_exti.h" +#endif /* HAL_EXTI_MODULE_ENABLED */ + +#ifdef HAL_GFXMMU_MODULE_ENABLED + #include "stm32l4xx_hal_gfxmmu.h" +#endif /* HAL_GFXMMU_MODULE_ENABLED */ + +#ifdef HAL_FIREWALL_MODULE_ENABLED + #include "stm32l4xx_hal_firewall.h" +#endif /* HAL_FIREWALL_MODULE_ENABLED */ + +#ifdef HAL_FLASH_MODULE_ENABLED + #include "stm32l4xx_hal_flash.h" +#endif /* HAL_FLASH_MODULE_ENABLED */ + +#ifdef HAL_HASH_MODULE_ENABLED + #include "stm32l4xx_hal_hash.h" +#endif /* HAL_HASH_MODULE_ENABLED */ + +#ifdef HAL_HCD_MODULE_ENABLED + #include "stm32l4xx_hal_hcd.h" +#endif /* HAL_HCD_MODULE_ENABLED */ + +#ifdef HAL_I2C_MODULE_ENABLED + #include "stm32l4xx_hal_i2c.h" +#endif /* HAL_I2C_MODULE_ENABLED */ + +#ifdef HAL_IRDA_MODULE_ENABLED + #include "stm32l4xx_hal_irda.h" +#endif /* HAL_IRDA_MODULE_ENABLED */ + +#ifdef HAL_IWDG_MODULE_ENABLED + #include "stm32l4xx_hal_iwdg.h" +#endif /* HAL_IWDG_MODULE_ENABLED */ + +#ifdef HAL_LCD_MODULE_ENABLED + #include "stm32l4xx_hal_lcd.h" +#endif /* HAL_LCD_MODULE_ENABLED */ + +#ifdef HAL_LPTIM_MODULE_ENABLED + #include "stm32l4xx_hal_lptim.h" +#endif /* HAL_LPTIM_MODULE_ENABLED */ + +#ifdef HAL_LTDC_MODULE_ENABLED + #include "stm32l4xx_hal_ltdc.h" +#endif /* HAL_LTDC_MODULE_ENABLED */ + +#ifdef HAL_MMC_MODULE_ENABLED + #include "stm32l4xx_hal_mmc.h" +#endif /* HAL_MMC_MODULE_ENABLED */ + +#ifdef HAL_NAND_MODULE_ENABLED + #include "stm32l4xx_hal_nand.h" +#endif /* HAL_NAND_MODULE_ENABLED */ + +#ifdef HAL_NOR_MODULE_ENABLED + #include "stm32l4xx_hal_nor.h" +#endif /* HAL_NOR_MODULE_ENABLED */ + +#ifdef HAL_OPAMP_MODULE_ENABLED + #include "stm32l4xx_hal_opamp.h" +#endif /* HAL_OPAMP_MODULE_ENABLED */ + +#ifdef HAL_OSPI_MODULE_ENABLED + #include "stm32l4xx_hal_ospi.h" +#endif /* HAL_OSPI_MODULE_ENABLED */ + +#ifdef HAL_PCD_MODULE_ENABLED + #include "stm32l4xx_hal_pcd.h" +#endif /* HAL_PCD_MODULE_ENABLED */ + +#ifdef HAL_PWR_MODULE_ENABLED + #include "stm32l4xx_hal_pwr.h" +#endif /* HAL_PWR_MODULE_ENABLED */ + +#ifdef HAL_QSPI_MODULE_ENABLED + #include "stm32l4xx_hal_qspi.h" +#endif /* HAL_QSPI_MODULE_ENABLED */ + +#ifdef HAL_RNG_MODULE_ENABLED + #include "stm32l4xx_hal_rng.h" +#endif /* HAL_RNG_MODULE_ENABLED */ + +#ifdef HAL_RTC_MODULE_ENABLED + #include "stm32l4xx_hal_rtc.h" +#endif /* HAL_RTC_MODULE_ENABLED */ + +#ifdef HAL_SAI_MODULE_ENABLED + #include "stm32l4xx_hal_sai.h" +#endif /* HAL_SAI_MODULE_ENABLED */ + +#ifdef HAL_SD_MODULE_ENABLED + #include "stm32l4xx_hal_sd.h" +#endif /* HAL_SD_MODULE_ENABLED */ + +#ifdef HAL_SMARTCARD_MODULE_ENABLED + #include "stm32l4xx_hal_smartcard.h" +#endif /* HAL_SMARTCARD_MODULE_ENABLED */ + +#ifdef HAL_SMBUS_MODULE_ENABLED + #include "stm32l4xx_hal_smbus.h" +#endif /* HAL_SMBUS_MODULE_ENABLED */ + +#ifdef HAL_SPI_MODULE_ENABLED + #include "stm32l4xx_hal_spi.h" +#endif /* HAL_SPI_MODULE_ENABLED */ + +#ifdef HAL_SRAM_MODULE_ENABLED + #include "stm32l4xx_hal_sram.h" +#endif /* HAL_SRAM_MODULE_ENABLED */ + +#ifdef HAL_SWPMI_MODULE_ENABLED + #include "stm32l4xx_hal_swpmi.h" +#endif /* HAL_SWPMI_MODULE_ENABLED */ + +#ifdef HAL_TIM_MODULE_ENABLED + #include "stm32l4xx_hal_tim.h" +#endif /* HAL_TIM_MODULE_ENABLED */ + +#ifdef HAL_TSC_MODULE_ENABLED + #include "stm32l4xx_hal_tsc.h" +#endif /* HAL_TSC_MODULE_ENABLED */ + +#ifdef HAL_UART_MODULE_ENABLED + #include "stm32l4xx_hal_uart.h" +#endif /* HAL_UART_MODULE_ENABLED */ + +#ifdef HAL_USART_MODULE_ENABLED + #include "stm32l4xx_hal_usart.h" +#endif /* HAL_USART_MODULE_ENABLED */ + +#ifdef HAL_WWDG_MODULE_ENABLED + #include "stm32l4xx_hal_wwdg.h" +#endif /* HAL_WWDG_MODULE_ENABLED */ + +/* Exported macro ------------------------------------------------------------*/ +#ifdef USE_FULL_ASSERT +/** + * @brief The assert_param macro is used for function's parameters check. + * @param expr: If expr is false, it calls assert_failed function + * which reports the name of the source file and the source + * line number of the call that failed. + * If expr is true, it returns no value. + * @retval None + */ + #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) +/* Exported functions ------------------------------------------------------- */ +void assert_failed(uint8_t *file, uint32_t line); +#else + #define assert_param(expr) ((void)0U) +#endif /* USE_FULL_ASSERT */ + +#ifdef __cplusplus +} +#endif + +// CircuitPython specific conditionals. Using a value is better than checking +// defined because undefined variable happen when a file isn't included when it +// should have been. +#define CPY_STM32F4 0 +#define CPY_STM32F7 0 +#define CPY_STM32H7 0 +#define CPY_STM32L4 1 + +#endif /* STM32L4xx_HAL_CONF_H */ + + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/ports/stm/mpconfigport.h b/ports/stm/mpconfigport.h index 4ac8c20eae..94fccd53e9 100644 --- a/ports/stm/mpconfigport.h +++ b/ports/stm/mpconfigport.h @@ -51,6 +51,9 @@ extern uint8_t _ld_default_stack_size; #ifndef BOARD_NO_VBUS_SENSE #define BOARD_NO_VBUS_SENSE (0) #endif +#ifndef BOARD_NO_USB_OTG_ID_SENSE +#define BOARD_NO_USB_OTG_ID_SENSE (0) +#endif // Peripheral implementation counts #define MAX_UART 10 diff --git a/ports/stm/mpconfigport.mk b/ports/stm/mpconfigport.mk index 16c098841c..6729a747b5 100644 --- a/ports/stm/mpconfigport.mk +++ b/ports/stm/mpconfigport.mk @@ -62,4 +62,22 @@ ifeq ($(MCU_SERIES),F7) USB_NUM_ENDPOINT_PAIRS = 6 endif +ifeq ($(MCU_SERIES),L4) + # Not yet implemented common-hal modules: + CIRCUITPY_ANALOGIO ?= 0 + CIRCUITPY_AUDIOBUSIO ?= 0 + CIRCUITPY_AUDIOIO ?= 0 + CIRCUITPY_COUNTIO ?= 0 + CIRCUITPY_FREQUENCYIO ?= 0 + CIRCUITPY_I2CPERIPHERAL ?= 0 + CIRCUITPY_NEOPIXEL_WRITE ?= 0 + CIRCUITPY_NVM ?= 0 + CIRCUITPY_ROTARYIO ?= 0 + CIRCUITPY_RTC ?= 0 + # todo - this varies between devices in the series + # This slide deck https://www.st.com/content/ccc/resource/training/technical/product_training/98/89/c8/6c/3e/e9/49/79/STM32L4_Peripheral_USB.pdf/files/STM32L4_Peripheral_USB.pdf/jcr:content/translations/en.STM32L4_Peripheral_USB.pdf + # cites 16 endpoints, 8 endpoint pairs, while section 3.39 of the L4R5 datasheet states 6 endpoint pairs. + USB_NUM_ENDPOINT_PAIRS = 6 +endif + CIRCUITPY_PARALLELDISPLAY := 0 diff --git a/ports/stm/packages/WLCSP144.c b/ports/stm/packages/WLCSP144.c new file mode 100644 index 0000000000..a08d160863 --- /dev/null +++ b/ports/stm/packages/WLCSP144.c @@ -0,0 +1,159 @@ +#include "shared-bindings/microcontroller/__init__.h" +#include "common-hal/microcontroller/Pin.h" +#include "py/obj.h" + +STATIC const mp_rom_map_elem_t mcu_pin_globals_table[] = { +// Pins 1-36 + { MP_ROM_QSTR(MP_QSTR_PE02), MP_ROM_PTR(&pin_PE02) }, + { MP_ROM_QSTR(MP_QSTR_PE03), MP_ROM_PTR(&pin_PE03) }, + { MP_ROM_QSTR(MP_QSTR_PE04), MP_ROM_PTR(&pin_PE04) }, + { MP_ROM_QSTR(MP_QSTR_PE05), MP_ROM_PTR(&pin_PE05) }, + { MP_ROM_QSTR(MP_QSTR_PE06), MP_ROM_PTR(&pin_PE06) }, + /* VBAT -------------------------------------------*/ + { MP_ROM_QSTR(MP_QSTR_PC13), MP_ROM_PTR(&pin_PC13) }, + // PC14 OSC32_IN ----------------------------------*/ + // PC15 OSC32_OUT ---------------------------------*/ + { MP_ROM_QSTR(MP_QSTR_PF00), MP_ROM_PTR(&pin_PF00) }, + { MP_ROM_QSTR(MP_QSTR_PF01), MP_ROM_PTR(&pin_PF01) }, + { MP_ROM_QSTR(MP_QSTR_PF02), MP_ROM_PTR(&pin_PF02) }, + { MP_ROM_QSTR(MP_QSTR_PF03), MP_ROM_PTR(&pin_PF03) }, + { MP_ROM_QSTR(MP_QSTR_PF04), MP_ROM_PTR(&pin_PF04) }, + { MP_ROM_QSTR(MP_QSTR_PF05), MP_ROM_PTR(&pin_PF05) }, + // VSS --------------------------------------------*/ + // VDD --------------------------------------------*/ + { MP_ROM_QSTR(MP_QSTR_PF06), MP_ROM_PTR(&pin_PF06) }, + { MP_ROM_QSTR(MP_QSTR_PF07), MP_ROM_PTR(&pin_PF07) }, + { MP_ROM_QSTR(MP_QSTR_PF08), MP_ROM_PTR(&pin_PF08) }, + { MP_ROM_QSTR(MP_QSTR_PF09), MP_ROM_PTR(&pin_PF09) }, + { MP_ROM_QSTR(MP_QSTR_PF10), MP_ROM_PTR(&pin_PF10) }, + // PH0 OSC_IN -------------------------------------*/ + // PH1 OSC_OUT ------------------------------------*/ + // NRST -------------------------------------------*/ + { MP_ROM_QSTR(MP_QSTR_PC00), MP_ROM_PTR(&pin_PC00) }, + { MP_ROM_QSTR(MP_QSTR_PC01), MP_ROM_PTR(&pin_PC01) }, + { MP_ROM_QSTR(MP_QSTR_PC02), MP_ROM_PTR(&pin_PC02) }, + { MP_ROM_QSTR(MP_QSTR_PC03), MP_ROM_PTR(&pin_PC03) }, + // VDD --------------------------------------------*/ + // VSSA -------------------------------------------*/ + // VREF+ ------------------------------------------*/ + // VDDA -------------------------------------------*/ + { MP_ROM_QSTR(MP_QSTR_PA00), MP_ROM_PTR(&pin_PA00) }, + { MP_ROM_QSTR(MP_QSTR_PA01), MP_ROM_PTR(&pin_PA01) }, + { MP_ROM_QSTR(MP_QSTR_PA02), MP_ROM_PTR(&pin_PA02) }, + +// Pins 37-72 + { MP_ROM_QSTR(MP_QSTR_PA03), MP_ROM_PTR(&pin_PA03) }, + // VSS --------------------------------------------*/ + // VDD --------------------------------------------*/ + { MP_ROM_QSTR(MP_QSTR_PA04), MP_ROM_PTR(&pin_PA04) }, + { MP_ROM_QSTR(MP_QSTR_PA05), MP_ROM_PTR(&pin_PA05) }, + { MP_ROM_QSTR(MP_QSTR_PA06), MP_ROM_PTR(&pin_PA06) }, + { MP_ROM_QSTR(MP_QSTR_PA07), MP_ROM_PTR(&pin_PA07) }, + { MP_ROM_QSTR(MP_QSTR_PC04), MP_ROM_PTR(&pin_PC04) }, + { MP_ROM_QSTR(MP_QSTR_PC05), MP_ROM_PTR(&pin_PC05) }, + { MP_ROM_QSTR(MP_QSTR_PB00), MP_ROM_PTR(&pin_PB00) }, + { MP_ROM_QSTR(MP_QSTR_PB01), MP_ROM_PTR(&pin_PB01) }, + { MP_ROM_QSTR(MP_QSTR_PB02), MP_ROM_PTR(&pin_PB02) }, + { MP_ROM_QSTR(MP_QSTR_PF11), MP_ROM_PTR(&pin_PF11) }, + { MP_ROM_QSTR(MP_QSTR_PF12), MP_ROM_PTR(&pin_PF12) }, + // VSS --------------------------------------------*/ + // VDD --------------------------------------------*/ + { MP_ROM_QSTR(MP_QSTR_PF13), MP_ROM_PTR(&pin_PF13) }, + { MP_ROM_QSTR(MP_QSTR_PF14), MP_ROM_PTR(&pin_PF14) }, + { MP_ROM_QSTR(MP_QSTR_PF15), MP_ROM_PTR(&pin_PF15) }, + { MP_ROM_QSTR(MP_QSTR_PG00), MP_ROM_PTR(&pin_PG00) }, + { MP_ROM_QSTR(MP_QSTR_PG01), MP_ROM_PTR(&pin_PG01) }, + { MP_ROM_QSTR(MP_QSTR_PE07), MP_ROM_PTR(&pin_PE07) }, + { MP_ROM_QSTR(MP_QSTR_PE08), MP_ROM_PTR(&pin_PE08) }, + { MP_ROM_QSTR(MP_QSTR_PE09), MP_ROM_PTR(&pin_PE09) }, + // VSS --------------------------------------------*/ + // VDD --------------------------------------------*/ + { MP_ROM_QSTR(MP_QSTR_PE10), MP_ROM_PTR(&pin_PE10) }, + { MP_ROM_QSTR(MP_QSTR_PE11), MP_ROM_PTR(&pin_PE11) }, + { MP_ROM_QSTR(MP_QSTR_PE12), MP_ROM_PTR(&pin_PE12) }, + { MP_ROM_QSTR(MP_QSTR_PE13), MP_ROM_PTR(&pin_PE13) }, + { MP_ROM_QSTR(MP_QSTR_PE14), MP_ROM_PTR(&pin_PE14) }, + { MP_ROM_QSTR(MP_QSTR_PE15), MP_ROM_PTR(&pin_PE15) }, + { MP_ROM_QSTR(MP_QSTR_PB10), MP_ROM_PTR(&pin_PB10) }, + { MP_ROM_QSTR(MP_QSTR_PB11), MP_ROM_PTR(&pin_PB11) }, + // VCAP1 ------------------------------------------*/ + // VDD --------------------------------------------*/ + +// Pins 73-108 + { MP_ROM_QSTR(MP_QSTR_PB12), MP_ROM_PTR(&pin_PB12) }, + { MP_ROM_QSTR(MP_QSTR_PB13), MP_ROM_PTR(&pin_PB13) }, + { MP_ROM_QSTR(MP_QSTR_PB14), MP_ROM_PTR(&pin_PB14) }, + { MP_ROM_QSTR(MP_QSTR_PB15), MP_ROM_PTR(&pin_PB15) }, + { MP_ROM_QSTR(MP_QSTR_PD08), MP_ROM_PTR(&pin_PD08) }, + { MP_ROM_QSTR(MP_QSTR_PD09), MP_ROM_PTR(&pin_PD09) }, + { MP_ROM_QSTR(MP_QSTR_PD10), MP_ROM_PTR(&pin_PD10) }, + { MP_ROM_QSTR(MP_QSTR_PD11), MP_ROM_PTR(&pin_PD11) }, + { MP_ROM_QSTR(MP_QSTR_PD12), MP_ROM_PTR(&pin_PD12) }, + { MP_ROM_QSTR(MP_QSTR_PD13), MP_ROM_PTR(&pin_PD13) }, + // VSS --------------------------------------------*/ + // VDD --------------------------------------------*/ + { MP_ROM_QSTR(MP_QSTR_PD14), MP_ROM_PTR(&pin_PD14) }, + { MP_ROM_QSTR(MP_QSTR_PD15), MP_ROM_PTR(&pin_PD15) }, + { MP_ROM_QSTR(MP_QSTR_PG02), MP_ROM_PTR(&pin_PG02) }, + { MP_ROM_QSTR(MP_QSTR_PG03), MP_ROM_PTR(&pin_PG03) }, + { MP_ROM_QSTR(MP_QSTR_PG04), MP_ROM_PTR(&pin_PG04) }, + { MP_ROM_QSTR(MP_QSTR_PG05), MP_ROM_PTR(&pin_PG05) }, + { MP_ROM_QSTR(MP_QSTR_PG06), MP_ROM_PTR(&pin_PG06) }, + { MP_ROM_QSTR(MP_QSTR_PG07), MP_ROM_PTR(&pin_PG07) }, + { MP_ROM_QSTR(MP_QSTR_PG08), MP_ROM_PTR(&pin_PG08) }, + // VSS --------------------------------------------*/ + // VDD or VDD_USB (F412, F446) --------------------*/ + { MP_ROM_QSTR(MP_QSTR_PC06), MP_ROM_PTR(&pin_PC06) }, + { MP_ROM_QSTR(MP_QSTR_PC07), MP_ROM_PTR(&pin_PC07) }, + { MP_ROM_QSTR(MP_QSTR_PC08), MP_ROM_PTR(&pin_PC08) }, + { MP_ROM_QSTR(MP_QSTR_PC09), MP_ROM_PTR(&pin_PC09) }, + { MP_ROM_QSTR(MP_QSTR_PA08), MP_ROM_PTR(&pin_PA08) }, + { MP_ROM_QSTR(MP_QSTR_PA09), MP_ROM_PTR(&pin_PA09) }, + { MP_ROM_QSTR(MP_QSTR_PA10), MP_ROM_PTR(&pin_PA10) }, + { MP_ROM_QSTR(MP_QSTR_PA11), MP_ROM_PTR(&pin_PA11) }, + { MP_ROM_QSTR(MP_QSTR_PA12), MP_ROM_PTR(&pin_PA12) }, + { MP_ROM_QSTR(MP_QSTR_PA13), MP_ROM_PTR(&pin_PA13) }, + // VCAP2 ------------------------------------------*/ + // VSS --------------------------------------------*/ + // VDD --------------------------------------------*/ + +// Pins 109-144 + { MP_ROM_QSTR(MP_QSTR_PA14), MP_ROM_PTR(&pin_PA14) }, + { MP_ROM_QSTR(MP_QSTR_PA15), MP_ROM_PTR(&pin_PA15) }, + { MP_ROM_QSTR(MP_QSTR_PC10), MP_ROM_PTR(&pin_PC10) }, + { MP_ROM_QSTR(MP_QSTR_PC11), MP_ROM_PTR(&pin_PC11) }, + { MP_ROM_QSTR(MP_QSTR_PC12), MP_ROM_PTR(&pin_PC12) }, + { MP_ROM_QSTR(MP_QSTR_PD00), MP_ROM_PTR(&pin_PD00) }, + { MP_ROM_QSTR(MP_QSTR_PD01), MP_ROM_PTR(&pin_PD01) }, + { MP_ROM_QSTR(MP_QSTR_PD02), MP_ROM_PTR(&pin_PD02) }, + { MP_ROM_QSTR(MP_QSTR_PD03), MP_ROM_PTR(&pin_PD03) }, + { MP_ROM_QSTR(MP_QSTR_PD04), MP_ROM_PTR(&pin_PD04) }, + { MP_ROM_QSTR(MP_QSTR_PD05), MP_ROM_PTR(&pin_PD05) }, + // VSS --------------------------------------------*/ + // VDD --------------------------------------------*/ + { MP_ROM_QSTR(MP_QSTR_PD06), MP_ROM_PTR(&pin_PD06) }, + { MP_ROM_QSTR(MP_QSTR_PD07), MP_ROM_PTR(&pin_PD07) }, + { MP_ROM_QSTR(MP_QSTR_PG09), MP_ROM_PTR(&pin_PG09) }, + { MP_ROM_QSTR(MP_QSTR_PG10), MP_ROM_PTR(&pin_PG10) }, + { MP_ROM_QSTR(MP_QSTR_PG11), MP_ROM_PTR(&pin_PG11) }, + { MP_ROM_QSTR(MP_QSTR_PG12), MP_ROM_PTR(&pin_PG12) }, + { MP_ROM_QSTR(MP_QSTR_PG13), MP_ROM_PTR(&pin_PG13) }, + { MP_ROM_QSTR(MP_QSTR_PG14), MP_ROM_PTR(&pin_PG14) }, + // VSS --------------------------------------------*/ + // VDD --------------------------------------------*/ + { MP_ROM_QSTR(MP_QSTR_PG15), MP_ROM_PTR(&pin_PG15) }, + { MP_ROM_QSTR(MP_QSTR_PB03), MP_ROM_PTR(&pin_PB03) }, + { MP_ROM_QSTR(MP_QSTR_PB04), MP_ROM_PTR(&pin_PB04) }, + { MP_ROM_QSTR(MP_QSTR_PB05), MP_ROM_PTR(&pin_PB05) }, + { MP_ROM_QSTR(MP_QSTR_PB06), MP_ROM_PTR(&pin_PB06) }, + { MP_ROM_QSTR(MP_QSTR_PB07), MP_ROM_PTR(&pin_PB07) }, + // BOOT0 ------------------------------------------*/ + { MP_ROM_QSTR(MP_QSTR_PB08), MP_ROM_PTR(&pin_PB08) }, + { MP_ROM_QSTR(MP_QSTR_PB09), MP_ROM_PTR(&pin_PB09) }, + { MP_ROM_QSTR(MP_QSTR_PE00), MP_ROM_PTR(&pin_PE00) }, + { MP_ROM_QSTR(MP_QSTR_PE01), MP_ROM_PTR(&pin_PE01) }, + // PDR_ON -----------------------------------------*/ + // VDD --------------------------------------------*/ + +}; +MP_DEFINE_CONST_DICT(mcu_pin_globals, mcu_pin_globals_table); diff --git a/ports/stm/peripherals/exti.c b/ports/stm/peripherals/exti.c index 3ba943a208..a161898491 100644 --- a/ports/stm/peripherals/exti.c +++ b/ports/stm/peripherals/exti.c @@ -123,6 +123,9 @@ void EXTI4_IRQHandler(void) { stm_exti_callback[4](4); } +#ifdef STM32L4 +#define PR PR1 +#endif void EXTI9_5_IRQHandler(void) { uint32_t pending = EXTI->PR; for (uint i = 5; i <= 9; i++) { @@ -140,5 +143,9 @@ void EXTI15_10_IRQHandler(void) { } } } +#ifdef STM32L4 +#undef PR +#endif + #endif diff --git a/ports/stm/peripherals/periph.h b/ports/stm/peripherals/periph.h index d9e65c2172..3957eb5280 100644 --- a/ports/stm/peripherals/periph.h +++ b/ports/stm/peripherals/periph.h @@ -91,6 +91,13 @@ typedef struct { // Foundation Lines +#ifdef STM32L4R5xx +#define HAS_DAC 1 +#define HAS_TRNG 1 +#define HAS_BASIC_TIM 1 +#include "stm32l4/stm32l4r5xx/periph.h" +#endif + #ifdef STM32F405xx #define HAS_DAC 1 #define HAS_TRNG 1 diff --git a/ports/stm/peripherals/pins.h b/ports/stm/peripherals/pins.h index 4a516864b0..5a808e00ea 100644 --- a/ports/stm/peripherals/pins.h +++ b/ports/stm/peripherals/pins.h @@ -85,6 +85,9 @@ extern const mp_obj_type_t mcu_pin_type; #ifdef STM32F412Zx #include "stm32f4/stm32f412zx/pins.h" #endif +#ifdef STM32L4R5xx +#include "stm32l4/stm32l4r5xx/pins.h" +#endif #ifdef STM32F405xx #include "stm32f4/stm32f405xx/pins.h" #endif diff --git a/ports/stm/peripherals/stm32l4/clocks.c b/ports/stm/peripherals/stm32l4/clocks.c new file mode 100644 index 0000000000..4419f751d4 --- /dev/null +++ b/ports/stm/peripherals/stm32l4/clocks.c @@ -0,0 +1,110 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Blues Wireless Contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "stm32l4xx_hal.h" +#include "supervisor/shared/safe_mode.h" +#include + +// L4 Series +#ifdef STM32L4R5xx +#include "stm32l4/stm32l4r5xx/clocks.h" +#else +#error Please add other MCUs here so that they are not silently ignored due to #define typos +#endif + +#if BOARD_HAS_HIGH_SPEED_CRYSTAL +#error HSE support needs to be added for the L4 family. +#elif !BOARD_HAS_LOW_SPEED_CRYSTAL + #error LSE clock source required +#endif + +void Error_Handler(void) { + for (;;) { + + } +} + +#define HAL_CHECK(x) if (x != HAL_OK) Error_Handler() + +void stm32_peripherals_clocks_init(void) { + + RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; + RCC_OscInitTypeDef RCC_OscInitStruct = {0}; + RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; + + // Configure LSE Drive + HAL_PWR_EnableBkUpAccess(); + __HAL_RCC_LSEDRIVE_CONFIG(RCC_LSEDRIVE_LOW); + __HAL_RCC_PWR_CLK_ENABLE(); + + /** Configure the main internal regulator output voltage + */ + if (HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1_BOOST) != HAL_OK) { + Error_Handler(); + } + + + /* Activate PLL with MSI , stabilizied via PLL by LSE */ + RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSE | RCC_OSCILLATORTYPE_MSI; + RCC_OscInitStruct.MSIState = RCC_MSI_ON; + RCC_OscInitStruct.LSEState = RCC_LSE_ON; + RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_11; + RCC_OscInitStruct.MSICalibrationValue = RCC_MSICALIBRATION_DEFAULT; + RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; + RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_MSI; + RCC_OscInitStruct.PLL.PLLM = 6; + RCC_OscInitStruct.PLL.PLLN = 30; + RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV5; + RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV2; + RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV2; + HAL_CHECK(HAL_RCC_OscConfig(&RCC_OscInitStruct)); + + /* Enable MSI Auto-calibration through LSE */ + HAL_RCCEx_EnableMSIPLLMode(); + + /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 + clocks dividers */ + RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2); + RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; + // Avoid overshoot and start with HCLK 60 MHz + RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; + RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; + RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; + HAL_CHECK(HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_3)); + + /* AHB prescaler divider at 1 as second step */ + RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK; + RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; + HAL_CHECK(HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5)); + + /* Select MSI output as USB clock source */ + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_USB | RCC_PERIPHCLK_RTC | RCC_PERIPHCLK_ADC; + PeriphClkInitStruct.UsbClockSelection = RCC_USBCLKSOURCE_MSI; + PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSE; + PeriphClkInitStruct.AdcClockSelection = RCC_ADCCLKSOURCE_SYSCLK; + HAL_CHECK(HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct)); + +} diff --git a/ports/stm/peripherals/stm32l4/stm32l4r5xx/clocks.h b/ports/stm/peripherals/stm32l4/stm32l4r5xx/clocks.h new file mode 100644 index 0000000000..ef4a866c68 --- /dev/null +++ b/ports/stm/peripherals/stm32l4/stm32l4r5xx/clocks.h @@ -0,0 +1,67 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Blues Wireless Contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "stm32l4xx_hal.h" + +// Chip: STM32L4R5 +// Line Type: Foundation Line +// Speed: 120MHz (MAX) + +// Defaults: +#ifndef CPY_CLK_VSCALE +#define CPY_CLK_VSCALE (PWR_REGULATOR_VOLTAGE_SCALE1_BOOST) // up to 120MHz +#endif +#ifndef CPY_CLK_PLLM +#define CPY_CLK_PLLM (12) +#endif +#ifndef CPY_CLK_PLLN +#define CPY_CLK_PLLN (60) +#endif +#ifndef CPY_CLK_PLLP +#define CPY_CLK_PLLP (RCC_PLLP_DIV2) +#endif +#ifndef CPY_CLK_PLLQ +#define CPY_CLK_PLLQ (2) +#endif +#ifndef CPY_CLK_AHBDIV +#define CPY_CLK_AHBDIV (RCC_SYSCLK_DIV1) +#endif +#ifndef CPY_CLK_APB1DIV +#define CPY_CLK_APB1DIV (RCC_HCLK_DIV1) +#endif +#ifndef CPY_CLK_APB2DIV +#define CPY_CLK_APB2DIV (RCC_HCLK_DIV1) +#endif +#ifndef CPY_CLK_FLASH_LATENCY +#define CPY_CLK_FLASH_LATENCY (FLASH_LATENCY_5) +#endif +#ifndef CPY_CLK_USB_USES_AUDIOPLL +#define CPY_CLK_USB_USES_AUDIOPLL (0) +#endif + +#ifndef BOARD_HAS_HIGH_SPEED_CRYSTAL +#define BOARD_HAS_HIGH_SPEED_CRYSTAL (1) +#endif diff --git a/ports/stm/peripherals/stm32l4/stm32l4r5xx/gpio.c b/ports/stm/peripherals/stm32l4/stm32l4r5xx/gpio.c new file mode 100644 index 0000000000..e8b805dcec --- /dev/null +++ b/ports/stm/peripherals/stm32l4/stm32l4r5xx/gpio.c @@ -0,0 +1,60 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Blues Wireless Contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "peripherals/gpio.h" +#include "common-hal/microcontroller/Pin.h" + +void stm32_peripherals_gpio_init(void) { + // Enable all GPIO for now + __HAL_RCC_GPIOA_CLK_ENABLE(); + __HAL_RCC_GPIOB_CLK_ENABLE(); + __HAL_RCC_GPIOC_CLK_ENABLE(); + __HAL_RCC_GPIOD_CLK_ENABLE(); + __HAL_RCC_GPIOE_CLK_ENABLE(); + __HAL_RCC_GPIOF_CLK_ENABLE(); + __HAL_RCC_GPIOG_CLK_ENABLE(); + + // These ports are not used on the Swan R5 but may need to be enabeld on other boards + // __HAL_RCC_GPIOH_CLK_ENABLE(); + // __HAL_RCC_GPIOI_CLK_ENABLE(); + + // Never reset pins + never_reset_pin_number(2,14); // PC14 OSC32_IN + never_reset_pin_number(2,15); // PC15 OSC32_OUT + never_reset_pin_number(0,13); // PA13 SWDIO + never_reset_pin_number(0,14); // PA14 SWCLK + // never_reset_pin_number(0,15); //PA15 JTDI + // never_reset_pin_number(1,3); //PB3 JTDO + // never_reset_pin_number(1,4); //PB4 JTRST + + // Port H is not included in GPIO port array + // never_reset_pin_number(5,0); //PH0 JTDO + // never_reset_pin_number(5,1); //PH1 JTRST +} + +void stm32l4_peripherals_status_led(uint8_t led, uint8_t state) { + +} diff --git a/ports/stm/peripherals/stm32l4/stm32l4r5xx/periph.c b/ports/stm/peripherals/stm32l4/stm32l4r5xx/periph.c new file mode 100644 index 0000000000..32da56f222 --- /dev/null +++ b/ports/stm/peripherals/stm32l4/stm32l4r5xx/periph.c @@ -0,0 +1,283 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Blues Wireless Contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "py/obj.h" +#include "py/mphal.h" +#include "peripherals/pins.h" +#include "peripherals/periph.h" + +I2C_TypeDef *mcu_i2c_banks[I2C_BANK_ARRAY_LEN] = {I2C1, I2C2, I2C3, I2C4}; + +const mcu_periph_obj_t mcu_i2c_sda_list[I2C_SDA_ARRAY_LEN] = { + PERIPH(3, 4, &pin_PB04), + PERIPH(1, 4, &pin_PB07), + PERIPH(4, 5, &pin_PB07), + PERIPH(1, 4, &pin_PB09), + PERIPH(4, 3, &pin_PB11), + PERIPH(2, 4, &pin_PB11), + PERIPH(2, 4, &pin_PB14), + PERIPH(3, 4, &pin_PC01), + PERIPH(3, 6, &pin_PC09), + PERIPH(4, 4, &pin_PD13), + PERIPH(2, 4, &pin_PF00), + PERIPH(4, 4, &pin_PF15), + PERIPH(3, 4, &pin_PG08), + PERIPH(1, 4, &pin_PG13), + PERIPH(2, 4, &pin_PH05), + PERIPH(3, 4, &pin_PH08), +}; + +const mcu_periph_obj_t mcu_i2c_scl_list[I2C_SCL_ARRAY_LEN] = { + PERIPH(1, 4, &pin_PB06), + PERIPH(1, 4, &pin_PG14), + PERIPH(3, 4, &pin_PA07), + PERIPH(4, 5, &pin_PB06), + PERIPH(1, 4, &pin_PB08), + PERIPH(4, 3, &pin_PB10), + PERIPH(2, 4, &pin_PB10), + PERIPH(2, 4, &pin_PB13), + PERIPH(3, 4, &pin_PC00), + PERIPH(4, 4, &pin_PD12), + PERIPH(2, 4, &pin_PF01), + PERIPH(4, 4, &pin_PF14), + PERIPH(3, 4, &pin_PG07), + PERIPH(2, 4, &pin_PH04), + PERIPH(3, 4, &pin_PH07), +}; + +SPI_TypeDef *mcu_spi_banks[SPI_BANK_ARRAY_LEN] = {SPI1, SPI2, SPI3}; + +const mcu_periph_obj_t mcu_spi_sck_list[SPI_SCK_ARRAY_LEN] = { + PERIPH(1, 5, &pin_PA01), + PERIPH(1, 5, &pin_PA05), + PERIPH(2, 3, &pin_PA09), + PERIPH(1, 5, &pin_PB03), + PERIPH(3, 6, &pin_PB03), + PERIPH(2, 5, &pin_PB10), + PERIPH(2, 5, &pin_PB13), + PERIPH(3, 6, &pin_PC10), + PERIPH(2, 5, &pin_PD01), + PERIPH(2, 3, &pin_PD03), + PERIPH(1, 5, &pin_PE13), + PERIPH(1, 5, &pin_PG02), + PERIPH(3, 6, &pin_PG09), + PERIPH(2, 5, &pin_PI01), +}; +const mcu_periph_obj_t mcu_spi_mosi_list[SPI_MOSI_ARRAY_LEN] = { + PERIPH(1, 5, &pin_PA07), + PERIPH(1, 5, &pin_PA12), + PERIPH(1, 5, &pin_PB05), + PERIPH(3, 6, &pin_PB05), + PERIPH(2, 5, &pin_PB15), + PERIPH(2, 3, &pin_PC01), + PERIPH(2, 5, &pin_PC03), + PERIPH(3, 6, &pin_PC12), + PERIPH(2, 5, &pin_PD04), + PERIPH(3, 5, &pin_PD06), + PERIPH(1, 5, &pin_PE15), + PERIPH(1, 5, &pin_PG04), + PERIPH(3, 6, &pin_PG11), + PERIPH(2, 5, &pin_PI03), +}; +const mcu_periph_obj_t mcu_spi_miso_list[SPI_MISO_ARRAY_LEN] = { + PERIPH(1, 5, &pin_PA06), + PERIPH(1, 5, &pin_PA11), + PERIPH(1, 5, &pin_PB04), + PERIPH(3, 6, &pin_PB04), + PERIPH(2, 5, &pin_PB14), + PERIPH(2, 5, &pin_PC02), + PERIPH(3, 6, &pin_PC11), + PERIPH(2, 5, &pin_PD03), + PERIPH(1, 5, &pin_PE14), + PERIPH(1, 5, &pin_PG03), + PERIPH(3, 6, &pin_PG10), + PERIPH(2, 5, &pin_PI02), +}; +const mcu_periph_obj_t mcu_spi_nss_list[SPI_NSS_ARRAY_LEN] = { + PERIPH(1, 5, &pin_PA04), + PERIPH(3, 6, &pin_PA04), + PERIPH(1, 5, &pin_PA15), + PERIPH(3, 6, &pin_PA15), + PERIPH(1, 5, &pin_PB00), + PERIPH(2, 5, &pin_PB09), + PERIPH(2, 5, &pin_PB12), + PERIPH(2, 5, &pin_PD00), + PERIPH(1, 5, &pin_PE12), + PERIPH(1, 5, &pin_PG05), + PERIPH(3, 6, &pin_PG12), + PERIPH(2, 5, &pin_PI00), +}; + +// todo - add LPUART? +USART_TypeDef *mcu_uart_banks[MAX_UART] = {USART1, USART2, USART3, UART4, UART5}; +bool mcu_uart_has_usart[MAX_UART] = {true, true, true, false, false}; + +const mcu_periph_obj_t mcu_uart_tx_list[UART_TX_ARRAY_LEN] = { + PERIPH(4, 9, &pin_PA00), + PERIPH(2, 7, &pin_PA02), + PERIPH(1, 7, &pin_PA09), + PERIPH(1, 7, &pin_PB06), + PERIPH(3, 7, &pin_PB10), + PERIPH(3, 7, &pin_PC04), + PERIPH(3, 7, &pin_PC10), + PERIPH(4, 9, &pin_PC10), + PERIPH(5, 9, &pin_PC12), + PERIPH(2, 7, &pin_PD05), + PERIPH(3, 7, &pin_PD08), + PERIPH(1, 7, &pin_PG09), +}; +const mcu_periph_obj_t mcu_uart_rx_list[UART_RX_ARRAY_LEN] = { + PERIPH(4, 9, &pin_PA01), + PERIPH(2, 7, &pin_PA03), + PERIPH(1, 7, &pin_PA10), + PERIPH(2, 3, &pin_PA15), + PERIPH(1, 7, &pin_PB07), + PERIPH(3, 7, &pin_PB11), + PERIPH(3, 7, &pin_PC05), + PERIPH(3, 7, &pin_PC11), + PERIPH(4, 9, &pin_PC11), + PERIPH(5, 9, &pin_PD02), + PERIPH(2, 7, &pin_PD06), + PERIPH(3, 7, &pin_PD09), + PERIPH(1, 7, &pin_PG10), +}; + +// Timers +// TIM6 and TIM7 are basic timers that are only used by DAC, and don't have pins +TIM_TypeDef *mcu_tim_banks[TIM_BANK_ARRAY_LEN] = {TIM1, TIM2, TIM3, TIM4, TIM5, NULL, NULL, TIM8, /*TIM9*/ NULL, NULL, NULL, NULL, NULL, NULL, TIM15, TIM16, TIM17}; + +const mcu_tim_pin_obj_t mcu_tim_pin_list[TIM_PIN_ARRAY_LEN] = { + TIM(2, 1, 1, &pin_PA00), + TIM(5, 2, 1, &pin_PA00), + TIM(2, 1, 2, &pin_PA01), + TIM(5, 2, 2, &pin_PA01), + TIM(2, 1, 3, &pin_PA02), + TIM(5, 2, 3, &pin_PA02), + TIM(15, 15, 1, &pin_PA02), + TIM(2, 1, 4, &pin_PA03), + TIM(5, 2, 4, &pin_PA03), + TIM(15, 15, 2, &pin_PA03), + TIM(2, 1, 1, &pin_PA05), + TIM(3, 2, 1, &pin_PA06), + TIM(16, 15, 1, &pin_PA06), + TIM(3, 2, 2, &pin_PA07), + // TIM(17, 15, 1, &pin_PA07), // peripheral indices are 1 based, stored 0-based with 4 bits available. + TIM(1, 1, 1, &pin_PA08), + TIM(1, 1, 2, &pin_PA09), + TIM(1, 1, 3, &pin_PA10), + TIM(1, 1, 4, &pin_PA11), + TIM(2, 1, 1, &pin_PA15), + TIM(3, 2, 3, &pin_PB00), + TIM(3, 2, 4, &pin_PB01), + TIM(2, 1, 2, &pin_PB03), + TIM(3, 2, 1, &pin_PB04), + TIM(3, 2, 2, &pin_PB05), + TIM(4, 2, 1, &pin_PB06), + TIM(4, 2, 2, &pin_PB07), + TIM(4, 2, 3, &pin_PB08), + TIM(16, 15, 1, &pin_PB08), + TIM(4, 2, 4, &pin_PB09), + // TIM(17, 15, 1, &pin_PB09), // peripheral indices are 1 based, stored 0-based with 4 bits available. + TIM(2, 1, 3, &pin_PB10), + TIM(2, 1, 4, &pin_PB11), + TIM(15, 15, 1, &pin_PB14), + TIM(15, 15, 2, &pin_PB15), + TIM(3, 2, 1, &pin_PC06), + TIM(8, 3, 1, &pin_PC06), + TIM(3, 2, 2, &pin_PC07), + TIM(8, 3, 2, &pin_PC07), + TIM(3, 2, 3, &pin_PC08), + TIM(8, 3, 3, &pin_PC08), + TIM(3, 2, 4, &pin_PC09), + TIM(8, 3, 4, &pin_PC09), + TIM(4, 2, 1, &pin_PD12), + TIM(4, 2, 2, &pin_PD13), + TIM(4, 2, 3, &pin_PD14), + TIM(4, 2, 4, &pin_PD15), + TIM(16, 15, 1, &pin_PE00), + // TIM(17, 15, 1, &pin_PE01), // peripheral indices are 1 based, stored 0-based with 4 bits available. + TIM(3, 2, 1, &pin_PE03), + TIM(3, 2, 2, &pin_PE04), + TIM(3, 2, 3, &pin_PE05), + TIM(3, 2, 4, &pin_PE06), + TIM(1, 1, 1, &pin_PE09), + TIM(1, 1, 2, &pin_PE11), + TIM(1, 1, 3, &pin_PE13), + TIM(1, 1, 4, &pin_PE14), + TIM(5, 2, 1, &pin_PF06), + TIM(5, 2, 2, &pin_PF07), + TIM(5, 2, 3, &pin_PF08), + TIM(5, 2, 4, &pin_PF09), + TIM(15, 15, 1, &pin_PF09), + TIM(15, 15, 2, &pin_PF10), + TIM(15, 15, 1, &pin_PG10), + TIM(15, 15, 2, &pin_PG11), + TIM(5, 2, 1, &pin_PH10), + TIM(5, 2, 2, &pin_PH11), + TIM(5, 2, 3, &pin_PH12), + TIM(5, 2, 4, &pin_PI00), + TIM(8, 3, 4, &pin_PI02), + TIM(8, 3, 1, &pin_PI05), + TIM(8, 3, 2, &pin_PI06), + TIM(8, 3, 3, &pin_PI07), +}; +// SDIO +// SDIO_TypeDef *mcu_sdio_banks[1] = {SDIO}; +// todo - the L4 has a SDMMC pripheral +const mcu_periph_obj_t mcu_sdio_clock_list[1] = { + PERIPH(1, 12, &pin_PC12), +}; +const mcu_periph_obj_t mcu_sdio_command_list[1] = { + PERIPH(1, 12, &pin_PD02), +}; +const mcu_periph_obj_t mcu_sdio_data0_list[1] = { + PERIPH(1, 12, &pin_PC08), +}; +const mcu_periph_obj_t mcu_sdio_data1_list[1] = { + PERIPH(1, 12, &pin_PC09), +}; +const mcu_periph_obj_t mcu_sdio_data2_list[1] = { + PERIPH(1, 12, &pin_PC10), +}; +const mcu_periph_obj_t mcu_sdio_data3_list[1] = { + PERIPH(1, 12, &pin_PC11), +}; + +// CAN +CAN_TypeDef *mcu_can_banks[] = {CAN1}; + +const mcu_periph_obj_t mcu_can_tx_list[4] = { + PERIPH(1, 10, &pin_PA12), + PERIPH(1, 10, &pin_PB09), + PERIPH(1, 10, &pin_PD01), + PERIPH(1, 10, &pin_PH13), +}; +const mcu_periph_obj_t mcu_can_rx_list[4] = { + PERIPH(1, 10, &pin_PA11), + PERIPH(1, 10, &pin_PB08), + PERIPH(1, 10, &pin_PD00), + PERIPH(1, 10, &pin_PI09), +}; diff --git a/ports/stm/peripherals/stm32l4/stm32l4r5xx/periph.h b/ports/stm/peripherals/stm32l4/stm32l4r5xx/periph.h new file mode 100644 index 0000000000..d28b6c8ea3 --- /dev/null +++ b/ports/stm/peripherals/stm32l4/stm32l4r5xx/periph.h @@ -0,0 +1,80 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Blues Wireless Contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_STM32_PERIPHERALS_STM32L4R5XX_PERIPH_H +#define MICROPY_INCLUDED_STM32_PERIPHERALS_STM32L4R5XX_PERIPH_H + +// I2C +#define I2C_BANK_ARRAY_LEN 4 +#define I2C_SDA_ARRAY_LEN 16 +#define I2C_SCL_ARRAY_LEN 15 +extern I2C_TypeDef *mcu_i2c_banks[I2C_BANK_ARRAY_LEN]; +extern const mcu_periph_obj_t mcu_i2c_sda_list[I2C_SDA_ARRAY_LEN]; +extern const mcu_periph_obj_t mcu_i2c_scl_list[I2C_SCL_ARRAY_LEN]; + +// SPI +#define SPI_BANK_ARRAY_LEN 3 +#define SPI_SCK_ARRAY_LEN 14 +#define SPI_MOSI_ARRAY_LEN 14 +#define SPI_MISO_ARRAY_LEN 12 +#define SPI_NSS_ARRAY_LEN 12 +extern SPI_TypeDef *mcu_spi_banks[SPI_BANK_ARRAY_LEN]; +extern const mcu_periph_obj_t mcu_spi_sck_list[SPI_SCK_ARRAY_LEN]; +extern const mcu_periph_obj_t mcu_spi_mosi_list[SPI_MOSI_ARRAY_LEN]; +extern const mcu_periph_obj_t mcu_spi_miso_list[SPI_MISO_ARRAY_LEN]; +extern const mcu_periph_obj_t mcu_spi_nss_list[SPI_NSS_ARRAY_LEN]; + +// UART +#define UART_TX_ARRAY_LEN 12 +#define UART_RX_ARRAY_LEN 13 +extern USART_TypeDef *mcu_uart_banks[MAX_UART]; +extern bool mcu_uart_has_usart[MAX_UART]; +extern const mcu_periph_obj_t mcu_uart_tx_list[UART_TX_ARRAY_LEN]; +extern const mcu_periph_obj_t mcu_uart_rx_list[UART_RX_ARRAY_LEN]; + +// Timers +#define TIM_BANK_ARRAY_LEN 17 +#define TIM_PIN_ARRAY_LEN (73 - 3) +extern TIM_TypeDef *mcu_tim_banks[TIM_BANK_ARRAY_LEN]; +extern const mcu_tim_pin_obj_t mcu_tim_pin_list[TIM_PIN_ARRAY_LEN]; + +// SDIO +// extern SDIO_TypeDef *mcu_sdio_banks[1]; + +// extern const mcu_periph_obj_t mcu_sdio_clock_list[1]; +// extern const mcu_periph_obj_t mcu_sdio_command_list[1]; +// extern const mcu_periph_obj_t mcu_sdio_data0_list[1]; +// extern const mcu_periph_obj_t mcu_sdio_data1_list[1]; +// extern const mcu_periph_obj_t mcu_sdio_data2_list[1]; +// extern const mcu_periph_obj_t mcu_sdio_data3_list[1]; + +// CAN +extern CAN_TypeDef *mcu_can_banks[1]; +extern const mcu_periph_obj_t mcu_can_tx_list[4]; +extern const mcu_periph_obj_t mcu_can_rx_list[4]; + + +#endif // MICROPY_INCLUDED_STM32_PERIPHERALS_STM32L4R5XX_PERIPH_H diff --git a/ports/stm/peripherals/stm32l4/stm32l4r5xx/pins.c b/ports/stm/peripherals/stm32l4/stm32l4r5xx/pins.c new file mode 100644 index 0000000000..e6ef178c52 --- /dev/null +++ b/ports/stm/peripherals/stm32l4/stm32l4r5xx/pins.c @@ -0,0 +1,172 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Blues Wireless Contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "py/obj.h" +#include "py/mphal.h" +#include "peripherals/pins.h" + +#include STM32_HAL_H + +const mcu_pin_obj_t pin_PA00 = PIN(0, 0, ADC_INPUT(ADC_1,5)); +const mcu_pin_obj_t pin_PA01 = PIN(0, 1, ADC_INPUT(ADC_1,6)); +const mcu_pin_obj_t pin_PA02 = PIN(0, 2, ADC_INPUT(ADC_1,7)); +const mcu_pin_obj_t pin_PA03 = PIN(0, 3, ADC_INPUT(ADC_1,8)); +const mcu_pin_obj_t pin_PA04 = PIN(0, 4, ADC_INPUT(ADC_1,9)); +const mcu_pin_obj_t pin_PA05 = PIN(0, 5, ADC_INPUT(ADC_1,10)); +const mcu_pin_obj_t pin_PA06 = PIN(0, 6, ADC_INPUT(ADC_1,11)); +const mcu_pin_obj_t pin_PA07 = PIN(0, 7, ADC_INPUT(ADC_1,12)); +const mcu_pin_obj_t pin_PA08 = PIN(0, 8, NO_ADC); +const mcu_pin_obj_t pin_PA09 = PIN(0, 9, NO_ADC); +const mcu_pin_obj_t pin_PA10 = PIN(0, 10, NO_ADC); +const mcu_pin_obj_t pin_PA11 = PIN(0, 11, NO_ADC); +const mcu_pin_obj_t pin_PA12 = PIN(0, 12, NO_ADC); +const mcu_pin_obj_t pin_PA13 = PIN(0, 13, NO_ADC); +const mcu_pin_obj_t pin_PA14 = PIN(0, 14, NO_ADC); +const mcu_pin_obj_t pin_PA15 = PIN(0, 15, NO_ADC); +const mcu_pin_obj_t pin_PB00 = PIN(1, 0, ADC_INPUT(ADC_1,15)); +const mcu_pin_obj_t pin_PB01 = PIN(1, 1, ADC_INPUT(ADC_1,16)); +const mcu_pin_obj_t pin_PB02 = PIN(1, 2, NO_ADC); +const mcu_pin_obj_t pin_PB03 = PIN(1, 3, NO_ADC); +const mcu_pin_obj_t pin_PB04 = PIN(1, 4, NO_ADC); +const mcu_pin_obj_t pin_PB05 = PIN(1, 5, NO_ADC); +const mcu_pin_obj_t pin_PB06 = PIN(1, 6, NO_ADC); +const mcu_pin_obj_t pin_PB07 = PIN(1, 7, NO_ADC); +const mcu_pin_obj_t pin_PB08 = PIN(1, 8, NO_ADC); +const mcu_pin_obj_t pin_PB09 = PIN(1, 9, NO_ADC); +const mcu_pin_obj_t pin_PB10 = PIN(1, 10, NO_ADC); +const mcu_pin_obj_t pin_PB11 = PIN(1, 11, NO_ADC); +const mcu_pin_obj_t pin_PB12 = PIN(1, 12, NO_ADC); +const mcu_pin_obj_t pin_PB13 = PIN(1, 13, NO_ADC); +const mcu_pin_obj_t pin_PB14 = PIN(1, 14, NO_ADC); +const mcu_pin_obj_t pin_PB15 = PIN(1, 15, NO_ADC); +const mcu_pin_obj_t pin_PC00 = PIN(2, 0, ADC_INPUT(ADC_1,1)); +const mcu_pin_obj_t pin_PC01 = PIN(2, 1, ADC_INPUT(ADC_1,2)); +const mcu_pin_obj_t pin_PC02 = PIN(2, 2, ADC_INPUT(ADC_1,3)); +const mcu_pin_obj_t pin_PC03 = PIN(2, 3, ADC_INPUT(ADC_1,4)); +const mcu_pin_obj_t pin_PC04 = PIN(2, 4, ADC_INPUT(ADC_1,13)); +const mcu_pin_obj_t pin_PC05 = PIN(2, 5, ADC_INPUT(ADC_1,14)); +const mcu_pin_obj_t pin_PC06 = PIN(2, 6, NO_ADC); +const mcu_pin_obj_t pin_PC07 = PIN(2, 7, NO_ADC); +const mcu_pin_obj_t pin_PC08 = PIN(2, 8, NO_ADC); +const mcu_pin_obj_t pin_PC09 = PIN(2, 9, NO_ADC); +const mcu_pin_obj_t pin_PC10 = PIN(2, 10, NO_ADC); +const mcu_pin_obj_t pin_PC11 = PIN(2, 11, NO_ADC); +const mcu_pin_obj_t pin_PC12 = PIN(2, 12, NO_ADC); +const mcu_pin_obj_t pin_PC13 = PIN(2, 13, NO_ADC); +const mcu_pin_obj_t pin_PC14 = PIN(2, 14, NO_ADC); +const mcu_pin_obj_t pin_PC15 = PIN(2, 15, NO_ADC); +const mcu_pin_obj_t pin_PD00 = PIN(3, 0, NO_ADC); +const mcu_pin_obj_t pin_PD01 = PIN(3, 1, NO_ADC); +const mcu_pin_obj_t pin_PD02 = PIN(3, 2, NO_ADC); +const mcu_pin_obj_t pin_PD03 = PIN(3, 3, NO_ADC); +const mcu_pin_obj_t pin_PD04 = PIN(3, 4, NO_ADC); +const mcu_pin_obj_t pin_PD05 = PIN(3, 5, NO_ADC); +const mcu_pin_obj_t pin_PD06 = PIN(3, 6, NO_ADC); +const mcu_pin_obj_t pin_PD07 = PIN(3, 7, NO_ADC); +const mcu_pin_obj_t pin_PD08 = PIN(3, 8, NO_ADC); +const mcu_pin_obj_t pin_PD09 = PIN(3, 9, NO_ADC); +const mcu_pin_obj_t pin_PD10 = PIN(3, 10, NO_ADC); +const mcu_pin_obj_t pin_PD11 = PIN(3, 11, NO_ADC); +const mcu_pin_obj_t pin_PD12 = PIN(3, 12, NO_ADC); +const mcu_pin_obj_t pin_PD13 = PIN(3, 13, NO_ADC); +const mcu_pin_obj_t pin_PD14 = PIN(3, 14, NO_ADC); +const mcu_pin_obj_t pin_PD15 = PIN(3, 15, NO_ADC); +const mcu_pin_obj_t pin_PE00 = PIN(4, 0, NO_ADC); +const mcu_pin_obj_t pin_PE01 = PIN(4, 1, NO_ADC); +const mcu_pin_obj_t pin_PE02 = PIN(4, 2, NO_ADC); +const mcu_pin_obj_t pin_PE03 = PIN(4, 3, NO_ADC); +const mcu_pin_obj_t pin_PE04 = PIN(4, 4, NO_ADC); +const mcu_pin_obj_t pin_PE05 = PIN(4, 5, NO_ADC); +const mcu_pin_obj_t pin_PE06 = PIN(4, 6, NO_ADC); +const mcu_pin_obj_t pin_PE07 = PIN(4, 7, NO_ADC); +const mcu_pin_obj_t pin_PE08 = PIN(4, 8, NO_ADC); +const mcu_pin_obj_t pin_PE09 = PIN(4, 9, NO_ADC); +const mcu_pin_obj_t pin_PE10 = PIN(4, 10, NO_ADC); +const mcu_pin_obj_t pin_PE11 = PIN(4, 11, NO_ADC); +const mcu_pin_obj_t pin_PE12 = PIN(4, 12, NO_ADC); +const mcu_pin_obj_t pin_PE13 = PIN(4, 13, NO_ADC); +const mcu_pin_obj_t pin_PE14 = PIN(4, 14, NO_ADC); +const mcu_pin_obj_t pin_PE15 = PIN(4, 15, NO_ADC); +const mcu_pin_obj_t pin_PF00 = PIN(5, 0, NO_ADC); +const mcu_pin_obj_t pin_PF01 = PIN(5, 1, NO_ADC); +const mcu_pin_obj_t pin_PF02 = PIN(5, 2, NO_ADC); +const mcu_pin_obj_t pin_PF03 = PIN(5, 3, NO_ADC); +const mcu_pin_obj_t pin_PF04 = PIN(5, 4, NO_ADC); +const mcu_pin_obj_t pin_PF05 = PIN(5, 5, NO_ADC); +const mcu_pin_obj_t pin_PF06 = PIN(5, 6, NO_ADC); +const mcu_pin_obj_t pin_PF07 = PIN(5, 7, NO_ADC); +const mcu_pin_obj_t pin_PF08 = PIN(5, 8, NO_ADC); +const mcu_pin_obj_t pin_PF09 = PIN(5, 9, NO_ADC); +const mcu_pin_obj_t pin_PF10 = PIN(5, 10, NO_ADC); +const mcu_pin_obj_t pin_PF11 = PIN(5, 11, NO_ADC); +const mcu_pin_obj_t pin_PF12 = PIN(5, 12, NO_ADC); +const mcu_pin_obj_t pin_PF13 = PIN(5, 13, NO_ADC); +const mcu_pin_obj_t pin_PF14 = PIN(5, 14, NO_ADC); +const mcu_pin_obj_t pin_PF15 = PIN(5, 15, NO_ADC); +const mcu_pin_obj_t pin_PG00 = PIN(6, 0, NO_ADC); +const mcu_pin_obj_t pin_PG01 = PIN(6, 1, NO_ADC); +const mcu_pin_obj_t pin_PG02 = PIN(6, 2, NO_ADC); +const mcu_pin_obj_t pin_PG03 = PIN(6, 3, NO_ADC); +const mcu_pin_obj_t pin_PG04 = PIN(6, 4, NO_ADC); +const mcu_pin_obj_t pin_PG05 = PIN(6, 5, NO_ADC); +const mcu_pin_obj_t pin_PG06 = PIN(6, 6, NO_ADC); +const mcu_pin_obj_t pin_PG07 = PIN(6, 7, NO_ADC); +const mcu_pin_obj_t pin_PG08 = PIN(6, 8, NO_ADC); +const mcu_pin_obj_t pin_PG09 = PIN(6, 9, NO_ADC); +const mcu_pin_obj_t pin_PG10 = PIN(6, 10, NO_ADC); +const mcu_pin_obj_t pin_PG11 = PIN(6, 11, NO_ADC); +const mcu_pin_obj_t pin_PG12 = PIN(6, 12, NO_ADC); +const mcu_pin_obj_t pin_PG13 = PIN(6, 13, NO_ADC); +const mcu_pin_obj_t pin_PG14 = PIN(6, 14, NO_ADC); +const mcu_pin_obj_t pin_PG15 = PIN(6, 15, NO_ADC); +const mcu_pin_obj_t pin_PH00 = PIN(7, 0, NO_ADC); +const mcu_pin_obj_t pin_PH01 = PIN(7, 1, NO_ADC); +const mcu_pin_obj_t pin_PH02 = PIN(7, 2, NO_ADC); +const mcu_pin_obj_t pin_PH03 = PIN(7, 3, NO_ADC); +const mcu_pin_obj_t pin_PH04 = PIN(7, 4, NO_ADC); +const mcu_pin_obj_t pin_PH05 = PIN(7, 5, NO_ADC); +const mcu_pin_obj_t pin_PH06 = PIN(7, 6, NO_ADC); +const mcu_pin_obj_t pin_PH07 = PIN(7, 7, NO_ADC); +const mcu_pin_obj_t pin_PH08 = PIN(7, 8, NO_ADC); +const mcu_pin_obj_t pin_PH09 = PIN(7, 9, NO_ADC); +const mcu_pin_obj_t pin_PH10 = PIN(7, 10, NO_ADC); +const mcu_pin_obj_t pin_PH11 = PIN(7, 11, NO_ADC); +const mcu_pin_obj_t pin_PH12 = PIN(7, 12, NO_ADC); +const mcu_pin_obj_t pin_PH13 = PIN(7, 13, NO_ADC); +const mcu_pin_obj_t pin_PH14 = PIN(7, 14, NO_ADC); +const mcu_pin_obj_t pin_PH15 = PIN(7, 15, NO_ADC); +const mcu_pin_obj_t pin_PI00 = PIN(8, 0, NO_ADC); +const mcu_pin_obj_t pin_PI01 = PIN(8, 1, NO_ADC); +const mcu_pin_obj_t pin_PI02 = PIN(8, 2, NO_ADC); +const mcu_pin_obj_t pin_PI03 = PIN(8, 3, NO_ADC); +const mcu_pin_obj_t pin_PI04 = PIN(8, 4, NO_ADC); +const mcu_pin_obj_t pin_PI05 = PIN(8, 5, NO_ADC); +const mcu_pin_obj_t pin_PI06 = PIN(8, 6, NO_ADC); +const mcu_pin_obj_t pin_PI07 = PIN(8, 7, NO_ADC); +const mcu_pin_obj_t pin_PI08 = PIN(8, 8, NO_ADC); +const mcu_pin_obj_t pin_PI09 = PIN(8, 9, NO_ADC); +const mcu_pin_obj_t pin_PI10 = PIN(8, 10, NO_ADC); +const mcu_pin_obj_t pin_PI11 = PIN(8, 11, NO_ADC); diff --git a/ports/stm/peripherals/stm32l4/stm32l4r5xx/pins.h b/ports/stm/peripherals/stm32l4/stm32l4r5xx/pins.h new file mode 100644 index 0000000000..86416cab31 --- /dev/null +++ b/ports/stm/peripherals/stm32l4/stm32l4r5xx/pins.h @@ -0,0 +1,171 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2021 Blues Wireless Contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_STM32_PERIPHERALS_STM32L4R5XX_PINS_H +#define MICROPY_INCLUDED_STM32_PERIPHERALS_STM32L4R5XX_PINS_H + +extern const mcu_pin_obj_t pin_PA00; +extern const mcu_pin_obj_t pin_PA01; +extern const mcu_pin_obj_t pin_PA02; +extern const mcu_pin_obj_t pin_PA03; +extern const mcu_pin_obj_t pin_PA04; +extern const mcu_pin_obj_t pin_PA05; +extern const mcu_pin_obj_t pin_PA06; +extern const mcu_pin_obj_t pin_PA07; +extern const mcu_pin_obj_t pin_PA08; +extern const mcu_pin_obj_t pin_PA09; +extern const mcu_pin_obj_t pin_PA10; +extern const mcu_pin_obj_t pin_PA11; +extern const mcu_pin_obj_t pin_PA12; +extern const mcu_pin_obj_t pin_PA13; +extern const mcu_pin_obj_t pin_PA14; +extern const mcu_pin_obj_t pin_PA15; +extern const mcu_pin_obj_t pin_PB00; +extern const mcu_pin_obj_t pin_PB01; +extern const mcu_pin_obj_t pin_PB02; +extern const mcu_pin_obj_t pin_PB03; +extern const mcu_pin_obj_t pin_PB04; +extern const mcu_pin_obj_t pin_PB05; +extern const mcu_pin_obj_t pin_PB06; +extern const mcu_pin_obj_t pin_PB07; +extern const mcu_pin_obj_t pin_PB08; +extern const mcu_pin_obj_t pin_PB09; +extern const mcu_pin_obj_t pin_PB10; +extern const mcu_pin_obj_t pin_PB11; +extern const mcu_pin_obj_t pin_PB12; +extern const mcu_pin_obj_t pin_PB13; +extern const mcu_pin_obj_t pin_PB14; +extern const mcu_pin_obj_t pin_PB15; +extern const mcu_pin_obj_t pin_PC00; +extern const mcu_pin_obj_t pin_PC01; +extern const mcu_pin_obj_t pin_PC02; +extern const mcu_pin_obj_t pin_PC03; +extern const mcu_pin_obj_t pin_PC04; +extern const mcu_pin_obj_t pin_PC05; +extern const mcu_pin_obj_t pin_PC06; +extern const mcu_pin_obj_t pin_PC07; +extern const mcu_pin_obj_t pin_PC08; +extern const mcu_pin_obj_t pin_PC09; +extern const mcu_pin_obj_t pin_PC10; +extern const mcu_pin_obj_t pin_PC11; +extern const mcu_pin_obj_t pin_PC12; +extern const mcu_pin_obj_t pin_PC13; +extern const mcu_pin_obj_t pin_PC14; +extern const mcu_pin_obj_t pin_PC15; +extern const mcu_pin_obj_t pin_PD00; +extern const mcu_pin_obj_t pin_PD01; +extern const mcu_pin_obj_t pin_PD02; +extern const mcu_pin_obj_t pin_PD03; +extern const mcu_pin_obj_t pin_PD04; +extern const mcu_pin_obj_t pin_PD05; +extern const mcu_pin_obj_t pin_PD06; +extern const mcu_pin_obj_t pin_PD07; +extern const mcu_pin_obj_t pin_PD08; +extern const mcu_pin_obj_t pin_PD09; +extern const mcu_pin_obj_t pin_PD10; +extern const mcu_pin_obj_t pin_PD11; +extern const mcu_pin_obj_t pin_PD12; +extern const mcu_pin_obj_t pin_PD13; +extern const mcu_pin_obj_t pin_PD14; +extern const mcu_pin_obj_t pin_PD15; +extern const mcu_pin_obj_t pin_PE00; +extern const mcu_pin_obj_t pin_PE01; +extern const mcu_pin_obj_t pin_PE02; +extern const mcu_pin_obj_t pin_PE03; +extern const mcu_pin_obj_t pin_PE04; +extern const mcu_pin_obj_t pin_PE05; +extern const mcu_pin_obj_t pin_PE06; +extern const mcu_pin_obj_t pin_PE07; +extern const mcu_pin_obj_t pin_PE08; +extern const mcu_pin_obj_t pin_PE09; +extern const mcu_pin_obj_t pin_PE10; +extern const mcu_pin_obj_t pin_PE11; +extern const mcu_pin_obj_t pin_PE12; +extern const mcu_pin_obj_t pin_PE13; +extern const mcu_pin_obj_t pin_PE14; +extern const mcu_pin_obj_t pin_PE15; +extern const mcu_pin_obj_t pin_PF00; +extern const mcu_pin_obj_t pin_PF01; +extern const mcu_pin_obj_t pin_PF02; +extern const mcu_pin_obj_t pin_PF03; +extern const mcu_pin_obj_t pin_PF04; +extern const mcu_pin_obj_t pin_PF05; +extern const mcu_pin_obj_t pin_PF06; +extern const mcu_pin_obj_t pin_PF07; +extern const mcu_pin_obj_t pin_PF08; +extern const mcu_pin_obj_t pin_PF09; +extern const mcu_pin_obj_t pin_PF10; +extern const mcu_pin_obj_t pin_PF11; +extern const mcu_pin_obj_t pin_PF12; +extern const mcu_pin_obj_t pin_PF13; +extern const mcu_pin_obj_t pin_PF14; +extern const mcu_pin_obj_t pin_PF15; +extern const mcu_pin_obj_t pin_PG00; +extern const mcu_pin_obj_t pin_PG01; +extern const mcu_pin_obj_t pin_PG02; +extern const mcu_pin_obj_t pin_PG03; +extern const mcu_pin_obj_t pin_PG04; +extern const mcu_pin_obj_t pin_PG05; +extern const mcu_pin_obj_t pin_PG06; +extern const mcu_pin_obj_t pin_PG07; +extern const mcu_pin_obj_t pin_PG08; +extern const mcu_pin_obj_t pin_PG09; +extern const mcu_pin_obj_t pin_PG10; +extern const mcu_pin_obj_t pin_PG11; +extern const mcu_pin_obj_t pin_PG12; +extern const mcu_pin_obj_t pin_PG13; +extern const mcu_pin_obj_t pin_PG14; +extern const mcu_pin_obj_t pin_PG15; +extern const mcu_pin_obj_t pin_PH00; +extern const mcu_pin_obj_t pin_PH01; +extern const mcu_pin_obj_t pin_PH02; +extern const mcu_pin_obj_t pin_PH03; +extern const mcu_pin_obj_t pin_PH04; +extern const mcu_pin_obj_t pin_PH05; +extern const mcu_pin_obj_t pin_PH06; +extern const mcu_pin_obj_t pin_PH07; +extern const mcu_pin_obj_t pin_PH08; +extern const mcu_pin_obj_t pin_PH09; +extern const mcu_pin_obj_t pin_PH10; +extern const mcu_pin_obj_t pin_PH11; +extern const mcu_pin_obj_t pin_PH12; +extern const mcu_pin_obj_t pin_PH13; +extern const mcu_pin_obj_t pin_PH14; +extern const mcu_pin_obj_t pin_PH15; +extern const mcu_pin_obj_t pin_PI00; +extern const mcu_pin_obj_t pin_PI01; +extern const mcu_pin_obj_t pin_PI02; +extern const mcu_pin_obj_t pin_PI03; +extern const mcu_pin_obj_t pin_PI04; +extern const mcu_pin_obj_t pin_PI05; +extern const mcu_pin_obj_t pin_PI06; +extern const mcu_pin_obj_t pin_PI07; +extern const mcu_pin_obj_t pin_PI08; +extern const mcu_pin_obj_t pin_PI09; +extern const mcu_pin_obj_t pin_PI10; +extern const mcu_pin_obj_t pin_PI11; + +#endif // MICROPY_INCLUDED_STM32_PERIPHERALS_STM32L4R5XX_PINS_H diff --git a/ports/stm/peripherals/timers.c b/ports/stm/peripherals/timers.c index 24060678e4..f0054648fc 100644 --- a/ports/stm/peripherals/timers.c +++ b/ports/stm/peripherals/timers.c @@ -122,17 +122,29 @@ static size_t irq_map[] = { NULL_IRQ, #endif #ifdef TIM15 + #ifdef STM32L4 + TIM1_BRK_TIM15_IRQn, + #else TIM15_IRQn, + #endif #else NULL_IRQ, #endif #ifdef TIM16 + #ifdef STM32L4 + TIM1_UP_TIM16_IRQn, + #else TIM16_IRQn, + #endif #else NULL_IRQ, #endif #ifdef TIM17 + #ifdef STM32L4 + TIM1_TRG_COM_TIM17_IRQn + #else TIM17_IRQn, + #endif #else NULL_IRQ, #endif diff --git a/ports/stm/supervisor/internal_flash.c b/ports/stm/supervisor/internal_flash.c index 5600810138..8d8ca2e0e1 100644 --- a/ports/stm/supervisor/internal_flash.c +++ b/ports/stm/supervisor/internal_flash.c @@ -94,6 +94,16 @@ STATIC const flash_layout_t flash_layout[] = { }; STATIC uint8_t _flash_cache[0x20000] __attribute__((aligned(4))); +#elif defined(STM32L4) +// todo - the L4 devices can have different flash sizes and different page sizes +// depending upon the dual bank configuration +// This is hardcoded for the Swan R5. When support for other devices is needed more conditionals will be required +// to differentiate. +STATIC const flash_layout_t flash_layout[] = { + { 0x08000000, 0x1000, 256 }, +}; +STATIC uint8_t _flash_cache[0x1000] __attribute__((aligned(4))); + #else #error Unsupported processor #endif @@ -125,10 +135,23 @@ STATIC uint32_t get_bank(uint32_t addr) { } #endif -// Return the sector of a given flash address. uint32_t flash_get_sector_info(uint32_t addr, uint32_t *start_addr, uint32_t *size) { if (addr >= flash_layout[0].base_address) { uint32_t sector_index = 0; + if (MP_ARRAY_SIZE(flash_layout) == 1) { + sector_index = (addr - flash_layout[0].base_address) / flash_layout[0].sector_size; + if (sector_index >= flash_layout[0].sector_count) { + return 0; + } + if (start_addr) { + *start_addr = flash_layout[0].base_address + (sector_index * flash_layout[0].sector_size); + } + if (size) { + *size = flash_layout[0].sector_size; + } + return sector_index; + } + for (uint8_t i = 0; i < MP_ARRAY_SIZE(flash_layout); ++i) { for (uint8_t j = 0; j < flash_layout[i].sector_count; ++j) { uint32_t sector_start_next = flash_layout[i].base_address @@ -147,7 +170,7 @@ uint32_t flash_get_sector_info(uint32_t addr, uint32_t *start_addr, uint32_t *si } } } - return 0; + return 0; // todo dangerous - shouldn't this raise an exception? } void supervisor_flash_init(void) { @@ -169,22 +192,34 @@ void port_internal_flash_flush(void) { #if defined(STM32H7) __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_ALL_ERRORS_BANK1 | FLASH_FLAG_ALL_ERRORS_BANK2); #else - __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR | - FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR | FLASH_FLAG_PGSERR); + #ifndef FLASH_FLAG_ALL_ERRORS + #define FLASH_FLAG_ALL_ERRORS FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR | FLASH_FLAG_PGPERR | FLASH_FLAG_PGSERR + #endif + __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_ALL_ERRORS); #endif // set up for erase - FLASH_EraseInitTypeDef EraseInitStruct; + FLASH_EraseInitTypeDef EraseInitStruct = {}; + #if CPY_STM32L4 + EraseInitStruct.TypeErase = TYPEERASE_PAGES; + EraseInitStruct.Banks = FLASH_BANK_1; + #else EraseInitStruct.TypeErase = TYPEERASE_SECTORS; EraseInitStruct.VoltageRange = VOLTAGE_RANGE_3; // voltage range needs to be 2.7V to 3.6V + #endif // get the sector information uint32_t sector_size; uint32_t sector_start_addr = 0xffffffff; #if defined(STM32H7) EraseInitStruct.Banks = get_bank(_cache_flash_addr); #endif + #if CPY_STM32L4 + EraseInitStruct.Page = flash_get_sector_info(_cache_flash_addr, §or_start_addr, §or_size); + EraseInitStruct.NbPages = 1; + #else EraseInitStruct.Sector = flash_get_sector_info(_cache_flash_addr, §or_start_addr, §or_size); EraseInitStruct.NbSectors = 1; + #endif if (sector_size > sizeof(_flash_cache) || sector_start_addr == 0xffffffff) { reset_into_safe_mode(FLASH_WRITE_FAIL); } @@ -217,6 +252,19 @@ void port_internal_flash_flush(void) { cache_addr += 8; sector_start_addr += 32; } + #elif CPY_STM32L4 + // program the flash word by word + for (uint32_t i = 0; i < sector_size / 8; i++) { + if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_DOUBLEWORD, sector_start_addr, + *(uint64_t *)cache_addr) != HAL_OK) { + // error occurred during flash write + HAL_FLASH_Lock(); // lock the flash + reset_into_safe_mode(FLASH_WRITE_FAIL); + } + // RAM memory is by word (4 byte), but flash memory is by byte + cache_addr += 2; + sector_start_addr += 8; + } #else // STM32F4 // program the flash word by word @@ -236,6 +284,7 @@ void port_internal_flash_flush(void) { // lock the flash HAL_FLASH_Lock(); } + } static uint32_t convert_block_to_flash_addr(uint32_t block) { diff --git a/ports/stm/supervisor/internal_flash.h b/ports/stm/supervisor/internal_flash.h index 106ff6c540..4df4e9ddbc 100644 --- a/ports/stm/supervisor/internal_flash.h +++ b/ports/stm/supervisor/internal_flash.h @@ -86,6 +86,12 @@ #define INTERNAL_FLASH_FILESYSTEM_START_ADDR 0x08020000 #endif +#ifdef STM32L4R5xx +#define STM32_FLASH_SIZE 0x100000 // 1MB // for now just use the first bank +#define INTERNAL_FLASH_FILESYSTEM_SIZE 0x20000 // 128KiB +#define INTERNAL_FLASH_FILESYSTEM_START_ADDR 0x080e0000 +#endif + #define INTERNAL_FLASH_FILESYSTEM_NUM_BLOCKS (INTERNAL_FLASH_FILESYSTEM_SIZE / FILESYSTEM_BLOCK_SIZE) #define STM32_FLASH_OFFSET 0x8000000 // All STM32 chips map to this flash location diff --git a/ports/stm/supervisor/port.c b/ports/stm/supervisor/port.c index 9dc6eeb870..3b487d38ab 100644 --- a/ports/stm/supervisor/port.c +++ b/ports/stm/supervisor/port.c @@ -177,7 +177,7 @@ safe_mode_t port_init(void) { HAL_Init(); // Turns on SysTick __HAL_RCC_SYSCFG_CLK_ENABLE(); - #if CPY_STM32F4 + #if CPY_STM32F4 || CPY_STM32L4 __HAL_RCC_PWR_CLK_ENABLE(); HAL_PWR_EnableBkUpAccess(); diff --git a/ports/stm/supervisor/usb.c b/ports/stm/supervisor/usb.c index 906d07f737..d58eaba7b2 100644 --- a/ports/stm/supervisor/usb.c +++ b/ports/stm/supervisor/usb.c @@ -43,6 +43,11 @@ STATIC void init_usb_vbus_sense(void) { // Deactivate VBUS Sensing B USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_VBDEN; + #if (BOARD_NO_USB_OTG_ID_SENSE) + USB_OTG_FS->GUSBCFG &= ~USB_OTG_GUSBCFG_FHMOD; + USB_OTG_FS->GUSBCFG |= USB_OTG_GUSBCFG_FDMOD; + #endif + // B-peripheral session valid override enable USB_OTG_FS->GOTGCTL |= USB_OTG_GOTGCTL_BVALOEN; USB_OTG_FS->GOTGCTL |= USB_OTG_GOTGCTL_BVALOVAL; @@ -63,6 +68,12 @@ STATIC void init_usb_vbus_sense(void) { } void init_usb_hardware(void) { + + /* Enable USB power on Pwrctrl CR2 register */ + #ifdef PWR_CR2_USV + HAL_PWREx_EnableVddUSB(); + #endif + // TODO: if future chips overload this with options, move to peripherals management. GPIO_InitTypeDef GPIO_InitStruct = {0}; @@ -80,7 +91,7 @@ void init_usb_hardware(void) { GPIO_InitStruct.Pull = GPIO_NOPULL; #if CPY_STM32H7 GPIO_InitStruct.Alternate = GPIO_AF10_OTG1_FS; - #elif CPY_STM32F4 || CPY_STM32F7 + #elif CPY_STM32F4 || CPY_STM32F7 || CPY_STM32L4 GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS; #endif HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); @@ -100,18 +111,20 @@ void init_usb_hardware(void) { #endif /* This for ID line debug */ + #if !(BOARD_NO_USB_OTG_ID_SENSE) GPIO_InitStruct.Pin = GPIO_PIN_10; GPIO_InitStruct.Mode = GPIO_MODE_AF_OD; GPIO_InitStruct.Pull = GPIO_PULLUP; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; #if CPY_STM32H7 GPIO_InitStruct.Alternate = GPIO_AF10_OTG1_FS; - #elif CPY_STM32F4 || CPY_STM32F7 + #elif CPY_STM32F4 || CPY_STM32F7 || CPY_STM32L4 GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS; #endif HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); never_reset_pin_number(0, 10); claim_pin(0, 10); + #endif #ifdef STM32F412Zx /* Configure POWER_SWITCH IO pin (F412 ONLY)*/ @@ -131,6 +144,7 @@ void init_usb_hardware(void) { __HAL_RCC_USB_OTG_FS_CLK_ENABLE(); #endif + init_usb_vbus_sense(); } diff --git a/ports/stm/tools/examples/stm32f405.csv b/ports/stm/tools/examples/stm32f405.csv index 2602db8775..20043f5855 100644 --- a/ports/stm/tools/examples/stm32f405.csv +++ b/ports/stm/tools/examples/stm32f405.csv @@ -1,142 +1,142 @@ Port,,AF0,AF1,AF2,AF3,AF4,AF5,AF6,AF7,AF8,AF9,AF10,AF11,AF12,AF13,AF14,AF15, ,,SYS,TIM1/2,TIM3/4/5,TIM8/9/10/11,I2C1/2/3,SPI1/SPI2/I2S2/I2S2ext,SPI3/I2Sext/I2S3,USART1/2/3/I2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ETH_MII_RXD1/ETH_RMII_RXD1,,,,EVENTOUT,ADC123_IN15 -PortC,PC6,,,TIM3_CH1,TIM8_CH1,,I2S2_MCK,,,USART6_TX,,,,SDIO_D6,DCMI_D0,,EVENTOUT, -PortC,PC7,,,TIM3_CH2,TIM8_CH2,,,I2S3_MCK,,USART6_RX,,,,SDIO_D7,DCMI_D1,,EVENTOUT, -PortC,PC8,,,TIM3_CH3,TIM8_CH3,,,,,USART6_CK,,,,SDIO_D0,DCMI_D2,,EVENTOUT, -PortC,PC9,MCO2,,TIM3_CH4,TIM8_CH4,I2C3_SDA,I2S_CKIN,,,,,,,SDIO_D1,DCMI_D3,,EVENTOUT, -PortC,PC10,,,,,,,SPI3_SCK/I2S3_CK,USART3_TX,UART4_TX,,,,SDIO_D2,DCMI_D8,,EVENTOUT, -PortC,PC11,,,,,,I2S3ext_SD,SPI3_MISO,USART3_RX,UART4_RX,,,,SDIO_D3,DCMI_D4,,EVENTOUT, -PortC,PC12,,,,,,,SPI3_MOSI/I2S3_SD,USART3_CK,UART5_TX,,,,SDIO_CK,DCMI_D9,,EVENTOUT, -PortC,PC13,,,,,,,,,,,,,,,,EVENTOUT, -PortC,PC14,,,,,,,,,,,,,,,,EVENTOUT, -PortC,PC15,,,,,,,,,,,,,,,,EVENTOUT, -PortD,PD0,,,,,,,,,,CAN1_RX,,,FSMC_D2,,,EVENTOUT, -PortD,PD1,,,,,,,,,,CAN1_TX,,,FSMC_D3,,,EVENTOUT, -PortD,PD2,,,TIM3_ETR,,,,,,UART5_RX,,,,SDIO_CMD,DCMI_D11,,EVENTOUT, -PortD,PD3,,,,,,,,USART2_CTS,,,,,FSMC_CLK,,,EVENTOUT, -PortD,PD4,,,,,,,,USART2_RTS,,,,,FSMC_NOE,,,EVENTOUT, -PortD,PD5,,,,,,,,USART2_TX,,,,,FSMC_NWE,,,EVENTOUT, -PortD,PD6,,,,,,,,USART2_RX,,,,,FSMC_NWAIT,,,EVENTOUT, -PortD,PD7,,,,,,,,USART2_CK,,,,,FSMC_NE1/FSMC_NCE2,,,EVENTOUT, -PortD,PD8,,,,,,,,USART3_TX,,,,,FSMC_D13,,,EVENTOUT, -PortD,PD9,,,,,,,,USART3_RX,,,,,FSMC_D14,,,EVENTOUT, -PortD,PD10,,,,,,,,USART3_CK,,,,,FSMC_D15,,,EVENTOUT, -PortD,PD11,,,,,,,,USART3_CTS,,,,,FSMC_A16,,,EVENTOUT, -PortD,PD12,,,TIM4_CH1,,,,,USART3_RTS,,,,,FSMC_A17,,,EVENTOUT, -PortD,PD13,,,TIM4_CH2,,,,,,,,,,FSMC_A18,,,EVENTOUT, -PortD,PD14,,,TIM4_CH3,,,,,,,,,,FSMC_D0,,,EVENTOUT, -PortD,PD15,,,TIM4_CH4,,,,,,,,,,FSMC_D1,,,EVENTOUT, -PortE,PE0,,,TIM4_ETR,,,,,,,,,,FSMC_NBL0,DCMI_D2,,EVENTOUT, -PortE,PE1,,,,,,,,,,,,,FSMC_NBL1,DCMI_D3,,EVENTOUT, -PortE,PE2,TRACECLK,,,,,,,,,,,ETH_MII_TXD3,FSMC_A23,,,EVENTOUT, -PortE,PE3,TRACED0,,,,,,,,,,,,FSMC_A19,,,EVENTOUT, -PortE,PE4,TRACED1,,,,,,,,,,,,FSMC_A20,DCMI_D4,,EVENTOUT, -PortE,PE5,TRACED2,,,TIM9_CH1,,,,,,,,,FSMC_A21,DCMI_D6,,EVENTOUT, -PortE,PE6,TRACED3,,,TIM9_CH2,,,,,,,,,FSMC_A22,DCMI_D7,,EVENTOUT, -PortE,PE7,,TIM1_ETR,,,,,,,,,,,FSMC_D4,,,EVENTOUT, -PortE,PE8,,TIM1_CH1N,,,,,,,,,,,FSMC_D5,,,EVENTOUT, -PortE,PE9,,TIM1_CH1,,,,,,,,,,,FSMC_D6,,,EVENTOUT, -PortE,PE10,,TIM1_CH2N,,,,,,,,,,,FSMC_D7,,,EVENTOUT, -PortE,PE11,,TIM1_CH2,,,,,,,,,,,FSMC_D8,,,EVENTOUT, -PortE,PE12,,TIM1_CH3N,,,,,,,,,,,FSMC_D9,,,EVENTOUT, -PortE,PE13,,TIM1_CH3,,,,,,,,,,,FSMC_D10,,,EVENTOUT, -PortE,PE14,,TIM1_CH4,,,,,,,,,,,FSMC_D11,,,EVENTOUT, -PortE,PE15,,TIM1_BKIN,,,,,,,,,,,FSMC_D12,,,EVENTOUT, -PortF,PF0,,,,,I2C2_SDA,,,,,,,,FSMC_A0,,,EVENTOUT, -PortF,PF1,,,,,I2C2_SCL,,,,,,,,FSMC_A1,,,EVENTOUT, -PortF,PF2,,,,,I2C2_SMBA,,,,,,,,FSMC_A2,,,EVENTOUT, -PortF,PF3,,,,,,,,,,,,,FSMC_A3,,,EVENTOUT,ADC3_IN9 -PortF,PF4,,,,,,,,,,,,,FSMC_A4,,,EVENTOUT,ADC3_IN14 -PortF,PF5,,,,,,,,,,,,,FSMC_A5,,,EVENTOUT,ADC3_IN15 -PortF,PF6,,,,TIM10_CH1,,,,,,,,,FSMC_NIORD,,,EVENTOUT,ADC3_IN4 -PortF,PF7,,,,TIM11_CH1,,,,,,,,,FSMC_NREG,,,EVENTOUT,ADC3_IN5 -PortF,PF8,,,,,,,,,,TIM13_CH1,,,FSMC_NIOWR,,,EVENTOUT,ADC3_IN6 -PortF,PF9,,,,,,,,,,TIM14_CH1,,,FSMC_CD,,,EVENTOUT,ADC3_IN7 -PortF,PF10,,,,,,,,,,,,,FSMC_INTR,,,EVENTOUT,ADC3_IN8 -PortF,PF11,,,,,,,,,,,,,,DCMI_D12,,EVENTOUT, -PortF,PF12,,,,,,,,,,,,,FSMC_A6,,,EVENTOUT, -PortF,PF13,,,,,,,,,,,,,FSMC_A7,,,EVENTOUT, -PortF,PF14,,,,,,,,,,,,,FSMC_A8,,,EVENTOUT, -PortF,PF15,,,,,,,,,,,,,FSMC_A9,,,EVENTOUT, -PortG,PG0,,,,,,,,,,,,,FSMC_A10,,,EVENTOUT, -PortG,PG1,,,,,,,,,,,,,FSMC_A11,,,EVENTOUT, -PortG,PG2,,,,,,,,,,,,,FSMC_A12,,,EVENTOUT, -PortG,PG3,,,,,,,,,,,,,FSMC_A13,,,EVENTOUT, -PortG,PG4,,,,,,,,,,,,,FSMC_A14,,,EVENTOUT, -PortG,PG5,,,,,,,,,,,,,FSMC_A15,,,EVENTOUT, -PortG,PG6,,,,,,,,,,,,,FSMC_INT2,,,EVENTOUT, -PortG,PG7,,,,,,,,,USART6_CK,,,,FSMC_INT3,,,EVENTOUT, -PortG,PG8,,,,,,,,,USART6_RTS,,,ETH_PPS_OUT,,,,EVENTOUT, -PortG,PG9,,,,,,,,,USART6_RX,,,,FSMC_NE2/FSMC_NCE3,,,EVENTOUT, -PortG,PG10,,,,,,,,,,,,,FSMC_NCE4_1/FSMC_NE3,,,EVENTOUT, -PortG,PG11,,,,,,,,,,,,ETH_MII_TX_EN/ETH_RMII_TX_EN,FSMC_NCE4_2,,,EVENTOUT, -PortG,PG12,,,,,,,,,USART6_RTS,,,,FSMC_NE4,,,EVENTOUT, -PortG,PG13,,,,,,,,,USART6_CTS,,,ETH_MII_TXD0/ETH_RMII_TXD0,FSMC_A24,,,EVENTOUT, -PortG,PG14,,,,,,,,,USART6_TX,,,ETH_MII_TXD1/ETH_RMII_TXD1,FSMC_A25,,,EVENTOUT, -PortG,PG15,,,,,,,,,USART6_CTS,,,,,DCMI_D13,,EVENTOUT, -PortH,PH0,,,,,,,,,,,,,,,,EVENTOUT, -PortH,PH1,,,,,,,,,,,,,,,,EVENTOUT, -PortH,PH2,,,,,,,,,,,,ETH_MII_CRS,,,,EVENTOUT, -PortH,PH3,,,,,,,,,,,,ETH_MII_COL,,,,EVENTOUT, -PortH,PH4,,,,,I2C2_SCL,,,,,,OTG_HS_ULPI_NXT,,,,,EVENTOUT, -PortH,PH5,,,,,I2C2_SDA,,,,,,,,,,,EVENTOUT, -PortH,PH6,,,,,I2C2_SMBA,,,,,TIM12_CH1,,ETH_MII_RXD2,,,,EVENTOUT, -PortH,PH7,,,,,I2C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IO_D0,DCMI_D2,,EVENTOUT, +PC9,MCO2,,TIM3_CH4,TIM8_CH4,I2C3_SDA,I2S_CKIN,,,,,,,SDIO_D1,DCMI_D3,,EVENTOUT, +PC10,,,,,,,SPI3_SCK/I2S3_CK,USART3_TX,UART4_TX,,,,SDIO_D2,DCMI_D8,,EVENTOUT, +PC11,,,,,,I2S3ext_SD,SPI3_MISO,USART3_RX,UART4_RX,,,,SDIO_D3,DCMI_D4,,EVENTOUT, +PC12,,,,,,,SPI3_MOSI/I2S3_SD,USART3_CK,UART5_TX,,,,SDIO_CK,DCMI_D9,,EVENTOUT, +PC13,,,,,,,,,,,,,,,,EVENTOUT, +PC14,,,,,,,,,,,,,,,,EVENTOUT, +PC15,,,,,,,,,,,,,,,,EVENTOUT, +PD0,,,,,,,,,,CAN1_RX,,,FSMC_D2,,,EVENTOUT, +PD1,,,,,,,,,,CAN1_TX,,,FSMC_D3,,,EVENTOUT, +PD2,,,TIM3_ETR,,,,,,UART5_RX,,,,SDIO_CMD,DCMI_D11,,EVENTOUT, +PD3,,,,,,,,USART2_CTS,,,,,FSMC_CLK,,,EVENTOUT, +PD4,,,,,,,,USART2_RTS,,,,,FSMC_NOE,,,EVENTOUT, +PD5,,,,,,,,USART2_TX,,,,,FSMC_NWE,,,EVENTOUT, +PD6,,,,,,,,USART2_RX,,,,,FSMC_NWAIT,,,EVENTOUT, +PD7,,,,,,,,USART2_CK,,,,,FSMC_NE1/FSMC_NCE2,,,EVENTOUT, +PD8,,,,,,,,USART3_TX,,,,,FSMC_D13,,,EVENTOUT, +PD9,,,,,,,,USART3_RX,,,,,FSMC_D14,,,EVENTOUT, +PD10,,,,,,,,USART3_CK,,,,,FSMC_D15,,,EVENTOUT, +PD11,,,,,,,,USART3_CTS,,,,,FSMC_A16,,,EVENTOUT, +PD12,,,TIM4_CH1,,,,,USART3_RTS,,,,,FSMC_A17,,,EVENTOUT, +PD13,,,TIM4_CH2,,,,,,,,,,FSMC_A18,,,EVENTOUT, +PD14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VENTOUT, +PI3,,,,TIM8_ETR,,SPI2_MOSI/I2S2_SD,,,,,,,,DCMI_D10,,EVENTOUT, +PI4,,,,TIM8_BKIN,,,,,,,,,,DCMI_D5,,EVENTOUT, +PI5,,,,TIM8_CH1,,,,,,,,,,DCMI_VSYNC,,EVENTOUT, +PI6,,,,TIM8_CH2,,,,,,,,,,DCMI_D6,,EVENTOUT, +PI7,,,,TIM8_CH3,,,,,,,,,,DCMI_D7,,EVENTOUT, +PI8,,,,,,,,,,,,,,,,EVENTOUT, +PI9,,,,,,,,,,CAN1_RX,,,,,,EVENTOUT, +PI10,,,,,,,,,,,,ETH_MII_RX_ER,,,,EVENTOUT, +PI11,,,,,,,,,,,OTG_HS_ULPI_DIR,,,,,EVENTOUT, diff --git a/ports/stm/tools/examples/stm32l4r5zi.csv b/ports/stm/tools/examples/stm32l4r5zi.csv new file mode 100644 index 0000000000..37683c751f --- /dev/null +++ b/ports/stm/tools/examples/stm32l4r5zi.csv @@ -0,0 +1,141 @@ +Port,,AF0,AF1,AF2,AF3,AF4,AF5,AF6,AF7,AF8,AF9,AF10,AF11,AF12,AF13,AF14,AF15 +PA0,-,TIM2_CH1,TIM5_CH1,TIM8_ETR,-,-,-,USART2_CTS_NSS,,UART4_TX,-,-,-,-,SAI1_EXTCLK,TIM2_ETR,EVENTOUT +PA1,-,TIM2_CH2,TIM5_CH2,-,I2C1_SMBA,SPI1_SCK,-,USART2_RTS_DE,,UART4_RX,-,OCTOSPIM_P1_DQS,-,-,-,TIM15_CH1N,EVENTOUT +PA2,-,TIM2_CH3,TIM5_CH3,-,-,-,-,USART2_TX,,LPUART1_TX,-,OCTOSPIM_P1_NCS,-,-,SAI2_EXTCLK,TIM15_CH1,EVENTOUT +PA3,-,TIM2_CH4,TIM5_CH4,SAI1_CK1,-,-,-,USART2_RX,,LPUART1_RX,-,OCTOSPIM_P1_CLK,-,-,SAI1_MCLK_A,TIM15_CH2,EVENTOUT +PA4,-,-,-,OCTOSPIM_P1_NCS,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TOSPIM_P2_IO1,-,-,,-,-,-,-,-,-,-,EVENTOUT +PI11,-,-,-,-,-,OCTOSPIM_P2_IO0,-,-,,-,-,-,-,-,-,-,EVENTOUT diff --git a/ports/stm/tools/parse_af_csv.py b/ports/stm/tools/parse_af_csv.py index 38608b5dac..3e48d4145d 100644 --- a/ports/stm/tools/parse_af_csv.py +++ b/ports/stm/tools/parse_af_csv.py @@ -25,7 +25,7 @@ import csv import sys -# Use: parse_af_csf.py Filename.csv -pins-only +# Use: parse_af_csv.py Filename.csv -pins-only # Designed for use with .csv files from Micropython, or in identical format # created via Datasheet peripheral tables with a Sheets program. # @@ -70,6 +70,7 @@ with open(sys.argv[1]) as csv_file: ["SPI", "SCK"], ["SPI", "MOSI"], ["SPI", "MISO"], + ["SPI", "NSS"], ["UART", "TX"], ["UART", "RX"], ] @@ -86,22 +87,22 @@ with open(sys.argv[1]) as csv_file: # Each line is a list of strings for row in csv_reader: altfn = 0 - pin = row[1] - if len(pin) < 4: + pin = row[0] + if len(pin) < 4: # add additional leading 0 to pin number after port pin = pin[:2] + "0" + pin[2:] for col in row: array_index = 0 # Evaluate the string for every possible todo entry for item in todo: - evaluate_periph(col, outlist[array_index], item[0], item[1], altfn - 2, pin) + evaluate_periph(col, outlist[array_index], item[0], item[1], altfn - 1, pin) # UART special case, run again for USART variant if item[0] == "UART": evaluate_periph( - col, outlist[array_index], "USART", item[1], altfn - 2, pin + col, outlist[array_index], "USART", item[1], altfn - 1, pin ) array_index += 1 # TIM special case - evaluate_tim(col, outlist[-1], altfn - 2, pin) + evaluate_tim(col, outlist[-1], altfn - 1, pin) altfn += 1 line_count += 1 @@ -139,10 +140,10 @@ with open(sys.argv[1]) as csv_file: for row in csv_reader: altfn = 0 - pin = row[1] + pin = row[0] if len(pin) < 4: pin = pin[:2] + "0" + pin[2:] - outlist.append([pin, str(ord(row[1][1:2]) - 65), row[1][2:4]]) + outlist.append([pin, str(ord(pin[1:2]) - 65), pin[2:4]]) line_count += 1 for line in outlist: @@ -159,4 +160,4 @@ with open(sys.argv[1]) as csv_file: for line in outlist: print("extern const mcu_pin_obj_t pin_" + line[0] + ";") - print(f"Processed {line_count} lines.") + print("Processed %d lines." % line_count) diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index 2ec0d2a849..3608b9c71d 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -244,26 +244,16 @@ typedef long mp_off_t; // These CIRCUITPY_xxx values should all be defined in the *.mk files as being on or off. // So if any are not defined in *.mk, they'll throw an error here. -#if CIRCUITPY_BINASCII -#define MICROPY_PY_UBINASCII CIRCUITPY_BINASCII -#define BINASCII_MODULE { MP_ROM_QSTR(MP_QSTR_binascii), MP_ROM_PTR(&mp_module_ubinascii) }, -#else -#define BINASCII_MODULE -#endif - #if CIRCUITPY_BOARD #define BOARD_I2C (defined(DEFAULT_I2C_BUS_SDA) && defined(DEFAULT_I2C_BUS_SCL)) #define BOARD_SPI (defined(DEFAULT_SPI_BUS_SCK) && defined(DEFAULT_SPI_BUS_MISO) && defined(DEFAULT_SPI_BUS_MOSI)) #define BOARD_UART (defined(DEFAULT_UART_BUS_RX) && defined(DEFAULT_UART_BUS_TX)) - // I2C and SPI are always allocated off the heap. - #if BOARD_UART #define BOARD_UART_ROOT_POINTER mp_obj_t shared_uart_bus; #else #define BOARD_UART_ROOT_POINTER #endif - #else #define BOARD_UART_ROOT_POINTER #endif @@ -276,23 +266,6 @@ typedef long mp_off_t; #define CIRCUITPY_DISPLAY_LIMIT (0) #endif -#if CIRCUITPY_ERRNO -#define MICROPY_PY_UERRNO (1) -// Uses about 80 bytes. -#define MICROPY_PY_UERRNO_ERRORCODE (1) -#define ERRNO_MODULE { MP_ROM_QSTR(MP_QSTR_errno), MP_ROM_PTR(&mp_module_uerrno) }, -#else -#define ERRNO_MODULE -# - #endif - -#if CIRCUITPY_ESPIDF -extern const struct _mp_obj_module_t espidf_module; -#define ESPIDF_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_espidf),(mp_obj_t)&espidf_module }, -#else -#define ESPIDF_MODULE -#endif - #if CIRCUITPY_GAMEPADSHIFT // Scan gamepad every 32ms #define CIRCUITPY_GAMEPAD_TICKS 0x1f @@ -301,18 +274,6 @@ extern const struct _mp_obj_module_t espidf_module; #define GAMEPAD_ROOT_POINTERS #endif -#if CIRCUITPY_JSON -#define MICROPY_PY_UJSON (1) -#define MICROPY_PY_IO (1) -#define JSON_MODULE { MP_ROM_QSTR(MP_QSTR_json), MP_ROM_PTR(&mp_module_ujson) }, -#else -#ifndef MICROPY_PY_IO -// We don't need MICROPY_PY_IO unless someone else wants it. -#define MICROPY_PY_IO (0) -#endif -#define JSON_MODULE -#endif - #if CIRCUITPY_KEYPAD #define KEYPAD_ROOT_POINTERS mp_obj_t keypad_scanners_linked_list; #else @@ -331,83 +292,51 @@ extern const struct _mp_obj_module_t espidf_module; extern const struct _mp_obj_module_t nvm_module; #endif -#if CIRCUITPY_OS -extern const struct _mp_obj_module_t os_module; -#define OS_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_os), (mp_obj_t)&os_module }, -#define OS_MODULE_ALT_NAME { MP_OBJ_NEW_QSTR(MP_QSTR__os), (mp_obj_t)&os_module }, +// Following modules are implemented in either extmod or py directory. + +#define MICROPY_PY_UBINASCII CIRCUITPY_BINASCII + +#define MICROPY_PY_UERRNO CIRCUITPY_ERRNO +// Uses about 80 bytes. +#define MICROPY_PY_UERRNO_ERRORCODE CIRCUITPY_ERRNO + +#define MICROPY_PY_URE CIRCUITPY_RE + +#if CIRCUITPY_JSON +#define MICROPY_PY_UJSON (1) +#define MICROPY_PY_IO (1) #else -#define OS_MODULE -#define OS_MODULE_ALT_NAME +#ifndef MICROPY_PY_IO +// We don't need MICROPY_PY_IO unless someone else wants it. +#define MICROPY_PY_IO (0) +#endif #endif -#if CIRCUITPY_RE -#define MICROPY_PY_URE (1) -#define RE_MODULE { MP_ROM_QSTR(MP_QSTR_re), MP_ROM_PTR(&mp_module_ure) }, -#else -#define RE_MODULE -#endif - -#if CIRCUITPY_RP2PIO -extern const struct _mp_obj_module_t rp2pio_module; -#define RP2PIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_rp2pio),(mp_obj_t)&rp2pio_module }, -#else -#define RP2PIO_MODULE -#endif - -#if CIRCUITPY_SAMD -extern const struct _mp_obj_module_t samd_module; -#define SAMD_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_samd),(mp_obj_t)&samd_module }, -#else -#define SAMD_MODULE -#endif - -#if CIRCUITPY_TIME -extern const struct _mp_obj_module_t time_module; -#define TIME_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_time), (mp_obj_t)&time_module }, -#define TIME_MODULE_ALT_NAME { MP_OBJ_NEW_QSTR(MP_QSTR__time), (mp_obj_t)&time_module }, -#else -#define TIME_MODULE -#define TIME_MODULE_ALT_NAME -#endif - -#if defined(CIRCUITPY_ULAB) && CIRCUITPY_ULAB +#if CIRCUITPY_ULAB // ulab requires reverse special methods #if defined(MICROPY_PY_REVERSE_SPECIAL_METHODS) && !MICROPY_PY_REVERSE_SPECIAL_METHODS #error "ulab requires MICROPY_PY_REVERSE_SPECIAL_METHODS" #endif -#define ULAB_MODULE \ - { MP_ROM_QSTR(MP_QSTR_ulab), MP_ROM_PTR(&ulab_user_cmodule) }, -#else -#define ULAB_MODULE #endif // Define certain native modules with weak links so they can be replaced with Python // implementations. This list may grow over time. -#define MICROPY_PORT_BUILTIN_MODULE_WEAK_LINKS \ - OS_MODULE \ - TIME_MODULE \ + +#define MICROPY_PORT_BUILTIN_MODULE_WEAK_LINKS // Native modules that are weak links can be accessed directly // by prepending their name with an underscore. This list should correspond to // MICROPY_PORT_BUILTIN_MODULE_WEAK_LINKS, assuming you want the native modules // to be accessible when overriden. -#define MICROPY_PORT_BUILTIN_MODULE_ALT_NAMES \ - OS_MODULE_ALT_NAME \ - TIME_MODULE_ALT_NAME \ + +#define MICROPY_PORT_BUILTIN_MODULE_ALT_NAMES // This is an inclusive list that should correspond to the CIRCUITPY_XXX list above, // including dependencies. // Some of these definitions will be blank depending on what is turned on and off. // Some are omitted because they're in MICROPY_PORT_BUILTIN_MODULE_WEAK_LINKS above. -#define MICROPY_PORT_BUILTIN_MODULES_STRONG_LINKS \ - BINASCII_MODULE \ - ERRNO_MODULE \ - ESPIDF_MODULE \ - JSON_MODULE \ - RE_MODULE \ - RP2PIO_MODULE \ - SAMD_MODULE \ +#define MICROPY_PORT_BUILTIN_MODULES_STRONG_LINKS // The following modules are defined in their respective __init__.c file in the // shared-bindings directory using MP_REGISTER_MODULE. diff --git a/py/moduerrno.c b/py/moduerrno.c index d13028e73a..56d903f115 100644 --- a/py/moduerrno.c +++ b/py/moduerrno.c @@ -105,6 +105,8 @@ const mp_obj_module_t mp_module_uerrno = { .globals = (mp_obj_dict_t *)&mp_module_uerrno_globals, }; +MP_REGISTER_MODULE(MP_QSTR_errno, mp_module_uerrno, MICROPY_PY_UERRNO); + qstr mp_errno_to_str(mp_obj_t errno_val) { // Otherwise, return the Exxxx string for that error code #if MICROPY_PY_UERRNO_ERRORCODE diff --git a/shared-bindings/_bleio/Adapter.c b/shared-bindings/_bleio/Adapter.c index c126ee79f2..1c65c0327f 100644 --- a/shared-bindings/_bleio/Adapter.c +++ b/shared-bindings/_bleio/Adapter.c @@ -271,7 +271,7 @@ STATIC mp_obj_t bleio_adapter_start_advertising(mp_uint_t n_args, const mp_obj_t return mp_const_none; } -STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_adapter_start_advertising_obj, 2, bleio_adapter_start_advertising); +STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_adapter_start_advertising_obj, 1, bleio_adapter_start_advertising); //| def stop_advertising(self) -> None: //| """Stop sending advertising packets.""" @@ -456,7 +456,7 @@ STATIC mp_obj_t bleio_adapter_connect(mp_uint_t n_args, const mp_obj_t *pos_args return common_hal_bleio_adapter_connect(self, address, timeout); } -STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_adapter_connect_obj, 2, bleio_adapter_connect); +STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_adapter_connect_obj, 1, bleio_adapter_connect); //| def erase_bonding(self) -> None: //| """Erase all bonding information stored in flash memory.""" diff --git a/shared-bindings/_bleio/Characteristic.c b/shared-bindings/_bleio/Characteristic.c index b6b6ee69d4..c83645352b 100644 --- a/shared-bindings/_bleio/Characteristic.c +++ b/shared-bindings/_bleio/Characteristic.c @@ -156,7 +156,7 @@ STATIC mp_obj_t bleio_characteristic_add_to_service(size_t n_args, const mp_obj_ return MP_OBJ_FROM_PTR(characteristic); } -STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_characteristic_add_to_service_fun_obj, 3, bleio_characteristic_add_to_service); +STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_characteristic_add_to_service_fun_obj, 1, bleio_characteristic_add_to_service); STATIC MP_DEFINE_CONST_CLASSMETHOD_OBJ(bleio_characteristic_add_to_service_obj, MP_ROM_PTR(&bleio_characteristic_add_to_service_fun_obj)); diff --git a/shared-bindings/_bleio/Descriptor.c b/shared-bindings/_bleio/Descriptor.c index c8a1c87149..86e65ca6eb 100644 --- a/shared-bindings/_bleio/Descriptor.c +++ b/shared-bindings/_bleio/Descriptor.c @@ -136,7 +136,7 @@ STATIC mp_obj_t bleio_descriptor_add_to_characteristic(size_t n_args, const mp_o return MP_OBJ_FROM_PTR(descriptor); } -STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_descriptor_add_to_characteristic_fun_obj, 3, bleio_descriptor_add_to_characteristic); +STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_descriptor_add_to_characteristic_fun_obj, 1, bleio_descriptor_add_to_characteristic); STATIC MP_DEFINE_CONST_CLASSMETHOD_OBJ(bleio_descriptor_add_to_characteristic_obj, MP_ROM_PTR(&bleio_descriptor_add_to_characteristic_fun_obj)); //| uuid: UUID diff --git a/shared-bindings/_bleio/ScanEntry.c b/shared-bindings/_bleio/ScanEntry.c index 531986f349..5a0f6eb1be 100644 --- a/shared-bindings/_bleio/ScanEntry.c +++ b/shared-bindings/_bleio/ScanEntry.c @@ -72,7 +72,7 @@ STATIC mp_obj_t bleio_scanentry_matches(mp_uint_t n_args, const mp_obj_t *pos_ar mp_get_buffer_raise(args[ARG_prefixes].u_obj, &bufinfo, MP_BUFFER_READ); return mp_obj_new_bool(common_hal_bleio_scanentry_matches(self, bufinfo.buf, bufinfo.len, match_all)); } -STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_scanentry_matches_obj, 2, bleio_scanentry_matches); +STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_scanentry_matches_obj, 1, bleio_scanentry_matches); //| address: Address //| """The address of the device (read-only), of type `_bleio.Address`.""" diff --git a/shared-bindings/_bleio/UUID.c b/shared-bindings/_bleio/UUID.c index a575e382cc..90ee0c82b0 100644 --- a/shared-bindings/_bleio/UUID.c +++ b/shared-bindings/_bleio/UUID.c @@ -214,7 +214,7 @@ STATIC mp_obj_t bleio_uuid_pack_into(mp_uint_t n_args, const mp_obj_t *pos_args, common_hal_bleio_uuid_pack_into(self, bufinfo.buf + offset); return mp_const_none; } -STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_uuid_pack_into_obj, 2, bleio_uuid_pack_into); +STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_uuid_pack_into_obj, 1, bleio_uuid_pack_into); STATIC const mp_rom_map_elem_t bleio_uuid_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_uuid16), MP_ROM_PTR(&bleio_uuid_uuid16_obj) }, diff --git a/shared-bindings/_stage/__init__.c b/shared-bindings/_stage/__init__.c index 1d5c06c862..4dfcc796e7 100644 --- a/shared-bindings/_stage/__init__.c +++ b/shared-bindings/_stage/__init__.c @@ -81,21 +81,17 @@ STATIC mp_obj_t stage_render(size_t n_args, const mp_obj_t *args) { mp_raise_TypeError(translate("argument num/types mismatch")); } displayio_display_obj_t *display = MP_OBJ_TO_PTR(native_display); - uint8_t scale = 1; - if (n_args > 7) { - scale = mp_obj_get_int(args[7]); - } + uint8_t scale = mp_obj_get_int(args[7]); + int16_t vx = mp_obj_get_int(args[8]); + int16_t vy = mp_obj_get_int(args[9]); uint16_t background = 0; - if (n_args > 8) { - background = mp_obj_get_int(args[8]); - } - render_stage(x0, y0, x1, y1, layers, layers_size, buffer, buffer_size, - display, scale, background); + render_stage(x0, y0, x1, y1, vx, vy, layers, layers_size, + buffer, buffer_size, display, scale, background); return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(stage_render_obj, 7, 8, stage_render); +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(stage_render_obj, 10, 10, stage_render); STATIC const mp_rom_map_elem_t stage_module_globals_table[] = { diff --git a/shared-bindings/adafruit_bus_device/I2CDevice.c b/shared-bindings/adafruit_bus_device/I2CDevice.c index 12c836396d..a6ec8a2dfb 100644 --- a/shared-bindings/adafruit_bus_device/I2CDevice.c +++ b/shared-bindings/adafruit_bus_device/I2CDevice.c @@ -63,7 +63,8 @@ //| device.readinto(bytes_read) //| # A second transaction //| with device: -//| device.write(bytes_read)""" +//| device.write(bytes_read) +//| """ //| ... //| STATIC mp_obj_t adafruit_bus_device_i2cdevice_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { @@ -109,16 +110,18 @@ STATIC mp_obj_t adafruit_bus_device_i2cdevice_obj___exit__(size_t n_args, const } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(adafruit_bus_device_i2cdevice___exit___obj, 4, 4, adafruit_bus_device_i2cdevice_obj___exit__); -//| def readinto(self, buf: WriteableBuffer, *, start: int = 0, end: Optional[int] = None) -> None: -//| """Read into ``buf`` from the device. The number of bytes read will be the -//| length of ``buf``. -//| If ``start`` or ``end`` is provided, then the buffer will be sliced -//| as if ``buf[start:end]``. This will not cause an allocation like -//| ``buf[start:end]`` will so it saves memory. +//| import sys +//| def readinto(self, buffer: WriteableBuffer, *, start: int = 0, end: int = sys.maxsize) -> None: +//| """Read into ``buffer`` from the device. //| -//| :param bytearray buf: buffer to write into -//| :param int start: Index to start writing at -//| :param int end: Index to write up to but not include; if None, use ``len(buf)``""" +//| If ``start`` or ``end`` is provided, then the buffer will be sliced +//| as if ``buffer[start:end]`` were passed. +//| The number of bytes read will be the length of ``buffer[start:end]``. +//| +//| :param WriteableBuffer buffer: read bytes into this buffer +//| :param int start: beginning of buffer slice +//| :param int end: end of buffer slice; if not specified, use ``len(buffer)`` +//| """ //| ... //| STATIC mp_obj_t adafruit_bus_device_i2cdevice_readinto(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { @@ -152,17 +155,19 @@ STATIC mp_obj_t adafruit_bus_device_i2cdevice_readinto(size_t n_args, const mp_o return mp_const_none; } -STATIC MP_DEFINE_CONST_FUN_OBJ_KW(adafruit_bus_device_i2cdevice_readinto_obj, 2, adafruit_bus_device_i2cdevice_readinto); +STATIC MP_DEFINE_CONST_FUN_OBJ_KW(adafruit_bus_device_i2cdevice_readinto_obj, 1, adafruit_bus_device_i2cdevice_readinto); -//| def write(self, buf: ReadableBuffer, *, start: int = 0, end: Optional[int] = None) -> None: +//| import sys +//| def write(self, buffer: ReadableBuffer, *, start: int = 0, end: int = sys.maxsize) -> None: //| """Write the bytes from ``buffer`` to the device, then transmit a stop bit. -//| If ``start`` or ``end`` is provided, then the buffer will be sliced -//| as if ``buffer[start:end]``. This will not cause an allocation like -//| ``buffer[start:end]`` will so it saves memory. //| -//| :param bytearray buf: buffer containing the bytes to write -//| :param int start: Index to start writing from -//| :param int end: Index to read up to but not include; if None, use ``len(buf)`` +//| If ``start`` or ``end`` is provided, then the buffer will be sliced +//| as if ``buffer[start:end]`` were passed, but without copying the data. +//| The number of bytes written will be the length of ``buffer[start:end]``. +//| +//| :param ReadableBuffer buffer: write out bytes from this buffer +//| :param int start: beginning of buffer slice +//| :param int end: end of buffer slice; if not specified, use ``len(buffer)`` //| """ //| ... //| @@ -196,28 +201,28 @@ STATIC mp_obj_t adafruit_bus_device_i2cdevice_write(size_t n_args, const mp_obj_ return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_KW(adafruit_bus_device_i2cdevice_write_obj, 2, adafruit_bus_device_i2cdevice_write); +MP_DEFINE_CONST_FUN_OBJ_KW(adafruit_bus_device_i2cdevice_write_obj, 1, adafruit_bus_device_i2cdevice_write); -//| def write_then_readinto(self, out_buffer: WriteableBuffer, in_buffer: ReadableBuffer, *, out_start: int = 0, out_end: Optional[int] = None, in_start: int = 0, in_end: Optional[int] = None) -> None: +//| import sys +//| def write_then_readinto(self, out_buffer: ReadableBuffer, in_buffer: WriteableBuffer, *, out_start: int = 0, out_end: int = sys.maxsize, in_start: int = 0, in_end: int = sys.maxsize) -> None: //| """Write the bytes from ``out_buffer`` to the device, then immediately -//| reads into ``in_buffer`` from the device. The number of bytes read -//| will be the length of ``in_buffer``. -//| If ``out_start`` or ``out_end`` is provided, then the output buffer -//| will be sliced as if ``out_buffer[out_start:out_end]``. This will -//| not cause an allocation like ``buffer[out_start:out_end]`` will so -//| it saves memory. -//| If ``in_start`` or ``in_end`` is provided, then the input buffer -//| will be sliced as if ``in_buffer[in_start:in_end]``. This will not -//| cause an allocation like ``in_buffer[in_start:in_end]`` will so -//| it saves memory. +//| reads into ``in_buffer`` from the device. //| -//| :param bytearray out_buffer: buffer containing the bytes to write -//| :param bytearray in_buffer: buffer containing the bytes to read into -//| :param int out_start: Index to start writing from -//| :param int out_end: Index to read up to but not include; if None, use ``len(out_buffer)`` -//| :param int in_start: Index to start writing at -//| :param int in_end: Index to write up to but not include; if None, use ``len(in_buffer)`` +//| If ``out_start`` or ``out_end`` is provided, then the buffer will be sliced +//| as if ``out_buffer[out_start:out_end]`` were passed, but without copying the data. +//| The number of bytes written will be the length of ``out_buffer[out_start:out_end]``. +//| +//| If ``in_start`` or ``in_end`` is provided, then the input buffer will be sliced +//| as if ``in_buffer[in_start:in_end]`` were passed, +//| The number of bytes read will be the length of ``out_buffer[in_start:in_end]``. +//| +//| :param ReadableBuffer out_buffer: write out bytes from this buffer +//| :param WriteableBuffer in_buffer: read bytes into this buffer +//| :param int out_start: beginning of ``out_buffer`` slice +//| :param int out_end: end of ``out_buffer`` slice; if not specified, use ``len(out_buffer)`` +//| :param int in_start: beginning of ``in_buffer`` slice +//| :param int in_end: end of ``in_buffer slice``; if not specified, use ``len(in_buffer)`` //| """ //| ... //| @@ -263,7 +268,7 @@ STATIC mp_obj_t adafruit_bus_device_i2cdevice_write_then_readinto(size_t n_args, return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_KW(adafruit_bus_device_i2cdevice_write_then_readinto_obj, 3, adafruit_bus_device_i2cdevice_write_then_readinto); +MP_DEFINE_CONST_FUN_OBJ_KW(adafruit_bus_device_i2cdevice_write_then_readinto_obj, 1, adafruit_bus_device_i2cdevice_write_then_readinto); STATIC const mp_rom_map_elem_t adafruit_bus_device_i2cdevice_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&adafruit_bus_device_i2cdevice___enter___obj) }, diff --git a/shared-bindings/bitbangio/I2C.c b/shared-bindings/bitbangio/I2C.c index 9f39e84061..3599cad48f 100644 --- a/shared-bindings/bitbangio/I2C.c +++ b/shared-bindings/bitbangio/I2C.c @@ -165,7 +165,8 @@ STATIC mp_obj_t bitbangio_i2c_obj_unlock(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(bitbangio_i2c_unlock_obj, bitbangio_i2c_obj_unlock); -//| def readfrom_into(self, address: int, buffer: WriteableBuffer, *, start: int = 0, end: Optional[int] = None) -> None: +//| import sys +//| def readfrom_into(self, address: int, buffer: WriteableBuffer, *, start: int = 0, end: int = sys.maxsize) -> None: //| """Read into ``buffer`` from the device selected by ``address``. //| The number of bytes read will be the length of ``buffer``. //| At least one byte must be read. @@ -175,7 +176,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(bitbangio_i2c_unlock_obj, bitbangio_i2c_obj_unlock); //| ``buf[start:end]`` will so it saves memory. //| //| :param int address: 7-bit device address -//| :param ~_typing.WriteableBuffer buffer: buffer to write into +//| :param WriteableBuffer buffer: buffer to write into //| :param int start: Index to start writing at //| :param int end: Index to write up to but not include""" //| ... @@ -215,24 +216,26 @@ STATIC mp_obj_t bitbangio_i2c_readfrom_into(size_t n_args, const mp_obj_t *pos_a args[ARG_end].u_int); return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_KW(bitbangio_i2c_readfrom_into_obj, 3, bitbangio_i2c_readfrom_into); +MP_DEFINE_CONST_FUN_OBJ_KW(bitbangio_i2c_readfrom_into_obj, 1, bitbangio_i2c_readfrom_into); -//| def writeto(self, address: int, buffer: ReadableBuffer, *, start: int = 0, end: Optional[int] = None) -> None: +//| import sys +//| def writeto(self, address: int, buffer: ReadableBuffer, *, start: int = 0, end: int = sys.maxsize) -> None: //| """Write the bytes from ``buffer`` to the device selected by ``address`` and then transmits a //| stop bit. Use `writeto_then_readfrom` when needing a write, no stop and repeated start //| before a read. //| //| If ``start`` or ``end`` is provided, then the buffer will be sliced -//| as if ``buffer[start:end]``. This will not cause an allocation like -//| ``buffer[start:end]`` will so it saves memory. +//| as if ``buffer[start:end]`` were passed, but without copying the data. +//| The number of bytes written will be the length of ``buffer[start:end]``. //| //| Writing a buffer or slice of length zero is permitted, as it can be used //| to poll for the existence of a device. //| //| :param int address: 7-bit device address -//| :param ~_typing.ReadableBuffer buffer: buffer containing the bytes to write -//| :param int start: Index to start writing from -//| :param int end: Index to read up to but not include""" +//| :param ReadableBuffer buffer: buffer containing the bytes to write +//| :param int start: beginning of buffer slice +//| :param int end: end of buffer slice; if not specified, use ``len(buffer)`` +//| """ //| ... //| // Shared arg parsing for writeto and writeto_then_readfrom. @@ -274,22 +277,29 @@ STATIC mp_obj_t bitbangio_i2c_writeto(size_t n_args, const mp_obj_t *pos_args, m STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bitbangio_i2c_writeto_obj, 1, bitbangio_i2c_writeto); -//| def writeto_then_readfrom(self, address: int, out_buffer: ReadableBuffer, in_buffer: ReadableBuffer, *, out_start: int = 0, out_end: Optional[int] = None, in_start: int = 0, in_end: Optional[int] = None) -> None: +//| import sys +//| def writeto_then_readfrom(self, address: int, out_buffer: ReadableBuffer, in_buffer: ReadableBuffer, *, out_start: int = 0, out_end: int = sys.maxsize, in_start: int = 0, in_end: int = sys.maxsize) -> None: //| """Write the bytes from ``out_buffer`` to the device selected by ``address``, generate no stop //| bit, generate a repeated start and read into ``in_buffer``. ``out_buffer`` and //| ``in_buffer`` can be the same buffer because they are used sequentially. //| -//| If ``start`` or ``end`` is provided, then the corresponding buffer will be sliced -//| as if ``buffer[start:end]``. This will not cause an allocation like ``buf[start:end]`` -//| will so it saves memory. +//| If ``out_start`` or ``out_end`` is provided, then the buffer will be sliced +//| as if ``out_buffer[out_start:out_end]`` were passed, but without copying the data. +//| The number of bytes written will be the length of ``out_buffer[start:end]``. //| +//| If ``in_start`` or ``in_end`` is provided, then the input buffer will be sliced +//| as if ``in_buffer[in_start:in_end]`` were passed, +//| The number of bytes read will be the length of ``out_buffer[in_start:in_end]``. + //| :param int address: 7-bit device address //| :param ~_typing.ReadableBuffer out_buffer: buffer containing the bytes to write //| :param ~_typing.WriteableBuffer in_buffer: buffer to write into -//| :param int out_start: Index to start writing from -//| :param int out_end: Index to read up to but not include. Defaults to ``len(buffer)`` -//| :param int in_start: Index to start writing at -//| :param int in_end: Index to write up to but not include. Defaults to ``len(buffer)``""" +//| :param int out_start: beginning of ``out_buffer`` slice +//| :param int out_end: end of ``out_buffer`` slice; if not specified, use ``len(out_buffer)`` +//| :param int in_start: beginning of ``in_buffer`` slice +//| :param int in_end: end of ``in_buffer slice``; if not specified, use ``len(in_buffer)`` +//| """ +//| ... //| STATIC mp_obj_t bitbangio_i2c_writeto_then_readfrom(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_address, ARG_out_buffer, ARG_in_buffer, ARG_out_start, ARG_out_end, ARG_in_start, ARG_in_end }; @@ -315,7 +325,7 @@ STATIC mp_obj_t bitbangio_i2c_writeto_then_readfrom(size_t n_args, const mp_obj_ return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_KW(bitbangio_i2c_writeto_then_readfrom_obj, 3, bitbangio_i2c_writeto_then_readfrom); +MP_DEFINE_CONST_FUN_OBJ_KW(bitbangio_i2c_writeto_then_readfrom_obj, 1, bitbangio_i2c_writeto_then_readfrom); STATIC const mp_rom_map_elem_t bitbangio_i2c_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&bitbangio_i2c_deinit_obj) }, diff --git a/shared-bindings/bitbangio/SPI.c b/shared-bindings/bitbangio/SPI.c index 0f8cb59a60..0f453b3807 100644 --- a/shared-bindings/bitbangio/SPI.c +++ b/shared-bindings/bitbangio/SPI.c @@ -224,18 +224,23 @@ STATIC mp_obj_t bitbangio_spi_write(mp_obj_t self_in, mp_obj_t wr_buf) { MP_DEFINE_CONST_FUN_OBJ_2(bitbangio_spi_write_obj, bitbangio_spi_write); -//| def readinto(self, buffer: WriteableBuffer, *, start: int = 0, end: Optional[int] = None, write_value: int = 0) -> None: +//| import sys +//| def readinto(self, buffer: WriteableBuffer, *, start: int = 0, end: int = sys.maxsize, write_value: int = 0) -> None: //| """Read into ``buffer`` while writing ``write_value`` for each byte read. //| The SPI object must be locked. //| If the number of bytes to read is 0, nothing happens. //| -//| :param bytearray buffer: Read data into this buffer -//| :param int start: Start of the slice of ``buffer`` to read into: ``buffer[start:end]`` -//| :param int end: End of the slice; this index is not included. Defaults to ``len(buffer)`` -//| :param int write_value: Value to write while reading.""" +//| If ``start`` or ``end`` is provided, then the buffer will be sliced +//| as if ``buffer[start:end]`` were passed. +//| The number of bytes read will be the length of ``buffer[start:end]``. +//| +//| :param WriteableBuffer buffer: read bytes into this buffer +//| :param int start: beginning of buffer slice +//| :param int end: end of buffer slice; if not specified, use ``len(buffer)`` +//| :param int write_value: value to write while reading +//| """ //| ... //| - STATIC mp_obj_t bitbangio_spi_readinto(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_buffer, ARG_start, ARG_end, ARG_write_value }; static const mp_arg_t allowed_args[] = { @@ -266,28 +271,39 @@ STATIC mp_obj_t bitbangio_spi_readinto(size_t n_args, const mp_obj_t *pos_args, } return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_KW(bitbangio_spi_readinto_obj, 2, bitbangio_spi_readinto); +MP_DEFINE_CONST_FUN_OBJ_KW(bitbangio_spi_readinto_obj, 1, bitbangio_spi_readinto); -//| def write_readinto(self, buffer_out: ReadableBuffer, buffer_in: ReadableBuffer, *, out_start: int = 0, out_end: Optional[int] = None, in_start: int = 0, in_end: Optional[int] = None) -> None: -//| """Write out the data in ``buffer_out`` while simultaneously reading data into ``buffer_in``. +//| import sys +//| def write_readinto(self, out_buffer: ReadableBuffer, in_buffer: WriteableBuffer, *, out_start: int = 0, out_end: int = sys.maxsize, in_start: int = 0, in_end: int = sys.maxsize) -> None: +//| """Write out the data in ``out_buffer`` while simultaneously reading data into ``in_buffer``. //| The SPI object must be locked. -//| The lengths of the slices defined by ``buffer_out[out_start:out_end]`` and ``buffer_in[in_start:in_end]`` -//| must be equal. +//| +//| If ``out_start`` or ``out_end`` is provided, then the buffer will be sliced +//| as if ``out_buffer[out_start:out_end]`` were passed, but without copying the data. +//| The number of bytes written will be the length of ``out_buffer[out_start:out_end]``. +//| +//| If ``in_start`` or ``in_end`` is provided, then the input buffer will be sliced +//| as if ``in_buffer[in_start:in_end]`` were passed, +//| The number of bytes read will be the length of ``out_buffer[in_start:in_end]``. +//| +//| The lengths of the slices defined by ``out_buffer[out_start:out_end]`` +//| and ``in_buffer[in_start:in_end]`` must be equal. //| If buffer slice lengths are both 0, nothing happens. //| -//| :param ~_typing.ReadableBuffer buffer_out: Write out the data in this buffer -//| :param ~_typing.WriteableBuffer buffer_in: Read data into this buffer -//| :param int out_start: Start of the slice of buffer_out to write out: ``buffer_out[out_start:out_end]`` -//| :param int out_end: End of the slice; this index is not included. Defaults to ``len(buffer_out)`` -//| :param int in_start: Start of the slice of ``buffer_in`` to read into: ``buffer_in[in_start:in_end]`` -//| :param int in_end: End of the slice; this index is not included. Defaults to ``len(buffer_in)``""" +//| :param ReadableBuffer out_buffer: write out bytes from this buffer +//| :param WriteableBuffer in_buffer: read bytes into this buffer +//| :param int out_start: beginning of ``out_buffer`` slice +//| :param int out_end: end of ``out_buffer`` slice; if not specified, use ``len(out_buffer)`` +//| :param int in_start: beginning of ``in_buffer`` slice +//| :param int in_end: end of ``in_buffer slice``; if not specified, use ``len(in_buffer)`` +//| """ //| ... //| STATIC mp_obj_t bitbangio_spi_write_readinto(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { - enum { ARG_buffer_out, ARG_buffer_in, ARG_out_start, ARG_out_end, ARG_in_start, ARG_in_end }; + enum { ARG_out_buffer, ARG_in_buffer, ARG_out_start, ARG_out_end, ARG_in_start, ARG_in_end }; static const mp_arg_t allowed_args[] = { - { MP_QSTR_buffer_out, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, - { MP_QSTR_buffer_in, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, + { MP_QSTR_out_buffer, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, + { MP_QSTR_in_buffer, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, { MP_QSTR_out_start, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} }, { MP_QSTR_out_end, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = INT_MAX} }, { MP_QSTR_in_start, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} }, @@ -301,13 +317,13 @@ STATIC mp_obj_t bitbangio_spi_write_readinto(size_t n_args, const mp_obj_t *pos_ mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); mp_buffer_info_t buf_out_info; - mp_get_buffer_raise(args[ARG_buffer_out].u_obj, &buf_out_info, MP_BUFFER_READ); + mp_get_buffer_raise(args[ARG_out_buffer].u_obj, &buf_out_info, MP_BUFFER_READ); int32_t out_start = args[ARG_out_start].u_int; size_t out_length = buf_out_info.len; normalize_buffer_bounds(&out_start, args[ARG_out_end].u_int, &out_length); mp_buffer_info_t buf_in_info; - mp_get_buffer_raise(args[ARG_buffer_in].u_obj, &buf_in_info, MP_BUFFER_WRITE); + mp_get_buffer_raise(args[ARG_in_buffer].u_obj, &buf_in_info, MP_BUFFER_WRITE); int32_t in_start = args[ARG_in_start].u_int; size_t in_length = buf_in_info.len; normalize_buffer_bounds(&in_start, args[ARG_in_end].u_int, &in_length); @@ -329,7 +345,7 @@ STATIC mp_obj_t bitbangio_spi_write_readinto(size_t n_args, const mp_obj_t *pos_ } return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_KW(bitbangio_spi_write_readinto_obj, 2, bitbangio_spi_write_readinto); +MP_DEFINE_CONST_FUN_OBJ_KW(bitbangio_spi_write_readinto_obj, 1, bitbangio_spi_write_readinto); STATIC const mp_rom_map_elem_t bitbangio_spi_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&bitbangio_spi_deinit_obj) }, diff --git a/shared-bindings/bitops/__init__.c b/shared-bindings/bitops/__init__.c index d9849da917..5b455dcb0f 100644 --- a/shared-bindings/bitops/__init__.c +++ b/shared-bindings/bitops/__init__.c @@ -86,7 +86,7 @@ STATIC mp_obj_t bit_transpose(size_t n_args, const mp_obj_t *pos_args, mp_map_t common_hal_bitops_bit_transpose(output_bufinfo.buf, input_bufinfo.buf, inlen, width); return args[ARG_output].u_obj; } -STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bitops_bit_transpose_obj, 1, bit_transpose); +STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bitops_bit_transpose_obj, 0, bit_transpose); STATIC const mp_rom_map_elem_t bitops_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_bitops) }, diff --git a/shared-bindings/busio/I2C.c b/shared-bindings/busio/I2C.c index 344dad8acc..740bd7cca4 100644 --- a/shared-bindings/busio/I2C.c +++ b/shared-bindings/busio/I2C.c @@ -176,19 +176,19 @@ STATIC mp_obj_t busio_i2c_obj_unlock(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(busio_i2c_unlock_obj, busio_i2c_obj_unlock); -//| def readfrom_into(self, address: int, buffer: WriteableBuffer, *, start: int = 0, end: Optional[int] = None) -> None: +//| import sys +//| def readfrom_into(self, address: int, buffer: WriteableBuffer, *, start: int = 0, end: int = sys.maxsize) -> None: //| """Read into ``buffer`` from the device selected by ``address``. -//| The number of bytes read will be the length of ``buffer``. //| At least one byte must be read. //| //| If ``start`` or ``end`` is provided, then the buffer will be sliced -//| as if ``buffer[start:end]``. This will not cause an allocation like -//| ``buf[start:end]`` will so it saves memory. +//| as if ``buffer[start:end]`` were passed, but without copying the data. +//| The number of bytes read will be the length of ``buffer[start:end]``. //| //| :param int address: 7-bit device address -//| :param ~_typing.WriteableBuffer buffer: buffer to write into -//| :param int start: Index to start writing at -//| :param int end: Index to write up to but not include. Defaults to ``len(buffer)``""" +//| :param WriteableBuffer buffer: buffer to write into +//| :param int start: beginning of buffer slice +//| :param int end: end of buffer slice; if not specified, use ``len(buffer)``""" //| ... //| // Shared arg parsing for readfrom_into and writeto_then_readfrom. @@ -226,23 +226,25 @@ STATIC mp_obj_t busio_i2c_readfrom_into(size_t n_args, const mp_obj_t *pos_args, args[ARG_end].u_int); return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_KW(busio_i2c_readfrom_into_obj, 3, busio_i2c_readfrom_into); +MP_DEFINE_CONST_FUN_OBJ_KW(busio_i2c_readfrom_into_obj, 1, busio_i2c_readfrom_into); -//| def writeto(self, address: int, buffer: ReadableBuffer, *, start: int = 0, end: Optional[int] = None) -> None: +//| import sys +//| def writeto(self, address: int, buffer: ReadableBuffer, *, start: int = 0, end: int = sys.maxsize) -> None: //| """Write the bytes from ``buffer`` to the device selected by ``address`` and //| then transmit a stop bit. //| //| If ``start`` or ``end`` is provided, then the buffer will be sliced -//| as if ``buffer[start:end]``. This will not cause an allocation like -//| ``buffer[start:end]`` will so it saves memory. +//| as if ``buffer[start:end]`` were passed, but without copying the data. +//| The number of bytes written will be the length of ``buffer[start:end]``. //| //| Writing a buffer or slice of length zero is permitted, as it can be used //| to poll for the existence of a device. //| //| :param int address: 7-bit device address -//| :param ~_typing.ReadableBuffer buffer: buffer containing the bytes to write -//| :param int start: Index to start writing from -//| :param int end: Index to read up to but not include. Defaults to ``len(buffer)``""" +//| :param ReadableBuffer buffer: buffer containing the bytes to write +//| :param int start: beginning of buffer slice +//| :param int end: end of buffer slice; if not specified, use ``len(buffer)`` +//| """ //| ... //| // Shared arg parsing for writeto and writeto_then_readfrom. @@ -282,22 +284,28 @@ STATIC mp_obj_t busio_i2c_writeto(size_t n_args, const mp_obj_t *pos_args, mp_ma } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(busio_i2c_writeto_obj, 1, busio_i2c_writeto); -//| def writeto_then_readfrom(self, address: int, out_buffer: ReadableBuffer, in_buffer: WriteableBuffer, *, out_start: int = 0, out_end: Optional[int] = None, in_start: int = 0, in_end: Optional[int] = None) -> None: +//| import sys +//| def writeto_then_readfrom(self, address: int, out_buffer: ReadableBuffer, in_buffer: WriteableBuffer, *, out_start: int = 0, out_end: int = sys.maxsize, in_start: int = 0, in_end: int = sys.maxsize) -> None: //| """Write the bytes from ``out_buffer`` to the device selected by ``address``, generate no stop //| bit, generate a repeated start and read into ``in_buffer``. ``out_buffer`` and //| ``in_buffer`` can be the same buffer because they are used sequentially. //| -//| If ``start`` or ``end`` is provided, then the corresponding buffer will be sliced -//| as if ``buffer[start:end]``. This will not cause an allocation like ``buf[start:end]`` -//| will so it saves memory. +//| If ``out_start`` or ``out_end`` is provided, then the buffer will be sliced +//| as if ``out_buffer[out_start:out_end]`` were passed, but without copying the data. +//| The number of bytes written will be the length of ``out_buffer[start:end]``. //| +//| If ``in_start`` or ``in_end`` is provided, then the input buffer will be sliced +//| as if ``in_buffer[in_start:in_end]`` were passed, +//| The number of bytes read will be the length of ``out_buffer[in_start:in_end]``. + //| :param int address: 7-bit device address //| :param ~_typing.ReadableBuffer out_buffer: buffer containing the bytes to write //| :param ~_typing.WriteableBuffer in_buffer: buffer to write into -//| :param int out_start: Index to start writing from -//| :param int out_end: Index to read up to but not include. Defaults to ``len(buffer)`` -//| :param int in_start: Index to start writing at -//| :param int in_end: Index to write up to but not include. Defaults to ``len(buffer)``""" +//| :param int out_start: beginning of ``out_buffer`` slice +//| :param int out_end: end of ``out_buffer`` slice; if not specified, use ``len(out_buffer)`` +//| :param int in_start: beginning of ``in_buffer`` slice +//| :param int in_end: end of ``in_buffer slice``; if not specified, use ``len(in_buffer)`` +//| """ //| ... //| STATIC mp_obj_t busio_i2c_writeto_then_readfrom(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { @@ -324,7 +332,7 @@ STATIC mp_obj_t busio_i2c_writeto_then_readfrom(size_t n_args, const mp_obj_t *p return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_KW(busio_i2c_writeto_then_readfrom_obj, 3, busio_i2c_writeto_then_readfrom); +MP_DEFINE_CONST_FUN_OBJ_KW(busio_i2c_writeto_then_readfrom_obj, 1, busio_i2c_writeto_then_readfrom); STATIC const mp_rom_map_elem_t busio_i2c_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&busio_i2c_deinit_obj) }, diff --git a/shared-bindings/busio/SPI.c b/shared-bindings/busio/SPI.c index a611d8e1d5..ceebce974b 100644 --- a/shared-bindings/busio/SPI.c +++ b/shared-bindings/busio/SPI.c @@ -237,13 +237,19 @@ STATIC mp_obj_t busio_spi_obj_unlock(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(busio_spi_unlock_obj, busio_spi_obj_unlock); -//| def write(self, buffer: ReadableBuffer, *, start: int = 0, end: Optional[int] = None) -> None: +//| import sys +//| def write(self, buffer: ReadableBuffer, *, start: int = 0, end: int = sys.maxsize) -> None: //| """Write the data contained in ``buffer``. The SPI object must be locked. //| If the buffer is empty, nothing happens. //| -//| :param ~_typing.ReadableBuffer buffer: Write out the data in this buffer -//| :param int start: Start of the slice of ``buffer`` to write out: ``buffer[start:end]`` -//| :param int end: End of the slice; this index is not included. Defaults to ``len(buffer)``""" +//| If ``start`` or ``end`` is provided, then the buffer will be sliced +//| as if ``buffer[start:end]`` were passed, but without copying the data. +//| The number of bytes written will be the length of ``buffer[start:end]``. +//| +//| :param ReadableBuffer buffer: write out bytes from this buffer +//| :param int start: beginning of buffer slice +//| :param int end: end of buffer slice; if not specified, use ``len(buffer)`` +//| """ //| ... //| @@ -276,18 +282,24 @@ STATIC mp_obj_t busio_spi_write(size_t n_args, const mp_obj_t *pos_args, mp_map_ } return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_KW(busio_spi_write_obj, 2, busio_spi_write); +MP_DEFINE_CONST_FUN_OBJ_KW(busio_spi_write_obj, 1, busio_spi_write); -//| def readinto(self, buffer: WriteableBuffer, *, start: int = 0, end: Optional[int] = None, write_value: int = 0) -> None: +//| import sys +//| def readinto(self, buffer: WriteableBuffer, *, start: int = 0, end: int = sys.maxsize, write_value: int = 0) -> None: //| """Read into ``buffer`` while writing ``write_value`` for each byte read. //| The SPI object must be locked. //| If the number of bytes to read is 0, nothing happens. //| -//| :param ~_typing.WriteableBuffer buffer: Read data into this buffer -//| :param int start: Start of the slice of ``buffer`` to read into: ``buffer[start:end]`` -//| :param int end: End of the slice; this index is not included. Defaults to ``len(buffer)`` -//| :param int write_value: Value to write while reading. (Usually ignored.)""" +//| If ``start`` or ``end`` is provided, then the buffer will be sliced +//| as if ``buffer[start:end]`` were passed. +//| The number of bytes read will be the length of ``buffer[start:end]``. +//| +//| :param WriteableBuffer buffer: read bytes into this buffer +//| :param int start: beginning of buffer slice +//| :param int end: end of buffer slice; if not specified, use ``len(buffer)`` +//| :param int write_value: value to write while reading +//| """ //| ... //| @@ -321,29 +333,40 @@ STATIC mp_obj_t busio_spi_readinto(size_t n_args, const mp_obj_t *pos_args, mp_m } return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_KW(busio_spi_readinto_obj, 2, busio_spi_readinto); +MP_DEFINE_CONST_FUN_OBJ_KW(busio_spi_readinto_obj, 1, busio_spi_readinto); -//| def write_readinto(self, buffer_out: ReadableBuffer, buffer_in: WriteableBuffer, *, out_start: int = 0, out_end: Optional[int] = None, in_start: int = 0, in_end: Optional[int] = None) -> None: -//| """Write out the data in ``buffer_out`` while simultaneously reading data into ``buffer_in``. +//| import sys +//| def write_readinto(self, out_buffer: ReadableBuffer, in_buffer: WriteableBuffer, *, out_start: int = 0, out_end: int = sys.maxsize, in_start: int = 0, in_end: int = sys.maxsize) -> None: +//| """Write out the data in ``out_buffer`` while simultaneously reading data into ``in_buffer``. //| The SPI object must be locked. -//| The lengths of the slices defined by ``buffer_out[out_start:out_end]`` and ``buffer_in[in_start:in_end]`` -//| must be equal. +//| +//| If ``out_start`` or ``out_end`` is provided, then the buffer will be sliced +//| as if ``out_buffer[out_start:out_end]`` were passed, but without copying the data. +//| The number of bytes written will be the length of ``out_buffer[out_start:out_end]``. +//| +//| If ``in_start`` or ``in_end`` is provided, then the input buffer will be sliced +//| as if ``in_buffer[in_start:in_end]`` were passed, +//| The number of bytes read will be the length of ``out_buffer[in_start:in_end]``. +//| +//| The lengths of the slices defined by ``out_buffer[out_start:out_end]`` +//| and ``in_buffer[in_start:in_end]`` must be equal. //| If buffer slice lengths are both 0, nothing happens. //| -//| :param ~_typing.ReadableBuffer buffer_out: Write out the data in this buffer -//| :param ~_typing.WriteableBuffer buffer_in: Read data into this buffer -//| :param int out_start: Start of the slice of buffer_out to write out: ``buffer_out[out_start:out_end]`` -//| :param int out_end: End of the slice; this index is not included. Defaults to ``len(buffer_out)`` -//| :param int in_start: Start of the slice of ``buffer_in`` to read into: ``buffer_in[in_start:in_end]`` -//| :param int in_end: End of the slice; this index is not included. Defaults to ``len(buffer_in)``""" +//| :param ReadableBuffer out_buffer: write out bytes from this buffer +//| :param WriteableBuffer in_buffer: read bytes into this buffer +//| :param int out_start: beginning of ``out_buffer`` slice +//| :param int out_end: end of ``out_buffer`` slice; if not specified, use ``len(out_buffer)`` +//| :param int in_start: beginning of ``in_buffer`` slice +//| :param int in_end: end of ``in_buffer slice``; if not specified, use ``len(in_buffer)`` +//| """ //| ... //| STATIC mp_obj_t busio_spi_write_readinto(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { - enum { ARG_buffer_out, ARG_buffer_in, ARG_out_start, ARG_out_end, ARG_in_start, ARG_in_end }; + enum { ARG_out_buffer, ARG_in_buffer, ARG_out_start, ARG_out_end, ARG_in_start, ARG_in_end }; static const mp_arg_t allowed_args[] = { - { MP_QSTR_buffer_out, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, - { MP_QSTR_buffer_in, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, + { MP_QSTR_out_buffer, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, + { MP_QSTR_in_buffer, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, { MP_QSTR_out_start, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} }, { MP_QSTR_out_end, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = INT_MAX} }, { MP_QSTR_in_start, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} }, @@ -356,13 +379,13 @@ STATIC mp_obj_t busio_spi_write_readinto(size_t n_args, const mp_obj_t *pos_args mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); mp_buffer_info_t buf_out_info; - mp_get_buffer_raise(args[ARG_buffer_out].u_obj, &buf_out_info, MP_BUFFER_READ); + mp_get_buffer_raise(args[ARG_out_buffer].u_obj, &buf_out_info, MP_BUFFER_READ); int32_t out_start = args[ARG_out_start].u_int; size_t out_length = buf_out_info.len; normalize_buffer_bounds(&out_start, args[ARG_out_end].u_int, &out_length); mp_buffer_info_t buf_in_info; - mp_get_buffer_raise(args[ARG_buffer_in].u_obj, &buf_in_info, MP_BUFFER_WRITE); + mp_get_buffer_raise(args[ARG_in_buffer].u_obj, &buf_in_info, MP_BUFFER_WRITE); int32_t in_start = args[ARG_in_start].u_int; size_t in_length = buf_in_info.len; normalize_buffer_bounds(&in_start, args[ARG_in_end].u_int, &in_length); @@ -384,7 +407,7 @@ STATIC mp_obj_t busio_spi_write_readinto(size_t n_args, const mp_obj_t *pos_args } return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_KW(busio_spi_write_readinto_obj, 2, busio_spi_write_readinto); +MP_DEFINE_CONST_FUN_OBJ_KW(busio_spi_write_readinto_obj, 1, busio_spi_write_readinto); //| frequency: int //| """The actual SPI bus frequency. This may not match the frequency requested diff --git a/shared-bindings/camera/Camera.c b/shared-bindings/camera/Camera.c index a588965005..2e84f702cf 100644 --- a/shared-bindings/camera/Camera.c +++ b/shared-bindings/camera/Camera.c @@ -116,7 +116,7 @@ STATIC mp_obj_t camera_obj_take_picture(size_t n_args, const mp_obj_t *pos_args, return MP_OBJ_NEW_SMALL_INT(common_hal_camera_take_picture(self, (uint8_t *)bufinfo.buf, bufinfo.len, args[ARG_width].u_int, args[ARG_height].u_int, format)); } -MP_DEFINE_CONST_FUN_OBJ_KW(camera_take_picture_obj, 2, camera_obj_take_picture); +MP_DEFINE_CONST_FUN_OBJ_KW(camera_take_picture_obj, 1, camera_obj_take_picture); STATIC const mp_rom_map_elem_t camera_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&camera_deinit_obj) }, diff --git a/shared-bindings/displayio/Bitmap.c b/shared-bindings/displayio/Bitmap.c index b56991c0c2..de2be6d637 100644 --- a/shared-bindings/displayio/Bitmap.c +++ b/shared-bindings/displayio/Bitmap.c @@ -285,8 +285,7 @@ STATIC mp_obj_t displayio_bitmap_obj_blit(size_t n_args, const mp_obj_t *pos_arg return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_KW(displayio_bitmap_blit_obj, 4, displayio_bitmap_obj_blit); -// `displayio_bitmap_obj_blit` requires at least 4 arguments +MP_DEFINE_CONST_FUN_OBJ_KW(displayio_bitmap_blit_obj, 1, displayio_bitmap_obj_blit); //| def fill(self, value: int) -> None: //| """Fills the bitmap with the supplied palette index value.""" diff --git a/shared-bindings/displayio/EPaperDisplay.c b/shared-bindings/displayio/EPaperDisplay.c index afe1321251..8d9b68f2b0 100644 --- a/shared-bindings/displayio/EPaperDisplay.c +++ b/shared-bindings/displayio/EPaperDisplay.c @@ -240,7 +240,7 @@ STATIC mp_obj_t displayio_epaperdisplay_update_refresh_mode(size_t n_args, const displayio_epaperdisplay_change_refresh_mode_parameters(self, &start_sequence, seconds_per_frame); return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_KW(displayio_epaperdisplay_update_refresh_mode_obj, 3, displayio_epaperdisplay_update_refresh_mode); +MP_DEFINE_CONST_FUN_OBJ_KW(displayio_epaperdisplay_update_refresh_mode_obj, 1, displayio_epaperdisplay_update_refresh_mode); //| def refresh(self) -> None: //| """Refreshes the display immediately or raises an exception if too soon. Use diff --git a/shared-bindings/displayio/FourWire.c b/shared-bindings/displayio/FourWire.c index 2145425342..c065fee551 100644 --- a/shared-bindings/displayio/FourWire.c +++ b/shared-bindings/displayio/FourWire.c @@ -149,7 +149,7 @@ STATIC mp_obj_t displayio_fourwire_obj_send(size_t n_args, const mp_obj_t *pos_a return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_KW(displayio_fourwire_send_obj, 3, displayio_fourwire_obj_send); +MP_DEFINE_CONST_FUN_OBJ_KW(displayio_fourwire_send_obj, 1, displayio_fourwire_obj_send); STATIC const mp_rom_map_elem_t displayio_fourwire_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_reset), MP_ROM_PTR(&displayio_fourwire_reset_obj) }, diff --git a/shared-bindings/msgpack/__init__.c b/shared-bindings/msgpack/__init__.c index 65d5558e60..d71ab9a6b9 100644 --- a/shared-bindings/msgpack/__init__.c +++ b/shared-bindings/msgpack/__init__.c @@ -112,7 +112,7 @@ STATIC mp_obj_t mod_msgpack_pack(size_t n_args, const mp_obj_t *pos_args, mp_map common_hal_msgpack_pack(args[ARG_obj].u_obj, args[ARG_buffer].u_obj, handler); return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_KW(mod_msgpack_pack_obj, 1, mod_msgpack_pack); +MP_DEFINE_CONST_FUN_OBJ_KW(mod_msgpack_pack_obj, 0, mod_msgpack_pack); //| def unpack(buffer: ReadableBuffer, *, ext_hook: Union[Callable[[int, bytes], object], None] = None, use_list: bool=True) -> object: @@ -144,7 +144,7 @@ STATIC mp_obj_t mod_msgpack_unpack(size_t n_args, const mp_obj_t *pos_args, mp_m return common_hal_msgpack_unpack(args[ARG_buffer].u_obj, hook, args[ARG_use_list].u_bool); } -MP_DEFINE_CONST_FUN_OBJ_KW(mod_msgpack_unpack_obj, 1, mod_msgpack_unpack); +MP_DEFINE_CONST_FUN_OBJ_KW(mod_msgpack_unpack_obj, 0, mod_msgpack_unpack); STATIC const mp_rom_map_elem_t msgpack_module_globals_table[] = { diff --git a/shared-bindings/os/__init__.c b/shared-bindings/os/__init__.c index 798f3c361f..fc246582fd 100644 --- a/shared-bindings/os/__init__.c +++ b/shared-bindings/os/__init__.c @@ -247,3 +247,5 @@ const mp_obj_module_t os_module = { .base = { &mp_type_module }, .globals = (mp_obj_dict_t *)&os_module_globals, }; + +MP_REGISTER_MODULE(MP_QSTR_os, os_module, CIRCUITPY_OS); diff --git a/shared-bindings/qrio/QRDecoder.c b/shared-bindings/qrio/QRDecoder.c index 73a5d64694..689c1c6884 100644 --- a/shared-bindings/qrio/QRDecoder.c +++ b/shared-bindings/qrio/QRDecoder.c @@ -88,7 +88,7 @@ STATIC mp_obj_t qrio_qrdecoder_decode(size_t n_args, const mp_obj_t *pos_args, m return shared_module_qrio_qrdecoder_decode(self, &bufinfo, policy); } -MP_DEFINE_CONST_FUN_OBJ_KW(qrio_qrdecoder_decode_obj, 2, qrio_qrdecoder_decode); +MP_DEFINE_CONST_FUN_OBJ_KW(qrio_qrdecoder_decode_obj, 1, qrio_qrdecoder_decode); //| width: int //| """The width of image the decoder expects""" diff --git a/shared-bindings/socketpool/SocketPool.c b/shared-bindings/socketpool/SocketPool.c index bd6a2b44f9..90f4fb8d75 100644 --- a/shared-bindings/socketpool/SocketPool.c +++ b/shared-bindings/socketpool/SocketPool.c @@ -69,19 +69,20 @@ STATIC mp_obj_t socketpool_socketpool_make_new(const mp_obj_type_t *type, size_t //| :param ~int type: SOCK_STREAM, SOCK_DGRAM or SOCK_RAW""" //| ... //| - STATIC mp_obj_t socketpool_socketpool_socket(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { - mp_arg_check_num(n_args, kw_args, 0, 5, false); + enum { ARG_family, ARG_type }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_family, MP_ARG_INT, {.u_int = SOCKETPOOL_AF_INET} }, + { MP_QSTR_type, MP_ARG_INT, {.u_int = SOCKETPOOL_SOCK_STREAM} }, + }; + socketpool_socketpool_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); + + mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; + mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + + socketpool_socketpool_addressfamily_t family = args[ARG_family].u_int; + socketpool_socketpool_sock_t type = args[ARG_type].u_int; - socketpool_socketpool_obj_t *self = pos_args[0]; - socketpool_socketpool_addressfamily_t family = SOCKETPOOL_AF_INET; - socketpool_socketpool_sock_t type = SOCKETPOOL_SOCK_STREAM; - if (n_args >= 2) { - family = mp_obj_get_int(pos_args[1]); - if (n_args >= 3) { - type = mp_obj_get_int(pos_args[2]); - } - } return common_hal_socketpool_socket(self, family, type); } MP_DEFINE_CONST_FUN_OBJ_KW(socketpool_socketpool_socket_obj, 1, socketpool_socketpool_socket); @@ -94,7 +95,6 @@ MP_DEFINE_CONST_FUN_OBJ_KW(socketpool_socketpool_socket_obj, 1, socketpool_socke //| as a tuple.""" //| ... //| - STATIC mp_obj_t socketpool_socketpool_getaddrinfo(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_host, ARG_port, ARG_family, ARG_type, ARG_proto, ARG_flags }; static const mp_arg_t allowed_args[] = { @@ -137,7 +137,7 @@ STATIC mp_obj_t socketpool_socketpool_getaddrinfo(size_t n_args, const mp_obj_t tuple->items[4] = MP_OBJ_FROM_PTR(sockaddr); return mp_obj_new_list(1, (mp_obj_t *)&tuple); } -STATIC MP_DEFINE_CONST_FUN_OBJ_KW(socketpool_socketpool_getaddrinfo_obj, 3, socketpool_socketpool_getaddrinfo); +STATIC MP_DEFINE_CONST_FUN_OBJ_KW(socketpool_socketpool_getaddrinfo_obj, 1, socketpool_socketpool_getaddrinfo); STATIC const mp_rom_map_elem_t socketpool_socketpool_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_socket), MP_ROM_PTR(&socketpool_socketpool_socket_obj) }, diff --git a/shared-bindings/ssl/SSLContext.c b/shared-bindings/ssl/SSLContext.c index 4a3dafb981..f90365054a 100644 --- a/shared-bindings/ssl/SSLContext.c +++ b/shared-bindings/ssl/SSLContext.c @@ -79,7 +79,7 @@ STATIC mp_obj_t ssl_sslcontext_wrap_socket(size_t n_args, const mp_obj_t *pos_ar return common_hal_ssl_sslcontext_wrap_socket(self, sock, server_side, server_hostname); } -STATIC MP_DEFINE_CONST_FUN_OBJ_KW(ssl_sslcontext_wrap_socket_obj, 2, ssl_sslcontext_wrap_socket); +STATIC MP_DEFINE_CONST_FUN_OBJ_KW(ssl_sslcontext_wrap_socket_obj, 1, ssl_sslcontext_wrap_socket); STATIC const mp_rom_map_elem_t ssl_sslcontext_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_wrap_socket), MP_ROM_PTR(&ssl_sslcontext_wrap_socket_obj) }, diff --git a/shared-bindings/storage/__init__.c b/shared-bindings/storage/__init__.c index ddd2b9a1a9..c5769b56b5 100644 --- a/shared-bindings/storage/__init__.c +++ b/shared-bindings/storage/__init__.c @@ -48,26 +48,30 @@ //| //| This is the CircuitPython analog to the UNIX ``mount`` command. //| -//| :param bool readonly: True when the filesystem should be readonly to CircuitPython.""" +//| :param VfsFat filesystem: The filesystem to mount. +//| :param str mount_path: Where to mount the filesystem. +//| :param bool readonly: True when the filesystem should be readonly to CircuitPython. +//| """ //| ... //| mp_obj_t storage_mount(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { - enum { ARG_readonly }; + enum { ARG_filesystem, ARG_mount_path, ARG_readonly }; static const mp_arg_t allowed_args[] = { + { MP_QSTR_filesystem, MP_ARG_OBJ | MP_ARG_REQUIRED }, + { MP_QSTR_mount_path, MP_ARG_OBJ | MP_ARG_REQUIRED }, { MP_QSTR_readonly, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = false} }, }; - // parse args mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args - 2, pos_args + 2, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); // get the mount point - const char *mnt_str = mp_obj_str_get_str(pos_args[1]); + const char *mnt_str = mp_obj_str_get_str(args[ARG_mount_path].u_obj); // Make sure we're given an object we can mount. // TODO(tannewt): Make sure we have all the methods we need to operating it // as a file system. - mp_obj_t vfs_obj = pos_args[0]; + mp_obj_t vfs_obj = args[ARG_filesystem].u_obj; mp_obj_t dest[2]; mp_load_method_maybe(vfs_obj, MP_QSTR_mount, dest); if (dest[0] == MP_OBJ_NULL) { @@ -78,7 +82,7 @@ mp_obj_t storage_mount(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_arg return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_KW(storage_mount_obj, 2, storage_mount); +MP_DEFINE_CONST_FUN_OBJ_KW(storage_mount_obj, 0, storage_mount); //| def umount(mount: Union[str, VfsFat]) -> None: //| """Unmounts the given filesystem object or if *mount* is a path, then unmount @@ -101,6 +105,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(storage_umount_obj, storage_umount); //| def remount(mount_path: str, readonly: bool = False, *, disable_concurrent_write_protection: bool = False) -> None: //| """Remounts the given path with new parameters. //| +//| :param str mount_path: The path to remount. //| :param bool readonly: True when the filesystem should be readonly to CircuitPython. //| :param bool disable_concurrent_write_protection: When True, the check that makes sure the //| underlying filesystem data is written by one computer is disabled. Disabling the protection @@ -109,24 +114,23 @@ MP_DEFINE_CONST_FUN_OBJ_1(storage_umount_obj, storage_umount); //| ... //| mp_obj_t storage_remount(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { - enum { ARG_readonly, ARG_disable_concurrent_write_protection }; + enum { ARG_mount_path, ARG_readonly, ARG_disable_concurrent_write_protection }; static const mp_arg_t allowed_args[] = { + { MP_QSTR_mount_path, MP_ARG_OBJ | MP_ARG_REQUIRED }, { MP_QSTR_readonly, MP_ARG_BOOL, {.u_bool = false} }, { MP_QSTR_disable_concurrent_write_protection, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = false} }, }; - // get the mount point - const char *mnt_str = mp_obj_str_get_str(pos_args[0]); - - // parse args mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + + const char *mnt_str = mp_obj_str_get_str(args[ARG_mount_path].u_obj); common_hal_storage_remount(mnt_str, args[ARG_readonly].u_bool, args[ARG_disable_concurrent_write_protection].u_bool); return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_KW(storage_remount_obj, 1, storage_remount); +MP_DEFINE_CONST_FUN_OBJ_KW(storage_remount_obj, 0, storage_remount); //| def getmount(mount_path: str) -> VfsFat: //| """Retrieves the mount object associated with the mount path""" diff --git a/shared-bindings/time/__init__.c b/shared-bindings/time/__init__.c index cc8689ca33..3aa9b11b6f 100644 --- a/shared-bindings/time/__init__.c +++ b/shared-bindings/time/__init__.c @@ -39,12 +39,26 @@ //| """time and timing related functions //| //| The `time` module is a strict subset of the CPython `cpython:time` module. So, code -//| written in MicroPython will work in CPython but not necessarily the other +//| using `time` written in CircuitPython will work in CPython but not necessarily the other //| way around.""" //| //| def monotonic() -> float: //| """Returns an always increasing value of time with an unknown reference -//| point. Only use it to compare against other values from `monotonic`. +//| point. Only use it to compare against other values from `time.monotonic()`. +//| +//| On most boards, `time.monotonic()` converts a 64-bit millisecond tick counter +//| to a float. Floats on most boards are encoded in 30 bits internally, with +//| effectively 22 bits of precision. The float returned by `time.monotonic()` will +//| accurately represent time to millisecond precision only up to 2**22 milliseconds +//| (about 1.165 hours). +//| At that point it will start losing precision, and its value will change only +//| every second millisecond. At 2**23 milliseconds it will change every fourth +//| millisecond, and so forth. +//| +//| If you need more consistent precision, use `time.monotonic_ns()`, or `supervisor.ticks_ms()`. +//| `time.monotonic_ns()` is not available on boards without long integer support. +//| `supervisor.ticks_ms()` uses intervals of a millisecond, but wraps around, and is not +//| CPython-compatible. //| //| :return: the current monotonic time //| :rtype: float""" @@ -216,7 +230,8 @@ STATIC mp_obj_t time_time(void) { MP_DEFINE_CONST_FUN_OBJ_0(time_time_obj, time_time); //| def monotonic_ns() -> int: -//| """Return the time of the monotonic clock, cannot go backward, in nanoseconds. +//| """Return the time of the monotonic clock, which cannot go backward, in nanoseconds. +//| Not available on boards without long integer support. //| //| :return: the current time //| :rtype: int""" @@ -330,3 +345,5 @@ const mp_obj_module_t time_module = { .base = { &mp_type_module }, .globals = (mp_obj_dict_t *)&time_module_globals, }; + +MP_REGISTER_MODULE(MP_QSTR_time, time_module, CIRCUITPY_TIME); diff --git a/shared-bindings/traceback/__init__.c b/shared-bindings/traceback/__init__.c index 37ef921cca..71fe858dfa 100644 --- a/shared-bindings/traceback/__init__.c +++ b/shared-bindings/traceback/__init__.c @@ -105,7 +105,7 @@ STATIC mp_obj_t traceback_format_exception(size_t n_args, const mp_obj_t *pos_ar return mp_obj_new_str_from_vstr(&mp_type_str, &vstr); } -STATIC MP_DEFINE_CONST_FUN_OBJ_KW(traceback_format_exception_obj, 3, traceback_format_exception); +STATIC MP_DEFINE_CONST_FUN_OBJ_KW(traceback_format_exception_obj, 0, traceback_format_exception); //| def print_exception(etype: Type[BaseException], value: BaseException, tb: TracebackType, //| limit: Optional[int] = None, file: Optional[io.FileIO] = None, chain: Optional[bool] = True) -> None: @@ -155,7 +155,7 @@ STATIC mp_obj_t traceback_print_exception(size_t n_args, const mp_obj_t *pos_arg traceback_exception_common(&print, args[ARG_value].u_obj, args[ARG_tb].u_obj, args[ARG_limit].u_obj); return mp_const_none; } -STATIC MP_DEFINE_CONST_FUN_OBJ_KW(traceback_print_exception_obj, 3, traceback_print_exception); +STATIC MP_DEFINE_CONST_FUN_OBJ_KW(traceback_print_exception_obj, 0, traceback_print_exception); STATIC const mp_rom_map_elem_t traceback_module_globals_table[] = { // module name diff --git a/shared-bindings/usb_hid/Device.c b/shared-bindings/usb_hid/Device.c index 44f3216b01..30379a25e9 100644 --- a/shared-bindings/usb_hid/Device.c +++ b/shared-bindings/usb_hid/Device.c @@ -136,7 +136,7 @@ STATIC mp_obj_t usb_hid_device_make_new(const mp_obj_type_t *type, size_t n_args // It's not the actual argument that's out of range, but its elements. // But the error message is close enough. MP_OBJ_SMALL_INT_VALUE(mp_obj_subscr(report_ids, i_obj, MP_OBJ_SENTINEL)), - 1, 255, MP_QSTR_report_ids); + 0, 255, MP_QSTR_report_ids); in_report_lengths_array[i] = (uint8_t)mp_arg_validate_int_range( MP_OBJ_SMALL_INT_VALUE(mp_obj_subscr(in_report_lengths, i_obj, MP_OBJ_SENTINEL)), @@ -147,6 +147,10 @@ STATIC mp_obj_t usb_hid_device_make_new(const mp_obj_type_t *type, size_t n_args 0, 255, MP_QSTR_out_report_lengths); } + if (report_ids_array[0] == 0 && report_ids_count > 1) { + mp_raise_ValueError_varg(translate("%q with a report ID of 0 must be of length 1"), MP_QSTR_report_ids); + } + common_hal_usb_hid_device_construct( self, descriptor, usage_page, usage, report_ids_count, report_ids_array, in_report_lengths_array, out_report_lengths_array); return (mp_obj_t)self; @@ -185,7 +189,7 @@ STATIC mp_obj_t usb_hid_device_send_report(size_t n_args, const mp_obj_t *pos_ar common_hal_usb_hid_device_send_report(self, ((uint8_t *)bufinfo.buf), bufinfo.len, report_id); return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_KW(usb_hid_device_send_report_obj, 2, usb_hid_device_send_report); +MP_DEFINE_CONST_FUN_OBJ_KW(usb_hid_device_send_report_obj, 1, usb_hid_device_send_report); //| def get_last_received_report(self, report_id: Optional[int] = None) -> bytes: //| """Get the last received HID OUT report for the given report ID. diff --git a/shared-module/_stage/Layer.c b/shared-module/_stage/Layer.c index df2b27fa13..6d06e7261f 100644 --- a/shared-module/_stage/Layer.c +++ b/shared-module/_stage/Layer.c @@ -29,7 +29,7 @@ // Get the color of the pixel on the layer. -uint16_t get_layer_pixel(layer_obj_t *layer, uint16_t x, uint16_t y) { +uint16_t get_layer_pixel(layer_obj_t *layer, int16_t x, int16_t y) { // Shift by the layer's position offset. x -= layer->x; diff --git a/shared-module/_stage/Layer.h b/shared-module/_stage/Layer.h index 17d101263f..4233847641 100644 --- a/shared-module/_stage/Layer.h +++ b/shared-module/_stage/Layer.h @@ -43,6 +43,6 @@ typedef struct { uint8_t rotation; } layer_obj_t; -uint16_t get_layer_pixel(layer_obj_t *layer, uint16_t x, uint16_t y); +uint16_t get_layer_pixel(layer_obj_t *layer, int16_t x, int16_t y); #endif // MICROPY_INCLUDED_SHARED_MODULE__STAGE_LAYER diff --git a/shared-module/_stage/Text.c b/shared-module/_stage/Text.c index 91223f5258..a803b85de4 100644 --- a/shared-module/_stage/Text.c +++ b/shared-module/_stage/Text.c @@ -29,7 +29,7 @@ // Get the color of the pixel on the text. -uint16_t get_text_pixel(text_obj_t *text, uint16_t x, uint16_t y) { +uint16_t get_text_pixel(text_obj_t *text, int16_t x, int16_t y) { // Shift by the text's position offset. x -= text->x; diff --git a/shared-module/_stage/Text.h b/shared-module/_stage/Text.h index b263fc7108..dd75465d17 100644 --- a/shared-module/_stage/Text.h +++ b/shared-module/_stage/Text.h @@ -41,6 +41,6 @@ typedef struct { uint8_t width, height; } text_obj_t; -uint16_t get_text_pixel(text_obj_t *text, uint16_t x, uint16_t y); +uint16_t get_text_pixel(text_obj_t *text, int16_t x, int16_t y); #endif // MICROPY_INCLUDED_SHARED_MODULE__STAGE_TEXT diff --git a/shared-module/_stage/__init__.c b/shared-module/_stage/__init__.c index 06a12aa0a7..7ec640bc6e 100644 --- a/shared-module/_stage/__init__.c +++ b/shared-module/_stage/__init__.c @@ -31,7 +31,10 @@ #include "shared-bindings/_stage/Text.h" -void render_stage(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, +void render_stage( + uint16_t x0, uint16_t y0, + uint16_t x1, uint16_t y1, + int16_t vx, int16_t vy, mp_obj_t *layers, size_t layers_size, uint16_t *buffer, size_t buffer_size, displayio_display_obj_t *display, @@ -39,13 +42,14 @@ void render_stage(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, displayio_area_t area; - area.x1 = x0; - area.y1 = y0; - area.x2 = x1; - area.y2 = y1; + area.x1 = x0 * scale; + area.y1 = y0 * scale; + area.x2 = x1 * scale; + area.y2 = y1 * scale; displayio_display_core_set_region_to_update( &display->core, display->set_column_command, display->set_row_command, - NO_COMMAND, NO_COMMAND, display->data_as_commands, false, &area, display->SH1107_addressing); + NO_COMMAND, NO_COMMAND, display->data_as_commands, false, &area, + display->SH1107_addressing); while (!displayio_display_core_begin_transaction(&display->core)) { RUN_BACKGROUND_TASKS; @@ -54,9 +58,9 @@ void render_stage(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, CHIP_SELECT_TOGGLE_EVERY_BYTE, &display->write_ram_command, 1); size_t index = 0; - for (uint16_t y = y0; y < y1; ++y) { + for (int16_t y = y0 + vy; y < y1 + vy; ++y) { for (uint8_t yscale = 0; yscale < scale; ++yscale) { - for (uint16_t x = x0; x < x1; ++x) { + for (int16_t x = x0 + vx; x < x1 + vx; ++x) { uint16_t c = TRANSPARENT; for (size_t layer = 0; layer < layers_size; ++layer) { layer_obj_t *obj = MP_OBJ_TO_PTR(layers[layer]); diff --git a/shared-module/_stage/__init__.h b/shared-module/_stage/__init__.h index 5cbaa235b6..596752bee5 100644 --- a/shared-module/_stage/__init__.h +++ b/shared-module/_stage/__init__.h @@ -34,7 +34,10 @@ #define TRANSPARENT (0x1ff8) -void render_stage(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, +void render_stage( + uint16_t x0, uint16_t y0, + uint16_t x1, uint16_t y1, + int16_t vx, int16_t vy, mp_obj_t *layers, size_t layers_size, uint16_t *buffer, size_t buffer_size, displayio_display_obj_t *display, diff --git a/shared-module/usb_cdc/__init__.c b/shared-module/usb_cdc/__init__.c index 5881ec4c32..9961d6d53f 100644 --- a/shared-module/usb_cdc/__init__.c +++ b/shared-module/usb_cdc/__init__.c @@ -35,6 +35,11 @@ #include "tusb.h" +#if CIRCUITPY_USB_VENDOR +// todo - this doesn't feel like it should be here. +#include "supervisor/memory.h" +#endif + #if CFG_TUD_CDC != 2 #error CFG_TUD_CDC must be exactly 2 #endif @@ -259,3 +264,154 @@ bool common_hal_usb_cdc_enable(bool console, bool data) { return true; } + +#if CIRCUITPY_USB_VENDOR +#include "usb_vendor_descriptors.h" + +#define BOS_TOTAL_LEN (TUD_BOS_DESC_LEN + TUD_BOS_WEBUSB_DESC_LEN + TUD_BOS_MICROSOFT_OS_DESC_LEN) + +#define MS_OS_20_DESC_LEN 0xB2 + +// BOS Descriptor is required for webUSB +uint8_t const desc_bos[] = +{ + // total length, number of device caps + TUD_BOS_DESCRIPTOR(BOS_TOTAL_LEN, 2), + + // Vendor Code, iLandingPage + TUD_BOS_WEBUSB_DESCRIPTOR(VENDOR_REQUEST_WEBUSB, 1), + + // Microsoft OS 2.0 descriptor + TUD_BOS_MS_OS_20_DESCRIPTOR(MS_OS_20_DESC_LEN, VENDOR_REQUEST_MICROSOFT) +}; + +uint8_t const *tud_descriptor_bos_cb(void) { + return desc_bos; +} + +#define MS_OS_20_ITF_NUM_MAGIC 0x5b +#define MS_OS_20_ITF_NUM_OFFSET 22 + +const uint8_t ms_os_20_descriptor_template[] = +{ + // 10 Set header: length, type, windows version, total length + U16_TO_U8S_LE(0x000A), U16_TO_U8S_LE(MS_OS_20_SET_HEADER_DESCRIPTOR), U32_TO_U8S_LE(0x06030000), U16_TO_U8S_LE(MS_OS_20_DESC_LEN), + + // 8 Configuration subset header: length, type, configuration index, reserved, configuration total length + U16_TO_U8S_LE(0x0008), U16_TO_U8S_LE(MS_OS_20_SUBSET_HEADER_CONFIGURATION), 0, 0, U16_TO_U8S_LE(MS_OS_20_DESC_LEN - 0x0A), + + // 8 Function Subset header: length, type, first interface, reserved, subset length + U16_TO_U8S_LE(0x0008), U16_TO_U8S_LE(MS_OS_20_SUBSET_HEADER_FUNCTION), /* 22 */ MS_OS_20_ITF_NUM_MAGIC, 0, U16_TO_U8S_LE(MS_OS_20_DESC_LEN - 0x0A - 0x08), + + // 20 MS OS 2.0 Compatible ID descriptor: length, type, compatible ID, sub compatible ID + U16_TO_U8S_LE(0x0014), U16_TO_U8S_LE(MS_OS_20_FEATURE_COMPATBLE_ID), 'W', 'I', 'N', 'U', 'S', 'B', 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // sub-compatible + + // MS OS 2.0 Registry property descriptor: length, type + U16_TO_U8S_LE(MS_OS_20_DESC_LEN - 0x0A - 0x08 - 0x08 - 0x14), U16_TO_U8S_LE(MS_OS_20_FEATURE_REG_PROPERTY), + U16_TO_U8S_LE(0x0007), U16_TO_U8S_LE(0x002A), // wPropertyDataType, wPropertyNameLength and PropertyName "DeviceInterfaceGUIDs\0" in UTF-16 + 'D', 0x00, 'e', 0x00, 'v', 0x00, 'i', 0x00, 'c', 0x00, 'e', 0x00, 'I', 0x00, 'n', 0x00, 't', 0x00, 'e', 0x00, + 'r', 0x00, 'f', 0x00, 'a', 0x00, 'c', 0x00, 'e', 0x00, 'G', 0x00, 'U', 0x00, 'I', 0x00, 'D', 0x00, 's', 0x00, 0x00, 0x00, + U16_TO_U8S_LE(0x0050), // wPropertyDataLength + // bPropertyData: “{975F44D9-0D08-43FD-8B3E-127CA8AFFF9D}”. + '{', 0x00, '9', 0x00, '7', 0x00, '5', 0x00, 'F', 0x00, '4', 0x00, '4', 0x00, 'D', 0x00, '9', 0x00, '-', 0x00, + '0', 0x00, 'D', 0x00, '0', 0x00, '8', 0x00, '-', 0x00, '4', 0x00, '3', 0x00, 'F', 0x00, 'D', 0x00, '-', 0x00, + '8', 0x00, 'B', 0x00, '3', 0x00, 'E', 0x00, '-', 0x00, '1', 0x00, '2', 0x00, '7', 0x00, 'C', 0x00, 'A', 0x00, + '8', 0x00, 'A', 0x00, 'F', 0x00, 'F', 0x00, 'F', 0x00, '9', 0x00, 'D', 0x00, '}', 0x00, 0x00, 0x00, 0x00, 0x00 +}; + +TU_VERIFY_STATIC(sizeof(ms_os_20_descriptor_template) == MS_OS_20_DESC_LEN, "Incorrect size"); + +static const uint8_t usb_vendor_descriptor_template[] = { + // Vendor Descriptor + 0x09, // 0 bLength + 0x04, // 1 bDescriptorType (Interface) + 0xFF, // 2 bInterfaceNumber [SET AT RUNTIME] +#define VENDOR_INTERFACE_INDEX 2 + 0x00, // 3 bAlternateSetting + 0x02, // 4 bNumEndpoints 2 + 0xFF, // 5 bInterfaceClass: Vendor Specific + 0x00, // 6 bInterfaceSubClass: NONE + 0x00, // 7 bInterfaceProtocol: NONE + 0xFF, // 8 iInterface (String Index) +#define VENDOR_INTERFACE_STRING_INDEX 8 + + // Vendor OUT Endpoint Descriptor + 0x07, // 9 bLength + 0x05, // 10 bDescriptorType (Endpoint) + 0xFF, // 11 bEndpointAddress (IN/D2H) [SET AT RUNTIME: number] +#define VENDOR_OUT_ENDPOINT_INDEX 11 + 0x02, // 12 bmAttributes (Bulk) + #if USB_HIGHSPEED + 0x00, 0x02, // 13,14 wMaxPacketSize 512 + #else + 0x40, 0x00, // 13,14 wMaxPacketSize 64 + #endif + 0x0, // 15 bInterval 0 + + // Vendor IN Endpoint Descriptor + 0x07, // 16 bLength + 0x05, // 17 bDescriptorType (Endpoint) + 0xFF, // 18 bEndpointAddress (IN/D2H) [SET AT RUNTIME: 0x80 | number] +#define VENDOR_IN_ENDPOINT_INDEX 18 + 0x02, // 19 bmAttributes (Bulk) + 0x40, 0x00, // 20, 21 wMaxPacketSize 64 + 0x0 // 22 bInterval 0 +}; + +static const char vendor_interface_name[] = USB_INTERFACE_NAME " WebUSB"; + + +bool usb_vendor_enabled(void) { + return usb_cdc_console_enabled(); +} + +size_t usb_vendor_descriptor_length(void) { + return sizeof(usb_vendor_descriptor_template); +} + +static supervisor_allocation *ms_os_20_descriptor_allocation; + +size_t vendor_ms_os_20_descriptor_length() { + return sizeof(ms_os_20_descriptor_template); +} +uint8_t const *vendor_ms_os_20_descriptor() { + return (uint8_t *)ms_os_20_descriptor_allocation->ptr; +} + + +size_t usb_vendor_add_descriptor(uint8_t *descriptor_buf, descriptor_counts_t *descriptor_counts, uint8_t *current_interface_string) { + + if (ms_os_20_descriptor_template[MS_OS_20_ITF_NUM_OFFSET] == MS_OS_20_ITF_NUM_MAGIC) { + ms_os_20_descriptor_allocation = + allocate_memory(align32_size(sizeof(ms_os_20_descriptor_template)), + /*high_address*/ false, /*movable*/ false); + uint8_t *ms_os_20_descriptor_buf = (uint8_t *)ms_os_20_descriptor_allocation->ptr; + memcpy(ms_os_20_descriptor_buf, ms_os_20_descriptor_template, sizeof(ms_os_20_descriptor_template)); + ms_os_20_descriptor_buf[MS_OS_20_ITF_NUM_OFFSET] = descriptor_counts->current_interface; + ms_os_20_descriptor_buf[VENDOR_IN_ENDPOINT_INDEX] = 0x80 | descriptor_counts->current_endpoint; + ms_os_20_descriptor_buf[VENDOR_OUT_ENDPOINT_INDEX] = descriptor_counts->current_endpoint; + } + + memcpy(descriptor_buf, usb_vendor_descriptor_template, sizeof(usb_vendor_descriptor_template)); + + descriptor_buf[VENDOR_INTERFACE_INDEX] = descriptor_counts->current_interface; + descriptor_counts->current_interface++; + + descriptor_buf[VENDOR_IN_ENDPOINT_INDEX] = 0x80 | descriptor_counts->current_endpoint; + descriptor_counts->num_in_endpoints++; + descriptor_buf[VENDOR_OUT_ENDPOINT_INDEX] = descriptor_counts->current_endpoint; + descriptor_counts->num_out_endpoints++; + descriptor_counts->current_endpoint++; + + usb_add_interface_string(*current_interface_string, vendor_interface_name); + descriptor_buf[VENDOR_INTERFACE_STRING_INDEX] = *current_interface_string; + (*current_interface_string)++; + + return sizeof(usb_vendor_descriptor_template); +} + + + + +#endif diff --git a/shared-module/usb_cdc/__init__.h b/shared-module/usb_cdc/__init__.h index 5195c964e2..87dabf05db 100644 --- a/shared-module/usb_cdc/__init__.h +++ b/shared-module/usb_cdc/__init__.h @@ -39,4 +39,13 @@ void usb_cdc_set_defaults(void); size_t usb_cdc_descriptor_length(void); size_t usb_cdc_add_descriptor(uint8_t *descriptor_buf, descriptor_counts_t *descriptor_counts, uint8_t *current_interface_string, bool console); +#if CIRCUITPY_USB_VENDOR +bool usb_vendor_enabled(void); +size_t usb_vendor_descriptor_length(void); +size_t usb_vendor_add_descriptor(uint8_t *descriptor_buf, descriptor_counts_t *descriptor_counts, uint8_t *current_interface_string); + +size_t vendor_ms_os_20_descriptor_length(void); +uint8_t const *vendor_ms_os_20_descriptor(void); +#endif + #endif /* SHARED_MODULE_USB_CDC___INIT___H */ diff --git a/supervisor/shared/memory.c b/supervisor/shared/memory.c index cf7dbf7ed7..ff0382fc17 100644 --- a/supervisor/shared/memory.c +++ b/supervisor/shared/memory.c @@ -52,6 +52,10 @@ enum { + 1 // hid_report_descriptor_allocation + 1 // hid_devices_allocation #endif + + #if CIRCUITPY_USB_VENDOR + + 1 // usb_vendor_add_descriptor + #endif , CIRCUITPY_SUPERVISOR_MOVABLE_ALLOC_COUNT = diff --git a/supervisor/shared/usb/usb.c b/supervisor/shared/usb/usb.c index 8333f662b5..9a8b6cd1b6 100644 --- a/supervisor/shared/usb/usb.c +++ b/supervisor/shared/usb/usb.c @@ -54,13 +54,23 @@ #include "tusb.h" #if CIRCUITPY_USB_VENDOR +#include "usb_vendor_descriptors.h" // The WebUSB support being conditionally added to this file is based on the // tinyusb demo examples/device/webusb_serial. -extern const tusb_desc_webusb_url_t desc_webusb_url; - static bool web_serial_connected = false; + +#define URL "www.tinyusb.org/examples/webusb-serial" + +const tusb_desc_webusb_url_t desc_webusb_url = +{ + .bLength = 3 + sizeof(URL) - 1, + .bDescriptorType = 3, // WEBUSB URL type + .bScheme = 1, // 0: http, 1: https + .url = URL +}; + #endif bool usb_enabled(void) { @@ -253,10 +263,11 @@ bool tud_vendor_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_requ case VENDOR_REQUEST_MICROSOFT: if (request->wIndex == 7) { // Get Microsoft OS 2.0 compatible descriptor + // let's just hope the target architecture always has the same endianness uint16_t total_len; - memcpy(&total_len, desc_ms_os_20 + 8, 2); + memcpy(&total_len, vendor_ms_os_20_descriptor() + 8, 2); - return tud_control_xfer(rhport, request, (void *)desc_ms_os_20, total_len); + return tud_control_xfer(rhport, request, (void *)vendor_ms_os_20_descriptor(), total_len); } else { return false; } diff --git a/supervisor/shared/usb/usb_desc.c b/supervisor/shared/usb/usb_desc.c index bad0d84523..6a0b7ab851 100644 --- a/supervisor/shared/usb/usb_desc.c +++ b/supervisor/shared/usb/usb_desc.c @@ -170,6 +170,13 @@ static void usb_build_configuration_descriptor(void) { } #endif + #if CIRCUITPY_USB_VENDOR + if (usb_vendor_enabled()) { + total_descriptor_length += usb_vendor_descriptor_length(); + } + #endif + + // Now we now how big the configuration descriptor will be, so we can allocate space for it. configuration_descriptor_allocation = allocate_memory(align32_size(total_descriptor_length), @@ -235,6 +242,13 @@ static void usb_build_configuration_descriptor(void) { } #endif + #if CIRCUITPY_USB_VENDOR + if (usb_vendor_enabled()) { + descriptor_buf_remaining += usb_vendor_add_descriptor( + descriptor_buf_remaining, &descriptor_counts, ¤t_interface_string); + } + #endif + // Now we know how many interfaces have been used. configuration_descriptor[CONFIG_NUM_INTERFACES_INDEX] = descriptor_counts.current_interface; diff --git a/supervisor/shared/usb/usb_vendor_descriptors.h b/supervisor/shared/usb/usb_vendor_descriptors.h new file mode 100644 index 0000000000..0b41c09d34 --- /dev/null +++ b/supervisor/shared/usb/usb_vendor_descriptors.h @@ -0,0 +1,39 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2019 Ha Thach (tinyusb.org) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef USB_DESCRIPTORS_H_ +#define USB_DESCRIPTORS_H_ + +#include + +enum +{ + VENDOR_REQUEST_WEBUSB = 1, + VENDOR_REQUEST_MICROSOFT = 2 +}; + +size_t vendor_ms_os_20_descriptor_length(void); +uint8_t const *vendor_ms_os_20_descriptor(void); + +#endif /* USB_DESCRIPTORS_H_ */ diff --git a/tests/unix/extra_coverage.py.exp b/tests/unix/extra_coverage.py.exp index 2cf48de142..893a6b72c3 100644 --- a/tests/unix/extra_coverage.py.exp +++ b/tests/unix/extra_coverage.py.exp @@ -30,9 +30,10 @@ ame__ mport builtins micropython _thread array -btree cexample cmath collections -cppexample ffi framebuf gc -hashlib math qrio sys +binascii btree cexample cmath +collections cppexample errno ffi +framebuf gc hashlib json +math qrio re sys termios ubinascii uctypes uerrno uheapq uio ujson ulab uos urandom ure uselect diff --git a/tools/build_board_info.py b/tools/build_board_info.py index de25015dd0..9c57dc64ab 100644 --- a/tools/build_board_info.py +++ b/tools/build_board_info.py @@ -65,6 +65,9 @@ extension_by_board = { "microbit_v2": COMBINED_HEX, # stm32 "meowbit_v121": UF2, + # esp32c3 + "ai_thinker_esp32-c3s": BIN, + "microdev_micro_c3": BIN, } language_allow_list = set(