summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnson He <ansonhe1997@gmail.com>2020-07-28 17:03:10 +0800
committerGitHub <noreply@github.com>2020-07-28 17:03:10 +0800
commitc010cc2c414a98caa1aa510497666bf017c792ab (patch)
treedac841881017719bae0654a64cbc52f35cf6977a
parent36ef3476de945071da9c1274e5b4d8bcdcc13d13 (diff)
parentdebbf1028adee2309ed991c90517c50d5eb13bfb (diff)
Merge pull request #1 from adafruit/main
Merged main to fork
-rw-r--r--.gitattributes4
-rw-r--r--.github/workflows/build.yml20
-rw-r--r--.github/workflows/create_website_pr.yml4
-rw-r--r--.gitignore4
-rw-r--r--.gitmodules4
-rw-r--r--.mailmap112
-rw-r--r--.readthedocs.yml4
-rw-r--r--.rosie.yml4
-rw-r--r--ACKNOWLEDGEMENTS.license3
-rw-r--r--BUILDING.md5
-rw-r--r--CONTRIBUTING.md6
-rw-r--r--LICENSES/BSD-3-Clause.txt26
-rw-r--r--LICENSES/CC-BY-4.0.txt324
-rw-r--r--LICENSES/MIT.txt19
-rw-r--r--LICENSES/OFL-1.1.txt90
-rw-r--r--LICENSES/Unlicense.txt20
-rw-r--r--Makefile50
-rw-r--r--conf.py4
-rw-r--r--docs/library/index.rst2
-rw-r--r--docs/shared_bindings_matrix.py39
-rw-r--r--docs/static/customstyle.css12
-rw-r--r--docs/static/favicon.ico.license3
-rw-r--r--drivers/bus/qspi.h2
-rw-r--r--drivers/bus/softqspi.c2
-rw-r--r--drivers/bus/softspi.c2
-rw-r--r--drivers/bus/spi.h2
-rw-r--r--extmod/font_petme128_8x8.h30
-rw-r--r--extmod/machine_mem.c29
-rw-r--r--extmod/machine_mem.h30
-rw-r--r--extmod/machine_pinbase.c29
-rw-r--r--extmod/machine_pinbase.h30
-rw-r--r--extmod/machine_pulse.c29
-rw-r--r--extmod/machine_pulse.h30
-rw-r--r--extmod/machine_signal.c29
-rw-r--r--extmod/machine_signal.h30
-rw-r--r--extmod/misc.h32
-rw-r--r--extmod/modbtree.c29
-rw-r--r--extmod/modframebuf.c29
-rw-r--r--extmod/modlwip.c33
-rw-r--r--extmod/modonewire.c29
-rw-r--r--extmod/modubinascii.c29
-rw-r--r--extmod/modubinascii.h30
-rw-r--r--extmod/moductypes.c29
-rw-r--r--extmod/moduhashlib.c29
-rw-r--r--extmod/moduheapq.c29
-rw-r--r--extmod/modujson.c67
-rw-r--r--extmod/modurandom.c29
-rw-r--r--extmod/modure.c29
-rw-r--r--extmod/moduselect.c29
-rw-r--r--extmod/modussl_axtls.c29
-rw-r--r--extmod/modussl_mbedtls.c29
-rw-r--r--extmod/modutimeq.c31
-rw-r--r--extmod/moduzlib.c29
-rw-r--r--extmod/modwebrepl.c29
-rw-r--r--extmod/modwebsocket.c29
-rw-r--r--extmod/modwebsocket.h4
m---------extmod/ulab0
-rw-r--r--extmod/uos_dupterm.c31
-rw-r--r--extmod/utime_mphal.c31
-rw-r--r--extmod/utime_mphal.h32
-rw-r--r--extmod/vfs.c29
-rw-r--r--extmod/vfs.h30
-rw-r--r--extmod/vfs_fat.c31
-rw-r--r--extmod/vfs_fat.h30
-rw-r--r--extmod/vfs_fat_diskio.c32
-rw-r--r--extmod/vfs_fat_file.c29
-rw-r--r--extmod/vfs_posix.c29
-rw-r--r--extmod/vfs_posix.h30
-rw-r--r--extmod/vfs_posix_file.c29
-rw-r--r--extmod/vfs_reader.c29
-rw-r--r--extmod/virtpin.c29
-rw-r--r--extmod/virtpin.h30
m---------frozen/circuitpython-stage0
-rw-r--r--lib/libc/string0.c2
-rw-r--r--lib/libm/math.c2
-rw-r--r--lib/mp-readline/readline.c2
-rw-r--r--lib/mp-readline/readline.h2
m---------lib/mp30
-rw-r--r--lib/netutils/netutils.c2
-rw-r--r--lib/netutils/netutils.h2
-rw-r--r--lib/oofatfs/ffconf.h2
m---------lib/protomatter0
-rw-r--r--lib/timeutils/timeutils.c2
-rw-r--r--lib/timeutils/timeutils.h2
-rw-r--r--lib/utils/interrupt_char.c2
-rw-r--r--lib/utils/interrupt_char.h2
-rw-r--r--lib/utils/printf.c2
-rwxr-xr-xlib/utils/pyexec.c2
-rw-r--r--lib/utils/pyexec.h2
-rw-r--r--lib/utils/sys_stdio_mphal.c2
-rw-r--r--locale/ID.po481
-rw-r--r--locale/circuitpython.pot146
-rw-r--r--locale/cs.po131
-rw-r--r--locale/de_DE.po131
-rw-r--r--locale/en_US.po7
-rw-r--r--locale/en_x_pirate.po7
-rw-r--r--locale/es.po471
-rw-r--r--locale/fil.po131
-rw-r--r--locale/fr.po134
-rw-r--r--locale/it_IT.po133
-rw-r--r--locale/ko.po133
-rw-r--r--locale/nl.po139
-rw-r--r--locale/pl.po132
-rw-r--r--locale/pt_BR.po1389
-rw-r--r--locale/sv.po143
-rw-r--r--locale/zh_Latn_pinyin.po132
-rw-r--r--logo/CircuitPython_Repo_header_logo.png.license3
-rw-r--r--logo/adafruit_blinka_angles-back.svg.license3
-rw-r--r--logo/adafruit_blinka_angles-front.svg.license3
-rw-r--r--logo/adafruit_blinka_angles-left.svg.license3
-rw-r--r--logo/adafruit_blinka_angles-right.svg.license3
-rw-r--r--logo/adafruit_blinka_computer.svg.license3
-rw-r--r--logo/adafruit_circuit_python_ourboros_color.svg.license3
-rw-r--r--logo/adafruit_circuit_python_ouroboros_logo_final.svg.license3
-rw-r--r--logo/adafruit_circuit_python_sitting_color.svg.license3
-rw-r--r--logo/adafruit_circuit_python_stacked_lockup_logo_final.svg.license3
-rw-r--r--logo/awesome_circuitpython.svg.license3
-rw-r--r--logo/blinka_colorform-cooking.png.license3
-rw-r--r--logo/blinka_colorform-cooking.svg.license3
-rw-r--r--logo/blinka_colorform-first-birthday.svg.license3
-rw-r--r--logo/blinka_colorform-painting.svg.license3
-rw-r--r--logo/blinka_colorform-reading.svg.license3
-rw-r--r--logo/blinka_colorform-singing.svg.license3
-rw-r--r--logo/blinka_colorform-telescope.svg.license3
-rw-r--r--logo/blinka_colorform-test_tubes.svg.license3
-rwxr-xr-xmain.c24
-rw-r--r--mpy-cross/.gitignore4
-rw-r--r--mpy-cross/Makefile4
-rw-r--r--mpy-cross/Makefile.fuzz3
-rw-r--r--mpy-cross/Makefile.static4
-rw-r--r--mpy-cross/Makefile.static-mingw4
-rw-r--r--mpy-cross/Makefile.static-raspbian4
-rw-r--r--mpy-cross/README.md6
-rw-r--r--mpy-cross/fmode.c29
-rw-r--r--mpy-cross/fmode.h30
-rw-r--r--mpy-cross/gccollect.c29
-rw-r--r--mpy-cross/main.c29
-rw-r--r--mpy-cross/mpconfigport.h30
-rw-r--r--mpy-cross/mphalport.h4
-rw-r--r--mpy-cross/mpy-cross.mk4
-rw-r--r--mpy-cross/qstrdefsport.h4
-rw-r--r--ports/atmel-samd/Makefile26
m---------ports/atmel-samd/asf40
-rw-r--r--ports/atmel-samd/asf4_conf/samd51/hpl_sdhc_config.h24
-rw-r--r--ports/atmel-samd/asf4_conf/samd51/peripheral_clk_config.h164
-rw-r--r--ports/atmel-samd/asf4_conf/same54/hpl_sdhc_config.h24
-rw-r--r--ports/atmel-samd/asf4_conf/same54/peripheral_clk_config.h164
-rw-r--r--ports/atmel-samd/audio_dma.c54
-rw-r--r--ports/atmel-samd/audio_dma.h2
-rw-r--r--ports/atmel-samd/background.c52
-rw-r--r--ports/atmel-samd/background.h5
-rw-r--r--ports/atmel-samd/bindings/samd/Clock.c9
-rw-r--r--ports/atmel-samd/boards/8086_commander/mpconfigboard.mk2
-rw-r--r--ports/atmel-samd/boards/aloriumtech_evo_m51/mpconfigboard.mk2
-rwxr-xr-xports/atmel-samd/boards/circuitbrains_basic_m0/mpconfigboard.mk1
-rwxr-xr-xports/atmel-samd/boards/circuitbrains_deluxe_m4/mpconfigboard.mk2
-rw-r--r--ports/atmel-samd/boards/fluff_m0/pins.c2
-rw-r--r--ports/atmel-samd/boards/grandcentral_m4_express/mpconfigboard.mk2
-rw-r--r--ports/atmel-samd/boards/grandcentral_m4_express/pins.c17
-rw-r--r--ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.mk4
-rw-r--r--ports/atmel-samd/boards/loc_ber_m4_base_board/mpconfigboard.mk2
-rw-r--r--ports/atmel-samd/boards/ndgarage_ndbit6_v2/board.c39
-rw-r--r--ports/atmel-samd/boards/ndgarage_ndbit6_v2/mpconfigboard.h22
-rw-r--r--ports/atmel-samd/boards/ndgarage_ndbit6_v2/mpconfigboard.mk14
-rw-r--r--ports/atmel-samd/boards/ndgarage_ndbit6_v2/pins.c36
-rw-r--r--ports/atmel-samd/boards/pewpew10/mpconfigboard.h2
-rw-r--r--ports/atmel-samd/boards/pewpew_m4/mpconfigboard.h2
-rw-r--r--ports/atmel-samd/boards/pewpew_m4/mpconfigboard.mk24
-rw-r--r--ports/atmel-samd/boards/same54_xplained/mpconfigboard.mk3
-rw-r--r--ports/atmel-samd/boards/same54_xplained/pins.c17
-rw-r--r--ports/atmel-samd/boards/sparkfun_samd51_thing_plus/mpconfigboard.mk2
-rw-r--r--ports/atmel-samd/boards/uchip/mpconfigboard.mk5
-rw-r--r--ports/atmel-samd/boards/winterbloom_big_honking_button/mpconfigboard.mk5
-rw-r--r--ports/atmel-samd/boards/winterbloom_big_honking_button/usermods/_bhb/bhb.c120
-rw-r--r--ports/atmel-samd/boards/winterbloom_big_honking_button/usermods/_bhb/micropython.mk6
-rw-r--r--ports/atmel-samd/boards/winterbloom_sol/mpconfigboard.mk1
-rw-r--r--ports/atmel-samd/common-hal/analogio/AnalogOut.c2
-rw-r--r--ports/atmel-samd/common-hal/board/__init__.c2
-rw-r--r--ports/atmel-samd/common-hal/busio/SPI.c4
-rw-r--r--ports/atmel-samd/common-hal/busio/UART.c8
-rw-r--r--ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c3
-rw-r--r--ports/atmel-samd/common-hal/pulseio/PWMOut.c2
-rw-r--r--ports/atmel-samd/common-hal/pulseio/PulseIn.c13
-rw-r--r--ports/atmel-samd/common-hal/pulseio/PulseIn.h6
-rw-r--r--ports/atmel-samd/common-hal/pulseio/PulseOut.c2
-rw-r--r--ports/atmel-samd/common-hal/sdioio/SDCard.c272
-rw-r--r--ports/atmel-samd/common-hal/sdioio/SDCard.h40
-rw-r--r--ports/atmel-samd/common-hal/sdioio/__init__.c0
-rw-r--r--ports/atmel-samd/common-hal/sdioio/__init__.h0
-rw-r--r--ports/atmel-samd/fatfs_port.c2
-rw-r--r--ports/atmel-samd/mpconfigport.h16
-rw-r--r--ports/atmel-samd/mpconfigport.mk5
-rw-r--r--ports/atmel-samd/mphalport.h4
-rw-r--r--ports/atmel-samd/sd_mmc/conf_sd_mmc.h79
-rw-r--r--ports/atmel-samd/sd_mmc/sd_mmc.c1671
-rw-r--r--ports/atmel-samd/sd_mmc/sd_mmc.h310
-rw-r--r--ports/atmel-samd/sd_mmc/sd_mmc_protocol.h1001
-rw-r--r--ports/atmel-samd/supervisor/internal_flash.c2
-rw-r--r--ports/atmel-samd/supervisor/internal_flash.h2
-rw-r--r--ports/atmel-samd/supervisor/port.c34
-rw-r--r--ports/atmel-samd/supervisor/usb.c12
-rw-r--r--ports/atmel-samd/tools/gen_pin_name_table.py2
-rw-r--r--ports/cxd56/Makefile27
-rw-r--r--ports/cxd56/README.md4
-rw-r--r--ports/cxd56/background.c24
-rw-r--r--ports/cxd56/background.h3
-rw-r--r--ports/cxd56/boards/spresense/pins.c16
-rw-r--r--ports/cxd56/common-hal/busio/SPI.c2
-rw-r--r--ports/cxd56/common-hal/busio/UART.c4
-rw-r--r--ports/cxd56/common-hal/microcontroller/Pin.c6
-rw-r--r--ports/cxd56/common-hal/microcontroller/Pin.h6
-rw-r--r--ports/cxd56/common-hal/pulseio/PWMOut.h2
-rw-r--r--ports/cxd56/common-hal/sdioio/SDCard.c141
-rw-r--r--ports/cxd56/common-hal/sdioio/SDCard.h47
-rw-r--r--ports/cxd56/common-hal/sdioio/__init__.c0
-rw-r--r--ports/cxd56/configs/circuitpython/defconfig171
-rw-r--r--ports/cxd56/mkspk/elf32.h175
-rw-r--r--ports/cxd56/mkspk/mkspk.h12
-rw-r--r--ports/cxd56/mpconfigport.mk3
m---------ports/cxd56/spresense-exported-sdk0
-rwxr-xr-xports/cxd56/tools/flash_writer.py580
-rw-r--r--ports/cxd56/tools/xmodem.py590
-rw-r--r--ports/esp32s2/Makefile45
-rw-r--r--ports/esp32s2/background.c27
-rw-r--r--ports/esp32s2/background.h3
-rw-r--r--ports/esp32s2/boards/espressif_saola_1_wroom/board.c8
-rw-r--r--ports/esp32s2/boards/espressif_saola_1_wroom/mpconfigboard.mk2
-rw-r--r--ports/esp32s2/boards/espressif_saola_1_wrover/board.c8
-rw-r--r--ports/esp32s2/boards/espressif_saola_1_wrover/mpconfigboard.mk2
-rw-r--r--ports/esp32s2/boards/unexpectedmaker_feathers2/board.c56
-rw-r--r--ports/esp32s2/boards/unexpectedmaker_feathers2/mpconfigboard.h36
-rw-r--r--ports/esp32s2/boards/unexpectedmaker_feathers2/mpconfigboard.mk21
-rw-r--r--ports/esp32s2/boards/unexpectedmaker_feathers2/pins.c57
-rw-r--r--ports/esp32s2/boards/unexpectedmaker_feathers2/sdkconfig0
-rw-r--r--ports/esp32s2/common-hal/busio/I2C.c228
-rw-r--r--ports/esp32s2/common-hal/busio/I2C.h48
-rw-r--r--ports/esp32s2/common-hal/busio/OneWire.h33
-rw-r--r--ports/esp32s2/common-hal/busio/SPI.c358
-rw-r--r--ports/esp32s2/common-hal/busio/SPI.h62
-rw-r--r--ports/esp32s2/common-hal/busio/UART.c348
-rw-r--r--ports/esp32s2/common-hal/busio/UART.h49
-rw-r--r--ports/esp32s2/common-hal/busio/__init__.c1
-rw-r--r--ports/esp32s2/common-hal/digitalio/DigitalInOut.c4
-rw-r--r--ports/esp32s2/common-hal/displayio/ParallelBus.c66
-rw-r--r--ports/esp32s2/common-hal/displayio/ParallelBus.h36
-rw-r--r--ports/esp32s2/common-hal/microcontroller/Pin.c9
-rw-r--r--ports/esp32s2/common-hal/microcontroller/Pin.h5
-rw-r--r--ports/esp32s2/common-hal/microcontroller/Processor.c22
-rw-r--r--ports/esp32s2/common-hal/microcontroller/Processor.h2
-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
m---------ports/esp32s2/esp-idf0
-rw-r--r--ports/esp32s2/fatfs_port.c2
-rw-r--r--ports/esp32s2/modules/wroom.c12
-rw-r--r--ports/esp32s2/modules/wrover.c14
-rw-r--r--ports/esp32s2/mpconfigport.mk10
-rw-r--r--ports/esp32s2/mphalport.c3
-rw-r--r--ports/esp32s2/sdkconfig.defaults28
-rw-r--r--ports/esp32s2/supervisor/internal_flash.c38
-rw-r--r--ports/esp32s2/supervisor/internal_flash.h2
-rw-r--r--ports/esp32s2/supervisor/port.c41
-rw-r--r--ports/litex/Makefile9
-rw-r--r--ports/litex/background.c32
-rw-r--r--ports/litex/background.h5
-rw-r--r--ports/litex/common-hal/digitalio/DigitalInOut.c4
-rw-r--r--ports/litex/common-hal/microcontroller/Pin.c7
-rw-r--r--ports/litex/fatfs_port.c2
-rw-r--r--ports/litex/mpconfigport.mk3
-rw-r--r--ports/litex/mphalport.c3
-rw-r--r--ports/litex/supervisor/internal_flash.c2
-rw-r--r--ports/litex/supervisor/internal_flash.h2
-rw-r--r--ports/mimxrt10xx/Makefile11
-rw-r--r--ports/mimxrt10xx/background.c53
-rw-r--r--ports/mimxrt10xx/background.h7
-rw-r--r--ports/mimxrt10xx/common-hal/analogio/AnalogOut.c2
-rw-r--r--ports/mimxrt10xx/common-hal/board/__init__.c2
-rw-r--r--ports/mimxrt10xx/common-hal/busio/SPI.c4
-rw-r--r--ports/mimxrt10xx/common-hal/busio/UART.c6
-rw-r--r--ports/mimxrt10xx/common-hal/pulseio/PWMOut.c2
-rw-r--r--ports/mimxrt10xx/common-hal/pulseio/PulseIn.c2
-rw-r--r--ports/mimxrt10xx/common-hal/pulseio/PulseOut.c2
-rw-r--r--ports/mimxrt10xx/fatfs_port.c2
-rw-r--r--ports/mimxrt10xx/supervisor/internal_flash.c2
-rw-r--r--ports/mimxrt10xx/supervisor/internal_flash.h2
-rw-r--r--ports/mimxrt10xx/supervisor/usb.c3
-rwxr-xr-xports/nrf/Makefile10
-rw-r--r--ports/nrf/background.c28
-rw-r--r--ports/nrf/background.h5
-rw-r--r--ports/nrf/boards/bless_dev_board_multi_sensor/board.c12
-rw-r--r--ports/nrf/boards/bless_dev_board_multi_sensor/mpconfigboard.h17
-rw-r--r--ports/nrf/boards/bless_dev_board_multi_sensor/mpconfigboard.mk8
-rw-r--r--ports/nrf/boards/bless_dev_board_multi_sensor/pins.c45
-rw-r--r--ports/nrf/boards/ikigaisense_vita/board.c38
-rw-r--r--ports/nrf/boards/ikigaisense_vita/mpconfigboard.h20
-rw-r--r--ports/nrf/boards/ikigaisense_vita/mpconfigboard.mk8
-rw-r--r--ports/nrf/boards/ikigaisense_vita/pins.c36
-rw-r--r--ports/nrf/boards/makerdiary_m60_keyboard/README.md4
-rw-r--r--ports/nrf/boards/makerdiary_m60_keyboard/board.c38
-rw-r--r--ports/nrf/boards/makerdiary_m60_keyboard/mpconfigboard.h50
-rw-r--r--ports/nrf/boards/makerdiary_m60_keyboard/mpconfigboard.mk12
-rw-r--r--ports/nrf/boards/makerdiary_m60_keyboard/pins.c41
-rw-r--r--ports/nrf/boards/makerdiary_nrf52840_m2_devkit/README.md8
-rw-r--r--ports/nrf/boards/makerdiary_nrf52840_m2_devkit/board.c103
-rw-r--r--ports/nrf/boards/makerdiary_nrf52840_m2_devkit/mpconfigboard.h57
-rw-r--r--ports/nrf/boards/makerdiary_nrf52840_m2_devkit/mpconfigboard.mk12
-rw-r--r--ports/nrf/boards/makerdiary_nrf52840_m2_devkit/pins.c110
-rw-r--r--ports/nrf/boards/particle_argon/mpconfigboard.mk4
-rw-r--r--ports/nrf/boards/particle_boron/mpconfigboard.mk4
-rw-r--r--ports/nrf/boards/particle_xenon/mpconfigboard.mk4
-rw-r--r--ports/nrf/boards/pca10100/mpconfigboard.mk4
-rw-r--r--ports/nrf/boards/raytac_mdbt50q-db-40/board.c38
-rw-r--r--ports/nrf/boards/raytac_mdbt50q-db-40/bootloader/6.0.0/pca10056_bootloader_6.0.0_s140.zipbin0 -> 174550 bytes
-rw-r--r--ports/nrf/boards/raytac_mdbt50q-db-40/mpconfigboard.h30
-rw-r--r--ports/nrf/boards/raytac_mdbt50q-db-40/mpconfigboard.mk8
-rw-r--r--ports/nrf/boards/raytac_mdbt50q-db-40/pins.c80
-rw-r--r--ports/nrf/boards/simmel/mpconfigboard.mk3
-rw-r--r--ports/nrf/boards/tinkeringtech_scoutmakes_azul/README.md25
-rw-r--r--ports/nrf/boards/tinkeringtech_scoutmakes_azul/board.c38
-rw-r--r--ports/nrf/boards/tinkeringtech_scoutmakes_azul/mpconfigboard.h63
-rw-r--r--ports/nrf/boards/tinkeringtech_scoutmakes_azul/mpconfigboard.mk10
-rw-r--r--ports/nrf/boards/tinkeringtech_scoutmakes_azul/pins.c53
-rw-r--r--ports/nrf/common-hal/busio/SPI.c6
-rw-r--r--ports/nrf/common-hal/busio/UART.c6
-rw-r--r--ports/nrf/common-hal/microcontroller/__init__.c44
-rw-r--r--ports/nrf/examples/ubluepy_temp.py2
-rw-r--r--ports/nrf/fatfs_port.c2
-rw-r--r--ports/nrf/peripherals/nrf/nvm.c2
-rw-r--r--ports/nrf/peripherals/nrf/nvm.h2
-rw-r--r--ports/nrf/supervisor/internal_flash.c2
-rw-r--r--ports/nrf/supervisor/internal_flash.h2
-rw-r--r--ports/nrf/supervisor/port.c13
-rw-r--r--ports/nrf/supervisor/usb.c7
-rwxr-xr-xports/stm/Makefile15
-rw-r--r--ports/stm/background.c28
-rw-r--r--ports/stm/background.h5
-rw-r--r--ports/stm/common-hal/analogio/AnalogIn.c4
-rw-r--r--ports/stm/common-hal/analogio/AnalogOut.c4
-rw-r--r--ports/stm/common-hal/busio/I2C.c6
-rw-r--r--ports/stm/common-hal/busio/SPI.c154
-rw-r--r--ports/stm/common-hal/busio/UART.c11
-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/fatfs_port.c2
-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
m---------ports/stm/st_driver0
-rw-r--r--ports/stm/supervisor/internal_flash.c2
-rw-r--r--ports/stm/supervisor/internal_flash.h2
-rw-r--r--ports/stm/supervisor/port.c2
-rw-r--r--ports/stm/supervisor/usb.c7
-rw-r--r--ports/stm/tools/parse_af_csv.py4
-rw-r--r--ports/stm/tools/parse_pins_csv.py2
-rw-r--r--ports/stm/tools/pins.csv93
-rw-r--r--ports/stm/tools/stm32f767_af.csv168
-rw-r--r--ports/unix/fdfile.h2
-rw-r--r--ports/unix/file.c2
-rw-r--r--ports/unix/gccollect.c2
-rw-r--r--ports/unix/input.c2
-rw-r--r--ports/unix/main.c2
-rw-r--r--ports/unix/modffi.c2
-rw-r--r--ports/unix/modmachine.c2
-rw-r--r--ports/unix/modos.c2
-rw-r--r--ports/unix/modtime.c2
-rw-r--r--ports/unix/moduos_vfs.c2
-rw-r--r--ports/unix/moduselect.c2
-rw-r--r--ports/unix/modusocket.c2
-rw-r--r--ports/unix/mpconfigport.h2
-rw-r--r--ports/unix/mpconfigport_coverage.h2
-rw-r--r--ports/unix/mpconfigport_fast.h2
-rw-r--r--ports/unix/mpconfigport_freedos.h2
-rw-r--r--ports/unix/mpconfigport_minimal.h2
-rw-r--r--ports/unix/mpconfigport_nanbox.h2
-rw-r--r--ports/unix/mphalport.h2
-rw-r--r--ports/unix/mpthreadport.c2
-rw-r--r--ports/unix/mpthreadport.h2
-rw-r--r--ports/unix/qstrdefsport.h2
-rw-r--r--ports/unix/unix_mphal.c2
-rw-r--r--py/argcheck.c2
-rw-r--r--py/asmarm.c2
-rw-r--r--py/asmarm.h2
-rw-r--r--py/asmbase.c2
-rw-r--r--py/asmbase.h2
-rw-r--r--py/asmthumb.c2
-rw-r--r--py/asmthumb.h2
-rw-r--r--py/asmx64.c2
-rw-r--r--py/asmx64.h2
-rw-r--r--py/asmx86.c2
-rw-r--r--py/asmx86.h2
-rw-r--r--py/asmxtensa.c2
-rw-r--r--py/asmxtensa.h2
-rw-r--r--py/bc.c2
-rw-r--r--py/bc.h2
-rw-r--r--py/bc0.h2
-rw-r--r--py/binary.c2
-rw-r--r--py/binary.h2
-rw-r--r--py/builtin.h2
-rw-r--r--py/builtinevex.c2
-rw-r--r--py/builtinhelp.c2
-rw-r--r--py/builtinimport.c2
-rw-r--r--py/circuitpy_defns.mk18
-rw-r--r--py/circuitpy_mpconfig.h33
-rw-r--r--py/circuitpy_mpconfig.mk14
-rw-r--r--py/compile.c9
-rw-r--r--py/compile.h2
-rw-r--r--py/emit.h2
-rw-r--r--py/emitbc.c2
-rw-r--r--py/emitcommon.c2
-rw-r--r--py/emitglue.c4
-rw-r--r--py/emitglue.h2
-rw-r--r--py/emitinlinethumb.c2
-rw-r--r--py/emitinlinextensa.c2
-rw-r--r--py/emitnative.c2
-rw-r--r--py/formatfloat.c2
-rw-r--r--py/formatfloat.h2
-rw-r--r--py/frozenmod.c2
-rw-r--r--py/frozenmod.h2
-rwxr-xr-xpy/gc.c18
-rw-r--r--py/gc.h2
-rw-r--r--py/grammar.h2
-rw-r--r--py/ioctl.h2
-rw-r--r--py/lexer.c2
-rw-r--r--py/lexer.h2
-rw-r--r--py/malloc.c2
-rw-r--r--py/map.c2
-rw-r--r--py/misc.h2
-rw-r--r--py/modarray.c2
-rw-r--r--py/modbuiltins.c2
-rw-r--r--py/modcmath.c2
-rw-r--r--py/modcollections.c2
-rw-r--r--py/modgc.c2
-rw-r--r--py/modio.c2
-rw-r--r--py/modmath.c2
-rw-r--r--py/modmicropython.c2
-rw-r--r--py/modstruct.c2
-rw-r--r--py/modsys.c2
-rw-r--r--py/modthread.c2
-rw-r--r--py/moduerrno.c2
-rwxr-xr-xpy/mpconfig.h2
-rw-r--r--py/mperrno.h2
-rw-r--r--py/mphal.h2
-rw-r--r--py/mpprint.c2
-rw-r--r--py/mpprint.h2
-rw-r--r--py/mpstate.c2
-rw-r--r--py/mpstate.h2
-rw-r--r--py/mpthread.h2
-rw-r--r--py/mpz.c6
-rw-r--r--py/mpz.h2
-rw-r--r--py/nativeglue.c2
-rw-r--r--py/nlr.c2
-rw-r--r--py/nlr.h2
-rw-r--r--py/nlrsetjmp.c2
-rw-r--r--py/nlrthumb.c2
-rw-r--r--py/nlrx64.c2
-rw-r--r--py/nlrx86.c2
-rw-r--r--py/nlrxtensa.c2
-rw-r--r--py/obj.c2
-rw-r--r--py/obj.h4
-rw-r--r--py/objarray.c68
-rw-r--r--py/objarray.h2
-rw-r--r--py/objattrtuple.c2
-rw-r--r--py/objbool.c2
-rw-r--r--py/objboundmeth.c2
-rw-r--r--py/objcell.c2
-rw-r--r--py/objclosure.c2
-rw-r--r--py/objcomplex.c2
-rw-r--r--py/objdict.c2
-rw-r--r--py/objenumerate.c2
-rw-r--r--py/objexcept.c2
-rw-r--r--py/objexcept.h2
-rw-r--r--py/objfilter.c2
-rw-r--r--py/objfloat.c2
-rw-r--r--py/objfun.c2
-rw-r--r--py/objfun.h2
-rw-r--r--py/objgenerator.c21
-rw-r--r--py/objgenerator.h2
-rw-r--r--py/objgetitemiter.c2
-rw-r--r--py/objint.c2
-rw-r--r--py/objint.h2
-rw-r--r--py/objint_longlong.c2
-rw-r--r--py/objint_mpz.c2
-rw-r--r--py/objlist.c2
-rw-r--r--py/objlist.h2
-rw-r--r--py/objmap.c2
-rw-r--r--py/objmodule.c2
-rw-r--r--py/objmodule.h2
-rw-r--r--py/objnamedtuple.c2
-rw-r--r--py/objnamedtuple.h2
-rw-r--r--py/objnone.c2
-rw-r--r--py/objobject.c2
-rw-r--r--py/objproperty.c2
-rw-r--r--py/objproperty.h2
-rw-r--r--py/objrange.c2
-rw-r--r--py/objreversed.c2
-rw-r--r--py/objset.c2
-rw-r--r--py/objsingleton.c2
-rw-r--r--py/objslice.c2
-rw-r--r--py/objstr.c2
-rw-r--r--py/objstr.h6
-rw-r--r--py/objstringio.c2
-rw-r--r--py/objstringio.h2
-rw-r--r--py/objstrunicode.c2
-rw-r--r--py/objtuple.c2
-rw-r--r--py/objtuple.h2
-rw-r--r--py/objtype.c2
-rw-r--r--py/objtype.h2
-rw-r--r--py/objzip.c2
-rw-r--r--py/opmethods.c2
-rw-r--r--py/parse.c2
-rw-r--r--py/parse.h2
-rw-r--r--py/parsenum.c2
-rw-r--r--py/parsenum.h2
-rw-r--r--py/parsenumbase.c2
-rw-r--r--py/parsenumbase.h2
-rw-r--r--py/persistentcode.c2
-rw-r--r--py/persistentcode.h2
-rw-r--r--py/py.mk5
-rw-r--r--py/pystack.c2
-rw-r--r--py/pystack.h2
-rwxr-xr-xpy/qstr.c2
-rw-r--r--py/qstr.h2
-rw-r--r--py/qstrdefs.h2
-rw-r--r--py/reader.c2
-rw-r--r--py/reader.h2
-rw-r--r--py/repl.c2
-rw-r--r--py/repl.h2
-rw-r--r--py/runtime.c2
-rw-r--r--py/runtime.h2
-rw-r--r--py/runtime0.h3
-rw-r--r--py/scheduler.c2
-rw-r--r--py/scope.c2
-rw-r--r--py/scope.h2
-rw-r--r--py/sequence.c2
-rw-r--r--py/showbc.c2
-rw-r--r--py/smallint.c2
-rw-r--r--py/smallint.h2
-rw-r--r--py/stream.c2
-rw-r--r--py/stream.h2
-rw-r--r--py/unicode.c2
-rw-r--r--py/unicode.h2
-rw-r--r--py/vm.c2
-rw-r--r--py/vmentrytable.h2
-rw-r--r--py/vstr.c2
-rw-r--r--py/warning.c2
-rw-r--r--setup.py4
-rw-r--r--shared-bindings/_bleio/Adapter.c28
-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.c20
-rw-r--r--shared-bindings/_bleio/Descriptor.c44
-rw-r--r--shared-bindings/_bleio/PacketBuffer.c14
-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.c27
-rw-r--r--shared-bindings/_pixelbuf/PixelBuf.c28
-rw-r--r--shared-bindings/_pixelbuf/PixelBuf.h2
-rw-r--r--shared-bindings/_pixelbuf/__init__.c4
-rw-r--r--shared-bindings/_stage/Layer.c6
-rw-r--r--shared-bindings/_stage/Text.c4
-rw-r--r--shared-bindings/_stage/__init__.c2
-rw-r--r--shared-bindings/aesio/aes.c7
-rw-r--r--shared-bindings/analogio/AnalogIn.c14
-rw-r--r--shared-bindings/analogio/AnalogIn.h2
-rw-r--r--shared-bindings/analogio/AnalogOut.c12
-rw-r--r--shared-bindings/analogio/AnalogOut.h2
-rw-r--r--shared-bindings/audiobusio/I2SOut.c20
-rw-r--r--shared-bindings/audiobusio/PDMIn.c12
-rw-r--r--shared-bindings/audiocore/RawSample.c12
-rw-r--r--shared-bindings/audiocore/WaveFile.c14
-rw-r--r--shared-bindings/audiocore/__init__.c7
-rw-r--r--shared-bindings/audioio/AudioOut.c20
-rw-r--r--shared-bindings/audioio/__init__.c16
-rw-r--r--shared-bindings/audiomixer/Mixer.c18
-rw-r--r--shared-bindings/audiomixer/MixerVoice.c10
-rw-r--r--shared-bindings/audiomp3/MP3Decoder.c20
-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.c112
-rw-r--r--shared-bindings/busio/OneWire.c14
-rw-r--r--shared-bindings/busio/SPI.c31
-rw-r--r--shared-bindings/busio/SPI.h4
-rw-r--r--shared-bindings/busio/UART.c51
-rw-r--r--shared-bindings/busio/UART.h10
-rw-r--r--shared-bindings/countio/Counter.c12
-rw-r--r--shared-bindings/digitalio/DigitalInOut.c32
-rw-r--r--shared-bindings/digitalio/DigitalInOut.h2
-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.c35
-rw-r--r--shared-bindings/displayio/EPaperDisplay.c14
-rw-r--r--shared-bindings/displayio/FourWire.c6
-rw-r--r--shared-bindings/displayio/Group.c31
-rw-r--r--shared-bindings/displayio/I2CDisplay.c6
-rw-r--r--shared-bindings/displayio/OnDiskBitmap.c6
-rw-r--r--shared-bindings/displayio/Palette.c25
-rw-r--r--shared-bindings/displayio/ParallelBus.c6
-rw-r--r--shared-bindings/displayio/Shape.c4
-rw-r--r--shared-bindings/displayio/TileGrid.c24
-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.c17
-rw-r--r--shared-bindings/gamepadshift/GamePadShift.c6
-rw-r--r--shared-bindings/gnss/GNSS.c46
-rw-r--r--shared-bindings/gnss/GNSS.h28
-rw-r--r--shared-bindings/gnss/PositionFix.c48
-rw-r--r--shared-bindings/gnss/PositionFix.h28
-rw-r--r--shared-bindings/gnss/SatelliteSystem.c60
-rw-r--r--shared-bindings/gnss/SatelliteSystem.h28
-rw-r--r--shared-bindings/gnss/__init__.c28
-rw-r--r--shared-bindings/i2cperipheral/I2CPeripheral.c26
-rw-r--r--shared-bindings/math/__init__.c80
-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__.c76
-rw-r--r--shared-bindings/memorymonitor/__init__.h49
-rw-r--r--shared-bindings/microcontroller/Pin.c16
-rw-r--r--shared-bindings/microcontroller/Pin.h1
-rw-r--r--shared-bindings/microcontroller/Processor.c10
-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__.c20
-rw-r--r--shared-bindings/multiterminal/__init__.c8
-rw-r--r--shared-bindings/neopixel_write/__init__.c10
-rw-r--r--shared-bindings/network/__init__.c7
-rw-r--r--shared-bindings/network/__init__.h2
-rw-r--r--shared-bindings/nvm/ByteArray.c19
-rw-r--r--shared-bindings/nvm/ByteArray.h2
-rw-r--r--shared-bindings/os/__init__.c30
-rw-r--r--shared-bindings/os/__init__.h2
-rw-r--r--shared-bindings/ps2io/Ps2.c18
-rw-r--r--shared-bindings/pulseio/PWMOut.c14
-rw-r--r--shared-bindings/pulseio/PWMOut.h2
-rw-r--r--shared-bindings/pulseio/PulseIn.c26
-rw-r--r--shared-bindings/pulseio/PulseOut.c10
-rw-r--r--shared-bindings/pulseio/PulseOut.h2
-rw-r--r--shared-bindings/random/__init__.c17
-rw-r--r--shared-bindings/rgbmatrix/RGBMatrix.c28
-rw-r--r--shared-bindings/rotaryio/IncrementalEncoder.c10
-rw-r--r--shared-bindings/rtc/RTC.c8
-rw-r--r--shared-bindings/rtc/__init__.c4
-rw-r--r--shared-bindings/sdcardio/SDCard.c183
-rw-r--r--shared-bindings/sdcardio/SDCard.h30
-rw-r--r--shared-bindings/sdcardio/__init__.c47
-rw-r--r--shared-bindings/sdcardio/__init__.h0
-rw-r--r--shared-bindings/sdioio/SDCard.c296
-rw-r--r--shared-bindings/sdioio/SDCard.h66
-rw-r--r--shared-bindings/sdioio/__init__.c47
-rw-r--r--shared-bindings/sdioio/__init__.h0
-rw-r--r--shared-bindings/socket/__init__.c33
-rw-r--r--shared-bindings/storage/__init__.c42
-rw-r--r--shared-bindings/struct/__init__.c10
-rwxr-xr-xshared-bindings/supervisor/Runtime.c6
-rwxr-xr-xshared-bindings/supervisor/Runtime.h2
-rw-r--r--shared-bindings/supervisor/__init__.c2
-rw-r--r--shared-bindings/terminalio/Terminal.c4
-rw-r--r--shared-bindings/time/__init__.c18
-rw-r--r--shared-bindings/touchio/TouchIn.c16
-rw-r--r--shared-bindings/touchio/TouchIn.h2
-rw-r--r--shared-bindings/uheap/__init__.c2
-rw-r--r--shared-bindings/ulab/__init__.pyi2
-rw-r--r--shared-bindings/ulab/filter/__init__.pyi17
-rw-r--r--shared-bindings/usb_hid/Device.c8
-rw-r--r--shared-bindings/usb_hid/Device.h2
-rw-r--r--shared-bindings/usb_hid/__init__.c2
-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.c4
-rw-r--r--shared-bindings/vectorio/Polygon.c21
-rw-r--r--shared-bindings/vectorio/Rectangle.c2
-rw-r--r--shared-bindings/vectorio/VectorShape.c8
-rw-r--r--shared-bindings/watchdog/WatchDogMode.c10
-rw-r--r--shared-bindings/watchdog/WatchDogTimer.c10
-rw-r--r--shared-bindings/wiznet/__init__.c9
-rw-r--r--shared-bindings/wiznet/wiznet5k.c10
-rw-r--r--shared-module/audiomp3/MP3Decoder.c54
-rw-r--r--shared-module/audiomp3/MP3Decoder.h2
-rw-r--r--shared-module/bitbangio/I2C.c2
-rw-r--r--shared-module/bitbangio/SPI.c2
-rw-r--r--shared-module/board/__init__.c2
-rw-r--r--shared-module/displayio/Display.c12
-rw-r--r--shared-module/displayio/Display.h4
-rw-r--r--shared-module/displayio/EPaperDisplay.c4
-rw-r--r--shared-module/displayio/EPaperDisplay.h1
-rw-r--r--shared-module/displayio/__init__.c4
-rw-r--r--shared-module/framebufferio/FramebufferDisplay.c17
-rw-r--r--shared-module/framebufferio/FramebufferDisplay.h1
-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/network/__init__.h2
-rw-r--r--shared-module/os/__init__.c2
-rw-r--r--shared-module/sdcardio/SDCard.c466
-rw-r--r--shared-module/sdcardio/SDCard.h51
-rw-r--r--shared-module/sdcardio/__init__.c0
-rw-r--r--shared-module/sdcardio/__init__.h0
-rw-r--r--shared-module/storage/__init__.c2
-rw-r--r--shared-module/touchio/TouchIn.c3
-rw-r--r--shared-module/vectorio/Polygon.c21
-rw-r--r--shared-module/vectorio/VectorShape.c4
-rw-r--r--shared-module/wiznet/wiznet5k.c2
-rw-r--r--shared-module/wiznet/wiznet5k.h2
-rw-r--r--supervisor/background_callback.h87
-rw-r--r--supervisor/flash.h2
-rw-r--r--supervisor/port.h8
-rw-r--r--supervisor/serial.h2
-rw-r--r--supervisor/shared/background_callback.c138
-rw-r--r--supervisor/shared/external_flash/common_commands.h2
-rw-r--r--supervisor/shared/serial.c2
-rw-r--r--supervisor/shared/tick.c65
-rw-r--r--supervisor/shared/tick.h16
-rw-r--r--supervisor/shared/usb/usb.c15
-rw-r--r--supervisor/stub/internal_flash.c2
-rw-r--r--supervisor/supervisor.mk1
-rw-r--r--supervisor/usb.h9
-rw-r--r--tests/basics/async_coroutine.py13
-rw-r--r--tests/basics/async_coroutine.py.exp1
-rw-r--r--tests/extmod/ujson_load_readinto.py22
-rw-r--r--tests/extmod/ujson_load_readinto.py.exp4
-rwxr-xr-xtests/run-tests2
-rw-r--r--tests/skip_if.py23
-rw-r--r--tests/thread/mutate_bytearray.py4
-rw-r--r--tests/thread/mutate_dict.py4
-rw-r--r--tests/thread/mutate_instance.py4
-rw-r--r--tests/thread/mutate_list.py4
-rw-r--r--tests/thread/mutate_set.py4
-rw-r--r--tests/thread/stress_aes.py4
-rw-r--r--tests/thread/stress_heap.py4
-rw-r--r--tests/thread/stress_recurse.py4
-rw-r--r--tests/thread/thread_exc1.py4
-rw-r--r--tests/thread/thread_exit1.py4
-rw-r--r--tests/thread/thread_exit2.py4
-rw-r--r--tests/thread/thread_gc1.py4
-rw-r--r--tests/thread/thread_ident1.py4
-rw-r--r--tests/thread/thread_lock1.py4
-rw-r--r--tests/thread/thread_lock2.py4
-rw-r--r--tests/thread/thread_lock3.py4
-rw-r--r--tests/thread/thread_lock4.py4
-rw-r--r--tests/thread/thread_qstr1.py4
-rw-r--r--tests/thread/thread_shared1.py4
-rw-r--r--tests/thread/thread_shared2.py4
-rw-r--r--tests/thread/thread_sleep1.py4
-rw-r--r--tests/thread/thread_stacksize1.py4
-rw-r--r--tests/thread/thread_start1.py4
-rw-r--r--tests/thread/thread_start2.py4
-rwxr-xr-xtools/analyze_heap_dump.py4
-rw-r--r--tools/analyze_mpy.py4
-rwxr-xr-xtools/bootstrap_upip.sh4
-rwxr-xr-xtools/build-stm-latest.sh4
-rw-r--r--tools/build_board_info.py34
-rw-r--r--tools/build_memory_info.py27
-rwxr-xr-xtools/build_release_files.py4
-rw-r--r--tools/chart_code_size.py4
-rwxr-xr-xtools/check_code_size.sh5
-rw-r--r--tools/check_translations.py4
-rw-r--r--tools/ci_new_boards_check.py4
-rwxr-xr-xtools/codestats.sh5
-rw-r--r--tools/convert_release_notes.py30
-rw-r--r--tools/cpboard.py35
-rw-r--r--tools/dfu.py4
-rw-r--r--tools/extract_pyi.py154
-rw-r--r--tools/file2h.py4
-rw-r--r--tools/fixup_translations.py4
-rw-r--r--tools/fonts/ter-u12n.bdf.license3
-rw-r--r--tools/gc_activity.py4
-rw-r--r--tools/gc_activity_between_collects.py4
-rwxr-xr-xtools/gen-changelog.sh4
-rw-r--r--tools/gen_display_resources.py4
-rwxr-xr-xtools/gen_ld_files.py5
-rw-r--r--tools/gen_usb_descriptor.py14
-rw-r--r--tools/gendoc.py4
-rwxr-xr-xtools/git-checkout-latest-tag.sh5
-rw-r--r--tools/hid_report_descriptors.py23
-rw-r--r--tools/insert-usb-ids.py4
-rw-r--r--tools/join_bins.py4
-rwxr-xr-xtools/make-frozen.py5
-rwxr-xr-xtools/mksdiodata.py40
-rwxr-xr-xtools/mpy-tool.py27
-rwxr-xr-xtools/mpy_bin2res.py5
-rwxr-xr-xtools/mpy_cross_all.py5
-rwxr-xr-xtools/preprocess_frozen_modules.py5
-rwxr-xr-xtools/print_status.py4
-rwxr-xr-xtools/pyboard.py29
-rwxr-xr-xtools/pydfu.py9
-rwxr-xr-xtools/tinytest-codegen.py4
-rw-r--r--tools/upip.py10
-rw-r--r--tools/upip_utarfile.py4
823 files changed, 18411 insertions, 5539 deletions
diff --git a/.gitattributes b/.gitattributes
index 7d1fdfe33..5ebde95f0 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1,3 +1,7 @@
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+#
+# SPDX-License-Identifier: MIT
+
# Per default everything gets normalized and gets LF line endings on checkout.
* text eol=lf
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 8ddb8bbd4..406f6c43b 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -1,3 +1,7 @@
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+#
+# SPDX-License-Identifier: MIT
+
name: Build CI
on:
@@ -22,7 +26,9 @@ jobs:
fetch-depth: 0
- run: git fetch --recurse-submodules=no https://github.com/adafruit/circuitpython refs/tags/*:refs/tags/*
- name: CircuitPython version
- run: git describe --dirty --tags
+ run: |
+ git describe --dirty --tags
+ echo "::set-env name=CP_VERSION::$(git describe --dirty --tags)"
- name: Set up Python 3.8
uses: actions/setup-python@v1
with:
@@ -31,7 +37,7 @@ jobs:
run: |
sudo apt-get install -y eatmydata
sudo eatmydata apt-get install -y gettext librsvg2-bin mingw-w64
- pip install requests sh click setuptools cpp-coveralls "Sphinx<4" sphinx-rtd-theme recommonmark sphinx-autoapi sphinxcontrib-svg2pdfconverter polib pyyaml astroid
+ pip install requests sh click setuptools cpp-coveralls "Sphinx<4" sphinx-rtd-theme recommonmark sphinx-autoapi sphinxcontrib-svg2pdfconverter polib pyyaml astroid isort black
- name: Versions
run: |
gcc --version
@@ -68,7 +74,7 @@ jobs:
name: stubs
path: circuitpython-stubs*
- name: Docs
- run: sphinx-build -E -W -b html . _build/html
+ run: sphinx-build -E -W -b html -D version=${{ env.CP_VERSION }} -D release=${{ env.CP_VERSION }} . _build/html
- uses: actions/upload-artifact@v2
with:
name: docs
@@ -147,6 +153,7 @@ jobs:
- "arduino_zero"
- "bast_pro_mini_m0"
- "bdmicro_vina_m0"
+ - "bless_dev_board_multi_sensor"
- "capablerobot_usbhub"
- "catwan_usbstick"
- "circuitbrains_basic_m0"
@@ -188,6 +195,7 @@ jobs:
- "hallowing_m0_express"
- "hallowing_m4_express"
- "hiibot_bluefi"
+ - "ikigaisense_vita"
- "imxrt1010_evk"
- "imxrt1020_evk"
- "imxrt1060_evk"
@@ -196,6 +204,8 @@ jobs:
- "itsybitsy_nrf52840_express"
- "kicksat-sprite"
- "loc_ber_m4_base_board"
+ - "makerdiary_m60_keyboard"
+ - "makerdiary_nrf52840_m2_devkit"
- "makerdiary_nrf52840_mdk"
- "makerdiary_nrf52840_mdk_usb_dongle"
- "meowbit_v121"
@@ -207,6 +217,7 @@ jobs:
- "mini_sam_m4"
- "monster_m4sk"
- "ndgarage_ndbit6"
+ - "ndgarage_ndbit6_v2"
- "nfc_copy_cat"
- "nice_nano"
- "nucleo_f746zg"
@@ -236,6 +247,7 @@ jobs:
- "pyportal"
- "pyportal_titano"
- "pyruler"
+ - "raytac_mdbt50q-db-40"
- "robohatmm1_m4"
- "sam32"
- "same54_xplained"
@@ -264,6 +276,7 @@ jobs:
- "teensy41"
- "teknikio_bluebird"
- "thunderpack"
+ - "tinkeringtech_scoutmakes_azul"
- "trellis_m4_express"
- "trinket_m0"
- "trinket_m0_haxpress"
@@ -370,6 +383,7 @@ jobs:
board:
- "espressif_saola_1_wroom"
- "espressif_saola_1_wrover"
+ - "unexpectedmaker_feathers2"
steps:
- name: Set up Python 3.8
diff --git a/.github/workflows/create_website_pr.yml b/.github/workflows/create_website_pr.yml
index 9907c08ae..71959ffdc 100644
--- a/.github/workflows/create_website_pr.yml
+++ b/.github/workflows/create_website_pr.yml
@@ -1,3 +1,7 @@
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+#
+# SPDX-License-Identifier: MIT
+
name: Update CircuitPython.org
on:
diff --git a/.gitignore b/.gitignore
index 8a773970d..475a1183f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,7 @@
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+#
+# SPDX-License-Identifier: MIT
+
# Compiled Sources
###################
*.o
diff --git a/.gitmodules b/.gitmodules
index a990aed2a..f09a1e4c6 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,3 +1,7 @@
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+#
+# SPDX-License-Identifier: MIT
+
[submodule "lib/axtls"]
path = lib/axtls
url = https://github.com/pfalcon/axtls
diff --git a/.mailmap b/.mailmap
new file mode 100644
index 000000000..f9d7f47a1
--- /dev/null
+++ b/.mailmap
@@ -0,0 +1,112 @@
+# SPDX-FileCopyrightText: 2020 Diego Elio Pettenò
+#
+# SPDX-License-Identifier: Unlicense
+
+Alexander Steffen <devel.20.webmeister@spamgourmet.com>
+Alexander Steffen <devel.20.webmeister@spamgourmet.com> <Alexander.Steffen@infineon.com>
+Alexander Steffen <devel.20.webmeister@spamgourmet.com> <webmeister@users.noreply.github.com>
+Benjamin Vernoux <bvernoux@gmail.com>
+Brent Rubell <robots199@me.com>
+Brent Rubell <robots199@me.com> <brent@xn.home>
+Brent Rubell <robots199@me.com> <brentru@users.noreply.github.com>
+Carlos <carlos.santiago.diaz@gmail.com>
+Chris Packham <judge.packham@gmail.com>
+Chris Packham <judge.packham@gmail.com> <chris.packham@alliedtelesis.co.nz>
+Damiano Mazzella <damianomazzella@gmail.com>
+Damien George <damien.p.george@gmail.com>
+Dan Halbert <halbert@adafruit.com>
+Dan Halbert <halbert@adafruit.com> <halbert@halwitz.org>
+Daniel Pollard <daniel@learnweaver.com>
+Daniel Pollard <daniel@learnweaver.com> <daniel.pollard@learnweaver.com>
+Daniel Tralamazza <daniel@tralamazza.com>
+Daniel Tralamazza <daniel@tralamazza.com> <tralamazza@users.noreply.github.com>
+David Glaude <david.glaude@gmail.com>
+David Glaude <david.glaude@gmail.com> <dglaude@users.noreply.github.com>
+George Waters <gwatersdev@gmail.com>
+George Waters <gwatersdev@gmail.com> <george@georgeh2os.com>
+Ha Thach <thach@tinyusb.org>
+Henrik Sölver <henrik.solver@gmail.com>
+Ilya Dmitrichenko <errordeveloper@gmail.com>
+Ilya Dmitrichenko <errordeveloper@gmail.com> <ilya@xively.com>
+Jason Pecor <14111408+jpecor@users.noreply.github.com>
+Jeff Epler <jepler@gmail.com>
+Jeff Epler <jepler@gmail.com> <jeff@adafruit.com>
+Jeff Epler <jepler@gmail.com> <jepler@de11.u>
+Jeff Epler <jepler@gmail.com> <jepler@unpythonic.net>
+Jerry Needell <jerryneedell@gmail.com>
+Joe Bakalor <jmbakalor@gmail.com>
+Josh Klar <josh@klar.sh>
+Josh Klar <josh@klar.sh> <j@iv597.com>
+Juan Biondi <juanernestobiondi@gmail.com>
+Juan Biondi <juanernestobiondi@gmail.com> <juanernestobiondi@hotmail.com>
+KalbeAbbas <kalbeabbas142@gmail.com>
+KalbeAbbas <kalbeabbas142@gmail.com> <kalbeabbas@142@gmail.com>
+Kamil Tomaszewski <kamil.tomaszewski@sony.com>
+Kamil Tomaszewski <kamil.tomaszewski@sony.com> <46525824+kamtom480@users.noreply.github.com>
+Kattni <kattni@adafruit.com> <kattni@kittyfish.org>
+Kattni Rembor <kattni@adafruit.com>
+Kenny <WarriorOfWire@users.noreply.github.com>
+Kenny <WarriorOfWire@users.noreply.github.com> <3454741+WarriorOfWire@users.noreply.github.com>
+Kevin Townsend <contact@microbuilder.eu>
+Kevin Townsend <contact@microbuilder.eu> <microbuilder@users.noreply.github.com>
+Krzysztof Blazewicz <blazewicz.krzysztof@gmail.com>
+Krzysztof Blazewicz <blazewicz.krzysztof@gmail.com> <krzysztof.blazewicz@uxeon.com>
+Li Weiwei <liweiwei@yeweitech.org>
+Li Weiwei <liweiwei@yeweitech.org> <liweiwei@yeweitech.com>
+Limor "Ladyada" Fried <limor@ladyada.net>
+Limor "Ladyada" Fried <limor@ladyada.net> <ladyada>
+Lucian Copeland <hierophect@gmail.com>
+Lucian Copeland <hierophect@gmail.com> <hierophect@Lucians-MacBook-Air-2.local>
+Mark Olsson <post@markolsson.se>
+Mark Olsson <post@markolsson.se> <mark@markolsson.se>
+Matt Land <matt-land@users.noreply.github.com>
+Matt Land <matt-land@users.noreply.github.com> <mland@sparefoot.com>
+Matt Wozniski <godlygeek+git@gmail.com>
+Matt Wozniski <godlygeek+git@gmail.com> <mwozniski@bloomberg.net>
+Melissa LeBlanc-Williams <melissa@adafruit.com>
+Melissa LeBlanc-Williams <melissa@adafruit.com> <melissa@melissagirl.com>
+Metallicow <metaliobovinus@gmail.com>
+Metallicow <metaliobovinus@gmail.com> <edg62702@yahoo.com>
+Peter Hinch <peter@hinch.me.uk>
+Peter Hinch <peter@hinch.me.uk> <peterhinch@users.noreply.github.com>
+Radomir Dopieralski <openstack@sheep.art.pl>
+Radomir Dopieralski <openstack@sheep.art.pl> <deshipu@users.noreply.github.com>
+Rafa Gould <rafagoulds@gmail.com>
+Rafa Gould <rafagoulds@gmail.com> <50337143+rafa-gould@users.noreply.github.com>
+Ryan Shaw <ryan.shaw@wisetechglobal.com>
+Ryan Shaw <ryan.shaw@wisetechglobal.com> <ryannathans@hotmail.com>
+Sabas <s@electroniccats.com>
+Sabas <s@electroniccats.com> <s@theinventorhouse.org>
+Sabas <s@electroniccats.com> <sabasjimenez@gmail.com>
+Scott Shawcroft <scott@adafruit.com>
+Scott Shawcroft <scott@adafruit.com> <devnull@unpythonic.net>
+Scott Shawcroft <scott@adafruit.com> <scott.shawcroft@gmail.com>
+Scott Shawcroft <scott@adafruit.com> <scott@chickadee.tech>
+Scott Shawcroft <scott@adafruit.com> <scott@tannewt.org>
+Sebastian Plamauer <oeplse@gmail.com>
+Sebastian Plamauer <oeplse@gmail.com> <oepse@gmail.com>
+Senuros <Senuros@users.noreply.github.com>
+Senuros <Senuros@users.noreply.github.com> <senuros@noreply.github.com>
+Stewart Colborne <tscolborne@outlook.com>
+Stewart Colborne <tscolborne@outlook.com> <tscolborne@hotmail.com>
+TG-Techie <TGTechie01@gmail.com>
+TG-Techie <TGTechie01@gmail.com> <39284876+TG-Techie@users.noreply.github.com>
+Thea Flowers <me@thea.codes>
+Thea Flowers <me@thea.codes> <theaflowers@google.com>
+Tobias Badertscher <badi@baerospace.ch>
+Tobias Badertscher <badi@baerospace.ch> <python@baerospace.ch>
+danicampora <danicampora@gmail.com>
+danicampora <danicampora@gmail.com> <daniel@wipy.io>
+dherrada <dylan.herrada@gmail.com>
+dherrada <dylan.herrada@gmail.com> <33632497+dherrada@users.noreply.github.com>
+dherrada <dylan.herrada@gmail.com> <=>
+glennrub <glennbakke@gmail.com>
+retoc <retoc@users.noreply.github.com>
+retoc <retoc@users.noreply.github.com> <Retoc@noreply.github.com>
+siddacious <nospam187+github@gmail.com>
+siddacious <nospam187+github@gmail.com> <bsiepert@gmail.com>
+siddacious <nospam187+github@gmail.com> <bsiepert@lbl.gov>
+sommersoft <sommersoft@gmail.com>
+sommersoft <sommersoft@gmail.com> <sommersoft@users.noreply.github.com>
+stijn <stijn@ignitron.net>
+stijn <stijn@ignitron.net> <stinos@zoho.com>
diff --git a/.readthedocs.yml b/.readthedocs.yml
index 6ff5f2422..4030bc317 100644
--- a/.readthedocs.yml
+++ b/.readthedocs.yml
@@ -1,3 +1,7 @@
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+#
+# SPDX-License-Identifier: MIT
+
# .readthedocs.yml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
diff --git a/.rosie.yml b/.rosie.yml
index 3f7f9bb1d..52a8802de 100644
--- a/.rosie.yml
+++ b/.rosie.yml
@@ -1,3 +1,7 @@
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+#
+# SPDX-License-Identifier: MIT
+
# This configuration file tells Rosie where to find prebuilt .bin files (Travis
# builds them) and where to find the tests.
diff --git a/ACKNOWLEDGEMENTS.license b/ACKNOWLEDGEMENTS.license
new file mode 100644
index 000000000..d25be1763
--- /dev/null
+++ b/ACKNOWLEDGEMENTS.license
@@ -0,0 +1,3 @@
+SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+
+SPDX-License-Identifier: MIT
diff --git a/BUILDING.md b/BUILDING.md
index bc6002678..10d7d8f4a 100644
--- a/BUILDING.md
+++ b/BUILDING.md
@@ -1,3 +1,8 @@
+<!--
+SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+
+SPDX-License-Identifier: MIT
+-->
# Building CircuitPython
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 0d8592631..29db39793 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -1,3 +1,9 @@
+<!--
+SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+
+SPDX-License-Identifier: MIT
+-->
+
# Contributing
Please note that this project is released with a
[Contributor Code of Conduct](https://github.com/adafruit/circuitpython/blob/main/CODE_OF_CONDUCT.md).
diff --git a/LICENSES/BSD-3-Clause.txt b/LICENSES/BSD-3-Clause.txt
new file mode 100644
index 000000000..0741db789
--- /dev/null
+++ b/LICENSES/BSD-3-Clause.txt
@@ -0,0 +1,26 @@
+Copyright (c) <year> <owner>. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice,
+this list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright notice,
+this list of conditions and the following disclaimer in the documentation
+and/or other materials provided with the distribution.
+
+3. Neither the name of the copyright holder nor the names of its contributors
+may be used to endorse or promote products derived from this software without
+specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/LICENSES/CC-BY-4.0.txt b/LICENSES/CC-BY-4.0.txt
new file mode 100644
index 000000000..3f92dfc5f
--- /dev/null
+++ b/LICENSES/CC-BY-4.0.txt
@@ -0,0 +1,324 @@
+Creative Commons Attribution 4.0 International Creative Commons Corporation
+("Creative Commons") is not a law firm and does not provide legal services
+or legal advice. Distribution of Creative Commons public licenses does not
+create a lawyer-client or other relationship. Creative Commons makes its licenses
+and related information available on an "as-is" basis. Creative Commons gives
+no warranties regarding its licenses, any material licensed under their terms
+and conditions, or any related information. Creative Commons disclaims all
+liability for damages resulting from their use to the fullest extent possible.
+
+Using Creative Commons Public Licenses
+
+Creative Commons public licenses provide a standard set of terms and conditions
+that creators and other rights holders may use to share original works of
+authorship and other material subject to copyright and certain other rights
+specified in the public license below. The following considerations are for
+informational purposes only, are not exhaustive, and do not form part of our
+licenses.
+
+Considerations for licensors: Our public licenses are intended for use by
+those authorized to give the public permission to use material in ways otherwise
+restricted by copyright and certain other rights. Our licenses are irrevocable.
+Licensors should read and understand the terms and conditions of the license
+they choose before applying it. Licensors should also secure all rights necessary
+before applying our licenses so that the public can reuse the material as
+expected. Licensors should clearly mark any material not subject to the license.
+This includes other CC-licensed material, or material used under an exception
+or limitation to copyright. More considerations for licensors : wiki.creativecommons.org/Considerations_for_licensors
+
+Considerations for the public: By using one of our public licenses, a licensor
+grants the public permission to use the licensed material under specified
+terms and conditions. If the licensor's permission is not necessary for any
+reason–for example, because of any applicable exception or limitation to copyright–then
+that use is not regulated by the license. Our licenses grant only permissions
+under copyright and certain other rights that a licensor has authority to
+grant. Use of the licensed material may still be restricted for other reasons,
+including because others have copyright or other rights in the material. A
+licensor may make special requests, such as asking that all changes be marked
+or described. Although not required by our licenses, you are encouraged to
+respect those requests where reasonable. More considerations for the public
+: wiki.creativecommons.org/Considerations_for_licensees Creative Commons Attribution
+4.0 International Public License
+
+By exercising the Licensed Rights (defined below), You accept and agree to
+be bound by the terms and conditions of this Creative Commons Attribution
+4.0 International Public License ("Public License"). To the extent this Public
+License may be interpreted as a contract, You are granted the Licensed Rights
+in consideration of Your acceptance of these terms and conditions, and the
+Licensor grants You such rights in consideration of benefits the Licensor
+receives from making the Licensed Material available under these terms and
+conditions.
+
+Section 1 – Definitions.
+
+a. Adapted Material means material subject to Copyright and Similar Rights
+that is derived from or based upon the Licensed Material and in which the
+Licensed Material is translated, altered, arranged, transformed, or otherwise
+modified in a manner requiring permission under the Copyright and Similar
+Rights held by the Licensor. For purposes of this Public License, where the
+Licensed Material is a musical work, performance, or sound recording, Adapted
+Material is always produced where the Licensed Material is synched in timed
+relation with a moving image.
+
+b. Adapter's License means the license You apply to Your Copyright and Similar
+Rights in Your contributions to Adapted Material in accordance with the terms
+and conditions of this Public License.
+
+c. Copyright and Similar Rights means copyright and/or similar rights closely
+related to copyright including, without limitation, performance, broadcast,
+sound recording, and Sui Generis Database Rights, without regard to how the
+rights are labeled or categorized. For purposes of this Public License, the
+rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights.
+
+d. Effective Technological Measures means those measures that, in the absence
+of proper authority, may not be circumvented under laws fulfilling obligations
+under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996,
+and/or similar international agreements.
+
+e. Exceptions and Limitations means fair use, fair dealing, and/or any other
+exception or limitation to Copyright and Similar Rights that applies to Your
+use of the Licensed Material.
+
+f. Licensed Material means the artistic or literary work, database, or other
+material to which the Licensor applied this Public License.
+
+g. Licensed Rights means the rights granted to You subject to the terms and
+conditions of this Public License, which are limited to all Copyright and
+Similar Rights that apply to Your use of the Licensed Material and that the
+Licensor has authority to license.
+
+h. Licensor means the individual(s) or entity(ies) granting rights under this
+Public License.
+
+i. Share means to provide material to the public by any means or process that
+requires permission under the Licensed Rights, such as reproduction, public
+display, public performance, distribution, dissemination, communication, or
+importation, and to make material available to the public including in ways
+that members of the public may access the material from a place and at a time
+individually chosen by them.
+
+j. Sui Generis Database Rights means rights other than copyright resulting
+from Directive 96/9/EC of the European Parliament and of the Council of 11
+March 1996 on the legal protection of databases, as amended and/or succeeded,
+as well as other essentially equivalent rights anywhere in the world.
+
+k. You means the individual or entity exercising the Licensed Rights under
+this Public License. Your has a corresponding meaning.
+
+Section 2 – Scope.
+
+ a. License grant.
+
+1. Subject to the terms and conditions of this Public License, the Licensor
+hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive,
+irrevocable license to exercise the Licensed Rights in the Licensed Material
+to:
+
+ A. reproduce and Share the Licensed Material, in whole or in part; and
+
+ B. produce, reproduce, and Share Adapted Material.
+
+2. Exceptions and Limitations. For the avoidance of doubt, where Exceptions
+and Limitations apply to Your use, this Public License does not apply, and
+You do not need to comply with its terms and conditions.
+
+ 3. Term. The term of this Public License is specified in Section 6(a).
+
+4. Media and formats; technical modifications allowed. The Licensor authorizes
+You to exercise the Licensed Rights in all media and formats whether now known
+or hereafter created, and to make technical modifications necessary to do
+so. The Licensor waives and/or agrees not to assert any right or authority
+to forbid You from making technical modifications necessary to exercise the
+Licensed Rights, including technical modifications necessary to circumvent
+Effective Technological Measures. For purposes of this Public License, simply
+making modifications authorized by this Section 2(a)(4) never produces Adapted
+Material.
+
+ 5. Downstream recipients.
+
+A. Offer from the Licensor – Licensed Material. Every recipient of the Licensed
+Material automatically receives an offer from the Licensor to exercise the
+Licensed Rights under the terms and conditions of this Public License.
+
+B. No downstream restrictions. You may not offer or impose any additional
+or different terms or conditions on, or apply any Effective Technological
+Measures to, the Licensed Material if doing so restricts exercise of the Licensed
+Rights by any recipient of the Licensed Material.
+
+6. No endorsement. Nothing in this Public License constitutes or may be construed
+as permission to assert or imply that You are, or that Your use of the Licensed
+Material is, connected with, or sponsored, endorsed, or granted official status
+by, the Licensor or others designated to receive attribution as provided in
+Section 3(a)(1)(A)(i).
+
+ b. Other rights.
+
+1. Moral rights, such as the right of integrity, are not licensed under this
+Public License, nor are publicity, privacy, and/or other similar personality
+rights; however, to the extent possible, the Licensor waives and/or agrees
+not to assert any such rights held by the Licensor to the limited extent necessary
+to allow You to exercise the Licensed Rights, but not otherwise.
+
+2. Patent and trademark rights are not licensed under this Public License.
+
+3. To the extent possible, the Licensor waives any right to collect royalties
+from You for the exercise of the Licensed Rights, whether directly or through
+a collecting society under any voluntary or waivable statutory or compulsory
+licensing scheme. In all other cases the Licensor expressly reserves any right
+to collect such royalties.
+
+Section 3 – License Conditions.
+
+Your exercise of the Licensed Rights is expressly made subject to the following
+conditions.
+
+ a. Attribution.
+
+1. If You Share the Licensed Material (including in modified form), You must:
+
+A. retain the following if it is supplied by the Licensor with the Licensed
+Material:
+
+i. identification of the creator(s) of the Licensed Material and any others
+designated to receive attribution, in any reasonable manner requested by the
+Licensor (including by pseudonym if designated);
+
+ ii. a copyright notice;
+
+ iii. a notice that refers to this Public License;
+
+ iv. a notice that refers to the disclaimer of warranties;
+
+v. a URI or hyperlink to the Licensed Material to the extent reasonably practicable;
+
+B. indicate if You modified the Licensed Material and retain an indication
+of any previous modifications; and
+
+C. indicate the Licensed Material is licensed under this Public License, and
+include the text of, or the URI or hyperlink to, this Public License.
+
+2. You may satisfy the conditions in Section 3(a)(1) in any reasonable manner
+based on the medium, means, and context in which You Share the Licensed Material.
+For example, it may be reasonable to satisfy the conditions by providing a
+URI or hyperlink to a resource that includes the required information.
+
+3. If requested by the Licensor, You must remove any of the information required
+by Section 3(a)(1)(A) to the extent reasonably practicable.
+
+4. If You Share Adapted Material You produce, the Adapter's License You apply
+must not prevent recipients of the Adapted Material from complying with this
+Public License.
+
+Section 4 – Sui Generis Database Rights.
+
+Where the Licensed Rights include Sui Generis Database Rights that apply to
+Your use of the Licensed Material:
+
+a. for the avoidance of doubt, Section 2(a)(1) grants You the right to extract,
+reuse, reproduce, and Share all or a substantial portion of the contents of
+the database;
+
+b. if You include all or a substantial portion of the database contents in
+a database in which You have Sui Generis Database Rights, then the database
+in which You have Sui Generis Database Rights (but not its individual contents)
+is Adapted Material; and
+
+c. You must comply with the conditions in Section 3(a) if You Share all or
+a substantial portion of the contents of the database.
+
+For the avoidance of doubt, this Section 4 supplements and does not replace
+Your obligations under this Public License where the Licensed Rights include
+other Copyright and Similar Rights.
+
+Section 5 – Disclaimer of Warranties and Limitation of Liability.
+
+a. Unless otherwise separately undertaken by the Licensor, to the extent possible,
+the Licensor offers the Licensed Material as-is and as-available, and makes
+no representations or warranties of any kind concerning the Licensed Material,
+whether express, implied, statutory, or other. This includes, without limitation,
+warranties of title, merchantability, fitness for a particular purpose, non-infringement,
+absence of latent or other defects, accuracy, or the presence or absence of
+errors, whether or not known or discoverable. Where disclaimers of warranties
+are not allowed in full or in part, this disclaimer may not apply to You.
+
+b. To the extent possible, in no event will the Licensor be liable to You
+on any legal theory (including, without limitation, negligence) or otherwise
+for any direct, special, indirect, incidental, consequential, punitive, exemplary,
+or other losses, costs, expenses, or damages arising out of this Public License
+or use of the Licensed Material, even if the Licensor has been advised of
+the possibility of such losses, costs, expenses, or damages. Where a limitation
+of liability is not allowed in full or in part, this limitation may not apply
+to You.
+
+c. The disclaimer of warranties and limitation of liability provided above
+shall be interpreted in a manner that, to the extent possible, most closely
+approximates an absolute disclaimer and waiver of all liability.
+
+Section 6 – Term and Termination.
+
+a. This Public License applies for the term of the Copyright and Similar Rights
+licensed here. However, if You fail to comply with this Public License, then
+Your rights under this Public License terminate automatically.
+
+b. Where Your right to use the Licensed Material has terminated under Section
+6(a), it reinstates:
+
+1. automatically as of the date the violation is cured, provided it is cured
+within 30 days of Your discovery of the violation; or
+
+ 2. upon express reinstatement by the Licensor.
+
+c. For the avoidance of doubt, this Section 6(b) does not affect any right
+the Licensor may have to seek remedies for Your violations of this Public
+License.
+
+d. For the avoidance of doubt, the Licensor may also offer the Licensed Material
+under separate terms or conditions or stop distributing the Licensed Material
+at any time; however, doing so will not terminate this Public License.
+
+ e. Sections 1, 5, 6, 7, and 8 survive termination of this Public License.
+
+Section 7 – Other Terms and Conditions.
+
+a. The Licensor shall not be bound by any additional or different terms or
+conditions communicated by You unless expressly agreed.
+
+b. Any arrangements, understandings, or agreements regarding the Licensed
+Material not stated herein are separate from and independent of the terms
+and conditions of this Public License.
+
+Section 8 – Interpretation.
+
+a. For the avoidance of doubt, this Public License does not, and shall not
+be interpreted to, reduce, limit, restrict, or impose conditions on any use
+of the Licensed Material that could lawfully be made without permission under
+this Public License.
+
+b. To the extent possible, if any provision of this Public License is deemed
+unenforceable, it shall be automatically reformed to the minimum extent necessary
+to make it enforceable. If the provision cannot be reformed, it shall be severed
+from this Public License without affecting the enforceability of the remaining
+terms and conditions.
+
+c. No term or condition of this Public License will be waived and no failure
+to comply consented to unless expressly agreed to by the Licensor.
+
+d. Nothing in this Public License constitutes or may be interpreted as a limitation
+upon, or waiver of, any privileges and immunities that apply to the Licensor
+or You, including from the legal processes of any jurisdiction or authority.
+
+Creative Commons is not a party to its public licenses. Notwithstanding, Creative
+Commons may elect to apply one of its public licenses to material it publishes
+and in those instances will be considered the "Licensor." The text of the
+Creative Commons public licenses is dedicated to the public domain under the
+CC0 Public Domain Dedication. Except for the limited purpose of indicating
+that material is shared under a Creative Commons public license or as otherwise
+permitted by the Creative Commons policies published at creativecommons.org/policies,
+Creative Commons does not authorize the use of the trademark "Creative Commons"
+or any other trademark or logo of Creative Commons without its prior written
+consent including, without limitation, in connection with any unauthorized
+modifications to any of its public licenses or any other arrangements, understandings,
+or agreements concerning use of licensed material. For the avoidance of doubt,
+this paragraph does not form part of the public licenses.
+
+Creative Commons may be contacted at creativecommons.org.
diff --git a/LICENSES/MIT.txt b/LICENSES/MIT.txt
new file mode 100644
index 000000000..204b93da4
--- /dev/null
+++ b/LICENSES/MIT.txt
@@ -0,0 +1,19 @@
+MIT License Copyright (c) <year> <copyright holders>
+
+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 (including the next
+paragraph) shall be included in all copies or substantial portions of the
+Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
+OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/LICENSES/OFL-1.1.txt b/LICENSES/OFL-1.1.txt
new file mode 100644
index 000000000..084c9628a
--- /dev/null
+++ b/LICENSES/OFL-1.1.txt
@@ -0,0 +1,90 @@
+Copyright (c) <dates>, <Copyright Holder> (<URL|email>),
+
+with Reserved Font Name <Reserved Font Name>. This Font Software is licensed
+under the SIL Open Font License, Version 1.1.
+
+This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL
+SIL OPEN FONT LICENSE
+
+Version 1.1 - 26 February 2007
+
+PREAMBLE
+
+The goals of the Open Font License (OFL) are to stimulate worldwide development
+of collaborative font projects, to support the font creation efforts of academic
+and linguistic communities, and to provide a free and open framework in which
+fonts may be shared and improved in partnership with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and redistributed
+freely as long as they are not sold by themselves. The fonts, including any
+derivative works, can be bundled, embedded, redistributed and/or sold with
+any software provided that any reserved names are not used by derivative works.
+The fonts and derivatives, however, cannot be released under any other type
+of license. The requirement for fonts to remain under this license does not
+apply to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+
+"Font Software" refers to the set of files released by the Copyright Holder(s)
+under this license and clearly marked as such. This may include source files,
+build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the copyright
+statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting, or
+substituting — in part or in whole — any of the components of the Original
+Version, by changing formats or by porting the Font Software to a new environment.
+
+"Author" refers to any designer, engineer, programmer, technical writer or
+other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of the Font Software, to use, study, copy, merge, embed, modify, redistribute,
+and sell modified and unmodified copies of the Font Software, subject to the
+following conditions:
+
+1) Neither the Font Software nor any of its individual components, in Original
+or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled, redistributed
+and/or sold with any software, provided that each copy contains the above
+copyright notice and this license. These can be included either as stand-alone
+text files, human-readable headers or in the appropriate machine-readable
+metadata fields within text or binary files as long as those fields can be
+easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font Name(s)
+unless explicit written permission is granted by the corresponding Copyright
+Holder. This restriction only applies to the primary font name as presented
+to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font Software
+shall not be used to promote, endorse or advertise any Modified Version, except
+to acknowledge the contribution(s) of the Copyright Holder(s) and the Author(s)
+or with their explicit written permission.
+
+5) The Font Software, modified or unmodified, in part or in whole, must be
+distributed entirely under this license, and must not be distributed under
+any other license. The requirement for fonts to remain under this license
+does not apply to any document created using the Font Software.
+
+TERMINATION
+
+This license becomes null and void if any of the above conditions are not met.
+
+DISCLAIMER
+
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT,
+TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE
+FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL,
+INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT
+SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/LICENSES/Unlicense.txt b/LICENSES/Unlicense.txt
new file mode 100644
index 000000000..24a8f9019
--- /dev/null
+++ b/LICENSES/Unlicense.txt
@@ -0,0 +1,20 @@
+This is free and unencumbered software released into the public domain.
+
+Anyone is free to copy, modify, publish, use, compile, sell, or distribute
+this software, either in source code form or as a compiled binary, for any
+purpose, commercial or non-commercial, and by any means.
+
+In jurisdictions that recognize copyright laws, the author or authors of this
+software dedicate any and all copyright interest in the software to the public
+domain. We make this dedication for the benefit of the public at large and
+to the detriment of our heirs and successors. We intend this dedication to
+be an overt act of relinquishment in perpetuity of all present and future
+rights to this software under copyright law.
+
+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
+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. For more information,
+please refer to <https://unlicense.org/>
diff --git a/Makefile b/Makefile
index 55f64b17d..74d3d88c7 100644
--- a/Makefile
+++ b/Makefile
@@ -1,3 +1,7 @@
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+#
+# SPDX-License-Identifier: MIT
+
# Top-level Makefile for documentation builds and miscellaneous tasks.
#
@@ -243,3 +247,49 @@ stubs:
update-frozen-libraries:
@echo "Updating all frozen libraries to latest tagged version."
cd frozen; for library in *; do cd $$library; ../../tools/git-checkout-latest-tag.sh; cd ..; done
+
+one-of-each: samd21 samd51 esp32s2 litex mimxrt10xx nrf stm
+
+samd21:
+ $(MAKE) -C ports/atmel-samd BOARD=trinket_m0
+
+samd51:
+ $(MAKE) -C ports/atmel-samd BOARD=feather_m4_express
+
+esp32s2:
+ $(MAKE) -C ports/esp32s2 BOARD=espressif_saola_1_wroom
+
+litex:
+ $(MAKE) -C ports/litex BOARD=fomu
+
+mimxrt10xx:
+ $(MAKE) -C ports/mimxrt10xx BOARD=feather_mimxrt1011
+
+nrf:
+ $(MAKE) -C ports/nrf BOARD=feather_nrf52840_express
+
+stm:
+ $(MAKE) -C ports/stm BOARD=feather_stm32f405_express
+
+clean-one-of-each: clean-samd21 clean-samd51 clean-esp32s2 clean-litex clean-mimxrt10xx clean-nrf clean-stm
+
+clean-samd21:
+ $(MAKE) -C ports/atmel-samd BOARD=trinket_m0 clean
+
+clean-samd51:
+ $(MAKE) -C ports/atmel-samd BOARD=feather_m4_express clean
+
+clean-esp32s2:
+ $(MAKE) -C ports/esp32s2 BOARD=espressif_saola_1_wroom clean
+
+clean-litex:
+ $(MAKE) -C ports/litex BOARD=fomu clean
+
+clean-mimxrt10xx:
+ $(MAKE) -C ports/mimxrt10xx BOARD=feather_mimxrt1011 clean
+
+clean-nrf:
+ $(MAKE) -C ports/nrf BOARD=feather_nrf52840_express clean
+
+clean-stm:
+ $(MAKE) -C ports/stm BOARD=feather_stm32f405_express clean
diff --git a/conf.py b/conf.py
index 43f689648..37e611dbb 100644
--- a/conf.py
+++ b/conf.py
@@ -13,6 +13,10 @@
# All configuration values have a default; values that are commented out
# serve to show the default.
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+#
+# SPDX-License-Identifier: MIT
+
import json
import logging
import os
diff --git a/docs/library/index.rst b/docs/library/index.rst
index 6c2e576e7..f847ead0a 100644
--- a/docs/library/index.rst
+++ b/docs/library/index.rst
@@ -70,7 +70,7 @@ CircuitPython/MicroPython-specific libraries
Functionality specific to the CircuitPython/MicroPython implementation is available in
the following libraries. These libraries may change signficantly or be removed in future
-versions of CircuitPtyon.
+versions of CircuitPython.
.. toctree::
:maxdepth: 1
diff --git a/docs/shared_bindings_matrix.py b/docs/shared_bindings_matrix.py
index 02ef68349..7b96c14f2 100644
--- a/docs/shared_bindings_matrix.py
+++ b/docs/shared_bindings_matrix.py
@@ -1,6 +1,6 @@
# The MIT License (MIT)
#
-# Copyright (c) 2019 Michael Schroeder
+# SPDX-FileCopyrightText: Copyright (c) 2019 Michael Schroeder
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
@@ -23,6 +23,7 @@
import json
import os
+import pathlib
import re
import subprocess
import sys
@@ -30,17 +31,27 @@ import sys
SUPPORTED_PORTS = ['atmel-samd', 'esp32s2', 'litex', 'mimxrt10xx', 'nrf', 'stm']
+def get_circuitpython_root_dir():
+ """ The path to the root './circuitpython' directory
+ """
+ file_path = pathlib.Path(__file__).resolve()
+ root_dir = file_path.parent.parent
+
+ return root_dir
+
def get_shared_bindings():
""" Get a list of modules in shared-bindings based on folder names
"""
- return [item for item in os.listdir("./shared-bindings")]
+ shared_bindings_dir = get_circuitpython_root_dir() / "shared-bindings"
+ return [item.name for item in shared_bindings_dir.iterdir()]
def read_mpconfig():
""" Open 'circuitpy_mpconfig.mk' and return the contents.
"""
configs = []
- with open("py/circuitpy_mpconfig.mk") as mpconfig:
+ cpy_mpcfg = get_circuitpython_root_dir() / "py" / "circuitpy_mpconfig.mk"
+ with open(cpy_mpcfg) as mpconfig:
configs = mpconfig.read()
return configs
@@ -120,7 +131,7 @@ def lookup_setting(settings, key, default=''):
key = value[2:-1]
return value
-def support_matrix_by_board():
+def support_matrix_by_board(use_branded_name=True):
""" Compiles a list of the available core modules available for each
board.
"""
@@ -129,20 +140,22 @@ def support_matrix_by_board():
boards = dict()
for port in SUPPORTED_PORTS:
- port_dir = "ports/{}/boards".format(port)
- for entry in os.scandir(port_dir):
+ port_dir = get_circuitpython_root_dir() / "ports" / port
+ for entry in (port_dir / "boards").iterdir():
if not entry.is_dir():
continue
board_modules = []
+ board_name = entry.name
- settings = get_settings_from_makefile(f'ports/{port}', entry.name)
+ settings = get_settings_from_makefile(str(port_dir), entry.name)
- with open(os.path.join(entry.path, "mpconfigboard.h")) as get_name:
- board_contents = get_name.read()
- board_name_re = re.search("(?<=MICROPY_HW_BOARD_NAME)\s+(.+)",
- board_contents)
- if board_name_re:
- board_name = board_name_re.group(1).strip('"')
+ if use_branded_name:
+ with open(entry / "mpconfigboard.h") as get_name:
+ board_contents = get_name.read()
+ board_name_re = re.search(r"(?<=MICROPY_HW_BOARD_NAME)\s+(.+)",
+ board_contents)
+ if board_name_re:
+ board_name = board_name_re.group(1).strip('"')
board_modules = []
for module in base:
diff --git a/docs/static/customstyle.css b/docs/static/customstyle.css
index 3c0bc8424..ce2140e70 100644
--- a/docs/static/customstyle.css
+++ b/docs/static/customstyle.css
@@ -9,7 +9,19 @@
margin: 4px;
}
+/* custom CSS to sticky the ' viewing outdated version'
+ warning
+*/
+.document > .admonition {
+ position: sticky;
+ top: 0px;
+ background-color: salmon;
+ z-index: 2;
+}
+body {
+ overflow-x: unset!important;
+}
/* override table width restrictions */
@media screen and (min-width: 767px) {
diff --git a/docs/static/favicon.ico.license b/docs/static/favicon.ico.license
new file mode 100644
index 000000000..86a3fbfe8
--- /dev/null
+++ b/docs/static/favicon.ico.license
@@ -0,0 +1,3 @@
+SPDX-FileCopyrightText: 2018 Phillip Torrone for Adafruit Industries
+
+SPDX-License-Identifier: CC-BY-4.0
diff --git a/drivers/bus/qspi.h b/drivers/bus/qspi.h
index 31c9d14fc..81587b08b 100644
--- a/drivers/bus/qspi.h
+++ b/drivers/bus/qspi.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2017-2018 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2017-2018 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/drivers/bus/softqspi.c b/drivers/bus/softqspi.c
index 10c599246..87f7c8ae8 100644
--- a/drivers/bus/softqspi.c
+++ b/drivers/bus/softqspi.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2017-2018 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2017-2018 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/drivers/bus/softspi.c b/drivers/bus/softspi.c
index bc12d89d3..feb8e00d3 100644
--- a/drivers/bus/softspi.c
+++ b/drivers/bus/softspi.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2016-2018 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2016-2018 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/drivers/bus/spi.h b/drivers/bus/spi.h
index 6d1b9c2f8..5d150cd38 100644
--- a/drivers/bus/spi.h
+++ b/drivers/bus/spi.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2016-2018 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2016-2018 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/extmod/font_petme128_8x8.h b/extmod/font_petme128_8x8.h
index 9963698b1..632397dfe 100644
--- a/extmod/font_petme128_8x8.h
+++ b/extmod/font_petme128_8x8.h
@@ -1,28 +1,8 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2013, 2014 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.
- */
+// SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+// SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
+//
+// SPDX-License-Identifier: MIT
+
#ifndef MICROPY_INCLUDED_STM32_FONT_PETME128_8X8_H
#define MICROPY_INCLUDED_STM32_FONT_PETME128_8X8_H
diff --git a/extmod/machine_mem.c b/extmod/machine_mem.c
index e0649290e..6c6e11063 100644
--- a/extmod/machine_mem.c
+++ b/extmod/machine_mem.c
@@ -1,28 +1,7 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2013, 2014 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.
- */
+// SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+// SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
+//
+// SPDX-License-Identifier: MIT
#include "py/runtime.h"
#include "extmod/machine_mem.h"
diff --git a/extmod/machine_mem.h b/extmod/machine_mem.h
index a48a52c82..735887c60 100644
--- a/extmod/machine_mem.h
+++ b/extmod/machine_mem.h
@@ -1,28 +1,8 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2015 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.
- */
+// SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+// SPDX-FileCopyrightText: Copyright (c) 2015 Damien P. George
+//
+// SPDX-License-Identifier: MIT
+
#ifndef MICROPY_INCLUDED_EXTMOD_MACHINE_MEM_H
#define MICROPY_INCLUDED_EXTMOD_MACHINE_MEM_H
diff --git a/extmod/machine_pinbase.c b/extmod/machine_pinbase.c
index 6cd14c187..a5e33c560 100644
--- a/extmod/machine_pinbase.c
+++ b/extmod/machine_pinbase.c
@@ -1,28 +1,7 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2016 Paul Sokolovsky
- *
- * 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.
- */
+// Copyright (c) 2016 Paul Sokolovsky
+// SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+//
+// SPDX-License-Identifier: MIT
#include "py/mpconfig.h"
#if MICROPY_PY_MACHINE
diff --git a/extmod/machine_pinbase.h b/extmod/machine_pinbase.h
index c96abbc46..b747563a1 100644
--- a/extmod/machine_pinbase.h
+++ b/extmod/machine_pinbase.h
@@ -1,28 +1,8 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2016 Paul Sokolovsky
- *
- * 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.
- */
+// Copyright (c) 2016 Paul Sokolovsky
+// SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+//
+// SPDX-License-Identifier: MIT
+
#ifndef MICROPY_INCLUDED_EXTMOD_MACHINE_PINBASE_H
#define MICROPY_INCLUDED_EXTMOD_MACHINE_PINBASE_H
diff --git a/extmod/machine_pulse.c b/extmod/machine_pulse.c
index 5f837479d..eaee12b36 100644
--- a/extmod/machine_pulse.c
+++ b/extmod/machine_pulse.c
@@ -1,28 +1,7 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 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.
- */
+// SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+// SPDX-FileCopyrightText: Copyright (c) 2016 Damien P. George
+//
+// SPDX-License-Identifier: MIT
#include "py/runtime.h"
#include "py/mperrno.h"
diff --git a/extmod/machine_pulse.h b/extmod/machine_pulse.h
index e303dca02..a9b0ebc1b 100644
--- a/extmod/machine_pulse.h
+++ b/extmod/machine_pulse.h
@@ -1,28 +1,8 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 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.
- */
+// SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+// SPDX-FileCopyrightText: Copyright (c) 2016 Damien P. George
+//
+// SPDX-License-Identifier: MIT
+
#ifndef MICROPY_INCLUDED_EXTMOD_MACHINE_PULSE_H
#define MICROPY_INCLUDED_EXTMOD_MACHINE_PULSE_H
diff --git a/extmod/machine_signal.c b/extmod/machine_signal.c
index 50501e34f..a215fc388 100644
--- a/extmod/machine_signal.c
+++ b/extmod/machine_signal.c
@@ -1,28 +1,7 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2017 Paul Sokolovsky
- *
- * 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.
- */
+// Copyright (c) 2017 Paul Sokolovsky
+// SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+//
+// SPDX-License-Identifier: MIT
#include "py/mpconfig.h"
#if MICROPY_PY_MACHINE
diff --git a/extmod/machine_signal.h b/extmod/machine_signal.h
index df1c3e2e9..17ffe5563 100644
--- a/extmod/machine_signal.h
+++ b/extmod/machine_signal.h
@@ -1,28 +1,8 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2017 Paul Sokolovsky
- *
- * 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.
- */
+// Copyright (c) 2017 Paul Sokolovsky
+// SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+//
+// SPDX-License-Identifier: MIT
+
#ifndef MICROPY_INCLUDED_EXTMOD_MACHINE_SIGNAL_H
#define MICROPY_INCLUDED_EXTMOD_MACHINE_SIGNAL_H
diff --git a/extmod/misc.h b/extmod/misc.h
index d6f6d859c..3e12e5671 100644
--- a/extmod/misc.h
+++ b/extmod/misc.h
@@ -1,29 +1,9 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2014-2016 Damien P. George
- * Copyright (c) 2016 Paul Sokolovsky
- *
- * 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.
- */
+// Copyright (c) 2016 Paul Sokolovsky
+// SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+// SPDX-FileCopyrightText: Copyright (c) 2014-2016 Damien P. George
+//
+// SPDX-License-Identifier: MIT
+
#ifndef MICROPY_INCLUDED_EXTMOD_MISC_H
#define MICROPY_INCLUDED_EXTMOD_MISC_H
diff --git a/extmod/modbtree.c b/extmod/modbtree.c
index 7cfa9c6af..9f5261b1b 100644
--- a/extmod/modbtree.c
+++ b/extmod/modbtree.c
@@ -1,28 +1,7 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2016 Paul Sokolovsky
- *
- * 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.
- */
+// Copyright (c) 2016 Paul Sokolovsky
+// SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+//
+// SPDX-License-Identifier: MIT
#include <stdio.h>
#include <string.h>
diff --git a/extmod/modframebuf.c b/extmod/modframebuf.c
index c59d1592b..07a50a2f4 100644
--- a/extmod/modframebuf.c
+++ b/extmod/modframebuf.c
@@ -1,28 +1,7 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 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.
- */
+// SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+// SPDX-FileCopyrightText: Copyright (c) 2016 Damien P. George
+//
+// SPDX-License-Identifier: MIT
#include <stdio.h>
#include <string.h>
diff --git a/extmod/modlwip.c b/extmod/modlwip.c
index 776b81ee5..20cc3a659 100644
--- a/extmod/modlwip.c
+++ b/extmod/modlwip.c
@@ -1,30 +1,9 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2013, 2014 Damien P. George
- * Copyright (c) 2015 Galen Hazelwood
- * Copyright (c) 2015-2017 Paul Sokolovsky
- *
- * 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.
- */
+// Copyright (c) 2015 Galen Hazelwood
+// Copyright (c) 2015-2017 Paul Sokolovsky
+// SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+// SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
+//
+// SPDX-License-Identifier: MIT
#include <string.h>
#include <stdio.h>
diff --git a/extmod/modonewire.c b/extmod/modonewire.c
index 53c9456c2..1b085a055 100644
--- a/extmod/modonewire.c
+++ b/extmod/modonewire.c
@@ -1,28 +1,7 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2015-2017 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.
- */
+// SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+// SPDX-FileCopyrightText: Copyright (c) 2015-2017 Damien P. George
+//
+// SPDX-License-Identifier: MIT
#include <stdio.h>
#include <stdint.h>
diff --git a/extmod/modubinascii.c b/extmod/modubinascii.c
index 0f64b2715..32c36eea6 100644
--- a/extmod/modubinascii.c
+++ b/extmod/modubinascii.c
@@ -1,28 +1,7 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2014 Paul Sokolovsky
- *
- * 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.
- */
+// Copyright (c) 2014 Paul Sokolovsky
+// SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+//
+// SPDX-License-Identifier: MIT
#include <stdio.h>
#include <assert.h>
diff --git a/extmod/modubinascii.h b/extmod/modubinascii.h
index fb3169267..eb47e286b 100644
--- a/extmod/modubinascii.h
+++ b/extmod/modubinascii.h
@@ -1,28 +1,8 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2014 Paul Sokolovsky
- *
- * 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.
- */
+// Copyright (c) 2014 Paul Sokolovsky
+// SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+//
+// SPDX-License-Identifier: MIT
+
#ifndef MICROPY_INCLUDED_EXTMOD_MODUBINASCII_H
#define MICROPY_INCLUDED_EXTMOD_MODUBINASCII_H
diff --git a/extmod/moductypes.c b/extmod/moductypes.c
index 451dc29ed..a384f1e2c 100644
--- a/extmod/moductypes.c
+++ b/extmod/moductypes.c
@@ -1,28 +1,7 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2014 Paul Sokolovsky
- *
- * 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.
- */
+// Copyright (c) 2014 Paul Sokolovsky
+// SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+//
+// SPDX-License-Identifier: MIT
#include <assert.h>
#include <string.h>
diff --git a/extmod/moduhashlib.c b/extmod/moduhashlib.c
index 970c63da8..95485de13 100644
--- a/extmod/moduhashlib.c
+++ b/extmod/moduhashlib.c
@@ -1,28 +1,7 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2014 Paul Sokolovsky
- *
- * 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.
- */
+// Copyright (c) 2014 Paul Sokolovsky
+// SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+//
+// SPDX-License-Identifier: MIT
#include <assert.h>
#include <string.h>
diff --git a/extmod/moduheapq.c b/extmod/moduheapq.c
index db17e8ca2..bc4b97ff5 100644
--- a/extmod/moduheapq.c
+++ b/extmod/moduheapq.c
@@ -1,28 +1,7 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2014 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.
- */
+// SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+// SPDX-FileCopyrightText: Copyright (c) 2014 Damien P. George
+//
+// SPDX-License-Identifier: MIT
#include "py/objlist.h"
#include "py/runtime.h"
diff --git a/extmod/modujson.c b/extmod/modujson.c
index 0f93ccb11..431b5e0cf 100644
--- a/extmod/modujson.c
+++ b/extmod/modujson.c
@@ -1,31 +1,12 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2014-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.
- */
+// SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+// SPDX-FileCopyrightText: Copyright (c) 2014-2016 Damien P. George
+//
+// SPDX-License-Identifier: MIT
#include <stdio.h>
+#include "py/binary.h"
+#include "py/objarray.h"
#include "py/objlist.h"
#include "py/objstringio.h"
#include "py/parsenum.h"
@@ -74,6 +55,8 @@ typedef struct _ujson_stream_t {
mp_obj_t stream_obj;
mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode);
int errcode;
+ mp_obj_t python_readinto[2 + 1];
+ mp_obj_array_t bytearray_obj;
byte cur;
} ujson_stream_t;
@@ -94,9 +77,39 @@ STATIC byte ujson_stream_next(ujson_stream_t *s) {
return s->cur;
}
+STATIC mp_uint_t ujson_python_readinto(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode) {
+ ujson_stream_t* s = obj;
+ s->bytearray_obj.items = buf;
+ s->bytearray_obj.len = size;
+ *errcode = 0;
+ mp_obj_t ret = mp_call_method_n_kw(1, 0, s->python_readinto);
+ if (ret == mp_const_none) {
+ *errcode = MP_EAGAIN;
+ return MP_STREAM_ERROR;
+ }
+ return mp_obj_get_int(ret);
+}
+
STATIC mp_obj_t _mod_ujson_load(mp_obj_t stream_obj, bool return_first_json) {
- const mp_stream_p_t *stream_p = mp_get_stream_raise(stream_obj, MP_STREAM_OP_READ);
- ujson_stream_t s = {stream_obj, stream_p->read, 0, 0};
+ const mp_stream_p_t *stream_p = mp_proto_get(MP_QSTR_protocol_stream, stream_obj);
+ ujson_stream_t s;
+ if (stream_p == NULL) {
+ mp_load_method(stream_obj, MP_QSTR_readinto, s.python_readinto);
+ s.bytearray_obj.base.type = &mp_type_bytearray;
+ s.bytearray_obj.typecode = BYTEARRAY_TYPECODE;
+ s.bytearray_obj.free = 0;
+ // len and items are set at read time
+ s.python_readinto[2] = MP_OBJ_FROM_PTR(&s.bytearray_obj);
+ s.stream_obj = &s;
+ s.read = ujson_python_readinto;
+ } else {
+ stream_p = mp_get_stream_raise(stream_obj, MP_STREAM_OP_READ);
+ s.stream_obj = stream_obj;
+ s.read = stream_p->read;
+ s.errcode = 0;
+ s.cur = 0;
+ }
+
JSON_DEBUG("got JSON stream\n");
vstr_t vstr;
vstr_init(&vstr, 8);
diff --git a/extmod/modurandom.c b/extmod/modurandom.c
index 1512a3fd4..a60250efc 100644
--- a/extmod/modurandom.c
+++ b/extmod/modurandom.c
@@ -1,28 +1,7 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2016 Paul Sokolovsky
- *
- * 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.
- */
+// Copyright (c) 2016 Paul Sokolovsky
+// SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+//
+// SPDX-License-Identifier: MIT
#include <assert.h>
#include <string.h>
diff --git a/extmod/modure.c b/extmod/modure.c
index 125afef4d..a20f3ee42 100644
--- a/extmod/modure.c
+++ b/extmod/modure.c
@@ -1,28 +1,7 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2014 Paul Sokolovsky
- *
- * 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.
- */
+// Copyright (c) 2014 Paul Sokolovsky
+// SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+//
+// SPDX-License-Identifier: MIT
#include <stdio.h>
#include <assert.h>
diff --git a/extmod/moduselect.c b/extmod/moduselect.c
index 6c9d18e50..97b14a5f2 100644
--- a/extmod/moduselect.c
+++ b/extmod/moduselect.c
@@ -1,28 +1,7 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2014 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.
- */
+// SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+// SPDX-FileCopyrightText: Copyright (c) 2014 Damien P. George
+//
+// SPDX-License-Identifier: MIT
#include "py/mpconfig.h"
#if MICROPY_PY_USELECT
diff --git a/extmod/modussl_axtls.c b/extmod/modussl_axtls.c
index 032dea09f..7cc2bb3e2 100644
--- a/extmod/modussl_axtls.c
+++ b/extmod/modussl_axtls.c
@@ -1,28 +1,7 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2015-2017 Paul Sokolovsky
- *
- * 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.
- */
+// Copyright (c) 2015-2017 Paul Sokolovsky
+// SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+//
+// SPDX-License-Identifier: MIT
#include <stdio.h>
#include <string.h>
diff --git a/extmod/modussl_mbedtls.c b/extmod/modussl_mbedtls.c
index 9abdeb966..990523173 100644
--- a/extmod/modussl_mbedtls.c
+++ b/extmod/modussl_mbedtls.c
@@ -1,28 +1,7 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2016 Linaro Ltd.
- *
- * 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.
- */
+// Copyright (c) 2016 Linaro Ltd.
+// SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+//
+// SPDX-License-Identifier: MIT
#include "py/mpconfig.h"
#if MICROPY_PY_USSL && MICROPY_SSL_MBEDTLS
diff --git a/extmod/modutimeq.c b/extmod/modutimeq.c
index 99b51016d..bb2b6b335 100644
--- a/extmod/modutimeq.c
+++ b/extmod/modutimeq.c
@@ -1,29 +1,8 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2014 Damien P. George
- * Copyright (c) 2016-2017 Paul Sokolovsky
- *
- * 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.
- */
+// Copyright (c) 2016-2017 Paul Sokolovsky
+// SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+// SPDX-FileCopyrightText: Copyright (c) 2014 Damien P. George
+//
+// SPDX-License-Identifier: MIT
#include <string.h>
diff --git a/extmod/moduzlib.c b/extmod/moduzlib.c
index 3a081bc45..8422e7598 100644
--- a/extmod/moduzlib.c
+++ b/extmod/moduzlib.c
@@ -1,28 +1,7 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2014-2016 Paul Sokolovsky
- *
- * 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.
- */
+// Copyright (c) 2014-2016 Paul Sokolovsky
+// SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+//
+// SPDX-License-Identifier: MIT
#include <stdio.h>
#include <string.h>
diff --git a/extmod/modwebrepl.c b/extmod/modwebrepl.c
index fb4d97358..5b3c6150a 100644
--- a/extmod/modwebrepl.c
+++ b/extmod/modwebrepl.c
@@ -1,28 +1,7 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2016 Paul Sokolovsky
- *
- * 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.
- */
+// Copyright (c) 2016 Paul Sokolovsky
+// SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+//
+// SPDX-License-Identifier: MIT
#include <stdio.h>
#include <stdint.h>
diff --git a/extmod/modwebsocket.c b/extmod/modwebsocket.c
index 496e4b5bb..581af6b58 100644
--- a/extmod/modwebsocket.c
+++ b/extmod/modwebsocket.c
@@ -1,28 +1,7 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2016 Paul Sokolovsky
- *
- * 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.
- */
+// Copyright (c) 2016 Paul Sokolovsky
+// SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+//
+// SPDX-License-Identifier: MIT
#include <stdio.h>
#include <stdint.h>
diff --git a/extmod/modwebsocket.h b/extmod/modwebsocket.h
index 2720147df..46aa0408b 100644
--- a/extmod/modwebsocket.h
+++ b/extmod/modwebsocket.h
@@ -1,3 +1,7 @@
+// SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+//
+// SPDX-License-Identifier: MIT
+
#ifndef MICROPY_INCLUDED_EXTMOD_MODWEBSOCKET_H
#define MICROPY_INCLUDED_EXTMOD_MODWEBSOCKET_H
diff --git a/extmod/ulab b/extmod/ulab
-Subproject 0394801933f6e68a5bc7cdb0da76c7884e8cf70
+Subproject 48cb939839fcf091fcdcdf742530b1b650066a1
diff --git a/extmod/uos_dupterm.c b/extmod/uos_dupterm.c
index 781ec0d46..bd2dc639c 100644
--- a/extmod/uos_dupterm.c
+++ b/extmod/uos_dupterm.c
@@ -1,29 +1,8 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2016 Paul Sokolovsky
- * Copyright (c) 2017 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.
- */
+// Copyright (c) 2016 Paul Sokolovsky
+// SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+// SPDX-FileCopyrightText: Copyright (c) 2017 Damien P. George
+//
+// SPDX-License-Identifier: MIT
#include <string.h>
#include "py/mpconfig.h"
diff --git a/extmod/utime_mphal.c b/extmod/utime_mphal.c
index 0fe3a3ba1..ebbc9ac26 100644
--- a/extmod/utime_mphal.c
+++ b/extmod/utime_mphal.c
@@ -1,29 +1,8 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2013-2016 Damien P. George
- * Copyright (c) 2016 Paul Sokolovsky
- *
- * 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.
- */
+// Copyright (c) 2016 Paul Sokolovsky
+// SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+// SPDX-FileCopyrightText: Copyright (c) 2013-2016 Damien P. George
+//
+// SPDX-License-Identifier: MIT
#include "py/mpconfig.h"
#if MICROPY_PY_UTIME_MP_HAL
diff --git a/extmod/utime_mphal.h b/extmod/utime_mphal.h
index 88a9ed4d3..20b4093d3 100644
--- a/extmod/utime_mphal.h
+++ b/extmod/utime_mphal.h
@@ -1,29 +1,9 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2013-2016 Damien P. George
- * Copyright (c) 2016 Paul Sokolovsky
- *
- * 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.
- */
+// Copyright (c) 2016 Paul Sokolovsky
+// SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+// SPDX-FileCopyrightText: Copyright (c) 2013-2016 Damien P. George
+//
+// SPDX-License-Identifier: MIT
+
#ifndef MICROPY_INCLUDED_EXTMOD_UTIME_MPHAL_H
#define MICROPY_INCLUDED_EXTMOD_UTIME_MPHAL_H
diff --git a/extmod/vfs.c b/extmod/vfs.c
index 2bb4057e7..c9c1fe3c3 100644
--- a/extmod/vfs.c
+++ b/extmod/vfs.c
@@ -1,28 +1,7 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2017 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.
- */
+// SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+// SPDX-FileCopyrightText: Copyright (c) 2017 Damien P. George
+//
+// SPDX-License-Identifier: MIT
#include <stdint.h>
#include <string.h>
diff --git a/extmod/vfs.h b/extmod/vfs.h
index 6c0692365..85958d80d 100644
--- a/extmod/vfs.h
+++ b/extmod/vfs.h
@@ -1,28 +1,8 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2017 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.
- */
+// SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+// SPDX-FileCopyrightText: Copyright (c) 2017 Damien P. George
+//
+// SPDX-License-Identifier: MIT
+
#ifndef MICROPY_INCLUDED_EXTMOD_VFS_H
#define MICROPY_INCLUDED_EXTMOD_VFS_H
diff --git a/extmod/vfs_fat.c b/extmod/vfs_fat.c
index 9cb4d9842..b8f43ee29 100644
--- a/extmod/vfs_fat.c
+++ b/extmod/vfs_fat.c
@@ -1,29 +1,8 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2014 Damien P. George
- * Copyright (c) 2016 Paul Sokolovsky
- *
- * 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.
- */
+// Copyright (c) 2016 Paul Sokolovsky
+// SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+// SPDX-FileCopyrightText: Copyright (c) 2014 Damien P. George
+//
+// SPDX-License-Identifier: MIT
#include "py/mpconfig.h"
#if MICROPY_VFS_FAT
diff --git a/extmod/vfs_fat.h b/extmod/vfs_fat.h
index 08b03d0d1..41f8365ec 100644
--- a/extmod/vfs_fat.h
+++ b/extmod/vfs_fat.h
@@ -1,28 +1,8 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2013, 2014 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.
- */
+// SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+// SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
+//
+// SPDX-License-Identifier: MIT
+
#ifndef MICROPY_INCLUDED_EXTMOD_VFS_FAT_H
#define MICROPY_INCLUDED_EXTMOD_VFS_FAT_H
diff --git a/extmod/vfs_fat_diskio.c b/extmod/vfs_fat_diskio.c
index 0e442d8fa..ac8924394 100644
--- a/extmod/vfs_fat_diskio.c
+++ b/extmod/vfs_fat_diskio.c
@@ -1,31 +1,7 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * Original template for this file comes from:
- * Low level disk I/O module skeleton for FatFs, (C)ChaN, 2013
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2013, 2014 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.
- */
+// SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+// SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
+//
+// SPDX-License-Identifier: MIT
#include "py/mpconfig.h"
#if MICROPY_VFS && MICROPY_VFS_FAT
diff --git a/extmod/vfs_fat_file.c b/extmod/vfs_fat_file.c
index 422f057a8..0642f4a9c 100644
--- a/extmod/vfs_fat_file.c
+++ b/extmod/vfs_fat_file.c
@@ -1,28 +1,7 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2013, 2014 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.
- */
+// SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+// SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
+//
+// SPDX-License-Identifier: MIT
#include "py/mpconfig.h"
#if MICROPY_VFS && MICROPY_VFS_FAT
diff --git a/extmod/vfs_posix.c b/extmod/vfs_posix.c
index 56a5de303..8d81d5175 100644
--- a/extmod/vfs_posix.c
+++ b/extmod/vfs_posix.c
@@ -1,28 +1,7 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2017-2018 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.
- */
+// SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+// SPDX-FileCopyrightText: Copyright (c) 2017-2018 Damien P. George
+//
+// SPDX-License-Identifier: MIT
#include "py/runtime.h"
#include "py/mperrno.h"
diff --git a/extmod/vfs_posix.h b/extmod/vfs_posix.h
index 32299b826..4540baedf 100644
--- a/extmod/vfs_posix.h
+++ b/extmod/vfs_posix.h
@@ -1,28 +1,8 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2018 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.
- */
+// SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+// SPDX-FileCopyrightText: Copyright (c) 2018 Damien P. George
+//
+// SPDX-License-Identifier: MIT
+
#ifndef MICROPY_INCLUDED_EXTMOD_VFS_POSIX_H
#define MICROPY_INCLUDED_EXTMOD_VFS_POSIX_H
diff --git a/extmod/vfs_posix_file.c b/extmod/vfs_posix_file.c
index be455fa28..eefc1d905 100644
--- a/extmod/vfs_posix_file.c
+++ b/extmod/vfs_posix_file.c
@@ -1,28 +1,7 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2013-2018 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.
- */
+// SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+// SPDX-FileCopyrightText: Copyright (c) 2013-2018 Damien P. George
+//
+// SPDX-License-Identifier: MIT
#include "py/runtime.h"
#include "py/stream.h"
diff --git a/extmod/vfs_reader.c b/extmod/vfs_reader.c
index e1ee45a3c..a70061186 100644
--- a/extmod/vfs_reader.c
+++ b/extmod/vfs_reader.c
@@ -1,28 +1,7 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2013-2017 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.
- */
+// SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+// SPDX-FileCopyrightText: Copyright (c) 2013-2017 Damien P. George
+//
+// SPDX-License-Identifier: MIT
#include <stdio.h>
#include <string.h>
diff --git a/extmod/virtpin.c b/extmod/virtpin.c
index 559f99265..fb993946a 100644
--- a/extmod/virtpin.c
+++ b/extmod/virtpin.c
@@ -1,28 +1,7 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2016 Paul Sokolovsky
- *
- * 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.
- */
+// Copyright (c) 2016 Paul Sokolovsky
+// SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+//
+// SPDX-License-Identifier: MIT
#include "extmod/virtpin.h"
#include "py/proto.h"
diff --git a/extmod/virtpin.h b/extmod/virtpin.h
index 591249e48..9b43406bd 100644
--- a/extmod/virtpin.h
+++ b/extmod/virtpin.h
@@ -1,28 +1,8 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2016 Paul Sokolovsky
- *
- * 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.
- */
+// Copyright (c) 2016 Paul Sokolovsky
+// SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+//
+// SPDX-License-Identifier: MIT
+
#ifndef MICROPY_INCLUDED_EXTMOD_VIRTPIN_H
#define MICROPY_INCLUDED_EXTMOD_VIRTPIN_H
diff --git a/frozen/circuitpython-stage b/frozen/circuitpython-stage
-Subproject 0d2c083a2fb57a1562d4806775f45273abbfbfa
+Subproject 9596a5904ed757e6fbffcf03e7aa77ae9ecf522
diff --git a/lib/libc/string0.c b/lib/libc/string0.c
index a2f936237..18bd99361 100644
--- a/lib/libc/string0.c
+++ b/lib/libc/string0.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/lib/libm/math.c b/lib/libm/math.c
index 0e53563bc..670d95ed2 100644
--- a/lib/libm/math.c
+++ b/lib/libm/math.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/lib/mp-readline/readline.c b/lib/mp-readline/readline.c
index 0edaebbfa..432413d50 100644
--- a/lib/mp-readline/readline.c
+++ b/lib/mp-readline/readline.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/lib/mp-readline/readline.h b/lib/mp-readline/readline.h
index 17d4ec60e..9168edafa 100644
--- a/lib/mp-readline/readline.h
+++ b/lib/mp-readline/readline.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/lib/mp3 b/lib/mp3
-Subproject c3c664bf4db6a36d11808dfcbb5dbf7cff1715b
+Subproject bc58a654964c799e972719a63ff12694998f354
diff --git a/lib/netutils/netutils.c b/lib/netutils/netutils.c
index 03418d7e6..4385f5a5e 100644
--- a/lib/netutils/netutils.c
+++ b/lib/netutils/netutils.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
* Copyright (c) 2015 Daniel Campora
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
diff --git a/lib/netutils/netutils.h b/lib/netutils/netutils.h
index 4befc90db..98e1d2493 100644
--- a/lib/netutils/netutils.h
+++ b/lib/netutils/netutils.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
* Copyright (c) 2015 Daniel Campora
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
diff --git a/lib/oofatfs/ffconf.h b/lib/oofatfs/ffconf.h
index 214311b4c..d8485a293 100644
--- a/lib/oofatfs/ffconf.h
+++ b/lib/oofatfs/ffconf.h
@@ -6,7 +6,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013-2017 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013-2017 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/lib/protomatter b/lib/protomatter
-Subproject 9f71088d2c32206c6f0495704ae0c040426d576
+Subproject 761d6437e8cd6a131d51de96974337121a9c716
diff --git a/lib/timeutils/timeutils.c b/lib/timeutils/timeutils.c
index b93a85dee..fdd3426ad 100644
--- a/lib/timeutils/timeutils.c
+++ b/lib/timeutils/timeutils.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
* Copyright (c) 2015 Daniel Campora
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
diff --git a/lib/timeutils/timeutils.h b/lib/timeutils/timeutils.h
index 0ca6bb167..4ba8c7fda 100644
--- a/lib/timeutils/timeutils.h
+++ b/lib/timeutils/timeutils.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
* Copyright (c) 2015 Daniel Campora
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
diff --git a/lib/utils/interrupt_char.c b/lib/utils/interrupt_char.c
index da7f70254..7410ac1e5 100644
--- a/lib/utils/interrupt_char.c
+++ b/lib/utils/interrupt_char.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013-2016 Damien P. George
+ * SPDX-FileCopyrightText: 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
diff --git a/lib/utils/interrupt_char.h b/lib/utils/interrupt_char.h
index e0b1db529..0e5e2fc0c 100644
--- a/lib/utils/interrupt_char.h
+++ b/lib/utils/interrupt_char.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013-2016 Damien P. George
+ * SPDX-FileCopyrightText: 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
diff --git a/lib/utils/printf.c b/lib/utils/printf.c
index 3a4cc2549..e95d778fd 100644
--- a/lib/utils/printf.c
+++ b/lib/utils/printf.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/lib/utils/pyexec.c b/lib/utils/pyexec.c
index c8e369e79..8e99bc209 100755
--- a/lib/utils/pyexec.c
+++ b/lib/utils/pyexec.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/lib/utils/pyexec.h b/lib/utils/pyexec.h
index bde516c59..cef72a76c 100644
--- a/lib/utils/pyexec.h
+++ b/lib/utils/pyexec.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/lib/utils/sys_stdio_mphal.c b/lib/utils/sys_stdio_mphal.c
index c1607dfe8..3a11fa66c 100644
--- a/lib/utils/sys_stdio_mphal.c
+++ b/lib/utils/sys_stdio_mphal.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013-2017 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013-2017 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/locale/ID.po b/locale/ID.po
index ae057fbd7..bd865c054 100644
--- a/locale/ID.po
+++ b/locale/ID.po
@@ -1,27 +1,28 @@
-# SOME DESCRIPTIVE TITLE.
-# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
-# This file is distributed under the same license as the PACKAGE package.
-# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
#
-#, fuzzy
+# SPDX-License-Identifier: MIT
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2020-06-25 11:44-0500\n"
-"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
-"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"POT-Creation-Date: 2020-07-17 18:03-0700\n"
+"PO-Revision-Date: 2020-07-06 18:10+0000\n"
+"Last-Translator: oon arfiandwi <oon.arfiandwi@gmail.com>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
-"Language: \n"
+"Language: ID\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=1; plural=0;\n"
+"X-Generator: Weblate 4.2-dev\n"
#: main.c
msgid ""
"\n"
"Code done running. Waiting for reload.\n"
msgstr ""
+"\n"
+"Kode selesai berjalan. Menunggu memuat ulang.\n"
#: supervisor/shared/safe_mode.c
msgid ""
@@ -29,20 +30,25 @@ msgid ""
"Please file an issue with the contents of your CIRCUITPY drive at \n"
"https://github.com/adafruit/circuitpython/issues\n"
msgstr ""
+"\n"
+"Harap ajukan masalah dengan konten drive CIRCUITPY Anda di\n"
+"https://github.com/adafruit/circuitpython/issues\n"
#: supervisor/shared/safe_mode.c
msgid ""
"\n"
"To exit, please reset the board without "
msgstr ""
+"\n"
+"Untuk keluar, harap setel ulang papan tanpa"
#: py/obj.c
msgid " File \"%q\""
-msgstr ""
+msgstr " File \"%q\""
#: py/obj.c
msgid " File \"%q\", line %d"
-msgstr ""
+msgstr " File \"%q\", baris %d"
#: main.c
msgid " output:\n"
@@ -51,44 +57,56 @@ msgstr "output:\n"
#: py/objstr.c
#, c-format
msgid "%%c requires int or char"
-msgstr ""
+msgstr "%%c harus int atau char"
#: shared-bindings/rgbmatrix/RGBMatrix.c
#, c-format
msgid "%d address pins and %d rgb pins indicate a height of %d, not %d"
+msgstr "pin alamat %d dan pin rgb %d menunjukkan tinggi %d, bukan %d"
+
+#: ports/atmel-samd/common-hal/sdioio/SDCard.c
+msgid "%q failure: %d"
msgstr ""
#: shared-bindings/microcontroller/Pin.c
msgid "%q in use"
-msgstr ""
+msgstr "%q sedang digunakan"
#: py/obj.c
msgid "%q index out of range"
-msgstr ""
+msgstr "%q indeks di luar batas"
#: py/obj.c
msgid "%q indices must be integers, not %s"
-msgstr ""
+msgstr "indeks %q harus bilangan bulat, bukan %s"
#: shared-bindings/vectorio/Polygon.c
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
-#, fuzzy
+#: 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 "buffers harus mempunyai panjang yang sama"
+msgstr "%q harus >= 1"
#: shared-module/vectorio/Polygon.c
msgid "%q must be a tuple of length 2"
-msgstr ""
+msgstr "%q harus berupa tuple dengan panjang 2"
+
+#: ports/atmel-samd/common-hal/sdioio/SDCard.c
+msgid "%q pin invalid"
+msgstr "pin %q tidak valid"
#: shared-bindings/fontio/BuiltinFont.c
msgid "%q should be an int"
-msgstr ""
+msgstr "%q harus berupa int"
#: py/bc.c py/objnamedtuple.c
msgid "%q() takes %d positional arguments but %d were given"
@@ -98,10 +116,14 @@ msgstr "%q() mengambil posisi argumen %d tapi %d yang diberikan"
msgid "'%q' argument required"
msgstr "'%q' argumen dibutuhkan"
+#: py/objarray.c
+msgid "'%q' object is not bytes-like"
+msgstr ""
+
#: py/emitinlinethumb.c py/emitinlinextensa.c
#, c-format
msgid "'%s' expects a label"
-msgstr ""
+msgstr "'%s' mengharapkan sebuah label"
#: py/emitinlinethumb.c py/emitinlinextensa.c
#, c-format
@@ -141,7 +163,7 @@ msgstr "'%s' mengharapkan {r0, r1, ...}"
#: py/emitinlinextensa.c
#, c-format
msgid "'%s' integer %d is not within range %d..%d"
-msgstr ""
+msgstr "'%s' integer %d tidak dalam kisaran %d..%d"
#: py/emitinlinethumb.c
#, c-format
@@ -150,53 +172,53 @@ msgstr "'%s' integer 0x%x tidak cukup didalam mask 0x%x"
#: py/runtime.c
msgid "'%s' object cannot assign attribute '%q'"
-msgstr ""
+msgstr "Objek '%s' tidak dapat menetapkan atribut '%q'"
#: py/proto.c
msgid "'%s' object does not support '%q'"
-msgstr ""
+msgstr "Objek '%s' tidak mendukung '%q'"
#: py/obj.c
#, c-format
msgid "'%s' object does not support item assignment"
-msgstr ""
+msgstr "Objek '%s' tidak mendukung penetapan item"
#: py/obj.c
#, c-format
msgid "'%s' object does not support item deletion"
-msgstr ""
+msgstr "Objek '%s' tidak mendukung penghapusan item"
#: py/runtime.c
msgid "'%s' object has no attribute '%q'"
-msgstr ""
+msgstr "Objek '%s' tidak memiliki atribut '%q'"
#: py/runtime.c
#, c-format
msgid "'%s' object is not an iterator"
-msgstr ""
+msgstr "Objek '%s' bukan iterator"
#: py/objtype.c py/runtime.c
#, c-format
msgid "'%s' object is not callable"
-msgstr ""
+msgstr "Objek '%s' tidak dapat dipanggil"
#: py/runtime.c
#, c-format
msgid "'%s' object is not iterable"
-msgstr ""
+msgstr "'%s' objek tidak dapat diulang"
#: py/obj.c
#, c-format
msgid "'%s' object is not subscriptable"
-msgstr ""
+msgstr "Objek '%s' tidak dapat disubkripsikan"
#: py/objstr.c
msgid "'=' alignment not allowed in string format specifier"
-msgstr ""
+msgstr "'=' perataan tidak diizinkan dalam penentu format string"
#: shared-module/struct/__init__.c
msgid "'S' and 'O' are not supported format types"
-msgstr ""
+msgstr "'S' dan 'O' bukan tipe format yang didukung"
#: py/compile.c
msgid "'align' requires 1 argument"
@@ -204,7 +226,7 @@ msgstr "'align' membutuhkan 1 argumen"
#: py/compile.c
msgid "'async for' or 'async with' outside async function"
-msgstr ""
+msgstr "'async for' atau 'async with' di luar fungsi async"
#: py/compile.c
msgid "'await' outside function"
@@ -244,15 +266,15 @@ msgstr "*x harus menjadi target assignment"
#: py/obj.c
msgid ", in %q\n"
-msgstr ""
+msgstr ", dalam %q\n"
#: py/objcomplex.c
msgid "0.0 to a complex power"
-msgstr ""
+msgstr "0.0 ke kompleks berpangkat"
#: py/modbuiltins.c
msgid "3-arg pow() not supported"
-msgstr ""
+msgstr "pow() 3-arg tidak didukung"
#: ports/atmel-samd/common-hal/countio/Counter.c
#: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c
@@ -260,13 +282,13 @@ msgid "A hardware interrupt channel is already in use"
msgstr "Sebuah channel hardware interrupt sedang digunakan"
#: shared-bindings/_bleio/Address.c
-#, fuzzy, c-format
+#, c-format
msgid "Address must be %d bytes long"
-msgstr "buffers harus mempunyai panjang yang sama"
+msgstr "Alamat harus sepanjang %d byte"
#: shared-bindings/_bleio/Address.c
msgid "Address type out of range"
-msgstr ""
+msgstr "Jenis alamat di luar batas"
#: ports/nrf/common-hal/busio/I2C.c
msgid "All I2C peripherals are in use"
@@ -277,9 +299,8 @@ msgid "All SPI peripherals are in use"
msgstr "Semua perangkat SPI sedang digunakan"
#: ports/nrf/common-hal/busio/UART.c
-#, fuzzy
msgid "All UART peripherals are in use"
-msgstr "Semua perangkat I2C sedang digunakan"
+msgstr "Semua perangkat UART sedang digunakan"
#: ports/atmel-samd/common-hal/audioio/AudioOut.c
msgid "All event channels in use"
@@ -307,11 +328,16 @@ msgstr "Semua timer sedang digunakan"
#: ports/nrf/common-hal/_bleio/Adapter.c
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 ""
+msgstr "AnalogIn tidak didukung pada pin yang diberikan"
#: ports/cxd56/common-hal/analogio/AnalogOut.c
#: ports/mimxrt10xx/common-hal/analogio/AnalogOut.c
@@ -321,7 +347,7 @@ msgstr "fungsionalitas AnalogOut tidak didukung"
#: shared-bindings/analogio/AnalogOut.c
msgid "AnalogOut is only 16 bits. Value must be less than 65536."
-msgstr ""
+msgstr "AnalogOut hanya 16 bit. Nilai harus kurang dari 65536."
#: ports/atmel-samd/common-hal/analogio/AnalogOut.c
msgid "AnalogOut not supported on given pin"
@@ -334,19 +360,24 @@ msgstr "Send yang lain sudah aktif"
#: shared-bindings/pulseio/PulseOut.c
msgid "Array must contain halfwords (type 'H')"
-msgstr ""
+msgstr "Array harus mengandung halfwords (ketik 'H')"
#: shared-bindings/nvm/ByteArray.c
msgid "Array values should be single bytes."
-msgstr ""
+msgstr "Nilai array harus berupa byte tunggal."
-#: shared-bindings/rgbmatrix/RGBMatrix.c
+#: shared-bindings/microcontroller/Pin.c
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 ""
+msgstr "Mencoba alokasi heap ketika MicroPython VM tidak berjalan."
#: main.c
msgid "Auto-reload is off.\n"
@@ -363,7 +394,7 @@ msgstr ""
#: shared-module/displayio/Display.c
#: shared-module/framebufferio/FramebufferDisplay.c
msgid "Below minimum frame rate"
-msgstr ""
+msgstr "Di bawah frame rate minimum"
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
msgid "Bit clock and word select must share a clock unit"
@@ -371,7 +402,7 @@ msgstr "Bit clock dan word harus memiliki kesamaan pada clock unit"
#: shared-bindings/audiobusio/PDMIn.c
msgid "Bit depth must be multiple of 8."
-msgstr ""
+msgstr "Kedalaman bit harus kelipatan 8."
#: ports/mimxrt10xx/common-hal/busio/UART.c
msgid "Both RX and TX required for flow control"
@@ -385,85 +416,91 @@ msgstr "Kedua pin harus mendukung hardware interrut"
#: shared-bindings/framebufferio/FramebufferDisplay.c
#: shared-bindings/rgbmatrix/RGBMatrix.c
msgid "Brightness must be 0-1.0"
-msgstr ""
+msgstr "Kecerahan harus di antara 0-1.0"
#: shared-bindings/supervisor/__init__.c
msgid "Brightness must be between 0 and 255"
-msgstr ""
+msgstr "Brightness harus di antara 0 dan 255"
#: shared-bindings/displayio/Display.c
#: shared-bindings/framebufferio/FramebufferDisplay.c
msgid "Brightness not adjustable"
-msgstr ""
+msgstr "Brightness tidak bisa disesuaikan"
#: shared-bindings/_bleio/UUID.c
#, c-format
msgid "Buffer + offset too small %d %d %d"
-msgstr ""
+msgstr "Buffer + offset terlalu kecil %d %d %d"
#: shared-module/usb_hid/Device.c
#, c-format
msgid "Buffer incorrect size. Should be %d bytes."
-msgstr ""
+msgstr "Ukuran buffer salah. Seharusnya %d byte."
#: shared-bindings/displayio/Display.c
#: shared-bindings/framebufferio/FramebufferDisplay.c
msgid "Buffer is not a bytearray."
-msgstr ""
+msgstr "Buffer bukan bytearray."
#: shared-bindings/displayio/Display.c
#: shared-bindings/framebufferio/FramebufferDisplay.c
msgid "Buffer is too small"
-msgstr ""
+msgstr "Buffer terlalu kecil"
#: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c
#, c-format
msgid "Buffer length %d too big. It must be less than %d"
-msgstr ""
+msgstr "Panjang buffer %d terlalu besar. Itu harus kurang dari %d"
+
+#: ports/atmel-samd/common-hal/sdioio/SDCard.c
+#: ports/cxd56/common-hal/sdioio/SDCard.c shared-module/sdcardio/SDCard.c
+msgid "Buffer length must be a multiple of 512"
+msgstr "Panjang buffer harus kelipatan 512"
#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c
msgid "Buffer must be at least length 1"
-msgstr ""
+msgstr "Penyangga harus memiliki panjang setidaknya 1"
#: ports/nrf/common-hal/_bleio/PacketBuffer.c
msgid "Buffer too large and unable to allocate"
-msgstr ""
+msgstr "Buffer terlalu besar dan tidak dapat dialokasikan"
#: shared-bindings/_bleio/PacketBuffer.c
#, c-format
msgid "Buffer too short by %d bytes"
-msgstr ""
+msgstr "Buffer terlalu pendek untuk %d byte"
#: ports/atmel-samd/common-hal/displayio/ParallelBus.c
#: ports/nrf/common-hal/displayio/ParallelBus.c
-#, fuzzy, c-format
+#, c-format
msgid "Bus pin %d is already in use"
-msgstr "DAC sudah digunakan"
+msgstr "Pin bus %d sudah digunakan"
#: shared-bindings/_bleio/UUID.c
-#, fuzzy
msgid "Byte buffer must be 16 bytes."
-msgstr "buffers harus mempunyai panjang yang sama"
+msgstr "Byte buffer harus 16 byte."
#: shared-bindings/nvm/ByteArray.c
msgid "Bytes must be between 0 and 255."
-msgstr ""
+msgstr "Bytes harus di antara 0 dan 255."
#: shared-bindings/aesio/aes.c
msgid "CBC blocks must be multiples of 16 bytes"
-msgstr ""
+msgstr "Blok CBC harus merupakan kelipatan 16 byte"
#: py/objtype.c
msgid "Call super().__init__() before accessing native object."
-msgstr ""
+msgstr "Panggil super().__init__() sebelum mengakses objek asli."
#: ports/nrf/common-hal/_bleio/Characteristic.c
msgid "Can't set CCCD on local Characteristic"
-msgstr ""
+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 ""
+msgstr "Tidak dapat menghapus nilai"
#: ports/atmel-samd/common-hal/digitalio/DigitalInOut.c
#: ports/mimxrt10xx/common-hal/digitalio/DigitalInOut.c
@@ -472,13 +509,14 @@ msgid "Cannot get pull while in output mode"
msgstr "Tidak bisa mendapatkan pull pada saat mode output"
#: ports/nrf/common-hal/microcontroller/Processor.c
-#, fuzzy
msgid "Cannot get temperature"
-msgstr "Tidak bisa mendapatkan temperatur. status: 0x%02x"
+msgstr "Tidak bisa mendapatkan suhu"
#: shared-bindings/_bleio/Adapter.c
msgid "Cannot have scan responses for extended, connectable advertisements."
msgstr ""
+"Tidak dapat memiliki respon pindaian untuk penyebaran yang terhubung dan "
+"diperluas."
#: ports/atmel-samd/common-hal/audioio/AudioOut.c
msgid "Cannot output both channels on the same pin"
@@ -488,15 +526,15 @@ msgstr ""
#: shared-module/bitbangio/SPI.c
msgid "Cannot read without MISO pin."
-msgstr ""
+msgstr "Tidak dapat membaca tanpa pin MISO."
#: shared-bindings/audiobusio/PDMIn.c
msgid "Cannot record to a file"
-msgstr ""
+msgstr "Tidak dapat merekam ke file"
#: shared-module/storage/__init__.c
msgid "Cannot remount '/' when USB is active."
-msgstr ""
+msgstr "Tidak dapat memasang kembali '/' ketika USB aktif."
#: ports/atmel-samd/common-hal/microcontroller/__init__.c
#: ports/cxd56/common-hal/microcontroller/__init__.c
@@ -508,19 +546,19 @@ msgstr ""
#: shared-bindings/digitalio/DigitalInOut.c
msgid "Cannot set value when direction is input."
-msgstr ""
+msgstr "Tidak dapat menetapkan nilai saat arah input."
#: ports/mimxrt10xx/common-hal/busio/UART.c
msgid "Cannot specify RTS or CTS in RS485 mode"
-msgstr ""
+msgstr "Tidak dapat menentukan RTS atau CTS dalam mode RS485"
#: py/objslice.c
msgid "Cannot subclass slice"
-msgstr ""
+msgstr "Tidak dapat membuat subkelas dari irisan"
#: shared-module/bitbangio/SPI.c
msgid "Cannot transfer without MOSI and MISO pins."
-msgstr ""
+msgstr "Tidak dapat transfer tanpa pin MOSI dan MISO."
#: extmod/moductypes.c
msgid "Cannot unambiguously get sizeof scalar"
@@ -529,32 +567,36 @@ msgstr "tidak dapat mendapatkan ukuran scalar secara tidak ambigu"
#: ports/stm/common-hal/pulseio/PWMOut.c
msgid "Cannot vary frequency on a timer that is already in use"
msgstr ""
+"Tidak dapat membuat variasi frekuensi pada penghitung waktu yang sudah "
+"digunakan"
#: shared-module/bitbangio/SPI.c
msgid "Cannot write without MOSI pin."
-msgstr ""
+msgstr "Tidak dapat menulis tanpa pin MOSI."
#: shared-bindings/_bleio/CharacteristicBuffer.c
msgid "CharacteristicBuffer writing not provided"
-msgstr ""
+msgstr "Menulis CharacteristicBuffer tidak tersedia"
#: supervisor/shared/safe_mode.c
msgid "CircuitPython core code crashed hard. Whoops!\n"
-msgstr ""
+msgstr "Kode inti CircuitPython mengalami crash. Aduh!\n"
#: supervisor/shared/safe_mode.c
msgid ""
"CircuitPython is in safe mode because you pressed the reset button during "
"boot. Press again to exit safe mode.\n"
msgstr ""
+"CircuitPython dalam mode aman karena Anda menekan tombol reset saat boot. "
+"Tekan lagi untuk keluar dari mode aman.\n"
#: shared-module/bitbangio/SPI.c
msgid "Clock pin init failed."
-msgstr ""
+msgstr "Init pin clock gagal."
#: shared-module/bitbangio/I2C.c
msgid "Clock stretch too long"
-msgstr ""
+msgstr "Peregangan clock terlalu panjang"
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
msgid "Clock unit in use"
@@ -562,92 +604,97 @@ msgstr "Clock unit sedang digunakan"
#: shared-bindings/_pew/PewPew.c
msgid "Column entry must be digitalio.DigitalInOut"
-msgstr ""
+msgstr "Entri kolom harus digitalio.DigitalInOut"
#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/I2CDisplay.c
#: shared-bindings/displayio/ParallelBus.c
msgid "Command must be an int between 0 and 255"
-msgstr ""
+msgstr "Perintah harus berupa int di antara 0 dan 255"
#: shared-bindings/_bleio/Connection.c
msgid ""
"Connection has been disconnected and can no longer be used. Create a new "
"connection."
msgstr ""
+"Koneksi telah terputus dan tidak dapat lagi digunakan. Buat koneksi baru."
#: py/persistentcode.c
msgid "Corrupt .mpy file"
-msgstr ""
+msgstr "File .mpy rusak"
#: py/emitglue.c
msgid "Corrupt raw code"
-msgstr ""
+msgstr "Kode raw rusak"
#: ports/cxd56/common-hal/gnss/GNSS.c
msgid "Could not initialize GNSS"
msgstr ""
+#: ports/cxd56/common-hal/sdioio/SDCard.c
+msgid "Could not initialize SDCard"
+msgstr ""
+
#: ports/atmel-samd/common-hal/busio/UART.c ports/cxd56/common-hal/busio/UART.c
msgid "Could not initialize UART"
msgstr "Tidak dapat menginisialisasi UART"
#: ports/stm/common-hal/pulseio/PWMOut.c
msgid "Could not initialize channel"
-msgstr ""
+msgstr "Tidak dapat menginisialisasi kanal"
#: ports/stm/common-hal/pulseio/PWMOut.c
msgid "Could not initialize timer"
-msgstr ""
+msgstr "Tidak dapat menginisialisasi timer"
#: ports/stm/common-hal/pulseio/PWMOut.c
msgid "Could not re-init channel"
-msgstr ""
+msgstr "Tidak dapat menginisialisasi ulang kanal"
#: ports/stm/common-hal/pulseio/PWMOut.c
msgid "Could not re-init timer"
-msgstr ""
+msgstr "Tidak dapat menginisialisasi ulang timer"
#: ports/stm/common-hal/pulseio/PWMOut.c
msgid "Could not restart PWM"
-msgstr ""
+msgstr "Tidak dapat memulai ulang PWM"
#: ports/stm/common-hal/pulseio/PWMOut.c
msgid "Could not start PWM"
-msgstr ""
+msgstr "Tidak dapat memulai PWM"
#: ports/stm/common-hal/busio/UART.c
msgid "Could not start interrupt, RX busy"
-msgstr ""
+msgstr "Tidak dapat memulai interupsi, RX sibuk"
#: shared-module/audiomp3/MP3Decoder.c
msgid "Couldn't allocate decoder"
-msgstr ""
+msgstr "Tidak dapat mengalokasikan dekoder"
#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c
#: shared-module/audiomp3/MP3Decoder.c
msgid "Couldn't allocate first buffer"
-msgstr ""
+msgstr "Tidak dapat mengalokasikan penyangga pertama"
#: shared-module/audiomp3/MP3Decoder.c
msgid "Couldn't allocate input buffer"
-msgstr ""
+msgstr "Tidak dapat mengalokasikan penyangga masukan"
#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c
#: shared-module/audiomp3/MP3Decoder.c
msgid "Couldn't allocate second buffer"
-msgstr ""
+msgstr "Tidak dapat mengalokasikan penyangga kedua"
#: supervisor/shared/safe_mode.c
msgid "Crash into the HardFault_Handler."
-msgstr ""
+msgstr "Gagal ke HardFault_Handler."
#: ports/stm/common-hal/analogio/AnalogOut.c
msgid "DAC Channel Init Error"
-msgstr ""
+msgstr "Terjadi kesalahan saat menginisialisasi kanal DAC"
#: ports/stm/common-hal/analogio/AnalogOut.c
msgid "DAC Device Init Error"
-msgstr ""
+msgstr "Terjadi kesalahan saat menginisialisasi perangkat DAC"
#: ports/atmel-samd/common-hal/audioio/AudioOut.c
msgid "DAC already in use"
@@ -656,11 +703,11 @@ msgstr "DAC sudah digunakan"
#: ports/atmel-samd/common-hal/displayio/ParallelBus.c
#: ports/nrf/common-hal/displayio/ParallelBus.c
msgid "Data 0 pin must be byte aligned"
-msgstr ""
+msgstr "Data 0 pin harus byte disejajarkan"
#: shared-module/audiocore/WaveFile.c
msgid "Data chunk must follow fmt chunk"
-msgstr ""
+msgstr "Potongan data harus mengikuti fmt chunk"
#: ports/nrf/common-hal/_bleio/Adapter.c
#, fuzzy
@@ -669,34 +716,34 @@ msgstr "Tidak bisa menyesuaikan data ke dalam paket advertisment"
#: shared-bindings/audiobusio/PDMIn.c
msgid "Destination capacity is smaller than destination_length."
-msgstr ""
+msgstr "Kapasitas tujuan lebih kecil dari destination_length."
#: ports/nrf/common-hal/audiobusio/I2SOut.c
msgid "Device in use"
-msgstr ""
+msgstr "Perangkat sedang digunakan"
#: ports/cxd56/common-hal/digitalio/DigitalInOut.c
msgid "DigitalInOut not supported on given pin"
-msgstr ""
+msgstr "DigitalInOut tidak didukung pada pin yang diberikan"
#: shared-bindings/displayio/Display.c
#: shared-bindings/framebufferio/FramebufferDisplay.c
msgid "Display must have a 16 bit colorspace."
-msgstr ""
+msgstr "Tampilan harus memiliki ruang warna 16 bit."
#: shared-bindings/displayio/Display.c
#: shared-bindings/displayio/EPaperDisplay.c
#: shared-bindings/framebufferio/FramebufferDisplay.c
msgid "Display rotation must be in 90 degree increments"
-msgstr ""
+msgstr "Rotasi tampilan harus dalam kelipatan 90 derajat"
#: shared-bindings/digitalio/DigitalInOut.c
msgid "Drive mode not used when direction is input."
-msgstr ""
+msgstr "Mode kendara tidak digunakan saat arah input."
#: shared-bindings/aesio/aes.c
msgid "ECB only operates on 16 bytes at a time"
-msgstr ""
+msgstr "ECB hanya beroperasi pada 16 byte di satu waktu"
#: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c
#: ports/atmel-samd/common-hal/ps2io/Ps2.c
@@ -709,46 +756,47 @@ msgstr "Channel EXTINT sedang digunakan"
msgid "Error in regex"
msgstr "Error pada regex"
-#: shared-bindings/aesio/aes.c shared-bindings/microcontroller/Pin.c
+#: shared-bindings/aesio/aes.c shared-bindings/busio/SPI.c
+#: shared-bindings/microcontroller/Pin.c
#: shared-bindings/neopixel_write/__init__.c shared-bindings/pulseio/PulseOut.c
#: shared-bindings/terminalio/Terminal.c
msgid "Expected a %q"
-msgstr ""
+msgstr "Diharapkan %q"
#: shared-bindings/_bleio/CharacteristicBuffer.c
#: shared-bindings/_bleio/Descriptor.c shared-bindings/_bleio/PacketBuffer.c
msgid "Expected a Characteristic"
-msgstr ""
+msgstr "Diharapkan sebuah Karakteristik"
#: shared-bindings/_bleio/Characteristic.c
msgid "Expected a Service"
-msgstr ""
+msgstr "Diharapkan sebuah Layanan"
#: shared-bindings/_bleio/Characteristic.c shared-bindings/_bleio/Descriptor.c
#: shared-bindings/_bleio/Service.c
msgid "Expected a UUID"
-msgstr ""
+msgstr "Diharapkan sebuah UUID"
#: shared-bindings/_bleio/Adapter.c
msgid "Expected an Address"
-msgstr ""
+msgstr "Diharapkan sebuah Alamat"
#: shared-module/_pixelbuf/PixelBuf.c
#, c-format
msgid "Expected tuple of length %d, got %d"
-msgstr ""
+msgstr "Diharapkan tuple dengan panjang %d, didapatkan %d"
#: ports/nrf/common-hal/_bleio/Adapter.c
msgid "Extended advertisements with scan response not supported."
-msgstr ""
+msgstr "Penyebaran yang diperluas dengan respon pindai tidak didukung."
#: extmod/ulab/code/fft.c
msgid "FFT is defined for ndarrays only"
-msgstr ""
+msgstr "FFT didefinisikan hanya untuk ndarrays"
#: shared-bindings/ps2io/Ps2.c
msgid "Failed sending command."
-msgstr ""
+msgstr "Gagal mengirim perintah."
#: ports/nrf/sd_mutex.c
#, fuzzy, c-format
@@ -770,15 +818,15 @@ msgstr "Gagal untuk megalokasikan buffer RX dari %d byte"
#: ports/nrf/common-hal/_bleio/Adapter.c
msgid "Failed to connect: internal error"
-msgstr ""
+msgstr "Gagal terhubung: kesalahan internal"
#: ports/nrf/common-hal/_bleio/Adapter.c
msgid "Failed to connect: timeout"
-msgstr ""
+msgstr "Gagal terhubung: habis waktu"
#: shared-module/audiomp3/MP3Decoder.c
msgid "Failed to parse MP3 file"
-msgstr ""
+msgstr "Gagal mengurai file MP3"
#: ports/nrf/sd_mutex.c
#, fuzzy, c-format
@@ -787,43 +835,44 @@ msgstr "Gagal untuk melepaskan mutex, status: 0x%08lX"
#: supervisor/shared/safe_mode.c
msgid "Failed to write internal flash."
-msgstr ""
+msgstr "Gagal menulis flash internal."
#: py/moduerrno.c
msgid "File exists"
-msgstr ""
+msgstr "File sudah ada"
#: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c
msgid "Frequency captured is above capability. Capture Paused."
msgstr ""
+"Frekuensi yang ditangkap berada di atas kemampuan. Penangkapan Ditunda."
#: ports/stm/common-hal/pulseio/PWMOut.c
msgid "Frequency must match existing PWMOut using this timer"
-msgstr ""
+msgstr "Frekuensi harus cocok dengan PWMOut yang ada menggunakan timer ini"
#: shared-bindings/bitbangio/I2C.c shared-bindings/bitbangio/SPI.c
#: shared-bindings/busio/I2C.c shared-bindings/busio/SPI.c
msgid "Function requires lock"
-msgstr ""
+msgstr "Fungsinya membutuhkan kunci"
#: shared-bindings/displayio/Display.c
#: shared-bindings/displayio/EPaperDisplay.c
#: shared-bindings/framebufferio/FramebufferDisplay.c
msgid "Group already used"
-msgstr ""
+msgstr "Grup sudah digunakan"
#: shared-module/displayio/Group.c
msgid "Group full"
-msgstr ""
+msgstr "Grup penuh"
#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/I2C.c
#: ports/stm/common-hal/busio/SPI.c
msgid "Hardware busy, try alternative pins"
-msgstr ""
+msgstr "Perangkat keras sibuk, coba pin alternatif"
#: ports/mimxrt10xx/common-hal/busio/UART.c ports/stm/common-hal/busio/UART.c
msgid "Hardware in use, try alternative pins"
-msgstr ""
+msgstr "Perangkat keras sedang digunakan, coba pin alternatif"
#: extmod/vfs_posix_file.c py/objstringio.c
msgid "I/O operation on closed file"
@@ -831,42 +880,48 @@ msgstr "operasi I/O pada file tertutup"
#: ports/stm/common-hal/busio/I2C.c
msgid "I2C Init Error"
-msgstr ""
+msgstr "Gagal Inisialisasi I2C"
#: shared-bindings/aesio/aes.c
#, c-format
msgid "IV must be %d bytes long"
-msgstr ""
+msgstr "Panjang IV harus %d byte"
#: py/persistentcode.c
msgid ""
"Incompatible .mpy file. Please update all .mpy files. See http://adafru.it/"
"mpy-update for more info."
msgstr ""
+"File .mpy tidak kompatibel. Perbarui semua file .mpy. Lihat http://adafru.it/"
+"mpy-update untuk info lebih lanjut."
#: shared-bindings/_pew/PewPew.c
msgid "Incorrect buffer size"
-msgstr ""
+msgstr "Ukuran penyangga salah"
#: py/moduerrno.c
msgid "Input/output error"
-msgstr ""
+msgstr "Kesalahan input/output"
#: ports/nrf/common-hal/_bleio/__init__.c
msgid "Insufficient authentication"
-msgstr ""
+msgstr "Otentikasi tidak cukup"
#: ports/nrf/common-hal/_bleio/__init__.c
msgid "Insufficient encryption"
-msgstr ""
+msgstr "Enkripsi tidak cukup"
#: ports/stm/common-hal/busio/UART.c
msgid "Internal define error"
-msgstr ""
+msgstr "Kesalahan definisi internal"
#: shared-module/rgbmatrix/RGBMatrix.c
#, c-format
msgid "Internal error #%d"
+msgstr "Kesalahan internal #%d"
+
+#: shared-bindings/sdioio/SDCard.c
+msgid "Invalid %q"
msgstr ""
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
@@ -876,19 +931,19 @@ msgstr "%q pada tidak valid"
#: ports/stm/common-hal/analogio/AnalogIn.c
msgid "Invalid ADC Unit value"
-msgstr ""
+msgstr "Nilai Unit ADC tidak valid"
#: shared-module/displayio/OnDiskBitmap.c
msgid "Invalid BMP file"
-msgstr ""
+msgstr "File BMP tidak valid"
#: ports/stm/common-hal/analogio/AnalogOut.c
msgid "Invalid DAC pin supplied"
-msgstr ""
+msgstr "Pin DAC yang diberikan tidak valid"
#: ports/stm/common-hal/busio/I2C.c
msgid "Invalid I2C pin selection"
-msgstr ""
+msgstr "Pilihan pin I2C tidak valid"
#: ports/atmel-samd/common-hal/pulseio/PWMOut.c
#: ports/cxd56/common-hal/pulseio/PWMOut.c
@@ -898,19 +953,19 @@ msgstr "Frekuensi PWM tidak valid"
#: ports/stm/common-hal/busio/SPI.c
msgid "Invalid SPI pin selection"
-msgstr ""
+msgstr "Pilihan pin SPI tidak valid"
#: ports/stm/common-hal/busio/UART.c
msgid "Invalid UART pin selection"
-msgstr ""
+msgstr "Pilihan pin UART tidak valid"
#: py/moduerrno.c shared-module/rgbmatrix/RGBMatrix.c
msgid "Invalid argument"
-msgstr ""
+msgstr "Argumen tidak valid"
#: shared-module/displayio/Bitmap.c
msgid "Invalid bits per value"
-msgstr ""
+msgstr "Bit per nilai tidak valid"
#: ports/nrf/common-hal/busio/UART.c ports/stm/common-hal/busio/UART.c
msgid "Invalid buffer size"
@@ -918,44 +973,44 @@ msgstr "Ukuran buffer tidak valid"
#: shared-bindings/_pixelbuf/PixelBuf.c
msgid "Invalid byteorder string"
-msgstr ""
+msgstr "String byteorder tidak valid"
#: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c
msgid "Invalid capture period. Valid range: 1 - 500"
-msgstr ""
+msgstr "Periode penangkapan tidak valid. Kisaran yang valid: 1 - 500"
#: shared-bindings/audiomixer/Mixer.c
msgid "Invalid channel count"
-msgstr ""
+msgstr "Jumlah kanal tidak valid"
#: shared-bindings/digitalio/DigitalInOut.c
msgid "Invalid direction."
-msgstr ""
+msgstr "Arah tidak valid."
#: shared-module/audiocore/WaveFile.c
msgid "Invalid file"
-msgstr ""
+msgstr "File tidak valid"
#: shared-module/audiocore/WaveFile.c
msgid "Invalid format chunk size"
-msgstr ""
+msgstr "Ukuran potongan format tidak valid"
#: ports/stm/common-hal/pulseio/PWMOut.c
msgid "Invalid frequency supplied"
-msgstr ""
+msgstr "Frekuensi yang diberikan tidak valid"
#: supervisor/shared/safe_mode.c
msgid "Invalid memory access."
-msgstr ""
+msgstr "Akses memori tidak valid."
#: shared-bindings/bitbangio/SPI.c shared-bindings/busio/SPI.c
msgid "Invalid number of bits"
-msgstr ""
+msgstr "Jumlah bit tidak valid"
#: shared-bindings/bitbangio/SPI.c shared-bindings/busio/SPI.c
#: shared-bindings/displayio/FourWire.c
msgid "Invalid phase"
-msgstr ""
+msgstr "Fase tidak valid"
#: ports/atmel-samd/common-hal/audioio/AudioOut.c
#: ports/atmel-samd/common-hal/touchio/TouchIn.c
@@ -976,7 +1031,8 @@ msgstr "Pin untuk channel kanan tidak valid"
#: ports/atmel-samd/common-hal/busio/UART.c
#: ports/atmel-samd/common-hal/i2cperipheral/I2CPeripheral.c
#: ports/cxd56/common-hal/busio/I2C.c ports/cxd56/common-hal/busio/SPI.c
-#: ports/cxd56/common-hal/busio/UART.c ports/mimxrt10xx/common-hal/busio/I2C.c
+#: ports/cxd56/common-hal/busio/UART.c ports/cxd56/common-hal/sdioio/SDCard.c
+#: ports/mimxrt10xx/common-hal/busio/I2C.c
#: ports/mimxrt10xx/common-hal/busio/SPI.c
#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/I2C.c
msgid "Invalid pins"
@@ -984,44 +1040,44 @@ msgstr "Pin-pin tidak valid"
#: ports/stm/common-hal/pulseio/PWMOut.c
msgid "Invalid pins for PWMOut"
-msgstr ""
+msgstr "Pin untuk PWMOut tidak valid"
#: shared-bindings/bitbangio/SPI.c shared-bindings/busio/SPI.c
#: shared-bindings/displayio/FourWire.c
msgid "Invalid polarity"
-msgstr ""
+msgstr "Polaritas tidak valid"
#: shared-bindings/_bleio/Characteristic.c
msgid "Invalid properties"
-msgstr ""
+msgstr "Properti tidak valid"
#: shared-bindings/microcontroller/__init__.c
msgid "Invalid run mode."
-msgstr ""
+msgstr "Mode operasi tidak valid."
#: shared-module/_bleio/Attribute.c
msgid "Invalid security_mode"
-msgstr ""
+msgstr "security_mode tidak valid"
#: shared-bindings/audiomixer/Mixer.c
msgid "Invalid voice"
-msgstr ""
+msgstr "Suara tidak valid"
#: shared-bindings/audiomixer/Mixer.c
msgid "Invalid voice count"
-msgstr ""
+msgstr "Hitungan suara tidak valid"
#: shared-module/audiocore/WaveFile.c
msgid "Invalid wave file"
-msgstr ""
+msgstr "File wave tidak valid"
#: ports/stm/common-hal/busio/UART.c
msgid "Invalid word/bit length"
-msgstr ""
+msgstr "Panjang kata/bit tidak valid"
#: shared-bindings/aesio/aes.c
msgid "Key must be 16, 24, or 32 bytes long"
-msgstr ""
+msgstr "Panjang kunci harus 16, 24, atau 32 byte"
#: py/compile.c
msgid "LHS of keyword arg must be an id"
@@ -1029,40 +1085,40 @@ msgstr "LHS dari keyword arg harus menjadi sebuah id"
#: shared-module/displayio/Group.c
msgid "Layer already in a group."
-msgstr ""
+msgstr "Layer sudah ada dalam grup."
#: shared-module/displayio/Group.c
msgid "Layer must be a Group or TileGrid subclass."
-msgstr ""
+msgstr "Layer harus sebuah Grup atau subklas dari TileGrid."
#: py/objslice.c
msgid "Length must be an int"
-msgstr ""
+msgstr "Panjang harus berupa int"
#: py/objslice.c
msgid "Length must be non-negative"
-msgstr ""
+msgstr "Panjangnya harus non-negatif"
#: shared-module/bitbangio/SPI.c
msgid "MISO pin init failed."
-msgstr ""
+msgstr "Pin MISO gagal inisialisasi."
#: shared-module/bitbangio/SPI.c
msgid "MOSI pin init failed."
-msgstr ""
+msgstr "Pin MOSI gagal inisialisasi."
#: shared-module/displayio/Shape.c
#, c-format
msgid "Maximum x value when mirrored is %d"
-msgstr ""
+msgstr "Nilai x maksimum ketika dicerminkan adalah %d"
#: supervisor/shared/safe_mode.c
msgid "MicroPython NLR jump failed. Likely memory corruption."
-msgstr ""
+msgstr "Lompatan NLR MicroPython gagal. Kemungkinan kerusakan memori."
#: supervisor/shared/safe_mode.c
msgid "MicroPython fatal error."
-msgstr ""
+msgstr "Kesalahan fatal MicroPython."
#: shared-bindings/audiobusio/PDMIn.c
msgid "Microphone startup delay must be in range 0.0 to 1.0"
@@ -1080,6 +1136,10 @@ msgstr ""
msgid "Must provide MISO or MOSI pin"
msgstr ""
+#: ports/stm/common-hal/busio/SPI.c
+msgid "Must provide SCK pin"
+msgstr ""
+
#: shared-bindings/rgbmatrix/RGBMatrix.c
#, c-format
msgid "Must use a multiple of 6 rgb pins, not %d"
@@ -1336,6 +1396,7 @@ msgstr ""
msgid "Random number generation error"
msgstr ""
+#: shared-bindings/memorymonitor/AllocationSize.c
#: shared-bindings/pulseio/PulseIn.c
msgid "Read-only"
msgstr ""
@@ -1374,6 +1435,10 @@ msgid "Running in safe mode! Not running saved code.\n"
msgstr ""
"Berjalan di mode aman(safe mode)! tidak menjalankan kode yang tersimpan.\n"
+#: shared-module/sdcardio/SDCard.c
+msgid "SD card CSD format not supported"
+msgstr ""
+
#: ports/atmel-samd/common-hal/busio/I2C.c
#: ports/mimxrt10xx/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c
msgid "SDA or SCL needs a pull up"
@@ -1418,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 ""
@@ -2003,6 +2070,10 @@ msgstr ""
msgid "can't send non-None value to a just-started generator"
msgstr ""
+#: shared-module/sdcardio/SDCard.c
+msgid "can't set 512 block size"
+msgstr ""
+
#: py/objnamedtuple.c
msgid "can't set attribute"
msgstr ""
@@ -2129,6 +2200,10 @@ msgstr ""
msgid "could not invert Vandermonde matrix"
msgstr ""
+#: shared-module/sdcardio/SDCard.c
+msgid "couldn't determine SD card version"
+msgstr ""
+
#: extmod/ulab/code/approx.c
msgid "data must be iterable"
msgstr ""
@@ -2686,6 +2761,10 @@ msgstr ""
msgid "negative shift count"
msgstr ""
+#: shared-module/sdcardio/SDCard.c
+msgid "no SD card"
+msgstr ""
+
#: py/vm.c
msgid "no active exception to reraise"
msgstr ""
@@ -2707,6 +2786,10 @@ msgstr "tidak ada modul yang bernama '%q'"
msgid "no reset pin available"
msgstr ""
+#: shared-module/sdcardio/SDCard.c
+msgid "no response from SD card"
+msgstr ""
+
#: py/runtime.c
msgid "no such attribute"
msgstr ""
@@ -2997,6 +3080,10 @@ msgstr ""
msgid "sleep length must be non-negative"
msgstr ""
+#: extmod/ulab/code/ndarray.c
+msgid "slice step can't be zero"
+msgstr ""
+
#: py/objslice.c py/sequence.c
msgid "slice step cannot be zero"
msgstr ""
@@ -3013,6 +3100,18 @@ msgstr "memulai ulang software(soft reboot)\n"
msgid "sort argument must be an ndarray"
msgstr ""
+#: extmod/ulab/code/filter.c
+msgid "sos array must be of shape (n_section, 6)"
+msgstr ""
+
+#: extmod/ulab/code/filter.c
+msgid "sos[:, 3] should be all ones"
+msgstr ""
+
+#: extmod/ulab/code/filter.c
+msgid "sosfilt requires iterable arguments"
+msgstr ""
+
#: py/objstr.c
msgid "start/end indices"
msgstr ""
@@ -3062,7 +3161,7 @@ msgstr "struct: index keluar dari jangkauan"
msgid "struct: no fields"
msgstr "struct: tidak ada fields"
-#: py/objstr.c
+#: py/objarray.c py/objstr.c
msgid "substring not found"
msgstr ""
@@ -3099,6 +3198,14 @@ msgstr ""
msgid "timeout must be >= 0.0"
msgstr "bits harus memilki nilai 8"
+#: shared-module/sdcardio/SDCard.c
+msgid "timeout waiting for v1 card"
+msgstr ""
+
+#: shared-module/sdcardio/SDCard.c
+msgid "timeout waiting for v2 card"
+msgstr ""
+
#: shared-bindings/time/__init__.c
msgid "timestamp out of range for platform time_t"
msgstr ""
@@ -3296,6 +3403,18 @@ msgstr ""
msgid "zero step"
msgstr ""
+#: extmod/ulab/code/filter.c
+msgid "zi must be an ndarray"
+msgstr ""
+
+#: extmod/ulab/code/filter.c
+msgid "zi must be of float type"
+msgstr ""
+
+#: extmod/ulab/code/filter.c
+msgid "zi must be of shape (n_section, 2)"
+msgstr ""
+
#~ msgid "AP required"
#~ msgstr "AP dibutuhkan"
diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot
index 1582b746c..153f0edad 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-06-25 11:44-0500\n"
+"POT-Creation-Date: 2020-07-24 19:58-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"
@@ -58,6 +58,10 @@ msgstr ""
msgid "%d address pins and %d rgb pins indicate a height of %d, not %d"
msgstr ""
+#: ports/atmel-samd/common-hal/sdioio/SDCard.c
+msgid "%q failure: %d"
+msgstr ""
+
#: shared-bindings/microcontroller/Pin.c
msgid "%q in use"
msgstr ""
@@ -74,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 ""
@@ -85,6 +94,10 @@ msgstr ""
msgid "%q must be a tuple of length 2"
msgstr ""
+#: ports/atmel-samd/common-hal/sdioio/SDCard.c
+msgid "%q pin invalid"
+msgstr ""
+
#: shared-bindings/fontio/BuiltinFont.c
msgid "%q should be an int"
msgstr ""
@@ -202,11 +215,11 @@ msgid "'align' requires 1 argument"
msgstr ""
#: py/compile.c
-msgid "'async for' or 'async with' outside async function"
+msgid "'await' outside function"
msgstr ""
#: py/compile.c
-msgid "'await' outside function"
+msgid "'await', 'async for' or 'async with' outside async function"
msgstr ""
#: py/compile.c
@@ -217,6 +230,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 ""
@@ -299,7 +316,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 ""
@@ -307,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 ""
@@ -338,10 +360,15 @@ msgstr ""
msgid "Array values should be single bytes."
msgstr ""
-#: shared-bindings/rgbmatrix/RGBMatrix.c
+#: shared-bindings/microcontroller/Pin.c
msgid "At most %d %q may be specified (not %d)"
msgstr ""
+#: shared-module/memorymonitor/AllocationAlarm.c
+#, c-format
+msgid "Attempt to allocate %d blocks"
+msgstr ""
+
#: supervisor/shared/safe_mode.c
msgid "Attempted heap allocation when MicroPython VM not running."
msgstr ""
@@ -417,6 +444,11 @@ msgstr ""
msgid "Buffer length %d too big. It must be less than %d"
msgstr ""
+#: ports/atmel-samd/common-hal/sdioio/SDCard.c
+#: ports/cxd56/common-hal/sdioio/SDCard.c shared-module/sdcardio/SDCard.c
+msgid "Buffer length must be a multiple of 512"
+msgstr ""
+
#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c
msgid "Buffer must be at least length 1"
msgstr ""
@@ -456,7 +488,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 ""
@@ -577,6 +611,10 @@ msgstr ""
msgid "Could not initialize GNSS"
msgstr ""
+#: ports/cxd56/common-hal/sdioio/SDCard.c
+msgid "Could not initialize SDCard"
+msgstr ""
+
#: ports/atmel-samd/common-hal/busio/UART.c ports/cxd56/common-hal/busio/UART.c
msgid "Could not initialize UART"
msgstr ""
@@ -698,7 +736,8 @@ msgstr ""
msgid "Error in regex"
msgstr ""
-#: shared-bindings/aesio/aes.c shared-bindings/microcontroller/Pin.c
+#: shared-bindings/aesio/aes.c shared-bindings/busio/SPI.c
+#: shared-bindings/microcontroller/Pin.c
#: shared-bindings/neopixel_write/__init__.c shared-bindings/pulseio/PulseOut.c
#: shared-bindings/terminalio/Terminal.c
msgid "Expected a %q"
@@ -858,6 +897,10 @@ msgstr ""
msgid "Internal error #%d"
msgstr ""
+#: shared-bindings/sdioio/SDCard.c
+msgid "Invalid %q"
+msgstr ""
+
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
msgid "Invalid %q pin"
@@ -965,7 +1008,8 @@ msgstr ""
#: ports/atmel-samd/common-hal/busio/UART.c
#: ports/atmel-samd/common-hal/i2cperipheral/I2CPeripheral.c
#: ports/cxd56/common-hal/busio/I2C.c ports/cxd56/common-hal/busio/SPI.c
-#: ports/cxd56/common-hal/busio/UART.c ports/mimxrt10xx/common-hal/busio/I2C.c
+#: ports/cxd56/common-hal/busio/UART.c ports/cxd56/common-hal/sdioio/SDCard.c
+#: ports/mimxrt10xx/common-hal/busio/I2C.c
#: ports/mimxrt10xx/common-hal/busio/SPI.c
#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/I2C.c
msgid "Invalid pins"
@@ -1069,6 +1113,10 @@ msgstr ""
msgid "Must provide MISO or MOSI pin"
msgstr ""
+#: ports/stm/common-hal/busio/SPI.c
+msgid "Must provide SCK pin"
+msgstr ""
+
#: shared-bindings/rgbmatrix/RGBMatrix.c
#, c-format
msgid "Must use a multiple of 6 rgb pins, not %d"
@@ -1284,14 +1332,6 @@ 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
-msgid "PulseOut not supported on this chip"
-msgstr ""
-
#: ports/stm/common-hal/os/__init__.c
msgid "RNG DeInit Error"
msgstr ""
@@ -1322,6 +1362,7 @@ msgstr ""
msgid "Random number generation error"
msgstr ""
+#: shared-bindings/memorymonitor/AllocationSize.c
#: shared-bindings/pulseio/PulseIn.c
msgid "Read-only"
msgstr ""
@@ -1358,6 +1399,10 @@ msgstr ""
msgid "Running in safe mode! Not running saved code.\n"
msgstr ""
+#: shared-module/sdcardio/SDCard.c
+msgid "SD card CSD format not supported"
+msgstr ""
+
#: ports/atmel-samd/common-hal/busio/I2C.c
#: ports/mimxrt10xx/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c
msgid "SDA or SCL needs a pull up"
@@ -1402,7 +1447,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 ""
@@ -1490,6 +1537,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 ""
@@ -1713,7 +1765,7 @@ msgstr ""
msgid "__new__ arg must be a user-type"
msgstr ""
-#: extmod/modubinascii.c extmod/moduhashlib.c
+#: extmod/modubinascii.c extmod/moduhashlib.c py/objarray.c
msgid "a bytes-like object is required"
msgstr ""
@@ -1979,6 +2031,10 @@ msgstr ""
msgid "can't send non-None value to a just-started generator"
msgstr ""
+#: shared-module/sdcardio/SDCard.c
+msgid "can't set 512 block size"
+msgstr ""
+
#: py/objnamedtuple.c
msgid "can't set attribute"
msgstr ""
@@ -2105,6 +2161,10 @@ msgstr ""
msgid "could not invert Vandermonde matrix"
msgstr ""
+#: shared-module/sdcardio/SDCard.c
+msgid "couldn't determine SD card version"
+msgstr ""
+
#: extmod/ulab/code/approx.c
msgid "data must be iterable"
msgstr ""
@@ -2662,6 +2722,10 @@ msgstr ""
msgid "negative shift count"
msgstr ""
+#: shared-module/sdcardio/SDCard.c
+msgid "no SD card"
+msgstr ""
+
#: py/vm.c
msgid "no active exception to reraise"
msgstr ""
@@ -2683,6 +2747,10 @@ msgstr ""
msgid "no reset pin available"
msgstr ""
+#: shared-module/sdcardio/SDCard.c
+msgid "no response from SD card"
+msgstr ""
+
#: py/runtime.c
msgid "no such attribute"
msgstr ""
@@ -2972,6 +3040,10 @@ msgstr ""
msgid "sleep length must be non-negative"
msgstr ""
+#: extmod/ulab/code/ndarray.c
+msgid "slice step can't be zero"
+msgstr ""
+
#: py/objslice.c py/sequence.c
msgid "slice step cannot be zero"
msgstr ""
@@ -2988,6 +3060,18 @@ msgstr ""
msgid "sort argument must be an ndarray"
msgstr ""
+#: extmod/ulab/code/filter.c
+msgid "sos array must be of shape (n_section, 6)"
+msgstr ""
+
+#: extmod/ulab/code/filter.c
+msgid "sos[:, 3] should be all ones"
+msgstr ""
+
+#: extmod/ulab/code/filter.c
+msgid "sosfilt requires iterable arguments"
+msgstr ""
+
#: py/objstr.c
msgid "start/end indices"
msgstr ""
@@ -3037,7 +3121,7 @@ msgstr ""
msgid "struct: no fields"
msgstr ""
-#: py/objstr.c
+#: py/objarray.c py/objstr.c
msgid "substring not found"
msgstr ""
@@ -3073,6 +3157,14 @@ msgstr ""
msgid "timeout must be >= 0.0"
msgstr ""
+#: shared-module/sdcardio/SDCard.c
+msgid "timeout waiting for v1 card"
+msgstr ""
+
+#: shared-module/sdcardio/SDCard.c
+msgid "timeout waiting for v2 card"
+msgstr ""
+
#: shared-bindings/time/__init__.c
msgid "timestamp out of range for platform time_t"
msgstr ""
@@ -3269,3 +3361,15 @@ msgstr ""
#: py/objrange.c
msgid "zero step"
msgstr ""
+
+#: extmod/ulab/code/filter.c
+msgid "zi must be an ndarray"
+msgstr ""
+
+#: extmod/ulab/code/filter.c
+msgid "zi must be of float type"
+msgstr ""
+
+#: extmod/ulab/code/filter.c
+msgid "zi must be of shape (n_section, 2)"
+msgstr ""
diff --git a/locale/cs.po b/locale/cs.po
index b23144fc8..cf9141627 100644
--- a/locale/cs.po
+++ b/locale/cs.po
@@ -1,13 +1,11 @@
-# SOME DESCRIPTIVE TITLE.
-# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
-# This file is distributed under the same license as the PACKAGE package.
-# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
#
+# SPDX-License-Identifier: MIT
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2020-06-25 11:44-0500\n"
+"POT-Creation-Date: 2020-07-17 18:03-0700\n"
"PO-Revision-Date: 2020-05-24 03:22+0000\n"
"Last-Translator: dronecz <mzuzelka@gmail.com>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -66,6 +64,10 @@ msgstr "%% c vyžaduje int nebo char"
msgid "%d address pins and %d rgb pins indicate a height of %d, not %d"
msgstr "%d adresní piny a %d rgb piny označují výšku %d, nikoli %d"
+#: ports/atmel-samd/common-hal/sdioio/SDCard.c
+msgid "%q failure: %d"
+msgstr ""
+
#: shared-bindings/microcontroller/Pin.c
msgid "%q in use"
msgstr "%q se nyní používá"
@@ -82,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"
@@ -93,6 +100,10 @@ msgstr "% q musí být > = 1"
msgid "%q must be a tuple of length 2"
msgstr "% q musí být n-tice délky 2"
+#: ports/atmel-samd/common-hal/sdioio/SDCard.c
+msgid "%q pin invalid"
+msgstr ""
+
#: shared-bindings/fontio/BuiltinFont.c
msgid "%q should be an int"
msgstr "% q by měl být int"
@@ -105,6 +116,10 @@ msgstr ""
msgid "'%q' argument required"
msgstr ""
+#: py/objarray.c
+msgid "'%q' object is not bytes-like"
+msgstr ""
+
#: py/emitinlinethumb.c py/emitinlinextensa.c
#, c-format
msgid "'%s' expects a label"
@@ -315,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 ""
@@ -346,10 +366,15 @@ msgstr ""
msgid "Array values should be single bytes."
msgstr ""
-#: shared-bindings/rgbmatrix/RGBMatrix.c
+#: shared-bindings/microcontroller/Pin.c
msgid "At most %d %q may be specified (not %d)"
msgstr ""
+#: shared-module/memorymonitor/AllocationAlarm.c
+#, c-format
+msgid "Attempt to allocate %d blocks"
+msgstr ""
+
#: supervisor/shared/safe_mode.c
msgid "Attempted heap allocation when MicroPython VM not running."
msgstr ""
@@ -425,6 +450,11 @@ msgstr ""
msgid "Buffer length %d too big. It must be less than %d"
msgstr ""
+#: ports/atmel-samd/common-hal/sdioio/SDCard.c
+#: ports/cxd56/common-hal/sdioio/SDCard.c shared-module/sdcardio/SDCard.c
+msgid "Buffer length must be a multiple of 512"
+msgstr ""
+
#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c
msgid "Buffer must be at least length 1"
msgstr ""
@@ -464,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 ""
@@ -585,6 +617,10 @@ msgstr ""
msgid "Could not initialize GNSS"
msgstr ""
+#: ports/cxd56/common-hal/sdioio/SDCard.c
+msgid "Could not initialize SDCard"
+msgstr ""
+
#: ports/atmel-samd/common-hal/busio/UART.c ports/cxd56/common-hal/busio/UART.c
msgid "Could not initialize UART"
msgstr ""
@@ -706,7 +742,8 @@ msgstr ""
msgid "Error in regex"
msgstr ""
-#: shared-bindings/aesio/aes.c shared-bindings/microcontroller/Pin.c
+#: shared-bindings/aesio/aes.c shared-bindings/busio/SPI.c
+#: shared-bindings/microcontroller/Pin.c
#: shared-bindings/neopixel_write/__init__.c shared-bindings/pulseio/PulseOut.c
#: shared-bindings/terminalio/Terminal.c
msgid "Expected a %q"
@@ -866,6 +903,10 @@ msgstr ""
msgid "Internal error #%d"
msgstr ""
+#: shared-bindings/sdioio/SDCard.c
+msgid "Invalid %q"
+msgstr ""
+
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
msgid "Invalid %q pin"
@@ -973,7 +1014,8 @@ msgstr ""
#: ports/atmel-samd/common-hal/busio/UART.c
#: ports/atmel-samd/common-hal/i2cperipheral/I2CPeripheral.c
#: ports/cxd56/common-hal/busio/I2C.c ports/cxd56/common-hal/busio/SPI.c
-#: ports/cxd56/common-hal/busio/UART.c ports/mimxrt10xx/common-hal/busio/I2C.c
+#: ports/cxd56/common-hal/busio/UART.c ports/cxd56/common-hal/sdioio/SDCard.c
+#: ports/mimxrt10xx/common-hal/busio/I2C.c
#: ports/mimxrt10xx/common-hal/busio/SPI.c
#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/I2C.c
msgid "Invalid pins"
@@ -1077,6 +1119,10 @@ msgstr ""
msgid "Must provide MISO or MOSI pin"
msgstr ""
+#: ports/stm/common-hal/busio/SPI.c
+msgid "Must provide SCK pin"
+msgstr ""
+
#: shared-bindings/rgbmatrix/RGBMatrix.c
#, c-format
msgid "Must use a multiple of 6 rgb pins, not %d"
@@ -1330,6 +1376,7 @@ msgstr ""
msgid "Random number generation error"
msgstr ""
+#: shared-bindings/memorymonitor/AllocationSize.c
#: shared-bindings/pulseio/PulseIn.c
msgid "Read-only"
msgstr ""
@@ -1366,6 +1413,10 @@ msgstr ""
msgid "Running in safe mode! Not running saved code.\n"
msgstr ""
+#: shared-module/sdcardio/SDCard.c
+msgid "SD card CSD format not supported"
+msgstr ""
+
#: ports/atmel-samd/common-hal/busio/I2C.c
#: ports/mimxrt10xx/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c
msgid "SDA or SCL needs a pull up"
@@ -1410,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 ""
@@ -1987,6 +2040,10 @@ msgstr ""
msgid "can't send non-None value to a just-started generator"
msgstr ""
+#: shared-module/sdcardio/SDCard.c
+msgid "can't set 512 block size"
+msgstr ""
+
#: py/objnamedtuple.c
msgid "can't set attribute"
msgstr ""
@@ -2113,6 +2170,10 @@ msgstr ""
msgid "could not invert Vandermonde matrix"
msgstr ""
+#: shared-module/sdcardio/SDCard.c
+msgid "couldn't determine SD card version"
+msgstr ""
+
#: extmod/ulab/code/approx.c
msgid "data must be iterable"
msgstr ""
@@ -2670,6 +2731,10 @@ msgstr ""
msgid "negative shift count"
msgstr ""
+#: shared-module/sdcardio/SDCard.c
+msgid "no SD card"
+msgstr ""
+
#: py/vm.c
msgid "no active exception to reraise"
msgstr ""
@@ -2691,6 +2756,10 @@ msgstr ""
msgid "no reset pin available"
msgstr ""
+#: shared-module/sdcardio/SDCard.c
+msgid "no response from SD card"
+msgstr ""
+
#: py/runtime.c
msgid "no such attribute"
msgstr ""
@@ -2980,6 +3049,10 @@ msgstr ""
msgid "sleep length must be non-negative"
msgstr ""
+#: extmod/ulab/code/ndarray.c
+msgid "slice step can't be zero"
+msgstr ""
+
#: py/objslice.c py/sequence.c
msgid "slice step cannot be zero"
msgstr ""
@@ -2996,6 +3069,18 @@ msgstr ""
msgid "sort argument must be an ndarray"
msgstr ""
+#: extmod/ulab/code/filter.c
+msgid "sos array must be of shape (n_section, 6)"
+msgstr ""
+
+#: extmod/ulab/code/filter.c
+msgid "sos[:, 3] should be all ones"
+msgstr ""
+
+#: extmod/ulab/code/filter.c
+msgid "sosfilt requires iterable arguments"
+msgstr ""
+
#: py/objstr.c
msgid "start/end indices"
msgstr ""
@@ -3045,7 +3130,7 @@ msgstr ""
msgid "struct: no fields"
msgstr ""
-#: py/objstr.c
+#: py/objarray.c py/objstr.c
msgid "substring not found"
msgstr ""
@@ -3081,6 +3166,14 @@ msgstr ""
msgid "timeout must be >= 0.0"
msgstr ""
+#: shared-module/sdcardio/SDCard.c
+msgid "timeout waiting for v1 card"
+msgstr ""
+
+#: shared-module/sdcardio/SDCard.c
+msgid "timeout waiting for v2 card"
+msgstr ""
+
#: shared-bindings/time/__init__.c
msgid "timestamp out of range for platform time_t"
msgstr ""
@@ -3277,3 +3370,15 @@ msgstr ""
#: py/objrange.c
msgid "zero step"
msgstr ""
+
+#: extmod/ulab/code/filter.c
+msgid "zi must be an ndarray"
+msgstr ""
+
+#: extmod/ulab/code/filter.c
+msgid "zi must be of float type"
+msgstr ""
+
+#: extmod/ulab/code/filter.c
+msgid "zi must be of shape (n_section, 2)"
+msgstr ""
diff --git a/locale/de_DE.po b/locale/de_DE.po
index eff611b20..9b07989ca 100644
--- a/locale/de_DE.po
+++ b/locale/de_DE.po
@@ -1,13 +1,11 @@
-# SOME DESCRIPTIVE TITLE.
-# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
-# This file is distributed under the same license as the PACKAGE package.
-# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
#
+# SPDX-License-Identifier: MIT
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2020-06-25 11:44-0500\n"
+"POT-Creation-Date: 2020-07-17 18:03-0700\n"
"PO-Revision-Date: 2020-06-16 18:24+0000\n"
"Last-Translator: Andreas Buchen <andreas.buchen@gmail.com>\n"
"Language: de_DE\n"
@@ -65,6 +63,10 @@ msgstr "%%c erwartet int oder char"
msgid "%d address pins and %d rgb pins indicate a height of %d, not %d"
msgstr "%d Adress-Pins und %d rgb-Pins zeigen eine Höhe von %d, nicht von %d"
+#: ports/atmel-samd/common-hal/sdioio/SDCard.c
+msgid "%q failure: %d"
+msgstr ""
+
#: shared-bindings/microcontroller/Pin.c
msgid "%q in use"
msgstr "%q in Benutzung"
@@ -81,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"
@@ -92,6 +99,10 @@ msgstr "%q muss >= 1 sein"
msgid "%q must be a tuple of length 2"
msgstr "%q muss ein Tupel der Länge 2 sein"
+#: ports/atmel-samd/common-hal/sdioio/SDCard.c
+msgid "%q pin invalid"
+msgstr ""
+
#: shared-bindings/fontio/BuiltinFont.c
msgid "%q should be an int"
msgstr "%q sollte ein integer sein"
@@ -104,6 +115,10 @@ msgstr "%q() nimmt %d Argumente ohne Keyword an, aber es wurden %d angegeben"
msgid "'%q' argument required"
msgstr "'%q' Argument erforderlich"
+#: py/objarray.c
+msgid "'%q' object is not bytes-like"
+msgstr ""
+
#: py/emitinlinethumb.c py/emitinlinextensa.c
#, c-format
msgid "'%s' expects a label"
@@ -314,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"
@@ -345,10 +365,15 @@ msgstr "Array muss Halbwörter enthalten (type 'H')"
msgid "Array values should be single bytes."
msgstr "Array-Werte sollten aus Einzelbytes bestehen."
-#: shared-bindings/rgbmatrix/RGBMatrix.c
+#: shared-bindings/microcontroller/Pin.c
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 ""
@@ -428,6 +453,11 @@ msgstr "Der Puffer ist zu klein"
msgid "Buffer length %d too big. It must be less than %d"
msgstr "Die Pufferlänge %d ist zu groß. Sie muss kleiner als %d sein"
+#: ports/atmel-samd/common-hal/sdioio/SDCard.c
+#: ports/cxd56/common-hal/sdioio/SDCard.c shared-module/sdcardio/SDCard.c
+msgid "Buffer length must be a multiple of 512"
+msgstr ""
+
#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c
msgid "Buffer must be at least length 1"
msgstr "Der Puffer muss eine Mindestenslänge von 1 haben"
@@ -467,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"
@@ -595,6 +627,10 @@ msgstr "Beschädigter raw code"
msgid "Could not initialize GNSS"
msgstr ""
+#: ports/cxd56/common-hal/sdioio/SDCard.c
+msgid "Could not initialize SDCard"
+msgstr ""
+
#: ports/atmel-samd/common-hal/busio/UART.c ports/cxd56/common-hal/busio/UART.c
msgid "Could not initialize UART"
msgstr "Konnte UART nicht initialisieren"
@@ -716,7 +752,8 @@ msgstr "EXTINT Kanal ist schon in Benutzung"
msgid "Error in regex"
msgstr "Fehler in regex"
-#: shared-bindings/aesio/aes.c shared-bindings/microcontroller/Pin.c
+#: shared-bindings/aesio/aes.c shared-bindings/busio/SPI.c
+#: shared-bindings/microcontroller/Pin.c
#: shared-bindings/neopixel_write/__init__.c shared-bindings/pulseio/PulseOut.c
#: shared-bindings/terminalio/Terminal.c
msgid "Expected a %q"
@@ -883,6 +920,10 @@ msgstr "Interner Definitionsfehler"
msgid "Internal error #%d"
msgstr "Interner Fehler #%d"
+#: shared-bindings/sdioio/SDCard.c
+msgid "Invalid %q"
+msgstr ""
+
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
msgid "Invalid %q pin"
@@ -990,7 +1031,8 @@ msgstr "Ungültiger Pin für rechten Kanal"
#: ports/atmel-samd/common-hal/busio/UART.c
#: ports/atmel-samd/common-hal/i2cperipheral/I2CPeripheral.c
#: ports/cxd56/common-hal/busio/I2C.c ports/cxd56/common-hal/busio/SPI.c
-#: ports/cxd56/common-hal/busio/UART.c ports/mimxrt10xx/common-hal/busio/I2C.c
+#: ports/cxd56/common-hal/busio/UART.c ports/cxd56/common-hal/sdioio/SDCard.c
+#: ports/mimxrt10xx/common-hal/busio/I2C.c
#: ports/mimxrt10xx/common-hal/busio/SPI.c
#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/I2C.c
msgid "Invalid pins"
@@ -1096,6 +1138,10 @@ msgstr "Muss eine %q Unterklasse sein."
msgid "Must provide MISO or MOSI pin"
msgstr "Muss MISO- oder MOSI-Pin bereitstellen"
+#: ports/stm/common-hal/busio/SPI.c
+msgid "Must provide SCK pin"
+msgstr ""
+
#: shared-bindings/rgbmatrix/RGBMatrix.c
#, c-format
msgid "Must use a multiple of 6 rgb pins, not %d"
@@ -1360,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"
@@ -1396,6 +1443,10 @@ msgstr "Sicherheitsmodus aktiv! Automatisches Neuladen ist deaktiviert.\n"
msgid "Running in safe mode! Not running saved code.\n"
msgstr "Sicherheitsmodus aktiv! Gespeicherter Code wird nicht ausgeführt\n"
+#: shared-module/sdcardio/SDCard.c
+msgid "SD card CSD format not supported"
+msgstr ""
+
#: ports/atmel-samd/common-hal/busio/I2C.c
#: ports/mimxrt10xx/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c
msgid "SDA or SCL needs a pull up"
@@ -1440,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"
@@ -2048,6 +2101,10 @@ msgstr ""
"Nicht \"None\" Werte können nicht an einen gerade gestarteten Generator "
"gesendet werden"
+#: shared-module/sdcardio/SDCard.c
+msgid "can't set 512 block size"
+msgstr ""
+
#: py/objnamedtuple.c
msgid "can't set attribute"
msgstr "kann Attribut nicht setzen"
@@ -2181,6 +2238,10 @@ msgstr "Eingabearray konnte nicht aus der Form übertragen werden"
msgid "could not invert Vandermonde matrix"
msgstr "Vandermonde-Matrix konnte nicht invertiert werden"
+#: shared-module/sdcardio/SDCard.c
+msgid "couldn't determine SD card version"
+msgstr ""
+
#: extmod/ulab/code/approx.c
msgid "data must be iterable"
msgstr ""
@@ -2747,6 +2808,10 @@ msgstr "negative Potenz ohne Gleitkomma (float) Unterstützung"
msgid "negative shift count"
msgstr "Negative shift Anzahl"
+#: shared-module/sdcardio/SDCard.c
+msgid "no SD card"
+msgstr ""
+
#: py/vm.c
msgid "no active exception to reraise"
msgstr "Keine aktive Ausnahme zu verusachen (raise)"
@@ -2768,6 +2833,10 @@ msgstr "Kein Modul mit dem Namen '%q'"
msgid "no reset pin available"
msgstr "kein Reset Pin verfügbar"
+#: shared-module/sdcardio/SDCard.c
+msgid "no response from SD card"
+msgstr ""
+
#: py/runtime.c
msgid "no such attribute"
msgstr "kein solches Attribut"
@@ -3063,6 +3132,10 @@ msgstr "Größe ist nur für ndarrays definiert"
msgid "sleep length must be non-negative"
msgstr "Die Schlafdauer darf nicht negativ sein"
+#: extmod/ulab/code/ndarray.c
+msgid "slice step can't be zero"
+msgstr ""
+
#: py/objslice.c py/sequence.c
msgid "slice step cannot be zero"
msgstr "Der Slice-Schritt kann nicht Null sein"
@@ -3079,6 +3152,18 @@ msgstr "weicher reboot\n"
msgid "sort argument must be an ndarray"
msgstr "sortierungs Argument muss ein ndarray sein"
+#: extmod/ulab/code/filter.c
+msgid "sos array must be of shape (n_section, 6)"
+msgstr ""
+
+#: extmod/ulab/code/filter.c
+msgid "sos[:, 3] should be all ones"
+msgstr ""
+
+#: extmod/ulab/code/filter.c
+msgid "sosfilt requires iterable arguments"
+msgstr ""
+
#: py/objstr.c
msgid "start/end indices"
msgstr "start/end Indizes"
@@ -3129,7 +3214,7 @@ msgstr "struct: index außerhalb gültigen Bereichs"
msgid "struct: no fields"
msgstr "struct: keine Felder"
-#: py/objstr.c
+#: py/objarray.c py/objstr.c
msgid "substring not found"
msgstr "substring nicht gefunden"
@@ -3165,6 +3250,14 @@ msgstr "Das Zeitlimit muss 0,0-100,0 Sekunden betragen"
msgid "timeout must be >= 0.0"
msgstr "timeout muss >= 0.0 sein"
+#: shared-module/sdcardio/SDCard.c
+msgid "timeout waiting for v1 card"
+msgstr ""
+
+#: shared-module/sdcardio/SDCard.c
+msgid "timeout waiting for v2 card"
+msgstr ""
+
#: shared-bindings/time/__init__.c
msgid "timestamp out of range for platform time_t"
msgstr "Zeitstempel außerhalb des Bereichs für Plattform time_t"
@@ -3366,6 +3459,18 @@ msgstr "y Wert außerhalb der Grenzen"
msgid "zero step"
msgstr "Nullschritt"
+#: extmod/ulab/code/filter.c
+msgid "zi must be an ndarray"
+msgstr ""
+
+#: extmod/ulab/code/filter.c
+msgid "zi must be of float type"
+msgstr ""
+
+#: extmod/ulab/code/filter.c
+msgid "zi must be of shape (n_section, 2)"
+msgstr ""
+
#~ msgid "AP required"
#~ msgstr "AP erforderlich"
diff --git a/locale/en_US.po b/locale/en_US.po
index c89772779..de9fa6347 100644
--- a/locale/en_US.po
+++ b/locale/en_US.po
@@ -1,8 +1,7 @@
-# SOME DESCRIPTIVE TITLE.
-# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
-# This file is distributed under the same license as the PACKAGE package.
-# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
#
+# SPDX-License-Identifier: MIT
+
msgid ""
msgstr ""
"Project-Id-Version: \n"
diff --git a/locale/en_x_pirate.po b/locale/en_x_pirate.po
index 16f2b3669..40b0b314c 100644
--- a/locale/en_x_pirate.po
+++ b/locale/en_x_pirate.po
@@ -1,8 +1,7 @@
-# Pirate (English) Translation
-# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
-# This file is distributed under the same license as the PACKAGE package.
-# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
#
+# SPDX-License-Identifier: MIT
+
msgid ""
msgstr ""
"Project-Id-Version: \n"
diff --git a/locale/es.po b/locale/es.po
index 22597249b..8d19b0ab0 100644
--- a/locale/es.po
+++ b/locale/es.po
@@ -1,14 +1,14 @@
-# Spanish translation.
-# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
-# This file is distributed under the same license as the PACKAGE package.
-# Carlos Diaz <carlos.santiago.diaz@gmail.com>, 2018.
-# Juan Biondi <juanernestobiondi@gmail.com>, 2018.
+# SPDX-FileCopyrightText: 2018 Carlos Diaz <carlos.santiago.diaz@gmail.com>
+# SPDX-FileCopyrightText: 2018 Juan Biondi <juanernestobiondi@gmail.com>
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+#
+# SPDX-License-Identifier: MIT
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2020-06-25 11:44-0500\n"
-"PO-Revision-Date: 2020-06-24 18:32+0000\n"
+"POT-Creation-Date: 2020-07-17 18:03-0700\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"
@@ -67,6 +67,10 @@ msgid "%d address pins and %d rgb pins indicate a height of %d, not %d"
msgstr ""
"%d pines de dirección y %d pines rgb indican una altura de %d, no de %d"
+#: ports/atmel-samd/common-hal/sdioio/SDCard.c
+msgid "%q failure: %d"
+msgstr "%q fallo: %d"
+
#: shared-bindings/microcontroller/Pin.c
msgid "%q in use"
msgstr "%q está siendo utilizado"
@@ -83,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"
@@ -94,6 +103,10 @@ msgstr "%q debe ser >= 1"
msgid "%q must be a tuple of length 2"
msgstr "%q debe ser una tupla de longitud 2"
+#: ports/atmel-samd/common-hal/sdioio/SDCard.c
+msgid "%q pin invalid"
+msgstr "pin inválido %q"
+
#: shared-bindings/fontio/BuiltinFont.c
msgid "%q should be an int"
msgstr "%q debe ser un int"
@@ -106,6 +119,10 @@ msgstr "%q() toma %d argumentos posicionales pero %d fueron dados"
msgid "'%q' argument required"
msgstr "argumento '%q' requerido"
+#: py/objarray.c
+msgid "'%q' object is not bytes-like"
+msgstr "el objeto '%q' no es similar a bytes"
+
#: py/emitinlinethumb.c py/emitinlinextensa.c
#, c-format
msgid "'%s' expects a label"
@@ -212,7 +229,7 @@ msgstr "'align' requiere 1 argumento"
#: py/compile.c
msgid "'async for' or 'async with' outside async function"
-msgstr ""
+msgstr "'async for' o 'async with' fuera de la función async"
#: py/compile.c
msgid "'await' outside function"
@@ -318,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"
@@ -349,13 +371,20 @@ msgstr "Array debe contener media palabra (type 'H')"
msgid "Array values should be single bytes."
msgstr "Valores del array deben ser bytes individuales."
-#: shared-bindings/rgbmatrix/RGBMatrix.c
+#: shared-bindings/microcontroller/Pin.c
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 ""
+"Se intentó asignación del montículo, sin que la VM de MicroPython esté "
+"ejecutando."
#: main.c
msgid "Auto-reload is off.\n"
@@ -408,7 +437,7 @@ msgstr "El brillo no se puede ajustar"
#: shared-bindings/_bleio/UUID.c
#, c-format
msgid "Buffer + offset too small %d %d %d"
-msgstr ""
+msgstr "Búfer + compensado muy pequeños %d %d %d"
#: shared-module/usb_hid/Device.c
#, c-format
@@ -430,6 +459,11 @@ msgstr "El buffer es muy pequeño"
msgid "Buffer length %d too big. It must be less than %d"
msgstr "La longitud del buffer %d es muy grande. Debe ser menor a %d"
+#: ports/atmel-samd/common-hal/sdioio/SDCard.c
+#: ports/cxd56/common-hal/sdioio/SDCard.c shared-module/sdcardio/SDCard.c
+msgid "Buffer length must be a multiple of 512"
+msgstr "El tamaño del búfer debe ser múltiplo de 512"
+
#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c
msgid "Buffer must be at least length 1"
msgstr "Buffer debe ser de longitud 1 como minimo"
@@ -441,7 +475,7 @@ msgstr "Buffer demasiado grande e incapaz de asignar"
#: shared-bindings/_bleio/PacketBuffer.c
#, c-format
msgid "Buffer too short by %d bytes"
-msgstr ""
+msgstr "Búfer muy corto por %d bytes"
#: ports/atmel-samd/common-hal/displayio/ParallelBus.c
#: ports/nrf/common-hal/displayio/ParallelBus.c
@@ -451,7 +485,7 @@ msgstr "Bus pin %d ya está siendo utilizado"
#: shared-bindings/_bleio/UUID.c
msgid "Byte buffer must be 16 bytes."
-msgstr "Byte buffer debe de ser 16 bytes"
+msgstr "Búfer Byte debe de ser 16 bytes."
#: shared-bindings/nvm/ByteArray.c
msgid "Bytes must be between 0 and 255."
@@ -467,9 +501,11 @@ msgstr "Llame a super().__ init __() antes de acceder al objeto nativo."
#: ports/nrf/common-hal/_bleio/Characteristic.c
msgid "Can't set CCCD on local Characteristic"
-msgstr ""
+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"
@@ -481,11 +517,13 @@ msgstr "No puede ser pull mientras este en modo de salida"
#: ports/nrf/common-hal/microcontroller/Processor.c
msgid "Cannot get temperature"
-msgstr "No se puede obtener la temperatura."
+msgstr "No se puede obtener la temperatura"
#: shared-bindings/_bleio/Adapter.c
msgid "Cannot have scan responses for extended, connectable advertisements."
msgstr ""
+"No se pueden obtener respuestas de exploración para anuncios extendidos y "
+"conectables."
#: ports/atmel-samd/common-hal/audioio/AudioOut.c
msgid "Cannot output both channels on the same pin"
@@ -519,7 +557,7 @@ msgstr "No se puede especificar RTS o CTS en modo RS485"
#: py/objslice.c
msgid "Cannot subclass slice"
-msgstr "Cannot subclass slice"
+msgstr "No se puede manejar la partición en una subclase"
#: shared-module/bitbangio/SPI.c
msgid "Cannot transfer without MOSI and MISO pins."
@@ -555,11 +593,11 @@ msgstr ""
#: shared-module/bitbangio/SPI.c
msgid "Clock pin init failed."
-msgstr "Clock pin init fallido"
+msgstr "Iniciado de pin de reloj fallido."
#: shared-module/bitbangio/I2C.c
msgid "Clock stretch too long"
-msgstr "Clock stretch demasiado largo "
+msgstr "Estirado de reloj demasiado largo"
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
msgid "Clock unit in use"
@@ -572,7 +610,7 @@ msgstr "Entrada de columna debe ser digitalio.DigitalInOut"
#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/I2CDisplay.c
#: shared-bindings/displayio/ParallelBus.c
msgid "Command must be an int between 0 and 255"
-msgstr "Command debe estar entre 0 y 255."
+msgstr "Command debe ser un int entre 0 y 255"
#: shared-bindings/_bleio/Connection.c
msgid ""
@@ -592,7 +630,11 @@ msgstr "Código crudo corrupto"
#: ports/cxd56/common-hal/gnss/GNSS.c
msgid "Could not initialize GNSS"
-msgstr ""
+msgstr "No se pudo inicializar el GNSS"
+
+#: ports/cxd56/common-hal/sdioio/SDCard.c
+msgid "Could not initialize SDCard"
+msgstr "No se pudo inicializar SDCard"
#: ports/atmel-samd/common-hal/busio/UART.c ports/cxd56/common-hal/busio/UART.c
msgid "Could not initialize UART"
@@ -628,7 +670,7 @@ msgstr "No se pudo iniciar la interrupción, RX ocupado"
#: shared-module/audiomp3/MP3Decoder.c
msgid "Couldn't allocate decoder"
-msgstr ""
+msgstr "No se pudo encontrar el decodificador"
#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c
#: shared-module/audiomp3/MP3Decoder.c
@@ -637,7 +679,7 @@ msgstr "No se pudo asignar el primer buffer"
#: shared-module/audiomp3/MP3Decoder.c
msgid "Couldn't allocate input buffer"
-msgstr ""
+msgstr "No se pudo encontrar el búfer de entrada"
#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c
#: shared-module/audiomp3/MP3Decoder.c
@@ -646,7 +688,7 @@ msgstr "No se pudo asignar el segundo buffer"
#: supervisor/shared/safe_mode.c
msgid "Crash into the HardFault_Handler."
-msgstr ""
+msgstr "Choque contra el HardFault_Handler."
#: ports/stm/common-hal/analogio/AnalogOut.c
msgid "DAC Channel Init Error"
@@ -671,7 +713,7 @@ msgstr "Trozo de datos debe seguir fmt chunk"
#: ports/nrf/common-hal/_bleio/Adapter.c
msgid "Data too large for advertisement packet"
-msgstr "Data es muy grande para el paquete de advertisement."
+msgstr "Data es muy grande para el paquete de anuncio"
#: shared-bindings/audiobusio/PDMIn.c
msgid "Destination capacity is smaller than destination_length."
@@ -702,7 +744,7 @@ msgstr "Modo Drive no se usa cuando la dirección es input."
#: shared-bindings/aesio/aes.c
msgid "ECB only operates on 16 bytes at a time"
-msgstr ""
+msgstr "ECB solo opera sobre 16 bytes a la vez"
#: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c
#: ports/atmel-samd/common-hal/ps2io/Ps2.c
@@ -715,7 +757,8 @@ msgstr "El canal EXTINT ya está siendo utilizado"
msgid "Error in regex"
msgstr "Error en regex"
-#: shared-bindings/aesio/aes.c shared-bindings/microcontroller/Pin.c
+#: shared-bindings/aesio/aes.c shared-bindings/busio/SPI.c
+#: shared-bindings/microcontroller/Pin.c
#: shared-bindings/neopixel_write/__init__.c shared-bindings/pulseio/PulseOut.c
#: shared-bindings/terminalio/Terminal.c
msgid "Expected a %q"
@@ -724,7 +767,7 @@ msgstr "Se espera un %q"
#: shared-bindings/_bleio/CharacteristicBuffer.c
#: shared-bindings/_bleio/Descriptor.c shared-bindings/_bleio/PacketBuffer.c
msgid "Expected a Characteristic"
-msgstr "Se esperaba una Característica."
+msgstr "Se esperaba una Característica"
#: shared-bindings/_bleio/Characteristic.c
msgid "Expected a Service"
@@ -750,16 +793,16 @@ msgstr "No se admiten anuncios extendidos con respuesta de escaneo."
#: extmod/ulab/code/fft.c
msgid "FFT is defined for ndarrays only"
-msgstr ""
+msgstr "FFT se define solo para ndarrays"
#: shared-bindings/ps2io/Ps2.c
msgid "Failed sending command."
-msgstr "Fallo enviando comando"
+msgstr "Fallo enviando comando."
#: ports/nrf/sd_mutex.c
-#, fuzzy, c-format
+#, c-format
msgid "Failed to acquire mutex, err 0x%04x"
-msgstr "No se puede adquirir el mutex, status: 0x%08lX"
+msgstr "No se puede adquirir el mutex, error 0x%04x"
#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c
msgid "Failed to allocate RX buffer"
@@ -851,7 +894,7 @@ msgid ""
"mpy-update for more info."
msgstr ""
"Archivo .mpy incompatible. Actualice todos los archivos .mpy. Consulte "
-"http://adafru.it/mpy-update para más información"
+"http://adafru.it/mpy-update para más información."
#: shared-bindings/_pew/PewPew.c
msgid "Incorrect buffer size"
@@ -871,13 +914,17 @@ msgstr "Cifrado insuficiente"
#: ports/stm/common-hal/busio/UART.c
msgid "Internal define error"
-msgstr ""
+msgstr "Error interno de definición"
#: shared-module/rgbmatrix/RGBMatrix.c
#, c-format
msgid "Internal error #%d"
msgstr "Error interno #%d"
+#: shared-bindings/sdioio/SDCard.c
+msgid "Invalid %q"
+msgstr "%q inválido"
+
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
msgid "Invalid %q pin"
@@ -955,7 +1002,7 @@ msgstr "Frecuencia suministrada no válida"
#: supervisor/shared/safe_mode.c
msgid "Invalid memory access."
-msgstr "Acceso a memoria no válido"
+msgstr "Acceso a memoria no válido."
#: shared-bindings/bitbangio/SPI.c shared-bindings/busio/SPI.c
msgid "Invalid number of bits"
@@ -985,7 +1032,8 @@ msgstr "Pin inválido para canal derecho"
#: ports/atmel-samd/common-hal/busio/UART.c
#: ports/atmel-samd/common-hal/i2cperipheral/I2CPeripheral.c
#: ports/cxd56/common-hal/busio/I2C.c ports/cxd56/common-hal/busio/SPI.c
-#: ports/cxd56/common-hal/busio/UART.c ports/mimxrt10xx/common-hal/busio/I2C.c
+#: ports/cxd56/common-hal/busio/UART.c ports/cxd56/common-hal/sdioio/SDCard.c
+#: ports/mimxrt10xx/common-hal/busio/I2C.c
#: ports/mimxrt10xx/common-hal/busio/SPI.c
#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/I2C.c
msgid "Invalid pins"
@@ -1010,7 +1058,7 @@ msgstr "Modo de ejecución inválido."
#: shared-module/_bleio/Attribute.c
msgid "Invalid security_mode"
-msgstr ""
+msgstr "Modo de seguridad no válido"
#: shared-bindings/audiomixer/Mixer.c
msgid "Invalid voice"
@@ -1038,7 +1086,7 @@ msgstr "LHS del agumento por palabra clave deberia ser un identificador"
#: shared-module/displayio/Group.c
msgid "Layer already in a group."
-msgstr "Layer ya pertenece a un grupo"
+msgstr "La capa ya pertenece a un grupo."
#: shared-module/displayio/Group.c
msgid "Layer must be a Group or TileGrid subclass."
@@ -1067,7 +1115,7 @@ msgstr "Valor máximo de x cuando se refleja es %d"
#: supervisor/shared/safe_mode.c
msgid "MicroPython NLR jump failed. Likely memory corruption."
-msgstr ""
+msgstr "MicroPython NLR jump falló. Probable corrupción de la memoria."
#: supervisor/shared/safe_mode.c
msgid "MicroPython fatal error."
@@ -1083,16 +1131,20 @@ msgstr "Falta el pin MISO o MOSI"
#: shared-bindings/displayio/Group.c
msgid "Must be a %q subclass."
-msgstr "Debe de ser una subclase de %q"
+msgstr "Debe de ser una subclase de %q."
#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c
msgid "Must provide MISO or MOSI pin"
msgstr "Debe proporcionar un pin MISO o MOSI"
+#: ports/stm/common-hal/busio/SPI.c
+msgid "Must provide SCK pin"
+msgstr "Debes proveer un pin para SCK"
+
#: shared-bindings/rgbmatrix/RGBMatrix.c
#, c-format
msgid "Must use a multiple of 6 rgb pins, not %d"
-msgstr ""
+msgstr "Debe usar un múltiplo de 6 pines rgb, no %d"
#: py/parse.c
msgid "Name too long"
@@ -1100,7 +1152,7 @@ msgstr "Nombre muy largo"
#: ports/nrf/common-hal/_bleio/Characteristic.c
msgid "No CCCD for this Characteristic"
-msgstr ""
+msgstr "No hay CCCD para esta característica"
#: ports/atmel-samd/common-hal/analogio/AnalogOut.c
#: ports/stm/common-hal/analogio/AnalogOut.c
@@ -1191,7 +1243,7 @@ msgstr "No hay temporizador disponible"
#: supervisor/shared/safe_mode.c
msgid "Nordic Soft Device failure assertion."
-msgstr ""
+msgstr "fallo de aserción de dispositivo Nordic Soft."
#: ports/nrf/common-hal/_bleio/__init__.c
#: shared-bindings/_bleio/CharacteristicBuffer.c
@@ -1208,7 +1260,7 @@ msgid ""
"Object has been deinitialized and can no longer be used. Create a new object."
msgstr ""
"El objeto se ha desinicializado y ya no se puede utilizar. Crea un nuevo "
-"objeto"
+"objeto."
#: ports/nrf/common-hal/busio/UART.c
msgid "Odd parity is not supported"
@@ -1232,10 +1284,12 @@ msgid ""
"Only monochrome, indexed 4bpp or 8bpp, and 16bpp or greater BMPs supported: "
"%d bpp given"
msgstr ""
+"Solo se admiten BMP monocromáticos, indexados de 4 bpp u 8 bpp y 16 bpp o "
+"más: %d bpp proporcionados"
#: shared-bindings/audiobusio/PDMIn.c
msgid "Oversample must be multiple of 8."
-msgstr "El sobremuestreo debe ser un múltiplo de 8"
+msgstr "El sobremuestreo debe ser un múltiplo de 8."
#: shared-bindings/pulseio/PWMOut.c
msgid ""
@@ -1246,8 +1300,8 @@ msgstr "PWM duty_cycle debe ser entre 0 y 65535 inclusivo (16 bit resolution)"
msgid ""
"PWM frequency not writable when variable_frequency is False on construction."
msgstr ""
-"PWM frecuencia no esta escrito cuando el variable_frequency es falso en "
-"construcion"
+"La frecuencia de PWM no se puede escribir variable_frequency es False en la "
+"construcción."
#: ports/mimxrt10xx/common-hal/displayio/ParallelBus.c
#: ports/stm/common-hal/displayio/ParallelBus.c
@@ -1285,6 +1339,8 @@ msgid ""
"bytes. If this cannot be avoided, pass allow_inefficient=True to the "
"constructor"
msgstr ""
+"El pinout utiliza %d bytes por elemento, lo que consume más del ideal de %d "
+"bytes. Si esto no se puede evitar, pase allow_inefficient=True al constructor"
#: py/builtinhelp.c
msgid "Plus any modules on the filesystem\n"
@@ -1300,7 +1356,7 @@ msgstr "Pop de un buffer Ps2 vacio"
#: shared-bindings/_bleio/Adapter.c
msgid "Prefix buffer must be on the heap"
-msgstr ""
+msgstr "El búfer de prefijo debe estar en el montículo"
#: main.c
msgid "Press any key to enter the REPL. Use CTRL-D to reload."
@@ -1321,7 +1377,7 @@ msgstr "PulseOut no es compatible con este chip"
#: ports/stm/common-hal/os/__init__.c
msgid "RNG DeInit Error"
-msgstr ""
+msgstr "Error de desinicializado del RNG"
#: ports/stm/common-hal/os/__init__.c
msgid "RNG Init Error"
@@ -1329,7 +1385,7 @@ msgstr "Error de inicialización de RNG"
#: ports/mimxrt10xx/common-hal/busio/UART.c
msgid "RS485 inversion specified when not in RS485 mode"
-msgstr ""
+msgstr "Se especifica inversión de RS485 sin estar en modo RS485"
#: ports/cxd56/common-hal/rtc/RTC.c ports/mimxrt10xx/common-hal/rtc/RTC.c
#: ports/nrf/common-hal/rtc/RTC.c
@@ -1343,12 +1399,13 @@ msgstr "RTC no soportado en esta placa"
#: ports/atmel-samd/common-hal/busio/UART.c ports/cxd56/common-hal/busio/UART.c
#: ports/nrf/common-hal/busio/UART.c ports/stm/common-hal/busio/UART.c
msgid "RTS/CTS/RS485 Not yet supported on this device"
-msgstr ""
+msgstr "Sin capacidad de RTS/CTS/RS485 para este dispositivo"
#: ports/stm/common-hal/os/__init__.c
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"
@@ -1385,6 +1442,10 @@ msgstr "Ejecutando en modo seguro! La auto-recarga esta deshabilitada.\n"
msgid "Running in safe mode! Not running saved code.\n"
msgstr "Ejecutando en modo seguro! No se esta ejecutando el código guardado.\n"
+#: shared-module/sdcardio/SDCard.c
+msgid "SD card CSD format not supported"
+msgstr "Sin capacidad para formato CSD para tarjeta SD"
+
#: ports/atmel-samd/common-hal/busio/I2C.c
#: ports/mimxrt10xx/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c
msgid "SDA or SCL needs a pull up"
@@ -1426,16 +1487,18 @@ msgstr "Serializer está siendo utilizado"
#: shared-bindings/nvm/ByteArray.c
msgid "Slice and value different lengths."
-msgstr "Slice y value tienen diferentes longitudes"
+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"
#: shared-bindings/aesio/aes.c
msgid "Source and destination buffers must be the same length"
-msgstr ""
+msgstr "Los búferes de fuente y destino deben ser del mismo tamaño"
#: extmod/modure.c
msgid "Splitting with sub-captures"
@@ -1455,7 +1518,7 @@ msgstr "Suministre al menos un pin UART"
#: shared-bindings/gnss/GNSS.c
msgid "System entry must be gnss.SatelliteSystem"
-msgstr ""
+msgstr "La entrada del sistema debe ser gnss.SatelliteSystem"
#: ports/stm/common-hal/microcontroller/Processor.c
msgid "Temperature read timed out"
@@ -1466,12 +1529,16 @@ msgid ""
"The CircuitPython heap was corrupted because the stack was too small.\n"
"Please increase the stack size if you know how, or if not:"
msgstr ""
+"El montículo de CircuitPython se dañó porque la pila era demasiado pequeña.\n"
+"Aumente el tamaño de la pila si sabe cómo, o si no:"
#: supervisor/shared/safe_mode.c
msgid ""
"The `microcontroller` module was used to boot into safe mode. Press reset to "
"exit safe mode.\n"
msgstr ""
+"El módulo de `microcontroller` fue utilizado para bootear en modo seguro. "
+"Presione reset para salir del modo seguro.\n"
#: supervisor/shared/safe_mode.c
msgid ""
@@ -1479,6 +1546,11 @@ msgid ""
"enough power for the whole circuit and press reset (after ejecting "
"CIRCUITPY).\n"
msgstr ""
+"La alimentación de la microntroladora bajó. Asegúrate que tu fuente de "
+"poder\n"
+"pueda suplir suficiente energía para todo el circuito y presione reset "
+"(luego de\n"
+"expulsar CIRCUITPY)\n"
#: shared-module/audiomixer/MixerVoice.c
msgid "The sample's bits_per_sample does not match the mixer's"
@@ -1534,6 +1606,7 @@ msgstr "Muchos displays"
#: ports/nrf/common-hal/_bleio/PacketBuffer.c
msgid "Total data to write is larger than outgoing_packet_length"
msgstr ""
+"Los datos totales a escribir son más grandes que outgoing_packet_length"
#: py/obj.c
msgid "Traceback (most recent call last):\n"
@@ -1545,7 +1618,7 @@ msgstr "Argumento tuple o struct_time requerido"
#: ports/stm/common-hal/busio/UART.c
msgid "UART Buffer allocation error"
-msgstr ""
+msgstr "No se pudo encontrar el búfer para UART"
#: ports/stm/common-hal/busio/UART.c
msgid "UART De-init error"
@@ -1608,7 +1681,7 @@ msgstr "No se pudo leer los datos de la paleta de colores"
#: shared-bindings/nvm/ByteArray.c
msgid "Unable to write to nvm."
-msgstr "Imposible escribir en nvm"
+msgstr "Imposible escribir en nvm."
#: ports/nrf/common-hal/_bleio/UUID.c
msgid "Unexpected nrfx uuid type"
@@ -1617,7 +1690,7 @@ msgstr "Tipo de uuid nrfx inesperado"
#: ports/nrf/common-hal/_bleio/__init__.c
#, c-format
msgid "Unknown gatt error: 0x%04x"
-msgstr ""
+msgstr "Error de gatt desconocido: 0x%04x"
#: supervisor/shared/safe_mode.c
msgid "Unknown reason."
@@ -1636,13 +1709,15 @@ msgstr "Error suave desconocido en dispositivo: %04x"
#: shared-bindings/_pixelbuf/PixelBuf.c
#, c-format
msgid "Unmatched number of items on RHS (expected %d, got %d)."
-msgstr "Número incomparable de elementos en RHS (%d esperado,%d obtenido)"
+msgstr "Número incomparable de elementos en RHS (%d esperado,%d obtenido)."
#: ports/nrf/common-hal/_bleio/__init__.c
msgid ""
"Unspecified issue. Can be that the pairing prompt on the other device was "
"declined or ignored."
msgstr ""
+"Problema no especificado. Puede ser que la señal de emparejamiento del otro "
+"dispositivo fue declinada o ignorada."
#: ports/atmel-samd/common-hal/busio/I2C.c ports/cxd56/common-hal/busio/I2C.c
#: ports/stm/common-hal/busio/I2C.c
@@ -1650,9 +1725,8 @@ msgid "Unsupported baudrate"
msgstr "Baudrate no soportado"
#: shared-module/displayio/display_core.c
-#, fuzzy
msgid "Unsupported display bus type"
-msgstr "tipo de bitmap no soportado"
+msgstr "Sin capacidad de bus tipo display"
#: shared-module/audiocore/WaveFile.c
msgid "Unsupported format"
@@ -1669,20 +1743,20 @@ msgstr "valor pull no soportado."
#: ports/nrf/common-hal/_bleio/Characteristic.c
#: ports/nrf/common-hal/_bleio/Descriptor.c
msgid "Value length != required fixed length"
-msgstr ""
+msgstr "Tamaño del valor != del tamaño fijo requerido"
#: ports/nrf/common-hal/_bleio/Characteristic.c
#: ports/nrf/common-hal/_bleio/Descriptor.c
msgid "Value length > max_length"
-msgstr ""
+msgstr "Tamaño de valor > max_length"
#: py/emitnative.c
msgid "Viper functions don't currently support more than 4 arguments"
-msgstr "funciones Viper actualmente no soportan más de 4 argumentos."
+msgstr "funciones Viper no soportan por el momento, más de 4 argumentos"
#: ports/stm/common-hal/microcontroller/Processor.c
msgid "Voltage read timed out"
-msgstr ""
+msgstr "Tiempo de espera agotado para lectura de voltaje"
#: main.c
msgid "WARNING: Your code filename has two extensions\n"
@@ -1691,22 +1765,25 @@ msgstr "ADVERTENCIA: El nombre de archivo de tu código tiene dos extensiones\n"
#: shared-bindings/watchdog/WatchDogTimer.c
msgid "WatchDogTimer cannot be deinitialized once mode is set to RESET"
msgstr ""
+"WatchDogTimer no se puede desinicializar luego de definirse en modo RESET"
#: shared-bindings/watchdog/WatchDogTimer.c
msgid "WatchDogTimer is not currently running"
-msgstr ""
+msgstr "WatchDogTimer no se está ejecutando en este momento"
#: shared-bindings/watchdog/WatchDogTimer.c
msgid "WatchDogTimer.mode cannot be changed once set to WatchDogMode.RESET"
msgstr ""
+"WatchDogTimer.mode no se puede modificar luego de configurar WatchDogMode."
+"RESET"
#: shared-bindings/watchdog/WatchDogTimer.c
msgid "WatchDogTimer.timeout must be greater than 0"
-msgstr ""
+msgstr "WatchDogTimer.timeout debe ser mayor a 0"
#: supervisor/shared/safe_mode.c
msgid "Watchdog timer expired."
-msgstr ""
+msgstr "Temporizador de perro guardián expirado."
#: py/builtinhelp.c
#, c-format
@@ -1726,11 +1803,11 @@ msgstr ""
#: ports/nrf/common-hal/_bleio/PacketBuffer.c
msgid "Writes not supported on Characteristic"
-msgstr ""
+msgstr "Escrituras no admitidas en la característica"
#: supervisor/shared/safe_mode.c
msgid "You are in safe mode: something unanticipated happened.\n"
-msgstr ""
+msgstr "Estás en modo seguro: algo inesperado ha sucedido.\n"
#: supervisor/shared/safe_mode.c
msgid "You requested starting safe mode by "
@@ -1772,7 +1849,7 @@ msgstr "addresses esta vacío"
#: extmod/ulab/code/vectorise.c
msgid "arctan2 is implemented for scalars and ndarrays only"
-msgstr ""
+msgstr "arctan2 se encuentra implementado solo para escalares y ndarrays"
#: py/modbuiltins.c
msgid "arg is an empty sequence"
@@ -1780,7 +1857,7 @@ msgstr "argumento es una secuencia vacía"
#: extmod/ulab/code/numerical.c
msgid "argsort argument must be an ndarray"
-msgstr ""
+msgstr "El argumento para argsort debe ser un ndarray"
#: py/runtime.c
msgid "argument has wrong type"
@@ -1797,7 +1874,7 @@ msgstr "argumento deberia ser un '%q' no un '%q'"
#: extmod/ulab/code/linalg.c
msgid "arguments must be ndarrays"
-msgstr ""
+msgstr "argumentos deben ser ndarrays"
#: py/objarray.c shared-bindings/nvm/ByteArray.c
msgid "array/bytes required on right side"
@@ -1805,7 +1882,7 @@ msgstr "array/bytes requeridos en el lado derecho"
#: extmod/ulab/code/numerical.c
msgid "attempt to get argmin/argmax of an empty sequence"
-msgstr ""
+msgstr "se trató de traer argmin/argmax de una secuencia vacía"
#: py/objstr.c
msgid "attributes not supported yet"
@@ -1813,15 +1890,15 @@ msgstr "atributos aún no soportados"
#: extmod/ulab/code/numerical.c
msgid "axis must be -1, 0, None, or 1"
-msgstr ""
+msgstr "eje debe ser -1, 0, None o 1"
#: extmod/ulab/code/numerical.c
msgid "axis must be -1, 0, or 1"
-msgstr ""
+msgstr "eje debe ser -1, 0, o 1"
#: extmod/ulab/code/numerical.c
msgid "axis must be None, 0, or 1"
-msgstr ""
+msgstr "eje debe ser None, 0, o 1"
#: py/builtinevex.c
msgid "bad compile mode"
@@ -1852,9 +1929,8 @@ msgid "bits_per_sample must be 8 or 16"
msgstr "bits_per_sample debe ser 8 ó 16"
#: py/emitinlinethumb.c
-#, fuzzy
msgid "branch not in range"
-msgstr "El argumento de chr() no esta en el rango(256)"
+msgstr "la rama no está dentro del rango"
#: shared-bindings/audiocore/RawSample.c
msgid "buffer must be a bytes-like object"
@@ -1883,7 +1959,7 @@ msgstr "codigo byte no implementado"
#: shared-bindings/_pixelbuf/PixelBuf.c
msgid "byteorder is not a string"
-msgstr ""
+msgstr "byteorder no es una cadena"
#: ports/atmel-samd/common-hal/busio/UART.c
msgid "bytes > 8 bits not supported"
@@ -2017,6 +2093,10 @@ msgid "can't send non-None value to a just-started generator"
msgstr ""
"no se puede enviar un valor que no sea None a un generador recién iniciado"
+#: shared-module/sdcardio/SDCard.c
+msgid "can't set 512 block size"
+msgstr "no se puede definir un tamaño de bloque de 512"
+
#: py/objnamedtuple.c
msgid "can't set attribute"
msgstr "no se puede asignar el atributo"
@@ -2065,11 +2145,11 @@ msgstr "no se puedo realizar importación relativa"
#: extmod/ulab/code/ndarray.c
msgid "cannot reshape array (incompatible input/output shape)"
-msgstr ""
+msgstr "no se puede reformar el arreglo (forma de entrada/salida incompatible)"
#: py/emitnative.c
msgid "casting"
-msgstr ""
+msgstr "convirtiendo tipo"
#: shared-bindings/_stage/Text.c
msgid "chars buffer too small"
@@ -2085,7 +2165,7 @@ msgstr "El argumento de chr() no esta en el rango(256)"
#: shared-module/vectorio/Circle.c
msgid "circle can only be registered in one parent"
-msgstr ""
+msgstr "circle solo puede ser registrado con un pariente"
#: shared-bindings/displayio/Palette.c
msgid "color buffer must be 3 bytes (RGB) or 4 bytes (RGB + pad byte)"
@@ -2093,7 +2173,7 @@ msgstr "color buffer debe ser 3 bytes (RGB) ó 4 bytes (RGB + pad byte)"
#: shared-bindings/displayio/Palette.c
msgid "color buffer must be a buffer, tuple, list, or int"
-msgstr ""
+msgstr "el búfer de color debe ser un búfer, una tupla, una lista o un entero"
#: shared-bindings/displayio/Palette.c
msgid "color buffer must be a bytearray or array of type 'b' or 'B'"
@@ -2129,35 +2209,39 @@ msgstr "conversión a objeto"
#: extmod/ulab/code/filter.c
msgid "convolve arguments must be linear arrays"
-msgstr ""
+msgstr "los argumentos para convolve deben ser arreglos lineares"
#: extmod/ulab/code/filter.c
msgid "convolve arguments must be ndarrays"
-msgstr ""
+msgstr "los argumentos para convolve deben ser ndarrays"
#: extmod/ulab/code/filter.c
msgid "convolve arguments must not be empty"
-msgstr ""
+msgstr "los argumentos para convolve no deben estar vacíos"
#: extmod/ulab/code/ndarray.c
msgid "could not broadast input array from shape"
-msgstr ""
+msgstr "no se pudo anunciar la matriz de entrada desde la forma"
#: extmod/ulab/code/poly.c
msgid "could not invert Vandermonde matrix"
-msgstr ""
+msgstr "no se pudo invertir la matriz de Vandermonde"
+
+#: shared-module/sdcardio/SDCard.c
+msgid "couldn't determine SD card version"
+msgstr "no se pudo determinar la versión de la tarjeta SD"
#: extmod/ulab/code/approx.c
msgid "data must be iterable"
-msgstr ""
+msgstr "los datos deben permitir iteración"
#: extmod/ulab/code/approx.c
msgid "data must be of equal length"
-msgstr ""
+msgstr "los datos deben ser de igual tamaño"
#: extmod/ulab/code/numerical.c
msgid "ddof must be smaller than length of data set"
-msgstr ""
+msgstr "ddof debe ser menor que la longitud del conjunto de datos"
#: py/parsenum.c
msgid "decimal numbers not supported"
@@ -2188,7 +2272,7 @@ msgstr "la secuencia de actualizacion del dict tiene una longitud incorrecta"
#: extmod/ulab/code/numerical.c
msgid "diff argument must be an ndarray"
-msgstr ""
+msgstr "El argumento diff debe ser un ndarray"
#: py/modmath.c py/objfloat.c py/objint_longlong.c py/objint_mpz.c py/runtime.c
#: shared-bindings/math/__init__.c
@@ -2222,7 +2306,7 @@ msgstr "end_x debe ser un int"
#: ports/nrf/common-hal/busio/UART.c
#, c-format
msgid "error = 0x%08lX"
-msgstr "error = 0x%08lx"
+msgstr "error = 0x%08lX"
#: py/runtime.c
msgid "exceptions must derive from BaseException"
@@ -2262,23 +2346,23 @@ msgstr "argumento posicional adicional dado"
#: py/parse.c
msgid "f-string expression part cannot include a '#'"
-msgstr ""
+msgstr "La parte de expresión f-string no puede incluir un '#'"
#: py/parse.c
msgid "f-string expression part cannot include a backslash"
-msgstr ""
+msgstr "La parte de expresión f-string no puede incluir una barra invertida"
#: py/parse.c
msgid "f-string: empty expression not allowed"
-msgstr ""
+msgstr "cadena-f: expresión vacía no permitida"
#: py/parse.c
msgid "f-string: expecting '}'"
-msgstr ""
+msgstr "f-string: esperando '}'"
#: py/parse.c
msgid "f-string: single '}' is not allowed"
-msgstr ""
+msgstr "cadena-f: solo '}' no está permitido"
#: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c
#: shared-bindings/displayio/OnDiskBitmap.c
@@ -2291,19 +2375,19 @@ msgstr "sistema de archivos debe proporcionar método de montaje"
#: extmod/ulab/code/vectorise.c
msgid "first argument must be a callable"
-msgstr ""
+msgstr "se debe poder llamar al primer argumento"
#: extmod/ulab/code/approx.c
msgid "first argument must be a function"
-msgstr ""
+msgstr "el primer argumento debe ser una función"
#: extmod/ulab/code/ndarray.c
msgid "first argument must be an iterable"
-msgstr ""
+msgstr "el primer argumento debe permitir iteración"
#: extmod/ulab/code/vectorise.c
msgid "first argument must be an ndarray"
-msgstr ""
+msgstr "el primer argumento debe ser ndarray"
#: py/objtype.c
msgid "first argument to super() must be type"
@@ -2311,15 +2395,15 @@ msgstr "primer argumento para super() debe ser de tipo"
#: extmod/ulab/code/ndarray.c
msgid "flattening order must be either 'C', or 'F'"
-msgstr ""
+msgstr "el orden de aplanamiento debe ser 'C' o 'F'"
#: extmod/ulab/code/numerical.c
msgid "flip argument must be an ndarray"
-msgstr ""
+msgstr "el argumento invertido debe ser un ndarray"
#: py/objint.c
msgid "float too big"
-msgstr ""
+msgstr "punto flotante muy grande"
#: shared-bindings/_stage/Text.c
msgid "font must be 2048 bytes long"
@@ -2348,11 +2432,11 @@ msgstr "la función tiene múltiples valores para el argumento '%q'"
#: extmod/ulab/code/approx.c
msgid "function has the same sign at the ends of interval"
-msgstr ""
+msgstr "la función tiene el mismo signo a extremos del intervalo"
#: extmod/ulab/code/compare.c
msgid "function is implemented for scalars and ndarrays only"
-msgstr ""
+msgstr "la función está implementada solo para escalares y ndarrays"
#: py/argcheck.c
#, c-format
@@ -2379,7 +2463,7 @@ msgstr "la función toma %d argumentos posicionales pero le fueron dados %d"
#: shared-bindings/time/__init__.c
msgid "function takes exactly 9 arguments"
-msgstr "la función toma exactamente 9 argumentos."
+msgstr "la función toma exactamente 9 argumentos"
#: py/objgenerator.c
msgid "generator already executing"
@@ -2411,7 +2495,7 @@ msgstr "formato incompleto"
#: py/objstr.c
msgid "incomplete format key"
-msgstr ""
+msgstr "formato de llave incompleto"
#: extmod/modubinascii.c
msgid "incorrect padding"
@@ -2419,7 +2503,7 @@ msgstr "relleno (padding) incorrecto"
#: extmod/ulab/code/ndarray.c
msgid "index is out of bounds"
-msgstr ""
+msgstr "el índice está fuera de límites"
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c
#: ports/cxd56/common-hal/pulseio/PulseIn.c
@@ -2434,11 +2518,11 @@ msgstr "indices deben ser enteros"
#: extmod/ulab/code/ndarray.c
msgid "indices must be integers, slices, or Boolean lists"
-msgstr ""
+msgstr "los índices deben ser enteros, particiones o listas de booleanos"
#: extmod/ulab/code/approx.c
msgid "initial values must be iterable"
-msgstr ""
+msgstr "los valores iniciales deben permitir iteración"
#: py/compile.c
msgid "inline assembler must be a function"
@@ -2446,35 +2530,35 @@ msgstr "ensamblador en línea debe ser una función"
#: extmod/ulab/code/create.c
msgid "input argument must be an integer or a 2-tuple"
-msgstr ""
+msgstr "el argumento de entrada debe ser un entero o una tupla de par"
#: extmod/ulab/code/fft.c
msgid "input array length must be power of 2"
-msgstr ""
+msgstr "el tamaño del arreglo de entrada debe ser potencia de 2"
#: extmod/ulab/code/poly.c
msgid "input data must be an iterable"
-msgstr ""
+msgstr "los datos de entrada deben permitir iteración"
#: extmod/ulab/code/linalg.c
msgid "input matrix is asymmetric"
-msgstr ""
+msgstr "la matriz de entrada es asimétrica"
#: extmod/ulab/code/linalg.c
msgid "input matrix is singular"
-msgstr ""
+msgstr "la matriz de entrada es singular"
#: extmod/ulab/code/linalg.c
msgid "input must be square matrix"
-msgstr ""
+msgstr "la entrada debe ser una matriz cuadrada"
#: extmod/ulab/code/numerical.c
msgid "input must be tuple, list, range, or ndarray"
-msgstr ""
+msgstr "la entrada debe ser una tupla, lista, rango o ndarray"
#: extmod/ulab/code/poly.c
msgid "input vectors must be of equal length"
-msgstr ""
+msgstr "los vectores de entrada deben ser de igual tamaño"
#: py/parsenum.c
msgid "int() arg 2 must be >= 2 and <= 36"
@@ -2486,12 +2570,12 @@ msgstr "Entero requerido"
#: extmod/ulab/code/approx.c
msgid "interp is defined for 1D arrays of equal length"
-msgstr ""
+msgstr "interp está definido para arreglos de 1D del mismo tamaño"
#: shared-bindings/_bleio/Adapter.c
#, c-format
msgid "interval must be in range %s-%s"
-msgstr ""
+msgstr "el intervalo debe ser der rango %s-%s"
#: lib/netutils/netutils.c
msgid "invalid arguments"
@@ -2523,7 +2607,7 @@ msgstr "decorador de micropython inválido"
#: shared-bindings/random/__init__.c
msgid "invalid step"
-msgstr ""
+msgstr "paso inválido"
#: py/compile.c py/parse.c
msgid "invalid syntax"
@@ -2552,11 +2636,11 @@ msgstr "issubclass() arg 2 debe ser una clase o tuple de clases"
#: extmod/ulab/code/ndarray.c
msgid "iterables are not of the same length"
-msgstr ""
+msgstr "los iterables no son del mismo tamaño"
#: extmod/ulab/code/linalg.c
msgid "iterations did not converge"
-msgstr ""
+msgstr "las iteraciones no convergen"
#: py/objstr.c
msgid "join expects a list of str/bytes objects consistent with self object"
@@ -2587,7 +2671,7 @@ msgstr "argumento length no permitido para este tipo"
#: shared-bindings/audiomixer/MixerVoice.c
msgid "level must be between 0 and 1"
-msgstr ""
+msgstr "el nivel debe ser entre 0 y 1"
#: py/objarray.c
msgid "lhs and rhs should be compatible"
@@ -2611,7 +2695,7 @@ msgstr "long int no soportado en esta compilación"
#: py/parse.c
msgid "malformed f-string"
-msgstr ""
+msgstr "cadena-f mal formada"
#: shared-bindings/_stage/Layer.c
msgid "map buffer too small"
@@ -2623,17 +2707,17 @@ msgstr "error de dominio matemático"
#: extmod/ulab/code/linalg.c
msgid "matrix dimensions do not match"
-msgstr ""
+msgstr "las dimensiones de la matriz no coinciden"
#: extmod/ulab/code/linalg.c
msgid "matrix is not positive definite"
-msgstr ""
+msgstr "matrix no es definida positiva"
#: ports/nrf/common-hal/_bleio/Characteristic.c
#: ports/nrf/common-hal/_bleio/Descriptor.c
#, c-format
msgid "max_length must be 0-%d when fixed_length is %s"
-msgstr ""
+msgstr "max_length debe ser 0-%d cuando fixed_length es %s"
#: py/runtime.c
msgid "maximum recursion depth exceeded"
@@ -2654,7 +2738,7 @@ msgstr "módulo no encontrado"
#: extmod/ulab/code/poly.c
msgid "more degrees of freedom than data points"
-msgstr ""
+msgstr "más grados de libertad que los puntos de datos"
#: py/compile.c
msgid "multiple *x in assignment"
@@ -2678,7 +2762,7 @@ msgstr "debe utilizar argumento de palabra clave para la función clave"
#: extmod/ulab/code/numerical.c
msgid "n must be between 0, and 9"
-msgstr ""
+msgstr "n debe estar entre 0 y 9"
#: py/runtime.c
msgid "name '%q' is not defined"
@@ -2709,6 +2793,10 @@ msgstr "potencia negativa sin float support"
msgid "negative shift count"
msgstr "cuenta de corrimientos negativo"
+#: shared-module/sdcardio/SDCard.c
+msgid "no SD card"
+msgstr "no hay tarjeta SD"
+
#: py/vm.c
msgid "no active exception to reraise"
msgstr "exception no activa para reraise"
@@ -2728,7 +2816,11 @@ msgstr "ningún módulo se llama '%q'"
#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/I2CDisplay.c
#: shared-bindings/displayio/ParallelBus.c
msgid "no reset pin available"
-msgstr ""
+msgstr "no hay pin de reinicio disponible"
+
+#: shared-module/sdcardio/SDCard.c
+msgid "no response from SD card"
+msgstr "no hay respuesta de la tarjeta SD"
#: py/runtime.c
msgid "no such attribute"
@@ -2736,7 +2828,7 @@ msgstr "no hay tal atributo"
#: ports/nrf/common-hal/_bleio/Connection.c
msgid "non-UUID found in service_uuids_whitelist"
-msgstr ""
+msgstr "no UUID encontrado en service_uuids_whitelist"
#: py/compile.c
msgid "non-default argument follows default argument"
@@ -2771,11 +2863,11 @@ msgstr "no suficientes argumentos para format string"
#: extmod/ulab/code/poly.c
msgid "number of arguments must be 2, or 3"
-msgstr ""
+msgstr "el número de argumentos debe ser 2 o 3"
#: extmod/ulab/code/create.c
msgid "number of points must be at least 2"
-msgstr ""
+msgstr "el número de puntos debe ser al menos 2"
#: py/obj.c
#, c-format
@@ -2828,17 +2920,16 @@ msgid "odd-length string"
msgstr "string de longitud impar"
#: py/objstr.c py/objstrunicode.c
-#, fuzzy
msgid "offset out of bounds"
-msgstr "address fuera de límites"
+msgstr "offset fuera de límites"
#: ports/nrf/common-hal/audiobusio/PDMIn.c
msgid "only bit_depth=16 is supported"
-msgstr ""
+msgstr "solo se admite bit_depth=16"
#: ports/nrf/common-hal/audiobusio/PDMIn.c
msgid "only sample_rate=16000 is supported"
-msgstr ""
+msgstr "solo se admite sample_rate=16000"
#: py/objarray.c py/objstr.c py/objstrunicode.c py/objtuple.c
#: shared-bindings/nvm/ByteArray.c
@@ -2848,15 +2939,15 @@ msgstr "solo se admiten segmentos con step=1 (alias None)"
#: extmod/ulab/code/compare.c extmod/ulab/code/ndarray.c
#: extmod/ulab/code/vectorise.c
msgid "operands could not be broadcast together"
-msgstr ""
+msgstr "los operandos no se pueden transmitir juntos"
#: extmod/ulab/code/numerical.c
msgid "operation is not implemented on ndarrays"
-msgstr ""
+msgstr "la operación no está implementada para ndarrays"
#: extmod/ulab/code/ndarray.c
msgid "operation is not supported for given type"
-msgstr ""
+msgstr "la operación no es compatible para un tipo dado"
#: py/modbuiltins.c
msgid "ord expects a character"
@@ -2905,7 +2996,7 @@ msgstr "pixel_shader debe ser displayio.Palette o displayio.ColorConverter"
#: shared-module/vectorio/Polygon.c
msgid "polygon can only be registered in one parent"
-msgstr ""
+msgstr "el polígono solo se puede registrar en uno de los padres"
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c
#: ports/cxd56/common-hal/pulseio/PulseIn.c
@@ -2940,11 +3031,11 @@ msgstr "desbordamiento de cola(queue)"
#: py/parse.c
msgid "raw f-strings are not implemented"
-msgstr ""
+msgstr "no está implementado cadenas-f sin procesar"
#: extmod/ulab/code/fft.c
msgid "real and imaginary parts must be of equal length"
-msgstr ""
+msgstr "las partes reales e imaginarias deben ser de igual longitud"
#: py/builtinimport.c
msgid "relative import"
@@ -2966,16 +3057,16 @@ msgstr "retorno esperado '%q' pero se obtuvo '%q'"
#: shared-bindings/rgbmatrix/RGBMatrix.c
#, c-format
msgid "rgb_pins[%d] duplicates another pin assignment"
-msgstr ""
+msgstr "rgb_pins[%d] duplica otra asignación de pin"
#: shared-bindings/rgbmatrix/RGBMatrix.c
#, c-format
msgid "rgb_pins[%d] is not on the same port as clock"
-msgstr ""
+msgstr "rgb_pins[%d] no está en el mismo puerto que el reloj"
#: extmod/ulab/code/ndarray.c
msgid "right hand side must be an ndarray, or a scalar"
-msgstr ""
+msgstr "el lado derecho debe ser un ndarray o escalar"
#: py/objstr.c
msgid "rsplit(None,n)"
@@ -2995,7 +3086,7 @@ msgstr "frecuencia de muestreo fuera de rango"
#: py/modmicropython.c
msgid "schedule stack full"
-msgstr ""
+msgstr "pila de horario llena"
#: lib/utils/pyexec.c py/builtinimport.c
msgid "script compilation not supported"
@@ -3003,7 +3094,7 @@ msgstr "script de compilación no soportado"
#: extmod/ulab/code/ndarray.c
msgid "shape must be a 2-tuple"
-msgstr ""
+msgstr "la forma debe ser una tupla de 2"
#: py/objstr.c
msgid "sign not allowed in string format specifier"
@@ -3019,12 +3110,16 @@ msgstr "un solo '}' encontrado en format string"
#: extmod/ulab/code/linalg.c
msgid "size is defined for ndarrays only"
-msgstr ""
+msgstr "el tamaño se define solo para ndarrays"
#: shared-bindings/time/__init__.c
msgid "sleep length must be non-negative"
msgstr "la longitud de sleep no puede ser negativa"
+#: extmod/ulab/code/ndarray.c
+msgid "slice step can't be zero"
+msgstr "el tamaño de la división no puede ser cero"
+
#: py/objslice.c py/sequence.c
msgid "slice step cannot be zero"
msgstr "slice step no puede ser cero"
@@ -3039,16 +3134,27 @@ msgstr "reinicio suave\n"
#: extmod/ulab/code/numerical.c
msgid "sort argument must be an ndarray"
-msgstr ""
+msgstr "argumento de ordenado debe ser un ndarray"
+
+#: extmod/ulab/code/filter.c
+msgid "sos array must be of shape (n_section, 6)"
+msgstr "el arreglo sos debe de forma (n_section, 6)"
+
+#: extmod/ulab/code/filter.c
+msgid "sos[:, 3] should be all ones"
+msgstr "sos[:, 3] deberían ser todos unos"
+
+#: extmod/ulab/code/filter.c
+msgid "sosfilt requires iterable arguments"
+msgstr "sosfilt requiere argumentos iterables"
#: py/objstr.c
msgid "start/end indices"
msgstr "índices inicio/final"
#: shared-bindings/displayio/Shape.c
-#, fuzzy
msgid "start_x should be an int"
-msgstr "y deberia ser un int"
+msgstr "start_x deberia ser un int"
#: shared-bindings/random/__init__.c
msgid "step must be non-zero"
@@ -3091,7 +3197,7 @@ msgstr "struct: index fuera de rango"
msgid "struct: no fields"
msgstr "struct: sin campos"
-#: py/objstr.c
+#: py/objarray.c py/objstr.c
msgid "substring not found"
msgstr "substring no encontrado"
@@ -3118,15 +3224,24 @@ msgstr "time.struct_time() toma un sequencio 9"
#: ports/nrf/common-hal/watchdog/WatchDogTimer.c
msgid "timeout duration exceeded the maximum supported value"
msgstr ""
+"la duración de tiempo de espera ha excedido la capacidad máxima del valor"
#: shared-bindings/busio/UART.c
msgid "timeout must be 0.0-100.0 seconds"
-msgstr ""
+msgstr "el tiempo de espera debe ser 0.0-100.0 segundos"
#: shared-bindings/_bleio/CharacteristicBuffer.c
msgid "timeout must be >= 0.0"
msgstr "tiempo muerto debe ser >= 0.0"
+#: shared-module/sdcardio/SDCard.c
+msgid "timeout waiting for v1 card"
+msgstr "tiempo de espera agotado esperando por tarjeta v1"
+
+#: shared-module/sdcardio/SDCard.c
+msgid "timeout waiting for v2 card"
+msgstr "tiempo de espera agotado esperando a tarjeta v2"
+
#: shared-bindings/time/__init__.c
msgid "timestamp out of range for platform time_t"
msgstr "timestamp fuera de rango para plataform time_t"
@@ -3137,7 +3252,7 @@ msgstr "demasiados argumentos provistos con el formato dado"
#: extmod/ulab/code/ndarray.c
msgid "too many indices"
-msgstr ""
+msgstr "demasiados índices"
#: py/runtime.c
#, c-format
@@ -3266,31 +3381,31 @@ msgstr "tipos no soportados para %q: '%s', '%s'"
#: py/objint.c
#, c-format
msgid "value must fit in %d byte(s)"
-msgstr ""
+msgstr "el valor debe caber en %d byte(s)"
#: shared-bindings/displayio/Bitmap.c
msgid "value_count must be > 0"
-msgstr ""
+msgstr "value_count debe ser > 0"
#: shared-bindings/watchdog/WatchDogTimer.c
msgid "watchdog timeout must be greater than 0"
-msgstr ""
+msgstr "el tiempo de espera del perro guardián debe ser mayor a 0"
#: shared-bindings/_bleio/Adapter.c
msgid "window must be <= interval"
-msgstr ""
+msgstr "la ventana debe ser <= intervalo"
#: extmod/ulab/code/linalg.c
msgid "wrong argument type"
-msgstr ""
+msgstr "tipo de argumento incorrecto"
#: extmod/ulab/code/ndarray.c
msgid "wrong index type"
-msgstr ""
+msgstr "tipo de índice incorrecto"
#: extmod/ulab/code/vectorise.c
msgid "wrong input type"
-msgstr ""
+msgstr "tipo de entrada incorrecta"
#: py/objstr.c
msgid "wrong number of arguments"
@@ -3302,30 +3417,40 @@ msgstr "numero erroneo de valores a descomprimir"
#: extmod/ulab/code/ndarray.c
msgid "wrong operand type"
-msgstr ""
+msgstr "tipo de operando incorrecto"
#: extmod/ulab/code/vectorise.c
msgid "wrong output type"
-msgstr ""
+msgstr "tipo de salida incorrecta"
#: shared-module/displayio/Shape.c
-#, fuzzy
msgid "x value out of bounds"
-msgstr "address fuera de límites"
+msgstr "valor x fuera de límites"
#: shared-bindings/displayio/Shape.c
msgid "y should be an int"
msgstr "y deberia ser un int"
#: shared-module/displayio/Shape.c
-#, fuzzy
msgid "y value out of bounds"
-msgstr "address fuera de límites"
+msgstr "valor y fuera de límites"
#: py/objrange.c
msgid "zero step"
msgstr "paso cero"
+#: extmod/ulab/code/filter.c
+msgid "zi must be an ndarray"
+msgstr "zi debe ser un ndarray"
+
+#: extmod/ulab/code/filter.c
+msgid "zi must be of float type"
+msgstr "zi debe ser de tipo flotante"
+
+#: extmod/ulab/code/filter.c
+msgid "zi must be of shape (n_section, 2)"
+msgstr "zi debe ser una forma (n_section,2)"
+
#~ msgid "AP required"
#~ msgstr "AP requerido"
diff --git a/locale/fil.po b/locale/fil.po
index e4c5678d2..92dc9cc91 100644
--- a/locale/fil.po
+++ b/locale/fil.po
@@ -1,13 +1,11 @@
-# SOME DESCRIPTIVE TITLE.
-# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
-# This file is distributed under the same license as the PACKAGE package.
-# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
#
+# SPDX-License-Identifier: MIT
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2020-06-25 11:44-0500\n"
+"POT-Creation-Date: 2020-07-17 18:03-0700\n"
"PO-Revision-Date: 2018-12-20 22:15-0800\n"
"Last-Translator: Timothy <me@timothygarcia.ca>\n"
"Language-Team: fil\n"
@@ -58,6 +56,10 @@ msgstr "%%c nangangailangan ng int o char"
msgid "%d address pins and %d rgb pins indicate a height of %d, not %d"
msgstr ""
+#: ports/atmel-samd/common-hal/sdioio/SDCard.c
+msgid "%q failure: %d"
+msgstr ""
+
#: shared-bindings/microcontroller/Pin.c
msgid "%q in use"
msgstr "%q ay ginagamit"
@@ -74,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"
@@ -86,6 +93,10 @@ msgstr "aarehas na haba dapat ang buffer slices"
msgid "%q must be a tuple of length 2"
msgstr ""
+#: ports/atmel-samd/common-hal/sdioio/SDCard.c
+msgid "%q pin invalid"
+msgstr ""
+
#: shared-bindings/fontio/BuiltinFont.c
#, fuzzy
msgid "%q should be an int"
@@ -100,6 +111,10 @@ msgstr ""
msgid "'%q' argument required"
msgstr "'%q' argument kailangan"
+#: py/objarray.c
+msgid "'%q' object is not bytes-like"
+msgstr ""
+
#: py/emitinlinethumb.c py/emitinlinextensa.c
#, c-format
msgid "'%s' expects a label"
@@ -311,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 ""
@@ -342,10 +362,15 @@ msgstr "May halfwords (type 'H') dapat ang array"
msgid "Array values should be single bytes."
msgstr "Array values ay dapat single bytes."
-#: shared-bindings/rgbmatrix/RGBMatrix.c
+#: shared-bindings/microcontroller/Pin.c
msgid "At most %d %q may be specified (not %d)"
msgstr ""
+#: shared-module/memorymonitor/AllocationAlarm.c
+#, c-format
+msgid "Attempt to allocate %d blocks"
+msgstr ""
+
#: supervisor/shared/safe_mode.c
msgid "Attempted heap allocation when MicroPython VM not running."
msgstr ""
@@ -423,6 +448,11 @@ msgstr ""
msgid "Buffer length %d too big. It must be less than %d"
msgstr ""
+#: ports/atmel-samd/common-hal/sdioio/SDCard.c
+#: ports/cxd56/common-hal/sdioio/SDCard.c shared-module/sdcardio/SDCard.c
+msgid "Buffer length must be a multiple of 512"
+msgstr ""
+
#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c
msgid "Buffer must be at least length 1"
msgstr "Buffer dapat ay hindi baba sa 1 na haba"
@@ -463,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"
@@ -586,6 +618,10 @@ msgstr ""
msgid "Could not initialize GNSS"
msgstr ""
+#: ports/cxd56/common-hal/sdioio/SDCard.c
+msgid "Could not initialize SDCard"
+msgstr ""
+
#: ports/atmel-samd/common-hal/busio/UART.c ports/cxd56/common-hal/busio/UART.c
msgid "Could not initialize UART"
msgstr "Hindi ma-initialize ang UART"
@@ -710,7 +746,8 @@ msgstr "Ginagamit na ang EXTINT channel"
msgid "Error in regex"
msgstr "May pagkakamali sa REGEX"
-#: shared-bindings/aesio/aes.c shared-bindings/microcontroller/Pin.c
+#: shared-bindings/aesio/aes.c shared-bindings/busio/SPI.c
+#: shared-bindings/microcontroller/Pin.c
#: shared-bindings/neopixel_write/__init__.c shared-bindings/pulseio/PulseOut.c
#: shared-bindings/terminalio/Terminal.c
msgid "Expected a %q"
@@ -874,6 +911,10 @@ msgstr ""
msgid "Internal error #%d"
msgstr ""
+#: shared-bindings/sdioio/SDCard.c
+msgid "Invalid %q"
+msgstr ""
+
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
msgid "Invalid %q pin"
@@ -981,7 +1022,8 @@ msgstr "Mali ang pin para sa kanang channel"
#: ports/atmel-samd/common-hal/busio/UART.c
#: ports/atmel-samd/common-hal/i2cperipheral/I2CPeripheral.c
#: ports/cxd56/common-hal/busio/I2C.c ports/cxd56/common-hal/busio/SPI.c
-#: ports/cxd56/common-hal/busio/UART.c ports/mimxrt10xx/common-hal/busio/I2C.c
+#: ports/cxd56/common-hal/busio/UART.c ports/cxd56/common-hal/sdioio/SDCard.c
+#: ports/mimxrt10xx/common-hal/busio/I2C.c
#: ports/mimxrt10xx/common-hal/busio/SPI.c
#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/I2C.c
msgid "Invalid pins"
@@ -1085,6 +1127,10 @@ msgstr ""
msgid "Must provide MISO or MOSI pin"
msgstr ""
+#: ports/stm/common-hal/busio/SPI.c
+msgid "Must provide SCK pin"
+msgstr ""
+
#: shared-bindings/rgbmatrix/RGBMatrix.c
#, c-format
msgid "Must use a multiple of 6 rgb pins, not %d"
@@ -1344,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"
@@ -1381,6 +1428,10 @@ msgstr "Tumatakbo sa safe mode! Awtomatikong pag re-reload ay OFF.\n"
msgid "Running in safe mode! Not running saved code.\n"
msgstr "Tumatakbo sa safe mode! Hindi tumatakbo ang nai-save na code.\n"
+#: shared-module/sdcardio/SDCard.c
+msgid "SD card CSD format not supported"
+msgstr ""
+
#: ports/atmel-samd/common-hal/busio/I2C.c
#: ports/mimxrt10xx/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c
msgid "SDA or SCL needs a pull up"
@@ -1425,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"
@@ -2015,6 +2068,10 @@ msgstr "hindi mapadala ang send throw sa isang kaka umpisang generator"
msgid "can't send non-None value to a just-started generator"
msgstr "hindi mapadala ang non-None value sa isang kaka umpisang generator"
+#: shared-module/sdcardio/SDCard.c
+msgid "can't set 512 block size"
+msgstr ""
+
#: py/objnamedtuple.c
msgid "can't set attribute"
msgstr "hindi ma i-set ang attribute"
@@ -2145,6 +2202,10 @@ msgstr ""
msgid "could not invert Vandermonde matrix"
msgstr ""
+#: shared-module/sdcardio/SDCard.c
+msgid "couldn't determine SD card version"
+msgstr ""
+
#: extmod/ulab/code/approx.c
msgid "data must be iterable"
msgstr ""
@@ -2712,6 +2773,10 @@ msgstr "negatibong power na walang float support"
msgid "negative shift count"
msgstr "negative shift count"
+#: shared-module/sdcardio/SDCard.c
+msgid "no SD card"
+msgstr ""
+
#: py/vm.c
msgid "no active exception to reraise"
msgstr "walang aktibong exception para i-reraise"
@@ -2733,6 +2798,10 @@ msgstr "walang module na '%q'"
msgid "no reset pin available"
msgstr ""
+#: shared-module/sdcardio/SDCard.c
+msgid "no response from SD card"
+msgstr ""
+
#: py/runtime.c
msgid "no such attribute"
msgstr "walang ganoon na attribute"
@@ -3026,6 +3095,10 @@ msgstr ""
msgid "sleep length must be non-negative"
msgstr "sleep length ay dapat hindi negatibo"
+#: extmod/ulab/code/ndarray.c
+msgid "slice step can't be zero"
+msgstr ""
+
#: py/objslice.c py/sequence.c
msgid "slice step cannot be zero"
msgstr "slice step ay hindi puedeng 0"
@@ -3042,6 +3115,18 @@ msgstr "malambot na reboot\n"
msgid "sort argument must be an ndarray"
msgstr ""
+#: extmod/ulab/code/filter.c
+msgid "sos array must be of shape (n_section, 6)"
+msgstr ""
+
+#: extmod/ulab/code/filter.c
+msgid "sos[:, 3] should be all ones"
+msgstr ""
+
+#: extmod/ulab/code/filter.c
+msgid "sosfilt requires iterable arguments"
+msgstr ""
+
#: py/objstr.c
msgid "start/end indices"
msgstr "start/end indeks"
@@ -3092,7 +3177,7 @@ msgstr "struct: index hindi maabot"
msgid "struct: no fields"
msgstr "struct: walang fields"
-#: py/objstr.c
+#: py/objarray.c py/objstr.c
msgid "substring not found"
msgstr "substring hindi nahanap"
@@ -3129,6 +3214,14 @@ msgstr ""
msgid "timeout must be >= 0.0"
msgstr "bits ay dapat walo (8)"
+#: shared-module/sdcardio/SDCard.c
+msgid "timeout waiting for v1 card"
+msgstr ""
+
+#: shared-module/sdcardio/SDCard.c
+msgid "timeout waiting for v2 card"
+msgstr ""
+
#: shared-bindings/time/__init__.c
msgid "timestamp out of range for platform time_t"
msgstr "wala sa sakop ng timestamp ang platform time_t"
@@ -3328,6 +3421,18 @@ msgstr "wala sa sakop ang address"
msgid "zero step"
msgstr "zero step"
+#: extmod/ulab/code/filter.c
+msgid "zi must be an ndarray"
+msgstr ""
+
+#: extmod/ulab/code/filter.c
+msgid "zi must be of float type"
+msgstr ""
+
+#: extmod/ulab/code/filter.c
+msgid "zi must be of shape (n_section, 2)"
+msgstr ""
+
#~ msgid "AP required"
#~ msgstr "AP kailangan"
diff --git a/locale/fr.po b/locale/fr.po
index 5a49fd5f9..8953efe37 100644
--- a/locale/fr.po
+++ b/locale/fr.po
@@ -1,14 +1,13 @@
-# French translation.
-# Copyright (C) 2018
-# This file is distributed under the same license as the PACKAGE package.
-# Pierrick Couturier <arofarn@arofarn.info>, 2018.
-# Olivier Deveault <odeevee@outlook.com>
+# SPDX-FileCopyrightText: 2018 Pierrick Couturier <arofarn@arofarn.info>
+# SPDX-FileCopyrightText: 2018 Olivier Deveault <odeevee@outlook.com>
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
#
+# SPDX-License-Identifier: MIT
msgid ""
msgstr ""
"Project-Id-Version: 0.1\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2020-06-25 11:44-0500\n"
+"POT-Creation-Date: 2020-07-17 18:03-0700\n"
"PO-Revision-Date: 2020-06-05 17:29+0000\n"
"Last-Translator: aberwag <aberwag@gmail.com>\n"
"Language: fr\n"
@@ -69,6 +68,10 @@ msgstr ""
"Les broches d'adresse %d et les broches RVB %d indiquent une hauteur de %d, "
"pas %d"
+#: ports/atmel-samd/common-hal/sdioio/SDCard.c
+msgid "%q failure: %d"
+msgstr ""
+
#: shared-bindings/microcontroller/Pin.c
msgid "%q in use"
msgstr "%q utilisé"
@@ -85,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"
@@ -96,6 +104,10 @@ msgstr "%q doit être >=1"
msgid "%q must be a tuple of length 2"
msgstr "%q doit être un tuple de longueur 2"
+#: ports/atmel-samd/common-hal/sdioio/SDCard.c
+msgid "%q pin invalid"
+msgstr ""
+
#: shared-bindings/fontio/BuiltinFont.c
msgid "%q should be an int"
msgstr "%q doit être un entier (int)"
@@ -108,6 +120,10 @@ msgstr "%q() prend %d arguments positionnels mais %d ont été donnés"
msgid "'%q' argument required"
msgstr "'%q' argument requis"
+#: py/objarray.c
+msgid "'%q' object is not bytes-like"
+msgstr ""
+
#: py/emitinlinethumb.c py/emitinlinextensa.c
#, c-format
msgid "'%s' expects a label"
@@ -318,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"
@@ -350,10 +371,15 @@ msgstr "Le tableau doit contenir des demi-mots (type 'H')"
msgid "Array values should be single bytes."
msgstr "Les valeurs du tableau doivent être des octets simples 'bytes'."
-#: shared-bindings/rgbmatrix/RGBMatrix.c
+#: shared-bindings/microcontroller/Pin.c
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 ""
@@ -433,6 +459,11 @@ msgstr "Le tampon est trop petit"
msgid "Buffer length %d too big. It must be less than %d"
msgstr "La longueur du tampon %d est trop grande. Il doit être inférieur à %d"
+#: ports/atmel-samd/common-hal/sdioio/SDCard.c
+#: ports/cxd56/common-hal/sdioio/SDCard.c shared-module/sdcardio/SDCard.c
+msgid "Buffer length must be a multiple of 512"
+msgstr ""
+
#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c
msgid "Buffer must be at least length 1"
msgstr "Le tampon doit être de longueur au moins 1"
@@ -472,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"
@@ -602,6 +635,10 @@ msgstr "Code brut corrompu"
msgid "Could not initialize GNSS"
msgstr ""
+#: ports/cxd56/common-hal/sdioio/SDCard.c
+msgid "Could not initialize SDCard"
+msgstr ""
+
#: ports/atmel-samd/common-hal/busio/UART.c ports/cxd56/common-hal/busio/UART.c
msgid "Could not initialize UART"
msgstr "L'UART n'a pu être initialisé"
@@ -723,7 +760,8 @@ msgstr "Canal EXTINT déjà utilisé"
msgid "Error in regex"
msgstr "Erreur dans l'expression régulière"
-#: shared-bindings/aesio/aes.c shared-bindings/microcontroller/Pin.c
+#: shared-bindings/aesio/aes.c shared-bindings/busio/SPI.c
+#: shared-bindings/microcontroller/Pin.c
#: shared-bindings/neopixel_write/__init__.c shared-bindings/pulseio/PulseOut.c
#: shared-bindings/terminalio/Terminal.c
msgid "Expected a %q"
@@ -887,6 +925,10 @@ msgstr "Erreur de définition interne"
msgid "Internal error #%d"
msgstr "Erreur interne #%d"
+#: shared-bindings/sdioio/SDCard.c
+msgid "Invalid %q"
+msgstr ""
+
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
msgid "Invalid %q pin"
@@ -994,7 +1036,8 @@ msgstr "Broche invalide pour le canal droit"
#: ports/atmel-samd/common-hal/busio/UART.c
#: ports/atmel-samd/common-hal/i2cperipheral/I2CPeripheral.c
#: ports/cxd56/common-hal/busio/I2C.c ports/cxd56/common-hal/busio/SPI.c
-#: ports/cxd56/common-hal/busio/UART.c ports/mimxrt10xx/common-hal/busio/I2C.c
+#: ports/cxd56/common-hal/busio/UART.c ports/cxd56/common-hal/sdioio/SDCard.c
+#: ports/mimxrt10xx/common-hal/busio/I2C.c
#: ports/mimxrt10xx/common-hal/busio/SPI.c
#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/I2C.c
msgid "Invalid pins"
@@ -1098,6 +1141,10 @@ msgstr "Doit être une sous-classe de %q."
msgid "Must provide MISO or MOSI pin"
msgstr "Doit fournir une broche MISO ou MOSI"
+#: ports/stm/common-hal/busio/SPI.c
+msgid "Must provide SCK pin"
+msgstr ""
+
#: shared-bindings/rgbmatrix/RGBMatrix.c
#, c-format
msgid "Must use a multiple of 6 rgb pins, not %d"
@@ -1364,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"
@@ -1400,6 +1448,10 @@ msgstr "Mode sans-échec ! Auto-chargement désactivé.\n"
msgid "Running in safe mode! Not running saved code.\n"
msgstr "Mode sans-échec ! Le code sauvegardé n'est pas éxecuté.\n"
+#: shared-module/sdcardio/SDCard.c
+msgid "SD card CSD format not supported"
+msgstr ""
+
#: ports/atmel-samd/common-hal/busio/I2C.c
#: ports/mimxrt10xx/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c
msgid "SDA or SCL needs a pull up"
@@ -1444,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"
@@ -2052,6 +2106,10 @@ msgstr ""
"on ne peut envoyer une valeur autre que 'None' à un générateur fraîchement "
"démarré"
+#: shared-module/sdcardio/SDCard.c
+msgid "can't set 512 block size"
+msgstr ""
+
#: py/objnamedtuple.c
msgid "can't set attribute"
msgstr "attribut non modifiable"
@@ -2185,6 +2243,10 @@ msgstr "n'a pas pu diffuser le tableau d'entrée à partir de la forme"
msgid "could not invert Vandermonde matrix"
msgstr "n'a pas pu inverser la matrice Vandermonde"
+#: shared-module/sdcardio/SDCard.c
+msgid "couldn't determine SD card version"
+msgstr ""
+
#: extmod/ulab/code/approx.c
msgid "data must be iterable"
msgstr "les données doivent être les objets iterables"
@@ -2752,6 +2814,10 @@ msgstr "puissance négative sans support des nombres à virgule flottante"
msgid "negative shift count"
msgstr "compte de décalage négatif"
+#: shared-module/sdcardio/SDCard.c
+msgid "no SD card"
+msgstr ""
+
#: py/vm.c
msgid "no active exception to reraise"
msgstr "aucune exception active à relever"
@@ -2773,6 +2839,10 @@ msgstr "pas de module '%q'"
msgid "no reset pin available"
msgstr "pas de broche de réinitialisation disponible"
+#: shared-module/sdcardio/SDCard.c
+msgid "no response from SD card"
+msgstr ""
+
#: py/runtime.c
msgid "no such attribute"
msgstr "pas de tel attribut"
@@ -3069,6 +3139,10 @@ msgstr "la taille est définie pour les ndarrays uniquement"
msgid "sleep length must be non-negative"
msgstr "la longueur de sleep ne doit pas être négative"
+#: extmod/ulab/code/ndarray.c
+msgid "slice step can't be zero"
+msgstr ""
+
#: py/objslice.c py/sequence.c
msgid "slice step cannot be zero"
msgstr "le pas 'step' de la tranche ne peut être zéro"
@@ -3085,6 +3159,18 @@ msgstr "redémarrage logiciel\n"
msgid "sort argument must be an ndarray"
msgstr "l'argument de «sort» doit être un ndarray"
+#: extmod/ulab/code/filter.c
+msgid "sos array must be of shape (n_section, 6)"
+msgstr ""
+
+#: extmod/ulab/code/filter.c
+msgid "sos[:, 3] should be all ones"
+msgstr ""
+
+#: extmod/ulab/code/filter.c
+msgid "sosfilt requires iterable arguments"
+msgstr ""
+
#: py/objstr.c
msgid "start/end indices"
msgstr "indices de début/fin"
@@ -3135,7 +3221,7 @@ msgstr "struct : index hors limites"
msgid "struct: no fields"
msgstr "struct : aucun champs"
-#: py/objstr.c
+#: py/objarray.c py/objstr.c
msgid "substring not found"
msgstr "sous-chaîne non trouvée"
@@ -3171,6 +3257,14 @@ msgstr "le délai doit être compris entre 0.0 et 100.0 secondes"
msgid "timeout must be >= 0.0"
msgstr "'timeout' doit être >= 0.0"
+#: shared-module/sdcardio/SDCard.c
+msgid "timeout waiting for v1 card"
+msgstr ""
+
+#: shared-module/sdcardio/SDCard.c
+msgid "timeout waiting for v2 card"
+msgstr ""
+
#: shared-bindings/time/__init__.c
msgid "timestamp out of range for platform time_t"
msgstr "'timestamp' hors bornes pour 'time_t' de la plateforme"
@@ -3368,6 +3462,18 @@ msgstr "valeur y hors limites"
msgid "zero step"
msgstr "'step' nul"
+#: extmod/ulab/code/filter.c
+msgid "zi must be an ndarray"
+msgstr ""
+
+#: extmod/ulab/code/filter.c
+msgid "zi must be of float type"
+msgstr ""
+
+#: extmod/ulab/code/filter.c
+msgid "zi must be of shape (n_section, 2)"
+msgstr ""
+
#~ msgid "AP required"
#~ msgstr "'AP' requis"
diff --git a/locale/it_IT.po b/locale/it_IT.po
index c47d0e8e3..9f0aea9e9 100644
--- a/locale/it_IT.po
+++ b/locale/it_IT.po
@@ -1,14 +1,12 @@
-# Italian translation.
-# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
-# This file is distributed under the same license as the PACKAGE package.
-# Enrico Paganin <enrico.paganin@mail.com>, 2018
+# SPDX-FileCopyrightText: 2018 Enrico Paganin <enrico.paganin@mail.com>
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
#
-#, fuzzy
+# SPDX-License-Identifier: MIT
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2020-06-25 11:44-0500\n"
+"POT-Creation-Date: 2020-07-17 18:03-0700\n"
"PO-Revision-Date: 2018-10-02 16:27+0200\n"
"Last-Translator: Enrico Paganin <enrico.paganin@mail.com>\n"
"Language-Team: \n"
@@ -58,6 +56,10 @@ msgstr "%%c necessita di int o char"
msgid "%d address pins and %d rgb pins indicate a height of %d, not %d"
msgstr ""
+#: ports/atmel-samd/common-hal/sdioio/SDCard.c
+msgid "%q failure: %d"
+msgstr ""
+
#: shared-bindings/microcontroller/Pin.c
msgid "%q in use"
msgstr "%q in uso"
@@ -74,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"
@@ -86,6 +93,10 @@ msgstr "slice del buffer devono essere della stessa lunghezza"
msgid "%q must be a tuple of length 2"
msgstr ""
+#: ports/atmel-samd/common-hal/sdioio/SDCard.c
+msgid "%q pin invalid"
+msgstr ""
+
#: shared-bindings/fontio/BuiltinFont.c
#, fuzzy
msgid "%q should be an int"
@@ -99,6 +110,10 @@ msgstr "%q() prende %d argomenti posizionali ma ne sono stati forniti %d"
msgid "'%q' argument required"
msgstr "'%q' argomento richiesto"
+#: py/objarray.c
+msgid "'%q' object is not bytes-like"
+msgstr ""
+
#: py/emitinlinethumb.c py/emitinlinextensa.c
#, c-format
msgid "'%s' expects a label"
@@ -310,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 ""
@@ -341,10 +361,15 @@ msgstr "Array deve avere mezzoparole (typo 'H')"
msgid "Array values should be single bytes."
msgstr "Valori di Array dovrebbero essere bytes singulari"
-#: shared-bindings/rgbmatrix/RGBMatrix.c
+#: shared-bindings/microcontroller/Pin.c
msgid "At most %d %q may be specified (not %d)"
msgstr ""
+#: shared-module/memorymonitor/AllocationAlarm.c
+#, c-format
+msgid "Attempt to allocate %d blocks"
+msgstr ""
+
#: supervisor/shared/safe_mode.c
msgid "Attempted heap allocation when MicroPython VM not running."
msgstr ""
@@ -423,6 +448,11 @@ msgstr ""
msgid "Buffer length %d too big. It must be less than %d"
msgstr ""
+#: ports/atmel-samd/common-hal/sdioio/SDCard.c
+#: ports/cxd56/common-hal/sdioio/SDCard.c shared-module/sdcardio/SDCard.c
+msgid "Buffer length must be a multiple of 512"
+msgstr ""
+
#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c
msgid "Buffer must be at least length 1"
msgstr "Il buffer deve essere lungo almeno 1"
@@ -463,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"
@@ -587,6 +619,10 @@ msgstr ""
msgid "Could not initialize GNSS"
msgstr ""
+#: ports/cxd56/common-hal/sdioio/SDCard.c
+msgid "Could not initialize SDCard"
+msgstr ""
+
#: ports/atmel-samd/common-hal/busio/UART.c ports/cxd56/common-hal/busio/UART.c
msgid "Could not initialize UART"
msgstr "Impossibile inizializzare l'UART"
@@ -710,7 +746,8 @@ msgstr "Canale EXTINT già in uso"
msgid "Error in regex"
msgstr "Errore nella regex"
-#: shared-bindings/aesio/aes.c shared-bindings/microcontroller/Pin.c
+#: shared-bindings/aesio/aes.c shared-bindings/busio/SPI.c
+#: shared-bindings/microcontroller/Pin.c
#: shared-bindings/neopixel_write/__init__.c shared-bindings/pulseio/PulseOut.c
#: shared-bindings/terminalio/Terminal.c
msgid "Expected a %q"
@@ -874,6 +911,10 @@ msgstr ""
msgid "Internal error #%d"
msgstr ""
+#: shared-bindings/sdioio/SDCard.c
+msgid "Invalid %q"
+msgstr ""
+
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
msgid "Invalid %q pin"
@@ -983,7 +1024,8 @@ msgstr "Pin non valido per il canale destro"
#: ports/atmel-samd/common-hal/busio/UART.c
#: ports/atmel-samd/common-hal/i2cperipheral/I2CPeripheral.c
#: ports/cxd56/common-hal/busio/I2C.c ports/cxd56/common-hal/busio/SPI.c
-#: ports/cxd56/common-hal/busio/UART.c ports/mimxrt10xx/common-hal/busio/I2C.c
+#: ports/cxd56/common-hal/busio/UART.c ports/cxd56/common-hal/sdioio/SDCard.c
+#: ports/mimxrt10xx/common-hal/busio/I2C.c
#: ports/mimxrt10xx/common-hal/busio/SPI.c
#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/I2C.c
msgid "Invalid pins"
@@ -1089,6 +1131,10 @@ msgstr ""
msgid "Must provide MISO or MOSI pin"
msgstr ""
+#: ports/stm/common-hal/busio/SPI.c
+msgid "Must provide SCK pin"
+msgstr ""
+
#: shared-bindings/rgbmatrix/RGBMatrix.c
#, c-format
msgid "Must use a multiple of 6 rgb pins, not %d"
@@ -1353,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"
@@ -1390,6 +1437,10 @@ msgstr "Modalità sicura in esecuzione! Auto-reload disattivato.\n"
msgid "Running in safe mode! Not running saved code.\n"
msgstr "Modalità sicura in esecuzione! Codice salvato non in esecuzione.\n"
+#: shared-module/sdcardio/SDCard.c
+msgid "SD card CSD format not supported"
+msgstr ""
+
#: ports/atmel-samd/common-hal/busio/I2C.c
#: ports/mimxrt10xx/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c
msgid "SDA or SCL needs a pull up"
@@ -1436,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"
@@ -2019,6 +2072,10 @@ msgstr ""
msgid "can't send non-None value to a just-started generator"
msgstr ""
+#: shared-module/sdcardio/SDCard.c
+msgid "can't set 512 block size"
+msgstr ""
+
#: py/objnamedtuple.c
msgid "can't set attribute"
msgstr "impossibile impostare attributo"
@@ -2147,6 +2204,10 @@ msgstr ""
msgid "could not invert Vandermonde matrix"
msgstr ""
+#: shared-module/sdcardio/SDCard.c
+msgid "couldn't determine SD card version"
+msgstr ""
+
#: extmod/ulab/code/approx.c
msgid "data must be iterable"
msgstr ""
@@ -2714,6 +2775,10 @@ msgstr "potenza negativa senza supporto per float"
msgid "negative shift count"
msgstr ""
+#: shared-module/sdcardio/SDCard.c
+msgid "no SD card"
+msgstr ""
+
#: py/vm.c
msgid "no active exception to reraise"
msgstr "nessuna eccezione attiva da rilanciare"
@@ -2736,6 +2801,10 @@ msgstr "nessun modulo chiamato '%q'"
msgid "no reset pin available"
msgstr ""
+#: shared-module/sdcardio/SDCard.c
+msgid "no response from SD card"
+msgstr ""
+
#: py/runtime.c
msgid "no such attribute"
msgstr "attributo inesistente"
@@ -3033,6 +3102,10 @@ msgstr ""
msgid "sleep length must be non-negative"
msgstr "la lunghezza di sleed deve essere non negativa"
+#: extmod/ulab/code/ndarray.c
+msgid "slice step can't be zero"
+msgstr ""
+
#: py/objslice.c py/sequence.c
msgid "slice step cannot be zero"
msgstr "la step della slice non può essere zero"
@@ -3049,6 +3122,18 @@ msgstr "soft reboot\n"
msgid "sort argument must be an ndarray"
msgstr ""
+#: extmod/ulab/code/filter.c
+msgid "sos array must be of shape (n_section, 6)"
+msgstr ""
+
+#: extmod/ulab/code/filter.c
+msgid "sos[:, 3] should be all ones"
+msgstr ""
+
+#: extmod/ulab/code/filter.c
+msgid "sosfilt requires iterable arguments"
+msgstr ""
+
#: py/objstr.c
msgid "start/end indices"
msgstr ""
@@ -3099,7 +3184,7 @@ msgstr "struct: indice fuori intervallo"
msgid "struct: no fields"
msgstr "struct: nessun campo"
-#: py/objstr.c
+#: py/objarray.c py/objstr.c
msgid "substring not found"
msgstr "sottostringa non trovata"
@@ -3136,6 +3221,14 @@ msgstr ""
msgid "timeout must be >= 0.0"
msgstr "i bit devono essere 8"
+#: shared-module/sdcardio/SDCard.c
+msgid "timeout waiting for v1 card"
+msgstr ""
+
+#: shared-module/sdcardio/SDCard.c
+msgid "timeout waiting for v2 card"
+msgstr ""
+
#: shared-bindings/time/__init__.c
msgid "timestamp out of range for platform time_t"
msgstr "timestamp è fuori intervallo per il time_t della piattaforma"
@@ -3335,6 +3428,18 @@ msgstr "indirizzo fuori limite"
msgid "zero step"
msgstr "zero step"
+#: extmod/ulab/code/filter.c
+msgid "zi must be an ndarray"
+msgstr ""
+
+#: extmod/ulab/code/filter.c
+msgid "zi must be of float type"
+msgstr ""
+
+#: extmod/ulab/code/filter.c
+msgid "zi must be of shape (n_section, 2)"
+msgstr ""
+
#~ msgid "AP required"
#~ msgstr "AP richiesto"
diff --git a/locale/ko.po b/locale/ko.po
index 156f40d9b..e0f4dd9cb 100644
--- a/locale/ko.po
+++ b/locale/ko.po
@@ -1,14 +1,12 @@
-# SOME DESCRIPTIVE TITLE.
-# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
-# This file is distributed under the same license as the PACKAGE package.
-# 글라파, 2019.
+# SPDX-FileCopyrightText: 2019 글라파
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
#
-#, fuzzy
+# SPDX-License-Identifier: MIT
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2020-06-25 11:44-0500\n"
+"POT-Creation-Date: 2020-07-17 18:03-0700\n"
"PO-Revision-Date: 2019-05-06 14:22-0700\n"
"Last-Translator: \n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -60,6 +58,10 @@ msgstr "%%c 전수(int)또는 캐릭터(char)필요합니다"
msgid "%d address pins and %d rgb pins indicate a height of %d, not %d"
msgstr ""
+#: ports/atmel-samd/common-hal/sdioio/SDCard.c
+msgid "%q failure: %d"
+msgstr ""
+
#: shared-bindings/microcontroller/Pin.c
msgid "%q in use"
msgstr "%q 사용 중입니다"
@@ -76,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이어야합니다"
@@ -87,6 +94,10 @@ msgstr "%q 는 >=1이어야합니다"
msgid "%q must be a tuple of length 2"
msgstr ""
+#: ports/atmel-samd/common-hal/sdioio/SDCard.c
+msgid "%q pin invalid"
+msgstr ""
+
#: shared-bindings/fontio/BuiltinFont.c
msgid "%q should be an int"
msgstr "%q 는 정수(int) 여야합니다"
@@ -99,6 +110,10 @@ msgstr ""
msgid "'%q' argument required"
msgstr ""
+#: py/objarray.c
+msgid "'%q' object is not bytes-like"
+msgstr ""
+
#: py/emitinlinethumb.c py/emitinlinextensa.c
#, c-format
msgid "'%s' expects a label"
@@ -309,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 ""
@@ -340,10 +360,15 @@ msgstr ""
msgid "Array values should be single bytes."
msgstr ""
-#: shared-bindings/rgbmatrix/RGBMatrix.c
+#: shared-bindings/microcontroller/Pin.c
msgid "At most %d %q may be specified (not %d)"
msgstr ""
+#: shared-module/memorymonitor/AllocationAlarm.c
+#, c-format
+msgid "Attempt to allocate %d blocks"
+msgstr ""
+
#: supervisor/shared/safe_mode.c
msgid "Attempted heap allocation when MicroPython VM not running."
msgstr ""
@@ -421,6 +446,11 @@ msgstr ""
msgid "Buffer length %d too big. It must be less than %d"
msgstr ""
+#: ports/atmel-samd/common-hal/sdioio/SDCard.c
+#: ports/cxd56/common-hal/sdioio/SDCard.c shared-module/sdcardio/SDCard.c
+msgid "Buffer length must be a multiple of 512"
+msgstr ""
+
#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c
msgid "Buffer must be at least length 1"
msgstr "잘못된 크기의 버퍼. >1 여야합니다"
@@ -460,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 "값을 삭제할 수 없습니다"
@@ -581,6 +613,10 @@ msgstr ""
msgid "Could not initialize GNSS"
msgstr ""
+#: ports/cxd56/common-hal/sdioio/SDCard.c
+msgid "Could not initialize SDCard"
+msgstr ""
+
#: ports/atmel-samd/common-hal/busio/UART.c ports/cxd56/common-hal/busio/UART.c
msgid "Could not initialize UART"
msgstr ""
@@ -702,7 +738,8 @@ msgstr ""
msgid "Error in regex"
msgstr "Regex에 오류가 있습니다."
-#: shared-bindings/aesio/aes.c shared-bindings/microcontroller/Pin.c
+#: shared-bindings/aesio/aes.c shared-bindings/busio/SPI.c
+#: shared-bindings/microcontroller/Pin.c
#: shared-bindings/neopixel_write/__init__.c shared-bindings/pulseio/PulseOut.c
#: shared-bindings/terminalio/Terminal.c
msgid "Expected a %q"
@@ -862,6 +899,10 @@ msgstr ""
msgid "Internal error #%d"
msgstr ""
+#: shared-bindings/sdioio/SDCard.c
+msgid "Invalid %q"
+msgstr ""
+
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
msgid "Invalid %q pin"
@@ -969,7 +1010,8 @@ msgstr "오른쪽 채널 핀이 잘못되었습니다"
#: ports/atmel-samd/common-hal/busio/UART.c
#: ports/atmel-samd/common-hal/i2cperipheral/I2CPeripheral.c
#: ports/cxd56/common-hal/busio/I2C.c ports/cxd56/common-hal/busio/SPI.c
-#: ports/cxd56/common-hal/busio/UART.c ports/mimxrt10xx/common-hal/busio/I2C.c
+#: ports/cxd56/common-hal/busio/UART.c ports/cxd56/common-hal/sdioio/SDCard.c
+#: ports/mimxrt10xx/common-hal/busio/I2C.c
#: ports/mimxrt10xx/common-hal/busio/SPI.c
#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/I2C.c
msgid "Invalid pins"
@@ -1073,6 +1115,10 @@ msgstr ""
msgid "Must provide MISO or MOSI pin"
msgstr ""
+#: ports/stm/common-hal/busio/SPI.c
+msgid "Must provide SCK pin"
+msgstr ""
+
#: shared-bindings/rgbmatrix/RGBMatrix.c
#, c-format
msgid "Must use a multiple of 6 rgb pins, not %d"
@@ -1326,6 +1372,7 @@ msgstr ""
msgid "Random number generation error"
msgstr ""
+#: shared-bindings/memorymonitor/AllocationSize.c
#: shared-bindings/pulseio/PulseIn.c
msgid "Read-only"
msgstr ""
@@ -1362,6 +1409,10 @@ msgstr ""
msgid "Running in safe mode! Not running saved code.\n"
msgstr ""
+#: shared-module/sdcardio/SDCard.c
+msgid "SD card CSD format not supported"
+msgstr ""
+
#: ports/atmel-samd/common-hal/busio/I2C.c
#: ports/mimxrt10xx/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c
msgid "SDA or SCL needs a pull up"
@@ -1406,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 ""
@@ -1984,6 +2037,10 @@ msgstr ""
msgid "can't send non-None value to a just-started generator"
msgstr ""
+#: shared-module/sdcardio/SDCard.c
+msgid "can't set 512 block size"
+msgstr ""
+
#: py/objnamedtuple.c
msgid "can't set attribute"
msgstr ""
@@ -2110,6 +2167,10 @@ msgstr ""
msgid "could not invert Vandermonde matrix"
msgstr ""
+#: shared-module/sdcardio/SDCard.c
+msgid "couldn't determine SD card version"
+msgstr ""
+
#: extmod/ulab/code/approx.c
msgid "data must be iterable"
msgstr ""
@@ -2667,6 +2728,10 @@ msgstr ""
msgid "negative shift count"
msgstr ""
+#: shared-module/sdcardio/SDCard.c
+msgid "no SD card"
+msgstr ""
+
#: py/vm.c
msgid "no active exception to reraise"
msgstr ""
@@ -2688,6 +2753,10 @@ msgstr ""
msgid "no reset pin available"
msgstr ""
+#: shared-module/sdcardio/SDCard.c
+msgid "no response from SD card"
+msgstr ""
+
#: py/runtime.c
msgid "no such attribute"
msgstr ""
@@ -2977,6 +3046,10 @@ msgstr ""
msgid "sleep length must be non-negative"
msgstr ""
+#: extmod/ulab/code/ndarray.c
+msgid "slice step can't be zero"
+msgstr ""
+
#: py/objslice.c py/sequence.c
msgid "slice step cannot be zero"
msgstr ""
@@ -2993,6 +3066,18 @@ msgstr ""
msgid "sort argument must be an ndarray"
msgstr ""
+#: extmod/ulab/code/filter.c
+msgid "sos array must be of shape (n_section, 6)"
+msgstr ""
+
+#: extmod/ulab/code/filter.c
+msgid "sos[:, 3] should be all ones"
+msgstr ""
+
+#: extmod/ulab/code/filter.c
+msgid "sosfilt requires iterable arguments"
+msgstr ""
+
#: py/objstr.c
msgid "start/end indices"
msgstr ""
@@ -3042,7 +3127,7 @@ msgstr ""
msgid "struct: no fields"
msgstr ""
-#: py/objstr.c
+#: py/objarray.c py/objstr.c
msgid "substring not found"
msgstr ""
@@ -3078,6 +3163,14 @@ msgstr ""
msgid "timeout must be >= 0.0"
msgstr ""
+#: shared-module/sdcardio/SDCard.c
+msgid "timeout waiting for v1 card"
+msgstr ""
+
+#: shared-module/sdcardio/SDCard.c
+msgid "timeout waiting for v2 card"
+msgstr ""
+
#: shared-bindings/time/__init__.c
msgid "timestamp out of range for platform time_t"
msgstr ""
@@ -3275,6 +3368,18 @@ msgstr ""
msgid "zero step"
msgstr ""
+#: extmod/ulab/code/filter.c
+msgid "zi must be an ndarray"
+msgstr ""
+
+#: extmod/ulab/code/filter.c
+msgid "zi must be of float type"
+msgstr ""
+
+#: extmod/ulab/code/filter.c
+msgid "zi must be of shape (n_section, 2)"
+msgstr ""
+
#~ msgid "Can't add services in Central mode"
#~ msgstr "센트랄(중앙) 모드에서는 서비스를 추가 할 수 없습니다"
diff --git a/locale/nl.po b/locale/nl.po
index 77cc11cab..29591dfd8 100644
--- a/locale/nl.po
+++ b/locale/nl.po
@@ -1,14 +1,12 @@
-# SOME DESCRIPTIVE TITLE.
-# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
-# This file is distributed under the same license as the PACKAGE package.
-# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
#
+# SPDX-License-Identifier: MIT
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2020-06-25 11:44-0500\n"
-"PO-Revision-Date: 2020-06-02 19:50+0000\n"
+"POT-Creation-Date: 2020-07-17 18:03-0700\n"
+"PO-Revision-Date: 2020-07-13 17:39+0000\n"
"Last-Translator: _fonzlate <vooralfred@gmail.com>\n"
"Language-Team: none\n"
"Language: nl\n"
@@ -16,7 +14,7 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
-"X-Generator: Weblate 4.1-dev\n"
+"X-Generator: Weblate 4.2-dev\n"
#: main.c
msgid ""
@@ -66,6 +64,10 @@ msgstr "%%c vereist een int of char"
msgid "%d address pins and %d rgb pins indicate a height of %d, not %d"
msgstr "%d adres pins en %d RGB pins geven een hoogte van %d aan, niet %d"
+#: ports/atmel-samd/common-hal/sdioio/SDCard.c
+msgid "%q failure: %d"
+msgstr "%q fout: %d"
+
#: shared-bindings/microcontroller/Pin.c
msgid "%q in use"
msgstr "%q in gebruik"
@@ -82,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"
@@ -93,6 +100,10 @@ msgstr "%q moet >= 1 zijn"
msgid "%q must be a tuple of length 2"
msgstr "%q moet een tuple van lengte 2 zijn"
+#: ports/atmel-samd/common-hal/sdioio/SDCard.c
+msgid "%q pin invalid"
+msgstr "%q pin onjuist"
+
#: shared-bindings/fontio/BuiltinFont.c
msgid "%q should be an int"
msgstr "%q moet een int zijn"
@@ -105,6 +116,10 @@ msgstr "%q() verwacht %d positionele argumenten maar kreeg %d"
msgid "'%q' argument required"
msgstr "'%q' argument vereist"
+#: py/objarray.c
+msgid "'%q' object is not bytes-like"
+msgstr ""
+
#: py/emitinlinethumb.c py/emitinlinextensa.c
#, c-format
msgid "'%s' expects a label"
@@ -315,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"
@@ -346,10 +366,15 @@ msgstr "Array moet halfwords (type 'H') bevatten"
msgid "Array values should be single bytes."
msgstr "Array waardes moet enkele bytes zijn."
-#: shared-bindings/rgbmatrix/RGBMatrix.c
+#: shared-bindings/microcontroller/Pin.c
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."
@@ -427,6 +452,11 @@ msgstr "Buffer is te klein"
msgid "Buffer length %d too big. It must be less than %d"
msgstr "Buffer lengte %d te groot. Het moet kleiner zijn dan %d"
+#: ports/atmel-samd/common-hal/sdioio/SDCard.c
+#: ports/cxd56/common-hal/sdioio/SDCard.c shared-module/sdcardio/SDCard.c
+msgid "Buffer length must be a multiple of 512"
+msgstr "Buffer lengte moet een veelvoud van 512 zijn"
+
#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c
msgid "Buffer must be at least length 1"
msgstr "Buffer moet op zijn minst lengte 1 zijn"
@@ -466,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"
@@ -591,7 +623,11 @@ msgstr "Corrupt raw code"
#: ports/cxd56/common-hal/gnss/GNSS.c
msgid "Could not initialize GNSS"
-msgstr ""
+msgstr "Kan GNSS niet initialiseren"
+
+#: ports/cxd56/common-hal/sdioio/SDCard.c
+msgid "Could not initialize SDCard"
+msgstr "Kan SDCard niet initialiseren"
#: ports/atmel-samd/common-hal/busio/UART.c ports/cxd56/common-hal/busio/UART.c
msgid "Could not initialize UART"
@@ -714,7 +750,8 @@ msgstr "EXTINT kanaal al in gebruik"
msgid "Error in regex"
msgstr "Fout in regex"
-#: shared-bindings/aesio/aes.c shared-bindings/microcontroller/Pin.c
+#: shared-bindings/aesio/aes.c shared-bindings/busio/SPI.c
+#: shared-bindings/microcontroller/Pin.c
#: shared-bindings/neopixel_write/__init__.c shared-bindings/pulseio/PulseOut.c
#: shared-bindings/terminalio/Terminal.c
msgid "Expected a %q"
@@ -878,6 +915,10 @@ msgstr "Interne define fout"
msgid "Internal error #%d"
msgstr "Interne fout #%d"
+#: shared-bindings/sdioio/SDCard.c
+msgid "Invalid %q"
+msgstr "Ongeldige %q"
+
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
msgid "Invalid %q pin"
@@ -985,7 +1026,8 @@ msgstr "Ongeldige pin voor rechter kanaal"
#: ports/atmel-samd/common-hal/busio/UART.c
#: ports/atmel-samd/common-hal/i2cperipheral/I2CPeripheral.c
#: ports/cxd56/common-hal/busio/I2C.c ports/cxd56/common-hal/busio/SPI.c
-#: ports/cxd56/common-hal/busio/UART.c ports/mimxrt10xx/common-hal/busio/I2C.c
+#: ports/cxd56/common-hal/busio/UART.c ports/cxd56/common-hal/sdioio/SDCard.c
+#: ports/mimxrt10xx/common-hal/busio/I2C.c
#: ports/mimxrt10xx/common-hal/busio/SPI.c
#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/I2C.c
msgid "Invalid pins"
@@ -1089,6 +1131,10 @@ msgstr "%q moet een subklasse zijn."
msgid "Must provide MISO or MOSI pin"
msgstr "MISO of MOSI moeten worden gegeven"
+#: ports/stm/common-hal/busio/SPI.c
+msgid "Must provide SCK pin"
+msgstr "SCK pin moet opgegeven worden"
+
#: shared-bindings/rgbmatrix/RGBMatrix.c
#, c-format
msgid "Must use a multiple of 6 rgb pins, not %d"
@@ -1356,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"
@@ -1392,6 +1439,10 @@ msgstr "Draaiende in veilige modus! Auto-herlaad is uit.\n"
msgid "Running in safe mode! Not running saved code.\n"
msgstr "Draaiende in veilige modus! Opgeslagen code wordt niet uitgevoerd.\n"
+#: shared-module/sdcardio/SDCard.c
+msgid "SD card CSD format not supported"
+msgstr "SD kaart CSD formaat niet ondersteund"
+
#: ports/atmel-samd/common-hal/busio/I2C.c
#: ports/mimxrt10xx/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c
msgid "SDA or SCL needs a pull up"
@@ -1436,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"
@@ -1462,7 +1515,7 @@ msgstr "Geef op zijn minst 1 UART pin op"
#: shared-bindings/gnss/GNSS.c
msgid "System entry must be gnss.SatelliteSystem"
-msgstr ""
+msgstr "Systeem invoer moet gnss.SatelliteSystem zijn"
#: ports/stm/common-hal/microcontroller/Processor.c
msgid "Temperature read timed out"
@@ -2033,6 +2086,10 @@ msgstr "kan throw niet aan net gestartte generator toevoegen"
msgid "can't send non-None value to a just-started generator"
msgstr "kan geen niet-'None' waarde naar een net gestartte generator sturen"
+#: shared-module/sdcardio/SDCard.c
+msgid "can't set 512 block size"
+msgstr "kan geen 512 blokgrootte instellen"
+
#: py/objnamedtuple.c
msgid "can't set attribute"
msgstr "kan attribute niet instellen"
@@ -2160,6 +2217,10 @@ msgstr "kon de invoerarray niet vanuit vorm uitzenden"
msgid "could not invert Vandermonde matrix"
msgstr "kon de Vandermonde matrix niet omkeren"
+#: shared-module/sdcardio/SDCard.c
+msgid "couldn't determine SD card version"
+msgstr "kon SD kaart versie niet bepalen"
+
#: extmod/ulab/code/approx.c
msgid "data must be iterable"
msgstr "data moet itereerbaar zijn"
@@ -2723,6 +2784,10 @@ msgstr "negatieve macht terwijl er geen ondersteuning is voor float"
msgid "negative shift count"
msgstr "negatieve verschuivingstelling (shift count)"
+#: shared-module/sdcardio/SDCard.c
+msgid "no SD card"
+msgstr "geen SD kaart"
+
#: py/vm.c
msgid "no active exception to reraise"
msgstr "geen actieve uitzondering om opnieuw op te werpen (raise)"
@@ -2744,6 +2809,10 @@ msgstr "geen module met naam '%q'"
msgid "no reset pin available"
msgstr "geen reset pin beschikbaar"
+#: shared-module/sdcardio/SDCard.c
+msgid "no response from SD card"
+msgstr "geen antwoord van SD kaart"
+
#: py/runtime.c
msgid "no such attribute"
msgstr "niet zo'n attribuut"
@@ -3036,6 +3105,10 @@ msgstr "omvang is alleen voor ndarrays gedefinieerd"
msgid "sleep length must be non-negative"
msgstr "de slaapduur mag niet negatief zijn"
+#: extmod/ulab/code/ndarray.c
+msgid "slice step can't be zero"
+msgstr "segmentstap mag niet nul zijn"
+
#: py/objslice.c py/sequence.c
msgid "slice step cannot be zero"
msgstr "segmentstap mag niet nul zijn"
@@ -3052,6 +3125,18 @@ msgstr "zachte herstart\n"
msgid "sort argument must be an ndarray"
msgstr "sorteerargument moet een ndarray zijn"
+#: extmod/ulab/code/filter.c
+msgid "sos array must be of shape (n_section, 6)"
+msgstr "sos array moet vorm (n_section, 6) hebben"
+
+#: extmod/ulab/code/filter.c
+msgid "sos[:, 3] should be all ones"
+msgstr "sos[:, 3] moeten allemaal 1 zijn"
+
+#: extmod/ulab/code/filter.c
+msgid "sosfilt requires iterable arguments"
+msgstr "sosfilt vereist itereerbare argumenten"
+
#: py/objstr.c
msgid "start/end indices"
msgstr "start/stop indices"
@@ -3101,7 +3186,7 @@ msgstr "struct: index buiten bereik"
msgid "struct: no fields"
msgstr "struct: geen velden"
-#: py/objstr.c
+#: py/objarray.c py/objstr.c
msgid "substring not found"
msgstr "deelreeks niet gevonden"
@@ -3137,6 +3222,14 @@ msgstr "timeout moet tussen 0.0 en 100.0 seconden zijn"
msgid "timeout must be >= 0.0"
msgstr "timeout moet groter dan 0.0 zijn"
+#: shared-module/sdcardio/SDCard.c
+msgid "timeout waiting for v1 card"
+msgstr "timeout bij wachten op v1 kaart"
+
+#: shared-module/sdcardio/SDCard.c
+msgid "timeout waiting for v2 card"
+msgstr "timeout bij wachten op v2 kaart"
+
#: shared-bindings/time/__init__.c
msgid "timestamp out of range for platform time_t"
msgstr "timestamp buiten bereik voor platform time_t"
@@ -3334,6 +3427,18 @@ msgstr "y-waarde buiten bereik"
msgid "zero step"
msgstr "nul-stap"
+#: extmod/ulab/code/filter.c
+msgid "zi must be an ndarray"
+msgstr "zi moet een ndarray zijn"
+
+#: extmod/ulab/code/filter.c
+msgid "zi must be of float type"
+msgstr "zi moet van type float zijn"
+
+#: extmod/ulab/code/filter.c
+msgid "zi must be of shape (n_section, 2)"
+msgstr "zi moet vorm (n_section, 2) hebben"
+
#~ msgid "I2C operation not supported"
#~ msgstr "I2C actie niet ondersteund"
diff --git a/locale/pl.po b/locale/pl.po
index 888ce6428..e359e71b6 100644
--- a/locale/pl.po
+++ b/locale/pl.po
@@ -1,13 +1,12 @@
-# Adafruit CircuitPython Polish Translation
-# Copyright (C) 2019
-# This file is distributed under the same license as the CircuitPython package.
-# Radomir Dopieralski <circuitpython@sheep.art.pl>, 2019.
+# SPDX-FileCopyrightText: 2019 Radomir Dopieralski <circuitpython@sheep.art.pl>
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
#
+# SPDX-License-Identifier: MIT
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2020-06-25 11:44-0500\n"
+"POT-Creation-Date: 2020-07-17 18:03-0700\n"
"PO-Revision-Date: 2019-03-19 18:37-0700\n"
"Last-Translator: Radomir Dopieralski <circuitpython@sheep.art.pl>\n"
"Language-Team: pl\n"
@@ -59,6 +58,10 @@ msgstr "%%c wymaga int lub char"
msgid "%d address pins and %d rgb pins indicate a height of %d, not %d"
msgstr ""
+#: ports/atmel-samd/common-hal/sdioio/SDCard.c
+msgid "%q failure: %d"
+msgstr ""
+
#: shared-bindings/microcontroller/Pin.c
msgid "%q in use"
msgstr "%q w użyciu"
@@ -75,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"
@@ -86,6 +94,10 @@ msgstr "%q musi być >= 1"
msgid "%q must be a tuple of length 2"
msgstr ""
+#: ports/atmel-samd/common-hal/sdioio/SDCard.c
+msgid "%q pin invalid"
+msgstr ""
+
#: shared-bindings/fontio/BuiltinFont.c
msgid "%q should be an int"
msgstr "%q powinno być typu int"
@@ -98,6 +110,10 @@ msgstr "%q() bierze %d argumentów pozycyjnych, lecz podano %d"
msgid "'%q' argument required"
msgstr "'%q' wymaga argumentu"
+#: py/objarray.c
+msgid "'%q' object is not bytes-like"
+msgstr ""
+
#: py/emitinlinethumb.c py/emitinlinextensa.c
#, c-format
msgid "'%s' expects a label"
@@ -308,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 ""
@@ -339,10 +360,15 @@ msgstr "Tablica musi zawierać pół-słowa (typ 'H')"
msgid "Array values should be single bytes."
msgstr "Wartości powinny być bajtami."
-#: shared-bindings/rgbmatrix/RGBMatrix.c
+#: shared-bindings/microcontroller/Pin.c
msgid "At most %d %q may be specified (not %d)"
msgstr ""
+#: shared-module/memorymonitor/AllocationAlarm.c
+#, c-format
+msgid "Attempt to allocate %d blocks"
+msgstr ""
+
#: supervisor/shared/safe_mode.c
msgid "Attempted heap allocation when MicroPython VM not running."
msgstr ""
@@ -420,6 +446,11 @@ msgstr ""
msgid "Buffer length %d too big. It must be less than %d"
msgstr ""
+#: ports/atmel-samd/common-hal/sdioio/SDCard.c
+#: ports/cxd56/common-hal/sdioio/SDCard.c shared-module/sdcardio/SDCard.c
+msgid "Buffer length must be a multiple of 512"
+msgstr ""
+
#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c
msgid "Buffer must be at least length 1"
msgstr "Bufor musi mieć długość 1 lub więcej"
@@ -459,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ąć"
@@ -580,6 +613,10 @@ msgstr ""
msgid "Could not initialize GNSS"
msgstr ""
+#: ports/cxd56/common-hal/sdioio/SDCard.c
+msgid "Could not initialize SDCard"
+msgstr ""
+
#: ports/atmel-samd/common-hal/busio/UART.c ports/cxd56/common-hal/busio/UART.c
msgid "Could not initialize UART"
msgstr "Ustawienie UART nie powiodło się"
@@ -701,7 +738,8 @@ msgstr "Kanał EXTINT w użyciu"
msgid "Error in regex"
msgstr "Błąd w regex"
-#: shared-bindings/aesio/aes.c shared-bindings/microcontroller/Pin.c
+#: shared-bindings/aesio/aes.c shared-bindings/busio/SPI.c
+#: shared-bindings/microcontroller/Pin.c
#: shared-bindings/neopixel_write/__init__.c shared-bindings/pulseio/PulseOut.c
#: shared-bindings/terminalio/Terminal.c
msgid "Expected a %q"
@@ -863,6 +901,10 @@ msgstr ""
msgid "Internal error #%d"
msgstr ""
+#: shared-bindings/sdioio/SDCard.c
+msgid "Invalid %q"
+msgstr ""
+
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
msgid "Invalid %q pin"
@@ -970,7 +1012,8 @@ msgstr "Zła nóżka dla prawego kanału"
#: ports/atmel-samd/common-hal/busio/UART.c
#: ports/atmel-samd/common-hal/i2cperipheral/I2CPeripheral.c
#: ports/cxd56/common-hal/busio/I2C.c ports/cxd56/common-hal/busio/SPI.c
-#: ports/cxd56/common-hal/busio/UART.c ports/mimxrt10xx/common-hal/busio/I2C.c
+#: ports/cxd56/common-hal/busio/UART.c ports/cxd56/common-hal/sdioio/SDCard.c
+#: ports/mimxrt10xx/common-hal/busio/I2C.c
#: ports/mimxrt10xx/common-hal/busio/SPI.c
#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/I2C.c
msgid "Invalid pins"
@@ -1074,6 +1117,10 @@ msgstr ""
msgid "Must provide MISO or MOSI pin"
msgstr ""
+#: ports/stm/common-hal/busio/SPI.c
+msgid "Must provide SCK pin"
+msgstr ""
+
#: shared-bindings/rgbmatrix/RGBMatrix.c
#, c-format
msgid "Must use a multiple of 6 rgb pins, not %d"
@@ -1327,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"
@@ -1363,6 +1411,10 @@ msgstr "Uruchomiony tryb bezpieczeństwa! Samo-przeładowanie wyłączone.\n"
msgid "Running in safe mode! Not running saved code.\n"
msgstr "Uruchomiony tryb bezpieczeństwa! Zapisany kod nie jest uruchamiany.\n"
+#: shared-module/sdcardio/SDCard.c
+msgid "SD card CSD format not supported"
+msgstr ""
+
#: ports/atmel-samd/common-hal/busio/I2C.c
#: ports/mimxrt10xx/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c
msgid "SDA or SCL needs a pull up"
@@ -1407,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"
@@ -1987,6 +2041,10 @@ msgstr "nie można skoczyć do świeżo stworzonego generatora"
msgid "can't send non-None value to a just-started generator"
msgstr "świeżo stworzony generator może tylko przyjąć None"
+#: shared-module/sdcardio/SDCard.c
+msgid "can't set 512 block size"
+msgstr ""
+
#: py/objnamedtuple.c
msgid "can't set attribute"
msgstr "nie można ustawić atrybutu"
@@ -2113,6 +2171,10 @@ msgstr ""
msgid "could not invert Vandermonde matrix"
msgstr ""
+#: shared-module/sdcardio/SDCard.c
+msgid "couldn't determine SD card version"
+msgstr ""
+
#: extmod/ulab/code/approx.c
msgid "data must be iterable"
msgstr ""
@@ -2671,6 +2733,10 @@ msgstr "ujemna potęga, ale brak obsługi liczb zmiennoprzecinkowych"
msgid "negative shift count"
msgstr "ujemne przesunięcie"
+#: shared-module/sdcardio/SDCard.c
+msgid "no SD card"
+msgstr ""
+
#: py/vm.c
msgid "no active exception to reraise"
msgstr "brak wyjątku do ponownego rzucenia"
@@ -2692,6 +2758,10 @@ msgstr "brak modułu o nazwie '%q'"
msgid "no reset pin available"
msgstr ""
+#: shared-module/sdcardio/SDCard.c
+msgid "no response from SD card"
+msgstr ""
+
#: py/runtime.c
msgid "no such attribute"
msgstr "nie ma takiego atrybutu"
@@ -2983,6 +3053,10 @@ msgstr ""
msgid "sleep length must be non-negative"
msgstr "okres snu musi być nieujemny"
+#: extmod/ulab/code/ndarray.c
+msgid "slice step can't be zero"
+msgstr ""
+
#: py/objslice.c py/sequence.c
msgid "slice step cannot be zero"
msgstr "zerowy krok"
@@ -2999,6 +3073,18 @@ msgstr "programowy reset\n"
msgid "sort argument must be an ndarray"
msgstr ""
+#: extmod/ulab/code/filter.c
+msgid "sos array must be of shape (n_section, 6)"
+msgstr ""
+
+#: extmod/ulab/code/filter.c
+msgid "sos[:, 3] should be all ones"
+msgstr ""
+
+#: extmod/ulab/code/filter.c
+msgid "sosfilt requires iterable arguments"
+msgstr ""
+
#: py/objstr.c
msgid "start/end indices"
msgstr "początkowe/końcowe indeksy"
@@ -3048,7 +3134,7 @@ msgstr "struct: indeks poza zakresem"
msgid "struct: no fields"
msgstr "struct: brak pól"
-#: py/objstr.c
+#: py/objarray.c py/objstr.c
msgid "substring not found"
msgstr "brak pod-łańcucha"
@@ -3084,6 +3170,14 @@ msgstr ""
msgid "timeout must be >= 0.0"
msgstr "timeout musi być >= 0.0"
+#: shared-module/sdcardio/SDCard.c
+msgid "timeout waiting for v1 card"
+msgstr ""
+
+#: shared-module/sdcardio/SDCard.c
+msgid "timeout waiting for v2 card"
+msgstr ""
+
#: shared-bindings/time/__init__.c
msgid "timestamp out of range for platform time_t"
msgstr "timestamp poza zakresem dla time_t na tej platformie"
@@ -3281,6 +3375,18 @@ msgstr "y poza zakresem"
msgid "zero step"
msgstr "zerowy krok"
+#: extmod/ulab/code/filter.c
+msgid "zi must be an ndarray"
+msgstr ""
+
+#: extmod/ulab/code/filter.c
+msgid "zi must be of float type"
+msgstr ""
+
+#: extmod/ulab/code/filter.c
+msgid "zi must be of shape (n_section, 2)"
+msgstr ""
+
#~ msgid "Address is not %d bytes long or is in wrong format"
#~ msgstr "Adres nie ma długości %d bajtów lub zły format"
diff --git a/locale/pt_BR.po b/locale/pt_BR.po
index e951df108..10f3bf611 100644
--- a/locale/pt_BR.po
+++ b/locale/pt_BR.po
@@ -1,27 +1,28 @@
-# SOME DESCRIPTIVE TITLE.
-# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
-# This file is distributed under the same license as the PACKAGE package.
-# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
#
-#, fuzzy
+# SPDX-License-Identifier: MIT
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2020-06-25 11:44-0500\n"
-"PO-Revision-Date: 2018-10-02 21:14-0000\n"
-"Last-Translator: \n"
+"POT-Creation-Date: 2020-07-17 18:03-0700\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"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=n > 1;\n"
+"X-Generator: Weblate 4.2-dev\n"
#: main.c
msgid ""
"\n"
"Code done running. Waiting for reload.\n"
msgstr ""
+"\n"
+"O código concluiu a execução. Esperando pela recarga.\n"
#: supervisor/shared/safe_mode.c
msgid ""
@@ -29,12 +30,17 @@ msgid ""
"Please file an issue with the contents of your CIRCUITPY drive at \n"
"https://github.com/adafruit/circuitpython/issues\n"
msgstr ""
+"\n"
+"Registre um problema com o conteúdo do seu controlador no CIRCUITPY\n"
+"https://github.com/adafruit/circuitpython/issues\n"
#: supervisor/shared/safe_mode.c
msgid ""
"\n"
"To exit, please reset the board without "
msgstr ""
+"\n"
+"Para encerrar, redefina a placa sem "
#: py/obj.c
msgid " File \"%q\""
@@ -56,7 +62,11 @@ msgstr "%%c requer int ou char"
#: shared-bindings/rgbmatrix/RGBMatrix.c
#, c-format
msgid "%d address pins and %d rgb pins indicate a height of %d, not %d"
-msgstr ""
+msgstr "%d endereços dos pinos e %d pinos rgb indicam uma altura do %d, não %d"
+
+#: ports/atmel-samd/common-hal/sdioio/SDCard.c
+msgid "%q failure: %d"
+msgstr "%q falha: %d"
#: shared-bindings/microcontroller/Pin.c
msgid "%q in use"
@@ -64,136 +74,149 @@ msgstr "%q em uso"
#: py/obj.c
msgid "%q index out of range"
-msgstr ""
+msgstr "O índice %q está fora do intervalo"
#: py/obj.c
msgid "%q indices must be integers, not %s"
-msgstr ""
+msgstr "Os índices %q devem ser inteiros, e não %s"
#: shared-bindings/vectorio/Polygon.c
msgid "%q list must be a list"
-msgstr ""
+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
-#, fuzzy
+#: 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 "buffers devem ser o mesmo tamanho"
+msgstr "%q deve ser >= 1"
#: shared-module/vectorio/Polygon.c
msgid "%q must be a tuple of length 2"
-msgstr ""
+msgstr "%q deve ser uma tupla de comprimento 2"
+
+#: ports/atmel-samd/common-hal/sdioio/SDCard.c
+msgid "%q pin invalid"
+msgstr "%q pino inválido"
#: shared-bindings/fontio/BuiltinFont.c
-#, fuzzy
msgid "%q should be an int"
-msgstr "y deve ser um int"
+msgstr "%q deve ser um int"
#: py/bc.c py/objnamedtuple.c
msgid "%q() takes %d positional arguments but %d were given"
-msgstr ""
+msgstr "%q() recebe %d argumentos posicionais, porém %d foram informados"
#: py/argcheck.c
msgid "'%q' argument required"
msgstr "'%q' argumento(s) requerido(s)"
+#: py/objarray.c
+msgid "'%q' object is not bytes-like"
+msgstr "objetos '%q' não são bytes-like"
+
#: py/emitinlinethumb.c py/emitinlinextensa.c
#, c-format
msgid "'%s' expects a label"
-msgstr ""
+msgstr "'%s' exige um rótulo"
#: py/emitinlinethumb.c py/emitinlinextensa.c
#, c-format
msgid "'%s' expects a register"
-msgstr ""
+msgstr "'%s' exige um registro"
#: py/emitinlinethumb.c
#, c-format
msgid "'%s' expects a special register"
-msgstr ""
+msgstr "'%s' exige um registro especial"
#: py/emitinlinethumb.c
#, c-format
msgid "'%s' expects an FPU register"
-msgstr ""
+msgstr "'%s' exige um registro FPU"
#: py/emitinlinethumb.c
#, c-format
msgid "'%s' expects an address of the form [a, b]"
-msgstr ""
+msgstr "'%s' exige um endereço no formato [a, b]"
#: py/emitinlinethumb.c py/emitinlinextensa.c
#, c-format
msgid "'%s' expects an integer"
-msgstr ""
+msgstr "'%s' exige um número inteiro"
#: py/emitinlinethumb.c
#, c-format
msgid "'%s' expects at most r%d"
-msgstr ""
+msgstr "'%s' exige no máximo r%d"
#: py/emitinlinethumb.c
#, c-format
msgid "'%s' expects {r0, r1, ...}"
-msgstr ""
+msgstr "'%s' exige {r0, r1, ...}"
#: py/emitinlinextensa.c
#, c-format
msgid "'%s' integer %d is not within range %d..%d"
-msgstr ""
+msgstr "O número inteiro '%s' %d não está dentro do intervalo %d..%d"
#: py/emitinlinethumb.c
#, c-format
msgid "'%s' integer 0x%x does not fit in mask 0x%x"
-msgstr ""
+msgstr "O número inteiro '%s' 0x%x não cabe na máscara 0x%x"
#: py/runtime.c
msgid "'%s' object cannot assign attribute '%q'"
-msgstr ""
+msgstr "O objeto '%s' não pode definir o atributo '%q'"
#: py/proto.c
msgid "'%s' object does not support '%q'"
-msgstr ""
+msgstr "O objeto '%s' não é compatível com '%q'"
#: py/obj.c
#, c-format
msgid "'%s' object does not support item assignment"
-msgstr ""
+msgstr "O objeto '%s' não compatível com a atribuição dos itens"
#: py/obj.c
#, c-format
msgid "'%s' object does not support item deletion"
-msgstr ""
+msgstr "O objeto '%s' não é compatível com exclusão do item"
#: py/runtime.c
msgid "'%s' object has no attribute '%q'"
-msgstr ""
+msgstr "O objeto '%s' não possui o atributo '%q'"
#: py/runtime.c
#, c-format
msgid "'%s' object is not an iterator"
-msgstr ""
+msgstr "O objeto '%s' não é um iterador"
#: py/objtype.c py/runtime.c
#, c-format
msgid "'%s' object is not callable"
-msgstr ""
+msgstr "O objeto '%s' não é invocável"
#: py/runtime.c
#, c-format
msgid "'%s' object is not iterable"
-msgstr ""
+msgstr "O objeto '%s' não é iterável"
#: py/obj.c
#, c-format
msgid "'%s' object is not subscriptable"
-msgstr ""
+msgstr "O objeto '%s' não é subroteirizável"
#: py/objstr.c
msgid "'=' alignment not allowed in string format specifier"
msgstr ""
+"'=' alinhamento não permitido no especificador do formato da cadeia de "
+"caracteres"
#: shared-module/struct/__init__.c
msgid "'S' and 'O' are not supported format types"
@@ -201,59 +224,59 @@ msgstr "'S' e 'O' não são tipos de formato suportados"
#: py/compile.c
msgid "'align' requires 1 argument"
-msgstr ""
+msgstr "O 'align' exige 1 argumento"
#: py/compile.c
msgid "'async for' or 'async with' outside async function"
-msgstr ""
+msgstr "'assíncrono para' ou 'assíncrono com' função assíncrona externa"
#: py/compile.c
msgid "'await' outside function"
-msgstr ""
+msgstr "'aguardar' fora da função"
#: py/compile.c
msgid "'break' outside loop"
-msgstr ""
+msgstr "'break' fora do loop"
#: py/compile.c
msgid "'continue' outside loop"
-msgstr ""
+msgstr "'continue' fora do loop"
#: py/compile.c
msgid "'data' requires at least 2 arguments"
-msgstr ""
+msgstr "'data' exige pelo menos 2 argumentos"
#: py/compile.c
msgid "'data' requires integer arguments"
-msgstr ""
+msgstr "'data' exige argumentos inteiros"
#: py/compile.c
msgid "'label' requires 1 argument"
-msgstr ""
+msgstr "'label' exige 1 argumento"
#: py/compile.c
msgid "'return' outside function"
-msgstr ""
+msgstr "função externa 'return'"
#: py/compile.c
msgid "'yield' outside function"
-msgstr ""
+msgstr "função externa 'yield'"
#: py/compile.c
msgid "*x must be assignment target"
-msgstr ""
+msgstr "*x deve ser o destino da atribuição"
#: py/obj.c
msgid ", in %q\n"
-msgstr ""
+msgstr ", em %q\n"
#: py/objcomplex.c
msgid "0.0 to a complex power"
-msgstr ""
+msgstr "0,0 para uma potência complexa"
#: py/modbuiltins.c
msgid "3-arg pow() not supported"
-msgstr ""
+msgstr "3-arg pow() não compatível"
#: ports/atmel-samd/common-hal/countio/Counter.c
#: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c
@@ -261,13 +284,13 @@ msgid "A hardware interrupt channel is already in use"
msgstr "Um canal de interrupção de hardware já está em uso"
#: shared-bindings/_bleio/Address.c
-#, fuzzy, c-format
+#, c-format
msgid "Address must be %d bytes long"
-msgstr "buffers devem ser o mesmo tamanho"
+msgstr "O endereço deve ter %d bytes de comprimento"
#: shared-bindings/_bleio/Address.c
msgid "Address type out of range"
-msgstr ""
+msgstr "O tipo do endereço está fora do alcance"
#: ports/nrf/common-hal/busio/I2C.c
msgid "All I2C peripherals are in use"
@@ -278,9 +301,8 @@ msgid "All SPI peripherals are in use"
msgstr "Todos os periféricos SPI estão em uso"
#: ports/nrf/common-hal/busio/UART.c
-#, fuzzy
msgid "All UART peripherals are in use"
-msgstr "Todos os periféricos I2C estão em uso"
+msgstr "Todos os periféricos UART estão em uso"
#: ports/atmel-samd/common-hal/audioio/AudioOut.c
msgid "All event channels in use"
@@ -288,7 +310,7 @@ msgstr "Todos os canais de eventos em uso"
#: ports/atmel-samd/audio_dma.c ports/atmel-samd/common-hal/audiobusio/PDMIn.c
msgid "All sync event channels in use"
-msgstr ""
+msgstr "Todos os canais dos eventos de sincronização em uso"
#: shared-bindings/pulseio/PWMOut.c
msgid "All timers for this pin are in use"
@@ -308,11 +330,16 @@ msgstr "Todos os temporizadores em uso"
#: ports/nrf/common-hal/_bleio/Adapter.c
msgid "Already advertising."
-msgstr ""
+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 ""
+msgstr "O AnalogIn não é compatível no pino informado"
#: ports/cxd56/common-hal/analogio/AnalogOut.c
#: ports/mimxrt10xx/common-hal/analogio/AnalogOut.c
@@ -322,7 +349,7 @@ msgstr "Funcionalidade AnalogOut não suportada"
#: shared-bindings/analogio/AnalogOut.c
msgid "AnalogOut is only 16 bits. Value must be less than 65536."
-msgstr ""
+msgstr "O AnalogOut é de apenas 16 bits. O valor deve ser menor que 65536."
#: ports/atmel-samd/common-hal/analogio/AnalogOut.c
msgid "AnalogOut not supported on given pin"
@@ -339,15 +366,22 @@ msgstr "Array deve conter meias palavras (tipo 'H')"
#: shared-bindings/nvm/ByteArray.c
msgid "Array values should be single bytes."
-msgstr ""
+msgstr "Os valores das matrizes devem ser bytes simples."
-#: shared-bindings/rgbmatrix/RGBMatrix.c
+#: shared-bindings/microcontroller/Pin.c
msgid "At most %d %q may be specified (not %d)"
-msgstr ""
+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 ""
+"A tentativa da área de alocação dinâmica de variáveis (heap) quando o "
+"MicroPython VM não está em execução."
#: main.c
msgid "Auto-reload is off.\n"
@@ -358,23 +392,27 @@ msgid ""
"Auto-reload is on. Simply save files over USB to run them or enter REPL to "
"disable.\n"
msgstr ""
+"O recarregamento automático está ativo. Simplesmente salve os arquivos via "
+"USB para executá-los ou digite REPL para desativar.\n"
#: shared-module/displayio/Display.c
#: shared-module/framebufferio/FramebufferDisplay.c
msgid "Below minimum frame rate"
-msgstr ""
+msgstr "Abaixo da taxa mínima de quadros"
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
msgid "Bit clock and word select must share a clock unit"
msgstr ""
+"O clock de bits e a seleção de palavras devem compartilhar uma unidade de "
+"clock"
#: shared-bindings/audiobusio/PDMIn.c
msgid "Bit depth must be multiple of 8."
-msgstr ""
+msgstr "A profundidade de bits deve ser o múltiplo de 8."
#: ports/mimxrt10xx/common-hal/busio/UART.c
msgid "Both RX and TX required for flow control"
-msgstr ""
+msgstr "Ambos os RX e TX são necessários para o controle do fluxo"
#: ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c
msgid "Both pins must support hardware interrupts"
@@ -384,7 +422,7 @@ msgstr "Ambos os pinos devem suportar interrupções de hardware"
#: shared-bindings/framebufferio/FramebufferDisplay.c
#: shared-bindings/rgbmatrix/RGBMatrix.c
msgid "Brightness must be 0-1.0"
-msgstr ""
+msgstr "O brilho deve ser 0-1,0"
#: shared-bindings/supervisor/__init__.c
msgid "Brightness must be between 0 and 255"
@@ -393,12 +431,12 @@ msgstr "O brilho deve estar entre 0 e 255"
#: shared-bindings/displayio/Display.c
#: shared-bindings/framebufferio/FramebufferDisplay.c
msgid "Brightness not adjustable"
-msgstr ""
+msgstr "Brilho não ajustável"
#: shared-bindings/_bleio/UUID.c
#, c-format
msgid "Buffer + offset too small %d %d %d"
-msgstr ""
+msgstr "O buffer + desvio é muito pequeno %d %d %d"
#: shared-module/usb_hid/Device.c
#, c-format
@@ -408,41 +446,45 @@ msgstr "Buffer de tamanho incorreto. Deve ser %d bytes."
#: shared-bindings/displayio/Display.c
#: shared-bindings/framebufferio/FramebufferDisplay.c
msgid "Buffer is not a bytearray."
-msgstr ""
+msgstr "O buffer não é um bytearray."
#: shared-bindings/displayio/Display.c
#: shared-bindings/framebufferio/FramebufferDisplay.c
msgid "Buffer is too small"
-msgstr ""
+msgstr "O buffer é muito pequeno"
#: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c
#, c-format
msgid "Buffer length %d too big. It must be less than %d"
-msgstr ""
+msgstr "O tamanho do buffer %d é muito grande. Deve ser menor que %d"
+
+#: ports/atmel-samd/common-hal/sdioio/SDCard.c
+#: ports/cxd56/common-hal/sdioio/SDCard.c shared-module/sdcardio/SDCard.c
+msgid "Buffer length must be a multiple of 512"
+msgstr "O comprimento do Buffer deve ser um múltiplo de 512"
#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c
msgid "Buffer must be at least length 1"
-msgstr ""
+msgstr "O comprimento do buffer deve ter pelo menos 1"
#: ports/nrf/common-hal/_bleio/PacketBuffer.c
msgid "Buffer too large and unable to allocate"
-msgstr ""
+msgstr "O buffer é muito grande e incapaz de alocar"
#: shared-bindings/_bleio/PacketBuffer.c
#, c-format
msgid "Buffer too short by %d bytes"
-msgstr ""
+msgstr "O buffer é muito curto em %d bytes"
#: ports/atmel-samd/common-hal/displayio/ParallelBus.c
#: ports/nrf/common-hal/displayio/ParallelBus.c
-#, fuzzy, c-format
+#, c-format
msgid "Bus pin %d is already in use"
-msgstr "DAC em uso"
+msgstr "O pino bus %d já está em uso"
#: shared-bindings/_bleio/UUID.c
-#, fuzzy
msgid "Byte buffer must be 16 bytes."
-msgstr "buffers devem ser o mesmo tamanho"
+msgstr "O buffer deve ter 16 bytes."
#: shared-bindings/nvm/ByteArray.c
msgid "Bytes must be between 0 and 255."
@@ -450,17 +492,19 @@ msgstr "Os bytes devem estar entre 0 e 255."
#: shared-bindings/aesio/aes.c
msgid "CBC blocks must be multiples of 16 bytes"
-msgstr ""
+msgstr "Os blocos CBC devem ter múltiplos de 16 bytes"
#: py/objtype.c
msgid "Call super().__init__() before accessing native object."
-msgstr ""
+msgstr "Chame super().__init__() antes de acessar o objeto nativo."
#: ports/nrf/common-hal/_bleio/Characteristic.c
msgid "Can't set CCCD on local Characteristic"
-msgstr ""
+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"
@@ -468,20 +512,21 @@ msgstr "Não é possível excluir valores"
#: ports/mimxrt10xx/common-hal/digitalio/DigitalInOut.c
#: ports/nrf/common-hal/digitalio/DigitalInOut.c
msgid "Cannot get pull while in output mode"
-msgstr ""
+msgstr "Não é possível obter pull enquanto está modo de saída"
#: ports/nrf/common-hal/microcontroller/Processor.c
-#, fuzzy
msgid "Cannot get temperature"
-msgstr "Não pode obter a temperatura. status: 0x%02x"
+msgstr "Não é possível obter a temperatura"
#: shared-bindings/_bleio/Adapter.c
msgid "Cannot have scan responses for extended, connectable advertisements."
msgstr ""
+"Não é possível ter respostas da verificação para os anúncios estendidos e "
+"conectáveis."
#: ports/atmel-samd/common-hal/audioio/AudioOut.c
msgid "Cannot output both channels on the same pin"
-msgstr ""
+msgstr "Não é possível emitir os dois canais no mesmo pino"
#: shared-module/bitbangio/SPI.c
msgid "Cannot read without MISO pin."
@@ -500,18 +545,19 @@ msgstr "Não é possível remontar '/' enquanto o USB estiver ativo."
#: ports/mimxrt10xx/common-hal/microcontroller/__init__.c
msgid "Cannot reset into bootloader because no bootloader is present."
msgstr ""
+"Não é possível redefinir para o bootloader porque o mesmo não está presente."
#: shared-bindings/digitalio/DigitalInOut.c
msgid "Cannot set value when direction is input."
-msgstr ""
+msgstr "Não é possível definir o valor quando a direção é inserida."
#: ports/mimxrt10xx/common-hal/busio/UART.c
msgid "Cannot specify RTS or CTS in RS485 mode"
-msgstr ""
+msgstr "Não é possível definir o RTS ou CTS no modo RS485"
#: py/objslice.c
msgid "Cannot subclass slice"
-msgstr ""
+msgstr "Não é possível subclassificar a fatia"
#: shared-module/bitbangio/SPI.c
msgid "Cannot transfer without MOSI and MISO pins."
@@ -519,29 +565,32 @@ msgstr "Não é possível transferir sem os pinos MOSI e MISO."
#: extmod/moductypes.c
msgid "Cannot unambiguously get sizeof scalar"
-msgstr ""
+msgstr "Não é possível obter inequivocamente o tamanho do escalar"
#: ports/stm/common-hal/pulseio/PWMOut.c
msgid "Cannot vary frequency on a timer that is already in use"
-msgstr ""
+msgstr "Não é possível variar a frequência em um timer que já esteja em uso"
#: shared-module/bitbangio/SPI.c
msgid "Cannot write without MOSI pin."
-msgstr "Não é possível ler sem um pino MOSI"
+msgstr "Não é possível fazer a escrita sem um pino MOSI."
#: shared-bindings/_bleio/CharacteristicBuffer.c
msgid "CharacteristicBuffer writing not provided"
-msgstr ""
+msgstr "Escrita CharacteristicBuffer não informada"
#: supervisor/shared/safe_mode.c
msgid "CircuitPython core code crashed hard. Whoops!\n"
-msgstr ""
+msgstr "O núcleo principal do CircuitPython falhou feio. Ops!\n"
#: supervisor/shared/safe_mode.c
msgid ""
"CircuitPython is in safe mode because you pressed the reset button during "
"boot. Press again to exit safe mode.\n"
msgstr ""
+"O CircuitPython está no modo de segurança porque você pressionou o botão de "
+"redefinição durante a inicialização. Pressione novamente para sair do modo "
+"de segurança.\n"
#: shared-module/bitbangio/SPI.c
msgid "Clock pin init failed."
@@ -557,31 +606,35 @@ msgstr "Unidade de Clock em uso"
#: shared-bindings/_pew/PewPew.c
msgid "Column entry must be digitalio.DigitalInOut"
-msgstr ""
+msgstr "A entrada da coluna deve ser digitalio.DigitalInOut"
#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/I2CDisplay.c
#: shared-bindings/displayio/ParallelBus.c
-#, fuzzy
msgid "Command must be an int between 0 and 255"
-msgstr "Os bytes devem estar entre 0 e 255."
+msgstr "O comando deve ser um int entre 0 e 255"
#: shared-bindings/_bleio/Connection.c
msgid ""
"Connection has been disconnected and can no longer be used. Create a new "
"connection."
msgstr ""
+"A conexão foi desconectada e não pode mais ser usada. Crie uma nova conexão."
#: py/persistentcode.c
msgid "Corrupt .mpy file"
-msgstr ""
+msgstr "Arquivo .mpy corrompido"
#: py/emitglue.c
msgid "Corrupt raw code"
-msgstr ""
+msgstr "Código bruto corrompido"
#: ports/cxd56/common-hal/gnss/GNSS.c
msgid "Could not initialize GNSS"
-msgstr ""
+msgstr "Não foi possível inicializar o GNSS"
+
+#: ports/cxd56/common-hal/sdioio/SDCard.c
+msgid "Could not initialize SDCard"
+msgstr "Não foi possível inicializar o SDCard"
#: ports/atmel-samd/common-hal/busio/UART.c ports/cxd56/common-hal/busio/UART.c
msgid "Could not initialize UART"
@@ -589,35 +642,35 @@ msgstr "Não foi possível inicializar o UART"
#: ports/stm/common-hal/pulseio/PWMOut.c
msgid "Could not initialize channel"
-msgstr ""
+msgstr "Não foi possível inicializar o canal"
#: ports/stm/common-hal/pulseio/PWMOut.c
msgid "Could not initialize timer"
-msgstr ""
+msgstr "Não foi possível inicializar o temporizador"
#: ports/stm/common-hal/pulseio/PWMOut.c
msgid "Could not re-init channel"
-msgstr ""
+msgstr "Não foi possível reiniciar o canal"
#: ports/stm/common-hal/pulseio/PWMOut.c
msgid "Could not re-init timer"
-msgstr ""
+msgstr "Não foi possível reiniciar o temporizador"
#: ports/stm/common-hal/pulseio/PWMOut.c
msgid "Could not restart PWM"
-msgstr ""
+msgstr "Não foi possível reiniciar o PWM"
#: ports/stm/common-hal/pulseio/PWMOut.c
msgid "Could not start PWM"
-msgstr ""
+msgstr "Não foi possível iniciar o PWM"
#: ports/stm/common-hal/busio/UART.c
msgid "Could not start interrupt, RX busy"
-msgstr ""
+msgstr "Não foi possível iniciar a interrupção, RX ocupado"
#: shared-module/audiomp3/MP3Decoder.c
msgid "Couldn't allocate decoder"
-msgstr ""
+msgstr "Não foi possível alocar o decodificador"
#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c
#: shared-module/audiomp3/MP3Decoder.c
@@ -626,7 +679,7 @@ msgstr "Não pôde alocar primeiro buffer"
#: shared-module/audiomp3/MP3Decoder.c
msgid "Couldn't allocate input buffer"
-msgstr ""
+msgstr "Não foi possível alocar o buffer de entrada"
#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c
#: shared-module/audiomp3/MP3Decoder.c
@@ -635,15 +688,15 @@ msgstr "Não pôde alocar segundo buffer"
#: supervisor/shared/safe_mode.c
msgid "Crash into the HardFault_Handler."
-msgstr ""
+msgstr "Falha no HardFault_Handler."
#: ports/stm/common-hal/analogio/AnalogOut.c
msgid "DAC Channel Init Error"
-msgstr ""
+msgstr "Erro de Inicialização do Canal DAC"
#: ports/stm/common-hal/analogio/AnalogOut.c
msgid "DAC Device Init Error"
-msgstr ""
+msgstr "Erro de Inicialização do Dispositivo DAC"
#: ports/atmel-samd/common-hal/audioio/AudioOut.c
msgid "DAC already in use"
@@ -652,47 +705,46 @@ msgstr "DAC em uso"
#: ports/atmel-samd/common-hal/displayio/ParallelBus.c
#: ports/nrf/common-hal/displayio/ParallelBus.c
msgid "Data 0 pin must be byte aligned"
-msgstr ""
+msgstr "O pino de dados 0 deve ser alinhado por bytes"
#: shared-module/audiocore/WaveFile.c
msgid "Data chunk must follow fmt chunk"
msgstr "Pedaço de dados deve seguir o pedaço de cortes"
#: ports/nrf/common-hal/_bleio/Adapter.c
-#, fuzzy
msgid "Data too large for advertisement packet"
-msgstr "Não é possível ajustar dados no pacote de anúncios."
+msgstr "Os dados são grandes demais para o pacote de publicidade"
#: shared-bindings/audiobusio/PDMIn.c
msgid "Destination capacity is smaller than destination_length."
-msgstr ""
+msgstr "A capacidade do destino é menor que destination_length."
#: ports/nrf/common-hal/audiobusio/I2SOut.c
msgid "Device in use"
-msgstr ""
+msgstr "Dispositivo em uso"
#: ports/cxd56/common-hal/digitalio/DigitalInOut.c
msgid "DigitalInOut not supported on given pin"
-msgstr ""
+msgstr "O DigitalInOut não é compatível em um determinado pino"
#: shared-bindings/displayio/Display.c
#: shared-bindings/framebufferio/FramebufferDisplay.c
msgid "Display must have a 16 bit colorspace."
-msgstr ""
+msgstr "O monitor deve ter um espaço de cores com 16 bits."
#: shared-bindings/displayio/Display.c
#: shared-bindings/displayio/EPaperDisplay.c
#: shared-bindings/framebufferio/FramebufferDisplay.c
msgid "Display rotation must be in 90 degree increments"
-msgstr ""
+msgstr "A rotação da tela deve estar em incrementos de 90 graus"
#: shared-bindings/digitalio/DigitalInOut.c
msgid "Drive mode not used when direction is input."
-msgstr ""
+msgstr "O modo do controlador não é usado quando a direção for inserida."
#: shared-bindings/aesio/aes.c
msgid "ECB only operates on 16 bytes at a time"
-msgstr ""
+msgstr "O BCE opera apenas com 16 bytes por vez"
#: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c
#: ports/atmel-samd/common-hal/ps2io/Ps2.c
@@ -705,7 +757,8 @@ msgstr "Canal EXTINT em uso"
msgid "Error in regex"
msgstr "Erro no regex"
-#: shared-bindings/aesio/aes.c shared-bindings/microcontroller/Pin.c
+#: shared-bindings/aesio/aes.c shared-bindings/busio/SPI.c
+#: shared-bindings/microcontroller/Pin.c
#: shared-bindings/neopixel_write/__init__.c shared-bindings/pulseio/PulseOut.c
#: shared-bindings/terminalio/Terminal.c
msgid "Expected a %q"
@@ -713,45 +766,43 @@ msgstr "Esperado um"
#: shared-bindings/_bleio/CharacteristicBuffer.c
#: shared-bindings/_bleio/Descriptor.c shared-bindings/_bleio/PacketBuffer.c
-#, fuzzy
msgid "Expected a Characteristic"
-msgstr "Não é possível adicionar Característica."
+msgstr "Uma característica é necessária"
#: shared-bindings/_bleio/Characteristic.c
msgid "Expected a Service"
-msgstr ""
+msgstr "Esperava um Serviço"
#: shared-bindings/_bleio/Characteristic.c shared-bindings/_bleio/Descriptor.c
#: shared-bindings/_bleio/Service.c
-#, fuzzy
msgid "Expected a UUID"
-msgstr "Esperado um"
+msgstr "Um UUID é necessário"
#: shared-bindings/_bleio/Adapter.c
msgid "Expected an Address"
-msgstr ""
+msgstr "Um endereço esperado"
#: shared-module/_pixelbuf/PixelBuf.c
#, c-format
msgid "Expected tuple of length %d, got %d"
-msgstr ""
+msgstr "Tupla esperada com comprimento %d, obteve %d"
#: ports/nrf/common-hal/_bleio/Adapter.c
msgid "Extended advertisements with scan response not supported."
-msgstr ""
+msgstr "Anúncios estendidos não compatíveis com a resposta da varredura."
#: extmod/ulab/code/fft.c
msgid "FFT is defined for ndarrays only"
-msgstr ""
+msgstr "O FFT é definido apenas para ndarrays"
#: shared-bindings/ps2io/Ps2.c
msgid "Failed sending command."
msgstr "Falha ao enviar comando."
#: ports/nrf/sd_mutex.c
-#, fuzzy, c-format
+#, c-format
msgid "Failed to acquire mutex, err 0x%04x"
-msgstr "Não é possível ler o valor do atributo. status: 0x%02x"
+msgstr "Houve uma falha na aquisição do mutex, err 0x%04x"
#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c
msgid "Failed to allocate RX buffer"
@@ -768,24 +819,24 @@ msgstr "Falha ao alocar buffer RX de %d bytes"
#: ports/nrf/common-hal/_bleio/Adapter.c
msgid "Failed to connect: internal error"
-msgstr ""
+msgstr "Falha ao conectar: erro interno"
#: ports/nrf/common-hal/_bleio/Adapter.c
msgid "Failed to connect: timeout"
-msgstr ""
+msgstr "Falha ao conectar: tempo limite"
#: shared-module/audiomp3/MP3Decoder.c
msgid "Failed to parse MP3 file"
-msgstr ""
+msgstr "Falha ao analisar o arquivo MP3"
#: ports/nrf/sd_mutex.c
-#, fuzzy, c-format
+#, c-format
msgid "Failed to release mutex, err 0x%04x"
-msgstr "Não é possível ler o valor do atributo. status: 0x%02x"
+msgstr "Houve uma falha ao liberar o mutex, err 0x%04x"
#: supervisor/shared/safe_mode.c
msgid "Failed to write internal flash."
-msgstr ""
+msgstr "Falha ao gravar o flash interno."
#: py/moduerrno.c
msgid "File exists"
@@ -794,21 +845,23 @@ msgstr "Arquivo já existe"
#: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c
msgid "Frequency captured is above capability. Capture Paused."
msgstr ""
+"A frequência capturada está acima da capacidade. A captura está em pausa."
#: ports/stm/common-hal/pulseio/PWMOut.c
msgid "Frequency must match existing PWMOut using this timer"
msgstr ""
+"A frequência deve coincidir com o PWMOut existente usando este temporizador"
#: shared-bindings/bitbangio/I2C.c shared-bindings/bitbangio/SPI.c
#: shared-bindings/busio/I2C.c shared-bindings/busio/SPI.c
msgid "Function requires lock"
-msgstr ""
+msgstr "A função requer bloqueio"
#: shared-bindings/displayio/Display.c
#: shared-bindings/displayio/EPaperDisplay.c
#: shared-bindings/framebufferio/FramebufferDisplay.c
msgid "Group already used"
-msgstr ""
+msgstr "O grupo já está em uso"
#: shared-module/displayio/Group.c
msgid "Group full"
@@ -817,11 +870,11 @@ msgstr "Grupo cheio"
#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/I2C.c
#: ports/stm/common-hal/busio/SPI.c
msgid "Hardware busy, try alternative pins"
-msgstr ""
+msgstr "O hardware está ocupado, tente os pinos alternativos"
#: ports/mimxrt10xx/common-hal/busio/UART.c ports/stm/common-hal/busio/UART.c
msgid "Hardware in use, try alternative pins"
-msgstr ""
+msgstr "O hardware está em uso, tente os pinos alternativos"
#: extmod/vfs_posix_file.c py/objstringio.c
msgid "I/O operation on closed file"
@@ -829,43 +882,49 @@ msgstr "Operação I/O no arquivo fechado"
#: ports/stm/common-hal/busio/I2C.c
msgid "I2C Init Error"
-msgstr ""
+msgstr "Erro de inicialização do I2C"
#: shared-bindings/aesio/aes.c
#, c-format
msgid "IV must be %d bytes long"
-msgstr ""
+msgstr "O IV deve ter %d bytes de comprimento"
#: py/persistentcode.c
msgid ""
"Incompatible .mpy file. Please update all .mpy files. See http://adafru.it/"
"mpy-update for more info."
msgstr ""
+"Arquivo .mpy incompatível. Atualize todos os arquivos .mpy. Consulte http://"
+"adafru.it/mpy-update para mais informações."
#: shared-bindings/_pew/PewPew.c
msgid "Incorrect buffer size"
-msgstr ""
+msgstr "O tamanho do buffer está incorreto"
#: py/moduerrno.c
msgid "Input/output error"
-msgstr ""
+msgstr "Erro de entrada/saída"
#: ports/nrf/common-hal/_bleio/__init__.c
msgid "Insufficient authentication"
-msgstr ""
+msgstr "Autenticação insuficiente"
#: ports/nrf/common-hal/_bleio/__init__.c
msgid "Insufficient encryption"
-msgstr ""
+msgstr "Criptografia insuficiente"
#: ports/stm/common-hal/busio/UART.c
msgid "Internal define error"
-msgstr ""
+msgstr "Erro interno de definição"
#: shared-module/rgbmatrix/RGBMatrix.c
#, c-format
msgid "Internal error #%d"
-msgstr ""
+msgstr "Erro interno #%d"
+
+#: shared-bindings/sdioio/SDCard.c
+msgid "Invalid %q"
+msgstr "%q Inválido"
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
@@ -874,7 +933,7 @@ msgstr "Pino do %q inválido"
#: ports/stm/common-hal/analogio/AnalogIn.c
msgid "Invalid ADC Unit value"
-msgstr ""
+msgstr "Valor inválido da unidade ADC"
#: shared-module/displayio/OnDiskBitmap.c
msgid "Invalid BMP file"
@@ -882,11 +941,11 @@ msgstr "Arquivo BMP inválido"
#: ports/stm/common-hal/analogio/AnalogOut.c
msgid "Invalid DAC pin supplied"
-msgstr ""
+msgstr "O pino DAC informado é inválido"
#: ports/stm/common-hal/busio/I2C.c
msgid "Invalid I2C pin selection"
-msgstr ""
+msgstr "A seleção dos pinos I2C é inválido"
#: ports/atmel-samd/common-hal/pulseio/PWMOut.c
#: ports/cxd56/common-hal/pulseio/PWMOut.c
@@ -896,11 +955,11 @@ msgstr "Frequência PWM inválida"
#: ports/stm/common-hal/busio/SPI.c
msgid "Invalid SPI pin selection"
-msgstr ""
+msgstr "A seleção do pino SPI é inválido"
#: ports/stm/common-hal/busio/UART.c
msgid "Invalid UART pin selection"
-msgstr ""
+msgstr "A seleção dos pinos UART é inválido"
#: py/moduerrno.c shared-module/rgbmatrix/RGBMatrix.c
msgid "Invalid argument"
@@ -908,29 +967,27 @@ msgstr "Argumento inválido"
#: shared-module/displayio/Bitmap.c
msgid "Invalid bits per value"
-msgstr ""
+msgstr "Os valores por bits são inválidos"
#: ports/nrf/common-hal/busio/UART.c ports/stm/common-hal/busio/UART.c
-#, fuzzy
msgid "Invalid buffer size"
-msgstr "Arquivo inválido"
+msgstr "O tamanho do buffer é inválido"
#: shared-bindings/_pixelbuf/PixelBuf.c
msgid "Invalid byteorder string"
-msgstr ""
+msgstr "A cadeia de bytes é inválida"
#: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c
msgid "Invalid capture period. Valid range: 1 - 500"
-msgstr ""
+msgstr "O período de captura é inválido. O intervalo válido é: 1 - 500"
#: shared-bindings/audiomixer/Mixer.c
-#, fuzzy
msgid "Invalid channel count"
-msgstr "certificado inválido"
+msgstr "A contagem do canal é inválido"
#: shared-bindings/digitalio/DigitalInOut.c
msgid "Invalid direction."
-msgstr "Direção inválida"
+msgstr "Direção inválida."
#: shared-module/audiocore/WaveFile.c
msgid "Invalid file"
@@ -942,11 +999,11 @@ msgstr "Tamanho do pedaço de formato inválido"
#: ports/stm/common-hal/pulseio/PWMOut.c
msgid "Invalid frequency supplied"
-msgstr ""
+msgstr "A frequência informada é inválida"
#: supervisor/shared/safe_mode.c
msgid "Invalid memory access."
-msgstr ""
+msgstr "O acesso da memória é inválido."
#: shared-bindings/bitbangio/SPI.c shared-bindings/busio/SPI.c
msgid "Invalid number of bits"
@@ -976,7 +1033,8 @@ msgstr "Pino inválido para canal direito"
#: ports/atmel-samd/common-hal/busio/UART.c
#: ports/atmel-samd/common-hal/i2cperipheral/I2CPeripheral.c
#: ports/cxd56/common-hal/busio/I2C.c ports/cxd56/common-hal/busio/SPI.c
-#: ports/cxd56/common-hal/busio/UART.c ports/mimxrt10xx/common-hal/busio/I2C.c
+#: ports/cxd56/common-hal/busio/UART.c ports/cxd56/common-hal/sdioio/SDCard.c
+#: ports/mimxrt10xx/common-hal/busio/I2C.c
#: ports/mimxrt10xx/common-hal/busio/SPI.c
#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/I2C.c
msgid "Invalid pins"
@@ -984,33 +1042,32 @@ msgstr "Pinos inválidos"
#: ports/stm/common-hal/pulseio/PWMOut.c
msgid "Invalid pins for PWMOut"
-msgstr ""
+msgstr "Os pinos para o PWMOut são inválidos"
#: shared-bindings/bitbangio/SPI.c shared-bindings/busio/SPI.c
#: shared-bindings/displayio/FourWire.c
msgid "Invalid polarity"
-msgstr ""
+msgstr "Polaridade inválida"
#: shared-bindings/_bleio/Characteristic.c
msgid "Invalid properties"
-msgstr ""
+msgstr "Propriedades inválidas"
#: shared-bindings/microcontroller/__init__.c
msgid "Invalid run mode."
-msgstr ""
+msgstr "O modo de execução é inválido."
#: shared-module/_bleio/Attribute.c
msgid "Invalid security_mode"
-msgstr ""
+msgstr "O Security_mode é inválido"
#: shared-bindings/audiomixer/Mixer.c
msgid "Invalid voice"
-msgstr ""
+msgstr "A voz é inválida"
#: shared-bindings/audiomixer/Mixer.c
-#, fuzzy
msgid "Invalid voice count"
-msgstr "certificado inválido"
+msgstr "A contagem da voz é inválida"
#: shared-module/audiocore/WaveFile.c
msgid "Invalid wave file"
@@ -1018,23 +1075,23 @@ msgstr "Aqruivo de ondas inválido"
#: ports/stm/common-hal/busio/UART.c
msgid "Invalid word/bit length"
-msgstr ""
+msgstr "O comprimento do bit/palavra são inválidos"
#: shared-bindings/aesio/aes.c
msgid "Key must be 16, 24, or 32 bytes long"
-msgstr ""
+msgstr "A chave deve ter 16, 24 ou 32 bytes de comprimento"
#: py/compile.c
msgid "LHS of keyword arg must be an id"
-msgstr ""
+msgstr "O LHS da palavra-chave arg deve ser um ID"
#: shared-module/displayio/Group.c
msgid "Layer already in a group."
-msgstr ""
+msgstr "A camada já existe em um grupo."
#: shared-module/displayio/Group.c
msgid "Layer must be a Group or TileGrid subclass."
-msgstr ""
+msgstr "A camada deve ser uma subclasse Group ou TileGrid."
#: py/objslice.c
msgid "Length must be an int"
@@ -1042,11 +1099,11 @@ msgstr "Tamanho deve ser um int"
#: py/objslice.c
msgid "Length must be non-negative"
-msgstr ""
+msgstr "O comprimento deve ser positivo"
#: shared-module/bitbangio/SPI.c
msgid "MISO pin init failed."
-msgstr "Inicialização do pino MISO falhou"
+msgstr "A inicialização do pino MISO falhou."
#: shared-module/bitbangio/SPI.c
msgid "MOSI pin init failed."
@@ -1055,44 +1112,48 @@ msgstr "Inicialização do pino MOSI falhou."
#: shared-module/displayio/Shape.c
#, c-format
msgid "Maximum x value when mirrored is %d"
-msgstr ""
+msgstr "O valor máximo de x quando espelhado é %d"
#: supervisor/shared/safe_mode.c
msgid "MicroPython NLR jump failed. Likely memory corruption."
-msgstr ""
+msgstr "O salto do MicroPython NLR falhou. Possível corrupção de memória."
#: supervisor/shared/safe_mode.c
msgid "MicroPython fatal error."
-msgstr ""
+msgstr "Houve um erro fatal do MicroPython."
#: shared-bindings/audiobusio/PDMIn.c
msgid "Microphone startup delay must be in range 0.0 to 1.0"
-msgstr ""
+msgstr "O atraso na inicialização do microfone deve estar entre 0,0 e 1,0"
#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c
msgid "Missing MISO or MOSI Pin"
-msgstr ""
+msgstr "O pino MISO ou MOSI está ausente"
#: shared-bindings/displayio/Group.c
msgid "Must be a %q subclass."
-msgstr ""
+msgstr "Deve ser uma subclasse %q."
#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c
msgid "Must provide MISO or MOSI pin"
-msgstr ""
+msgstr "Deve informar os pinos MISO ou MOSI"
+
+#: ports/stm/common-hal/busio/SPI.c
+msgid "Must provide SCK pin"
+msgstr "É obrigatório informar o pino SCK"
#: shared-bindings/rgbmatrix/RGBMatrix.c
#, c-format
msgid "Must use a multiple of 6 rgb pins, not %d"
-msgstr ""
+msgstr "Deve utilizar um múltiplo de 6 pinos rgb, não %d"
#: py/parse.c
msgid "Name too long"
-msgstr ""
+msgstr "Nome muito longo"
#: ports/nrf/common-hal/_bleio/Characteristic.c
msgid "No CCCD for this Characteristic"
-msgstr ""
+msgstr "Não há nenhum CCCD para esta característica"
#: ports/atmel-samd/common-hal/analogio/AnalogOut.c
#: ports/stm/common-hal/analogio/AnalogOut.c
@@ -1106,11 +1167,11 @@ msgstr "Nenhum canal DMA encontrado"
#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c
msgid "No MISO Pin"
-msgstr ""
+msgstr "Nenhum pino MISO"
#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/SPI.c
msgid "No MOSI Pin"
-msgstr ""
+msgstr "Nenhum pino MOSI"
#: ports/atmel-samd/common-hal/busio/UART.c
#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c
@@ -1126,11 +1187,11 @@ msgstr "Nenhum pino TX"
#: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c
msgid "No available clocks"
-msgstr ""
+msgstr "Nenhum clock disponível"
#: shared-bindings/_bleio/PacketBuffer.c
msgid "No connection: length cannot be determined"
-msgstr ""
+msgstr "Sem conexão: o comprimento não pode ser determinado"
#: shared-bindings/board/__init__.c
msgid "No default %q bus"
@@ -1142,7 +1203,7 @@ msgstr "Não há GCLKs livre"
#: shared-bindings/os/__init__.c
msgid "No hardware random available"
-msgstr ""
+msgstr "Nenhum hardware aleatório está disponível"
#: ports/atmel-samd/common-hal/ps2io/Ps2.c
msgid "No hardware support on clk pin"
@@ -1155,46 +1216,45 @@ msgstr "Nenhum suporte de hardware no pino"
#: shared-bindings/aesio/aes.c
msgid "No key was specified"
-msgstr ""
+msgstr "Nenhuma chave foi definida"
#: shared-bindings/time/__init__.c
msgid "No long integer support"
-msgstr ""
+msgstr "Não há compatibilidade com inteiro longo"
#: ports/stm/common-hal/pulseio/PWMOut.c
msgid "No more timers available on this pin."
-msgstr ""
+msgstr "Não há mais temporizadores disponíveis neste pino."
#: shared-module/touchio/TouchIn.c
msgid "No pulldown on pin; 1Mohm recommended"
-msgstr ""
+msgstr "Não há pulldown no pino; É recomendável utilizar um resistor de 1M ohm"
#: py/moduerrno.c
msgid "No space left on device"
-msgstr ""
+msgstr "Não resta espaço no dispositivo"
#: py/moduerrno.c
msgid "No such file/directory"
-msgstr ""
+msgstr "Este arquivo/diretório não existe"
#: shared-module/rgbmatrix/RGBMatrix.c
msgid "No timer available"
-msgstr ""
+msgstr "Não há um temporizador disponível"
#: supervisor/shared/safe_mode.c
msgid "Nordic Soft Device failure assertion."
-msgstr ""
+msgstr "Declaração de falha do dispositivo Nordic Soft."
#: ports/nrf/common-hal/_bleio/__init__.c
#: shared-bindings/_bleio/CharacteristicBuffer.c
-#, fuzzy
msgid "Not connected"
-msgstr "Não é possível conectar-se ao AP"
+msgstr "Não Conectado"
#: shared-bindings/audiobusio/I2SOut.c shared-bindings/audioio/AudioOut.c
#: shared-bindings/audiopwmio/PWMAudioOut.c
msgid "Not playing"
-msgstr ""
+msgstr "Não está jogando"
#: shared-bindings/util.c
msgid ""
@@ -1203,19 +1263,20 @@ msgstr ""
"Objeto foi desinicializado e não pode ser mais usaado. Crie um novo objeto."
#: ports/nrf/common-hal/busio/UART.c
-#, fuzzy
msgid "Odd parity is not supported"
-msgstr "I2C operação não suportada"
+msgstr "A paridade ímpar não é compatível"
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
msgid "Only 8 or 16 bit mono with "
-msgstr ""
+msgstr "Apenas mono com 8 ou 16 bits com "
#: shared-module/displayio/OnDiskBitmap.c
#, c-format
msgid ""
"Only Windows format, uncompressed BMP supported: given header size is %d"
msgstr ""
+"O BMP descompactado é compatível apenas no formato Windows: o tamanho do "
+"cabeçalho é %d"
#: shared-module/displayio/OnDiskBitmap.c
#, c-format
@@ -1223,25 +1284,31 @@ msgid ""
"Only monochrome, indexed 4bpp or 8bpp, and 16bpp or greater BMPs supported: "
"%d bpp given"
msgstr ""
+"São compatíveis apenas os BMPs monocromáticos, indexados em 4bpp ou 8bpp e "
+"16bpp ou superior: determinado %d bpp"
#: shared-bindings/audiobusio/PDMIn.c
msgid "Oversample must be multiple of 8."
-msgstr ""
+msgstr "A superamostragem deve ser um múltiplo de 8."
#: shared-bindings/pulseio/PWMOut.c
msgid ""
"PWM duty_cycle must be between 0 and 65535 inclusive (16 bit resolution)"
msgstr ""
+"O duty_cycle do PWM deve estar entre 0 e inclusive 65535 (com resolução de "
+"16 bits)"
#: shared-bindings/pulseio/PWMOut.c
msgid ""
"PWM frequency not writable when variable_frequency is False on construction."
msgstr ""
+"A frequência do PWM não pode ser gravada quando variable_frequency for False "
+"na construção."
#: ports/mimxrt10xx/common-hal/displayio/ParallelBus.c
#: ports/stm/common-hal/displayio/ParallelBus.c
msgid "ParallelBus not yet supported"
-msgstr ""
+msgstr "O ParallelBus ainda não é compatível"
#: py/moduerrno.c
msgid "Permission denied"
@@ -1257,15 +1324,15 @@ msgstr "O pino não tem recursos de ADC"
#: shared-bindings/digitalio/DigitalInOut.c
msgid "Pin is input only"
-msgstr ""
+msgstr "Apenas o pino de entrada"
#: ports/atmel-samd/common-hal/countio/Counter.c
msgid "Pin must support hardware interrupts"
-msgstr ""
+msgstr "O pino deve ser compatível com as interrupções do hardware"
#: ports/stm/common-hal/pulseio/PulseIn.c
msgid "Pin number already reserved by EXTI"
-msgstr ""
+msgstr "Número do PIN já está reservado através da EXTI"
#: shared-bindings/rgbmatrix/RGBMatrix.c
#, c-format
@@ -1274,15 +1341,17 @@ msgid ""
"bytes. If this cannot be avoided, pass allow_inefficient=True to the "
"constructor"
msgstr ""
+"A pinagem utiliza %d bytes por elemento, que consome mais do que %d bytes do "
+"ideal. Caso isso não possa ser evitado, passe allow_inefficient=True ao "
+"construtor"
#: py/builtinhelp.c
-#, fuzzy
msgid "Plus any modules on the filesystem\n"
-msgstr "Não é possível remontar o sistema de arquivos"
+msgstr "Além de quaisquer módulos no sistema de arquivos\n"
#: shared-module/vectorio/Polygon.c
msgid "Polygon needs at least 3 points"
-msgstr ""
+msgstr "O Polígono precisa de pelo menos 3 pontos"
#: shared-bindings/ps2io/Ps2.c
msgid "Pop from an empty Ps2 buffer"
@@ -1291,34 +1360,37 @@ msgstr "Buffer Ps2 vazio"
#: shared-bindings/_bleio/Adapter.c
msgid "Prefix buffer must be on the heap"
msgstr ""
+"O buffer do prefixo deve estar na área de alocação dinâmica de variáveis "
+"(heap)"
#: main.c
msgid "Press any key to enter the REPL. Use CTRL-D to reload."
msgstr ""
+"Pressione qualquer tecla para entrar no REPL. Use CTRL-D para recarregar."
#: shared-bindings/digitalio/DigitalInOut.c
msgid "Pull not used when direction is output."
-msgstr ""
+msgstr "O Pull não foi usado quando a direção for gerada."
#: ports/stm/common-hal/pulseio/PulseIn.c
msgid "PulseIn not supported on this chip"
-msgstr ""
+msgstr "O PulseIn não é compatível neste CI"
#: ports/stm/common-hal/pulseio/PulseOut.c
msgid "PulseOut not supported on this chip"
-msgstr ""
+msgstr "O PulseOut não é compatível neste CI"
#: ports/stm/common-hal/os/__init__.c
msgid "RNG DeInit Error"
-msgstr ""
+msgstr "Erro DeInit RNG"
#: ports/stm/common-hal/os/__init__.c
msgid "RNG Init Error"
-msgstr ""
+msgstr "Houve um erro na inicialização do RNG"
#: ports/mimxrt10xx/common-hal/busio/UART.c
msgid "RS485 inversion specified when not in RS485 mode"
-msgstr ""
+msgstr "A definição da inversão do RS485 quando não está no modo RS485"
#: ports/cxd56/common-hal/rtc/RTC.c ports/mimxrt10xx/common-hal/rtc/RTC.c
#: ports/nrf/common-hal/rtc/RTC.c
@@ -1332,12 +1404,13 @@ msgstr "O RTC não é suportado nesta placa"
#: ports/atmel-samd/common-hal/busio/UART.c ports/cxd56/common-hal/busio/UART.c
#: ports/nrf/common-hal/busio/UART.c ports/stm/common-hal/busio/UART.c
msgid "RTS/CTS/RS485 Not yet supported on this device"
-msgstr ""
+msgstr "RTS/CTS/RS485 Ainda não é compatível neste dispositivo"
#: ports/stm/common-hal/os/__init__.c
msgid "Random number generation error"
-msgstr ""
+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"
@@ -1347,17 +1420,16 @@ msgid "Read-only filesystem"
msgstr "Sistema de arquivos somente leitura"
#: shared-module/displayio/Bitmap.c
-#, fuzzy
msgid "Read-only object"
-msgstr "Somente leitura"
+msgstr "Objeto de leitura apenas"
#: shared-bindings/displayio/EPaperDisplay.c
msgid "Refresh too soon"
-msgstr ""
+msgstr "A recarga foi cedo demais"
#: shared-bindings/aesio/aes.c
msgid "Requested AES mode is unsupported"
-msgstr ""
+msgstr "O modo AES solicitado não é compatível"
#: ports/atmel-samd/common-hal/audioio/AudioOut.c
msgid "Right channel unsupported"
@@ -1365,7 +1437,7 @@ msgstr "Canal direito não suportado"
#: shared-bindings/_pew/PewPew.c
msgid "Row entry must be digitalio.DigitalInOut"
-msgstr ""
+msgstr "A entrada da linha deve ser digitalio.DigitalInOut"
#: main.c
msgid "Running in safe mode! Auto-reload is off.\n"
@@ -1375,6 +1447,10 @@ msgstr "Rodando em modo seguro! Atualização automática está desligada.\n"
msgid "Running in safe mode! Not running saved code.\n"
msgstr "Rodando em modo seguro! Não está executando o código salvo.\n"
+#: shared-module/sdcardio/SDCard.c
+msgid "SD card CSD format not supported"
+msgstr "O formato CSD do Cartão SD não é compatível"
+
#: ports/atmel-samd/common-hal/busio/I2C.c
#: ports/mimxrt10xx/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c
msgid "SDA or SCL needs a pull up"
@@ -1382,15 +1458,15 @@ msgstr "SDA ou SCL precisa de um pull up"
#: ports/stm/common-hal/busio/SPI.c
msgid "SPI Init Error"
-msgstr ""
+msgstr "Houve um erro na inicialização SPI"
#: ports/stm/common-hal/busio/SPI.c
msgid "SPI Re-initialization error"
-msgstr ""
+msgstr "Houve um erro na reinicialização SPI"
#: shared-bindings/audiomixer/Mixer.c
msgid "Sample rate must be positive"
-msgstr ""
+msgstr "A taxa de amostragem deve ser positiva"
#: ports/atmel-samd/common-hal/audioio/AudioOut.c
#, c-format
@@ -1399,15 +1475,15 @@ msgstr "Taxa de amostragem muito alta. Deve ser menor que %d"
#: ports/nrf/common-hal/_bleio/Adapter.c
msgid "Scan already in progess. Stop with stop_scan."
-msgstr ""
+msgstr "O escaneamento já está em andamento. Interrompa com stop_scan."
#: ports/mimxrt10xx/common-hal/busio/UART.c
msgid "Selected CTS pin not valid"
-msgstr ""
+msgstr "O pino CTS selecionado é inválido"
#: ports/mimxrt10xx/common-hal/busio/UART.c
msgid "Selected RTS pin not valid"
-msgstr ""
+msgstr "O pino RTS selecionado é inválido"
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
@@ -1416,20 +1492,22 @@ msgstr "Serializer em uso"
#: shared-bindings/nvm/ByteArray.c
msgid "Slice and value different lengths."
-msgstr ""
+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 ""
+msgstr "Fatiamento não compatível"
#: shared-bindings/aesio/aes.c
msgid "Source and destination buffers must be the same length"
-msgstr ""
+msgstr "Os buffers da origem e do destino devem ter o mesmo comprimento"
#: extmod/modure.c
msgid "Splitting with sub-captures"
-msgstr ""
+msgstr "Divisão com sub-capturas"
#: shared-bindings/supervisor/__init__.c
msgid "Stack size must be at least 256"
@@ -1437,31 +1515,36 @@ msgstr "O tamanho da pilha deve ser pelo menos 256"
#: shared-bindings/multiterminal/__init__.c
msgid "Stream missing readinto() or write() method."
-msgstr ""
+msgstr "Transmita o método ausente readinto() ou write()."
#: ports/mimxrt10xx/common-hal/busio/UART.c ports/stm/common-hal/busio/UART.c
msgid "Supply at least one UART pin"
-msgstr ""
+msgstr "Forneça pelo menos um pino UART"
#: shared-bindings/gnss/GNSS.c
msgid "System entry must be gnss.SatelliteSystem"
-msgstr ""
+msgstr "A entrada no sistema deve ser gnss.SatelliteSystem"
#: ports/stm/common-hal/microcontroller/Processor.c
msgid "Temperature read timed out"
-msgstr ""
+msgstr "A leitura da temperatura expirou"
#: supervisor/shared/safe_mode.c
msgid ""
"The CircuitPython heap was corrupted because the stack was too small.\n"
"Please increase the stack size if you know how, or if not:"
msgstr ""
+"A área de alocação dinâmica de variáveis (heap) do CircuitPython foi "
+"corrompida porque a pilha de funções (stack) era muito pequena.\n"
+"Aumente o tamanho da pilha de funções caso saiba como, ou caso não saiba:"
#: supervisor/shared/safe_mode.c
msgid ""
"The `microcontroller` module was used to boot into safe mode. Press reset to "
"exit safe mode.\n"
msgstr ""
+"O módulo `microcontrolador` foi utilizado para inicializar no modo de "
+"segurança. Pressione reset para encerrar do modo de segurança.\n"
#: supervisor/shared/safe_mode.c
msgid ""
@@ -1469,43 +1552,49 @@ msgid ""
"enough power for the whole circuit and press reset (after ejecting "
"CIRCUITPY).\n"
msgstr ""
+"A força do microcontrolador caiu. Verifique se a fonte de alimentação "
+"fornece\n"
+"energia suficiente para todo o circuito e pressione reset (após a ejeção "
+"CIRCUITPY).\n"
#: shared-module/audiomixer/MixerVoice.c
msgid "The sample's bits_per_sample does not match the mixer's"
-msgstr ""
+msgstr "A amostragem bits_per_sample não coincide com a do mixer"
#: shared-module/audiomixer/MixerVoice.c
msgid "The sample's channel count does not match the mixer's"
-msgstr ""
+msgstr "A contagem da amostragem dos canais não coincide com o a do mixer"
#: shared-module/audiomixer/MixerVoice.c
msgid "The sample's sample rate does not match the mixer's"
-msgstr ""
+msgstr "A taxa de amostragem da amostra não coincide com a do mixer"
#: shared-module/audiomixer/MixerVoice.c
msgid "The sample's signedness does not match the mixer's"
-msgstr ""
+msgstr "A amostragem \"signedness\" não coincide com a do mixer"
#: shared-bindings/displayio/TileGrid.c
msgid "Tile height must exactly divide bitmap height"
-msgstr ""
+msgstr "A altura do bloco deve dividir exatamente com a altura do bitmap"
#: shared-bindings/displayio/TileGrid.c shared-module/displayio/TileGrid.c
msgid "Tile index out of bounds"
-msgstr ""
+msgstr "O índice do bloco está fora dos limites"
#: shared-bindings/displayio/TileGrid.c
msgid "Tile value out of bounds"
-msgstr ""
+msgstr "O valor do bloco está fora dos limites"
#: shared-bindings/displayio/TileGrid.c
msgid "Tile width must exactly divide bitmap width"
-msgstr ""
+msgstr "A largura do bloco deve dividir exatamente com a largura do bitmap"
#: ports/nrf/common-hal/_bleio/Adapter.c
#, c-format
msgid "Timeout is too long: Maximum timeout length is %d seconds"
msgstr ""
+"O tempo limite é long demais: O comprimento máximo do tempo limite é de %d "
+"segundos"
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
msgid "Too many channels in sample."
@@ -1513,43 +1602,44 @@ msgstr "Muitos canais na amostra."
#: shared-module/displayio/__init__.c
msgid "Too many display busses"
-msgstr ""
+msgstr "Muitos barramentos estão sendo exibidos"
#: shared-module/displayio/__init__.c
msgid "Too many displays"
-msgstr ""
+msgstr "Exibições demais"
#: ports/nrf/common-hal/_bleio/PacketBuffer.c
msgid "Total data to write is larger than outgoing_packet_length"
msgstr ""
+"O total dos dados que serão gravados é maior que outgoing_packet_length"
#: py/obj.c
msgid "Traceback (most recent call last):\n"
-msgstr ""
+msgstr "Traceback (a última chamada mais recente):\n"
#: shared-bindings/time/__init__.c
msgid "Tuple or struct_time argument required"
-msgstr ""
+msgstr "O argumento de tupla ou struct_time é necessário"
#: ports/stm/common-hal/busio/UART.c
msgid "UART Buffer allocation error"
-msgstr ""
+msgstr "Houve um erro na alocação do Buffer UART"
#: ports/stm/common-hal/busio/UART.c
msgid "UART De-init error"
-msgstr ""
+msgstr "Houve um erro da não inicialização do UART"
#: ports/stm/common-hal/busio/UART.c
msgid "UART Init Error"
-msgstr ""
+msgstr "Houve um erro na inicialização do UART"
#: ports/stm/common-hal/busio/UART.c
msgid "UART Re-init error"
-msgstr ""
+msgstr "Houve um erro na reinicialização do UART"
#: ports/stm/common-hal/busio/UART.c
msgid "UART write error"
-msgstr ""
+msgstr "Houve um erro na gravação UART"
#: shared-module/usb_hid/Device.c
msgid "USB Busy"
@@ -1561,15 +1651,15 @@ msgstr "Erro na USB"
#: shared-bindings/_bleio/UUID.c
msgid "UUID integer value must be 0-0xffff"
-msgstr ""
+msgstr "O valor inteiro UUID deve ser 0-0xffff"
#: shared-bindings/_bleio/UUID.c
msgid "UUID string not 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'"
-msgstr ""
+msgstr "A cadeia de caracteres UUID não 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'"
#: shared-bindings/_bleio/UUID.c
msgid "UUID value is not str, int or byte buffer"
-msgstr ""
+msgstr "O valor UUID não é um buffer str, int ou byte"
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audioio/AudioOut.c
@@ -1579,7 +1669,7 @@ msgstr "Não é possível alocar buffers para conversão assinada"
#: shared-module/displayio/I2CDisplay.c
#, c-format
msgid "Unable to find I2C Display at %x"
-msgstr ""
+msgstr "Não foi possível encontrar a tela I2C no %x"
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
@@ -1588,11 +1678,11 @@ msgstr "Não é possível encontrar GCLK livre"
#: py/parse.c
msgid "Unable to init parser"
-msgstr ""
+msgstr "Não foi possível iniciar o analisador"
#: shared-module/displayio/OnDiskBitmap.c
msgid "Unable to read color palette data"
-msgstr ""
+msgstr "Não foi possível ler os dados da paleta de cores"
#: shared-bindings/nvm/ByteArray.c
msgid "Unable to write to nvm."
@@ -1600,37 +1690,39 @@ msgstr "Não é possível gravar no nvm."
#: ports/nrf/common-hal/_bleio/UUID.c
msgid "Unexpected nrfx uuid type"
-msgstr ""
+msgstr "Tipo uuid nrfx inesperado"
#: ports/nrf/common-hal/_bleio/__init__.c
#, c-format
msgid "Unknown gatt error: 0x%04x"
-msgstr ""
+msgstr "Erro gatt desconhecido: 0x%04x"
#: supervisor/shared/safe_mode.c
msgid "Unknown reason."
-msgstr ""
+msgstr "Motivo desconhecido."
#: ports/nrf/common-hal/_bleio/__init__.c
#, c-format
msgid "Unknown security error: 0x%04x"
-msgstr ""
+msgstr "Erro de segurança desconhecido: 0x%04x"
#: ports/nrf/common-hal/_bleio/__init__.c
#, c-format
msgid "Unknown soft device error: %04x"
-msgstr ""
+msgstr "Erro desconhecido do dispositivo de soft: %04x"
#: shared-bindings/_pixelbuf/PixelBuf.c
#, c-format
msgid "Unmatched number of items on RHS (expected %d, got %d)."
-msgstr ""
+msgstr "Quantidade inigualável de itens no RHS (%d esperado, obteve %d)."
#: ports/nrf/common-hal/_bleio/__init__.c
msgid ""
"Unspecified issue. Can be that the pairing prompt on the other device was "
"declined or ignored."
msgstr ""
+"Problema desconhecido. Pode ser que o prompt de emparelhamento no outro "
+"dispositivo tenha sido recusado ou ignorado."
#: ports/atmel-samd/common-hal/busio/I2C.c ports/cxd56/common-hal/busio/I2C.c
#: ports/stm/common-hal/busio/I2C.c
@@ -1638,9 +1730,8 @@ msgid "Unsupported baudrate"
msgstr "Taxa de transmissão não suportada"
#: shared-module/displayio/display_core.c
-#, fuzzy
msgid "Unsupported display bus type"
-msgstr "Taxa de transmissão não suportada"
+msgstr "Não há suporte para o tipo do display bus"
#: shared-module/audiocore/WaveFile.c
msgid "Unsupported format"
@@ -1648,29 +1739,29 @@ msgstr "Formato não suportado"
#: py/moduerrno.c
msgid "Unsupported operation"
-msgstr ""
+msgstr "Operação não suportada"
#: shared-bindings/digitalio/DigitalInOut.c
msgid "Unsupported pull value."
-msgstr ""
+msgstr "O valor pull não é compatível."
#: ports/nrf/common-hal/_bleio/Characteristic.c
#: ports/nrf/common-hal/_bleio/Descriptor.c
msgid "Value length != required fixed length"
-msgstr ""
+msgstr "Comprimento do valor != comprimento fixo necessário"
#: ports/nrf/common-hal/_bleio/Characteristic.c
#: ports/nrf/common-hal/_bleio/Descriptor.c
msgid "Value length > max_length"
-msgstr ""
+msgstr "O comprimento do valor é > max_length"
#: py/emitnative.c
msgid "Viper functions don't currently support more than 4 arguments"
-msgstr ""
+msgstr "Atualmente, as funções do Viper não suportam mais de 4 argumentos"
#: ports/stm/common-hal/microcontroller/Processor.c
msgid "Voltage read timed out"
-msgstr ""
+msgstr "O tempo limite de leitura da tensão expirou"
#: main.c
msgid "WARNING: Your code filename has two extensions\n"
@@ -1679,22 +1770,26 @@ msgstr "AVISO: Seu arquivo de código tem duas extensões\n"
#: shared-bindings/watchdog/WatchDogTimer.c
msgid "WatchDogTimer cannot be deinitialized once mode is set to RESET"
msgstr ""
+"O WatchDogTimer não pode ser não-inicializado uma vez que o modo é definido "
+"como RESET"
#: shared-bindings/watchdog/WatchDogTimer.c
msgid "WatchDogTimer is not currently running"
-msgstr ""
+msgstr "O WatchDogTimer não está em execução"
#: shared-bindings/watchdog/WatchDogTimer.c
msgid "WatchDogTimer.mode cannot be changed once set to WatchDogMode.RESET"
msgstr ""
+"O WatchDogTimer.mode não pode ser alterado uma vez definido para "
+"WatchDogMode.RESET"
#: shared-bindings/watchdog/WatchDogTimer.c
msgid "WatchDogTimer.timeout must be greater than 0"
-msgstr ""
+msgstr "O WatchDogTimer.timeout deve ser maior que 0"
#: supervisor/shared/safe_mode.c
msgid "Watchdog timer expired."
-msgstr ""
+msgstr "O temporizador Watchdog expirou."
#: py/builtinhelp.c
#, c-format
@@ -1705,35 +1800,41 @@ msgid ""
"\n"
"To list built-in modules please do `help(\"modules\")`.\n"
msgstr ""
+"Bem-vindo ao Adafruit CircuitPython %s!\n"
+"\n"
+"Para obter guias de projeto, visite learn.adafruit.com/category/"
+"circuitpython.\n"
+"\n"
+"Para listar os módulos internos, faça `help(\"modules\")`.\n"
#: ports/nrf/common-hal/_bleio/PacketBuffer.c
msgid "Writes not supported on Characteristic"
-msgstr ""
+msgstr "A escrita não é compatível na Característica"
#: supervisor/shared/safe_mode.c
msgid "You are in safe mode: something unanticipated happened.\n"
-msgstr ""
+msgstr "Você está no modo de segurança: algo inesperado aconteceu.\n"
#: supervisor/shared/safe_mode.c
msgid "You requested starting safe mode by "
-msgstr "Você solicitou o início do modo de segurança"
+msgstr "Você solicitou o início do modo de segurança através do "
#: py/objtype.c
msgid "__init__() should return None"
-msgstr ""
+msgstr "O __init__() deve retornar Nenhum"
#: py/objtype.c
#, c-format
msgid "__init__() should return None, not '%s'"
-msgstr ""
+msgstr "O __init__() deve retornar Nenhum, não '%s'"
#: py/objobject.c
msgid "__new__ arg must be a user-type"
-msgstr ""
+msgstr "O argumento __new__ deve ser um tipo usuário"
#: extmod/modubinascii.c extmod/moduhashlib.c
msgid "a bytes-like object is required"
-msgstr ""
+msgstr "é necessário objetos tipo bytes"
#: lib/embed/abort_.c
msgid "abort() called"
@@ -1746,23 +1847,23 @@ msgstr "endereço %08x não está alinhado com %d bytes"
#: shared-bindings/i2cperipheral/I2CPeripheral.c
msgid "address out of bounds"
-msgstr ""
+msgstr "endereço fora dos limites"
#: shared-bindings/i2cperipheral/I2CPeripheral.c
msgid "addresses is empty"
-msgstr ""
+msgstr "os endereços estão vazios"
#: extmod/ulab/code/vectorise.c
msgid "arctan2 is implemented for scalars and ndarrays only"
-msgstr ""
+msgstr "O arctan2 está implementado apenas para escalares e ndarrays"
#: py/modbuiltins.c
msgid "arg is an empty sequence"
-msgstr ""
+msgstr "o arg é uma sequência vazia"
#: extmod/ulab/code/numerical.c
msgid "argsort argument must be an ndarray"
-msgstr ""
+msgstr "O argumento argsort deve ser um ndarray"
#: py/runtime.c
msgid "argument has wrong type"
@@ -1771,23 +1872,23 @@ msgstr "argumento tem tipo errado"
#: py/argcheck.c shared-bindings/_stage/__init__.c
#: shared-bindings/digitalio/DigitalInOut.c shared-bindings/gamepad/GamePad.c
msgid "argument num/types mismatch"
-msgstr ""
+msgstr "o argumento num/tipos não combinam"
#: py/runtime.c
msgid "argument should be a '%q' not a '%q'"
-msgstr ""
+msgstr "o argumento deve ser um '%q' e não um '%q'"
#: extmod/ulab/code/linalg.c
msgid "arguments must be ndarrays"
-msgstr ""
+msgstr "os argumentos devem ser ndarrays"
#: py/objarray.c shared-bindings/nvm/ByteArray.c
msgid "array/bytes required on right side"
-msgstr ""
+msgstr "matriz/bytes são necessários no lado direito"
#: extmod/ulab/code/numerical.c
msgid "attempt to get argmin/argmax of an empty sequence"
-msgstr ""
+msgstr "tente obter argmin/argmax de uma sequência vazia"
#: py/objstr.c
msgid "attributes not supported yet"
@@ -1795,79 +1896,76 @@ msgstr "atributos ainda não suportados"
#: extmod/ulab/code/numerical.c
msgid "axis must be -1, 0, None, or 1"
-msgstr ""
+msgstr "o eixo deve ser -1, 0, Nenhum ou 1"
#: extmod/ulab/code/numerical.c
msgid "axis must be -1, 0, or 1"
-msgstr ""
+msgstr "o eixo deve ser -1, 0 ou 1"
#: extmod/ulab/code/numerical.c
msgid "axis must be None, 0, or 1"
-msgstr ""
+msgstr "o eixo deve ser Nenhum, 0 ou 1"
#: py/builtinevex.c
msgid "bad compile mode"
-msgstr ""
+msgstr "modo de compilação ruim"
#: py/objstr.c
msgid "bad conversion specifier"
-msgstr ""
+msgstr "especificador de conversão incorreto"
#: py/objstr.c
msgid "bad format string"
-msgstr ""
+msgstr "formato da string incorreta"
#: py/binary.c
msgid "bad typecode"
-msgstr ""
+msgstr "typecode incorreto"
#: py/emitnative.c
msgid "binary op %q not implemented"
-msgstr ""
+msgstr "a operação binário %q não foi implementada"
#: shared-bindings/busio/UART.c
msgid "bits must be 7, 8 or 9"
-msgstr ""
+msgstr "os bits devem ser 7, 8 ou 9"
#: shared-bindings/audiomixer/Mixer.c
-#, fuzzy
msgid "bits_per_sample must be 8 or 16"
-msgstr "bits devem ser 8"
+msgstr "bits_per_sample deve ser 8 ou 16"
#: py/emitinlinethumb.c
-#, fuzzy
msgid "branch not in range"
-msgstr "Calibração está fora do intervalo"
+msgstr "ramo fora do alcance"
#: shared-bindings/audiocore/RawSample.c
msgid "buffer must be a bytes-like object"
-msgstr ""
+msgstr "o buffer deve ser um objeto como bytes"
#: shared-module/struct/__init__.c
-#, fuzzy
msgid "buffer size must match format"
-msgstr "buffers devem ser o mesmo tamanho"
+msgstr "o tamanho do buffer deve coincidir com o formato"
#: shared-bindings/bitbangio/SPI.c shared-bindings/busio/SPI.c
msgid "buffer slices must be of equal length"
-msgstr ""
+msgstr "as fatias do buffer devem ter o mesmo comprimento"
#: py/modstruct.c shared-bindings/struct/__init__.c
#: shared-module/struct/__init__.c
msgid "buffer too small"
-msgstr ""
+msgstr "o buffer é muito pequeno"
#: shared-bindings/_pew/PewPew.c
msgid "buttons must be digitalio.DigitalInOut"
-msgstr ""
+msgstr "os botões devem ser digitalio.DigitalInOut"
#: py/vm.c
msgid "byte code not implemented"
-msgstr ""
+msgstr "o código dos bytes ainda não foi implementado"
#: shared-bindings/_pixelbuf/PixelBuf.c
msgid "byteorder is not a string"
-msgstr ""
+msgstr "a ordem dos bytes não é uma cadeia de caracteres"
#: ports/atmel-samd/common-hal/busio/UART.c
msgid "bytes > 8 bits not supported"
@@ -1875,7 +1973,7 @@ msgstr "bytes > 8 bits não suportado"
#: py/objstr.c
msgid "bytes value out of range"
-msgstr ""
+msgstr "o valor dos bytes estão fora do alcance"
#: ports/atmel-samd/bindings/samd/Clock.c
msgid "calibration is out of range"
@@ -1891,144 +1989,152 @@ msgstr "Valor de calibração fora do intervalo +/- 127"
#: py/emitinlinethumb.c
msgid "can only have up to 4 parameters to Thumb assembly"
-msgstr ""
+msgstr "só pode haver até 4 parâmetros para a montagem Thumb"
#: py/emitinlinextensa.c
msgid "can only have up to 4 parameters to Xtensa assembly"
-msgstr ""
+msgstr "só pode haver até 4 parâmetros para a montagem Xtensa"
#: py/persistentcode.c
msgid "can only save bytecode"
-msgstr ""
+msgstr "apenas o bytecode pode ser salvo"
#: py/objtype.c
msgid "can't add special method to already-subclassed class"
-msgstr ""
+msgstr "não é possível adicionar o método especial à classe já subclassificada"
#: py/compile.c
msgid "can't assign to expression"
-msgstr ""
+msgstr "a expressão não pode ser atribuída"
#: py/obj.c
#, c-format
msgid "can't convert %s to complex"
-msgstr ""
+msgstr "Não é possível converter %s para complex"
#: py/obj.c
#, c-format
msgid "can't convert %s to float"
-msgstr ""
+msgstr "Não é possível converter %s para float"
#: py/obj.c
#, c-format
msgid "can't convert %s to int"
-msgstr ""
+msgstr "Não é possível converter %s para int"
#: py/objstr.c
msgid "can't convert '%q' object to %q implicitly"
-msgstr ""
+msgstr "não é possível converter implicitamente o objeto '%q' para %q"
#: py/objint.c
msgid "can't convert NaN to int"
-msgstr ""
+msgstr "Não é possível converter NaN para int"
#: shared-bindings/i2cperipheral/I2CPeripheral.c
msgid "can't convert address to int"
-msgstr ""
+msgstr "não é possível converter o endereço para int"
#: py/objint.c
msgid "can't convert inf to int"
-msgstr ""
+msgstr "não é possível converter inf para int"
#: py/obj.c
msgid "can't convert to complex"
-msgstr ""
+msgstr "não é possível converter para complex"
#: py/obj.c
msgid "can't convert to float"
-msgstr ""
+msgstr "não é possível converter para float"
#: py/obj.c
msgid "can't convert to int"
-msgstr ""
+msgstr "não é possível converter para int"
#: py/objstr.c
msgid "can't convert to str implicitly"
-msgstr ""
+msgstr "não é possível converter implicitamente para str"
#: py/compile.c
msgid "can't declare nonlocal in outer code"
-msgstr ""
+msgstr "não é possível declarar nonlocal no código externo"
#: py/compile.c
msgid "can't delete expression"
-msgstr ""
+msgstr "não é possível excluir a expressão"
#: py/emitnative.c
msgid "can't do binary op between '%q' and '%q'"
-msgstr ""
+msgstr "não é possível executar uma operação binária entre '%q' e '%q'"
#: py/objcomplex.c
msgid "can't do truncated division of a complex number"
-msgstr ""
+msgstr "não é possível fazer a divisão truncada de um número complexo"
#: py/compile.c
msgid "can't have multiple **x"
-msgstr ""
+msgstr "não pode haver vários **x"
#: py/compile.c
msgid "can't have multiple *x"
-msgstr ""
+msgstr "não pode haver vários *x"
#: py/emitnative.c
msgid "can't implicitly convert '%q' to 'bool'"
-msgstr ""
+msgstr "não é possível converter implicitamente '%q' em 'bool'"
#: py/emitnative.c
msgid "can't load from '%q'"
-msgstr ""
+msgstr "não é possível carregar a partir de '%q'"
#: py/emitnative.c
msgid "can't load with '%q' index"
-msgstr ""
+msgstr "não é possível carregar com o índice '%q'"
#: py/objgenerator.c
msgid "can't pend throw to just-started generator"
-msgstr ""
+msgstr "não pode pendurar o lançamento para o gerador recém-iniciado"
#: py/objgenerator.c
msgid "can't send non-None value to a just-started generator"
msgstr ""
+"Não é possível enviar algo que não seja um valor para um gerador recém-"
+"iniciado"
+
+#: shared-module/sdcardio/SDCard.c
+msgid "can't set 512 block size"
+msgstr "não é possível definir o tamanho de 512 blocos"
#: py/objnamedtuple.c
msgid "can't set attribute"
-msgstr ""
+msgstr "não é possível definir o atributo"
#: py/emitnative.c
msgid "can't store '%q'"
-msgstr ""
+msgstr "não é possível armazenar '%q'"
#: py/emitnative.c
msgid "can't store to '%q'"
-msgstr ""
+msgstr "não é possível armazenar em '%q'"
#: py/emitnative.c
msgid "can't store with '%q' index"
-msgstr ""
+msgstr "não é possível armazenar com o índice '%q'"
#: py/objstr.c
msgid ""
"can't switch from automatic field numbering to manual field specification"
msgstr ""
+"não é possível alternar entre a numeração automática dos campos para a manual"
#: py/objstr.c
msgid ""
"can't switch from manual field specification to automatic field numbering"
msgstr ""
+"não é possível alternar da especificação de campo manual para a automática"
#: py/objtype.c
msgid "cannot create '%q' instances"
-msgstr ""
+msgstr "não é possível criar instâncias '%q'"
#: py/objtype.c
msgid "cannot create instance"
@@ -2040,43 +2146,46 @@ msgstr "não pode importar nome %q"
#: py/builtinimport.c
msgid "cannot perform relative import"
-msgstr ""
+msgstr "não pode executar a importação relativa"
#: extmod/ulab/code/ndarray.c
msgid "cannot reshape array (incompatible input/output shape)"
msgstr ""
+"não é possível remodelar a matriz (formato de entrada/saída incompatível)"
#: py/emitnative.c
msgid "casting"
-msgstr ""
+msgstr "fundição"
#: shared-bindings/_stage/Text.c
msgid "chars buffer too small"
-msgstr ""
+msgstr "o buffer dos caracteres é muito pequeno"
#: py/modbuiltins.c
msgid "chr() arg not in range(0x110000)"
-msgstr ""
+msgstr "o arg chr() está fora do intervalo(0x110000)"
#: py/modbuiltins.c
msgid "chr() arg not in range(256)"
-msgstr ""
+msgstr "o arg chr() está fora do intervalo(256)"
#: shared-module/vectorio/Circle.c
msgid "circle can only be registered in one parent"
-msgstr ""
+msgstr "o círculo só pode ser registrado em um pai"
#: shared-bindings/displayio/Palette.c
msgid "color buffer must be 3 bytes (RGB) or 4 bytes (RGB + pad byte)"
-msgstr ""
+msgstr "o buffer das cores deve ter 3 bytes (RGB) ou 4 bytes (RGB + pad byte)"
#: shared-bindings/displayio/Palette.c
msgid "color buffer must be a buffer, tuple, list, or int"
-msgstr ""
+msgstr "O buffer das cores deve ser um buffer, tupla, lista ou int"
#: shared-bindings/displayio/Palette.c
msgid "color buffer must be a bytearray or array of type 'b' or 'B'"
msgstr ""
+"O buffer das cores deve ser uma matriz de bytes ou uma matriz do tipo 'b' ou "
+"'B'"
#: shared-bindings/displayio/Palette.c
msgid "color must be between 0x000000 and 0xffffff"
@@ -2088,15 +2197,15 @@ msgstr "cor deve ser um int"
#: py/objcomplex.c
msgid "complex division by zero"
-msgstr ""
+msgstr "divisão complexa por zero"
#: py/objfloat.c py/parsenum.c
msgid "complex values not supported"
-msgstr ""
+msgstr "os valores complexos não compatíveis"
#: extmod/moduzlib.c
msgid "compression header"
-msgstr ""
+msgstr "compressão do cabeçalho"
#: py/parse.c
msgid "constant must be an integer"
@@ -2104,56 +2213,63 @@ msgstr "constante deve ser um inteiro"
#: py/emitnative.c
msgid "conversion to object"
-msgstr ""
+msgstr "conversão para o objeto"
#: extmod/ulab/code/filter.c
msgid "convolve arguments must be linear arrays"
-msgstr ""
+msgstr "os argumentos convolutivos devem ser matrizes lineares"
#: extmod/ulab/code/filter.c
msgid "convolve arguments must be ndarrays"
-msgstr ""
+msgstr "os argumentos convolutivos devem ser ndarrays"
#: extmod/ulab/code/filter.c
msgid "convolve arguments must not be empty"
-msgstr ""
+msgstr "os argumentos convolutivos não devem estar vazios"
#: extmod/ulab/code/ndarray.c
msgid "could not broadast input array from shape"
-msgstr ""
+msgstr "não foi possível transmitir a matriz da entrada a partir da forma"
#: extmod/ulab/code/poly.c
msgid "could not invert Vandermonde matrix"
-msgstr ""
+msgstr "não foi possível inverter a matriz Vandermonde"
+
+#: shared-module/sdcardio/SDCard.c
+msgid "couldn't determine SD card version"
+msgstr "não foi possível determinar a versão do cartão SD"
#: extmod/ulab/code/approx.c
msgid "data must be iterable"
-msgstr ""
+msgstr "os dados devem ser iteráveis"
#: extmod/ulab/code/approx.c
msgid "data must be of equal length"
-msgstr ""
+msgstr "os dados devem ser de igual comprimento"
#: extmod/ulab/code/numerical.c
msgid "ddof must be smaller than length of data set"
-msgstr ""
+msgstr "O ddof deve ser menor que o comprimento do conjunto dos dados"
#: py/parsenum.c
msgid "decimal numbers not supported"
-msgstr ""
+msgstr "os números decimais não são compatíveis"
#: py/compile.c
msgid "default 'except' must be last"
-msgstr ""
+msgstr "a predefinição 'exceto' deve ser o último"
#: shared-bindings/audiobusio/PDMIn.c
msgid ""
"destination buffer must be a bytearray or array of type 'B' for bit_depth = 8"
msgstr ""
+"o buffer do destino deve ser um bytearray ou matriz do tipo 'B' para "
+"bit_depth = 8"
#: shared-bindings/audiobusio/PDMIn.c
msgid "destination buffer must be an array of type 'H' for bit_depth = 16"
msgstr ""
+"o buffer do destino deve ser uma matriz do tipo 'H' para bit_depth = 16"
#: shared-bindings/audiobusio/PDMIn.c
msgid "destination_length must be an int >= 0"
@@ -2161,11 +2277,11 @@ msgstr "destination_length deve ser um int >= 0"
#: py/objdict.c
msgid "dict update sequence has wrong length"
-msgstr ""
+msgstr "sequência da atualização dict tem o comprimento errado"
#: extmod/ulab/code/numerical.c
msgid "diff argument must be an ndarray"
-msgstr ""
+msgstr "O argumento diff deve ser um ndarray"
#: py/modmath.c py/objfloat.c py/objint_longlong.c py/objint_mpz.c py/runtime.c
#: shared-bindings/math/__init__.c
@@ -2178,11 +2294,11 @@ msgstr "vazio"
#: extmod/moduheapq.c extmod/modutimeq.c
msgid "empty heap"
-msgstr "heap vazia"
+msgstr "a área de alocação dinâmica de variáveis (heap) está vazia"
#: py/objstr.c
msgid "empty separator"
-msgstr ""
+msgstr "separador vazio"
#: shared-bindings/random/__init__.c
msgid "empty sequence"
@@ -2190,12 +2306,11 @@ msgstr "seqüência vazia"
#: py/objstr.c
msgid "end of format while looking for conversion specifier"
-msgstr ""
+msgstr "final de formato enquanto procura pelo especificador de conversão"
#: shared-bindings/displayio/Shape.c
-#, fuzzy
msgid "end_x should be an int"
-msgstr "y deve ser um int"
+msgstr "end_x deve ser um int"
#: ports/nrf/common-hal/busio/UART.c
#, c-format
@@ -2204,31 +2319,31 @@ msgstr "erro = 0x%08lX"
#: py/runtime.c
msgid "exceptions must derive from BaseException"
-msgstr ""
+msgstr "as exceções devem derivar a partir do BaseException"
#: py/objstr.c
msgid "expected ':' after format specifier"
-msgstr ""
+msgstr "é esperado ':' após o especificador do formato"
#: py/obj.c
msgid "expected tuple/list"
-msgstr ""
+msgstr "é esperada tupla/lista"
#: py/modthread.c
msgid "expecting a dict for keyword args"
-msgstr ""
+msgstr "esperando um dicionário para os args da palavra-chave"
#: py/compile.c
msgid "expecting an assembler instruction"
-msgstr ""
+msgstr "esperando uma instrução assembler"
#: py/compile.c
msgid "expecting just a value for set"
-msgstr ""
+msgstr "esperando apenas um valor para o conjunto"
#: py/compile.c
msgid "expecting key:value for dict"
-msgstr ""
+msgstr "chave esperada: valor para dict"
#: py/argcheck.c
msgid "extra keyword arguments given"
@@ -2240,28 +2355,28 @@ msgstr "argumentos extra posicionais passados"
#: py/parse.c
msgid "f-string expression part cannot include a '#'"
-msgstr ""
+msgstr "A parte da expressão f-string não pode incluir um '#'"
#: py/parse.c
msgid "f-string expression part cannot include a backslash"
-msgstr ""
+msgstr "A parte da expressão f-string não pode incluir uma barra invertida"
#: py/parse.c
msgid "f-string: empty expression not allowed"
-msgstr ""
+msgstr "f-string: expressão vazia não é permitida"
#: py/parse.c
msgid "f-string: expecting '}'"
-msgstr ""
+msgstr "f-string: esperando '}'"
#: py/parse.c
msgid "f-string: single '}' is not allowed"
-msgstr ""
+msgstr "f-string: um único '}' não é permitido"
#: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3Decoder.c
#: shared-bindings/displayio/OnDiskBitmap.c
msgid "file must be a file opened in byte mode"
-msgstr ""
+msgstr "o arquivo deve ser um arquivo aberto no modo byte"
#: shared-bindings/storage/__init__.c
msgid "filesystem must provide mount method"
@@ -2269,31 +2384,31 @@ msgstr "sistema de arquivos deve fornecer método de montagem"
#: extmod/ulab/code/vectorise.c
msgid "first argument must be a callable"
-msgstr ""
+msgstr "o primeiro argumento deve ser chamável"
#: extmod/ulab/code/approx.c
msgid "first argument must be a function"
-msgstr ""
+msgstr "o primeiro argumento deve ser uma função"
#: extmod/ulab/code/ndarray.c
msgid "first argument must be an iterable"
-msgstr ""
+msgstr "o primeiro argumento deve ser um iterável"
#: extmod/ulab/code/vectorise.c
msgid "first argument must be an ndarray"
-msgstr ""
+msgstr "o primeiro argumento deve ser um ndarray"
#: py/objtype.c
msgid "first argument to super() must be type"
-msgstr ""
+msgstr "o primeiro argumento para super() deve ser um tipo"
#: extmod/ulab/code/ndarray.c
msgid "flattening order must be either 'C', or 'F'"
-msgstr ""
+msgstr "a ordem do nivelamento deve ser 'C' ou 'F'"
#: extmod/ulab/code/numerical.c
msgid "flip argument must be an ndarray"
-msgstr ""
+msgstr "o argumento flip deve ser um ndarray"
#: py/objint.c
msgid "float too big"
@@ -2301,11 +2416,11 @@ msgstr "float muito grande"
#: shared-bindings/_stage/Text.c
msgid "font must be 2048 bytes long"
-msgstr ""
+msgstr "a fonte deve ter 2048 bytes de comprimento"
#: py/objstr.c
msgid "format requires a dict"
-msgstr ""
+msgstr "formato requer um dict"
#: py/objdeque.c
msgid "full"
@@ -2322,15 +2437,15 @@ msgstr "função esperada na maioria dos %d argumentos, obteve %d"
#: py/bc.c py/objnamedtuple.c
msgid "function got multiple values for argument '%q'"
-msgstr ""
+msgstr "A função obteve vários valores para o argumento '%q'"
#: extmod/ulab/code/approx.c
msgid "function has the same sign at the ends of interval"
-msgstr ""
+msgstr "a função tem o mesmo sinal nas extremidades do intervalo"
#: extmod/ulab/code/compare.c
msgid "function is implemented for scalars and ndarrays only"
-msgstr ""
+msgstr "A função foi implementada apenas para escalares e ndarrays"
#: py/argcheck.c
#, c-format
@@ -2339,16 +2454,16 @@ msgstr "função ausente %d requer argumentos posicionais"
#: py/bc.c
msgid "function missing keyword-only argument"
-msgstr ""
+msgstr "falta apenas a palavra chave do argumento da função"
#: py/bc.c
msgid "function missing required keyword argument '%q'"
-msgstr ""
+msgstr "falta apenas a palavra chave do argumento '%q' da função"
#: py/bc.c
#, c-format
msgid "function missing required positional argument #%d"
-msgstr ""
+msgstr "falta o argumento #%d da posição necessária da função"
#: py/argcheck.c py/bc.c py/objnamedtuple.c
#, c-format
@@ -2361,27 +2476,27 @@ msgstr "função leva exatamente 9 argumentos"
#: py/objgenerator.c
msgid "generator already executing"
-msgstr ""
+msgstr "o gerador já está em execução"
#: py/objgenerator.c
msgid "generator ignored GeneratorExit"
-msgstr ""
+msgstr "ignorando o gerador GeneratorExit"
#: shared-bindings/_stage/Layer.c
msgid "graphic must be 2048 bytes long"
-msgstr ""
+msgstr "o gráfico deve ter 2048 bytes de comprimento"
#: extmod/moduheapq.c
msgid "heap must be a list"
-msgstr "heap deve ser uma lista"
+msgstr "a área de alocação dinâmica de variáveis (heap) deve ser uma lista"
#: py/compile.c
msgid "identifier redefined as global"
-msgstr ""
+msgstr "o identificador foi redefinido como global"
#: py/compile.c
msgid "identifier redefined as nonlocal"
-msgstr ""
+msgstr "o identificador foi redefinido como não-local"
#: py/objstr.c
msgid "incomplete format"
@@ -2389,7 +2504,7 @@ msgstr "formato incompleto"
#: py/objstr.c
msgid "incomplete format key"
-msgstr ""
+msgstr "a chave do formato está incompleto"
#: extmod/modubinascii.c
msgid "incorrect padding"
@@ -2397,7 +2512,7 @@ msgstr "preenchimento incorreto"
#: extmod/ulab/code/ndarray.c
msgid "index is out of bounds"
-msgstr ""
+msgstr "o índice está fora dos limites"
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c
#: ports/cxd56/common-hal/pulseio/PulseIn.c
@@ -2408,55 +2523,55 @@ msgstr "Índice fora do intervalo"
#: py/obj.c
msgid "indices must be integers"
-msgstr ""
+msgstr "os índices devem ser inteiros"
#: extmod/ulab/code/ndarray.c
msgid "indices must be integers, slices, or Boolean lists"
-msgstr ""
+msgstr "os índices devem ser números inteiros, fatias ou listas booleanas"
#: extmod/ulab/code/approx.c
msgid "initial values must be iterable"
-msgstr ""
+msgstr "os valores iniciais devem ser iteráveis"
#: py/compile.c
msgid "inline assembler must be a function"
-msgstr ""
+msgstr "o assembler em linha deve ser uma função"
#: extmod/ulab/code/create.c
msgid "input argument must be an integer or a 2-tuple"
-msgstr ""
+msgstr "o argumento da entrada deve ser um número inteiro ou uma tupla de 2"
#: extmod/ulab/code/fft.c
msgid "input array length must be power of 2"
-msgstr ""
+msgstr "comprimento da matriz da entrada deve ter potência de 2"
#: extmod/ulab/code/poly.c
msgid "input data must be an iterable"
-msgstr ""
+msgstr "os dados da entrada devem ser iteráveis"
#: extmod/ulab/code/linalg.c
msgid "input matrix is asymmetric"
-msgstr ""
+msgstr "a matriz da entrada é assimétrica"
#: extmod/ulab/code/linalg.c
msgid "input matrix is singular"
-msgstr ""
+msgstr "a matriz da entrada é singular"
#: extmod/ulab/code/linalg.c
msgid "input must be square matrix"
-msgstr ""
+msgstr "a entrada deve ser uma matriz quadrada"
#: extmod/ulab/code/numerical.c
msgid "input must be tuple, list, range, or ndarray"
-msgstr ""
+msgstr "A entrada deve ser tupla, lista, intervalo ou matriz"
#: extmod/ulab/code/poly.c
msgid "input vectors must be of equal length"
-msgstr ""
+msgstr "os vetores da entrada devem ter o mesmo comprimento"
#: py/parsenum.c
msgid "int() arg 2 must be >= 2 and <= 36"
-msgstr ""
+msgstr "int() arg 2 deve ser >= 2 e <= 36"
#: py/objstr.c
msgid "integer required"
@@ -2464,12 +2579,12 @@ msgstr "inteiro requerido"
#: extmod/ulab/code/approx.c
msgid "interp is defined for 1D arrays of equal length"
-msgstr ""
+msgstr "o interp é definido para matrizes 1D de igual comprimento"
#: shared-bindings/_bleio/Adapter.c
#, c-format
msgid "interval must be in range %s-%s"
-msgstr ""
+msgstr "o intervalo deve estar entre %s-%s"
#: lib/netutils/netutils.c
msgid "invalid arguments"
@@ -2489,7 +2604,7 @@ msgstr "formato inválido"
#: py/objstr.c
msgid "invalid format specifier"
-msgstr ""
+msgstr "o especificador do formato é inválido"
#: extmod/modussl_axtls.c
msgid "invalid key"
@@ -2497,7 +2612,7 @@ msgstr "chave inválida"
#: py/compile.c
msgid "invalid micropython decorator"
-msgstr ""
+msgstr "o decorador micropython é inválido"
#: shared-bindings/random/__init__.c
msgid "invalid step"
@@ -2505,159 +2620,164 @@ msgstr "passo inválido"
#: py/compile.c py/parse.c
msgid "invalid syntax"
-msgstr ""
+msgstr "sintaxe inválida"
#: py/parsenum.c
msgid "invalid syntax for integer"
-msgstr ""
+msgstr "sintaxe inválida para o número inteiro"
#: py/parsenum.c
#, c-format
msgid "invalid syntax for integer with base %d"
-msgstr ""
+msgstr "sintaxe inválida para o número inteiro com base %d"
#: py/parsenum.c
msgid "invalid syntax for number"
-msgstr ""
+msgstr "sintaxe inválida para o número"
#: py/objtype.c
msgid "issubclass() arg 1 must be a class"
-msgstr ""
+msgstr "issubclass() arg 1 deve ser uma classe"
#: py/objtype.c
msgid "issubclass() arg 2 must be a class or a tuple of classes"
-msgstr ""
+msgstr "issubclass() arg 2 deve ser uma classe ou uma tupla de classes"
#: extmod/ulab/code/ndarray.c
msgid "iterables are not of the same length"
-msgstr ""
+msgstr "os iteráveis não têm o mesmo comprimento"
#: extmod/ulab/code/linalg.c
msgid "iterations did not converge"
-msgstr ""
+msgstr "as iterações não convergiram"
#: py/objstr.c
msgid "join expects a list of str/bytes objects consistent with self object"
msgstr ""
+"join espera uma lista de objetos str/bytes consistentes com o próprio objeto"
#: py/argcheck.c
msgid "keyword argument(s) not yet implemented - use normal args instead"
msgstr ""
+"o(s) argumento(s) de palavra-chave ainda não foi implementado - em vez "
+"disso, use argumentos normais"
#: py/bc.c
msgid "keywords must be strings"
-msgstr ""
+msgstr "as palavras-chave devem ser uma cadeia de caracteres"
#: py/emitinlinethumb.c py/emitinlinextensa.c
msgid "label '%q' not defined"
-msgstr ""
+msgstr "o rótulo '%q' não foi definido"
#: py/compile.c
msgid "label redefined"
-msgstr ""
+msgstr "o rótulo foi redefinido"
#: py/stream.c
msgid "length argument not allowed for this type"
-msgstr ""
+msgstr "o argumento de comprimento não é permitido para este tipo"
#: shared-bindings/audiomixer/MixerVoice.c
msgid "level must be between 0 and 1"
-msgstr ""
+msgstr "o nível deve estar entre 0 e 1"
#: py/objarray.c
msgid "lhs and rhs should be compatible"
-msgstr ""
+msgstr "o lhs e rhs devem ser compatíveis"
#: py/emitnative.c
msgid "local '%q' has type '%q' but source is '%q'"
-msgstr ""
+msgstr "o local '%q' tem o tipo '%q', porém a origem é '%q'"
#: py/emitnative.c
msgid "local '%q' used before type known"
-msgstr ""
+msgstr "o local '%q' usado antes do tipo conhecido"
#: py/vm.c
msgid "local variable referenced before assignment"
-msgstr ""
+msgstr "a variável local referenciada antes da atribuição"
#: py/objint.c
msgid "long int not supported in this build"
-msgstr ""
+msgstr "o long int não é suportado nesta compilação"
#: py/parse.c
msgid "malformed f-string"
-msgstr ""
+msgstr "f-string malformado"
#: shared-bindings/_stage/Layer.c
msgid "map buffer too small"
-msgstr ""
+msgstr "o mapa do buffer é muito pequeno"
#: py/modmath.c shared-bindings/math/__init__.c
msgid "math domain error"
-msgstr ""
+msgstr "erro de domínio matemático"
#: extmod/ulab/code/linalg.c
msgid "matrix dimensions do not match"
-msgstr ""
+msgstr "as dimensões da matriz não coincidem"
#: extmod/ulab/code/linalg.c
msgid "matrix is not positive definite"
-msgstr ""
+msgstr "a matriz não é definitiva positiva"
#: ports/nrf/common-hal/_bleio/Characteristic.c
#: ports/nrf/common-hal/_bleio/Descriptor.c
#, c-format
msgid "max_length must be 0-%d when fixed_length is %s"
-msgstr ""
+msgstr "o max_length deve ser 0-%d quando Fixed_length for %s"
#: py/runtime.c
msgid "maximum recursion depth exceeded"
-msgstr ""
+msgstr "a recursão máxima da profundidade foi excedida"
#: py/runtime.c
#, c-format
msgid "memory allocation failed, allocating %u bytes"
-msgstr ""
+msgstr "falha na alocação de memória, alocando %u bytes"
#: py/runtime.c
msgid "memory allocation failed, heap is locked"
msgstr ""
+"falha na alocação de memória, a área de alocação dinâmica de variáveis "
+"(heap) está bloqueada"
#: py/builtinimport.c
msgid "module not found"
-msgstr ""
+msgstr "o módulo não foi encontrado"
#: extmod/ulab/code/poly.c
msgid "more degrees of freedom than data points"
-msgstr ""
+msgstr "mais graus de liberdade do que pontos de dados"
#: py/compile.c
msgid "multiple *x in assignment"
-msgstr ""
+msgstr "múltiplo *x na atribuição"
#: py/objtype.c
msgid "multiple bases have instance lay-out conflict"
-msgstr ""
+msgstr "várias bases possuem instâncias de layout com conflitos"
#: py/objtype.c
msgid "multiple inheritance not supported"
-msgstr ""
+msgstr "herança múltipla não suportada"
#: py/emitnative.c
msgid "must raise an object"
-msgstr ""
+msgstr "deve levantar um objeto"
#: py/modbuiltins.c
msgid "must use keyword argument for key function"
-msgstr ""
+msgstr "deve usar o argumento da palavra-chave para a função da chave"
#: extmod/ulab/code/numerical.c
msgid "n must be between 0, and 9"
-msgstr ""
+msgstr "n deve estar entre 0 e 9"
#: py/runtime.c
msgid "name '%q' is not defined"
-msgstr ""
+msgstr "o nome '%q' não está definido"
#: py/runtime.c
msgid "name not defined"
@@ -2665,11 +2785,11 @@ msgstr "nome não definido"
#: py/compile.c
msgid "name reused for argument"
-msgstr ""
+msgstr "o nome foi reutilizado para o argumento"
#: py/emitnative.c
msgid "native yield"
-msgstr ""
+msgstr "rendimento nativo"
#: py/runtime.c
#, c-format
@@ -2678,105 +2798,113 @@ msgstr "precisa de mais de %d valores para desempacotar"
#: py/objint_longlong.c py/objint_mpz.c py/runtime.c
msgid "negative power with no float support"
-msgstr ""
+msgstr "potência negativa sem suporte de flutuação"
#: py/objint_mpz.c py/runtime.c
msgid "negative shift count"
-msgstr ""
+msgstr "contagem de turnos negativos"
+
+#: shared-module/sdcardio/SDCard.c
+msgid "no SD card"
+msgstr "nenhum cartão SD"
#: py/vm.c
msgid "no active exception to reraise"
-msgstr ""
+msgstr "nenhuma exceção ativa para reraise"
#: shared-bindings/socket/__init__.c shared-module/network/__init__.c
msgid "no available NIC"
-msgstr ""
+msgstr "não há uma Placa de Rede disponível"
#: py/compile.c
msgid "no binding for nonlocal found"
-msgstr ""
+msgstr "nenhuma ligação para nonlocal foi encontrada"
#: py/builtinimport.c
msgid "no module named '%q'"
-msgstr ""
+msgstr "nenhum módulo chamado '%q'"
#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/I2CDisplay.c
#: shared-bindings/displayio/ParallelBus.c
msgid "no reset pin available"
-msgstr ""
+msgstr "nenhum pino de redefinição está disponível"
+
+#: shared-module/sdcardio/SDCard.c
+msgid "no response from SD card"
+msgstr "não houve resposta do cartão SD"
#: py/runtime.c
msgid "no such attribute"
-msgstr ""
+msgstr "não há tal atributo"
#: ports/nrf/common-hal/_bleio/Connection.c
msgid "non-UUID found in service_uuids_whitelist"
-msgstr ""
+msgstr "um não UUID foi encontrado na lista service_uuids_whitelist"
#: py/compile.c
msgid "non-default argument follows default argument"
-msgstr ""
+msgstr "o argumento não predefinido segue o argumento predefinido"
#: extmod/modubinascii.c
msgid "non-hex digit found"
-msgstr ""
+msgstr "um dígito não hexadecimal foi encontrado"
#: py/compile.c
msgid "non-keyword arg after */**"
-msgstr ""
+msgstr "um arg sem palavra-chave após */ **"
#: py/compile.c
msgid "non-keyword arg after keyword arg"
-msgstr ""
+msgstr "um arg não-palavra-chave após a palavra-chave arg"
#: shared-bindings/_bleio/UUID.c
msgid "not a 128-bit UUID"
-msgstr ""
+msgstr "não é um UUID com 128 bits"
#: py/objstr.c
msgid "not all arguments converted during string formatting"
-msgstr ""
+msgstr "nem todos os argumentos são convertidos durante a formatação da string"
#: py/objstr.c
msgid "not enough arguments for format string"
-msgstr ""
+msgstr "argumentos insuficientes para o formato da string"
#: extmod/ulab/code/poly.c
msgid "number of arguments must be 2, or 3"
-msgstr ""
+msgstr "a quantidade dos argumentos deve ser 2 ou 3"
#: extmod/ulab/code/create.c
msgid "number of points must be at least 2"
-msgstr ""
+msgstr "a quantidade dos pontos deve ser pelo menos 2"
#: py/obj.c
#, c-format
msgid "object '%s' is not a tuple or list"
-msgstr ""
+msgstr "o objeto '%s' não é uma tupla ou uma lista"
#: py/obj.c
msgid "object does not support item assignment"
-msgstr ""
+msgstr "O objeto não suporta a atribuição dos itens"
#: py/obj.c
msgid "object does not support item deletion"
-msgstr ""
+msgstr "objeto não suporta a exclusão do item"
#: py/obj.c
msgid "object has no len"
-msgstr ""
+msgstr "o objeto não tem len"
#: py/obj.c
msgid "object is not subscriptable"
-msgstr ""
+msgstr "O objeto não é subroteirizável"
#: py/runtime.c
msgid "object not an iterator"
-msgstr ""
+msgstr "o objeto não é um iterador"
#: py/objtype.c py/runtime.c
msgid "object not callable"
-msgstr ""
+msgstr "o objeto não é resgatável"
#: py/sequence.c shared-bindings/displayio/Group.c
msgid "object not in sequence"
@@ -2789,121 +2917,126 @@ msgstr "objeto não iterável"
#: py/obj.c
#, c-format
msgid "object of type '%s' has no len()"
-msgstr ""
+msgstr "O objeto do tipo '%s' não possui len()"
#: py/obj.c
msgid "object with buffer protocol required"
-msgstr ""
+msgstr "é necessário objeto com protocolo do buffer"
#: extmod/modubinascii.c
msgid "odd-length string"
-msgstr ""
+msgstr "sequência com comprimento ímpar"
#: py/objstr.c py/objstrunicode.c
msgid "offset out of bounds"
-msgstr ""
+msgstr "desvio fora dos limites"
#: ports/nrf/common-hal/audiobusio/PDMIn.c
msgid "only bit_depth=16 is supported"
-msgstr ""
+msgstr "apenas bit_depth = 16 é compatível"
#: ports/nrf/common-hal/audiobusio/PDMIn.c
msgid "only sample_rate=16000 is supported"
-msgstr ""
+msgstr "apenas sample_rate = 16000 é compatível"
#: py/objarray.c py/objstr.c py/objstrunicode.c py/objtuple.c
#: shared-bindings/nvm/ByteArray.c
msgid "only slices with step=1 (aka None) are supported"
msgstr ""
+"apenas fatias com a etapa=1 (também conhecida como Nenhuma) são compatíveis"
#: extmod/ulab/code/compare.c extmod/ulab/code/ndarray.c
#: extmod/ulab/code/vectorise.c
msgid "operands could not be broadcast together"
-msgstr ""
+msgstr "os operandos não puderam ser transmitidos juntos"
#: extmod/ulab/code/numerical.c
msgid "operation is not implemented on ndarrays"
-msgstr ""
+msgstr "a operação não foi implementada nos ndarrays"
#: extmod/ulab/code/ndarray.c
msgid "operation is not supported for given type"
-msgstr ""
+msgstr "operação não é compatível com o tipo informado"
#: py/modbuiltins.c
msgid "ord expects a character"
-msgstr ""
+msgstr "o ord espera um caractere"
#: py/modbuiltins.c
#, c-format
msgid "ord() expected a character, but string of length %d found"
msgstr ""
+"o ord() esperava um caractere, porém a sequência do comprimento %d foi "
+"encontrada"
#: py/objint_mpz.c
msgid "overflow converting long int to machine word"
msgstr ""
+"houve um transbordamento durante a conversão int longo para a palavra de "
+"máquina"
#: shared-bindings/_stage/Layer.c shared-bindings/_stage/Text.c
msgid "palette must be 32 bytes long"
-msgstr ""
+msgstr "a paleta deve ter 32 bytes de comprimento"
#: shared-bindings/displayio/Palette.c
msgid "palette_index should be an int"
-msgstr ""
+msgstr "palette_index deve ser um int"
#: py/compile.c
msgid "parameter annotation must be an identifier"
-msgstr ""
+msgstr "a anotação do parâmetro deve ser um identificador"
#: py/emitinlinextensa.c
msgid "parameters must be registers in sequence a2 to a5"
-msgstr ""
+msgstr "os parâmetros devem ser registradores na sequência a2 até a5"
#: py/emitinlinethumb.c
msgid "parameters must be registers in sequence r0 to r3"
-msgstr ""
+msgstr "os parâmetros devem ser registradores na sequência r0 até r3"
#: shared-bindings/displayio/Bitmap.c
msgid "pixel coordinates out of bounds"
-msgstr ""
+msgstr "as coordenadas do pixel estão fora dos limites"
#: shared-bindings/displayio/Bitmap.c
msgid "pixel value requires too many bits"
-msgstr ""
+msgstr "o valor do pixel requer bits demais"
#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c
msgid "pixel_shader must be displayio.Palette or displayio.ColorConverter"
-msgstr ""
+msgstr "o pixel_shader deve ser displayio.Palette ou displayio.ColorConverter"
#: shared-module/vectorio/Polygon.c
msgid "polygon can only be registered in one parent"
-msgstr ""
+msgstr "o polígono só pode ser registrado em um pai"
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c
#: ports/cxd56/common-hal/pulseio/PulseIn.c
#: ports/nrf/common-hal/pulseio/PulseIn.c
#: ports/stm/common-hal/pulseio/PulseIn.c
msgid "pop from an empty PulseIn"
-msgstr ""
+msgstr "pop a partir de um PulseIn vazio"
#: py/objset.c
msgid "pop from an empty set"
-msgstr ""
+msgstr "pop a partir de um conjunto vazio"
#: py/objlist.c
msgid "pop from empty list"
-msgstr ""
+msgstr "pop a partir da lista vazia"
#: py/objdict.c
msgid "popitem(): dictionary is empty"
-msgstr ""
+msgstr "popitem(): o dicionário está vazio"
#: py/objint_mpz.c
msgid "pow() 3rd argument cannot be 0"
-msgstr ""
+msgstr "O terceiro argumento pow() não pode ser 0"
#: py/objint_mpz.c
msgid "pow() with 3 arguments requires integers"
-msgstr ""
+msgstr "o pow() com 3 argumentos requer números inteiros"
#: extmod/modutimeq.c
msgid "queue overflow"
@@ -2911,52 +3044,54 @@ msgstr "estouro de fila"
#: py/parse.c
msgid "raw f-strings are not implemented"
-msgstr ""
+msgstr "o f-strings bruto não estão implementados"
#: extmod/ulab/code/fft.c
msgid "real and imaginary parts must be of equal length"
-msgstr ""
+msgstr "partes reais e imaginárias devem ter o mesmo comprimento"
#: py/builtinimport.c
msgid "relative import"
-msgstr ""
+msgstr "importação relativa"
#: py/obj.c
#, c-format
msgid "requested length %d but object has length %d"
-msgstr ""
+msgstr "o comprimento solicitado %d, porém o objeto tem comprimento %d"
#: py/compile.c
msgid "return annotation must be an identifier"
-msgstr ""
+msgstr "a anotação do retorno deve ser um identificador"
#: py/emitnative.c
msgid "return expected '%q' but got '%q'"
-msgstr ""
+msgstr "o retorno esperado era '%q', porém obteve '% q'"
#: shared-bindings/rgbmatrix/RGBMatrix.c
#, c-format
msgid "rgb_pins[%d] duplicates another pin assignment"
-msgstr ""
+msgstr "rgb_pins[%d] duplica outra atribuição dos pinos"
#: shared-bindings/rgbmatrix/RGBMatrix.c
#, c-format
msgid "rgb_pins[%d] is not on the same port as clock"
-msgstr ""
+msgstr "rgb_pins[%d] não está na mesma porta que o clock"
#: extmod/ulab/code/ndarray.c
msgid "right hand side must be an ndarray, or a scalar"
-msgstr ""
+msgstr "o lado direito deve ser um ndarray ou um escalar"
#: py/objstr.c
msgid "rsplit(None,n)"
-msgstr ""
+msgstr "rsplit(Nenhum,n)"
#: shared-bindings/audiocore/RawSample.c
msgid ""
"sample_source buffer must be a bytearray or array of type 'h', 'H', 'b' or "
"'B'"
msgstr ""
+"O buffer sample_source deve ser um bytearray ou matriz do tipo 'h', 'H', 'b' "
+"ou 'B'"
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
msgid "sampling rate out of range"
@@ -2964,7 +3099,7 @@ msgstr "Taxa de amostragem fora do intervalo"
#: py/modmicropython.c
msgid "schedule stack full"
-msgstr ""
+msgstr "agende a pilha de função completa"
#: lib/utils/pyexec.c py/builtinimport.c
msgid "script compilation not supported"
@@ -2972,52 +3107,67 @@ msgstr "compilação de script não suportada"
#: extmod/ulab/code/ndarray.c
msgid "shape must be a 2-tuple"
-msgstr ""
+msgstr "a forma deve ser uma tupla de 2"
#: py/objstr.c
msgid "sign not allowed in string format specifier"
-msgstr ""
+msgstr "sinal não permitido no especificador do formato da sequência"
#: py/objstr.c
msgid "sign not allowed with integer format specifier 'c'"
-msgstr ""
+msgstr "sinal não permitido com o especificador no formato inteiro 'c'"
#: py/objstr.c
msgid "single '}' encountered in format string"
-msgstr ""
+msgstr "único '}' encontrado na string do formato"
#: extmod/ulab/code/linalg.c
msgid "size is defined for ndarrays only"
-msgstr ""
+msgstr "o tamanho é definido apenas para os ndarrays"
#: shared-bindings/time/__init__.c
msgid "sleep length must be non-negative"
-msgstr ""
+msgstr "a duração do sleep não deve ser negativo"
+
+#: extmod/ulab/code/ndarray.c
+msgid "slice step can't be zero"
+msgstr "a etapa da fatia não pode ser zero"
#: py/objslice.c py/sequence.c
msgid "slice step cannot be zero"
-msgstr ""
+msgstr "a etapa da fatia não pode ser zero"
#: py/objint.c py/sequence.c
msgid "small int overflow"
-msgstr ""
+msgstr "transbordamento int pequeno"
#: main.c
msgid "soft reboot\n"
-msgstr ""
+msgstr "reinicialização soft\n"
#: extmod/ulab/code/numerical.c
msgid "sort argument must be an ndarray"
-msgstr ""
+msgstr "o argumento da classificação deve ser um ndarray"
+
+#: extmod/ulab/code/filter.c
+msgid "sos array must be of shape (n_section, 6)"
+msgstr "o sos da matriz deve estar na forma (n_section, 6)"
+
+#: extmod/ulab/code/filter.c
+msgid "sos[:, 3] should be all ones"
+msgstr "sos[:, 3] deve ser um em todos"
+
+#: extmod/ulab/code/filter.c
+msgid "sosfilt requires iterable arguments"
+msgstr "o sosfilt requer que os argumentos sejam iteráveis"
#: py/objstr.c
msgid "start/end indices"
-msgstr ""
+msgstr "os índices de início/fim"
#: shared-bindings/displayio/Shape.c
-#, fuzzy
msgid "start_x should be an int"
-msgstr "y deve ser um int"
+msgstr "start_x deve ser um int"
#: shared-bindings/random/__init__.c
msgid "step must be non-zero"
@@ -3025,28 +3175,28 @@ msgstr "o passo deve ser diferente de zero"
#: shared-bindings/busio/UART.c
msgid "stop must be 1 or 2"
-msgstr ""
+msgstr "o stop deve ser 1 ou 2"
#: shared-bindings/random/__init__.c
msgid "stop not reachable from start"
-msgstr ""
+msgstr "stop não está acessível a partir do início"
#: py/stream.c
msgid "stream operation not supported"
-msgstr ""
+msgstr "a operação do fluxo não é compatível"
#: py/objstrunicode.c
msgid "string index out of range"
-msgstr ""
+msgstr "o índice da string está fora do intervalo"
#: py/objstrunicode.c
#, c-format
msgid "string indices must be integers, not %s"
-msgstr ""
+msgstr "o índices das string devem ser números inteiros, não %s"
#: py/stream.c
msgid "string not supported; use bytes or bytearray"
-msgstr ""
+msgstr "a string não é compatível; use bytes ou bytearray"
#: extmod/moductypes.c
msgid "struct: cannot index"
@@ -3060,13 +3210,13 @@ msgstr "struct: índice fora do intervalo"
msgid "struct: no fields"
msgstr "struct: sem campos"
-#: py/objstr.c
+#: py/objarray.c py/objstr.c
msgid "substring not found"
-msgstr ""
+msgstr "a substring não foi encontrada"
#: py/compile.c
msgid "super() can't find self"
-msgstr ""
+msgstr "o super() não consegue se encontrar"
#: extmod/modujson.c
msgid "syntax error in JSON"
@@ -3074,7 +3224,7 @@ msgstr "erro de sintaxe no JSON"
#: extmod/moductypes.c
msgid "syntax error in uctypes descriptor"
-msgstr ""
+msgstr "houve um erro de sintaxe no descritor uctypes"
#: shared-bindings/touchio/TouchIn.c
msgid "threshold must be in the range 0-65536"
@@ -3082,20 +3232,27 @@ msgstr "Limite deve estar no alcance de 0-65536"
#: shared-bindings/time/__init__.c
msgid "time.struct_time() takes a 9-sequence"
-msgstr ""
+msgstr "time.struct_time() leva uma sequência com 9"
#: ports/nrf/common-hal/watchdog/WatchDogTimer.c
msgid "timeout duration exceeded the maximum supported value"
-msgstr ""
+msgstr "a duração do tempo limite excedeu o valor máximo suportado"
#: shared-bindings/busio/UART.c
msgid "timeout must be 0.0-100.0 seconds"
-msgstr ""
+msgstr "o tempo limite deve ser entre 0.0 a 100.0 segundos"
#: shared-bindings/_bleio/CharacteristicBuffer.c
-#, fuzzy
msgid "timeout must be >= 0.0"
-msgstr "bits devem ser 8"
+msgstr "o tempo limite deve ser >= 0,0"
+
+#: shared-module/sdcardio/SDCard.c
+msgid "timeout waiting for v1 card"
+msgstr "o tempo limite na espera pelo cartão v1"
+
+#: shared-module/sdcardio/SDCard.c
+msgid "timeout waiting for v2 card"
+msgstr "o tempo limite na espera pelo cartão v2"
#: shared-bindings/time/__init__.c
msgid "timestamp out of range for platform time_t"
@@ -3107,24 +3264,24 @@ msgstr "Muitos argumentos fornecidos com o formato dado"
#: extmod/ulab/code/ndarray.c
msgid "too many indices"
-msgstr ""
+msgstr "índices demais"
#: py/runtime.c
#, c-format
msgid "too many values to unpack (expected %d)"
-msgstr ""
+msgstr "valores demais para descompactar (esperado %d)"
#: extmod/ulab/code/linalg.c py/objstr.c
msgid "tuple index out of range"
-msgstr ""
+msgstr "o índice da tupla está fora do intervalo"
#: py/obj.c
msgid "tuple/list has wrong length"
-msgstr ""
+msgstr "a tupla/lista está com tamanho incorreto"
#: shared-bindings/_pixelbuf/PixelBuf.c
msgid "tuple/list required on RHS"
-msgstr ""
+msgstr "a tupla/lista necessária no RHS"
#: ports/atmel-samd/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c
#: shared-bindings/busio/UART.c
@@ -3133,69 +3290,69 @@ msgstr "TX e RX não podem ser ambos"
#: py/objtype.c
msgid "type '%q' is not an acceptable base type"
-msgstr ""
+msgstr "o tipo '%q' não é um tipo base aceitável"
#: py/objtype.c
msgid "type is not an acceptable base type"
-msgstr ""
+msgstr "tipo não é um tipo base aceitável"
#: py/runtime.c
msgid "type object '%q' has no attribute '%q'"
-msgstr ""
+msgstr "o objeto tipo '%q' não possuí atributo '%q'"
#: py/objtype.c
msgid "type takes 1 or 3 arguments"
-msgstr ""
+msgstr "o tipo usa 1 ou 3 argumentos"
#: py/objint_longlong.c
msgid "ulonglong too large"
-msgstr ""
+msgstr "ulonglong é muito grande"
#: py/emitnative.c
msgid "unary op %q not implemented"
-msgstr ""
+msgstr "op %q unário não foi implementado"
#: py/parse.c
msgid "unexpected indent"
-msgstr ""
+msgstr "recuo inesperado"
#: py/bc.c
msgid "unexpected keyword argument"
-msgstr ""
+msgstr "argumento inesperado da palavra-chave"
#: py/bc.c py/objnamedtuple.c
msgid "unexpected keyword argument '%q'"
-msgstr ""
+msgstr "argumento inesperado da palavra-chave '%q'"
#: py/lexer.c
msgid "unicode name escapes"
-msgstr ""
+msgstr "escapar o nome unicode"
#: py/parse.c
msgid "unindent does not match any outer indentation level"
-msgstr ""
+msgstr "o unindent não coincide com nenhum nível de recuo externo"
#: py/objstr.c
#, c-format
msgid "unknown conversion specifier %c"
-msgstr ""
+msgstr "especificador de conversão desconhecido %c"
#: py/objstr.c
#, c-format
msgid "unknown format code '%c' for object of type '%s'"
-msgstr ""
+msgstr "código de formato desconhecido '%c' para o objeto do tipo '%s'"
#: py/compile.c
msgid "unknown type"
-msgstr ""
+msgstr "tipo desconhecido"
#: py/emitnative.c
msgid "unknown type '%q'"
-msgstr ""
+msgstr "tipo desconhecido '%q'"
#: py/objstr.c
msgid "unmatched '{' in format"
-msgstr ""
+msgstr "um '{' sem par no formato"
#: py/objtype.c py/runtime.c
msgid "unreadable attribute"
@@ -3204,83 +3361,83 @@ msgstr "atributo ilegível"
#: shared-bindings/displayio/TileGrid.c shared-bindings/vectorio/VectorShape.c
#: shared-module/vectorio/Polygon.c
msgid "unsupported %q type"
-msgstr ""
+msgstr "tipo %q não suportado"
#: py/emitinlinethumb.c
#, c-format
msgid "unsupported Thumb instruction '%s' with %d arguments"
-msgstr ""
+msgstr "instrução Thumb '%s' não compatível com argumentos %d"
#: py/emitinlinextensa.c
#, c-format
msgid "unsupported Xtensa instruction '%s' with %d arguments"
-msgstr ""
+msgstr "instrução Xtensa '%s' não compatível com argumentos %d"
#: py/objstr.c
#, c-format
msgid "unsupported format character '%c' (0x%x) at index %d"
-msgstr ""
+msgstr "o caractere do formato não é compatível '%c' (0x%x) no índice %d"
#: py/runtime.c
msgid "unsupported type for %q: '%s'"
-msgstr ""
+msgstr "tipo não compatível para %q: '%s'"
#: py/runtime.c
msgid "unsupported type for operator"
-msgstr ""
+msgstr "tipo não compatível para o operador"
#: py/runtime.c
msgid "unsupported types for %q: '%s', '%s'"
-msgstr ""
+msgstr "tipos não compatíveis para %q: '%s', '%s'"
#: py/objint.c
#, c-format
msgid "value must fit in %d byte(s)"
-msgstr ""
+msgstr "o valor deve caber em %d byte(s)"
#: shared-bindings/displayio/Bitmap.c
msgid "value_count must be > 0"
-msgstr ""
+msgstr "o value_count deve ser > 0"
#: shared-bindings/watchdog/WatchDogTimer.c
msgid "watchdog timeout must be greater than 0"
-msgstr ""
+msgstr "o tempo limite do watchdog deve ser maior que 0"
#: shared-bindings/_bleio/Adapter.c
msgid "window must be <= interval"
-msgstr ""
+msgstr "a janela deve ser <= intervalo"
#: extmod/ulab/code/linalg.c
msgid "wrong argument type"
-msgstr ""
+msgstr "tipo do argumento errado"
#: extmod/ulab/code/ndarray.c
msgid "wrong index type"
-msgstr ""
+msgstr "tipo do índice errado"
#: extmod/ulab/code/vectorise.c
msgid "wrong input type"
-msgstr ""
+msgstr "tipo da entrada incorreta"
#: py/objstr.c
msgid "wrong number of arguments"
-msgstr ""
+msgstr "quantidade errada dos argumentos"
#: py/runtime.c
msgid "wrong number of values to unpack"
-msgstr ""
+msgstr "quantidade incorreta dos valores para descompressão"
#: extmod/ulab/code/ndarray.c
msgid "wrong operand type"
-msgstr ""
+msgstr "tipo do operando errado"
#: extmod/ulab/code/vectorise.c
msgid "wrong output type"
-msgstr ""
+msgstr "tipo da saída incorreta"
#: shared-module/displayio/Shape.c
msgid "x value out of bounds"
-msgstr ""
+msgstr "o valor x está fora dos limites"
#: shared-bindings/displayio/Shape.c
msgid "y should be an int"
@@ -3288,12 +3445,24 @@ msgstr "y deve ser um int"
#: shared-module/displayio/Shape.c
msgid "y value out of bounds"
-msgstr ""
+msgstr "o valor y está fora dos limites"
#: py/objrange.c
msgid "zero step"
msgstr "passo zero"
+#: extmod/ulab/code/filter.c
+msgid "zi must be an ndarray"
+msgstr "zi deve ser um ndarray"
+
+#: extmod/ulab/code/filter.c
+msgid "zi must be of float type"
+msgstr "zi deve ser de um tipo float"
+
+#: extmod/ulab/code/filter.c
+msgid "zi must be of shape (n_section, 2)"
+msgstr "zi deve estar na forma (n_section, 2)"
+
#~ msgid "AP required"
#~ msgstr "AP requerido"
diff --git a/locale/sv.po b/locale/sv.po
index df2431c4e..075db8ab0 100644
--- a/locale/sv.po
+++ b/locale/sv.po
@@ -1,14 +1,12 @@
-# SOME DESCRIPTIVE TITLE.
-# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
-# This file is distributed under the same license as the PACKAGE package.
-# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
#
+# SPDX-License-Identifier: MIT
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2020-06-25 11:44-0500\n"
-"PO-Revision-Date: 2020-06-03 18:59+0000\n"
+"POT-Creation-Date: 2020-07-17 18:03-0700\n"
+"PO-Revision-Date: 2020-07-13 17:39+0000\n"
"Last-Translator: Jonny Bergdahl <jonny@bergdahl.it>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: sv\n"
@@ -16,7 +14,7 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
-"X-Generator: Weblate 4.1-dev\n"
+"X-Generator: Weblate 4.2-dev\n"
#: main.c
msgid ""
@@ -66,6 +64,10 @@ msgstr "%%c kräver int eller char"
msgid "%d address pins and %d rgb pins indicate a height of %d, not %d"
msgstr "%d adresspinnar och %d RGB-pinnar indikerar en höjd av %d, inte %d"
+#: ports/atmel-samd/common-hal/sdioio/SDCard.c
+msgid "%q failure: %d"
+msgstr "%q-fel: %d"
+
#: shared-bindings/microcontroller/Pin.c
msgid "%q in use"
msgstr "%q används redan"
@@ -82,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"
@@ -93,6 +100,10 @@ msgstr "%q måste vara >= 1"
msgid "%q must be a tuple of length 2"
msgstr "%q måste vara en tuple av längd 2"
+#: ports/atmel-samd/common-hal/sdioio/SDCard.c
+msgid "%q pin invalid"
+msgstr "Pinne %q ogiltig"
+
#: shared-bindings/fontio/BuiltinFont.c
msgid "%q should be an int"
msgstr "%q ska vara en int"
@@ -105,6 +116,10 @@ msgstr "%q() kräver %d positionsargument men %d gavs"
msgid "'%q' argument required"
msgstr "'%q' argument krävs"
+#: py/objarray.c
+msgid "'%q' object is not bytes-like"
+msgstr ""
+
#: py/emitinlinethumb.c py/emitinlinextensa.c
#, c-format
msgid "'%s' expects a label"
@@ -315,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"
@@ -346,10 +366,15 @@ msgstr "Matrisen måste innehålla halfwords (typ \"H\")"
msgid "Array values should be single bytes."
msgstr "Matrisvärden ska bestå av enstaka bytes."
-#: shared-bindings/rgbmatrix/RGBMatrix.c
+#: shared-bindings/microcontroller/Pin.c
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."
@@ -427,6 +452,11 @@ msgstr "Bufferten är för liten"
msgid "Buffer length %d too big. It must be less than %d"
msgstr "Buffertlängd %d för stor. Den måste vara mindre än %d"
+#: ports/atmel-samd/common-hal/sdioio/SDCard.c
+#: ports/cxd56/common-hal/sdioio/SDCard.c shared-module/sdcardio/SDCard.c
+msgid "Buffer length must be a multiple of 512"
+msgstr "Buffertlängd måste vara en multipel av 512"
+
#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c
msgid "Buffer must be at least length 1"
msgstr "Bufferten måste ha minst längd 1"
@@ -466,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"
@@ -591,7 +623,11 @@ msgstr "Korrupt rå kod"
#: ports/cxd56/common-hal/gnss/GNSS.c
msgid "Could not initialize GNSS"
-msgstr ""
+msgstr "Kan inte initiera GNSS"
+
+#: ports/cxd56/common-hal/sdioio/SDCard.c
+msgid "Could not initialize SDCard"
+msgstr "Kan inte initiera SD-kort"
#: ports/atmel-samd/common-hal/busio/UART.c ports/cxd56/common-hal/busio/UART.c
msgid "Could not initialize UART"
@@ -714,7 +750,8 @@ msgstr "EXTINT-kanalen används redan"
msgid "Error in regex"
msgstr "Fel i regex"
-#: shared-bindings/aesio/aes.c shared-bindings/microcontroller/Pin.c
+#: shared-bindings/aesio/aes.c shared-bindings/busio/SPI.c
+#: shared-bindings/microcontroller/Pin.c
#: shared-bindings/neopixel_write/__init__.c shared-bindings/pulseio/PulseOut.c
#: shared-bindings/terminalio/Terminal.c
msgid "Expected a %q"
@@ -876,6 +913,10 @@ msgstr "Internt define-fel"
msgid "Internal error #%d"
msgstr "Internt fel #%d"
+#: shared-bindings/sdioio/SDCard.c
+msgid "Invalid %q"
+msgstr "Ogiltig %q"
+
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
msgid "Invalid %q pin"
@@ -983,7 +1024,8 @@ msgstr "Ogiltig pinne för höger kanal"
#: ports/atmel-samd/common-hal/busio/UART.c
#: ports/atmel-samd/common-hal/i2cperipheral/I2CPeripheral.c
#: ports/cxd56/common-hal/busio/I2C.c ports/cxd56/common-hal/busio/SPI.c
-#: ports/cxd56/common-hal/busio/UART.c ports/mimxrt10xx/common-hal/busio/I2C.c
+#: ports/cxd56/common-hal/busio/UART.c ports/cxd56/common-hal/sdioio/SDCard.c
+#: ports/mimxrt10xx/common-hal/busio/I2C.c
#: ports/mimxrt10xx/common-hal/busio/SPI.c
#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/I2C.c
msgid "Invalid pins"
@@ -1088,6 +1130,10 @@ msgstr "Måste vara en %q-subklass."
msgid "Must provide MISO or MOSI pin"
msgstr "Måste ange MISO- eller MOSI-pinne"
+#: ports/stm/common-hal/busio/SPI.c
+msgid "Must provide SCK pin"
+msgstr "Måste ange SCK-pinne"
+
#: shared-bindings/rgbmatrix/RGBMatrix.c
#, c-format
msgid "Must use a multiple of 6 rgb pins, not %d"
@@ -1352,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"
@@ -1388,6 +1435,10 @@ msgstr "Kör i säkert läge! Autoladdning är avstängd.\n"
msgid "Running in safe mode! Not running saved code.\n"
msgstr "Kör i säkert läge! Sparad kod körs inte.\n"
+#: shared-module/sdcardio/SDCard.c
+msgid "SD card CSD format not supported"
+msgstr "SD-kort CSD-format stöds inte"
+
#: ports/atmel-samd/common-hal/busio/I2C.c
#: ports/mimxrt10xx/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c
msgid "SDA or SCL needs a pull up"
@@ -1432,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"
@@ -1458,7 +1511,7 @@ msgstr "Ange minst en UART-pinne"
#: shared-bindings/gnss/GNSS.c
msgid "System entry must be gnss.SatelliteSystem"
-msgstr ""
+msgstr "Systeminträdet måste vara gnss. SatellitSystem"
#: ports/stm/common-hal/microcontroller/Processor.c
msgid "Temperature read timed out"
@@ -2025,6 +2078,10 @@ msgstr "kan inte 'pend throw' för nystartad generator"
msgid "can't send non-None value to a just-started generator"
msgstr "kan inte skicka icke-None värde till nystartad generator"
+#: shared-module/sdcardio/SDCard.c
+msgid "can't set 512 block size"
+msgstr "kan inte sätta blockstorlek 512"
+
#: py/objnamedtuple.c
msgid "can't set attribute"
msgstr "kan inte att ange attribut"
@@ -2153,6 +2210,10 @@ msgstr "Kan inte sända indatamatris från form"
msgid "could not invert Vandermonde matrix"
msgstr "kan inte invertera Vandermonde-matris"
+#: shared-module/sdcardio/SDCard.c
+msgid "couldn't determine SD card version"
+msgstr "kan inte avgöra SD-kortversion"
+
#: extmod/ulab/code/approx.c
msgid "data must be iterable"
msgstr "data måste vara itererbar"
@@ -2716,6 +2777,10 @@ msgstr "negativ exponent utan stöd för flyttal"
msgid "negative shift count"
msgstr "negativt skiftantal"
+#: shared-module/sdcardio/SDCard.c
+msgid "no SD card"
+msgstr "inget SD-kort"
+
#: py/vm.c
msgid "no active exception to reraise"
msgstr "ingen aktiv exception för reraise"
@@ -2737,6 +2802,10 @@ msgstr "ingen modul med namnet '%q'"
msgid "no reset pin available"
msgstr "ingen reset-pinne tillgänglig"
+#: shared-module/sdcardio/SDCard.c
+msgid "no response from SD card"
+msgstr "inget svar från SD-kort"
+
#: py/runtime.c
msgid "no such attribute"
msgstr "inget sådant attribut"
@@ -3029,13 +3098,17 @@ msgstr "storlek är enbart definierad ndarrays"
msgid "sleep length must be non-negative"
msgstr "värdet för sleep måste vara positivt"
+#: extmod/ulab/code/ndarray.c
+msgid "slice step can't be zero"
+msgstr "segmentsteg kan inte vara noll"
+
#: py/objslice.c py/sequence.c
msgid "slice step cannot be zero"
-msgstr "segmentsteg får inte vara noll"
+msgstr "segmentsteg kan inte vara noll"
#: py/objint.c py/sequence.c
msgid "small int overflow"
-msgstr "värdet för konvertering till small int överskreds"
+msgstr "värdet för small int överskreds"
#: main.c
msgid "soft reboot\n"
@@ -3045,6 +3118,18 @@ msgstr "mjuk omstart\n"
msgid "sort argument must be an ndarray"
msgstr "argumentet sort måste vara en ndarray"
+#: extmod/ulab/code/filter.c
+msgid "sos array must be of shape (n_section, 6)"
+msgstr "sos array måste ha form (n_section, 6)"
+
+#: extmod/ulab/code/filter.c
+msgid "sos[:, 3] should be all ones"
+msgstr "sos[:, 3] måste vara ettor"
+
+#: extmod/ulab/code/filter.c
+msgid "sosfilt requires iterable arguments"
+msgstr "sosfilt kräver iterable argument"
+
#: py/objstr.c
msgid "start/end indices"
msgstr "start-/slutindex"
@@ -3094,7 +3179,7 @@ msgstr "struct: index utanför intervallet"
msgid "struct: no fields"
msgstr "struct: inga fält"
-#: py/objstr.c
+#: py/objarray.c py/objstr.c
msgid "substring not found"
msgstr "det gick inte att hitta delsträng"
@@ -3130,6 +3215,14 @@ msgstr "timeout måste vara 0.0-100.0 sekunder"
msgid "timeout must be >= 0.0"
msgstr "timeout måste vara >= 0.0"
+#: shared-module/sdcardio/SDCard.c
+msgid "timeout waiting for v1 card"
+msgstr "timeout för v1-kort"
+
+#: shared-module/sdcardio/SDCard.c
+msgid "timeout waiting for v2 card"
+msgstr "timeout för v2-kort"
+
#: shared-bindings/time/__init__.c
msgid "timestamp out of range for platform time_t"
msgstr "timestamp utom räckvidd för plattformens \"time_t\""
@@ -3327,6 +3420,18 @@ msgstr "y-värde utanför intervall"
msgid "zero step"
msgstr "noll steg"
+#: extmod/ulab/code/filter.c
+msgid "zi must be an ndarray"
+msgstr "zi måste vara en ndarray"
+
+#: extmod/ulab/code/filter.c
+msgid "zi must be of float type"
+msgstr "zi måste vara av typ float"
+
+#: extmod/ulab/code/filter.c
+msgid "zi must be of shape (n_section, 2)"
+msgstr "zi måste vara i formen (n_section, 2)"
+
#~ msgid "I2C operation not supported"
#~ msgstr "I2C-åtgärd stöds inte"
diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po
index 4f85c5fa8..a820c142c 100644
--- a/locale/zh_Latn_pinyin.po
+++ b/locale/zh_Latn_pinyin.po
@@ -1,13 +1,12 @@
-# Adafruit CircuitPython Chinese Hanyu Pinyin Translation
-# Copyright (C) 2019
-# This file is distributed under the same license as the CircuitPython package.
-# @hexthat#2155, 2019.
+# SPDX-FileCopyrightText: 2019 @hexthat#2155
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
#
+# SPDX-License-Identifier: MIT
msgid ""
msgstr ""
"Project-Id-Version: circuitpython-cn\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2020-06-25 11:44-0500\n"
+"POT-Creation-Date: 2020-07-17 18:03-0700\n"
"PO-Revision-Date: 2019-04-13 10:10-0700\n"
"Last-Translator: hexthat\n"
"Language-Team: Chinese Hanyu Pinyin\n"
@@ -65,6 +64,10 @@ msgstr "%%c xūyào zhěngshù huò char"
msgid "%d address pins and %d rgb pins indicate a height of %d, not %d"
msgstr ""
+#: ports/atmel-samd/common-hal/sdioio/SDCard.c
+msgid "%q failure: %d"
+msgstr ""
+
#: shared-bindings/microcontroller/Pin.c
msgid "%q in use"
msgstr "%q zhèngzài shǐyòng"
@@ -81,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"
@@ -92,6 +100,10 @@ msgstr "%q bìxū dàyú huò děngyú 1"
msgid "%q must be a tuple of length 2"
msgstr ""
+#: ports/atmel-samd/common-hal/sdioio/SDCard.c
+msgid "%q pin invalid"
+msgstr ""
+
#: shared-bindings/fontio/BuiltinFont.c
msgid "%q should be an int"
msgstr "%q yīnggāi shì yīgè int"
@@ -104,6 +116,10 @@ msgstr "%q() cǎiyòng %d wèizhì cānshù, dàn gěi chū %d"
msgid "'%q' argument required"
msgstr "xūyào '%q' cānshù"
+#: py/objarray.c
+msgid "'%q' object is not bytes-like"
+msgstr ""
+
#: py/emitinlinethumb.c py/emitinlinextensa.c
#, c-format
msgid "'%s' expects a label"
@@ -314,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"
@@ -345,10 +366,15 @@ msgstr "Shùzǔ bìxū bāohán bàn zìshù (type 'H')"
msgid "Array values should be single bytes."
msgstr "Shùzǔ zhí yīnggāi shì dāngè zì jié."
-#: shared-bindings/rgbmatrix/RGBMatrix.c
+#: shared-bindings/microcontroller/Pin.c
msgid "At most %d %q may be specified (not %d)"
msgstr ""
+#: shared-module/memorymonitor/AllocationAlarm.c
+#, c-format
+msgid "Attempt to allocate %d blocks"
+msgstr ""
+
#: 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ī."
@@ -426,6 +452,11 @@ msgstr "Huǎnchōng qū tài xiǎo"
msgid "Buffer length %d too big. It must be less than %d"
msgstr "Huǎnchōng qū chángdù%d tài dà. Tā bìxū xiǎoyú%d"
+#: ports/atmel-samd/common-hal/sdioio/SDCard.c
+#: ports/cxd56/common-hal/sdioio/SDCard.c shared-module/sdcardio/SDCard.c
+msgid "Buffer length must be a multiple of 512"
+msgstr ""
+
#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c
msgid "Buffer must be at least length 1"
msgstr "Huǎnchōng qū bìxū zhìshǎo chángdù 1"
@@ -465,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í"
@@ -588,6 +621,10 @@ msgstr "Sǔnhuài de yuánshǐ dàimǎ"
msgid "Could not initialize GNSS"
msgstr ""
+#: ports/cxd56/common-hal/sdioio/SDCard.c
+msgid "Could not initialize SDCard"
+msgstr ""
+
#: ports/atmel-samd/common-hal/busio/UART.c ports/cxd56/common-hal/busio/UART.c
msgid "Could not initialize UART"
msgstr "Wúfǎ chūshǐhuà UART"
@@ -709,7 +746,8 @@ msgstr "EXTINT píndào yǐjīng shǐyòng"
msgid "Error in regex"
msgstr "Zhèngzé biǎodá shì cuòwù"
-#: shared-bindings/aesio/aes.c shared-bindings/microcontroller/Pin.c
+#: shared-bindings/aesio/aes.c shared-bindings/busio/SPI.c
+#: shared-bindings/microcontroller/Pin.c
#: shared-bindings/neopixel_write/__init__.c shared-bindings/pulseio/PulseOut.c
#: shared-bindings/terminalio/Terminal.c
msgid "Expected a %q"
@@ -871,6 +909,10 @@ msgstr "Nèibù dìngyì cuòwù"
msgid "Internal error #%d"
msgstr ""
+#: shared-bindings/sdioio/SDCard.c
+msgid "Invalid %q"
+msgstr ""
+
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
msgid "Invalid %q pin"
@@ -978,7 +1020,8 @@ msgstr "Yòuxián tōngdào yǐn jiǎo wúxiào"
#: ports/atmel-samd/common-hal/busio/UART.c
#: ports/atmel-samd/common-hal/i2cperipheral/I2CPeripheral.c
#: ports/cxd56/common-hal/busio/I2C.c ports/cxd56/common-hal/busio/SPI.c
-#: ports/cxd56/common-hal/busio/UART.c ports/mimxrt10xx/common-hal/busio/I2C.c
+#: ports/cxd56/common-hal/busio/UART.c ports/cxd56/common-hal/sdioio/SDCard.c
+#: ports/mimxrt10xx/common-hal/busio/I2C.c
#: ports/mimxrt10xx/common-hal/busio/SPI.c
#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/I2C.c
msgid "Invalid pins"
@@ -1082,6 +1125,10 @@ msgstr "Bìxū shì %q zi lèi."
msgid "Must provide MISO or MOSI pin"
msgstr "Bìxū tígōng MISO huò MOSI yǐn jiǎo"
+#: ports/stm/common-hal/busio/SPI.c
+msgid "Must provide SCK pin"
+msgstr ""
+
#: shared-bindings/rgbmatrix/RGBMatrix.c
#, c-format
msgid "Must use a multiple of 6 rgb pins, not %d"
@@ -1341,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ú"
@@ -1377,6 +1425,10 @@ msgstr "Zài ānquán móshì xià yùnxíng! Zìdòng chóngxīn jiāzài yǐ g
msgid "Running in safe mode! Not running saved code.\n"
msgstr "Zài ānquán móshì xià yùnxíng! Bù yùnxíng yǐ bǎocún de dàimǎ.\n"
+#: shared-module/sdcardio/SDCard.c
+msgid "SD card CSD format not supported"
+msgstr ""
+
#: ports/atmel-samd/common-hal/busio/I2C.c
#: ports/mimxrt10xx/common-hal/busio/I2C.c ports/nrf/common-hal/busio/I2C.c
msgid "SDA or SCL needs a pull up"
@@ -1421,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í"
@@ -2012,6 +2066,10 @@ msgstr "bùnéng bǎ tā rēng dào gāng qǐdòng de fā diànjī shàng"
msgid "can't send non-None value to a just-started generator"
msgstr "wúfǎ xiàng gānggāng qǐdòng de shēngchéng qì fāsòng fēi zhí"
+#: shared-module/sdcardio/SDCard.c
+msgid "can't set 512 block size"
+msgstr ""
+
#: py/objnamedtuple.c
msgid "can't set attribute"
msgstr "wúfǎ shèzhì shǔxìng"
@@ -2141,6 +2199,10 @@ msgstr ""
msgid "could not invert Vandermonde matrix"
msgstr ""
+#: shared-module/sdcardio/SDCard.c
+msgid "couldn't determine SD card version"
+msgstr ""
+
#: extmod/ulab/code/approx.c
msgid "data must be iterable"
msgstr ""
@@ -2701,6 +2763,10 @@ msgstr "méiyǒu fú diǎn zhīchí de xiāojí gōnglǜ"
msgid "negative shift count"
msgstr "fù zhuǎnyí jìshù"
+#: shared-module/sdcardio/SDCard.c
+msgid "no SD card"
+msgstr ""
+
#: py/vm.c
msgid "no active exception to reraise"
msgstr "méiyǒu jīhuó de yìcháng lái chóngxīn píngjià"
@@ -2722,6 +2788,10 @@ msgstr "méiyǒu mókuài '%q'"
msgid "no reset pin available"
msgstr "Méiyǒu kěyòng de fùwèi yǐn jiǎo"
+#: shared-module/sdcardio/SDCard.c
+msgid "no response from SD card"
+msgstr ""
+
#: py/runtime.c
msgid "no such attribute"
msgstr "méiyǒu cǐ shǔxìng"
@@ -3013,6 +3083,10 @@ msgstr ""
msgid "sleep length must be non-negative"
msgstr "shuìmián chángdù bìxū shìfēi fùshù"
+#: extmod/ulab/code/ndarray.c
+msgid "slice step can't be zero"
+msgstr ""
+
#: py/objslice.c py/sequence.c
msgid "slice step cannot be zero"
msgstr "qiēpiàn bù bùnéng wéi líng"
@@ -3029,6 +3103,18 @@ msgstr "ruǎn chóngqǐ\n"
msgid "sort argument must be an ndarray"
msgstr ""
+#: extmod/ulab/code/filter.c
+msgid "sos array must be of shape (n_section, 6)"
+msgstr ""
+
+#: extmod/ulab/code/filter.c
+msgid "sos[:, 3] should be all ones"
+msgstr ""
+
+#: extmod/ulab/code/filter.c
+msgid "sosfilt requires iterable arguments"
+msgstr ""
+
#: py/objstr.c
msgid "start/end indices"
msgstr "kāishǐ/jiéshù zhǐshù"
@@ -3078,7 +3164,7 @@ msgstr "jiégòu: suǒyǐn chāochū fànwéi"
msgid "struct: no fields"
msgstr "jiégòu: méiyǒu zìduàn"
-#: py/objstr.c
+#: py/objarray.c py/objstr.c
msgid "substring not found"
msgstr "wèi zhǎodào zi zìfú chuàn"
@@ -3114,6 +3200,14 @@ msgstr "Chāo shí shíjiān bìxū wèi 0.0 Dào 100.0 Miǎo"
msgid "timeout must be >= 0.0"
msgstr "chāoshí bìxū shì >= 0.0"
+#: shared-module/sdcardio/SDCard.c
+msgid "timeout waiting for v1 card"
+msgstr ""
+
+#: shared-module/sdcardio/SDCard.c
+msgid "timeout waiting for v2 card"
+msgstr ""
+
#: shared-bindings/time/__init__.c
msgid "timestamp out of range for platform time_t"
msgstr "time_t shíjiān chuō chāochū píngtái fànwéi"
@@ -3311,6 +3405,18 @@ msgstr "y zhí chāochū biānjiè"
msgid "zero step"
msgstr "líng bù"
+#: extmod/ulab/code/filter.c
+msgid "zi must be an ndarray"
+msgstr ""
+
+#: extmod/ulab/code/filter.c
+msgid "zi must be of float type"
+msgstr ""
+
+#: extmod/ulab/code/filter.c
+msgid "zi must be of shape (n_section, 2)"
+msgstr ""
+
#~ msgid "Address is not %d bytes long or is in wrong format"
#~ msgstr "Dìzhǐ bùshì %d zì jié zhǎng, huòzhě géshì cuòwù"
diff --git a/logo/CircuitPython_Repo_header_logo.png.license b/logo/CircuitPython_Repo_header_logo.png.license
new file mode 100644
index 000000000..86a3fbfe8
--- /dev/null
+++ b/logo/CircuitPython_Repo_header_logo.png.license
@@ -0,0 +1,3 @@
+SPDX-FileCopyrightText: 2018 Phillip Torrone for Adafruit Industries
+
+SPDX-License-Identifier: CC-BY-4.0
diff --git a/logo/adafruit_blinka_angles-back.svg.license b/logo/adafruit_blinka_angles-back.svg.license
new file mode 100644
index 000000000..86a3fbfe8
--- /dev/null
+++ b/logo/adafruit_blinka_angles-back.svg.license
@@ -0,0 +1,3 @@
+SPDX-FileCopyrightText: 2018 Phillip Torrone for Adafruit Industries
+
+SPDX-License-Identifier: CC-BY-4.0
diff --git a/logo/adafruit_blinka_angles-front.svg.license b/logo/adafruit_blinka_angles-front.svg.license
new file mode 100644
index 000000000..86a3fbfe8
--- /dev/null
+++ b/logo/adafruit_blinka_angles-front.svg.license
@@ -0,0 +1,3 @@
+SPDX-FileCopyrightText: 2018 Phillip Torrone for Adafruit Industries
+
+SPDX-License-Identifier: CC-BY-4.0
diff --git a/logo/adafruit_blinka_angles-left.svg.license b/logo/adafruit_blinka_angles-left.svg.license
new file mode 100644
index 000000000..86a3fbfe8
--- /dev/null
+++ b/logo/adafruit_blinka_angles-left.svg.license
@@ -0,0 +1,3 @@
+SPDX-FileCopyrightText: 2018 Phillip Torrone for Adafruit Industries
+
+SPDX-License-Identifier: CC-BY-4.0
diff --git a/logo/adafruit_blinka_angles-right.svg.license b/logo/adafruit_blinka_angles-right.svg.license
new file mode 100644
index 000000000..86a3fbfe8
--- /dev/null
+++ b/logo/adafruit_blinka_angles-right.svg.license
@@ -0,0 +1,3 @@
+SPDX-FileCopyrightText: 2018 Phillip Torrone for Adafruit Industries
+
+SPDX-License-Identifier: CC-BY-4.0
diff --git a/logo/adafruit_blinka_computer.svg.license b/logo/adafruit_blinka_computer.svg.license
new file mode 100644
index 000000000..86a3fbfe8
--- /dev/null
+++ b/logo/adafruit_blinka_computer.svg.license
@@ -0,0 +1,3 @@
+SPDX-FileCopyrightText: 2018 Phillip Torrone for Adafruit Industries
+
+SPDX-License-Identifier: CC-BY-4.0
diff --git a/logo/adafruit_circuit_python_ourboros_color.svg.license b/logo/adafruit_circuit_python_ourboros_color.svg.license
new file mode 100644
index 000000000..86a3fbfe8
--- /dev/null
+++ b/logo/adafruit_circuit_python_ourboros_color.svg.license
@@ -0,0 +1,3 @@
+SPDX-FileCopyrightText: 2018 Phillip Torrone for Adafruit Industries
+
+SPDX-License-Identifier: CC-BY-4.0
diff --git a/logo/adafruit_circuit_python_ouroboros_logo_final.svg.license b/logo/adafruit_circuit_python_ouroboros_logo_final.svg.license
new file mode 100644
index 000000000..86a3fbfe8
--- /dev/null
+++ b/logo/adafruit_circuit_python_ouroboros_logo_final.svg.license
@@ -0,0 +1,3 @@
+SPDX-FileCopyrightText: 2018 Phillip Torrone for Adafruit Industries
+
+SPDX-License-Identifier: CC-BY-4.0
diff --git a/logo/adafruit_circuit_python_sitting_color.svg.license b/logo/adafruit_circuit_python_sitting_color.svg.license
new file mode 100644
index 000000000..86a3fbfe8
--- /dev/null
+++ b/logo/adafruit_circuit_python_sitting_color.svg.license
@@ -0,0 +1,3 @@
+SPDX-FileCopyrightText: 2018 Phillip Torrone for Adafruit Industries
+
+SPDX-License-Identifier: CC-BY-4.0
diff --git a/logo/adafruit_circuit_python_stacked_lockup_logo_final.svg.license b/logo/adafruit_circuit_python_stacked_lockup_logo_final.svg.license
new file mode 100644
index 000000000..86a3fbfe8
--- /dev/null
+++ b/logo/adafruit_circuit_python_stacked_lockup_logo_final.svg.license
@@ -0,0 +1,3 @@
+SPDX-FileCopyrightText: 2018 Phillip Torrone for Adafruit Industries
+
+SPDX-License-Identifier: CC-BY-4.0
diff --git a/logo/awesome_circuitpython.svg.license b/logo/awesome_circuitpython.svg.license
new file mode 100644
index 000000000..86a3fbfe8
--- /dev/null
+++ b/logo/awesome_circuitpython.svg.license
@@ -0,0 +1,3 @@
+SPDX-FileCopyrightText: 2018 Phillip Torrone for Adafruit Industries
+
+SPDX-License-Identifier: CC-BY-4.0
diff --git a/logo/blinka_colorform-cooking.png.license b/logo/blinka_colorform-cooking.png.license
new file mode 100644
index 000000000..86a3fbfe8
--- /dev/null
+++ b/logo/blinka_colorform-cooking.png.license
@@ -0,0 +1,3 @@
+SPDX-FileCopyrightText: 2018 Phillip Torrone for Adafruit Industries
+
+SPDX-License-Identifier: CC-BY-4.0
diff --git a/logo/blinka_colorform-cooking.svg.license b/logo/blinka_colorform-cooking.svg.license
new file mode 100644
index 000000000..86a3fbfe8
--- /dev/null
+++ b/logo/blinka_colorform-cooking.svg.license
@@ -0,0 +1,3 @@
+SPDX-FileCopyrightText: 2018 Phillip Torrone for Adafruit Industries
+
+SPDX-License-Identifier: CC-BY-4.0
diff --git a/logo/blinka_colorform-first-birthday.svg.license b/logo/blinka_colorform-first-birthday.svg.license
new file mode 100644
index 000000000..86a3fbfe8
--- /dev/null
+++ b/logo/blinka_colorform-first-birthday.svg.license
@@ -0,0 +1,3 @@
+SPDX-FileCopyrightText: 2018 Phillip Torrone for Adafruit Industries
+
+SPDX-License-Identifier: CC-BY-4.0
diff --git a/logo/blinka_colorform-painting.svg.license b/logo/blinka_colorform-painting.svg.license
new file mode 100644
index 000000000..86a3fbfe8
--- /dev/null
+++ b/logo/blinka_colorform-painting.svg.license
@@ -0,0 +1,3 @@
+SPDX-FileCopyrightText: 2018 Phillip Torrone for Adafruit Industries
+
+SPDX-License-Identifier: CC-BY-4.0
diff --git a/logo/blinka_colorform-reading.svg.license b/logo/blinka_colorform-reading.svg.license
new file mode 100644
index 000000000..86a3fbfe8
--- /dev/null
+++ b/logo/blinka_colorform-reading.svg.license
@@ -0,0 +1,3 @@
+SPDX-FileCopyrightText: 2018 Phillip Torrone for Adafruit Industries
+
+SPDX-License-Identifier: CC-BY-4.0
diff --git a/logo/blinka_colorform-singing.svg.license b/logo/blinka_colorform-singing.svg.license
new file mode 100644
index 000000000..86a3fbfe8
--- /dev/null
+++ b/logo/blinka_colorform-singing.svg.license
@@ -0,0 +1,3 @@
+SPDX-FileCopyrightText: 2018 Phillip Torrone for Adafruit Industries
+
+SPDX-License-Identifier: CC-BY-4.0
diff --git a/logo/blinka_colorform-telescope.svg.license b/logo/blinka_colorform-telescope.svg.license
new file mode 100644
index 000000000..86a3fbfe8
--- /dev/null
+++ b/logo/blinka_colorform-telescope.svg.license
@@ -0,0 +1,3 @@
+SPDX-FileCopyrightText: 2018 Phillip Torrone for Adafruit Industries
+
+SPDX-License-Identifier: CC-BY-4.0
diff --git a/logo/blinka_colorform-test_tubes.svg.license b/logo/blinka_colorform-test_tubes.svg.license
new file mode 100644
index 000000000..86a3fbfe8
--- /dev/null
+++ b/logo/blinka_colorform-test_tubes.svg.license
@@ -0,0 +1,3 @@
+SPDX-FileCopyrightText: 2018 Phillip Torrone for Adafruit Industries
+
+SPDX-License-Identifier: CC-BY-4.0
diff --git a/main.c b/main.c
index c3787122d..8c5c9ac37 100755
--- a/main.c
+++ b/main.c
@@ -45,6 +45,7 @@
#include "background.h"
#include "mpconfigboard.h"
+#include "supervisor/background_callback.h"
#include "supervisor/cpu.h"
#include "supervisor/memory.h"
#include "supervisor/port.h"
@@ -63,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
@@ -96,12 +101,14 @@ void do_str(const char *src, mp_parse_input_kind_t input_kind) {
}
}
+#if MICROPY_ENABLE_PYSTACK
+static size_t PLACE_IN_DTCM_BSS(_pystack[CIRCUITPY_PYSTACK_SIZE / sizeof(size_t)]);
+#endif
+
void start_mp(supervisor_allocation* heap) {
reset_status_led();
autoreload_stop();
- background_tasks_reset();
-
// Stack limit should be less than real stack size, so we have a chance
// to recover from limit hit. (Limit is measured in bytes.)
mp_stack_ctrl_init();
@@ -126,6 +133,10 @@ void start_mp(supervisor_allocation* heap) {
// Clear the readline history. It references the heap we're about to destroy.
readline_init0();
+ #if MICROPY_ENABLE_PYSTACK
+ mp_pystack_init(_pystack, _pystack + (sizeof(_pystack) / sizeof(size_t)));
+ #endif
+
#if MICROPY_ENABLE_GC
gc_init(heap->ptr, heap->ptr + heap->length / 4);
#endif
@@ -161,6 +172,8 @@ void stop_mp(void) {
MP_STATE_VM(vfs_cur) = vfs;
#endif
+ background_callback_reset();
+
gc_deinit();
}
@@ -197,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);
@@ -315,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.
@@ -492,6 +510,8 @@ void gc_collect(void) {
// have lost their references in the VM even though they are mounted.
gc_collect_root((void**)&MP_STATE_VM(vfs_mount_table), sizeof(mp_vfs_mount_t) / sizeof(mp_uint_t));
+ background_callback_gc_collect();
+
#if CIRCUITPY_DISPLAYIO
displayio_gc_collect();
#endif
diff --git a/mpy-cross/.gitignore b/mpy-cross/.gitignore
index 80d7acd42..6daeea504 100644
--- a/mpy-cross/.gitignore
+++ b/mpy-cross/.gitignore
@@ -1,3 +1,7 @@
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+#
+# SPDX-License-Identifier: MIT
+
/build-*
/mpy-cross
/mpy-cross.static
diff --git a/mpy-cross/Makefile b/mpy-cross/Makefile
index 072304faa..3ff379ed3 100644
--- a/mpy-cross/Makefile
+++ b/mpy-cross/Makefile
@@ -1,3 +1,7 @@
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+#
+# SPDX-License-Identifier: MIT
+
# The following is a temporary hack to forefully undefine vars that might have
# be defined by a calling Makefile (from recursive make).
# TODO: Find a better way to be able to call this Makefile recursively.
diff --git a/mpy-cross/Makefile.fuzz b/mpy-cross/Makefile.fuzz
index ca59788f4..0fbbe9b64 100644
--- a/mpy-cross/Makefile.fuzz
+++ b/mpy-cross/Makefile.fuzz
@@ -1,3 +1,6 @@
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+#
+# SPDX-License-Identifier: MIT
PROG=mpy-cross.fuzz
BUILD=build-static
diff --git a/mpy-cross/Makefile.static b/mpy-cross/Makefile.static
index ca0925f75..ac2a8079b 100644
--- a/mpy-cross/Makefile.static
+++ b/mpy-cross/Makefile.static
@@ -1,3 +1,7 @@
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+#
+# SPDX-License-Identifier: MIT
+
PROG=mpy-cross.static
BUILD=build-static
STATIC_BUILD=1
diff --git a/mpy-cross/Makefile.static-mingw b/mpy-cross/Makefile.static-mingw
index a176e80e6..f5bc86177 100644
--- a/mpy-cross/Makefile.static-mingw
+++ b/mpy-cross/Makefile.static-mingw
@@ -1,3 +1,7 @@
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+#
+# SPDX-License-Identifier: MIT
+
PROG=mpy-cross.static.exe
CROSS_COMPILE = x86_64-w64-mingw32-
BUILD=build-static-mingw
diff --git a/mpy-cross/Makefile.static-raspbian b/mpy-cross/Makefile.static-raspbian
index 9129f555e..f895f998b 100644
--- a/mpy-cross/Makefile.static-raspbian
+++ b/mpy-cross/Makefile.static-raspbian
@@ -1,3 +1,7 @@
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+#
+# SPDX-License-Identifier: MIT
+
PROG=mpy-cross.static-raspbian
BUILD=build-static-raspbian
STATIC_BUILD=1
diff --git a/mpy-cross/README.md b/mpy-cross/README.md
index e35b28b69..3d1ace394 100644
--- a/mpy-cross/README.md
+++ b/mpy-cross/README.md
@@ -1,3 +1,9 @@
+<!--
+SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+
+SPDX-License-Identifier: MIT
+-->
+
MicroPython cross compiler
==========================
diff --git a/mpy-cross/fmode.c b/mpy-cross/fmode.c
index 33ba24ed1..b1fa3fc85 100644
--- a/mpy-cross/fmode.c
+++ b/mpy-cross/fmode.c
@@ -1,28 +1,7 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * 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.
- */
+// SPDX-FileCopyrightText: Copyright (c) 2013-2016 Damien P. George
+// SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+//
+// SPDX-License-Identifier: MIT
#include "fmode.h"
#include "py/mpconfig.h"
diff --git a/mpy-cross/fmode.h b/mpy-cross/fmode.h
index c661c84d0..05b4a46b2 100644
--- a/mpy-cross/fmode.h
+++ b/mpy-cross/fmode.h
@@ -1,28 +1,8 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * 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.
- */
+// SPDX-FileCopyrightText: Copyright (c) 2013-2016 Damien P. George
+// SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+//
+// SPDX-License-Identifier: MIT
+
#ifndef MICROPY_INCLUDED_WINDOWS_FMODE_H
#define MICROPY_INCLUDED_WINDOWS_FMODE_H
diff --git a/mpy-cross/gccollect.c b/mpy-cross/gccollect.c
index 75891a2fb..2216fad31 100644
--- a/mpy-cross/gccollect.c
+++ b/mpy-cross/gccollect.c
@@ -1,28 +1,7 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2013-2014 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.
- */
+// SPDX-FileCopyrightText: Copyright (c) 2013-2014 Damien P. George
+// SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+//
+// SPDX-License-Identifier: MIT
#include <stdio.h>
diff --git a/mpy-cross/main.c b/mpy-cross/main.c
index 7c232385b..7a1012b8f 100644
--- a/mpy-cross/main.c
+++ b/mpy-cross/main.c
@@ -1,28 +1,7 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * 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.
- */
+// SPDX-FileCopyrightText: Copyright (c) 2013-2016 Damien P. George
+// SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+//
+// SPDX-License-Identifier: MIT
#include <stdio.h>
#include <string.h>
diff --git a/mpy-cross/mpconfigport.h b/mpy-cross/mpconfigport.h
index 1a8b4880d..464c9113d 100644
--- a/mpy-cross/mpconfigport.h
+++ b/mpy-cross/mpconfigport.h
@@ -1,28 +1,7 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2013-2015 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.
- */
+// SPDX-FileCopyrightText: Copyright (c) 2013-2015 Damien P. George
+// SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+//
+// SPDX-License-Identifier: MIT
// options to control how MicroPython is built
@@ -61,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/mpy-cross/mphalport.h b/mpy-cross/mphalport.h
index 4bd8276f3..245b99c4c 100644
--- a/mpy-cross/mphalport.h
+++ b/mpy-cross/mphalport.h
@@ -1 +1,5 @@
+// SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+//
+// SPDX-License-Identifier: MIT
+
// empty file
diff --git a/mpy-cross/mpy-cross.mk b/mpy-cross/mpy-cross.mk
index de96305cb..c813dae9e 100644
--- a/mpy-cross/mpy-cross.mk
+++ b/mpy-cross/mpy-cross.mk
@@ -1,3 +1,7 @@
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+#
+# SPDX-License-Identifier: MIT
+
include ../py/mkenv.mk
# define main target
diff --git a/mpy-cross/qstrdefsport.h b/mpy-cross/qstrdefsport.h
index 3ba897069..36d4b9ccf 100644
--- a/mpy-cross/qstrdefsport.h
+++ b/mpy-cross/qstrdefsport.h
@@ -1 +1,5 @@
+// SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+//
+// SPDX-License-Identifier: MIT
+
// qstrs specific to this port
diff --git a/ports/atmel-samd/Makefile b/ports/atmel-samd/Makefile
index 5f901a199..25ab2c4aa 100644
--- a/ports/atmel-samd/Makefile
+++ b/ports/atmel-samd/Makefile
@@ -2,7 +2,7 @@
#
# The MIT License (MIT)
#
-# Copyright (c) 2019 Dan Halbert for Adafruit Industries
+# SPDX-FileCopyrightText: Copyright (c) 2019 Dan Halbert for Adafruit Industries
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
@@ -87,25 +87,28 @@ INC += -I. \
ifeq ($(CHIP_FAMILY), samd21)
PERIPHERALS_CHIP_FAMILY=samd21
-CFLAGS += -Os -DNDEBUG
+OPTIMIZATION_FLAGS ?= -Os
# TinyUSB defines
CFLAGS += -DCFG_TUSB_MCU=OPT_MCU_SAMD21 -DCFG_TUD_MIDI_RX_BUFSIZE=128 -DCFG_TUD_CDC_RX_BUFSIZE=128 -DCFG_TUD_MIDI_TX_BUFSIZE=128 -DCFG_TUD_CDC_TX_BUFSIZE=128 -DCFG_TUD_MSC_BUFSIZE=512
endif
ifeq ($(CHIP_FAMILY), samd51)
PERIPHERALS_CHIP_FAMILY=sam_d5x_e5x
-CFLAGS += -Os -DNDEBUG
+OPTIMIZATION_FLAGS ?= -O2
# TinyUSB defines
CFLAGS += -DCFG_TUSB_MCU=OPT_MCU_SAMD51 -DCFG_TUD_MIDI_RX_BUFSIZE=128 -DCFG_TUD_CDC_RX_BUFSIZE=256 -DCFG_TUD_MIDI_TX_BUFSIZE=128 -DCFG_TUD_CDC_TX_BUFSIZE=256 -DCFG_TUD_MSC_BUFSIZE=1024
endif
ifeq ($(CHIP_FAMILY), same54)
PERIPHERALS_CHIP_FAMILY=sam_d5x_e5x
-CFLAGS += -Os -DNDEBUG
+OPTIMIZATION_FLAGS ?= -O2
# TinyUSB defines
CFLAGS += -DCFG_TUSB_MCU=OPT_MCU_SAMD51 -DCFG_TUD_MIDI_RX_BUFSIZE=128 -DCFG_TUD_CDC_RX_BUFSIZE=256 -DCFG_TUD_MIDI_TX_BUFSIZE=128 -DCFG_TUD_CDC_TX_BUFSIZE=256 -DCFG_TUD_MSC_BUFSIZE=1024
endif
+# option to override default optimization level, set in boards/$(BOARD)/mpconfigboard.mk
+CFLAGS += $(OPTIMIZATION_FLAGS) -DNDEBUG
+
$(echo PERIPHERALS_CHIP_FAMILY=$(PERIPHERALS_CHIP_FAMILY))
#Debugging/Optimization
ifeq ($(DEBUG), 1)
@@ -246,6 +249,14 @@ SRC_ASF += \
endif
+ifeq ($(CIRCUITPY_SDIOIO),1)
+SRC_ASF += \
+ hal/src/hal_mci_sync.c \
+ hpl/sdhc/hpl_sdhc.c \
+
+$(BUILD)/asf4/$(CHIP_FAMILY)/hpl/sdhc/hpl_sdhc.o: CFLAGS += -Wno-cast-align
+endif
+
SRC_ASF := $(addprefix asf4/$(CHIP_FAMILY)/, $(SRC_ASF))
SRC_C = \
@@ -290,6 +301,9 @@ SRC_C = \
supervisor/shared/memory.c \
timer_handler.c \
+ifeq ($(CIRCUITPY_SDIOIO),1)
+SRC_C += ports/atmel-samd/sd_mmc/sd_mmc.c
+endif
ifeq ($(CIRCUITPY_NETWORK),1)
CFLAGS += -DMICROPY_PY_NETWORK=1
@@ -346,6 +360,10 @@ endif
OBJ += $(addprefix $(BUILD)/, $(SRC_S:.s=.o))
OBJ += $(addprefix $(BUILD)/, $(SRC_MOD:.c=.o))
+SRC_QSTR += $(HEADER_BUILD)/sdiodata.h
+$(HEADER_BUILD)/sdiodata.h: $(TOP)/tools/mksdiodata.py | $(HEADER_BUILD)
+ $(Q)$(PYTHON3) $< > $@
+
SRC_QSTR += $(SRC_C) $(SRC_SUPERVISOR) $(SRC_COMMON_HAL_EXPANDED) $(SRC_SHARED_MODULE_EXPANDED)
# Sources that only hold QSTRs after pre-processing.
SRC_QSTR_PREPROCESSOR += peripherals/samd/$(PERIPHERALS_CHIP_FAMILY)/clocks.c
diff --git a/ports/atmel-samd/asf4 b/ports/atmel-samd/asf4
-Subproject c0eef7b75124fc946af5f75e12d82d6d01315ab
+Subproject 35a1525796c7ef8a3893d90befdad2f267fca20
diff --git a/ports/atmel-samd/asf4_conf/samd51/hpl_sdhc_config.h b/ports/atmel-samd/asf4_conf/samd51/hpl_sdhc_config.h
new file mode 100644
index 000000000..daa662051
--- /dev/null
+++ b/ports/atmel-samd/asf4_conf/samd51/hpl_sdhc_config.h
@@ -0,0 +1,24 @@
+/* Auto-generated config file hpl_sdhc_config.h */
+#ifndef HPL_SDHC_CONFIG_H
+#define HPL_SDHC_CONFIG_H
+
+// <<< Use Configuration Wizard in Context Menu >>>
+
+#include "peripheral_clk_config.h"
+
+#ifndef CONF_BASE_FREQUENCY
+#define CONF_BASE_FREQUENCY CONF_SDHC0_FREQUENCY
+#endif
+
+// <o> Clock Generator Select
+// <0=> Divided Clock mode
+// <1=> Programmable Clock mode
+// <i> This defines the clock generator mode in the SDCLK Frequency Select field
+// <id> sdhc_clk_gsel
+#ifndef CONF_SDHC0_CLK_GEN_SEL
+#define CONF_SDHC0_CLK_GEN_SEL 0
+#endif
+
+// <<< end of configuration section >>>
+
+#endif // HPL_SDHC_CONFIG_H
diff --git a/ports/atmel-samd/asf4_conf/samd51/peripheral_clk_config.h b/ports/atmel-samd/asf4_conf/samd51/peripheral_clk_config.h
index 030a90a7a..59fe8730e 100644
--- a/ports/atmel-samd/asf4_conf/samd51/peripheral_clk_config.h
+++ b/ports/atmel-samd/asf4_conf/samd51/peripheral_clk_config.h
@@ -1001,6 +1001,170 @@
#define CONF_GCLK_USB_FREQUENCY 48000000
#endif
+// <h> SDHC Clock Settings
+// <y> SDHC Clock source
+
+// <GCLK_PCHCTRL_GEN_GCLK0_Val"> Generic clock generator 0
+
+// <GCLK_PCHCTRL_GEN_GCLK1_Val"> Generic clock generator 1
+
+// <GCLK_PCHCTRL_GEN_GCLK2_Val"> Generic clock generator 2
+
+// <GCLK_PCHCTRL_GEN_GCLK3_Val"> Generic clock generator 3
+
+// <GCLK_PCHCTRL_GEN_GCLK4_Val"> Generic clock generator 4
+
+// <GCLK_PCHCTRL_GEN_GCLK5_Val"> Generic clock generator 5
+
+// <GCLK_PCHCTRL_GEN_GCLK6_Val"> Generic clock generator 6
+
+// <GCLK_PCHCTRL_GEN_GCLK7_Val"> Generic clock generator 7
+
+// <GCLK_PCHCTRL_GEN_GCLK8_Val"> Generic clock generator 8
+
+// <GCLK_PCHCTRL_GEN_GCLK9_Val"> Generic clock generator 9
+
+// <GCLK_PCHCTRL_GEN_GCLK10_Val"> Generic clock generator 10
+
+// <GCLK_PCHCTRL_GEN_GCLK11_Val"> Generic clock generator 11
+
+// <i> Select the clock source for SDHC.
+// <id> sdhc_gclk_selection
+#ifndef CONF_GCLK_SDHC0_SRC
+#define CONF_GCLK_SDHC0_SRC GCLK_GENCTRL_SRC_DFLL_Val
+#endif
+
+// <y> SDHC clock slow source
+
+// <GCLK_PCHCTRL_GEN_GCLK0_Val"> Generic clock generator 0
+
+// <GCLK_PCHCTRL_GEN_GCLK1_Val"> Generic clock generator 1
+
+// <GCLK_PCHCTRL_GEN_GCLK2_Val"> Generic clock generator 2
+
+// <GCLK_PCHCTRL_GEN_GCLK3_Val"> Generic clock generator 3
+
+// <GCLK_PCHCTRL_GEN_GCLK4_Val"> Generic clock generator 4
+
+// <GCLK_PCHCTRL_GEN_GCLK5_Val"> Generic clock generator 5
+
+// <GCLK_PCHCTRL_GEN_GCLK6_Val"> Generic clock generator 6
+
+// <GCLK_PCHCTRL_GEN_GCLK7_Val"> Generic clock generator 7
+
+// <GCLK_PCHCTRL_GEN_GCLK8_Val"> Generic clock generator 8
+
+// <GCLK_PCHCTRL_GEN_GCLK9_Val"> Generic clock generator 9
+
+// <GCLK_PCHCTRL_GEN_GCLK10_Val"> Generic clock generator 10
+
+// <GCLK_PCHCTRL_GEN_GCLK11_Val"> Generic clock generator 11
+
+// <i> Select the clock source for SDHC.
+// <id> sdhc_slow_gclk_selection
+#ifndef CONF_GCLK_SDHC0_SLOW_SRC
+#define CONF_GCLK_SDHC0_SLOW_SRC GCLK_GENCTRL_SRC_DFLL_Val
+#endif
+// </h>
+
+/**
+ * \def SDHC FREQUENCY
+ * \brief SDHC's Clock frequency
+ */
+#ifndef CONF_SDHC0_FREQUENCY
+#define CONF_SDHC0_FREQUENCY 12000000
+#endif
+
+/**
+ * \def SDHC FREQUENCY
+ * \brief SDHC's Clock slow frequency
+ */
+#ifndef CONF_SDHC0_SLOW_FREQUENCY
+#define CONF_SDHC0_SLOW_FREQUENCY 12000000
+#endif
+
+// <h> SDHC Clock Settings
+// <y> SDHC Clock source
+
+// <GCLK_PCHCTRL_GEN_GCLK0_Val"> Generic clock generator 0
+
+// <GCLK_PCHCTRL_GEN_GCLK1_Val"> Generic clock generator 1
+
+// <GCLK_PCHCTRL_GEN_GCLK2_Val"> Generic clock generator 2
+
+// <GCLK_PCHCTRL_GEN_GCLK3_Val"> Generic clock generator 3
+
+// <GCLK_PCHCTRL_GEN_GCLK4_Val"> Generic clock generator 4
+
+// <GCLK_PCHCTRL_GEN_GCLK5_Val"> Generic clock generator 5
+
+// <GCLK_PCHCTRL_GEN_GCLK6_Val"> Generic clock generator 6
+
+// <GCLK_PCHCTRL_GEN_GCLK7_Val"> Generic clock generator 7
+
+// <GCLK_PCHCTRL_GEN_GCLK8_Val"> Generic clock generator 8
+
+// <GCLK_PCHCTRL_GEN_GCLK9_Val"> Generic clock generator 9
+
+// <GCLK_PCHCTRL_GEN_GCLK10_Val"> Generic clock generator 10
+
+// <GCLK_PCHCTRL_GEN_GCLK11_Val"> Generic clock generator 11
+
+// <i> Select the clock source for SDHC.
+// <id> sdhc_gclk_selection
+#ifndef CONF_GCLK_SDHC1_SRC
+#define CONF_GCLK_SDHC1_SRC GCLK_GENCTRL_SRC_DFLL_Val
+#endif
+
+// <y> SDHC clock slow source
+
+// <GCLK_PCHCTRL_GEN_GCLK0_Val"> Generic clock generator 0
+
+// <GCLK_PCHCTRL_GEN_GCLK1_Val"> Generic clock generator 1
+
+// <GCLK_PCHCTRL_GEN_GCLK2_Val"> Generic clock generator 2
+
+// <GCLK_PCHCTRL_GEN_GCLK3_Val"> Generic clock generator 3
+
+// <GCLK_PCHCTRL_GEN_GCLK4_Val"> Generic clock generator 4
+
+// <GCLK_PCHCTRL_GEN_GCLK5_Val"> Generic clock generator 5
+
+// <GCLK_PCHCTRL_GEN_GCLK6_Val"> Generic clock generator 6
+
+// <GCLK_PCHCTRL_GEN_GCLK7_Val"> Generic clock generator 7
+
+// <GCLK_PCHCTRL_GEN_GCLK8_Val"> Generic clock generator 8
+
+// <GCLK_PCHCTRL_GEN_GCLK9_Val"> Generic clock generator 9
+
+// <GCLK_PCHCTRL_GEN_GCLK10_Val"> Generic clock generator 10
+
+// <GCLK_PCHCTRL_GEN_GCLK11_Val"> Generic clock generator 11
+
+// <i> Select the clock source for SDHC.
+// <id> sdhc_slow_gclk_selection
+#ifndef CONF_GCLK_SDHC1_SLOW_SRC
+#define CONF_GCLK_SDHC1_SLOW_SRC GCLK_GENCTRL_SRC_DFLL_Val
+#endif
+// </h>
+
+/**
+ * \def SDHC FREQUENCY
+ * \brief SDHC's Clock frequency
+ */
+#ifndef CONF_SDHC1_FREQUENCY
+#define CONF_SDHC1_FREQUENCY 12000000
+#endif
+
+/**
+ * \def SDHC FREQUENCY
+ * \brief SDHC's Clock slow frequency
+ */
+#ifndef CONF_SDHC1_SLOW_FREQUENCY
+#define CONF_SDHC1_SLOW_FREQUENCY 12000000
+#endif
+
// <<< end of configuration section >>>
#endif // PERIPHERAL_CLK_CONFIG_H
diff --git a/ports/atmel-samd/asf4_conf/same54/hpl_sdhc_config.h b/ports/atmel-samd/asf4_conf/same54/hpl_sdhc_config.h
new file mode 100644
index 000000000..daa662051
--- /dev/null
+++ b/ports/atmel-samd/asf4_conf/same54/hpl_sdhc_config.h
@@ -0,0 +1,24 @@
+/* Auto-generated config file hpl_sdhc_config.h */
+#ifndef HPL_SDHC_CONFIG_H
+#define HPL_SDHC_CONFIG_H
+
+// <<< Use Configuration Wizard in Context Menu >>>
+
+#include "peripheral_clk_config.h"
+
+#ifndef CONF_BASE_FREQUENCY
+#define CONF_BASE_FREQUENCY CONF_SDHC0_FREQUENCY
+#endif
+
+// <o> Clock Generator Select
+// <0=> Divided Clock mode
+// <1=> Programmable Clock mode
+// <i> This defines the clock generator mode in the SDCLK Frequency Select field
+// <id> sdhc_clk_gsel
+#ifndef CONF_SDHC0_CLK_GEN_SEL
+#define CONF_SDHC0_CLK_GEN_SEL 0
+#endif
+
+// <<< end of configuration section >>>
+
+#endif // HPL_SDHC_CONFIG_H
diff --git a/ports/atmel-samd/asf4_conf/same54/peripheral_clk_config.h b/ports/atmel-samd/asf4_conf/same54/peripheral_clk_config.h
index 030a90a7a..59fe8730e 100644
--- a/ports/atmel-samd/asf4_conf/same54/peripheral_clk_config.h
+++ b/ports/atmel-samd/asf4_conf/same54/peripheral_clk_config.h
@@ -1001,6 +1001,170 @@
#define CONF_GCLK_USB_FREQUENCY 48000000
#endif
+// <h> SDHC Clock Settings
+// <y> SDHC Clock source
+
+// <GCLK_PCHCTRL_GEN_GCLK0_Val"> Generic clock generator 0
+
+// <GCLK_PCHCTRL_GEN_GCLK1_Val"> Generic clock generator 1
+
+// <GCLK_PCHCTRL_GEN_GCLK2_Val"> Generic clock generator 2
+
+// <GCLK_PCHCTRL_GEN_GCLK3_Val"> Generic clock generator 3
+
+// <GCLK_PCHCTRL_GEN_GCLK4_Val"> Generic clock generator 4
+
+// <GCLK_PCHCTRL_GEN_GCLK5_Val"> Generic clock generator 5
+
+// <GCLK_PCHCTRL_GEN_GCLK6_Val"> Generic clock generator 6
+
+// <GCLK_PCHCTRL_GEN_GCLK7_Val"> Generic clock generator 7
+
+// <GCLK_PCHCTRL_GEN_GCLK8_Val"> Generic clock generator 8
+
+// <GCLK_PCHCTRL_GEN_GCLK9_Val"> Generic clock generator 9
+
+// <GCLK_PCHCTRL_GEN_GCLK10_Val"> Generic clock generator 10
+
+// <GCLK_PCHCTRL_GEN_GCLK11_Val"> Generic clock generator 11
+
+// <i> Select the clock source for SDHC.
+// <id> sdhc_gclk_selection
+#ifndef CONF_GCLK_SDHC0_SRC
+#define CONF_GCLK_SDHC0_SRC GCLK_GENCTRL_SRC_DFLL_Val
+#endif
+
+// <y> SDHC clock slow source
+
+// <GCLK_PCHCTRL_GEN_GCLK0_Val"> Generic clock generator 0
+
+// <GCLK_PCHCTRL_GEN_GCLK1_Val"> Generic clock generator 1
+
+// <GCLK_PCHCTRL_GEN_GCLK2_Val"> Generic clock generator 2
+
+// <GCLK_PCHCTRL_GEN_GCLK3_Val"> Generic clock generator 3
+
+// <GCLK_PCHCTRL_GEN_GCLK4_Val"> Generic clock generator 4
+
+// <GCLK_PCHCTRL_GEN_GCLK5_Val"> Generic clock generator 5
+
+// <GCLK_PCHCTRL_GEN_GCLK6_Val"> Generic clock generator 6
+
+// <GCLK_PCHCTRL_GEN_GCLK7_Val"> Generic clock generator 7
+
+// <GCLK_PCHCTRL_GEN_GCLK8_Val"> Generic clock generator 8
+
+// <GCLK_PCHCTRL_GEN_GCLK9_Val"> Generic clock generator 9
+
+// <GCLK_PCHCTRL_GEN_GCLK10_Val"> Generic clock generator 10
+
+// <GCLK_PCHCTRL_GEN_GCLK11_Val"> Generic clock generator 11
+
+// <i> Select the clock source for SDHC.
+// <id> sdhc_slow_gclk_selection
+#ifndef CONF_GCLK_SDHC0_SLOW_SRC
+#define CONF_GCLK_SDHC0_SLOW_SRC GCLK_GENCTRL_SRC_DFLL_Val
+#endif
+// </h>
+
+/**
+ * \def SDHC FREQUENCY
+ * \brief SDHC's Clock frequency
+ */
+#ifndef CONF_SDHC0_FREQUENCY
+#define CONF_SDHC0_FREQUENCY 12000000
+#endif
+
+/**
+ * \def SDHC FREQUENCY
+ * \brief SDHC's Clock slow frequency
+ */
+#ifndef CONF_SDHC0_SLOW_FREQUENCY
+#define CONF_SDHC0_SLOW_FREQUENCY 12000000
+#endif
+
+// <h> SDHC Clock Settings
+// <y> SDHC Clock source
+
+// <GCLK_PCHCTRL_GEN_GCLK0_Val"> Generic clock generator 0
+
+// <GCLK_PCHCTRL_GEN_GCLK1_Val"> Generic clock generator 1
+
+// <GCLK_PCHCTRL_GEN_GCLK2_Val"> Generic clock generator 2
+
+// <GCLK_PCHCTRL_GEN_GCLK3_Val"> Generic clock generator 3
+
+// <GCLK_PCHCTRL_GEN_GCLK4_Val"> Generic clock generator 4
+
+// <GCLK_PCHCTRL_GEN_GCLK5_Val"> Generic clock generator 5
+
+// <GCLK_PCHCTRL_GEN_GCLK6_Val"> Generic clock generator 6
+
+// <GCLK_PCHCTRL_GEN_GCLK7_Val"> Generic clock generator 7
+
+// <GCLK_PCHCTRL_GEN_GCLK8_Val"> Generic clock generator 8
+
+// <GCLK_PCHCTRL_GEN_GCLK9_Val"> Generic clock generator 9
+
+// <GCLK_PCHCTRL_GEN_GCLK10_Val"> Generic clock generator 10
+
+// <GCLK_PCHCTRL_GEN_GCLK11_Val"> Generic clock generator 11
+
+// <i> Select the clock source for SDHC.
+// <id> sdhc_gclk_selection
+#ifndef CONF_GCLK_SDHC1_SRC
+#define CONF_GCLK_SDHC1_SRC GCLK_GENCTRL_SRC_DFLL_Val
+#endif
+
+// <y> SDHC clock slow source
+
+// <GCLK_PCHCTRL_GEN_GCLK0_Val"> Generic clock generator 0
+
+// <GCLK_PCHCTRL_GEN_GCLK1_Val"> Generic clock generator 1
+
+// <GCLK_PCHCTRL_GEN_GCLK2_Val"> Generic clock generator 2
+
+// <GCLK_PCHCTRL_GEN_GCLK3_Val"> Generic clock generator 3
+
+// <GCLK_PCHCTRL_GEN_GCLK4_Val"> Generic clock generator 4
+
+// <GCLK_PCHCTRL_GEN_GCLK5_Val"> Generic clock generator 5
+
+// <GCLK_PCHCTRL_GEN_GCLK6_Val"> Generic clock generator 6
+
+// <GCLK_PCHCTRL_GEN_GCLK7_Val"> Generic clock generator 7
+
+// <GCLK_PCHCTRL_GEN_GCLK8_Val"> Generic clock generator 8
+
+// <GCLK_PCHCTRL_GEN_GCLK9_Val"> Generic clock generator 9
+
+// <GCLK_PCHCTRL_GEN_GCLK10_Val"> Generic clock generator 10
+
+// <GCLK_PCHCTRL_GEN_GCLK11_Val"> Generic clock generator 11
+
+// <i> Select the clock source for SDHC.
+// <id> sdhc_slow_gclk_selection
+#ifndef CONF_GCLK_SDHC1_SLOW_SRC
+#define CONF_GCLK_SDHC1_SLOW_SRC GCLK_GENCTRL_SRC_DFLL_Val
+#endif
+// </h>
+
+/**
+ * \def SDHC FREQUENCY
+ * \brief SDHC's Clock frequency
+ */
+#ifndef CONF_SDHC1_FREQUENCY
+#define CONF_SDHC1_FREQUENCY 12000000
+#endif
+
+/**
+ * \def SDHC FREQUENCY
+ * \brief SDHC's Clock slow frequency
+ */
+#ifndef CONF_SDHC1_SLOW_FREQUENCY
+#define CONF_SDHC1_SLOW_FREQUENCY 12000000
+#endif
+
// <<< end of configuration section >>>
#endif // PERIPHERAL_CLK_CONFIG_H
diff --git a/ports/atmel-samd/audio_dma.c b/ports/atmel-samd/audio_dma.c
index 93cd96b98..c6c636160 100644
--- a/ports/atmel-samd/audio_dma.c
+++ b/ports/atmel-samd/audio_dma.c
@@ -31,7 +31,7 @@
#include "shared-bindings/audiocore/RawSample.h"
#include "shared-bindings/audiocore/WaveFile.h"
-#include "supervisor/shared/tick.h"
+#include "supervisor/background_callback.h"
#include "py/mpstate.h"
#include "py/runtime.h"
@@ -61,7 +61,6 @@ void audio_dma_free_channel(uint8_t channel) {
assert(audio_dma_allocated[channel]);
audio_dma_disable_channel(channel);
audio_dma_allocated[channel] = false;
- supervisor_disable_tick();
}
void audio_dma_disable_channel(uint8_t channel) {
@@ -73,7 +72,6 @@ void audio_dma_disable_channel(uint8_t channel) {
void audio_dma_enable_channel(uint8_t channel) {
if (channel >= AUDIO_DMA_CHANNEL_COUNT)
return;
- supervisor_enable_tick();
dma_enable_channel(channel);
}
@@ -259,6 +257,15 @@ audio_dma_result audio_dma_setup_playback(audio_dma_t* dma,
dma->beat_size *= 2;
}
+#ifdef SAM_D5X_E5X
+ int irq = dma->event_channel < 4 ? EVSYS_0_IRQn + dma->event_channel : EVSYS_4_IRQn;
+#else
+ int irq = EVSYS_IRQn;
+#endif
+
+ NVIC_DisableIRQ(irq);
+ NVIC_ClearPendingIRQ(irq);
+
DmacDescriptor* first_descriptor = dma_descriptor(dma_channel);
setup_audio_descriptor(first_descriptor, dma->beat_size, output_spacing, output_register_address);
if (single_buffer) {
@@ -281,6 +288,8 @@ audio_dma_result audio_dma_setup_playback(audio_dma_t* dma,
dma_configure(dma_channel, dma_trigger_source, true);
audio_dma_enable_channel(dma_channel);
+ NVIC_EnableIRQ(irq);
+
return AUDIO_DMA_OK;
}
@@ -321,9 +330,6 @@ void audio_dma_reset(void) {
for (uint8_t i = 0; i < AUDIO_DMA_CHANNEL_COUNT; i++) {
audio_dma_state[i] = NULL;
audio_dma_pending[i] = false;
- if (audio_dma_allocated[i]) {
- supervisor_disable_tick();
- }
audio_dma_allocated[i] = false;
audio_dma_disable_channel(i);
dma_descriptor(i)->BTCTRL.bit.VALID = false;
@@ -343,29 +349,39 @@ bool audio_dma_get_playing(audio_dma_t* dma) {
return (status & DMAC_CHINTFLAG_TERR) == 0;
}
-// WARN(tannewt): DO NOT print from here. Printing calls background tasks such as this and causes a
-// stack overflow.
+// WARN(tannewt): DO NOT print from here, or anything it calls. Printing calls
+// background tasks such as this and causes a stack overflow.
+STATIC void dma_callback_fun(void *arg) {
+ audio_dma_t* dma = arg;
+ if (dma == NULL) {
+ return;
+ }
+
+ audio_dma_load_next_block(dma);
+}
-void audio_dma_background(void) {
+void evsyshandler_common(void) {
for (uint8_t i = 0; i < AUDIO_DMA_CHANNEL_COUNT; i++) {
- if (audio_dma_pending[i]) {
- continue;
- }
audio_dma_t* dma = audio_dma_state[i];
if (dma == NULL) {
continue;
}
-
bool block_done = event_interrupt_active(dma->event_channel);
if (!block_done) {
continue;
}
-
- // audio_dma_load_next_block() can call Python code, which can call audio_dma_background()
- // recursively at the next background processing time. So disallow recursive calls to here.
- audio_dma_pending[i] = true;
- audio_dma_load_next_block(dma);
- audio_dma_pending[i] = false;
+ background_callback_add(&dma->callback, dma_callback_fun, (void*)dma);
}
}
+
+#ifdef SAM_D5X_E5X
+void EVSYS_0_Handler(void) { evsyshandler_common(); }
+void EVSYS_1_Handler(void) { evsyshandler_common(); }
+void EVSYS_2_Handler(void) { evsyshandler_common(); }
+void EVSYS_3_Handler(void) { evsyshandler_common(); }
+void EVSYS_4_Handler(void) { evsyshandler_common(); }
+#else
+void EVSYS_Handler(void) { evsyshandler_common(); }
+#endif
+
#endif
diff --git a/ports/atmel-samd/audio_dma.h b/ports/atmel-samd/audio_dma.h
index 1ebec6f7e..4fffd06b8 100644
--- a/ports/atmel-samd/audio_dma.h
+++ b/ports/atmel-samd/audio_dma.h
@@ -31,6 +31,7 @@
#include "py/obj.h"
#include "shared-module/audiocore/RawSample.h"
#include "shared-module/audiocore/WaveFile.h"
+#include "supervisor/background_callback.h"
typedef struct {
mp_obj_t sample;
@@ -49,6 +50,7 @@ typedef struct {
uint8_t* second_buffer;
bool first_descriptor_free;
DmacDescriptor* second_descriptor;
+ background_callback_t callback;
} audio_dma_t;
typedef enum {
diff --git a/ports/atmel-samd/background.c b/ports/atmel-samd/background.c
index 767c7f3b6..62c233a3f 100644
--- a/ports/atmel-samd/background.c
+++ b/ports/atmel-samd/background.c
@@ -39,63 +39,21 @@
#include "shared-module/displayio/__init__.h"
#endif
-volatile uint64_t last_finished_tick = 0;
-
-bool stack_ok_so_far = true;
-
-static bool running_background_tasks = false;
-
#ifdef MONITOR_BACKGROUND_TASKS
// PB03 is physical pin "SCL" on the Metro M4 express
// so you can't use this code AND an i2c peripheral
// at the same time unless you change this
-STATIC void start_background_task(void) {
+void port_start_background_task(void) {
REG_PORT_DIRSET1 = (1<<3);
REG_PORT_OUTSET1 = (1<<3);
}
-STATIC void finish_background_task(void) {
+void port_finish_background_task(void) {
REG_PORT_OUTCLR1 = (1<<3);
}
#else
-STATIC void start_background_task(void) {}
-STATIC void finish_background_task(void) {}
+void port_start_background_task(void) {}
+void port_finish_background_task(void) {}
#endif
-void background_tasks_reset(void) {
- running_background_tasks = false;
-}
-
-void run_background_tasks(void) {
- // Don't call ourselves recursively.
- if (running_background_tasks) {
- return;
- }
-
- start_background_task();
-
- assert_heap_ok();
- running_background_tasks = true;
-
- #if CIRCUITPY_AUDIOIO || CIRCUITPY_AUDIOBUSIO
- audio_dma_background();
- #endif
- #if CIRCUITPY_DISPLAYIO
- displayio_background();
- #endif
-
- #if CIRCUITPY_NETWORK
- network_module_background();
- #endif
- filesystem_background();
- usb_background();
- running_background_tasks = false;
- assert_heap_ok();
-
- last_finished_tick = port_get_raw_ticks(NULL);
- finish_background_task();
-}
-
-bool background_tasks_ok(void) {
- return port_get_raw_ticks(NULL) - last_finished_tick < 1024;
-}
+void port_background_task(void) {}
diff --git a/ports/atmel-samd/background.h b/ports/atmel-samd/background.h
index d9866a6ab..2a89c3b1b 100644
--- a/ports/atmel-samd/background.h
+++ b/ports/atmel-samd/background.h
@@ -29,9 +29,4 @@
#include <stdbool.h>
-void background_tasks_reset(void);
-void run_background_tasks(void);
-void run_background_vm_tasks(void);
-bool background_tasks_ok(void);
-
#endif // MICROPY_INCLUDED_ATMEL_SAMD_BACKGROUND_H
diff --git a/ports/atmel-samd/bindings/samd/Clock.c b/ports/atmel-samd/bindings/samd/Clock.c
index e1022c52f..478a10fcd 100644
--- a/ports/atmel-samd/bindings/samd/Clock.c
+++ b/ports/atmel-samd/bindings/samd/Clock.c
@@ -30,7 +30,6 @@
#include "py/objproperty.h"
#include "py/runtime.h"
-//| import typing
//| class Clock:
//| """Identifies a clock on the microcontroller.
//|
@@ -44,7 +43,7 @@ STATIC void samd_clock_print(const mp_print_t *print, mp_obj_t self_in, mp_print
mp_printf(print, "%q.%q.%q", MP_QSTR_samd, MP_QSTR_clock, self->name);
}
-//| enabled: bool = ...
+//| enabled: bool
//| """Is the clock enabled? (read-only)"""
//|
STATIC mp_obj_t samd_clock_get_enabled(mp_obj_t self_in) {
@@ -62,7 +61,7 @@ const mp_obj_property_t samd_clock_enabled_obj = {
},
};
-//| parent: typing.Union(Clock | None) = ...
+//| parent: Union[Clock, None]
//| """Clock parent. (read-only)"""
//|
STATIC mp_obj_t samd_clock_get_parent(mp_obj_t self_in) {
@@ -90,7 +89,7 @@ const mp_obj_property_t samd_clock_parent_obj = {
},
};
-//| frequency: int = ...
+//| frequency: int
//| """Clock frequency in Herz. (read-only)"""
//|
STATIC mp_obj_t samd_clock_get_frequency(mp_obj_t self_in) {
@@ -108,7 +107,7 @@ const mp_obj_property_t samd_clock_frequency_obj = {
},
};
-//| calibration: int = ...
+//| calibration: int
//| """Clock calibration. Not all clocks can be calibrated."""
//|
STATIC mp_obj_t samd_clock_get_calibration(mp_obj_t self_in) {
diff --git a/ports/atmel-samd/boards/8086_commander/mpconfigboard.mk b/ports/atmel-samd/boards/8086_commander/mpconfigboard.mk
index 4b0377be2..9151040a0 100644
--- a/ports/atmel-samd/boards/8086_commander/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/8086_commander/mpconfigboard.mk
@@ -18,6 +18,8 @@ SUPEROPT_GC = 0
CFLAGS_INLINE_LIMIT = 60
+CIRCUITPY_GAMEPAD = 1
+
# Include these Python libraries in firmware.
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_BusDevice
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_HID
diff --git a/ports/atmel-samd/boards/aloriumtech_evo_m51/mpconfigboard.mk b/ports/atmel-samd/boards/aloriumtech_evo_m51/mpconfigboard.mk
index 28b1434fb..34301da3f 100644
--- a/ports/atmel-samd/boards/aloriumtech_evo_m51/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/aloriumtech_evo_m51/mpconfigboard.mk
@@ -13,6 +13,4 @@ EXTERNAL_FLASH_DEVICE_COUNT = 1
EXTERNAL_FLASH_DEVICES = GD25Q16C
LONGINT_IMPL = MPZ
-CIRCUITPY_NETWORK = 1
-MICROPY_PY_WIZNET5K = 5500
CIRCUITPY_PS2IO = 1
diff --git a/ports/atmel-samd/boards/circuitbrains_basic_m0/mpconfigboard.mk b/ports/atmel-samd/boards/circuitbrains_basic_m0/mpconfigboard.mk
index da5f1ffac..619b7d694 100755
--- a/ports/atmel-samd/boards/circuitbrains_basic_m0/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/circuitbrains_basic_m0/mpconfigboard.mk
@@ -12,6 +12,7 @@ EXTERNAL_FLASH_DEVICES = "W25Q32JV_IQ"
LONGINT_IMPL = MPZ
CIRCUITPY_BITBANGIO = 0
+CIRCUITPY_COUNTIO = 0
CIRCUITPY_FREQUENCYIO = 0
CIRCUITPY_I2CPERIPHERAL = 0
CIRCUITPY_VECTORIO = 0
diff --git a/ports/atmel-samd/boards/circuitbrains_deluxe_m4/mpconfigboard.mk b/ports/atmel-samd/boards/circuitbrains_deluxe_m4/mpconfigboard.mk
index 7a9e5a780..13ae59de4 100755
--- a/ports/atmel-samd/boards/circuitbrains_deluxe_m4/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/circuitbrains_deluxe_m4/mpconfigboard.mk
@@ -11,6 +11,4 @@ EXTERNAL_FLASH_DEVICE_COUNT = 2
EXTERNAL_FLASH_DEVICES = "W25Q64JV_IQ, S25FL064L"
LONGINT_IMPL = MPZ
-CIRCUITPY_NETWORK = 1
-MICROPY_PY_WIZNET5K = 5500
CIRCUITPY_PS2IO = 1
diff --git a/ports/atmel-samd/boards/fluff_m0/pins.c b/ports/atmel-samd/boards/fluff_m0/pins.c
index d80d46b89..ac7811328 100644
--- a/ports/atmel-samd/boards/fluff_m0/pins.c
+++ b/ports/atmel-samd/boards/fluff_m0/pins.c
@@ -30,6 +30,8 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_PA16) },
{ MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_PA19) },
{ MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_PA17) },
+ { MP_ROM_QSTR(MP_QSTR_D14), MP_ROM_PTR(&pin_PA27) },
+ { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_PA28) },
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
{ MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) },
diff --git a/ports/atmel-samd/boards/grandcentral_m4_express/mpconfigboard.mk b/ports/atmel-samd/boards/grandcentral_m4_express/mpconfigboard.mk
index ab81ec5a2..08eb5c98b 100644
--- a/ports/atmel-samd/boards/grandcentral_m4_express/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/grandcentral_m4_express/mpconfigboard.mk
@@ -10,3 +10,5 @@ QSPI_FLASH_FILESYSTEM = 1
EXTERNAL_FLASH_DEVICE_COUNT = 2
EXTERNAL_FLASH_DEVICES = "W25Q64JV_IQ, GD25Q64C"
LONGINT_IMPL = MPZ
+
+CIRCUITPY_SDIOIO = 1
diff --git a/ports/atmel-samd/boards/grandcentral_m4_express/pins.c b/ports/atmel-samd/boards/grandcentral_m4_express/pins.c
index 6b09c62bf..b125aca08 100644
--- a/ports/atmel-samd/boards/grandcentral_m4_express/pins.c
+++ b/ports/atmel-samd/boards/grandcentral_m4_express/pins.c
@@ -1,5 +1,18 @@
+#include "py/objtuple.h"
#include "shared-bindings/board/__init__.h"
+STATIC const mp_rom_obj_tuple_t sdio_data_tuple = {
+ {&mp_type_tuple},
+ 4,
+ {
+ MP_ROM_PTR(&pin_PB18),
+ MP_ROM_PTR(&pin_PB19),
+ MP_ROM_PTR(&pin_PB20),
+ MP_ROM_PTR(&pin_PB21),
+ }
+};
+
+
// This mapping only includes functional names because pins broken
// out on connectors are labeled with their MCU name available from
// microcontroller.pin.
@@ -129,5 +142,9 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
{ MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) },
{ MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) },
+
+ { MP_ROM_QSTR(MP_QSTR_SDIO_CLOCK), MP_ROM_PTR(&pin_PA21) },
+ { MP_ROM_QSTR(MP_QSTR_SDIO_COMMAND), MP_ROM_PTR(&pin_PA20) },
+ { MP_ROM_QSTR(MP_QSTR_SDIO_DATA), MP_ROM_PTR(&sdio_data_tuple) },
};
MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);
diff --git a/ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.mk b/ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.mk
index febd2a6c3..18cef738e 100644
--- a/ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/kicksat-sprite/mpconfigboard.mk
@@ -13,9 +13,11 @@ LONGINT_IMPL = MPZ
CIRCUITPY_AUDIOBUSIO = 0
CIRCUITPY_FRAMEBUFFERIO = 0
CIRCUITPY_DISPLAYIO = 0
-CIRCUITPY_NETWORK = 0
CIRCUITPY_RGBMATRIX = 0
CIRCUITPY_PS2IO = 0
CIRCUITPY_AUDIOMP3 = 0
CIRCUITPY_ULAB = 0
+
+# Override optimization to keep binary small
+OPTIMIZATION_FLAGS = -Os
diff --git a/ports/atmel-samd/boards/loc_ber_m4_base_board/mpconfigboard.mk b/ports/atmel-samd/boards/loc_ber_m4_base_board/mpconfigboard.mk
index 55d6fa78e..3c407f530 100644
--- a/ports/atmel-samd/boards/loc_ber_m4_base_board/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/loc_ber_m4_base_board/mpconfigboard.mk
@@ -15,3 +15,5 @@ LONGINT_IMPL = MPZ
CIRCUITPY_AUDIOBUSIO = 0
CIRCUITPY_BITBANG_APA102 = 1
+# Override optimization to keep binary small
+OPTIMIZATION_FLAGS = -Os
diff --git a/ports/atmel-samd/boards/ndgarage_ndbit6_v2/board.c b/ports/atmel-samd/boards/ndgarage_ndbit6_v2/board.c
new file mode 100644
index 000000000..0f60736a2
--- /dev/null
+++ b/ports/atmel-samd/boards/ndgarage_ndbit6_v2/board.c
@@ -0,0 +1,39 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include "boards/board.h"
+#include "mpconfigboard.h"
+#include "hal/include/hal_gpio.h"
+
+void board_init(void) {
+}
+
+bool board_requests_safe_mode(void) {
+ return false;
+}
+
+void reset_board(void) {
+}
diff --git a/ports/atmel-samd/boards/ndgarage_ndbit6_v2/mpconfigboard.h b/ports/atmel-samd/boards/ndgarage_ndbit6_v2/mpconfigboard.h
new file mode 100644
index 000000000..0dc7f5d19
--- /dev/null
+++ b/ports/atmel-samd/boards/ndgarage_ndbit6_v2/mpconfigboard.h
@@ -0,0 +1,22 @@
+#define MICROPY_HW_BOARD_NAME "ndGarage[n°] Bit6: FeatherSnow-v2"
+#define MICROPY_HW_MCU_NAME "samd21e18"
+
+#define MICROPY_HW_LED_STATUS (&pin_PA23)
+
+#define MICROPY_PORT_A (PORT_PA24 | PORT_PA25)
+#define MICROPY_PORT_B (0)
+#define MICROPY_PORT_C (0)
+
+#define CIRCUITPY_INTERNAL_NVM_SIZE 256
+
+#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000 CIRCUITPY_INTERNAL_NVM_SIZE)
+
+#define DEFAULT_I2C_BUS_SCL (&pin_PA17)
+#define DEFAULT_I2C_BUS_SDA (&pin_PA16)
+
+#define DEFAULT_UART_BUS_RX (&pin_PA17)
+#define DEFAULT_UART_BUS_TX (&pin_PA16)
+
+// USB is always used.
+#define IGNORE_PIN_PA24 1
+#define IGNORE_PIN_PA25 1
diff --git a/ports/atmel-samd/boards/ndgarage_ndbit6_v2/mpconfigboard.mk b/ports/atmel-samd/boards/ndgarage_ndbit6_v2/mpconfigboard.mk
new file mode 100644
index 000000000..193a0cf99
--- /dev/null
+++ b/ports/atmel-samd/boards/ndgarage_ndbit6_v2/mpconfigboard.mk
@@ -0,0 +1,14 @@
+LD_FILE = boards/samd21x18-bootloader.ld
+USB_VID = 0x239A
+USB_PID = 0x80B9
+USB_PRODUCT = "Bit6"
+USB_MANUFACTURER = "ndGarage"
+
+CHIP_VARIANT = SAMD21E18A
+CHIP_FAMILY = samd21
+
+INTERNAL_FLASH_FILESYSTEM = 1
+LONGINT_IMPL = NONE
+CIRCUITPY_FULL_BUILD = 0
+
+SUPEROPT_GC = 0
diff --git a/ports/atmel-samd/boards/ndgarage_ndbit6_v2/pins.c b/ports/atmel-samd/boards/ndgarage_ndbit6_v2/pins.c
new file mode 100644
index 000000000..f0615df5a
--- /dev/null
+++ b/ports/atmel-samd/boards/ndgarage_ndbit6_v2/pins.c
@@ -0,0 +1,36 @@
+#include "shared-bindings/board/__init__.h"
+
+STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
+ { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_PA02) },
+ { MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_PA04) },
+ { MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_PA07) },
+ { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_PA10) },
+ { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_PA15) },
+ { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PA27) },
+ { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_PA01) },
+ { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_PA03) },
+ { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_PA06) },
+
+ { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PA09) },
+ { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_PA18) },
+ { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_PA23) },
+ { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_PA00) },
+ { MP_ROM_QSTR(MP_QSTR_D14), MP_ROM_PTR(&pin_PA05) },
+ { MP_ROM_QSTR(MP_QSTR_D15), MP_ROM_PTR(&pin_PA08) },
+ { MP_ROM_QSTR(MP_QSTR_D16), MP_ROM_PTR(&pin_PA11) },
+ { MP_ROM_QSTR(MP_QSTR_D17), MP_ROM_PTR(&pin_PA22) },
+ { MP_ROM_QSTR(MP_QSTR_D18), MP_ROM_PTR(&pin_PA28) },
+ { MP_ROM_QSTR(MP_QSTR_D19), MP_ROM_PTR(&pin_PA19) },
+
+ { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PA16) },
+ { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PA17) },
+
+ { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PA17) },
+ { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PA16) },
+
+ { MP_ROM_QSTR(MP_QSTR_L), MP_ROM_PTR(&pin_PA23) },
+
+ { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
+ { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) },
+};
+MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);
diff --git a/ports/atmel-samd/boards/pewpew10/mpconfigboard.h b/ports/atmel-samd/boards/pewpew10/mpconfigboard.h
index 6b3b4aa15..2cb097e8d 100644
--- a/ports/atmel-samd/boards/pewpew10/mpconfigboard.h
+++ b/ports/atmel-samd/boards/pewpew10/mpconfigboard.h
@@ -43,3 +43,5 @@
#define DEFAULT_UART_BUS_RX (&pin_PA01)
#define DEFAULT_UART_BUS_TX (&pin_PA00)
+
+#define SAMD21_BOD33_LEVEL (6)
diff --git a/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.h b/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.h
index 60cd8d754..4b88c89f2 100644
--- a/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.h
+++ b/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.h
@@ -40,3 +40,5 @@
#define IGNORE_PIN_PB09 1
#define IGNORE_PIN_PB10 1
#define IGNORE_PIN_PB11 1
+
+#define SAMD5x_E5x_BOD33_LEVEL (100)
diff --git a/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.mk b/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.mk
index b6490433e..1ea4a7601 100644
--- a/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/pewpew_m4/mpconfigboard.mk
@@ -10,38 +10,32 @@ INTERNAL_FLASH_FILESYSTEM = 1
LONGINT_IMPL = NONE
CIRCUITPY_FULL_BUILD = 0
-# TODO: Turn off analogio for now for space reasons, but restore it
-# when frozen module gets smaller.
-CIRCUITPY_ANALOGIO = 0
CIRCUITPY_AUDIOBUSIO = 0
+CIRCUITPY_AUDIOPWMIO = 0
+CIRCUITPY_AUDIOMP3 = 0
CIRCUITPY_BITBANGIO = 0
+CIRCUITPY_BITBANG_APA102 = 0
CIRCUITPY_FREQUENCYIO = 0
+CIRCUITPY_GAMEPADSHIFT = 0
CIRCUITPY_I2CPERIPHERAL = 0
CIRCUITPY_NEOPIXEL_WRITE = 0
-CIRCUITPY_NETWORK = 0
CIRCUITPY_PIXELBUF = 0
CIRCUITPY_PS2IO = 0
+CIRCUITPY_ROTARYIO = 0
CIRCUITPY_RTC = 0
+CIRCUITPY_SAMD = 0
CIRCUITPY_TOUCHIO = 0
CIRCUITPY_USB_HID = 0
CIRCUITPY_USB_MIDI = 0
-CIRCUITPY_AUDIOPWMIO = 0
-CIRCUITPY_AUDIOMP3 = 0
-CIRCUITPY_BITBANG_APA102 = 0
-CIRCUITPY_BLEIO = 0
-CIRCUITPY_GAMEPADSHIFT = 0
-CIRCUITPY_NETWORK = 0
-CIRCUITPY_ROTARYIO = 0
-CIRCUITPY_SAMD = 0
-CIRCUITPY_TOUCHIO = 0
CIRCUITPY_VECTORIO = 0
+CIRCUITPY_ANALOGIO = 1
CIRCUITPY_AUDIOMIXER = 1
CIRCUITPY_AUDIOIO = 1
CIRCUITPY_DISPLAYIO = 1
CIRCUITPY_GAMEPAD = 1
-CIRCUITPY_STAGE = 1
CIRCUITPY_MATH = 1
+CIRCUITPY_STAGE = 1
FROZEN_MPY_DIRS += $(TOP)/frozen/circuitpython-stage/pewpew_m4
CIRCUITPY_DISPLAY_FONT = $(TOP)/ports/atmel-samd/boards/ugame10/brutalist-6.bdf
@@ -52,3 +46,5 @@ CFLAGS_INLINE_LIMIT = 45
else
CFLAGS_INLINE_LIMIT = 70
endif
+# Override optimization to keep binary small
+OPTIMIZATION_FLAGS = -Os
diff --git a/ports/atmel-samd/boards/same54_xplained/mpconfigboard.mk b/ports/atmel-samd/boards/same54_xplained/mpconfigboard.mk
index ffc4f567f..7ac126514 100644
--- a/ports/atmel-samd/boards/same54_xplained/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/same54_xplained/mpconfigboard.mk
@@ -10,4 +10,5 @@ QSPI_FLASH_FILESYSTEM = 1
EXTERNAL_FLASH_DEVICE_COUNT = 2
EXTERNAL_FLASH_DEVICES = "N25Q256A"
LONGINT_IMPL = MPZ
-LONGINT_IMPL = MPZ
+
+CIRCUITPY_SDIOIO = 1
diff --git a/ports/atmel-samd/boards/same54_xplained/pins.c b/ports/atmel-samd/boards/same54_xplained/pins.c
index 5b9373724..8a864ab97 100644
--- a/ports/atmel-samd/boards/same54_xplained/pins.c
+++ b/ports/atmel-samd/boards/same54_xplained/pins.c
@@ -1,5 +1,18 @@
+#include "py/objtuple.h"
#include "shared-bindings/board/__init__.h"
+STATIC const mp_rom_obj_tuple_t sdio_data_tuple = {
+ {&mp_type_tuple},
+ 4,
+ {
+ MP_ROM_PTR(&pin_PB18),
+ MP_ROM_PTR(&pin_PB19),
+ MP_ROM_PTR(&pin_PB20),
+ MP_ROM_PTR(&pin_PB21),
+ }
+};
+
+
// This mapping only includes functional names because pins broken
// out on connectors are labeled with their MCU name available from
// microcontroller.pin.
@@ -95,5 +108,9 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
{ MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) },
{ MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) },
+
+ { MP_ROM_QSTR(MP_QSTR_SDIO_CLOCK), MP_ROM_PTR(&pin_PA21) },
+ { MP_ROM_QSTR(MP_QSTR_SDIO_COMMAND), MP_ROM_PTR(&pin_PA20) },
+ { MP_ROM_QSTR(MP_QSTR_SDIO_DATA), MP_ROM_PTR(&sdio_data_tuple) },
};
MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);
diff --git a/ports/atmel-samd/boards/sparkfun_samd51_thing_plus/mpconfigboard.mk b/ports/atmel-samd/boards/sparkfun_samd51_thing_plus/mpconfigboard.mk
index 13863e565..567f1db20 100644
--- a/ports/atmel-samd/boards/sparkfun_samd51_thing_plus/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/sparkfun_samd51_thing_plus/mpconfigboard.mk
@@ -12,6 +12,4 @@ EXTERNAL_FLASH_DEVICE_COUNT = 1
EXTERNAL_FLASH_DEVICES = AT25SF041A
LONGINT_IMPL = MPZ
-CIRCUITPY_NETWORK = 1
-MICROPY_PY_WIZNET5K = 5500
CIRCUITPY_PS2IO = 1
diff --git a/ports/atmel-samd/boards/uchip/mpconfigboard.mk b/ports/atmel-samd/boards/uchip/mpconfigboard.mk
index 90b5600dc..d08690a15 100644
--- a/ports/atmel-samd/boards/uchip/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/uchip/mpconfigboard.mk
@@ -9,3 +9,8 @@ CHIP_FAMILY = samd21
INTERNAL_FLASH_FILESYSTEM = 1
LONGINT_IMPL = NONE
CIRCUITPY_FULL_BUILD = 0
+
+# Always use aggressive inlining
+CFLAGS_INLINE_LIMIT = 45
+
+SUPEROPT_GC = 0
diff --git a/ports/atmel-samd/boards/winterbloom_big_honking_button/mpconfigboard.mk b/ports/atmel-samd/boards/winterbloom_big_honking_button/mpconfigboard.mk
index e06a2af7e..71586d6e0 100644
--- a/ports/atmel-samd/boards/winterbloom_big_honking_button/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/winterbloom_big_honking_button/mpconfigboard.mk
@@ -24,10 +24,13 @@ CIRCUITPY_BLEIO = 0
CIRCUITPY_DISPLAYIO = 0
CIRCUITPY_GAMEPAD = 0
CIRCUITPY_I2CPERIPHERAL = 0
-CIRCUITPY_NETWORK = 0
CIRCUITPY_TOUCHIO = 0
CIRCUITPY_RGBMATRIX = 0
CIRCUITPY_PS2IO = 0
CIRCUITPY_USB_HID = 0
CIRCUITPY_USB_MIDI = 0
CIRCUITPY_RTC = 0
+
+# Enable board-specific modules
+USER_C_MODULES = boards/winterbloom_big_honking_button/usermods
+CFLAGS += -DMODULE_BHB_ENABLED=1
diff --git a/ports/atmel-samd/boards/winterbloom_big_honking_button/usermods/_bhb/bhb.c b/ports/atmel-samd/boards/winterbloom_big_honking_button/usermods/_bhb/bhb.c
new file mode 100644
index 000000000..54ce173d8
--- /dev/null
+++ b/ports/atmel-samd/boards/winterbloom_big_honking_button/usermods/_bhb/bhb.c
@@ -0,0 +1,120 @@
+#include "py/obj.h"
+#include "py/runtime.h"
+#include "shared-bindings/microcontroller/Pin.h"
+#include "samd/pins.h"
+#include "sam.h"
+
+STATIC mp_obj_t _bhb_read_adc(void);
+
+STATIC mp_obj_t _bhb_init_adc(void) {
+ claim_pin(&pin_PB08);
+ common_hal_never_reset_pin(&pin_PB08);
+
+ /* Enable the APB clock for the ADC. */
+ PM->APBCMASK.reg |= PM_APBCMASK_ADC;
+
+ /* Enable GCLK0 for the ADC */
+ GCLK->CLKCTRL.reg = GCLK_CLKCTRL_CLKEN |
+ GCLK_CLKCTRL_GEN_GCLK0 |
+ GCLK_CLKCTRL_ID_ADC;
+
+ /* Wait for bus synchronization. */
+ while (GCLK->STATUS.bit.SYNCBUSY) {};
+
+ uint32_t bias = (*((uint32_t *) ADC_FUSES_BIASCAL_ADDR) & ADC_FUSES_BIASCAL_Msk) >> ADC_FUSES_BIASCAL_Pos;
+ uint32_t linearity = (*((uint32_t *) ADC_FUSES_LINEARITY_0_ADDR) & ADC_FUSES_LINEARITY_0_Msk) >> ADC_FUSES_LINEARITY_0_Pos;
+ linearity |= ((*((uint32_t *) ADC_FUSES_LINEARITY_1_ADDR) & ADC_FUSES_LINEARITY_1_Msk) >> ADC_FUSES_LINEARITY_1_Pos) << 5;
+
+ /* Wait for bus synchronization. */
+ while (ADC->STATUS.bit.SYNCBUSY) {};
+
+ /* Write the calibration data. */
+ ADC->CALIB.reg = ADC_CALIB_BIAS_CAL(bias) | ADC_CALIB_LINEARITY_CAL(linearity);
+
+ /* Use the internal VCC reference. This is 1/2 of what's on VCCA.
+ since VCCA is 3.3v, this is 1.65v.
+ */
+ ADC->REFCTRL.reg = ADC_REFCTRL_REFSEL_INTVCC1;
+
+ /* Capture 64 samples. */
+ ADC->AVGCTRL.reg = ADC_AVGCTRL_SAMPLENUM_64 | ADC_AVGCTRL_ADJRES(4);
+
+ /* Set the clock prescaler to 32, which is the same as the CircuitPython default.
+ Set the resolution to 16 for averaging
+ */
+ ADC->CTRLB.reg = ADC_CTRLB_PRESCALER_DIV32 |
+ ADC_CTRLB_RESSEL_16BIT;
+
+ /* Configure the input parameters.
+
+ - GAIN_DIV2 means that the input voltage is halved. This is important
+ because the voltage reference is 1/2 of VCCA. So if you want to
+ measure 0-3.3v, you need to halve the input as well.
+
+ - MUXNEG_GND means that the ADC should compare the input value to GND.
+
+ - MUXPOS_PIN3 means that the ADC should read from AIN2, or PB08.
+ */
+ ADC->INPUTCTRL.reg = ADC_INPUTCTRL_GAIN_DIV2 |
+ ADC_INPUTCTRL_MUXNEG_GND |
+ ADC_INPUTCTRL_MUXPOS_PIN2;
+
+
+ /* Set PB08 as an input pin. */
+ PORT->Group[1].DIRCLR.reg = PORT_PB08;
+
+ /* Enable the peripheral multiplexer for PB08. */
+ PORT->Group[1].PINCFG[8].reg |= PORT_PINCFG_PMUXEN;
+
+ /* Set PB08 to function B which is analog input. */
+ PORT->Group[1].PMUX[4].reg |= PORT_PMUX_PMUXE_B;
+
+ /* Wait for bus synchronization. */
+ while (ADC->STATUS.bit.SYNCBUSY) {};
+
+ /* Enable the ADC. */
+ ADC->CTRLA.bit.ENABLE = true;
+
+ /* Make one read and throw it away, as per the datasheet. */
+ _bhb_read_adc();
+
+ return mp_const_none;
+}
+
+STATIC mp_obj_t _bhb_read_adc(void) {
+ /* Wait for bus synchronization. */
+ while (ADC->STATUS.bit.SYNCBUSY) {};
+
+ /* Start the ADC using a software trigger. */
+ ADC->SWTRIG.bit.START = true;
+
+ /* Wait for the result ready flag to be set. */
+ while (ADC->INTFLAG.bit.RESRDY == 0);
+
+ /* Clear the flag. */
+ ADC->INTFLAG.reg = ADC_INTFLAG_RESRDY;
+
+ /* Read the value. */
+ uint32_t result = ADC->RESULT.reg;
+
+ return MP_OBJ_NEW_SMALL_INT(result);
+}
+
+
+STATIC MP_DEFINE_CONST_FUN_OBJ_0(_bhb_init_adc_obj, _bhb_init_adc);
+STATIC MP_DEFINE_CONST_FUN_OBJ_0(_bhb_read_adc_obj, _bhb_read_adc);
+
+STATIC const mp_rom_map_elem_t _bhb_module_globals_table[] = {
+ { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR__bhb) },
+ { MP_ROM_QSTR(MP_QSTR_init_adc), MP_ROM_PTR(&_bhb_init_adc_obj) },
+ { MP_ROM_QSTR(MP_QSTR_read_adc), MP_ROM_PTR(&_bhb_read_adc_obj) },
+};
+
+STATIC MP_DEFINE_CONST_DICT(_bhb_module_globals, _bhb_module_globals_table);
+
+const mp_obj_module_t _bhb_user_cmodule = {
+ .base = { &mp_type_module },
+ .globals = (mp_obj_dict_t*)&_bhb_module_globals,
+};
+
+MP_REGISTER_MODULE(MP_QSTR__bhb, _bhb_user_cmodule, MODULE_BHB_ENABLED);
diff --git a/ports/atmel-samd/boards/winterbloom_big_honking_button/usermods/_bhb/micropython.mk b/ports/atmel-samd/boards/winterbloom_big_honking_button/usermods/_bhb/micropython.mk
new file mode 100644
index 000000000..9374ec34e
--- /dev/null
+++ b/ports/atmel-samd/boards/winterbloom_big_honking_button/usermods/_bhb/micropython.mk
@@ -0,0 +1,6 @@
+USERMODULES_DIR := $(USERMOD_DIR)
+
+# Add all C files to SRC_USERMOD.
+SRC_USERMOD += $(USERMODULES_DIR)/bhb.c
+
+CFLAGS_USERMOD += -I$(USERMODULES_DIR)
diff --git a/ports/atmel-samd/boards/winterbloom_sol/mpconfigboard.mk b/ports/atmel-samd/boards/winterbloom_sol/mpconfigboard.mk
index 11592073f..9217cdf23 100644
--- a/ports/atmel-samd/boards/winterbloom_sol/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/winterbloom_sol/mpconfigboard.mk
@@ -23,7 +23,6 @@ CIRCUITPY_DISPLAYIO = 0
CIRCUITPY_FRAMEBUFFERIO = 0
CIRCUITPY_GAMEPAD = 0
CIRCUITPY_I2CPERIPHERAL = 0
-CIRCUITPY_NETWORK = 0
CIRCUITPY_TOUCHIO = 0
CIRCUITPY_RGBMATRIX = 0
CIRCUITPY_PS2IO = 0
diff --git a/ports/atmel-samd/common-hal/analogio/AnalogOut.c b/ports/atmel-samd/common-hal/analogio/AnalogOut.c
index e69a24071..fac4c6bfc 100644
--- a/ports/atmel-samd/common-hal/analogio/AnalogOut.c
+++ b/ports/atmel-samd/common-hal/analogio/AnalogOut.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/ports/atmel-samd/common-hal/board/__init__.c b/ports/atmel-samd/common-hal/board/__init__.c
index 634760335..92a172138 100644
--- a/ports/atmel-samd/common-hal/board/__init__.c
+++ b/ports/atmel-samd/common-hal/board/__init__.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/ports/atmel-samd/common-hal/busio/SPI.c b/ports/atmel-samd/common-hal/busio/SPI.c
index 1dc389027..921713d69 100644
--- a/ports/atmel-samd/common-hal/busio/SPI.c
+++ b/ports/atmel-samd/common-hal/busio/SPI.c
@@ -341,7 +341,7 @@ bool common_hal_busio_spi_read(busio_spi_obj_t *self,
return status >= 0; // Status is number of chars read or an error code < 0.
}
-bool common_hal_busio_spi_transfer(busio_spi_obj_t *self, uint8_t *data_out, uint8_t *data_in, size_t len) {
+bool common_hal_busio_spi_transfer(busio_spi_obj_t *self, const uint8_t *data_out, uint8_t *data_in, size_t len) {
if (len == 0) {
return true;
}
@@ -350,7 +350,7 @@ bool common_hal_busio_spi_transfer(busio_spi_obj_t *self, uint8_t *data_out, uin
status = sercom_dma_transfer(self->spi_desc.dev.prvt, data_out, data_in, len);
} else {
struct spi_xfer xfer;
- xfer.txbuf = data_out;
+ xfer.txbuf = (uint8_t*) data_out;
xfer.rxbuf = data_in;
xfer.size = len;
status = spi_m_sync_transfer(&self->spi_desc, &xfer);
diff --git a/ports/atmel-samd/common-hal/busio/UART.c b/ports/atmel-samd/common-hal/busio/UART.c
index b587eaaef..9557c3b5f 100644
--- a/ports/atmel-samd/common-hal/busio/UART.c
+++ b/ports/atmel-samd/common-hal/busio/UART.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2016 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 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
@@ -58,7 +58,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
const mcu_pin_obj_t * tx, const mcu_pin_obj_t * rx,
const mcu_pin_obj_t * rts, const mcu_pin_obj_t * cts,
const mcu_pin_obj_t * rs485_dir, bool rs485_invert,
- uint32_t baudrate, uint8_t bits, uart_parity_t parity, uint8_t stop,
+ uint32_t baudrate, uint8_t bits, busio_uart_parity_t parity, uint8_t stop,
mp_float_t timeout, uint16_t receiver_buffer_size, byte* receiver_buffer,
bool sigint_enabled) {
@@ -195,7 +195,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
SERCOM_USART_CTRLA_FORM_Msk);
sercom->USART.CTRLA.reg |= SERCOM_USART_CTRLA_TXPO(tx_pad / 2) |
SERCOM_USART_CTRLA_RXPO(rx_pad) |
- (parity == PARITY_NONE ? 0 : SERCOM_USART_CTRLA_FORM(1));
+ (parity == BUSIO_UART_PARITY_NONE ? 0 : SERCOM_USART_CTRLA_FORM(1));
// Enable tx and/or rx based on whether the pins were specified.
// CHSIZE is 0 for 8 bits, 5, 6, 7 for 5, 6, 7 bits. 1 for 9 bits, but we don't support that.
@@ -206,7 +206,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
SERCOM_USART_CTRLB_CHSIZE_Msk);
sercom->USART.CTRLB.reg |= (have_tx ? SERCOM_USART_CTRLB_TXEN : 0) |
(have_rx ? SERCOM_USART_CTRLB_RXEN : 0) |
- (parity == PARITY_ODD ? SERCOM_USART_CTRLB_PMODE : 0) |
+ (parity == BUSIO_UART_PARITY_ODD ? SERCOM_USART_CTRLB_PMODE : 0) |
(stop > 1 ? SERCOM_USART_CTRLB_SBMODE : 0) |
SERCOM_USART_CTRLB_CHSIZE(bits % 8);
diff --git a/ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c b/ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c
index 1952df563..02d0482dc 100644
--- a/ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c
+++ b/ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c
@@ -46,6 +46,7 @@
#include "hpl_gclk_config.h"
#include "shared-bindings/time/__init__.h"
+#include "supervisor/shared/tick.h"
#include "supervisor/shared/translate.h"
#ifdef SAMD21
@@ -132,7 +133,7 @@ void frequencyin_interrupt_handler(uint8_t index) {
}
// Check if we've reached the upper limit of detection
- if (!background_tasks_ok() || self->errored_too_fast) {
+ if (!supervisor_background_tasks_ok() || self->errored_too_fast) {
self->errored_too_fast = true;
frequencyin_emergency_cancel_capture(i);
}
diff --git a/ports/atmel-samd/common-hal/pulseio/PWMOut.c b/ports/atmel-samd/common-hal/pulseio/PWMOut.c
index 752f6c214..e33437dad 100644
--- a/ports/atmel-samd/common-hal/pulseio/PWMOut.c
+++ b/ports/atmel-samd/common-hal/pulseio/PWMOut.c
@@ -4,7 +4,7 @@
* The MIT License (MIT)
*
* Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
- * Copyright (c) 2016 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 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
diff --git a/ports/atmel-samd/common-hal/pulseio/PulseIn.c b/ports/atmel-samd/common-hal/pulseio/PulseIn.c
index 7ea20321b..ae58b089d 100644
--- a/ports/atmel-samd/common-hal/pulseio/PulseIn.c
+++ b/ports/atmel-samd/common-hal/pulseio/PulseIn.c
@@ -42,6 +42,7 @@
#include "samd/timers.h"
#include "shared-bindings/microcontroller/__init__.h"
#include "shared-bindings/pulseio/PulseIn.h"
+#include "supervisor/shared/tick.h"
#include "supervisor/shared/translate.h"
// This timer is shared amongst all PulseIn objects as a higher resolution clock.
@@ -87,7 +88,7 @@ void pulsein_interrupt_handler(uint8_t channel) {
uint32_t current_count = tc->COUNT16.COUNT.reg;
pulseio_pulsein_obj_t* self = get_eic_channel_data(channel);
- if (!background_tasks_ok() || self->errored_too_fast) {
+ if (!supervisor_background_tasks_ok() || self->errored_too_fast) {
self->errored_too_fast = true;
common_hal_pulseio_pulsein_pause(self);
return;
@@ -125,6 +126,9 @@ void pulsein_interrupt_handler(uint8_t channel) {
}
void pulsein_reset() {
+#ifdef SAMD21
+ rtc_end_pulsein();
+#endif
refcount = 0;
pulsein_tc_index = 0xff;
overflow_count = 0;
@@ -221,6 +225,10 @@ void common_hal_pulseio_pulsein_construct(pulseio_pulsein_obj_t* self,
// Set config will enable the EIC.
pulsein_set_config(self, true);
+#ifdef SAMD21
+ rtc_start_pulsein();
+#endif
+
}
bool common_hal_pulseio_pulsein_deinited(pulseio_pulsein_obj_t* self) {
@@ -231,6 +239,9 @@ void common_hal_pulseio_pulsein_deinit(pulseio_pulsein_obj_t* self) {
if (common_hal_pulseio_pulsein_deinited(self)) {
return;
}
+#ifdef SAMD21
+ rtc_end_pulsein();
+#endif
set_eic_handler(self->channel, EIC_HANDLER_NO_INTERRUPT);
turn_off_eic_channel(self->channel);
reset_pin_number(self->pin);
diff --git a/ports/atmel-samd/common-hal/pulseio/PulseIn.h b/ports/atmel-samd/common-hal/pulseio/PulseIn.h
index 89b61a83a..99358178f 100644
--- a/ports/atmel-samd/common-hal/pulseio/PulseIn.h
+++ b/ports/atmel-samd/common-hal/pulseio/PulseIn.h
@@ -50,5 +50,11 @@ void pulsein_reset(void);
void pulsein_interrupt_handler(uint8_t channel);
void pulsein_timer_interrupt_handler(uint8_t index);
+#ifdef SAMD21
+void rtc_set_continuous(void);
+void rtc_start_pulsein(void);
+void rtc_end_pulsein(void);
+#endif
+
#endif // MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_PULSEIO_PULSEIN_H
diff --git a/ports/atmel-samd/common-hal/pulseio/PulseOut.c b/ports/atmel-samd/common-hal/pulseio/PulseOut.c
index 5c829f84d..e9b2137cb 100644
--- a/ports/atmel-samd/common-hal/pulseio/PulseOut.c
+++ b/ports/atmel-samd/common-hal/pulseio/PulseOut.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2016 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 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
diff --git a/ports/atmel-samd/common-hal/sdioio/SDCard.c b/ports/atmel-samd/common-hal/sdioio/SDCard.c
new file mode 100644
index 000000000..8cd077ecd
--- /dev/null
+++ b/ports/atmel-samd/common-hal/sdioio/SDCard.c
@@ -0,0 +1,272 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020 Jeff Epler for Adafruit Industries
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+#include <stdbool.h>
+
+#include "py/mperrno.h"
+#include "py/runtime.h"
+
+#include "boards/board.h"
+#include "common-hal/microcontroller/Pin.h"
+#include "shared-bindings/sdioio/SDCard.h"
+#include "shared-bindings/microcontroller/Pin.h"
+#include "shared-bindings/microcontroller/__init__.h"
+#include "supervisor/shared/translate.h"
+
+#include "genhdr/sdiodata.h"
+
+#include "sd_mmc/sd_mmc.h"
+#include "sd_mmc/conf_sd_mmc.h"
+#include "peripheral_clk_config.h"
+
+#ifndef DEBUG_SDIO
+#define DEBUG_SDIO (0)
+#endif
+
+#if DEBUG_SDIO
+#define DEBUG_PRINT(...) ((void)mp_printf(&mp_plat_print, __VA_ARGS__))
+#define DEBUG_PRINT_OBJ(o) ((void)mp_obj_print_helper(&mp_plat_print, (mp_obj_t)o, PRINT_REPR))
+#else
+#define DEBUG_PRINT(...) ((void)0)
+#define DEBUG_PRINT_OBJ(...) ((void)0)
+#endif
+#define DEBUG_PRINT_OBJ_NL(o) (DEBUG_PRINT_OBJ(o), DEBUG_PRINT("\n"))
+
+#define GPIO_PIN_FUNCTION_SDIO (GPIO_PIN_FUNCTION_I)
+
+static Sdhc *sdhc_insts[] = SDHC_INSTS;
+
+STATIC pin_function_t *find_pin_function(pin_function_t *table, const mcu_pin_obj_t *pin, int instance, uint16_t name) {
+ DEBUG_PRINT("\n\n[inst=% 2d] %q: ", instance, name);
+ DEBUG_PRINT_OBJ_NL(pin);
+
+ for(; table->obj; table++) {
+ DEBUG_PRINT("[inst=% 2d] considering table @%p: ");
+ DEBUG_PRINT_OBJ(table->obj);
+ DEBUG_PRINT(" %d %d\n", table->instance, table->pin);
+ if (instance != -1 && instance != table->instance) {
+ continue;
+ }
+ if (pin == table->obj) {
+ return table;
+ }
+ }
+ mp_raise_ValueError_varg(translate("%q pin invalid"), name);
+}
+
+void common_hal_sdioio_sdcard_construct(sdioio_sdcard_obj_t *self,
+ const mcu_pin_obj_t * clock, const mcu_pin_obj_t * command,
+ uint8_t num_data, mcu_pin_obj_t ** data, uint32_t frequency) {
+ /*
+SD breakout as assembled ("*" = minimum viable set)
+
+PURPLE 9 DAT2 SDA
+BLUE 1 DAT3 SCL
+GREEN 2 CMD * D32
+YELLOW 3 VSS1
+RED 4 VDD * 3.3V
+BROWN 5 CLK * BROWN
+BLACK 6 VSS2 * GND
+WHITE 7 DAT0 * D8
+GREY 8 DAT1 D29
+
+DAT0..3 PB18..21 (D8 D29 D20 D21) WHITE GREY PURPLE BLUE
+CMD PA20 PCC_D? (D33) GREEN
+CLK PA21 PCC_D? (D32) BROWN
+
+*/
+
+ pin_function_t *functions[6] = {};
+ functions[0] = find_pin_function(sdio_cmd, command, -1, MP_QSTR_command);
+ int instance = functions[0]->instance;
+ functions[1] = find_pin_function(sdio_ck, clock, instance, MP_QSTR_clock);
+ functions[2] = find_pin_function(sdio_dat0, data[0], instance, MP_QSTR_data0);
+ if(num_data == 4) {
+ functions[3] = find_pin_function(sdio_dat1, data[1], instance, MP_QSTR_data1);
+ functions[4] = find_pin_function(sdio_dat2, data[2], instance, MP_QSTR_data2);
+ functions[5] = find_pin_function(sdio_dat3, data[3], instance, MP_QSTR_data3);
+ }
+
+ // We've verified all pins, now set their special functions
+ self->command_pin = common_hal_mcu_pin_number(functions[0]->obj);
+ self->clock_pin = common_hal_mcu_pin_number(functions[1]->obj);
+
+ for(int i=0; i<num_data; i++) {
+ pin_function_t *function = functions[2+i];
+ if (function) {
+ self->data_pins[i] = common_hal_mcu_pin_number(function->obj);
+ } else {
+ self->data_pins[i] = COMMON_HAL_MCU_NO_PIN;
+ }
+ }
+
+ for(size_t i=0; i<MP_ARRAY_SIZE(functions); i++) {
+ if (!functions[i]->obj) {
+ break;
+ }
+
+ gpio_set_pin_direction(functions[i]->pin, GPIO_DIRECTION_OUT);
+ gpio_set_pin_level(functions[i]->pin, false);
+ // Enable pullups on all pins except CLK and DAT3
+ gpio_set_pin_pull_mode(functions[i]->pin,
+ (i == 1 || i == 5) ? GPIO_PULL_OFF : GPIO_PULL_UP);
+ gpio_set_pin_function(functions[i]->pin, GPIO_PIN_FUNCTION_SDIO);
+
+ common_hal_never_reset_pin(functions[i]->obj);
+ }
+
+ self->num_data = num_data;
+ self->frequency = frequency;
+
+ if(instance == 0) {
+ hri_mclk_set_AHBMASK_SDHC0_bit(MCLK);
+ hri_gclk_write_PCHCTRL_reg(GCLK, SDHC0_GCLK_ID, CONF_GCLK_SDHC0_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
+ hri_gclk_write_PCHCTRL_reg(GCLK, SDHC0_GCLK_ID_SLOW, CONF_GCLK_SDHC0_SLOW_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
+ } else {
+#ifdef SDHC1_GCLK_ID
+ hri_mclk_set_AHBMASK_SDHC1_bit(MCLK);
+ hri_gclk_write_PCHCTRL_reg(GCLK, SDHC1_GCLK_ID, CONF_GCLK_SDHC1_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
+ hri_gclk_write_PCHCTRL_reg(GCLK, SDHC1_GCLK_ID_SLOW, CONF_GCLK_SDHC1_SLOW_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos));
+#endif
+ }
+
+ DEBUG_PRINT("instance %d @%p\n", instance, sdhc_insts[instance]);
+ mci_sync_init(&self->IO_BUS, sdhc_insts[instance]);
+ sd_mmc_init(&self->IO_BUS, NULL, NULL);
+
+ sd_mmc_err_t result = SD_MMC_INIT_ONGOING;
+
+ for (int i=0; result == SD_MMC_INIT_ONGOING && i<100; i++) {
+ result = sd_mmc_check(0);
+ DEBUG_PRINT("sd_mmc_check(0) -> %d\n", result);
+ }
+
+ if (result != SD_MMC_OK) {
+ mp_raise_OSError_msg_varg(translate("%q failure: %d"), MP_QSTR_sd_mmc_check, (int)result);
+ }
+ // sd_mmc_get_capacity() is in KiB, but our "capacity" is in 512-byte blocks
+ self->capacity = sd_mmc_get_capacity(0) * 2;
+
+ DEBUG_PRINT("capacity=%u\n", self->capacity);
+}
+
+uint32_t common_hal_sdioio_sdcard_get_count(sdioio_sdcard_obj_t *self) {
+ return self->capacity;
+}
+
+uint32_t common_hal_sdioio_sdcard_get_frequency(sdioio_sdcard_obj_t *self) {
+ return self->frequency; // self->frequency;
+}
+
+uint8_t common_hal_sdioio_sdcard_get_width(sdioio_sdcard_obj_t *self) {
+ return self->num_data; // self->width;
+}
+
+STATIC void check_for_deinit(sdioio_sdcard_obj_t *self) {
+}
+
+STATIC void check_whole_block(mp_buffer_info_t *bufinfo) {
+ if (bufinfo->len % 512) {
+ mp_raise_ValueError(translate("Buffer length must be a multiple of 512"));
+ }
+}
+
+STATIC void wait_write_complete(sdioio_sdcard_obj_t *self) {
+ if (self->state_programming) {
+ sd_mmc_wait_end_of_write_blocks(0);
+ self->state_programming = 0;
+ }
+}
+
+STATIC void debug_print_state(sdioio_sdcard_obj_t *self, const char *what, sd_mmc_err_t r) {
+#if DEBUG_SDIO
+ DEBUG_PRINT("%s: %d\n", what, r);
+#endif
+}
+
+int common_hal_sdioio_sdcard_writeblocks(sdioio_sdcard_obj_t *self, uint32_t start_block, mp_buffer_info_t *bufinfo) {
+ check_for_deinit(self);
+ check_whole_block(bufinfo);
+ wait_write_complete(self);
+ self->state_programming = true;
+ sd_mmc_err_t r = sd_mmc_init_write_blocks(0, start_block, bufinfo->len / 512);
+ if (r != SD_MMC_OK) {
+ debug_print_state(self, "sd_mmc_init_write_blocks", r);
+ return -EIO;
+ }
+ r = sd_mmc_start_write_blocks(bufinfo->buf, bufinfo->len / 512);
+ if (r != SD_MMC_OK) {
+ debug_print_state(self, "sd_mmc_start_write_blocks", r);
+ return -EIO;
+ }
+ // debug_print_state(self, "after writeblocks OK");
+ return 0;
+}
+
+int common_hal_sdioio_sdcard_readblocks(sdioio_sdcard_obj_t *self, uint32_t start_block, mp_buffer_info_t *bufinfo) {
+ check_for_deinit(self);
+ check_whole_block(bufinfo);
+ wait_write_complete(self);
+ sd_mmc_err_t r = sd_mmc_init_read_blocks(0, start_block, bufinfo->len / 512);
+ if (r != SD_MMC_OK) {
+ debug_print_state(self, "sd_mmc_init_read_blocks", r);
+ return -EIO;
+ }
+ r = sd_mmc_start_read_blocks(bufinfo->buf, bufinfo->len / 512);
+ if (r != SD_MMC_OK) {
+ debug_print_state(self, "sd_mmc_start_read_blocks", r);
+ return -EIO;
+ }
+ sd_mmc_wait_end_of_write_blocks(0);
+ return 0;
+}
+
+bool common_hal_sdioio_sdcard_configure(sdioio_sdcard_obj_t *self, uint32_t frequency, uint8_t bits) {
+ check_for_deinit(self);
+ return true;
+}
+
+bool common_hal_sdioio_sdcard_deinited(sdioio_sdcard_obj_t *self) {
+ return self->command_pin == COMMON_HAL_MCU_NO_PIN;
+}
+
+void common_hal_sdioio_sdcard_deinit(sdioio_sdcard_obj_t *self) {
+ reset_pin_number(self->command_pin);
+ reset_pin_number(self->clock_pin);
+ reset_pin_number(self->data_pins[0]);
+ reset_pin_number(self->data_pins[1]);
+ reset_pin_number(self->data_pins[2]);
+ reset_pin_number(self->data_pins[3]);
+
+ self->command_pin = COMMON_HAL_MCU_NO_PIN;
+ self->clock_pin = COMMON_HAL_MCU_NO_PIN;
+ self->data_pins[0] = COMMON_HAL_MCU_NO_PIN;
+ self->data_pins[1] = COMMON_HAL_MCU_NO_PIN;
+ self->data_pins[2] = COMMON_HAL_MCU_NO_PIN;
+ self->data_pins[3] = COMMON_HAL_MCU_NO_PIN;
+}
+
+void common_hal_sdioio_sdcard_never_reset(sdioio_sdcard_obj_t *self) {
+}
diff --git a/ports/atmel-samd/common-hal/sdioio/SDCard.h b/ports/atmel-samd/common-hal/sdioio/SDCard.h
new file mode 100644
index 000000000..2baba38f0
--- /dev/null
+++ b/ports/atmel-samd/common-hal/sdioio/SDCard.h
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ */
+
+#pragma once
+
+#include "hal_mci_sync.h"
+
+typedef struct {
+ mp_obj_base_t base;
+ struct mci_sync_desc IO_BUS;
+ uint32_t frequency;
+ uint32_t capacity;
+ uint8_t num_data:3, state_programming:1, has_lock:1;
+ uint8_t command_pin;
+ uint8_t clock_pin;
+ uint8_t data_pins[4];
+} sdioio_sdcard_obj_t;
diff --git a/ports/atmel-samd/common-hal/sdioio/__init__.c b/ports/atmel-samd/common-hal/sdioio/__init__.c
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/ports/atmel-samd/common-hal/sdioio/__init__.c
diff --git a/ports/atmel-samd/common-hal/sdioio/__init__.h b/ports/atmel-samd/common-hal/sdioio/__init__.h
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/ports/atmel-samd/common-hal/sdioio/__init__.h
diff --git a/ports/atmel-samd/fatfs_port.c b/ports/atmel-samd/fatfs_port.c
index c4ce18c2a..c65a73a42 100644
--- a/ports/atmel-samd/fatfs_port.c
+++ b/ports/atmel-samd/fatfs_port.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/ports/atmel-samd/mpconfigport.h b/ports/atmel-samd/mpconfigport.h
index 354097ce4..540a2f77c 100644
--- a/ports/atmel-samd/mpconfigport.h
+++ b/ports/atmel-samd/mpconfigport.h
@@ -112,6 +112,14 @@
#define CIRCUITPY_DEFAULT_STACK_SIZE 4096
#endif
+#ifndef SAMD21_BOD33_LEVEL
+// Set brownout detection to ~2.7V. Default from factory is 1.7V,
+// which is too low for proper operation of external SPI flash chips
+// (they are 2.7-3.6V).
+#define SAMD21_BOD33_LEVEL (39)
+// 2.77V with hysteresis off. Table 37.20 in datasheet.
+#endif
+
// Smallest unit of flash that can be erased.
#define FLASH_ERASE_SIZE NVMCTRL_ROW_SIZE
@@ -129,6 +137,14 @@
#define CIRCUITPY_DEFAULT_STACK_SIZE (24*1024)
#endif
+#ifndef SAMD5x_E5x_BOD33_LEVEL
+// Set brownout detection to ~2.7V. Default from factory is 1.7V,
+// which is too low for proper operation of external SPI flash chips
+// (they are 2.7-3.6V).
+#define SAMD5x_E5x_BOD33_LEVEL (200)
+// 2.7V: 1.5V + LEVEL * 6mV.
+#endif
+
// Smallest unit of flash that can be erased.
#define FLASH_ERASE_SIZE NVMCTRL_BLOCK_SIZE
diff --git a/ports/atmel-samd/mpconfigport.mk b/ports/atmel-samd/mpconfigport.mk
index 92d47b186..e4cf9ca83 100644
--- a/ports/atmel-samd/mpconfigport.mk
+++ b/ports/atmel-samd/mpconfigport.mk
@@ -37,6 +37,8 @@ ifndef CIRCUITPY_TOUCHIO_USE_NATIVE
CIRCUITPY_TOUCHIO_USE_NATIVE = 1
endif
+CIRCUITPY_SDCARDIO ?= 0
+
# SAMD21 needs separate endpoint pairs for MSC BULK IN and BULK OUT, otherwise it's erratic.
USB_MSC_EP_NUM_OUT = 1
@@ -52,8 +54,7 @@ CIRCUITPY_TOUCHIO_USE_NATIVE = 0
# The ifndef's allow overriding in mpconfigboard.mk.
ifndef CIRCUITPY_NETWORK
-CIRCUITPY_NETWORK = 1
-MICROPY_PY_WIZNET5K = 5500
+CIRCUITPY_NETWORK = 0
endif
ifndef CIRCUITPY_PS2IO
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/atmel-samd/sd_mmc/conf_sd_mmc.h b/ports/atmel-samd/sd_mmc/conf_sd_mmc.h
new file mode 100644
index 000000000..735dd3783
--- /dev/null
+++ b/ports/atmel-samd/sd_mmc/conf_sd_mmc.h
@@ -0,0 +1,79 @@
+/* Auto-generated config file conf_sd_mmc.h */
+#ifndef CONF_SD_MMC_H
+#define CONF_SD_MMC_H
+
+// <<< Use Configuration Wizard in Context Menu >>>
+
+// <q> Enable the SDIO support
+// <id> conf_sdio_support
+#ifndef CONF_SDIO_SUPPORT
+#define CONF_SDIO_SUPPORT 0
+#endif
+
+// <q> Enable the MMC card support
+// <id> conf_mmc_support
+#ifndef CONF_MMC_SUPPORT
+#define CONF_MMC_SUPPORT 0
+#endif
+
+// <q> Enable the OS support
+// <id> conf_sd_mmc_os_support
+#ifndef CONF_OS_SUPPORT
+#define CONF_OS_SUPPORT 0
+#endif
+
+// Detection (card/write protect) timeout (ms/ticks)
+// conf_sd_mmc_debounce
+#ifndef CONF_SD_MMC_DEBOUNCE
+#define CONF_SD_MMC_DEBOUNCE 1000
+#endif
+
+#ifndef CONF_SD_MMC_MEM_CNT
+#define CONF_SD_MMC_MEM_CNT 1
+#endif
+
+// <e> SD/MMC Slot 0
+// <id> conf_sd_mmc_0_enable
+#ifndef CONF_SD_MMC_0_ENABLE
+#define CONF_SD_MMC_0_ENABLE 1
+#endif
+
+// <e> Card Detect (CD) 0 Enable
+// <id> conf_sd_mmc_0_cd_detect_en
+#ifndef CONF_SD_MMC_0_CD_DETECT_EN
+#define CONF_SD_MMC_0_CD_DETECT_EN 0
+#endif
+
+// <o> Card Detect (CD) detection level
+// <1=> High
+// <0=> Low
+// <id> conf_sd_mmc_0_cd_detect_value
+#ifndef CONF_SD_MMC_0_CD_DETECT_VALUE
+#define CONF_SD_MMC_0_CD_DETECT_VALUE 0
+#endif
+// </e>
+
+// <e> Write Protect (WP) 0 Enable
+// <id> conf_sd_mmc_0_wp_detect_en
+#ifndef CONF_SD_MMC_0_WP_DETECT_EN
+#define CONF_SD_MMC_0_WP_DETECT_EN 0
+#endif
+
+// <o> Write Protect (WP) detection level
+// <1=> High
+// <0=> Low
+// <id> conf_sd_mmc_0_wp_detect_value
+#ifndef CONF_SD_MMC_0_WP_DETECT_VALUE
+#define CONF_SD_MMC_0_WP_DETECT_VALUE 1
+#endif
+// </e>
+
+// </e>
+
+#ifndef CONF_MCI_OS_SUPPORT
+#define CONF_MCI_OS_SUPPORT 0
+#endif
+
+// <<< end of configuration section >>>
+
+#endif // CONF_SD_MMC_H
diff --git a/ports/atmel-samd/sd_mmc/sd_mmc.c b/ports/atmel-samd/sd_mmc/sd_mmc.c
new file mode 100644
index 000000000..5ea9d830e
--- /dev/null
+++ b/ports/atmel-samd/sd_mmc/sd_mmc.c
@@ -0,0 +1,1671 @@
+/**
+ * \file
+ *
+ * \brief Common SD/MMC stack
+ *
+ * Copyright (c) 2016-2018 Microchip Technology Inc. and its subsidiaries.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Subject to your compliance with these terms, you may use Microchip
+ * software and any derivatives exclusively with Microchip products.
+ * It is your responsibility to comply with third party license terms applicable
+ * to your use of third party software (including open source software) that
+ * may accompany Microchip software.
+ *
+ * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES,
+ * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE,
+ * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY,
+ * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE
+ * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL
+ * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE
+ * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE
+ * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT
+ * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY
+ * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
+ * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit <a href="https://www.microchip.com/support/">Microchip Support</a>
+ */
+
+#include <string.h>
+
+#include "conf_sd_mmc.h"
+
+#include "sd_mmc_protocol.h"
+#include "sd_mmc.h"
+
+#if CONF_OS_SUPPORT
+#include <hal_rtos.h>
+#endif
+#include <hal_gpio.h>
+#include <utils.h>
+#include <utils_assert.h>
+#include <utils_repeat_macro.h>
+
+#define TPASTE2(a, b) a##b
+#define ATPASTE2(a, b) TPASTE2(a, b)
+
+/**
+ * \ingroup sd_mmc_stack
+ * \defgroup sd_mmc_stack_internal Implementation of SD/MMC/SDIO Stack
+ * @{
+ */
+
+#ifndef CONF_SD_MMC_MEM_CNT
+#define CONF_SD_MMC_MEM_CNT 0
+#endif
+
+/* Macros to switch SD MMC stack to the correct driver (MCI or SPI) */
+#if (CONF_SD_MMC_MEM_CNT != 0)
+#if CONF_MCI_OS_SUPPORT
+#include "hal_mci_os.h"
+#else
+#include "hal_mci_sync.h"
+#endif
+#define driver mci
+#else
+#error No MCI or HSMCI interfaces are defined for SD MMC stack. \
+ CONF_SD_MMC_MEM_CNT must be added in board.h file.
+#endif
+
+#if CONF_MCI_OS_SUPPORT
+#define driver_select_device ATPASTE2(driver, _os_select_device)
+#define driver_deselect_device ATPASTE2(driver, _os_deselect_device)
+#define driver_get_bus_width ATPASTE2(driver, _os_get_bus_width)
+#define driver_is_high_speed_capable ATPASTE2(driver, _os_is_high_speed_capable)
+#define driver_send_clock ATPASTE2(driver, _os_send_init_sequence)
+#define driver_send_cmd ATPASTE2(driver, _os_send_cmd)
+#define driver_get_response ATPASTE2(driver, _os_get_response)
+#define driver_get_response_128 ATPASTE2(driver, _os_get_response_128)
+#define driver_adtc_start ATPASTE2(driver, _os_adtc_start)
+#define driver_adtc_stop ATPASTE2(driver, _os_send_cmd)
+#define driver_read_word ATPASTE2(driver, _os_read_bytes)
+#define driver_write_word ATPASTE2(driver, _os_write_bytes)
+#define driver_start_read_blocks ATPASTE2(driver, _os_start_read_blocks)
+#define driver_wait_end_of_read_blocks ATPASTE2(driver, _os_wait_end_of_read_blocks)
+#define driver_start_write_blocks ATPASTE2(driver, _os_start_write_blocks)
+#define driver_wait_end_of_write_blocks ATPASTE2(driver, _os_wait_end_of_write_blocks)
+#else
+#define driver_select_device ATPASTE2(driver, _sync_select_device)
+#define driver_deselect_device ATPASTE2(driver, _sync_deselect_device)
+#define driver_get_bus_width ATPASTE2(driver, _sync_get_bus_width)
+#define driver_is_high_speed_capable ATPASTE2(driver, _sync_is_high_speed_capable)
+#define driver_send_clock ATPASTE2(driver, _sync_send_clock)
+#define driver_send_cmd ATPASTE2(driver, _sync_send_cmd)
+#define driver_get_response ATPASTE2(driver, _sync_get_response)
+#define driver_get_response_128 ATPASTE2(driver, _sync_get_response_128)
+#define driver_adtc_start ATPASTE2(driver, _sync_adtc_start)
+#define driver_adtc_stop ATPASTE2(driver, _sync_send_cmd)
+#define driver_read_word ATPASTE2(driver, _sync_read_word)
+#define driver_write_word ATPASTE2(driver, _sync_write_word)
+#define driver_start_read_blocks ATPASTE2(driver, _sync_start_read_blocks)
+#define driver_wait_end_of_read_blocks ATPASTE2(driver, _sync_wait_end_of_read_blocks)
+#define driver_start_write_blocks ATPASTE2(driver, _sync_start_write_blocks)
+#define driver_wait_end_of_write_blocks ATPASTE2(driver, _sync_wait_end_of_write_blocks)
+#endif
+
+#if (CONF_SDIO_SUPPORT == 1)
+#define IS_SDIO() (sd_mmc_card->type & CARD_TYPE_SDIO)
+#else
+#define IS_SDIO() false
+#endif
+
+/** This SD MMC stack supports only the high voltage */
+#define SD_MMC_VOLTAGE_SUPPORT \
+ (OCR_VDD_27_28 | OCR_VDD_28_29 | OCR_VDD_29_30 | OCR_VDD_30_31 | OCR_VDD_31_32 | OCR_VDD_32_33)
+
+/** SD/MMC card states */
+enum card_state {
+ SD_MMC_CARD_STATE_READY = 0, /**< Ready to use */
+ SD_MMC_CARD_STATE_DEBOUNCE = 1, /**< Debounce on going */
+ SD_MMC_CARD_STATE_INIT = 2, /**< Initialization on going */
+ SD_MMC_CARD_STATE_UNUSABLE = 3, /**< Unusable card */
+ SD_MMC_CARD_STATE_NO_CARD = 4 /**< No SD/MMC card inserted */
+};
+
+/** SD/MMC card information structure */
+struct sd_mmc_card {
+ uint32_t clock; /**< Card access clock */
+ uint32_t capacity; /**< Card capacity in KBytes */
+ uint16_t rca; /**< Relative card address */
+ enum card_state state; /**< Card state */
+ card_type_t type; /**< Card type */
+ card_version_t version; /**< Card version */
+ uint8_t bus_width; /**< Number of DATA lin on bus (MCI only) */
+ uint8_t csd[CSD_REG_BSIZE]; /**< CSD register */
+ uint8_t high_speed; /**< High speed card (1) */
+};
+
+/** Card detect pin */
+static sd_mmc_detect_t *_cd;
+/** Write protect pin */
+static sd_mmc_detect_t *_wp;
+
+/** SD/MMC card list */
+/** Note: Initialize card detect pin fields if present */
+static struct sd_mmc_card sd_mmc_cards[CONF_SD_MMC_MEM_CNT];
+
+/** HAL driver instance */
+static void *sd_mmc_hal;
+/** Index of current slot configurated */
+static uint8_t sd_mmc_slot_sel;
+/** Pointer on current slot configurated */
+static struct sd_mmc_card *sd_mmc_card;
+/** Number of block to read or write on the current transfer */
+static uint16_t sd_mmc_nb_block_to_tranfer = 0;
+/** Number of block remaining to read or write on the current transfer */
+static uint16_t sd_mmc_nb_block_remaining = 0;
+
+/** SD/MMC transfer rate unit codes (10K) list */
+const uint32_t sd_mmc_trans_units[7] = {10, 100, 1000, 10000, 0, 0, 0};
+/** SD transfer multiplier factor codes (1/10) list */
+const uint32_t sd_trans_multipliers[16] = {0, 10, 12, 13, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 70, 80};
+/** MMC transfer multiplier factor codes (1/10) list */
+const uint32_t mmc_trans_multipliers[16] = {0, 10, 12, 13, 15, 20, 26, 30, 35, 40, 45, 52, 55, 60, 70, 80};
+
+/** \name MMC, SD and SDIO commands process */
+/** @{ */
+#if CONF_MMC_SUPPORT
+static bool mmc_mci_op_cond(void);
+static bool mmc_cmd6_set_bus_width(uint8_t bus_width);
+static bool mmc_cmd6_set_high_speed(void);
+static bool mmc_cmd8(uint8_t *b_authorize_high_speed);
+static void mmc_decode_csd(void);
+#endif
+static bool sd_mci_op_cond(uint8_t v2);
+static bool sdio_op_cond(void);
+static bool sdio_get_max_speed(void);
+static bool sdio_cmd52_set_bus_width(void);
+static bool sdio_cmd52_set_high_speed(void);
+static bool sd_cm6_set_high_speed(void);
+static bool sd_cmd8(uint8_t *v2);
+static bool sd_mmc_cmd9_mci(void);
+static void sd_decode_csd(void);
+static bool sd_mmc_cmd13(void);
+#if (CONF_SDIO_SUPPORT == 1)
+static bool sdio_cmd52(uint8_t rw_flag, uint8_t func_nb, uint32_t reg_addr, uint8_t rd_after_wr, uint8_t *io_data);
+static bool sdio_cmd53(uint8_t rw_flag, uint8_t func_nb, uint32_t reg_addr, uint8_t inc_addr, uint32_t size,
+ bool access_block);
+#endif
+static bool sd_acmd6(void);
+static bool sd_acmd51(void);
+/** @} */
+
+/** \name Internal function to process the initialization and install */
+/** @{ */
+static sd_mmc_err_t sd_mmc_select_slot(uint8_t slot);
+static void sd_mmc_configure_slot(void);
+static void sd_mmc_deselect_slot(void);
+static bool sd_mmc_mci_card_init(void);
+#if CONF_MMC_SUPPORT
+static bool sd_mmc_mci_install_mmc(void);
+#endif
+/** @} */
+
+/** \name Internal functions to manage a large timeout after a card insertion */
+/** @{ */
+#if CONF_OS_SUPPORT
+#define SD_MMC_START_TIMEOUT() os_sleep(CONF_SD_MMC_DEBOUNCE)
+#else
+#define SD_MMC_START_TIMEOUT()
+#endif
+#define SD_MMC_IS_TIMEOUT() true
+#define SD_MMC_STOP_TIMEOUT()
+/** @} */
+
+#if CONF_MMC_SUPPORT
+/**
+ * \brief Sends operation condition command and read OCR (MCI only)
+ * - CMD1 sends operation condition command
+ * - CMD1 reads OCR
+ *
+ * \return true if success, otherwise false
+ */
+static bool mmc_mci_op_cond(void)
+{
+ uint32_t retry, resp;
+
+ /*
+ * Timeout 1s = 400KHz / ((6+6)*8) cylces = 4200 retry
+ * 6 = cmd byte size
+ * 6 = response byte size
+ */
+ retry = 4200;
+ do {
+ if (!driver_send_cmd(sd_mmc_hal, MMC_MCI_CMD1_SEND_OP_COND, SD_MMC_VOLTAGE_SUPPORT | OCR_ACCESS_MODE_SECTOR)) {
+ return false;
+ }
+ /* Check busy flag */
+ resp = driver_get_response(sd_mmc_hal);
+ if (resp & OCR_POWER_UP_BUSY) {
+ /* Check OCR value */
+ if ((resp & OCR_ACCESS_MODE_MASK) == OCR_ACCESS_MODE_SECTOR) {
+ sd_mmc_card->type |= CARD_TYPE_HC;
+ }
+ break;
+ }
+ if (retry-- == 0) {
+ return false;
+ }
+ } while (1);
+ return true;
+}
+#endif
+
+/**
+ * \brief Ask to all cards to send their operations conditions (MCI only).
+ * - ACMD41 sends operation condition command.
+ * - ACMD41 reads OCR
+ *
+ * \param v2 Shall be 1 if it is a SD card V2
+ *
+ * \return true if success, otherwise false
+ */
+static bool sd_mci_op_cond(uint8_t v2)
+{
+ uint32_t arg, retry, resp;
+
+ /*
+ * Timeout 1s = 400KHz / ((6+6+6+6)*8) cylces = 2100 retry
+ * 6 = cmd byte size
+ * 6 = response byte size
+ * 6 = cmd byte size
+ * 6 = response byte size
+ */
+ retry = 2100;
+ do {
+ /* CMD55 - Indicate to the card that the next command is an
+ * application specific command rather than a standard command.*/
+ if (!driver_send_cmd(sd_mmc_hal, SDMMC_CMD55_APP_CMD, 0)) {
+ return false;
+ }
+
+ /* (ACMD41) Sends host OCR register */
+ arg = SD_MMC_VOLTAGE_SUPPORT;
+ if (v2) {
+ arg |= SD_ACMD41_HCS;
+ }
+ /* Check response */
+ if (!driver_send_cmd(sd_mmc_hal, SD_MCI_ACMD41_SD_SEND_OP_COND, arg)) {
+ return false;
+ }
+ resp = driver_get_response(sd_mmc_hal);
+ if (resp & OCR_POWER_UP_BUSY) {
+ /* Card is ready */
+ if ((resp & OCR_CCS) != 0) {
+ sd_mmc_card->type |= CARD_TYPE_HC;
+ }
+ break;
+ }
+ if (retry-- == 0) {
+ return false;
+ }
+ } while (1);
+ return true;
+}
+
+#if (CONF_SDIO_SUPPORT == 1)
+/**
+ * \brief Try to get the SDIO card's operating condition
+ * - CMD5 to read OCR NF field
+ * - CMD5 to wait OCR power up busy
+ * - CMD5 to read OCR MP field
+ * sd_mmc_card->type is updated
+ *
+ * \return true if success, otherwise false
+ */
+static bool sdio_op_cond(void)
+{
+ uint32_t resp;
+
+ /* CMD5 - SDIO send operation condition (OCR) command. */
+ if (!driver_send_cmd(sd_mmc_hal, SDIO_CMD5_SEND_OP_COND, 0)) {
+ return true; /* No error but card type not updated */
+ }
+ resp = driver_get_response(sd_mmc_hal);
+ if ((resp & OCR_SDIO_NF) == 0) {
+ return true; /* No error but card type not updated */
+ }
+
+ /*
+ * Wait card ready
+ * Timeout 1s = 400KHz / ((6+4)*8) cylces = 5000 retry
+ * 6 = cmd byte size
+ * 4(SPI) 6(MCI) = response byte size
+ */
+ uint32_t cmd5_retry = 5000;
+ while (1) {
+ /* CMD5 - SDIO send operation condition (OCR) command.*/
+ if (!driver_send_cmd(sd_mmc_hal, SDIO_CMD5_SEND_OP_COND, resp & SD_MMC_VOLTAGE_SUPPORT)) {
+ return false;
+ }
+ resp = driver_get_response(sd_mmc_hal);
+ if ((resp & OCR_POWER_UP_BUSY) == OCR_POWER_UP_BUSY) {
+ break;
+ }
+ if (cmd5_retry-- == 0) {
+ return false;
+ }
+ }
+ /* Update card type at the end of busy */
+ if ((resp & OCR_SDIO_MP) > 0) {
+ sd_mmc_card->type = CARD_TYPE_SD_COMBO;
+ } else {
+ sd_mmc_card->type = CARD_TYPE_SDIO;
+ }
+ return true; /* No error and card type updated with SDIO type */
+}
+
+/**
+ * \brief Get SDIO max transfer speed in Hz.
+ * - CMD53 reads CIS area address in CCCR area.
+ * - Nx CMD53 search Fun0 tuple in CIS area
+ * - CMD53 reads TPLFE_MAX_TRAN_SPEED in Fun0 tuple
+ * - Compute maximum speed of SDIO
+ * and update sd_mmc_card->clock
+ *
+ * \return true if success, otherwise false
+ */
+static bool sdio_get_max_speed(void)
+{
+ uint32_t addr_new, addr_old;
+ uint8_t buf[6];
+ uint32_t unit;
+ uint32_t mul;
+ uint8_t tplfe_max_tran_speed, i;
+ uint8_t addr_cis[4];
+
+ /* Read CIS area address in CCCR area */
+ addr_old = SDIO_CCCR_CIS_PTR;
+ for (i = 0; i < 4; i++) {
+ sdio_cmd52(SDIO_CMD52_READ_FLAG, SDIO_CIA, addr_old, 0, &addr_cis[i]);
+ addr_old++;
+ }
+ addr_old = addr_cis[0] + (addr_cis[1] << 8) + (addr_cis[2] << 16) + (addr_cis[3] << 24);
+ addr_new = addr_old;
+
+ while (1) {
+ /* Read a sample of CIA area */
+ for (i = 0; i < 3; i++) {
+ sdio_cmd52(SDIO_CMD52_READ_FLAG, SDIO_CIA, addr_new, 0, &buf[i]);
+ addr_new++;
+ }
+ if (buf[0] == SDIO_CISTPL_END) {
+ return false; /* Tuple error */
+ }
+ if (buf[0] == SDIO_CISTPL_FUNCE && buf[2] == 0x00) {
+ break; /* Fun0 tuple found */
+ }
+ if (buf[1] == 0) {
+ return false; /* Tuple error */
+ }
+ /* Next address */
+ addr_new += buf[1] - 1;
+ if (addr_new > (addr_old + 256)) {
+ return false; /* Outoff CIS area */
+ }
+ }
+
+ /* Read all Fun0 tuple fields: fn0_blk_siz & max_tran_speed */
+ addr_new -= 3;
+ for (i = 0; i < 6; i++) {
+ sdio_cmd52(SDIO_CMD52_READ_FLAG, SDIO_CIA, addr_new, 0, &buf[i]);
+ addr_new++;
+ }
+
+ tplfe_max_tran_speed = buf[5];
+ if (tplfe_max_tran_speed > 0x32) {
+ /* Error on SDIO register, the high speed is not activated
+ * and the clock can not be more than 25MHz.
+ * This error is present on specific SDIO card
+ * (H&D wireless card - HDG104 WiFi SIP).
+ */
+ tplfe_max_tran_speed = 0x32; /* 25Mhz */
+ }
+
+ /* Decode transfer speed in Hz.*/
+ unit = sd_mmc_trans_units[tplfe_max_tran_speed & 0x7];
+ mul = sd_trans_multipliers[(tplfe_max_tran_speed >> 3) & 0xF];
+ sd_mmc_card->clock = unit * mul * 1000;
+ /**
+ * Note: A combo card shall be a Full-Speed SDIO card
+ * which supports upto 25MHz.
+ * A SDIO card alone can be:
+ * - a Low-Speed SDIO card which supports 400Khz minimum
+ * - a Full-Speed SDIO card which supports upto 25MHz
+ */
+ return true;
+}
+
+/**
+ * \brief CMD52 for SDIO - Switches the bus width mode to 4
+ *
+ * \note sd_mmc_card->bus_width is updated.
+ *
+ * \return true if success, otherwise false
+ */
+static bool sdio_cmd52_set_bus_width(void)
+{
+ /**
+ * A SD memory card always supports bus 4bit
+ * A SD COMBO card always supports bus 4bit
+ * A SDIO Full-Speed alone always supports 4bit
+ * A SDIO Low-Speed alone can supports 4bit (Optional)
+ */
+ uint8_t u8_value;
+
+ /* Check 4bit support in 4BLS of "Card Capability" register */
+ if (!sdio_cmd52(SDIO_CMD52_READ_FLAG, SDIO_CIA, SDIO_CCCR_CAP, 0, &u8_value)) {
+ return false;
+ }
+ if ((u8_value & SDIO_CAP_4BLS) != SDIO_CAP_4BLS) {
+ /* No supported, it is not a protocol error */
+ return true;
+ }
+ /* HS mode possible, then enable */
+ u8_value = SDIO_BUSWIDTH_4B;
+ if (!sdio_cmd52(SDIO_CMD52_WRITE_FLAG, SDIO_CIA, SDIO_CCCR_BUS_CTRL, 1, &u8_value)) {
+ return false;
+ }
+ sd_mmc_card->bus_width = 4;
+ return true;
+}
+
+/**
+ * \brief CMD52 for SDIO - Enable the high speed mode
+ *
+ * \note sd_mmc_card->high_speed is updated.
+ * \note sd_mmc_card->clock is updated.
+ *
+ * \return true if success, otherwise false
+ */
+static bool sdio_cmd52_set_high_speed(void)
+{
+ uint8_t u8_value;
+
+ /* Check CIA.HS */
+ if (!sdio_cmd52(SDIO_CMD52_READ_FLAG, SDIO_CIA, SDIO_CCCR_HS, 0, &u8_value)) {
+ return false;
+ }
+ if ((u8_value & SDIO_SHS) != SDIO_SHS) {
+ /* No supported, it is not a protocol error */
+ return true;
+ }
+ /* HS mode possible, then enable */
+ u8_value = SDIO_EHS;
+ if (!sdio_cmd52(SDIO_CMD52_WRITE_FLAG, SDIO_CIA, SDIO_CCCR_HS, 1, &u8_value)) {
+ return false;
+ }
+ sd_mmc_card->high_speed = 1;
+ sd_mmc_card->clock *= 2;
+ return true;
+}
+
+#else
+static bool sdio_op_cond(void)
+{
+ return true; /* No error but card type not updated */
+}
+static bool sdio_get_max_speed(void)
+{
+ return false;
+}
+static bool sdio_cmd52_set_bus_width(void)
+{
+ return false;
+}
+static bool sdio_cmd52_set_high_speed(void)
+{
+ return false;
+}
+#endif
+
+/**
+ * \brief CMD6 for SD - Switch card in high speed mode
+ *
+ * \note CMD6 for SD is valid under the "trans" state.
+ * \note sd_mmc_card->high_speed is updated.
+ * \note sd_mmc_card->clock is updated.
+ *
+ * \return true if success, otherwise false
+ */
+static bool sd_cm6_set_high_speed(void)
+{
+ uint8_t switch_status[SD_SW_STATUS_BSIZE] = {0};
+
+ if (!driver_adtc_start(sd_mmc_hal,
+ SD_CMD6_SWITCH_FUNC,
+ SD_CMD6_MODE_SWITCH | SD_CMD6_GRP6_NO_INFLUENCE | SD_CMD6_GRP5_NO_INFLUENCE
+ | SD_CMD6_GRP4_NO_INFLUENCE | SD_CMD6_GRP3_NO_INFLUENCE | SD_CMD6_GRP2_DEFAULT
+ | SD_CMD6_GRP1_HIGH_SPEED,
+ SD_SW_STATUS_BSIZE,
+ 1,
+ true)) {
+ return false;
+ }
+ if (!driver_start_read_blocks(sd_mmc_hal, switch_status, 1)) {
+ return false;
+ }
+ if (!driver_wait_end_of_read_blocks(sd_mmc_hal)) {
+ return false;
+ }
+
+ if (driver_get_response(sd_mmc_hal) & CARD_STATUS_SWITCH_ERROR) {
+ return false;
+ }
+ if (SD_SW_STATUS_FUN_GRP1_RC(switch_status) == SD_SW_STATUS_FUN_GRP_RC_ERROR) {
+ /* No supported, it is not a protocol error */
+ return true;
+ }
+ if (SD_SW_STATUS_FUN_GRP1_BUSY(switch_status)) {
+ return false;
+ }
+ /* CMD6 function switching period is within 8 clocks
+ * after the end bit of status data.*/
+ driver_send_clock(sd_mmc_hal);
+ sd_mmc_card->high_speed = 1;
+ sd_mmc_card->clock *= 2;
+ return true;
+}
+
+#if CONF_MMC_SUPPORT
+
+/**
+ * \brief CMD6 for MMC - Switches the bus width mode
+ *
+ * \note CMD6 is valid under the "trans" state.
+ * \note sd_mmc_card->bus_width is updated.
+ *
+ * \param bus_width Bus width to set
+ *
+ * \return true if success, otherwise false
+ */
+static bool mmc_cmd6_set_bus_width(uint8_t bus_width)
+{
+ uint32_t arg;
+
+ switch (bus_width) {
+ case 8:
+ arg = MMC_CMD6_ACCESS_SET_BITS | MMC_CMD6_INDEX_BUS_WIDTH | MMC_CMD6_VALUE_BUS_WIDTH_8BIT;
+ break;
+ case 4:
+ arg = MMC_CMD6_ACCESS_SET_BITS | MMC_CMD6_INDEX_BUS_WIDTH | MMC_CMD6_VALUE_BUS_WIDTH_4BIT;
+ break;
+ default:
+ arg = MMC_CMD6_ACCESS_SET_BITS | MMC_CMD6_INDEX_BUS_WIDTH | MMC_CMD6_VALUE_BUS_WIDTH_1BIT;
+ break;
+ }
+ if (!driver_send_cmd(sd_mmc_hal, MMC_CMD6_SWITCH, arg)) {
+ return false;
+ }
+ if (driver_get_response(sd_mmc_hal) & CARD_STATUS_SWITCH_ERROR) {
+ /* No supported, it is not a protocol error */
+ return false;
+ }
+ sd_mmc_card->bus_width = bus_width;
+ return true;
+}
+
+/**
+ * \brief CMD6 for MMC - Switches in high speed mode
+ *
+ * \note CMD6 is valid under the "trans" state.
+ * \note sd_mmc_card->high_speed is updated.
+ * \note sd_mmc_card->clock is updated.
+ *
+ * \return true if success, otherwise false
+ */
+static bool mmc_cmd6_set_high_speed(void)
+{
+ if (!driver_send_cmd(sd_mmc_hal,
+ MMC_CMD6_SWITCH,
+ MMC_CMD6_ACCESS_WRITE_BYTE | MMC_CMD6_INDEX_HS_TIMING | MMC_CMD6_VALUE_HS_TIMING_ENABLE)) {
+ return false;
+ }
+ if (driver_get_response(sd_mmc_hal) & CARD_STATUS_SWITCH_ERROR) {
+ /* No supported, it is not a protocol error */
+ return false;
+ }
+ sd_mmc_card->high_speed = 1;
+ sd_mmc_card->clock = 52000000lu;
+ return true;
+}
+#endif
+
+/**
+ * \brief CMD8 for SD card - Send Interface Condition Command.
+ *
+ * \note
+ * Send SD Memory Card interface condition, which includes host supply
+ * voltage information and asks the card whether card supports voltage.
+ * Should be performed at initialization time to detect the card type.
+ *
+ * \param v2 Pointer to v2 flag to update
+ *
+ * \return true if success, otherwise false
+ * with a update of \ref sd_mmc_err.
+ */
+static bool sd_cmd8(uint8_t *v2)
+{
+ uint32_t resp;
+
+ *v2 = 0;
+ /* Test for SD version 2 */
+ if (!driver_send_cmd(sd_mmc_hal, SD_CMD8_SEND_IF_COND, SD_CMD8_PATTERN | SD_CMD8_HIGH_VOLTAGE)) {
+ return true; /* It is not a V2 */
+ }
+ /* Check R7 response */
+ resp = driver_get_response(sd_mmc_hal);
+ if (resp == 0xFFFFFFFF) {
+ /* No compliance R7 value */
+ return true; /* It is not a V2 */
+ }
+ if ((resp & (SD_CMD8_MASK_PATTERN | SD_CMD8_MASK_VOLTAGE)) != (SD_CMD8_PATTERN | SD_CMD8_HIGH_VOLTAGE)) {
+ return false;
+ }
+ *v2 = 1;
+ return true;
+}
+
+#if CONF_MMC_SUPPORT
+/**
+ * \brief CMD8 - The card sends its EXT_CSD register as a block of data.
+ *
+ * \param b_authorize_high_speed Pointer to update with the high speed
+ * support information
+ *
+ * \return true if success, otherwise false
+ */
+static bool mmc_cmd8(uint8_t *b_authorize_high_speed)
+{
+ uint16_t i;
+ uint32_t ext_csd;
+ uint32_t sec_count;
+
+ if (!driver_adtc_start(sd_mmc_hal, MMC_CMD8_SEND_EXT_CSD, 0, EXT_CSD_BSIZE, 1, false)) {
+ return false;
+ }
+ /* Read and decode Extended Extended CSD
+ * Note: The read access is done in byte to avoid a buffer
+ * of EXT_CSD_BSIZE Byte in stack.*/
+
+ /* Read card type */
+ for (i = 0; i < (EXT_CSD_CARD_TYPE_INDEX + 4) / 4; i++) {
+ if (!driver_read_word(sd_mmc_hal, &ext_csd)) {
+ return false;
+ }
+ }
+ *b_authorize_high_speed = (ext_csd >> ((EXT_CSD_CARD_TYPE_INDEX % 4) * 8)) & MMC_CTYPE_52MHZ;
+
+ if (MMC_CSD_C_SIZE(sd_mmc_card->csd) == 0xFFF) {
+ /* For high capacity SD/MMC card,
+ * memory capacity = SEC_COUNT * 512 byte */
+ for (; i < (EXT_CSD_SEC_COUNT_INDEX + 4) / 4; i++) {
+ if (!driver_read_word(sd_mmc_hal, &sec_count)) {
+ return false;
+ }
+ }
+ sd_mmc_card->capacity = sec_count / 2;
+ }
+ for (; i < EXT_CSD_BSIZE / 4; i++) {
+ if (!driver_read_word(sd_mmc_hal, &sec_count)) {
+ return false;
+ }
+ }
+ return true;
+}
+
+#endif
+
+/**
+ * \brief CMD9: Addressed card sends its card-specific
+ * data (CSD) on the CMD line mci.
+ *
+ * \return true if success, otherwise false
+ */
+static bool sd_mmc_cmd9_mci(void)
+{
+ if (!driver_send_cmd(sd_mmc_hal, SDMMC_MCI_CMD9_SEND_CSD, (uint32_t)sd_mmc_card->rca << 16)) {
+ return false;
+ }
+ driver_get_response_128(sd_mmc_hal, sd_mmc_card->csd);
+ return true;
+}
+
+#if CONF_MMC_SUPPORT
+/**
+ * \brief Decodes MMC CSD register
+ */
+static void mmc_decode_csd(void)
+{
+ uint32_t unit;
+ uint32_t mul;
+ uint32_t tran_speed;
+
+ /* Get MMC System Specification version supported by the card */
+ switch (MMC_CSD_SPEC_VERS(sd_mmc_card->csd)) {
+ default:
+ case 0:
+ sd_mmc_card->version = CARD_VER_MMC_1_2;
+ break;
+
+ case 1:
+ sd_mmc_card->version = CARD_VER_MMC_1_4;
+ break;
+
+ case 2:
+ sd_mmc_card->version = CARD_VER_MMC_2_2;
+ break;
+
+ case 3:
+ sd_mmc_card->version = CARD_VER_MMC_3;
+ break;
+
+ case 4:
+ sd_mmc_card->version = CARD_VER_MMC_4;
+ break;
+ }
+
+ /* Get MMC memory max transfer speed in Hz.*/
+ tran_speed = CSD_TRAN_SPEED(sd_mmc_card->csd);
+ unit = sd_mmc_trans_units[tran_speed & 0x7];
+ mul = mmc_trans_multipliers[(tran_speed >> 3) & 0xF];
+ sd_mmc_card->clock = unit * mul * 1000;
+
+ /*
+ * Get card capacity.
+ * ----------------------------------------------------
+ * For normal SD/MMC card:
+ * memory capacity = BLOCKNR * BLOCK_LEN
+ * Where
+ * BLOCKNR = (C_SIZE+1) * MULT
+ * MULT = 2 ^ (C_SIZE_MULT+2) (C_SIZE_MULT < 8)
+ * BLOCK_LEN = 2 ^ READ_BL_LEN (READ_BL_LEN < 12)
+ * ----------------------------------------------------
+ * For high capacity SD/MMC card:
+ * memory capacity = SEC_COUNT * 512 byte
+ */
+ if (MMC_CSD_C_SIZE(sd_mmc_card->csd) != 0xFFF) {
+ uint32_t blocknr
+ = ((MMC_CSD_C_SIZE(sd_mmc_card->csd) + 1) * (1 << (MMC_CSD_C_SIZE_MULT(sd_mmc_card->csd) + 2)));
+ sd_mmc_card->capacity = blocknr * (1 << MMC_CSD_READ_BL_LEN(sd_mmc_card->csd)) / 1024;
+ }
+}
+#endif
+
+/**
+ * \brief Decodes SD CSD register
+ */
+static void sd_decode_csd(void)
+{
+ uint32_t unit;
+ uint32_t mul;
+ uint32_t tran_speed;
+
+ /* Get SD memory maximum transfer speed in Hz. */
+ tran_speed = CSD_TRAN_SPEED(sd_mmc_card->csd);
+ unit = sd_mmc_trans_units[tran_speed & 0x7];
+ mul = sd_trans_multipliers[(tran_speed >> 3) & 0xF];
+ sd_mmc_card->clock = unit * mul * 1000;
+
+ /*
+ * Get card capacity.
+ * ----------------------------------------------------
+ * For normal SD/MMC card:
+ * memory capacity = BLOCKNR * BLOCK_LEN
+ * Where
+ * BLOCKNR = (C_SIZE+1) * MULT
+ * MULT = 2 ^ (C_SIZE_MULT+2) (C_SIZE_MULT < 8)
+ * BLOCK_LEN = 2 ^ READ_BL_LEN (READ_BL_LEN < 12)
+ * ----------------------------------------------------
+ * For high capacity SD card:
+ * memory capacity = (C_SIZE+1) * 512K byte
+ */
+ if (CSD_STRUCTURE_VERSION(sd_mmc_card->csd) >= SD_CSD_VER_2_0) {
+ sd_mmc_card->capacity = (SD_CSD_2_0_C_SIZE(sd_mmc_card->csd) + 1) * 512;
+ } else {
+ uint32_t blocknr
+ = ((SD_CSD_1_0_C_SIZE(sd_mmc_card->csd) + 1) * (1 << (SD_CSD_1_0_C_SIZE_MULT(sd_mmc_card->csd) + 2)));
+ sd_mmc_card->capacity = blocknr * (1 << SD_CSD_1_0_READ_BL_LEN(sd_mmc_card->csd)) / 1024;
+ }
+}
+
+/**
+ * \brief CMD13 - Addressed card sends its status register.
+ * This function waits the clear of the busy flag
+ *
+ * \return true if success, otherwise false
+ */
+static bool sd_mmc_cmd13(void)
+{
+ uint32_t nec_timeout;
+
+ /* Wait for data ready status.
+ * Nec timing: 0 to unlimited
+ * However a timeout is used.
+ * 200 000 * 8 cycles
+ */
+ nec_timeout = 200000;
+ do {
+ if (!driver_send_cmd(sd_mmc_hal, SDMMC_MCI_CMD13_SEND_STATUS, (uint32_t)sd_mmc_card->rca << 16)) {
+ return false;
+ }
+ /* Check busy flag */
+ if (driver_get_response(sd_mmc_hal) & CARD_STATUS_READY_FOR_DATA) {
+ break;
+ }
+ if (nec_timeout-- == 0) {
+ return false;
+ }
+ } while (1);
+
+ return true;
+}
+
+#if (CONF_SDIO_SUPPORT == 1)
+/**
+ * \brief CMD52 - SDIO IO_RW_DIRECT command
+ *
+ * \param rw_flag Direction, 1:write, 0:read.
+ * \param func_nb Number of the function.
+ * \param rd_after_wr Read after Write flag.
+ * \param reg_addr register address.
+ * \param io_data Pointer to input argument and response buffer.
+ *
+ * \return true if success, otherwise false
+ */
+static bool sdio_cmd52(uint8_t rw_flag, uint8_t func_nb, uint32_t reg_addr, uint8_t rd_after_wr, uint8_t *io_data)
+{
+ ASSERT(io_data != NULL);
+ if (!driver_send_cmd(sd_mmc_hal,
+ SDIO_CMD52_IO_RW_DIRECT,
+ ((uint32_t)*io_data << SDIO_CMD52_WR_DATA) | ((uint32_t)rw_flag << SDIO_CMD52_RW_FLAG)
+ | ((uint32_t)func_nb << SDIO_CMD52_FUNCTION_NUM)
+ | ((uint32_t)rd_after_wr << SDIO_CMD52_RAW_FLAG)
+ | ((uint32_t)reg_addr << SDIO_CMD52_REG_ADRR))) {
+ return false;
+ }
+ *io_data = driver_get_response(sd_mmc_hal) & 0xFF;
+ return true;
+}
+
+/**
+ * \brief CMD53 - SDIO IO_RW_EXTENDED command
+ * This implementation support only the SDIO multi-byte transfer mode which is
+ * similar to the single block transfer on memory.
+ * Note: The SDIO block transfer mode is optional for SDIO card.
+ *
+ * \param rw_flag Direction, 1:write, 0:read.
+ * \param func_nb Number of the function.
+ * \param reg_addr Register address.
+ * \param inc_addr 1:Incrementing address, 0: fixed.
+ * \param size Transfer data size.
+ * \param access_block true, if the block access (DMA) is used
+ *
+ * \return true if success, otherwise false
+ */
+static bool sdio_cmd53(uint8_t rw_flag, uint8_t func_nb, uint32_t reg_addr, uint8_t inc_addr, uint32_t size,
+ bool access_block)
+{
+ ASSERT(size != 0);
+ ASSERT(size <= 512);
+
+ return driver_adtc_start(
+ sd_mmc_hal,
+ (rw_flag == SDIO_CMD53_READ_FLAG) ? SDIO_CMD53_IO_R_BYTE_EXTENDED : SDIO_CMD53_IO_W_BYTE_EXTENDED,
+ ((size % 512) << SDIO_CMD53_COUNT) | ((uint32_t)reg_addr << SDIO_CMD53_REG_ADDR)
+ | ((uint32_t)inc_addr << SDIO_CMD53_OP_CODE) | ((uint32_t)0 << SDIO_CMD53_BLOCK_MODE)
+ | ((uint32_t)func_nb << SDIO_CMD53_FUNCTION_NUM) | ((uint32_t)rw_flag << SDIO_CMD53_RW_FLAG),
+ size,
+ 1,
+ access_block);
+}
+#endif
+
+/**
+ * \brief ACMD6 - Define the data bus width to 4 bits bus
+ *
+ * \return true if success, otherwise false
+ */
+static bool sd_acmd6(void)
+{
+ /* CMD55 - Indicate to the card that the next command is an
+ * application specific command rather than a standard command.*/
+ if (!driver_send_cmd(sd_mmc_hal, SDMMC_CMD55_APP_CMD, (uint32_t)sd_mmc_card->rca << 16)) {
+ return false;
+ }
+ /* 10b = 4 bits bus */
+ if (!driver_send_cmd(sd_mmc_hal, SD_ACMD6_SET_BUS_WIDTH, 0x2)) {
+ return false;
+ }
+ sd_mmc_card->bus_width = 4;
+ return true;
+}
+
+/**
+ * \brief ACMD51 - Read the SD Configuration Register.
+ *
+ * \note
+ * SD Card Configuration Register (SCR) provides information on the SD Memory
+ * Card's special features that were configured into the given card. The size
+ * of SCR register is 64 bits.
+ *
+ *
+ * \return true if success, otherwise false
+ */
+static bool sd_acmd51(void)
+{
+ uint8_t scr[SD_SCR_REG_BSIZE];
+
+ /* CMD55 - Indicate to the card that the next command is an
+ * application specific command rather than a standard command.*/
+ if (!driver_send_cmd(sd_mmc_hal, SDMMC_CMD55_APP_CMD, (uint32_t)sd_mmc_card->rca << 16)) {
+ return false;
+ }
+ if (!driver_adtc_start(sd_mmc_hal, SD_ACMD51_SEND_SCR, 0, SD_SCR_REG_BSIZE, 1, true)) {
+ return false;
+ }
+ if (!driver_start_read_blocks(sd_mmc_hal, scr, 1)) {
+ return false;
+ }
+ if (!driver_wait_end_of_read_blocks(sd_mmc_hal)) {
+ return false;
+ }
+
+ /* Get SD Memory Card - Spec. Version */
+ switch (SD_SCR_SD_SPEC(scr)) {
+ case SD_SCR_SD_SPEC_1_0_01:
+ sd_mmc_card->version = CARD_VER_SD_1_0;
+ break;
+
+ case SD_SCR_SD_SPEC_1_10:
+ sd_mmc_card->version = CARD_VER_SD_1_10;
+ break;
+
+ case SD_SCR_SD_SPEC_2_00:
+ if (SD_SCR_SD_SPEC3(scr) == SD_SCR_SD_SPEC_3_00) {
+ sd_mmc_card->version = CARD_VER_SD_3_0;
+ } else {
+ sd_mmc_card->version = CARD_VER_SD_2_0;
+ }
+ break;
+
+ default:
+ sd_mmc_card->version = CARD_VER_SD_1_0;
+ break;
+ }
+ return true;
+}
+
+/**
+ * \brief Select a card slot and initialize the associated driver
+ *
+ * \param slot Card slot number
+ *
+ * \retval SD_MMC_ERR_SLOT Wrong slot number
+ * \retval SD_MMC_ERR_NO_CARD No card present on slot
+ * \retval SD_MMC_ERR_UNUSABLE Unusable card
+ * \retval SD_MMC_INIT_ONGOING Card initialization requested
+ * \retval SD_MMC_OK Card present
+ */
+static sd_mmc_err_t sd_mmc_select_slot(uint8_t slot)
+{
+ if (slot >= CONF_SD_MMC_MEM_CNT) {
+ return SD_MMC_ERR_SLOT;
+ }
+
+ if (_cd && _cd[slot].pin != -1) {
+ /** Card Detect pins */
+ if (gpio_get_pin_level(_cd[slot].pin) != _cd[slot].val) {
+ if (sd_mmc_cards[slot].state == SD_MMC_CARD_STATE_DEBOUNCE) {
+ SD_MMC_STOP_TIMEOUT();
+ }
+ sd_mmc_cards[slot].state = SD_MMC_CARD_STATE_NO_CARD;
+ return SD_MMC_ERR_NO_CARD;
+ }
+ if (sd_mmc_cards[slot].state == SD_MMC_CARD_STATE_NO_CARD) {
+ /* A card plug on going, but this is not initialized */
+ sd_mmc_cards[slot].state = SD_MMC_CARD_STATE_DEBOUNCE;
+ /* Debounce + Power On Setup */
+ SD_MMC_START_TIMEOUT();
+ return SD_MMC_ERR_NO_CARD;
+ }
+ if (sd_mmc_cards[slot].state == SD_MMC_CARD_STATE_DEBOUNCE) {
+ if (!SD_MMC_IS_TIMEOUT()) {
+ /* Debounce on going */
+ return SD_MMC_ERR_NO_CARD;
+ }
+ /* Card is not initialized */
+ sd_mmc_cards[slot].state = SD_MMC_CARD_STATE_INIT;
+ /* Set 1-bit bus width and low clock for initialization */
+ sd_mmc_cards[slot].clock = SDMMC_CLOCK_INIT;
+ sd_mmc_cards[slot].bus_width = 1;
+ sd_mmc_cards[slot].high_speed = 0;
+ }
+ if (sd_mmc_cards[slot].state == SD_MMC_CARD_STATE_UNUSABLE) {
+ return SD_MMC_ERR_UNUSABLE;
+ }
+ } else {
+ /* No pin card detection, then always try to install it */
+ if ((sd_mmc_cards[slot].state == SD_MMC_CARD_STATE_NO_CARD)
+ || (sd_mmc_cards[slot].state == SD_MMC_CARD_STATE_UNUSABLE)) {
+ /* Card is not initialized */
+ sd_mmc_cards[slot].state = SD_MMC_CARD_STATE_INIT;
+ /* Set 1-bit bus width and low clock for initialization */
+ sd_mmc_cards[slot].clock = SDMMC_CLOCK_INIT;
+ sd_mmc_cards[slot].bus_width = 1;
+ sd_mmc_cards[slot].high_speed = 0;
+ }
+ }
+
+ ASSERT(!(sd_mmc_slot_sel != slot && sd_mmc_nb_block_remaining != 0));
+
+ /* Initialize interface */
+ sd_mmc_slot_sel = slot;
+ sd_mmc_card = &sd_mmc_cards[slot];
+ sd_mmc_configure_slot();
+ return (sd_mmc_cards[slot].state == SD_MMC_CARD_STATE_INIT) ? SD_MMC_INIT_ONGOING : SD_MMC_OK;
+}
+
+/**
+ * \brief Configures the driver with the selected card configuration
+ */
+static void sd_mmc_configure_slot(void)
+{
+ driver_select_device(
+ sd_mmc_hal, sd_mmc_slot_sel, sd_mmc_card->clock, sd_mmc_card->bus_width, sd_mmc_card->high_speed);
+}
+
+/**
+ * \brief Deselect the current card slot
+ */
+static void sd_mmc_deselect_slot(void)
+{
+ if (sd_mmc_slot_sel < CONF_SD_MMC_MEM_CNT) {
+ driver_deselect_device(sd_mmc_hal, sd_mmc_slot_sel);
+ }
+}
+
+/**
+ * \brief Initialize the SD card in MCI mode.
+ *
+ * \note
+ * This function runs the initialization procedure and the identification
+ * process, then it sets the SD/MMC card in transfer state.
+ * At last, it will automaticly enable maximum bus width and transfer speed.
+ *
+ * \return true if success, otherwise false
+ */
+static bool sd_mmc_mci_card_init(void)
+{
+ uint8_t v2 = 0;
+#if (CONF_SDIO_SUPPORT == 1)
+ uint8_t data = 0x08;
+#endif
+
+ /* In first, try to install SD/SDIO card */
+ sd_mmc_card->type = CARD_TYPE_SD;
+ sd_mmc_card->version = CARD_VER_UNKNOWN;
+ sd_mmc_card->rca = 0;
+
+ /* Card need of 74 cycles clock minimum to start */
+ driver_send_clock(sd_mmc_hal);
+
+#if (CONF_SDIO_SUPPORT == 1)
+ /* CMD52 Reset SDIO */
+ sdio_cmd52(SDIO_CMD52_WRITE_FLAG, SDIO_CIA, SDIO_CCCR_IOA, 0, &data);
+#endif
+
+ /* CMD0 - Reset all cards to idle state.*/
+ if (!driver_send_cmd(sd_mmc_hal, SDMMC_MCI_CMD0_GO_IDLE_STATE, 0)) {
+ return false;
+ }
+ if (!sd_cmd8(&v2)) {
+ return false;
+ }
+ /* Try to get the SDIO card's operating condition */
+ if (!sdio_op_cond()) {
+ return false;
+ }
+
+ if (sd_mmc_card->type & CARD_TYPE_SD) {
+ /* Try to get the SD card's operating condition */
+ if (!sd_mci_op_cond(v2)) {
+ /* It is not a SD card */
+#if CONF_MMC_SUPPORT
+ sd_mmc_card->type = CARD_TYPE_MMC;
+ return sd_mmc_mci_install_mmc();
+#else
+ sd_mmc_card->type = CARD_TYPE_UNKNOWN;
+ return false;
+#endif
+ }
+ }
+
+ if (sd_mmc_card->type & CARD_TYPE_SD) {
+ /* SD MEMORY, Put the Card in Identify Mode
+ * Note: The CID is not used in this stack */
+ if (!driver_send_cmd(sd_mmc_hal, SDMMC_CMD2_ALL_SEND_CID, 0)) {
+ return false;
+ }
+ }
+ /* Ask the card to publish a new relative address (RCA).*/
+ if (!driver_send_cmd(sd_mmc_hal, SD_CMD3_SEND_RELATIVE_ADDR, 0)) {
+ return false;
+ }
+ sd_mmc_card->rca = (driver_get_response(sd_mmc_hal) >> 16) & 0xFFFF;
+
+ /* SD MEMORY, Get the Card-Specific Data */
+ if (sd_mmc_card->type & CARD_TYPE_SD) {
+ if (!sd_mmc_cmd9_mci()) {
+ return false;
+ }
+ sd_decode_csd();
+ }
+ /* Select the and put it into Transfer Mode */
+ if (!driver_send_cmd(sd_mmc_hal, SDMMC_CMD7_SELECT_CARD_CMD, (uint32_t)sd_mmc_card->rca << 16)) {
+ return false;
+ }
+ /* SD MEMORY, Read the SCR to get card version */
+ if (sd_mmc_card->type & CARD_TYPE_SD) {
+ if (!sd_acmd51()) {
+ return false;
+ }
+ }
+ if (IS_SDIO()) {
+ if (!sdio_get_max_speed()) {
+ return false;
+ }
+ }
+ if ((4 <= driver_get_bus_width(sd_mmc_hal, sd_mmc_slot_sel))) {
+ /* TRY to enable 4-bit mode */
+ if (IS_SDIO()) {
+ if (!sdio_cmd52_set_bus_width()) {
+ return false;
+ }
+ }
+ if (sd_mmc_card->type & CARD_TYPE_SD) {
+ if (!sd_acmd6()) {
+ return false;
+ }
+ }
+ /* Switch to selected bus mode */
+ sd_mmc_configure_slot();
+ }
+ if (driver_is_high_speed_capable(sd_mmc_hal)) {
+ /* TRY to enable High-Speed Mode */
+ if (IS_SDIO()) {
+ if (!sdio_cmd52_set_high_speed()) {
+ return false;
+ }
+ }
+ if (sd_mmc_card->type & CARD_TYPE_SD) {
+ if (sd_mmc_card->version > CARD_VER_SD_1_0) {
+ if (!sd_cm6_set_high_speed()) {
+ return false;
+ }
+ }
+ }
+ /* Valid new configuration */
+ sd_mmc_configure_slot();
+ }
+ /* SD MEMORY, Set default block size */
+ if (sd_mmc_card->type & CARD_TYPE_SD) {
+ if (!driver_send_cmd(sd_mmc_hal, SDMMC_CMD16_SET_BLOCKLEN, SD_MMC_BLOCK_SIZE)) {
+ return false;
+ }
+ }
+ return true;
+}
+
+#if CONF_MMC_SUPPORT
+/**
+ * \brief Initialize the MMC card in MCI mode.
+ *
+ * \note
+ * This function runs the initialization procedure and the identification
+ * process, then it sets the SD/MMC card in transfer state.
+ * At last, it will automaticly enable maximum bus width and transfer speed.
+ *
+ * \return true if success, otherwise false
+ */
+static bool sd_mmc_mci_install_mmc(void)
+{
+ uint8_t b_authorize_high_speed;
+
+ /* CMD0 - Reset all cards to idle state. */
+ if (!driver_send_cmd(sd_mmc_hal, SDMMC_MCI_CMD0_GO_IDLE_STATE, 0)) {
+ return false;
+ }
+
+ if (!mmc_mci_op_cond()) {
+ return false;
+ }
+
+ /* Put the Card in Identify Mode
+ * Note: The CID is not used in this stack*/
+ if (!driver_send_cmd(sd_mmc_hal, SDMMC_CMD2_ALL_SEND_CID, 0)) {
+ return false;
+ }
+ /* Assign relative address to the card.*/
+ sd_mmc_card->rca = 1;
+ if (!driver_send_cmd(sd_mmc_hal, MMC_CMD3_SET_RELATIVE_ADDR, (uint32_t)sd_mmc_card->rca << 16)) {
+ return false;
+ }
+ /* Get the Card-Specific Data */
+ if (!sd_mmc_cmd9_mci()) {
+ return false;
+ }
+ mmc_decode_csd();
+ /* Select the and put it into Transfer Mode */
+ if (!driver_send_cmd(sd_mmc_hal, SDMMC_CMD7_SELECT_CARD_CMD, (uint32_t)sd_mmc_card->rca << 16)) {
+ return false;
+ }
+ if (sd_mmc_card->version >= CARD_VER_MMC_4) {
+ /* For MMC 4.0 Higher version
+ * Get EXT_CSD */
+ if (!mmc_cmd8(&b_authorize_high_speed)) {
+ return false;
+ }
+ if (4 <= driver_get_bus_width(sd_mmc_hal, sd_mmc_slot_sel)) {
+ /* Enable more bus width */
+ if (!mmc_cmd6_set_bus_width(driver_get_bus_width(sd_mmc_hal, sd_mmc_slot_sel))) {
+ return false;
+ }
+ /* Reinitialize the slot with the bus width */
+ sd_mmc_configure_slot();
+ }
+ if (driver_is_high_speed_capable(sd_mmc_hal) && b_authorize_high_speed) {
+ /* Enable HS */
+ if (!mmc_cmd6_set_high_speed()) {
+ return false;
+ }
+ /* Reinitialize the slot with the new speed */
+ sd_mmc_configure_slot();
+ }
+ } else {
+ /* Reinitialize the slot with the new speed */
+ sd_mmc_configure_slot();
+ }
+
+ uint8_t retry = 10;
+ while (retry--) {
+ /* Retry is a WORKAROUND for no compliance card (Atmel Internal ref. MMC19):
+ * These cards seem not ready immediatly
+ * after the end of busy of mmc_cmd6_set_high_speed()*/
+
+ /* Set default block size */
+ if (driver_send_cmd(sd_mmc_hal, SDMMC_CMD16_SET_BLOCKLEN, SD_MMC_BLOCK_SIZE)) {
+ return true;
+ }
+ }
+ return false;
+}
+#endif
+
+/*--------------------- PUBLIC FUNCTIONS ----------------------------*/
+
+void sd_mmc_init(void *hal, sd_mmc_detect_t *card_detects, sd_mmc_detect_t *wp_detects)
+{
+ /* GPIO will be used to detect card and write protect.
+ * The related clocks and pinmux must be configurated in good
+ * condition. */
+
+ for (uint8_t slot = 0; slot < CONF_SD_MMC_MEM_CNT; slot++) {
+ sd_mmc_cards[slot].state = SD_MMC_CARD_STATE_NO_CARD;
+ }
+ sd_mmc_slot_sel = 0xFF; /* No slot configurated */
+ sd_mmc_hal = hal;
+ _cd = card_detects;
+ _wp = wp_detects;
+}
+
+uint8_t sd_mmc_nb_slot(void)
+{
+ return CONF_SD_MMC_MEM_CNT;
+}
+
+sd_mmc_err_t sd_mmc_check(uint8_t slot)
+{
+ sd_mmc_err_t sd_mmc_err;
+
+ sd_mmc_err = sd_mmc_select_slot(slot);
+ if (sd_mmc_err != SD_MMC_INIT_ONGOING) {
+ sd_mmc_deselect_slot();
+ return sd_mmc_err;
+ }
+
+ /* Initialization of the card requested */
+ if (sd_mmc_mci_card_init()) {
+ sd_mmc_card->state = SD_MMC_CARD_STATE_READY;
+ sd_mmc_deselect_slot();
+ /* To notify that the card has been just initialized
+ * It is necessary for USB Device MSC */
+ return SD_MMC_INIT_ONGOING;
+ }
+ sd_mmc_card->state = SD_MMC_CARD_STATE_UNUSABLE;
+ sd_mmc_deselect_slot();
+ return SD_MMC_ERR_UNUSABLE;
+}
+
+card_type_t sd_mmc_get_type(uint8_t slot)
+{
+ if (SD_MMC_OK != sd_mmc_select_slot(slot)) {
+ return CARD_TYPE_UNKNOWN;
+ }
+ sd_mmc_deselect_slot();
+ return sd_mmc_card->type;
+}
+
+card_version_t sd_mmc_get_version(uint8_t slot)
+{
+ if (SD_MMC_OK != sd_mmc_select_slot(slot)) {
+ return CARD_VER_UNKNOWN;
+ }
+ sd_mmc_deselect_slot();
+ return sd_mmc_card->version;
+}
+
+uint32_t sd_mmc_get_capacity(uint8_t slot)
+{
+ if (SD_MMC_OK != sd_mmc_select_slot(slot)) {
+ return 0;
+ }
+ sd_mmc_deselect_slot();
+ return sd_mmc_card->capacity;
+}
+
+bool sd_mmc_is_write_protected(uint8_t slot)
+{
+ /* No detection, always writable */
+ if (!_wp || _wp[slot].pin == -1) {
+ return false;
+ }
+ /* Write Protect Detect */
+ if (gpio_get_pin_level(_wp[slot].pin) == _wp[slot].val) {
+ return true;
+ }
+ return false;
+}
+
+sd_mmc_err_t sd_mmc_init_read_blocks(uint8_t slot, uint32_t start, uint16_t nb_block)
+{
+ sd_mmc_err_t sd_mmc_err;
+ uint32_t cmd, arg, resp;
+
+ sd_mmc_err = sd_mmc_select_slot(slot);
+ if (sd_mmc_err != SD_MMC_OK) {
+ return sd_mmc_err;
+ }
+
+ /* Wait for data ready status */
+ if (!sd_mmc_cmd13()) {
+ sd_mmc_deselect_slot();
+ return SD_MMC_ERR_COMM;
+ }
+
+ if (nb_block > 1) {
+ cmd = SDMMC_CMD18_READ_MULTIPLE_BLOCK;
+ } else {
+ cmd = SDMMC_CMD17_READ_SINGLE_BLOCK;
+ }
+ /*
+ * SDSC Card (CCS=0) uses byte unit address,
+ * SDHC and SDXC Cards (CCS=1) use block unit address (512 Bytes unit).
+ */
+ if (sd_mmc_card->type & CARD_TYPE_HC) {
+ arg = start;
+ } else {
+ arg = (start * SD_MMC_BLOCK_SIZE);
+ }
+
+ if (!driver_adtc_start(sd_mmc_hal, cmd, arg, SD_MMC_BLOCK_SIZE, nb_block, true)) {
+ sd_mmc_deselect_slot();
+ return SD_MMC_ERR_COMM;
+ }
+ /* Check response */
+ resp = driver_get_response(sd_mmc_hal);
+ if (resp & CARD_STATUS_ERR_RD_WR) {
+ sd_mmc_deselect_slot();
+ return SD_MMC_ERR_COMM;
+ }
+
+ sd_mmc_nb_block_remaining = nb_block;
+ sd_mmc_nb_block_to_tranfer = nb_block;
+ return SD_MMC_OK;
+}
+
+sd_mmc_err_t sd_mmc_start_read_blocks(void *dest, uint16_t nb_block)
+{
+ ASSERT(sd_mmc_nb_block_remaining >= nb_block);
+
+ if (!driver_start_read_blocks(sd_mmc_hal, dest, nb_block)) {
+ sd_mmc_nb_block_remaining = 0;
+ return SD_MMC_ERR_COMM;
+ }
+ sd_mmc_nb_block_remaining -= nb_block;
+ return SD_MMC_OK;
+}
+
+sd_mmc_err_t sd_mmc_wait_end_of_read_blocks(bool abort)
+{
+ if (!driver_wait_end_of_read_blocks(sd_mmc_hal)) {
+ return SD_MMC_ERR_COMM;
+ }
+ if (abort) {
+ sd_mmc_nb_block_remaining = 0;
+ } else if (sd_mmc_nb_block_remaining) {
+ return SD_MMC_OK;
+ }
+
+ /* All blocks are transfered then stop read operation */
+ if (sd_mmc_nb_block_to_tranfer == 1) {
+ /* Single block transfer, then nothing to do */
+ sd_mmc_deselect_slot();
+ return SD_MMC_OK;
+ }
+ /* WORKAROUND for no compliance card (Atmel Internal ref. !MMC7 !SD19):
+ * The errors on this command must be ignored
+ * and one retry can be necessary in SPI mode for no compliance card.*/
+ if (!driver_adtc_stop(sd_mmc_hal, SDMMC_CMD12_STOP_TRANSMISSION, 0)) {
+ driver_adtc_stop(sd_mmc_hal, SDMMC_CMD12_STOP_TRANSMISSION, 0);
+ }
+ sd_mmc_deselect_slot();
+ return SD_MMC_OK;
+}
+
+sd_mmc_err_t sd_mmc_init_write_blocks(uint8_t slot, uint32_t start, uint16_t nb_block)
+{
+ sd_mmc_err_t sd_mmc_err;
+ uint32_t cmd, arg, resp;
+
+ sd_mmc_err = sd_mmc_select_slot(slot);
+ if (sd_mmc_err != SD_MMC_OK) {
+ return sd_mmc_err;
+ }
+ if (sd_mmc_is_write_protected(slot)) {
+ sd_mmc_deselect_slot();
+ return SD_MMC_ERR_WP;
+ }
+
+ if (nb_block > 1) {
+ cmd = SDMMC_CMD25_WRITE_MULTIPLE_BLOCK;
+ } else {
+ cmd = SDMMC_CMD24_WRITE_BLOCK;
+ }
+ /*
+ * SDSC Card (CCS=0) uses byte unit address,
+ * SDHC and SDXC Cards (CCS=1) use block unit address (512 Bytes unit).
+ */
+ if (sd_mmc_card->type & CARD_TYPE_HC) {
+ arg = start;
+ } else {
+ arg = (start * SD_MMC_BLOCK_SIZE);
+ }
+ if (!driver_adtc_start(sd_mmc_hal, cmd, arg, SD_MMC_BLOCK_SIZE, nb_block, true)) {
+ sd_mmc_deselect_slot();
+ return SD_MMC_ERR_COMM;
+ }
+ /* Check response */
+ resp = driver_get_response(sd_mmc_hal);
+ if (resp & CARD_STATUS_ERR_RD_WR) {
+ sd_mmc_deselect_slot();
+ return SD_MMC_ERR_COMM;
+ }
+
+ sd_mmc_nb_block_remaining = nb_block;
+ sd_mmc_nb_block_to_tranfer = nb_block;
+ return SD_MMC_OK;
+}
+
+sd_mmc_err_t sd_mmc_start_write_blocks(const void *src, uint16_t nb_block)
+{
+ ASSERT(sd_mmc_nb_block_remaining >= nb_block);
+ if (!driver_start_write_blocks(sd_mmc_hal, src, nb_block)) {
+ sd_mmc_nb_block_remaining = 0;
+ return SD_MMC_ERR_COMM;
+ }
+ sd_mmc_nb_block_remaining -= nb_block;
+ return SD_MMC_OK;
+}
+
+sd_mmc_err_t sd_mmc_wait_end_of_write_blocks(bool abort)
+{
+ if (!driver_wait_end_of_write_blocks(sd_mmc_hal)) {
+ return SD_MMC_ERR_COMM;
+ }
+ if (abort) {
+ sd_mmc_nb_block_remaining = 0;
+ } else if (sd_mmc_nb_block_remaining) {
+ return SD_MMC_OK;
+ }
+
+ /* All blocks are transfered then stop write operation */
+ if (sd_mmc_nb_block_to_tranfer == 1) {
+ /* Single block transfer, then nothing to do */
+ sd_mmc_deselect_slot();
+ return SD_MMC_OK;
+ }
+
+ /* Note: SPI multiblock writes terminate using a special
+ * token, not a STOP_TRANSMISSION request.*/
+ if (!driver_adtc_stop(sd_mmc_hal, SDMMC_CMD12_STOP_TRANSMISSION, 0)) {
+ sd_mmc_deselect_slot();
+ return SD_MMC_ERR_COMM;
+ }
+
+ sd_mmc_deselect_slot();
+ return SD_MMC_OK;
+}
+
+#if (CONF_SDIO_SUPPORT == 1)
+sd_mmc_err_t sdio_read_direct(uint8_t slot, uint8_t func_num, uint32_t addr, uint8_t *dest)
+{
+ sd_mmc_err_t sd_mmc_err;
+
+ if (dest == NULL) {
+ return SD_MMC_ERR_PARAM;
+ }
+
+ sd_mmc_err = sd_mmc_select_slot(slot);
+ if (sd_mmc_err != SD_MMC_OK) {
+ return sd_mmc_err;
+ }
+
+ if (!sdio_cmd52(SDIO_CMD52_READ_FLAG, func_num, addr, 0, dest)) {
+ sd_mmc_deselect_slot();
+ return SD_MMC_ERR_COMM;
+ }
+ sd_mmc_deselect_slot();
+ return SD_MMC_OK;
+}
+
+sd_mmc_err_t sdio_write_direct(uint8_t slot, uint8_t func_num, uint32_t addr, uint8_t data)
+{
+ sd_mmc_err_t sd_mmc_err;
+
+ sd_mmc_err = sd_mmc_select_slot(slot);
+ if (sd_mmc_err != SD_MMC_OK) {
+ return sd_mmc_err;
+ }
+
+ if (!sdio_cmd52(SDIO_CMD52_WRITE_FLAG, func_num, addr, 0, &data)) {
+ sd_mmc_deselect_slot();
+ return SD_MMC_ERR_COMM;
+ }
+
+ sd_mmc_deselect_slot();
+ return SD_MMC_OK;
+}
+
+sd_mmc_err_t sdio_read_extended(uint8_t slot, uint8_t func_num, uint32_t addr, uint8_t inc_addr, uint8_t *dest,
+ uint16_t size)
+{
+ sd_mmc_err_t sd_mmc_err;
+
+ if ((size == 0) || (size > 512)) {
+ return SD_MMC_ERR_PARAM;
+ }
+
+ sd_mmc_err = sd_mmc_select_slot(slot);
+ if (sd_mmc_err != SD_MMC_OK) {
+ return sd_mmc_err;
+ }
+
+ if (!sdio_cmd53(SDIO_CMD53_READ_FLAG, func_num, addr, inc_addr, size, true)) {
+ sd_mmc_deselect_slot();
+ return SD_MMC_ERR_COMM;
+ }
+ if (!driver_start_read_blocks(sd_mmc_hal, dest, 1)) {
+ sd_mmc_deselect_slot();
+ return SD_MMC_ERR_COMM;
+ }
+ if (!driver_wait_end_of_read_blocks(sd_mmc_hal)) {
+ sd_mmc_deselect_slot();
+ return SD_MMC_ERR_COMM;
+ }
+
+ sd_mmc_deselect_slot();
+ return SD_MMC_OK;
+}
+
+sd_mmc_err_t sdio_write_extended(uint8_t slot, uint8_t func_num, uint32_t addr, uint8_t inc_addr, uint8_t *src,
+ uint16_t size)
+{
+ sd_mmc_err_t sd_mmc_err;
+
+ if ((size == 0) || (size > 512)) {
+ return SD_MMC_ERR_PARAM;
+ }
+
+ sd_mmc_err = sd_mmc_select_slot(slot);
+ if (sd_mmc_err != SD_MMC_OK) {
+ return sd_mmc_err;
+ }
+
+ if (!sdio_cmd53(SDIO_CMD53_WRITE_FLAG, func_num, addr, inc_addr, size, true)) {
+ sd_mmc_deselect_slot();
+ return SD_MMC_ERR_COMM;
+ }
+ if (!driver_start_write_blocks(sd_mmc_hal, src, 1)) {
+ sd_mmc_deselect_slot();
+ return SD_MMC_ERR_COMM;
+ }
+ if (!driver_wait_end_of_write_blocks(sd_mmc_hal)) {
+ sd_mmc_deselect_slot();
+ return SD_MMC_ERR_COMM;
+ }
+
+ sd_mmc_deselect_slot();
+ return SD_MMC_OK;
+}
+#endif
+
+/** @} */
diff --git a/ports/atmel-samd/sd_mmc/sd_mmc.h b/ports/atmel-samd/sd_mmc/sd_mmc.h
new file mode 100644
index 000000000..1437e5efd
--- /dev/null
+++ b/ports/atmel-samd/sd_mmc/sd_mmc.h
@@ -0,0 +1,310 @@
+/**
+ * \file
+ *
+ * \brief Common SD/MMC stack header file
+ *
+ * Copyright (c) 2012-2018 Microchip Technology Inc. and its subsidiaries.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Subject to your compliance with these terms, you may use Microchip
+ * software and any derivatives exclusively with Microchip products.
+ * It is your responsibility to comply with third party license terms applicable
+ * to your use of third party software (including open source software) that
+ * may accompany Microchip software.
+ *
+ * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES,
+ * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE,
+ * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY,
+ * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE
+ * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL
+ * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE
+ * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE
+ * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT
+ * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY
+ * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
+ * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit <a href="https://www.microchip.com/support/">Microchip Support</a>
+ */
+
+#ifndef SD_MMC_H_INCLUDED
+#define SD_MMC_H_INCLUDED
+
+#include "compiler.h"
+#include "conf_sd_mmc.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \ingroup common_memory
+ * \defgroup sd_mmc_stack_group SD/MMC/SDIO common stack
+ *
+ * SD/MMC/SDIO basic APIs used by SD/MMC/SDIO memory
+ * APIs (\ref sd_mmc_stack_mem_group).
+ * Also, it can be used by application which use the SDIO card
+ * or specific application which does not need of File System.
+ *
+ * For usual application which use the SD/MMC card in
+ * memory mode with a file system, please refer to
+ * \ref sd_mmc_stack_mem_group.
+ * @{
+ */
+
+typedef uint8_t sd_mmc_err_t; /**< Type of return error code */
+
+/** \name Return error codes */
+/** @{ */
+#define SD_MMC_OK 0 /**< No error */
+#define SD_MMC_INIT_ONGOING 1 /**< Card not initialized */
+#define SD_MMC_ERR_NO_CARD 2 /**< No SD/MMC card inserted */
+#define SD_MMC_ERR_UNUSABLE 3 /**< Unusable card */
+#define SD_MMC_ERR_SLOT 4 /**< Slot unknow */
+#define SD_MMC_ERR_COMM 5 /**< General communication error */
+#define SD_MMC_ERR_PARAM 6 /**< Illeage input parameter */
+#define SD_MMC_ERR_WP 7 /**< Card write protected */
+/** @} */
+
+typedef uint8_t card_type_t; /**< Type of card type */
+
+/** \name Card Types */
+/** @{ */
+#define CARD_TYPE_UNKNOWN (0) /**< Unknown type card */
+#define CARD_TYPE_SD (1 << 0) /**< SD card */
+#define CARD_TYPE_MMC (1 << 1) /**< MMC card */
+#define CARD_TYPE_SDIO (1 << 2) /**< SDIO card */
+#define CARD_TYPE_HC (1 << 3) /**< High capacity card */
+/** SD combo card (io + memory) */
+#define CARD_TYPE_SD_COMBO (CARD_TYPE_SD | CARD_TYPE_SDIO)
+/** @} */
+
+typedef uint8_t card_version_t; /**< Type of card version */
+
+/** \name Card Versions */
+/** @{ */
+#define CARD_VER_UNKNOWN (0) /**< Unknown card version */
+#define CARD_VER_SD_1_0 (0x10) /**< SD version 1.0 and 1.01 */
+#define CARD_VER_SD_1_10 (0x1A) /**< SD version 1.10 */
+#define CARD_VER_SD_2_0 (0X20) /**< SD version 2.00 */
+#define CARD_VER_SD_3_0 (0X30) /**< SD version 3.0X */
+#define CARD_VER_MMC_1_2 (0x12) /**< MMC version 1.2 */
+#define CARD_VER_MMC_1_4 (0x14) /**< MMC version 1.4 */
+#define CARD_VER_MMC_2_2 (0x22) /**< MMC version 2.2 */
+#define CARD_VER_MMC_3 (0x30) /**< MMC version 3 */
+#define CARD_VER_MMC_4 (0x40) /**< MMC version 4 */
+/** @} */
+
+/** Card detect setting */
+typedef struct sd_mmc_detect {
+ int16_t pin; /**< Detection pin, -1 if no such pin */
+ uint16_t val; /**< Detection value */
+} sd_mmc_detect_t;
+
+/** This SD MMC stack uses the maximum block size autorized (512 bytes) */
+#define SD_MMC_BLOCK_SIZE 512
+
+/**
+ * \brief Initialize the SD/MMC stack and low level driver required
+ * \param[in] hal Pointer to HAL instance
+ * \param[in] card_detects Pointer to list of card detect settings,
+ * list size should be \ref CONF_SD_MMC_MEM_CNT
+ * \param[in] wp_detects Pointer to list of write protect detect settings
+ * list size should be \ref CONF_SD_MMC_MEM_CNT
+ */
+void sd_mmc_init(void *hal, sd_mmc_detect_t *card_detects, sd_mmc_detect_t *wp_detects);
+
+/** \brief Return the number of slot available
+ *
+ * \return Number of card slot available
+ */
+uint8_t sd_mmc_nb_slot(void);
+
+/** \brief Performs a card checks
+ *
+ * \param[in] slot Card slot to use
+ *
+ * \retval SD_MMC_OK Card ready
+ * \retval SD_MMC_INIT_ONGOING Initialization on going
+ * \retval SD_MMC_ERR_NO_CARD Card not present in slot
+ * \retval Other value for error cases, see \ref sd_mmc_err_t
+ */
+sd_mmc_err_t sd_mmc_check(uint8_t slot);
+
+/** \brief Get the card type
+ *
+ * \param[in] slot Card slot
+ *
+ * \return Card type (\ref card_type_t)
+ */
+card_type_t sd_mmc_get_type(uint8_t slot);
+
+/** \brief Get the card version
+ *
+ * \param[in] slot Card slot
+ *
+ * \return Card version (\ref card_version_t)
+ */
+card_version_t sd_mmc_get_version(uint8_t slot);
+
+/** \brief Get the memory capacity
+ *
+ * \param[in] slot Card slot
+ *
+ * \return Capacity (unit KB)
+ */
+uint32_t sd_mmc_get_capacity(uint8_t slot);
+
+/** \brief Get the card write protection status
+ *
+ * \param[in] slot Card slot
+ *
+ * \return true, if write portected
+ */
+bool sd_mmc_is_write_protected(uint8_t slot);
+
+/**
+ * \brief Initialize the read blocks of data from the card.
+ *
+ * \param[in] slot Card slot to use
+ * \param[in] start Start block number to to read.
+ * \param[in] nb_block Total number of blocks to be read.
+ *
+ * \return return SD_MMC_OK if success,
+ * otherwise return an error code (\ref sd_mmc_err_t).
+ */
+sd_mmc_err_t sd_mmc_init_read_blocks(uint8_t slot, uint32_t start, uint16_t nb_block);
+
+/**
+ * \brief Start the read blocks of data from the card.
+ *
+ * \param[out] dest Pointer to read buffer.
+ * \param[in] nb_block Number of blocks to be read.
+ *
+ * \return return SD_MMC_OK if started,
+ * otherwise return an error code (\ref sd_mmc_err_t).
+ */
+sd_mmc_err_t sd_mmc_start_read_blocks(void *dest, uint16_t nb_block);
+
+/**
+ * \brief Wait the end of read blocks of data from the card.
+ *
+ * \param[in] abort Abort reading process initialized by
+ * \ref sd_mmc_init_read_blocks() after the reading issued by
+ * \ref sd_mmc_start_read_blocks() is done
+ *
+ * \return return SD_MMC_OK if success,
+ * otherwise return an error code (\ref sd_mmc_err_t).
+ */
+sd_mmc_err_t sd_mmc_wait_end_of_read_blocks(bool abort);
+
+/**
+ * \brief Initialize the write blocks of data
+ *
+ * \param[in] slot Card slot to use
+ * \param[in] start Start block number to be written.
+ * \param[in] nb_block Total number of blocks to be written.
+ *
+ * \return return SD_MMC_OK if success,
+ * otherwise return an error code (\ref sd_mmc_err_t).
+ */
+sd_mmc_err_t sd_mmc_init_write_blocks(uint8_t slot, uint32_t start, uint16_t nb_block);
+
+/**
+ * \brief Start the write blocks of data
+ *
+ * \param[in] src Pointer to write buffer.
+ * \param[in] nb_block Number of blocks to be written.
+ *
+ * \return return SD_MMC_OK if started,
+ * otherwise return an error code (\ref sd_mmc_err_t).
+ */
+sd_mmc_err_t sd_mmc_start_write_blocks(const void *src, uint16_t nb_block);
+
+/**
+ * \brief Wait the end of write blocks of data
+ *
+ * \param[in] abort Abort writing process initialized by
+ * \ref sd_mmc_init_write_blocks() after the writing issued by
+ * \ref sd_mmc_start_write_blocks() is done
+ *
+ * \return return SD_MMC_OK if success,
+ * otherwise return an error code (\ref sd_mmc_err_t).
+ */
+sd_mmc_err_t sd_mmc_wait_end_of_write_blocks(bool abort);
+
+#if (CONF_SDIO_SUPPORT == 1)
+/**
+ * \brief Read one byte from SDIO using RW_DIRECT command.
+ *
+ * \param[in] slot Card slot to use
+ * \param[in] func_num Function number.
+ * \param[in] addr Register address to read from.
+ * \param[out] dest Pointer to read buffer.
+ *
+ * \return return SD_MMC_OK if success,
+ * otherwise return an error code (\ref sd_mmc_err_t).
+ */
+sd_mmc_err_t sdio_read_direct(uint8_t slot, uint8_t func_num, uint32_t addr, uint8_t *dest);
+/**
+ * \brief Write one byte to SDIO using RW_DIRECT command.
+ *
+ * \param[in] slot Card slot to use
+ * \param[in] func_num Function number.
+ * \param[in] addr Register address to read from.
+ * \param[in] data Data to be written.
+ *
+ * \return return SD_MMC_OK if success,
+ * otherwise return an error code (\ref sd_mmc_err_t).
+ */
+sd_mmc_err_t sdio_write_direct(uint8_t slot, uint8_t func_num, uint32_t addr, uint8_t data);
+
+/**
+ * \brief Read bytes from SDIO using RW_EXTENDED command.
+ *
+ * \param[in] slot Card slot to use
+ * \param[in] func_num Function number.
+ * \param[in] addr First register address to read from.
+ * \param[in] inc_addr 0 - The data address is fixed.
+ * 1 - The data address increase automatically.
+ * \param[out] dest Pointer to read buffer.
+ * \param[in] size Number of bytes to read (1 ~ 512).
+ *
+ * \return return SD_MMC_OK if success,
+ * otherwise return an error code (\ref sd_mmc_err_t).
+ */
+sd_mmc_err_t sdio_read_extended(uint8_t slot, uint8_t func_num, uint32_t addr, uint8_t inc_addr, uint8_t *dest,
+ uint16_t size);
+
+/**
+ * \brief Write bytes to SDIO using RW_EXTENDED command.
+ *
+ * \param[in] slot Card slot to use
+ * \param[in] func_num Function number.
+ * \param[in] addr First register address to write to.
+ * \param[in] inc_addr 0 - The data address is fixed.
+ * 1 - The data address increase automatically.
+ * \param[in] src Pointer to write buffer.
+ * \param[in] size Number of bytes to read (1 ~ 512).
+ *
+ * \return return SD_MMC_OK if success,
+ * otherwise return an error code (\ref sd_mmc_err_t).
+ */
+sd_mmc_err_t sdio_write_extended(uint8_t slot, uint8_t func_num, uint32_t addr, uint8_t inc_addr, uint8_t *src,
+ uint16_t size);
+#endif /* SDIO_SUPPORT_ENABLE */
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* SD_MMC_H_INCLUDED */
diff --git a/ports/atmel-samd/sd_mmc/sd_mmc_protocol.h b/ports/atmel-samd/sd_mmc/sd_mmc_protocol.h
new file mode 100644
index 000000000..0516e4fd1
--- /dev/null
+++ b/ports/atmel-samd/sd_mmc/sd_mmc_protocol.h
@@ -0,0 +1,1001 @@
+/**
+ * \file
+ *
+ * \brief SD/MMC protocol definitions.
+ *
+ * Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.
+ *
+ * \asf_license_start
+ *
+ * \page License
+ *
+ * Subject to your compliance with these terms, you may use Microchip
+ * software and any derivatives exclusively with Microchip products.
+ * It is your responsibility to comply with third party license terms applicable
+ * to your use of third party software (including open source software) that
+ * may accompany Microchip software.
+ *
+ * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES,
+ * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE,
+ * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY,
+ * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE
+ * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL
+ * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE
+ * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE
+ * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT
+ * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY
+ * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
+ * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
+ *
+ * \asf_license_stop
+ *
+ */
+/*
+ * Support and FAQ: visit <a href="https://www.microchip.com/support/">Microchip Support</a>
+ */
+
+#ifndef SD_MMC_PROTOCOL_H_INCLUDED
+#define SD_MMC_PROTOCOL_H_INCLUDED
+
+#include "compiler.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \addtogroup sd_mmc_protocol SD/MMC Protocol Definition
+ * \ingroup sd_mmc_stack_group
+ * @{
+ */
+
+// SD/MMC/SDIO default clock frequency for initialization (400KHz)
+#define SDMMC_CLOCK_INIT 400000
+
+/**
+ * \name Macros for command definition
+ *
+ * Commands types:
+ * - broadcast commands (bc), no response
+ * - broadcast commands with response (bcr) (Note: No open drain on SD card)
+ * - addressed (point-to-point) commands (ac), no data transfer on DAT lines
+ * - addressed (point-to-point) data transfer commands (adtc), data transfer
+ * on DAT lines
+ *
+ * Specific MMC norms:
+ * CMD1, CMD2 & CMD3 are processed in the open-drain mode.
+ * The CMD line is driven with push-pull drivers.
+ *
+ * Specific SD norms:
+ * There is no open drain mode in SD memory card.
+ *
+ ***************************************
+ * Responses types:
+ *
+ * R1, R3, R4 & R5 use a 48 bits response protected by a 7bit CRC checksum
+ * - R1 receiv data not specified
+ * - R3 receiv OCR
+ * - R4, R5 RCA management (MMC only)
+ * - R6, R7 RCA management (SD only)
+ *
+ * R1b assert the BUSY signal and respond with R1.
+ * If the busy signal is asserted, it is done two clock cycles (Nsr time)
+ * after the end bit of the command. The DAT0 line is driven low.
+ * DAT1-DAT7 lines are driven by the card though their values are not relevant.
+ *
+ * R2 use a 136 bits response protected by a 7bit CRC checksum
+ * The content is CID or CSD
+ *
+ * Specific MMC norms:
+ * - R4 (Fast I/O) return RCA
+ * - R5 (interrupt request) return RCA null
+ *
+ * Specific SD norms:
+ * - R6 (Published RCA) return RCA
+ * - R7 (Card interface condition) return RCA null
+ *
+ * @{
+ */
+
+//! Value to define a SD/MMC/SDIO command
+typedef uint32_t sdmmc_cmd_def_t;
+
+//! \name Flags used to define a SD/MMC/SDIO command
+//! @{
+#define SDMMC_CMD_GET_INDEX(cmd) (cmd & 0x3F)
+//! Have response (MCI only)
+#define SDMMC_RESP_PRESENT (1lu << 8)
+//! 8 bit response (SPI only)
+#define SDMMC_RESP_8 (1lu << 9)
+//! 32 bit response (SPI only)
+#define SDMMC_RESP_32 (1lu << 10)
+//! 136 bit response (MCI only)
+#define SDMMC_RESP_136 (1lu << 11)
+//! Expect valid crc (MCI only)
+#define SDMMC_RESP_CRC (1lu << 12)
+//! Card may send busy
+#define SDMMC_RESP_BUSY (1lu << 13)
+// Open drain for a braodcast command (bc)
+// or to enter in inactive state (MCI only)
+#define SDMMC_CMD_OPENDRAIN (1lu << 14)
+//! To signal a data write operation
+#define SDMMC_CMD_WRITE (1lu << 15)
+//! To signal a SDIO tranfer in multi byte mode
+#define SDMMC_CMD_SDIO_BYTE (1lu << 16)
+//! To signal a SDIO tranfer in block mode
+#define SDMMC_CMD_SDIO_BLOCK (1lu << 17)
+//! To signal a data transfer in stream mode
+#define SDMMC_CMD_STREAM (1lu << 18)
+//! To signal a data transfer in single block mode
+#define SDMMC_CMD_SINGLE_BLOCK (1lu << 19)
+//! To signal a data transfer in multi block mode
+#define SDMMC_CMD_MULTI_BLOCK (1lu << 20)
+//! @}
+
+//! \name Set of flags to define a reponse type
+//! @{
+#define SDMMC_CMD_NO_RESP (0)
+#define SDMMC_CMD_R1 (SDMMC_RESP_PRESENT | SDMMC_RESP_CRC)
+#define SDMMC_CMD_R1B (SDMMC_RESP_PRESENT | SDMMC_RESP_CRC | SDMMC_RESP_BUSY)
+#define SDMMC_CMD_R2 (SDMMC_RESP_PRESENT | SDMMC_RESP_8 | SDMMC_RESP_136 | SDMMC_RESP_CRC)
+#define SDMMC_CMD_R3 (SDMMC_RESP_PRESENT | SDMMC_RESP_32)
+#define SDMMC_CMD_R4 (SDMMC_RESP_PRESENT | SDMMC_RESP_32)
+#define SDMMC_CMD_R5 (SDMMC_RESP_PRESENT | SDMMC_RESP_8 | SDMMC_RESP_CRC)
+#define SDMMC_CMD_R6 (SDMMC_RESP_PRESENT | SDMMC_RESP_CRC)
+#define SDMMC_CMD_R7 (SDMMC_RESP_PRESENT | SDMMC_RESP_32 | SDMMC_RESP_CRC)
+//! @}
+
+//! \name SD/MMC/SDIO command definitions
+//! SDMMC_CMDx are include in SD and MMC norms
+//! MMC_CMDx are include in MMC norms only
+//! SD_CMDx are include in SD norms only
+//! SDIO_CMDx are include in SDIO norms only
+//! @{
+
+/*
+ * --- Basic commands and read-stream command (class 0 and class 1) ---
+ */
+
+/** Cmd0(bc): Reset all cards to idle state */
+#define SDMMC_SPI_CMD0_GO_IDLE_STATE (0 | SDMMC_CMD_R1)
+#define SDMMC_MCI_CMD0_GO_IDLE_STATE (0 | SDMMC_CMD_NO_RESP | SDMMC_CMD_OPENDRAIN)
+/** MMC Cmd1(bcr, R3): Ask the card to send its Operating Conditions */
+#define MMC_SPI_CMD1_SEND_OP_COND (1 | SDMMC_CMD_R1)
+#define MMC_MCI_CMD1_SEND_OP_COND (1 | SDMMC_CMD_R3 | SDMMC_CMD_OPENDRAIN)
+/** Cmd2(bcr, R2): Ask the card to send its CID number (stuff but arg 0 used) */
+#define SDMMC_CMD2_ALL_SEND_CID (2 | SDMMC_CMD_R2 | SDMMC_CMD_OPENDRAIN)
+/** SD Cmd3(bcr, R6): Ask the card to publish a new relative address (RCA) */
+#define SD_CMD3_SEND_RELATIVE_ADDR (3 | SDMMC_CMD_R6 | SDMMC_CMD_OPENDRAIN)
+/** MMC Cmd3(ac, R1): Assigns relative address to the card */
+#define MMC_CMD3_SET_RELATIVE_ADDR (3 | SDMMC_CMD_R1)
+/** Cmd4(bc): Program the DSR of all cards (MCI only) */
+#define SDMMC_CMD4_SET_DSR (4 | SDMMC_CMD_NO_RESP)
+/** MMC Cmd5(ac, R1b): Toggle the card between Sleep state and Standby state. */
+#define MMC_CMD5_SLEEP_AWAKE (5 | SDMMC_CMD_R1B)
+/** Cmd7(ac, R1/R1b): Select/Deselect card
+ * For SD: R1b only from the selected card.
+ * For MMC: R1 while selecting from Stand-By State to Transfer State;
+ * R1b while selecting from Disconnected State to Programming State.
+ */
+#define SDMMC_CMD7_SELECT_CARD_CMD (7 | SDMMC_CMD_R1B)
+#define SDMMC_CMD7_DESELECT_CARD_CMD (7 | SDMMC_CMD_R1)
+/** MMC Cmd8(adtc, R1): Send EXT_CSD register as a block of data */
+#define MMC_CMD8_SEND_EXT_CSD (8 | SDMMC_CMD_R1 | SDMMC_CMD_SINGLE_BLOCK)
+/** SD Cmd8(bcr, R7) : Send SD Memory Card interface condition */
+#define SD_CMD8_SEND_IF_COND (8 | SDMMC_CMD_R7 | SDMMC_CMD_OPENDRAIN)
+/** Cmd9 SPI (R1): Addressed card sends its card-specific data (CSD) */
+#define SDMMC_SPI_CMD9_SEND_CSD (9 | SDMMC_CMD_R1 | SDMMC_CMD_SINGLE_BLOCK)
+/** Cmd9 MCI (ac, R2): Addressed card sends its card-specific data (CSD) */
+#define SDMMC_MCI_CMD9_SEND_CSD (9 | SDMMC_CMD_R2)
+/** Cmd10(ac, R2): Addressed card sends its card identification (CID) */
+#define SDMMC_CMD10_SEND_CID (10 | SDMMC_CMD_R2)
+/**
+ * MMC Cmd11(adtc, R1): Read data stream from the card, starting at the given
+ * address, until a STOP_TRANSMISSION follows.
+ */
+#define MMC_CMD11_READ_DAT_UNTIL_STOP (11 | SDMMC_CMD_R1)
+/* SD Cmd11 MCI (ac, R1): Voltage switching */
+#define SD_CMD11_READ_DAT_UNTIL_STOP (11 | SDMMC_CMD_R1)
+/** Cmd12(ac, R1b): Force the card to stop transmission */
+#define SDMMC_CMD12_STOP_TRANSMISSION (12 | SDMMC_CMD_R1B)
+/** Cmd13(R2): Addressed card sends its status register. */
+#define SDMMC_SPI_CMD13_SEND_STATUS (13 | SDMMC_CMD_R2)
+/** Cmd13(ac, R1): Addressed card sends its status register. */
+#define SDMMC_MCI_CMD13_SEND_STATUS (13 | SDMMC_CMD_R1)
+/** MMC Cmd14(adtc, R1): Read the reversed bus testing data pattern from a card. */
+#define MMC_CMD14_BUSTEST_R (14 | SDMMC_CMD_R1)
+/** Cmd15(ac): Send an addressed card into the Inactive State. */
+// Note: It is a ac cmd, but it must be send like bc cmd to open drain
+#define SDMMC_CMD15_GO_INACTIVE_STATE (15 | SDMMC_CMD_NO_RESP | SDMMC_CMD_OPENDRAIN)
+/** MMC Cmd19(adtc, R1): Send the bus test data pattern */
+#define MMC_CMD19_BUSTEST_W (19 | SDMMC_CMD_R1)
+/** Cmd58(R3): Reads the OCR register of a card */
+#define SDMMC_SPI_CMD58_READ_OCR (58 | SDMMC_CMD_R3)
+/** Cmd59(R1): Turns the CRC option on or off */
+#define SDMMC_SPI_CMD59_CRC_ON_OFF (59 | SDMMC_CMD_R1)
+
+/*
+ * --- Block-oriented read commands (class 2) ---
+ */
+/** Cmd16(ac, R1): Set the block length (in bytes) */
+#define SDMMC_CMD16_SET_BLOCKLEN (16 | SDMMC_CMD_R1)
+/** Cmd17(adtc, R1): Read single block */
+#define SDMMC_CMD17_READ_SINGLE_BLOCK (17 | SDMMC_CMD_R1 | SDMMC_CMD_SINGLE_BLOCK)
+/** Cmd18(adtc, R1): Read multiple block */
+#define SDMMC_CMD18_READ_MULTIPLE_BLOCK (18 | SDMMC_CMD_R1 | SDMMC_CMD_MULTI_BLOCK)
+
+/*
+ * --- Sequential write commands (class 3) ---
+ */
+
+/**
+ * MMC Cmd20(adtc, R1): Write a data stream from the host, starting at the
+ * given address, until a STOP_TRANSMISSION follows.
+ */
+#define MMC_CMD20_WRITE_DAT_UNTIL_STOP (20 | SDMMC_CMD_R1)
+
+/*
+ * --- Block-oriented write commands (class 4) ---
+ */
+/** MMC Cmd23(ac, R1): Set block count */
+#define MMC_CMD23_SET_BLOCK_COUNT (23 | SDMMC_CMD_R1)
+/** Cmd24(adtc, R1): Write block */
+#define SDMMC_CMD24_WRITE_BLOCK (24 | SDMMC_CMD_R1 | SDMMC_CMD_WRITE | SDMMC_CMD_SINGLE_BLOCK)
+/** Cmd25(adtc, R1): Write multiple block */
+#define SDMMC_CMD25_WRITE_MULTIPLE_BLOCK (25 | SDMMC_CMD_R1 | SDMMC_CMD_WRITE | SDMMC_CMD_MULTI_BLOCK)
+/** MMC Cmd26(adtc, R1): Programming of the card identification register. */
+#define MMC_CMD26_PROGRAM_CID (26 | SDMMC_CMD_R1)
+/** Cmd27(adtc, R1): Programming of the programmable bits of the CSD. */
+#define SDMMC_CMD27_PROGRAM_CSD (27 | SDMMC_CMD_R1)
+
+/*
+ * --- Erase commands (class 5) ---
+ */
+/** SD Cmd32(ac, R1): */
+#define SD_CMD32_ERASE_WR_BLK_START (32 | SDMMC_CMD_R1)
+/** SD Cmd33(ac, R1): */
+#define SD_CMD33_ERASE_WR_BLK_END (33 | SDMMC_CMD_R1)
+/** MMC Cmd35(ac, R1): */
+#define MMC_CMD35_ERASE_GROUP_START (35 | SDMMC_CMD_R1)
+/** MMC Cmd36(ac, R1): */
+#define MMC_CMD36_ERASE_GROUP_END (36 | SDMMC_CMD_R1)
+/** Cmd38(ac, R1B): */
+#define SDMMC_CMD38_ERASE (38 | SDMMC_CMD_R1B)
+
+/*
+ * --- Block Oriented Write Protection Commands (class 6) ---
+ */
+/** Cmd28(ac, R1b): Set write protection */
+#define SDMMC_CMD28_SET_WRITE_PROT (28 | SDMMC_CMD_R1B)
+/** Cmd29(ac, R1b): Clr write protection */
+#define SDMMC_CMD29_CLR_WRITE_PROT (29 | SDMMC_CMD_R1B)
+/** Cmd30(adtc, R1b): Send write protection */
+#define SDMMC_CMD30_SEND_WRITE_PROT (30 | SDMMC_CMD_R1)
+
+/*
+ * --- Lock Card (class 7) ---
+ */
+/** Cmd42(adtc, R1): Used to set/reset the password or lock/unlock the card. */
+#define SDMMC_CMD42_LOCK_UNLOCK (42 | SDMMC_CMD_R1)
+
+/*
+ * --- Application-specific commands (class 8) ---
+ */
+/**
+ * Cmd55(ac, R1): Indicate to the card that the next command is an application
+ * specific command rather than a standard command.
+ */
+#define SDMMC_CMD55_APP_CMD (55 | SDMMC_CMD_R1)
+/**
+ * Cmd 56(adtc, R1): Used either to transfer a data block to the card or to get
+ * a data block from the card for general purpose/application specific commands.
+ */
+#define SDMMC_CMD56_GEN_CMD (56 | SDMMC_CMD_R1)
+
+/**
+ * MMC Cmd6(ac, R1b) : Switche the mode of operation of the selected card
+ * or modifies the EXT_CSD registers.
+ */
+#define MMC_CMD6_SWITCH (6 | SDMMC_CMD_R1B)
+/**
+ * SD Cmd6(adtc, R1) : Check switchable function (mode 0)
+ * and switch card function (mode 1).
+ */
+#define SD_CMD6_SWITCH_FUNC (6 | SDMMC_CMD_R1 | SDMMC_CMD_SINGLE_BLOCK)
+/** ACMD6(ac, R1): Define the data bus width */
+#define SD_ACMD6_SET_BUS_WIDTH (6 | SDMMC_CMD_R1)
+/** ACMD13(adtc, R1): Send the SD Status. */
+#define SD_ACMD13_SD_STATUS (13 | SDMMC_CMD_R1)
+/**
+ * ACMD22(adtc, R1): Send the number of the written (with-out errors) write
+ * blocks.
+ */
+#define SD_ACMD22_SEND_NUM_WR_BLOCKS (22 | SDMMC_CMD_R1)
+/**
+ * ACMD23(ac, R1): Set the number of write blocks to be pre-erased before
+ * writing
+ */
+#define SD_ACMD23_SET_WR_BLK_ERASE_COUNT (23 | SDMMC_CMD_R1)
+/**
+ * ACMD41(bcr, R3): Send host capacity support information (HCS) and asks the
+ * accessed card to send its operating condition register (OCR) content
+ * in the response
+ */
+#define SD_MCI_ACMD41_SD_SEND_OP_COND (41 | SDMMC_CMD_R3 | SDMMC_CMD_OPENDRAIN)
+/**
+ * ACMD41(R1): Send host capacity support information (HCS) and activates the
+ * card's initilization process
+ */
+#define SD_SPI_ACMD41_SD_SEND_OP_COND (41 | SDMMC_CMD_R1)
+/**
+ * ACMD42(ac, R1): Connect[1]/Disconnect[0] the 50 KOhm pull-up resistor on
+ * CD/DAT3 (pin 1) of the card.
+ */
+#define SD_ACMD42_SET_CLR_CARD_DETECT (42 | SDMMC_CMD_R1)
+/** ACMD51(adtc, R1): Read the SD Configuration Register (SCR). */
+#define SD_ACMD51_SEND_SCR (51 | SDMMC_CMD_R1 | SDMMC_CMD_SINGLE_BLOCK)
+
+/*
+ * --- I/O mode commands (class 9) ---
+ */
+/** MMC Cmd39(ac, R4): Used to write and read 8 bit (register) data fields. */
+#define MMC_CMD39_FAST_IO (39 | SDMMC_CMD_R4)
+/** MMC Cmd40(bcr, R5): Set the system into interrupt mode */
+#define MMC_CMD40_GO_IRQ_STATE (40 | SDMMC_CMD_R5 | SDMMC_CMD_OPENDRAIN)
+/** SDIO Cmd5(R4): Send operation condition */
+#define SDIO_CMD5_SEND_OP_COND (5 | SDMMC_CMD_R4 | SDMMC_CMD_OPENDRAIN)
+/** SDIO CMD52(R5): Direct IO read/write */
+#define SDIO_CMD52_IO_RW_DIRECT (52 | SDMMC_CMD_R5)
+/** SDIO CMD53(R5): Extended IO read/write */
+#define SDIO_CMD53_IO_R_BYTE_EXTENDED (53 | SDMMC_CMD_R5 | SDMMC_CMD_SDIO_BYTE)
+#define SDIO_CMD53_IO_W_BYTE_EXTENDED (53 | SDMMC_CMD_R5 | SDMMC_CMD_SDIO_BYTE | SDMMC_CMD_WRITE)
+#define SDIO_CMD53_IO_R_BLOCK_EXTENDED (53 | SDMMC_CMD_R5 | SDMMC_CMD_SDIO_BLOCK)
+#define SDIO_CMD53_IO_W_BLOCK_EXTENDED (53 | SDMMC_CMD_R5 | SDMMC_CMD_SDIO_BLOCK | SDMMC_CMD_WRITE)
+//! @}
+//! @}
+
+//! \name Macros for command argument definition
+//! @{
+
+//! \name MMC CMD6 argument structure
+//! @{
+//! [31:26] Set to 0
+//! [25:24] Access
+#define MMC_CMD6_ACCESS_COMMAND_SET (0lu << 24)
+#define MMC_CMD6_ACCESS_SET_BITS (1lu << 24)
+#define MMC_CMD6_ACCESS_CLEAR_BITS (2lu << 24)
+#define MMC_CMD6_ACCESS_WRITE_BYTE (3lu << 24)
+//! [23:16] Index for Mode Segment
+#define MMC_CMD6_INDEX_CMD_SET (EXT_CSD_CMD_SET_INDEX << 16)
+#define MMC_CMD6_INDEX_CMD_SET_REV (EXT_CSD_CMD_SET_REV_INDEX << 16)
+#define MMC_CMD6_INDEX_POWER_CLASS (EXT_CSD_POWER_CLASS_INDEX << 16)
+#define MMC_CMD6_INDEX_HS_TIMING (EXT_CSD_HS_TIMING_INDEX << 16)
+#define MMC_CMD6_INDEX_BUS_WIDTH (EXT_CSD_BUS_WIDTH_INDEX << 16)
+#define MMC_CMD6_INDEX_ERASED_MEM_CONT (EXT_CSD_ERASED_MEM_CONT_INDEX << 16)
+#define MMC_CMD6_INDEX_BOOT_CONFIG (EXT_CSD_BOOT_CONFIG_INDEX << 16)
+#define MMC_CMD6_INDEX_BOOT_BUS_WIDTH (EXT_CSD_BOOT_BUS_WIDTH_INDEX << 16)
+#define MMC_CMD6_INDEX_ERASE_GROUP_DEF (EXT_CSD_ERASE_GROUP_DEF_INDEX << 16)
+//! [15:8] Value
+#define MMC_CMD6_VALUE_BUS_WIDTH_1BIT (0x0lu << 8)
+#define MMC_CMD6_VALUE_BUS_WIDTH_4BIT (0x1lu << 8)
+#define MMC_CMD6_VALUE_BUS_WIDTH_8BIT (0x2lu << 8)
+#define MMC_CMD6_VALUE_HS_TIMING_ENABLE (0x1lu << 8)
+#define MMC_CMD6_VALUE_HS_TIMING_DISABLE (0x0lu << 8)
+//! [7:3] Set to 0
+//! [2:0] Cmd Set
+//! @}
+
+//! \name SD CMD6 argument structure
+//! @{
+//! CMD6 arg[ 3: 0] function group 1, access mode
+#define SD_CMD6_GRP1_HIGH_SPEED (0x1lu << 0)
+#define SD_CMD6_GRP1_DEFAULT (0x0lu << 0)
+//! CMD6 arg[ 7: 4] function group 2, command system
+#define SD_CMD6_GRP2_NO_INFLUENCE (0xFlu << 4)
+#define SD_CMD6_GRP2_DEFAULT (0x0lu << 4)
+//! CMD6 arg[11: 8] function group 3, 0xF or 0x0
+#define SD_CMD6_GRP3_NO_INFLUENCE (0xFlu << 8)
+#define SD_CMD6_GRP3_DEFAULT (0x0lu << 8)
+//! CMD6 arg[15:12] function group 4, 0xF or 0x0
+#define SD_CMD6_GRP4_NO_INFLUENCE (0xFlu << 12)
+#define SD_CMD6_GRP4_DEFAULT (0x0lu << 12)
+//! CMD6 arg[19:16] function group 5, 0xF or 0x0
+#define SD_CMD6_GRP5_NO_INFLUENCE (0xFlu << 16)
+#define SD_CMD6_GRP5_DEFAULT (0x0lu << 16)
+//! CMD6 arg[23:20] function group 6, 0xF or 0x0
+#define SD_CMD6_GRP6_NO_INFLUENCE (0xFlu << 20)
+#define SD_CMD6_GRP6_DEFAULT (0x0lu << 20)
+//! CMD6 arg[30:24] reserved 0
+//! CMD6 arg[31 ] Mode, 0: Check, 1: Switch
+#define SD_CMD6_MODE_CHECK (0lu << 31)
+#define SD_CMD6_MODE_SWITCH (1lu << 31)
+//! @}
+
+//! \name SD CMD8 argument structure
+//! @{
+#define SD_CMD8_PATTERN 0xAA
+#define SD_CMD8_MASK_PATTERN 0xFF
+#define SD_CMD8_HIGH_VOLTAGE 0x100
+#define SD_CMD8_MASK_VOLTAGE 0xF00
+//! @}
+
+//! \name SD ACMD41 arguments
+//! @{
+#define SD_ACMD41_HCS (1lu << 30) //!< (SD) Host Capacity Support
+ //! @}
+//! @}
+
+//! \name SDIO definitions
+//! @{
+
+//! \name SDIO state (in R5)
+//! @{
+#define SDIO_R5_COM_CRC_ERROR (1lu << 15) /**< CRC check error */
+#define SDIO_R5_ILLEGAL_COMMAND (1lu << 14) /**< Illegal command */
+#define SDIO_R5_STATE (3lu << 12) /**< SDIO R5 state mask */
+#define SDIO_R5_STATE_DIS (0lu << 12) /**< Disabled */
+#define SDIO_R5_STATE_CMD (1lu << 12) /**< DAT lines free */
+#define SDIO_R5_STATE_TRN (2lu << 12) /**< Transfer */
+#define SDIO_R5_STATE_RFU (3lu << 12) /**< Reserved */
+#define SDIO_R5_ERROR (1lu << 11) /**< General error */
+#define SDIO_R5_FUNC_NUM (1lu << 9) /**< Invalid function number */
+#define SDIO_R5_OUT_OF_RANGE (1lu << 8) /**< Argument out of range */
+#define SDIO_R5_STATUS_ERR (SDIO_R5_ERROR | SDIO_R5_FUNC_NUM | SDIO_R5_OUT_OF_RANGE) //!< Errro status bits mask
+ //! @}
+
+//! \name SDIO state (in R6)
+//! @{
+/** The CRC check of the previous command failed. */
+#define SDIO_R6_COM_CRC_ERROR (1lu << 15)
+/** Command not legal for the card state. */
+#define SDIO_R6_ILLEGAL_COMMAND (1lu << 14)
+/** A general or an unknown error occurred during the operation. */
+#define SDIO_R6_ERROR (1lu << 13)
+/** Status bits mask for SDIO R6 */
+#define SDIO_STATUS_R6 (SDIO_R6_COM_CRC_ERROR | SDIO_R6_ILLEGAL_COMMAND | SDIO_R6_ERROR)
+//! @}
+
+//! \name SDIO CMD52 argument bit offset
+//! @{
+//! CMD52 arg[ 7: 0] Write data or stuff bits
+#define SDIO_CMD52_WR_DATA 0
+//! CMD52 arg[ 8] Reserved
+#define SDIO_CMD52_STUFF0 8
+//! CMD52 arg[25: 9] Register address
+#define SDIO_CMD52_REG_ADRR 9
+//! CMD52 arg[ 26] Reserved
+#define SDIO_CMD52_STUFF1 26
+//! CMD52 arg[ 27] Read after Write flag
+#define SDIO_CMD52_RAW_FLAG 27
+//! CMD52 arg[30:28] Number of the function
+#define SDIO_CMD52_FUNCTION_NUM 28
+//! CMD52 arg[ 31] Direction, 1:write, 0:read.
+#define SDIO_CMD52_RW_FLAG 31
+#define SDIO_CMD52_READ_FLAG 0
+#define SDIO_CMD52_WRITE_FLAG 1
+//! @}
+
+//! \name SDIO CMD53 argument structure
+//! @{
+/**
+ * [ 8: 0] Byte mode: number of bytes to transfer,
+ * 0 cause 512 bytes transfer.
+ * Block mode: number of blocks to transfer,
+ * 0 set count to infinite.
+ */
+#define SDIO_CMD53_COUNT 0
+//! CMD53 arg[25: 9] Start Address I/O register
+#define SDIO_CMD53_REG_ADDR 9
+//! CMD53 arg[ 26] 1:Incrementing address, 0: fixed
+#define SDIO_CMD53_OP_CODE 26
+//! CMD53 arg[ 27] (Optional) 1:block mode
+#define SDIO_CMD53_BLOCK_MODE 27
+//! CMD53 arg[30:28] Number of the function
+#define SDIO_CMD53_FUNCTION_NUM 28
+//! CMD53 arg[ 31] Direction, 1:WR, 0:RD
+#define SDIO_CMD53_RW_FLAG 31
+#define SDIO_CMD53_READ_FLAG 0
+#define SDIO_CMD53_WRITE_FLAG 1
+//! @}
+
+//! \name SDIO Functions
+//! @{
+#define SDIO_CIA 0 /**< SDIO Function 0 (CIA) */
+#define SDIO_FN0 0 /**< SDIO Function 0 */
+#define SDIO_FN1 1 /**< SDIO Function 1 */
+#define SDIO_FN2 2 /**< SDIO Function 2 */
+#define SDIO_FN3 3 /**< SDIO Function 3 */
+#define SDIO_FN4 4 /**< SDIO Function 4 */
+#define SDIO_FN5 5 /**< SDIO Function 5 */
+#define SDIO_FN6 6 /**< SDIO Function 6 */
+#define SDIO_FN7 7 /**< SDIO Function 7 */
+ //! @}
+
+//! \name SDIO Card Common Control Registers (CCCR)
+//! @{
+#define SDIO_CCCR_SDIO_REV 0x00 /**< CCCR/SDIO revision (RO) */
+#define SDIO_CCCR_REV (0xFlu << 0) /**< CCCR/FBR Version */
+#define SDIO_CCCR_REV_1_00 (0x0lu << 0) /**< CCCR/FBR Version 1.00 */
+#define SDIO_CCCR_REV_1_10 (0x1lu << 0) /**< CCCR/FBR Version 1.10 */
+#define SDIO_CCCR_REV_2_00 (0x2lu << 0) /**< CCCR/FBR Version 2.00 */
+#define SDIO_CCCR_REV_3_00 (0x3lu << 0) /**< CCCR/FBR Version 3.00 */
+#define SDIO_SDIO_REV (0xFlu << 4) /**< SDIO Spec */
+#define SDIO_SDIO_REV_1_00 (0x0lu << 4) /**< SDIO Spec 1.00 */
+#define SDIO_SDIO_REV_1_10 (0x1lu << 4) /**< SDIO Spec 1.10 */
+#define SDIO_SDIO_REV_1_20 (0x2lu << 4) /**< SDIO Spec 1.20(unreleased) */
+#define SDIO_SDIO_REV_2_00 (0x3lu << 4) /**< SDIO Spec Version 2.00 */
+#define SDIO_SDIO_REV_3_00 (0x4lu << 4) /**< SDIO Spec Version 3.00 */
+#define SDIO_CCCR_SD_REV 0x01 /**< SD Spec Revision (RO) */
+#define SDIO_SD_REV (0xFlu << 0) /**< SD Physical Spec */
+#define SDIO_SD_REV_1_01 (0x0lu << 0) /**< SD 1.01 (Mar 2000) */
+#define SDIO_SD_REV_1_10 (0x1lu << 0) /**< SD 1.10 (Oct 2004) */
+#define SDIO_SD_REV_2_00 (0x2lu << 0) /**< SD 2.00 (May 2006) */
+#define SDIO_SD_REV_3_00 (0x3lu << 0) /**< SD 3.00 */
+#define SDIO_CCCR_IOE 0x02 /**< I/O Enable (R/W) */
+#define SDIO_IOE (0xFElu << 1) /**< Functions Enable/Disable */
+#define SDIO_IOE_FN1 (0x1lu << 1) /**< Function 1 Enable/Disable */
+#define SDIO_IOE_FN2 (0x1lu << 2) /**< Function 2 Enable/Disable */
+#define SDIO_IOE_FN3 (0x1lu << 3) /**< Function 3 Enable/Disable */
+#define SDIO_IOE_FN4 (0x1lu << 4) /**< Function 4 Enable/Disable */
+#define SDIO_IOE_FN5 (0x1lu << 5) /**< Function 5 Enable/Disable */
+#define SDIO_IOE_FN6 (0x1lu << 6) /**< Function 6 Enable/Disable */
+#define SDIO_IOE_FN7 (0x1lu << 7) /**< Function 7 Enable/Disable */
+#define SDIO_CCCR_IOR 0x03 /**< I/O Ready (RO) */
+#define SDIO_IOR (0xFElu << 1) /**< Functions ready */
+#define SDIO_IOR_FN1 (0x1lu << 1) /**< Function 1 ready */
+#define SDIO_IOR_FN2 (0x1lu << 2) /**< Function 2 ready */
+#define SDIO_IOR_FN3 (0x1lu << 3) /**< Function 3 ready */
+#define SDIO_IOR_FN4 (0x1lu << 4) /**< Function 4 ready */
+#define SDIO_IOR_FN5 (0x1lu << 5) /**< Function 5 ready */
+#define SDIO_IOR_FN6 (0x1lu << 6) /**< Function 6 ready */
+#define SDIO_IOR_FN7 (0x1lu << 7) /**< Function 7 ready */
+#define SDIO_CCCR_IEN 0x04 /**< Int Enable */
+#define SDIO_IENM (0x1lu << 0) /**< Int Enable Master (R/W) */
+#define SDIO_IEN (0xFElu << 1) /**< Functions Int Enable */
+#define SDIO_IEN_FN1 (0x1lu << 1) /**< Function 1 Int Enable */
+#define SDIO_IEN_FN2 (0x1lu << 2) /**< Function 2 Int Enable */
+#define SDIO_IEN_FN3 (0x1lu << 3) /**< Function 3 Int Enable */
+#define SDIO_IEN_FN4 (0x1lu << 4) /**< Function 4 Int Enable */
+#define SDIO_IEN_FN5 (0x1lu << 5) /**< Function 5 Int Enable */
+#define SDIO_IEN_FN6 (0x1lu << 6) /**< Function 6 Int Enable */
+#define SDIO_IEN_FN7 (0x1lu << 7) /**< Function 7 Int Enable */
+#define SDIO_CCCR_INT 0x05 /**< Int Pending */
+#define SDIO_INT (0xFElu << 1) /**< Functions Int pending */
+#define SDIO_INT_FN1 (0x1lu << 1) /**< Function 1 Int pending */
+#define SDIO_INT_FN2 (0x1lu << 2) /**< Function 2 Int pending */
+#define SDIO_INT_FN3 (0x1lu << 3) /**< Function 3 Int pending */
+#define SDIO_INT_FN4 (0x1lu << 4) /**< Function 4 Int pending */
+#define SDIO_INT_FN5 (0x1lu << 5) /**< Function 5 Int pending */
+#define SDIO_INT_FN6 (0x1lu << 6) /**< Function 6 Int pending */
+#define SDIO_INT_FN7 (0x1lu << 7) /**< Function 7 Int pending */
+#define SDIO_CCCR_IOA 0x06 /**< I/O Abort */
+#define SDIO_AS (0x7lu << 0) /**< Abort Select In Order (WO) */
+#define SDIO_AS_FN1 (0x1lu << 0) /**< Abort function 1 IO */
+#define SDIO_AS_FN2 (0x2lu << 0) /**< Abort function 2 IO */
+#define SDIO_AS_FN3 (0x3lu << 0) /**< Abort function 3 IO */
+#define SDIO_AS_FN4 (0x4lu << 0) /**< Abort function 4 IO */
+#define SDIO_AS_FN5 (0x5lu << 0) /**< Abort function 5 IO */
+#define SDIO_AS_FN6 (0x6lu << 0) /**< Abort function 6 IO */
+#define SDIO_AS_FN7 (0x7lu << 0) /**< Abort function 7 IO */
+#define SDIO_RES (0x1lu << 3) /**< IO CARD RESET (WO) */
+#define SDIO_CCCR_BUS_CTRL 0x07 /**< Bus Interface Control */
+#define SDIO_BUSWIDTH (0x3lu << 0) /**< Data bus width (R/W) */
+#define SDIO_BUSWIDTH_1B (0x0lu << 0) /**< 1-bit data bus */
+#define SDIO_BUSWIDTH_4B (0x2lu << 0) /**< 4-bit data bus */
+/** Enable Continuous SPI interrupt (R/W) */
+#define SDIO_BUS_ECSI (0x1lu << 5)
+/** Support Continuous SPI interrupt (RO) */
+#define SDIO_BUS_SCSI (0x1lu << 6)
+/** Connect(0)/Disconnect(1) pull-up on CD/DAT[3] (R/W) */
+#define SDIO_BUS_CD_DISABLE (0x1lu << 7)
+#define SDIO_CCCR_CAP 0x08 /**< Card Capability */
+/** Support Direct Commands during data transfer (RO) */
+#define SDIO_CAP_SDC (0x1lu << 0)
+/** Support Multi-Block (RO) */
+#define SDIO_CAP_SMB (0x1lu << 1)
+/** Support Read Wait (RO) */
+#define SDIO_CAP_SRW (0x1lu << 2)
+/** Support Suspend/Resume (RO) */
+#define SDIO_CAP_SBS (0x1lu << 3)
+/** Support interrupt between blocks of data in 4-bit SD mode (RO) */
+#define SDIO_CAP_S4MI (0x1lu << 4)
+/** Enable interrupt between blocks of data in 4-bit SD mode (R/W) */
+#define SDIO_CAP_E4MI (0x1lu << 5)
+/** Low-Speed Card (RO) */
+#define SDIO_CAP_LSC (0x1lu << 6)
+/** 4-bit support for Low-Speed Card (RO) */
+#define SDIO_CAP_4BLS (0x1lu << 7)
+/** Pointer to CIS (3B, LSB first) */
+#define SDIO_CCCR_CIS_PTR 0x09
+/** Bus Suspend */
+#define SDIO_CCCR_BUS_SUSPEND 0x0C
+/** Bus Status (transfer on DAT[x] lines) (RO) */
+#define SDIO_BS (0x1lu << 0)
+/** Bus Release Request/Status (R/W) */
+#define SDIO_BR (0x1lu << 1)
+#define SDIO_CCCR_FUN_SEL 0x0D /**< Function select */
+#define SDIO_DF (0x1lu << 7) /**< Resume Data Flag (RO) */
+#define SDIO_FS (0xFlu << 0) /**< Select Function (R/W) */
+#define SDIO_FS_CIA (0x0lu << 0) /**< Select CIA (function 0) */
+#define SDIO_FS_FN1 (0x1lu << 0) /**< Select Function 1 */
+#define SDIO_FS_FN2 (0x2lu << 0) /**< Select Function 2 */
+#define SDIO_FS_FN3 (0x3lu << 0) /**< Select Function 3 */
+#define SDIO_FS_FN4 (0x4lu << 0) /**< Select Function 4 */
+#define SDIO_FS_FN5 (0x5lu << 0) /**< Select Function 5 */
+#define SDIO_FS_FN6 (0x6lu << 0) /**< Select Function 6 */
+#define SDIO_FS_FN7 (0x7lu << 0) /**< Select Function 7 */
+#define SDIO_FS_MEM (0x8lu << 0) /**< Select memory in combo card */
+#define SDIO_CCCR_EXEC 0x0E /**< Exec Flags (RO) */
+#define SDIO_EXM (0x1lu << 0) /**< Executing status of memory */
+#define SDIO_EX (0xFElu << 1) /**< Executing functions status */
+#define SDIO_EX_FN1 (0x1lu << 1) /**< Executing status of func 1 */
+#define SDIO_EX_FN2 (0x1lu << 2) /**< Executing status of func 2 */
+#define SDIO_EX_FN3 (0x1lu << 3) /**< Executing status of func 3 */
+#define SDIO_EX_FN4 (0x1lu << 4) /**< Executing status of func 4 */
+#define SDIO_EX_FN5 (0x1lu << 5) /**< Executing status of func 5 */
+#define SDIO_EX_FN6 (0x1lu << 6) /**< Executing status of func 6 */
+#define SDIO_EX_FN7 (0x1lu << 7) /**< Executing status of func 7 */
+#define SDIO_CCCR_READY 0x0F /**< Ready Flags (RO) */
+#define SDIO_RFM (0x1lu << 0) /**< Ready Flag for memory */
+#define SDIO_RF (0xFElu) /**< Ready Flag for functions */
+#define SDIO_RF_FN1 (0x1lu << 1) /**< Ready Flag for function 1 */
+#define SDIO_RF_FN2 (0x1lu << 2) /**< Ready Flag for function 2 */
+#define SDIO_RF_FN3 (0x1lu << 3) /**< Ready Flag for function 3 */
+#define SDIO_RF_FN4 (0x1lu << 4) /**< Ready Flag for function 4 */
+#define SDIO_RF_FN5 (0x1lu << 5) /**< Ready Flag for function 5 */
+#define SDIO_RF_FN6 (0x1lu << 6) /**< Ready Flag for function 6 */
+#define SDIO_RF_FN7 (0x1lu << 7) /**< Ready Flag for function 7 */
+#define SDIO_CCCR_FN0_BLKSIZ 0x10 /**< FN0 Block Size (2B, LSB first) (R/W) */
+#define SDIO_CCCR_POWER 0x12 /**< Power Control */
+#define SDIO_SMPC (0x1lu << 0) /**< Support Master Power Control*/
+#define SDIO_EMPC (0x1lu << 1) /**< Enable Master Power Control */
+#define SDIO_CCCR_HS 0x13 /**< High-Speed */
+#define SDIO_SHS (0x1lu << 0) /**< Support High-Speed (RO) */
+#define SDIO_EHS (0x1lu << 1) /**< Enable High-Speed (R/W) */
+ //! @}
+
+//! \name SDIO Function Basic Registers (FBR)
+//! @{
+#define SDIO_FBR_ADDR(fn, x) (0x100 * (fn) + (x))
+#define SDIO_FBR_CSA_IF 0x0 /**< CSA and function interface code (RO) */
+#define SDIO_IFC (0xFUL << 0) /**< Standard SDIO Fun Interface Code */
+#define SDIO_IFC_NO_IF (0x0UL << 0) /**< No SDIO standard interface */
+#define SDIO_IFC_UART (0x1UL << 0) /**< UART */
+#define SDIO_IFC_TA_BT (0x2UL << 0) /**< Type-A Bluetooth */
+#define SDIO_IFC_TB_BT (0x3UL << 0) /**< Type-B Bluetooth */
+#define SDIO_IFC_GPS (0x4UL << 0) /**< GPS */
+#define SDIO_IFC_CAMERA (0x5UL << 0) /**< Camera */
+#define SDIO_IFC_PHS (0x6UL << 0) /**< PHS */
+#define SDIO_IFC_WLAN (0x7UL << 0) /**< WLAN */
+#define SDIO_IFC_ATA (0x8UL << 0) /**< Embedded SDIO-ATA */
+#define SDIO_IFC_EXT (0xFUL << 0) /**< Check EXT interface code */
+#define SDIO_SCSA (0x1UL << 6) /**< Function supports Code Storage Area (CSA) */
+#define SDIO_FBR_CSA (0x1UL << 7) /**< Function CSA enable */
+#define SDIO_FBR_EXT_IF 0x1 /**< Extended function interface code (RO) */
+#define SDIO_FBR_PWR 0x2 /**< function power control */
+#define SDIO_SPS (0x1UL << 0) /**< function support power selection (RO) */
+#define SDIO_EPS (0x1UL << 1) /**< Low Current Mode/High Current Mode (R/W) */
+#define SDIO_FBR_CIS_PTR 0x9 /**< Address pointer to function CIS (3B, LSB first) (RO) */
+#define SDIO_FBR_CSA_PTR 0xC /**< Address pointer to CSA (3B, LSB first) (R/W) */
+#define SDIO_FBR_CSA_DATA 0xF /**< Read/Write fifo to CSA (R/W) */
+#define SDIO_FBR_BLK_SIZ 0x10 /**< Block size (2B, LSB first) (R/W) */
+ //! @}
+
+//! \name SDIO Card Metaformat
+//! @{
+/** Null tuple (PCMCIA 3.1.9) */
+#define SDIO_CISTPL_NULL 0x00
+/** Device tuple (PCMCIA 3.2.2) */
+#define SDIO_CISTPL_DEVICE 0x01
+/** Checksum control (PCMCIA 3.1.1) */
+#define SDIO_CISTPL_CHECKSUM 0x10
+/** Level 1 version (PCMCIA 3.2.10) */
+#define SDIO_CISTPL_VERS_1 0x15
+/** Alternate Language String (PCMCIA 3.2.1) */
+#define SDIO_CISTPL_ALTSTR 0x16
+/** Manufacturer Identification String (PCMCIA 3.2.9) */
+#define SDIO_CISTPL_MANFID 0x20
+/** Function Identification (PCMCIA 3.2.7) */
+#define SDIO_CISTPL_FUNCID 0x21
+/** Function Extensions (PCMCIA 3.2.6) */
+#define SDIO_CISTPL_FUNCE 0x22
+/** Additional information for SDIO (PCMCIA 6.1.2) */
+#define SDIO_CISTPL_SDIO_STD 0x91
+/** Reserved for future SDIO (PCMCIA 6.1.3) */
+#define SDIO_CISTPL_SDIO_EXT 0x92
+/** The End-of-chain Tuple (PCMCIA 3.1.2) */
+#define SDIO_CISTPL_END 0xFF
+//! @}
+
+//! @}
+
+//! \name CSD, OCR, SCR, Switch status, extend CSD definitions
+//! @{
+
+/**
+ * \brief Macro function to extract a bits field from a large SD MMC register
+ * Used by : CSD, SCR, Switch status
+ */
+static inline uint32_t SDMMC_UNSTUFF_BITS(uint8_t *reg, uint16_t reg_size, uint16_t pos, uint8_t size)
+{
+ uint32_t value;
+ value = reg[((reg_size - pos + 7) / 8) - 1] >> (pos % 8);
+ if (((pos % 8) + size) > 8) {
+ value |= (uint32_t)reg[((reg_size - pos + 7) / 8) - 2] << (8 - (pos % 8));
+ }
+ if (((pos % 8) + size) > 16) {
+ value |= (uint32_t)reg[((reg_size - pos + 7) / 8) - 3] << (16 - (pos % 8));
+ }
+ if (((pos % 8) + size) > 24) {
+ value |= (uint32_t)reg[((reg_size - pos + 7) / 8) - 3] << (24 - (pos % 8));
+ }
+ value &= ((uint32_t)1 << size) - 1;
+ return value;
+}
+
+ //! \name CSD Fields
+ //! @{
+#define CSD_REG_BIT_SIZE 128 //!< 128 bits
+#define CSD_REG_BSIZE (CSD_REG_BIT_SIZE / 8) //!< 16 bytes
+#define CSD_STRUCTURE(csd, pos, size) SDMMC_UNSTUFF_BITS(csd, CSD_REG_BIT_SIZE, pos, size)
+#define CSD_STRUCTURE_VERSION(csd) CSD_STRUCTURE(csd, 126, 2)
+#define SD_CSD_VER_1_0 0
+#define SD_CSD_VER_2_0 1
+#define MMC_CSD_VER_1_0 0
+#define MMC_CSD_VER_1_1 1
+#define MMC_CSD_VER_1_2 2
+#define CSD_TRAN_SPEED(csd) CSD_STRUCTURE(csd, 96, 8)
+#define SD_CSD_1_0_C_SIZE(csd) CSD_STRUCTURE(csd, 62, 12)
+#define SD_CSD_1_0_C_SIZE_MULT(csd) CSD_STRUCTURE(csd, 47, 3)
+#define SD_CSD_1_0_READ_BL_LEN(csd) CSD_STRUCTURE(csd, 80, 4)
+#define SD_CSD_2_0_C_SIZE(csd) CSD_STRUCTURE(csd, 48, 22)
+#define MMC_CSD_C_SIZE(csd) CSD_STRUCTURE(csd, 62, 12)
+#define MMC_CSD_C_SIZE_MULT(csd) CSD_STRUCTURE(csd, 47, 3)
+#define MMC_CSD_READ_BL_LEN(csd) CSD_STRUCTURE(csd, 80, 4)
+#define MMC_CSD_SPEC_VERS(csd) CSD_STRUCTURE(csd, 122, 4)
+ //! @}
+
+ //! \name OCR Register Fields
+ //! @{
+#define OCR_REG_BSIZE (32 / 8) /**< 32 bits, 4 bytes */
+#define OCR_VDD_170_195 (1lu << 7)
+#define OCR_VDD_20_21 (1lu << 8)
+#define OCR_VDD_21_22 (1lu << 9)
+#define OCR_VDD_22_23 (1lu << 10)
+#define OCR_VDD_23_24 (1lu << 11)
+#define OCR_VDD_24_25 (1lu << 12)
+#define OCR_VDD_25_26 (1lu << 13)
+#define OCR_VDD_26_27 (1lu << 14)
+#define OCR_VDD_27_28 (1lu << 15)
+#define OCR_VDD_28_29 (1lu << 16)
+#define OCR_VDD_29_30 (1lu << 17)
+#define OCR_VDD_30_31 (1lu << 18)
+#define OCR_VDD_31_32 (1lu << 19)
+#define OCR_VDD_32_33 (1lu << 20)
+#define OCR_VDD_33_34 (1lu << 21)
+#define OCR_VDD_34_35 (1lu << 22)
+#define OCR_VDD_35_36 (1lu << 23)
+#define OCR_SDIO_S18R (1lu << 24) /**< Switching to 1.8V Accepted */
+#define OCR_SDIO_MP (1lu << 27) /**< Memory Present */
+#define OCR_SDIO_NF (7lu << 28) /**< Number of I/O Functions */
+#define OCR_ACCESS_MODE_MASK (3lu << 29) /**< (MMC) Access mode mask */
+#define OCR_ACCESS_MODE_BYTE (0lu << 29) /**< (MMC) Byte access mode */
+#define OCR_ACCESS_MODE_SECTOR (2lu << 29) /**< (MMC) Sector access mode */
+#define OCR_CCS (1lu << 30) /**< (SD) Card Capacity Status */
+#define OCR_POWER_UP_BUSY (1lu << 31) /**< Card power up status bit */
+ //! @}
+
+ //! \name SD SCR Register Fields
+ //! @{
+#define SD_SCR_REG_BIT_SIZE 64 //!< 64 bits
+#define SD_SCR_REG_BSIZE (SD_SCR_REG_BIT_SIZE / 8) //!< 8 bytes
+#define SD_SCR_STRUCTURE(scr, pos, size) SDMMC_UNSTUFF_BITS(scr, SD_SCR_REG_BIT_SIZE, pos, size)
+#define SD_SCR_SCR_STRUCTURE(scr) SD_SCR_STRUCTURE(scr, 60, 4)
+#define SD_SCR_SCR_STRUCTURE_1_0 0
+#define SD_SCR_SD_SPEC(scr) SD_SCR_STRUCTURE(scr, 56, 4)
+#define SD_SCR_SD_SPEC_1_0_01 0
+#define SD_SCR_SD_SPEC_1_10 1
+#define SD_SCR_SD_SPEC_2_00 2
+#define SD_SCR_DATA_STATUS_AFTER_ERASE(scr) SD_SCR_STRUCTURE(scr, 55, 1)
+#define SD_SCR_SD_SECURITY(scr) SD_SCR_STRUCTURE(scr, 52, 3)
+#define SD_SCR_SD_SECURITY_NO 0
+#define SD_SCR_SD_SECURITY_NOTUSED 1
+#define SD_SCR_SD_SECURITY_1_01 2
+#define SD_SCR_SD_SECURITY_2_00 3
+#define SD_SCR_SD_SECURITY_3_00 4
+#define SD_SCR_SD_BUS_WIDTHS(scr) SD_SCR_STRUCTURE(scr, 48, 4)
+#define SD_SCR_SD_BUS_WIDTH_1BITS (1lu << 0)
+#define SD_SCR_SD_BUS_WIDTH_4BITS (1lu << 2)
+#define SD_SCR_SD_SPEC3(scr) SD_SCR_STRUCTURE(scr, 47, 1)
+#define SD_SCR_SD_SPEC_3_00 1
+#define SD_SCR_SD_EX_SECURITY(scr) SD_SCR_STRUCTURE(scr, 43, 4)
+#define SD_SCR_SD_CMD_SUPPORT(scr) SD_SCR_STRUCTURE(scr, 32, 2)
+ //! @}
+
+ //! \name SD Switch Status Fields
+ //! @{
+#define SD_SW_STATUS_BIT_SIZE 512 //!< 512 bits
+#define SD_SW_STATUS_BSIZE (SD_SW_STATUS_BIT_SIZE / 8) //!< 64 bytes
+#define SD_SW_STATUS_STRUCTURE(sd_sw_status, pos, size) \
+ SDMMC_UNSTUFF_BITS(sd_sw_status, SD_SW_STATUS_BIT_SIZE, pos, size)
+#define SD_SW_STATUS_MAX_CURRENT_CONSUMPTION(status) SD_SW_STATUS_STRUCTURE(status, 496, 16)
+#define SD_SW_STATUS_FUN_GRP6_INFO(status) SD_SW_STATUS_STRUCTURE(status, 480, 16)
+#define SD_SW_STATUS_FUN_GRP5_INFO(status) SD_SW_STATUS_STRUCTURE(status, 464, 16)
+#define SD_SW_STATUS_FUN_GRP4_INFO(status) SD_SW_STATUS_STRUCTURE(status, 448, 16)
+#define SD_SW_STATUS_FUN_GRP3_INFO(status) SD_SW_STATUS_STRUCTURE(status, 432, 16)
+#define SD_SW_STATUS_FUN_GRP2_INFO(status) SD_SW_STATUS_STRUCTURE(status, 416, 16)
+#define SD_SW_STATUS_FUN_GRP1_INFO(status) SD_SW_STATUS_STRUCTURE(status, 400, 16)
+#define SD_SW_STATUS_FUN_GRP6_RC(status) SD_SW_STATUS_STRUCTURE(status, 396, 4)
+#define SD_SW_STATUS_FUN_GRP5_RC(status) SD_SW_STATUS_STRUCTURE(status, 392, 4)
+#define SD_SW_STATUS_FUN_GRP4_RC(status) SD_SW_STATUS_STRUCTURE(status, 388, 4)
+#define SD_SW_STATUS_FUN_GRP3_RC(status) SD_SW_STATUS_STRUCTURE(status, 384, 4)
+#define SD_SW_STATUS_FUN_GRP2_RC(status) SD_SW_STATUS_STRUCTURE(status, 380, 4)
+#define SD_SW_STATUS_FUN_GRP1_RC(status) SD_SW_STATUS_STRUCTURE(status, 376, 4)
+#define SD_SW_STATUS_FUN_GRP_RC_ERROR 0xFU
+#define SD_SW_STATUS_DATA_STRUCT_VER(status) SD_SW_STATUS_STRUCTURE(status, 368, 8)
+#define SD_SW_STATUS_FUN_GRP6_BUSY(status) SD_SW_STATUS_STRUCTURE(status, 352, 16)
+#define SD_SW_STATUS_FUN_GRP5_BUSY(status) SD_SW_STATUS_STRUCTURE(status, 336, 16)
+#define SD_SW_STATUS_FUN_GRP4_BUSY(status) SD_SW_STATUS_STRUCTURE(status, 320, 16)
+#define SD_SW_STATUS_FUN_GRP3_BUSY(status) SD_SW_STATUS_STRUCTURE(status, 304, 16)
+#define SD_SW_STATUS_FUN_GRP2_BUSY(status) SD_SW_STATUS_STRUCTURE(status, 288, 16)
+#define SD_SW_STATUS_FUN_GRP1_BUSY(status) SD_SW_STATUS_STRUCTURE(status, 272, 16)
+ //! @}
+
+ //! \name Card Status Fields
+ //! @{
+#define CARD_STATUS_APP_CMD (1lu << 5)
+#define CARD_STATUS_SWITCH_ERROR (1lu << 7)
+#define CARD_STATUS_READY_FOR_DATA (1lu << 8)
+#define CARD_STATUS_STATE_IDLE (0lu << 9)
+#define CARD_STATUS_STATE_READY (1lu << 9)
+#define CARD_STATUS_STATE_IDENT (2lu << 9)
+#define CARD_STATUS_STATE_STBY (3lu << 9)
+#define CARD_STATUS_STATE_TRAN (4lu << 9)
+#define CARD_STATUS_STATE_DATA (5lu << 9)
+#define CARD_STATUS_STATE_RCV (6lu << 9)
+#define CARD_STATUS_STATE_PRG (7lu << 9)
+#define CARD_STATUS_STATE_DIS (8lu << 9)
+#define CARD_STATUS_STATE (0xFlu << 9)
+#define CARD_STATUS_ERASE_RESET (1lu << 13)
+#define CARD_STATUS_WP_ERASE_SKIP (1lu << 15)
+#define CARD_STATUS_CIDCSD_OVERWRITE (1lu << 16)
+#define CARD_STATUS_OVERRUN (1lu << 17)
+#define CARD_STATUS_UNERRUN (1lu << 18)
+#define CARD_STATUS_ERROR (1lu << 19)
+#define CARD_STATUS_CC_ERROR (1lu << 20)
+#define CARD_STATUS_CARD_ECC_FAILED (1lu << 21)
+#define CARD_STATUS_ILLEGAL_COMMAND (1lu << 22)
+#define CARD_STATUS_COM_CRC_ERROR (1lu << 23)
+#define CARD_STATUS_UNLOCK_FAILED (1lu << 24)
+#define CARD_STATUS_CARD_IS_LOCKED (1lu << 25)
+#define CARD_STATUS_WP_VIOLATION (1lu << 26)
+#define CARD_STATUS_ERASE_PARAM (1lu << 27)
+#define CARD_STATUS_ERASE_SEQ_ERROR (1lu << 28)
+#define CARD_STATUS_BLOCK_LEN_ERROR (1lu << 29)
+#define CARD_STATUS_ADDRESS_MISALIGN (1lu << 30)
+#define CARD_STATUS_ADDR_OUT_OF_RANGE (1lu << 31)
+
+#define CARD_STATUS_ERR_RD_WR \
+ (CARD_STATUS_ADDR_OUT_OF_RANGE | CARD_STATUS_ADDRESS_MISALIGN | CARD_STATUS_BLOCK_LEN_ERROR \
+ | CARD_STATUS_WP_VIOLATION | CARD_STATUS_ILLEGAL_COMMAND | CARD_STATUS_CC_ERROR | CARD_STATUS_ERROR)
+ //! @}
+
+ //! \name SD Status Field
+ //! @{
+#define SD_STATUS_BSIZE (512 / 8) /**< 512 bits, 64bytes */
+ //! @}
+
+ //! \name MMC Extended CSD Register Field
+ //! @{
+#define EXT_CSD_BSIZE 512 /**< 512 bytes. */
+/* Below belongs to Properties Segment */
+#define EXT_CSD_S_CMD_SET_INDEX 504lu
+#define EXT_CSD_BOOT_INFO_INDEX 228lu
+#define EXT_CSD_BOOT_SIZE_MULTI_INDEX 226lu
+#define EXT_CSD_ACC_SIZE_INDEX 225lu
+#define EXT_CSD_HC_ERASE_GRP_SIZE_INDEX 224lu
+#define EXT_CSD_ERASE_TIMEOUT_MULT_INDEX 223lu
+#define EXT_CSD_REL_WR_SEC_C_INDEX 222lu
+#define EXT_CSD_HC_WP_GRP_SIZE_INDEX 221lu
+#define EXT_CSD_S_C_VCC_INDEX 220lu
+#define EXT_CSD_S_C_VCCQ_INDEX 219lu
+#define EXT_CSD_S_A_TIMEOUT_INDEX 217lu
+#define EXT_CSD_SEC_COUNT_INDEX 212lu
+#define EXT_CSD_MIN_PERF_W_8_52_INDEX 210lu
+#define EXT_CSD_MIN_PERF_R_8_52_INDEX 209lu
+#define EXT_CSD_MIN_PERF_W_8_26_4_52_INDEX 208lu
+#define EXT_CSD_MIN_PERF_R_8_26_4_52_INDEX 207lu
+#define EXT_CSD_MIN_PERF_W_4_26_INDEX 206lu
+#define EXT_CSD_MIN_PERF_R_4_26_INDEX 205lu
+#define EXT_CSD_PWR_CL_26_360_INDEX 203lu
+#define EXT_CSD_PWR_CL_52_360_INDEX 202lu
+#define EXT_CSD_PWR_CL_26_195_INDEX 201lu
+#define EXT_CSD_PWR_CL_52_195_INDEX 200lu
+#define EXT_CSD_CARD_TYPE_INDEX 196lu
+/* MMC card type */
+#define MMC_CTYPE_26MHZ 0x1
+#define MMC_CTYPE_52MHZ 0x2
+#define EXT_CSD_CSD_STRUCTURE_INDEX 194lu
+#define EXT_CSD_EXT_CSD_REV_INDEX 192lu
+
+/* Below belongs to Mode Segment */
+#define EXT_CSD_CMD_SET_INDEX 191lu
+#define EXT_CSD_CMD_SET_REV_INDEX 189lu
+#define EXT_CSD_POWER_CLASS_INDEX 187lu
+#define EXT_CSD_HS_TIMING_INDEX 185lu
+#define EXT_CSD_BUS_WIDTH_INDEX 183lu
+#define EXT_CSD_ERASED_MEM_CONT_INDEX 181lu
+#define EXT_CSD_BOOT_CONFIG_INDEX 179lu
+#define EXT_CSD_BOOT_BUS_WIDTH_INDEX 177lu
+#define EXT_CSD_ERASE_GROUP_DEF_INDEX 175lu
+ //! @}
+//! @}
+
+//! \name Definition for SPI mode only
+//! @{
+
+//! SPI commands start with a start bit "0" and a transmit bit "1"
+#define SPI_CMD_ENCODE(x) (0x40 | (x & 0x3F))
+
+//! \name Register R1 definition for SPI mode
+//! The R1 register is always send after a command.
+//! @{
+#define R1_SPI_IDLE (1lu << 0)
+#define R1_SPI_ERASE_RESET (1lu << 1)
+#define R1_SPI_ILLEGAL_COMMAND (1lu << 2)
+#define R1_SPI_COM_CRC (1lu << 3)
+#define R1_SPI_ERASE_SEQ (1lu << 4)
+#define R1_SPI_ADDRESS (1lu << 5)
+#define R1_SPI_PARAMETER (1lu << 6)
+// R1 bit 7 is always zero, reuse this bit for error
+#define R1_SPI_ERROR (1lu << 7)
+//! @}
+
+//! \name Register R2 definition for SPI mode
+//! The R2 register can be send after R1 register.
+//! @{
+#define R2_SPI_CARD_LOCKED (1lu << 0)
+#define R2_SPI_WP_ERASE_SKIP (1lu << 1)
+#define R2_SPI_LOCK_UNLOCK_FAIL R2_SPI_WP_ERASE_SKIP
+#define R2_SPI_ERROR (1lu << 2)
+#define R2_SPI_CC_ERROR (1lu << 3)
+#define R2_SPI_CARD_ECC_ERROR (1lu << 4)
+#define R2_SPI_WP_VIOLATION (1lu << 5)
+#define R2_SPI_ERASE_PARAM (1lu << 6)
+#define R2_SPI_OUT_OF_RANGE (1lu << 7)
+#define R2_SPI_CSD_OVERWRITE R2_SPI_OUT_OF_RANGE
+//! @}
+
+//! \name Control Tokens in SPI Mode
+//! @{
+//! \name Tokens used for a read operation
+//! @{
+#define SPI_TOKEN_SINGLE_MULTI_READ 0xFE
+#define SPI_TOKEN_DATA_ERROR_VALID(token) (((token)&0xF0) == 0)
+#define SPI_TOKEN_DATA_ERROR_ERRORS (0x0F)
+#define SPI_TOKEN_DATA_ERROR_ERROR (1lu << 0)
+#define SPI_TOKEN_DATA_ERROR_CC_ERROR (1lu << 1)
+#define SPI_TOKEN_DATA_ERROR_ECC_ERROR (1lu << 2)
+#define SPI_TOKEN_DATA_ERROR_OUT_RANGE (1lu << 3)
+ //! @}
+ //! \name Tokens used for a write operation
+ //! @{
+#define SPI_TOKEN_SINGLE_WRITE 0xFE
+#define SPI_TOKEN_MULTI_WRITE 0xFC
+#define SPI_TOKEN_STOP_TRAN 0xFD
+#define SPI_TOKEN_DATA_RESP_VALID(token) ((((token) & (1 << 4)) == 0) && (((token) & (1 << 0)) == 1))
+#define SPI_TOKEN_DATA_RESP_CODE(token) ((token)&0x1E)
+#define SPI_TOKEN_DATA_RESP_ACCEPTED (2lu << 1)
+#define SPI_TOKEN_DATA_RESP_CRC_ERR (5lu << 1)
+#define SPI_TOKEN_DATA_RESP_WRITE_ERR (6lu << 1)
+ //! @}
+ //! @}
+ //! @}
+
+ //! @} end of sd_mmc_protocol
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* SD_MMC_PROTOCOL_H_INCLUDED */
diff --git a/ports/atmel-samd/supervisor/internal_flash.c b/ports/atmel-samd/supervisor/internal_flash.c
index 091959c4e..ecb59f836 100644
--- a/ports/atmel-samd/supervisor/internal_flash.c
+++ b/ports/atmel-samd/supervisor/internal_flash.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/ports/atmel-samd/supervisor/internal_flash.h b/ports/atmel-samd/supervisor/internal_flash.h
index df8b495cc..1199e3b9c 100644
--- a/ports/atmel-samd/supervisor/internal_flash.h
+++ b/ports/atmel-samd/supervisor/internal_flash.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/ports/atmel-samd/supervisor/port.c b/ports/atmel-samd/supervisor/port.c
index 48bd3211b..65501861e 100644
--- a/ports/atmel-samd/supervisor/port.c
+++ b/ports/atmel-samd/supervisor/port.c
@@ -91,6 +91,23 @@
#if CIRCUITPY_PEW
#include "common-hal/_pew/PewPew.h"
#endif
+volatile bool hold_interrupt = false;
+#ifdef SAMD21
+void rtc_start_pulsein(void) {
+ rtc_set_continuous();
+ hold_interrupt = true;
+}
+
+void rtc_end_pulsein(void) {
+ hold_interrupt = false;
+}
+
+void rtc_set_continuous(void) {
+ while (RTC->MODE0.STATUS.bit.SYNCBUSY);
+ RTC->MODE0.READREQ.reg = RTC_READREQ_RREQ | RTC_READREQ_RCONT | 0x0010;
+ while (RTC->MODE0.STATUS.bit.SYNCBUSY);
+}
+#endif
extern volatile bool mp_msc_enabled;
@@ -189,11 +206,10 @@ static void rtc_init(void) {
safe_mode_t port_init(void) {
#if defined(SAMD21)
- // Set brownout detection to ~2.7V. Default from factory is 1.7V,
- // which is too low for proper operation of external SPI flash chips (they are 2.7-3.6V).
+ // Set brownout detection.
// Disable while changing level.
SYSCTRL->BOD33.bit.ENABLE = 0;
- SYSCTRL->BOD33.bit.LEVEL = 39; // 2.77V with hysteresis off. Table 37.20 in datasheet.
+ SYSCTRL->BOD33.bit.LEVEL = SAMD21_BOD33_LEVEL;
SYSCTRL->BOD33.bit.ENABLE = 1;
#ifdef ENABLE_MICRO_TRACE_BUFFER
@@ -208,11 +224,10 @@ safe_mode_t port_init(void) {
#endif
#if defined(SAM_D5X_E5X)
- // Set brownout detection to ~2.7V. Default from factory is 1.7V,
- // which is too low for proper operation of external SPI flash chips (they are 2.7-3.6V).
+ // Set brownout detection.
// Disable while changing level.
SUPC->BOD33.bit.ENABLE = 0;
- SUPC->BOD33.bit.LEVEL = 200; // 2.7V: 1.5V + LEVEL * 6mV.
+ SUPC->BOD33.bit.LEVEL = SAMD5x_E5x_BOD33_LEVEL;
SUPC->BOD33.bit.ENABLE = 1;
// MPU (Memory Protection Unit) setup.
@@ -489,6 +504,11 @@ void port_interrupt_after_ticks(uint32_t ticks) {
// We'll interrupt sooner with an overflow.
return;
}
+#ifdef SAMD21
+ if (hold_interrupt) {
+ return;
+ }
+#endif
RTC->MODE0.COMP[0].reg = current_ticks + (ticks << 4);
RTC->MODE0.INTFLAG.reg = RTC_MODE0_INTFLAG_CMP0;
RTC->MODE0.INTENSET.reg = RTC_MODE0_INTENSET_CMP0;
@@ -503,7 +523,7 @@ void port_sleep_until_interrupt(void) {
}
#endif
common_hal_mcu_disable_interrupts();
- if (!tud_task_event_ready()) {
+ if (!tud_task_event_ready() && !hold_interrupt) {
__DSB();
__WFI();
}
diff --git a/ports/atmel-samd/supervisor/usb.c b/ports/atmel-samd/supervisor/usb.c
index 650ed6a39..ea940f898 100644
--- a/ports/atmel-samd/supervisor/usb.c
+++ b/ports/atmel-samd/supervisor/usb.c
@@ -29,6 +29,8 @@
#include "hpl/gclk/hpl_gclk_base.h"
#include "hal_gpio.h"
#include "lib/tinyusb/src/device/usbd.h"
+#include "supervisor/background_callback.h"
+#include "supervisor/usb.h"
void init_usb_hardware(void) {
#ifdef SAMD21
@@ -61,24 +63,24 @@ void init_usb_hardware(void) {
#ifdef SAMD21
void USB_Handler(void) {
- tud_int_handler(0);
+ usb_irq_handler();
}
#endif
#ifdef SAM_D5X_E5X
void USB_0_Handler (void) {
- tud_int_handler(0);
+ usb_irq_handler();
}
void USB_1_Handler (void) {
- tud_int_handler(0);
+ usb_irq_handler();
}
void USB_2_Handler (void) {
- tud_int_handler(0);
+ usb_irq_handler();
}
void USB_3_Handler (void) {
- tud_int_handler(0);
+ usb_irq_handler();
}
#endif
diff --git a/ports/atmel-samd/tools/gen_pin_name_table.py b/ports/atmel-samd/tools/gen_pin_name_table.py
index ded64e5f6..4e25c39fd 100644
--- a/ports/atmel-samd/tools/gen_pin_name_table.py
+++ b/ports/atmel-samd/tools/gen_pin_name_table.py
@@ -2,7 +2,7 @@
#
# The MIT License (MIT)
#
-# Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
+# SPDX-FileCopyrightText: Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
diff --git a/ports/cxd56/Makefile b/ports/cxd56/Makefile
index 507d76331..b3e104e1e 100644
--- a/ports/cxd56/Makefile
+++ b/ports/cxd56/Makefile
@@ -62,6 +62,13 @@ SPRESENSE_SDK = spresense-exported-sdk
FIRMWARE = $(SPRESENSE_SDK)/firmware
+BOOTLOADER_FILES += \
+ $(FIRMWARE)/AESM.espk \
+ $(FIRMWARE)/dnnrt-mp.espk \
+ $(FIRMWARE)/gnssfw.espk \
+ $(FIRMWARE)/loader.espk \
+ $(FIRMWARE)/sysutil.spk \
+
# Platforms are: Linux, Darwin, MSYS, CYGWIN
PLATFORM := $(firstword $(subst _, ,$(shell uname -s 2>/dev/null)))
@@ -91,8 +98,7 @@ INC += \
-I$(SPRESENSE_SDK)/nuttx/arch \
-I$(SPRESENSE_SDK)/nuttx/arch/chip \
-I$(SPRESENSE_SDK)/nuttx/arch/os \
- -I$(SPRESENSE_SDK)/sdk/bsp/include \
- -I$(SPRESENSE_SDK)/sdk/bsp/include/sdk \
+ -I$(SPRESENSE_SDK)/sdk/include \
CFLAGS += \
$(INC) \
@@ -101,7 +107,6 @@ CFLAGS += \
-Dmain=spresense_main \
-D_estack=__stack \
-c \
- -Os \
-pipe \
-std=gnu11 \
-mcpu=cortex-m4 \
@@ -117,6 +122,12 @@ CFLAGS += \
-fdata-sections \
-Wall \
+OPTIMIZATION_FLAGS ?= -O2
+
+# option to override compiler optimization level, set in boards/$(BOARD)/mpconfigboard.mk
+CFLAGS += $(OPTIMIZATION_FLAGS)
+
+
LIBM = "${shell "$(CC)" $(CFLAGS) -print-file-name=libm.a}"
LIBGCC = "${shell "$(CC)" $(CFLAGS) -print-libgcc-file-name}"
@@ -125,7 +136,7 @@ LDFLAGS = \
--entry=__start \
-nostartfiles \
-nodefaultlibs \
- -T$(SPRESENSE_SDK)/nuttx/build/ramconfig.ld \
+ -T$(SPRESENSE_SDK)/nuttx/scripts/ramconfig.ld \
--gc-sections \
-Map=$(BUILD)/output.map \
-o $(BUILD)/firmware.elf \
@@ -133,8 +144,8 @@ LDFLAGS = \
-u spresense_main \
-u board_timerhook \
$(BUILD)/libmpy.a \
- $(SPRESENSE_SDK)/sdk/libs/libapps.a \
- $(SPRESENSE_SDK)/sdk/libs/libsdk.a \
+ $(SPRESENSE_SDK)/nuttx/libs/libapps.a \
+ $(SPRESENSE_SDK)/nuttx/libs/libnuttx.a \
$(LIBM) \
$(LIBGCC) \
--end-group \
@@ -213,11 +224,11 @@ $(BUILD)/firmware.spk: $(BUILD)/firmware.elf $(MKSPK)
flash: $(BUILD)/firmware.spk
$(ECHO) "Writing $< to the board"
- $(SPRESENSE_SDK)/sdk/tools/flash.sh -c $(SERIAL) $(BUILD)/firmware.spk
+ tools/flash_writer.py -s -c $(SERIAL) -d -b 115200 -n $(BUILD)/firmware.spk
flash-bootloader: $(SPRESENSE_SDK) $(FIRMWARE)
$(ECHO) "Writing loader to the board"
- $(SPRESENSE_SDK)/sdk/tools/flash.sh -l $(FIRMWARE) -c $(SERIAL)
+ tools/flash_writer.py -s -c $(SERIAL) -d -b 115200 -n $(BOOTLOADER_FILES)
include $(TOP)/py/mkrules.mk
diff --git a/ports/cxd56/README.md b/ports/cxd56/README.md
index ec284e742..7fa439aac 100644
--- a/ports/cxd56/README.md
+++ b/ports/cxd56/README.md
@@ -16,7 +16,7 @@ Board features:
* Spresense is powered by Sony's CXD5602 microcontroller (ARM® Cortex®-M4F × 6
cores), with a clock speed of 156 MHz.
-Currently, Spresense port does not support GNSS, Audio and Multicore.
+Currently, Spresense port does not support Audio and Multicore.
Refer to [developer.sony.com/develop/spresense/](https://developer.sony.com/develop/spresense/)
for further information about this board.
@@ -75,7 +75,7 @@ Bootloader information:
* You have to accept the End User License Agreement to be able to download and use the Spresense bootloader binary.
-Download the spresense binaries zip archive from: [Spresense firmware v1-4-000](https://developer.sony.com/file/download/download-spresense-firmware-v1-4-000)
+Download the spresense binaries zip archive from: [Spresense firmware v2-0-000](https://developer.sony.com/file/download/download-spresense-firmware-v2-0-000)
Extract spresense binaries in your PC to ports/spresense/spresense-exported-sdk/firmware/
diff --git a/ports/cxd56/background.c b/ports/cxd56/background.c
index ade257dd2..6de6d7275 100644
--- a/ports/cxd56/background.c
+++ b/ports/cxd56/background.c
@@ -30,24 +30,6 @@
#include "supervisor/filesystem.h"
#include "supervisor/shared/stack.h"
-static bool running_background_tasks = false;
-
-void background_tasks_reset(void) {
- running_background_tasks = false;
-}
-
-void run_background_tasks(void) {
- // Don't call ourselves recursively.
- if (running_background_tasks) {
- return;
- }
-
- assert_heap_ok();
- running_background_tasks = true;
-
- usb_background();
- filesystem_background();
-
- running_background_tasks = false;
- assert_heap_ok();
-}
+void port_background_task(void) {}
+void port_start_background_task(void) {}
+void port_finish_background_task(void) {}
diff --git a/ports/cxd56/background.h b/ports/cxd56/background.h
index a38e3faed..5f76e6442 100644
--- a/ports/cxd56/background.h
+++ b/ports/cxd56/background.h
@@ -27,7 +27,4 @@
#ifndef MICROPY_INCLUDED_CXD56_BACKGROUND_H
#define MICROPY_INCLUDED_CXD56_BACKGROUND_H
-void background_tasks_reset(void);
-void run_background_tasks(void);
-
#endif // MICROPY_INCLUDED_CXD56_BACKGROUND_H
diff --git a/ports/cxd56/boards/spresense/pins.c b/ports/cxd56/boards/spresense/pins.c
index fcc854590..5028d9155 100644
--- a/ports/cxd56/boards/spresense/pins.c
+++ b/ports/cxd56/boards/spresense/pins.c
@@ -24,8 +24,21 @@
* THE SOFTWARE.
*/
+#include "py/objtuple.h"
+
#include "shared-bindings/board/__init__.h"
+STATIC const mp_rom_obj_tuple_t sdio_data_tuple = {
+ {&mp_type_tuple},
+ 4,
+ {
+ MP_ROM_PTR(&pin_SDIO_DATA0),
+ MP_ROM_PTR(&pin_SDIO_DATA1),
+ MP_ROM_PTR(&pin_SDIO_DATA2),
+ MP_ROM_PTR(&pin_SDIO_DATA3),
+ }
+};
+
STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_UART2_RXD) },
{ MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_UART2_TXD) },
@@ -76,5 +89,8 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
{ MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) },
{ MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) },
+ { MP_ROM_QSTR(MP_QSTR_SDIO_CLOCK), MP_ROM_PTR(&pin_SDIO_CLK) },
+ { MP_ROM_QSTR(MP_QSTR_SDIO_COMMAND), MP_ROM_PTR(&pin_SDIO_CMD) },
+ { MP_ROM_QSTR(MP_QSTR_SDIO_DATA), MP_ROM_PTR(&sdio_data_tuple) },
};
MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);
diff --git a/ports/cxd56/common-hal/busio/SPI.c b/ports/cxd56/common-hal/busio/SPI.c
index 718a8ff16..2d365d482 100644
--- a/ports/cxd56/common-hal/busio/SPI.c
+++ b/ports/cxd56/common-hal/busio/SPI.c
@@ -130,7 +130,7 @@ bool common_hal_busio_spi_read(busio_spi_obj_t *self, uint8_t *data, size_t len,
return true;
}
-bool common_hal_busio_spi_transfer(busio_spi_obj_t *self, uint8_t *data_out, uint8_t *data_in, size_t len) {
+bool common_hal_busio_spi_transfer(busio_spi_obj_t *self, const uint8_t *data_out, uint8_t *data_in, size_t len) {
SPI_EXCHANGE(self->spi_dev, data_out, data_in, len);
return true;
diff --git a/ports/cxd56/common-hal/busio/UART.c b/ports/cxd56/common-hal/busio/UART.c
index e455b0568..52d2afc0c 100644
--- a/ports/cxd56/common-hal/busio/UART.c
+++ b/ports/cxd56/common-hal/busio/UART.c
@@ -56,7 +56,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
const mcu_pin_obj_t * tx, const mcu_pin_obj_t * rx,
const mcu_pin_obj_t * rts, const mcu_pin_obj_t * cts,
const mcu_pin_obj_t * rs485_dir, bool rs485_invert,
- uint32_t baudrate, uint8_t bits, uart_parity_t parity, uint8_t stop,
+ uint32_t baudrate, uint8_t bits, busio_uart_parity_t parity, uint8_t stop,
mp_float_t timeout, uint16_t receiver_buffer_size, byte* receiver_buffer,
bool sigint_enabled) {
struct termios tio;
@@ -69,7 +69,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
mp_raise_ValueError(translate("Could not initialize UART"));
}
- if (parity != PARITY_NONE) {
+ if (parity != BUSIO_UART_PARITY_NONE) {
mp_raise_ValueError(translate("Could not initialize UART"));
}
diff --git a/ports/cxd56/common-hal/microcontroller/Pin.c b/ports/cxd56/common-hal/microcontroller/Pin.c
index 23377197c..7aba1ad54 100644
--- a/ports/cxd56/common-hal/microcontroller/Pin.c
+++ b/ports/cxd56/common-hal/microcontroller/Pin.c
@@ -72,6 +72,12 @@ const mcu_pin_obj_t pin_I2S1_BCK = PIN(PIN_I2S1_BCK, false);
const mcu_pin_obj_t pin_I2S1_LRCK = PIN(PIN_I2S1_LRCK, false);
const mcu_pin_obj_t pin_I2S1_DATA_IN = PIN(PIN_I2S1_DATA_IN, false);
const mcu_pin_obj_t pin_I2S1_DATA_OUT = PIN(PIN_I2S1_DATA_OUT, false);
+const mcu_pin_obj_t pin_SDIO_CLK = PIN(PIN_SDIO_CLK, false);
+const mcu_pin_obj_t pin_SDIO_CMD = PIN(PIN_SDIO_CMD, false);
+const mcu_pin_obj_t pin_SDIO_DATA0 = PIN(PIN_SDIO_DATA0, false);
+const mcu_pin_obj_t pin_SDIO_DATA1 = PIN(PIN_SDIO_DATA1, false);
+const mcu_pin_obj_t pin_SDIO_DATA2 = PIN(PIN_SDIO_DATA2, false);
+const mcu_pin_obj_t pin_SDIO_DATA3 = PIN(PIN_SDIO_DATA3, false);
const mcu_pin_obj_t pin_LPADC0 = PIN(0, true);
const mcu_pin_obj_t pin_LPADC1 = PIN(1, true);
const mcu_pin_obj_t pin_LPADC2 = PIN(2, true);
diff --git a/ports/cxd56/common-hal/microcontroller/Pin.h b/ports/cxd56/common-hal/microcontroller/Pin.h
index fe6524edb..6759a2dca 100644
--- a/ports/cxd56/common-hal/microcontroller/Pin.h
+++ b/ports/cxd56/common-hal/microcontroller/Pin.h
@@ -77,6 +77,12 @@ extern const mcu_pin_obj_t pin_I2S1_BCK;
extern const mcu_pin_obj_t pin_I2S1_LRCK;
extern const mcu_pin_obj_t pin_I2S1_DATA_IN;
extern const mcu_pin_obj_t pin_I2S1_DATA_OUT;
+extern const mcu_pin_obj_t pin_SDIO_CLK;
+extern const mcu_pin_obj_t pin_SDIO_CMD;
+extern const mcu_pin_obj_t pin_SDIO_DATA0;
+extern const mcu_pin_obj_t pin_SDIO_DATA1;
+extern const mcu_pin_obj_t pin_SDIO_DATA2;
+extern const mcu_pin_obj_t pin_SDIO_DATA3;
extern const mcu_pin_obj_t pin_LPADC0;
extern const mcu_pin_obj_t pin_LPADC1;
extern const mcu_pin_obj_t pin_LPADC2;
diff --git a/ports/cxd56/common-hal/pulseio/PWMOut.h b/ports/cxd56/common-hal/pulseio/PWMOut.h
index 57fc4181f..694acc4e0 100644
--- a/ports/cxd56/common-hal/pulseio/PWMOut.h
+++ b/ports/cxd56/common-hal/pulseio/PWMOut.h
@@ -27,7 +27,7 @@
#ifndef MICROPY_INCLUDED_CXD56_COMMON_HAL_PULSEIO_PWMOUT_H
#define MICROPY_INCLUDED_CXD56_COMMON_HAL_PULSEIO_PWMOUT_H
-#include <nuttx/drivers/pwm.h>
+#include <nuttx/timers/pwm.h>
#include "common-hal/microcontroller/Pin.h"
diff --git a/ports/cxd56/common-hal/sdioio/SDCard.c b/ports/cxd56/common-hal/sdioio/SDCard.c
new file mode 100644
index 000000000..cf7de422c
--- /dev/null
+++ b/ports/cxd56/common-hal/sdioio/SDCard.c
@@ -0,0 +1,141 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright 2020 Sony Semiconductor Solutions Corporation
+ *
+ * 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 <fcntl.h>
+#include <unistd.h>
+#include <arch/chip/pin.h>
+
+#include "py/mperrno.h"
+#include "py/runtime.h"
+
+#include "shared-bindings/sdioio/SDCard.h"
+#include "shared-bindings/util.h"
+
+#define DATA_PINS_NUM 4
+
+void common_hal_sdioio_sdcard_construct(sdioio_sdcard_obj_t *self,
+ const mcu_pin_obj_t *clock, const mcu_pin_obj_t *command,
+ uint8_t num_data, mcu_pin_obj_t **data, uint32_t frequency) {
+ struct geometry geo;
+
+ if (clock->number != PIN_SDIO_CLK || command->number != PIN_SDIO_CMD) {
+ mp_raise_ValueError(translate("Invalid pins"));
+ }
+
+ uint8_t data_pins_num = 0;
+ for (uint8_t i = 0; i < DATA_PINS_NUM; i++) {
+ if (data[i]->number != PIN_SDIO_DATA0 || data[i]->number != PIN_SDIO_DATA1 ||
+ data[i]->number != PIN_SDIO_DATA2 || data[i]->number != PIN_SDIO_DATA3) {
+ data_pins_num++;
+ }
+ }
+
+ if (data_pins_num != DATA_PINS_NUM) {
+ mp_raise_ValueError(translate("Invalid pins"));
+ }
+
+ if (open_blockdriver("/dev/mmcsd0", 0, &self->inode) < 0) {
+ mp_raise_ValueError(translate("Could not initialize SDCard"));
+ }
+
+ self->inode->u.i_bops->geometry(self->inode, &geo);
+
+ claim_pin(clock);
+ claim_pin(command);
+ self->clock_pin = clock;
+ self->command_pin = command;
+ for (uint8_t i = 0; i < DATA_PINS_NUM; i++) {
+ claim_pin(data[i]);
+ self->data_pins[i] = data[i];
+ }
+
+ self->count = geo.geo_nsectors;
+ self->frequency = frequency;
+ self->width = num_data;
+}
+
+void common_hal_sdioio_sdcard_deinit(sdioio_sdcard_obj_t *self) {
+ close_blockdriver(self->inode);
+ self->inode = NULL;
+
+ reset_pin_number(self->clock_pin->number);
+ reset_pin_number(self->command_pin->number);
+ for (uint8_t i = 0; i < DATA_PINS_NUM; i++) {
+ reset_pin_number(self->data_pins[i]->number);
+ }
+}
+
+bool common_hal_sdioio_sdcard_deinited(sdioio_sdcard_obj_t *self) {
+ return self->inode == NULL;
+}
+
+bool common_hal_sdioio_sdcard_configure(sdioio_sdcard_obj_t *self, uint32_t baudrate, uint8_t width) {
+ return true;
+}
+
+uint32_t common_hal_sdioio_sdcard_get_frequency(sdioio_sdcard_obj_t* self) {
+ return self->frequency;
+}
+
+uint8_t common_hal_sdioio_sdcard_get_width(sdioio_sdcard_obj_t* self) {
+ return self->width;
+}
+
+uint32_t common_hal_sdioio_sdcard_get_count(sdioio_sdcard_obj_t* self) {
+ return self->count;
+}
+
+STATIC void check_whole_block(mp_buffer_info_t *bufinfo) {
+ if (bufinfo->len % 512) {
+ mp_raise_ValueError(translate("Buffer length must be a multiple of 512"));
+ }
+}
+
+int common_hal_sdioio_sdcard_readblocks(sdioio_sdcard_obj_t* self, uint32_t start_block, mp_buffer_info_t *bufinfo) {
+ if (common_hal_sdioio_sdcard_deinited(self)) {
+ raise_deinited_error();
+ }
+ check_whole_block(bufinfo);
+
+ return self->inode->u.i_bops->read(self->inode, bufinfo->buf, start_block, bufinfo->len / 512);
+}
+
+int common_hal_sdioio_sdcard_writeblocks(sdioio_sdcard_obj_t* self, uint32_t start_block, mp_buffer_info_t *bufinfo) {
+ if (common_hal_sdioio_sdcard_deinited(self)) {
+ raise_deinited_error();
+ }
+ check_whole_block(bufinfo);
+
+ return self->inode->u.i_bops->write(self->inode, bufinfo->buf, start_block, bufinfo->len / 512);;
+}
+
+void common_hal_sdioio_sdcard_never_reset(sdioio_sdcard_obj_t *self) {
+ never_reset_pin_number(self->clock_pin->number);
+ never_reset_pin_number(self->command_pin->number);
+ for (uint8_t i = 0; i < DATA_PINS_NUM; i++) {
+ never_reset_pin_number(self->data_pins[i]->number);
+ }
+}
diff --git a/ports/cxd56/common-hal/sdioio/SDCard.h b/ports/cxd56/common-hal/sdioio/SDCard.h
new file mode 100644
index 000000000..cbdcd4706
--- /dev/null
+++ b/ports/cxd56/common-hal/sdioio/SDCard.h
@@ -0,0 +1,47 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright 2020 Sony Semiconductor Solutions Corporation
+ *
+ * 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_CXD56_SDIOIO_SDCARD_H
+#define MICROPY_INCLUDED_CXD56_SDIOIO_SDCARD_H
+
+#include <nuttx/fs/fs.h>
+
+#include "py/obj.h"
+
+#include "common-hal/microcontroller/Pin.h"
+
+typedef struct {
+ mp_obj_base_t base;
+ struct inode* inode;
+ uint32_t frequency;
+ uint32_t count;
+ uint8_t width;
+ const mcu_pin_obj_t *command_pin;
+ const mcu_pin_obj_t *clock_pin;
+ const mcu_pin_obj_t *data_pins[4];
+} sdioio_sdcard_obj_t;
+
+#endif // MICROPY_INCLUDED_CXD56_SDIOIO_SDCARD_H
diff --git a/ports/cxd56/common-hal/sdioio/__init__.c b/ports/cxd56/common-hal/sdioio/__init__.c
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/ports/cxd56/common-hal/sdioio/__init__.c
diff --git a/ports/cxd56/configs/circuitpython/defconfig b/ports/cxd56/configs/circuitpython/defconfig
new file mode 100644
index 000000000..268f7a68e
--- /dev/null
+++ b/ports/cxd56/configs/circuitpython/defconfig
@@ -0,0 +1,171 @@
+#
+# This file is autogenerated: PLEASE DO NOT EDIT IT.
+#
+# You can use "make menuconfig" to make any modifications to the installed .config file.
+# You can then do "make savedefconfig" to generate a new defconfig file that includes your
+# modifications.
+#
+# CONFIG_ARCH_LEDS is not set
+# CONFIG_CXD56_I2C0_SCUSEQ is not set
+# CONFIG_CXD56_SFC is not set
+# CONFIG_CXD56_SPI3_SCUSEQ is not set
+# CONFIG_MMCSD_MMCSUPPORT is not set
+# CONFIG_MMCSD_SPI is not set
+# CONFIG_MTD_SMART_WEAR_LEVEL is not set
+# CONFIG_NET_IPv4 is not set
+# CONFIG_NXFONTS_PACKEDMSFIRST is not set
+# CONFIG_STANDARD_SERIAL is not set
+CONFIG_ARCH="arm"
+CONFIG_ARCH_BOARD="spresense"
+CONFIG_ARCH_BOARD_SPRESENSE=y
+CONFIG_ARCH_CHIP="cxd56xx"
+CONFIG_ARCH_CHIP_CXD56XX=y
+CONFIG_ARCH_INTERRUPTSTACK=2048
+CONFIG_ARCH_MATH_H=y
+CONFIG_ARCH_STACKDUMP=y
+CONFIG_ARMV7M_USEBASEPRI=y
+CONFIG_ASMP=y
+CONFIG_AUDIO=y
+CONFIG_AUDIOUTILS_DSP_MOUNTPT="/mnt/sd0/BIN"
+CONFIG_AUDIOUTILS_MANAGER=y
+CONFIG_AUDIOUTILS_PLAYER=y
+CONFIG_AUDIOUTILS_PLAYLIST=y
+CONFIG_AUDIOUTILS_RECORDER=y
+CONFIG_BOARDCTL_IOCTL=y
+CONFIG_BOARDCTL_POWEROFF=y
+CONFIG_BOARDCTL_RESET=y
+CONFIG_BOARDCTL_UNIQUEID=y
+CONFIG_BOARDCTL_UNIQUEID_SIZE=5
+CONFIG_BOARDCTL_USBDEVCTRL=y
+CONFIG_BOARD_CRASHDUMP=y
+CONFIG_BOARD_LATE_INITIALIZE=y
+CONFIG_BOARD_LOOPSPERMSEC=5434
+CONFIG_BOOT_RUNFROMISRAM=y
+CONFIG_BUILTIN=y
+CONFIG_CLOCK_MONOTONIC=y
+CONFIG_CXD56_ADC=y
+CONFIG_CXD56_AUDIO=y
+CONFIG_CXD56_BINARY=y
+CONFIG_CXD56_CHARGER=y
+CONFIG_CXD56_CISIF=y
+CONFIG_CXD56_GAUGE=y
+CONFIG_CXD56_GNSS=y
+CONFIG_CXD56_HPADC0=y
+CONFIG_CXD56_HPADC1=y
+CONFIG_CXD56_I2C0=y
+CONFIG_CXD56_I2C2=y
+CONFIG_CXD56_I2C=y
+CONFIG_CXD56_I2C_DRIVER=y
+CONFIG_CXD56_IMAGEPROC=y
+CONFIG_CXD56_LPADC=y
+CONFIG_CXD56_PWM0=y
+CONFIG_CXD56_PWM1=y
+CONFIG_CXD56_PWM2=y
+CONFIG_CXD56_PWM3=y
+CONFIG_CXD56_PWM=y
+CONFIG_CXD56_SDIO=y
+CONFIG_CXD56_SPI3=y
+CONFIG_CXD56_SPI5=y
+CONFIG_CXD56_SPI=y
+CONFIG_CXD56_UART2=y
+CONFIG_DEBUG_FULLOPT=y
+CONFIG_DEBUG_SYMBOLS=y
+CONFIG_DNN_RT=y
+CONFIG_DNN_RT_MP=y
+CONFIG_DRIVERS_VIDEO=y
+CONFIG_EXTERNALS_CMSIS=y
+CONFIG_FAT_LCNAMES=y
+CONFIG_FAT_LFN=y
+CONFIG_FAT_MAXFNAME=64
+CONFIG_FS_FAT=y
+CONFIG_FS_PROCFS=y
+CONFIG_FS_PROCFS_REGISTER=y
+CONFIG_FS_ROMFS=y
+CONFIG_FS_SMARTFS=y
+CONFIG_HAVE_CXX=y
+CONFIG_HAVE_CXXINITIALIZE=y
+CONFIG_LCD=y
+CONFIG_LCD_NOGETRUN=y
+CONFIG_LIBC_FLOATINGPOINT=y
+CONFIG_LIBC_IPv4_ADDRCONV=y
+CONFIG_LIBC_IPv6_ADDRCONV=y
+CONFIG_LIB_KBDCODEC=y
+CONFIG_MAX_WDOGPARMS=2
+CONFIG_MEMUTILS=y
+CONFIG_MMCSD=y
+CONFIG_MMCSD_SDIO=y
+CONFIG_MTD=y
+CONFIG_MTD_BYTE_WRITE=y
+CONFIG_MTD_SMART=y
+CONFIG_MTD_SMART_ENABLE_CRC=y
+CONFIG_MTD_SMART_FSCK=y
+CONFIG_MTD_SMART_SECTOR_SIZE=4096
+CONFIG_NAME_MAX=64
+CONFIG_NET=y
+CONFIG_NETDEVICES=y
+CONFIG_NETDEV_LATEINIT=y
+CONFIG_NET_SOCKOPTS=y
+CONFIG_NET_TCP_NO_STACK=y
+CONFIG_NET_UDP_NO_STACK=y
+CONFIG_NET_USRSOCK=y
+CONFIG_NET_USRSOCK_TCP=y
+CONFIG_NET_USRSOCK_UDP=y
+CONFIG_NFILE_STREAMS=8
+CONFIG_NSH_ARCHINIT=y
+CONFIG_NSH_BUILTIN_APPS=y
+CONFIG_NSH_DISABLE_LOSMART=y
+CONFIG_NSH_LINELEN=160
+CONFIG_NSH_MAXARGUMENTS=14
+CONFIG_NSH_READLINE=y
+CONFIG_PIPES=y
+CONFIG_PREALLOC_MQ_MSGS=4
+CONFIG_PREALLOC_TIMERS=4
+CONFIG_PREALLOC_WDOGS=16
+CONFIG_PWM=y
+CONFIG_RAM_SIZE=1572864
+CONFIG_RAM_START=0x0d000000
+CONFIG_READLINE_CMD_HISTORY=y
+CONFIG_READLINE_CMD_HISTORY_LINELEN=160
+CONFIG_READLINE_TABCOMPLETION=y
+CONFIG_RR_INTERVAL=200
+CONFIG_RTC=y
+CONFIG_RTC_ALARM=y
+CONFIG_RTC_DRIVER=y
+CONFIG_RTC_FREQUENCY=32768
+CONFIG_RTC_HIRES=y
+CONFIG_SCHED_CHILD_STATUS=y
+CONFIG_SCHED_HAVE_PARENT=y
+CONFIG_SCHED_HPWORK=y
+CONFIG_SCHED_LPNTHREADS=3
+CONFIG_SCHED_LPWORK=y
+CONFIG_SCHED_WAITPID=y
+CONFIG_SDCLONE_DISABLE=y
+CONFIG_SDIO_MUXBUS=y
+CONFIG_SDK_AUDIO=y
+CONFIG_SERIAL_TERMIOS=y
+CONFIG_SMARTFS_ALIGNED_ACCESS=y
+CONFIG_SMARTFS_MAXNAMLEN=30
+CONFIG_SMARTFS_MULTI_ROOT_DIRS=y
+CONFIG_SPECIFIC_DRIVERS=y
+CONFIG_SPI=y
+CONFIG_SPRESENSE_EXTENSION=y
+CONFIG_START_DAY=6
+CONFIG_START_MONTH=12
+CONFIG_START_YEAR=2011
+CONFIG_SYSTEMTICK_HOOK=y
+CONFIG_SYSTEM_CLE=y
+CONFIG_SYSTEM_NSH=y
+CONFIG_SYSTEM_NSH_CXXINITIALIZE=y
+CONFIG_UART1_RXBUFSIZE=1024
+CONFIG_UART1_SERIAL_CONSOLE=y
+CONFIG_UART1_TXBUFSIZE=1024
+CONFIG_UART2_IFLOWCONTROL=y
+CONFIG_UART2_OFLOWCONTROL=y
+CONFIG_USBDEV=y
+CONFIG_USBDEV_DMA=y
+CONFIG_USBDEV_DUALSPEED=y
+CONFIG_USEC_PER_TICK=1000
+CONFIG_USERMAIN_STACKSIZE=1064960
+CONFIG_USER_ENTRYPOINT="spresense_main"
+CONFIG_VIDEO_ISX012=y
+CONFIG_VIDEO_STREAM=y
diff --git a/ports/cxd56/mkspk/elf32.h b/ports/cxd56/mkspk/elf32.h
new file mode 100644
index 000000000..94a9c81ba
--- /dev/null
+++ b/ports/cxd56/mkspk/elf32.h
@@ -0,0 +1,175 @@
+/****************************************************************************
+ * include/elf32.h
+ *
+ * Copyright (C) 2012 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <gnutt@nuttx.org>
+ *
+ * Reference: System V Application Binary Interface, Edition 4.1, March 18,
+ * 1997, The Santa Cruz Operation, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+#ifndef __INCLUDE_ELF32_H
+#define __INCLUDE_ELF32_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <stdint.h>
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define EI_NIDENT 16 /* Size of e_ident[] */
+
+#define ELF32_ST_BIND(i) ((i) >> 4)
+#define ELF32_ST_TYPE(i) ((i) & 0xf)
+#define ELF32_ST_INFO(b,t) (((b) << 4) | ((t) & 0xf))
+
+/* Definitions for Elf32_Rel*::r_info */
+
+#define ELF32_R_SYM(i) ((i) >> 8)
+#define ELF32_R_TYPE(i) ((i) & 0xff)
+#define ELF32_R_INFO(s,t) (((s)<< 8) | ((t) & 0xff))
+
+#define ELF_R_SYM(i) ELF32_R_SYM(i)
+
+/****************************************************************************
+ * Public Type Definitions
+ ****************************************************************************/
+
+/* Figure 4.2: 32-Bit Data Types */
+
+typedef uint32_t Elf32_Addr; /* Unsigned program address */
+typedef uint16_t Elf32_Half; /* Unsigned medium integer */
+typedef uint32_t Elf32_Off; /* Unsigned file offset */
+typedef int32_t Elf32_Sword; /* Signed large integer */
+typedef uint32_t Elf32_Word; /* Unsigned large integer */
+
+/* Figure 4-3: ELF Header */
+
+typedef struct
+{
+ unsigned char e_ident[EI_NIDENT];
+ Elf32_Half e_type;
+ Elf32_Half e_machine;
+ Elf32_Word e_version;
+ Elf32_Addr e_entry;
+ Elf32_Off e_phoff;
+ Elf32_Off e_shoff;
+ Elf32_Word e_flags;
+ Elf32_Half e_ehsize;
+ Elf32_Half e_phentsize;
+ Elf32_Half e_phnum;
+ Elf32_Half e_shentsize;
+ Elf32_Half e_shnum;
+ Elf32_Half e_shstrndx;
+} Elf32_Ehdr;
+
+/* Figure 4-8: Section Header */
+
+typedef struct
+{
+ Elf32_Word sh_name;
+ Elf32_Word sh_type;
+ Elf32_Word sh_flags;
+ Elf32_Addr sh_addr;
+ Elf32_Off sh_offset;
+ Elf32_Word sh_size;
+ Elf32_Word sh_link;
+ Elf32_Word sh_info;
+ Elf32_Word sh_addralign;
+ Elf32_Word sh_entsize;
+} Elf32_Shdr;
+
+/* Figure 4-15: Symbol Table Entry */
+
+typedef struct
+{
+ Elf32_Word st_name;
+ Elf32_Addr st_value;
+ Elf32_Word st_size;
+ unsigned char st_info;
+ unsigned char st_other;
+ Elf32_Half st_shndx;
+} Elf32_Sym;
+
+/* Figure 4-19: Relocation Entries */
+
+typedef struct
+{
+ Elf32_Addr r_offset;
+ Elf32_Word r_info;
+} Elf32_Rel;
+
+typedef struct
+{
+ Elf32_Addr r_offset;
+ Elf32_Word r_info;
+ Elf32_Sword r_addend;
+} Elf32_Rela;
+
+/* Figure 5-1: Program Header */
+
+typedef struct
+{
+ Elf32_Word p_type;
+ Elf32_Off p_offset;
+ Elf32_Addr p_vaddr;
+ Elf32_Addr p_paddr;
+ Elf32_Word p_filesz;
+ Elf32_Word p_memsz;
+ Elf32_Word p_flags;
+ Elf32_Word p_align;
+} Elf32_Phdr;
+
+/* Figure 5-9: Dynamic Structure */
+
+typedef struct
+{
+ Elf32_Sword d_tag;
+ union
+ {
+ Elf32_Word d_val;
+ Elf32_Addr d_ptr;
+ } d_un;
+} Elf32_Dyn;
+
+typedef Elf32_Addr Elf_Addr;
+typedef Elf32_Ehdr Elf_Ehdr;
+typedef Elf32_Rel Elf_Rel;
+typedef Elf32_Rela Elf_Rela;
+typedef Elf32_Sym Elf_Sym;
+typedef Elf32_Shdr Elf_Shdr;
+typedef Elf32_Word Elf_Word;
+
+#endif /* __INCLUDE_ELF32_H */
diff --git a/ports/cxd56/mkspk/mkspk.h b/ports/cxd56/mkspk/mkspk.h
index 5a67bb3dd..5c1b979c0 100644
--- a/ports/cxd56/mkspk/mkspk.h
+++ b/ports/cxd56/mkspk/mkspk.h
@@ -36,12 +36,22 @@
****************************************************************************/
#include "clefia.h"
-#include "elf.h"
+#include "elf32.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
+#define EI_MAG0 0 /* File identification */
+#define EI_MAG1 1
+#define EI_MAG2 2
+#define EI_MAG3 3
+
+#define SHT_SYMTAB 2
+#define SHT_STRTAB 3
+
+#define PT_LOAD 1
+
#define alignup(x, a) (((x) + ((a) - 1)) & ~((a) - 1))
#define swap(a, b) { (a) ^= (b); (b) ^= (a); (a) ^= (b); }
diff --git a/ports/cxd56/mpconfigport.mk b/ports/cxd56/mpconfigport.mk
index 23f60f8a7..eb077c07b 100644
--- a/ports/cxd56/mpconfigport.mk
+++ b/ports/cxd56/mpconfigport.mk
@@ -7,6 +7,8 @@ USB_CDC_EP_NUM_DATA_IN = 1
USB_MSC_EP_NUM_OUT = 5
USB_MSC_EP_NUM_IN = 4
+MPY_TOOL_LONGINT_IMPL = -mlongint-impl=mpz
+
CIRCUITPY_AUDIOBUSIO = 0
CIRCUITPY_AUDIOIO = 0
CIRCUITPY_COUNTIO = 0
@@ -18,6 +20,7 @@ CIRCUITPY_I2CPERIPHERAL = 0
CIRCUITPY_NEOPIXEL_WRITE = 0
CIRCUITPY_NVM = 0
CIRCUITPY_ROTARYIO = 0
+CIRCUITPY_SDIOIO = 1
CIRCUITPY_TOUCHIO = 0
CIRCUITPY_USB_HID = 0
CIRCUITPY_USB_MIDI = 0
diff --git a/ports/cxd56/spresense-exported-sdk b/ports/cxd56/spresense-exported-sdk
-Subproject 7f6568c7f4898cdb24a2f06040784a836050686
+Subproject c991d439fac9c23cfcac0da16fe8055f818d40a
diff --git a/ports/cxd56/tools/flash_writer.py b/ports/cxd56/tools/flash_writer.py
new file mode 100755
index 000000000..840f10c32
--- /dev/null
+++ b/ports/cxd56/tools/flash_writer.py
@@ -0,0 +1,580 @@
+#! /usr/bin/env python3
+
+# Copyright (C) 2018 Sony Semiconductor Solutions Corp.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in
+# the documentation and/or other materials provided with the
+# distribution.
+# 3. Neither the name NuttX nor the names of its contributors may be
+# used to endorse or promote products derived from this software
+# without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+
+import time
+import sys
+import os
+import struct
+import glob
+import fnmatch
+import errno
+import telnetlib
+import argparse
+import shutil
+import subprocess
+import re
+import xmodem
+
+import_serial_module = True
+
+# When SDK release, plase set SDK_RELEASE as True.
+SDK_RELEASE = False
+
+if SDK_RELEASE :
+ PRINT_RAW_COMMAND = False
+ REBOOT_AT_END = True
+else :
+ PRINT_RAW_COMMAND = True
+ REBOOT_AT_END = True
+
+try:
+ import serial
+except:
+ import_serial_module = False
+
+# supported environment various
+# CXD56_PORT
+# CXD56_TELNETSRV_PORT
+# CXD56_TELNETSRV_IP
+
+PROTOCOL_SERIAL = 0
+PROTOCOL_TELNET = 1
+
+MAX_DOT_COUNT = 70
+
+# configure parameters and default value
+class ConfigArgs:
+ PROTOCOL_TYPE = None
+ SERIAL_PORT = "COM1"
+ SERVER_PORT = 4569
+ SERVER_IP = "localhost"
+ EOL = bytes([10])
+ WAIT_RESET = True
+ AUTO_RESET = False
+ DTR_RESET = False
+ XMODEM_BAUD = 0
+ NO_SET_BOOTABLE = False
+ PACKAGE_NAME = []
+ FILE_NAME = []
+ ERASE_NAME = []
+ PKGSYS_NAME = []
+ PKGAPP_NAME = []
+ PKGUPD_NAME = []
+
+ROM_MSG = [b"Welcome to nash"]
+XMDM_MSG = "Waiting for XMODEM (CRC or 1K) transfer. Ctrl-X to cancel."
+
+class ConfigArgsLoader():
+ def __init__(self):
+ self.parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter)
+ self.parser.add_argument("package_name", help="the name of the package to install", nargs='*')
+ self.parser.add_argument("-f", "--file", dest="file_name", help="save file", action='append')
+ self.parser.add_argument("-e", "--erase", dest="erase_name", help="erase file", action='append')
+
+ self.parser.add_argument("-S", "--sys", dest="pkgsys_name", help="the name of the system package to install", action='append')
+ self.parser.add_argument("-A", "--app", dest="pkgapp_name", help="the name of the application package to install", action='append')
+ self.parser.add_argument("-U", "--upd", dest="pkgupd_name", help="the name of the updater package to install", action='append')
+
+ self.parser.add_argument("-a", "--auto-reset", dest="auto_reset",
+ action="store_true", default=None,
+ help="try to auto reset develop board if possible")
+ self.parser.add_argument("-d", "--dtr-reset", dest="dtr_reset",
+ action="store_true", default=None,
+ help="try to auto reset develop board if possible")
+ self.parser.add_argument("-n", "--no-set-bootable", dest="no_set_bootable",
+ action="store_true", default=None,
+ help="not to set bootable")
+
+ group = self.parser.add_argument_group()
+ group.add_argument("-i", "--server-ip", dest="server_ip",
+ help="the ip address connected to the telnet server")
+ group.add_argument("-p", "--server-port", dest="server_port", type=int,
+ help="the port connected to the telnet server")
+
+ group = self.parser.add_argument_group()
+ group.add_argument("-c", "--serial-port", dest="serial_port", help="the serial port")
+ group.add_argument("-b", "--xmodem-baudrate", dest="xmodem_baud", help="Use the faster baudrate in xmodem")
+
+ mutually_group = self.parser.add_mutually_exclusive_group()
+ mutually_group.add_argument("-t", "--telnet-protocol", dest="telnet_protocol",
+ action="store_true", default=None,
+ help="use the telnet protocol for binary transmission")
+ mutually_group.add_argument("-s", "--serial-protocol", dest="serial_protocol",
+ action="store_true", default=None,
+ help="use the serial port for binary transmission, default options")
+
+ mutually_group2 = self.parser.add_mutually_exclusive_group()
+ mutually_group2.add_argument("-F", "--force-wait-reset", dest="wait_reset",
+ action="store_true", default=None,
+ help="force wait for pressing RESET button")
+ mutually_group2.add_argument("-N", "--no-wait-reset", dest="wait_reset",
+ action="store_false", default=None,
+ help="if possible, skip to wait for pressing RESET button")
+
+ def update_config(self):
+ args = self.parser.parse_args()
+
+ ConfigArgs.PACKAGE_NAME = args.package_name
+ ConfigArgs.FILE_NAME = args.file_name
+ ConfigArgs.ERASE_NAME = args.erase_name
+ ConfigArgs.PKGSYS_NAME = args.pkgsys_name
+ ConfigArgs.PKGAPP_NAME = args.pkgapp_name
+ ConfigArgs.PKGUPD_NAME = args.pkgupd_name
+
+ # Get serial port or telnet server ip etc
+ if args.serial_protocol == True:
+ ConfigArgs.PROTOCOL_TYPE = PROTOCOL_SERIAL
+ elif args.telnet_protocol == True:
+ ConfigArgs.PROTOCOL_TYPE = PROTOCOL_TELNET
+
+ if ConfigArgs.PROTOCOL_TYPE == None:
+ proto = os.environ.get("CXD56_PROTOCOL")
+ if proto is not None:
+ if 's' in proto:
+ ConfigArgs.PROTOCOL_TYPE = PROTOCOL_SERIAL
+ elif 't' in proto:
+ ConfigArgs.PROTOCOL_TYPE = PROTOCOL_TELNET
+
+ if ConfigArgs.PROTOCOL_TYPE == None:
+ ConfigArgs.PROTOCOL_TYPE = PROTOCOL_SERIAL
+
+ if ConfigArgs.PROTOCOL_TYPE == PROTOCOL_SERIAL:
+ if args.serial_port is not None:
+ ConfigArgs.SERIAL_PORT = args.serial_port
+ else:
+ # Get serial port from the environment
+ port = os.environ.get("CXD56_PORT")
+ if port is not None:
+ ConfigArgs.SERIAL_PORT = port
+ else:
+ print("CXD56_PORT is not set, Use " + ConfigArgs.SERIAL_PORT + ".")
+ else:
+ ConfigArgs.PROTOCOL_TYPE = PROTOCOL_TELNET
+ if args.server_port is not None:
+ ConfigArgs.SERVER_PORT = args.server_port
+ else:
+ port = os.environ.get("CXD56_TELNETSRV_PORT")
+ if port is not None:
+ ConfigArgs.SERVER_PORT = port
+ else:
+ print("CXD56_TELNETSRV_PORT is not set, Use " + str(ConfigArgs.SERVER_PORT) + ".")
+ if args.server_ip is not None:
+ ConfigArgs.SERVER_IP = args.server_ip
+ else:
+ ip = os.environ.get("CXD56_TELNETSRV_IP")
+ if ip is not None:
+ ConfigArgs.SERVER_IP = ip
+ else:
+ print("CXD56_TELNETSRV_IP is not set, Use " + ConfigArgs.SERVER_IP + ".")
+
+ if args.xmodem_baud is not None:
+ ConfigArgs.XMODEM_BAUD = args.xmodem_baud
+
+ if args.auto_reset is not None:
+ ConfigArgs.AUTO_RESET = args.auto_reset
+
+ if args.dtr_reset is not None:
+ ConfigArgs.DTR_RESET = args.dtr_reset
+
+ if args.no_set_bootable is not None:
+ ConfigArgs.NO_SET_BOOTABLE = args.no_set_bootable
+
+ if args.wait_reset is not None:
+ ConfigArgs.WAIT_RESET = args.wait_reset
+
+class TelnetDev:
+ def __init__(self):
+ srv_ipaddr = ConfigArgs.SERVER_IP
+ srv_port = ConfigArgs.SERVER_PORT
+ self.recvbuf = b'';
+ try:
+ self.telnet = telnetlib.Telnet(host=srv_ipaddr, port=srv_port, timeout=10)
+ # There is a ack to be sent after connecting to the telnet server.
+ self.telnet.write(b"\xff")
+ except Exception as e:
+ print("Cannot connect to the server %s:%d" % (srv_ipaddr, srv_port))
+ sys.exit(e.args[0])
+
+ def readline(self, size=None):
+ res = b''
+ ch = b''
+ while ch != ConfigArgs.EOL:
+ ch = self.getc_raw(1, timeout=0.1)
+ if ch == b'':
+ return res
+ res += ch
+ return res
+
+ def getc_raw(self, size, timeout=1):
+ res = b''
+ tm = time.monotonic()
+ while size > 0:
+ while self.recvbuf == b'':
+ self.recvbuf = self.telnet.read_eager()
+ if self.recvbuf == b'':
+ if (time.monotonic() - tm) > timeout:
+ return res
+ time.sleep(0.1)
+ res += self.recvbuf[0:1]
+ self.recvbuf = self.recvbuf[1:]
+ size -= 1
+ return res
+
+ def write(self, buffer):
+ self.telnet.write(buffer)
+
+ def discard_inputs(self, timeout=1.0):
+ while True:
+ ch = self.getc_raw(1, timeout=timeout)
+ if ch == b'':
+ break
+
+ def getc(self, size, timeout=1):
+ c = self.getc_raw(size, timeout)
+ return c
+
+ def putc(self, buffer, timeout=1):
+ self.telnet.write(buffer)
+ self.show_progress(len(buffer))
+
+ def reboot(self):
+ # no-op
+ pass
+
+ def set_file_size(self, filesize):
+ self.bytes_transfered = 0
+ self.filesize = filesize
+ self.count = 0
+
+ def show_progress(self, sendsize):
+ if PRINT_RAW_COMMAND:
+ if self.count < MAX_DOT_COUNT:
+ self.bytes_transfered = self.bytes_transfered + sendsize
+ cur_count = int(self.bytes_transfered * MAX_DOT_COUNT / self.filesize)
+ if MAX_DOT_COUNT < cur_count:
+ cur_count = MAX_DOT_COUNT
+ for idx in range(cur_count - self.count):
+ print('#',end='')
+ sys.stdout.flush()
+ self.count = cur_count
+ if self.count == MAX_DOT_COUNT:
+ print("\n")
+
+class SerialDev:
+ def __init__(self):
+ if import_serial_module is False:
+ print("Cannot import serial module, maybe it's not install yet.")
+ print("\n", end="")
+ print("Please install python-setuptool by Cygwin installer.")
+ print("After that use easy_intall command to install serial module")
+ print(" $ cd tool/")
+ print(" $ python3 -m easy_install pyserial-2.7.tar.gz")
+ quit()
+ else:
+ port = ConfigArgs.SERIAL_PORT
+ try:
+ self.serial = serial.Serial(port, baudrate=115200,
+ parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE,
+ bytesize=serial.EIGHTBITS, timeout=0.1)
+ except Exception as e:
+ print("Cannot open port : " + port)
+ sys.exit(e.args[0])
+
+ def readline(self, size=None):
+ return self.serial.readline(size)
+
+ def write(self, buffer):
+ self.serial.write(buffer)
+ self.serial.flush()
+
+ def discard_inputs(self, timeout=1.0):
+ time.sleep(timeout)
+ self.serial.flushInput()
+
+ def getc(self, size, timeout=1):
+ self.serial.timeout = timeout
+ c = self.serial.read(size)
+ self.serial.timeout = 0.1
+ return c
+
+ def putc(self, buffer, timeout=1):
+ self.serial.timeout = timeout
+ self.serial.write(buffer)
+ self.serial.flush()
+ self.serial.timeout = 0.1
+ self.show_progress(len(buffer))
+
+ # Note: windows platform dependent code
+ def putc_win(self, buffer, timeout=1):
+ self.serial.write(buffer)
+ self.show_progress(len(buffer))
+ while True:
+ if self.serial.out_waiting == 0:
+ break
+
+ def setBaudrate(self, baudrate):
+# self.serial.setBaudrate(baudrate)
+ self.serial.baudrate = baudrate
+
+ def reboot(self):
+ # Target Reset by DTR
+ self.serial.setDTR(False)
+ self.serial.setDTR(True)
+ self.serial.setDTR(False)
+
+ def set_file_size(self, filesize):
+ self.bytes_transfered = 0
+ self.filesize = filesize
+ self.count = 0
+
+ def show_progress(self, sendsize):
+ if PRINT_RAW_COMMAND:
+ if self.count < MAX_DOT_COUNT:
+ self.bytes_transfered = self.bytes_transfered + sendsize
+ cur_count = int(self.bytes_transfered * MAX_DOT_COUNT / self.filesize)
+ if MAX_DOT_COUNT < cur_count:
+ cur_count = MAX_DOT_COUNT
+ for idx in range(cur_count - self.count):
+ print('#',end='')
+ sys.stdout.flush()
+ self.count = cur_count
+ if self.count == MAX_DOT_COUNT:
+ print("\n")
+
+class FlashWriter:
+ def __init__(self, protocol_sel=PROTOCOL_SERIAL):
+ if protocol_sel == PROTOCOL_TELNET:
+ self.serial = TelnetDev()
+ else:
+ self.serial = SerialDev()
+
+ def cancel_autoboot(self) :
+ boot_msg = ''
+ self.serial.reboot() # Target reboot before send 'r'
+ while boot_msg == '' :
+ rx = self.serial.readline().strip()
+ self.serial.write(b"r") # Send "r" key to avoid auto boot
+ for msg in ROM_MSG :
+ if msg in rx :
+ boot_msg = msg
+ break
+ while True :
+ rx = self.serial.readline().decode(errors="replace").strip()
+ if "updater" in rx :
+ # Workaround : Sometime first character is dropped.
+ # Send line feed as air shot before actual command.
+ self.serial.write(b"\n") # Send line feed
+ self.serial.discard_inputs()# Clear input buffer to sync
+ return boot_msg.decode(errors="ignore")
+
+ def recv(self):
+ rx = self.serial.readline()
+ if PRINT_RAW_COMMAND :
+ serial_line = rx.decode(errors="replace")
+ if serial_line.strip() != "" and not serial_line.startswith(XMDM_MSG):
+ print(serial_line, end="")
+ return rx
+
+ def wait(self, string):
+ while True:
+ rx = self.recv()
+ if string.encode() in rx:
+ time.sleep(0.1)
+ break
+
+ def wait_for_prompt(self):
+ prompt_pat = re.compile(b"updater")
+ while True:
+ rx = self.recv()
+ if prompt_pat.search(rx):
+ time.sleep(0.1)
+ break
+
+ def send(self, string):
+ self.serial.write(str(string).encode() + b"\n")
+ rx = self.serial.readline()
+ if PRINT_RAW_COMMAND :
+ print(rx.decode(errors="replace"), end="")
+
+ def read_output(self, prompt_text) :
+ output = []
+ while True :
+ rx = self.serial.readline()
+ if prompt_text.encode() in rx :
+ time.sleep(0.1)
+ break
+ if rx != "" :
+ output.append(rx.decode(errors="ignore").rstrip())
+ return output
+
+ def install_files(self, files, command) :
+ if ConfigArgs.XMODEM_BAUD:
+ command += " -b " + ConfigArgs.XMODEM_BAUD
+ if os.name == 'nt':
+ modem = xmodem.XMODEM(self.serial.getc, self.serial.putc_win, 'xmodem1k')
+ else:
+ modem = xmodem.XMODEM(self.serial.getc, self.serial.putc, 'xmodem1k')
+ for file in files:
+ with open(file, "rb") as bin :
+ self.send(command)
+ print("Install " + file)
+ self.wait(XMDM_MSG)
+ print("|0%" +
+ "-" * (int(MAX_DOT_COUNT / 2) - 6) +
+ "50%" +
+ "-" * (MAX_DOT_COUNT - int(MAX_DOT_COUNT / 2) - 5) +
+ "100%|")
+ if ConfigArgs.XMODEM_BAUD:
+ self.serial.setBaudrate(ConfigArgs.XMODEM_BAUD)
+ self.serial.discard_inputs() # Clear input buffer to sync
+ self.serial.set_file_size(os.path.getsize(file))
+ modem.send(bin)
+ if ConfigArgs.XMODEM_BAUD:
+ self.serial.setBaudrate(115200)
+ self.wait_for_prompt()
+
+ def save_files(self, files) :
+ if ConfigArgs.XMODEM_BAUD:
+ command = "save_file -b " + ConfigArgs.XMODEM_BAUD + " -x "
+ else:
+ command = "save_file -x "
+ if os.name == 'nt':
+ modem = xmodem.XMODEM(self.serial.getc, self.serial.putc_win, 'xmodem1k')
+ else:
+ modem = xmodem.XMODEM(self.serial.getc, self.serial.putc, 'xmodem1k')
+ for file in files:
+ with open(file, "rb") as bin :
+ self.send(command + os.path.basename(file))
+ print("Save " + file)
+ self.wait(XMDM_MSG)
+ if ConfigArgs.XMODEM_BAUD:
+ self.serial.setBaudrate(ConfigArgs.XMODEM_BAUD)
+ self.serial.discard_inputs() # Clear input buffer to sync
+ self.serial.set_file_size(os.path.getsize(file))
+ modem.send(bin)
+ if ConfigArgs.XMODEM_BAUD:
+ self.serial.setBaudrate(115200)
+ self.wait_for_prompt()
+ self.send("chmod d+rw " + os.path.basename(file))
+ self.wait_for_prompt()
+
+ def delete_files(self, files) :
+ for file in files :
+ self.delete_binary(file)
+
+ def delete_binary(self, bin_name) :
+ self.send("rm " + bin_name)
+ self.wait_for_prompt()
+
+def main():
+ try:
+ config_loader = ConfigArgsLoader()
+ config_loader.update_config()
+ except:
+ return errno.EINVAL
+
+ # Wait to reset the board
+ writer = FlashWriter(ConfigArgs.PROTOCOL_TYPE)
+
+ do_wait_reset = True
+ if ConfigArgs.AUTO_RESET:
+ if subprocess.call("cd " + sys.path[0] + "; ./reset_board.sh", shell=True) == 0:
+ print("auto reset board sucess!!")
+ do_wait_reset = False
+ bootrom_msg = writer.cancel_autoboot()
+
+ if ConfigArgs.DTR_RESET:
+ do_wait_reset = False
+ bootrom_msg = writer.cancel_autoboot()
+
+ if ConfigArgs.WAIT_RESET == False and do_wait_reset == True:
+ rx = writer.recv()
+ time.sleep(1)
+ for i in range(3):
+ writer.send("")
+ rx = writer.recv()
+ if "updater".encode() in rx:
+ # No need to wait for reset
+ do_wait_reset = False
+ break
+ time.sleep(1)
+
+ if do_wait_reset:
+ # Wait to reset the board
+ print('Please press RESET button on target board')
+ sys.stdout.flush()
+ bootrom_msg = writer.cancel_autoboot()
+
+ # Remove files
+ if ConfigArgs.ERASE_NAME :
+ print(">>> Remove exisiting files ...")
+ writer.delete_files(ConfigArgs.ERASE_NAME)
+
+ # Install files
+ if ConfigArgs.PACKAGE_NAME or ConfigArgs.PKGSYS_NAME or ConfigArgs.PKGAPP_NAME or ConfigArgs.PKGUPD_NAME:
+ print(">>> Install files ...")
+ if ConfigArgs.PACKAGE_NAME :
+ writer.install_files(ConfigArgs.PACKAGE_NAME, "install")
+ if ConfigArgs.PKGSYS_NAME :
+ writer.install_files(ConfigArgs.PKGSYS_NAME, "install")
+ if ConfigArgs.PKGAPP_NAME :
+ writer.install_files(ConfigArgs.PKGAPP_NAME, "install")
+ if ConfigArgs.PKGUPD_NAME :
+ writer.install_files(ConfigArgs.PKGUPD_NAME, "install -k updater.key")
+
+ # Save files
+ if ConfigArgs.FILE_NAME :
+ print(">>> Save files ...")
+ writer.save_files(ConfigArgs.FILE_NAME)
+
+ # Set auto boot
+ if not ConfigArgs.NO_SET_BOOTABLE:
+ print(">>> Save Configuration to FlashROM ...")
+ writer.send("set bootable M0P")
+ writer.wait_for_prompt()
+
+ # Sync all cached data to flash
+ writer.send("sync")
+ writer.wait_for_prompt()
+
+ if REBOOT_AT_END :
+ print("Restarting the board ...")
+ writer.send("reboot")
+
+ return 0
+
+if __name__ == "__main__":
+ try:
+ sys.exit(main())
+ except KeyboardInterrupt:
+ print("Canceled by keyboard interrupt.")
+ pass
diff --git a/ports/cxd56/tools/xmodem.py b/ports/cxd56/tools/xmodem.py
new file mode 100644
index 000000000..c93430056
--- /dev/null
+++ b/ports/cxd56/tools/xmodem.py
@@ -0,0 +1,590 @@
+'''
+===============================
+ XMODEM file transfer protocol
+===============================
+
+.. $Id$
+
+This is a literal implementation of XMODEM.TXT_, XMODEM1K.TXT_ and
+XMODMCRC.TXT_, support for YMODEM and ZMODEM is pending. YMODEM should
+be fairly easy to implement as it is a hack on top of the XMODEM
+protocol using sequence bytes ``0x00`` for sending file names (and some
+meta data).
+
+.. _XMODEM.TXT: doc/XMODEM.TXT
+.. _XMODEM1K.TXT: doc/XMODEM1K.TXT
+.. _XMODMCRC.TXT: doc/XMODMCRC.TXT
+
+Data flow example including error recovery
+==========================================
+
+Here is a sample of the data flow, sending a 3-block message.
+It includes the two most common line hits - a garbaged block,
+and an ``ACK`` reply getting garbaged. ``CRC`` or ``CSUM`` represents
+the checksum bytes.
+
+XMODEM 128 byte blocks
+----------------------
+
+::
+
+ SENDER RECEIVER
+
+ <-- NAK
+ SOH 01 FE Data[128] CSUM -->
+ <-- ACK
+ SOH 02 FD Data[128] CSUM -->
+ <-- ACK
+ SOH 03 FC Data[128] CSUM -->
+ <-- ACK
+ SOH 04 FB Data[128] CSUM -->
+ <-- ACK
+ SOH 05 FA Data[100] CPMEOF[28] CSUM -->
+ <-- ACK
+ EOT -->
+ <-- ACK
+
+XMODEM-1k blocks, CRC mode
+--------------------------
+
+::
+
+ SENDER RECEIVER
+
+ <-- C
+ STX 01 FE Data[1024] CRC CRC -->
+ <-- ACK
+ STX 02 FD Data[1024] CRC CRC -->
+ <-- ACK
+ STX 03 FC Data[1000] CPMEOF[24] CRC CRC -->
+ <-- ACK
+ EOT -->
+ <-- ACK
+
+Mixed 1024 and 128 byte Blocks
+------------------------------
+
+::
+
+ SENDER RECEIVER
+
+ <-- C
+ STX 01 FE Data[1024] CRC CRC -->
+ <-- ACK
+ STX 02 FD Data[1024] CRC CRC -->
+ <-- ACK
+ SOH 03 FC Data[128] CRC CRC -->
+ <-- ACK
+ SOH 04 FB Data[100] CPMEOF[28] CRC CRC -->
+ <-- ACK
+ EOT -->
+ <-- ACK
+
+YMODEM Batch Transmission Session (1 file)
+------------------------------------------
+
+::
+
+ SENDER RECEIVER
+ <-- C (command:rb)
+ SOH 00 FF foo.c NUL[123] CRC CRC -->
+ <-- ACK
+ <-- C
+ SOH 01 FE Data[128] CRC CRC -->
+ <-- ACK
+ SOH 02 FC Data[128] CRC CRC -->
+ <-- ACK
+ SOH 03 FB Data[100] CPMEOF[28] CRC CRC -->
+ <-- ACK
+ EOT -->
+ <-- NAK
+ EOT -->
+ <-- ACK
+ <-- C
+ SOH 00 FF NUL[128] CRC CRC -->
+ <-- ACK
+
+
+'''
+
+__author__ = 'Wijnand Modderman <maze@pyth0n.org>'
+__copyright__ = ['Copyright (c) 2010 Wijnand Modderman',
+ 'Copyright (c) 1981 Chuck Forsberg']
+__license__ = 'MIT'
+__version__ = '0.3.2'
+
+import logging
+import time
+import sys
+from functools import partial
+import collections
+
+# Loggerr
+log = logging.getLogger('xmodem')
+
+# Protocol bytes
+SOH = bytes([0x01])
+STX = bytes([0x02])
+EOT = bytes([0x04])
+ACK = bytes([0x06])
+DLE = bytes([0x10])
+NAK = bytes([0x15])
+CAN = bytes([0x18])
+CRC = bytes([0x43]) # C
+
+
+class XMODEM(object):
+ '''
+ XMODEM Protocol handler, expects an object to read from and an object to
+ write to.
+
+ >>> def getc(size, timeout=1):
+ ... return data or None
+ ...
+ >>> def putc(data, timeout=1):
+ ... return size or None
+ ...
+ >>> modem = XMODEM(getc, putc)
+
+
+ :param getc: Function to retreive bytes from a stream
+ :type getc: callable
+ :param putc: Function to transmit bytes to a stream
+ :type putc: callable
+ :param mode: XMODEM protocol mode
+ :type mode: string
+ :param pad: Padding character to make the packets match the packet size
+ :type pad: char
+
+ '''
+
+ # crctab calculated by Mark G. Mendel, Network Systems Corporation
+ crctable = [
+ 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7,
+ 0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef,
+ 0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6,
+ 0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de,
+ 0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485,
+ 0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d,
+ 0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4,
+ 0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc,
+ 0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823,
+ 0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b,
+ 0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12,
+ 0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a,
+ 0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41,
+ 0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49,
+ 0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70,
+ 0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78,
+ 0x9188, 0x81a9, 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f,
+ 0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067,
+ 0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e,
+ 0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214, 0x6277, 0x7256,
+ 0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d,
+ 0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405,
+ 0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d, 0xd73c,
+ 0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634,
+ 0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab,
+ 0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3,
+ 0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a,
+ 0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, 0x2ab3, 0x3a92,
+ 0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9,
+ 0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1,
+ 0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8,
+ 0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0,
+ ]
+
+ def __init__(self, getc, putc, mode='xmodem', pad=b'\x1a'):
+ self.getc = getc
+ self.putc = putc
+ self.mode = mode
+ self.pad = pad
+
+ def abort(self, count=2, timeout=60):
+ '''
+ Send an abort sequence using CAN bytes.
+ '''
+ for counter in range(0, count):
+ self.putc(CAN, timeout)
+
+ def send(self, stream, retry=32, timeout=360, quiet=0, callback=None):
+ '''
+ Send a stream via the XMODEM protocol.
+
+ >>> stream = file('/etc/issue', 'rb')
+ >>> print modem.send(stream)
+ True
+
+ Returns ``True`` upon succesful transmission or ``False`` in case of
+ failure.
+
+ :param stream: The stream object to send data from.
+ :type stream: stream (file, etc.)
+ :param retry: The maximum number of times to try to resend a failed
+ packet before failing.
+ :type retry: int
+ :param timeout: The number of seconds to wait for a response before
+ timing out.
+ :type timeout: int
+ :param quiet: If 0, it prints info to stderr. If 1, it does not print any info.
+ :type quiet: int
+ :param callback: Reference to a callback function that has the
+ following signature. This is useful for
+ getting status updates while a xmodem
+ transfer is underway.
+ Expected callback signature:
+ def callback(total_packets, success_count, error_count)
+ :type callback: callable
+ '''
+
+ # initialize protocol
+ try:
+ packet_size = dict(
+ xmodem = 128,
+ xmodem1k = 1024,
+ )[self.mode]
+ except AttributeError:
+ raise ValueError("An invalid mode was supplied")
+
+ error_count = 0
+ crc_mode = 0
+ cancel = 0
+ while True:
+ char = self.getc(1)
+ if char:
+ if char == NAK:
+ crc_mode = 0
+ break
+ elif char == CRC:
+ crc_mode = 1
+ break
+ elif char == CAN:
+ if not quiet:
+ print('received CAN', file=sys.stderr)
+ if cancel:
+ return False
+ else:
+ cancel = 1
+ else:
+ log.error('send ERROR expected NAK/CRC, got %s' % \
+ (ord(char),))
+
+ error_count += 1
+ if error_count >= retry:
+ self.abort(timeout=timeout)
+ return False
+
+ # send data
+ error_count = 0
+ success_count = 0
+ total_packets = 0
+ sequence = 1
+ while True:
+ data = stream.read(packet_size)
+ if not data:
+ log.info('sending EOT')
+ # end of stream
+ break
+ total_packets += 1
+ data = data.ljust(packet_size, self.pad)
+ if crc_mode:
+ crc = self.calc_crc(data)
+ else:
+ crc = self.calc_checksum(data)
+
+ # emit packet
+ while True:
+ if packet_size == 128:
+ self.putc(SOH)
+ else: # packet_size == 1024
+ self.putc(STX)
+ self.putc(bytes([sequence]))
+ self.putc(bytes([0xff - sequence]))
+ self.putc(data)
+ if crc_mode:
+ self.putc(bytes([crc >> 8]))
+ self.putc(bytes([crc & 0xff]))
+ else:
+ self.putc(bytes([crc]))
+
+ char = self.getc(1, timeout)
+ if char == ACK:
+ success_count += 1
+ if isinstance(callback, collections.Callable):
+ callback(total_packets, success_count, error_count)
+ break
+ if char == NAK:
+ error_count += 1
+ if isinstance(callback, collections.Callable):
+ callback(total_packets, success_count, error_count)
+ if error_count >= retry:
+ # excessive amounts of retransmissions requested,
+ # abort transfer
+ self.abort(timeout=timeout)
+ log.warning('excessive NAKs, transfer aborted')
+ return False
+
+ # return to loop and resend
+ continue
+ else:
+ log.error('Not ACK, Not NAK')
+ error_count += 1
+ if isinstance(callback, collections.Callable):
+ callback(total_packets, success_count, error_count)
+ if error_count >= retry:
+ # excessive amounts of retransmissions requested,
+ # abort transfer
+ self.abort(timeout=timeout)
+ log.warning('excessive protocol errors, transfer aborted')
+ return False
+
+ # return to loop and resend
+ continue
+
+ # protocol error
+ self.abort(timeout=timeout)
+ log.error('protocol error')
+ return False
+
+ # keep track of sequence
+ sequence = (sequence + 1) % 0x100
+
+ while True:
+ # end of transmission
+ self.putc(EOT)
+
+ #An ACK should be returned
+ char = self.getc(1, timeout)
+ if char == ACK:
+ break
+ else:
+ error_count += 1
+ if error_count >= retry:
+ self.abort(timeout=timeout)
+ log.warning('EOT was not ACKd, transfer aborted')
+ return False
+
+ return True
+
+ def recv(self, stream, crc_mode=1, retry=16, timeout=60, delay=1, quiet=0):
+ '''
+ Receive a stream via the XMODEM protocol.
+
+ >>> stream = file('/etc/issue', 'wb')
+ >>> print modem.recv(stream)
+ 2342
+
+ Returns the number of bytes received on success or ``None`` in case of
+ failure.
+ '''
+
+ # initiate protocol
+ error_count = 0
+ char = 0
+ cancel = 0
+ while True:
+ # first try CRC mode, if this fails,
+ # fall back to checksum mode
+ if error_count >= retry:
+ self.abort(timeout=timeout)
+ return None
+ elif crc_mode and error_count < (retry / 2):
+ if not self.putc(CRC):
+ time.sleep(delay)
+ error_count += 1
+ else:
+ crc_mode = 0
+ if not self.putc(NAK):
+ time.sleep(delay)
+ error_count += 1
+
+ char = self.getc(1, timeout)
+ if not char:
+ error_count += 1
+ continue
+ elif char == SOH:
+ #crc_mode = 0
+ break
+ elif char == STX:
+ break
+ elif char == CAN:
+ if cancel:
+ return None
+ else:
+ cancel = 1
+ else:
+ error_count += 1
+
+ # read data
+ error_count = 0
+ income_size = 0
+ packet_size = 128
+ sequence = 1
+ cancel = 0
+ while True:
+ while True:
+ if char == SOH:
+ packet_size = 128
+ break
+ elif char == STX:
+ packet_size = 1024
+ break
+ elif char == EOT:
+ # We received an EOT, so send an ACK and return the received
+ # data length
+ self.putc(ACK)
+ return income_size
+ elif char == CAN:
+ # cancel at two consecutive cancels
+ if cancel:
+ return None
+ else:
+ cancel = 1
+ else:
+ if not quiet:
+ print('recv ERROR expected SOH/EOT, got', ord(char), file=sys.stderr)
+ error_count += 1
+ if error_count >= retry:
+ self.abort()
+ return None
+ # read sequence
+ error_count = 0
+ cancel = 0
+ seq1 = ord(self.getc(1))
+ seq2 = 0xff - ord(self.getc(1))
+ if seq1 == sequence and seq2 == sequence:
+ # sequence is ok, read packet
+ # packet_size + checksum
+ data = self.getc(packet_size + 1 + crc_mode, timeout)
+ if crc_mode:
+ csum = (ord(data[-2]) << 8) + ord(data[-1])
+ data = data[:-2]
+ log.debug('CRC (%04x <> %04x)' % \
+ (csum, self.calc_crc(data)))
+ valid = csum == self.calc_crc(data)
+ else:
+ csum = data[-1]
+ data = data[:-1]
+ log.debug('checksum (checksum(%02x <> %02x)' % \
+ (ord(csum), self.calc_checksum(data)))
+ valid = ord(csum) == self.calc_checksum(data)
+
+ # valid data, append chunk
+ if valid:
+ income_size += len(data)
+ stream.write(data)
+ self.putc(ACK)
+ sequence = (sequence + 1) % 0x100
+ char = self.getc(1, timeout)
+ continue
+ else:
+ # consume data
+ self.getc(packet_size + 1 + crc_mode)
+ self.debug('expecting sequence %d, got %d/%d' % \
+ (sequence, seq1, seq2))
+
+ # something went wrong, request retransmission
+ self.putc(NAK)
+
+ def calc_checksum(self, data, checksum=0):
+ '''
+ Calculate the checksum for a given block of data, can also be used to
+ update a checksum.
+
+ >>> csum = modem.calc_checksum('hello')
+ >>> csum = modem.calc_checksum('world', csum)
+ >>> hex(csum)
+ '0x3c'
+
+ '''
+ return (sum(map(ord, data)) + checksum) % 256
+
+ def calc_crc(self, data, crc=0):
+ '''
+ Calculate the Cyclic Redundancy Check for a given block of data, can
+ also be used to update a CRC.
+
+ >>> crc = modem.calc_crc('hello')
+ >>> crc = modem.calc_crc('world', crc)
+ >>> hex(crc)
+ '0xd5e3'
+
+ '''
+ for char in data:
+ crc = (crc << 8) ^ self.crctable[((crc >> 8) ^ int(char)) & 0xff]
+ return crc & 0xffff
+
+
+XMODEM1k = partial(XMODEM, mode='xmodem1k')
+
+
+def run():
+ import optparse
+ import subprocess
+
+ parser = optparse.OptionParser(usage='%prog [<options>] <send|recv> filename filename')
+ parser.add_option('-m', '--mode', default='xmodem',
+ help='XMODEM mode (xmodem, xmodem1k)')
+
+ options, args = parser.parse_args()
+ if len(args) != 3:
+ parser.error('invalid arguments')
+ return 1
+
+ elif args[0] not in ('send', 'recv'):
+ parser.error('invalid mode')
+ return 1
+
+ def _func(so, si):
+ import select
+ import subprocess
+
+ print('si', si)
+ print('so', so)
+
+ def getc(size, timeout=3):
+ w,t,f = select.select([so], [], [], timeout)
+ if w:
+ data = so.read(size)
+ else:
+ data = None
+
+ print('getc(', repr(data), ')')
+ return data
+
+ def putc(data, timeout=3):
+ w,t,f = select.select([], [si], [], timeout)
+ if t:
+ si.write(data)
+ si.flush()
+ size = len(data)
+ else:
+ size = None
+
+ print('putc(', repr(data), repr(size), ')')
+ return size
+
+ return getc, putc
+
+ def _pipe(*command):
+ pipe = subprocess.Popen(command,
+ stdout=subprocess.PIPE, stdin=subprocess.PIPE)
+ return pipe.stdout, pipe.stdin
+
+ if args[0] == 'recv':
+ import io
+ getc, putc = _func(*_pipe('sz', '--xmodem', args[2]))
+ stream = open(args[1], 'wb')
+ xmodem = XMODEM(getc, putc, mode=options.mode)
+ status = xmodem.recv(stream, retry=8)
+ stream.close()
+
+ elif args[0] == 'send':
+ getc, putc = _func(*_pipe('rz', '--xmodem', args[2]))
+ stream = open(args[1], 'rb')
+ xmodem = XMODEM(getc, putc, mode=options.mode)
+ status = xmodem.send(stream, retry=8)
+ stream.close()
+
+if __name__ == '__main__':
+ sys.exit(run())
diff --git a/ports/esp32s2/Makefile b/ports/esp32s2/Makefile
index 47afc4108..55db73604 100644
--- a/ports/esp32s2/Makefile
+++ b/ports/esp32s2/Makefile
@@ -2,7 +2,7 @@
#
# The MIT License (MIT)
#
-# Copyright (c) 2020 Scott Shawcroft for Adafruit Industries
+# SPDX-FileCopyrightText: 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
@@ -78,6 +78,7 @@ INC += -Iesp-idf/components/freertos/xtensa/include
INC += -Iesp-idf/components/esp32s2/include
INC += -Iesp-idf/components/xtensa/esp32s2/include
INC += -Iesp-idf/components/esp_common/include
+INC += -Iesp-idf/components/esp_ringbuf/include
INC += -Iesp-idf/components/esp_rom/include
INC += -Iesp-idf/components/xtensa/include
INC += -Iesp-idf/components/esp_timer/include
@@ -100,14 +101,19 @@ CFLAGS += -DSTACK_CANARY_VALUE=0xa5a5a5a5
#Debugging/Optimization
ifeq ($(DEBUG), 1)
CFLAGS += -ggdb
+ OPTIMIZATION_FLAGS ?= -Og
# You may want to enable these flags to make setting breakpoints easier.
# CFLAGS += -fno-inline -fno-ipa-sra
else
- CFLAGS += -Os -DNDEBUG -ggdb3
+ CFLAGS += -DNDEBUG -ggdb3
+ OPTIMIZATION_FLAGS ?= -O2
# TODO: Test with -flto
### CFLAGS += -flto
endif
+# option to override compiler optimization level, set in boards/$(BOARD)/mpconfigboard.mk
+CFLAGS += $(OPTIMIZATION_FLAGS)
+
CFLAGS += $(INC) -Werror -Wall -mlongcalls -std=gnu11 -Wl,--gc-sections $(BASE_CFLAGS) $(C_DEFS) $(CFLAGS_MOD) $(COPT)
LDFLAGS = $(CFLAGS) -Wl,-nostdlib -Wl,-Map=$@.map -Wl,-cref
@@ -216,8 +222,8 @@ $(BUILD)/esp-idf/config/sdkconfig.h: boards/$(BOARD)/sdkconfig | $(BUILD)/esp-id
# build a lib
# Adding -d explain -j 1 -v to the ninja line will output debug info
-$(BUILD)/esp-idf/esp-idf/%.a: $(BUILD)/esp-idf/config/sdkconfig.h
- ninja -C $(BUILD)/esp-idf esp-idf/$*.a
+#$(BUILD)/esp-idf/esp-idf/%.a: $(BUILD)/esp-idf/config/sdkconfig.h
+# ninja -C $(BUILD)/esp-idf esp-idf/$*.a
$(BUILD)/esp-idf/esp-idf/esp32s2/esp32s2_out.ld: $(BUILD)/esp-idf/config/sdkconfig.h
ninja -C $(BUILD)/esp-idf esp-idf/esp32s2/esp32s2_out.ld
@@ -229,9 +235,6 @@ $(BUILD)/esp-idf/esp-idf/esp32s2/ld/esp32s2.project.ld: $(BUILD)/esp-idf/config/
$(BUILD)/esp-idf/partition_table/partition-table.bin: $(BUILD)/esp-idf/config/sdkconfig.h
IDF_PATH=$(IDF_PATH) ninja -C $(BUILD)/esp-idf partition_table/partition-table.bin
-$(BUILD)/esp-idf/bootloader/bootloader.bin: $(BUILD)/esp-idf/config/sdkconfig.h
- ninja -C $(BUILD)/esp-idf bootloader/bootloader.bin
-
# run menuconfig
menuconfig: $(BUILD)/esp-idf/config
ninja -C $(BUILD)/esp-idf menuconfig
@@ -257,11 +260,22 @@ ESP_AUTOGEN_LD = $(BUILD)/esp-idf/esp-idf/esp32s2/esp32s2_out.ld $(BUILD)/esp-id
FLASH_FLAGS = --flash_mode $(CIRCUITPY_ESP_FLASH_MODE) --flash_freq $(CIRCUITPY_ESP_FLASH_FREQ) --flash_size $(CIRCUITPY_ESP_FLASH_SIZE)
-all: $(BUILD)/firmware.bin
+all: $(BUILD)/firmware.bin $(BUILD)/firmware.uf2
+
+.PHONY: esp-idf-stamp
+esp-idf-stamp: $(BUILD)/esp-idf/config/sdkconfig.h
+ ninja -C $(BUILD)/esp-idf \
+ bootloader/bootloader.bin \
+ esp-idf/bootloader_support/libbootloader_support.a \
+ esp-idf/esp32s2/ld/esp32s2.project.ld \
+ esp-idf/esp_system/libesp_system.a \
+ esp-idf/freertos/libfreertos.a \
+ esp-idf/log/liblog.a \
+ esp-idf/xtensa/libxtensa.a
-$(BUILD)/firmware.elf: $(OBJ) | $(ESP_IDF_COMPONENTS_EXPANDED) $(ESP_AUTOGEN_LD)
+$(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
@@ -270,11 +284,18 @@ $(BUILD)/circuitpython-firmware.bin: $(BUILD)/firmware.elf
# $(Q)$(OBJCOPY) -O binary $^ $@
# $(Q)$(OBJCOPY) -O binary -j .vectors -j .text -j .data $^ $@
-$(BUILD)/firmware.bin: $(BUILD)/esp-idf/partition_table/partition-table.bin $(BUILD)/esp-idf/bootloader/bootloader.bin $(BUILD)/circuitpython-firmware.bin
+$(BUILD)/firmware.bin: $(BUILD)/circuitpython-firmware.bin | esp-idf-stamp
$(Q)$(PYTHON) ../../tools/join_bins.py $@ 0x1000 $(BUILD)/esp-idf/bootloader/bootloader.bin 0x8000 $(BUILD)/esp-idf/partition_table/partition-table.bin 0x10000 $(BUILD)/circuitpython-firmware.bin
+$(BUILD)/firmware.uf2: $(BUILD)/circuitpython-firmware.bin
+ $(STEPECHO) "Create $@"
+ $(Q)$(PYTHON3) $(TOP)/tools/uf2/utils/uf2conv.py -f 0xbfdd4eee -b 0x0000 -c -o $@ $^
+
flash: $(BUILD)/firmware.bin
- esptool.py --chip esp32s2 -p $(PORT) -b 460800 --before=default_reset --after=hard_reset write_flash $(FLASH_FLAGS) 0x0000 $^
+ esptool.py --chip esp32s2 -p $(PORT) --no-stub -b 460800 --before=default_reset --after=hard_reset write_flash $(FLASH_FLAGS) 0x0000 $^
+
+flash-circuitpython-only: $(BUILD)/circuitpython-firmware.bin
+ esptool.py --chip esp32s2 -p $(PORT) --no-stub -b 460800 --before=default_reset --after=hard_reset write_flash $(FLASH_FLAGS) 0x10000 $^
include $(TOP)/py/mkrules.mk
diff --git a/ports/esp32s2/background.c b/ports/esp32s2/background.c
index e22cf4aac..40ce9ecfd 100644
--- a/ports/esp32s2/background.c
+++ b/ports/esp32s2/background.c
@@ -35,29 +35,12 @@
#include "shared-module/displayio/__init__.h"
#endif
-static bool running_background_tasks = false;
-void background_tasks_reset(void) {
- running_background_tasks = false;
+void port_background_task(void) {
+ // Zero delay in case FreeRTOS wants to switch to something else.
+ vTaskDelay(0);
}
-void run_background_tasks(void) {
- // Don't call ourselves recursively.
- if (running_background_tasks) {
- return;
- }
+void port_start_background_task(void) {}
- // Delay for 1 tick so that we don't starve the idle task.
- // TODO: 1 tick is 10ms which is a long time! Can we delegate to idle for a minimal amount of
- // time?
- vTaskDelay(1);
- running_background_tasks = true;
- filesystem_background();
-
- // #if CIRCUITPY_DISPLAYIO
- // displayio_background();
- // #endif
- running_background_tasks = false;
-
- assert_heap_ok();
-}
+void port_finish_background_task(void) {}
diff --git a/ports/esp32s2/background.h b/ports/esp32s2/background.h
index 0e1fb7a56..cb850d4e5 100644
--- a/ports/esp32s2/background.h
+++ b/ports/esp32s2/background.h
@@ -29,7 +29,4 @@
#include <stdbool.h>
-void background_tasks_reset(void);
-void run_background_tasks(void);
-
#endif // MICROPY_INCLUDED_ESP32S2_BACKGROUND_H
diff --git a/ports/esp32s2/boards/espressif_saola_1_wroom/board.c b/ports/esp32s2/boards/espressif_saola_1_wroom/board.c
index b7b2c4ef5..9f708874b 100644
--- a/ports/esp32s2/boards/espressif_saola_1_wroom/board.c
+++ b/ports/esp32s2/boards/espressif_saola_1_wroom/board.c
@@ -30,12 +30,12 @@
void board_init(void) {
// USB
- never_reset_pin(&pin_GPIO19);
- never_reset_pin(&pin_GPIO20);
+ common_hal_never_reset_pin(&pin_GPIO19);
+ common_hal_never_reset_pin(&pin_GPIO20);
// Debug UART
- never_reset_pin(&pin_GPIO43);
- never_reset_pin(&pin_GPIO44);
+ common_hal_never_reset_pin(&pin_GPIO43);
+ common_hal_never_reset_pin(&pin_GPIO44);
}
bool board_requests_safe_mode(void) {
diff --git a/ports/esp32s2/boards/espressif_saola_1_wroom/mpconfigboard.mk b/ports/esp32s2/boards/espressif_saola_1_wroom/mpconfigboard.mk
index d9ad56886..6e7627265 100644
--- a/ports/esp32s2/boards/espressif_saola_1_wroom/mpconfigboard.mk
+++ b/ports/esp32s2/boards/espressif_saola_1_wroom/mpconfigboard.mk
@@ -11,8 +11,6 @@ LONGINT_IMPL = MPZ
CFLAGS += -DCFG_TUD_TASK_QUEUE_SZ=32
CIRCUITPY_NEOPIXEL_WRITE = 0
-CIRCUITPY_DIGITALIO = 0
-CIRCUITPY_MICROCONTROLLER = 0
CIRCUITPY_ESP_FLASH_MODE=dio
CIRCUITPY_ESP_FLASH_FREQ=40m
diff --git a/ports/esp32s2/boards/espressif_saola_1_wrover/board.c b/ports/esp32s2/boards/espressif_saola_1_wrover/board.c
index b7b2c4ef5..9f708874b 100644
--- a/ports/esp32s2/boards/espressif_saola_1_wrover/board.c
+++ b/ports/esp32s2/boards/espressif_saola_1_wrover/board.c
@@ -30,12 +30,12 @@
void board_init(void) {
// USB
- never_reset_pin(&pin_GPIO19);
- never_reset_pin(&pin_GPIO20);
+ common_hal_never_reset_pin(&pin_GPIO19);
+ common_hal_never_reset_pin(&pin_GPIO20);
// Debug UART
- never_reset_pin(&pin_GPIO43);
- never_reset_pin(&pin_GPIO44);
+ common_hal_never_reset_pin(&pin_GPIO43);
+ common_hal_never_reset_pin(&pin_GPIO44);
}
bool board_requests_safe_mode(void) {
diff --git a/ports/esp32s2/boards/espressif_saola_1_wrover/mpconfigboard.mk b/ports/esp32s2/boards/espressif_saola_1_wrover/mpconfigboard.mk
index 558b1144a..1437df7f4 100644
--- a/ports/esp32s2/boards/espressif_saola_1_wrover/mpconfigboard.mk
+++ b/ports/esp32s2/boards/espressif_saola_1_wrover/mpconfigboard.mk
@@ -11,8 +11,6 @@ LONGINT_IMPL = MPZ
CFLAGS += -DCFG_TUD_TASK_QUEUE_SZ=32
CIRCUITPY_NEOPIXEL_WRITE = 0
-CIRCUITPY_DIGITALIO = 0
-CIRCUITPY_MICROCONTROLLER = 0
CIRCUITPY_ESP_FLASH_MODE=dio
CIRCUITPY_ESP_FLASH_FREQ=40m
diff --git a/ports/esp32s2/boards/unexpectedmaker_feathers2/board.c b/ports/esp32s2/boards/unexpectedmaker_feathers2/board.c
new file mode 100644
index 000000000..1dc30b5af
--- /dev/null
+++ b/ports/esp32s2/boards/unexpectedmaker_feathers2/board.c
@@ -0,0 +1,56 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020 Scott Shawcroft for Adafruit Industries
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include "boards/board.h"
+#include "mpconfigboard.h"
+#include "shared-bindings/microcontroller/Pin.h"
+
+void board_init(void) {
+ // USB
+ common_hal_never_reset_pin(&pin_GPIO19);
+ common_hal_never_reset_pin(&pin_GPIO20);
+
+ // Debug UART
+ common_hal_never_reset_pin(&pin_GPIO43);
+ common_hal_never_reset_pin(&pin_GPIO44);
+
+ // SPI Flash and RAM
+ common_hal_never_reset_pin(&pin_GPIO26);
+ common_hal_never_reset_pin(&pin_GPIO27);
+ common_hal_never_reset_pin(&pin_GPIO28);
+ common_hal_never_reset_pin(&pin_GPIO29);
+ common_hal_never_reset_pin(&pin_GPIO30);
+ common_hal_never_reset_pin(&pin_GPIO31);
+ common_hal_never_reset_pin(&pin_GPIO32);
+}
+
+bool board_requests_safe_mode(void) {
+ return false;
+}
+
+void reset_board(void) {
+
+}
diff --git a/ports/esp32s2/boards/unexpectedmaker_feathers2/mpconfigboard.h b/ports/esp32s2/boards/unexpectedmaker_feathers2/mpconfigboard.h
new file mode 100644
index 000000000..93fb0c573
--- /dev/null
+++ b/ports/esp32s2/boards/unexpectedmaker_feathers2/mpconfigboard.h
@@ -0,0 +1,36 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019 Scott Shawcroft for Adafruit Industries
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+//Micropython setup
+
+#define MICROPY_HW_BOARD_NAME "FeatherS2"
+#define MICROPY_HW_MCU_NAME "ESP32S2"
+
+#define AUTORESET_DELAY_MS 500
+
+// Doesn't work with this on.
+// #define MICROPY_HW_APA102_MOSI (&pin_GPIO44)
+// #define MICROPY_HW_APA102_SCK (&pin_GPIO45)
diff --git a/ports/esp32s2/boards/unexpectedmaker_feathers2/mpconfigboard.mk b/ports/esp32s2/boards/unexpectedmaker_feathers2/mpconfigboard.mk
new file mode 100644
index 000000000..ea3484d2f
--- /dev/null
+++ b/ports/esp32s2/boards/unexpectedmaker_feathers2/mpconfigboard.mk
@@ -0,0 +1,21 @@
+USB_VID = 0x239A
+USB_PID = 0x80AC
+USB_PRODUCT = "FeatherS2"
+USB_MANUFACTURER = "UnexpectedMaker"
+USB_DEVICES = "CDC,MSC,HID"
+
+
+INTERNAL_FLASH_FILESYSTEM = 1
+LONGINT_IMPL = MPZ
+
+# The default queue depth of 16 overflows on release builds,
+# so increase it to 32.
+CFLAGS += -DCFG_TUD_TASK_QUEUE_SZ=32
+
+CIRCUITPY_NEOPIXEL_WRITE = 0
+
+CIRCUITPY_ESP_FLASH_MODE=qio
+CIRCUITPY_ESP_FLASH_FREQ=40m
+CIRCUITPY_ESP_FLASH_SIZE=16MB
+
+CIRCUITPY_BITBANG_APA102 = 1
diff --git a/ports/esp32s2/boards/unexpectedmaker_feathers2/pins.c b/ports/esp32s2/boards/unexpectedmaker_feathers2/pins.c
new file mode 100644
index 000000000..e8dd2edf6
--- /dev/null
+++ b/ports/esp32s2/boards/unexpectedmaker_feathers2/pins.c
@@ -0,0 +1,57 @@
+#include "shared-bindings/board/__init__.h"
+
+STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
+ { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO17) },
+ { MP_ROM_QSTR(MP_QSTR_D14), MP_ROM_PTR(&pin_GPIO17) },
+
+ { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO18) },
+ { MP_ROM_QSTR(MP_QSTR_D15), MP_ROM_PTR(&pin_GPIO18) },
+
+ { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO14) },
+ { MP_ROM_QSTR(MP_QSTR_D16), MP_ROM_PTR(&pin_GPIO14) },
+
+ { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_GPIO12) },
+ { MP_ROM_QSTR(MP_QSTR_D17), MP_ROM_PTR(&pin_GPIO12) },
+
+ { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_GPIO6) },
+ { MP_ROM_QSTR(MP_QSTR_D18), MP_ROM_PTR(&pin_GPIO6) },
+
+ { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_GPIO5) },
+ { MP_ROM_QSTR(MP_QSTR_D19), MP_ROM_PTR(&pin_GPIO5) },
+
+ { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO36) },
+ { MP_ROM_QSTR(MP_QSTR_D25), MP_ROM_PTR(&pin_GPIO36) },
+
+ { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO35) },
+ { MP_ROM_QSTR(MP_QSTR_D24), MP_ROM_PTR(&pin_GPIO35) },
+
+ { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO37) },
+ { MP_ROM_QSTR(MP_QSTR_D23), MP_ROM_PTR(&pin_GPIO37) },
+
+ { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_GPIO44) },
+ { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO44) },
+
+ { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_GPIO43) },
+ { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO43) },
+
+ // Moving to 9 and 8
+ { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO38) },
+ { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO33) },
+ { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_GPIO1) },
+ { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_GPIO3) },
+ { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_GPIO7) },
+ { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_GPIO8) },
+ { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_GPIO9) },
+ { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_GPIO10) },
+ { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_GPIO11) },
+
+ { MP_ROM_QSTR(MP_QSTR_APA102_MOSI), MP_ROM_PTR(&pin_GPIO44) }, // MTDO
+ { MP_ROM_QSTR(MP_QSTR_APA102_SCK), MP_ROM_PTR(&pin_GPIO45) },
+
+ { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO13) },
+
+ { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
+ { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) },
+ { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) },
+};
+MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);
diff --git a/ports/esp32s2/boards/unexpectedmaker_feathers2/sdkconfig b/ports/esp32s2/boards/unexpectedmaker_feathers2/sdkconfig
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/ports/esp32s2/boards/unexpectedmaker_feathers2/sdkconfig
diff --git a/ports/esp32s2/common-hal/busio/I2C.c b/ports/esp32s2/common-hal/busio/I2C.c
new file mode 100644
index 000000000..57270372f
--- /dev/null
+++ b/ports/esp32s2/common-hal/busio/I2C.c
@@ -0,0 +1,228 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020 Scott Shawcroft for Adafruit Industries LLC
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include "shared-bindings/busio/I2C.h"
+#include "py/mperrno.h"
+#include "py/runtime.h"
+
+#include "driver/i2c.h"
+
+#include "shared-bindings/microcontroller/__init__.h"
+#include "shared-bindings/microcontroller/Pin.h"
+#include "supervisor/shared/translate.h"
+
+typedef enum {
+ STATUS_FREE = 0,
+ STATUS_IN_USE,
+ STATUS_NEVER_RESET
+} i2c_status_t;
+
+static i2c_status_t i2c_status[I2C_NUM_MAX];
+
+void never_reset_i2c(i2c_port_t num) {
+ i2c_status[num] = STATUS_NEVER_RESET;
+}
+
+void i2c_reset(void) {
+ for (i2c_port_t num = 0; num < I2C_NUM_MAX; num++) {
+ if (i2c_status[num] == STATUS_IN_USE) {
+ i2c_driver_delete(num);
+ i2c_status[num] = STATUS_FREE;
+ }
+ }
+}
+
+void common_hal_busio_i2c_construct(busio_i2c_obj_t *self,
+ const mcu_pin_obj_t* scl, const mcu_pin_obj_t* sda, uint32_t frequency, uint32_t timeout) {
+ // Pins 45 and 46 are "strapping" pins that impact start up behavior. They usually need to
+ // be pulled-down so pulling them up for I2C is a bad idea. To make this hard, we don't
+ // support I2C on these pins.
+ //
+ // 46 is also input-only so it'll never work.
+ if (scl->number == 45 || scl->number == 46 || sda->number == 45 || sda->number == 46) {
+ mp_raise_ValueError(translate("Invalid pins"));
+ }
+
+#if CIRCUITPY_REQUIRE_I2C_PULLUPS
+ // Test that the pins are in a high state. (Hopefully indicating they are pulled up.)
+ gpio_set_direction(sda->number, GPIO_MODE_DEF_INPUT);
+ gpio_set_direction(scl->number, GPIO_MODE_DEF_INPUT);
+
+ gpio_pulldown_en(sda->number);
+ gpio_pulldown_en(scl->number);
+
+ common_hal_mcu_delay_us(10);
+
+ gpio_pulldown_dis(sda->number);
+ gpio_pulldown_dis(scl->number);
+
+ // We must pull up within 3us to achieve 400khz.
+ common_hal_mcu_delay_us(3);
+
+ if (gpio_get_level(sda->number) == 0 || gpio_get_level(scl->number) == 0) {
+ reset_pin_number(sda->number);
+ reset_pin_number(scl->number);
+ mp_raise_RuntimeError(translate("SDA or SCL needs a pull up"));
+ }
+#endif
+
+
+ if (xSemaphoreCreateBinaryStatic(&self->semaphore) != &self->semaphore) {
+ mp_raise_RuntimeError(translate("Unable to create lock"));
+ }
+ xSemaphoreGive(&self->semaphore);
+ self->sda_pin = sda;
+ self->scl_pin = scl;
+ self->i2c_num = I2C_NUM_MAX;
+ for (i2c_port_t num = 0; num < I2C_NUM_MAX; num++) {
+ if (i2c_status[num] == STATUS_FREE) {
+ self->i2c_num = num;
+ }
+ }
+ if (self->i2c_num == I2C_NUM_MAX) {
+ mp_raise_ValueError(translate("All I2C peripherals are in use"));
+ }
+ i2c_status[self->i2c_num] = STATUS_IN_USE;
+ i2c_config_t i2c_conf = {
+ .mode = I2C_MODE_MASTER,
+ .sda_io_num = self->sda_pin->number,
+ .scl_io_num = self->scl_pin->number,
+ .sda_pullup_en = GPIO_PULLUP_DISABLE, /*!< Internal GPIO pull mode for I2C sda signal*/
+ .scl_pullup_en = GPIO_PULLUP_DISABLE, /*!< Internal GPIO pull mode for I2C scl signal*/
+
+ .master = {
+ .clk_speed = frequency,
+ }
+ };
+ esp_err_t result = i2c_param_config(self->i2c_num, &i2c_conf);
+ if (result != ESP_OK) {
+ mp_raise_ValueError(translate("Invalid pins"));
+ }
+ result = i2c_driver_install(self->i2c_num,
+ I2C_MODE_MASTER,
+ 0,
+ 0,
+ 0);
+ if (result != ESP_OK) {
+ mp_raise_OSError(MP_EIO);
+ }
+
+ claim_pin(sda);
+ claim_pin(scl);
+}
+
+bool common_hal_busio_i2c_deinited(busio_i2c_obj_t *self) {
+ return self->sda_pin == NULL;
+}
+
+void common_hal_busio_i2c_deinit(busio_i2c_obj_t *self) {
+ if (common_hal_busio_i2c_deinited(self)) {
+ return;
+ }
+
+ i2c_driver_delete(self->i2c_num);
+ i2c_status[self->i2c_num] = STATUS_FREE;
+
+ common_hal_reset_pin(self->sda_pin);
+ common_hal_reset_pin(self->scl_pin);
+ self->sda_pin = NULL;
+ self->scl_pin = NULL;
+}
+
+bool common_hal_busio_i2c_probe(busio_i2c_obj_t *self, uint8_t addr) {
+ i2c_cmd_handle_t cmd = i2c_cmd_link_create();
+ i2c_master_start(cmd);
+ i2c_master_write_byte(cmd, addr << 1, true);
+ i2c_master_stop(cmd);
+ esp_err_t result = i2c_master_cmd_begin(self->i2c_num, cmd, 10);
+ i2c_cmd_link_delete(cmd);
+ return result == ESP_OK;
+}
+
+bool common_hal_busio_i2c_try_lock(busio_i2c_obj_t *self) {
+ if (self->has_lock) {
+ return false;
+ }
+ self->has_lock = xSemaphoreTake(&self->semaphore, 0) == pdTRUE;
+ return self->has_lock;
+}
+
+bool common_hal_busio_i2c_has_lock(busio_i2c_obj_t *self) {
+ return self->has_lock;
+}
+
+void common_hal_busio_i2c_unlock(busio_i2c_obj_t *self) {
+ xSemaphoreGive(&self->semaphore);
+ self->has_lock = false;
+}
+
+uint8_t common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t addr,
+ const uint8_t *data, size_t len, bool transmit_stop_bit) {
+ i2c_cmd_handle_t cmd = i2c_cmd_link_create();
+ i2c_master_start(cmd);
+ i2c_master_write_byte(cmd, addr << 1, true);
+ i2c_master_write(cmd, (uint8_t*) data, len, true);
+ if (transmit_stop_bit) {
+ i2c_master_stop(cmd);
+ }
+ esp_err_t result = i2c_master_cmd_begin(self->i2c_num, cmd, 100 /* wait in ticks */);
+ i2c_cmd_link_delete(cmd);
+
+ if (result == ESP_OK) {
+ return 0;
+ } else if (result == ESP_FAIL) {
+ return MP_ENODEV;
+ }
+ return MP_EIO;
+}
+
+uint8_t common_hal_busio_i2c_read(busio_i2c_obj_t *self, uint16_t addr,
+ uint8_t *data, size_t len) {
+ i2c_cmd_handle_t cmd = i2c_cmd_link_create();
+ i2c_master_start(cmd);
+ i2c_master_write_byte(cmd, addr << 1 | 1, true); // | 1 to indicate read
+ if (len > 1) {
+ i2c_master_read(cmd, data, len - 1, 0);
+ }
+ i2c_master_read_byte(cmd, data + len - 1, 1);
+ i2c_master_stop(cmd);
+ esp_err_t result = i2c_master_cmd_begin(self->i2c_num, cmd, 100 /* wait in ticks */);
+ i2c_cmd_link_delete(cmd);
+
+ if (result == ESP_OK) {
+ return 0;
+ } else if (result == ESP_FAIL) {
+ return MP_ENODEV;
+ }
+ return MP_EIO;
+}
+
+void common_hal_busio_i2c_never_reset(busio_i2c_obj_t *self) {
+ never_reset_i2c(self->i2c_num);
+
+ common_hal_never_reset_pin(self->scl_pin);
+ common_hal_never_reset_pin(self->sda_pin);
+}
diff --git a/ports/esp32s2/common-hal/busio/I2C.h b/ports/esp32s2/common-hal/busio/I2C.h
new file mode 100644
index 000000000..24a3fd495
--- /dev/null
+++ b/ports/esp32s2/common-hal/busio/I2C.h
@@ -0,0 +1,48 @@
+/*
+ * 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_ESP32S2_COMMON_HAL_BUSIO_I2C_H
+#define MICROPY_INCLUDED_ESP32S2_COMMON_HAL_BUSIO_I2C_H
+
+#include "common-hal/microcontroller/Pin.h"
+
+#include "esp-idf/components/soc/include/hal/i2c_types.h"
+#include "FreeRTOS.h"
+#include "freertos/semphr.h"
+#include "py/obj.h"
+
+typedef struct {
+ mp_obj_base_t base;
+ const mcu_pin_obj_t* scl_pin;
+ const mcu_pin_obj_t* sda_pin;
+ i2c_port_t i2c_num;
+ StaticSemaphore_t semaphore;
+ bool has_lock;
+} busio_i2c_obj_t;
+
+void i2c_reset(void);
+
+#endif // MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_BUSIO_I2C_H
diff --git a/ports/esp32s2/common-hal/busio/OneWire.h b/ports/esp32s2/common-hal/busio/OneWire.h
new file mode 100644
index 000000000..bb6a01419
--- /dev/null
+++ b/ports/esp32s2/common-hal/busio/OneWire.h
@@ -0,0 +1,33 @@
+/*
+ * 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.
+ */
+
+#ifndef MICROPY_INCLUDED_ESP32S2_COMMON_HAL_BUSIO_ONEWIRE_H
+#define MICROPY_INCLUDED_ESP32S2_COMMON_HAL_BUSIO_ONEWIRE_H
+
+// Use bitbangio.
+#include "shared-module/busio/OneWire.h"
+
+#endif // MICROPY_INCLUDED_ESP32S2_COMMON_HAL_BUSIO_ONEWIRE_H
diff --git a/ports/esp32s2/common-hal/busio/SPI.c b/ports/esp32s2/common-hal/busio/SPI.c
new file mode 100644
index 000000000..a22075cd5
--- /dev/null
+++ b/ports/esp32s2/common-hal/busio/SPI.c
@@ -0,0 +1,358 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2016 Scott Shawcroft
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include "shared-bindings/busio/SPI.h"
+#include "py/mperrno.h"
+#include "py/runtime.h"
+
+#include "boards/board.h"
+#include "shared-bindings/microcontroller/Pin.h"
+#include "supervisor/shared/rgb_led_status.h"
+
+static bool spi_never_reset[SOC_SPI_PERIPH_NUM];
+
+// Store one lock handle per device so that we can free it.
+static spi_bus_lock_dev_handle_t lock_dev_handle[SOC_SPI_PERIPH_NUM];
+static intr_handle_t intr_handle[SOC_SPI_PERIPH_NUM];
+
+void spi_reset(void) {
+ for (spi_host_device_t host_id = SPI2_HOST; host_id < SOC_SPI_PERIPH_NUM; host_id++) {
+ if (spi_never_reset[host_id]) {
+ continue;
+ }
+ bool in_use = false;
+ if (lock_dev_handle[host_id] != NULL) {
+ spi_bus_lock_unregister_dev(lock_dev_handle[host_id]);
+ lock_dev_handle[host_id] = NULL;
+ in_use = true;
+ }
+ if (intr_handle[host_id] != NULL) {
+ esp_intr_free(intr_handle[host_id]);
+ intr_handle[host_id] = NULL;
+ in_use = true;
+ }
+ if (in_use) {
+ spi_bus_free(host_id);
+ }
+ }
+}
+
+// This is copied in from the ESP-IDF because it is static.
+// Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+static bool bus_uses_iomux_pins(spi_host_device_t host, const spi_bus_config_t* bus_config)
+{
+ if (bus_config->sclk_io_num>=0 &&
+ bus_config->sclk_io_num != spi_periph_signal[host].spiclk_iomux_pin) return false;
+ if (bus_config->quadwp_io_num>=0 &&
+ bus_config->quadwp_io_num != spi_periph_signal[host].spiwp_iomux_pin) return false;
+ if (bus_config->quadhd_io_num>=0 &&
+ bus_config->quadhd_io_num != spi_periph_signal[host].spihd_iomux_pin) return false;
+ if (bus_config->mosi_io_num >= 0 &&
+ bus_config->mosi_io_num != spi_periph_signal[host].spid_iomux_pin) return false;
+ if (bus_config->miso_io_num>=0 &&
+ bus_config->miso_io_num != spi_periph_signal[host].spiq_iomux_pin) return false;
+
+ return true;
+}
+
+// End copied code.
+
+static bool spi_bus_is_free(spi_host_device_t host_id) {
+ return spi_bus_get_attr(host_id) == NULL;
+}
+
+static void spi_interrupt_handler(void *arg) {
+ // busio_spi_obj_t *self = arg;
+}
+
+// The interrupt may get invoked by the bus lock.
+static void spi_bus_intr_enable(void *self)
+{
+ esp_intr_enable(((busio_spi_obj_t *)self)->interrupt);
+}
+
+// The interrupt is always disabled by the ISR itself, not exposed
+static void spi_bus_intr_disable(void *self)
+{
+ esp_intr_disable(((busio_spi_obj_t *)self)->interrupt);
+}
+
+void common_hal_busio_spi_construct(busio_spi_obj_t *self,
+ const mcu_pin_obj_t * clock, const mcu_pin_obj_t * mosi,
+ const mcu_pin_obj_t * miso) {
+ spi_bus_config_t bus_config;
+ bus_config.mosi_io_num = mosi != NULL ? mosi->number : -1;
+ bus_config.miso_io_num = miso != NULL ? miso->number : -1;
+ bus_config.sclk_io_num = clock != NULL ? clock->number : -1;
+ bus_config.quadwp_io_num = -1;
+ bus_config.quadhd_io_num = -1;
+ bus_config.max_transfer_sz = 0; // Uses the default
+ bus_config.flags = SPICOMMON_BUSFLAG_MASTER | SPICOMMON_BUSFLAG_SCLK |
+ (mosi != NULL ? SPICOMMON_BUSFLAG_MOSI : 0) |
+ (miso != NULL ? SPICOMMON_BUSFLAG_MISO : 0);
+ bus_config.intr_flags = 0;
+
+ // RAM and Flash is often on SPI1 and is unsupported by the IDF so use it as
+ // a flag value.
+ spi_host_device_t host_id = SPI1_HOST;
+ self->connected_through_gpio = true;
+ // Try and save SPI2 for pins that are on the IOMUX
+ if (bus_uses_iomux_pins(SPI2_HOST, &bus_config) && spi_bus_is_free(SPI2_HOST)) {
+ host_id = SPI2_HOST;
+ self->connected_through_gpio = false;
+ } else if (spi_bus_is_free(SPI3_HOST)) {
+ host_id = SPI3_HOST;
+ } else if (spi_bus_is_free(SPI2_HOST)) {
+ host_id = SPI2_HOST;
+ }
+ if (host_id == SPI1_HOST) {
+ mp_raise_ValueError(translate("All SPI peripherals are in use"));
+ }
+
+ esp_err_t result = spi_bus_initialize(host_id, &bus_config, host_id /* dma channel */);
+ if (result == ESP_ERR_NO_MEM) {
+ mp_raise_msg(&mp_type_MemoryError, translate("ESP-IDF memory allocation failed"));
+ } else if (result == ESP_ERR_INVALID_ARG) {
+ mp_raise_ValueError(translate("Invalid pins"));
+ }
+
+ // After this point, we need to deinit to free IDF memory so fill out self's pins.
+ self->clock_pin = clock;
+ self->MOSI_pin = mosi;
+ self->MISO_pin = miso;
+ self->host_id = host_id;
+
+ spi_bus_lock_dev_config_t config = { .flags = 0 };
+ // The returned lock is stored in the bus lock but must be freed separately with
+ // spi_bus_lock_unregister_dev.
+ result = spi_bus_lock_register_dev(spi_bus_get_attr(host_id)->lock,
+ &config,
+ &self->lock);
+ if (result == ESP_ERR_NO_MEM) {
+ common_hal_busio_spi_deinit(self);
+ mp_raise_msg(&mp_type_MemoryError, translate("ESP-IDF memory allocation failed"));
+ }
+ lock_dev_handle[host_id] = self->lock;
+
+ result = esp_intr_alloc(spicommon_irqsource_for_host(host_id),
+ bus_config.intr_flags | ESP_INTR_FLAG_INTRDISABLED,
+ spi_interrupt_handler, self, &self->interrupt);
+ if (result == ESP_ERR_NO_MEM) {
+ common_hal_busio_spi_deinit(self);
+ mp_raise_msg(&mp_type_MemoryError, translate("ESP-IDF memory allocation failed"));
+ }
+ intr_handle[host_id] = self->interrupt;
+ spi_bus_lock_set_bg_control(spi_bus_get_attr(host_id)->lock, spi_bus_intr_enable, spi_bus_intr_disable, self);
+
+ spi_hal_context_t* hal = &self->hal_context;
+
+ // spi_hal_init clears the given hal context so set everything after.
+ spi_hal_init(hal, host_id);
+ hal->dmadesc_tx = &self->tx_dma;
+ hal->dmadesc_rx = &self->rx_dma;
+ hal->dmadesc_n = 1;
+
+ // We don't use native CS.
+ // hal->cs_setup = 0;
+ // hal->cs_hold = 0;
+ // hal->cs_pin_id = 0;
+
+ hal->sio = 0;
+ hal->half_duplex = 0;
+ // hal->tx_lsbfirst = 0;
+ // hal->rx_lsbfirst = 0;
+ hal->dma_enabled = 1;
+ hal->no_compensate = 1;
+ // Ignore CS bits
+
+ // We don't use cmd, addr or dummy bits.
+ // hal->cmd = 0;
+ // hal->cmd_bits = 0;
+ // hal->addr_bits = 0;
+ // hal->dummy_bits = 0;
+ // hal->addr = 0;
+
+ hal->io_mode = SPI_LL_IO_MODE_NORMAL;
+
+ common_hal_busio_spi_configure(self, 250000, 0, 0, 8);
+}
+
+void common_hal_busio_spi_never_reset(busio_spi_obj_t *self) {
+ spi_never_reset[self->host_id] = true;
+
+ common_hal_never_reset_pin(self->clock_pin);
+ common_hal_never_reset_pin(self->MOSI_pin);
+ common_hal_never_reset_pin(self->MISO_pin);
+}
+
+bool common_hal_busio_spi_deinited(busio_spi_obj_t *self) {
+ return self->clock_pin == NULL;
+}
+
+void common_hal_busio_spi_deinit(busio_spi_obj_t *self) {
+ if (common_hal_busio_spi_deinited(self)) {
+ return;
+ }
+ spi_never_reset[self->host_id] = false;
+ if (self->lock != NULL) {
+ spi_bus_lock_unregister_dev(self->lock);
+ lock_dev_handle[self->host_id] = NULL;
+ }
+ if (self->interrupt != NULL) {
+ esp_intr_free(self->interrupt);
+ intr_handle[self->host_id] = NULL;
+ }
+ spi_bus_free(self->host_id);
+
+ common_hal_reset_pin(self->clock_pin);
+ common_hal_reset_pin(self->MOSI_pin);
+ common_hal_reset_pin(self->MISO_pin);
+ self->clock_pin = NULL;
+}
+
+bool common_hal_busio_spi_configure(busio_spi_obj_t *self,
+ uint32_t baudrate, uint8_t polarity, uint8_t phase, uint8_t bits) {
+ if (baudrate == self->target_frequency &&
+ polarity == self->polarity &&
+ phase == self->phase &&
+ bits == self->bits) {
+ return true;
+ }
+ self->hal_context.mode = polarity << 1 | phase;
+ self->polarity = polarity;
+ self->phase = phase;
+ self->bits = bits;
+ self->target_frequency = baudrate;
+ self->hal_context.timing_conf = &self->timing_conf;
+ esp_err_t result = spi_hal_get_clock_conf(&self->hal_context,
+ self->target_frequency,
+ 128 /* duty_cycle */,
+ self->connected_through_gpio,
+ 0 /* input_delay_ns */,
+ &self->real_frequency,
+ &self->timing_conf);
+ if (result != ESP_OK) {
+ return false;
+ }
+
+ spi_hal_setup_device(&self->hal_context);
+ return true;
+}
+
+bool common_hal_busio_spi_try_lock(busio_spi_obj_t *self) {
+ // If our lock has already been taken then return false because someone else
+ // may already grabbed it in our call stack.
+ if (self->has_lock) {
+ return false;
+ }
+ // Wait to grab the lock from another task.
+ esp_err_t result = spi_bus_lock_acquire_start(self->lock, portMAX_DELAY);
+ self->has_lock = result == ESP_OK;
+ return self->has_lock;
+}
+
+bool common_hal_busio_spi_has_lock(busio_spi_obj_t *self) {
+ return self->has_lock;
+}
+
+void common_hal_busio_spi_unlock(busio_spi_obj_t *self) {
+ spi_bus_lock_acquire_end(self->lock);
+ self->has_lock = false;
+}
+
+bool common_hal_busio_spi_write(busio_spi_obj_t *self,
+ const uint8_t *data, size_t len) {
+ return common_hal_busio_spi_transfer(self, data, NULL, len);
+}
+
+bool common_hal_busio_spi_read(busio_spi_obj_t *self,
+ uint8_t *data, size_t len, uint8_t write_value) {
+ return common_hal_busio_spi_transfer(self, NULL, data, len);
+}
+
+bool common_hal_busio_spi_transfer(busio_spi_obj_t *self, const uint8_t *data_out, uint8_t *data_in, size_t len) {
+ if (len == 0) {
+ return true;
+ }
+
+ spi_hal_context_t* hal = &self->hal_context;
+ hal->send_buffer = NULL;
+ hal->rcv_buffer = NULL;
+ // Reset timing_conf in case we've moved since the last time we used it.
+ hal->timing_conf = &self->timing_conf;
+ // This rounds up.
+ size_t dma_count = (len + LLDESC_MAX_NUM_PER_DESC - 1) / LLDESC_MAX_NUM_PER_DESC;
+ for (size_t i = 0; i < dma_count; i++) {
+ size_t offset = LLDESC_MAX_NUM_PER_DESC * i;
+ size_t dma_len = len - offset;
+ if (dma_len > LLDESC_MAX_NUM_PER_DESC) {
+ dma_len = LLDESC_MAX_NUM_PER_DESC;
+ }
+ hal->tx_bitlen = dma_len * self->bits;
+ hal->rx_bitlen = dma_len * self->bits;
+ if (data_out != NULL) {
+ hal->send_buffer = (uint8_t*) data_out + offset;
+ }
+ if (data_in != NULL) {
+ hal->rcv_buffer = data_in + offset;
+ }
+
+ spi_hal_setup_trans(hal);
+ spi_hal_prepare_data(hal);
+ spi_hal_user_start(hal);
+ // TODO: Switch to waiting on a lock that is given by an interrupt.
+ while (!spi_hal_usr_is_done(hal)) {
+ RUN_BACKGROUND_TASKS;
+ }
+ spi_hal_fetch_result(hal);
+ }
+
+ return true;
+}
+
+uint32_t common_hal_busio_spi_get_frequency(busio_spi_obj_t* self) {
+ return self->real_frequency;
+}
+
+uint8_t common_hal_busio_spi_get_phase(busio_spi_obj_t* self) {
+ return self->phase;
+}
+
+uint8_t common_hal_busio_spi_get_polarity(busio_spi_obj_t* self) {
+ return self->polarity;
+}
diff --git a/ports/esp32s2/common-hal/busio/SPI.h b/ports/esp32s2/common-hal/busio/SPI.h
new file mode 100644
index 000000000..6d8203831
--- /dev/null
+++ b/ports/esp32s2/common-hal/busio/SPI.h
@@ -0,0 +1,62 @@
+/*
+ * 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_ESP32S2_COMMON_HAL_BUSIO_SPI_H
+#define MICROPY_INCLUDED_ESP32S2_COMMON_HAL_BUSIO_SPI_H
+
+#include "common-hal/microcontroller/Pin.h"
+
+#include "esp-idf/components/driver/include/driver/spi_common_internal.h"
+#include "esp-idf/components/soc/include/hal/spi_hal.h"
+#include "esp-idf/components/soc/include/hal/spi_types.h"
+#include "py/obj.h"
+
+typedef struct {
+ mp_obj_base_t base;
+ const mcu_pin_obj_t* clock_pin;
+ const mcu_pin_obj_t* MOSI_pin;
+ const mcu_pin_obj_t* MISO_pin;
+ spi_host_device_t host_id;
+ spi_bus_lock_dev_handle_t lock;
+ spi_hal_context_t hal_context;
+ spi_hal_timing_conf_t timing_conf;
+ intr_handle_t interrupt;
+ // IDF allocates these in DMA accessible memory so they may need to move when
+ // we use external RAM for CircuitPython.
+ lldesc_t tx_dma;
+ lldesc_t rx_dma;
+ uint32_t target_frequency;
+ int32_t real_frequency;
+ uint8_t polarity;
+ uint8_t phase;
+ uint8_t bits;
+ bool has_lock;
+ bool connected_through_gpio;
+} busio_spi_obj_t;
+
+void spi_reset(void);
+
+#endif // MICROPY_INCLUDED_ESP32S2_COMMON_HAL_BUSIO_SPI_H
diff --git a/ports/esp32s2/common-hal/busio/UART.c b/ports/esp32s2/common-hal/busio/UART.c
new file mode 100644
index 000000000..b0162adba
--- /dev/null
+++ b/ports/esp32s2/common-hal/busio/UART.c
@@ -0,0 +1,348 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020 Scott Shawcroft for Adafruit Industries LLC
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include "shared-bindings/microcontroller/__init__.h"
+#include "shared-bindings/busio/UART.h"
+
+#include "driver/uart.h"
+
+#include "mpconfigport.h"
+#include "lib/utils/interrupt_char.h"
+#include "py/gc.h"
+#include "py/mperrno.h"
+#include "py/runtime.h"
+#include "py/stream.h"
+#include "supervisor/shared/translate.h"
+#include "supervisor/shared/tick.h"
+
+void uart_reset(void) {
+ for (uart_port_t num = 0; num < UART_NUM_MAX; num++) {
+ // Ignore the UART used by the IDF.
+ #ifdef CONFIG_CONSOLE_UART_NUM
+ if (num == CONFIG_CONSOLE_UART_NUM) {
+ continue;
+ }
+ #endif
+ if (uart_is_driver_installed(num)) {
+ uart_driver_delete(num);
+ }
+ }
+}
+
+void common_hal_busio_uart_construct(busio_uart_obj_t *self,
+ const mcu_pin_obj_t * tx, const mcu_pin_obj_t * rx,
+ const mcu_pin_obj_t * rts, const mcu_pin_obj_t * cts,
+ const mcu_pin_obj_t * rs485_dir, bool rs485_invert,
+ uint32_t baudrate, uint8_t bits, busio_uart_parity_t parity, uint8_t stop,
+ mp_float_t timeout, uint16_t receiver_buffer_size, byte* receiver_buffer,
+ bool sigint_enabled) {
+
+ if (bits > 8) {
+ mp_raise_NotImplementedError(translate("bytes > 8 bits not supported"));
+ }
+
+ bool have_tx = tx != NULL;
+ bool have_rx = rx != NULL;
+ bool have_rts = rts != NULL;
+ bool have_cts = cts != NULL;
+ bool have_rs485_dir = rs485_dir != NULL;
+ if (!have_tx && !have_rx) {
+ mp_raise_ValueError(translate("tx and rx cannot both be None"));
+ }
+
+ // Filter for sane settings for RS485
+ if (have_rs485_dir) {
+ if (have_rts || have_cts) {
+ mp_raise_ValueError(translate("Cannot specify RTS or CTS in RS485 mode"));
+ }
+ } else if (rs485_invert) {
+ mp_raise_ValueError(translate("RS485 inversion specified when not in RS485 mode"));
+ }
+
+ self->timeout_ms = timeout * 1000;
+
+ self->uart_num = UART_NUM_MAX;
+ for (uart_port_t num = 0; num < UART_NUM_MAX; num++) {
+ if (!uart_is_driver_installed(num)) {
+ self->uart_num = num;
+ }
+ }
+ if (self->uart_num == UART_NUM_MAX) {
+ mp_raise_ValueError(translate("All UART peripherals are in use"));
+ }
+
+ uart_mode_t mode = UART_MODE_UART;
+ uart_hw_flowcontrol_t flow_control = UART_HW_FLOWCTRL_DISABLE;
+ if (have_rs485_dir) {
+ mode = UART_MODE_RS485_HALF_DUPLEX;
+ if (!rs485_invert) {
+ uart_set_line_inverse(self->uart_num, UART_SIGNAL_DTR_INV);
+ }
+ } else if (have_rts && have_cts) {
+ flow_control = UART_HW_FLOWCTRL_CTS_RTS;
+ } else if (have_rts) {
+ flow_control = UART_HW_FLOWCTRL_RTS;
+ } else if (have_rts) {
+ flow_control = UART_HW_FLOWCTRL_CTS;
+ }
+
+ if (receiver_buffer_size <= UART_FIFO_LEN) {
+ receiver_buffer_size = UART_FIFO_LEN + 8;
+ }
+
+ uint8_t rx_threshold = UART_FIFO_LEN - 8;
+ // Install the driver before we change the settings.
+ if (uart_driver_install(self->uart_num, receiver_buffer_size, 0, 0, NULL, 0) != ESP_OK ||
+ uart_set_mode(self->uart_num, mode) != ESP_OK) {
+ mp_raise_ValueError(translate("Could not initialize UART"));
+ }
+ uart_set_hw_flow_ctrl(self->uart_num, flow_control, rx_threshold);
+
+ // Set baud rate
+ common_hal_busio_uart_set_baudrate(self, baudrate);
+
+ uart_word_length_t word_length = UART_DATA_8_BITS;
+ switch (bits) {
+ // Shared bindings prevents data < 7 bits.
+ // case 5:
+ // word_length = UART_DATA_5_BITS;
+ // break;
+ // case 6:
+ // word_length = UART_DATA_6_BITS;
+ // break;
+ case 7:
+ word_length = UART_DATA_7_BITS;
+ break;
+ case 8:
+ word_length = UART_DATA_8_BITS;
+ break;
+ default:
+ // Won't hit this because shared-bindings limits to 7-9 bits. We error on 9 above.
+ break;
+ }
+ uart_set_word_length(self->uart_num, word_length);
+
+ uart_parity_t parity_mode = UART_PARITY_DISABLE;
+ switch (parity) {
+ case BUSIO_UART_PARITY_NONE:
+ parity_mode = UART_PARITY_DISABLE;
+ break;
+ case BUSIO_UART_PARITY_EVEN:
+ parity_mode = UART_PARITY_EVEN;
+ break;
+ case BUSIO_UART_PARITY_ODD:
+ parity_mode = UART_PARITY_ODD;
+ break;
+ default:
+ // Won't reach here because the input is an enum that is completely handled.
+ break;
+ }
+ uart_set_parity(self->uart_num, parity_mode);
+
+ // Stop is 1 or 2 always.
+ uart_stop_bits_t stop_bits= UART_STOP_BITS_1;
+ if (stop == 2) {
+ stop_bits = UART_STOP_BITS_2;
+ }
+ uart_set_stop_bits(self->uart_num, stop_bits);
+
+ self->tx_pin = NULL;
+ self->rx_pin = NULL;
+ self->rts_pin = NULL;
+ self->cts_pin = NULL;
+ int tx_num = -1;
+ int rx_num = -1;
+ int rts_num = -1;
+ int cts_num = -1;
+ if (have_tx) {
+ claim_pin(tx);
+ self->tx_pin = tx;
+ tx_num = tx->number;
+ }
+
+ if (have_rx) {
+ claim_pin(rx);
+ self->rx_pin = rx;
+ rx_num = rx->number;
+ }
+
+ if (have_rts) {
+ claim_pin(rts);
+ self->rts_pin = rts;
+ rts_num = rts->number;
+ }
+
+ if (have_cts) {
+ claim_pin(cts);
+ self->cts_pin = cts;
+ cts_num = cts->number;
+ }
+
+ if (have_rs485_dir) {
+ claim_pin(rs485_dir);
+ // RTS is used for RS485 direction.
+ self->rts_pin = rs485_dir;
+ rts_num = rs485_dir->number;
+ }
+ if (uart_set_pin(self->uart_num, tx_num, rx_num, rts_num, cts_num) != ESP_OK) {
+ mp_raise_ValueError(translate("Invalid pins"));
+ }
+}
+
+bool common_hal_busio_uart_deinited(busio_uart_obj_t *self) {
+ return self->rx_pin == NULL && self->tx_pin == NULL;
+}
+
+void common_hal_busio_uart_deinit(busio_uart_obj_t *self) {
+ if (common_hal_busio_uart_deinited(self)) {
+ return;
+ }
+ uart_driver_delete(self->uart_num);
+
+ common_hal_reset_pin(self->rx_pin);
+ common_hal_reset_pin(self->tx_pin);
+ common_hal_reset_pin(self->rts_pin);
+ common_hal_reset_pin(self->cts_pin);
+ self->rx_pin = NULL;
+ self->tx_pin = NULL;
+ self->cts_pin = NULL;
+ self->rts_pin = NULL;
+}
+
+// Read characters.
+size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t len, int *errcode) {
+ if (self->rx_pin == NULL) {
+ mp_raise_ValueError(translate("No RX pin"));
+ }
+ if (len == 0) {
+ // Nothing to read.
+ return 0;
+ }
+
+ size_t total_read = 0;
+ uint64_t start_ticks = supervisor_ticks_ms64();
+
+ // Busy-wait until timeout or until we've read enough chars.
+ while (supervisor_ticks_ms64() - start_ticks <= self->timeout_ms) {
+ // Read as many chars as we can right now, up to len.
+ size_t num_read = uart_read_bytes(self->uart_num, data, len, 0);
+ if (num_read < 0) {
+ break;
+ }
+
+ // Advance pointer in data buffer, and decrease how many chars left to read.
+ data += num_read;
+ len -= num_read;
+ total_read += num_read;
+ if (len == 0) {
+ // Don't need to read any more: data buf is full.
+ break;
+ }
+ if (num_read > 0) {
+ // Reset the timeout on every character read.
+ start_ticks = supervisor_ticks_ms64();
+ }
+ RUN_BACKGROUND_TASKS;
+ // Allow user to break out of a timeout with a KeyboardInterrupt.
+ if (mp_hal_is_interrupted()) {
+ break;
+ }
+ // If we are zero timeout, make sure we don't loop again (in the event
+ // we read in under 1ms)
+ if (self->timeout_ms == 0) {
+ break;
+ }
+ }
+
+ if (total_read == 0) {
+ *errcode = EAGAIN;
+ return MP_STREAM_ERROR;
+ }
+
+ return total_read;
+}
+
+// Write characters.
+size_t common_hal_busio_uart_write(busio_uart_obj_t *self, const uint8_t *data, size_t len, int *errcode) {
+ if (self->tx_pin == NULL) {
+ mp_raise_ValueError(translate("No TX pin"));
+ }
+
+ while (len > 0) {
+ int count = uart_tx_chars(self->uart_num, (const char*) data, len);
+ if (count < 0) {
+ *errcode = MP_EAGAIN;
+ return MP_STREAM_ERROR;
+ }
+ len -= count;
+ data += count;
+ RUN_BACKGROUND_TASKS;
+ }
+ while (uart_wait_tx_done(self->uart_num, 0) == ESP_ERR_TIMEOUT) {
+ RUN_BACKGROUND_TASKS;
+ }
+
+ return len;
+}
+
+uint32_t common_hal_busio_uart_get_baudrate(busio_uart_obj_t *self) {
+ uint32_t baudrate;
+ uart_get_baudrate(self->uart_num, &baudrate);
+ return baudrate;
+}
+
+void common_hal_busio_uart_set_baudrate(busio_uart_obj_t *self, uint32_t baudrate) {
+ if (baudrate > UART_BITRATE_MAX ||
+ uart_set_baudrate(self->uart_num, baudrate) != ESP_OK) {
+ mp_raise_ValueError(translate("Unsupported baudrate"));
+ }
+}
+
+mp_float_t common_hal_busio_uart_get_timeout(busio_uart_obj_t *self) {
+ return (mp_float_t) (self->timeout_ms / 1000.0f);
+}
+
+void common_hal_busio_uart_set_timeout(busio_uart_obj_t *self, mp_float_t timeout) {
+ self->timeout_ms = timeout * 1000;
+}
+
+uint32_t common_hal_busio_uart_rx_characters_available(busio_uart_obj_t *self) {
+ size_t count;
+ uart_get_buffered_data_len(self->uart_num, &count);
+ return count;
+}
+
+void common_hal_busio_uart_clear_rx_buffer(busio_uart_obj_t *self) {
+ uart_flush(self->uart_num);
+}
+
+// True if there are no characters still to be written.
+bool common_hal_busio_uart_ready_to_tx(busio_uart_obj_t *self) {
+ if (self->tx_pin == NULL) {
+ return false;
+ }
+ return uart_wait_tx_done(self->uart_num, 0) != ESP_ERR_TIMEOUT;
+}
diff --git a/ports/esp32s2/common-hal/busio/UART.h b/ports/esp32s2/common-hal/busio/UART.h
new file mode 100644
index 000000000..b3cc92966
--- /dev/null
+++ b/ports/esp32s2/common-hal/busio/UART.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_ESP32S2_COMMON_HAL_BUSIO_UART_H
+#define MICROPY_INCLUDED_ESP32S2_COMMON_HAL_BUSIO_UART_H
+
+#include "common-hal/microcontroller/Pin.h"
+
+#include "esp-idf/components/soc/include/hal/uart_types.h"
+#include "py/obj.h"
+
+typedef struct {
+ mp_obj_base_t base;
+ const mcu_pin_obj_t* rx_pin;
+ const mcu_pin_obj_t* tx_pin;
+ const mcu_pin_obj_t* rts_pin;
+ const mcu_pin_obj_t* cts_pin;
+ uart_port_t uart_num;
+ uint8_t character_bits;
+ bool rx_error;
+ uint32_t timeout_ms;
+} busio_uart_obj_t;
+
+void uart_reset(void);
+
+#endif // MICROPY_INCLUDED_ESP32S2_COMMON_HAL_BUSIO_UART_H
diff --git a/ports/esp32s2/common-hal/busio/__init__.c b/ports/esp32s2/common-hal/busio/__init__.c
new file mode 100644
index 000000000..41761b674
--- /dev/null
+++ b/ports/esp32s2/common-hal/busio/__init__.c
@@ -0,0 +1 @@
+// No busio module functions.
diff --git a/ports/esp32s2/common-hal/digitalio/DigitalInOut.c b/ports/esp32s2/common-hal/digitalio/DigitalInOut.c
index 7745a9c0a..fb3ee10ad 100644
--- a/ports/esp32s2/common-hal/digitalio/DigitalInOut.c
+++ b/ports/esp32s2/common-hal/digitalio/DigitalInOut.c
@@ -46,7 +46,7 @@ digitalinout_result_t common_hal_digitalio_digitalinout_construct(
}
bool common_hal_digitalio_digitalinout_deinited(digitalio_digitalinout_obj_t *self) {
- return self->pin == mp_const_none;
+ return self->pin == NULL;
}
void common_hal_digitalio_digitalinout_deinit(digitalio_digitalinout_obj_t *self) {
@@ -55,7 +55,7 @@ void common_hal_digitalio_digitalinout_deinit(digitalio_digitalinout_obj_t *self
}
reset_pin_number(self->pin->number);
- self->pin = mp_const_none;
+ self->pin = NULL;
}
void common_hal_digitalio_digitalinout_switch_to_input(
diff --git a/ports/esp32s2/common-hal/displayio/ParallelBus.c b/ports/esp32s2/common-hal/displayio/ParallelBus.c
new file mode 100644
index 000000000..314b72ff7
--- /dev/null
+++ b/ports/esp32s2/common-hal/displayio/ParallelBus.c
@@ -0,0 +1,66 @@
+/*
+ * 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 "shared-bindings/displayio/ParallelBus.h"
+
+#include <stdint.h>
+
+#include "common-hal/microcontroller/Pin.h"
+#include "py/runtime.h"
+#include "shared-bindings/digitalio/DigitalInOut.h"
+#include "shared-bindings/microcontroller/__init__.h"
+
+void common_hal_displayio_parallelbus_construct(displayio_parallelbus_obj_t* self,
+ const mcu_pin_obj_t* data0, const mcu_pin_obj_t* command, const mcu_pin_obj_t* chip_select,
+ const mcu_pin_obj_t* write, const mcu_pin_obj_t* read, const mcu_pin_obj_t* reset) {
+
+ mp_raise_NotImplementedError(translate("ParallelBus not yet supported"));
+}
+
+void common_hal_displayio_parallelbus_deinit(displayio_parallelbus_obj_t* self) {
+
+}
+
+bool common_hal_displayio_parallelbus_reset(mp_obj_t obj) {
+ return false;
+}
+
+bool common_hal_displayio_parallelbus_bus_free(mp_obj_t obj) {
+ return false;
+}
+
+bool common_hal_displayio_parallelbus_begin_transaction(mp_obj_t obj) {
+
+ return false;
+}
+
+void common_hal_displayio_parallelbus_send(mp_obj_t obj, display_byte_type_t byte_type, display_chip_select_behavior_t chip_select, uint8_t *data, uint32_t data_length) {
+
+}
+
+void common_hal_displayio_parallelbus_end_transaction(mp_obj_t obj) {
+
+}
diff --git a/ports/esp32s2/common-hal/displayio/ParallelBus.h b/ports/esp32s2/common-hal/displayio/ParallelBus.h
new file mode 100644
index 000000000..cd636921d
--- /dev/null
+++ b/ports/esp32s2/common-hal/displayio/ParallelBus.h
@@ -0,0 +1,36 @@
+/*
+ * 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_DISPLAYIO_PARALLELBUS_H
+#define MICROPY_INCLUDED_ESP32S2_COMMON_HAL_DISPLAYIO_PARALLELBUS_H
+
+#include "common-hal/digitalio/DigitalInOut.h"
+
+typedef struct {
+ mp_obj_base_t base;
+} displayio_parallelbus_obj_t;
+
+#endif // MICROPY_INCLUDED_ESP32S2_COMMON_HAL_DISPLAYIO_PARALLELBUS_H
diff --git a/ports/esp32s2/common-hal/microcontroller/Pin.c b/ports/esp32s2/common-hal/microcontroller/Pin.c
index 4c39eea16..5a059f0bb 100644
--- a/ports/esp32s2/common-hal/microcontroller/Pin.c
+++ b/ports/esp32s2/common-hal/microcontroller/Pin.c
@@ -35,11 +35,14 @@
STATIC uint32_t never_reset_pins[2];
STATIC uint32_t in_use[2];
+bool apa102_mosi_in_use;
+bool apa102_sck_in_use;
+
void never_reset_pin_number(gpio_num_t pin_number) {
never_reset_pins[pin_number / 32] |= 1 << pin_number % 32;
}
-void never_reset_pin(const mcu_pin_obj_t* pin) {
+void common_hal_never_reset_pin(const mcu_pin_obj_t* pin) {
never_reset_pin_number(pin->number);
}
@@ -49,6 +52,10 @@ void reset_pin_number(gpio_num_t pin_number) {
in_use[pin_number / 32] &= ~(1 << pin_number % 32);
}
+void common_hal_reset_pin(const mcu_pin_obj_t* pin) {
+ reset_pin_number(pin->number);
+}
+
void reset_all_pins(void) {
for (uint8_t i = 0; i < GPIO_PIN_COUNT; i++) {
uint32_t iomux_address = GPIO_PIN_MUX_REG[i];
diff --git a/ports/esp32s2/common-hal/microcontroller/Pin.h b/ports/esp32s2/common-hal/microcontroller/Pin.h
index 6f47b1ed3..19985bda6 100644
--- a/ports/esp32s2/common-hal/microcontroller/Pin.h
+++ b/ports/esp32s2/common-hal/microcontroller/Pin.h
@@ -31,13 +31,16 @@
#include "peripherals/pins.h"
+extern bool apa102_mosi_in_use;
+extern bool apa102_sck_in_use;
+
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(gpio_num_t pin_number);
+void common_hal_reset_pin(const mcu_pin_obj_t* pin);
void claim_pin(const mcu_pin_obj_t* pin);
bool pin_number_is_free(gpio_num_t pin_number);
void never_reset_pin_number(gpio_num_t pin_number);
-void never_reset_pin(const mcu_pin_obj_t* pin);
#endif // MICROPY_INCLUDED_ESP32S2_COMMON_HAL_MICROCONTROLLER_PIN_H
diff --git a/ports/esp32s2/common-hal/microcontroller/Processor.c b/ports/esp32s2/common-hal/microcontroller/Processor.c
index 8eaf1a33d..39b85a18b 100644
--- a/ports/esp32s2/common-hal/microcontroller/Processor.c
+++ b/ports/esp32s2/common-hal/microcontroller/Processor.c
@@ -26,10 +26,14 @@
*/
#include <math.h>
+#include <string.h>
+
#include "common-hal/microcontroller/Processor.h"
#include "py/runtime.h"
#include "supervisor/shared/translate.h"
+#include "soc/efuse_reg.h"
+
float common_hal_mcu_processor_get_temperature(void) {
return NAN;
}
@@ -42,5 +46,23 @@ uint32_t common_hal_mcu_processor_get_frequency(void) {
return 0;
}
+STATIC uint8_t swap_nibbles(uint8_t v) {
+ return ((v << 4) | (v >> 4)) & 0xff;
+}
+
void common_hal_mcu_processor_get_uid(uint8_t raw_id[]) {
+ memset(raw_id, 0, COMMON_HAL_MCU_PROCESSOR_UID_LENGTH);
+
+ uint8_t *ptr = &raw_id[COMMON_HAL_MCU_PROCESSOR_UID_LENGTH-1];
+ // MAC address contains 48 bits (6 bytes), 32 in the low order word
+ uint32_t mac_address_part = REG_READ(EFUSE_RD_MAC_SPI_SYS_0_REG);
+ *ptr-- = swap_nibbles(mac_address_part & 0xff); mac_address_part >>= 8;
+ *ptr-- = swap_nibbles(mac_address_part & 0xff); mac_address_part >>= 8;
+ *ptr-- = swap_nibbles(mac_address_part & 0xff); mac_address_part >>= 8;
+ *ptr-- = swap_nibbles(mac_address_part & 0xff);
+
+ // and 16 in the high order word
+ mac_address_part = REG_READ(EFUSE_RD_MAC_SPI_SYS_1_REG);
+ *ptr-- = swap_nibbles(mac_address_part & 0xff); mac_address_part >>= 8;
+ *ptr-- = swap_nibbles(mac_address_part & 0xff);
}
diff --git a/ports/esp32s2/common-hal/microcontroller/Processor.h b/ports/esp32s2/common-hal/microcontroller/Processor.h
index a2ea261c8..f6636b333 100644
--- a/ports/esp32s2/common-hal/microcontroller/Processor.h
+++ b/ports/esp32s2/common-hal/microcontroller/Processor.h
@@ -27,7 +27,7 @@
#ifndef MICROPY_INCLUDED_LITEX_COMMON_HAL_MICROCONTROLLER_PROCESSOR_H
#define MICROPY_INCLUDED_LITEX_COMMON_HAL_MICROCONTROLLER_PROCESSOR_H
-#define COMMON_HAL_MCU_PROCESSOR_UID_LENGTH 15
+#define COMMON_HAL_MCU_PROCESSOR_UID_LENGTH 6
#include "py/obj.h"
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/esp-idf b/ports/esp32s2/esp-idf
-Subproject 7aae7f034bab68d2dd6aaa763924c91eb697d87
+Subproject 160ba4924d8b588e718f76e3a0d0e92c11052fa
diff --git a/ports/esp32s2/fatfs_port.c b/ports/esp32s2/fatfs_port.c
index 13ac21fb1..8bdc047c1 100644
--- a/ports/esp32s2/fatfs_port.c
+++ b/ports/esp32s2/fatfs_port.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/ports/esp32s2/modules/wroom.c b/ports/esp32s2/modules/wroom.c
index 16c586118..5e530701b 100644
--- a/ports/esp32s2/modules/wroom.c
+++ b/ports/esp32s2/modules/wroom.c
@@ -28,10 +28,10 @@
void never_reset_module_internal_pins(void) {
// SPI Flash
- never_reset_pin(&pin_GPIO27);
- never_reset_pin(&pin_GPIO28);
- never_reset_pin(&pin_GPIO29);
- never_reset_pin(&pin_GPIO30);
- never_reset_pin(&pin_GPIO31);
- never_reset_pin(&pin_GPIO32);
+ common_hal_never_reset_pin(&pin_GPIO27);
+ common_hal_never_reset_pin(&pin_GPIO28);
+ common_hal_never_reset_pin(&pin_GPIO29);
+ common_hal_never_reset_pin(&pin_GPIO30);
+ common_hal_never_reset_pin(&pin_GPIO31);
+ common_hal_never_reset_pin(&pin_GPIO32);
}
diff --git a/ports/esp32s2/modules/wrover.c b/ports/esp32s2/modules/wrover.c
index d589a8fd4..23fa7ee5c 100644
--- a/ports/esp32s2/modules/wrover.c
+++ b/ports/esp32s2/modules/wrover.c
@@ -28,11 +28,11 @@
void never_reset_module_internal_pins(void) {
// SPI Flash and RAM
- never_reset_pin(&pin_GPIO26);
- never_reset_pin(&pin_GPIO27);
- never_reset_pin(&pin_GPIO28);
- never_reset_pin(&pin_GPIO29);
- never_reset_pin(&pin_GPIO30);
- never_reset_pin(&pin_GPIO31);
- never_reset_pin(&pin_GPIO32);
+ common_hal_never_reset_pin(&pin_GPIO26);
+ common_hal_never_reset_pin(&pin_GPIO27);
+ common_hal_never_reset_pin(&pin_GPIO28);
+ common_hal_never_reset_pin(&pin_GPIO29);
+ common_hal_never_reset_pin(&pin_GPIO30);
+ common_hal_never_reset_pin(&pin_GPIO31);
+ common_hal_never_reset_pin(&pin_GPIO32);
}
diff --git a/ports/esp32s2/mpconfigport.mk b/ports/esp32s2/mpconfigport.mk
index ad2310539..c2d21e084 100644
--- a/ports/esp32s2/mpconfigport.mk
+++ b/ports/esp32s2/mpconfigport.mk
@@ -7,7 +7,7 @@ MPY_TOOL_LONGINT_IMPL = -mlongint-impl=mpz
INTERNAL_LIBM = 1
# Chip supplied serial number, in bytes
-USB_SERIAL_NUMBER_LENGTH = 30
+USB_SERIAL_NUMBER_LENGTH = 12
# Longints can be implemented as mpz, as longlong, or not
LONGINT_IMPL = MPZ
@@ -16,16 +16,16 @@ CIRCUITPY_FULL_BUILD = 0
CIRCUITPY_ANALOGIO = 0
CIRCUITPY_AUDIOBUSIO = 0
CIRCUITPY_AUDIOIO = 0
-CIRCUITPY_BITBANGIO = 0
+CIRCUITPY_BITBANGIO = 1
CIRCUITPY_BOARD = 1
CIRCUITPY_DIGITALIO = 1
-CIRCUITPY_BUSIO = 0
-CIRCUITPY_DISPLAYIO = 0
+CIRCUITPY_BUSIO = 1
+CIRCUITPY_DISPLAYIO = 1
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/mphalport.c b/ports/esp32s2/mphalport.c
index da5258b0e..e1662a6ce 100644
--- a/ports/esp32s2/mphalport.c
+++ b/ports/esp32s2/mphalport.c
@@ -32,9 +32,10 @@
#include "py/gc.h"
#include "esp-idf/components/xtensa/include/esp_debug_helpers.h"
+#include "esp-idf/components/esp_rom/include/esp32s2/rom/ets_sys.h"
void mp_hal_delay_us(mp_uint_t delay) {
- mp_hal_delay_ms(delay / 1000);
+ ets_delay_us(delay);
}
// This is provided by the esp-idf/components/xtensa/esp32s2/libhal.a binary
diff --git a/ports/esp32s2/sdkconfig.defaults b/ports/esp32s2/sdkconfig.defaults
index 958e1852e..729ebac88 100644
--- a/ports/esp32s2/sdkconfig.defaults
+++ b/ports/esp32s2/sdkconfig.defaults
@@ -190,9 +190,9 @@ CONFIG_EFUSE_MAX_BLK_LEN=256
# ESP32S2-specific
#
# CONFIG_ESP32S2_DEFAULT_CPU_FREQ_80 is not set
-CONFIG_ESP32S2_DEFAULT_CPU_FREQ_160=y
-# CONFIG_ESP32S2_DEFAULT_CPU_FREQ_240 is not set
-CONFIG_ESP32S2_DEFAULT_CPU_FREQ_MHZ=160
+# CONFIG_ESP32S2_DEFAULT_CPU_FREQ_160 is not set
+CONFIG_ESP32S2_DEFAULT_CPU_FREQ_240=y
+CONFIG_ESP32S2_DEFAULT_CPU_FREQ_MHZ=240
#
# Memory protection
@@ -271,10 +271,7 @@ CONFIG_ESP_CONSOLE_UART_RX_GPIO=3
CONFIG_ESP_CONSOLE_UART_BAUDRATE=115200
CONFIG_ESP_INT_WDT=y
CONFIG_ESP_INT_WDT_TIMEOUT_MS=300
-CONFIG_ESP_TASK_WDT=y
-# CONFIG_ESP_TASK_WDT_PANIC is not set
-CONFIG_ESP_TASK_WDT_TIMEOUT_S=5
-CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU0=y
+# CONFIG_ESP_TASK_WDT is not set
CONFIG_ESP_MAC_ADDR_UNIVERSE_WIFI_STA=y
CONFIG_ESP_MAC_ADDR_UNIVERSE_WIFI_AP=y
# end of Common ESP-related
@@ -528,6 +525,7 @@ CONFIG_MBEDTLS_INTERNAL_MEM_ALLOC=y
CONFIG_MBEDTLS_ASYMMETRIC_CONTENT_LEN=y
CONFIG_MBEDTLS_SSL_IN_CONTENT_LEN=16384
CONFIG_MBEDTLS_SSL_OUT_CONTENT_LEN=4096
+# CONFIG_MBEDTLS_DYNAMIC_BUFFER is not set
# CONFIG_MBEDTLS_DEBUG is not set
#
@@ -547,8 +545,12 @@ CONFIG_MBEDTLS_AES_USE_INTERRUPT=y
CONFIG_MBEDTLS_HARDWARE_GCM=y
CONFIG_MBEDTLS_HARDWARE_MPI=y
CONFIG_MBEDTLS_HARDWARE_SHA=y
+# CONFIG_MBEDTLS_ATCA_HW_ECDSA_SIGN is not set
+# CONFIG_MBEDTLS_ATCA_HW_ECDSA_VERIFY is not set
CONFIG_MBEDTLS_HAVE_TIME=y
# CONFIG_MBEDTLS_HAVE_TIME_DATE is not set
+CONFIG_MBEDTLS_ECDSA_DETERMINISTIC=y
+CONFIG_MBEDTLS_SHA512_C=y
CONFIG_MBEDTLS_TLS_SERVER_AND_CLIENT=y
# CONFIG_MBEDTLS_TLS_SERVER_ONLY is not set
# CONFIG_MBEDTLS_TLS_CLIENT_ONLY is not set
@@ -627,6 +629,10 @@ CONFIG_MBEDTLS_ECP_DP_BP384R1_ENABLED=y
CONFIG_MBEDTLS_ECP_DP_BP512R1_ENABLED=y
CONFIG_MBEDTLS_ECP_DP_CURVE25519_ENABLED=y
CONFIG_MBEDTLS_ECP_NIST_OPTIM=y
+# CONFIG_MBEDTLS_POLY1305_C is not set
+# CONFIG_MBEDTLS_CHACHA20_C is not set
+# CONFIG_MBEDTLS_HKDF_C is not set
+# CONFIG_MBEDTLS_THREADING_C is not set
# CONFIG_MBEDTLS_SECURITY_RISKS is not set
# end of mbedTLS
@@ -705,6 +711,7 @@ CONFIG_WPA_MBEDTLS_CRYPTO=y
# CONFIG_WPA_DEBUG_PRINT is not set
# CONFIG_WPA_TESTING_OPTIONS is not set
# CONFIG_WPA_TLS_V12 is not set
+# CONFIG_WPA_WPS_WARS is not set
# end of Supplicant
# end of Component config
@@ -756,7 +763,7 @@ CONFIG_ESP32_APPTRACE_LOCK_ENABLE=y
CONFIG_ADC2_DISABLE_DAC=y
CONFIG_SYSTEM_EVENT_QUEUE_SIZE=32
CONFIG_SYSTEM_EVENT_TASK_STACK_SIZE=2304
-CONFIG_MAIN_TASK_STACK_SIZE=3584
+CONFIG_MAIN_TASK_STACK_SIZE=8192
CONFIG_IPC_TASK_STACK_SIZE=1024
CONFIG_CONSOLE_UART_DEFAULT=y
# CONFIG_CONSOLE_UART_CUSTOM is not set
@@ -767,10 +774,7 @@ CONFIG_CONSOLE_UART_RX_GPIO=3
CONFIG_CONSOLE_UART_BAUDRATE=115200
CONFIG_INT_WDT=y
CONFIG_INT_WDT_TIMEOUT_MS=300
-CONFIG_TASK_WDT=y
-# CONFIG_TASK_WDT_PANIC is not set
-CONFIG_TASK_WDT_TIMEOUT_S=5
-CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU0=y
+# CONFIG_TASK_WDT is not set
# CONFIG_EVENT_LOOP_PROFILING is not set
CONFIG_POST_EVENTS_FROM_ISR=y
CONFIG_POST_EVENTS_FROM_IRAM_ISR=y
diff --git a/ports/esp32s2/supervisor/internal_flash.c b/ports/esp32s2/supervisor/internal_flash.c
index a8d3fa485..26774efac 100644
--- a/ports/esp32s2/supervisor/internal_flash.c
+++ b/ports/esp32s2/supervisor/internal_flash.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
* Copyright (c) 2019 Lucian Copeland for Adafruit Industries
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -39,11 +39,6 @@
#include "esp-idf/components/spi_flash/include/esp_partition.h"
-#include "esp_log.h"
-
-
-static const char* TAG = "CircuitPython Internal Flash";
-
#include "supervisor/usb.h"
STATIC const esp_partition_t * _partition;
@@ -52,8 +47,6 @@ void supervisor_flash_init(void) {
_partition = esp_partition_find_first(ESP_PARTITION_TYPE_DATA,
ESP_PARTITION_SUBTYPE_DATA_FAT,
NULL);
-
- ESP_EARLY_LOGW(TAG, "fatfs partition %p", _partition);
}
uint32_t supervisor_flash_get_block_size(void) {
@@ -74,11 +67,10 @@ STATIC uint8_t _cache[SECTOR_SIZE];
STATIC uint32_t _cache_lba;
mp_uint_t supervisor_flash_read_blocks(uint8_t *dest, uint32_t block, uint32_t num_blocks) {
- esp_err_t ok = esp_partition_read(_partition,
- block * FILESYSTEM_BLOCK_SIZE,
- dest,
- num_blocks * FILESYSTEM_BLOCK_SIZE);
- ESP_EARLY_LOGW(TAG, "read %d", ok);
+ esp_partition_read(_partition,
+ block * FILESYSTEM_BLOCK_SIZE,
+ dest,
+ num_blocks * FILESYSTEM_BLOCK_SIZE);
return 0;
}
@@ -90,13 +82,11 @@ mp_uint_t supervisor_flash_write_blocks(const uint8_t *src, uint32_t lba, uint32
uint32_t sector_offset = block_address / blocks_per_sector * SECTOR_SIZE;
uint8_t block_offset = block_address % blocks_per_sector;
- esp_err_t result;
if (_cache_lba != block_address) {
- result = esp_partition_read(_partition,
- sector_offset,
- _cache,
- SECTOR_SIZE);
- ESP_EARLY_LOGW(TAG, "flash read before write %d", result);
+ esp_partition_read(_partition,
+ sector_offset,
+ _cache,
+ SECTOR_SIZE);
_cache_lba = sector_offset;
}
for (uint8_t b = block_offset; b < blocks_per_sector; b++) {
@@ -109,11 +99,11 @@ mp_uint_t supervisor_flash_write_blocks(const uint8_t *src, uint32_t lba, uint32
FILESYSTEM_BLOCK_SIZE);
block++;
}
- result = esp_partition_erase_range(_partition, sector_offset, SECTOR_SIZE);
- result = esp_partition_write(_partition,
- sector_offset,
- _cache,
- SECTOR_SIZE);
+ esp_partition_erase_range(_partition, sector_offset, SECTOR_SIZE);
+ esp_partition_write(_partition,
+ sector_offset,
+ _cache,
+ SECTOR_SIZE);
}
return 0; // success
diff --git a/ports/esp32s2/supervisor/internal_flash.h b/ports/esp32s2/supervisor/internal_flash.h
index e06ef2d16..02d519003 100644
--- a/ports/esp32s2/supervisor/internal_flash.h
+++ b/ports/esp32s2/supervisor/internal_flash.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
* Copyright (c) 2019 Lucian Copeland for Adafruit Industries
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
diff --git a/ports/esp32s2/supervisor/port.c b/ports/esp32s2/supervisor/port.c
index 2437b4f34..e4767e514 100644
--- a/ports/esp32s2/supervisor/port.c
+++ b/ports/esp32s2/supervisor/port.c
@@ -35,13 +35,13 @@
#include "freertos/task.h"
#include "common-hal/microcontroller/Pin.h"
+#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"
-#include "esp_log.h"
-
-static const char* TAG = "CircuitPython";
-
STATIC esp_timer_handle_t _tick_timer;
void tick_timer_cb(void* arg) {
@@ -54,18 +54,25 @@ safe_mode_t port_init(void) {
args.arg = NULL;
args.dispatch_method = ESP_TIMER_TASK;
args.name = "CircuitPython Tick";
- esp_err_t result = esp_timer_create(&args, &_tick_timer);
- if (result != ESP_OK) {
- ESP_EARLY_LOGE(TAG, "Unable to create tick timer.");
- }
+ esp_timer_create(&args, &_tick_timer);
never_reset_module_internal_pins();
- ESP_EARLY_LOGW(TAG, "port init done");
return NO_SAFE_MODE;
}
void reset_port(void) {
-
reset_all_pins();
+
+ // 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();
+ uart_reset();
+#endif
}
void reset_to_bootloader(void) {
@@ -98,12 +105,8 @@ uint32_t *port_stack_get_top(void) {
supervisor_allocation _fixed_stack;
supervisor_allocation* port_fixed_stack(void) {
-
- ESP_EARLY_LOGW(TAG, "port fixed stack");
_fixed_stack.ptr = port_stack_get_limit();
- ESP_EARLY_LOGW(TAG, "got limit %p", _fixed_stack.ptr);
_fixed_stack.length = (port_stack_get_top() - port_stack_get_limit()) * sizeof(uint32_t);
- ESP_EARLY_LOGW(TAG, "got length %d", _fixed_stack.length);
return &_fixed_stack;
}
@@ -128,10 +131,7 @@ uint64_t port_get_raw_ticks(uint8_t* subticks) {
// Enable 1/1024 second tick.
void port_enable_tick(void) {
- esp_err_t result = esp_timer_start_periodic(_tick_timer, 1000000 / 1024);
- if (result != ESP_OK) {
- ESP_EARLY_LOGE(TAG, "Unable to start tick timer.");
- }
+ esp_timer_start_periodic(_tick_timer, 1000000 / 1024);
}
// Disable 1/1024 second tick.
@@ -142,14 +142,12 @@ void port_disable_tick(void) {
TickType_t sleep_time_set;
TickType_t sleep_time_duration;
void port_interrupt_after_ticks(uint32_t ticks) {
- // ESP_EARLY_LOGW(TAG, "after ticks");
sleep_time_set = xTaskGetTickCount();
sleep_time_duration = ticks / portTICK_PERIOD_MS;
// esp_sleep_enable_timer_wakeup(uint64_t time_in_us)
}
void port_sleep_until_interrupt(void) {
- // ESP_EARLY_LOGW(TAG, "sleep until");
// FreeRTOS delay here maybe.
// Light sleep shuts down BLE and wifi.
// esp_light_sleep_start()
@@ -163,8 +161,5 @@ void port_sleep_until_interrupt(void) {
// Wrap main in app_main that the IDF expects.
extern void main(void);
void app_main(void) {
- ESP_EARLY_LOGW(TAG, "Hello from CircuitPython");
- // ESP_LOGW(TAG, "Hello from CircuitPython");
-
main();
}
diff --git a/ports/litex/Makefile b/ports/litex/Makefile
index d75a4da28..612953daa 100644
--- a/ports/litex/Makefile
+++ b/ports/litex/Makefile
@@ -2,7 +2,7 @@
#
# The MIT License (MIT)
#
-# Copyright (c) 2019 Scott Shawcroft for Adafruit Industries
+# SPDX-FileCopyrightText: Copyright (c) 2019 Scott Shawcroft for Adafruit Industries
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
@@ -77,12 +77,17 @@ ifeq ($(DEBUG), 1)
CFLAGS += -ggdb
# You may want to enable these flags to make setting breakpoints easier.
CFLAGS += -fno-inline -fno-ipa-sra
+ OPTIMIZATION_FLAGS ?= -Og
else
- CFLAGS += -Os -DNDEBUG -ggdb3
+ CFLAGS += -DNDEBUG -ggdb3
+ OPTIMIZATION_FLAGS ?= -O2
# TODO: Test with -flto
### CFLAGS += -flto
endif
+# option to override compiler optimization level, set in boards/$(BOARD)/mpconfigboard.mk
+CFLAGS += $(OPTIMIZATION_FLAGS)
+
CFLAGS += $(INC) -Werror -Wall -std=gnu11 -nostdlib -fshort-enums $(BASE_CFLAGS) $(C_DEFS) $(CFLAGS_MOD) $(COPT)
# TODO: check this
diff --git a/ports/litex/background.c b/ports/litex/background.c
index 8c1897043..174d9588a 100644
--- a/ports/litex/background.c
+++ b/ports/litex/background.c
@@ -29,32 +29,6 @@
#include "supervisor/usb.h"
#include "supervisor/shared/stack.h"
-#if CIRCUITPY_DISPLAYIO
-#include "shared-module/displayio/__init__.h"
-#endif
-
-static bool running_background_tasks = false;
-
-void background_tasks_reset(void) {
- running_background_tasks = false;
-}
-
-void run_background_tasks(void) {
- // Don't call ourselves recursively.
- if (running_background_tasks) {
- return;
- }
- running_background_tasks = true;
- filesystem_background();
-
- #if USB_AVAILABLE
- usb_background();
- #endif
-
- #if CIRCUITPY_DISPLAYIO
- displayio_background();
- #endif
- running_background_tasks = false;
-
- assert_heap_ok();
-}
+void port_background_task(void) {}
+void port_start_background_task(void) {}
+void port_finish_background_task(void) {}
diff --git a/ports/litex/background.h b/ports/litex/background.h
index 09551c7fb..c80fbbe5c 100644
--- a/ports/litex/background.h
+++ b/ports/litex/background.h
@@ -27,9 +27,4 @@
#ifndef MICROPY_INCLUDED_LITEX_BACKGROUND_H
#define MICROPY_INCLUDED_LITEX_BACKGROUND_H
-#include <stdbool.h>
-
-void background_tasks_reset(void);
-void run_background_tasks(void);
-
#endif // MICROPY_INCLUDED_LITEX_BACKGROUND_H
diff --git a/ports/litex/common-hal/digitalio/DigitalInOut.c b/ports/litex/common-hal/digitalio/DigitalInOut.c
index 26f79f16d..53df637c4 100644
--- a/ports/litex/common-hal/digitalio/DigitalInOut.c
+++ b/ports/litex/common-hal/digitalio/DigitalInOut.c
@@ -46,7 +46,7 @@ digitalinout_result_t common_hal_digitalio_digitalinout_construct(
}
bool common_hal_digitalio_digitalinout_deinited(digitalio_digitalinout_obj_t *self) {
- return self->pin == mp_const_none;
+ return self->pin == NULL;
}
void common_hal_digitalio_digitalinout_deinit(digitalio_digitalinout_obj_t *self) {
@@ -55,7 +55,7 @@ void common_hal_digitalio_digitalinout_deinit(digitalio_digitalinout_obj_t *self
}
// reset_pin_number(0, self->pin->number);
- self->pin = mp_const_none;
+ self->pin = NULL;
}
void common_hal_digitalio_digitalinout_switch_to_input(
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/litex/fatfs_port.c b/ports/litex/fatfs_port.c
index 13ac21fb1..8bdc047c1 100644
--- a/ports/litex/fatfs_port.c
+++ b/ports/litex/fatfs_port.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/ports/litex/mpconfigport.mk b/ports/litex/mpconfigport.mk
index 311c87b5d..427e9ea84 100644
--- a/ports/litex/mpconfigport.mk
+++ b/ports/litex/mpconfigport.mk
@@ -18,6 +18,7 @@ CIRCUITPY_AUDIOIO = 0
CIRCUITPY_BITBANGIO = 0
CIRCUITPY_BOARD = 0
CIRCUITPY_BUSIO = 0
+CIRCUITPY_COUNTIO = 0
CIRCUITPY_DISPLAYIO = 0
CIRCUITPY_FREQUENCYIO = 0
CIRCUITPY_I2CPERIPHERAL = 0
@@ -25,7 +26,7 @@ CIRCUITPY_NVM = 0
CIRCUITPY_PULSEIO = 0
CIRCUITPY_ROTARYIO = 0
CIRCUITPY_RTC = 0
-CIRCUITPY_COUNTIO = 0
+CIRCUITPY_SDCARDIO = 0
# Enable USB support
CIRCUITPY_USB_HID = 1
CIRCUITPY_USB_MIDI = 1
diff --git a/ports/litex/mphalport.c b/ports/litex/mphalport.c
index 84a546795..862f16393 100644
--- a/ports/litex/mphalport.c
+++ b/ports/litex/mphalport.c
@@ -31,6 +31,7 @@
#include "py/mphal.h"
#include "py/mpstate.h"
#include "py/gc.h"
+#include "supervisor/usb.h"
#include "csr.h"
#include "generated/soc.h"
@@ -49,7 +50,7 @@ void isr(void) {
#ifdef CFG_TUSB_MCU
if (irqs & (1 << USB_INTERRUPT))
- tud_int_handler(0);
+ usb_irq_handler();
#endif
if (irqs & (1 << TIMER0_INTERRUPT))
SysTick_Handler();
diff --git a/ports/litex/supervisor/internal_flash.c b/ports/litex/supervisor/internal_flash.c
index cf777a8ac..9b1dea685 100644
--- a/ports/litex/supervisor/internal_flash.c
+++ b/ports/litex/supervisor/internal_flash.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
* Copyright (c) 2019 Lucian Copeland for Adafruit Industries
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
diff --git a/ports/litex/supervisor/internal_flash.h b/ports/litex/supervisor/internal_flash.h
index 41a69e2ab..1498207d3 100644
--- a/ports/litex/supervisor/internal_flash.h
+++ b/ports/litex/supervisor/internal_flash.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
* Copyright (c) 2019 Lucian Copeland for Adafruit Industries
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
diff --git a/ports/mimxrt10xx/Makefile b/ports/mimxrt10xx/Makefile
index 78cab0188..917718810 100644
--- a/ports/mimxrt10xx/Makefile
+++ b/ports/mimxrt10xx/Makefile
@@ -2,8 +2,8 @@
#
# The MIT License (MIT)
#
-# Copyright (c) 2019 Dan Halbert for Adafruit Industries
-# Copyright (c) 2019 Artur Pacholec
+# SPDX-FileCopyrightText: Copyright (c) 2019 Dan Halbert for Adafruit Industries
+# SPDX-FileCopyrightText: Copyright (c) 2019 Artur Pacholec
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
@@ -105,9 +105,14 @@ CFLAGS += \
-DCPU_$(CHIP_VARIANT) \
-DDEBUG \
-DIMXRT10XX \
- -Os -g3 -Wno-unused-parameter \
+ -g3 -Wno-unused-parameter \
-ffunction-sections -fdata-sections -fstack-usage
+OPTIMIZATION_FLAGS ?= -O2
+
+# option to override compiler optimization level, set in boards/$(BOARD)/mpconfigboard.mk
+CFLAGS += $(OPTIMIZATION_FLAGS)
+
LD_FILES = $(wildcard boards/$(BOARD)/*.ld) $(addprefix linking/, flash/$(FLASH).ld chip_family/$(CHIP_FAMILY).ld common.ld)
LD_SCRIPT_FLAG := -Wl,-T,
diff --git a/ports/mimxrt10xx/background.c b/ports/mimxrt10xx/background.c
index ff53ea44f..a8a613d41 100644
--- a/ports/mimxrt10xx/background.c
+++ b/ports/mimxrt10xx/background.c
@@ -24,58 +24,13 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
-#include "background.h"
-//#include "audio_dma.h"
-#include "supervisor/filesystem.h"
-#include "supervisor/shared/tick.h"
-#include "supervisor/usb.h"
-
-#include "py/runtime.h"
-#include "shared-module/network/__init__.h"
-#include "supervisor/linker.h"
-#include "supervisor/shared/stack.h"
-
-#ifdef CIRCUITPY_DISPLAYIO
-#include "shared-module/displayio/__init__.h"
-#endif
-
-volatile uint64_t last_finished_tick = 0;
-
-bool stack_ok_so_far = true;
-
-static bool running_background_tasks = false;
-
-void background_tasks_reset(void) {
- running_background_tasks = false;
-}
-
-void PLACE_IN_ITCM(run_background_tasks)(void) {
- // Don't call ourselves recursively.
- if (running_background_tasks) {
- return;
- }
- assert_heap_ok();
- running_background_tasks = true;
+#include "supervisor/port.h"
+void port_background_task(void) {
#if CIRCUITPY_AUDIOIO || CIRCUITPY_AUDIOBUSIO
audio_dma_background();
#endif
- #if CIRCUITPY_DISPLAYIO
- displayio_background();
- #endif
-
- #if CIRCUITPY_NETWORK
- network_module_background();
- #endif
- filesystem_background();
- usb_background();
- running_background_tasks = false;
- assert_heap_ok();
-
- last_finished_tick = supervisor_ticks_ms64();
-}
-
-bool background_tasks_ok(void) {
- return supervisor_ticks_ms64() - last_finished_tick < 1000;
}
+void port_start_background_task(void) {}
+void port_finish_background_task(void) {}
diff --git a/ports/mimxrt10xx/background.h b/ports/mimxrt10xx/background.h
index 52789d038..a3fe102ac 100644
--- a/ports/mimxrt10xx/background.h
+++ b/ports/mimxrt10xx/background.h
@@ -28,11 +28,4 @@
#ifndef MICROPY_INCLUDED_MIMXRT10XX_BACKGROUND_H
#define MICROPY_INCLUDED_MIMXRT10XX_BACKGROUND_H
-#include <stdbool.h>
-
-void background_tasks_reset(void);
-void run_background_tasks(void);
-void run_background_vm_tasks(void);
-bool background_tasks_ok(void);
-
#endif // MICROPY_INCLUDED_MIMXRT10XX_BACKGROUND_H
diff --git a/ports/mimxrt10xx/common-hal/analogio/AnalogOut.c b/ports/mimxrt10xx/common-hal/analogio/AnalogOut.c
index 3d072627a..6bdbeff7c 100644
--- a/ports/mimxrt10xx/common-hal/analogio/AnalogOut.c
+++ b/ports/mimxrt10xx/common-hal/analogio/AnalogOut.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
* Copyright (c) 2019 Artur Pacholec
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
diff --git a/ports/mimxrt10xx/common-hal/board/__init__.c b/ports/mimxrt10xx/common-hal/board/__init__.c
index e86251480..4967e1a76 100644
--- a/ports/mimxrt10xx/common-hal/board/__init__.c
+++ b/ports/mimxrt10xx/common-hal/board/__init__.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
* Copyright (c) 2019 Artur Pacholec
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
diff --git a/ports/mimxrt10xx/common-hal/busio/SPI.c b/ports/mimxrt10xx/common-hal/busio/SPI.c
index c51aef4da..8fe1b799d 100644
--- a/ports/mimxrt10xx/common-hal/busio/SPI.c
+++ b/ports/mimxrt10xx/common-hal/busio/SPI.c
@@ -321,7 +321,7 @@ bool common_hal_busio_spi_read(busio_spi_obj_t *self,
return (status == kStatus_Success);
}
-bool common_hal_busio_spi_transfer(busio_spi_obj_t *self, uint8_t *data_out, uint8_t *data_in, size_t len) {
+bool common_hal_busio_spi_transfer(busio_spi_obj_t *self, const uint8_t *data_out, uint8_t *data_in, size_t len) {
if (len == 0) {
return true;
}
@@ -332,7 +332,7 @@ bool common_hal_busio_spi_transfer(busio_spi_obj_t *self, uint8_t *data_out, uin
LPSPI_SetDummyData(self->spi, 0xFF);
lpspi_transfer_t xfer = { 0 };
- xfer.txData = data_out;
+ xfer.txData = (uint8_t *)data_out;
xfer.rxData = data_in;
xfer.dataSize = len;
diff --git a/ports/mimxrt10xx/common-hal/busio/UART.c b/ports/mimxrt10xx/common-hal/busio/UART.c
index 5ef347e59..db5582d15 100644
--- a/ports/mimxrt10xx/common-hal/busio/UART.c
+++ b/ports/mimxrt10xx/common-hal/busio/UART.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2016 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2016 Damien P. George
* Copyright (c) 2019 Artur Pacholec
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -85,7 +85,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
const mcu_pin_obj_t * tx, const mcu_pin_obj_t * rx,
const mcu_pin_obj_t * rts, const mcu_pin_obj_t * cts,
const mcu_pin_obj_t * rs485_dir, bool rs485_invert,
- uint32_t baudrate, uint8_t bits, uart_parity_t parity, uint8_t stop,
+ uint32_t baudrate, uint8_t bits, busio_uart_parity_t parity, uint8_t stop,
mp_float_t timeout, uint16_t receiver_buffer_size, byte* receiver_buffer,
bool sigint_enabled) {
@@ -94,7 +94,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
self->timeout_ms = timeout * 1000;
// We are transmitting one direction if one pin is NULL and the other isn't.
- bool is_onedirection = (rx != NULL) != (tx != NULL);
+ bool is_onedirection = (rx == NULL) != (tx == NULL);
bool uart_taken = false;
const uint32_t rx_count = MP_ARRAY_SIZE(mcu_uart_rx_list);
diff --git a/ports/mimxrt10xx/common-hal/pulseio/PWMOut.c b/ports/mimxrt10xx/common-hal/pulseio/PWMOut.c
index c75b75316..50dd477ea 100644
--- a/ports/mimxrt10xx/common-hal/pulseio/PWMOut.c
+++ b/ports/mimxrt10xx/common-hal/pulseio/PWMOut.c
@@ -4,7 +4,7 @@
* The MIT License (MIT)
*
* Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
- * Copyright (c) 2016 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2016 Damien P. George
* Copyright (c) 2019 Artur Pacholec
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
diff --git a/ports/mimxrt10xx/common-hal/pulseio/PulseIn.c b/ports/mimxrt10xx/common-hal/pulseio/PulseIn.c
index d8bf2017e..ec0290861 100644
--- a/ports/mimxrt10xx/common-hal/pulseio/PulseIn.c
+++ b/ports/mimxrt10xx/common-hal/pulseio/PulseIn.c
@@ -64,7 +64,7 @@
// // last ms.
// current_us = 1000 - current_us;
// pulseio_pulsein_obj_t* self = get_eic_channel_data(channel);
-// if (!background_tasks_ok() || self->errored_too_fast) {
+// if (!supervisor_background_tasks_ok() || self->errored_too_fast) {
// self->errored_too_fast = true;
// common_hal_pulseio_pulsein_pause(self);
// return;
diff --git a/ports/mimxrt10xx/common-hal/pulseio/PulseOut.c b/ports/mimxrt10xx/common-hal/pulseio/PulseOut.c
index a49cfa7af..ffa885688 100644
--- a/ports/mimxrt10xx/common-hal/pulseio/PulseOut.c
+++ b/ports/mimxrt10xx/common-hal/pulseio/PulseOut.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2016 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2016 Damien P. George
* Copyright (c) 2019 Artur Pacholec
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
diff --git a/ports/mimxrt10xx/fatfs_port.c b/ports/mimxrt10xx/fatfs_port.c
index c4ce18c2a..c65a73a42 100644
--- a/ports/mimxrt10xx/fatfs_port.c
+++ b/ports/mimxrt10xx/fatfs_port.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/ports/mimxrt10xx/supervisor/internal_flash.c b/ports/mimxrt10xx/supervisor/internal_flash.c
index 9abd15e60..09f44cced 100644
--- a/ports/mimxrt10xx/supervisor/internal_flash.c
+++ b/ports/mimxrt10xx/supervisor/internal_flash.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
* Copyright (c) 2019 Artur Pacholec
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
diff --git a/ports/mimxrt10xx/supervisor/internal_flash.h b/ports/mimxrt10xx/supervisor/internal_flash.h
index dfbfe1d4b..daee66620 100644
--- a/ports/mimxrt10xx/supervisor/internal_flash.h
+++ b/ports/mimxrt10xx/supervisor/internal_flash.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/ports/mimxrt10xx/supervisor/usb.c b/ports/mimxrt10xx/supervisor/usb.c
index 1bc7ea9b5..af259405a 100644
--- a/ports/mimxrt10xx/supervisor/usb.c
+++ b/ports/mimxrt10xx/supervisor/usb.c
@@ -27,6 +27,7 @@
#include "fsl_clock.h"
#include "tusb.h"
+#include "supervisor/usb.h"
void init_usb_hardware(void) {
CLOCK_EnableUsbhs0PhyPllClock(kCLOCK_Usbphy480M, 480000000U);
@@ -56,5 +57,5 @@ void init_usb_hardware(void) {
}
void USB_OTG1_IRQHandler(void) {
- tud_int_handler(0);
+ usb_irq_handler();
}
diff --git a/ports/nrf/Makefile b/ports/nrf/Makefile
index 5b81fa9a7..13a148df3 100755
--- a/ports/nrf/Makefile
+++ b/ports/nrf/Makefile
@@ -2,7 +2,7 @@
#
# The MIT License (MIT)
#
-# Copyright (c) 2019 Dan Halbert for Adafruit Industries
+# SPDX-FileCopyrightText: Copyright (c) 2019 Dan Halbert for Adafruit Industries
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
@@ -86,12 +86,16 @@ INC += -I../../supervisor/shared/usb
#Debugging/Optimization
ifeq ($(DEBUG), 1)
- CFLAGS += -ggdb3 -Og
+ CFLAGS += -ggdb3
+ OPTIMIZATION_FLAGS = -Og
else
- CFLAGS += -Os -DNDEBUG -ggdb3
+ OPTIMIZATION_FLAGS ?= -O2
+ CFLAGS += -DNDEBUG -ggdb3
CFLAGS += -flto -flto-partition=none
endif
+# option to override compiler optimization level, set in boards/$(BOARD)/mpconfigboard.mk
+CFLAGS += $(OPTIMIZATION_FLAGS)
CFLAGS += $(INC) -Wall -Werror -std=gnu11 -nostdlib -fshort-enums $(BASE_CFLAGS) $(CFLAGS_MOD) $(COPT)
diff --git a/ports/nrf/background.c b/ports/nrf/background.c
index 966c56e0b..10543ddb2 100644
--- a/ports/nrf/background.c
+++ b/ports/nrf/background.c
@@ -46,36 +46,14 @@
#include "common-hal/_bleio/bonding.h"
#endif
-static bool running_background_tasks = false;
+void port_start_background_task(void) {}
+void port_finish_background_task(void) {}
-void background_tasks_reset(void) {
- running_background_tasks = false;
-}
-
-void run_background_tasks(void) {
- // Don't call ourselves recursively.
- if (running_background_tasks) {
- return;
- }
- running_background_tasks = true;
- filesystem_background();
- usb_background();
+void port_background_task(void) {
#if CIRCUITPY_AUDIOPWMIO
audiopwmout_background();
#endif
#if CIRCUITPY_AUDIOBUSIO
i2s_background();
#endif
-
-#if CIRCUITPY_BLEIO
- supervisor_bluetooth_background();
- bonding_background();
-#endif
-
- #if CIRCUITPY_DISPLAYIO
- displayio_background();
- #endif
- running_background_tasks = false;
-
- assert_heap_ok();
}
diff --git a/ports/nrf/background.h b/ports/nrf/background.h
index d53681c0f..64a768cf9 100644
--- a/ports/nrf/background.h
+++ b/ports/nrf/background.h
@@ -27,9 +27,4 @@
#ifndef MICROPY_INCLUDED_NRF_BACKGROUND_H
#define MICROPY_INCLUDED_NRF_BACKGROUND_H
-#include <stdbool.h>
-
-void background_tasks_reset(void);
-void run_background_tasks(void);
-
#endif // MICROPY_INCLUDED_NRF_BACKGROUND_H
diff --git a/ports/nrf/boards/bless_dev_board_multi_sensor/board.c b/ports/nrf/boards/bless_dev_board_multi_sensor/board.c
new file mode 100644
index 000000000..71b9a0657
--- /dev/null
+++ b/ports/nrf/boards/bless_dev_board_multi_sensor/board.c
@@ -0,0 +1,12 @@
+#include "boards/board.h"
+
+void board_init(void) {
+}
+
+bool board_requests_safe_mode(void) {
+ return false;
+}
+
+void reset_board(void) {
+
+}
diff --git a/ports/nrf/boards/bless_dev_board_multi_sensor/mpconfigboard.h b/ports/nrf/boards/bless_dev_board_multi_sensor/mpconfigboard.h
new file mode 100644
index 000000000..7fffd86cc
--- /dev/null
+++ b/ports/nrf/boards/bless_dev_board_multi_sensor/mpconfigboard.h
@@ -0,0 +1,17 @@
+#include "nrfx/hal/nrf_gpio.h"
+
+#define MICROPY_HW_BOARD_NAME "BLE-SS dev board Multi Sensor"
+#define MICROPY_HW_MCU_NAME "nRF52840"
+#define MICROPY_HW_LED_STATUS (&pin_P0_07)
+
+#define DEFAULT_I2C_BUS_SCL (&pin_P0_26)
+#define DEFAULT_I2C_BUS_SDA (&pin_P0_24)
+
+#define DEFAULT_SPI_BUS_SCK (&pin_P0_13) /* n.c */
+#define DEFAULT_SPI_BUS_MOSI (&pin_P0_14) /* n.c */
+#define DEFAULT_SPI_BUS_MISO (&pin_P0_15) /* n.c */
+
+#define DEFAULT_UART_BUS_RX (&pin_P0_02) /* TP7 */
+#define DEFAULT_UART_BUS_TX (&pin_P0_03) /* TP6 */
+
+/* Note: Flash chip is not provided. */
diff --git a/ports/nrf/boards/bless_dev_board_multi_sensor/mpconfigboard.mk b/ports/nrf/boards/bless_dev_board_multi_sensor/mpconfigboard.mk
new file mode 100644
index 000000000..90b090850
--- /dev/null
+++ b/ports/nrf/boards/bless_dev_board_multi_sensor/mpconfigboard.mk
@@ -0,0 +1,8 @@
+USB_VID = 0x2786
+USB_PID = 0x9207
+USB_PRODUCT = "BLE-SS dev board Multi Sensor"
+USB_MANUFACTURER = "Switch Science, Inc."
+
+MCU_CHIP = nrf52840
+
+INTERNAL_FLASH_FILESYSTEM = 1
diff --git a/ports/nrf/boards/bless_dev_board_multi_sensor/pins.c b/ports/nrf/boards/bless_dev_board_multi_sensor/pins.c
new file mode 100644
index 000000000..c6010a8c3
--- /dev/null
+++ b/ports/nrf/boards/bless_dev_board_multi_sensor/pins.c
@@ -0,0 +1,45 @@
+#include "shared-bindings/board/__init__.h"
+
+STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
+ { MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_P0_02) }, // TP7
+ { MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_P0_03) }, // TP6
+ { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_P0_04) }, // LED1
+ { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_P0_05) }, // U2-BMX055-INT1
+ { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_P0_06) }, // U2-BMX055-DRDYM
+ { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_P0_07) }, // LED2
+ { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_P0_08) }, // U4-HDC2010-DRDY/INT
+ { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_P0_09) }, // TP1
+ { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_P0_10) }, // U3-LPS22HB-INT_DRDY
+ { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_P0_12) }, // S2
+ { MP_ROM_QSTR(MP_QSTR_D23), MP_ROM_PTR(&pin_P0_23) }, // BZ1
+ { MP_ROM_QSTR(MP_QSTR_D28), MP_ROM_PTR(&pin_P0_28) }, // U2-BMX055-INT4
+ { MP_ROM_QSTR(MP_QSTR_D29), MP_ROM_PTR(&pin_P0_29) }, // U2-BMX055-INT3
+ { MP_ROM_QSTR(MP_QSTR_D30), MP_ROM_PTR(&pin_P0_30) }, // U2-BMX055-INT5
+ { MP_ROM_QSTR(MP_QSTR_D31), MP_ROM_PTR(&pin_P0_31) }, // S1
+
+ { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_P0_02) }, // A0/TP7
+ { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_P0_03) }, // A1/TP6
+
+ { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_P0_24) }, // 24 - SDA
+ { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_P0_26) }, // 26 - SCL
+
+ { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_P0_13) }, // 13 - MISO (n.c)
+ { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_P0_14) }, // 14 - MOSI (n.c)
+ { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_P0_15) }, // 15 - SCK (n.c)
+
+ { MP_ROM_QSTR(MP_QSTR_LED1), MP_ROM_PTR(&pin_P0_07) }, // 4 - LED1
+ { MP_ROM_QSTR(MP_QSTR_LED2), MP_ROM_PTR(&pin_P0_04) }, // 7 - LED2
+
+ { MP_ROM_QSTR(MP_QSTR_BUTTON1), MP_ROM_PTR(&pin_P0_31) }, // 31 - S1
+ { MP_ROM_QSTR(MP_QSTR_BUTTON2), MP_ROM_PTR(&pin_P0_12) }, // 12 - S2
+
+ { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_P0_02) }, // 2 - UART RX
+ { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_P0_03) }, // 3 - UART TX
+
+ { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) },
+ { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) },
+ { MP_ROM_QSTR(MP_QSTR_QWIIC), MP_ROM_PTR(&board_i2c_obj) },
+ { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
+};
+
+MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);
diff --git a/ports/nrf/boards/ikigaisense_vita/board.c b/ports/nrf/boards/ikigaisense_vita/board.c
new file mode 100644
index 000000000..4421970ee
--- /dev/null
+++ b/ports/nrf/boards/ikigaisense_vita/board.c
@@ -0,0 +1,38 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include "boards/board.h"
+
+void board_init(void) {
+}
+
+bool board_requests_safe_mode(void) {
+ return false;
+}
+
+void reset_board(void) {
+
+}
diff --git a/ports/nrf/boards/ikigaisense_vita/mpconfigboard.h b/ports/nrf/boards/ikigaisense_vita/mpconfigboard.h
new file mode 100644
index 000000000..14798aeee
--- /dev/null
+++ b/ports/nrf/boards/ikigaisense_vita/mpconfigboard.h
@@ -0,0 +1,20 @@
+#include "nrfx/hal/nrf_gpio.h"
+
+#define MICROPY_HW_BOARD_NAME "IkigaiSense Vita nRF52840"
+#define MICROPY_HW_MCU_NAME "nRF52840"
+
+#define MICROPY_HW_LED_STATUS (&pin_P0_27)
+
+#define CIRCUITPY_AUTORELOAD_DELAY_MS 500
+
+#define CIRCUITPY_INTERNAL_NVM_SIZE (4096)
+
+#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE)
+
+#define BOARD_HAS_CRYSTAL 1
+
+#define DEFAULT_I2C_BUS_SCL (&pin_P0_08)
+#define DEFAULT_I2C_BUS_SDA (&pin_P0_04)
+
+#define DEFAULT_UART_BUS_RX (&pin_P0_24)
+#define DEFAULT_UART_BUS_TX (&pin_P0_22)
diff --git a/ports/nrf/boards/ikigaisense_vita/mpconfigboard.mk b/ports/nrf/boards/ikigaisense_vita/mpconfigboard.mk
new file mode 100644
index 000000000..28bdee952
--- /dev/null
+++ b/ports/nrf/boards/ikigaisense_vita/mpconfigboard.mk
@@ -0,0 +1,8 @@
+USB_VID = 0x239A
+USB_PID = 0x8094
+USB_PRODUCT = "IkigaiSense Vita nRF52840"
+USB_MANUFACTURER = "IkigaiSense Technologies LTD"
+
+MCU_CHIP = nrf52840
+
+INTERNAL_FLASH_FILESYSTEM = 1
diff --git a/ports/nrf/boards/ikigaisense_vita/pins.c b/ports/nrf/boards/ikigaisense_vita/pins.c
new file mode 100644
index 000000000..021f94f30
--- /dev/null
+++ b/ports/nrf/boards/ikigaisense_vita/pins.c
@@ -0,0 +1,36 @@
+#include "shared-bindings/board/__init__.h"
+
+STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
+ { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_P0_29) },
+ { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_P1_15) },
+ { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_P1_13) },
+
+ { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_P0_24) },
+ { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_P0_22) },
+ { MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_P0_20) },
+ { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_P0_17) },
+ { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_P0_15) },
+ { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_P0_13) },
+ { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_P0_24) },
+ { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_P0_22) },
+
+ { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_P0_08) },
+ { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_P0_04) },
+
+ { MP_ROM_QSTR(MP_QSTR_MAXTEMP_SCL), MP_ROM_PTR(&pin_P0_31) },
+ { MP_ROM_QSTR(MP_QSTR_MAXTEMP_SDA), MP_ROM_PTR(&pin_P0_30) },
+
+ { MP_ROM_QSTR(MP_QSTR_ACC_SCL), MP_ROM_PTR(&pin_P1_11) },
+ { MP_ROM_QSTR(MP_QSTR_ACC_SDA), MP_ROM_PTR(&pin_P1_10) },
+
+ { MP_ROM_QSTR(MP_QSTR_ADDON_SCL), MP_ROM_PTR(&pin_P1_09) },
+ { MP_ROM_QSTR(MP_QSTR_ADDON_SDA), MP_ROM_PTR(&pin_P0_06) },
+
+ { MP_ROM_QSTR(MP_QSTR_L), MP_ROM_PTR(&pin_P0_27) },
+ { MP_ROM_QSTR(MP_QSTR_YELLOW_LED), MP_ROM_PTR(&pin_P0_27) },
+
+ { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) },
+ { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
+};
+
+MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);
diff --git a/ports/nrf/boards/makerdiary_m60_keyboard/README.md b/ports/nrf/boards/makerdiary_m60_keyboard/README.md
new file mode 100644
index 000000000..04486ba21
--- /dev/null
+++ b/ports/nrf/boards/makerdiary_m60_keyboard/README.md
@@ -0,0 +1,4 @@
+# Makerdiary M60 Keyboard
+
+M60 is a USB & BLE, modular, hot-swappable, 60% keyboard powered by Python.
+Refer to https://makerdiary.com/m60 for more details.
diff --git a/ports/nrf/boards/makerdiary_m60_keyboard/board.c b/ports/nrf/boards/makerdiary_m60_keyboard/board.c
new file mode 100644
index 000000000..4421970ee
--- /dev/null
+++ b/ports/nrf/boards/makerdiary_m60_keyboard/board.c
@@ -0,0 +1,38 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include "boards/board.h"
+
+void board_init(void) {
+}
+
+bool board_requests_safe_mode(void) {
+ return false;
+}
+
+void reset_board(void) {
+
+}
diff --git a/ports/nrf/boards/makerdiary_m60_keyboard/mpconfigboard.h b/ports/nrf/boards/makerdiary_m60_keyboard/mpconfigboard.h
new file mode 100644
index 000000000..086718089
--- /dev/null
+++ b/ports/nrf/boards/makerdiary_m60_keyboard/mpconfigboard.h
@@ -0,0 +1,50 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2016 Glenn Ruben Bakke
+ * Copyright (c) 2018 Dan Halbert for Adafruit Industries
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include "nrfx/hal/nrf_gpio.h"
+
+#define MICROPY_HW_BOARD_NAME "Makerdiary M60 Keyboard"
+#define MICROPY_HW_MCU_NAME "nRF52840"
+
+#define CP_RGB_STATUS_R (&pin_P0_30)
+#define CP_RGB_STATUS_G (&pin_P0_29)
+#define CP_RGB_STATUS_B (&pin_P0_31)
+
+#define MICROPY_QSPI_DATA0 NRF_GPIO_PIN_MAP(1, 10)
+#define MICROPY_QSPI_DATA1 NRF_GPIO_PIN_MAP(1, 14)
+#define MICROPY_QSPI_DATA2 NRF_GPIO_PIN_MAP(1, 15)
+#define MICROPY_QSPI_DATA3 NRF_GPIO_PIN_MAP(1, 12)
+#define MICROPY_QSPI_SCK NRF_GPIO_PIN_MAP(1, 11)
+#define MICROPY_QSPI_CS NRF_GPIO_PIN_MAP(1, 13)
+
+#define BOARD_HAS_CRYSTAL 1
+
+// #define DEFAULT_UART_BUS_RX (&pin_P0_15)
+// #define DEFAULT_UART_BUS_TX (&pin_P0_16)
+
+#define DEFAULT_I2C_BUS_SCL (&pin_P1_06)
+#define DEFAULT_I2C_BUS_SDA (&pin_P1_05)
diff --git a/ports/nrf/boards/makerdiary_m60_keyboard/mpconfigboard.mk b/ports/nrf/boards/makerdiary_m60_keyboard/mpconfigboard.mk
new file mode 100644
index 000000000..fc630e5bb
--- /dev/null
+++ b/ports/nrf/boards/makerdiary_m60_keyboard/mpconfigboard.mk
@@ -0,0 +1,12 @@
+USB_VID = 0x2886
+USB_PID = 0xf002
+USB_PRODUCT = "M60 Keyboard"
+USB_MANUFACTURER = "Makerdiary"
+
+MCU_CHIP = nrf52840
+
+QSPI_FLASH_FILESYSTEM = 1
+EXTERNAL_FLASH_DEVICE_COUNT = 1
+EXTERNAL_FLASH_DEVICES = "MX25R6435F"
+
+CIRCUITPY_ENABLE_MPY_NATIVE = 1
diff --git a/ports/nrf/boards/makerdiary_m60_keyboard/pins.c b/ports/nrf/boards/makerdiary_m60_keyboard/pins.c
new file mode 100644
index 000000000..63c3ad171
--- /dev/null
+++ b/ports/nrf/boards/makerdiary_m60_keyboard/pins.c
@@ -0,0 +1,41 @@
+#include "shared-bindings/board/__init__.h"
+
+#include "boards/board.h"
+#include "shared-module/displayio/__init__.h"
+
+STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
+ { MP_ROM_QSTR(MP_QSTR_R1), MP_ROM_PTR(&pin_P0_05) },
+ { MP_ROM_QSTR(MP_QSTR_R2), MP_ROM_PTR(&pin_P0_06) },
+ { MP_ROM_QSTR(MP_QSTR_R3), MP_ROM_PTR(&pin_P0_07) },
+ { MP_ROM_QSTR(MP_QSTR_R4), MP_ROM_PTR(&pin_P0_08) },
+ { MP_ROM_QSTR(MP_QSTR_R5), MP_ROM_PTR(&pin_P1_09) },
+ { MP_ROM_QSTR(MP_QSTR_R6), MP_ROM_PTR(&pin_P1_08) },
+ { MP_ROM_QSTR(MP_QSTR_R7), MP_ROM_PTR(&pin_P0_12) },
+ { MP_ROM_QSTR(MP_QSTR_R8), MP_ROM_PTR(&pin_P0_11) },
+
+ { MP_ROM_QSTR(MP_QSTR_C1), MP_ROM_PTR(&pin_P0_19) },
+ { MP_ROM_QSTR(MP_QSTR_C2), MP_ROM_PTR(&pin_P0_20) },
+ { MP_ROM_QSTR(MP_QSTR_C3), MP_ROM_PTR(&pin_P0_21) },
+ { MP_ROM_QSTR(MP_QSTR_C4), MP_ROM_PTR(&pin_P0_22) },
+ { MP_ROM_QSTR(MP_QSTR_C5), MP_ROM_PTR(&pin_P0_23) },
+ { MP_ROM_QSTR(MP_QSTR_C6), MP_ROM_PTR(&pin_P0_24) },
+ { MP_ROM_QSTR(MP_QSTR_C7), MP_ROM_PTR(&pin_P0_25) },
+ { MP_ROM_QSTR(MP_QSTR_C8), MP_ROM_PTR(&pin_P0_26) },
+
+ { MP_ROM_QSTR(MP_QSTR_TXD), MP_ROM_PTR(&pin_P0_16) },
+ { MP_ROM_QSTR(MP_QSTR_RXD), MP_ROM_PTR(&pin_P0_15) },
+
+ { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_P1_06) },
+ { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_P1_05) },
+
+ { MP_ROM_QSTR(MP_QSTR_LED_R), MP_ROM_PTR(&pin_P0_30) },
+ { MP_ROM_QSTR(MP_QSTR_LED_G), MP_ROM_PTR(&pin_P0_29) },
+ { MP_ROM_QSTR(MP_QSTR_LED_B), MP_ROM_PTR(&pin_P0_31) },
+
+ { MP_ROM_QSTR(MP_QSTR_BTN), MP_ROM_PTR(&pin_P0_27) },
+
+// { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) },
+ { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }
+};
+
+MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);
diff --git a/ports/nrf/boards/makerdiary_nrf52840_m2_devkit/README.md b/ports/nrf/boards/makerdiary_nrf52840_m2_devkit/README.md
new file mode 100644
index 000000000..b75385414
--- /dev/null
+++ b/ports/nrf/boards/makerdiary_nrf52840_m2_devkit/README.md
@@ -0,0 +1,8 @@
+# Makerdiary nRF52840 M.2 Developer Kit
+
+The devkit is a versatile IoT prototyping platform,
+including the nRF52840 M.2 Module and M.2 Dock. You can use the developer kit
+to prototype your IoT products and then scale to production faster using the
+nRF52840 M.2 Module combined with your custom PCB hardware.
+
+Refer to https://github.com/makerdiary/nrf52840-m2-devkit for more details.
diff --git a/ports/nrf/boards/makerdiary_nrf52840_m2_devkit/board.c b/ports/nrf/boards/makerdiary_nrf52840_m2_devkit/board.c
new file mode 100644
index 000000000..e7f946f4d
--- /dev/null
+++ b/ports/nrf/boards/makerdiary_nrf52840_m2_devkit/board.c
@@ -0,0 +1,103 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
+ * Copyright (c) 2020 Yihui Xiong for Makerdiary
+ *
+ * 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 "boards/board.h"
+#include "mpconfigboard.h"
+
+#include "shared-bindings/busio/SPI.h"
+#include "shared-bindings/displayio/FourWire.h"
+#include "shared-module/displayio/__init__.h"
+#include "shared-module/displayio/mipi_constants.h"
+
+displayio_fourwire_obj_t board_display_obj;
+
+#define DELAY 0x80
+
+uint8_t display_init_sequence[] = {
+ 0x01, 0 | DELAY, 150, // SWRESET
+ 0x11, 0 | DELAY, 255, // SLPOUT
+ 0x36, 1, 0b10100000, // _MADCTL for rotation 0
+ 0x3a, 1, 0x55, // COLMOD - 16bit color
+ 0x21, 0 | DELAY, 10, // _INVON
+ 0x13, 0 | DELAY, 10, // _NORON
+ 0x29, 0 | DELAY, 255, // _DISPON
+};
+
+void board_init(void) {
+ busio_spi_obj_t* spi = &displays[0].fourwire_bus.inline_bus;
+ common_hal_busio_spi_construct(spi, &pin_P0_11, &pin_P0_12, NULL);
+ common_hal_busio_spi_never_reset(spi);
+
+ displayio_fourwire_obj_t* bus = &displays[0].fourwire_bus;
+ bus->base.type = &displayio_fourwire_type;
+ common_hal_displayio_fourwire_construct(bus,
+ spi,
+ &pin_P0_08, // TFT_DC Command or data
+ &pin_P0_06, // TFT_CS Chip select
+ &pin_P1_09, // TFT_RST Reset
+ 60000000, // Baudrate
+ 0, // Polarity
+ 0); // Phase
+
+ displayio_display_obj_t* display = &displays[0].display;
+ display->base.type = &displayio_display_type;
+ common_hal_displayio_display_construct(display,
+ bus,
+ 240, // Width (after rotation)
+ 240, // Height (after rotation)
+ 80, // column start
+ 0, // row start
+ 0, // rotation
+ 16, // Color depth
+ false, // Grayscale
+ false, // Pixels in a byte share a row. Only used for depth < 8
+ 1, // bytes per cell. Only valid for depths < 8
+ false, // reverse_pixels_in_byte. Only valid for depths < 8
+ true, // reverse_pixels_in_word
+ MIPI_COMMAND_SET_COLUMN_ADDRESS, // Set column command
+ MIPI_COMMAND_SET_PAGE_ADDRESS, // Set row command
+ MIPI_COMMAND_WRITE_MEMORY_START, // Write memory command
+ 37, // set vertical scroll command
+ display_init_sequence,
+ sizeof(display_init_sequence),
+ &pin_P0_20, // backlight pin
+ NO_BRIGHTNESS_COMMAND,
+ 1.0f, // brightness (ignored)
+ true, // auto_brightness
+ false, // single_byte_bounds
+ false, // data_as_commands
+ true, // auto_refresh
+ 60, // native_frames_per_second
+ true); // backlight_on_high
+}
+
+bool board_requests_safe_mode(void) {
+ return false;
+}
+
+void reset_board(void) {
+}
diff --git a/ports/nrf/boards/makerdiary_nrf52840_m2_devkit/mpconfigboard.h b/ports/nrf/boards/makerdiary_nrf52840_m2_devkit/mpconfigboard.h
new file mode 100644
index 000000000..dab2ff042
--- /dev/null
+++ b/ports/nrf/boards/makerdiary_nrf52840_m2_devkit/mpconfigboard.h
@@ -0,0 +1,57 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2016 Glenn Ruben Bakke
+ * Copyright (c) 2018 Dan Halbert for Adafruit Industries
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include "nrfx/hal/nrf_gpio.h"
+
+#define MICROPY_HW_BOARD_NAME "Makerdiary nRF52840 M.2 Developer Kit"
+#define MICROPY_HW_MCU_NAME "nRF52840"
+
+#define MICROPY_HW_LED_STATUS (&pin_P1_07)
+
+#define CP_RGB_STATUS_INVERTED_PWM
+#define CP_RGB_STATUS_R (&pin_P0_30)
+#define CP_RGB_STATUS_G (&pin_P0_29)
+#define CP_RGB_STATUS_B (&pin_P0_31)
+
+#define MICROPY_QSPI_DATA0 NRF_GPIO_PIN_MAP(1, 10)
+#define MICROPY_QSPI_DATA1 NRF_GPIO_PIN_MAP(1, 14)
+#define MICROPY_QSPI_DATA2 NRF_GPIO_PIN_MAP(1, 15)
+#define MICROPY_QSPI_DATA3 NRF_GPIO_PIN_MAP(1, 12)
+#define MICROPY_QSPI_SCK NRF_GPIO_PIN_MAP(1, 11)
+#define MICROPY_QSPI_CS NRF_GPIO_PIN_MAP(1, 13)
+
+#define BOARD_HAS_CRYSTAL 1
+
+#define DEFAULT_UART_BUS_RX (&pin_P0_15)
+#define DEFAULT_UART_BUS_TX (&pin_P0_16)
+
+#define DEFAULT_I2C_BUS_SCL (&pin_P1_06)
+#define DEFAULT_I2C_BUS_SDA (&pin_P1_05)
+
+#define DEFAULT_SPI_BUS_SCK (&pin_P0_11)
+#define DEFAULT_SPI_BUS_MOSI (&pin_P0_12)
+#define DEFAULT_SPI_BUS_MISO (&pin_P1_08)
diff --git a/ports/nrf/boards/makerdiary_nrf52840_m2_devkit/mpconfigboard.mk b/ports/nrf/boards/makerdiary_nrf52840_m2_devkit/mpconfigboard.mk
new file mode 100644
index 000000000..4e6aebc8e
--- /dev/null
+++ b/ports/nrf/boards/makerdiary_nrf52840_m2_devkit/mpconfigboard.mk
@@ -0,0 +1,12 @@
+USB_VID = 0x2886
+USB_PID = 0xf001
+USB_PRODUCT = "nRF52840 M.2 Developer Kit"
+USB_MANUFACTURER = "Makerdiary"
+
+MCU_CHIP = nrf52840
+
+QSPI_FLASH_FILESYSTEM = 1
+EXTERNAL_FLASH_DEVICE_COUNT = 1
+EXTERNAL_FLASH_DEVICES = "MX25R6435F"
+
+CIRCUITPY_ENABLE_MPY_NATIVE = 1
diff --git a/ports/nrf/boards/makerdiary_nrf52840_m2_devkit/pins.c b/ports/nrf/boards/makerdiary_nrf52840_m2_devkit/pins.c
new file mode 100644
index 000000000..cb3bda35a
--- /dev/null
+++ b/ports/nrf/boards/makerdiary_nrf52840_m2_devkit/pins.c
@@ -0,0 +1,110 @@
+#include "shared-bindings/board/__init__.h"
+
+#include "boards/board.h"
+#include "shared-module/displayio/__init__.h"
+
+STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
+ { MP_ROM_QSTR(MP_QSTR_AIN0), MP_ROM_PTR(&pin_P0_02) },
+ { MP_ROM_QSTR(MP_QSTR_AIN1), MP_ROM_PTR(&pin_P0_03) },
+ { MP_ROM_QSTR(MP_QSTR_AIN2), MP_ROM_PTR(&pin_P0_04) },
+ { MP_ROM_QSTR(MP_QSTR_AIN3), MP_ROM_PTR(&pin_P0_05) },
+ { MP_ROM_QSTR(MP_QSTR_AIN4), MP_ROM_PTR(&pin_P0_28) },
+ { MP_ROM_QSTR(MP_QSTR_AIN5), MP_ROM_PTR(&pin_P0_29) },
+ { MP_ROM_QSTR(MP_QSTR_AIN6), MP_ROM_PTR(&pin_P0_30) },
+ { MP_ROM_QSTR(MP_QSTR_AIN7), MP_ROM_PTR(&pin_P0_31) },
+
+ { MP_ROM_QSTR(MP_QSTR_AREF), MP_ROM_PTR(&pin_P0_04) },
+ { MP_ROM_QSTR(MP_QSTR_VDIV), MP_ROM_PTR(&pin_P0_05) },
+
+ { MP_ROM_QSTR(MP_QSTR_NFC1), MP_ROM_PTR(&pin_P0_09) },
+ { MP_ROM_QSTR(MP_QSTR_NFC2), MP_ROM_PTR(&pin_P0_10) },
+
+ { MP_ROM_QSTR(MP_QSTR_P2), MP_ROM_PTR(&pin_P0_02) },
+ { MP_ROM_QSTR(MP_QSTR_P3), MP_ROM_PTR(&pin_P0_03) },
+ { MP_ROM_QSTR(MP_QSTR_P4), MP_ROM_PTR(&pin_P0_04) },
+ { MP_ROM_QSTR(MP_QSTR_P5), MP_ROM_PTR(&pin_P0_05) },
+ { MP_ROM_QSTR(MP_QSTR_P6), MP_ROM_PTR(&pin_P0_06) },
+ { MP_ROM_QSTR(MP_QSTR_P7), MP_ROM_PTR(&pin_P0_07) },
+ { MP_ROM_QSTR(MP_QSTR_P8), MP_ROM_PTR(&pin_P0_08) },
+ { MP_ROM_QSTR(MP_QSTR_P9), MP_ROM_PTR(&pin_P0_09) },
+ { MP_ROM_QSTR(MP_QSTR_P10), MP_ROM_PTR(&pin_P0_10) },
+ { MP_ROM_QSTR(MP_QSTR_P11), MP_ROM_PTR(&pin_P0_11) },
+ { MP_ROM_QSTR(MP_QSTR_P12), MP_ROM_PTR(&pin_P0_12) },
+ { MP_ROM_QSTR(MP_QSTR_P13), MP_ROM_PTR(&pin_P0_13) },
+ { MP_ROM_QSTR(MP_QSTR_P14), MP_ROM_PTR(&pin_P0_14) },
+ { MP_ROM_QSTR(MP_QSTR_P15), MP_ROM_PTR(&pin_P0_15) },
+ { MP_ROM_QSTR(MP_QSTR_P16), MP_ROM_PTR(&pin_P0_16) },
+ { MP_ROM_QSTR(MP_QSTR_P17), MP_ROM_PTR(&pin_P0_17) },
+ { MP_ROM_QSTR(MP_QSTR_P18), MP_ROM_PTR(&pin_P0_18) },
+ { MP_ROM_QSTR(MP_QSTR_P19), MP_ROM_PTR(&pin_P0_19) },
+ { MP_ROM_QSTR(MP_QSTR_P20), MP_ROM_PTR(&pin_P0_20) },
+ { MP_ROM_QSTR(MP_QSTR_P21), MP_ROM_PTR(&pin_P0_21) },
+ { MP_ROM_QSTR(MP_QSTR_P25), MP_ROM_PTR(&pin_P0_25) },
+ { MP_ROM_QSTR(MP_QSTR_P26), MP_ROM_PTR(&pin_P0_26) },
+ { MP_ROM_QSTR(MP_QSTR_P27), MP_ROM_PTR(&pin_P0_27) },
+ { MP_ROM_QSTR(MP_QSTR_P28), MP_ROM_PTR(&pin_P0_28) },
+ { MP_ROM_QSTR(MP_QSTR_P29), MP_ROM_PTR(&pin_P0_29) },
+ { MP_ROM_QSTR(MP_QSTR_P30), MP_ROM_PTR(&pin_P0_30) },
+ { MP_ROM_QSTR(MP_QSTR_P31), MP_ROM_PTR(&pin_P0_31) },
+
+ { MP_ROM_QSTR(MP_QSTR_P1_0), MP_ROM_PTR(&pin_P1_00) },
+ { MP_ROM_QSTR(MP_QSTR_P1_1), MP_ROM_PTR(&pin_P1_01) },
+ { MP_ROM_QSTR(MP_QSTR_P1_2), MP_ROM_PTR(&pin_P1_02) },
+ { MP_ROM_QSTR(MP_QSTR_P1_3), MP_ROM_PTR(&pin_P1_03) },
+ { MP_ROM_QSTR(MP_QSTR_P1_4), MP_ROM_PTR(&pin_P1_04) },
+ { MP_ROM_QSTR(MP_QSTR_P1_5), MP_ROM_PTR(&pin_P1_05) },
+ { MP_ROM_QSTR(MP_QSTR_P1_6), MP_ROM_PTR(&pin_P1_06) },
+ { MP_ROM_QSTR(MP_QSTR_P1_7), MP_ROM_PTR(&pin_P1_07) },
+ { MP_ROM_QSTR(MP_QSTR_P1_8), MP_ROM_PTR(&pin_P1_08) },
+ { MP_ROM_QSTR(MP_QSTR_P1_9), MP_ROM_PTR(&pin_P1_09) },
+
+ { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_P0_15) },
+ { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_P0_16) },
+ { MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_P0_19) },
+ { MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_P0_20) },
+ { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_P0_21) },
+ { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_P0_22) },
+ { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_P0_23) },
+ { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_P0_24) },
+ { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_P1_00) },
+ { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_P1_01) },
+ { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_P1_02) },
+ { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_P1_03) },
+ { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_P1_04) },
+ { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_P1_07) },
+ { MP_ROM_QSTR(MP_QSTR_D14), MP_ROM_PTR(&pin_P1_05) },
+ { MP_ROM_QSTR(MP_QSTR_D15), MP_ROM_PTR(&pin_P1_06) },
+
+ { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_P0_02) },
+ { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_P0_03) },
+ { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_P0_28) },
+ { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_P0_27) },
+ { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_P0_26) },
+ { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_P0_04) },
+
+ { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_P0_11) },
+ { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_P0_12) },
+ { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_P1_08) },
+
+ { MP_ROM_QSTR(MP_QSTR_LCD_DC), MP_ROM_PTR(&pin_P0_08) },
+ { MP_ROM_QSTR(MP_QSTR_LCD_CS), MP_ROM_PTR(&pin_P0_06) },
+ { MP_ROM_QSTR(MP_QSTR_LCD_BL), MP_ROM_PTR(&pin_P0_20) },
+ { MP_ROM_QSTR(MP_QSTR_LCD_RST), MP_ROM_PTR(&pin_P1_09) },
+
+ { MP_ROM_QSTR(MP_QSTR_TXD), MP_ROM_PTR(&pin_P0_16) },
+ { MP_ROM_QSTR(MP_QSTR_RXD), MP_ROM_PTR(&pin_P0_15) },
+
+ { MP_ROM_QSTR(MP_QSTR_LED_R), MP_ROM_PTR(&pin_P0_30) },
+ { MP_ROM_QSTR(MP_QSTR_LED_G), MP_ROM_PTR(&pin_P0_29) },
+ { MP_ROM_QSTR(MP_QSTR_LED_B), MP_ROM_PTR(&pin_P0_31) },
+
+ { MP_ROM_QSTR(MP_QSTR_USR_BTN), MP_ROM_PTR(&pin_P0_19) },
+
+ { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) },
+ { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) },
+ { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
+
+ { MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display)}
+};
+
+MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);
diff --git a/ports/nrf/boards/particle_argon/mpconfigboard.mk b/ports/nrf/boards/particle_argon/mpconfigboard.mk
index 2ca08b982..f8d3d2aca 100644
--- a/ports/nrf/boards/particle_argon/mpconfigboard.mk
+++ b/ports/nrf/boards/particle_argon/mpconfigboard.mk
@@ -8,7 +8,3 @@ MCU_CHIP = nrf52840
QSPI_FLASH_FILESYSTEM = 1
EXTERNAL_FLASH_DEVICE_COUNT = 1
EXTERNAL_FLASH_DEVICES = "MX25L3233F"
-
-# Support for the Ethernet FeatherWing
-CIRCUITPY_NETWORK = 1
-MICROPY_PY_WIZNET5K = 5500
diff --git a/ports/nrf/boards/particle_boron/mpconfigboard.mk b/ports/nrf/boards/particle_boron/mpconfigboard.mk
index f03f43a7b..eada97a73 100644
--- a/ports/nrf/boards/particle_boron/mpconfigboard.mk
+++ b/ports/nrf/boards/particle_boron/mpconfigboard.mk
@@ -8,7 +8,3 @@ MCU_CHIP = nrf52840
QSPI_FLASH_FILESYSTEM = 1
EXTERNAL_FLASH_DEVICE_COUNT = 1
EXTERNAL_FLASH_DEVICES = "MX25L3233F"
-
-# Support for the Ethernet FeatherWing
-CIRCUITPY_NETWORK = 1
-MICROPY_PY_WIZNET5K = 5500
diff --git a/ports/nrf/boards/particle_xenon/mpconfigboard.mk b/ports/nrf/boards/particle_xenon/mpconfigboard.mk
index 44309bbca..6062da378 100644
--- a/ports/nrf/boards/particle_xenon/mpconfigboard.mk
+++ b/ports/nrf/boards/particle_xenon/mpconfigboard.mk
@@ -8,7 +8,3 @@ MCU_CHIP = nrf52840
QSPI_FLASH_FILESYSTEM = 1
EXTERNAL_FLASH_DEVICE_COUNT = 1
EXTERNAL_FLASH_DEVICES = "MX25L3233F"
-
-# Support for the Ethernet FeatherWing
-CIRCUITPY_NETWORK = 1
-MICROPY_PY_WIZNET5K = 5500
diff --git a/ports/nrf/boards/pca10100/mpconfigboard.mk b/ports/nrf/boards/pca10100/mpconfigboard.mk
index 385870a65..e15bf3a67 100644
--- a/ports/nrf/boards/pca10100/mpconfigboard.mk
+++ b/ports/nrf/boards/pca10100/mpconfigboard.mk
@@ -21,6 +21,7 @@ CIRCUITPY_PIXELBUF = 0
CIRCUITPY_RGBMATRIX = 0
CIRCUITPY_ROTARYIO = 0
CIRCUITPY_RTC = 1
+CIRCUITPY_SDCARDIO = 0
CIRCUITPY_TOUCHIO = 0
CIRCUITPY_ULAB = 0
@@ -29,3 +30,6 @@ SUPEROPT_GC = 0
# These defines must be overridden before mpconfigboard.h is included, which is
# why they are passed on the command line.
CFLAGS += -DSPIM3_BUFFER_SIZE=0 -DSOFTDEVICE_RAM_SIZE='(32*1024)'
+
+# Override optimization to keep binary small
+OPTIMIZATION_FLAGS = -Os
diff --git a/ports/nrf/boards/raytac_mdbt50q-db-40/board.c b/ports/nrf/boards/raytac_mdbt50q-db-40/board.c
new file mode 100644
index 000000000..4421970ee
--- /dev/null
+++ b/ports/nrf/boards/raytac_mdbt50q-db-40/board.c
@@ -0,0 +1,38 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include "boards/board.h"
+
+void board_init(void) {
+}
+
+bool board_requests_safe_mode(void) {
+ return false;
+}
+
+void reset_board(void) {
+
+}
diff --git a/ports/nrf/boards/raytac_mdbt50q-db-40/bootloader/6.0.0/pca10056_bootloader_6.0.0_s140.zip b/ports/nrf/boards/raytac_mdbt50q-db-40/bootloader/6.0.0/pca10056_bootloader_6.0.0_s140.zip
new file mode 100644
index 000000000..691f4a1ab
--- /dev/null
+++ b/ports/nrf/boards/raytac_mdbt50q-db-40/bootloader/6.0.0/pca10056_bootloader_6.0.0_s140.zip
Binary files differ
diff --git a/ports/nrf/boards/raytac_mdbt50q-db-40/mpconfigboard.h b/ports/nrf/boards/raytac_mdbt50q-db-40/mpconfigboard.h
new file mode 100644
index 000000000..93fdce3a0
--- /dev/null
+++ b/ports/nrf/boards/raytac_mdbt50q-db-40/mpconfigboard.h
@@ -0,0 +1,30 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2016 Glenn Ruben Bakke
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#define MICROPY_HW_BOARD_NAME "MDBT50Q-DB-40"
+#define MICROPY_HW_MCU_NAME "nRF52840"
+
+#define MICROPY_HW_LED_STATUS (&pin_P0_13)
diff --git a/ports/nrf/boards/raytac_mdbt50q-db-40/mpconfigboard.mk b/ports/nrf/boards/raytac_mdbt50q-db-40/mpconfigboard.mk
new file mode 100644
index 000000000..f49618e77
--- /dev/null
+++ b/ports/nrf/boards/raytac_mdbt50q-db-40/mpconfigboard.mk
@@ -0,0 +1,8 @@
+USB_VID = 0x239A
+USB_PID = 0x80BC
+USB_PRODUCT = "MDBT50Q-DB-40"
+USB_MANUFACTURER = "Raytac Corporation"
+
+MCU_CHIP = nrf52840
+
+INTERNAL_FLASH_FILESYSTEM = 1
diff --git a/ports/nrf/boards/raytac_mdbt50q-db-40/pins.c b/ports/nrf/boards/raytac_mdbt50q-db-40/pins.c
new file mode 100644
index 000000000..426498cc2
--- /dev/null
+++ b/ports/nrf/boards/raytac_mdbt50q-db-40/pins.c
@@ -0,0 +1,80 @@
+#include "shared-bindings/board/__init__.h"
+
+STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
+ { MP_ROM_QSTR(MP_QSTR_P0_02), MP_ROM_PTR(&pin_P0_02) },
+ { MP_ROM_QSTR(MP_QSTR_P0_03), MP_ROM_PTR(&pin_P0_03) },
+ { MP_ROM_QSTR(MP_QSTR_P0_04), MP_ROM_PTR(&pin_P0_04) },
+ { MP_ROM_QSTR(MP_QSTR_P0_05), MP_ROM_PTR(&pin_P0_05) },
+ { MP_ROM_QSTR(MP_QSTR_P0_06), MP_ROM_PTR(&pin_P0_06) },
+ { MP_ROM_QSTR(MP_QSTR_P0_07), MP_ROM_PTR(&pin_P0_07) },
+ { MP_ROM_QSTR(MP_QSTR_P0_08), MP_ROM_PTR(&pin_P0_08) },
+ { MP_ROM_QSTR(MP_QSTR_P0_09), MP_ROM_PTR(&pin_P0_09) },
+ { MP_ROM_QSTR(MP_QSTR_P0_10), MP_ROM_PTR(&pin_P0_10) },
+ { MP_ROM_QSTR(MP_QSTR_P0_11), MP_ROM_PTR(&pin_P0_11) },
+ { MP_ROM_QSTR(MP_QSTR_P0_12), MP_ROM_PTR(&pin_P0_12) },
+ { MP_ROM_QSTR(MP_QSTR_P0_13), MP_ROM_PTR(&pin_P0_13) },
+ { MP_ROM_QSTR(MP_QSTR_P0_14), MP_ROM_PTR(&pin_P0_14) },
+ { MP_ROM_QSTR(MP_QSTR_P0_15), MP_ROM_PTR(&pin_P0_15) },
+ { MP_ROM_QSTR(MP_QSTR_P0_16), MP_ROM_PTR(&pin_P0_16) },
+ { MP_ROM_QSTR(MP_QSTR_P0_17), MP_ROM_PTR(&pin_P0_17) },
+ { MP_ROM_QSTR(MP_QSTR_P0_18), MP_ROM_PTR(&pin_P0_18) },
+ { MP_ROM_QSTR(MP_QSTR_P0_19), MP_ROM_PTR(&pin_P0_19) },
+ { MP_ROM_QSTR(MP_QSTR_P0_20), MP_ROM_PTR(&pin_P0_20) },
+ { MP_ROM_QSTR(MP_QSTR_P0_21), MP_ROM_PTR(&pin_P0_21) },
+ { MP_ROM_QSTR(MP_QSTR_P0_22), MP_ROM_PTR(&pin_P0_22) },
+ { MP_ROM_QSTR(MP_QSTR_P0_23), MP_ROM_PTR(&pin_P0_23) },
+ { MP_ROM_QSTR(MP_QSTR_P0_24), MP_ROM_PTR(&pin_P0_24) },
+ { MP_ROM_QSTR(MP_QSTR_P0_25), MP_ROM_PTR(&pin_P0_25) },
+ { MP_ROM_QSTR(MP_QSTR_P0_26), MP_ROM_PTR(&pin_P0_26) },
+ { MP_ROM_QSTR(MP_QSTR_P0_27), MP_ROM_PTR(&pin_P0_27) },
+ { MP_ROM_QSTR(MP_QSTR_P0_28), MP_ROM_PTR(&pin_P0_28) },
+ { MP_ROM_QSTR(MP_QSTR_P0_29), MP_ROM_PTR(&pin_P0_29) },
+ { MP_ROM_QSTR(MP_QSTR_P0_30), MP_ROM_PTR(&pin_P0_30) },
+ { MP_ROM_QSTR(MP_QSTR_P0_31), MP_ROM_PTR(&pin_P0_31) },
+
+ { MP_ROM_QSTR(MP_QSTR_P1_00), MP_ROM_PTR(&pin_P1_00) },
+ { MP_ROM_QSTR(MP_QSTR_P1_01), MP_ROM_PTR(&pin_P1_01) },
+ { MP_ROM_QSTR(MP_QSTR_P1_02), MP_ROM_PTR(&pin_P1_02) },
+ { MP_ROM_QSTR(MP_QSTR_P1_03), MP_ROM_PTR(&pin_P1_03) },
+ { MP_ROM_QSTR(MP_QSTR_P1_04), MP_ROM_PTR(&pin_P1_04) },
+ { MP_ROM_QSTR(MP_QSTR_P1_05), MP_ROM_PTR(&pin_P1_05) },
+ { MP_ROM_QSTR(MP_QSTR_P1_06), MP_ROM_PTR(&pin_P1_06) },
+ { MP_ROM_QSTR(MP_QSTR_P1_07), MP_ROM_PTR(&pin_P1_07) },
+ { MP_ROM_QSTR(MP_QSTR_P1_08), MP_ROM_PTR(&pin_P1_08) },
+ { MP_ROM_QSTR(MP_QSTR_P1_09), MP_ROM_PTR(&pin_P1_09) },
+ { MP_ROM_QSTR(MP_QSTR_P1_10), MP_ROM_PTR(&pin_P1_10) },
+ { MP_ROM_QSTR(MP_QSTR_P1_11), MP_ROM_PTR(&pin_P1_11) },
+ { MP_ROM_QSTR(MP_QSTR_P1_12), MP_ROM_PTR(&pin_P1_12) },
+ { MP_ROM_QSTR(MP_QSTR_P1_13), MP_ROM_PTR(&pin_P1_13) },
+ { MP_ROM_QSTR(MP_QSTR_P1_14), MP_ROM_PTR(&pin_P1_14) },
+ { MP_ROM_QSTR(MP_QSTR_P1_15), MP_ROM_PTR(&pin_P1_15) },
+
+ { MP_ROM_QSTR(MP_QSTR_AIN_0), MP_ROM_PTR(&pin_P0_02) },
+ { MP_ROM_QSTR(MP_QSTR_AIN_1), MP_ROM_PTR(&pin_P0_03) },
+ { MP_ROM_QSTR(MP_QSTR_AIN_2), MP_ROM_PTR(&pin_P0_04) },
+ { MP_ROM_QSTR(MP_QSTR_AIN_3), MP_ROM_PTR(&pin_P0_05) },
+ { MP_ROM_QSTR(MP_QSTR_AIN_4), MP_ROM_PTR(&pin_P0_28) },
+ { MP_ROM_QSTR(MP_QSTR_AIN_5), MP_ROM_PTR(&pin_P0_29) },
+ { MP_ROM_QSTR(MP_QSTR_AIN_6), MP_ROM_PTR(&pin_P0_30) },
+ { MP_ROM_QSTR(MP_QSTR_AIN_7), MP_ROM_PTR(&pin_P0_31) },
+
+ { MP_ROM_QSTR(MP_QSTR_NFC_1), MP_ROM_PTR(&pin_P0_09) },
+ { MP_ROM_QSTR(MP_QSTR_NFC_2), MP_ROM_PTR(&pin_P0_10) },
+
+ { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_P0_06) },
+ { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_P0_08) },
+ { MP_ROM_QSTR(MP_QSTR_CTS), MP_ROM_PTR(&pin_P0_07) },
+ { MP_ROM_QSTR(MP_QSTR_RTS), MP_ROM_PTR(&pin_P0_05) },
+
+ { MP_ROM_QSTR(MP_QSTR_LED_R), MP_ROM_PTR(&pin_P0_14) },
+ { MP_ROM_QSTR(MP_QSTR_LED_G), MP_ROM_PTR(&pin_P0_13) },
+ { MP_ROM_QSTR(MP_QSTR_LED_B), MP_ROM_PTR(&pin_P0_15) },
+ { MP_ROM_QSTR(MP_QSTR_LED_4), MP_ROM_PTR(&pin_P0_16) },
+
+ { MP_ROM_QSTR(MP_QSTR_SW1), MP_ROM_PTR(&pin_P0_11) },
+ { MP_ROM_QSTR(MP_QSTR_SW2), MP_ROM_PTR(&pin_P0_12) },
+ { MP_ROM_QSTR(MP_QSTR_SW3), MP_ROM_PTR(&pin_P0_24) },
+ { MP_ROM_QSTR(MP_QSTR_SW4), MP_ROM_PTR(&pin_P0_25) },
+};
+
+MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);
diff --git a/ports/nrf/boards/simmel/mpconfigboard.mk b/ports/nrf/boards/simmel/mpconfigboard.mk
index 2bca2492f..8dd284d57 100644
--- a/ports/nrf/boards/simmel/mpconfigboard.mk
+++ b/ports/nrf/boards/simmel/mpconfigboard.mk
@@ -32,3 +32,6 @@ CIRCUITPY_WATCHDOG = 1
# These defines must be overridden before mpconfigboard.h is included, which is
# why they are passed on the command line.
CFLAGS += -DSPIM3_BUFFER_SIZE=0 -DSOFTDEVICE_RAM_SIZE='(32*1024)' -DNRFX_SPIM3_ENABLED=0
+
+# Override optimization to keep binary small
+OPTIMIZATION_FLAGS = -Os
diff --git a/ports/nrf/boards/tinkeringtech_scoutmakes_azul/README.md b/ports/nrf/boards/tinkeringtech_scoutmakes_azul/README.md
new file mode 100644
index 000000000..614daa72c
--- /dev/null
+++ b/ports/nrf/boards/tinkeringtech_scoutmakes_azul/README.md
@@ -0,0 +1,25 @@
+# Setup
+
+The TinkeringTech ScoutMakes Azul is a bluetooth enabled, feather format, open source platform featuring the nRF52840 from Nordic Semiconductors. The design is based on the Adafruit nRF52840 feather express and uses the Raytac MDBT50Q-1MV2 module.
+
+Schematic, datasheet, pin mapping etc. can be found over [here](https://tinkeringtech.com/scoutmakes-azul).
+
+features:
+- ARM Cortex M4F (with HW floating point acceleration) running at 64MHz
+- Raytac MDBT50Q-1MV2 BLE module. FCC / IC / TELEC certified module
+- 1MB flash and 256KB SRAM
+- Native Open Source USB stack – pre-programmed with UF2 bootloader and CircuitPython
+- 128×32 OLED display
+- USB type-C
+- On/off power switch
+- Bluetooth Low Energy compatible 2.4GHz radio (Details available in the nRF52840 product specification)
+- BT5.1 & BT5 Bluetooth Specification Certified
+- Supports BT5 Long Range Feature
+- 1.7v to 3.3v operation with internal linear and DC/DC voltage regulators
+- 21 GPIO, 6 x 12-bit ADC pins, up to 12 PWM outputs (3 PWM modules with 4 outputs each)
+- Pin #3 red LED for general purpose blinking,
+- Programmable NeoPixel for colorful feedback
+- 4 mounting holes
+- Reset button
+- Works out of the box with Adafruit feather wings.
+- Open source design.
diff --git a/ports/nrf/boards/tinkeringtech_scoutmakes_azul/board.c b/ports/nrf/boards/tinkeringtech_scoutmakes_azul/board.c
new file mode 100644
index 000000000..4421970ee
--- /dev/null
+++ b/ports/nrf/boards/tinkeringtech_scoutmakes_azul/board.c
@@ -0,0 +1,38 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include "boards/board.h"
+
+void board_init(void) {
+}
+
+bool board_requests_safe_mode(void) {
+ return false;
+}
+
+void reset_board(void) {
+
+}
diff --git a/ports/nrf/boards/tinkeringtech_scoutmakes_azul/mpconfigboard.h b/ports/nrf/boards/tinkeringtech_scoutmakes_azul/mpconfigboard.h
new file mode 100644
index 000000000..2d6663394
--- /dev/null
+++ b/ports/nrf/boards/tinkeringtech_scoutmakes_azul/mpconfigboard.h
@@ -0,0 +1,63 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2016 Glenn Ruben Bakke
+ * Copyright (c) 2018 Dan Halbert for Adafruit Industries
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include "nrfx/hal/nrf_gpio.h"
+
+#define MICROPY_HW_BOARD_NAME "TinkeringTech ScoutMakes Azul"
+#define MICROPY_HW_MCU_NAME "nRF52840"
+
+#define MICROPY_HW_NEOPIXEL (&pin_P0_16)
+
+#define MICROPY_HW_LED_STATUS (&pin_P1_15)
+
+#if QSPI_FLASH_FILESYSTEM
+#define MICROPY_QSPI_DATA0 NRF_GPIO_PIN_MAP(0, 17)
+#define MICROPY_QSPI_DATA1 NRF_GPIO_PIN_MAP(0, 22)
+#define MICROPY_QSPI_DATA2 NRF_GPIO_PIN_MAP(0, 23)
+#define MICROPY_QSPI_DATA3 NRF_GPIO_PIN_MAP(0, 21)
+#define MICROPY_QSPI_SCK NRF_GPIO_PIN_MAP(0, 19)
+#define MICROPY_QSPI_CS NRF_GPIO_PIN_MAP(0, 20)
+#endif
+
+#if SPI_FLASH_FILESYSTEM
+#define SPI_FLASH_MOSI_PIN &pin_P0_17
+#define SPI_FLASH_MISO_PIN &pin_P0_22
+#define SPI_FLASH_SCK_PIN &pin_P0_19
+#define SPI_FLASH_CS_PIN &pin_P0_20
+#endif
+
+#define BOARD_HAS_CRYSTAL 1
+
+#define DEFAULT_I2C_BUS_SCL (&pin_P0_11)
+#define DEFAULT_I2C_BUS_SDA (&pin_P0_12)
+
+#define DEFAULT_SPI_BUS_SCK (&pin_P0_14)
+#define DEFAULT_SPI_BUS_MOSI (&pin_P0_13)
+#define DEFAULT_SPI_BUS_MISO (&pin_P0_15)
+
+#define DEFAULT_UART_BUS_RX (&pin_P0_24)
+#define DEFAULT_UART_BUS_TX (&pin_P0_25)
diff --git a/ports/nrf/boards/tinkeringtech_scoutmakes_azul/mpconfigboard.mk b/ports/nrf/boards/tinkeringtech_scoutmakes_azul/mpconfigboard.mk
new file mode 100644
index 000000000..e8bd636ad
--- /dev/null
+++ b/ports/nrf/boards/tinkeringtech_scoutmakes_azul/mpconfigboard.mk
@@ -0,0 +1,10 @@
+USB_VID = 0x239A
+USB_PID = 0x80BE
+USB_PRODUCT = "TinkeringTech ScoutMakes Azul"
+USB_MANUFACTURER = "TinkeringTech LLC"
+
+MCU_CHIP = nrf52840
+
+QSPI_FLASH_FILESYSTEM = 1
+EXTERNAL_FLASH_DEVICE_COUNT = 1
+EXTERNAL_FLASH_DEVICES = "GD25Q16C"
diff --git a/ports/nrf/boards/tinkeringtech_scoutmakes_azul/pins.c b/ports/nrf/boards/tinkeringtech_scoutmakes_azul/pins.c
new file mode 100644
index 000000000..ec2689ab4
--- /dev/null
+++ b/ports/nrf/boards/tinkeringtech_scoutmakes_azul/pins.c
@@ -0,0 +1,53 @@
+#include "shared-bindings/board/__init__.h"
+
+STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
+ { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_P0_04) },
+ { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_P0_05) },
+ { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_P0_30) },
+ { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_P0_28) },
+ { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_P0_02) },
+ { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_P0_03) },
+
+ { MP_ROM_QSTR(MP_QSTR_AREF), MP_ROM_PTR(&pin_P0_31) },
+
+ { MP_ROM_QSTR(MP_QSTR_VOLTAGE_MONITOR), MP_ROM_PTR(&pin_P0_29) },
+ { MP_ROM_QSTR(MP_QSTR_BATTERY), MP_ROM_PTR(&pin_P0_29) },
+
+ { MP_ROM_QSTR(MP_QSTR_SWITCH), MP_ROM_PTR(&pin_P1_02) },
+
+ { MP_ROM_QSTR(MP_QSTR_NFC1), MP_ROM_PTR(&pin_P0_09) },
+ { MP_ROM_QSTR(MP_QSTR_NFC2), MP_ROM_PTR(&pin_P0_10) },
+
+ { MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_P0_10) },
+ { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_P1_08) },
+ { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_P0_07) },
+ { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_P0_26) },
+ { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_P0_27) },
+ { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_P0_06) },
+ { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_P0_08) },
+ { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_P1_09) },
+
+ { MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_P0_16) },
+
+ { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_P0_14) },
+ { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_P0_13) },
+ { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_P0_15) },
+
+ { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_P0_25) },
+ { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_P0_24) },
+
+ { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_P0_11) },
+ { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_P0_12) },
+
+ { MP_ROM_QSTR(MP_QSTR_L), MP_ROM_PTR(&pin_P1_15) },
+ { MP_ROM_QSTR(MP_QSTR_RED_LED), MP_ROM_PTR(&pin_P1_15) },
+ { MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_P1_15) },
+
+ { MP_ROM_QSTR(MP_QSTR_BLUE_LED), MP_ROM_PTR(&pin_P1_10) },
+
+ { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) },
+ { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) },
+ { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
+};
+
+MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);
diff --git a/ports/nrf/common-hal/busio/SPI.c b/ports/nrf/common-hal/busio/SPI.c
index 3f205e778..f27f0e267 100644
--- a/ports/nrf/common-hal/busio/SPI.c
+++ b/ports/nrf/common-hal/busio/SPI.c
@@ -271,13 +271,13 @@ bool common_hal_busio_spi_read(busio_spi_obj_t *self, uint8_t *data, size_t len,
return true;
}
-bool common_hal_busio_spi_transfer(busio_spi_obj_t *self, uint8_t *data_out, uint8_t *data_in, size_t len) {
+bool common_hal_busio_spi_transfer(busio_spi_obj_t *self, const uint8_t *data_out, uint8_t *data_in, size_t len) {
const bool is_spim3 = self->spim_peripheral->spim.p_reg == NRF_SPIM3;
- uint8_t *next_chunk_out = data_out;
+ const uint8_t *next_chunk_out = data_out;
uint8_t *next_chunk_in = data_in;
while (len > 0) {
- uint8_t *chunk_out = next_chunk_out;
+ const uint8_t *chunk_out = next_chunk_out;
size_t chunk_size = MIN(len, self->spim_peripheral->max_xfer_size);
if (is_spim3) {
// If SPIM3, copy into unused RAM block, and do DMA from there.
diff --git a/ports/nrf/common-hal/busio/UART.c b/ports/nrf/common-hal/busio/UART.c
index 89f3c9f32..012ebc3b5 100644
--- a/ports/nrf/common-hal/busio/UART.c
+++ b/ports/nrf/common-hal/busio/UART.c
@@ -133,7 +133,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
const mcu_pin_obj_t * tx, const mcu_pin_obj_t * rx,
const mcu_pin_obj_t * rts, const mcu_pin_obj_t * cts,
const mcu_pin_obj_t * rs485_dir, bool rs485_invert,
- uint32_t baudrate, uint8_t bits, uart_parity_t parity, uint8_t stop,
+ uint32_t baudrate, uint8_t bits, busio_uart_parity_t parity, uint8_t stop,
mp_float_t timeout, uint16_t receiver_buffer_size, byte* receiver_buffer,
bool sigint_enabled) {
@@ -162,7 +162,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
mp_raise_ValueError(translate("Invalid buffer size"));
}
- if ( parity == PARITY_ODD ) {
+ if ( parity == BUSIO_UART_PARITY_ODD ) {
mp_raise_ValueError(translate("Odd parity is not supported"));
}
@@ -176,7 +176,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
.interrupt_priority = 7,
.hal_cfg = {
.hwfc = NRF_UARTE_HWFC_DISABLED,
- .parity = (parity == PARITY_NONE) ? NRF_UARTE_PARITY_EXCLUDED : NRF_UARTE_PARITY_INCLUDED
+ .parity = (parity == BUSIO_UART_PARITY_NONE) ? NRF_UARTE_PARITY_EXCLUDED : NRF_UARTE_PARITY_INCLUDED
}
};
diff --git a/ports/nrf/common-hal/microcontroller/__init__.c b/ports/nrf/common-hal/microcontroller/__init__.c
index f5caf68ef..06aac9409 100644
--- a/ports/nrf/common-hal/microcontroller/__init__.c
+++ b/ports/nrf/common-hal/microcontroller/__init__.c
@@ -50,36 +50,34 @@ void common_hal_mcu_delay_us(uint32_t delay) {
static volatile uint32_t nesting_count = 0;
static uint8_t is_nested_critical_region;
-static uint8_t sd_is_enabled = false;
void common_hal_mcu_disable_interrupts() {
- sd_softdevice_is_enabled(&sd_is_enabled);
- if (sd_is_enabled) {
+ if (nesting_count == 0) {
+ // Unlike __disable_irq(), this should only be called the first time
+ // "is_nested_critical_region" is sd's equivalent of our nesting count
+ // so a nested call would store 0 in the global and make the later
+ // exit call not actually reenable interrupts
+ //
+ // This only disables interrupts of priority 2 through 7; levels 0, 1,
+ // and 4, are exclusive to softdevice and should never be used, so
+ // this limitation is not important.
sd_nvic_critical_region_enter(&is_nested_critical_region);
- } else {
- __disable_irq();
- __DMB();
- nesting_count++;
}
+ __DMB();
+ nesting_count++;
}
void common_hal_mcu_enable_interrupts() {
- // Don't check here if SD is enabled, because we'll crash if interrupts
- // were turned off and sd_softdevice_is_enabled is called.
- if (sd_is_enabled) {
- sd_nvic_critical_region_exit(is_nested_critical_region);
- } else {
- if (nesting_count == 0) {
- // This is very very bad because it means there was mismatched disable/enables so we
- // crash.
- reset_into_safe_mode(HARD_CRASH);
- }
- nesting_count--;
- if (nesting_count > 0) {
- return;
- }
- __DMB();
- __enable_irq();
+ if (nesting_count == 0) {
+ // This is very very bad because it means there was mismatched disable/enables so we
+ // crash.
+ reset_into_safe_mode(HARD_CRASH);
}
+ nesting_count--;
+ if (nesting_count > 0) {
+ return;
+ }
+ __DMB();
+ sd_nvic_critical_region_exit(is_nested_critical_region);
}
void common_hal_mcu_on_next_reset(mcu_runmode_t runmode) {
diff --git a/ports/nrf/examples/ubluepy_temp.py b/ports/nrf/examples/ubluepy_temp.py
index 118407af5..405f77c4b 100644
--- a/ports/nrf/examples/ubluepy_temp.py
+++ b/ports/nrf/examples/ubluepy_temp.py
@@ -2,7 +2,7 @@
#
# The MIT License (MIT)
#
-# Copyright (c) 2017 Glenn Ruben Bakke
+# SPDX-FileCopyrightText: Copyright (c) 2017 Glenn Ruben Bakke
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
diff --git a/ports/nrf/fatfs_port.c b/ports/nrf/fatfs_port.c
index cb1bfa834..2b741f993 100644
--- a/ports/nrf/fatfs_port.c
+++ b/ports/nrf/fatfs_port.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/ports/nrf/peripherals/nrf/nvm.c b/ports/nrf/peripherals/nrf/nvm.c
index dc50e2eef..ce47d73c7 100644
--- a/ports/nrf/peripherals/nrf/nvm.c
+++ b/ports/nrf/peripherals/nrf/nvm.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
* Copyright (c) 2019 Nick Moore for Adafruit Industries
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
diff --git a/ports/nrf/peripherals/nrf/nvm.h b/ports/nrf/peripherals/nrf/nvm.h
index 8ba95773d..9e144d802 100644
--- a/ports/nrf/peripherals/nrf/nvm.h
+++ b/ports/nrf/peripherals/nrf/nvm.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
* Copyright (c) 2019 Nick Moore for Adafruit Industries
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
diff --git a/ports/nrf/supervisor/internal_flash.c b/ports/nrf/supervisor/internal_flash.c
index 737bab203..93de0b2c4 100644
--- a/ports/nrf/supervisor/internal_flash.c
+++ b/ports/nrf/supervisor/internal_flash.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/ports/nrf/supervisor/internal_flash.h b/ports/nrf/supervisor/internal_flash.h
index 024a53ebb..81da69021 100644
--- a/ports/nrf/supervisor/internal_flash.h
+++ b/ports/nrf/supervisor/internal_flash.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/ports/nrf/supervisor/port.c b/ports/nrf/supervisor/port.c
index aee2d63e1..e681e6825 100644
--- a/ports/nrf/supervisor/port.c
+++ b/ports/nrf/supervisor/port.c
@@ -313,12 +313,21 @@ void port_sleep_until_interrupt(void) {
// instruction will returned as long as an interrupt is
// available, even though the actual handler won't fire until
// we re-enable interrupts.
- common_hal_mcu_disable_interrupts();
+ //
+ // We do not use common_hal_mcu_disable_interrupts here because
+ // we truly require that interrupts be disabled, while
+ // common_hal_mcu_disable_interrupts actually just masks the
+ // interrupts that are not required to allow the softdevice to
+ // function (whether or not SD is enabled)
+ int nested = __get_PRIMASK();
+ __disable_irq();
if (!tud_task_event_ready()) {
__DSB();
__WFI();
}
- common_hal_mcu_enable_interrupts();
+ if (!nested) {
+ __enable_irq();
+ }
}
}
diff --git a/ports/nrf/supervisor/usb.c b/ports/nrf/supervisor/usb.c
index 3d2527faa..771e86ce0 100644
--- a/ports/nrf/supervisor/usb.c
+++ b/ports/nrf/supervisor/usb.c
@@ -30,6 +30,7 @@
#include "lib/utils/interrupt_char.h"
#include "lib/mp-readline/readline.h"
#include "lib/tinyusb/src/device/usbd.h"
+#include "supervisor/background_callback.h"
#ifdef SOFTDEVICE_PRESENT
#include "nrf_sdm.h"
@@ -42,7 +43,9 @@ extern void tusb_hal_nrf_power_event(uint32_t event);
void init_usb_hardware(void) {
- // 2 is max priority (0, 1 are reserved for SD)
+ // 2 is max priority (0, 1, and 4 are reserved for SD)
+ // 5 is max priority that still allows calling SD functions such as
+ // sd_softdevice_is_enabled
NVIC_SetPriority(USBD_IRQn, 2);
// USB power may already be ready at this time -> no event generated
@@ -89,5 +92,5 @@ void init_usb_hardware(void) {
}
void USBD_IRQHandler(void) {
- tud_int_handler(0);
+ usb_irq_handler();
}
diff --git a/ports/stm/Makefile b/ports/stm/Makefile
index 08cb36ddf..dccc749ed 100755
--- a/ports/stm/Makefile
+++ b/ports/stm/Makefile
@@ -2,8 +2,8 @@
#
# The MIT License (MIT)
#
-# Copyright (c) 2019 Dan Halbert for Adafruit Industries
-# Copyright (c) 2019 Lucian Copeland for Adafruit Industries
+# SPDX-FileCopyrightText: Copyright (c) 2019 Dan Halbert for Adafruit Industries
+# SPDX-FileCopyrightText: 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
@@ -81,16 +81,20 @@ INC += -I../../supervisor/shared/usb
#Debugging/Optimization
ifeq ($(DEBUG), 1)
- CFLAGS += -ggdb
+ CFLAGS += -ggdb3
# You may want to enable these flags to make setting breakpoints easier.
CFLAGS += -fno-inline -fno-ipa-sra
else
- CFLAGS += -Os -DNDEBUG
- CFLAGS += -ggdb
+ CFLAGS += -DNDEBUG
+ OPTIMIZATION_FLAGS ?= -O2
+ CFLAGS += -ggdb3
# TODO: Test with -flto
# CFLAGS += -flto
endif
+# to override compiler optimization level, set in boards/$(BOARD)/mpconfigboard.mk
+CFLAGS += $(OPTIMIZATION_FLAGS)
+
# MCU Series is defined by the HAL package and doesn't need to be specified here
C_DEFS = -D$(MCU_PACKAGE) -DUSE_HAL_DRIVER -DUSE_FULL_LL_DRIVER -D$(MCU_VARIANT)
@@ -207,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/background.c b/ports/stm/background.c
index 8c1897043..d83a0ccec 100644
--- a/ports/stm/background.c
+++ b/ports/stm/background.c
@@ -33,28 +33,6 @@
#include "shared-module/displayio/__init__.h"
#endif
-static bool running_background_tasks = false;
-
-void background_tasks_reset(void) {
- running_background_tasks = false;
-}
-
-void run_background_tasks(void) {
- // Don't call ourselves recursively.
- if (running_background_tasks) {
- return;
- }
- running_background_tasks = true;
- filesystem_background();
-
- #if USB_AVAILABLE
- usb_background();
- #endif
-
- #if CIRCUITPY_DISPLAYIO
- displayio_background();
- #endif
- running_background_tasks = false;
-
- assert_heap_ok();
-}
+void port_background_task(void) {}
+void port_start_background_task(void) {}
+void port_finish_background_task(void) {}
diff --git a/ports/stm/background.h b/ports/stm/background.h
index 6225429f8..e57aa40dd 100644
--- a/ports/stm/background.h
+++ b/ports/stm/background.h
@@ -27,9 +27,4 @@
#ifndef MICROPY_INCLUDED_STM32_BACKGROUND_H
#define MICROPY_INCLUDED_STM32_BACKGROUND_H
-#include <stdbool.h>
-
-void background_tasks_reset(void);
-void run_background_tasks(void);
-
#endif // MICROPY_INCLUDED_STM32_BACKGROUND_H
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 2ea969f50..69c1f3e04 100644
--- a/ports/stm/common-hal/analogio/AnalogOut.c
+++ b/ports/stm/common-hal/analogio/AnalogOut.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
* Copyright (c) 2019, Lucian Copeland for Adafruit Industries
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -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 65eeb8ebc..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.
@@ -107,104 +107,78 @@ void spi_reset(void) {
spi_clock_disable(ALL_CLOCKS & ~(never_reset_mask));
}
-void common_hal_busio_spi_construct(busio_spi_obj_t *self,
+STATIC const mcu_periph_obj_t *find_pin_function(const mcu_periph_obj_t *table, size_t sz, const mcu_pin_obj_t *pin, int periph_index) {
+ for(size_t i = 0; i<sz; i++, table++) {
+ if(periph_index == table->periph_index && pin == table->pin ) {
+ return table;
+ }
+ }
+ return NULL;
+}
+
+//match pins to SPI objects
+STATIC int check_pins(busio_spi_obj_t *self,
const mcu_pin_obj_t * sck, const mcu_pin_obj_t * mosi,
const mcu_pin_obj_t * miso) {
-
- //match pins to SPI objects
- SPI_TypeDef * SPIx;
+ bool spi_taken = false;
uint8_t sck_len = MP_ARRAY_SIZE(mcu_spi_sck_list);
uint8_t mosi_len = MP_ARRAY_SIZE(mcu_spi_mosi_list);
uint8_t miso_len = MP_ARRAY_SIZE(mcu_spi_miso_list);
- bool spi_taken = false;
//SCK is not optional. MOSI and MISO are
+ if (!sck) {
+ mp_raise_ValueError(translate("Must provide SCK pin"));
+ }
+
+ if (!miso && !mosi) {
+ mp_raise_ValueError(translate("Must provide MISO or MOSI pin"));
+ }
+
+ // Loop over each possibility for SCK. Check whether MISO and/or MOSI can be used on the same peripheral
for (uint i = 0; i < sck_len; i++) {
- if (mcu_spi_sck_list[i].pin == sck) {
- //if both MOSI and MISO exist, loop search normally
- if ((mosi != NULL) && (miso != NULL)) {
- //MOSI
- for (uint j = 0; j < mosi_len; j++) {
- if (mcu_spi_mosi_list[j].pin == mosi) {
- //MISO
- for (uint k = 0; k < miso_len; k++) {
- if ((mcu_spi_miso_list[k].pin == miso) //everything needs the same index
- && (mcu_spi_sck_list[i].periph_index == mcu_spi_mosi_list[j].periph_index)
- && (mcu_spi_sck_list[i].periph_index == mcu_spi_miso_list[k].periph_index)) {
- //keep looking if the SPI is taken, edge case
- if (reserved_spi[mcu_spi_sck_list[i].periph_index - 1]) {
- spi_taken = true;
- continue;
- }
- //store pins if not
- self->sck = &mcu_spi_sck_list[i];
- self->mosi = &mcu_spi_mosi_list[j];
- self->miso = &mcu_spi_miso_list[k];
- break;
- }
- }
- if (self->sck != NULL) {
- break; // Multi-level break to pick lowest peripheral
- }
- }
- }
- if (self->sck != NULL) {
- break;
- }
- // if just MISO, reduce search
- } else if (miso != NULL) {
- for (uint j = 0; j < miso_len; j++) {
- if ((mcu_spi_miso_list[j].pin == miso) //only SCK and MISO need the same index
- && (mcu_spi_sck_list[i].periph_index == mcu_spi_miso_list[j].periph_index)) {
- if (reserved_spi[mcu_spi_sck_list[i].periph_index - 1]) {
- spi_taken = true;
- continue;
- }
- self->sck = &mcu_spi_sck_list[i];
- self->mosi = NULL;
- self->miso = &mcu_spi_miso_list[j];
- break;
- }
- }
- if (self->sck != NULL) {
- break;
- }
- // if just MOSI, reduce search
- } else if (mosi != NULL) {
- for (uint j = 0; j < mosi_len; j++) {
- if ((mcu_spi_mosi_list[j].pin == mosi) //only SCK and MOSI need the same index
- && (mcu_spi_sck_list[i].periph_index == mcu_spi_mosi_list[j].periph_index)) {
- if (reserved_spi[mcu_spi_sck_list[i].periph_index - 1]) {
- spi_taken = true;
- continue;
- }
- self->sck = &mcu_spi_sck_list[i];
- self->mosi = &mcu_spi_mosi_list[j];
- self->miso = NULL;
- break;
- }
- }
- if (self->sck != NULL) {
- break;
- }
- } else {
- //throw an error immediately
- mp_raise_ValueError(translate("Must provide MISO or MOSI pin"));
- }
+ const mcu_periph_obj_t *mcu_spi_sck = &mcu_spi_sck_list[i];
+ if (mcu_spi_sck->pin != sck) {
+ continue;
+ }
+
+ int periph_index = mcu_spi_sck->periph_index;
+
+ const mcu_periph_obj_t *mcu_spi_miso = NULL;
+ if (miso && !(mcu_spi_miso = find_pin_function(mcu_spi_miso_list, miso_len, miso, periph_index))) {
+ continue;
}
+
+ const mcu_periph_obj_t *mcu_spi_mosi = NULL;
+ if (mosi && !(mcu_spi_mosi = find_pin_function(mcu_spi_mosi_list, mosi_len, mosi, periph_index))) {
+ continue;
+ }
+
+ if (reserved_spi[periph_index-1]) {
+ spi_taken = true;
+ continue;
+ }
+
+ self->sck = mcu_spi_sck;
+ self->mosi = mcu_spi_mosi;
+ self->miso = mcu_spi_miso;
+
+ return periph_index;
}
- //handle typedef selection, errors
- if (self->sck != NULL && (self->mosi != NULL || self->miso != NULL)) {
- SPIx = mcu_spi_banks[self->sck->periph_index - 1];
+ if (spi_taken) {
+ mp_raise_ValueError(translate("Hardware busy, try alternative pins"));
} else {
- if (spi_taken) {
- mp_raise_ValueError(translate("Hardware busy, try alternative pins"));
- } else {
- mp_raise_ValueError(translate("Invalid SPI pin selection"));
- }
+ mp_raise_ValueError(translate("Invalid SPI pin selection"));
}
+}
+
+void common_hal_busio_spi_construct(busio_spi_obj_t *self,
+ const mcu_pin_obj_t * sck, const mcu_pin_obj_t * mosi,
+ const mcu_pin_obj_t * miso) {
+
+ int periph_index = check_pins(self, sck, mosi, miso);
+ SPI_TypeDef * SPIx = mcu_spi_banks[periph_index - 1];
//Start GPIO for each pin
GPIO_InitTypeDef GPIO_InitStruct = {0};
@@ -259,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);
}
}
@@ -380,12 +354,12 @@ bool common_hal_busio_spi_read(busio_spi_obj_t *self,
}
bool common_hal_busio_spi_transfer(busio_spi_obj_t *self,
- uint8_t *data_out, uint8_t *data_in, size_t len) {
+ const uint8_t *data_out, uint8_t *data_in, size_t len) {
if (self->miso == NULL || self->mosi == NULL) {
mp_raise_ValueError(translate("Missing MISO or MOSI Pin"));
}
HAL_StatusTypeDef result = HAL_SPI_TransmitReceive (&self->handle,
- data_out, data_in, (uint16_t)len,HAL_MAX_DELAY);
+ (uint8_t *) data_out, data_in, (uint16_t)len,HAL_MAX_DELAY);
return result == HAL_OK;
}
diff --git a/ports/stm/common-hal/busio/UART.c b/ports/stm/common-hal/busio/UART.c
index 86a932290..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"
@@ -79,7 +80,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
const mcu_pin_obj_t * tx, const mcu_pin_obj_t * rx,
const mcu_pin_obj_t * rts, const mcu_pin_obj_t * cts,
const mcu_pin_obj_t * rs485_dir, bool rs485_invert,
- uint32_t baudrate, uint8_t bits, uart_parity_t parity, uint8_t stop,
+ uint32_t baudrate, uint8_t bits, busio_uart_parity_t parity, uint8_t stop,
mp_float_t timeout, uint16_t receiver_buffer_size, byte* receiver_buffer,
bool sigint_enabled) {
@@ -201,8 +202,8 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
self->handle.Init.BaudRate = baudrate;
self->handle.Init.WordLength = (bits == 9) ? UART_WORDLENGTH_9B : UART_WORDLENGTH_8B;
self->handle.Init.StopBits = (stop > 1) ? UART_STOPBITS_2 : UART_STOPBITS_1;
- self->handle.Init.Parity = (parity == PARITY_ODD) ? UART_PARITY_ODD :
- (parity == PARITY_EVEN) ? UART_PARITY_EVEN :
+ self->handle.Init.Parity = (parity == BUSIO_UART_PARITY_ODD) ? UART_PARITY_ODD :
+ (parity == BUSIO_UART_PARITY_EVEN) ? UART_PARITY_EVEN :
UART_PARITY_NONE;
self->handle.Init.Mode = (self->tx != NULL && self->rx != NULL) ? UART_MODE_TX_RX :
(self->tx != NULL) ? UART_MODE_TX :
@@ -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/fatfs_port.c b/ports/stm/fatfs_port.c
index 6a17f627b..631f7f098 100644
--- a/ports/stm/fatfs_port.c
+++ b/ports/stm/fatfs_port.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/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/st_driver b/ports/stm/st_driver
-Subproject 3fc2e0f3db155b33177bb0705e0dd65cadb5841
+Subproject 1900834751fd6754457874b8c971690bab33e0a
diff --git a/ports/stm/supervisor/internal_flash.c b/ports/stm/supervisor/internal_flash.c
index d37a54f60..864403c36 100644
--- a/ports/stm/supervisor/internal_flash.c
+++ b/ports/stm/supervisor/internal_flash.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
* Copyright (c) 2020 Lucian Copeland for Adafruit Industries
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
diff --git a/ports/stm/supervisor/internal_flash.h b/ports/stm/supervisor/internal_flash.h
index 13ade4e6e..ad5cba62d 100644
--- a/ports/stm/supervisor/internal_flash.h
+++ b/ports/stm/supervisor/internal_flash.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
* Copyright (c) 2020 Lucian Copeland for Adafruit Industries
* Copyright (c) 2020 Mark Olsson <mark@markolsson.se>
*
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 3dd0acafd..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
@@ -130,5 +135,5 @@ void init_usb_hardware(void) {
}
void OTG_FS_IRQHandler(void) {
- tud_int_handler(0);
+ usb_irq_handler();
}
diff --git a/ports/stm/tools/parse_af_csv.py b/ports/stm/tools/parse_af_csv.py
index 4e9725260..06af3bf1e 100644
--- a/ports/stm/tools/parse_af_csv.py
+++ b/ports/stm/tools/parse_af_csv.py
@@ -2,7 +2,7 @@
#
# The MIT License (MIT)
#
-# Copyright (c) 2020 Lucian Copeland for Adafruit Industries
+# SPDX-FileCopyrightText: 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
@@ -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/parse_pins_csv.py b/ports/stm/tools/parse_pins_csv.py
index 4ab3fc25c..68f6db586 100644
--- a/ports/stm/tools/parse_pins_csv.py
+++ b/ports/stm/tools/parse_pins_csv.py
@@ -2,7 +2,7 @@
#
# The MIT License (MIT)
#
-# Copyright (c) 2020 Lucian Copeland for Adafruit Industries
+# SPDX-FileCopyrightText: 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
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/ports/unix/fdfile.h b/ports/unix/fdfile.h
index 69a9b6be4..d7da673be 100644
--- a/ports/unix/fdfile.h
+++ b/ports/unix/fdfile.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
* Copyright (c) 2016 Paul Sokolovsky
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
diff --git a/ports/unix/file.c b/ports/unix/file.c
index e5c73d26c..e4f62e3d5 100644
--- a/ports/unix/file.c
+++ b/ports/unix/file.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/ports/unix/gccollect.c b/ports/unix/gccollect.c
index 02f6fc91a..7cd74ec13 100644
--- a/ports/unix/gccollect.c
+++ b/ports/unix/gccollect.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/ports/unix/input.c b/ports/unix/input.c
index 7d60b46cc..b661ce3e2 100644
--- a/ports/unix/input.c
+++ b/ports/unix/input.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/ports/unix/main.c b/ports/unix/main.c
index d1187ae90..5a3cbaf47 100644
--- a/ports/unix/main.c
+++ b/ports/unix/main.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/ports/unix/modffi.c b/ports/unix/modffi.c
index 03dc9e4ec..c750f2eb7 100644
--- a/ports/unix/modffi.c
+++ b/ports/unix/modffi.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
* Copyright (c) 2014 Paul Sokolovsky
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
diff --git a/ports/unix/modmachine.c b/ports/unix/modmachine.c
index b2bca1206..61697cfb6 100644
--- a/ports/unix/modmachine.c
+++ b/ports/unix/modmachine.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/ports/unix/modos.c b/ports/unix/modos.c
index d99d0d62c..252b19a50 100644
--- a/ports/unix/modos.c
+++ b/ports/unix/modos.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
* Copyright (c) 2014 Paul Sokolovsky
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
diff --git a/ports/unix/modtime.c b/ports/unix/modtime.c
index a8f6ed5c6..cc9b4a337 100644
--- a/ports/unix/modtime.c
+++ b/ports/unix/modtime.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/ports/unix/moduos_vfs.c b/ports/unix/moduos_vfs.c
index e9ac8e1f8..b45d4485b 100644
--- a/ports/unix/moduos_vfs.c
+++ b/ports/unix/moduos_vfs.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2017 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2017 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/ports/unix/moduselect.c b/ports/unix/moduselect.c
index 1ea7dc19a..dbda5e110 100644
--- a/ports/unix/moduselect.c
+++ b/ports/unix/moduselect.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2014 Damien P. George
* Copyright (c) 2015-2017 Paul Sokolovsky
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
diff --git a/ports/unix/modusocket.c b/ports/unix/modusocket.c
index 95da276ed..90651a19e 100644
--- a/ports/unix/modusocket.c
+++ b/ports/unix/modusocket.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
* Copyright (c) 2014 Paul Sokolovsky
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
diff --git a/ports/unix/mpconfigport.h b/ports/unix/mpconfigport.h
index 3ac7ceaf2..3ae4ff786 100644
--- a/ports/unix/mpconfigport.h
+++ b/ports/unix/mpconfigport.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/ports/unix/mpconfigport_coverage.h b/ports/unix/mpconfigport_coverage.h
index 97c05cfee..51015a587 100644
--- a/ports/unix/mpconfigport_coverage.h
+++ b/ports/unix/mpconfigport_coverage.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013-2016 Damien P. George
+ * SPDX-FileCopyrightText: 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
diff --git a/ports/unix/mpconfigport_fast.h b/ports/unix/mpconfigport_fast.h
index 442159eb4..76e02c1b0 100644
--- a/ports/unix/mpconfigport_fast.h
+++ b/ports/unix/mpconfigport_fast.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/ports/unix/mpconfigport_freedos.h b/ports/unix/mpconfigport_freedos.h
index 09c85ab1e..19c73b762 100644
--- a/ports/unix/mpconfigport_freedos.h
+++ b/ports/unix/mpconfigport_freedos.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2015 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2015 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/ports/unix/mpconfigport_minimal.h b/ports/unix/mpconfigport_minimal.h
index ef7a1a09a..1a13d5725 100644
--- a/ports/unix/mpconfigport_minimal.h
+++ b/ports/unix/mpconfigport_minimal.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2015 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2015 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/ports/unix/mpconfigport_nanbox.h b/ports/unix/mpconfigport_nanbox.h
index 7da2cf7b8..fa41407cf 100644
--- a/ports/unix/mpconfigport_nanbox.h
+++ b/ports/unix/mpconfigport_nanbox.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2016 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 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
diff --git a/ports/unix/mphalport.h b/ports/unix/mphalport.h
index ff7a51567..6f2880d4e 100644
--- a/ports/unix/mphalport.h
+++ b/ports/unix/mphalport.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2015 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2015 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/ports/unix/mpthreadport.c b/ports/unix/mpthreadport.c
index baca0a2b1..3641745bc 100644
--- a/ports/unix/mpthreadport.c
+++ b/ports/unix/mpthreadport.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd
+ * SPDX-FileCopyrightText: Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/ports/unix/mpthreadport.h b/ports/unix/mpthreadport.h
index b158ed5bc..bd712ebee 100644
--- a/ports/unix/mpthreadport.h
+++ b/ports/unix/mpthreadport.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd
+ * SPDX-FileCopyrightText: Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/ports/unix/qstrdefsport.h b/ports/unix/qstrdefsport.h
index ebfaa6cca..873e83272 100644
--- a/ports/unix/qstrdefsport.h
+++ b/ports/unix/qstrdefsport.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/ports/unix/unix_mphal.c b/ports/unix/unix_mphal.c
index f27c62fd1..e9494d7ff 100644
--- a/ports/unix/unix_mphal.c
+++ b/ports/unix/unix_mphal.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2015 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2015 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/argcheck.c b/py/argcheck.c
index a8df206e2..9341c02a6 100644
--- a/py/argcheck.c
+++ b/py/argcheck.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/asmarm.c b/py/asmarm.c
index 1a8923bc2..11e498b2c 100644
--- a/py/asmarm.c
+++ b/py/asmarm.c
@@ -4,7 +4,7 @@
* The MIT License (MIT)
*
* Copyright (c) 2014 Fabian Vogt
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/asmarm.h b/py/asmarm.h
index 560303091..f63106a9b 100644
--- a/py/asmarm.h
+++ b/py/asmarm.h
@@ -4,7 +4,7 @@
* The MIT License (MIT)
*
* Copyright (c) 2014 Fabian Vogt
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/asmbase.c b/py/asmbase.c
index 4c84c3b25..4d080f095 100644
--- a/py/asmbase.c
+++ b/py/asmbase.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2016 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 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
diff --git a/py/asmbase.h b/py/asmbase.h
index d2b403893..3b2f59d15 100644
--- a/py/asmbase.h
+++ b/py/asmbase.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2016 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 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
diff --git a/py/asmthumb.c b/py/asmthumb.c
index c5b45f2f5..3cf47c5b1 100644
--- a/py/asmthumb.c
+++ b/py/asmthumb.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/asmthumb.h b/py/asmthumb.h
index b7e2acc04..32219eb55 100644
--- a/py/asmthumb.h
+++ b/py/asmthumb.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/asmx64.c b/py/asmx64.c
index c900a08d1..8706b806e 100644
--- a/py/asmx64.c
+++ b/py/asmx64.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/asmx64.h b/py/asmx64.h
index ed0b785fb..113d92511 100644
--- a/py/asmx64.h
+++ b/py/asmx64.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/asmx86.c b/py/asmx86.c
index 3938baaac..8a08c68a0 100644
--- a/py/asmx86.c
+++ b/py/asmx86.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/asmx86.h b/py/asmx86.h
index 0908b8c71..05902350f 100644
--- a/py/asmx86.h
+++ b/py/asmx86.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/asmxtensa.c b/py/asmxtensa.c
index 00448dfc5..98b49ecb5 100644
--- a/py/asmxtensa.c
+++ b/py/asmxtensa.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2016 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 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
diff --git a/py/asmxtensa.h b/py/asmxtensa.h
index ef80f700a..d43824338 100644
--- a/py/asmxtensa.h
+++ b/py/asmxtensa.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2016 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 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
diff --git a/py/bc.c b/py/bc.c
index 69b4cb238..640671338 100644
--- a/py/bc.c
+++ b/py/bc.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2014 Damien P. George
* Copyright (c) 2014 Paul Sokolovsky
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
diff --git a/py/bc.h b/py/bc.h
index ebfdeaac1..b71325f92 100644
--- a/py/bc.h
+++ b/py/bc.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/bc0.h b/py/bc0.h
index 70acfb0ca..a031bcc88 100644
--- a/py/bc0.h
+++ b/py/bc0.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/binary.c b/py/binary.c
index 2ec12fa93..cd0f1aa4d 100644
--- a/py/binary.c
+++ b/py/binary.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/binary.h b/py/binary.h
index 0dae6a29e..6c70d9333 100644
--- a/py/binary.h
+++ b/py/binary.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/builtin.h b/py/builtin.h
index 6e0d5d9be..2275691fc 100644
--- a/py/builtin.h
+++ b/py/builtin.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/builtinevex.c b/py/builtinevex.c
index cb046b407..ade12d39d 100644
--- a/py/builtinevex.c
+++ b/py/builtinevex.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/builtinhelp.c b/py/builtinhelp.c
index 01c0bc84e..d12e088d6 100644
--- a/py/builtinhelp.c
+++ b/py/builtinhelp.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013-2016 Damien P. George
+ * SPDX-FileCopyrightText: 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
diff --git a/py/builtinimport.c b/py/builtinimport.c
index 2be779c6c..597819f55 100644
--- a/py/builtinimport.c
+++ b/py/builtinimport.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
* Copyright (c) 2014 Paul Sokolovsky
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk
index 74d8f548d..a39e0c9dd 100644
--- a/py/circuitpy_defns.mk
+++ b/py/circuitpy_defns.mk
@@ -2,7 +2,7 @@
#
# The MIT License (MIT)
#
-# Copyright (c) 2019 Dan Halbert for Adafruit Industries
+# SPDX-FileCopyrightText: Copyright (c) 2019 Dan Halbert for Adafruit Industries
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
@@ -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
@@ -213,6 +216,12 @@ endif
ifeq ($(CIRCUITPY_SAMD),1)
SRC_PATTERNS += samd/%
endif
+ifeq ($(CIRCUITPY_SDCARDIO),1)
+SRC_PATTERNS += sdcardio/%
+endif
+ifeq ($(CIRCUITPY_SDIOIO),1)
+SRC_PATTERNS += sdioio/%
+endif
ifeq ($(CIRCUITPY_STAGE),1)
SRC_PATTERNS += _stage/%
endif
@@ -311,6 +320,8 @@ SRC_COMMON_HAL_ALL = \
rotaryio/__init__.c \
rtc/RTC.c \
rtc/__init__.c \
+ sdioio/SDCard.c \
+ sdioio/__init__.c \
supervisor/Runtime.c \
supervisor/__init__.c \
watchdog/WatchDogMode.c \
@@ -384,10 +395,15 @@ SRC_SHARED_MODULE_ALL = \
fontio/__init__.c \
framebufferio/FramebufferDisplay.c \
framebufferio/__init__.c \
+ sdcardio/SDCard.c \
+ sdcardio/__init__.c \
gamepad/GamePad.c \
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 c92cb1b66..a1a7ec238 100644
--- a/py/circuitpy_mpconfig.h
+++ b/py/circuitpy_mpconfig.h
@@ -119,6 +119,7 @@
#define MICROPY_QSTR_BYTES_IN_HASH (1)
#define MICROPY_REPL_AUTO_INDENT (1)
#define MICROPY_REPL_EVENT_DRIVEN (0)
+#define MICROPY_ENABLE_PYSTACK (1)
#define MICROPY_STACK_CHECK (1)
#define MICROPY_STREAMS_NON_BLOCK (1)
#ifndef MICROPY_USE_INTERNAL_PRINTF
@@ -429,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 },
@@ -537,6 +548,20 @@ extern const struct _mp_obj_module_t samd_module;
#define SAMD_MODULE
#endif
+#if CIRCUITPY_SDCARDIO
+extern const struct _mp_obj_module_t sdcardio_module;
+#define SDCARDIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_sdcardio), (mp_obj_t)&sdcardio_module },
+#else
+#define SDCARDIO_MODULE
+#endif
+
+#if CIRCUITPY_SDIOIO
+extern const struct _mp_obj_module_t sdioio_module;
+#define SDIOIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_sdioio), (mp_obj_t)&sdioio_module },
+#else
+#define SDIOIO_MODULE
+#endif
+
#if CIRCUITPY_STAGE
extern const struct _mp_obj_module_t stage_module;
#define STAGE_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR__stage), (mp_obj_t)&stage_module },
@@ -694,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 \
@@ -709,6 +735,8 @@ extern const struct _mp_obj_module_t watchdog_module;
ROTARYIO_MODULE \
RTC_MODULE \
SAMD_MODULE \
+ SDCARDIO_MODULE \
+ SDIOIO_MODULE \
STAGE_MODULE \
STORAGE_MODULE \
STRUCT_MODULE \
@@ -749,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);
@@ -769,6 +798,10 @@ void supervisor_run_background_tasks_if_tick(void);
#define CIRCUITPY_FILESYSTEM_FLUSH_INTERVAL_MS 1000
#endif
+#ifndef CIRCUITPY_PYSTACK_SIZE
+#define CIRCUITPY_PYSTACK_SIZE 1024
+#endif
+
#define CIRCUITPY_BOOT_OUTPUT_FILE "/boot_out.txt"
#define CIRCUITPY_VERBOSE_BLE 0
diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk
index 3459bff6d..baa29e26b 100644
--- a/py/circuitpy_mpconfig.mk
+++ b/py/circuitpy_mpconfig.mk
@@ -3,7 +3,7 @@
#
# The MIT License (MIT)
#
-# Copyright (c) 2019 Dan Halbert for Adafruit Industries
+# SPDX-FileCopyrightText: Copyright (c) 2019 Dan Halbert for Adafruit Industries
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
@@ -45,9 +45,6 @@ CFLAGS += -DCIRCUITPY_AUDIOBUSIO=$(CIRCUITPY_AUDIOBUSIO)
CIRCUITPY_AUDIOIO ?= $(CIRCUITPY_FULL_BUILD)
CFLAGS += -DCIRCUITPY_AUDIOIO=$(CIRCUITPY_AUDIOIO)
-CIRCUITPY_AUDIOIO_COMPAT ?= $(CIRCUITPY_AUDIOIO)
-CFLAGS += -DCIRCUITPY_AUDIOIO_COMPAT=$(CIRCUITPY_AUDIOIO_COMPAT)
-
CIRCUITPY_AUDIOPWMIO ?= 0
CFLAGS += -DCIRCUITPY_AUDIOPWMIO=$(CIRCUITPY_AUDIOPWMIO)
@@ -121,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)
@@ -166,6 +166,12 @@ CFLAGS += -DCIRCUITPY_RTC=$(CIRCUITPY_RTC)
CIRCUITPY_SAMD ?= 0
CFLAGS += -DCIRCUITPY_SAMD=$(CIRCUITPY_SAMD)
+CIRCUITPY_SDCARDIO ?= $(CIRCUITPY_FULL_BUILD)
+CFLAGS += -DCIRCUITPY_SDCARDIO=$(CIRCUITPY_SDCARDIO)
+
+CIRCUITPY_SDIOIO ?= 0
+CFLAGS += -DCIRCUITPY_SDIOIO=$(CIRCUITPY_SDIOIO)
+
# Currently always off.
CIRCUITPY_STAGE ?= 0
CFLAGS += -DCIRCUITPY_STAGE=$(CIRCUITPY_STAGE)
diff --git a/py/compile.c b/py/compile.c
index d5fae0299..fade4c01a 100644
--- a/py/compile.c
+++ b/py/compile.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013-2015 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013-2015 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
@@ -1713,11 +1713,11 @@ STATIC void compile_yield_from(compiler_t *comp) {
#if MICROPY_PY_ASYNC_AWAIT
STATIC bool compile_require_async_context(compiler_t *comp, mp_parse_node_struct_t *pns) {
int scope_flags = comp->scope_cur->scope_flags;
- if(scope_flags & MP_SCOPE_FLAG_GENERATOR) {
+ if(scope_flags & MP_SCOPE_FLAG_ASYNC) {
return true;
}
compile_syntax_error(comp, (mp_parse_node_t)pns,
- translate("'async for' or 'async with' outside async function"));
+ translate("'await', 'async for' or 'async with' outside async function"));
return false;
}
@@ -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);
@@ -2645,6 +2645,7 @@ STATIC void compile_atom_expr_await(compiler_t *comp, mp_parse_node_struct_t *pn
compile_syntax_error(comp, (mp_parse_node_t)pns, translate("'await' outside function"));
return;
}
+ compile_require_async_context(comp, pns);
compile_atom_expr_normal(comp, pns);
compile_yield_from(comp);
}
diff --git a/py/compile.h b/py/compile.h
index 3297e83ae..0f8d023a2 100644
--- a/py/compile.h
+++ b/py/compile.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/emit.h b/py/emit.h
index aa98efa77..30543d2a3 100644
--- a/py/emit.h
+++ b/py/emit.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/emitbc.c b/py/emitbc.c
index f3951e9cb..f45dcb916 100644
--- a/py/emitbc.c
+++ b/py/emitbc.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/emitcommon.c b/py/emitcommon.c
index 89cc2c959..88c9803a6 100644
--- a/py/emitcommon.c
+++ b/py/emitcommon.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/emitglue.c b/py/emitglue.c
index 7708689dd..7635a73d6 100644
--- a/py/emitglue.c
+++ b/py/emitglue.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 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
@@ -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/emitglue.h b/py/emitglue.h
index 0830a0d5c..2ddcc3e53 100644
--- a/py/emitglue.h
+++ b/py/emitglue.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/emitinlinethumb.c b/py/emitinlinethumb.c
index 7f0ec6659..47ed14321 100644
--- a/py/emitinlinethumb.c
+++ b/py/emitinlinethumb.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/emitinlinextensa.c b/py/emitinlinextensa.c
index 9cd65824b..ae84aae2e 100644
--- a/py/emitinlinextensa.c
+++ b/py/emitinlinextensa.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013-2016 Damien P. George
+ * SPDX-FileCopyrightText: 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
diff --git a/py/emitnative.c b/py/emitnative.c
index 60f31d15f..51919e389 100644
--- a/py/emitnative.c
+++ b/py/emitnative.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/formatfloat.c b/py/formatfloat.c
index dc7fc1d1f..166a98a2e 100644
--- a/py/formatfloat.c
+++ b/py/formatfloat.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/formatfloat.h b/py/formatfloat.h
index 9a1643b4d..c433cb805 100644
--- a/py/formatfloat.h
+++ b/py/formatfloat.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/frozenmod.c b/py/frozenmod.c
index a9143b582..0e040a44f 100644
--- a/py/frozenmod.c
+++ b/py/frozenmod.c
@@ -4,7 +4,7 @@
* The MIT License (MIT)
*
* Copyright (c) 2015 Paul Sokolovsky
- * Copyright (c) 2016 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 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
diff --git a/py/frozenmod.h b/py/frozenmod.h
index 1e50f3807..3ba1b590d 100644
--- a/py/frozenmod.h
+++ b/py/frozenmod.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/gc.c b/py/gc.c
index 271bc9462..69327060f 100755
--- a/py/gc.c
+++ b/py/gc.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 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
@@ -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/gc.h b/py/gc.h
index 2a0811f4e..b7c2889d5 100644
--- a/py/gc.h
+++ b/py/gc.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/grammar.h b/py/grammar.h
index 5a5b682ac..28f785039 100644
--- a/py/grammar.h
+++ b/py/grammar.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013-2015 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013-2015 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/ioctl.h b/py/ioctl.h
index ced427590..8c84835cc 100644
--- a/py/ioctl.h
+++ b/py/ioctl.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013-2015 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013-2015 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/lexer.c b/py/lexer.c
index 00cd59bca..de121f87a 100644
--- a/py/lexer.c
+++ b/py/lexer.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/lexer.h b/py/lexer.h
index a3eaa2a7e..74195fe03 100644
--- a/py/lexer.h
+++ b/py/lexer.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/malloc.c b/py/malloc.c
index f190582ab..8d5141ee0 100644
--- a/py/malloc.c
+++ b/py/malloc.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/map.c b/py/map.c
index 57c11dbc9..69eed9d3b 100644
--- a/py/map.c
+++ b/py/map.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/misc.h b/py/misc.h
index 673568f22..944c0a716 100644
--- a/py/misc.h
+++ b/py/misc.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/modarray.c b/py/modarray.c
index c0cdca928..75bc5169f 100644
--- a/py/modarray.c
+++ b/py/modarray.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/modbuiltins.c b/py/modbuiltins.c
index e764f1987..905c3471f 100644
--- a/py/modbuiltins.c
+++ b/py/modbuiltins.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/modcmath.c b/py/modcmath.c
index 70fd542af..d6b364733 100644
--- a/py/modcmath.c
+++ b/py/modcmath.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/modcollections.c b/py/modcollections.c
index 91e735528..9634c5ce7 100644
--- a/py/modcollections.c
+++ b/py/modcollections.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/modgc.c b/py/modgc.c
index 55e73defc..b01876422 100644
--- a/py/modgc.c
+++ b/py/modgc.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/modio.c b/py/modio.c
index 17840a6d8..4bcc3971e 100644
--- a/py/modio.c
+++ b/py/modio.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/modmath.c b/py/modmath.c
index 9d75ea2d5..ec520bb6f 100644
--- a/py/modmath.c
+++ b/py/modmath.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013-2017 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013-2017 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/modmicropython.c b/py/modmicropython.c
index a45d44653..7e29825ae 100644
--- a/py/modmicropython.c
+++ b/py/modmicropython.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/modstruct.c b/py/modstruct.c
index a238d3935..fe766a4de 100644
--- a/py/modstruct.c
+++ b/py/modstruct.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
* Copyright (c) 2014 Paul Sokolovsky
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
diff --git a/py/modsys.c b/py/modsys.c
index 68e048d91..a1d2cf831 100644
--- a/py/modsys.c
+++ b/py/modsys.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
* Copyright (c) 2014-2017 Paul Sokolovsky
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
diff --git a/py/modthread.c b/py/modthread.c
index 1c00f6397..250756ef2 100644
--- a/py/modthread.c
+++ b/py/modthread.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd
+ * SPDX-FileCopyrightText: Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/moduerrno.c b/py/moduerrno.c
index 3be5adba1..3928f8cd8 100644
--- a/py/moduerrno.c
+++ b/py/moduerrno.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2016 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 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
diff --git a/py/mpconfig.h b/py/mpconfig.h
index 513f04f6e..034d39d40 100755
--- a/py/mpconfig.h
+++ b/py/mpconfig.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/mperrno.h b/py/mperrno.h
index 911a9b413..e339fde85 100644
--- a/py/mperrno.h
+++ b/py/mperrno.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2016 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 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
diff --git a/py/mphal.h b/py/mphal.h
index 92de01d08..c242dd245 100644
--- a/py/mphal.h
+++ b/py/mphal.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2015 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2015 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/mpprint.c b/py/mpprint.c
index c2e65301c..e814d2ebe 100644
--- a/py/mpprint.c
+++ b/py/mpprint.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013-2015 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013-2015 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/mpprint.h b/py/mpprint.h
index 07462bddc..0d12b9a3d 100644
--- a/py/mpprint.h
+++ b/py/mpprint.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/mpstate.c b/py/mpstate.c
index 32f1d60a5..b3957cc09 100644
--- a/py/mpstate.c
+++ b/py/mpstate.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/mpstate.h b/py/mpstate.h
index a5815776a..32f353528 100644
--- a/py/mpstate.h
+++ b/py/mpstate.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/mpthread.h b/py/mpthread.h
index 602df830c..3a6983e9d 100644
--- a/py/mpthread.h
+++ b/py/mpthread.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd
+ * SPDX-FileCopyrightText: Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/mpz.c b/py/mpz.c
index 8687092d0..41b46f92f 100644
--- a/py/mpz.c
+++ b/py/mpz.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 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
@@ -444,6 +444,10 @@ STATIC size_t mpn_mul(mpz_dig_t *idig, mpz_dig_t *jdig, size_t jlen, mpz_dig_t *
}
ilen = id - oidig;
+ // check to prevent usb starvation
+ #ifdef RUN_BACKGROUND_TASKS
+ RUN_BACKGROUND_TASKS;
+ #endif
}
return ilen;
diff --git a/py/mpz.h b/py/mpz.h
index 3c36cac66..e412f5cce 100644
--- a/py/mpz.h
+++ b/py/mpz.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/nativeglue.c b/py/nativeglue.c
index b87da6931..9ac806009 100644
--- a/py/nativeglue.c
+++ b/py/nativeglue.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/nlr.c b/py/nlr.c
index 1bfd9c19b..95d833177 100644
--- a/py/nlr.c
+++ b/py/nlr.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013-2017 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013-2017 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/nlr.h b/py/nlr.h
index 1b95002d3..aed24e277 100644
--- a/py/nlr.h
+++ b/py/nlr.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/nlrsetjmp.c b/py/nlrsetjmp.c
index 960dd86f5..a93595dc8 100644
--- a/py/nlrsetjmp.c
+++ b/py/nlrsetjmp.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013-2017 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013-2017 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/nlrthumb.c b/py/nlrthumb.c
index 056aa358e..464995fa8 100644
--- a/py/nlrthumb.c
+++ b/py/nlrthumb.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013-2017 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013-2017 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/nlrx64.c b/py/nlrx64.c
index 569ad84fb..246d6a95b 100644
--- a/py/nlrx64.c
+++ b/py/nlrx64.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013-2017 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013-2017 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/nlrx86.c b/py/nlrx86.c
index 6fbbe4432..18306253d 100644
--- a/py/nlrx86.c
+++ b/py/nlrx86.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013-2017 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013-2017 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/nlrxtensa.c b/py/nlrxtensa.c
index 564035004..e04535ff8 100644
--- a/py/nlrxtensa.c
+++ b/py/nlrxtensa.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2014-2017 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2014-2017 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/obj.c b/py/obj.c
index 4fa2032dc..7644b5de8 100644
--- a/py/obj.c
+++ b/py/obj.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/obj.h b/py/obj.h
index fa315d12f..e603d4a49 100644
--- a/py/obj.h
+++ b/py/obj.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 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
@@ -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/objarray.c b/py/objarray.c
index fccb966a2..5d83f0697 100644
--- a/py/objarray.c
+++ b/py/objarray.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
* Copyright (c) 2014 Paul Sokolovsky
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -400,6 +400,66 @@ STATIC mp_obj_t array_extend(mp_obj_t self_in, mp_obj_t arg_in) {
STATIC MP_DEFINE_CONST_FUN_OBJ_2(array_extend_obj, array_extend);
#endif
+#if MICROPY_PY_BUILTINS_BYTEARRAY && MICROPY_CPYTHON_COMPAT
+STATIC mp_obj_t buffer_finder(size_t n_args, const mp_obj_t *args, int direction, bool is_index) {
+ mp_check_self(MP_OBJ_IS_TYPE(args[0], &mp_type_bytearray));
+ const mp_obj_type_t *self_type = mp_obj_get_type(args[0]);
+
+ mp_buffer_info_t haystack_bufinfo;
+ mp_get_buffer_raise(args[0], &haystack_bufinfo, MP_BUFFER_READ);
+
+ mp_buffer_info_t needle_bufinfo;
+ mp_get_buffer_raise(args[1], &needle_bufinfo, MP_BUFFER_READ);
+
+ if (mp_binary_get_size('@', needle_bufinfo.typecode, NULL) != 1) {
+ mp_raise_TypeError(translate("a bytes-like object is required"));
+ }
+
+ const byte *start = haystack_bufinfo.buf;
+ const byte *end = ((const byte*)haystack_bufinfo.buf) + haystack_bufinfo.len;
+ if (n_args >= 3 && args[2] != mp_const_none) {
+ start += mp_get_index(self_type, haystack_bufinfo.len, args[2], true);
+ }
+ if (n_args >= 4 && args[3] != mp_const_none) {
+ end = ((const byte*)haystack_bufinfo.buf) + mp_get_index(self_type, haystack_bufinfo.len, args[3], true);
+ }
+
+ const byte *p = NULL;
+ if (end >= start) {
+ p = find_subbytes(start, end - start, needle_bufinfo.buf, needle_bufinfo.len, direction);
+ }
+
+ if (p == NULL) {
+ if (is_index) {
+ mp_raise_ValueError(translate("substring not found"));
+ } else {
+ return MP_OBJ_NEW_SMALL_INT(-1);
+ }
+ }
+ return MP_OBJ_NEW_SMALL_INT(p - (const byte*) haystack_bufinfo.buf);
+}
+
+STATIC mp_obj_t buffer_find(size_t n_args, const mp_obj_t *args) {
+ return buffer_finder(n_args, args, 1, false);
+}
+MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(buffer_find_obj, 2, 4, buffer_find);
+
+STATIC mp_obj_t buffer_rfind(size_t n_args, const mp_obj_t *args) {
+ return buffer_finder(n_args, args, -1, false);
+}
+MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(buffer_rfind_obj, 2, 4, buffer_rfind);
+
+STATIC mp_obj_t buffer_index(size_t n_args, const mp_obj_t *args) {
+ return buffer_finder(n_args, args, 1, true);
+}
+MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(buffer_index_obj, 2, 4, buffer_index);
+
+STATIC mp_obj_t buffer_rindex(size_t n_args, const mp_obj_t *args) {
+ return buffer_finder(n_args, args, -1, true);
+}
+MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(buffer_rindex_obj, 2, 4, buffer_rindex);
+#endif
+
STATIC mp_obj_t array_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value) {
if (value == MP_OBJ_NULL) {
// delete item
@@ -580,7 +640,13 @@ STATIC MP_DEFINE_CONST_DICT(array_locals_dict, array_locals_dict_table);
STATIC const mp_rom_map_elem_t bytearray_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_append), MP_ROM_PTR(&array_append_obj) },
{ MP_ROM_QSTR(MP_QSTR_extend), MP_ROM_PTR(&array_extend_obj) },
+
#if MICROPY_CPYTHON_COMPAT
+ { MP_ROM_QSTR(MP_QSTR_find), MP_ROM_PTR(&buffer_find_obj) },
+ { MP_ROM_QSTR(MP_QSTR_rfind), MP_ROM_PTR(&buffer_rfind_obj) },
+ { MP_ROM_QSTR(MP_QSTR_index), MP_ROM_PTR(&buffer_index_obj) },
+ { MP_ROM_QSTR(MP_QSTR_rindex), MP_ROM_PTR(&buffer_rindex_obj) },
+
{ MP_ROM_QSTR(MP_QSTR_decode), MP_ROM_PTR(&array_decode_obj) },
#endif
};
diff --git a/py/objarray.h b/py/objarray.h
index 0dad70571..7ad5328f0 100644
--- a/py/objarray.h
+++ b/py/objarray.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
* Copyright (c) 2014 Paul Sokolovsky
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
diff --git a/py/objattrtuple.c b/py/objattrtuple.c
index 3cc298d4e..ac9b808a2 100644
--- a/py/objattrtuple.c
+++ b/py/objattrtuple.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2015 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2015 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/objbool.c b/py/objbool.c
index cd7d7100c..5e8f630ff 100644
--- a/py/objbool.c
+++ b/py/objbool.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/objboundmeth.c b/py/objboundmeth.c
index a05680d41..5bf25567f 100644
--- a/py/objboundmeth.c
+++ b/py/objboundmeth.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/objcell.c b/py/objcell.c
index 111906412..25fe5232a 100644
--- a/py/objcell.c
+++ b/py/objcell.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/objclosure.c b/py/objclosure.c
index 4eb9eb8b8..6f6772ff1 100644
--- a/py/objclosure.c
+++ b/py/objclosure.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/objcomplex.c b/py/objcomplex.c
index b38e2c5fa..43e0690d3 100644
--- a/py/objcomplex.c
+++ b/py/objcomplex.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/objdict.c b/py/objdict.c
index 3ec3cbe80..39169fe1a 100644
--- a/py/objdict.c
+++ b/py/objdict.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/objenumerate.c b/py/objenumerate.c
index 818725d85..dee7fc760 100644
--- a/py/objenumerate.c
+++ b/py/objenumerate.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/objexcept.c b/py/objexcept.c
index 796be122f..e3b953543 100644
--- a/py/objexcept.c
+++ b/py/objexcept.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/objexcept.h b/py/objexcept.h
index 7c3076224..c19658427 100644
--- a/py/objexcept.h
+++ b/py/objexcept.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/objfilter.c b/py/objfilter.c
index af95326e6..0e02f4b5e 100644
--- a/py/objfilter.c
+++ b/py/objfilter.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/objfloat.c b/py/objfloat.c
index f544ade05..59f1eb2f6 100644
--- a/py/objfloat.c
+++ b/py/objfloat.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/objfun.c b/py/objfun.c
index c586a290a..933044ef7 100644
--- a/py/objfun.c
+++ b/py/objfun.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
* Copyright (c) 2014 Paul Sokolovsky
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
diff --git a/py/objfun.h b/py/objfun.h
index fbb351626..457c3cf48 100644
--- a/py/objfun.h
+++ b/py/objfun.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/objgenerator.c b/py/objgenerator.c
index 01d42ba94..df421b60c 100644
--- a/py/objgenerator.c
+++ b/py/objgenerator.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
* Copyright (c) 2014-2017 Paul Sokolovsky
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -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/objgenerator.h b/py/objgenerator.h
index 80bf9cd86..4b7f8c1ac 100644
--- a/py/objgenerator.h
+++ b/py/objgenerator.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/objgetitemiter.c b/py/objgetitemiter.c
index ec41c2c5b..44e8fe889 100644
--- a/py/objgetitemiter.c
+++ b/py/objgetitemiter.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/objint.c b/py/objint.c
index b78c9f25b..82f5aadd1 100644
--- a/py/objint.c
+++ b/py/objint.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/objint.h b/py/objint.h
index e8c9bc3e0..bba9ff50a 100644
--- a/py/objint.h
+++ b/py/objint.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/objint_longlong.c b/py/objint_longlong.c
index ce02fa175..189049630 100644
--- a/py/objint_longlong.c
+++ b/py/objint_longlong.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
* Copyright (c) 2014 Paul Sokolovsky
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
diff --git a/py/objint_mpz.c b/py/objint_mpz.c
index 95e4d7e17..90060114e 100644
--- a/py/objint_mpz.c
+++ b/py/objint_mpz.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/objlist.c b/py/objlist.c
index 608ea9f6c..9242020d4 100644
--- a/py/objlist.c
+++ b/py/objlist.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/objlist.h b/py/objlist.h
index a43663db7..f02030557 100644
--- a/py/objlist.h
+++ b/py/objlist.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/objmap.c b/py/objmap.c
index cf71f99ee..5cf975f49 100644
--- a/py/objmap.c
+++ b/py/objmap.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/objmodule.c b/py/objmodule.c
index b6a8a084e..757aece04 100644
--- a/py/objmodule.c
+++ b/py/objmodule.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/objmodule.h b/py/objmodule.h
index b7702ec50..0b9b2d130 100644
--- a/py/objmodule.h
+++ b/py/objmodule.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/objnamedtuple.c b/py/objnamedtuple.c
index 84dcf7909..6c36909e7 100644
--- a/py/objnamedtuple.c
+++ b/py/objnamedtuple.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
* Copyright (c) 2014 Paul Sokolovsky
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
diff --git a/py/objnamedtuple.h b/py/objnamedtuple.h
index 0ea0d2862..9f290c3ec 100644
--- a/py/objnamedtuple.h
+++ b/py/objnamedtuple.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
* Copyright (c) 2014 Paul Sokolovsky
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
diff --git a/py/objnone.c b/py/objnone.c
index da1031835..b1fbd48f7 100644
--- a/py/objnone.c
+++ b/py/objnone.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/objobject.c b/py/objobject.c
index a42edde3c..8983cd9ad 100644
--- a/py/objobject.c
+++ b/py/objobject.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/objproperty.c b/py/objproperty.c
index ddf484af2..e909533c4 100644
--- a/py/objproperty.c
+++ b/py/objproperty.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/objproperty.h b/py/objproperty.h
index f95c1083c..f3ade89d9 100644
--- a/py/objproperty.h
+++ b/py/objproperty.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/objrange.c b/py/objrange.c
index 30d55c56c..7af9f37a1 100644
--- a/py/objrange.c
+++ b/py/objrange.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/objreversed.c b/py/objreversed.c
index 4937d0818..63d122b5d 100644
--- a/py/objreversed.c
+++ b/py/objreversed.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/objset.c b/py/objset.c
index 5d1608c7e..d986c6dda 100644
--- a/py/objset.c
+++ b/py/objset.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013-2017 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013-2017 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/objsingleton.c b/py/objsingleton.c
index 67535391e..1c2757334 100644
--- a/py/objsingleton.c
+++ b/py/objsingleton.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/objslice.c b/py/objslice.c
index cbbee326e..40d4d3c76 100644
--- a/py/objslice.c
+++ b/py/objslice.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/objstr.c b/py/objstr.c
index a60f507e9..5e0c6fdfa 100644
--- a/py/objstr.c
+++ b/py/objstr.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
* Copyright (c) 2014 Paul Sokolovsky
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
diff --git a/py/objstr.h b/py/objstr.h
index 61a11d0bd..cddc6a83a 100644
--- a/py/objstr.h
+++ b/py/objstr.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 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
@@ -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/objstringio.c b/py/objstringio.c
index 178e6446c..eb40e5154 100644
--- a/py/objstringio.c
+++ b/py/objstringio.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
* Copyright (c) 2014 Paul Sokolovsky
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
diff --git a/py/objstringio.h b/py/objstringio.h
index 56738f4e4..38778f03a 100644
--- a/py/objstringio.h
+++ b/py/objstringio.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2016 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 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
diff --git a/py/objstrunicode.c b/py/objstrunicode.c
index 30000a51e..351a67e91 100644
--- a/py/objstrunicode.c
+++ b/py/objstrunicode.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
* Copyright (c) 2014 Paul Sokolovsky
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
diff --git a/py/objtuple.c b/py/objtuple.c
index 0a2ed6f4c..d34a7f762 100644
--- a/py/objtuple.c
+++ b/py/objtuple.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/objtuple.h b/py/objtuple.h
index 7f20ab7b6..d2e87e994 100644
--- a/py/objtuple.h
+++ b/py/objtuple.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/objtype.c b/py/objtype.c
index ad68b85d2..fd51ce36b 100644
--- a/py/objtype.c
+++ b/py/objtype.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013-2018 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013-2018 Damien P. George
* Copyright (c) 2014-2016 Paul Sokolovsky
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
diff --git a/py/objtype.h b/py/objtype.h
index a32c87496..a44622ffe 100644
--- a/py/objtype.h
+++ b/py/objtype.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/objzip.c b/py/objzip.c
index ce9afd55d..885e46441 100644
--- a/py/objzip.c
+++ b/py/objzip.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/opmethods.c b/py/opmethods.c
index 247fa5bbc..07d1e340d 100644
--- a/py/opmethods.c
+++ b/py/opmethods.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/parse.c b/py/parse.c
index b8cfda2cb..28621cf89 100644
--- a/py/parse.c
+++ b/py/parse.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013-2017 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013-2017 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/parse.h b/py/parse.h
index 9a1a2b4dd..946b41eac 100644
--- a/py/parse.h
+++ b/py/parse.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/parsenum.c b/py/parsenum.c
index 6ef309b47..da63825e4 100644
--- a/py/parsenum.c
+++ b/py/parsenum.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/parsenum.h b/py/parsenum.h
index a5bed731d..a91ca532d 100644
--- a/py/parsenum.h
+++ b/py/parsenum.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/parsenumbase.c b/py/parsenumbase.c
index ba1059122..e4ac6d00e 100644
--- a/py/parsenumbase.c
+++ b/py/parsenumbase.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/parsenumbase.h b/py/parsenumbase.h
index 3a525f993..43dcc2353 100644
--- a/py/parsenumbase.h
+++ b/py/parsenumbase.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/persistentcode.c b/py/persistentcode.c
index eb69bd407..9b438453a 100644
--- a/py/persistentcode.c
+++ b/py/persistentcode.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013-2016 Damien P. George
+ * SPDX-FileCopyrightText: 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
diff --git a/py/persistentcode.h b/py/persistentcode.h
index d04e0b633..cbb300e4b 100644
--- a/py/persistentcode.h
+++ b/py/persistentcode.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013-2016 Damien P. George
+ * SPDX-FileCopyrightText: 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
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/pystack.c b/py/pystack.c
index 552e59d53..f79ea9210 100644
--- a/py/pystack.c
+++ b/py/pystack.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2017 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2017 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/pystack.h b/py/pystack.h
index 82ac3743d..3fbcdeeb8 100644
--- a/py/pystack.h
+++ b/py/pystack.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2017 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2017 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/qstr.c b/py/qstr.c
index bb8024435..17d8517c9 100755
--- a/py/qstr.c
+++ b/py/qstr.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/qstr.h b/py/qstr.h
index 39b904fb1..070a3cd4f 100644
--- a/py/qstr.h
+++ b/py/qstr.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/qstrdefs.h b/py/qstrdefs.h
index a60905812..b68267197 100644
--- a/py/qstrdefs.h
+++ b/py/qstrdefs.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/reader.c b/py/reader.c
index 80364104b..1b0bbf094 100644
--- a/py/reader.c
+++ b/py/reader.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013-2016 Damien P. George
+ * SPDX-FileCopyrightText: 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
diff --git a/py/reader.h b/py/reader.h
index 8511c72ce..6d8565d7b 100644
--- a/py/reader.h
+++ b/py/reader.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013-2016 Damien P. George
+ * SPDX-FileCopyrightText: 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
diff --git a/py/repl.c b/py/repl.c
index aa91c3f12..785c0fb53 100644
--- a/py/repl.c
+++ b/py/repl.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013-2015 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013-2015 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/repl.h b/py/repl.h
index a7a4136ca..89b64c45f 100644
--- a/py/repl.h
+++ b/py/repl.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/runtime.c b/py/runtime.c
index 59dcbc7a1..91ead1fba 100644
--- a/py/runtime.c
+++ b/py/runtime.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/runtime.h b/py/runtime.h
index f81103557..d3a82333e 100644
--- a/py/runtime.h
+++ b/py/runtime.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/runtime0.h b/py/runtime0.h
index 16434b315..fb35c8a9f 100644
--- a/py/runtime0.h
+++ b/py/runtime0.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 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
@@ -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/py/scheduler.c b/py/scheduler.c
index 30851a4d2..fea7e0153 100644
--- a/py/scheduler.c
+++ b/py/scheduler.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2017 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2017 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/scope.c b/py/scope.c
index 1a6ae7b8a..98f39d4c6 100644
--- a/py/scope.c
+++ b/py/scope.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/scope.h b/py/scope.h
index e3b6a57c7..c92a39e5e 100644
--- a/py/scope.h
+++ b/py/scope.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/sequence.c b/py/sequence.c
index 0e668ea2a..e6421fde5 100644
--- a/py/sequence.c
+++ b/py/sequence.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
* Copyright (c) 2014 Paul Sokolovsky
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
diff --git a/py/showbc.c b/py/showbc.c
index e71d8a253..5a8e660fc 100644
--- a/py/showbc.c
+++ b/py/showbc.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/smallint.c b/py/smallint.c
index aa542ca7b..9124b76c1 100644
--- a/py/smallint.c
+++ b/py/smallint.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/smallint.h b/py/smallint.h
index 6a3c75236..c58584413 100644
--- a/py/smallint.h
+++ b/py/smallint.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/stream.c b/py/stream.c
index 2ff2b76a6..ae702bb1b 100644
--- a/py/stream.c
+++ b/py/stream.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
* Copyright (c) 2014 Paul Sokolovsky
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
diff --git a/py/stream.h b/py/stream.h
index dc9fc84c9..be6b23d40 100644
--- a/py/stream.h
+++ b/py/stream.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/unicode.c b/py/unicode.c
index 935dc9012..a17dbf969 100644
--- a/py/unicode.c
+++ b/py/unicode.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/unicode.h b/py/unicode.h
index c1fb51789..78e7a7ab7 100644
--- a/py/unicode.h
+++ b/py/unicode.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/vm.c b/py/vm.c
index 4f0340681..9b3354b09 100644
--- a/py/vm.c
+++ b/py/vm.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
* Copyright (c) 2014 Paul Sokolovsky
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
diff --git a/py/vmentrytable.h b/py/vmentrytable.h
index 31a96dbec..e01199eee 100644
--- a/py/vmentrytable.h
+++ b/py/vmentrytable.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/vstr.c b/py/vstr.c
index 91cd7f584..ccc567d10 100644
--- a/py/vstr.c
+++ b/py/vstr.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/py/warning.c b/py/warning.c
index 12d0f9c99..d516eabdd 100644
--- a/py/warning.c
+++ b/py/warning.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/setup.py b/setup.py
index 769bc66e1..d2989d068 100644
--- a/setup.py
+++ b/setup.py
@@ -1,3 +1,7 @@
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+#
+# SPDX-License-Identifier: MIT
+
from datetime import datetime
from setuptools import setup
from pathlib import Path
diff --git a/shared-bindings/_bleio/Adapter.c b/shared-bindings/_bleio/Adapter.c
index 13acb9d3c..f898d404a 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: ReadableBuffer, *, scan_response: Optional[ReadableBuffer] = 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: ReadableBuffer = b"", *, buffer_size: int = 512, extended: bool = False, timeout: Optional[float] = None, interval: float = 0.1, window: float = 0.1, minimum_rssi: int = -80, active: bool = True) -> Iterable[ScanEntry]:
//| """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,11 +350,11 @@ 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) -> Connection:
//| """Attempts a connection to the device with the given address.
//|
//| :param Address address: The address of the peripheral to connect to
-//| :param float/int timeout: Try to connect for timeout seconds."""
+//| :param float timeout: Try to connect for timeout seconds."""
//| ...
//|
STATIC mp_obj_t bleio_adapter_connect(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
@@ -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..94994fb70 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: Address) -> 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..2c144c71b 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..557a356b6 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: Optional[ReadableBuffer] = 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: bool = 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..7bcbc807e 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: 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
@@ -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..ed480ec04 100644
--- a/shared-bindings/_bleio/Connection.c
+++ b/shared-bindings/_bleio/Connection.c
@@ -68,14 +68,14 @@ 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.
+//| created by a peer, read the `Adapter.connections` property."""
//| ...
//|
-//| def disconnect(self, ) -> Any:
-//| ""Disconnects from the remote peripheral. Does nothing if already disconnected."""
+//| def disconnect(self) -> None:
+//| """Disconnects from the remote peripheral. Does nothing if already disconnected."""
//| ...
//|
STATIC mp_obj_t bleio_connection_disconnect(mp_obj_t self_in) {
@@ -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: Optional[Iterable[UUID]] = None) -> Tuple[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..e24751f75 100644
--- a/shared-bindings/_bleio/Descriptor.c
+++ b/shared-bindings/_bleio/Descriptor.c
@@ -39,31 +39,31 @@
//| 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()`
-//| as part of remote Characteristics in the remote Services that are discovered.
+//| as part of remote Characteristics in the remote Services that are discovered."""
//|
-//| .. classmethod:: add_to_characteristic(characteristic, uuid, *, read_perm=`Attribute.OPEN`, write_perm=`Attribute.OPEN`, max_length=20, fixed_length=False, initial_value=b'')
+//| @classmethod
+//| def add_to_characteristic(characteristic: Characteristic, uuid: UUID, *, read_perm: int = Attribute.OPEN, write_perm: int = Attribute.OPEN, max_length = 20, fixed_length: bool = False, initial_value: ReadableBuffer = b'') -> Descriptor:
+//| """Create a new Descriptor object, and add it to this Service.
//|
-//| Create a new Descriptor object, and add it to this Service.
+//| :param Characteristic characteristic: The characteristic that will hold this descriptor
+//| :param UUID uuid: The uuid of the descriptor
+//| :param int read_perm: Specifies whether the descriptor can be read by a client, and if so, which
+//| security mode is required. Must be one of the integer values `Attribute.NO_ACCESS`, `Attribute.OPEN`,
+//| `Attribute.ENCRYPT_NO_MITM`, `Attribute.ENCRYPT_WITH_MITM`, `Attribute.LESC_ENCRYPT_WITH_MITM`,
+//| `Attribute.SIGNED_NO_MITM`, or `Attribute.SIGNED_WITH_MITM`.
+//| :param int write_perm: Specifies whether the descriptor can be written by a client, and if so, which
+//| security mode is required. Values allowed are the same as ``read_perm``.
+//| :param int max_length: Maximum length in bytes of the descriptor value. The maximum allowed is
+//| is 512, or possibly 510 if ``fixed_length`` is False. The default, 20, is the maximum
+//| number of data bytes that fit in a single BLE 4.x ATT packet.
+//| :param bool fixed_length: True if the descriptor value is of fixed length.
+//| :param buf initial_value: The initial value for this descriptor.
//|
-//| :param Characteristic characteristic: The characteristic that will hold this descriptor
-//| :param UUID uuid: The uuid of the descriptor
-//| :param int read_perm: Specifies whether the descriptor can be read by a client, and if so, which
-//| security mode is required. Must be one of the integer values `Attribute.NO_ACCESS`, `Attribute.OPEN`,
-//| `Attribute.ENCRYPT_NO_MITM`, `Attribute.ENCRYPT_WITH_MITM`, `Attribute.LESC_ENCRYPT_WITH_MITM`,
-//| `Attribute.SIGNED_NO_MITM`, or `Attribute.SIGNED_WITH_MITM`.
-//| :param int write_perm: Specifies whether the descriptor can be written by a client, and if so, which
-//| security mode is required. Values allowed are the same as ``read_perm``.
-//| :param int max_length: Maximum length in bytes of the descriptor value. The maximum allowed is
-//| is 512, or possibly 510 if ``fixed_length`` is False. The default, 20, is the maximum
-//| number of data bytes that fit in a single BLE 4.x ATT packet.
-//| :param bool fixed_length: True if the descriptor value is of fixed length.
-//| :param buf initial_value: The initial value for this descriptor.
-//|
-//| :return: the new Descriptor."""
+//| :return: the new Descriptor."""
//| ...
//|
STATIC mp_obj_t bleio_descriptor_add_to_characteristic(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
@@ -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: bytearray
//| """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..8c8970939 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: ReadableBuffer, *, 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) {
@@ -179,12 +179,12 @@ STATIC mp_obj_t bleio_packet_buffer_deinit(mp_obj_t self_in) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_packet_buffer_deinit_obj, bleio_packet_buffer_deinit);
-//| packet_size: int = ...
+//| packet_size: int
//| """`packet_size` is the same as `incoming_packet_length`.
//| 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) {
@@ -205,7 +205,7 @@ const mp_obj_property_t bleio_packet_buffer_incoming_packet_length_obj = {
(mp_obj_t)&mp_const_none_obj },
};
-//| outgoing_packet_length: int = ...
+//| outgoing_packet_length: int
//| """Maximum length in bytes of a packet we are writing."""
//|
STATIC mp_obj_t bleio_packet_buffer_get_outgoing_packet_length(mp_obj_t self_in) {
diff --git a/shared-bindings/_bleio/ScanEntry.c b/shared-bindings/_bleio/ScanEntry.c
index 905bea81d..4f0789019 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..f410b1798 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..6d92cf793 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: UUID) -> 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..51d3d65ae 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: ReadableBuffer) -> 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..0563181d9 100644
--- a/shared-bindings/_pew/PewPew.c
+++ b/shared-bindings/_pew/PewPew.c
@@ -45,8 +45,31 @@
//| used internally by it. All user-visible interactions are done through
//| that library."""
//|
-
-//| def __init__(self, buffer: Any, rows: Any, cols: Any, buttons: Any):
+//| def __init__(
+//| self,
+//| buffer: ReadableBuffer,
+//| rows: List[
+//| digitalio.DigitalInOut,
+//| digitalio.DigitalInOut,
+//| digitalio.DigitalInOut,
+//| digitalio.DigitalInOut,
+//| digitalio.DigitalInOut,
+//| digitalio.DigitalInOut,
+//| digitalio.DigitalInOut,
+//| digitalio.DigitalInOut,
+//| ],
+//| cols: List[
+//| digitalio.DigitalInOut,
+//| digitalio.DigitalInOut,
+//| digitalio.DigitalInOut,
+//| digitalio.DigitalInOut,
+//| digitalio.DigitalInOut,
+//| digitalio.DigitalInOut,
+//| digitalio.DigitalInOut,
+//| digitalio.DigitalInOut,
+//| ],
+//| buttons: digitalio.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..abfe190d8 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: ReadableBuffer = b"", trailer: ReadableBuffer = 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: str
//| """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(self, 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,19 @@ 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:
+//| @overload
+//| def __getitem__(self, index: slice) -> Tuple[Tuple, ...]: ...
+//| def __getitem__(self, index: int) -> Tuple:
//| """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:
+//| @overload
+//| def __setitem__(self, index: slice, value: Tuple[Union[int, Tuple, List], ...]) -> None: ...
+//| @overload
+//| def __setitem__(self, index: slice, value: List[Union[int, Tuple, List]]) -> None: ...
+//| def __setitem__(self, index: int, value: Union[int, Tuple, List]) -> None:
//| """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..c714cade4 100644
--- a/shared-bindings/_pixelbuf/__init__.c
+++ b/shared-bindings/_pixelbuf/__init__.c
@@ -41,12 +41,12 @@
//| Byteorders are configured with strings, such as "RGB" or "RGBD"."""
// TODO: Pull in docs from pypixelbuf.
-//| def colorwheel(n: int) -> Any:
+//| def colorwheel(n: float) -> 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)."""
//| ...
//|
-//| def wheel(n: Any) -> Any:
+//| def wheel(n: float) -> int:
//| """Use of wheel() is deprecated. Please use colorwheel()."""
//|
diff --git a/shared-bindings/_stage/Layer.c b/shared-bindings/_stage/Layer.c
index 0f8260e53..269005ccf 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: ReadableBuffer, palette: ReadableBuffer, grid: ReadableBuffer) -> 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..464af1b98 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: ReadableBuffer, palette: ReadableBuffer, chars: ReadableBuffer) -> 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/_stage/__init__.c b/shared-bindings/_stage/__init__.c
index 6a5638185..6651b3e0b 100644
--- a/shared-bindings/_stage/__init__.c
+++ b/shared-bindings/_stage/__init__.c
@@ -39,7 +39,7 @@
//| The `_stage` module contains native code to speed-up the ```stage`` Library
//| <https://github.com/python-ugame/circuitpython-stage>`_."""
//|
-//| def render(x0: int, y0: int, x1: int, y1: int, layers: list, buffer: bytearray, display: displayio.Display, scale: int, background: int) -> Any:
+//| def render(x0: int, y0: int, x1: int, y1: int, layers: list, buffer: WriteableBuffer, display: displayio.Display, scale: int, background: int) -> None:
//| """Render and send to the display a fragment of the screen.
//|
//| :param int x0: Left edge of the fragment.
diff --git a/shared-bindings/aesio/aes.c b/shared-bindings/aesio/aes.c
index f6a0a89b8..7c10693fe 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: ReadableBuffer, mode: int = 0, iv: Optional[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(self, 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,8 +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(self, 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
//| buffers must be a multiple of 16 bytes, and must be equal length. For
diff --git a/shared-bindings/analogio/AnalogIn.c b/shared-bindings/analogio/AnalogIn.c
index 400784b39..2cda9355a 100644
--- a/shared-bindings/analogio/AnalogIn.c
+++ b/shared-bindings/analogio/AnalogIn.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 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
@@ -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/AnalogIn.h b/shared-bindings/analogio/AnalogIn.h
index 4aa7fca23..32f11e08f 100644
--- a/shared-bindings/analogio/AnalogIn.h
+++ b/shared-bindings/analogio/AnalogIn.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/shared-bindings/analogio/AnalogOut.c b/shared-bindings/analogio/AnalogOut.c
index a8edcc0ae..787905c3c 100644
--- a/shared-bindings/analogio/AnalogOut.c
+++ b/shared-bindings/analogio/AnalogOut.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 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
@@ -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/analogio/AnalogOut.h b/shared-bindings/analogio/AnalogOut.h
index 6fe5d9b19..e4e94548b 100644
--- a/shared-bindings/analogio/AnalogOut.h
+++ b/shared-bindings/analogio/AnalogOut.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/shared-bindings/audiobusio/I2SOut.c b/shared-bindings/audiobusio/I2SOut.c
index fd71a6e85..73a78ab06 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: audiocore._AudioSample, *, 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..6c5fa7939 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..fd8652c14 100644
--- a/shared-bindings/audiocore/RawSample.c
+++ b/shared-bindings/audiocore/RawSample.c
@@ -38,13 +38,13 @@
//| 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: ReadableBuffer, *, 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
//| channel 1 and so on.
//|
-//| :param array.array buffer: An `array.array` with samples
+//| :param ReadableBuffer buffer: A buffer with samples
//| :param int channel_count: The number of channels in the buffer
//| :param int sample_rate: The desired playback sample rate
//|
@@ -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..89c731c68 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/audiocore/__init__.c b/shared-bindings/audiocore/__init__.c
index b400b9454..a27dcefa4 100644
--- a/shared-bindings/audiocore/__init__.c
+++ b/shared-bindings/audiocore/__init__.c
@@ -38,6 +38,13 @@
//| """Support for audio samples"""
//|
+//| _AudioSample = Union[audiocore.WaveFile, audiocore.RawSample, audiomixer.Mixer, audiomp3.MP3Decoder]
+//| """An audio sample for playback with `audioio.AudioOut`, `audiobusio.I2SOut` or `audiopwmio.PWMAudioOut`.
+//|
+//| Supported sources are :py:class:`audiocore.WaveFile`, :py:class:`audiocore.RawSample`,
+//| :py:class:`audiomixer.Mixer` and :py:class:`audiomp3.MP3Decoder`."""
+//|
+
STATIC const mp_rom_map_elem_t audiocore_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_audiocore) },
{ MP_ROM_QSTR(MP_QSTR_RawSample), MP_ROM_PTR(&audioio_rawsample_type) },
diff --git a/shared-bindings/audioio/AudioOut.c b/shared-bindings/audioio/AudioOut.c
index 9ba72bd41..25620a491 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: Optional[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: audiocore._AudioSample, *, 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/audioio/__init__.c b/shared-bindings/audioio/__init__.c
index 7ec927834..a9c58e864 100644
--- a/shared-bindings/audioio/__init__.c
+++ b/shared-bindings/audioio/__init__.c
@@ -33,15 +33,6 @@
#include "shared-bindings/audioio/__init__.h"
#include "shared-bindings/audioio/AudioOut.h"
-#if CIRCUITPY_AUDIOIO_COMPAT
-#include "shared-bindings/audiomixer/Mixer.h"
-#include "shared-bindings/audiocore/RawSample.h"
-#include "shared-bindings/audiocore/WaveFile.h"
-#endif
-#if CIRCUITPY_AUDIOMIXER
-#include "shared-bindings/audiomixer/Mixer.h"
-#endif
-
//| """Support for audio output
//|
//| The `audioio` module contains classes to provide access to audio IO.
@@ -62,13 +53,6 @@
STATIC const mp_rom_map_elem_t audioio_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_audioio) },
{ MP_ROM_QSTR(MP_QSTR_AudioOut), MP_ROM_PTR(&audioio_audioout_type) },
-#if CIRCUITPY_AUDIOIO_COMPAT
- #if CIRCUITPY_AUDIOMIXER
- { MP_ROM_QSTR(MP_QSTR_Mixer), MP_ROM_PTR(&audiomixer_mixer_type) },
- #endif
- { MP_ROM_QSTR(MP_QSTR_RawSample), MP_ROM_PTR(&audioio_rawsample_type) },
- { MP_ROM_QSTR(MP_QSTR_WaveFile), MP_ROM_PTR(&audioio_wavefile_type) },
-#endif
};
STATIC MP_DEFINE_CONST_DICT(audioio_module_globals, audioio_module_globals_table);
diff --git a/shared-bindings/audiomixer/Mixer.c b/shared-bindings/audiomixer/Mixer.c
index 31e62cdae..9a78c7fad 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: audiocore._AudioSample, *, voice: int = 0, loop: bool = False) -> None:
//| """Plays the sample once when loop=False and continuously when loop=True.
//| Does not block. Use `playing` to block.
//|
@@ -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..335949bb6 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: audiocore._AudioSample, *, 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..0e427951c 100644
--- a/shared-bindings/audiomp3/MP3Decoder.c
+++ b/shared-bindings/audiomp3/MP3Decoder.c
@@ -34,10 +34,10 @@
#include "shared-bindings/util.h"
#include "supervisor/shared/translate.h"
-//| class MP3:
+//| class MP3Decoder:
//| """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..74545a4eb 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: Optional[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: audiocore._AudioSample, *, 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..28ccb4746 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 = 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
//| 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: Optional[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: Optional[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: Optional[int] = None, in_start: int = 0, in_end: Optional[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..3e071ed74 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: Optional[microcontroller.Pin] = None, MISO: Optional[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: 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 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..4a5d39c52 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,14 +125,13 @@ 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.
//|
-//| """Scan all I2C addresses between 0x08 and 0x77 inclusive and return a
-//| list of those that respond.
-//|
-//| :return: List of device ids on the I2C bus
-//| :rtype: list"""
-//| ...
+//| :return: List of device ids on the I2C bus
+//| :rtype: list"""
+//| ...
//|
STATIC mp_obj_t busio_i2c_scan(mp_obj_t self_in) {
busio_i2c_obj_t *self = MP_OBJ_TO_PTR(self_in);
@@ -150,7 +149,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 +163,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,20 +175,20 @@ 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:
-//| """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.
+//| def readfrom_into(self, address: int, buffer: WriteableBuffer, *, start: int = 0, end: Optional[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.
//|
-//| If ``start`` or ``end`` is provided, then the buffer will be sliced
-//| as if ``buffer[start:end]``. This will not cause an allocation like
-//| ``buf[start:end]`` will so it saves memory.
+//| If ``start`` or ``end`` is provided, then the buffer will be sliced
+//| as if ``buffer[start:end]``. This will not cause an allocation like
+//| ``buf[start:end]`` will so it saves memory.
//|
-//| :param int address: 7-bit device address
-//| :param bytearray buffer: buffer to write into
-//| :param int start: Index to start writing at
-//| :param int end: Index to write up to but not include. Defaults to ``len(buffer)``"""
-//| ...
+//| :param int address: 7-bit device address
+//| :param bytearray buffer: buffer to write into
+//| :param int start: Index to start writing at
+//| :param int end: Index to write up to but not include. Defaults to ``len(buffer)``"""
+//| ...
//|
// Shared arg parsing for readfrom_into and writeto_then_readfrom.
STATIC void readfrom(busio_i2c_obj_t *self, mp_int_t address, mp_obj_t buffer, int32_t start, mp_int_t end) {
@@ -228,26 +227,22 @@ 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: Optional[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
-//| ``buffer[start:end]`` will so it saves memory.
+//| If ``start`` or ``end`` is provided, then the buffer will be sliced
+//| as if ``buffer[start:end]``. This will not cause an allocation like
+//| ``buffer[start:end]`` will so it saves memory.
//|
//| Writing a buffer or slice of length zero is permitted, as it can be used
-//| to poll for the existence of a device.
+//| to poll for the existence of a device.
//|
-//| :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 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)``"""
+//| ...
//|
// Shared arg parsing for writeto and writeto_then_readfrom.
STATIC void writeto(busio_i2c_obj_t *self, mp_int_t address, mp_obj_t buffer, int32_t start, mp_int_t end, bool stop) {
@@ -267,13 +262,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,28 +276,28 @@ 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:
-//| """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.
+//| def writeto_then_readfrom(self, address: int, out_buffer: ReadableBuffer, in_buffer: WriteableBuffer, *, out_start: int = 0, out_end: Optional[int] = None, in_start: int = 0, in_end: Optional[int] = None) -> None:
+//| """Write the bytes from ``out_buffer`` to the device selected by ``address``, generate no stop
+//| bit, generate a repeated start and read into ``in_buffer``. ``out_buffer`` and
+//| ``in_buffer`` can be the same buffer because they are used sequentially.
//|
-//| If ``start`` or ``end`` is provided, then the corresponding buffer will be sliced
-//| as if ``buffer[start:end]``. This will not cause an allocation like ``buf[start:end]``
-//| will so it saves memory.
+//| if ``start`` or ``end`` is provided, then the corresponding buffer will be sliced
+//| as if ``buffer[start:end]``. This will not cause an allocation like ``buf[start:end]``
+//| will so it saves memory.
//|
-//| :param int address: 7-bit device address
-//| :param bytearray out_buffer: buffer containing the bytes to write
-//| :param bytearray in_buffer: buffer to write into
-//| :param int out_start: Index to start writing from
-//| :param int out_end: Index to read up to but not include. Defaults to ``len(buffer)``
-//| :param int in_start: Index to start writing at
-//| :param int in_end: Index to write up to but not include. Defaults to ``len(buffer)``"""
-//| ...
+//| :param int address: 7-bit device address
+//| :param bytearray out_buffer: buffer containing the bytes to write
+//| :param bytearray in_buffer: buffer to write into
+//| :param int out_start: Index to start writing from
+//| :param int out_end: Index to read up to but not include. Defaults to ``len(buffer)``
+//| :param int in_start: Index to start writing at
+//| :param int in_end: Index to write up to but not include. Defaults to ``len(buffer)``"""
+//| ...
//|
STATIC mp_obj_t busio_i2c_writeto_then_readfrom(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
enum { ARG_address, ARG_out_buffer, ARG_in_buffer, ARG_out_start, ARG_out_end, ARG_in_start, ARG_in_end };
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 22f001d2d..93dc64d50 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: Optional[microcontroller.Pin] = None, MISO: Optional[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
@@ -153,7 +153,7 @@ STATIC void check_for_deinit(busio_spi_obj_t *self) {
//| or second (1). Rising or falling depends on clock polarity.
//| :param int bits: the number of bits per word
//|
-//| .. note:: On the SAMD21, it is possible to set the baudrate to 24 MHz, but that
+//| .. note:: On the SAMD21, it is possible to set the baudrate to 24 MHz, but that
//| speed is not guaranteed to work. 12 MHz is the next available lower speed, and is
//| within spec for the SAMD21.
//|
@@ -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: WriteableBuffer, *, 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."""
//|
@@ -418,3 +418,10 @@ const mp_obj_type_t busio_spi_type = {
.make_new = busio_spi_make_new,
.locals_dict = (mp_obj_dict_t*)&busio_spi_locals_dict,
};
+
+busio_spi_obj_t *validate_obj_is_spi_bus(mp_obj_t obj) {
+ if (!MP_OBJ_IS_TYPE(obj, &busio_spi_type)) {
+ mp_raise_TypeError_varg(translate("Expected a %q"), busio_spi_type.name);
+ }
+ return MP_OBJ_TO_PTR(obj);
+}
diff --git a/shared-bindings/busio/SPI.h b/shared-bindings/busio/SPI.h
index b7b0715d1..3a8b6dbc1 100644
--- a/shared-bindings/busio/SPI.h
+++ b/shared-bindings/busio/SPI.h
@@ -56,7 +56,7 @@ extern bool common_hal_busio_spi_write(busio_spi_obj_t *self, const uint8_t *dat
extern bool common_hal_busio_spi_read(busio_spi_obj_t *self, uint8_t *data, size_t len, uint8_t write_value);
// Reads and write len bytes simultaneously.
-extern bool common_hal_busio_spi_transfer(busio_spi_obj_t *self, uint8_t *data_out, uint8_t *data_in, size_t len);
+extern bool common_hal_busio_spi_transfer(busio_spi_obj_t *self, const uint8_t *data_out, uint8_t *data_in, size_t len);
// Return actual SPI bus frequency.
uint32_t common_hal_busio_spi_get_frequency(busio_spi_obj_t* self);
@@ -70,4 +70,6 @@ uint8_t common_hal_busio_spi_get_polarity(busio_spi_obj_t* self);
// This is used by the supervisor to claim SPI devices indefinitely.
extern void common_hal_busio_spi_never_reset(busio_spi_obj_t *self);
+extern busio_spi_obj_t *validate_obj_is_spi_bus(mp_obj_t obj_in);
+
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_BUSIO_SPI_H
diff --git a/shared-bindings/busio/UART.c b/shared-bindings/busio/UART.c
index 8c0811266..bf0b7e721 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: Optional[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.
//|
@@ -52,8 +52,8 @@
//| :param ~microcontroller.Pin rx: the pin to receive on, or ``None`` if this ``UART`` is transmit-only.
//| :param ~microcontroller.Pin rts: the pin for rts, or ``None`` if rts not in use.
//| :param ~microcontroller.Pin cts: the pin for cts, or ``None`` if cts not in use.
-//| :param ~microcontroller.Pin rs485_dir: the pin for rs485 direction setting, or ``None`` if rs485 not in use.
-//| :param bool rs485_invert: set to invert the sense of the rs485_dir pin.
+//| :param ~microcontroller.Pin rs485_dir: the output pin for rs485 direction setting, or ``None`` if rs485 not in use.
+//| :param bool rs485_invert: rs485_dir pin active high when set. Active low otherwise.
//| :param int baudrate: the transmit and receive speed.
//| :param int bits: the number of bits per byte, 7, 8 or 9.
//| :param Parity parity: the parity used for error checking.
@@ -87,8 +87,8 @@ STATIC mp_obj_t busio_uart_make_new(const mp_obj_type_t *type, size_t n_args, co
enum { ARG_tx, ARG_rx, ARG_baudrate, ARG_bits, ARG_parity, ARG_stop, ARG_timeout, ARG_receiver_buffer_size,
ARG_rts, ARG_cts, ARG_rs485_dir,ARG_rs485_invert};
static const mp_arg_t allowed_args[] = {
- { MP_QSTR_tx, MP_ARG_REQUIRED | MP_ARG_OBJ },
- { MP_QSTR_rx, MP_ARG_REQUIRED | MP_ARG_OBJ },
+ { MP_QSTR_tx, MP_ARG_OBJ, {.u_obj = mp_const_none} },
+ { MP_QSTR_rx, MP_ARG_OBJ, {.u_obj = mp_const_none} },
{ MP_QSTR_baudrate, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 9600} },
{ MP_QSTR_bits, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 8} },
{ MP_QSTR_parity, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} },
@@ -115,11 +115,11 @@ STATIC mp_obj_t busio_uart_make_new(const mp_obj_type_t *type, size_t n_args, co
mp_raise_ValueError(translate("bits must be 7, 8 or 9"));
}
- uart_parity_t parity = PARITY_NONE;
+ busio_uart_parity_t parity = BUSIO_UART_PARITY_NONE;
if (args[ARG_parity].u_obj == &busio_uart_parity_even_obj) {
- parity = PARITY_EVEN;
+ parity = BUSIO_UART_PARITY_EVEN;
} else if (args[ARG_parity].u_obj == &busio_uart_parity_odd_obj) {
- parity = PARITY_ODD;
+ parity = BUSIO_UART_PARITY_ODD;
}
uint8_t stop = args[ARG_stop].u_int;
@@ -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``
@@ -200,15 +200,17 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(busio_uart___exit___obj, 4, 4, busio_
//| ...
//|
-//| def readline(self, ) -> Any:
-//| """Read a line, ending in a newline character.
+//| 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
//|
//| :return: the line read
-//| :rtype: int or None"""
+//| :rtype: bytes or None"""
//| ...
//|
-//| 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.
@@ -261,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) {
@@ -287,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) {
@@ -304,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) {
@@ -332,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);
@@ -346,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/busio/UART.h b/shared-bindings/busio/UART.h
index 3aed4e534..ce8da1445 100644
--- a/shared-bindings/busio/UART.h
+++ b/shared-bindings/busio/UART.h
@@ -34,17 +34,17 @@
extern const mp_obj_type_t busio_uart_type;
typedef enum {
- PARITY_NONE,
- PARITY_EVEN,
- PARITY_ODD
-} uart_parity_t;
+ BUSIO_UART_PARITY_NONE,
+ BUSIO_UART_PARITY_EVEN,
+ BUSIO_UART_PARITY_ODD
+} busio_uart_parity_t;
// Construct an underlying UART object.
extern void common_hal_busio_uart_construct(busio_uart_obj_t *self,
const mcu_pin_obj_t * tx, const mcu_pin_obj_t * rx,
const mcu_pin_obj_t * rts, const mcu_pin_obj_t * cts,
const mcu_pin_obj_t * rs485_dir, bool rs485_invert,
- uint32_t baudrate, uint8_t bits, uart_parity_t parity, uint8_t stop,
+ uint32_t baudrate, uint8_t bits, busio_uart_parity_t parity, uint8_t stop,
mp_float_t timeout, uint16_t receiver_buffer_size, byte* receiver_buffer,
bool sigint_enabled);
diff --git a/shared-bindings/countio/Counter.c b/shared-bindings/countio/Counter.c
index 8db795015..e51db2644 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.
//|
@@ -53,7 +53,7 @@ STATIC mp_obj_t countio_counter_make_new(const mp_obj_type_t *type, size_t n_arg
return MP_OBJ_FROM_PTR(self);
}
-//| def deinit(self):
+//| def deinit(self) -> None:
//| """Deinitializes the Counter and releases any hardware resources for reuse."""
//|
STATIC mp_obj_t countio_counter_deinit(mp_obj_t self_in) {
@@ -69,12 +69,12 @@ STATIC void check_for_deinit(countio_counter_obj_t *self) {
}
}
-//| def __enter__(self):
+//| def __enter__(self) -> Counter:
//| """No-op used by Context Managers."""
//|
// Provided by context manager helper.
-//| def __exit__(self):
+//| def __exit__(self) -> None:
//| """Automatically deinitializes the hardware when exiting a context. See
//| :ref:`lifetime-and-contextmanagers` for more info."""
//|
@@ -86,7 +86,7 @@ STATIC mp_obj_t countio_counter_obj___exit__(size_t n_args, const mp_obj_t *args
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(countio_counter___exit___obj, 4, 4, countio_counter_obj___exit__);
-//| count: int = ...
+//| count: int
//| """The current count in terms of pulses."""
//|
STATIC mp_obj_t countio_counter_obj_get_count(mp_obj_t self_in) {
@@ -113,7 +113,7 @@ const mp_obj_property_t countio_counter_count_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| def reset(self):
+//| def reset(self) -> None:
//| """Resets the count back to 0."""
//|
STATIC mp_obj_t countio_counter_reset(mp_obj_t self_in){
diff --git a/shared-bindings/digitalio/DigitalInOut.c b/shared-bindings/digitalio/DigitalInOut.c
index eaf2c1810..351e122e0 100644
--- a/shared-bindings/digitalio/DigitalInOut.c
+++ b/shared-bindings/digitalio/DigitalInOut.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 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
@@ -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."""
//| ...
@@ -106,14 +106,14 @@ STATIC void check_for_deinit(digitalio_digitalinout_obj_t *self) {
}
}
-//| def switch_to_output(self, value: bool = False, drive_mode: digitalio.DriveMode = digitalio.DriveMode.PUSH_PULL) -> None:
-//| """Set the drive mode and value and then switch to writing out digital
-//| values.
+//| def switch_to_output(self, value: bool = False, drive_mode: DriveMode = DriveMode.PUSH_PULL) -> None:
+//| """Set the drive mode and value and then switch to writing out digital
+//| values.
//|
-//| :param bool value: default value to set upon switching
-//| :param ~digitalio.DriveMode drive_mode: drive mode for the output
-//| """
-//| ...
+//| :param bool value: default value to set upon switching
+//| :param ~digitalio.DriveMode drive_mode: drive mode for the output
+//| """
+//| ...
//|
STATIC mp_obj_t digitalio_digitalinout_switch_to_output(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
enum { ARG_value, ARG_drive_mode };
@@ -139,7 +139,7 @@ STATIC mp_obj_t digitalio_digitalinout_switch_to_output(size_t n_args, const mp_
}
MP_DEFINE_CONST_FUN_OBJ_KW(digitalio_digitalinout_switch_to_output_obj, 1, digitalio_digitalinout_switch_to_output);
-//| def switch_to_input(self, pull: Pull = None) -> None:
+//| def switch_to_input(self, pull: Optional[Pull] = None) -> None:
//| """Set the pull and then switch to read in digital values.
//|
//| :param Pull pull: pull configuration for the input
@@ -179,7 +179,7 @@ STATIC mp_obj_t digitalio_digitalinout_switch_to_input(size_t n_args, const mp_o
}
MP_DEFINE_CONST_FUN_OBJ_KW(digitalio_digitalinout_switch_to_input_obj, 1, digitalio_digitalinout_switch_to_input);
-//| direction: Direction = ...
+//| direction: Direction
//| """The direction of the pin.
//|
//| Setting this will use the defaults from the corresponding
@@ -228,7 +228,7 @@ const mp_obj_property_t digitalio_digitalio_direction_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| value: Bool = ...
+//| value: bool
//| """The digital logic level of the pin."""
//|
STATIC mp_obj_t digitalio_digitalinout_obj_get_value(mp_obj_t self_in) {
@@ -258,7 +258,7 @@ const mp_obj_property_t digitalio_digitalinout_value_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| drive_mode: DriveMode = ...
+//| drive_mode: DriveMode
//| """The pin drive mode. One of:
//|
//| - `digitalio.DriveMode.PUSH_PULL`
@@ -302,7 +302,7 @@ const mp_obj_property_t digitalio_digitalio_drive_mode_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| pull: Optional[Pull] = ...
+//| pull: Optional[Pull]
//| """The pin pull direction. One of:
//|
//| - `digitalio.Pull.UP`
diff --git a/shared-bindings/digitalio/DigitalInOut.h b/shared-bindings/digitalio/DigitalInOut.h
index dd6f088ab..3d1f9c7cb 100644
--- a/shared-bindings/digitalio/DigitalInOut.h
+++ b/shared-bindings/digitalio/DigitalInOut.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/shared-bindings/digitalio/Direction.c b/shared-bindings/digitalio/Direction.c
index dbd0e93e4..0c2448ca9 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..39b940d7f 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..ed08b0f6b 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..65d80fba6 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..a2b6699ef 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..70e29ff3e 100644
--- a/shared-bindings/displayio/Display.c
+++ b/shared-bindings/displayio/Display.c
@@ -39,6 +39,11 @@
#include "shared-module/displayio/__init__.h"
#include "supervisor/shared/translate.h"
+//| _DisplayBus = Union[FourWire, ParallelBus, I2CDisplay]
+//| """:py:class:`FourWire`, :py:class:`ParallelBus` or :py:class:`I2CDisplay`"""
+//|
+
+//|
//| class Display:
//| """Manage updating a display over a display bus
//|
@@ -49,8 +54,8 @@
//| 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):
-//| r"""Create a Display object on the given display bus (`displayio.FourWire` or `displayio.ParallelBus`).
+//| def __init__(self, display_bus: _DisplayBus, init_sequence: ReadableBuffer, *, 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: Optional[int] = None, brightness: float = 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 (`FourWire`, `ParallelBus` or `I2CDisplay`).
//|
//| The ``init_sequence`` is bitpacked to minimize the ram impact. Every command begins with a
//| command byte followed by a byte to determine the parameter count and if a delay is need after.
@@ -76,7 +81,7 @@
//| of the display to minimize tearing artifacts.
//|
//| :param display_bus: The bus that the display is connected to
-//| :type display_bus: displayio.FourWire or displayio.ParallelBus
+//| :type display_bus: FourWire, ParallelBus or I2CDisplay
//| :param buffer init_sequence: Byte-packed initialization sequence.
//| :param int width: Width in pixels
//| :param int height: Height in pixels
@@ -96,7 +101,7 @@
//| :param int set_vertical_scroll: Command used to set the first row to show
//| :param microcontroller.Pin backlight_pin: Pin connected to the display's backlight
//| :param int brightness_command: Command to set display brightness. Usually available in OLED controllers.
-//| :param bool brightness: Initial display brightness. This value is ignored if auto_brightness is True.
+//| :param float brightness: Initial display brightness. This value is ignored if auto_brightness is True.
//| :param bool auto_brightness: If True, brightness is controlled via an ambient light sensor or other mechanism.
//| :param bool single_byte_bounds: Display column and row commands use single bytes
//| :param bool data_as_commands: Treat all init and boundary data as SPI commands. Certain displays require this.
@@ -188,7 +193,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 +215,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 +250,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: bool
//| """True when the display is refreshed automatically."""
//|
STATIC mp_obj_t displayio_display_obj_get_auto_refresh(mp_obj_t self_in) {
@@ -270,7 +275,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 +312,7 @@ const mp_obj_property_t displayio_display_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
@@ -338,10 +343,9 @@ const mp_obj_property_t displayio_display_auto_brightness_obj = {
-//| width: Any = ...
+//| width: int
//| Gets the width of the board
//|
-//|
STATIC mp_obj_t displayio_display_obj_get_width(mp_obj_t self_in) {
displayio_display_obj_t *self = native_display(self_in);
return MP_OBJ_NEW_SMALL_INT(common_hal_displayio_display_get_width(self));
@@ -355,10 +359,9 @@ 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"""
//|
-//|
STATIC mp_obj_t displayio_display_obj_get_height(mp_obj_t self_in) {
displayio_display_obj_t *self = native_display(self_in);
return MP_OBJ_NEW_SMALL_INT(common_hal_displayio_display_get_height(self));
@@ -372,7 +375,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 +398,7 @@ const mp_obj_property_t displayio_display_rotation_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| bus: Any = ...
+//| bus: _DisplayBus
//| """The bus being used by the display"""
//|
//|
@@ -413,7 +416,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) -> WriteableBuffer:
//| """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..ee1586fe6 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: _DisplayBus, start_sequence: ReadableBuffer, stop_sequence: ReadableBuffer, *, 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: _DisplayBus
//| """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..455d22e72 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: Optional[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..31d4f5b91 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,10 @@ 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 +281,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 +289,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 +297,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..5dc4711b3 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: Optional[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..938e408ab 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: typing.BinaryIO) -> 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..c868aea9c 100644
--- a/shared-bindings/displayio/Palette.c
+++ b/shared-bindings/displayio/Palette.c
@@ -36,17 +36,11 @@
#include "shared-bindings/util.h"
#include "supervisor/shared/translate.h"
-
-
-
-
-
-
//| class Palette:
//| """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 +64,10 @@ 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 +81,11 @@ 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 __getitem__(self, index: int) -> Optional[int]:
+//| r"""Return the pixel color at the given index as an integer."""
+//| ...
+//|
+//| def __setitem__(self, index: int, value: Union[int, ReadableBuffer, Tuple[int, int, int]]) -> None:
//| 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 +148,8 @@ 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,8 @@ 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..73a08f556 100644
--- a/shared-bindings/displayio/TileGrid.c
+++ b/shared-bindings/displayio/TileGrid.c
@@ -48,15 +48,15 @@
//|
//| 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: Bitmap, *, pixel_shader: Union[ColorConverter, Palette], width: int = 1, height: int = 1, tile_width: Optional[int] = None, tile_height: Optional[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.
//|
//| tile_width and tile_height match the height of the bitmap by default.
//|
-//| :param displayio.Bitmap bitmap: The bitmap storing one or more tiles.
-//| :param displayio.Palette pixel_shader: The pixel shader that produces colors from values
+//| :param Bitmap bitmap: The bitmap storing one or more tiles.
+//| :param ColorConverter or Palette pixel_shader: The pixel shader that produces colors from values
//| :param int width: Width of the grid in tiles.
//| :param int height: Height of the grid in tiles.
//| :param int tile_width: Width of a single tile in pixels. Defaults to the full Bitmap and must evenly divide into the Bitmap's dimensions.
@@ -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], value: 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..8ae2356bb 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..e29718fdf 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: displayio.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..8b0e2b41c 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..dca1eb1e8 100644
--- a/shared-bindings/gamepad/GamePad.c
+++ b/shared-bindings/gamepad/GamePad.c
@@ -69,8 +69,17 @@
//| buttons = pad.get_pressed()
//| 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: digitalio.DigitalInOut,
+//| b2: digitalio.DigitalInOut,
+//| b3: digitalio.DigitalInOut,
+//| b4: digitalio.DigitalInOut,
+//| b5: digitalio.DigitalInOut,
+//| b6: digitalio.DigitalInOut,
+//| b7: digitalio.DigitalInOut,
+//| b8: digitalio.DigitalInOut,
+//| ) -> None:
//| """Initializes button scanning routines.
//|
//| The ``b1``-``b8`` parameters are ``DigitalInOut`` objects, which
@@ -114,7 +123,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 +142,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..f6488bbd7 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: digitalio.DigitalInOut, data: digitalio.DigitalInOut, latch: digitalio.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 929e02ab8..087c35395 100644
--- a/shared-bindings/gnss/GNSS.c
+++ b/shared-bindings/gnss/GNSS.c
@@ -1,28 +1,6 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright 2020 Sony Semiconductor Solutions Corporation
- *
- * 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.
- */
+// SPDX-FileCopyrightText: Sony Semiconductor Solutions Corporation
+//
+// SPDX-License-Identifier: MIT
#include "shared-bindings/gnss/GNSS.h"
#include "shared-bindings/time/__init__.h"
@@ -53,10 +31,10 @@
//| print("Longitude: {0:.6f} degrees".format(nav.longitude))"""
//|
-//| def __init__(self, ):
+//| def __init__(self, system: Union[SatelliteSystem, List[SatelliteSystem]]) -> None:
//| """Turn on the GNSS.
//|
-//| :param gnss.SatelliteSystem system: satellite system to use"""
+//| :param system: satellite system to use"""
//| ...
//|
STATIC mp_obj_t gnss_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
@@ -90,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."""
//| ...
//|
@@ -107,7 +85,7 @@ STATIC void check_for_deinit(gnss_obj_t *self) {
}
}
-//| def update(self, ) -> Any:
+//| def update(self) -> None:
//| """Update GNSS positioning information."""
//| ...
//|
@@ -120,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) {
@@ -137,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) {
@@ -154,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) {
@@ -171,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) {
@@ -190,7 +168,7 @@ const mp_obj_property_t gnss_timestamp_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| fix: Any = ...
+//| fix: PositionFix
//| """Fix mode."""
//|
STATIC mp_obj_t gnss_obj_get_fix(mp_obj_t self_in) {
diff --git a/shared-bindings/gnss/GNSS.h b/shared-bindings/gnss/GNSS.h
index 61ae35b12..60069a90a 100644
--- a/shared-bindings/gnss/GNSS.h
+++ b/shared-bindings/gnss/GNSS.h
@@ -1,28 +1,6 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright 2020 Sony Semiconductor Solutions Corporation
- *
- * 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.
- */
+// SPDX-FileCopyrightText: Sony Semiconductor Solutions Corporation
+//
+// SPDX-License-Identifier: MIT
#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_GNSS_GNSS_H
#define MICROPY_INCLUDED_SHARED_BINDINGS_GNSS_GNSS_H
diff --git a/shared-bindings/gnss/PositionFix.c b/shared-bindings/gnss/PositionFix.c
index 106a28c34..e60611d70 100644
--- a/shared-bindings/gnss/PositionFix.c
+++ b/shared-bindings/gnss/PositionFix.c
@@ -1,51 +1,23 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright 2020 Sony Semiconductor Solutions Corporation
- *
- * 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.
- */
+// SPDX-FileCopyrightText: Sony Semiconductor Solutions Corporation
+//
+// SPDX-License-Identifier: MIT
#include "shared-bindings/gnss/PositionFix.h"
//| class PositionFix:
//| """Position fix mode"""
//|
-//| def __init__(self, ):
+//| def __init__(self) -> None:
//| """Enum-like class to define the position fix mode."""
//|
-//| INVALID: Any = ...
-//| """No measurement.
+//| INVALID: PositionFix
+//| """No measurement."""
//|
-//| :type gnss.PositionFix:"""
+//| FIX_2D: PositionFix
+//| """2D fix."""
//|
-//| FIX_2D: Any = ...
-//| """2D fix.
-//|
-//| :type gnss.PositionFix:"""
-//|
-//| FIX_3D: Any = ...
-//| """3D fix.
-//|
-//| :type gnss.PositionFix:"""
+//| FIX_3D: PositionFix
+//| """3D fix."""
//|
const mp_obj_type_t gnss_positionfix_type;
diff --git a/shared-bindings/gnss/PositionFix.h b/shared-bindings/gnss/PositionFix.h
index 64497cb59..34090872c 100644
--- a/shared-bindings/gnss/PositionFix.h
+++ b/shared-bindings/gnss/PositionFix.h
@@ -1,28 +1,6 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright 2020 Sony Semiconductor Solutions Corporation
- *
- * 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.
- */
+// SPDX-FileCopyrightText: Sony Semiconductor Solutions Corporation
+//
+// SPDX-License-Identifier: MIT
#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_GNSS_POSITIONFIX_H
#define MICROPY_INCLUDED_SHARED_BINDINGS_GNSS_POSITIONFIX_H
diff --git a/shared-bindings/gnss/SatelliteSystem.c b/shared-bindings/gnss/SatelliteSystem.c
index badc02b96..7d66727b8 100644
--- a/shared-bindings/gnss/SatelliteSystem.c
+++ b/shared-bindings/gnss/SatelliteSystem.c
@@ -1,61 +1,29 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright 2020 Sony Semiconductor Solutions Corporation
- *
- * 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.
- */
+// SPDX-FileCopyrightText: Sony Semiconductor Solutions Corporation
+//
+// SPDX-License-Identifier: MIT
#include "shared-bindings/gnss/SatelliteSystem.h"
//| class SatelliteSystem:
//| """Satellite system type"""
//|
-//| def __init__(self, ):
+//| def __init__(self) -> None:
//| """Enum-like class to define the satellite system type."""
//|
-//| GPS: Any = ...
-//| """Global Positioning System.
+//| GPS: SatelliteSystem
+//| """Global Positioning System."""
//|
-//| :type gnss.SatelliteSystem:"""
+//| GLONASS: SatelliteSystem
+//| """GLObal NAvigation Satellite System."""
//|
-//| GLONASS: Any = ...
-//| """GLObal NAvigation Satellite System.
+//| SBAS: SatelliteSystem
+//| """Satellite Based Augmentation System."""
//|
-//| :type gnss.SatelliteSystem:"""
+//| QZSS_L1CA: SatelliteSystem
+//| """Quasi-Zenith Satellite System L1C/A."""
//|
-//| SBAS: Any = ...
-//| """Satellite Based Augmentation System.
-//|
-//| :type gnss.SatelliteSystem:"""
-//|
-//| QZSS_L1CA: Any = ...
-//| """Quasi-Zenith Satellite System L1C/A.
-//|
-//| :type gnss.SatelliteSystem:"""
-//|
-//| QZSS_L1S: Any = ...
-//| """Quasi-Zenith Satellite System L1S.
-//|
-//| :type gnss.SatelliteSystem:"""
+//| QZSS_L1S: SatelliteSystem
+//| """Quasi-Zenith Satellite System L1S."""
//|
const mp_obj_type_t gnss_satellitesystem_type;
diff --git a/shared-bindings/gnss/SatelliteSystem.h b/shared-bindings/gnss/SatelliteSystem.h
index 484e861ab..17f155002 100644
--- a/shared-bindings/gnss/SatelliteSystem.h
+++ b/shared-bindings/gnss/SatelliteSystem.h
@@ -1,28 +1,6 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright 2020 Sony Semiconductor Solutions Corporation
- *
- * 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.
- */
+// SPDX-FileCopyrightText: Sony Semiconductor Solutions Corporation
+//
+// SPDX-License-Identifier: MIT
#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_GNSS_SATELLITESYSTEM_H
#define MICROPY_INCLUDED_SHARED_BINDINGS_GNSS_SATELLITESYSTEM_H
diff --git a/shared-bindings/gnss/__init__.c b/shared-bindings/gnss/__init__.c
index b3cf722f1..4b0d312ae 100644
--- a/shared-bindings/gnss/__init__.c
+++ b/shared-bindings/gnss/__init__.c
@@ -1,28 +1,6 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright 2020 Sony Semiconductor Solutions Corporation
- *
- * 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.
- */
+// SPDX-FileCopyrightText: Sony Semiconductor Solutions Corporation
+//
+// SPDX-License-Identifier: MIT
#include "py/obj.h"
#include "py/runtime.h"
diff --git a/shared-bindings/i2cperipheral/I2CPeripheral.c b/shared-bindings/i2cperipheral/I2CPeripheral.c
index 4a3900174..cfebd472e 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."""
//| ...
//|
@@ -259,7 +259,7 @@ STATIC mp_obj_t i2cperipheral_i2c_peripheral_request_obj___exit__(size_t n_args,
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(i2cperipheral_i2c_peripheral_request___exit___obj, 4, 4, i2cperipheral_i2c_peripheral_request_obj___exit__);
-//| address: int = ...
+//| address: int
//| """The I2C address of the request."""
//|
STATIC mp_obj_t i2cperipheral_i2c_peripheral_request_get_address(mp_obj_t self_in) {
@@ -269,7 +269,7 @@ STATIC mp_obj_t i2cperipheral_i2c_peripheral_request_get_address(mp_obj_t self_i
}
MP_DEFINE_CONST_PROP_GET(i2cperipheral_i2c_peripheral_request_address_obj, i2cperipheral_i2c_peripheral_request_get_address);
-//| is_read: bool = ...
+//| is_read: bool
//| """The I2C main controller is reading from this peripheral."""
//|
STATIC mp_obj_t i2cperipheral_i2c_peripheral_request_get_is_read(mp_obj_t self_in) {
@@ -279,7 +279,7 @@ STATIC mp_obj_t i2cperipheral_i2c_peripheral_request_get_is_read(mp_obj_t self_i
}
MP_DEFINE_CONST_PROP_GET(i2cperipheral_i2c_peripheral_request_is_read_obj, i2cperipheral_i2c_peripheral_request_get_is_read);
-//| is_restart: bool = ...
+//| is_restart: bool
//| """Is Repeated Start Condition."""
//|
STATIC mp_obj_t i2cperipheral_i2c_peripheral_request_get_is_restart(mp_obj_t self_in) {
@@ -349,7 +349,7 @@ STATIC mp_obj_t i2cperipheral_i2c_peripheral_request_read(size_t n_args, const m
}
MP_DEFINE_CONST_FUN_OBJ_KW(i2cperipheral_i2c_peripheral_request_read_obj, 1, i2cperipheral_i2c_peripheral_request_read);
-//| def write(self, buffer: bytearray) -> int:
+//| def write(self, buffer: ReadableBuffer) -> int:
//| """Write the data contained in buffer.
//|
//| :param buffer: Write out the data in this buffer
@@ -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 8226a08ec..3883c03c1 100644
--- a/shared-bindings/math/__init__.c
+++ b/shared-bindings/math/__init__.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
* Copyright (c) 2017 Michael McWethy
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -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) -> int:
//| """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..7de8c1287
--- /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: int = 1) -> None:
+//| """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: int) -> 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) -> 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..b35bae360
--- /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) -> None:
+//| """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) -> AllocationSize:
+//| """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) -> None:
+//| """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) -> int:
+//| """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: int) -> Optional[int]:
+//| """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..c101ba5e0
--- /dev/null
+++ b/shared-bindings/memorymonitor/__init__.c
@@ -0,0 +1,76 @@
+/*
+ * 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(Exception):
+//| """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 765e602e5..1294b78f0 100644
--- a/shared-bindings/microcontroller/Pin.c
+++ b/shared-bindings/microcontroller/Pin.c
@@ -36,10 +36,10 @@
//| 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."""
+//| :mod:`board` or :mod:`microcontroller.pin` to reference the desired pin."""
//| ...
//|
@@ -101,6 +101,18 @@ mcu_pin_obj_t *validate_obj_is_free_pin(mp_obj_t obj) {
return pin;
}
+// Validate every element in the list to be a free pin.
+void validate_list_is_free_pins(qstr what, mcu_pin_obj_t **pins_out, mp_int_t max_pins, mp_obj_t seq, uint8_t *count_out) {
+ mp_int_t len = MP_OBJ_SMALL_INT_VALUE(mp_obj_len(seq));
+ if (len > max_pins) {
+ mp_raise_ValueError_varg(translate("At most %d %q may be specified (not %d)"), max_pins, what, len);
+ }
+ *count_out = len;
+ for (mp_int_t i=0; i<len; i++) {
+ pins_out[i] = validate_obj_is_free_pin(mp_obj_subscr(seq, MP_OBJ_NEW_SMALL_INT(i), MP_OBJ_SENTINEL));
+ }
+}
+
// Validate that the obj is a free pin or None. Return an mcu_pin_obj_t* or NULL, correspondingly.
mcu_pin_obj_t *validate_obj_is_free_pin_or_none(mp_obj_t obj) {
if (obj == mp_const_none) {
diff --git a/shared-bindings/microcontroller/Pin.h b/shared-bindings/microcontroller/Pin.h
index bb5256b55..f6659db7d 100644
--- a/shared-bindings/microcontroller/Pin.h
+++ b/shared-bindings/microcontroller/Pin.h
@@ -37,6 +37,7 @@ mcu_pin_obj_t *validate_obj_is_pin(mp_obj_t obj);
mcu_pin_obj_t *validate_obj_is_pin_or_none(mp_obj_t obj);
mcu_pin_obj_t *validate_obj_is_free_pin(mp_obj_t obj);
mcu_pin_obj_t *validate_obj_is_free_pin_or_none(mp_obj_t obj);
+void validate_list_is_free_pins(qstr what, mcu_pin_obj_t **pins_out, mp_int_t max_pins, mp_obj_t seq, uint8_t *count_out);
void assert_pin_free(const mcu_pin_obj_t* pin);
diff --git a/shared-bindings/microcontroller/Processor.c b/shared-bindings/microcontroller/Processor.c
index c4b249124..8c703891d 100644
--- a/shared-bindings/microcontroller/Processor.c
+++ b/shared-bindings/microcontroller/Processor.c
@@ -44,13 +44,13 @@
//| 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."""
//| ...
//|
-//| frequency: int = ...
+//| frequency: int
//| """The CPU operating frequency in Hertz. (read-only)"""
//|
STATIC mp_obj_t mcu_processor_get_frequency(mp_obj_t self) {
@@ -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..a54f40cac 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..c00b1e314 100644
--- a/shared-bindings/microcontroller/__init__.c
+++ b/shared-bindings/microcontroller/__init__.c
@@ -48,13 +48,13 @@
//| microcontroller. See `board` for board-specific pin mappings."""
//|
-//| cpu: Processor = ...
+//| cpu: Processor
//| """CPU information and control, such as ``cpu.temperature`` and ``cpu.frequency``
//| (clock frequency).
//| 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`.
//|
@@ -133,13 +133,19 @@ STATIC mp_obj_t mcu_reset(void) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_0(mcu_reset_obj, mcu_reset);
-//| nvm: Any = ...
+//| nvm: Optional[nvm.ByteArray]
//| """Available non-volatile memory.
//| This object is the sole instance of `nvm.ByteArray` when available or ``None`` otherwise.
//|
//| :type: nvm.ByteArray or None"""
//|
+//| watchdog: Optional[watchdog.WatchDogTimer]
+//| """Available watchdog timer.
+//| This object is the sole instance of `watchdog.WatchDogTimer` when available or ``None`` otherwise."""
+//|
+
+
//| """:mod:`microcontroller.pin` --- Microcontroller pin names
//| --------------------------------------------------------
//|
diff --git a/shared-bindings/multiterminal/__init__.c b/shared-bindings/multiterminal/__init__.c
index baf2fb674..1fbeca79c 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() -> Optional[typing.BinaryIO]:
//| """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: typing.BinaryIO) -> 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/neopixel_write/__init__.c b/shared-bindings/neopixel_write/__init__.c
index 5e5bc31eb..8eb426c2b 100644
--- a/shared-bindings/neopixel_write/__init__.c
+++ b/shared-bindings/neopixel_write/__init__.c
@@ -50,12 +50,12 @@
//| pixel_off = bytearray([0, 0, 0])
//| neopixel_write.neopixel_write(pin, pixel_off)"""
//|
-//| def neopixel_write(digitalinout: digitalio.DigitalInOut, buf: bytearray) -> None:
-//| """Write buf out on the given DigitalInOut.
+//| def neopixel_write(digitalinout: digitalio.DigitalInOut, buf: ReadableBuffer) -> None:
+//| """Write buf out on the given DigitalInOut.
//|
-//| :param digitalinout: the DigitalInOut to output with
-//| :param buf: The bytes to clock out. No assumption is made about color order"""
-//| ...
+//| :param digitalinout: the DigitalInOut to output with
+//| :param buf: The bytes to clock out. No assumption is made about color order"""
+//| ...
STATIC mp_obj_t neopixel_write_neopixel_write_(mp_obj_t digitalinout_obj, mp_obj_t buf) {
if (!MP_OBJ_IS_TYPE(digitalinout_obj, &digitalio_digitalinout_type)) {
mp_raise_TypeError_varg(translate("Expected a %q"), digitalio_digitalinout_type.name);
diff --git a/shared-bindings/network/__init__.c b/shared-bindings/network/__init__.c
index 6af86688e..35bbaa510 100644
--- a/shared-bindings/network/__init__.c
+++ b/shared-bindings/network/__init__.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2014 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
@@ -40,11 +40,14 @@
//| """Network Interface Management
//|
+//| .. warning:: This module is disabled in 6.x and will removed in 7.x. Please use networking
+//| libraries instead.
+//|
//| This module provides a registry of configured NICs.
//| 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/network/__init__.h b/shared-bindings/network/__init__.h
index 4fe5e75a3..b579aa57a 100644
--- a/shared-bindings/network/__init__.h
+++ b/shared-bindings/network/__init__.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/shared-bindings/nvm/ByteArray.c b/shared-bindings/nvm/ByteArray.c
index 06d7d4c95..994ce7045 100644
--- a/shared-bindings/nvm/ByteArray.c
+++ b/shared-bindings/nvm/ByteArray.c
@@ -44,12 +44,15 @@
//| 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`)"""
//| ...
//|
@@ -68,6 +71,18 @@ STATIC const mp_rom_map_elem_t nvm_bytearray_locals_dict_table[] = {
STATIC MP_DEFINE_CONST_DICT(nvm_bytearray_locals_dict, nvm_bytearray_locals_dict_table);
+//| @overload
+//| def __getitem__(self, index: slice) -> bytearray: ...
+//| def __getitem__(self, index: int) -> int:
+//| """Returns the value at the given index."""
+//| ...
+//|
+//| @overload
+//| def __setitem__(self, index: slice, value: ReadableBuffer) -> None: ...
+//| def __setitem__(self, index: int, value: int) -> None:
+//| """Set the value at the given index."""
+//| ...
+//|
STATIC mp_obj_t nvm_bytearray_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value) {
if (value == MP_OBJ_NULL) {
// delete item
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 4e991d089..2406dbc37 100644
--- a/shared-bindings/os/__init__.c
+++ b/shared-bindings/os/__init__.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
* Copyright (c) 2015 Josef Gajdusek
* Copyright (c) 2016 Scott Shawcroft for Adafruit Industries
*
@@ -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: str) -> 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() -> str:
//| """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: str) -> str:
//| """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: str) -> 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: str) -> 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: str) -> 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: str, new_path: str) -> str:
//| """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: str) -> str:
//| """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: str) -> Tuple[int, int, int, int, int, int, int, int, int, int]:
//| """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) -> str:
//| """Returns a string of *size* random bytes based on a hardware True Random
//| Number Generator. When not available, it will raise a NotImplementedError."""
//| ...
@@ -224,9 +224,9 @@ STATIC const mp_rom_map_elem_t os_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR_urandom), MP_ROM_PTR(&os_urandom_obj) },
-//| """.. data:: sep
//|
-//| Separator used to delineate path components such as folder and file names."""
+//| sep: str
+//| """Separator used to delineate path components such as folder and file names."""
//|
{ MP_ROM_QSTR(MP_QSTR_sep), MP_ROM_QSTR(MP_QSTR__slash_) },
};
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 7970c02f3..e9b6c45d2 100644
--- a/shared-bindings/pulseio/PWMOut.c
+++ b/shared-bindings/pulseio/PWMOut.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2016 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 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
@@ -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/PWMOut.h b/shared-bindings/pulseio/PWMOut.h
index c01e0c926..c72278e0e 100644
--- a/shared-bindings/pulseio/PWMOut.h
+++ b/shared-bindings/pulseio/PWMOut.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/shared-bindings/pulseio/PulseIn.c b/shared-bindings/pulseio/PulseIn.c
index 5c52b2582..3e44a1479 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..3d35f0544 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: 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: ReadableBuffer) -> 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/pulseio/PulseOut.h b/shared-bindings/pulseio/PulseOut.h
index 2cf78d3f2..390910ff6 100644
--- a/shared-bindings/pulseio/PulseOut.h
+++ b/shared-bindings/pulseio/PulseOut.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/shared-bindings/random/__init__.c b/shared-bindings/random/__init__.c
index c0124df41..35756eef1 100644
--- a/shared-bindings/random/__init__.c
+++ b/shared-bindings/random/__init__.c
@@ -46,8 +46,11 @@
//| .. warning:: Numbers from this module are not cryptographically strong! Use
//| bytes from `os.urandom` directly for true randomness."""
//|
+//| from typing import TypeVar
+//| _T = TypeVar('_T')
+//|
-//| 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 +62,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 +75,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 +117,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 +132,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: Sequence[_T]) -> _T:
//| """Returns a randomly selected element from the given sequence. Raises
//| IndexError when the sequence is empty."""
//| ...
@@ -143,7 +146,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 +155,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 cbf570958..b2dd80682 100644
--- a/shared-bindings/rgbmatrix/RGBMatrix.c
+++ b/shared-bindings/rgbmatrix/RGBMatrix.c
@@ -50,13 +50,10 @@ STATIC uint8_t validate_pin(mp_obj_t obj) {
}
STATIC void validate_pins(qstr what, uint8_t* pin_nos, mp_int_t max_pins, mp_obj_t seq, uint8_t *count_out) {
- mp_int_t len = MP_OBJ_SMALL_INT_VALUE(mp_obj_len(seq));
- if (len > max_pins) {
- mp_raise_ValueError_varg(translate("At most %d %q may be specified (not %d)"), max_pins, what, len);
- }
- *count_out = len;
- for (mp_int_t i=0; i<len; i++) {
- pin_nos[i] = validate_pin(mp_obj_subscr(seq, MP_OBJ_NEW_SMALL_INT(i), MP_OBJ_SENTINEL));
+ mcu_pin_obj_t *pins[max_pins];
+ validate_list_is_free_pins(what, pins, max_pins, seq, count_out);
+ for (mp_int_t i=0; i<*count_out; i++) {
+ pin_nos[i] = common_hal_mcu_pin_number(pins[i]);
}
}
@@ -131,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: int, rgb_pins: Sequence[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
@@ -240,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."""
@@ -260,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."""
//|
@@ -291,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;
@@ -303,7 +301,7 @@ STATIC mp_obj_t rgbmatrix_rgbmatrix_refresh(mp_obj_t self_in) {
}
MP_DEFINE_CONST_FUN_OBJ_1(rgbmatrix_rgbmatrix_refresh_obj, rgbmatrix_rgbmatrix_refresh);
-//| width: int = ...
+//| width: int
//| """The width of the display, in pixels"""
//|
STATIC mp_obj_t rgbmatrix_rgbmatrix_get_width(mp_obj_t self_in) {
@@ -319,7 +317,7 @@ const mp_obj_property_t rgbmatrix_rgbmatrix_width_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| height: int = ...
+//| height: int
//| """The height of the display, in pixels"""
//|
STATIC mp_obj_t rgbmatrix_rgbmatrix_get_height(mp_obj_t self_in) {
diff --git a/shared-bindings/rotaryio/IncrementalEncoder.c b/shared-bindings/rotaryio/IncrementalEncoder.c
index 8b2723866..8b0badbe8 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 58fe308f5..4a792484d 100644
--- a/shared-bindings/rtc/RTC.c
+++ b/shared-bindings/rtc/RTC.c
@@ -4,7 +4,7 @@
* The MIT License (MIT)
*
* Copyright (c) 2018 Noralf Trønnes
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 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
@@ -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."""
//| ...
//|
@@ -53,7 +53,7 @@ STATIC mp_obj_t rtc_rtc_make_new(const mp_obj_type_t *type, size_t n_args, const
return (mp_obj_t)&rtc_rtc_obj;
}
-//| datetime: time.struct_time = ...
+//| datetime: time.struct_time
//| """The current date and time of the RTC as a `time.struct_time`.
//|
//| This must be set to the current date and time whenever the board loses power::
@@ -94,7 +94,7 @@ const mp_obj_property_t rtc_rtc_datetime_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| calibration: int = ...
+//| calibration: int
//| """The RTC calibration value as an `int`.
//|
//| A positive value speeds up the clock and a negative value slows it down.
diff --git a/shared-bindings/rtc/__init__.c b/shared-bindings/rtc/__init__.c
index b204d511c..baa9c95e1 100644
--- a/shared-bindings/rtc/__init__.c
+++ b/shared-bindings/rtc/__init__.c
@@ -4,7 +4,7 @@
* The MIT License (MIT)
*
* Copyright (c) 2018 Noralf Trønnes
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 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
@@ -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
new file mode 100644
index 000000000..a0582d143
--- /dev/null
+++ b/shared-bindings/sdcardio/SDCard.c
@@ -0,0 +1,183 @@
+/*
+ * This file is part of the Micro Python project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020 Jeff Epler for Adafruit Industries
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include "py/obj.h"
+#include "py/objproperty.h"
+#include "py/runtime.h"
+#include "py/objarray.h"
+
+#include "shared-bindings/sdcardio/SDCard.h"
+#include "shared-module/sdcardio/SDCard.h"
+#include "common-hal/busio/SPI.h"
+#include "shared-bindings/busio/SPI.h"
+#include "shared-bindings/microcontroller/Pin.h"
+#include "supervisor/flash.h"
+
+//| class SDCard:
+//| """SD Card Block Interface
+//|
+//| Controls an SD card over SPI. This built-in module has higher read
+//| performance than the library adafruit_sdcard, but it is only compatible with
+//| `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__(self, bus: busio.SPI, cs: microcontroller.Pin, baudrate: int = 8000000) -> None:
+//| """Construct an SPI SD Card object with the given properties
+//|
+//| :param busio.SPI spi: The SPI bus
+//| :param microcontroller.Pin cs: The chip select connected to the card
+//| :param int baudrate: The SPI data rate to use after card setup
+//|
+//| Note that during detection and configuration, a hard-coded low baudrate is used.
+//| Data transfers use the specified baurate (rounded down to one that is supported by
+//| the microcontroller)
+//|
+//| Example usage:
+//|
+//| .. code-block:: python
+//|
+//| import os
+//|
+//| import board
+//| import sdcardio
+//| import storage
+//|
+//| sd = sdcardio.SDCard(board.SPI(), board.SD_CS)
+//| vfs = storage.VfsFat(sd)
+//| storage.mount(vfs, '/sd')
+//| os.listdir('/sd')"""
+
+STATIC mp_obj_t sdcardio_sdcard_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
+ enum { ARG_spi, ARG_cs, ARG_baudrate, ARG_sdio, NUM_ARGS };
+ static const mp_arg_t allowed_args[] = {
+ { MP_QSTR_spi, MP_ARG_OBJ, {.u_obj = mp_const_none } },
+ { MP_QSTR_cs, MP_ARG_OBJ, {.u_obj = mp_const_none } },
+ { MP_QSTR_baudrate, MP_ARG_INT, {.u_int = 8000000} },
+ { MP_QSTR_sdio, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_int = 8000000} },
+ };
+ MP_STATIC_ASSERT( MP_ARRAY_SIZE(allowed_args) == NUM_ARGS );
+ mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
+ mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
+
+ busio_spi_obj_t *spi = validate_obj_is_spi_bus(args[ARG_spi].u_obj);
+ mcu_pin_obj_t *cs = validate_obj_is_free_pin(args[ARG_cs].u_obj);
+
+ sdcardio_sdcard_obj_t *self = m_new_obj(sdcardio_sdcard_obj_t);
+ self->base.type = &sdcardio_SDCard_type;
+
+ common_hal_sdcardio_sdcard_construct(self, spi, cs, args[ARG_baudrate].u_int);
+
+ return self;
+}
+
+
+//| def count(self) -> int:
+//| """Returns the total number of sectors
+//|
+//| Due to technical limitations, this is a function and not a property.
+//|
+//| :return: The number of 512-byte blocks, as a number"""
+//|
+mp_obj_t sdcardio_sdcard_count(mp_obj_t self_in) {
+ sdcardio_sdcard_obj_t *self = (sdcardio_sdcard_obj_t*)self_in;
+ return mp_obj_new_int_from_ull(common_hal_sdcardio_sdcard_get_blockcount(self));
+}
+MP_DEFINE_CONST_FUN_OBJ_1(sdcardio_sdcard_count_obj, sdcardio_sdcard_count);
+
+//| def deinit(self) -> None:
+//| """Disable permanently.
+//|
+//| :return: None"""
+//|
+mp_obj_t sdcardio_sdcard_deinit(mp_obj_t self_in) {
+ sdcardio_sdcard_obj_t *self = (sdcardio_sdcard_obj_t*)self_in;
+ common_hal_sdcardio_sdcard_deinit(self);
+ return mp_const_none;
+}
+MP_DEFINE_CONST_FUN_OBJ_1(sdcardio_sdcard_deinit_obj, sdcardio_sdcard_deinit);
+
+
+//| def readblocks(self, start_block: int, buf: WriteableBuffer) -> None:
+//|
+//| """Read one or more blocks from the card
+//|
+//| :param int start_block: The block to start reading from
+//| :param bytearray buf: The buffer to write into. Length must be multiple of 512.
+//|
+//| :return: None"""
+//|
+
+mp_obj_t sdcardio_sdcard_readblocks(mp_obj_t self_in, mp_obj_t start_block_in, mp_obj_t buf_in) {
+ uint32_t start_block = mp_obj_get_int(start_block_in);
+ mp_buffer_info_t bufinfo;
+ mp_get_buffer_raise(buf_in, &bufinfo, MP_BUFFER_WRITE);
+ sdcardio_sdcard_obj_t *self = (sdcardio_sdcard_obj_t*)self_in;
+ int result = common_hal_sdcardio_sdcard_readblocks(self, start_block, &bufinfo);
+ if (result < 0) {
+ mp_raise_OSError(-result);
+ }
+ return mp_const_none;
+}
+
+MP_DEFINE_CONST_FUN_OBJ_3(sdcardio_sdcard_readblocks_obj, sdcardio_sdcard_readblocks);
+
+//| def writeblocks(self, start_block: int, buf: ReadableBuffer) -> None:
+//|
+//| """Write one or more blocks to the card
+//|
+//| :param int start_block: The block to start writing from
+//| :param bytearray buf: The buffer to read from. Length must be multiple of 512.
+//|
+//| :return: None"""
+//|
+
+mp_obj_t sdcardio_sdcard_writeblocks(mp_obj_t self_in, mp_obj_t start_block_in, mp_obj_t buf_in) {
+ uint32_t start_block = mp_obj_get_int(start_block_in);
+ mp_buffer_info_t bufinfo;
+ mp_get_buffer_raise(buf_in, &bufinfo, MP_BUFFER_READ);
+ sdcardio_sdcard_obj_t *self = (sdcardio_sdcard_obj_t*)self_in;
+ int result = common_hal_sdcardio_sdcard_writeblocks(self, start_block, &bufinfo);
+ if (result < 0) {
+ mp_raise_OSError(-result);
+ }
+ return mp_const_none;
+}
+MP_DEFINE_CONST_FUN_OBJ_3(sdcardio_sdcard_writeblocks_obj, sdcardio_sdcard_writeblocks);
+
+STATIC const mp_rom_map_elem_t sdcardio_sdcard_locals_dict_table[] = {
+ { MP_ROM_QSTR(MP_QSTR_count), MP_ROM_PTR(&sdcardio_sdcard_count_obj) },
+ { MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&sdcardio_sdcard_deinit_obj) },
+ { MP_ROM_QSTR(MP_QSTR_readblocks), MP_ROM_PTR(&sdcardio_sdcard_readblocks_obj) },
+ { MP_ROM_QSTR(MP_QSTR_writeblocks), MP_ROM_PTR(&sdcardio_sdcard_writeblocks_obj) },
+};
+STATIC MP_DEFINE_CONST_DICT(sdcardio_sdcard_locals_dict, sdcardio_sdcard_locals_dict_table);
+
+const mp_obj_type_t sdcardio_SDCard_type = {
+ { &mp_type_type },
+ .name = MP_QSTR_SDCard,
+ .make_new = sdcardio_sdcard_make_new,
+ .locals_dict = (mp_obj_dict_t*)&sdcardio_sdcard_locals_dict,
+};
diff --git a/shared-bindings/sdcardio/SDCard.h b/shared-bindings/sdcardio/SDCard.h
new file mode 100644
index 000000000..5986d5b81
--- /dev/null
+++ b/shared-bindings/sdcardio/SDCard.h
@@ -0,0 +1,30 @@
+/*
+ * This file is part of the Micro Python project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2017, 2018 Scott Shawcroft for Adafruit Industries
+ * Copyright (c) 2020 Jeff Epler for Adafruit Industries
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#pragma once
+
+extern const mp_obj_type_t sdcardio_SDCard_type;
diff --git a/shared-bindings/sdcardio/__init__.c b/shared-bindings/sdcardio/__init__.c
new file mode 100644
index 000000000..746aa5588
--- /dev/null
+++ b/shared-bindings/sdcardio/__init__.c
@@ -0,0 +1,47 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020 Jeff Epler for Adafruit Industries
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+
+#include <stdint.h>
+
+#include "py/obj.h"
+#include "py/runtime.h"
+
+#include "shared-bindings/sdcardio/SDCard.h"
+
+//| """Interface to an SD card via the SPI bus"""
+
+STATIC const mp_rom_map_elem_t sdcardio_module_globals_table[] = {
+ { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_sdcardio) },
+ { MP_ROM_QSTR(MP_QSTR_SDCard), MP_ROM_PTR(&sdcardio_SDCard_type) },
+};
+
+STATIC MP_DEFINE_CONST_DICT(sdcardio_module_globals, sdcardio_module_globals_table);
+
+const mp_obj_module_t sdcardio_module = {
+ .base = { &mp_type_module },
+ .globals = (mp_obj_dict_t*)&sdcardio_module_globals,
+};
diff --git a/shared-bindings/sdcardio/__init__.h b/shared-bindings/sdcardio/__init__.h
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/shared-bindings/sdcardio/__init__.h
diff --git a/shared-bindings/sdioio/SDCard.c b/shared-bindings/sdioio/SDCard.c
new file mode 100644
index 000000000..594fa71ff
--- /dev/null
+++ b/shared-bindings/sdioio/SDCard.c
@@ -0,0 +1,296 @@
+/*
+ * 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.
+ */
+
+// This file contains all of the Python API definitions for the
+// sdioio.SDCard class.
+
+#include <string.h>
+
+#include "shared-bindings/microcontroller/Pin.h"
+#include "shared-bindings/sdioio/SDCard.h"
+#include "shared-bindings/util.h"
+
+#include "lib/utils/buffer_helper.h"
+#include "lib/utils/context_manager_helpers.h"
+#include "py/mperrno.h"
+#include "py/objproperty.h"
+#include "py/runtime.h"
+#include "supervisor/shared/translate.h"
+
+//| class SDCard:
+//| """SD Card Block Interface with SDIO
+//|
+//| Controls an SD card over SDIO. SDIO is a parallel protocol designed
+//| for SD cards. It uses a clock pin, a command pin, and 1 or 4
+//| data pins. It can be operated at a high frequency such as
+//| 25MHz. Usually an SDCard object is used with ``storage.VfsFat``
+//| to allow file I/O to an SD card."""
+//|
+//| def __init__(self, clock: microcontroller.Pin, command: microcontroller.Pin, data: Sequence[microcontroller.Pin], frequency: int) -> None:
+//| """Construct an SDIO SD Card object with the given properties
+//|
+//| :param ~microcontroller.Pin clock: the pin to use for the clock.
+//| :param ~microcontroller.Pin command: the pin to use for the command.
+//| :param data: A sequence of pins to use for data.
+//| :param frequency: The frequency of the bus in Hz
+//|
+//| Example usage:
+//|
+//| .. code-block:: python
+//|
+//| import os
+//|
+//| import board
+//| import sdioio
+//| import storage
+//|
+//| sd = sdioio.SDCard(
+//| clock=board.SDIO_CLOCK,
+//| command=board.SDIO_COMMAND,
+//| data=board.SDIO_DATA,
+//| frequency=25000000)
+//| vfs = storage.VfsFat(sd)
+//| storage.mount(vfs, '/sd')
+//| os.listdir('/sd')"""
+//| ...
+//|
+
+STATIC mp_obj_t sdioio_sdcard_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
+ sdioio_sdcard_obj_t *self = m_new_obj(sdioio_sdcard_obj_t);
+ self->base.type = &sdioio_SDCard_type;
+ enum { ARG_clock, ARG_command, ARG_data, ARG_frequency, NUM_ARGS };
+ static const mp_arg_t allowed_args[] = {
+ { MP_QSTR_clock, MP_ARG_REQUIRED | MP_ARG_KW_ONLY | MP_ARG_OBJ },
+ { MP_QSTR_command, MP_ARG_REQUIRED | MP_ARG_KW_ONLY | MP_ARG_OBJ },
+ { MP_QSTR_data, MP_ARG_REQUIRED | MP_ARG_KW_ONLY | MP_ARG_OBJ },
+ { MP_QSTR_frequency, MP_ARG_REQUIRED | MP_ARG_KW_ONLY | MP_ARG_INT },
+ };
+ MP_STATIC_ASSERT( MP_ARRAY_SIZE(allowed_args) == NUM_ARGS );
+ mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
+
+ mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
+
+ const mcu_pin_obj_t* clock = validate_obj_is_free_pin(args[ARG_clock].u_obj);
+ const mcu_pin_obj_t* command = validate_obj_is_free_pin(args[ARG_command].u_obj);
+ mcu_pin_obj_t *data_pins[4];
+ uint8_t num_data;
+ validate_list_is_free_pins(MP_QSTR_data, data_pins, MP_ARRAY_SIZE(data_pins), args[ARG_data].u_obj, &num_data);
+
+ common_hal_sdioio_sdcard_construct(self, clock, command, num_data, data_pins, args[ARG_frequency].u_int);
+ return MP_OBJ_FROM_PTR(self);
+}
+
+STATIC void check_for_deinit(sdioio_sdcard_obj_t *self) {
+ if (common_hal_sdioio_sdcard_deinited(self)) {
+ raise_deinited_error();
+ }
+}
+
+//| def configure(self, 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.
+//| :param int width: the number of data lines to use. Must be 1 or 4 and must also not exceed the number of data lines at construction
+//|
+//| .. note:: Leaving a value unspecified or 0 means the current setting is kept"""
+//|
+STATIC mp_obj_t sdioio_sdcard_configure(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
+ enum { ARG_frequency, ARG_width, NUM_ARGS };
+ static const mp_arg_t allowed_args[] = {
+ { MP_QSTR_frequency, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} },
+ { MP_QSTR_width, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} },
+ };
+ sdioio_sdcard_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]);
+ check_for_deinit(self);
+ mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
+ MP_STATIC_ASSERT( MP_ARRAY_SIZE(allowed_args) == NUM_ARGS );
+ mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
+
+ mp_int_t frequency = args[ARG_frequency].u_int;
+ if (frequency < 0) {
+ mp_raise_ValueError_varg(translate("Invalid %q"), MP_QSTR_baudrate);
+ }
+
+ uint8_t width = args[ARG_width].u_int;
+ if (width != 0 && width != 1 && width != 4) {
+ mp_raise_ValueError_varg(translate("Invalid %q"), MP_QSTR_width);
+ }
+
+ if (!common_hal_sdioio_sdcard_configure(self, frequency, width)) {
+ mp_raise_OSError(MP_EIO);
+ }
+ return mp_const_none;
+}
+MP_DEFINE_CONST_FUN_OBJ_KW(sdioio_sdcard_configure_obj, 1, sdioio_sdcard_configure);
+
+//| def count(self) -> int:
+//| """Returns the total number of sectors
+//|
+//| Due to technical limitations, this is a function and not a property.
+//|
+//| :return: The number of 512-byte blocks, as a number"""
+//|
+STATIC mp_obj_t sdioio_sdcard_count(mp_obj_t self_in) {
+ sdioio_sdcard_obj_t *self = MP_OBJ_TO_PTR(self_in);
+ check_for_deinit(self);
+ return MP_OBJ_NEW_SMALL_INT(common_hal_sdioio_sdcard_get_count(self));
+}
+MP_DEFINE_CONST_FUN_OBJ_1(sdioio_sdcard_count_obj, sdioio_sdcard_count);
+
+//| def readblocks(self, start_block: int, buf: WriteableBuffer) -> None:
+//|
+//| """Read one or more blocks from the card
+//|
+//| :param int start_block: The block to start reading from
+//| :param bytearray buf: The buffer to write into. Length must be multiple of 512.
+//|
+//| :return: None"""
+mp_obj_t sdioio_sdcard_readblocks(mp_obj_t self_in, mp_obj_t start_block_in, mp_obj_t buf_in) {
+ uint32_t start_block = mp_obj_get_int(start_block_in);
+ mp_buffer_info_t bufinfo;
+ mp_get_buffer_raise(buf_in, &bufinfo, MP_BUFFER_WRITE);
+ sdioio_sdcard_obj_t *self = (sdioio_sdcard_obj_t*)self_in;
+ int result = common_hal_sdioio_sdcard_readblocks(self, start_block, &bufinfo);
+ if (result < 0) {
+ mp_raise_OSError(-result);
+ }
+ return mp_const_none;
+}
+
+MP_DEFINE_CONST_FUN_OBJ_3(sdioio_sdcard_readblocks_obj, sdioio_sdcard_readblocks);
+
+//| def writeblocks(self, start_block: int, buf: WriteableBuffer) -> None:
+//|
+//| """Write one or more blocks to the card
+//|
+//| :param int start_block: The block to start writing from
+//| :param bytearray buf: The buffer to read from. Length must be multiple of 512.
+//|
+//| :return: None"""
+//|
+mp_obj_t sdioio_sdcard_writeblocks(mp_obj_t self_in, mp_obj_t start_block_in, mp_obj_t buf_in) {
+ uint32_t start_block = mp_obj_get_int(start_block_in);
+ mp_buffer_info_t bufinfo;
+ mp_get_buffer_raise(buf_in, &bufinfo, MP_BUFFER_READ);
+ sdioio_sdcard_obj_t *self = (sdioio_sdcard_obj_t*)self_in;
+ int result = common_hal_sdioio_sdcard_writeblocks(self, start_block, &bufinfo);
+ if (result < 0) {
+ mp_raise_OSError(-result);
+ }
+ return mp_const_none;
+}
+
+MP_DEFINE_CONST_FUN_OBJ_3(sdioio_sdcard_writeblocks_obj, sdioio_sdcard_writeblocks);
+
+//| @property
+//| def frequency(self) -> int:
+//| """The actual SDIO bus frequency. This may not match the frequency
+//| requested due to internal limitations."""
+//| ...
+//|
+STATIC mp_obj_t sdioio_sdcard_obj_get_frequency(mp_obj_t self_in) {
+ sdioio_sdcard_obj_t *self = MP_OBJ_TO_PTR(self_in);
+ check_for_deinit(self);
+ return MP_OBJ_NEW_SMALL_INT(common_hal_sdioio_sdcard_get_frequency(self));
+}
+MP_DEFINE_CONST_FUN_OBJ_1(sdioio_sdcard_get_frequency_obj, sdioio_sdcard_obj_get_frequency);
+
+const mp_obj_property_t sdioio_sdcard_frequency_obj = {
+ .base.type = &mp_type_property,
+ .proxy = {(mp_obj_t)&sdioio_sdcard_get_frequency_obj,
+ (mp_obj_t)&mp_const_none_obj,
+ (mp_obj_t)&mp_const_none_obj},
+};
+
+//| @property
+//| def width(self) -> int:
+//| """The actual SDIO bus width, in bits"""
+//| ...
+//|
+STATIC mp_obj_t sdioio_sdcard_obj_get_width(mp_obj_t self_in) {
+ sdioio_sdcard_obj_t *self = MP_OBJ_TO_PTR(self_in);
+ check_for_deinit(self);
+ return MP_OBJ_NEW_SMALL_INT(common_hal_sdioio_sdcard_get_width(self));
+}
+MP_DEFINE_CONST_FUN_OBJ_1(sdioio_sdcard_get_width_obj, sdioio_sdcard_obj_get_width);
+
+const mp_obj_property_t sdioio_sdcard_width_obj = {
+ .base.type = &mp_type_property,
+ .proxy = {(mp_obj_t)&sdioio_sdcard_get_width_obj,
+ (mp_obj_t)&mp_const_none_obj,
+ (mp_obj_t)&mp_const_none_obj},
+};
+
+//| def deinit(self) -> None:
+//| """Disable permanently.
+//|
+//| :return: None"""
+STATIC mp_obj_t sdioio_sdcard_obj_deinit(mp_obj_t self_in) {
+ sdioio_sdcard_obj_t *self = MP_OBJ_TO_PTR(self_in);
+ common_hal_sdioio_sdcard_deinit(self);
+ return mp_const_none;
+}
+MP_DEFINE_CONST_FUN_OBJ_1(sdioio_sdcard_deinit_obj, sdioio_sdcard_obj_deinit);
+
+//| def __enter__(self) -> SDCard:
+//| """No-op used by Context Managers.
+//| Provided by context manager helper."""
+//| ...
+//|
+
+//| def __exit__(self) -> None:
+//| """Automatically deinitializes the hardware when exiting a context. See
+//| :ref:`lifetime-and-contextmanagers` for more info."""
+//| ...
+//|
+STATIC mp_obj_t sdioio_sdcard_obj___exit__(size_t n_args, const mp_obj_t *args) {
+ (void)n_args;
+ common_hal_sdioio_sdcard_deinit(args[0]);
+ return mp_const_none;
+}
+STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(sdioio_sdcard_obj___exit___obj, 4, 4, sdioio_sdcard_obj___exit__);
+
+STATIC const mp_rom_map_elem_t sdioio_sdcard_locals_dict_table[] = {
+ { MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&sdioio_sdcard_deinit_obj) },
+ { MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&default___enter___obj) },
+ { MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&sdioio_sdcard_obj___exit___obj) },
+
+ { MP_ROM_QSTR(MP_QSTR_configure), MP_ROM_PTR(&sdioio_sdcard_configure_obj) },
+ { MP_ROM_QSTR(MP_QSTR_frequency), MP_ROM_PTR(&sdioio_sdcard_frequency_obj) },
+ { MP_ROM_QSTR(MP_QSTR_width), MP_ROM_PTR(&sdioio_sdcard_width_obj) },
+
+ { MP_ROM_QSTR(MP_QSTR_count), MP_ROM_PTR(&sdioio_sdcard_count_obj) },
+ { MP_ROM_QSTR(MP_QSTR_readblocks), MP_ROM_PTR(&sdioio_sdcard_readblocks_obj) },
+ { MP_ROM_QSTR(MP_QSTR_writeblocks), MP_ROM_PTR(&sdioio_sdcard_writeblocks_obj) },
+};
+STATIC MP_DEFINE_CONST_DICT(sdioio_sdcard_locals_dict, sdioio_sdcard_locals_dict_table);
+
+const mp_obj_type_t sdioio_SDCard_type = {
+ { &mp_type_type },
+ .name = MP_QSTR_SDCard,
+ .make_new = sdioio_sdcard_make_new,
+ .locals_dict = (mp_obj_dict_t*)&sdioio_sdcard_locals_dict,
+};
diff --git a/shared-bindings/sdioio/SDCard.h b/shared-bindings/sdioio/SDCard.h
new file mode 100644
index 000000000..7f62ee7a6
--- /dev/null
+++ b/shared-bindings/sdioio/SDCard.h
@@ -0,0 +1,66 @@
+/*
+ * 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_BUSIO_SDIO_H
+#define MICROPY_INCLUDED_SHARED_BINDINGS_BUSIO_SDIO_H
+
+#include "py/obj.h"
+
+#include "common-hal/microcontroller/Pin.h"
+#include "common-hal/sdioio/SDCard.h"
+
+// Type object used in Python. Should be shared between ports.
+extern const mp_obj_type_t sdioio_SDCard_type;
+
+// Construct an underlying SDIO object.
+extern void common_hal_sdioio_sdcard_construct(sdioio_sdcard_obj_t *self,
+ const mcu_pin_obj_t * clock, const mcu_pin_obj_t * command,
+ uint8_t num_data, mcu_pin_obj_t ** data, uint32_t frequency);
+
+extern void common_hal_sdioio_sdcard_deinit(sdioio_sdcard_obj_t *self);
+extern bool common_hal_sdioio_sdcard_deinited(sdioio_sdcard_obj_t *self);
+
+extern bool common_hal_sdioio_sdcard_configure(sdioio_sdcard_obj_t *self, uint32_t baudrate, uint8_t width);
+
+extern void common_hal_sdioio_sdcard_unlock(sdioio_sdcard_obj_t *self);
+
+// Return actual SDIO bus frequency.
+uint32_t common_hal_sdioio_sdcard_get_frequency(sdioio_sdcard_obj_t* self);
+
+// Return SDIO bus width.
+uint8_t common_hal_sdioio_sdcard_get_width(sdioio_sdcard_obj_t* self);
+
+// Return number of device blocks
+uint32_t common_hal_sdioio_sdcard_get_count(sdioio_sdcard_obj_t* self);
+
+// Read or write blocks
+int common_hal_sdioio_sdcard_readblocks(sdioio_sdcard_obj_t* self, uint32_t start_block, mp_buffer_info_t *bufinfo);
+int common_hal_sdioio_sdcard_writeblocks(sdioio_sdcard_obj_t* self, uint32_t start_block, mp_buffer_info_t *bufinfo);
+
+// This is used by the supervisor to claim SDIO devices indefinitely.
+extern void common_hal_sdioio_sdcard_never_reset(sdioio_sdcard_obj_t *self);
+
+#endif // MICROPY_INCLUDED_SHARED_BINDINGS_BUSIO_SDIO_H
diff --git a/shared-bindings/sdioio/__init__.c b/shared-bindings/sdioio/__init__.c
new file mode 100644
index 000000000..b88e5c3a9
--- /dev/null
+++ b/shared-bindings/sdioio/__init__.c
@@ -0,0 +1,47 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020 Jeff Epler for Adafruit Industries
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+
+#include <stdint.h>
+
+#include "py/obj.h"
+#include "py/runtime.h"
+
+#include "shared-bindings/sdioio/SDCard.h"
+
+//| """Interface to an SD card via the SDIO bus"""
+
+STATIC const mp_rom_map_elem_t sdioio_module_globals_table[] = {
+ { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_sdio) },
+ { MP_ROM_QSTR(MP_QSTR_SDCard), MP_ROM_PTR(&sdioio_SDCard_type) },
+};
+
+STATIC MP_DEFINE_CONST_DICT(sdioio_module_globals, sdioio_module_globals_table);
+
+const mp_obj_module_t sdioio_module = {
+ .base = { &mp_type_module },
+ .globals = (mp_obj_dict_t*)&sdioio_module_globals,
+};
diff --git a/shared-bindings/sdioio/__init__.h b/shared-bindings/sdioio/__init__.h
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/shared-bindings/sdioio/__init__.h
diff --git a/shared-bindings/socket/__init__.c b/shared-bindings/socket/__init__.c
index 19c4850cd..53ac57d11 100644
--- a/shared-bindings/socket/__init__.c
+++ b/shared-bindings/socket/__init__.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2014 Damien P. George
* 2018 Nick Moore for Adafruit Industries
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -39,6 +39,9 @@
//| """TCP, UDP and RAW socket support
//|
+//| .. warning:: This module is disabled in 6.x and will removed in 7.x. Please use networking
+//| libraries instead. (Native networking will provide a socket compatible class.)
+//|
//| Create TCP, UDP and RAW sockets for communicating over the Internet."""
//|
@@ -46,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
@@ -93,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)"""
@@ -120,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"""
@@ -145,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)"""
@@ -182,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)"""
@@ -209,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: ReadableBuffer) -> int:
//| """Send some bytes to the connected remote address.
//| Suits sockets of type SOCK_STREAM
//|
@@ -246,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
@@ -282,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
@@ -309,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: ReadableBuffer, address: tuple) -> int:
//| """Send some bytes to a specific address.
//| Suits sockets of type SOCK_DGRAM
//|
@@ -343,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
//|
@@ -382,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"""
//| ...
//|
@@ -416,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."""
@@ -447,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."""
@@ -509,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: str, port: int) -> 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 3abc5512c..79c5274aa 100644
--- a/shared-bindings/storage/__init__.c
+++ b/shared-bindings/storage/__init__.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
* Copyright (c) 2015 Josef Gajdusek
* Copyright (c) 2016 Scott Shawcroft for Adafruit Industries
*
@@ -43,7 +43,7 @@
//| directly."""
//|
-//| def mount(filesystem: Any, mount_path: Any, *, readonly: bool = False) -> Any:
+//| def mount(filesystem: VfsFat, mount_path: str, *, 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[str, 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: str, 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: str) -> 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: str) -> None:
//| """Create a new VfsFat filesystem around the given block device.
//|
//| :param block_device: Block device the the filesystem lives on"""
//|
-//| label: Any = ...
-//| """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."""
-//| ...
+//| label: str
+//| """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: str, mode: str) -> None:
//| """Like builtin ``open()``"""
//| ...
//|
-//| def ilistdir(self, path: Any) -> Any:
+//| def ilistdir(self, path: str) -> Iterator[Tuple[AnyStr, int, int, int]]:
//| """Return an iterator whose values describe files and folders within
//| ``path``"""
//| ...
//|
-//| def mkdir(self, path: Any) -> Any:
+//| def mkdir(self, path: str) -> None:
//| """Like `os.mkdir`"""
//| ...
//|
-//| def rmdir(self, path: Any) -> Any:
+//| def rmdir(self, path: str) -> None:
//| """Like `os.rmdir`"""
//| ...
//|
-//| def stat(self, path: Any) -> Any:
+//| def stat(self, path: str) -> str:
//| """Like `os.stat`"""
//| ...
//|
-//| def statvfs(self, path: Any) -> Any:
+//| def statvfs(self, path: str) -> Tuple[str, str, str, str, str, str, str, str, str, str]:
//| """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 256b385c8..d74b96212 100644
--- a/shared-bindings/struct/__init__.c
+++ b/shared-bindings/struct/__init__.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
* Copyright (c) 2014 Paul Sokolovsky
* Copyright (c) 2017 Michael McWethy
*
@@ -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: str, *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: str, 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: str, 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: str, 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..84d8370dd 100755
--- a/shared-bindings/supervisor/Runtime.c
+++ b/shared-bindings/supervisor/Runtime.c
@@ -39,13 +39,13 @@
//| 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."""
//| ...
//|
-//| serial_connected: bool = ...
+//| serial_connected: bool
//| """Returns the USB serial communication status (read-only).
//|
//| .. note::
@@ -73,7 +73,7 @@ const mp_obj_property_t supervisor_serial_connected_obj = {
};
-//| serial_bytes_available: int = ...
+//| serial_bytes_available: int
//| """Returns the whether any bytes are available to read
//| on the USB serial input. Allows for polling to see whether
//| to call the built-in input() or wait. (read-only)"""
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/supervisor/__init__.c b/shared-bindings/supervisor/__init__.c
index 1830308b7..b59394bbc 100644
--- a/shared-bindings/supervisor/__init__.c
+++ b/shared-bindings/supervisor/__init__.c
@@ -39,7 +39,7 @@
//| """Supervisor settings"""
//|
-//| runtime: Runtime = ...
+//| runtime: Runtime
//| """Runtime information, such as ``runtime.serial_connected``
//| (USB serial connection status).
//| This object is the sole instance of `supervisor.Runtime`."""
diff --git a/shared-bindings/terminalio/Terminal.c b/shared-bindings/terminalio/Terminal.c
index 5c045fdee..3d53e3cce 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: displayio.TileGrid, 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 531980eff..262da17fd 100644
--- a/shared-bindings/time/__init__.c
+++ b/shared-bindings/time/__init__.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
* Copyright (c) 2015 Josef Gajdusek
* Copyright (c) 2016 Scott Shawcroft for Adafruit Industries
*
@@ -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)``
@@ -102,7 +102,7 @@ mp_obj_t struct_time_make_new(const mp_obj_type_t *type, size_t n_args, const mp
//| * ``tm_month``: the month, range [1, 12]
//| * ``tm_mday``: the day of the month, range [1, 31]
//| * ``tm_hour``: the hour, range [0, 23]
-//| * ``tm_minute``: the minute, range [0, 59]
+//| * ``tm_min``: the minute, range [0, 59]
//| * ``tm_sec``: the second, range [0, 61]
//| * ``tm_wday``: the day of the week, range [0, 6], Monday is 0
//| * ``tm_yday``: the day of the year, range [1, 366], -1 indicates not known
@@ -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 4c1d534ea..ff723ccc7 100644
--- a/shared-bindings/touchio/TouchIn.c
+++ b/shared-bindings/touchio/TouchIn.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 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
@@ -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/touchio/TouchIn.h b/shared-bindings/touchio/TouchIn.h
index e04e79c0b..42f9da46d 100644
--- a/shared-bindings/touchio/TouchIn.h
+++ b/shared-bindings/touchio/TouchIn.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/shared-bindings/uheap/__init__.c b/shared-bindings/uheap/__init__.c
index f089f2922..daf55a613 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: object) -> 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/ulab/filter/__init__.pyi b/shared-bindings/ulab/filter/__init__.pyi
index fff404300..5e7202e06 100644
--- a/shared-bindings/ulab/filter/__init__.pyi
+++ b/shared-bindings/ulab/filter/__init__.pyi
@@ -17,3 +17,20 @@ def convolve(r, c=None):
Convolution is most time-efficient when both inputs are of float type."""
...
+
+def sosfilt(sos : ulab.array, x : ulab.array, *, xi : Optional[ulab.array] = None) -> Union[ulab.array, Tuple[ulab.array, ulab.array]]:
+ """
+ :param ulab.array sos: Array of second-order filter coefficients, must have shape (n_sections, 6). Each row corresponds to a second-order section, with the first three columns providing the numerator coefficients and the last three providing the denominator coefficients.
+ :param ulab.array x: The data to be filtered
+ :param ulab.array zi: Optional initial conditions for the filter
+
+ :return: If ``xi`` is not specified, the filter result alone is returned. If ``xi`` is specified, the return value is a 2-tuple of the filter result and the final filter conditions.
+
+ Filter data along one dimension using cascaded second-order sections.
+
+ Filter a data sequence, x, using a digital IIR filter defined by sos.
+
+ The filter function is implemented as a series of second-order filters with direct-form II transposed structure. It is designed to minimize numerical precision errors for high-order filters.
+
+ Filter coefficients can be generated by using scipy's filter generators such as ``signal.ellip(..., output='sos')``."""
+ ...
diff --git a/shared-bindings/usb_hid/Device.c b/shared-bindings/usb_hid/Device.c
index 8c0c364ff..83c0df4ae 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_hid/__init__.c b/shared-bindings/usb_hid/__init__.c
index e12ea8da4..36111e919 100644
--- a/shared-bindings/usb_hid/__init__.c
+++ b/shared-bindings/usb_hid/__init__.c
@@ -36,7 +36,7 @@
//| The `usb_hid` module allows you to output data as a HID device."""
//|
-//| usb_hid.devices: Any = ...
+//| devices: Tuple[Device, ...]
//| """Tuple of all active HID device interfaces."""
//|
STATIC const mp_rom_map_elem_t usb_hid_module_globals_table[] = {
diff --git a/shared-bindings/usb_midi/PortIn.c b/shared-bindings/usb_midi/PortIn.c
index 9d9310b47..c621c8c50 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: 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
@@ -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..8f0d58d87 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"""
@@ -37,7 +37,7 @@ static mp_obj_t vectorio_circle_make_new(const mp_obj_type_t *type, size_t n_arg
}
-//| radius : int = ...
+//| radius : int
//| """The radius of the circle in pixels."""
//|
STATIC mp_obj_t vectorio_circle_obj_get_radius(mp_obj_t self_in) {
diff --git a/shared-bindings/vectorio/Polygon.c b/shared-bindings/vectorio/Polygon.c
index 3443d9e42..6a72f9124 100644
--- a/shared-bindings/vectorio/Polygon.c
+++ b/shared-bindings/vectorio/Polygon.c
@@ -15,10 +15,8 @@
// #define VECTORIO_POLYGON_DEBUG(...) mp_printf(&mp_plat_print __VA_OPT__(,) __VA_ARGS__)
-//| from typing import List, Tuple
-//|
//| class Polygon:
-//| def __init__(self, points: List[ Tuple[ x, y ], ... ] ):
+//| def __init__(self, points: List[Tuple[int, int]]) -> None:
//| """Represents a closed shape by ordered vertices
//|
//| :param points: Vertices for the polygon"""
@@ -44,25 +42,12 @@ static mp_obj_t vectorio_polygon_make_new(const mp_obj_type_t *type, size_t n_ar
}
-//| points: List[ Tuple[ x, y ], ... ] = ...
+//| points: List[Tuple[int, int]]
//| """Set a new look and shape for this polygon"""
//|
STATIC mp_obj_t vectorio_polygon_obj_get_points(mp_obj_t self_in) {
vectorio_polygon_t *self = MP_OBJ_TO_PTR(self_in);
- mp_obj_t list = mp_obj_new_list(0, NULL);
-
- size_t len = 0;
- mp_obj_t *items;
- mp_obj_list_get(common_hal_vectorio_polygon_get_points(self), &len, &items);
-
- for (size_t i = 0; i < len; i += 2) {
- mp_obj_t tuple[] = { items[i], items[i+1] };
- mp_obj_list_append(
- list,
- mp_obj_new_tuple(2, tuple)
- );
- }
- return list;
+ return common_hal_vectorio_polygon_get_points(self);
}
MP_DEFINE_CONST_FUN_OBJ_1(vectorio_polygon_get_points_obj, vectorio_polygon_obj_get_points);
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..957e9dc08 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: 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.
@@ -93,7 +93,7 @@ STATIC mp_obj_t vectorio_vector_shape_make_new(const mp_obj_type_t *type, size_t
}
-//| x: int = ...
+//| x: int
//| """X position of the center point of the shape in the parent."""
//|
STATIC mp_obj_t vectorio_vector_shape_obj_get_x(mp_obj_t self_in) {
@@ -119,7 +119,7 @@ const mp_obj_property_t vectorio_vector_shape_x_obj = {
};
-//| y: int = ...
+//| y: int
//| """Y position of the center point of the shape in the parent."""
//|
STATIC mp_obj_t vectorio_vector_shape_obj_get_y(mp_obj_t self_in) {
@@ -145,7 +145,7 @@ const mp_obj_property_t vectorio_vector_shape_y_obj = {
};
-//| pixel_shader: displayio.Palette = ...
+//| pixel_shader: displayio.Palette
//| """The pixel shader of the shape."""
//|
STATIC mp_obj_t vectorio_vector_shape_obj_get_pixel_shader(mp_obj_t self_in) {
diff --git a/shared-bindings/watchdog/WatchDogMode.c b/shared-bindings/watchdog/WatchDogMode.c
index 369454c11..71512bdf8 100644
--- a/shared-bindings/watchdog/WatchDogMode.c
+++ b/shared-bindings/watchdog/WatchDogMode.c
@@ -29,18 +29,18 @@
//| 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: WatchDogMode
//| """Raise an exception when the WatchDogTimer expires.
//|
-//| :type watchdog.WatchDogMode:"""
+//| :type WatchDogMode:"""
//|
-//| RESET: Any = ...
+//| RESET: WatchDogMode
//| """Reset the system if the WatchDogTimer expires.
//|
-//| :type watchdog.WatchDogMode:"""
+//| :type WatchDogMode:"""
//|
const mp_obj_type_t watchdog_watchdogmode_type;
diff --git a/shared-bindings/watchdog/WatchDogTimer.c b/shared-bindings/watchdog/WatchDogTimer.c
index 52bda4c77..09219f710 100644
--- a/shared-bindings/watchdog/WatchDogTimer.c
+++ b/shared-bindings/watchdog/WatchDogTimer.c
@@ -49,12 +49,12 @@
//| """
//|
-//| def __init__(self, ):
+//| def __init__(self) -> None:
//| """Not currently dynamically supported. Access the sole instance through `microcontroller.watchdog`."""
//| ...
//|
-//| def feed(self):
+//| def feed(self) -> None:
//| """Feed the watchdog timer. This must be called regularly, otherwise
//| the timer will expire."""
//| ...
@@ -71,7 +71,7 @@ STATIC mp_obj_t watchdog_watchdogtimer_feed(mp_obj_t self_in) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(watchdog_watchdogtimer_feed_obj, watchdog_watchdogtimer_feed);
-//| def deinit(self):
+//| def deinit(self) -> None:
//| """Stop the watchdog timer. This may raise an error if the watchdog
//| timer cannot be disabled on this platform."""
//| ...
@@ -89,7 +89,7 @@ STATIC mp_obj_t watchdog_watchdogtimer_deinit(mp_obj_t self_in) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(watchdog_watchdogtimer_deinit_obj, watchdog_watchdogtimer_deinit);
-//| timeout: float = ...
+//| timeout: float
//| """The maximum number of seconds that can elapse between calls
//| to feed()"""
//|
@@ -119,7 +119,7 @@ const mp_obj_property_t watchdog_watchdogtimer_timeout_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| mode: watchdog.WatchDogMode = ...
+//| mode: WatchDogMode
//| """The current operating mode of the WatchDogTimer `watchdog.WatchDogMode`.
//|
//| Setting a WatchDogMode activates the WatchDog::
diff --git a/shared-bindings/wiznet/__init__.c b/shared-bindings/wiznet/__init__.c
index 0d3f1e4cd..8df06b546 100644
--- a/shared-bindings/wiznet/__init__.c
+++ b/shared-bindings/wiznet/__init__.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2014 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
@@ -35,7 +35,12 @@
#include "shared-module/network/__init__.h"
-//| """Support for WizNet hardware, including the WizNet 5500 Ethernet adaptor."""
+//| """Support for WizNet hardware, including the WizNet 5500 Ethernet adaptor.
+//|
+//|
+//| .. warning:: This module is disabled in 6.x and will removed in 7.x. Please use networking
+//| libraries instead.
+//| """
//|
extern const mod_network_nic_type_t mod_network_nic_type_wiznet5k;
diff --git a/shared-bindings/wiznet/wiznet5k.c b/shared-bindings/wiznet/wiznet5k.c
index 2f49dffea..4e5744d82 100644
--- a/shared-bindings/wiznet/wiznet5k.c
+++ b/shared-bindings/wiznet/wiznet5k.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2014 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
@@ -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: Optional[Tuple] = None) -> Optional[Tuple]:
//| """Called without parameters, returns a tuple of
//| (ip_address, subnet_mask, gateway_address, dns_server)
//|
diff --git a/shared-module/audiomp3/MP3Decoder.c b/shared-module/audiomp3/MP3Decoder.c
index 30357c616..5f3f42a51 100644
--- a/shared-module/audiomp3/MP3Decoder.c
+++ b/shared-module/audiomp3/MP3Decoder.c
@@ -36,11 +36,12 @@
#include "shared-module/audiomp3/MP3Decoder.h"
#include "supervisor/shared/translate.h"
+#include "supervisor/background_callback.h"
#include "lib/mp3/src/mp3common.h"
#define MAX_BUFFER_LEN (MAX_NSAMP * MAX_NGRAN * MAX_NCHAN * sizeof(int16_t))
-/** Fill the input buffer if it is less than half full.
+/** Fill the input buffer unconditionally.
*
* Returns true if the input buffer contains any useful data,
* false otherwise. (The input buffer will be padded to the end with
@@ -50,10 +51,7 @@
*
* Sets self->eof if any read of the file returns 0 bytes
*/
-STATIC bool mp3file_update_inbuf(audiomp3_mp3file_obj_t* self) {
- // If buffer is over half full, do nothing
- if (self->inbuf_offset < self->inbuf_length/2) return true;
-
+STATIC bool mp3file_update_inbuf_always(audiomp3_mp3file_obj_t* self) {
// If we didn't previously reach the end of file, we can try reading now
if (!self->eof) {
@@ -87,6 +85,26 @@ STATIC bool mp3file_update_inbuf(audiomp3_mp3file_obj_t* self) {
return self->inbuf_offset < self->inbuf_length;
}
+/** Update the inbuf from a background callback.
+ *
+ * This variant is introduced so that at the site of the
+ * add_background_callback_core call, the prototype matches.
+ */
+STATIC void mp3file_update_inbuf_cb(void* self) {
+ mp3file_update_inbuf_always(self);
+}
+
+/** Fill the input buffer if it is less than half full.
+ *
+ * Returns the same as mp3file_update_inbuf_always.
+ */
+STATIC bool mp3file_update_inbuf_half(audiomp3_mp3file_obj_t* self) {
+ // If buffer is over half full, do nothing
+ if (self->inbuf_offset < self->inbuf_length/2) return true;
+
+ return mp3file_update_inbuf_always(self);
+}
+
#define READ_PTR(self) (self->inbuf + self->inbuf_offset)
#define BYTES_LEFT(self) (self->inbuf_length - self->inbuf_offset)
#define CONSUME(self, n) (self->inbuf_offset += n)
@@ -94,7 +112,7 @@ STATIC bool mp3file_update_inbuf(audiomp3_mp3file_obj_t* self) {
// http://id3.org/d3v2.3.0
// http://id3.org/id3v2.3.0
STATIC void mp3file_skip_id3v2(audiomp3_mp3file_obj_t* self) {
- mp3file_update_inbuf(self);
+ mp3file_update_inbuf_half(self);
if (BYTES_LEFT(self) < 10) {
return;
}
@@ -129,11 +147,11 @@ STATIC void mp3file_skip_id3v2(audiomp3_mp3file_obj_t* self) {
*/
STATIC bool mp3file_find_sync_word(audiomp3_mp3file_obj_t* self) {
do {
- mp3file_update_inbuf(self);
+ mp3file_update_inbuf_half(self);
int offset = MP3FindSyncWord(READ_PTR(self), BYTES_LEFT(self));
if (offset >= 0) {
CONSUME(self, offset);
- mp3file_update_inbuf(self);
+ mp3file_update_inbuf_half(self);
return true;
}
CONSUME(self, MAX(0, BYTES_LEFT(self) - 16));
@@ -209,12 +227,14 @@ void common_hal_audiomp3_mp3file_construct(audiomp3_mp3file_obj_t* self,
}
void common_hal_audiomp3_mp3file_set_file(audiomp3_mp3file_obj_t* self, pyb_file_obj_t* file) {
+ background_callback_begin_critical_section();
+
self->file = file;
f_lseek(&self->file->fp, 0);
self->inbuf_offset = self->inbuf_length;
self->eof = 0;
self->other_channel = -1;
- mp3file_update_inbuf(self);
+ mp3file_update_inbuf_half(self);
mp3file_find_sync_word(self);
// It **SHOULD** not be necessary to do this; the buffer should be filled
// with fresh content before it is returned by get_buffer(). The fact that
@@ -224,7 +244,9 @@ void common_hal_audiomp3_mp3file_set_file(audiomp3_mp3file_obj_t* self, pyb_file
memset(self->buffers[0], 0, MAX_BUFFER_LEN);
memset(self->buffers[1], 0, MAX_BUFFER_LEN);
MP3FrameInfo fi;
- if(!mp3file_get_next_frame_info(self, &fi)) {
+ bool result = mp3file_get_next_frame_info(self, &fi);
+ background_callback_end_critical_section();
+ if (!result) {
mp_raise_msg(&mp_type_RuntimeError,
translate("Failed to parse MP3 file"));
}
@@ -277,13 +299,15 @@ void audiomp3_mp3file_reset_buffer(audiomp3_mp3file_obj_t* self,
}
// We don't reset the buffer index in case we're looping and we have an odd number of buffer
// loads
+ background_callback_begin_critical_section();
f_lseek(&self->file->fp, 0);
self->inbuf_offset = self->inbuf_length;
self->eof = 0;
self->other_channel = -1;
- mp3file_update_inbuf(self);
+ mp3file_update_inbuf_half(self);
mp3file_skip_id3v2(self);
mp3file_find_sync_word(self);
+ background_callback_end_critical_section();
}
audioio_get_buffer_result_t audiomp3_mp3file_get_buffer(audiomp3_mp3file_obj_t* self,
@@ -321,6 +345,14 @@ audioio_get_buffer_result_t audiomp3_mp3file_get_buffer(audiomp3_mp3file_obj_t*
uint8_t *inbuf = READ_PTR(self);
int err = MP3Decode(self->decoder, &inbuf, &bytes_left, buffer, 0);
CONSUME(self, BYTES_LEFT(self) - bytes_left);
+
+ if (self->inbuf_offset >= 512) {
+ background_callback_add(
+ &self->inbuf_fill_cb,
+ mp3file_update_inbuf_cb,
+ self);
+ }
+
if (err) {
return GET_BUFFER_DONE;
}
diff --git a/shared-module/audiomp3/MP3Decoder.h b/shared-module/audiomp3/MP3Decoder.h
index 9ee1d0949..f91f102a2 100644
--- a/shared-module/audiomp3/MP3Decoder.h
+++ b/shared-module/audiomp3/MP3Decoder.h
@@ -28,6 +28,7 @@
#ifndef MICROPY_INCLUDED_SHARED_MODULE_AUDIOIO_MP3FILE_H
#define MICROPY_INCLUDED_SHARED_MODULE_AUDIOIO_MP3FILE_H
+#include "supervisor/background_callback.h"
#include "extmod/vfs_fat.h"
#include "py/obj.h"
@@ -36,6 +37,7 @@
typedef struct {
mp_obj_base_t base;
struct _MP3DecInfo *decoder;
+ background_callback_t inbuf_fill_cb;
uint8_t* inbuf;
uint32_t inbuf_length;
uint32_t inbuf_offset;
diff --git a/shared-module/bitbangio/I2C.c b/shared-module/bitbangio/I2C.c
index 5a9ac9a99..d44aec0e7 100644
--- a/shared-module/bitbangio/I2C.c
+++ b/shared-module/bitbangio/I2C.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2016 Damien P. George, Scott Shawcroft
+ * SPDX-FileCopyrightText: Copyright (c) 2016 Damien P. George, 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
diff --git a/shared-module/bitbangio/SPI.c b/shared-module/bitbangio/SPI.c
index e0ff1184f..f3fe16029 100644
--- a/shared-module/bitbangio/SPI.c
+++ b/shared-module/bitbangio/SPI.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/shared-module/board/__init__.c b/shared-module/board/__init__.c
index 0fbf916cd..2c9139d8a 100644
--- a/shared-module/board/__init__.c
+++ b/shared-module/board/__init__.c
@@ -123,7 +123,7 @@ mp_obj_t common_hal_board_create_uart(void) {
#endif
common_hal_busio_uart_construct(self, tx, rx, rts, cts, rs485_dir, rs485_invert,
- 9600, 8, PARITY_NONE, 1, 1.0f, 64, NULL, false);
+ 9600, 8, BUSIO_UART_PARITY_NONE, 1, 1.0f, 64, NULL, false);
MP_STATE_VM(shared_uart_bus) = MP_OBJ_FROM_PTR(self);
return MP_STATE_VM(shared_uart_bus);
}
diff --git a/shared-module/displayio/Display.c b/shared-module/displayio/Display.c
index a3d877f1a..46bb6fdb5 100644
--- a/shared-module/displayio/Display.c
+++ b/shared-module/displayio/Display.c
@@ -137,7 +137,7 @@ void common_hal_displayio_display_construct(displayio_display_obj_t* self,
// Set the group after initialization otherwise we may send pixels while we delay in
// initialization.
common_hal_displayio_display_show(self, &circuitpython_splash);
- self->auto_refresh = auto_refresh;
+ common_hal_displayio_display_set_auto_refresh(self, auto_refresh);
}
bool common_hal_displayio_display_show(displayio_display_obj_t* self, displayio_group_t* root_group) {
@@ -383,6 +383,13 @@ bool common_hal_displayio_display_get_auto_refresh(displayio_display_obj_t* self
void common_hal_displayio_display_set_auto_refresh(displayio_display_obj_t* self,
bool auto_refresh) {
self->first_manual_refresh = !auto_refresh;
+ if (auto_refresh != self->auto_refresh) {
+ if (auto_refresh) {
+ supervisor_enable_tick();
+ } else {
+ supervisor_disable_tick();
+ }
+ }
self->auto_refresh = auto_refresh;
}
@@ -409,6 +416,7 @@ void displayio_display_background(displayio_display_obj_t* self) {
}
void release_display(displayio_display_obj_t* self) {
+ common_hal_displayio_display_set_auto_refresh(self, false);
release_display_core(&self->core);
#if (CIRCUITPY_PULSEIO)
if (self->backlight_pwm.base.type == &pulseio_pwmout_type) {
@@ -423,7 +431,7 @@ void release_display(displayio_display_obj_t* self) {
}
void reset_display(displayio_display_obj_t* self) {
- self->auto_refresh = true;
+ common_hal_displayio_display_set_auto_refresh(self, true);
self->auto_brightness = true;
common_hal_displayio_display_show(self, NULL);
}
diff --git a/shared-module/displayio/Display.h b/shared-module/displayio/Display.h
index 8adaf597f..861a38fd7 100644
--- a/shared-module/displayio/Display.h
+++ b/shared-module/displayio/Display.h
@@ -29,7 +29,9 @@
#include "shared-bindings/digitalio/DigitalInOut.h"
#include "shared-bindings/displayio/Group.h"
+#if CIRCUITPY_PULSEIO
#include "shared-bindings/pulseio/PWMOut.h"
+#endif
#include "shared-module/displayio/area.h"
#include "shared-module/displayio/display_core.h"
@@ -39,7 +41,9 @@ typedef struct {
displayio_display_core_t core;
union {
digitalio_digitalinout_obj_t backlight_inout;
+ #if CIRCUITPY_PULSEIO
pulseio_pwmout_obj_t backlight_pwm;
+ #endif
};
uint64_t last_backlight_refresh;
uint64_t last_refresh_call;
diff --git a/shared-module/displayio/EPaperDisplay.c b/shared-module/displayio/EPaperDisplay.c
index 6a55687b9..6d9e915b4 100644
--- a/shared-module/displayio/EPaperDisplay.c
+++ b/shared-module/displayio/EPaperDisplay.c
@@ -187,6 +187,7 @@ void displayio_epaperdisplay_finish_refresh(displayio_epaperdisplay_obj_t* self)
displayio_display_core_begin_transaction(&self->core);
self->core.send(self->core.bus, DISPLAY_COMMAND, self->chip_select, &self->refresh_display_command, 1);
displayio_display_core_end_transaction(&self->core);
+ supervisor_enable_tick();
self->refreshing = true;
displayio_display_core_finish_refresh(&self->core);
@@ -301,6 +302,7 @@ bool common_hal_displayio_epaperdisplay_refresh(displayio_epaperdisplay_obj_t* s
if (self->refreshing && self->busy.base.type == &digitalio_digitalinout_type) {
if (common_hal_digitalio_digitalinout_get_value(&self->busy) != self->busy_state) {
+ supervisor_disable_tick();
self->refreshing = false;
// Run stop sequence but don't wait for busy because busy is set when sleeping.
send_command_sequence(self, false, self->stop_sequence, self->stop_sequence_len);
@@ -342,6 +344,7 @@ void displayio_epaperdisplay_background(displayio_epaperdisplay_obj_t* self) {
refresh_done = supervisor_ticks_ms64() - self->core.last_refresh > self->refresh_time;
}
if (refresh_done) {
+ supervisor_disable_tick();
self->refreshing = false;
// Run stop sequence but don't wait for busy because busy is set when sleeping.
send_command_sequence(self, false, self->stop_sequence, self->stop_sequence_len);
@@ -352,6 +355,7 @@ void displayio_epaperdisplay_background(displayio_epaperdisplay_obj_t* self) {
void release_epaperdisplay(displayio_epaperdisplay_obj_t* self) {
if (self->refreshing) {
wait_for_busy(self);
+ supervisor_disable_tick();
self->refreshing = false;
// Run stop sequence but don't wait for busy because busy is set when sleeping.
send_command_sequence(self, false, self->stop_sequence, self->stop_sequence_len);
diff --git a/shared-module/displayio/EPaperDisplay.h b/shared-module/displayio/EPaperDisplay.h
index d08bed546..3b9f6e368 100644
--- a/shared-module/displayio/EPaperDisplay.h
+++ b/shared-module/displayio/EPaperDisplay.h
@@ -29,7 +29,6 @@
#include "shared-bindings/digitalio/DigitalInOut.h"
#include "shared-bindings/displayio/Group.h"
-#include "shared-bindings/pulseio/PWMOut.h"
#include "shared-module/displayio/area.h"
#include "shared-module/displayio/display_core.h"
diff --git a/shared-module/displayio/__init__.c b/shared-module/displayio/__init__.c
index c898bbb98..efc28470f 100644
--- a/shared-module/displayio/__init__.c
+++ b/shared-module/displayio/__init__.c
@@ -190,9 +190,7 @@ void reset_displays(void) {
common_hal_displayio_epaperdisplay_show(display, NULL);
#if CIRCUITPY_FRAMEBUFFERIO
} else if (displays[i].framebuffer_display.base.type == &framebufferio_framebufferdisplay_type) {
- framebufferio_framebufferdisplay_obj_t* display = &displays[i].framebuffer_display;
- display->auto_refresh = true;
- common_hal_framebufferio_framebufferdisplay_show(display, NULL);
+ framebufferio_framebufferdisplay_reset(&displays[i].framebuffer_display);
#endif
}
}
diff --git a/shared-module/framebufferio/FramebufferDisplay.c b/shared-module/framebufferio/FramebufferDisplay.c
index f296da409..2a90fa0d4 100644
--- a/shared-module/framebufferio/FramebufferDisplay.c
+++ b/shared-module/framebufferio/FramebufferDisplay.c
@@ -79,7 +79,7 @@ void common_hal_framebufferio_framebufferdisplay_construct(framebufferio_framebu
// Set the group after initialization otherwise we may send pixels while we delay in
// initialization.
common_hal_framebufferio_framebufferdisplay_show(self, &circuitpython_splash);
- self->auto_refresh = auto_refresh;
+ common_hal_framebufferio_framebufferdisplay_set_auto_refresh(self, auto_refresh);
}
bool common_hal_framebufferio_framebufferdisplay_show(framebufferio_framebufferdisplay_obj_t* self, displayio_group_t* root_group) {
@@ -280,6 +280,13 @@ bool common_hal_framebufferio_framebufferdisplay_get_auto_refresh(framebufferio_
void common_hal_framebufferio_framebufferdisplay_set_auto_refresh(framebufferio_framebufferdisplay_obj_t* self,
bool auto_refresh) {
self->first_manual_refresh = !auto_refresh;
+ if (auto_refresh != self->auto_refresh) {
+ if (auto_refresh) {
+ supervisor_enable_tick();
+ } else {
+ supervisor_disable_tick();
+ }
+ }
self->auto_refresh = auto_refresh;
}
@@ -297,12 +304,13 @@ void framebufferio_framebufferdisplay_background(framebufferio_framebufferdispla
}
void release_framebufferdisplay(framebufferio_framebufferdisplay_obj_t* self) {
+ common_hal_framebufferio_framebufferdisplay_set_auto_refresh(self, false);
release_display_core(&self->core);
self->framebuffer_protocol->deinit(self->framebuffer);
}
void reset_framebufferdisplay(framebufferio_framebufferdisplay_obj_t* self) {
- self->auto_refresh = true;
+ common_hal_framebufferio_framebufferdisplay_set_auto_refresh(self, true);
common_hal_framebufferio_framebufferdisplay_show(self, NULL);
}
@@ -310,3 +318,8 @@ void framebufferio_framebufferdisplay_collect_ptrs(framebufferio_framebufferdisp
gc_collect_ptr(self->framebuffer);
displayio_display_core_collect_ptrs(&self->core);
}
+
+void framebufferio_framebufferdisplay_reset(framebufferio_framebufferdisplay_obj_t* self) {
+ common_hal_framebufferio_framebufferdisplay_set_auto_refresh(self, true);
+ common_hal_framebufferio_framebufferdisplay_show(self, NULL);
+}
diff --git a/shared-module/framebufferio/FramebufferDisplay.h b/shared-module/framebufferio/FramebufferDisplay.h
index 1b68d2ab0..ca1ab984a 100644
--- a/shared-module/framebufferio/FramebufferDisplay.h
+++ b/shared-module/framebufferio/FramebufferDisplay.h
@@ -55,6 +55,7 @@ typedef struct {
void framebufferio_framebufferdisplay_background(framebufferio_framebufferdisplay_obj_t* self);
void release_framebufferdisplay(framebufferio_framebufferdisplay_obj_t* self);
void reset_framebufferdisplay(framebufferio_framebufferdisplay_obj_t* self);
+void framebufferio_framebufferdisplay_reset(framebufferio_framebufferdisplay_obj_t* self);
void framebufferio_framebufferdisplay_collect_ptrs(framebufferio_framebufferdisplay_obj_t* self);
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/network/__init__.h b/shared-module/network/__init__.h
index f4eb05bb5..280cfe6c8 100644
--- a/shared-module/network/__init__.h
+++ b/shared-module/network/__init__.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
* Copyright (c) 2018 Nick Moore
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
diff --git a/shared-module/os/__init__.c b/shared-module/os/__init__.c
index 8060eec4f..39cf40fda 100644
--- a/shared-module/os/__init__.c
+++ b/shared-module/os/__init__.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
* Copyright (c) 2015 Josef Gajdusek
* Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
*
diff --git a/shared-module/sdcardio/SDCard.c b/shared-module/sdcardio/SDCard.c
new file mode 100644
index 000000000..9e861279d
--- /dev/null
+++ b/shared-module/sdcardio/SDCard.c
@@ -0,0 +1,466 @@
+/*
+ * This file is part of the Micro Python project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020 Jeff Epler for Adafruit Industries
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+// This implementation largely follows the structure of adafruit_sdcard.py
+
+#include "shared-bindings/busio/SPI.h"
+#include "shared-bindings/digitalio/DigitalInOut.h"
+#include "shared-bindings/time/__init__.h"
+#include "shared-bindings/util.h"
+#include "shared-module/sdcardio/SDCard.h"
+
+#include "py/mperrno.h"
+
+#if 0
+#define DEBUG_PRINT(...) ((void)mp_printf(&mp_plat_print, ## __VA_ARGS__))
+#else
+#define DEBUG_PRINT(...) ((void)0)
+#endif
+
+#define CMD_TIMEOUT (200)
+
+#define R1_IDLE_STATE (1<<0)
+#define R1_ILLEGAL_COMMAND (1<<2)
+
+#define TOKEN_CMD25 (0xFC)
+#define TOKEN_STOP_TRAN (0xFD)
+#define TOKEN_DATA (0xFE)
+
+STATIC bool lock_and_configure_bus(sdcardio_sdcard_obj_t *self) {
+ if (!common_hal_busio_spi_try_lock(self->bus)) {
+ return false;
+ }
+ common_hal_busio_spi_configure(self->bus, self->baudrate, 0, 0, 8);
+ common_hal_digitalio_digitalinout_set_value(&self->cs, false);
+ return true;
+}
+
+STATIC void lock_bus_or_throw(sdcardio_sdcard_obj_t *self) {
+ if (!lock_and_configure_bus(self)) {
+ mp_raise_OSError(EAGAIN);
+ }
+}
+
+STATIC void clock_card(sdcardio_sdcard_obj_t *self, int bytes) {
+ uint8_t buf[] = {0xff};
+ common_hal_digitalio_digitalinout_set_value(&self->cs, true);
+ for (int i=0; i<bytes; i++) {
+ common_hal_busio_spi_write(self->bus, buf, 1);
+ }
+}
+
+STATIC void extraclock_and_unlock_bus(sdcardio_sdcard_obj_t *self) {
+ clock_card(self, 1);
+ common_hal_busio_spi_unlock(self->bus);
+}
+
+static uint8_t CRC7(const uint8_t* data, uint8_t n) {
+ uint8_t crc = 0;
+ for (uint8_t i = 0; i < n; i++) {
+ uint8_t d = data[i];
+ for (uint8_t j = 0; j < 8; j++) {
+ crc <<= 1;
+ if ((d & 0x80) ^ (crc & 0x80)) {
+ crc ^= 0x09;
+ }
+ d <<= 1;
+ }
+ }
+ return (crc << 1) | 1;
+}
+
+#define READY_TIMEOUT_NS (300 * 1000 * 1000) // 300ms
+STATIC void wait_for_ready(sdcardio_sdcard_obj_t *self) {
+ uint64_t deadline = common_hal_time_monotonic_ns() + READY_TIMEOUT_NS;
+ while (common_hal_time_monotonic_ns() < deadline) {
+ uint8_t b;
+ common_hal_busio_spi_read(self->bus, &b, 1, 0xff);
+ if (b == 0xff) {
+ break;
+ }
+ }
+}
+
+// In Python API, defaults are response=None, data_block=True, wait=True
+STATIC int cmd(sdcardio_sdcard_obj_t *self, int cmd, int arg, void *response_buf, size_t response_len, bool data_block, bool wait) {
+ DEBUG_PRINT("cmd % 3d [%02x] arg=% 11d [%08x] len=%d%s%s\n", cmd, cmd, arg, arg, response_len, data_block ? " data" : "", wait ? " wait" : "");
+ uint8_t cmdbuf[6];
+ cmdbuf[0] = cmd | 0x40;
+ cmdbuf[1] = (arg >> 24) & 0xff;
+ cmdbuf[2] = (arg >> 16) & 0xff;
+ cmdbuf[3] = (arg >> 8) & 0xff;
+ cmdbuf[4] = arg & 0xff;
+ cmdbuf[5] = CRC7(cmdbuf, 5);
+
+ if (wait) {
+ wait_for_ready(self);
+ }
+
+ common_hal_busio_spi_write(self->bus, cmdbuf, sizeof(cmdbuf));
+
+ // Wait for the response (response[7] == 0)
+ bool response_received = false;
+ for (int i=0; i<CMD_TIMEOUT; i++) {
+ common_hal_busio_spi_read(self->bus, cmdbuf, 1, 0xff);
+ if ((cmdbuf[0] & 0x80) == 0) {
+ response_received = true;
+ break;
+ }
+ }
+
+ if (!response_received) {
+ return -EIO;
+ }
+
+ if (response_buf) {
+
+ if (data_block) {
+ cmdbuf[1] = 0xff;
+ do {
+ // Wait for the start block byte
+ common_hal_busio_spi_read(self->bus, cmdbuf+1, 1, 0xff);
+ } while (cmdbuf[1] != 0xfe);
+ }
+
+ common_hal_busio_spi_read(self->bus, response_buf, response_len, 0xff);
+
+ if (data_block) {
+ // Read and discard the CRC-CCITT checksum
+ common_hal_busio_spi_read(self->bus, cmdbuf+1, 2, 0xff);
+ }
+
+ }
+
+ return cmdbuf[0];
+}
+
+STATIC int block_cmd(sdcardio_sdcard_obj_t *self, int cmd_, int block, void *response_buf, size_t response_len, bool data_block, bool wait) {
+ return cmd(self, cmd_, block * self->cdv, response_buf, response_len, true, true);
+}
+
+STATIC bool cmd_nodata(sdcardio_sdcard_obj_t* self, int cmd, int response) {
+ uint8_t cmdbuf[2] = {cmd, 0xff};
+
+ common_hal_busio_spi_write(self->bus, cmdbuf, sizeof(cmdbuf));
+
+ // Wait for the response (response[7] == response)
+ for (int i=0; i<CMD_TIMEOUT; i++) {
+ common_hal_busio_spi_read(self->bus, cmdbuf, 1, 0xff);
+ if (cmdbuf[0] == response) {
+ return 0;
+ }
+ }
+ return -EIO;
+}
+
+STATIC const compressed_string_t *init_card_v1(sdcardio_sdcard_obj_t *self) {
+ for (int i=0; i<CMD_TIMEOUT; i++) {
+ if (cmd(self, 41, 0, NULL, 0, true, true) == 0) {
+ return NULL;
+ }
+ }
+ return translate("timeout waiting for v1 card");
+}
+
+STATIC const compressed_string_t *init_card_v2(sdcardio_sdcard_obj_t *self) {
+ for (int i=0; i<CMD_TIMEOUT; i++) {
+ uint8_t ocr[4];
+ common_hal_time_delay_ms(50);
+ cmd(self, 58, 0, ocr, sizeof(ocr), false, true);
+ cmd(self, 55, 0, NULL, 0, true, true);
+ if (cmd(self, 41, 0x40000000, NULL, 0, true, true) == 0) {
+ cmd(self, 58, 0, ocr, sizeof(ocr), false, true);
+ if ((ocr[0] & 0x40) != 0) {
+ self->cdv = 1;
+ }
+ return NULL;
+ }
+ }
+ return translate("timeout waiting for v2 card");
+}
+
+STATIC const compressed_string_t *init_card(sdcardio_sdcard_obj_t *self) {
+ clock_card(self, 10);
+
+ common_hal_digitalio_digitalinout_set_value(&self->cs, false);
+
+ // CMD0: init card: should return _R1_IDLE_STATE (allow 5 attempts)
+ {
+ bool reached_idle_state = false;
+ for (int i=0; i<5; i++) {
+ if (cmd(self, 0, 0, NULL, 0, true, true) == R1_IDLE_STATE) {
+ reached_idle_state = true;
+ break;
+ }
+ }
+ if (!reached_idle_state) {
+ return translate("no SD card");
+ }
+ }
+
+ // CMD8: determine card version
+ {
+ uint8_t rb7[4];
+ int response = cmd(self, 8, 0x1AA, rb7, sizeof(rb7), false, true);
+ if (response == R1_IDLE_STATE) {
+ const compressed_string_t *result =init_card_v2(self);
+ if (result != NULL) {
+ return result;
+ }
+ } else if (response == (R1_IDLE_STATE | R1_ILLEGAL_COMMAND)) {
+ const compressed_string_t *result =init_card_v1(self);
+ if (result != NULL) {
+ return result;
+ }
+ } else {
+ return translate("couldn't determine SD card version");
+ }
+ }
+
+ // CMD9: get number of sectors
+ {
+ uint8_t csd[16];
+ int response = cmd(self, 9, 0, csd, sizeof(csd), true, true);
+ if (response != 0) {
+ return translate("no response from SD card");
+ }
+ int csd_version = (csd[0] & 0xC0) >> 6;
+ if (csd_version >= 2) {
+ return translate("SD card CSD format not supported");
+ }
+
+ if (csd_version == 1) {
+ self->sectors = ((csd[8] << 8 | csd[9]) + 1) * 1024;
+ } else {
+ uint32_t block_length = 1 << (csd[5] & 0xF);
+ uint32_t c_size = ((csd[6] & 0x3) << 10) | (csd[7] << 2) | ((csd[8] & 0xC) >> 6);
+ uint32_t mult = 1 << (((csd[9] & 0x3) << 1 | (csd[10] & 0x80) >> 7) + 2);
+ self->sectors = block_length / 512 * mult * (c_size + 1);
+ }
+ }
+
+ // CMD16: set block length to 512 bytes
+ {
+ int response = cmd(self, 16, 512, NULL, 0, true, true);
+ if (response != 0) {
+ return translate("can't set 512 block size");
+ }
+ }
+
+ return NULL;
+}
+
+void common_hal_sdcardio_sdcard_construct(sdcardio_sdcard_obj_t *self, busio_spi_obj_t *bus, mcu_pin_obj_t *cs, int baudrate) {
+ self->bus = bus;
+ common_hal_digitalio_digitalinout_construct(&self->cs, cs);
+ common_hal_digitalio_digitalinout_switch_to_output(&self->cs, true, DRIVE_MODE_PUSH_PULL);
+
+ self->cdv = 512;
+ self->sectors = 0;
+ self->baudrate = 250000;
+
+ lock_bus_or_throw(self);
+ const compressed_string_t *result = init_card(self);
+ extraclock_and_unlock_bus(self);
+
+ if (result != NULL) {
+ common_hal_digitalio_digitalinout_deinit(&self->cs);
+ mp_raise_OSError_msg(result);
+ }
+
+ self->baudrate = baudrate;
+}
+
+void common_hal_sdcardio_sdcard_deinit(sdcardio_sdcard_obj_t *self) {
+ if (!self->bus) {
+ return;
+ }
+ self->bus = 0;
+ common_hal_digitalio_digitalinout_deinit(&self->cs);
+}
+
+void common_hal_sdcardio_check_for_deinit(sdcardio_sdcard_obj_t *self) {
+ if (!self->bus) {
+ raise_deinited_error();
+ }
+}
+
+int common_hal_sdcardio_sdcard_get_blockcount(sdcardio_sdcard_obj_t *self) {
+ common_hal_sdcardio_check_for_deinit(self);
+ return self->sectors;
+}
+
+int readinto(sdcardio_sdcard_obj_t *self, void *buf, size_t size) {
+ uint8_t aux[2] = {0, 0};
+ while (aux[0] != 0xfe) {
+ common_hal_busio_spi_read(self->bus, aux, 1, 0xff);
+ }
+
+ common_hal_busio_spi_read(self->bus, buf, size, 0xff);
+
+ // Read checksum and throw it away
+ common_hal_busio_spi_read(self->bus, aux, sizeof(aux), 0xff);
+ return 0;
+}
+
+int readblocks(sdcardio_sdcard_obj_t *self, uint32_t start_block, mp_buffer_info_t *buf) {
+ uint32_t nblocks = buf->len / 512;
+ if (nblocks == 1) {
+ // Use CMD17 to read a single block
+ return block_cmd(self, 17, start_block, buf->buf, buf->len, true, true);
+ } else {
+ // Use CMD18 to read multiple blocks
+ int r = block_cmd(self, 18, start_block, NULL, 0, true, true);
+ if (r < 0) {
+ return r;
+ }
+
+ uint8_t *ptr = buf->buf;
+ while (nblocks--) {
+ r = readinto(self, ptr, 512);
+ if (r < 0) {
+ return r;
+ }
+ ptr += 512;
+ }
+
+ // End the multi-block read
+ r = cmd(self, 12, 0, NULL, 0, true, false);
+
+ // Return first status 0 or last before card ready (0xff)
+ while (r != 0) {
+ uint8_t single_byte;
+ common_hal_busio_spi_read(self->bus, &single_byte, 1, 0xff);
+ if (single_byte & 0x80) {
+ return r;
+ }
+ r = single_byte;
+ }
+ }
+ return 0;
+}
+
+int common_hal_sdcardio_sdcard_readblocks(sdcardio_sdcard_obj_t *self, uint32_t start_block, mp_buffer_info_t *buf) {
+ common_hal_sdcardio_check_for_deinit(self);
+ if (buf->len % 512 != 0) {
+ mp_raise_ValueError(translate("Buffer length must be a multiple of 512"));
+ }
+
+ lock_and_configure_bus(self);
+ int r = readblocks(self, start_block, buf);
+ extraclock_and_unlock_bus(self);
+ return r;
+}
+
+int _write(sdcardio_sdcard_obj_t *self, uint8_t token, void *buf, size_t size) {
+ wait_for_ready(self);
+
+ uint8_t cmd[2];
+ cmd[0] = token;
+
+ common_hal_busio_spi_write(self->bus, cmd, 1);
+ common_hal_busio_spi_write(self->bus, buf, size);
+
+ cmd[0] = cmd[1] = 0xff;
+ common_hal_busio_spi_write(self->bus, cmd, 2);
+
+ // Check the response
+ // This differs from the traditional adafruit_sdcard handling,
+ // but adafruit_sdcard also ignored the return value of SDCard._write(!)
+ // so nobody noticed
+ //
+ //
+ // Response is as follows:
+ // x x x 0 STAT 1
+ // 7 6 5 4 3..1 0
+ // with STATUS 010 indicating "data accepted", and other status bit
+ // combinations indicating failure.
+ // In practice, I was seeing cmd[0] as 0xe5, indicating success
+ for (int i=0; i<CMD_TIMEOUT; i++) {
+ common_hal_busio_spi_read(self->bus, cmd, 1, 0xff);
+ DEBUG_PRINT("i=%02d cmd[0] = 0x%02x\n", i, cmd[0]);
+ if ((cmd[0] & 0b00010001) == 0b00000001) {
+ if ((cmd[0] & 0x1f) != 0x5) {
+ return -EIO;
+ } else {
+ break;
+ }
+ }
+ }
+
+ // Wait for the write to finish
+ do {
+ common_hal_busio_spi_read(self->bus, cmd, 1, 0xff);
+ } while (cmd[0] == 0);
+
+ // Success
+ return 0;
+}
+
+int writeblocks(sdcardio_sdcard_obj_t *self, uint32_t start_block, mp_buffer_info_t *buf) {
+ common_hal_sdcardio_check_for_deinit(self);
+ uint32_t nblocks = buf->len / 512;
+ if (nblocks == 1) {
+ // Use CMD24 to write a single block
+ int r = block_cmd(self, 24, start_block, NULL, 0, true, true);
+ if (r < 0) {
+ return r;
+ }
+ r = _write(self, TOKEN_DATA, buf->buf, buf->len);
+ if (r < 0) {
+ return r;
+ }
+ } else {
+ // Use CMD25 to write multiple block
+ int r = block_cmd(self, 25, start_block, NULL, 0, true, true);
+ if (r < 0) {
+ return r;
+ }
+
+ uint8_t *ptr = buf->buf;
+ while (nblocks--) {
+ r = _write(self, TOKEN_CMD25, ptr, 512);
+ if (r < 0) {
+ return r;
+ }
+ ptr += 512;
+ }
+
+ cmd_nodata(self, TOKEN_STOP_TRAN, 0);
+ }
+ return 0;
+}
+
+int common_hal_sdcardio_sdcard_writeblocks(sdcardio_sdcard_obj_t *self, uint32_t start_block, mp_buffer_info_t *buf) {
+ common_hal_sdcardio_check_for_deinit(self);
+ if (buf->len % 512 != 0) {
+ mp_raise_ValueError(translate("Buffer length must be a multiple of 512"));
+ }
+ lock_and_configure_bus(self);
+ int r = writeblocks(self, start_block, buf);
+ extraclock_and_unlock_bus(self);
+ return r;
+}
diff --git a/shared-module/sdcardio/SDCard.h b/shared-module/sdcardio/SDCard.h
new file mode 100644
index 000000000..76c906029
--- /dev/null
+++ b/shared-module/sdcardio/SDCard.h
@@ -0,0 +1,51 @@
+/*
+ * This file is part of the Micro Python project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020 Jeff Epler for Adafruit Industries
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#pragma once
+
+#include "py/obj.h"
+#include "py/objproperty.h"
+#include "py/runtime.h"
+#include "py/objarray.h"
+
+#include "common-hal/busio/SPI.h"
+#include "common-hal/digitalio/DigitalInOut.h"
+
+typedef struct {
+ mp_obj_base_t base;
+ busio_spi_obj_t *bus;
+ digitalio_digitalinout_obj_t cs;
+ int cdv;
+ int baudrate;
+ uint32_t sectors;
+} sdcardio_sdcard_obj_t;
+
+void common_hal_sdcardio_sdcard_construct(sdcardio_sdcard_obj_t *self, busio_spi_obj_t *spi, mcu_pin_obj_t *cs, int baudrate);
+void common_hal_sdcardio_sdcard_deinit(sdcardio_sdcard_obj_t *self);
+void common_hal_sdcardio_sdcard_check_for_deinit(sdcardio_sdcard_obj_t *self);
+int common_hal_sdcardio_sdcard_get_blockcount(sdcardio_sdcard_obj_t *self);
+int common_hal_sdcardio_sdcard_readblocks(sdcardio_sdcard_obj_t *self, uint32_t start_block, mp_buffer_info_t *buf);
+int common_hal_sdcardio_sdcard_writeblocks(sdcardio_sdcard_obj_t *self, uint32_t start_block, mp_buffer_info_t *buf);
diff --git a/shared-module/sdcardio/__init__.c b/shared-module/sdcardio/__init__.c
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/shared-module/sdcardio/__init__.c
diff --git a/shared-module/sdcardio/__init__.h b/shared-module/sdcardio/__init__.h
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/shared-module/sdcardio/__init__.h
diff --git a/shared-module/storage/__init__.c b/shared-module/storage/__init__.c
index c3d4b50c8..aa3bcc686 100644
--- a/shared-module/storage/__init__.c
+++ b/shared-module/storage/__init__.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
* Copyright (c) 2015 Josef Gajdusek
* Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
*
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/shared-module/vectorio/Polygon.c b/shared-module/vectorio/Polygon.c
index 0025d4bfc..c44c13fd7 100644
--- a/shared-module/vectorio/Polygon.c
+++ b/shared-module/vectorio/Polygon.c
@@ -20,7 +20,7 @@ static void _clobber_points_list(vectorio_polygon_t *self, mp_obj_t points_tuple
size_t len = 0;
mp_obj_t *items;
mp_obj_list_get(points_tuple_list, &len, &items);
- VECTORIO_POLYGON_DEBUG("polygon_points_list len: %d\n", len);
+ VECTORIO_POLYGON_DEBUG(" self.len: %d, len: %d, ", self->len, len);
if ( len < 3 ) {
mp_raise_TypeError_varg(translate("Polygon needs at least 3 points"));
@@ -28,9 +28,11 @@ static void _clobber_points_list(vectorio_polygon_t *self, mp_obj_t points_tuple
if ( self->len < 2*len ) {
if ( self->points_list != NULL ) {
+ VECTORIO_POLYGON_DEBUG("free(%d), ", sizeof(self->points_list));
gc_free( self->points_list );
}
self->points_list = gc_alloc( 2 * len * sizeof(int), false, false );
+ VECTORIO_POLYGON_DEBUG("alloc(%p, %d)", self->points_list, 2 * len * sizeof(int));
}
self->len = 2*len;
@@ -56,22 +58,35 @@ static void _clobber_points_list(vectorio_polygon_t *self, mp_obj_t points_tuple
void common_hal_vectorio_polygon_construct(vectorio_polygon_t *self, mp_obj_t points_list) {
- VECTORIO_POLYGON_DEBUG("%p polygon_construct\n", self);
+ VECTORIO_POLYGON_DEBUG("%p polygon_construct: ", self);
self->points_list = NULL;
self->len = 0;
self->on_dirty.obj = NULL;
_clobber_points_list( self, points_list );
+ VECTORIO_POLYGON_DEBUG("\n");
}
mp_obj_t common_hal_vectorio_polygon_get_points(vectorio_polygon_t *self) {
- return self->points_list;
+ VECTORIO_POLYGON_DEBUG("%p common_hal_vectorio_polygon_get_points {len: %d, points_list: %p}\n", self, self->len, self->points_list);
+ mp_obj_t list = mp_obj_new_list(self->len/2, NULL);
+
+ for (size_t i = 0; i < self->len; i += 2) {
+ mp_obj_t tuple[] = { mp_obj_new_int(self->points_list[i]), mp_obj_new_int(self->points_list[i+1]) };
+ mp_obj_list_append(
+ list,
+ mp_obj_new_tuple(2, tuple)
+ );
+ }
+ return list;
}
void common_hal_vectorio_polygon_set_points(vectorio_polygon_t *self, mp_obj_t points_list) {
+ VECTORIO_POLYGON_DEBUG("%p common_hal_vectorio_polygon_set_points: ", self);
_clobber_points_list( self, points_list );
if (self->on_dirty.obj != NULL) {
self->on_dirty.event(self->on_dirty.obj);
}
+ VECTORIO_POLYGON_DEBUG("\n");
}
void common_hal_vectorio_polygon_set_on_dirty(vectorio_polygon_t *self, vectorio_event_t notification) {
diff --git a/shared-module/vectorio/VectorShape.c b/shared-module/vectorio/VectorShape.c
index bfe8a7b25..81f46b3fa 100644
--- a/shared-module/vectorio/VectorShape.c
+++ b/shared-module/vectorio/VectorShape.c
@@ -223,8 +223,8 @@ bool vectorio_vector_shape_fill_area(vectorio_vector_shape_t *self, const _displ
pixel_to_get_x = (input_pixel.y - self->absolute_transform->dy * self->x - self->absolute_transform->y) / self->absolute_transform->dy;
pixel_to_get_y = (input_pixel.x - self->absolute_transform->dx * self->y - self->absolute_transform->x) / self->absolute_transform->dx;
} else {
- pixel_to_get_x = (input_pixel.x - self->absolute_transform->dx * self->x) / self->absolute_transform->dx;
- pixel_to_get_y = (input_pixel.y - self->absolute_transform->dy * self->y) / self->absolute_transform->dy;
+ pixel_to_get_x = (input_pixel.x - self->absolute_transform->dx * self->x - self->absolute_transform->x) / self->absolute_transform->dx;
+ pixel_to_get_y = (input_pixel.y - self->absolute_transform->dy * self->y - self->absolute_transform->y) / self->absolute_transform->dy;
}
VECTORIO_SHAPE_PIXEL_DEBUG(" get_pixel %p (%3d, %3d) -> ( %3d, %3d )", self->ishape.shape, input_pixel.x, input_pixel.y, pixel_to_get_x, pixel_to_get_y);
#ifdef VECTORIO_PERF
diff --git a/shared-module/wiznet/wiznet5k.c b/shared-module/wiznet/wiznet5k.c
index a603a5593..8ccb4ff8d 100644
--- a/shared-module/wiznet/wiznet5k.c
+++ b/shared-module/wiznet/wiznet5k.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/shared-module/wiznet/wiznet5k.h b/shared-module/wiznet/wiznet5k.h
index 19823ae55..4597a3016 100644
--- a/shared-module/wiznet/wiznet5k.h
+++ b/shared-module/wiznet/wiznet5k.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/supervisor/background_callback.h b/supervisor/background_callback.h
new file mode 100644
index 000000000..535dd656b
--- /dev/null
+++ b/supervisor/background_callback.h
@@ -0,0 +1,87 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020 Jeff Epler for Adafruit Industries
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#ifndef CIRCUITPY_INCLUDED_SUPERVISOR_BACKGROUND_CALLBACK_H
+#define CIRCUITPY_INCLUDED_SUPERVISOR_BACKGROUND_CALLBACK_H
+
+/** Background callbacks are a linked list of tasks to call in the background.
+ *
+ * Include a member of type `background_callback_t` inside an object
+ * which needs to queue up background work, and zero-initialize it.
+ *
+ * To schedule the work, use background_callback_add, with fun as the
+ * function to call and data pointing to the object itself.
+ *
+ * Next time run_background_tasks_if_tick is called, the callback will
+ * be run and removed from the linked list.
+ *
+ * Queueing a task that is already queued does nothing. Unconditionally
+ * re-queueing it from its own background task will cause it to run during the
+ * very next background-tasks invocation, leading to a CircuitPython freeze, so
+ * don't do that.
+ *
+ * background_callback_add can be called from interrupt context.
+ */
+typedef void (*background_callback_fun)(void *data);
+typedef struct background_callback {
+ background_callback_fun fun;
+ void *data;
+ struct background_callback *next;
+ struct background_callback *prev;
+} background_callback_t;
+
+/* Add a background callback for which 'fun' and 'data' were previously set */
+void background_callback_add_core(background_callback_t *cb);
+
+/* Add a background callback to the given function with the given data. When
+ * the callback involves an object on the GC heap, the 'data' must be a pointer
+ * to that object itself, not an internal pointer. Otherwise, it can be the
+ * case that no other references to the object itself survive, and the object
+ * becomes garbage collected while an outstanding background callback still
+ * exists.
+ */
+void background_callback_add(background_callback_t *cb, background_callback_fun fun, void *data);
+
+/* Run all background callbacks. Normally, this is done by the supervisor
+ * whenever the list is non-empty */
+void background_callback_run_all(void);
+
+/* During soft reset, remove all pending callbacks and clear the critical section flag */
+void background_callback_reset(void);
+
+/* Sometimes background callbacks must be blocked. Use these functions to
+ * bracket the section of code where this is the case. These calls nest, and
+ * begins must be balanced with ends.
+ */
+void background_callback_begin_critical_section(void);
+void background_callback_end_critical_section(void);
+
+/*
+ * Background callbacks may stop objects from being collected
+ */
+void background_callback_gc_collect(void);
+
+#endif
diff --git a/supervisor/flash.h b/supervisor/flash.h
index a8a77bf04..cd69cbfa9 100644
--- a/supervisor/flash.h
+++ b/supervisor/flash.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/supervisor/port.h b/supervisor/port.h
index 8a12d34c8..ad5b3cf32 100644
--- a/supervisor/port.h
+++ b/supervisor/port.h
@@ -91,4 +91,12 @@ void port_interrupt_after_ticks(uint32_t ticks);
// Sleep the CPU until an interrupt is received.
void port_sleep_until_interrupt(void);
+// Execute port specific actions during background tasks.
+void port_background_task(void);
+
+// Take port specific actions at the beginning and end of background tasks.
+// This is used e.g., to set a monitoring pin for debug purposes. "Actual
+// work" should be done in port_background_task() instead.
+void port_start_background_task(void);
+void port_finish_background_task(void);
#endif // MICROPY_INCLUDED_SUPERVISOR_PORT_H
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/supervisor/shared/background_callback.c b/supervisor/shared/background_callback.c
new file mode 100644
index 000000000..8e12dd362
--- /dev/null
+++ b/supervisor/shared/background_callback.c
@@ -0,0 +1,138 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2020 Jeff Epler for Adafruit Industries
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include <string.h>
+
+#include "py/gc.h"
+#include "py/mpconfig.h"
+#include "supervisor/background_callback.h"
+#include "supervisor/shared/tick.h"
+#include "shared-bindings/microcontroller/__init__.h"
+
+STATIC volatile background_callback_t *callback_head, *callback_tail;
+
+#define CALLBACK_CRITICAL_BEGIN (common_hal_mcu_disable_interrupts())
+#define CALLBACK_CRITICAL_END (common_hal_mcu_enable_interrupts())
+
+void background_callback_add_core(background_callback_t *cb) {
+ CALLBACK_CRITICAL_BEGIN;
+ if (cb->prev || callback_head == cb) {
+ CALLBACK_CRITICAL_END;
+ return;
+ }
+ cb->next = 0;
+ cb->prev = (background_callback_t*)callback_tail;
+ if (callback_tail) {
+ callback_tail->next = cb;
+ cb->prev = (background_callback_t*)callback_tail;
+ }
+ if (!callback_head) {
+ callback_head = cb;
+ }
+ callback_tail = cb;
+ CALLBACK_CRITICAL_END;
+}
+
+void background_callback_add(background_callback_t *cb, background_callback_fun fun, void *data) {
+ cb->fun = fun;
+ cb->data = data;
+ background_callback_add_core(cb);
+}
+
+static bool in_background_callback;
+void background_callback_run_all() {
+ if (!callback_head) {
+ return;
+ }
+ CALLBACK_CRITICAL_BEGIN;
+ if (in_background_callback) {
+ CALLBACK_CRITICAL_END;
+ return;
+ }
+ in_background_callback = true;
+ background_callback_t *cb = (background_callback_t*)callback_head;
+ callback_head = NULL;
+ callback_tail = NULL;
+ while (cb) {
+ background_callback_t *next = cb->next;
+ cb->next = cb->prev = NULL;
+ background_callback_fun fun = cb->fun;
+ void *data = cb->data;
+ CALLBACK_CRITICAL_END;
+ // Leave the critical section in order to run the callback function
+ if (fun) {
+ fun(data);
+ }
+ CALLBACK_CRITICAL_BEGIN;
+ cb = next;
+ }
+ in_background_callback = false;
+ CALLBACK_CRITICAL_END;
+}
+
+void background_callback_begin_critical_section() {
+ CALLBACK_CRITICAL_BEGIN;
+}
+
+void background_callback_end_critical_section() {
+ CALLBACK_CRITICAL_END;
+}
+
+void background_callback_reset() {
+ CALLBACK_CRITICAL_BEGIN;
+ background_callback_t *cb = (background_callback_t*)callback_head;
+ while(cb) {
+ background_callback_t *next = cb->next;
+ memset(cb, 0, sizeof(*cb));
+ cb = next;
+ }
+ callback_head = NULL;
+ callback_tail = NULL;
+ in_background_callback = false;
+ CALLBACK_CRITICAL_END;
+}
+
+void background_callback_gc_collect(void) {
+ // We don't enter the callback critical section here. We rely on
+ // gc_collect_ptr _NOT_ entering background callbacks, so it is not
+ // possible for the list to be cleared.
+ //
+ // However, it is possible for the list to be extended. We make the
+ // minor assumption that no newly added callback is for a
+ // collectable object. That is, we only plug the hole where an
+ // object becomes collectable AFTER it is added but before the
+ // callback is run, not the hole where an object was ALREADY
+ // collectable but adds a background task for itself.
+ //
+ // It's necessary to traverse the whole list here, as the callbacks
+ // themselves can be in non-gc memory, and some of the cb->data
+ // objects themselves might be in non-gc memory.
+ background_callback_t *cb = (background_callback_t*)callback_head;
+ while(cb) {
+ gc_collect_ptr(cb->data);
+ cb = cb->next;
+ }
+}
diff --git a/supervisor/shared/external_flash/common_commands.h b/supervisor/shared/external_flash/common_commands.h
index 2eaa84833..37efd8ceb 100644
--- a/supervisor/shared/external_flash/common_commands.h
+++ b/supervisor/shared/external_flash/common_commands.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/supervisor/shared/serial.c b/supervisor/shared/serial.c
index 513022667..8eb78a90e 100644
--- a/supervisor/shared/serial.c
+++ b/supervisor/shared/serial.c
@@ -55,7 +55,7 @@ void serial_early_init(void) {
const mcu_pin_obj_t* tx = MP_OBJ_TO_PTR(DEBUG_UART_TX);
common_hal_busio_uart_construct(&debug_uart, tx, rx, NULL, NULL, NULL,
- false, 115200, 8, PARITY_NONE, 1, 1.0f, 64,
+ false, 115200, 8, UART_PARITY_NONE, 1, 1.0f, 64,
buf_array, true);
common_hal_busio_uart_never_reset(&debug_uart);
#endif
diff --git a/supervisor/shared/tick.c b/supervisor/shared/tick.c
index dd7dba8f3..4af59f78e 100644
--- a/supervisor/shared/tick.c
+++ b/supervisor/shared/tick.c
@@ -29,10 +29,19 @@
#include "py/mpstate.h"
#include "supervisor/linker.h"
#include "supervisor/filesystem.h"
+#include "supervisor/background_callback.h"
#include "supervisor/port.h"
#include "supervisor/shared/autoreload.h"
+#include "supervisor/shared/stack.h"
-static volatile uint64_t PLACE_IN_DTCM_BSS(background_ticks);
+#if CIRCUITPY_BLEIO
+#include "supervisor/shared/bluetooth.h"
+#include "common-hal/_bleio/bonding.h"
+#endif
+
+#if CIRCUITPY_DISPLAYIO
+#include "shared-module/displayio/__init__.h"
+#endif
#if CIRCUITPY_GAMEPAD
#include "shared-module/gamepad/__init__.h"
@@ -42,6 +51,10 @@ static volatile uint64_t PLACE_IN_DTCM_BSS(background_ticks);
#include "shared-module/gamepadshift/__init__.h"
#endif
+#if CIRCUITPY_NETWORK
+#include "shared-module/network/__init__.h"
+#endif
+
#include "shared-bindings/microcontroller/__init__.h"
#if CIRCUITPY_WATCHDOG
@@ -51,6 +64,44 @@ static volatile uint64_t PLACE_IN_DTCM_BSS(background_ticks);
#define WATCHDOG_EXCEPTION_CHECK() 0
#endif
+static volatile uint64_t PLACE_IN_DTCM_BSS(background_ticks);
+
+static background_callback_t tick_callback;
+
+volatile uint64_t last_finished_tick = 0;
+
+void supervisor_background_tasks(void *unused) {
+ port_start_background_task();
+
+ assert_heap_ok();
+
+ #if CIRCUITPY_DISPLAYIO
+ displayio_background();
+ #endif
+
+ #if CIRCUITPY_NETWORK
+ network_module_background();
+ #endif
+ filesystem_background();
+
+ #if CIRCUITPY_BLEIO
+ supervisor_bluetooth_background();
+ bonding_background();
+ #endif
+
+ port_background_task();
+
+ assert_heap_ok();
+
+ last_finished_tick = port_get_raw_ticks(NULL);
+
+ port_finish_background_task();
+}
+
+bool supervisor_background_tasks_ok(void) {
+ return port_get_raw_ticks(NULL) - last_finished_tick < 1024;
+}
+
void supervisor_tick(void) {
#if CIRCUITPY_FILESYSTEM_FLUSH_INTERVAL_MS > 0
filesystem_tick();
@@ -68,6 +119,7 @@ void supervisor_tick(void) {
#endif
}
#endif
+ background_callback_add(&tick_callback, supervisor_background_tasks, NULL);
}
uint64_t supervisor_ticks_ms64() {
@@ -83,14 +135,9 @@ uint32_t supervisor_ticks_ms32() {
return supervisor_ticks_ms64();
}
-extern void run_background_tasks(void);
void PLACE_IN_ITCM(supervisor_run_background_tasks_if_tick)() {
- // TODO: Add a global that can be set by anyone to indicate we should run background tasks. That
- // way we can short circuit the background tasks early. We used to do it based on time but it
- // breaks cases where we wake up for a short period and then sleep. If we skipped the last
- // background task or more before sleeping we may end up starving a task like USB.
- run_background_tasks();
+ background_callback_run_all();
}
void mp_hal_delay_ms(mp_uint_t delay) {
@@ -104,13 +151,13 @@ void mp_hal_delay_ms(mp_uint_t delay) {
// Check to see if we've been CTRL-Ced by autoreload or the user.
if(MP_STATE_VM(mp_pending_exception) == MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception)))
{
- // clear exception and generate stacktrace
+ // clear exception and generate stacktrace
MP_STATE_VM(mp_pending_exception) = MP_OBJ_NULL;
nlr_raise(&MP_STATE_VM(mp_kbd_exception));
}
if( MP_STATE_VM(mp_pending_exception) == MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_reload_exception)) ||
WATCHDOG_EXCEPTION_CHECK()) {
- // stop sleeping immediately
+ // stop sleeping immediately
break;
}
remaining = end_tick - port_get_raw_ticks(NULL);
diff --git a/supervisor/shared/tick.h b/supervisor/shared/tick.h
index e7e808058..3a01bd622 100644
--- a/supervisor/shared/tick.h
+++ b/supervisor/shared/tick.h
@@ -28,6 +28,7 @@
#define __INCLUDED_SUPERVISOR_TICK_H
#include <stdint.h>
+#include <stdbool.h>
/** @brief To be called once every ms
*
@@ -36,13 +37,6 @@
* interrupt context.
*/
extern void supervisor_tick(void);
-/** @brief Cause background tasks to be called soon
- *
- * Normally, background tasks are only run once per tick. For other cases where
- * an event noticed from an interrupt context needs to be completed by a background
- * task activity, the interrupt can call supervisor_fake_tick.
- */
-extern void supervisor_fake_tick(void);
/** @brief Get the lower 32 bits of the time in milliseconds
*
* This can be more efficient than supervisor_ticks_ms64, for sites where a wraparound
@@ -67,4 +61,12 @@ extern void supervisor_run_background_if_tick(void);
extern void supervisor_enable_tick(void);
extern void supervisor_disable_tick(void);
+/**
+ * @brief Return true if tick-based background tasks ran within the last 1s
+ *
+ * Note that when ticks are not enabled, this function can return false; this is
+ * intended.
+ */
+extern bool supervisor_background_tasks_ok(void);
+
#endif
diff --git a/supervisor/shared/usb/usb.c b/supervisor/shared/usb/usb.c
index edf810118..36b5ec05d 100644
--- a/supervisor/shared/usb/usb.c
+++ b/supervisor/shared/usb/usb.c
@@ -27,6 +27,7 @@
#include "py/objstr.h"
#include "shared-bindings/microcontroller/Processor.h"
#include "shared-module/usb_midi/__init__.h"
+#include "supervisor/background_callback.h"
#include "supervisor/port.h"
#include "supervisor/usb.h"
#include "lib/utils/interrupt_char.h"
@@ -63,8 +64,8 @@ void usb_init(void) {
tusb_init();
#if MICROPY_KBD_EXCEPTION
- // Set Ctrl+C as wanted char, tud_cdc_rx_wanted_cb() callback will be invoked when Ctrl+C is received
- // This callback always got invoked regardless of mp_interrupt_char value since we only set it once here
+ // Set Ctrl+C as wanted char, tud_cdc_rx_wanted_cb() usb_callback will be invoked when Ctrl+C is received
+ // This usb_callback always got invoked regardless of mp_interrupt_char value since we only set it once here
tud_cdc_set_wanted_char(CHAR_CTRL_C);
#endif
@@ -82,6 +83,16 @@ void usb_background(void) {
}
}
+static background_callback_t usb_callback;
+static void usb_background_do(void* unused) {
+ usb_background();
+}
+
+void usb_irq_handler(void) {
+ tud_int_handler(0);
+ background_callback_add(&usb_callback, usb_background_do, NULL);
+}
+
//--------------------------------------------------------------------+
// tinyusb callbacks
//--------------------------------------------------------------------+
diff --git a/supervisor/stub/internal_flash.c b/supervisor/stub/internal_flash.c
index 5a82f81f7..3a4ba935d 100644
--- a/supervisor/stub/internal_flash.c
+++ b/supervisor/stub/internal_flash.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013, 2014 Damien P. George
+ * SPDX-FileCopyrightText: Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/supervisor/supervisor.mk b/supervisor/supervisor.mk
index 21803ae0a..188536686 100644
--- a/supervisor/supervisor.mk
+++ b/supervisor/supervisor.mk
@@ -2,6 +2,7 @@ SRC_SUPERVISOR = \
main.c \
supervisor/port.c \
supervisor/shared/autoreload.c \
+ supervisor/shared/background_callback.c \
supervisor/shared/board.c \
supervisor/shared/filesystem.c \
supervisor/shared/flash.c \
diff --git a/supervisor/usb.h b/supervisor/usb.h
index 29280c725..2a447c368 100644
--- a/supervisor/usb.h
+++ b/supervisor/usb.h
@@ -29,10 +29,15 @@
#include <stdbool.h>
-// Ports must call this as frequently as they can in order to keep the USB connection
-// alive and responsive.
+// Ports must call this as frequently as they can in order to keep the USB
+// connection alive and responsive. Normally this is called from background
+// tasks after the USB IRQ handler is executed, but in specific circumstances
+// it may be necessary to call it directly.
void usb_background(void);
+// Ports must call this from their particular USB IRQ handler
+void usb_irq_handler(void);
+
// Only inits the USB peripheral clocks and pins. The peripheral will be initialized by
// TinyUSB.
void init_usb_hardware(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/extmod/ujson_load_readinto.py b/tests/extmod/ujson_load_readinto.py
new file mode 100644
index 000000000..a277f40ef
--- /dev/null
+++ b/tests/extmod/ujson_load_readinto.py
@@ -0,0 +1,22 @@
+import ujson as json
+
+# Test that json can load from any object with readinto
+
+class Buffer:
+ def __init__(self, data):
+ self._data = data
+ self._i = 0
+
+ def readinto(self, buf):
+ end = self._i + len(buf)
+ remaining = len(self._data) - self._i
+ end = min(end, len(self._data))
+ l = min(len(buf), remaining)
+ buf[:l] = self._data[self._i:end]
+ self._i += l
+ return l
+
+print(json.load(Buffer(b'null')))
+print(json.load(Buffer(b'"abc\\u0064e"')))
+print(json.load(Buffer(b'[false, true, 1, -2]')))
+print(json.load(Buffer(b'{"a":true}')))
diff --git a/tests/extmod/ujson_load_readinto.py.exp b/tests/extmod/ujson_load_readinto.py.exp
new file mode 100644
index 000000000..f8c3c693b
--- /dev/null
+++ b/tests/extmod/ujson_load_readinto.py.exp
@@ -0,0 +1,4 @@
+None
+abcde
+[False, True, 1, -2]
+{'a': True}
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/tests/skip_if.py b/tests/skip_if.py
index 7d6c5b207..a8f50c465 100644
--- a/tests/skip_if.py
+++ b/tests/skip_if.py
@@ -1,24 +1,7 @@
-# The MIT License (MIT)
+# SPDX-FileCopyrightText: Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
#
-# Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
-#
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to deal
-# in the Software without restriction, including without limitation the rights
-# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-# copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included in
-# all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-# THE SOFTWARE.
+# SPDX-License-Identifier: MIT
# This must be on one line so its skipped when built into tests.
"""This file provides helpers to detect particular running conditions and skip the test when appropriate."""
diff --git a/tests/thread/mutate_bytearray.py b/tests/thread/mutate_bytearray.py
index f91b2d580..5015c3f9c 100644
--- a/tests/thread/mutate_bytearray.py
+++ b/tests/thread/mutate_bytearray.py
@@ -1,6 +1,8 @@
# test concurrent mutating access to a shared bytearray object
#
-# MIT license; Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd
+# SPDX-FileCopyrightText: Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd
+#
+# SPDX-License-Identifier: MIT
import _thread
diff --git a/tests/thread/mutate_dict.py b/tests/thread/mutate_dict.py
index c57d332d5..563fce39d 100644
--- a/tests/thread/mutate_dict.py
+++ b/tests/thread/mutate_dict.py
@@ -1,6 +1,8 @@
# test concurrent mutating access to a shared dict object
#
-# MIT license; Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd
+# SPDX-FileCopyrightText: Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd
+#
+# SPDX-License-Identifier: MIT
import _thread
diff --git a/tests/thread/mutate_instance.py b/tests/thread/mutate_instance.py
index a1ae428b5..2ecfbe109 100644
--- a/tests/thread/mutate_instance.py
+++ b/tests/thread/mutate_instance.py
@@ -1,6 +1,8 @@
# test concurrent mutating access to a shared user instance
#
-# MIT license; Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd
+# SPDX-FileCopyrightText: Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd
+#
+# SPDX-License-Identifier: MIT
import _thread
diff --git a/tests/thread/mutate_list.py b/tests/thread/mutate_list.py
index 764a9bd99..d70e8a8a3 100644
--- a/tests/thread/mutate_list.py
+++ b/tests/thread/mutate_list.py
@@ -1,6 +1,8 @@
# test concurrent mutating access to a shared list object
#
-# MIT license; Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd
+# SPDX-FileCopyrightText: Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd
+#
+# SPDX-License-Identifier: MIT
import _thread
diff --git a/tests/thread/mutate_set.py b/tests/thread/mutate_set.py
index 5492d8631..c4529f356 100644
--- a/tests/thread/mutate_set.py
+++ b/tests/thread/mutate_set.py
@@ -1,6 +1,8 @@
# test concurrent mutating access to a shared set object
#
-# MIT license; Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd
+# SPDX-FileCopyrightText: Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd
+#
+# SPDX-License-Identifier: MIT
import _thread
diff --git a/tests/thread/stress_aes.py b/tests/thread/stress_aes.py
index df75e616c..ebf7af371 100644
--- a/tests/thread/stress_aes.py
+++ b/tests/thread/stress_aes.py
@@ -11,7 +11,9 @@
# aggressive by changing the amount of data to encrypt, the number of loops and
# the number of threads.
#
-# MIT license; Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd
+# SPDX-FileCopyrightText: Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd
+#
+# SPDX-License-Identifier: MIT
##################################################################
# discrete arithmetic routines, mostly from a precomputed table
diff --git a/tests/thread/stress_heap.py b/tests/thread/stress_heap.py
index 5482a9ac6..206cf1a86 100644
--- a/tests/thread/stress_heap.py
+++ b/tests/thread/stress_heap.py
@@ -1,7 +1,9 @@
# stress test for the heap by allocating lots of objects within threads
# allocates about 5mb on the heap
#
-# MIT license; Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd
+# SPDX-FileCopyrightText: Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd
+#
+# SPDX-License-Identifier: MIT
try:
import utime as time
diff --git a/tests/thread/stress_recurse.py b/tests/thread/stress_recurse.py
index 68367c4dd..8edee246a 100644
--- a/tests/thread/stress_recurse.py
+++ b/tests/thread/stress_recurse.py
@@ -1,6 +1,8 @@
# test hitting the function recursion limit within a thread
#
-# MIT license; Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd
+# SPDX-FileCopyrightText: Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd
+#
+# SPDX-License-Identifier: MIT
import _thread
diff --git a/tests/thread/thread_exc1.py b/tests/thread/thread_exc1.py
index 10fb94b4f..e00a16bd2 100644
--- a/tests/thread/thread_exc1.py
+++ b/tests/thread/thread_exc1.py
@@ -1,6 +1,8 @@
# test raising and catching an exception within a thread
#
-# MIT license; Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd
+# SPDX-FileCopyrightText: Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd
+#
+# SPDX-License-Identifier: MIT
import _thread
diff --git a/tests/thread/thread_exit1.py b/tests/thread/thread_exit1.py
index 88cdd165c..ad7b01d89 100644
--- a/tests/thread/thread_exit1.py
+++ b/tests/thread/thread_exit1.py
@@ -1,6 +1,8 @@
# test _thread.exit() function
#
-# MIT license; Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd
+# SPDX-FileCopyrightText: Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd
+#
+# SPDX-License-Identifier: MIT
try:
import utime as time
diff --git a/tests/thread/thread_exit2.py b/tests/thread/thread_exit2.py
index 368a11bba..6bff8a173 100644
--- a/tests/thread/thread_exit2.py
+++ b/tests/thread/thread_exit2.py
@@ -1,6 +1,8 @@
# test raising SystemExit to finish a thread
#
-# MIT license; Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd
+# SPDX-FileCopyrightText: Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd
+#
+# SPDX-License-Identifier: MIT
try:
import utime as time
diff --git a/tests/thread/thread_gc1.py b/tests/thread/thread_gc1.py
index 8dcbf7e07..2ea189161 100644
--- a/tests/thread/thread_gc1.py
+++ b/tests/thread/thread_gc1.py
@@ -1,6 +1,8 @@
# test that we can run the garbage collector within threads
#
-# MIT license; Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd
+# SPDX-FileCopyrightText: Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd
+#
+# SPDX-License-Identifier: MIT
import gc
import _thread
diff --git a/tests/thread/thread_ident1.py b/tests/thread/thread_ident1.py
index 217fce73b..9a6f89ff5 100644
--- a/tests/thread/thread_ident1.py
+++ b/tests/thread/thread_ident1.py
@@ -1,6 +1,8 @@
# test _thread.get_ident() function
#
-# MIT license; Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd
+# SPDX-FileCopyrightText: Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd
+#
+# SPDX-License-Identifier: MIT
import _thread
diff --git a/tests/thread/thread_lock1.py b/tests/thread/thread_lock1.py
index ba5c7dff0..c2d7c9d1e 100644
--- a/tests/thread/thread_lock1.py
+++ b/tests/thread/thread_lock1.py
@@ -1,6 +1,8 @@
# test _thread lock object using a single thread
#
-# MIT license; Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd
+# SPDX-FileCopyrightText: Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd
+#
+# SPDX-License-Identifier: MIT
import _thread
diff --git a/tests/thread/thread_lock2.py b/tests/thread/thread_lock2.py
index 405f10b0b..4ef912dff 100644
--- a/tests/thread/thread_lock2.py
+++ b/tests/thread/thread_lock2.py
@@ -1,6 +1,8 @@
# test _thread lock objects with multiple threads
#
-# MIT license; Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd
+# SPDX-FileCopyrightText: Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd
+#
+# SPDX-License-Identifier: MIT
try:
import utime as time
diff --git a/tests/thread/thread_lock3.py b/tests/thread/thread_lock3.py
index 607898dad..35808d99c 100644
--- a/tests/thread/thread_lock3.py
+++ b/tests/thread/thread_lock3.py
@@ -1,6 +1,8 @@
# test thread coordination using a lock object
#
-# MIT license; Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd
+# SPDX-FileCopyrightText: Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd
+#
+# SPDX-License-Identifier: MIT
import _thread
diff --git a/tests/thread/thread_lock4.py b/tests/thread/thread_lock4.py
index 2f9d42d6b..440f3e90c 100644
--- a/tests/thread/thread_lock4.py
+++ b/tests/thread/thread_lock4.py
@@ -1,6 +1,8 @@
# test using lock to coordinate access to global mutable objects
#
-# MIT license; Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd
+# SPDX-FileCopyrightText: Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd
+#
+# SPDX-License-Identifier: MIT
try:
import utime as time
diff --git a/tests/thread/thread_qstr1.py b/tests/thread/thread_qstr1.py
index f4136d964..dccfb7f51 100644
--- a/tests/thread/thread_qstr1.py
+++ b/tests/thread/thread_qstr1.py
@@ -1,6 +1,8 @@
# test concurrent interning of strings
#
-# MIT license; Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd
+# SPDX-FileCopyrightText: Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd
+#
+# SPDX-License-Identifier: MIT
try:
import utime as time
diff --git a/tests/thread/thread_shared1.py b/tests/thread/thread_shared1.py
index 13c6651cc..de339ad7f 100644
--- a/tests/thread/thread_shared1.py
+++ b/tests/thread/thread_shared1.py
@@ -1,6 +1,8 @@
# test capability for threads to access a shared immutable data structure
#
-# MIT license; Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd
+# SPDX-FileCopyrightText: Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd
+#
+# SPDX-License-Identifier: MIT
import _thread
diff --git a/tests/thread/thread_shared2.py b/tests/thread/thread_shared2.py
index e4bfe7802..2c749e688 100644
--- a/tests/thread/thread_shared2.py
+++ b/tests/thread/thread_shared2.py
@@ -1,7 +1,9 @@
# test capability for threads to access a shared mutable data structure
# (without contention because they access different parts of the structure)
#
-# MIT license; Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd
+# SPDX-FileCopyrightText: Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd
+#
+# SPDX-License-Identifier: MIT
import _thread
diff --git a/tests/thread/thread_sleep1.py b/tests/thread/thread_sleep1.py
index 032ec1754..d5aa99f97 100644
--- a/tests/thread/thread_sleep1.py
+++ b/tests/thread/thread_sleep1.py
@@ -1,6 +1,8 @@
# test threads sleeping
#
-# MIT license; Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd
+# SPDX-FileCopyrightText: Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd
+#
+# SPDX-License-Identifier: MIT
try:
import utime
diff --git a/tests/thread/thread_stacksize1.py b/tests/thread/thread_stacksize1.py
index 62b6e5e40..e7189fafb 100644
--- a/tests/thread/thread_stacksize1.py
+++ b/tests/thread/thread_stacksize1.py
@@ -1,6 +1,8 @@
# test setting the thread stack size
#
-# MIT license; Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd
+# SPDX-FileCopyrightText: Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd
+#
+# SPDX-License-Identifier: MIT
import sys
import _thread
diff --git a/tests/thread/thread_start1.py b/tests/thread/thread_start1.py
index d23a74aa2..94df6dc62 100644
--- a/tests/thread/thread_start1.py
+++ b/tests/thread/thread_start1.py
@@ -1,6 +1,8 @@
# test basic capability to start a new thread
#
-# MIT license; Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd
+# SPDX-FileCopyrightText: Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd
+#
+# SPDX-License-Identifier: MIT
try:
import utime as time
diff --git a/tests/thread/thread_start2.py b/tests/thread/thread_start2.py
index d0913e37c..9412bb618 100644
--- a/tests/thread/thread_start2.py
+++ b/tests/thread/thread_start2.py
@@ -1,6 +1,8 @@
# test capability to start a thread with keyword args
#
-# MIT license; Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd
+# SPDX-FileCopyrightText: Copyright (c) 2016 Damien P. George on behalf of Pycom Ltd
+#
+# SPDX-License-Identifier: MIT
try:
import utime as time
diff --git a/tools/analyze_heap_dump.py b/tools/analyze_heap_dump.py
index b8f2bd011..887871db7 100755
--- a/tools/analyze_heap_dump.py
+++ b/tools/analyze_heap_dump.py
@@ -1,3 +1,7 @@
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+#
+# SPDX-License-Identifier: MIT
+
# This script renders a graph of the MicroPython heap at the given point it was dumped.
# It takes three files, the binary dump of ram, the binary for CircuitPython and the linker map file.
diff --git a/tools/analyze_mpy.py b/tools/analyze_mpy.py
index 376207a24..a2f541d0f 100644
--- a/tools/analyze_mpy.py
+++ b/tools/analyze_mpy.py
@@ -1,3 +1,7 @@
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+#
+# SPDX-License-Identifier: MIT
+
import sys
import binascii
import io
diff --git a/tools/bootstrap_upip.sh b/tools/bootstrap_upip.sh
index 2891775d7..8b9d199fa 100755
--- a/tools/bootstrap_upip.sh
+++ b/tools/bootstrap_upip.sh
@@ -1,3 +1,7 @@
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+#
+# SPDX-License-Identifier: MIT
+
# This script performs bootstrap installation of upip package manager from PyPI
# All the other packages can be installed using it.
diff --git a/tools/build-stm-latest.sh b/tools/build-stm-latest.sh
index 07cb168da..bfee1b192 100755
--- a/tools/build-stm-latest.sh
+++ b/tools/build-stm-latest.sh
@@ -1,5 +1,9 @@
#!/bin/bash
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+#
+# SPDX-License-Identifier: MIT
+
# function for building firmware
function do_build() {
descr=$1
diff --git a/tools/build_board_info.py b/tools/build_board_info.py
index 6c670930f..6ed8b8c16 100644
--- a/tools/build_board_info.py
+++ b/tools/build_board_info.py
@@ -1,5 +1,9 @@
#!/usr/bin/env python3
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+#
+# SPDX-License-Identifier: MIT
+
import json
import os
import subprocess
@@ -9,6 +13,9 @@ import base64
from datetime import date
from sh.contrib import git
+sys.path.append("../docs")
+import shared_bindings_matrix
+
sys.path.append("adabot")
import adabot.github_requests as github
@@ -150,7 +157,7 @@ def create_pr(changes, updated, git_info, user):
info["id"] = id
updated_list.append(info)
- updated = json.dumps(updated_list, sort_keys=True, indent=4).encode("utf-8") + b"\n"
+ updated = json.dumps(updated_list, sort_keys=True, indent=1).encode("utf-8") + b"\n"
#print(updated.decode("utf-8"))
pr_title = "Automated website update for release {}".format(changes["new_release"])
boards = ""
@@ -202,19 +209,6 @@ def create_pr(changes, updated, git_info, user):
print(changes)
print(pr_info)
-def update_downloads(boards, release):
- response = github.get("/repos/adafruit/circuitpython/releases/tags/{}".format(release))
- if not response.ok:
- print(response.text)
- raise RuntimeError("cannot get previous release info")
-
- assets = response.json()["assets"]
- for asset in assets:
- board_name = asset["name"].split("-")[2]
- if board_name not in boards:
- continue
- boards[board_name]["download_count"] += asset["download_count"]
-
def print_active_user():
response = github.get("/user")
@@ -246,6 +240,10 @@ def generate_download_info():
languages = get_languages()
+ support_matrix = shared_bindings_matrix.support_matrix_by_board(
+ use_branded_name=False
+ )
+
new_stable = "-" not in new_tag
previous_releases = set()
@@ -262,9 +260,6 @@ def generate_download_info():
board_mapping = get_board_mapping()
- for release in previous_releases:
- update_downloads(board_mapping, release)
-
for port in SUPPORTED_PORTS:
board_path = os.path.join("../ports", port, "boards")
for board_path in os.scandir(board_path):
@@ -283,7 +278,10 @@ def generate_download_info():
new_version = {
"stable": new_stable,
"version": new_tag,
- "files": {}
+ "modules": support_matrix.get(alias, "[]"),
+ "files": {},
+ "languages": languages,
+ "extensions": board_info["extensions"]
}
for language in languages:
files = []
diff --git a/tools/build_memory_info.py b/tools/build_memory_info.py
index 808b70bd2..26697b974 100644
--- a/tools/build_memory_info.py
+++ b/tools/build_memory_info.py
@@ -1,28 +1,9 @@
#!/usr/bin/env python3
+
+# SPDX-FileCopyrightText: Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
#
-# This file is part of the MicroPython project, http://micropython.org/
-#
-# The MIT License (MIT)
-#
-# Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
-#
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to deal
-# in the Software without restriction, including without limitation the rights
-# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-# copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included in
-# all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-# THE SOFTWARE.
+# SPDX-License-Identifier: MIT
import re
import sys
diff --git a/tools/build_release_files.py b/tools/build_release_files.py
index 09133e51f..3563dd99f 100755
--- a/tools/build_release_files.py
+++ b/tools/build_release_files.py
@@ -1,5 +1,9 @@
#! /usr/bin/env python3
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+#
+# SPDX-License-Identifier: MIT
+
import os
import sys
import subprocess
diff --git a/tools/chart_code_size.py b/tools/chart_code_size.py
index 0b55787fa..f75269130 100644
--- a/tools/chart_code_size.py
+++ b/tools/chart_code_size.py
@@ -1,3 +1,7 @@
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+#
+# SPDX-License-Identifier: MIT
+
# This script renders a graph of the CircuitPython rom image.
# It takes the single elf file and uses objdump to get its contents.
diff --git a/tools/check_code_size.sh b/tools/check_code_size.sh
index 2925ff168..bdf1b5ad9 100755
--- a/tools/check_code_size.sh
+++ b/tools/check_code_size.sh
@@ -1,4 +1,9 @@
#!/bin/bash
+
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+#
+# SPDX-License-Identifier: MIT
+
#
# This script check that changes don't lead to code size regressions.
# (Size of the language core (== minimal port should not grow)).
diff --git a/tools/check_translations.py b/tools/check_translations.py
index 7c008d3da..95776a544 100644
--- a/tools/check_translations.py
+++ b/tools/check_translations.py
@@ -1,3 +1,7 @@
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+#
+# SPDX-License-Identifier: MIT
+
# Validate that all entries in the .pot are in every .po. Only the .pot is updated so we can detect
# if a translation was added to the source but isn't in a .po. This ensures translators can grab
# complete files to work on.
diff --git a/tools/ci_new_boards_check.py b/tools/ci_new_boards_check.py
index 8bb8876fb..86010bad3 100644
--- a/tools/ci_new_boards_check.py
+++ b/tools/ci_new_boards_check.py
@@ -1,5 +1,9 @@
#! /usr/bin/env python3
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+#
+# SPDX-License-Identifier: MIT
+
import sys
import os
import json
diff --git a/tools/codestats.sh b/tools/codestats.sh
index 5f7625c45..c0dd747dc 100755
--- a/tools/codestats.sh
+++ b/tools/codestats.sh
@@ -1,4 +1,9 @@
#!/bin/sh
+
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+#
+# SPDX-License-Identifier: MIT
+
#
# This script generates statistics (build size, speed) for successive
# revisions of the code. It checks out git commits one an a time, compiles
diff --git a/tools/convert_release_notes.py b/tools/convert_release_notes.py
index 649184102..797e71834 100644
--- a/tools/convert_release_notes.py
+++ b/tools/convert_release_notes.py
@@ -1,12 +1,17 @@
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+#
+# SPDX-License-Identifier: MIT
+
import sys
import mistune
+import mistune.renderers
print(sys.argv[1])
with open(sys.argv[1], "r") as source_file:
source = source_file.read()
-html = mistune.Markdown()
+html = mistune.create_markdown()
print()
print("HTML")
@@ -15,39 +20,39 @@ print("From the <a href=\"\">GitHub release page</a>:\n<blockquote>")
print(html(source))
print("</blockquote>")
-class AdafruitBBCodeRenderer:
- def __init__(self, **kwargs):
- self.options = kwargs
-
+class AdafruitBBCodeRenderer(mistune.renderers.BaseRenderer):
def placeholder(self):
return ''
def paragraph(self, text):
return text + "\n\n"
+ def block_text(self, text):
+ return text
+
def text(self, text):
return text
def link(self, link, title, text):
- return "[url={}]{}[/url]".format(link, text)
+ return "[url={}]{}[/url]".format(link, title)
def autolink(self, link, is_email):
if not is_email:
return "[url={}]{}[/url]".format(link, link)
return link
- def header(self, text, level, raw):
+ def heading(self, text, level):
return "[b][size=150]{}[/size][/b]\n".format(text)
def codespan(self, text):
return "[color=#E74C3C][size=95]{}[/size][/color]".format(text)
- def list_item(self, text):
+ def list_item(self, text, level):
return "[*]{}[/*]\n".format(text.strip())
- def list(self, body, ordered=True):
+ def list(self, text, ordered, level, start=None):
ordered_indicator = "=" if ordered else ""
- return "[list{}]\n{}[/list]".format(ordered_indicator, body)
+ return "[list{}]\n{}[/list]".format(ordered_indicator, text)
def double_emphasis(self, text):
return "[b]{}[/b]".format(text)
@@ -55,7 +60,10 @@ class AdafruitBBCodeRenderer:
def emphasis(self, text):
return "[b]{}[/b]".format(text)
-bbcode = mistune.Markdown(renderer=AdafruitBBCodeRenderer())
+ def strong(self, text):
+ return "[i]{}[/i]".format(text)
+
+bbcode = mistune.create_markdown(renderer=AdafruitBBCodeRenderer())
print()
print("BBCode")
diff --git a/tools/cpboard.py b/tools/cpboard.py
index 7769cb4f4..464be4ba4 100644
--- a/tools/cpboard.py
+++ b/tools/cpboard.py
@@ -1,33 +1,12 @@
#!/usr/bin/env python3
+
+# SPDX-FileCopyrightText: Copyright (c) 2014-2016 Damien P. George
+# SPDX-FileCopyrightText: Copyright (c) 2017 Paul Sokolovsky
+# SPDX-FileCopyrightText: Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
+# SPDX-FileCopyrightText: Copyright (c) 2018 Noralf Trønnes
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
#
-# This file is part of the MicroPython project, http://micropython.org/
-#
-# The MIT License (MIT)
-#
-# Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
-# Copyright (c) 2018 Noralf Trønnes
-#
-# Parts taken from pyboard.py:
-# Copyright (c) 2014-2016 Damien P. George
-# Copyright (c) 2017 Paul Sokolovsky
-#
-# 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.
+# SPDX-License-Identifier: MIT
import os
import re
diff --git a/tools/dfu.py b/tools/dfu.py
index dd6019235..489465f0c 100644
--- a/tools/dfu.py
+++ b/tools/dfu.py
@@ -1,5 +1,9 @@
#!/usr/bin/python
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+#
+# SPDX-License-Identifier: MIT
+
# Written by Antonio Galea - 2010/11/18
# Updated for DFU 1.1 by Sean Cross - 2020/03/31
# Distributed under Gnu LGPL 3.0
diff --git a/tools/extract_pyi.py b/tools/extract_pyi.py
index d749d202b..d29c3444f 100644
--- a/tools/extract_pyi.py
+++ b/tools/extract_pyi.py
@@ -1,21 +1,101 @@
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+#
+# 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
import sys
-import astroid
import traceback
-top_level = sys.argv[1].strip("/")
-stub_directory = sys.argv[2]
+import isort
+import black
+
+
+IMPORTS_IGNORE = frozenset({'int', 'float', 'bool', 'str', 'bytes', 'tuple', 'list', 'set', 'dict', 'bytearray', 'slice', 'file', 'buffer', 'range', 'array', 'struct_time'})
+IMPORTS_TYPING = frozenset({'Any', 'Optional', 'Union', 'Tuple', 'List', 'Sequence', 'Iterable', 'Iterator', 'overload'})
+IMPORTS_TYPESHED = frozenset({'ReadableBuffer', 'WriteableBuffer'})
+
+
+def is_any(node):
+ node_type = type(node)
+ if node is None:
+ return True
+ if node_type == ast.Name and node.id == "Any":
+ return True
+ if (node_type == ast.Attribute and type(node.value) == ast.Name
+ and node.value.id == "typing" and node.attr == "Any"):
+ return True
+ return False
+
+
+def report_missing_annotations(tree):
+ for node in ast.walk(tree):
+ node_type = type(node)
+ if node_type == ast.AnnAssign:
+ if is_any(node.annotation):
+ print(f"Missing attribute type on line {node.lineno}")
+ elif node_type == ast.arg:
+ if is_any(node.annotation) and node.arg != "self":
+ print(f"Missing argument type: {node.arg} on line {node.lineno}")
+ elif node_type == ast.FunctionDef:
+ if is_any(node.returns) and node.name != "__init__":
+ print(f"Missing return type: {node.name} on line {node.lineno}")
+
+
+def extract_imports(tree):
+ modules = set()
+ typing = set()
+ typeshed = set()
+
+ def collect_annotations(anno_tree):
+ if anno_tree is None:
+ return
+ for node in ast.walk(anno_tree):
+ node_type = type(node)
+ if node_type == ast.Name:
+ if node.id in IMPORTS_IGNORE:
+ continue
+ elif node.id in IMPORTS_TYPING:
+ typing.add(node.id)
+ elif node.id in IMPORTS_TYPESHED:
+ typeshed.add(node.id)
+ if node_type == ast.Attribute:
+ if type(node.value) == ast.Name:
+ modules.add(node.value.id)
+
+ for node in ast.walk(tree):
+ node_type = type(node)
+ if (node_type == ast.AnnAssign) or (node_type == ast.arg):
+ collect_annotations(node.annotation)
+ elif node_type == ast.FunctionDef:
+ collect_annotations(node.returns)
+ for deco in node.decorator_list:
+ if deco.id in IMPORTS_TYPING:
+ typing.add(deco.id)
+
+ return {
+ "modules": sorted(modules),
+ "typing": sorted(typing),
+ "typeshed": sorted(typeshed),
+ }
+
def convert_folder(top_level, stub_directory):
ok = 0
total = 0
filenames = sorted(os.listdir(top_level))
pyi_lines = []
+
for filename in filenames:
full_path = os.path.join(top_level, filename)
file_lines = []
if os.path.isdir(full_path):
- mok, mtotal = convert_folder(full_path, os.path.join(stub_directory, filename))
+ (mok, mtotal) = convert_folder(full_path, os.path.join(stub_directory, filename))
ok += mok
total += mtotal
elif filename.endswith(".c"):
@@ -40,44 +120,56 @@ def convert_folder(top_level, stub_directory):
pyi_lines.extend(file_lines)
if not pyi_lines:
- return ok, total
+ return (ok, total)
stub_filename = os.path.join(stub_directory, "__init__.pyi")
print(stub_filename)
stub_contents = "".join(pyi_lines)
- os.makedirs(stub_directory, exist_ok=True)
- with open(stub_filename, "w") as f:
- f.write(stub_contents)
# Validate that the module is a parseable stub.
total += 1
try:
- tree = astroid.parse(stub_contents)
- for i in tree.body:
- if 'name' in i.__dict__:
- print(i.__dict__['name'])
- for j in i.body:
- if isinstance(j, astroid.scoped_nodes.FunctionDef):
- if None in j.args.__dict__['annotations']:
- print(f"Missing parameter type: {j.__dict__['name']} on line {j.__dict__['lineno']}\n")
- if j.returns:
- if 'Any' in j.returns.__dict__.values():
- print(f"Missing return type: {j.__dict__['name']} on line {j.__dict__['lineno']}")
- elif isinstance(j, astroid.node_classes.AnnAssign):
- if 'name' in j.__dict__['annotation'].__dict__:
- if j.__dict__['annotation'].__dict__['name'] == 'Any':
- print(f"missing attribute type on line {j.__dict__['lineno']}")
-
+ tree = ast.parse(stub_contents)
+ imports = extract_imports(tree)
+ report_missing_annotations(tree)
ok += 1
- except astroid.exceptions.AstroidSyntaxError as e:
- e = e.__cause__
+ except SyntaxError as e:
traceback.print_exception(type(e), e, e.__traceback__)
+ return (ok, total)
+
+ # Add import statements
+ import_lines = ["from __future__ import annotations"]
+ if imports["typing"]:
+ import_lines.append("from typing import " + ", ".join(imports["typing"]))
+ if imports["typeshed"]:
+ import_lines.append("from _typeshed import " + ", ".join(imports["typeshed"]))
+ import_lines.extend(f"import {m}" for m in imports["modules"])
+ import_body = "\n".join(import_lines)
+ m = re.match(r'(\s*""".*?""")', stub_contents, flags=re.DOTALL)
+ if m:
+ stub_contents = m.group(1) + "\n\n" + import_body + "\n\n" + stub_contents[m.end():]
+ else:
+ stub_contents = import_body + "\n\n" + stub_contents
+
+ # Code formatting
+ stub_contents = isort.code(stub_contents)
+ stub_contents = black.format_str(stub_contents, mode=black.FileMode(is_pyi=True))
+
+ os.makedirs(stub_directory, exist_ok=True)
+ with open(stub_filename, "w") as f:
+ f.write(stub_contents)
+
print()
- return ok, total
+ return (ok, total)
+
+
+if __name__ == "__main__":
+ top_level = sys.argv[1].strip("/")
+ stub_directory = sys.argv[2]
-ok, total = convert_folder(top_level, stub_directory)
+ (ok, total) = convert_folder(top_level, stub_directory)
-print(f"{ok} ok out of {total}")
+ print(f"Parsing .pyi files: {total - ok} failed, {ok} passed")
-if ok != total:
- sys.exit(total - ok)
+ if ok != total:
+ sys.exit(total - ok)
diff --git a/tools/file2h.py b/tools/file2h.py
index 2a04ae22b..706dd4dd2 100644
--- a/tools/file2h.py
+++ b/tools/file2h.py
@@ -1,3 +1,7 @@
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+#
+# SPDX-License-Identifier: MIT
+
# Reads in a text file, and performs the necessary escapes so that it
# can be #included as a static string like:
# static const char string_from_textfile[] =
diff --git a/tools/fixup_translations.py b/tools/fixup_translations.py
index 6db7f1cc5..0362923e8 100644
--- a/tools/fixup_translations.py
+++ b/tools/fixup_translations.py
@@ -1,3 +1,7 @@
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+#
+# SPDX-License-Identifier: MIT
+
# Validate that all entries in the .pot are in every .po. Only the .pot is updated so we can detect
# if a translation was added to the source but isn't in a .po. This ensures translators can grab
# complete files to work on.
diff --git a/tools/fonts/ter-u12n.bdf.license b/tools/fonts/ter-u12n.bdf.license
new file mode 100644
index 000000000..a40e8711d
--- /dev/null
+++ b/tools/fonts/ter-u12n.bdf.license
@@ -0,0 +1,3 @@
+SPDX-FileCopyrightText: 2018 Dimitar Toshkov Zhekov
+
+SPDX-License-Identifier: OFL-1.1
diff --git a/tools/gc_activity.py b/tools/gc_activity.py
index 8d172ea3a..cc9a21836 100644
--- a/tools/gc_activity.py
+++ b/tools/gc_activity.py
@@ -1,3 +1,7 @@
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+#
+# SPDX-License-Identifier: MIT
+
import sys
import json
diff --git a/tools/gc_activity_between_collects.py b/tools/gc_activity_between_collects.py
index c02c479f9..f906cf5c7 100644
--- a/tools/gc_activity_between_collects.py
+++ b/tools/gc_activity_between_collects.py
@@ -1,3 +1,7 @@
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+#
+# SPDX-License-Identifier: MIT
+
import sys
import json
diff --git a/tools/gen-changelog.sh b/tools/gen-changelog.sh
index 6eca1b4b1..b29606b0c 100755
--- a/tools/gen-changelog.sh
+++ b/tools/gen-changelog.sh
@@ -1,5 +1,9 @@
#!/bin/sh
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+#
+# SPDX-License-Identifier: MIT
+
echo "MicroPython change log"
for t in $(git tag | grep -v v1.0-rc1 | sort -rV); do
diff --git a/tools/gen_display_resources.py b/tools/gen_display_resources.py
index c08daf477..478a2f22f 100644
--- a/tools/gen_display_resources.py
+++ b/tools/gen_display_resources.py
@@ -1,3 +1,7 @@
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+#
+# SPDX-License-Identifier: MIT
+
import argparse
import os
diff --git a/tools/gen_ld_files.py b/tools/gen_ld_files.py
index c2ac812bc..1fea1a7ef 100755
--- a/tools/gen_ld_files.py
+++ b/tools/gen_ld_files.py
@@ -1,4 +1,9 @@
#! /usr/bin/env python3
+
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+#
+# SPDX-License-Identifier: MIT
+
import argparse
import os
diff --git a/tools/gen_usb_descriptor.py b/tools/gen_usb_descriptor.py
index 5e25528f9..adec33100 100644
--- a/tools/gen_usb_descriptor.py
+++ b/tools/gen_usb_descriptor.py
@@ -1,3 +1,7 @@
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+#
+# SPDX-License-Identifier: MIT
+
import argparse
import os
@@ -535,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}
diff --git a/tools/gendoc.py b/tools/gendoc.py
index 61844d203..85411cb41 100644
--- a/tools/gendoc.py
+++ b/tools/gendoc.py
@@ -1,3 +1,7 @@
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+#
+# SPDX-License-Identifier: MIT
+
"""
Generate documentation for pyboard API from C files.
"""
diff --git a/tools/git-checkout-latest-tag.sh b/tools/git-checkout-latest-tag.sh
index f6242a946..69fa2ced4 100755
--- a/tools/git-checkout-latest-tag.sh
+++ b/tools/git-checkout-latest-tag.sh
@@ -1,3 +1,8 @@
#!/bin/bash
+
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+#
+# SPDX-License-Identifier: MIT
+
git fetch --tags
git checkout $(git describe --tags `git rev-list --tags --max-count=1`)
diff --git a/tools/hid_report_descriptors.py b/tools/hid_report_descriptors.py
index 07ed26744..e13e0dbdd 100644
--- a/tools/hid_report_descriptors.py
+++ b/tools/hid_report_descriptors.py
@@ -1,24 +1,7 @@
-# The MIT License (MIT)
+# SPDX-FileCopyrightText: Copyright (c) 2018 Dan Halbert for Adafruit Industries
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
#
-# Copyright (c) 2018 Dan Halbert for Adafruit Industries
-#
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to deal
-# in the Software without restriction, including without limitation the rights
-# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-# copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included in
-# all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-# THE SOFTWARE.
+# SPDX-License-Identifier: MIT
import struct
diff --git a/tools/insert-usb-ids.py b/tools/insert-usb-ids.py
index cdccd3be9..bf74ceeab 100644
--- a/tools/insert-usb-ids.py
+++ b/tools/insert-usb-ids.py
@@ -1,3 +1,7 @@
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+#
+# SPDX-License-Identifier: MIT
+
# Reads the USB VID and PID from the file specified by sys.argv[1] and then
# inserts those values into the template file specified by sys.argv[2],
# printing the result to stdout
diff --git a/tools/join_bins.py b/tools/join_bins.py
index cb73aaabb..a370f86e4 100644
--- a/tools/join_bins.py
+++ b/tools/join_bins.py
@@ -1,3 +1,7 @@
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+#
+# SPDX-License-Identifier: MIT
+
import sys
output_filename = sys.argv[1]
diff --git a/tools/make-frozen.py b/tools/make-frozen.py
index 1051b520e..ad23b9d59 100755
--- a/tools/make-frozen.py
+++ b/tools/make-frozen.py
@@ -1,4 +1,9 @@
#!/usr/bin/env python
+
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+#
+# SPDX-License-Identifier: MIT
+
#
# Create frozen modules structure for MicroPython.
#
diff --git a/tools/mksdiodata.py b/tools/mksdiodata.py
new file mode 100755
index 000000000..0cce3819f
--- /dev/null
+++ b/tools/mksdiodata.py
@@ -0,0 +1,40 @@
+#!/usr/bin/python3
+
+def defines(name, function):
+ print(f'pin_function_t {name} [] = {{')
+ for instance in (0, 1):
+ for port in 'ABCD':
+ for idx in range(32):
+ pin = f'P{port}{idx:02d}'
+ pinmux = f'PINMUX_{pin}I_SDHC{instance}_{function}'
+ print(f'''\
+#if defined({pinmux}) && ! defined(IGNORE_PIN_{pin})
+ {{&pin_{pin}, {instance}, PIN_{pin}, {pinmux} & 0xffff}},
+#endif''')
+ print(f'{{NULL, 0, 0}}')
+ print(f'}};')
+ print()
+
+print('''\
+#include <stdint.h>
+#include "py/obj.h"
+#include "sam.h"
+#include "samd/pins.h"
+#include "mpconfigport.h"
+#include "atmel_start_pins.h"
+#include "hal/include/hal_gpio.h"
+
+typedef struct {
+ const mcu_pin_obj_t *obj;
+ uint8_t instance;
+ uint8_t pin;
+ uint16_t function;
+} pin_function_t;
+''')
+
+defines('sdio_ck', 'SDCK')
+defines('sdio_cmd', 'SDCMD')
+defines('sdio_dat0', 'SDDAT0')
+defines('sdio_dat1', 'SDDAT1')
+defines('sdio_dat2', 'SDDAT2')
+defines('sdio_dat3', 'SDDAT3')
diff --git a/tools/mpy-tool.py b/tools/mpy-tool.py
index 5ce24061b..95090466c 100755
--- a/tools/mpy-tool.py
+++ b/tools/mpy-tool.py
@@ -1,28 +1,9 @@
#!/usr/bin/env python3
+
+# SPDX-FileCopyrightText: Copyright (c) 2016 Damien P. George
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
#
-# This file is part of the MicroPython project, http://micropython.org/
-#
-# The MIT License (MIT)
-#
-# Copyright (c) 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.
+# SPDX-License-Identifier: MIT
# Python 2/3 compatibility code
from __future__ import print_function
diff --git a/tools/mpy_bin2res.py b/tools/mpy_bin2res.py
index 0c89e7e92..8d67b71ba 100755
--- a/tools/mpy_bin2res.py
+++ b/tools/mpy_bin2res.py
@@ -1,4 +1,9 @@
#!/usr/bin/env python3
+
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+#
+# SPDX-License-Identifier: MIT
+
#
# This tool converts binary resource files passed on the command line
# into a Python source file containing data from these files, which can
diff --git a/tools/mpy_cross_all.py b/tools/mpy_cross_all.py
index 2bda71e9b..5d9f8bc0b 100755
--- a/tools/mpy_cross_all.py
+++ b/tools/mpy_cross_all.py
@@ -1,4 +1,9 @@
#!/usr/bin/env python3
+
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+#
+# SPDX-License-Identifier: MIT
+
import argparse
import os
import os.path
diff --git a/tools/preprocess_frozen_modules.py b/tools/preprocess_frozen_modules.py
index 7ae20c4d6..b75a2e723 100755
--- a/tools/preprocess_frozen_modules.py
+++ b/tools/preprocess_frozen_modules.py
@@ -1,4 +1,9 @@
#!/usr/bin/env python3
+
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+#
+# SPDX-License-Identifier: MIT
+
import argparse
import os
import os.path
diff --git a/tools/print_status.py b/tools/print_status.py
index ed563fd68..9a8b311dc 100755
--- a/tools/print_status.py
+++ b/tools/print_status.py
@@ -1,5 +1,9 @@
#!/usr/bin/env python3
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+#
+# SPDX-License-Identifier: MIT
+
import sys
if len(sys.argv) != 2:
print("""\
diff --git a/tools/pyboard.py b/tools/pyboard.py
index bb5642bd7..ddf6bb6c4 100755
--- a/tools/pyboard.py
+++ b/tools/pyboard.py
@@ -1,29 +1,10 @@
#!/usr/bin/env python
+
+# SPDX-FileCopyrightText: Copyright (c) 2014-2016 Damien P. George
+# SPDX-FileCopyrightText: Copyright (c) 2017 Paul Sokolovsky
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
#
-# This file is part of the MicroPython project, http://micropython.org/
-#
-# The MIT License (MIT)
-#
-# Copyright (c) 2014-2016 Damien P. George
-# Copyright (c) 2017 Paul Sokolovsky
-#
-# 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.
+# SPDX-License-Identifier: MIT
"""
pyboard interface
diff --git a/tools/pydfu.py b/tools/pydfu.py
index a7adda37c..a6210c603 100755
--- a/tools/pydfu.py
+++ b/tools/pydfu.py
@@ -1,8 +1,9 @@
#!/usr/bin/env python
-# This file is part of the OpenMV project.
-# Copyright (c) 2013/2014 Ibrahim Abdelkader <i.abdalkader@gmail.com>
-# This work is licensed under the MIT license, see the file LICENSE for
-# details.
+
+# SPDX-FileCopyrightText: Copyright (c) 2013/2014 Ibrahim Abdelkader <i.abdalkader@gmail.com>
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+#
+# SPDX-License-Identifier: MIT
"""This module implements enough functionality to program the STM32F4xx over
DFU, without requiring dfu-util.
diff --git a/tools/tinytest-codegen.py b/tools/tinytest-codegen.py
index 7a48f8a9a..74b1878f9 100755
--- a/tools/tinytest-codegen.py
+++ b/tools/tinytest-codegen.py
@@ -1,5 +1,9 @@
#!/usr/bin/env python3
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+#
+# SPDX-License-Identifier: MIT
+
import os, sys
from glob import glob
from re import sub
diff --git a/tools/upip.py b/tools/upip.py
index a400c3174..27fbae272 100644
--- a/tools/upip.py
+++ b/tools/upip.py
@@ -1,10 +1,10 @@
-#
# upip - Package manager for MicroPython
+
+# SPDX-FileCopyrightText: Copyright (c) 2015-2018 Paul Sokolovsky
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
#
-# Copyright (c) 2015-2018 Paul Sokolovsky
-#
-# Licensed under the MIT license.
-#
+# SPDX-License-Identifier: MIT
+
import sys
import gc
import uos as os
diff --git a/tools/upip_utarfile.py b/tools/upip_utarfile.py
index 460ca2cd4..44d636452 100644
--- a/tools/upip_utarfile.py
+++ b/tools/upip_utarfile.py
@@ -1,3 +1,7 @@
+# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
+#
+# SPDX-License-Identifier: MIT
+
import uctypes
# http://www.gnu.org/software/tar/manual/html_node/Standard.html