summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
m---------lib/protomatter0
-rw-r--r--locale/ID.po28
-rw-r--r--locale/circuitpython.pot47
-rw-r--r--locale/cs.po28
-rw-r--r--locale/de_DE.po28
-rw-r--r--locale/es.po33
-rw-r--r--locale/fil.po28
-rw-r--r--locale/fr.po28
-rw-r--r--locale/it_IT.po28
-rw-r--r--locale/ko.po28
-rw-r--r--locale/nl.po28
-rw-r--r--locale/pl.po28
-rw-r--r--locale/pt_BR.po32
-rw-r--r--locale/sv.po28
-rw-r--r--locale/zh_Latn_pinyin.po28
-rwxr-xr-xmain.c9
-rw-r--r--mpy-cross/mpconfigport.h1
-rw-r--r--ports/atmel-samd/mphalport.h4
-rw-r--r--ports/esp32s2/Makefile2
-rw-r--r--ports/esp32s2/common-hal/pulseio/PWMOut.c198
-rw-r--r--ports/esp32s2/common-hal/pulseio/PWMOut.h45
-rw-r--r--ports/esp32s2/common-hal/pulseio/PulseIn.c75
-rw-r--r--ports/esp32s2/common-hal/pulseio/PulseIn.h53
-rw-r--r--ports/esp32s2/common-hal/pulseio/PulseOut.c60
-rw-r--r--ports/esp32s2/common-hal/pulseio/PulseOut.h42
-rw-r--r--ports/esp32s2/common-hal/pulseio/__init__.c1
-rw-r--r--ports/esp32s2/mpconfigport.mk2
-rw-r--r--ports/esp32s2/supervisor/port.c4
-rw-r--r--ports/litex/common-hal/microcontroller/Pin.c7
-rwxr-xr-xports/stm/Makefile1
-rw-r--r--ports/stm/common-hal/analogio/AnalogIn.c4
-rw-r--r--ports/stm/common-hal/analogio/AnalogOut.c2
-rw-r--r--ports/stm/common-hal/busio/I2C.c6
-rw-r--r--ports/stm/common-hal/busio/SPI.c8
-rw-r--r--ports/stm/common-hal/busio/UART.c5
-rw-r--r--ports/stm/common-hal/digitalio/DigitalInOut.c3
-rw-r--r--ports/stm/common-hal/microcontroller/Pin.c19
-rw-r--r--ports/stm/common-hal/microcontroller/Pin.h2
-rw-r--r--ports/stm/common-hal/pulseio/PWMOut.c180
-rw-r--r--ports/stm/common-hal/pulseio/PulseIn.c84
-rw-r--r--ports/stm/common-hal/pulseio/PulseOut.c138
-rw-r--r--ports/stm/common-hal/rgbmatrix/RGBMatrix.c14
-rw-r--r--ports/stm/peripherals/stm32f4/stm32f405xx/periph.c182
-rw-r--r--ports/stm/peripherals/stm32f4/stm32f405xx/periph.h35
-rw-r--r--ports/stm/peripherals/stm32f4/stm32f405xx/pins.c205
-rw-r--r--ports/stm/peripherals/stm32f4/stm32f405xx/pins.h201
-rw-r--r--ports/stm/peripherals/timers.c460
-rw-r--r--ports/stm/peripherals/timers.h46
-rw-r--r--ports/stm/supervisor/port.c2
-rw-r--r--ports/stm/supervisor/usb.c5
-rw-r--r--ports/stm/tools/parse_af_csv.py2
-rw-r--r--ports/stm/tools/pins.csv93
-rw-r--r--ports/stm/tools/stm32f767_af.csv168
-rw-r--r--py/circuitpy_defns.mk6
-rw-r--r--py/circuitpy_mpconfig.h12
-rw-r--r--py/circuitpy_mpconfig.mk3
-rw-r--r--py/compile.c2
-rw-r--r--py/emitglue.c2
-rwxr-xr-xpy/gc.c16
-rw-r--r--py/obj.h2
-rw-r--r--py/objgenerator.c19
-rw-r--r--py/objstr.h4
-rw-r--r--py/py.mk5
-rw-r--r--py/runtime0.h1
-rw-r--r--shared-bindings/_bleio/Adapter.c26
-rw-r--r--shared-bindings/_bleio/Address.c20
-rw-r--r--shared-bindings/_bleio/Attribute.c16
-rw-r--r--shared-bindings/_bleio/Characteristic.c28
-rw-r--r--shared-bindings/_bleio/CharacteristicBuffer.c14
-rw-r--r--shared-bindings/_bleio/Connection.c16
-rw-r--r--shared-bindings/_bleio/Descriptor.c8
-rw-r--r--shared-bindings/_bleio/PacketBuffer.c10
-rw-r--r--shared-bindings/_bleio/ScanEntry.c14
-rw-r--r--shared-bindings/_bleio/ScanResults.c6
-rw-r--r--shared-bindings/_bleio/Service.c10
-rw-r--r--shared-bindings/_bleio/UUID.c12
-rw-r--r--shared-bindings/_bleio/__init__.c31
-rw-r--r--shared-bindings/_eve/__init__.c112
-rw-r--r--shared-bindings/_pew/PewPew.c2
-rw-r--r--shared-bindings/_pixelbuf/PixelBuf.c22
-rw-r--r--shared-bindings/_pixelbuf/PixelBuf.h2
-rw-r--r--shared-bindings/_pixelbuf/__init__.c2
-rw-r--r--shared-bindings/_stage/Layer.c6
-rw-r--r--shared-bindings/_stage/Text.c4
-rw-r--r--shared-bindings/aesio/aes.c6
-rw-r--r--shared-bindings/analogio/AnalogIn.c12
-rw-r--r--shared-bindings/analogio/AnalogOut.c10
-rw-r--r--shared-bindings/audiobusio/I2SOut.c20
-rw-r--r--shared-bindings/audiobusio/PDMIn.c12
-rw-r--r--shared-bindings/audiocore/RawSample.c10
-rw-r--r--shared-bindings/audiocore/WaveFile.c14
-rw-r--r--shared-bindings/audioio/AudioOut.c20
-rw-r--r--shared-bindings/audiomixer/Mixer.c18
-rw-r--r--shared-bindings/audiomixer/MixerVoice.c10
-rw-r--r--shared-bindings/audiomp3/MP3Decoder.c18
-rw-r--r--shared-bindings/audiopwmio/PWMAudioOut.c20
-rw-r--r--shared-bindings/bitbangio/I2C.c29
-rw-r--r--shared-bindings/bitbangio/OneWire.c14
-rw-r--r--shared-bindings/bitbangio/SPI.c20
-rw-r--r--shared-bindings/board/__init__.c6
-rw-r--r--shared-bindings/busio/I2C.c35
-rw-r--r--shared-bindings/busio/OneWire.c14
-rw-r--r--shared-bindings/busio/SPI.c22
-rw-r--r--shared-bindings/busio/UART.c32
-rw-r--r--shared-bindings/countio/Counter.c2
-rw-r--r--shared-bindings/digitalio/DigitalInOut.c6
-rw-r--r--shared-bindings/digitalio/Direction.c6
-rw-r--r--shared-bindings/digitalio/Direction.h2
-rw-r--r--shared-bindings/digitalio/DriveMode.c6
-rw-r--r--shared-bindings/digitalio/DriveMode.h2
-rw-r--r--shared-bindings/digitalio/Pull.c6
-rw-r--r--shared-bindings/digitalio/Pull.h2
-rw-r--r--shared-bindings/displayio/Bitmap.c12
-rw-r--r--shared-bindings/displayio/ColorConverter.c6
-rw-r--r--shared-bindings/displayio/Display.c22
-rw-r--r--shared-bindings/displayio/EPaperDisplay.c14
-rw-r--r--shared-bindings/displayio/FourWire.c6
-rw-r--r--shared-bindings/displayio/Group.c30
-rw-r--r--shared-bindings/displayio/I2CDisplay.c6
-rw-r--r--shared-bindings/displayio/OnDiskBitmap.c6
-rw-r--r--shared-bindings/displayio/Palette.c12
-rw-r--r--shared-bindings/displayio/ParallelBus.c6
-rw-r--r--shared-bindings/displayio/Shape.c4
-rw-r--r--shared-bindings/displayio/TileGrid.c20
-rw-r--r--shared-bindings/displayio/__init__.c2
-rw-r--r--shared-bindings/fontio/BuiltinFont.c8
-rw-r--r--shared-bindings/framebufferio/FramebufferDisplay.c22
-rw-r--r--shared-bindings/frequencyio/FrequencyIn.c18
-rw-r--r--shared-bindings/gamepad/GamePad.c6
-rw-r--r--shared-bindings/gamepadshift/GamePadShift.c6
-rw-r--r--shared-bindings/gnss/GNSS.c16
-rw-r--r--shared-bindings/gnss/PositionFix.c12
-rw-r--r--shared-bindings/gnss/SatelliteSystem.c12
-rw-r--r--shared-bindings/i2cperipheral/I2CPeripheral.c18
-rw-r--r--shared-bindings/math/__init__.c78
-rw-r--r--shared-bindings/memorymonitor/AllocationAlarm.c137
-rw-r--r--shared-bindings/memorymonitor/AllocationAlarm.h39
-rw-r--r--shared-bindings/memorymonitor/AllocationSize.c183
-rw-r--r--shared-bindings/memorymonitor/AllocationSize.h42
-rw-r--r--shared-bindings/memorymonitor/__init__.c77
-rw-r--r--shared-bindings/memorymonitor/__init__.h49
-rw-r--r--shared-bindings/microcontroller/Pin.c2
-rw-r--r--shared-bindings/microcontroller/Processor.c8
-rw-r--r--shared-bindings/microcontroller/Processor.h2
-rw-r--r--shared-bindings/microcontroller/RunMode.c8
-rw-r--r--shared-bindings/microcontroller/RunMode.h2
-rw-r--r--shared-bindings/microcontroller/__init__.c10
-rw-r--r--shared-bindings/multiterminal/__init__.c8
-rw-r--r--shared-bindings/network/__init__.c2
-rw-r--r--shared-bindings/nvm/ByteArray.c6
-rw-r--r--shared-bindings/nvm/ByteArray.h2
-rw-r--r--shared-bindings/os/__init__.c24
-rw-r--r--shared-bindings/os/__init__.h2
-rw-r--r--shared-bindings/ps2io/Ps2.c18
-rw-r--r--shared-bindings/pulseio/PWMOut.c12
-rw-r--r--shared-bindings/pulseio/PulseIn.c26
-rw-r--r--shared-bindings/pulseio/PulseOut.c10
-rw-r--r--shared-bindings/random/__init__.c14
-rw-r--r--shared-bindings/rgbmatrix/RGBMatrix.c13
-rw-r--r--shared-bindings/rotaryio/IncrementalEncoder.c10
-rw-r--r--shared-bindings/rtc/RTC.c2
-rw-r--r--shared-bindings/rtc/__init__.c2
-rw-r--r--shared-bindings/sdcardio/SDCard.c2
-rw-r--r--shared-bindings/sdioio/SDCard.c8
-rw-r--r--shared-bindings/socket/__init__.c28
-rw-r--r--shared-bindings/storage/__init__.c32
-rw-r--r--shared-bindings/struct/__init__.c8
-rwxr-xr-xshared-bindings/supervisor/Runtime.c2
-rwxr-xr-xshared-bindings/supervisor/Runtime.h2
-rw-r--r--shared-bindings/terminalio/Terminal.c4
-rw-r--r--shared-bindings/time/__init__.c14
-rw-r--r--shared-bindings/touchio/TouchIn.c14
-rw-r--r--shared-bindings/uheap/__init__.c2
-rw-r--r--shared-bindings/ulab/__init__.pyi2
-rw-r--r--shared-bindings/usb_hid/Device.c8
-rw-r--r--shared-bindings/usb_hid/Device.h2
-rw-r--r--shared-bindings/usb_midi/PortIn.c6
-rw-r--r--shared-bindings/usb_midi/PortOut.c4
-rw-r--r--shared-bindings/ustack/__init__.c2
-rw-r--r--shared-bindings/vectorio/Circle.c2
-rw-r--r--shared-bindings/vectorio/Polygon.c2
-rw-r--r--shared-bindings/vectorio/Rectangle.c2
-rw-r--r--shared-bindings/vectorio/VectorShape.c2
-rw-r--r--shared-bindings/watchdog/WatchDogMode.c6
-rw-r--r--shared-bindings/watchdog/WatchDogTimer.c2
-rw-r--r--shared-bindings/wiznet/wiznet5k.c8
-rw-r--r--shared-module/memorymonitor/AllocationAlarm.c94
-rw-r--r--shared-module/memorymonitor/AllocationAlarm.h51
-rw-r--r--shared-module/memorymonitor/AllocationSize.c91
-rw-r--r--shared-module/memorymonitor/AllocationSize.h51
-rw-r--r--shared-module/memorymonitor/__init__.c39
-rw-r--r--shared-module/memorymonitor/__init__.h35
-rw-r--r--shared-module/touchio/TouchIn.c3
-rw-r--r--supervisor/serial.h2
-rw-r--r--tests/basics/async_coroutine.py13
-rw-r--r--tests/basics/async_coroutine.py.exp1
-rwxr-xr-xtests/run-tests2
-rw-r--r--tools/extract_pyi.py4
-rw-r--r--tools/gen_usb_descriptor.py10
199 files changed, 3537 insertions, 1670 deletions
diff --git a/lib/protomatter b/lib/protomatter
-Subproject 9f71088d2c32206c6f0495704ae0c040426d576
+Subproject 761d6437e8cd6a131d51de96974337121a9c716
diff --git a/locale/ID.po b/locale/ID.po
index c85b8edfe..bd865c054 100644
--- a/locale/ID.po
+++ b/locale/ID.po
@@ -84,10 +84,15 @@ msgstr "indeks %q harus bilangan bulat, bukan %s"
msgid "%q list must be a list"
msgstr "daftar %q harus berupa daftar"
+#: shared-bindings/memorymonitor/AllocationAlarm.c
+msgid "%q must be >= 0"
+msgstr ""
+
#: shared-bindings/_bleio/CharacteristicBuffer.c
#: shared-bindings/_bleio/PacketBuffer.c shared-bindings/displayio/Group.c
-#: shared-bindings/displayio/Shape.c shared-bindings/vectorio/Circle.c
-#: shared-bindings/vectorio/Rectangle.c
+#: shared-bindings/displayio/Shape.c
+#: shared-bindings/memorymonitor/AllocationAlarm.c
+#: shared-bindings/vectorio/Circle.c shared-bindings/vectorio/Rectangle.c
msgid "%q must be >= 1"
msgstr "%q harus >= 1"
@@ -325,6 +330,11 @@ msgstr "Semua timer sedang digunakan"
msgid "Already advertising."
msgstr "Sudah disebarkan."
+#: shared-module/memorymonitor/AllocationAlarm.c
+#: shared-module/memorymonitor/AllocationSize.c
+msgid "Already running"
+msgstr ""
+
#: ports/cxd56/common-hal/analogio/AnalogIn.c
msgid "AnalogIn not supported on given pin"
msgstr "AnalogIn tidak didukung pada pin yang diberikan"
@@ -360,6 +370,11 @@ msgstr "Nilai array harus berupa byte tunggal."
msgid "At most %d %q may be specified (not %d)"
msgstr "Paling banyak %d %q dapat ditentukan (bukan %d)"
+#: shared-module/memorymonitor/AllocationAlarm.c
+#, c-format
+msgid "Attempt to allocate %d blocks"
+msgstr ""
+
#: supervisor/shared/safe_mode.c
msgid "Attempted heap allocation when MicroPython VM not running."
msgstr "Mencoba alokasi heap ketika MicroPython VM tidak berjalan."
@@ -481,7 +496,9 @@ msgstr "Panggil super().__init__() sebelum mengakses objek asli."
msgid "Can't set CCCD on local Characteristic"
msgstr "Tidak dapat mengatur CCCD pada Karakteristik lokal"
-#: shared-bindings/displayio/Bitmap.c shared-bindings/pulseio/PulseIn.c
+#: shared-bindings/displayio/Bitmap.c
+#: shared-bindings/memorymonitor/AllocationSize.c
+#: shared-bindings/pulseio/PulseIn.c
msgid "Cannot delete values"
msgstr "Tidak dapat menghapus nilai"
@@ -1379,6 +1396,7 @@ msgstr ""
msgid "Random number generation error"
msgstr ""
+#: shared-bindings/memorymonitor/AllocationSize.c
#: shared-bindings/pulseio/PulseIn.c
msgid "Read-only"
msgstr ""
@@ -1465,7 +1483,9 @@ msgid "Slice and value different lengths."
msgstr ""
#: shared-bindings/displayio/Bitmap.c shared-bindings/displayio/Group.c
-#: shared-bindings/displayio/TileGrid.c shared-bindings/pulseio/PulseIn.c
+#: shared-bindings/displayio/TileGrid.c
+#: shared-bindings/memorymonitor/AllocationSize.c
+#: shared-bindings/pulseio/PulseIn.c
msgid "Slices not supported"
msgstr ""
diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot
index 988f89a05..4d3a87706 100644
--- a/locale/circuitpython.pot
+++ b/locale/circuitpython.pot
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2020-07-17 18:03-0700\n"
+"POT-Creation-Date: 2020-07-21 18:43-0700\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -78,10 +78,15 @@ msgstr ""
msgid "%q list must be a list"
msgstr ""
+#: shared-bindings/memorymonitor/AllocationAlarm.c
+msgid "%q must be >= 0"
+msgstr ""
+
#: shared-bindings/_bleio/CharacteristicBuffer.c
#: shared-bindings/_bleio/PacketBuffer.c shared-bindings/displayio/Group.c
-#: shared-bindings/displayio/Shape.c shared-bindings/vectorio/Circle.c
-#: shared-bindings/vectorio/Rectangle.c
+#: shared-bindings/displayio/Shape.c
+#: shared-bindings/memorymonitor/AllocationAlarm.c
+#: shared-bindings/vectorio/Circle.c shared-bindings/vectorio/Rectangle.c
msgid "%q must be >= 1"
msgstr ""
@@ -229,6 +234,10 @@ msgstr ""
msgid "'continue' outside loop"
msgstr ""
+#: py/objgenerator.c
+msgid "'coroutine' object is not an iterator"
+msgstr ""
+
#: py/compile.c
msgid "'data' requires at least 2 arguments"
msgstr ""
@@ -311,7 +320,7 @@ msgstr ""
#: ports/cxd56/common-hal/pulseio/PulseOut.c
#: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c
#: ports/nrf/common-hal/pulseio/PulseIn.c ports/nrf/peripherals/nrf/timers.c
-#: shared-bindings/pulseio/PWMOut.c
+#: ports/stm/peripherals/timers.c shared-bindings/pulseio/PWMOut.c
msgid "All timers in use"
msgstr ""
@@ -319,6 +328,11 @@ msgstr ""
msgid "Already advertising."
msgstr ""
+#: shared-module/memorymonitor/AllocationAlarm.c
+#: shared-module/memorymonitor/AllocationSize.c
+msgid "Already running"
+msgstr ""
+
#: ports/cxd56/common-hal/analogio/AnalogIn.c
msgid "AnalogIn not supported on given pin"
msgstr ""
@@ -354,6 +368,11 @@ msgstr ""
msgid "At most %d %q may be specified (not %d)"
msgstr ""
+#: shared-module/memorymonitor/AllocationAlarm.c
+#, c-format
+msgid "Attempt to allocate %d blocks"
+msgstr ""
+
#: supervisor/shared/safe_mode.c
msgid "Attempted heap allocation when MicroPython VM not running."
msgstr ""
@@ -473,7 +492,9 @@ msgstr ""
msgid "Can't set CCCD on local Characteristic"
msgstr ""
-#: shared-bindings/displayio/Bitmap.c shared-bindings/pulseio/PulseIn.c
+#: shared-bindings/displayio/Bitmap.c
+#: shared-bindings/memorymonitor/AllocationSize.c
+#: shared-bindings/pulseio/PulseIn.c
msgid "Cannot delete values"
msgstr ""
@@ -1315,11 +1336,7 @@ msgstr ""
msgid "Pull not used when direction is output."
msgstr ""
-#: ports/stm/common-hal/pulseio/PulseIn.c
-msgid "PulseIn not supported on this chip"
-msgstr ""
-
-#: ports/stm/common-hal/pulseio/PulseOut.c
+#: ports/stm/ref/pulseout-pre-timeralloc.c
msgid "PulseOut not supported on this chip"
msgstr ""
@@ -1353,6 +1370,7 @@ msgstr ""
msgid "Random number generation error"
msgstr ""
+#: shared-bindings/memorymonitor/AllocationSize.c
#: shared-bindings/pulseio/PulseIn.c
msgid "Read-only"
msgstr ""
@@ -1437,7 +1455,9 @@ msgid "Slice and value different lengths."
msgstr ""
#: shared-bindings/displayio/Bitmap.c shared-bindings/displayio/Group.c
-#: shared-bindings/displayio/TileGrid.c shared-bindings/pulseio/PulseIn.c
+#: shared-bindings/displayio/TileGrid.c
+#: shared-bindings/memorymonitor/AllocationSize.c
+#: shared-bindings/pulseio/PulseIn.c
msgid "Slices not supported"
msgstr ""
@@ -1525,6 +1545,11 @@ msgstr ""
msgid "Timeout is too long: Maximum timeout length is %d seconds"
msgstr ""
+#: ports/stm/common-hal/pulseio/PWMOut.c
+msgid ""
+"Timer was reserved for internal use - declare PWM pins earlier in the program"
+msgstr ""
+
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
msgid "Too many channels in sample."
msgstr ""
diff --git a/locale/cs.po b/locale/cs.po
index 2cecbcc10..cf9141627 100644
--- a/locale/cs.po
+++ b/locale/cs.po
@@ -84,10 +84,15 @@ msgstr "Indexy% q musí být celá čísla, nikoli% s"
msgid "%q list must be a list"
msgstr "Seznam% q musí být seznam"
+#: shared-bindings/memorymonitor/AllocationAlarm.c
+msgid "%q must be >= 0"
+msgstr ""
+
#: shared-bindings/_bleio/CharacteristicBuffer.c
#: shared-bindings/_bleio/PacketBuffer.c shared-bindings/displayio/Group.c
-#: shared-bindings/displayio/Shape.c shared-bindings/vectorio/Circle.c
-#: shared-bindings/vectorio/Rectangle.c
+#: shared-bindings/displayio/Shape.c
+#: shared-bindings/memorymonitor/AllocationAlarm.c
+#: shared-bindings/vectorio/Circle.c shared-bindings/vectorio/Rectangle.c
msgid "%q must be >= 1"
msgstr "% q musí být > = 1"
@@ -325,6 +330,11 @@ msgstr ""
msgid "Already advertising."
msgstr ""
+#: shared-module/memorymonitor/AllocationAlarm.c
+#: shared-module/memorymonitor/AllocationSize.c
+msgid "Already running"
+msgstr ""
+
#: ports/cxd56/common-hal/analogio/AnalogIn.c
msgid "AnalogIn not supported on given pin"
msgstr ""
@@ -360,6 +370,11 @@ msgstr ""
msgid "At most %d %q may be specified (not %d)"
msgstr ""
+#: shared-module/memorymonitor/AllocationAlarm.c
+#, c-format
+msgid "Attempt to allocate %d blocks"
+msgstr ""
+
#: supervisor/shared/safe_mode.c
msgid "Attempted heap allocation when MicroPython VM not running."
msgstr ""
@@ -479,7 +494,9 @@ msgstr ""
msgid "Can't set CCCD on local Characteristic"
msgstr ""
-#: shared-bindings/displayio/Bitmap.c shared-bindings/pulseio/PulseIn.c
+#: shared-bindings/displayio/Bitmap.c
+#: shared-bindings/memorymonitor/AllocationSize.c
+#: shared-bindings/pulseio/PulseIn.c
msgid "Cannot delete values"
msgstr ""
@@ -1359,6 +1376,7 @@ msgstr ""
msgid "Random number generation error"
msgstr ""
+#: shared-bindings/memorymonitor/AllocationSize.c
#: shared-bindings/pulseio/PulseIn.c
msgid "Read-only"
msgstr ""
@@ -1443,7 +1461,9 @@ msgid "Slice and value different lengths."
msgstr ""
#: shared-bindings/displayio/Bitmap.c shared-bindings/displayio/Group.c
-#: shared-bindings/displayio/TileGrid.c shared-bindings/pulseio/PulseIn.c
+#: shared-bindings/displayio/TileGrid.c
+#: shared-bindings/memorymonitor/AllocationSize.c
+#: shared-bindings/pulseio/PulseIn.c
msgid "Slices not supported"
msgstr ""
diff --git a/locale/de_DE.po b/locale/de_DE.po
index 014cd749f..9b07989ca 100644
--- a/locale/de_DE.po
+++ b/locale/de_DE.po
@@ -83,10 +83,15 @@ msgstr "%q Indizes müssen Integer sein, nicht %s"
msgid "%q list must be a list"
msgstr "%q Liste muss eine Liste sein"
+#: shared-bindings/memorymonitor/AllocationAlarm.c
+msgid "%q must be >= 0"
+msgstr ""
+
#: shared-bindings/_bleio/CharacteristicBuffer.c
#: shared-bindings/_bleio/PacketBuffer.c shared-bindings/displayio/Group.c
-#: shared-bindings/displayio/Shape.c shared-bindings/vectorio/Circle.c
-#: shared-bindings/vectorio/Rectangle.c
+#: shared-bindings/displayio/Shape.c
+#: shared-bindings/memorymonitor/AllocationAlarm.c
+#: shared-bindings/vectorio/Circle.c shared-bindings/vectorio/Rectangle.c
msgid "%q must be >= 1"
msgstr "%q muss >= 1 sein"
@@ -324,6 +329,11 @@ msgstr "Alle timer werden benutzt"
msgid "Already advertising."
msgstr "Bereits am anbieten (advertising)."
+#: shared-module/memorymonitor/AllocationAlarm.c
+#: shared-module/memorymonitor/AllocationSize.c
+msgid "Already running"
+msgstr ""
+
#: ports/cxd56/common-hal/analogio/AnalogIn.c
msgid "AnalogIn not supported on given pin"
msgstr "AnalogIn ist an diesem Pin nicht unterstützt"
@@ -359,6 +369,11 @@ msgstr "Array-Werte sollten aus Einzelbytes bestehen."
msgid "At most %d %q may be specified (not %d)"
msgstr "Es darf höchstens %d %q spezifiziert werden (nicht %d)"
+#: shared-module/memorymonitor/AllocationAlarm.c
+#, c-format
+msgid "Attempt to allocate %d blocks"
+msgstr ""
+
#: supervisor/shared/safe_mode.c
msgid "Attempted heap allocation when MicroPython VM not running."
msgstr ""
@@ -482,7 +497,9 @@ msgstr "Rufe super().__init__() vor dem Zugriff auf ein natives Objekt auf."
msgid "Can't set CCCD on local Characteristic"
msgstr "CCCD kann nicht auf lokales Merkmal eingestellt werden"
-#: shared-bindings/displayio/Bitmap.c shared-bindings/pulseio/PulseIn.c
+#: shared-bindings/displayio/Bitmap.c
+#: shared-bindings/memorymonitor/AllocationSize.c
+#: shared-bindings/pulseio/PulseIn.c
msgid "Cannot delete values"
msgstr "Kann Werte nicht löschen"
@@ -1389,6 +1406,7 @@ msgstr "RTS / CTS / RS485 Wird von diesem Gerät noch nicht unterstützt"
msgid "Random number generation error"
msgstr "Fehler bei der Erzeugung von Zufallszahlen"
+#: shared-bindings/memorymonitor/AllocationSize.c
#: shared-bindings/pulseio/PulseIn.c
msgid "Read-only"
msgstr "Nur lesen möglich, da Schreibgeschützt"
@@ -1473,7 +1491,9 @@ msgid "Slice and value different lengths."
msgstr "Slice und Wert (value) haben unterschiedliche Längen."
#: shared-bindings/displayio/Bitmap.c shared-bindings/displayio/Group.c
-#: shared-bindings/displayio/TileGrid.c shared-bindings/pulseio/PulseIn.c
+#: shared-bindings/displayio/TileGrid.c
+#: shared-bindings/memorymonitor/AllocationSize.c
+#: shared-bindings/pulseio/PulseIn.c
msgid "Slices not supported"
msgstr "Slices werden nicht unterstützt"
diff --git a/locale/es.po b/locale/es.po
index 2ebad85e9..8d19b0ab0 100644
--- a/locale/es.po
+++ b/locale/es.po
@@ -3,13 +3,12 @@
# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
#
# SPDX-License-Identifier: MIT
-#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-07-17 18:03-0700\n"
-"PO-Revision-Date: 2020-07-13 19:24+0000\n"
+"PO-Revision-Date: 2020-07-22 20:48+0000\n"
"Last-Translator: Alvaro Figueroa <alvaro@greencore.co.cr>\n"
"Language-Team: \n"
"Language: es\n"
@@ -88,10 +87,15 @@ msgstr "%q indices deben ser enteros, no %s"
msgid "%q list must be a list"
msgstr "%q lista debe ser una lista"
+#: shared-bindings/memorymonitor/AllocationAlarm.c
+msgid "%q must be >= 0"
+msgstr ""
+
#: shared-bindings/_bleio/CharacteristicBuffer.c
#: shared-bindings/_bleio/PacketBuffer.c shared-bindings/displayio/Group.c
-#: shared-bindings/displayio/Shape.c shared-bindings/vectorio/Circle.c
-#: shared-bindings/vectorio/Rectangle.c
+#: shared-bindings/displayio/Shape.c
+#: shared-bindings/memorymonitor/AllocationAlarm.c
+#: shared-bindings/vectorio/Circle.c shared-bindings/vectorio/Rectangle.c
msgid "%q must be >= 1"
msgstr "%q debe ser >= 1"
@@ -117,7 +121,7 @@ msgstr "argumento '%q' requerido"
#: py/objarray.c
msgid "'%q' object is not bytes-like"
-msgstr ""
+msgstr "el objeto '%q' no es similar a bytes"
#: py/emitinlinethumb.c py/emitinlinextensa.c
#, c-format
@@ -331,6 +335,11 @@ msgstr "Todos los timers en uso"
msgid "Already advertising."
msgstr "Ya se encuentra publicando."
+#: shared-module/memorymonitor/AllocationAlarm.c
+#: shared-module/memorymonitor/AllocationSize.c
+msgid "Already running"
+msgstr ""
+
#: ports/cxd56/common-hal/analogio/AnalogIn.c
msgid "AnalogIn not supported on given pin"
msgstr "El pin proporcionado no soporta AnalogIn"
@@ -366,6 +375,11 @@ msgstr "Valores del array deben ser bytes individuales."
msgid "At most %d %q may be specified (not %d)"
msgstr "Como máximo %d %q se puede especificar (no %d)"
+#: shared-module/memorymonitor/AllocationAlarm.c
+#, c-format
+msgid "Attempt to allocate %d blocks"
+msgstr ""
+
#: supervisor/shared/safe_mode.c
msgid "Attempted heap allocation when MicroPython VM not running."
msgstr ""
@@ -489,7 +503,9 @@ msgstr "Llame a super().__ init __() antes de acceder al objeto nativo."
msgid "Can't set CCCD on local Characteristic"
msgstr "No se puede configurar CCCD en la característica local"
-#: shared-bindings/displayio/Bitmap.c shared-bindings/pulseio/PulseIn.c
+#: shared-bindings/displayio/Bitmap.c
+#: shared-bindings/memorymonitor/AllocationSize.c
+#: shared-bindings/pulseio/PulseIn.c
msgid "Cannot delete values"
msgstr "No se puede eliminar valores"
@@ -1389,6 +1405,7 @@ msgstr "Sin capacidad de RTS/CTS/RS485 para este dispositivo"
msgid "Random number generation error"
msgstr "Error de generación de números aleatorios"
+#: shared-bindings/memorymonitor/AllocationSize.c
#: shared-bindings/pulseio/PulseIn.c
msgid "Read-only"
msgstr "Solo-lectura"
@@ -1473,7 +1490,9 @@ msgid "Slice and value different lengths."
msgstr "Slice y value tienen tamaños diferentes."
#: shared-bindings/displayio/Bitmap.c shared-bindings/displayio/Group.c
-#: shared-bindings/displayio/TileGrid.c shared-bindings/pulseio/PulseIn.c
+#: shared-bindings/displayio/TileGrid.c
+#: shared-bindings/memorymonitor/AllocationSize.c
+#: shared-bindings/pulseio/PulseIn.c
msgid "Slices not supported"
msgstr "Rebanadas no soportadas"
diff --git a/locale/fil.po b/locale/fil.po
index e35982930..92dc9cc91 100644
--- a/locale/fil.po
+++ b/locale/fil.po
@@ -76,10 +76,15 @@ msgstr "%q indeks ay dapat integers, hindi %s"
msgid "%q list must be a list"
msgstr ""
+#: shared-bindings/memorymonitor/AllocationAlarm.c
+msgid "%q must be >= 0"
+msgstr ""
+
#: shared-bindings/_bleio/CharacteristicBuffer.c
#: shared-bindings/_bleio/PacketBuffer.c shared-bindings/displayio/Group.c
-#: shared-bindings/displayio/Shape.c shared-bindings/vectorio/Circle.c
-#: shared-bindings/vectorio/Rectangle.c
+#: shared-bindings/displayio/Shape.c
+#: shared-bindings/memorymonitor/AllocationAlarm.c
+#: shared-bindings/vectorio/Circle.c shared-bindings/vectorio/Rectangle.c
#, fuzzy
msgid "%q must be >= 1"
msgstr "aarehas na haba dapat ang buffer slices"
@@ -321,6 +326,11 @@ msgstr "Lahat ng timer ginagamit"
msgid "Already advertising."
msgstr ""
+#: shared-module/memorymonitor/AllocationAlarm.c
+#: shared-module/memorymonitor/AllocationSize.c
+msgid "Already running"
+msgstr ""
+
#: ports/cxd56/common-hal/analogio/AnalogIn.c
msgid "AnalogIn not supported on given pin"
msgstr ""
@@ -356,6 +366,11 @@ msgstr "Array values ay dapat single bytes."
msgid "At most %d %q may be specified (not %d)"
msgstr ""
+#: shared-module/memorymonitor/AllocationAlarm.c
+#, c-format
+msgid "Attempt to allocate %d blocks"
+msgstr ""
+
#: supervisor/shared/safe_mode.c
msgid "Attempted heap allocation when MicroPython VM not running."
msgstr ""
@@ -478,7 +493,9 @@ msgstr ""
msgid "Can't set CCCD on local Characteristic"
msgstr ""
-#: shared-bindings/displayio/Bitmap.c shared-bindings/pulseio/PulseIn.c
+#: shared-bindings/displayio/Bitmap.c
+#: shared-bindings/memorymonitor/AllocationSize.c
+#: shared-bindings/pulseio/PulseIn.c
msgid "Cannot delete values"
msgstr "Hindi mabura ang values"
@@ -1373,6 +1390,7 @@ msgstr ""
msgid "Random number generation error"
msgstr ""
+#: shared-bindings/memorymonitor/AllocationSize.c
#: shared-bindings/pulseio/PulseIn.c
msgid "Read-only"
msgstr "Basahin-lamang"
@@ -1458,7 +1476,9 @@ msgid "Slice and value different lengths."
msgstr "Slice at value iba't ibang haba."
#: shared-bindings/displayio/Bitmap.c shared-bindings/displayio/Group.c
-#: shared-bindings/displayio/TileGrid.c shared-bindings/pulseio/PulseIn.c
+#: shared-bindings/displayio/TileGrid.c
+#: shared-bindings/memorymonitor/AllocationSize.c
+#: shared-bindings/pulseio/PulseIn.c
msgid "Slices not supported"
msgstr "Hindi suportado ang Slices"
diff --git a/locale/fr.po b/locale/fr.po
index 6dffd41eb..8953efe37 100644
--- a/locale/fr.po
+++ b/locale/fr.po
@@ -88,10 +88,15 @@ msgstr "les indices %q doivent être des entiers, pas %s"
msgid "%q list must be a list"
msgstr "La liste %q doit être une liste"
+#: shared-bindings/memorymonitor/AllocationAlarm.c
+msgid "%q must be >= 0"
+msgstr ""
+
#: shared-bindings/_bleio/CharacteristicBuffer.c
#: shared-bindings/_bleio/PacketBuffer.c shared-bindings/displayio/Group.c
-#: shared-bindings/displayio/Shape.c shared-bindings/vectorio/Circle.c
-#: shared-bindings/vectorio/Rectangle.c
+#: shared-bindings/displayio/Shape.c
+#: shared-bindings/memorymonitor/AllocationAlarm.c
+#: shared-bindings/vectorio/Circle.c shared-bindings/vectorio/Rectangle.c
msgid "%q must be >= 1"
msgstr "%q doit être >=1"
@@ -329,6 +334,11 @@ msgstr "Tous les timers sont utilisés"
msgid "Already advertising."
msgstr "S'annonce déjà."
+#: shared-module/memorymonitor/AllocationAlarm.c
+#: shared-module/memorymonitor/AllocationSize.c
+msgid "Already running"
+msgstr ""
+
#: ports/cxd56/common-hal/analogio/AnalogIn.c
msgid "AnalogIn not supported on given pin"
msgstr "'AnalogOut' n'est pas supporté sur la broche indiquée"
@@ -365,6 +375,11 @@ msgstr "Les valeurs du tableau doivent être des octets simples 'bytes'."
msgid "At most %d %q may be specified (not %d)"
msgstr "Au plus %d %q peut être spécifié (pas %d)"
+#: shared-module/memorymonitor/AllocationAlarm.c
+#, c-format
+msgid "Attempt to allocate %d blocks"
+msgstr ""
+
#: supervisor/shared/safe_mode.c
msgid "Attempted heap allocation when MicroPython VM not running."
msgstr ""
@@ -488,7 +503,9 @@ msgstr "Appelez super () .__ init __ () avant d'accéder à l'objet natif."
msgid "Can't set CCCD on local Characteristic"
msgstr "Impossible de définir CCCD sur une caractéristique locale"
-#: shared-bindings/displayio/Bitmap.c shared-bindings/pulseio/PulseIn.c
+#: shared-bindings/displayio/Bitmap.c
+#: shared-bindings/memorymonitor/AllocationSize.c
+#: shared-bindings/pulseio/PulseIn.c
msgid "Cannot delete values"
msgstr "Impossible de supprimer les valeurs"
@@ -1394,6 +1411,7 @@ msgstr "RTS / CTS / RS485 Pas encore pris en charge sur cet appareil"
msgid "Random number generation error"
msgstr "Erreur de génération de nombres aléatoires"
+#: shared-bindings/memorymonitor/AllocationSize.c
#: shared-bindings/pulseio/PulseIn.c
msgid "Read-only"
msgstr "Lecture seule"
@@ -1478,7 +1496,9 @@ msgid "Slice and value different lengths."
msgstr "Tranche et valeur de tailles différentes."
#: shared-bindings/displayio/Bitmap.c shared-bindings/displayio/Group.c
-#: shared-bindings/displayio/TileGrid.c shared-bindings/pulseio/PulseIn.c
+#: shared-bindings/displayio/TileGrid.c
+#: shared-bindings/memorymonitor/AllocationSize.c
+#: shared-bindings/pulseio/PulseIn.c
msgid "Slices not supported"
msgstr "Tranches non supportées"
diff --git a/locale/it_IT.po b/locale/it_IT.po
index 92b8fbaaa..9f0aea9e9 100644
--- a/locale/it_IT.po
+++ b/locale/it_IT.po
@@ -76,10 +76,15 @@ msgstr "gli indici %q devono essere interi, non %s"
msgid "%q list must be a list"
msgstr ""
+#: shared-bindings/memorymonitor/AllocationAlarm.c
+msgid "%q must be >= 0"
+msgstr ""
+
#: shared-bindings/_bleio/CharacteristicBuffer.c
#: shared-bindings/_bleio/PacketBuffer.c shared-bindings/displayio/Group.c
-#: shared-bindings/displayio/Shape.c shared-bindings/vectorio/Circle.c
-#: shared-bindings/vectorio/Rectangle.c
+#: shared-bindings/displayio/Shape.c
+#: shared-bindings/memorymonitor/AllocationAlarm.c
+#: shared-bindings/vectorio/Circle.c shared-bindings/vectorio/Rectangle.c
#, fuzzy
msgid "%q must be >= 1"
msgstr "slice del buffer devono essere della stessa lunghezza"
@@ -320,6 +325,11 @@ msgstr "Tutti i timer utilizzati"
msgid "Already advertising."
msgstr ""
+#: shared-module/memorymonitor/AllocationAlarm.c
+#: shared-module/memorymonitor/AllocationSize.c
+msgid "Already running"
+msgstr ""
+
#: ports/cxd56/common-hal/analogio/AnalogIn.c
msgid "AnalogIn not supported on given pin"
msgstr ""
@@ -355,6 +365,11 @@ msgstr "Valori di Array dovrebbero essere bytes singulari"
msgid "At most %d %q may be specified (not %d)"
msgstr ""
+#: shared-module/memorymonitor/AllocationAlarm.c
+#, c-format
+msgid "Attempt to allocate %d blocks"
+msgstr ""
+
#: supervisor/shared/safe_mode.c
msgid "Attempted heap allocation when MicroPython VM not running."
msgstr ""
@@ -478,7 +493,9 @@ msgstr ""
msgid "Can't set CCCD on local Characteristic"
msgstr ""
-#: shared-bindings/displayio/Bitmap.c shared-bindings/pulseio/PulseIn.c
+#: shared-bindings/displayio/Bitmap.c
+#: shared-bindings/memorymonitor/AllocationSize.c
+#: shared-bindings/pulseio/PulseIn.c
msgid "Cannot delete values"
msgstr "Impossibile cancellare valori"
@@ -1382,6 +1399,7 @@ msgstr ""
msgid "Random number generation error"
msgstr ""
+#: shared-bindings/memorymonitor/AllocationSize.c
#: shared-bindings/pulseio/PulseIn.c
msgid "Read-only"
msgstr "Sola lettura"
@@ -1469,7 +1487,9 @@ msgid "Slice and value different lengths."
msgstr ""
#: shared-bindings/displayio/Bitmap.c shared-bindings/displayio/Group.c
-#: shared-bindings/displayio/TileGrid.c shared-bindings/pulseio/PulseIn.c
+#: shared-bindings/displayio/TileGrid.c
+#: shared-bindings/memorymonitor/AllocationSize.c
+#: shared-bindings/pulseio/PulseIn.c
msgid "Slices not supported"
msgstr "Slice non supportate"
diff --git a/locale/ko.po b/locale/ko.po
index 8aa96e901..e0f4dd9cb 100644
--- a/locale/ko.po
+++ b/locale/ko.po
@@ -78,10 +78,15 @@ msgstr "%q 인덱스는 %s 가 아닌 정수 여야합니다"
msgid "%q list must be a list"
msgstr ""
+#: shared-bindings/memorymonitor/AllocationAlarm.c
+msgid "%q must be >= 0"
+msgstr ""
+
#: shared-bindings/_bleio/CharacteristicBuffer.c
#: shared-bindings/_bleio/PacketBuffer.c shared-bindings/displayio/Group.c
-#: shared-bindings/displayio/Shape.c shared-bindings/vectorio/Circle.c
-#: shared-bindings/vectorio/Rectangle.c
+#: shared-bindings/displayio/Shape.c
+#: shared-bindings/memorymonitor/AllocationAlarm.c
+#: shared-bindings/vectorio/Circle.c shared-bindings/vectorio/Rectangle.c
msgid "%q must be >= 1"
msgstr "%q 는 >=1이어야합니다"
@@ -319,6 +324,11 @@ msgstr "모든 타이머가 사용 중입니다"
msgid "Already advertising."
msgstr ""
+#: shared-module/memorymonitor/AllocationAlarm.c
+#: shared-module/memorymonitor/AllocationSize.c
+msgid "Already running"
+msgstr ""
+
#: ports/cxd56/common-hal/analogio/AnalogIn.c
msgid "AnalogIn not supported on given pin"
msgstr ""
@@ -354,6 +364,11 @@ msgstr ""
msgid "At most %d %q may be specified (not %d)"
msgstr ""
+#: shared-module/memorymonitor/AllocationAlarm.c
+#, c-format
+msgid "Attempt to allocate %d blocks"
+msgstr ""
+
#: supervisor/shared/safe_mode.c
msgid "Attempted heap allocation when MicroPython VM not running."
msgstr ""
@@ -475,7 +490,9 @@ msgstr ""
msgid "Can't set CCCD on local Characteristic"
msgstr ""
-#: shared-bindings/displayio/Bitmap.c shared-bindings/pulseio/PulseIn.c
+#: shared-bindings/displayio/Bitmap.c
+#: shared-bindings/memorymonitor/AllocationSize.c
+#: shared-bindings/pulseio/PulseIn.c
msgid "Cannot delete values"
msgstr "값을 삭제할 수 없습니다"
@@ -1355,6 +1372,7 @@ msgstr ""
msgid "Random number generation error"
msgstr ""
+#: shared-bindings/memorymonitor/AllocationSize.c
#: shared-bindings/pulseio/PulseIn.c
msgid "Read-only"
msgstr ""
@@ -1439,7 +1457,9 @@ msgid "Slice and value different lengths."
msgstr ""
#: shared-bindings/displayio/Bitmap.c shared-bindings/displayio/Group.c
-#: shared-bindings/displayio/TileGrid.c shared-bindings/pulseio/PulseIn.c
+#: shared-bindings/displayio/TileGrid.c
+#: shared-bindings/memorymonitor/AllocationSize.c
+#: shared-bindings/pulseio/PulseIn.c
msgid "Slices not supported"
msgstr ""
diff --git a/locale/nl.po b/locale/nl.po
index 253d18a04..29591dfd8 100644
--- a/locale/nl.po
+++ b/locale/nl.po
@@ -84,10 +84,15 @@ msgstr "%q indexen moeten integers zijn, niet %s"
msgid "%q list must be a list"
msgstr "%q lijst moet een lijst zijn"
+#: shared-bindings/memorymonitor/AllocationAlarm.c
+msgid "%q must be >= 0"
+msgstr ""
+
#: shared-bindings/_bleio/CharacteristicBuffer.c
#: shared-bindings/_bleio/PacketBuffer.c shared-bindings/displayio/Group.c
-#: shared-bindings/displayio/Shape.c shared-bindings/vectorio/Circle.c
-#: shared-bindings/vectorio/Rectangle.c
+#: shared-bindings/displayio/Shape.c
+#: shared-bindings/memorymonitor/AllocationAlarm.c
+#: shared-bindings/vectorio/Circle.c shared-bindings/vectorio/Rectangle.c
msgid "%q must be >= 1"
msgstr "%q moet >= 1 zijn"
@@ -325,6 +330,11 @@ msgstr "Alle timers zijn in gebruik"
msgid "Already advertising."
msgstr "Advertising is al bezig."
+#: shared-module/memorymonitor/AllocationAlarm.c
+#: shared-module/memorymonitor/AllocationSize.c
+msgid "Already running"
+msgstr ""
+
#: ports/cxd56/common-hal/analogio/AnalogIn.c
msgid "AnalogIn not supported on given pin"
msgstr "AnalogIn niet ondersteund door gegeven pin"
@@ -360,6 +370,11 @@ msgstr "Array waardes moet enkele bytes zijn."
msgid "At most %d %q may be specified (not %d)"
msgstr "Op zijn meest %d %q mogen worden gespecificeerd (niet %d)"
+#: shared-module/memorymonitor/AllocationAlarm.c
+#, c-format
+msgid "Attempt to allocate %d blocks"
+msgstr ""
+
#: supervisor/shared/safe_mode.c
msgid "Attempted heap allocation when MicroPython VM not running."
msgstr "heap allocatie geprobeerd terwijl MicroPython VM niet draait."
@@ -481,7 +496,9 @@ msgstr "Roep super().__init__() aan voor toegang native object."
msgid "Can't set CCCD on local Characteristic"
msgstr "Kan CCCD niet toewijzen aan lokaal Characteristic"
-#: shared-bindings/displayio/Bitmap.c shared-bindings/pulseio/PulseIn.c
+#: shared-bindings/displayio/Bitmap.c
+#: shared-bindings/memorymonitor/AllocationSize.c
+#: shared-bindings/pulseio/PulseIn.c
msgid "Cannot delete values"
msgstr "Kan waardes niet verwijderen"
@@ -1385,6 +1402,7 @@ msgstr "RTS/CTS/RS485 Nog niet ondersteund door dit apparaat"
msgid "Random number generation error"
msgstr "Random number generatie fout"
+#: shared-bindings/memorymonitor/AllocationSize.c
#: shared-bindings/pulseio/PulseIn.c
msgid "Read-only"
msgstr "Alleen-lezen"
@@ -1469,7 +1487,9 @@ msgid "Slice and value different lengths."
msgstr "Slice en waarde hebben verschillende lengtes."
#: shared-bindings/displayio/Bitmap.c shared-bindings/displayio/Group.c
-#: shared-bindings/displayio/TileGrid.c shared-bindings/pulseio/PulseIn.c
+#: shared-bindings/displayio/TileGrid.c
+#: shared-bindings/memorymonitor/AllocationSize.c
+#: shared-bindings/pulseio/PulseIn.c
msgid "Slices not supported"
msgstr "Slices niet ondersteund"
diff --git a/locale/pl.po b/locale/pl.po
index b2b2d7a16..e359e71b6 100644
--- a/locale/pl.po
+++ b/locale/pl.po
@@ -78,10 +78,15 @@ msgstr "%q indeks musi być liczbą całkowitą, a nie %s"
msgid "%q list must be a list"
msgstr ""
+#: shared-bindings/memorymonitor/AllocationAlarm.c
+msgid "%q must be >= 0"
+msgstr ""
+
#: shared-bindings/_bleio/CharacteristicBuffer.c
#: shared-bindings/_bleio/PacketBuffer.c shared-bindings/displayio/Group.c
-#: shared-bindings/displayio/Shape.c shared-bindings/vectorio/Circle.c
-#: shared-bindings/vectorio/Rectangle.c
+#: shared-bindings/displayio/Shape.c
+#: shared-bindings/memorymonitor/AllocationAlarm.c
+#: shared-bindings/vectorio/Circle.c shared-bindings/vectorio/Rectangle.c
msgid "%q must be >= 1"
msgstr "%q musi być >= 1"
@@ -319,6 +324,11 @@ msgstr "Wszystkie timery w użyciu"
msgid "Already advertising."
msgstr ""
+#: shared-module/memorymonitor/AllocationAlarm.c
+#: shared-module/memorymonitor/AllocationSize.c
+msgid "Already running"
+msgstr ""
+
#: ports/cxd56/common-hal/analogio/AnalogIn.c
msgid "AnalogIn not supported on given pin"
msgstr ""
@@ -354,6 +364,11 @@ msgstr "Wartości powinny być bajtami."
msgid "At most %d %q may be specified (not %d)"
msgstr ""
+#: shared-module/memorymonitor/AllocationAlarm.c
+#, c-format
+msgid "Attempt to allocate %d blocks"
+msgstr ""
+
#: supervisor/shared/safe_mode.c
msgid "Attempted heap allocation when MicroPython VM not running."
msgstr ""
@@ -475,7 +490,9 @@ msgstr ""
msgid "Can't set CCCD on local Characteristic"
msgstr ""
-#: shared-bindings/displayio/Bitmap.c shared-bindings/pulseio/PulseIn.c
+#: shared-bindings/displayio/Bitmap.c
+#: shared-bindings/memorymonitor/AllocationSize.c
+#: shared-bindings/pulseio/PulseIn.c
msgid "Cannot delete values"
msgstr "Nie można usunąć"
@@ -1357,6 +1374,7 @@ msgstr ""
msgid "Random number generation error"
msgstr ""
+#: shared-bindings/memorymonitor/AllocationSize.c
#: shared-bindings/pulseio/PulseIn.c
msgid "Read-only"
msgstr "Tylko do odczytu"
@@ -1441,7 +1459,9 @@ msgid "Slice and value different lengths."
msgstr "Fragment i wartość są różnych długości."
#: shared-bindings/displayio/Bitmap.c shared-bindings/displayio/Group.c
-#: shared-bindings/displayio/TileGrid.c shared-bindings/pulseio/PulseIn.c
+#: shared-bindings/displayio/TileGrid.c
+#: shared-bindings/memorymonitor/AllocationSize.c
+#: shared-bindings/pulseio/PulseIn.c
msgid "Slices not supported"
msgstr "Fragmenty nieobsługiwane"
diff --git a/locale/pt_BR.po b/locale/pt_BR.po
index b7062f5f0..10f3bf611 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: 2020-07-17 18:03-0700\n"
-"PO-Revision-Date: 2020-07-09 17:23+0000\n"
+"PO-Revision-Date: 2020-07-23 02:57+0000\n"
"Last-Translator: Wellington Terumi Uemura <wellingtonuemura@gmail.com>\n"
"Language-Team: \n"
"Language: pt_BR\n"
@@ -84,10 +84,15 @@ msgstr "Os índices %q devem ser inteiros, e não %s"
msgid "%q list must be a list"
msgstr "A lista %q deve ser uma lista"
+#: shared-bindings/memorymonitor/AllocationAlarm.c
+msgid "%q must be >= 0"
+msgstr "%q deve ser >= 0"
+
#: shared-bindings/_bleio/CharacteristicBuffer.c
#: shared-bindings/_bleio/PacketBuffer.c shared-bindings/displayio/Group.c
-#: shared-bindings/displayio/Shape.c shared-bindings/vectorio/Circle.c
-#: shared-bindings/vectorio/Rectangle.c
+#: shared-bindings/displayio/Shape.c
+#: shared-bindings/memorymonitor/AllocationAlarm.c
+#: shared-bindings/vectorio/Circle.c shared-bindings/vectorio/Rectangle.c
msgid "%q must be >= 1"
msgstr "%q deve ser >= 1"
@@ -113,7 +118,7 @@ msgstr "'%q' argumento(s) requerido(s)"
#: py/objarray.c
msgid "'%q' object is not bytes-like"
-msgstr ""
+msgstr "objetos '%q' não são bytes-like"
#: py/emitinlinethumb.c py/emitinlinextensa.c
#, c-format
@@ -327,6 +332,11 @@ msgstr "Todos os temporizadores em uso"
msgid "Already advertising."
msgstr "Já está anunciando."
+#: shared-module/memorymonitor/AllocationAlarm.c
+#: shared-module/memorymonitor/AllocationSize.c
+msgid "Already running"
+msgstr "Já está em execução"
+
#: ports/cxd56/common-hal/analogio/AnalogIn.c
msgid "AnalogIn not supported on given pin"
msgstr "O AnalogIn não é compatível no pino informado"
@@ -362,6 +372,11 @@ msgstr "Os valores das matrizes devem ser bytes simples."
msgid "At most %d %q may be specified (not %d)"
msgstr "Pelo menos %d %q pode ser definido (não %d)"
+#: shared-module/memorymonitor/AllocationAlarm.c
+#, c-format
+msgid "Attempt to allocate %d blocks"
+msgstr "Tentativa de alocar %d blocos"
+
#: supervisor/shared/safe_mode.c
msgid "Attempted heap allocation when MicroPython VM not running."
msgstr ""
@@ -487,7 +502,9 @@ msgstr "Chame super().__init__() antes de acessar o objeto nativo."
msgid "Can't set CCCD on local Characteristic"
msgstr "Não é possível definir o CCCD com a característica local"
-#: shared-bindings/displayio/Bitmap.c shared-bindings/pulseio/PulseIn.c
+#: shared-bindings/displayio/Bitmap.c
+#: shared-bindings/memorymonitor/AllocationSize.c
+#: shared-bindings/pulseio/PulseIn.c
msgid "Cannot delete values"
msgstr "Não é possível excluir valores"
@@ -1393,6 +1410,7 @@ msgstr "RTS/CTS/RS485 Ainda não é compatível neste dispositivo"
msgid "Random number generation error"
msgstr "Houve um erro na geração do número aleatório"
+#: shared-bindings/memorymonitor/AllocationSize.c
#: shared-bindings/pulseio/PulseIn.c
msgid "Read-only"
msgstr "Somente leitura"
@@ -1477,7 +1495,9 @@ msgid "Slice and value different lengths."
msgstr "Fatie e avalie os diferentes comprimentos."
#: shared-bindings/displayio/Bitmap.c shared-bindings/displayio/Group.c
-#: shared-bindings/displayio/TileGrid.c shared-bindings/pulseio/PulseIn.c
+#: shared-bindings/displayio/TileGrid.c
+#: shared-bindings/memorymonitor/AllocationSize.c
+#: shared-bindings/pulseio/PulseIn.c
msgid "Slices not supported"
msgstr "Fatiamento não compatível"
diff --git a/locale/sv.po b/locale/sv.po
index ffec64bfe..075db8ab0 100644
--- a/locale/sv.po
+++ b/locale/sv.po
@@ -84,10 +84,15 @@ msgstr "Indexet %q måste vara ett heltal, inte %s"
msgid "%q list must be a list"
msgstr "%q-listan måste vara en lista"
+#: shared-bindings/memorymonitor/AllocationAlarm.c
+msgid "%q must be >= 0"
+msgstr ""
+
#: shared-bindings/_bleio/CharacteristicBuffer.c
#: shared-bindings/_bleio/PacketBuffer.c shared-bindings/displayio/Group.c
-#: shared-bindings/displayio/Shape.c shared-bindings/vectorio/Circle.c
-#: shared-bindings/vectorio/Rectangle.c
+#: shared-bindings/displayio/Shape.c
+#: shared-bindings/memorymonitor/AllocationAlarm.c
+#: shared-bindings/vectorio/Circle.c shared-bindings/vectorio/Rectangle.c
msgid "%q must be >= 1"
msgstr "%q måste vara >= 1"
@@ -325,6 +330,11 @@ msgstr "Alla timers används"
msgid "Already advertising."
msgstr "Annonserar redan."
+#: shared-module/memorymonitor/AllocationAlarm.c
+#: shared-module/memorymonitor/AllocationSize.c
+msgid "Already running"
+msgstr ""
+
#: ports/cxd56/common-hal/analogio/AnalogIn.c
msgid "AnalogIn not supported on given pin"
msgstr "AnalogIn stöds inte på angiven pinne"
@@ -360,6 +370,11 @@ msgstr "Matrisvärden ska bestå av enstaka bytes."
msgid "At most %d %q may be specified (not %d)"
msgstr "Högst %d %q kan anges (inte %d)"
+#: shared-module/memorymonitor/AllocationAlarm.c
+#, c-format
+msgid "Attempt to allocate %d blocks"
+msgstr ""
+
#: supervisor/shared/safe_mode.c
msgid "Attempted heap allocation when MicroPython VM not running."
msgstr "Försökte tilldela heap när MicroPython VM inte körs."
@@ -481,7 +496,9 @@ msgstr "Anropa super().__init__() innan du använder det ursprungliga objektet."
msgid "Can't set CCCD on local Characteristic"
msgstr "Kan inte ställa in CCCD på lokal karaktäristik"
-#: shared-bindings/displayio/Bitmap.c shared-bindings/pulseio/PulseIn.c
+#: shared-bindings/displayio/Bitmap.c
+#: shared-bindings/memorymonitor/AllocationSize.c
+#: shared-bindings/pulseio/PulseIn.c
msgid "Cannot delete values"
msgstr "Kan inte radera värden"
@@ -1381,6 +1398,7 @@ msgstr "RTS/CTS/RS485 Stöds ännu inte på den här enheten"
msgid "Random number generation error"
msgstr "Fel vid generering av slumptal"
+#: shared-bindings/memorymonitor/AllocationSize.c
#: shared-bindings/pulseio/PulseIn.c
msgid "Read-only"
msgstr "Skrivskyddad"
@@ -1465,7 +1483,9 @@ msgid "Slice and value different lengths."
msgstr "Slice och värde har olika längd."
#: shared-bindings/displayio/Bitmap.c shared-bindings/displayio/Group.c
-#: shared-bindings/displayio/TileGrid.c shared-bindings/pulseio/PulseIn.c
+#: shared-bindings/displayio/TileGrid.c
+#: shared-bindings/memorymonitor/AllocationSize.c
+#: shared-bindings/pulseio/PulseIn.c
msgid "Slices not supported"
msgstr "Slice stöds inte"
diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po
index 6c19fb67c..a820c142c 100644
--- a/locale/zh_Latn_pinyin.po
+++ b/locale/zh_Latn_pinyin.po
@@ -84,10 +84,15 @@ msgstr "%q suǒyǐn bìxū shì zhěngshù, ér bùshì %s"
msgid "%q list must be a list"
msgstr ""
+#: shared-bindings/memorymonitor/AllocationAlarm.c
+msgid "%q must be >= 0"
+msgstr ""
+
#: shared-bindings/_bleio/CharacteristicBuffer.c
#: shared-bindings/_bleio/PacketBuffer.c shared-bindings/displayio/Group.c
-#: shared-bindings/displayio/Shape.c shared-bindings/vectorio/Circle.c
-#: shared-bindings/vectorio/Rectangle.c
+#: shared-bindings/displayio/Shape.c
+#: shared-bindings/memorymonitor/AllocationAlarm.c
+#: shared-bindings/vectorio/Circle.c shared-bindings/vectorio/Rectangle.c
msgid "%q must be >= 1"
msgstr "%q bìxū dàyú huò děngyú 1"
@@ -325,6 +330,11 @@ msgstr "Suǒyǒu jìshí qì shǐyòng"
msgid "Already advertising."
msgstr "Mùqián zhèngzài guǎngbò"
+#: shared-module/memorymonitor/AllocationAlarm.c
+#: shared-module/memorymonitor/AllocationSize.c
+msgid "Already running"
+msgstr ""
+
#: ports/cxd56/common-hal/analogio/AnalogIn.c
msgid "AnalogIn not supported on given pin"
msgstr "Gěi dìng de yǐn jiǎo bù zhīchí AnalogIn"
@@ -360,6 +370,11 @@ msgstr "Shùzǔ zhí yīnggāi shì dāngè zì jié."
msgid "At most %d %q may be specified (not %d)"
msgstr ""
+#: shared-module/memorymonitor/AllocationAlarm.c
+#, c-format
+msgid "Attempt to allocate %d blocks"
+msgstr ""
+
#: supervisor/shared/safe_mode.c
msgid "Attempted heap allocation when MicroPython VM not running."
msgstr "MicroPython VM zài wèi yùnxíng shí chángshì fēnpèi duī."
@@ -481,7 +496,9 @@ msgstr "Zài fǎngwèn běn jī wùjiàn zhīqián diàoyòng super().__init__()
msgid "Can't set CCCD on local Characteristic"
msgstr "Wúfǎ jiāng CCCD shèzhì wéi běndì tèzhēng"
-#: shared-bindings/displayio/Bitmap.c shared-bindings/pulseio/PulseIn.c
+#: shared-bindings/displayio/Bitmap.c
+#: shared-bindings/memorymonitor/AllocationSize.c
+#: shared-bindings/pulseio/PulseIn.c
msgid "Cannot delete values"
msgstr "Wúfǎ shānchú zhí"
@@ -1371,6 +1388,7 @@ msgstr ""
msgid "Random number generation error"
msgstr "Suíjī shù shēngchéng cuòwù"
+#: shared-bindings/memorymonitor/AllocationSize.c
#: shared-bindings/pulseio/PulseIn.c
msgid "Read-only"
msgstr "Zhǐ dú"
@@ -1455,7 +1473,9 @@ msgid "Slice and value different lengths."
msgstr "Qiēpiàn hé zhí bùtóng chángdù."
#: shared-bindings/displayio/Bitmap.c shared-bindings/displayio/Group.c
-#: shared-bindings/displayio/TileGrid.c shared-bindings/pulseio/PulseIn.c
+#: shared-bindings/displayio/TileGrid.c
+#: shared-bindings/memorymonitor/AllocationSize.c
+#: shared-bindings/pulseio/PulseIn.c
msgid "Slices not supported"
msgstr "Qiēpiàn bù shòu zhīchí"
diff --git a/main.c b/main.c
index a571c547a..8c5c9ac37 100755
--- a/main.c
+++ b/main.c
@@ -64,6 +64,10 @@
#include "shared-module/displayio/__init__.h"
#endif
+#if CIRCUITPY_MEMORYMONITOR
+#include "shared-module/memorymonitor/__init__.h"
+#endif
+
#if CIRCUITPY_NETWORK
#include "shared-module/network/__init__.h"
#endif
@@ -206,6 +210,9 @@ void cleanup_after_vm(supervisor_allocation* heap) {
#if CIRCUITPY_DISPLAYIO
reset_displays();
#endif
+ #if CIRCUITPY_MEMORYMONITOR
+ memorymonitor_reset();
+ #endif
filesystem_flush();
stop_mp();
free_memory(heap);
@@ -324,6 +331,8 @@ bool run_code_py(safe_mode_t safe_mode) {
}
}
+FIL* boot_output_file;
+
void __attribute__ ((noinline)) run_boot_py(safe_mode_t safe_mode) {
// If not in safe mode, run boot before initing USB and capture output in a
// file.
diff --git a/mpy-cross/mpconfigport.h b/mpy-cross/mpconfigport.h
index 0b07a5b44..464c9113d 100644
--- a/mpy-cross/mpconfigport.h
+++ b/mpy-cross/mpconfigport.h
@@ -40,6 +40,7 @@
#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_DOUBLE)
#define MICROPY_CPYTHON_COMPAT (1)
+#define MICROPY_PY_ASYNC_AWAIT (1)
#define MICROPY_USE_INTERNAL_PRINTF (0)
#define MICROPY_PY_BUILTINS_STR_UNICODE (1)
diff --git a/ports/atmel-samd/mphalport.h b/ports/atmel-samd/mphalport.h
index f11971749..adc65ade5 100644
--- a/ports/atmel-samd/mphalport.h
+++ b/ports/atmel-samd/mphalport.h
@@ -37,8 +37,8 @@
#define mp_hal_ticks_ms() ((mp_uint_t) supervisor_ticks_ms32())
// Number of bytes in receive buffer
-volatile uint8_t usb_rx_count;
-volatile bool mp_cdc_enabled;
+extern volatile uint8_t usb_rx_count;
+extern volatile bool mp_cdc_enabled;
int receive_usb(void);
diff --git a/ports/esp32s2/Makefile b/ports/esp32s2/Makefile
index 9415f42f2..55db73604 100644
--- a/ports/esp32s2/Makefile
+++ b/ports/esp32s2/Makefile
@@ -275,7 +275,7 @@ esp-idf-stamp: $(BUILD)/esp-idf/config/sdkconfig.h
$(BUILD)/firmware.elf: $(OBJ) | esp-idf-stamp
$(STEPECHO) "LINK $@"
- $(Q)$(CC) -o $@ $(LDFLAGS) $^ $(ESP_IDF_COMPONENTS_EXPANDED) $(BINARY_BLOBS) build-$(BOARD)/esp-idf/esp-idf/newlib/libnewlib.a -u newlib_include_pthread_impl
+ $(Q)$(CC) -o $@ $(LDFLAGS) $^ $(ESP_IDF_COMPONENTS_EXPANDED) $(BINARY_BLOBS) build-$(BOARD)/esp-idf/esp-idf/newlib/libnewlib.a -u newlib_include_pthread_impl -Wl,--start-group $(LIBS) -Wl,--end-group
# $(Q)$(SIZE) $@ | $(PYTHON3) $(TOP)/tools/build_memory_info.py $(BUILD)/esp-idf/esp-idf/esp32s2/esp32s2_out.ld
$(BUILD)/circuitpython-firmware.bin: $(BUILD)/firmware.elf
diff --git a/ports/esp32s2/common-hal/pulseio/PWMOut.c b/ports/esp32s2/common-hal/pulseio/PWMOut.c
new file mode 100644
index 000000000..c4f5e18dd
--- /dev/null
+++ b/ports/esp32s2/common-hal/pulseio/PWMOut.c
@@ -0,0 +1,198 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019 Lucian Copeland for Adafruit Industries
+ * Uses code from Micropython, Copyright (c) 2013-2016 Damien P. George
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+#include <math.h>
+
+#include "common-hal/pulseio/PWMOut.h"
+#include "shared-bindings/pulseio/PWMOut.h"
+#include "py/runtime.h"
+#include "driver/ledc.h"
+
+#define INDEX_EMPTY 0xFF
+
+STATIC uint32_t reserved_timer_freq[LEDC_TIMER_MAX];
+STATIC uint8_t reserved_channels[LEDC_CHANNEL_MAX];
+STATIC bool never_reset_tim[LEDC_TIMER_MAX];
+STATIC bool never_reset_chan[LEDC_CHANNEL_MAX];
+
+void pwmout_reset(void) {
+ for (size_t i = 0; i < LEDC_CHANNEL_MAX; i++ ) {
+ ledc_stop(LEDC_LOW_SPEED_MODE, i, 0);
+ if (!never_reset_chan[i]) {
+ reserved_channels[i] = INDEX_EMPTY;
+ }
+ }
+ for (size_t i = 0; i < LEDC_TIMER_MAX; i++ ) {
+ ledc_timer_rst(LEDC_LOW_SPEED_MODE, i);
+ if (!never_reset_tim[i]) {
+ reserved_timer_freq[i] = 0;
+ }
+ }
+}
+
+pwmout_result_t common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self,
+ const mcu_pin_obj_t* pin,
+ uint16_t duty,
+ uint32_t frequency,
+ bool variable_frequency) {
+ // Calculate duty cycle
+ uint32_t duty_bits = 0;
+ uint32_t interval = LEDC_APB_CLK_HZ/frequency;
+ for (size_t i = 0; i < 32; i++) {
+ if(!(interval >> i)) {
+ duty_bits = i - 1;
+ break;
+ }
+ }
+ if (duty_bits < 1) {
+ mp_raise_ValueError(translate("Invalid frequency"));
+ } else if (duty_bits >= LEDC_TIMER_14_BIT) {
+ duty_bits = LEDC_TIMER_13_BIT;
+ }
+
+ // Find a viable timer
+ size_t timer_index = INDEX_EMPTY;
+ size_t channel_index = INDEX_EMPTY;
+ for (size_t i = 0; i < LEDC_TIMER_MAX; i++) {
+ if ((reserved_timer_freq[i] == frequency) && !variable_frequency) {
+ //prioritize matched frequencies so we don't needlessly take slots
+ timer_index = i;
+ break;
+ } else if (reserved_timer_freq[i] == 0) {
+ timer_index = i;
+ break;
+ }
+ }
+ if (timer_index == INDEX_EMPTY) {
+ // Running out of timers isn't pin related on ESP32S2 so we can't re-use error messages
+ mp_raise_ValueError(translate("No more timers available"));
+ }
+
+ // Find a viable channel
+ for (size_t i = 0; i < LEDC_CHANNEL_MAX; i++) {
+ if (reserved_channels[i] == INDEX_EMPTY) {
+ channel_index = i;
+ break;
+ }
+ }
+ if (channel_index == INDEX_EMPTY) {
+ mp_raise_ValueError(translate("No more channels available"));
+ }
+
+ // Run configuration
+ self->tim_handle.timer_num = timer_index;
+ self->tim_handle.duty_resolution = duty_bits;
+ self->tim_handle.freq_hz = frequency;
+ self->tim_handle.speed_mode = LEDC_LOW_SPEED_MODE;
+ self->tim_handle.clk_cfg = LEDC_AUTO_CLK;
+
+ if (ledc_timer_config(&(self->tim_handle)) != ESP_OK) {
+ mp_raise_ValueError(translate("Could not initialize timer"));
+ }
+
+ self->chan_handle.channel = channel_index;
+ self->chan_handle.duty = duty >> (16 - duty_bits);
+ self->chan_handle.gpio_num = pin->number;
+ self->chan_handle.speed_mode = LEDC_LOW_SPEED_MODE; // Only LS is allowed on ESP32-S2
+ self->chan_handle.hpoint = 0;
+ self->chan_handle.timer_sel = timer_index;
+
+ if (ledc_channel_config(&(self->chan_handle))) {
+ mp_raise_ValueError(translate("Could not initialize channel"));
+ }
+
+ // Make reservations
+ reserved_timer_freq[timer_index] = frequency;
+ reserved_channels[channel_index] = timer_index;
+
+ self->variable_frequency = variable_frequency;
+ self->pin_number = pin->number;
+ self->deinited = false;
+ self->duty_resolution = duty_bits;
+ claim_pin(pin);
+
+ // Set initial duty
+ common_hal_pulseio_pwmout_set_duty_cycle(self, duty);
+
+ return PWMOUT_OK;
+}
+
+void common_hal_pulseio_pwmout_never_reset(pulseio_pwmout_obj_t *self) {
+ never_reset_tim[self->tim_handle.timer_num] = true;
+ never_reset_chan[self->chan_handle.channel] = true;
+}
+
+void common_hal_pulseio_pwmout_reset_ok(pulseio_pwmout_obj_t *self) {
+ never_reset_tim[self->tim_handle.timer_num] = false;
+ never_reset_chan[self->chan_handle.channel] = false;
+}
+
+bool common_hal_pulseio_pwmout_deinited(pulseio_pwmout_obj_t* self) {
+ return self->deinited == true;
+}
+
+void common_hal_pulseio_pwmout_deinit(pulseio_pwmout_obj_t* self) {
+ if (common_hal_pulseio_pwmout_deinited(self)) {
+ return;
+ }
+ ledc_stop(LEDC_LOW_SPEED_MODE, self->chan_handle.channel, 0);
+ // Search if any other channel is using the timer
+ bool taken = false;
+ for (size_t i =0; i < LEDC_CHANNEL_MAX; i++) {
+ if (reserved_channels[i] == self->tim_handle.timer_num) {
+ taken = true;
+ }
+ }
+ // Variable frequency means there's only one channel on the timer
+ if (!taken || self->variable_frequency) {
+ ledc_timer_rst(LEDC_LOW_SPEED_MODE, self->tim_handle.timer_num);
+ reserved_timer_freq[self->tim_handle.timer_num] = 0;
+ }
+ reset_pin_number(self->pin_number);
+ reserved_channels[self->chan_handle.channel] = INDEX_EMPTY;
+ self->deinited = true;
+}
+
+void common_hal_pulseio_pwmout_set_duty_cycle(pulseio_pwmout_obj_t* self, uint16_t duty) {
+ ledc_set_duty(LEDC_LOW_SPEED_MODE, self->chan_handle.channel, duty >> (16 - self->duty_resolution));
+ ledc_update_duty(LEDC_LOW_SPEED_MODE, self->chan_handle.channel);
+}
+
+uint16_t common_hal_pulseio_pwmout_get_duty_cycle(pulseio_pwmout_obj_t* self) {
+ return ledc_get_duty(LEDC_LOW_SPEED_MODE, self->chan_handle.channel) << (16 - self->duty_resolution);
+}
+
+void common_hal_pulseio_pwmout_set_frequency(pulseio_pwmout_obj_t* self, uint32_t frequency) {
+ ledc_set_freq(LEDC_LOW_SPEED_MODE, self->tim_handle.timer_num, frequency);
+}
+
+uint32_t common_hal_pulseio_pwmout_get_frequency(pulseio_pwmout_obj_t* self) {
+ return ledc_get_freq(LEDC_LOW_SPEED_MODE, self->tim_handle.timer_num);
+}
+
+bool common_hal_pulseio_pwmout_get_variable_frequency(pulseio_pwmout_obj_t* self) {
+ return self->variable_frequency;
+}
diff --git a/ports/esp32s2/common-hal/pulseio/PWMOut.h b/ports/esp32s2/common-hal/pulseio/PWMOut.h
new file mode 100644
index 000000000..90a0c3ed9
--- /dev/null
+++ b/ports/esp32s2/common-hal/pulseio/PWMOut.h
@@ -0,0 +1,45 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019 Lucian Copeland for Adafruit Industries
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#ifndef MICROPY_INCLUDED_ESP32S2_COMMON_HAL_PULSEIO_PWMOUT_H
+#define MICROPY_INCLUDED_ESP32S2_COMMON_HAL_PULSEIO_PWMOUT_H
+
+#include "common-hal/microcontroller/Pin.h"
+#include "driver/ledc.h"
+
+typedef struct {
+ mp_obj_base_t base;
+ ledc_timer_config_t tim_handle;
+ ledc_channel_config_t chan_handle;
+ uint16_t pin_number;
+ uint8_t duty_resolution;
+ bool variable_frequency: 1;
+ bool deinited: 1;
+} pulseio_pwmout_obj_t;
+
+void pwmout_reset(void);
+
+#endif // MICROPY_INCLUDED_ESP32S2_COMMON_HAL_PULSEIO_PWMOUT_H
diff --git a/ports/esp32s2/common-hal/pulseio/PulseIn.c b/ports/esp32s2/common-hal/pulseio/PulseIn.c
new file mode 100644
index 000000000..65fc6631d
--- /dev/null
+++ b/ports/esp32s2/common-hal/pulseio/PulseIn.c
@@ -0,0 +1,75 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020 Lucian Copeland for Adafruit Industries
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include "common-hal/pulseio/PulseIn.h"
+#include "py/runtime.h"
+
+// STATIC void pulsein_handler(uint8_t num) {
+// }
+
+void pulsein_reset(void) {
+}
+
+void common_hal_pulseio_pulsein_construct(pulseio_pulsein_obj_t* self, const mcu_pin_obj_t* pin,
+ uint16_t maxlen, bool idle_state) {
+ mp_raise_NotImplementedError(translate("PulseIn not supported on this chip"));
+}
+
+bool common_hal_pulseio_pulsein_deinited(pulseio_pulsein_obj_t* self) {
+ return false;
+}
+
+void common_hal_pulseio_pulsein_deinit(pulseio_pulsein_obj_t* self) {
+}
+
+void common_hal_pulseio_pulsein_pause(pulseio_pulsein_obj_t* self) {
+}
+
+void common_hal_pulseio_pulsein_resume(pulseio_pulsein_obj_t* self, uint16_t trigger_duration) {
+}
+
+void common_hal_pulseio_pulsein_clear(pulseio_pulsein_obj_t* self) {
+}
+
+uint16_t common_hal_pulseio_pulsein_get_item(pulseio_pulsein_obj_t* self, int16_t index) {
+ return false;
+}
+
+uint16_t common_hal_pulseio_pulsein_popleft(pulseio_pulsein_obj_t* self) {
+ return false;
+}
+
+uint16_t common_hal_pulseio_pulsein_get_maxlen(pulseio_pulsein_obj_t* self) {
+ return false;
+}
+
+bool common_hal_pulseio_pulsein_get_paused(pulseio_pulsein_obj_t* self) {
+ return false;
+}
+
+uint16_t common_hal_pulseio_pulsein_get_len(pulseio_pulsein_obj_t* self) {
+ return false;
+}
diff --git a/ports/esp32s2/common-hal/pulseio/PulseIn.h b/ports/esp32s2/common-hal/pulseio/PulseIn.h
new file mode 100644
index 000000000..b317c516c
--- /dev/null
+++ b/ports/esp32s2/common-hal/pulseio/PulseIn.h
@@ -0,0 +1,53 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019 Lucian Copeland for Adafruit Industries
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#ifndef MICROPY_INCLUDED_ESP32S2_COMMON_HAL_PULSEIO_PULSEIN_H
+#define MICROPY_INCLUDED_ESP32S2_COMMON_HAL_PULSEIO_PULSEIN_H
+
+#include "common-hal/microcontroller/Pin.h"
+
+#include "py/obj.h"
+
+typedef struct {
+ mp_obj_base_t base;
+
+ const mcu_pin_obj_t* pin;
+ bool idle_state;
+ bool paused;
+ volatile bool first_edge;
+
+ uint16_t* buffer;
+ uint16_t maxlen;
+
+ volatile uint16_t start;
+ volatile uint16_t len;
+ volatile uint32_t last_overflow;
+ volatile uint16_t last_count;
+} pulseio_pulsein_obj_t;
+
+void pulsein_reset(void);
+
+#endif // MICROPY_INCLUDED_ESP32S2_COMMON_HAL_PULSEIO_PULSEIN_H
diff --git a/ports/esp32s2/common-hal/pulseio/PulseOut.c b/ports/esp32s2/common-hal/pulseio/PulseOut.c
new file mode 100644
index 000000000..c448c578d
--- /dev/null
+++ b/ports/esp32s2/common-hal/pulseio/PulseOut.c
@@ -0,0 +1,60 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019 Lucian Copeland for Adafruit Industries
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include "common-hal/pulseio/PulseOut.h"
+
+#include "shared-bindings/pulseio/PWMOut.h"
+#include "py/runtime.h"
+
+// STATIC void turn_on(pulseio_pulseout_obj_t *pulseout) {
+// }
+
+// STATIC void turn_off(pulseio_pulseout_obj_t *pulseout) {
+// }
+
+// STATIC void start_timer(void) {
+// }
+
+// STATIC void pulseout_event_handler(void) {
+// }
+
+void pulseout_reset() {
+}
+
+void common_hal_pulseio_pulseout_construct(pulseio_pulseout_obj_t* self,
+ const pulseio_pwmout_obj_t* carrier) {
+ mp_raise_NotImplementedError(translate("PulseOut not supported on this chip"));
+}
+
+bool common_hal_pulseio_pulseout_deinited(pulseio_pulseout_obj_t* self) {
+ return false;
+}
+
+void common_hal_pulseio_pulseout_deinit(pulseio_pulseout_obj_t* self) {
+}
+
+void common_hal_pulseio_pulseout_send(pulseio_pulseout_obj_t* self, uint16_t* pulses, uint16_t length) {
+}
diff --git a/ports/esp32s2/common-hal/pulseio/PulseOut.h b/ports/esp32s2/common-hal/pulseio/PulseOut.h
new file mode 100644
index 000000000..f465d0079
--- /dev/null
+++ b/ports/esp32s2/common-hal/pulseio/PulseOut.h
@@ -0,0 +1,42 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019 Lucian Copeland for Adafruit Industries
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#ifndef MICROPY_INCLUDED_ESP32S2_COMMON_HAL_PULSEIO_PULSEOUT_H
+#define MICROPY_INCLUDED_ESP32S2_COMMON_HAL_PULSEIO_PULSEOUT_H
+
+#include "common-hal/microcontroller/Pin.h"
+#include "common-hal/pulseio/PWMOut.h"
+
+#include "py/obj.h"
+
+typedef struct {
+ mp_obj_base_t base;
+ pulseio_pwmout_obj_t *pwmout;
+} pulseio_pulseout_obj_t;
+
+void pulseout_reset(void);
+
+#endif // MICROPY_INCLUDED_ESP32S2_COMMON_HAL_PULSEIO_PULSEOUT_H
diff --git a/ports/esp32s2/common-hal/pulseio/__init__.c b/ports/esp32s2/common-hal/pulseio/__init__.c
new file mode 100644
index 000000000..2bee925bc
--- /dev/null
+++ b/ports/esp32s2/common-hal/pulseio/__init__.c
@@ -0,0 +1 @@
+// No pulseio module functions.
diff --git a/ports/esp32s2/mpconfigport.mk b/ports/esp32s2/mpconfigport.mk
index 713ccbb09..c2d21e084 100644
--- a/ports/esp32s2/mpconfigport.mk
+++ b/ports/esp32s2/mpconfigport.mk
@@ -25,7 +25,7 @@ CIRCUITPY_FREQUENCYIO = 0
CIRCUITPY_I2CPERIPHERAL = 0
CIRCUITPY_MICROCONTROLLER = 1
CIRCUITPY_NVM = 0
-CIRCUITPY_PULSEIO = 0
+CIRCUITPY_PULSEIO = 1
CIRCUITPY_ROTARYIO = 0
CIRCUITPY_RTC = 0
CIRCUITPY_TOUCHIO = 0
diff --git a/ports/esp32s2/supervisor/port.c b/ports/esp32s2/supervisor/port.c
index a80550b30..e4767e514 100644
--- a/ports/esp32s2/supervisor/port.c
+++ b/ports/esp32s2/supervisor/port.c
@@ -38,6 +38,7 @@
#include "common-hal/busio/I2C.h"
#include "common-hal/busio/SPI.h"
#include "common-hal/busio/UART.h"
+#include "common-hal/pulseio/PWMOut.h"
#include "supervisor/memory.h"
#include "supervisor/shared/tick.h"
@@ -64,6 +65,9 @@ void reset_port(void) {
// A larger delay so the idle task can run and do any IDF cleanup needed.
vTaskDelay(4);
+#if CIRCUITPY_PULSEIO
+ pwmout_reset();
+#endif
#if CIRCUITPY_BUSIO
i2c_reset();
spi_reset();
diff --git a/ports/litex/common-hal/microcontroller/Pin.c b/ports/litex/common-hal/microcontroller/Pin.c
index 632468f6d..38601e0d3 100644
--- a/ports/litex/common-hal/microcontroller/Pin.c
+++ b/ports/litex/common-hal/microcontroller/Pin.c
@@ -41,12 +41,19 @@ void reset_pin_number(uint8_t pin_port, uint8_t pin_number) {
claimed_pins[pin_port] &= ~(1<<pin_number);
}
+void common_hal_reset_pin(const mcu_pin_obj_t* pin) {
+ reset_pin_number(0, pin->number);
+}
void claim_pin(const mcu_pin_obj_t* pin) {
// Set bit in claimed_pins bitmask.
claimed_pins[0] |= 1<<pin->number;
}
+void common_hal_mcu_pin_claim(const mcu_pin_obj_t* pin) {
+ claim_pin(pin);
+}
+
bool pin_number_is_free(uint8_t pin_port, uint8_t pin_number) {
return !(claimed_pins[pin_port] & 1<<pin_number);
}
diff --git a/ports/stm/Makefile b/ports/stm/Makefile
index 5865ca845..dccc749ed 100755
--- a/ports/stm/Makefile
+++ b/ports/stm/Makefile
@@ -211,6 +211,7 @@ SRC_C += \
mphalport.c \
boards/$(BOARD)/board.c \
boards/$(BOARD)/pins.c \
+ peripherals/timers.c \
peripherals/stm32$(MCU_SERIES_LOWER)/clocks.c \
peripherals/stm32$(MCU_SERIES_LOWER)/$(MCU_VARIANT_LOWER)/pins.c \
peripherals/stm32$(MCU_SERIES_LOWER)/$(MCU_VARIANT_LOWER)/gpio.c \
diff --git a/ports/stm/common-hal/analogio/AnalogIn.c b/ports/stm/common-hal/analogio/AnalogIn.c
index 1d1b308b6..588d687ee 100644
--- a/ports/stm/common-hal/analogio/AnalogIn.c
+++ b/ports/stm/common-hal/analogio/AnalogIn.c
@@ -29,7 +29,7 @@
#include "py/runtime.h"
#include "supervisor/shared/translate.h"
-#include "common-hal/microcontroller/Pin.h"
+#include "shared-bindings/microcontroller/Pin.h"
#include "stm32f4xx_hal.h"
#include "stm32f4xx_ll_gpio.h"
@@ -57,7 +57,7 @@ void common_hal_analogio_analogin_construct(analogio_analogin_obj_t* self,
} else {
mp_raise_ValueError(translate("Invalid ADC Unit value"));
}
- claim_pin(pin);
+ common_hal_mcu_pin_claim(pin);
self->pin = pin;
}
diff --git a/ports/stm/common-hal/analogio/AnalogOut.c b/ports/stm/common-hal/analogio/AnalogOut.c
index a505b2bf0..69c1f3e04 100644
--- a/ports/stm/common-hal/analogio/AnalogOut.c
+++ b/ports/stm/common-hal/analogio/AnalogOut.c
@@ -86,7 +86,7 @@ void common_hal_analogio_analogout_construct(analogio_analogout_obj_t* self,
dac_on[self->dac_index] = true;
self->pin = pin;
- claim_pin(pin);
+ common_hal_mcu_pin_claim(pin);
#endif
}
diff --git a/ports/stm/common-hal/busio/I2C.c b/ports/stm/common-hal/busio/I2C.c
index 6adcf5575..b05d28c85 100644
--- a/ports/stm/common-hal/busio/I2C.c
+++ b/ports/stm/common-hal/busio/I2C.c
@@ -32,7 +32,7 @@
#include "shared-bindings/microcontroller/__init__.h"
#include "supervisor/shared/translate.h"
-#include "common-hal/microcontroller/Pin.h"
+#include "shared-bindings/microcontroller/Pin.h"
// I2C timing specs for the H7 and F7
// Configured for maximum possible clock settings for the family
@@ -161,8 +161,8 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self,
if (HAL_I2C_Init(&(self->handle)) != HAL_OK) {
mp_raise_RuntimeError(translate("I2C Init Error"));
}
- claim_pin(sda);
- claim_pin(scl);
+ common_hal_mcu_pin_claim(sda);
+ common_hal_mcu_pin_claim(scl);
}
void common_hal_busio_i2c_never_reset(busio_i2c_obj_t *self) {
diff --git a/ports/stm/common-hal/busio/SPI.c b/ports/stm/common-hal/busio/SPI.c
index d4dd6cb3f..15c746b62 100644
--- a/ports/stm/common-hal/busio/SPI.c
+++ b/ports/stm/common-hal/busio/SPI.c
@@ -33,7 +33,7 @@
#include "shared-bindings/microcontroller/__init__.h"
#include "boards/board.h"
#include "supervisor/shared/translate.h"
-#include "common-hal/microcontroller/Pin.h"
+#include "shared-bindings/microcontroller/Pin.h"
// Note that any bugs introduced in this file can cause crashes at startup
// for chips using external SPI flash.
@@ -233,12 +233,12 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self,
self->phase = 0;
self->bits = 8;
- claim_pin(sck);
+ common_hal_mcu_pin_claim(sck);
if (self->mosi != NULL) {
- claim_pin(mosi);
+ common_hal_mcu_pin_claim(mosi);
}
if (self->miso != NULL) {
- claim_pin(miso);
+ common_hal_mcu_pin_claim(miso);
}
}
diff --git a/ports/stm/common-hal/busio/UART.c b/ports/stm/common-hal/busio/UART.c
index 7450f9897..08dae7e42 100644
--- a/ports/stm/common-hal/busio/UART.c
+++ b/ports/stm/common-hal/busio/UART.c
@@ -25,6 +25,7 @@
*/
#include "shared-bindings/microcontroller/__init__.h"
+#include "shared-bindings/microcontroller/Pin.h"
#include "shared-bindings/busio/UART.h"
#include "mpconfigport.h"
@@ -224,10 +225,10 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
mp_raise_ValueError(translate("UART Buffer allocation error"));
}
}
- claim_pin(rx);
+ common_hal_mcu_pin_claim(rx);
}
if (self->tx != NULL) {
- claim_pin(tx);
+ common_hal_mcu_pin_claim(tx);
}
self->baudrate = baudrate;
self->timeout_ms = timeout * 1000;
diff --git a/ports/stm/common-hal/digitalio/DigitalInOut.c b/ports/stm/common-hal/digitalio/DigitalInOut.c
index 1354e1a32..a676aeb15 100644
--- a/ports/stm/common-hal/digitalio/DigitalInOut.c
+++ b/ports/stm/common-hal/digitalio/DigitalInOut.c
@@ -26,6 +26,7 @@
*/
#include "shared-bindings/digitalio/DigitalInOut.h"
+#include "shared-bindings/microcontroller/Pin.h"
#include "py/runtime.h"
#include "supervisor/shared/translate.h"
@@ -46,7 +47,7 @@ void common_hal_digitalio_digitalinout_never_reset(
digitalinout_result_t common_hal_digitalio_digitalinout_construct(
digitalio_digitalinout_obj_t *self, const mcu_pin_obj_t *pin) {
- claim_pin(pin);
+ common_hal_mcu_pin_claim(pin);
self->pin = pin;
GPIO_InitTypeDef GPIO_InitStruct = {0};
diff --git a/ports/stm/common-hal/microcontroller/Pin.c b/ports/stm/common-hal/microcontroller/Pin.c
index 3e3fc0522..9fbdedead 100644
--- a/ports/stm/common-hal/microcontroller/Pin.c
+++ b/ports/stm/common-hal/microcontroller/Pin.c
@@ -89,6 +89,8 @@ void reset_pin_number(uint8_t pin_port, uint8_t pin_number) {
void never_reset_pin_number(uint8_t pin_port, uint8_t pin_number) {
never_reset_pins[pin_port] |= 1<<pin_number;
+ // Make sure never reset pins are also always claimed
+ claimed_pins[pin_port] |= 1<<pin_number;
}
void common_hal_never_reset_pin(const mcu_pin_obj_t* pin) {
@@ -99,15 +101,9 @@ void common_hal_reset_pin(const mcu_pin_obj_t* pin) {
reset_pin_number(pin->port, pin->number);
}
-void claim_pin(const mcu_pin_obj_t* pin) {
+void claim_pin(uint8_t pin_port, uint8_t pin_number) {
// Set bit in claimed_pins bitmask.
- claimed_pins[pin->port] |= 1<<pin->number;
-
- #ifdef MICROPY_HW_NEOPIXEL
- if (pin == MICROPY_HW_NEOPIXEL) {
- neopixel_in_use = true;
- }
- #endif
+ claimed_pins[pin_port] |= 1<<pin_number;
}
bool pin_number_is_free(uint8_t pin_port, uint8_t pin_number) {
@@ -137,7 +133,12 @@ uint8_t common_hal_mcu_pin_number(const mcu_pin_obj_t* pin) {
}
void common_hal_mcu_pin_claim(const mcu_pin_obj_t* pin) {
- claim_pin(pin);
+ claim_pin(pin->port, pin->number);
+ #ifdef MICROPY_HW_NEOPIXEL
+ if (pin == MICROPY_HW_NEOPIXEL) {
+ neopixel_in_use = true;
+ }
+ #endif
}
void common_hal_mcu_pin_reset_number(uint8_t pin_no) {
diff --git a/ports/stm/common-hal/microcontroller/Pin.h b/ports/stm/common-hal/microcontroller/Pin.h
index d69ddfb1d..f461d3813 100644
--- a/ports/stm/common-hal/microcontroller/Pin.h
+++ b/ports/stm/common-hal/microcontroller/Pin.h
@@ -43,7 +43,7 @@ void reset_all_pins(void);
// reset_pin_number takes the pin number instead of the pointer so that objects don't
// need to store a full pointer.
void reset_pin_number(uint8_t pin_port, uint8_t pin_number);
-void claim_pin(const mcu_pin_obj_t* pin);
+void claim_pin(uint8_t pin_port, uint8_t pin_number);
bool pin_number_is_free(uint8_t pin_port, uint8_t pin_number);
void never_reset_pin_number(uint8_t pin_port, uint8_t pin_number);
GPIO_TypeDef * pin_port(uint8_t pin_port);
diff --git a/ports/stm/common-hal/pulseio/PWMOut.c b/ports/stm/common-hal/pulseio/PWMOut.c
index 304a1539c..ddbadaf4c 100644
--- a/ports/stm/common-hal/pulseio/PWMOut.c
+++ b/ports/stm/common-hal/pulseio/PWMOut.c
@@ -33,7 +33,9 @@
#include "shared-bindings/microcontroller/__init__.h"
#include STM32_HAL_H
-#include "common-hal/microcontroller/Pin.h"
+#include "shared-bindings/microcontroller/Pin.h"
+
+#include "timers.h"
#define ALL_CLOCKS 0xFFFF
@@ -41,32 +43,6 @@ STATIC uint8_t reserved_tim[TIM_BANK_ARRAY_LEN];
STATIC uint32_t tim_frequencies[TIM_BANK_ARRAY_LEN];
STATIC bool never_reset_tim[TIM_BANK_ARRAY_LEN];
-STATIC void tim_clock_enable(uint16_t mask);
-STATIC void tim_clock_disable(uint16_t mask);
-
-// Get the frequency (in Hz) of the source clock for the given timer.
-// On STM32F405/407/415/417 there are 2 cases for how the clock freq is set.
-// If the APB prescaler is 1, then the timer clock is equal to its respective
-// APB clock. Otherwise (APB prescaler > 1) the timer clock is twice its
-// respective APB clock. See DM00031020 Rev 4, page 115.
-STATIC uint32_t timer_get_source_freq(uint32_t tim_id) {
- uint32_t source, clk_div;
- if (tim_id == 1 || (8 <= tim_id && tim_id <= 11)) {
- // TIM{1,8,9,10,11} are on APB2
- source = HAL_RCC_GetPCLK2Freq();
- clk_div = RCC->CFGR & RCC_CFGR_PPRE2;
- } else {
- // TIM{2,3,4,5,6,7,12,13,14} are on APB1
- source = HAL_RCC_GetPCLK1Freq();
- clk_div = RCC->CFGR & RCC_CFGR_PPRE1;
- }
- if (clk_div != 0) {
- // APB prescaler for this timer is > 1
- source *= 2;
- }
- return source;
-}
-
STATIC uint32_t timer_get_internal_duty(uint16_t duty, uint32_t period) {
//duty cycle is duty/0xFFFF fraction x (number of pulses per period)
return (duty*period) / ((1 << 16) - 1);
@@ -97,7 +73,6 @@ void pwmout_reset(void) {
never_reset_mask |= 1 << i;
}
}
- tim_clock_disable(ALL_CLOCKS & ~(never_reset_mask));
}
pwmout_result_t common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self,
@@ -107,6 +82,7 @@ pwmout_result_t common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self,
bool variable_frequency) {
TIM_TypeDef * TIMx;
uint8_t tim_num = MP_ARRAY_SIZE(mcu_tim_pin_list);
+ bool tim_taken_internal = false;
bool tim_chan_taken = false;
bool tim_taken_f_mismatch = false;
bool var_freq_mismatch = false;
@@ -119,8 +95,13 @@ pwmout_result_t common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self,
//if pin is same
if (l_tim->pin == pin) {
- //check if the timer has a channel active
+ //check if the timer has a channel active, or is reserved by main timer system
if (reserved_tim[l_tim_index] != 0) {
+ // Timer has already been reserved by an internal module
+ if (stm_peripherals_timer_is_reserved(mcu_tim_banks[l_tim_index])) {
+ tim_taken_internal = true;
+ continue; //keep looking
+ }
//is it the same channel? (or all channels reserved by a var-freq)
if (reserved_tim[l_tim_index] & 1 << (l_tim_channel)) {
tim_chan_taken = true;
@@ -155,9 +136,12 @@ pwmout_result_t common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self,
reserved_tim[self->tim->tim_index - 1] |= 1 << (self->tim->channel_index - 1);
}
tim_frequencies[self->tim->tim_index - 1] = frequency;
+ stm_peripherals_timer_reserve(TIMx);
} else { //no match found
if (tim_chan_taken) {
mp_raise_ValueError(translate("No more timers available on this pin."));
+ } else if (tim_taken_internal) {
+ mp_raise_ValueError(translate("Timer was reserved for internal use - declare PWM pins earlier in the program"));
} else if (tim_taken_f_mismatch) {
mp_raise_ValueError(translate("Frequency must match existing PWMOut using this timer"));
} else if (var_freq_mismatch) {
@@ -182,8 +166,8 @@ pwmout_result_t common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self,
uint32_t prescaler = 0; //prescaler is 15 bit
uint32_t period = 0; //period is 16 bit
- timer_get_optimal_divisors(&period, &prescaler, frequency,
- timer_get_source_freq(self->tim->tim_index));
+ uint32_t source_freq = stm_peripherals_timer_get_source_freq(TIMx);
+ timer_get_optimal_divisors(&period, &prescaler, frequency, source_freq);
//Timer init
self->handle.Instance = TIMx;
@@ -260,7 +244,7 @@ void common_hal_pulseio_pwmout_deinit(pulseio_pwmout_obj_t* self) {
//if reserved timer has no active channels, we can disable it
if (!reserved_tim[self->tim->tim_index - 1]) {
tim_frequencies[self->tim->tim_index - 1] = 0x00;
- tim_clock_disable(1 << (self->tim->tim_index - 1));
+ stm_peripherals_timer_free(self->handle.Instance);
}
}
@@ -282,8 +266,8 @@ void common_hal_pulseio_pwmout_set_frequency(pulseio_pwmout_obj_t* self, uint32_
uint32_t prescaler = 0;
uint32_t period = 0;
- timer_get_optimal_divisors(&period, &prescaler, frequency,
- timer_get_source_freq(self->tim->tim_index));
+ uint32_t source_freq = stm_peripherals_timer_get_source_freq(self->handle.Instance);
+ timer_get_optimal_divisors(&period, &prescaler, frequency, source_freq);
//shut down
HAL_TIM_PWM_Stop(&self->handle, self->channel);
@@ -318,131 +302,3 @@ uint32_t common_hal_pulseio_pwmout_get_frequency(pulseio_pwmout_obj_t* self) {
bool common_hal_pulseio_pwmout_get_variable_frequency(pulseio_pwmout_obj_t* self) {
return self->variable_frequency;
}
-
-STATIC void tim_clock_enable(uint16_t mask) {
- #ifdef TIM1
- if (mask & (1 << 0)) {
- __HAL_RCC_TIM1_CLK_ENABLE();
- }
- #endif
- #ifdef TIM2
- if (mask & (1 << 1)) {
- __HAL_RCC_TIM2_CLK_ENABLE();
- }
- #endif
- #ifdef TIM3
- if (mask & (1 << 2)) {
- __HAL_RCC_TIM3_CLK_ENABLE();
- }
- #endif
- #ifdef TIM4
- if (mask & (1 << 3)) {
- __HAL_RCC_TIM4_CLK_ENABLE();
- }
- #endif
- #ifdef TIM5
- if (mask & (1 << 4)) {
- __HAL_RCC_TIM5_CLK_ENABLE();
- }
- #endif
- //6 and 7 are reserved ADC timers
- #ifdef TIM8
- if (mask & (1 << 7)) {
- __HAL_RCC_TIM8_CLK_ENABLE();
- }
- #endif
- #ifdef TIM9
- if (mask & (1 << 8)) {
- __HAL_RCC_TIM9_CLK_ENABLE();
- }
- #endif
- #ifdef TIM10
- if (mask & (1 << 9)) {
- __HAL_RCC_TIM10_CLK_ENABLE();
- }
- #endif
- #ifdef TIM11
- if (mask & (1 << 10)) {
- __HAL_RCC_TIM11_CLK_ENABLE();
- }
- #endif
- #ifdef TIM12
- if (mask & (1 << 11)) {
- __HAL_RCC_TIM12_CLK_ENABLE();
- }
- #endif
- #ifdef TIM13
- if (mask & (1 << 12)) {
- __HAL_RCC_TIM13_CLK_ENABLE();
- }
- #endif
- #ifdef TIM14
- if (mask & (1 << 13)) {
- __HAL_RCC_TIM14_CLK_ENABLE();
- }
- #endif
-}
-
-STATIC void tim_clock_disable(uint16_t mask) {
- #ifdef TIM1
- if (mask & (1 << 0)) {
- __HAL_RCC_TIM1_CLK_DISABLE();
- }
- #endif
- #ifdef TIM2
- if (mask & (1 << 1)) {
- __HAL_RCC_TIM2_CLK_DISABLE();
- }
- #endif
- #ifdef TIM3
- if (mask & (1 << 2)) {
- __HAL_RCC_TIM3_CLK_DISABLE();
- }
- #endif
- #ifdef TIM4
- if (mask & (1 << 3)) {
- __HAL_RCC_TIM4_CLK_DISABLE();
- }
- #endif
- #ifdef TIM5
- if (mask & (1 << 4)) {
- __HAL_RCC_TIM5_CLK_DISABLE();
- }
- #endif
- //6 and 7 are reserved ADC timers
- #ifdef TIM8
- if (mask & (1 << 7)) {
- __HAL_RCC_TIM8_CLK_DISABLE();
- }
- #endif
- #ifdef TIM9
- if (mask & (1 << 8)) {
- __HAL_RCC_TIM9_CLK_DISABLE();
- }
- #endif
- #ifdef TIM10
- if (mask & (1 << 9)) {
- __HAL_RCC_TIM10_CLK_DISABLE();
- }
- #endif
- #ifdef TIM11
- if (mask & (1 << 10)) {
- __HAL_RCC_TIM11_CLK_DISABLE();
- }
- #endif
- #ifdef TIM12
- if (mask & (1 << 11)) {
- __HAL_RCC_TIM12_CLK_DISABLE();
- }
- #endif
- #ifdef TIM13
- if (mask & (1 << 12)) {
- __HAL_RCC_TIM13_CLK_DISABLE();
- }
- #endif
- #ifdef TIM14
- if (mask & (1 << 13)) {
- __HAL_RCC_TIM14_CLK_DISABLE();
- }
- #endif
-}
diff --git a/ports/stm/common-hal/pulseio/PulseIn.c b/ports/stm/common-hal/pulseio/PulseIn.c
index 9d82a18a0..4052c240f 100644
--- a/ports/stm/common-hal/pulseio/PulseIn.c
+++ b/ports/stm/common-hal/pulseio/PulseIn.c
@@ -31,40 +31,38 @@
#include "py/gc.h"
#include "py/runtime.h"
#include "shared-bindings/microcontroller/__init__.h"
+#include "shared-bindings/microcontroller/Pin.h"
#include "shared-bindings/pulseio/PulseIn.h"
+#include "timers.h"
#include STM32_HAL_H
#define STM32_GPIO_PORT_SIZE 16
-
static pulseio_pulsein_obj_t* _objs[STM32_GPIO_PORT_SIZE];
-STATIC TIM_HandleTypeDef t6_handle;
+STATIC TIM_HandleTypeDef tim_handle;
static uint32_t overflow_count = 0;
STATIC uint8_t refcount = 0;
static void assign_EXTI_Interrupt(pulseio_pulsein_obj_t* self, uint8_t num);
-void TIM6_IRQHandler(void)
+void pulsein_timer_event_handler(void)
{
// Detect TIM Update event
- if (__HAL_TIM_GET_FLAG(&t6_handle, TIM_FLAG_UPDATE) != RESET)
+ if (__HAL_TIM_GET_FLAG(&tim_handle, TIM_FLAG_UPDATE) != RESET)
{
- if (__HAL_TIM_GET_IT_SOURCE(&t6_handle, TIM_IT_UPDATE) != RESET)
+ if (__HAL_TIM_GET_IT_SOURCE(&tim_handle, TIM_IT_UPDATE) != RESET)
{
- __HAL_TIM_CLEAR_IT(&t6_handle, TIM_IT_UPDATE);
+ __HAL_TIM_CLEAR_IT(&tim_handle, TIM_IT_UPDATE);
overflow_count++;
}
}
}
-static void pulsein_handler(uint8_t num) {
+static void pulsein_exti_event_handler(uint8_t num) {
// Grab the current time first.
uint32_t current_overflow = overflow_count;
- uint32_t current_count = 0;
- #if HAS_BASIC_TIM
- current_count = TIM6->CNT;
- #endif
+ uint32_t current_count = tim_handle.Instance->CNT;
// Interrupt register must be cleared manually
EXTI->PR = 1 << num;
@@ -105,17 +103,14 @@ void pulsein_reset(void) {
}
memset(_objs, 0, sizeof(_objs));
- #if HAS_BASIC_TIM
- __HAL_RCC_TIM6_CLK_DISABLE();
+ HAL_TIM_Base_DeInit(&tim_handle);
+ tim_clock_disable(stm_peripherals_timer_get_index(tim_handle.Instance));
+ memset(&tim_handle, 0, sizeof(tim_handle));
refcount = 0;
- #endif
}
void common_hal_pulseio_pulsein_construct(pulseio_pulsein_obj_t* self, const mcu_pin_obj_t* pin,
uint16_t maxlen, bool idle_state) {
-#if !(HAS_BASIC_TIM)
- mp_raise_NotImplementedError(translate("PulseIn not supported on this chip"));
-#else
// STM32 has one shared EXTI for each pin number, 0-15
uint8_t p_num = pin->number;
if(_objs[p_num]) {
@@ -141,24 +136,34 @@ void common_hal_pulseio_pulsein_construct(pulseio_pulsein_obj_t* self, const mcu
self->last_count = 0;
self->last_overflow = 0;
- if (HAL_TIM_Base_GetState(&t6_handle) == HAL_TIM_STATE_RESET) {
- // Set the new period
- t6_handle.Instance = TIM6;
- t6_handle.Init.Prescaler = 168; // HCLK is 168 mhz so divide down to 1mhz
- t6_handle.Init.Period = 0xffff;
- HAL_TIM_Base_Init(&t6_handle);
+ if (HAL_TIM_Base_GetState(&tim_handle) == HAL_TIM_STATE_RESET) {
+ // Find a suitable timer
+ TIM_TypeDef * tim_instance = stm_peripherals_find_timer();
+ stm_peripherals_timer_reserve(tim_instance);
+
+ // Set ticks to 1us
+ uint32_t source = stm_peripherals_timer_get_source_freq(tim_instance);
+ uint32_t prescaler = source/1000000;
+
+ // Enable clocks and IRQ, set callback
+ stm_peripherals_timer_preinit(tim_instance, 4, pulsein_timer_event_handler);
- // TIM6 has limited HAL support, set registers manually
- t6_handle.Instance->SR = 0; // Prevent the SR from triggering an interrupt
- t6_handle.Instance->CR1 |= TIM_CR1_CEN; // Resume timer
- t6_handle.Instance->CR1 |= TIM_CR1_URS; // Disable non-overflow interrupts
- __HAL_TIM_ENABLE_IT(&t6_handle, TIM_IT_UPDATE);
+ // Set the new period
+ tim_handle.Instance = tim_instance;
+ tim_handle.Init.Prescaler = prescaler - 1;
+ tim_handle.Init.Period = 0x10000 - 1; //65 ms period (maximum)
+ HAL_TIM_Base_Init(&tim_handle);
+
+ // Set registers manually
+ tim_handle.Instance->SR = 0; // Prevent the SR from triggering an interrupt
+ tim_handle.Instance->CR1 |= TIM_CR1_CEN; // Resume timer
+ tim_handle.Instance->CR1 |= TIM_CR1_URS; // Disable non-overflow interrupts
+ __HAL_TIM_ENABLE_IT(&tim_handle, TIM_IT_UPDATE);
overflow_count = 0;
}
// Add to active PulseIns
refcount++;
-#endif
// EXTI pins can also be read as an input
GPIO_InitTypeDef GPIO_InitStruct = {0};
@@ -170,7 +175,7 @@ void common_hal_pulseio_pulsein_construct(pulseio_pulsein_obj_t* self, const mcu
// Interrupt starts immediately
assign_EXTI_Interrupt(self, pin->number);
HAL_NVIC_EnableIRQ(self->irq);
- claim_pin(pin);
+ common_hal_mcu_pin_claim(pin);
}
bool common_hal_pulseio_pulsein_deinited(pulseio_pulsein_obj_t* self) {
@@ -182,16 +187,13 @@ void common_hal_pulseio_pulsein_deinit(pulseio_pulsein_obj_t* self) {
return;
}
//Remove pulsein slot from shared array
- HAL_NVIC_DisableIRQ(self->irq);
_objs[self->pin->number] = NULL;
reset_pin_number(self->pin->port, self->pin->number);
self->pin = NULL;
refcount--;
if (refcount == 0) {
- #if HAS_BASIC_TIM
- __HAL_RCC_TIM6_CLK_DISABLE();
- #endif
+ stm_peripherals_timer_free(tim_handle.Instance);
}
}
@@ -299,23 +301,23 @@ static void assign_EXTI_Interrupt(pulseio_pulsein_obj_t* self, uint8_t num) {
void EXTI0_IRQHandler(void)
{
- pulsein_handler(0);
+ pulsein_exti_event_handler(0);
}
void EXTI1_IRQHandler(void)
{
- pulsein_handler(1);
+ pulsein_exti_event_handler(1);
}
void EXTI2_IRQHandler(void)
{
- pulsein_handler(2);
+ pulsein_exti_event_handler(2);
}
void EXTI3_IRQHandler(void)
{
- pulsein_handler(3);
+ pulsein_exti_event_handler(3);
}
void EXTI4_IRQHandler(void)
{
- pulsein_handler(4);
+ pulsein_exti_event_handler(4);
}
void EXTI9_5_IRQHandler(void)
@@ -323,7 +325,7 @@ void EXTI9_5_IRQHandler(void)
uint32_t pending = EXTI->PR;
for (uint i = 5; i <= 9; i++) {
if(pending & (1 << i)) {
- pulsein_handler(i);
+ pulsein_exti_event_handler(i);
}
}
}
@@ -333,7 +335,7 @@ void EXTI15_10_IRQHandler(void)
uint32_t pending = EXTI->PR;
for (uint i = 10; i <= 15; i++) {
if(pending & (1 << i)) {
- pulsein_handler(i);
+ pulsein_exti_event_handler(i);
}
}
}
diff --git a/ports/stm/common-hal/pulseio/PulseOut.c b/ports/stm/common-hal/pulseio/PulseOut.c
index c7c879c88..bcc25d817 100644
--- a/ports/stm/common-hal/pulseio/PulseOut.c
+++ b/ports/stm/common-hal/pulseio/PulseOut.c
@@ -36,20 +36,20 @@
#include "supervisor/shared/translate.h"
#include STM32_HAL_H
-#include "common-hal/microcontroller/Pin.h"
+#include "shared-bindings/microcontroller/Pin.h"
+#include "timers.h"
// A single timer is shared amongst all PulseOut objects under the assumption that
// the code is single threaded.
STATIC uint8_t refcount = 0;
-
STATIC uint16_t *pulse_array = NULL;
STATIC volatile uint16_t pulse_array_index = 0;
STATIC uint16_t pulse_array_length;
-
//Timer is shared, must be accessible by interrupt
-STATIC TIM_HandleTypeDef t7_handle;
+STATIC TIM_HandleTypeDef tim_handle;
pulseio_pulseout_obj_t *curr_pulseout = NULL;
+
STATIC void turn_on(pulseio_pulseout_obj_t *pulseout) {
// Turn on PWM
HAL_TIM_PWM_Start(&(pulseout->pwmout->handle), pulseout->pwmout->channel);
@@ -65,91 +65,78 @@ STATIC void turn_off(pulseio_pulseout_obj_t *pulseout) {
STATIC void start_timer(void) {
// Set the new period
- t7_handle.Init.Period = pulse_array[pulse_array_index] - 1;
- HAL_TIM_Base_Init(&t7_handle);
+ tim_handle.Init.Period = pulse_array[pulse_array_index] - 1;
+ HAL_TIM_Base_Init(&tim_handle);
// TIM7 has limited HAL support, set registers manually
- t7_handle.Instance->SR = 0; // Prevent the SR from triggering an interrupt
- t7_handle.Instance->CR1 |= TIM_CR1_CEN; // Resume timer
- t7_handle.Instance->CR1 |= TIM_CR1_URS; // Disable non-overflow interrupts
- __HAL_TIM_ENABLE_IT(&t7_handle, TIM_IT_UPDATE);
-
+ tim_handle.Instance->SR = 0; // Prevent the SR from triggering an interrupt
+ tim_handle.Instance->CR1 |= TIM_CR1_CEN; // Resume timer
+ tim_handle.Instance->CR1 |= TIM_CR1_URS; // Disable non-overflow interrupts
+ __HAL_TIM_ENABLE_IT(&tim_handle, TIM_IT_UPDATE);
}
STATIC void pulseout_event_handler(void) {
- if (curr_pulseout->pwmout == NULL) {
- return; //invalid interrupt
- }
-
- HAL_GPIO_WritePin(pin_port(2),pin_mask(6), 1);
- HAL_GPIO_WritePin(pin_port(2),pin_mask(6), 0);
-
- pulse_array_index++;
-
- // No more pulses. Turn off output and don't restart.
- if (pulse_array_index >= pulse_array_length) {
- turn_off(curr_pulseout);
- return;
- }
-
- // Alternate on and off, starting with on.
- if (pulse_array_index % 2 == 0) {
- turn_on(curr_pulseout);
- } else {
- turn_off(curr_pulseout);
+ // Detect TIM Update event
+ if (__HAL_TIM_GET_FLAG(&tim_handle, TIM_FLAG_UPDATE) != RESET)
+ {
+ if (__HAL_TIM_GET_IT_SOURCE(&tim_handle, TIM_IT_UPDATE) != RESET)
+ {
+ __HAL_TIM_CLEAR_IT(&tim_handle, TIM_IT_UPDATE);
+ if (curr_pulseout->pwmout == NULL) {
+ return; //invalid interrupt
+ }
+
+ pulse_array_index++;
+
+ // No more pulses. Turn off output and don't restart.
+ if (pulse_array_index >= pulse_array_length) {
+ turn_off(curr_pulseout);
+ return;
+ }
+
+ // Alternate on and off, starting with on.
+ if (pulse_array_index % 2 == 0) {
+ turn_on(curr_pulseout);
+ } else {
+ turn_off(curr_pulseout);
+ }
+
+ // Count up to the next given value.
+ start_timer();
+ }
}
-
- // Count up to the next given value.
- start_timer();
}
void pulseout_reset() {
- #if HAS_BASIC_TIM
- __HAL_RCC_TIM7_CLK_DISABLE();
+ stm_peripherals_timer_free(tim_handle.Instance);
refcount = 0;
- #endif
}
void common_hal_pulseio_pulseout_construct(pulseio_pulseout_obj_t* self,
const pulseio_pwmout_obj_t* carrier) {
-#if !(HAS_BASIC_TIM)
- mp_raise_NotImplementedError(translate("PulseOut not supported on this chip"));
-#else
// Add to active PulseOuts
refcount++;
+ TIM_TypeDef * tim_instance = stm_peripherals_find_timer();
+ stm_peripherals_timer_reserve(tim_instance);
- // Calculate a 1 ms period
- uint32_t source, clk_div;
- source = HAL_RCC_GetPCLK1Freq(); // TIM7 is on APB1
- clk_div = RCC->CFGR & RCC_CFGR_PPRE1;
- // APB quirk, see See DM00031020 Rev 4, page 115.
- if (clk_div != 0) {
- // APB prescaler for this timer is > 1
- source *= 2;
- }
-
+ //calculate a 1ms period
+ uint32_t source = stm_peripherals_timer_get_source_freq(tim_instance);
uint32_t prescaler = source/1000000; //1us intervals
- __HAL_RCC_TIM7_CLK_ENABLE();
- HAL_NVIC_SetPriority(TIM7_IRQn, 4, 0);
- HAL_NVIC_EnableIRQ(TIM7_IRQn);
-
- // Timers 6 and 7 have no pins, so using them doesn't affect PWM availability
- t7_handle.Instance = TIM7;
- t7_handle.Init.Period = 100; //immediately replaced.
- t7_handle.Init.Prescaler = prescaler - 1;
- t7_handle.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
- t7_handle.Init.CounterMode = TIM_COUNTERMODE_UP;
- t7_handle.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
+ stm_peripherals_timer_preinit(tim_instance, 4, pulseout_event_handler);
+ tim_handle.Instance = tim_instance;
+ tim_handle.Init.Period = 100; //immediately replaced.
+ tim_handle.Init.Prescaler = prescaler - 1;
+ tim_handle.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
+ tim_handle.Init.CounterMode = TIM_COUNTERMODE_UP;
+ tim_handle.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
- HAL_TIM_Base_Init(&t7_handle);
- t7_handle.Instance->SR = 0;
+ HAL_TIM_Base_Init(&tim_handle);
+ tim_handle.Instance->SR = 0;
// The HAL can't work with const, recast required.
self->pwmout = (pulseio_pwmout_obj_t*)carrier;
-
turn_off(self);
-#endif
}
bool common_hal_pulseio_pulseout_deinited(pulseio_pulseout_obj_t* self) {
@@ -165,9 +152,7 @@ void common_hal_pulseio_pulseout_deinit(pulseio_pulseout_obj_t* self) {
refcount--;
if (refcount == 0) {
- #if HAS_BASIC_TIM
- __HAL_RCC_TIM7_CLK_DISABLE();
- #endif
+ stm_peripherals_timer_free(tim_handle.Instance);
}
}
@@ -190,24 +175,11 @@ void common_hal_pulseio_pulseout_send(pulseio_pulseout_obj_t* self, uint16_t* pu
// signal.
RUN_BACKGROUND_TASKS;
- // Use when debugging, or issues are irrecoverable
+ // // Use when debugging, or issues are irrecoverable
// if ((supervisor_ticks_ms64() - starttime ) > timeout ) {
// mp_raise_RuntimeError(translate("Error: Send Timeout"));
// }
}
//turn off timer counter.
- t7_handle.Instance->CR1 &= ~TIM_CR1_CEN;
-}
-
-void TIM7_IRQHandler(void)
-{
- // Detect TIM Update event
- if (__HAL_TIM_GET_FLAG(&t7_handle, TIM_FLAG_UPDATE) != RESET)
- {
- if (__HAL_TIM_GET_IT_SOURCE(&t7_handle, TIM_IT_UPDATE) != RESET)
- {
- __HAL_TIM_CLEAR_IT(&t7_handle, TIM_IT_UPDATE);
- pulseout_event_handler();
- }
- }
+ tim_handle.Instance->CR1 &= ~TIM_CR1_CEN;
}
diff --git a/ports/stm/common-hal/rgbmatrix/RGBMatrix.c b/ports/stm/common-hal/rgbmatrix/RGBMatrix.c
index 9e60cc3e6..3b42631ad 100644
--- a/ports/stm/common-hal/rgbmatrix/RGBMatrix.c
+++ b/ports/stm/common-hal/rgbmatrix/RGBMatrix.c
@@ -27,28 +27,30 @@
#include <stddef.h>
#include "common-hal/rgbmatrix/RGBMatrix.h"
+#include "timers.h"
#include STM32_HAL_H
extern void _PM_IRQ_HANDLER(void);
void *common_hal_rgbmatrix_timer_allocate() {
- // TODO(jepler) properly handle resource allocation including never-reset
- return TIM6;
+ TIM_TypeDef * timer = stm_peripherals_find_timer();
+ stm_peripherals_timer_reserve(timer);
+ return timer;
}
-
void common_hal_rgbmatrix_timer_enable(void* ptr) {
- HAL_NVIC_EnableIRQ(TIM6_DAC_IRQn);
+ TIM_TypeDef *tim = (TIM_TypeDef*)ptr;
+ HAL_NVIC_EnableIRQ(stm_peripherals_timer_get_irqnum(tim));
}
void common_hal_rgbmatrix_timer_disable(void* ptr) {
TIM_TypeDef *tim = (TIM_TypeDef*)ptr;
tim->DIER &= ~TIM_DIER_UIE;
- HAL_NVIC_DisableIRQ(TIM6_DAC_IRQn);
}
void common_hal_rgbmatrix_timer_free(void* ptr) {
+ TIM_TypeDef *tim = (TIM_TypeDef*)ptr;
+ stm_peripherals_timer_free(tim);
common_hal_rgbmatrix_timer_disable(ptr);
- // TODO(jepler) properly handle resource allocation including never-reset
}
diff --git a/ports/stm/peripherals/stm32f4/stm32f405xx/periph.c b/ports/stm/peripherals/stm32f4/stm32f405xx/periph.c
index e75f0b206..e2124bc30 100644
--- a/ports/stm/peripherals/stm32f4/stm32f405xx/periph.c
+++ b/ports/stm/peripherals/stm32f4/stm32f405xx/periph.c
@@ -29,55 +29,57 @@
#include "peripherals/pins.h"
#include "peripherals/periph.h"
-// I2C
+I2C_TypeDef * mcu_i2c_banks[I2C_BANK_ARRAY_LEN] = {I2C1, I2C2, I2C3};
-I2C_TypeDef * mcu_i2c_banks[3] = {I2C1, I2C2, I2C3};
-
-const mcu_periph_obj_t mcu_i2c_sda_list[4] = {
+const mcu_periph_obj_t mcu_i2c_sda_list[I2C_SDA_ARRAY_LEN] = {
PERIPH(1, 4, &pin_PB07),
PERIPH(1, 4, &pin_PB09),
PERIPH(2, 4, &pin_PB11),
PERIPH(3, 4, &pin_PC09),
+ PERIPH(2, 4, &pin_PF00),
+ PERIPH(2, 4, &pin_PH05),
+ PERIPH(3, 4, &pin_PH08),
};
-
-const mcu_periph_obj_t mcu_i2c_scl_list[4] = {
+const mcu_periph_obj_t mcu_i2c_scl_list[I2C_SCL_ARRAY_LEN] = {
+ PERIPH(3, 4, &pin_PA08),
PERIPH(1, 4, &pin_PB06),
PERIPH(1, 4, &pin_PB08),
PERIPH(2, 4, &pin_PB10),
- PERIPH(3, 4, &pin_PA08)
+ PERIPH(2, 4, &pin_PF01),
+ PERIPH(2, 4, &pin_PH04),
+ PERIPH(3, 4, &pin_PH07),
};
-SPI_TypeDef * mcu_spi_banks[3] = {SPI1, SPI2, SPI3};
+SPI_TypeDef * mcu_spi_banks[SPI_BANK_ARRAY_LEN] = {SPI1, SPI2, SPI3};
-const mcu_periph_obj_t mcu_spi_sck_list[7] = {
+const mcu_periph_obj_t mcu_spi_sck_list[SPI_SCK_ARRAY_LEN] = {
PERIPH(1, 5, &pin_PA05),
PERIPH(1, 5, &pin_PB03),
+ PERIPH(3, 6, &pin_PB03),
PERIPH(2, 5, &pin_PB10),
PERIPH(2, 5, &pin_PB13),
- PERIPH(2, 5, &pin_PC07),
- PERIPH(3, 6, &pin_PB03),
PERIPH(3, 6, &pin_PC10),
+ PERIPH(2, 5, &pin_PI01),
};
-
-const mcu_periph_obj_t mcu_spi_mosi_list[6] = {
+const mcu_periph_obj_t mcu_spi_mosi_list[SPI_MOSI_ARRAY_LEN] = {
PERIPH(1, 5, &pin_PA07),
PERIPH(1, 5, &pin_PB05),
+ PERIPH(3, 6, &pin_PB05),
PERIPH(2, 5, &pin_PB15),
PERIPH(2, 5, &pin_PC03),
- PERIPH(3, 6, &pin_PB05),
PERIPH(3, 6, &pin_PC12),
+ PERIPH(2, 5, &pin_PI03),
};
-
-const mcu_periph_obj_t mcu_spi_miso_list[6] = {
+const mcu_periph_obj_t mcu_spi_miso_list[SPI_MISO_ARRAY_LEN] = {
PERIPH(1, 5, &pin_PA06),
PERIPH(1, 5, &pin_PB04),
+ PERIPH(3, 6, &pin_PB04),
PERIPH(2, 5, &pin_PB14),
PERIPH(2, 5, &pin_PC02),
- PERIPH(3, 6, &pin_PB04),
PERIPH(3, 6, &pin_PC11),
+ PERIPH(2, 5, &pin_PI02),
};
-
-const mcu_periph_obj_t mcu_spi_nss_list[6] = {
+const mcu_periph_obj_t mcu_spi_nss_list[SPI_NSS_ARRAY_LEN] = {
PERIPH(1, 5, &pin_PA04),
PERIPH(1, 5, &pin_PA15),
PERIPH(2, 5, &pin_PB09),
@@ -89,7 +91,7 @@ const mcu_periph_obj_t mcu_spi_nss_list[6] = {
USART_TypeDef * mcu_uart_banks[MAX_UART] = {USART1, USART2, USART3, UART4, UART5, USART6};
bool mcu_uart_has_usart[MAX_UART] = {true, true, true, false, false, true};
-const mcu_periph_obj_t mcu_uart_tx_list[12] = {
+const mcu_periph_obj_t mcu_uart_tx_list[UART_TX_ARRAY_LEN] = {
PERIPH(4, 8, &pin_PA00),
PERIPH(2, 7, &pin_PA02),
PERIPH(1, 7, &pin_PA09),
@@ -103,8 +105,7 @@ const mcu_periph_obj_t mcu_uart_tx_list[12] = {
PERIPH(3, 7, &pin_PD08),
PERIPH(6, 8, &pin_PG14),
};
-
-const mcu_periph_obj_t mcu_uart_rx_list[12] = {
+const mcu_periph_obj_t mcu_uart_rx_list[UART_RX_ARRAY_LEN] = {
PERIPH(4, 8, &pin_PA01),
PERIPH(2, 7, &pin_PA03),
PERIPH(1, 7, &pin_PA10),
@@ -121,74 +122,75 @@ const mcu_periph_obj_t mcu_uart_rx_list[12] = {
//Timers
//TIM6 and TIM7 are basic timers that are only used by DAC, and don't have pins
-TIM_TypeDef * mcu_tim_banks[14] = {TIM1, TIM2, TIM3, TIM4, TIM5, NULL, NULL, TIM8, TIM9, TIM10,
+TIM_TypeDef * mcu_tim_banks[TIM_BANK_ARRAY_LEN] = {TIM1, TIM2, TIM3, TIM4, TIM5, NULL, NULL, TIM8, TIM9, TIM10,
TIM11, TIM12, TIM13, TIM14};
-const mcu_tim_pin_obj_t mcu_tim_pin_list[56] = {
- 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(2,1,4,&pin_PA03),
- TIM(5,2,4,&pin_PA03),
- TIM(9,3,1,&pin_PA02),
- TIM(9,3,2,&pin_PA03),
- TIM(3,2,1,&pin_PA06),
- TIM(13,9,1,&pin_PA06),
- TIM(3,2,2,&pin_PA07),
- TIM(14,9,1,&pin_PA07),
- 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(10,2,1,&pin_PB08),
- TIM(4,2,4,&pin_PB09),
- TIM(11,2,1,&pin_PB09),
- TIM(2,1,3,&pin_PB10),
- TIM(2,1,4,&pin_PB11),
- TIM(12,9,1,&pin_PB14),
- TIM(12,9,2,&pin_PB15),
- TIM(3,2,1,&pin_PC06),
- TIM(3,2,2,&pin_PC07),
- TIM(3,2,3,&pin_PC08),
- TIM(3,2,4,&pin_PC09),
- TIM(8,3,1,&pin_PC06),
- TIM(8,3,2,&pin_PC07),
- TIM(8,3,3,&pin_PC08),
- 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(9,3,1,&pin_PE05),
- TIM(9,3,2,&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(10,3,1,&pin_PF06),
- TIM(11,3,1,&pin_PF07),
- TIM(13,9,1,&pin_PF08),
- TIM(14,9,1,&pin_PF09),
- // TIM(12,9,1,&pin_PH06), //TODO: include these when pin map is expanded
- // TIM(12,9,2,&pin_PH09),
- // 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),
+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(9, 3, 1, &pin_PA02),
+ TIM(2, 1, 4, &pin_PA03),
+ TIM(5, 2, 4, &pin_PA03),
+ TIM(9, 3, 2, &pin_PA03),
+ TIM(2, 1, 1, &pin_PA05),
+ TIM(3, 2, 1, &pin_PA06),
+ TIM(13, 9, 1, &pin_PA06),
+ TIM(3, 2, 2, &pin_PA07),
+ TIM(14, 9, 1, &pin_PA07),
+ 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(10, 3, 1, &pin_PB08),
+ TIM(4, 2, 4, &pin_PB09),
+ TIM(11, 3, 1, &pin_PB09),
+ TIM(2, 1, 3, &pin_PB10),
+ TIM(2, 1, 4, &pin_PB11),
+ TIM(12, 9, 1, &pin_PB14),
+ TIM(12, 9, 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(9, 3, 1, &pin_PE05),
+ TIM(9, 3, 2, &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(10, 3, 1, &pin_PF06),
+ TIM(11, 3, 1, &pin_PF07),
+ TIM(13, 9, 1, &pin_PF08),
+ TIM(14, 9, 1, &pin_PF09),
+ TIM(12, 9, 1, &pin_PH06),
+ TIM(12, 9, 2, &pin_PH09),
+ 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),
};
diff --git a/ports/stm/peripherals/stm32f4/stm32f405xx/periph.h b/ports/stm/peripherals/stm32f4/stm32f405xx/periph.h
index df67a99d7..e52568c85 100644
--- a/ports/stm/peripherals/stm32f4/stm32f405xx/periph.h
+++ b/ports/stm/peripherals/stm32f4/stm32f405xx/periph.h
@@ -28,29 +28,36 @@
#define MICROPY_INCLUDED_STM32_PERIPHERALS_STM32F405XX_PERIPH_H
//I2C
-extern I2C_TypeDef * mcu_i2c_banks[3];
-
-extern const mcu_periph_obj_t mcu_i2c_sda_list[4];
-extern const mcu_periph_obj_t mcu_i2c_scl_list[4];
+#define I2C_BANK_ARRAY_LEN 3
+#define I2C_SDA_ARRAY_LEN 7
+#define I2C_SCL_ARRAY_LEN 7
+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
-extern SPI_TypeDef * mcu_spi_banks[3];
-
-extern const mcu_periph_obj_t mcu_spi_sck_list[7];
-extern const mcu_periph_obj_t mcu_spi_mosi_list[6];
-extern const mcu_periph_obj_t mcu_spi_miso_list[6];
-extern const mcu_periph_obj_t mcu_spi_nss_list[6];
+#define SPI_BANK_ARRAY_LEN 3
+#define SPI_SCK_ARRAY_LEN 7
+#define SPI_MOSI_ARRAY_LEN 7
+#define SPI_MISO_ARRAY_LEN 7
+#define SPI_NSS_ARRAY_LEN 6
+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 12
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[12];
-extern const mcu_periph_obj_t mcu_uart_rx_list[12];
+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 14
-#define TIM_PIN_ARRAY_LEN 56
+#define TIM_PIN_ARRAY_LEN 67
TIM_TypeDef * mcu_tim_banks[TIM_BANK_ARRAY_LEN];
const mcu_tim_pin_obj_t mcu_tim_pin_list[TIM_PIN_ARRAY_LEN];
diff --git a/ports/stm/peripherals/stm32f4/stm32f405xx/pins.c b/ports/stm/peripherals/stm32f4/stm32f405xx/pins.c
index 4282741a8..62acb1955 100644
--- a/ports/stm/peripherals/stm32f4/stm32f405xx/pins.c
+++ b/ports/stm/peripherals/stm32f4/stm32f405xx/pins.c
@@ -28,33 +28,6 @@
#include "py/mphal.h"
#include "peripherals/pins.h"
-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_PC13 = PIN(2, 13, NO_ADC); //anti-tamp
-const mcu_pin_obj_t pin_PC14 = PIN(2, 14, NO_ADC); //OSC32_IN
-const mcu_pin_obj_t pin_PC15 = PIN(2, 15, NO_ADC); //OSC32_OUT
-
-const mcu_pin_obj_t pin_PF00 = PIN(5, 0, NO_ADC); // 144 only
-const mcu_pin_obj_t pin_PF01 = PIN(5, 1, NO_ADC); // 144 only
-const mcu_pin_obj_t pin_PF02 = PIN(5, 2, NO_ADC); // 144 only
-const mcu_pin_obj_t pin_PF03 = PIN(5, 3, ADC_INPUT(ADC_3,9)); // 144 only
-const mcu_pin_obj_t pin_PF04 = PIN(5, 4, ADC_INPUT(ADC_3,14)); // 144 only
-const mcu_pin_obj_t pin_PF05 = PIN(5, 5, ADC_INPUT(ADC_3,15)); // 144 only
-const mcu_pin_obj_t pin_PF06 = PIN(5, 6, ADC_INPUT(ADC_3,4)); // 144 only
-const mcu_pin_obj_t pin_PF07 = PIN(5, 7, ADC_INPUT(ADC_3,5)); // 144 only
-const mcu_pin_obj_t pin_PF08 = PIN(5, 8, ADC_INPUT(ADC_3,6)); // 144 only
-const mcu_pin_obj_t pin_PF09 = PIN(5, 9, ADC_INPUT(ADC_3,7)); // 144 only
-const mcu_pin_obj_t pin_PF10 = PIN(5, 10, ADC_INPUT(ADC_3,8)); // 144 only
-
-const mcu_pin_obj_t pin_PC00 = PIN(2, 0, ADC_INPUT(ADC_123,10));
-const mcu_pin_obj_t pin_PC01 = PIN(2, 1, ADC_INPUT(ADC_123,11));
-const mcu_pin_obj_t pin_PC02 = PIN(2, 2, ADC_INPUT(ADC_123,12));
-const mcu_pin_obj_t pin_PC03 = PIN(2, 3, ADC_INPUT(ADC_123,13));
-
const mcu_pin_obj_t pin_PA00 = PIN(0, 0, ADC_INPUT(ADC_123,0));
const mcu_pin_obj_t pin_PA01 = PIN(0, 1, ADC_INPUT(ADC_123,1));
const mcu_pin_obj_t pin_PA02 = PIN(0, 2, ADC_INPUT(ADC_123,2));
@@ -63,75 +36,46 @@ const mcu_pin_obj_t pin_PA04 = PIN(0, 4, ADC_INPUT(ADC_12,4));
const mcu_pin_obj_t pin_PA05 = PIN(0, 5, ADC_INPUT(ADC_12,5));
const mcu_pin_obj_t pin_PA06 = PIN(0, 6, ADC_INPUT(ADC_12,6));
const mcu_pin_obj_t pin_PA07 = PIN(0, 7, ADC_INPUT(ADC_12,7));
-
-const mcu_pin_obj_t pin_PC04 = PIN(2, 4, ADC_INPUT(ADC_12,14));
-const mcu_pin_obj_t pin_PC05 = PIN(2, 5, ADC_INPUT(ADC_12,15));
-
+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_12,8));
const mcu_pin_obj_t pin_PB01 = PIN(1, 1, ADC_INPUT(ADC_12,9));
-const mcu_pin_obj_t pin_PB02 = PIN(1, 2, NO_ADC); //BOOT1
-
-const mcu_pin_obj_t pin_PF11 = PIN(5, 11, NO_ADC); // 144 only
-const mcu_pin_obj_t pin_PF12 = PIN(5, 12, NO_ADC); // 144 only
-const mcu_pin_obj_t pin_PF13 = PIN(5, 13, NO_ADC); // 144 only
-const mcu_pin_obj_t pin_PF14 = PIN(5, 14, NO_ADC); // 144 only
-const mcu_pin_obj_t pin_PF15 = PIN(5, 15, NO_ADC); // 144 only
-
-const mcu_pin_obj_t pin_PG00 = PIN(6, 0, NO_ADC); // 144 only
-const mcu_pin_obj_t pin_PG01 = PIN(6, 1, NO_ADC); // 144 only
-
-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_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_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_PG02 = PIN(6, 2, NO_ADC); // 144 only
-const mcu_pin_obj_t pin_PG03 = PIN(6, 3, NO_ADC); // 144 only
-const mcu_pin_obj_t pin_PG04 = PIN(6, 4, NO_ADC); // 144 only
-const mcu_pin_obj_t pin_PG05 = PIN(6, 5, NO_ADC); // 144 only
-const mcu_pin_obj_t pin_PG06 = PIN(6, 6, NO_ADC); // 144 only
-const mcu_pin_obj_t pin_PG07 = PIN(6, 7, NO_ADC); // 144 only
-const mcu_pin_obj_t pin_PG08 = PIN(6, 8, NO_ADC); // 144 only
-
+const mcu_pin_obj_t pin_PC00 = PIN(2, 0, ADC_INPUT(ADC_123,10));
+const mcu_pin_obj_t pin_PC01 = PIN(2, 1, ADC_INPUT(ADC_123,11));
+const mcu_pin_obj_t pin_PC02 = PIN(2, 2, ADC_INPUT(ADC_123,12));
+const mcu_pin_obj_t pin_PC03 = PIN(2, 3, ADC_INPUT(ADC_123,13));
+const mcu_pin_obj_t pin_PC04 = PIN(2, 4, ADC_INPUT(ADC_12,14));
+const mcu_pin_obj_t pin_PC05 = PIN(2, 5, ADC_INPUT(ADC_12,15));
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_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_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);
@@ -140,22 +84,87 @@ 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_PG09 = PIN(6, 9, NO_ADC); // 144 only
-const mcu_pin_obj_t pin_PG10 = PIN(6, 10, NO_ADC); // 144 only
-const mcu_pin_obj_t pin_PG11 = PIN(6, 11, NO_ADC); // 144 only
-const mcu_pin_obj_t pin_PG12 = PIN(6, 12, NO_ADC); // 144 only
-const mcu_pin_obj_t pin_PG13 = PIN(6, 13, NO_ADC); // 144 only
-const mcu_pin_obj_t pin_PG14 = PIN(6, 14, NO_ADC); // 144 only
-const mcu_pin_obj_t pin_PG15 = PIN(6, 15, NO_ADC); // 144 only
-
-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_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, ADC_INPUT(ADC_3,9));
+const mcu_pin_obj_t pin_PF04 = PIN(5, 4, ADC_INPUT(ADC_3,14));
+const mcu_pin_obj_t pin_PF05 = PIN(5, 5, ADC_INPUT(ADC_3,15));
+const mcu_pin_obj_t pin_PF06 = PIN(5, 6, ADC_INPUT(ADC_3,4));
+const mcu_pin_obj_t pin_PF07 = PIN(5, 7, ADC_INPUT(ADC_3,5));
+const mcu_pin_obj_t pin_PF08 = PIN(5, 8, ADC_INPUT(ADC_3,6));
+const mcu_pin_obj_t pin_PF09 = PIN(5, 9, ADC_INPUT(ADC_3,7));
+const mcu_pin_obj_t pin_PF10 = PIN(5, 10, ADC_INPUT(ADC_3,8));
+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/stm32f4/stm32f405xx/pins.h b/ports/stm/peripherals/stm32f4/stm32f405xx/pins.h
index e722b6e5a..fe0eb9e53 100644
--- a/ports/stm/peripherals/stm32f4/stm32f405xx/pins.h
+++ b/ports/stm/peripherals/stm32f4/stm32f405xx/pins.h
@@ -27,107 +27,54 @@
#ifndef MICROPY_INCLUDED_STM32_PERIPHERALS_STM32F405XX_PINS_H
#define MICROPY_INCLUDED_STM32_PERIPHERALS_STM32F405XX_PINS_H
-//Pins in datasheet order: DocID028087 Rev 7 page 50. LQFP100 only
-//pg 50
-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_PC13;
-extern const mcu_pin_obj_t pin_PC14;
-//pg 51
-extern const mcu_pin_obj_t pin_PC15;
-extern const mcu_pin_obj_t pin_PF00; // 144 only
-extern const mcu_pin_obj_t pin_PF01; // 144 only
-extern const mcu_pin_obj_t pin_PF02; // 144 only
-extern const mcu_pin_obj_t pin_PF03; // 144 only
-extern const mcu_pin_obj_t pin_PF04; // 144 only
-extern const mcu_pin_obj_t pin_PF05; // 144 only
-extern const mcu_pin_obj_t pin_PF06; // 144 only
-extern const mcu_pin_obj_t pin_PF07; // 144 only
-extern const mcu_pin_obj_t pin_PF08; // 144 only
-extern const mcu_pin_obj_t pin_PF09; // 144 only
-extern const mcu_pin_obj_t pin_PF10; // 144 only
-//pg 52
-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_PA00;
extern const mcu_pin_obj_t pin_PA01;
extern const mcu_pin_obj_t pin_PA02;
-//pg 53
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_PC04;
-//pg 54
-extern const mcu_pin_obj_t pin_PC05;
+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_PF11; // 144 only
-extern const mcu_pin_obj_t pin_PF12; // 144 only
-extern const mcu_pin_obj_t pin_PF13; // 144 only
-extern const mcu_pin_obj_t pin_PF14; // 144 only
-extern const mcu_pin_obj_t pin_PF15; // 144 only
-extern const mcu_pin_obj_t pin_PG00; // 144 only
-extern const mcu_pin_obj_t pin_PG01; // 144 only
-//pg 55
-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;
-//pg 56
-extern const mcu_pin_obj_t pin_PE15;
+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; // 144 only
+extern const mcu_pin_obj_t pin_PB11;
extern const mcu_pin_obj_t pin_PB12;
extern const mcu_pin_obj_t pin_PB13;
-//pg 57
extern const mcu_pin_obj_t pin_PB14;
extern const mcu_pin_obj_t pin_PB15;
-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;
-//pg 58
-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_PG02; // 144 only
-extern const mcu_pin_obj_t pin_PG03; // 144 only
-extern const mcu_pin_obj_t pin_PG04; // 144 only
-extern const mcu_pin_obj_t pin_PG05; // 144 only
-extern const mcu_pin_obj_t pin_PG06; // 144 only
-extern const mcu_pin_obj_t pin_PG07; // 144 only
-extern const mcu_pin_obj_t pin_PG08; // 144 only
-//pg 59
+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_PA08;
-extern const mcu_pin_obj_t pin_PA09;
-extern const mcu_pin_obj_t pin_PA10;
-//pg 60
-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_PC10;
extern const mcu_pin_obj_t pin_PC11;
-//pg 61
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;
@@ -136,23 +83,89 @@ 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;
-//pg 62
-extern const mcu_pin_obj_t pin_PG09; // 144 only
-extern const mcu_pin_obj_t pin_PG10; // 144 only
-extern const mcu_pin_obj_t pin_PG11; // 144 only
-extern const mcu_pin_obj_t pin_PG12; // 144 only
-extern const mcu_pin_obj_t pin_PG13; // 144 only
-extern const mcu_pin_obj_t pin_PG14; // 144 only
-extern const mcu_pin_obj_t pin_PG15; // 144 only
-extern const mcu_pin_obj_t pin_PB03;
-extern const mcu_pin_obj_t pin_PB04;
-//pg 63
-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_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_STM32F405XX_PINS_H
diff --git a/ports/stm/peripherals/timers.c b/ports/stm/peripherals/timers.c
new file mode 100644
index 000000000..baa81d2b5
--- /dev/null
+++ b/ports/stm/peripherals/timers.c
@@ -0,0 +1,460 @@
+/*
+ * This file is part of the Micro Python project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020 Lucian Copeland for Adafruit Industries
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+#include "timers.h"
+
+#include "py/mpconfig.h"
+#include "py/gc.h"
+#include "py/obj.h"
+#include "py/runtime.h"
+#include "supervisor/shared/translate.h"
+
+#include "shared-bindings/microcontroller/__init__.h"
+#include "shared-bindings/microcontroller/Pin.h"
+
+#if !(CPY_STM32H7)
+
+#define ALL_CLOCKS 0xFFFF
+#define NULL_IRQ 0xFF
+
+static bool stm_timer_reserved[MP_ARRAY_SIZE(mcu_tim_banks)];
+static bool stm_timer_never_reset[MP_ARRAY_SIZE(mcu_tim_banks)];
+static void (*stm_timer_callback[MP_ARRAY_SIZE(mcu_tim_banks)])(void);
+static size_t irq_map[] = {
+ #ifdef TIM1
+ TIM1_CC_IRQn,
+ #else
+ NULL_IRQ,
+ #endif
+ #ifdef TIM2
+ TIM2_IRQn,
+ #else
+ NULL_IRQ,
+ #endif
+ #ifdef TIM3
+ TIM3_IRQn,
+ #else
+ NULL_IRQ,
+ #endif
+ #ifdef TIM4
+ TIM4_IRQn,
+ #else
+ NULL_IRQ,
+ #endif
+ #ifdef TIM5
+ TIM5_IRQn,
+ #else
+ NULL_IRQ,
+ #endif
+ #ifdef TIM6
+ #if !defined(DAC_BASE) && !defined(DAC1_BASE)
+ TIM6_IRQn,
+ #else
+ TIM6_DAC_IRQn,
+ #endif
+ #else
+ NULL_IRQ,
+ #endif
+ #ifdef TIM7
+ TIM7_IRQn,
+ #else
+ NULL_IRQ,
+ #endif
+ #ifdef TIM8
+ TIM8_CC_IRQn,
+ #else
+ NULL_IRQ,
+ #endif
+ #ifdef TIM9
+ TIM1_BRK_TIM9_IRQn,
+ #else
+ NULL_IRQ,
+ #endif
+ #ifdef TIM10
+ TIM1_UP_TIM10_IRQn,
+ #else
+ NULL_IRQ,
+ #endif
+ #ifdef TIM11
+ TIM1_TRG_COM_TIM11_IRQn,
+ #else
+ NULL_IRQ,
+ #endif
+ #ifdef TIM12
+ TIM8_BRK_TIM12_IRQn,
+ #else
+ NULL_IRQ,
+ #endif
+ #ifdef TIM13
+ TIM8_UP_TIM13_IRQn,
+ #else
+ NULL_IRQ,
+ #endif
+ #ifdef TIM14
+ TIM8_TRG_COM_TIM14_IRQn,
+ #else
+ NULL_IRQ,
+ #endif
+ #ifdef TIM15
+ TIM15_IRQn,
+ #else
+ NULL_IRQ,
+ #endif
+ #ifdef TIM16
+ TIM16_IRQn,
+ #else
+ NULL_IRQ,
+ #endif
+ #ifdef TIM17
+ TIM17_IRQn,
+ #else
+ NULL_IRQ,
+ #endif
+};
+
+// Get the frequency (in Hz) of the source clock for the given timer.
+// On STM32F405/407/415/417 there are 2 cases for how the clock freq is set.
+// If the APB prescaler is 1, then the timer clock is equal to its respective
+// APB clock. Otherwise (APB prescaler > 1) the timer clock is twice its
+// respective APB clock. See DM00031020 Rev 4, page 115.
+uint32_t stm_peripherals_timer_get_source_freq(TIM_TypeDef * timer) {
+ size_t tim_id = stm_peripherals_timer_get_index(timer);
+ uint32_t source, clk_div;
+ if (tim_id == 1 || (8 <= tim_id && tim_id <= 11)) {
+ // TIM{1,8,9,10,11} are on APB2
+ source = HAL_RCC_GetPCLK2Freq();
+ clk_div = RCC->CFGR & RCC_CFGR_PPRE2;
+ } else {
+ // TIM{2,3,4,5,6,7,12,13,14} are on APB1
+ source = HAL_RCC_GetPCLK1Freq();
+ clk_div = RCC->CFGR & RCC_CFGR_PPRE1;
+ }
+ if (clk_div != 0) {
+ // APB prescaler for this timer is > 1
+ source *= 2;
+ }
+ return source;
+}
+
+size_t stm_peripherals_timer_get_irqnum(TIM_TypeDef * instance) {
+ size_t tim_id = stm_peripherals_timer_get_index(instance);
+ return irq_map[tim_id];
+}
+
+void timers_reset(void) {
+ uint16_t never_reset_mask = 0x00;
+ for (size_t i = 0; i < MP_ARRAY_SIZE(mcu_tim_banks); i++) {
+ if (!stm_timer_never_reset[i]) {
+ stm_timer_reserved[i] = false;
+ } else {
+ never_reset_mask |= 1 << i;
+ }
+ }
+ tim_clock_disable(ALL_CLOCKS & ~(never_reset_mask));
+}
+
+TIM_TypeDef * stm_peripherals_find_timer(void) {
+ // Check for timers on pins outside the package size
+ for (size_t i = 0; i < MP_ARRAY_SIZE(mcu_tim_banks); i++) {
+ bool timer_in_package = false;
+ // Find each timer instance on the given bank
+ for (size_t j = 0; j < MP_ARRAY_SIZE(mcu_tim_pin_list); j++) {
+ // If a pin is claimed, we skip it
+ if ( (mcu_tim_pin_list[j].tim_index == i + 1)
+ && (common_hal_mcu_pin_is_free(mcu_tim_pin_list[j].pin) == true) ) {
+ // Search whether any pins in the package array match it
+ for (size_t k = 0; k < mcu_pin_globals.map.alloc; k++) {
+ if ( (mcu_tim_pin_list[j].pin == (mcu_pin_obj_t*)(mcu_pin_globals.map.table[k].value)) ) {
+ timer_in_package = true;
+ }
+ }
+ }
+ }
+ // If no results are found, no unclaimed pins with this timer are in this package,
+ // and it is safe to pick
+ if (timer_in_package == false && mcu_tim_banks[i] != NULL) {
+ // DEBUG: print the timer
+ return mcu_tim_banks[i];
+ mp_printf(&mp_plat_print, "Timer: %d\n",i);
+ }
+ }
+ //TODO: secondary search for timers outside the pins in the board profile
+
+ // Work backwards - higher index timers have fewer pin allocations
+ for (size_t i = (MP_ARRAY_SIZE(mcu_tim_banks) - 1); i >= 0; i--) {
+ if ((!stm_timer_reserved[i]) && (mcu_tim_banks[i] != NULL)) {
+ // DEBUG: print the timer
+ mp_printf(&mp_plat_print, "Timer: %d\n",i);
+ return mcu_tim_banks[i];
+ }
+ }
+ mp_raise_RuntimeError(translate("All timers in use"));
+ return NULL;
+}
+
+void stm_peripherals_timer_preinit(TIM_TypeDef * instance, uint8_t prio, void (*callback)(void)) {
+ size_t tim_idx = stm_peripherals_timer_get_index(instance);
+ stm_timer_callback[tim_idx] = callback;
+ tim_clock_enable(1 << tim_idx);
+ HAL_NVIC_SetPriority(irq_map[tim_idx], prio, 0);
+ HAL_NVIC_EnableIRQ(irq_map[tim_idx]);
+}
+
+void stm_peripherals_timer_reserve(TIM_TypeDef * instance) {
+ size_t tim_idx = stm_peripherals_timer_get_index(instance);
+ stm_timer_reserved[tim_idx] = true;
+}
+
+void stm_peripherals_timer_set_callback(void(*callback)(void), TIM_TypeDef * timer) {
+ stm_timer_callback[stm_peripherals_timer_get_index(timer)] = callback;
+}
+
+void stm_peripherals_timer_free(TIM_TypeDef * instance) {
+ size_t tim_idx = stm_peripherals_timer_get_index(instance);
+ HAL_NVIC_DisableIRQ(irq_map[tim_idx]);
+ stm_timer_callback[tim_idx] = NULL;
+ tim_clock_disable(1 << tim_idx);
+ stm_timer_reserved[tim_idx] = false;
+ stm_timer_never_reset[tim_idx] = false;
+}
+
+void stm_peripherals_timer_never_reset(TIM_TypeDef * instance) {
+ size_t tim_idx = stm_peripherals_timer_get_index(instance);
+ stm_timer_never_reset[tim_idx] = true;
+}
+void stm_peripherals_timer_reset_ok(TIM_TypeDef * instance) {
+ size_t tim_idx = stm_peripherals_timer_get_index(instance);
+ stm_timer_never_reset[tim_idx] = false;
+}
+bool stm_peripherals_timer_is_never_reset(TIM_TypeDef * instance){
+ size_t tim_idx = stm_peripherals_timer_get_index(instance);
+ return stm_timer_never_reset[tim_idx];
+}
+bool stm_peripherals_timer_is_reserved(TIM_TypeDef * instance) {
+ size_t tim_idx = stm_peripherals_timer_get_index(instance);
+ return stm_timer_reserved[tim_idx];
+}
+
+size_t stm_peripherals_timer_get_index(TIM_TypeDef * instance) {
+ for (size_t i = 0; i < MP_ARRAY_SIZE(mcu_tim_banks); i++) {
+ if (instance == mcu_tim_banks[i]) {
+ return i;
+ }
+ }
+ return ~(size_t)0;
+}
+
+void tim_clock_enable(uint16_t mask) {
+ #ifdef TIM1
+ if (mask & (1 << 0)) {
+ __HAL_RCC_TIM1_CLK_ENABLE();
+ }
+ #endif
+ #ifdef TIM2
+ if (mask & (1 << 1)) {
+ __HAL_RCC_TIM2_CLK_ENABLE();
+ }
+ #endif
+ #ifdef TIM3
+ if (mask & (1 << 2)) {
+ __HAL_RCC_TIM3_CLK_ENABLE();
+ }
+ #endif
+ #ifdef TIM4
+ if (mask & (1 << 3)) {
+ __HAL_RCC_TIM4_CLK_ENABLE();
+ }
+ #endif
+ #ifdef TIM5
+ if (mask & (1 << 4)) {
+ __HAL_RCC_TIM5_CLK_ENABLE();
+ }
+ #endif
+ //6 and 7 are reserved ADC timers
+ #ifdef TIM8
+ if (mask & (1 << 7)) {
+ __HAL_RCC_TIM8_CLK_ENABLE();
+ }
+ #endif
+ #ifdef TIM9
+ if (mask & (1 << 8)) {
+ __HAL_RCC_TIM9_CLK_ENABLE();
+ }
+ #endif
+ #ifdef TIM10
+ if (mask & (1 << 9)) {
+ __HAL_RCC_TIM10_CLK_ENABLE();
+ }
+ #endif
+ #ifdef TIM11
+ if (mask & (1 << 10)) {
+ __HAL_RCC_TIM11_CLK_ENABLE();
+ }
+ #endif
+ #ifdef TIM12
+ if (mask & (1 << 11)) {
+ __HAL_RCC_TIM12_CLK_ENABLE();
+ }
+ #endif
+ #ifdef TIM13
+ if (mask & (1 << 12)) {
+ __HAL_RCC_TIM13_CLK_ENABLE();
+ }
+ #endif
+ #ifdef TIM14
+ if (mask & (1 << 13)) {
+ __HAL_RCC_TIM14_CLK_ENABLE();
+ }
+ #endif
+}
+
+void tim_clock_disable(uint16_t mask) {
+ #ifdef TIM1
+ if (mask & (1 << 0)) {
+ __HAL_RCC_TIM1_CLK_DISABLE();
+ }
+ #endif
+ #ifdef TIM2
+ if (mask & (1 << 1)) {
+ __HAL_RCC_TIM2_CLK_DISABLE();
+ }
+ #endif
+ #ifdef TIM3
+ if (mask & (1 << 2)) {
+ __HAL_RCC_TIM3_CLK_DISABLE();
+ }
+ #endif
+ #ifdef TIM4
+ if (mask & (1 << 3)) {
+ __HAL_RCC_TIM4_CLK_DISABLE();
+ }
+ #endif
+ #ifdef TIM5
+ if (mask & (1 << 4)) {
+ __HAL_RCC_TIM5_CLK_DISABLE();
+ }
+ #endif
+ //6 and 7 are reserved ADC timers
+ #ifdef TIM8
+ if (mask & (1 << 7)) {
+ __HAL_RCC_TIM8_CLK_DISABLE();
+ }
+ #endif
+ #ifdef TIM9
+ if (mask & (1 << 8)) {
+ __HAL_RCC_TIM9_CLK_DISABLE();
+ }
+ #endif
+ #ifdef TIM10
+ if (mask & (1 << 9)) {
+ __HAL_RCC_TIM10_CLK_DISABLE();
+ }
+ #endif
+ #ifdef TIM11
+ if (mask & (1 << 10)) {
+ __HAL_RCC_TIM11_CLK_DISABLE();
+ }
+ #endif
+ #ifdef TIM12
+ if (mask & (1 << 11)) {
+ __HAL_RCC_TIM12_CLK_DISABLE();
+ }
+ #endif
+ #ifdef TIM13
+ if (mask & (1 << 12)) {
+ __HAL_RCC_TIM13_CLK_DISABLE();
+ }
+ #endif
+ #ifdef TIM14
+ if (mask & (1 << 13)) {
+ __HAL_RCC_TIM14_CLK_DISABLE();
+ }
+ #endif
+}
+
+STATIC void callback_router(size_t index) {
+ if (stm_timer_callback[index - 1]) {
+ (*stm_timer_callback[index - 1])();
+ }
+}
+
+void TIM1_CC_IRQHandler(void) { // Advanced timer
+ callback_router(1);
+}
+void TIM2_IRQHandler(void) {
+ callback_router(2);
+}
+void TIM3_IRQHandler(void) {
+ callback_router(3);
+}
+void TIM4_IRQHandler(void) {
+ callback_router(4);
+}
+void TIM5_IRQHandler(void) {
+ callback_router(5);
+}
+void TIM6_DAC_IRQHandler(void) { // Basic timer (DAC)
+ callback_router(6);
+}
+void TIM7_IRQHandler(void) { // Basic timer
+ callback_router(7);
+}
+void TIM8_CC_IRQHandler(void) { // Advanced timer
+ callback_router(8);
+}
+
+// Advanced timer interrupts are currently unused.
+void TIM1_BRK_TIM9_IRQHandler(void) {
+ callback_router(9);
+}
+void TIM1_UP_TIM10_IRQHandler(void) {
+ callback_router(10);
+}
+void TIM1_TRG_COM_TIM11_IRQHandler(void) {
+ callback_router(11);
+}
+void TIM8_BRK_TIM12_IRQHandler(void) {
+ callback_router(12);
+}
+void TIM8_UP_TIM13_IRQHandler(void) {
+ callback_router(13);
+}
+void TIM8_TRG_COM_TIM14_IRQHandler(void) {
+ callback_router(14);
+}
+
+#if (CPY_STM32H7)
+void TIM15_IRQHandler(void) {
+ callback_router(15);
+}
+void TIM16_IRQHandler(void) {
+ callback_router(16);
+}
+void TIM17_IRQHandler(void) {
+ callback_router(17);
+}
+#endif
+
+#endif
diff --git a/ports/stm/peripherals/timers.h b/ports/stm/peripherals/timers.h
new file mode 100644
index 000000000..c4b6c6367
--- /dev/null
+++ b/ports/stm/peripherals/timers.h
@@ -0,0 +1,46 @@
+/*
+ * This file is part of the Micro Python project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020 Lucian Copeland for Adafruit Industries
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include <stdint.h>
+#include "py/mphal.h"
+#include "peripherals/periph.h"
+
+#include STM32_HAL_H
+
+void tim_clock_enable(uint16_t mask);
+void tim_clock_disable(uint16_t mask);
+uint32_t stm_peripherals_timer_get_source_freq(TIM_TypeDef * timer);
+size_t stm_peripherals_timer_get_irqnum(TIM_TypeDef * instance);
+void timers_reset(void);
+TIM_TypeDef * stm_peripherals_find_timer(void);
+void stm_peripherals_timer_preinit(TIM_TypeDef * instance, uint8_t prio, void (*callback)(void));
+void stm_peripherals_timer_reserve(TIM_TypeDef * instance);
+void stm_peripherals_timer_free(TIM_TypeDef * instance);
+void stm_peripherals_timer_never_reset(TIM_TypeDef * instance);
+void stm_peripherals_timer_reset_ok(TIM_TypeDef * instance);
+bool stm_peripherals_timer_is_never_reset(TIM_TypeDef * instance);
+bool stm_peripherals_timer_is_reserved(TIM_TypeDef * instance);
+size_t stm_peripherals_timer_get_index(TIM_TypeDef * instance);
diff --git a/ports/stm/supervisor/port.c b/ports/stm/supervisor/port.c
index 07a93c025..7c9fcf750 100644
--- a/ports/stm/supervisor/port.c
+++ b/ports/stm/supervisor/port.c
@@ -41,6 +41,7 @@
#include "common-hal/pulseio/PWMOut.h"
#include "common-hal/pulseio/PulseOut.h"
#include "common-hal/pulseio/PulseIn.h"
+#include "timers.h"
#endif
#include "clocks.h"
@@ -224,6 +225,7 @@ void reset_port(void) {
uart_reset();
#endif
#if CIRCUITPY_PULSEIO
+ timers_reset();
pwmout_reset();
pulseout_reset();
pulsein_reset();
diff --git a/ports/stm/supervisor/usb.c b/ports/stm/supervisor/usb.c
index 3d53fa374..c0e012cc6 100644
--- a/ports/stm/supervisor/usb.c
+++ b/ports/stm/supervisor/usb.c
@@ -86,6 +86,8 @@ void init_usb_hardware(void) {
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
never_reset_pin_number(0, 11);
never_reset_pin_number(0, 12);
+ claim_pin(0, 11);
+ claim_pin(0, 12);
/* Configure VBUS Pin */
#if !(BOARD_NO_VBUS_SENSE)
@@ -94,6 +96,7 @@ void init_usb_hardware(void) {
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
never_reset_pin_number(0, 9);
+ claim_pin(0, 9);
#endif
/* This for ID line debug */
@@ -108,6 +111,7 @@ void init_usb_hardware(void) {
#endif
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
never_reset_pin_number(0, 10);
+ claim_pin(0, 10);
#ifdef STM32F412Zx
/* Configure POWER_SWITCH IO pin (F412 ONLY)*/
@@ -116,6 +120,7 @@ void init_usb_hardware(void) {
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);
never_reset_pin_number(0, 8);
+ claim_pin(0, 8);
#endif
#if CPY_STM32H7
diff --git a/ports/stm/tools/parse_af_csv.py b/ports/stm/tools/parse_af_csv.py
index 984696be0..06af3bf1e 100644
--- a/ports/stm/tools/parse_af_csv.py
+++ b/ports/stm/tools/parse_af_csv.py
@@ -52,6 +52,8 @@ def evaluate_tim(inper, inlist, altfn, pin):
if inper[:3] == "TIM" and inper[5:7] == "CH" and inper[-1:] != 'N':
inlist.append([inper[3:4],altfn,inper[-1:],pin])
+ elif inper[:3] == "TIM" and inper[6:8] == "CH" and inper[-1:] != 'N':
+ inlist.append([inper[3:5],altfn,inper[-1:],pin])
# Open target file
with open(sys.argv[1]) as csv_file:
diff --git a/ports/stm/tools/pins.csv b/ports/stm/tools/pins.csv
deleted file mode 100644
index b424c2f78..000000000
--- a/ports/stm/tools/pins.csv
+++ /dev/null
@@ -1,93 +0,0 @@
-A0,PA3
-A1,PC0
-A2,PC3
-A3,PB1
-A4,PC2
-A5,PF10
-A6,PF4
-A7,PF5
-A8,PF6
-D0,PB7
-D1,PB6
-D2,PG14
-D3,PE13
-D4,PE14
-D5,PE11
-D6,PE9
-D7,PG12
-D8,PF3
-D9,PD15
-D10,PD14
-D11,PB5
-D12,PA6
-D13,PA5
-D14,PB9
-D15,PB8
-D16,PC6
-D17,PB15
-D18,PB13
-D19,PB12
-D20,PA15
-D21,PC7
-D22,PB5
-D23,PB3
-D24,PA4
-D25,PB4
-D26,PG6
-D27,PB2
-D28,PD13
-D29,PD12
-D30,PD11
-D31,PE2
-D32,PA0
-D33,PB0
-D34,PE0
-D35,PB11
-D36,PB10
-D37,PE15
-D38,PE6
-D39,PE12
-D40,PE10
-D41,PE7
-D42,PE8
-D43,PC8
-D44,PC9
-D45,PC10
-D46,PC11
-D47,PC12
-D48,PD2
-D49,PG2
-D50,PG3
-D51,PD7
-D52,PD6
-D53,PD5
-D54,PD4
-D55,PD3
-D56,PE2
-D57,PE4
-D58,PE5
-D59,PE6
-D60,PE3
-D61,PF8
-D62,PF7
-D63,PF9
-D64,PG1
-D65,PG0
-D66,PD1
-D67,PD0
-D68,PF0
-D69,PF1
-D70,PF2
-D71,PE0
-D72,PB2
-SDA,PB9
-SCL,PB8
-MOSI,PB5
-MISO,PA6
-SCK,PA5
-RX,PB7
-TX,PB6
-LED1,PB00
-LED2,PE01
-LED3,PB14
-SW,PC13
diff --git a/ports/stm/tools/stm32f767_af.csv b/ports/stm/tools/stm32f767_af.csv
deleted file mode 100644
index 86f10b6dc..000000000
--- a/ports/stm/tools/stm32f767_af.csv
+++ /dev/null
@@ -1,168 +0,0 @@
-PortA,PA0,,TIM2_CH1/TIM2_ETR,TIM5_CH1,TIM8_ETR,,,,USART2_CTS,UART4_TX,,SAI2_SD_B,ETH_MII_CRS,,,,EVENTOUT,ADC123_IN0
-PortA,PA1,,TIM2_CH2,TIM5_CH2,,,,,USART2_RTS,UART4_RX,QUADSPI_BK1_IO3,SAI2_MCK_B,ETH_MII_RX_CLK/ETH_RMII_REF_CLK,,,LCD_R2,EVENTOUT,ADC123_IN1
-PortA,PA2,,TIM2_CH3,TIM5_CH3,TIM9_CH1,,,,USART2_TX,SAI2_SCK_B,,,ETH_MDIO,MDIOS_MDIO,,LCD_R1,EVENTOUT,ADC123_IN2
-PortA,PA3,,TIM2_CH4,TIM5_CH4,TIM9_CH2,,,,USART2_RX,,LCD_B2,OTG_HS_ULPI_D0,ETH_MII_COL,,,LCD_B5,EVENTOUT,ADC123_IN3
-PortA,PA4,,,,,,SPI1_NSS/I2S1_WS,SPI3_NSS/I2S3_WS,USART2_CK,SPI6_NSS,,,,OTG_HS_SOF,DCMI_HSYNC,LCD_VSYNC,EVENTOUT,ADC12_IN4
-PortA,PA5,,TIM2_CH1/TIM2_ETR,,TIM8_CH1N,,SPI1_SCK/I2S1_CK,,,SPI6_SCK,,OTG_HS_ULPI_CK,,,,LCD_R4,EVENTOUT,ADC12_IN5
-PortA,PA6,,TIM1_BKIN,TIM3_CH1,TIM8_BKIN,,SPI1_MISO,,,SPI6_MISO,TIM13_CH1,,,MDIOS_MDC,DCMI_PIXCLK,LCD_G2,EVENTOUT,ADC12_IN6
-PortA,PA7,,TIM1_CH1N,TIM3_CH2,TIM8_CH1N,,SPI1_MOSI/I2S1_SD,,,SPI6_MOSI,TIM14_CH1,,ETH_MII_RX_DV/ETH_RMII_CRS_DV,FMC_SDNWE,,,EVENTOUT,ADC12_IN7
-PortA,PA8,MCO1,TIM1_CH1,,TIM8_BKIN2,I2C3_SCL,,,USART1_CK,,,OTG_FS_SOF,CAN3_RX,UART7_RX,LCD_B3,LCD_R6,EVENTOUT,
-PortA,PA9,,TIM1_CH2,,,I2C3_SMBA,SPI2_SCK/I2S2_CK,,USART1_TX,,,,,,DCMI_D0,LCD_R5,EVENTOUT,
-PortA,PA10,,TIM1_CH3,,,,,,USART1_RX,,LCD_B4,OTG_FS_ID,,MDIOS_MDIO,DCMI_D1,LCD_B1,EVENTOUT,
-PortA,PA11,,TIM1_CH4,,,,SPI2_NSS/I2S2_WS,UART4_RX,USART1_CTS,,CAN1_RX,OTG_FS_DM,,,,LCD_R4,EVENTOUT,
-PortA,PA12,,TIM1_ETR,,,,SPI2_SCK/I2S2_CK,UART4_TX,USART1_RTS,SAI2_FS_B,CAN1_TX,OTG_FS_DP,,,,LCD_R5,EVENTOUT,
-PortA,PA13,JTMS/SWDIO,,,,,,,,,,,,,,,EVENTOUT,
-PortA,PA14,JTCK/SWCLK,,,,,,,,,,,,,,,EVENTOUT,
-PortA,PA15,JTDI,TIM2_CH1/TIM2_ETR,,,HDMI_CEC,SPI1_NSS/I2S1_WS,SPI3_NSS/I2S3_WS,SPI6_NSS,UART4_RTS,,,CAN3_TX,UART7_TX,,,EVENTOUT,
-PortB,PB0,,TIM1_CH2N,TIM3_CH3,TIM8_CH2N,,,DFSDM1_CKOUT,,UART4_CTS,LCD_R3,OTG_HS_ULPI_D1,ETH_MII_RXD2,,,LCD_G1,EVENTOUT,ADC12_IN8
-PortB,PB1,,TIM1_CH3N,TIM3_CH4,TIM8_CH3N,,,DFSDM1_DATAIN1,,,LCD_R6,OTG_HS_ULPI_D2,ETH_MII_RXD3,,,LCD_G0,EVENTOUT,ADC12_IN9
-PortB,PB2,,,,,,,SAI1_SD_A,SPI3_MOSI/I2S3_SD,,QUADSPI_CLK,DFSDM1_CKIN1,,,,,EVENTOUT,
-PortB,PB3,JTDO/TRACESWO,TIM2_CH2,,,,SPI1_SCK/I2S1_CK,SPI3_SCK/I2S3_CK,,SPI6_SCK,,SDMMC2_D2,CAN3_RX,UART7_RX,,,EVENTOUT,
-PortB,PB4,NJTRST,,TIM3_CH1,,,SPI1_MISO,SPI3_MISO,SPI2_NSS/I2S2_WS,SPI6_MISO,,SDMMC2_D3,CAN3_TX,UART7_TX,,,EVENTOUT,
-PortB,PB5,,UART5_RX,TIM3_CH2,,I2C1_SMBA,SPI1_MOSI/I2S1_SD,SPI3_MOSI/I2S3_SD,,SPI6_MOSI,CAN2_RX,OTG_HS_ULPI_D7,ETH_PPS_OUT,FMC_SDCKE1,DCMI_D10,LCD_G7,EVENTOUT,
-PortB,PB6,,UART5_TX,TIM4_CH1,HDMI_CEC,I2C1_SCL,,DFSDM1_DATAIN5,USART1_TX,,CAN2_TX,QUADSPI_BK1_NCS,I2C4_SCL,FMC_SDNE1,DCMI_D5,,EVENTOUT,
-PortB,PB7,,,TIM4_CH2,,I2C1_SDA,,DFSDM1_CKIN5,USART1_RX,,,,I2C4_SDA,FMC_NL,DCMI_VSYNC,,EVENTOUT,
-PortB,PB8,,I2C4_SCL,TIM4_CH3,TIM10_CH1,I2C1_SCL,,DFSDM1_CKIN7,UART5_RX,,CAN1_RX,SDMMC2_D4,ETH_MII_TXD3,SDMMC1_D4,DCMI_D6,LCD_B6,EVENTOUT,
-PortB,PB9,,I2C4_SDA,TIM4_CH4,TIM11_CH1,I2C1_SDA,SPI2_NSS/I2S2_WS,DFSDM1_DATAIN7,UART5_TX,,CAN1_TX,SDMMC2_D5,I2C4_SMBA,SDMMC1_D5,DCMI_D7,LCD_B7,EVENTOUT,
-PortB,PB10,,TIM2_CH3,,,I2C2_SCL,SPI2_SCK/I2S2_CK,DFSDM1_DATAIN7,USART3_TX,,QUADSPI_BK1_NCS,OTG_HS_ULPI_D3,ETH_MII_RX_ER,,,LCD_G4,EVENTOUT,
-PortB,PB11,,TIM2_CH4,,,I2C2_SDA,,DFSDM1_CKIN7,USART3_RX,,,OTG_HS_ULPI_D4,ETH_MII_TX_EN/ETH_RMII_TX_EN,,DSI_TE,LCD_G5,EVENTOUT,
-PortB,PB12,,TIM1_BKIN,,,I2C2_SMBA,SPI2_NSS/I2S2_WS,DFSDM1_DATAIN1,USART3_CK,UART5_RX,CAN2_RX,OTG_HS_ULPI_D5,ETH_MII_TXD0/ETH_RMII_TXD0,OTG_HS_ID,,,EVENTOUT,
-PortB,PB13,,TIM1_CH1N,,,,SPI2_SCK/I2S2_CK,DFSDM1_CKIN1,USART3_CTS,UART5_TX,CAN2_TX,OTG_HS_ULPI_D6,ETH_MII_TXD1/ETH_RMII_TXD1,,,,EVENTOUT,
-PortB,PB14,,TIM1_CH2N,,TIM8_CH2N,USART1_TX,SPI2_MISO,DFSDM1_DATAIN2,USART3_RTS,UART4_RTS,TIM12_CH1,SDMMC2_D0,,OTG_HS_DM,,,EVENTOUT,
-PortB,PB15,RTC_REFIN,TIM1_CH3N,,TIM8_CH3N,USART1_RX,SPI2_MOSI/I2S2_SD,DFSDM1_CKIN2,,UART4_CTS,TIM12_CH2,SDMMC2_D1,,OTG_HS_DP,,,EVENTOUT,
-PortC,PC0,,,,DFSDM1_CKIN0,,,DFSDM1_DATAIN4,,SAI2_FS_B,,OTG_HS_ULPI_STP,,FMC_SDNWE,,LCD_R5,EVENTOUT,ADC123_IN10
-PortC,PC1,TRACED0,,,DFSDM1_DATAIN0,,SPI2_MOSI/I2S2_SD,SAI1_SD_A,,,,DFSDM1_CKIN4,ETH_MDC,MDIOS_MDC,,,EVENTOUT,ADC123_IN11
-PortC,PC2,,,,DFSDM1_CKIN1,,SPI2_MISO,DFSDM1_CKOUT,,,,OTG_HS_ULPI_DIR,ETH_MII_TXD2,FMC_SDNE0,,,EVENTOUT,ADC123_IN12
-PortC,PC3,,,,DFSDM1_DATAIN1,,SPI2_MOSI/I2S2_SD,,,,,OTG_HS_ULPI_NXT,ETH_MII_TX_CLK,FMC_SDCKE0,,,EVENTOUT,ADC123_IN13
-PortC,PC4,,,,DFSDM1_CKIN2,,I2S1_MCK,,,SPDIFRX_IN2,,,ETH_MII_RXD0/ETH_RMII_RXD0,FMC_SDNE0,,,EVENTOUT,ADC12_IN14
-PortC,PC5,,,,DFSDM1_DATAIN2,,,,,SPDIFRX_IN3,,,ETH_MII_RXD1/ETH_RMII_RXD1,FMC_SDCKE0,,,EVENTOUT,ADC12_IN15
-PortC,PC6,,,TIM3_CH1,TIM8_CH1,,I2S2_MCK,,DFSDM1_CKIN3,USART6_TX,FMC_NWAIT,SDMMC2_D6,,SDMMC1_D6,DCMI_D0,LCD_HSYNC,EVENTOUT,
-PortC,PC7,,,TIM3_CH2,TIM8_CH2,,,I2S3_MCK,DFSDM1_DATAIN3,USART6_RX,FMC_NE1,SDMMC2_D7,,SDMMC1_D7,DCMI_D1,LCD_G6,EVENTOUT,
-PortC,PC8,TRACED1,,TIM3_CH3,TIM8_CH3,,,,UART5_RTS,USART6_CK,FMC_NE2/FMC_NCE,,,SDMMC1_D0,DCMI_D2,,EVENTOUT,
-PortC,PC9,MCO2,,TIM3_CH4,TIM8_CH4,I2C3_SDA,I2S_CKIN,,UART5_CTS,,QUADSPI_BK1_IO0,LCD_G3,,SDMMC1_D1,DCMI_D3,LCD_B2,EVENTOUT,
-PortC,PC10,,,,DFSDM1_CKIN5,,,SPI3_SCK/I2S3_CK,USART3_TX,UART4_TX,QUADSPI_BK1_IO1,,,SDMMC1_D2,DCMI_D8,LCD_R2,EVENTOUT,
-PortC,PC11,,,,DFSDM1_DATAIN5,,,SPI3_MISO,USART3_RX,UART4_RX,QUADSPI_BK2_NCS,,,SDMMC1_D3,DCMI_D4,,EVENTOUT,
-PortC,PC12,TRACED3,,,,,,SPI3_MOSI/I2S3_SD,USART3_CK,UART5_TX,,,,SDMMC1_CK,DCMI_D9,,EVENTOUT,
-PortC,PC13,,,,,,,,,,,,,,,,EVENTOUT,
-PortC,PC14,,,,,,,,,,,,,,,,EVENTOUT,
-PortC,PC15,,,,,,,,,,,,,,,,EVENTOUT,
-PortD,PD0,,,,DFSDM1_CKIN6,,,DFSDM1_DATAIN7,,UART4_RX,CAN1_RX,,,FMC_D2,,,EVENTOUT,
-PortD,PD1,,,,DFSDM1_DATAIN6,,,DFSDM1_CKIN7,,UART4_TX,CAN1_TX,,,FMC_D3,,,EVENTOUT,
-PortD,PD2,TRACED2,,TIM3_ETR,,,,,,UART5_RX,,,,SDMMC1_CMD,DCMI_D11,,EVENTOUT,
-PortD,PD3,,,,DFSDM1_CKOUT,,SPI2_SCK/I2S2_CK,DFSDM1_DATAIN0,USART2_CTS,,,,,FMC_CLK,DCMI_D5,LCD_G7,EVENTOUT,
-PortD,PD4,,,,,,,DFSDM1_CKIN0,USART2_RTS,,,,,FMC_NOE,,,EVENTOUT,
-PortD,PD5,,,,,,,,USART2_TX,,,,,FMC_NWE,,,EVENTOUT,
-PortD,PD6,,,,DFSDM1_CKIN4,,SPI3_MOSI/I2S3_SD,SAI1_SD_A,USART2_RX,,,DFSDM1_DATAIN1,SDMMC2_CK,FMC_NWAIT,DCMI_D10,LCD_B2,EVENTOUT,
-PortD,PD7,,,,DFSDM1_DATAIN4,,SPI1_MOSI/I2S1_SD,DFSDM1_CKIN1,USART2_CK,SPDIFRX_IN0,,,SDMMC2_CMD,FMC_NE1,,,EVENTOUT,
-PortD,PD8,,,,DFSDM1_CKIN3,,,,USART3_TX,SPDIFRX_IN1,,,,FMC_D13,,,EVENTOUT,
-PortD,PD9,,,,DFSDM1_DATAIN3,,,,USART3_RX,,,,,FMC_D14,,,EVENTOUT,
-PortD,PD10,,,,DFSDM1_CKOUT,,,,USART3_CK,,,,,FMC_D15,,LCD_B3,EVENTOUT,
-PortD,PD11,,,,,I2C4_SMBA,,,USART3_CTS,,QUADSPI_BK1_IO0,SAI2_SD_A,,FMC_A16/FMC_CLE,,,EVENTOUT,
-PortD,PD12,,,TIM4_CH1,LPTIM1_IN1,I2C4_SCL,,,USART3_RTS,,QUADSPI_BK1_IO1,SAI2_FS_A,,FMC_A17/FMC_ALE,,,EVENTOUT,
-PortD,PD13,,,TIM4_CH2,LPTIM1_OUT,I2C4_SDA,,,,,QUADSPI_BK1_IO3,SAI2_SCK_A,,FMC_A18,,,EVENTOUT,
-PortD,PD14,,,TIM4_CH3,,,,,,UART8_CTS,,,,FMC_D0,,,EVENTOUT,
-PortD,PD15,,,TIM4_CH4,,,,,,UART8_RTS,,,,FMC_D1,,,EVENTOUT,
-PortE,PE0,,,TIM4_ETR,LPTIM1_ETR,,,,,UART8_RX,,SAI2_MCK_A,,FMC_NBL0,DCMI_D2,,EVENTOUT,
-PortE,PE1,,,,LPTIM1_IN2,,,,,UART8_TX,,,,FMC_NBL1,DCMI_D3,,EVENTOUT,
-PortE,PE2,TRACECLK,,,,,SPI4_SCK,SAI1_MCLK_A,,,QUADSPI_BK1_IO2,,ETH_MII_TXD3,FMC_A23,,,EVENTOUT,
-PortE,PE3,TRACED0,,,,,,SAI1_SD_B,,,,,,FMC_A19,,,EVENTOUT,
-PortE,PE4,TRACED1,,,,,SPI4_NSS,SAI1_FS_A,,,,DFSDM1_DATAIN3,,FMC_A20,DCMI_D4,LCD_B0,EVENTOUT,
-PortE,PE5,TRACED2,,,TIM9_CH1,,SPI4_MISO,SAI1_SCK_A,,,,DFSDM1_CKIN3,,FMC_A21,DCMI_D6,LCD_G0,EVENTOUT,
-PortE,PE6,TRACED3,TIM1_BKIN2,,TIM9_CH2,,SPI4_MOSI,SAI1_SD_A,,,,SAI2_MCK_B,,FMC_A22,DCMI_D7,LCD_G1,EVENTOUT,
-PortE,PE7,,TIM1_ETR,,,,,DFSDM1_DATAIN2,,UART7_RX,,QUADSPI_BK2_IO0,,FMC_D4,,,EVENTOUT,
-PortE,PE8,,TIM1_CH1N,,,,,DFSDM1_CKIN2,,UART7_TX,,QUADSPI_BK2_IO1,,FMC_D5,,,EVENTOUT,
-PortE,PE9,,TIM1_CH1,,,,,DFSDM1_CKOUT,,UART7_RTS,,QUADSPI_BK2_IO2,,FMC_D6,,,EVENTOUT,
-PortE,PE10,,TIM1_CH2N,,,,,DFSDM1_DATAIN4,,UART7_CTS,,QUADSPI_BK2_IO3,,FMC_D7,,,EVENTOUT,
-PortE,PE11,,TIM1_CH2,,,,SPI4_NSS,DFSDM1_CKIN4,,,,SAI2_SD_B,,FMC_D8,,LCD_G3,EVENTOUT,
-PortE,PE12,,TIM1_CH3N,,,,SPI4_SCK,DFSDM1_DATAIN5,,,,SAI2_SCK_B,,FMC_D9,,LCD_B4,EVENTOUT,
-PortE,PE13,,TIM1_CH3,,,,SPI4_MISO,DFSDM1_CKIN5,,,,SAI2_FS_B,,FMC_D10,,LCD_DE,EVENTOUT,
-PortE,PE14,,TIM1_CH4,,,,SPI4_MOSI,,,,,SAI2_MCK_B,,FMC_D11,,LCD_CLK,EVENTOUT,
-PortE,PE15,,TIM1_BKIN,,,,,,,,,,,FMC_D12,,LCD_R7,EVENTOUT,
-PortF,PF0,,,,,I2C2_SDA,,,,,,,,FMC_A0,,,EVENTOUT,
-PortF,PF1,,,,,I2C2_SCL,,,,,,,,FMC_A1,,,EVENTOUT,
-PortF,PF2,,,,,I2C2_SMBA,,,,,,,,FMC_A2,,,EVENTOUT,
-PortF,PF3,,,,,,,,,,,,,FMC_A3,,,EVENTOUT,ADC3_IN9
-PortF,PF4,,,,,,,,,,,,,FMC_A4,,,EVENTOUT,ADC3_IN14
-PortF,PF5,,,,,,,,,,,,,FMC_A5,,,EVENTOUT,ADC3_IN15
-PortF,PF6,,,,TIM10_CH1,,SPI5_NSS,SAI1_SD_B,,UART7_RX,QUADSPI_BK1_IO3,,,,,,EVENTOUT,ADC3_IN4
-PortF,PF7,,,,TIM11_CH1,,SPI5_SCK,SAI1_MCLK_B,,UART7_TX,QUADSPI_BK1_IO2,,,,,,EVENTOUT,ADC3_IN5
-PortF,PF8,,,,,,SPI5_MISO,SAI1_SCK_B,,UART7_RTS,TIM13_CH1,QUADSPI_BK1_IO0,,,,,EVENTOUT,ADC3_IN6
-PortF,PF9,,,,,,SPI5_MOSI,SAI1_FS_B,,UART7_CTS,TIM14_CH1,QUADSPI_BK1_IO1,,,,,EVENTOUT,ADC3_IN7
-PortF,PF10,,,,,,,,,,QUADSPI_CLK,,,,DCMI_D11,LCD_DE,EVENTOUT,ADC3_IN8
-PortF,PF11,,,,,,SPI5_MOSI,,,,,SAI2_SD_B,,FMC_SDNRAS,DCMI_D12,,EVENTOUT,
-PortF,PF12,,,,,,,,,,,,,FMC_A6,,,EVENTOUT,
-PortF,PF13,,,,,I2C4_SMBA,,DFSDM1_DATAIN6,,,,,,FMC_A7,,,EVENTOUT,
-PortF,PF14,,,,,I2C4_SCL,,DFSDM1_CKIN6,,,,,,FMC_A8,,,EVENTOUT,
-PortF,PF15,,,,,I2C4_SDA,,,,,,,,FMC_A9,,,EVENTOUT,
-PortG,PG0,,,,,,,,,,,,,FMC_A10,,,EVENTOUT,
-PortG,PG1,,,,,,,,,,,,,FMC_A11,,,EVENTOUT,
-PortG,PG2,,,,,,,,,,,,,FMC_A12,,,EVENTOUT,
-PortG,PG3,,,,,,,,,,,,,FMC_A13,,,EVENTOUT,
-PortG,PG4,,,,,,,,,,,,,FMC_A14/FMC_BA0,,,EVENTOUT,
-PortG,PG5,,,,,,,,,,,,,FMC_A15/FMC_BA1,,,EVENTOUT,
-PortG,PG6,,,,,,,,,,,,,FMC_NE3,DCMI_D12,LCD_R7,EVENTOUT,
-PortG,PG7,,,,,,,SAI1_MCLK_A,,USART6_CK,,,,FMC_INT,DCMI_D13,LCD_CLK,EVENTOUT,
-PortG,PG8,,,,,,SPI6_NSS,,SPDIFRX_IN2,USART6_RTS,,,ETH_PPS_OUT,FMC_SDCLK,,LCD_G7,EVENTOUT,
-PortG,PG9,,,,,,SPI1_MISO,,SPDIFRX_IN3,USART6_RX,QUADSPI_BK2_IO2,SAI2_FS_B,SDMMC2_D0,FMC_NE2/FMC_NCE,DCMI_VSYNC,,EVENTOUT,
-PortG,PG10,,,,,,SPI1_NSS/I2S1_WS,,,,LCD_G3,SAI2_SD_B,SDMMC2_D1,FMC_NE3,DCMI_D2,LCD_B2,EVENTOUT,
-PortG,PG11,,,,,,SPI1_SCK/I2S1_CK,,SPDIFRX_IN0,,,SDMMC2_D2,ETH_MII_TX_EN/ETH_RMII_TX_EN,,DCMI_D3,LCD_B3,EVENTOUT,
-PortG,PG12,,,,LPTIM1_IN1,,SPI6_MISO,,SPDIFRX_IN1,USART6_RTS,LCD_B4,,SDMMC2_D3,FMC_NE4,,LCD_B1,EVENTOUT,
-PortG,PG13,TRACED0,,,LPTIM1_OUT,,SPI6_SCK,,,USART6_CTS,,,ETH_MII_TXD0/ETH_RMII_TXD0,FMC_A24,,LCD_R0,EVENTOUT,
-PortG,PG14,TRACED1,,,LPTIM1_ETR,,SPI6_MOSI,,,USART6_TX,QUADSPI_BK2_IO3,,ETH_MII_TXD1/ETH_RMII_TXD1,FMC_A25,,LCD_B0,EVENTOUT,
-PortG,PG15,,,,,,,,,USART6_CTS,,,,FMC_SDNCAS,DCMI_D13,,EVENTOUT,
-PortH,PH0,,,,,,,,,,,,,,,,EVENTOUT,
-PortH,PH1,,,,,,,,,,,,,,,,EVENTOUT,
-PortH,PH2,,,,LPTIM1_IN2,,,,,,QUADSPI_BK2_IO0,SAI2_SCK_B,ETH_MII_CRS,FMC_SDCKE0,,LCD_R0,EVENTOUT,
-PortH,PH3,,,,,,,,,,QUADSPI_BK2_IO1,SAI2_MCK_B,ETH_MII_COL,FMC_SDNE0,,LCD_R1,EVENTOUT,
-PortH,PH4,,,,,I2C2_SCL,,,,,LCD_G5,OTG_HS_ULPI_NXT,,,,LCD_G4,EVENTOUT,
-PortH,PH5,,,,,I2C2_SDA,SPI5_NSS,,,,,,,FMC_SDNWE,,,EVENTOUT,
-PortH,PH6,,,,,I2C2_SMBA,SPI5_SCK,,,,TIM12_CH1,,ETH_MII_RXD2,FMC_SDNE1,DCMI_D8,,EVENTOUT,
-PortH,PH7,,,,,I2C3_SCL,SPI5_MISO,,,,,,ETH_MII_RXD3,FMC_SDCKE1,DCMI_D9,,EVENTOUT,
-PortH,PH8,,,,,I2C3_SDA,,,,,,,,FMC_D16,DCMI_HSYNC,LCD_R2,EVENTOUT,
-PortH,PH9,,,,,I2C3_SMBA,,,,,TIM12_CH2,,,FMC_D17,DCMI_D0,LCD_R3,EVENTOUT,
-PortH,PH10,,,TIM5_CH1,,I2C4_SMBA,,,,,,,,FMC_D18,DCMI_D1,LCD_R4,EVENTOUT,
-PortH,PH11,,,TIM5_CH2,,I2C4_SCL,,,,,,,,FMC_D19,DCMI_D2,LCD_R5,EVENTOUT,
-PortH,PH12,,,TIM5_CH3,,I2C4_SDA,,,,,,,,FMC_D20,DCMI_D3,LCD_R6,EVENTOUT,
-PortH,PH13,,,,TIM8_CH1N,,,,,UART4_TX,CAN1_TX,,,FMC_D21,,LCD_G2,EVENTOUT,
-PortH,PH14,,,,TIM8_CH2N,,,,,UART4_RX,CAN1_RX,,,FMC_D22,DCMI_D4,LCD_G3,EVENTOUT,
-PortH,PH15,,,,TIM8_CH3N,,,,,,,,,FMC_D23,DCMI_D11,LCD_G4,EVENTOUT,
-PortI,PI0,,,TIM5_CH4,,,SPI2_NSS/I2S2_WS,,,,,,,FMC_D24,DCMI_D13,LCD_G5,EVENTOUT,
-PortI,PI1,,,,TIM8_BKIN2,,SPI2_SCK/I2S2_CK,,,,,,,FMC_D25,DCMI_D8,LCD_G6,EVENTOUT,
-PortI,PI2,,,,TIM8_CH4,,SPI2_MISO,,,,,,,FMC_D26,DCMI_D9,LCD_G7,EVENTOUT,
-PortI,PI3,,,,TIM8_ETR,,SPI2_MOSI/I2S2_SD,,,,,,,FMC_D27,DCMI_D10,,EVENTOUT,
-PortI,PI4,,,,TIM8_BKIN,,,,,,,SAI2_MCK_A,,FMC_NBL2,DCMI_D5,LCD_B4,EVENTOUT,
-PortI,PI5,,,,TIM8_CH1,,,,,,,SAI2_SCK_A,,FMC_NBL3,DCMI_VSYNC,LCD_B5,EVENTOUT,
-PortI,PI6,,,,TIM8_CH2,,,,,,,SAI2_SD_A,,FMC_D28,DCMI_D6,LCD_B6,EVENTOUT,
-PortI,PI7,,,,TIM8_CH3,,,,,,,SAI2_FS_A,,FMC_D29,DCMI_D7,LCD_B7,EVENTOUT,
-PortI,PI8,,,,,,,,,,,,,,,,EVENTOUT,
-PortI,PI9,,,,,,,,,UART4_RX,CAN1_RX,,,FMC_D30,,LCD_VSYNC,EVENTOUT,
-PortI,PI10,,,,,,,,,,,,ETH_MII_RX_ER,FMC_D31,,LCD_HSYNC,EVENTOUT,
-PortI,PI11,,,,,,,,,,LCD_G6,OTG_HS_ULPI_DIR,,,,,EVENTOUT,
-PortI,PI12,,,,,,,,,,,,,,,LCD_HSYNC,EVENTOUT,
-PortI,PI13,,,,,,,,,,,,,,,LCD_VSYNC,EVENTOUT,
-PortI,PI14,,,,,,,,,,,,,,,LCD_CLK,EVENTOUT,
-PortI,PI15,,,,,,,,,,LCD_G2,,,,,LCD_R0,EVENTOUT,
-PortJ,PJ0,,,,,,,,,,LCD_R7,,,,,LCD_R1,EVENTOUT,
-PortJ,PJ1,,,,,,,,,,,,,,,LCD_R2,EVENTOUT,
-PortJ,PJ2,,,,,,,,,,,,,,DSI_TE,LCD_R3,EVENTOUT,
-PortJ,PJ3,,,,,,,,,,,,,,,LCD_R4,EVENTOUT,
-PortJ,PJ4,,,,,,,,,,,,,,,LCD_R5,EVENTOUT,
-PortJ,PJ5,,,,,,,,,,,,,,,LCD_R6,EVENTOUT,
-PortJ,PJ6,,,,,,,,,,,,,,,LCD_R7,EVENTOUT,
-PortJ,PJ7,,,,,,,,,,,,,,,LCD_G0,EVENTOUT,
-PortJ,PJ8,,,,,,,,,,,,,,,LCD_G1,EVENTOUT,
-PortJ,PJ9,,,,,,,,,,,,,,,LCD_G2,EVENTOUT,
-PortJ,PJ10,,,,,,,,,,,,,,,LCD_G3,EVENTOUT,
-PortJ,PJ11,,,,,,,,,,,,,,,LCD_G4,EVENTOUT,
-PortJ,PJ12,,,,,,,,,,LCD_G3,,,,,LCD_B0,EVENTOUT,
-PortJ,PJ13,,,,,,,,,,LCD_G4,,,,,LCD_B1,EVENTOUT,
-PortJ,PJ14,,,,,,,,,,,,,,,LCD_B2,EVENTOUT,
-PortJ,PJ15,,,,,,,,,,,,,,,LCD_B3,EVENTOUT,
-PortK,PK0,,,,,,,,,,,,,,,LCD_G5,EVENTOUT,
-PortK,PK1,,,,,,,,,,,,,,,LCD_G6,EVENTOUT,
-PortK,PK2,,,,,,,,,,,,,,,LCD_G7,EVENTOUT,
-PortK,PK3,,,,,,,,,,,,,,,LCD_B4,EVENTOUT,
-PortK,PK4,,,,,,,,,,,,,,,LCD_B5,EVENTOUT,
-PortK,PK5,,,,,,,,,,,,,,,LCD_B6,EVENTOUT,
-PortK,PK6,,,,,,,,,,,,,,,LCD_B7,EVENTOUT,
-PortK,PK7,,,,,,,,,,,,,,,LCD_DE,EVENTOUT,
diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk
index 815ee2e62..a39e0c9dd 100644
--- a/py/circuitpy_defns.mk
+++ b/py/circuitpy_defns.mk
@@ -174,6 +174,9 @@ endif
ifeq ($(CIRCUITPY__EVE),1)
SRC_PATTERNS += _eve/%
endif
+ifeq ($(CIRCUITPY_MEMORYMONITOR),1)
+SRC_PATTERNS += memorymonitor/%
+endif
ifeq ($(CIRCUITPY_MICROCONTROLLER),1)
SRC_PATTERNS += microcontroller/%
endif
@@ -398,6 +401,9 @@ SRC_SHARED_MODULE_ALL = \
gamepad/__init__.c \
gamepadshift/GamePadShift.c \
gamepadshift/__init__.c \
+ memorymonitor/__init__.c \
+ memorymonitor/AllocationAlarm.c \
+ memorymonitor/AllocationSize.c \
network/__init__.c \
os/__init__.c \
random/__init__.c \
diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h
index a7853fabd..a1a7ec238 100644
--- a/py/circuitpy_mpconfig.h
+++ b/py/circuitpy_mpconfig.h
@@ -430,6 +430,16 @@ extern const struct _mp_obj_module_t _eve_module;
#define _EVE_MODULE
#endif
+#if CIRCUITPY_MEMORYMONITOR
+extern const struct _mp_obj_module_t memorymonitor_module;
+#define MEMORYMONITOR_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_memorymonitor), (mp_obj_t)&memorymonitor_module },
+#define MEMORYMONITOR_ROOT_POINTERS mp_obj_t active_allocationsizes; \
+ mp_obj_t active_allocationalarms;
+#else
+#define MEMORYMONITOR_MODULE
+#define MEMORYMONITOR_ROOT_POINTERS
+#endif
+
#if CIRCUITPY_MICROCONTROLLER
extern const struct _mp_obj_module_t microcontroller_module;
#define MICROCONTROLLER_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_microcontroller), (mp_obj_t)&microcontroller_module },
@@ -709,6 +719,7 @@ extern const struct _mp_obj_module_t watchdog_module;
JSON_MODULE \
MATH_MODULE \
_EVE_MODULE \
+ MEMORYMONITOR_MODULE \
MICROCONTROLLER_MODULE \
NEOPIXEL_WRITE_MODULE \
NETWORK_MODULE \
@@ -766,6 +777,7 @@ extern const struct _mp_obj_module_t watchdog_module;
mp_obj_t terminal_tilegrid_tiles; \
BOARD_UART_ROOT_POINTER \
FLASH_ROOT_POINTERS \
+ MEMORYMONITOR_ROOT_POINTERS \
NETWORK_ROOT_POINTERS \
void supervisor_run_background_tasks_if_tick(void);
diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk
index 2d4a5ecee..baa29e26b 100644
--- a/py/circuitpy_mpconfig.mk
+++ b/py/circuitpy_mpconfig.mk
@@ -118,6 +118,9 @@ CFLAGS += -DCIRCUITPY_MATH=$(CIRCUITPY_MATH)
CIRCUITPY__EVE ?= 0
CFLAGS += -DCIRCUITPY__EVE=$(CIRCUITPY__EVE)
+CIRCUITPY_MEMORYMONITOR ?= 0
+CFLAGS += -DCIRCUITPY_MEMORYMONITOR=$(CIRCUITPY_MEMORYMONITOR)
+
CIRCUITPY_MICROCONTROLLER ?= 1
CFLAGS += -DCIRCUITPY_MICROCONTROLLER=$(CIRCUITPY_MICROCONTROLLER)
diff --git a/py/compile.c b/py/compile.c
index 470811005..9b0d29998 100644
--- a/py/compile.c
+++ b/py/compile.c
@@ -1890,7 +1890,7 @@ STATIC void compile_async_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
// async def
compile_funcdef(comp, pns0);
scope_t *fscope = (scope_t*)pns0->nodes[4];
- fscope->scope_flags |= MP_SCOPE_FLAG_GENERATOR;
+ fscope->scope_flags |= MP_SCOPE_FLAG_GENERATOR | MP_SCOPE_FLAG_ASYNC;
} else if (MP_PARSE_NODE_STRUCT_KIND(pns0) == PN_for_stmt) {
// async for
compile_async_for_stmt(comp, pns0);
diff --git a/py/emitglue.c b/py/emitglue.c
index 3a3174b0f..7635a73d6 100644
--- a/py/emitglue.c
+++ b/py/emitglue.c
@@ -152,7 +152,7 @@ mp_obj_t mp_make_function_from_raw_code(const mp_raw_code_t *rc, mp_obj_t def_ar
// check for generator functions and if so wrap in generator object
if ((rc->scope_flags & MP_SCOPE_FLAG_GENERATOR) != 0) {
- fun = mp_obj_new_gen_wrap(fun);
+ fun = mp_obj_new_gen_wrap(fun, (rc->scope_flags & MP_SCOPE_FLAG_ASYNC) != 0);
}
return fun;
diff --git a/py/gc.c b/py/gc.c
index 2f3f63522..69327060f 100755
--- a/py/gc.c
+++ b/py/gc.c
@@ -33,6 +33,10 @@
#include "supervisor/shared/safe_mode.h"
+#if CIRCUITPY_MEMORYMONITOR
+#include "shared-module/memorymonitor/__init__.h"
+#endif
+
#if MICROPY_ENABLE_GC
#if MICROPY_DEBUG_VERBOSE // print debugging info
@@ -653,6 +657,10 @@ void *gc_alloc(size_t n_bytes, bool has_finaliser, bool long_lived) {
gc_dump_alloc_table();
#endif
+ #if CIRCUITPY_MEMORYMONITOR
+ memorymonitor_track_allocation(end_block - start_block + 1);
+ #endif
+
return ret_ptr;
}
@@ -906,6 +914,10 @@ void *gc_realloc(void *ptr_in, size_t n_bytes, bool allow_move) {
gc_log_change(block, new_blocks);
#endif
+ #if CIRCUITPY_MEMORYMONITOR
+ memorymonitor_track_allocation(new_blocks);
+ #endif
+
return ptr_in;
}
@@ -935,6 +947,10 @@ void *gc_realloc(void *ptr_in, size_t n_bytes, bool allow_move) {
gc_log_change(block, new_blocks);
#endif
+ #if CIRCUITPY_MEMORYMONITOR
+ memorymonitor_track_allocation(new_blocks);
+ #endif
+
return ptr_in;
}
diff --git a/py/obj.h b/py/obj.h
index 8536e3333..e603d4a49 100644
--- a/py/obj.h
+++ b/py/obj.h
@@ -665,7 +665,7 @@ mp_obj_t mp_obj_new_fun_bc(mp_obj_t def_args, mp_obj_t def_kw_args, const byte *
mp_obj_t mp_obj_new_fun_native(mp_obj_t def_args_in, mp_obj_t def_kw_args, const void *fun_data, const mp_uint_t *const_table);
mp_obj_t mp_obj_new_fun_viper(size_t n_args, void *fun_data, mp_uint_t type_sig);
mp_obj_t mp_obj_new_fun_asm(size_t n_args, void *fun_data, mp_uint_t type_sig);
-mp_obj_t mp_obj_new_gen_wrap(mp_obj_t fun);
+mp_obj_t mp_obj_new_gen_wrap(mp_obj_t fun, bool is_coroutine);
mp_obj_t mp_obj_new_closure(mp_obj_t fun, size_t n_closed, const mp_obj_t *closed);
mp_obj_t mp_obj_new_tuple(size_t n, const mp_obj_t *items);
mp_obj_t mp_obj_new_list(size_t n, mp_obj_t *items);
diff --git a/py/objgenerator.c b/py/objgenerator.c
index 6ffcfae46..df421b60c 100644
--- a/py/objgenerator.c
+++ b/py/objgenerator.c
@@ -42,11 +42,13 @@
typedef struct _mp_obj_gen_wrap_t {
mp_obj_base_t base;
mp_obj_t *fun;
+ bool coroutine_generator;
} mp_obj_gen_wrap_t;
typedef struct _mp_obj_gen_instance_t {
mp_obj_base_t base;
mp_obj_dict_t *globals;
+ bool coroutine_generator;
mp_code_state_t code_state;
} mp_obj_gen_instance_t;
@@ -64,6 +66,7 @@ STATIC mp_obj_t gen_wrap_call(mp_obj_t self_in, size_t n_args, size_t n_kw, cons
n_state * sizeof(mp_obj_t) + n_exc_stack * sizeof(mp_exc_stack_t));
o->base.type = &mp_type_gen_instance;
+ o->coroutine_generator = self->coroutine_generator;
o->globals = self_fun->globals;
o->code_state.fun_bc = self_fun;
o->code_state.ip = 0;
@@ -78,10 +81,11 @@ const mp_obj_type_t mp_type_gen_wrap = {
.unary_op = mp_generic_unary_op,
};
-mp_obj_t mp_obj_new_gen_wrap(mp_obj_t fun) {
+mp_obj_t mp_obj_new_gen_wrap(mp_obj_t fun, bool is_coroutine) {
mp_obj_gen_wrap_t *o = m_new_obj(mp_obj_gen_wrap_t);
o->base.type = &mp_type_gen_wrap;
o->fun = MP_OBJ_TO_PTR(fun);
+ o->coroutine_generator = is_coroutine;
return MP_OBJ_FROM_PTR(o);
}
@@ -91,6 +95,12 @@ mp_obj_t mp_obj_new_gen_wrap(mp_obj_t fun) {
STATIC void gen_instance_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
(void)kind;
mp_obj_gen_instance_t *self = MP_OBJ_TO_PTR(self_in);
+#if MICROPY_PY_ASYNC_AWAIT
+ if (self->coroutine_generator) {
+ mp_printf(print, "<coroutine object '%q' at %p>", mp_obj_fun_get_name(MP_OBJ_FROM_PTR(self->code_state.fun_bc)), self);
+ return;
+ }
+#endif
mp_printf(print, "<generator object '%q' at %p>", mp_obj_fun_get_name(MP_OBJ_FROM_PTR(self->code_state.fun_bc)), self);
}
@@ -194,6 +204,13 @@ STATIC mp_obj_t gen_resume_and_raise(mp_obj_t self_in, mp_obj_t send_value, mp_o
}
STATIC mp_obj_t gen_instance_iternext(mp_obj_t self_in) {
+#if MICROPY_PY_ASYNC_AWAIT
+ // This translate is literally too much for m0 boards
+ mp_obj_gen_instance_t *self = MP_OBJ_TO_PTR(self_in);
+ if (self->coroutine_generator) {
+ mp_raise_TypeError(translate("'coroutine' object is not an iterator"));
+ }
+#endif
return gen_resume_and_raise(self_in, mp_const_none, MP_OBJ_NULL);
}
diff --git a/py/objstr.h b/py/objstr.h
index 4b5e2054e..cddc6a83a 100644
--- a/py/objstr.h
+++ b/py/objstr.h
@@ -77,8 +77,8 @@ const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, s
mp_obj_t index, bool is_slice);
const byte *find_subbytes(const byte *haystack, size_t hlen, const byte *needle, size_t nlen, int direction);
-const char nibble_to_hex_upper[16];
-const char nibble_to_hex_lower[16];
+extern const char nibble_to_hex_upper[16];
+extern const char nibble_to_hex_lower[16];
MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(str_encode_obj);
MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(str_find_obj);
diff --git a/py/py.mk b/py/py.mk
index 3cb505920..3e1d7989f 100644
--- a/py/py.mk
+++ b/py/py.mk
@@ -346,6 +346,11 @@ $(HEADER_BUILD)/qstrdefs.generated.h: $(PY_SRC)/makeqstrdata.py $(HEADER_BUILD)/
$(PY_BUILD)/qstr.o: $(HEADER_BUILD)/qstrdefs.generated.h
+# Standard C functions like memset need to be compiled with special flags so
+# the compiler does not optimise these functions in terms of themselves.
+CFLAGS_BUILTIN ?= -ffreestanding -fno-builtin -fno-lto
+$(BUILD)/lib/libc/string0.o: CFLAGS += $(CFLAGS_BUILTIN)
+
# Force nlr code to always be compiled with space-saving optimisation so
# that the function preludes are of a minimal and predictable form.
$(PY_BUILD)/nlr%.o: CFLAGS += -Os
diff --git a/py/runtime0.h b/py/runtime0.h
index a8089ea64..fb35c8a9f 100644
--- a/py/runtime0.h
+++ b/py/runtime0.h
@@ -33,6 +33,7 @@
#define MP_SCOPE_FLAG_VARKEYWORDS (0x02)
#define MP_SCOPE_FLAG_GENERATOR (0x04)
#define MP_SCOPE_FLAG_DEFKWARGS (0x08)
+#define MP_SCOPE_FLAG_ASYNC (0x10)
// types for native (viper) function signature
#define MP_NATIVE_TYPE_OBJ (0x00)
diff --git a/shared-bindings/_bleio/Adapter.c b/shared-bindings/_bleio/Adapter.c
index 13acb9d3c..75212fa91 100644
--- a/shared-bindings/_bleio/Adapter.c
+++ b/shared-bindings/_bleio/Adapter.c
@@ -65,13 +65,13 @@
//| connections and also initiate connections."""
//|
-//| def __init__(self, ):
+//| def __init__(self) -> None:
//| """You cannot create an instance of `_bleio.Adapter`.
//| Use `_bleio.adapter` to access the sole instance available."""
//| ...
//|
-//| enabled: Any = ...
+//| enabled: bool = ...
//| """State of the BLE adapter."""
//|
STATIC mp_obj_t bleio_adapter_get_enabled(mp_obj_t self) {
@@ -95,7 +95,7 @@ const mp_obj_property_t bleio_adapter_enabled_obj = {
(mp_obj_t)&mp_const_none_obj },
};
-//| address: Any = ...
+//| address: Address = ...
//| """MAC address of the BLE adapter. (read-only)"""
//|
STATIC mp_obj_t bleio_adapter_get_address(mp_obj_t self) {
@@ -111,7 +111,7 @@ const mp_obj_property_t bleio_adapter_address_obj = {
(mp_obj_t)&mp_const_none_obj },
};
-//| name: Any = ...
+//| name: str = ...
//| """name of the BLE adapter used once connected.
//| The name is "CIRCUITPY" + the last four hex digits of ``adapter.address``,
//| to make it easy to distinguish multiple CircuitPython boards."""
@@ -135,7 +135,7 @@ const mp_obj_property_t bleio_adapter_name_obj = {
(mp_obj_t)&mp_const_none_obj },
};
-//| def start_advertising(self, data: buf, *, scan_response: buf = None, connectable: bool = True, anonymous: bool = False, timeout: int = 0, interval: float = 0.1) -> Any:
+//| def start_advertising(self, data: buf, *, scan_response: buf = None, connectable: bool = True, anonymous: bool = False, timeout: int = 0, interval: float = 0.1) -> None:
//| """Starts advertising until `stop_advertising` is called or if connectable, another device
//| connects to us.
//|
@@ -202,7 +202,7 @@ STATIC mp_obj_t bleio_adapter_start_advertising(mp_uint_t n_args, const mp_obj_t
}
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_adapter_start_advertising_obj, 2, bleio_adapter_start_advertising);
-//| def stop_advertising(self, ) -> Any:
+//| def stop_advertising(self) -> None:
//| """Stop sending advertising packets."""
//| ...
//|
@@ -215,7 +215,7 @@ STATIC mp_obj_t bleio_adapter_stop_advertising(mp_obj_t self_in) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_adapter_stop_advertising_obj, bleio_adapter_stop_advertising);
-//| def start_scan(self, prefixes: sequence = b"", *, buffer_size: int = 512, extended: bool = False, timeout: float = None, interval: float = 0.1, window: float = 0.1, minimum_rssi: int = -80, active: bool = True) -> Any:
+//| def start_scan(self, prefixes: sequence = b"", *, buffer_size: int = 512, extended: bool = False, timeout: float = None, interval: float = 0.1, window: float = 0.1, minimum_rssi: int = -80, active: bool = True) -> iterable:
//| """Starts a BLE scan and returns an iterator of results. Advertisements and scan responses are
//| filtered and returned separately.
//|
@@ -288,7 +288,7 @@ STATIC mp_obj_t bleio_adapter_start_scan(size_t n_args, const mp_obj_t *pos_args
}
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_adapter_start_scan_obj, 1, bleio_adapter_start_scan);
-//| def stop_scan(self, ) -> Any:
+//| def stop_scan(self) -> None:
//| """Stop the current scan."""
//| ...
//|
@@ -301,7 +301,7 @@ STATIC mp_obj_t bleio_adapter_stop_scan(mp_obj_t self_in) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_adapter_stop_scan_obj, bleio_adapter_stop_scan);
-//| advertising: Any = ...
+//| advertising: bool = ...
//| """True when the adapter is currently advertising. (read-only)"""
//|
STATIC mp_obj_t bleio_adapter_get_advertising(mp_obj_t self) {
@@ -317,7 +317,7 @@ const mp_obj_property_t bleio_adapter_advertising_obj = {
(mp_obj_t)&mp_const_none_obj },
};
-//| connected: Any = ...
+//| connected: bool = ...
//| """True when the adapter is connected to another device regardless of who initiated the
//| connection. (read-only)"""
//|
@@ -334,7 +334,7 @@ const mp_obj_property_t bleio_adapter_connected_obj = {
(mp_obj_t)&mp_const_none_obj },
};
-//| connections: Any = ...
+//| connections: tuple = ...
//| """Tuple of active connections including those initiated through
//| :py:meth:`_bleio.Adapter.connect`. (read-only)"""
//|
@@ -350,7 +350,7 @@ const mp_obj_property_t bleio_adapter_connections_obj = {
(mp_obj_t)&mp_const_none_obj },
};
-//| def connect(self, address: Address, *, timeout: float/int) -> Any:
+//| def connect(self, address: Address, *, timeout: float/int) -> Connection:
//| """Attempts a connection to the device with the given address.
//|
//| :param Address address: The address of the peripheral to connect to
@@ -380,7 +380,7 @@ STATIC mp_obj_t bleio_adapter_connect(mp_uint_t n_args, const mp_obj_t *pos_args
}
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_adapter_connect_obj, 2, bleio_adapter_connect);
-//| def erase_bonding(self, ) -> Any:
+//| def erase_bonding(self) -> None:
//| """Erase all bonding information stored in flash memory."""
//| ...
//|
diff --git a/shared-bindings/_bleio/Address.c b/shared-bindings/_bleio/Address.c
index 9beaff2ab..2481a9199 100644
--- a/shared-bindings/_bleio/Address.c
+++ b/shared-bindings/_bleio/Address.c
@@ -38,7 +38,7 @@
//| """Encapsulates the address of a BLE device."""
//|
-//| def __init__(self, address: buf, address_type: Any):
+//| def __init__(self, address: ReadableBuffer, address_type: int) -> None:
//| """Create a new Address object encapsulating the address value.
//| The value itself can be one of:
//|
@@ -77,8 +77,8 @@ STATIC mp_obj_t bleio_address_make_new(const mp_obj_type_t *type, size_t n_args,
return MP_OBJ_FROM_PTR(self);
}
-//| address_bytes: Any = ...
-//| r"""The bytes that make up the device address (read-only).
+//| address_bytes: bytes = ...
+//| """The bytes that make up the device address (read-only).
//|
//| Note that the ``bytes`` object returned is in little-endian order:
//| The least significant byte is ``address_bytes[0]``. So the address will
@@ -108,7 +108,7 @@ const mp_obj_property_t bleio_address_address_bytes_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| type: Any = ...
+//| type: int = ...
//| """The address type (read-only).
//|
//| One of the integer values: `PUBLIC`, `RANDOM_STATIC`, `RANDOM_PRIVATE_RESOLVABLE`,
@@ -128,7 +128,7 @@ const mp_obj_property_t bleio_address_type_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| def __eq__(self, other: Any) -> Any:
+//| def __eq__(self, other: Any) -> bool:
//| """Two Address objects are equal if their addresses and address types are equal."""
//| ...
//|
@@ -154,7 +154,7 @@ STATIC mp_obj_t bleio_address_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_o
}
}
-//| def __hash__(self, ) -> Any:
+//| def __hash__(self) -> int:
//| """Returns a hash for the Address data."""
//| ...
//|
@@ -187,17 +187,17 @@ STATIC void bleio_address_print(const mp_print_t *print, mp_obj_t self_in, mp_pr
buf[5], buf[4], buf[3], buf[2], buf[1], buf[0]);
}
-//| PUBLIC: Any = ...
+//| PUBLIC: int = ...
//| """A publicly known address, with a company ID (high 24 bits)and company-assigned part (low 24 bits)."""
//|
-//| RANDOM_STATIC: Any = ...
+//| RANDOM_STATIC: int = ...
//| """A randomly generated address that does not change often. It may never change or may change after
//| a power cycle."""
//|
-//| RANDOM_PRIVATE_RESOLVABLE: Any = ...
+//| RANDOM_PRIVATE_RESOLVABLE: int = ...
//| """An address that is usable when the peer knows the other device's secret Identity Resolving Key (IRK)."""
//|
-//| RANDOM_PRIVATE_NON_RESOLVABLE: Any = ...
+//| RANDOM_PRIVATE_NON_RESOLVABLE: int = ...
//| """A randomly generated address that changes on every connection."""
//|
STATIC const mp_rom_map_elem_t bleio_address_locals_dict_table[] = {
diff --git a/shared-bindings/_bleio/Attribute.c b/shared-bindings/_bleio/Attribute.c
index 6c47c87ba..7d91c9378 100644
--- a/shared-bindings/_bleio/Attribute.c
+++ b/shared-bindings/_bleio/Attribute.c
@@ -36,32 +36,32 @@
//| :py:class:`~Characteristic` and :py:class:`~Descriptor`,
//| but is not defined as a Python superclass of those classes."""
//|
-//| def __init__(self, ):
+//| def __init__(self) -> None:
//| """You cannot create an instance of :py:class:`~_bleio.Attribute`."""
//| ...
//|
STATIC const mp_rom_map_elem_t bleio_attribute_locals_dict_table[] = {
-//| NO_ACCESS: Any = ...
+//| NO_ACCESS: int = ...
//| """security mode: access not allowed"""
//|
-//| OPEN: Any = ...
+//| OPEN: int = ...
//| """security_mode: no security (link is not encrypted)"""
//|
-//| ENCRYPT_NO_MITM: Any = ...
+//| ENCRYPT_NO_MITM: int = ...
//| """security_mode: unauthenticated encryption, without man-in-the-middle protection"""
//|
-//| ENCRYPT_WITH_MITM: Any = ...
+//| ENCRYPT_WITH_MITM: int = ...
//| """security_mode: authenticated encryption, with man-in-the-middle protection"""
//|
-//| LESC_ENCRYPT_WITH_MITM: Any = ...
+//| LESC_ENCRYPT_WITH_MITM: int = ...
//| """security_mode: LESC encryption, with man-in-the-middle protection"""
//|
-//| SIGNED_NO_MITM: Any = ...
+//| SIGNED_NO_MITM: int = ...
//| """security_mode: unauthenticated data signing, without man-in-the-middle protection"""
//|
-//| SIGNED_WITH_MITM: Any = ...
+//| SIGNED_WITH_MITM: int = ...
//| """security_mode: authenticated data signing, without man-in-the-middle protection"""
//|
{ MP_ROM_QSTR(MP_QSTR_NO_ACCESS), MP_ROM_INT(SECURITY_MODE_NO_ACCESS) },
diff --git a/shared-bindings/_bleio/Characteristic.c b/shared-bindings/_bleio/Characteristic.c
index 785b677d6..593d8edcb 100644
--- a/shared-bindings/_bleio/Characteristic.c
+++ b/shared-bindings/_bleio/Characteristic.c
@@ -37,7 +37,7 @@
//| """Stores information about a BLE service characteristic and allows reading
//| and writing of the characteristic's value."""
//|
-//| def __init__(self, ):
+//| def __init__(self) -> None:
//| """There is no regular constructor for a Characteristic. A new local Characteristic can be created
//| and attached to a Service by calling `add_to_service()`.
//| Remote Characteristic objects are created by `Connection.discover_remote_services()`
@@ -45,7 +45,7 @@
//| ...
//|
-//| def add_to_service(self, service: Service, uuid: UUID, *, properties: int = 0, read_perm: int = Attribute.OPEN, write_perm: int = Attribute.OPEN, max_length: int = 20, fixed_length: bool = False, initial_value: buf = None) -> Any:
+//| def add_to_service(self, service: Service, uuid: UUID, *, properties: int = 0, read_perm: int = Attribute.OPEN, write_perm: int = Attribute.OPEN, max_length: int = 20, fixed_length: bool = False, initial_value: buf = None) -> Characteristic:
//| """Create a new Characteristic object, and add it to this Service.
//|
//| :param Service service: The service that will provide this characteristic
@@ -141,7 +141,7 @@ STATIC MP_DEFINE_CONST_CLASSMETHOD_OBJ(bleio_characteristic_add_to_service_obj,
-//| properties: Any = ...
+//| properties: int = ...
//| """An int bitmask representing which properties are set, specified as bitwise or'ing of
//| of these possible values.
//| `BROADCAST`, `INDICATE`, `NOTIFY`, `READ`, `WRITE`, `WRITE_NO_RESPONSE`."""
@@ -160,7 +160,7 @@ const mp_obj_property_t bleio_characteristic_properties_obj = {
(mp_obj_t)&mp_const_none_obj },
};
-//| uuid: Any = ...
+//| uuid: Optional[UUID] = ...
//| """The UUID of this characteristic. (read-only)
//|
//| Will be ``None`` if the 128-bit UUID for this characteristic is not known."""
@@ -180,7 +180,7 @@ const mp_obj_property_t bleio_characteristic_uuid_obj = {
(mp_obj_t)&mp_const_none_obj },
};
-//| value: Any = ...
+//| value: bytearray = ...
//| """The value of this characteristic."""
//|
STATIC mp_obj_t bleio_characteristic_get_value(mp_obj_t self_in) {
@@ -211,7 +211,7 @@ const mp_obj_property_t bleio_characteristic_value_obj = {
(mp_obj_t)&mp_const_none_obj },
};
-//| descriptors: Any = ...
+//| descriptors: Descriptor = ...
//| """A tuple of :py:class:`Descriptor` that describe this characteristic. (read-only)"""
//|
STATIC mp_obj_t bleio_characteristic_get_descriptors(mp_obj_t self_in) {
@@ -241,7 +241,7 @@ const mp_obj_property_t bleio_characteristic_descriptors_obj = {
(mp_obj_t)&mp_const_none_obj },
};
-//| service: Any = ...
+//| service: Service = ...
//| """The Service this Characteristic is a part of."""
//|
STATIC mp_obj_t bleio_characteristic_get_service(mp_obj_t self_in) {
@@ -258,7 +258,7 @@ const mp_obj_property_t bleio_characteristic_service_obj = {
(mp_obj_t)&mp_const_none_obj },
};
-//| def set_cccd(self, *, notify: bool = False, indicate: float = False) -> Any:
+//| def set_cccd(self, *, notify: bool = False, indicate: float = False) -> None:
//| """Set the remote characteristic's CCCD to enable or disable notification and indication.
//|
//| :param bool notify: True if Characteristic should receive notifications of remote writes
@@ -291,22 +291,22 @@ STATIC const mp_rom_map_elem_t bleio_characteristic_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_set_cccd), MP_ROM_PTR(&bleio_characteristic_set_cccd_obj) },
// Bitmask constants to represent properties
-//| BROADCAST: Any = ...
+//| BROADCAST: int = ...
//| """property: allowed in advertising packets"""
//|
-//| INDICATE: Any = ...
+//| INDICATE: int = ...
//| """property: server will indicate to the client when the value is set and wait for a response"""
//|
-//| NOTIFY: Any = ...
+//| NOTIFY: int = ...
//| """property: server will notify the client when the value is set"""
//|
-//| READ: Any = ...
+//| READ: int = ...
//| """property: clients may read this characteristic"""
//|
-//| WRITE: Any = ...
+//| WRITE: int = ...
//| """property: clients may write this characteristic; a response will be sent back"""
//|
-//| WRITE_NO_RESPONSE: Any = ...
+//| WRITE_NO_RESPONSE: int = ...
//| """property: clients may write this characteristic; no response will be sent back"""
//|
{ MP_ROM_QSTR(MP_QSTR_BROADCAST), MP_ROM_INT(CHAR_PROP_BROADCAST) },
diff --git a/shared-bindings/_bleio/CharacteristicBuffer.c b/shared-bindings/_bleio/CharacteristicBuffer.c
index 6cbd587c6..24d7a26b6 100644
--- a/shared-bindings/_bleio/CharacteristicBuffer.c
+++ b/shared-bindings/_bleio/CharacteristicBuffer.c
@@ -44,7 +44,7 @@ STATIC void raise_error_if_not_connected(bleio_characteristic_buffer_obj_t *self
//| class CharacteristicBuffer:
//| """Accumulates a Characteristic's incoming values in a FIFO buffer."""
//|
-//| def __init__(self, characteristic: Characteristic, *, timeout: int = 1, buffer_size: int = 64):
+//| def __init__(self, characteristic: Characteristic, *, timeout: int = 1, buffer_size: int = 64) -> None:
//|
//| """Monitor the given Characteristic. Each time a new value is written to the Characteristic
//| add the newly-written bytes to a FIFO buffer.
@@ -100,7 +100,7 @@ STATIC void check_for_deinit(bleio_characteristic_buffer_obj_t *self) {
// These are standard stream methods. Code is in py/stream.c.
//
-//| def read(self, nbytes: Any = None) -> Any:
+//| def read(self, nbytes: int = None) -> Optional[bytes]:
//| """Read characters. If ``nbytes`` is specified then read at most that many
//| bytes. Otherwise, read everything that arrives until the connection
//| times out. Providing the number of bytes expected is highly recommended
@@ -110,14 +110,14 @@ STATIC void check_for_deinit(bleio_characteristic_buffer_obj_t *self) {
//| :rtype: bytes or None"""
//| ...
//|
-//| def readinto(self, buf: Any) -> Any:
+//| def readinto(self, buf: WriteableBuffer) -> Optional[int]:
//| """Read bytes into the ``buf``. Read at most ``len(buf)`` bytes.
//|
//| :return: number of bytes read and stored into ``buf``
//| :rtype: int or None (on a non-blocking error)"""
//| ...
//|
-//| def readline(self, ) -> Any:
+//| def readline(self) -> bytes:
//| """Read a line, ending in a newline character.
//|
//| :return: the line read
@@ -167,7 +167,7 @@ STATIC mp_uint_t bleio_characteristic_buffer_ioctl(mp_obj_t self_in, mp_uint_t r
return ret;
}
-//| in_waiting: Any = ...
+//| in_waiting: int = ...
//| """The number of bytes in the input buffer, available to be read"""
//|
STATIC mp_obj_t bleio_characteristic_buffer_obj_get_in_waiting(mp_obj_t self_in) {
@@ -184,7 +184,7 @@ const mp_obj_property_t bleio_characteristic_buffer_in_waiting_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| def reset_input_buffer(self, ) -> Any:
+//| def reset_input_buffer(self) -> None:
//| """Discard any unread characters in the input buffer."""
//| ...
//|
@@ -196,7 +196,7 @@ STATIC mp_obj_t bleio_characteristic_buffer_obj_reset_input_buffer(mp_obj_t self
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_characteristic_buffer_reset_input_buffer_obj, bleio_characteristic_buffer_obj_reset_input_buffer);
-//| def deinit(self, ) -> Any:
+//| def deinit(self) -> None:
//| """Disable permanently."""
//| ...
//|
diff --git a/shared-bindings/_bleio/Connection.c b/shared-bindings/_bleio/Connection.c
index 0a96d8a11..5dfbc5a36 100644
--- a/shared-bindings/_bleio/Connection.c
+++ b/shared-bindings/_bleio/Connection.c
@@ -68,13 +68,13 @@ void bleio_connection_ensure_connected(bleio_connection_obj_t *self) {
}
}
-//| def __init__(self, ):
+//| def __init__(self) -> None:
//| """Connections cannot be made directly. Instead, to initiate a connection use `Adapter.connect`.
//| Connections may also be made when another device initiates a connection. To use a Connection
//| created by a peer, read the `Adapter.connections` property.
//| ...
//|
-//| def disconnect(self, ) -> Any:
+//| def disconnect(self) -> Any:
//| ""Disconnects from the remote peripheral. Does nothing if already disconnected."""
//| ...
//|
@@ -87,7 +87,7 @@ STATIC mp_obj_t bleio_connection_disconnect(mp_obj_t self_in) {
STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_connection_disconnect_obj, bleio_connection_disconnect);
-//| def pair(self, *, bond: Any = True) -> Any:
+//| def pair(self, *, bond: bool = True) -> None:
//| """Pair to the peer to improve security."""
//| ...
//|
@@ -109,7 +109,7 @@ STATIC mp_obj_t bleio_connection_pair(mp_uint_t n_args, const mp_obj_t *pos_args
}
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_connection_pair_obj, 1, bleio_connection_pair);
-//| def discover_remote_services(self, service_uuids_whitelist: iterable = None) -> Any:
+//| def discover_remote_services(self, service_uuids_whitelist: iterable = None) -> Service:
//| """Do BLE discovery for all services or for the given service UUIDS,
//| to find their handles and characteristics, and return the discovered services.
//| `Connection.connected` must be True.
@@ -152,7 +152,7 @@ STATIC mp_obj_t bleio_connection_discover_remote_services(mp_uint_t n_args, cons
}
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_connection_discover_remote_services_obj, 1, bleio_connection_discover_remote_services);
-//| connected: Any = ...
+//| connected: bool = ...
//| """True if connected to the remote peer."""
//|
STATIC mp_obj_t bleio_connection_get_connected(mp_obj_t self_in) {
@@ -170,7 +170,7 @@ const mp_obj_property_t bleio_connection_connected_obj = {
};
-//| paired: Any = ...
+//| paired: bool = ...
//| """True if paired to the remote peer."""
//|
STATIC mp_obj_t bleio_connection_get_paired(mp_obj_t self_in) {
@@ -188,7 +188,7 @@ const mp_obj_property_t bleio_connection_paired_obj = {
};
-//| connection_interval: Any = ...
+//| connection_interval: float = ...
//| """Time between transmissions in milliseconds. Will be multiple of 1.25ms. Lower numbers
//| increase speed and decrease latency but increase power consumption.
//|
@@ -206,7 +206,7 @@ STATIC mp_obj_t bleio_connection_get_connection_interval(mp_obj_t self_in) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_connection_get_connection_interval_obj, bleio_connection_get_connection_interval);
-//| attribute: Any = ...
+//| attribute: int = ...
//| """The maximum number of data bytes that can be sent in a single transmission,
//| not including overhead bytes.
//|
diff --git a/shared-bindings/_bleio/Descriptor.c b/shared-bindings/_bleio/Descriptor.c
index 9d7020849..b709fea6d 100644
--- a/shared-bindings/_bleio/Descriptor.c
+++ b/shared-bindings/_bleio/Descriptor.c
@@ -39,7 +39,7 @@
//| Descriptors are attached to BLE characteristics and provide contextual
//| information about the characteristic."""
//|
-//| def __init__(self, ):
+//| def __init__(self) -> None:
//| """There is no regular constructor for a Descriptor. A new local Descriptor can be created
//| and attached to a Characteristic by calling `add_to_characteristic()`.
//| Remote Descriptor objects are created by `Connection.discover_remote_services()`
@@ -132,7 +132,7 @@ STATIC mp_obj_t bleio_descriptor_add_to_characteristic(size_t n_args, const mp_o
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_descriptor_add_to_characteristic_fun_obj, 3, 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: Any = ...
+//| uuid: UUID = ...
//| """The descriptor uuid. (read-only)"""
//|
STATIC mp_obj_t bleio_descriptor_get_uuid(mp_obj_t self_in) {
@@ -150,7 +150,7 @@ const mp_obj_property_t bleio_descriptor_uuid_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| characteristic: Any = ...
+//| characteristic: Characteristic = ...
//| """The Characteristic this Descriptor is a part of."""
//|
STATIC mp_obj_t bleio_descriptor_get_characteristic(mp_obj_t self_in) {
@@ -167,7 +167,7 @@ const mp_obj_property_t bleio_descriptor_characteristic_obj = {
(mp_obj_t)&mp_const_none_obj },
};
-//| value: Any = ...
+//| value: WriteableBuffer = ...
//| """The value of this descriptor."""
//|
STATIC mp_obj_t bleio_descriptor_get_value(mp_obj_t self_in) {
diff --git a/shared-bindings/_bleio/PacketBuffer.c b/shared-bindings/_bleio/PacketBuffer.c
index 907bfabd2..bbdde37d5 100644
--- a/shared-bindings/_bleio/PacketBuffer.c
+++ b/shared-bindings/_bleio/PacketBuffer.c
@@ -44,7 +44,7 @@
//| When we're the server, we ignore all connections besides the first to subscribe to
//| notifications."""
//|
-//| def __init__(self, characteristic: Characteristic, *, buffer_size: int):
+//| def __init__(self, characteristic: Characteristic, *, buffer_size: int) -> None:
//| """Monitor the given Characteristic. Each time a new value is written to the Characteristic
//| add the newly-written bytes to a FIFO buffer.
//|
@@ -93,7 +93,7 @@ STATIC void check_for_deinit(bleio_packet_buffer_obj_t *self) {
}
}
-//| def readinto(self, buf: Any) -> Any:
+//| def readinto(self, buf: WriteableBuffer) -> int:
//| """Reads a single BLE packet into the ``buf``. Raises an exception if the next packet is longer
//| than the given buffer. Use `packet_size` to read the maximum length of a single packet.
//|
@@ -117,7 +117,7 @@ STATIC mp_obj_t bleio_packet_buffer_readinto(mp_obj_t self_in, mp_obj_t buffer_o
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(bleio_packet_buffer_readinto_obj, bleio_packet_buffer_readinto);
-//| def write(self, data: Any, *, header: Any = None) -> Any:
+//| def write(self, data: bytes, *, header: Optional[bytes] = None) -> int:
//| """Writes all bytes from data into the same outgoing packet. The bytes from header are included
//| before data when the pending packet is currently empty.
//|
@@ -169,7 +169,7 @@ STATIC mp_obj_t bleio_packet_buffer_write(mp_uint_t n_args, const mp_obj_t *pos_
}
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_packet_buffer_write_obj, 1, bleio_packet_buffer_write);
-//| def deinit(self) -> Any:
+//| def deinit(self) -> None:
//| """Disable permanently."""
//| ...
STATIC mp_obj_t bleio_packet_buffer_deinit(mp_obj_t self_in) {
@@ -184,7 +184,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_packet_buffer_deinit_obj, bleio_packet_bu
//| The name `packet_size` is deprecated and
//| will be removed in CircuitPython 6.0.0."""
//|
-//| incoming_packet_length: Any = ...
+//| incoming_packet_length: int = ...
//| """Maximum length in bytes of a packet we are reading."""
//|
STATIC mp_obj_t bleio_packet_buffer_get_incoming_packet_length(mp_obj_t self_in) {
diff --git a/shared-bindings/_bleio/ScanEntry.c b/shared-bindings/_bleio/ScanEntry.c
index 905bea81d..d2f0e77fd 100644
--- a/shared-bindings/_bleio/ScanEntry.c
+++ b/shared-bindings/_bleio/ScanEntry.c
@@ -41,11 +41,11 @@
//| it has no user-visible constructor."""
//|
-//| def __init__(self, ):
+//| def __init__(self) -> None:
//| """Cannot be instantiated directly. Use `_bleio.Adapter.start_scan`."""
//| ...
//|
-//| def matches(self, prefixes: Any, *, all: Any = True) -> Any:
+//| def matches(self, prefixes: ScanEntry, *, all: bool = True) -> bool:
//| """Returns True if the ScanEntry matches all prefixes when ``all`` is True. This is stricter
//| than the scan filtering which accepts any advertisements that match any of the prefixes
//| where all is False."""
@@ -70,7 +70,7 @@ STATIC mp_obj_t bleio_scanentry_matches(mp_uint_t n_args, const mp_obj_t *pos_ar
}
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_scanentry_matches_obj, 2, bleio_scanentry_matches);
-//| address: Any = ...
+//| address: Address = ...
//| """The address of the device (read-only), of type `_bleio.Address`."""
//|
STATIC mp_obj_t bleio_scanentry_get_address(mp_obj_t self_in) {
@@ -86,7 +86,7 @@ const mp_obj_property_t bleio_scanentry_address_obj = {
(mp_obj_t)&mp_const_none_obj },
};
-//| advertisement_bytes: Any = ...
+//| advertisement_bytes: bytes = ...
//| """All the advertisement data present in the packet, returned as a ``bytes`` object. (read-only)"""
//|
STATIC mp_obj_t scanentry_get_advertisement_bytes(mp_obj_t self_in) {
@@ -102,7 +102,7 @@ const mp_obj_property_t bleio_scanentry_advertisement_bytes_obj = {
(mp_obj_t)&mp_const_none_obj },
};
-//| rssi: Any = ...
+//| rssi: int = ...
//| """The signal strength of the device at the time of the scan, in integer dBm. (read-only)"""
//|
STATIC mp_obj_t scanentry_get_rssi(mp_obj_t self_in) {
@@ -118,7 +118,7 @@ const mp_obj_property_t bleio_scanentry_rssi_obj = {
(mp_obj_t)&mp_const_none_obj },
};
-//| connectable: Any = ...
+//| connectable: bool = ...
//| """True if the device can be connected to. (read-only)"""
//|
STATIC mp_obj_t scanentry_get_connectable(mp_obj_t self_in) {
@@ -134,7 +134,7 @@ const mp_obj_property_t bleio_scanentry_connectable_obj = {
(mp_obj_t)&mp_const_none_obj },
};
-//| scan_response: Any = ...
+//| scan_response: bool = ...
//| """True if the entry was a scan response. (read-only)"""
//|
STATIC mp_obj_t scanentry_get_scan_response(mp_obj_t self_in) {
diff --git a/shared-bindings/_bleio/ScanResults.c b/shared-bindings/_bleio/ScanResults.c
index 6077dcbda..9dca90c38 100644
--- a/shared-bindings/_bleio/ScanResults.c
+++ b/shared-bindings/_bleio/ScanResults.c
@@ -46,15 +46,15 @@ STATIC mp_obj_t scanresults_iternext(mp_obj_t self_in) {
return MP_OBJ_STOP_ITERATION;
}
-//| def __init__(self, ):
+//| def __init__(self) -> None:
//| """Cannot be instantiated directly. Use `_bleio.Adapter.start_scan`."""
//| ...
//|
-//| def __iter__(self, ) -> Any:
+//| def __iter__(self) -> Iterator[ScanEntry]:
//| """Returns itself since it is the iterator."""
//| ...
//|
-//| def __next__(self, ) -> Any:
+//| def __next__(self) -> ScanEntry:
//| """Returns the next `_bleio.ScanEntry`. Blocks if none have been received and scanning is still
//| active. Raises `StopIteration` if scanning is finished and no other results are available."""
//| ...
diff --git a/shared-bindings/_bleio/Service.c b/shared-bindings/_bleio/Service.c
index 5ca7504f2..65f920c58 100644
--- a/shared-bindings/_bleio/Service.c
+++ b/shared-bindings/_bleio/Service.c
@@ -35,7 +35,7 @@
//| class Service:
//| """Stores information about a BLE service and its characteristics."""
//|
-//| def __init__(self, uuid: UUID, *, secondary: bool = False):
+//| def __init__(self, uuid: UUID, *, secondary: bool = False) -> None:
//| """Create a new Service identified by the specified UUID. It can be accessed by all
//| connections. This is known as a Service server. Client Service objects are created via
//| `Connection.discover_remote_services`.
@@ -73,7 +73,7 @@ STATIC mp_obj_t bleio_service_make_new(const mp_obj_type_t *type, size_t n_args,
return MP_OBJ_FROM_PTR(service);
}
-//| characteristics: Any = ...
+//| characteristics: Tuple[Characteristic, ...] = ...
//| """A tuple of :py:class:`Characteristic` designating the characteristics that are offered by
//| this service. (read-only)"""
//|
@@ -92,7 +92,7 @@ const mp_obj_property_t bleio_service_characteristics_obj = {
(mp_obj_t)&mp_const_none_obj },
};
-//| remote: Any = ...
+//| remote: bool = ...
//| """True if this is a service provided by a remote device. (read-only)"""
//|
STATIC mp_obj_t bleio_service_get_remote(mp_obj_t self_in) {
@@ -109,7 +109,7 @@ const mp_obj_property_t bleio_service_remote_obj = {
(mp_obj_t)&mp_const_none_obj },
};
-//| secondary: Any = ...
+//| secondary: bool = ...
//| """True if this is a secondary service. (read-only)"""
//|
STATIC mp_obj_t bleio_service_get_secondary(mp_obj_t self_in) {
@@ -126,7 +126,7 @@ const mp_obj_property_t bleio_service_secondary_obj = {
(mp_obj_t)&mp_const_none_obj },
};
-//| uuid: Any = ...
+//| uuid: Optional[UUID] = ...
//| """The UUID of this service. (read-only)
//|
//| Will be ``None`` if the 128-bit UUID for this service is not known."""
diff --git a/shared-bindings/_bleio/UUID.c b/shared-bindings/_bleio/UUID.c
index 78161b956..c6706e46a 100644
--- a/shared-bindings/_bleio/UUID.c
+++ b/shared-bindings/_bleio/UUID.c
@@ -36,7 +36,7 @@
//| class UUID:
//| """A 16-bit or 128-bit UUID. Can be used for services, characteristics, descriptors and more."""
//|
-//| def __init__(self, value: Any):
+//| def __init__(self, value: Union[int, ReadableBuffer, str]) -> None:
//| """Create a new UUID or UUID object encapsulating the uuid value.
//| The value can be one of:
//|
@@ -120,7 +120,7 @@ STATIC mp_obj_t bleio_uuid_make_new(const mp_obj_type_t *type, size_t n_args, co
return MP_OBJ_FROM_PTR(self);
}
-//| uuid16: Any = ...
+//| uuid16: int = ...
//| """The 16-bit part of the UUID. (read-only)
//|
//| :type: int"""
@@ -139,7 +139,7 @@ const mp_obj_property_t bleio_uuid_uuid16_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| uuid128: Any = ...
+//| uuid128: bytes = ...
//| """The 128-bit value of the UUID
//| Raises AttributeError if this is a 16-bit UUID. (read-only)
//|
@@ -165,7 +165,7 @@ const mp_obj_property_t bleio_uuid_uuid128_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| size: Any = ...
+//| size: int = ...
//| """128 if this UUID represents a 128-bit vendor-specific UUID. 16 if this UUID represents a
//| 16-bit Bluetooth SIG assigned UUID. (read-only) 32-bit UUIDs are not currently supported.
//|
@@ -186,7 +186,7 @@ const mp_obj_property_t bleio_uuid_size_obj = {
};
-//| def pack_into(self, buffer: Any, offset: Any = 0) -> Any:
+//| def pack_into(self, buffer: WriteableBuffer, offset: int = 0) -> None:
//| """Packs the UUID into the given buffer at the given offset."""
//| ...
//|
@@ -248,7 +248,7 @@ STATIC mp_obj_t bleio_uuid_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
}
}
-//| def __eq__(self, other: Any) -> Any:
+//| def __eq__(self, other: Any) -> bool:
//| """Two UUID objects are equal if their values match and they are both 128-bit or both 16-bit."""
//| ...
//|
diff --git a/shared-bindings/_bleio/__init__.c b/shared-bindings/_bleio/__init__.c
index 90b185f79..3002ecd18 100644
--- a/shared-bindings/_bleio/__init__.c
+++ b/shared-bindings/_bleio/__init__.c
@@ -58,11 +58,9 @@
//| This object is the sole instance of `_bleio.Adapter`."""
//|
-
-//| class BluetoothError:
-//| def __init__(self, Exception: Any):
-//| """Catch all exception for Bluetooth related errors."""
-//| ...
+//| class BluetoothError(Exception):
+//| """Catchall exception for Bluetooth related errors."""
+//| ...
MP_DEFINE_BLEIO_EXCEPTION(BluetoothError, Exception)
NORETURN void mp_raise_bleio_BluetoothError(const compressed_string_t* fmt, ...) {
@@ -72,10 +70,9 @@ NORETURN void mp_raise_bleio_BluetoothError(const compressed_string_t* fmt, ...)
va_end(argptr);
nlr_raise(exception);
}
-//| class ConnectionError:
-//| def __init__(self, BluetoothError: Any):
-//| """Raised when a connection is unavailable."""
-//| ...
+//| class ConnectionError(BluetoothError):
+//| """Raised when a connection is unavailable."""
+//| ...
//|
MP_DEFINE_BLEIO_EXCEPTION(ConnectionError, bleio_BluetoothError)
NORETURN void mp_raise_bleio_ConnectionError(const compressed_string_t* fmt, ...) {
@@ -86,20 +83,18 @@ NORETURN void mp_raise_bleio_ConnectionError(const compressed_string_t* fmt, ...
nlr_raise(exception);
}
-//| class RoleError:
-//| def __init__(self, BluetoothError: Any):
-//| """Raised when a resource is used as the mismatched role. For example, if a local CCCD is
-//| attempted to be set but they can only be set when remote."""
-//| ...
+//| class RoleError(BluetoothError):
+//| """Raised when a resource is used as the mismatched role. For example, if a local CCCD is
+//| attempted to be set but they can only be set when remote."""
+//| ...
//|
MP_DEFINE_BLEIO_EXCEPTION(RoleError, bleio_BluetoothError)
NORETURN void mp_raise_bleio_RoleError(const compressed_string_t* msg) {
mp_raise_msg(&mp_type_bleio_RoleError, msg);
}
-//| class SecurityError:
-//| def __init__(self, BluetoothError: Any):
-//| """Raised when a security related error occurs."""
-//| ...
+//| class SecurityError(BluetoothError):
+//| """Raised when a security related error occurs."""
+//| ...
//|
MP_DEFINE_BLEIO_EXCEPTION(SecurityError, bleio_BluetoothError)
NORETURN void mp_raise_bleio_SecurityError(const compressed_string_t* fmt, ...) {
diff --git a/shared-bindings/_eve/__init__.c b/shared-bindings/_eve/__init__.c
index 4fa48f2c7..dd7f6f8bd 100644
--- a/shared-bindings/_eve/__init__.c
+++ b/shared-bindings/_eve/__init__.c
@@ -58,7 +58,7 @@ STATIC mp_obj_t _register(mp_obj_t self, mp_obj_t o) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(register_obj, _register);
-//| def flush(self, ) -> Any:
+//| def flush(self) -> None:
//| """Send any queued drawing commands directly to the hardware.
//|
//| :param int width: The width of the grid in tiles, or 1 for sprites."""
@@ -70,7 +70,7 @@ STATIC mp_obj_t _flush(mp_obj_t self) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(flush_obj, _flush);
-//| def cc(self, b: bytes) -> Any:
+//| def cc(self, b: bytes) -> None:
//| """Append bytes to the command FIFO.
//|
//| :param bytes b: The bytes to add"""
@@ -86,7 +86,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(cc_obj, _cc);
//{
-//| def AlphaFunc(self, func: int, ref: int) -> Any:
+//| def AlphaFunc(self, func: int, ref: int) -> None:
//| """Set the alpha test function
//|
//| :param int func: specifies the test function, one of ``NEVER``, ``LESS``, ``LEQUAL``, ``GREATER``, ``GEQUAL``, ``EQUAL``, ``NOTEQUAL``, or ``ALWAYS``. Range 0-7. The initial value is ALWAYS(7)
@@ -104,7 +104,7 @@ STATIC mp_obj_t _alphafunc(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_3(alphafunc_obj, _alphafunc);
-//| def Begin(self, prim: int) -> Any:
+//| def Begin(self, prim: int) -> None:
//| """Begin drawing a graphics primitive
//|
//| :param int prim: graphics primitive.
@@ -120,7 +120,7 @@ STATIC mp_obj_t _begin(mp_obj_t self, mp_obj_t a0) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(begin_obj, _begin);
-//| def BitmapExtFormat(self, format: int) -> Any:
+//| def BitmapExtFormat(self, format: int) -> None:
//| """Set the bitmap format
//|
//| :param int format: bitmap pixel format."""
@@ -134,7 +134,7 @@ STATIC mp_obj_t _bitmapextformat(mp_obj_t self, mp_obj_t a0) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(bitmapextformat_obj, _bitmapextformat);
-//| def BitmapHandle(self, handle: int) -> Any:
+//| def BitmapHandle(self, handle: int) -> None:
//| """Set the bitmap handle
//|
//| :param int handle: bitmap handle. Range 0-31. The initial value is 0
@@ -150,7 +150,7 @@ STATIC mp_obj_t _bitmaphandle(mp_obj_t self, mp_obj_t a0) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(bitmaphandle_obj, _bitmaphandle);
-//| def BitmapLayoutH(self, linestride: int, height: int) -> Any:
+//| def BitmapLayoutH(self, linestride: int, height: int) -> None:
//| """Set the source bitmap memory format and layout for the current handle. high bits for large bitmaps
//|
//| :param int linestride: high part of bitmap line stride, in bytes. Range 0-7
@@ -166,7 +166,7 @@ STATIC mp_obj_t _bitmaplayouth(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaplayouth_obj, _bitmaplayouth);
-//| def BitmapLayout(self, format: int, linestride: int, height: int) -> Any:
+//| def BitmapLayout(self, format: int, linestride: int, height: int) -> None:
//| """Set the source bitmap memory format and layout for the current handle
//|
//| :param int format: bitmap pixel format, or GLFORMAT to use BITMAP_EXT_FORMAT instead. Range 0-31
@@ -184,7 +184,7 @@ STATIC mp_obj_t _bitmaplayout(size_t n_args, const mp_obj_t *args) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bitmaplayout_obj, 4, 4, _bitmaplayout);
-//| def BitmapSizeH(self, width: int, height: int) -> Any:
+//| def BitmapSizeH(self, width: int, height: int) -> None:
//| """Set the screen drawing of bitmaps for the current handle. high bits for large bitmaps
//|
//| :param int width: high part of drawn bitmap width, in pixels. Range 0-3
@@ -200,7 +200,7 @@ STATIC mp_obj_t _bitmapsizeh(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmapsizeh_obj, _bitmapsizeh);
-//| def BitmapSize(self, filter: int, wrapx: int, wrapy: int, width: int, height: int) -> Any:
+//| def BitmapSize(self, filter: int, wrapx: int, wrapy: int, width: int, height: int) -> None:
//| """Set the screen drawing of bitmaps for the current handle
//|
//| :param int filter: bitmap filtering mode, one of ``NEAREST`` or ``BILINEAR``. Range 0-1
@@ -222,7 +222,7 @@ STATIC mp_obj_t _bitmapsize(size_t n_args, const mp_obj_t *args) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bitmapsize_obj, 6, 6, _bitmapsize);
-//| def BitmapSource(self, addr: int) -> Any:
+//| def BitmapSource(self, addr: int) -> None:
//| """Set the source address for bitmap graphics
//|
//| :param int addr: Bitmap start address, pixel-aligned. May be in SRAM or flash. Range 0-16777215"""
@@ -236,7 +236,7 @@ STATIC mp_obj_t _bitmapsource(mp_obj_t self, mp_obj_t a0) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(bitmapsource_obj, _bitmapsource);
-//| def BitmapSwizzle(self, r: int, g: int, b: int, a: int) -> Any:
+//| def BitmapSwizzle(self, r: int, g: int, b: int, a: int) -> None:
//| """Set the source for the r,g,b and a channels of a bitmap
//|
//| :param int r: red component source channel. Range 0-7
@@ -256,7 +256,7 @@ STATIC mp_obj_t _bitmapswizzle(size_t n_args, const mp_obj_t *args) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bitmapswizzle_obj, 5, 5, _bitmapswizzle);
-//| def BitmapTransformA(self, p: Any, v: int) -> Any:
+//| def BitmapTransformA(self, p: int, v: int) -> None:
//| """Set the :math:`a` component of the bitmap transform matrix
//|
//| :param int p: precision control: 0 is 8.8, 1 is 1.15. Range 0-1. The initial value is 0
@@ -276,7 +276,7 @@ STATIC mp_obj_t _bitmaptransforma(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransforma_obj, _bitmaptransforma);
-//| def BitmapTransformB(self, p: Any, v: int) -> Any:
+//| def BitmapTransformB(self, p: int, v: int) -> None:
//| """Set the :math:`b` component of the bitmap transform matrix
//|
//| :param int p: precision control: 0 is 8.8, 1 is 1.15. Range 0-1. The initial value is 0
@@ -296,7 +296,7 @@ STATIC mp_obj_t _bitmaptransformb(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransformb_obj, _bitmaptransformb);
-//| def BitmapTransformC(self, v: int) -> Any:
+//| def BitmapTransformC(self, v: int) -> None:
//| """Set the :math:`c` component of the bitmap transform matrix
//|
//| :param int v: The :math:`c` component of the bitmap transform matrix, in signed 15.8 bit fixed-point form. Range 0-16777215. The initial value is 0
@@ -312,7 +312,7 @@ STATIC mp_obj_t _bitmaptransformc(mp_obj_t self, mp_obj_t a0) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(bitmaptransformc_obj, _bitmaptransformc);
-//| def BitmapTransformD(self, p: Any, v: int) -> Any:
+//| def BitmapTransformD(self, p: int, v: int) -> None:
//| """Set the :math:`d` component of the bitmap transform matrix
//|
//| :param int p: precision control: 0 is 8.8, 1 is 1.15. Range 0-1. The initial value is 0
@@ -332,7 +332,7 @@ STATIC mp_obj_t _bitmaptransformd(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransformd_obj, _bitmaptransformd);
-//| def BitmapTransformE(self, p: Any, v: int) -> Any:
+//| def BitmapTransformE(self, p: int, v: int) -> None:
//| """Set the :math:`e` component of the bitmap transform matrix
//|
//| :param int p: precision control: 0 is 8.8, 1 is 1.15. Range 0-1. The initial value is 0
@@ -352,7 +352,7 @@ STATIC mp_obj_t _bitmaptransforme(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransforme_obj, _bitmaptransforme);
-//| def BitmapTransformF(self, v: int) -> Any:
+//| def BitmapTransformF(self, v: int) -> None:
//| """Set the :math:`f` component of the bitmap transform matrix
//|
//| :param int v: The :math:`f` component of the bitmap transform matrix, in signed 15.8 bit fixed-point form. Range 0-16777215. The initial value is 0
@@ -368,7 +368,7 @@ STATIC mp_obj_t _bitmaptransformf(mp_obj_t self, mp_obj_t a0) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(bitmaptransformf_obj, _bitmaptransformf);
-//| def BlendFunc(self, src: int, dst: int) -> Any:
+//| def BlendFunc(self, src: int, dst: int) -> None:
//| """Set pixel arithmetic
//|
//| :param int src: specifies how the source blending factor is computed. One of ``ZERO``, ``ONE``, ``SRC_ALPHA``, ``DST_ALPHA``, ``ONE_MINUS_SRC_ALPHA`` or ``ONE_MINUS_DST_ALPHA``. Range 0-7. The initial value is SRC_ALPHA(2)
@@ -386,7 +386,7 @@ STATIC mp_obj_t _blendfunc(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_3(blendfunc_obj, _blendfunc);
-//| def Call(self, dest: int) -> Any:
+//| def Call(self, dest: int) -> None:
//| """Execute a sequence of commands at another location in the display list
//|
//| :param int dest: display list address. Range 0-65535"""
@@ -400,7 +400,7 @@ STATIC mp_obj_t _call(mp_obj_t self, mp_obj_t a0) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(call_obj, _call);
-//| def Cell(self, cell: int) -> Any:
+//| def Cell(self, cell: int) -> None:
//| """Set the bitmap cell number for the vertex2f command
//|
//| :param int cell: bitmap cell number. Range 0-127. The initial value is 0
@@ -416,7 +416,7 @@ STATIC mp_obj_t _cell(mp_obj_t self, mp_obj_t a0) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(cell_obj, _cell);
-//| def ClearColorA(self, alpha: int) -> Any:
+//| def ClearColorA(self, alpha: int) -> None:
//| """Set clear value for the alpha channel
//|
//| :param int alpha: alpha value used when the color buffer is cleared. Range 0-255. The initial value is 0
@@ -432,7 +432,7 @@ STATIC mp_obj_t _clearcolora(mp_obj_t self, mp_obj_t a0) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(clearcolora_obj, _clearcolora);
-//| def ClearColorRGB(self, red: int, green: int, blue: int) -> Any:
+//| def ClearColorRGB(self, red: int, green: int, blue: int) -> None:
//| """Set clear values for red, green and blue channels
//|
//| :param int red: red value used when the color buffer is cleared. Range 0-255. The initial value is 0
@@ -452,7 +452,7 @@ STATIC mp_obj_t _clearcolorrgb(size_t n_args, const mp_obj_t *args) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(clearcolorrgb_obj, 4, 4, _clearcolorrgb);
-//| def Clear(self, c: int, s: int, t: int) -> Any:
+//| def Clear(self, c: int, s: int, t: int) -> None:
//| """Clear buffers to preset values
//|
//| :param int c: clear color buffer. Range 0-1
@@ -470,7 +470,7 @@ STATIC mp_obj_t _clear(size_t n_args, const mp_obj_t *args) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(clear_obj, 1, 4, _clear);
-//| def ClearStencil(self, s: int) -> Any:
+//| def ClearStencil(self, s: int) -> None:
//| """Set clear value for the stencil buffer
//|
//| :param int s: value used when the stencil buffer is cleared. Range 0-255. The initial value is 0
@@ -486,7 +486,7 @@ STATIC mp_obj_t _clearstencil(mp_obj_t self, mp_obj_t a0) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(clearstencil_obj, _clearstencil);
-//| def ClearTag(self, s: int) -> Any:
+//| def ClearTag(self, s: int) -> None:
//| """Set clear value for the tag buffer
//|
//| :param int s: value used when the tag buffer is cleared. Range 0-255. The initial value is 0
@@ -501,7 +501,7 @@ STATIC mp_obj_t _cleartag(mp_obj_t self, mp_obj_t a0) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(cleartag_obj, _cleartag);
-//| def ColorA(self, alpha: int) -> Any:
+//| def ColorA(self, alpha: int) -> None:
//| """Set the current color alpha
//|
//| :param int alpha: alpha for the current color. Range 0-255. The initial value is 255
@@ -517,7 +517,7 @@ STATIC mp_obj_t _colora(mp_obj_t self, mp_obj_t a0) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(colora_obj, _colora);
-//| def ColorMask(self, r: int, g: int, b: int, a: int) -> Any:
+//| def ColorMask(self, r: int, g: int, b: int, a: int) -> None:
//| """Enable and disable writing of frame buffer color components
//|
//| :param int r: allow updates to the frame buffer red component. Range 0-1. The initial value is 1
@@ -539,7 +539,7 @@ STATIC mp_obj_t _colormask(size_t n_args, const mp_obj_t *args) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(colormask_obj, 5, 5, _colormask);
-//| def ColorRGB(self, red: int, green: int, blue: int) -> Any:
+//| def ColorRGB(self, red: int, green: int, blue: int) -> None:
//| """Set the drawing color
//|
//| :param int red: red value for the current color. Range 0-255. The initial value is 255
@@ -559,9 +559,9 @@ STATIC mp_obj_t _colorrgb(size_t n_args, const mp_obj_t *args) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(colorrgb_obj, 4, 4, _colorrgb);
-//| def Display(self, ) -> Any: ...
-//| """End the display list"""
-//|
+//| def Display(self) -> None:
+//| """End the display list"""
+//| ...
STATIC mp_obj_t _display(mp_obj_t self) {
@@ -570,7 +570,7 @@ STATIC mp_obj_t _display(mp_obj_t self) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(display_obj, _display);
-//| def End(self, ) -> Any:
+//| def End(self) -> None:
//| """End drawing a graphics primitive
//|
//| :meth:`Vertex2ii` and :meth:`Vertex2f` calls are ignored until the next :meth:`Begin`."""
@@ -584,7 +584,7 @@ STATIC mp_obj_t _end(mp_obj_t self) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(end_obj, _end);
-//| def Jump(self, dest: int) -> Any:
+//| def Jump(self, dest: int) -> None:
//| """Execute commands at another location in the display list
//|
//| :param int dest: display list address. Range 0-65535"""
@@ -598,7 +598,7 @@ STATIC mp_obj_t _jump(mp_obj_t self, mp_obj_t a0) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(jump_obj, _jump);
-//| def LineWidth(self, width: int) -> Any:
+//| def LineWidth(self, width: int) -> None:
//| """Set the width of rasterized lines
//|
//| :param int width: line width in :math:`1/16` pixel. Range 0-4095. The initial value is 16
@@ -614,7 +614,7 @@ STATIC mp_obj_t _linewidth(mp_obj_t self, mp_obj_t a0) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(linewidth_obj, _linewidth);
-//| def Macro(self, m: int) -> Any:
+//| def Macro(self, m: int) -> None:
//| """Execute a single command from a macro register
//|
//| :param int m: macro register to read. Range 0-1"""
@@ -628,7 +628,7 @@ STATIC mp_obj_t _macro(mp_obj_t self, mp_obj_t a0) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(macro_obj, _macro);
-//| def Nop(self, ) -> Any:
+//| def Nop(self) -> None:
//| """No operation"""
//| ...
//|
@@ -640,7 +640,7 @@ STATIC mp_obj_t _nop(mp_obj_t self) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(nop_obj, _nop);
-//| def PaletteSource(self, addr: int) -> Any:
+//| def PaletteSource(self, addr: int) -> None:
//| """Set the base address of the palette
//|
//| :param int addr: Address in graphics SRAM, 2-byte aligned. Range 0-4194303. The initial value is 0
@@ -656,7 +656,7 @@ STATIC mp_obj_t _palettesource(mp_obj_t self, mp_obj_t a0) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(palettesource_obj, _palettesource);
-//| def PointSize(self, size: int) -> Any:
+//| def PointSize(self, size: int) -> None:
//| """Set the radius of rasterized points
//|
//| :param int size: point radius in :math:`1/16` pixel. Range 0-8191. The initial value is 16
@@ -672,7 +672,7 @@ STATIC mp_obj_t _pointsize(mp_obj_t self, mp_obj_t a0) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(pointsize_obj, _pointsize);
-//| def RestoreContext(self, ) -> Any:
+//| def RestoreContext(self) -> None:
//| """Restore the current graphics context from the context stack"""
//| ...
//|
@@ -684,7 +684,7 @@ STATIC mp_obj_t _restorecontext(mp_obj_t self) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(restorecontext_obj, _restorecontext);
-//| def Return(self, ) -> Any:
+//| def Return(self) -> None:
//| """Return from a previous call command"""
//| ...
//|
@@ -696,7 +696,7 @@ STATIC mp_obj_t _return(mp_obj_t self) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(return_obj, _return);
-//| def SaveContext(self, ) -> Any:
+//| def SaveContext(self) -> None:
//| """Push the current graphics context on the context stack"""
//| ...
//|
@@ -708,7 +708,7 @@ STATIC mp_obj_t _savecontext(mp_obj_t self) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(savecontext_obj, _savecontext);
-//| def ScissorSize(self, width: int, height: int) -> Any:
+//| def ScissorSize(self, width: int, height: int) -> None:
//| """Set the size of the scissor clip rectangle
//|
//| :param int width: The width of the scissor clip rectangle, in pixels. Range 0-4095. The initial value is hsize
@@ -726,7 +726,7 @@ STATIC mp_obj_t _scissorsize(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_3(scissorsize_obj, _scissorsize);
-//| def ScissorXY(self, x: int, y: int) -> Any:
+//| def ScissorXY(self, x: int, y: int) -> None:
//| """Set the top left corner of the scissor clip rectangle
//|
//| :param int x: The :math:`x` coordinate of the scissor clip rectangle, in pixels. Range 0-2047. The initial value is 0
@@ -744,7 +744,7 @@ STATIC mp_obj_t _scissorxy(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_3(scissorxy_obj, _scissorxy);
-//| def StencilFunc(self, func: int, ref: int, mask: int) -> Any:
+//| def StencilFunc(self, func: int, ref: int, mask: int) -> None:
//| """Set function and reference value for stencil testing
//|
//| :param int func: specifies the test function, one of ``NEVER``, ``LESS``, ``LEQUAL``, ``GREATER``, ``GEQUAL``, ``EQUAL``, ``NOTEQUAL``, or ``ALWAYS``. Range 0-7. The initial value is ALWAYS(7)
@@ -764,7 +764,7 @@ STATIC mp_obj_t _stencilfunc(size_t n_args, const mp_obj_t *args) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(stencilfunc_obj, 4, 4, _stencilfunc);
-//| def StencilMask(self, mask: int) -> Any:
+//| def StencilMask(self, mask: int) -> None:
//| """Control the writing of individual bits in the stencil planes
//|
//| :param int mask: the mask used to enable writing stencil bits. Range 0-255. The initial value is 255
@@ -780,7 +780,7 @@ STATIC mp_obj_t _stencilmask(mp_obj_t self, mp_obj_t a0) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(stencilmask_obj, _stencilmask);
-//| def StencilOp(self, sfail: int, spass: int) -> Any:
+//| def StencilOp(self, sfail: int, spass: int) -> None:
//| """Set stencil test actions
//|
//| :param int sfail: specifies the action to take when the stencil test fails, one of ``KEEP``, ``ZERO``, ``REPLACE``, ``INCR``, ``INCR_WRAP``, ``DECR``, ``DECR_WRAP``, and ``INVERT``. Range 0-7. The initial value is KEEP(1)
@@ -798,7 +798,7 @@ STATIC mp_obj_t _stencilop(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_3(stencilop_obj, _stencilop);
-//| def TagMask(self, mask: int) -> Any:
+//| def TagMask(self, mask: int) -> None:
//| """Control the writing of the tag buffer
//|
//| :param int mask: allow updates to the tag buffer. Range 0-1. The initial value is 1
@@ -814,7 +814,7 @@ STATIC mp_obj_t _tagmask(mp_obj_t self, mp_obj_t a0) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(tagmask_obj, _tagmask);
-//| def Tag(self, s: int) -> Any:
+//| def Tag(self, s: int) -> None:
//| """Set the current tag value
//|
//| :param int s: tag value. Range 0-255. The initial value is 255
@@ -830,7 +830,7 @@ STATIC mp_obj_t _tag(mp_obj_t self, mp_obj_t a0) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(tag_obj, _tag);
-//| def VertexTranslateX(self, x: int) -> Any:
+//| def VertexTranslateX(self, x: int) -> None:
//| """Set the vertex transformation's x translation component
//|
//| :param int x: signed x-coordinate in :math:`1/16` pixel. Range 0-131071. The initial value is 0
@@ -846,7 +846,7 @@ STATIC mp_obj_t _vertextranslatex(mp_obj_t self, mp_obj_t a0) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(vertextranslatex_obj, _vertextranslatex);
-//| def VertexTranslateY(self, y: int) -> Any:
+//| def VertexTranslateY(self, y: int) -> None:
//| """Set the vertex transformation's y translation component
//|
//| :param int y: signed y-coordinate in :math:`1/16` pixel. Range 0-131071. The initial value is 0
@@ -863,7 +863,7 @@ STATIC mp_obj_t _vertextranslatey(mp_obj_t self, mp_obj_t a0) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(vertextranslatey_obj, _vertextranslatey);
-//| def VertexFormat(self, frac: int) -> Any:
+//| def VertexFormat(self, frac: int) -> None:
//| """Set the precision of vertex2f coordinates
//|
//| :param int frac: Number of fractional bits in X,Y coordinates, 0-4. Range 0-7. The initial value is 4
@@ -879,7 +879,7 @@ STATIC mp_obj_t _vertexformat(mp_obj_t self, mp_obj_t a0) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(vertexformat_obj, _vertexformat);
-//| def Vertex2ii(self, x: int, y: int, handle: int, cell: int) -> Any:
+//| def Vertex2ii(self, x: int, y: int, handle: int, cell: int) -> None:
//| """:param int x: x-coordinate in pixels. Range 0-511
//| :param int y: y-coordinate in pixels. Range 0-511
//| :param int handle: bitmap handle. Range 0-31
@@ -954,7 +954,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(vertex2ii_obj, 3, 5, _vertex2ii);
// Hand-written functions {
-//| def Vertex2f(self, b: Any) -> Any:
+//| def Vertex2f(self, b: float) -> None:
//| """Draw a point.
//|
//| :param float x: pixel x-coordinate
@@ -973,7 +973,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_3(vertex2f_obj, _vertex2f);
#define ADD_X(self, x) \
common_hal__eve_add(EVEHAL(self), sizeof(x), &(x));
-//| def cmd0(self, n: int) -> Any:
+//| def cmd0(self, n: int) -> None:
//| """Append the command word n to the FIFO
//|
//| :param int n: The command code
@@ -990,7 +990,7 @@ STATIC mp_obj_t _cmd0(mp_obj_t self, mp_obj_t n) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(cmd0_obj, _cmd0);
-//| def cmd(self, n: int, fmt: str, args: tuple) -> Any:
+//| def cmd(self, n: int, fmt: str, args: tuple) -> None:
//| """Append a command packet to the FIFO.
//|
//| :param int n: The command code
diff --git a/shared-bindings/_pew/PewPew.c b/shared-bindings/_pew/PewPew.c
index 352ef38f2..32a956c93 100644
--- a/shared-bindings/_pew/PewPew.c
+++ b/shared-bindings/_pew/PewPew.c
@@ -46,7 +46,7 @@
//| that library."""
//|
-//| def __init__(self, buffer: Any, rows: Any, cols: Any, buttons: Any):
+//| def __init__(self, buffer: ReadableBuffer, rows: List[DigitalInOut, DigitalInOut, DigitalInOut, DigitalInOut, DigitalInOut, DigitalInOut, DigitalInOut, DigitalInOut], cols: List[DigitalInOut, DigitalInOut, DigitalInOut, DigitalInOut, DigitalInOut, DigitalInOut, DigitalInOut, DigitalInOut], buttons: DigitalInOut) -> None:
//| """Initializes matrix scanning routines.
//|
//| The ``buffer`` is a 64 byte long ``bytearray`` that stores what should
diff --git a/shared-bindings/_pixelbuf/PixelBuf.c b/shared-bindings/_pixelbuf/PixelBuf.c
index c953951ea..951395acb 100644
--- a/shared-bindings/_pixelbuf/PixelBuf.c
+++ b/shared-bindings/_pixelbuf/PixelBuf.c
@@ -47,7 +47,7 @@ static void parse_byteorder(mp_obj_t byteorder_obj, pixelbuf_byteorder_details_t
//| class PixelBuf:
//| """A fast RGB[W] pixel buffer for LED and similar devices."""
//|
-//| def __init__(self, size: int, *, byteorder: str = "BGR", brightness: float = 0, auto_write: bool = False, header: bytes = b"", trailer: bytes = b""):
+//| def __init__(self, size: int, *, byteorder: str = "BGR", brightness: float = 0, auto_write: bool = False, header: bytes = b"", trailer: bytes = b"") -> None:
//| """Create a PixelBuf object of the specified size, byteorder, and bits per pixel.
//|
//| When brightness is less than 1.0, a second buffer will be used to store the color values
@@ -152,7 +152,7 @@ static void parse_byteorder(mp_obj_t byteorder_obj, pixelbuf_byteorder_details_t
}
}
-//| bpp: Any = ...
+//| bpp: int = ...
//| """The number of bytes per pixel in the buffer (read-only)"""
//|
STATIC mp_obj_t pixelbuf_pixelbuf_obj_get_bpp(mp_obj_t self_in) {
@@ -168,7 +168,7 @@ const mp_obj_property_t pixelbuf_pixelbuf_bpp_obj = {
};
-//| brightness: Any = ...
+//| brightness: float = ...
//| """Float value between 0 and 1. Output brightness.
//|
//| When brightness is less than 1.0, a second buffer will be used to store the color values
@@ -199,7 +199,7 @@ const mp_obj_property_t pixelbuf_pixelbuf_brightness_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| auto_write: Any = ...
+//| auto_write: bool = ...
//| """Whether to automatically write the pixels after each update."""
//|
STATIC mp_obj_t pixelbuf_pixelbuf_obj_get_auto_write(mp_obj_t self_in) {
@@ -221,7 +221,7 @@ const mp_obj_property_t pixelbuf_pixelbuf_auto_write_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| byteorder: Any = ...
+//| byteorder: string = ...
//| """byteorder string for the buffer (read-only)"""
//|
STATIC mp_obj_t pixelbuf_pixelbuf_obj_get_byteorder(mp_obj_t self_in) {
@@ -245,7 +245,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
}
}
-//| def show(self, ) -> Any:
+//| def show(self) -> None:
//| """Transmits the color data to the pixels so that they are shown. This is done automatically
//| when `auto_write` is True."""
//| ...
@@ -257,9 +257,9 @@ STATIC mp_obj_t pixelbuf_pixelbuf_show(mp_obj_t self_in) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(pixelbuf_pixelbuf_show_obj, pixelbuf_pixelbuf_show);
-//| def fill(color: Any) -> Any:
-//| """Fills the given pixelbuf with the given color."""
-//| ...
+//| def fill(color: Union[int, Tuple[int, int, int]]) -> None:
+//| """Fills the given pixelbuf with the given color."""
+//| ...
//|
STATIC mp_obj_t pixelbuf_pixelbuf_fill(mp_obj_t self_in, mp_obj_t value) {
@@ -269,13 +269,13 @@ STATIC mp_obj_t pixelbuf_pixelbuf_fill(mp_obj_t self_in, mp_obj_t value) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(pixelbuf_pixelbuf_fill_obj, pixelbuf_pixelbuf_fill);
-//| def __getitem__(self, index: Any) -> Any:
+//| def __getitem__(self, index: int) -> Tuple[int, int, int, Union[int, float]]:
//| """Returns the pixel value at the given index as a tuple of (Red, Green, Blue[, White]) values
//| between 0 and 255. When in PWM (DotStar) mode, the 4th tuple value is a float of the pixel
//| intensity from 0-1.0."""
//| ...
//|
-//| def __setitem__(self, index: Any, value: Any) -> Any:
+//| def __setitem__(self, index: int, value: Union[int, Tuple[int, int, int, Union[int, float]]]) -> PixelBuf:
//| """Sets the pixel value at the given index. Value can either be a tuple or integer. Tuples are
//| The individual (Red, Green, Blue[, White]) values between 0 and 255. If given an integer, the
//| red, green and blue values are packed into the lower three bytes (0xRRGGBB).
diff --git a/shared-bindings/_pixelbuf/PixelBuf.h b/shared-bindings/_pixelbuf/PixelBuf.h
index 14ee2e900..0b09a5771 100644
--- a/shared-bindings/_pixelbuf/PixelBuf.h
+++ b/shared-bindings/_pixelbuf/PixelBuf.h
@@ -29,7 +29,7 @@
#include "shared-module/_pixelbuf/PixelBuf.h"
-const mp_obj_type_t pixelbuf_pixelbuf_type;
+extern const mp_obj_type_t pixelbuf_pixelbuf_type;
void common_hal__pixelbuf_pixelbuf_construct(pixelbuf_pixelbuf_obj_t *self, size_t n,
pixelbuf_byteorder_details_t* byteorder, mp_float_t brightness, bool auto_write, uint8_t* header,
diff --git a/shared-bindings/_pixelbuf/__init__.c b/shared-bindings/_pixelbuf/__init__.c
index bfd479fde..6038fdfdc 100644
--- a/shared-bindings/_pixelbuf/__init__.c
+++ b/shared-bindings/_pixelbuf/__init__.c
@@ -41,7 +41,7 @@
//| Byteorders are configured with strings, such as "RGB" or "RGBD"."""
// TODO: Pull in docs from pypixelbuf.
-//| def colorwheel(n: int) -> Any:
+//| def colorwheel(n: int) -> int:
//| """C implementation of the common wheel() function found in many examples.
//| Returns the colorwheel RGB value as an integer value for n (usable in :py:class:`PixelBuf`, neopixel, and dotstar)."""
//| ...
diff --git a/shared-bindings/_stage/Layer.c b/shared-bindings/_stage/Layer.c
index 0f8260e53..5828669a7 100644
--- a/shared-bindings/_stage/Layer.c
+++ b/shared-bindings/_stage/Layer.c
@@ -33,7 +33,7 @@
//| class Layer:
//| """Keep information about a single layer of graphics"""
//|
-//| def __init__(self, width: int, height: int, graphic: bytearray, palette: bytearray, grid: bytearray):
+//| def __init__(self, width: int, height: int, graphic: bytearray, palette: bytearray, grid: bytearray) -> None:
//| """Keep internal information about a layer of graphics (either a
//| ``Grid`` or a ``Sprite``) in a format suitable for fast rendering
//| with the ``render()`` function.
@@ -88,7 +88,7 @@ STATIC mp_obj_t layer_make_new(const mp_obj_type_t *type, size_t n_args,
return MP_OBJ_FROM_PTR(self);
}
-//| def move(self, x: Any, y: Any) -> Any:
+//| def move(self, x: int, y: int) -> None:
//| """Set the offset of the layer to the specified values."""
//| ...
//|
@@ -100,7 +100,7 @@ STATIC mp_obj_t layer_move(mp_obj_t self_in, mp_obj_t x_in, mp_obj_t y_in) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_3(layer_move_obj, layer_move);
-//| def frame(self, frame: Any, rotation: Any) -> Any:
+//| def frame(self, frame: int, rotation: int) -> None:
//| """Set the animation frame of the sprite, and optionally rotation its
//| graphic."""
//| ...
diff --git a/shared-bindings/_stage/Text.c b/shared-bindings/_stage/Text.c
index b0ff1525c..555eb5831 100644
--- a/shared-bindings/_stage/Text.c
+++ b/shared-bindings/_stage/Text.c
@@ -33,7 +33,7 @@
//| class Text:
//| """Keep information about a single grid of text"""
//|
-//| def __init__(self, width: int, height: int, font: bytearray, palette: bytearray, chars: bytearray):
+//| def __init__(self, width: int, height: int, font: bytearray, palette: bytearray, chars: bytearray) -> None:
//| """Keep internal information about a grid of text
//| in a format suitable for fast rendering
//| with the ``render()`` function.
@@ -82,7 +82,7 @@ STATIC mp_obj_t text_make_new(const mp_obj_type_t *type, size_t n_args,
return MP_OBJ_FROM_PTR(self);
}
-//| def move(self, x: Any, y: Any) -> Any:
+//| def move(self, x: int, y: int) -> None:
//| """Set the offset of the text to the specified values."""
//| ...
//|
diff --git a/shared-bindings/aesio/aes.c b/shared-bindings/aesio/aes.c
index f6a0a89b8..e580be38b 100644
--- a/shared-bindings/aesio/aes.c
+++ b/shared-bindings/aesio/aes.c
@@ -12,7 +12,7 @@
//| class AES:
//| """Encrypt and decrypt AES streams"""
//|
-//| def __init__(self, key, mode=0, iv=None, segment_size=8) -> Any:
+//| def __init__(self, key: Optional[ReadableBuffer], mode: int=0, iv: ReadableBuffer=None, segment_size: int=8) -> None:
//| """Create a new AES state with the given key.
//|
//| :param bytearray key: A 16-, 24-, or 32-byte key
@@ -152,7 +152,7 @@ STATIC void validate_length(aesio_aes_obj_t *self, size_t src_length,
}
}
-//| def encrypt_into(src, dest) -> None:
+//| def encrypt_into(src: ReadableBuffer, dest: WriteableBuffer) -> None:
//| """Encrypt the buffer from ``src`` into ``dest``.
//|
//| For ECB mode, the buffers must be 16 bytes long. For CBC mode, the
@@ -183,7 +183,7 @@ STATIC mp_obj_t aesio_aes_encrypt_into(mp_obj_t aesio_obj, mp_obj_t src,
STATIC MP_DEFINE_CONST_FUN_OBJ_3(aesio_aes_encrypt_into_obj,
aesio_aes_encrypt_into);
-//| def decrypt_into(src, dest) -> None:
+//| def decrypt_into(src: ReadableBuffer, dest: WriteableBuffer) -> None:
//|
//| """Decrypt the buffer from ``src`` into ``dest``.
//| For ECB mode, the buffers must be 16 bytes long. For CBC mode, the
diff --git a/shared-bindings/analogio/AnalogIn.c b/shared-bindings/analogio/AnalogIn.c
index 2aadf1c76..2164bdf3e 100644
--- a/shared-bindings/analogio/AnalogIn.c
+++ b/shared-bindings/analogio/AnalogIn.c
@@ -48,7 +48,7 @@
//| val = adc.value"""
//|
-//| def __init__(self, pin: microcontroller.Pin):
+//| def __init__(self, pin: microcontroller.Pin) -> None:
//| """Use the AnalogIn on the given pin. The reference voltage varies by
//| platform so use ``reference_voltage`` to read the configured setting.
//|
@@ -70,7 +70,7 @@ STATIC mp_obj_t analogio_analogin_make_new(const mp_obj_type_t *type,
return MP_OBJ_FROM_PTR(self);
}
-//| def deinit(self, ) -> Any:
+//| def deinit(self) -> None:
//| """Turn off the AnalogIn and release the pin for other use."""
//| ...
//|
@@ -86,13 +86,13 @@ STATIC void check_for_deinit(analogio_analogin_obj_t *self) {
raise_deinited_error();
}
}
-//| def __enter__(self, ) -> Any:
+//| def __enter__(self) -> AnalogIn:
//| """No-op used by Context Managers."""
//| ...
//|
// Provided by context manager helper.
-//| def __exit__(self, ) -> Any:
+//| def __exit__(self) -> None:
//| """Automatically deinitializes the hardware when exiting a context. See
//| :ref:`lifetime-and-contextmanagers` for more info."""
//| ...
@@ -104,7 +104,7 @@ STATIC mp_obj_t analogio_analogin___exit__(size_t n_args, const mp_obj_t *args)
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(analogio_analogin___exit___obj, 4, 4, analogio_analogin___exit__);
-//| value: Any = ...
+//| value: int = ...
//| """The value on the analog pin between 0 and 65535 inclusive (16-bit). (read-only)
//|
//| Even if the underlying analog to digital converter (ADC) is lower
@@ -124,7 +124,7 @@ const mp_obj_property_t analogio_analogin_value_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| reference_voltage: Any = ...
+//| reference_voltage: Optional[float] = ...
//| """The maximum voltage measurable (also known as the reference voltage) as a
//| `float` in Volts."""
//|
diff --git a/shared-bindings/analogio/AnalogOut.c b/shared-bindings/analogio/AnalogOut.c
index 62b73c5b1..7b960d2ed 100644
--- a/shared-bindings/analogio/AnalogOut.c
+++ b/shared-bindings/analogio/AnalogOut.c
@@ -47,7 +47,7 @@
//| dac = analogio.AnalogOut(pin.PA02) # output on pin PA02
//| dac.value = 32768 # makes PA02 1.65V"""
//|
-//| def __init__(self, pin: microcontroller.Pin):
+//| def __init__(self, pin: microcontroller.Pin) -> None:
//| """Use the AnalogOut on the given pin.
//|
//| :param ~microcontroller.Pin pin: the pin to output to"""
@@ -66,7 +66,7 @@ STATIC mp_obj_t analogio_analogout_make_new(const mp_obj_type_t *type, mp_uint_t
return MP_OBJ_FROM_PTR(self);
}
-//| def deinit(self, ) -> Any:
+//| def deinit(self) -> None:
//| """Turn off the AnalogOut and release the pin for other use."""
//| ...
//|
@@ -79,13 +79,13 @@ STATIC mp_obj_t analogio_analogout_deinit(mp_obj_t self_in) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(analogio_analogout_deinit_obj, analogio_analogout_deinit);
-//| def __enter__(self, ) -> Any:
+//| def __enter__(self) -> AnalogOut:
//| """No-op used by Context Managers."""
//| ...
//|
// Provided by context manager helper.
-//| def __exit__(self, ) -> Any:
+//| def __exit__(self) -> None:
//| """Automatically deinitializes the hardware when exiting a context. See
//| :ref:`lifetime-and-contextmanagers` for more info."""
//| ...
@@ -97,7 +97,7 @@ STATIC mp_obj_t analogio_analogout___exit__(size_t n_args, const mp_obj_t *args)
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(analogio_analogout___exit___obj, 4, 4, analogio_analogout___exit__);
-//| value: Any = ...
+//| value: int = ...
//| """The value on the analog pin between 0 and 65535 inclusive (16-bit). (write-only)
//|
//| Even if the underlying digital to analog converter (DAC) is lower
diff --git a/shared-bindings/audiobusio/I2SOut.c b/shared-bindings/audiobusio/I2SOut.c
index fd71a6e85..304c737f6 100644
--- a/shared-bindings/audiobusio/I2SOut.c
+++ b/shared-bindings/audiobusio/I2SOut.c
@@ -38,7 +38,7 @@
//| class I2SOut:
//| """Output an I2S audio signal"""
//|
-//| def __init__(self, bit_clock: microcontroller.Pin, word_select: microcontroller.Pin, data: microcontroller.Pin, *, left_justified: bool):
+//| def __init__(self, bit_clock: microcontroller.Pin, word_select: microcontroller.Pin, data: microcontroller.Pin, *, left_justified: bool) -> None:
//| """Create a I2SOut object associated with the given pins.
//|
//| :param ~microcontroller.Pin bit_clock: The bit clock (or serial clock) pin
@@ -112,7 +112,7 @@ STATIC mp_obj_t audiobusio_i2sout_make_new(const mp_obj_type_t *type, size_t n_a
return MP_OBJ_FROM_PTR(self);
}
-//| def deinit(self, ) -> Any:
+//| def deinit(self) -> None:
//| """Deinitialises the I2SOut and releases any hardware resources for reuse."""
//| ...
//|
@@ -128,13 +128,13 @@ STATIC void check_for_deinit(audiobusio_i2sout_obj_t *self) {
raise_deinited_error();
}
}
-//| def __enter__(self, ) -> Any:
+//| def __enter__(self) -> I2SOut:
//| """No-op used by Context Managers."""
//| ...
//|
// Provided by context manager helper.
-//| def __exit__(self, ) -> Any:
+//| def __exit__(self) -> None:
//| """Automatically deinitializes the hardware when exiting a context. See
//| :ref:`lifetime-and-contextmanagers` for more info."""
//| ...
@@ -147,7 +147,7 @@ STATIC mp_obj_t audiobusio_i2sout_obj___exit__(size_t n_args, const mp_obj_t *ar
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audiobusio_i2sout___exit___obj, 4, 4, audiobusio_i2sout_obj___exit__);
-//| def play(self, sample: Any, *, loop: Any = False) -> Any:
+//| def play(self, sample: Union[audiocore.WaveFile, audiocore.RawSample, audiomixer.Mixer], *, loop: bool = False) -> None:
//| """Plays the sample once when loop=False and continuously when loop=True.
//| Does not block. Use `playing` to block.
//|
@@ -174,7 +174,7 @@ STATIC mp_obj_t audiobusio_i2sout_obj_play(size_t n_args, const mp_obj_t *pos_ar
}
MP_DEFINE_CONST_FUN_OBJ_KW(audiobusio_i2sout_play_obj, 1, audiobusio_i2sout_obj_play);
-//| def stop(self, ) -> Any:
+//| def stop(self) -> None:
//| """Stops playback."""
//| ...
//|
@@ -186,7 +186,7 @@ STATIC mp_obj_t audiobusio_i2sout_obj_stop(mp_obj_t self_in) {
}
MP_DEFINE_CONST_FUN_OBJ_1(audiobusio_i2sout_stop_obj, audiobusio_i2sout_obj_stop);
-//| playing: Any = ...
+//| playing: bool = ...
//| """True when the audio sample is being output. (read-only)"""
//|
STATIC mp_obj_t audiobusio_i2sout_obj_get_playing(mp_obj_t self_in) {
@@ -203,7 +203,7 @@ const mp_obj_property_t audiobusio_i2sout_playing_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| def pause(self, ) -> Any:
+//| def pause(self) -> None:
//| """Stops playback temporarily while remembering the position. Use `resume` to resume playback."""
//| ...
//|
@@ -219,7 +219,7 @@ STATIC mp_obj_t audiobusio_i2sout_obj_pause(mp_obj_t self_in) {
}
MP_DEFINE_CONST_FUN_OBJ_1(audiobusio_i2sout_pause_obj, audiobusio_i2sout_obj_pause);
-//| def resume(self, ) -> Any:
+//| def resume(self) -> None:
//| """Resumes sample playback after :py:func:`pause`."""
//| ...
//|
@@ -235,7 +235,7 @@ STATIC mp_obj_t audiobusio_i2sout_obj_resume(mp_obj_t self_in) {
}
MP_DEFINE_CONST_FUN_OBJ_1(audiobusio_i2sout_resume_obj, audiobusio_i2sout_obj_resume);
-//| paused: Any = ...
+//| paused: bool = ...
//| """True when playback is paused. (read-only)"""
//|
STATIC mp_obj_t audiobusio_i2sout_obj_get_paused(mp_obj_t self_in) {
diff --git a/shared-bindings/audiobusio/PDMIn.c b/shared-bindings/audiobusio/PDMIn.c
index 5b950297b..9a963bcfa 100644
--- a/shared-bindings/audiobusio/PDMIn.c
+++ b/shared-bindings/audiobusio/PDMIn.c
@@ -39,7 +39,7 @@
//| class PDMIn:
//| """Record an input PDM audio stream"""
//|
-//| def __init__(self, clock_pin: microcontroller.Pin, data_pin: microcontroller.Pin, *, sample_rate: int = 16000, bit_depth: int = 8, mono: bool = True, oversample: int = 64, startup_delay: float = 0.11):
+//| def __init__(self, clock_pin: microcontroller.Pin, data_pin: microcontroller.Pin, *, sample_rate: int = 16000, bit_depth: int = 8, mono: bool = True, oversample: int = 64, startup_delay: float = 0.11) -> None:
//| """Create a PDMIn object associated with the given pins. This allows you to
//| record audio signals from the given pins. Individual ports may put further
//| restrictions on the recording parameters. The overall sample rate is
@@ -134,7 +134,7 @@ STATIC mp_obj_t audiobusio_pdmin_make_new(const mp_obj_type_t *type, size_t n_ar
return MP_OBJ_FROM_PTR(self);
}
-//| def deinit(self, ) -> Any:
+//| def deinit(self) -> None:
//| """Deinitialises the PDMIn and releases any hardware resources for reuse."""
//| ...
//|
@@ -150,13 +150,13 @@ STATIC void check_for_deinit(audiobusio_pdmin_obj_t *self) {
raise_deinited_error();
}
}
-//| def __enter__(self, ) -> Any:
+//| def __enter__(self) -> PDMIn:
//| """No-op used by Context Managers."""
//| ...
//|
// Provided by context manager helper.
-//| def __exit__(self, ) -> Any:
+//| def __exit__(self) -> None:
//| """Automatically deinitializes the hardware when exiting a context."""
//| ...
//|
@@ -168,7 +168,7 @@ STATIC mp_obj_t audiobusio_pdmin_obj___exit__(size_t n_args, const mp_obj_t *arg
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audiobusio_pdmin___exit___obj, 4, 4, audiobusio_pdmin_obj___exit__);
-//| def record(self, destination: Any, destination_length: Any) -> Any:
+//| def record(self, destination: WriteableBuffer, destination_length: int) -> None:
//| """Records destination_length bytes of samples to destination. This is
//| blocking.
//|
@@ -210,7 +210,7 @@ STATIC mp_obj_t audiobusio_pdmin_obj_record(mp_obj_t self_obj, mp_obj_t destinat
}
MP_DEFINE_CONST_FUN_OBJ_3(audiobusio_pdmin_record_obj, audiobusio_pdmin_obj_record);
-//| sample_rate: Any = ...
+//| sample_rate: int = ...
//| """The actual sample_rate of the recording. This may not match the constructed
//| sample rate due to internal clock limitations."""
//|
diff --git a/shared-bindings/audiocore/RawSample.c b/shared-bindings/audiocore/RawSample.c
index 2eadf1fab..20ebae001 100644
--- a/shared-bindings/audiocore/RawSample.c
+++ b/shared-bindings/audiocore/RawSample.c
@@ -38,7 +38,7 @@
//| class RawSample:
//| """A raw audio sample buffer in memory"""
//|
-//| def __init__(self, buffer: array.array, *, channel_count: int = 1, sample_rate: int = 8000):
+//| def __init__(self, buffer: array.array, *, channel_count: int = 1, sample_rate: int = 8000) -> None:
//| """Create a RawSample based on the given buffer of signed values. If channel_count is more than
//| 1 then each channel's samples should alternate. In other words, for a two channel buffer, the
//| first sample will be for channel 1, the second sample will be for channel two, the third for
@@ -101,7 +101,7 @@ STATIC mp_obj_t audioio_rawsample_make_new(const mp_obj_type_t *type, size_t n_a
return MP_OBJ_FROM_PTR(self);
}
-//| def deinit(self, ) -> Any:
+//| def deinit(self) -> None:
//| """Deinitialises the AudioOut and releases any hardware resources for reuse."""
//| ...
//|
@@ -118,13 +118,13 @@ STATIC void check_for_deinit(audioio_rawsample_obj_t *self) {
}
}
-//| def __enter__(self, ) -> Any:
+//| def __enter__(self) -> RawSample:
//| """No-op used by Context Managers."""
//| ...
//|
// Provided by context manager helper.
-//| def __exit__(self, ) -> Any:
+//| def __exit__(self) -> None:
//| """Automatically deinitializes the hardware when exiting a context. See
//| :ref:`lifetime-and-contextmanagers` for more info."""
//| ...
@@ -136,7 +136,7 @@ STATIC mp_obj_t audioio_rawsample_obj___exit__(size_t n_args, const mp_obj_t *ar
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audioio_rawsample___exit___obj, 4, 4, audioio_rawsample_obj___exit__);
-//| sample_rate: Any = ...
+//| sample_rate: Optional(int) = ...
//| """32 bit value that dictates how quickly samples are played in Hertz (cycles per second).
//| When the sample is looped, this can change the pitch output without changing the underlying
//| sample. This will not change the sample rate of any active playback. Call ``play`` again to
diff --git a/shared-bindings/audiocore/WaveFile.c b/shared-bindings/audiocore/WaveFile.c
index a067f6cda..d986d6db5 100644
--- a/shared-bindings/audiocore/WaveFile.c
+++ b/shared-bindings/audiocore/WaveFile.c
@@ -40,7 +40,7 @@
//| be 8 bit unsigned or 16 bit signed. If a buffer is provided, it will be used instead of allocating
//| an internal buffer."""
//|
-//| def __init__(self, file: typing.BinaryIO, buffer: bytearray):
+//| def __init__(self, file: typing.BinaryIO, buffer: ReadableBuffer) -> None:
//| """Load a .wav file for playback with `audioio.AudioOut` or `audiobusio.I2SOut`.
//|
//| :param typing.BinaryIO file: Already opened wave file
@@ -91,7 +91,7 @@ STATIC mp_obj_t audioio_wavefile_make_new(const mp_obj_type_t *type, size_t n_ar
return MP_OBJ_FROM_PTR(self);
}
-//| def deinit(self, ) -> Any:
+//| def deinit(self) -> None:
//| """Deinitialises the WaveFile and releases all memory resources for reuse."""
//| ...
STATIC mp_obj_t audioio_wavefile_deinit(mp_obj_t self_in) {
@@ -107,13 +107,13 @@ STATIC void check_for_deinit(audioio_wavefile_obj_t *self) {
}
}
-//| def __enter__(self, ) -> Any:
+//| def __enter__(self) -> WaveFile:
//| """No-op used by Context Managers."""
//| ...
//|
// Provided by context manager helper.
-//| def __exit__(self, ) -> Any:
+//| def __exit__(self) -> None:
//| """Automatically deinitializes the hardware when exiting a context. See
//| :ref:`lifetime-and-contextmanagers` for more info."""
//| ...
@@ -125,7 +125,7 @@ STATIC mp_obj_t audioio_wavefile_obj___exit__(size_t n_args, const mp_obj_t *arg
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audioio_wavefile___exit___obj, 4, 4, audioio_wavefile_obj___exit__);
-//| sample_rate: Any = ...
+//| sample_rate: int = ...
//| """32 bit value that dictates how quickly samples are loaded into the DAC
//| in Hertz (cycles per second). When the sample is looped, this can change
//| the pitch output without changing the underlying sample."""
@@ -152,7 +152,7 @@ const mp_obj_property_t audioio_wavefile_sample_rate_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| bits_per_sample: Any = ...
+//| bits_per_sample: int = ...
//| """Bits per sample. (read only)"""
//|
STATIC mp_obj_t audioio_wavefile_obj_get_bits_per_sample(mp_obj_t self_in) {
@@ -168,7 +168,7 @@ const mp_obj_property_t audioio_wavefile_bits_per_sample_obj = {
(mp_obj_t)&mp_const_none_obj,
(mp_obj_t)&mp_const_none_obj},
};
-//| channel_count: Any = ...
+//| channel_count: int = ...
//| """Number of audio channels. (read only)"""
//|
STATIC mp_obj_t audioio_wavefile_obj_get_channel_count(mp_obj_t self_in) {
diff --git a/shared-bindings/audioio/AudioOut.c b/shared-bindings/audioio/AudioOut.c
index 9ba72bd41..e1a78c44c 100644
--- a/shared-bindings/audioio/AudioOut.c
+++ b/shared-bindings/audioio/AudioOut.c
@@ -39,7 +39,7 @@
//| class AudioOut:
//| """Output an analog audio signal"""
//|
-//| def __init__(self, left_channel: microcontroller.Pin, *, right_channel: microcontroller.Pin = None, quiescent_value: int = 0x8000):
+//| def __init__(self, left_channel: microcontroller.Pin, *, right_channel: microcontroller.Pin = None, quiescent_value: int = 0x8000) -> None:
//| """Create a AudioOut object associated with the given pin(s). This allows you to
//| play audio signals out on the given pin(s).
//|
@@ -111,7 +111,7 @@ STATIC mp_obj_t audioio_audioout_make_new(const mp_obj_type_t *type, size_t n_ar
return MP_OBJ_FROM_PTR(self);
}
-//| def deinit(self, ) -> Any:
+//| def deinit(self) -> None:
//| """Deinitialises the AudioOut and releases any hardware resources for reuse."""
//| ...
//|
@@ -127,13 +127,13 @@ STATIC void check_for_deinit(audioio_audioout_obj_t *self) {
raise_deinited_error();
}
}
-//| def __enter__(self, ) -> Any:
+//| def __enter__(self) -> AudioOut:
//| """No-op used by Context Managers."""
//| ...
//|
// Provided by context manager helper.
-//| def __exit__(self, ) -> Any:
+//| def __exit__(self) -> None:
//| """Automatically deinitializes the hardware when exiting a context. See
//| :ref:`lifetime-and-contextmanagers` for more info."""
//| ...
@@ -146,7 +146,7 @@ STATIC mp_obj_t audioio_audioout_obj___exit__(size_t n_args, const mp_obj_t *arg
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audioio_audioout___exit___obj, 4, 4, audioio_audioout_obj___exit__);
-//| def play(self, sample: Any, *, loop: Any = False) -> Any:
+//| def play(self, sample: Union[audiocore.WaveFile, audiocore.RawSample, audiomixer.Mixer], *, loop: bool = False) -> None:
//| """Plays the sample once when loop=False and continuously when loop=True.
//| Does not block. Use `playing` to block.
//|
@@ -175,7 +175,7 @@ STATIC mp_obj_t audioio_audioout_obj_play(size_t n_args, const mp_obj_t *pos_arg
}
MP_DEFINE_CONST_FUN_OBJ_KW(audioio_audioout_play_obj, 1, audioio_audioout_obj_play);
-//| def stop(self, ) -> Any:
+//| def stop(self) -> None:
//| """Stops playback and resets to the start of the sample."""
//| ...
//|
@@ -187,7 +187,7 @@ STATIC mp_obj_t audioio_audioout_obj_stop(mp_obj_t self_in) {
}
MP_DEFINE_CONST_FUN_OBJ_1(audioio_audioout_stop_obj, audioio_audioout_obj_stop);
-//| playing: Any = ...
+//| playing: bool = ...
//| """True when an audio sample is being output even if `paused`. (read-only)"""
//|
STATIC mp_obj_t audioio_audioout_obj_get_playing(mp_obj_t self_in) {
@@ -204,7 +204,7 @@ const mp_obj_property_t audioio_audioout_playing_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| def pause(self, ) -> Any:
+//| def pause(self) -> None:
//| """Stops playback temporarily while remembering the position. Use `resume` to resume playback."""
//| ...
//|
@@ -220,7 +220,7 @@ STATIC mp_obj_t audioio_audioout_obj_pause(mp_obj_t self_in) {
}
MP_DEFINE_CONST_FUN_OBJ_1(audioio_audioout_pause_obj, audioio_audioout_obj_pause);
-//| def resume(self, ) -> Any:
+//| def resume(self) -> None:
//| """Resumes sample playback after :py:func:`pause`."""
//| ...
//|
@@ -236,7 +236,7 @@ STATIC mp_obj_t audioio_audioout_obj_resume(mp_obj_t self_in) {
}
MP_DEFINE_CONST_FUN_OBJ_1(audioio_audioout_resume_obj, audioio_audioout_obj_resume);
-//| paused: Any = ...
+//| paused: bool = ...
//| """True when playback is paused. (read-only)"""
//|
STATIC mp_obj_t audioio_audioout_obj_get_paused(mp_obj_t self_in) {
diff --git a/shared-bindings/audiomixer/Mixer.c b/shared-bindings/audiomixer/Mixer.c
index 31e62cdae..0d7712b03 100644
--- a/shared-bindings/audiomixer/Mixer.c
+++ b/shared-bindings/audiomixer/Mixer.c
@@ -41,7 +41,7 @@
//| class Mixer:
//| """Mixes one or more audio samples together into one sample."""
//|
-//| def __init__(self, voice_count: int = 2, buffer_size: int = 1024, channel_count: int = 2, bits_per_sample: int = 16, samples_signed: bool = True, sample_rate: int = 8000):
+//| def __init__(self, voice_count: int = 2, buffer_size: int = 1024, channel_count: int = 2, bits_per_sample: int = 16, samples_signed: bool = True, sample_rate: int = 8000) -> None:
//| """Create a Mixer object that can mix multiple channels with the same sample rate.
//| Samples are accessed and controlled with the mixer's `audiomixer.MixerVoice` objects.
//|
@@ -121,7 +121,7 @@ STATIC mp_obj_t audiomixer_mixer_make_new(const mp_obj_type_t *type, size_t n_ar
return MP_OBJ_FROM_PTR(self);
}
-//| def deinit(self, ) -> Any:
+//| def deinit(self) -> None:
//| """Deinitialises the Mixer and releases any hardware resources for reuse."""
//| ...
//|
@@ -138,13 +138,13 @@ STATIC void check_for_deinit(audiomixer_mixer_obj_t *self) {
}
}
-//| def __enter__(self, ) -> Any:
+//| def __enter__(self) -> Mixer:
//| """No-op used by Context Managers."""
//| ...
//|
// Provided by context manager helper.
-//| def __exit__(self, ) -> Any:
+//| def __exit__(self) -> None:
//| """Automatically deinitializes the hardware when exiting a context. See
//| :ref:`lifetime-and-contextmanagers` for more info."""
//| ...
@@ -156,7 +156,7 @@ STATIC mp_obj_t audiomixer_mixer_obj___exit__(size_t n_args, const mp_obj_t *arg
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audiomixer_mixer___exit___obj, 4, 4, audiomixer_mixer_obj___exit__);
-//| playing: Any = ...
+//| playing: bool = ...
//| """True when any voice is being output. (read-only)"""
//|
STATIC mp_obj_t audiomixer_mixer_obj_get_playing(mp_obj_t self_in) {
@@ -173,7 +173,7 @@ const mp_obj_property_t audiomixer_mixer_playing_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| sample_rate: Any = ...
+//| sample_rate: int = ...
//| """32 bit value that dictates how quickly samples are played in Hertz (cycles per second)."""
//|
STATIC mp_obj_t audiomixer_mixer_obj_get_sample_rate(mp_obj_t self_in) {
@@ -190,7 +190,7 @@ const mp_obj_property_t audiomixer_mixer_sample_rate_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| voice: Any = ...
+//| voice: Tuple[MixerVoice, ...] = ...
//| """A tuple of the mixer's `audiomixer.MixerVoice` object(s).
//|
//| .. code-block:: python
@@ -211,7 +211,7 @@ const mp_obj_property_t audiomixer_mixer_voice_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| def play(self, sample: Any, *, voice: Any = 0, loop: Any = False) -> Any:
+//| def play(self, sample: Union[audiomixer.WaveFile, audiocore.RawSample, audiomixer.Mixer], *, voice: int = 0, loop: bool = False) -> None:
//| """Plays the sample once when loop=False and continuously when loop=True.
//| Does not block. Use `playing` to block.
//|
@@ -244,7 +244,7 @@ STATIC mp_obj_t audiomixer_mixer_obj_play(size_t n_args, const mp_obj_t *pos_arg
}
MP_DEFINE_CONST_FUN_OBJ_KW(audiomixer_mixer_play_obj, 1, audiomixer_mixer_obj_play);
-//| def stop_voice(self, voice: Any = 0) -> Any:
+//| def stop_voice(self, voice: int = 0) -> None:
//| """Stops playback of the sample on the given voice."""
//| ...
//|
diff --git a/shared-bindings/audiomixer/MixerVoice.c b/shared-bindings/audiomixer/MixerVoice.c
index ec5768d2f..26a044d46 100644
--- a/shared-bindings/audiomixer/MixerVoice.c
+++ b/shared-bindings/audiomixer/MixerVoice.c
@@ -42,7 +42,7 @@
//|
//| Used to access and control samples with `audiomixer.Mixer`."""
//|
-//| def __init__(self, ):
+//| def __init__(self) -> None:
//| """MixerVoice instance object(s) created by `audiomixer.Mixer`."""
//| ...
//|
@@ -56,7 +56,7 @@ STATIC mp_obj_t audiomixer_mixervoice_make_new(const mp_obj_type_t *type, size_t
return MP_OBJ_FROM_PTR(self);
}
-//| def play(self, sample: Any, *, loop: Any = False) -> Any:
+//| def play(self, sample: Union[audiocore.WaveFile, Mixer, audiocore.RawSample], *, loop: bool = False) -> None:
//| """Plays the sample once when ``loop=False``, and continuously when ``loop=True``.
//| Does not block. Use `playing` to block.
//|
@@ -81,7 +81,7 @@ STATIC mp_obj_t audiomixer_mixervoice_obj_play(size_t n_args, const mp_obj_t *po
}
MP_DEFINE_CONST_FUN_OBJ_KW(audiomixer_mixervoice_play_obj, 1, audiomixer_mixervoice_obj_play);
-//| def stop(self, ) -> Any:
+//| def stop(self) -> None:
//| """Stops playback of the sample on this voice."""
//| ...
//|
@@ -100,7 +100,7 @@ STATIC mp_obj_t audiomixer_mixervoice_obj_stop(size_t n_args, const mp_obj_t *po
}
MP_DEFINE_CONST_FUN_OBJ_KW(audiomixer_mixervoice_stop_obj, 1, audiomixer_mixervoice_obj_stop);
-//| level: Any = ...
+//| level: float = ...
//| """The volume level of a voice, as a floating point number between 0 and 1."""
//|
STATIC mp_obj_t audiomixer_mixervoice_obj_get_level(mp_obj_t self_in) {
@@ -136,7 +136,7 @@ const mp_obj_property_t audiomixer_mixervoice_level_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| playing: Any = ...
+//| playing: bool = ...
//| """True when this voice is being output. (read-only)"""
//|
diff --git a/shared-bindings/audiomp3/MP3Decoder.c b/shared-bindings/audiomp3/MP3Decoder.c
index e6d48e32c..b7bb44957 100644
--- a/shared-bindings/audiomp3/MP3Decoder.c
+++ b/shared-bindings/audiomp3/MP3Decoder.c
@@ -37,7 +37,7 @@
//| class MP3:
//| """Load a mp3 file for audio playback"""
//|
-//| def __init__(self, file: typing.BinaryIO, buffer: bytearray):
+//| def __init__(self, file: typing.BinaryIO, buffer: WriteableBuffer) -> None:
//|
//| """Load a .mp3 file for playback with `audioio.AudioOut` or `audiobusio.I2SOut`.
//|
@@ -89,7 +89,7 @@ STATIC mp_obj_t audiomp3_mp3file_make_new(const mp_obj_type_t *type, size_t n_ar
return MP_OBJ_FROM_PTR(self);
}
-//| def deinit(self, ) -> Any:
+//| def deinit(self) -> None:
//| """Deinitialises the MP3 and releases all memory resources for reuse."""
//| ...
//|
@@ -106,13 +106,13 @@ STATIC void check_for_deinit(audiomp3_mp3file_obj_t *self) {
}
}
-//| def __enter__(self, ) -> Any:
+//| def __enter__(self) -> MP3:
//| """No-op used by Context Managers."""
//| ...
//|
// Provided by context manager helper.
-//| def __exit__(self, ) -> Any:
+//| def __exit__(self) -> None:
//| """Automatically deinitializes the hardware when exiting a context. See
//| :ref:`lifetime-and-contextmanagers` for more info."""
//| ...
@@ -124,7 +124,7 @@ STATIC mp_obj_t audiomp3_mp3file_obj___exit__(size_t n_args, const mp_obj_t *arg
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audiomp3_mp3file___exit___obj, 4, 4, audiomp3_mp3file_obj___exit__);
-//| file: Any = ...
+//| file: file = ...
//| """File to play back."""
//|
STATIC mp_obj_t audiomp3_mp3file_obj_get_file(mp_obj_t self_in) {
@@ -154,7 +154,7 @@ const mp_obj_property_t audiomp3_mp3file_file_obj = {
-//| sample_rate: Any = ...
+//| sample_rate: int = ...
//| """32 bit value that dictates how quickly samples are loaded into the DAC
//| in Hertz (cycles per second). When the sample is looped, this can change
//| the pitch output without changing the underlying sample."""
@@ -181,7 +181,7 @@ const mp_obj_property_t audiomp3_mp3file_sample_rate_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| bits_per_sample: Any = ...
+//| bits_per_sample: int = ...
//| """Bits per sample. (read only)"""
//|
STATIC mp_obj_t audiomp3_mp3file_obj_get_bits_per_sample(mp_obj_t self_in) {
@@ -198,7 +198,7 @@ const mp_obj_property_t audiomp3_mp3file_bits_per_sample_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| channel_count: Any = ...
+//| channel_count: int = ...
//| """Number of audio channels. (read only)"""
//|
STATIC mp_obj_t audiomp3_mp3file_obj_get_channel_count(mp_obj_t self_in) {
@@ -215,7 +215,7 @@ const mp_obj_property_t audiomp3_mp3file_channel_count_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| rms_level: Any = ...
+//| rms_level: float = ...
//| """The RMS audio level of a recently played moment of audio. (read only)"""
//|
STATIC mp_obj_t audiomp3_mp3file_obj_get_rms_level(mp_obj_t self_in) {
diff --git a/shared-bindings/audiopwmio/PWMAudioOut.c b/shared-bindings/audiopwmio/PWMAudioOut.c
index 812b7330d..1d740823a 100644
--- a/shared-bindings/audiopwmio/PWMAudioOut.c
+++ b/shared-bindings/audiopwmio/PWMAudioOut.c
@@ -39,7 +39,7 @@
//| class PWMAudioOut:
//| """Output an analog audio signal by varying the PWM duty cycle."""
//|
-//| def __init__(self, left_channel: microcontroller.Pin, *, right_channel: microcontroller.Pin = None, quiescent_value: int = 0x8000):
+//| def __init__(self, left_channel: microcontroller.Pin, *, right_channel: microcontroller.Pin = None, quiescent_value: int = 0x8000) -> None:
//| """Create a PWMAudioOut object associated with the given pin(s). This allows you to
//| play audio signals out on the given pin(s). In contrast to mod:`audioio`,
//| the pin(s) specified are digital pins, and are driven with a device-dependent PWM
@@ -114,7 +114,7 @@ STATIC mp_obj_t audiopwmio_pwmaudioout_make_new(const mp_obj_type_t *type, size_
return MP_OBJ_FROM_PTR(self);
}
-//| def deinit(self, ) -> Any:
+//| def deinit(self) -> None:
//| """Deinitialises the PWMAudioOut and releases any hardware resources for reuse."""
//| ...
//|
@@ -130,13 +130,13 @@ STATIC void check_for_deinit(audiopwmio_pwmaudioout_obj_t *self) {
raise_deinited_error();
}
}
-//| def __enter__(self, ) -> Any:
+//| def __enter__(self) -> PWMAudioOut:
//| """No-op used by Context Managers."""
//| ...
//|
// Provided by context manager helper.
-//| def __exit__(self, ) -> Any:
+//| def __exit__(self) -> None:
//| """Automatically deinitializes the hardware when exiting a context. See
//| :ref:`lifetime-and-contextmanagers` for more info."""
//| ...
@@ -148,7 +148,7 @@ STATIC mp_obj_t audiopwmio_pwmaudioout_obj___exit__(size_t n_args, const mp_obj_
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audiopwmio_pwmaudioout___exit___obj, 4, 4, audiopwmio_pwmaudioout_obj___exit__);
-//| def play(self, sample: Any, *, loop: Any = False) -> Any:
+//| def play(self, sample: Union[audiocore.WaveFile, audiocore.RawSample, audiomixer.Mixer], *, loop: bool = False) -> None:
//| """Plays the sample once when loop=False and continuously when loop=True.
//| Does not block. Use `playing` to block.
//|
@@ -177,7 +177,7 @@ STATIC mp_obj_t audiopwmio_pwmaudioout_obj_play(size_t n_args, const mp_obj_t *p
}
MP_DEFINE_CONST_FUN_OBJ_KW(audiopwmio_pwmaudioout_play_obj, 1, audiopwmio_pwmaudioout_obj_play);
-//| def stop(self, ) -> Any:
+//| def stop(self) -> None:
//| """Stops playback and resets to the start of the sample."""
//| ...
//|
@@ -189,7 +189,7 @@ STATIC mp_obj_t audiopwmio_pwmaudioout_obj_stop(mp_obj_t self_in) {
}
MP_DEFINE_CONST_FUN_OBJ_1(audiopwmio_pwmaudioout_stop_obj, audiopwmio_pwmaudioout_obj_stop);
-//| playing: Any = ...
+//| playing: bool = ...
//| """True when an audio sample is being output even if `paused`. (read-only)"""
//|
STATIC mp_obj_t audiopwmio_pwmaudioout_obj_get_playing(mp_obj_t self_in) {
@@ -206,7 +206,7 @@ const mp_obj_property_t audiopwmio_pwmaudioout_playing_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| def pause(self, ) -> Any:
+//| def pause(self) -> None:
//| """Stops playback temporarily while remembering the position. Use `resume` to resume playback."""
//| ...
//|
@@ -222,7 +222,7 @@ STATIC mp_obj_t audiopwmio_pwmaudioout_obj_pause(mp_obj_t self_in) {
}
MP_DEFINE_CONST_FUN_OBJ_1(audiopwmio_pwmaudioout_pause_obj, audiopwmio_pwmaudioout_obj_pause);
-//| def resume(self, ) -> Any:
+//| def resume(self) -> None:
//| """Resumes sample playback after :py:func:`pause`."""
//| ...
//|
@@ -238,7 +238,7 @@ STATIC mp_obj_t audiopwmio_pwmaudioout_obj_resume(mp_obj_t self_in) {
}
MP_DEFINE_CONST_FUN_OBJ_1(audiopwmio_pwmaudioout_resume_obj, audiopwmio_pwmaudioout_obj_resume);
-//| paused: Any = ...
+//| paused: bool = ...
//| """True when playback is paused. (read-only)"""
//|
STATIC mp_obj_t audiopwmio_pwmaudioout_obj_get_paused(mp_obj_t self_in) {
diff --git a/shared-bindings/bitbangio/I2C.c b/shared-bindings/bitbangio/I2C.c
index 43fe11e62..212956726 100644
--- a/shared-bindings/bitbangio/I2C.c
+++ b/shared-bindings/bitbangio/I2C.c
@@ -40,7 +40,7 @@
//| class I2C:
//| """Two wire serial protocol"""
//|
-//| def __init__(self, scl: microcontroller.Pin, sda: microcontroller.Pin, *, frequency: int = 400000, timeout: int):
+//| def __init__(self, scl: microcontroller.Pin, sda: microcontroller.Pin, *, frequency: int = 400000, timeout: int) -> None:
//| """I2C is a two-wire protocol for communicating between devices. At the
//| physical level it consists of 2 wires: SCL and SDA, the clock and data
//| lines respectively.
@@ -79,7 +79,7 @@ STATIC mp_obj_t bitbangio_i2c_make_new(const mp_obj_type_t *type, size_t n_args,
return (mp_obj_t)self;
}
-//| def deinit(self, ) -> Any:
+//| def deinit(self) -> None:
//| """Releases control of the underlying hardware so other classes can use it."""
//| ...
//|
@@ -96,13 +96,13 @@ STATIC void check_for_deinit(bitbangio_i2c_obj_t *self) {
}
}
-//| def __enter__(self, ) -> Any:
+//| def __enter__(self) -> I2C:
//| """No-op used in Context Managers."""
//| ...
//|
// Provided by context manager helper.
-//| def __exit__(self, ) -> Any:
+//| def __exit__(self) -> None:
//| """Automatically deinitializes the hardware on context exit. See
//| :ref:`lifetime-and-contextmanagers` for more info."""
//| ...
@@ -120,7 +120,7 @@ static void check_lock(bitbangio_i2c_obj_t *self) {
}
}
-//| def scan(self, ) -> Any:
+//| def scan(self) -> list:
//| """Scan all I2C addresses between 0x08 and 0x77 inclusive and return a list of
//| those that respond. A device responds if it pulls the SDA line low after
//| its address (including a read bit) is sent on the bus."""
@@ -142,7 +142,7 @@ STATIC mp_obj_t bitbangio_i2c_scan(mp_obj_t self_in) {
}
MP_DEFINE_CONST_FUN_OBJ_1(bitbangio_i2c_scan_obj, bitbangio_i2c_scan);
-//| def try_lock(self, ) -> Any:
+//| def try_lock(self) -> bool:
//| """Attempts to grab the I2C lock. Returns True on success."""
//| ...
//|
@@ -153,7 +153,7 @@ STATIC mp_obj_t bitbangio_i2c_obj_try_lock(mp_obj_t self_in) {
}
MP_DEFINE_CONST_FUN_OBJ_1(bitbangio_i2c_try_lock_obj, bitbangio_i2c_obj_try_lock);
-//| def unlock(self, ) -> Any:
+//| def unlock(self) -> None:
//| """Releases the I2C lock."""
//| ...
//|
@@ -165,7 +165,7 @@ 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: bytearray, *, start: int = 0, end: int = None) -> Any:
+//| def readfrom_into(self, address: int, buffer: WriteableBuffer, *, start: int = 0, end: int = None) -> 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.
@@ -217,7 +217,7 @@ STATIC mp_obj_t bitbangio_i2c_readfrom_into(size_t n_args, const mp_obj_t *pos_a
}
MP_DEFINE_CONST_FUN_OBJ_KW(bitbangio_i2c_readfrom_into_obj, 3, bitbangio_i2c_readfrom_into);
-//| def writeto(self, address: int, buffer: bytearray, *, start: int = 0, end: int = None, stop: bool = True) -> Any:
+//| def writeto(self, address: int, buffer: ReadableBuffer, *, start: int = 0, end: int = None, stop: bool = True) -> 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.
@@ -232,9 +232,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(bitbangio_i2c_readfrom_into_obj, 3, bitbangio_i2c_rea
//| :param int address: 7-bit device address
//| :param bytearray 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 bool stop: If true, output an I2C stop condition after the buffer is written.
-//| Deprecated. Will be removed in 6.x and act as stop=True."""
+//| :param int end: Index to read up to but not include"""
//| ...
//|
// Shared arg parsing for writeto and writeto_then_readfrom.
@@ -256,13 +254,12 @@ STATIC void writeto(bitbangio_i2c_obj_t *self, mp_int_t address, mp_obj_t buffer
}
STATIC mp_obj_t bitbangio_i2c_writeto(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
- enum { ARG_address, ARG_buffer, ARG_start, ARG_end, ARG_stop };
+ enum { ARG_address, ARG_buffer, ARG_start, ARG_end };
static const mp_arg_t allowed_args[] = {
{ MP_QSTR_address, MP_ARG_REQUIRED | MP_ARG_INT, {.u_int = 0} },
{ MP_QSTR_buffer, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
{ MP_QSTR_start, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} },
{ MP_QSTR_end, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = INT_MAX} },
- { MP_QSTR_stop, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = true} },
};
bitbangio_i2c_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]);
check_for_deinit(self);
@@ -271,13 +268,13 @@ STATIC mp_obj_t bitbangio_i2c_writeto(size_t n_args, const mp_obj_t *pos_args, m
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
writeto(self, args[ARG_address].u_int, args[ARG_buffer].u_obj, args[ARG_start].u_int,
- args[ARG_end].u_int, args[ARG_stop].u_bool);
+ args[ARG_end].u_int, true);
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bitbangio_i2c_writeto_obj, 1, bitbangio_i2c_writeto);
-//| def writeto_then_readfrom(self, address: int, out_buffer: bytearray, in_buffer: bytearray, *, out_start: int = 0, out_end: int = None, in_start: int = 0, in_end: int = None) -> Any:
+//| def writeto_then_readfrom(self, address: int, out_buffer: WriteableBuffer, in_buffer: ReadableBuffer, *, out_start: int = 0, out_end: int = None, in_start: int = 0, in_end: int = None) -> 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.
diff --git a/shared-bindings/bitbangio/OneWire.c b/shared-bindings/bitbangio/OneWire.c
index a236f4c2a..da94a393e 100644
--- a/shared-bindings/bitbangio/OneWire.c
+++ b/shared-bindings/bitbangio/OneWire.c
@@ -42,7 +42,7 @@
//|
//| Protocol definition is here: https://www.maximintegrated.com/en/app-notes/index.mvp/id/126"""
//|
-//| def __init__(self, pin: microcontroller.Pin):
+//| def __init__(self, pin: microcontroller.Pin) -> None:
//|
//| """Create a OneWire object associated with the given pin. The object
//| implements the lowest level timing-sensitive bits of the protocol.
@@ -78,7 +78,7 @@ STATIC mp_obj_t bitbangio_onewire_make_new(const mp_obj_type_t *type, size_t n_a
return MP_OBJ_FROM_PTR(self);
}
-//| def deinit(self, ) -> Any:
+//| def deinit(self) -> None:
//| """Deinitialize the OneWire bus and release any hardware resources for reuse."""
//| ...
//|
@@ -95,13 +95,13 @@ STATIC void check_for_deinit(bitbangio_onewire_obj_t *self) {
}
}
-//| def __enter__(self, ) -> Any:
+//| def __enter__(self) -> OneWire:
//| """No-op used by Context Managers."""
//| ...
//|
// Provided by context manager helper.
-//| def __exit__(self, ) -> Any:
+//| def __exit__(self) -> None:
//| """Automatically deinitializes the hardware when exiting a context. See
//| :ref:`lifetime-and-contextmanagers` for more info."""
//| ...
@@ -113,7 +113,7 @@ STATIC mp_obj_t bitbangio_onewire_obj___exit__(size_t n_args, const mp_obj_t *ar
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bitbangio_onewire___exit___obj, 4, 4, bitbangio_onewire_obj___exit__);
-//| def reset(self, ) -> Any:
+//| def reset(self) -> bool:
//| """Reset the OneWire bus"""
//| ...
//|
@@ -125,7 +125,7 @@ STATIC mp_obj_t bitbangio_onewire_obj_reset(mp_obj_t self_in) {
}
MP_DEFINE_CONST_FUN_OBJ_1(bitbangio_onewire_reset_obj, bitbangio_onewire_obj_reset);
-//| def read_bit(self, ) -> Any:
+//| def read_bit(self) -> bool:
//| """Read in a bit
//|
//| :returns: bit state read
@@ -140,7 +140,7 @@ STATIC mp_obj_t bitbangio_onewire_obj_read_bit(mp_obj_t self_in) {
}
MP_DEFINE_CONST_FUN_OBJ_1(bitbangio_onewire_read_bit_obj, bitbangio_onewire_obj_read_bit);
-//| def write_bit(self, value: Any) -> Any:
+//| def write_bit(self, value: bool) -> None:
//| """Write out a bit based on value."""
//| ...
//|
diff --git a/shared-bindings/bitbangio/SPI.c b/shared-bindings/bitbangio/SPI.c
index 6d31037c7..0a4d62361 100644
--- a/shared-bindings/bitbangio/SPI.c
+++ b/shared-bindings/bitbangio/SPI.c
@@ -51,7 +51,7 @@
//| multiple secondaries can share the `!clock`, `!MOSI` and `!MISO` lines
//| and therefore the hardware.)"""
//|
-//| def __init__(self, clock: microcontroller.Pin, MOSI: microcontroller.Pin = None, MISO: microcontroller.Pin = None):
+//| def __init__(self, clock: microcontroller.Pin, MOSI: microcontroller.Pin = None, MISO: microcontroller.Pin = None) -> None:
//| """Construct an SPI object on the given pins.
//|
//| .. seealso:: Using this class directly requires careful lock management.
@@ -90,7 +90,7 @@ STATIC mp_obj_t bitbangio_spi_make_new(const mp_obj_type_t *type, size_t n_args,
return (mp_obj_t)self;
}
-//| def deinit(self, ) -> Any:
+//| def deinit(self) -> None:
//| """Turn off the SPI bus."""
//| ...
//|
@@ -107,13 +107,13 @@ STATIC void check_for_deinit(bitbangio_spi_obj_t *self) {
}
}
-//| def __enter__(self, ) -> Any:
+//| def __enter__(self) -> SPI:
//| """No-op used by Context Managers."""
//| ...
//|
// Provided by context manager helper.
-//| def __exit__(self, ) -> Any:
+//| def __exit__(self) -> None:
//| """Automatically deinitializes the hardware when exiting a context. See
//| :ref:`lifetime-and-contextmanagers` for more info."""
//| ...
@@ -132,7 +132,7 @@ static void check_lock(bitbangio_spi_obj_t *self) {
}
}
-//| def configure(self, *, baudrate: int = 100000, polarity: int = 0, phase: int = 0, bits: int = 8) -> Any:
+//| def configure(self, *, baudrate: int = 100000, polarity: int = 0, phase: int = 0, bits: int = 8) -> None:
//| """Configures the SPI bus. Only valid when locked.
//|
//| :param int baudrate: the clock rate in Hertz
@@ -174,7 +174,7 @@ STATIC mp_obj_t bitbangio_spi_configure(size_t n_args, const mp_obj_t *pos_args,
}
MP_DEFINE_CONST_FUN_OBJ_KW(bitbangio_spi_configure_obj, 1, bitbangio_spi_configure);
-//| def try_lock(self, ) -> Any:
+//| def try_lock(self) -> bool:
//| """Attempts to grab the SPI lock. Returns True on success.
//|
//| :return: True when lock has been grabbed
@@ -188,7 +188,7 @@ STATIC mp_obj_t bitbangio_spi_obj_try_lock(mp_obj_t self_in) {
}
MP_DEFINE_CONST_FUN_OBJ_1(bitbangio_spi_try_lock_obj, bitbangio_spi_obj_try_lock);
-//| def unlock(self, ) -> Any:
+//| def unlock(self) -> None:
//| """Releases the SPI lock."""
//| ...
//|
@@ -200,7 +200,7 @@ STATIC mp_obj_t bitbangio_spi_obj_unlock(mp_obj_t self_in) {
}
MP_DEFINE_CONST_FUN_OBJ_1(bitbangio_spi_unlock_obj, bitbangio_spi_obj_unlock);
-//| def write(self, buf: Any) -> Any:
+//| def write(self, buf: ReadableBuffer) -> None:
//| """Write the data contained in ``buf``. Requires the SPI being locked.
//| If the buffer is empty, nothing happens."""
//| ...
@@ -224,7 +224,7 @@ 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, buf: Any) -> Any:
+//| def readinto(self, buf: WriteableBuffer) -> None:
//| """Read into the buffer specified by ``buf`` while writing zeroes.
//| Requires the SPI being locked.
//| If the number of bytes to read is 0, nothing happens."""
@@ -248,7 +248,7 @@ STATIC mp_obj_t bitbangio_spi_readinto(size_t n_args, const mp_obj_t *args) {
}
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bitbangio_spi_readinto_obj, 2, 2, bitbangio_spi_readinto);
-//| def write_readinto(self, buffer_out: bytearray, buffer_in: bytearray, *, out_start: Any = 0, out_end: int = None, in_start: Any = 0, in_end: int = None) -> Any:
+//| def write_readinto(self, buffer_out: ReadableBuffer, buffer_in: WriteableBuffer, *, out_start: int = 0, out_end: int = None, in_start: int = 0, in_end: int = None) -> None:
//| """Write out the data in ``buffer_out`` while simultaneously reading data into ``buffer_in``.
//| The lengths of the slices defined by ``buffer_out[out_start:out_end]`` and ``buffer_in[in_start:in_end]``
//| must be equal.
diff --git a/shared-bindings/board/__init__.c b/shared-bindings/board/__init__.c
index 010a9fb92..6837fc41c 100644
--- a/shared-bindings/board/__init__.c
+++ b/shared-bindings/board/__init__.c
@@ -37,7 +37,7 @@
//| .. warning:: The board module varies by board. The APIs documented here may or may not be
//| available on a specific board."""
-//| def I2C() -> Any:
+//| def I2C() -> busio.I2C:
//| """Returns the `busio.I2C` object for the board designated SDA and SCL pins. It is a singleton."""
//| ...
//|
@@ -61,7 +61,7 @@ mp_obj_t board_i2c(void) {
MP_DEFINE_CONST_FUN_OBJ_0(board_i2c_obj, board_i2c);
-//| def SPI() -> Any:
+//| def SPI() -> busio.SPI:
//| """Returns the `busio.SPI` object for the board designated SCK, MOSI and MISO pins. It is a
//| singleton."""
//| ...
@@ -85,7 +85,7 @@ mp_obj_t board_spi(void) {
#endif
MP_DEFINE_CONST_FUN_OBJ_0(board_spi_obj, board_spi);
-//| def UART() -> Any:
+//| def UART() -> busio.UART:
//| """Returns the `busio.UART` object for the board designated TX and RX pins. It is a singleton.
//|
//| The object created uses the default parameter values for `busio.UART`. If you need to set
diff --git a/shared-bindings/busio/I2C.c b/shared-bindings/busio/I2C.c
index b61dd93f3..2b965fbe9 100644
--- a/shared-bindings/busio/I2C.c
+++ b/shared-bindings/busio/I2C.c
@@ -39,7 +39,7 @@
//| class I2C:
//| """Two wire serial protocol"""
//|
-//| def __init__(self, scl: microcontroller.Pin, sda: microcontroller.Pin, *, frequency: int = 400000, timeout: int = 255):
+//| def __init__(self, scl: microcontroller.Pin, sda: microcontroller.Pin, *, frequency: int = 400000, timeout: int = 255) -> None:
//|
//| """I2C is a two-wire protocol for communicating between devices. At the
//| physical level it consists of 2 wires: SCL and SDA, the clock and data
@@ -83,7 +83,7 @@ STATIC mp_obj_t busio_i2c_make_new(const mp_obj_type_t *type, size_t n_args, con
return (mp_obj_t)self;
}
-//| def deinit(self, ) -> Any:
+//| def deinit(self) -> None:
//| """Releases control of the underlying hardware so other classes can use it."""
//| ...
//|
@@ -100,13 +100,13 @@ STATIC void check_for_deinit(busio_i2c_obj_t *self) {
}
}
-//| def __enter__(self, ) -> Any:
+//| def __enter__(self) -> I2C:
//| """No-op used in Context Managers."""
//| ...
//|
// Provided by context manager helper.
-//| def __exit__(self, ) -> Any:
+//| def __exit__(self) -> None:
//| """Automatically deinitializes the hardware on context exit. See
//| :ref:`lifetime-and-contextmanagers` for more info."""
//| ...
@@ -125,7 +125,7 @@ static void check_lock(busio_i2c_obj_t *self) {
}
}
-//| def scan(self, ) -> Any:
+//| def scan(self) -> list:
//|
//| """Scan all I2C addresses between 0x08 and 0x77 inclusive and return a
//| list of those that respond.
@@ -150,7 +150,7 @@ STATIC mp_obj_t busio_i2c_scan(mp_obj_t self_in) {
}
MP_DEFINE_CONST_FUN_OBJ_1(busio_i2c_scan_obj, busio_i2c_scan);
-//| def try_lock(self, ) -> Any:
+//| def try_lock(self) -> bool:
//| """Attempts to grab the I2C lock. Returns True on success.
//|
//| :return: True when lock has been grabbed
@@ -164,7 +164,7 @@ STATIC mp_obj_t busio_i2c_obj_try_lock(mp_obj_t self_in) {
}
MP_DEFINE_CONST_FUN_OBJ_1(busio_i2c_try_lock_obj, busio_i2c_obj_try_lock);
-//| def unlock(self, ) -> Any:
+//| def unlock(self) -> None:
//| """Releases the I2C lock."""
//| ...
//|
@@ -176,7 +176,7 @@ 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: bytearray, *, start: int = 0, end: int = None) -> Any:
+//| def readfrom_into(self, address: int, buffer: WriteableBuffer, *, start: int = 0, end: int = None) -> 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.
@@ -228,11 +228,9 @@ STATIC mp_obj_t busio_i2c_readfrom_into(size_t n_args, const mp_obj_t *pos_args,
}
MP_DEFINE_CONST_FUN_OBJ_KW(busio_i2c_readfrom_into_obj, 3, busio_i2c_readfrom_into);
-//| def writeto(self, address: int, buffer: bytearray, *, start: int = 0, end: int = None, stop: bool = True) -> Any:
-//| """Write the bytes from ``buffer`` to the device selected by ``address``.
-//| Transmits a stop bit when stop is True. Setting stop=False is deprecated and stop will be
-//| removed in CircuitPython 6.x. Use `writeto_then_readfrom` when needing a write, no stop and
-//| repeated start before a read.
+//| def writeto(self, address: int, buffer: ReadableBuffer, *, start: int = 0, end: int = None, stop: bool = True) -> 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
@@ -244,9 +242,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(busio_i2c_readfrom_into_obj, 3, busio_i2c_readfrom_in
//| :param int address: 7-bit device address
//| :param bytearray 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 bool stop: If true, output an I2C stop condition after the buffer is written.
-//| Deprecated. Will be removed in 6.x and act as stop=True."""
+//| :param int end: Index to read up to but not include. Defaults to ``len(buffer)``"""
//| ...
//|
// Shared arg parsing for writeto and writeto_then_readfrom.
@@ -267,13 +263,12 @@ STATIC void writeto(busio_i2c_obj_t *self, mp_int_t address, mp_obj_t buffer, in
}
STATIC mp_obj_t busio_i2c_writeto(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
- enum { ARG_address, ARG_buffer, ARG_start, ARG_end, ARG_stop };
+ enum { ARG_address, ARG_buffer, ARG_start, ARG_end };
static const mp_arg_t allowed_args[] = {
{ MP_QSTR_address, MP_ARG_REQUIRED | MP_ARG_INT, {.u_int = 0} },
{ MP_QSTR_buffer, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
{ MP_QSTR_start, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} },
{ MP_QSTR_end, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = INT_MAX} },
- { MP_QSTR_stop, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = true} },
};
busio_i2c_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]);
check_for_deinit(self);
@@ -282,12 +277,12 @@ STATIC mp_obj_t busio_i2c_writeto(size_t n_args, const mp_obj_t *pos_args, mp_ma
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
writeto(self, args[ARG_address].u_int, args[ARG_buffer].u_obj, args[ARG_start].u_int,
- args[ARG_end].u_int, args[ARG_stop].u_bool);
+ args[ARG_end].u_int, true);
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(busio_i2c_writeto_obj, 1, busio_i2c_writeto);
-//| def writeto_then_readfrom(self, address: int, out_buffer: bytearray, in_buffer: bytearray, *, out_start: int = 0, out_end: int = None, in_start: int = 0, in_end: int = None) -> Any:
+//| def writeto_then_readfrom(self, address: int, out_buffer: ReadableBuffer, in_buffer: WriteableBuffer, *, out_start: int = 0, out_end: int = None, in_start: int = 0, in_end: int = None) -> 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.
diff --git a/shared-bindings/busio/OneWire.c b/shared-bindings/busio/OneWire.c
index 723cc031a..1fae39181 100644
--- a/shared-bindings/busio/OneWire.c
+++ b/shared-bindings/busio/OneWire.c
@@ -37,7 +37,7 @@
//| class OneWire:
//| """Lowest-level of the Maxim OneWire protocol"""
//|
-//| def __init__(self, pin: microcontroller.Pin):
+//| def __init__(self, pin: microcontroller.Pin) -> None:
//| """(formerly Dallas Semi) OneWire protocol.
//|
//| Protocol definition is here: https://www.maximintegrated.com/en/app-notes/index.mvp/id/126
@@ -77,7 +77,7 @@ STATIC mp_obj_t busio_onewire_make_new(const mp_obj_type_t *type, size_t n_args,
return MP_OBJ_FROM_PTR(self);
}
-//| def deinit(self, ) -> Any:
+//| def deinit(self) -> None:
//| """Deinitialize the OneWire bus and release any hardware resources for reuse."""
//| ...
//|
@@ -94,13 +94,13 @@ STATIC void check_for_deinit(busio_onewire_obj_t *self) {
}
}
-//| def __enter__(self, ) -> Any:
+//| def __enter__(self) -> OneWire:
//| """No-op used by Context Managers."""
//| ...
//|
// Provided by context manager helper.
-//| def __exit__(self, ) -> Any:
+//| def __exit__(self) -> None:
//| """Automatically deinitializes the hardware when exiting a context. See
//| :ref:`lifetime-and-contextmanagers` for more info."""
//| ...
@@ -112,7 +112,7 @@ STATIC mp_obj_t busio_onewire_obj___exit__(size_t n_args, const mp_obj_t *args)
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(busio_onewire___exit___obj, 4, 4, busio_onewire_obj___exit__);
-//| def reset(self, ) -> Any:
+//| def reset(self) -> bool:
//| """Reset the OneWire bus and read presence
//|
//| :returns: False when at least one device is present
@@ -127,7 +127,7 @@ STATIC mp_obj_t busio_onewire_obj_reset(mp_obj_t self_in) {
}
MP_DEFINE_CONST_FUN_OBJ_1(busio_onewire_reset_obj, busio_onewire_obj_reset);
-//| def read_bit(self, ) -> Any:
+//| def read_bit(self) -> bool:
//| """Read in a bit
//|
//| :returns: bit state read
@@ -142,7 +142,7 @@ STATIC mp_obj_t busio_onewire_obj_read_bit(mp_obj_t self_in) {
}
MP_DEFINE_CONST_FUN_OBJ_1(busio_onewire_read_bit_obj, busio_onewire_obj_read_bit);
-//| def write_bit(self, value: Any) -> Any:
+//| def write_bit(self, value: bool) -> None:
//| """Write out a bit based on value."""
//| ...
//|
diff --git a/shared-bindings/busio/SPI.c b/shared-bindings/busio/SPI.c
index 793ab4f67..173f8aa6d 100644
--- a/shared-bindings/busio/SPI.c
+++ b/shared-bindings/busio/SPI.c
@@ -53,7 +53,7 @@
//| multiple secondaries can share the `!clock`, `!MOSI` and `!MISO` lines
//| and therefore the hardware.)"""
//|
-//| def __init__(self, clock: microcontroller.Pin, MOSI: microcontroller.Pin = None, MISO: microcontroller.Pin = None):
+//| def __init__(self, clock: microcontroller.Pin, MOSI: microcontroller.Pin = None, MISO: microcontroller.Pin = None) -> None:
//|
//| """Construct an SPI object on the given pins.
//|
@@ -100,7 +100,7 @@ STATIC mp_obj_t busio_spi_make_new(const mp_obj_type_t *type, size_t n_args, con
return MP_OBJ_FROM_PTR(self);
}
-//| def deinit(self, ) -> Any:
+//| def deinit(self) -> None:
//| """Turn off the SPI bus."""
//| ...
//|
@@ -111,13 +111,13 @@ STATIC mp_obj_t busio_spi_obj_deinit(mp_obj_t self_in) {
}
MP_DEFINE_CONST_FUN_OBJ_1(busio_spi_deinit_obj, busio_spi_obj_deinit);
-//| def __enter__(self, ) -> Any:
+//| def __enter__(self) -> SPI:
//| """No-op used by Context Managers.
//| Provided by context manager helper."""
//| ...
//|
-//| def __exit__(self, ) -> Any:
+//| def __exit__(self) -> None:
//| """Automatically deinitializes the hardware when exiting a context. See
//| :ref:`lifetime-and-contextmanagers` for more info."""
//| ...
@@ -142,7 +142,7 @@ STATIC void check_for_deinit(busio_spi_obj_t *self) {
}
}
-//| def configure(self, *, baudrate: int = 100000, polarity: int = 0, phase: int = 0, bits: int = 8) -> Any:
+//| def configure(self, *, baudrate: int = 100000, polarity: int = 0, phase: int = 0, bits: int = 8) -> None:
//| """Configures the SPI bus. The SPI object must be locked.
//|
//| :param int baudrate: the desired clock rate in Hertz. The actual clock rate may be higher or lower
@@ -201,7 +201,7 @@ STATIC mp_obj_t busio_spi_configure(size_t n_args, const mp_obj_t *pos_args, mp_
}
MP_DEFINE_CONST_FUN_OBJ_KW(busio_spi_configure_obj, 1, busio_spi_configure);
-//| def try_lock(self, ) -> Any:
+//| def try_lock(self) -> bool:
//| """Attempts to grab the SPI lock. Returns True on success.
//|
//| :return: True when lock has been grabbed
@@ -215,7 +215,7 @@ STATIC mp_obj_t busio_spi_obj_try_lock(mp_obj_t self_in) {
}
MP_DEFINE_CONST_FUN_OBJ_1(busio_spi_try_lock_obj, busio_spi_obj_try_lock);
-//| def unlock(self, ) -> Any:
+//| def unlock(self) -> None:
//| """Releases the SPI lock."""
//| ...
//|
@@ -228,7 +228,7 @@ 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: bytearray, *, start: Any = 0, end: int = None) -> Any:
+//| def write(self, buffer: ReadableBuffer, *, start: int = 0, end: Optional[int] = None) -> None:
//| """Write the data contained in ``buffer``. The SPI object must be locked.
//| If the buffer is empty, nothing happens.
//|
@@ -270,7 +270,7 @@ STATIC mp_obj_t busio_spi_write(size_t n_args, const mp_obj_t *pos_args, mp_map_
MP_DEFINE_CONST_FUN_OBJ_KW(busio_spi_write_obj, 2, busio_spi_write);
-//| def readinto(self, buffer: bytearray, *, start: Any = 0, end: int = None, write_value: int = 0) -> Any:
+//| def readinto(self, buffer: bytearray, *, start: int = 0, end: Optional[int] = None, 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.
@@ -314,7 +314,7 @@ STATIC mp_obj_t busio_spi_readinto(size_t n_args, const mp_obj_t *pos_args, mp_m
}
MP_DEFINE_CONST_FUN_OBJ_KW(busio_spi_readinto_obj, 2, busio_spi_readinto);
-//| def write_readinto(self, buffer_out: bytearray, buffer_in: bytearray, *, out_start: Any = 0, out_end: int = None, in_start: Any = 0, in_end: int = None) -> Any:
+//| 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``.
//| 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]``
@@ -377,7 +377,7 @@ STATIC mp_obj_t busio_spi_write_readinto(size_t n_args, const mp_obj_t *pos_args
}
MP_DEFINE_CONST_FUN_OBJ_KW(busio_spi_write_readinto_obj, 2, busio_spi_write_readinto);
-//| frequency: Any = ...
+//| frequency: int = ...
//| """The actual SPI bus frequency. This may not match the frequency requested
//| due to internal limitations."""
//|
diff --git a/shared-bindings/busio/UART.c b/shared-bindings/busio/UART.c
index a9619a8e0..c4e1f5134 100644
--- a/shared-bindings/busio/UART.c
+++ b/shared-bindings/busio/UART.c
@@ -44,7 +44,7 @@
//| class UART:
//| """A bidirectional serial protocol"""
-//| def __init__(self, tx: microcontroller.Pin, rx: microcontroller.Pin, *, baudrate: int = 9600, bits: int = 8, parity: Parity = None, stop: int = 1, timeout: float = 1, receiver_buffer_size: int = 64):
+//| def __init__(self, tx: microcontroller.Pin, rx: microcontroller.Pin, *, baudrate: int = 9600, bits: int = 8, parity: Parity = None, stop: int = 1, timeout: float = 1, receiver_buffer_size: int = 64) -> None:
//| """A common bidirectional serial protocol that uses an an agreed upon speed
//| rather than a shared clock line.
//|
@@ -142,7 +142,7 @@ STATIC mp_obj_t busio_uart_make_new(const mp_obj_type_t *type, size_t n_args, co
return (mp_obj_t)self;
}
-//| def deinit(self, ) -> Any:
+//| def deinit(self) -> None:
//| """Deinitialises the UART and releases any hardware resources for reuse."""
//| ...
//|
@@ -159,13 +159,13 @@ STATIC void check_for_deinit(busio_uart_obj_t *self) {
}
}
-//| def __enter__(self, ) -> Any:
+//| def __enter__(self) -> UART:
//| """No-op used by Context Managers."""
//| ...
//|
// Provided by context manager helper.
-//| def __exit__(self, ) -> Any:
+//| def __exit__(self) -> None:
//| """Automatically deinitializes the hardware when exiting a context. See
//| :ref:`lifetime-and-contextmanagers` for more info."""
//| ...
@@ -179,7 +179,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(busio_uart___exit___obj, 4, 4, busio_
// These are standard stream methods. Code is in py/stream.c.
//
-//| def read(self, nbytes: Any = None) -> Any:
+//| def read(self, nbytes: Optional[int] = None) -> Optional[bytes]:
//| """Read characters. If ``nbytes`` is specified then read at most that many
//| bytes. Otherwise, read everything that arrives until the connection
//| times out. Providing the number of bytes expected is highly recommended
@@ -190,7 +190,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(busio_uart___exit___obj, 4, 4, busio_
//| ...
//|
-//| def readinto(self, buf: Any) -> Any:
+//| def readinto(self, buf: WriteableBuffer) -> Optional[int]:
//| """Read bytes into the ``buf``. Read at most ``len(buf)`` bytes.
//|
//| :return: number of bytes read and stored into ``buf``
@@ -199,7 +199,8 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(busio_uart___exit___obj, 4, 4, busio_
//| *New in CircuitPython 4.0:* No length parameter is permitted."""
//| ...
//|
-//| def readline(self, ) -> Any:
+
+//| def readline(self) -> bytes:
//| """Read a line, ending in a newline character, or
//| return None if a timeout occurs sooner, or
//| return everything readable if no newline is found and timeout=0
@@ -209,7 +210,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(busio_uart___exit___obj, 4, 4, busio_
//| ...
//|
-//| def write(self, buf: Any) -> Any:
+//| def write(self, buf: WriteableBuffer) -> Optional[int]:
//| """Write the buffer of bytes to the bus.
//|
//| *New in CircuitPython 4.0:* ``buf`` must be bytes, not a string.
@@ -262,7 +263,7 @@ STATIC mp_uint_t busio_uart_ioctl(mp_obj_t self_in, mp_uint_t request, mp_uint_t
return ret;
}
-//| baudrate: Any = ...
+//| baudrate: int = ...
//| """The current baudrate."""
//|
STATIC mp_obj_t busio_uart_obj_get_baudrate(mp_obj_t self_in) {
@@ -288,7 +289,7 @@ const mp_obj_property_t busio_uart_baudrate_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| in_waiting: Any = ...
+//| in_waiting: int = ...
//| """The number of bytes in the input buffer, available to be read"""
//|
STATIC mp_obj_t busio_uart_obj_get_in_waiting(mp_obj_t self_in) {
@@ -305,7 +306,7 @@ const mp_obj_property_t busio_uart_in_waiting_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| timeout: Any = ...
+//| timeout: float = ...
//| """The current timeout, in seconds (float)."""
//|
STATIC mp_obj_t busio_uart_obj_get_timeout(mp_obj_t self_in) {
@@ -333,8 +334,9 @@ const mp_obj_property_t busio_uart_timeout_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| def reset_input_buffer(self, ) -> Any: ...
-//| """Discard any unread characters in the input buffer."""
+//| def reset_input_buffer(self) -> None:
+//| """Discard any unread characters in the input buffer."""
+//| ...
//|
STATIC mp_obj_t busio_uart_obj_reset_input_buffer(mp_obj_t self_in) {
busio_uart_obj_t *self = MP_OBJ_TO_PTR(self_in);
@@ -347,10 +349,10 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(busio_uart_reset_input_buffer_obj, busio_uart_o
//| class Parity:
//| """Enum-like class to define the parity used to verify correct data transfer."""
//|
-//| ODD: Any = ...
+//| ODD: int = ...
//| """Total number of ones should be odd."""
//|
-//| EVEN: Any = ...
+//| EVEN: int = ...
//| """Total number of ones should be even."""
//|
const mp_obj_type_t busio_uart_parity_type;
diff --git a/shared-bindings/countio/Counter.c b/shared-bindings/countio/Counter.c
index 8db795015..e40ec3b64 100644
--- a/shared-bindings/countio/Counter.c
+++ b/shared-bindings/countio/Counter.c
@@ -13,7 +13,7 @@
//| """Counter will keep track of the number of falling edge transistions (pulses) on a
//| given pin"""
//|
-//| def __init__(self, pin_a):
+//| def __init__(self, pin_a: microcontroller.Pin) -> None:
//| """Create a Counter object associated with the given pin. It tracks the number of
//| falling pulses relative when the object is constructed.
//|
diff --git a/shared-bindings/digitalio/DigitalInOut.c b/shared-bindings/digitalio/DigitalInOut.c
index 0ef527f76..603f008e3 100644
--- a/shared-bindings/digitalio/DigitalInOut.c
+++ b/shared-bindings/digitalio/DigitalInOut.c
@@ -50,7 +50,7 @@
//| a pin, see the :py:class:`analogio.AnalogIn` and
//| :py:class:`analogio.AnalogOut` classes."""
//|
-//| def __init__(self, pin: microcontroller.Pin):
+//| def __init__(self, pin: microcontroller.Pin) -> None:
//| """Create a new DigitalInOut object associated with the pin. Defaults to input
//| with no pull. Use :py:meth:`switch_to_input` and
//| :py:meth:`switch_to_output` to change the direction.
@@ -82,13 +82,13 @@ STATIC mp_obj_t digitalio_digitalinout_obj_deinit(mp_obj_t self_in) {
}
MP_DEFINE_CONST_FUN_OBJ_1(digitalio_digitalinout_deinit_obj, digitalio_digitalinout_obj_deinit);
-//| def __enter__(self, ) -> DigitalInOut:
+//| def __enter__(self) -> DigitalInOut:
//| """No-op used by Context Managers."""
//| ...
//|
// Provided by context manager helper.
-//| def __exit__(self, ) -> None:
+//| def __exit__(self) -> None:
//| """Automatically deinitializes the hardware when exiting a context. See
//| :ref:`lifetime-and-contextmanagers` for more info."""
//| ...
diff --git a/shared-bindings/digitalio/Direction.c b/shared-bindings/digitalio/Direction.c
index dbd0e93e4..173ebfb2b 100644
--- a/shared-bindings/digitalio/Direction.c
+++ b/shared-bindings/digitalio/Direction.c
@@ -41,15 +41,15 @@
//| class Direction:
//| """Defines the direction of a digital pin"""
//|
-//| def __init__(self, ):
+//| def __init__(self) -> None:
//| """Enum-like class to define which direction the digital values are
//| going."""
//| ...
//|
-//| INPUT: Any = ...
+//| INPUT: Direction = ...
//| """Read digital data in"""
//|
-//| OUTPUT: Any = ...
+//| OUTPUT: Direction = ...
//| """Write digital data out"""
//|
const mp_obj_type_t digitalio_direction_type;
diff --git a/shared-bindings/digitalio/Direction.h b/shared-bindings/digitalio/Direction.h
index d71f48c2e..17e1eda8d 100644
--- a/shared-bindings/digitalio/Direction.h
+++ b/shared-bindings/digitalio/Direction.h
@@ -37,7 +37,7 @@ typedef struct {
mp_obj_base_t base;
} digitalio_direction_obj_t;
-const mp_obj_type_t digitalio_direction_type;
+extern const mp_obj_type_t digitalio_direction_type;
extern const digitalio_direction_obj_t digitalio_direction_input_obj;
extern const digitalio_direction_obj_t digitalio_direction_output_obj;
diff --git a/shared-bindings/digitalio/DriveMode.c b/shared-bindings/digitalio/DriveMode.c
index 31b682d38..2f22029b0 100644
--- a/shared-bindings/digitalio/DriveMode.c
+++ b/shared-bindings/digitalio/DriveMode.c
@@ -29,15 +29,15 @@
//| class DriveMode:
//| """Defines the drive mode of a digital pin"""
//|
-//| def __init__(self, ):
+//| def __init__(self) -> None:
//| """Enum-like class to define the drive mode used when outputting
//| digital values."""
//| ...
//|
-//| PUSH_PULL: Any = ...
+//| PUSH_PULL: DriveMode = ...
//| """Output both high and low digital values"""
//|
-//| OPEN_DRAIN: Any = ...
+//| OPEN_DRAIN: DriveMode = ...
//| """Output low digital values but go into high z for digital high. This is
//| useful for i2c and other protocols that share a digital line."""
//|
diff --git a/shared-bindings/digitalio/DriveMode.h b/shared-bindings/digitalio/DriveMode.h
index 47d036b3a..01ecaa4ae 100644
--- a/shared-bindings/digitalio/DriveMode.h
+++ b/shared-bindings/digitalio/DriveMode.h
@@ -38,7 +38,7 @@ typedef struct {
mp_obj_base_t base;
} digitalio_drive_mode_obj_t;
-const mp_obj_type_t digitalio_drive_mode_type;
+extern const mp_obj_type_t digitalio_drive_mode_type;
extern const digitalio_drive_mode_obj_t digitalio_drive_mode_push_pull_obj;
extern const digitalio_drive_mode_obj_t digitalio_drive_mode_open_drain_obj;
diff --git a/shared-bindings/digitalio/Pull.c b/shared-bindings/digitalio/Pull.c
index 9aeec1f33..87e2a8f1e 100644
--- a/shared-bindings/digitalio/Pull.c
+++ b/shared-bindings/digitalio/Pull.c
@@ -29,16 +29,16 @@
//| class Pull:
//| """Defines the pull of a digital input pin"""
//|
-//| def __init__(self, ):
+//| def __init__(self) -> None:
//| """Enum-like class to define the pull value, if any, used while reading
//| digital values in."""
//| ...
//|
-//| UP: Any = ...
+//| UP: Pull = ...
//| """When the input line isn't being driven the pull up can pull the state
//| of the line high so it reads as true."""
//|
-//| DOWN: Any = ...
+//| DOWN: Pull = ...
//| """When the input line isn't being driven the pull down can pull the
//| state of the line low so it reads as false."""
//|
diff --git a/shared-bindings/digitalio/Pull.h b/shared-bindings/digitalio/Pull.h
index 22fb6cd0e..b97e8fb25 100644
--- a/shared-bindings/digitalio/Pull.h
+++ b/shared-bindings/digitalio/Pull.h
@@ -35,7 +35,7 @@ typedef enum _digitalio_pull_t {
PULL_DOWN
} digitalio_pull_t;
-const mp_obj_type_t digitalio_pull_type;
+extern const mp_obj_type_t digitalio_pull_type;
typedef struct {
mp_obj_base_t base;
diff --git a/shared-bindings/displayio/Bitmap.c b/shared-bindings/displayio/Bitmap.c
index a52840f2e..b2cda2153 100644
--- a/shared-bindings/displayio/Bitmap.c
+++ b/shared-bindings/displayio/Bitmap.c
@@ -39,7 +39,7 @@
//| class Bitmap:
//| """Stores values of a certain size in a 2D array"""
//|
-//| def __init__(self, width: int, height: int, value_count: int):
+//| def __init__(self, width: int, height: int, value_count: int) -> None:
//| """Create a Bitmap object with the given fixed size. Each pixel stores a value that is used to
//| index into a corresponding palette. This enables differently colored sprites to share the
//| underlying Bitmap. value_count is used to minimize the memory used to store the Bitmap.
@@ -73,7 +73,7 @@ STATIC mp_obj_t displayio_bitmap_make_new(const mp_obj_type_t *type, size_t n_ar
return MP_OBJ_FROM_PTR(self);
}
-//| width: Any = ...
+//| width: int = ...
//| """Width of the bitmap. (read only)"""
//|
STATIC mp_obj_t displayio_bitmap_obj_get_width(mp_obj_t self_in) {
@@ -91,7 +91,7 @@ const mp_obj_property_t displayio_bitmap_width_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| height: Any = ...
+//| height: int = ...
//| """Height of the bitmap. (read only)"""
//|
STATIC mp_obj_t displayio_bitmap_obj_get_height(mp_obj_t self_in) {
@@ -109,7 +109,7 @@ const mp_obj_property_t displayio_bitmap_height_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| def __getitem__(self, index: Any) -> Any:
+//| def __getitem__(self, index: Union[Tuple[int, int], int]) -> int:
//| """Returns the value at the given index. The index can either be an x,y tuple or an int equal
//| to ``y * width + x``.
//|
@@ -118,7 +118,7 @@ const mp_obj_property_t displayio_bitmap_height_obj = {
//| print(bitmap[0,1])"""
//| ...
//|
-//| def __setitem__(self, index: Any, value: Any) -> Any:
+//| def __setitem__(self, index: Union[Tuple[int, int], int], value: int) -> None:
//| """Sets the value at the given index. The index can either be an x,y tuple or an int equal
//| to ``y * width + x``.
//|
@@ -172,7 +172,7 @@ STATIC mp_obj_t bitmap_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t val
return mp_const_none;
}
-//| def fill(self, value: Any) -> Any:
+//| def fill(self, value: int) -> None:
//| """Fills the bitmap with the supplied palette index value."""
//| ...
//|
diff --git a/shared-bindings/displayio/ColorConverter.c b/shared-bindings/displayio/ColorConverter.c
index 33d0bdd3c..17eed1a9b 100644
--- a/shared-bindings/displayio/ColorConverter.c
+++ b/shared-bindings/displayio/ColorConverter.c
@@ -39,7 +39,7 @@
//| class ColorConverter:
//| """Converts one color format to another."""
//|
-//| def __init__(self, *, dither: bool = False):
+//| def __init__(self, *, dither: bool = False) -> None:
//| """Create a ColorConverter object to convert color formats. Only supports RGB888 to RGB565
//| currently.
//| :param bool dither: Adds random noise to dither the output image"""
@@ -65,7 +65,7 @@ STATIC mp_obj_t displayio_colorconverter_make_new(const mp_obj_type_t *type, siz
return MP_OBJ_FROM_PTR(self);
}
-//| def convert(self, color: Any) -> Any:
+//| def convert(self, color: int) -> int:
//| """Converts the given RGB888 color to RGB565"""
//| ...
//|
@@ -84,7 +84,7 @@ STATIC mp_obj_t displayio_colorconverter_obj_convert(mp_obj_t self_in, mp_obj_t
}
MP_DEFINE_CONST_FUN_OBJ_2(displayio_colorconverter_convert_obj, displayio_colorconverter_obj_convert);
-//| dither: Any = ...
+//| dither: bool = ...
//| """When true the color converter dithers the output by adding random noise when
//| truncating to display bitdepth"""
//|
diff --git a/shared-bindings/displayio/Display.c b/shared-bindings/displayio/Display.c
index 6e454f34b..4534babca 100644
--- a/shared-bindings/displayio/Display.c
+++ b/shared-bindings/displayio/Display.c
@@ -49,7 +49,7 @@
//| Most people should not use this class directly. Use a specific display driver instead that will
//| contain the initialization sequence at minimum."""
//|
-//| def __init__(self, display_bus: Any, init_sequence: buffer, *, width: int, height: int, colstart: int = 0, rowstart: int = 0, rotation: int = 0, color_depth: int = 16, grayscale: bool = False, pixels_in_byte_share_row: bool = True, bytes_per_cell: int = 1, reverse_pixels_in_byte: bool = False, set_column_command: int = 0x2a, set_row_command: int = 0x2b, write_ram_command: int = 0x2c, set_vertical_scroll: int = 0, backlight_pin: microcontroller.Pin = None, brightness_command: int = None, brightness: bool = 1.0, auto_brightness: bool = False, single_byte_bounds: bool = False, data_as_commands: bool = False, auto_refresh: bool = True, native_frames_per_second: int = 60):
+//| def __init__(self, display_bus: displayio, init_sequence: buffer, *, width: int, height: int, colstart: int = 0, rowstart: int = 0, rotation: int = 0, color_depth: int = 16, grayscale: bool = False, pixels_in_byte_share_row: bool = True, bytes_per_cell: int = 1, reverse_pixels_in_byte: bool = False, set_column_command: int = 0x2a, set_row_command: int = 0x2b, write_ram_command: int = 0x2c, set_vertical_scroll: int = 0, backlight_pin: Optional[microcontroller.Pin] = None, brightness_command: int = None, brightness: bool = 1.0, auto_brightness: bool = False, single_byte_bounds: bool = False, data_as_commands: bool = False, auto_refresh: bool = True, native_frames_per_second: int = 60) -> None:
//| r"""Create a Display object on the given display bus (`displayio.FourWire` or `displayio.ParallelBus`).
//|
//| The ``init_sequence`` is bitpacked to minimize the ram impact. Every command begins with a
@@ -188,7 +188,7 @@ static displayio_display_obj_t* native_display(mp_obj_t display_obj) {
return MP_OBJ_TO_PTR(native_display);
}
-//| def show(self, group: Group) -> Any:
+//| def show(self, group: Group) -> None:
//| """Switches to displaying the given group of layers. When group is None, the default
//| CircuitPython terminal will be shown.
//|
@@ -210,7 +210,7 @@ STATIC mp_obj_t displayio_display_obj_show(mp_obj_t self_in, mp_obj_t group_in)
}
MP_DEFINE_CONST_FUN_OBJ_2(displayio_display_show_obj, displayio_display_obj_show);
-//| def refresh(self, *, target_frames_per_second: int = 60, minimum_frames_per_second: int = 1) -> Any:
+//| def refresh(self, *, target_frames_per_second: int = 60, minimum_frames_per_second: int = 1) -> bool:
//| """When auto refresh is off, waits for the target frame rate and then refreshes the display,
//| returning True. If the call has taken too long since the last refresh call for the given
//| target frame rate, then the refresh returns False immediately without updating the screen to
@@ -245,7 +245,7 @@ STATIC mp_obj_t displayio_display_obj_refresh(size_t n_args, const mp_obj_t *pos
}
MP_DEFINE_CONST_FUN_OBJ_KW(displayio_display_refresh_obj, 1, displayio_display_obj_refresh);
-//| auto_refresh: Any = ...
+//| auto_refresh: None = ...
//| """True when the display is refreshed automatically."""
//|
STATIC mp_obj_t displayio_display_obj_get_auto_refresh(mp_obj_t self_in) {
@@ -270,7 +270,7 @@ const mp_obj_property_t displayio_display_auto_refresh_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| brightness: Any = ...
+//| brightness: float = ...
//| """The brightness of the display as a float. 0.0 is off and 1.0 is full brightness. When
//| `auto_brightness` is True, the value of `brightness` will change automatically.
//| If `brightness` is set, `auto_brightness` will be disabled and will be set to False."""
@@ -307,7 +307,7 @@ const mp_obj_property_t displayio_display_brightness_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| auto_brightness: Any = ...
+//| auto_brightness: Optional[bool] = ...
//| """True when the display brightness is adjusted automatically, based on an ambient
//| light sensor or other method. Note that some displays may have this set to True by default,
//| but not actually implement automatic brightness adjustment. `auto_brightness` is set to False
@@ -338,7 +338,7 @@ const mp_obj_property_t displayio_display_auto_brightness_obj = {
-//| width: Any = ...
+//| width: int = ...
//| Gets the width of the board
//|
//|
@@ -355,7 +355,7 @@ const mp_obj_property_t displayio_display_width_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| height: Any = ...
+//| height: int = ...
//| """Gets the height of the board"""
//|
//|
@@ -372,7 +372,7 @@ const mp_obj_property_t displayio_display_height_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| rotation: Any = ...
+//| rotation: int = ...
//| """The rotation of the display as an int in degrees."""
//|
STATIC mp_obj_t displayio_display_obj_get_rotation(mp_obj_t self_in) {
@@ -395,7 +395,7 @@ const mp_obj_property_t displayio_display_rotation_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| bus: Any = ...
+//| bus: Union[ParallelBus, FourWire, I2CDisplay] = ...
//| """The bus being used by the display"""
//|
//|
@@ -413,7 +413,7 @@ const mp_obj_property_t displayio_display_bus_obj = {
};
-//| def fill_row(self, y: int, buffer: bytearray) -> Any:
+//| def fill_row(self, y: int, buffer: WriteableBuffer) -> bytearray:
//| """Extract the pixels from a single row
//|
//| :param int y: The top edge of the area
diff --git a/shared-bindings/displayio/EPaperDisplay.c b/shared-bindings/displayio/EPaperDisplay.c
index 8b77e4df3..21eaf14da 100644
--- a/shared-bindings/displayio/EPaperDisplay.c
+++ b/shared-bindings/displayio/EPaperDisplay.c
@@ -49,7 +49,7 @@
//| Most people should not use this class directly. Use a specific display driver instead that will
//| contain the startup and shutdown sequences at minimum."""
//|
-//| def __init__(self, display_bus: Any, start_sequence: buffer, stop_sequence: buffer, *, width: int, height: int, ram_width: int, ram_height: int, colstart: int = 0, rowstart: int = 0, rotation: int = 0, set_column_window_command: int = None, set_row_window_command: int = None, single_byte_bounds: Any = False, write_black_ram_command: int, black_bits_inverted: bool = False, write_color_ram_command: int = None, color_bits_inverted: bool = False, highlight_color: int = 0x000000, refresh_display_command: int, refresh_time: float = 40, busy_pin: microcontroller.Pin = None, busy_state: bool = True, seconds_per_frame: float = 180, always_toggle_chip_select: bool = False):
+//| def __init__(self, display_bus: displayio, start_sequence: buffer, stop_sequence: buffer, *, width: int, height: int, ram_width: int, ram_height: int, colstart: int = 0, rowstart: int = 0, rotation: int = 0, set_column_window_command: Optional[int] = None, set_row_window_command: Optional[int] = None, single_byte_bounds: bool = False, write_black_ram_command: int, black_bits_inverted: bool = False, write_color_ram_command: Optional[int] = None, color_bits_inverted: bool = False, highlight_color: int = 0x000000, refresh_display_command: int, refresh_time: float = 40, busy_pin: Optional[microcontroller.Pin] = None, busy_state: bool = True, seconds_per_frame: float = 180, always_toggle_chip_select: bool = False) -> None:
//| """Create a EPaperDisplay object on the given display bus (`displayio.FourWire` or `displayio.ParallelBus`).
//|
//| The ``start_sequence`` and ``stop_sequence`` are bitpacked to minimize the ram impact. Every
@@ -168,7 +168,7 @@ static displayio_epaperdisplay_obj_t* native_display(mp_obj_t display_obj) {
return MP_OBJ_TO_PTR(native_display);
}
-//| def show(self, group: Group) -> Any:
+//| def show(self, group: Group) -> None:
//| """Switches to displaying the given group of layers. When group is None, the default
//| CircuitPython terminal will be shown.
//|
@@ -190,7 +190,7 @@ STATIC mp_obj_t displayio_epaperdisplay_obj_show(mp_obj_t self_in, mp_obj_t grou
}
MP_DEFINE_CONST_FUN_OBJ_2(displayio_epaperdisplay_show_obj, displayio_epaperdisplay_obj_show);
-//| def refresh(self, ) -> Any:
+//| def refresh(self) -> None:
//| """Refreshes the display immediately or raises an exception if too soon. Use
//| ``time.sleep(display.time_to_refresh)`` to sleep until a refresh can occur."""
//| ...
@@ -205,7 +205,7 @@ STATIC mp_obj_t displayio_epaperdisplay_obj_refresh(mp_obj_t self_in) {
}
MP_DEFINE_CONST_FUN_OBJ_1(displayio_epaperdisplay_refresh_obj, displayio_epaperdisplay_obj_refresh);
-//| time_to_refresh: Any = ...
+//| time_to_refresh: float = ...
//| """Time, in fractional seconds, until the ePaper display can be refreshed."""
//|
STATIC mp_obj_t displayio_epaperdisplay_obj_get_time_to_refresh(mp_obj_t self_in) {
@@ -221,7 +221,7 @@ const mp_obj_property_t displayio_epaperdisplay_time_to_refresh_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| width: Any = ...
+//| width: int = ...
//| """Gets the width of the display in pixels"""
//|
STATIC mp_obj_t displayio_epaperdisplay_obj_get_width(mp_obj_t self_in) {
@@ -237,7 +237,7 @@ const mp_obj_property_t displayio_epaperdisplay_width_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| height: Any = ...
+//| height: int = ...
//| """Gets the height of the display in pixels"""
//|
STATIC mp_obj_t displayio_epaperdisplay_obj_get_height(mp_obj_t self_in) {
@@ -253,7 +253,7 @@ const mp_obj_property_t displayio_epaperdisplay_height_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| bus: Any = ...
+//| bus: displayio = ...
//| """The bus being used by the display"""
//|
STATIC mp_obj_t displayio_epaperdisplay_obj_get_bus(mp_obj_t self_in) {
diff --git a/shared-bindings/displayio/FourWire.c b/shared-bindings/displayio/FourWire.c
index 5ee4ec5a9..83d260c0f 100644
--- a/shared-bindings/displayio/FourWire.c
+++ b/shared-bindings/displayio/FourWire.c
@@ -42,7 +42,7 @@
//| """Manage updating a display over SPI four wire protocol in the background while Python code runs.
//| It doesn't handle display initialization."""
//|
-//| def __init__(self, spi_bus: busio.SPI, *, command: microcontroller.Pin, chip_select: microcontroller.Pin, reset: microcontroller.Pin = None, baudrate: int = 24000000, polarity: int = 0, phase: int = 0):
+//| def __init__(self, spi_bus: busio.SPI, *, command: microcontroller.Pin, chip_select: microcontroller.Pin, reset: microcontroller.Pin = None, baudrate: int = 24000000, polarity: int = 0, phase: int = 0) -> None:
//| """Create a FourWire object associated with the given pins.
//|
//| The SPI bus and pins are then in use by the display until `displayio.release_displays()` is
@@ -96,7 +96,7 @@ STATIC mp_obj_t displayio_fourwire_make_new(const mp_obj_type_t *type, size_t n_
return self;
}
-//| def reset(self, ) -> Any:
+//| def reset(self) -> None:
//| """Performs a hardware reset via the reset pin. Raises an exception if called when no reset pin
//| is available."""
//| ...
@@ -111,7 +111,7 @@ STATIC mp_obj_t displayio_fourwire_obj_reset(mp_obj_t self_in) {
}
MP_DEFINE_CONST_FUN_OBJ_1(displayio_fourwire_reset_obj, displayio_fourwire_obj_reset);
-//| def send(self, command: Any, data: Any, *, toggle_every_byte: Any = False) -> Any:
+//| def send(self, command: int, data: FourWire, *, toggle_every_byte: bool = False) -> None:
//| """Sends the given command value followed by the full set of data. Display state, such as
//| vertical scroll, set via ``send`` may or may not be reset once the code is done."""
//| ...
diff --git a/shared-bindings/displayio/Group.c b/shared-bindings/displayio/Group.c
index b6f96883b..1176db563 100644
--- a/shared-bindings/displayio/Group.c
+++ b/shared-bindings/displayio/Group.c
@@ -38,7 +38,7 @@
//| class Group:
//| """Manage a group of sprites and groups and how they are inter-related."""
//|
-//| def __init__(self, *, max_size: int = 4, scale: int = 1, x: int = 0, y: int = 0):
+//| def __init__(self, *, max_size: int = 4, scale: int = 1, x: int = 0, y: int = 0) -> None:
//| """Create a Group of a given size and scale. Scale is in one dimension. For example, scale=2
//| leads to a layer's pixel being 2x2 pixels when in the group.
//|
@@ -86,7 +86,7 @@ displayio_group_t* native_group(mp_obj_t group_obj) {
return MP_OBJ_TO_PTR(native_group);
}
-//| hidden: Any = ...
+//| hidden: bool = ...
//| """True when the Group and all of it's layers are not visible. When False, the Group's layers
//| are visible if they haven't been hidden."""
//|
@@ -111,7 +111,7 @@ const mp_obj_property_t displayio_group_hidden_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| scale: Any = ...
+//| scale: int = ...
//| """Scales each pixel within the Group in both directions. For example, when scale=2 each pixel
//| will be represented by 2x2 pixels."""
//|
@@ -140,7 +140,7 @@ const mp_obj_property_t displayio_group_scale_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| x: Any = ...
+//| x: int = ...
//| """X position of the Group in the parent."""
//|
STATIC mp_obj_t displayio_group_obj_get_x(mp_obj_t self_in) {
@@ -165,7 +165,7 @@ const mp_obj_property_t displayio_group_x_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| y: Any = ...
+//| y: int = ...
//| """Y position of the Group in the parent."""
//|
STATIC mp_obj_t displayio_group_obj_get_y(mp_obj_t self_in) {
@@ -190,7 +190,7 @@ const mp_obj_property_t displayio_group_y_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| def append(self, layer: Any) -> Any:
+//| def append(self, layer: Union[vectorio.Shape, Group, TileGrid]) -> None:
//| """Append a layer to the group. It will be drawn above other layers."""
//| ...
//|
@@ -201,7 +201,7 @@ STATIC mp_obj_t displayio_group_obj_append(mp_obj_t self_in, mp_obj_t layer) {
}
MP_DEFINE_CONST_FUN_OBJ_2(displayio_group_append_obj, displayio_group_obj_append);
-//| def insert(self, index: Any, layer: Any) -> Any:
+//| def insert(self, index: int, layer: Union[vectorio.Shape, Group, TileGrid]) -> None:
//| """Insert a layer into the group."""
//| ...
//|
@@ -214,7 +214,7 @@ STATIC mp_obj_t displayio_group_obj_insert(mp_obj_t self_in, mp_obj_t index_obj,
MP_DEFINE_CONST_FUN_OBJ_3(displayio_group_insert_obj, displayio_group_obj_insert);
-//| def index(self, layer: Any) -> Any:
+//| def index(self, layer: Union[vectorio.Shape, Group, TileGrid]) -> int:
//| """Returns the index of the first copy of layer. Raises ValueError if not found."""
//| ...
//|
@@ -228,7 +228,7 @@ STATIC mp_obj_t displayio_group_obj_index(mp_obj_t self_in, mp_obj_t layer) {
}
MP_DEFINE_CONST_FUN_OBJ_2(displayio_group_index_obj, displayio_group_obj_index);
-//| def pop(self, i: Any = -1) -> Any:
+//| def pop(self, i: int = -1) -> Union[vectorio.Shape, Group, TileGrid]:
//| """Remove the ith item and return it."""
//| ...
//|
@@ -251,7 +251,7 @@ STATIC mp_obj_t displayio_group_obj_pop(size_t n_args, const mp_obj_t *pos_args,
MP_DEFINE_CONST_FUN_OBJ_KW(displayio_group_pop_obj, 1, displayio_group_obj_pop);
-//| def remove(self, layer: Any) -> Any:
+//| def remove(self, layer: Union[vectorio.Shape, Group, TileGrid]) -> None:
//| """Remove the first copy of layer. Raises ValueError if it is not present."""
//| ...
//|
@@ -264,7 +264,9 @@ STATIC mp_obj_t displayio_group_obj_remove(mp_obj_t self_in, mp_obj_t layer) {
}
MP_DEFINE_CONST_FUN_OBJ_2(displayio_group_remove_obj, displayio_group_obj_remove);
-//| def __len__(self, ) -> Any:
+//| def __bool__(self) -> bool: ...
+//|
+//| def __len__(self) -> int:
//| """Returns the number of layers in a Group"""
//| ...
//|
@@ -278,7 +280,7 @@ STATIC mp_obj_t group_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
}
}
-//| def __getitem__(self, index: Any) -> Any:
+//| def __getitem__(self, index: int) -> Union[vectorio.Shape, Group, TileGrid]:
//| """Returns the value at the given index.
//|
//| This allows you to::
@@ -286,7 +288,7 @@ STATIC mp_obj_t group_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
//| print(group[0])"""
//| ...
//|
-//| def __setitem__(self, index: Any, value: Any) -> Any:
+//| def __setitem__(self, index: int, value: Union[vectorio.Shape, Group, TileGrid]) -> None:
//| """Sets the value at the given index.
//|
//| This allows you to::
@@ -294,7 +296,7 @@ STATIC mp_obj_t group_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
//| group[0] = sprite"""
//| ...
//|
-//| def __delitem__(self, index: Any) -> Any:
+//| def __delitem__(self, index: int) -> None:
//| """Deletes the value at the given index.
//|
//| This allows you to::
diff --git a/shared-bindings/displayio/I2CDisplay.c b/shared-bindings/displayio/I2CDisplay.c
index 0cfac6672..c8b6702a1 100644
--- a/shared-bindings/displayio/I2CDisplay.c
+++ b/shared-bindings/displayio/I2CDisplay.c
@@ -42,7 +42,7 @@
//| """Manage updating a display over I2C in the background while Python code runs.
//| It doesn't handle display initialization."""
//|
-//| def __init__(self, i2c_bus: busio.I2C, *, device_address: int, reset: microcontroller.Pin = None):
+//| def __init__(self, i2c_bus: busio.I2C, *, device_address: int, reset: microcontroller.Pin = None) -> None:
//| """Create a I2CDisplay object associated with the given I2C bus and reset pin.
//|
//| The I2C bus and pins are then in use by the display until `displayio.release_displays()` is
@@ -76,7 +76,7 @@ STATIC mp_obj_t displayio_i2cdisplay_make_new(const mp_obj_type_t *type, size_t
return self;
}
-//| def reset(self, ) -> Any:
+//| def reset(self) -> None:
//| """Performs a hardware reset via the reset pin. Raises an exception if called when no reset pin
//| is available."""
//| ...
@@ -91,7 +91,7 @@ STATIC mp_obj_t displayio_i2cdisplay_obj_reset(mp_obj_t self_in) {
}
MP_DEFINE_CONST_FUN_OBJ_1(displayio_i2cdisplay_reset_obj, displayio_i2cdisplay_obj_reset);
-//| def send(self, command: Any, data: Any) -> Any:
+//| def send(self, command: int, data: ReadableBuffer) -> None:
//| """Sends the given command value followed by the full set of data. Display state, such as
//| vertical scroll, set via ``send`` may or may not be reset once the code is done."""
//| ...
diff --git a/shared-bindings/displayio/OnDiskBitmap.c b/shared-bindings/displayio/OnDiskBitmap.c
index 170873653..7e94a0401 100644
--- a/shared-bindings/displayio/OnDiskBitmap.c
+++ b/shared-bindings/displayio/OnDiskBitmap.c
@@ -69,7 +69,7 @@
//| while True:
//| pass"""
//|
-//| def __init__(self, file: file):
+//| def __init__(self, file: file) -> None:
//| """Create an OnDiskBitmap object with the given file.
//|
//| :param file file: The open bitmap file"""
@@ -89,7 +89,7 @@ STATIC mp_obj_t displayio_ondiskbitmap_make_new(const mp_obj_type_t *type, size_
return MP_OBJ_FROM_PTR(self);
}
-//| width: Any = ...
+//| width: int = ...
//| """Width of the bitmap. (read only)"""
//|
STATIC mp_obj_t displayio_ondiskbitmap_obj_get_width(mp_obj_t self_in) {
@@ -108,7 +108,7 @@ const mp_obj_property_t displayio_ondiskbitmap_width_obj = {
};
-//| height: Any = ...
+//| height: int = ...
//| """Height of the bitmap. (read only)"""
//|
STATIC mp_obj_t displayio_ondiskbitmap_obj_get_height(mp_obj_t self_in) {
diff --git a/shared-bindings/displayio/Palette.c b/shared-bindings/displayio/Palette.c
index 37cfbd82e..5418133e1 100644
--- a/shared-bindings/displayio/Palette.c
+++ b/shared-bindings/displayio/Palette.c
@@ -46,7 +46,7 @@
//| """Map a pixel palette_index to a full color. Colors are transformed to the display's format internally to
//| save memory."""
//|
-//| def __init__(self, color_count: int):
+//| def __init__(self, color_count: int) -> None:
//| """Create a Palette object to store a set number of colors.
//|
//| :param int color_count: The number of colors in the Palette"""
@@ -70,7 +70,9 @@ STATIC mp_obj_t displayio_palette_make_new(const mp_obj_type_t *type, size_t n_a
return MP_OBJ_FROM_PTR(self);
}
-//| def __len__(self, ) -> Any:
+//| def __bool__(self) -> bool: ...
+//|
+//| def __len__(self) -> int:
//| """Returns the number of colors in a Palette"""
//| ...
//|
@@ -84,7 +86,7 @@ STATIC mp_obj_t group_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
}
}
-//| def __setitem__(self, index: Any, value: Any) -> Any:
+//| def __setitem__(self, index: int, value: Union[int, ReadableBuffer]) -> Optional[int]:
//| r"""Sets the pixel color at the given index. The index should be an integer in the range 0 to color_count-1.
//|
//| The value argument represents a color, and can be from 0x000000 to 0xFFFFFF (to represent an RGB value).
@@ -147,7 +149,7 @@ STATIC mp_obj_t palette_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t val
return mp_const_none;
}
-//| def make_transparent(self, palette_index: Any) -> Any: ...
+//| def make_transparent(self, palette_index: int) -> None: ...
//|
STATIC mp_obj_t displayio_palette_obj_make_transparent(mp_obj_t self_in, mp_obj_t palette_index_obj) {
displayio_palette_t *self = MP_OBJ_TO_PTR(self_in);
@@ -161,7 +163,7 @@ STATIC mp_obj_t displayio_palette_obj_make_transparent(mp_obj_t self_in, mp_obj_
}
MP_DEFINE_CONST_FUN_OBJ_2(displayio_palette_make_transparent_obj, displayio_palette_obj_make_transparent);
-//| def make_opaque(self, palette_index: Any) -> Any: ...
+//| def make_opaque(self, palette_index: int) -> None: ...
//|
STATIC mp_obj_t displayio_palette_obj_make_opaque(mp_obj_t self_in, mp_obj_t palette_index_obj) {
displayio_palette_t *self = MP_OBJ_TO_PTR(self_in);
diff --git a/shared-bindings/displayio/ParallelBus.c b/shared-bindings/displayio/ParallelBus.c
index eb75ecc03..30c9d373c 100644
--- a/shared-bindings/displayio/ParallelBus.c
+++ b/shared-bindings/displayio/ParallelBus.c
@@ -42,7 +42,7 @@
//| protocol may be refered to as 8080-I Series Parallel Interface in datasheets. It doesn't handle
//| display initialization."""
//|
-//| def __init__(self, *, data0: microcontroller.Pin, command: microcontroller.Pin, chip_select: microcontroller.Pin, write: microcontroller.Pin, read: microcontroller.Pin, reset: microcontroller.Pin):
+//| def __init__(self, *, data0: microcontroller.Pin, command: microcontroller.Pin, chip_select: microcontroller.Pin, write: microcontroller.Pin, read: microcontroller.Pin, reset: microcontroller.Pin) -> None:
//| """Create a ParallelBus object associated with the given pins. The bus is inferred from data0
//| by implying the next 7 additional pins on a given GPIO port.
//|
@@ -86,7 +86,7 @@ STATIC mp_obj_t displayio_parallelbus_make_new(const mp_obj_type_t *type, size_t
return self;
}
-//| def reset(self, ) -> Any:
+//| def reset(self) -> None:
//| """Performs a hardware reset via the reset pin. Raises an exception if called when no reset pin
//| is available."""
//| ...
@@ -102,7 +102,7 @@ STATIC mp_obj_t displayio_parallelbus_obj_reset(mp_obj_t self_in) {
}
MP_DEFINE_CONST_FUN_OBJ_1(displayio_parallelbus_reset_obj, displayio_parallelbus_obj_reset);
-//| def send(self, command: Any, data: Any) -> Any:
+//| def send(self, command: int, data: ReadableBuffer) -> None:
//| """Sends the given command value followed by the full set of data. Display state, such as
//| vertical scroll, set via ``send`` may or may not be reset once the code is done."""
//| ...
diff --git a/shared-bindings/displayio/Shape.c b/shared-bindings/displayio/Shape.c
index fce89c771..4d737ecae 100644
--- a/shared-bindings/displayio/Shape.c
+++ b/shared-bindings/displayio/Shape.c
@@ -37,7 +37,7 @@
//| class Shape:
//| """Represents a shape made by defining boundaries that may be mirrored."""
//|
-//| def __init__(self, width: int, height: int, *, mirror_x: bool = False, mirror_y: bool = False):
+//| def __init__(self, width: int, height: int, *, mirror_x: bool = False, mirror_y: bool = False) -> None:
//| """Create a Shape object with the given fixed size. Each pixel is one bit and is stored by the
//| column boundaries of the shape on each row. Each row's boundary defaults to the full row.
//|
@@ -79,7 +79,7 @@ STATIC mp_obj_t displayio_shape_make_new(const mp_obj_type_t *type, size_t n_arg
}
-//| def set_boundary(self, y: Any, start_x: Any, end_x: Any) -> Any:
+//| def set_boundary(self, y: int, start_x: int, end_x: int) -> None:
//| """Loads pre-packed data into the given row."""
//| ...
//|
diff --git a/shared-bindings/displayio/TileGrid.c b/shared-bindings/displayio/TileGrid.c
index 01fba46a5..c17d984db 100644
--- a/shared-bindings/displayio/TileGrid.c
+++ b/shared-bindings/displayio/TileGrid.c
@@ -48,7 +48,7 @@
//|
//| A single tile grid is also known as a Sprite."""
//|
-//| def __init__(self, bitmap: displayio.Bitmap, *, pixel_shader: displayio.Palette, width: int = 1, height: int = 1, tile_width: int = None, tile_height: int = None, default_tile: int = 0, x: int = 0, y: int = 0):
+//| def __init__(self, bitmap: displayio.Bitmap, *, pixel_shader: displayio.Palette, width: int = 1, height: int = 1, tile_width: int = None, tile_height: int = None, default_tile: int = 0, x: int = 0, y: int = 0) -> None:
//| """Create a TileGrid object. The bitmap is source for 2d pixels. The pixel_shader is used to
//| convert the value and its location to a display native pixel color. This may be a simple color
//| palette lookup, a gradient, a pattern or a color transformer.
@@ -141,7 +141,7 @@ static displayio_tilegrid_t* native_tilegrid(mp_obj_t tilegrid_obj) {
mp_obj_assert_native_inited(native_tilegrid);
return MP_OBJ_TO_PTR(native_tilegrid);
}
-//| hidden: Any = ...
+//| hidden: bool = ...
//| """True when the TileGrid is hidden. This may be False even when a part of a hidden Group."""
//|
STATIC mp_obj_t displayio_tilegrid_obj_get_hidden(mp_obj_t self_in) {
@@ -165,7 +165,7 @@ const mp_obj_property_t displayio_tilegrid_hidden_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| x: Any = ...
+//| x: int = ...
//| """X position of the left edge in the parent."""
//|
STATIC mp_obj_t displayio_tilegrid_obj_get_x(mp_obj_t self_in) {
@@ -190,7 +190,7 @@ const mp_obj_property_t displayio_tilegrid_x_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| y: Any = ...
+//| y: int = ...
//| """Y position of the top edge in the parent."""
//|
STATIC mp_obj_t displayio_tilegrid_obj_get_y(mp_obj_t self_in) {
@@ -215,7 +215,7 @@ const mp_obj_property_t displayio_tilegrid_y_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| flip_x: Any = ...
+//| flip_x: bool = ...
//| """If true, the left edge rendered will be the right edge of the right-most tile."""
//|
STATIC mp_obj_t displayio_tilegrid_obj_get_flip_x(mp_obj_t self_in) {
@@ -239,7 +239,7 @@ const mp_obj_property_t displayio_tilegrid_flip_x_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| flip_y: Any = ...
+//| flip_y: bool = ...
//| """If true, the top edge rendered will be the bottom edge of the bottom-most tile."""
//|
STATIC mp_obj_t displayio_tilegrid_obj_get_flip_y(mp_obj_t self_in) {
@@ -264,7 +264,7 @@ const mp_obj_property_t displayio_tilegrid_flip_y_obj = {
};
-//| transpose_xy: Any = ...
+//| transpose_xy: bool = ...
//| """If true, the TileGrid's axis will be swapped. When combined with mirroring, any 90 degree
//| rotation can be achieved along with the corresponding mirrored version."""
//|
@@ -289,7 +289,7 @@ const mp_obj_property_t displayio_tilegrid_transpose_xy_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| pixel_shader: Any = ...
+//| pixel_shader: Union[ColorConverter, Palette] = ...
//| """The pixel shader of the tilegrid."""
//|
STATIC mp_obj_t displayio_tilegrid_obj_get_pixel_shader(mp_obj_t self_in) {
@@ -317,7 +317,7 @@ const mp_obj_property_t displayio_tilegrid_pixel_shader_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| def __getitem__(self, index: Any) -> Any:
+//| def __getitem__(self, index: Union[Tuple[int, int], int]) -> int:
//| """Returns the tile index at the given index. The index can either be an x,y tuple or an int equal
//| to ``y * width + x``.
//|
@@ -326,7 +326,7 @@ const mp_obj_property_t displayio_tilegrid_pixel_shader_obj = {
//| print(grid[0])"""
//| ...
//|
-//| def __setitem__(self, index: Any, tile_index: Any) -> Any:
+//| def __setitem__(self, index: Union[Tuple[int, int], int], tile_index: int) -> None:
//| """Sets the tile index at the given index. The index can either be an x,y tuple or an int equal
//| to ``y * width + x``.
//|
diff --git a/shared-bindings/displayio/__init__.c b/shared-bindings/displayio/__init__.c
index b791336b5..16d068e2e 100644
--- a/shared-bindings/displayio/__init__.c
+++ b/shared-bindings/displayio/__init__.c
@@ -50,7 +50,7 @@
//|
-//| def release_displays() -> Any:
+//| def release_displays() -> None:
//| """Releases any actively used displays so their busses and pins can be used again. This will also
//| release the builtin display on boards that have one. You will need to reinitialize it yourself
//| afterwards. This may take seconds to complete if an active EPaperDisplay is refreshing.
diff --git a/shared-bindings/fontio/BuiltinFont.c b/shared-bindings/fontio/BuiltinFont.c
index bf9a65873..5eaae624e 100644
--- a/shared-bindings/fontio/BuiltinFont.c
+++ b/shared-bindings/fontio/BuiltinFont.c
@@ -39,14 +39,14 @@
//| class BuiltinFont:
//| """A font built into CircuitPython"""
//|
-//| def __init__(self, ):
+//| def __init__(self) -> None:
//| """Creation not supported. Available fonts are defined when CircuitPython is built. See the
//| `Adafruit_CircuitPython_Bitmap_Font <https://github.com/adafruit/Adafruit_CircuitPython_Bitmap_Font>`_
//| library for dynamically loaded fonts."""
//| ...
//|
-//| bitmap: Any = ...
+//| bitmap: displayio.Bitmap = ...
//| """Bitmap containing all font glyphs starting with ASCII and followed by unicode. Use
//| `get_glyph` in most cases. This is useful for use with `displayio.TileGrid` and
//| `terminalio.Terminal`."""
@@ -64,7 +64,7 @@ const mp_obj_property_t fontio_builtinfont_bitmap_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| def get_bounding_box(self, ) -> Any:
+//| def get_bounding_box(self) -> Tuple[int, int]:
//| """Returns the maximum bounds of all glyphs in the font in a tuple of two values: width, height."""
//| ...
//|
@@ -76,7 +76,7 @@ STATIC mp_obj_t fontio_builtinfont_obj_get_bounding_box(mp_obj_t self_in) {
MP_DEFINE_CONST_FUN_OBJ_1(fontio_builtinfont_get_bounding_box_obj, fontio_builtinfont_obj_get_bounding_box);
-//| def get_glyph(self, codepoint: Any) -> Any:
+//| def get_glyph(self, codepoint: int) -> Glyph:
//| """Returns a `fontio.Glyph` for the given codepoint or None if no glyph is available."""
//| ...
//|
diff --git a/shared-bindings/framebufferio/FramebufferDisplay.c b/shared-bindings/framebufferio/FramebufferDisplay.c
index 51ef09059..d687e3e95 100644
--- a/shared-bindings/framebufferio/FramebufferDisplay.c
+++ b/shared-bindings/framebufferio/FramebufferDisplay.c
@@ -47,7 +47,7 @@
//| objects in CircuitPython, Display objects live until `displayio.release_displays()`
//| is called. This is done so that CircuitPython can use the display itself."""
//|
-//| def __init__(self, framebuffer: Any, *, rotation: int = 0, auto_refresh: bool = True):
+//| def __init__(self, framebuffer: rgbmatrix.RGBMatrix, *, rotation: int = 0, auto_refresh: bool = True) -> None:
//| """Create a Display object with the given framebuffer (a buffer, array, ulab.array, etc)
//|
//| :param framebuffer: The framebuffer that the display is connected to
@@ -94,7 +94,7 @@ static framebufferio_framebufferdisplay_obj_t* native_display(mp_obj_t display_o
return MP_OBJ_TO_PTR(native_display);
}
-//| def show(self, group: Group) -> Any:
+//| def show(self, group: Group) -> None:
//| """Switches to displaying the given group of layers. When group is None, the default
//| CircuitPython terminal will be shown.
//|
@@ -116,7 +116,7 @@ STATIC mp_obj_t framebufferio_framebufferdisplay_obj_show(mp_obj_t self_in, mp_o
}
MP_DEFINE_CONST_FUN_OBJ_2(framebufferio_framebufferdisplay_show_obj, framebufferio_framebufferdisplay_obj_show);
-//| def refresh(self, *, target_frames_per_second: int = 60, minimum_frames_per_second: int = 1) -> Any:
+//| def refresh(self, *, target_frames_per_second: int = 60, minimum_frames_per_second: int = 1) -> bool:
//| """When auto refresh is off, waits for the target frame rate and then refreshes the display,
//| returning True. If the call has taken too long since the last refresh call for the given
//| target frame rate, then the refresh returns False immediately without updating the screen to
@@ -151,7 +151,7 @@ STATIC mp_obj_t framebufferio_framebufferdisplay_obj_refresh(size_t n_args, cons
}
MP_DEFINE_CONST_FUN_OBJ_KW(framebufferio_framebufferdisplay_refresh_obj, 1, framebufferio_framebufferdisplay_obj_refresh);
-//| auto_refresh: Any = ...
+//| auto_refresh: bool = ...
//| """True when the display is refreshed automatically."""
//|
STATIC mp_obj_t framebufferio_framebufferdisplay_obj_get_auto_refresh(mp_obj_t self_in) {
@@ -176,7 +176,7 @@ const mp_obj_property_t framebufferio_framebufferdisplay_auto_refresh_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| brightness: Any = ...
+//| brightness: float = ...
//| """The brightness of the display as a float. 0.0 is off and 1.0 is full brightness. When
//| `auto_brightness` is True, the value of `brightness` will change automatically.
//| If `brightness` is set, `auto_brightness` will be disabled and will be set to False."""
@@ -213,7 +213,7 @@ const mp_obj_property_t framebufferio_framebufferdisplay_brightness_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| auto_brightness: Any = ...
+//| auto_brightness: bool = ...
//| """True when the display brightness is adjusted automatically, based on an ambient
//| light sensor or other method. Note that some displays may have this set to True by default,
//| but not actually implement automatic brightness adjustment. `auto_brightness` is set to False
@@ -244,7 +244,7 @@ const mp_obj_property_t framebufferio_framebufferdisplay_auto_brightness_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| width: Any = ...
+//| width: int = ...
//| """Gets the width of the framebuffer"""
//|
STATIC mp_obj_t framebufferio_framebufferdisplay_obj_get_width(mp_obj_t self_in) {
@@ -260,7 +260,7 @@ const mp_obj_property_t framebufferio_framebufferdisplay_width_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| height: Any = ...
+//| height: int = ...
//| """Gets the height of the framebuffer"""
//|
STATIC mp_obj_t framebufferio_framebufferdisplay_obj_get_height(mp_obj_t self_in) {
@@ -276,7 +276,7 @@ const mp_obj_property_t framebufferio_framebufferdisplay_height_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| rotation: Any = ...
+//| rotation: int = ...
//| """The rotation of the display as an int in degrees."""
//|
STATIC mp_obj_t framebufferio_framebufferdisplay_obj_get_rotation(mp_obj_t self_in) {
@@ -299,7 +299,7 @@ const mp_obj_property_t framebufferio_framebufferdisplay_rotation_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| framebuffer: Any = ...
+//| framebuffer: rgbmatrix.RGBMatrix = ...
//| """The framebuffer being used by the display"""
//|
//|
@@ -317,7 +317,7 @@ const mp_obj_property_t framebufferio_framebufferframebuffer_obj = {
};
-//| def fill_row(self, y: int, buffer: bytearray) -> Any:
+//| def fill_row(self, y: int, buffer: WriteableBuffer) -> displayio:
//| """Extract the pixels from a single row
//|
//| :param int y: The top edge of the area
diff --git a/shared-bindings/frequencyio/FrequencyIn.c b/shared-bindings/frequencyio/FrequencyIn.c
index 2d628088b..5f99b166c 100644
--- a/shared-bindings/frequencyio/FrequencyIn.c
+++ b/shared-bindings/frequencyio/FrequencyIn.c
@@ -46,7 +46,7 @@
//|
//| FrequencyIn will not determine pulse width (use ``PulseIn``)."""
//|
-//| def __init__(self, pin: microcontroller.Pin, capture_period: int = 10):
+//| def __init__(self, pin: microcontroller.Pin, capture_period: int = 10) -> None:
//| """Create a FrequencyIn object associated with the given pin.
//|
//| :param ~microcontroller.Pin pin: Pin to read frequency from.
@@ -94,7 +94,7 @@ STATIC mp_obj_t frequencyio_frequencyin_make_new(const mp_obj_type_t *type, size
return MP_OBJ_FROM_PTR(self);
}
-//| def deinit(self, ) -> Any:
+//| def deinit(self) -> None:
//| """Deinitialises the FrequencyIn and releases any hardware resources for reuse."""
//| ...
//|
@@ -111,13 +111,13 @@ STATIC void check_for_deinit(frequencyio_frequencyin_obj_t *self) {
}
}
-//| def __enter__(self, ) -> Any:
+//| def __enter__(self) -> FrequencyIn:
//| """No-op used by Context Managers."""
//| ...
//|
// Provided by context manager helper.
-//| def __exit__(self, ) -> Any:
+//| def __exit__(self) -> None:
//| """Automatically deinitializes the hardware when exiting a context. See
//| :ref:`lifetime-and-contextmanagers` for more info."""
//| ...
@@ -129,7 +129,7 @@ STATIC mp_obj_t frequencyio_frequencyin_obj___exit__(size_t n_args, const mp_obj
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(frequencyio_frequencyin___exit___obj, 4, 4, frequencyio_frequencyin_obj___exit__);
-//| def pause(self, ) -> Any:
+//| def pause(self) -> None:
//| """Pause frequency capture."""
//| ...
//|
@@ -142,7 +142,7 @@ STATIC mp_obj_t frequencyio_frequencyin_obj_pause(mp_obj_t self_in) {
}
MP_DEFINE_CONST_FUN_OBJ_1(frequencyio_frequencyin_pause_obj, frequencyio_frequencyin_obj_pause);
-//| def resume(self, ) -> Any:
+//| def resume(self) -> None:
//| """Resumes frequency capture."""
//| ...
//|
@@ -155,7 +155,7 @@ STATIC mp_obj_t frequencyio_frequencyin_obj_resume(mp_obj_t self_in) {
}
MP_DEFINE_CONST_FUN_OBJ_1(frequencyio_frequencyin_resume_obj, frequencyio_frequencyin_obj_resume);
-//| def clear(self, ) -> Any:
+//| def clear(self) -> None:
//| """Clears the last detected frequency capture value."""
//| ...
//|
@@ -169,7 +169,7 @@ STATIC mp_obj_t frequencyio_frequencyin_obj_clear(mp_obj_t self_in) {
}
MP_DEFINE_CONST_FUN_OBJ_1(frequencyio_frequencyin_clear_obj, frequencyio_frequencyin_obj_clear);
-//| capture_period: Any = ...
+//| capture_period: int = ...
//| """The capture measurement period. Lower incoming frequencies will be measured
//| more accurately with longer capture periods. Higher frequencies are more
//| accurate with shorter capture periods.
@@ -201,7 +201,7 @@ const mp_obj_property_t frequencyio_frequencyin_capture_period_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| def __get__(self, index: Any) -> Any:
+//| def __get__(self, index: int) -> int:
//| """Returns the value of the last frequency captured."""
//| ...
//|
diff --git a/shared-bindings/gamepad/GamePad.c b/shared-bindings/gamepad/GamePad.c
index 9a23344b3..f03a6cd33 100644
--- a/shared-bindings/gamepad/GamePad.c
+++ b/shared-bindings/gamepad/GamePad.c
@@ -70,7 +70,7 @@
//| time.sleep(0.1)"""
//|
-//| def __init__(self, b1: Any, b2: Any, b3: Any, b4: Any, b5: Any, b6: Any, b7: Any, b8: Any):
+//| def __init__(self, b1: DigitalInOut, b2: DigitalInOut, b3: DigitalInOut, b4: DigitalInOut, b5: DigitalInOut, b6: DigitalInOut, b7: DigitalInOut, b8: DigitalInOut) -> None:
//| """Initializes button scanning routines.
//|
//| The ``b1``-``b8`` parameters are ``DigitalInOut`` objects, which
@@ -114,7 +114,7 @@ STATIC mp_obj_t gamepad_make_new(const mp_obj_type_t *type, size_t n_args,
return MP_OBJ_FROM_PTR(gamepad_singleton);
}
-//| def get_pressed(self, ) -> Any:
+//| def get_pressed(self) -> int:
//| """Get the status of buttons pressed since the last call and clear it.
//|
//| Returns an 8-bit number, with bits that correspond to buttons,
@@ -133,7 +133,7 @@ STATIC mp_obj_t gamepad_get_pressed(mp_obj_t self_in) {
MP_DEFINE_CONST_FUN_OBJ_1(gamepad_get_pressed_obj, gamepad_get_pressed);
-//| def deinit(self, ) -> Any:
+//| def deinit(self) -> None:
//| """Disable button scanning."""
//| ...
//|
diff --git a/shared-bindings/gamepadshift/GamePadShift.c b/shared-bindings/gamepadshift/GamePadShift.c
index 854f092ad..e05a95865 100644
--- a/shared-bindings/gamepadshift/GamePadShift.c
+++ b/shared-bindings/gamepadshift/GamePadShift.c
@@ -36,7 +36,7 @@
//| class GamePadShift:
//| """Scan buttons for presses through a shift register"""
//|
-//| def __init__(self, clock: Any, data: Any, latch: Any):
+//| def __init__(self, clock: DigitalInOut, data: DigitalInOut, latch: DigitalInOut) -> None:
//| """Initializes button scanning routines.
//|
//| The ``clock``, ``data`` and ``latch`` parameters are ``DigitalInOut``
@@ -82,7 +82,7 @@ STATIC mp_obj_t gamepadshift_make_new(const mp_obj_type_t *type, size_t n_args,
return MP_OBJ_FROM_PTR(gamepad_singleton);
}
-//| def get_pressed(self, ) -> Any:
+//| def get_pressed(self) -> int:
//| """Get the status of buttons pressed since the last call and clear it.
//|
//| Returns an 8-bit number, with bits that correspond to buttons,
@@ -100,7 +100,7 @@ STATIC mp_obj_t gamepadshift_get_pressed(mp_obj_t self_in) {
}
MP_DEFINE_CONST_FUN_OBJ_1(gamepadshift_get_pressed_obj, gamepadshift_get_pressed);
-//| def deinit(self, ) -> Any:
+//| def deinit(self) -> None:
//| """Disable button scanning."""
//| ...
//|
diff --git a/shared-bindings/gnss/GNSS.c b/shared-bindings/gnss/GNSS.c
index 186766591..f87a943b0 100644
--- a/shared-bindings/gnss/GNSS.c
+++ b/shared-bindings/gnss/GNSS.c
@@ -31,7 +31,7 @@
//| print("Longitude: {0:.6f} degrees".format(nav.longitude))"""
//|
-//| def __init__(self, ):
+//| def __init__(self) -> None:
//| """Turn on the GNSS.
//|
//| :param gnss.SatelliteSystem system: satellite system to use"""
@@ -68,7 +68,7 @@ STATIC mp_obj_t gnss_make_new(const mp_obj_type_t *type, size_t n_args, const mp
return MP_OBJ_FROM_PTR(self);
}
-//| def deinit(self, ) -> Any:
+//| def deinit(self) -> None:
//| """Turn off the GNSS."""
//| ...
//|
@@ -85,7 +85,7 @@ STATIC void check_for_deinit(gnss_obj_t *self) {
}
}
-//| def update(self, ) -> Any:
+//| def update(self) -> None:
//| """Update GNSS positioning information."""
//| ...
//|
@@ -98,7 +98,7 @@ STATIC mp_obj_t gnss_obj_update(mp_obj_t self_in) {
}
MP_DEFINE_CONST_FUN_OBJ_1(gnss_update_obj, gnss_obj_update);
-//| latitude: Any = ...
+//| latitude: float = ...
//| """Latitude of current position in degrees (float)."""
//|
STATIC mp_obj_t gnss_obj_get_latitude(mp_obj_t self_in) {
@@ -115,7 +115,7 @@ const mp_obj_property_t gnss_latitude_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| longitude: Any = ...
+//| longitude: float = ...
//| """Longitude of current position in degrees (float)."""
//|
STATIC mp_obj_t gnss_obj_get_longitude(mp_obj_t self_in) {
@@ -132,7 +132,7 @@ const mp_obj_property_t gnss_longitude_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| altitude: Any = ...
+//| altitude: float = ...
//| """Altitude of current position in meters (float)."""
//|
STATIC mp_obj_t gnss_obj_get_altitude(mp_obj_t self_in) {
@@ -149,7 +149,7 @@ const mp_obj_property_t gnss_altitude_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| timestamp: Any = ...
+//| timestamp: time.struct_time = ...
//| """Time when the position data was updated."""
//|
STATIC mp_obj_t gnss_obj_get_timestamp(mp_obj_t self_in) {
@@ -168,7 +168,7 @@ const mp_obj_property_t gnss_timestamp_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| fix: Any = ...
+//| fix: gnss.PositionFix = ...
//| """Fix mode."""
//|
STATIC mp_obj_t gnss_obj_get_fix(mp_obj_t self_in) {
diff --git a/shared-bindings/gnss/PositionFix.c b/shared-bindings/gnss/PositionFix.c
index 262ebf319..867911f01 100644
--- a/shared-bindings/gnss/PositionFix.c
+++ b/shared-bindings/gnss/PositionFix.c
@@ -7,20 +7,20 @@
//| class PositionFix:
//| """Position fix mode"""
//|
-//| def __init__(self, ):
+//| def __init__(self) -> None:
//| """Enum-like class to define the position fix mode."""
//|
-//| INVALID: Any = ...
+//| INVALID: PositionFix = ...
//| """No measurement.
//|
-//| :type gnss.PositionFix:"""
+//| :type PositionFix:"""
//|
-//| FIX_2D: Any = ...
+//| FIX_2D: PositionFix = ...
//| """2D fix.
//|
-//| :type gnss.PositionFix:"""
+//| :type PositionFix:"""
//|
-//| FIX_3D: Any = ...
+//| FIX_3D: PositionFix = ...
//| """3D fix.
//|
//| :type gnss.PositionFix:"""
diff --git a/shared-bindings/gnss/SatelliteSystem.c b/shared-bindings/gnss/SatelliteSystem.c
index 8739fbc02..951c5a0e8 100644
--- a/shared-bindings/gnss/SatelliteSystem.c
+++ b/shared-bindings/gnss/SatelliteSystem.c
@@ -7,30 +7,30 @@
//| class SatelliteSystem:
//| """Satellite system type"""
//|
-//| def __init__(self, ):
+//| def __init__(self) -> None:
//| """Enum-like class to define the satellite system type."""
//|
-//| GPS: Any = ...
+//| GPS: SatelliteSystem = ...
//| """Global Positioning System.
//|
//| :type gnss.SatelliteSystem:"""
//|
-//| GLONASS: Any = ...
+//| GLONASS: SatelliteSystem = ...
//| """GLObal NAvigation Satellite System.
//|
//| :type gnss.SatelliteSystem:"""
//|
-//| SBAS: Any = ...
+//| SBAS: SatelliteSystem = ...
//| """Satellite Based Augmentation System.
//|
//| :type gnss.SatelliteSystem:"""
//|
-//| QZSS_L1CA: Any = ...
+//| QZSS_L1CA: SatelliteSystem = ...
//| """Quasi-Zenith Satellite System L1C/A.
//|
//| :type gnss.SatelliteSystem:"""
//|
-//| QZSS_L1S: Any = ...
+//| QZSS_L1S: SatelliteSystem = ...
//| """Quasi-Zenith Satellite System L1S.
//|
//| :type gnss.SatelliteSystem:"""
diff --git a/shared-bindings/i2cperipheral/I2CPeripheral.c b/shared-bindings/i2cperipheral/I2CPeripheral.c
index 4a3900174..b528ca9c3 100644
--- a/shared-bindings/i2cperipheral/I2CPeripheral.c
+++ b/shared-bindings/i2cperipheral/I2CPeripheral.c
@@ -52,7 +52,7 @@ STATIC mp_obj_t mp_obj_new_i2cperipheral_i2c_peripheral_request(i2cperipheral_i2
//| class I2CPeripheral:
//| """Two wire serial protocol peripheral"""
//|
-//| def __init__(self, scl: microcontroller.Pin, sda: microcontroller.Pin, addresses: tuple, smbus: bool = False):
+//| def __init__(self, scl: microcontroller.Pin, sda: microcontroller.Pin, addresses: tuple, smbus: bool = False) -> None:
//| """I2C is a two-wire protocol for communicating between devices.
//| This implements the peripheral (sensor, secondary) side.
//|
@@ -102,7 +102,7 @@ STATIC mp_obj_t i2cperipheral_i2c_peripheral_make_new(const mp_obj_type_t *type,
return (mp_obj_t)self;
}
-//| def deinit(self, ) -> Any:
+//| def deinit(self) -> None:
//| """Releases control of the underlying hardware so other classes can use it."""
//| ...
//|
@@ -114,13 +114,13 @@ STATIC mp_obj_t i2cperipheral_i2c_peripheral_obj_deinit(mp_obj_t self_in) {
}
MP_DEFINE_CONST_FUN_OBJ_1(i2cperipheral_i2c_peripheral_deinit_obj, i2cperipheral_i2c_peripheral_obj_deinit);
-//| def __enter__(self, ) -> Any:
+//| def __enter__(self) -> I2CPeripheral:
//| """No-op used in Context Managers."""
//| ...
//|
// Provided by context manager helper.
-//| def __exit__(self, ) -> Any:
+//| def __exit__(self) -> None:
//| """Automatically deinitializes the hardware on context exit. See
//| :ref:`lifetime-and-contextmanagers` for more info."""
//| ...
@@ -133,7 +133,7 @@ STATIC mp_obj_t i2cperipheral_i2c_peripheral_obj___exit__(size_t n_args, const m
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(i2cperipheral_i2c_peripheral___exit___obj, 4, 4, i2cperipheral_i2c_peripheral_obj___exit__);
-//| def request(self, timeout: float = -1) -> Any:
+//| def request(self, timeout: float = -1) -> I2CPeripheralRequest:
//| """Wait for an I2C request.
//|
//| :param float timeout: Timeout in seconds. Zero means wait forever, a negative value means check once
@@ -227,7 +227,7 @@ const mp_obj_type_t i2cperipheral_i2c_peripheral_type = {
//| class I2CPeripheralRequest:
//|
-//| def __init__(self, peripheral: i2cperipheral.I2CPeripheral, address: int, is_read: bool, is_restart: bool):
+//| def __init__(self, peripheral: i2cperipheral.I2CPeripheral, address: int, is_read: bool, is_restart: bool) -> None:
//| """Information about an I2C transfer request
//| This cannot be instantiated directly, but is returned by :py:meth:`I2CPeripheral.request`.
//|
@@ -241,13 +241,13 @@ STATIC mp_obj_t i2cperipheral_i2c_peripheral_request_make_new(const mp_obj_type_
return mp_obj_new_i2cperipheral_i2c_peripheral_request(args[0], mp_obj_get_int(args[1]), mp_obj_is_true(args[2]), mp_obj_is_true(args[3]));
}
-//| def __enter__(self, ) -> Any:
+//| def __enter__(self) -> I2CPeripheralRequest:
//| """No-op used in Context Managers."""
//| ...
//|
// Provided by context manager helper.
-//| def __exit__(self, ) -> Any:
+//| def __exit__(self) -> None:
//| """Close the request."""
//| ...
//|
@@ -383,7 +383,7 @@ STATIC mp_obj_t i2cperipheral_i2c_peripheral_request_write(mp_obj_t self_in, mp_
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(i2cperipheral_i2c_peripheral_request_write_obj, i2cperipheral_i2c_peripheral_request_write);
-//| def ack(self, ack: bool = True) -> Any:
+//| def ack(self, ack: bool = True) -> None:
//| """Acknowledge or Not Acknowledge last byte received.
//| Use together with :py:meth:`I2CPeripheralRequest.read` ack=False.
//|
diff --git a/shared-bindings/math/__init__.c b/shared-bindings/math/__init__.c
index ad2e1877d..968da0d61 100644
--- a/shared-bindings/math/__init__.c
+++ b/shared-bindings/math/__init__.c
@@ -79,108 +79,108 @@ STATIC NORETURN void math_error(void) {
#define log2(x) (log(x) * 1.442695040888963407354163704)
#endif
-//| e: Any = ...
+//| e: float = ...
//| """base of the natural logarithm"""
//|
-//| pi: Any = ...
+//| pi: float = ...
//| """the ratio of a circle's circumference to its diameter"""
//|
-//| def acos(x: Any) -> Any:
+//| def acos(x: float) -> float:
//| """Return the inverse cosine of ``x``."""
//| ...
//|
-//| def asin(x: Any) -> Any:
+//| def asin(x: float) -> float:
//| """Return the inverse sine of ``x``."""
//| ...
//|
-//| def atan(x: Any) -> Any:
+//| def atan(x: float) -> float:
//| """Return the inverse tangent of ``x``."""
//| ...
//|
-//| def atan2(y: Any, x: Any) -> Any:
+//| def atan2(y: float, x: float) -> float:
//| """Return the principal value of the inverse tangent of ``y/x``."""
//| ...
//|
-//| def ceil(x: Any) -> Any:
+//| def ceil(x: float) -> int:
//| """Return an integer, being ``x`` rounded towards positive infinity."""
//| ...
//|
-//| def copysign(x: Any, y: Any) -> Any:
+//| def copysign(x: float, y: float) -> float:
//| """Return ``x`` with the sign of ``y``."""
//| ...
//|
-//| def cos(x: Any) -> Any:
+//| def cos(x: float) -> float:
//| """Return the cosine of ``x``."""
//| ...
//|
-//| def degrees(x: Any) -> Any:
+//| def degrees(x: float) -> float:
//| """Return radians ``x`` converted to degrees."""
//| ...
//|
-//| def exp(x: Any) -> Any:
+//| def exp(x: float) -> float:
//| """Return the exponential of ``x``."""
//| ...
//|
-//| def fabs(x: Any) -> Any:
+//| def fabs(x: float) -> float:
//| """Return the absolute value of ``x``."""
//| ...
//|
-//| def floor(x: Any) -> Any:
+//| def floor(x: float) -> float:
//| """Return an integer, being ``x`` rounded towards negative infinity."""
//| ...
//|
-//| def fmod(x: Any, y: Any) -> Any:
+//| def fmod(x: float, y: float) -> int:
//| """Return the remainder of ``x/y``."""
//| ...
//|
-//| def frexp(x: Any) -> Any:
+//| def frexp(x: float) -> Tuple[int, int]:
//| """Decomposes a floating-point number into its mantissa and exponent.
//| The returned value is the tuple ``(m, e)`` such that ``x == m * 2**e``
//| exactly. If ``x == 0`` then the function returns ``(0.0, 0)``, otherwise
//| the relation ``0.5 <= abs(m) < 1`` holds."""
//| ...
//|
-//| def isfinite(x: Any) -> Any:
+//| def isfinite(x: float) -> bool:
//| """Return ``True`` if ``x`` is finite."""
//| ...
//|
-//| def isinf(x: Any) -> Any:
+//| def isinf(x: float) -> bool:
//| """Return ``True`` if ``x`` is infinite."""
//| ...
//|
-//| def isnan(x: Any) -> Any:
+//| def isnan(x: float) -> bool:
//| """Return ``True`` if ``x`` is not-a-number"""
//| ...
//|
-//| def ldexp(x: Any, exp: Any) -> Any:
+//| def ldexp(x: float, exp: float) -> float:
//| """Return ``x * (2**exp)``."""
//| ...
//|
-//| def modf(x: Any) -> Any:
+//| def modf(x: float) -> Tuple[float, float]:
//| """Return a tuple of two floats, being the fractional and integral parts of
//| ``x``. Both return values have the same sign as ``x``."""
//| ...
//|
-//| def pow(x: Any, y: Any) -> Any:
+//| def pow(x: float, y: float) -> float:
//| """Returns ``x`` to the power of ``y``."""
//|
-//| def radians(x: Any) -> Any:
+//| def radians(x: float) -> float:
//| """Return degrees ``x`` converted to radians."""
//|
-//| def sin(x: Any) -> Any:
+//| def sin(x: float) -> float:
//| """Return the sine of ``x``."""
//| ...
//|
-//| def sqrt(x: Any) -> Any:
+//| def sqrt(x: float) -> float:
//| """Returns the square root of ``x``."""
//| ...
//|
-//| def tan(x: Any) -> Any:
+//| def tan(x: float) -> float:
//| """Return the tangent of ``x``."""
//| ...
//|
-//| def trunc(x: Any) -> Any:
+//| def trunc(x: float) -> int:
//| """Return an integer, being ``x`` rounded towards 0."""
//| ...
//|
@@ -190,55 +190,55 @@ MATH_FUN_2(pow, pow)
MATH_FUN_1(exp, exp)
#if MICROPY_PY_MATH_SPECIAL_FUNCTIONS
-//| def expm1(x):
+//| def expm1(x: float) -> float:
//| """Return ``exp(x) - 1``."""
//| ...
//|
MATH_FUN_1(expm1, expm1)
-//| def log2(x):
+//| def log2(x: float) -> float:
//| """Return the base-2 logarithm of ``x``."""
//| ...
//|
MATH_FUN_1_ERRCOND(log2, log2, (x <= (mp_float_t)0.0))
-//| def log10(x):
+//| def log10(x: float) -> float:
//| """Return the base-10 logarithm of ``x``."""
//| ...
//|
MATH_FUN_1_ERRCOND(log10, log10, (x <= (mp_float_t)0.0))
-//| def cosh(x):
+//| def cosh(x: float) -> float:
//| """Return the hyperbolic cosine of ``x``."""
//| ...
//|
MATH_FUN_1(cosh, cosh)
-//| def sinh(x):
+//| def sinh(x: float) -> float:
//| """Return the hyperbolic sine of ``x``."""
//| ...
//|
MATH_FUN_1(sinh, sinh)
-//| def tanh(x):
+//| def tanh(x: float) -> float:
//| """Return the hyperbolic tangent of ``x``."""
//| ...
//|
MATH_FUN_1(tanh, tanh)
-//| def acosh(x):
+//| def acosh(x: float) -> float:
//| """Return the inverse hyperbolic cosine of ``x``."""
//| ...
//|
MATH_FUN_1(acosh, acosh)
-//| def asinh(x):
+//| def asinh(x: float) -> float:
//| """Return the inverse hyperbolic sine of ``x``."""
//| ...
//|
MATH_FUN_1(asinh, asinh)
-//| def atanh(x):
+//| def atanh(x: float) -> float:
//| """Return the inverse hyperbolic tangent of ``x``."""
//| ...
//|
@@ -280,25 +280,25 @@ MATH_FUN_1_TO_INT(trunc, trunc)
MATH_FUN_2(ldexp, ldexp)
#if MICROPY_PY_MATH_SPECIAL_FUNCTIONS
-//| def erf(x):
+//| def erf(x: float) -> float:
//| """Return the error function of ``x``."""
//| ...
//|
MATH_FUN_1(erf, erf)
-//| def erfc(x):
+//| def erfc(x: float) -> float:
//| """Return the complementary error function of ``x``."""
//| ...
//|
MATH_FUN_1(erfc, erfc)
-//| def gamma(x):
+//| def gamma(x: float) -> float:
//| """Return the gamma function of ``x``."""
//| ...
//|
MATH_FUN_1(gamma, tgamma)
-//| def lgamma(x):
+//| def lgamma(x: float) -> float:
//| """Return the natural logarithm of the gamma function of ``x``."""
//| ...
//|
diff --git a/shared-bindings/memorymonitor/AllocationAlarm.c b/shared-bindings/memorymonitor/AllocationAlarm.c
new file mode 100644
index 000000000..36e2cb5b2
--- /dev/null
+++ b/shared-bindings/memorymonitor/AllocationAlarm.c
@@ -0,0 +1,137 @@
+/*
+ * This file is part of the Micro Python project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020 Scott Shawcroft for Adafruit Industries
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include <stdint.h>
+
+#include "py/objproperty.h"
+#include "py/runtime.h"
+#include "py/runtime0.h"
+#include "shared-bindings/memorymonitor/AllocationAlarm.h"
+#include "shared-bindings/util.h"
+#include "supervisor/shared/translate.h"
+
+//| class AllocationAlarm:
+//|
+//| def __init__(self, *, minimum_block_count=1):
+//| """Throw an exception when an allocation of ``minimum_block_count`` or more blocks
+//| occurs while active.
+//|
+//| Track allocations::
+//|
+//| import memorymonitor
+//|
+//| aa = memorymonitor.AllocationAlarm(minimum_block_count=2)
+//| x = 2
+//| # Should not allocate any blocks.
+//| with aa:
+//| x = 5
+//|
+//| # Should throw an exception when allocating storage for the 20 bytes.
+//| with aa:
+//| x = bytearray(20)
+//|
+//| """
+//| ...
+//|
+STATIC mp_obj_t memorymonitor_allocationalarm_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
+ enum { ARG_minimum_block_count };
+ static const mp_arg_t allowed_args[] = {
+ { MP_QSTR_minimum_block_count, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 1} },
+ };
+ mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
+ mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
+ mp_int_t minimum_block_count = args[ARG_minimum_block_count].u_int;
+ if (minimum_block_count < 1) {
+ mp_raise_ValueError_varg(translate("%q must be >= 1"), MP_QSTR_minimum_block_count);
+ }
+
+ memorymonitor_allocationalarm_obj_t *self = m_new_obj(memorymonitor_allocationalarm_obj_t);
+ self->base.type = &memorymonitor_allocationalarm_type;
+
+ common_hal_memorymonitor_allocationalarm_construct(self, minimum_block_count);
+
+ return MP_OBJ_FROM_PTR(self);
+}
+
+//| def ignore(self, count) -> AllocationAlarm:
+//| """Sets the number of applicable allocations to ignore before raising the exception.
+//| Automatically set back to zero at context exit.
+//|
+//| Use it within a ``with`` block::
+//|
+//| # Will not alarm because the bytearray allocation will be ignored.
+//| with aa.ignore(2):
+//| x = bytearray(20)
+//| """
+//| ...
+//|
+STATIC mp_obj_t memorymonitor_allocationalarm_obj_ignore(mp_obj_t self_in, mp_obj_t count_obj) {
+ mp_int_t count = mp_obj_get_int(count_obj);
+ if (count < 0) {
+ mp_raise_ValueError_varg(translate("%q must be >= 0"), MP_QSTR_count);
+ }
+ common_hal_memorymonitor_allocationalarm_set_ignore(self_in, count);
+ return self_in;
+}
+MP_DEFINE_CONST_FUN_OBJ_2(memorymonitor_allocationalarm_ignore_obj, memorymonitor_allocationalarm_obj_ignore);
+
+//| def __enter__(self) -> memorymonitor.AllocationAlarm:
+//| """Enables the alarm."""
+//| ...
+//|
+STATIC mp_obj_t memorymonitor_allocationalarm_obj___enter__(mp_obj_t self_in) {
+ common_hal_memorymonitor_allocationalarm_resume(self_in);
+ return self_in;
+}
+MP_DEFINE_CONST_FUN_OBJ_1(memorymonitor_allocationalarm___enter___obj, memorymonitor_allocationalarm_obj___enter__);
+
+//| def __exit__(self) -> None:
+//| """Automatically disables the allocation alarm when exiting a context. See
+//| :ref:`lifetime-and-contextmanagers` for more info."""
+//| ...
+//|
+STATIC mp_obj_t memorymonitor_allocationalarm_obj___exit__(size_t n_args, const mp_obj_t *args) {
+ (void)n_args;
+ common_hal_memorymonitor_allocationalarm_set_ignore(args[0], 0);
+ common_hal_memorymonitor_allocationalarm_pause(args[0]);
+ return mp_const_none;
+}
+STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(memorymonitor_allocationalarm___exit___obj, 4, 4, memorymonitor_allocationalarm_obj___exit__);
+
+STATIC const mp_rom_map_elem_t memorymonitor_allocationalarm_locals_dict_table[] = {
+ // Methods
+ { MP_ROM_QSTR(MP_QSTR_ignore), MP_ROM_PTR(&memorymonitor_allocationalarm_ignore_obj) },
+ { MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&memorymonitor_allocationalarm___enter___obj) },
+ { MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&memorymonitor_allocationalarm___exit___obj) },
+};
+STATIC MP_DEFINE_CONST_DICT(memorymonitor_allocationalarm_locals_dict, memorymonitor_allocationalarm_locals_dict_table);
+
+const mp_obj_type_t memorymonitor_allocationalarm_type = {
+ { &mp_type_type },
+ .name = MP_QSTR_AllocationAlarm,
+ .make_new = memorymonitor_allocationalarm_make_new,
+ .locals_dict = (mp_obj_dict_t*)&memorymonitor_allocationalarm_locals_dict,
+};
diff --git a/shared-bindings/memorymonitor/AllocationAlarm.h b/shared-bindings/memorymonitor/AllocationAlarm.h
new file mode 100644
index 000000000..304b9c5a7
--- /dev/null
+++ b/shared-bindings/memorymonitor/AllocationAlarm.h
@@ -0,0 +1,39 @@
+/*
+ * This file is part of the Micro Python project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020 Scott Shawcroft for Adafruit Industries
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_MEMORYMONITOR_ALLOCATIONALARM_H
+#define MICROPY_INCLUDED_SHARED_BINDINGS_MEMORYMONITOR_ALLOCATIONALARM_H
+
+#include "shared-module/memorymonitor/AllocationAlarm.h"
+
+extern const mp_obj_type_t memorymonitor_allocationalarm_type;
+
+void common_hal_memorymonitor_allocationalarm_construct(memorymonitor_allocationalarm_obj_t* self, size_t minimum_block_count);
+void common_hal_memorymonitor_allocationalarm_pause(memorymonitor_allocationalarm_obj_t* self);
+void common_hal_memorymonitor_allocationalarm_resume(memorymonitor_allocationalarm_obj_t* self);
+void common_hal_memorymonitor_allocationalarm_set_ignore(memorymonitor_allocationalarm_obj_t* self, mp_int_t count);
+
+#endif // MICROPY_INCLUDED_SHARED_BINDINGS_MEMORYMONITOR_ALLOCATIONALARM_H
diff --git a/shared-bindings/memorymonitor/AllocationSize.c b/shared-bindings/memorymonitor/AllocationSize.c
new file mode 100644
index 000000000..501674441
--- /dev/null
+++ b/shared-bindings/memorymonitor/AllocationSize.c
@@ -0,0 +1,183 @@
+/*
+ * This file is part of the Micro Python project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020 Scott Shawcroft for Adafruit Industries
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include <stdint.h>
+
+#include "py/objproperty.h"
+#include "py/runtime.h"
+#include "py/runtime0.h"
+#include "shared-bindings/memorymonitor/AllocationSize.h"
+#include "shared-bindings/util.h"
+#include "supervisor/shared/translate.h"
+
+//| class AllocationSize:
+//|
+//| def __init__(self):
+//| """Tracks the number of allocations in power of two buckets.
+//|
+//| It will have 16 16-bit buckets to track allocation counts. It is total allocations
+//| meaning frees are ignored. Reallocated memory is counted twice, at allocation and when
+//| reallocated with the larger size.
+//|
+//| The buckets are measured in terms of blocks which is the finest granularity of the heap.
+//| This means bucket 0 will count all allocations less than or equal to the number of bytes
+//| per block, typically 16. Bucket 2 will be less than or equal to 4 blocks. See
+//| `bytes_per_block` to convert blocks to bytes.
+//|
+//| Multiple AllocationSizes can be used to track different code boundaries.
+//|
+//| Track allocations::
+//|
+//| import memorymonitor
+//|
+//| mm = memorymonitor.AllocationSize()
+//| with mm:
+//| print("hello world" * 3)
+//|
+//| for bucket, count in enumerate(mm):
+//| print("<", 2 ** bucket, count)
+//|
+//| """
+//| ...
+//|
+STATIC mp_obj_t memorymonitor_allocationsize_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
+ memorymonitor_allocationsize_obj_t *self = m_new_obj(memorymonitor_allocationsize_obj_t);
+ self->base.type = &memorymonitor_allocationsize_type;
+
+ common_hal_memorymonitor_allocationsize_construct(self);
+
+ return MP_OBJ_FROM_PTR(self);
+}
+
+//| def __enter__(self, ) -> Any:
+//| """Clears counts and resumes tracking."""
+//| ...
+//|
+STATIC mp_obj_t memorymonitor_allocationsize_obj___enter__(mp_obj_t self_in) {
+ common_hal_memorymonitor_allocationsize_clear(self_in);
+ common_hal_memorymonitor_allocationsize_resume(self_in);
+ return self_in;
+}
+MP_DEFINE_CONST_FUN_OBJ_1(memorymonitor_allocationsize___enter___obj, memorymonitor_allocationsize_obj___enter__);
+
+//| def __exit__(self, ) -> Any:
+//| """Automatically pauses allocation tracking when exiting a context. See
+//| :ref:`lifetime-and-contextmanagers` for more info."""
+//| ...
+//|
+STATIC mp_obj_t memorymonitor_allocationsize_obj___exit__(size_t n_args, const mp_obj_t *args) {
+ (void)n_args;
+ common_hal_memorymonitor_allocationsize_pause(args[0]);
+ return mp_const_none;
+}
+STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(memorymonitor_allocationsize___exit___obj, 4, 4, memorymonitor_allocationsize_obj___exit__);
+
+//| bytes_per_block: int = ...
+//| """Number of bytes per block"""
+//|
+STATIC mp_obj_t memorymonitor_allocationsize_obj_get_bytes_per_block(mp_obj_t self_in) {
+ memorymonitor_allocationsize_obj_t *self = MP_OBJ_TO_PTR(self_in);
+
+ return MP_OBJ_NEW_SMALL_INT(common_hal_memorymonitor_allocationsize_get_bytes_per_block(self));
+}
+MP_DEFINE_CONST_FUN_OBJ_1(memorymonitor_allocationsize_get_bytes_per_block_obj, memorymonitor_allocationsize_obj_get_bytes_per_block);
+
+const mp_obj_property_t memorymonitor_allocationsize_bytes_per_block_obj = {
+ .base.type = &mp_type_property,
+ .proxy = {(mp_obj_t)&memorymonitor_allocationsize_get_bytes_per_block_obj,
+ (mp_obj_t)&mp_const_none_obj,
+ (mp_obj_t)&mp_const_none_obj},
+};
+
+//| def __len__(self, ) -> Any:
+//| """Returns the number of allocation buckets.
+//|
+//| This allows you to::
+//|
+//| mm = memorymonitor.AllocationSize()
+//| print(len(mm))"""
+//| ...
+//|
+STATIC mp_obj_t memorymonitor_allocationsize_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
+ memorymonitor_allocationsize_obj_t *self = MP_OBJ_TO_PTR(self_in);
+ uint16_t len = common_hal_memorymonitor_allocationsize_get_len(self);
+ switch (op) {
+ case MP_UNARY_OP_BOOL: return mp_obj_new_bool(len != 0);
+ case MP_UNARY_OP_LEN: return MP_OBJ_NEW_SMALL_INT(len);
+ default: return MP_OBJ_NULL; // op not supported
+ }
+}
+
+//| def __getitem__(self, index: Any) -> Any:
+//| """Returns the allocation count for the given bucket.
+//|
+//| This allows you to::
+//|
+//| mm = memorymonitor.AllocationSize()
+//| print(mm[0])"""
+//| ...
+//|
+STATIC mp_obj_t memorymonitor_allocationsize_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t value) {
+ if (value == mp_const_none) {
+ // delete item
+ mp_raise_AttributeError(translate("Cannot delete values"));
+ } else {
+ memorymonitor_allocationsize_obj_t *self = MP_OBJ_TO_PTR(self_in);
+
+ if (MP_OBJ_IS_TYPE(index_obj, &mp_type_slice)) {
+ mp_raise_NotImplementedError(translate("Slices not supported"));
+ } else {
+ size_t index = mp_get_index(&memorymonitor_allocationsize_type, common_hal_memorymonitor_allocationsize_get_len(self), index_obj, false);
+ if (value == MP_OBJ_SENTINEL) {
+ // load
+ return MP_OBJ_NEW_SMALL_INT(common_hal_memorymonitor_allocationsize_get_item(self, index));
+ } else {
+ mp_raise_AttributeError(translate("Read-only"));
+ }
+ }
+ }
+ return mp_const_none;
+}
+
+STATIC const mp_rom_map_elem_t memorymonitor_allocationsize_locals_dict_table[] = {
+ // Methods
+ { MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&memorymonitor_allocationsize___enter___obj) },
+ { MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&memorymonitor_allocationsize___exit___obj) },
+
+ // Properties
+ { MP_ROM_QSTR(MP_QSTR_bytes_per_block), MP_ROM_PTR(&memorymonitor_allocationsize_bytes_per_block_obj) },
+};
+STATIC MP_DEFINE_CONST_DICT(memorymonitor_allocationsize_locals_dict, memorymonitor_allocationsize_locals_dict_table);
+
+const mp_obj_type_t memorymonitor_allocationsize_type = {
+ { &mp_type_type },
+ .name = MP_QSTR_AllocationSize,
+ .make_new = memorymonitor_allocationsize_make_new,
+ .subscr = memorymonitor_allocationsize_subscr,
+ .unary_op = memorymonitor_allocationsize_unary_op,
+ .getiter = mp_obj_new_generic_iterator,
+ .locals_dict = (mp_obj_dict_t*)&memorymonitor_allocationsize_locals_dict,
+};
diff --git a/shared-bindings/memorymonitor/AllocationSize.h b/shared-bindings/memorymonitor/AllocationSize.h
new file mode 100644
index 000000000..bcd9514bf
--- /dev/null
+++ b/shared-bindings/memorymonitor/AllocationSize.h
@@ -0,0 +1,42 @@
+/*
+ * This file is part of the Micro Python project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020 Scott Shawcroft for Adafruit Industries
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_MEMORYMONITOR_ALLOCATIONSIZE_H
+#define MICROPY_INCLUDED_SHARED_BINDINGS_MEMORYMONITOR_ALLOCATIONSIZE_H
+
+#include "shared-module/memorymonitor/AllocationSize.h"
+
+extern const mp_obj_type_t memorymonitor_allocationsize_type;
+
+extern void common_hal_memorymonitor_allocationsize_construct(memorymonitor_allocationsize_obj_t* self);
+extern void common_hal_memorymonitor_allocationsize_pause(memorymonitor_allocationsize_obj_t* self);
+extern void common_hal_memorymonitor_allocationsize_resume(memorymonitor_allocationsize_obj_t* self);
+extern void common_hal_memorymonitor_allocationsize_clear(memorymonitor_allocationsize_obj_t* self);
+extern size_t common_hal_memorymonitor_allocationsize_get_bytes_per_block(memorymonitor_allocationsize_obj_t* self);
+extern uint16_t common_hal_memorymonitor_allocationsize_get_len(memorymonitor_allocationsize_obj_t* self);
+extern uint16_t common_hal_memorymonitor_allocationsize_get_item(memorymonitor_allocationsize_obj_t* self, int16_t index);
+
+#endif // MICROPY_INCLUDED_SHARED_BINDINGS_MEMORYMONITOR_ALLOCATIONSIZE_H
diff --git a/shared-bindings/memorymonitor/__init__.c b/shared-bindings/memorymonitor/__init__.c
new file mode 100644
index 000000000..98f48f525
--- /dev/null
+++ b/shared-bindings/memorymonitor/__init__.c
@@ -0,0 +1,77 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020 Scott Shawcroft
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include <stdint.h>
+
+#include "py/obj.h"
+#include "py/runtime.h"
+
+#include "shared-bindings/memorymonitor/__init__.h"
+#include "shared-bindings/memorymonitor/AllocationAlarm.h"
+#include "shared-bindings/memorymonitor/AllocationSize.h"
+
+//| """Memory monitoring helpers"""
+//|
+
+//| class AllocationError:
+//| def __init__(self, Exception: Any):
+//| """Catchall exception for allocation related errors."""
+//| ...
+MP_DEFINE_MEMORYMONITOR_EXCEPTION(AllocationError, Exception)
+
+NORETURN void mp_raise_memorymonitor_AllocationError(const compressed_string_t* fmt, ...) {
+ va_list argptr;
+ va_start(argptr,fmt);
+ mp_obj_t exception = mp_obj_new_exception_msg_vlist(&mp_type_memorymonitor_AllocationError, fmt, argptr);
+ va_end(argptr);
+ nlr_raise(exception);
+}
+
+STATIC const mp_rom_map_elem_t memorymonitor_module_globals_table[] = {
+ { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_memorymonitor) },
+ { MP_ROM_QSTR(MP_QSTR_AllocationAlarm), MP_ROM_PTR(&memorymonitor_allocationalarm_type) },
+ { MP_ROM_QSTR(MP_QSTR_AllocationSize), MP_ROM_PTR(&memorymonitor_allocationsize_type) },
+
+ // Errors
+ { MP_ROM_QSTR(MP_QSTR_AllocationError), MP_ROM_PTR(&mp_type_memorymonitor_AllocationError) },
+};
+
+STATIC MP_DEFINE_CONST_DICT(memorymonitor_module_globals, memorymonitor_module_globals_table);
+
+void memorymonitor_exception_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
+ mp_print_kind_t k = kind & ~PRINT_EXC_SUBCLASS;
+ bool is_subclass = kind & PRINT_EXC_SUBCLASS;
+ if (!is_subclass && (k == PRINT_EXC)) {
+ mp_print_str(print, qstr_str(MP_OBJ_QSTR_VALUE(memorymonitor_module_globals_table[0].value)));
+ mp_print_str(print, ".");
+ }
+ mp_obj_exception_print(print, o_in, kind);
+}
+
+const mp_obj_module_t memorymonitor_module = {
+ .base = { &mp_type_module },
+ .globals = (mp_obj_dict_t*)&memorymonitor_module_globals,
+};
diff --git a/shared-bindings/memorymonitor/__init__.h b/shared-bindings/memorymonitor/__init__.h
new file mode 100644
index 000000000..60fcdc3f6
--- /dev/null
+++ b/shared-bindings/memorymonitor/__init__.h
@@ -0,0 +1,49 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2016 Scott Shawcroft
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_MEMORYMONITOR___INIT___H
+#define MICROPY_INCLUDED_SHARED_BINDINGS_MEMORYMONITOR___INIT___H
+
+#include "py/obj.h"
+
+
+void memorymonitor_exception_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind);
+
+#define MP_DEFINE_MEMORYMONITOR_EXCEPTION(exc_name, base_name) \
+const mp_obj_type_t mp_type_memorymonitor_ ## exc_name = { \
+ { &mp_type_type }, \
+ .name = MP_QSTR_ ## exc_name, \
+ .print = memorymonitor_exception_print, \
+ .make_new = mp_obj_exception_make_new, \
+ .attr = mp_obj_exception_attr, \
+ .parent = &mp_type_ ## base_name, \
+};
+
+extern const mp_obj_type_t mp_type_memorymonitor_AllocationError;
+
+NORETURN void mp_raise_memorymonitor_AllocationError(const compressed_string_t* msg, ...);
+
+#endif // MICROPY_INCLUDED_SHARED_BINDINGS_MEMORYMONITOR___INIT___H
diff --git a/shared-bindings/microcontroller/Pin.c b/shared-bindings/microcontroller/Pin.c
index d5b971ae5..931c0b4c4 100644
--- a/shared-bindings/microcontroller/Pin.c
+++ b/shared-bindings/microcontroller/Pin.c
@@ -36,7 +36,7 @@
//| class Pin:
//| """Identifies an IO pin on the microcontroller."""
//|
-//| def __init__(self, ):
+//| def __init__(self) -> None:
//| """Identifies an IO pin on the microcontroller. They are fixed by the
//| hardware so they cannot be constructed on demand. Instead, use
//| `board` or `microcontroller.pin` to reference the desired pin."""
diff --git a/shared-bindings/microcontroller/Processor.c b/shared-bindings/microcontroller/Processor.c
index c4b249124..d9f780f84 100644
--- a/shared-bindings/microcontroller/Processor.c
+++ b/shared-bindings/microcontroller/Processor.c
@@ -44,7 +44,7 @@
//| print(microcontroller.cpu.temperature)"""
//|
-//| def __init__(self, ):
+//| def __init__(self) -> None:
//| """You cannot create an instance of `microcontroller.Processor`.
//| Use `microcontroller.cpu` to access the sole instance available."""
//| ...
@@ -67,7 +67,7 @@ const mp_obj_property_t mcu_processor_frequency_obj = {
},
};
-//| temperature: Any = ...
+//| temperature: Optional[float] = ...
//| """The on-chip temperature, in Celsius, as a float. (read-only)
//|
//| Is `None` if the temperature is not available."""
@@ -87,7 +87,7 @@ const mp_obj_property_t mcu_processor_temperature_obj = {
},
};
-//| uid: Any = ...
+//| uid: bytearray = ...
//| """The unique id (aka serial number) of the chip as a `bytearray`. (read-only)"""
//|
STATIC mp_obj_t mcu_processor_get_uid(mp_obj_t self) {
@@ -106,7 +106,7 @@ const mp_obj_property_t mcu_processor_uid_obj = {
},
};
-//| voltage: Any = ...
+//| voltage: Optional[float] = ...
//| """The input voltage to the microcontroller, as a float. (read-only)
//|
//| Is `None` if the voltage is not available."""
diff --git a/shared-bindings/microcontroller/Processor.h b/shared-bindings/microcontroller/Processor.h
index 1088112f4..0f520f940 100644
--- a/shared-bindings/microcontroller/Processor.h
+++ b/shared-bindings/microcontroller/Processor.h
@@ -31,7 +31,7 @@
#include "common-hal/microcontroller/Processor.h"
-const mp_obj_type_t mcu_processor_type;
+extern const mp_obj_type_t mcu_processor_type;
uint32_t common_hal_mcu_processor_get_frequency(void);
float common_hal_mcu_processor_get_temperature(void);
diff --git a/shared-bindings/microcontroller/RunMode.c b/shared-bindings/microcontroller/RunMode.c
index 6db315d8d..38bbb612b 100644
--- a/shared-bindings/microcontroller/RunMode.c
+++ b/shared-bindings/microcontroller/RunMode.c
@@ -29,22 +29,22 @@
//| class RunMode:
//| """run state of the microcontroller"""
//|
-//| def __init__(self, ):
+//| def __init__(self) -> None:
//| """Enum-like class to define the run mode of the microcontroller and
//| CircuitPython."""
//|
-//| NORMAL: Any = ...
+//| NORMAL: RunMode = ...
//| """Run CircuitPython as normal.
//|
//| :type microcontroller.RunMode:"""
//|
-//| SAFE_MODE: Any = ...
+//| SAFE_MODE: RunMode = ...
//| """Run CircuitPython in safe mode. User code will not be run and the
//| file system will be writeable over USB.
//|
//| :type microcontroller.RunMode:"""
//|
-//| BOOTLOADER: Any = ...
+//| BOOTLOADER: RunMode = ...
//| """Run the bootloader.
//|
//| :type microcontroller.RunMode:"""
diff --git a/shared-bindings/microcontroller/RunMode.h b/shared-bindings/microcontroller/RunMode.h
index 5e8b6e646..ce90ab93a 100644
--- a/shared-bindings/microcontroller/RunMode.h
+++ b/shared-bindings/microcontroller/RunMode.h
@@ -35,7 +35,7 @@ typedef enum {
RUNMODE_BOOTLOADER
} mcu_runmode_t;
-const mp_obj_type_t mcu_runmode_type;
+extern const mp_obj_type_t mcu_runmode_type;
typedef struct {
mp_obj_base_t base;
diff --git a/shared-bindings/microcontroller/__init__.c b/shared-bindings/microcontroller/__init__.c
index 88fe9c224..6d556cdd7 100644
--- a/shared-bindings/microcontroller/__init__.c
+++ b/shared-bindings/microcontroller/__init__.c
@@ -54,7 +54,7 @@
//| This object is the sole instance of `microcontroller.Processor`."""
//|
-//| def delay_us(delay: Any) -> Any:
+//| def delay_us(delay: int) -> None:
//| """Dedicated delay method used for very short delays. **Do not** do long delays
//| because this stops all other functions from completing. Think of this as an empty
//| ``while`` loop that runs for the specified ``(delay)`` time. If you have other
@@ -72,7 +72,7 @@ STATIC mp_obj_t mcu_delay_us(mp_obj_t delay_obj) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(mcu_delay_us_obj, mcu_delay_us);
-//| def disable_interrupts() -> Any:
+//| def disable_interrupts() -> None:
//| """Disable all interrupts. Be very careful, this can stall everything."""
//| ...
//|
@@ -82,7 +82,7 @@ STATIC mp_obj_t mcu_disable_interrupts(void) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_0(mcu_disable_interrupts_obj, mcu_disable_interrupts);
-//| def enable_interrupts() -> Any:
+//| def enable_interrupts() -> None:
//| """Enable the interrupts that were enabled at the last disable."""
//| ...
//|
@@ -92,7 +92,7 @@ STATIC mp_obj_t mcu_enable_interrupts(void) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_0(mcu_enable_interrupts_obj, mcu_enable_interrupts);
-//| def on_next_reset(run_mode: microcontroller.RunMode) -> Any:
+//| def on_next_reset(run_mode: microcontroller.RunMode) -> None:
//| """Configure the run mode used the next time the microcontroller is reset but
//| not powered down.
//|
@@ -117,7 +117,7 @@ STATIC mp_obj_t mcu_on_next_reset(mp_obj_t run_mode_obj) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(mcu_on_next_reset_obj, mcu_on_next_reset);
-//| def reset() -> Any:
+//| def reset() -> None:
//| """Reset the microcontroller. After reset, the microcontroller will enter the
//| run mode last set by `on_next_reset`.
//|
diff --git a/shared-bindings/multiterminal/__init__.c b/shared-bindings/multiterminal/__init__.c
index baf2fb674..e4d6768ad 100644
--- a/shared-bindings/multiterminal/__init__.c
+++ b/shared-bindings/multiterminal/__init__.c
@@ -37,7 +37,7 @@
//| serial connection and the optional secondary connection."""
//|
-//| def get_secondary_terminal() -> Any:
+//| def get_secondary_terminal() -> secondary_terminal:
//| """Returns the current secondary terminal."""
//| ...
//|
@@ -46,7 +46,7 @@ STATIC mp_obj_t multiterminal_obj_get_secondary_terminal() {
}
MP_DEFINE_CONST_FUN_OBJ_0(multiterminal_get_secondary_terminal_obj, multiterminal_obj_get_secondary_terminal);
-//| def set_secondary_terminal(stream: stream) -> Any:
+//| def set_secondary_terminal(stream: stream) -> None:
//| """Read additional input from the given stream and write out back to it.
//| This doesn't replace the core stream (usually UART or native USB) but is
//| mixed in instead.
@@ -68,7 +68,7 @@ STATIC mp_obj_t multiterminal_obj_set_secondary_terminal(mp_obj_t secondary_term
}
MP_DEFINE_CONST_FUN_OBJ_1(multiterminal_set_secondary_terminal_obj, multiterminal_obj_set_secondary_terminal);
-//| def clear_secondary_terminal() -> Any:
+//| def clear_secondary_terminal() -> None:
//| """Clears the secondary terminal."""
//| ...
//|
@@ -78,7 +78,7 @@ STATIC mp_obj_t multiterminal_obj_clear_secondary_terminal() {
}
MP_DEFINE_CONST_FUN_OBJ_0(multiterminal_clear_secondary_terminal_obj, multiterminal_obj_clear_secondary_terminal);
-//| def schedule_secondary_terminal_read(socket: Any) -> Any:
+//| def schedule_secondary_terminal_read(socket: secondary_terminal) -> None:
//| """In cases where the underlying OS is doing task scheduling, this notifies
//| the OS when more data is available on the socket to read. This is useful
//| as a callback for lwip sockets."""
diff --git a/shared-bindings/network/__init__.c b/shared-bindings/network/__init__.c
index 4bd543a0a..35bbaa510 100644
--- a/shared-bindings/network/__init__.c
+++ b/shared-bindings/network/__init__.c
@@ -47,7 +47,7 @@
//| It is used by the 'socket' module to look up a suitable
//| NIC when a socket is created."""
//|
-//| def route() -> Any:
+//| def route() -> list:
//| """Returns a list of all configured NICs."""
//| ...
//|
diff --git a/shared-bindings/nvm/ByteArray.c b/shared-bindings/nvm/ByteArray.c
index 06d7d4c95..278ac4d73 100644
--- a/shared-bindings/nvm/ByteArray.c
+++ b/shared-bindings/nvm/ByteArray.c
@@ -44,12 +44,14 @@
//| microcontroller.nvm[0:3] = b\"\xcc\x10\x00\""""
//|
-//| def __init__(self, ):
+//| def __init__(self) -> None:
//| """Not currently dynamically supported. Access the sole instance through `microcontroller.nvm`."""
//| ...
//|
-//| def __len__(self, ) -> Any:
+//| def __bool__(self) -> bool: ...
+//|
+//| def __len__(self) -> int:
//| """Return the length. This is used by (`len`)"""
//| ...
//|
diff --git a/shared-bindings/nvm/ByteArray.h b/shared-bindings/nvm/ByteArray.h
index 5eee3ab50..9375bcb85 100644
--- a/shared-bindings/nvm/ByteArray.h
+++ b/shared-bindings/nvm/ByteArray.h
@@ -29,7 +29,7 @@
#include "common-hal/nvm/ByteArray.h"
-const mp_obj_type_t nvm_bytearray_type;
+extern const mp_obj_type_t nvm_bytearray_type;
uint32_t common_hal_nvm_bytearray_get_length(nvm_bytearray_obj_t *self);
diff --git a/shared-bindings/os/__init__.c b/shared-bindings/os/__init__.c
index a247d6d84..c9aaf3b2c 100644
--- a/shared-bindings/os/__init__.c
+++ b/shared-bindings/os/__init__.c
@@ -44,7 +44,7 @@
//| other way around."""
//|
-//| def uname() -> Any:
+//| def uname() -> tuple:
//| """Returns a named tuple of operating specific and CircuitPython port
//| specific information."""
//| ...
@@ -54,7 +54,7 @@ STATIC mp_obj_t os_uname(void) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_0(os_uname_obj, os_uname);
-//| def chdir(path: Any) -> Any:
+//| def chdir(path: string) -> None:
//| """Change current directory."""
//| ...
//|
@@ -65,7 +65,7 @@ mp_obj_t os_chdir(mp_obj_t path_in) {
}
MP_DEFINE_CONST_FUN_OBJ_1(os_chdir_obj, os_chdir);
-//| def getcwd() -> Any:
+//| def getcwd() -> string:
//| """Get the current directory."""
//| ...
//|
@@ -74,7 +74,7 @@ mp_obj_t os_getcwd(void) {
}
MP_DEFINE_CONST_FUN_OBJ_0(os_getcwd_obj, os_getcwd);
-//| def listdir(dir: Any) -> Any:
+//| def listdir(dir: string) -> string:
//| """With no argument, list the current directory. Otherwise list the given directory."""
//| ...
//|
@@ -89,7 +89,7 @@ mp_obj_t os_listdir(size_t n_args, const mp_obj_t *args) {
}
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(os_listdir_obj, 0, 1, os_listdir);
-//| def mkdir(path: Any) -> Any:
+//| def mkdir(path: string) -> None:
//| """Create a new directory."""
//| ...
//|
@@ -100,7 +100,7 @@ mp_obj_t os_mkdir(mp_obj_t path_in) {
}
MP_DEFINE_CONST_FUN_OBJ_1(os_mkdir_obj, os_mkdir);
-//| def remove(path: Any) -> Any:
+//| def remove(path: string) -> None:
//| """Remove a file."""
//| ...
//|
@@ -111,7 +111,7 @@ mp_obj_t os_remove(mp_obj_t path_in) {
}
MP_DEFINE_CONST_FUN_OBJ_1(os_remove_obj, os_remove);
-//| def rmdir(path: Any) -> Any:
+//| def rmdir(path: string) -> None:
//| """Remove a directory."""
//| ...
//|
@@ -123,7 +123,7 @@ mp_obj_t os_rename(mp_obj_t old_path_in, mp_obj_t new_path_in) {
}
MP_DEFINE_CONST_FUN_OBJ_2(os_rename_obj, os_rename);
-//| def rename(old_path: Any, new_path: Any) -> Any:
+//| def rename(old_path: string, new_path: string) -> string:
//| """Rename a file."""
//| ...
//|
@@ -134,7 +134,7 @@ mp_obj_t os_rmdir(mp_obj_t path_in) {
}
MP_DEFINE_CONST_FUN_OBJ_1(os_rmdir_obj, os_rmdir);
-//| def stat(path: Any) -> Any:
+//| def stat(path: string) -> string:
//| """Get the status of a file or directory.
//|
//| .. note:: On builds without long integers, the number of seconds
@@ -149,7 +149,7 @@ mp_obj_t os_stat(mp_obj_t path_in) {
}
MP_DEFINE_CONST_FUN_OBJ_1(os_stat_obj, os_stat);
-//| def statvfs(path: Any) -> Any:
+//| def statvfs(path: string) -> Tuple[string, string, string, string, string, string, string, string, string, string]:
//| """Get the status of a fileystem.
//|
//| Returns a tuple with the filesystem information in the following order:
@@ -176,7 +176,7 @@ mp_obj_t os_statvfs(mp_obj_t path_in) {
}
MP_DEFINE_CONST_FUN_OBJ_1(os_statvfs_obj, os_statvfs);
-//| def sync() -> Any:
+//| def sync() -> None:
//| """Sync all filesystems."""
//| ...
//|
@@ -189,7 +189,7 @@ STATIC mp_obj_t os_sync(void) {
}
MP_DEFINE_CONST_FUN_OBJ_0(os_sync_obj, os_sync);
-//| def urandom(size: Any) -> Any:
+//| def urandom(size: int) -> string:
//| """Returns a string of *size* random bytes based on a hardware True Random
//| Number Generator. When not available, it will raise a NotImplementedError."""
//| ...
diff --git a/shared-bindings/os/__init__.h b/shared-bindings/os/__init__.h
index 3776fef64..8394890de 100644
--- a/shared-bindings/os/__init__.h
+++ b/shared-bindings/os/__init__.h
@@ -32,7 +32,7 @@
#include "py/objtuple.h"
-const mp_rom_obj_tuple_t common_hal_os_uname_info_obj;
+extern const mp_rom_obj_tuple_t common_hal_os_uname_info_obj;
mp_obj_t common_hal_os_uname(void);
void common_hal_os_chdir(const char* path);
diff --git a/shared-bindings/ps2io/Ps2.c b/shared-bindings/ps2io/Ps2.c
index a87b14ddd..15731ea40 100644
--- a/shared-bindings/ps2io/Ps2.c
+++ b/shared-bindings/ps2io/Ps2.c
@@ -45,7 +45,7 @@
//| level converters must be used to connect the I/O lines to pins
//| of 3.3V boards."""
//|
-//| def __init__(self, data_pin: microcontroller.Pin, clock_pin: microcontroller.Pin):
+//| def __init__(self, data_pin: microcontroller.Pin, clock_pin: microcontroller.Pin) -> None:
//| """Create a Ps2 object associated with the given pins.
//|
//| :param ~microcontroller.Pin data_pin: Pin tied to data wire.
@@ -87,7 +87,7 @@ STATIC mp_obj_t ps2io_ps2_make_new(const mp_obj_type_t *type, size_t n_args, con
return MP_OBJ_FROM_PTR(self);
}
-//| def deinit(self, ) -> Any:
+//| def deinit(self) -> None:
//| """Deinitialises the Ps2 and releases any hardware resources for reuse."""
//| ...
//|
@@ -104,13 +104,13 @@ STATIC void check_for_deinit(ps2io_ps2_obj_t *self) {
}
}
-//| def __enter__(self, ) -> Any:
+//| def __enter__(self) -> Ps2:
//| """No-op used by Context Managers."""
//| ...
//|
// Provided by context manager helper.
-//| def __exit__(self, ) -> Any:
+//| def __exit__(self) -> None:
//| """Automatically deinitializes the hardware when exiting a context. See
//| :ref:`lifetime-and-contextmanagers` for more info."""
//| ...
@@ -122,7 +122,7 @@ STATIC mp_obj_t ps2io_ps2_obj___exit__(size_t n_args, const mp_obj_t *args) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(ps2io_ps2___exit___obj, 4, 4, ps2io_ps2_obj___exit__);
-//| def popleft(self, ) -> Any:
+//| def popleft(self) -> int:
//| """Removes and returns the oldest received byte. When buffer
//| is empty, raises an IndexError exception."""
//| ...
@@ -139,7 +139,7 @@ STATIC mp_obj_t ps2io_ps2_obj_popleft(mp_obj_t self_in) {
}
MP_DEFINE_CONST_FUN_OBJ_1(ps2io_ps2_popleft_obj, ps2io_ps2_obj_popleft);
-//| def sendcmd(self, byte: int) -> Any:
+//| def sendcmd(self, byte: int) -> int:
//| """Sends a command byte to PS/2. Returns the response byte, typically
//| the general ack value (0xFA). Some commands return additional data
//| which is available through :py:func:`popleft()`.
@@ -164,7 +164,7 @@ STATIC mp_obj_t ps2io_ps2_obj_sendcmd(mp_obj_t self_in, mp_obj_t ob) {
}
MP_DEFINE_CONST_FUN_OBJ_2(ps2io_ps2_sendcmd_obj, ps2io_ps2_obj_sendcmd);
-//| def clear_errors(self, ) -> Any:
+//| def clear_errors(self) -> None:
//| """Returns and clears a bitmap with latest recorded communication errors.
//|
//| Reception errors (arise asynchronously, as data is received):
@@ -202,7 +202,9 @@ STATIC mp_obj_t ps2io_ps2_obj_clear_errors(mp_obj_t self_in) {
}
MP_DEFINE_CONST_FUN_OBJ_1(ps2io_ps2_clear_errors_obj, ps2io_ps2_obj_clear_errors);
-//| def __len__(self, ) -> Any:
+//| def __bool__(self) -> bool: ...
+//|
+//| def __len__(self) -> int:
//| """Returns the number of received bytes in buffer, available
//| to :py:func:`popleft()`."""
//| ...
diff --git a/shared-bindings/pulseio/PWMOut.c b/shared-bindings/pulseio/PWMOut.c
index a51789053..07b47c133 100644
--- a/shared-bindings/pulseio/PWMOut.c
+++ b/shared-bindings/pulseio/PWMOut.c
@@ -38,7 +38,7 @@
//| class PWMOut:
//| """Output a Pulse Width Modulated signal on a given pin."""
//|
-//| def __init__(self, pin: microcontroller.Pin, *, duty_cycle: int = 0, frequency: int = 500, variable_frequency: bool = False):
+//| def __init__(self, pin: microcontroller.Pin, *, duty_cycle: int = 0, frequency: int = 500, variable_frequency: bool = False) -> None:
//| """Create a PWM object associated with the given pin. This allows you to
//| write PWM signals out on the given pin. Frequency is fixed after init
//| unless ``variable_frequency`` is True.
@@ -115,7 +115,7 @@ STATIC mp_obj_t pulseio_pwmout_make_new(const mp_obj_type_t *type, size_t n_args
return MP_OBJ_FROM_PTR(self);
}
-//| def deinit(self, ) -> Any:
+//| def deinit(self) -> None:
//| """Deinitialises the PWMOut and releases any hardware resources for reuse."""
//| ...
//|
@@ -132,13 +132,13 @@ STATIC void check_for_deinit(pulseio_pwmout_obj_t *self) {
}
}
-//| def __enter__(self, ) -> Any:
+//| def __enter__(self) -> PWMOut:
//| """No-op used by Context Managers."""
//| ...
//|
// Provided by context manager helper.
-//| def __exit__(self, ) -> Any:
+//| def __exit__(self) -> None:
//| """Automatically deinitializes the hardware when exiting a context. See
//| :ref:`lifetime-and-contextmanagers` for more info."""
//| ...
@@ -150,7 +150,7 @@ STATIC mp_obj_t pulseio_pwmout_obj___exit__(size_t n_args, const mp_obj_t *args)
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pulseio_pwmout___exit___obj, 4, 4, pulseio_pwmout_obj___exit__);
-//| duty_cycle: Any = ...
+//| duty_cycle: int = ...
//| """16 bit value that dictates how much of one cycle is high (1) versus low
//| (0). 0xffff will always be high, 0 will always be low and 0x7fff will
//| be half high and then half low.
@@ -186,7 +186,7 @@ const mp_obj_property_t pulseio_pwmout_duty_cycle_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| frequency: Any = ...
+//| frequency: int = ...
//| """32 bit value that dictates the PWM frequency in Hertz (cycles per
//| second). Only writeable when constructed with ``variable_frequency=True``.
//|
diff --git a/shared-bindings/pulseio/PulseIn.c b/shared-bindings/pulseio/PulseIn.c
index 5c52b2582..4bcff06ee 100644
--- a/shared-bindings/pulseio/PulseIn.c
+++ b/shared-bindings/pulseio/PulseIn.c
@@ -40,7 +40,7 @@
//| and low cost temperature sensors (DHT). The pulsed signal consists of timed active and
//| idle periods. Unlike PWM, there is no set duration for active and idle pairs."""
//|
-//| def __init__(self, pin: microcontroller.Pin, maxlen: int = 2, *, idle_state: bool = False):
+//| def __init__(self, pin: microcontroller.Pin, maxlen: int = 2, *, idle_state: bool = False) -> None:
//| """Create a PulseIn object associated with the given pin. The object acts as
//| a read-only sequence of pulse lengths with a given max length. When it is
//| active, new pulse lengths are added to the end of the list. When there is
@@ -96,7 +96,7 @@ STATIC mp_obj_t pulseio_pulsein_make_new(const mp_obj_type_t *type, size_t n_arg
return MP_OBJ_FROM_PTR(self);
}
-//| def deinit(self, ) -> Any:
+//| def deinit(self) -> None:
//| """Deinitialises the PulseIn and releases any hardware resources for reuse."""
//| ...
//|
@@ -113,13 +113,13 @@ STATIC void check_for_deinit(pulseio_pulsein_obj_t *self) {
}
}
-//| def __enter__(self, ) -> Any:
+//| def __enter__(self) -> PulseIn:
//| """No-op used by Context Managers."""
//| ...
//|
// Provided by context manager helper.
-//| def __exit__(self, ) -> Any:
+//| def __exit__(self) -> None:
//| """Automatically deinitializes the hardware when exiting a context. See
//| :ref:`lifetime-and-contextmanagers` for more info."""
//| ...
@@ -131,7 +131,7 @@ STATIC mp_obj_t pulseio_pulsein_obj___exit__(size_t n_args, const mp_obj_t *args
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pulseio_pulsein___exit___obj, 4, 4, pulseio_pulsein_obj___exit__);
-//| def pause(self, ) -> Any:
+//| def pause(self) -> None:
//| """Pause pulse capture"""
//| ...
//|
@@ -144,7 +144,7 @@ STATIC mp_obj_t pulseio_pulsein_obj_pause(mp_obj_t self_in) {
}
MP_DEFINE_CONST_FUN_OBJ_1(pulseio_pulsein_pause_obj, pulseio_pulsein_obj_pause);
-//| def resume(self, trigger_duration: int = 0) -> Any:
+//| def resume(self, trigger_duration: int = 0) -> None:
//| """Resumes pulse capture after an optional trigger pulse.
//|
//| .. warning:: Using trigger pulse with a device that drives both high and
@@ -171,7 +171,7 @@ STATIC mp_obj_t pulseio_pulsein_obj_resume(size_t n_args, const mp_obj_t *pos_ar
}
MP_DEFINE_CONST_FUN_OBJ_KW(pulseio_pulsein_resume_obj, 1, pulseio_pulsein_obj_resume);
-//| def clear(self, ) -> Any:
+//| def clear(self) -> None:
//| """Clears all captured pulses"""
//| ...
//|
@@ -184,7 +184,7 @@ STATIC mp_obj_t pulseio_pulsein_obj_clear(mp_obj_t self_in) {
}
MP_DEFINE_CONST_FUN_OBJ_1(pulseio_pulsein_clear_obj, pulseio_pulsein_obj_clear);
-//| def popleft(self, ) -> Any:
+//| def popleft(self) -> int:
//| """Removes and returns the oldest read pulse."""
//| ...
//|
@@ -196,7 +196,7 @@ STATIC mp_obj_t pulseio_pulsein_obj_popleft(mp_obj_t self_in) {
}
MP_DEFINE_CONST_FUN_OBJ_1(pulseio_pulsein_popleft_obj, pulseio_pulsein_obj_popleft);
-//| maxlen: Any = ...
+//| maxlen: int = ...
//| """The maximum length of the PulseIn. When len() is equal to maxlen,
//| it is unclear which pulses are active and which are idle."""
//|
@@ -215,7 +215,7 @@ const mp_obj_property_t pulseio_pulsein_maxlen_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| paused: Any = ...
+//| paused: bool = ...
//| """True when pulse capture is paused as a result of :py:func:`pause` or an error during capture
//| such as a signal that is too fast."""
//|
@@ -234,7 +234,9 @@ const mp_obj_property_t pulseio_pulsein_paused_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| def __len__(self, ) -> Any:
+//| def __bool__(self) -> bool: ...
+//|
+//| def __len__(self) -> int:
//| """Returns the current pulse length
//|
//| This allows you to::
@@ -254,7 +256,7 @@ STATIC mp_obj_t pulsein_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
}
}
-//| def __getitem__(self, index: Any) -> Any:
+//| def __getitem__(self, index: int) -> Optional[int]:
//| """Returns the value at the given index or values in slice.
//|
//| This allows you to::
diff --git a/shared-bindings/pulseio/PulseOut.c b/shared-bindings/pulseio/PulseOut.c
index 16b0a6f0c..9e2d68744 100644
--- a/shared-bindings/pulseio/PulseOut.c
+++ b/shared-bindings/pulseio/PulseOut.c
@@ -41,7 +41,7 @@
//| pulsed signal consists of timed on and off periods. Unlike PWM, there is no set duration
//| for on and off pairs."""
//|
-//| def __init__(self, carrier: pulseio.PWMOut):
+//| def __init__(self, carrier: pulseio.PWMOut) -> None:
//| """Create a PulseOut object associated with the given PWMout object.
//|
//| :param ~pulseio.PWMOut carrier: PWMOut that is set to output on the desired pin.
@@ -81,7 +81,7 @@ STATIC mp_obj_t pulseio_pulseout_make_new(const mp_obj_type_t *type, size_t n_ar
return MP_OBJ_FROM_PTR(self);
}
-//| def deinit(self, ) -> Any:
+//| def deinit(self) -> None:
//| """Deinitialises the PulseOut and releases any hardware resources for reuse."""
//| ...
//|
@@ -92,13 +92,13 @@ STATIC mp_obj_t pulseio_pulseout_deinit(mp_obj_t self_in) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(pulseio_pulseout_deinit_obj, pulseio_pulseout_deinit);
-//| def __enter__(self, ) -> Any:
+//| def __enter__(self) -> PulseOut:
//| """No-op used by Context Managers."""
//| ...
//|
// Provided by context manager helper.
-//| def __exit__(self, ) -> Any:
+//| def __exit__(self) -> None:
//| """Automatically deinitializes the hardware when exiting a context. See
//| :ref:`lifetime-and-contextmanagers` for more info."""
//| ...
@@ -110,7 +110,7 @@ STATIC mp_obj_t pulseio_pulseout_obj___exit__(size_t n_args, const mp_obj_t *arg
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pulseio_pulseout___exit___obj, 4, 4, pulseio_pulseout_obj___exit__);
-//| def send(self, pulses: array.array) -> Any:
+//| def send(self, pulses: array.array) -> None:
//| """Pulse alternating on and off durations in microseconds starting with on.
//| ``pulses`` must be an `array.array` with data type 'H' for unsigned
//| halfword (two bytes).
diff --git a/shared-bindings/random/__init__.c b/shared-bindings/random/__init__.c
index c0124df41..10ddca499 100644
--- a/shared-bindings/random/__init__.c
+++ b/shared-bindings/random/__init__.c
@@ -47,7 +47,7 @@
//| bytes from `os.urandom` directly for true randomness."""
//|
-//| def seed(seed: Any) -> Any:
+//| def seed(seed: int) -> None:
//| """Sets the starting seed of the random number generation. Further calls to
//| `random` will return deterministic results afterwards."""
//| ...
@@ -59,7 +59,7 @@ STATIC mp_obj_t random_seed(mp_obj_t seed_in) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(random_seed_obj, random_seed);
-//| def getrandbits(k: Any) -> Any:
+//| def getrandbits(k: int) -> int:
//| """Returns an integer with *k* random bits."""
//| ...
//|
@@ -72,7 +72,7 @@ STATIC mp_obj_t random_getrandbits(mp_obj_t num_in) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(random_getrandbits_obj, random_getrandbits);
-//| def randrange(stop: Any) -> Any:
+//| def randrange(stop: Tuple[int, int, int]) -> int:
//| """Returns a randomly selected integer from ``range(start, stop, step)``."""
//| ...
//|
@@ -114,7 +114,7 @@ STATIC mp_obj_t random_randrange(size_t n_args, const mp_obj_t *args) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(random_randrange_obj, 1, 3, random_randrange);
-//| def randint(a: Any, b: Any) -> Any:
+//| def randint(a: int, b: int) -> int:
//| """Returns a randomly selected integer between a and b inclusive. Equivalent
//| to ``randrange(a, b + 1, 1)``"""
//| ...
@@ -129,7 +129,7 @@ STATIC mp_obj_t random_randint(mp_obj_t a_in, mp_obj_t b_in) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(random_randint_obj, random_randint);
-//| def choice(seq: Any) -> Any:
+//| def choice(seq: list) -> Any:
//| """Returns a randomly selected element from the given sequence. Raises
//| IndexError when the sequence is empty."""
//| ...
@@ -143,7 +143,7 @@ STATIC mp_obj_t random_choice(mp_obj_t seq) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(random_choice_obj, random_choice);
-//| def random() -> Any:
+//| def random() -> float:
//| """Returns a random float between 0 and 1.0."""
//| ...
//|
@@ -152,7 +152,7 @@ STATIC mp_obj_t random_random(void) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_0(random_random_obj, random_random);
-//| def uniform(a: Any, b: Any) -> Any:
+//| def uniform(a: float, b: float) -> float:
//| """Returns a random float between a and b. It may or may not be inclusive
//| depending on float rounding."""
//| ...
diff --git a/shared-bindings/rgbmatrix/RGBMatrix.c b/shared-bindings/rgbmatrix/RGBMatrix.c
index c833faa6e..e04336351 100644
--- a/shared-bindings/rgbmatrix/RGBMatrix.c
+++ b/shared-bindings/rgbmatrix/RGBMatrix.c
@@ -128,7 +128,7 @@ STATIC void preflight_pins_or_throw(uint8_t clock_pin, uint8_t *rgb_pins, uint8_
}
}
-//| def __init__(self, *, width: Any, bit_depth: Any, rgb_pins: Any, addr_pins: Any, clock_pin: Any, latch_pin: Any, output_enable_pin: Any, doublebuffer: Any = True, framebuffer: Any = None, height: Any = 0):
+//| def __init__(self, *, width: int, bit_depth: List[digitalio.DigitalInOut], rgb_pins: List[digitalio.DigitalInOut], addr_pins: List[digitalio.DigitalInOut], clock_pin: digitalio.DigitalInOut, latch_pin: digitalio.DigitalInOut, output_enable_pin: digitalio.DigitalInOut, doublebuffer: bool = True, framebuffer: Optional[WriteableBuffer] = None, height: int = 0) -> None:
//| """Create a RGBMatrix object with the given attributes. The height of
//| the display is determined by the number of rgb and address pins:
//| len(rgb_pins) // 3 * 2 ** len(address_pins). With 6 RGB pins and 4
@@ -237,7 +237,7 @@ STATIC mp_obj_t rgbmatrix_rgbmatrix_make_new(const mp_obj_type_t *type, size_t n
return MP_OBJ_FROM_PTR(self);
}
-//| def deinit(self, ) -> Any:
+//| def deinit(self) -> None:
//| """Free the resources (pins, timers, etc.) associated with this
//| rgbmatrix instance. After deinitialization, no further operations
//| may be performed."""
@@ -257,7 +257,7 @@ static void check_for_deinit(rgbmatrix_rgbmatrix_obj_t *self) {
}
}
-//| brightness: Any = ...
+//| brightness: float = ...
//| """In the current implementation, 0.0 turns the display off entirely
//| and any other value up to 1.0 turns the display on fully."""
//|
@@ -288,9 +288,10 @@ const mp_obj_property_t rgbmatrix_rgbmatrix_brightness_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| def refresh(self) -> Any: ...
-//| """Transmits the color data in the buffer to the pixels so that
-//| they are shown."""
+//| def refresh(self) -> None:
+//| """Transmits the color data in the buffer to the pixels so that
+//| they are shown."""
+//| ...
//|
STATIC mp_obj_t rgbmatrix_rgbmatrix_refresh(mp_obj_t self_in) {
rgbmatrix_rgbmatrix_obj_t *self = (rgbmatrix_rgbmatrix_obj_t*)self_in;
diff --git a/shared-bindings/rotaryio/IncrementalEncoder.c b/shared-bindings/rotaryio/IncrementalEncoder.c
index 8b2723866..37c4ee324 100644
--- a/shared-bindings/rotaryio/IncrementalEncoder.c
+++ b/shared-bindings/rotaryio/IncrementalEncoder.c
@@ -37,7 +37,7 @@
//| class IncrementalEncoder:
//| """IncrementalEncoder determines the relative rotational position based on two series of pulses."""
//|
-//| def __init__(self, pin_a: microcontroller.Pin, pin_b: microcontroller.Pin):
+//| def __init__(self, pin_a: microcontroller.Pin, pin_b: microcontroller.Pin) -> None:
//| """Create an IncrementalEncoder object associated with the given pins. It tracks the positional
//| state of an incremental rotary encoder (also known as a quadrature encoder.) Position is
//| relative to the position when the object is contructed.
@@ -80,7 +80,7 @@ STATIC mp_obj_t rotaryio_incrementalencoder_make_new(const mp_obj_type_t *type,
return MP_OBJ_FROM_PTR(self);
}
-//| def deinit(self, ) -> Any:
+//| def deinit(self) -> None:
//| """Deinitializes the IncrementalEncoder and releases any hardware resources for reuse."""
//| ...
//|
@@ -97,13 +97,13 @@ STATIC void check_for_deinit(rotaryio_incrementalencoder_obj_t *self) {
}
}
-//| def __enter__(self, ) -> Any:
+//| def __enter__(self) -> IncrementalEncoder:
//| """No-op used by Context Managers."""
//| ...
//|
// Provided by context manager helper.
-//| def __exit__(self, ) -> Any:
+//| def __exit__(self) -> None:
//| """Automatically deinitializes the hardware when exiting a context. See
//| :ref:`lifetime-and-contextmanagers` for more info."""
//| ...
@@ -116,7 +116,7 @@ STATIC mp_obj_t rotaryio_incrementalencoder_obj___exit__(size_t n_args, const mp
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(rotaryio_incrementalencoder___exit___obj, 4, 4, rotaryio_incrementalencoder_obj___exit__);
-//| position: Any = ...
+//| position: int = ...
//| """The current position in terms of pulses. The number of pulses per rotation is defined by the
//| specific hardware."""
//|
diff --git a/shared-bindings/rtc/RTC.c b/shared-bindings/rtc/RTC.c
index 7debb70c1..5af1f4267 100644
--- a/shared-bindings/rtc/RTC.c
+++ b/shared-bindings/rtc/RTC.c
@@ -41,7 +41,7 @@ const rtc_rtc_obj_t rtc_rtc_obj = {{&rtc_rtc_type}};
//| class RTC:
//| """Real Time Clock"""
//|
-//| def __init__(self, ):
+//| def __init__(self) -> None:
//| """This class represents the onboard Real Time Clock. It is a singleton and will always return the same instance."""
//| ...
//|
diff --git a/shared-bindings/rtc/__init__.c b/shared-bindings/rtc/__init__.c
index 9f8d37fdd..baa9c95e1 100644
--- a/shared-bindings/rtc/__init__.c
+++ b/shared-bindings/rtc/__init__.c
@@ -50,7 +50,7 @@ mp_obj_t rtc_get_time_source_time(void) {
return struct_time_from_tm(&tm);
}
-//| def set_time_source(rtc: Any) -> Any:
+//| def set_time_source(rtc: RTC) -> None:
//| """Sets the RTC time source used by :func:`time.localtime`.
//| The default is :class:`rtc.RTC`, but it's useful to use this to override the
//| time source for testing purposes. For example::
diff --git a/shared-bindings/sdcardio/SDCard.c b/shared-bindings/sdcardio/SDCard.c
index 1d8c4bafb..7f53f741d 100644
--- a/shared-bindings/sdcardio/SDCard.c
+++ b/shared-bindings/sdcardio/SDCard.c
@@ -44,7 +44,7 @@
//| `busio.SPI`, not `bitbangio.SPI`. Usually an SDCard object is used
//| with ``storage.VfsFat`` to allow file I/O to an SD card."""
//|
-//| def __init__(bus:busio.SPI, cs=digitalio.DigitalInOut, baudrate=8000000):
+//| def __init__(bus:busio.SPI, cs: digitalio.DigitalInOut=digitalio.DigitalInOut, baudrate: int=8000000) -> None:
//| """Construct an SPI SD Card object with the given properties
//|
//| :param busio.SPI spi: The SPI bus
diff --git a/shared-bindings/sdioio/SDCard.c b/shared-bindings/sdioio/SDCard.c
index 77b41ce12..94ba1c387 100644
--- a/shared-bindings/sdioio/SDCard.c
+++ b/shared-bindings/sdioio/SDCard.c
@@ -49,7 +49,7 @@
//| 25MHz. Usually an SDCard object is used with ``storage.VfsFat``
//| to allow file I/O to an SD card."""
//|
-//| def __init__(*, clock: digitalio.DigitalInOut, command: digitalio.DigitalInOut, data: List[digitalio.DigitalInOut], frequency: int):
+//| def __init__(*, clock: digitalio.DigitalInOut, command: digitalio.DigitalInOut, data: List[digitalio.DigitalInOut], frequency: int) -> None:
//| """Construct an SDIO SD Card object with the given properties
//|
//| :param ~microcontroller.Pin clock: the pin to use for the clock.
@@ -109,7 +109,7 @@ STATIC void check_for_deinit(sdioio_sdcard_obj_t *self) {
}
}
-//| def configure(*, frequency=0, width=0) -> None:
+//| def configure(*, frequency: int=0, width: int=0) -> None:
//| """Configures the SDIO bus.
//|
//| :param int frequency: the desired clock rate in Hertz. The actual clock rate may be higher or lower due to the granularity of available clock settings. Check the `frequency` attribute for the actual clock rate.
@@ -255,13 +255,13 @@ STATIC mp_obj_t sdioio_sdcard_obj_deinit(mp_obj_t self_in) {
}
MP_DEFINE_CONST_FUN_OBJ_1(sdioio_sdcard_deinit_obj, sdioio_sdcard_obj_deinit);
-//| def __enter__(self, ) -> Any:
+//| def __enter__(self) -> SDCard:
//| """No-op used by Context Managers.
//| Provided by context manager helper."""
//| ...
//|
-//| def __exit__(self, ) -> Any:
+//| def __exit__(self) -> None:
//| """Automatically deinitializes the hardware when exiting a context. See
//| :ref:`lifetime-and-contextmanagers` for more info."""
//| ...
diff --git a/shared-bindings/socket/__init__.c b/shared-bindings/socket/__init__.c
index 2485d8ef8..a2007edf6 100644
--- a/shared-bindings/socket/__init__.c
+++ b/shared-bindings/socket/__init__.c
@@ -49,7 +49,7 @@ STATIC const mp_obj_type_t socket_type;
//| class socket:
//|
-//| def __init__(self, family: int, type: int, proto: int):
+//| def __init__(self, family: int, type: int, proto: int) -> None:
//| """Create a new socket
//|
//| :param ~int family: AF_INET or AF_INET6
@@ -96,7 +96,7 @@ STATIC void socket_select_nic(mod_network_socket_obj_t *self, const byte *ip) {
}
}
-//| def bind(self, address: tuple) -> Any:
+//| def bind(self, address: tuple) -> None:
//| """Bind a socket to an address
//|
//| :param ~tuple address: tuple of (remote_address, remote_port)"""
@@ -123,7 +123,7 @@ STATIC mp_obj_t socket_bind(mp_obj_t self_in, mp_obj_t addr_in) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(socket_bind_obj, socket_bind);
-//| def listen(self, backlog: int) -> Any:
+//| def listen(self, backlog: int) -> None:
//| """Set socket to listen for incoming connections
//|
//| :param ~int backlog: length of backlog queue for waiting connetions"""
@@ -148,7 +148,7 @@ STATIC mp_obj_t socket_listen(mp_obj_t self_in, mp_obj_t backlog) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(socket_listen_obj, socket_listen);
-//| def accept(self, ) -> Any:
+//| def accept(self) -> tuple:
//| """Accept a connection on a listening socket of type SOCK_STREAM,
//| creating a new socket of type SOCK_STREAM.
//| Returns a tuple of (new_socket, remote_address)"""
@@ -185,7 +185,7 @@ STATIC mp_obj_t socket_accept(mp_obj_t self_in) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(socket_accept_obj, socket_accept);
-//| def connect(self, address: tuple) -> Any:
+//| def connect(self, address: tuple) -> None:
//| """Connect a socket to a remote address
//|
//| :param ~tuple address: tuple of (remote_address, remote_port)"""
@@ -212,7 +212,7 @@ STATIC mp_obj_t socket_connect(mp_obj_t self_in, mp_obj_t addr_in) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(socket_connect_obj, socket_connect);
-//| def send(self, bytes: bytes) -> Any:
+//| def send(self, bytes: bytes) -> int:
//| """Send some bytes to the connected remote address.
//| Suits sockets of type SOCK_STREAM
//|
@@ -249,7 +249,7 @@ STATIC mp_int_t _socket_recv_into(mod_network_socket_obj_t *sock, byte *buf, mp_
}
-//| def recv_into(self, buffer: bytearray, bufsize: int) -> Any:
+//| def recv_into(self, buffer: WriteableBuffer, bufsize: int) -> int:
//| """Reads some bytes from the connected remote address, writing
//| into the provided buffer. If bufsize <= len(buffer) is given,
//| a maximum of bufsize bytes will be read into the buffer. If no
@@ -285,7 +285,7 @@ STATIC mp_obj_t socket_recv_into(size_t n_args, const mp_obj_t *args) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(socket_recv_into_obj, 2, 3, socket_recv_into);
-//| def recv(self, bufsize: int) -> Any:
+//| def recv(self, bufsize: int) -> bytes:
//| """Reads some bytes from the connected remote address.
//| Suits sockets of type SOCK_STREAM
//| Returns a bytes() of length <= bufsize
@@ -312,7 +312,7 @@ STATIC mp_obj_t socket_recv(mp_obj_t self_in, mp_obj_t len_in) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(socket_recv_obj, socket_recv);
-//| def sendto(self, bytes: bytes, address: tuple) -> Any:
+//| def sendto(self, bytes: bytes, address: tuple) -> int:
//| """Send some bytes to a specific address.
//| Suits sockets of type SOCK_DGRAM
//|
@@ -346,7 +346,7 @@ STATIC mp_obj_t socket_sendto(mp_obj_t self_in, mp_obj_t data_in, mp_obj_t addr_
}
STATIC MP_DEFINE_CONST_FUN_OBJ_3(socket_sendto_obj, socket_sendto);
-//| def recvfrom(self, bufsize: int) -> Any:
+//| def recvfrom(self, bufsize: int) -> Tuple[bytes, tuple]:
//| """Reads some bytes from the connected remote address.
//| Suits sockets of type SOCK_STREAM
//|
@@ -385,7 +385,7 @@ STATIC mp_obj_t socket_recvfrom(mp_obj_t self_in, mp_obj_t len_in) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(socket_recvfrom_obj, socket_recvfrom);
-//| def setsockopt(self, level: Any, optname: Any, value: Any) -> Any:
+//| def setsockopt(self, level: int, optname: int, value: int) -> None:
//| """Sets socket options"""
//| ...
//|
@@ -419,7 +419,7 @@ STATIC mp_obj_t socket_setsockopt(size_t n_args, const mp_obj_t *args) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(socket_setsockopt_obj, 4, 4, socket_setsockopt);
-//| def settimeout(self, value: int) -> Any:
+//| def settimeout(self, value: int) -> None:
//| """Set the timeout value for this socket.
//|
//| :param ~int value: timeout in seconds. 0 means non-blocking. None means block indefinitely."""
@@ -450,7 +450,7 @@ STATIC mp_obj_t socket_settimeout(mp_obj_t self_in, mp_obj_t timeout_in) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(socket_settimeout_obj, socket_settimeout);
-//| def setblocking(self, flag: bool) -> Any:
+//| def setblocking(self, flag: bool) -> Optional[int]:
//| """Set the blocking behaviour of this socket.
//|
//| :param ~bool flag: False means non-blocking, True means block indefinitely."""
@@ -512,7 +512,7 @@ STATIC const mp_obj_type_t socket_type = {
.locals_dict = (mp_obj_dict_t*)&socket_locals_dict,
};
-//| def getaddrinfo(host: Any, port: Any) -> Any:
+//| def getaddrinfo(host: string, port: string) -> tuple:
//| """Gets the address information for a hostname and port
//|
//| Returns the appropriate family, socket type, socket protocol and
diff --git a/shared-bindings/storage/__init__.c b/shared-bindings/storage/__init__.c
index 725329ad5..2defdbb62 100644
--- a/shared-bindings/storage/__init__.c
+++ b/shared-bindings/storage/__init__.c
@@ -43,7 +43,7 @@
//| directly."""
//|
-//| def mount(filesystem: Any, mount_path: Any, *, readonly: bool = False) -> Any:
+//| def mount(filesystem: VfsFat, mount_path: string, *, readonly: bool = False) -> None:
//| """Mounts the given filesystem object at the given path.
//|
//| This is the CircuitPython analog to the UNIX ``mount`` command.
@@ -80,7 +80,7 @@ mp_obj_t storage_mount(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_arg
}
MP_DEFINE_CONST_FUN_OBJ_KW(storage_mount_obj, 2, storage_mount);
-//| def umount(mount: Any) -> Any:
+//| def umount(mount: Union[string, VfsFat]) -> None:
//| """Unmounts the given filesystem object or if *mount* is a path, then unmount
//| the filesystem mounted at that location.
//|
@@ -98,7 +98,7 @@ mp_obj_t storage_umount(mp_obj_t mnt_in) {
}
MP_DEFINE_CONST_FUN_OBJ_1(storage_umount_obj, storage_umount);
-//| def remount(mount_path: Any, readonly: bool = False, *, disable_concurrent_write_protection: bool = False) -> Any:
+//| def remount(mount_path: string, readonly: bool = False, *, disable_concurrent_write_protection: bool = False) -> None:
//| """Remounts the given path with new parameters.
//|
//| :param bool readonly: True when the filesystem should be readonly to CircuitPython.
@@ -128,7 +128,7 @@ mp_obj_t storage_remount(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_a
}
MP_DEFINE_CONST_FUN_OBJ_KW(storage_remount_obj, 1, storage_remount);
-//| def getmount(mount_path: Any) -> Any:
+//| def getmount(mount_path: string) -> VfsFat:
//| """Retrieves the mount object associated with the mount path"""
//| ...
//|
@@ -137,7 +137,7 @@ mp_obj_t storage_getmount(const mp_obj_t mnt_in) {
}
MP_DEFINE_CONST_FUN_OBJ_1(storage_getmount_obj, storage_getmount);
-//| def erase_filesystem() -> Any:
+//| def erase_filesystem() -> None:
//| """Erase and re-create the ``CIRCUITPY`` filesystem.
//|
//| On boards that present USB-visible ``CIRCUITPY`` drive (e.g., SAMD21 and SAMD51),
@@ -168,51 +168,51 @@ STATIC const mp_rom_map_elem_t storage_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR_erase_filesystem), MP_ROM_PTR(&storage_erase_filesystem_obj) },
//| class VfsFat:
-//| def __init__(self, block_device: Any):
+//| def __init__(self, block_device: string) -> None:
//| """Create a new VfsFat filesystem around the given block device.
//|
//| :param block_device: Block device the the filesystem lives on"""
//|
-//| label: Any = ...
+//| label: string = ...
//| """The filesystem label, up to 11 case-insensitive bytes. Note that
//| this property can only be set when the device is writable by the
//| microcontroller."""
//| ...
//|
-//| def mkfs(self) -> Any:
+//| def mkfs(self) -> None:
//| """Format the block device, deleting any data that may have been there"""
//| ...
//|
-//| def open(self, path: Any, mode: Any) -> Any:
+//| def open(self, path: string, mode: string) -> None:
//| """Like builtin ``open()``"""
//| ...
//|
-//| def ilistdir(self, path: Any) -> Any:
+//| def ilistdir(self, path: string) -> iterator:
//| """Return an iterator whose values describe files and folders within
//| ``path``"""
//| ...
//|
-//| def mkdir(self, path: Any) -> Any:
+//| def mkdir(self, path: string) -> None:
//| """Like `os.mkdir`"""
//| ...
//|
-//| def rmdir(self, path: Any) -> Any:
+//| def rmdir(self, path: string) -> None:
//| """Like `os.rmdir`"""
//| ...
//|
-//| def stat(self, path: Any) -> Any:
+//| def stat(self, path: string) -> string:
//| """Like `os.stat`"""
//| ...
//|
-//| def statvfs(self, path: Any) -> Any:
+//| def statvfs(self, path: string) -> Tuple[string, string, string, string, string, string, string, string, string, string]:
//| """Like `os.statvfs`"""
//| ...
//|
-//| def mount(self, readonly: Any, mkfs: Any) -> Any:
+//| def mount(self, readonly: bool, mkfs: VfsFat) -> None:
//| """Don't call this directly, call `storage.mount`."""
//| ...
//|
-//| def umount(self) -> Any:
+//| def umount(self) -> None:
//| """Don't call this directly, call `storage.umount`."""
//| ...
//|
diff --git a/shared-bindings/struct/__init__.c b/shared-bindings/struct/__init__.c
index 26c0ff3af..de357dde4 100644
--- a/shared-bindings/struct/__init__.c
+++ b/shared-bindings/struct/__init__.c
@@ -62,7 +62,7 @@ STATIC mp_obj_t struct_calcsize(mp_obj_t fmt_in) {
}
MP_DEFINE_CONST_FUN_OBJ_1(struct_calcsize_obj, struct_calcsize);
-//| def pack(fmt: Any, *values: Any) -> Any:
+//| def pack(fmt: string, *values: ReadableBuffer) -> bytes:
//| """Pack the values according to the format string fmt.
//| The return value is a bytes object encoding the values."""
//| ...
@@ -80,7 +80,7 @@ STATIC mp_obj_t struct_pack(size_t n_args, const mp_obj_t *args) {
}
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(struct_pack_obj, 1, MP_OBJ_FUN_ARGS_MAX, struct_pack);
-//| def pack_into(fmt: Any, buffer: Any, offset: Any, *values: Any) -> Any:
+//| def pack_into(fmt: string, buffer: WriteableBuffer, offset: int, *values: readableBuffer) -> None:
//| """Pack the values according to the format string fmt into a buffer
//| starting at offset. offset may be negative to count from the end of buffer."""
//| ...
@@ -106,7 +106,7 @@ STATIC mp_obj_t struct_pack_into(size_t n_args, const mp_obj_t *args) {
}
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(struct_pack_into_obj, 3, MP_OBJ_FUN_ARGS_MAX, struct_pack_into);
-//| def unpack(fmt: Any, data: Any) -> Any:
+//| def unpack(fmt: string, data: ReadableBuffer) -> tuple:
//| """Unpack from the data according to the format string fmt. The return value
//| is a tuple of the unpacked values. The buffer size must match the size
//| required by the format."""
@@ -124,7 +124,7 @@ STATIC mp_obj_t struct_unpack(size_t n_args, const mp_obj_t *args) {
}
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(struct_unpack_obj, 2, 3, struct_unpack);
-//| def unpack_from(fmt: Any, data: Any, offset: Any = 0) -> Any:
+//| def unpack_from(fmt: string, data: ReadableBuffer, offset: int = 0) -> tuple:
//| """Unpack from the data starting at offset according to the format string fmt.
//| offset may be negative to count from the end of buffer. The return value is
//| a tuple of the unpacked values. The buffer size must be at least as big
diff --git a/shared-bindings/supervisor/Runtime.c b/shared-bindings/supervisor/Runtime.c
index a420d5b80..689c299ef 100755
--- a/shared-bindings/supervisor/Runtime.c
+++ b/shared-bindings/supervisor/Runtime.c
@@ -39,7 +39,7 @@
//| print("Hello World!")"""
//|
-//| def __init__(self, ):
+//| def __init__(self) -> None:
//| """You cannot create an instance of `supervisor.Runtime`.
//| Use `supervisor.runtime` to access the sole instance available."""
//| ...
diff --git a/shared-bindings/supervisor/Runtime.h b/shared-bindings/supervisor/Runtime.h
index 864b070cd..2dc59c3ab 100755
--- a/shared-bindings/supervisor/Runtime.h
+++ b/shared-bindings/supervisor/Runtime.h
@@ -31,7 +31,7 @@
#include "py/obj.h"
-const mp_obj_type_t supervisor_runtime_type;
+extern const mp_obj_type_t supervisor_runtime_type;
bool common_hal_get_serial_connected(void);
diff --git a/shared-bindings/terminalio/Terminal.c b/shared-bindings/terminalio/Terminal.c
index 5c045fdee..623b99e09 100644
--- a/shared-bindings/terminalio/Terminal.c
+++ b/shared-bindings/terminalio/Terminal.c
@@ -40,7 +40,7 @@
//| class Terminal:
//| """Display a character stream with a TileGrid"""
//|
-//| def __init__(self, tilegrid: Any, font: Any):
+//| def __init__(self, tilegrid: bitmap, font: fontio.BuiltinFont) -> None:
//| """Terminal manages tile indices and cursor position based on VT100 commands. The font should be
//| a `fontio.BuiltinFont` and the TileGrid's bitmap should match the font's bitmap."""
//| ...
@@ -72,7 +72,7 @@ STATIC mp_obj_t terminalio_terminal_make_new(const mp_obj_type_t *type, size_t n
// These are standard stream methods. Code is in py/stream.c.
//
-//| def write(self, buf: Any) -> Any:
+//| def write(self, buf: ReadableBuffer) -> Optional[int]:
//| """Write the buffer of bytes to the bus.
//|
//| :return: the number of bytes written
diff --git a/shared-bindings/time/__init__.c b/shared-bindings/time/__init__.c
index ae978a497..262da17fd 100644
--- a/shared-bindings/time/__init__.c
+++ b/shared-bindings/time/__init__.c
@@ -42,7 +42,7 @@
//| written in MicroPython will work in CPython but not necessarily the other
//| way around."""
//|
-//| def monotonic() -> Any:
+//| 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`.
//|
@@ -57,7 +57,7 @@ STATIC mp_obj_t time_monotonic(void) {
}
MP_DEFINE_CONST_FUN_OBJ_0(time_monotonic_obj, time_monotonic);
-//| def sleep(seconds: float) -> Any:
+//| def sleep(seconds: float) -> None:
//| """Sleep for a given number of seconds.
//|
//| :param float seconds: the time to sleep in fractional seconds"""
@@ -93,7 +93,7 @@ mp_obj_t struct_time_make_new(const mp_obj_type_t *type, size_t n_args, const mp
}
//| class struct_time:
-//| def __init__(self, time_tuple: Any):
+//| def __init__(self, time_tuple: tuple) -> None:
//| """Structure used to capture a date and time. Note that it takes a tuple!
//|
//| :param tuple time_tuple: Tuple of time info: ``(tm_year, tm_mon, tm_mday, tm_hour, tm_min, tm_sec, tm_wday, tm_yday, tm_isdst)``
@@ -198,7 +198,7 @@ mp_obj_t MP_WEAK rtc_get_time_source_time(void) {
mp_raise_RuntimeError(translate("RTC is not supported on this board"));
}
-//| def time() -> Any:
+//| def time() -> int:
//| """Return the current time in seconds since since Jan 1, 1970.
//|
//| :return: the current time
@@ -214,7 +214,7 @@ STATIC mp_obj_t time_time(void) {
}
MP_DEFINE_CONST_FUN_OBJ_0(time_time_obj, time_time);
-//| def monotonic_ns() -> Any:
+//| def monotonic_ns() -> int:
//| """Return the time of the specified clock clk_id in nanoseconds.
//|
//| :return: the current time
@@ -227,7 +227,7 @@ STATIC mp_obj_t time_monotonic_ns(void) {
}
MP_DEFINE_CONST_FUN_OBJ_0(time_monotonic_ns_obj, time_monotonic_ns);
-//| def localtime(secs: Any) -> Any:
+//| def localtime(secs: int) -> struct_time:
//| """Convert a time expressed in seconds since Jan 1, 1970 to a struct_time in
//| local time. If secs is not provided or None, the current time as returned
//| by time() is used.
@@ -260,7 +260,7 @@ STATIC mp_obj_t time_localtime(size_t n_args, const mp_obj_t *args) {
}
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(time_localtime_obj, 0, 1, time_localtime);
-//| def mktime(t: Any) -> Any:
+//| def mktime(t: struct_time) -> int:
//| """This is the inverse function of localtime(). Its argument is the
//| struct_time or full 9-tuple (since the dst flag is needed; use -1 as the
//| dst flag if it is unknown) which expresses the time in local time, not UTC.
diff --git a/shared-bindings/touchio/TouchIn.c b/shared-bindings/touchio/TouchIn.c
index 54e5ac4a5..e05490ced 100644
--- a/shared-bindings/touchio/TouchIn.c
+++ b/shared-bindings/touchio/TouchIn.c
@@ -52,7 +52,7 @@
//| print("touched!")"""
//|
-//| def __init__(self, pin: microcontroller.Pin):
+//| def __init__(self, pin: microcontroller.Pin) -> None:
//| """Use the TouchIn on the given pin.
//|
//| :param ~microcontroller.Pin pin: the pin to read from"""
@@ -73,7 +73,7 @@ STATIC mp_obj_t touchio_touchin_make_new(const mp_obj_type_t *type,
return (mp_obj_t) self;
}
-//| def deinit(self, ) -> Any:
+//| def deinit(self) -> None:
//| """Deinitialises the TouchIn and releases any hardware resources for reuse."""
//| ...
//|
@@ -90,13 +90,13 @@ STATIC void check_for_deinit(touchio_touchin_obj_t *self) {
}
}
-//| def __enter__(self, ) -> Any:
+//| def __enter__(self) -> TouchIn:
//| """No-op used by Context Managers."""
//| ...
//|
// Provided by context manager helper.
-//| def __exit__(self, ) -> Any:
+//| def __exit__(self) -> None:
//| """Automatically deinitializes the hardware when exiting a context. See
//| :ref:`lifetime-and-contextmanagers` for more info."""
//| ...
@@ -108,7 +108,7 @@ STATIC mp_obj_t touchio_touchin_obj___exit__(size_t n_args, const mp_obj_t *args
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(touchio_touchin___exit___obj, 4, 4, touchio_touchin_obj___exit__);
-//| value: Any = ...
+//| value: bool = ...
//| """Whether the touch pad is being touched or not. (read-only)
//|
//| True when `raw_value` > `threshold`."""
@@ -128,7 +128,7 @@ const mp_obj_property_t touchio_touchin_value_obj = {
};
-//| raw_value: Any = ...
+//| raw_value: int = ...
//| """The raw touch measurement as an `int`. (read-only)"""
//|
STATIC mp_obj_t touchio_touchin_obj_get_raw_value(mp_obj_t self_in) {
@@ -147,7 +147,7 @@ const mp_obj_property_t touchio_touchin_raw_value_obj = {
};
-//| threshold: Any = ...
+//| threshold: Optional[int] = ...
//| """Minimum `raw_value` needed to detect a touch (and for `value` to be `True`).
//|
//| When the **TouchIn** object is created, an initial `raw_value` is read from the pin,
diff --git a/shared-bindings/uheap/__init__.c b/shared-bindings/uheap/__init__.c
index f089f2922..0559d974a 100644
--- a/shared-bindings/uheap/__init__.c
+++ b/shared-bindings/uheap/__init__.c
@@ -34,7 +34,7 @@
//| """Heap size analysis"""
//|
-//| def info(object: Any) -> Any:
+//| def info(object: Any) -> int:
//| """Prints memory debugging info for the given object and returns the
//| estimated size."""
//| ...
diff --git a/shared-bindings/ulab/__init__.pyi b/shared-bindings/ulab/__init__.pyi
index e5de1391b..03bfe3610 100644
--- a/shared-bindings/ulab/__init__.pyi
+++ b/shared-bindings/ulab/__init__.pyi
@@ -17,7 +17,7 @@ https://docs.scipy.org/doc/numpy/index.html"""
class array:
"""1- and 2- dimensional array"""
- def __init__(self, values, *, dtype=float):
+ def __init__(self, values, *, dtype=float) -> None:
""":param sequence values: Sequence giving the initial content of the array.
:param dtype: The type of array values, ``int8``, ``uint8``, ``int16``, ``uint16``, or ``float``
diff --git a/shared-bindings/usb_hid/Device.c b/shared-bindings/usb_hid/Device.c
index 8c0c364ff..d071716ef 100644
--- a/shared-bindings/usb_hid/Device.c
+++ b/shared-bindings/usb_hid/Device.c
@@ -39,11 +39,11 @@
//| mouse.send_report()"""
//|
-//| def __init__(self, ):
+//| def __init__(self) -> None:
//| """Not currently dynamically supported."""
//| ...
//|
-//| def send_report(self, buf: Any) -> Any:
+//| def send_report(self, buf: ReadableBuffer) -> None:
//| """Send a HID report."""
//| ...
//|
@@ -58,7 +58,7 @@ STATIC mp_obj_t usb_hid_device_send_report(mp_obj_t self_in, mp_obj_t buffer) {
}
MP_DEFINE_CONST_FUN_OBJ_2(usb_hid_device_send_report_obj, usb_hid_device_send_report);
-//| usage_page: Any = ...
+//| usage_page: int = ...
//| """The usage page of the device as an `int`. Can be thought of a category. (read-only)"""
//|
STATIC mp_obj_t usb_hid_device_obj_get_usage_page(mp_obj_t self_in) {
@@ -74,7 +74,7 @@ const mp_obj_property_t usb_hid_device_usage_page_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| usage: Any = ...
+//| usage: int = ...
//| """The functionality of the device as an int. (read-only)
//|
//| For example, Keyboard is 0x06 within the generic desktop usage page 0x01.
diff --git a/shared-bindings/usb_hid/Device.h b/shared-bindings/usb_hid/Device.h
index cb9a64b5e..017995ccc 100644
--- a/shared-bindings/usb_hid/Device.h
+++ b/shared-bindings/usb_hid/Device.h
@@ -29,7 +29,7 @@
#include "shared-module/usb_hid/Device.h"
-const mp_obj_type_t usb_hid_device_type;
+extern const mp_obj_type_t usb_hid_device_type;
void common_hal_usb_hid_device_send_report(usb_hid_device_obj_t *self, uint8_t* report, uint8_t len);
uint8_t common_hal_usb_hid_device_get_usage_page(usb_hid_device_obj_t *self);
diff --git a/shared-bindings/usb_midi/PortIn.c b/shared-bindings/usb_midi/PortIn.c
index 9d9310b47..5b26a94c4 100644
--- a/shared-bindings/usb_midi/PortIn.c
+++ b/shared-bindings/usb_midi/PortIn.c
@@ -38,7 +38,7 @@
//| class PortIn:
//| """Receives midi commands over USB"""
//|
-//| def __init__(self):
+//| def __init__(self) -> None:
//| """You cannot create an instance of `usb_midi.PortIn`.
//|
//| PortIn objects are constructed for every corresponding entry in the USB
@@ -48,7 +48,7 @@
// These are standard stream methods. Code is in py/stream.c.
//
-//| def read(self, nbytes: Any = None) -> Any:
+//| def read(self, nbytes: int = None) -> Optional[bytes]:
//| """Read characters. If ``nbytes`` is specified then read at most that many
//| bytes. Otherwise, read everything that arrives until the connection
//| times out. Providing the number of bytes expected is highly recommended
@@ -58,7 +58,7 @@
//| :rtype: bytes or None"""
//| ...
//|
-//| def readinto(self, buf: Any, nbytes: Any = None) -> Any:
+//| def readinto(self, buf: WriteableBuffer, nbytes: Optional[int] = None) -> Optional[bytes]:
//| """Read bytes into the ``buf``. If ``nbytes`` is specified then read at most
//| that many bytes. Otherwise, read at most ``len(buf)`` bytes.
//|
diff --git a/shared-bindings/usb_midi/PortOut.c b/shared-bindings/usb_midi/PortOut.c
index 14ed0e767..ce7062ed3 100644
--- a/shared-bindings/usb_midi/PortOut.c
+++ b/shared-bindings/usb_midi/PortOut.c
@@ -38,7 +38,7 @@
//| class PortOut:
//| """Sends midi messages to a computer over USB"""
//|
-//| def __init__(self, ):
+//| def __init__(self) -> None:
//| """You cannot create an instance of `usb_midi.PortOut`.
//|
//| PortOut objects are constructed for every corresponding entry in the USB
@@ -47,7 +47,7 @@
// These are standard stream methods. Code is in py/stream.c.
//
-//| def write(self, buf: Any) -> Any:
+//| def write(self, buf: ReadableBuffer) -> Optional[int]:
//| """Write the buffer of bytes to the bus.
//|
//| :return: the number of bytes written
diff --git a/shared-bindings/ustack/__init__.c b/shared-bindings/ustack/__init__.c
index e5fac6941..de48c838a 100644
--- a/shared-bindings/ustack/__init__.c
+++ b/shared-bindings/ustack/__init__.c
@@ -60,7 +60,7 @@ STATIC mp_obj_t stack_size(void) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_0(stack_size_obj, stack_size);
-//| def stack_usage() -> Any:
+//| def stack_usage() -> int:
//| """Return how much stack is currently in use.
//| Same as micropython.stack_use(); duplicated here for convenience."""
//| ...
diff --git a/shared-bindings/vectorio/Circle.c b/shared-bindings/vectorio/Circle.c
index 65923fd96..7b010591d 100644
--- a/shared-bindings/vectorio/Circle.c
+++ b/shared-bindings/vectorio/Circle.c
@@ -11,7 +11,7 @@
//| class Circle:
//|
-//| def __init__(self, radius: int):
+//| def __init__(self, radius: int) -> None:
//| """Circle is positioned on screen by its center point.
//|
//| :param radius: The radius of the circle in pixels"""
diff --git a/shared-bindings/vectorio/Polygon.c b/shared-bindings/vectorio/Polygon.c
index 1aca4611e..b5c9d1c42 100644
--- a/shared-bindings/vectorio/Polygon.c
+++ b/shared-bindings/vectorio/Polygon.c
@@ -18,7 +18,7 @@
//| from typing import List, Tuple
//|
//| class Polygon:
-//| def __init__(self, points: List[ Tuple[ x, y ], ... ] ):
+//| def __init__(self, points: List[ Tuple[ x, y ], ... ] ) -> None:
//| """Represents a closed shape by ordered vertices
//|
//| :param points: Vertices for the polygon"""
diff --git a/shared-bindings/vectorio/Rectangle.c b/shared-bindings/vectorio/Rectangle.c
index f04a25c35..9a637f317 100644
--- a/shared-bindings/vectorio/Rectangle.c
+++ b/shared-bindings/vectorio/Rectangle.c
@@ -8,7 +8,7 @@
#include "supervisor/shared/translate.h"
//| class Rectangle:
-//| def __init__(self, width: int, height: int):
+//| def __init__(self, width: int, height: int) -> None:
//| """Represents a rectangle by defining its bounds
//|
//| :param width: The number of pixels wide
diff --git a/shared-bindings/vectorio/VectorShape.c b/shared-bindings/vectorio/VectorShape.c
index c512bcd54..d1042b1c6 100644
--- a/shared-bindings/vectorio/VectorShape.c
+++ b/shared-bindings/vectorio/VectorShape.c
@@ -20,7 +20,7 @@
//| class VectorShape:
-//| def __init__(self, shape: vectorio.Polygon, pixel_shader: displayio.Palette, x: int=0, y: int=0):
+//| def __init__(self, shape: vectorio.Polygon, pixel_shader: displayio.Palette, x: int=0, y: int=0) -> None:
//| """Binds a vector shape to a location and pixel color
//|
//| :param shape: The shape to draw.
diff --git a/shared-bindings/watchdog/WatchDogMode.c b/shared-bindings/watchdog/WatchDogMode.c
index 369454c11..9b9999d8b 100644
--- a/shared-bindings/watchdog/WatchDogMode.c
+++ b/shared-bindings/watchdog/WatchDogMode.c
@@ -29,15 +29,15 @@
//| class WatchDogMode:
//| """run state of the watchdog timer"""
//|
-//| def __init__(self, ):
+//| def __init__(self) -> None:
//| """Enum-like class to define the run mode of the watchdog timer."""
//|
-//| RAISE: Any = ...
+//| RAISE: watchdog.WatchDogMode = ...
//| """Raise an exception when the WatchDogTimer expires.
//|
//| :type watchdog.WatchDogMode:"""
//|
-//| RESET: Any = ...
+//| RESET: watchdog.WatchDogMode = ...
//| """Reset the system if the WatchDogTimer expires.
//|
//| :type watchdog.WatchDogMode:"""
diff --git a/shared-bindings/watchdog/WatchDogTimer.c b/shared-bindings/watchdog/WatchDogTimer.c
index 52bda4c77..20bead106 100644
--- a/shared-bindings/watchdog/WatchDogTimer.c
+++ b/shared-bindings/watchdog/WatchDogTimer.c
@@ -49,7 +49,7 @@
//| """
//|
-//| def __init__(self, ):
+//| def __init__(self) -> None:
//| """Not currently dynamically supported. Access the sole instance through `microcontroller.watchdog`."""
//| ...
//|
diff --git a/shared-bindings/wiznet/wiznet5k.c b/shared-bindings/wiznet/wiznet5k.c
index b3f372f41..525468178 100644
--- a/shared-bindings/wiznet/wiznet5k.c
+++ b/shared-bindings/wiznet/wiznet5k.c
@@ -49,7 +49,7 @@
//| class WIZNET5K:
//| """Wrapper for Wiznet 5500 Ethernet interface"""
//|
-//| def __init__(self, spi: busio.SPI, cs: microcontroller.Pin, rst: microcontroller.Pin, dhcp: bool = True):
+//| def __init__(self, spi: busio.SPI, cs: microcontroller.Pin, rst: microcontroller.Pin, dhcp: bool = True) -> None:
//| """Create a new WIZNET5500 interface using the specified pins
//|
//| :param ~busio.SPI spi: spi bus to use
@@ -84,7 +84,7 @@ STATIC mp_obj_t wiznet5k_make_new(const mp_obj_type_t *type, size_t n_args, cons
return ret;
}
-//| connected: Any = ...
+//| connected: bool = ...
//| """(boolean, readonly) is this device physically connected?"""
//|
@@ -101,7 +101,7 @@ const mp_obj_property_t wiznet5k_connected_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| dhcp: Any = ...
+//| dhcp: bool = ...
//| """(boolean, readwrite) is DHCP active on this device?
//|
//| * set to True to activate DHCP, False to turn it off"""
@@ -134,7 +134,7 @@ const mp_obj_property_t wiznet5k_dhcp_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| def ifconfig(self, params: Any = None) -> Any:
+//| def ifconfig(self, params: tuple = None) -> Optional[tuple]:
//| """Called without parameters, returns a tuple of
//| (ip_address, subnet_mask, gateway_address, dns_server)
//|
diff --git a/shared-module/memorymonitor/AllocationAlarm.c b/shared-module/memorymonitor/AllocationAlarm.c
new file mode 100644
index 000000000..35f4e4c63
--- /dev/null
+++ b/shared-module/memorymonitor/AllocationAlarm.c
@@ -0,0 +1,94 @@
+/*
+ * This file is part of the Micro Python project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020 Scott Shawcroft for Adafruit Industries
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include "shared-bindings/memorymonitor/__init__.h"
+#include "shared-bindings/memorymonitor/AllocationAlarm.h"
+
+#include "py/gc.h"
+#include "py/mpstate.h"
+#include "py/runtime.h"
+
+void common_hal_memorymonitor_allocationalarm_construct(memorymonitor_allocationalarm_obj_t* self, size_t minimum_block_count) {
+ self->minimum_block_count = minimum_block_count;
+ self->next = NULL;
+ self->previous = NULL;
+}
+
+void common_hal_memorymonitor_allocationalarm_set_ignore(memorymonitor_allocationalarm_obj_t* self, mp_int_t count) {
+ self->count = count;
+}
+
+void common_hal_memorymonitor_allocationalarm_pause(memorymonitor_allocationalarm_obj_t* self) {
+ // Check to make sure we aren't already paused. We can be if we're exiting from an exception we
+ // caused.
+ if (self->previous == NULL) {
+ return;
+ }
+ *self->previous = self->next;
+ self->next = NULL;
+ self->previous = NULL;
+}
+
+void common_hal_memorymonitor_allocationalarm_resume(memorymonitor_allocationalarm_obj_t* self) {
+ if (self->previous != NULL) {
+ mp_raise_RuntimeError(translate("Already running"));
+ }
+ self->next = MP_STATE_VM(active_allocationalarms);
+ self->previous = (memorymonitor_allocationalarm_obj_t**) &MP_STATE_VM(active_allocationalarms);
+ if (self->next != NULL) {
+ self->next->previous = &self->next;
+ }
+ MP_STATE_VM(active_allocationalarms) = self;
+}
+
+void memorymonitor_allocationalarms_allocation(size_t block_count) {
+ memorymonitor_allocationalarm_obj_t* alarm = MP_OBJ_TO_PTR(MP_STATE_VM(active_allocationalarms));
+ size_t alert_count = 0;
+ while (alarm != NULL) {
+ // Hold onto next in case we remove the alarm from the list.
+ memorymonitor_allocationalarm_obj_t* next = alarm->next;
+ if (block_count >= alarm->minimum_block_count) {
+ if (alarm->count > 0) {
+ alarm->count--;
+ } else {
+ // Uncomment the breakpoint below if you want to use a C debugger to figure out the C
+ // call stack for an allocation.
+ // asm("bkpt");
+ // Pause now because we may alert when throwing the exception too.
+ common_hal_memorymonitor_allocationalarm_pause(alarm);
+ alert_count++;
+ }
+ }
+ alarm = next;
+ }
+ if (alert_count > 0) {
+ mp_raise_memorymonitor_AllocationError(translate("Attempt to allocate %d blocks"), block_count);
+ }
+}
+
+void memorymonitor_allocationalarms_reset(void) {
+ MP_STATE_VM(active_allocationalarms) = NULL;
+}
diff --git a/shared-module/memorymonitor/AllocationAlarm.h b/shared-module/memorymonitor/AllocationAlarm.h
new file mode 100644
index 000000000..172c24f6c
--- /dev/null
+++ b/shared-module/memorymonitor/AllocationAlarm.h
@@ -0,0 +1,51 @@
+/*
+ * This file is part of the Micro Python project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020 Scott Shawcroft for Adafruit Industries
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#ifndef MICROPY_INCLUDED_SHARED_MODULE_MEMORYMONITOR_ALLOCATIONALARM_H
+#define MICROPY_INCLUDED_SHARED_MODULE_MEMORYMONITOR_ALLOCATIONALARM_H
+
+#include <stdbool.h>
+#include <stdint.h>
+
+#include "py/obj.h"
+
+typedef struct _memorymonitor_allocationalarm_obj_t memorymonitor_allocationalarm_obj_t;
+
+#define ALLOCATION_SIZE_BUCKETS 16
+
+typedef struct _memorymonitor_allocationalarm_obj_t {
+ mp_obj_base_t base;
+ size_t minimum_block_count;
+ mp_int_t count;
+ // Store the location that points to us so we can remove ourselves.
+ memorymonitor_allocationalarm_obj_t** previous;
+ memorymonitor_allocationalarm_obj_t* next;
+} memorymonitor_allocationalarm_obj_t;
+
+void memorymonitor_allocationalarms_allocation(size_t block_count);
+void memorymonitor_allocationalarms_reset(void);
+
+#endif // MICROPY_INCLUDED_SHARED_MODULE_MEMORYMONITOR_ALLOCATIONALARM_H
diff --git a/shared-module/memorymonitor/AllocationSize.c b/shared-module/memorymonitor/AllocationSize.c
new file mode 100644
index 000000000..c28e65592
--- /dev/null
+++ b/shared-module/memorymonitor/AllocationSize.c
@@ -0,0 +1,91 @@
+/*
+ * This file is part of the Micro Python project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020 Scott Shawcroft for Adafruit Industries
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include "shared-bindings/memorymonitor/AllocationSize.h"
+
+#include "py/gc.h"
+#include "py/mpstate.h"
+#include "py/runtime.h"
+
+void common_hal_memorymonitor_allocationsize_construct(memorymonitor_allocationsize_obj_t* self) {
+ common_hal_memorymonitor_allocationsize_clear(self);
+ self->next = NULL;
+ self->previous = NULL;
+}
+
+void common_hal_memorymonitor_allocationsize_pause(memorymonitor_allocationsize_obj_t* self) {
+ *self->previous = self->next;
+ self->next = NULL;
+ self->previous = NULL;
+}
+
+void common_hal_memorymonitor_allocationsize_resume(memorymonitor_allocationsize_obj_t* self) {
+ if (self->previous != NULL) {
+ mp_raise_RuntimeError(translate("Already running"));
+ }
+ self->next = MP_STATE_VM(active_allocationsizes);
+ self->previous = (memorymonitor_allocationsize_obj_t**) &MP_STATE_VM(active_allocationsizes);
+ if (self->next != NULL) {
+ self->next->previous = &self->next;
+ }
+ MP_STATE_VM(active_allocationsizes) = self;
+}
+
+void common_hal_memorymonitor_allocationsize_clear(memorymonitor_allocationsize_obj_t* self) {
+ for (size_t i = 0; i < ALLOCATION_SIZE_BUCKETS; i++) {
+ self->buckets[i] = 0;
+ }
+}
+
+uint16_t common_hal_memorymonitor_allocationsize_get_len(memorymonitor_allocationsize_obj_t* self) {
+ return ALLOCATION_SIZE_BUCKETS;
+}
+
+size_t common_hal_memorymonitor_allocationsize_get_bytes_per_block(memorymonitor_allocationsize_obj_t* self) {
+ return BYTES_PER_BLOCK;
+}
+
+uint16_t common_hal_memorymonitor_allocationsize_get_item(memorymonitor_allocationsize_obj_t* self, int16_t index) {
+ return self->buckets[index];
+}
+
+void memorymonitor_allocationsizes_track_allocation(size_t block_count) {
+ memorymonitor_allocationsize_obj_t* as = MP_OBJ_TO_PTR(MP_STATE_VM(active_allocationsizes));
+ size_t power_of_two = 0;
+ block_count >>= 1;
+ while (block_count != 0) {
+ power_of_two++;
+ block_count >>= 1;
+ }
+ while (as != NULL) {
+ as->buckets[power_of_two]++;
+ as = as->next;
+ }
+}
+
+void memorymonitor_allocationsizes_reset(void) {
+ MP_STATE_VM(active_allocationsizes) = NULL;
+}
diff --git a/shared-module/memorymonitor/AllocationSize.h b/shared-module/memorymonitor/AllocationSize.h
new file mode 100644
index 000000000..3baab2213
--- /dev/null
+++ b/shared-module/memorymonitor/AllocationSize.h
@@ -0,0 +1,51 @@
+/*
+ * This file is part of the Micro Python project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020 Scott Shawcroft for Adafruit Industries
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#ifndef MICROPY_INCLUDED_SHARED_MODULE_MEMORYMONITOR_ALLOCATIONSIZE_H
+#define MICROPY_INCLUDED_SHARED_MODULE_MEMORYMONITOR_ALLOCATIONSIZE_H
+
+#include <stdbool.h>
+#include <stdint.h>
+
+#include "py/obj.h"
+
+typedef struct _memorymonitor_allocationsize_obj_t memorymonitor_allocationsize_obj_t;
+
+#define ALLOCATION_SIZE_BUCKETS 16
+
+typedef struct _memorymonitor_allocationsize_obj_t {
+ mp_obj_base_t base;
+ uint16_t buckets[ALLOCATION_SIZE_BUCKETS];
+ // Store the location that points to us so we can remove ourselves.
+ memorymonitor_allocationsize_obj_t** previous;
+ memorymonitor_allocationsize_obj_t* next;
+ bool paused;
+} memorymonitor_allocationsize_obj_t;
+
+void memorymonitor_allocationsizes_track_allocation(size_t block_count);
+void memorymonitor_allocationsizes_reset(void);
+
+#endif // MICROPY_INCLUDED_SHARED_MODULE_MEMORYMONITOR_ALLOCATIONSIZE_H
diff --git a/shared-module/memorymonitor/__init__.c b/shared-module/memorymonitor/__init__.c
new file mode 100644
index 000000000..6cb424153
--- /dev/null
+++ b/shared-module/memorymonitor/__init__.c
@@ -0,0 +1,39 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020 Scott Shawcroft
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include "shared-module/memorymonitor/__init__.h"
+#include "shared-module/memorymonitor/AllocationAlarm.h"
+#include "shared-module/memorymonitor/AllocationSize.h"
+
+void memorymonitor_track_allocation(size_t block_count) {
+ memorymonitor_allocationalarms_allocation(block_count);
+ memorymonitor_allocationsizes_track_allocation(block_count);
+}
+
+void memorymonitor_reset(void) {
+ memorymonitor_allocationalarms_reset();
+ memorymonitor_allocationsizes_reset();
+}
diff --git a/shared-module/memorymonitor/__init__.h b/shared-module/memorymonitor/__init__.h
new file mode 100644
index 000000000..f47f6434b
--- /dev/null
+++ b/shared-module/memorymonitor/__init__.h
@@ -0,0 +1,35 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2016 Scott Shawcroft for Adafruit Industries
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#ifndef MICROPY_INCLUDED_MEMORYMONITOR___INIT___H
+#define MICROPY_INCLUDED_MEMORYMONITOR___INIT___H
+
+#include <stddef.h>
+
+void memorymonitor_track_allocation(size_t block_count);
+void memorymonitor_reset(void);
+
+#endif // MICROPY_INCLUDED_MEMORYMONITOR___INIT___H
diff --git a/shared-module/touchio/TouchIn.c b/shared-module/touchio/TouchIn.c
index 88d12b8b8..3fdf3e0ca 100644
--- a/shared-module/touchio/TouchIn.c
+++ b/shared-module/touchio/TouchIn.c
@@ -31,6 +31,7 @@
#include "py/runtime.h"
#include "py/mphal.h"
#include "shared-bindings/touchio/TouchIn.h"
+#include "shared-bindings/microcontroller/Pin.h"
// This is a capacitive touch sensing routine using a single digital
// pin. The pin should be connected to the sensing pad, and to ground
@@ -67,7 +68,7 @@ static uint16_t get_raw_reading(touchio_touchin_obj_t *self) {
}
void common_hal_touchio_touchin_construct(touchio_touchin_obj_t* self, const mcu_pin_obj_t *pin) {
- claim_pin(pin);
+ common_hal_mcu_pin_claim(pin);
self->digitalinout = m_new_obj(digitalio_digitalinout_obj_t);
self->digitalinout->base.type = &digitalio_digitalinout_type;
diff --git a/supervisor/serial.h b/supervisor/serial.h
index ef88ad346..066886303 100644
--- a/supervisor/serial.h
+++ b/supervisor/serial.h
@@ -35,7 +35,7 @@
#ifdef CIRCUITPY_BOOT_OUTPUT_FILE
#include "lib/oofatfs/ff.h"
-FIL* boot_output_file;
+extern FIL* boot_output_file;
#endif
void serial_early_init(void);
diff --git a/tests/basics/async_coroutine.py b/tests/basics/async_coroutine.py
new file mode 100644
index 000000000..791f6df14
--- /dev/null
+++ b/tests/basics/async_coroutine.py
@@ -0,0 +1,13 @@
+async def f():
+ pass
+
+try:
+ f() # Should not crash
+except Exception as e:
+ print('failed to invoke')
+
+try:
+ next(f())
+ print('This should fail because async def returns a coroutine, and next() is not allowed')
+except Exception as e:
+ print('pass')
diff --git a/tests/basics/async_coroutine.py.exp b/tests/basics/async_coroutine.py.exp
new file mode 100644
index 000000000..2ae28399f
--- /dev/null
+++ b/tests/basics/async_coroutine.py.exp
@@ -0,0 +1 @@
+pass
diff --git a/tests/run-tests b/tests/run-tests
index 151d48095..e28600361 100755
--- a/tests/run-tests
+++ b/tests/run-tests
@@ -362,7 +362,7 @@ def run_tests(pyb, tests, args, base_path=".", num_threads=1):
if args.emit == 'native':
skip_tests.update({'basics/%s.py' % t for t in 'gen_yield_from gen_yield_from_close gen_yield_from_ducktype gen_yield_from_exc gen_yield_from_executing gen_yield_from_iter gen_yield_from_send gen_yield_from_stopped gen_yield_from_throw gen_yield_from_throw2 gen_yield_from_throw3 generator1 generator2 generator_args generator_close generator_closure generator_exc generator_pend_throw generator_return generator_send'.split()}) # require yield
skip_tests.update({'basics/%s.py' % t for t in 'bytes_gen class_store_class globals_del string_join gen_stack_overflow'.split()}) # require yield
- skip_tests.update({'basics/async_%s.py' % t for t in 'def await await2 for for2 with with2'.split()}) # require yield
+ skip_tests.update({'basics/async_%s.py' % t for t in 'def await await2 for for2 with with2 coroutine'.split()}) # require yield
skip_tests.update({'basics/%s.py' % t for t in 'try_reraise try_reraise2'.split()}) # require raise_varargs
skip_tests.update({'basics/%s.py' % t for t in 'with_break with_continue with_return'.split()}) # require complete with support
skip_tests.add('basics/array_construct2.py') # requires generators
diff --git a/tools/extract_pyi.py b/tools/extract_pyi.py
index e5da61035..ab223877e 100644
--- a/tools/extract_pyi.py
+++ b/tools/extract_pyi.py
@@ -2,6 +2,10 @@
#
# SPDX-License-Identifier: MIT
+# Run with 'python tools/extract_pyi.py shared-bindings/ path/to/stub/dir
+# You can also test a specific library in shared-bindings by putting the path
+# to that directory instead
+
import ast
import os
import re
diff --git a/tools/gen_usb_descriptor.py b/tools/gen_usb_descriptor.py
index 9a8423c32..adec33100 100644
--- a/tools/gen_usb_descriptor.py
+++ b/tools/gen_usb_descriptor.py
@@ -539,14 +539,14 @@ h_file.write("""\
#include <stdint.h>
-const uint8_t usb_desc_dev[{device_length}];
+extern const uint8_t usb_desc_dev[{device_length}];
// Make sure the control buffer is big enough to fit the descriptor.
#define CFG_TUD_ENUM_BUFFER_SIZE {max_configuration_length}
-const uint8_t usb_desc_cfg[{configuration_length}];
-uint16_t usb_serial_number[{serial_number_length}];
-uint16_t const * const string_desc_arr [{string_descriptor_length}];
+extern const uint8_t usb_desc_cfg[{configuration_length}];
+extern uint16_t usb_serial_number[{serial_number_length}];
+extern uint16_t const * const string_desc_arr [{string_descriptor_length}];
-const uint8_t hid_report_descriptor[{hid_report_descriptor_length}];
+extern const uint8_t hid_report_descriptor[{hid_report_descriptor_length}];
#define USB_HID_NUM_DEVICES {hid_num_devices}