summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsommersoft <sommersoft@users.noreply.github.com>2019-07-27 10:46:53 -0500
committerGitHub <noreply@github.com>2019-07-27 10:46:53 -0500
commitcebdadd0f6122826337c962b3d443bd41d1de69d (patch)
treee2aeb661c3760f7aaf152bc1bbd95fd120161ab8
parentc335f170d7d561d07ca7412da60c260e13c5e746 (diff)
parentd99d3bd471920cdd9b2683b7dbd538551f7aee43 (diff)
Merge branch 'master' into dynamic_support_matrix
-rw-r--r--.gitmodules3
-rwxr-xr-x.travis.yml8
-rw-r--r--conf.py5
m---------lib/tinyusb0
-rw-r--r--locale/ID.po190
-rw-r--r--locale/circuitpython.pot128
-rw-r--r--locale/de_DE.po197
-rw-r--r--locale/en_US.po128
-rw-r--r--locale/en_x_pirate.po128
-rw-r--r--locale/es.po240
-rw-r--r--locale/fil.po204
-rw-r--r--locale/fr.po218
-rw-r--r--locale/it_IT.po204
-rw-r--r--locale/pl.po200
-rw-r--r--locale/pt_BR.po176
-rw-r--r--locale/zh_Latn_pinyin.po200
-rwxr-xr-xmain.c7
-rw-r--r--ports/atmel-samd/README.rst17
-rw-r--r--ports/atmel-samd/audio_dma.c4
-rw-r--r--ports/atmel-samd/audio_dma.h4
-rw-r--r--ports/atmel-samd/boards/datum_distance/board.c38
-rw-r--r--ports/atmel-samd/boards/datum_distance/mpconfigboard.h29
-rw-r--r--ports/atmel-samd/boards/datum_distance/mpconfigboard.mk14
-rw-r--r--ports/atmel-samd/boards/datum_distance/pins.c27
-rw-r--r--ports/atmel-samd/boards/datum_imu/board.c38
-rw-r--r--ports/atmel-samd/boards/datum_imu/mpconfigboard.h29
-rw-r--r--ports/atmel-samd/boards/datum_imu/mpconfigboard.mk14
-rw-r--r--ports/atmel-samd/boards/datum_imu/pins.c29
-rw-r--r--ports/atmel-samd/boards/datum_light/board.c38
-rw-r--r--ports/atmel-samd/boards/datum_light/mpconfigboard.h29
-rw-r--r--ports/atmel-samd/boards/datum_light/mpconfigboard.mk14
-rw-r--r--ports/atmel-samd/boards/datum_light/pins.c27
-rw-r--r--ports/atmel-samd/boards/datum_weather/board.c38
-rw-r--r--ports/atmel-samd/boards/datum_weather/mpconfigboard.h29
-rw-r--r--ports/atmel-samd/boards/datum_weather/mpconfigboard.mk14
-rw-r--r--ports/atmel-samd/boards/datum_weather/pins.c27
-rw-r--r--ports/atmel-samd/boards/hallowing_m0_express/board.c3
-rw-r--r--ports/atmel-samd/boards/hallowing_m0_express/mpconfigboard.mk1
-rw-r--r--ports/atmel-samd/boards/pybadge/board.c3
-rw-r--r--ports/atmel-samd/boards/pybadge_airlift/board.c3
-rw-r--r--ports/atmel-samd/boards/pygamer/board.c3
-rw-r--r--ports/atmel-samd/boards/pygamer_advance/board.c3
-rw-r--r--ports/atmel-samd/boards/pyportal/board.c5
-rw-r--r--ports/atmel-samd/boards/pyruler/board.c37
-rw-r--r--ports/atmel-samd/boards/pyruler/mpconfigboard.h63
-rw-r--r--ports/atmel-samd/boards/pyruler/mpconfigboard.mk14
-rw-r--r--ports/atmel-samd/boards/pyruler/pins.c50
-rw-r--r--ports/atmel-samd/boards/ugame10/board.c3
-rw-r--r--ports/atmel-samd/boards/ugame10/brutalist-6.bdf1147
-rw-r--r--ports/atmel-samd/boards/ugame10/brutalist.sfd1034
-rw-r--r--ports/atmel-samd/boards/ugame10/mpconfigboard.mk2
-rw-r--r--ports/atmel-samd/common-hal/audiobusio/I2SOut.c2
-rw-r--r--ports/atmel-samd/common-hal/busio/I2C.c9
-rw-r--r--ports/atmel-samd/common-hal/busio/SPI.h1
-rw-r--r--ports/atmel-samd/common-hal/busio/UART.c12
-rw-r--r--ports/atmel-samd/common-hal/displayio/ParallelBus.c17
-rw-r--r--ports/atmel-samd/mpconfigport.mk2
-rw-r--r--ports/esp8266/common-hal/busio/UART.c2
-rwxr-xr-xports/nrf/Makefile2
-rw-r--r--ports/nrf/bluetooth/ble_drv.c3
-rw-r--r--ports/nrf/bluetooth/ble_drv.h10
-rw-r--r--ports/nrf/bluetooth/ble_uart.c3
-rw-r--r--ports/nrf/boards/electronut_labs_blip/mpconfigboard.mk10
-rw-r--r--ports/nrf/boards/particle_xenon/mpconfigboard.h6
-rw-r--r--ports/nrf/common-hal/analogio/AnalogIn.c2
-rw-r--r--ports/nrf/common-hal/bleio/Adapter.c11
-rw-r--r--ports/nrf/common-hal/bleio/Adapter.h3
-rw-r--r--ports/nrf/common-hal/bleio/Broadcaster.c98
-rw-r--r--ports/nrf/common-hal/bleio/Central.c463
-rw-r--r--ports/nrf/common-hal/bleio/Central.h (renamed from shared-module/bleio/Device.h)20
-rw-r--r--ports/nrf/common-hal/bleio/Characteristic.c228
-rw-r--r--ports/nrf/common-hal/bleio/Characteristic.h14
-rw-r--r--ports/nrf/common-hal/bleio/CharacteristicBuffer.c45
-rw-r--r--ports/nrf/common-hal/bleio/CharacteristicBuffer.h8
-rw-r--r--ports/nrf/common-hal/bleio/Descriptor.c8
-rw-r--r--ports/nrf/common-hal/bleio/Descriptor.h5
-rw-r--r--ports/nrf/common-hal/bleio/Device.c601
-rw-r--r--ports/nrf/common-hal/bleio/Peripheral.c359
-rw-r--r--ports/nrf/common-hal/bleio/Peripheral.h23
-rw-r--r--ports/nrf/common-hal/bleio/Scanner.c57
-rw-r--r--ports/nrf/common-hal/bleio/Scanner.h (renamed from shared-module/bleio/Scanner.h)9
-rw-r--r--ports/nrf/common-hal/bleio/Service.c34
-rw-r--r--ports/nrf/common-hal/bleio/Service.h (renamed from shared-module/bleio/Service.h)14
-rw-r--r--ports/nrf/common-hal/bleio/UUID.c3
-rw-r--r--ports/nrf/common-hal/bleio/UUID.h3
-rw-r--r--ports/nrf/common-hal/bleio/__init__.c14
-rw-r--r--ports/nrf/common-hal/bleio/__init__.h6
-rw-r--r--ports/nrf/common-hal/busio/I2C.c22
-rw-r--r--ports/nrf/common-hal/busio/SPI.c10
-rw-r--r--ports/nrf/common-hal/busio/UART.c2
-rw-r--r--ports/nrf/common-hal/microcontroller/Pin.c2
-rw-r--r--ports/nrf/common-hal/pulseio/PWMOut.c55
-rw-r--r--ports/nrf/mphalport.c3
-rw-r--r--ports/nrf/nrfx_config.h4
-rw-r--r--ports/stm32f4/.gitignore9
-rwxr-xr-xports/stm32f4/Makefile271
-rw-r--r--ports/stm32f4/README.md3
-rw-r--r--ports/stm32f4/background.c57
-rw-r--r--ports/stm32f4/background.h35
-rw-r--r--ports/stm32f4/boards/STM32F411VETx_FLASH.ld189
-rw-r--r--ports/stm32f4/boards/STM32F412ZGTx_FLASH.ld189
-rw-r--r--ports/stm32f4/boards/board.h45
-rw-r--r--ports/stm32f4/boards/startup_stm32f411xe.s452
-rw-r--r--ports/stm32f4/boards/startup_stm32f412zx.s524
-rw-r--r--ports/stm32f4/boards/stm32f411.ld189
-rw-r--r--ports/stm32f4/boards/stm32f411re_discovery/board.c (renamed from supervisor/shared/usb/usb_desc.h)23
-rw-r--r--ports/stm32f4/boards/stm32f411re_discovery/mpconfigboard.h38
-rw-r--r--ports/stm32f4/boards/stm32f411re_discovery/mpconfigboard.mk13
-rw-r--r--ports/stm32f4/boards/stm32f411re_discovery/pins.c90
-rw-r--r--ports/stm32f4/boards/stm32f411re_discovery/stm32f4xx_hal_conf.h439
-rw-r--r--ports/stm32f4/boards/stm32f411re_discovery/stm32f4xx_hal_msp.c427
-rw-r--r--ports/stm32f4/boards/stm32f412zg_discovery/board.c38
-rw-r--r--ports/stm32f4/boards/stm32f412zg_discovery/mpconfigboard.h38
-rw-r--r--ports/stm32f4/boards/stm32f412zg_discovery/mpconfigboard.mk13
-rw-r--r--ports/stm32f4/boards/stm32f412zg_discovery/pins.c90
-rw-r--r--ports/stm32f4/boards/stm32f412zg_discovery/stm32f4xx_hal_conf.h439
-rw-r--r--ports/stm32f4/boards/stm32f412zg_discovery/stm32f4xx_hal_msp.c832
-rw-r--r--ports/stm32f4/common-hal/board/__init__.c25
-rw-r--r--ports/stm32f4/common-hal/digitalio/DigitalInOut.c159
-rw-r--r--ports/stm32f4/common-hal/digitalio/DigitalInOut.h38
-rw-r--r--ports/stm32f4/common-hal/digitalio/__init__.c1
-rw-r--r--ports/stm32f4/common-hal/microcontroller/Pin.c81
-rw-r--r--ports/stm32f4/common-hal/microcontroller/Pin.h42
-rw-r--r--ports/stm32f4/common-hal/microcontroller/Processor.c44
-rw-r--r--ports/stm32f4/common-hal/microcontroller/Processor.h39
-rw-r--r--ports/stm32f4/common-hal/microcontroller/__init__.c191
-rw-r--r--ports/stm32f4/common-hal/nvm/ByteArray.c81
-rw-r--r--ports/stm32f4/common-hal/nvm/ByteArray.h36
-rw-r--r--ports/stm32f4/common-hal/nvm/__init__.c27
-rwxr-xr-xports/stm32f4/common-hal/supervisor/Runtime.c38
-rwxr-xr-xports/stm32f4/common-hal/supervisor/Runtime.h37
-rwxr-xr-xports/stm32f4/common-hal/supervisor/__init__.c40
-rw-r--r--ports/stm32f4/common-hal/time/__init__.c37
-rw-r--r--ports/stm32f4/fatfs_port.c33
-rw-r--r--ports/stm32f4/mpconfigport.h45
-rw-r--r--ports/stm32f4/mpconfigport.mk22
-rw-r--r--ports/stm32f4/mphalport.c (renamed from shared-bindings/bleio/Device.h)38
-rw-r--r--ports/stm32f4/mphalport.h45
-rw-r--r--ports/stm32f4/peripherals/stm32f4/clocks.h27
-rw-r--r--ports/stm32f4/peripherals/stm32f4/gpio.h27
-rw-r--r--ports/stm32f4/peripherals/stm32f4/pins.h73
-rw-r--r--ports/stm32f4/peripherals/stm32f4/stm32f411xe/clocks.c63
-rw-r--r--ports/stm32f4/peripherals/stm32f4/stm32f411xe/gpio.c137
-rw-r--r--ports/stm32f4/peripherals/stm32f4/stm32f411xe/pins.c33
-rw-r--r--ports/stm32f4/peripherals/stm32f4/stm32f411xe/pins.h36
-rw-r--r--ports/stm32f4/peripherals/stm32f4/stm32f412zx/clocks.c75
-rw-r--r--ports/stm32f4/peripherals/stm32f4/stm32f412zx/gpio.c218
-rw-r--r--ports/stm32f4/peripherals/stm32f4/stm32f412zx/pins.c159
-rw-r--r--ports/stm32f4/peripherals/stm32f4/stm32f412zx/pins.h156
-rw-r--r--ports/stm32f4/qstrdefsport.h1
m---------ports/stm32f4/stm32f40
-rwxr-xr-xports/stm32f4/supervisor/cpu.s27
-rw-r--r--ports/stm32f4/supervisor/internal_flash.c73
-rw-r--r--ports/stm32f4/supervisor/internal_flash.h37
-rw-r--r--ports/stm32f4/supervisor/internal_flash_root_pointers.h31
-rw-r--r--ports/stm32f4/supervisor/port.c80
-rw-r--r--ports/stm32f4/supervisor/qspi_flash.c162
-rw-r--r--ports/stm32f4/supervisor/serial.c75
-rw-r--r--ports/stm32f4/supervisor/usb.c80
-rw-r--r--ports/stm32f4/system_stm32f4xx.c761
-rw-r--r--ports/stm32f4/tick.c85
-rw-r--r--ports/stm32f4/tick.h46
-rw-r--r--py/circuitpy_defns.mk17
-rw-r--r--py/circuitpy_mpconfig.h8
-rw-r--r--py/circuitpy_mpconfig.mk58
-rw-r--r--py/obj.h1
-rw-r--r--py/objlist.c4
-rw-r--r--shared-bindings/_stage/__init__.c7
-rw-r--r--shared-bindings/audiocore/Mixer.c (renamed from shared-bindings/audioio/Mixer.c)4
-rw-r--r--shared-bindings/audiocore/Mixer.h (renamed from shared-bindings/audioio/Mixer.h)4
-rw-r--r--shared-bindings/audiocore/RawSample.c (renamed from shared-bindings/audioio/RawSample.c)2
-rw-r--r--shared-bindings/audiocore/RawSample.h (renamed from shared-bindings/audioio/RawSample.h)3
-rw-r--r--shared-bindings/audiocore/WaveFile.c (renamed from shared-bindings/audioio/WaveFile.c)2
-rw-r--r--shared-bindings/audiocore/WaveFile.h (renamed from shared-bindings/audioio/WaveFile.h)5
-rw-r--r--shared-bindings/audiocore/__init__.c69
-rw-r--r--shared-bindings/audiocore/__init__.h (renamed from shared-bindings/bleio/AdvertisementData.h)10
-rw-r--r--shared-bindings/audioio/AudioOut.c2
-rw-r--r--shared-bindings/audioio/AudioOut.h2
-rw-r--r--shared-bindings/audioio/__init__.c12
-rw-r--r--shared-bindings/bleio/Adapter.c1
-rw-r--r--shared-bindings/bleio/Adapter.h1
-rw-r--r--shared-bindings/bleio/Address.c195
-rw-r--r--shared-bindings/bleio/Address.h14
-rw-r--r--shared-bindings/bleio/AddressType.c99
-rw-r--r--shared-bindings/bleio/AdvertisementData.c90
-rw-r--r--shared-bindings/bleio/Broadcaster.c132
-rw-r--r--shared-bindings/bleio/Central.c199
-rw-r--r--shared-bindings/bleio/Central.h (renamed from ports/nrf/common-hal/bleio/Broadcaster.h)29
-rw-r--r--shared-bindings/bleio/Characteristic.c92
-rw-r--r--shared-bindings/bleio/Characteristic.h10
-rw-r--r--shared-bindings/bleio/CharacteristicBuffer.c12
-rw-r--r--shared-bindings/bleio/CharacteristicBuffer.h2
-rw-r--r--shared-bindings/bleio/Descriptor.c99
-rw-r--r--shared-bindings/bleio/Descriptor.h19
-rw-r--r--shared-bindings/bleio/Device.c363
-rw-r--r--shared-bindings/bleio/Peripheral.c115
-rw-r--r--shared-bindings/bleio/Peripheral.h9
-rw-r--r--shared-bindings/bleio/ScanEntry.c252
-rw-r--r--shared-bindings/bleio/ScanEntry.h6
-rw-r--r--shared-bindings/bleio/Scanner.c151
-rw-r--r--shared-bindings/bleio/Scanner.h7
-rw-r--r--shared-bindings/bleio/Service.c75
-rw-r--r--shared-bindings/bleio/Service.h9
-rw-r--r--shared-bindings/bleio/UUID.c16
-rw-r--r--shared-bindings/bleio/UUID.h1
-rw-r--r--shared-bindings/bleio/__init__.c32
-rw-r--r--shared-bindings/bleio/__init__.h3
-rw-r--r--shared-bindings/busio/I2C.h3
-rw-r--r--shared-bindings/busio/UART.h2
-rw-r--r--shared-bindings/displayio/ColorConverter.c8
-rw-r--r--shared-bindings/displayio/ColorConverter.h4
-rw-r--r--shared-bindings/displayio/Display.c24
-rw-r--r--shared-bindings/displayio/Display.h8
-rw-r--r--shared-bindings/displayio/Group.c2
-rw-r--r--shared-bindings/displayio/I2CDisplay.c138
-rw-r--r--shared-bindings/displayio/I2CDisplay.h (renamed from shared-bindings/bleio/AddressType.h)34
-rw-r--r--shared-bindings/displayio/Palette.c27
-rw-r--r--shared-bindings/displayio/Palette.h2
-rw-r--r--shared-bindings/displayio/__init__.c3
-rw-r--r--shared-module/audiocore/Mixer.c (renamed from shared-module/audioio/Mixer.c)6
-rw-r--r--shared-module/audiocore/Mixer.h (renamed from shared-module/audioio/Mixer.h)2
-rw-r--r--shared-module/audiocore/RawSample.c (renamed from shared-module/audioio/RawSample.c)4
-rw-r--r--shared-module/audiocore/RawSample.h (renamed from shared-module/audioio/RawSample.h)2
-rw-r--r--shared-module/audiocore/WaveFile.c (renamed from shared-module/audioio/WaveFile.c)4
-rw-r--r--shared-module/audiocore/WaveFile.h (renamed from shared-module/audioio/WaveFile.h)2
-rw-r--r--shared-module/audiocore/__init__.c125
-rw-r--r--shared-module/audiocore/__init__.h53
-rw-r--r--shared-module/audioio/__init__.c125
-rw-r--r--shared-module/audioio/__init__.h23
-rw-r--r--shared-module/bleio/Address.c45
-rw-r--r--shared-module/bleio/Address.h9
-rw-r--r--shared-module/bleio/AdvertisementData.h85
-rw-r--r--shared-module/bleio/Characteristic.h3
-rw-r--r--shared-module/bleio/ScanEntry.c (renamed from shared-bindings/bleio/Broadcaster.h)23
-rw-r--r--shared-module/bleio/ScanEntry.h6
-rw-r--r--shared-module/board/__init__.c12
-rw-r--r--shared-module/displayio/ColorConverter.c35
-rw-r--r--shared-module/displayio/ColorConverter.h4
-rw-r--r--shared-module/displayio/Display.c171
-rw-r--r--shared-module/displayio/Display.h4
-rw-r--r--shared-module/displayio/FourWire.c21
-rw-r--r--shared-module/displayio/FourWire.h6
-rw-r--r--shared-module/displayio/Group.c6
-rw-r--r--shared-module/displayio/Group.h3
-rw-r--r--shared-module/displayio/I2CDisplay.c105
-rw-r--r--shared-module/displayio/I2CDisplay.h41
-rw-r--r--shared-module/displayio/Palette.c50
-rw-r--r--shared-module/displayio/Palette.h21
-rw-r--r--shared-module/displayio/TileGrid.c54
-rw-r--r--shared-module/displayio/TileGrid.h3
-rw-r--r--shared-module/displayio/__init__.c135
-rw-r--r--shared-module/displayio/__init__.h2
-rw-r--r--shared-module/terminalio/Terminal.c2
-rw-r--r--shared-module/usb_hid/Device.c10
-rw-r--r--shared-module/usb_midi/PortOut.c2
-rw-r--r--supervisor/shared/display.c49
-rw-r--r--supervisor/shared/rgb_led_status.c125
-rw-r--r--supervisor/shared/status_leds.c2
-rw-r--r--supervisor/shared/usb/tusb_config.h2
-rw-r--r--supervisor/shared/usb/usb_desc.c42
-rw-r--r--supervisor/shared/usb/usb_msc_flash.c96
-rw-r--r--tools/build_board_info.py3
-rw-r--r--tools/gen_display_resources.py24
263 files changed, 15314 insertions, 4006 deletions
diff --git a/.gitmodules b/.gitmodules
index 163d45fcd..7b57cab54 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -95,3 +95,6 @@
[submodule "frozen/circuitpython-stage"]
path = frozen/circuitpython-stage
url = https://github.com/python-ugame/circuitpython-stage.git
+[submodule "ports/stm32f4/stm32f4"]
+ path = ports/stm32f4/stm32f4
+ url = https://github.com/adafruit/stm32f4.git
diff --git a/.travis.yml b/.travis.yml
index de5f34c68..d75b4e7d4 100755
--- a/.travis.yml
+++ b/.travis.yml
@@ -22,10 +22,10 @@ git:
# just try to make the builds "about equal in run time"
env:
- TRAVIS_TESTS="unix docs translations website" TRAVIS_BOARDS="circuitplayground_express mini_sam_m4 grandcentral_m4_express capablerobot_usbhub pygamer pca10056 pca10059 feather_nrf52840_express makerdiary_nrf52840_mdk makerdiary_nrf52840_mdk_usb_dongle particle_boron particle_argon particle_xenon sparkfun_nrf52840_mini electronut_labs_papyr electronut_labs_blip" TRAVIS_SDK=arm:nrf
- - TRAVIS_BOARDS="metro_m0_express metro_m4_express metro_m4_airlift_lite pirkey_m0 trellis_m4_express trinket_m0 sparkfun_lumidrive sparkfun_redboard_turbo bast_pro_mini_m0" TRAVIS_SDK=arm
- - TRAVIS_BOARDS="feather_radiofruit_zigbee gemma_m0 hallowing_m0_express itsybitsy_m0_express itsybitsy_m4_express meowmeow sam32 uchip escornabot_makech pygamer_advance" TRAVIS_SDK=arm
- - TRAVIS_BOARDS="feather_m0_express_crickit feather_m0_rfm69 feather_m0_rfm9x feather_m4_express arduino_zero arduino_mkr1300 arduino_mkrzero pewpew10 kicksat-sprite ugame10 robohatmm1" TRAVIS_SDK=arm
- - TRAVIS_BOARDS="circuitplayground_express_crickit feather_m0_adalogger feather_m0_basic feather_m0_express catwan_usbstick pyportal sparkfun_samd21_mini sparkfun_samd21_dev pybadge pybadge_airlift" TRAVIS_SDK=arm
+ - TRAVIS_BOARDS="metro_m0_express metro_m4_express metro_m4_airlift_lite pirkey_m0 trellis_m4_express trinket_m0 sparkfun_lumidrive sparkfun_redboard_turbo bast_pro_mini_m0 datum_distance pyruler" TRAVIS_SDK=arm
+ - TRAVIS_BOARDS="feather_radiofruit_zigbee gemma_m0 hallowing_m0_express itsybitsy_m0_express itsybitsy_m4_express meowmeow sam32 uchip escornabot_makech pygamer_advance datum_imu" TRAVIS_SDK=arm
+ - TRAVIS_BOARDS="feather_m0_express_crickit feather_m0_rfm69 feather_m0_rfm9x feather_m4_express arduino_zero arduino_mkr1300 arduino_mkrzero pewpew10 kicksat-sprite ugame10 robohatmm1 datum_light" TRAVIS_SDK=arm
+ - TRAVIS_BOARDS="circuitplayground_express_crickit feather_m0_adalogger feather_m0_basic feather_m0_express catwan_usbstick pyportal sparkfun_samd21_mini sparkfun_samd21_dev pybadge pybadge_airlift datum_weather" TRAVIS_SDK=arm
addons:
artifacts:
diff --git a/conf.py b/conf.py
index 1e287e75e..7a00454e0 100644
--- a/conf.py
+++ b/conf.py
@@ -98,6 +98,7 @@ version = release = '0.0.0'
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = ["**/build*",
+ ".git",
".venv",
".direnv",
"docs/README.md",
@@ -135,6 +136,10 @@ exclude_patterns = ["**/build*",
"ports/nrf/nrfx",
"ports/nrf/peripherals",
"ports/nrf/usb",
+ "ports/stm32f4/stm32f4",
+ "ports/stm32f4/peripherals",
+ "ports/stm32f4/ref",
+ "ports/stm32f4/README.md",
"ports/pic16bit",
"ports/qemu-arm",
"ports/stm32",
diff --git a/lib/tinyusb b/lib/tinyusb
-Subproject 0848c462b3e431a9da42e96537d2b597a457963
+Subproject 1ee9ef4f2b7c6acfab6c398a4f57ca22036958f
diff --git a/locale/ID.po b/locale/ID.po
index d062bce29..b211d5379 100644
--- a/locale/ID.po
+++ b/locale/ID.po
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2019-06-25 17:53-0700\n"
+"POT-Creation-Date: 2019-07-19 16:10-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"
@@ -219,15 +219,14 @@ msgid "A hardware interrupt channel is already in use"
msgstr "Sebuah channel hardware interrupt sedang digunakan"
#: shared-bindings/bleio/Address.c
-#, c-format
-msgid "Address is not %d bytes long or is in wrong format"
-msgstr ""
-
-#: shared-bindings/bleio/Address.c
#, fuzzy, c-format
msgid "Address must be %d bytes long"
msgstr "buffers harus mempunyai panjang yang sama"
+#: shared-bindings/bleio/Address.c
+msgid "Address type out of range"
+msgstr ""
+
#: ports/nrf/common-hal/busio/I2C.c
msgid "All I2C peripherals are in use"
msgstr "Semua perangkat I2C sedang digunakan"
@@ -313,6 +312,10 @@ msgstr ""
msgid "Both pins must support hardware interrupts"
msgstr "Kedua pin harus mendukung hardware interrut"
+#: shared-bindings/displayio/Display.c
+msgid "Brightness must be 0-1.0"
+msgstr ""
+
#: shared-bindings/supervisor/__init__.c
msgid "Brightness must be between 0 and 255"
msgstr ""
@@ -354,20 +357,8 @@ msgstr ""
msgid "Can not use dotstar with %s"
msgstr ""
-#: shared-bindings/bleio/Device.c
-msgid "Can't add services in Central mode"
-msgstr ""
-
-#: shared-bindings/bleio/Device.c
-msgid "Can't advertise in Central mode"
-msgstr ""
-
-#: shared-bindings/bleio/Device.c
-msgid "Can't change the name in Central mode"
-msgstr ""
-
-#: shared-bindings/bleio/Device.c
-msgid "Can't connect in Peripheral mode"
+#: ports/nrf/common-hal/bleio/Characteristic.c
+msgid "Can't set CCCD for local Characteristic"
msgstr ""
#: shared-bindings/displayio/Bitmap.c shared-bindings/pulseio/PulseIn.c
@@ -456,6 +447,10 @@ msgstr "Clock unit sedang digunakan"
msgid "Column entry must be digitalio.DigitalInOut"
msgstr ""
+#: shared-bindings/displayio/I2CDisplay.c
+msgid "Command must be 0-255"
+msgstr ""
+
#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c
msgid "Command must be an int between 0 and 255"
msgstr ""
@@ -502,17 +497,11 @@ msgstr ""
msgid "Data chunk must follow fmt chunk"
msgstr ""
-#: ports/nrf/common-hal/bleio/Broadcaster.c
#: ports/nrf/common-hal/bleio/Peripheral.c
#, fuzzy
msgid "Data too large for advertisement packet"
msgstr "Tidak bisa menyesuaikan data ke dalam paket advertisment"
-#: ports/nrf/common-hal/bleio/Device.c
-#, fuzzy
-msgid "Data too large for the advertisement packet"
-msgstr "Tidak bisa menyesuaikan data ke dalam paket advertisment"
-
#: shared-bindings/audiobusio/PDMIn.c
msgid "Destination capacity is smaller than destination_length."
msgstr ""
@@ -550,6 +539,10 @@ msgstr ""
msgid "Expected a UUID"
msgstr ""
+#: shared-bindings/bleio/Central.c
+msgid "Expected an Address"
+msgstr ""
+
#: shared-module/_pixelbuf/PixelBuf.c
#, c-format
msgid "Expected tuple of length %d, got %d"
@@ -559,12 +552,7 @@ msgstr ""
msgid "Failed sending command."
msgstr ""
-#: ports/nrf/common-hal/bleio/Device.c
-#, fuzzy
-msgid "Failed to acquire mutex"
-msgstr "Gagal untuk mendapatkan mutex, status: 0x%08lX"
-
-#: ports/nrf/common-hal/bleio/Characteristic.c ports/nrf/sd_mutex.c
+#: ports/nrf/sd_mutex.c
#, fuzzy, c-format
msgid "Failed to acquire mutex, err 0x%04x"
msgstr "Gagal untuk mendapatkan mutex, status: 0x%08lX"
@@ -574,11 +562,6 @@ msgstr "Gagal untuk mendapatkan mutex, status: 0x%08lX"
msgid "Failed to add characteristic, err 0x%04x"
msgstr "Gagal untuk menambahkan karakteristik, status: 0x%08lX"
-#: ports/nrf/common-hal/bleio/Device.c
-#, fuzzy
-msgid "Failed to add service"
-msgstr "Gagal untuk menambahkan layanan, status: 0x%08lX"
-
#: ports/nrf/common-hal/bleio/Peripheral.c
#, fuzzy, c-format
msgid "Failed to add service, err 0x%04x"
@@ -599,27 +582,21 @@ msgstr "Gagal untuk megalokasikan buffer RX dari %d byte"
msgid "Failed to change softdevice state"
msgstr "Gagal untuk merubah status softdevice, error: 0x%08lX"
-#: ports/nrf/common-hal/bleio/Device.c
-#, fuzzy
-msgid "Failed to connect:"
-msgstr "Gagal untuk menyambungkan, status: 0x%08lX"
+#: ports/nrf/common-hal/bleio/Peripheral.c
+#, c-format
+msgid "Failed to configure advertising, err 0x%04x"
+msgstr ""
-#: ports/nrf/common-hal/bleio/Device.c
-#, fuzzy
-msgid "Failed to continue scanning"
-msgstr "Gagal untuk melanjutkan scanning, status: 0x%08lX"
+#: ports/nrf/common-hal/bleio/Central.c
+msgid "Failed to connect: timeout"
+msgstr ""
#: ports/nrf/common-hal/bleio/Scanner.c
#, fuzzy, c-format
msgid "Failed to continue scanning, err 0x%04x"
msgstr "Gagal untuk melanjutkan scanning, status: 0x%08lX"
-#: ports/nrf/common-hal/bleio/Device.c
-#, fuzzy
-msgid "Failed to create mutex"
-msgstr "Gagal untuk membuat mutex, status: 0x%08lX"
-
-#: ports/nrf/common-hal/bleio/Device.c
+#: ports/nrf/common-hal/bleio/Central.c
#, fuzzy
msgid "Failed to discover services"
msgstr "Gagal untuk menemukan layanan, status: 0x%08lX"
@@ -659,49 +636,42 @@ msgstr "Gagal untuk menulis nilai gatts, status: 0x%08lX"
msgid "Failed to register Vendor-Specific UUID, err 0x%04x"
msgstr "Gagal untuk menambahkan Vendor Spesific UUID, status: 0x%08lX"
-#: ports/nrf/common-hal/bleio/Device.c
-#, fuzzy
-msgid "Failed to release mutex"
-msgstr "Gagal untuk melepaskan mutex, status: 0x%08lX"
-
-#: ports/nrf/common-hal/bleio/Characteristic.c ports/nrf/sd_mutex.c
+#: ports/nrf/sd_mutex.c
#, fuzzy, c-format
msgid "Failed to release mutex, err 0x%04x"
msgstr "Gagal untuk melepaskan mutex, status: 0x%08lX"
-#: ports/nrf/common-hal/bleio/Device.c
-#, fuzzy
-msgid "Failed to start advertising"
-msgstr "Gagal untuk memulai advertisement, status: 0x%08lX"
+#: ports/nrf/common-hal/bleio/Peripheral.c
+#, c-format
+msgid "Failed to set device name, err 0x%04x"
+msgstr ""
-#: ports/nrf/common-hal/bleio/Broadcaster.c
#: ports/nrf/common-hal/bleio/Peripheral.c
#, fuzzy, c-format
msgid "Failed to start advertising, err 0x%04x"
msgstr "Gagal untuk memulai advertisement, status: 0x%08lX"
-#: ports/nrf/common-hal/bleio/Device.c
-#, fuzzy
-msgid "Failed to start scanning"
-msgstr "Gagal untuk melakukan scanning, status: 0x%08lX"
+#: ports/nrf/common-hal/bleio/Central.c
+#, c-format
+msgid "Failed to start connecting, error 0x%04x"
+msgstr ""
#: ports/nrf/common-hal/bleio/Scanner.c
#, fuzzy, c-format
msgid "Failed to start scanning, err 0x%04x"
msgstr "Gagal untuk melakukan scanning, status: 0x%08lX"
-#: ports/nrf/common-hal/bleio/Device.c
-#, fuzzy
-msgid "Failed to stop advertising"
-msgstr "Gagal untuk memberhentikan advertisement, status: 0x%08lX"
-
-#: ports/nrf/common-hal/bleio/Broadcaster.c
#: ports/nrf/common-hal/bleio/Peripheral.c
#, fuzzy, c-format
msgid "Failed to stop advertising, err 0x%04x"
msgstr "Gagal untuk memberhentikan advertisement, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Characteristic.c
+#, c-format
+msgid "Failed to write CCCD, err 0x%04x"
+msgstr ""
+
+#: ports/nrf/common-hal/bleio/Characteristic.c
#, fuzzy, c-format
msgid "Failed to write attribute value, err 0x%04x"
msgstr "Gagal untuk menulis nilai atribut, status: 0x%08lX"
@@ -916,6 +886,10 @@ msgstr ""
msgid "Must be a %q subclass."
msgstr ""
+#: ports/nrf/common-hal/bleio/Characteristic.c
+msgid "No CCCD for this Characteristic"
+msgstr ""
+
#: ports/atmel-samd/common-hal/analogio/AnalogOut.c
msgid "No DAC on chip"
msgstr "Tidak ada DAC (Digital Analog Converter) di dalam chip"
@@ -966,6 +940,7 @@ msgstr ""
msgid "No such file/directory"
msgstr ""
+#: ports/nrf/common-hal/bleio/Characteristic.c
#: shared-bindings/bleio/CharacteristicBuffer.c
#, fuzzy
msgid "Not connected"
@@ -1204,7 +1179,8 @@ msgstr "Untuk keluar, silahkan reset board tanpa "
msgid "Too many channels in sample."
msgstr "Terlalu banyak channel dalam sampel"
-#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c
+#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/I2CDisplay.c
+#: shared-bindings/displayio/ParallelBus.c
msgid "Too many display busses"
msgstr ""
@@ -1229,7 +1205,7 @@ msgid "USB Error"
msgstr ""
#: shared-bindings/bleio/UUID.c
-msgid "UUID integer value not in range 0 to 0xffff"
+msgid "UUID integer value must be 0-0xffff"
msgstr ""
#: shared-bindings/bleio/UUID.c
@@ -1245,6 +1221,11 @@ msgstr ""
msgid "Unable to allocate buffers for signed conversion"
msgstr "Tidak dapat mengalokasikan buffer untuk signed conversion"
+#: shared-module/displayio/I2CDisplay.c
+#, c-format
+msgid "Unable to find I2C Display at %x"
+msgstr ""
+
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
msgid "Unable to find free GCLK"
@@ -1928,8 +1909,9 @@ msgstr ""
msgid "integer required"
msgstr ""
-#: ports/nrf/common-hal/bleio/Broadcaster.c
-msgid "interval not in range 0.0020 to 10.24"
+#: shared-bindings/bleio/Peripheral.c shared-bindings/bleio/Scanner.c
+#, c-format
+msgid "interval must be in range %s-%s"
msgstr ""
#: extmod/machine_i2c.c
@@ -2144,6 +2126,14 @@ msgstr "tidak ada modul yang bernama '%q'"
msgid "no such attribute"
msgstr ""
+#: shared-bindings/bleio/Peripheral.c
+msgid "non-Service found in services"
+msgstr ""
+
+#: ports/nrf/common-hal/bleio/Central.c
+msgid "non-UUID found in service_uuids"
+msgstr ""
+
#: py/compile.c
msgid "non-default argument follows default argument"
msgstr "argumen non-default mengikuti argumen standar(default)"
@@ -2353,10 +2343,6 @@ msgstr ""
msgid "script compilation not supported"
msgstr "kompilasi script tidak didukung"
-#: shared-bindings/bleio/Peripheral.c
-msgid "services includes an object that is not a Service"
-msgstr ""
-
#: py/objstr.c
msgid "sign not allowed in string format specifier"
msgstr ""
@@ -2624,6 +2610,10 @@ msgstr ""
msgid "value_count must be > 0"
msgstr ""
+#: shared-bindings/bleio/Scanner.c
+msgid "window must be <= interval"
+msgstr ""
+
#: shared-bindings/_pixelbuf/PixelBuf.c
msgid "write_args must be a list, tuple, or None"
msgstr ""
@@ -2670,6 +2660,10 @@ msgstr ""
#~ msgid "Cannot update i/f status"
#~ msgstr "Tidak dapat memperbarui status i/f"
+#, fuzzy
+#~ msgid "Data too large for the advertisement packet"
+#~ msgstr "Tidak bisa menyesuaikan data ke dalam paket advertisment"
+
#~ msgid "Don't know how to pass object to native function"
#~ msgstr "Tidak tahu cara meloloskan objek ke fungsi native"
@@ -2683,6 +2677,26 @@ msgstr ""
#~ msgstr "Errod pada ffi_prep_cif"
#, fuzzy
+#~ msgid "Failed to acquire mutex"
+#~ msgstr "Gagal untuk mendapatkan mutex, status: 0x%08lX"
+
+#, fuzzy
+#~ msgid "Failed to add service"
+#~ msgstr "Gagal untuk menambahkan layanan, status: 0x%08lX"
+
+#, fuzzy
+#~ msgid "Failed to connect:"
+#~ msgstr "Gagal untuk menyambungkan, status: 0x%08lX"
+
+#, fuzzy
+#~ msgid "Failed to continue scanning"
+#~ msgstr "Gagal untuk melanjutkan scanning, status: 0x%08lX"
+
+#, fuzzy
+#~ msgid "Failed to create mutex"
+#~ msgstr "Gagal untuk membuat mutex, status: 0x%08lX"
+
+#, fuzzy
#~ msgid "Failed to notify or indicate attribute value, err %0x04x"
#~ msgstr "Gagal untuk melaporkan nilai atribut, status: 0x%08lX"
@@ -2690,6 +2704,22 @@ msgstr ""
#~ msgid "Failed to read attribute value, err %0x04x"
#~ msgstr "Gagal untuk membaca nilai atribut, status: 0x%08lX"
+#, fuzzy
+#~ msgid "Failed to release mutex"
+#~ msgstr "Gagal untuk melepaskan mutex, status: 0x%08lX"
+
+#, fuzzy
+#~ msgid "Failed to start advertising"
+#~ msgstr "Gagal untuk memulai advertisement, status: 0x%08lX"
+
+#, fuzzy
+#~ msgid "Failed to start scanning"
+#~ msgstr "Gagal untuk melakukan scanning, status: 0x%08lX"
+
+#, fuzzy
+#~ msgid "Failed to stop advertising"
+#~ msgstr "Gagal untuk memberhentikan advertisement, status: 0x%08lX"
+
#~ msgid "GPIO16 does not support pull up."
#~ msgstr "GPIO16 tidak mendukung pull up"
diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot
index 2b37887b4..d91e2b3ac 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: 2019-06-25 17:53-0700\n"
+"POT-Creation-Date: 2019-07-19 16:10-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"
@@ -219,12 +219,11 @@ msgstr ""
#: shared-bindings/bleio/Address.c
#, c-format
-msgid "Address is not %d bytes long or is in wrong format"
+msgid "Address must be %d bytes long"
msgstr ""
#: shared-bindings/bleio/Address.c
-#, c-format
-msgid "Address must be %d bytes long"
+msgid "Address type out of range"
msgstr ""
#: ports/nrf/common-hal/busio/I2C.c
@@ -309,6 +308,10 @@ msgstr ""
msgid "Both pins must support hardware interrupts"
msgstr ""
+#: shared-bindings/displayio/Display.c
+msgid "Brightness must be 0-1.0"
+msgstr ""
+
#: shared-bindings/supervisor/__init__.c
msgid "Brightness must be between 0 and 255"
msgstr ""
@@ -349,20 +352,8 @@ msgstr ""
msgid "Can not use dotstar with %s"
msgstr ""
-#: shared-bindings/bleio/Device.c
-msgid "Can't add services in Central mode"
-msgstr ""
-
-#: shared-bindings/bleio/Device.c
-msgid "Can't advertise in Central mode"
-msgstr ""
-
-#: shared-bindings/bleio/Device.c
-msgid "Can't change the name in Central mode"
-msgstr ""
-
-#: shared-bindings/bleio/Device.c
-msgid "Can't connect in Peripheral mode"
+#: ports/nrf/common-hal/bleio/Characteristic.c
+msgid "Can't set CCCD for local Characteristic"
msgstr ""
#: shared-bindings/displayio/Bitmap.c shared-bindings/pulseio/PulseIn.c
@@ -446,6 +437,10 @@ msgstr ""
msgid "Column entry must be digitalio.DigitalInOut"
msgstr ""
+#: shared-bindings/displayio/I2CDisplay.c
+msgid "Command must be 0-255"
+msgstr ""
+
#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c
msgid "Command must be an int between 0 and 255"
msgstr ""
@@ -492,15 +487,10 @@ msgstr ""
msgid "Data chunk must follow fmt chunk"
msgstr ""
-#: ports/nrf/common-hal/bleio/Broadcaster.c
#: ports/nrf/common-hal/bleio/Peripheral.c
msgid "Data too large for advertisement packet"
msgstr ""
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Data too large for the advertisement packet"
-msgstr ""
-
#: shared-bindings/audiobusio/PDMIn.c
msgid "Destination capacity is smaller than destination_length."
msgstr ""
@@ -538,6 +528,10 @@ msgstr ""
msgid "Expected a UUID"
msgstr ""
+#: shared-bindings/bleio/Central.c
+msgid "Expected an Address"
+msgstr ""
+
#: shared-module/_pixelbuf/PixelBuf.c
#, c-format
msgid "Expected tuple of length %d, got %d"
@@ -547,11 +541,7 @@ msgstr ""
msgid "Failed sending command."
msgstr ""
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Failed to acquire mutex"
-msgstr ""
-
-#: ports/nrf/common-hal/bleio/Characteristic.c ports/nrf/sd_mutex.c
+#: ports/nrf/sd_mutex.c
#, c-format
msgid "Failed to acquire mutex, err 0x%04x"
msgstr ""
@@ -561,10 +551,6 @@ msgstr ""
msgid "Failed to add characteristic, err 0x%04x"
msgstr ""
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Failed to add service"
-msgstr ""
-
#: ports/nrf/common-hal/bleio/Peripheral.c
#, c-format
msgid "Failed to add service, err 0x%04x"
@@ -584,12 +570,13 @@ msgstr ""
msgid "Failed to change softdevice state"
msgstr ""
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Failed to connect:"
+#: ports/nrf/common-hal/bleio/Peripheral.c
+#, c-format
+msgid "Failed to configure advertising, err 0x%04x"
msgstr ""
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Failed to continue scanning"
+#: ports/nrf/common-hal/bleio/Central.c
+msgid "Failed to connect: timeout"
msgstr ""
#: ports/nrf/common-hal/bleio/Scanner.c
@@ -597,11 +584,7 @@ msgstr ""
msgid "Failed to continue scanning, err 0x%04x"
msgstr ""
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Failed to create mutex"
-msgstr ""
-
-#: ports/nrf/common-hal/bleio/Device.c
+#: ports/nrf/common-hal/bleio/Central.c
msgid "Failed to discover services"
msgstr ""
@@ -638,27 +621,24 @@ msgstr ""
msgid "Failed to register Vendor-Specific UUID, err 0x%04x"
msgstr ""
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Failed to release mutex"
-msgstr ""
-
-#: ports/nrf/common-hal/bleio/Characteristic.c ports/nrf/sd_mutex.c
+#: ports/nrf/sd_mutex.c
#, c-format
msgid "Failed to release mutex, err 0x%04x"
msgstr ""
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Failed to start advertising"
+#: ports/nrf/common-hal/bleio/Peripheral.c
+#, c-format
+msgid "Failed to set device name, err 0x%04x"
msgstr ""
-#: ports/nrf/common-hal/bleio/Broadcaster.c
#: ports/nrf/common-hal/bleio/Peripheral.c
#, c-format
msgid "Failed to start advertising, err 0x%04x"
msgstr ""
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Failed to start scanning"
+#: ports/nrf/common-hal/bleio/Central.c
+#, c-format
+msgid "Failed to start connecting, error 0x%04x"
msgstr ""
#: ports/nrf/common-hal/bleio/Scanner.c
@@ -666,11 +646,6 @@ msgstr ""
msgid "Failed to start scanning, err 0x%04x"
msgstr ""
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Failed to stop advertising"
-msgstr ""
-
-#: ports/nrf/common-hal/bleio/Broadcaster.c
#: ports/nrf/common-hal/bleio/Peripheral.c
#, c-format
msgid "Failed to stop advertising, err 0x%04x"
@@ -678,6 +653,11 @@ msgstr ""
#: ports/nrf/common-hal/bleio/Characteristic.c
#, c-format
+msgid "Failed to write CCCD, err 0x%04x"
+msgstr ""
+
+#: ports/nrf/common-hal/bleio/Characteristic.c
+#, c-format
msgid "Failed to write attribute value, err 0x%04x"
msgstr ""
@@ -891,6 +871,10 @@ msgstr ""
msgid "Must be a %q subclass."
msgstr ""
+#: ports/nrf/common-hal/bleio/Characteristic.c
+msgid "No CCCD for this Characteristic"
+msgstr ""
+
#: ports/atmel-samd/common-hal/analogio/AnalogOut.c
msgid "No DAC on chip"
msgstr ""
@@ -941,6 +925,7 @@ msgstr ""
msgid "No such file/directory"
msgstr ""
+#: ports/nrf/common-hal/bleio/Characteristic.c
#: shared-bindings/bleio/CharacteristicBuffer.c
msgid "Not connected"
msgstr ""
@@ -1171,7 +1156,8 @@ msgstr ""
msgid "Too many channels in sample."
msgstr ""
-#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c
+#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/I2CDisplay.c
+#: shared-bindings/displayio/ParallelBus.c
msgid "Too many display busses"
msgstr ""
@@ -1196,7 +1182,7 @@ msgid "USB Error"
msgstr ""
#: shared-bindings/bleio/UUID.c
-msgid "UUID integer value not in range 0 to 0xffff"
+msgid "UUID integer value must be 0-0xffff"
msgstr ""
#: shared-bindings/bleio/UUID.c
@@ -1212,6 +1198,11 @@ msgstr ""
msgid "Unable to allocate buffers for signed conversion"
msgstr ""
+#: shared-module/displayio/I2CDisplay.c
+#, c-format
+msgid "Unable to find I2C Display at %x"
+msgstr ""
+
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
msgid "Unable to find free GCLK"
@@ -1884,8 +1875,9 @@ msgstr ""
msgid "integer required"
msgstr ""
-#: ports/nrf/common-hal/bleio/Broadcaster.c
-msgid "interval not in range 0.0020 to 10.24"
+#: shared-bindings/bleio/Peripheral.c shared-bindings/bleio/Scanner.c
+#, c-format
+msgid "interval must be in range %s-%s"
msgstr ""
#: extmod/machine_i2c.c
@@ -2099,6 +2091,14 @@ msgstr ""
msgid "no such attribute"
msgstr ""
+#: shared-bindings/bleio/Peripheral.c
+msgid "non-Service found in services"
+msgstr ""
+
+#: ports/nrf/common-hal/bleio/Central.c
+msgid "non-UUID found in service_uuids"
+msgstr ""
+
#: py/compile.c
msgid "non-default argument follows default argument"
msgstr ""
@@ -2307,10 +2307,6 @@ msgstr ""
msgid "script compilation not supported"
msgstr ""
-#: shared-bindings/bleio/Peripheral.c
-msgid "services includes an object that is not a Service"
-msgstr ""
-
#: py/objstr.c
msgid "sign not allowed in string format specifier"
msgstr ""
@@ -2577,6 +2573,10 @@ msgstr ""
msgid "value_count must be > 0"
msgstr ""
+#: shared-bindings/bleio/Scanner.c
+msgid "window must be <= interval"
+msgstr ""
+
#: shared-bindings/_pixelbuf/PixelBuf.c
msgid "write_args must be a list, tuple, or None"
msgstr ""
diff --git a/locale/de_DE.po b/locale/de_DE.po
index 8f36f00d3..748833147 100644
--- a/locale/de_DE.po
+++ b/locale/de_DE.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2019-06-25 17:53-0700\n"
+"POT-Creation-Date: 2019-07-19 16:10-0700\n"
"PO-Revision-Date: 2018-07-27 11:55-0700\n"
"Last-Translator: Pascal Deneaux\n"
"Language-Team: Sebastian Plamauer, Pascal Deneaux\n"
@@ -221,14 +221,13 @@ msgstr "Ein Hardware Interrupt Kanal wird schon benutzt"
#: shared-bindings/bleio/Address.c
#, c-format
-msgid "Address is not %d bytes long or is in wrong format"
-msgstr "Die Adresse ist nicht %d Bytes lang oder das Format ist falsch"
-
-#: shared-bindings/bleio/Address.c
-#, c-format
msgid "Address must be %d bytes long"
msgstr "Die Adresse muss %d Bytes lang sein"
+#: shared-bindings/bleio/Address.c
+msgid "Address type out of range"
+msgstr ""
+
#: ports/nrf/common-hal/busio/I2C.c
msgid "All I2C peripherals are in use"
msgstr "Alle I2C-Peripheriegeräte sind in Benutzung"
@@ -313,6 +312,10 @@ msgstr "Bit depth muss ein Vielfaches von 8 sein."
msgid "Both pins must support hardware interrupts"
msgstr "Beide pins müssen Hardware Interrupts unterstützen"
+#: shared-bindings/displayio/Display.c
+msgid "Brightness must be 0-1.0"
+msgstr ""
+
#: shared-bindings/supervisor/__init__.c
msgid "Brightness must be between 0 and 255"
msgstr "Die Helligkeit muss zwischen 0 und 255 liegen"
@@ -353,21 +356,9 @@ msgstr ""
msgid "Can not use dotstar with %s"
msgstr "Kann dotstar nicht mit %s verwenden"
-#: shared-bindings/bleio/Device.c
-msgid "Can't add services in Central mode"
-msgstr "Im Central mode können Dienste nicht hinzugefügt werden"
-
-#: shared-bindings/bleio/Device.c
-msgid "Can't advertise in Central mode"
-msgstr "Im Central mode kann advertise nicht gemacht werden"
-
-#: shared-bindings/bleio/Device.c
-msgid "Can't change the name in Central mode"
-msgstr "Im Central mode kann name nicht geändert werden"
-
-#: shared-bindings/bleio/Device.c
-msgid "Can't connect in Peripheral mode"
-msgstr "Im Peripheral mode kann keine Verbindung hergestellt werden"
+#: ports/nrf/common-hal/bleio/Characteristic.c
+msgid "Can't set CCCD for local Characteristic"
+msgstr ""
#: shared-bindings/displayio/Bitmap.c shared-bindings/pulseio/PulseIn.c
msgid "Cannot delete values"
@@ -450,6 +441,10 @@ msgstr "Clock unit wird benutzt"
msgid "Column entry must be digitalio.DigitalInOut"
msgstr ""
+#: shared-bindings/displayio/I2CDisplay.c
+msgid "Command must be 0-255"
+msgstr ""
+
#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c
msgid "Command must be an int between 0 and 255"
msgstr "Der Befehl muss ein int zwischen 0 und 255 sein"
@@ -496,15 +491,10 @@ msgstr "Data 0 pin muss am Byte ausgerichtet sein"
msgid "Data chunk must follow fmt chunk"
msgstr ""
-#: ports/nrf/common-hal/bleio/Broadcaster.c
#: ports/nrf/common-hal/bleio/Peripheral.c
msgid "Data too large for advertisement packet"
msgstr "Zu vielen Daten für das advertisement packet"
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Data too large for the advertisement packet"
-msgstr "Daten sind zu groß für das advertisement packet"
-
#: shared-bindings/audiobusio/PDMIn.c
msgid "Destination capacity is smaller than destination_length."
msgstr "Die Zielkapazität ist kleiner als destination_length."
@@ -542,6 +532,10 @@ msgstr "Characteristic wird erwartet"
msgid "Expected a UUID"
msgstr "Eine UUID wird erwartet"
+#: shared-bindings/bleio/Central.c
+msgid "Expected an Address"
+msgstr ""
+
#: shared-module/_pixelbuf/PixelBuf.c
#, c-format
msgid "Expected tuple of length %d, got %d"
@@ -551,11 +545,7 @@ msgstr "Habe ein Tupel der Länge %d erwartet aber %d erhalten"
msgid "Failed sending command."
msgstr ""
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Failed to acquire mutex"
-msgstr "Akquirieren des Mutex gescheitert"
-
-#: ports/nrf/common-hal/bleio/Characteristic.c ports/nrf/sd_mutex.c
+#: ports/nrf/sd_mutex.c
#, c-format
msgid "Failed to acquire mutex, err 0x%04x"
msgstr "Mutex konnte nicht akquiriert werden. Status: 0x%04x"
@@ -565,10 +555,6 @@ msgstr "Mutex konnte nicht akquiriert werden. Status: 0x%04x"
msgid "Failed to add characteristic, err 0x%04x"
msgstr "Hinzufügen des Characteristic ist gescheitert. Status: 0x%04x"
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Failed to add service"
-msgstr "Dienst konnte nicht hinzugefügt werden"
-
#: ports/nrf/common-hal/bleio/Peripheral.c
#, c-format
msgid "Failed to add service, err 0x%04x"
@@ -588,24 +574,21 @@ msgstr "Konnte keine RX Buffer mit %d allozieren"
msgid "Failed to change softdevice state"
msgstr "Fehler beim Ändern des Softdevice-Status"
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Failed to connect:"
-msgstr "Verbindung fehlgeschlagen:"
+#: ports/nrf/common-hal/bleio/Peripheral.c
+#, c-format
+msgid "Failed to configure advertising, err 0x%04x"
+msgstr ""
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Failed to continue scanning"
-msgstr "Der Scanvorgang kann nicht fortgesetzt werden"
+#: ports/nrf/common-hal/bleio/Central.c
+msgid "Failed to connect: timeout"
+msgstr ""
#: ports/nrf/common-hal/bleio/Scanner.c
#, c-format
msgid "Failed to continue scanning, err 0x%04x"
msgstr "Der Scanvorgang kann nicht fortgesetzt werden. Status: 0x%04x"
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Failed to create mutex"
-msgstr "Erstellen des Mutex ist fehlgeschlagen"
-
-#: ports/nrf/common-hal/bleio/Device.c
+#: ports/nrf/common-hal/bleio/Central.c
msgid "Failed to discover services"
msgstr "Es konnten keine Dienste gefunden werden"
@@ -642,39 +625,31 @@ msgstr "gatts value konnte nicht gelesen werden. Status: 0x%04x"
msgid "Failed to register Vendor-Specific UUID, err 0x%04x"
msgstr "Kann keine herstellerspezifische UUID hinzufügen. Status: 0x%04x"
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Failed to release mutex"
-msgstr "Loslassen des Mutex gescheitert"
-
-#: ports/nrf/common-hal/bleio/Characteristic.c ports/nrf/sd_mutex.c
+#: ports/nrf/sd_mutex.c
#, c-format
msgid "Failed to release mutex, err 0x%04x"
msgstr "Mutex konnte nicht freigegeben werden. Status: 0x%04x"
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Failed to start advertising"
-msgstr "Kann advertisement nicht starten"
+#: ports/nrf/common-hal/bleio/Peripheral.c
+#, c-format
+msgid "Failed to set device name, err 0x%04x"
+msgstr ""
-#: ports/nrf/common-hal/bleio/Broadcaster.c
#: ports/nrf/common-hal/bleio/Peripheral.c
#, c-format
msgid "Failed to start advertising, err 0x%04x"
msgstr "Kann advertisement nicht starten. Status: 0x%04x"
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Failed to start scanning"
-msgstr "Der Scanvorgang kann nicht gestartet werden"
+#: ports/nrf/common-hal/bleio/Central.c
+#, c-format
+msgid "Failed to start connecting, error 0x%04x"
+msgstr ""
#: ports/nrf/common-hal/bleio/Scanner.c
#, c-format
msgid "Failed to start scanning, err 0x%04x"
msgstr "Der Scanvorgang kann nicht gestartet werden. Status: 0x%04x"
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Failed to stop advertising"
-msgstr "Kann advertisement nicht stoppen"
-
-#: ports/nrf/common-hal/bleio/Broadcaster.c
#: ports/nrf/common-hal/bleio/Peripheral.c
#, c-format
msgid "Failed to stop advertising, err 0x%04x"
@@ -682,6 +657,11 @@ msgstr "Kann advertisement nicht stoppen. Status: 0x%04x"
#: ports/nrf/common-hal/bleio/Characteristic.c
#, c-format
+msgid "Failed to write CCCD, err 0x%04x"
+msgstr ""
+
+#: ports/nrf/common-hal/bleio/Characteristic.c
+#, c-format
msgid "Failed to write attribute value, err 0x%04x"
msgstr "Kann den Attributwert nicht schreiben. Status: 0x%04x"
@@ -904,6 +884,10 @@ msgstr ""
msgid "Must be a %q subclass."
msgstr ""
+#: ports/nrf/common-hal/bleio/Characteristic.c
+msgid "No CCCD for this Characteristic"
+msgstr ""
+
#: ports/atmel-samd/common-hal/analogio/AnalogOut.c
msgid "No DAC on chip"
msgstr "Kein DAC im Chip vorhanden"
@@ -954,6 +938,7 @@ msgstr "Kein Speicherplatz auf Gerät"
msgid "No such file/directory"
msgstr "Keine solche Datei/Verzeichnis"
+#: ports/nrf/common-hal/bleio/Characteristic.c
#: shared-bindings/bleio/CharacteristicBuffer.c
msgid "Not connected"
msgstr "Nicht verbunden"
@@ -1200,7 +1185,8 @@ msgstr "Zum beenden, resette bitte das board ohne "
msgid "Too many channels in sample."
msgstr "Zu viele Kanäle im sample"
-#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c
+#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/I2CDisplay.c
+#: shared-bindings/displayio/ParallelBus.c
msgid "Too many display busses"
msgstr ""
@@ -1225,8 +1211,8 @@ msgid "USB Error"
msgstr "USB Fehler"
#: shared-bindings/bleio/UUID.c
-msgid "UUID integer value not in range 0 to 0xffff"
-msgstr "UUID-Integer nicht im Bereich 0 bis 0xffff"
+msgid "UUID integer value must be 0-0xffff"
+msgstr ""
#: shared-bindings/bleio/UUID.c
msgid "UUID string not 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'"
@@ -1241,6 +1227,11 @@ msgstr "Der UUID-Wert ist kein str-, int- oder Byte-Puffer"
msgid "Unable to allocate buffers for signed conversion"
msgstr "Konnte keine Buffer für Vorzeichenumwandlung allozieren"
+#: shared-module/displayio/I2CDisplay.c
+#, c-format
+msgid "Unable to find I2C Display at %x"
+msgstr ""
+
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
msgid "Unable to find free GCLK"
@@ -1925,9 +1916,10 @@ msgstr "int() arg 2 muss >= 2 und <= 36 sein"
msgid "integer required"
msgstr "integer erforderlich"
-#: ports/nrf/common-hal/bleio/Broadcaster.c
-msgid "interval not in range 0.0020 to 10.24"
-msgstr "Das Interval ist nicht im Bereich 0.0020 bis 10.24"
+#: shared-bindings/bleio/Peripheral.c shared-bindings/bleio/Scanner.c
+#, c-format
+msgid "interval must be in range %s-%s"
+msgstr ""
#: extmod/machine_i2c.c
msgid "invalid I2C peripheral"
@@ -2146,6 +2138,14 @@ msgstr "Kein Modul mit dem Namen '%q'"
msgid "no such attribute"
msgstr ""
+#: shared-bindings/bleio/Peripheral.c
+msgid "non-Service found in services"
+msgstr ""
+
+#: ports/nrf/common-hal/bleio/Central.c
+msgid "non-UUID found in service_uuids"
+msgstr ""
+
#: py/compile.c
msgid "non-default argument follows default argument"
msgstr "ein non-default argument folgt auf ein default argument"
@@ -2358,10 +2358,6 @@ msgstr "Der schedule stack ist voll"
msgid "script compilation not supported"
msgstr "kompilieren von Skripten ist nicht unterstützt"
-#: shared-bindings/bleio/Peripheral.c
-msgid "services includes an object that is not a Service"
-msgstr ""
-
#: py/objstr.c
msgid "sign not allowed in string format specifier"
msgstr ""
@@ -2633,6 +2629,10 @@ msgstr ""
msgid "value_count must be > 0"
msgstr ""
+#: shared-bindings/bleio/Scanner.c
+msgid "window must be <= interval"
+msgstr ""
+
#: shared-bindings/_pixelbuf/PixelBuf.c
msgid "write_args must be a list, tuple, or None"
msgstr "write_args muss eine Liste, ein Tupel oder None sein"
@@ -2664,9 +2664,24 @@ msgstr ""
#~ msgid "AP required"
#~ msgstr "AP erforderlich"
+#~ msgid "Address is not %d bytes long or is in wrong format"
+#~ msgstr "Die Adresse ist nicht %d Bytes lang oder das Format ist falsch"
+
#~ msgid "C-level assert"
#~ msgstr "C-Level Assert"
+#~ msgid "Can't add services in Central mode"
+#~ msgstr "Im Central mode können Dienste nicht hinzugefügt werden"
+
+#~ msgid "Can't advertise in Central mode"
+#~ msgstr "Im Central mode kann advertise nicht gemacht werden"
+
+#~ msgid "Can't change the name in Central mode"
+#~ msgstr "Im Central mode kann name nicht geändert werden"
+
+#~ msgid "Can't connect in Peripheral mode"
+#~ msgstr "Im Peripheral mode kann keine Verbindung hergestellt werden"
+
#~ msgid "Cannot connect to AP"
#~ msgstr "Kann nicht zu AP verbinden"
@@ -2679,6 +2694,9 @@ msgstr ""
#~ msgid "Cannot update i/f status"
#~ msgstr "Kann i/f Status nicht updaten"
+#~ msgid "Data too large for the advertisement packet"
+#~ msgstr "Daten sind zu groß für das advertisement packet"
+
#~ msgid "Don't know how to pass object to native function"
#~ msgstr ""
#~ "Ich weiß nicht, wie man das Objekt an die native Funktion übergeben kann"
@@ -2692,12 +2710,39 @@ msgstr ""
#~ msgid "Error in ffi_prep_cif"
#~ msgstr "Fehler in ffi_prep_cif"
+#~ msgid "Failed to acquire mutex"
+#~ msgstr "Akquirieren des Mutex gescheitert"
+
+#~ msgid "Failed to add service"
+#~ msgstr "Dienst konnte nicht hinzugefügt werden"
+
+#~ msgid "Failed to connect:"
+#~ msgstr "Verbindung fehlgeschlagen:"
+
+#~ msgid "Failed to continue scanning"
+#~ msgstr "Der Scanvorgang kann nicht fortgesetzt werden"
+
+#~ msgid "Failed to create mutex"
+#~ msgstr "Erstellen des Mutex ist fehlgeschlagen"
+
#~ msgid "Failed to notify or indicate attribute value, err %0x04x"
#~ msgstr "Kann den Attributwert nicht mitteilen. Status: 0x%04x"
#~ msgid "Failed to read attribute value, err %0x04x"
#~ msgstr "Kann den Attributwert nicht lesen. Status: 0x%04x"
+#~ msgid "Failed to release mutex"
+#~ msgstr "Loslassen des Mutex gescheitert"
+
+#~ msgid "Failed to start advertising"
+#~ msgstr "Kann advertisement nicht starten"
+
+#~ msgid "Failed to start scanning"
+#~ msgstr "Der Scanvorgang kann nicht gestartet werden"
+
+#~ msgid "Failed to stop advertising"
+#~ msgstr "Kann advertisement nicht stoppen"
+
#~ msgid "Function requires lock."
#~ msgstr ""
#~ "Die Funktion erwartet, dass der 'lock'-Befehl zuvor ausgeführt wurde"
@@ -2769,6 +2814,9 @@ msgstr ""
#~ msgid "UART(1) can't read"
#~ msgstr "UART(1) kann nicht lesen"
+#~ msgid "UUID integer value not in range 0 to 0xffff"
+#~ msgstr "UUID-Integer nicht im Bereich 0 bis 0xffff"
+
#~ msgid "Unable to remount filesystem"
#~ msgstr "Dateisystem konnte nicht wieder eingebunden werden."
@@ -2800,6 +2848,9 @@ msgstr ""
#~ msgid "impossible baudrate"
#~ msgstr "Unmögliche Baudrate"
+#~ msgid "interval not in range 0.0020 to 10.24"
+#~ msgstr "Das Interval ist nicht im Bereich 0.0020 bis 10.24"
+
#~ msgid "invalid alarm"
#~ msgstr "ungültiger Alarm"
diff --git a/locale/en_US.po b/locale/en_US.po
index caea41f6b..38074de98 100644
--- a/locale/en_US.po
+++ b/locale/en_US.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2019-06-25 17:53-0700\n"
+"POT-Creation-Date: 2019-07-19 16:10-0700\n"
"PO-Revision-Date: 2018-07-27 11:55-0700\n"
"Last-Translator: \n"
"Language-Team: \n"
@@ -219,12 +219,11 @@ msgstr ""
#: shared-bindings/bleio/Address.c
#, c-format
-msgid "Address is not %d bytes long or is in wrong format"
+msgid "Address must be %d bytes long"
msgstr ""
#: shared-bindings/bleio/Address.c
-#, c-format
-msgid "Address must be %d bytes long"
+msgid "Address type out of range"
msgstr ""
#: ports/nrf/common-hal/busio/I2C.c
@@ -309,6 +308,10 @@ msgstr ""
msgid "Both pins must support hardware interrupts"
msgstr ""
+#: shared-bindings/displayio/Display.c
+msgid "Brightness must be 0-1.0"
+msgstr ""
+
#: shared-bindings/supervisor/__init__.c
msgid "Brightness must be between 0 and 255"
msgstr ""
@@ -349,20 +352,8 @@ msgstr ""
msgid "Can not use dotstar with %s"
msgstr ""
-#: shared-bindings/bleio/Device.c
-msgid "Can't add services in Central mode"
-msgstr ""
-
-#: shared-bindings/bleio/Device.c
-msgid "Can't advertise in Central mode"
-msgstr ""
-
-#: shared-bindings/bleio/Device.c
-msgid "Can't change the name in Central mode"
-msgstr ""
-
-#: shared-bindings/bleio/Device.c
-msgid "Can't connect in Peripheral mode"
+#: ports/nrf/common-hal/bleio/Characteristic.c
+msgid "Can't set CCCD for local Characteristic"
msgstr ""
#: shared-bindings/displayio/Bitmap.c shared-bindings/pulseio/PulseIn.c
@@ -446,6 +437,10 @@ msgstr ""
msgid "Column entry must be digitalio.DigitalInOut"
msgstr ""
+#: shared-bindings/displayio/I2CDisplay.c
+msgid "Command must be 0-255"
+msgstr ""
+
#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c
msgid "Command must be an int between 0 and 255"
msgstr ""
@@ -492,15 +487,10 @@ msgstr ""
msgid "Data chunk must follow fmt chunk"
msgstr ""
-#: ports/nrf/common-hal/bleio/Broadcaster.c
#: ports/nrf/common-hal/bleio/Peripheral.c
msgid "Data too large for advertisement packet"
msgstr ""
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Data too large for the advertisement packet"
-msgstr ""
-
#: shared-bindings/audiobusio/PDMIn.c
msgid "Destination capacity is smaller than destination_length."
msgstr ""
@@ -538,6 +528,10 @@ msgstr ""
msgid "Expected a UUID"
msgstr ""
+#: shared-bindings/bleio/Central.c
+msgid "Expected an Address"
+msgstr ""
+
#: shared-module/_pixelbuf/PixelBuf.c
#, c-format
msgid "Expected tuple of length %d, got %d"
@@ -547,11 +541,7 @@ msgstr ""
msgid "Failed sending command."
msgstr ""
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Failed to acquire mutex"
-msgstr ""
-
-#: ports/nrf/common-hal/bleio/Characteristic.c ports/nrf/sd_mutex.c
+#: ports/nrf/sd_mutex.c
#, c-format
msgid "Failed to acquire mutex, err 0x%04x"
msgstr ""
@@ -561,10 +551,6 @@ msgstr ""
msgid "Failed to add characteristic, err 0x%04x"
msgstr ""
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Failed to add service"
-msgstr ""
-
#: ports/nrf/common-hal/bleio/Peripheral.c
#, c-format
msgid "Failed to add service, err 0x%04x"
@@ -584,12 +570,13 @@ msgstr ""
msgid "Failed to change softdevice state"
msgstr ""
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Failed to connect:"
+#: ports/nrf/common-hal/bleio/Peripheral.c
+#, c-format
+msgid "Failed to configure advertising, err 0x%04x"
msgstr ""
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Failed to continue scanning"
+#: ports/nrf/common-hal/bleio/Central.c
+msgid "Failed to connect: timeout"
msgstr ""
#: ports/nrf/common-hal/bleio/Scanner.c
@@ -597,11 +584,7 @@ msgstr ""
msgid "Failed to continue scanning, err 0x%04x"
msgstr ""
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Failed to create mutex"
-msgstr ""
-
-#: ports/nrf/common-hal/bleio/Device.c
+#: ports/nrf/common-hal/bleio/Central.c
msgid "Failed to discover services"
msgstr ""
@@ -638,27 +621,24 @@ msgstr ""
msgid "Failed to register Vendor-Specific UUID, err 0x%04x"
msgstr ""
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Failed to release mutex"
-msgstr ""
-
-#: ports/nrf/common-hal/bleio/Characteristic.c ports/nrf/sd_mutex.c
+#: ports/nrf/sd_mutex.c
#, c-format
msgid "Failed to release mutex, err 0x%04x"
msgstr ""
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Failed to start advertising"
+#: ports/nrf/common-hal/bleio/Peripheral.c
+#, c-format
+msgid "Failed to set device name, err 0x%04x"
msgstr ""
-#: ports/nrf/common-hal/bleio/Broadcaster.c
#: ports/nrf/common-hal/bleio/Peripheral.c
#, c-format
msgid "Failed to start advertising, err 0x%04x"
msgstr ""
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Failed to start scanning"
+#: ports/nrf/common-hal/bleio/Central.c
+#, c-format
+msgid "Failed to start connecting, error 0x%04x"
msgstr ""
#: ports/nrf/common-hal/bleio/Scanner.c
@@ -666,11 +646,6 @@ msgstr ""
msgid "Failed to start scanning, err 0x%04x"
msgstr ""
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Failed to stop advertising"
-msgstr ""
-
-#: ports/nrf/common-hal/bleio/Broadcaster.c
#: ports/nrf/common-hal/bleio/Peripheral.c
#, c-format
msgid "Failed to stop advertising, err 0x%04x"
@@ -678,6 +653,11 @@ msgstr ""
#: ports/nrf/common-hal/bleio/Characteristic.c
#, c-format
+msgid "Failed to write CCCD, err 0x%04x"
+msgstr ""
+
+#: ports/nrf/common-hal/bleio/Characteristic.c
+#, c-format
msgid "Failed to write attribute value, err 0x%04x"
msgstr ""
@@ -891,6 +871,10 @@ msgstr ""
msgid "Must be a %q subclass."
msgstr ""
+#: ports/nrf/common-hal/bleio/Characteristic.c
+msgid "No CCCD for this Characteristic"
+msgstr ""
+
#: ports/atmel-samd/common-hal/analogio/AnalogOut.c
msgid "No DAC on chip"
msgstr ""
@@ -941,6 +925,7 @@ msgstr ""
msgid "No such file/directory"
msgstr ""
+#: ports/nrf/common-hal/bleio/Characteristic.c
#: shared-bindings/bleio/CharacteristicBuffer.c
msgid "Not connected"
msgstr ""
@@ -1171,7 +1156,8 @@ msgstr ""
msgid "Too many channels in sample."
msgstr ""
-#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c
+#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/I2CDisplay.c
+#: shared-bindings/displayio/ParallelBus.c
msgid "Too many display busses"
msgstr ""
@@ -1196,7 +1182,7 @@ msgid "USB Error"
msgstr ""
#: shared-bindings/bleio/UUID.c
-msgid "UUID integer value not in range 0 to 0xffff"
+msgid "UUID integer value must be 0-0xffff"
msgstr ""
#: shared-bindings/bleio/UUID.c
@@ -1212,6 +1198,11 @@ msgstr ""
msgid "Unable to allocate buffers for signed conversion"
msgstr ""
+#: shared-module/displayio/I2CDisplay.c
+#, c-format
+msgid "Unable to find I2C Display at %x"
+msgstr ""
+
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
msgid "Unable to find free GCLK"
@@ -1884,8 +1875,9 @@ msgstr ""
msgid "integer required"
msgstr ""
-#: ports/nrf/common-hal/bleio/Broadcaster.c
-msgid "interval not in range 0.0020 to 10.24"
+#: shared-bindings/bleio/Peripheral.c shared-bindings/bleio/Scanner.c
+#, c-format
+msgid "interval must be in range %s-%s"
msgstr ""
#: extmod/machine_i2c.c
@@ -2099,6 +2091,14 @@ msgstr ""
msgid "no such attribute"
msgstr ""
+#: shared-bindings/bleio/Peripheral.c
+msgid "non-Service found in services"
+msgstr ""
+
+#: ports/nrf/common-hal/bleio/Central.c
+msgid "non-UUID found in service_uuids"
+msgstr ""
+
#: py/compile.c
msgid "non-default argument follows default argument"
msgstr ""
@@ -2307,10 +2307,6 @@ msgstr ""
msgid "script compilation not supported"
msgstr ""
-#: shared-bindings/bleio/Peripheral.c
-msgid "services includes an object that is not a Service"
-msgstr ""
-
#: py/objstr.c
msgid "sign not allowed in string format specifier"
msgstr ""
@@ -2577,6 +2573,10 @@ msgstr ""
msgid "value_count must be > 0"
msgstr ""
+#: shared-bindings/bleio/Scanner.c
+msgid "window must be <= interval"
+msgstr ""
+
#: shared-bindings/_pixelbuf/PixelBuf.c
msgid "write_args must be a list, tuple, or None"
msgstr ""
diff --git a/locale/en_x_pirate.po b/locale/en_x_pirate.po
index f751e86dd..9bee12d2a 100644
--- a/locale/en_x_pirate.po
+++ b/locale/en_x_pirate.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2019-06-25 17:53-0700\n"
+"POT-Creation-Date: 2019-07-19 16:10-0700\n"
"PO-Revision-Date: 2018-07-27 11:55-0700\n"
"Last-Translator: \n"
"Language-Team: @sommersoft, @MrCertainly\n"
@@ -221,12 +221,11 @@ msgstr "Avast! A hardware interrupt channel be used already"
#: shared-bindings/bleio/Address.c
#, c-format
-msgid "Address is not %d bytes long or is in wrong format"
+msgid "Address must be %d bytes long"
msgstr ""
#: shared-bindings/bleio/Address.c
-#, c-format
-msgid "Address must be %d bytes long"
+msgid "Address type out of range"
msgstr ""
#: ports/nrf/common-hal/busio/I2C.c
@@ -313,6 +312,10 @@ msgstr ""
msgid "Both pins must support hardware interrupts"
msgstr ""
+#: shared-bindings/displayio/Display.c
+msgid "Brightness must be 0-1.0"
+msgstr ""
+
#: shared-bindings/supervisor/__init__.c
msgid "Brightness must be between 0 and 255"
msgstr ""
@@ -353,20 +356,8 @@ msgstr ""
msgid "Can not use dotstar with %s"
msgstr ""
-#: shared-bindings/bleio/Device.c
-msgid "Can't add services in Central mode"
-msgstr ""
-
-#: shared-bindings/bleio/Device.c
-msgid "Can't advertise in Central mode"
-msgstr ""
-
-#: shared-bindings/bleio/Device.c
-msgid "Can't change the name in Central mode"
-msgstr ""
-
-#: shared-bindings/bleio/Device.c
-msgid "Can't connect in Peripheral mode"
+#: ports/nrf/common-hal/bleio/Characteristic.c
+msgid "Can't set CCCD for local Characteristic"
msgstr ""
#: shared-bindings/displayio/Bitmap.c shared-bindings/pulseio/PulseIn.c
@@ -450,6 +441,10 @@ msgstr ""
msgid "Column entry must be digitalio.DigitalInOut"
msgstr ""
+#: shared-bindings/displayio/I2CDisplay.c
+msgid "Command must be 0-255"
+msgstr ""
+
#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c
msgid "Command must be an int between 0 and 255"
msgstr ""
@@ -496,15 +491,10 @@ msgstr ""
msgid "Data chunk must follow fmt chunk"
msgstr ""
-#: ports/nrf/common-hal/bleio/Broadcaster.c
#: ports/nrf/common-hal/bleio/Peripheral.c
msgid "Data too large for advertisement packet"
msgstr ""
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Data too large for the advertisement packet"
-msgstr ""
-
#: shared-bindings/audiobusio/PDMIn.c
msgid "Destination capacity is smaller than destination_length."
msgstr ""
@@ -542,6 +532,10 @@ msgstr ""
msgid "Expected a UUID"
msgstr ""
+#: shared-bindings/bleio/Central.c
+msgid "Expected an Address"
+msgstr ""
+
#: shared-module/_pixelbuf/PixelBuf.c
#, c-format
msgid "Expected tuple of length %d, got %d"
@@ -551,11 +545,7 @@ msgstr ""
msgid "Failed sending command."
msgstr ""
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Failed to acquire mutex"
-msgstr ""
-
-#: ports/nrf/common-hal/bleio/Characteristic.c ports/nrf/sd_mutex.c
+#: ports/nrf/sd_mutex.c
#, c-format
msgid "Failed to acquire mutex, err 0x%04x"
msgstr ""
@@ -565,10 +555,6 @@ msgstr ""
msgid "Failed to add characteristic, err 0x%04x"
msgstr ""
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Failed to add service"
-msgstr ""
-
#: ports/nrf/common-hal/bleio/Peripheral.c
#, c-format
msgid "Failed to add service, err 0x%04x"
@@ -588,12 +574,13 @@ msgstr ""
msgid "Failed to change softdevice state"
msgstr ""
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Failed to connect:"
+#: ports/nrf/common-hal/bleio/Peripheral.c
+#, c-format
+msgid "Failed to configure advertising, err 0x%04x"
msgstr ""
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Failed to continue scanning"
+#: ports/nrf/common-hal/bleio/Central.c
+msgid "Failed to connect: timeout"
msgstr ""
#: ports/nrf/common-hal/bleio/Scanner.c
@@ -601,11 +588,7 @@ msgstr ""
msgid "Failed to continue scanning, err 0x%04x"
msgstr ""
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Failed to create mutex"
-msgstr ""
-
-#: ports/nrf/common-hal/bleio/Device.c
+#: ports/nrf/common-hal/bleio/Central.c
msgid "Failed to discover services"
msgstr ""
@@ -642,27 +625,24 @@ msgstr ""
msgid "Failed to register Vendor-Specific UUID, err 0x%04x"
msgstr ""
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Failed to release mutex"
-msgstr ""
-
-#: ports/nrf/common-hal/bleio/Characteristic.c ports/nrf/sd_mutex.c
+#: ports/nrf/sd_mutex.c
#, c-format
msgid "Failed to release mutex, err 0x%04x"
msgstr ""
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Failed to start advertising"
+#: ports/nrf/common-hal/bleio/Peripheral.c
+#, c-format
+msgid "Failed to set device name, err 0x%04x"
msgstr ""
-#: ports/nrf/common-hal/bleio/Broadcaster.c
#: ports/nrf/common-hal/bleio/Peripheral.c
#, c-format
msgid "Failed to start advertising, err 0x%04x"
msgstr ""
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Failed to start scanning"
+#: ports/nrf/common-hal/bleio/Central.c
+#, c-format
+msgid "Failed to start connecting, error 0x%04x"
msgstr ""
#: ports/nrf/common-hal/bleio/Scanner.c
@@ -670,11 +650,6 @@ msgstr ""
msgid "Failed to start scanning, err 0x%04x"
msgstr ""
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Failed to stop advertising"
-msgstr ""
-
-#: ports/nrf/common-hal/bleio/Broadcaster.c
#: ports/nrf/common-hal/bleio/Peripheral.c
#, c-format
msgid "Failed to stop advertising, err 0x%04x"
@@ -682,6 +657,11 @@ msgstr ""
#: ports/nrf/common-hal/bleio/Characteristic.c
#, c-format
+msgid "Failed to write CCCD, err 0x%04x"
+msgstr ""
+
+#: ports/nrf/common-hal/bleio/Characteristic.c
+#, c-format
msgid "Failed to write attribute value, err 0x%04x"
msgstr ""
@@ -895,6 +875,10 @@ msgstr ""
msgid "Must be a %q subclass."
msgstr ""
+#: ports/nrf/common-hal/bleio/Characteristic.c
+msgid "No CCCD for this Characteristic"
+msgstr ""
+
#: ports/atmel-samd/common-hal/analogio/AnalogOut.c
msgid "No DAC on chip"
msgstr "Shiver me timbers! There be no DAC on this chip"
@@ -945,6 +929,7 @@ msgstr ""
msgid "No such file/directory"
msgstr ""
+#: ports/nrf/common-hal/bleio/Characteristic.c
#: shared-bindings/bleio/CharacteristicBuffer.c
msgid "Not connected"
msgstr ""
@@ -1175,7 +1160,8 @@ msgstr ""
msgid "Too many channels in sample."
msgstr ""
-#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c
+#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/I2CDisplay.c
+#: shared-bindings/displayio/ParallelBus.c
msgid "Too many display busses"
msgstr ""
@@ -1200,7 +1186,7 @@ msgid "USB Error"
msgstr ""
#: shared-bindings/bleio/UUID.c
-msgid "UUID integer value not in range 0 to 0xffff"
+msgid "UUID integer value must be 0-0xffff"
msgstr ""
#: shared-bindings/bleio/UUID.c
@@ -1216,6 +1202,11 @@ msgstr ""
msgid "Unable to allocate buffers for signed conversion"
msgstr ""
+#: shared-module/displayio/I2CDisplay.c
+#, c-format
+msgid "Unable to find I2C Display at %x"
+msgstr ""
+
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
msgid "Unable to find free GCLK"
@@ -1888,8 +1879,9 @@ msgstr ""
msgid "integer required"
msgstr ""
-#: ports/nrf/common-hal/bleio/Broadcaster.c
-msgid "interval not in range 0.0020 to 10.24"
+#: shared-bindings/bleio/Peripheral.c shared-bindings/bleio/Scanner.c
+#, c-format
+msgid "interval must be in range %s-%s"
msgstr ""
#: extmod/machine_i2c.c
@@ -2103,6 +2095,14 @@ msgstr ""
msgid "no such attribute"
msgstr ""
+#: shared-bindings/bleio/Peripheral.c
+msgid "non-Service found in services"
+msgstr ""
+
+#: ports/nrf/common-hal/bleio/Central.c
+msgid "non-UUID found in service_uuids"
+msgstr ""
+
#: py/compile.c
msgid "non-default argument follows default argument"
msgstr ""
@@ -2311,10 +2311,6 @@ msgstr ""
msgid "script compilation not supported"
msgstr ""
-#: shared-bindings/bleio/Peripheral.c
-msgid "services includes an object that is not a Service"
-msgstr ""
-
#: py/objstr.c
msgid "sign not allowed in string format specifier"
msgstr ""
@@ -2581,6 +2577,10 @@ msgstr ""
msgid "value_count must be > 0"
msgstr ""
+#: shared-bindings/bleio/Scanner.c
+msgid "window must be <= interval"
+msgstr ""
+
#: shared-bindings/_pixelbuf/PixelBuf.c
msgid "write_args must be a list, tuple, or None"
msgstr ""
diff --git a/locale/es.po b/locale/es.po
index d03a308cf..33cdfe348 100644
--- a/locale/es.po
+++ b/locale/es.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2019-06-25 17:53-0700\n"
+"POT-Creation-Date: 2019-07-19 16:10-0700\n"
"PO-Revision-Date: 2018-08-24 22:56-0500\n"
"Last-Translator: \n"
"Language-Team: \n"
@@ -221,14 +221,13 @@ msgstr "El canal EXTINT ya está siendo utilizado"
#: shared-bindings/bleio/Address.c
#, c-format
-msgid "Address is not %d bytes long or is in wrong format"
-msgstr "Direción no es %d bytes de largo o esta en el formato incorrecto"
-
-#: shared-bindings/bleio/Address.c
-#, c-format
msgid "Address must be %d bytes long"
msgstr "La dirección debe ser %d bytes de largo"
+#: shared-bindings/bleio/Address.c
+msgid "Address type out of range"
+msgstr ""
+
#: ports/nrf/common-hal/busio/I2C.c
msgid "All I2C peripherals are in use"
msgstr "Todos los periféricos I2C están siendo usados"
@@ -247,7 +246,9 @@ msgstr "Todos los canales de eventos estan siendo usados"
#: ports/atmel-samd/audio_dma.c ports/atmel-samd/common-hal/audiobusio/PDMIn.c
msgid "All sync event channels in use"
-msgstr "Todos los canales de eventos de sincronización (sync event channels) están siendo utilizados"
+msgstr ""
+"Todos los canales de eventos de sincronización (sync event channels) están "
+"siendo utilizados"
#: shared-bindings/pulseio/PWMOut.c
msgid "All timers for this pin are in use"
@@ -287,7 +288,9 @@ msgstr "Valores del array deben ser bytes individuales."
#: supervisor/shared/safe_mode.c
msgid "Attempted heap allocation when MicroPython VM not running.\n"
-msgstr "Intento de allocation de heap cuando la VM de MicroPython no estaba corriendo.\n"
+msgstr ""
+"Intento de allocation de heap cuando la VM de MicroPython no estaba "
+"corriendo.\n"
#: main.c
msgid "Auto-reload is off.\n"
@@ -297,7 +300,9 @@ msgstr "Auto-recarga deshabilitada.\n"
msgid ""
"Auto-reload is on. Simply save files over USB to run them or enter REPL to "
"disable.\n"
-msgstr "Auto-reload habilitado. Simplemente guarda los archivos via USB para ejecutarlos o entra al REPL para desabilitarlos.\n"
+msgstr ""
+"Auto-reload habilitado. Simplemente guarda los archivos via USB para "
+"ejecutarlos o entra al REPL para desabilitarlos.\n"
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
msgid "Bit clock and word select must share a clock unit"
@@ -311,6 +316,10 @@ msgstr "Bits depth debe ser múltiplo de 8."
msgid "Both pins must support hardware interrupts"
msgstr "Ambos pines deben soportar interrupciones por hardware"
+#: shared-bindings/displayio/Display.c
+msgid "Brightness must be 0-1.0"
+msgstr ""
+
#: shared-bindings/supervisor/__init__.c
msgid "Brightness must be between 0 and 255"
msgstr "El brillo debe estar entro 0 y 255"
@@ -351,21 +360,9 @@ msgstr ""
msgid "Can not use dotstar with %s"
msgstr "No se puede usar dotstar con %s"
-#: shared-bindings/bleio/Device.c
-msgid "Can't add services in Central mode"
-msgstr "No se pueden agregar servicio en modo Central"
-
-#: shared-bindings/bleio/Device.c
-msgid "Can't advertise in Central mode"
-msgstr "No puede anunciarse en Central mode"
-
-#: shared-bindings/bleio/Device.c
-msgid "Can't change the name in Central mode"
-msgstr "No se puede cambiar el nombre en modo Central"
-
-#: shared-bindings/bleio/Device.c
-msgid "Can't connect in Peripheral mode"
-msgstr "No se puede conectar en modo Peripheral"
+#: ports/nrf/common-hal/bleio/Characteristic.c
+msgid "Can't set CCCD for local Characteristic"
+msgstr ""
#: shared-bindings/displayio/Bitmap.c shared-bindings/pulseio/PulseIn.c
msgid "Cannot delete values"
@@ -448,6 +445,10 @@ msgstr "Clock unit está siendo utilizado"
msgid "Column entry must be digitalio.DigitalInOut"
msgstr "Entrada de columna debe ser digitalio.DigitalInOut"
+#: shared-bindings/displayio/I2CDisplay.c
+msgid "Command must be 0-255"
+msgstr ""
+
#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c
msgid "Command must be an int between 0 and 255"
msgstr "Command debe estar entre 0 y 255."
@@ -494,15 +495,10 @@ msgstr "El pin Data 0 debe estar alineado a bytes"
msgid "Data chunk must follow fmt chunk"
msgstr "Trozo de datos debe seguir fmt chunk"
-#: ports/nrf/common-hal/bleio/Broadcaster.c
#: ports/nrf/common-hal/bleio/Peripheral.c
msgid "Data too large for advertisement packet"
msgstr "Data es muy grande para el paquete de advertisement."
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Data too large for the advertisement packet"
-msgstr "Data es muy grande para el paquete de advertisement."
-
#: shared-bindings/audiobusio/PDMIn.c
msgid "Destination capacity is smaller than destination_length."
msgstr "Capacidad de destino es mas pequeña que destination_length."
@@ -540,6 +536,10 @@ msgstr "Se esperaba una Característica."
msgid "Expected a UUID"
msgstr "Se esperaba un UUID"
+#: shared-bindings/bleio/Central.c
+msgid "Expected an Address"
+msgstr ""
+
#: shared-module/_pixelbuf/PixelBuf.c
#, c-format
msgid "Expected tuple of length %d, got %d"
@@ -549,24 +549,16 @@ msgstr "Se esperaba un tuple de %d, se obtuvo %d"
msgid "Failed sending command."
msgstr "Fallo enviando comando"
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Failed to acquire mutex"
-msgstr "Fallo al adquirir el mutex"
-
-#: ports/nrf/common-hal/bleio/Characteristic.c ports/nrf/sd_mutex.c
-#, c-format
+#: ports/nrf/sd_mutex.c
+#, fuzzy, c-format
msgid "Failed to acquire mutex, err 0x%04x"
-msgstr "Fallo al adquirir el mutex, err: 0x%08lX"
+msgstr "No se puede adquirir el mutex, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Service.c
-#, c-format
+#, fuzzy, c-format
msgid "Failed to add characteristic, err 0x%04x"
msgstr "Fallo al añadir caracteristica, err: 0x%08lX"
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Failed to add service"
-msgstr "Fallo al agregar servicio"
-
#: ports/nrf/common-hal/bleio/Peripheral.c
#, c-format
msgid "Failed to add service, err 0x%04x"
@@ -586,24 +578,22 @@ msgstr "Falló la asignación del buffer RX de %d bytes"
msgid "Failed to change softdevice state"
msgstr "No se puede cambiar el estado del softdevice"
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Failed to connect:"
-msgstr "No se puede conectar:"
+#: ports/nrf/common-hal/bleio/Peripheral.c
+#, c-format
+msgid "Failed to configure advertising, err 0x%04x"
+msgstr ""
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Failed to continue scanning"
-msgstr "No se puede iniciar el escaneo."
+#: ports/nrf/common-hal/bleio/Central.c
+msgid "Failed to connect: timeout"
+msgstr ""
#: ports/nrf/common-hal/bleio/Scanner.c
#, c-format
msgid "Failed to continue scanning, err 0x%04x"
msgstr "No se puede iniciar el escaneo. err: 0x%02x"
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Failed to create mutex"
-msgstr "Fallo al crear mutex"
-
-#: ports/nrf/common-hal/bleio/Device.c
+#: ports/nrf/common-hal/bleio/Central.c
+#, fuzzy
msgid "Failed to discover services"
msgstr "No se puede descubrir servicios"
@@ -640,39 +630,31 @@ msgstr "No se puede escribir el valor del atributo. status: 0x%02x"
msgid "Failed to register Vendor-Specific UUID, err 0x%04x"
msgstr "Fallo al registrar el Vendor-Specific UUID, err 0x%04x"
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Failed to release mutex"
-msgstr "No se puede liberar el mutex, status: 0x%08lX"
-
-#: ports/nrf/common-hal/bleio/Characteristic.c ports/nrf/sd_mutex.c
+#: ports/nrf/sd_mutex.c
#, c-format
msgid "Failed to release mutex, err 0x%04x"
msgstr "No se puede liberar el mutex, err 0x%04x"
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Failed to start advertising"
-msgstr "No se puede inicar el anuncio"
+#: ports/nrf/common-hal/bleio/Peripheral.c
+#, c-format
+msgid "Failed to set device name, err 0x%04x"
+msgstr ""
-#: ports/nrf/common-hal/bleio/Broadcaster.c
#: ports/nrf/common-hal/bleio/Peripheral.c
#, c-format
msgid "Failed to start advertising, err 0x%04x"
msgstr "No se puede inicar el anuncio. err: 0x%04x"
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Failed to start scanning"
-msgstr "No se puede iniciar el escaneo"
+#: ports/nrf/common-hal/bleio/Central.c
+#, c-format
+msgid "Failed to start connecting, error 0x%04x"
+msgstr ""
#: ports/nrf/common-hal/bleio/Scanner.c
#, c-format
msgid "Failed to start scanning, err 0x%04x"
msgstr "No se puede iniciar el escaneo. err 0x%04x"
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Failed to stop advertising"
-msgstr "No se puede detener el anuncio"
-
-#: ports/nrf/common-hal/bleio/Broadcaster.c
#: ports/nrf/common-hal/bleio/Peripheral.c
#, c-format
msgid "Failed to stop advertising, err 0x%04x"
@@ -680,6 +662,11 @@ msgstr "No se puede detener el anuncio. err: 0x%04x"
#: ports/nrf/common-hal/bleio/Characteristic.c
#, c-format
+msgid "Failed to write CCCD, err 0x%04x"
+msgstr ""
+
+#: ports/nrf/common-hal/bleio/Characteristic.c
+#, c-format
msgid "Failed to write attribute value, err 0x%04x"
msgstr "No se puede escribir el valor del atributo. err: 0x%04x"
@@ -735,7 +722,9 @@ msgstr "operación I2C no soportada"
msgid ""
"Incompatible .mpy file. Please update all .mpy files. See http://adafru.it/"
"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"
+msgstr ""
+"Archivo .mpy incompatible. Actualice todos los archivos .mpy. Consulte "
+"http://adafru.it/mpy-update para más información"
#: shared-bindings/_pew/PewPew.c
msgid "Incorrect buffer size"
@@ -897,6 +886,10 @@ msgstr "Micrófono demora de inicio debe estar en el rango 0.0 a 1.0"
msgid "Must be a %q subclass."
msgstr "Debe de ser una subclase de %q"
+#: ports/nrf/common-hal/bleio/Characteristic.c
+msgid "No CCCD for this Characteristic"
+msgstr ""
+
#: ports/atmel-samd/common-hal/analogio/AnalogOut.c
msgid "No DAC on chip"
msgstr "El chip no tiene DAC"
@@ -947,6 +940,7 @@ msgstr "No queda espacio en el dispositivo"
msgid "No such file/directory"
msgstr "No existe el archivo/directorio"
+#: ports/nrf/common-hal/bleio/Characteristic.c
#: shared-bindings/bleio/CharacteristicBuffer.c
msgid "Not connected"
msgstr "No conectado"
@@ -959,7 +953,8 @@ msgstr "No reproduciendo"
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"
+"El objeto se ha desinicializado y ya no se puede utilizar. Crea un nuevo "
+"objeto"
#: ports/nrf/common-hal/busio/UART.c
msgid "Odd parity is not supported"
@@ -1201,7 +1196,8 @@ msgstr "Para salir, por favor reinicia la tarjeta sin "
msgid "Too many channels in sample."
msgstr "Demasiados canales en sample."
-#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c
+#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/I2CDisplay.c
+#: shared-bindings/displayio/ParallelBus.c
msgid "Too many display busses"
msgstr "Demasiados buses de pantalla"
@@ -1226,8 +1222,8 @@ msgid "USB Error"
msgstr "Error USB"
#: shared-bindings/bleio/UUID.c
-msgid "UUID integer value not in range 0 to 0xffff"
-msgstr "UUID integer valor no es en el distancia de 0 a 0xffff"
+msgid "UUID integer value must be 0-0xffff"
+msgstr ""
#: shared-bindings/bleio/UUID.c
msgid "UUID string not 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'"
@@ -1242,6 +1238,11 @@ msgstr "UUID valor no es un str, int o byte buffer"
msgid "Unable to allocate buffers for signed conversion"
msgstr "No se pudieron asignar buffers para la conversión con signo"
+#: shared-module/displayio/I2CDisplay.c
+#, c-format
+msgid "Unable to find I2C Display at %x"
+msgstr ""
+
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
msgid "Unable to find free GCLK"
@@ -1370,8 +1371,8 @@ msgstr "argumento es una secuencia vacía"
msgid "argument has wrong type"
msgstr "el argumento tiene un tipo erroneo"
-#: py/argcheck.c shared-bindings/digitalio/DigitalInOut.c
-#: shared-bindings/gamepad/GamePad.c shared-bindings/_stage/__init__.c
+#: py/argcheck.c shared-bindings/_stage/__init__.c
+#: shared-bindings/digitalio/DigitalInOut.c shared-bindings/gamepad/GamePad.c
msgid "argument num/types mismatch"
msgstr "argumento número/tipos no coinciden"
@@ -1930,9 +1931,10 @@ msgstr "int() arg 2 debe ser >= 2 y <= 36"
msgid "integer required"
msgstr "Entero requerido"
-#: ports/nrf/common-hal/bleio/Broadcaster.c
-msgid "interval not in range 0.0020 to 10.24"
-msgstr "interval no estan en el rango 0.0020 a 10.24"
+#: shared-bindings/bleio/Peripheral.c shared-bindings/bleio/Scanner.c
+#, c-format
+msgid "interval must be in range %s-%s"
+msgstr ""
#: extmod/machine_i2c.c
msgid "invalid I2C peripheral"
@@ -2148,6 +2150,14 @@ msgstr "ningún módulo se llama '%q'"
msgid "no such attribute"
msgstr "no hay tal atributo"
+#: shared-bindings/bleio/Peripheral.c
+msgid "non-Service found in services"
+msgstr ""
+
+#: ports/nrf/common-hal/bleio/Central.c
+msgid "non-UUID found in service_uuids"
+msgstr ""
+
#: py/compile.c
msgid "non-default argument follows default argument"
msgstr "argumento no predeterminado sigue argumento predeterminado"
@@ -2363,10 +2373,6 @@ msgstr ""
msgid "script compilation not supported"
msgstr "script de compilación no soportado"
-#: shared-bindings/bleio/Peripheral.c
-msgid "services includes an object that is not a Service"
-msgstr "services incluye un objeto que no es Servicio"
-
#: py/objstr.c
msgid "sign not allowed in string format specifier"
msgstr "signo no permitido en el espeficador de string format"
@@ -2634,6 +2640,10 @@ msgstr ""
msgid "value_count must be > 0"
msgstr ""
+#: shared-bindings/bleio/Scanner.c
+msgid "window must be <= interval"
+msgstr ""
+
#: shared-bindings/_pixelbuf/PixelBuf.c
msgid "write_args must be a list, tuple, or None"
msgstr ""
@@ -2667,6 +2677,21 @@ msgstr "paso cero"
#~ msgid "AP required"
#~ msgstr "AP requerido"
+#~ msgid "Address is not %d bytes long or is in wrong format"
+#~ msgstr "Direción no es %d bytes largo o esta en el formato incorrecto"
+
+#~ msgid "Can't add services in Central mode"
+#~ msgstr "No se pueden agregar servicio en modo Central"
+
+#~ msgid "Can't advertise in Central mode"
+#~ msgstr "No se puede anunciar en modo Central"
+
+#~ msgid "Can't change the name in Central mode"
+#~ msgstr "No se puede cambiar el nombre en modo Central"
+
+#~ msgid "Can't connect in Peripheral mode"
+#~ msgstr "No se puede conectar en modo Peripheral"
+
#~ msgid "Cannot connect to AP"
#~ msgstr "No se puede conectar a AP"
@@ -2679,6 +2704,10 @@ msgstr "paso cero"
#~ msgid "Cannot update i/f status"
#~ msgstr "No se puede actualizar i/f status"
+#, fuzzy
+#~ msgid "Data too large for the advertisement packet"
+#~ msgstr "Los datos no caben en el paquete de anuncio."
+
#~ msgid "Don't know how to pass object to native function"
#~ msgstr "No se sabe cómo pasar objeto a función nativa"
@@ -2692,6 +2721,26 @@ msgstr "paso cero"
#~ msgstr "Error en ffi_prep_cif"
#, fuzzy
+#~ msgid "Failed to acquire mutex"
+#~ msgstr "No se puede adquirir el mutex, status: 0x%08lX"
+
+#, fuzzy
+#~ msgid "Failed to add service"
+#~ msgstr "No se puede detener el anuncio. status: 0x%02x"
+
+#, fuzzy
+#~ msgid "Failed to connect:"
+#~ msgstr "No se puede conectar. status: 0x%02x"
+
+#, fuzzy
+#~ msgid "Failed to continue scanning"
+#~ msgstr "No se puede iniciar el escaneo. status: 0x%02x"
+
+#, fuzzy
+#~ msgid "Failed to create mutex"
+#~ msgstr "No se puede leer el valor del atributo. status 0x%02x"
+
+#, fuzzy
#~ msgid "Failed to notify or indicate attribute value, err %0x04x"
#~ msgstr "No se puede notificar el valor del anuncio. status: 0x%02x"
@@ -2699,6 +2748,22 @@ msgstr "paso cero"
#~ msgid "Failed to read attribute value, err %0x04x"
#~ msgstr "No se puede leer el valor del atributo. status 0x%02x"
+#, fuzzy
+#~ msgid "Failed to release mutex"
+#~ msgstr "No se puede liberar el mutex, status: 0x%08lX"
+
+#, fuzzy
+#~ msgid "Failed to start advertising"
+#~ msgstr "No se puede inicar el anuncio. status: 0x%02x"
+
+#, fuzzy
+#~ msgid "Failed to start scanning"
+#~ msgstr "No se puede iniciar el escaneo. status: 0x%02x"
+
+#, fuzzy
+#~ msgid "Failed to stop advertising"
+#~ msgstr "No se puede detener el anuncio. status: 0x%02x"
+
#~ msgid "Function requires lock."
#~ msgstr "La función requiere lock"
@@ -2772,6 +2837,9 @@ msgstr "paso cero"
#~ msgid "UART(1) can't read"
#~ msgstr "UART(1) no puede leer"
+#~ msgid "UUID integer value not in range 0 to 0xffff"
+#~ msgstr "El valor integer UUID no está en el rango 0 a 0xffff"
+
#~ msgid "Unable to remount filesystem"
#~ msgstr "Incapaz de montar de nuevo el sistema de archivos"
@@ -2821,6 +2889,9 @@ msgstr "paso cero"
#~ msgid "impossible baudrate"
#~ msgstr "baudrate imposible"
+#~ msgid "interval not in range 0.0020 to 10.24"
+#~ msgstr "El intervalo está fuera del rango de 0.0020 a 10.24"
+
#~ msgid "invalid alarm"
#~ msgstr "alarma inválida"
@@ -2858,6 +2929,9 @@ msgstr "paso cero"
#~ msgid "scan failed"
#~ msgstr "scan ha fallado"
+#~ msgid "services includes an object that is not a Service"
+#~ msgstr "services incluye un objeto que no es servicio"
+
#~ msgid "too many arguments"
#~ msgstr "muchos argumentos"
diff --git a/locale/fil.po b/locale/fil.po
index db544f61e..4f05812f7 100644
--- a/locale/fil.po
+++ b/locale/fil.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2019-06-25 17:53-0700\n"
+"POT-Creation-Date: 2019-07-19 16:10-0700\n"
"PO-Revision-Date: 2018-12-20 22:15-0800\n"
"Last-Translator: Timothy <me@timothygarcia.ca>\n"
"Language-Team: fil\n"
@@ -221,15 +221,14 @@ msgid "A hardware interrupt channel is already in use"
msgstr "Isang channel ng hardware interrupt ay ginagamit na"
#: shared-bindings/bleio/Address.c
-#, c-format
-msgid "Address is not %d bytes long or is in wrong format"
-msgstr ""
-
-#: shared-bindings/bleio/Address.c
#, fuzzy, c-format
msgid "Address must be %d bytes long"
msgstr "ang palette ay dapat 32 bytes ang haba"
+#: shared-bindings/bleio/Address.c
+msgid "Address type out of range"
+msgstr ""
+
#: ports/nrf/common-hal/busio/I2C.c
msgid "All I2C peripherals are in use"
msgstr "Lahat ng I2C peripherals ginagamit"
@@ -315,6 +314,10 @@ msgstr "Bit depth ay dapat multiple ng 8."
msgid "Both pins must support hardware interrupts"
msgstr "Ang parehong mga pin ay dapat na sumusuporta sa hardware interrupts"
+#: shared-bindings/displayio/Display.c
+msgid "Brightness must be 0-1.0"
+msgstr ""
+
#: shared-bindings/supervisor/__init__.c
msgid "Brightness must be between 0 and 255"
msgstr "Ang liwanag ay dapat sa gitna ng 0 o 255"
@@ -356,21 +359,9 @@ msgstr ""
msgid "Can not use dotstar with %s"
msgstr ""
-#: shared-bindings/bleio/Device.c
-msgid "Can't add services in Central mode"
-msgstr "Hindi maarang maglagay ng service sa Central mode"
-
-#: shared-bindings/bleio/Device.c
-msgid "Can't advertise in Central mode"
-msgstr "Hindi ma advertise habang nasa Central mode"
-
-#: shared-bindings/bleio/Device.c
-msgid "Can't change the name in Central mode"
-msgstr "Hindi mapalitan ang pangalan sa Central mode"
-
-#: shared-bindings/bleio/Device.c
-msgid "Can't connect in Peripheral mode"
-msgstr "Hindi maconnect sa Peripheral mode"
+#: ports/nrf/common-hal/bleio/Characteristic.c
+msgid "Can't set CCCD for local Characteristic"
+msgstr ""
#: shared-bindings/displayio/Bitmap.c shared-bindings/pulseio/PulseIn.c
msgid "Cannot delete values"
@@ -454,6 +445,10 @@ msgstr "Clock unit ginagamit"
msgid "Column entry must be digitalio.DigitalInOut"
msgstr ""
+#: shared-bindings/displayio/I2CDisplay.c
+msgid "Command must be 0-255"
+msgstr ""
+
#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c
#, fuzzy
msgid "Command must be an int between 0 and 255"
@@ -502,17 +497,11 @@ msgstr "graphic ay dapat 2048 bytes ang haba"
msgid "Data chunk must follow fmt chunk"
msgstr "Dapat sunurin ng Data chunk ang fmt chunk"
-#: ports/nrf/common-hal/bleio/Broadcaster.c
#: ports/nrf/common-hal/bleio/Peripheral.c
#, fuzzy
msgid "Data too large for advertisement packet"
msgstr "Hindi makasya ang data sa loob ng advertisement packet"
-#: ports/nrf/common-hal/bleio/Device.c
-#, fuzzy
-msgid "Data too large for the advertisement packet"
-msgstr "Hindi makasya ang data sa loob ng advertisement packet"
-
#: shared-bindings/audiobusio/PDMIn.c
msgid "Destination capacity is smaller than destination_length."
msgstr ""
@@ -553,6 +542,10 @@ msgstr "Hindi mabasa and Characteristic."
msgid "Expected a UUID"
msgstr "Umasa ng %q"
+#: shared-bindings/bleio/Central.c
+msgid "Expected an Address"
+msgstr ""
+
#: shared-module/_pixelbuf/PixelBuf.c
#, c-format
msgid "Expected tuple of length %d, got %d"
@@ -562,12 +555,7 @@ msgstr ""
msgid "Failed sending command."
msgstr ""
-#: ports/nrf/common-hal/bleio/Device.c
-#, fuzzy
-msgid "Failed to acquire mutex"
-msgstr "Nabigo sa pag kuha ng mutex, status: 0x%08lX"
-
-#: ports/nrf/common-hal/bleio/Characteristic.c ports/nrf/sd_mutex.c
+#: ports/nrf/sd_mutex.c
#, fuzzy, c-format
msgid "Failed to acquire mutex, err 0x%04x"
msgstr "Nabigo sa pag kuha ng mutex, status: 0x%08lX"
@@ -577,11 +565,6 @@ msgstr "Nabigo sa pag kuha ng mutex, status: 0x%08lX"
msgid "Failed to add characteristic, err 0x%04x"
msgstr "Nabigo sa paglagay ng characteristic, status: 0x%08lX"
-#: ports/nrf/common-hal/bleio/Device.c
-#, fuzzy
-msgid "Failed to add service"
-msgstr "Hindi matagumpay ang paglagay ng service, status: 0x%08lX"
-
#: ports/nrf/common-hal/bleio/Peripheral.c
#, fuzzy, c-format
msgid "Failed to add service, err 0x%04x"
@@ -602,27 +585,21 @@ msgstr "Nabigong ilaan ang RX buffer ng %d bytes"
msgid "Failed to change softdevice state"
msgstr "Nabigo sa pagbago ng softdevice state, error: 0x%08lX"
-#: ports/nrf/common-hal/bleio/Device.c
-#, fuzzy
-msgid "Failed to connect:"
-msgstr "Hindi makaconnect, status: 0x%08lX"
+#: ports/nrf/common-hal/bleio/Peripheral.c
+#, c-format
+msgid "Failed to configure advertising, err 0x%04x"
+msgstr ""
-#: ports/nrf/common-hal/bleio/Device.c
-#, fuzzy
-msgid "Failed to continue scanning"
-msgstr "Hindi maituloy ang pag scan, status: 0x%0xlX"
+#: ports/nrf/common-hal/bleio/Central.c
+msgid "Failed to connect: timeout"
+msgstr ""
#: ports/nrf/common-hal/bleio/Scanner.c
#, fuzzy, c-format
msgid "Failed to continue scanning, err 0x%04x"
msgstr "Hindi maituloy ang pag scan, status: 0x%0xlX"
-#: ports/nrf/common-hal/bleio/Device.c
-#, fuzzy
-msgid "Failed to create mutex"
-msgstr "Hindi matagumpay ang pagbuo ng mutex, status: 0x%0xlX"
-
-#: ports/nrf/common-hal/bleio/Device.c
+#: ports/nrf/common-hal/bleio/Central.c
#, fuzzy
msgid "Failed to discover services"
msgstr "Nabigo sa pagdiscover ng services, status: 0x%08lX"
@@ -662,49 +639,42 @@ msgstr "Hindi maisulat ang gatts value, status: 0x%08lX"
msgid "Failed to register Vendor-Specific UUID, err 0x%04x"
msgstr "Hindi matagumpay ang paglagay ng Vender Specific UUID, status: 0x%08lX"
-#: ports/nrf/common-hal/bleio/Device.c
-#, fuzzy
-msgid "Failed to release mutex"
-msgstr "Nabigo sa pagrelease ng mutex, status: 0x%08lX"
-
-#: ports/nrf/common-hal/bleio/Characteristic.c ports/nrf/sd_mutex.c
+#: ports/nrf/sd_mutex.c
#, fuzzy, c-format
msgid "Failed to release mutex, err 0x%04x"
msgstr "Nabigo sa pagrelease ng mutex, status: 0x%08lX"
-#: ports/nrf/common-hal/bleio/Device.c
-#, fuzzy
-msgid "Failed to start advertising"
-msgstr "Hindi masimulaan ang advertisement, status: 0x%08lX"
+#: ports/nrf/common-hal/bleio/Peripheral.c
+#, c-format
+msgid "Failed to set device name, err 0x%04x"
+msgstr ""
-#: ports/nrf/common-hal/bleio/Broadcaster.c
#: ports/nrf/common-hal/bleio/Peripheral.c
#, fuzzy, c-format
msgid "Failed to start advertising, err 0x%04x"
msgstr "Hindi masimulaan ang advertisement, status: 0x%08lX"
-#: ports/nrf/common-hal/bleio/Device.c
-#, fuzzy
-msgid "Failed to start scanning"
-msgstr "Hindi masimulaan mag i-scan, status: 0x%0xlX"
+#: ports/nrf/common-hal/bleio/Central.c
+#, c-format
+msgid "Failed to start connecting, error 0x%04x"
+msgstr ""
#: ports/nrf/common-hal/bleio/Scanner.c
#, fuzzy, c-format
msgid "Failed to start scanning, err 0x%04x"
msgstr "Hindi masimulaan mag i-scan, status: 0x%0xlX"
-#: ports/nrf/common-hal/bleio/Device.c
-#, fuzzy
-msgid "Failed to stop advertising"
-msgstr "Hindi mahinto ang advertisement, status: 0x%08lX"
-
-#: ports/nrf/common-hal/bleio/Broadcaster.c
#: ports/nrf/common-hal/bleio/Peripheral.c
#, fuzzy, c-format
msgid "Failed to stop advertising, err 0x%04x"
msgstr "Hindi mahinto ang advertisement, status: 0x%08lX"
#: ports/nrf/common-hal/bleio/Characteristic.c
+#, c-format
+msgid "Failed to write CCCD, err 0x%04x"
+msgstr ""
+
+#: ports/nrf/common-hal/bleio/Characteristic.c
#, fuzzy, c-format
msgid "Failed to write attribute value, err 0x%04x"
msgstr "Hindi maisulat ang attribute value, status: 0x%08lX"
@@ -925,6 +895,10 @@ msgstr "Ang delay ng startup ng mikropono ay dapat na nasa 0.0 hanggang 1.0"
msgid "Must be a %q subclass."
msgstr ""
+#: ports/nrf/common-hal/bleio/Characteristic.c
+msgid "No CCCD for this Characteristic"
+msgstr ""
+
#: ports/atmel-samd/common-hal/analogio/AnalogOut.c
msgid "No DAC on chip"
msgstr "Walang DAC sa chip"
@@ -975,6 +949,7 @@ msgstr ""
msgid "No such file/directory"
msgstr "Walang file/directory"
+#: ports/nrf/common-hal/bleio/Characteristic.c
#: shared-bindings/bleio/CharacteristicBuffer.c
#, fuzzy
msgid "Not connected"
@@ -1224,7 +1199,8 @@ msgstr "Para lumabas, paki-reset ang board na wala ang "
msgid "Too many channels in sample."
msgstr "Sobra ang channels sa sample."
-#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c
+#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/I2CDisplay.c
+#: shared-bindings/displayio/ParallelBus.c
msgid "Too many display busses"
msgstr ""
@@ -1249,7 +1225,7 @@ msgid "USB Error"
msgstr "May pagkakamali ang USB"
#: shared-bindings/bleio/UUID.c
-msgid "UUID integer value not in range 0 to 0xffff"
+msgid "UUID integer value must be 0-0xffff"
msgstr ""
#: shared-bindings/bleio/UUID.c
@@ -1265,6 +1241,11 @@ msgstr ""
msgid "Unable to allocate buffers for signed conversion"
msgstr "Hindi ma-allocate ang buffers para sa naka-sign na conversion"
+#: shared-module/displayio/I2CDisplay.c
+#, c-format
+msgid "Unable to find I2C Display at %x"
+msgstr ""
+
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
msgid "Unable to find free GCLK"
@@ -1960,8 +1941,9 @@ msgstr "int() arg 2 ay dapat >=2 at <= 36"
msgid "integer required"
msgstr "kailangan ng int"
-#: ports/nrf/common-hal/bleio/Broadcaster.c
-msgid "interval not in range 0.0020 to 10.24"
+#: shared-bindings/bleio/Peripheral.c shared-bindings/bleio/Scanner.c
+#, c-format
+msgid "interval must be in range %s-%s"
msgstr ""
#: extmod/machine_i2c.c
@@ -2180,6 +2162,14 @@ msgstr "walang module na '%q'"
msgid "no such attribute"
msgstr "walang ganoon na attribute"
+#: shared-bindings/bleio/Peripheral.c
+msgid "non-Service found in services"
+msgstr ""
+
+#: ports/nrf/common-hal/bleio/Central.c
+msgid "non-UUID found in service_uuids"
+msgstr ""
+
#: py/compile.c
msgid "non-default argument follows default argument"
msgstr "non-default argument sumusunod sa default argument"
@@ -2393,10 +2383,6 @@ msgstr "puno na ang schedule stack"
msgid "script compilation not supported"
msgstr "script kompilasyon hindi supportado"
-#: shared-bindings/bleio/Peripheral.c
-msgid "services includes an object that is not a Service"
-msgstr ""
-
#: py/objstr.c
msgid "sign not allowed in string format specifier"
msgstr "sign hindi maaring string format specifier"
@@ -2665,6 +2651,10 @@ msgstr ""
msgid "value_count must be > 0"
msgstr ""
+#: shared-bindings/bleio/Scanner.c
+msgid "window must be <= interval"
+msgstr ""
+
#: shared-bindings/_pixelbuf/PixelBuf.c
msgid "write_args must be a list, tuple, or None"
msgstr ""
@@ -2701,6 +2691,18 @@ msgstr "zero step"
#~ msgid "C-level assert"
#~ msgstr "C-level assert"
+#~ msgid "Can't add services in Central mode"
+#~ msgstr "Hindi maarang maglagay ng service sa Central mode"
+
+#~ msgid "Can't advertise in Central mode"
+#~ msgstr "Hindi ma advertise habang nasa Central mode"
+
+#~ msgid "Can't change the name in Central mode"
+#~ msgstr "Hindi mapalitan ang pangalan sa Central mode"
+
+#~ msgid "Can't connect in Peripheral mode"
+#~ msgstr "Hindi maconnect sa Peripheral mode"
+
#~ msgid "Cannot connect to AP"
#~ msgstr "Hindi maka connect sa AP"
@@ -2713,6 +2715,10 @@ msgstr "zero step"
#~ msgid "Cannot update i/f status"
#~ msgstr "Hindi ma-update i/f status"
+#, fuzzy
+#~ msgid "Data too large for the advertisement packet"
+#~ msgstr "Hindi makasya ang data sa loob ng advertisement packet"
+
#~ msgid "Don't know how to pass object to native function"
#~ msgstr "Hindi alam ipasa ang object sa native function"
@@ -2726,6 +2732,26 @@ msgstr "zero step"
#~ msgstr "Pagkakamali sa ffi_prep_cif"
#, fuzzy
+#~ msgid "Failed to acquire mutex"
+#~ msgstr "Nabigo sa pag kuha ng mutex, status: 0x%08lX"
+
+#, fuzzy
+#~ msgid "Failed to add service"
+#~ msgstr "Hindi matagumpay ang paglagay ng service, status: 0x%08lX"
+
+#, fuzzy
+#~ msgid "Failed to connect:"
+#~ msgstr "Hindi makaconnect, status: 0x%08lX"
+
+#, fuzzy
+#~ msgid "Failed to continue scanning"
+#~ msgstr "Hindi maituloy ang pag scan, status: 0x%0xlX"
+
+#, fuzzy
+#~ msgid "Failed to create mutex"
+#~ msgstr "Hindi matagumpay ang pagbuo ng mutex, status: 0x%0xlX"
+
+#, fuzzy
#~ msgid "Failed to notify or indicate attribute value, err %0x04x"
#~ msgstr "Hindi mabalitaan ang attribute value, status: 0x%08lX"
@@ -2733,6 +2759,22 @@ msgstr "zero step"
#~ msgid "Failed to read attribute value, err %0x04x"
#~ msgstr "Hindi mabasa ang value ng attribute, status: 0x%08lX"
+#, fuzzy
+#~ msgid "Failed to release mutex"
+#~ msgstr "Nabigo sa pagrelease ng mutex, status: 0x%08lX"
+
+#, fuzzy
+#~ msgid "Failed to start advertising"
+#~ msgstr "Hindi masimulaan ang advertisement, status: 0x%08lX"
+
+#, fuzzy
+#~ msgid "Failed to start scanning"
+#~ msgstr "Hindi masimulaan mag i-scan, status: 0x%0xlX"
+
+#, fuzzy
+#~ msgid "Failed to stop advertising"
+#~ msgstr "Hindi mahinto ang advertisement, status: 0x%08lX"
+
#~ msgid "Function requires lock."
#~ msgstr "Kailangan ng lock ang function."
diff --git a/locale/fr.po b/locale/fr.po
index 654b908ca..a948630ee 100644
--- a/locale/fr.po
+++ b/locale/fr.po
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: 0.1\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2019-06-25 17:53-0700\n"
+"POT-Creation-Date: 2019-07-19 16:10-0700\n"
"PO-Revision-Date: 2019-04-14 20:05+0100\n"
"Last-Translator: Pierrick Couturier <arofarn@arofarn.info>\n"
"Language-Team: fr\n"
@@ -222,15 +222,14 @@ msgid "A hardware interrupt channel is already in use"
msgstr "Un canal d'interruptions matérielles est déjà utilisé"
#: shared-bindings/bleio/Address.c
-#, c-format
-msgid "Address is not %d bytes long or is in wrong format"
-msgstr "L'adresse n'est pas longue de %d octets ou est d'un format erroné"
-
-#: shared-bindings/bleio/Address.c
#, fuzzy, c-format
msgid "Address must be %d bytes long"
msgstr "L'adresse doit être longue de %d octets"
+#: shared-bindings/bleio/Address.c
+msgid "Address type out of range"
+msgstr ""
+
#: ports/nrf/common-hal/busio/I2C.c
#, fuzzy
msgid "All I2C peripherals are in use"
@@ -320,6 +319,10 @@ msgstr "La profondeur de bit doit être un multiple de 8."
msgid "Both pins must support hardware interrupts"
msgstr "Les deux entrées doivent supporter les interruptions matérielles"
+#: shared-bindings/displayio/Display.c
+msgid "Brightness must be 0-1.0"
+msgstr ""
+
#: shared-bindings/supervisor/__init__.c
msgid "Brightness must be between 0 and 255"
msgstr "La luminosité doit être entre 0 et 255"
@@ -361,21 +364,9 @@ msgstr ""
msgid "Can not use dotstar with %s"
msgstr "Impossible d'utiliser 'dotstar' avec %s"
-#: shared-bindings/bleio/Device.c
-msgid "Can't add services in Central mode"
-msgstr "Impossible d'ajouter des services en mode Central"
-
-#: shared-bindings/bleio/Device.c
-msgid "Can't advertise in Central mode"
-msgstr "Impossible de publier en mode Central"
-
-#: shared-bindings/bleio/Device.c
-msgid "Can't change the name in Central mode"
-msgstr "Modification du nom impossible en mode Central"
-
-#: shared-bindings/bleio/Device.c
-msgid "Can't connect in Peripheral mode"
-msgstr "Impossible de se connecter en mode 'Peripheral'"
+#: ports/nrf/common-hal/bleio/Characteristic.c
+msgid "Can't set CCCD for local Characteristic"
+msgstr ""
#: shared-bindings/displayio/Bitmap.c shared-bindings/pulseio/PulseIn.c
msgid "Cannot delete values"
@@ -460,6 +451,10 @@ msgstr "Horloge en cours d'utilisation"
msgid "Column entry must be digitalio.DigitalInOut"
msgstr "L'entrée 'Column' doit être un digitalio.DigitalInOut"
+#: shared-bindings/displayio/I2CDisplay.c
+msgid "Command must be 0-255"
+msgstr ""
+
#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c
#, fuzzy
msgid "Command must be an int between 0 and 255"
@@ -508,15 +503,10 @@ msgstr "La broche 'Data 0' doit être aligné sur l'octet"
msgid "Data chunk must follow fmt chunk"
msgstr "Un bloc de données doit suivre un bloc de format"
-#: ports/nrf/common-hal/bleio/Broadcaster.c
#: ports/nrf/common-hal/bleio/Peripheral.c
msgid "Data too large for advertisement packet"
msgstr "Données trop volumineuses pour un paquet de diffusion"
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Data too large for the advertisement packet"
-msgstr "Données trop volumineuses pour le paquet de diffusion"
-
#: shared-bindings/audiobusio/PDMIn.c
msgid "Destination capacity is smaller than destination_length."
msgstr "La capacité de destination est plus petite que 'destination_length'."
@@ -556,6 +546,10 @@ msgstr "Une 'Characteristic' est attendue"
msgid "Expected a UUID"
msgstr "Un UUID est attendu"
+#: shared-bindings/bleio/Central.c
+msgid "Expected an Address"
+msgstr ""
+
#: shared-module/_pixelbuf/PixelBuf.c
#, c-format
msgid "Expected tuple of length %d, got %d"
@@ -565,12 +559,7 @@ msgstr "Tuple de longueur %d attendu, obtenu %d"
msgid "Failed sending command."
msgstr ""
-#: ports/nrf/common-hal/bleio/Device.c
-#, fuzzy
-msgid "Failed to acquire mutex"
-msgstr "Echec de l'obtention de mutex"
-
-#: ports/nrf/common-hal/bleio/Characteristic.c ports/nrf/sd_mutex.c
+#: ports/nrf/sd_mutex.c
#, fuzzy, c-format
msgid "Failed to acquire mutex, err 0x%04x"
msgstr "Echec de l'obtention de mutex, err 0x%04x"
@@ -580,11 +569,6 @@ msgstr "Echec de l'obtention de mutex, err 0x%04x"
msgid "Failed to add characteristic, err 0x%04x"
msgstr "Echec de l'ajout de caractéristique, err 0x%04x"
-#: ports/nrf/common-hal/bleio/Device.c
-#, fuzzy
-msgid "Failed to add service"
-msgstr "Echec de l'ajout de service"
-
#: ports/nrf/common-hal/bleio/Peripheral.c
#, fuzzy, c-format
msgid "Failed to add service, err 0x%04x"
@@ -605,27 +589,21 @@ msgstr "Echec de l'allocation de %d octets du tampon RX"
msgid "Failed to change softdevice state"
msgstr "Echec de la modification de l'état du périphérique"
-#: ports/nrf/common-hal/bleio/Device.c
-#, fuzzy
-msgid "Failed to connect:"
-msgstr "Echec de connection:"
+#: ports/nrf/common-hal/bleio/Peripheral.c
+#, c-format
+msgid "Failed to configure advertising, err 0x%04x"
+msgstr ""
-#: ports/nrf/common-hal/bleio/Device.c
-#, fuzzy
-msgid "Failed to continue scanning"
-msgstr "Impossible de poursuivre le scan"
+#: ports/nrf/common-hal/bleio/Central.c
+msgid "Failed to connect: timeout"
+msgstr ""
#: ports/nrf/common-hal/bleio/Scanner.c
#, fuzzy, c-format
msgid "Failed to continue scanning, err 0x%04x"
msgstr "Impossible de poursuivre le scan, err 0x%04x"
-#: ports/nrf/common-hal/bleio/Device.c
-#, fuzzy
-msgid "Failed to create mutex"
-msgstr "Echec de la création de mutex"
-
-#: ports/nrf/common-hal/bleio/Device.c
+#: ports/nrf/common-hal/bleio/Central.c
#, fuzzy
msgid "Failed to discover services"
msgstr "Echec de la découverte de services"
@@ -666,49 +644,42 @@ msgstr "Impossible de lire la valeur de 'gatts', err 0x%04x"
msgid "Failed to register Vendor-Specific UUID, err 0x%04x"
msgstr "Echec de l'ajout de l'UUID du fournisseur, err 0x%04x"
-#: ports/nrf/common-hal/bleio/Device.c
-#, fuzzy
-msgid "Failed to release mutex"
-msgstr "Impossible de libérer mutex"
-
-#: ports/nrf/common-hal/bleio/Characteristic.c ports/nrf/sd_mutex.c
+#: ports/nrf/sd_mutex.c
#, fuzzy, c-format
msgid "Failed to release mutex, err 0x%04x"
msgstr "Impossible de libérer mutex, err 0x%04x"
-#: ports/nrf/common-hal/bleio/Device.c
-#, fuzzy
-msgid "Failed to start advertising"
-msgstr "Echec du démarrage de la diffusion"
+#: ports/nrf/common-hal/bleio/Peripheral.c
+#, c-format
+msgid "Failed to set device name, err 0x%04x"
+msgstr ""
-#: ports/nrf/common-hal/bleio/Broadcaster.c
#: ports/nrf/common-hal/bleio/Peripheral.c
#, fuzzy, c-format
msgid "Failed to start advertising, err 0x%04x"
msgstr "Impossible de commencer à diffuser, err 0x%04x"
-#: ports/nrf/common-hal/bleio/Device.c
-#, fuzzy
-msgid "Failed to start scanning"
-msgstr "Impossible de commencer à scanner"
+#: ports/nrf/common-hal/bleio/Central.c
+#, c-format
+msgid "Failed to start connecting, error 0x%04x"
+msgstr ""
#: ports/nrf/common-hal/bleio/Scanner.c
#, fuzzy, c-format
msgid "Failed to start scanning, err 0x%04x"
msgstr "Impossible de commencer à scanner, err 0x%04x"
-#: ports/nrf/common-hal/bleio/Device.c
-#, fuzzy
-msgid "Failed to stop advertising"
-msgstr "Echec de l'arrêt de diffusion"
-
-#: ports/nrf/common-hal/bleio/Broadcaster.c
#: ports/nrf/common-hal/bleio/Peripheral.c
#, fuzzy, c-format
msgid "Failed to stop advertising, err 0x%04x"
msgstr "Echec de l'arrêt de diffusion, err 0x%04x"
#: ports/nrf/common-hal/bleio/Characteristic.c
+#, c-format
+msgid "Failed to write CCCD, err 0x%04x"
+msgstr ""
+
+#: ports/nrf/common-hal/bleio/Characteristic.c
#, fuzzy, c-format
msgid "Failed to write attribute value, err 0x%04x"
msgstr "Impossible d'écrire la valeur de l'attribut, err 0x%04x"
@@ -933,6 +904,10 @@ msgstr "Le délais au démarrage du micro doit être entre 0.0 et 1.0"
msgid "Must be a %q subclass."
msgstr ""
+#: ports/nrf/common-hal/bleio/Characteristic.c
+msgid "No CCCD for this Characteristic"
+msgstr ""
+
#: ports/atmel-samd/common-hal/analogio/AnalogOut.c
msgid "No DAC on chip"
msgstr "Pas de DAC sur la puce"
@@ -983,6 +958,7 @@ msgstr "Il n'y a plus d'espace libre sur le périphérique"
msgid "No such file/directory"
msgstr "Fichier/dossier introuvable"
+#: ports/nrf/common-hal/bleio/Characteristic.c
#: shared-bindings/bleio/CharacteristicBuffer.c
#, fuzzy
msgid "Not connected"
@@ -1244,7 +1220,8 @@ msgstr "Pour quitter, redémarrez la carte SVP sans "
msgid "Too many channels in sample."
msgstr "Trop de canaux dans l'échantillon."
-#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c
+#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/I2CDisplay.c
+#: shared-bindings/displayio/ParallelBus.c
msgid "Too many display busses"
msgstr "Trop de bus d'affichage"
@@ -1269,8 +1246,8 @@ msgid "USB Error"
msgstr "Erreur USB"
#: shared-bindings/bleio/UUID.c
-msgid "UUID integer value not in range 0 to 0xffff"
-msgstr "valeur de l'entier UUID est hors-bornes 0 à 0xffff"
+msgid "UUID integer value must be 0-0xffff"
+msgstr ""
#: shared-bindings/bleio/UUID.c
msgid "UUID string not 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'"
@@ -1288,6 +1265,11 @@ msgstr ""
msgid "Unable to allocate buffers for signed conversion"
msgstr "Impossible d'allouer des tampons pour une conversion signée"
+#: shared-module/displayio/I2CDisplay.c
+#, c-format
+msgid "Unable to find I2C Display at %x"
+msgstr ""
+
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
msgid "Unable to find free GCLK"
@@ -1992,9 +1974,10 @@ msgstr "l'argument 2 de int() doit être >=2 et <=36"
msgid "integer required"
msgstr "entier requis"
-#: ports/nrf/common-hal/bleio/Broadcaster.c
-msgid "interval not in range 0.0020 to 10.24"
-msgstr "intervalle hors bornes 0.0020 à 10.24"
+#: shared-bindings/bleio/Peripheral.c shared-bindings/bleio/Scanner.c
+#, c-format
+msgid "interval must be in range %s-%s"
+msgstr ""
#: extmod/machine_i2c.c
msgid "invalid I2C peripheral"
@@ -2213,6 +2196,14 @@ msgstr "pas de module '%q'"
msgid "no such attribute"
msgstr "pas de tel attribut"
+#: shared-bindings/bleio/Peripheral.c
+msgid "non-Service found in services"
+msgstr ""
+
+#: ports/nrf/common-hal/bleio/Central.c
+msgid "non-UUID found in service_uuids"
+msgstr ""
+
#: py/compile.c
msgid "non-default argument follows default argument"
msgstr ""
@@ -2433,10 +2424,6 @@ msgstr "pile de planification pleine"
msgid "script compilation not supported"
msgstr "compilation de script non supportée"
-#: shared-bindings/bleio/Peripheral.c
-msgid "services includes an object that is not a Service"
-msgstr "'services' inclut un object qui n'est pas un 'Service'"
-
#: py/objstr.c
msgid "sign not allowed in string format specifier"
msgstr "signe non autorisé dans les spéc. de formats de chaînes de caractères"
@@ -2707,6 +2694,10 @@ msgstr ""
msgid "value_count must be > 0"
msgstr "'value_count' doit être > 0"
+#: shared-bindings/bleio/Scanner.c
+msgid "window must be <= interval"
+msgstr ""
+
#: shared-bindings/_pixelbuf/PixelBuf.c
msgid "write_args must be a list, tuple, or None"
msgstr "'write_args' doit être une liste, un tuple ou 'None'"
@@ -2741,6 +2732,21 @@ msgstr "'step' nul"
#~ msgid "AP required"
#~ msgstr "'AP' requis"
+#~ msgid "Address is not %d bytes long or is in wrong format"
+#~ msgstr "L'adresse n'est pas longue de %d octets ou est d'un format erroné"
+
+#~ msgid "Can't add services in Central mode"
+#~ msgstr "Impossible d'ajouter des services en mode Central"
+
+#~ msgid "Can't advertise in Central mode"
+#~ msgstr "Impossible de publier en mode Central"
+
+#~ msgid "Can't change the name in Central mode"
+#~ msgstr "Modification du nom impossible en mode Central"
+
+#~ msgid "Can't connect in Peripheral mode"
+#~ msgstr "Impossible de se connecter en mode 'Peripheral'"
+
#~ msgid "Cannot connect to AP"
#~ msgstr "Impossible de se connecter à 'AP'"
@@ -2753,6 +2759,9 @@ msgstr "'step' nul"
#~ msgid "Cannot update i/f status"
#~ msgstr "le status i/f ne peut être mis à jour"
+#~ msgid "Data too large for the advertisement packet"
+#~ msgstr "Données trop volumineuses pour le paquet de diffusion"
+
#~ msgid "Don't know how to pass object to native function"
#~ msgstr "Ne sais pas comment passer l'objet à une fonction native"
@@ -2766,6 +2775,26 @@ msgstr "'step' nul"
#~ msgstr "Erreur dans ffi_prep_cif"
#, fuzzy
+#~ msgid "Failed to acquire mutex"
+#~ msgstr "Echec de l'obtention de mutex"
+
+#, fuzzy
+#~ msgid "Failed to add service"
+#~ msgstr "Echec de l'ajout de service"
+
+#, fuzzy
+#~ msgid "Failed to connect:"
+#~ msgstr "Echec de connection:"
+
+#, fuzzy
+#~ msgid "Failed to continue scanning"
+#~ msgstr "Impossible de poursuivre le scan"
+
+#, fuzzy
+#~ msgid "Failed to create mutex"
+#~ msgstr "Echec de la création de mutex"
+
+#, fuzzy
#~ msgid "Failed to notify or indicate attribute value, err %0x04x"
#~ msgstr "Impossible de notifier la valeur de l'attribut. status: 0x%08lX"
@@ -2773,6 +2802,22 @@ msgstr "'step' nul"
#~ msgid "Failed to read attribute value, err %0x04x"
#~ msgstr "Impossible de lire la valeur de l'attribut. status: 0x%08lX"
+#, fuzzy
+#~ msgid "Failed to release mutex"
+#~ msgstr "Impossible de libérer mutex"
+
+#, fuzzy
+#~ msgid "Failed to start advertising"
+#~ msgstr "Echec du démarrage de la diffusion"
+
+#, fuzzy
+#~ msgid "Failed to start scanning"
+#~ msgstr "Impossible de commencer à scanner"
+
+#, fuzzy
+#~ msgid "Failed to stop advertising"
+#~ msgstr "Echec de l'arrêt de diffusion"
+
#~ msgid "Function requires lock."
#~ msgstr "La fonction nécessite un verrou."
@@ -2843,6 +2888,9 @@ msgstr "'step' nul"
#~ msgid "UART(1) can't read"
#~ msgstr "UART(1) ne peut pas lire"
+#~ msgid "UUID integer value not in range 0 to 0xffff"
+#~ msgstr "valeur de l'entier UUID est hors-bornes 0 à 0xffff"
+
#~ msgid "Unable to remount filesystem"
#~ msgstr "Impossible de remonter le système de fichiers"
@@ -2889,6 +2937,9 @@ msgstr "'step' nul"
#~ msgid "impossible baudrate"
#~ msgstr "débit impossible"
+#~ msgid "interval not in range 0.0020 to 10.24"
+#~ msgstr "intervalle hors bornes 0.0020 à 10.24"
+
#~ msgid "invalid alarm"
#~ msgstr "alarme invalide"
@@ -2924,6 +2975,9 @@ msgstr "'step' nul"
#~ msgid "scan failed"
#~ msgstr "échec du scan"
+#~ msgid "services includes an object that is not a Service"
+#~ msgstr "'services' inclut un object qui n'est pas un 'Service'"
+
#~ msgid "too many arguments"
#~ msgstr "trop d'arguments"
diff --git a/locale/it_IT.po b/locale/it_IT.po
index e930753d7..40a685f75 100644
--- a/locale/it_IT.po
+++ b/locale/it_IT.po
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2019-06-25 17:53-0700\n"
+"POT-Creation-Date: 2019-07-19 16:10-0700\n"
"PO-Revision-Date: 2018-10-02 16:27+0200\n"
"Last-Translator: Enrico Paganin <enrico.paganin@mail.com>\n"
"Language-Team: \n"
@@ -220,15 +220,14 @@ msgid "A hardware interrupt channel is already in use"
msgstr "Un canale di interrupt hardware è già in uso"
#: shared-bindings/bleio/Address.c
-#, c-format
-msgid "Address is not %d bytes long or is in wrong format"
-msgstr ""
-
-#: shared-bindings/bleio/Address.c
#, fuzzy, c-format
msgid "Address must be %d bytes long"
msgstr "la palette deve essere lunga 32 byte"
+#: shared-bindings/bleio/Address.c
+msgid "Address type out of range"
+msgstr ""
+
#: ports/nrf/common-hal/busio/I2C.c
msgid "All I2C peripherals are in use"
msgstr "Tutte le periferiche I2C sono in uso"
@@ -315,6 +314,10 @@ msgstr "La profondità di bit deve essere multipla di 8."
msgid "Both pins must support hardware interrupts"
msgstr "Entrambi i pin devono supportare gli interrupt hardware"
+#: shared-bindings/displayio/Display.c
+msgid "Brightness must be 0-1.0"
+msgstr ""
+
#: shared-bindings/supervisor/__init__.c
msgid "Brightness must be between 0 and 255"
msgstr "La luminosità deve essere compreso tra 0 e 255"
@@ -356,21 +359,9 @@ msgstr ""
msgid "Can not use dotstar with %s"
msgstr "dotstar non può essere usato con %s"
-#: shared-bindings/bleio/Device.c
-msgid "Can't add services in Central mode"
-msgstr "non si può aggiungere servizi in Central mode"
-
-#: shared-bindings/bleio/Device.c
-msgid "Can't advertise in Central mode"
-msgstr "non si può pubblicizzare in Central mode"
-
-#: shared-bindings/bleio/Device.c
-msgid "Can't change the name in Central mode"
-msgstr "non si può cambiare il nome in Central mode"
-
-#: shared-bindings/bleio/Device.c
-msgid "Can't connect in Peripheral mode"
-msgstr "non si può connettere in Periferal mode"
+#: ports/nrf/common-hal/bleio/Characteristic.c
+msgid "Can't set CCCD for local Characteristic"
+msgstr ""
#: shared-bindings/displayio/Bitmap.c shared-bindings/pulseio/PulseIn.c
msgid "Cannot delete values"
@@ -455,6 +446,10 @@ msgstr "Unità di clock in uso"
msgid "Column entry must be digitalio.DigitalInOut"
msgstr ""
+#: shared-bindings/displayio/I2CDisplay.c
+msgid "Command must be 0-255"
+msgstr ""
+
#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c
#, fuzzy
msgid "Command must be an int between 0 and 255"
@@ -503,17 +498,11 @@ msgstr "graphic deve essere lunga 2048 byte"
msgid "Data chunk must follow fmt chunk"
msgstr ""
-#: ports/nrf/common-hal/bleio/Broadcaster.c
#: ports/nrf/common-hal/bleio/Peripheral.c
#, fuzzy
msgid "Data too large for advertisement packet"
msgstr "Impossibile inserire dati nel pacchetto di advertisement."
-#: ports/nrf/common-hal/bleio/Device.c
-#, fuzzy
-msgid "Data too large for the advertisement packet"
-msgstr "Impossibile inserire dati nel pacchetto di advertisement."
-
#: shared-bindings/audiobusio/PDMIn.c
msgid "Destination capacity is smaller than destination_length."
msgstr "La capacità di destinazione è più piccola di destination_length."
@@ -553,6 +542,10 @@ msgstr "Non è possibile aggiungere Characteristic."
msgid "Expected a UUID"
msgstr "Atteso un %q"
+#: shared-bindings/bleio/Central.c
+msgid "Expected an Address"
+msgstr ""
+
#: shared-module/_pixelbuf/PixelBuf.c
#, c-format
msgid "Expected tuple of length %d, got %d"
@@ -562,12 +555,7 @@ msgstr ""
msgid "Failed sending command."
msgstr ""
-#: ports/nrf/common-hal/bleio/Device.c
-#, fuzzy
-msgid "Failed to acquire mutex"
-msgstr "Impossibile allocare buffer RX"
-
-#: ports/nrf/common-hal/bleio/Characteristic.c ports/nrf/sd_mutex.c
+#: ports/nrf/sd_mutex.c
#, fuzzy, c-format
msgid "Failed to acquire mutex, err 0x%04x"
msgstr "Impossibile leggere valore dell'attributo. status: 0x%02x"
@@ -577,11 +565,6 @@ msgstr "Impossibile leggere valore dell'attributo. status: 0x%02x"
msgid "Failed to add characteristic, err 0x%04x"
msgstr "Impossibile fermare advertisement. status: 0x%02x"
-#: ports/nrf/common-hal/bleio/Device.c
-#, fuzzy
-msgid "Failed to add service"
-msgstr "Impossibile fermare advertisement. status: 0x%02x"
-
#: ports/nrf/common-hal/bleio/Peripheral.c
#, fuzzy, c-format
msgid "Failed to add service, err 0x%04x"
@@ -602,27 +585,21 @@ msgstr "Fallita allocazione del buffer RX di %d byte"
msgid "Failed to change softdevice state"
msgstr "Impossibile fermare advertisement. status: 0x%02x"
-#: ports/nrf/common-hal/bleio/Device.c
-#, fuzzy
-msgid "Failed to connect:"
-msgstr "Impossibile connettersi. status: 0x%02x"
+#: ports/nrf/common-hal/bleio/Peripheral.c
+#, c-format
+msgid "Failed to configure advertising, err 0x%04x"
+msgstr ""
-#: ports/nrf/common-hal/bleio/Device.c
-#, fuzzy
-msgid "Failed to continue scanning"
-msgstr "Impossible iniziare la scansione. status: 0x%02x"
+#: ports/nrf/common-hal/bleio/Central.c
+msgid "Failed to connect: timeout"
+msgstr ""
#: ports/nrf/common-hal/bleio/Scanner.c
#, fuzzy, c-format
msgid "Failed to continue scanning, err 0x%04x"
msgstr "Impossible iniziare la scansione. status: 0x%02x"
-#: ports/nrf/common-hal/bleio/Device.c
-#, fuzzy
-msgid "Failed to create mutex"
-msgstr "Impossibile leggere valore dell'attributo. status: 0x%02x"
-
-#: ports/nrf/common-hal/bleio/Device.c
+#: ports/nrf/common-hal/bleio/Central.c
#, fuzzy
msgid "Failed to discover services"
msgstr "Impossibile fermare advertisement. status: 0x%02x"
@@ -661,49 +638,42 @@ msgstr "Impossibile scrivere valore dell'attributo. status: 0x%02x"
msgid "Failed to register Vendor-Specific UUID, err 0x%04x"
msgstr "Non è possibile aggiungere l'UUID del vendor specifico da 128-bit"
-#: ports/nrf/common-hal/bleio/Device.c
-#, fuzzy
-msgid "Failed to release mutex"
-msgstr "Impossibile leggere valore dell'attributo. status: 0x%02x"
-
-#: ports/nrf/common-hal/bleio/Characteristic.c ports/nrf/sd_mutex.c
+#: ports/nrf/sd_mutex.c
#, fuzzy, c-format
msgid "Failed to release mutex, err 0x%04x"
msgstr "Impossibile leggere valore dell'attributo. status: 0x%02x"
-#: ports/nrf/common-hal/bleio/Device.c
-#, fuzzy
-msgid "Failed to start advertising"
-msgstr "Impossibile avviare advertisement. status: 0x%02x"
+#: ports/nrf/common-hal/bleio/Peripheral.c
+#, c-format
+msgid "Failed to set device name, err 0x%04x"
+msgstr ""
-#: ports/nrf/common-hal/bleio/Broadcaster.c
#: ports/nrf/common-hal/bleio/Peripheral.c
#, fuzzy, c-format
msgid "Failed to start advertising, err 0x%04x"
msgstr "Impossibile avviare advertisement. status: 0x%02x"
-#: ports/nrf/common-hal/bleio/Device.c
-#, fuzzy
-msgid "Failed to start scanning"
-msgstr "Impossible iniziare la scansione. status: 0x%02x"
+#: ports/nrf/common-hal/bleio/Central.c
+#, c-format
+msgid "Failed to start connecting, error 0x%04x"
+msgstr ""
#: ports/nrf/common-hal/bleio/Scanner.c
#, fuzzy, c-format
msgid "Failed to start scanning, err 0x%04x"
msgstr "Impossible iniziare la scansione. status: 0x%02x"
-#: ports/nrf/common-hal/bleio/Device.c
-#, fuzzy
-msgid "Failed to stop advertising"
-msgstr "Impossibile fermare advertisement. status: 0x%02x"
-
-#: ports/nrf/common-hal/bleio/Broadcaster.c
#: ports/nrf/common-hal/bleio/Peripheral.c
#, fuzzy, c-format
msgid "Failed to stop advertising, err 0x%04x"
msgstr "Impossibile fermare advertisement. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Characteristic.c
+#, c-format
+msgid "Failed to write CCCD, err 0x%04x"
+msgstr ""
+
+#: ports/nrf/common-hal/bleio/Characteristic.c
#, fuzzy, c-format
msgid "Failed to write attribute value, err 0x%04x"
msgstr "Impossibile scrivere valore dell'attributo. status: 0x%02x"
@@ -924,6 +894,10 @@ msgstr ""
msgid "Must be a %q subclass."
msgstr ""
+#: ports/nrf/common-hal/bleio/Characteristic.c
+msgid "No CCCD for this Characteristic"
+msgstr ""
+
#: ports/atmel-samd/common-hal/analogio/AnalogOut.c
msgid "No DAC on chip"
msgstr "Nessun DAC sul chip"
@@ -974,6 +948,7 @@ msgstr "Non che spazio sul dispositivo"
msgid "No such file/directory"
msgstr "Nessun file/directory esistente"
+#: ports/nrf/common-hal/bleio/Characteristic.c
#: shared-bindings/bleio/CharacteristicBuffer.c
#, fuzzy
msgid "Not connected"
@@ -1223,7 +1198,8 @@ msgstr "Per uscire resettare la scheda senza "
msgid "Too many channels in sample."
msgstr ""
-#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c
+#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/I2CDisplay.c
+#: shared-bindings/displayio/ParallelBus.c
msgid "Too many display busses"
msgstr ""
@@ -1248,7 +1224,7 @@ msgid "USB Error"
msgstr "Errore USB"
#: shared-bindings/bleio/UUID.c
-msgid "UUID integer value not in range 0 to 0xffff"
+msgid "UUID integer value must be 0-0xffff"
msgstr ""
#: shared-bindings/bleio/UUID.c
@@ -1264,6 +1240,11 @@ msgstr ""
msgid "Unable to allocate buffers for signed conversion"
msgstr "Ipossibilitato ad allocare buffer per la conversione con segno"
+#: shared-module/displayio/I2CDisplay.c
+#, c-format
+msgid "Unable to find I2C Display at %x"
+msgstr ""
+
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
msgid "Unable to find free GCLK"
@@ -1952,8 +1933,9 @@ msgstr "il secondo argomanto di int() deve essere >= 2 e <= 36"
msgid "integer required"
msgstr "intero richiesto"
-#: ports/nrf/common-hal/bleio/Broadcaster.c
-msgid "interval not in range 0.0020 to 10.24"
+#: shared-bindings/bleio/Peripheral.c shared-bindings/bleio/Scanner.c
+#, c-format
+msgid "interval must be in range %s-%s"
msgstr ""
#: extmod/machine_i2c.c
@@ -2174,6 +2156,14 @@ msgstr "nessun modulo chiamato '%q'"
msgid "no such attribute"
msgstr "attributo inesistente"
+#: shared-bindings/bleio/Peripheral.c
+msgid "non-Service found in services"
+msgstr ""
+
+#: ports/nrf/common-hal/bleio/Central.c
+msgid "non-UUID found in service_uuids"
+msgstr ""
+
#: py/compile.c
msgid "non-default argument follows default argument"
msgstr "argomento non predefinito segue argmoento predfinito"
@@ -2391,10 +2381,6 @@ msgstr ""
msgid "script compilation not supported"
msgstr "compilazione dello scrip non suportata"
-#: shared-bindings/bleio/Peripheral.c
-msgid "services includes an object that is not a Service"
-msgstr ""
-
#: py/objstr.c
msgid "sign not allowed in string format specifier"
msgstr "segno non permesso nello spcificatore di formato della stringa"
@@ -2663,6 +2649,10 @@ msgstr ""
msgid "value_count must be > 0"
msgstr ""
+#: shared-bindings/bleio/Scanner.c
+msgid "window must be <= interval"
+msgstr ""
+
#: shared-bindings/_pixelbuf/PixelBuf.c
msgid "write_args must be a list, tuple, or None"
msgstr ""
@@ -2699,6 +2689,18 @@ msgstr "zero step"
#~ msgid "C-level assert"
#~ msgstr "assert a livello C"
+#~ msgid "Can't add services in Central mode"
+#~ msgstr "non si può aggiungere servizi in Central mode"
+
+#~ msgid "Can't advertise in Central mode"
+#~ msgstr "non si può pubblicizzare in Central mode"
+
+#~ msgid "Can't change the name in Central mode"
+#~ msgstr "non si può cambiare il nome in Central mode"
+
+#~ msgid "Can't connect in Peripheral mode"
+#~ msgstr "non si può connettere in Periferal mode"
+
#~ msgid "Cannot connect to AP"
#~ msgstr "Impossible connettersi all'AP"
@@ -2711,6 +2713,10 @@ msgstr "zero step"
#~ msgid "Cannot update i/f status"
#~ msgstr "Impossibile aggiornare status di i/f"
+#, fuzzy
+#~ msgid "Data too large for the advertisement packet"
+#~ msgstr "Impossibile inserire dati nel pacchetto di advertisement."
+
#~ msgid "Don't know how to pass object to native function"
#~ msgstr "Non so come passare l'oggetto alla funzione nativa"
@@ -2724,6 +2730,26 @@ msgstr "zero step"
#~ msgstr "Errore in ffi_prep_cif"
#, fuzzy
+#~ msgid "Failed to acquire mutex"
+#~ msgstr "Impossibile allocare buffer RX"
+
+#, fuzzy
+#~ msgid "Failed to add service"
+#~ msgstr "Impossibile fermare advertisement. status: 0x%02x"
+
+#, fuzzy
+#~ msgid "Failed to connect:"
+#~ msgstr "Impossibile connettersi. status: 0x%02x"
+
+#, fuzzy
+#~ msgid "Failed to continue scanning"
+#~ msgstr "Impossible iniziare la scansione. status: 0x%02x"
+
+#, fuzzy
+#~ msgid "Failed to create mutex"
+#~ msgstr "Impossibile leggere valore dell'attributo. status: 0x%02x"
+
+#, fuzzy
#~ msgid "Failed to notify or indicate attribute value, err %0x04x"
#~ msgstr "Impossibile notificare valore dell'attributo. status: 0x%02x"
@@ -2731,6 +2757,22 @@ msgstr "zero step"
#~ msgid "Failed to read attribute value, err %0x04x"
#~ msgstr "Impossibile leggere valore dell'attributo. status: 0x%02x"
+#, fuzzy
+#~ msgid "Failed to release mutex"
+#~ msgstr "Impossibile leggere valore dell'attributo. status: 0x%02x"
+
+#, fuzzy
+#~ msgid "Failed to start advertising"
+#~ msgstr "Impossibile avviare advertisement. status: 0x%02x"
+
+#, fuzzy
+#~ msgid "Failed to start scanning"
+#~ msgstr "Impossible iniziare la scansione. status: 0x%02x"
+
+#, fuzzy
+#~ msgid "Failed to stop advertising"
+#~ msgstr "Impossibile fermare advertisement. status: 0x%02x"
+
#~ msgid "GPIO16 does not support pull up."
#~ msgstr "GPIO16 non supporta pull-up"
diff --git a/locale/pl.po b/locale/pl.po
index 89042935c..896785126 100644
--- a/locale/pl.po
+++ b/locale/pl.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2019-06-25 17:53-0700\n"
+"POT-Creation-Date: 2019-07-19 16:10-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"
@@ -220,14 +220,13 @@ msgstr "Kanał przerwań sprzętowych w użyciu"
#: shared-bindings/bleio/Address.c
#, c-format
-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"
-
-#: shared-bindings/bleio/Address.c
-#, c-format
msgid "Address must be %d bytes long"
msgstr "Adres musi mieć %d bajtów"
+#: shared-bindings/bleio/Address.c
+msgid "Address type out of range"
+msgstr ""
+
#: ports/nrf/common-hal/busio/I2C.c
msgid "All I2C peripherals are in use"
msgstr "Wszystkie peryferia I2C w użyciu"
@@ -312,6 +311,10 @@ msgstr "Głębia musi być wielokrotnością 8."
msgid "Both pins must support hardware interrupts"
msgstr "Obie nóżki muszą wspierać przerwania sprzętowe"
+#: shared-bindings/displayio/Display.c
+msgid "Brightness must be 0-1.0"
+msgstr ""
+
#: shared-bindings/supervisor/__init__.c
msgid "Brightness must be between 0 and 255"
msgstr "Jasność musi być pomiędzy 0 a 255"
@@ -352,21 +355,9 @@ msgstr ""
msgid "Can not use dotstar with %s"
msgstr "Nie można używać dotstar z %s"
-#: shared-bindings/bleio/Device.c
-msgid "Can't add services in Central mode"
-msgstr "Nie można dodać serwisów w trybie Central"
-
-#: shared-bindings/bleio/Device.c
-msgid "Can't advertise in Central mode"
-msgstr "Nie można rozgłaszać w trybie Central"
-
-#: shared-bindings/bleio/Device.c
-msgid "Can't change the name in Central mode"
-msgstr "Nie można zmienić nazwy w trybie Central"
-
-#: shared-bindings/bleio/Device.c
-msgid "Can't connect in Peripheral mode"
-msgstr "Nie można się łączyć w trybie Peripheral"
+#: ports/nrf/common-hal/bleio/Characteristic.c
+msgid "Can't set CCCD for local Characteristic"
+msgstr ""
#: shared-bindings/displayio/Bitmap.c shared-bindings/pulseio/PulseIn.c
msgid "Cannot delete values"
@@ -449,6 +440,10 @@ msgstr "Jednostka zegara w użyciu"
msgid "Column entry must be digitalio.DigitalInOut"
msgstr "Kolumny muszą być typu digitalio.DigitalInOut"
+#: shared-bindings/displayio/I2CDisplay.c
+msgid "Command must be 0-255"
+msgstr ""
+
#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c
msgid "Command must be an int between 0 and 255"
msgstr "Komenda musi być int pomiędzy 0 a 255"
@@ -495,15 +490,10 @@ msgstr "Nóżka data 0 musi być wyrównana do bajtu"
msgid "Data chunk must follow fmt chunk"
msgstr "Fragment danych musi następować po fragmencie fmt"
-#: ports/nrf/common-hal/bleio/Broadcaster.c
#: ports/nrf/common-hal/bleio/Peripheral.c
msgid "Data too large for advertisement packet"
msgstr "Zbyt dużo danych pakietu rozgłoszeniowego"
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Data too large for the advertisement packet"
-msgstr "Zbyt dużo danych pakietu rozgłoszeniowego"
-
#: shared-bindings/audiobusio/PDMIn.c
msgid "Destination capacity is smaller than destination_length."
msgstr "Pojemność celu mniejsza od destination_length."
@@ -541,6 +531,10 @@ msgstr "Oczekiwano charakterystyki"
msgid "Expected a UUID"
msgstr "Oczekiwano UUID"
+#: shared-bindings/bleio/Central.c
+msgid "Expected an Address"
+msgstr ""
+
#: shared-module/_pixelbuf/PixelBuf.c
#, c-format
msgid "Expected tuple of length %d, got %d"
@@ -550,11 +544,7 @@ msgstr "Oczekiwano krotkę długości %d, otrzymano %d"
msgid "Failed sending command."
msgstr ""
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Failed to acquire mutex"
-msgstr "Nie udało się uzyskać blokady"
-
-#: ports/nrf/common-hal/bleio/Characteristic.c ports/nrf/sd_mutex.c
+#: ports/nrf/sd_mutex.c
#, c-format
msgid "Failed to acquire mutex, err 0x%04x"
msgstr "Nie udało się uzyskać blokady, błąd 0x$04x"
@@ -564,10 +554,6 @@ msgstr "Nie udało się uzyskać blokady, błąd 0x$04x"
msgid "Failed to add characteristic, err 0x%04x"
msgstr "Nie udało się dodać charakterystyki, błąd 0x$04x"
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Failed to add service"
-msgstr "Nie udało się dodać serwisu"
-
#: ports/nrf/common-hal/bleio/Peripheral.c
#, c-format
msgid "Failed to add service, err 0x%04x"
@@ -587,24 +573,21 @@ msgstr "Nie udała się alokacja %d bajtów na bufor RX"
msgid "Failed to change softdevice state"
msgstr "Nie udało się zmienić stanu softdevice"
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Failed to connect:"
-msgstr "Nie udało się połączenie:"
+#: ports/nrf/common-hal/bleio/Peripheral.c
+#, c-format
+msgid "Failed to configure advertising, err 0x%04x"
+msgstr ""
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Failed to continue scanning"
-msgstr "Nie udała się kontynuacja skanowania"
+#: ports/nrf/common-hal/bleio/Central.c
+msgid "Failed to connect: timeout"
+msgstr ""
#: ports/nrf/common-hal/bleio/Scanner.c
#, c-format
msgid "Failed to continue scanning, err 0x%04x"
msgstr "Nie udała się kontynuacja skanowania, błąd 0x%04x"
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Failed to create mutex"
-msgstr "Nie udało się stworzyć blokady"
-
-#: ports/nrf/common-hal/bleio/Device.c
+#: ports/nrf/common-hal/bleio/Central.c
msgid "Failed to discover services"
msgstr "Nie udało się odkryć serwisów"
@@ -641,39 +624,31 @@ msgstr "Nie udało się odczytać gatts, błąd 0x%04x"
msgid "Failed to register Vendor-Specific UUID, err 0x%04x"
msgstr "Nie udało się zarejestrować UUID dostawcy, błąd 0x%04x"
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Failed to release mutex"
-msgstr "Nie udało się zwolnić blokady"
-
-#: ports/nrf/common-hal/bleio/Characteristic.c ports/nrf/sd_mutex.c
+#: ports/nrf/sd_mutex.c
#, c-format
msgid "Failed to release mutex, err 0x%04x"
msgstr "Nie udało się zwolnić blokady, błąd 0x%04x"
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Failed to start advertising"
-msgstr "Nie udało się rozpocząć rozgłaszania"
+#: ports/nrf/common-hal/bleio/Peripheral.c
+#, c-format
+msgid "Failed to set device name, err 0x%04x"
+msgstr ""
-#: ports/nrf/common-hal/bleio/Broadcaster.c
#: ports/nrf/common-hal/bleio/Peripheral.c
#, c-format
msgid "Failed to start advertising, err 0x%04x"
msgstr "Nie udało się rozpocząć rozgłaszania, błąd 0x%04x"
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Failed to start scanning"
-msgstr "Nie udało się rozpocząć skanowania"
+#: ports/nrf/common-hal/bleio/Central.c
+#, c-format
+msgid "Failed to start connecting, error 0x%04x"
+msgstr ""
#: ports/nrf/common-hal/bleio/Scanner.c
#, c-format
msgid "Failed to start scanning, err 0x%04x"
msgstr "Nie udało się rozpocząć skanowania, błąd 0x%04x"
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Failed to stop advertising"
-msgstr "Nie udało się zatrzymać rozgłaszania"
-
-#: ports/nrf/common-hal/bleio/Broadcaster.c
#: ports/nrf/common-hal/bleio/Peripheral.c
#, c-format
msgid "Failed to stop advertising, err 0x%04x"
@@ -681,6 +656,11 @@ msgstr "Nie udało się zatrzymać rozgłaszania, błąd 0x%04x"
#: ports/nrf/common-hal/bleio/Characteristic.c
#, c-format
+msgid "Failed to write CCCD, err 0x%04x"
+msgstr ""
+
+#: ports/nrf/common-hal/bleio/Characteristic.c
+#, c-format
msgid "Failed to write attribute value, err 0x%04x"
msgstr "Nie udało się zapisać atrybutu, błąd 0x%04x"
@@ -901,6 +881,10 @@ msgstr "Opóźnienie włączenia mikrofonu musi być w zakresie od 0.0 do 1.0"
msgid "Must be a %q subclass."
msgstr ""
+#: ports/nrf/common-hal/bleio/Characteristic.c
+msgid "No CCCD for this Characteristic"
+msgstr ""
+
#: ports/atmel-samd/common-hal/analogio/AnalogOut.c
msgid "No DAC on chip"
msgstr "Brak DAC"
@@ -951,6 +935,7 @@ msgstr "Brak miejsca"
msgid "No such file/directory"
msgstr "Brak pliku/katalogu"
+#: ports/nrf/common-hal/bleio/Characteristic.c
#: shared-bindings/bleio/CharacteristicBuffer.c
msgid "Not connected"
msgstr "Nie podłączono"
@@ -1191,7 +1176,8 @@ msgstr "By wyjść, proszę zresetować płytkę bez "
msgid "Too many channels in sample."
msgstr "Zbyt wiele kanałów."
-#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c
+#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/I2CDisplay.c
+#: shared-bindings/displayio/ParallelBus.c
msgid "Too many display busses"
msgstr "Zbyt wiele magistrali"
@@ -1216,8 +1202,8 @@ msgid "USB Error"
msgstr "Błąd USB"
#: shared-bindings/bleio/UUID.c
-msgid "UUID integer value not in range 0 to 0xffff"
-msgstr "Wartość UUID poza zakresem 0 do 0xffff"
+msgid "UUID integer value must be 0-0xffff"
+msgstr ""
#: shared-bindings/bleio/UUID.c
msgid "UUID string not 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'"
@@ -1232,6 +1218,11 @@ msgstr "UUID nie jest typu str, int lub bytes"
msgid "Unable to allocate buffers for signed conversion"
msgstr "Nie udała się alokacja buforów do konwersji ze znakiem"
+#: shared-module/displayio/I2CDisplay.c
+#, c-format
+msgid "Unable to find I2C Display at %x"
+msgstr ""
+
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
msgid "Unable to find free GCLK"
@@ -1909,9 +1900,10 @@ msgstr "argument 2 do int() busi być pomiędzy 2 a 36"
msgid "integer required"
msgstr "wymagana liczba całkowita"
-#: ports/nrf/common-hal/bleio/Broadcaster.c
-msgid "interval not in range 0.0020 to 10.24"
-msgstr "przedział poza zakresem 0.0020 do 10.24"
+#: shared-bindings/bleio/Peripheral.c shared-bindings/bleio/Scanner.c
+#, c-format
+msgid "interval must be in range %s-%s"
+msgstr ""
#: extmod/machine_i2c.c
msgid "invalid I2C peripheral"
@@ -2124,6 +2116,14 @@ msgstr "brak modułu o nazwie '%q'"
msgid "no such attribute"
msgstr "nie ma takiego atrybutu"
+#: shared-bindings/bleio/Peripheral.c
+msgid "non-Service found in services"
+msgstr ""
+
+#: ports/nrf/common-hal/bleio/Central.c
+msgid "non-UUID found in service_uuids"
+msgstr ""
+
#: py/compile.c
msgid "non-default argument follows default argument"
msgstr "argument z wartością domyślną przed argumentem bez"
@@ -2334,10 +2334,6 @@ msgstr "stos planu pełen"
msgid "script compilation not supported"
msgstr "kompilowanie skryptów nieobsługiwane"
-#: shared-bindings/bleio/Peripheral.c
-msgid "services includes an object that is not a Service"
-msgstr "obiekt typu innego niż Service w services"
-
#: py/objstr.c
msgid "sign not allowed in string format specifier"
msgstr "znak jest niedopuszczalny w specyfikacji formatu łańcucha"
@@ -2604,6 +2600,10 @@ msgstr ""
msgid "value_count must be > 0"
msgstr "value_count musi być > 0"
+#: shared-bindings/bleio/Scanner.c
+msgid "window must be <= interval"
+msgstr ""
+
#: shared-bindings/_pixelbuf/PixelBuf.c
msgid "write_args must be a list, tuple, or None"
msgstr "write_args musi być listą, krotką lub None"
@@ -2632,6 +2632,51 @@ msgstr "y poza zakresem"
msgid "zero step"
msgstr "zerowy krok"
+#~ 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"
+
+#~ msgid "Can't add services in Central mode"
+#~ msgstr "Nie można dodać serwisów w trybie Central"
+
+#~ msgid "Can't advertise in Central mode"
+#~ msgstr "Nie można rozgłaszać w trybie Central"
+
+#~ msgid "Can't change the name in Central mode"
+#~ msgstr "Nie można zmienić nazwy w trybie Central"
+
+#~ msgid "Can't connect in Peripheral mode"
+#~ msgstr "Nie można się łączyć w trybie Peripheral"
+
+#~ msgid "Data too large for the advertisement packet"
+#~ msgstr "Zbyt dużo danych pakietu rozgłoszeniowego"
+
+#~ msgid "Failed to acquire mutex"
+#~ msgstr "Nie udało się uzyskać blokady"
+
+#~ msgid "Failed to add service"
+#~ msgstr "Nie udało się dodać serwisu"
+
+#~ msgid "Failed to connect:"
+#~ msgstr "Nie udało się połączenie:"
+
+#~ msgid "Failed to continue scanning"
+#~ msgstr "Nie udała się kontynuacja skanowania"
+
+#~ msgid "Failed to create mutex"
+#~ msgstr "Nie udało się stworzyć blokady"
+
+#~ msgid "Failed to release mutex"
+#~ msgstr "Nie udało się zwolnić blokady"
+
+#~ msgid "Failed to start advertising"
+#~ msgstr "Nie udało się rozpocząć rozgłaszania"
+
+#~ msgid "Failed to start scanning"
+#~ msgstr "Nie udało się rozpocząć skanowania"
+
+#~ msgid "Failed to stop advertising"
+#~ msgstr "Nie udało się zatrzymać rozgłaszania"
+
#~ msgid "Invalid bit clock pin"
#~ msgstr "Zła nóżka zegara"
@@ -2643,3 +2688,12 @@ msgstr "zerowy krok"
#~ msgid "Must be a Group subclass."
#~ msgstr "Musi dziedziczyć z Group."
+
+#~ msgid "UUID integer value not in range 0 to 0xffff"
+#~ msgstr "Wartość UUID poza zakresem 0 do 0xffff"
+
+#~ msgid "interval not in range 0.0020 to 10.24"
+#~ msgstr "przedział poza zakresem 0.0020 do 10.24"
+
+#~ msgid "services includes an object that is not a Service"
+#~ msgstr "obiekt typu innego niż Service w services"
diff --git a/locale/pt_BR.po b/locale/pt_BR.po
index 370f93c96..7e052bfb7 100644
--- a/locale/pt_BR.po
+++ b/locale/pt_BR.po
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2019-06-25 17:53-0700\n"
+"POT-Creation-Date: 2019-07-19 16:10-0700\n"
"PO-Revision-Date: 2018-10-02 21:14-0000\n"
"Last-Translator: \n"
"Language-Team: \n"
@@ -220,15 +220,14 @@ 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
-#, c-format
-msgid "Address is not %d bytes long or is in wrong format"
-msgstr ""
-
-#: shared-bindings/bleio/Address.c
#, fuzzy, c-format
msgid "Address must be %d bytes long"
msgstr "buffers devem ser o mesmo tamanho"
+#: shared-bindings/bleio/Address.c
+msgid "Address type out of range"
+msgstr ""
+
#: ports/nrf/common-hal/busio/I2C.c
msgid "All I2C peripherals are in use"
msgstr "Todos os periféricos I2C estão em uso"
@@ -312,6 +311,10 @@ msgstr ""
msgid "Both pins must support hardware interrupts"
msgstr "Ambos os pinos devem suportar interrupções de hardware"
+#: shared-bindings/displayio/Display.c
+msgid "Brightness must be 0-1.0"
+msgstr ""
+
#: shared-bindings/supervisor/__init__.c
msgid "Brightness must be between 0 and 255"
msgstr "O brilho deve estar entre 0 e 255"
@@ -353,20 +356,8 @@ msgstr ""
msgid "Can not use dotstar with %s"
msgstr ""
-#: shared-bindings/bleio/Device.c
-msgid "Can't add services in Central mode"
-msgstr ""
-
-#: shared-bindings/bleio/Device.c
-msgid "Can't advertise in Central mode"
-msgstr ""
-
-#: shared-bindings/bleio/Device.c
-msgid "Can't change the name in Central mode"
-msgstr ""
-
-#: shared-bindings/bleio/Device.c
-msgid "Can't connect in Peripheral mode"
+#: ports/nrf/common-hal/bleio/Characteristic.c
+msgid "Can't set CCCD for local Characteristic"
msgstr ""
#: shared-bindings/displayio/Bitmap.c shared-bindings/pulseio/PulseIn.c
@@ -451,6 +442,10 @@ msgstr "Unidade de Clock em uso"
msgid "Column entry must be digitalio.DigitalInOut"
msgstr ""
+#: shared-bindings/displayio/I2CDisplay.c
+msgid "Command must be 0-255"
+msgstr ""
+
#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c
#, fuzzy
msgid "Command must be an int between 0 and 255"
@@ -498,17 +493,11 @@ msgstr ""
msgid "Data chunk must follow fmt chunk"
msgstr "Pedaço de dados deve seguir o pedaço de cortes"
-#: ports/nrf/common-hal/bleio/Broadcaster.c
#: ports/nrf/common-hal/bleio/Peripheral.c
#, fuzzy
msgid "Data too large for advertisement packet"
msgstr "Não é possível ajustar dados no pacote de anúncios."
-#: ports/nrf/common-hal/bleio/Device.c
-#, fuzzy
-msgid "Data too large for the advertisement packet"
-msgstr "Não é possível ajustar dados no pacote de anúncios."
-
#: shared-bindings/audiobusio/PDMIn.c
msgid "Destination capacity is smaller than destination_length."
msgstr ""
@@ -548,6 +537,10 @@ msgstr "Não é possível adicionar Característica."
msgid "Expected a UUID"
msgstr "Esperado um"
+#: shared-bindings/bleio/Central.c
+msgid "Expected an Address"
+msgstr ""
+
#: shared-module/_pixelbuf/PixelBuf.c
#, c-format
msgid "Expected tuple of length %d, got %d"
@@ -557,12 +550,7 @@ msgstr ""
msgid "Failed sending command."
msgstr "Falha ao enviar comando."
-#: ports/nrf/common-hal/bleio/Device.c
-#, fuzzy
-msgid "Failed to acquire mutex"
-msgstr "Falha ao alocar buffer RX"
-
-#: ports/nrf/common-hal/bleio/Characteristic.c ports/nrf/sd_mutex.c
+#: ports/nrf/sd_mutex.c
#, fuzzy, c-format
msgid "Failed to acquire mutex, err 0x%04x"
msgstr "Não é possível ler o valor do atributo. status: 0x%02x"
@@ -572,11 +560,6 @@ msgstr "Não é possível ler o valor do atributo. status: 0x%02x"
msgid "Failed to add characteristic, err 0x%04x"
msgstr "Não pode parar propaganda. status: 0x%02x"
-#: ports/nrf/common-hal/bleio/Device.c
-#, fuzzy
-msgid "Failed to add service"
-msgstr "Não pode parar propaganda. status: 0x%02x"
-
#: ports/nrf/common-hal/bleio/Peripheral.c
#, fuzzy, c-format
msgid "Failed to add service, err 0x%04x"
@@ -597,12 +580,13 @@ msgstr "Falha ao alocar buffer RX de %d bytes"
msgid "Failed to change softdevice state"
msgstr "Não pode parar propaganda. status: 0x%02x"
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Failed to connect:"
+#: ports/nrf/common-hal/bleio/Peripheral.c
+#, c-format
+msgid "Failed to configure advertising, err 0x%04x"
msgstr ""
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Failed to continue scanning"
+#: ports/nrf/common-hal/bleio/Central.c
+msgid "Failed to connect: timeout"
msgstr ""
#: ports/nrf/common-hal/bleio/Scanner.c
@@ -610,12 +594,7 @@ msgstr ""
msgid "Failed to continue scanning, err 0x%04x"
msgstr "Não é possível iniciar o anúncio. status: 0x%02x"
-#: ports/nrf/common-hal/bleio/Device.c
-#, fuzzy
-msgid "Failed to create mutex"
-msgstr "Não é possível ler o valor do atributo. status: 0x%02x"
-
-#: ports/nrf/common-hal/bleio/Device.c
+#: ports/nrf/common-hal/bleio/Central.c
#, fuzzy
msgid "Failed to discover services"
msgstr "Não pode parar propaganda. status: 0x%02x"
@@ -654,49 +633,42 @@ msgstr "Não é possível gravar o valor do atributo. status: 0x%02x"
msgid "Failed to register Vendor-Specific UUID, err 0x%04x"
msgstr "Não é possível adicionar o UUID de 128 bits específico do fornecedor."
-#: ports/nrf/common-hal/bleio/Device.c
-#, fuzzy
-msgid "Failed to release mutex"
-msgstr "Não é possível ler o valor do atributo. status: 0x%02x"
-
-#: ports/nrf/common-hal/bleio/Characteristic.c ports/nrf/sd_mutex.c
+#: ports/nrf/sd_mutex.c
#, fuzzy, c-format
msgid "Failed to release mutex, err 0x%04x"
msgstr "Não é possível ler o valor do atributo. status: 0x%02x"
-#: ports/nrf/common-hal/bleio/Device.c
-#, fuzzy
-msgid "Failed to start advertising"
-msgstr "Não é possível iniciar o anúncio. status: 0x%02x"
+#: ports/nrf/common-hal/bleio/Peripheral.c
+#, c-format
+msgid "Failed to set device name, err 0x%04x"
+msgstr ""
-#: ports/nrf/common-hal/bleio/Broadcaster.c
#: ports/nrf/common-hal/bleio/Peripheral.c
#, fuzzy, c-format
msgid "Failed to start advertising, err 0x%04x"
msgstr "Não é possível iniciar o anúncio. status: 0x%02x"
-#: ports/nrf/common-hal/bleio/Device.c
-#, fuzzy
-msgid "Failed to start scanning"
-msgstr "Não é possível iniciar o anúncio. status: 0x%02x"
+#: ports/nrf/common-hal/bleio/Central.c
+#, c-format
+msgid "Failed to start connecting, error 0x%04x"
+msgstr ""
#: ports/nrf/common-hal/bleio/Scanner.c
#, fuzzy, c-format
msgid "Failed to start scanning, err 0x%04x"
msgstr "Não é possível iniciar o anúncio. status: 0x%02x"
-#: ports/nrf/common-hal/bleio/Device.c
-#, fuzzy
-msgid "Failed to stop advertising"
-msgstr "Não pode parar propaganda. status: 0x%02x"
-
-#: ports/nrf/common-hal/bleio/Broadcaster.c
#: ports/nrf/common-hal/bleio/Peripheral.c
#, fuzzy, c-format
msgid "Failed to stop advertising, err 0x%04x"
msgstr "Não pode parar propaganda. status: 0x%02x"
#: ports/nrf/common-hal/bleio/Characteristic.c
+#, c-format
+msgid "Failed to write CCCD, err 0x%04x"
+msgstr ""
+
+#: ports/nrf/common-hal/bleio/Characteristic.c
#, fuzzy, c-format
msgid "Failed to write attribute value, err 0x%04x"
msgstr "Não é possível gravar o valor do atributo. status: 0x%02x"
@@ -914,6 +886,10 @@ msgstr ""
msgid "Must be a %q subclass."
msgstr ""
+#: ports/nrf/common-hal/bleio/Characteristic.c
+msgid "No CCCD for this Characteristic"
+msgstr ""
+
#: ports/atmel-samd/common-hal/analogio/AnalogOut.c
msgid "No DAC on chip"
msgstr "Nenhum DAC no chip"
@@ -964,6 +940,7 @@ msgstr ""
msgid "No such file/directory"
msgstr ""
+#: ports/nrf/common-hal/bleio/Characteristic.c
#: shared-bindings/bleio/CharacteristicBuffer.c
#, fuzzy
msgid "Not connected"
@@ -1199,7 +1176,8 @@ msgstr "Para sair, por favor, reinicie a placa sem "
msgid "Too many channels in sample."
msgstr "Muitos canais na amostra."
-#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c
+#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/I2CDisplay.c
+#: shared-bindings/displayio/ParallelBus.c
msgid "Too many display busses"
msgstr ""
@@ -1224,7 +1202,7 @@ msgid "USB Error"
msgstr "Erro na USB"
#: shared-bindings/bleio/UUID.c
-msgid "UUID integer value not in range 0 to 0xffff"
+msgid "UUID integer value must be 0-0xffff"
msgstr ""
#: shared-bindings/bleio/UUID.c
@@ -1240,6 +1218,11 @@ msgstr ""
msgid "Unable to allocate buffers for signed conversion"
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 ""
+
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
msgid "Unable to find free GCLK"
@@ -1917,8 +1900,9 @@ msgstr ""
msgid "integer required"
msgstr "inteiro requerido"
-#: ports/nrf/common-hal/bleio/Broadcaster.c
-msgid "interval not in range 0.0020 to 10.24"
+#: shared-bindings/bleio/Peripheral.c shared-bindings/bleio/Scanner.c
+#, c-format
+msgid "interval must be in range %s-%s"
msgstr ""
#: extmod/machine_i2c.c
@@ -2133,6 +2117,14 @@ msgstr ""
msgid "no such attribute"
msgstr ""
+#: shared-bindings/bleio/Peripheral.c
+msgid "non-Service found in services"
+msgstr ""
+
+#: ports/nrf/common-hal/bleio/Central.c
+msgid "non-UUID found in service_uuids"
+msgstr ""
+
#: py/compile.c
msgid "non-default argument follows default argument"
msgstr ""
@@ -2342,10 +2334,6 @@ msgstr ""
msgid "script compilation not supported"
msgstr "compilação de script não suportada"
-#: shared-bindings/bleio/Peripheral.c
-msgid "services includes an object that is not a Service"
-msgstr ""
-
#: py/objstr.c
msgid "sign not allowed in string format specifier"
msgstr ""
@@ -2614,6 +2602,10 @@ msgstr ""
msgid "value_count must be > 0"
msgstr ""
+#: shared-bindings/bleio/Scanner.c
+msgid "window must be <= interval"
+msgstr ""
+
#: shared-bindings/_pixelbuf/PixelBuf.c
msgid "write_args must be a list, tuple, or None"
msgstr ""
@@ -2657,6 +2649,10 @@ msgstr "passo zero"
#~ msgid "Cannot update i/f status"
#~ msgstr "Não é possível atualizar o status i/f"
+#, fuzzy
+#~ msgid "Data too large for the advertisement packet"
+#~ msgstr "Não é possível ajustar dados no pacote de anúncios."
+
#~ msgid "Don't know how to pass object to native function"
#~ msgstr "Não sabe como passar o objeto para a função nativa"
@@ -2670,6 +2666,18 @@ msgstr "passo zero"
#~ msgstr "Erro no ffi_prep_cif"
#, fuzzy
+#~ msgid "Failed to acquire mutex"
+#~ msgstr "Falha ao alocar buffer RX"
+
+#, fuzzy
+#~ msgid "Failed to add service"
+#~ msgstr "Não pode parar propaganda. status: 0x%02x"
+
+#, fuzzy
+#~ msgid "Failed to create mutex"
+#~ msgstr "Não é possível ler o valor do atributo. status: 0x%02x"
+
+#, fuzzy
#~ msgid "Failed to notify or indicate attribute value, err %0x04x"
#~ msgstr "Não é possível gravar o valor do atributo. status: 0x%02x"
@@ -2677,6 +2685,22 @@ msgstr "passo zero"
#~ msgid "Failed to read attribute value, err %0x04x"
#~ msgstr "Não é possível ler o valor do atributo. status: 0x%02x"
+#, fuzzy
+#~ msgid "Failed to release mutex"
+#~ msgstr "Não é possível ler o valor do atributo. status: 0x%02x"
+
+#, fuzzy
+#~ msgid "Failed to start advertising"
+#~ msgstr "Não é possível iniciar o anúncio. status: 0x%02x"
+
+#, fuzzy
+#~ msgid "Failed to start scanning"
+#~ msgstr "Não é possível iniciar o anúncio. status: 0x%02x"
+
+#, fuzzy
+#~ msgid "Failed to stop advertising"
+#~ msgstr "Não pode parar propaganda. status: 0x%02x"
+
#~ msgid "GPIO16 does not support pull up."
#~ msgstr "GPIO16 não suporta pull up."
diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po
index 47333d55a..258a4d3df 100644
--- a/locale/zh_Latn_pinyin.po
+++ b/locale/zh_Latn_pinyin.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: circuitpython-cn\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2019-06-25 17:53-0700\n"
+"POT-Creation-Date: 2019-07-19 16:10-0700\n"
"PO-Revision-Date: 2019-04-13 10:10-0700\n"
"Last-Translator: hexthat\n"
"Language-Team: Chinese Hanyu Pinyin\n"
@@ -221,14 +221,13 @@ msgstr "Yìngjiàn zhōngduàn tōngdào yǐ zài shǐyòng zhōng"
#: shared-bindings/bleio/Address.c
#, c-format
-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ù"
-
-#: shared-bindings/bleio/Address.c
-#, c-format
msgid "Address must be %d bytes long"
msgstr "Dìzhǐ bìxū shì %d zì jié zhǎng"
+#: shared-bindings/bleio/Address.c
+msgid "Address type out of range"
+msgstr ""
+
#: ports/nrf/common-hal/busio/I2C.c
msgid "All I2C peripherals are in use"
msgstr "Suǒyǒu I2C wàiwéi qì zhèngzài shǐyòng"
@@ -313,6 +312,10 @@ msgstr "Bǐtè shēndù bìxū shì 8 bèi yǐshàng."
msgid "Both pins must support hardware interrupts"
msgstr "Liǎng gè yǐn jiǎo dōu bìxū zhīchí yìngjiàn zhōngduàn"
+#: shared-bindings/displayio/Display.c
+msgid "Brightness must be 0-1.0"
+msgstr ""
+
#: shared-bindings/supervisor/__init__.c
msgid "Brightness must be between 0 and 255"
msgstr "Liàngdù bìxū jiè yú 0 dào 255 zhī jiān"
@@ -353,21 +356,9 @@ msgstr ""
msgid "Can not use dotstar with %s"
msgstr "Wúfǎ yǔ dotstar yīqǐ shǐyòng %s"
-#: shared-bindings/bleio/Device.c
-msgid "Can't add services in Central mode"
-msgstr "Wúfǎ zài zhōngyāng móshì xià tiānjiā fúwù"
-
-#: shared-bindings/bleio/Device.c
-msgid "Can't advertise in Central mode"
-msgstr "Wúfǎ zài zhōngyāng móshì zhōng guǎnggào"
-
-#: shared-bindings/bleio/Device.c
-msgid "Can't change the name in Central mode"
-msgstr "Wúfǎ gēnggǎi zhōngyāng móshì de míngchēng"
-
-#: shared-bindings/bleio/Device.c
-msgid "Can't connect in Peripheral mode"
-msgstr "Wúfǎ zài biānyuán móshì zhōng liánjiē"
+#: ports/nrf/common-hal/bleio/Characteristic.c
+msgid "Can't set CCCD for local Characteristic"
+msgstr ""
#: shared-bindings/displayio/Bitmap.c shared-bindings/pulseio/PulseIn.c
msgid "Cannot delete values"
@@ -450,6 +441,10 @@ msgstr "Shǐyòng shízhōng dānwèi"
msgid "Column entry must be digitalio.DigitalInOut"
msgstr "Liè tiáomù bìxū shì digitalio.DigitalInOut"
+#: shared-bindings/displayio/I2CDisplay.c
+msgid "Command must be 0-255"
+msgstr ""
+
#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c
msgid "Command must be an int between 0 and 255"
msgstr "Mìnglìng bìxū shì 0 dào 255 zhī jiān de int"
@@ -496,15 +491,10 @@ msgstr "Shùjù 0 de yǐn jiǎo bìxū shì zì jié duìqí"
msgid "Data chunk must follow fmt chunk"
msgstr "Shùjù kuài bìxū zūnxún fmt qū kuài"
-#: ports/nrf/common-hal/bleio/Broadcaster.c
#: ports/nrf/common-hal/bleio/Peripheral.c
msgid "Data too large for advertisement packet"
msgstr "Guǎnggào bāo de shùjù tài dà"
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Data too large for the advertisement packet"
-msgstr "Guǎnggào bāo de shùjù tài dà"
-
#: shared-bindings/audiobusio/PDMIn.c
msgid "Destination capacity is smaller than destination_length."
msgstr "Mùbiāo róngliàng xiǎoyú mùdì de_chángdù."
@@ -542,6 +532,10 @@ msgstr "Yùqí de tèdiǎn"
msgid "Expected a UUID"
msgstr "Yùqí UUID"
+#: shared-bindings/bleio/Central.c
+msgid "Expected an Address"
+msgstr ""
+
#: shared-module/_pixelbuf/PixelBuf.c
#, c-format
msgid "Expected tuple of length %d, got %d"
@@ -551,11 +545,7 @@ msgstr "Qīwàng de chángdù wèi %d de yuán zǔ, dédào %d"
msgid "Failed sending command."
msgstr ""
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Failed to acquire mutex"
-msgstr "Wúfǎ huòdé mutex"
-
-#: ports/nrf/common-hal/bleio/Characteristic.c ports/nrf/sd_mutex.c
+#: ports/nrf/sd_mutex.c
#, c-format
msgid "Failed to acquire mutex, err 0x%04x"
msgstr "Wúfǎ huòdé mutex, err 0x%04x"
@@ -565,10 +555,6 @@ msgstr "Wúfǎ huòdé mutex, err 0x%04x"
msgid "Failed to add characteristic, err 0x%04x"
msgstr "Tiānjiā tèxìng shībài, err 0x%04x"
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Failed to add service"
-msgstr "Tiānjiā fúwù shībài"
-
#: ports/nrf/common-hal/bleio/Peripheral.c
#, c-format
msgid "Failed to add service, err 0x%04x"
@@ -588,24 +574,21 @@ msgstr "Fēnpèi RX huǎnchōng qū%d zì jié shībài"
msgid "Failed to change softdevice state"
msgstr "Gēnggǎi ruǎn shèbèi zhuàngtài shībài"
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Failed to connect:"
-msgstr "Liánjiē shībài:"
+#: ports/nrf/common-hal/bleio/Peripheral.c
+#, c-format
+msgid "Failed to configure advertising, err 0x%04x"
+msgstr ""
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Failed to continue scanning"
-msgstr "Jìxù sǎomiáo shībài"
+#: ports/nrf/common-hal/bleio/Central.c
+msgid "Failed to connect: timeout"
+msgstr ""
#: ports/nrf/common-hal/bleio/Scanner.c
#, c-format
msgid "Failed to continue scanning, err 0x%04x"
msgstr "Jìxù sǎomiáo shībài, err 0x%04x"
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Failed to create mutex"
-msgstr "Wúfǎ chuàngjiàn hù chì suǒ"
-
-#: ports/nrf/common-hal/bleio/Device.c
+#: ports/nrf/common-hal/bleio/Central.c
msgid "Failed to discover services"
msgstr "Fāxiàn fúwù shībài"
@@ -642,39 +625,31 @@ msgstr "Wúfǎ dòu qǔ gatts zhí, err 0x%04x"
msgid "Failed to register Vendor-Specific UUID, err 0x%04x"
msgstr "Wúfǎ zhùcè màizhǔ tèdìng de UUID, err 0x%04x"
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Failed to release mutex"
-msgstr "Wúfǎ shìfàng mutex"
-
-#: ports/nrf/common-hal/bleio/Characteristic.c ports/nrf/sd_mutex.c
+#: ports/nrf/sd_mutex.c
#, c-format
msgid "Failed to release mutex, err 0x%04x"
msgstr "Wúfǎ shìfàng mutex, err 0x%04x"
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Failed to start advertising"
-msgstr "Qǐdòng guǎnggào shībài"
+#: ports/nrf/common-hal/bleio/Peripheral.c
+#, c-format
+msgid "Failed to set device name, err 0x%04x"
+msgstr ""
-#: ports/nrf/common-hal/bleio/Broadcaster.c
#: ports/nrf/common-hal/bleio/Peripheral.c
#, c-format
msgid "Failed to start advertising, err 0x%04x"
msgstr "Qǐdòng guǎnggào shībài, err 0x%04x"
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Failed to start scanning"
-msgstr "Qǐdòng sǎomiáo shībài"
+#: ports/nrf/common-hal/bleio/Central.c
+#, c-format
+msgid "Failed to start connecting, error 0x%04x"
+msgstr ""
#: ports/nrf/common-hal/bleio/Scanner.c
#, c-format
msgid "Failed to start scanning, err 0x%04x"
msgstr "Qǐdòng sǎomiáo shībài, err 0x%04x"
-#: ports/nrf/common-hal/bleio/Device.c
-msgid "Failed to stop advertising"
-msgstr "Wúfǎ tíngzhǐ guǎnggào"
-
-#: ports/nrf/common-hal/bleio/Broadcaster.c
#: ports/nrf/common-hal/bleio/Peripheral.c
#, c-format
msgid "Failed to stop advertising, err 0x%04x"
@@ -682,6 +657,11 @@ msgstr "Wúfǎ tíngzhǐ guǎnggào, err 0x%04x"
#: ports/nrf/common-hal/bleio/Characteristic.c
#, c-format
+msgid "Failed to write CCCD, err 0x%04x"
+msgstr ""
+
+#: ports/nrf/common-hal/bleio/Characteristic.c
+#, c-format
msgid "Failed to write attribute value, err 0x%04x"
msgstr "Xiě rù shǔxìng zhí shībài, err 0x%04x"
@@ -901,6 +881,10 @@ msgstr "Màikèfēng qǐdòng yánchí bìxū zài 0.0 Dào 1.0 De fànwéi nèi
msgid "Must be a %q subclass."
msgstr ""
+#: ports/nrf/common-hal/bleio/Characteristic.c
+msgid "No CCCD for this Characteristic"
+msgstr ""
+
#: ports/atmel-samd/common-hal/analogio/AnalogOut.c
msgid "No DAC on chip"
msgstr "Méiyǒu DAC zài xīnpiàn shàng de"
@@ -951,6 +935,7 @@ msgstr "Shèbèi shàng méiyǒu kònggé"
msgid "No such file/directory"
msgstr "Méiyǒu cǐ lèi wénjiàn/mùlù"
+#: ports/nrf/common-hal/bleio/Characteristic.c
#: shared-bindings/bleio/CharacteristicBuffer.c
msgid "Not connected"
msgstr "Wèi liánjiē"
@@ -1196,7 +1181,8 @@ msgstr "Yào tuìchū, qǐng chóng zhì bǎnkuài ér bùyòng "
msgid "Too many channels in sample."
msgstr "Chōuyàng zhōng de píndào tài duō."
-#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/ParallelBus.c
+#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/I2CDisplay.c
+#: shared-bindings/displayio/ParallelBus.c
msgid "Too many display busses"
msgstr "Xiǎnshì zǒngxiàn tài duōle"
@@ -1221,8 +1207,8 @@ msgid "USB Error"
msgstr "USB Cuòwù"
#: shared-bindings/bleio/UUID.c
-msgid "UUID integer value not in range 0 to 0xffff"
-msgstr "UUID zhěngshù zhí bùzài fànwéi 0 zhì 0xffff"
+msgid "UUID integer value must be 0-0xffff"
+msgstr ""
#: shared-bindings/bleio/UUID.c
msgid "UUID string not 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'"
@@ -1237,6 +1223,11 @@ msgstr "UUID zhí bùshì str,int huò zì jié huǎnchōng qū"
msgid "Unable to allocate buffers for signed conversion"
msgstr "Wúfǎ fēnpèi huǎnchōng qū yòng yú qiānmíng zhuǎnhuàn"
+#: shared-module/displayio/I2CDisplay.c
+#, c-format
+msgid "Unable to find I2C Display at %x"
+msgstr ""
+
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
msgid "Unable to find free GCLK"
@@ -1919,9 +1910,10 @@ msgstr "zhěngshù() cānshù 2 bìxū > = 2 qiě <= 36"
msgid "integer required"
msgstr "xūyào zhěngshù"
-#: ports/nrf/common-hal/bleio/Broadcaster.c
-msgid "interval not in range 0.0020 to 10.24"
-msgstr "jùlí 0.0020 Zhì 10.24 Zhī jiān de jiàngé shíjiān"
+#: shared-bindings/bleio/Peripheral.c shared-bindings/bleio/Scanner.c
+#, c-format
+msgid "interval must be in range %s-%s"
+msgstr ""
#: extmod/machine_i2c.c
msgid "invalid I2C peripheral"
@@ -2136,6 +2128,14 @@ msgstr "méiyǒu mókuài '%q'"
msgid "no such attribute"
msgstr "méiyǒu cǐ shǔxìng"
+#: shared-bindings/bleio/Peripheral.c
+msgid "non-Service found in services"
+msgstr ""
+
+#: ports/nrf/common-hal/bleio/Central.c
+msgid "non-UUID found in service_uuids"
+msgstr ""
+
#: py/compile.c
msgid "non-default argument follows default argument"
msgstr "bùshì mòrèn cānshù zūnxún mòrèn cānshù"
@@ -2346,10 +2346,6 @@ msgstr "jìhuà duīzhàn yǐ mǎn"
msgid "script compilation not supported"
msgstr "bù zhīchí jiǎoběn biānyì"
-#: shared-bindings/bleio/Peripheral.c
-msgid "services includes an object that is not a Service"
-msgstr "fúwù bāokuò yīgè bùshì fúwù de wùjiàn"
-
#: py/objstr.c
msgid "sign not allowed in string format specifier"
msgstr "zìfú chuàn géshì shuōmíng fú zhōng bù yǔnxǔ shǐyòng fúhào"
@@ -2616,6 +2612,10 @@ msgstr ""
msgid "value_count must be > 0"
msgstr "zhí jìshù bìxū wèi > 0"
+#: shared-bindings/bleio/Scanner.c
+msgid "window must be <= interval"
+msgstr ""
+
#: shared-bindings/_pixelbuf/PixelBuf.c
msgid "write_args must be a list, tuple, or None"
msgstr "xiě cānshù bìxū shì yuán zǔ, lièbiǎo huò None"
@@ -2644,6 +2644,51 @@ msgstr "y zhí chāochū biānjiè"
msgid "zero step"
msgstr "líng bù"
+#~ 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ù"
+
+#~ msgid "Can't add services in Central mode"
+#~ msgstr "Wúfǎ zài zhōngyāng móshì xià tiānjiā fúwù"
+
+#~ msgid "Can't advertise in Central mode"
+#~ msgstr "Wúfǎ zài zhōngyāng móshì zhōng guǎnggào"
+
+#~ msgid "Can't change the name in Central mode"
+#~ msgstr "Wúfǎ gēnggǎi zhōngyāng móshì de míngchēng"
+
+#~ msgid "Can't connect in Peripheral mode"
+#~ msgstr "Wúfǎ zài biānyuán móshì zhōng liánjiē"
+
+#~ msgid "Data too large for the advertisement packet"
+#~ msgstr "Guǎnggào bāo de shùjù tài dà"
+
+#~ msgid "Failed to acquire mutex"
+#~ msgstr "Wúfǎ huòdé mutex"
+
+#~ msgid "Failed to add service"
+#~ msgstr "Tiānjiā fúwù shībài"
+
+#~ msgid "Failed to connect:"
+#~ msgstr "Liánjiē shībài:"
+
+#~ msgid "Failed to continue scanning"
+#~ msgstr "Jìxù sǎomiáo shībài"
+
+#~ msgid "Failed to create mutex"
+#~ msgstr "Wúfǎ chuàngjiàn hù chì suǒ"
+
+#~ msgid "Failed to release mutex"
+#~ msgstr "Wúfǎ shìfàng mutex"
+
+#~ msgid "Failed to start advertising"
+#~ msgstr "Qǐdòng guǎnggào shībài"
+
+#~ msgid "Failed to start scanning"
+#~ msgstr "Qǐdòng sǎomiáo shībài"
+
+#~ msgid "Failed to stop advertising"
+#~ msgstr "Wúfǎ tíngzhǐ guǎnggào"
+
#~ msgid "Invalid bit clock pin"
#~ msgstr "Wúxiào de wèi shízhōng yǐn jiǎo"
@@ -2668,12 +2713,21 @@ msgstr "líng bù"
#~ msgid "Only bit maps of 8 bit color or less are supported"
#~ msgstr "Jǐn zhīchí 8 wèi yánsè huò xiǎoyú"
+#~ msgid "UUID integer value not in range 0 to 0xffff"
+#~ msgstr "UUID zhěngshù zhí bùzài fànwéi 0 zhì 0xffff"
+
#~ msgid "expected a DigitalInOut"
#~ msgstr "qídài de DigitalInOut"
+#~ msgid "interval not in range 0.0020 to 10.24"
+#~ msgstr "jùlí 0.0020 Zhì 10.24 Zhī jiān de jiàngé shíjiān"
+
#~ msgid "row must be packed and word aligned"
#~ msgstr "xíng bìxū dǎbāo bìngqiě zì duìqí"
+#~ msgid "services includes an object that is not a Service"
+#~ msgstr "fúwù bāokuò yīgè bùshì fúwù de wùjiàn"
+
#~ msgid "too many arguments"
#~ msgstr "tài duō cānshù"
diff --git a/main.c b/main.c
index 6d7502ba4..6ab50fc3c 100755
--- a/main.c
+++ b/main.c
@@ -45,7 +45,6 @@
#include "background.h"
#include "mpconfigboard.h"
-#include "shared-module/displayio/__init__.h"
#include "supervisor/cpu.h"
#include "supervisor/memory.h"
#include "supervisor/port.h"
@@ -58,6 +57,10 @@
#include "supervisor/shared/stack.h"
#include "supervisor/serial.h"
+#if CIRCUITPY_DISPLAYIO
+#include "shared-module/displayio/__init__.h"
+#endif
+
#if CIRCUITPY_NETWORK
#include "shared-module/network/__init__.h"
#endif
@@ -187,7 +190,9 @@ void cleanup_after_vm(supervisor_allocation* heap) {
supervisor_move_memory();
reset_port();
+ #if CIRCUITPY_BOARD
reset_board_busses();
+ #endif
reset_board();
reset_status_led();
}
diff --git a/ports/atmel-samd/README.rst b/ports/atmel-samd/README.rst
index 167373b26..9afa19b83 100644
--- a/ports/atmel-samd/README.rst
+++ b/ports/atmel-samd/README.rst
@@ -124,15 +124,20 @@ Setup
-----
An ARM compiler is required for the build, along with the associated binary
-utilities. On Ubuntu, these can be installed as follows:
+utilities. They can be installed as follows:
-.. code-block:: shell
+- Ubuntu
+
+ .. code-block:: shell
+
+ sudo add-apt-repository ppa:team-gcc-arm-embedded/ppa
+ sudo apt-get install gcc-arm-embedded
+
+- Arch Linux
- sudo add-apt-repository ppa:team-gcc-arm-embedded/ppa
- sudo apt-get install gcc-arm-embedded
+ .. code-block:: shell
-On Arch Linux the compiler is available for via the package
-``arm-none-eabi-gcc``.
+ sudo pacman -S arm-none-eabi-gcc arm-none-eabi-newlib
For other systems, the `GNU Arm Embedded Toolchain <https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads>`_
may be available in binary form.
diff --git a/ports/atmel-samd/audio_dma.c b/ports/atmel-samd/audio_dma.c
index 68d6f182d..6b5eeddcc 100644
--- a/ports/atmel-samd/audio_dma.c
+++ b/ports/atmel-samd/audio_dma.c
@@ -29,8 +29,8 @@
#include "samd/events.h"
#include "samd/dma.h"
-#include "shared-bindings/audioio/RawSample.h"
-#include "shared-bindings/audioio/WaveFile.h"
+#include "shared-bindings/audiocore/RawSample.h"
+#include "shared-bindings/audiocore/WaveFile.h"
#include "py/mpstate.h"
#include "py/runtime.h"
diff --git a/ports/atmel-samd/audio_dma.h b/ports/atmel-samd/audio_dma.h
index 041d675a2..53173c277 100644
--- a/ports/atmel-samd/audio_dma.h
+++ b/ports/atmel-samd/audio_dma.h
@@ -29,8 +29,8 @@
#include "extmod/vfs_fat.h"
#include "py/obj.h"
-#include "shared-module/audioio/RawSample.h"
-#include "shared-module/audioio/WaveFile.h"
+#include "shared-module/audiocore/RawSample.h"
+#include "shared-module/audiocore/WaveFile.h"
typedef struct {
mp_obj_t sample;
diff --git a/ports/atmel-samd/boards/datum_distance/board.c b/ports/atmel-samd/boards/datum_distance/board.c
new file mode 100644
index 000000000..c8e20206a
--- /dev/null
+++ b/ports/atmel-samd/boards/datum_distance/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/atmel-samd/boards/datum_distance/mpconfigboard.h b/ports/atmel-samd/boards/datum_distance/mpconfigboard.h
new file mode 100644
index 000000000..e02e43780
--- /dev/null
+++ b/ports/atmel-samd/boards/datum_distance/mpconfigboard.h
@@ -0,0 +1,29 @@
+// LEDs
+#define MICROPY_HW_LED_STATUS (&pin_PA17)
+#define MICROPY_HW_LED_TX &pin_PA27
+#define MICROPY_HW_LED_RX &pin_PA17
+
+#define MICROPY_HW_BOARD_NAME "J&J Studios datum-Distance"
+#define MICROPY_HW_MCU_NAME "samd21g18"
+
+#define MICROPY_PORT_A (0)
+#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_PA23)
+#define DEFAULT_I2C_BUS_SDA (&pin_PA22)
+
+#define DEFAULT_SPI_BUS_SCK (&pin_PB11)
+#define DEFAULT_SPI_BUS_MOSI (&pin_PB10)
+#define DEFAULT_SPI_BUS_MISO (&pin_PA12)
+
+#define DEFAULT_UART_BUS_RX (&pin_PA11)
+#define DEFAULT_UART_BUS_TX (&pin_PA10)
+
+// USB is always used internally so skip the pin objects for it.
+#define IGNORE_PIN_PA24 1
+#define IGNORE_PIN_PA25 1
diff --git a/ports/atmel-samd/boards/datum_distance/mpconfigboard.mk b/ports/atmel-samd/boards/datum_distance/mpconfigboard.mk
new file mode 100644
index 000000000..a7bb8293d
--- /dev/null
+++ b/ports/atmel-samd/boards/datum_distance/mpconfigboard.mk
@@ -0,0 +1,14 @@
+LD_FILE = boards/samd21x18-bootloader.ld
+USB_VID = 0x04D8
+USB_PID = 0xEE8C
+USB_PRODUCT = "datum-Distance"
+USB_MANUFACTURER = "J&J Studios LLC"
+
+CHIP_VARIANT = SAMD21G18A
+CHIP_FAMILY = samd21
+
+INTERNAL_FLASH_FILESYSTEM = 1
+LONGINT_IMPL = NONE
+CIRCUITPY_SMALL_BUILD = 1
+
+SUPEROPT_GC = 0
diff --git a/ports/atmel-samd/boards/datum_distance/pins.c b/ports/atmel-samd/boards/datum_distance/pins.c
new file mode 100644
index 000000000..b29a859b6
--- /dev/null
+++ b/ports/atmel-samd/boards/datum_distance/pins.c
@@ -0,0 +1,27 @@
+#include "shared-bindings/board/__init__.h"
+
+STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
+ { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PB11) },
+ { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PB10) },
+ { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PA12) },
+ { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_PA11) },
+ { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PA11) },
+ { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_PA10) },
+ { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PA10) },
+ { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PA22) },
+ { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PA23) },
+ { MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_PA09) },
+ { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_PA08) },
+ { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PA20) },
+ { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_PA21) },
+ { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_PA06) },
+ { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_PA07) },
+ { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PA18) },
+ { 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_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/atmel-samd/boards/datum_imu/board.c b/ports/atmel-samd/boards/datum_imu/board.c
new file mode 100644
index 000000000..c8e20206a
--- /dev/null
+++ b/ports/atmel-samd/boards/datum_imu/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/atmel-samd/boards/datum_imu/mpconfigboard.h b/ports/atmel-samd/boards/datum_imu/mpconfigboard.h
new file mode 100644
index 000000000..b87739dd0
--- /dev/null
+++ b/ports/atmel-samd/boards/datum_imu/mpconfigboard.h
@@ -0,0 +1,29 @@
+// LEDs
+#define MICROPY_HW_LED_STATUS (&pin_PA17)
+#define MICROPY_HW_LED_TX &pin_PA27
+#define MICROPY_HW_LED_RX &pin_PA17
+
+#define MICROPY_HW_BOARD_NAME "J&J Studios datum-IMU"
+#define MICROPY_HW_MCU_NAME "samd21g18"
+
+#define MICROPY_PORT_A (0)
+#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_PA23)
+#define DEFAULT_I2C_BUS_SDA (&pin_PA22)
+
+#define DEFAULT_SPI_BUS_SCK (&pin_PB11)
+#define DEFAULT_SPI_BUS_MOSI (&pin_PB10)
+#define DEFAULT_SPI_BUS_MISO (&pin_PA12)
+
+#define DEFAULT_UART_BUS_RX (&pin_PA11)
+#define DEFAULT_UART_BUS_TX (&pin_PA10)
+
+// USB is always used internally so skip the pin objects for it.
+#define IGNORE_PIN_PA24 1
+#define IGNORE_PIN_PA25 1
diff --git a/ports/atmel-samd/boards/datum_imu/mpconfigboard.mk b/ports/atmel-samd/boards/datum_imu/mpconfigboard.mk
new file mode 100644
index 000000000..507c83b04
--- /dev/null
+++ b/ports/atmel-samd/boards/datum_imu/mpconfigboard.mk
@@ -0,0 +1,14 @@
+LD_FILE = boards/samd21x18-bootloader.ld
+USB_VID = 0x04D8
+USB_PID = 0xEE8D
+USB_PRODUCT = "datum-IMU"
+USB_MANUFACTURER = "J&J Studios LLC"
+
+CHIP_VARIANT = SAMD21G18A
+CHIP_FAMILY = samd21
+
+INTERNAL_FLASH_FILESYSTEM = 1
+LONGINT_IMPL = NONE
+CIRCUITPY_SMALL_BUILD = 1
+
+SUPEROPT_GC = 0
diff --git a/ports/atmel-samd/boards/datum_imu/pins.c b/ports/atmel-samd/boards/datum_imu/pins.c
new file mode 100644
index 000000000..237b5774e
--- /dev/null
+++ b/ports/atmel-samd/boards/datum_imu/pins.c
@@ -0,0 +1,29 @@
+#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_PA02) },
+ { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PA03) },
+ { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PB11) },
+ { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PB10) },
+ { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PA12) },
+ { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_PA11) },
+ { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PA11) },
+ { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_PA10) },
+ { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PA10) },
+ { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PA22) },
+ { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PA23) },
+ { MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_PA09) },
+ { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_PA08) },
+ { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PA20) },
+ { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_PA21) },
+ { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_PA06) },
+ { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_PA07) },
+ { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PA18) },
+ { 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_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/atmel-samd/boards/datum_light/board.c b/ports/atmel-samd/boards/datum_light/board.c
new file mode 100644
index 000000000..c8e20206a
--- /dev/null
+++ b/ports/atmel-samd/boards/datum_light/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/atmel-samd/boards/datum_light/mpconfigboard.h b/ports/atmel-samd/boards/datum_light/mpconfigboard.h
new file mode 100644
index 000000000..2a91c112d
--- /dev/null
+++ b/ports/atmel-samd/boards/datum_light/mpconfigboard.h
@@ -0,0 +1,29 @@
+// LEDs
+#define MICROPY_HW_LED_STATUS (&pin_PA17)
+#define MICROPY_HW_LED_TX &pin_PA27
+#define MICROPY_HW_LED_RX &pin_PA17
+
+#define MICROPY_HW_BOARD_NAME "J&J Studios datum-Light"
+#define MICROPY_HW_MCU_NAME "samd21g18"
+
+#define MICROPY_PORT_A (0)
+#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_PA23)
+#define DEFAULT_I2C_BUS_SDA (&pin_PA22)
+
+#define DEFAULT_SPI_BUS_SCK (&pin_PB11)
+#define DEFAULT_SPI_BUS_MOSI (&pin_PB10)
+#define DEFAULT_SPI_BUS_MISO (&pin_PA12)
+
+#define DEFAULT_UART_BUS_RX (&pin_PA11)
+#define DEFAULT_UART_BUS_TX (&pin_PA10)
+
+// USB is always used internally so skip the pin objects for it.
+#define IGNORE_PIN_PA24 1
+#define IGNORE_PIN_PA25 1
diff --git a/ports/atmel-samd/boards/datum_light/mpconfigboard.mk b/ports/atmel-samd/boards/datum_light/mpconfigboard.mk
new file mode 100644
index 000000000..4bb227ba4
--- /dev/null
+++ b/ports/atmel-samd/boards/datum_light/mpconfigboard.mk
@@ -0,0 +1,14 @@
+LD_FILE = boards/samd21x18-bootloader.ld
+USB_VID = 0x04D8
+USB_PID = 0xEE8E
+USB_PRODUCT = "datum-Light"
+USB_MANUFACTURER = "J&J Studios LLC"
+
+CHIP_VARIANT = SAMD21G18A
+CHIP_FAMILY = samd21
+
+INTERNAL_FLASH_FILESYSTEM = 1
+LONGINT_IMPL = NONE
+CIRCUITPY_SMALL_BUILD = 1
+
+SUPEROPT_GC = 0
diff --git a/ports/atmel-samd/boards/datum_light/pins.c b/ports/atmel-samd/boards/datum_light/pins.c
new file mode 100644
index 000000000..b29a859b6
--- /dev/null
+++ b/ports/atmel-samd/boards/datum_light/pins.c
@@ -0,0 +1,27 @@
+#include "shared-bindings/board/__init__.h"
+
+STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
+ { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PB11) },
+ { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PB10) },
+ { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PA12) },
+ { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_PA11) },
+ { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PA11) },
+ { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_PA10) },
+ { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PA10) },
+ { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PA22) },
+ { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PA23) },
+ { MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_PA09) },
+ { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_PA08) },
+ { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PA20) },
+ { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_PA21) },
+ { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_PA06) },
+ { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_PA07) },
+ { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PA18) },
+ { 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_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/atmel-samd/boards/datum_weather/board.c b/ports/atmel-samd/boards/datum_weather/board.c
new file mode 100644
index 000000000..c8e20206a
--- /dev/null
+++ b/ports/atmel-samd/boards/datum_weather/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/atmel-samd/boards/datum_weather/mpconfigboard.h b/ports/atmel-samd/boards/datum_weather/mpconfigboard.h
new file mode 100644
index 000000000..45619197b
--- /dev/null
+++ b/ports/atmel-samd/boards/datum_weather/mpconfigboard.h
@@ -0,0 +1,29 @@
+// LEDs
+#define MICROPY_HW_LED_STATUS (&pin_PA17)
+#define MICROPY_HW_LED_TX &pin_PA27
+#define MICROPY_HW_LED_RX &pin_PA17
+
+#define MICROPY_HW_BOARD_NAME "J&J Studios datum-Weather"
+#define MICROPY_HW_MCU_NAME "samd21g18"
+
+#define MICROPY_PORT_A (0)
+#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_PA23)
+#define DEFAULT_I2C_BUS_SDA (&pin_PA22)
+
+#define DEFAULT_SPI_BUS_SCK (&pin_PB11)
+#define DEFAULT_SPI_BUS_MOSI (&pin_PB10)
+#define DEFAULT_SPI_BUS_MISO (&pin_PA12)
+
+#define DEFAULT_UART_BUS_RX (&pin_PA11)
+#define DEFAULT_UART_BUS_TX (&pin_PA10)
+
+// USB is always used internally so skip the pin objects for it.
+#define IGNORE_PIN_PA24 1
+#define IGNORE_PIN_PA25 1
diff --git a/ports/atmel-samd/boards/datum_weather/mpconfigboard.mk b/ports/atmel-samd/boards/datum_weather/mpconfigboard.mk
new file mode 100644
index 000000000..411aee625
--- /dev/null
+++ b/ports/atmel-samd/boards/datum_weather/mpconfigboard.mk
@@ -0,0 +1,14 @@
+LD_FILE = boards/samd21x18-bootloader.ld
+USB_VID = 0x04D8
+USB_PID = 0xEE8F
+USB_PRODUCT = "datum-Weather"
+USB_MANUFACTURER = "J&J Studios LLC"
+
+CHIP_VARIANT = SAMD21G18A
+CHIP_FAMILY = samd21
+
+INTERNAL_FLASH_FILESYSTEM = 1
+LONGINT_IMPL = NONE
+CIRCUITPY_SMALL_BUILD = 1
+
+SUPEROPT_GC = 0
diff --git a/ports/atmel-samd/boards/datum_weather/pins.c b/ports/atmel-samd/boards/datum_weather/pins.c
new file mode 100644
index 000000000..b29a859b6
--- /dev/null
+++ b/ports/atmel-samd/boards/datum_weather/pins.c
@@ -0,0 +1,27 @@
+#include "shared-bindings/board/__init__.h"
+
+STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
+ { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PB11) },
+ { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PB10) },
+ { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PA12) },
+ { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_PA11) },
+ { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PA11) },
+ { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_PA10) },
+ { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PA10) },
+ { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PA22) },
+ { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PA23) },
+ { MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_PA09) },
+ { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_PA08) },
+ { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PA20) },
+ { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_PA21) },
+ { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_PA06) },
+ { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_PA07) },
+ { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PA18) },
+ { 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_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/atmel-samd/boards/hallowing_m0_express/board.c b/ports/atmel-samd/boards/hallowing_m0_express/board.c
index a0e160757..be1741c87 100644
--- a/ports/atmel-samd/boards/hallowing_m0_express/board.c
+++ b/ports/atmel-samd/boards/hallowing_m0_express/board.c
@@ -91,6 +91,8 @@ void board_init(void) {
1, // row start
0, // rotation
16, // Color depth
+ false, // Grayscale
+ false, // Pixels in a byte share a row. Only used for depth < 8
MIPI_COMMAND_SET_COLUMN_ADDRESS, // Set column command
MIPI_COMMAND_SET_PAGE_ADDRESS, // Set row command
MIPI_COMMAND_WRITE_MEMORY_START, // Write memory command
@@ -98,6 +100,7 @@ void board_init(void) {
display_init_sequence,
sizeof(display_init_sequence),
&pin_PA00,
+ NO_BRIGHTNESS_COMMAND,
1.0f, // brightness (ignored)
true, // auto_brightness
false, // single_byte_bounds
diff --git a/ports/atmel-samd/boards/hallowing_m0_express/mpconfigboard.mk b/ports/atmel-samd/boards/hallowing_m0_express/mpconfigboard.mk
index 8dfc741e5..92374721f 100644
--- a/ports/atmel-samd/boards/hallowing_m0_express/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/hallowing_m0_express/mpconfigboard.mk
@@ -16,6 +16,7 @@ LONGINT_IMPL = MPZ
CIRCUITPY_I2CSLAVE = 0
CIRCUITPY_FREQUENCYIO = 0
CIRCUITPY_AUDIOBUSIO = 0
+CIRCUITPY_BITBANGIO = 0
SUPEROPT_GC = 0
# Include these Python libraries in firmware.
diff --git a/ports/atmel-samd/boards/pybadge/board.c b/ports/atmel-samd/boards/pybadge/board.c
index 38902315a..c9dca0329 100644
--- a/ports/atmel-samd/boards/pybadge/board.c
+++ b/ports/atmel-samd/boards/pybadge/board.c
@@ -93,6 +93,8 @@ void board_init(void) {
0, // row start
270, // rotation
16, // Color depth
+ false, // grayscale
+ false, // pixels in byte share row. only used for depth < 8
MIPI_COMMAND_SET_COLUMN_ADDRESS, // Set column command
MIPI_COMMAND_SET_PAGE_ADDRESS, // Set row command
MIPI_COMMAND_WRITE_MEMORY_START, // Write memory command
@@ -100,6 +102,7 @@ void board_init(void) {
display_init_sequence,
sizeof(display_init_sequence),
&pin_PA01, // backlight pin
+ NO_BRIGHTNESS_COMMAND,
1.0f, // brightness (ignored)
true, // auto_brightness
false, // single_byte_bounds
diff --git a/ports/atmel-samd/boards/pybadge_airlift/board.c b/ports/atmel-samd/boards/pybadge_airlift/board.c
index a1f778df1..eeab3f2b2 100644
--- a/ports/atmel-samd/boards/pybadge_airlift/board.c
+++ b/ports/atmel-samd/boards/pybadge_airlift/board.c
@@ -71,6 +71,8 @@ void board_init(void) {
0, // row start
90, // rotation
16, // Color depth
+ false, // grayscale
+ false, // pixels in byte share row. Only used for depth < 8
MIPI_COMMAND_SET_COLUMN_ADDRESS, // Set column command
MIPI_COMMAND_SET_PAGE_ADDRESS, // Set row command
MIPI_COMMAND_WRITE_MEMORY_START, // Write memory command
@@ -78,6 +80,7 @@ void board_init(void) {
display_init_sequence,
sizeof(display_init_sequence),
&pin_PA01, // backlight pin
+ NO_BRIGHTNESS_COMMAND,
1.0f, // brightness (ignored)
true, // auto_brightness
false, // single_byte_bounds
diff --git a/ports/atmel-samd/boards/pygamer/board.c b/ports/atmel-samd/boards/pygamer/board.c
index 7b54b6fb5..d413c8e34 100644
--- a/ports/atmel-samd/boards/pygamer/board.c
+++ b/ports/atmel-samd/boards/pygamer/board.c
@@ -93,6 +93,8 @@ void board_init(void) {
0, // row start
270, // rotation
16, // Color depth
+ false, // Grayscale
+ false, // pixels in a byte share a row. Only valid for depths < 8
MIPI_COMMAND_SET_COLUMN_ADDRESS, // Set column command
MIPI_COMMAND_SET_PAGE_ADDRESS, // Set row command
MIPI_COMMAND_WRITE_MEMORY_START, // Write memory command
@@ -100,6 +102,7 @@ void board_init(void) {
display_init_sequence,
sizeof(display_init_sequence),
&pin_PA01, // backlight pin
+ NO_BRIGHTNESS_COMMAND,
1.0f, // brightness (ignored)
true, // auto_brightness
false, // single_byte_bounds
diff --git a/ports/atmel-samd/boards/pygamer_advance/board.c b/ports/atmel-samd/boards/pygamer_advance/board.c
index d1c5edc99..498a29db2 100644
--- a/ports/atmel-samd/boards/pygamer_advance/board.c
+++ b/ports/atmel-samd/boards/pygamer_advance/board.c
@@ -71,6 +71,8 @@ void board_init(void) {
0, // row start
90, // rotation
16, // Color depth
+ false, // Grayscale
+ false, // pixels in a byte share a row. Only valid for depths < 8
MIPI_COMMAND_SET_COLUMN_ADDRESS, // Set column command
MIPI_COMMAND_SET_PAGE_ADDRESS, // Set row command
MIPI_COMMAND_WRITE_MEMORY_START, // Write memory command
@@ -78,6 +80,7 @@ void board_init(void) {
display_init_sequence,
sizeof(display_init_sequence),
&pin_PA01, // backlight pin
+ NO_BRIGHTNESS_COMMAND,
1.0f, // brightness (ignored)
true, // auto_brightness
false, // single_byte_bounds
diff --git a/ports/atmel-samd/boards/pyportal/board.c b/ports/atmel-samd/boards/pyportal/board.c
index bb80c5b48..938072158 100644
--- a/ports/atmel-samd/boards/pyportal/board.c
+++ b/ports/atmel-samd/boards/pyportal/board.c
@@ -83,13 +83,16 @@ void board_init(void) {
0, // row start
0, // rotation
16, // Color depth
+ false, // grayscale
+ false, // pixels_in_byte_share_row (unused for depths > 8)
MIPI_COMMAND_SET_COLUMN_ADDRESS, // Set column command
MIPI_COMMAND_SET_PAGE_ADDRESS, // Set row command
MIPI_COMMAND_WRITE_MEMORY_START, // Write memory command
0x37, // Set vertical scroll command
display_init_sequence,
sizeof(display_init_sequence),
- &pin_PB31,
+ &pin_PB31, // Backlight pin
+ NO_BRIGHTNESS_COMMAND,
1.0f, // brightness (ignored)
true, // auto_brightness
false, // single_byte_bounds
diff --git a/ports/atmel-samd/boards/pyruler/board.c b/ports/atmel-samd/boards/pyruler/board.c
new file mode 100644
index 000000000..d7e856d61
--- /dev/null
+++ b/ports/atmel-samd/boards/pyruler/board.c
@@ -0,0 +1,37 @@
+/*
+ * 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/atmel-samd/boards/pyruler/mpconfigboard.h b/ports/atmel-samd/boards/pyruler/mpconfigboard.h
new file mode 100644
index 000000000..171873b47
--- /dev/null
+++ b/ports/atmel-samd/boards/pyruler/mpconfigboard.h
@@ -0,0 +1,63 @@
+#define MICROPY_HW_BOARD_NAME "Adafruit PyRuler"
+#define MICROPY_HW_MCU_NAME "samd21e18"
+
+#define MICROPY_HW_LED_STATUS (&pin_PA10)
+
+#define MICROPY_HW_APA102_MOSI (&pin_PA00)
+#define MICROPY_HW_APA102_SCK (&pin_PA01)
+
+#define MICROPY_PORT_A (PORT_PA00 | PORT_PA01)
+#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 IGNORE_PIN_PA12 1
+#define IGNORE_PIN_PA13 1
+#define IGNORE_PIN_PA16 1
+#define IGNORE_PIN_PA17 1
+#define IGNORE_PIN_PA18 1
+#define IGNORE_PIN_PA19 1
+#define IGNORE_PIN_PA20 1
+#define IGNORE_PIN_PA21 1
+#define IGNORE_PIN_PA22 1
+#define IGNORE_PIN_PA23 1
+// USB is always used internally so skip the pin objects for it.
+#define IGNORE_PIN_PA24 1
+#define IGNORE_PIN_PA25 1
+#define IGNORE_PIN_PA30 1
+#define IGNORE_PIN_PA31 1
+#define IGNORE_PIN_PB01 1
+#define IGNORE_PIN_PB02 1
+#define IGNORE_PIN_PB03 1
+#define IGNORE_PIN_PB04 1
+#define IGNORE_PIN_PB05 1
+#define IGNORE_PIN_PB06 1
+#define IGNORE_PIN_PB07 1
+#define IGNORE_PIN_PB08 1
+#define IGNORE_PIN_PB09 1
+#define IGNORE_PIN_PB10 1
+#define IGNORE_PIN_PB11 1
+#define IGNORE_PIN_PB12 1
+#define IGNORE_PIN_PB13 1
+#define IGNORE_PIN_PB14 1
+#define IGNORE_PIN_PB15 1
+#define IGNORE_PIN_PB16 1
+#define IGNORE_PIN_PB17 1
+#define IGNORE_PIN_PB22 1
+#define IGNORE_PIN_PB23 1
+#define IGNORE_PIN_PB30 1
+#define IGNORE_PIN_PB31 1
+#define IGNORE_PIN_PB00 1
+
+#define DEFAULT_I2C_BUS_SCL (&pin_PA09)
+#define DEFAULT_I2C_BUS_SDA (&pin_PA08)
+
+#define DEFAULT_SPI_BUS_SCK (&pin_PA07)
+#define DEFAULT_SPI_BUS_MOSI (&pin_PA06)
+#define DEFAULT_SPI_BUS_MISO (&pin_PA09)
+
+#define DEFAULT_UART_BUS_RX (&pin_PA07)
+#define DEFAULT_UART_BUS_TX (&pin_PA06)
diff --git a/ports/atmel-samd/boards/pyruler/mpconfigboard.mk b/ports/atmel-samd/boards/pyruler/mpconfigboard.mk
new file mode 100644
index 000000000..9663944a3
--- /dev/null
+++ b/ports/atmel-samd/boards/pyruler/mpconfigboard.mk
@@ -0,0 +1,14 @@
+LD_FILE = boards/samd21x18-bootloader.ld
+USB_VID = 0x239A
+USB_PID = 0x804C
+USB_PRODUCT = "PyRuler"
+USB_MANUFACTURER = "Adafruit Industries LLC"
+
+CHIP_VARIANT = SAMD21E18A
+CHIP_FAMILY = samd21
+
+INTERNAL_FLASH_FILESYSTEM = 1
+LONGINT_IMPL = NONE
+CIRCUITPY_SMALL_BUILD = 1
+
+SUPEROPT_GC = 0
diff --git a/ports/atmel-samd/boards/pyruler/pins.c b/ports/atmel-samd/boards/pyruler/pins.c
new file mode 100644
index 000000000..315dbe630
--- /dev/null
+++ b/ports/atmel-samd/boards/pyruler/pins.c
@@ -0,0 +1,50 @@
+#include "shared-bindings/board/__init__.h"
+
+STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
+ { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_PA08) },
+ { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PA08) },
+ { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PA08) },
+
+ { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_PA02) },
+ { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA02) },
+
+ { MP_ROM_QSTR(MP_QSTR_CAP0), MP_ROM_PTR(&pin_PA11) },
+
+ { MP_ROM_QSTR(MP_QSTR_CAP1), MP_ROM_PTR(&pin_PA05) },
+
+ { MP_ROM_QSTR(MP_QSTR_CAP2), MP_ROM_PTR(&pin_PA04) },
+
+ { MP_ROM_QSTR(MP_QSTR_CAP3), MP_ROM_PTR(&pin_PA03) },
+
+ { MP_ROM_QSTR(MP_QSTR_LED4), MP_ROM_PTR(&pin_PA15) },
+
+ { MP_ROM_QSTR(MP_QSTR_LED5), MP_ROM_PTR(&pin_PA14) },
+
+ { MP_ROM_QSTR(MP_QSTR_LED6), MP_ROM_PTR(&pin_PA28) },
+
+ { MP_ROM_QSTR(MP_QSTR_LED7), MP_ROM_PTR(&pin_PA27) },
+
+ { MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_PA09) },
+ { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PA09) },
+ { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PA09) },
+ { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PA09) },
+
+ { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_PA06) },
+ { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PA06) },
+ { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PA06) },
+ { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PA06) },
+
+ { MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_PA07) },
+ { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PA07) },
+ { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PA07) },
+ { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PA07) },
+
+ { MP_ROM_QSTR(MP_QSTR_D13),MP_ROM_PTR(&pin_PA10) },
+
+ { MP_ROM_QSTR(MP_QSTR_APA102_MOSI), MP_ROM_PTR(&pin_PA00) },
+ { MP_ROM_QSTR(MP_QSTR_APA102_SCK), MP_ROM_PTR(&pin_PA01) },
+ { 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/atmel-samd/boards/ugame10/board.c b/ports/atmel-samd/boards/ugame10/board.c
index 828f0c87d..15e22a72c 100644
--- a/ports/atmel-samd/boards/ugame10/board.c
+++ b/ports/atmel-samd/boards/ugame10/board.c
@@ -91,6 +91,8 @@ void board_init(void) {
2, // row start
0, // rotation
16, // Color depth
+ false, // grayscale
+ false, // pixels in byte share row. Only used with depth < 8
MIPI_COMMAND_SET_COLUMN_ADDRESS, // Set column command
MIPI_COMMAND_SET_PAGE_ADDRESS, // Set row command
MIPI_COMMAND_WRITE_MEMORY_START, // Write memory command
@@ -98,6 +100,7 @@ void board_init(void) {
display_init_sequence,
sizeof(display_init_sequence),
NULL,
+ NO_BRIGHTNESS_COMMAND,
1.0f, // brightness
false, // auto_brightness
false, // single_byte_bounds
diff --git a/ports/atmel-samd/boards/ugame10/brutalist-6.bdf b/ports/atmel-samd/boards/ugame10/brutalist-6.bdf
new file mode 100644
index 000000000..f9e21e76a
--- /dev/null
+++ b/ports/atmel-samd/boards/ugame10/brutalist-6.bdf
@@ -0,0 +1,1147 @@
+STARTFONT 2.1
+FONT -FontForge-Brutalist-Regular-R-Normal--6-60-75-75-P-40-ISO8859-1
+SIZE 6 100 100
+FONTBOUNDINGBOX 4 6 0 0
+COMMENT "Generated by fontforge, http://fontforge.sourceforge.net"
+STARTPROPERTIES 17
+FAMILY_NAME "brutalist"
+WEIGHT_NAME "Regular"
+SLANT "R"
+SETWIDTH_NAME "Normal"
+PIXEL_SIZE 6
+POINT_SIZE 60
+RESOLUTION_X 100
+RESOLUTION_Y 100
+SPACING "C"
+AVERAGE_WIDTH 40
+CHARSET_REGISTRY "ISO8859"
+CHARSET_ENCODING "1"
+FONTNAME_REGISTRY ""
+FONT_ASCENT 4
+FONT_DESCENT 2
+MIN_SPACE 6
+FIGURE_WIDTH 4
+ENDPROPERTIES
+CHARS 96
+STARTCHAR space
+ENCODING 32
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 1 1 3 -2
+BITMAP
+00
+ENDCHAR
+STARTCHAR exclam
+ENCODING 33
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 1 6 0 -2
+BITMAP
+80
+80
+80
+80
+00
+80
+ENDCHAR
+STARTCHAR quotedbl
+ENCODING 34
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 2 0 2
+BITMAP
+A0
+A0
+ENDCHAR
+STARTCHAR numbersign
+ENCODING 35
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 6 0 -2
+BITMAP
+A0
+E0
+A0
+A0
+E0
+A0
+ENDCHAR
+STARTCHAR dollar
+ENCODING 36
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 6 0 -2
+BITMAP
+40
+E0
+C0
+60
+E0
+40
+ENDCHAR
+STARTCHAR percent
+ENCODING 37
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 6 0 -2
+BITMAP
+A0
+20
+40
+40
+80
+A0
+ENDCHAR
+STARTCHAR ampersand
+ENCODING 38
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 6 0 -2
+BITMAP
+40
+A0
+40
+A0
+A0
+60
+ENDCHAR
+STARTCHAR quotesingle
+ENCODING 39
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 1 2 0 2
+BITMAP
+80
+80
+ENDCHAR
+STARTCHAR parenleft
+ENCODING 40
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 6 0 -2
+BITMAP
+60
+80
+80
+80
+80
+60
+ENDCHAR
+STARTCHAR parenright
+ENCODING 41
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 6 0 -2
+BITMAP
+C0
+20
+20
+20
+20
+C0
+ENDCHAR
+STARTCHAR asterisk
+ENCODING 42
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 3 0 0
+BITMAP
+A0
+40
+A0
+ENDCHAR
+STARTCHAR plus
+ENCODING 43
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 3 0 0
+BITMAP
+40
+E0
+40
+ENDCHAR
+STARTCHAR comma
+ENCODING 44
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 2 3 0 -2
+BITMAP
+40
+40
+80
+ENDCHAR
+STARTCHAR hyphen
+ENCODING 45
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 1 0 1
+BITMAP
+E0
+ENDCHAR
+STARTCHAR period
+ENCODING 46
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 1 1 0 -1
+BITMAP
+80
+ENDCHAR
+STARTCHAR slash
+ENCODING 47
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 6 0 -2
+BITMAP
+20
+20
+40
+40
+80
+80
+ENDCHAR
+STARTCHAR zero
+ENCODING 48
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 5 0 -1
+BITMAP
+60
+A0
+A0
+A0
+C0
+ENDCHAR
+STARTCHAR one
+ENCODING 49
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 2 5 0 -1
+BITMAP
+40
+C0
+40
+40
+40
+ENDCHAR
+STARTCHAR two
+ENCODING 50
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 5 0 -1
+BITMAP
+E0
+20
+E0
+80
+E0
+ENDCHAR
+STARTCHAR three
+ENCODING 51
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 5 0 -1
+BITMAP
+E0
+20
+E0
+20
+E0
+ENDCHAR
+STARTCHAR four
+ENCODING 52
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 5 0 -1
+BITMAP
+A0
+A0
+E0
+20
+20
+ENDCHAR
+STARTCHAR five
+ENCODING 53
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 5 0 -1
+BITMAP
+E0
+80
+E0
+20
+E0
+ENDCHAR
+STARTCHAR six
+ENCODING 54
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 5 0 -1
+BITMAP
+E0
+80
+E0
+A0
+E0
+ENDCHAR
+STARTCHAR seven
+ENCODING 55
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 5 0 -1
+BITMAP
+E0
+20
+20
+20
+20
+ENDCHAR
+STARTCHAR eight
+ENCODING 56
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 5 0 -1
+BITMAP
+E0
+A0
+E0
+A0
+E0
+ENDCHAR
+STARTCHAR nine
+ENCODING 57
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 5 0 -1
+BITMAP
+E0
+A0
+E0
+20
+E0
+ENDCHAR
+STARTCHAR colon
+ENCODING 58
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 1 3 1 0
+BITMAP
+80
+00
+80
+ENDCHAR
+STARTCHAR semicolon
+ENCODING 59
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 2 5 0 -2
+BITMAP
+40
+00
+40
+40
+80
+ENDCHAR
+STARTCHAR less
+ENCODING 60
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 5 0 -1
+BITMAP
+20
+40
+80
+40
+20
+ENDCHAR
+STARTCHAR equal
+ENCODING 61
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 3 0 0
+BITMAP
+E0
+00
+E0
+ENDCHAR
+STARTCHAR greater
+ENCODING 62
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 5 0 -1
+BITMAP
+80
+40
+20
+40
+80
+ENDCHAR
+STARTCHAR question
+ENCODING 63
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 6 0 -2
+BITMAP
+E0
+20
+60
+40
+00
+40
+ENDCHAR
+STARTCHAR at
+ENCODING 64
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 6 0 -2
+BITMAP
+E0
+A0
+E0
+E0
+80
+E0
+ENDCHAR
+STARTCHAR A
+ENCODING 65
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 5 0 -1
+BITMAP
+E0
+A0
+A0
+E0
+A0
+ENDCHAR
+STARTCHAR B
+ENCODING 66
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 5 0 -1
+BITMAP
+C0
+A0
+C0
+A0
+E0
+ENDCHAR
+STARTCHAR C
+ENCODING 67
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 5 0 -1
+BITMAP
+E0
+A0
+80
+A0
+E0
+ENDCHAR
+STARTCHAR D
+ENCODING 68
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 5 0 -1
+BITMAP
+C0
+A0
+A0
+A0
+C0
+ENDCHAR
+STARTCHAR E
+ENCODING 69
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 5 0 -1
+BITMAP
+E0
+80
+E0
+80
+E0
+ENDCHAR
+STARTCHAR F
+ENCODING 70
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 5 0 -1
+BITMAP
+E0
+80
+80
+E0
+80
+ENDCHAR
+STARTCHAR G
+ENCODING 71
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 6 0 -2
+BITMAP
+E0
+80
+A0
+A0
+E0
+20
+ENDCHAR
+STARTCHAR H
+ENCODING 72
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 5 0 -1
+BITMAP
+A0
+A0
+E0
+A0
+A0
+ENDCHAR
+STARTCHAR I
+ENCODING 73
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 5 0 -1
+BITMAP
+E0
+40
+40
+40
+E0
+ENDCHAR
+STARTCHAR J
+ENCODING 74
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 5 0 -1
+BITMAP
+20
+20
+20
+A0
+E0
+ENDCHAR
+STARTCHAR K
+ENCODING 75
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 5 0 -1
+BITMAP
+A0
+C0
+E0
+A0
+A0
+ENDCHAR
+STARTCHAR L
+ENCODING 76
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 5 0 -1
+BITMAP
+80
+80
+80
+80
+E0
+ENDCHAR
+STARTCHAR M
+ENCODING 77
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 5 0 -1
+BITMAP
+A0
+E0
+A0
+A0
+A0
+ENDCHAR
+STARTCHAR N
+ENCODING 78
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 5 0 -1
+BITMAP
+A0
+E0
+E0
+E0
+A0
+ENDCHAR
+STARTCHAR O
+ENCODING 79
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 5 0 -1
+BITMAP
+E0
+A0
+A0
+A0
+E0
+ENDCHAR
+STARTCHAR P
+ENCODING 80
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 5 0 -1
+BITMAP
+E0
+A0
+A0
+E0
+80
+ENDCHAR
+STARTCHAR Q
+ENCODING 81
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 6 0 -2
+BITMAP
+E0
+A0
+A0
+A0
+E0
+20
+ENDCHAR
+STARTCHAR R
+ENCODING 82
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 5 0 -1
+BITMAP
+E0
+A0
+A0
+C0
+A0
+ENDCHAR
+STARTCHAR S
+ENCODING 83
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 5 0 -1
+BITMAP
+E0
+80
+E0
+20
+E0
+ENDCHAR
+STARTCHAR T
+ENCODING 84
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 5 0 -1
+BITMAP
+E0
+40
+40
+40
+40
+ENDCHAR
+STARTCHAR U
+ENCODING 85
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 5 0 -1
+BITMAP
+A0
+A0
+A0
+A0
+E0
+ENDCHAR
+STARTCHAR V
+ENCODING 86
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 5 0 -1
+BITMAP
+A0
+A0
+A0
+E0
+40
+ENDCHAR
+STARTCHAR W
+ENCODING 87
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 5 0 -1
+BITMAP
+A0
+A0
+A0
+E0
+A0
+ENDCHAR
+STARTCHAR X
+ENCODING 88
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 5 0 -1
+BITMAP
+A0
+A0
+40
+A0
+A0
+ENDCHAR
+STARTCHAR Y
+ENCODING 89
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 5 0 -1
+BITMAP
+A0
+A0
+E0
+40
+40
+ENDCHAR
+STARTCHAR Z
+ENCODING 90
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 5 0 -1
+BITMAP
+E0
+20
+40
+80
+E0
+ENDCHAR
+STARTCHAR bracketleft
+ENCODING 91
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 6 0 -2
+BITMAP
+E0
+80
+80
+80
+80
+E0
+ENDCHAR
+STARTCHAR backslash
+ENCODING 92
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 6 0 -2
+BITMAP
+80
+80
+40
+40
+20
+20
+ENDCHAR
+STARTCHAR bracketright
+ENCODING 93
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 6 0 -2
+BITMAP
+E0
+20
+20
+20
+20
+E0
+ENDCHAR
+STARTCHAR asciicircum
+ENCODING 94
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 3 0 1
+BITMAP
+40
+E0
+A0
+ENDCHAR
+STARTCHAR underscore
+ENCODING 95
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 1 0 -1
+BITMAP
+E0
+ENDCHAR
+STARTCHAR grave
+ENCODING 96
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 2 2 1 2
+BITMAP
+80
+40
+ENDCHAR
+STARTCHAR a
+ENCODING 97
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 4 0 -1
+BITMAP
+E0
+60
+A0
+E0
+ENDCHAR
+STARTCHAR b
+ENCODING 98
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 5 0 -1
+BITMAP
+80
+E0
+A0
+A0
+E0
+ENDCHAR
+STARTCHAR c
+ENCODING 99
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 4 0 -1
+BITMAP
+E0
+A0
+80
+E0
+ENDCHAR
+STARTCHAR d
+ENCODING 100
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 5 0 -1
+BITMAP
+20
+E0
+A0
+A0
+E0
+ENDCHAR
+STARTCHAR e
+ENCODING 101
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 4 0 -1
+BITMAP
+E0
+A0
+C0
+E0
+ENDCHAR
+STARTCHAR f
+ENCODING 102
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 6 0 -2
+BITMAP
+60
+40
+E0
+40
+40
+40
+ENDCHAR
+STARTCHAR g
+ENCODING 103
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 5 0 -2
+BITMAP
+E0
+A0
+E0
+20
+E0
+ENDCHAR
+STARTCHAR h
+ENCODING 104
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 5 0 -1
+BITMAP
+80
+E0
+A0
+A0
+A0
+ENDCHAR
+STARTCHAR i
+ENCODING 105
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 2 5 1 -1
+BITMAP
+80
+00
+80
+80
+C0
+ENDCHAR
+STARTCHAR j
+ENCODING 106
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 6 0 -2
+BITMAP
+20
+00
+60
+20
+A0
+E0
+ENDCHAR
+STARTCHAR k
+ENCODING 107
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 5 0 -1
+BITMAP
+80
+A0
+C0
+A0
+A0
+ENDCHAR
+STARTCHAR l
+ENCODING 108
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 5 0 -1
+BITMAP
+C0
+40
+40
+40
+60
+ENDCHAR
+STARTCHAR m
+ENCODING 109
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 4 0 -1
+BITMAP
+E0
+E0
+E0
+A0
+ENDCHAR
+STARTCHAR n
+ENCODING 110
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 4 0 -1
+BITMAP
+E0
+A0
+A0
+A0
+ENDCHAR
+STARTCHAR o
+ENCODING 111
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 4 0 -1
+BITMAP
+E0
+A0
+A0
+E0
+ENDCHAR
+STARTCHAR p
+ENCODING 112
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 5 0 -2
+BITMAP
+E0
+A0
+A0
+E0
+80
+ENDCHAR
+STARTCHAR q
+ENCODING 113
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 5 0 -2
+BITMAP
+E0
+A0
+A0
+E0
+20
+ENDCHAR
+STARTCHAR r
+ENCODING 114
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 4 0 -1
+BITMAP
+E0
+A0
+80
+80
+ENDCHAR
+STARTCHAR s
+ENCODING 115
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 4 0 -1
+BITMAP
+E0
+80
+60
+E0
+ENDCHAR
+STARTCHAR t
+ENCODING 116
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 5 0 -1
+BITMAP
+40
+E0
+40
+40
+60
+ENDCHAR
+STARTCHAR u
+ENCODING 117
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 4 0 -1
+BITMAP
+A0
+A0
+A0
+E0
+ENDCHAR
+STARTCHAR v
+ENCODING 118
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 4 0 -1
+BITMAP
+A0
+A0
+E0
+40
+ENDCHAR
+STARTCHAR w
+ENCODING 119
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 4 0 -1
+BITMAP
+A0
+A0
+E0
+A0
+ENDCHAR
+STARTCHAR x
+ENCODING 120
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 4 0 -1
+BITMAP
+A0
+40
+A0
+A0
+ENDCHAR
+STARTCHAR y
+ENCODING 121
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 5 0 -2
+BITMAP
+A0
+A0
+E0
+20
+E0
+ENDCHAR
+STARTCHAR z
+ENCODING 122
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 4 0 -1
+BITMAP
+E0
+40
+80
+E0
+ENDCHAR
+STARTCHAR braceleft
+ENCODING 123
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 6 0 -2
+BITMAP
+60
+40
+C0
+40
+40
+60
+ENDCHAR
+STARTCHAR bar
+ENCODING 124
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 1 6 1 -2
+BITMAP
+80
+80
+80
+80
+80
+80
+ENDCHAR
+STARTCHAR braceright
+ENCODING 125
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 6 0 -2
+BITMAP
+C0
+40
+60
+40
+40
+C0
+ENDCHAR
+STARTCHAR asciitilde
+ENCODING 126
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 4 3 0 1
+BITMAP
+50
+F0
+A0
+ENDCHAR
+STARTCHAR uni007F
+ENCODING 127
+SWIDTH 666 0
+DWIDTH 5 0
+BBX 3 6 0 -2
+BITMAP
+E0
+A0
+A0
+A0
+A0
+E0
+ENDCHAR
+ENDFONT
diff --git a/ports/atmel-samd/boards/ugame10/brutalist.sfd b/ports/atmel-samd/boards/ugame10/brutalist.sfd
new file mode 100644
index 000000000..2a48515aa
--- /dev/null
+++ b/ports/atmel-samd/boards/ugame10/brutalist.sfd
@@ -0,0 +1,1034 @@
+SplineFontDB: 3.0
+FontName: brutalistRegular
+FullName: brutalist Regular
+FamilyName: brutalist
+Weight: Regular
+Copyright: Copyright (c) 2019, sheep,,,
+UComments: "2019-6-28: Created with FontForge (http://fontforge.org)"
+Version: 001.000
+ItalicAngle: 0
+UnderlinePosition: -100
+UnderlineWidth: 50
+Ascent: 666
+Descent: 334
+InvalidEm: 0
+LayerCount: 2
+Layer: 0 0 "Back" 1
+Layer: 1 0 "Fore" 0
+XUID: [1021 455 -922482232 13638063]
+OS2Version: 0
+OS2_WeightWidthSlopeOnly: 0
+OS2_UseTypoMetrics: 1
+CreationTime: 1561742286
+ModificationTime: 1561742286
+OS2TypoAscent: 0
+OS2TypoAOffset: 1
+OS2TypoDescent: 0
+OS2TypoDOffset: 1
+OS2TypoLinegap: 0
+OS2WinAscent: 0
+OS2WinAOffset: 1
+OS2WinDescent: 0
+OS2WinDOffset: 1
+HheadAscent: 0
+HheadAOffset: 1
+HheadDescent: 0
+HheadDOffset: 1
+OS2Vendor: 'PfEd'
+DEI: 91125
+Encoding: ISO8859-1
+UnicodeInterp: none
+NameList: AGL For New Fonts
+DisplaySize: 6
+AntiAlias: 1
+FitToEm: 0
+WinInfo: 0 32 23
+OnlyBitmaps: 1
+BeginChars: 256 96
+
+StartChar: space
+Encoding: 32 32 0
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: exclam
+Encoding: 33 33 1
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: quotedbl
+Encoding: 34 34 2
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: numbersign
+Encoding: 35 35 3
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: dollar
+Encoding: 36 36 4
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: percent
+Encoding: 37 37 5
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: ampersand
+Encoding: 38 38 6
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: quotesingle
+Encoding: 39 39 7
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: parenleft
+Encoding: 40 40 8
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: parenright
+Encoding: 41 41 9
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: asterisk
+Encoding: 42 42 10
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: plus
+Encoding: 43 43 11
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: comma
+Encoding: 44 44 12
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: hyphen
+Encoding: 45 45 13
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: period
+Encoding: 46 46 14
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: slash
+Encoding: 47 47 15
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: zero
+Encoding: 48 48 16
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: one
+Encoding: 49 49 17
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: two
+Encoding: 50 50 18
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: three
+Encoding: 51 51 19
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: four
+Encoding: 52 52 20
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: five
+Encoding: 53 53 21
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: six
+Encoding: 54 54 22
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: seven
+Encoding: 55 55 23
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: eight
+Encoding: 56 56 24
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: nine
+Encoding: 57 57 25
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: colon
+Encoding: 58 58 26
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: semicolon
+Encoding: 59 59 27
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: less
+Encoding: 60 60 28
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: equal
+Encoding: 61 61 29
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: greater
+Encoding: 62 62 30
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: question
+Encoding: 63 63 31
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: at
+Encoding: 64 64 32
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: A
+Encoding: 65 65 33
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: B
+Encoding: 66 66 34
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: C
+Encoding: 67 67 35
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: D
+Encoding: 68 68 36
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: E
+Encoding: 69 69 37
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: F
+Encoding: 70 70 38
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: G
+Encoding: 71 71 39
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: H
+Encoding: 72 72 40
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: I
+Encoding: 73 73 41
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: J
+Encoding: 74 74 42
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: K
+Encoding: 75 75 43
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: L
+Encoding: 76 76 44
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: M
+Encoding: 77 77 45
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: N
+Encoding: 78 78 46
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: O
+Encoding: 79 79 47
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: P
+Encoding: 80 80 48
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: Q
+Encoding: 81 81 49
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: R
+Encoding: 82 82 50
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: S
+Encoding: 83 83 51
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: T
+Encoding: 84 84 52
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: U
+Encoding: 85 85 53
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: V
+Encoding: 86 86 54
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: W
+Encoding: 87 87 55
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: X
+Encoding: 88 88 56
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: Y
+Encoding: 89 89 57
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: Z
+Encoding: 90 90 58
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: bracketleft
+Encoding: 91 91 59
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: backslash
+Encoding: 92 92 60
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: bracketright
+Encoding: 93 93 61
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: asciicircum
+Encoding: 94 94 62
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: underscore
+Encoding: 95 95 63
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: grave
+Encoding: 96 96 64
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: a
+Encoding: 97 97 65
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: b
+Encoding: 98 98 66
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: c
+Encoding: 99 99 67
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: d
+Encoding: 100 100 68
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: e
+Encoding: 101 101 69
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: f
+Encoding: 102 102 70
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: g
+Encoding: 103 103 71
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: h
+Encoding: 104 104 72
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: i
+Encoding: 105 105 73
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: j
+Encoding: 106 106 74
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: k
+Encoding: 107 107 75
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: l
+Encoding: 108 108 76
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: m
+Encoding: 109 109 77
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: n
+Encoding: 110 110 78
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: o
+Encoding: 111 111 79
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: p
+Encoding: 112 112 80
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: q
+Encoding: 113 113 81
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: r
+Encoding: 114 114 82
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: s
+Encoding: 115 115 83
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: t
+Encoding: 116 116 84
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: u
+Encoding: 117 117 85
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: v
+Encoding: 118 118 86
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: w
+Encoding: 119 119 87
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: x
+Encoding: 120 120 88
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: y
+Encoding: 121 121 89
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: z
+Encoding: 122 122 90
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: braceleft
+Encoding: 123 123 91
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: bar
+Encoding: 124 124 92
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: braceright
+Encoding: 125 125 93
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: asciitilde
+Encoding: 126 126 94
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+
+StartChar: uni007F
+Encoding: 127 127 95
+Width: 666
+VWidth: 0
+Flags: W
+LayerCount: 2
+EndChar
+EndChars
+BitmapFont: 6 96 4 2 1
+BDFStartProperties: 20
+FONT 1 "-FontForge-Brutalist-Regular-R-Normal--6-60-75-75-P-40-ISO8859-1"
+SIZE 1 "6 100 100"
+FONTBOUNDINGBOX 1 "4 6 0 -1"
+FAMILY_NAME 16 "brutalist"
+WEIGHT_NAME 16 "Regular"
+SLANT 16 "R"
+SETWIDTH_NAME 16 "Normal"
+PIXEL_SIZE 18 6
+POINT_SIZE 18 60
+RESOLUTION_X 19 100
+RESOLUTION_Y 19 100
+SPACING 16 "C"
+AVERAGE_WIDTH 18 40
+CHARSET_REGISTRY 16 "ISO8859"
+CHARSET_ENCODING 16 "1"
+FONTNAME_REGISTRY 16 ""
+FONT_ASCENT 18 4
+FONT_DESCENT 18 2
+MIN_SPACE 18 6
+FIGURE_WIDTH 18 4
+BDFEndProperties
+Resolution: 100
+BDFChar: 0 32 5 3 3 -2 -2
+z
+BDFChar: 1 33 5 0 0 -2 3
+J:N0#!.Y%L
+BDFChar: 2 34 5 0 2 2 3
+TV)8b
+BDFChar: 3 35 5 0 2 -2 3
+T\uK9i1L&M
+BDFChar: 4 36 5 0 2 -2 3
+5iBFci'78B
+BDFChar: 5 37 5 0 2 -2 3
+THHKbJ=llB
+BDFChar: 6 38 5 0 2 -2 3
+5bLB8TO7a"
+BDFChar: 7 39 5 0 0 2 3
+J:IV"
+BDFChar: 8 40 5 0 2 -2 3
+@"<cXJ7&?W
+BDFChar: 9 41 5 0 2 -2 3
+^`XaB+M[sW
+BDFChar: 10 42 5 0 2 0 2
+TKo.M
+BDFChar: 11 43 5 0 2 0 2
+5i=m-
+BDFChar: 12 44 5 0 1 -2 0
+5X9i"
+BDFChar: 13 45 5 0 2 1 1
+huE`W
+BDFChar: 14 46 5 0 0 -1 -1
+J,fQL
+BDFChar: 15 47 5 0 2 -2 3
++<Wp7J:IV"
+BDFChar: 16 48 5 0 2 -1 3
+@%a0c^]4?7
+BDFChar: 17 49 5 0 1 -1 3
+5eoWM5QCca
+BDFChar: 18 50 5 0 2 -1 3
+i#ps.huE`W
+BDFChar: 19 51 5 0 2 -1 3
+i#pr#huE`W
+BDFChar: 20 52 5 0 2 -1 3
+TV13c+92BA
+BDFChar: 21 53 5 0 2 -1 3
+i.0`.huE`W
+BDFChar: 22 54 5 0 2 -1 3
+i.0aYhuE`W
+BDFChar: 23 55 5 0 2 -1 3
+i#j-b+92BA
+BDFChar: 24 56 5 0 2 -1 3
+i1T#$huE`W
+BDFChar: 25 57 5 0 2 -1 3
+i1T!NhuE`W
+BDFChar: 26 58 5 1 1 0 2
+J,k*"
+BDFChar: 27 59 5 0 1 -2 2
+5QF&7J,fQL
+BDFChar: 28 60 5 0 2 -1 3
++@(HB+92BA
+BDFChar: 29 61 5 0 2 0 2
+huM[8
+BDFChar: 30 62 5 0 2 -1 3
+J3Y5BJ,fQL
+BDFChar: 31 63 5 0 2 -2 3
+i#lDm!'gMa
+BDFChar: 32 64 5 0 2 -2 3
+i1T#dJD^D-
+BDFChar: 33 65 5 0 2 -1 3
+i1Qb$TE"rl
+BDFChar: 34 66 5 0 2 -1 3
+^nAK9huE`W
+BDFChar: 35 67 5 0 2 -1 3
+i1PUnhuE`W
+BDFChar: 36 68 5 0 2 -1 3
+^n@?n^]4?7
+BDFChar: 37 69 5 0 2 -1 3
+i.0a9huE`W
+BDFChar: 38 70 5 0 2 -1 3
+i.-@9J,fQL
+BDFChar: 39 71 5 0 2 -2 3
+i..Jni#i""
+BDFChar: 40 72 5 0 2 -1 3
+TV159TE"rl
+BDFChar: 41 73 5 0 2 -1 3
+i'9OmhuE`W
+BDFChar: 42 74 5 0 2 -1 3
++<Vf"huE`W
+BDFChar: 43 75 5 0 2 -1 3
+TYTKYTE"rl
+BDFChar: 44 76 5 0 2 -1 3
+J:N0#huE`W
+BDFChar: 45 77 5 0 2 -1 3
+T\uK9TE"rl
+BDFChar: 46 78 5 0 2 -1 3
+T]"bdTE"rl
+BDFChar: 47 79 5 0 2 -1 3
+i1Qa9huE`W
+BDFChar: 48 80 5 0 2 -1 3
+i1Qb$J,fQL
+BDFChar: 49 81 5 0 2 -2 3
+i1Qa9i#i""
+BDFChar: 50 82 5 0 2 -1 3
+i1QaYTE"rl
+BDFChar: 51 83 5 0 2 -1 3
+i.0`.huE`W
+BDFChar: 52 84 5 0 2 -1 3
+i'9Om5QCca
+BDFChar: 53 85 5 0 2 -1 3
+TV.sNhuE`W
+BDFChar: 54 86 5 0 2 -1 3
+TV.t95QCca
+BDFChar: 55 87 5 0 2 -1 3
+TV.t9TE"rl
+BDFChar: 56 88 5 0 2 -1 3
+TV+QCTE"rl
+BDFChar: 57 89 5 0 2 -1 3
+TV14.5QCca
+BDFChar: 58 90 5 0 2 -1 3
+i#k:8huE`W
+BDFChar: 59 91 5 0 2 -2 3
+i.-?.JD^D-
+BDFChar: 60 92 5 0 2 -2 3
+J:KmM+<UXa
+BDFChar: 61 93 5 0 2 -2 3
+i#j-b+Q*5"
+BDFChar: 62 94 5 0 2 1 3
+5iA:8
+BDFChar: 63 95 5 0 2 -1 -1
+huE`W
+BDFChar: 64 96 5 1 2 2 3
+J3X)7
+BDFChar: 65 97 5 0 2 -1 2
+i*`59
+BDFChar: 66 98 5 0 2 -1 3
+JDd)nhuE`W
+BDFChar: 67 99 5 0 2 -1 2
+i1PVY
+BDFChar: 68 100 5 0 2 -1 3
++Q/ochuE`W
+BDFChar: 69 101 5 0 2 -1 2
+i1RmD
+BDFChar: 70 102 5 0 2 -2 3
+?pNX85X5;L
+BDFChar: 71 103 5 0 2 -2 2
+i1T!NhuE`W
+BDFChar: 72 104 5 0 2 -1 3
+JDd)nTE"rl
+BDFChar: 73 105 5 1 2 -1 3
+J,k+M^]4?7
+BDFChar: 74 106 5 0 2 -2 3
++95dlT\oeM
+BDFChar: 75 107 5 0 2 -1 3
+J=s]NTE"rl
+BDFChar: 76 108 5 0 2 -1 3
+^d(.M?iU0,
+BDFChar: 77 109 5 0 2 -1 2
+i8EOd
+BDFChar: 78 110 5 0 2 -1 2
+i1Qa9
+BDFChar: 79 111 5 0 2 -1 2
+i1Qb$
+BDFChar: 80 112 5 0 2 -2 2
+i1Qb$J,fQL
+BDFChar: 81 113 5 0 2 -2 2
+i1Qb$+92BA
+BDFChar: 82 114 5 0 2 -1 2
+i1PUN
+BDFChar: 83 115 5 0 2 -1 2
+i.,4n
+BDFChar: 84 116 5 0 2 -1 3
+5i=mm?iU0,
+BDFChar: 85 117 5 0 2 -1 2
+TV.t9
+BDFChar: 86 118 5 0 2 -1 2
+TV14.
+BDFChar: 87 119 5 0 2 -1 2
+TV159
+BDFChar: 88 120 5 0 2 -1 2
+TKo0C
+BDFChar: 89 121 5 0 2 -2 2
+TV13chuE`W
+BDFChar: 90 122 5 0 2 -1 2
+i';hN
+BDFChar: 91 123 5 0 2 -2 3
+?pMLm5[XQl
+BDFChar: 92 124 5 1 1 -2 3
+J:N0#J:IV"
+BDFChar: 93 125 5 0 2 -2 3
+^d)9m5em@"
+BDFChar: 94 126 5 0 3 -1 3
+;"1+Xz
+BDFChar: 95 127 5 0 2 -2 3
+i1Qa9T\oeM
+EndBitmapFont
+EndSplineFont
diff --git a/ports/atmel-samd/boards/ugame10/mpconfigboard.mk b/ports/atmel-samd/boards/ugame10/mpconfigboard.mk
index a27ca8874..6361da2a6 100644
--- a/ports/atmel-samd/boards/ugame10/mpconfigboard.mk
+++ b/ports/atmel-samd/boards/ugame10/mpconfigboard.mk
@@ -31,4 +31,4 @@ CIRCUITPY_PIXELBUF = 0
FROZEN_MPY_DIRS += $(TOP)/frozen/circuitpython-stage/ugame10
-CIRCUITPY_DISPLAY_FONT = "../../tools/Tecate-bitmap-fonts/bitmap/phallus/lemon.bdf"
+CIRCUITPY_DISPLAY_FONT = $(TOP)/ports/atmel-samd/boards/ugame10/brutalist-6.bdf
diff --git a/ports/atmel-samd/common-hal/audiobusio/I2SOut.c b/ports/atmel-samd/common-hal/audiobusio/I2SOut.c
index 20934bed4..05a6aaf7b 100644
--- a/ports/atmel-samd/common-hal/audiobusio/I2SOut.c
+++ b/ports/atmel-samd/common-hal/audiobusio/I2SOut.c
@@ -33,7 +33,7 @@
#include "py/runtime.h"
#include "common-hal/audiobusio/I2SOut.h"
#include "shared-bindings/audiobusio/I2SOut.h"
-#include "shared-bindings/audioio/RawSample.h"
+#include "shared-bindings/audiocore/RawSample.h"
#include "shared-bindings/microcontroller/Pin.h"
#include "supervisor/shared/translate.h"
diff --git a/ports/atmel-samd/common-hal/busio/I2C.c b/ports/atmel-samd/common-hal/busio/I2C.c
index a0c04d65d..cdc616bbc 100644
--- a/ports/atmel-samd/common-hal/busio/I2C.c
+++ b/ports/atmel-samd/common-hal/busio/I2C.c
@@ -36,6 +36,8 @@
#include "shared-bindings/microcontroller/__init__.h"
#include "supervisor/shared/translate.h"
+#include "common-hal/busio/SPI.h" // for never_reset_sercom
+
// Number of times to try to send packet if failed.
#define ATTEMPTS 2
@@ -225,3 +227,10 @@ uint8_t common_hal_busio_i2c_read(busio_i2c_obj_t *self, uint16_t addr,
}
return MP_EIO;
}
+
+void common_hal_busio_i2c_never_reset(busio_i2c_obj_t *self) {
+ never_reset_sercom(self->i2c_desc.device.hw);
+
+ never_reset_pin_number(self->scl_pin);
+ never_reset_pin_number(self->sda_pin);
+}
diff --git a/ports/atmel-samd/common-hal/busio/SPI.h b/ports/atmel-samd/common-hal/busio/SPI.h
index 56d163a9d..a1c0e1517 100644
--- a/ports/atmel-samd/common-hal/busio/SPI.h
+++ b/ports/atmel-samd/common-hal/busio/SPI.h
@@ -43,6 +43,7 @@ typedef struct {
} busio_spi_obj_t;
void reset_sercoms(void);
+void never_reset_sercom(Sercom* sercom);
#endif // MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_BUSIO_SPI_H
diff --git a/ports/atmel-samd/common-hal/busio/UART.c b/ports/atmel-samd/common-hal/busio/UART.c
index 10618d1ce..f04594842 100644
--- a/ports/atmel-samd/common-hal/busio/UART.c
+++ b/ports/atmel-samd/common-hal/busio/UART.c
@@ -55,7 +55,7 @@ static void usart_async_rxc_callback(const struct usart_async_descriptor *const
void common_hal_busio_uart_construct(busio_uart_obj_t *self,
const mcu_pin_obj_t * tx, const mcu_pin_obj_t * rx, uint32_t baudrate,
uint8_t bits, uart_parity_t parity, uint8_t stop, mp_float_t timeout,
- uint8_t receiver_buffer_size) {
+ uint16_t receiver_buffer_size) {
Sercom* sercom = NULL;
uint8_t sercom_index = 255; // Unset index
uint32_t rx_pinmux = 0;
@@ -88,11 +88,19 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
continue;
}
potential_sercom = sercom_insts[sercom_index];
- if (potential_sercom->USART.CTRLA.bit.ENABLE != 0 ||
+#ifdef SAMD21
+ if (potential_sercom->USART.CTRLA.bit.ENABLE != 0 ||
!(tx->sercom[i].pad == 0 ||
tx->sercom[i].pad == 2)) {
continue;
}
+#endif
+#ifdef SAMD51
+ if (potential_sercom->USART.CTRLA.bit.ENABLE != 0 ||
+ !(tx->sercom[i].pad == 0)) {
+ continue;
+ }
+#endif
tx_pinmux = PINMUX(tx->number, (i == 0) ? MUX_C : MUX_D);
tx_pad = tx->sercom[i].pad;
if (rx == mp_const_none) {
diff --git a/ports/atmel-samd/common-hal/displayio/ParallelBus.c b/ports/atmel-samd/common-hal/displayio/ParallelBus.c
index 7a5f61448..c370f7e52 100644
--- a/ports/atmel-samd/common-hal/displayio/ParallelBus.c
+++ b/ports/atmel-samd/common-hal/displayio/ParallelBus.c
@@ -31,6 +31,7 @@
#include "common-hal/microcontroller/Pin.h"
#include "py/runtime.h"
#include "shared-bindings/digitalio/DigitalInOut.h"
+#include "shared-bindings/microcontroller/__init__.h"
#include "tick.h"
@@ -66,10 +67,6 @@ void common_hal_displayio_parallelbus_construct(displayio_parallelbus_obj_t* sel
common_hal_digitalio_digitalinout_construct(&self->chip_select, chip_select);
common_hal_digitalio_digitalinout_switch_to_output(&self->chip_select, true, DRIVE_MODE_PUSH_PULL);
- self->reset.base.type = &digitalio_digitalinout_type;
- common_hal_digitalio_digitalinout_construct(&self->reset, reset);
- common_hal_digitalio_digitalinout_switch_to_output(&self->reset, true, DRIVE_MODE_PUSH_PULL);
-
self->write.base.type = &digitalio_digitalinout_type;
common_hal_digitalio_digitalinout_construct(&self->write, write);
common_hal_digitalio_digitalinout_switch_to_output(&self->write, true, DRIVE_MODE_PUSH_PULL);
@@ -82,11 +79,21 @@ void common_hal_displayio_parallelbus_construct(displayio_parallelbus_obj_t* sel
self->write_group = &PORT->Group[write->number / 32];
self->write_mask = 1 << (write->number % 32);
+ if (reset != NULL) {
+ self->reset.base.type = &digitalio_digitalinout_type;
+ common_hal_digitalio_digitalinout_construct(&self->reset, reset);
+ common_hal_digitalio_digitalinout_switch_to_output(&self->reset, true, DRIVE_MODE_PUSH_PULL);
+ never_reset_pin_number(reset->number);
+
+ common_hal_digitalio_digitalinout_set_value(&self->reset, false);
+ common_hal_mcu_delay_us(4);
+ common_hal_digitalio_digitalinout_set_value(&self->reset, true);
+ }
+
never_reset_pin_number(command->number);
never_reset_pin_number(chip_select->number);
never_reset_pin_number(write->number);
never_reset_pin_number(read->number);
- never_reset_pin_number(reset->number);
for (uint8_t i = 0; i < 8; i++) {
never_reset_pin_number(data_pin + i);
}
diff --git a/ports/atmel-samd/mpconfigport.mk b/ports/atmel-samd/mpconfigport.mk
index 66ee92e6b..4ddd097f0 100644
--- a/ports/atmel-samd/mpconfigport.mk
+++ b/ports/atmel-samd/mpconfigport.mk
@@ -17,7 +17,7 @@ endif
# Put samd21-only choices here.
ifeq ($(CHIP_FAMILY),samd21)
# frequencyio not yet verified as working on SAMD21.
-CIRCUITPY_FRQUENCYIO = 0
+CIRCUITPY_FREQUENCYIO = 0
endif
# Put samd51-only choices here.
diff --git a/ports/esp8266/common-hal/busio/UART.c b/ports/esp8266/common-hal/busio/UART.c
index f10e3dc55..e72dce639 100644
--- a/ports/esp8266/common-hal/busio/UART.c
+++ b/ports/esp8266/common-hal/busio/UART.c
@@ -40,7 +40,7 @@ extern UartDevice UartDev;
void common_hal_busio_uart_construct(busio_uart_obj_t *self,
const mcu_pin_obj_t * tx, const mcu_pin_obj_t * rx, uint32_t baudrate,
uint8_t bits, uart_parity_t parity, uint8_t stop, mp_float_t timeout,
- uint8_t receiver_buffer_size) {
+ uint16_t receiver_buffer_size) {
if (rx != mp_const_none || tx != &pin_GPIO2) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, translate("Only tx supported on UART1 (GPIO2).")));
}
diff --git a/ports/nrf/Makefile b/ports/nrf/Makefile
index d947ab34c..9da2c498d 100755
--- a/ports/nrf/Makefile
+++ b/ports/nrf/Makefile
@@ -81,6 +81,7 @@ INC += -I./nrfx
INC += -I./nrfx/hal
INC += -I./nrfx/mdk
INC += -I./nrfx/drivers/include
+INC += -I./nrfx/drivers/src
INC += -I./bluetooth
INC += -I./peripherals
INC += -I../../lib/mp-readline
@@ -159,7 +160,6 @@ SRC_C += \
boards/$(BOARD)/pins.c \
device/$(MCU_VARIANT)/startup_$(MCU_SUB_VARIANT).c \
bluetooth/ble_drv.c \
- bluetooth/ble_uart.c \
lib/libc/string0.c \
lib/mp-readline/readline.c \
lib/oofatfs/ff.c \
diff --git a/ports/nrf/bluetooth/ble_drv.c b/ports/nrf/bluetooth/ble_drv.c
index f6e575a8c..6b17e7af2 100644
--- a/ports/nrf/bluetooth/ble_drv.c
+++ b/ports/nrf/bluetooth/ble_drv.c
@@ -3,8 +3,9 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2016 Glenn Ruben Bakke
+ * Copyright (c) 2019 Dan Halbert for Adafruit Industries
* Copyright (c) 2018 Artur Pacholec
+ * Copyright (c) 2016 Glenn Ruben Bakke
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/ports/nrf/bluetooth/ble_drv.h b/ports/nrf/bluetooth/ble_drv.h
index cdb4c9b03..a066f588f 100644
--- a/ports/nrf/bluetooth/ble_drv.h
+++ b/ports/nrf/bluetooth/ble_drv.h
@@ -3,8 +3,9 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2016 Glenn Ruben Bakke
+ * Copyright (c) 2019 Dan Halbert for Adafruit Industries
* Copyright (c) 2018 Artur Pacholec
+ * Copyright (c) 2016 Glenn Ruben Bakke
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -30,10 +31,6 @@
#include "ble.h"
-#if (BLUETOOTH_SD == 132) && (BLE_API_VERSION == 2)
-#define NRF52
-#endif
-
#define MAX_TX_IN_PROGRESS 10
#ifndef BLE_GATT_ATT_MTU_DEFAULT
@@ -43,9 +40,12 @@
#define BLE_CONN_CFG_TAG_CUSTOM 1
#define MSEC_TO_UNITS(TIME, RESOLUTION) (((TIME) * 1000) / (RESOLUTION))
+#define SEC_TO_UNITS(TIME, RESOLUTION) (((TIME) * 1000000) / (RESOLUTION))
// 0.625 msecs (625 usecs)
#define ADV_INTERVAL_UNIT_FLOAT_SECS (0.000625)
+// Microseconds is the base unit. The macros above know that.
#define UNIT_0_625_MS (625)
+#define UNIT_1_25_MS (1250)
#define UNIT_10_MS (10000)
typedef void (*ble_drv_evt_handler_t)(ble_evt_t*, void*);
diff --git a/ports/nrf/bluetooth/ble_uart.c b/ports/nrf/bluetooth/ble_uart.c
index 7faaafb0e..91d10cff1 100644
--- a/ports/nrf/bluetooth/ble_uart.c
+++ b/ports/nrf/bluetooth/ble_uart.c
@@ -3,8 +3,9 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2017 Glenn Ruben Bakke
+ * Copyright (c) 2019 Dan Halbert for Adafruit Industries
* Copyright (c) 2018 Artur Pacholec
+ * 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/boards/electronut_labs_blip/mpconfigboard.mk b/ports/nrf/boards/electronut_labs_blip/mpconfigboard.mk
index bf82400d1..9cddd96ee 100644
--- a/ports/nrf/boards/electronut_labs_blip/mpconfigboard.mk
+++ b/ports/nrf/boards/electronut_labs_blip/mpconfigboard.mk
@@ -19,4 +19,12 @@ else
CIRCUITPY_BLEIO = 1
endif
-NRF_DEFINES += -DNRF52840_XXAA -DNRF52840 \ No newline at end of file
+NRF_DEFINES += -DNRF52840_XXAA -DNRF52840
+
+QSPI_FLASH_FILESYSTEM = 0
+INTERNAL_FLASH_FILESYSTEM = 1
+CIRCUITPY_AUDIOIO = 0
+CIRCUITPY_DISPLAYIO = 1
+CIRCUITPY_GAMEPAD = 1
+CIRCUITPY_STAGE = 1
+
diff --git a/ports/nrf/boards/particle_xenon/mpconfigboard.h b/ports/nrf/boards/particle_xenon/mpconfigboard.h
index 41551d2e1..c8da66736 100644
--- a/ports/nrf/boards/particle_xenon/mpconfigboard.h
+++ b/ports/nrf/boards/particle_xenon/mpconfigboard.h
@@ -35,9 +35,9 @@
#define MICROPY_HW_LED_STATUS (&pin_P1_12)
-#define MICROPY_HW_RGB_LED_RED (&pin_P0_13)
-#define MICROPY_HW_RGB_LED_GREEN (&pin_P0_14)
-#define MICROPY_HW_RGB_LED_BLUE (&pin_P0_15)
+#define CP_RGB_STATUS_R (&pin_P0_13)
+#define CP_RGB_STATUS_G (&pin_P0_14)
+#define CP_RGB_STATUS_B (&pin_P0_15)
#if QSPI_FLASH_FILESYSTEM
#define MICROPY_QSPI_DATA0 NRF_GPIO_PIN_MAP(0, 20)
diff --git a/ports/nrf/common-hal/analogio/AnalogIn.c b/ports/nrf/common-hal/analogio/AnalogIn.c
index 1e572f7cb..f20802ac9 100644
--- a/ports/nrf/common-hal/analogio/AnalogIn.c
+++ b/ports/nrf/common-hal/analogio/AnalogIn.c
@@ -3,8 +3,8 @@
*
* The MIT License (MIT)
*
+ * Copyright (c) 2019 Dan Halbert for Adafruit Industries
* Copyright (c) 2016 Scott Shawcroft for Adafruit Industries
- * Copyright (c) 2018 Artur Pacholec
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/ports/nrf/common-hal/bleio/Adapter.c b/ports/nrf/common-hal/bleio/Adapter.c
index 540659aa1..9d0912930 100644
--- a/ports/nrf/common-hal/bleio/Adapter.c
+++ b/ports/nrf/common-hal/bleio/Adapter.c
@@ -3,6 +3,7 @@
*
* The MIT License (MIT)
*
+ * Copyright (c) 2018 Dan Halbert for Adafruit Industries
* Copyright (c) 2016 Glenn Ruben Bakke
* Copyright (c) 2018 Artur Pacholec
*
@@ -136,17 +137,15 @@ void common_hal_bleio_adapter_get_address(bleio_address_obj_t *address) {
uint32_t err_code;
common_hal_bleio_adapter_set_enabled(true);
-
-#if (BLE_API_VERSION == 2)
- err_code = sd_ble_gap_address_get(&local_address);
-#else
err_code = sd_ble_gap_addr_get(&local_address);
-#endif
if (err_code != NRF_SUCCESS) {
mp_raise_OSError_msg(translate("Failed to get local address"));
}
address->type = local_address.addr_type;
- memcpy(address->value, local_address.addr, BLEIO_ADDRESS_BYTES);
+
+ mp_buffer_info_t buf_info;
+ mp_get_buffer_raise(address, &buf_info, MP_BUFFER_READ);
+ memcpy(address->bytes, buf_info.buf, NUM_BLEIO_ADDRESS_BYTES);
}
diff --git a/ports/nrf/common-hal/bleio/Adapter.h b/ports/nrf/common-hal/bleio/Adapter.h
index 0497f9ac9..5dcc62540 100644
--- a/ports/nrf/common-hal/bleio/Adapter.h
+++ b/ports/nrf/common-hal/bleio/Adapter.h
@@ -3,8 +3,9 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2016 Glenn Ruben Bakke
+ * Copyright (c) 2018 Dan Halbert for Adafruit Industries
* Copyright (c) 2018 Artur Pacholec
+ * Copyright (c) 2016 Glenn Ruben Bakke
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/ports/nrf/common-hal/bleio/Broadcaster.c b/ports/nrf/common-hal/bleio/Broadcaster.c
deleted file mode 100644
index a70209a7f..000000000
--- a/ports/nrf/common-hal/bleio/Broadcaster.c
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2018 Dan Halbert for Adafruit Industries
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-#include <string.h>
-
-#include "ble.h"
-#include "ble_drv.h"
-#include "ble_hci.h"
-#include "nrf_soc.h"
-#include "py/runtime.h"
-
-#include "common-hal/bleio/Broadcaster.h"
-#include "shared-bindings/bleio/Adapter.h"
-#include "shared-bindings/bleio/Broadcaster.h"
-
-static uint8_t m_adv_handle = BLE_GAP_ADV_SET_HANDLE_NOT_SET;
-
-void common_hal_bleio_broadcaster_construct(bleio_broadcaster_obj_t *self, mp_float_t interval) {
- common_hal_bleio_adapter_set_enabled(true); // TODO -- Do this somewhere else maybe bleio __init__
- const mp_float_t min = BLE_GAP_ADV_INTERVAL_MIN * ADV_INTERVAL_UNIT_FLOAT_SECS;
- const mp_float_t max = BLE_GAP_ADV_INTERVAL_MAX * ADV_INTERVAL_UNIT_FLOAT_SECS;
-
- if (interval < min || interval > max) {
- // Would like to print range using the constants above, but vargs would convert to double.
- mp_raise_ValueError(translate("interval not in range 0.0020 to 10.24"));
- }
- self->interval = interval;
-}
-
-
-void common_hal_bleio_broadcaster_start_advertising(bleio_broadcaster_obj_t *self, mp_buffer_info_t *data) {
- uint32_t err_code;
-
- if (data->len >= BLE_GAP_ADV_SET_DATA_SIZE_MAX) {
- mp_raise_ValueError(translate("Data too large for advertisement packet"));
- }
- memcpy(self->adv_data, data->buf, data->len);
-
- ble_gap_adv_params_t m_adv_params = {
- .interval = (uint32_t) (self->interval / ADV_INTERVAL_UNIT_FLOAT_SECS),
- .properties.type = BLE_GAP_ADV_TYPE_NONCONNECTABLE_SCANNABLE_UNDIRECTED,
- .duration = BLE_GAP_ADV_TIMEOUT_GENERAL_UNLIMITED,
- .filter_policy = BLE_GAP_ADV_FP_ANY,
- .primary_phy = BLE_GAP_PHY_1MBPS,
- };
-
- common_hal_bleio_broadcaster_stop_advertising(self);
-
- const ble_gap_adv_data_t ble_gap_adv_data = {
- .adv_data.p_data = self->adv_data,
- .adv_data.len = data->len,
- };
-
- err_code = sd_ble_gap_adv_set_configure(&m_adv_handle, &ble_gap_adv_data, &m_adv_params);
- if (err_code == NRF_SUCCESS) {
- err_code = sd_ble_gap_adv_start(m_adv_handle, BLE_CONN_CFG_TAG_CUSTOM);
- }
-
- if (err_code != NRF_SUCCESS) {
- mp_raise_OSError_msg_varg(translate("Failed to start advertising, err 0x%04x"), err_code);
- }
-}
-
-void common_hal_bleio_broadcaster_stop_advertising(bleio_broadcaster_obj_t *self) {
-
- if (m_adv_handle == BLE_GAP_ADV_SET_HANDLE_NOT_SET) {
- return;
- }
-
- const uint32_t err_code = sd_ble_gap_adv_stop(m_adv_handle);
-
- if ((err_code != NRF_SUCCESS) && (err_code != NRF_ERROR_INVALID_STATE)) {
- mp_raise_OSError_msg_varg(translate("Failed to stop advertising, err 0x%04x"), err_code);
- }
-}
diff --git a/ports/nrf/common-hal/bleio/Central.c b/ports/nrf/common-hal/bleio/Central.c
new file mode 100644
index 000000000..d90737411
--- /dev/null
+++ b/ports/nrf/common-hal/bleio/Central.c
@@ -0,0 +1,463 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019 Dan Halbert for Adafruit Industries
+ * Copyright (c) 2018 Artur Pacholec
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include <string.h>
+#include <stdio.h>
+
+#include "ble.h"
+#include "ble_drv.h"
+#include "ble_hci.h"
+#include "nrf_soc.h"
+#include "py/objstr.h"
+#include "py/runtime.h"
+#include "shared-bindings/bleio/Adapter.h"
+#include "shared-bindings/bleio/Characteristic.h"
+#include "shared-bindings/bleio/Central.h"
+#include "shared-bindings/bleio/Descriptor.h"
+#include "shared-bindings/bleio/Service.h"
+#include "shared-bindings/bleio/UUID.h"
+
+static bleio_service_obj_t *m_char_discovery_service;
+static bleio_characteristic_obj_t *m_desc_discovery_characteristic;
+
+static volatile bool m_discovery_in_process;
+static volatile bool m_discovery_successful;
+
+// service_uuid may be NULL, to discover all services.
+STATIC bool discover_next_services(bleio_central_obj_t *self, uint16_t start_handle, ble_uuid_t *service_uuid) {
+ m_discovery_successful = false;
+ m_discovery_in_process = true;
+
+ uint32_t err_code = sd_ble_gattc_primary_services_discover(self->conn_handle, start_handle, service_uuid);
+
+ if (err_code != NRF_SUCCESS) {
+ mp_raise_OSError_msg(translate("Failed to discover services"));
+ }
+
+ // Wait for a discovery event.
+ while (m_discovery_in_process) {
+ MICROPY_VM_HOOK_LOOP;
+ }
+ return m_discovery_successful;
+}
+
+STATIC bool discover_next_characteristics(bleio_central_obj_t *self, bleio_service_obj_t *service, uint16_t start_handle) {
+ m_char_discovery_service = service;
+
+ ble_gattc_handle_range_t handle_range;
+ handle_range.start_handle = start_handle;
+ handle_range.end_handle = service->end_handle;
+
+ m_discovery_successful = false;
+ m_discovery_in_process = true;
+
+ uint32_t err_code = sd_ble_gattc_characteristics_discover(self->conn_handle, &handle_range);
+ if (err_code != NRF_SUCCESS) {
+ return false;
+ }
+
+ // Wait for a discovery event.
+ while (m_discovery_in_process) {
+ MICROPY_VM_HOOK_LOOP;
+ }
+ return m_discovery_successful;
+}
+
+STATIC bool discover_next_descriptors(bleio_central_obj_t *self, bleio_characteristic_obj_t *characteristic, uint16_t start_handle, uint16_t end_handle) {
+ m_desc_discovery_characteristic = characteristic;
+
+ ble_gattc_handle_range_t handle_range;
+ handle_range.start_handle = start_handle;
+ handle_range.end_handle = end_handle;
+
+ m_discovery_successful = false;
+ m_discovery_in_process = true;
+
+ uint32_t err_code = sd_ble_gattc_descriptors_discover(self->conn_handle, &handle_range);
+ if (err_code != NRF_SUCCESS) {
+ return false;
+ }
+
+ // Wait for a discovery event.
+ while (m_discovery_in_process) {
+ MICROPY_VM_HOOK_LOOP;
+ }
+ return m_discovery_successful;
+}
+
+STATIC void on_primary_srv_discovery_rsp(ble_gattc_evt_prim_srvc_disc_rsp_t *response, bleio_central_obj_t *central) {
+ for (size_t i = 0; i < response->count; ++i) {
+ ble_gattc_service_t *gattc_service = &response->services[i];
+
+ bleio_service_obj_t *service = m_new_obj(bleio_service_obj_t);
+ service->base.type = &bleio_service_type;
+
+ // Initialize several fields at once.
+ common_hal_bleio_service_construct(service, NULL, mp_obj_new_list(0, NULL), false);
+
+ service->device = MP_OBJ_FROM_PTR(central);
+ service->start_handle = gattc_service->handle_range.start_handle;
+ service->end_handle = gattc_service->handle_range.end_handle;
+ service->handle = gattc_service->handle_range.start_handle;
+
+ if (gattc_service->uuid.type != BLE_UUID_TYPE_UNKNOWN) {
+ // Known service UUID.
+ bleio_uuid_obj_t *uuid = m_new_obj(bleio_uuid_obj_t);
+ uuid->base.type = &bleio_uuid_type;
+ bleio_uuid_construct_from_nrf_ble_uuid(uuid, &gattc_service->uuid);
+ service->uuid = uuid;
+ service->device = MP_OBJ_FROM_PTR(central);
+ } else {
+ // The discovery response contained a 128-bit UUID that has not yet been registered with the
+ // softdevice via sd_ble_uuid_vs_add(). We need to fetch the 128-bit value and register it.
+ // For now, just set the UUID to NULL.
+ service->uuid = NULL;
+ }
+
+ mp_obj_list_append(central->service_list, service);
+ }
+
+ if (response->count > 0) {
+ m_discovery_successful = true;
+ }
+ m_discovery_in_process = false;
+}
+
+STATIC void on_char_discovery_rsp(ble_gattc_evt_char_disc_rsp_t *response, bleio_central_obj_t *central) {
+ for (size_t i = 0; i < response->count; ++i) {
+ ble_gattc_char_t *gattc_char = &response->chars[i];
+
+ bleio_characteristic_obj_t *characteristic = m_new_obj(bleio_characteristic_obj_t);
+ characteristic->base.type = &bleio_characteristic_type;
+
+ characteristic->descriptor_list = mp_obj_new_list(0, NULL);
+
+ bleio_uuid_obj_t *uuid = NULL;
+
+ if (gattc_char->uuid.type != BLE_UUID_TYPE_UNKNOWN) {
+ // Known characteristic UUID.
+ uuid = m_new_obj(bleio_uuid_obj_t);
+ uuid->base.type = &bleio_uuid_type;
+ bleio_uuid_construct_from_nrf_ble_uuid(uuid, &gattc_char->uuid);
+ } else {
+ // The discovery response contained a 128-bit UUID that has not yet been registered with the
+ // softdevice via sd_ble_uuid_vs_add(). We need to fetch the 128-bit value and register it.
+ // For now, just leave the UUID as NULL.
+ }
+
+ bleio_characteristic_properties_t props;
+
+ props.broadcast = gattc_char->char_props.broadcast;
+ props.indicate = gattc_char->char_props.indicate;
+ props.notify = gattc_char->char_props.notify;
+ props.read = gattc_char->char_props.read;
+ props.write = gattc_char->char_props.write;
+ props.write_no_response = gattc_char->char_props.write_wo_resp;
+
+ // Call common_hal_bleio_characteristic_construct() to initalize some fields and set up evt handler.
+ common_hal_bleio_characteristic_construct(characteristic, uuid, props, mp_obj_new_list(0, NULL));
+ characteristic->handle = gattc_char->handle_value;
+ characteristic->service = m_char_discovery_service;
+
+ mp_obj_list_append(m_char_discovery_service->characteristic_list, MP_OBJ_FROM_PTR(characteristic));
+ }
+
+ if (response->count > 0) {
+ m_discovery_successful = true;
+ }
+ m_discovery_in_process = false;
+}
+
+STATIC void on_desc_discovery_rsp(ble_gattc_evt_desc_disc_rsp_t *response, bleio_central_obj_t *central) {
+ for (size_t i = 0; i < response->count; ++i) {
+ ble_gattc_desc_t *gattc_desc = &response->descs[i];
+
+ // Remember handles for certain well-known descriptors.
+ switch (gattc_desc->uuid.uuid) {
+ case DESCRIPTOR_UUID_CLIENT_CHARACTERISTIC_CONFIGURATION:
+ m_desc_discovery_characteristic->cccd_handle = gattc_desc->handle;
+ break;
+
+ case DESCRIPTOR_UUID_SERVER_CHARACTERISTIC_CONFIGURATION:
+ m_desc_discovery_characteristic->sccd_handle = gattc_desc->handle;
+ break;
+
+ case DESCRIPTOR_UUID_CHARACTERISTIC_USER_DESCRIPTION:
+ m_desc_discovery_characteristic->user_desc_handle = gattc_desc->handle;
+ break;
+
+ default:
+ // TODO: sd_ble_gattc_descriptors_discover() can return things that are not descriptors,
+ // so ignore those.
+ // https://devzone.nordicsemi.com/f/nordic-q-a/49500/sd_ble_gattc_descriptors_discover-is-returning-attributes-that-are-not-descriptors
+ break;
+ }
+
+ bleio_descriptor_obj_t *descriptor = m_new_obj(bleio_descriptor_obj_t);
+ descriptor->base.type = &bleio_descriptor_type;
+
+ bleio_uuid_obj_t *uuid = NULL;
+
+ if (gattc_desc->uuid.type != BLE_UUID_TYPE_UNKNOWN) {
+ // Known descriptor UUID.
+ uuid = m_new_obj(bleio_uuid_obj_t);
+ uuid->base.type = &bleio_uuid_type;
+ bleio_uuid_construct_from_nrf_ble_uuid(uuid, &gattc_desc->uuid);
+ } else {
+ // The discovery response contained a 128-bit UUID that has not yet been registered with the
+ // softdevice via sd_ble_uuid_vs_add(). We need to fetch the 128-bit value and register it.
+ // For now, just leave the UUID as NULL.
+ }
+
+ common_hal_bleio_descriptor_construct(descriptor, uuid);
+ descriptor->handle = gattc_desc->handle;
+ descriptor->characteristic = m_desc_discovery_characteristic;
+
+ mp_obj_list_append(m_desc_discovery_characteristic->descriptor_list, MP_OBJ_FROM_PTR(descriptor));
+ }
+
+ if (response->count > 0) {
+ m_discovery_successful = true;
+ }
+ m_discovery_in_process = false;
+}
+
+STATIC void central_on_ble_evt(ble_evt_t *ble_evt, void *central_in) {
+ bleio_central_obj_t *central = (bleio_central_obj_t*)central_in;
+
+ switch (ble_evt->header.evt_id) {
+ case BLE_GAP_EVT_CONNECTED:
+ central->conn_handle = ble_evt->evt.gap_evt.conn_handle;
+ central->waiting_to_connect = false;
+ break;
+
+ case BLE_GAP_EVT_TIMEOUT:
+ // Handle will be invalid.
+ central->waiting_to_connect = false;
+ break;
+
+ case BLE_GAP_EVT_DISCONNECTED:
+ central->conn_handle = BLE_CONN_HANDLE_INVALID;
+ m_discovery_successful = false;
+ m_discovery_in_process = false;
+ break;
+
+ case BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP:
+ on_primary_srv_discovery_rsp(&ble_evt->evt.gattc_evt.params.prim_srvc_disc_rsp, central);
+ break;
+
+ case BLE_GATTC_EVT_CHAR_DISC_RSP:
+ on_char_discovery_rsp(&ble_evt->evt.gattc_evt.params.char_disc_rsp, central);
+ break;
+
+ case BLE_GATTC_EVT_DESC_DISC_RSP:
+ on_desc_discovery_rsp(&ble_evt->evt.gattc_evt.params.desc_disc_rsp, central);
+ break;
+
+ case BLE_GAP_EVT_SEC_PARAMS_REQUEST:
+ sd_ble_gap_sec_params_reply(central->conn_handle, BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP, NULL, NULL);
+ break;
+
+ case BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST: {
+ ble_gap_evt_conn_param_update_request_t *request =
+ &ble_evt->evt.gap_evt.params.conn_param_update_request;
+ sd_ble_gap_conn_param_update(central->conn_handle, &request->conn_params);
+ break;
+ }
+
+ default:
+ // For debugging.
+ // mp_printf(&mp_plat_print, "Unhandled central event: 0x%04x\n", ble_evt->header.evt_id);
+ break;
+ }
+}
+
+void common_hal_bleio_central_construct(bleio_central_obj_t *self) {
+ common_hal_bleio_adapter_set_enabled(true);
+
+ self->service_list = mp_obj_new_list(0, NULL);
+ self->gatt_role = GATT_ROLE_CLIENT;
+ self->conn_handle = BLE_CONN_HANDLE_INVALID;
+}
+
+void common_hal_bleio_central_connect(bleio_central_obj_t *self, bleio_address_obj_t *address, mp_float_t timeout, mp_obj_t service_uuids) {
+ common_hal_bleio_adapter_set_enabled(true);
+ ble_drv_add_event_handler(central_on_ble_evt, self);
+
+ ble_gap_addr_t addr;
+
+ addr.addr_type = address->type;
+ mp_buffer_info_t address_buf_info;
+ mp_get_buffer_raise(address->bytes, &address_buf_info, MP_BUFFER_READ);
+ memcpy(addr.addr, (uint8_t *) address_buf_info.buf, NUM_BLEIO_ADDRESS_BYTES);
+
+ ble_gap_scan_params_t scan_params = {
+ .interval = MSEC_TO_UNITS(100, UNIT_0_625_MS),
+ .window = MSEC_TO_UNITS(100, UNIT_0_625_MS),
+ .scan_phys = BLE_GAP_PHY_1MBPS,
+ // timeout of 0 means no timeout
+ .timeout = SEC_TO_UNITS(timeout, UNIT_10_MS),
+ };
+
+ ble_gap_conn_params_t conn_params = {
+ .conn_sup_timeout = MSEC_TO_UNITS(4000, UNIT_10_MS),
+ .min_conn_interval = MSEC_TO_UNITS(15, UNIT_1_25_MS),
+ .max_conn_interval = MSEC_TO_UNITS(300, UNIT_1_25_MS),
+ .slave_latency = 0, // number of conn events
+ };
+
+ self->waiting_to_connect = true;
+
+ uint32_t err_code = sd_ble_gap_connect(&addr, &scan_params, &conn_params, BLE_CONN_CFG_TAG_CUSTOM);
+
+ if (err_code != NRF_SUCCESS) {
+ mp_raise_OSError_msg_varg(translate("Failed to start connecting, error 0x%04x"), err_code);
+ }
+
+ while (self->waiting_to_connect) {
+ MICROPY_VM_HOOK_LOOP;
+ }
+
+ if (self->conn_handle == BLE_CONN_HANDLE_INVALID) {
+ mp_raise_OSError_msg(translate("Failed to connect: timeout"));
+ }
+
+ // Connection successful.
+ // Now discover services on the remote peripheral.
+
+ if (service_uuids == mp_const_none) {
+
+ // List of service UUID's not given, so discover all available services.
+
+ uint16_t next_service_start_handle = BLE_GATT_HANDLE_START;
+
+ while (discover_next_services(self, next_service_start_handle, MP_OBJ_NULL)) {
+ // discover_next_services() appends to service_list.
+
+ // Get the most recently discovered service, and then ask for services
+ // whose handles start after the last attribute handle inside that service.
+ const bleio_service_obj_t *service =
+ MP_OBJ_TO_PTR(self->service_list->items[self->service_list->len - 1]);
+ next_service_start_handle = service->end_handle + 1;
+ }
+ } else {
+ mp_obj_iter_buf_t iter_buf;
+ mp_obj_t iterable = mp_getiter(service_uuids, &iter_buf);
+ mp_obj_t uuid_obj;
+ while ((uuid_obj = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) {
+ if (!MP_OBJ_IS_TYPE(uuid_obj, &bleio_uuid_type)) {
+ mp_raise_ValueError(translate("non-UUID found in service_uuids"));
+ }
+ bleio_uuid_obj_t *uuid = MP_OBJ_TO_PTR(uuid_obj);
+
+ ble_uuid_t nrf_uuid;
+ bleio_uuid_convert_to_nrf_ble_uuid(uuid, &nrf_uuid);
+
+ // Service might or might not be discovered; that's ok. Caller has to check
+ // Central.remote_services to find out.
+ // We only need to call this once for each service to discover.
+ discover_next_services(self, BLE_GATT_HANDLE_START, &nrf_uuid);
+ }
+ }
+
+
+ for (size_t service_idx = 0; service_idx < self->service_list->len; ++service_idx) {
+ bleio_service_obj_t *service = MP_OBJ_TO_PTR(self->service_list->items[service_idx]);
+
+ // Skip the service if it had an unknown (unregistered) UUID.
+ if (service->uuid == NULL) {
+ continue;
+ }
+
+ uint16_t next_char_start_handle = service->start_handle;
+
+ // Stop when we go past the end of the range of handles for this service or
+ // discovery call returns nothing.
+ // discover_next_characteristics() appends to the characteristic_list.
+ while (next_char_start_handle <= service->end_handle &&
+ discover_next_characteristics(self, service, next_char_start_handle)) {
+
+
+ // Get the most recently discovered characteristic, and then ask for characteristics
+ // whose handles start after the last attribute handle inside that characteristic.
+ const bleio_characteristic_obj_t *characteristic =
+ MP_OBJ_TO_PTR(service->characteristic_list->items[service->characteristic_list->len - 1]);
+ next_char_start_handle = characteristic->handle + 1;
+ }
+
+ // Got characteristics for this service. Now discover descriptors for each characteristic.
+ size_t char_list_len = service->characteristic_list->len;
+ for (size_t char_idx = 0; char_idx < char_list_len; ++char_idx) {
+ bleio_characteristic_obj_t *characteristic =
+ MP_OBJ_TO_PTR(service->characteristic_list->items[char_idx]);
+ const bool last_characteristic = char_idx == char_list_len - 1;
+ bleio_characteristic_obj_t *next_characteristic = last_characteristic
+ ? NULL
+ : MP_OBJ_TO_PTR(service->characteristic_list->items[char_idx + 1]);
+
+ // Skip the characteristic if it had an unknown (unregistered) UUID.
+ if (characteristic->uuid == NULL) {
+ continue;
+ }
+
+ uint16_t next_desc_start_handle = characteristic->handle + 1;
+
+ // Don't run past the end of this service or the beginning of the next characteristic.
+ uint16_t next_desc_end_handle = next_characteristic == NULL
+ ? service->end_handle
+ : next_characteristic->handle - 1;
+
+ // Stop when we go past the end of the range of handles for this service or
+ // discovery call returns nothing.
+ // discover_next_descriptors() appends to the descriptor_list.
+ while (next_desc_start_handle <= service->end_handle &&
+ next_desc_start_handle < next_desc_end_handle &&
+ discover_next_descriptors(self, characteristic,
+ next_desc_start_handle, next_desc_end_handle)) {
+
+ // Get the most recently discovered descriptor, and then ask for descriptors
+ // whose handles start after that descriptor's handle.
+ const bleio_descriptor_obj_t *descriptor =
+ MP_OBJ_TO_PTR(characteristic->descriptor_list->items[characteristic->descriptor_list->len - 1]);
+ next_desc_start_handle = descriptor->handle + 1;
+ }
+ }
+
+ }
+}
+
+void common_hal_bleio_central_disconnect(bleio_central_obj_t *self) {
+ sd_ble_gap_disconnect(self->conn_handle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
+}
+
+bool common_hal_bleio_central_get_connected(bleio_central_obj_t *self) {
+ return self->conn_handle != BLE_CONN_HANDLE_INVALID;
+}
+
+mp_obj_list_t *common_hal_bleio_central_get_remote_services(bleio_central_obj_t *self) {
+ return self->service_list;
+}
diff --git a/shared-module/bleio/Device.h b/ports/nrf/common-hal/bleio/Central.h
index 8d9ece5ef..ac1670088 100644
--- a/shared-module/bleio/Device.h
+++ b/ports/nrf/common-hal/bleio/Central.h
@@ -3,6 +3,7 @@
*
* The MIT License (MIT)
*
+ * Copyright (c) 2019 Dan Halbert for Adafruit Industries
* Copyright (c) 2018 Artur Pacholec
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -24,22 +25,21 @@
* THE SOFTWARE.
*/
-#ifndef MICROPY_INCLUDED_SHARED_MODULE_BLEIO_DEVICE_H
-#define MICROPY_INCLUDED_SHARED_MODULE_BLEIO_DEVICE_H
+#ifndef MICROPY_INCLUDED_SHARED_MODULE_BLEIO_CENTRAL_H
+#define MICROPY_INCLUDED_SHARED_MODULE_BLEIO_CENTRAL_H
#include <stdbool.h>
+#include "py/objlist.h"
+#include "shared-module/bleio/__init__.h"
#include "shared-module/bleio/Address.h"
typedef struct {
mp_obj_base_t base;
- bool is_peripheral;
- mp_obj_t name;
- bleio_address_obj_t address;
+ gatt_role_t gatt_role;
+ volatile bool waiting_to_connect;
volatile uint16_t conn_handle;
- mp_obj_t service_list;
- mp_obj_t notif_handler;
- mp_obj_t conn_handler;
-} bleio_device_obj_t;
+ mp_obj_list_t *service_list;
+} bleio_central_obj_t;
-#endif // MICROPY_INCLUDED_SHARED_MODULE_BLEIO_DEVICE_H
+#endif // MICROPY_INCLUDED_SHARED_MODULE_BLEIO_CENTRAL_H
diff --git a/ports/nrf/common-hal/bleio/Characteristic.c b/ports/nrf/common-hal/bleio/Characteristic.c
index 9409b73ce..17417a5e6 100644
--- a/ports/nrf/common-hal/bleio/Characteristic.c
+++ b/ports/nrf/common-hal/bleio/Characteristic.c
@@ -3,6 +3,7 @@
*
* The MIT License (MIT)
*
+ * Copyright (c) Dan Halbert for Adafruit Industries
* Copyright (c) 2018 Artur Pacholec
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -34,12 +35,8 @@
#include "py/runtime.h"
#include "common-hal/bleio/__init__.h"
#include "common-hal/bleio/Characteristic.h"
-#include "shared-module/bleio/Characteristic.h"
STATIC volatile bleio_characteristic_obj_t *m_read_characteristic;
-STATIC volatile uint8_t m_tx_in_progress;
-// Serialize gattc writes that send a response. This might be done per object?
-STATIC nrf_mutex_t *m_write_mutex;
STATIC uint16_t get_cccd(bleio_characteristic_obj_t *characteristic) {
const uint16_t conn_handle = common_hal_bleio_device_get_conn_handle(characteristic->service->device);
@@ -63,7 +60,7 @@ STATIC uint16_t get_cccd(bleio_characteristic_obj_t *characteristic) {
}
STATIC void gatts_read(bleio_characteristic_obj_t *characteristic) {
- // This might be BLE_CONN_HANDLE_INVALID if we're not conected, but that's OK, because
+ // This might be BLE_CONN_HANDLE_INVALID if we're not connected, but that's OK, because
// we can still read and write the local value.
const uint16_t conn_handle = common_hal_bleio_device_get_conn_handle(characteristic->service->device);
@@ -118,24 +115,35 @@ STATIC void gatts_notify_indicate(bleio_characteristic_obj_t *characteristic, mp
.p_data = bufinfo->buf,
};
- while (m_tx_in_progress >= MAX_TX_IN_PROGRESS) {
-#ifdef MICROPY_VM_HOOK_LOOP
- MICROPY_VM_HOOK_LOOP
-#endif
- }
-
const uint16_t conn_handle = common_hal_bleio_device_get_conn_handle(characteristic->service->device);
- m_tx_in_progress++;
- const uint32_t err_code = sd_ble_gatts_hvx(conn_handle, &hvx_params);
- if (err_code != NRF_SUCCESS) {
- m_tx_in_progress--;
+
+ while (1) {
+ const uint32_t err_code = sd_ble_gatts_hvx(conn_handle, &hvx_params);
+ if (err_code == NRF_SUCCESS) {
+ break;
+ }
+ // TX buffer is full
+ // We could wait for an event indicating the write is complete, but just retrying is easier.
+ if (err_code == NRF_ERROR_RESOURCES) {
+ MICROPY_VM_HOOK_LOOP;
+ continue;
+ }
+
+ // Some real error has occurred.
mp_raise_OSError_msg_varg(translate("Failed to notify or indicate attribute value, err 0x%04x"), err_code);
}
}
+STATIC void check_connected(uint16_t conn_handle) {
+ if (conn_handle == BLE_CONN_HANDLE_INVALID) {
+ mp_raise_OSError_msg(translate("Not connected"));
+ }
+}
+
STATIC void gattc_read(bleio_characteristic_obj_t *characteristic) {
const uint16_t conn_handle = common_hal_bleio_device_get_conn_handle(characteristic->service->device);
+ check_connected(conn_handle);
m_read_characteristic = characteristic;
@@ -144,100 +152,79 @@ STATIC void gattc_read(bleio_characteristic_obj_t *characteristic) {
mp_raise_OSError_msg_varg(translate("Failed to read attribute value, err 0x%04x"), err_code);
}
-//
while (m_read_characteristic != NULL) {
-#ifdef MICROPY_VM_HOOK_LOOP
- MICROPY_VM_HOOK_LOOP
-#endif
+ MICROPY_VM_HOOK_LOOP;
}
}
STATIC void gattc_write(bleio_characteristic_obj_t *characteristic, mp_buffer_info_t *bufinfo) {
const uint16_t conn_handle = common_hal_bleio_device_get_conn_handle(characteristic->service->device);
- uint32_t err_code;
+ check_connected(conn_handle);
ble_gattc_write_params_t write_params = {
- .flags = BLE_GATT_EXEC_WRITE_FLAG_PREPARED_CANCEL,
- .write_op = BLE_GATT_OP_WRITE_REQ,
+ .write_op = characteristic->props.write_no_response ? BLE_GATT_OP_WRITE_CMD : BLE_GATT_OP_WRITE_REQ,
.handle = characteristic->handle,
.p_value = bufinfo->buf,
.len = bufinfo->len,
};
- if (characteristic->props.write_no_response) {
- write_params.write_op = BLE_GATT_OP_WRITE_CMD;
+ while (1) {
+ uint32_t err_code = sd_ble_gattc_write(conn_handle, &write_params);
+ if (err_code == NRF_SUCCESS) {
+ break;
+ }
- err_code = sd_mutex_acquire(m_write_mutex);
- if (err_code != NRF_SUCCESS) {
- mp_raise_OSError_msg_varg(translate("Failed to acquire mutex, err 0x%04x"), err_code);
+ // Write with response will return NRF_ERROR_BUSY if the response has not been received.
+ // Write without reponse will return NRF_ERROR_RESOURCES if too many writes are pending.
+ if (err_code == NRF_ERROR_BUSY || err_code == NRF_ERROR_RESOURCES) {
+ // We could wait for an event indicating the write is complete, but just retrying is easier.
+ MICROPY_VM_HOOK_LOOP;
+ continue;
}
- }
- err_code = sd_ble_gattc_write(conn_handle, &write_params);
- if (err_code != NRF_SUCCESS) {
+ // Some real error occurred.
mp_raise_OSError_msg_varg(translate("Failed to write attribute value, err 0x%04x"), err_code);
}
- while (sd_mutex_acquire(m_write_mutex) == NRF_ERROR_SOC_MUTEX_ALREADY_TAKEN) {
-#ifdef MICROPY_VM_HOOK_LOOP
- MICROPY_VM_HOOK_LOOP
-#endif
- }
-
- err_code = sd_mutex_release(m_write_mutex);
- if (err_code != NRF_SUCCESS) {
- mp_raise_OSError_msg_varg(translate("Failed to release mutex, err 0x%04x"), err_code);
- }
}
STATIC void characteristic_on_ble_evt(ble_evt_t *ble_evt, void *param) {
switch (ble_evt->header.evt_id) {
- case BLE_GATTS_EVT_HVN_TX_COMPLETE:
- {
- uint8_t count = ble_evt->evt.gatts_evt.params.hvn_tx_complete.count;
- // Don't underflow the count.
- if (count >= m_tx_in_progress) {
- m_tx_in_progress = 0;
- } else {
- m_tx_in_progress -= count;
- }
- break;
- }
- case BLE_GATTC_EVT_READ_RSP:
- {
- ble_gattc_evt_read_rsp_t *response = &ble_evt->evt.gattc_evt.params.read_rsp;
- m_read_characteristic->value_data = mp_obj_new_bytearray(response->len, response->data);
- // Flag to busy-wait loop that we've read the characteristic.
- m_read_characteristic = NULL;
- break;
- }
+ // More events may be handled later, so keep this as a switch.
- case BLE_GATTC_EVT_WRITE_RSP:
- // Someone else can write now.
- sd_mutex_release(m_write_mutex);
- break;
+ case BLE_GATTC_EVT_READ_RSP: {
+ ble_gattc_evt_read_rsp_t *response = &ble_evt->evt.gattc_evt.params.read_rsp;
+ m_read_characteristic->value_data = mp_obj_new_bytearray(response->len, response->data);
+ // Indicate to busy-wait loop that we've read the characteristic.
+ m_read_characteristic = NULL;
+ break;
+ }
- // For debugging.
- default:
- // mp_printf(&mp_plat_print, "Unhandled characteristic event: 0x%04x\n", ble_evt->header.evt_id);
- break;
+ // For debugging.
+ default:
+ // mp_printf(&mp_plat_print, "Unhandled characteristic event: 0x%04x\n", ble_evt->header.evt_id);
+ break;
}
}
-void common_hal_bleio_characteristic_construct(bleio_characteristic_obj_t *self, bleio_uuid_obj_t *uuid, bleio_characteristic_properties_t props) {
- self->service = NULL;
+void common_hal_bleio_characteristic_construct(bleio_characteristic_obj_t *self, bleio_uuid_obj_t *uuid, bleio_characteristic_properties_t props, mp_obj_list_t *descriptor_list) {
+ self->service = mp_const_none;
self->uuid = uuid;
- self->value_data = NULL;
+ self->value_data = mp_const_none;
self->props = props;
+ self->descriptor_list = descriptor_list;
self->handle = BLE_GATT_HANDLE_INVALID;
ble_drv_add_event_handler(characteristic_on_ble_evt, self);
+}
+mp_obj_list_t *common_hal_bleio_characteristic_get_descriptor_list(bleio_characteristic_obj_t *self) {
+ return self->descriptor_list;
}
-void common_hal_bleio_characteristic_get_value(bleio_characteristic_obj_t *self) {
+mp_obj_t common_hal_bleio_characteristic_get_value(bleio_characteristic_obj_t *self) {
switch (common_hal_bleio_device_get_gatt_role(self->service->device)) {
case GATT_ROLE_CLIENT:
gattc_read(self);
@@ -251,6 +238,8 @@ void common_hal_bleio_characteristic_get_value(bleio_characteristic_obj_t *self)
mp_raise_RuntimeError(translate("bad GATT role"));
break;
}
+
+ return self->value_data;
}
void common_hal_bleio_characteristic_set_value(bleio_characteristic_obj_t *self, mp_buffer_info_t *bufinfo) {
@@ -258,30 +247,83 @@ void common_hal_bleio_characteristic_set_value(bleio_characteristic_obj_t *self,
uint16_t cccd = 0;
switch (common_hal_bleio_device_get_gatt_role(self->service->device)) {
- case GATT_ROLE_SERVER:
- if (self->props.notify || self->props.indicate) {
- cccd = get_cccd(self);
- }
- // It's possible that both notify and indicate are set.
- if (self->props.notify && (cccd & BLE_GATT_HVX_NOTIFICATION)) {
- gatts_notify_indicate(self, bufinfo, BLE_GATT_HVX_NOTIFICATION);
- sent = true;
- }
- if (self->props.indicate && (cccd & BLE_GATT_HVX_INDICATION)) {
- gatts_notify_indicate(self, bufinfo, BLE_GATT_HVX_INDICATION);
- sent = true;
- }
- if (!sent) {
- gatts_write(self, bufinfo);
+ case GATT_ROLE_SERVER:
+ if (self->props.notify || self->props.indicate) {
+ cccd = get_cccd(self);
+ }
+ // It's possible that both notify and indicate are set.
+ if (self->props.notify && (cccd & BLE_GATT_HVX_NOTIFICATION)) {
+ gatts_notify_indicate(self, bufinfo, BLE_GATT_HVX_NOTIFICATION);
+ sent = true;
+ }
+ if (self->props.indicate && (cccd & BLE_GATT_HVX_INDICATION)) {
+ gatts_notify_indicate(self, bufinfo, BLE_GATT_HVX_INDICATION);
+ sent = true;
+ }
+ if (!sent) {
+ gatts_write(self, bufinfo);
+ }
+ break;
+
+ case GATT_ROLE_CLIENT:
+ gattc_write(self, bufinfo);
+ break;
+
+ default:
+ mp_raise_RuntimeError(translate("bad GATT role"));
+ break;
+ }
+}
+
+
+bleio_uuid_obj_t *common_hal_bleio_characteristic_get_uuid(bleio_characteristic_obj_t *self) {
+ return self->uuid;
+}
+
+bleio_characteristic_properties_t common_hal_bleio_characteristic_get_properties(bleio_characteristic_obj_t *self) {
+ return self->props;
+}
+
+void common_hal_bleio_characteristic_set_cccd(bleio_characteristic_obj_t *self, bool notify, bool indicate) {
+ if (self->cccd_handle == BLE_GATT_HANDLE_INVALID) {
+ mp_raise_ValueError(translate("No CCCD for this Characteristic"));
+ }
+
+ if (common_hal_bleio_device_get_gatt_role(self->service->device) != GATT_ROLE_CLIENT) {
+ mp_raise_ValueError(translate("Can't set CCCD for local Characteristic"));
+ }
+
+ uint16_t cccd_value =
+ (notify ? BLE_GATT_HVX_NOTIFICATION : 0) |
+ (indicate ? BLE_GATT_HVX_INDICATION : 0);
+
+ const uint16_t conn_handle = common_hal_bleio_device_get_conn_handle(self->service->device);
+ check_connected(conn_handle);
+
+
+ ble_gattc_write_params_t write_params = {
+ .write_op = BLE_GATT_OP_WRITE_REQ,
+ .handle = self->cccd_handle,
+ .p_value = (uint8_t *) &cccd_value,
+ .len = 2,
+ };
+
+ while (1) {
+ uint32_t err_code = sd_ble_gattc_write(conn_handle, &write_params);
+ if (err_code == NRF_SUCCESS) {
+ break;
}
- break;
- case GATT_ROLE_CLIENT:
- gattc_write(self, bufinfo);
- break;
+ // Write with response will return NRF_ERROR_BUSY if the response has not been received.
+ // Write without reponse will return NRF_ERROR_RESOURCES if too many writes are pending.
+ if (err_code == NRF_ERROR_BUSY || err_code == NRF_ERROR_RESOURCES) {
+ // We could wait for an event indicating the write is complete, but just retrying is easier.
+ MICROPY_VM_HOOK_LOOP;
+ continue;
+ }
- default:
- mp_raise_RuntimeError(translate("bad GATT role"));
- break;
+ // Some real error occurred.
+ mp_raise_OSError_msg_varg(translate("Failed to write CCCD, err 0x%04x"), err_code);
}
+
}
diff --git a/ports/nrf/common-hal/bleio/Characteristic.h b/ports/nrf/common-hal/bleio/Characteristic.h
index bce1eec1d..7cb227596 100644
--- a/ports/nrf/common-hal/bleio/Characteristic.h
+++ b/ports/nrf/common-hal/bleio/Characteristic.h
@@ -3,6 +3,7 @@
*
* The MIT License (MIT)
*
+ * Copyright (c) 2019 Dan Halbert for Adafruit Industries
* Copyright (c) 2018 Artur Pacholec
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -24,23 +25,24 @@
* THE SOFTWARE.
*/
-#ifndef MICROPY_INCLUDED_COMMON_HAL_BLEIO_CHARACTERISTIC_H
-#define MICROPY_INCLUDED_COMMON_HAL_BLEIO_CHARACTERISTIC_H
+#ifndef MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_CHARACTERISTIC_H
+#define MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_CHARACTERISTIC_H
-#include "shared-module/bleio/Characteristic.h"
-#include "shared-module/bleio/Service.h"
+#include "common-hal/bleio/Service.h"
#include "common-hal/bleio/UUID.h"
+#include "shared-module/bleio/Characteristic.h"
typedef struct {
mp_obj_base_t base;
bleio_service_obj_t *service;
bleio_uuid_obj_t *uuid;
- mp_obj_t value_data;
+ volatile mp_obj_t value_data;
uint16_t handle;
bleio_characteristic_properties_t props;
+ mp_obj_list_t *descriptor_list;
uint16_t user_desc_handle;
uint16_t cccd_handle;
uint16_t sccd_handle;
} bleio_characteristic_obj_t;
-#endif // MICROPY_INCLUDED_COMMON_HAL_BLEIO_CHARACTERISTIC_H
+#endif // MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_CHARACTERISTIC_H
diff --git a/ports/nrf/common-hal/bleio/CharacteristicBuffer.c b/ports/nrf/common-hal/bleio/CharacteristicBuffer.c
index 19b3b85ea..59eaaf02b 100644
--- a/ports/nrf/common-hal/bleio/CharacteristicBuffer.c
+++ b/ports/nrf/common-hal/bleio/CharacteristicBuffer.c
@@ -40,25 +40,42 @@
#include "common-hal/bleio/__init__.h"
#include "common-hal/bleio/CharacteristicBuffer.h"
+STATIC void write_to_ringbuf(bleio_characteristic_buffer_obj_t *self, uint8_t *data, uint16_t len) {
+ // Push all the data onto the ring buffer.
+ uint8_t is_nested_critical_region;
+ sd_nvic_critical_region_enter(&is_nested_critical_region);
+ for (size_t i = 0; i < len; i++) {
+ ringbuf_put(&self->ringbuf, data[i]);
+ }
+ sd_nvic_critical_region_exit(is_nested_critical_region);
+}
+
STATIC void characteristic_buffer_on_ble_evt(ble_evt_t *ble_evt, void *param) {
bleio_characteristic_buffer_obj_t *self = (bleio_characteristic_buffer_obj_t *) param;
switch (ble_evt->header.evt_id) {
- case BLE_GATTS_EVT_WRITE: {
- ble_gatts_evt_write_t *evt_write = &ble_evt->evt.gatts_evt.params.write;
- // Event handle must match the handle for my characteristic.
- if (evt_write->handle == self->characteristic->handle) {
- // Push all the data onto the ring buffer.
- uint8_t is_nested_critical_region;
- sd_nvic_critical_region_enter(&is_nested_critical_region);
- for (size_t i = 0; i < evt_write->len; i++) {
- ringbuf_put(&self->ringbuf, evt_write->data[i]);
+ case BLE_GATTS_EVT_WRITE: {
+ // A client wrote to this server characteristic.
+
+ ble_gatts_evt_write_t *evt_write = &ble_evt->evt.gatts_evt.params.write;
+ // Event handle must match the handle for my characteristic.
+ if (evt_write->handle == self->characteristic->handle) {
+ write_to_ringbuf(self, evt_write->data, evt_write->len);
}
- sd_nvic_critical_region_exit(is_nested_critical_region);
break;
}
- }
- }
+ case BLE_GATTC_EVT_HVX: {
+ // A remote service wrote to this characteristic.
+
+ ble_gattc_evt_hvx_t* evt_hvx = &ble_evt->evt.gattc_evt.params.hvx;
+ // Must be a notification, and event handle must match the handle for my characteristic.
+ if (evt_hvx->type == BLE_GATT_HVX_NOTIFICATION &&
+ evt_hvx->handle == self->characteristic->handle) {
+ write_to_ringbuf(self, evt_hvx->data, evt_hvx->len);
+ }
+ break;
+ }
+ }
}
// Assumes that timeout and buffer_size have been validated before call.
@@ -82,13 +99,11 @@ int common_hal_bleio_characteristic_buffer_read(bleio_characteristic_buffer_obj_
// Wait for all bytes received or timeout
while ( (ringbuf_count(&self->ringbuf) < len) && (ticks_ms - start_ticks < self->timeout_ms) ) {
-#ifdef MICROPY_VM_HOOK_LOOP
- MICROPY_VM_HOOK_LOOP ;
+ MICROPY_VM_HOOK_LOOP;
// Allow user to break out of a timeout with a KeyboardInterrupt.
if ( mp_hal_is_interrupted() ) {
return 0;
}
-#endif
}
// Copy received data. Lock out write interrupt handler while copying.
diff --git a/ports/nrf/common-hal/bleio/CharacteristicBuffer.h b/ports/nrf/common-hal/bleio/CharacteristicBuffer.h
index b36f63fec..db8fd2fad 100644
--- a/ports/nrf/common-hal/bleio/CharacteristicBuffer.h
+++ b/ports/nrf/common-hal/bleio/CharacteristicBuffer.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2018 Artur Pacholec
+ * 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
@@ -24,8 +24,8 @@
* THE SOFTWARE.
*/
-#ifndef MICROPY_INCLUDED_COMMON_HAL_BLEIO_CHARACTERISTICBUFFER_H
-#define MICROPY_INCLUDED_COMMON_HAL_BLEIO_CHARACTERISTICBUFFER_H
+#ifndef MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_CHARACTERISTICBUFFER_H
+#define MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_CHARACTERISTICBUFFER_H
#include "nrf_soc.h"
@@ -40,4 +40,4 @@ typedef struct {
ringbuf_t ringbuf;
} bleio_characteristic_buffer_obj_t;
-#endif // MICROPY_INCLUDED_COMMON_HAL_BLEIO_CHARACTERISTICBUFFER_H
+#endif // MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_CHARACTERISTICBUFFER_H
diff --git a/ports/nrf/common-hal/bleio/Descriptor.c b/ports/nrf/common-hal/bleio/Descriptor.c
index 8282be8f2..005af6eaa 100644
--- a/ports/nrf/common-hal/bleio/Descriptor.c
+++ b/ports/nrf/common-hal/bleio/Descriptor.c
@@ -3,8 +3,9 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2016 Glenn Ruben Bakke
+ * Copyright (c) 2018 Dan Halbert for Adafruit Industries
* Copyright (c) 2018 Artur Pacholec
+ * Copyright (c) 2016 Glenn Ruben Bakke
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -29,7 +30,6 @@
#include "shared-bindings/bleio/UUID.h"
void common_hal_bleio_descriptor_construct(bleio_descriptor_obj_t *self, bleio_uuid_obj_t *uuid) {
- // TODO: set handle ???
self->uuid = uuid;
}
@@ -37,6 +37,6 @@ mp_int_t common_hal_bleio_descriptor_get_handle(bleio_descriptor_obj_t *self) {
return self->handle;
}
-mp_obj_t common_hal_bleio_descriptor_get_uuid(bleio_descriptor_obj_t *self) {
- return MP_OBJ_FROM_PTR(self->uuid);
+bleio_uuid_obj_t *common_hal_bleio_descriptor_get_uuid(bleio_descriptor_obj_t *self) {
+ return self->uuid;
}
diff --git a/ports/nrf/common-hal/bleio/Descriptor.h b/ports/nrf/common-hal/bleio/Descriptor.h
index ee0886c22..b7af6a42f 100644
--- a/ports/nrf/common-hal/bleio/Descriptor.h
+++ b/ports/nrf/common-hal/bleio/Descriptor.h
@@ -3,8 +3,9 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2016 Glenn Ruben Bakke
+ * Copyright (c) 2018 Dan Halbert for Adafruit Industries
* Copyright (c) 2018 Artur Pacholec
+ * Copyright (c) 2016 Glenn Ruben Bakke
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -29,11 +30,13 @@
#define MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_DESCRIPTOR_H
#include "py/obj.h"
+#include "common-hal/bleio/Characteristic.h"
#include "common-hal/bleio/UUID.h"
typedef struct {
mp_obj_base_t base;
uint16_t handle;
+ bleio_characteristic_obj_t *characteristic;
bleio_uuid_obj_t *uuid;
} bleio_descriptor_obj_t;
diff --git a/ports/nrf/common-hal/bleio/Device.c b/ports/nrf/common-hal/bleio/Device.c
deleted file mode 100644
index 5f625829e..000000000
--- a/ports/nrf/common-hal/bleio/Device.c
+++ /dev/null
@@ -1,601 +0,0 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2018 Artur Pacholec
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-#include <string.h>
-#include <stdio.h>
-
-#include "ble.h"
-#include "ble_drv.h"
-#include "ble_hci.h"
-#include "nrf_soc.h"
-#include "py/objstr.h"
-#include "py/runtime.h"
-#include "shared-bindings/bleio/Adapter.h"
-#include "shared-bindings/bleio/Characteristic.h"
-#include "shared-bindings/bleio/Device.h"
-#include "shared-bindings/bleio/Service.h"
-#include "shared-bindings/bleio/UUID.h"
-
-#define BLE_MIN_CONN_INTERVAL MSEC_TO_UNITS(15, UNIT_0_625_MS)
-#define BLE_MAX_CONN_INTERVAL MSEC_TO_UNITS(300, UNIT_0_625_MS)
-#define BLE_SLAVE_LATENCY 0
-#define BLE_CONN_SUP_TIMEOUT MSEC_TO_UNITS(4000, UNIT_10_MS)
-
-#define BLE_ADV_LENGTH_FIELD_SIZE 1
-#define BLE_ADV_AD_TYPE_FIELD_SIZE 1
-#define BLE_AD_TYPE_FLAGS_DATA_SIZE 1
-
-#ifndef BLE_GAP_ADV_MAX_SIZE
-#define BLE_GAP_ADV_MAX_SIZE 31
-#endif
-
-static bleio_service_obj_t *m_char_discovery_service;
-static volatile bool m_discovery_successful;
-static nrf_mutex_t *m_discovery_mutex;
-
-#if (BLUETOOTH_SD == 140)
-static uint8_t m_adv_handle = BLE_GAP_ADV_SET_HANDLE_NOT_SET;
-
-static uint8_t m_scan_buffer_data[BLE_GAP_SCAN_BUFFER_MIN];
-
-static ble_data_t m_scan_buffer = {
- .p_data = m_scan_buffer_data,
- .len = BLE_GAP_SCAN_BUFFER_MIN
-};
-#endif
-
-STATIC uint32_t set_advertisement_data(bleio_device_obj_t *device, bool connectable, mp_buffer_info_t *raw_data) {
- common_hal_bleio_adapter_set_enabled(true);
-
- uint8_t adv_data[BLE_GAP_ADV_MAX_SIZE];
- uint8_t byte_pos = 0;
- uint32_t err_code;
-
-#define ADD_FIELD(field, len) \
- do { \
- if (byte_pos + (len) > BLE_GAP_ADV_MAX_SIZE) { \
- mp_raise_ValueError(translate("Data too large for the advertisement packet")); \
- } \
- adv_data[byte_pos] = (field); \
- byte_pos += (len); \
- } while (0)
-
- GET_STR_DATA_LEN(device->name, name_data, name_len);
- if (name_len > 0) {
- ble_gap_conn_sec_mode_t sec_mode;
- BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode);
-
- err_code = sd_ble_gap_device_name_set(&sec_mode, name_data, name_len);
- if (err_code != NRF_SUCCESS) {
- return err_code;
- }
-
- // TODO: Shorten if too long
-
- ADD_FIELD(BLE_ADV_AD_TYPE_FIELD_SIZE + name_len, BLE_ADV_LENGTH_FIELD_SIZE);
- ADD_FIELD(BLE_GAP_AD_TYPE_COMPLETE_LOCAL_NAME, BLE_ADV_AD_TYPE_FIELD_SIZE);
-
- memcpy(&adv_data[byte_pos], name_data, name_len);
- byte_pos += name_len;
- }
-
- // set flags, default to disc mode
- if (raw_data->len == 0) {
- ADD_FIELD(BLE_ADV_AD_TYPE_FIELD_SIZE + BLE_AD_TYPE_FLAGS_DATA_SIZE, BLE_ADV_LENGTH_FIELD_SIZE);
- ADD_FIELD(BLE_GAP_AD_TYPE_FLAGS, BLE_AD_TYPE_FLAGS_DATA_SIZE);
- ADD_FIELD(BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE, BLE_AD_TYPE_FLAGS_DATA_SIZE);
- } else {
- if (byte_pos + raw_data->len > BLE_GAP_ADV_MAX_SIZE) {
- mp_raise_ValueError(translate("Data too large for the advertisement packet"));
- }
-
- memcpy(&adv_data[byte_pos], raw_data->buf, raw_data->len);
- byte_pos += raw_data->len;
- }
-
- const mp_obj_list_t *service_list = MP_OBJ_TO_PTR(device->service_list);
- if (service_list->len > 0) {
- bool has_128bit_services = false;
- bool has_16bit_services = false;
-
- for (size_t i = 0; i < service_list->len; ++i) {
- const bleio_service_obj_t *service = MP_OBJ_TO_PTR(service_list->items[i]);
-
- if (service->is_secondary) {
- continue;
- }
-
- switch (common_hal_bleio_uuid_get_size(service->uuid)) {
- case 16:
- has_16bit_services = true;
- break;
- case 128:
- has_128bit_services = true;
- break;
- }
- }
-
- if (has_16bit_services) {
- const uint8_t size_byte_pos = byte_pos;
- uint8_t uuid_total_size = 0;
-
- // skip length byte for now, apply total length post calculation
- byte_pos += BLE_ADV_LENGTH_FIELD_SIZE;
-
- ADD_FIELD(BLE_GAP_AD_TYPE_16BIT_SERVICE_UUID_COMPLETE, BLE_ADV_AD_TYPE_FIELD_SIZE);
-
- for (size_t i = 0; i < service_list->len; ++i) {
- const bleio_service_obj_t *service = MP_OBJ_TO_PTR(service_list->items[i]);
- uint8_t encoded_size = 0;
-
- if (common_hal_bleio_uuid_get_size(service->uuid) != 16 || service->is_secondary) {
- continue;
- }
-
- ble_uuid_t uuid;
- bleio_uuid_convert_to_nrf_ble_uuid(service->uuid, &uuid);
-
- err_code = sd_ble_uuid_encode(&uuid, &encoded_size, &adv_data[byte_pos]);
- if (err_code != NRF_SUCCESS) {
- return err_code;
- }
-
- uuid_total_size += encoded_size;
- byte_pos += encoded_size;
- }
-
- adv_data[size_byte_pos] = (BLE_ADV_AD_TYPE_FIELD_SIZE + uuid_total_size);
- }
-
- if (has_128bit_services) {
- const uint8_t size_byte_pos = byte_pos;
- uint8_t uuid_total_size = 0;
-
- // skip length byte for now, apply total length post calculation
- byte_pos += BLE_ADV_LENGTH_FIELD_SIZE;
-
- ADD_FIELD(BLE_GAP_AD_TYPE_128BIT_SERVICE_UUID_COMPLETE, BLE_ADV_AD_TYPE_FIELD_SIZE);
-
- for (size_t i = 0; i < service_list->len; ++i) {
- const bleio_service_obj_t *service = MP_OBJ_TO_PTR(service_list->items[i]);
- uint8_t encoded_size = 0;
-
- if (common_hal_bleio_uuid_get_size(service->uuid) != 16 || service->is_secondary) {
- continue;
- }
-
- ble_uuid_t uuid;
- bleio_uuid_convert_to_nrf_ble_uuid(service->uuid, &uuid);
-
- err_code = sd_ble_uuid_encode(&uuid, &encoded_size, &adv_data[byte_pos]);
- if (err_code != NRF_SUCCESS) {
- return err_code;
- }
-
- uuid_total_size += encoded_size;
- byte_pos += encoded_size;
- }
-
- adv_data[size_byte_pos] = (BLE_ADV_AD_TYPE_FIELD_SIZE + uuid_total_size);
- }
- }
-
-#if (BLUETOOTH_SD == 132)
- err_code = sd_ble_gap_adv_data_set(adv_data, byte_pos, NULL, 0);
- if (err_code != NRF_SUCCESS) {
- return err_code;
- }
-#endif
-
- static ble_gap_adv_params_t m_adv_params = {
- .interval = MSEC_TO_UNITS(100, UNIT_0_625_MS),
-#if (BLUETOOTH_SD == 140)
- .properties.type = BLE_GAP_ADV_TYPE_CONNECTABLE_SCANNABLE_UNDIRECTED,
- .duration = BLE_GAP_ADV_TIMEOUT_GENERAL_UNLIMITED,
- .filter_policy = BLE_GAP_ADV_FP_ANY,
- .primary_phy = BLE_GAP_PHY_1MBPS,
-#else
- .type = BLE_GAP_ADV_TYPE_ADV_IND,
- .fp = BLE_GAP_ADV_FP_ANY,
-#endif
- };
-
- if (!connectable) {
-#if (BLUETOOTH_SD == 140)
- m_adv_params.properties.type = BLE_GAP_ADV_TYPE_NONCONNECTABLE_NONSCANNABLE_UNDIRECTED;
-#else
- m_adv_params.type = BLE_GAP_ADV_TYPE_ADV_NONCONN_IND;
-#endif
- }
-
- common_hal_bleio_device_stop_advertising(device);
-
-#if (BLUETOOTH_SD == 140)
- const ble_gap_adv_data_t ble_gap_adv_data = {
- .adv_data.p_data = adv_data,
- .adv_data.len = byte_pos,
- };
-
- err_code = sd_ble_gap_adv_set_configure(&m_adv_handle, &ble_gap_adv_data, &m_adv_params);
- if (err_code != NRF_SUCCESS) {
- return err_code;
- }
-
- err_code = sd_ble_gap_adv_start(m_adv_handle, BLE_CONN_CFG_TAG_CUSTOM);
-#elif (BLUETOOTH_SD == 132 && BLE_API_VERSION == 4)
- err_code = sd_ble_gap_adv_start(&m_adv_params, BLE_CONN_CFG_TAG_CUSTOM);
-#else
- err_code = sd_ble_gap_adv_start(&m_adv_params);
-#endif
-
- return err_code;
-}
-
-STATIC bool discover_services(bleio_device_obj_t *device, uint16_t start_handle) {
- m_discovery_successful = false;
-
- uint32_t err_code = sd_ble_gattc_primary_services_discover(device->conn_handle, start_handle, NULL);
- if (err_code != NRF_SUCCESS) {
- mp_raise_OSError_msg(translate("Failed to discover services"));
- }
-
- // Serialize discovery.
- err_code = sd_mutex_acquire(m_discovery_mutex);
- if (err_code != NRF_SUCCESS) {
- mp_raise_OSError_msg(translate("Failed to acquire mutex"));
- }
-
- // Wait for someone else to release m_discovery_mutex.
- while (sd_mutex_acquire(m_discovery_mutex) == NRF_ERROR_SOC_MUTEX_ALREADY_TAKEN) {
-#ifdef MICROPY_VM_HOOK_LOOP
- MICROPY_VM_HOOK_LOOP
-#endif
- }
-
- err_code = sd_mutex_release(m_discovery_mutex);
- if (err_code != NRF_SUCCESS) {
- mp_raise_OSError_msg(translate("Failed to release mutex"));
- }
-
- return m_discovery_successful;
-}
-
-STATIC bool discover_characteristics(bleio_device_obj_t *device, bleio_service_obj_t *service, uint16_t start_handle) {
- m_char_discovery_service = service;
-
- ble_gattc_handle_range_t handle_range;
- handle_range.start_handle = start_handle;
- handle_range.end_handle = service->end_handle;
-
- m_discovery_successful = false;
-
- uint32_t err_code = sd_ble_gattc_characteristics_discover(device->conn_handle, &handle_range);
- if (err_code != NRF_SUCCESS) {
- return false;
- }
-
- err_code = sd_mutex_acquire(m_discovery_mutex);
- if (err_code != NRF_SUCCESS) {
- mp_raise_OSError_msg(translate("Failed to acquire mutex"));
- }
-
- while (sd_mutex_acquire(m_discovery_mutex) == NRF_ERROR_SOC_MUTEX_ALREADY_TAKEN) {
-#ifdef MICROPY_VM_HOOK_LOOP
- MICROPY_VM_HOOK_LOOP
-#endif
- }
-
- err_code = sd_mutex_release(m_discovery_mutex);
- if (err_code != NRF_SUCCESS) {
- mp_raise_OSError_msg(translate("Failed to release mutex"));
- }
-
- return m_discovery_successful;
-}
-
-STATIC void on_primary_srv_discovery_rsp(ble_gattc_evt_prim_srvc_disc_rsp_t *response, bleio_device_obj_t *device) {
- for (size_t i = 0; i < response->count; ++i) {
- ble_gattc_service_t *gattc_service = &response->services[i];
-
- bleio_service_obj_t *service = m_new_obj(bleio_service_obj_t);
- service->base.type = &bleio_service_type;
- service->device = device;
- service->char_list = mp_obj_new_list(0, NULL);
- service->start_handle = gattc_service->handle_range.start_handle;
- service->end_handle = gattc_service->handle_range.end_handle;
- service->handle = gattc_service->handle_range.start_handle;
-
- bleio_uuid_obj_t *uuid = m_new_obj(bleio_uuid_obj_t);
- bleio_uuid_construct_from_nrf_ble_uuid(uuid, &gattc_service->uuid);
- service->uuid = uuid;
-
- mp_obj_list_append(device->service_list, service);
- }
-
- if (response->count > 0) {
- m_discovery_successful = true;
- }
-
- const uint32_t err_code = sd_mutex_release(m_discovery_mutex);
- if (err_code != NRF_SUCCESS) {
- mp_raise_OSError_msg(translate("Failed to release mutex"));
- }
-}
-
-STATIC void on_char_discovery_rsp(ble_gattc_evt_char_disc_rsp_t *response, bleio_device_obj_t *device) {
- for (size_t i = 0; i < response->count; ++i) {
- ble_gattc_char_t *gattc_char = &response->chars[i];
-
- bleio_characteristic_obj_t *characteristic = m_new_obj(bleio_characteristic_obj_t);
- characteristic->base.type = &bleio_characteristic_type;
-
- bleio_uuid_obj_t *uuid = m_new_obj(bleio_uuid_obj_t);
- uuid->base.type = &bleio_uuid_type;
- bleio_uuid_construct_from_nrf_ble_uuid(uuid, &gattc_char->uuid);
- characteristic->uuid = uuid;
-
- characteristic->props.broadcast = gattc_char->char_props.broadcast;
- characteristic->props.indicate = gattc_char->char_props.indicate;
- characteristic->props.notify = gattc_char->char_props.notify;
- characteristic->props.read = gattc_char->char_props.read;
- characteristic->props.write = gattc_char->char_props.write;
- characteristic->props.write_no_response = gattc_char->char_props.write_wo_resp;
- characteristic->handle = gattc_char->handle_value;
- characteristic->service = m_char_discovery_service;
-
- mp_obj_list_append(m_char_discovery_service->char_list, MP_OBJ_FROM_PTR(characteristic));
- }
-
- if (response->count > 0) {
- m_discovery_successful = true;
- }
-
- const uint32_t err_code = sd_mutex_release(m_discovery_mutex);
- if (err_code != NRF_SUCCESS) {
- mp_raise_OSError_msg(translate("Failed to release mutex"));
- }
-}
-
-STATIC void on_adv_report(ble_gap_evt_adv_report_t *report, bleio_device_obj_t *device) {
- uint32_t err_code;
-
- if (memcmp(report->peer_addr.addr, device->address.value, BLEIO_ADDRESS_BYTES) != 0) {
-#if (BLUETOOTH_SD == 140)
- err_code = sd_ble_gap_scan_start(NULL, &m_scan_buffer);
- if (err_code != NRF_SUCCESS) {
- mp_raise_OSError_msg(translate("Failed to continue scanning"));
- }
-#endif
- return;
- }
-
- ble_gap_scan_params_t scan_params = {
- .active = 1,
- .interval = MSEC_TO_UNITS(100, UNIT_0_625_MS),
- .window = MSEC_TO_UNITS(100, UNIT_0_625_MS),
- };
-
- ble_gap_addr_t addr;
- memset(&addr, 0, sizeof(addr));
-
- addr.addr_type = report->peer_addr.addr_type;
- memcpy(addr.addr, report->peer_addr.addr, BLEIO_ADDRESS_BYTES);
-
- ble_gap_conn_params_t conn_params = {
- .min_conn_interval = BLE_MIN_CONN_INTERVAL,
- .max_conn_interval = BLE_MAX_CONN_INTERVAL,
- .conn_sup_timeout = BLE_CONN_SUP_TIMEOUT,
- .slave_latency = BLE_SLAVE_LATENCY,
- };
-
-#if (BLE_API_VERSION == 2)
- err_code = sd_ble_gap_connect(&addr, &scan_params, &conn_params);
-#else
- err_code = sd_ble_gap_connect(&addr, &scan_params, &conn_params, BLE_CONN_CFG_TAG_CUSTOM);
-#endif
-
- if (err_code != NRF_SUCCESS) {
- mp_raise_OSError_msg(translate("Failed to connect:"));
- }
-}
-
-STATIC void on_ble_evt(ble_evt_t *ble_evt, void *device_in) {
- bleio_device_obj_t *device = (bleio_device_obj_t*)device_in;
-
- switch (ble_evt->header.evt_id) {
- case BLE_GAP_EVT_CONNECTED:
- {
- ble_gap_conn_params_t conn_params;
- device->conn_handle = ble_evt->evt.gap_evt.conn_handle;
-
- sd_ble_gap_ppcp_get(&conn_params);
- sd_ble_gap_conn_param_update(ble_evt->evt.gap_evt.conn_handle, &conn_params);
- break;
- }
-
- case BLE_GAP_EVT_DISCONNECTED:
- device->conn_handle = BLE_CONN_HANDLE_INVALID;
- break;
-
- case BLE_GAP_EVT_ADV_REPORT:
- on_adv_report(&ble_evt->evt.gap_evt.params.adv_report, device);
- break;
-
- case BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP:
- on_primary_srv_discovery_rsp(&ble_evt->evt.gattc_evt.params.prim_srvc_disc_rsp, device);
- break;
-
- case BLE_GATTC_EVT_CHAR_DISC_RSP:
- on_char_discovery_rsp(&ble_evt->evt.gattc_evt.params.char_disc_rsp, device);
- break;
-
- case BLE_GATTS_EVT_SYS_ATTR_MISSING:
- sd_ble_gatts_sys_attr_set(ble_evt->evt.gatts_evt.conn_handle, NULL, 0, 0);
- break;
-
-#if (BLE_API_VERSION == 4)
- case BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST:
- sd_ble_gatts_exchange_mtu_reply(device->conn_handle, BLE_GATT_ATT_MTU_DEFAULT);
- break;
-#endif
-
- case BLE_GAP_EVT_SEC_PARAMS_REQUEST:
- sd_ble_gap_sec_params_reply(device->conn_handle, BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP, NULL, NULL);
- break;
-
- case BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST:
- {
- ble_gap_evt_conn_param_update_request_t *request = &ble_evt->evt.gap_evt.params.conn_param_update_request;
- sd_ble_gap_conn_param_update(device->conn_handle, &request->conn_params);
- break;
- }
- }
-}
-
-void common_hal_bleio_device_add_service(bleio_device_obj_t *device, bleio_service_obj_t *service) {
- ble_uuid_t uuid;
- bleio_uuid_convert_to_nrf_ble_uuid(service->uuid, &uuid);
-
- uint8_t service_type = BLE_GATTS_SRVC_TYPE_PRIMARY;
- if (service->is_secondary) {
- service_type = BLE_GATTS_SRVC_TYPE_SECONDARY;
- }
-
- common_hal_bleio_adapter_set_enabled(true);
-
- const uint32_t err_code = sd_ble_gatts_service_add(service_type, &uuid, &service->handle);
- if (err_code != NRF_SUCCESS) {
- mp_raise_OSError_msg(translate("Failed to add service"));
- }
-
- const mp_obj_list_t *char_list = MP_OBJ_TO_PTR(service->char_list);
- for (size_t i = 0; i < char_list->len; ++i) {
- bleio_characteristic_obj_t *characteristic = char_list->items[i];
- common_hal_bleio_service_add_characteristic(service, characteristic);
- }
-}
-
-void common_hal_bleio_device_start_advertising(bleio_device_obj_t *device, bool connectable, mp_buffer_info_t *raw_data) {
- if (connectable) {
- ble_drv_add_event_handler(on_ble_evt, device);
- }
-
- const uint32_t err_code = set_advertisement_data(device, connectable, raw_data);
- if (err_code != NRF_SUCCESS) {
- mp_raise_OSError_msg(translate("Failed to start advertising"));
- }
-}
-
-void common_hal_bleio_device_stop_advertising(bleio_device_obj_t *device) {
- uint32_t err_code;
-
-#if (BLUETOOTH_SD == 140)
- if (m_adv_handle == BLE_GAP_ADV_SET_HANDLE_NOT_SET)
- return;
-
- err_code = sd_ble_gap_adv_stop(m_adv_handle);
-#else
- err_code = sd_ble_gap_adv_stop();
-#endif
-
- if ((err_code != NRF_SUCCESS) && (err_code != NRF_ERROR_INVALID_STATE)) {
- mp_raise_OSError_msg(translate("Failed to stop advertising"));
- }
-}
-
-void common_hal_bleio_device_connect(bleio_device_obj_t *device) {
- ble_drv_add_event_handler(on_ble_evt, device);
-
- ble_gap_scan_params_t scan_params = {
- .interval = MSEC_TO_UNITS(100, UNIT_0_625_MS),
- .window = MSEC_TO_UNITS(100, UNIT_0_625_MS),
-#if (BLUETOOTH_SD == 140)
- .scan_phys = BLE_GAP_PHY_1MBPS,
-#endif
- };
-
- common_hal_bleio_adapter_set_enabled(true);
-
- uint32_t err_code;
-#if (BLUETOOTH_SD == 140)
- err_code = sd_ble_gap_scan_start(&scan_params, &m_scan_buffer);
-#else
- err_code = sd_ble_gap_scan_start(&scan_params);
-#endif
-
- if (err_code != NRF_SUCCESS) {
- mp_raise_OSError_msg(translate("Failed to start scanning"));
- }
-
- while (device->conn_handle == BLE_CONN_HANDLE_INVALID) {
-#ifdef MICROPY_VM_HOOK_LOOP
- MICROPY_VM_HOOK_LOOP
-#endif
- }
-
- // TODO: read name
-
- if (m_discovery_mutex == NULL) {
- m_discovery_mutex = m_new_ll(nrf_mutex_t, 1);
-
- err_code = sd_mutex_new(m_discovery_mutex);
- if (err_code != NRF_SUCCESS) {
- mp_raise_OSError_msg(translate("Failed to create mutex"));
- }
- }
-
- // find services
- bool found_service = discover_services(device, BLE_GATT_HANDLE_START);
- while (found_service) {
- const mp_obj_list_t *service_list = MP_OBJ_TO_PTR(device->service_list);
- const bleio_service_obj_t *service = service_list->items[service_list->len - 1];
-
- found_service = discover_services(device, service->end_handle + 1);
- }
-
- // find characteristics in each service
- const mp_obj_list_t *service_list = MP_OBJ_TO_PTR(device->service_list);
- for (size_t i = 0; i < service_list->len; ++i) {
- bleio_service_obj_t *service = service_list->items[i];
-
- bool found_char = discover_characteristics(device, service, service->start_handle);
- while (found_char) {
- const mp_obj_list_t *char_list = MP_OBJ_TO_PTR(service->char_list);
- const bleio_characteristic_obj_t *characteristic = char_list->items[char_list->len - 1];
-
- const uint16_t next_handle = characteristic->handle + 1;
- if (next_handle >= service->end_handle) {
- break;
- }
-
- found_char = discover_characteristics(device, service, next_handle);
- }
- }
-}
-
-void common_hal_bleio_device_disconnect(bleio_device_obj_t *device) {
- sd_ble_gap_disconnect(device->conn_handle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
-}
diff --git a/ports/nrf/common-hal/bleio/Peripheral.c b/ports/nrf/common-hal/bleio/Peripheral.c
index 0a5a8069d..608bd1342 100644
--- a/ports/nrf/common-hal/bleio/Peripheral.c
+++ b/ports/nrf/common-hal/bleio/Peripheral.c
@@ -3,8 +3,8 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2018 Artur Pacholec
* Copyright (c) 2018 Dan Halbert for Adafruit Industries
+ * Copyright (c) 2018 Artur Pacholec
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -32,6 +32,8 @@
#include "ble_drv.h"
#include "ble_hci.h"
#include "nrf_soc.h"
+#include "py/gc.h"
+#include "py/objlist.h"
#include "py/objstr.h"
#include "py/runtime.h"
#include "shared-bindings/bleio/Adapter.h"
@@ -39,6 +41,7 @@
#include "shared-bindings/bleio/Peripheral.h"
#include "shared-bindings/bleio/Service.h"
#include "shared-bindings/bleio/UUID.h"
+#include "common-hal/bleio/Service.h"
#define BLE_MIN_CONN_INTERVAL MSEC_TO_UNITS(15, UNIT_0_625_MS)
#define BLE_MAX_CONN_INTERVAL MSEC_TO_UNITS(300, UNIT_0_625_MS)
@@ -49,261 +52,96 @@
#define BLE_ADV_AD_TYPE_FIELD_SIZE 1
#define BLE_AD_TYPE_FLAGS_DATA_SIZE 1
-static uint8_t m_adv_handle = BLE_GAP_ADV_SET_HANDLE_NOT_SET;
-
-STATIC void check_data_fit(size_t pos, size_t data_len) {
- if (pos + data_len >= BLE_GAP_ADV_SET_DATA_SIZE_MAX) {
+STATIC void check_data_fit(size_t data_len) {
+ if (data_len > BLE_GAP_ADV_SET_DATA_SIZE_MAX) {
mp_raise_ValueError(translate("Data too large for advertisement packet"));
}
}
-STATIC uint32_t add_services_to_advertisement(bleio_peripheral_obj_t *self, size_t* adv_data_pos_p, size_t uuid_len) {
- uint32_t uuids_total_size = 0;
- const mp_obj_list_t *service_list = MP_OBJ_TO_PTR(self->service_list);
- uint32_t err_code = NRF_SUCCESS;
-
- check_data_fit(*adv_data_pos_p, 1 + 1);
-
- // Remember where length byte is; fill in later when we know the size.
- const size_t length_pos = *adv_data_pos_p;
- (*adv_data_pos_p)++;
-
- self->adv_data[(*adv_data_pos_p)++] = (uuid_len == 16)
- ? BLE_GAP_AD_TYPE_16BIT_SERVICE_UUID_COMPLETE
- : BLE_GAP_AD_TYPE_128BIT_SERVICE_UUID_COMPLETE;
-
- for (size_t i = 0; i < service_list->len; ++i) {
- const bleio_service_obj_t *service = MP_OBJ_TO_PTR(service_list->items[i]);
- uint8_t encoded_size = 0;
-
- // Skip services of the wrong length and secondary services.
- if (common_hal_bleio_uuid_get_size(service->uuid) != uuid_len || service->is_secondary) {
- continue;
- }
-
- ble_uuid_t uuid;
- bleio_uuid_convert_to_nrf_ble_uuid(service->uuid, &uuid);
-
- err_code = sd_ble_uuid_encode(&uuid, &encoded_size, &(self->adv_data[*adv_data_pos_p]));
- if (err_code != NRF_SUCCESS) {
- return err_code;
- }
-
- check_data_fit(*adv_data_pos_p, encoded_size);
- uuids_total_size += encoded_size;
- (*adv_data_pos_p) += encoded_size;
- }
-
- self->adv_data[length_pos] = 1 + uuids_total_size; // 1 for the field type.
- return err_code;
-}
-
-
-
-// if raw_data is a zero-length buffer, generate an advertising packet that advertises the
-// services passed in when this Peripheral was created.
-// If raw_data contains some bytes, use those bytes as the advertising packet.
-// TODO: Generate the advertising packet in Python, not here.
-STATIC uint32_t set_advertisement_data(bleio_peripheral_obj_t *self, bool connectable, mp_buffer_info_t *raw_data) {
- common_hal_bleio_adapter_set_enabled(true);
-
- size_t adv_data_pos = 0;
- uint32_t err_code;
-
- GET_STR_DATA_LEN(self->name, name_data, name_len);
- if (name_len > 0) {
- ble_gap_conn_sec_mode_t sec_mode;
- BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode);
-
- // We'll add the name after everything else, shortening it if necessary.
- err_code = sd_ble_gap_device_name_set(&sec_mode, name_data, name_len);
- if (err_code != NRF_SUCCESS) {
- return err_code;
- }
- }
-
- if (raw_data->len != 0) {
- // User-supplied advertising packet.
- check_data_fit(adv_data_pos, raw_data->len);
- memcpy(&(self->adv_data[adv_data_pos]), raw_data->buf, raw_data->len);
- adv_data_pos += raw_data->len;
- } else {
- // Build up advertising packet.
- check_data_fit(adv_data_pos, 1 + 1 + 1);
- self->adv_data[adv_data_pos++] = 2;
- self->adv_data[adv_data_pos++] = BLE_GAP_AD_TYPE_FLAGS;
- self->adv_data[adv_data_pos++] = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;
-
- // The 16-bit ids and 128-bit ids are grouped together by length, so find it whether we have
- // 16 and/or 128-bit service UUIDs.
-
- const mp_obj_list_t *service_list = MP_OBJ_TO_PTR(self->service_list);
- if (service_list->len > 0) {
- bool has_128bit_services = false;
- bool has_16bit_services = false;
-
- for (size_t i = 0; i < service_list->len; ++i) {
- const bleio_service_obj_t *service = MP_OBJ_TO_PTR(service_list->items[i]);
-
- if (service->is_secondary) {
- continue;
- }
-
- switch (common_hal_bleio_uuid_get_size(service->uuid)) {
- case 16:
- has_16bit_services = true;
- break;
- case 128:
- has_128bit_services = true;
- break;
- }
- }
-
- // Add 16-bit service UUID's in a group, then 128-bit service UUID's.
-
- if (has_16bit_services) {
- err_code = add_services_to_advertisement(self, &adv_data_pos, 16);
- if (err_code != NRF_SUCCESS) {
- return err_code;
- }
- }
-
- if (has_128bit_services) {
- err_code = add_services_to_advertisement(self, &adv_data_pos, 128);
- if (err_code != NRF_SUCCESS) {
- return err_code;
- }
- }
- }
-
- // Always include TX power.
- check_data_fit(adv_data_pos, 1 + 1 + 1);
- self->adv_data[adv_data_pos++] = 1 + 1;
- self->adv_data[adv_data_pos++] = BLE_GAP_AD_TYPE_TX_POWER_LEVEL;
- self->adv_data[adv_data_pos++] = 0; // TODO - allow power level to be set later.
-
- // We need room for at least a one-character name.
- check_data_fit(adv_data_pos, 1 + 1 + 1);
-
- // How big a name can we fit?
- size_t bytes_left = BLE_GAP_ADV_SET_DATA_SIZE_MAX - adv_data_pos - 1 - 1;
- size_t partial_name_len = MIN(bytes_left, name_len);
- self->adv_data[adv_data_pos++] = 1 + partial_name_len;
- self->adv_data[adv_data_pos++] = (partial_name_len == name_len)
- ? BLE_GAP_AD_TYPE_COMPLETE_LOCAL_NAME
- : BLE_GAP_AD_TYPE_SHORT_LOCAL_NAME;
- memcpy(&(self->adv_data[adv_data_pos]), name_data, partial_name_len);
- adv_data_pos += partial_name_len;
- } // end of advertising packet construction
-
- static ble_gap_adv_params_t m_adv_params = {
- .interval = MSEC_TO_UNITS(1000, UNIT_0_625_MS),
- .properties.type = BLE_GAP_ADV_TYPE_CONNECTABLE_SCANNABLE_UNDIRECTED,
- .duration = BLE_GAP_ADV_TIMEOUT_GENERAL_UNLIMITED,
- .filter_policy = BLE_GAP_ADV_FP_ANY,
- .primary_phy = BLE_GAP_PHY_1MBPS,
- };
-
- if (!connectable) {
- m_adv_params.properties.type = BLE_GAP_ADV_TYPE_NONCONNECTABLE_NONSCANNABLE_UNDIRECTED;
- }
-
- common_hal_bleio_peripheral_stop_advertising(self);
-
- const ble_gap_adv_data_t ble_gap_adv_data = {
- .adv_data.p_data = self->adv_data,
- .adv_data.len = adv_data_pos,
- };
-
- err_code = sd_ble_gap_adv_set_configure(&m_adv_handle, &ble_gap_adv_data, &m_adv_params);
- if (err_code != NRF_SUCCESS) {
- return err_code;
- }
-
- err_code = sd_ble_gap_adv_start(m_adv_handle, BLE_CONN_CFG_TAG_CUSTOM);
-
- return err_code;
-}
-
STATIC void peripheral_on_ble_evt(ble_evt_t *ble_evt, void *self_in) {
bleio_peripheral_obj_t *self = (bleio_peripheral_obj_t*)self_in;
switch (ble_evt->header.evt_id) {
- case BLE_GAP_EVT_CONNECTED: {
- // Central has connected.
- ble_gap_conn_params_t conn_params;
- self->conn_handle = ble_evt->evt.gap_evt.conn_handle;
- sd_ble_gap_ppcp_get(&conn_params);
- sd_ble_gap_conn_param_update(ble_evt->evt.gap_evt.conn_handle, &conn_params);
- break;
- }
+ case BLE_GAP_EVT_CONNECTED: {
+ // Central has connected.
+ ble_gap_conn_params_t conn_params;
+ self->conn_handle = ble_evt->evt.gap_evt.conn_handle;
+ sd_ble_gap_ppcp_get(&conn_params);
+ sd_ble_gap_conn_param_update(ble_evt->evt.gap_evt.conn_handle, &conn_params);
+ break;
+ }
- case BLE_GAP_EVT_DISCONNECTED:
- // Central has disconnected.
- self->conn_handle = BLE_CONN_HANDLE_INVALID;
- break;
-
- case BLE_GAP_EVT_PHY_UPDATE_REQUEST: {
- ble_gap_phys_t const phys = {
- .rx_phys = BLE_GAP_PHY_AUTO,
- .tx_phys = BLE_GAP_PHY_AUTO,
- };
- sd_ble_gap_phy_update(ble_evt->evt.gap_evt.conn_handle, &phys);
- break;
- }
+ case BLE_GAP_EVT_DISCONNECTED:
+ // Central has disconnected.
+ self->conn_handle = BLE_CONN_HANDLE_INVALID;
+ break;
+
+ case BLE_GAP_EVT_PHY_UPDATE_REQUEST: {
+ ble_gap_phys_t const phys = {
+ .rx_phys = BLE_GAP_PHY_AUTO,
+ .tx_phys = BLE_GAP_PHY_AUTO,
+ };
+ sd_ble_gap_phy_update(ble_evt->evt.gap_evt.conn_handle, &phys);
+ break;
+ }
- case BLE_GAP_EVT_ADV_SET_TERMINATED:
- // Someday may handle timeouts or limit reached.
- break;
+ case BLE_GAP_EVT_ADV_SET_TERMINATED:
+ // Someday may handle timeouts or limit reached.
+ break;
- case BLE_GAP_EVT_SEC_PARAMS_REQUEST:
- sd_ble_gap_sec_params_reply(self->conn_handle, BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP, NULL, NULL);
- break;
+ case BLE_GAP_EVT_SEC_PARAMS_REQUEST:
+ sd_ble_gap_sec_params_reply(self->conn_handle, BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP, NULL, NULL);
+ break;
- case BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST: {
- ble_gap_evt_conn_param_update_request_t *request = &ble_evt->evt.gap_evt.params.conn_param_update_request;
- sd_ble_gap_conn_param_update(self->conn_handle, &request->conn_params);
- break;
- }
+ case BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST: {
+ ble_gap_evt_conn_param_update_request_t *request =
+ &ble_evt->evt.gap_evt.params.conn_param_update_request;
+ sd_ble_gap_conn_param_update(self->conn_handle, &request->conn_params);
+ break;
+ }
- case BLE_GAP_EVT_DATA_LENGTH_UPDATE_REQUEST:
- sd_ble_gap_data_length_update(self->conn_handle, NULL, NULL);
- break;
+ case BLE_GAP_EVT_DATA_LENGTH_UPDATE_REQUEST:
+ sd_ble_gap_data_length_update(self->conn_handle, NULL, NULL);
+ break;
- case BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST: {
- sd_ble_gatts_exchange_mtu_reply(self->conn_handle, BLE_GATT_ATT_MTU_DEFAULT);
- break;
- }
+ case BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST: {
+ sd_ble_gatts_exchange_mtu_reply(self->conn_handle, BLE_GATT_ATT_MTU_DEFAULT);
+ break;
+ }
- case BLE_GATTS_EVT_SYS_ATTR_MISSING:
- sd_ble_gatts_sys_attr_set(self->conn_handle, NULL, 0, 0);
- break;
+ case BLE_GATTS_EVT_SYS_ATTR_MISSING:
+ sd_ble_gatts_sys_attr_set(self->conn_handle, NULL, 0, 0);
+ break;
- default:
- // For debugging.
- // mp_printf(&mp_plat_print, "Unhandled peripheral event: 0x%04x\n", ble_evt->header.evt_id);
- break;
+ default:
+ // For debugging.
+ // mp_printf(&mp_plat_print, "Unhandled peripheral event: 0x%04x\n", ble_evt->header.evt_id);
+ break;
}
}
+void common_hal_bleio_peripheral_construct(bleio_peripheral_obj_t *self, mp_obj_list_t *service_list, mp_obj_t name) {
+ common_hal_bleio_adapter_set_enabled(true);
-void common_hal_bleio_peripheral_construct(bleio_peripheral_obj_t *self) {
- common_hal_bleio_adapter_set_enabled(true); // TODO -- Do this somewhere else maybe bleio __init__
+ self->service_list = service_list;
+ self->name = name;
self->gatt_role = GATT_ROLE_SERVER;
self->conn_handle = BLE_CONN_HANDLE_INVALID;
+ self->adv_handle = BLE_GAP_ADV_SET_HANDLE_NOT_SET;
// Add all the services.
- mp_obj_list_t *service_list = MP_OBJ_TO_PTR(self->service_list);
for (size_t service_idx = 0; service_idx < service_list->len; ++service_idx) {
bleio_service_obj_t *service = MP_OBJ_TO_PTR(service_list->items[service_idx]);
+ service->device = MP_OBJ_FROM_PTR(self);
+
ble_uuid_t uuid;
bleio_uuid_convert_to_nrf_ble_uuid(service->uuid, &uuid);
uint8_t service_type = BLE_GATTS_SRVC_TYPE_PRIMARY;
- if (service->is_secondary) {
+ if (common_hal_bleio_service_get_is_secondary(service)) {
service_type = BLE_GATTS_SRVC_TYPE_SECONDARY;
}
@@ -318,29 +156,94 @@ void common_hal_bleio_peripheral_construct(bleio_peripheral_obj_t *self) {
}
+mp_obj_list_t *common_hal_bleio_peripheral_get_service_list(bleio_peripheral_obj_t *self) {
+ return self->service_list;
+}
+
bool common_hal_bleio_peripheral_get_connected(bleio_peripheral_obj_t *self) {
return self->conn_handle != BLE_CONN_HANDLE_INVALID;
}
-void common_hal_bleio_peripheral_start_advertising(bleio_peripheral_obj_t *self, bool connectable, mp_buffer_info_t *raw_data) {
+mp_obj_t common_hal_bleio_peripheral_get_name(bleio_peripheral_obj_t *self) {
+ return self->name;
+}
+
+void common_hal_bleio_peripheral_start_advertising(bleio_peripheral_obj_t *self, bool connectable, mp_float_t interval, mp_buffer_info_t *advertising_data_bufinfo, mp_buffer_info_t *scan_response_data_bufinfo) {
+
+ // interval value has already been validated.
+
if (connectable) {
ble_drv_add_event_handler(peripheral_on_ble_evt, self);
}
- const uint32_t err_code = set_advertisement_data(self, connectable, raw_data);
+ common_hal_bleio_adapter_set_enabled(true);
+
+ uint32_t err_code;
+
+ GET_STR_DATA_LEN(self->name, name_data, name_len);
+ if (name_len > 0) {
+ ble_gap_conn_sec_mode_t sec_mode;
+ BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode);
+
+ err_code = sd_ble_gap_device_name_set(&sec_mode, name_data, name_len);
+ if (err_code != NRF_SUCCESS) {
+ mp_raise_OSError_msg_varg(translate("Failed to set device name, err 0x%04x"), err_code);
+
+ }
+ }
+
+ check_data_fit(advertising_data_bufinfo->len);
+ // The advertising data buffers must not move, because the SoftDevice depends on them.
+ // So make them long-lived.
+ self->advertising_data = (uint8_t *) gc_alloc(BLE_GAP_ADV_SET_DATA_SIZE_MAX * sizeof(uint8_t), false, true);
+ memcpy(self->advertising_data, advertising_data_bufinfo->buf, advertising_data_bufinfo->len);
+
+ check_data_fit(scan_response_data_bufinfo->len);
+ self->scan_response_data = (uint8_t *) gc_alloc(BLE_GAP_ADV_SET_DATA_SIZE_MAX * sizeof(uint8_t), false, true);
+ memcpy(self->scan_response_data, scan_response_data_bufinfo->buf, scan_response_data_bufinfo->len);
+
+
+ ble_gap_adv_params_t adv_params = {
+ .interval = SEC_TO_UNITS(interval, UNIT_0_625_MS),
+ .properties.type = connectable ? BLE_GAP_ADV_TYPE_CONNECTABLE_SCANNABLE_UNDIRECTED
+ : BLE_GAP_ADV_TYPE_NONCONNECTABLE_NONSCANNABLE_UNDIRECTED,
+ .duration = BLE_GAP_ADV_TIMEOUT_GENERAL_UNLIMITED,
+ .filter_policy = BLE_GAP_ADV_FP_ANY,
+ .primary_phy = BLE_GAP_PHY_1MBPS,
+ };
+
+ common_hal_bleio_peripheral_stop_advertising(self);
+
+ const ble_gap_adv_data_t ble_gap_adv_data = {
+ .adv_data.p_data = self->advertising_data,
+ .adv_data.len = advertising_data_bufinfo->len,
+ .scan_rsp_data.p_data = scan_response_data_bufinfo-> len > 0 ? self->scan_response_data : NULL,
+ .scan_rsp_data.len = scan_response_data_bufinfo->len,
+ };
+
+ err_code = sd_ble_gap_adv_set_configure(&self->adv_handle, &ble_gap_adv_data, &adv_params);
+ if (err_code != NRF_SUCCESS) {
+ mp_raise_OSError_msg_varg(translate("Failed to configure advertising, err 0x%04x"), err_code);
+ }
+
+ err_code = sd_ble_gap_adv_start(self->adv_handle, BLE_CONN_CFG_TAG_CUSTOM);
+
if (err_code != NRF_SUCCESS) {
mp_raise_OSError_msg_varg(translate("Failed to start advertising, err 0x%04x"), err_code);
}
}
void common_hal_bleio_peripheral_stop_advertising(bleio_peripheral_obj_t *self) {
-
- if (m_adv_handle == BLE_GAP_ADV_SET_HANDLE_NOT_SET)
+ if (self->adv_handle == BLE_GAP_ADV_SET_HANDLE_NOT_SET)
return;
- const uint32_t err_code = sd_ble_gap_adv_stop(m_adv_handle);
+ const uint32_t err_code = sd_ble_gap_adv_stop(self->adv_handle);
if ((err_code != NRF_SUCCESS) && (err_code != NRF_ERROR_INVALID_STATE)) {
mp_raise_OSError_msg_varg(translate("Failed to stop advertising, err 0x%04x"), err_code);
}
}
+
+void common_hal_bleio_peripheral_disconnect(bleio_peripheral_obj_t *self) {
+ sd_ble_gap_disconnect(self->conn_handle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
+}
diff --git a/ports/nrf/common-hal/bleio/Peripheral.h b/ports/nrf/common-hal/bleio/Peripheral.h
index b255fe9f4..2a1251715 100644
--- a/ports/nrf/common-hal/bleio/Peripheral.h
+++ b/ports/nrf/common-hal/bleio/Peripheral.h
@@ -3,8 +3,8 @@
*
* The MIT License (MIT)
*
+ * Copyright (c) 2019 Dan Halbert for Adafruit Industries
* Copyright (c) 2018 Artur Pacholec
- * 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
@@ -25,13 +25,16 @@
* THE SOFTWARE.
*/
-#ifndef MICROPY_INCLUDED_COMMON_HAL_BLEIO_PERIPHERAL_H
-#define MICROPY_INCLUDED_COMMON_HAL_BLEIO_PERIPHERAL_H
+#ifndef MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_PERIPHERAL_H
+#define MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_PERIPHERAL_H
#include <stdbool.h>
#include "ble.h"
+#include "py/obj.h"
+#include "py/objlist.h"
+
#include "shared-module/bleio/__init__.h"
#include "shared-module/bleio/Address.h"
@@ -40,14 +43,14 @@ typedef struct {
mp_obj_t name;
gatt_role_t gatt_role;
volatile uint16_t conn_handle;
- mp_obj_t service_list;
- mp_obj_t notif_handler;
- mp_obj_t conn_handler;
- // The advertising data buffer is held by us, not by the SD, so we must
- // maintain it and not change it. If we need to change its contents during advertising,
+ mp_obj_list_t *service_list;
+ // The advertising data and scan response buffers are held by us, not by the SD, so we must
+ // maintain them and not change it. If we need to change the contents during advertising,
// there are tricks to get the SD to notice (see DevZone - TBS).
- uint8_t adv_data[BLE_GAP_ADV_SET_DATA_SIZE_MAX];
+ uint8_t* advertising_data;
+ uint8_t* scan_response_data;
+ uint8_t adv_handle;
} bleio_peripheral_obj_t;
-#endif // MICROPY_INCLUDED_COMMON_HAL_BLEIO_PERIPHERAL_H
+#endif // MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_PERIPHERAL_H
diff --git a/ports/nrf/common-hal/bleio/Scanner.c b/ports/nrf/common-hal/bleio/Scanner.c
index d2e19b5f9..57ce940ab 100644
--- a/ports/nrf/common-hal/bleio/Scanner.c
+++ b/ports/nrf/common-hal/bleio/Scanner.c
@@ -3,8 +3,9 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2016 Glenn Ruben Bakke
+ * Copyright (c) 2019 Dan Halbert for Adafruit Industries
* Copyright (c) 2018 Artur Pacholec
+ * Copyright (c) 2016 Glenn Ruben Bakke
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -30,22 +31,21 @@
#include "ble_drv.h"
#include "ble_gap.h"
#include "py/mphal.h"
+#include "py/objlist.h"
#include "py/runtime.h"
#include "shared-bindings/bleio/Adapter.h"
#include "shared-bindings/bleio/ScanEntry.h"
#include "shared-bindings/bleio/Scanner.h"
#include "shared-module/bleio/ScanEntry.h"
-#if (BLUETOOTH_SD == 140)
static uint8_t m_scan_buffer_data[BLE_GAP_SCAN_BUFFER_MIN];
static ble_data_t m_scan_buffer = {
m_scan_buffer_data,
BLE_GAP_SCAN_BUFFER_MIN
};
-#endif
-STATIC void on_ble_evt(ble_evt_t *ble_evt, void *scanner_in) {
+STATIC void scanner_on_ble_evt(ble_evt_t *ble_evt, void *scanner_in) {
bleio_scanner_obj_t *scanner = (bleio_scanner_obj_t*)scanner_in;
ble_gap_evt_adv_report_t *report = &ble_evt->evt.gap_evt.params.adv_report;
@@ -53,56 +53,53 @@ STATIC void on_ble_evt(ble_evt_t *ble_evt, void *scanner_in) {
return;
}
- // TODO: Don't add new entry for each item, group by address and update
bleio_scanentry_obj_t *entry = m_new_obj(bleio_scanentry_obj_t);
entry->base.type = &bleio_scanentry_type;
entry->rssi = report->rssi;
- entry->address.type = report->peer_addr.addr_type;
- memcpy(entry->address.value, report->peer_addr.addr, BLEIO_ADDRESS_BYTES);
+ bleio_address_obj_t *address = m_new_obj(bleio_address_obj_t);
+ address->base.type = &bleio_address_type;
+ common_hal_bleio_address_construct(MP_OBJ_TO_PTR(address),
+ report->peer_addr.addr, report->peer_addr.addr_type);
+ entry->address = address;
-#if (BLUETOOTH_SD == 140)
- entry->data = mp_obj_new_bytearray(report->data.len, report->data.p_data);
-#else
- entry->data = mp_obj_new_bytearray(report->dlen, report->data);
-#endif
+ entry->data = mp_obj_new_bytes(report->data.p_data, report->data.len);
- mp_obj_list_append(scanner->adv_reports, entry);
+ mp_obj_list_append(scanner->scan_entries, MP_OBJ_FROM_PTR(entry));
-#if (BLUETOOTH_SD == 140)
const uint32_t err_code = sd_ble_gap_scan_start(NULL, &m_scan_buffer);
if (err_code != NRF_SUCCESS) {
mp_raise_OSError_msg_varg(translate("Failed to continue scanning, err 0x%04x"), err_code);
}
-#endif
}
-void common_hal_bleio_scanner_scan(bleio_scanner_obj_t *self, mp_int_t timeout) {
- ble_drv_add_event_handler(on_ble_evt, self);
+void common_hal_bleio_scanner_construct(bleio_scanner_obj_t *self) {
+}
+
+mp_obj_t common_hal_bleio_scanner_scan(bleio_scanner_obj_t *self, mp_float_t timeout, mp_float_t interval, mp_float_t window) {
+ common_hal_bleio_adapter_set_enabled(true);
+ ble_drv_add_event_handler(scanner_on_ble_evt, self);
ble_gap_scan_params_t scan_params = {
- .interval = MSEC_TO_UNITS(self->interval, UNIT_0_625_MS),
- .window = MSEC_TO_UNITS(self->window, UNIT_0_625_MS),
-#if (BLUETOOTH_SD == 140)
+ .interval = SEC_TO_UNITS(interval, UNIT_0_625_MS),
+ .window = SEC_TO_UNITS(window, UNIT_0_625_MS),
.scan_phys = BLE_GAP_PHY_1MBPS,
-#endif
};
- common_hal_bleio_adapter_set_enabled(true);
+ self->scan_entries = mp_obj_new_list(0, NULL);
uint32_t err_code;
-#if (BLUETOOTH_SD == 140)
err_code = sd_ble_gap_scan_start(&scan_params, &m_scan_buffer);
-#else
- err_code = sd_ble_gap_scan_start(&scan_params);
-#endif
if (err_code != NRF_SUCCESS) {
mp_raise_OSError_msg_varg(translate("Failed to start scanning, err 0x%04x"), err_code);
}
- if (timeout > 0) {
- mp_hal_delay_ms(timeout);
- sd_ble_gap_scan_stop();
- }
+ mp_hal_delay_ms(timeout * 1000);
+ sd_ble_gap_scan_stop();
+
+ // Return list, and don't hang on to it, so it can be GC'd.
+ mp_obj_t entries = self->scan_entries;
+ self->scan_entries = MP_OBJ_NULL;
+ return entries;
}
diff --git a/shared-module/bleio/Scanner.h b/ports/nrf/common-hal/bleio/Scanner.h
index 76f5e5866..3768a52cb 100644
--- a/shared-module/bleio/Scanner.h
+++ b/ports/nrf/common-hal/bleio/Scanner.h
@@ -3,6 +3,7 @@
*
* The MIT License (MIT)
*
+ * Copyright (c) 2019 Dan Halbert for Adafruit Industries
* Copyright (c) 2018 Artur Pacholec
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -24,16 +25,16 @@
* THE SOFTWARE.
*/
-#ifndef MICROPY_INCLUDED_SHARED_MODULE_BLEIO_SCANNER_H
-#define MICROPY_INCLUDED_SHARED_MODULE_BLEIO_SCANNER_H
+#ifndef MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_SCANNER_H
+#define MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_SCANNER_H
#include "py/obj.h"
typedef struct {
mp_obj_base_t base;
- mp_obj_t adv_reports;
+ mp_obj_t scan_entries;
uint16_t interval;
uint16_t window;
} bleio_scanner_obj_t;
-#endif // MICROPY_INCLUDED_SHARED_MODULE_BLEIO_SCANNER_H
+#endif // MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_SCANNER_H
diff --git a/ports/nrf/common-hal/bleio/Service.c b/ports/nrf/common-hal/bleio/Service.c
index 26a1f1cff..b6fcde827 100644
--- a/ports/nrf/common-hal/bleio/Service.c
+++ b/ports/nrf/common-hal/bleio/Service.c
@@ -3,6 +3,7 @@
*
* The MIT License (MIT)
*
+ * Copyright (c) 2019 Dan Halbert for Adafruit Industries
* Copyright (c) 2018 Artur Pacholec
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -29,18 +30,43 @@
#include "py/runtime.h"
#include "common-hal/bleio/__init__.h"
#include "common-hal/bleio/Characteristic.h"
+#include "shared-bindings/bleio/Characteristic.h"
#include "shared-bindings/bleio/Service.h"
#include "shared-bindings/bleio/Adapter.h"
-void common_hal_bleio_service_construct(bleio_service_obj_t *self) {
+void common_hal_bleio_service_construct(bleio_service_obj_t *self, bleio_uuid_obj_t *uuid, mp_obj_list_t *characteristic_list, bool is_secondary) {
+ self->device = mp_const_none;
+ self->handle = 0xFFFF;
+ self->uuid = uuid;
+ self->characteristic_list = characteristic_list;
+ self->is_secondary = is_secondary;
+
+ for (size_t characteristic_idx = 0; characteristic_idx < characteristic_list->len; ++characteristic_idx) {
+ bleio_characteristic_obj_t *characteristic =
+ MP_OBJ_TO_PTR(characteristic_list->items[characteristic_idx]);
+ characteristic->service = self;
+ }
+
+}
+
+bleio_uuid_obj_t *common_hal_bleio_service_get_uuid(bleio_service_obj_t *self) {
+ return self->uuid;
+}
+
+mp_obj_list_t *common_hal_bleio_service_get_characteristic_list(bleio_service_obj_t *self) {
+ return self->characteristic_list;
+}
+
+bool common_hal_bleio_service_get_is_secondary(bleio_service_obj_t *self) {
+ return self->is_secondary;
}
// Call this after the Service has been added to the Peripheral.
void common_hal_bleio_service_add_all_characteristics(bleio_service_obj_t *self) {
// Add all the characteristics.
- const mp_obj_list_t *char_list = MP_OBJ_TO_PTR(self->char_list);
- for (size_t char_idx = 0; char_idx < char_list->len; ++char_idx) {
- bleio_characteristic_obj_t *characteristic = char_list->items[char_idx];
+ for (size_t characteristic_idx = 0; characteristic_idx < self->characteristic_list->len; ++characteristic_idx) {
+ bleio_characteristic_obj_t *characteristic =
+ MP_OBJ_TO_PTR(self->characteristic_list->items[characteristic_idx]);
ble_gatts_char_md_t char_md = {
.char_props.broadcast = characteristic->props.broadcast,
diff --git a/shared-module/bleio/Service.h b/ports/nrf/common-hal/bleio/Service.h
index 828d4cdc8..583593fb8 100644
--- a/shared-module/bleio/Service.h
+++ b/ports/nrf/common-hal/bleio/Service.h
@@ -3,6 +3,7 @@
*
* The MIT License (MIT)
*
+ * Copyright (c) 2018 Dan Halbert for Adafruit Industries
* Copyright (c) 2018 Artur Pacholec
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -24,21 +25,24 @@
* THE SOFTWARE.
*/
-#ifndef MICROPY_INCLUDED_SHARED_MODULE_BLEIO_SERVICE_H
-#define MICROPY_INCLUDED_SHARED_MODULE_BLEIO_SERVICE_H
+#ifndef MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_SERVICE_H
+#define MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_SERVICE_H
+#include "py/objlist.h"
#include "common-hal/bleio/UUID.h"
typedef struct {
mp_obj_base_t base;
+ // Handle for this service.
uint16_t handle;
bool is_secondary;
bleio_uuid_obj_t *uuid;
// May be a Peripheral, Central, etc.
- mp_obj_t *device;
- mp_obj_t char_list;
+ mp_obj_t device;
+ mp_obj_list_t *characteristic_list;
+ // Range of attribute handles of this service.
uint16_t start_handle;
uint16_t end_handle;
} bleio_service_obj_t;
-#endif // MICROPY_INCLUDED_SHARED_MODULE_BLEIO_SERVICE_H
+#endif // MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_SERVICE_H
diff --git a/ports/nrf/common-hal/bleio/UUID.c b/ports/nrf/common-hal/bleio/UUID.c
index 23e643433..ebd6b6d1f 100644
--- a/ports/nrf/common-hal/bleio/UUID.c
+++ b/ports/nrf/common-hal/bleio/UUID.c
@@ -3,8 +3,9 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2016 Glenn Ruben Bakke
+ * Copyright (c) 2018 Dan Halbert for Adafruit Industries
* Copyright (c) 2018 Artur Pacholec
+ * Copyright (c) 2016 Glenn Ruben Bakke
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/ports/nrf/common-hal/bleio/UUID.h b/ports/nrf/common-hal/bleio/UUID.h
index b464093ea..7d3a6204e 100644
--- a/ports/nrf/common-hal/bleio/UUID.h
+++ b/ports/nrf/common-hal/bleio/UUID.h
@@ -3,8 +3,9 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2016 Glenn Ruben Bakke
+ * Copyright (c) 2019 Dan Halbert for Adafruit Industries
* Copyright (c) 2018 Artur Pacholec
+ * Copyright (c) 2016 Glenn Ruben Bakke
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/ports/nrf/common-hal/bleio/__init__.c b/ports/nrf/common-hal/bleio/__init__.c
index cfb701019..2dba5780c 100644
--- a/ports/nrf/common-hal/bleio/__init__.c
+++ b/ports/nrf/common-hal/bleio/__init__.c
@@ -3,8 +3,9 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2016 Glenn Ruben Bakke
+ * Copyright (c) 2018 Dan Halbert for Adafruit Industries
* Copyright (c) 2018 Artur Pacholec
+ * Copyright (c) 2016 Glenn Ruben Bakke
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -27,6 +28,7 @@
#include "shared-bindings/bleio/__init__.h"
#include "shared-bindings/bleio/Adapter.h"
+#include "shared-bindings/bleio/Central.h"
#include "shared-bindings/bleio/Peripheral.h"
#include "common-hal/bleio/__init__.h"
@@ -48,9 +50,8 @@ const super_adapter_obj_t common_hal_bleio_adapter_obj = {
gatt_role_t common_hal_bleio_device_get_gatt_role(mp_obj_t device) {
if (MP_OBJ_IS_TYPE(device, &bleio_peripheral_type)) {
return ((bleio_peripheral_obj_t*) MP_OBJ_TO_PTR(device))->gatt_role;
-// Does not exist yet.
-// } else if (MP_OBJ_IS_TYPE(device, &bleio_central_type)) {
-// return ((bleio_central_obj_t*) MP_OBJ_TO_PTR(device))->gatt_role;
+ } else if (MP_OBJ_IS_TYPE(device, &bleio_central_type)) {
+ return ((bleio_central_obj_t*) MP_OBJ_TO_PTR(device))->gatt_role;
} else {
return GATT_ROLE_NONE;
}
@@ -59,9 +60,8 @@ gatt_role_t common_hal_bleio_device_get_gatt_role(mp_obj_t device) {
uint16_t common_hal_bleio_device_get_conn_handle(mp_obj_t device) {
if (MP_OBJ_IS_TYPE(device, &bleio_peripheral_type)) {
return ((bleio_peripheral_obj_t*) MP_OBJ_TO_PTR(device))->conn_handle;
-// Does not exist yet.
-// } else if (MP_OBJ_IS_TYPE(device, &bleio_central_type)) {
-// return ((bleio_central_obj_t*) MP_OBJ_TO_PTR(device))->conn_handle;
+ } else if (MP_OBJ_IS_TYPE(device, &bleio_central_type)) {
+ return ((bleio_central_obj_t*) MP_OBJ_TO_PTR(device))->conn_handle;
} else {
return 0;
}
diff --git a/ports/nrf/common-hal/bleio/__init__.h b/ports/nrf/common-hal/bleio/__init__.h
index 9e044f37c..0c46b631f 100644
--- a/ports/nrf/common-hal/bleio/__init__.h
+++ b/ports/nrf/common-hal/bleio/__init__.h
@@ -24,8 +24,8 @@
* THE SOFTWARE.
*/
-#ifndef MICROPY_INCLUDED_COMMON_HAL_BLEIO_INIT_H
-#define MICROPY_INCLUDED_COMMON_HAL_BLEIO_INIT_H
+#ifndef MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_INIT_H
+#define MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_INIT_H
#include "shared-bindings/bleio/__init__.h"
#include "shared-bindings/bleio/Adapter.h"
@@ -39,4 +39,4 @@
gatt_role_t common_hal_bleio_device_get_gatt_role(mp_obj_t device);
uint16_t common_hal_bleio_device_get_conn_handle(mp_obj_t device);
-#endif // MICROPY_INCLUDED_COMMON_HAL_BLEIO_INIT_H
+#endif // MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_INIT_H
diff --git a/ports/nrf/common-hal/busio/I2C.c b/ports/nrf/common-hal/busio/I2C.c
index 05106d490..71835d16a 100644
--- a/ports/nrf/common-hal/busio/I2C.c
+++ b/ports/nrf/common-hal/busio/I2C.c
@@ -3,9 +3,10 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2016 Sandeep Mistry All right reserved.
- * Copyright (c) 2017 hathach
+ * Copyright (c) 2019 Dan Halbert for Adafruit Industries
* Copyright (c) 2018 Artur Pacholec
+ * Copyright (c) 2017 hathach
+ * Copyright (c) 2016 Sandeep Mistry All right reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -56,13 +57,30 @@ STATIC twim_peripheral_t twim_peripherals[] = {
#endif
};
+STATIC bool never_reset[MP_ARRAY_SIZE(twim_peripherals)];
+
void i2c_reset(void) {
for (size_t i = 0 ; i < MP_ARRAY_SIZE(twim_peripherals); i++) {
+ if (never_reset[i]) {
+ continue;
+ }
nrf_twim_disable(twim_peripherals[i].twim.p_twim);
twim_peripherals[i].in_use = false;
}
}
+void common_hal_busio_i2c_never_reset(busio_i2c_obj_t *self) {
+ for (size_t i = 0 ; i < MP_ARRAY_SIZE(twim_peripherals); i++) {
+ if (self->twim_peripheral == &twim_peripherals[i]) {
+ never_reset[i] = true;
+
+ never_reset_pin_number(self->scl_pin_number);
+ never_reset_pin_number(self->sda_pin_number);
+ break;
+ }
+ }
+}
+
static uint8_t twi_error_to_mp(const nrfx_err_t err) {
switch (err) {
case NRFX_ERROR_DRV_TWI_ERR_ANACK:
diff --git a/ports/nrf/common-hal/busio/SPI.c b/ports/nrf/common-hal/busio/SPI.c
index 8881bdc6b..5f1aac193 100644
--- a/ports/nrf/common-hal/busio/SPI.c
+++ b/ports/nrf/common-hal/busio/SPI.c
@@ -1,9 +1,11 @@
/*
* SPI Master library for nRF5x.
- * Copyright (c) 2015 Arduino LLC
- * Copyright (c) 2016 Sandeep Mistry All right reserved.
- * Copyright (c) 2017 hathach
+ *
+ * Copyright (c) 2019 Dan Halbert for Adafruit Industries
* Copyright (c) 2018 Artur Pacholec
+ * Copyright (c) 2017 hathach
+ * Copyright (c) 2016 Sandeep Mistry All right reserved.
+ * Copyright (c) 2015 Arduino LLC
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -59,7 +61,7 @@ STATIC spim_peripheral_t spim_peripherals[] = {
#endif
};
-STATIC bool never_reset[4];
+STATIC bool never_reset[MP_ARRAY_SIZE(spim_peripherals)];
void spi_reset(void) {
for (size_t i = 0 ; i < MP_ARRAY_SIZE(spim_peripherals); i++) {
diff --git a/ports/nrf/common-hal/busio/UART.c b/ports/nrf/common-hal/busio/UART.c
index 593914afc..b9e9e5538 100644
--- a/ports/nrf/common-hal/busio/UART.c
+++ b/ports/nrf/common-hal/busio/UART.c
@@ -131,7 +131,7 @@ void uart_reset(void) {
void common_hal_busio_uart_construct (busio_uart_obj_t *self,
const mcu_pin_obj_t * tx, const mcu_pin_obj_t * rx, uint32_t baudrate,
uint8_t bits, uart_parity_t parity, uint8_t stop, mp_float_t timeout,
- uint8_t receiver_buffer_size) {
+ uint16_t receiver_buffer_size) {
// Find a free UART peripheral.
self->uarte = NULL;
for (size_t i = 0 ; i < MP_ARRAY_SIZE(nrfx_uartes); i++) {
diff --git a/ports/nrf/common-hal/microcontroller/Pin.c b/ports/nrf/common-hal/microcontroller/Pin.c
index b9c0ecaca..3cee784b6 100644
--- a/ports/nrf/common-hal/microcontroller/Pin.c
+++ b/ports/nrf/common-hal/microcontroller/Pin.c
@@ -105,7 +105,7 @@ void reset_pin_number(uint8_t pin_number) {
#ifdef SPEAKER_ENABLE_PIN
if (pin_number == SPEAKER_ENABLE_PIN->number) {
speaker_enable_in_use = false;
- common_hal_digitalio_digitalinout_switch_to_output(
+ common_hal_digitalio_digitalinout_switch_to_output(SPEAKER_ENABLE_PIN, true, DRIVE_MODE_PUSH_PULL);
nrf_gpio_pin_dir_set(pin_number, NRF_GPIO_PIN_DIR_OUTPUT);
nrf_gpio_pin_write(pin_number, false);
}
diff --git a/ports/nrf/common-hal/pulseio/PWMOut.c b/ports/nrf/common-hal/pulseio/PWMOut.c
index 5485a75d0..5233c9adc 100644
--- a/ports/nrf/common-hal/pulseio/PWMOut.c
+++ b/ports/nrf/common-hal/pulseio/PWMOut.c
@@ -77,33 +77,37 @@ void common_hal_pulseio_pwmout_reset_ok(pulseio_pwmout_obj_t *self) {
}
}
+void reset_single_pwmout(uint8_t i) {
+ NRF_PWM_Type* pwm = pwms[i];
+
+ pwm->ENABLE = 0;
+ pwm->MODE = PWM_MODE_UPDOWN_Up;
+ pwm->DECODER = PWM_DECODER_LOAD_Individual;
+ pwm->LOOP = 0;
+ pwm->PRESCALER = PWM_PRESCALER_PRESCALER_DIV_1; // default is 500 hz
+ pwm->COUNTERTOP = (PWM_MAX_FREQ/500); // default is 500 hz
+
+ pwm->SEQ[0].PTR = (uint32_t) pwm_seq[i];
+ pwm->SEQ[0].CNT = CHANNELS_PER_PWM; // default mode is Individual --> count must be 4
+ pwm->SEQ[0].REFRESH = 0;
+ pwm->SEQ[0].ENDDELAY = 0;
+
+ pwm->SEQ[1].PTR = 0;
+ pwm->SEQ[1].CNT = 0;
+ pwm->SEQ[1].REFRESH = 0;
+ pwm->SEQ[1].ENDDELAY = 0;
+
+ for(int ch =0; ch < CHANNELS_PER_PWM; ch++) {
+ pwm_seq[i][ch] = (1 << 15); // polarity = 0
+ }
+}
+
void pwmout_reset(void) {
for(size_t i=0; i < MP_ARRAY_SIZE(pwms); i++) {
if (never_reset_pwm[i] > 0) {
continue;
}
- NRF_PWM_Type* pwm = pwms[i];
-
- pwm->ENABLE = 0;
- pwm->MODE = PWM_MODE_UPDOWN_Up;
- pwm->DECODER = PWM_DECODER_LOAD_Individual;
- pwm->LOOP = 0;
- pwm->PRESCALER = PWM_PRESCALER_PRESCALER_DIV_1; // default is 500 hz
- pwm->COUNTERTOP = (PWM_MAX_FREQ/500); // default is 500 hz
-
- pwm->SEQ[0].PTR = (uint32_t) pwm_seq[i];
- pwm->SEQ[0].CNT = CHANNELS_PER_PWM; // default mode is Individual --> count must be 4
- pwm->SEQ[0].REFRESH = 0;
- pwm->SEQ[0].ENDDELAY = 0;
-
- pwm->SEQ[1].PTR = 0;
- pwm->SEQ[1].CNT = 0;
- pwm->SEQ[1].REFRESH = 0;
- pwm->SEQ[1].ENDDELAY = 0;
-
- for(int ch =0; ch < CHANNELS_PER_PWM; ch++) {
- pwm_seq[i][ch] = (1 << 15); // polarity = 0
- }
+ reset_single_pwmout(i);
}
}
@@ -148,9 +152,9 @@ pwmout_result_t common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self,
self->channel = CHANNELS_PER_PWM; // out-of-range value.
bool pwm_already_in_use;
NRF_PWM_Type* pwm;
-
- for (size_t i = 0 ; i < MP_ARRAY_SIZE(pwms); i++) {
- pwm = pwms[i];
+ size_t pwm_index = 0;
+ for (; pwm_index < MP_ARRAY_SIZE(pwms); pwm_index++) {
+ pwm = pwms[pwm_index];
pwm_already_in_use = pwm->ENABLE & SPIM_ENABLE_ENABLE_Msk;
if (pwm_already_in_use) {
if (variable_frequency) {
@@ -199,6 +203,7 @@ pwmout_result_t common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self,
nrf_pwm_disable(pwm);
if (!pwm_already_in_use) {
+ reset_single_pwmout(pwm_index);
nrf_pwm_configure(pwm, base_clock, NRF_PWM_MODE_UP, countertop);
}
diff --git a/ports/nrf/mphalport.c b/ports/nrf/mphalport.c
index ea864e7ce..7d9463d0b 100644
--- a/ports/nrf/mphalport.c
+++ b/ports/nrf/mphalport.c
@@ -3,8 +3,9 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2015 Glenn Ruben Bakke
+ * Copyright (c) 2019 Dan Halbert for Adafruit Industries
* Copyright (c) 2018 Artur Pacholec
+ * Copyright (c) 2015 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/nrfx_config.h b/ports/nrf/nrfx_config.h
index d51739fac..a2b48065d 100644
--- a/ports/nrf/nrfx_config.h
+++ b/ports/nrf/nrfx_config.h
@@ -81,13 +81,13 @@
#define NRFX_TIMER1_ENABLED 1
#define NRFX_TIMER2_ENABLED 1
-#ifdef NRFX_TIMER3
+#ifdef NRF_TIMER3
#define NRFX_TIMER3_ENABLED 1
#else
#define NRFX_TIMER3_ENABLED 0
#endif
-#ifdef NRFX_TIMER4
+#ifdef NRF_TIMER4
#define NRFX_TIMER4_ENABLED 1
#else
#define NRFX_TIMER4_ENABLED 0
diff --git a/ports/stm32f4/.gitignore b/ports/stm32f4/.gitignore
new file mode 100644
index 000000000..3080ece14
--- /dev/null
+++ b/ports/stm32f4/.gitignore
@@ -0,0 +1,9 @@
+# Build files
+#####################
+build-*/
+
+# Reference files
+#####################
+ref/
+
+.gdb_history \ No newline at end of file
diff --git a/ports/stm32f4/Makefile b/ports/stm32f4/Makefile
new file mode 100755
index 000000000..7f0744443
--- /dev/null
+++ b/ports/stm32f4/Makefile
@@ -0,0 +1,271 @@
+# This file is part of the MicroPython project, http://micropython.org/
+#
+# The MIT License (MIT)
+#
+# Copyright (c) 2019 Dan Halbert for Adafruit Industries
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+DEBUG = 1
+
+# Select the board to build for.
+ifeq ($(BOARD),)
+ $(error You must provide a BOARD parameter)
+else
+ ifeq ($(wildcard boards/$(BOARD)/.),)
+ $(error Invalid BOARD specified)
+ endif
+endif
+
+# If the build directory is not given, make it reflect the board name.
+BUILD ?= build-$(BOARD)
+
+include ../../py/mkenv.mk
+# Board-specific
+include boards/$(BOARD)/mpconfigboard.mk
+# Port-specific
+include mpconfigport.mk
+
+# CircuitPython-specific
+include $(TOP)/py/circuitpy_mpconfig.mk
+
+# qstr definitions (must come before including py.mk)
+QSTR_DEFS = qstrdefsport.h
+
+# include py core make definitions
+include $(TOP)/py/py.mk
+
+include $(TOP)/supervisor/supervisor.mk
+
+# Include make rules and variables common across CircuitPython builds.
+include $(TOP)/py/circuitpy_defns.mk
+
+CROSS_COMPILE = arm-none-eabi-
+
+#######################################
+# CFLAGS
+#######################################
+
+INC += -I.
+INC += -I../..
+INC += -I$(BUILD)
+INC += -I$(BUILD)/genhdr
+INC += -I./stm32f4/STM32F4xx_HAL_Driver/Inc
+INC += -I./stm32f4/STM32F4xx_HAL_Driver/Inc/Legacy
+INC += -I./stm32f4/CMSIS/Device/ST/STM32F4xx/Include
+INC += -I./stm32f4/CMSIS/Include
+INC += -I./boards
+INC += -I./boards/$(BOARD)
+INC += -I./peripherals
+INC += -I../../lib/mp-readline
+INC += -I../../lib/tinyusb/src
+INC += -I../../supervisor/shared/usb
+
+
+#Debugging/Optimization
+ifeq ($(DEBUG), 1)
+ CFLAGS += -ggdb
+ # You may want to enable these flags to make setting breakpoints easier.
+ CFLAGS += -fno-inline -fno-ipa-sra
+else
+ CFLAGS += -Os -DNDEBUG
+ # TODO: Test with -flto
+ ### CFLAGS += -flto
+endif
+
+# C defines and other board specifics
+ifeq ($(MCU_SUB_VARIANT), stm32f412zx)
+C_DEFS = \
+ -DUSE_FULL_LL_DRIVER \
+ -DUSE_HAL_DRIVER \
+ -DSTM32F412Zx
+endif
+
+ifeq ($(MCU_SUB_VARIANT), stm32f411xe)
+C_DEFS = \
+ -DUSE_HAL_DRIVER \
+ -DSTM32F411xE
+endif
+
+#TODO: Add ASM Flags? -Werror
+CFLAGS += $(INC) -Wall -std=gnu11 -nostdlib $(BASE_CFLAGS) $(C_DEFS) $(CFLAGS_MOD) $(COPT)
+
+# Undo some warnings.
+# STM32 apparently also uses undefined preprocessor variables quite casually,
+# so we can't do warning checks for these.
+CFLAGS += -Wno-undef
+# STM32 might do casts that increase alignment requirements.
+CFLAGS += -Wno-cast-align
+
+CFLAGS += \
+ -mthumb \
+ -mabi=aapcs-linux \
+ -mfloat-abi=hard \
+ -mcpu=cortex-m4 \
+ -mfpu=fpv4-sp-d16
+
+# TODO: check this
+CFLAGS += -D__START=main
+
+LDFLAGS = $(CFLAGS) -fshort-enums -Wl,-nostdlib -Wl,-T,$(LD_FILE) -Wl,-Map=$@.map -Wl,-cref -Wl,-gc-sections -specs=nano.specs
+LIBS := -lgcc -lc
+
+LDFLAGS += -mthumb -mcpu=cortex-m4
+
+# Use toolchain libm if we're not using our own.
+ifndef INTERNAL_LIBM
+LIBS += -lm
+endif
+
+# TinyUSB defines
+CFLAGS += -DCFG_TUSB_MCU=OPT_MCU_STM32F4 -DCFG_TUD_CDC_RX_BUFSIZE=1024 -DCFG_TUD_CDC_TX_BUFSIZE=1024 -DCFG_TUD_MSC_BUFSIZE=4096 -DCFG_TUD_MIDI_RX_BUFSIZE=128 -DCFG_TUD_MIDI_TX_BUFSIZE=128
+
+
+######################################
+# source
+######################################
+
+SRC_STM32 = \
+ boards/$(BOARD)/stm32f4xx_hal_msp.c \
+ stm32f4/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_gpio.c \
+ stm32f4/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pcd.c \
+ stm32f4/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pcd_ex.c \
+ stm32f4/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_usb.c \
+ stm32f4/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_fsmc.c \
+ stm32f4/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_sram.c \
+ stm32f4/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_i2c.c \
+ stm32f4/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_dma.c \
+ stm32f4/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2s.c \
+ stm32f4/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2s_ex.c \
+ stm32f4/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_qspi.c \
+ stm32f4/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_sdmmc.c \
+ stm32f4/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_sd.c \
+ stm32f4/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.c \
+ stm32f4/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.c \
+ stm32f4/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_usart.c \
+ stm32f4/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_rcc.c \
+ stm32f4/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_utils.c \
+ stm32f4/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_exti.c \
+ stm32f4/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_uart.c \
+ stm32f4/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.c \
+ stm32f4/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.c \
+ stm32f4/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.c \
+ stm32f4/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.c \
+ stm32f4/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.c \
+ stm32f4/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.c \
+ stm32f4/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma_ex.c \
+ stm32f4/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c \
+ stm32f4/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.c \
+ stm32f4/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.c \
+ stm32f4/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.c \
+ stm32f4/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c \
+ stm32f4/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_exti.c \
+ system_stm32f4xx.c
+
+SRC_C += \
+ background.c \
+ fatfs_port.c \
+ mphalport.c \
+ tick.c \
+ boards/$(BOARD)/board.c \
+ peripherals/stm32f4/$(MCU_SUB_VARIANT)/clocks.c \
+ peripherals/stm32f4/$(MCU_SUB_VARIANT)/gpio.c \
+ lib/libc/string0.c \
+ lib/mp-readline/readline.c \
+ lib/oofatfs/ff.c \
+ lib/oofatfs/option/ccsbcs.c \
+ lib/timeutils/timeutils.c \
+ lib/utils/buffer_helper.c \
+ lib/utils/context_manager_helpers.c \
+ lib/utils/interrupt_char.c \
+ lib/utils/pyexec.c \
+ lib/utils/stdout_helpers.c \
+ lib/utils/sys_stdio_mphal.c \
+ supervisor/shared/memory.c
+
+ifneq ($(USB),FALSE)
+SRC_C += lib/tinyusb/src/portable/st/stm32f4/dcd_stm32f4.c
+endif
+
+ifeq ($(MCU_SUB_VARIANT), stm32f412zx)
+SRC_C += peripherals/stm32f4/stm32f412zx/pins.c
+SRC_C += boards/$(BOARD)/pins.c
+endif
+
+SRC_S = \
+ supervisor/cpu.s \
+ boards/startup_$(MCU_SUB_VARIANT).s
+
+SRC_COMMON_HAL_EXPANDED = $(addprefix shared-bindings/, $(SRC_COMMON_HAL)) \
+ $(addprefix shared-bindings/, $(SRC_BINDINGS_ENUMS)) \
+ $(addprefix common-hal/, $(SRC_COMMON_HAL))
+
+SRC_SHARED_MODULE_EXPANDED = $(addprefix shared-bindings/, $(SRC_SHARED_MODULE)) \
+ $(addprefix shared-module/, $(SRC_SHARED_MODULE))
+
+
+
+FROZEN_MPY_PY_FILES := $(shell find -L $(FROZEN_MPY_DIR) -type f -name '*.py')
+FROZEN_MPY_MPY_FILES := $(addprefix $(BUILD)/,$(FROZEN_MPY_PY_FILES:.py=.mpy))
+
+OBJ += $(PY_O) $(SUPERVISOR_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
+OBJ += $(addprefix $(BUILD)/, $(SRC_STM32:.c=.o))
+OBJ += $(addprefix $(BUILD)/, $(SRC_COMMON_HAL_EXPANDED:.c=.o))
+OBJ += $(addprefix $(BUILD)/, $(SRC_SHARED_MODULE_EXPANDED:.c=.o))
+ifeq ($(INTERNAL_LIBM),1)
+OBJ += $(addprefix $(BUILD)/, $(SRC_LIBM:.c=.o))
+endif
+OBJ += $(addprefix $(BUILD)/, $(SRC_S:.s=.o))
+OBJ += $(addprefix $(BUILD)/, $(SRC_MOD:.c=.o))
+
+$(BUILD)/$(FATFS_DIR)/ff.o: COPT += -Os
+$(filter $(PY_BUILD)/../extmod/vfs_fat_%.o, $(PY_O)): COPT += -Os
+
+# List of sources for qstr extraction
+SRC_QSTR += $(SRC_C) $(SRC_SUPERVISOR) $(SRC_MOD) $(SRC_COMMON_HAL_EXPANDED) $(SRC_SHARED_MODULE_EXPANDED)
+# Sources that only hold QSTRs after pre-processing.
+SRC_QSTR_PREPROCESSOR +=
+
+
+all: $(BUILD)/firmware.bin $(BUILD)/firmware.uf2
+
+$(BUILD)/firmware.elf: $(OBJ)
+ $(STEPECHO) "LINK $@"
+ $(Q)$(CC) -o $@ $(LDFLAGS) $^ -Wl,--start-group $(LIBS) -Wl,--end-group
+ $(Q)$(SIZE) $@ | $(PYTHON3) $(TOP)/tools/build_memory_info.py $(LD_FILE)
+
+$(BUILD)/firmware.bin: $(BUILD)/firmware.elf
+ $(STEPECHO) "Create $@"
+ $(Q)$(OBJCOPY) -O binary $^ $@
+# $(Q)$(OBJCOPY) -O binary -j .vectors -j .text -j .data $^ $@
+
+$(BUILD)/firmware.hex: $(BUILD)/firmware.elf
+ $(STEPECHO) "Create $@"
+ $(Q)$(OBJCOPY) -O ihex $^ $@
+# $(Q)$(OBJCOPY) -O ihex -j .vectors -j .text -j .data $^ $@
+
+$(BUILD)/firmware.uf2: $(BUILD)/firmware.hex
+ $(ECHO) "Create $@"
+ $(PYTHON3) $(TOP)/tools/uf2/utils/uf2conv.py -f 0xADA52840 -c -o "$(BUILD)/firmware.uf2" $^
+
+include $(TOP)/py/mkrules.mk
+
+# Print out the value of a make variable.
+# https://stackoverflow.com/questions/16467718/how-to-print-out-a-variable-in-makefile
+print-%:
+ @echo $* = $($*)
diff --git a/ports/stm32f4/README.md b/ports/stm32f4/README.md
new file mode 100644
index 000000000..a860c01ce
--- /dev/null
+++ b/ports/stm32f4/README.md
@@ -0,0 +1,3 @@
+# CircuitPython Port To The ST Microelectronics STM32F4 Series
+
+This is a port of CircuitPython to the STM32F4 series of chips.
diff --git a/ports/stm32f4/background.c b/ports/stm32f4/background.c
new file mode 100644
index 000000000..e9872b045
--- /dev/null
+++ b/ports/stm32f4/background.c
@@ -0,0 +1,57 @@
+/*
+ * 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 "py/runtime.h"
+#include "supervisor/filesystem.h"
+#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();
+ //usb_background();
+
+ #if CIRCUITPY_DISPLAYIO
+ displayio_refresh_displays();
+ #endif
+ running_background_tasks = false;
+
+ assert_heap_ok();
+}
diff --git a/ports/stm32f4/background.h b/ports/stm32f4/background.h
new file mode 100644
index 000000000..05a4f894a
--- /dev/null
+++ b/ports/stm32f4/background.h
@@ -0,0 +1,35 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019 Dan Halbert for Adafruit Industries
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#ifndef MICROPY_INCLUDED_STM32F4_BACKGROUND_H
+#define MICROPY_INCLUDED_STM32F4_BACKGROUND_H
+
+#include <stdbool.h>
+
+void background_tasks_reset(void);
+void run_background_tasks(void);
+
+#endif // MICROPY_INCLUDED_STM32F4_BACKGROUND_H
diff --git a/ports/stm32f4/boards/STM32F411VETx_FLASH.ld b/ports/stm32f4/boards/STM32F411VETx_FLASH.ld
new file mode 100644
index 000000000..a3c3594a9
--- /dev/null
+++ b/ports/stm32f4/boards/STM32F411VETx_FLASH.ld
@@ -0,0 +1,189 @@
+/*
+******************************************************************************
+**
+
+** File : LinkerScript.ld
+**
+** Author : Auto-generated by Ac6 System Workbench
+**
+** Abstract : Linker script for STM32F411VETx series
+** 512Kbytes FLASH and 128Kbytes RAM
+**
+** Set heap size, stack size and stack location according
+** to application requirements.
+**
+** Set memory bank area and size if external memory is used.
+**
+** Target : STMicroelectronics STM32
+**
+** Distribution: The file is distributed “as is,” without any warranty
+** of any kind.
+**
+*****************************************************************************
+** @attention
+**
+** <h2><center>&copy; COPYRIGHT(c) 2014 Ac6</center></h2>
+**
+** 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 Ac6 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.
+**
+*****************************************************************************
+*/
+
+/* Entry Point */
+ENTRY(Reset_Handler)
+
+/* Highest address of the user mode stack */
+_estack = 0x20020000; /* end of RAM */
+/* Generate a link error if heap and stack don't fit into RAM */
+_Min_Heap_Size = 0x200; /* required amount of heap */
+_Min_Stack_Size = 0x400; /* required amount of stack */
+
+/* Specify the memory areas */
+MEMORY
+{
+RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
+FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 512K
+}
+
+/* Define output sections */
+SECTIONS
+{
+ /* The startup code goes first into FLASH */
+ .isr_vector :
+ {
+ . = ALIGN(4);
+ KEEP(*(.isr_vector)) /* Startup code */
+ . = ALIGN(4);
+ } >FLASH
+
+ /* The program code and other data goes into FLASH */
+ .text :
+ {
+ . = ALIGN(4);
+ *(.text) /* .text sections (code) */
+ *(.text*) /* .text* sections (code) */
+ *(.glue_7) /* glue arm to thumb code */
+ *(.glue_7t) /* glue thumb to arm code */
+ *(.eh_frame)
+
+ KEEP (*(.init))
+ KEEP (*(.fini))
+
+ . = ALIGN(4);
+ _etext = .; /* define a global symbols at end of code */
+ } >FLASH
+
+ /* Constant data goes into FLASH */
+ .rodata :
+ {
+ . = ALIGN(4);
+ *(.rodata) /* .rodata sections (constants, strings, etc.) */
+ *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
+ . = ALIGN(4);
+ } >FLASH
+
+ .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
+ .ARM : {
+ __exidx_start = .;
+ *(.ARM.exidx*)
+ __exidx_end = .;
+ } >FLASH
+
+ .preinit_array :
+ {
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ KEEP (*(.preinit_array*))
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+ } >FLASH
+ .init_array :
+ {
+ PROVIDE_HIDDEN (__init_array_start = .);
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array*))
+ PROVIDE_HIDDEN (__init_array_end = .);
+ } >FLASH
+ .fini_array :
+ {
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ KEEP (*(SORT(.fini_array.*)))
+ KEEP (*(.fini_array*))
+ PROVIDE_HIDDEN (__fini_array_end = .);
+ } >FLASH
+
+ /* used by the startup to initialize data */
+ _sidata = LOADADDR(.data);
+
+ /* Initialized data sections goes into RAM, load LMA copy after code */
+ .data :
+ {
+ . = ALIGN(4);
+ _sdata = .; /* create a global symbol at data start */
+ *(.data) /* .data sections */
+ *(.data*) /* .data* sections */
+
+ . = ALIGN(4);
+ _edata = .; /* define a global symbol at data end */
+ } >RAM AT> FLASH
+
+
+ /* Uninitialized data section */
+ . = ALIGN(4);
+ .bss :
+ {
+ /* This is used by the startup in order to initialize the .bss secion */
+ _sbss = .; /* define a global symbol at bss start */
+ __bss_start__ = _sbss;
+ *(.bss)
+ *(.bss*)
+ *(COMMON)
+
+ . = ALIGN(4);
+ _ebss = .; /* define a global symbol at bss end */
+ __bss_end__ = _ebss;
+ } >RAM
+
+ /* User_heap_stack section, used to check that there is enough RAM left */
+ ._user_heap_stack :
+ {
+ . = ALIGN(8);
+ PROVIDE ( end = . );
+ PROVIDE ( _end = . );
+ . = . + _Min_Heap_Size;
+ . = . + _Min_Stack_Size;
+ . = ALIGN(8);
+ } >RAM
+
+
+
+ /* Remove information from the standard libraries */
+ /DISCARD/ :
+ {
+ libc.a ( * )
+ libm.a ( * )
+ libgcc.a ( * )
+ }
+
+ .ARM.attributes 0 : { *(.ARM.attributes) }
+}
+
+
diff --git a/ports/stm32f4/boards/STM32F412ZGTx_FLASH.ld b/ports/stm32f4/boards/STM32F412ZGTx_FLASH.ld
new file mode 100644
index 000000000..da1efdecc
--- /dev/null
+++ b/ports/stm32f4/boards/STM32F412ZGTx_FLASH.ld
@@ -0,0 +1,189 @@
+/*
+******************************************************************************
+**
+
+** File : LinkerScript.ld
+**
+** Author : Auto-generated by Ac6 System Workbench
+**
+** Abstract : Linker script for STM32F412ZGTx series
+** 1024Kbytes FLASH and 256Kbytes RAM
+**
+** Set heap size, stack size and stack location according
+** to application requirements.
+**
+** Set memory bank area and size if external memory is used.
+**
+** Target : STMicroelectronics STM32
+**
+** Distribution: The file is distributed “as is,” without any warranty
+** of any kind.
+**
+*****************************************************************************
+** @attention
+**
+** <h2><center>&copy; COPYRIGHT(c) 2014 Ac6</center></h2>
+**
+** 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 Ac6 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.
+**
+*****************************************************************************
+*/
+
+/* Entry Point */
+ENTRY(Reset_Handler)
+
+/* Highest address of the user mode stack */
+_estack = 0x20040000; /* end of RAM */
+/* Generate a link error if heap and stack don't fit into RAM */
+_Min_Heap_Size = 0x200; /* required amount of heap */
+_Min_Stack_Size = 0x400; /* required amount of stack */
+
+/* Specify the memory areas */
+MEMORY
+{
+RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 256K
+FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 1024K
+}
+
+/* Define output sections */
+SECTIONS
+{
+ /* The startup code goes first into FLASH */
+ .isr_vector :
+ {
+ . = ALIGN(4);
+ KEEP(*(.isr_vector)) /* Startup code */
+ . = ALIGN(4);
+ } >FLASH
+
+ /* The program code and other data goes into FLASH */
+ .text :
+ {
+ . = ALIGN(4);
+ *(.text) /* .text sections (code) */
+ *(.text*) /* .text* sections (code) */
+ *(.glue_7) /* glue arm to thumb code */
+ *(.glue_7t) /* glue thumb to arm code */
+ *(.eh_frame)
+
+ KEEP (*(.init))
+ KEEP (*(.fini))
+
+ . = ALIGN(4);
+ _etext = .; /* define a global symbols at end of code */
+ } >FLASH
+
+ /* Constant data goes into FLASH */
+ .rodata :
+ {
+ . = ALIGN(4);
+ *(.rodata) /* .rodata sections (constants, strings, etc.) */
+ *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
+ . = ALIGN(4);
+ } >FLASH
+
+ .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
+ .ARM : {
+ __exidx_start = .;
+ *(.ARM.exidx*)
+ __exidx_end = .;
+ } >FLASH
+
+ .preinit_array :
+ {
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ KEEP (*(.preinit_array*))
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+ } >FLASH
+ .init_array :
+ {
+ PROVIDE_HIDDEN (__init_array_start = .);
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array*))
+ PROVIDE_HIDDEN (__init_array_end = .);
+ } >FLASH
+ .fini_array :
+ {
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ KEEP (*(SORT(.fini_array.*)))
+ KEEP (*(.fini_array*))
+ PROVIDE_HIDDEN (__fini_array_end = .);
+ } >FLASH
+
+ /* used by the startup to initialize data */
+ _sidata = LOADADDR(.data);
+
+ /* Initialized data sections goes into RAM, load LMA copy after code */
+ .data :
+ {
+ . = ALIGN(4);
+ _sdata = .; /* create a global symbol at data start */
+ *(.data) /* .data sections */
+ *(.data*) /* .data* sections */
+
+ . = ALIGN(4);
+ _edata = .; /* define a global symbol at data end */
+ } >RAM AT> FLASH
+
+
+ /* Uninitialized data section */
+ . = ALIGN(4);
+ .bss :
+ {
+ /* This is used by the startup in order to initialize the .bss secion */
+ _sbss = .; /* define a global symbol at bss start */
+ __bss_start__ = _sbss;
+ *(.bss)
+ *(.bss*)
+ *(COMMON)
+
+ . = ALIGN(4);
+ _ebss = .; /* define a global symbol at bss end */
+ __bss_end__ = _ebss;
+ } >RAM
+
+ /* User_heap_stack section, used to check that there is enough RAM left */
+ ._user_heap_stack :
+ {
+ . = ALIGN(8);
+ PROVIDE ( end = . );
+ PROVIDE ( _end = . );
+ . = . + _Min_Heap_Size;
+ . = . + _Min_Stack_Size;
+ . = ALIGN(8);
+ } >RAM
+
+
+
+ /* Remove information from the standard libraries */
+ /DISCARD/ :
+ {
+ libc.a ( * )
+ libm.a ( * )
+ libgcc.a ( * )
+ }
+
+ .ARM.attributes 0 : { *(.ARM.attributes) }
+}
+
+
diff --git a/ports/stm32f4/boards/board.h b/ports/stm32f4/boards/board.h
new file mode 100644
index 000000000..22d9e99be
--- /dev/null
+++ b/ports/stm32f4/boards/board.h
@@ -0,0 +1,45 @@
+/*
+ * 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.
+ */
+
+// This file defines board specific functions.
+
+#ifndef MICROPY_INCLUDED_STM32F4_BOARDS_BOARD_H
+#define MICROPY_INCLUDED_STM32F4_BOARDS_BOARD_H
+
+#include <stdbool.h>
+
+// Initializes board related state once on start up.
+void board_init(void);
+
+// Returns true if the user initiates safe mode in a board specific way.
+// Also add BOARD_USER_SAFE_MODE in mpconfigboard.h to explain the board specific
+// way.
+bool board_requests_safe_mode(void);
+
+// Reset the state of off MCU components such as neopixels.
+void reset_board(void);
+
+#endif // MICROPY_INCLUDED_STM32F4_BOARDS_BOARD_H
diff --git a/ports/stm32f4/boards/startup_stm32f411xe.s b/ports/stm32f4/boards/startup_stm32f411xe.s
new file mode 100644
index 000000000..3aac640cb
--- /dev/null
+++ b/ports/stm32f4/boards/startup_stm32f411xe.s
@@ -0,0 +1,452 @@
+/**
+ ******************************************************************************
+ * @file startup_stm32f411xe.s
+ * @author MCD Application Team
+ * @brief STM32F411xExx Devices vector table for GCC based toolchains.
+ * This module performs:
+ * - Set the initial SP
+ * - Set the initial PC == Reset_Handler,
+ * - Set the vector table entries with the exceptions ISR address
+ * - Branches to main in the C library (which eventually
+ * calls main()).
+ * After Reset the Cortex-M4 processor is in Thread mode,
+ * priority is Privileged, and the Stack is set to Main.
+ ******************************************************************************
+ * @attention
+ *
+ * <h2><center>&copy; COPYRIGHT 2017 STMicroelectronics</center></h2>
+ *
+ * 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 STMicroelectronics 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.
+ *
+ ******************************************************************************
+ */
+
+ .syntax unified
+ .cpu cortex-m4
+ .fpu softvfp
+ .thumb
+
+.global g_pfnVectors
+.global Default_Handler
+
+/* start address for the initialization values of the .data section.
+defined in linker script */
+.word _sidata
+/* start address for the .data section. defined in linker script */
+.word _sdata
+/* end address for the .data section. defined in linker script */
+.word _edata
+/* start address for the .bss section. defined in linker script */
+.word _sbss
+/* end address for the .bss section. defined in linker script */
+.word _ebss
+/* stack used for SystemInit_ExtMemCtl; always internal RAM used */
+
+/**
+ * @brief This is the code that gets called when the processor first
+ * starts execution following a reset event. Only the absolutely
+ * necessary set is performed, after which the application
+ * supplied main() routine is called.
+ * @param None
+ * @retval : None
+*/
+
+ .section .text.Reset_Handler
+ .weak Reset_Handler
+ .type Reset_Handler, %function
+Reset_Handler:
+ ldr sp, =_estack /* set stack pointer */
+
+/* Copy the data segment initializers from flash to SRAM */
+ movs r1, #0
+ b LoopCopyDataInit
+
+CopyDataInit:
+ ldr r3, =_sidata
+ ldr r3, [r3, r1]
+ str r3, [r0, r1]
+ adds r1, r1, #4
+
+LoopCopyDataInit:
+ ldr r0, =_sdata
+ ldr r3, =_edata
+ adds r2, r0, r1
+ cmp r2, r3
+ bcc CopyDataInit
+ ldr r2, =_sbss
+ b LoopFillZerobss
+/* Zero fill the bss segment. */
+FillZerobss:
+ movs r3, #0
+ str r3, [r2], #4
+
+LoopFillZerobss:
+ ldr r3, = _ebss
+ cmp r2, r3
+ bcc FillZerobss
+
+/* Call the clock system intitialization function.*/
+ bl SystemInit
+/* Call static constructors */
+/* bl __libc_init_array */
+/* Call the application's entry point.*/
+ bl main
+ bx lr
+.size Reset_Handler, .-Reset_Handler
+
+/**
+ * @brief This is the code that gets called when the processor receives an
+ * unexpected interrupt. This simply enters an infinite loop, preserving
+ * the system state for examination by a debugger.
+ * @param None
+ * @retval None
+*/
+ .section .text.Default_Handler,"ax",%progbits
+Default_Handler:
+Infinite_Loop:
+ b Infinite_Loop
+ .size Default_Handler, .-Default_Handler
+/******************************************************************************
+*
+* The minimal vector table for a Cortex M3. Note that the proper constructs
+* must be placed on this to ensure that it ends up at physical address
+* 0x0000.0000.
+*
+*******************************************************************************/
+ .section .isr_vector,"a",%progbits
+ .type g_pfnVectors, %object
+ .size g_pfnVectors, .-g_pfnVectors
+
+g_pfnVectors:
+ .word _estack
+ .word Reset_Handler
+ .word NMI_Handler
+ .word HardFault_Handler
+ .word MemManage_Handler
+ .word BusFault_Handler
+ .word UsageFault_Handler
+ .word 0
+ .word 0
+ .word 0
+ .word 0
+ .word SVC_Handler
+ .word DebugMon_Handler
+ .word 0
+ .word PendSV_Handler
+ .word SysTick_Handler
+
+ /* External Interrupts */
+ .word WWDG_IRQHandler /* Window WatchDog */
+ .word PVD_IRQHandler /* PVD through EXTI Line detection */
+ .word TAMP_STAMP_IRQHandler /* Tamper and TimeStamps through the EXTI line */
+ .word RTC_WKUP_IRQHandler /* RTC Wakeup through the EXTI line */
+ .word FLASH_IRQHandler /* FLASH */
+ .word RCC_IRQHandler /* RCC */
+ .word EXTI0_IRQHandler /* EXTI Line0 */
+ .word EXTI1_IRQHandler /* EXTI Line1 */
+ .word EXTI2_IRQHandler /* EXTI Line2 */
+ .word EXTI3_IRQHandler /* EXTI Line3 */
+ .word EXTI4_IRQHandler /* EXTI Line4 */
+ .word DMA1_Stream0_IRQHandler /* DMA1 Stream 0 */
+ .word DMA1_Stream1_IRQHandler /* DMA1 Stream 1 */
+ .word DMA1_Stream2_IRQHandler /* DMA1 Stream 2 */
+ .word DMA1_Stream3_IRQHandler /* DMA1 Stream 3 */
+ .word DMA1_Stream4_IRQHandler /* DMA1 Stream 4 */
+ .word DMA1_Stream5_IRQHandler /* DMA1 Stream 5 */
+ .word DMA1_Stream6_IRQHandler /* DMA1 Stream 6 */
+ .word ADC_IRQHandler /* ADC1, ADC2 and ADC3s */
+ .word 0 /* Reserved */
+ .word 0 /* Reserved */
+ .word 0 /* Reserved */
+ .word 0 /* Reserved */
+ .word EXTI9_5_IRQHandler /* External Line[9:5]s */
+ .word TIM1_BRK_TIM9_IRQHandler /* TIM1 Break and TIM9 */
+ .word TIM1_UP_TIM10_IRQHandler /* TIM1 Update and TIM10 */
+ .word TIM1_TRG_COM_TIM11_IRQHandler /* TIM1 Trigger and Commutation and TIM11 */
+ .word TIM1_CC_IRQHandler /* TIM1 Capture Compare */
+ .word TIM2_IRQHandler /* TIM2 */
+ .word TIM3_IRQHandler /* TIM3 */
+ .word TIM4_IRQHandler /* TIM4 */
+ .word I2C1_EV_IRQHandler /* I2C1 Event */
+ .word I2C1_ER_IRQHandler /* I2C1 Error */
+ .word I2C2_EV_IRQHandler /* I2C2 Event */
+ .word I2C2_ER_IRQHandler /* I2C2 Error */
+ .word SPI1_IRQHandler /* SPI1 */
+ .word SPI2_IRQHandler /* SPI2 */
+ .word USART1_IRQHandler /* USART1 */
+ .word USART2_IRQHandler /* USART2 */
+ .word 0 /* Reserved */
+ .word EXTI15_10_IRQHandler /* External Line[15:10]s */
+ .word RTC_Alarm_IRQHandler /* RTC Alarm (A and B) through EXTI Line */
+ .word OTG_FS_WKUP_IRQHandler /* USB OTG FS Wakeup through EXTI line */
+ .word 0 /* Reserved */
+ .word 0 /* Reserved */
+ .word 0 /* Reserved */
+ .word 0 /* Reserved */
+ .word DMA1_Stream7_IRQHandler /* DMA1 Stream7 */
+ .word 0 /* Reserved */
+ .word SDIO_IRQHandler /* SDIO */
+ .word TIM5_IRQHandler /* TIM5 */
+ .word SPI3_IRQHandler /* SPI3 */
+ .word 0 /* Reserved */
+ .word 0 /* Reserved */
+ .word 0 /* Reserved */
+ .word 0 /* Reserved */
+ .word DMA2_Stream0_IRQHandler /* DMA2 Stream 0 */
+ .word DMA2_Stream1_IRQHandler /* DMA2 Stream 1 */
+ .word DMA2_Stream2_IRQHandler /* DMA2 Stream 2 */
+ .word DMA2_Stream3_IRQHandler /* DMA2 Stream 3 */
+ .word DMA2_Stream4_IRQHandler /* DMA2 Stream 4 */
+ .word 0 /* Reserved */
+ .word 0 /* Reserved */
+ .word 0 /* Reserved */
+ .word 0 /* Reserved */
+ .word 0 /* Reserved */
+ .word 0 /* Reserved */
+ .word OTG_FS_IRQHandler /* USB OTG FS */
+ .word DMA2_Stream5_IRQHandler /* DMA2 Stream 5 */
+ .word DMA2_Stream6_IRQHandler /* DMA2 Stream 6 */
+ .word DMA2_Stream7_IRQHandler /* DMA2 Stream 7 */
+ .word USART6_IRQHandler /* USART6 */
+ .word I2C3_EV_IRQHandler /* I2C3 event */
+ .word I2C3_ER_IRQHandler /* I2C3 error */
+ .word 0 /* Reserved */
+ .word 0 /* Reserved */
+ .word 0 /* Reserved */
+ .word 0 /* Reserved */
+ .word 0 /* Reserved */
+ .word 0 /* Reserved */
+ .word 0 /* Reserved */
+ .word FPU_IRQHandler /* FPU */
+ .word 0 /* Reserved */
+ .word 0 /* Reserved */
+ .word SPI4_IRQHandler /* SPI4 */
+ .word SPI5_IRQHandler /* SPI5 */
+
+/*******************************************************************************
+*
+* Provide weak aliases for each Exception handler to the Default_Handler.
+* As they are weak aliases, any function with the same name will override
+* this definition.
+*
+*******************************************************************************/
+ .weak NMI_Handler
+ .thumb_set NMI_Handler,Default_Handler
+
+ .weak HardFault_Handler
+ .thumb_set HardFault_Handler,Default_Handler
+
+ .weak MemManage_Handler
+ .thumb_set MemManage_Handler,Default_Handler
+
+ .weak BusFault_Handler
+ .thumb_set BusFault_Handler,Default_Handler
+
+ .weak UsageFault_Handler
+ .thumb_set UsageFault_Handler,Default_Handler
+
+ .weak SVC_Handler
+ .thumb_set SVC_Handler,Default_Handler
+
+ .weak DebugMon_Handler
+ .thumb_set DebugMon_Handler,Default_Handler
+
+ .weak PendSV_Handler
+ .thumb_set PendSV_Handler,Default_Handler
+
+ .weak SysTick_Handler
+ .thumb_set SysTick_Handler,Default_Handler
+
+ .weak WWDG_IRQHandler
+ .thumb_set WWDG_IRQHandler,Default_Handler
+
+ .weak PVD_IRQHandler
+ .thumb_set PVD_IRQHandler,Default_Handler
+
+ .weak TAMP_STAMP_IRQHandler
+ .thumb_set TAMP_STAMP_IRQHandler,Default_Handler
+
+ .weak RTC_WKUP_IRQHandler
+ .thumb_set RTC_WKUP_IRQHandler,Default_Handler
+
+ .weak FLASH_IRQHandler
+ .thumb_set FLASH_IRQHandler,Default_Handler
+
+ .weak RCC_IRQHandler
+ .thumb_set RCC_IRQHandler,Default_Handler
+
+ .weak EXTI0_IRQHandler
+ .thumb_set EXTI0_IRQHandler,Default_Handler
+
+ .weak EXTI1_IRQHandler
+ .thumb_set EXTI1_IRQHandler,Default_Handler
+
+ .weak EXTI2_IRQHandler
+ .thumb_set EXTI2_IRQHandler,Default_Handler
+
+ .weak EXTI3_IRQHandler
+ .thumb_set EXTI3_IRQHandler,Default_Handler
+
+ .weak EXTI4_IRQHandler
+ .thumb_set EXTI4_IRQHandler,Default_Handler
+
+ .weak DMA1_Stream0_IRQHandler
+ .thumb_set DMA1_Stream0_IRQHandler,Default_Handler
+
+ .weak DMA1_Stream1_IRQHandler
+ .thumb_set DMA1_Stream1_IRQHandler,Default_Handler
+
+ .weak DMA1_Stream2_IRQHandler
+ .thumb_set DMA1_Stream2_IRQHandler,Default_Handler
+
+ .weak DMA1_Stream3_IRQHandler
+ .thumb_set DMA1_Stream3_IRQHandler,Default_Handler
+
+ .weak DMA1_Stream4_IRQHandler
+ .thumb_set DMA1_Stream4_IRQHandler,Default_Handler
+
+ .weak DMA1_Stream5_IRQHandler
+ .thumb_set DMA1_Stream5_IRQHandler,Default_Handler
+
+ .weak DMA1_Stream6_IRQHandler
+ .thumb_set DMA1_Stream6_IRQHandler,Default_Handler
+
+ .weak ADC_IRQHandler
+ .thumb_set ADC_IRQHandler,Default_Handler
+
+ .weak EXTI9_5_IRQHandler
+ .thumb_set EXTI9_5_IRQHandler,Default_Handler
+
+ .weak TIM1_BRK_TIM9_IRQHandler
+ .thumb_set TIM1_BRK_TIM9_IRQHandler,Default_Handler
+
+ .weak TIM1_UP_TIM10_IRQHandler
+ .thumb_set TIM1_UP_TIM10_IRQHandler,Default_Handler
+
+ .weak TIM1_TRG_COM_TIM11_IRQHandler
+ .thumb_set TIM1_TRG_COM_TIM11_IRQHandler,Default_Handler
+
+ .weak TIM1_CC_IRQHandler
+ .thumb_set TIM1_CC_IRQHandler,Default_Handler
+
+ .weak TIM2_IRQHandler
+ .thumb_set TIM2_IRQHandler,Default_Handler
+
+ .weak TIM3_IRQHandler
+ .thumb_set TIM3_IRQHandler,Default_Handler
+
+ .weak TIM4_IRQHandler
+ .thumb_set TIM4_IRQHandler,Default_Handler
+
+ .weak I2C1_EV_IRQHandler
+ .thumb_set I2C1_EV_IRQHandler,Default_Handler
+
+ .weak I2C1_ER_IRQHandler
+ .thumb_set I2C1_ER_IRQHandler,Default_Handler
+
+ .weak I2C2_EV_IRQHandler
+ .thumb_set I2C2_EV_IRQHandler,Default_Handler
+
+ .weak I2C2_ER_IRQHandler
+ .thumb_set I2C2_ER_IRQHandler,Default_Handler
+
+ .weak SPI1_IRQHandler
+ .thumb_set SPI1_IRQHandler,Default_Handler
+
+ .weak SPI2_IRQHandler
+ .thumb_set SPI2_IRQHandler,Default_Handler
+
+ .weak USART1_IRQHandler
+ .thumb_set USART1_IRQHandler,Default_Handler
+
+ .weak USART2_IRQHandler
+ .thumb_set USART2_IRQHandler,Default_Handler
+
+ .weak EXTI15_10_IRQHandler
+ .thumb_set EXTI15_10_IRQHandler,Default_Handler
+
+ .weak RTC_Alarm_IRQHandler
+ .thumb_set RTC_Alarm_IRQHandler,Default_Handler
+
+ .weak OTG_FS_WKUP_IRQHandler
+ .thumb_set OTG_FS_WKUP_IRQHandler,Default_Handler
+
+ .weak DMA1_Stream7_IRQHandler
+ .thumb_set DMA1_Stream7_IRQHandler,Default_Handler
+
+ .weak SDIO_IRQHandler
+ .thumb_set SDIO_IRQHandler,Default_Handler
+
+ .weak TIM5_IRQHandler
+ .thumb_set TIM5_IRQHandler,Default_Handler
+
+ .weak SPI3_IRQHandler
+ .thumb_set SPI3_IRQHandler,Default_Handler
+
+ .weak DMA2_Stream0_IRQHandler
+ .thumb_set DMA2_Stream0_IRQHandler,Default_Handler
+
+ .weak DMA2_Stream1_IRQHandler
+ .thumb_set DMA2_Stream1_IRQHandler,Default_Handler
+
+ .weak DMA2_Stream2_IRQHandler
+ .thumb_set DMA2_Stream2_IRQHandler,Default_Handler
+
+ .weak DMA2_Stream3_IRQHandler
+ .thumb_set DMA2_Stream3_IRQHandler,Default_Handler
+
+ .weak DMA2_Stream4_IRQHandler
+ .thumb_set DMA2_Stream4_IRQHandler,Default_Handler
+
+ .weak OTG_FS_IRQHandler
+ .thumb_set OTG_FS_IRQHandler,Default_Handler
+
+ .weak DMA2_Stream5_IRQHandler
+ .thumb_set DMA2_Stream5_IRQHandler,Default_Handler
+
+ .weak DMA2_Stream6_IRQHandler
+ .thumb_set DMA2_Stream6_IRQHandler,Default_Handler
+
+ .weak DMA2_Stream7_IRQHandler
+ .thumb_set DMA2_Stream7_IRQHandler,Default_Handler
+
+ .weak USART6_IRQHandler
+ .thumb_set USART6_IRQHandler,Default_Handler
+
+ .weak I2C3_EV_IRQHandler
+ .thumb_set I2C3_EV_IRQHandler,Default_Handler
+
+ .weak I2C3_ER_IRQHandler
+ .thumb_set I2C3_ER_IRQHandler,Default_Handler
+
+ .weak FPU_IRQHandler
+ .thumb_set FPU_IRQHandler,Default_Handler
+
+ .weak SPI4_IRQHandler
+ .thumb_set SPI4_IRQHandler,Default_Handler
+
+ .weak SPI5_IRQHandler
+ .thumb_set SPI5_IRQHandler,Default_Handler
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
+
diff --git a/ports/stm32f4/boards/startup_stm32f412zx.s b/ports/stm32f4/boards/startup_stm32f412zx.s
new file mode 100644
index 000000000..801220795
--- /dev/null
+++ b/ports/stm32f4/boards/startup_stm32f412zx.s
@@ -0,0 +1,524 @@
+/**
+ ******************************************************************************
+ * @file startup_stm32f412zx.s
+ * @author MCD Application Team
+ * @brief STM32F412Zx Devices vector table for GCC based toolchains.
+ * This module performs:
+ * - Set the initial SP
+ * - Set the initial PC == Reset_Handler,
+ * - Set the vector table entries with the exceptions ISR address
+ * - Branches to main in the C library (which eventually
+ * calls main()).
+ * After Reset the Cortex-M4 processor is in Thread mode,
+ * priority is Privileged, and the Stack is set to Main.
+ ******************************************************************************
+ * @attention
+ *
+ * <h2><center>&copy; COPYRIGHT 2017 STMicroelectronics</center></h2>
+ *
+ * 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 STMicroelectronics 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.
+ *
+ ******************************************************************************
+ */
+
+ .syntax unified
+ .cpu cortex-m4
+ .fpu softvfp
+ .thumb
+
+.global g_pfnVectors
+.global Default_Handler
+
+/* start address for the initialization values of the .data section.
+defined in linker script */
+.word _sidata
+/* start address for the .data section. defined in linker script */
+.word _sdata
+/* end address for the .data section. defined in linker script */
+.word _edata
+/* start address for the .bss section. defined in linker script */
+.word _sbss
+/* end address for the .bss section. defined in linker script */
+.word _ebss
+/* stack used for SystemInit_ExtMemCtl; always internal RAM used */
+
+/**
+ * @brief This is the code that gets called when the processor first
+ * starts execution following a reset event. Only the absolutely
+ * necessary set is performed, after which the application
+ * supplied main() routine is called.
+ * @param None
+ * @retval : None
+*/
+
+ .section .text.Reset_Handler
+ .weak Reset_Handler
+ .type Reset_Handler, %function
+Reset_Handler:
+ ldr sp, =_estack /* set stack pointer */
+
+/* Copy the data segment initializers from flash to SRAM */
+ movs r1, #0
+ b LoopCopyDataInit
+
+CopyDataInit:
+ ldr r3, =_sidata
+ ldr r3, [r3, r1]
+ str r3, [r0, r1]
+ adds r1, r1, #4
+
+LoopCopyDataInit:
+ ldr r0, =_sdata
+ ldr r3, =_edata
+ adds r2, r0, r1
+ cmp r2, r3
+ bcc CopyDataInit
+ ldr r2, =_sbss
+ b LoopFillZerobss
+/* Zero fill the bss segment. */
+FillZerobss:
+ movs r3, #0
+ str r3, [r2], #4
+
+LoopFillZerobss:
+ ldr r3, = _ebss
+ cmp r2, r3
+ bcc FillZerobss
+
+/* Call the clock system intitialization function.*/
+ bl SystemInit
+/* Call static constructors */
+/* bl __libc_init_array */
+/* Call the application's entry point.*/
+ bl main
+ bx lr
+.size Reset_Handler, .-Reset_Handler
+
+/**
+ * @brief This is the code that gets called when the processor receives an
+ * unexpected interrupt. This simply enters an infinite loop, preserving
+ * the system state for examination by a debugger.
+ * @param None
+ * @retval None
+*/
+ .section .text.Default_Handler,"ax",%progbits
+Default_Handler:
+Infinite_Loop:
+ b Infinite_Loop
+ .size Default_Handler, .-Default_Handler
+/******************************************************************************
+*
+* The minimal vector table for a Cortex M3. Note that the proper constructs
+* must be placed on this to ensure that it ends up at physical address
+* 0x0000.0000.
+*
+*******************************************************************************/
+ .section .isr_vector,"a",%progbits
+ .type g_pfnVectors, %object
+ .size g_pfnVectors, .-g_pfnVectors
+
+g_pfnVectors:
+ .word _estack
+ .word Reset_Handler
+ .word NMI_Handler
+ .word HardFault_Handler
+ .word MemManage_Handler
+ .word BusFault_Handler
+ .word UsageFault_Handler
+ .word 0
+ .word 0
+ .word 0
+ .word 0
+ .word SVC_Handler
+ .word DebugMon_Handler
+ .word 0
+ .word PendSV_Handler
+ .word SysTick_Handler
+
+ /* External Interrupts */
+ .word WWDG_IRQHandler /* Window WatchDog */
+ .word PVD_IRQHandler /* PVD through EXTI Line detection */
+ .word TAMP_STAMP_IRQHandler /* Tamper and TimeStamps through the EXTI line */
+ .word RTC_WKUP_IRQHandler /* RTC Wakeup through the EXTI line */
+ .word FLASH_IRQHandler /* FLASH */
+ .word RCC_IRQHandler /* RCC */
+ .word EXTI0_IRQHandler /* EXTI Line0 */
+ .word EXTI1_IRQHandler /* EXTI Line1 */
+ .word EXTI2_IRQHandler /* EXTI Line2 */
+ .word EXTI3_IRQHandler /* EXTI Line3 */
+ .word EXTI4_IRQHandler /* EXTI Line4 */
+ .word DMA1_Stream0_IRQHandler /* DMA1 Stream 0 */
+ .word DMA1_Stream1_IRQHandler /* DMA1 Stream 1 */
+ .word DMA1_Stream2_IRQHandler /* DMA1 Stream 2 */
+ .word DMA1_Stream3_IRQHandler /* DMA1 Stream 3 */
+ .word DMA1_Stream4_IRQHandler /* DMA1 Stream 4 */
+ .word DMA1_Stream5_IRQHandler /* DMA1 Stream 5 */
+ .word DMA1_Stream6_IRQHandler /* DMA1 Stream 6 */
+ .word ADC_IRQHandler /* ADC1, ADC2 and ADC3s */
+ .word CAN1_TX_IRQHandler /* CAN1 TX */
+ .word CAN1_RX0_IRQHandler /* CAN1 RX0 */
+ .word CAN1_RX1_IRQHandler /* CAN1 RX1 */
+ .word CAN1_SCE_IRQHandler /* CAN1 SCE */
+ .word EXTI9_5_IRQHandler /* External Line[9:5]s */
+ .word TIM1_BRK_TIM9_IRQHandler /* TIM1 Break and TIM9 */
+ .word TIM1_UP_TIM10_IRQHandler /* TIM1 Update and TIM10 */
+ .word TIM1_TRG_COM_TIM11_IRQHandler /* TIM1 Trigger and Commutation and TIM11 */
+ .word TIM1_CC_IRQHandler /* TIM1 Capture Compare */
+ .word TIM2_IRQHandler /* TIM2 */
+ .word TIM3_IRQHandler /* TIM3 */
+ .word TIM4_IRQHandler /* TIM4 */
+ .word I2C1_EV_IRQHandler /* I2C1 Event */
+ .word I2C1_ER_IRQHandler /* I2C1 Error */
+ .word I2C2_EV_IRQHandler /* I2C2 Event */
+ .word I2C2_ER_IRQHandler /* I2C2 Error */
+ .word SPI1_IRQHandler /* SPI1 */
+ .word SPI2_IRQHandler /* SPI2 */
+ .word USART1_IRQHandler /* USART1 */
+ .word USART2_IRQHandler /* USART2 */
+ .word USART3_IRQHandler /* USART3 */
+ .word EXTI15_10_IRQHandler /* External Line[15:10]s */
+ .word RTC_Alarm_IRQHandler /* RTC Alarm (A and B) through EXTI Line */
+ .word OTG_FS_WKUP_IRQHandler /* USB OTG FS Wakeup through EXTI line */
+ .word TIM8_BRK_TIM12_IRQHandler /* TIM8 Break and TIM12 */
+ .word TIM8_UP_TIM13_IRQHandler /* TIM8 Update and TIM13 */
+ .word TIM8_TRG_COM_TIM14_IRQHandler /* TIM8 Trigger and Commutation and TIM14 */
+ .word TIM8_CC_IRQHandler /* TIM8 Capture Compare */
+ .word DMA1_Stream7_IRQHandler /* DMA1 Stream7 */
+ .word 0 /* Reserved */
+ .word SDIO_IRQHandler /* SDIO */
+ .word TIM5_IRQHandler /* TIM5 */
+ .word SPI3_IRQHandler /* SPI3 */
+ .word 0 /* Reserved */
+ .word 0 /* Reserved */
+ .word TIM6_IRQHandler /* TIM6 */
+ .word TIM7_IRQHandler /* TIM7 */
+ .word DMA2_Stream0_IRQHandler /* DMA2 Stream 0 */
+ .word DMA2_Stream1_IRQHandler /* DMA2 Stream 1 */
+ .word DMA2_Stream2_IRQHandler /* DMA2 Stream 2 */
+ .word DMA2_Stream3_IRQHandler /* DMA2 Stream 3 */
+ .word DMA2_Stream4_IRQHandler /* DMA2 Stream 4 */
+ .word DFSDM1_FLT0_IRQHandler /* DFSDM1 Filter0 */
+ .word DFSDM1_FLT1_IRQHandler /* DFSDM1 Filter1 */
+ .word CAN2_TX_IRQHandler /* CAN2 TX */
+ .word CAN2_RX0_IRQHandler /* CAN2 RX0 */
+ .word CAN2_RX1_IRQHandler /* CAN2 RX1 */
+ .word CAN2_SCE_IRQHandler /* CAN2 SCE */
+ .word OTG_FS_IRQHandler /* USB OTG FS */
+ .word DMA2_Stream5_IRQHandler /* DMA2 Stream 5 */
+ .word DMA2_Stream6_IRQHandler /* DMA2 Stream 6 */
+ .word DMA2_Stream7_IRQHandler /* DMA2 Stream 7 */
+ .word USART6_IRQHandler /* USART6 */
+ .word I2C3_EV_IRQHandler /* I2C3 event */
+ .word I2C3_ER_IRQHandler /* I2C3 error */
+ .word 0 /* Reserved */
+ .word 0 /* Reserved */
+ .word 0 /* Reserved */
+ .word 0 /* Reserved */
+ .word 0 /* Reserved */
+ .word 0 /* Reserved */
+ .word RNG_IRQHandler /* RNG */
+ .word FPU_IRQHandler /* FPU */
+ .word 0 /* Reserved */
+ .word 0 /* Reserved */
+ .word SPI4_IRQHandler /* SPI4 */
+ .word SPI5_IRQHandler /* SPI5 */
+ .word 0 /* Reserved */
+ .word 0 /* Reserved */
+ .word 0 /* Reserved */
+ .word 0 /* Reserved */
+ .word 0 /* Reserved */
+ .word 0 /* Reserved */
+ .word QUADSPI_IRQHandler /* QuadSPI */
+ .word 0 /* Reserved */
+ .word 0 /* Reserved */
+ .word FMPI2C1_EV_IRQHandler /* FMPI2C1 Event */
+ .word FMPI2C1_ER_IRQHandler /* FMPI2C1 Error */
+
+/*******************************************************************************
+*
+* Provide weak aliases for each Exception handler to the Default_Handler.
+* As they are weak aliases, any function with the same name will override
+* this definition.
+*
+*******************************************************************************/
+ .weak NMI_Handler
+ .thumb_set NMI_Handler,Default_Handler
+
+ .weak HardFault_Handler
+ .thumb_set HardFault_Handler,Default_Handler
+
+ .weak MemManage_Handler
+ .thumb_set MemManage_Handler,Default_Handler
+
+ .weak BusFault_Handler
+ .thumb_set BusFault_Handler,Default_Handler
+
+ .weak UsageFault_Handler
+ .thumb_set UsageFault_Handler,Default_Handler
+
+ .weak SVC_Handler
+ .thumb_set SVC_Handler,Default_Handler
+
+ .weak DebugMon_Handler
+ .thumb_set DebugMon_Handler,Default_Handler
+
+ .weak PendSV_Handler
+ .thumb_set PendSV_Handler,Default_Handler
+
+ .weak SysTick_Handler
+ .thumb_set SysTick_Handler,Default_Handler
+
+ .weak WWDG_IRQHandler
+ .thumb_set WWDG_IRQHandler,Default_Handler
+
+ .weak PVD_IRQHandler
+ .thumb_set PVD_IRQHandler,Default_Handler
+
+ .weak TAMP_STAMP_IRQHandler
+ .thumb_set TAMP_STAMP_IRQHandler,Default_Handler
+
+ .weak RTC_WKUP_IRQHandler
+ .thumb_set RTC_WKUP_IRQHandler,Default_Handler
+
+ .weak FLASH_IRQHandler
+ .thumb_set FLASH_IRQHandler,Default_Handler
+
+ .weak RCC_IRQHandler
+ .thumb_set RCC_IRQHandler,Default_Handler
+
+ .weak EXTI0_IRQHandler
+ .thumb_set EXTI0_IRQHandler,Default_Handler
+
+ .weak EXTI1_IRQHandler
+ .thumb_set EXTI1_IRQHandler,Default_Handler
+
+ .weak EXTI2_IRQHandler
+ .thumb_set EXTI2_IRQHandler,Default_Handler
+
+ .weak EXTI3_IRQHandler
+ .thumb_set EXTI3_IRQHandler,Default_Handler
+
+ .weak EXTI4_IRQHandler
+ .thumb_set EXTI4_IRQHandler,Default_Handler
+
+ .weak DMA1_Stream0_IRQHandler
+ .thumb_set DMA1_Stream0_IRQHandler,Default_Handler
+
+ .weak DMA1_Stream1_IRQHandler
+ .thumb_set DMA1_Stream1_IRQHandler,Default_Handler
+
+ .weak DMA1_Stream2_IRQHandler
+ .thumb_set DMA1_Stream2_IRQHandler,Default_Handler
+
+ .weak DMA1_Stream3_IRQHandler
+ .thumb_set DMA1_Stream3_IRQHandler,Default_Handler
+
+ .weak DMA1_Stream4_IRQHandler
+ .thumb_set DMA1_Stream4_IRQHandler,Default_Handler
+
+ .weak DMA1_Stream5_IRQHandler
+ .thumb_set DMA1_Stream5_IRQHandler,Default_Handler
+
+ .weak DMA1_Stream6_IRQHandler
+ .thumb_set DMA1_Stream6_IRQHandler,Default_Handler
+
+ .weak ADC_IRQHandler
+ .thumb_set ADC_IRQHandler,Default_Handler
+
+ .weak CAN1_TX_IRQHandler
+ .thumb_set CAN1_TX_IRQHandler,Default_Handler
+
+ .weak CAN1_RX0_IRQHandler
+ .thumb_set CAN1_RX0_IRQHandler,Default_Handler
+
+ .weak CAN1_RX1_IRQHandler
+ .thumb_set CAN1_RX1_IRQHandler,Default_Handler
+
+ .weak CAN1_SCE_IRQHandler
+ .thumb_set CAN1_SCE_IRQHandler,Default_Handler
+
+ .weak EXTI9_5_IRQHandler
+ .thumb_set EXTI9_5_IRQHandler,Default_Handler
+
+ .weak TIM1_BRK_TIM9_IRQHandler
+ .thumb_set TIM1_BRK_TIM9_IRQHandler,Default_Handler
+
+ .weak TIM1_UP_TIM10_IRQHandler
+ .thumb_set TIM1_UP_TIM10_IRQHandler,Default_Handler
+
+ .weak TIM1_TRG_COM_TIM11_IRQHandler
+ .thumb_set TIM1_TRG_COM_TIM11_IRQHandler,Default_Handler
+
+ .weak TIM1_CC_IRQHandler
+ .thumb_set TIM1_CC_IRQHandler,Default_Handler
+
+ .weak TIM2_IRQHandler
+ .thumb_set TIM2_IRQHandler,Default_Handler
+
+ .weak TIM3_IRQHandler
+ .thumb_set TIM3_IRQHandler,Default_Handler
+
+ .weak TIM4_IRQHandler
+ .thumb_set TIM4_IRQHandler,Default_Handler
+
+ .weak I2C1_EV_IRQHandler
+ .thumb_set I2C1_EV_IRQHandler,Default_Handler
+
+ .weak I2C1_ER_IRQHandler
+ .thumb_set I2C1_ER_IRQHandler,Default_Handler
+
+ .weak I2C2_EV_IRQHandler
+ .thumb_set I2C2_EV_IRQHandler,Default_Handler
+
+ .weak I2C2_ER_IRQHandler
+ .thumb_set I2C2_ER_IRQHandler,Default_Handler
+
+ .weak SPI1_IRQHandler
+ .thumb_set SPI1_IRQHandler,Default_Handler
+
+ .weak SPI2_IRQHandler
+ .thumb_set SPI2_IRQHandler,Default_Handler
+
+ .weak USART1_IRQHandler
+ .thumb_set USART1_IRQHandler,Default_Handler
+
+ .weak USART2_IRQHandler
+ .thumb_set USART2_IRQHandler,Default_Handler
+
+ .weak USART3_IRQHandler
+ .thumb_set USART3_IRQHandler,Default_Handler
+
+ .weak EXTI15_10_IRQHandler
+ .thumb_set EXTI15_10_IRQHandler,Default_Handler
+
+ .weak RTC_Alarm_IRQHandler
+ .thumb_set RTC_Alarm_IRQHandler,Default_Handler
+
+ .weak OTG_FS_WKUP_IRQHandler
+ .thumb_set OTG_FS_WKUP_IRQHandler,Default_Handler
+
+ .weak TIM8_BRK_TIM12_IRQHandler
+ .thumb_set TIM8_BRK_TIM12_IRQHandler,Default_Handler
+
+ .weak TIM8_UP_TIM13_IRQHandler
+ .thumb_set TIM8_UP_TIM13_IRQHandler,Default_Handler
+
+ .weak TIM8_TRG_COM_TIM14_IRQHandler
+ .thumb_set TIM8_TRG_COM_TIM14_IRQHandler,Default_Handler
+
+ .weak TIM8_CC_IRQHandler
+ .thumb_set TIM8_CC_IRQHandler,Default_Handler
+
+ .weak DMA1_Stream7_IRQHandler
+ .thumb_set DMA1_Stream7_IRQHandler,Default_Handler
+
+ .weak SDIO_IRQHandler
+ .thumb_set SDIO_IRQHandler,Default_Handler
+
+ .weak TIM5_IRQHandler
+ .thumb_set TIM5_IRQHandler,Default_Handler
+
+ .weak SPI3_IRQHandler
+ .thumb_set SPI3_IRQHandler,Default_Handler
+
+ .weak TIM6_IRQHandler
+ .thumb_set TIM6_IRQHandler,Default_Handler
+
+ .weak TIM7_IRQHandler
+ .thumb_set TIM7_IRQHandler,Default_Handler
+
+ .weak DMA2_Stream0_IRQHandler
+ .thumb_set DMA2_Stream0_IRQHandler,Default_Handler
+
+ .weak DMA2_Stream1_IRQHandler
+ .thumb_set DMA2_Stream1_IRQHandler,Default_Handler
+
+ .weak DMA2_Stream2_IRQHandler
+ .thumb_set DMA2_Stream2_IRQHandler,Default_Handler
+
+ .weak DMA2_Stream3_IRQHandler
+ .thumb_set DMA2_Stream3_IRQHandler,Default_Handler
+
+ .weak DMA2_Stream4_IRQHandler
+ .thumb_set DMA2_Stream4_IRQHandler,Default_Handler
+
+ .weak DFSDM1_FLT0_IRQHandler
+ .thumb_set DFSDM1_FLT0_IRQHandler,Default_Handler
+
+ .weak DFSDM1_FLT1_IRQHandler
+ .thumb_set DFSDM1_FLT1_IRQHandler,Default_Handler
+
+ .weak CAN2_TX_IRQHandler
+ .thumb_set CAN2_TX_IRQHandler,Default_Handler
+
+ .weak CAN2_RX0_IRQHandler
+ .thumb_set CAN2_RX0_IRQHandler,Default_Handler
+
+ .weak CAN2_RX1_IRQHandler
+ .thumb_set CAN2_RX1_IRQHandler,Default_Handler
+
+ .weak CAN2_SCE_IRQHandler
+ .thumb_set CAN2_SCE_IRQHandler,Default_Handler
+
+ .weak OTG_FS_IRQHandler
+ .thumb_set OTG_FS_IRQHandler,Default_Handler
+
+ .weak DMA2_Stream5_IRQHandler
+ .thumb_set DMA2_Stream5_IRQHandler,Default_Handler
+
+ .weak DMA2_Stream6_IRQHandler
+ .thumb_set DMA2_Stream6_IRQHandler,Default_Handler
+
+ .weak DMA2_Stream7_IRQHandler
+ .thumb_set DMA2_Stream7_IRQHandler,Default_Handler
+
+ .weak USART6_IRQHandler
+ .thumb_set USART6_IRQHandler,Default_Handler
+
+ .weak I2C3_EV_IRQHandler
+ .thumb_set I2C3_EV_IRQHandler,Default_Handler
+
+ .weak I2C3_ER_IRQHandler
+ .thumb_set I2C3_ER_IRQHandler,Default_Handler
+
+ .weak RNG_IRQHandler
+ .thumb_set RNG_IRQHandler,Default_Handler
+
+ .weak FPU_IRQHandler
+ .thumb_set FPU_IRQHandler,Default_Handler
+
+ .weak SPI4_IRQHandler
+ .thumb_set SPI4_IRQHandler,Default_Handler
+
+ .weak SPI5_IRQHandler
+ .thumb_set SPI5_IRQHandler,Default_Handler
+
+ .weak QUADSPI_IRQHandler
+ .thumb_set QUADSPI_IRQHandler,Default_Handler
+
+ .weak FMPI2C1_EV_IRQHandler
+ .thumb_set FMPI2C1_EV_IRQHandler,Default_Handler
+
+ .weak FMPI2C1_ER_IRQHandler
+ .thumb_set FMPI2C1_ER_IRQHandler,Default_Handler
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/ports/stm32f4/boards/stm32f411.ld b/ports/stm32f4/boards/stm32f411.ld
new file mode 100644
index 000000000..f0d4804f9
--- /dev/null
+++ b/ports/stm32f4/boards/stm32f411.ld
@@ -0,0 +1,189 @@
+/*
+******************************************************************************
+**
+
+** File : LinkerScript.ld
+**
+** Author : Auto-generated by Ac6 System Workbench
+**
+** Abstract : Linker script for STM32F411RETx series
+** 512Kbytes FLASH and 128Kbytes RAM
+**
+** Set heap size, stack size and stack location according
+** to application requirements.
+**
+** Set memory bank area and size if external memory is used.
+**
+** Target : STMicroelectronics STM32
+**
+** Distribution: The file is distributed “as is,” without any warranty
+** of any kind.
+**
+*****************************************************************************
+** @attention
+**
+** <h2><center>&copy; COPYRIGHT(c) 2014 Ac6</center></h2>
+**
+** 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 Ac6 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.
+**
+*****************************************************************************
+*/
+
+/* Entry Point */
+ENTRY(Reset_Handler)
+
+/* Highest address of the user mode stack */
+_estack = 0x20020000; /* end of RAM */
+/* Generate a link error if heap and stack don't fit into RAM */
+_Min_Heap_Size = 0x200; /* required amount of heap */
+_Min_Stack_Size = 0x400; /* required amount of stack */
+
+/* Specify the memory areas */
+MEMORY
+{
+RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
+FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 512K
+}
+
+/* Define output sections */
+SECTIONS
+{
+ /* The startup code goes first into FLASH */
+ .isr_vector :
+ {
+ . = ALIGN(4);
+ KEEP(*(.isr_vector)) /* Startup code */
+ . = ALIGN(4);
+ } >FLASH
+
+ /* The program code and other data goes into FLASH */
+ .text :
+ {
+ . = ALIGN(4);
+ *(.text) /* .text sections (code) */
+ *(.text*) /* .text* sections (code) */
+ *(.glue_7) /* glue arm to thumb code */
+ *(.glue_7t) /* glue thumb to arm code */
+ *(.eh_frame)
+
+ KEEP (*(.init))
+ KEEP (*(.fini))
+
+ . = ALIGN(4);
+ _etext = .; /* define a global symbols at end of code */
+ } >FLASH
+
+ /* Constant data goes into FLASH */
+ .rodata :
+ {
+ . = ALIGN(4);
+ *(.rodata) /* .rodata sections (constants, strings, etc.) */
+ *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
+ . = ALIGN(4);
+ } >FLASH
+
+ .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
+ .ARM : {
+ __exidx_start = .;
+ *(.ARM.exidx*)
+ __exidx_end = .;
+ } >FLASH
+
+ .preinit_array :
+ {
+ PROVIDE_HIDDEN (__preinit_array_start = .);
+ KEEP (*(.preinit_array*))
+ PROVIDE_HIDDEN (__preinit_array_end = .);
+ } >FLASH
+ .init_array :
+ {
+ PROVIDE_HIDDEN (__init_array_start = .);
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array*))
+ PROVIDE_HIDDEN (__init_array_end = .);
+ } >FLASH
+ .fini_array :
+ {
+ PROVIDE_HIDDEN (__fini_array_start = .);
+ KEEP (*(SORT(.fini_array.*)))
+ KEEP (*(.fini_array*))
+ PROVIDE_HIDDEN (__fini_array_end = .);
+ } >FLASH
+
+ /* used by the startup to initialize data */
+ _sidata = LOADADDR(.data);
+
+ /* Initialized data sections goes into RAM, load LMA copy after code */
+ .data :
+ {
+ . = ALIGN(4);
+ _sdata = .; /* create a global symbol at data start */
+ *(.data) /* .data sections */
+ *(.data*) /* .data* sections */
+
+ . = ALIGN(4);
+ _edata = .; /* define a global symbol at data end */
+ } >RAM AT> FLASH
+
+
+ /* Uninitialized data section */
+ . = ALIGN(4);
+ .bss :
+ {
+ /* This is used by the startup in order to initialize the .bss secion */
+ _sbss = .; /* define a global symbol at bss start */
+ __bss_start__ = _sbss;
+ *(.bss)
+ *(.bss*)
+ *(COMMON)
+
+ . = ALIGN(4);
+ _ebss = .; /* define a global symbol at bss end */
+ __bss_end__ = _ebss;
+ } >RAM
+
+ /* User_heap_stack section, used to check that there is enough RAM left */
+ ._user_heap_stack :
+ {
+ . = ALIGN(8);
+ PROVIDE ( end = . );
+ PROVIDE ( _end = . );
+ . = . + _Min_Heap_Size;
+ . = . + _Min_Stack_Size;
+ . = ALIGN(8);
+ } >RAM
+
+
+
+ /* Remove information from the standard libraries */
+ /DISCARD/ :
+ {
+ libc.a ( * )
+ libm.a ( * )
+ libgcc.a ( * )
+ }
+
+ .ARM.attributes 0 : { *(.ARM.attributes) }
+}
+
+
diff --git a/supervisor/shared/usb/usb_desc.h b/ports/stm32f4/boards/stm32f411re_discovery/board.c
index 250147aa6..4421970ee 100644
--- a/supervisor/shared/usb/usb_desc.h
+++ b/ports/stm32f4/boards/stm32f411re_discovery/board.c
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2018 hathach for Adafruit Industries
+ * 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
@@ -24,20 +24,15 @@
* THE SOFTWARE.
*/
-#ifndef USB_DESC_H_
-#define USB_DESC_H_
+#include "boards/board.h"
-#include "lib/tinyusb/src/tusb.h"
+void board_init(void) {
+}
-#ifdef __cplusplus
- extern "C" {
-#endif
+bool board_requests_safe_mode(void) {
+ return false;
+}
-// Descriptors set used by tinyusb stack
-extern tud_desc_set_t tud_desc_set;
+void reset_board(void) {
-#ifdef __cplusplus
- }
-#endif
-
-#endif /* USB_DESC_H_ */
+}
diff --git a/ports/stm32f4/boards/stm32f411re_discovery/mpconfigboard.h b/ports/stm32f4/boards/stm32f411re_discovery/mpconfigboard.h
new file mode 100644
index 000000000..675443282
--- /dev/null
+++ b/ports/stm32f4/boards/stm32f411re_discovery/mpconfigboard.h
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ */
+
+//Micropython setup
+
+#define MICROPY_HW_BOARD_NAME "STM32F411E_DISCO"
+#define MICROPY_HW_MCU_NAME "STM32F411xE"
+
+#define FLASH_SIZE (0x7D000)
+#define FLASH_PAGE_SIZE (0x4000)
+
+#define CIRCUITPY_INTERNAL_NVM_SIZE (4096)
+#define AUTORESET_DELAY_MS 500
+#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE) \ No newline at end of file
diff --git a/ports/stm32f4/boards/stm32f411re_discovery/mpconfigboard.mk b/ports/stm32f4/boards/stm32f411re_discovery/mpconfigboard.mk
new file mode 100644
index 000000000..7b865b57e
--- /dev/null
+++ b/ports/stm32f4/boards/stm32f411re_discovery/mpconfigboard.mk
@@ -0,0 +1,13 @@
+USB_VID = 0x239A
+USB_PID = 0x802A
+USB_PRODUCT = "STM32F411RE Discovery Board - CPy"
+USB_MANUFACTURER = "Adafruit Industries LLC"
+
+MCU_SERIES = m4
+MCU_VARIANT = stm32f4
+MCU_SUB_VARIANT = stm32f411xe
+CMSIS_MCU = STM32F411xE
+LD_FILE = boards/STM32F411VETx_FLASH.ld
+TEXT0_ADDR = 0x08000000
+TEXT1_ADDR = 0x08020000
+
diff --git a/ports/stm32f4/boards/stm32f411re_discovery/pins.c b/ports/stm32f4/boards/stm32f411re_discovery/pins.c
new file mode 100644
index 000000000..e3a4b5ed6
--- /dev/null
+++ b/ports/stm32f4/boards/stm32f411re_discovery/pins.c
@@ -0,0 +1,90 @@
+#include "shared-bindings/board/__init__.h"
+
+STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
+ { MP_ROM_QSTR(MP_QSTR_PE02), MP_ROM_PTR(&pin_PE02) },
+ { MP_ROM_QSTR(MP_QSTR_PE03), MP_ROM_PTR(&pin_PE03) },
+ { MP_ROM_QSTR(MP_QSTR_PE04), MP_ROM_PTR(&pin_PE04) },
+ { MP_ROM_QSTR(MP_QSTR_PE05), MP_ROM_PTR(&pin_PE05) },
+ { MP_ROM_QSTR(MP_QSTR_PE06), MP_ROM_PTR(&pin_PE06) },
+ { MP_ROM_QSTR(MP_QSTR_PC13), MP_ROM_PTR(&pin_PC13) },
+ { MP_ROM_QSTR(MP_QSTR_PF02), MP_ROM_PTR(&pin_PF02) },
+ { MP_ROM_QSTR(MP_QSTR_PF03), MP_ROM_PTR(&pin_PF03) },
+ { MP_ROM_QSTR(MP_QSTR_PF10), MP_ROM_PTR(&pin_PF10) },
+ { MP_ROM_QSTR(MP_QSTR_PC00), MP_ROM_PTR(&pin_PC00) },
+ { MP_ROM_QSTR(MP_QSTR_PC01), MP_ROM_PTR(&pin_PC01) },
+ { MP_ROM_QSTR(MP_QSTR_PC02), MP_ROM_PTR(&pin_PC02) },
+ { MP_ROM_QSTR(MP_QSTR_PC03), MP_ROM_PTR(&pin_PC03) },
+ { MP_ROM_QSTR(MP_QSTR_PA01), MP_ROM_PTR(&pin_PA01) },
+ { MP_ROM_QSTR(MP_QSTR_PA02), MP_ROM_PTR(&pin_PA02) },
+ { MP_ROM_QSTR(MP_QSTR_PA03), MP_ROM_PTR(&pin_PA03) },
+ { MP_ROM_QSTR(MP_QSTR_PA04), MP_ROM_PTR(&pin_PA04) },
+ { MP_ROM_QSTR(MP_QSTR_PA05), MP_ROM_PTR(&pin_PA05) },
+ { MP_ROM_QSTR(MP_QSTR_PA06), MP_ROM_PTR(&pin_PA06) },
+ { MP_ROM_QSTR(MP_QSTR_PA07), MP_ROM_PTR(&pin_PA07) },
+ { MP_ROM_QSTR(MP_QSTR_PC04), MP_ROM_PTR(&pin_PC04) },
+ { MP_ROM_QSTR(MP_QSTR_PC05), MP_ROM_PTR(&pin_PC05) },
+ { MP_ROM_QSTR(MP_QSTR_PB00), MP_ROM_PTR(&pin_PB00) },
+ { MP_ROM_QSTR(MP_QSTR_PB01), MP_ROM_PTR(&pin_PB01) },
+ { MP_ROM_QSTR(MP_QSTR_PF11), MP_ROM_PTR(&pin_PF11) },
+ { MP_ROM_QSTR(MP_QSTR_PF13), MP_ROM_PTR(&pin_PF13) },
+ { MP_ROM_QSTR(MP_QSTR_PB10), MP_ROM_PTR(&pin_PB10) },
+ { MP_ROM_QSTR(MP_QSTR_PB11), MP_ROM_PTR(&pin_PB11) },
+ { MP_ROM_QSTR(MP_QSTR_PB12), MP_ROM_PTR(&pin_PB12) },
+ { MP_ROM_QSTR(MP_QSTR_PB13), MP_ROM_PTR(&pin_PB13) },
+ { MP_ROM_QSTR(MP_QSTR_PB14), MP_ROM_PTR(&pin_PB14) },
+ { MP_ROM_QSTR(MP_QSTR_PB15), MP_ROM_PTR(&pin_PB15) },
+ { MP_ROM_QSTR(MP_QSTR_PD12), MP_ROM_PTR(&pin_PD12) },
+ { MP_ROM_QSTR(MP_QSTR_PD13), MP_ROM_PTR(&pin_PD13) },
+ { MP_ROM_QSTR(MP_QSTR_PG02), MP_ROM_PTR(&pin_PG02) },
+ { MP_ROM_QSTR(MP_QSTR_PC06), MP_ROM_PTR(&pin_PC06) },
+ { MP_ROM_QSTR(MP_QSTR_PC07), MP_ROM_PTR(&pin_PC07) },
+ { MP_ROM_QSTR(MP_QSTR_PC09), MP_ROM_PTR(&pin_PC09) },
+ { MP_ROM_QSTR(MP_QSTR_PA08), MP_ROM_PTR(&pin_PA08) },
+ { MP_ROM_QSTR(MP_QSTR_PA10), MP_ROM_PTR(&pin_PA10) },
+ { MP_ROM_QSTR(MP_QSTR_PA13), MP_ROM_PTR(&pin_PA13) },
+ { MP_ROM_QSTR(MP_QSTR_PA14), MP_ROM_PTR(&pin_PA14) },
+ { MP_ROM_QSTR(MP_QSTR_PA15), MP_ROM_PTR(&pin_PA15) },
+ { MP_ROM_QSTR(MP_QSTR_PD06), MP_ROM_PTR(&pin_PD06) },
+ { MP_ROM_QSTR(MP_QSTR_PG09), MP_ROM_PTR(&pin_PG09) },
+ { MP_ROM_QSTR(MP_QSTR_PG10), MP_ROM_PTR(&pin_PG10) },
+ { MP_ROM_QSTR(MP_QSTR_PG11), MP_ROM_PTR(&pin_PG11) },
+ { MP_ROM_QSTR(MP_QSTR_PG12), MP_ROM_PTR(&pin_PG12) },
+ { MP_ROM_QSTR(MP_QSTR_PG13), MP_ROM_PTR(&pin_PG13) },
+ { MP_ROM_QSTR(MP_QSTR_PG14), MP_ROM_PTR(&pin_PG14) },
+ { MP_ROM_QSTR(MP_QSTR_PB03), MP_ROM_PTR(&pin_PB03) },
+ { MP_ROM_QSTR(MP_QSTR_PB04), MP_ROM_PTR(&pin_PB04) },
+ { MP_ROM_QSTR(MP_QSTR_PB05), MP_ROM_PTR(&pin_PB05) },
+ { MP_ROM_QSTR(MP_QSTR_PB06), MP_ROM_PTR(&pin_PB06) },
+ { MP_ROM_QSTR(MP_QSTR_PB07), MP_ROM_PTR(&pin_PB07) },
+ { MP_ROM_QSTR(MP_QSTR_PB08), MP_ROM_PTR(&pin_PB08) },
+ { MP_ROM_QSTR(MP_QSTR_PB09), MP_ROM_PTR(&pin_PB09) },
+ { MP_ROM_QSTR(MP_QSTR_PE00), MP_ROM_PTR(&pin_PE00) },
+ { MP_ROM_QSTR(MP_QSTR_PE01), MP_ROM_PTR(&pin_PE01) },
+ { MP_ROM_QSTR(MP_QSTR_D15), MP_ROM_PTR(&pin_PB10) },
+ { MP_ROM_QSTR(MP_QSTR_D14), MP_ROM_PTR(&pin_PB09) },
+ { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_PA05) },
+ { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_PA06) },
+ { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_PA07) },
+ { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PA15) },
+ { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_PB08) },
+ { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_PG10) },
+ { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_PG11) },
+ { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PF03) },
+ { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_PF10) },
+ { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_PG12) },
+ { MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_PF04) },
+ { MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_PG13) },
+ { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_PG14) },
+ { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_PG09) },
+ { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA01) },
+ { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PC01) },
+ { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PC03) },
+ { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PC04) },
+ { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PC05) }, //alt PB09, see F401ZG-DISCO manual
+ { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_PB00) }, //alt PB10, see F401ZG-DISCO manual
+ { MP_ROM_QSTR(MP_QSTR_LED1), MP_ROM_PTR(&pin_PE00) },
+ { MP_ROM_QSTR(MP_QSTR_LED2), MP_ROM_PTR(&pin_PE01) },
+ { MP_ROM_QSTR(MP_QSTR_LED3), MP_ROM_PTR(&pin_PE02) },
+ { MP_ROM_QSTR(MP_QSTR_LED4), MP_ROM_PTR(&pin_PE03) },
+};
+MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);
diff --git a/ports/stm32f4/boards/stm32f411re_discovery/stm32f4xx_hal_conf.h b/ports/stm32f4/boards/stm32f411re_discovery/stm32f4xx_hal_conf.h
new file mode 100644
index 000000000..548c501dc
--- /dev/null
+++ b/ports/stm32f4/boards/stm32f411re_discovery/stm32f4xx_hal_conf.h
@@ -0,0 +1,439 @@
+/**
+ ******************************************************************************
+ * @file stm32f4xx_hal_conf_template.h
+ * @author MCD Application Team
+ * @brief HAL configuration template file.
+ * This file should be copied to the application folder and renamed
+ * to stm32f4xx_hal_conf.h.
+ ******************************************************************************
+ * @attention
+ *
+ * <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
+ * All rights reserved.</center></h2>
+ *
+ * This software component is licensed by ST under BSD 3-Clause license,
+ * the "License"; You may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at:
+ * opensource.org/licenses/BSD-3-Clause
+ *
+ ******************************************************************************
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM32F4xx_HAL_CONF_H
+#define __STM32F4xx_HAL_CONF_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/* Exported types ------------------------------------------------------------*/
+/* Exported constants --------------------------------------------------------*/
+
+/* ########################## Module Selection ############################## */
+/**
+ * @brief This is the list of modules to be used in the HAL driver
+ */
+#define HAL_MODULE_ENABLED
+
+ /* #define HAL_ADC_MODULE_ENABLED */
+/* #define HAL_CRYP_MODULE_ENABLED */
+/* #define HAL_CAN_MODULE_ENABLED */
+/* #define HAL_CRC_MODULE_ENABLED */
+/* #define HAL_CRYP_MODULE_ENABLED */
+/* #define HAL_DAC_MODULE_ENABLED */
+/* #define HAL_DCMI_MODULE_ENABLED */
+/* #define HAL_DMA2D_MODULE_ENABLED */
+/* #define HAL_ETH_MODULE_ENABLED */
+/* #define HAL_NAND_MODULE_ENABLED */
+/* #define HAL_NOR_MODULE_ENABLED */
+/* #define HAL_PCCARD_MODULE_ENABLED */
+/* #define HAL_SRAM_MODULE_ENABLED */
+/* #define HAL_SDRAM_MODULE_ENABLED */
+/* #define HAL_HASH_MODULE_ENABLED */
+#define HAL_I2C_MODULE_ENABLED
+#define HAL_I2S_MODULE_ENABLED
+/* #define HAL_IWDG_MODULE_ENABLED */
+/* #define HAL_LTDC_MODULE_ENABLED */
+/* #define HAL_RNG_MODULE_ENABLED */
+/* #define HAL_RTC_MODULE_ENABLED */
+/* #define HAL_SAI_MODULE_ENABLED */
+/* #define HAL_SD_MODULE_ENABLED */
+/* #define HAL_MMC_MODULE_ENABLED */
+#define HAL_SPI_MODULE_ENABLED
+/* #define HAL_TIM_MODULE_ENABLED */
+#define HAL_UART_MODULE_ENABLED
+/* #define HAL_USART_MODULE_ENABLED */
+/* #define HAL_IRDA_MODULE_ENABLED */
+/* #define HAL_SMARTCARD_MODULE_ENABLED */
+/* #define HAL_WWDG_MODULE_ENABLED */
+#define HAL_PCD_MODULE_ENABLED
+/* #define HAL_HCD_MODULE_ENABLED */
+/* #define HAL_DSI_MODULE_ENABLED */
+/* #define HAL_QSPI_MODULE_ENABLED */
+/* #define HAL_QSPI_MODULE_ENABLED */
+/* #define HAL_CEC_MODULE_ENABLED */
+/* #define HAL_FMPI2C_MODULE_ENABLED */
+/* #define HAL_SPDIFRX_MODULE_ENABLED */
+/* #define HAL_DFSDM_MODULE_ENABLED */
+/* #define HAL_LPTIM_MODULE_ENABLED */
+/* #define HAL_EXTI_MODULE_ENABLED */
+#define HAL_GPIO_MODULE_ENABLED
+#define HAL_EXTI_MODULE_ENABLED
+#define HAL_DMA_MODULE_ENABLED
+#define HAL_RCC_MODULE_ENABLED
+#define HAL_FLASH_MODULE_ENABLED
+#define HAL_PWR_MODULE_ENABLED
+#define HAL_CORTEX_MODULE_ENABLED
+
+/* ########################## HSE/HSI Values adaptation ##################### */
+/**
+ * @brief Adjust the value of External High Speed oscillator (HSE) used in your application.
+ * This value is used by the RCC HAL module to compute the system frequency
+ * (when HSE is used as system clock source, directly or through the PLL).
+ */
+#if !defined (HSE_VALUE)
+ #define HSE_VALUE ((uint32_t)8000000U) /*!< Value of the External oscillator in Hz */
+#endif /* HSE_VALUE */
+
+#if !defined (HSE_STARTUP_TIMEOUT)
+ #define HSE_STARTUP_TIMEOUT ((uint32_t)100U) /*!< Time out for HSE start up, in ms */
+#endif /* HSE_STARTUP_TIMEOUT */
+
+/**
+ * @brief Internal High Speed oscillator (HSI) value.
+ * This value is used by the RCC HAL module to compute the system frequency
+ * (when HSI is used as system clock source, directly or through the PLL).
+ */
+#if !defined (HSI_VALUE)
+ #define HSI_VALUE ((uint32_t)16000000U) /*!< Value of the Internal oscillator in Hz*/
+#endif /* HSI_VALUE */
+
+/**
+ * @brief Internal Low Speed oscillator (LSI) value.
+ */
+#if !defined (LSI_VALUE)
+ #define LSI_VALUE ((uint32_t)32000U) /*!< LSI Typical Value in Hz*/
+#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz
+ The real value may vary depending on the variations
+ in voltage and temperature.*/
+/**
+ * @brief External Low Speed oscillator (LSE) value.
+ */
+#if !defined (LSE_VALUE)
+ #define LSE_VALUE ((uint32_t)32768U) /*!< Value of the External Low Speed oscillator in Hz */
+#endif /* LSE_VALUE */
+
+#if !defined (LSE_STARTUP_TIMEOUT)
+ #define LSE_STARTUP_TIMEOUT ((uint32_t)5000U) /*!< Time out for LSE start up, in ms */
+#endif /* LSE_STARTUP_TIMEOUT */
+
+/**
+ * @brief External clock source for I2S peripheral
+ * This value is used by the I2S HAL module to compute the I2S clock source
+ * frequency, this source is inserted directly through I2S_CKIN pad.
+ */
+#if !defined (EXTERNAL_CLOCK_VALUE)
+ #define EXTERNAL_CLOCK_VALUE ((uint32_t)12288000U) /*!< Value of the External audio frequency in Hz*/
+#endif /* EXTERNAL_CLOCK_VALUE */
+
+/* Tip: To avoid modifying this file each time you need to use different HSE,
+ === you can define the HSE value in your toolchain compiler preprocessor. */
+
+/* ########################### System Configuration ######################### */
+/**
+ * @brief This is the HAL system configuration section
+ */
+#define VDD_VALUE ((uint32_t)3300U) /*!< Value of VDD in mv */
+#define TICK_INT_PRIORITY ((uint32_t)0U) /*!< tick interrupt priority */
+#define USE_RTOS 0U
+#define PREFETCH_ENABLE 1U
+#define INSTRUCTION_CACHE_ENABLE 1U
+#define DATA_CACHE_ENABLE 1U
+
+/* ########################## Assert Selection ############################## */
+/**
+ * @brief Uncomment the line below to expanse the "assert_param" macro in the
+ * HAL drivers code
+ */
+/* #define USE_FULL_ASSERT 1U */
+
+/* ################## Ethernet peripheral configuration ##################### */
+
+/* Section 1 : Ethernet peripheral configuration */
+
+/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */
+#define MAC_ADDR0 2U
+#define MAC_ADDR1 0U
+#define MAC_ADDR2 0U
+#define MAC_ADDR3 0U
+#define MAC_ADDR4 0U
+#define MAC_ADDR5 0U
+
+/* Definition of the Ethernet driver buffers size and count */
+#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */
+#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */
+#define ETH_RXBUFNB ((uint32_t)4U) /* 4 Rx buffers of size ETH_RX_BUF_SIZE */
+#define ETH_TXBUFNB ((uint32_t)4U) /* 4 Tx buffers of size ETH_TX_BUF_SIZE */
+
+/* Section 2: PHY configuration section */
+
+/* DP83848_PHY_ADDRESS Address*/
+#define DP83848_PHY_ADDRESS 0x01U
+/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/
+#define PHY_RESET_DELAY ((uint32_t)0x000000FFU)
+/* PHY Configuration delay */
+#define PHY_CONFIG_DELAY ((uint32_t)0x00000FFFU)
+
+#define PHY_READ_TO ((uint32_t)0x0000FFFFU)
+#define PHY_WRITE_TO ((uint32_t)0x0000FFFFU)
+
+/* Section 3: Common PHY Registers */
+
+#define PHY_BCR ((uint16_t)0x0000U) /*!< Transceiver Basic Control Register */
+#define PHY_BSR ((uint16_t)0x0001U) /*!< Transceiver Basic Status Register */
+
+#define PHY_RESET ((uint16_t)0x8000U) /*!< PHY Reset */
+#define PHY_LOOPBACK ((uint16_t)0x4000U) /*!< Select loop-back mode */
+#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100U) /*!< Set the full-duplex mode at 100 Mb/s */
+#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000U) /*!< Set the half-duplex mode at 100 Mb/s */
+#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100U) /*!< Set the full-duplex mode at 10 Mb/s */
+#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000U) /*!< Set the half-duplex mode at 10 Mb/s */
+#define PHY_AUTONEGOTIATION ((uint16_t)0x1000U) /*!< Enable auto-negotiation function */
+#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200U) /*!< Restart auto-negotiation function */
+#define PHY_POWERDOWN ((uint16_t)0x0800U) /*!< Select the power down mode */
+#define PHY_ISOLATE ((uint16_t)0x0400U) /*!< Isolate PHY from MII */
+
+#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020U) /*!< Auto-Negotiation process completed */
+#define PHY_LINKED_STATUS ((uint16_t)0x0004U) /*!< Valid link established */
+#define PHY_JABBER_DETECTION ((uint16_t)0x0002U) /*!< Jabber condition detected */
+
+/* Section 4: Extended PHY Registers */
+#define PHY_SR ((uint16_t)0x10U) /*!< PHY status register Offset */
+
+#define PHY_SPEED_STATUS ((uint16_t)0x0002U) /*!< PHY Speed mask */
+#define PHY_DUPLEX_STATUS ((uint16_t)0x0004U) /*!< PHY Duplex mask */
+
+/* ################## SPI peripheral configuration ########################## */
+
+/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver
+* Activated: CRC code is present inside driver
+* Deactivated: CRC code cleaned from driver
+*/
+
+#define USE_SPI_CRC 0U
+
+/* Includes ------------------------------------------------------------------*/
+/**
+ * @brief Include module's header file
+ */
+
+#ifdef HAL_RCC_MODULE_ENABLED
+ #include "stm32f4xx_hal_rcc.h"
+#endif /* HAL_RCC_MODULE_ENABLED */
+
+#ifdef HAL_EXTI_MODULE_ENABLED
+ #include "stm32f4xx_hal_exti.h"
+#endif /* HAL_EXTI_MODULE_ENABLED */
+
+#ifdef HAL_GPIO_MODULE_ENABLED
+ #include "stm32f4xx_hal_gpio.h"
+#endif /* HAL_GPIO_MODULE_ENABLED */
+
+#ifdef HAL_DMA_MODULE_ENABLED
+ #include "stm32f4xx_hal_dma.h"
+#endif /* HAL_DMA_MODULE_ENABLED */
+
+#ifdef HAL_CORTEX_MODULE_ENABLED
+ #include "stm32f4xx_hal_cortex.h"
+#endif /* HAL_CORTEX_MODULE_ENABLED */
+
+#ifdef HAL_ADC_MODULE_ENABLED
+ #include "stm32f4xx_hal_adc.h"
+#endif /* HAL_ADC_MODULE_ENABLED */
+
+#ifdef HAL_CAN_MODULE_ENABLED
+ #include "stm32f4xx_hal_can.h"
+#endif /* HAL_CAN_MODULE_ENABLED */
+
+#ifdef HAL_CRC_MODULE_ENABLED
+ #include "stm32f4xx_hal_crc.h"
+#endif /* HAL_CRC_MODULE_ENABLED */
+
+#ifdef HAL_CRYP_MODULE_ENABLED
+ #include "stm32f4xx_hal_cryp.h"
+#endif /* HAL_CRYP_MODULE_ENABLED */
+
+#ifdef HAL_DMA2D_MODULE_ENABLED
+ #include "stm32f4xx_hal_dma2d.h"
+#endif /* HAL_DMA2D_MODULE_ENABLED */
+
+#ifdef HAL_DAC_MODULE_ENABLED
+ #include "stm32f4xx_hal_dac.h"
+#endif /* HAL_DAC_MODULE_ENABLED */
+
+#ifdef HAL_DCMI_MODULE_ENABLED
+ #include "stm32f4xx_hal_dcmi.h"
+#endif /* HAL_DCMI_MODULE_ENABLED */
+
+#ifdef HAL_ETH_MODULE_ENABLED
+ #include "stm32f4xx_hal_eth.h"
+#endif /* HAL_ETH_MODULE_ENABLED */
+
+#ifdef HAL_FLASH_MODULE_ENABLED
+ #include "stm32f4xx_hal_flash.h"
+#endif /* HAL_FLASH_MODULE_ENABLED */
+
+#ifdef HAL_SRAM_MODULE_ENABLED
+ #include "stm32f4xx_hal_sram.h"
+#endif /* HAL_SRAM_MODULE_ENABLED */
+
+#ifdef HAL_NOR_MODULE_ENABLED
+ #include "stm32f4xx_hal_nor.h"
+#endif /* HAL_NOR_MODULE_ENABLED */
+
+#ifdef HAL_NAND_MODULE_ENABLED
+ #include "stm32f4xx_hal_nand.h"
+#endif /* HAL_NAND_MODULE_ENABLED */
+
+#ifdef HAL_PCCARD_MODULE_ENABLED
+ #include "stm32f4xx_hal_pccard.h"
+#endif /* HAL_PCCARD_MODULE_ENABLED */
+
+#ifdef HAL_SDRAM_MODULE_ENABLED
+ #include "stm32f4xx_hal_sdram.h"
+#endif /* HAL_SDRAM_MODULE_ENABLED */
+
+#ifdef HAL_HASH_MODULE_ENABLED
+ #include "stm32f4xx_hal_hash.h"
+#endif /* HAL_HASH_MODULE_ENABLED */
+
+#ifdef HAL_I2C_MODULE_ENABLED
+ #include "stm32f4xx_hal_i2c.h"
+#endif /* HAL_I2C_MODULE_ENABLED */
+
+#ifdef HAL_I2S_MODULE_ENABLED
+ #include "stm32f4xx_hal_i2s.h"
+#endif /* HAL_I2S_MODULE_ENABLED */
+
+#ifdef HAL_IWDG_MODULE_ENABLED
+ #include "stm32f4xx_hal_iwdg.h"
+#endif /* HAL_IWDG_MODULE_ENABLED */
+
+#ifdef HAL_LTDC_MODULE_ENABLED
+ #include "stm32f4xx_hal_ltdc.h"
+#endif /* HAL_LTDC_MODULE_ENABLED */
+
+#ifdef HAL_PWR_MODULE_ENABLED
+ #include "stm32f4xx_hal_pwr.h"
+#endif /* HAL_PWR_MODULE_ENABLED */
+
+#ifdef HAL_RNG_MODULE_ENABLED
+ #include "stm32f4xx_hal_rng.h"
+#endif /* HAL_RNG_MODULE_ENABLED */
+
+#ifdef HAL_RTC_MODULE_ENABLED
+ #include "stm32f4xx_hal_rtc.h"
+#endif /* HAL_RTC_MODULE_ENABLED */
+
+#ifdef HAL_SAI_MODULE_ENABLED
+ #include "stm32f4xx_hal_sai.h"
+#endif /* HAL_SAI_MODULE_ENABLED */
+
+#ifdef HAL_SD_MODULE_ENABLED
+ #include "stm32f4xx_hal_sd.h"
+#endif /* HAL_SD_MODULE_ENABLED */
+
+#ifdef HAL_MMC_MODULE_ENABLED
+ #include "stm32f4xx_hal_mmc.h"
+#endif /* HAL_MMC_MODULE_ENABLED */
+
+#ifdef HAL_SPI_MODULE_ENABLED
+ #include "stm32f4xx_hal_spi.h"
+#endif /* HAL_SPI_MODULE_ENABLED */
+
+#ifdef HAL_TIM_MODULE_ENABLED
+ #include "stm32f4xx_hal_tim.h"
+#endif /* HAL_TIM_MODULE_ENABLED */
+
+#ifdef HAL_UART_MODULE_ENABLED
+ #include "stm32f4xx_hal_uart.h"
+#endif /* HAL_UART_MODULE_ENABLED */
+
+#ifdef HAL_USART_MODULE_ENABLED
+ #include "stm32f4xx_hal_usart.h"
+#endif /* HAL_USART_MODULE_ENABLED */
+
+#ifdef HAL_IRDA_MODULE_ENABLED
+ #include "stm32f4xx_hal_irda.h"
+#endif /* HAL_IRDA_MODULE_ENABLED */
+
+#ifdef HAL_SMARTCARD_MODULE_ENABLED
+ #include "stm32f4xx_hal_smartcard.h"
+#endif /* HAL_SMARTCARD_MODULE_ENABLED */
+
+#ifdef HAL_WWDG_MODULE_ENABLED
+ #include "stm32f4xx_hal_wwdg.h"
+#endif /* HAL_WWDG_MODULE_ENABLED */
+
+#ifdef HAL_PCD_MODULE_ENABLED
+ #include "stm32f4xx_hal_pcd.h"
+#endif /* HAL_PCD_MODULE_ENABLED */
+
+#ifdef HAL_HCD_MODULE_ENABLED
+ #include "stm32f4xx_hal_hcd.h"
+#endif /* HAL_HCD_MODULE_ENABLED */
+
+#ifdef HAL_DSI_MODULE_ENABLED
+ #include "stm32f4xx_hal_dsi.h"
+#endif /* HAL_DSI_MODULE_ENABLED */
+
+#ifdef HAL_QSPI_MODULE_ENABLED
+ #include "stm32f4xx_hal_qspi.h"
+#endif /* HAL_QSPI_MODULE_ENABLED */
+
+#ifdef HAL_CEC_MODULE_ENABLED
+ #include "stm32f4xx_hal_cec.h"
+#endif /* HAL_CEC_MODULE_ENABLED */
+
+#ifdef HAL_FMPI2C_MODULE_ENABLED
+ #include "stm32f4xx_hal_fmpi2c.h"
+#endif /* HAL_FMPI2C_MODULE_ENABLED */
+
+#ifdef HAL_SPDIFRX_MODULE_ENABLED
+ #include "stm32f4xx_hal_spdifrx.h"
+#endif /* HAL_SPDIFRX_MODULE_ENABLED */
+
+#ifdef HAL_DFSDM_MODULE_ENABLED
+ #include "stm32f4xx_hal_dfsdm.h"
+#endif /* HAL_DFSDM_MODULE_ENABLED */
+
+#ifdef HAL_LPTIM_MODULE_ENABLED
+ #include "stm32f4xx_hal_lptim.h"
+#endif /* HAL_LPTIM_MODULE_ENABLED */
+
+/* Exported macro ------------------------------------------------------------*/
+#ifdef USE_FULL_ASSERT
+/**
+ * @brief The assert_param macro is used for function's parameters check.
+ * @param expr: If expr is false, it calls assert_failed function
+ * which reports the name of the source file and the source
+ * line number of the call that failed.
+ * If expr is true, it returns no value.
+ * @retval None
+ */
+ #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__))
+/* Exported functions ------------------------------------------------------- */
+ void assert_failed(uint8_t* file, uint32_t line);
+#else
+ #define assert_param(expr) ((void)0U)
+#endif /* USE_FULL_ASSERT */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __STM32F4xx_HAL_CONF_H */
+
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/ports/stm32f4/boards/stm32f411re_discovery/stm32f4xx_hal_msp.c b/ports/stm32f4/boards/stm32f411re_discovery/stm32f4xx_hal_msp.c
new file mode 100644
index 000000000..4989f9889
--- /dev/null
+++ b/ports/stm32f4/boards/stm32f411re_discovery/stm32f4xx_hal_msp.c
@@ -0,0 +1,427 @@
+/* USER CODE BEGIN Header */
+/**
+ ******************************************************************************
+ * File Name : stm32f4xx_hal_msp.c
+ * Description : This file provides code for the MSP Initialization
+ * and de-Initialization codes.
+ ******************************************************************************
+ * @attention
+ *
+ * <h2><center>&copy; Copyright (c) 2019 STMicroelectronics.
+ * All rights reserved.</center></h2>
+ *
+ * This software component is licensed by ST under Ultimate Liberty license
+ * SLA0044, the "License"; You may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at:
+ * www.st.com/SLA0044
+ *
+ ******************************************************************************
+ */
+/* USER CODE END Header */
+
+/* Includes ------------------------------------------------------------------*/
+/* USER CODE BEGIN Includes */
+#include "stm32f4xx_hal.h"
+/* USER CODE END Includes */
+
+/* Private typedef -----------------------------------------------------------*/
+/* USER CODE BEGIN TD */
+
+/* USER CODE END TD */
+
+/* Private define ------------------------------------------------------------*/
+/* USER CODE BEGIN Define */
+#define DATA_Ready_Pin GPIO_PIN_2
+#define DATA_Ready_GPIO_Port GPIOE
+#define CS_I2C_SPI_Pin GPIO_PIN_3
+#define CS_I2C_SPI_GPIO_Port GPIOE
+#define INT1_Pin GPIO_PIN_4
+#define INT1_GPIO_Port GPIOE
+#define INT2_Pin GPIO_PIN_5
+#define INT2_GPIO_Port GPIOE
+#define PC14_OSC32_IN_Pin GPIO_PIN_14
+#define PC14_OSC32_IN_GPIO_Port GPIOC
+#define PC15_OSC32_OUT_Pin GPIO_PIN_15
+#define PC15_OSC32_OUT_GPIO_Port GPIOC
+#define PH0_OSC_IN_Pin GPIO_PIN_0
+#define PH0_OSC_IN_GPIO_Port GPIOH
+#define PH1_OSC_OUT_Pin GPIO_PIN_1
+#define PH1_OSC_OUT_GPIO_Port GPIOH
+#define OTG_FS_PowerSwitchOn_Pin GPIO_PIN_0
+#define OTG_FS_PowerSwitchOn_GPIO_Port GPIOC
+#define PDM_OUT_Pin GPIO_PIN_3
+#define PDM_OUT_GPIO_Port GPIOC
+#define I2S3_WS_Pin GPIO_PIN_4
+#define I2S3_WS_GPIO_Port GPIOA
+#define SPI1_SCK_Pin GPIO_PIN_5
+#define SPI1_SCK_GPIO_Port GPIOA
+#define SPI1_MISO_Pin GPIO_PIN_6
+#define SPI1_MISO_GPIO_Port GPIOA
+#define SPI1_MOSI_Pin GPIO_PIN_7
+#define SPI1_MOSI_GPIO_Port GPIOA
+#define CLK_IN_Pin GPIO_PIN_10
+#define CLK_IN_GPIO_Port GPIOB
+#define LD4_Pin GPIO_PIN_12
+#define LD4_GPIO_Port GPIOD
+#define LD3_Pin GPIO_PIN_13
+#define LD3_GPIO_Port GPIOD
+#define LD5_Pin GPIO_PIN_14
+#define LD5_GPIO_Port GPIOD
+#define LD6_Pin GPIO_PIN_15
+#define LD6_GPIO_Port GPIOD
+#define I2S3_MCK_Pin GPIO_PIN_7
+#define I2S3_MCK_GPIO_Port GPIOC
+#define VBUS_FS_Pin GPIO_PIN_9
+#define VBUS_FS_GPIO_Port GPIOA
+#define OTG_FS_ID_Pin GPIO_PIN_10
+#define OTG_FS_ID_GPIO_Port GPIOA
+#define OTG_FS_DM_Pin GPIO_PIN_11
+#define OTG_FS_DM_GPIO_Port GPIOA
+#define OTG_FS_DP_Pin GPIO_PIN_12
+#define OTG_FS_DP_GPIO_Port GPIOA
+#define SWDIO_Pin GPIO_PIN_13
+#define SWDIO_GPIO_Port GPIOA
+#define SWCLK_Pin GPIO_PIN_14
+#define SWCLK_GPIO_Port GPIOA
+#define I2S3_SCK_Pin GPIO_PIN_10
+#define I2S3_SCK_GPIO_Port GPIOC
+#define I2S3_SD_Pin GPIO_PIN_12
+#define I2S3_SD_GPIO_Port GPIOC
+#define Audio_RST_Pin GPIO_PIN_4
+#define Audio_RST_GPIO_Port GPIOD
+#define OTG_FS_OverCurrent_Pin GPIO_PIN_5
+#define OTG_FS_OverCurrent_GPIO_Port GPIOD
+#define SWO_Pin GPIO_PIN_3
+#define SWO_GPIO_Port GPIOB
+#define Audio_SCL_Pin GPIO_PIN_6
+#define Audio_SCL_GPIO_Port GPIOB
+#define Audio_SDA_Pin GPIO_PIN_9
+#define Audio_SDA_GPIO_Port GPIOB
+#define MEMS_INT2_Pin GPIO_PIN_1
+#define MEMS_INT2_GPIO_Port GPIOE
+
+/* USER CODE END Define */
+
+/* Private macro -------------------------------------------------------------*/
+/* USER CODE BEGIN Macro */
+
+/* USER CODE END Macro */
+
+/* Private variables ---------------------------------------------------------*/
+/* USER CODE BEGIN PV */
+
+/* USER CODE END PV */
+
+/* Private function prototypes -----------------------------------------------*/
+/* USER CODE BEGIN PFP */
+
+/* USER CODE END PFP */
+
+/* External functions --------------------------------------------------------*/
+/* USER CODE BEGIN ExternalFunctions */
+
+/* USER CODE END ExternalFunctions */
+
+/* USER CODE BEGIN 0 */
+
+/* USER CODE END 0 */
+/**
+ * Initializes the Global MSP.
+ */
+void HAL_MspInit(void)
+{
+ /* USER CODE BEGIN MspInit 0 */
+
+ /* USER CODE END MspInit 0 */
+
+ __HAL_RCC_SYSCFG_CLK_ENABLE();
+ __HAL_RCC_PWR_CLK_ENABLE();
+
+ HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_0);
+
+ /* System interrupt init*/
+
+ /* USER CODE BEGIN MspInit 1 */
+
+ /* USER CODE END MspInit 1 */
+}
+
+/**
+* @brief I2C MSP Initialization
+* This function configures the hardware resources used in this example
+* @param hi2c: I2C handle pointer
+* @retval None
+*/
+void HAL_I2C_MspInit(I2C_HandleTypeDef* hi2c)
+{
+ GPIO_InitTypeDef GPIO_InitStruct = {0};
+ if(hi2c->Instance==I2C1)
+ {
+ /* USER CODE BEGIN I2C1_MspInit 0 */
+
+ /* USER CODE END I2C1_MspInit 0 */
+
+ __HAL_RCC_GPIOB_CLK_ENABLE();
+ /**I2C1 GPIO Configuration
+ PB6 ------> I2C1_SCL
+ PB9 ------> I2C1_SDA
+ */
+ GPIO_InitStruct.Pin = Audio_SCL_Pin|Audio_SDA_Pin;
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
+ GPIO_InitStruct.Pull = GPIO_PULLUP;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
+ GPIO_InitStruct.Alternate = GPIO_AF4_I2C1;
+ HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
+
+ /* Peripheral clock enable */
+ __HAL_RCC_I2C1_CLK_ENABLE();
+ /* USER CODE BEGIN I2C1_MspInit 1 */
+
+ /* USER CODE END I2C1_MspInit 1 */
+ }
+
+}
+
+/**
+* @brief I2C MSP De-Initialization
+* This function freeze the hardware resources used in this example
+* @param hi2c: I2C handle pointer
+* @retval None
+*/
+void HAL_I2C_MspDeInit(I2C_HandleTypeDef* hi2c)
+{
+ if(hi2c->Instance==I2C1)
+ {
+ /* USER CODE BEGIN I2C1_MspDeInit 0 */
+
+ /* USER CODE END I2C1_MspDeInit 0 */
+ /* Peripheral clock disable */
+ __HAL_RCC_I2C1_CLK_DISABLE();
+
+ /**I2C1 GPIO Configuration
+ PB6 ------> I2C1_SCL
+ PB9 ------> I2C1_SDA
+ */
+ HAL_GPIO_DeInit(GPIOB, Audio_SCL_Pin|Audio_SDA_Pin);
+
+ /* USER CODE BEGIN I2C1_MspDeInit 1 */
+
+ /* USER CODE END I2C1_MspDeInit 1 */
+ }
+
+}
+
+/**
+* @brief I2S MSP Initialization
+* This function configures the hardware resources used in this example
+* @param hi2s: I2S handle pointer
+* @retval None
+*/
+void HAL_I2S_MspInit(I2S_HandleTypeDef* hi2s)
+{
+ GPIO_InitTypeDef GPIO_InitStruct = {0};
+ if(hi2s->Instance==SPI2)
+ {
+ /* USER CODE BEGIN SPI2_MspInit 0 */
+
+ /* USER CODE END SPI2_MspInit 0 */
+ /* Peripheral clock enable */
+ __HAL_RCC_SPI2_CLK_ENABLE();
+
+ __HAL_RCC_GPIOC_CLK_ENABLE();
+ __HAL_RCC_GPIOB_CLK_ENABLE();
+ /**I2S2 GPIO Configuration
+ PC2 ------> I2S2_ext_SD
+ PC3 ------> I2S2_SD
+ PB10 ------> I2S2_CK
+ PB12 ------> I2S2_WS
+ */
+ GPIO_InitStruct.Pin = GPIO_PIN_2;
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
+ GPIO_InitStruct.Alternate = GPIO_AF6_I2S2ext;
+ HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
+
+ GPIO_InitStruct.Pin = PDM_OUT_Pin;
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
+ GPIO_InitStruct.Alternate = GPIO_AF5_SPI2;
+ HAL_GPIO_Init(PDM_OUT_GPIO_Port, &GPIO_InitStruct);
+
+ GPIO_InitStruct.Pin = CLK_IN_Pin|GPIO_PIN_12;
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
+ GPIO_InitStruct.Alternate = GPIO_AF5_SPI2;
+ HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
+
+ /* USER CODE BEGIN SPI2_MspInit 1 */
+
+ /* USER CODE END SPI2_MspInit 1 */
+ }
+ else if(hi2s->Instance==SPI3)
+ {
+ /* USER CODE BEGIN SPI3_MspInit 0 */
+
+ /* USER CODE END SPI3_MspInit 0 */
+ /* Peripheral clock enable */
+ __HAL_RCC_SPI3_CLK_ENABLE();
+
+ __HAL_RCC_GPIOA_CLK_ENABLE();
+ __HAL_RCC_GPIOC_CLK_ENABLE();
+ /**I2S3 GPIO Configuration
+ PA4 ------> I2S3_WS
+ PC7 ------> I2S3_MCK
+ PC10 ------> I2S3_CK
+ PC12 ------> I2S3_SD
+ */
+ GPIO_InitStruct.Pin = I2S3_WS_Pin;
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
+ GPIO_InitStruct.Alternate = GPIO_AF6_SPI3;
+ HAL_GPIO_Init(I2S3_WS_GPIO_Port, &GPIO_InitStruct);
+
+ GPIO_InitStruct.Pin = I2S3_MCK_Pin|I2S3_SCK_Pin|I2S3_SD_Pin;
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
+ GPIO_InitStruct.Alternate = GPIO_AF6_SPI3;
+ HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
+
+ /* USER CODE BEGIN SPI3_MspInit 1 */
+
+ /* USER CODE END SPI3_MspInit 1 */
+ }
+
+}
+
+/**
+* @brief I2S MSP De-Initialization
+* This function freeze the hardware resources used in this example
+* @param hi2s: I2S handle pointer
+* @retval None
+*/
+void HAL_I2S_MspDeInit(I2S_HandleTypeDef* hi2s)
+{
+ if(hi2s->Instance==SPI2)
+ {
+ /* USER CODE BEGIN SPI2_MspDeInit 0 */
+
+ /* USER CODE END SPI2_MspDeInit 0 */
+ /* Peripheral clock disable */
+ __HAL_RCC_SPI2_CLK_DISABLE();
+
+ /**I2S2 GPIO Configuration
+ PC2 ------> I2S2_ext_SD
+ PC3 ------> I2S2_SD
+ PB10 ------> I2S2_CK
+ PB12 ------> I2S2_WS
+ */
+ HAL_GPIO_DeInit(GPIOC, GPIO_PIN_2|PDM_OUT_Pin);
+
+ HAL_GPIO_DeInit(GPIOB, CLK_IN_Pin|GPIO_PIN_12);
+
+ /* USER CODE BEGIN SPI2_MspDeInit 1 */
+
+ /* USER CODE END SPI2_MspDeInit 1 */
+ }
+ else if(hi2s->Instance==SPI3)
+ {
+ /* USER CODE BEGIN SPI3_MspDeInit 0 */
+
+ /* USER CODE END SPI3_MspDeInit 0 */
+ /* Peripheral clock disable */
+ __HAL_RCC_SPI3_CLK_DISABLE();
+
+ /**I2S3 GPIO Configuration
+ PA4 ------> I2S3_WS
+ PC7 ------> I2S3_MCK
+ PC10 ------> I2S3_CK
+ PC12 ------> I2S3_SD
+ */
+ HAL_GPIO_DeInit(I2S3_WS_GPIO_Port, I2S3_WS_Pin);
+
+ HAL_GPIO_DeInit(GPIOC, I2S3_MCK_Pin|I2S3_SCK_Pin|I2S3_SD_Pin);
+
+ /* USER CODE BEGIN SPI3_MspDeInit 1 */
+
+ /* USER CODE END SPI3_MspDeInit 1 */
+ }
+
+}
+
+/**
+* @brief SPI MSP Initialization
+* This function configures the hardware resources used in this example
+* @param hspi: SPI handle pointer
+* @retval None
+*/
+void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi)
+{
+ GPIO_InitTypeDef GPIO_InitStruct = {0};
+ if(hspi->Instance==SPI1)
+ {
+ /* USER CODE BEGIN SPI1_MspInit 0 */
+
+ /* USER CODE END SPI1_MspInit 0 */
+ /* Peripheral clock enable */
+ __HAL_RCC_SPI1_CLK_ENABLE();
+
+ __HAL_RCC_GPIOA_CLK_ENABLE();
+ /**SPI1 GPIO Configuration
+ PA5 ------> SPI1_SCK
+ PA6 ------> SPI1_MISO
+ PA7 ------> SPI1_MOSI
+ */
+ GPIO_InitStruct.Pin = SPI1_SCK_Pin|SPI1_MISO_Pin|SPI1_MOSI_Pin;
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
+ GPIO_InitStruct.Alternate = GPIO_AF5_SPI1;
+ HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
+
+ /* USER CODE BEGIN SPI1_MspInit 1 */
+
+ /* USER CODE END SPI1_MspInit 1 */
+ }
+
+}
+
+/**
+* @brief SPI MSP De-Initialization
+* This function freeze the hardware resources used in this example
+* @param hspi: SPI handle pointer
+* @retval None
+*/
+void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi)
+{
+ if(hspi->Instance==SPI1)
+ {
+ /* USER CODE BEGIN SPI1_MspDeInit 0 */
+
+ /* USER CODE END SPI1_MspDeInit 0 */
+ /* Peripheral clock disable */
+ __HAL_RCC_SPI1_CLK_DISABLE();
+
+ /**SPI1 GPIO Configuration
+ PA5 ------> SPI1_SCK
+ PA6 ------> SPI1_MISO
+ PA7 ------> SPI1_MOSI
+ */
+ HAL_GPIO_DeInit(GPIOA, SPI1_SCK_Pin|SPI1_MISO_Pin|SPI1_MOSI_Pin);
+
+ /* USER CODE BEGIN SPI1_MspDeInit 1 */
+
+ /* USER CODE END SPI1_MspDeInit 1 */
+ }
+
+}
+
+/* USER CODE BEGIN 1 */
+
+/* USER CODE END 1 */
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/ports/stm32f4/boards/stm32f412zg_discovery/board.c b/ports/stm32f4/boards/stm32f412zg_discovery/board.c
new file mode 100644
index 000000000..4421970ee
--- /dev/null
+++ b/ports/stm32f4/boards/stm32f412zg_discovery/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/stm32f4/boards/stm32f412zg_discovery/mpconfigboard.h b/ports/stm32f4/boards/stm32f412zg_discovery/mpconfigboard.h
new file mode 100644
index 000000000..416944257
--- /dev/null
+++ b/ports/stm32f4/boards/stm32f412zg_discovery/mpconfigboard.h
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ */
+
+//Micropython setup
+
+#define MICROPY_HW_BOARD_NAME "STM32F412G_DISCO"
+#define MICROPY_HW_MCU_NAME "STM32F412xGS"
+
+#define FLASH_SIZE (0x100000)
+#define FLASH_PAGE_SIZE (0x4000)
+
+#define CIRCUITPY_INTERNAL_NVM_SIZE (4096)
+#define AUTORESET_DELAY_MS 500
+#define BOARD_FLASH_SIZE (FLASH_SIZE - 0x4000 - CIRCUITPY_INTERNAL_NVM_SIZE) \ No newline at end of file
diff --git a/ports/stm32f4/boards/stm32f412zg_discovery/mpconfigboard.mk b/ports/stm32f4/boards/stm32f412zg_discovery/mpconfigboard.mk
new file mode 100644
index 000000000..444795874
--- /dev/null
+++ b/ports/stm32f4/boards/stm32f412zg_discovery/mpconfigboard.mk
@@ -0,0 +1,13 @@
+USB_VID = 0x483
+USB_PID = 0x572B
+USB_PRODUCT = "STM32F412ZG Discovery Board - CPy"
+USB_MANUFACTURER = "STMicroelectronics"
+
+MCU_SERIES = m4
+MCU_VARIANT = stm32f4
+MCU_SUB_VARIANT = stm32f412zx
+CMSIS_MCU = STM32F412xG
+LD_FILE = boards/STM32F412ZGTx_FLASH.ld
+TEXT0_ADDR = 0x08000000
+TEXT1_ADDR = 0x08020000
+
diff --git a/ports/stm32f4/boards/stm32f412zg_discovery/pins.c b/ports/stm32f4/boards/stm32f412zg_discovery/pins.c
new file mode 100644
index 000000000..e3a4b5ed6
--- /dev/null
+++ b/ports/stm32f4/boards/stm32f412zg_discovery/pins.c
@@ -0,0 +1,90 @@
+#include "shared-bindings/board/__init__.h"
+
+STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
+ { MP_ROM_QSTR(MP_QSTR_PE02), MP_ROM_PTR(&pin_PE02) },
+ { MP_ROM_QSTR(MP_QSTR_PE03), MP_ROM_PTR(&pin_PE03) },
+ { MP_ROM_QSTR(MP_QSTR_PE04), MP_ROM_PTR(&pin_PE04) },
+ { MP_ROM_QSTR(MP_QSTR_PE05), MP_ROM_PTR(&pin_PE05) },
+ { MP_ROM_QSTR(MP_QSTR_PE06), MP_ROM_PTR(&pin_PE06) },
+ { MP_ROM_QSTR(MP_QSTR_PC13), MP_ROM_PTR(&pin_PC13) },
+ { MP_ROM_QSTR(MP_QSTR_PF02), MP_ROM_PTR(&pin_PF02) },
+ { MP_ROM_QSTR(MP_QSTR_PF03), MP_ROM_PTR(&pin_PF03) },
+ { MP_ROM_QSTR(MP_QSTR_PF10), MP_ROM_PTR(&pin_PF10) },
+ { MP_ROM_QSTR(MP_QSTR_PC00), MP_ROM_PTR(&pin_PC00) },
+ { MP_ROM_QSTR(MP_QSTR_PC01), MP_ROM_PTR(&pin_PC01) },
+ { MP_ROM_QSTR(MP_QSTR_PC02), MP_ROM_PTR(&pin_PC02) },
+ { MP_ROM_QSTR(MP_QSTR_PC03), MP_ROM_PTR(&pin_PC03) },
+ { MP_ROM_QSTR(MP_QSTR_PA01), MP_ROM_PTR(&pin_PA01) },
+ { MP_ROM_QSTR(MP_QSTR_PA02), MP_ROM_PTR(&pin_PA02) },
+ { MP_ROM_QSTR(MP_QSTR_PA03), MP_ROM_PTR(&pin_PA03) },
+ { MP_ROM_QSTR(MP_QSTR_PA04), MP_ROM_PTR(&pin_PA04) },
+ { MP_ROM_QSTR(MP_QSTR_PA05), MP_ROM_PTR(&pin_PA05) },
+ { MP_ROM_QSTR(MP_QSTR_PA06), MP_ROM_PTR(&pin_PA06) },
+ { MP_ROM_QSTR(MP_QSTR_PA07), MP_ROM_PTR(&pin_PA07) },
+ { MP_ROM_QSTR(MP_QSTR_PC04), MP_ROM_PTR(&pin_PC04) },
+ { MP_ROM_QSTR(MP_QSTR_PC05), MP_ROM_PTR(&pin_PC05) },
+ { MP_ROM_QSTR(MP_QSTR_PB00), MP_ROM_PTR(&pin_PB00) },
+ { MP_ROM_QSTR(MP_QSTR_PB01), MP_ROM_PTR(&pin_PB01) },
+ { MP_ROM_QSTR(MP_QSTR_PF11), MP_ROM_PTR(&pin_PF11) },
+ { MP_ROM_QSTR(MP_QSTR_PF13), MP_ROM_PTR(&pin_PF13) },
+ { MP_ROM_QSTR(MP_QSTR_PB10), MP_ROM_PTR(&pin_PB10) },
+ { MP_ROM_QSTR(MP_QSTR_PB11), MP_ROM_PTR(&pin_PB11) },
+ { MP_ROM_QSTR(MP_QSTR_PB12), MP_ROM_PTR(&pin_PB12) },
+ { MP_ROM_QSTR(MP_QSTR_PB13), MP_ROM_PTR(&pin_PB13) },
+ { MP_ROM_QSTR(MP_QSTR_PB14), MP_ROM_PTR(&pin_PB14) },
+ { MP_ROM_QSTR(MP_QSTR_PB15), MP_ROM_PTR(&pin_PB15) },
+ { MP_ROM_QSTR(MP_QSTR_PD12), MP_ROM_PTR(&pin_PD12) },
+ { MP_ROM_QSTR(MP_QSTR_PD13), MP_ROM_PTR(&pin_PD13) },
+ { MP_ROM_QSTR(MP_QSTR_PG02), MP_ROM_PTR(&pin_PG02) },
+ { MP_ROM_QSTR(MP_QSTR_PC06), MP_ROM_PTR(&pin_PC06) },
+ { MP_ROM_QSTR(MP_QSTR_PC07), MP_ROM_PTR(&pin_PC07) },
+ { MP_ROM_QSTR(MP_QSTR_PC09), MP_ROM_PTR(&pin_PC09) },
+ { MP_ROM_QSTR(MP_QSTR_PA08), MP_ROM_PTR(&pin_PA08) },
+ { MP_ROM_QSTR(MP_QSTR_PA10), MP_ROM_PTR(&pin_PA10) },
+ { MP_ROM_QSTR(MP_QSTR_PA13), MP_ROM_PTR(&pin_PA13) },
+ { MP_ROM_QSTR(MP_QSTR_PA14), MP_ROM_PTR(&pin_PA14) },
+ { MP_ROM_QSTR(MP_QSTR_PA15), MP_ROM_PTR(&pin_PA15) },
+ { MP_ROM_QSTR(MP_QSTR_PD06), MP_ROM_PTR(&pin_PD06) },
+ { MP_ROM_QSTR(MP_QSTR_PG09), MP_ROM_PTR(&pin_PG09) },
+ { MP_ROM_QSTR(MP_QSTR_PG10), MP_ROM_PTR(&pin_PG10) },
+ { MP_ROM_QSTR(MP_QSTR_PG11), MP_ROM_PTR(&pin_PG11) },
+ { MP_ROM_QSTR(MP_QSTR_PG12), MP_ROM_PTR(&pin_PG12) },
+ { MP_ROM_QSTR(MP_QSTR_PG13), MP_ROM_PTR(&pin_PG13) },
+ { MP_ROM_QSTR(MP_QSTR_PG14), MP_ROM_PTR(&pin_PG14) },
+ { MP_ROM_QSTR(MP_QSTR_PB03), MP_ROM_PTR(&pin_PB03) },
+ { MP_ROM_QSTR(MP_QSTR_PB04), MP_ROM_PTR(&pin_PB04) },
+ { MP_ROM_QSTR(MP_QSTR_PB05), MP_ROM_PTR(&pin_PB05) },
+ { MP_ROM_QSTR(MP_QSTR_PB06), MP_ROM_PTR(&pin_PB06) },
+ { MP_ROM_QSTR(MP_QSTR_PB07), MP_ROM_PTR(&pin_PB07) },
+ { MP_ROM_QSTR(MP_QSTR_PB08), MP_ROM_PTR(&pin_PB08) },
+ { MP_ROM_QSTR(MP_QSTR_PB09), MP_ROM_PTR(&pin_PB09) },
+ { MP_ROM_QSTR(MP_QSTR_PE00), MP_ROM_PTR(&pin_PE00) },
+ { MP_ROM_QSTR(MP_QSTR_PE01), MP_ROM_PTR(&pin_PE01) },
+ { MP_ROM_QSTR(MP_QSTR_D15), MP_ROM_PTR(&pin_PB10) },
+ { MP_ROM_QSTR(MP_QSTR_D14), MP_ROM_PTR(&pin_PB09) },
+ { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_PA05) },
+ { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_PA06) },
+ { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_PA07) },
+ { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PA15) },
+ { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_PB08) },
+ { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_PG10) },
+ { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_PG11) },
+ { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PF03) },
+ { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_PF10) },
+ { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_PG12) },
+ { MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_PF04) },
+ { MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_PG13) },
+ { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_PG14) },
+ { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_PG09) },
+ { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA01) },
+ { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PC01) },
+ { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PC03) },
+ { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PC04) },
+ { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PC05) }, //alt PB09, see F401ZG-DISCO manual
+ { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_PB00) }, //alt PB10, see F401ZG-DISCO manual
+ { MP_ROM_QSTR(MP_QSTR_LED1), MP_ROM_PTR(&pin_PE00) },
+ { MP_ROM_QSTR(MP_QSTR_LED2), MP_ROM_PTR(&pin_PE01) },
+ { MP_ROM_QSTR(MP_QSTR_LED3), MP_ROM_PTR(&pin_PE02) },
+ { MP_ROM_QSTR(MP_QSTR_LED4), MP_ROM_PTR(&pin_PE03) },
+};
+MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);
diff --git a/ports/stm32f4/boards/stm32f412zg_discovery/stm32f4xx_hal_conf.h b/ports/stm32f4/boards/stm32f412zg_discovery/stm32f4xx_hal_conf.h
new file mode 100644
index 000000000..5d329c14f
--- /dev/null
+++ b/ports/stm32f4/boards/stm32f412zg_discovery/stm32f4xx_hal_conf.h
@@ -0,0 +1,439 @@
+/**
+ ******************************************************************************
+ * @file stm32f4xx_hal_conf_template.h
+ * @author MCD Application Team
+ * @brief HAL configuration template file.
+ * This file should be copied to the application folder and renamed
+ * to stm32f4xx_hal_conf.h.
+ ******************************************************************************
+ * @attention
+ *
+ * <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
+ * All rights reserved.</center></h2>
+ *
+ * This software component is licensed by ST under BSD 3-Clause license,
+ * the "License"; You may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at:
+ * opensource.org/licenses/BSD-3-Clause
+ *
+ ******************************************************************************
+ */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM32F4xx_HAL_CONF_H
+#define __STM32F4xx_HAL_CONF_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/* Exported types ------------------------------------------------------------*/
+/* Exported constants --------------------------------------------------------*/
+
+/* ########################## Module Selection ############################## */
+/**
+ * @brief This is the list of modules to be used in the HAL driver
+ */
+#define HAL_MODULE_ENABLED
+
+ /* #define HAL_ADC_MODULE_ENABLED */
+/* #define HAL_CRYP_MODULE_ENABLED */
+/* #define HAL_CAN_MODULE_ENABLED */
+/* #define HAL_CRC_MODULE_ENABLED */
+/* #define HAL_CRYP_MODULE_ENABLED */
+/* #define HAL_DAC_MODULE_ENABLED */
+/* #define HAL_DCMI_MODULE_ENABLED */
+/* #define HAL_DMA2D_MODULE_ENABLED */
+/* #define HAL_ETH_MODULE_ENABLED */
+/* #define HAL_NAND_MODULE_ENABLED */
+/* #define HAL_NOR_MODULE_ENABLED */
+/* #define HAL_PCCARD_MODULE_ENABLED */
+#define HAL_SRAM_MODULE_ENABLED
+/* #define HAL_SDRAM_MODULE_ENABLED */
+/* #define HAL_HASH_MODULE_ENABLED */
+#define HAL_I2C_MODULE_ENABLED
+#define HAL_I2S_MODULE_ENABLED
+/* #define HAL_IWDG_MODULE_ENABLED */
+/* #define HAL_LTDC_MODULE_ENABLED */
+/* #define HAL_RNG_MODULE_ENABLED */
+/* #define HAL_RTC_MODULE_ENABLED */
+/* #define HAL_SAI_MODULE_ENABLED */
+#define HAL_SD_MODULE_ENABLED
+/* #define HAL_MMC_MODULE_ENABLED */
+/* #define HAL_SPI_MODULE_ENABLED */
+/* #define HAL_TIM_MODULE_ENABLED */
+#define HAL_UART_MODULE_ENABLED
+/* #define HAL_USART_MODULE_ENABLED */
+/* #define HAL_IRDA_MODULE_ENABLED */
+/* #define HAL_SMARTCARD_MODULE_ENABLED */
+/* #define HAL_WWDG_MODULE_ENABLED */
+#define HAL_PCD_MODULE_ENABLED
+/* #define HAL_HCD_MODULE_ENABLED */
+/* #define HAL_DSI_MODULE_ENABLED */
+/* #define HAL_QSPI_MODULE_ENABLED */
+#define HAL_QSPI_MODULE_ENABLED
+/* #define HAL_CEC_MODULE_ENABLED */
+/* #define HAL_FMPI2C_MODULE_ENABLED */
+/* #define HAL_SPDIFRX_MODULE_ENABLED */
+/* #define HAL_DFSDM_MODULE_ENABLED */
+/* #define HAL_LPTIM_MODULE_ENABLED */
+/* #define HAL_EXTI_MODULE_ENABLED */
+#define HAL_GPIO_MODULE_ENABLED
+#define HAL_EXTI_MODULE_ENABLED
+#define HAL_DMA_MODULE_ENABLED
+#define HAL_RCC_MODULE_ENABLED
+#define HAL_FLASH_MODULE_ENABLED
+#define HAL_PWR_MODULE_ENABLED
+#define HAL_CORTEX_MODULE_ENABLED
+
+/* ########################## HSE/HSI Values adaptation ##################### */
+/**
+ * @brief Adjust the value of External High Speed oscillator (HSE) used in your application.
+ * This value is used by the RCC HAL module to compute the system frequency
+ * (when HSE is used as system clock source, directly or through the PLL).
+ */
+#if !defined (HSE_VALUE)
+ #define HSE_VALUE ((uint32_t)8000000U) /*!< Value of the External oscillator in Hz */
+#endif /* HSE_VALUE */
+
+#if !defined (HSE_STARTUP_TIMEOUT)
+ #define HSE_STARTUP_TIMEOUT ((uint32_t)100U) /*!< Time out for HSE start up, in ms */
+#endif /* HSE_STARTUP_TIMEOUT */
+
+/**
+ * @brief Internal High Speed oscillator (HSI) value.
+ * This value is used by the RCC HAL module to compute the system frequency
+ * (when HSI is used as system clock source, directly or through the PLL).
+ */
+#if !defined (HSI_VALUE)
+ #define HSI_VALUE ((uint32_t)16000000U) /*!< Value of the Internal oscillator in Hz*/
+#endif /* HSI_VALUE */
+
+/**
+ * @brief Internal Low Speed oscillator (LSI) value.
+ */
+#if !defined (LSI_VALUE)
+ #define LSI_VALUE ((uint32_t)32000U) /*!< LSI Typical Value in Hz*/
+#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz
+ The real value may vary depending on the variations
+ in voltage and temperature.*/
+/**
+ * @brief External Low Speed oscillator (LSE) value.
+ */
+#if !defined (LSE_VALUE)
+ #define LSE_VALUE ((uint32_t)32768U) /*!< Value of the External Low Speed oscillator in Hz */
+#endif /* LSE_VALUE */
+
+#if !defined (LSE_STARTUP_TIMEOUT)
+ #define LSE_STARTUP_TIMEOUT ((uint32_t)5000U) /*!< Time out for LSE start up, in ms */
+#endif /* LSE_STARTUP_TIMEOUT */
+
+/**
+ * @brief External clock source for I2S peripheral
+ * This value is used by the I2S HAL module to compute the I2S clock source
+ * frequency, this source is inserted directly through I2S_CKIN pad.
+ */
+#if !defined (EXTERNAL_CLOCK_VALUE)
+ #define EXTERNAL_CLOCK_VALUE ((uint32_t)12288000U) /*!< Value of the External audio frequency in Hz*/
+#endif /* EXTERNAL_CLOCK_VALUE */
+
+/* Tip: To avoid modifying this file each time you need to use different HSE,
+ === you can define the HSE value in your toolchain compiler preprocessor. */
+
+/* ########################### System Configuration ######################### */
+/**
+ * @brief This is the HAL system configuration section
+ */
+#define VDD_VALUE ((uint32_t)3300U) /*!< Value of VDD in mv */
+#define TICK_INT_PRIORITY ((uint32_t)0U) /*!< tick interrupt priority */
+#define USE_RTOS 0U
+#define PREFETCH_ENABLE 1U
+#define INSTRUCTION_CACHE_ENABLE 1U
+#define DATA_CACHE_ENABLE 1U
+
+/* ########################## Assert Selection ############################## */
+/**
+ * @brief Uncomment the line below to expanse the "assert_param" macro in the
+ * HAL drivers code
+ */
+/* #define USE_FULL_ASSERT 1U */
+
+/* ################## Ethernet peripheral configuration ##################### */
+
+/* Section 1 : Ethernet peripheral configuration */
+
+/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */
+#define MAC_ADDR0 2U
+#define MAC_ADDR1 0U
+#define MAC_ADDR2 0U
+#define MAC_ADDR3 0U
+#define MAC_ADDR4 0U
+#define MAC_ADDR5 0U
+
+/* Definition of the Ethernet driver buffers size and count */
+#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */
+#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */
+#define ETH_RXBUFNB ((uint32_t)4U) /* 4 Rx buffers of size ETH_RX_BUF_SIZE */
+#define ETH_TXBUFNB ((uint32_t)4U) /* 4 Tx buffers of size ETH_TX_BUF_SIZE */
+
+/* Section 2: PHY configuration section */
+
+/* DP83848_PHY_ADDRESS Address*/
+#define DP83848_PHY_ADDRESS 0x01U
+/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/
+#define PHY_RESET_DELAY ((uint32_t)0x000000FFU)
+/* PHY Configuration delay */
+#define PHY_CONFIG_DELAY ((uint32_t)0x00000FFFU)
+
+#define PHY_READ_TO ((uint32_t)0x0000FFFFU)
+#define PHY_WRITE_TO ((uint32_t)0x0000FFFFU)
+
+/* Section 3: Common PHY Registers */
+
+#define PHY_BCR ((uint16_t)0x0000U) /*!< Transceiver Basic Control Register */
+#define PHY_BSR ((uint16_t)0x0001U) /*!< Transceiver Basic Status Register */
+
+#define PHY_RESET ((uint16_t)0x8000U) /*!< PHY Reset */
+#define PHY_LOOPBACK ((uint16_t)0x4000U) /*!< Select loop-back mode */
+#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100U) /*!< Set the full-duplex mode at 100 Mb/s */
+#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000U) /*!< Set the half-duplex mode at 100 Mb/s */
+#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100U) /*!< Set the full-duplex mode at 10 Mb/s */
+#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000U) /*!< Set the half-duplex mode at 10 Mb/s */
+#define PHY_AUTONEGOTIATION ((uint16_t)0x1000U) /*!< Enable auto-negotiation function */
+#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200U) /*!< Restart auto-negotiation function */
+#define PHY_POWERDOWN ((uint16_t)0x0800U) /*!< Select the power down mode */
+#define PHY_ISOLATE ((uint16_t)0x0400U) /*!< Isolate PHY from MII */
+
+#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020U) /*!< Auto-Negotiation process completed */
+#define PHY_LINKED_STATUS ((uint16_t)0x0004U) /*!< Valid link established */
+#define PHY_JABBER_DETECTION ((uint16_t)0x0002U) /*!< Jabber condition detected */
+
+/* Section 4: Extended PHY Registers */
+#define PHY_SR ((uint16_t)0x10U) /*!< PHY status register Offset */
+
+#define PHY_SPEED_STATUS ((uint16_t)0x0002U) /*!< PHY Speed mask */
+#define PHY_DUPLEX_STATUS ((uint16_t)0x0004U) /*!< PHY Duplex mask */
+
+/* ################## SPI peripheral configuration ########################## */
+
+/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver
+* Activated: CRC code is present inside driver
+* Deactivated: CRC code cleaned from driver
+*/
+
+#define USE_SPI_CRC 0U
+
+/* Includes ------------------------------------------------------------------*/
+/**
+ * @brief Include module's header file
+ */
+
+#ifdef HAL_RCC_MODULE_ENABLED
+ #include "stm32f4xx_hal_rcc.h"
+#endif /* HAL_RCC_MODULE_ENABLED */
+
+#ifdef HAL_EXTI_MODULE_ENABLED
+ #include "stm32f4xx_hal_exti.h"
+#endif /* HAL_EXTI_MODULE_ENABLED */
+
+#ifdef HAL_GPIO_MODULE_ENABLED
+ #include "stm32f4xx_hal_gpio.h"
+#endif /* HAL_GPIO_MODULE_ENABLED */
+
+#ifdef HAL_DMA_MODULE_ENABLED
+ #include "stm32f4xx_hal_dma.h"
+#endif /* HAL_DMA_MODULE_ENABLED */
+
+#ifdef HAL_CORTEX_MODULE_ENABLED
+ #include "stm32f4xx_hal_cortex.h"
+#endif /* HAL_CORTEX_MODULE_ENABLED */
+
+#ifdef HAL_ADC_MODULE_ENABLED
+ #include "stm32f4xx_hal_adc.h"
+#endif /* HAL_ADC_MODULE_ENABLED */
+
+#ifdef HAL_CAN_MODULE_ENABLED
+ #include "stm32f4xx_hal_can.h"
+#endif /* HAL_CAN_MODULE_ENABLED */
+
+#ifdef HAL_CRC_MODULE_ENABLED
+ #include "stm32f4xx_hal_crc.h"
+#endif /* HAL_CRC_MODULE_ENABLED */
+
+#ifdef HAL_CRYP_MODULE_ENABLED
+ #include "stm32f4xx_hal_cryp.h"
+#endif /* HAL_CRYP_MODULE_ENABLED */
+
+#ifdef HAL_DMA2D_MODULE_ENABLED
+ #include "stm32f4xx_hal_dma2d.h"
+#endif /* HAL_DMA2D_MODULE_ENABLED */
+
+#ifdef HAL_DAC_MODULE_ENABLED
+ #include "stm32f4xx_hal_dac.h"
+#endif /* HAL_DAC_MODULE_ENABLED */
+
+#ifdef HAL_DCMI_MODULE_ENABLED
+ #include "stm32f4xx_hal_dcmi.h"
+#endif /* HAL_DCMI_MODULE_ENABLED */
+
+#ifdef HAL_ETH_MODULE_ENABLED
+ #include "stm32f4xx_hal_eth.h"
+#endif /* HAL_ETH_MODULE_ENABLED */
+
+#ifdef HAL_FLASH_MODULE_ENABLED
+ #include "stm32f4xx_hal_flash.h"
+#endif /* HAL_FLASH_MODULE_ENABLED */
+
+#ifdef HAL_SRAM_MODULE_ENABLED
+ #include "stm32f4xx_hal_sram.h"
+#endif /* HAL_SRAM_MODULE_ENABLED */
+
+#ifdef HAL_NOR_MODULE_ENABLED
+ #include "stm32f4xx_hal_nor.h"
+#endif /* HAL_NOR_MODULE_ENABLED */
+
+#ifdef HAL_NAND_MODULE_ENABLED
+ #include "stm32f4xx_hal_nand.h"
+#endif /* HAL_NAND_MODULE_ENABLED */
+
+#ifdef HAL_PCCARD_MODULE_ENABLED
+ #include "stm32f4xx_hal_pccard.h"
+#endif /* HAL_PCCARD_MODULE_ENABLED */
+
+#ifdef HAL_SDRAM_MODULE_ENABLED
+ #include "stm32f4xx_hal_sdram.h"
+#endif /* HAL_SDRAM_MODULE_ENABLED */
+
+#ifdef HAL_HASH_MODULE_ENABLED
+ #include "stm32f4xx_hal_hash.h"
+#endif /* HAL_HASH_MODULE_ENABLED */
+
+#ifdef HAL_I2C_MODULE_ENABLED
+ #include "stm32f4xx_hal_i2c.h"
+#endif /* HAL_I2C_MODULE_ENABLED */
+
+#ifdef HAL_I2S_MODULE_ENABLED
+ #include "stm32f4xx_hal_i2s.h"
+#endif /* HAL_I2S_MODULE_ENABLED */
+
+#ifdef HAL_IWDG_MODULE_ENABLED
+ #include "stm32f4xx_hal_iwdg.h"
+#endif /* HAL_IWDG_MODULE_ENABLED */
+
+#ifdef HAL_LTDC_MODULE_ENABLED
+ #include "stm32f4xx_hal_ltdc.h"
+#endif /* HAL_LTDC_MODULE_ENABLED */
+
+#ifdef HAL_PWR_MODULE_ENABLED
+ #include "stm32f4xx_hal_pwr.h"
+#endif /* HAL_PWR_MODULE_ENABLED */
+
+#ifdef HAL_RNG_MODULE_ENABLED
+ #include "stm32f4xx_hal_rng.h"
+#endif /* HAL_RNG_MODULE_ENABLED */
+
+#ifdef HAL_RTC_MODULE_ENABLED
+ #include "stm32f4xx_hal_rtc.h"
+#endif /* HAL_RTC_MODULE_ENABLED */
+
+#ifdef HAL_SAI_MODULE_ENABLED
+ #include "stm32f4xx_hal_sai.h"
+#endif /* HAL_SAI_MODULE_ENABLED */
+
+#ifdef HAL_SD_MODULE_ENABLED
+ #include "stm32f4xx_hal_sd.h"
+#endif /* HAL_SD_MODULE_ENABLED */
+
+#ifdef HAL_MMC_MODULE_ENABLED
+ #include "stm32f4xx_hal_mmc.h"
+#endif /* HAL_MMC_MODULE_ENABLED */
+
+#ifdef HAL_SPI_MODULE_ENABLED
+ #include "stm32f4xx_hal_spi.h"
+#endif /* HAL_SPI_MODULE_ENABLED */
+
+#ifdef HAL_TIM_MODULE_ENABLED
+ #include "stm32f4xx_hal_tim.h"
+#endif /* HAL_TIM_MODULE_ENABLED */
+
+#ifdef HAL_UART_MODULE_ENABLED
+ #include "stm32f4xx_hal_uart.h"
+#endif /* HAL_UART_MODULE_ENABLED */
+
+#ifdef HAL_USART_MODULE_ENABLED
+ #include "stm32f4xx_hal_usart.h"
+#endif /* HAL_USART_MODULE_ENABLED */
+
+#ifdef HAL_IRDA_MODULE_ENABLED
+ #include "stm32f4xx_hal_irda.h"
+#endif /* HAL_IRDA_MODULE_ENABLED */
+
+#ifdef HAL_SMARTCARD_MODULE_ENABLED
+ #include "stm32f4xx_hal_smartcard.h"
+#endif /* HAL_SMARTCARD_MODULE_ENABLED */
+
+#ifdef HAL_WWDG_MODULE_ENABLED
+ #include "stm32f4xx_hal_wwdg.h"
+#endif /* HAL_WWDG_MODULE_ENABLED */
+
+#ifdef HAL_PCD_MODULE_ENABLED
+ #include "stm32f4xx_hal_pcd.h"
+#endif /* HAL_PCD_MODULE_ENABLED */
+
+#ifdef HAL_HCD_MODULE_ENABLED
+ #include "stm32f4xx_hal_hcd.h"
+#endif /* HAL_HCD_MODULE_ENABLED */
+
+#ifdef HAL_DSI_MODULE_ENABLED
+ #include "stm32f4xx_hal_dsi.h"
+#endif /* HAL_DSI_MODULE_ENABLED */
+
+#ifdef HAL_QSPI_MODULE_ENABLED
+ #include "stm32f4xx_hal_qspi.h"
+#endif /* HAL_QSPI_MODULE_ENABLED */
+
+#ifdef HAL_CEC_MODULE_ENABLED
+ #include "stm32f4xx_hal_cec.h"
+#endif /* HAL_CEC_MODULE_ENABLED */
+
+#ifdef HAL_FMPI2C_MODULE_ENABLED
+ #include "stm32f4xx_hal_fmpi2c.h"
+#endif /* HAL_FMPI2C_MODULE_ENABLED */
+
+#ifdef HAL_SPDIFRX_MODULE_ENABLED
+ #include "stm32f4xx_hal_spdifrx.h"
+#endif /* HAL_SPDIFRX_MODULE_ENABLED */
+
+#ifdef HAL_DFSDM_MODULE_ENABLED
+ #include "stm32f4xx_hal_dfsdm.h"
+#endif /* HAL_DFSDM_MODULE_ENABLED */
+
+#ifdef HAL_LPTIM_MODULE_ENABLED
+ #include "stm32f4xx_hal_lptim.h"
+#endif /* HAL_LPTIM_MODULE_ENABLED */
+
+/* Exported macro ------------------------------------------------------------*/
+#ifdef USE_FULL_ASSERT
+/**
+ * @brief The assert_param macro is used for function's parameters check.
+ * @param expr: If expr is false, it calls assert_failed function
+ * which reports the name of the source file and the source
+ * line number of the call that failed.
+ * If expr is true, it returns no value.
+ * @retval None
+ */
+ #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__))
+/* Exported functions ------------------------------------------------------- */
+ void assert_failed(uint8_t* file, uint32_t line);
+#else
+ #define assert_param(expr) ((void)0U)
+#endif /* USE_FULL_ASSERT */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __STM32F4xx_HAL_CONF_H */
+
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/ports/stm32f4/boards/stm32f412zg_discovery/stm32f4xx_hal_msp.c b/ports/stm32f4/boards/stm32f412zg_discovery/stm32f4xx_hal_msp.c
new file mode 100644
index 000000000..9d29f3607
--- /dev/null
+++ b/ports/stm32f4/boards/stm32f412zg_discovery/stm32f4xx_hal_msp.c
@@ -0,0 +1,832 @@
+/* USER CODE BEGIN Header */
+/**
+ ******************************************************************************
+ * File Name : stm32f4xx_hal_msp.c
+ * Description : This file provides code for the MSP Initialization
+ * and de-Initialization codes.
+ ******************************************************************************
+ * @attention
+ *
+ * <h2><center>&copy; Copyright (c) 2019 STMicroelectronics.
+ * All rights reserved.</center></h2>
+ *
+ * This software component is licensed by ST under Ultimate Liberty license
+ * SLA0044, the "License"; You may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at:
+ * www.st.com/SLA0044
+ *
+ ******************************************************************************
+ */
+/* USER CODE END Header */
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm32f4xx_hal.h"
+/* USER CODE BEGIN Includes */
+
+/* USER CODE END Includes */
+
+/* Private typedef -----------------------------------------------------------*/
+/* USER CODE BEGIN TD */
+
+/* USER CODE END TD */
+
+/* Private define ------------------------------------------------------------*/
+/* USER CODE BEGIN Define */
+#define LED3_Pin GPIO_PIN_2
+#define LED3_GPIO_Port GPIOE
+#define LED4_Pin GPIO_PIN_3
+#define LED4_GPIO_Port GPIOE
+#define DFSDM_DATIN3_Pin GPIO_PIN_4
+#define DFSDM_DATIN3_GPIO_Port GPIOE
+#define A0_Pin GPIO_PIN_0
+#define A0_GPIO_Port GPIOF
+#define LCD_BLCTRL_Pin GPIO_PIN_5
+#define LCD_BLCTRL_GPIO_Port GPIOF
+#define QSPI_BK1_IO3_Pin GPIO_PIN_6
+#define QSPI_BK1_IO3_GPIO_Port GPIOF
+#define QSPI_BK1_IO2_Pin GPIO_PIN_7
+#define QSPI_BK1_IO2_GPIO_Port GPIOF
+#define QSPI_BK1_IO0_Pin GPIO_PIN_8
+#define QSPI_BK1_IO0_GPIO_Port GPIOF
+#define QSPI_BK1_IO1_Pin GPIO_PIN_9
+#define QSPI_BK1_IO1_GPIO_Port GPIOF
+#define STLK_MCO_Pin GPIO_PIN_0
+#define STLK_MCO_GPIO_Port GPIOH
+#define DFSDM_CKOUT_Pin GPIO_PIN_2
+#define DFSDM_CKOUT_GPIO_Port GPIOC
+#define JOY_SEL_Pin GPIO_PIN_0
+#define JOY_SEL_GPIO_Port GPIOA
+#define STLINK_RX_Pin GPIO_PIN_2
+#define STLINK_RX_GPIO_Port GPIOA
+#define STLINK_TX_Pin GPIO_PIN_3
+#define STLINK_TX_GPIO_Port GPIOA
+#define CODEC_I2S3_WS_Pin GPIO_PIN_4
+#define CODEC_I2S3_WS_GPIO_Port GPIOA
+#define DFSDM_DATIN0_Pin GPIO_PIN_1
+#define DFSDM_DATIN0_GPIO_Port GPIOB
+#define QSPI_CLK_Pin GPIO_PIN_2
+#define QSPI_CLK_GPIO_Port GPIOB
+#define EXT_RESET_Pin GPIO_PIN_11
+#define EXT_RESET_GPIO_Port GPIOF
+#define CTP_RST_Pin GPIO_PIN_12
+#define CTP_RST_GPIO_Port GPIOF
+#define JOY_RIGHT_Pin GPIO_PIN_14
+#define JOY_RIGHT_GPIO_Port GPIOF
+#define JOY_LEFT_Pin GPIO_PIN_15
+#define JOY_LEFT_GPIO_Port GPIOF
+#define JOY_UP_Pin GPIO_PIN_0
+#define JOY_UP_GPIO_Port GPIOG
+#define JOY_DOWN_Pin GPIO_PIN_1
+#define JOY_DOWN_GPIO_Port GPIOG
+#define D4_Pin GPIO_PIN_7
+#define D4_GPIO_Port GPIOE
+#define D5_Pin GPIO_PIN_8
+#define D5_GPIO_Port GPIOE
+#define D6_Pin GPIO_PIN_9
+#define D6_GPIO_Port GPIOE
+#define D7_Pin GPIO_PIN_10
+#define D7_GPIO_Port GPIOE
+#define D8_Pin GPIO_PIN_11
+#define D8_GPIO_Port GPIOE
+#define D9_Pin GPIO_PIN_12
+#define D9_GPIO_Port GPIOE
+#define D10_Pin GPIO_PIN_13
+#define D10_GPIO_Port GPIOE
+#define D11_Pin GPIO_PIN_14
+#define D11_GPIO_Port GPIOE
+#define D12_Pin GPIO_PIN_15
+#define D12_GPIO_Port GPIOE
+#define I2C2_SCL_Pin GPIO_PIN_10
+#define I2C2_SCL_GPIO_Port GPIOB
+#define M2_CKIN_Pin GPIO_PIN_11
+#define M2_CKIN_GPIO_Port GPIOB
+#define CODEC_I2S3_SCK_Pin GPIO_PIN_12
+#define CODEC_I2S3_SCK_GPIO_Port GPIOB
+#define D13_Pin GPIO_PIN_8
+#define D13_GPIO_Port GPIOD
+#define D14_Pin GPIO_PIN_9
+#define D14_GPIO_Port GPIOD
+#define D15_Pin GPIO_PIN_10
+#define D15_GPIO_Port GPIOD
+#define LCD_RESET_Pin GPIO_PIN_11
+#define LCD_RESET_GPIO_Port GPIOD
+#define D0_Pin GPIO_PIN_14
+#define D0_GPIO_Port GPIOD
+#define D1_Pin GPIO_PIN_15
+#define D1_GPIO_Port GPIOD
+#define CODEC_INT_Pin GPIO_PIN_2
+#define CODEC_INT_GPIO_Port GPIOG
+#define LCD_TE_Pin GPIO_PIN_4
+#define LCD_TE_GPIO_Port GPIOG
+#define CTP_INT_Pin GPIO_PIN_5
+#define CTP_INT_GPIO_Port GPIOG
+#define QSPI_BK1_NCS_Pin GPIO_PIN_6
+#define QSPI_BK1_NCS_GPIO_Port GPIOG
+#define USB_OTGFS_OVRCR_Pin GPIO_PIN_7
+#define USB_OTGFS_OVRCR_GPIO_Port GPIOG
+#define USB_OTGFS_PPWR_EN_Pin GPIO_PIN_8
+#define USB_OTGFS_PPWR_EN_GPIO_Port GPIOG
+#define CODEC_I2S3_MCK_Pin GPIO_PIN_7
+#define CODEC_I2S3_MCK_GPIO_Port GPIOC
+#define uSD_D0_Pin GPIO_PIN_8
+#define uSD_D0_GPIO_Port GPIOC
+#define uSD_D1_Pin GPIO_PIN_9
+#define uSD_D1_GPIO_Port GPIOC
+#define M2_CKINA8_Pin GPIO_PIN_8
+#define M2_CKINA8_GPIO_Port GPIOA
+#define USB_OTGFS_VBUS_Pin GPIO_PIN_9
+#define USB_OTGFS_VBUS_GPIO_Port GPIOA
+#define USB_OTGFS_ID_Pin GPIO_PIN_10
+#define USB_OTGFS_ID_GPIO_Port GPIOA
+#define USB_OTGFS_DM_Pin GPIO_PIN_11
+#define USB_OTGFS_DM_GPIO_Port GPIOA
+#define USB_OTGFS_DP_Pin GPIO_PIN_12
+#define USB_OTGFS_DP_GPIO_Port GPIOA
+#define SWDIO_Pin GPIO_PIN_13
+#define SWDIO_GPIO_Port GPIOA
+#define SWCLK_Pin GPIO_PIN_14
+#define SWCLK_GPIO_Port GPIOA
+#define uSD_D2_Pin GPIO_PIN_10
+#define uSD_D2_GPIO_Port GPIOC
+#define uSD_D3_Pin GPIO_PIN_11
+#define uSD_D3_GPIO_Port GPIOC
+#define uSD_CLK_Pin GPIO_PIN_12
+#define uSD_CLK_GPIO_Port GPIOC
+#define D2_Pin GPIO_PIN_0
+#define D2_GPIO_Port GPIOD
+#define D3_Pin GPIO_PIN_1
+#define D3_GPIO_Port GPIOD
+#define uSD_CMD_Pin GPIO_PIN_2
+#define uSD_CMD_GPIO_Port GPIOD
+#define uSD_DETECT_Pin GPIO_PIN_3
+#define uSD_DETECT_GPIO_Port GPIOD
+#define FMC_NOE_Pin GPIO_PIN_4
+#define FMC_NOE_GPIO_Port GPIOD
+#define FMC_NWE_Pin GPIO_PIN_5
+#define FMC_NWE_GPIO_Port GPIOD
+#define FMC_NE1_Pin GPIO_PIN_7
+#define FMC_NE1_GPIO_Port GPIOD
+#define SWO_Pin GPIO_PIN_3
+#define SWO_GPIO_Port GPIOB
+#define CODEC_I2S3ext_SD_Pin GPIO_PIN_4
+#define CODEC_I2S3ext_SD_GPIO_Port GPIOB
+#define CODEC_I2S3_SD_Pin GPIO_PIN_5
+#define CODEC_I2S3_SD_GPIO_Port GPIOB
+#define I2C1_SCL_Pin GPIO_PIN_6
+#define I2C1_SCL_GPIO_Port GPIOB
+#define I2C1_SDA_Pin GPIO_PIN_7
+#define I2C1_SDA_GPIO_Port GPIOB
+#define I2C2_SDA_Pin GPIO_PIN_9
+#define I2C2_SDA_GPIO_Port GPIOB
+#define LED1_Pin GPIO_PIN_0
+#define LED1_GPIO_Port GPIOE
+#define LED2_Pin GPIO_PIN_1
+#define LED2_GPIO_Port GPIOE
+
+/* USER CODE END Define */
+
+/* Private macro -------------------------------------------------------------*/
+/* USER CODE BEGIN Macro */
+
+/* USER CODE END Macro */
+
+/* Private variables ---------------------------------------------------------*/
+/* USER CODE BEGIN PV */
+
+/* USER CODE END PV */
+
+/* Private function prototypes -----------------------------------------------*/
+/* USER CODE BEGIN PFP */
+
+/* USER CODE END PFP */
+
+/* External functions --------------------------------------------------------*/
+/* USER CODE BEGIN ExternalFunctions */
+
+/* USER CODE END ExternalFunctions */
+
+/* USER CODE BEGIN 0 */
+
+/* USER CODE END 0 */
+/**
+ * Initializes the Global MSP.
+ */
+void HAL_MspInit(void)
+{
+ /* USER CODE BEGIN MspInit 0 */
+
+ /* USER CODE END MspInit 0 */
+
+ __HAL_RCC_SYSCFG_CLK_ENABLE();
+ __HAL_RCC_PWR_CLK_ENABLE();
+
+ /* System interrupt init*/
+
+ /* USER CODE BEGIN MspInit 1 */
+
+ /* USER CODE END MspInit 1 */
+}
+
+/**
+* @brief I2C MSP Initialization
+* This function configures the hardware resources used in this example
+* @param hi2c: I2C handle pointer
+* @retval None
+*/
+void HAL_I2C_MspInit(I2C_HandleTypeDef* hi2c)
+{
+ GPIO_InitTypeDef GPIO_InitStruct = {0};
+ if(hi2c->Instance==I2C1)
+ {
+ /* USER CODE BEGIN I2C1_MspInit 0 */
+
+ /* USER CODE END I2C1_MspInit 0 */
+
+ __HAL_RCC_GPIOB_CLK_ENABLE();
+ /**I2C1 GPIO Configuration
+ PB6 ------> I2C1_SCL
+ PB7 ------> I2C1_SDA
+ */
+ GPIO_InitStruct.Pin = I2C1_SCL_Pin|I2C1_SDA_Pin;
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
+ GPIO_InitStruct.Pull = GPIO_PULLUP;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
+ GPIO_InitStruct.Alternate = GPIO_AF4_I2C1;
+ HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
+
+ /* Peripheral clock enable */
+ __HAL_RCC_I2C1_CLK_ENABLE();
+ /* USER CODE BEGIN I2C1_MspInit 1 */
+
+ /* USER CODE END I2C1_MspInit 1 */
+ }
+ else if(hi2c->Instance==I2C2)
+ {
+ /* USER CODE BEGIN I2C2_MspInit 0 */
+
+ /* USER CODE END I2C2_MspInit 0 */
+
+ __HAL_RCC_GPIOB_CLK_ENABLE();
+ /**I2C2 GPIO Configuration
+ PB10 ------> I2C2_SCL
+ PB9 ------> I2C2_SDA
+ */
+ GPIO_InitStruct.Pin = I2C2_SCL_Pin;
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
+ GPIO_InitStruct.Pull = GPIO_PULLUP;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
+ GPIO_InitStruct.Alternate = GPIO_AF4_I2C2;
+ HAL_GPIO_Init(I2C2_SCL_GPIO_Port, &GPIO_InitStruct);
+
+ GPIO_InitStruct.Pin = I2C2_SDA_Pin;
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
+ GPIO_InitStruct.Pull = GPIO_PULLUP;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
+ GPIO_InitStruct.Alternate = GPIO_AF9_I2C2;
+ HAL_GPIO_Init(I2C2_SDA_GPIO_Port, &GPIO_InitStruct);
+
+ /* Peripheral clock enable */
+ __HAL_RCC_I2C2_CLK_ENABLE();
+ /* USER CODE BEGIN I2C2_MspInit 1 */
+
+ /* USER CODE END I2C2_MspInit 1 */
+ }
+
+}
+
+/**
+* @brief I2C MSP De-Initialization
+* This function freeze the hardware resources used in this example
+* @param hi2c: I2C handle pointer
+* @retval None
+*/
+void HAL_I2C_MspDeInit(I2C_HandleTypeDef* hi2c)
+{
+ if(hi2c->Instance==I2C1)
+ {
+ /* USER CODE BEGIN I2C1_MspDeInit 0 */
+
+ /* USER CODE END I2C1_MspDeInit 0 */
+ /* Peripheral clock disable */
+ __HAL_RCC_I2C1_CLK_DISABLE();
+
+ /**I2C1 GPIO Configuration
+ PB6 ------> I2C1_SCL
+ PB7 ------> I2C1_SDA
+ */
+ HAL_GPIO_DeInit(GPIOB, I2C1_SCL_Pin|I2C1_SDA_Pin);
+
+ /* USER CODE BEGIN I2C1_MspDeInit 1 */
+
+ /* USER CODE END I2C1_MspDeInit 1 */
+ }
+ else if(hi2c->Instance==I2C2)
+ {
+ /* USER CODE BEGIN I2C2_MspDeInit 0 */
+
+ /* USER CODE END I2C2_MspDeInit 0 */
+ /* Peripheral clock disable */
+ __HAL_RCC_I2C2_CLK_DISABLE();
+
+ /**I2C2 GPIO Configuration
+ PB10 ------> I2C2_SCL
+ PB9 ------> I2C2_SDA
+ */
+ HAL_GPIO_DeInit(GPIOB, I2C2_SCL_Pin|I2C2_SDA_Pin);
+
+ /* USER CODE BEGIN I2C2_MspDeInit 1 */
+
+ /* USER CODE END I2C2_MspDeInit 1 */
+ }
+
+}
+
+/**
+* @brief I2S MSP Initialization
+* This function configures the hardware resources used in this example
+* @param hi2s: I2S handle pointer
+* @retval None
+*/
+void HAL_I2S_MspInit(I2S_HandleTypeDef* hi2s)
+{
+ GPIO_InitTypeDef GPIO_InitStruct = {0};
+ if(hi2s->Instance==SPI3)
+ {
+ /* USER CODE BEGIN SPI3_MspInit 0 */
+
+ /* USER CODE END SPI3_MspInit 0 */
+ /* Peripheral clock enable */
+ __HAL_RCC_SPI3_CLK_ENABLE();
+
+ __HAL_RCC_GPIOA_CLK_ENABLE();
+ __HAL_RCC_GPIOB_CLK_ENABLE();
+ __HAL_RCC_GPIOC_CLK_ENABLE();
+ /**I2S3 GPIO Configuration
+ PA4 ------> I2S3_WS
+ PB12 ------> I2S3_CK
+ PC7 ------> I2S3_MCK
+ PB4 ------> I2S3_ext_SD
+ PB5 ------> I2S3_SD
+ */
+ GPIO_InitStruct.Pin = CODEC_I2S3_WS_Pin;
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
+ GPIO_InitStruct.Alternate = GPIO_AF6_SPI3;
+ HAL_GPIO_Init(CODEC_I2S3_WS_GPIO_Port, &GPIO_InitStruct);
+
+ GPIO_InitStruct.Pin = CODEC_I2S3_SCK_Pin|CODEC_I2S3ext_SD_Pin;
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
+ GPIO_InitStruct.Alternate = GPIO_AF7_SPI3;
+ HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
+
+ GPIO_InitStruct.Pin = CODEC_I2S3_MCK_Pin;
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
+ GPIO_InitStruct.Alternate = GPIO_AF6_SPI3;
+ HAL_GPIO_Init(CODEC_I2S3_MCK_GPIO_Port, &GPIO_InitStruct);
+
+ GPIO_InitStruct.Pin = CODEC_I2S3_SD_Pin;
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
+ GPIO_InitStruct.Alternate = GPIO_AF6_SPI3;
+ HAL_GPIO_Init(CODEC_I2S3_SD_GPIO_Port, &GPIO_InitStruct);
+
+ /* USER CODE BEGIN SPI3_MspInit 1 */
+
+ /* USER CODE END SPI3_MspInit 1 */
+ }
+
+}
+
+/**
+* @brief I2S MSP De-Initialization
+* This function freeze the hardware resources used in this example
+* @param hi2s: I2S handle pointer
+* @retval None
+*/
+void HAL_I2S_MspDeInit(I2S_HandleTypeDef* hi2s)
+{
+ if(hi2s->Instance==SPI3)
+ {
+ /* USER CODE BEGIN SPI3_MspDeInit 0 */
+
+ /* USER CODE END SPI3_MspDeInit 0 */
+ /* Peripheral clock disable */
+ __HAL_RCC_SPI3_CLK_DISABLE();
+
+ /**I2S3 GPIO Configuration
+ PA4 ------> I2S3_WS
+ PB12 ------> I2S3_CK
+ PC7 ------> I2S3_MCK
+ PB4 ------> I2S3_ext_SD
+ PB5 ------> I2S3_SD
+ */
+ HAL_GPIO_DeInit(CODEC_I2S3_WS_GPIO_Port, CODEC_I2S3_WS_Pin);
+
+ HAL_GPIO_DeInit(GPIOB, CODEC_I2S3_SCK_Pin|CODEC_I2S3ext_SD_Pin|CODEC_I2S3_SD_Pin);
+
+ HAL_GPIO_DeInit(CODEC_I2S3_MCK_GPIO_Port, CODEC_I2S3_MCK_Pin);
+
+ /* USER CODE BEGIN SPI3_MspDeInit 1 */
+
+ /* USER CODE END SPI3_MspDeInit 1 */
+ }
+
+}
+
+/**
+* @brief QSPI MSP Initialization
+* This function configures the hardware resources used in this example
+* @param hqspi: QSPI handle pointer
+* @retval None
+*/
+void HAL_QSPI_MspInit(QSPI_HandleTypeDef* hqspi)
+{
+ GPIO_InitTypeDef GPIO_InitStruct = {0};
+ if(hqspi->Instance==QUADSPI)
+ {
+ /* USER CODE BEGIN QUADSPI_MspInit 0 */
+
+ /* USER CODE END QUADSPI_MspInit 0 */
+ /* Peripheral clock enable */
+ __HAL_RCC_QSPI_CLK_ENABLE();
+
+ __HAL_RCC_GPIOF_CLK_ENABLE();
+ __HAL_RCC_GPIOB_CLK_ENABLE();
+ __HAL_RCC_GPIOG_CLK_ENABLE();
+ /**QUADSPI GPIO Configuration
+ PF6 ------> QUADSPI_BK1_IO3
+ PF7 ------> QUADSPI_BK1_IO2
+ PF8 ------> QUADSPI_BK1_IO0
+ PF9 ------> QUADSPI_BK1_IO1
+ PB2 ------> QUADSPI_CLK
+ PG6 ------> QUADSPI_BK1_NCS
+ */
+ GPIO_InitStruct.Pin = QSPI_BK1_IO3_Pin|QSPI_BK1_IO2_Pin;
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
+ GPIO_InitStruct.Alternate = GPIO_AF9_QSPI;
+ HAL_GPIO_Init(GPIOF, &GPIO_InitStruct);
+
+ GPIO_InitStruct.Pin = QSPI_BK1_IO0_Pin|QSPI_BK1_IO1_Pin;
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
+ GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS;
+ HAL_GPIO_Init(GPIOF, &GPIO_InitStruct);
+
+ GPIO_InitStruct.Pin = QSPI_CLK_Pin;
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
+ GPIO_InitStruct.Alternate = GPIO_AF9_QSPI;
+ HAL_GPIO_Init(QSPI_CLK_GPIO_Port, &GPIO_InitStruct);
+
+ GPIO_InitStruct.Pin = QSPI_BK1_NCS_Pin;
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
+ GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS;
+ HAL_GPIO_Init(QSPI_BK1_NCS_GPIO_Port, &GPIO_InitStruct);
+
+ /* USER CODE BEGIN QUADSPI_MspInit 1 */
+
+ /* USER CODE END QUADSPI_MspInit 1 */
+ }
+
+}
+
+/**
+* @brief QSPI MSP De-Initialization
+* This function freeze the hardware resources used in this example
+* @param hqspi: QSPI handle pointer
+* @retval None
+*/
+void HAL_QSPI_MspDeInit(QSPI_HandleTypeDef* hqspi)
+{
+ if(hqspi->Instance==QUADSPI)
+ {
+ /* USER CODE BEGIN QUADSPI_MspDeInit 0 */
+
+ /* USER CODE END QUADSPI_MspDeInit 0 */
+ /* Peripheral clock disable */
+ __HAL_RCC_QSPI_CLK_DISABLE();
+
+ /**QUADSPI GPIO Configuration
+ PF6 ------> QUADSPI_BK1_IO3
+ PF7 ------> QUADSPI_BK1_IO2
+ PF8 ------> QUADSPI_BK1_IO0
+ PF9 ------> QUADSPI_BK1_IO1
+ PB2 ------> QUADSPI_CLK
+ PG6 ------> QUADSPI_BK1_NCS
+ */
+ HAL_GPIO_DeInit(GPIOF, QSPI_BK1_IO3_Pin|QSPI_BK1_IO2_Pin|QSPI_BK1_IO0_Pin|QSPI_BK1_IO1_Pin);
+
+ HAL_GPIO_DeInit(QSPI_CLK_GPIO_Port, QSPI_CLK_Pin);
+
+ HAL_GPIO_DeInit(QSPI_BK1_NCS_GPIO_Port, QSPI_BK1_NCS_Pin);
+
+ /* USER CODE BEGIN QUADSPI_MspDeInit 1 */
+
+ /* USER CODE END QUADSPI_MspDeInit 1 */
+ }
+
+}
+
+/**
+* @brief SD MSP Initialization
+* This function configures the hardware resources used in this example
+* @param hsd: SD handle pointer
+* @retval None
+*/
+void HAL_SD_MspInit(SD_HandleTypeDef* hsd)
+{
+ GPIO_InitTypeDef GPIO_InitStruct = {0};
+ if(hsd->Instance==SDIO)
+ {
+ /* USER CODE BEGIN SDIO_MspInit 0 */
+
+ /* USER CODE END SDIO_MspInit 0 */
+ /* Peripheral clock enable */
+ __HAL_RCC_SDIO_CLK_ENABLE();
+
+ __HAL_RCC_GPIOC_CLK_ENABLE();
+ __HAL_RCC_GPIOD_CLK_ENABLE();
+ /**SDIO GPIO Configuration
+ PC8 ------> SDIO_D0
+ PC9 ------> SDIO_D1
+ PC10 ------> SDIO_D2
+ PC11 ------> SDIO_D3
+ PC12 ------> SDIO_CK
+ PD2 ------> SDIO_CMD
+ */
+ GPIO_InitStruct.Pin = uSD_D0_Pin|uSD_D1_Pin|uSD_D2_Pin|uSD_D3_Pin
+ |uSD_CLK_Pin;
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
+ GPIO_InitStruct.Alternate = GPIO_AF12_SDIO;
+ HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
+
+ GPIO_InitStruct.Pin = uSD_CMD_Pin;
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
+ GPIO_InitStruct.Alternate = GPIO_AF12_SDIO;
+ HAL_GPIO_Init(uSD_CMD_GPIO_Port, &GPIO_InitStruct);
+
+ /* USER CODE BEGIN SDIO_MspInit 1 */
+
+ /* USER CODE END SDIO_MspInit 1 */
+ }
+
+}
+
+/**
+* @brief SD MSP De-Initialization
+* This function freeze the hardware resources used in this example
+* @param hsd: SD handle pointer
+* @retval None
+*/
+void HAL_SD_MspDeInit(SD_HandleTypeDef* hsd)
+{
+ if(hsd->Instance==SDIO)
+ {
+ /* USER CODE BEGIN SDIO_MspDeInit 0 */
+
+ /* USER CODE END SDIO_MspDeInit 0 */
+ /* Peripheral clock disable */
+ __HAL_RCC_SDIO_CLK_DISABLE();
+
+ /**SDIO GPIO Configuration
+ PC8 ------> SDIO_D0
+ PC9 ------> SDIO_D1
+ PC10 ------> SDIO_D2
+ PC11 ------> SDIO_D3
+ PC12 ------> SDIO_CK
+ PD2 ------> SDIO_CMD
+ */
+ HAL_GPIO_DeInit(GPIOC, uSD_D0_Pin|uSD_D1_Pin|uSD_D2_Pin|uSD_D3_Pin
+ |uSD_CLK_Pin);
+
+ HAL_GPIO_DeInit(uSD_CMD_GPIO_Port, uSD_CMD_Pin);
+
+ /* USER CODE BEGIN SDIO_MspDeInit 1 */
+
+ /* USER CODE END SDIO_MspDeInit 1 */
+ }
+
+}
+
+/**
+* @brief UART MSP Initialization
+* This function configures the hardware resources used in this example
+* @param huart: UART handle pointer
+* @retval None
+*/
+void HAL_UART_MspInit(UART_HandleTypeDef* huart)
+{
+ GPIO_InitTypeDef GPIO_InitStruct = {0};
+ if(huart->Instance==USART2)
+ {
+ /* USER CODE BEGIN USART2_MspInit 0 */
+
+ /* USER CODE END USART2_MspInit 0 */
+ /* Peripheral clock enable */
+ __HAL_RCC_USART2_CLK_ENABLE();
+
+ __HAL_RCC_GPIOA_CLK_ENABLE();
+ /**USART2 GPIO Configuration
+ PA2 ------> USART2_TX
+ PA3 ------> USART2_RX
+ */
+ GPIO_InitStruct.Pin = STLINK_RX_Pin|STLINK_TX_Pin;
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
+ GPIO_InitStruct.Pull = GPIO_PULLUP;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
+ GPIO_InitStruct.Alternate = GPIO_AF7_USART2;
+ HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
+
+ /* USER CODE BEGIN USART2_MspInit 1 */
+
+ /* USER CODE END USART2_MspInit 1 */
+ }
+
+}
+
+/**
+* @brief UART MSP De-Initialization
+* This function freeze the hardware resources used in this example
+* @param huart: UART handle pointer
+* @retval None
+*/
+void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
+{
+ if(huart->Instance==USART2)
+ {
+ /* USER CODE BEGIN USART2_MspDeInit 0 */
+
+ /* USER CODE END USART2_MspDeInit 0 */
+ /* Peripheral clock disable */
+ __HAL_RCC_USART2_CLK_DISABLE();
+
+ /**USART2 GPIO Configuration
+ PA2 ------> USART2_TX
+ PA3 ------> USART2_RX
+ */
+ HAL_GPIO_DeInit(GPIOA, STLINK_RX_Pin|STLINK_TX_Pin);
+
+ /* USER CODE BEGIN USART2_MspDeInit 1 */
+
+ /* USER CODE END USART2_MspDeInit 1 */
+ }
+
+}
+
+static uint32_t FSMC_Initialized = 0;
+
+static void HAL_FSMC_MspInit(void){
+ /* USER CODE BEGIN FSMC_MspInit 0 */
+
+ /* USER CODE END FSMC_MspInit 0 */
+ GPIO_InitTypeDef GPIO_InitStruct ={0};
+ if (FSMC_Initialized) {
+ return;
+ }
+ FSMC_Initialized = 1;
+ /* Peripheral clock enable */
+ __HAL_RCC_FSMC_CLK_ENABLE();
+
+ /** FSMC GPIO Configuration
+ PF0 ------> FSMC_A0
+ PE7 ------> FSMC_D4
+ PE8 ------> FSMC_D5
+ PE9 ------> FSMC_D6
+ PE10 ------> FSMC_D7
+ PE11 ------> FSMC_D8
+ PE12 ------> FSMC_D9
+ PE13 ------> FSMC_D10
+ PE14 ------> FSMC_D11
+ PE15 ------> FSMC_D12
+ PD8 ------> FSMC_D13
+ PD9 ------> FSMC_D14
+ PD10 ------> FSMC_D15
+ PD14 ------> FSMC_D0
+ PD15 ------> FSMC_D1
+ PD0 ------> FSMC_D2
+ PD1 ------> FSMC_D3
+ PD4 ------> FSMC_NOE
+ PD5 ------> FSMC_NWE
+ PD7 ------> FSMC_NE1
+ */
+ GPIO_InitStruct.Pin = A0_Pin;
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
+ GPIO_InitStruct.Alternate = GPIO_AF12_FSMC;
+ HAL_GPIO_Init(A0_GPIO_Port, &GPIO_InitStruct);
+
+ GPIO_InitStruct.Pin = D4_Pin|D5_Pin|D6_Pin|D7_Pin
+ |D8_Pin|D9_Pin|D10_Pin|D11_Pin
+ |D12_Pin;
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
+ GPIO_InitStruct.Alternate = GPIO_AF12_FSMC;
+ HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
+
+ GPIO_InitStruct.Pin = D13_Pin|D14_Pin|D15_Pin|D0_Pin
+ |D1_Pin|D2_Pin|D3_Pin|FMC_NOE_Pin
+ |FMC_NWE_Pin|FMC_NE1_Pin;
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
+ GPIO_InitStruct.Alternate = GPIO_AF12_FSMC;
+ HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
+
+ /* USER CODE BEGIN FSMC_MspInit 1 */
+
+ /* USER CODE END FSMC_MspInit 1 */
+}
+
+void HAL_SRAM_MspInit(SRAM_HandleTypeDef* hsram){
+ /* USER CODE BEGIN SRAM_MspInit 0 */
+
+ /* USER CODE END SRAM_MspInit 0 */
+ HAL_FSMC_MspInit();
+ /* USER CODE BEGIN SRAM_MspInit 1 */
+
+ /* USER CODE END SRAM_MspInit 1 */
+}
+
+static uint32_t FSMC_DeInitialized = 0;
+
+static void HAL_FSMC_MspDeInit(void){
+ /* USER CODE BEGIN FSMC_MspDeInit 0 */
+
+ /* USER CODE END FSMC_MspDeInit 0 */
+ if (FSMC_DeInitialized) {
+ return;
+ }
+ FSMC_DeInitialized = 1;
+ /* Peripheral clock enable */
+ __HAL_RCC_FSMC_CLK_DISABLE();
+
+ /** FSMC GPIO Configuration
+ PF0 ------> FSMC_A0
+ PE7 ------> FSMC_D4
+ PE8 ------> FSMC_D5
+ PE9 ------> FSMC_D6
+ PE10 ------> FSMC_D7
+ PE11 ------> FSMC_D8
+ PE12 ------> FSMC_D9
+ PE13 ------> FSMC_D10
+ PE14 ------> FSMC_D11
+ PE15 ------> FSMC_D12
+ PD8 ------> FSMC_D13
+ PD9 ------> FSMC_D14
+ PD10 ------> FSMC_D15
+ PD14 ------> FSMC_D0
+ PD15 ------> FSMC_D1
+ PD0 ------> FSMC_D2
+ PD1 ------> FSMC_D3
+ PD4 ------> FSMC_NOE
+ PD5 ------> FSMC_NWE
+ PD7 ------> FSMC_NE1
+ */
+ HAL_GPIO_DeInit(A0_GPIO_Port, A0_Pin);
+
+ HAL_GPIO_DeInit(GPIOE, D4_Pin|D5_Pin|D6_Pin|D7_Pin
+ |D8_Pin|D9_Pin|D10_Pin|D11_Pin
+ |D12_Pin);
+
+ HAL_GPIO_DeInit(GPIOD, D13_Pin|D14_Pin|D15_Pin|D0_Pin
+ |D1_Pin|D2_Pin|D3_Pin|FMC_NOE_Pin
+ |FMC_NWE_Pin|FMC_NE1_Pin);
+
+ /* USER CODE BEGIN FSMC_MspDeInit 1 */
+
+ /* USER CODE END FSMC_MspDeInit 1 */
+}
+
+void HAL_SRAM_MspDeInit(SRAM_HandleTypeDef* hsram){
+ /* USER CODE BEGIN SRAM_MspDeInit 0 */
+
+ /* USER CODE END SRAM_MspDeInit 0 */
+ HAL_FSMC_MspDeInit();
+ /* USER CODE BEGIN SRAM_MspDeInit 1 */
+
+ /* USER CODE END SRAM_MspDeInit 1 */
+}
+
+/* USER CODE BEGIN 1 */
+
+/* USER CODE END 1 */
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/ports/stm32f4/common-hal/board/__init__.c b/ports/stm32f4/common-hal/board/__init__.c
new file mode 100644
index 000000000..880033ed6
--- /dev/null
+++ b/ports/stm32f4/common-hal/board/__init__.c
@@ -0,0 +1,25 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2018 Dan Halbert for Adafruit Industries
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
diff --git a/ports/stm32f4/common-hal/digitalio/DigitalInOut.c b/ports/stm32f4/common-hal/digitalio/DigitalInOut.c
new file mode 100644
index 000000000..0805779f4
--- /dev/null
+++ b/ports/stm32f4/common-hal/digitalio/DigitalInOut.c
@@ -0,0 +1,159 @@
+/*
+ * 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) 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/digitalio/DigitalInOut.h"
+#include "py/runtime.h"
+#include "supervisor/shared/translate.h"
+#include "stm32f4xx_hal.h"
+#include "stm32f4xx_ll_gpio.h"
+
+void common_hal_digitalio_digitalinout_never_reset(
+ digitalio_digitalinout_obj_t *self) {
+ never_reset_pin_number(self->pin->port_number, self->pin->number);
+}
+
+digitalinout_result_t common_hal_digitalio_digitalinout_construct(
+ digitalio_digitalinout_obj_t *self, const mcu_pin_obj_t *pin) {
+
+ claim_pin(pin);
+ self->pin = pin;
+
+ GPIO_InitTypeDef GPIO_InitStruct = {0};
+ GPIO_InitStruct.Pin = (1 << pin->number);
+ GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
+ HAL_GPIO_Init(pin->port, &GPIO_InitStruct);
+
+ return DIGITALINOUT_OK;
+}
+
+bool common_hal_digitalio_digitalinout_deinited(digitalio_digitalinout_obj_t *self) {
+ return self->pin == mp_const_none;
+}
+
+void common_hal_digitalio_digitalinout_deinit(digitalio_digitalinout_obj_t *self) {
+ if (common_hal_digitalio_digitalinout_deinited(self)) {
+ return;
+ }
+
+ reset_pin_number(self->pin->port_number, self->pin->number);
+ self->pin = mp_const_none;
+}
+
+void common_hal_digitalio_digitalinout_switch_to_input(
+ digitalio_digitalinout_obj_t *self, digitalio_pull_t pull) {
+
+ GPIO_InitTypeDef GPIO_InitStruct = {0};
+ GPIO_InitStruct.Pin = (1 << self->pin->number);
+ GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
+ HAL_GPIO_Init(self->pin->port, &GPIO_InitStruct);
+
+ common_hal_digitalio_digitalinout_set_pull(self, pull);
+}
+
+void common_hal_digitalio_digitalinout_switch_to_output(
+ digitalio_digitalinout_obj_t *self, bool value,
+ digitalio_drive_mode_t drive_mode) {
+
+ common_hal_digitalio_digitalinout_set_drive_mode(self, drive_mode);
+ common_hal_digitalio_digitalinout_set_value(self, value);
+}
+
+digitalio_direction_t common_hal_digitalio_digitalinout_get_direction(
+ digitalio_digitalinout_obj_t *self) {
+
+ return (LL_GPIO_GetPinMode(self->pin->port, (1 << self->pin->number))
+ == LL_GPIO_MODE_INPUT) ? DIRECTION_INPUT : DIRECTION_OUTPUT;
+}
+
+void common_hal_digitalio_digitalinout_set_value(
+ digitalio_digitalinout_obj_t *self, bool value) {
+ HAL_GPIO_WritePin(self->pin->port, 1 << self->pin->number, value);
+}
+
+bool common_hal_digitalio_digitalinout_get_value(
+ digitalio_digitalinout_obj_t *self) {
+ return (LL_GPIO_GetPinMode(self->pin->port, (1 << self->pin->number)) == LL_GPIO_MODE_INPUT)
+ ? HAL_GPIO_ReadPin(self->pin->port, (1 << self->pin->number))
+ : LL_GPIO_IsOutputPinSet(self->pin->port, (1 << self->pin->number));
+}
+
+void common_hal_digitalio_digitalinout_set_drive_mode(
+ digitalio_digitalinout_obj_t *self,
+ digitalio_drive_mode_t drive_mode) {
+ GPIO_InitTypeDef GPIO_InitStruct = {0};
+ GPIO_InitStruct.Pin = (1 << self->pin->number);
+ GPIO_InitStruct.Mode = (drive_mode == DRIVE_MODE_OPEN_DRAIN ?
+ GPIO_MODE_OUTPUT_OD : GPIO_MODE_OUTPUT_PP);
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
+ HAL_GPIO_Init(self->pin->port, &GPIO_InitStruct);
+}
+
+digitalio_drive_mode_t common_hal_digitalio_digitalinout_get_drive_mode(
+ digitalio_digitalinout_obj_t *self) {
+
+ return LL_GPIO_GetPinOutputType(self->pin->port, (1 << self->pin->port_number))
+ == LL_GPIO_OUTPUT_OPENDRAIN ? DRIVE_MODE_OPEN_DRAIN : DRIVE_MODE_PUSH_PULL;
+}
+
+void common_hal_digitalio_digitalinout_set_pull(
+ digitalio_digitalinout_obj_t *self, digitalio_pull_t pull) {
+
+ switch (pull) {
+ case PULL_UP:
+ LL_GPIO_SetPinPull(self->pin->port,(1 << self->pin->number),LL_GPIO_PULL_UP);
+ break;
+ case PULL_DOWN:
+ LL_GPIO_SetPinPull(self->pin->port,(1 << self->pin->number),LL_GPIO_PULL_DOWN);
+ break;
+ case PULL_NONE:
+ LL_GPIO_SetPinPull(self->pin->port,(1 << self->pin->number),LL_GPIO_PULL_NO);
+ break;
+ default:
+ break;
+ }
+}
+
+digitalio_pull_t common_hal_digitalio_digitalinout_get_pull(
+ digitalio_digitalinout_obj_t *self) {
+
+
+ switch (LL_GPIO_GetPinPull(self->pin->port,(1 << self->pin->number))) {
+ case LL_GPIO_PULL_UP:
+ return PULL_UP;
+ case LL_GPIO_PULL_DOWN:
+ return PULL_DOWN;
+ case LL_GPIO_PULL_NO:
+ return PULL_NONE;
+ default:
+ return PULL_NONE;
+ }
+}
diff --git a/ports/stm32f4/common-hal/digitalio/DigitalInOut.h b/ports/stm32f4/common-hal/digitalio/DigitalInOut.h
new file mode 100644
index 000000000..76aa2c855
--- /dev/null
+++ b/ports/stm32f4/common-hal/digitalio/DigitalInOut.h
@@ -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
+ * 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_STM32F4_COMMON_HAL_DIGITALIO_DIGITALINOUT_H
+#define MICROPY_INCLUDED_STM32F4_COMMON_HAL_DIGITALIO_DIGITALINOUT_H
+
+#include "common-hal/microcontroller/Pin.h"
+
+typedef struct {
+ mp_obj_base_t base;
+ const mcu_pin_obj_t *pin;
+} digitalio_digitalinout_obj_t;
+
+#endif // MICROPY_INCLUDED_STM32F4_COMMON_HAL_DIGITALIO_DIGITALINOUT_H
diff --git a/ports/stm32f4/common-hal/digitalio/__init__.c b/ports/stm32f4/common-hal/digitalio/__init__.c
new file mode 100644
index 000000000..20fad4595
--- /dev/null
+++ b/ports/stm32f4/common-hal/digitalio/__init__.c
@@ -0,0 +1 @@
+// No digitalio module functions.
diff --git a/ports/stm32f4/common-hal/microcontroller/Pin.c b/ports/stm32f4/common-hal/microcontroller/Pin.c
new file mode 100644
index 000000000..6bfe56515
--- /dev/null
+++ b/ports/stm32f4/common-hal/microcontroller/Pin.c
@@ -0,0 +1,81 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2016 Scott Shawcroft for Adafruit Industries
+ * 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/microcontroller/Pin.h"
+
+#include "py/mphal.h"
+#include "stm32f4/pins.h"
+#include "stm32f4xx_hal.h"
+
+#define GPIO_PORT_COUNT 5
+
+STATIC uint16_t claimed_pins[GPIO_PORT_COUNT];
+STATIC uint16_t never_reset_pins[GPIO_PORT_COUNT];
+GPIO_TypeDef * ports[GPIO_PORT_COUNT] = {GPIOA, GPIOB, GPIOC, GPIOD, GPIOE};
+
+void reset_all_pins(void) {
+ // Reset claimed pins
+ for (uint8_t i = 0; i < GPIO_PORT_COUNT; i++) {
+ claimed_pins[i] = never_reset_pins[i];
+ }
+ for (uint8_t i = 0; i < GPIO_PORT_COUNT; i++) {
+ HAL_GPIO_DeInit(ports[i], ~never_reset_pins[i]);
+ }
+}
+
+// Mark pin as free and return it to a quiescent state.
+void reset_pin_number(uint8_t pin_port, uint8_t pin_number) {
+ if (pin_number == NO_PIN) {
+ return;
+ }
+
+ // Clear claimed bit.
+ claimed_pins[pin_port] &= ~(1 << pin_number);
+ // Reset the pin
+ HAL_GPIO_DeInit(ports[pin_port], (1 << pin_number));
+}
+
+
+void never_reset_pin_number(uint8_t pin_port, uint8_t pin_number) {
+ never_reset_pins[pin_port] |= 1 << pin_number;
+}
+
+void claim_pin(const mcu_pin_obj_t* pin) {
+ // Set bit in claimed_pins bitmask.
+ claimed_pins[pin->port_number] |= 1 << pin->number;
+}
+
+
+bool pin_number_is_free(uint8_t pin_port, uint8_t pin_number) {
+ return !(claimed_pins[pin_port] & (1 << pin_number));
+}
+
+bool common_hal_mcu_pin_is_free(const mcu_pin_obj_t *pin) {
+
+ return pin_number_is_free(pin->port_number, pin->number);
+
+}
diff --git a/ports/stm32f4/common-hal/microcontroller/Pin.h b/ports/stm32f4/common-hal/microcontroller/Pin.h
new file mode 100644
index 000000000..e5b1b9ceb
--- /dev/null
+++ b/ports/stm32f4/common-hal/microcontroller/Pin.h
@@ -0,0 +1,42 @@
+/*
+ * 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_STM34F4_COMMON_HAL_MICROCONTROLLER_PIN_H
+#define MICROPY_INCLUDED_STM34F4_COMMON_HAL_MICROCONTROLLER_PIN_H
+
+#include "py/mphal.h"
+
+#include "peripherals/stm32f4/pins.h"
+
+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);
+void claim_pin(const mcu_pin_obj_t* pin);
+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);
+
+#endif // MICROPY_INCLUDED_STM34F4_COMMON_HAL_MICROCONTROLLER_PIN_H
diff --git a/ports/stm32f4/common-hal/microcontroller/Processor.c b/ports/stm32f4/common-hal/microcontroller/Processor.c
new file mode 100644
index 000000000..c59c340c0
--- /dev/null
+++ b/ports/stm32f4/common-hal/microcontroller/Processor.c
@@ -0,0 +1,44 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2017 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 "common-hal/microcontroller/Processor.h"
+#include "py/runtime.h"
+#include "supervisor/shared/translate.h"
+
+
+float common_hal_mcu_processor_get_temperature(void) {
+ return 0;
+}
+
+uint32_t common_hal_mcu_processor_get_frequency(void) {
+ return 64000000ul;
+}
+
+void common_hal_mcu_processor_get_uid(uint8_t raw_id[]) {
+ for (int i=0; i<2; i++) {
+ ((uint32_t*) raw_id)[i] = 0;
+ }
+}
diff --git a/ports/stm32f4/common-hal/microcontroller/Processor.h b/ports/stm32f4/common-hal/microcontroller/Processor.h
new file mode 100644
index 000000000..c3ca4efd5
--- /dev/null
+++ b/ports/stm32f4/common-hal/microcontroller/Processor.h
@@ -0,0 +1,39 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2017 Dan Halbert for Adafruit Industries
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#ifndef MICROPY_INCLUDED_STM32F4_COMMON_HAL_MICROCONTROLLER_PROCESSOR_H
+#define MICROPY_INCLUDED_STM32F4_COMMON_HAL_MICROCONTROLLER_PROCESSOR_H
+
+#define COMMON_HAL_MCU_PROCESSOR_UID_LENGTH 8
+
+#include "py/obj.h"
+
+typedef struct {
+ mp_obj_base_t base;
+ // Stores no state currently.
+} mcu_processor_obj_t;
+
+#endif // MICROPY_INCLUDED_STM32F4_COMMON_HAL_MICROCONTROLLER_PROCESSOR_H
diff --git a/ports/stm32f4/common-hal/microcontroller/__init__.c b/ports/stm32f4/common-hal/microcontroller/__init__.c
new file mode 100644
index 000000000..871caa018
--- /dev/null
+++ b/ports/stm32f4/common-hal/microcontroller/__init__.c
@@ -0,0 +1,191 @@
+/*
+ * 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.
+ */
+
+#include "py/mphal.h"
+#include "py/obj.h"
+#include "py/runtime.h"
+
+#include "common-hal/microcontroller/Pin.h"
+#include "common-hal/microcontroller/Processor.h"
+
+#include "shared-bindings/nvm/ByteArray.h"
+#include "shared-bindings/microcontroller/__init__.h"
+#include "shared-bindings/microcontroller/Pin.h"
+#include "shared-bindings/microcontroller/Processor.h"
+
+#include "supervisor/filesystem.h"
+
+// This routine should work even when interrupts are disabled. Used by OneWire
+// for precise timing.
+void common_hal_mcu_delay_us(uint32_t delay) {
+ //NRFX_DELAY_US(delay);
+}
+
+void common_hal_mcu_disable_interrupts() {
+}
+
+void common_hal_mcu_enable_interrupts() {
+}
+
+void common_hal_mcu_on_next_reset(mcu_runmode_t runmode) {
+ // TODO: see atmel-samd for functionality
+}
+
+void common_hal_mcu_reset(void) {
+ // filesystem_flush();
+ // NVIC_SystemReset();
+}
+
+// The singleton microcontroller.Processor object, bound to microcontroller.cpu
+// It currently only has properties, and no state.
+const mcu_processor_obj_t common_hal_mcu_processor_obj = {
+ .base = {
+ .type = &mcu_processor_type,
+ },
+};
+
+#if CIRCUITPY_INTERNAL_NVM_SIZE > 0
+// The singleton nvm.ByteArray object.
+const nvm_bytearray_obj_t common_hal_mcu_nvm_obj = {
+ .base = {
+ .type = &nvm_bytearray_type,
+ },
+};
+#endif
+
+STATIC const mp_rom_map_elem_t mcu_pin_globals_table[] = {
+ { MP_ROM_QSTR(MP_QSTR_PE02), MP_ROM_PTR(&pin_PE02) },
+ { MP_ROM_QSTR(MP_QSTR_PE03), MP_ROM_PTR(&pin_PE03) },
+ { MP_ROM_QSTR(MP_QSTR_PE04), MP_ROM_PTR(&pin_PE04) },
+ { MP_ROM_QSTR(MP_QSTR_PE05), MP_ROM_PTR(&pin_PE05) },
+ { MP_ROM_QSTR(MP_QSTR_PE06), MP_ROM_PTR(&pin_PE06) },
+ { MP_ROM_QSTR(MP_QSTR_PC13), MP_ROM_PTR(&pin_PC13) },
+ { MP_ROM_QSTR(MP_QSTR_PF00), MP_ROM_PTR(&pin_PF00) },
+ { MP_ROM_QSTR(MP_QSTR_PF01), MP_ROM_PTR(&pin_PF01) },
+ { MP_ROM_QSTR(MP_QSTR_PF02), MP_ROM_PTR(&pin_PF02) },
+ { MP_ROM_QSTR(MP_QSTR_PF03), MP_ROM_PTR(&pin_PF03) },
+ { MP_ROM_QSTR(MP_QSTR_PF04), MP_ROM_PTR(&pin_PF04) },
+ { MP_ROM_QSTR(MP_QSTR_PF05), MP_ROM_PTR(&pin_PF05) },
+ { MP_ROM_QSTR(MP_QSTR_PF06), MP_ROM_PTR(&pin_PF06) },
+ { MP_ROM_QSTR(MP_QSTR_PF07), MP_ROM_PTR(&pin_PF07) },
+ { MP_ROM_QSTR(MP_QSTR_PF08), MP_ROM_PTR(&pin_PF08) },
+ { MP_ROM_QSTR(MP_QSTR_PF09), MP_ROM_PTR(&pin_PF09) },
+ { MP_ROM_QSTR(MP_QSTR_PF10), MP_ROM_PTR(&pin_PF10) },
+ { MP_ROM_QSTR(MP_QSTR_PC00), MP_ROM_PTR(&pin_PC00) },
+ { MP_ROM_QSTR(MP_QSTR_PC01), MP_ROM_PTR(&pin_PC01) },
+ { MP_ROM_QSTR(MP_QSTR_PC02), MP_ROM_PTR(&pin_PC02) },
+ { MP_ROM_QSTR(MP_QSTR_PC03), MP_ROM_PTR(&pin_PC03) },
+ { MP_ROM_QSTR(MP_QSTR_PA00), MP_ROM_PTR(&pin_PA00) },
+ { MP_ROM_QSTR(MP_QSTR_PA01), MP_ROM_PTR(&pin_PA01) },
+ { MP_ROM_QSTR(MP_QSTR_PA02), MP_ROM_PTR(&pin_PA02) },
+ { MP_ROM_QSTR(MP_QSTR_PA03), MP_ROM_PTR(&pin_PA03) },
+ { MP_ROM_QSTR(MP_QSTR_PA04), MP_ROM_PTR(&pin_PA04) },
+ { MP_ROM_QSTR(MP_QSTR_PA05), MP_ROM_PTR(&pin_PA05) },
+ { MP_ROM_QSTR(MP_QSTR_PA06), MP_ROM_PTR(&pin_PA06) },
+ { MP_ROM_QSTR(MP_QSTR_PA07), MP_ROM_PTR(&pin_PA07) },
+ { MP_ROM_QSTR(MP_QSTR_PC04), MP_ROM_PTR(&pin_PC04) },
+ { MP_ROM_QSTR(MP_QSTR_PC05), MP_ROM_PTR(&pin_PC05) },
+ { MP_ROM_QSTR(MP_QSTR_PB00), MP_ROM_PTR(&pin_PB00) },
+ { MP_ROM_QSTR(MP_QSTR_PB01), MP_ROM_PTR(&pin_PB01) },
+ { MP_ROM_QSTR(MP_QSTR_PB02), MP_ROM_PTR(&pin_PB02) },
+ { MP_ROM_QSTR(MP_QSTR_PF11), MP_ROM_PTR(&pin_PF11) },
+ { MP_ROM_QSTR(MP_QSTR_PF12), MP_ROM_PTR(&pin_PF12) },
+ { MP_ROM_QSTR(MP_QSTR_PF13), MP_ROM_PTR(&pin_PF13) },
+ { MP_ROM_QSTR(MP_QSTR_PF14), MP_ROM_PTR(&pin_PF14) },
+ { MP_ROM_QSTR(MP_QSTR_PF15), MP_ROM_PTR(&pin_PF15) },
+ { MP_ROM_QSTR(MP_QSTR_PG00), MP_ROM_PTR(&pin_PG00) },
+ { MP_ROM_QSTR(MP_QSTR_PG01), MP_ROM_PTR(&pin_PG01) },
+ { MP_ROM_QSTR(MP_QSTR_PE07), MP_ROM_PTR(&pin_PE07) },
+ { MP_ROM_QSTR(MP_QSTR_PE08), MP_ROM_PTR(&pin_PE08) },
+ { MP_ROM_QSTR(MP_QSTR_PE09), MP_ROM_PTR(&pin_PE09) },
+ { MP_ROM_QSTR(MP_QSTR_PE10), MP_ROM_PTR(&pin_PE10) },
+ { MP_ROM_QSTR(MP_QSTR_PE11), MP_ROM_PTR(&pin_PE11) },
+ { MP_ROM_QSTR(MP_QSTR_PE12), MP_ROM_PTR(&pin_PE12) },
+ { MP_ROM_QSTR(MP_QSTR_PE13), MP_ROM_PTR(&pin_PE13) },
+ { MP_ROM_QSTR(MP_QSTR_PE14), MP_ROM_PTR(&pin_PE14) },
+ { MP_ROM_QSTR(MP_QSTR_PE15), MP_ROM_PTR(&pin_PE15) },
+ { MP_ROM_QSTR(MP_QSTR_PB10), MP_ROM_PTR(&pin_PB10) },
+ { MP_ROM_QSTR(MP_QSTR_PB11), MP_ROM_PTR(&pin_PB11) },
+ { MP_ROM_QSTR(MP_QSTR_PB12), MP_ROM_PTR(&pin_PB12) },
+ { MP_ROM_QSTR(MP_QSTR_PB13), MP_ROM_PTR(&pin_PB13) },
+ { MP_ROM_QSTR(MP_QSTR_PB14), MP_ROM_PTR(&pin_PB14) },
+ { MP_ROM_QSTR(MP_QSTR_PB15), MP_ROM_PTR(&pin_PB15) },
+ { MP_ROM_QSTR(MP_QSTR_PD08), MP_ROM_PTR(&pin_PD08) },
+ { MP_ROM_QSTR(MP_QSTR_PD09), MP_ROM_PTR(&pin_PD09) },
+ { MP_ROM_QSTR(MP_QSTR_PD10), MP_ROM_PTR(&pin_PD10) },
+ { MP_ROM_QSTR(MP_QSTR_PD11), MP_ROM_PTR(&pin_PD11) },
+ { MP_ROM_QSTR(MP_QSTR_PD12), MP_ROM_PTR(&pin_PD12) },
+ { MP_ROM_QSTR(MP_QSTR_PD13), MP_ROM_PTR(&pin_PD13) },
+ { MP_ROM_QSTR(MP_QSTR_PD14), MP_ROM_PTR(&pin_PD14) },
+ { MP_ROM_QSTR(MP_QSTR_PD15), MP_ROM_PTR(&pin_PD15) },
+ { MP_ROM_QSTR(MP_QSTR_PG02), MP_ROM_PTR(&pin_PG02) },
+ { MP_ROM_QSTR(MP_QSTR_PG03), MP_ROM_PTR(&pin_PG03) },
+ { MP_ROM_QSTR(MP_QSTR_PG04), MP_ROM_PTR(&pin_PG04) },
+ { MP_ROM_QSTR(MP_QSTR_PG05), MP_ROM_PTR(&pin_PG05) },
+ { MP_ROM_QSTR(MP_QSTR_PG06), MP_ROM_PTR(&pin_PG06) },
+ { MP_ROM_QSTR(MP_QSTR_PG07), MP_ROM_PTR(&pin_PG07) },
+ { MP_ROM_QSTR(MP_QSTR_PG08), MP_ROM_PTR(&pin_PG08) },
+ { MP_ROM_QSTR(MP_QSTR_PC06), MP_ROM_PTR(&pin_PC06) },
+ { MP_ROM_QSTR(MP_QSTR_PC07), MP_ROM_PTR(&pin_PC07) },
+ { MP_ROM_QSTR(MP_QSTR_PC08), MP_ROM_PTR(&pin_PC08) },
+ { MP_ROM_QSTR(MP_QSTR_PC09), MP_ROM_PTR(&pin_PC09) },
+ { MP_ROM_QSTR(MP_QSTR_PA08), MP_ROM_PTR(&pin_PA08) },
+ { MP_ROM_QSTR(MP_QSTR_PA09), MP_ROM_PTR(&pin_PA09) },
+ { MP_ROM_QSTR(MP_QSTR_PA10), MP_ROM_PTR(&pin_PA10) },
+ { MP_ROM_QSTR(MP_QSTR_PA11), MP_ROM_PTR(&pin_PA11) },
+ { MP_ROM_QSTR(MP_QSTR_PA12), MP_ROM_PTR(&pin_PA12) },
+ { MP_ROM_QSTR(MP_QSTR_PA13), MP_ROM_PTR(&pin_PA13) },
+ { MP_ROM_QSTR(MP_QSTR_PA14), MP_ROM_PTR(&pin_PA14) },
+ { MP_ROM_QSTR(MP_QSTR_PA15), MP_ROM_PTR(&pin_PA15) },
+ { MP_ROM_QSTR(MP_QSTR_PC10), MP_ROM_PTR(&pin_PC10) },
+ { MP_ROM_QSTR(MP_QSTR_PC11), MP_ROM_PTR(&pin_PC11) },
+ { MP_ROM_QSTR(MP_QSTR_PC12), MP_ROM_PTR(&pin_PC12) },
+ { MP_ROM_QSTR(MP_QSTR_PD00), MP_ROM_PTR(&pin_PD00) },
+ { MP_ROM_QSTR(MP_QSTR_PD01), MP_ROM_PTR(&pin_PD01) },
+ { MP_ROM_QSTR(MP_QSTR_PD02), MP_ROM_PTR(&pin_PD02) },
+ { MP_ROM_QSTR(MP_QSTR_PD03), MP_ROM_PTR(&pin_PD03) },
+ { MP_ROM_QSTR(MP_QSTR_PD04), MP_ROM_PTR(&pin_PD04) },
+ { MP_ROM_QSTR(MP_QSTR_PD05), MP_ROM_PTR(&pin_PD05) },
+ { MP_ROM_QSTR(MP_QSTR_PD06), MP_ROM_PTR(&pin_PD06) },
+ { MP_ROM_QSTR(MP_QSTR_PD07), MP_ROM_PTR(&pin_PD07) },
+ { MP_ROM_QSTR(MP_QSTR_PG09), MP_ROM_PTR(&pin_PG09) },
+ { MP_ROM_QSTR(MP_QSTR_PG10), MP_ROM_PTR(&pin_PG10) },
+ { MP_ROM_QSTR(MP_QSTR_PG11), MP_ROM_PTR(&pin_PG11) },
+ { MP_ROM_QSTR(MP_QSTR_PG12), MP_ROM_PTR(&pin_PG12) },
+ { MP_ROM_QSTR(MP_QSTR_PG13), MP_ROM_PTR(&pin_PG13) },
+ { MP_ROM_QSTR(MP_QSTR_PG14), MP_ROM_PTR(&pin_PG14) },
+ { MP_ROM_QSTR(MP_QSTR_PG15), MP_ROM_PTR(&pin_PG15) },
+ { MP_ROM_QSTR(MP_QSTR_PB03), MP_ROM_PTR(&pin_PB03) },
+ { MP_ROM_QSTR(MP_QSTR_PB04), MP_ROM_PTR(&pin_PB04) },
+ { MP_ROM_QSTR(MP_QSTR_PB05), MP_ROM_PTR(&pin_PB05) },
+ { MP_ROM_QSTR(MP_QSTR_PB06), MP_ROM_PTR(&pin_PB06) },
+ { MP_ROM_QSTR(MP_QSTR_PB07), MP_ROM_PTR(&pin_PB07) },
+ { MP_ROM_QSTR(MP_QSTR_PB08), MP_ROM_PTR(&pin_PB08) },
+ { MP_ROM_QSTR(MP_QSTR_PB09), MP_ROM_PTR(&pin_PB09) },
+ { MP_ROM_QSTR(MP_QSTR_PE00), MP_ROM_PTR(&pin_PE00) },
+ { MP_ROM_QSTR(MP_QSTR_PE01), MP_ROM_PTR(&pin_PE01) },
+};
+MP_DEFINE_CONST_DICT(mcu_pin_globals, mcu_pin_globals_table);
diff --git a/ports/stm32f4/common-hal/nvm/ByteArray.c b/ports/stm32f4/common-hal/nvm/ByteArray.c
new file mode 100644
index 000000000..ef70744ad
--- /dev/null
+++ b/ports/stm32f4/common-hal/nvm/ByteArray.c
@@ -0,0 +1,81 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019 Nick Moore 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.
+ */
+
+//TODO: Implement for STM32. File required by Microcontroller Init
+
+#include "common-hal/nvm/ByteArray.h"
+
+#include <stdio.h>
+#include <string.h>
+
+// defined in linker
+extern uint32_t __fatfs_flash_start_addr[];
+extern uint32_t __fatfs_flash_length[];
+
+#define NVM_START_ADDR ((uint32_t)__fatfs_flash_start_addr + \
+ (uint32_t)__fatfs_flash_length - CIRCUITPY_INTERNAL_NVM_SIZE)
+
+uint32_t common_hal_nvm_bytearray_get_length(nvm_bytearray_obj_t *self) {
+ return CIRCUITPY_INTERNAL_NVM_SIZE;
+}
+
+static void write_page(uint32_t page_addr, uint32_t offset, uint32_t len, uint8_t *bytes) {
+ //
+ // Write a whole page to flash, buffering it first and then erasing and rewriting
+ // it since we can only clear a whole page at a time.
+
+ // if (offset == 0 && len == FLASH_PAGE_SIZE) {
+ // nrf_nvm_safe_flash_page_write(page_addr, bytes);
+ // } else {
+ // uint8_t buffer[FLASH_PAGE_SIZE];
+ // memcpy(buffer, (uint8_t *)page_addr, FLASH_PAGE_SIZE);
+ // memcpy(buffer + offset, bytes, len);
+ // nrf_nvm_safe_flash_page_write(page_addr, buffer);
+ // }
+}
+
+bool common_hal_nvm_bytearray_set_bytes(nvm_bytearray_obj_t *self,
+ // uint32_t start_index, uint8_t* values, uint32_t len) {
+
+ // uint32_t address = NVM_START_ADDR + start_index;
+ // uint32_t offset = address % FLASH_PAGE_SIZE;
+ // uint32_t page_addr = address - offset;
+
+ // while (len) {
+ // uint32_t write_len = MIN(len, FLASH_PAGE_SIZE - offset);
+ // write_page(page_addr, offset, write_len, values);
+ // len -= write_len;
+ // values += write_len;
+ // page_addr += FLASH_PAGE_SIZE;
+ // offset = 0;
+ // }
+ return true;
+}
+
+void common_hal_nvm_bytearray_get_bytes(nvm_bytearray_obj_t *self,
+ uint32_t start_index, uint32_t len, uint8_t* values) {
+ memcpy(values, (uint8_t *)(NVM_START_ADDR + start_index), len);
+}
diff --git a/ports/stm32f4/common-hal/nvm/ByteArray.h b/ports/stm32f4/common-hal/nvm/ByteArray.h
new file mode 100644
index 000000000..ed00df9ff
--- /dev/null
+++ b/ports/stm32f4/common-hal/nvm/ByteArray.h
@@ -0,0 +1,36 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019 Nick Moore 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_STM32F4_COMMON_HAL_NVM_BYTEARRAY_H
+#define MICROPY_INCLUDED_STM32F4_COMMON_HAL_NVM_BYTEARRAY_H
+
+#include "py/obj.h"
+
+typedef struct {
+ mp_obj_base_t base;
+} nvm_bytearray_obj_t;
+
+#endif // MICROPY_INCLUDED_STM32F4_COMMON_HAL_NVM_BYTEARRAY_H
diff --git a/ports/stm32f4/common-hal/nvm/__init__.c b/ports/stm32f4/common-hal/nvm/__init__.c
new file mode 100644
index 000000000..3cdc9d3a4
--- /dev/null
+++ b/ports/stm32f4/common-hal/nvm/__init__.c
@@ -0,0 +1,27 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019 Nick Moore 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.
+ */
+
+// No nvm module functions.
diff --git a/ports/stm32f4/common-hal/supervisor/Runtime.c b/ports/stm32f4/common-hal/supervisor/Runtime.c
new file mode 100755
index 000000000..feab6987d
--- /dev/null
+++ b/ports/stm32f4/common-hal/supervisor/Runtime.c
@@ -0,0 +1,38 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2018 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
+ * 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 "shared-bindings/supervisor/Runtime.h"
+#include "supervisor/serial.h"
+
+bool common_hal_get_serial_connected(void) {
+ return (bool) serial_connected();
+}
+
+bool common_hal_get_serial_bytes_available(void) {
+ return (bool) serial_bytes_available();
+}
+
diff --git a/ports/stm32f4/common-hal/supervisor/Runtime.h b/ports/stm32f4/common-hal/supervisor/Runtime.h
new file mode 100755
index 000000000..9a798e056
--- /dev/null
+++ b/ports/stm32f4/common-hal/supervisor/Runtime.h
@@ -0,0 +1,37 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2018 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
+ * 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_STM32F4_COMMON_HAL_SUPERVISOR_RUNTIME_H
+#define MICROPY_INCLUDED_STM32F4_COMMON_HAL_SUPERVISOR_RUNTIME_H
+
+#include "py/obj.h"
+
+typedef struct {
+ mp_obj_base_t base;
+ // Stores no state currently.
+} super_runtime_obj_t;
+
+#endif // MICROPY_INCLUDED_STM32F4_COMMON_HAL_SUPERVISOR_RUNTIME_H
diff --git a/ports/stm32f4/common-hal/supervisor/__init__.c b/ports/stm32f4/common-hal/supervisor/__init__.c
new file mode 100755
index 000000000..ac88556b4
--- /dev/null
+++ b/ports/stm32f4/common-hal/supervisor/__init__.c
@@ -0,0 +1,40 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2018 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
+ * 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 "shared-bindings/supervisor/__init__.h"
+#include "shared-bindings/supervisor/Runtime.h"
+
+
+// The singleton supervisor.Runtime object, bound to supervisor.runtime
+// It currently only has properties, and no state.
+const super_runtime_obj_t common_hal_supervisor_runtime_obj = {
+ .base = {
+ .type = &supervisor_runtime_type,
+ },
+}; \ No newline at end of file
diff --git a/ports/stm32f4/common-hal/time/__init__.c b/ports/stm32f4/common-hal/time/__init__.c
new file mode 100644
index 000000000..e3cb481ef
--- /dev/null
+++ b/ports/stm32f4/common-hal/time/__init__.c
@@ -0,0 +1,37 @@
+/*
+ * 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.
+ */
+
+#include "py/mphal.h"
+
+#include "tick.h"
+
+uint64_t common_hal_time_monotonic(void) {
+ return ticks_ms;
+}
+
+void common_hal_time_delay_ms(uint32_t delay) {
+ mp_hal_delay_ms(delay);
+}
diff --git a/ports/stm32f4/fatfs_port.c b/ports/stm32f4/fatfs_port.c
new file mode 100644
index 000000000..13ac21fb1
--- /dev/null
+++ b/ports/stm32f4/fatfs_port.c
@@ -0,0 +1,33 @@
+/*
+ * 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.
+ */
+
+#include "py/runtime.h"
+#include "lib/oofatfs/ff.h"
+
+DWORD get_fattime(void) {
+ // TODO: Implement this function. For now, fake it.
+ return ((2016 - 1980) << 25) | ((12) << 21) | ((4) << 16) | ((00) << 11) | ((18) << 5) | (23 / 2);
+}
diff --git a/ports/stm32f4/mpconfigport.h b/ports/stm32f4/mpconfigport.h
new file mode 100644
index 000000000..543a55942
--- /dev/null
+++ b/ports/stm32f4/mpconfigport.h
@@ -0,0 +1,45 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2015 Glenn Ruben Bakke
+ * Copyright (c) 2019 Dan Halbert for Adafruit Industries
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#ifndef STM32F4_MPCONFIGPORT_H__
+#define STM32F4_MPCONFIGPORT_H__
+
+#define MICROPY_PY_COLLECTIONS_ORDEREDDICT (1)
+#define MICROPY_PY_FUNCTION_ATTRS (1)
+#define MICROPY_PY_IO (1)
+#define MICROPY_PY_REVERSE_SPECIAL_METHODS (1)
+#define MICROPY_PY_UJSON (1)
+
+// 24kiB stack
+#define CIRCUITPY_DEFAULT_STACK_SIZE 0x6000
+
+#include "py/circuitpy_mpconfig.h"
+
+#define MICROPY_PORT_ROOT_POINTERS \
+ CIRCUITPY_COMMON_ROOT_POINTERS
+
+#endif // __INCLUDED_MPCONFIGPORT_H
diff --git a/ports/stm32f4/mpconfigport.mk b/ports/stm32f4/mpconfigport.mk
new file mode 100644
index 000000000..814bb2b20
--- /dev/null
+++ b/ports/stm32f4/mpconfigport.mk
@@ -0,0 +1,22 @@
+# Define an equivalent for MICROPY_LONGINT_IMPL, to pass to $(MPY-TOOL) in py/mkrules.mk
+# $(MPY-TOOL) needs to know what kind of longint to use (if any) to freeze long integers.
+# This should correspond to the MICROPY_LONGINT_IMPL definition in mpconfigport.h.
+MPY_TOOL_LONGINT_IMPL = -mlongint-impl=mpz
+
+# Internal math library is substantially smaller than toolchain one
+INTERNAL_LIBM = 1
+
+# Chip supplied serial number, in bytes
+USB_SERIAL_NUMBER_LENGTH = 16
+
+# Longints can be implemented as mpz, as longlong, or not
+LONGINT_IMPL = MPZ
+
+#Reduced feature set for early port
+CIRCUITPY_MINIMAL_BUILD = 1
+
+ifeq ($(MCU_SUB_VARIANT), stm32f412zx)
+ CIRCUITPY_BOARD = 1
+ CIRCUITPY_DIGITALIO = 1
+ CIRCUITPY_MICROCONTROLLER = 1
+endif
diff --git a/shared-bindings/bleio/Device.h b/ports/stm32f4/mphalport.c
index aebf1d639..ea864e7ce 100644
--- a/shared-bindings/bleio/Device.h
+++ b/ports/stm32f4/mphalport.c
@@ -3,6 +3,7 @@
*
* The MIT License (MIT)
*
+ * Copyright (c) 2015 Glenn Ruben Bakke
* Copyright (c) 2018 Artur Pacholec
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -24,19 +25,28 @@
* THE SOFTWARE.
*/
-#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_DEVICE_H
-#define MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_DEVICE_H
+#include <string.h>
-#include "shared-module/bleio/AdvertisementData.h"
-#include "shared-module/bleio/Device.h"
-#include "shared-module/bleio/Service.h"
+#include "py/mphal.h"
+#include "py/mpstate.h"
+#include "py/gc.h"
-extern const mp_obj_type_t bleio_device_type;
-
-extern void common_hal_bleio_device_add_service(bleio_device_obj_t *device, bleio_service_obj_t *service);
-extern void common_hal_bleio_device_start_advertising(bleio_device_obj_t *device, bool connectable, mp_buffer_info_t *raw_data);
-extern void common_hal_bleio_device_stop_advertising(bleio_device_obj_t *device);
-extern void common_hal_bleio_device_connect(bleio_device_obj_t *device);
-extern void common_hal_bleio_device_disconnect(bleio_device_obj_t *device);
-
-#endif // MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_DEVICE_H
+/*------------------------------------------------------------------*/
+/* delay
+ *------------------------------------------------------------------*/
+void mp_hal_delay_ms(mp_uint_t delay) {
+ uint64_t start_tick = ticks_ms;
+ uint64_t duration = 0;
+ while (duration < delay) {
+ #ifdef MICROPY_VM_HOOK_LOOP
+ MICROPY_VM_HOOK_LOOP
+ #endif
+ // 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)) ||
+ MP_STATE_VM(mp_pending_exception) == MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_reload_exception))) {
+ break;
+ }
+ duration = (ticks_ms - start_tick);
+ // TODO(tannewt): Go to sleep for a little while while we wait.
+ }
+}
diff --git a/ports/stm32f4/mphalport.h b/ports/stm32f4/mphalport.h
new file mode 100644
index 000000000..131f2751d
--- /dev/null
+++ b/ports/stm32f4/mphalport.h
@@ -0,0 +1,45 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2015 Glenn Ruben Bakke
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#ifndef __STM32F4_HAL
+#define __STM32F4_HAL
+
+#include <stdbool.h>
+#include <stdint.h>
+
+#include "lib/utils/interrupt_char.h"
+#include "py/mpconfig.h"
+
+//extern nrfx_uarte_t serial_instance;
+
+extern volatile uint64_t ticks_ms;
+
+#define mp_hal_ticks_ms() ((mp_uint_t) ticks_ms)
+//#define mp_hal_delay_us(us) NRFX_DELAY_US((uint32_t) (us))
+
+bool mp_hal_stdin_any(void);
+
+#endif
diff --git a/ports/stm32f4/peripherals/stm32f4/clocks.h b/ports/stm32f4/peripherals/stm32f4/clocks.h
new file mode 100644
index 000000000..c7ba84662
--- /dev/null
+++ b/ports/stm32f4/peripherals/stm32f4/clocks.h
@@ -0,0 +1,27 @@
+/*
+ * This file is part of the Micro Python 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.
+ */
+
+void stm32f4_peripherals_clocks_init(void);
diff --git a/ports/stm32f4/peripherals/stm32f4/gpio.h b/ports/stm32f4/peripherals/stm32f4/gpio.h
new file mode 100644
index 000000000..251cdb814
--- /dev/null
+++ b/ports/stm32f4/peripherals/stm32f4/gpio.h
@@ -0,0 +1,27 @@
+/*
+ * This file is part of the Micro Python 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.
+ */
+
+void stm32f4_peripherals_gpio_init(void);
diff --git a/ports/stm32f4/peripherals/stm32f4/pins.h b/ports/stm32f4/peripherals/stm32f4/pins.h
new file mode 100644
index 000000000..1b48cc192
--- /dev/null
+++ b/ports/stm32f4/peripherals/stm32f4/pins.h
@@ -0,0 +1,73 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2018 Dan Halbert for Adafruit Industries
+ * Copyright (c) 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.
+ */
+
+// DO NOT include this file directly. Use shared-bindings/microcontroller/Pin.h instead to ensure
+// that all necessary includes are already included.
+
+#ifndef __MICROPY_INCLUDED_STM32F4_PERIPHERALS_PINS_H__
+#define __MICROPY_INCLUDED_STM32F4_PERIPHERALS_PINS_H__
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include "stm32f4xx_hal.h"
+
+typedef struct {
+ mp_obj_base_t base;
+ //uint8_t number; //(3)port,(5)pin
+ uint8_t port_number;
+ GPIO_TypeDef * port;
+ uint8_t number;
+} mcu_pin_obj_t;
+
+// extern GPIO_TypeDef *port_lookup_table[];
+
+// static inline GPIO_TypeDef * get_GPIO_ptr(const mcu_pin_obj_t *p)
+// {
+// return port_lookup_table[0x7&( (p->number) >> 5)];
+// }
+
+extern const mp_obj_type_t mcu_pin_type;
+
+// Used in device-specific pins.c
+#define PIN(p_port_num, p_port, p_number) \
+{ \
+ { &mcu_pin_type }, \
+ .port_number = (p_port_num), \
+ .port = (p_port), \
+ .number = (p_number), \
+}
+
+// Use illegal pin value to mark unassigned pins.
+#define NO_PIN 0xff
+
+// Choose based on chip
+#ifdef STM32F412Zx
+#include "stm32f412zx/pins.h"
+#endif
+
+#endif // __MICROPY_INCLUDED_STM32F4_PERIPHERALS_PINS_H__
diff --git a/ports/stm32f4/peripherals/stm32f4/stm32f411xe/clocks.c b/ports/stm32f4/peripherals/stm32f4/stm32f411xe/clocks.c
new file mode 100644
index 000000000..5b7a1e298
--- /dev/null
+++ b/ports/stm32f4/peripherals/stm32f4/stm32f411xe/clocks.c
@@ -0,0 +1,63 @@
+
+/*
+ * This file is part of the Micro Python 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 "stm32f4xx_hal.h"
+
+void stm32f4_peripherals_clocks_init(void) {
+ //System clock init
+ RCC_OscInitTypeDef RCC_OscInitStruct = {0};
+ RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
+ RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0};
+ /** Configure the main internal regulator output voltage
+ */
+ __HAL_RCC_PWR_CLK_ENABLE();
+ __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
+ /** Initializes the CPU, AHB and APB busses clocks
+ */
+ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
+ RCC_OscInitStruct.HSEState = RCC_HSE_ON;
+ RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
+ RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
+ RCC_OscInitStruct.PLL.PLLM = 4;
+ RCC_OscInitStruct.PLL.PLLN = 192;
+ RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4;
+ RCC_OscInitStruct.PLL.PLLQ = 8;
+ HAL_RCC_OscConfig(&RCC_OscInitStruct);
+ /** Initializes the CPU, AHB and APB busses clocks
+ */
+ RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
+ |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
+ RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
+ RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
+ RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
+ RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
+ HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_3);
+ PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_I2S;
+ PeriphClkInitStruct.PLLI2S.PLLI2SN = 200;
+ PeriphClkInitStruct.PLLI2S.PLLI2SM = 5;
+ PeriphClkInitStruct.PLLI2S.PLLI2SR = 2;
+ HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct);
+}
diff --git a/ports/stm32f4/peripherals/stm32f4/stm32f411xe/gpio.c b/ports/stm32f4/peripherals/stm32f4/stm32f411xe/gpio.c
new file mode 100644
index 000000000..a9ac97bae
--- /dev/null
+++ b/ports/stm32f4/peripherals/stm32f4/stm32f411xe/gpio.c
@@ -0,0 +1,137 @@
+/*
+ * This file is part of the Micro Python 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.
+ */
+
+/* GPIO PIN REFERENCE
+#define DATA_Ready_Pin GPIO_PIN_2
+#define DATA_Ready_GPIO_Port GPIOE
+#define CS_I2C_SPI_Pin GPIO_PIN_3
+#define CS_I2C_SPI_GPIO_Port GPIOE
+#define INT1_Pin GPIO_PIN_4
+#define INT1_GPIO_Port GPIOE
+#define INT2_Pin GPIO_PIN_5
+#define INT2_GPIO_Port GPIOE
+#define PC14_OSC32_IN_Pin GPIO_PIN_14
+#define PC14_OSC32_IN_GPIO_Port GPIOC
+#define PC15_OSC32_OUT_Pin GPIO_PIN_15
+#define PC15_OSC32_OUT_GPIO_Port GPIOC
+#define PH0_OSC_IN_Pin GPIO_PIN_0
+#define PH0_OSC_IN_GPIO_Port GPIOH
+#define PH1_OSC_OUT_Pin GPIO_PIN_1
+#define PH1_OSC_OUT_GPIO_Port GPIOH
+#define OTG_FS_PowerSwitchOn_Pin GPIO_PIN_0
+#define OTG_FS_PowerSwitchOn_GPIO_Port GPIOC
+#define PDM_OUT_Pin GPIO_PIN_3
+#define PDM_OUT_GPIO_Port GPIOC
+#define I2S3_WS_Pin GPIO_PIN_4
+#define I2S3_WS_GPIO_Port GPIOA
+#define SPI1_SCK_Pin GPIO_PIN_5
+#define SPI1_SCK_GPIO_Port GPIOA
+#define SPI1_MISO_Pin GPIO_PIN_6
+#define SPI1_MISO_GPIO_Port GPIOA
+#define SPI1_MOSI_Pin GPIO_PIN_7
+#define SPI1_MOSI_GPIO_Port GPIOA
+#define CLK_IN_Pin GPIO_PIN_10
+#define CLK_IN_GPIO_Port GPIOB
+#define LD4_Pin GPIO_PIN_12
+#define LD4_GPIO_Port GPIOD
+#define LD3_Pin GPIO_PIN_13
+#define LD3_GPIO_Port GPIOD
+#define LD5_Pin GPIO_PIN_14
+#define LD5_GPIO_Port GPIOD
+#define LD6_Pin GPIO_PIN_15
+#define LD6_GPIO_Port GPIOD
+#define I2S3_MCK_Pin GPIO_PIN_7
+#define I2S3_MCK_GPIO_Port GPIOC
+#define VBUS_FS_Pin GPIO_PIN_9
+#define VBUS_FS_GPIO_Port GPIOA
+#define OTG_FS_ID_Pin GPIO_PIN_10
+#define OTG_FS_ID_GPIO_Port GPIOA
+#define OTG_FS_DM_Pin GPIO_PIN_11
+#define OTG_FS_DM_GPIO_Port GPIOA
+#define OTG_FS_DP_Pin GPIO_PIN_12
+#define OTG_FS_DP_GPIO_Port GPIOA
+#define SWDIO_Pin GPIO_PIN_13
+#define SWDIO_GPIO_Port GPIOA
+#define SWCLK_Pin GPIO_PIN_14
+#define SWCLK_GPIO_Port GPIOA
+#define I2S3_SCK_Pin GPIO_PIN_10
+#define I2S3_SCK_GPIO_Port GPIOC
+#define I2S3_SD_Pin GPIO_PIN_12
+#define I2S3_SD_GPIO_Port GPIOC
+#define Audio_RST_Pin GPIO_PIN_4
+#define Audio_RST_GPIO_Port GPIOD
+#define OTG_FS_OverCurrent_Pin GPIO_PIN_5
+#define OTG_FS_OverCurrent_GPIO_Port GPIOD
+#define SWO_Pin GPIO_PIN_3
+#define SWO_GPIO_Port GPIOB
+#define Audio_SCL_Pin GPIO_PIN_6
+#define Audio_SCL_GPIO_Port GPIOB
+#define Audio_SDA_Pin GPIO_PIN_9
+#define Audio_SDA_GPIO_Port GPIOB
+#define MEMS_INT2_Pin GPIO_PIN_1
+#define MEMS_INT2_GPIO_Port GPIOE
+*/
+
+#define LD4_Pin GPIO_PIN_12
+#define LD4_GPIO_Port GPIOD
+#define LD3_Pin GPIO_PIN_13
+#define LD3_GPIO_Port GPIOD
+#define LD5_Pin GPIO_PIN_14
+#define LD5_GPIO_Port GPIOD
+#define LD6_Pin GPIO_PIN_15
+#define LD6_GPIO_Port GPIOD
+
+#include "stm32f4xx_hal.h"
+
+void stm32f4_peripherals_gpio_init(void) {
+ //Enable all GPIO for now
+ GPIO_InitTypeDef GPIO_InitStruct = {0};
+ /* GPIO Ports Clock Enable */
+ __HAL_RCC_GPIOE_CLK_ENABLE();
+ __HAL_RCC_GPIOC_CLK_ENABLE();
+ __HAL_RCC_GPIOH_CLK_ENABLE();
+ __HAL_RCC_GPIOA_CLK_ENABLE();
+ __HAL_RCC_GPIOB_CLK_ENABLE();
+ __HAL_RCC_GPIOD_CLK_ENABLE();
+
+ /*Configure GPIO pin Output Level */
+ HAL_GPIO_WritePin(GPIOD, LD4_Pin|LD3_Pin|LD5_Pin|LD6_Pin, GPIO_PIN_RESET);
+
+ /*Configure GPIO pins : LD4_Pin LD3_Pin LD5_Pin LD6_Pin */
+ GPIO_InitStruct.Pin = LD4_Pin|LD3_Pin|LD5_Pin|LD6_Pin;
+ GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
+ HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
+
+ //Status LED chain
+ HAL_GPIO_WritePin(GPIOD, LD4_Pin, GPIO_PIN_RESET); //LED 1
+ HAL_GPIO_WritePin(GPIOD, LD3_Pin, GPIO_PIN_SET); //LED 2
+ HAL_GPIO_WritePin(GPIOD, LD5_Pin, GPIO_PIN_SET); //LED 3
+ HAL_GPIO_WritePin(GPIOD, LD6_Pin, GPIO_PIN_SET); //LED 4
+}
+
+
diff --git a/ports/stm32f4/peripherals/stm32f4/stm32f411xe/pins.c b/ports/stm32f4/peripherals/stm32f4/stm32f411xe/pins.c
new file mode 100644
index 000000000..04502d714
--- /dev/null
+++ b/ports/stm32f4/peripherals/stm32f4/stm32f411xe/pins.c
@@ -0,0 +1,33 @@
+ /*
+ * 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 "py/obj.h"
+#include "py/mphal.h"
+#include "stm32f4/pins.h"
+
+
+//TODO
+//const mcu_pin_obj_t pin_PE02 = PIN(4, GPIOE, 2); \ No newline at end of file
diff --git a/ports/stm32f4/peripherals/stm32f4/stm32f411xe/pins.h b/ports/stm32f4/peripherals/stm32f4/stm32f411xe/pins.h
new file mode 100644
index 000000000..b060d9ed0
--- /dev/null
+++ b/ports/stm32f4/peripherals/stm32f4/stm32f411xe/pins.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_STM32F4_PERIPHERALS_STM32F411RE_PINS_H
+#define MICROPY_INCLUDED_STM32F4_PERIPHERALS_STM32F411RE_PINS_H
+
+//TODO
+//Pins in datasheet order: DocID028087 Rev 7 page 50. LQFP100 only
+//pg 50
+//extern const mcu_pin_obj_t pin_PE02;
+
+
+#endif // MICROPY_INCLUDED_STM32F4_PERIPHERALS_STM32F411RE_PINS_H
diff --git a/ports/stm32f4/peripherals/stm32f4/stm32f412zx/clocks.c b/ports/stm32f4/peripherals/stm32f4/stm32f412zx/clocks.c
new file mode 100644
index 000000000..0ccd9cb48
--- /dev/null
+++ b/ports/stm32f4/peripherals/stm32f4/stm32f412zx/clocks.c
@@ -0,0 +1,75 @@
+
+/*
+ * This file is part of the Micro Python 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 "stm32f4xx_hal.h"
+
+void stm32f4_peripherals_clocks_init(void) {
+ //System clock init
+ RCC_OscInitTypeDef RCC_OscInitStruct = {0};
+ RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
+ RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0};
+ /** Configure the main internal regulator output voltage
+ */
+ __HAL_RCC_PWR_CLK_ENABLE();
+ __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
+ /** Initializes the CPU, AHB and APB busses clocks
+ */
+ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI|RCC_OSCILLATORTYPE_HSE;
+ RCC_OscInitStruct.HSEState = RCC_HSE_ON;
+ RCC_OscInitStruct.HSIState = RCC_HSI_ON;
+ RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
+ RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
+ RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
+ RCC_OscInitStruct.PLL.PLLM = 4;
+ RCC_OscInitStruct.PLL.PLLN = 72;
+ RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
+ RCC_OscInitStruct.PLL.PLLQ = 3;
+ RCC_OscInitStruct.PLL.PLLR = 2;
+ HAL_RCC_OscConfig(&RCC_OscInitStruct);
+ /** Initializes the CPU, AHB and APB busses clocks
+ */
+ RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
+ |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
+ RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
+ RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
+ RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
+ RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
+ HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2);
+
+ PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_I2S_APB1|RCC_PERIPHCLK_SDIO
+ |RCC_PERIPHCLK_CLK48;
+ PeriphClkInitStruct.PLLI2S.PLLI2SN = 50;
+ PeriphClkInitStruct.PLLI2S.PLLI2SM = 4;
+ PeriphClkInitStruct.PLLI2S.PLLI2SR = 2;
+ PeriphClkInitStruct.PLLI2S.PLLI2SQ = 2;
+ PeriphClkInitStruct.Clk48ClockSelection = RCC_CLK48CLKSOURCE_PLLQ;
+ PeriphClkInitStruct.SdioClockSelection = RCC_SDIOCLKSOURCE_CLK48;
+ PeriphClkInitStruct.PLLI2SSelection = RCC_PLLI2SCLKSOURCE_PLLSRC;
+ PeriphClkInitStruct.I2sApb1ClockSelection = RCC_I2SAPB1CLKSOURCE_PLLI2S;
+ HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct);
+
+ HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_HSI, RCC_MCODIV_1);
+}
diff --git a/ports/stm32f4/peripherals/stm32f4/stm32f412zx/gpio.c b/ports/stm32f4/peripherals/stm32f4/stm32f412zx/gpio.c
new file mode 100644
index 000000000..de783bafe
--- /dev/null
+++ b/ports/stm32f4/peripherals/stm32f4/stm32f412zx/gpio.c
@@ -0,0 +1,218 @@
+/*
+ * This file is part of the Micro Python 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.
+ */
+
+/* GPIO PIN REFERENCE
+#define LED3_Pin GPIO_PIN_2
+#define LED3_GPIO_Port GPIOE
+#define LED4_Pin GPIO_PIN_3
+#define LED4_GPIO_Port GPIOE
+#define DFSDM_DATIN3_Pin GPIO_PIN_4
+#define DFSDM_DATIN3_GPIO_Port GPIOE
+#define A0_Pin GPIO_PIN_0
+#define A0_GPIO_Port GPIOF
+#define LCD_BLCTRL_Pin GPIO_PIN_5
+#define LCD_BLCTRL_GPIO_Port GPIOF
+#define QSPI_BK1_IO3_Pin GPIO_PIN_6
+#define QSPI_BK1_IO3_GPIO_Port GPIOF
+#define QSPI_BK1_IO2_Pin GPIO_PIN_7
+#define QSPI_BK1_IO2_GPIO_Port GPIOF
+#define QSPI_BK1_IO0_Pin GPIO_PIN_8
+#define QSPI_BK1_IO0_GPIO_Port GPIOF
+#define QSPI_BK1_IO1_Pin GPIO_PIN_9
+#define QSPI_BK1_IO1_GPIO_Port GPIOF
+#define STLK_MCO_Pin GPIO_PIN_0
+#define STLK_MCO_GPIO_Port GPIOH
+#define DFSDM_CKOUT_Pin GPIO_PIN_2
+#define DFSDM_CKOUT_GPIO_Port GPIOC
+#define JOY_SEL_Pin GPIO_PIN_0
+#define JOY_SEL_GPIO_Port GPIOA
+#define STLINK_RX_Pin GPIO_PIN_2
+#define STLINK_RX_GPIO_Port GPIOA
+#define STLINK_TX_Pin GPIO_PIN_3
+#define STLINK_TX_GPIO_Port GPIOA
+#define CODEC_I2S3_WS_Pin GPIO_PIN_4
+#define CODEC_I2S3_WS_GPIO_Port GPIOA
+#define DFSDM_DATIN0_Pin GPIO_PIN_1
+#define DFSDM_DATIN0_GPIO_Port GPIOB
+#define QSPI_CLK_Pin GPIO_PIN_2
+#define QSPI_CLK_GPIO_Port GPIOB
+#define EXT_RESET_Pin GPIO_PIN_11
+#define EXT_RESET_GPIO_Port GPIOF
+#define CTP_RST_Pin GPIO_PIN_12
+#define CTP_RST_GPIO_Port GPIOF
+#define JOY_RIGHT_Pin GPIO_PIN_14
+#define JOY_RIGHT_GPIO_Port GPIOF
+#define JOY_LEFT_Pin GPIO_PIN_15
+#define JOY_LEFT_GPIO_Port GPIOF
+#define JOY_UP_Pin GPIO_PIN_0
+#define JOY_UP_GPIO_Port GPIOG
+#define JOY_DOWN_Pin GPIO_PIN_1
+#define JOY_DOWN_GPIO_Port GPIOG
+#define D4_Pin GPIO_PIN_7
+#define D4_GPIO_Port GPIOE
+#define D5_Pin GPIO_PIN_8
+#define D5_GPIO_Port GPIOE
+#define D6_Pin GPIO_PIN_9
+#define D6_GPIO_Port GPIOE
+#define D7_Pin GPIO_PIN_10
+#define D7_GPIO_Port GPIOE
+#define D8_Pin GPIO_PIN_11
+#define D8_GPIO_Port GPIOE
+#define D9_Pin GPIO_PIN_12
+#define D9_GPIO_Port GPIOE
+#define D10_Pin GPIO_PIN_13
+#define D10_GPIO_Port GPIOE
+#define D11_Pin GPIO_PIN_14
+#define D11_GPIO_Port GPIOE
+#define D12_Pin GPIO_PIN_15
+#define D12_GPIO_Port GPIOE
+#define I2C2_SCL_Pin GPIO_PIN_10
+#define I2C2_SCL_GPIO_Port GPIOB
+#define M2_CKIN_Pin GPIO_PIN_11
+#define M2_CKIN_GPIO_Port GPIOB
+#define CODEC_I2S3_SCK_Pin GPIO_PIN_12
+#define CODEC_I2S3_SCK_GPIO_Port GPIOB
+#define D13_Pin GPIO_PIN_8
+#define D13_GPIO_Port GPIOD
+#define D14_Pin GPIO_PIN_9
+#define D14_GPIO_Port GPIOD
+#define D15_Pin GPIO_PIN_10
+#define D15_GPIO_Port GPIOD
+#define LCD_RESET_Pin GPIO_PIN_11
+#define LCD_RESET_GPIO_Port GPIOD
+#define D0_Pin GPIO_PIN_14
+#define D0_GPIO_Port GPIOD
+#define D1_Pin GPIO_PIN_15
+#define D1_GPIO_Port GPIOD
+#define CODEC_INT_Pin GPIO_PIN_2
+#define CODEC_INT_GPIO_Port GPIOG
+#define LCD_TE_Pin GPIO_PIN_4
+#define LCD_TE_GPIO_Port GPIOG
+#define CTP_INT_Pin GPIO_PIN_5
+#define CTP_INT_GPIO_Port GPIOG
+#define QSPI_BK1_NCS_Pin GPIO_PIN_6
+#define QSPI_BK1_NCS_GPIO_Port GPIOG
+#define USB_OTGFS_OVRCR_Pin GPIO_PIN_7
+#define USB_OTGFS_OVRCR_GPIO_Port GPIOG
+#define USB_OTGFS_PPWR_EN_Pin GPIO_PIN_8
+#define USB_OTGFS_PPWR_EN_GPIO_Port GPIOG
+#define CODEC_I2S3_MCK_Pin GPIO_PIN_7
+#define CODEC_I2S3_MCK_GPIO_Port GPIOC
+#define uSD_D0_Pin GPIO_PIN_8
+#define uSD_D0_GPIO_Port GPIOC
+#define uSD_D1_Pin GPIO_PIN_9
+#define uSD_D1_GPIO_Port GPIOC
+#define M2_CKINA8_Pin GPIO_PIN_8
+#define M2_CKINA8_GPIO_Port GPIOA
+#define USB_OTGFS_VBUS_Pin GPIO_PIN_9
+#define USB_OTGFS_VBUS_GPIO_Port GPIOA
+#define USB_OTGFS_ID_Pin GPIO_PIN_10
+#define USB_OTGFS_ID_GPIO_Port GPIOA
+#define USB_OTGFS_DM_Pin GPIO_PIN_11
+#define USB_OTGFS_DM_GPIO_Port GPIOA
+#define USB_OTGFS_DP_Pin GPIO_PIN_12
+#define USB_OTGFS_DP_GPIO_Port GPIOA
+#define SWDIO_Pin GPIO_PIN_13
+#define SWDIO_GPIO_Port GPIOA
+#define SWCLK_Pin GPIO_PIN_14
+#define SWCLK_GPIO_Port GPIOA
+#define uSD_D2_Pin GPIO_PIN_10
+#define uSD_D2_GPIO_Port GPIOC
+#define uSD_D3_Pin GPIO_PIN_11
+#define uSD_D3_GPIO_Port GPIOC
+#define uSD_CLK_Pin GPIO_PIN_12
+#define uSD_CLK_GPIO_Port GPIOC
+#define D2_Pin GPIO_PIN_0
+#define D2_GPIO_Port GPIOD
+#define D3_Pin GPIO_PIN_1
+#define D3_GPIO_Port GPIOD
+#define uSD_CMD_Pin GPIO_PIN_2
+#define uSD_CMD_GPIO_Port GPIOD
+#define uSD_DETECT_Pin GPIO_PIN_3
+#define uSD_DETECT_GPIO_Port GPIOD
+#define FMC_NOE_Pin GPIO_PIN_4
+#define FMC_NOE_GPIO_Port GPIOD
+#define FMC_NWE_Pin GPIO_PIN_5
+#define FMC_NWE_GPIO_Port GPIOD
+#define FMC_NE1_Pin GPIO_PIN_7
+#define FMC_NE1_GPIO_Port GPIOD
+#define SWO_Pin GPIO_PIN_3
+#define SWO_GPIO_Port GPIOB
+#define CODEC_I2S3ext_SD_Pin GPIO_PIN_4
+#define CODEC_I2S3ext_SD_GPIO_Port GPIOB
+#define CODEC_I2S3_SD_Pin GPIO_PIN_5
+#define CODEC_I2S3_SD_GPIO_Port GPIOB
+#define I2C1_SCL_Pin GPIO_PIN_6
+#define I2C1_SCL_GPIO_Port GPIOB
+#define I2C1_SDA_Pin GPIO_PIN_7
+#define I2C1_SDA_GPIO_Port GPIOB
+#define I2C2_SDA_Pin GPIO_PIN_9
+#define I2C2_SDA_GPIO_Port GPIOB
+#define LED1_Pin GPIO_PIN_0
+#define LED1_GPIO_Port GPIOE
+#define LED2_Pin GPIO_PIN_1
+#define LED2_GPIO_Port GPIOE
+*/
+
+#include "stm32f4xx_hal.h"
+
+void stm32f4_peripherals_gpio_init(void) {
+ //Enable all GPIO for now
+ GPIO_InitTypeDef GPIO_InitStruct = {0};
+ __HAL_RCC_GPIOE_CLK_ENABLE();
+ __HAL_RCC_GPIOC_CLK_ENABLE();
+ __HAL_RCC_GPIOF_CLK_ENABLE();
+ __HAL_RCC_GPIOH_CLK_ENABLE();
+ __HAL_RCC_GPIOA_CLK_ENABLE();
+ __HAL_RCC_GPIOB_CLK_ENABLE();
+ __HAL_RCC_GPIOG_CLK_ENABLE();
+ __HAL_RCC_GPIOD_CLK_ENABLE();
+
+ HAL_GPIO_WritePin(GPIOE, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3, GPIO_PIN_RESET);
+ //HAL_GPIO_WritePin(USB_OTGFS_PPWR_EN_GPIO_Port, USB_OTGFS_PPWR_EN_Pin, GPIO_PIN_SET);
+
+ //Configure LED pins
+ GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3;
+ GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
+ HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
+
+ //Status LED chain
+ HAL_GPIO_WritePin(GPIOE, GPIO_PIN_0, GPIO_PIN_RESET); //LED 1
+ HAL_GPIO_WritePin(GPIOE, GPIO_PIN_1, GPIO_PIN_SET); //LED 2
+ HAL_GPIO_WritePin(GPIOE, GPIO_PIN_2, GPIO_PIN_SET); //LED 3
+ HAL_GPIO_WritePin(GPIOE, GPIO_PIN_3, GPIO_PIN_SET); //LED 4
+
+ //TBD, USB power
+ // GPIO_InitStruct.Pin = USB_OTGFS_PPWR_EN_Pin;
+ // GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD;
+ // GPIO_InitStruct.Pull = GPIO_NOPULL;
+ // GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
+ // HAL_GPIO_Init(USB_OTGFS_PPWR_EN_GPIO_Port, &GPIO_InitStruct);
+}
+
+
diff --git a/ports/stm32f4/peripherals/stm32f4/stm32f412zx/pins.c b/ports/stm32f4/peripherals/stm32f4/stm32f412zx/pins.c
new file mode 100644
index 000000000..5a4703bea
--- /dev/null
+++ b/ports/stm32f4/peripherals/stm32f4/stm32f412zx/pins.c
@@ -0,0 +1,159 @@
+ /*
+ * 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 "py/obj.h"
+#include "py/mphal.h"
+#include "stm32f4/pins.h"
+
+const mcu_pin_obj_t pin_PE02 = PIN(4, GPIOE, 2);
+const mcu_pin_obj_t pin_PE03 = PIN(4, GPIOE, 3);
+const mcu_pin_obj_t pin_PE04 = PIN(4, GPIOE, 4);
+const mcu_pin_obj_t pin_PE05 = PIN(4, GPIOE, 5);
+const mcu_pin_obj_t pin_PE06 = PIN(4, GPIOE, 6);
+
+const mcu_pin_obj_t pin_PC13 = PIN(2, GPIOC, 13);
+
+const mcu_pin_obj_t pin_PF00 = PIN(5, GPIOF, 0); // 144 only
+const mcu_pin_obj_t pin_PF01 = PIN(5, GPIOF, 1); // 144 only
+const mcu_pin_obj_t pin_PF02 = PIN(5, GPIOF, 2); // 144 only
+const mcu_pin_obj_t pin_PF03 = PIN(5, GPIOF, 3); // 144 only
+const mcu_pin_obj_t pin_PF04 = PIN(5, GPIOF, 4); // 144 only
+const mcu_pin_obj_t pin_PF05 = PIN(5, GPIOF, 5); // 144 only
+const mcu_pin_obj_t pin_PF06 = PIN(5, GPIOF, 6); // 144 only
+const mcu_pin_obj_t pin_PF07 = PIN(5, GPIOF, 7); // 144 only
+const mcu_pin_obj_t pin_PF08 = PIN(5, GPIOF, 8); // 144 only
+const mcu_pin_obj_t pin_PF09 = PIN(5, GPIOF, 9); // 144 only
+const mcu_pin_obj_t pin_PF10 = PIN(5, GPIOF, 10); // 144 only
+
+const mcu_pin_obj_t pin_PC00 = PIN(2, GPIOC, 0);
+const mcu_pin_obj_t pin_PC01 = PIN(2, GPIOC, 1);
+const mcu_pin_obj_t pin_PC02 = PIN(2, GPIOC, 2);
+const mcu_pin_obj_t pin_PC03 = PIN(2, GPIOC, 3);
+
+const mcu_pin_obj_t pin_PA00 = PIN(0, GPIOA, 0);
+const mcu_pin_obj_t pin_PA01 = PIN(0, GPIOA, 1);
+const mcu_pin_obj_t pin_PA02 = PIN(0, GPIOA, 2);
+const mcu_pin_obj_t pin_PA03 = PIN(0, GPIOA, 3);
+const mcu_pin_obj_t pin_PA04 = PIN(0, GPIOA, 4);
+const mcu_pin_obj_t pin_PA05 = PIN(0, GPIOA, 5);
+const mcu_pin_obj_t pin_PA06 = PIN(0, GPIOA, 6);
+const mcu_pin_obj_t pin_PA07 = PIN(0, GPIOA, 7);
+
+const mcu_pin_obj_t pin_PC04 = PIN(2, GPIOC, 4);
+const mcu_pin_obj_t pin_PC05 = PIN(2, GPIOC, 5);
+
+const mcu_pin_obj_t pin_PB00 = PIN(1, GPIOB, 0);
+const mcu_pin_obj_t pin_PB01 = PIN(1, GPIOB, 1);
+const mcu_pin_obj_t pin_PB02 = PIN(1, GPIOB, 2);
+
+const mcu_pin_obj_t pin_PF11 = PIN(5, GPIOF, 11); // 144 only
+const mcu_pin_obj_t pin_PF12 = PIN(5, GPIOF, 12); // 144 only
+const mcu_pin_obj_t pin_PF13 = PIN(5, GPIOF, 13); // 144 only
+const mcu_pin_obj_t pin_PF14 = PIN(5, GPIOF, 14); // 144 only
+const mcu_pin_obj_t pin_PF15 = PIN(5, GPIOF, 15); // 144 only
+
+const mcu_pin_obj_t pin_PG00 = PIN(6, GPIOG, 0); // 144 only
+const mcu_pin_obj_t pin_PG01 = PIN(6, GPIOG, 1); // 144 only
+
+const mcu_pin_obj_t pin_PE07 = PIN(4, GPIOE, 7);
+const mcu_pin_obj_t pin_PE08 = PIN(4, GPIOE, 8);
+const mcu_pin_obj_t pin_PE09 = PIN(4, GPIOE, 9);
+const mcu_pin_obj_t pin_PE10 = PIN(4, GPIOE, 10);
+const mcu_pin_obj_t pin_PE11 = PIN(4, GPIOE, 11);
+const mcu_pin_obj_t pin_PE12 = PIN(4, GPIOE, 12);
+const mcu_pin_obj_t pin_PE13 = PIN(4, GPIOE, 13);
+const mcu_pin_obj_t pin_PE14 = PIN(4, GPIOE, 14);
+const mcu_pin_obj_t pin_PE15 = PIN(4, GPIOE, 15);
+
+const mcu_pin_obj_t pin_PB10 = PIN(1, GPIOB, 10);
+const mcu_pin_obj_t pin_PB12 = PIN(1, GPIOB, 12);
+const mcu_pin_obj_t pin_PB11 = PIN(1, GPIOB, 11); // 144 only
+const mcu_pin_obj_t pin_PB13 = PIN(1, GPIOB, 13);
+const mcu_pin_obj_t pin_PB14 = PIN(1, GPIOB, 14);
+const mcu_pin_obj_t pin_PB15 = PIN(1, GPIOB, 15);
+
+const mcu_pin_obj_t pin_PD08 = PIN(3, GPIOD, 8);
+const mcu_pin_obj_t pin_PD09 = PIN(3, GPIOD, 9);
+const mcu_pin_obj_t pin_PD10 = PIN(3, GPIOD, 10);
+const mcu_pin_obj_t pin_PD11 = PIN(3, GPIOD, 11);
+const mcu_pin_obj_t pin_PD12 = PIN(3, GPIOD, 12);
+const mcu_pin_obj_t pin_PD13 = PIN(3, GPIOD, 13);
+const mcu_pin_obj_t pin_PD14 = PIN(3, GPIOD, 14);
+const mcu_pin_obj_t pin_PD15 = PIN(3, GPIOD, 15);
+
+const mcu_pin_obj_t pin_PG02 = PIN(6, GPIOG, 2); // 144 only
+const mcu_pin_obj_t pin_PG03 = PIN(6, GPIOG, 3); // 144 only
+const mcu_pin_obj_t pin_PG04 = PIN(6, GPIOG, 4); // 144 only
+const mcu_pin_obj_t pin_PG05 = PIN(6, GPIOG, 5); // 144 only
+const mcu_pin_obj_t pin_PG06 = PIN(6, GPIOG, 6); // 144 only
+const mcu_pin_obj_t pin_PG07 = PIN(6, GPIOG, 7); // 144 only
+const mcu_pin_obj_t pin_PG08 = PIN(6, GPIOG, 8); // 144 only
+
+const mcu_pin_obj_t pin_PC06 = PIN(2, GPIOC, 6);
+const mcu_pin_obj_t pin_PC07 = PIN(2, GPIOC, 7);
+const mcu_pin_obj_t pin_PC08 = PIN(2, GPIOC, 8);
+const mcu_pin_obj_t pin_PC09 = PIN(2, GPIOC, 9);
+
+const mcu_pin_obj_t pin_PA08 = PIN(0, GPIOA, 8);
+const mcu_pin_obj_t pin_PA09 = PIN(0, GPIOA, 9);
+const mcu_pin_obj_t pin_PA10 = PIN(0, GPIOA, 10);
+const mcu_pin_obj_t pin_PA11 = PIN(0, GPIOA, 11);
+const mcu_pin_obj_t pin_PA12 = PIN(0, GPIOA, 12);
+const mcu_pin_obj_t pin_PA13 = PIN(0, GPIOA, 13);
+const mcu_pin_obj_t pin_PA14 = PIN(0, GPIOA, 14);
+const mcu_pin_obj_t pin_PA15 = PIN(0, GPIOA, 15);
+
+const mcu_pin_obj_t pin_PC10 = PIN(2, GPIOC, 10);
+const mcu_pin_obj_t pin_PC11 = PIN(2, GPIOC, 11);
+const mcu_pin_obj_t pin_PC12 = PIN(2, GPIOC, 12);
+
+const mcu_pin_obj_t pin_PD00 = PIN(3, GPIOD, 0);
+const mcu_pin_obj_t pin_PD01 = PIN(3, GPIOD, 1);
+const mcu_pin_obj_t pin_PD02 = PIN(3, GPIOD, 2);
+const mcu_pin_obj_t pin_PD03 = PIN(3, GPIOD, 3);
+const mcu_pin_obj_t pin_PD04 = PIN(3, GPIOD, 4);
+const mcu_pin_obj_t pin_PD05 = PIN(3, GPIOD, 5);
+const mcu_pin_obj_t pin_PD06 = PIN(3, GPIOD, 6);
+const mcu_pin_obj_t pin_PD07 = PIN(3, GPIOD, 7);
+
+const mcu_pin_obj_t pin_PG09 = PIN(6, GPIOG, 9); // 144 only
+const mcu_pin_obj_t pin_PG10 = PIN(6, GPIOG, 10); // 144 only
+const mcu_pin_obj_t pin_PG11 = PIN(6, GPIOG, 11); // 144 only
+const mcu_pin_obj_t pin_PG12 = PIN(6, GPIOG, 12); // 144 only
+const mcu_pin_obj_t pin_PG13 = PIN(6, GPIOG, 13); // 144 only
+const mcu_pin_obj_t pin_PG14 = PIN(6, GPIOG, 14); // 144 only
+const mcu_pin_obj_t pin_PG15 = PIN(6, GPIOG, 15); // 144 only
+
+const mcu_pin_obj_t pin_PB03 = PIN(1, GPIOB, 3);
+const mcu_pin_obj_t pin_PB04 = PIN(1, GPIOB, 4);
+const mcu_pin_obj_t pin_PB05 = PIN(1, GPIOB, 5);
+const mcu_pin_obj_t pin_PB06 = PIN(1, GPIOB, 6);
+const mcu_pin_obj_t pin_PB07 = PIN(1, GPIOB, 7);
+const mcu_pin_obj_t pin_PB08 = PIN(1, GPIOB, 8);
+const mcu_pin_obj_t pin_PB09 = PIN(1, GPIOB, 9);
+
+const mcu_pin_obj_t pin_PE00 = PIN(4, GPIOE, 0);
+const mcu_pin_obj_t pin_PE01 = PIN(4, GPIOE, 1); \ No newline at end of file
diff --git a/ports/stm32f4/peripherals/stm32f4/stm32f412zx/pins.h b/ports/stm32f4/peripherals/stm32f4/stm32f412zx/pins.h
new file mode 100644
index 000000000..a74bf7c5d
--- /dev/null
+++ b/ports/stm32f4/peripherals/stm32f4/stm32f412zx/pins.h
@@ -0,0 +1,156 @@
+/*
+ * 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_STM32F4_PERIPHERALS_STM32F412ZG_PINS_H
+#define MICROPY_INCLUDED_STM32F4_PERIPHERALS_STM32F412ZG_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;
+//pg 51
+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_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_PB10;
+extern const mcu_pin_obj_t pin_PB11; // 144 only
+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_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_PD00;
+extern const mcu_pin_obj_t pin_PD01;
+extern const mcu_pin_obj_t pin_PD02;
+extern const mcu_pin_obj_t pin_PD03;
+extern const mcu_pin_obj_t pin_PD04;
+extern const mcu_pin_obj_t pin_PD05;
+extern const mcu_pin_obj_t pin_PD06;
+extern const mcu_pin_obj_t pin_PD07;
+//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_PE00;
+extern const mcu_pin_obj_t pin_PE01;
+
+#endif // MICROPY_INCLUDED_STM32F4_PERIPHERALS_STM32F412ZG_PINS_H
diff --git a/ports/stm32f4/qstrdefsport.h b/ports/stm32f4/qstrdefsport.h
new file mode 100644
index 000000000..3ba897069
--- /dev/null
+++ b/ports/stm32f4/qstrdefsport.h
@@ -0,0 +1 @@
+// qstrs specific to this port
diff --git a/ports/stm32f4/stm32f4 b/ports/stm32f4/stm32f4
new file mode 160000
+Subproject 12411ade32aeec4e49c969d8d095463b0c2fb1f
diff --git a/ports/stm32f4/supervisor/cpu.s b/ports/stm32f4/supervisor/cpu.s
new file mode 100755
index 000000000..9e6807a5e
--- /dev/null
+++ b/ports/stm32f4/supervisor/cpu.s
@@ -0,0 +1,27 @@
+.syntax unified
+.cpu cortex-m4
+.thumb
+.text
+.align 2
+
+@ uint cpu_get_regs_and_sp(r0=uint regs[10])
+.global cpu_get_regs_and_sp
+.thumb
+.thumb_func
+.type cpu_get_regs_and_sp, %function
+cpu_get_regs_and_sp:
+@ store registers into given array
+str r4, [r0], #4
+str r5, [r0], #4
+str r6, [r0], #4
+str r7, [r0], #4
+str r8, [r0], #4
+str r9, [r0], #4
+str r10, [r0], #4
+str r11, [r0], #4
+str r12, [r0], #4
+str r13, [r0], #4
+
+@ return the sp
+mov r0, sp
+bx lr
diff --git a/ports/stm32f4/supervisor/internal_flash.c b/ports/stm32f4/supervisor/internal_flash.c
new file mode 100644
index 000000000..fa776ae1d
--- /dev/null
+++ b/ports/stm32f4/supervisor/internal_flash.c
@@ -0,0 +1,73 @@
+/*
+ * 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.
+ */
+#include "supervisor/flash.h"
+
+#include <stdint.h>
+#include <string.h>
+
+#include "extmod/vfs.h"
+#include "extmod/vfs_fat.h"
+#include "py/mphal.h"
+#include "py/obj.h"
+#include "py/runtime.h"
+#include "lib/oofatfs/ff.h"
+
+
+/*------------------------------------------------------------------*/
+/* Internal Flash API
+ *------------------------------------------------------------------*/
+static inline uint32_t lba2addr(uint32_t block) {
+}
+
+void supervisor_flash_init(void) {
+}
+
+uint32_t supervisor_flash_get_block_size(void) {
+ return FILESYSTEM_BLOCK_SIZE;
+}
+
+uint32_t supervisor_flash_get_block_count(void) {
+ return false;
+}
+
+void supervisor_flash_flush(void) {
+
+}
+
+mp_uint_t supervisor_flash_read_blocks(uint8_t *dest, uint32_t block, uint32_t num_blocks) {
+
+ return 0; // success
+}
+
+mp_uint_t supervisor_flash_write_blocks(const uint8_t *src, uint32_t lba, uint32_t num_blocks) {
+
+
+ return 0; // success
+}
+
+void supervisor_flash_release_cache(void) {
+}
+
diff --git a/ports/stm32f4/supervisor/internal_flash.h b/ports/stm32f4/supervisor/internal_flash.h
new file mode 100644
index 000000000..8c015a3e4
--- /dev/null
+++ b/ports/stm32f4/supervisor/internal_flash.h
@@ -0,0 +1,37 @@
+/*
+ * 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.
+ */
+#ifndef MICROPY_INCLUDED_STM32F4_INTERNAL_FLASH_H
+#define MICROPY_INCLUDED_STM32F4_INTERNAL_FLASH_H
+
+#include <stdbool.h>
+#include <stdint.h>
+
+#include "py/mpconfig.h"
+
+#define INTERNAL_FLASH_SYSTICK_MASK (0x1ff) // 512ms
+#define INTERNAL_FLASH_IDLE_TICK(tick) (((tick) & INTERNAL_FLASH_SYSTICK_MASK) == 2)
+
+#endif // MICROPY_INCLUDED_STM32F4_INTERNAL_FLASH_H
diff --git a/ports/stm32f4/supervisor/internal_flash_root_pointers.h b/ports/stm32f4/supervisor/internal_flash_root_pointers.h
new file mode 100644
index 000000000..7a8681bd9
--- /dev/null
+++ b/ports/stm32f4/supervisor/internal_flash_root_pointers.h
@@ -0,0 +1,31 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2018 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.
+ */
+#ifndef MICROPY_INCLUDED_STM32F4_INTERNAL_FLASH_ROOT_POINTERS_H
+#define MICROPY_INCLUDED_STM32F4_INTERNAL_FLASH_ROOT_POINTERS_H
+
+#define FLASH_ROOT_POINTERS
+
+#endif // MICROPY_INCLUDED_STM32F4_INTERNAL_FLASH_ROOT_POINTERS_H
diff --git a/ports/stm32f4/supervisor/port.c b/ports/stm32f4/supervisor/port.c
new file mode 100644
index 000000000..af4d1b8d8
--- /dev/null
+++ b/ports/stm32f4/supervisor/port.c
@@ -0,0 +1,80 @@
+/*
+ * 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) 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 <stdint.h>
+#include "supervisor/port.h"
+#include "boards/board.h"
+#include "tick.h"
+
+#include "stm32f4/clocks.h"
+#include "stm32f4/gpio.h"
+
+#include "stm32f4xx_hal.h"
+
+//#include "shared-bindings/rtc/__init__.h"
+
+static void power_warning_handler(void) {
+ reset_into_safe_mode(BROWNOUT);
+}
+
+safe_mode_t port_init(void) {
+ HAL_Init();
+
+ stm32f4_peripherals_clocks_init();
+ stm32f4_peripherals_gpio_init();
+
+ tick_init();
+ board_init();
+
+ return NO_SAFE_MODE;
+}
+
+void reset_port(void) {
+
+}
+
+void reset_to_bootloader(void) {
+
+}
+
+void reset_cpu(void) {
+
+}
+
+extern uint32_t _ebss;
+// Place the word to save just after our BSS section that gets blanked.
+void port_set_saved_word(uint32_t value) {
+ _ebss = value;
+}
+
+uint32_t port_get_saved_word(void) {
+ return _ebss;
+}
+
+// void HardFault_Handler(void) {
+
+// }
diff --git a/ports/stm32f4/supervisor/qspi_flash.c b/ports/stm32f4/supervisor/qspi_flash.c
new file mode 100644
index 000000000..f3915273b
--- /dev/null
+++ b/ports/stm32f4/supervisor/qspi_flash.c
@@ -0,0 +1,162 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2018 hathach for Adafruit Industries
+ * Copyright (c) 2018 Scott Shawcroft for Adafruit Industries
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include "supervisor/spi_flash_api.h"
+
+#include <stdint.h>
+#include <string.h>
+
+#include "py/mpconfig.h" // for EXTERNAL_FLASH_QSPI_DUAL
+//#include "nrfx_qspi.h"
+
+//#include "shared-bindings/microcontroller/__init__.h"
+
+#include "supervisor/shared/external_flash/common_commands.h"
+#include "supervisor/shared/external_flash/qspi_flash.h"
+
+bool spi_flash_command(uint8_t command) {
+ // nrf_qspi_cinstr_conf_t cinstr_cfg = {
+ // .opcode = command,
+ // .length = 1,
+ // .io2_level = true,
+ // .io3_level = true,
+ // .wipwait = false,
+ // .wren = false
+ // };
+ return false; //nrfx_qspi_cinstr_xfer(&cinstr_cfg, NULL, NULL) == NRFX_SUCCESS;
+}
+
+bool spi_flash_read_command(uint8_t command, uint8_t* response, uint32_t length) {
+ // nrf_qspi_cinstr_conf_t cinstr_cfg = {
+ // .opcode = command,
+ // .length = length + 1,
+ // .io2_level = true,
+ // .io3_level = true,
+ // .wipwait = false,
+ // .wren = false
+ // };
+ // return nrfx_qspi_cinstr_xfer(&cinstr_cfg, NULL, response) == NRFX_SUCCESS;
+ return false;
+
+}
+
+bool spi_flash_write_command(uint8_t command, uint8_t* data, uint32_t length) {
+ // nrf_qspi_cinstr_conf_t cinstr_cfg = {
+ // .opcode = command,
+ // .length = length + 1,
+ // .io2_level = true,
+ // .io3_level = true,
+ // .wipwait = false,
+ // .wren = false // We do this manually.
+ // };
+ // return nrfx_qspi_cinstr_xfer(&cinstr_cfg, data, NULL) == NRFX_SUCCESS;
+ return false;
+}
+
+bool spi_flash_sector_command(uint8_t command, uint32_t address) {
+ // if (command != CMD_SECTOR_ERASE) {
+ // return false;
+ // }
+ // return nrfx_qspi_erase(NRF_QSPI_ERASE_LEN_4KB, address) == NRFX_SUCCESS;
+ return false;
+}
+
+bool spi_flash_write_data(uint32_t address, uint8_t* data, uint32_t length) {
+ // return nrfx_qspi_write(data, length, address) == NRFX_SUCCESS;
+ return false;
+}
+
+bool spi_flash_read_data(uint32_t address, uint8_t* data, uint32_t length) {
+ // return nrfx_qspi_read(data, length, address) == NRFX_SUCCESS;
+ return false;
+}
+
+void spi_flash_init(void) {
+ // Init QSPI flash
+// nrfx_qspi_config_t qspi_cfg = {
+// .xip_offset = 0,
+// .pins = {
+// .sck_pin = MICROPY_QSPI_SCK,
+// .csn_pin = MICROPY_QSPI_CS,
+// .io0_pin = MICROPY_QSPI_DATA0,
+// .io1_pin = NRF_QSPI_PIN_NOT_CONNECTED,
+// .io2_pin = NRF_QSPI_PIN_NOT_CONNECTED,
+// .io3_pin = NRF_QSPI_PIN_NOT_CONNECTED,
+
+// },
+// .prot_if = {
+// .readoc = NRF_QSPI_READOC_FASTREAD,
+// .writeoc = NRF_QSPI_WRITEOC_PP,
+// .addrmode = NRF_QSPI_ADDRMODE_24BIT,
+// .dpmconfig = false
+// },
+// .phy_if = {
+// .sck_freq = NRF_QSPI_FREQ_32MDIV16, // Start at a slow 2MHz and speed up once we know what we're talking to.
+// .sck_delay = 10, // min time CS must stay high before going low again. in unit of 62.5 ns
+// .spi_mode = NRF_QSPI_MODE_0,
+// .dpmen = false
+// },
+// .irq_priority = 7,
+// };
+
+// #if EXTERNAL_FLASH_QSPI_DUAL
+// qspi_cfg.pins.io1_pin = MICROPY_QSPI_DATA1;
+// qspi_cfg.prot_if.readoc = NRF_QSPI_READOC_READ2O;
+// qspi_cfg.prot_if.writeoc = NRF_QSPI_WRITEOC_PP2O;
+// #else
+// qspi_cfg.pins.io1_pin = MICROPY_QSPI_DATA1;
+// qspi_cfg.pins.io2_pin = MICROPY_QSPI_DATA2;
+// qspi_cfg.pins.io3_pin = MICROPY_QSPI_DATA3;
+// qspi_cfg.prot_if.readoc = NRF_QSPI_READOC_READ4IO;
+// qspi_cfg.prot_if.writeoc = NRF_QSPI_WRITEOC_PP4O;
+// #endif
+
+// // No callback for blocking API
+// nrfx_qspi_init(&qspi_cfg, NULL, NULL);
+}
+
+void spi_flash_init_device(const external_flash_device* device) {
+ // check_quad_enable(device);
+
+ // // Switch to single output line if the device doesn't support quad programs.
+ // if (!device->supports_qspi_writes) {
+ // NRF_QSPI->IFCONFIG0 &= ~QSPI_IFCONFIG0_WRITEOC_Msk;
+ // NRF_QSPI->IFCONFIG0 |= QSPI_IFCONFIG0_WRITEOC_PP << QSPI_IFCONFIG0_WRITEOC_Pos;
+ // }
+
+ // // Speed up as much as we can.
+ // // Start at 16 MHz and go down.
+ // // At 32 MHz GD25Q16C doesn't work reliably on Feather 52840, even though it should work up to 104 MHz.
+ // // sckfreq = 0 is 32 Mhz
+ // // sckfreq = 1 is 16 MHz, etc.
+ // uint8_t sckfreq = 1;
+ // while (32000000 / (sckfreq + 1) > device->max_clock_speed_mhz * 1000000 && sckfreq < 16) {
+ // sckfreq += 1;
+ // }
+ // NRF_QSPI->IFCONFIG1 &= ~QSPI_IFCONFIG1_SCKFREQ_Msk;
+ // NRF_QSPI->IFCONFIG1 |= sckfreq << QSPI_IFCONFIG1_SCKFREQ_Pos;
+}
diff --git a/ports/stm32f4/supervisor/serial.c b/ports/stm32f4/supervisor/serial.c
new file mode 100644
index 000000000..3154dc3e5
--- /dev/null
+++ b/ports/stm32f4/supervisor/serial.c
@@ -0,0 +1,75 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2017, 2018 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 "py/mphal.h"
+#include <string.h>
+#include "supervisor/serial.h"
+#include "stm32f4xx_hal.h"
+
+UART_HandleTypeDef huart2;
+
+void serial_init(void) {
+ huart2.Instance = USART2;
+ huart2.Init.BaudRate = 9600;
+ huart2.Init.WordLength = UART_WORDLENGTH_8B;
+ huart2.Init.StopBits = UART_STOPBITS_1;
+ huart2.Init.Parity = UART_PARITY_NONE;
+ huart2.Init.Mode = UART_MODE_TX_RX;
+ huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE;
+ huart2.Init.OverSampling = UART_OVERSAMPLING_16;
+ if (HAL_UART_Init(&huart2) == HAL_OK)
+ {
+ //HAL_GPIO_WritePin(GPIOE, GPIO_PIN_1, GPIO_PIN_RESET);
+ }
+ //HAL_UART_Transmit(&huart2, (uint8_t*)"Serial On", 9, 5000);
+ //HAL_GPIO_WritePin(GPIOE, GPIO_PIN_2, GPIO_PIN_RESET);
+}
+
+bool serial_connected(void) {
+ return true;
+}
+
+char serial_read(void) {
+ uint8_t data;
+ HAL_UART_Receive(&huart2, &data, 1,5000);
+ return data;
+}
+
+bool serial_bytes_available(void) {
+ return __HAL_UART_GET_FLAG(&huart2, UART_FLAG_RXNE);
+}
+
+void serial_write(const char* text) {
+ serial_write_substring(text, strlen(text));
+}
+
+void serial_write_substring(const char *text, uint32_t len) {
+ if (len == 0) {
+ return;
+ }
+ HAL_UART_Transmit(&huart2, (uint8_t*)text, len, 5000);
+}
+
diff --git a/ports/stm32f4/supervisor/usb.c b/ports/stm32f4/supervisor/usb.c
new file mode 100644
index 000000000..913523523
--- /dev/null
+++ b/ports/stm32f4/supervisor/usb.c
@@ -0,0 +1,80 @@
+/*
+ * This file is part of the Micro Python project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2018 hathach 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 "tick.h"
+#include "supervisor/usb.h"
+#include "lib/utils/interrupt_char.h"
+#include "lib/mp-readline/readline.h"
+#include "stm32f4xx_hal.h"
+
+#define USB_OTGFS_VBUS_Pin GPIO_PIN_9
+#define USB_OTGFS_VBUS_GPIO_Port GPIOA
+#define USB_OTGFS_ID_Pin GPIO_PIN_10
+#define USB_OTGFS_ID_GPIO_Port GPIOA
+#define USB_OTGFS_DM_Pin GPIO_PIN_11
+#define USB_OTGFS_DM_GPIO_Port GPIOA
+#define USB_OTGFS_DP_Pin GPIO_PIN_12
+#define USB_OTGFS_DP_GPIO_Port GPIOA
+
+
+void init_usb_hardware(void) {
+ // HAL_GPIO_WritePin(GPIOE, GPIO_PIN_1, GPIO_PIN_RESET); //LED 2
+ GPIO_InitTypeDef GPIO_InitStruct = {0};
+ /**USB_OTG_FS GPIO Configuration
+ PA10 ------> USB_OTG_FS_ID
+ PA11 ------> USB_OTG_FS_DM
+ PA12 ------> USB_OTG_FS_DP
+ */
+ GPIO_InitStruct.Pin = USB_OTGFS_VBUS_Pin;
+ GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ HAL_GPIO_Init(USB_OTGFS_VBUS_GPIO_Port, &GPIO_InitStruct);
+
+ GPIO_InitStruct.Pin = USB_OTGFS_DM_Pin|USB_OTGFS_DP_Pin;
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
+ GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS;
+ HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
+
+ //TinyUSB suggestion
+ GPIO_InitStruct.Pin = USB_OTGFS_ID_Pin;
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
+ GPIO_InitStruct.Pull = GPIO_PULLUP;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
+ GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS;
+ HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
+
+ /* Peripheral clock enable */
+ __HAL_RCC_USB_OTG_FS_CLK_ENABLE();
+
+ /* Peripheral interrupt init */
+ HAL_NVIC_SetPriority(OTG_FS_IRQn, 0, 0);
+ HAL_NVIC_EnableIRQ(OTG_FS_IRQn);
+
+ //HAL_GPIO_WritePin(GPIOE, GPIO_PIN_2, GPIO_PIN_RESET); //LED 3
+}
diff --git a/ports/stm32f4/system_stm32f4xx.c b/ports/stm32f4/system_stm32f4xx.c
new file mode 100644
index 000000000..3303f969d
--- /dev/null
+++ b/ports/stm32f4/system_stm32f4xx.c
@@ -0,0 +1,761 @@
+/**
+ ******************************************************************************
+ * @file system_stm32f4xx.c
+ * @author MCD Application Team
+ * @brief CMSIS Cortex-M4 Device Peripheral Access Layer System Source File.
+ *
+ * This file provides two functions and one global variable to be called from
+ * user application:
+ * - SystemInit(): This function is called at startup just after reset and
+ * before branch to main program. This call is made inside
+ * the "startup_stm32f4xx.s" file.
+ *
+ * - SystemCoreClock variable: Contains the core clock (HCLK), it can be used
+ * by the user application to setup the SysTick
+ * timer or configure other parameters.
+ *
+ * - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must
+ * be called whenever the core clock is changed
+ * during program execution.
+ *
+ *
+ ******************************************************************************
+ * @attention
+ *
+ * <h2><center>&copy; COPYRIGHT 2017 STMicroelectronics</center></h2>
+ *
+ * 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 STMicroelectronics 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.
+ *
+ ******************************************************************************
+ */
+
+/** @addtogroup CMSIS
+ * @{
+ */
+
+/** @addtogroup stm32f4xx_system
+ * @{
+ */
+
+/** @addtogroup STM32F4xx_System_Private_Includes
+ * @{
+ */
+
+
+#include "stm32f4xx.h"
+
+#if !defined (HSE_VALUE)
+ #define HSE_VALUE ((uint32_t)25000000) /*!< Default value of the External oscillator in Hz */
+#endif /* HSE_VALUE */
+
+#if !defined (HSI_VALUE)
+ #define HSI_VALUE ((uint32_t)16000000) /*!< Value of the Internal oscillator in Hz*/
+#endif /* HSI_VALUE */
+
+/**
+ * @}
+ */
+
+/** @addtogroup STM32F4xx_System_Private_TypesDefinitions
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @addtogroup STM32F4xx_System_Private_Defines
+ * @{
+ */
+
+/************************* Miscellaneous Configuration ************************/
+/*!< Uncomment the following line if you need to use external SRAM or SDRAM as data memory */
+#if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx)\
+ || defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)\
+ || defined(STM32F469xx) || defined(STM32F479xx) || defined(STM32F412Zx) || defined(STM32F412Vx)
+/* #define DATA_IN_ExtSRAM */
+#endif /* STM32F40xxx || STM32F41xxx || STM32F42xxx || STM32F43xxx || STM32F469xx || STM32F479xx ||\
+ STM32F412Zx || STM32F412Vx */
+
+#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)\
+ || defined(STM32F446xx) || defined(STM32F469xx) || defined(STM32F479xx)
+/* #define DATA_IN_ExtSDRAM */
+#endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F446xx || STM32F469xx ||\
+ STM32F479xx */
+
+/*!< Uncomment the following line if you need to relocate your vector Table in
+ Internal SRAM. */
+/* #define VECT_TAB_SRAM */
+#define VECT_TAB_OFFSET 0x00 /*!< Vector Table base offset field.
+ This value must be a multiple of 0x200. */
+/******************************************************************************/
+
+/**
+ * @}
+ */
+
+/** @addtogroup STM32F4xx_System_Private_Macros
+ * @{
+ */
+
+/**
+ * @}
+ */
+
+/** @addtogroup STM32F4xx_System_Private_Variables
+ * @{
+ */
+ /* This variable is updated in three ways:
+ 1) by calling CMSIS function SystemCoreClockUpdate()
+ 2) by calling HAL API function HAL_RCC_GetHCLKFreq()
+ 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency
+ Note: If you use this function to configure the system clock; then there
+ is no need to call the 2 first functions listed above, since SystemCoreClock
+ variable is updated automatically.
+ */
+uint32_t SystemCoreClock = 16000000;
+const uint8_t AHBPrescTable[16] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7, 8, 9};
+const uint8_t APBPrescTable[8] = {0, 0, 0, 0, 1, 2, 3, 4};
+/**
+ * @}
+ */
+
+/** @addtogroup STM32F4xx_System_Private_FunctionPrototypes
+ * @{
+ */
+
+#if defined (DATA_IN_ExtSRAM) || defined (DATA_IN_ExtSDRAM)
+ static void SystemInit_ExtMemCtl(void);
+#endif /* DATA_IN_ExtSRAM || DATA_IN_ExtSDRAM */
+
+/**
+ * @}
+ */
+
+/** @addtogroup STM32F4xx_System_Private_Functions
+ * @{
+ */
+
+/**
+ * @brief Setup the microcontroller system
+ * Initialize the FPU setting, vector table location and External memory
+ * configuration.
+ * @param None
+ * @retval None
+ */
+void SystemInit(void)
+{
+ /* FPU settings ------------------------------------------------------------*/
+ #if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
+ SCB->CPACR |= ((3UL << 10*2)|(3UL << 11*2)); /* set CP10 and CP11 Full Access */
+ #endif
+ /* Reset the RCC clock configuration to the default reset state ------------*/
+ /* Set HSION bit */
+ RCC->CR |= (uint32_t)0x00000001;
+
+ /* Reset CFGR register */
+ RCC->CFGR = 0x00000000;
+
+ /* Reset HSEON, CSSON and PLLON bits */
+ RCC->CR &= (uint32_t)0xFEF6FFFF;
+
+ /* Reset PLLCFGR register */
+ RCC->PLLCFGR = 0x24003010;
+
+ /* Reset HSEBYP bit */
+ RCC->CR &= (uint32_t)0xFFFBFFFF;
+
+ /* Disable all interrupts */
+ RCC->CIR = 0x00000000;
+
+#if defined (DATA_IN_ExtSRAM) || defined (DATA_IN_ExtSDRAM)
+ SystemInit_ExtMemCtl();
+#endif /* DATA_IN_ExtSRAM || DATA_IN_ExtSDRAM */
+
+ /* Configure the Vector Table location add offset address ------------------*/
+#ifdef VECT_TAB_SRAM
+ SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */
+#else
+ SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */
+#endif
+}
+
+/**
+ * @brief Update SystemCoreClock variable according to Clock Register Values.
+ * The SystemCoreClock variable contains the core clock (HCLK), it can
+ * be used by the user application to setup the SysTick timer or configure
+ * other parameters.
+ *
+ * @note Each time the core clock (HCLK) changes, this function must be called
+ * to update SystemCoreClock variable value. Otherwise, any configuration
+ * based on this variable will be incorrect.
+ *
+ * @note - The system frequency computed by this function is not the real
+ * frequency in the chip. It is calculated based on the predefined
+ * constant and the selected clock source:
+ *
+ * - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(*)
+ *
+ * - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(**)
+ *
+ * - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(**)
+ * or HSI_VALUE(*) multiplied/divided by the PLL factors.
+ *
+ * (*) HSI_VALUE is a constant defined in stm32f4xx_hal_conf.h file (default value
+ * 16 MHz) but the real value may vary depending on the variations
+ * in voltage and temperature.
+ *
+ * (**) HSE_VALUE is a constant defined in stm32f4xx_hal_conf.h file (its value
+ * depends on the application requirements), user has to ensure that HSE_VALUE
+ * is same as the real frequency of the crystal used. Otherwise, this function
+ * may have wrong result.
+ *
+ * - The result of this function could be not correct when using fractional
+ * value for HSE crystal.
+ *
+ * @param None
+ * @retval None
+ */
+void SystemCoreClockUpdate(void)
+{
+ uint32_t tmp = 0, pllvco = 0, pllp = 2, pllsource = 0, pllm = 2;
+
+ /* Get SYSCLK source -------------------------------------------------------*/
+ tmp = RCC->CFGR & RCC_CFGR_SWS;
+
+ switch (tmp)
+ {
+ case 0x00: /* HSI used as system clock source */
+ SystemCoreClock = HSI_VALUE;
+ break;
+ case 0x04: /* HSE used as system clock source */
+ SystemCoreClock = HSE_VALUE;
+ break;
+ case 0x08: /* PLL used as system clock source */
+
+ /* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLL_M) * PLL_N
+ SYSCLK = PLL_VCO / PLL_P
+ */
+ pllsource = (RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC) >> 22;
+ pllm = RCC->PLLCFGR & RCC_PLLCFGR_PLLM;
+
+ if (pllsource != 0)
+ {
+ /* HSE used as PLL clock source */
+ pllvco = (HSE_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6);
+ }
+ else
+ {
+ /* HSI used as PLL clock source */
+ pllvco = (HSI_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6);
+ }
+
+ pllp = (((RCC->PLLCFGR & RCC_PLLCFGR_PLLP) >>16) + 1 ) *2;
+ SystemCoreClock = pllvco/pllp;
+ break;
+ default:
+ SystemCoreClock = HSI_VALUE;
+ break;
+ }
+ /* Compute HCLK frequency --------------------------------------------------*/
+ /* Get HCLK prescaler */
+ tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4)];
+ /* HCLK frequency */
+ SystemCoreClock >>= tmp;
+}
+
+#if defined (DATA_IN_ExtSRAM) && defined (DATA_IN_ExtSDRAM)
+#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)\
+ || defined(STM32F469xx) || defined(STM32F479xx)
+/**
+ * @brief Setup the external memory controller.
+ * Called in startup_stm32f4xx.s before jump to main.
+ * This function configures the external memories (SRAM/SDRAM)
+ * This SRAM/SDRAM will be used as program data memory (including heap and stack).
+ * @param None
+ * @retval None
+ */
+void SystemInit_ExtMemCtl(void)
+{
+ __IO uint32_t tmp = 0x00;
+
+ register uint32_t tmpreg = 0, timeout = 0xFFFF;
+ register __IO uint32_t index;
+
+ /* Enable GPIOC, GPIOD, GPIOE, GPIOF, GPIOG, GPIOH and GPIOI interface clock */
+ RCC->AHB1ENR |= 0x000001F8;
+
+ /* Delay after an RCC peripheral clock enabling */
+ tmp = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOCEN);
+
+ /* Connect PDx pins to FMC Alternate function */
+ GPIOD->AFR[0] = 0x00CCC0CC;
+ GPIOD->AFR[1] = 0xCCCCCCCC;
+ /* Configure PDx pins in Alternate function mode */
+ GPIOD->MODER = 0xAAAA0A8A;
+ /* Configure PDx pins speed to 100 MHz */
+ GPIOD->OSPEEDR = 0xFFFF0FCF;
+ /* Configure PDx pins Output type to push-pull */
+ GPIOD->OTYPER = 0x00000000;
+ /* No pull-up, pull-down for PDx pins */
+ GPIOD->PUPDR = 0x00000000;
+
+ /* Connect PEx pins to FMC Alternate function */
+ GPIOE->AFR[0] = 0xC00CC0CC;
+ GPIOE->AFR[1] = 0xCCCCCCCC;
+ /* Configure PEx pins in Alternate function mode */
+ GPIOE->MODER = 0xAAAA828A;
+ /* Configure PEx pins speed to 100 MHz */
+ GPIOE->OSPEEDR = 0xFFFFC3CF;
+ /* Configure PEx pins Output type to push-pull */
+ GPIOE->OTYPER = 0x00000000;
+ /* No pull-up, pull-down for PEx pins */
+ GPIOE->PUPDR = 0x00000000;
+
+ /* Connect PFx pins to FMC Alternate function */
+ GPIOF->AFR[0] = 0xCCCCCCCC;
+ GPIOF->AFR[1] = 0xCCCCCCCC;
+ /* Configure PFx pins in Alternate function mode */
+ GPIOF->MODER = 0xAA800AAA;
+ /* Configure PFx pins speed to 50 MHz */
+ GPIOF->OSPEEDR = 0xAA800AAA;
+ /* Configure PFx pins Output type to push-pull */
+ GPIOF->OTYPER = 0x00000000;
+ /* No pull-up, pull-down for PFx pins */
+ GPIOF->PUPDR = 0x00000000;
+
+ /* Connect PGx pins to FMC Alternate function */
+ GPIOG->AFR[0] = 0xCCCCCCCC;
+ GPIOG->AFR[1] = 0xCCCCCCCC;
+ /* Configure PGx pins in Alternate function mode */
+ GPIOG->MODER = 0xAAAAAAAA;
+ /* Configure PGx pins speed to 50 MHz */
+ GPIOG->OSPEEDR = 0xAAAAAAAA;
+ /* Configure PGx pins Output type to push-pull */
+ GPIOG->OTYPER = 0x00000000;
+ /* No pull-up, pull-down for PGx pins */
+ GPIOG->PUPDR = 0x00000000;
+
+ /* Connect PHx pins to FMC Alternate function */
+ GPIOH->AFR[0] = 0x00C0CC00;
+ GPIOH->AFR[1] = 0xCCCCCCCC;
+ /* Configure PHx pins in Alternate function mode */
+ GPIOH->MODER = 0xAAAA08A0;
+ /* Configure PHx pins speed to 50 MHz */
+ GPIOH->OSPEEDR = 0xAAAA08A0;
+ /* Configure PHx pins Output type to push-pull */
+ GPIOH->OTYPER = 0x00000000;
+ /* No pull-up, pull-down for PHx pins */
+ GPIOH->PUPDR = 0x00000000;
+
+ /* Connect PIx pins to FMC Alternate function */
+ GPIOI->AFR[0] = 0xCCCCCCCC;
+ GPIOI->AFR[1] = 0x00000CC0;
+ /* Configure PIx pins in Alternate function mode */
+ GPIOI->MODER = 0x0028AAAA;
+ /* Configure PIx pins speed to 50 MHz */
+ GPIOI->OSPEEDR = 0x0028AAAA;
+ /* Configure PIx pins Output type to push-pull */
+ GPIOI->OTYPER = 0x00000000;
+ /* No pull-up, pull-down for PIx pins */
+ GPIOI->PUPDR = 0x00000000;
+
+/*-- FMC Configuration -------------------------------------------------------*/
+ /* Enable the FMC interface clock */
+ RCC->AHB3ENR |= 0x00000001;
+ /* Delay after an RCC peripheral clock enabling */
+ tmp = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN);
+
+ FMC_Bank5_6->SDCR[0] = 0x000019E4;
+ FMC_Bank5_6->SDTR[0] = 0x01115351;
+
+ /* SDRAM initialization sequence */
+ /* Clock enable command */
+ FMC_Bank5_6->SDCMR = 0x00000011;
+ tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
+ while((tmpreg != 0) && (timeout-- > 0))
+ {
+ tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
+ }
+
+ /* Delay */
+ for (index = 0; index<1000; index++);
+
+ /* PALL command */
+ FMC_Bank5_6->SDCMR = 0x00000012;
+ timeout = 0xFFFF;
+ while((tmpreg != 0) && (timeout-- > 0))
+ {
+ tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
+ }
+
+ /* Auto refresh command */
+ FMC_Bank5_6->SDCMR = 0x00000073;
+ timeout = 0xFFFF;
+ while((tmpreg != 0) && (timeout-- > 0))
+ {
+ tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
+ }
+
+ /* MRD register program */
+ FMC_Bank5_6->SDCMR = 0x00046014;
+ timeout = 0xFFFF;
+ while((tmpreg != 0) && (timeout-- > 0))
+ {
+ tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
+ }
+
+ /* Set refresh count */
+ tmpreg = FMC_Bank5_6->SDRTR;
+ FMC_Bank5_6->SDRTR = (tmpreg | (0x0000027C<<1));
+
+ /* Disable write protection */
+ tmpreg = FMC_Bank5_6->SDCR[0];
+ FMC_Bank5_6->SDCR[0] = (tmpreg & 0xFFFFFDFF);
+
+#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)
+ /* Configure and enable Bank1_SRAM2 */
+ FMC_Bank1->BTCR[2] = 0x00001011;
+ FMC_Bank1->BTCR[3] = 0x00000201;
+ FMC_Bank1E->BWTR[2] = 0x0fffffff;
+#endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */
+#if defined(STM32F469xx) || defined(STM32F479xx)
+ /* Configure and enable Bank1_SRAM2 */
+ FMC_Bank1->BTCR[2] = 0x00001091;
+ FMC_Bank1->BTCR[3] = 0x00110212;
+ FMC_Bank1E->BWTR[2] = 0x0fffffff;
+#endif /* STM32F469xx || STM32F479xx */
+
+ (void)(tmp);
+}
+#endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */
+#elif defined (DATA_IN_ExtSRAM) || defined (DATA_IN_ExtSDRAM)
+/**
+ * @brief Setup the external memory controller.
+ * Called in startup_stm32f4xx.s before jump to main.
+ * This function configures the external memories (SRAM/SDRAM)
+ * This SRAM/SDRAM will be used as program data memory (including heap and stack).
+ * @param None
+ * @retval None
+ */
+void SystemInit_ExtMemCtl(void)
+{
+ __IO uint32_t tmp = 0x00;
+#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)\
+ || defined(STM32F446xx) || defined(STM32F469xx) || defined(STM32F479xx)
+#if defined (DATA_IN_ExtSDRAM)
+ register uint32_t tmpreg = 0, timeout = 0xFFFF;
+ register __IO uint32_t index;
+
+#if defined(STM32F446xx)
+ /* Enable GPIOA, GPIOC, GPIOD, GPIOE, GPIOF, GPIOG interface
+ clock */
+ RCC->AHB1ENR |= 0x0000007D;
+#else
+ /* Enable GPIOC, GPIOD, GPIOE, GPIOF, GPIOG, GPIOH and GPIOI interface
+ clock */
+ RCC->AHB1ENR |= 0x000001F8;
+#endif /* STM32F446xx */
+ /* Delay after an RCC peripheral clock enabling */
+ tmp = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOCEN);
+
+#if defined(STM32F446xx)
+ /* Connect PAx pins to FMC Alternate function */
+ GPIOA->AFR[0] |= 0xC0000000;
+ GPIOA->AFR[1] |= 0x00000000;
+ /* Configure PDx pins in Alternate function mode */
+ GPIOA->MODER |= 0x00008000;
+ /* Configure PDx pins speed to 50 MHz */
+ GPIOA->OSPEEDR |= 0x00008000;
+ /* Configure PDx pins Output type to push-pull */
+ GPIOA->OTYPER |= 0x00000000;
+ /* No pull-up, pull-down for PDx pins */
+ GPIOA->PUPDR |= 0x00000000;
+
+ /* Connect PCx pins to FMC Alternate function */
+ GPIOC->AFR[0] |= 0x00CC0000;
+ GPIOC->AFR[1] |= 0x00000000;
+ /* Configure PDx pins in Alternate function mode */
+ GPIOC->MODER |= 0x00000A00;
+ /* Configure PDx pins speed to 50 MHz */
+ GPIOC->OSPEEDR |= 0x00000A00;
+ /* Configure PDx pins Output type to push-pull */
+ GPIOC->OTYPER |= 0x00000000;
+ /* No pull-up, pull-down for PDx pins */
+ GPIOC->PUPDR |= 0x00000000;
+#endif /* STM32F446xx */
+
+ /* Connect PDx pins to FMC Alternate function */
+ GPIOD->AFR[0] = 0x000000CC;
+ GPIOD->AFR[1] = 0xCC000CCC;
+ /* Configure PDx pins in Alternate function mode */
+ GPIOD->MODER = 0xA02A000A;
+ /* Configure PDx pins speed to 50 MHz */
+ GPIOD->OSPEEDR = 0xA02A000A;
+ /* Configure PDx pins Output type to push-pull */
+ GPIOD->OTYPER = 0x00000000;
+ /* No pull-up, pull-down for PDx pins */
+ GPIOD->PUPDR = 0x00000000;
+
+ /* Connect PEx pins to FMC Alternate function */
+ GPIOE->AFR[0] = 0xC00000CC;
+ GPIOE->AFR[1] = 0xCCCCCCCC;
+ /* Configure PEx pins in Alternate function mode */
+ GPIOE->MODER = 0xAAAA800A;
+ /* Configure PEx pins speed to 50 MHz */
+ GPIOE->OSPEEDR = 0xAAAA800A;
+ /* Configure PEx pins Output type to push-pull */
+ GPIOE->OTYPER = 0x00000000;
+ /* No pull-up, pull-down for PEx pins */
+ GPIOE->PUPDR = 0x00000000;
+
+ /* Connect PFx pins to FMC Alternate function */
+ GPIOF->AFR[0] = 0xCCCCCCCC;
+ GPIOF->AFR[1] = 0xCCCCCCCC;
+ /* Configure PFx pins in Alternate function mode */
+ GPIOF->MODER = 0xAA800AAA;
+ /* Configure PFx pins speed to 50 MHz */
+ GPIOF->OSPEEDR = 0xAA800AAA;
+ /* Configure PFx pins Output type to push-pull */
+ GPIOF->OTYPER = 0x00000000;
+ /* No pull-up, pull-down for PFx pins */
+ GPIOF->PUPDR = 0x00000000;
+
+ /* Connect PGx pins to FMC Alternate function */
+ GPIOG->AFR[0] = 0xCCCCCCCC;
+ GPIOG->AFR[1] = 0xCCCCCCCC;
+ /* Configure PGx pins in Alternate function mode */
+ GPIOG->MODER = 0xAAAAAAAA;
+ /* Configure PGx pins speed to 50 MHz */
+ GPIOG->OSPEEDR = 0xAAAAAAAA;
+ /* Configure PGx pins Output type to push-pull */
+ GPIOG->OTYPER = 0x00000000;
+ /* No pull-up, pull-down for PGx pins */
+ GPIOG->PUPDR = 0x00000000;
+
+#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)\
+ || defined(STM32F469xx) || defined(STM32F479xx)
+ /* Connect PHx pins to FMC Alternate function */
+ GPIOH->AFR[0] = 0x00C0CC00;
+ GPIOH->AFR[1] = 0xCCCCCCCC;
+ /* Configure PHx pins in Alternate function mode */
+ GPIOH->MODER = 0xAAAA08A0;
+ /* Configure PHx pins speed to 50 MHz */
+ GPIOH->OSPEEDR = 0xAAAA08A0;
+ /* Configure PHx pins Output type to push-pull */
+ GPIOH->OTYPER = 0x00000000;
+ /* No pull-up, pull-down for PHx pins */
+ GPIOH->PUPDR = 0x00000000;
+
+ /* Connect PIx pins to FMC Alternate function */
+ GPIOI->AFR[0] = 0xCCCCCCCC;
+ GPIOI->AFR[1] = 0x00000CC0;
+ /* Configure PIx pins in Alternate function mode */
+ GPIOI->MODER = 0x0028AAAA;
+ /* Configure PIx pins speed to 50 MHz */
+ GPIOI->OSPEEDR = 0x0028AAAA;
+ /* Configure PIx pins Output type to push-pull */
+ GPIOI->OTYPER = 0x00000000;
+ /* No pull-up, pull-down for PIx pins */
+ GPIOI->PUPDR = 0x00000000;
+#endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */
+
+/*-- FMC Configuration -------------------------------------------------------*/
+ /* Enable the FMC interface clock */
+ RCC->AHB3ENR |= 0x00000001;
+ /* Delay after an RCC peripheral clock enabling */
+ tmp = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN);
+
+ /* Configure and enable SDRAM bank1 */
+#if defined(STM32F446xx)
+ FMC_Bank5_6->SDCR[0] = 0x00001954;
+#else
+ FMC_Bank5_6->SDCR[0] = 0x000019E4;
+#endif /* STM32F446xx */
+ FMC_Bank5_6->SDTR[0] = 0x01115351;
+
+ /* SDRAM initialization sequence */
+ /* Clock enable command */
+ FMC_Bank5_6->SDCMR = 0x00000011;
+ tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
+ while((tmpreg != 0) && (timeout-- > 0))
+ {
+ tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
+ }
+
+ /* Delay */
+ for (index = 0; index<1000; index++);
+
+ /* PALL command */
+ FMC_Bank5_6->SDCMR = 0x00000012;
+ timeout = 0xFFFF;
+ while((tmpreg != 0) && (timeout-- > 0))
+ {
+ tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
+ }
+
+ /* Auto refresh command */
+#if defined(STM32F446xx)
+ FMC_Bank5_6->SDCMR = 0x000000F3;
+#else
+ FMC_Bank5_6->SDCMR = 0x00000073;
+#endif /* STM32F446xx */
+ timeout = 0xFFFF;
+ while((tmpreg != 0) && (timeout-- > 0))
+ {
+ tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
+ }
+
+ /* MRD register program */
+#if defined(STM32F446xx)
+ FMC_Bank5_6->SDCMR = 0x00044014;
+#else
+ FMC_Bank5_6->SDCMR = 0x00046014;
+#endif /* STM32F446xx */
+ timeout = 0xFFFF;
+ while((tmpreg != 0) && (timeout-- > 0))
+ {
+ tmpreg = FMC_Bank5_6->SDSR & 0x00000020;
+ }
+
+ /* Set refresh count */
+ tmpreg = FMC_Bank5_6->SDRTR;
+#if defined(STM32F446xx)
+ FMC_Bank5_6->SDRTR = (tmpreg | (0x0000050C<<1));
+#else
+ FMC_Bank5_6->SDRTR = (tmpreg | (0x0000027C<<1));
+#endif /* STM32F446xx */
+
+ /* Disable write protection */
+ tmpreg = FMC_Bank5_6->SDCR[0];
+ FMC_Bank5_6->SDCR[0] = (tmpreg & 0xFFFFFDFF);
+#endif /* DATA_IN_ExtSDRAM */
+#endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F446xx || STM32F469xx || STM32F479xx */
+
+#if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx)\
+ || defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)\
+ || defined(STM32F469xx) || defined(STM32F479xx) || defined(STM32F412Zx) || defined(STM32F412Vx)
+
+#if defined(DATA_IN_ExtSRAM)
+/*-- GPIOs Configuration -----------------------------------------------------*/
+ /* Enable GPIOD, GPIOE, GPIOF and GPIOG interface clock */
+ RCC->AHB1ENR |= 0x00000078;
+ /* Delay after an RCC peripheral clock enabling */
+ tmp = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIODEN);
+
+ /* Connect PDx pins to FMC Alternate function */
+ GPIOD->AFR[0] = 0x00CCC0CC;
+ GPIOD->AFR[1] = 0xCCCCCCCC;
+ /* Configure PDx pins in Alternate function mode */
+ GPIOD->MODER = 0xAAAA0A8A;
+ /* Configure PDx pins speed to 100 MHz */
+ GPIOD->OSPEEDR = 0xFFFF0FCF;
+ /* Configure PDx pins Output type to push-pull */
+ GPIOD->OTYPER = 0x00000000;
+ /* No pull-up, pull-down for PDx pins */
+ GPIOD->PUPDR = 0x00000000;
+
+ /* Connect PEx pins to FMC Alternate function */
+ GPIOE->AFR[0] = 0xC00CC0CC;
+ GPIOE->AFR[1] = 0xCCCCCCCC;
+ /* Configure PEx pins in Alternate function mode */
+ GPIOE->MODER = 0xAAAA828A;
+ /* Configure PEx pins speed to 100 MHz */
+ GPIOE->OSPEEDR = 0xFFFFC3CF;
+ /* Configure PEx pins Output type to push-pull */
+ GPIOE->OTYPER = 0x00000000;
+ /* No pull-up, pull-down for PEx pins */
+ GPIOE->PUPDR = 0x00000000;
+
+ /* Connect PFx pins to FMC Alternate function */
+ GPIOF->AFR[0] = 0x00CCCCCC;
+ GPIOF->AFR[1] = 0xCCCC0000;
+ /* Configure PFx pins in Alternate function mode */
+ GPIOF->MODER = 0xAA000AAA;
+ /* Configure PFx pins speed to 100 MHz */
+ GPIOF->OSPEEDR = 0xFF000FFF;
+ /* Configure PFx pins Output type to push-pull */
+ GPIOF->OTYPER = 0x00000000;
+ /* No pull-up, pull-down for PFx pins */
+ GPIOF->PUPDR = 0x00000000;
+
+ /* Connect PGx pins to FMC Alternate function */
+ GPIOG->AFR[0] = 0x00CCCCCC;
+ GPIOG->AFR[1] = 0x000000C0;
+ /* Configure PGx pins in Alternate function mode */
+ GPIOG->MODER = 0x00085AAA;
+ /* Configure PGx pins speed to 100 MHz */
+ GPIOG->OSPEEDR = 0x000CAFFF;
+ /* Configure PGx pins Output type to push-pull */
+ GPIOG->OTYPER = 0x00000000;
+ /* No pull-up, pull-down for PGx pins */
+ GPIOG->PUPDR = 0x00000000;
+
+/*-- FMC/FSMC Configuration --------------------------------------------------*/
+ /* Enable the FMC/FSMC interface clock */
+ RCC->AHB3ENR |= 0x00000001;
+
+#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)
+ /* Delay after an RCC peripheral clock enabling */
+ tmp = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN);
+ /* Configure and enable Bank1_SRAM2 */
+ FMC_Bank1->BTCR[2] = 0x00001011;
+ FMC_Bank1->BTCR[3] = 0x00000201;
+ FMC_Bank1E->BWTR[2] = 0x0fffffff;
+#endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */
+#if defined(STM32F469xx) || defined(STM32F479xx)
+ /* Delay after an RCC peripheral clock enabling */
+ tmp = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FMCEN);
+ /* Configure and enable Bank1_SRAM2 */
+ FMC_Bank1->BTCR[2] = 0x00001091;
+ FMC_Bank1->BTCR[3] = 0x00110212;
+ FMC_Bank1E->BWTR[2] = 0x0fffffff;
+#endif /* STM32F469xx || STM32F479xx */
+#if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx)|| defined(STM32F417xx)\
+ || defined(STM32F412Zx) || defined(STM32F412Vx)
+ /* Delay after an RCC peripheral clock enabling */
+ tmp = READ_BIT(RCC->AHB3ENR, RCC_AHB3ENR_FSMCEN);
+ /* Configure and enable Bank1_SRAM2 */
+ FSMC_Bank1->BTCR[2] = 0x00001011;
+ FSMC_Bank1->BTCR[3] = 0x00000201;
+ FSMC_Bank1E->BWTR[2] = 0x0FFFFFFF;
+#endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F412Zx || STM32F412Vx */
+
+#endif /* DATA_IN_ExtSRAM */
+#endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F427xx || STM32F437xx ||\
+ STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx || STM32F412Zx || STM32F412Vx */
+ (void)(tmp);
+}
+#endif /* DATA_IN_ExtSRAM && DATA_IN_ExtSDRAM */
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/ports/stm32f4/tick.c b/ports/stm32f4/tick.c
new file mode 100644
index 000000000..5bd2da6ed
--- /dev/null
+++ b/ports/stm32f4/tick.c
@@ -0,0 +1,85 @@
+/*
+ * 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 "tick.h"
+
+#include "supervisor/shared/autoreload.h"
+#include "supervisor/filesystem.h"
+#include "shared-module/gamepad/__init__.h"
+#include "shared-bindings/microcontroller/Processor.h"
+
+#include "stm32f4xx.h"
+
+// Global millisecond tick count
+volatile uint64_t ticks_ms = 0;
+
+void SysTick_Handler(void) {
+ // SysTick interrupt handler called when the SysTick timer reaches zero
+ // (every millisecond).
+ ticks_ms += 1;
+
+#if CIRCUITPY_FILESYSTEM_FLUSH_INTERVAL_MS > 0
+ filesystem_tick();
+#endif
+#ifdef CIRCUITPY_AUTORELOAD_DELAY_MS
+ autoreload_tick();
+#endif
+#ifdef CIRCUITPY_GAMEPAD_TICKS
+ if (!(ticks_ms & CIRCUITPY_GAMEPAD_TICKS)) {
+ gamepad_tick();
+ }
+#endif
+}
+
+void tick_init() {
+ uint32_t ticks_per_ms = SystemCoreClock/ 1000;
+ SysTick_Config(ticks_per_ms); // interrupt is enabled
+}
+
+void tick_delay(uint32_t us) {
+ uint32_t ticks_per_us = SystemCoreClock / 1000 / 1000;
+ uint32_t us_between_ticks = SysTick->VAL / ticks_per_us;
+ uint64_t start_ms = ticks_ms;
+ while (us > 1000) {
+ while (ticks_ms == start_ms) {}
+ us -= us_between_ticks;
+ start_ms = ticks_ms;
+ us_between_ticks = 1000;
+ }
+ while (SysTick->VAL > ((us_between_ticks - us) * ticks_per_us)) {}
+}
+
+// us counts down!
+void current_tick(uint64_t* ms, uint32_t* us_until_ms) {
+ uint32_t ticks_per_us = SystemCoreClock / 1000 / 1000;
+ *ms = ticks_ms;
+ *us_until_ms = SysTick->VAL / ticks_per_us;
+}
+
+void wait_until(uint64_t ms, uint32_t us_until_ms) {
+ uint32_t ticks_per_us = SystemCoreClock / 1000 / 1000;
+ while(ticks_ms <= ms && SysTick->VAL / ticks_per_us >= us_until_ms) {}
+}
diff --git a/ports/stm32f4/tick.h b/ports/stm32f4/tick.h
new file mode 100644
index 000000000..e4772fa2c
--- /dev/null
+++ b/ports/stm32f4/tick.h
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ */
+#ifndef MICROPY_INCLUDED_STM32F4_TICK_H
+#define MICROPY_INCLUDED_STM32F4_TICK_H
+
+#include "py/mpconfig.h"
+
+#include <stdint.h>
+
+extern volatile uint64_t ticks_ms;
+
+extern struct timer_descriptor ms_timer;
+
+void tick_init(void);
+
+void tick_delay(uint32_t us);
+
+void current_tick(uint64_t* ms, uint32_t* us_until_ms);
+// Do not call this with interrupts disabled because it may be waiting for
+// ticks_ms to increment.
+void wait_until(uint64_t ms, uint32_t us_until_ms);
+
+#endif // MICROPY_INCLUDED_STM32F4_TICK_H
diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk
index 28d90dfea..bdefc18cc 100644
--- a/py/circuitpy_defns.mk
+++ b/py/circuitpy_defns.mk
@@ -108,6 +108,9 @@ endif
ifeq ($(CIRCUITPY_AUDIOIO),1)
SRC_PATTERNS += audioio/%
endif
+ifeq ($(CIRCUITPY_AUDIOCORE),1)
+SRC_PATTERNS += audiocore/%
+endif
ifeq ($(CIRCUITPY_BITBANGIO),1)
SRC_PATTERNS += bitbangio/%
endif
@@ -224,7 +227,7 @@ $(filter $(SRC_PATTERNS), \
audioio/AudioOut.c \
bleio/__init__.c \
bleio/Adapter.c \
- bleio/Broadcaster.c \
+ bleio/Central.c \
bleio/Characteristic.c \
bleio/CharacteristicBuffer.c \
bleio/Descriptor.c \
@@ -289,8 +292,6 @@ SRC_BINDINGS_ENUMS += \
SRC_BINDINGS_ENUMS += \
$(filter $(SRC_PATTERNS), \
bleio/Address.c \
- bleio/AddressType.c \
- bleio/AdvertisementData.c \
bleio/ScanEntry.c \
)
@@ -303,20 +304,24 @@ $(filter $(SRC_PATTERNS), \
_stage/Text.c \
_stage/__init__.c \
audioio/__init__.c \
- audioio/Mixer.c \
- audioio/RawSample.c \
- audioio/WaveFile.c \
+ audiocore/__init__.c \
+ audiocore/Mixer.c \
+ audiocore/RawSample.c \
+ audiocore/WaveFile.c \
bitbangio/I2C.c \
bitbangio/OneWire.c \
bitbangio/SPI.c \
bitbangio/__init__.c \
board/__init__.c \
+ bleio/Address.c \
+ bleio/ScanEntry.c \
busio/OneWire.c \
displayio/Bitmap.c \
displayio/ColorConverter.c \
displayio/Display.c \
displayio/FourWire.c \
displayio/Group.c \
+ displayio/I2CDisplay.c \
displayio/OnDiskBitmap.c \
displayio/Palette.c \
displayio/Shape.c \
diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h
index 2026185ef..3440eb052 100644
--- a/py/circuitpy_mpconfig.h
+++ b/py/circuitpy_mpconfig.h
@@ -230,6 +230,13 @@ extern const struct _mp_obj_module_t audiobusio_module;
#define AUDIOBUSIO_MODULE
#endif
+#if CIRCUITPY_AUDIOCORE
+#define AUDIOCORE_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_audiocore), (mp_obj_t)&audiocore_module },
+extern const struct _mp_obj_module_t audiocore_module;
+#else
+#define AUDIOCORE_MODULE
+#endif
+
#if CIRCUITPY_AUDIOIO
#define AUDIOIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_audioio), (mp_obj_t)&audioio_module },
extern const struct _mp_obj_module_t audioio_module;
@@ -564,6 +571,7 @@ extern const struct _mp_obj_module_t ustack_module;
#define MICROPY_PORT_BUILTIN_MODULES_STRONG_LINKS \
ANALOGIO_MODULE \
AUDIOBUSIO_MODULE \
+ AUDIOCORE_MODULE \
AUDIOIO_MODULE \
BITBANGIO_MODULE \
BLEIO_MODULE \
diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk
index 47303a73a..772a1c3e1 100644
--- a/py/circuitpy_mpconfig.mk
+++ b/py/circuitpy_mpconfig.mk
@@ -41,13 +41,26 @@ ifndef CIRCUITPY_FULL_BUILD
endif
endif
+# Setting CIRCUITPY_MINIMAL_BUILD = 1 will disable all features
+# Use for for early stage or highly restricted ports
+ifndef CIRCUITPY_DEFAULT_BUILD
+ ifeq ($(CIRCUITPY_MINIMAL_BUILD),1)
+ CIRCUITPY_FULL_BUILD = 0
+ CIRCUITPY_DEFAULT_BUILD = 0
+ else
+ CIRCUITPY_DEFAULT_BUILD = 1
+ endif
+endif
+
+
+
# All builtin modules are listed below, with default values (0 for off, 1 for on)
# Some are always on, some are always off, and some depend on CIRCUITPY_FULL_BUILD.
#
# *** You can override any of the defaults by defining them in your mpconfigboard.mk.
ifndef CIRCUITPY_ANALOGIO
-CIRCUITPY_ANALOGIO = 1
+CIRCUITPY_ANALOGIO = $(CIRCUITPY_DEFAULT_BUILD)
endif
CFLAGS += -DCIRCUITPY_ANALOGIO=$(CIRCUITPY_ANALOGIO)
@@ -61,6 +74,11 @@ CIRCUITPY_AUDIOIO = $(CIRCUITPY_FULL_BUILD)
endif
CFLAGS += -DCIRCUITPY_AUDIOIO=$(CIRCUITPY_AUDIOIO)
+ifndef CIRCUITPY_AUDIOCORE
+CIRCUITPY_AUDIOCORE = $(CIRCUITPY_AUDIOIO)
+endif
+CFLAGS += -DCIRCUITPY_AUDIOCORE=$(CIRCUITPY_AUDIOCORE)
+
ifndef CIRCUITPY_BITBANGIO
CIRCUITPY_BITBANGIO = $(CIRCUITPY_FULL_BUILD)
endif
@@ -73,17 +91,17 @@ endif
CFLAGS += -DCIRCUITPY_BLEIO=$(CIRCUITPY_BLEIO)
ifndef CIRCUITPY_BOARD
-CIRCUITPY_BOARD = 1
+CIRCUITPY_BOARD = $(CIRCUITPY_DEFAULT_BUILD)
endif
CFLAGS += -DCIRCUITPY_BOARD=$(CIRCUITPY_BOARD)
ifndef CIRCUITPY_BUSIO
-CIRCUITPY_BUSIO = 1
+CIRCUITPY_BUSIO = $(CIRCUITPY_DEFAULT_BUILD)
endif
CFLAGS += -DCIRCUITPY_BUSIO=$(CIRCUITPY_BUSIO)
ifndef CIRCUITPY_DIGITALIO
-CIRCUITPY_DIGITALIO = 1
+CIRCUITPY_DIGITALIO = $(CIRCUITPY_DEFAULT_BUILD)
endif
CFLAGS += -DCIRCUITPY_DIGITALIO=$(CIRCUITPY_DIGITALIO)
@@ -113,17 +131,17 @@ endif
CFLAGS += -DCIRCUITPY_I2CSLAVE=$(CIRCUITPY_I2CSLAVE)
ifndef CIRCUITPY_MATH
-CIRCUITPY_MATH = 1
+CIRCUITPY_MATH = $(CIRCUITPY_DEFAULT_BUILD)
endif
CFLAGS += -DCIRCUITPY_MATH=$(CIRCUITPY_MATH)
ifndef CIRCUITPY_MICROCONTROLLER
-CIRCUITPY_MICROCONTROLLER = 1
+CIRCUITPY_MICROCONTROLLER = $(CIRCUITPY_DEFAULT_BUILD)
endif
CFLAGS += -DCIRCUITPY_MICROCONTROLLER=$(CIRCUITPY_MICROCONTROLLER)
ifndef CIRCUITPY_NEOPIXEL_WRITE
-CIRCUITPY_NEOPIXEL_WRITE = 1
+CIRCUITPY_NEOPIXEL_WRITE = $(CIRCUITPY_DEFAULT_BUILD)
endif
CFLAGS += -DCIRCUITPY_NEOPIXEL_WRITE=$(CIRCUITPY_NEOPIXEL_WRITE)
@@ -134,12 +152,12 @@ endif
CFLAGS += -DCIRCUITPY_NETWORK=$(CIRCUITPY_NETWORK)
ifndef CIRCUITPY_NVM
-CIRCUITPY_NVM = 1
+CIRCUITPY_NVM = $(CIRCUITPY_DEFAULT_BUILD)
endif
CFLAGS += -DCIRCUITPY_NVM=$(CIRCUITPY_NVM)
ifndef CIRCUITPY_OS
-CIRCUITPY_OS = 1
+CIRCUITPY_OS = $(CIRCUITPY_DEFAULT_BUILD)
endif
CFLAGS += -DCIRCUITPY_OS=$(CIRCUITPY_OS)
@@ -149,7 +167,7 @@ endif
CFLAGS += -DCIRCUITPY_PIXELBUF=$(CIRCUITPY_PIXELBUF)
ifndef CIRCUITPY_PULSEIO
-CIRCUITPY_PULSEIO = 1
+CIRCUITPY_PULSEIO = $(CIRCUITPY_DEFAULT_BUILD)
endif
CFLAGS += -DCIRCUITPY_PULSEIO=$(CIRCUITPY_PULSEIO)
@@ -160,17 +178,17 @@ endif
CFLAGS += -DCIRCUITPY_PS2IO=$(CIRCUITPY_PS2IO)
ifndef CIRCUITPY_RANDOM
-CIRCUITPY_RANDOM = 1
+CIRCUITPY_RANDOM = $(CIRCUITPY_DEFAULT_BUILD)
endif
CFLAGS += -DCIRCUITPY_RANDOM=$(CIRCUITPY_RANDOM)
ifndef CIRCUITPY_ROTARYIO
-CIRCUITPY_ROTARYIO = 1
+CIRCUITPY_ROTARYIO = $(CIRCUITPY_DEFAULT_BUILD)
endif
CFLAGS += -DCIRCUITPY_ROTARYIO=$(CIRCUITPY_ROTARYIO)
ifndef CIRCUITPY_RTC
-CIRCUITPY_RTC = 1
+CIRCUITPY_RTC = $(CIRCUITPY_DEFAULT_BUILD)
endif
CFLAGS += -DCIRCUITPY_RTC=$(CIRCUITPY_RTC)
@@ -189,27 +207,27 @@ endif
CFLAGS += -DCIRCUITPY_STAGE=$(CIRCUITPY_STAGE)
ifndef CIRCUITPY_STORAGE
-CIRCUITPY_STORAGE = 1
+CIRCUITPY_STORAGE = $(CIRCUITPY_DEFAULT_BUILD)
endif
CFLAGS += -DCIRCUITPY_STORAGE=$(CIRCUITPY_STORAGE)
ifndef CIRCUITPY_STRUCT
-CIRCUITPY_STRUCT = 1
+CIRCUITPY_STRUCT = $(CIRCUITPY_DEFAULT_BUILD)
endif
CFLAGS += -DCIRCUITPY_STRUCT=$(CIRCUITPY_STRUCT)
ifndef CIRCUITPY_SUPERVISOR
-CIRCUITPY_SUPERVISOR = 1
+CIRCUITPY_SUPERVISOR = $(CIRCUITPY_DEFAULT_BUILD)
endif
CFLAGS += -DCIRCUITPY_SUPERVISOR=$(CIRCUITPY_SUPERVISOR)
ifndef CIRCUITPY_TIME
-CIRCUITPY_TIME = 1
+CIRCUITPY_TIME = $(CIRCUITPY_DEFAULT_BUILD)
endif
CFLAGS += -DCIRCUITPY_TIME=$(CIRCUITPY_TIME)
ifndef CIRCUITPY_TOUCHIO
-CIRCUITPY_TOUCHIO = 1
+CIRCUITPY_TOUCHIO = $(CIRCUITPY_DEFAULT_BUILD)
endif
CFLAGS += -DCIRCUITPY_TOUCHIO=$(CIRCUITPY_TOUCHIO)
@@ -220,12 +238,12 @@ endif
CFLAGS += -DCIRCUITPY_UHEAP=$(CIRCUITPY_UHEAP)
ifndef CIRCUITPY_USB_HID
-CIRCUITPY_USB_HID = 1
+CIRCUITPY_USB_HID = $(CIRCUITPY_DEFAULT_BUILD)
endif
CFLAGS += -DCIRCUITPY_USB_HID=$(CIRCUITPY_USB_HID)
ifndef CIRCUITPY_USB_MIDI
-CIRCUITPY_USB_MIDI = 1
+CIRCUITPY_USB_MIDI = $(CIRCUITPY_DEFAULT_BUILD)
endif
CFLAGS += -DCIRCUITPY_USB_MIDI=$(CIRCUITPY_USB_MIDI)
diff --git a/py/obj.h b/py/obj.h
index 773043b59..6eead377d 100644
--- a/py/obj.h
+++ b/py/obj.h
@@ -763,6 +763,7 @@ void mp_obj_tuple_del(mp_obj_t self_in);
mp_int_t mp_obj_tuple_hash(mp_obj_t self_in);
// list
+mp_obj_t mp_obj_list_clear(mp_obj_t self_in);
mp_obj_t mp_obj_list_append(mp_obj_t self_in, mp_obj_t arg);
mp_obj_t mp_obj_list_remove(mp_obj_t self_in, mp_obj_t value);
void mp_obj_list_get(mp_obj_t self_in, size_t *len, mp_obj_t **items);
diff --git a/py/objlist.c b/py/objlist.c
index 16ca4b353..558c4c611 100644
--- a/py/objlist.c
+++ b/py/objlist.c
@@ -340,7 +340,7 @@ mp_obj_t mp_obj_list_sort(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_
return mp_const_none;
}
-STATIC mp_obj_t list_clear(mp_obj_t self_in) {
+mp_obj_t mp_obj_list_clear(mp_obj_t self_in) {
mp_check_self(MP_OBJ_IS_TYPE(self_in, &mp_type_list));
mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in);
self->len = 0;
@@ -418,7 +418,7 @@ STATIC mp_obj_t list_reverse(mp_obj_t self_in) {
STATIC MP_DEFINE_CONST_FUN_OBJ_2(list_append_obj, mp_obj_list_append);
STATIC MP_DEFINE_CONST_FUN_OBJ_2(list_extend_obj, list_extend);
-STATIC MP_DEFINE_CONST_FUN_OBJ_1(list_clear_obj, list_clear);
+STATIC MP_DEFINE_CONST_FUN_OBJ_1(list_clear_obj, mp_obj_list_clear);
STATIC MP_DEFINE_CONST_FUN_OBJ_1(list_copy_obj, list_copy);
STATIC MP_DEFINE_CONST_FUN_OBJ_2(list_count_obj, list_count);
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(list_index_obj, 2, 4, list_index);
diff --git a/shared-bindings/_stage/__init__.c b/shared-bindings/_stage/__init__.c
index 03775b1de..9f3f89462 100644
--- a/shared-bindings/_stage/__init__.c
+++ b/shared-bindings/_stage/__init__.c
@@ -95,7 +95,12 @@ STATIC mp_obj_t stage_render(size_t n_args, const mp_obj_t *args) {
MICROPY_VM_HOOK_LOOP ;
#endif
}
- displayio_display_set_region_to_update(display, x0, y0, x1, y1);
+ displayio_area_t area;
+ area.x1 = x0;
+ area.y1 = y0;
+ area.x2 = x1;
+ area.y2 = y1;
+ displayio_display_set_region_to_update(display, &area);
render_stage(x0, y0, x1, y1, layers, layers_size, buffer, buffer_size, display);
displayio_display_end_transaction(display);
diff --git a/shared-bindings/audioio/Mixer.c b/shared-bindings/audiocore/Mixer.c
index dce4b3955..b2f0a3fda 100644
--- a/shared-bindings/audioio/Mixer.c
+++ b/shared-bindings/audiocore/Mixer.c
@@ -23,7 +23,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
-#include "shared-bindings/audioio/Mixer.h"
+#include "shared-bindings/audiocore/Mixer.h"
#include <stdint.h>
@@ -32,7 +32,7 @@
#include "py/objproperty.h"
#include "py/runtime.h"
#include "shared-bindings/microcontroller/Pin.h"
-#include "shared-bindings/audioio/RawSample.h"
+#include "shared-bindings/audiocore/RawSample.h"
#include "shared-bindings/util.h"
#include "supervisor/shared/translate.h"
diff --git a/shared-bindings/audioio/Mixer.h b/shared-bindings/audiocore/Mixer.h
index 832072b8f..ef12f9a70 100644
--- a/shared-bindings/audioio/Mixer.h
+++ b/shared-bindings/audiocore/Mixer.h
@@ -28,8 +28,8 @@
#define MICROPY_INCLUDED_SHARED_BINDINGS_AUDIOIO_MIXER_H
#include "common-hal/microcontroller/Pin.h"
-#include "shared-module/audioio/Mixer.h"
-#include "shared-bindings/audioio/RawSample.h"
+#include "shared-module/audiocore/Mixer.h"
+#include "shared-bindings/audiocore/RawSample.h"
extern const mp_obj_type_t audioio_mixer_type;
diff --git a/shared-bindings/audioio/RawSample.c b/shared-bindings/audiocore/RawSample.c
index 62998f580..912b48bfb 100644
--- a/shared-bindings/audioio/RawSample.c
+++ b/shared-bindings/audiocore/RawSample.c
@@ -31,8 +31,8 @@
#include "py/objproperty.h"
#include "py/runtime.h"
#include "shared-bindings/microcontroller/Pin.h"
-#include "shared-bindings/audioio/AudioOut.h"
#include "shared-bindings/util.h"
+#include "shared-bindings/audiocore/RawSample.h"
#include "supervisor/shared/translate.h"
//| .. currentmodule:: audioio
diff --git a/shared-bindings/audioio/RawSample.h b/shared-bindings/audiocore/RawSample.h
index 0d764b77c..b02778cad 100644
--- a/shared-bindings/audioio/RawSample.h
+++ b/shared-bindings/audiocore/RawSample.h
@@ -27,9 +27,8 @@
#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_AUDIOIO_RAWSAMPLE_H
#define MICROPY_INCLUDED_SHARED_BINDINGS_AUDIOIO_RAWSAMPLE_H
-#include "common-hal/audioio/AudioOut.h"
#include "common-hal/microcontroller/Pin.h"
-#include "shared-module/audioio/RawSample.h"
+#include "shared-module/audiocore/RawSample.h"
extern const mp_obj_type_t audioio_rawsample_type;
diff --git a/shared-bindings/audioio/WaveFile.c b/shared-bindings/audiocore/WaveFile.c
index 242c915d3..4c1993b7c 100644
--- a/shared-bindings/audioio/WaveFile.c
+++ b/shared-bindings/audiocore/WaveFile.c
@@ -29,7 +29,7 @@
#include "lib/utils/context_manager_helpers.h"
#include "py/objproperty.h"
#include "py/runtime.h"
-#include "shared-bindings/audioio/WaveFile.h"
+#include "shared-bindings/audiocore/WaveFile.h"
#include "shared-bindings/util.h"
#include "supervisor/shared/translate.h"
diff --git a/shared-bindings/audioio/WaveFile.h b/shared-bindings/audiocore/WaveFile.h
index 62a4200dc..d2572318b 100644
--- a/shared-bindings/audioio/WaveFile.h
+++ b/shared-bindings/audiocore/WaveFile.h
@@ -27,10 +27,11 @@
#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_AUDIOIO_WAVEFILE_H
#define MICROPY_INCLUDED_SHARED_BINDINGS_AUDIOIO_WAVEFILE_H
-#include "common-hal/audioio/AudioOut.h"
-#include "common-hal/microcontroller/Pin.h"
+#include "py/obj.h"
#include "extmod/vfs_fat.h"
+#include "shared-module/audiocore/WaveFile.h"
+
extern const mp_obj_type_t audioio_wavefile_type;
void common_hal_audioio_wavefile_construct(audioio_wavefile_obj_t* self,
diff --git a/shared-bindings/audiocore/__init__.c b/shared-bindings/audiocore/__init__.c
new file mode 100644
index 000000000..c64759d4f
--- /dev/null
+++ b/shared-bindings/audiocore/__init__.c
@@ -0,0 +1,69 @@
+/*
+ * 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 <stdint.h>
+
+#include "py/obj.h"
+#include "py/runtime.h"
+
+#include "shared-bindings/microcontroller/Pin.h"
+#include "shared-bindings/audiocore/__init__.h"
+#include "shared-bindings/audiocore/Mixer.h"
+#include "shared-bindings/audiocore/RawSample.h"
+#include "shared-bindings/audiocore/WaveFile.h"
+
+//| :mod:`audiocore` --- Support for audio samples and mixer
+//| ========================================================
+//|
+//| .. module:: audiocore
+//| :synopsis: Support for audio samples and mixer
+//| :platform: SAMD21
+//|
+//| The `audiocore` module contains core classes for audio IO
+//|
+//| Libraries
+//|
+//| .. toctree::
+//| :maxdepth: 3
+//|
+//| Mixer
+//| RawSample
+//| WaveFile
+//|
+
+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_Mixer), MP_ROM_PTR(&audioio_mixer_type) },
+ { MP_ROM_QSTR(MP_QSTR_RawSample), MP_ROM_PTR(&audioio_rawsample_type) },
+ { MP_ROM_QSTR(MP_QSTR_WaveFile), MP_ROM_PTR(&audioio_wavefile_type) },
+};
+
+STATIC MP_DEFINE_CONST_DICT(audiocore_module_globals, audiocore_module_globals_table);
+
+const mp_obj_module_t audiocore_module = {
+ .base = { &mp_type_module },
+ .globals = (mp_obj_dict_t*)&audiocore_module_globals,
+};
diff --git a/shared-bindings/bleio/AdvertisementData.h b/shared-bindings/audiocore/__init__.h
index 05b5a2c8d..02437cd13 100644
--- a/shared-bindings/bleio/AdvertisementData.h
+++ b/shared-bindings/audiocore/__init__.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2018 Artur Pacholec
+ * 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
@@ -24,11 +24,11 @@
* THE SOFTWARE.
*/
-#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_ADVERTISEMENTDATA_H
-#define MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_ADVERTISEMENTDATA_H
+#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_AUDIOCORE___INIT___H
+#define MICROPY_INCLUDED_SHARED_BINDINGS_AUDIOCORE___INIT___H
#include "py/obj.h"
-extern const mp_obj_type_t bleio_advertisementdata_type;
+// Nothing now.
-#endif // MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_ADVERTISEMENTDATA_H
+#endif // MICROPY_INCLUDED_SHARED_BINDINGS_AUDIOCORE___INIT___H
diff --git a/shared-bindings/audioio/AudioOut.c b/shared-bindings/audioio/AudioOut.c
index 571dcdaca..79df66f7d 100644
--- a/shared-bindings/audioio/AudioOut.c
+++ b/shared-bindings/audioio/AudioOut.c
@@ -32,7 +32,7 @@
#include "py/runtime.h"
#include "shared-bindings/microcontroller/Pin.h"
#include "shared-bindings/audioio/AudioOut.h"
-#include "shared-bindings/audioio/RawSample.h"
+#include "shared-bindings/audiocore/RawSample.h"
#include "shared-bindings/util.h"
#include "supervisor/shared/translate.h"
diff --git a/shared-bindings/audioio/AudioOut.h b/shared-bindings/audioio/AudioOut.h
index d09a5c9ca..1076ac5cc 100644
--- a/shared-bindings/audioio/AudioOut.h
+++ b/shared-bindings/audioio/AudioOut.h
@@ -29,7 +29,7 @@
#include "common-hal/audioio/AudioOut.h"
#include "common-hal/microcontroller/Pin.h"
-#include "shared-bindings/audioio/RawSample.h"
+#include "shared-bindings/audiocore/RawSample.h"
extern const mp_obj_type_t audioio_audioout_type;
diff --git a/shared-bindings/audioio/__init__.c b/shared-bindings/audioio/__init__.c
index 4786b6425..3fecf2708 100644
--- a/shared-bindings/audioio/__init__.c
+++ b/shared-bindings/audioio/__init__.c
@@ -32,9 +32,6 @@
#include "shared-bindings/microcontroller/Pin.h"
#include "shared-bindings/audioio/__init__.h"
#include "shared-bindings/audioio/AudioOut.h"
-#include "shared-bindings/audioio/Mixer.h"
-#include "shared-bindings/audioio/RawSample.h"
-#include "shared-bindings/audioio/WaveFile.h"
//| :mod:`audioio` --- Support for audio input and output
//| ======================================================
@@ -51,22 +48,19 @@
//| :maxdepth: 3
//|
//| AudioOut
-//| Mixer
-//| RawSample
-//| WaveFile
//|
//| All classes change hardware state and should be deinitialized when they
//| are no longer needed if the program continues after use. To do so, either
//| call :py:meth:`!deinit` or use a context manager. See
//| :ref:`lifetime-and-contextmanagers` for more info.
//|
+//| Since CircuitPython 5, `Mixer`, `RawSample` and `WaveFile` are moved
+//| to :mod:`audiocore`.
+//|
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) },
- { MP_ROM_QSTR(MP_QSTR_Mixer), MP_ROM_PTR(&audioio_mixer_type) },
- { MP_ROM_QSTR(MP_QSTR_RawSample), MP_ROM_PTR(&audioio_rawsample_type) },
- { MP_ROM_QSTR(MP_QSTR_WaveFile), MP_ROM_PTR(&audioio_wavefile_type) },
};
STATIC MP_DEFINE_CONST_DICT(audioio_module_globals, audioio_module_globals_table);
diff --git a/shared-bindings/bleio/Adapter.c b/shared-bindings/bleio/Adapter.c
index d9449d3ab..7b8df5103 100644
--- a/shared-bindings/bleio/Adapter.c
+++ b/shared-bindings/bleio/Adapter.c
@@ -3,6 +3,7 @@
*
* The MIT License (MIT)
*
+ * Copyright (c) 2018 Dan Halbert for Adafruit Industries
* Copyright (c) 2018 Artur Pacholec
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
diff --git a/shared-bindings/bleio/Adapter.h b/shared-bindings/bleio/Adapter.h
index fe3886e59..de9d1d6db 100644
--- a/shared-bindings/bleio/Adapter.h
+++ b/shared-bindings/bleio/Adapter.h
@@ -3,6 +3,7 @@
*
* The MIT License (MIT)
*
+ * Copyright (c) 2018 Dan Halbert for Adafruit Industries
* Copyright (c) 2018 Artur Pacholec
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
diff --git a/shared-bindings/bleio/Address.c b/shared-bindings/bleio/Address.c
index b7c76b7b2..37f01042c 100644
--- a/shared-bindings/bleio/Address.c
+++ b/shared-bindings/bleio/Address.c
@@ -3,6 +3,7 @@
*
* The MIT License (MIT)
*
+ * Copyright (c) 2019 Dan Halbert for Adafruit Industries
* Copyright (c) 2018 Artur Pacholec
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -33,13 +34,6 @@
#include "shared-bindings/bleio/Address.h"
#include "shared-module/bleio/Address.h"
-#define ADDRESS_BYTE_LEN 12
-
-STATIC uint8_t xdigit_8b_value(byte nibble1, byte nibble2) {
- return unichar_xdigit_value(nibble1) | (unichar_xdigit_value(nibble2) << 4);
-}
-
-
//| .. currentmodule:: bleio
//|
//| :class:`Address` -- BLE address
@@ -48,31 +42,20 @@ STATIC uint8_t xdigit_8b_value(byte nibble1, byte nibble2) {
//| Encapsulates the address of a BLE device.
//|
-//| .. class:: Address(address)
+//| .. class:: Address(address, address_type)
//|
//| Create a new Address object encapsulating the address value.
//| The value itself can be one of:
//|
-//| - a `str` value in the format of 'XXXXXXXXXXXX' or 'XX:XX:XX:XX:XX:XX' (12 hex digits)
-//| - a `bytes` or `bytearray` containing 6 bytes
-//| - another Address object
-//|
-//| :param address: The address to encapsulate
-//|
-
-//| .. attribute:: type
-//|
-//| The address type. One of:
-//|
-//| - `bleio.AddressType.PUBLIC`
-//| - `bleio.AddressType.RANDOM_STATIC`
-//| - `bleio.AddressType.RANDOM_PRIVATE_RESOLVABLE`
-//| - `bleio.AddressType.RANDOM_PRIVATE_NON_RESOLVABLE`
+//| :param buf address: The address value to encapsulate. A buffer object (bytearray, bytes) of 6 bytes.
+//| :param int address_type: one of the integer values: `PUBLIC`, `RANDOM_STATIC`,
+//| `RANDOM_PRIVATE_RESOLVABLE`, or `RANDOM_PRIVATE_NON_RESOLVABLE`.
//|
STATIC mp_obj_t bleio_address_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
- enum { ARG_address };
+ enum { ARG_address, ARG_address_type };
static const mp_arg_t allowed_args[] = {
- { MP_QSTR_address, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
+ { MP_QSTR_address, MP_ARG_OBJ | MP_ARG_REQUIRED },
+ { MP_QSTR_address_type, MP_ARG_INT, {.u_int = BLEIO_ADDRESS_TYPE_PUBLIC } },
};
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
@@ -80,83 +63,52 @@ STATIC mp_obj_t bleio_address_make_new(const mp_obj_type_t *type, size_t n_args,
bleio_address_obj_t *self = m_new_obj(bleio_address_obj_t);
self->base.type = &bleio_address_type;
- self->type = ADDRESS_PUBLIC;
const mp_obj_t address = args[ARG_address].u_obj;
+ mp_buffer_info_t buf_info;
+ mp_get_buffer_raise(address, &buf_info, MP_BUFFER_READ);
+ if (buf_info.len != NUM_BLEIO_ADDRESS_BYTES) {
+ mp_raise_ValueError_varg(translate("Address must be %d bytes long"), NUM_BLEIO_ADDRESS_BYTES);
+ }
- if (MP_OBJ_IS_STR(address)) {
- GET_STR_DATA_LEN(address, str, str_len);
-
- size_t value_index = 0;
- int str_index = str_len;
- bool error = false;
-
- // Loop until fewer than two characters left.
- while (str_index >= 1 && value_index < sizeof(self->value)) {
- if (str[str_index] == ':') {
- // Skip colon separators.
- str_index--;
- continue;
- }
-
- if (!unichar_isxdigit(str[str_index]) ||
- !unichar_isxdigit(str[str_index-1])) {
- error = true;
- break;
- }
-
- self->value[value_index] = xdigit_8b_value(str[str_index],
- str[str_index-1]);
- value_index += 1;
- str_index -= 2;
- }
- // Check for correct number of hex digits and no parsing errors.
- if (error || value_index != ADDRESS_BYTE_LEN || str_index != -1) {
- mp_raise_ValueError_varg(translate("Address is not %d bytes long or is in wrong format"),
- ADDRESS_BYTE_LEN);
- }
- } else if (MP_OBJ_IS_TYPE(address, &mp_type_bytearray) || MP_OBJ_IS_TYPE(address, &mp_type_bytes)) {
- mp_buffer_info_t buf_info;
- mp_get_buffer_raise(address, &buf_info, MP_BUFFER_READ);
- if (buf_info.len != BLEIO_ADDRESS_BYTES) {
- mp_raise_ValueError_varg(translate("Address must be %d bytes long"), BLEIO_ADDRESS_BYTES);
- }
-
- for (size_t b = 0; b < BLEIO_ADDRESS_BYTES; ++b) {
- self->value[BLEIO_ADDRESS_BYTES - b - 1] = ((uint8_t*)buf_info.buf)[b];
- }
- } else if (MP_OBJ_IS_TYPE(address, &bleio_address_type)) {
- // deep copy
- bleio_address_obj_t *other = MP_OBJ_TO_PTR(address);
- self->type = other->type;
- memcpy(self->value, other->value, BLEIO_ADDRESS_BYTES);
+ const mp_int_t address_type = args[ARG_address_type].u_int;
+ if (address_type < BLEIO_ADDRESS_TYPE_MIN || address_type > BLEIO_ADDRESS_TYPE_MAX) {
+ mp_raise_ValueError(translate("Address type out of range"));
}
+ common_hal_bleio_address_construct(self, buf_info.buf, address_type);
+
return MP_OBJ_FROM_PTR(self);
}
-STATIC void bleio_address_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
+//| .. attribute:: address_bytes
+//|
+//| The bytes that make up the device address (read-only)
+//|
+STATIC mp_obj_t bleio_address_get_address_bytes(mp_obj_t self_in) {
bleio_address_obj_t *self = MP_OBJ_TO_PTR(self_in);
- mp_printf(print, "Address('%02x:%02x:%02x:%02x:%02x:%02x')",
- self->value[5], self->value[4], self->value[3],
- self->value[2], self->value[1], self->value[0]);
+ return common_hal_bleio_address_get_address_bytes(self);
}
+MP_DEFINE_CONST_FUN_OBJ_1(bleio_address_get_address_bytes_obj, bleio_address_get_address_bytes);
+
+const mp_obj_property_t bleio_address_address_bytes_obj = {
+ .base.type = &mp_type_property,
+ .proxy = {(mp_obj_t)&bleio_address_get_address_bytes_obj,
+ (mp_obj_t)&mp_const_none_obj,
+ (mp_obj_t)&mp_const_none_obj},
+};
+//| .. attribute:: type
+//|
+//| The address type (read-only).
+//| One of the integer values: `PUBLIC`, `RANDOM_STATIC`,
+//| `RANDOM_PRIVATE_RESOLVABLE`, or `RANDOM_PRIVATE_NON_RESOLVABLE`.
+//|
STATIC mp_obj_t bleio_address_get_type(mp_obj_t self_in) {
bleio_address_obj_t *self = MP_OBJ_TO_PTR(self_in);
- if (self->type == ADDRESS_PUBLIC) {
- return (mp_obj_t)&bleio_addresstype_public_obj;
- } else if (self->type == ADDRESS_RANDOM_STATIC) {
- return (mp_obj_t)&bleio_addresstype_random_static_obj;
- } else if (self->type == ADDRESS_RANDOM_PRIVATE_RESOLVABLE) {
- return (mp_obj_t)&bleio_addresstype_random_private_resolvable_obj;
- } else if (self->type == ADDRESS_RANDOM_PRIVATE_NON_RESOLVABLE) {
- return (mp_obj_t)&bleio_addresstype_random_private_non_resolvable_obj;
- }
-
- return mp_const_none;
+ return MP_OBJ_NEW_SMALL_INT(common_hal_bleio_address_get_type(self));
}
MP_DEFINE_CONST_FUN_OBJ_1(bleio_address_get_type_obj, bleio_address_get_type);
@@ -167,8 +119,74 @@ const mp_obj_property_t bleio_address_type_obj = {
(mp_obj_t)&mp_const_none_obj},
};
+//| .. method:: __eq__(other)
+//|
+//| Two Address objects are equal if their addresses and address types are equal.
+//|
+STATIC mp_obj_t bleio_address_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
+ switch (op) {
+ // Two Addresses are equal if their address bytes and address_type are equal
+ case MP_BINARY_OP_EQUAL:
+ if (MP_OBJ_IS_TYPE(rhs_in, &bleio_address_type)) {
+ bleio_address_obj_t *lhs = MP_OBJ_TO_PTR(lhs_in);
+ bleio_address_obj_t *rhs = MP_OBJ_TO_PTR(rhs_in);
+ return mp_obj_new_bool(
+ mp_obj_equal(common_hal_bleio_address_get_address_bytes(lhs),
+ common_hal_bleio_address_get_address_bytes(rhs)) &&
+ common_hal_bleio_address_get_type(lhs) ==
+ common_hal_bleio_address_get_type(rhs));
+
+ } else {
+ return mp_const_false;
+ }
+
+ default:
+ return MP_OBJ_NULL; // op not supported
+ }
+}
+
+STATIC void bleio_address_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
+ bleio_address_obj_t *self = MP_OBJ_TO_PTR(self_in);
+ if (kind == PRINT_STR) {
+ mp_buffer_info_t buf_info;
+ mp_obj_t address_bytes = common_hal_bleio_address_get_address_bytes(self);
+ mp_get_buffer_raise(address_bytes, &buf_info, MP_BUFFER_READ);
+
+ const uint8_t *buf = (uint8_t *) buf_info.buf;
+ mp_printf(print,
+ "%02x:%02x:%02x:%02x:%02x:%02x",
+ buf[5], buf[4], buf[3], buf[2], buf[1], buf[0]);
+ } else {
+ mp_printf(print, "<Address>");
+ }
+}
+
+//| .. data:: PUBLIC
+//|
+//| A publicly known address, with a company ID (high 24 bits)and company-assigned part (low 24 bits).
+//|
+//| .. data:: RANDOM_STATIC
+//|
+//| A randomly generated address that does not change often. It may never change or may change after
+//| a power cycle.
+//|
+//| .. data:: RANDOM_PRIVATE_RESOLVABLE
+//|
+//| An address that is usable when the peer knows the other device's secret Identity Resolving Key (IRK).
+//|
+//| .. data:: RANDOM_PRIVATE_NON_RESOLVABLE
+//|
+//| A randomly generated address that changes on every connection.
+//|
STATIC const mp_rom_map_elem_t bleio_address_locals_dict_table[] = {
+ { MP_ROM_QSTR(MP_QSTR_address_bytes), MP_ROM_PTR(&bleio_address_address_bytes_obj) },
{ MP_ROM_QSTR(MP_QSTR_type), MP_ROM_PTR(&bleio_address_type_obj) },
+ // These match the BLE_GAP_ADDR_TYPES values used by the nRF library.
+ { MP_ROM_QSTR(MP_QSTR_PUBLIC), MP_OBJ_NEW_SMALL_INT(0) },
+ { MP_ROM_QSTR(MP_QSTR_RANDOM_STATIC), MP_OBJ_NEW_SMALL_INT(1) },
+ { MP_ROM_QSTR(MP_QSTR_RANDOM_PRIVATE_RESOLVABLE), MP_OBJ_NEW_SMALL_INT(2) },
+ { MP_ROM_QSTR(MP_QSTR_RANDOM_PRIVATE_NON_RESOLVABLE), MP_OBJ_NEW_SMALL_INT(3) },
+
};
STATIC MP_DEFINE_CONST_DICT(bleio_address_locals_dict, bleio_address_locals_dict_table);
@@ -176,7 +194,8 @@ STATIC MP_DEFINE_CONST_DICT(bleio_address_locals_dict, bleio_address_locals_dict
const mp_obj_type_t bleio_address_type = {
{ &mp_type_type },
.name = MP_QSTR_Address,
- .print = bleio_address_print,
.make_new = bleio_address_make_new,
+ .print = bleio_address_print,
+ .binary_op = bleio_address_binary_op,
.locals_dict = (mp_obj_dict_t*)&bleio_address_locals_dict
};
diff --git a/shared-bindings/bleio/Address.h b/shared-bindings/bleio/Address.h
index 9c9e20968..5e02ee210 100644
--- a/shared-bindings/bleio/Address.h
+++ b/shared-bindings/bleio/Address.h
@@ -3,6 +3,7 @@
*
* The MIT License (MIT)
*
+ * Copyright (c) 2019 Dan Halbert for Adafruit Industries
* Copyright (c) 2018 Artur Pacholec
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -28,7 +29,20 @@
#define MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_ADDRESS_H
#include "py/objtype.h"
+#include "shared-module/bleio/Address.h"
+
+#define BLEIO_ADDRESS_TYPE_PUBLIC (0)
+#define BLEIO_ADDRESS_TYPE_RANDOM_STATIC (1)
+#define BLEIO_ADDRESS_TYPE_RANDOM_PRIVATE_RESOLVABLE (2)
+#define BLEIO_ADDRESS_TYPE_RANDOM_PRIVATE_NON_RESOLVABLE (3)
+
+#define BLEIO_ADDRESS_TYPE_MIN BLEIO_ADDRESS_TYPE_PUBLIC
+#define BLEIO_ADDRESS_TYPE_MAX BLEIO_ADDRESS_TYPE_RANDOM_PRIVATE_NON_RESOLVABLE
extern const mp_obj_type_t bleio_address_type;
+extern void common_hal_bleio_address_construct(bleio_address_obj_t *self, uint8_t *bytes, uint8_t address_type);
+extern mp_obj_t common_hal_bleio_address_get_address_bytes(bleio_address_obj_t *self);
+extern uint8_t common_hal_bleio_address_get_type(bleio_address_obj_t *self);
+
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_ADDRESS_H
diff --git a/shared-bindings/bleio/AddressType.c b/shared-bindings/bleio/AddressType.c
deleted file mode 100644
index 7edf3c170..000000000
--- a/shared-bindings/bleio/AddressType.c
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * This file is part of the Micro Python project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2018 Artur Pacholec
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-#include "shared-bindings/bleio/AddressType.h"
-
-//| .. currentmodule:: bleio
-//|
-//| :class:`AddressType` -- defines the type of a BLE address
-//| =============================================================
-//|
-//| .. class:: AddressType()
-//|
-//| Enum-like class to define the type of a BLE address, see also `bleio.Address`.
-//|
-//| .. data:: PUBLIC
-//|
-//| The address is public
-//|
-//| .. data:: RANDOM_STATIC
-//|
-//| The address is random static
-//|
-//| .. data:: RANDOM_PRIVATE_RESOLVABLE
-//|
-//| The address is random private resolvable
-//|
-//| .. data:: RANDOM_PRIVATE_NON_RESOLVABLE
-//|
-//| The address is private non-resolvable
-//|
-const mp_obj_type_t bleio_addresstype_type;
-
-const bleio_addresstype_obj_t bleio_addresstype_public_obj = {
- { &bleio_addresstype_type },
-};
-
-const bleio_addresstype_obj_t bleio_addresstype_random_static_obj = {
- { &bleio_addresstype_type },
-};
-
-const bleio_addresstype_obj_t bleio_addresstype_random_private_resolvable_obj = {
- { &bleio_addresstype_type },
-};
-
-const bleio_addresstype_obj_t bleio_addresstype_random_private_non_resolvable_obj = {
- { &bleio_addresstype_type },
-};
-
-STATIC const mp_rom_map_elem_t bleio_addresstype_locals_dict_table[] = {
- { MP_ROM_QSTR(MP_QSTR_PUBLIC), MP_ROM_PTR(&bleio_addresstype_public_obj) },
- { MP_ROM_QSTR(MP_QSTR_RANDOM_STATIC), MP_ROM_PTR(&bleio_addresstype_random_static_obj) },
- { MP_ROM_QSTR(MP_QSTR_RANDOM_PRIVATE_RESOLVABLE), MP_ROM_PTR(&bleio_addresstype_random_private_resolvable_obj) },
- { MP_ROM_QSTR(MP_QSTR_RANDOM_PRIVATE_NON_RESOLVABLE), MP_ROM_PTR(&bleio_addresstype_random_private_non_resolvable_obj) },
-};
-STATIC MP_DEFINE_CONST_DICT(bleio_addresstype_locals_dict, bleio_addresstype_locals_dict_table);
-
-STATIC void bleio_addresstype_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
- qstr type = MP_QSTR_PUBLIC;
-
- if (MP_OBJ_TO_PTR(self_in) == MP_ROM_PTR(&bleio_addresstype_random_static_obj)) {
- type = MP_QSTR_RANDOM_STATIC;
- } else if (MP_OBJ_TO_PTR(self_in) == MP_ROM_PTR(&bleio_addresstype_random_private_resolvable_obj)) {
- type = MP_QSTR_RANDOM_PRIVATE_RESOLVABLE;
- } else if (MP_OBJ_TO_PTR(self_in) == MP_ROM_PTR(&bleio_addresstype_random_private_non_resolvable_obj)) {
- type = MP_QSTR_RANDOM_PRIVATE_NON_RESOLVABLE;
- }
-
- mp_printf(print, "%q.%q.%q", MP_QSTR_bleio, MP_QSTR_AddressType, type);
-}
-
-const mp_obj_type_t bleio_addresstype_type = {
- { &mp_type_type },
- .name = MP_QSTR_AddressType,
- .print = bleio_addresstype_print,
- .locals_dict = (mp_obj_t)&bleio_addresstype_locals_dict,
-};
diff --git a/shared-bindings/bleio/AdvertisementData.c b/shared-bindings/bleio/AdvertisementData.c
deleted file mode 100644
index 9cfdd74e9..000000000
--- a/shared-bindings/bleio/AdvertisementData.c
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2018 Artur Pacholec
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-#include "py/obj.h"
-#include "shared-module/bleio/AdvertisementData.h"
-
-//| .. currentmodule:: bleio
-//|
-//| :class:`AdvertisementData` -- data used during BLE advertising
-//| ==============================================================
-//|
-//| Represents the data to be broadcast during BLE advertising.
-//|
-
-STATIC const mp_rom_map_elem_t bleio_advertisementdata_locals_dict_table[] = {
- // Static variables
- { MP_ROM_QSTR(MP_QSTR_FLAGS), MP_ROM_INT(AdFlags) },
- { MP_ROM_QSTR(MP_QSTR_INCOMPLETE_LIST_OF_16BIT_SERVICE_CLASS_UUIDS), MP_ROM_INT(AdIncompleteListOf16BitServiceClassUUIDs) },
- { MP_ROM_QSTR(MP_QSTR_COMPLETE_LIST_OF_16BIT_SERVICE_CLASS_UUIDS), MP_ROM_INT(AdCompleteListOf16BitServiceClassUUIDs) },
- { MP_ROM_QSTR(MP_QSTR_INCOMPLETE_LIST_OF_32BIT_SERVICE_CLASS_UUIDS), MP_ROM_INT(AdIncompleteListOf32BitServiceClassUUIDs) },
- { MP_ROM_QSTR(MP_QSTR_COMPLETE_LIST_OF_32BIT_SERVICE_CLASS_UUIDS), MP_ROM_INT(AdCompleteListOf32BitServiceClassUUIDs) },
- { MP_ROM_QSTR(MP_QSTR_INCOMPLETE_LIST_OF_128BIT_SERVICE_CLASS_UUIDS), MP_ROM_INT(AdIncompleteListOf128BitServiceClassUUIDs) },
- { MP_ROM_QSTR(MP_QSTR_COMPLETE_LIST_OF_128BIT_SERVICE_CLASS_UUIDS), MP_ROM_INT(AdCompleteListOf128BitServiceClassUUIDs) },
- { MP_ROM_QSTR(MP_QSTR_SHORTENED_LOCAL_NAME), MP_ROM_INT(AdShortenedLocalName) },
- { MP_ROM_QSTR(MP_QSTR_COMPLETE_LOCAL_NAME), MP_ROM_INT(AdCompleteLocalName) },
- { MP_ROM_QSTR(MP_QSTR_TX_POWER_LEVEL), MP_ROM_INT(AdTxPowerLevel) },
- { MP_ROM_QSTR(MP_QSTR_CLASS_OF_DEVICE), MP_ROM_INT(AdClassOfDevice) },
- { MP_ROM_QSTR(MP_QSTR_SIMPLE_PAIRING_HASH_C), MP_ROM_INT(AdSimplePairingHashC) },
- { MP_ROM_QSTR(MP_QSTR_SIMPLE_PAIRING_RANDOMIZER_R), MP_ROM_INT(AdSimplePairingRandomizerR) },
- { MP_ROM_QSTR(MP_QSTR_SECURITY_MANAGER_TK_VALUE), MP_ROM_INT(AdSecurityManagerTKValue) },
- { MP_ROM_QSTR(MP_QSTR_SECURITY_MANAGER_OOB_FLAGS), MP_ROM_INT(AdSecurityManagerOOBFlags) },
- { MP_ROM_QSTR(MP_QSTR_SLAVE_CONNECTION_INTERVAL_RANGE), MP_ROM_INT(AdSlaveConnectionIntervalRange) },
- { MP_ROM_QSTR(MP_QSTR_LIST_OF_16BIT_SERVICE_SOLICITATION_UUIDS), MP_ROM_INT(AdListOf16BitServiceSolicitationUUIDs) },
- { MP_ROM_QSTR(MP_QSTR_LIST_OF_128BIT_SERVICE_SOLICITATION_UUIDS), MP_ROM_INT(AdListOf128BitServiceSolicitationUUIDs) },
- { MP_ROM_QSTR(MP_QSTR_SERVICE_DATA), MP_ROM_INT(AdServiceData) },
- { MP_ROM_QSTR(MP_QSTR_PUBLIC_TARGET_ADDRESS), MP_ROM_INT(AdPublicTargetAddress) },
- { MP_ROM_QSTR(MP_QSTR_RANDOM_TARGET_ADDRESS), MP_ROM_INT(AdRandomTargetAddress) },
- { MP_ROM_QSTR(MP_QSTR_APPEARANCE), MP_ROM_INT(AdAppearance) },
- { MP_ROM_QSTR(MP_QSTR_ADVERTISING_INTERNAL), MP_ROM_INT(AdAdvertisingInterval) },
- { MP_ROM_QSTR(MP_QSTR_LE_BLUETOOTH_DEVICE_ADDRESS), MP_ROM_INT(AdLEBluetoothDeviceAddress) },
- { MP_ROM_QSTR(MP_QSTR_LE_ROLE), MP_ROM_INT(AdLERole) },
- { MP_ROM_QSTR(MP_QSTR_SIMPLE_PAIRING_HASH_C256), MP_ROM_INT(AdSimplePairingHashC256) },
- { MP_ROM_QSTR(MP_QSTR_SIMPLE_PAIRING_RANDOMIZER_R256), MP_ROM_INT(AdSimplePairingRandomizerR256) },
- { MP_ROM_QSTR(MP_QSTR_LIST_OF_32BIT_SERVICE_SOLICITATION_UUIDS), MP_ROM_INT(AdListOf32BitServiceSolicitationUUIDs) },
- { MP_ROM_QSTR(MP_QSTR_SERVICE_DATA_32BIT_UUID), MP_ROM_INT(AdServiceData32BitUUID) },
- { MP_ROM_QSTR(MP_QSTR_SERVICE_DATA_128BIT_UUID), MP_ROM_INT(AdServiceData128BitUUID) },
- { MP_ROM_QSTR(MP_QSTR_LE_SECURE_CONNECTIONS_CONFIRMATION_VALUE), MP_ROM_INT(AdLESecureConnectionsConfirmationValue) },
- { MP_ROM_QSTR(MP_QSTR_LE_SECURE_CONNECTIONS_RANDOM_VALUE), MP_ROM_INT(AdLESecureConnectionsRandomValue) },
- { MP_ROM_QSTR(MP_QSTR_URI), MP_ROM_INT(AdURI) },
- { MP_ROM_QSTR(MP_QSTR_INDOOR_POSITIONING), MP_ROM_INT(AdIndoorPositioning) },
- { MP_ROM_QSTR(MP_QSTR_TRANSPORT_DISCOVERY_DATA), MP_ROM_INT(AdTransportDiscoveryData) },
- { MP_ROM_QSTR(MP_QSTR_LE_SUPPORTED_FEATURES), MP_ROM_INT(AdLESupportedFeatures) },
- { MP_ROM_QSTR(MP_QSTR_CHANNEL_MAP_UPDATE_INDICATION), MP_ROM_INT(AdChannelMapUpdateIndication) },
- { MP_ROM_QSTR(MP_QSTR_PB_ADV), MP_ROM_INT(AdPBADV) },
- { MP_ROM_QSTR(MP_QSTR_MESH_MESSAGE), MP_ROM_INT(AdMeshMessage) },
- { MP_ROM_QSTR(MP_QSTR_MESH_BEACON), MP_ROM_INT(AdMeshBeacon) },
- { MP_ROM_QSTR(MP_QSTR_3D_INFORMATION_DATA), MP_ROM_INT(Ad3DInformationData) },
- { MP_ROM_QSTR(MP_QSTR_MANUFACTURER_SPECIFIC_DATA), MP_ROM_INT(AdManufacturerSpecificData) },
-};
-
-STATIC MP_DEFINE_CONST_DICT(bleio_advertisementdata_locals_dict, bleio_advertisementdata_locals_dict_table);
-
-const mp_obj_type_t bleio_advertisementdata_type = {
- { &mp_type_type },
- .name = MP_QSTR_AdvertisementData,
- .locals_dict = (mp_obj_dict_t*)&bleio_advertisementdata_locals_dict
-};
diff --git a/shared-bindings/bleio/Broadcaster.c b/shared-bindings/bleio/Broadcaster.c
deleted file mode 100644
index 209e66490..000000000
--- a/shared-bindings/bleio/Broadcaster.c
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2018 Dan Halbert for Adafruit Industries
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-#include "ble_drv.h"
-#include "py/runtime.h"
-
-#include "shared-bindings/bleio/Broadcaster.h"
-
-//| .. currentmodule:: bleio
-//|
-//| :class:`Broadcaster` -- Broadcast advertising packets.
-//| =========================================================
-//|
-//| Implement a BLE broadcaster which sends data in advertising packets and does not connect.
-//| Used for beacons and other one-way data transmission.
-//|
-//| Usage::
-//|
-//| import bleio
-//| import time
-//|
-//| # Broadcast once a second.
-//| broadcaster = bleio.Broadcaster(interval=1)
-//| data = 0
-//| # Broadcast a byte of data that's incremented once a minute
-//| while True:
-//| # data is an entire advertising data packet, starting with flags.
-//| broadcaster.start_advertising(data)
-//| time.sleep(60)
-//| data += 1
-//|
-//| .. class:: Broadcaster(interval=1)
-//|
-//| Create a new Broadcaster object.
-
-//| :param float interval: how often to broadcast
-//|
-
-STATIC mp_obj_t bleio_broadcaster_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_interval };
- static const mp_arg_t allowed_args[] = {
- { MP_QSTR_interval, MP_ARG_OBJ, {.u_obj = MP_OBJ_NEW_SMALL_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_float_t interval = mp_obj_get_float(args[ARG_interval].u_obj);
-
- bleio_broadcaster_obj_t *self = m_new_obj(bleio_broadcaster_obj_t);
- self->base.type = &bleio_broadcaster_type;
- // Do port-specific initialization. interval will be validated.
- common_hal_bleio_broadcaster_construct(self, interval);
-
- return MP_OBJ_FROM_PTR(self);
-}
-
-//| .. method:: start_advertising(data)
-//|
-//| Start advertising using the given data packet.
-//|
-//| :param buf data: advertising data packet, starting with advertising data flags (0x01)
-//|
-STATIC mp_obj_t bleio_broadcaster_start_advertising(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
- bleio_broadcaster_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]);
-
- enum { ARG_data };
- static const mp_arg_t allowed_args[] = {
- { MP_QSTR_data, MP_ARG_REQUIRED | MP_ARG_OBJ },
- };
-
- mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
- mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
-
- mp_buffer_info_t bufinfo;
- mp_get_buffer_raise(args[ARG_data].u_obj, &bufinfo, MP_BUFFER_READ);
-
- common_hal_bleio_broadcaster_start_advertising(self, &bufinfo);
-
- return mp_const_none;
-}
-STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_broadcaster_start_advertising_obj, 0, bleio_broadcaster_start_advertising);
-
-//| .. method:: stop_advertising()
-//|
-//| Stop sending advertising packets.
-STATIC mp_obj_t bleio_broadcaster_stop_advertising(mp_obj_t self_in) {
- bleio_broadcaster_obj_t *self = MP_OBJ_TO_PTR(self_in);
-
- common_hal_bleio_broadcaster_stop_advertising(self);
-
- return mp_const_none;
-}
-STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_broadcaster_stop_advertising_obj, bleio_broadcaster_stop_advertising);
-
-STATIC const mp_rom_map_elem_t bleio_broadcaster_locals_dict_table[] = {
- // Methods
- { MP_ROM_QSTR(MP_QSTR_start_advertising), MP_ROM_PTR(&bleio_broadcaster_start_advertising_obj) },
- { MP_ROM_QSTR(MP_QSTR_stop_advertising), MP_ROM_PTR(&bleio_broadcaster_stop_advertising_obj) },
-};
-
-STATIC MP_DEFINE_CONST_DICT(bleio_broadcaster_locals_dict, bleio_broadcaster_locals_dict_table);
-
-const mp_obj_type_t bleio_broadcaster_type = {
- { &mp_type_type },
- .name = MP_QSTR_Broadcaster,
- .make_new = bleio_broadcaster_make_new,
- .locals_dict = (mp_obj_dict_t*)&bleio_broadcaster_locals_dict
-};
diff --git a/shared-bindings/bleio/Central.c b/shared-bindings/bleio/Central.c
new file mode 100644
index 000000000..fc00bce5c
--- /dev/null
+++ b/shared-bindings/bleio/Central.c
@@ -0,0 +1,199 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019 Dan Halbert for Adafruit Industries
+ * Copyright (c) 2018 Artur Pacholec
+ * Copyright (c) 2016 Glenn Ruben Bakke
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include <string.h>
+#include <stdio.h>
+
+#include "ble_drv.h"
+#include "py/objarray.h"
+#include "py/objproperty.h"
+#include "py/objstr.h"
+#include "py/runtime.h"
+#include "shared-bindings/bleio/Adapter.h"
+#include "shared-bindings/bleio/Address.h"
+#include "shared-bindings/bleio/Characteristic.h"
+#include "shared-bindings/bleio/Central.h"
+#include "shared-bindings/bleio/Service.h"
+
+//| .. currentmodule:: bleio
+//|
+//| :class:`Central` -- A BLE central device
+//| =========================================================
+//|
+//| Implement a BLE central, which runs locally. Can connect to a given address.
+//|
+//| Usage::
+//|
+//| import bleio
+//|
+//| scanner = bleio.Scanner()
+//| entries = scanner.scan(2.5)
+//|
+//| my_entry = None
+//| for entry in entries:
+//| if entry.name is not None and entry.name == 'MyPeripheral':
+//| my_entry = entry
+//| break
+//|
+//| central = bleio.Central(my_entry.address)
+//| central.connect(10.0) # timeout after 10 seconds
+//|
+
+//| .. class:: Central()
+//|
+//| Create a new Central object.
+//|
+STATIC mp_obj_t bleio_central_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
+ mp_arg_check_num(n_args, kw_args, 0, 0, false);
+
+ bleio_central_obj_t *self = m_new_obj(bleio_central_obj_t);
+ self->base.type = &bleio_central_type;
+
+ common_hal_bleio_central_construct(self);
+
+ return MP_OBJ_FROM_PTR(self);
+}
+
+//| .. method:: connect(address, timeout, *, service_uuids=None)
+//| Attempts a connection to the remote peripheral. If the connection is successful,
+//| Do BLE discovery for the listed services, to find their handles and characteristics.
+//| The attribute `remote_services` will contain a list of all discovered services.
+//|
+//| :param bleio.Address address: The address of the peripheral to connect to
+//| :param float/int timeout: Try to connect for timeout seconds.
+//| :param iterable service_uuids_whitelist: an iterable of :py:class:~`UUID` objects for the services
+//| provided by the peripheral that you want to use.
+//| The peripheral may provide more services, but services not listed are ignored.
+//| If a service in service_uuids is not found during discovery, it will not
+//| appear in `remote_services`.
+//|
+//| If service_uuids_whitelist is None, then all services will undergo discovery, which can be slow.
+//|
+//| If the service UUID is 128-bit, or its characteristic UUID's are 128-bit, you
+//| you must have already created a :py:class:~`UUID` object for that UUID in order for the
+//| service or characteristic to be discovered. (This restriction may be lifted in the future.)
+//|
+STATIC mp_obj_t bleio_central_connect(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
+ bleio_central_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]);
+
+ enum { ARG_address, ARG_timeout, ARG_service_uuids_whitelist };
+ static const mp_arg_t allowed_args[] = {
+ { MP_QSTR_address, MP_ARG_REQUIRED | MP_ARG_OBJ },
+ { MP_QSTR_timeout, MP_ARG_REQUIRED | MP_ARG_OBJ },
+ { MP_QSTR_service_uuids_whitelist, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} },
+ };
+
+ mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
+ mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
+
+ if (!MP_OBJ_IS_TYPE(args[ARG_address].u_obj, &bleio_address_type)) {
+ mp_raise_ValueError(translate("Expected an Address"));
+ }
+
+ bleio_address_obj_t *address = MP_OBJ_TO_PTR(args[ARG_address].u_obj);
+ mp_float_t timeout = mp_obj_get_float(args[ARG_timeout].u_obj);
+
+ // common_hal_bleio_central_connect() will validate that services is an iterable or None.
+ common_hal_bleio_central_connect(self, address, timeout, args[ARG_service_uuids_whitelist].u_obj);
+
+ return mp_const_none;
+}
+STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_central_connect_obj, 3, bleio_central_connect);
+
+
+//| .. method:: disconnect()
+//|
+//| Disconnects from the remote peripheral.
+//|
+STATIC mp_obj_t bleio_central_disconnect(mp_obj_t self_in) {
+ bleio_central_obj_t *self = MP_OBJ_TO_PTR(self_in);
+
+ common_hal_bleio_central_disconnect(self);
+
+ return mp_const_none;
+}
+STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_central_disconnect_obj, bleio_central_disconnect);
+
+//| .. attribute:: connected
+//|
+//| True if connected to a remove peripheral.
+//|
+STATIC mp_obj_t bleio_central_get_connected(mp_obj_t self_in) {
+ bleio_central_obj_t *self = MP_OBJ_TO_PTR(self_in);
+
+ return mp_obj_new_bool(common_hal_bleio_central_get_connected(self));
+}
+STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_central_get_connected_obj, bleio_central_get_connected);
+
+const mp_obj_property_t bleio_central_connected_obj = {
+ .base.type = &mp_type_property,
+ .proxy = { (mp_obj_t)&bleio_central_get_connected_obj,
+ (mp_obj_t)&mp_const_none_obj,
+ (mp_obj_t)&mp_const_none_obj },
+};
+
+
+//| .. attribute:: remote_services (read-only)
+//|
+//| A tuple of services provided by the remote peripheral.
+//| If the Central is not connected, an empty tuple will be returned.
+//|
+STATIC mp_obj_t bleio_central_get_remote_services(mp_obj_t self_in) {
+ bleio_central_obj_t *self = MP_OBJ_TO_PTR(self_in);
+
+ // Return list as a tuple so user won't be able to change it.
+ mp_obj_list_t *service_list = common_hal_bleio_central_get_remote_services(self);
+ return mp_obj_new_tuple(service_list->len, service_list->items);
+}
+STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_central_get_remote_services_obj, bleio_central_get_remote_services);
+
+const mp_obj_property_t bleio_central_remote_services_obj = {
+ .base.type = &mp_type_property,
+ .proxy = { (mp_obj_t)&bleio_central_get_remote_services_obj,
+ (mp_obj_t)&mp_const_none_obj,
+ (mp_obj_t)&mp_const_none_obj },
+};
+
+STATIC const mp_rom_map_elem_t bleio_central_locals_dict_table[] = {
+ // Methods
+ { MP_ROM_QSTR(MP_QSTR_connect), MP_ROM_PTR(&bleio_central_connect_obj) },
+ { MP_ROM_QSTR(MP_QSTR_disconnect), MP_ROM_PTR(&bleio_central_disconnect_obj) },
+
+ // Properties
+ { MP_ROM_QSTR(MP_QSTR_connected), MP_ROM_PTR(&bleio_central_connected_obj) },
+ { MP_ROM_QSTR(MP_QSTR_remote_services), MP_ROM_PTR(&bleio_central_remote_services_obj) },
+};
+
+STATIC MP_DEFINE_CONST_DICT(bleio_central_locals_dict, bleio_central_locals_dict_table);
+
+const mp_obj_type_t bleio_central_type = {
+ { &mp_type_type },
+ .name = MP_QSTR_Central,
+ .make_new = bleio_central_make_new,
+ .locals_dict = (mp_obj_dict_t*)&bleio_central_locals_dict
+};
diff --git a/ports/nrf/common-hal/bleio/Broadcaster.h b/shared-bindings/bleio/Central.h
index 72f93a443..0e84037f9 100644
--- a/ports/nrf/common-hal/bleio/Broadcaster.h
+++ b/shared-bindings/bleio/Central.h
@@ -3,8 +3,8 @@
*
* The MIT License (MIT)
*
+ * Copyright (c) 2019 Dan Halbert for Adafruit Industries
* Copyright (c) 2018 Artur Pacholec
- * 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
@@ -25,23 +25,18 @@
* THE SOFTWARE.
*/
-#ifndef MICROPY_INCLUDED_COMMON_HAL_BLEIO_BROADCASTER_H
-#define MICROPY_INCLUDED_COMMON_HAL_BLEIO_BROADCASTER_H
+#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_CENTRAL_H
+#define MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_CENTRAL_H
-#include "ble.h"
+#include "common-hal/bleio/Central.h"
+#include "common-hal/bleio/Service.h"
-#include "shared-module/bleio/__init__.h"
-#include "shared-module/bleio/Address.h"
+extern const mp_obj_type_t bleio_central_type;
-typedef struct {
- mp_obj_base_t base;
- // In seconds.
- mp_float_t interval;
- // The advertising data buffer is held by us, not by the SD, so we must
- // maintain it and not change it. If we need to change its contents during advertising,
- // there are tricks to get the SD to notice (see DevZone - TBS).
- uint8_t adv_data[BLE_GAP_ADV_SET_DATA_SIZE_MAX];
+extern void common_hal_bleio_central_construct(bleio_central_obj_t *self);
+extern void common_hal_bleio_central_connect(bleio_central_obj_t *self, bleio_address_obj_t *address, mp_float_t timeout, mp_obj_t service_uuids);
+extern void common_hal_bleio_central_disconnect(bleio_central_obj_t *self);
+extern bool common_hal_bleio_central_get_connected(bleio_central_obj_t *self);
+extern mp_obj_list_t *common_hal_bleio_central_get_remote_services(bleio_central_obj_t *self);
-} bleio_broadcaster_obj_t;
-
-#endif // MICROPY_INCLUDED_COMMON_HAL_BLEIO_BROADCASTER_H
+#endif // MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_CENTRAL_H
diff --git a/shared-bindings/bleio/Characteristic.c b/shared-bindings/bleio/Characteristic.c
index ae83de864..3bf0476ab 100644
--- a/shared-bindings/bleio/Characteristic.c
+++ b/shared-bindings/bleio/Characteristic.c
@@ -3,8 +3,9 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2017 Glenn Ruben Bakke
+ * Copyright (c) 2019 Dan Halbert for Adafruit Industries
* Copyright (c) 2018 Artur Pacholec
+ * 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
@@ -68,15 +69,15 @@ STATIC mp_obj_t bleio_characteristic_make_new(const mp_obj_type_t *type, size_t
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 mp_obj_t uuid = args[ARG_uuid].u_obj;
+ const mp_obj_t uuid_obj = args[ARG_uuid].u_obj;
- if (!MP_OBJ_IS_TYPE(uuid, &bleio_uuid_type)) {
+ if (!MP_OBJ_IS_TYPE(uuid_obj, &bleio_uuid_type)) {
mp_raise_ValueError(translate("Expected a UUID"));
}
+ bleio_uuid_obj_t *uuid = MP_OBJ_TO_PTR(uuid_obj);
bleio_characteristic_obj_t *self = m_new_obj(bleio_characteristic_obj_t);
self->base.type = &bleio_characteristic_type;
- self->uuid = MP_OBJ_TO_PTR(uuid);
bleio_characteristic_properties_t properties;
@@ -87,7 +88,8 @@ STATIC mp_obj_t bleio_characteristic_make_new(const mp_obj_type_t *type, size_t
properties.write = args[ARG_write].u_bool;
properties.write_no_response = args[ARG_write_no_response].u_bool;
- common_hal_bleio_characteristic_construct(self, uuid, properties);
+ // Initialize, with an empty descriptor list.
+ common_hal_bleio_characteristic_construct(self, uuid, properties, mp_obj_new_list(0, NULL));
return MP_OBJ_FROM_PTR(self);
}
@@ -99,7 +101,7 @@ STATIC mp_obj_t bleio_characteristic_make_new(const mp_obj_type_t *type, size_t
STATIC mp_obj_t bleio_characteristic_get_broadcast(mp_obj_t self_in) {
bleio_characteristic_obj_t *self = MP_OBJ_TO_PTR(self_in);
- return mp_obj_new_bool(self->props.broadcast);
+ return mp_obj_new_bool(common_hal_bleio_characteristic_get_properties(self).broadcast);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_characteristic_get_broadcast_obj, bleio_characteristic_get_broadcast);
@@ -117,7 +119,7 @@ const mp_obj_property_t bleio_characteristic_broadcast_obj = {
STATIC mp_obj_t bleio_characteristic_get_indicate(mp_obj_t self_in) {
bleio_characteristic_obj_t *self = MP_OBJ_TO_PTR(self_in);
- return mp_obj_new_bool(self->props.indicate);
+ return mp_obj_new_bool(common_hal_bleio_characteristic_get_properties(self).indicate);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_characteristic_get_indicate_obj, bleio_characteristic_get_indicate);
@@ -136,7 +138,7 @@ const mp_obj_property_t bleio_characteristic_indicate_obj = {
STATIC mp_obj_t bleio_characteristic_get_notify(mp_obj_t self_in) {
bleio_characteristic_obj_t *self = MP_OBJ_TO_PTR(self_in);
- return mp_obj_new_bool(self->props.notify);
+ return mp_obj_new_bool(common_hal_bleio_characteristic_get_properties(self).notify);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_characteristic_get_notify_obj, bleio_characteristic_get_notify);
@@ -154,7 +156,7 @@ const mp_obj_property_t bleio_characteristic_notify_obj = {
STATIC mp_obj_t bleio_characteristic_get_read(mp_obj_t self_in) {
bleio_characteristic_obj_t *self = MP_OBJ_TO_PTR(self_in);
- return mp_obj_new_bool(self->props.read);
+ return mp_obj_new_bool(common_hal_bleio_characteristic_get_properties(self).read);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_characteristic_get_read_obj, bleio_characteristic_get_read);
@@ -172,7 +174,7 @@ const mp_obj_property_t bleio_characteristic_read_obj = {
STATIC mp_obj_t bleio_characteristic_get_write(mp_obj_t self_in) {
bleio_characteristic_obj_t *self = MP_OBJ_TO_PTR(self_in);
- return mp_obj_new_bool(self->props.write);
+ return mp_obj_new_bool(common_hal_bleio_characteristic_get_properties(self).write);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_characteristic_get_write_obj, bleio_characteristic_get_write);
@@ -190,7 +192,7 @@ const mp_obj_property_t bleio_characteristic_write_obj = {
STATIC mp_obj_t bleio_characteristic_get_write_no_response(mp_obj_t self_in) {
bleio_characteristic_obj_t *self = MP_OBJ_TO_PTR(self_in);
- return mp_obj_new_bool(self->props.write_no_response);
+ return mp_obj_new_bool(common_hal_bleio_characteristic_get_properties(self).write_no_response);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_characteristic_get_write_no_response_obj, bleio_characteristic_get_write_no_response);
@@ -204,11 +206,13 @@ const mp_obj_property_t bleio_characteristic_write_no_response_obj = {
//| .. attribute:: uuid
//|
//| The UUID of this characteristic. (read-only)
+//| Will be ``None`` if the 128-bit UUID for this characteristic is not known.
//|
STATIC mp_obj_t bleio_characteristic_get_uuid(mp_obj_t self_in) {
bleio_characteristic_obj_t *self = MP_OBJ_TO_PTR(self_in);
- return MP_OBJ_FROM_PTR(self->uuid);
+ bleio_uuid_obj_t *uuid = common_hal_bleio_characteristic_get_uuid(self);
+ return uuid ? MP_OBJ_FROM_PTR(uuid) : mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_characteristic_get_uuid_obj, bleio_characteristic_get_uuid);
@@ -228,9 +232,7 @@ const mp_obj_property_t bleio_characteristic_uuid_obj = {
STATIC mp_obj_t bleio_characteristic_get_value(mp_obj_t self_in) {
bleio_characteristic_obj_t *self = MP_OBJ_TO_PTR(self_in);
- common_hal_bleio_characteristic_get_value(self);
-
- return self->value_data;
+ return common_hal_bleio_characteristic_get_value(self);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_characteristic_get_value_obj, bleio_characteristic_get_value);
@@ -253,22 +255,80 @@ const mp_obj_property_t bleio_characteristic_value_obj = {
(mp_obj_t)&mp_const_none_obj },
};
+//| .. attribute:: descriptors
+//|
+//| A tuple of `bleio.Descriptor` that describe this characteristic. (read-only)
+//|
+STATIC mp_obj_t bleio_characteristic_get_descriptors(mp_obj_t self_in) {
+ bleio_characteristic_obj_t *self = MP_OBJ_TO_PTR(self_in);
+ // Return list as a tuple so user won't be able to change it.
+ mp_obj_list_t *char_list = common_hal_bleio_characteristic_get_descriptor_list(self);
+ return mp_obj_new_tuple(char_list->len, char_list->items);
+}
+STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_characteristic_get_descriptors_obj, bleio_characteristic_get_descriptors);
+
+const mp_obj_property_t bleio_characteristic_descriptors_obj = {
+ .base.type = &mp_type_property,
+ .proxy = { (mp_obj_t)&bleio_characteristic_get_descriptors_obj,
+ (mp_obj_t)&mp_const_none_obj,
+ (mp_obj_t)&mp_const_none_obj },
+};
+
+//| .. method:: set_cccd(*, notify=False, indicate=False)
+//|
+//| 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
+//| :param float indicate: True if Characteristic should receive indications of remote writes
+//|
+STATIC mp_obj_t bleio_characteristic_set_cccd(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
+ bleio_characteristic_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]);
+
+ enum { ARG_notify, ARG_indicate };
+ static const mp_arg_t allowed_args[] = {
+ { MP_QSTR_notify, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = false} },
+ { MP_QSTR_indicate, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = false} },
+ };
+
+ mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
+ mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
+
+ common_hal_bleio_characteristic_set_cccd(self, args[ARG_notify].u_bool, args[ARG_indicate].u_bool);
+
+ return mp_const_none;
+}
+STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_characteristic_set_cccd_obj, 1, bleio_characteristic_set_cccd);
+
+
STATIC const mp_rom_map_elem_t bleio_characteristic_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_broadcast), MP_ROM_PTR(&bleio_characteristic_broadcast_obj) },
+ { MP_ROM_QSTR(MP_QSTR_descriptors), MP_ROM_PTR(&bleio_characteristic_descriptors_obj) },
{ MP_ROM_QSTR(MP_QSTR_indicate), MP_ROM_PTR(&bleio_characteristic_indicate_obj) },
{ MP_ROM_QSTR(MP_QSTR_notify), MP_ROM_PTR(&bleio_characteristic_notify_obj) },
{ MP_ROM_QSTR(MP_QSTR_read), MP_ROM_PTR(&bleio_characteristic_read_obj) },
+ { MP_ROM_QSTR(MP_QSTR_set_cccd), MP_ROM_PTR(&bleio_characteristic_set_cccd_obj) },
{ MP_ROM_QSTR(MP_QSTR_uuid), MP_ROM_PTR(&bleio_characteristic_uuid_obj) },
{ MP_ROM_QSTR(MP_QSTR_value), MP_ROM_PTR(&bleio_characteristic_value_obj) },
{ MP_ROM_QSTR(MP_QSTR_write), MP_ROM_PTR(&bleio_characteristic_write_obj) },
{ MP_ROM_QSTR(MP_QSTR_write_no_response), MP_ROM_PTR(&bleio_characteristic_write_no_response_obj) },
};
-
STATIC MP_DEFINE_CONST_DICT(bleio_characteristic_locals_dict, bleio_characteristic_locals_dict_table);
+STATIC void bleio_characteristic_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
+ bleio_characteristic_obj_t *self = MP_OBJ_TO_PTR(self_in);
+ if (self->uuid) {
+ mp_printf(print, "Characteristic(");
+ bleio_uuid_print(print, MP_OBJ_FROM_PTR(self->uuid), kind);
+ mp_printf(print, ")");
+ } else {
+ mp_printf(print, "<Characteristic with Unregistered UUID>");
+ }
+}
+
const mp_obj_type_t bleio_characteristic_type = {
{ &mp_type_type },
.name = MP_QSTR_Characteristic,
.make_new = bleio_characteristic_make_new,
+ .print = bleio_characteristic_print,
.locals_dict = (mp_obj_dict_t*)&bleio_characteristic_locals_dict
};
diff --git a/shared-bindings/bleio/Characteristic.h b/shared-bindings/bleio/Characteristic.h
index 206cbcd40..d450c42b4 100644
--- a/shared-bindings/bleio/Characteristic.h
+++ b/shared-bindings/bleio/Characteristic.h
@@ -3,6 +3,7 @@
*
* The MIT License (MIT)
*
+ * Copyright (c) 2019 Dan Halbert for Adafruit Industries
* Copyright (c) 2018 Artur Pacholec
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -27,12 +28,17 @@
#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_CHARACTERISTIC_H
#define MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_CHARACTERISTIC_H
+#include "shared-module/bleio/Characteristic.h"
#include "common-hal/bleio/Characteristic.h"
extern const mp_obj_type_t bleio_characteristic_type;
-extern void common_hal_bleio_characteristic_construct(bleio_characteristic_obj_t *self, bleio_uuid_obj_t *uuid, bleio_characteristic_properties_t props);
-extern void common_hal_bleio_characteristic_get_value(bleio_characteristic_obj_t *self);
+extern void common_hal_bleio_characteristic_construct(bleio_characteristic_obj_t *self, bleio_uuid_obj_t *uuid, bleio_characteristic_properties_t props, mp_obj_list_t *descriptor_list);
+extern mp_obj_t common_hal_bleio_characteristic_get_value(bleio_characteristic_obj_t *self);
extern void common_hal_bleio_characteristic_set_value(bleio_characteristic_obj_t *self, mp_buffer_info_t *bufinfo);
+extern bleio_characteristic_properties_t common_hal_bleio_characteristic_get_properties(bleio_characteristic_obj_t *self);
+extern bleio_uuid_obj_t *common_hal_bleio_characteristic_get_uuid(bleio_characteristic_obj_t *self);
+extern mp_obj_list_t *common_hal_bleio_characteristic_get_descriptor_list(bleio_characteristic_obj_t *self);
+extern void common_hal_bleio_characteristic_set_cccd(bleio_characteristic_obj_t *self, bool notify, bool indicate);
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_CHARACTERISTIC_H
diff --git a/shared-bindings/bleio/CharacteristicBuffer.c b/shared-bindings/bleio/CharacteristicBuffer.c
index a1dc663fd..26f9e012b 100644
--- a/shared-bindings/bleio/CharacteristicBuffer.c
+++ b/shared-bindings/bleio/CharacteristicBuffer.c
@@ -49,10 +49,13 @@ STATIC void raise_error_if_not_connected(bleio_characteristic_buffer_obj_t *self
//|
//| .. class:: CharacteristicBuffer(characteristic, *, timeout=1, buffer_size=64)
//|
-//| Create a new Characteristic object identified by the specified UUID.
+//| Monitor the given Characteristic. Each time a new value is written to the Characteristic
+//| add the newly-written bytes to a FIFO buffer.
//|
-//| :param bleio.Characteristic characteristic: The characteristic to monitor
-//| :param int timeout: the timeout in seconds to wait for the first character and between subsequent characters.//|
+//| :param bleio.Characteristic characteristic: The Characteristic to monitor.
+//| It may be a local Characteristic provided by a Peripheral Service, or a remote Characteristic
+//| in a remote Service that a Central has connected to.
+//| :param int timeout: the timeout in seconds to wait for the first character and between subsequent characters.
//| :param int buffer_size: Size of ring buffer that stores incoming data coming from client.
//| Must be >= 1.
//|
@@ -85,9 +88,8 @@ STATIC mp_obj_t bleio_characteristic_buffer_make_new(const mp_obj_type_t *type,
bleio_characteristic_buffer_obj_t *self = m_new_obj(bleio_characteristic_buffer_obj_t);
self->base.type = &bleio_characteristic_buffer_type;
- self->characteristic = MP_OBJ_TO_PTR(characteristic);
- common_hal_bleio_characteristic_buffer_construct(self, self->characteristic, timeout, buffer_size);
+ common_hal_bleio_characteristic_buffer_construct(self, MP_OBJ_TO_PTR(characteristic), timeout, buffer_size);
return MP_OBJ_FROM_PTR(self);
}
diff --git a/shared-bindings/bleio/CharacteristicBuffer.h b/shared-bindings/bleio/CharacteristicBuffer.h
index f25017c19..b45835ff3 100644
--- a/shared-bindings/bleio/CharacteristicBuffer.h
+++ b/shared-bindings/bleio/CharacteristicBuffer.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2018 Artur Pacholec
+ * 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
diff --git a/shared-bindings/bleio/Descriptor.c b/shared-bindings/bleio/Descriptor.c
index b32f4f08e..f2e5aa01d 100644
--- a/shared-bindings/bleio/Descriptor.c
+++ b/shared-bindings/bleio/Descriptor.c
@@ -3,8 +3,9 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2017 Glenn Ruben Bakke
+ * Copyright (c) 2019 Dan Halbert for Adafruit Industries
* Copyright (c) 2018 Artur Pacholec
+ * 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
@@ -30,27 +31,6 @@
#include "shared-bindings/bleio/Descriptor.h"
#include "shared-bindings/bleio/UUID.h"
-enum {
- DescriptorUuidCharacteristicExtendedProperties = 0x2900,
- DescriptorUuidCharacteristicUserDescription = 0x2901,
- DescriptorUuidClientCharacteristicConfiguration = 0x2902,
- DescriptorUuidServerCharacteristicConfiguration = 0x2903,
- DescriptorUuidCharacteristicPresentationFormat = 0x2904,
- DescriptorUuidCharacteristicAggregateFormat = 0x2905,
- DescriptorUuidValidRange = 0x2906,
- DescriptorUuidExternalReportReference = 0x2907,
- DescriptorUuidReportReference = 0x2908,
- DescriptorUuidNumberOfDigitals = 0x2909,
- DescriptorUuidValueTriggerSetting = 0x290A,
- DescriptorUuidEnvironmentalSensingConfiguration = 0x290B,
- DescriptorUuidEnvironmentalSensingMeasurement = 0x290C,
- DescriptorUuidEnvironmentalSensingTriggerSetting = 0x290D,
- DescriptorUuidTimeTriggerSetting = 0x290E,
-};
-
-// Work-in-progress: orphaned for now.
-//| :orphan:
-//|
//| .. currentmodule:: bleio
//|
//| :class:`Descriptor` -- BLE descriptor
@@ -113,7 +93,9 @@ const mp_obj_property_t bleio_descriptor_handle_obj = {
STATIC mp_obj_t bleio_descriptor_get_uuid(mp_obj_t self_in) {
bleio_descriptor_obj_t *self = MP_OBJ_TO_PTR(self_in);
- return common_hal_bleio_descriptor_get_uuid(self);
+
+ bleio_uuid_obj_t *uuid = common_hal_bleio_descriptor_get_uuid(self);
+ return uuid ? MP_OBJ_FROM_PTR(uuid) : mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_1(bleio_descriptor_get_uuid_obj, bleio_descriptor_get_uuid);
@@ -130,28 +112,69 @@ STATIC const mp_rom_map_elem_t bleio_descriptor_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_uuid), MP_ROM_PTR(&bleio_descriptor_uuid_obj) },
// Static variables
- { MP_ROM_QSTR(MP_QSTR_CHARACTERISTIC_EXTENDED_PROPERTIES), MP_ROM_INT(DescriptorUuidCharacteristicExtendedProperties) },
- { MP_ROM_QSTR(MP_QSTR_CHARACTERISTIC_USER_DESCRIPTION), MP_ROM_INT(DescriptorUuidCharacteristicUserDescription) },
- { MP_ROM_QSTR(MP_QSTR_CLIENT_CHARACTERISTIC_CONFIGURATION), MP_ROM_INT(DescriptorUuidClientCharacteristicConfiguration) },
- { MP_ROM_QSTR(MP_QSTR_SERVER_CHARACTERISTIC_CONFIGURATION), MP_ROM_INT(DescriptorUuidServerCharacteristicConfiguration) },
- { MP_ROM_QSTR(MP_QSTR_CHARACTERISTIC_PRESENTATION_FORMAT), MP_ROM_INT(DescriptorUuidCharacteristicPresentationFormat) },
- { MP_ROM_QSTR(MP_QSTR_CHARACTERISTIC_AGGREGATE_FORMAT), MP_ROM_INT(DescriptorUuidCharacteristicAggregateFormat) },
- { MP_ROM_QSTR(MP_QSTR_VALID_RANGE), MP_ROM_INT(DescriptorUuidValidRange) },
- { MP_ROM_QSTR(MP_QSTR_EXTERNAL_REPORT_REFERENCE), MP_ROM_INT(DescriptorUuidExternalReportReference) },
- { MP_ROM_QSTR(MP_QSTR_REPORT_REFERENCE), MP_ROM_INT(DescriptorUuidReportReference) },
- { MP_ROM_QSTR(MP_QSTR_NUMBER_OF_DIGITALS), MP_ROM_INT(DescriptorUuidNumberOfDigitals) },
- { MP_ROM_QSTR(MP_QSTR_VALUE_TRIGGER_SETTING), MP_ROM_INT(DescriptorUuidValueTriggerSetting) },
- { MP_ROM_QSTR(MP_QSTR_ENVIRONMENTAL_SENSING_CONFIGURATION), MP_ROM_INT(DescriptorUuidEnvironmentalSensingConfiguration) },
- { MP_ROM_QSTR(MP_QSTR_ENVIRONMENTAL_SENSING_MEASUREMENT ), MP_ROM_INT(DescriptorUuidEnvironmentalSensingMeasurement) },
- { MP_ROM_QSTR(MP_QSTR_ENVIRONMENTAL_SENSING_TRIGGER_SETTING), MP_ROM_INT(DescriptorUuidEnvironmentalSensingTriggerSetting) },
- { MP_ROM_QSTR(MP_QSTR_TIME_TRIGGER_SETTING), MP_ROM_INT(DescriptorUuidTimeTriggerSetting) }
+ { MP_ROM_QSTR(MP_QSTR_CHARACTERISTIC_EXTENDED_PROPERTIES),
+ MP_ROM_INT(DESCRIPTOR_UUID_CHARACTERISTIC_EXTENDED_PROPERTIES) },
+
+ { MP_ROM_QSTR(MP_QSTR_CHARACTERISTIC_USER_DESCRIPTION),
+ MP_ROM_INT(DESCRIPTOR_UUID_CHARACTERISTIC_USER_DESCRIPTION) },
+
+ { MP_ROM_QSTR(MP_QSTR_CLIENT_CHARACTERISTIC_CONFIGURATION),
+ MP_ROM_INT(DESCRIPTOR_UUID_CLIENT_CHARACTERISTIC_CONFIGURATION) },
+
+ { MP_ROM_QSTR(MP_QSTR_SERVER_CHARACTERISTIC_CONFIGURATION),
+ MP_ROM_INT(DESCRIPTOR_UUID_SERVER_CHARACTERISTIC_CONFIGURATION) },
+
+ { MP_ROM_QSTR(MP_QSTR_CHARACTERISTIC_PRESENTATION_FORMAT),
+ MP_ROM_INT(DESCRIPTOR_UUID_CHARACTERISTIC_PRESENTATION_FORMAT) },
+
+ { MP_ROM_QSTR(MP_QSTR_CHARACTERISTIC_AGGREGATE_FORMAT),
+ MP_ROM_INT(DESCRIPTOR_UUID_CHARACTERISTIC_AGGREGATE_FORMAT) },
+
+ { MP_ROM_QSTR(MP_QSTR_VALID_RANGE),
+ MP_ROM_INT(DESCRIPTOR_UUID_VALID_RANGE) },
+
+ { MP_ROM_QSTR(MP_QSTR_EXTERNAL_REPORT_REFERENCE),
+ MP_ROM_INT(DESCRIPTOR_UUID_EXTERNAL_REPORT_REFERENCE) },
+
+ { MP_ROM_QSTR(MP_QSTR_REPORT_REFERENCE),
+ MP_ROM_INT(DESCRIPTOR_UUID_REPORT_REFERENCE) },
+
+ { MP_ROM_QSTR(MP_QSTR_NUMBER_OF_DIGITALS),
+ MP_ROM_INT(DESCRIPTOR_UUID_NUMBER_OF_DIGITALS) },
+
+ { MP_ROM_QSTR(MP_QSTR_VALUE_TRIGGER_SETTING),
+ MP_ROM_INT(DESCRIPTOR_UUID_VALUE_TRIGGER_SETTING) },
+
+ { MP_ROM_QSTR(MP_QSTR_ENVIRONMENTAL_SENSING_CONFIGURATION),
+ MP_ROM_INT(DESCRIPTOR_UUID_ENVIRONMENTAL_SENSING_CONFIGURATION) },
+
+ { MP_ROM_QSTR(MP_QSTR_ENVIRONMENTAL_SENSING_MEASUREMENT ),
+ MP_ROM_INT(DESCRIPTOR_UUID_ENVIRONMENTAL_SENSING_MEASUREMENT) },
+
+ { MP_ROM_QSTR(MP_QSTR_ENVIRONMENTAL_SENSING_TRIGGER_SETTING),
+ MP_ROM_INT(DESCRIPTOR_UUID_ENVIRONMENTAL_SENSING_TRIGGER_SETTING) },
+
+ { MP_ROM_QSTR(MP_QSTR_TIME_TRIGGER_SETTING),
+ MP_ROM_INT(DESCRIPTOR_UUID_TIME_TRIGGER_SETTING) },
};
STATIC MP_DEFINE_CONST_DICT(bleio_descriptor_locals_dict, bleio_descriptor_locals_dict_table);
+STATIC void bleio_descriptor_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
+ bleio_descriptor_obj_t *self = MP_OBJ_TO_PTR(self_in);
+ if (self->uuid) {
+ mp_printf(print, "Descriptor(");
+ bleio_uuid_print(print, MP_OBJ_FROM_PTR(self->uuid), kind);
+ mp_printf(print, ")");
+ } else {
+ mp_printf(print, "<Descriptor with Unregistered UUID>");
+ }
+}
+
const mp_obj_type_t bleio_descriptor_type = {
{ &mp_type_type },
.name = MP_QSTR_Descriptor,
.make_new = bleio_descriptor_make_new,
+ .print = bleio_descriptor_print,
.locals_dict = (mp_obj_dict_t*)&bleio_descriptor_locals_dict
};
diff --git a/shared-bindings/bleio/Descriptor.h b/shared-bindings/bleio/Descriptor.h
index f47378ee1..fd11ea08c 100644
--- a/shared-bindings/bleio/Descriptor.h
+++ b/shared-bindings/bleio/Descriptor.h
@@ -3,6 +3,7 @@
*
* The MIT License (MIT)
*
+ * Copyright (c) 2019 Dan Halbert for Adafruit Industries
* Copyright (c) 2018 Artur Pacholec
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -30,6 +31,24 @@
#include "common-hal/bleio/Descriptor.h"
#include "common-hal/bleio/UUID.h"
+enum {
+ DESCRIPTOR_UUID_CHARACTERISTIC_EXTENDED_PROPERTIES = 0x2900,
+ DESCRIPTOR_UUID_CHARACTERISTIC_USER_DESCRIPTION = 0x2901,
+ DESCRIPTOR_UUID_CLIENT_CHARACTERISTIC_CONFIGURATION = 0x2902,
+ DESCRIPTOR_UUID_SERVER_CHARACTERISTIC_CONFIGURATION = 0x2903,
+ DESCRIPTOR_UUID_CHARACTERISTIC_PRESENTATION_FORMAT = 0x2904,
+ DESCRIPTOR_UUID_CHARACTERISTIC_AGGREGATE_FORMAT = 0x2905,
+ DESCRIPTOR_UUID_VALID_RANGE = 0x2906,
+ DESCRIPTOR_UUID_EXTERNAL_REPORT_REFERENCE = 0x2907,
+ DESCRIPTOR_UUID_REPORT_REFERENCE = 0x2908,
+ DESCRIPTOR_UUID_NUMBER_OF_DIGITALS = 0x2909,
+ DESCRIPTOR_UUID_VALUE_TRIGGER_SETTING = 0x290A,
+ DESCRIPTOR_UUID_ENVIRONMENTAL_SENSING_CONFIGURATION = 0x290B,
+ DESCRIPTOR_UUID_ENVIRONMENTAL_SENSING_MEASUREMENT = 0x290C,
+ DESCRIPTOR_UUID_ENVIRONMENTAL_SENSING_TRIGGER_SETTING = 0x290D,
+ DESCRIPTOR_UUID_TIME_TRIGGER_SETTING = 0x290E,
+};
+
extern const mp_obj_type_t bleio_descriptor_type;
extern void common_hal_bleio_descriptor_construct(bleio_descriptor_obj_t *self, bleio_uuid_obj_t *uuid);
diff --git a/shared-bindings/bleio/Device.c b/shared-bindings/bleio/Device.c
deleted file mode 100644
index 80595ef33..000000000
--- a/shared-bindings/bleio/Device.c
+++ /dev/null
@@ -1,363 +0,0 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2016 Glenn Ruben Bakke
- * Copyright (c) 2018 Artur Pacholec
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-#include <string.h>
-#include <stdio.h>
-
-#include "ble_drv.h"
-#include "py/objarray.h"
-#include "py/objproperty.h"
-#include "py/objstr.h"
-#include "py/runtime.h"
-#include "shared-bindings/bleio/Adapter.h"
-#include "shared-bindings/bleio/AddressType.h"
-#include "shared-bindings/bleio/Characteristic.h"
-#include "shared-bindings/bleio/Device.h"
-#include "shared-bindings/bleio/Service.h"
-#include "shared-bindings/bleio/UUID.h"
-#include "shared-module/bleio/AdvertisementData.h"
-#include "shared-module/bleio/Device.h"
-#include "shared-module/bleio/ScanEntry.h"
-
-// Work-in-progress: orphaned for now.
-//| :orphan:
-//|
-//| .. currentmodule:: bleio
-//|
-//| :class:`Device` -- BLE device
-//| =========================================================
-//|
-//| **IGNORE ``Device`` and all its documentation.
-//| It is being replaced by `Peripheral` and other classes.**
-//|
-//| Provides access a to BLE device, either in a Peripheral or Central role.
-//| When a device is created without any parameter passed to the constructor,
-//| it will be set to the Peripheral role. If a address is passed, the device
-//| will be a Central. For a Peripheral you can set the `name`, add services
-//| via `add_service` and then start and stop advertising via `bleio.Device.start_advertising`
-//| and `bleio.Device.stop_advertising`. For the Central, you can `bleio.Device.connect` and `bleio.Device.disconnect`
-//| to the device, once a connection is established, the device's services can
-//| be accessed using `bleio.Device.services`.
-//|
-//| Usage::
-//|
-//| import bleio
-//|
-//| # Peripheral
-//| periph = bleio.Device()
-//|
-//| serv = bleio.Service(bleio.UUID(0x180f))
-//| p.add_service(serv)
-//|
-//| chara = bleio.Characteristic(bleio.UUID(0x2919))
-//| chara.read = True
-//| chara.notify = True
-//| serv.add_characteristic(chara)
-//|
-//| periph.start_advertising()
-//|
-//| # Central
-//| scanner = bleio.Scanner()
-//| entries = scanner.scan(2500)
-//|
-//| my_entry = None
-//| for entry in entries:
-//| if entry.name is not None and entry.name == 'MyDevice':
-//| my_entry = entry
-//| break
-//|
-//| central = bleio.Device(my_entry.address)
-//| central.connect()
-//|
-
-//| .. class:: Device(address=None, scan_entry=None)
-//|
-//| Create a new Device object. If the `address` or :py:data:`scan_entry` parameters are not `None`,
-//| the role is set to Central, otherwise it's set to Peripheral.
-//|
-//| :param bleio.Address address: The address of the device to connect to
-//| :param bleio.ScanEntry scan_entry: The scan entry returned from `bleio.Scanner`
-//|
-
-//| .. attribute:: name
-//|
-//| For the Peripheral role, this property can be used to read and write the device's name.
-//| For the Central role, this property will equal the name of the remote device, if one was
-//| advertised by the device. In the Central role this property is read-only.
-//|
-
-//| .. attribute:: services
-//|
-//| A `list` of `bleio.Service` that are offered by this device. (read-only)
-//| For a Peripheral device, this list will contain services added using `add_service`,
-//| for a Central, this list will be empty until a connection is established, at which point
-//| it will be filled with the remote device's services.
-//|
-
-//| .. method:: add_service(service)
-//|
-//| Appends the :py:data:`service` to the list of this devices's services.
-//| This method can only be called for Peripheral devices.
-//|
-//| :param bleio.Service service: the service to append
-//|
-
-//| .. method:: connect()
-//|
-//| Attempts a connection to the remote device. If the connection is successful,
-//| the device's services are available via `services`.
-//| This method can only be called for Central devices.
-//|
-
-//| .. method:: disconnect()
-//|
-//| Disconnects from the remote device.
-//| This method can only be called for Central devices.
-//|
-
-//| .. method:: start_advertising(connectable=True)
-//|
-//| Starts advertising the device. The device's name and
-//| services are put into the advertisement packets.
-//| If :py:data:`connectable` is `True` then other devices are allowed to conncet to this device.
-//| This method can only be called for Peripheral devices.
-//|
-
-//| .. method:: stop_advertising()
-//|
-//| Disconnects from the remote device.
-//| This method can only be called for Peripheral devices.
-//|
-
-// TODO: Add unique MAC address part to name
-static const char default_name[] = "CIRCUITPY";
-
-STATIC void bleio_device_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
- bleio_device_obj_t *self = MP_OBJ_TO_PTR(self_in);
-
- mp_printf(print, "Device(role: %s)", self->is_peripheral ? "Peripheral" : "Central");
-}
-
-STATIC mp_obj_t bleio_device_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *pos_args) {
- mp_arg_check_num(n_args, n_kw, 0, 1, true);
- bleio_device_obj_t *self = m_new_obj(bleio_device_obj_t);
- self->base.type = &bleio_device_type;
- self->service_list = mp_obj_new_list(0, NULL);
- self->notif_handler = mp_const_none;
- self->conn_handler = mp_const_none;
- self->conn_handle = 0xFFFF;
- self->is_peripheral = true;
-
- mp_map_t kw_args;
- mp_map_init_fixed_table(&kw_args, n_kw, pos_args + n_args);
-
- enum { ARG_address, ARG_scan_entry };
- static const mp_arg_t allowed_args[] = {
- { MP_QSTR_address, MP_ARG_OBJ, {.u_obj = mp_const_none} },
- { MP_QSTR_scan_entry, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = mp_const_none} },
- };
-
- mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
- mp_arg_parse_all(n_args, pos_args, &kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
-
- const mp_obj_t address_obj = args[ARG_address].u_obj;
- const mp_obj_t scan_entry_obj = args[ARG_scan_entry].u_obj;
-
- if (address_obj != mp_const_none) {
- bleio_address_obj_t *address = MP_OBJ_TO_PTR(address_obj);
-
- self->is_peripheral = false;
- self->address.type = address->type;
- memcpy(self->address.value, address->value, BLEIO_ADDRESS_BYTES);
- } else if (scan_entry_obj != mp_const_none) {
- bleio_scanentry_obj_t *scan_entry = MP_OBJ_TO_PTR(scan_entry_obj);
-
- self->is_peripheral = false;
- self->address.type = scan_entry->address.type;
- memcpy(self->address.value, scan_entry->address.value, BLEIO_ADDRESS_BYTES);
- } else {
- self->name = mp_obj_new_str(default_name, strlen(default_name));
- common_hal_bleio_adapter_get_address(&self->address);
- }
-
- return MP_OBJ_FROM_PTR(self);
-}
-
-STATIC mp_obj_t bleio_device_add_service(mp_obj_t self_in, mp_obj_t service_in) {
- bleio_device_obj_t *self = MP_OBJ_TO_PTR(self_in);
- bleio_service_obj_t *service = MP_OBJ_TO_PTR(service_in);
-
- if (!self->is_peripheral) {
- nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError,
- translate("Can't add services in Central mode")));
- }
-
- service->device = self;
-
- mp_obj_list_append(self->service_list, service);
-
- return mp_const_none;
-}
-STATIC MP_DEFINE_CONST_FUN_OBJ_2(bleio_device_add_service_obj, bleio_device_add_service);
-
-STATIC mp_obj_t bleio_device_connect(mp_obj_t self_in) {
- bleio_device_obj_t *self = MP_OBJ_TO_PTR(self_in);
-
- if (self->is_peripheral) {
- nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError,
- translate("Can't connect in Peripheral mode")));
- }
-
- common_hal_bleio_device_connect(self);
-
- return mp_const_none;
-}
-STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_device_connect_obj, bleio_device_connect);
-
-STATIC mp_obj_t bleio_device_disconnect(mp_obj_t self_in) {
- bleio_device_obj_t *self = MP_OBJ_TO_PTR(self_in);
-
- common_hal_bleio_device_disconnect(self);
-
- return mp_const_none;
-}
-STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_device_disconnect_obj, bleio_device_disconnect);
-
-STATIC mp_obj_t bleio_device_get_name(mp_obj_t self_in) {
- bleio_device_obj_t *self = MP_OBJ_TO_PTR(self_in);
-
- return self->name;
-}
-MP_DEFINE_CONST_FUN_OBJ_1(bleio_device_get_name_obj, bleio_device_get_name);
-
-static mp_obj_t bleio_device_set_name(mp_obj_t self_in, mp_obj_t value) {
- bleio_device_obj_t *self = MP_OBJ_TO_PTR(self_in);
-
- if (!self->is_peripheral) {
- nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError,
- translate("Can't change the name in Central mode")));
- }
-
- self->name = value;
-
- return mp_const_none;
-}
-STATIC MP_DEFINE_CONST_FUN_OBJ_2(bleio_device_set_name_obj, bleio_device_set_name);
-
-const mp_obj_property_t bleio_device_name_obj = {
- .base.type = &mp_type_property,
- .proxy = { (mp_obj_t)&bleio_device_get_name_obj,
- (mp_obj_t)&bleio_device_set_name_obj,
- (mp_obj_t)&mp_const_none_obj },
-};
-
-STATIC mp_obj_t bleio_device_start_advertising(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
- bleio_device_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]);
-
- if (!self->is_peripheral) {
- nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError,
- translate("Can't advertise in Central mode")));
- }
-
- enum { ARG_connectable, ARG_data };
- static const mp_arg_t allowed_args[] = {
- { MP_QSTR_connectable, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = true} },
- { MP_QSTR_data, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} },
- };
-
- mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
- mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
-
- mp_buffer_info_t bufinfo = { 0 };
- if (args[ARG_data].u_obj != mp_const_none) {
- mp_get_buffer_raise(args[ARG_data].u_obj, &bufinfo, MP_BUFFER_READ);
- }
-
- const mp_obj_list_t *service_list = MP_OBJ_TO_PTR(self->service_list);
- for (size_t i = 0; i < service_list->len; ++i) {
- bleio_service_obj_t *service = service_list->items[i];
- if (service->handle == 0xFFFF) {
- common_hal_bleio_device_add_service(self, service);
- }
- }
-
- common_hal_bleio_device_start_advertising(self, args[ARG_connectable].u_bool, &bufinfo);
-
- return mp_const_none;
-}
-STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_device_start_advertising_obj, 0, bleio_device_start_advertising);
-
-STATIC mp_obj_t bleio_device_stop_advertising(mp_obj_t self_in) {
- bleio_device_obj_t *self = MP_OBJ_TO_PTR(self_in);
-
- if (!self->is_peripheral) {
- nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError,
- translate("Can't advertise in Central mode")));
- }
-
- common_hal_bleio_device_stop_advertising(self);
-
- return mp_const_none;
-}
-STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_device_stop_advertising_obj, bleio_device_stop_advertising);
-
-STATIC mp_obj_t bleio_device_get_services(mp_obj_t self_in) {
- bleio_device_obj_t *self = MP_OBJ_TO_PTR(self_in);
-
- return self->service_list;
-}
-STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_device_get_services_obj, bleio_device_get_services);
-
-const mp_obj_property_t bleio_device_services_obj = {
- .base.type = &mp_type_property,
- .proxy = { (mp_obj_t)&bleio_device_get_services_obj,
- (mp_obj_t)&mp_const_none_obj,
- (mp_obj_t)&mp_const_none_obj },
-};
-
-STATIC const mp_rom_map_elem_t bleio_device_locals_dict_table[] = {
- // Methods
- { MP_ROM_QSTR(MP_QSTR_add_service), MP_ROM_PTR(&bleio_device_add_service_obj) },
- { MP_ROM_QSTR(MP_QSTR_connect), MP_ROM_PTR(&bleio_device_connect_obj) },
- { MP_ROM_QSTR(MP_QSTR_disconnect), MP_ROM_PTR(&bleio_device_disconnect_obj) },
- { MP_ROM_QSTR(MP_QSTR_start_advertising), MP_ROM_PTR(&bleio_device_start_advertising_obj) },
- { MP_ROM_QSTR(MP_QSTR_stop_advertising), MP_ROM_PTR(&bleio_device_stop_advertising_obj) },
-
- // Properties
- { MP_ROM_QSTR(MP_QSTR_name), MP_ROM_PTR(&bleio_device_name_obj) },
- { MP_ROM_QSTR(MP_QSTR_services), MP_ROM_PTR(&bleio_device_services_obj) },
-};
-
-STATIC MP_DEFINE_CONST_DICT(bleio_device_locals_dict, bleio_device_locals_dict_table);
-
-const mp_obj_type_t bleio_device_type = {
- { &mp_type_type },
- .name = MP_QSTR_Device,
- .print = bleio_device_print,
- .make_new = bleio_device_make_new,
- .locals_dict = (mp_obj_dict_t*)&bleio_device_locals_dict
-};
diff --git a/shared-bindings/bleio/Peripheral.c b/shared-bindings/bleio/Peripheral.c
index 340485f35..1302c9652 100644
--- a/shared-bindings/bleio/Peripheral.c
+++ b/shared-bindings/bleio/Peripheral.c
@@ -3,8 +3,9 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2016 Glenn Ruben Bakke
+ * Copyright (c) 2019 Dan Halbert for Adafruit Industries
* Copyright (c) 2018 Artur Pacholec
+ * Copyright (c) 2016 Glenn Ruben Bakke
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -35,19 +36,22 @@
#include "py/runtime.h"
#include "shared-bindings/bleio/Adapter.h"
-#include "shared-bindings/bleio/AddressType.h"
#include "shared-bindings/bleio/Characteristic.h"
#include "shared-bindings/bleio/Peripheral.h"
#include "shared-bindings/bleio/Service.h"
#include "shared-bindings/bleio/UUID.h"
-#include "shared-module/bleio/AdvertisementData.h"
#include "shared-module/bleio/ScanEntry.h"
#include "common-hal/bleio/Peripheral.h"
-// TODO: Add unique MAC address part to name
static const char default_name[] = "CIRCUITPY";
+#define ADV_INTERVAL_DEFAULT (1.0f)
+#define ADV_INTERVAL_MIN (0.0020f)
+#define ADV_INTERVAL_MIN_STRING "0.0020"
+#define ADV_INTERVAL_MAX (10.24f)
+#define ADV_INTERVAL_MAX_STRING "10.24"
+
//| .. currentmodule:: bleio
//|
//| :class:`Peripheral` -- A BLE peripheral device
@@ -59,6 +63,7 @@ static const char default_name[] = "CIRCUITPY";
//| Usage::
//|
//| import bleio
+//| from adafruit_ble.advertising import ServerAdvertisement
//|
//| # Create a Characteristic.
//| chara = bleio.Characteristic(bleio.UUID(0x2919), read=True, notify=True)
@@ -68,25 +73,27 @@ static const char default_name[] = "CIRCUITPY";
//|
//| # Create a peripheral and start it up.
//| periph = bleio.Peripheral([service])
-//| periph.start_advertising()
+//| adv = ServerAdvertisement(periph)
+//| periph.start_advertising(adv.advertising_data_bytes, adv.scan_response_bytes)
//|
//| while not periph.connected:
//| # Wait for connection.
//| pass
//|
-//| .. class:: Peripheral(services, *, name='CIRCUITPY')
+//| .. class:: Peripheral(services=(), \*, name='CIRCUITPY')
//|
//| Create a new Peripheral object.
-
-//| :param iterable services: the Service objects representing services available from this peripheral.
-//| :param str name: The name used when advertising this peripheral
//|
-
+//| :param iterable services: the Service objects representing services available from this peripheral, if any.
+//| A non-connectable peripheral will have no services.
+//| :param str name: The name used when advertising this peripheral. Use ``None`` when a name is not needed,
+//| such as when the peripheral is a beacon
+//|
STATIC mp_obj_t bleio_peripheral_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_services, ARG_name };
static const mp_arg_t allowed_args[] = {
- { MP_QSTR_services, MP_ARG_OBJ, {.u_obj = mp_const_none} },
- { MP_QSTR_name, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = mp_const_none} },
+ { MP_QSTR_services, MP_ARG_OBJ, {.u_obj = mp_const_empty_tuple} },
+ { MP_QSTR_name, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = MP_OBJ_NULL} },
};
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
@@ -95,32 +102,33 @@ STATIC mp_obj_t bleio_peripheral_make_new(const mp_obj_type_t *type, size_t n_ar
// If services is not an iterable, an exception will be thrown.
mp_obj_iter_buf_t iter_buf;
mp_obj_t iterable = mp_getiter(args[ARG_services].u_obj, &iter_buf);
- mp_obj_t service;
bleio_peripheral_obj_t *self = m_new_obj(bleio_peripheral_obj_t);
self->base.type = &bleio_peripheral_type;
- self->service_list = mp_obj_new_list(0, NULL);
- self->notif_handler = mp_const_none;
+
+ // Copy the services list and validate its items.
+ mp_obj_t service_list_obj = mp_obj_new_list(0, NULL);
+ mp_obj_list_t *service_list = MP_OBJ_FROM_PTR(service_list_obj);
+
+ mp_obj_t service;
while ((service = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) {
if (!MP_OBJ_IS_TYPE(service, &bleio_service_type)) {
- mp_raise_ValueError(translate("services includes an object that is not a Service"));
+ mp_raise_ValueError(translate("non-Service found in services"));
}
- bleio_service_obj_t *service_ptr = MP_OBJ_TO_PTR(service);
- service_ptr->device = MP_OBJ_FROM_PTR(self);
- mp_obj_list_append(self->service_list, service);
+ mp_obj_list_append(service_list, service);
}
const mp_obj_t name = args[ARG_name].u_obj;
- if (name == mp_const_none) {
- self->name = mp_obj_new_str(default_name, strlen(default_name));
+ mp_obj_t name_str;
+ if (name == MP_OBJ_NULL || name == mp_const_none) {
+ name_str = mp_obj_new_str(default_name, strlen(default_name));
} else if (MP_OBJ_IS_STR(name)) {
- self->name = name;
+ name_str = name;
} else {
mp_raise_ValueError(translate("name must be a string"));
}
- // Do port-specific initialization.
- common_hal_bleio_peripheral_construct(self);
+ common_hal_bleio_peripheral_construct(self, service_list, name_str);
return MP_OBJ_FROM_PTR(self);
}
@@ -132,7 +140,6 @@ STATIC mp_obj_t bleio_peripheral_make_new(const mp_obj_type_t *type, size_t n_ar
STATIC mp_obj_t bleio_peripheral_get_connected(mp_obj_t self_in) {
bleio_peripheral_obj_t *self = MP_OBJ_TO_PTR(self_in);
- // Return list as a tuple so user won't be able to change it.
return mp_obj_new_bool(common_hal_bleio_peripheral_get_connected(self));
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_peripheral_get_connected_obj, bleio_peripheral_get_connected);
@@ -151,7 +158,7 @@ const mp_obj_property_t bleio_peripheral_connected_obj = {
STATIC mp_obj_t bleio_peripheral_get_services(mp_obj_t self_in) {
bleio_peripheral_obj_t *self = MP_OBJ_TO_PTR(self_in);
// Return list as a tuple so user won't be able to change it.
- mp_obj_list_t *service_list = MP_OBJ_TO_PTR(self->service_list);
+ mp_obj_list_t *service_list = common_hal_bleio_peripheral_get_service_list(self);
return mp_obj_new_tuple(service_list->len, service_list->items);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_peripheral_get_services_obj, bleio_peripheral_get_services);
@@ -170,7 +177,7 @@ const mp_obj_property_t bleio_peripheral_services_obj = {
STATIC mp_obj_t bleio_peripheral_get_name(mp_obj_t self_in) {
bleio_peripheral_obj_t *self = MP_OBJ_TO_PTR(self_in);
- return self->name;
+ return common_hal_bleio_peripheral_get_name(self);
}
MP_DEFINE_CONST_FUN_OBJ_1(bleio_peripheral_get_name_obj, bleio_peripheral_get_name);
@@ -181,37 +188,55 @@ const mp_obj_property_t bleio_peripheral_name_obj = {
(mp_obj_t)&mp_const_none_obj },
};
-//| .. method:: start_advertising(*, connectable=True, data=None)
+//| .. method:: start_advertising(data, *, scan_response=None, connectable=True, interval=1)
//|
//| Starts advertising the peripheral. The peripheral's name and
//| services are included in the advertisement packets.
//|
+//| :param buf data: advertising data packet bytes
+//| :param buf scan_response: scan response data packet bytes. ``None`` if no scan response is needed.
//| :param bool connectable: If `True` then other devices are allowed to connect to this peripheral.
-//| :param buf data: If `None`, advertise the services passed to this Peripheral when it was created.
-//| If not `None`, then send the bytes in ``data`` as the advertising packet.
+//| :param float interval: advertising interval, in seconds
//|
STATIC mp_obj_t bleio_peripheral_start_advertising(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
bleio_peripheral_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]);
- enum { ARG_connectable, ARG_data };
+ enum { ARG_data, ARG_scan_response, ARG_connectable, ARG_interval };
static const mp_arg_t allowed_args[] = {
+ { MP_QSTR_data, MP_ARG_REQUIRED | MP_ARG_OBJ },
+ { MP_QSTR_scan_response, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} },
{ MP_QSTR_connectable, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = true} },
- { MP_QSTR_data, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} },
+ { MP_QSTR_interval, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
};
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
- mp_buffer_info_t bufinfo = { 0 };
- if (args[ARG_data].u_obj != mp_const_none) {
- mp_get_buffer_raise(args[ARG_data].u_obj, &bufinfo, MP_BUFFER_READ);
+ mp_buffer_info_t data_bufinfo;
+ mp_get_buffer_raise(args[ARG_data].u_obj, &data_bufinfo, MP_BUFFER_READ);
+
+ // Pass an empty buffer if scan_response not provided.
+ mp_buffer_info_t scan_response_bufinfo = { 0 };
+ if (args[ARG_scan_response].u_obj != mp_const_none) {
+ mp_get_buffer_raise(args[ARG_scan_response].u_obj, &scan_response_bufinfo, MP_BUFFER_READ);
}
- common_hal_bleio_peripheral_start_advertising(self, args[ARG_connectable].u_bool, &bufinfo);
+ if (args[ARG_interval].u_obj == MP_OBJ_NULL) {
+ args[ARG_interval].u_obj = mp_obj_new_float(1.0F);
+ }
+
+ const mp_float_t interval = mp_obj_float_get(args[ARG_interval].u_obj);
+ if (interval < ADV_INTERVAL_MIN || interval > ADV_INTERVAL_MAX) {
+ mp_raise_ValueError_varg(translate("interval must be in range %s-%s"),
+ ADV_INTERVAL_MIN_STRING, ADV_INTERVAL_MAX_STRING);
+ }
+
+ common_hal_bleio_peripheral_start_advertising(self, args[ARG_connectable].u_bool, interval,
+ &data_bufinfo, &scan_response_bufinfo);
return mp_const_none;
}
-STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_peripheral_start_advertising_obj, 0, bleio_peripheral_start_advertising);
+STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_peripheral_start_advertising_obj, 2, bleio_peripheral_start_advertising);
//| .. method:: stop_advertising()
//|
@@ -225,10 +250,26 @@ STATIC mp_obj_t bleio_peripheral_stop_advertising(mp_obj_t self_in) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_peripheral_stop_advertising_obj, bleio_peripheral_stop_advertising);
+//| .. method:: disconnect()
+//|
+//| Disconnects from the remote central.
+//| Normally the central initiates a disconnection. Use this only
+//| if necessary for your application.
+//|
+STATIC mp_obj_t bleio_peripheral_disconnect(mp_obj_t self_in) {
+ bleio_peripheral_obj_t *self = MP_OBJ_TO_PTR(self_in);
+
+ common_hal_bleio_peripheral_disconnect(self);
+
+ return mp_const_none;
+}
+STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_peripheral_disconnect_obj, bleio_peripheral_disconnect);
+
STATIC const mp_rom_map_elem_t bleio_peripheral_locals_dict_table[] = {
// Methods
{ MP_ROM_QSTR(MP_QSTR_start_advertising), MP_ROM_PTR(&bleio_peripheral_start_advertising_obj) },
{ MP_ROM_QSTR(MP_QSTR_stop_advertising), MP_ROM_PTR(&bleio_peripheral_stop_advertising_obj) },
+ { MP_ROM_QSTR(MP_QSTR_disconnect), MP_ROM_PTR(&bleio_peripheral_disconnect_obj) },
// Properties
{ MP_ROM_QSTR(MP_QSTR_connected), MP_ROM_PTR(&bleio_peripheral_connected_obj) },
diff --git a/shared-bindings/bleio/Peripheral.h b/shared-bindings/bleio/Peripheral.h
index 02a5c1ef8..846250a5f 100644
--- a/shared-bindings/bleio/Peripheral.h
+++ b/shared-bindings/bleio/Peripheral.h
@@ -3,8 +3,8 @@
*
* The MIT License (MIT)
*
+ * Copyright (c) 2019 Dan Halbert for Adafruit Industries
* Copyright (c) 2018 Artur Pacholec
- * 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
@@ -32,9 +32,12 @@
extern const mp_obj_type_t bleio_peripheral_type;
-extern void common_hal_bleio_peripheral_construct(bleio_peripheral_obj_t *self);
+extern void common_hal_bleio_peripheral_construct(bleio_peripheral_obj_t *self, mp_obj_list_t *service_list, mp_obj_t name);
+extern mp_obj_list_t *common_hal_bleio_peripheral_get_service_list(bleio_peripheral_obj_t *self);
extern bool common_hal_bleio_peripheral_get_connected(bleio_peripheral_obj_t *self);
-extern void common_hal_bleio_peripheral_start_advertising(bleio_peripheral_obj_t *device, bool connectable, mp_buffer_info_t *raw_data);
+extern mp_obj_t common_hal_bleio_peripheral_get_name(bleio_peripheral_obj_t *self);
+extern void common_hal_bleio_peripheral_start_advertising(bleio_peripheral_obj_t *device, bool connectable, float interval, mp_buffer_info_t *advertising_data_bufinfo, mp_buffer_info_t *scan_response_data_bufinfo);
extern void common_hal_bleio_peripheral_stop_advertising(bleio_peripheral_obj_t *device);
+extern void common_hal_bleio_peripheral_disconnect(bleio_peripheral_obj_t *device);
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_PERIPHERAL_H
diff --git a/shared-bindings/bleio/ScanEntry.c b/shared-bindings/bleio/ScanEntry.c
index e6b955078..6eb02c716 100644
--- a/shared-bindings/bleio/ScanEntry.c
+++ b/shared-bindings/bleio/ScanEntry.c
@@ -3,6 +3,7 @@
*
* The MIT License (MIT)
*
+ * Copyright (c) 2019 Dan Halbert for Adafruit Industries
* Copyright (c) 2018 Artur Pacholec
* Copyright (c) 2017 Glenn Ruben Bakke
*
@@ -27,278 +28,78 @@
#include <string.h>
-#include "py/objarray.h"
#include "py/objproperty.h"
-#include "py/objstr.h"
-#include "py/objtuple.h"
#include "shared-bindings/bleio/Address.h"
#include "shared-bindings/bleio/ScanEntry.h"
#include "shared-bindings/bleio/UUID.h"
-#include "shared-module/bleio/AdvertisementData.h"
#include "shared-module/bleio/ScanEntry.h"
-// Work-in-progress: orphaned for now.
-//| :orphan:
-//|
//| .. currentmodule:: bleio
//|
//| :class:`ScanEntry` -- BLE scan response entry
//| =========================================================
//|
//| Encapsulates information about a device that was received as a
-//| response to a BLE scan request.
+//| response to a BLE scan request. This object may only be created
+//| by a `bleio.Scanner`: it has no user-visible constructor.
//|
//| .. attribute:: address
//|
-//| The address of the device. (read-only)
-//| This attribute is of type `bleio.Address`.
-//|
-
-//| .. attribute:: manufacturer_specific_data
-//|
-//| The manufacturer-specific data present in the advertisement packet. (read-only)
-//|
-
-//| .. attribute:: name
-//|
-//| The name of the device. (read-only)
-//| This attribute might be `None` if the data was missing from the advertisement packet.
-//|
-
-//| .. attribute:: raw_data
-//|
-//| All the advertisement data present in the packet. (read-only)
+//| The address of the device (read-only), of type `bleio.Address`.
//|
-
-//| .. attribute:: rssi
-//|
-//| The signal strength of the device at the time of the scan. (read-only)
-//|
-
-//| .. attribute:: service_uuids
-//|
-//| The address of the device. (read-only)
-//| This attribute is a list of `bleio.UUID`.
-//| This attribute might be empty or incomplete, depending on the advertisement packet.
-//| Currently only 16-bit UUIDS are listed.
-//|
-
-//| .. attribute:: tx_power_level
-//|
-//| The transmit power level of the device. (read-only)
-//| This attribute might be `None` if the data was missing from the advertisement packet.
-//|
-static uint8_t find_data_item(mp_obj_array_t *data_in, uint8_t type, uint8_t **data_out) {
- uint16_t i = 0;
- while (i < data_in->len) {
- const uint8_t item_len = ((uint8_t*)data_in->items)[i];
- const uint8_t item_type = ((uint8_t*)data_in->items)[i + 1];
- if (item_type != type) {
- i += (item_len + 1);
- continue;
- }
-
- *data_out = &((uint8_t*)data_in->items)[i + 2];
-
- return item_len;
- }
-
- return 0;
-}
-
-STATIC mp_obj_t scanentry_get_name(mp_obj_t self_in);
-
-STATIC void bleio_scanentry_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
- bleio_scanentry_obj_t *self = (bleio_scanentry_obj_t *)self_in;
- mp_printf(print, "ScanEntry(address: %02x:%02x:%02x:%02x:%02x:%02x",
- self->address.value[5], self->address.value[4], self->address.value[3],
- self->address.value[1], self->address.value[1], self->address.value[0]);
-
- const mp_obj_t name_obj = scanentry_get_name(self_in);
- if (name_obj != mp_const_none) {
- mp_obj_str_t *str = MP_OBJ_TO_PTR(name_obj);
- mp_printf(print, " name: %s", str->data);
- }
-
- mp_print_str(print, ")");
-}
-
STATIC mp_obj_t bleio_scanentry_get_address(mp_obj_t self_in) {
bleio_scanentry_obj_t *self = MP_OBJ_TO_PTR(self_in);
-
- mp_obj_t obj = bleio_address_type.make_new(&bleio_address_type, 1, 0, (mp_obj_t)&mp_const_none_obj);
- bleio_address_obj_t *address = MP_OBJ_TO_PTR(obj);
-
- address->type = self->address.type;
- memcpy(address->value, self->address.value, BLEIO_ADDRESS_BYTES);
-
- return obj;
+ return common_hal_bleio_scanentry_get_address(self);
}
-STATIC MP_DEFINE_CONST_FUN_OBJ_1(bluepy_scanentry_get_address_obj, bleio_scanentry_get_address);
+STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_scanentry_get_address_obj, bleio_scanentry_get_address);
const mp_obj_property_t bleio_scanentry_address_obj = {
.base.type = &mp_type_property,
- .proxy = { (mp_obj_t)&bluepy_scanentry_get_address_obj,
- (mp_obj_t)&mp_const_none_obj,
- (mp_obj_t)&mp_const_none_obj },
-};
-
-STATIC mp_obj_t scanentry_get_manufacturer_specific_data(mp_obj_t self_in) {
- bleio_scanentry_obj_t *self = MP_OBJ_TO_PTR(self_in);
- mp_obj_array_t *data = MP_OBJ_TO_PTR(self->data);
- uint8_t *manuf_data;
-
- const uint8_t manuf_data_len = find_data_item(data, AdManufacturerSpecificData, &manuf_data);
- if (manuf_data_len == 0) {
- return mp_const_none;
- }
-
- return mp_obj_new_bytearray_by_ref(manuf_data_len, manuf_data);
-}
-STATIC MP_DEFINE_CONST_FUN_OBJ_1(scanentry_get_manufacturer_specific_data_obj, scanentry_get_manufacturer_specific_data);
-
-const mp_obj_property_t bleio_scanentry_manufacturer_specific_data_obj = {
- .base.type = &mp_type_property,
- .proxy = { (mp_obj_t)&scanentry_get_manufacturer_specific_data_obj,
+ .proxy = { (mp_obj_t)&bleio_scanentry_get_address_obj,
(mp_obj_t)&mp_const_none_obj,
(mp_obj_t)&mp_const_none_obj },
};
-STATIC mp_obj_t scanentry_get_name(mp_obj_t self_in) {
- bleio_scanentry_obj_t *self = MP_OBJ_TO_PTR(self_in);
- mp_obj_array_t *data = MP_OBJ_TO_PTR(self->data);
- uint8_t *name;
-
- // Try for Complete but settle for Shortened
- uint8_t name_len = find_data_item(data, AdCompleteLocalName, &name);
- if (name_len == 0) {
- name_len = find_data_item(data, AdShortenedLocalName, &name);
- }
-
- if (name_len == 0) {
- return mp_const_none;
- }
-
- return mp_obj_new_str((const char*)name, name_len - 1);
-}
-STATIC MP_DEFINE_CONST_FUN_OBJ_1(bluepy_scanentry_get_name_obj, scanentry_get_name);
-
-const mp_obj_property_t bleio_scanentry_name_obj = {
- .base.type = &mp_type_property,
- .proxy = { (mp_obj_t)&bluepy_scanentry_get_name_obj,
- (mp_obj_t)&mp_const_none_obj,
- (mp_obj_t)&mp_const_none_obj },
-};
-
-STATIC mp_obj_t scanentry_get_raw_data(mp_obj_t self_in) {
+//| .. attribute:: advertisement_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) {
bleio_scanentry_obj_t *self = MP_OBJ_TO_PTR(self_in);
-
- mp_obj_t entries = mp_obj_new_list(0, NULL);
-
- mp_obj_array_t *data = MP_OBJ_TO_PTR(self->data);
-
- uint16_t i = 0;
- while (i < data->len) {
- mp_obj_tuple_t *entry = MP_OBJ_TO_PTR(mp_obj_new_tuple(2, NULL));
-
- const uint8_t item_len = ((uint8_t*)data->items)[i];
- const uint8_t item_type = ((uint8_t*)data->items)[i + 1];
-
- entry->items[0] = MP_OBJ_NEW_SMALL_INT(item_type);
- entry->items[1] = mp_obj_new_bytearray(item_len - 1, &((uint8_t*)data->items)[i + 2]);
- mp_obj_list_append(entries, MP_OBJ_FROM_PTR(entry));
-
- i += (item_len + 1);
- }
-
- return entries;
+ return common_hal_bleio_scanentry_get_advertisement_bytes(self);
}
-STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_scanentry_get_raw_data_obj, scanentry_get_raw_data);
+STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_scanentry_get_advertisement_bytes_obj, scanentry_get_advertisement_bytes);
-const mp_obj_property_t bleio_scanentry_raw_data_obj = {
+const mp_obj_property_t bleio_scanentry_advertisement_bytes_obj = {
.base.type = &mp_type_property,
- .proxy = { (mp_obj_t)&bleio_scanentry_get_raw_data_obj,
+ .proxy = { (mp_obj_t)&bleio_scanentry_get_advertisement_bytes_obj,
(mp_obj_t)&mp_const_none_obj,
(mp_obj_t)&mp_const_none_obj },
};
+//| .. attribute:: rssi
+//|
+//| 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) {
bleio_scanentry_obj_t *self = MP_OBJ_TO_PTR(self_in);
-
- return mp_obj_new_int(self->rssi);
+ return mp_obj_new_int(common_hal_bleio_scanentry_get_rssi(self));
}
-STATIC MP_DEFINE_CONST_FUN_OBJ_1(bluepy_scanentry_get_rssi_obj, scanentry_get_rssi);
+STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_scanentry_get_rssi_obj, scanentry_get_rssi);
const mp_obj_property_t bleio_scanentry_rssi_obj = {
.base.type = &mp_type_property,
- .proxy = { (mp_obj_t)&bluepy_scanentry_get_rssi_obj,
+ .proxy = { (mp_obj_t)&bleio_scanentry_get_rssi_obj,
(mp_obj_t)&mp_const_none_obj,
(mp_obj_t)&mp_const_none_obj },
};
-STATIC mp_obj_t scanentry_get_service_uuids(mp_obj_t self_in) {
- bleio_scanentry_obj_t *self = MP_OBJ_TO_PTR(self_in);
- mp_obj_array_t *data = MP_OBJ_TO_PTR(self->data);
- uint8_t *uuids;
-
- // Try for Complete but settle for Incomplete
- uint8_t uuids_len = find_data_item(data, AdCompleteListOf16BitServiceClassUUIDs, &uuids);
- if (uuids_len == 0) {
- uuids_len = find_data_item(data, AdIncompleteListOf16BitServiceClassUUIDs, &uuids);
- }
-
- mp_obj_t entries = mp_obj_new_list(0, NULL);
- for (size_t i = 0; i < uuids_len / sizeof(uint16_t); ++i) {
- const mp_obj_t uuid_int = mp_obj_new_int(uuids[sizeof(uint16_t) * i] | (uuids[sizeof(uint16_t) * i + 1] << 8));
- const mp_obj_t uuid_obj = bleio_uuid_type.make_new(&bleio_uuid_type, 1, &uuid_int, NULL);
-
- mp_obj_list_append(entries, uuid_obj);
- }
-
- // TODO: 32-bit UUIDs
- // TODO: 128-bit UUIDs
-
- return entries;
-}
-STATIC MP_DEFINE_CONST_FUN_OBJ_1(scanentry_get_service_uuids_obj, scanentry_get_service_uuids);
-
-const mp_obj_property_t bleio_scanentry_service_uuids_obj = {
- .base.type = &mp_type_property,
- .proxy = { (mp_obj_t)&scanentry_get_service_uuids_obj,
- (mp_obj_t)&mp_const_none_obj,
- (mp_obj_t)&mp_const_none_obj },
-};
-
-STATIC mp_obj_t scanentry_get_tx_power_level(mp_obj_t self_in) {
- bleio_scanentry_obj_t *self = MP_OBJ_TO_PTR(self_in);
- mp_obj_array_t *data = MP_OBJ_TO_PTR(self->data);
- uint8_t *tx_power;
-
- const uint8_t tx_power_len = find_data_item(data, AdTxPowerLevel, &tx_power);
- if (tx_power_len == 0) {
- return mp_const_none;
- }
-
- return mp_obj_new_int((int8_t)(*tx_power));
-}
-STATIC MP_DEFINE_CONST_FUN_OBJ_1(scanentry_get_tx_power_level_obj, scanentry_get_tx_power_level);
-
-const mp_obj_property_t bleio_scanentry_tx_power_level_obj = {
- .base.type = &mp_type_property,
- .proxy = { (mp_obj_t)&scanentry_get_tx_power_level_obj,
- (mp_obj_t)&mp_const_none_obj,
- (mp_obj_t)&mp_const_none_obj },
-};
STATIC const mp_rom_map_elem_t bleio_scanentry_locals_dict_table[] = {
- { MP_ROM_QSTR(MP_QSTR_address), MP_ROM_PTR(&bleio_scanentry_address_obj) },
- { MP_ROM_QSTR(MP_QSTR_manufacturer_specific_data), MP_ROM_PTR(&bleio_scanentry_manufacturer_specific_data_obj) },
- { MP_ROM_QSTR(MP_QSTR_name), MP_ROM_PTR(&bleio_scanentry_name_obj) },
- { MP_ROM_QSTR(MP_QSTR_raw_data), MP_ROM_PTR(&bleio_scanentry_raw_data_obj) },
- { MP_ROM_QSTR(MP_QSTR_rssi), MP_ROM_PTR(&bleio_scanentry_rssi_obj) },
- { MP_ROM_QSTR(MP_QSTR_service_uuids), MP_ROM_PTR(&bleio_scanentry_service_uuids_obj) },
- { MP_ROM_QSTR(MP_QSTR_tx_power_level), MP_ROM_PTR(&bleio_scanentry_tx_power_level_obj) },
+ { MP_ROM_QSTR(MP_QSTR_address), MP_ROM_PTR(&bleio_scanentry_address_obj) },
+ { MP_ROM_QSTR(MP_QSTR_advertisement_bytes), MP_ROM_PTR(&bleio_scanentry_advertisement_bytes_obj) },
+ { MP_ROM_QSTR(MP_QSTR_rssi), MP_ROM_PTR(&bleio_scanentry_rssi_obj) },
};
STATIC MP_DEFINE_CONST_DICT(bleio_scanentry_locals_dict, bleio_scanentry_locals_dict_table);
@@ -306,6 +107,5 @@ STATIC MP_DEFINE_CONST_DICT(bleio_scanentry_locals_dict, bleio_scanentry_locals_
const mp_obj_type_t bleio_scanentry_type = {
{ &mp_type_type },
.name = MP_QSTR_ScanEntry,
- .print = bleio_scanentry_print,
.locals_dict = (mp_obj_dict_t*)&bleio_scanentry_locals_dict
};
diff --git a/shared-bindings/bleio/ScanEntry.h b/shared-bindings/bleio/ScanEntry.h
index 2b44ba3f4..77e93175f 100644
--- a/shared-bindings/bleio/ScanEntry.h
+++ b/shared-bindings/bleio/ScanEntry.h
@@ -3,6 +3,7 @@
*
* The MIT License (MIT)
*
+ * Copyright (c) 2019 Dan Halbert for Adafruit Industries
* Copyright (c) 2018 Artur Pacholec
* Copyright (c) 2017 Glenn Ruben Bakke
*
@@ -29,7 +30,12 @@
#define MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_SCANENTRY_H
#include "py/obj.h"
+#include "shared-module/bleio/ScanEntry.h"
extern const mp_obj_type_t bleio_scanentry_type;
+mp_obj_t common_hal_bleio_scanentry_get_address(bleio_scanentry_obj_t *self);
+mp_obj_t common_hal_bleio_scanentry_get_advertisement_bytes(bleio_scanentry_obj_t *self);
+mp_int_t common_hal_bleio_scanentry_get_rssi(bleio_scanentry_obj_t *self);
+
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_SCANENTRY_H
diff --git a/shared-bindings/bleio/Scanner.c b/shared-bindings/bleio/Scanner.c
index f5424f706..269c42591 100644
--- a/shared-bindings/bleio/Scanner.c
+++ b/shared-bindings/bleio/Scanner.c
@@ -3,6 +3,7 @@
*
* The MIT License (MIT)
*
+ * Copyright (c) 2019 Dan Halbert for Adafruit Industries
* Copyright (c) 2018 Artur Pacholec
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -29,132 +30,93 @@
#include "shared-bindings/bleio/ScanEntry.h"
#include "shared-bindings/bleio/Scanner.h"
-#define DEFAULT_INTERVAL 100
-#define DEFAULT_WINDOW 100
+#define INTERVAL_DEFAULT (0.1f)
+#define INTERVAL_MIN (0.0025f)
+#define INTERVAL_MIN_STRING "0.0025"
+#define INTERVAL_MAX (40.959375f)
+#define INTERVAL_MAX_STRING "40.959375"
+#define WINDOW_DEFAULT (0.1f)
-// Work-in-progress: orphaned for now.
-//| :orphan:
-//|
//| .. currentmodule:: bleio
//|
//| :class:`Scanner` -- scan for nearby BLE devices
//| =========================================================
//|
-//| Allows scanning for nearby BLE devices.
+//| Scan for nearby BLE devices.
//|
//| Usage::
//|
//| import bleio
//| scanner = bleio.Scanner()
-//| entries = scanner.scan(2500)
-//| print(entries)
+//| entries = scanner.scan(2.5) # Scan for 2.5 seconds
//|
//| .. class:: Scanner()
//|
//| Create a new Scanner object.
//|
-
-//| .. attribute:: interval
-//|
-//| The interval (in ms) between the start of two consecutive scan windows.
-//| Allowed values are between 10ms and 10.24 sec.
-//|
-
-//| .. attribute:: window
-//|
-//| The duration (in ms) in which a single BLE channel is scanned.
-//| Allowed values are between 10ms and 10.24 sec.
-//|
-
-//| .. method:: scan(timeout)
-//|
-//| Performs a BLE scan.
-//|
-//| :param int timeout: the scan timeout in ms
-//| :returns: advertising packets found
-//| :rtype: list of :py:class:`bleio.ScanEntry`
-//|
-STATIC void bleio_scanner_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
- bleio_scanner_obj_t *self = MP_OBJ_TO_PTR(self_in);
-
- mp_printf(print, "Scanner(interval: %d window: %d)", self->interval, self->window);
-}
-
STATIC mp_obj_t bleio_scanner_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *all_args, mp_map_t *kw_args) {
mp_arg_check_num(n_args, kw_args, 0, 0, false);
bleio_scanner_obj_t *self = m_new_obj(bleio_scanner_obj_t);
self->base.type = type;
- self->interval = DEFAULT_INTERVAL;
- self->window = DEFAULT_WINDOW;
+ common_hal_bleio_scanner_construct(self);
return MP_OBJ_FROM_PTR(self);
}
-STATIC mp_obj_t bleio_scanner_get_interval(mp_obj_t self_in) {
- bleio_scanner_obj_t *self = MP_OBJ_TO_PTR(self_in);
-
- return mp_obj_new_int(self->interval);
-}
-MP_DEFINE_CONST_FUN_OBJ_1(bleio_scanner_get_interval_obj, bleio_scanner_get_interval);
-
-static mp_obj_t bleio_scanner_set_interval(mp_obj_t self_in, mp_obj_t value) {
- bleio_scanner_obj_t *self = MP_OBJ_TO_PTR(self_in);
-
- self->interval = mp_obj_get_int(value);
-
- return mp_const_none;
-}
-STATIC MP_DEFINE_CONST_FUN_OBJ_2(bleio_scanner_set_interval_obj, bleio_scanner_set_interval);
-
-const mp_obj_property_t bleio_scanner_interval_obj = {
- .base.type = &mp_type_property,
- .proxy = { (mp_obj_t)&bleio_scanner_get_interval_obj,
- (mp_obj_t)&bleio_scanner_set_interval_obj,
- (mp_obj_t)&mp_const_none_obj },
-};
-
-STATIC mp_obj_t scanner_scan(mp_obj_t self_in, mp_obj_t timeout_in) {
- bleio_scanner_obj_t *self = MP_OBJ_TO_PTR(self_in);
- const mp_int_t timeout = mp_obj_get_int(timeout_in);
-
- self->adv_reports = mp_obj_new_list(0, NULL);
-
- common_hal_bleio_scanner_scan(self, timeout);
-
- return self->adv_reports;
-}
-STATIC MP_DEFINE_CONST_FUN_OBJ_2(bleio_scanner_scan_obj, scanner_scan);
-
-STATIC mp_obj_t bleio_scanner_get_window(mp_obj_t self_in) {
- bleio_scanner_obj_t *self = MP_OBJ_TO_PTR(self_in);
-
- return mp_obj_new_int(self->window);
-}
-MP_DEFINE_CONST_FUN_OBJ_1(bleio_scanner_get_window_obj, bleio_scanner_get_window);
-
-static mp_obj_t bleio_scanner_set_window(mp_obj_t self_in, mp_obj_t value) {
- bleio_scanner_obj_t *self = MP_OBJ_TO_PTR(self_in);
-
- self->window = mp_obj_get_int(value);
-
- return mp_const_none;
+//| .. method:: scan(timeout, \*, interval=0.1, window=0.1)
+//|
+//| Performs a BLE scan.
+//|
+//| :param float timeout: the scan timeout in seconds
+//| :param float interval: the interval (in seconds) between the start of two consecutive scan windows
+//| Must be in the range 0.0025 - 40.959375 seconds.
+//| :param float window: the duration (in seconds) to scan a single BLE channel.
+//| window must be <= interval.
+//| :returns: an iterable of `ScanEntry` objects
+//| :rtype: iterable
+//|
+STATIC mp_obj_t bleio_scanner_scan(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
+ enum { ARG_timeout, ARG_interval, ARG_window };
+ static const mp_arg_t allowed_args[] = {
+ { MP_QSTR_timeout, MP_ARG_REQUIRED | MP_ARG_OBJ },
+ { MP_QSTR_interval, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
+ { MP_QSTR_window, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
+ };
+
+ bleio_scanner_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]);
+ mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
+ mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
+
+ const mp_float_t timeout = mp_obj_get_float(args[ARG_timeout].u_obj);
+
+ if (args[ARG_interval].u_obj == MP_OBJ_NULL) {
+ args[ARG_interval].u_obj = mp_obj_new_float(INTERVAL_DEFAULT);
+ }
+
+ if (args[ARG_window].u_obj == MP_OBJ_NULL) {
+ args[ARG_window].u_obj = mp_obj_new_float(WINDOW_DEFAULT);
+ }
+
+ const mp_float_t interval = mp_obj_float_get(args[ARG_interval].u_obj);
+ if (interval < INTERVAL_MIN || interval > INTERVAL_MAX) {
+ mp_raise_ValueError_varg(translate("interval must be in range %s-%s"), INTERVAL_MIN_STRING, INTERVAL_MAX_STRING);
+ }
+
+ const mp_float_t window = mp_obj_float_get(args[ARG_window].u_obj);
+ if (window > interval) {
+ mp_raise_ValueError(translate("window must be <= interval"));
+ }
+
+ return common_hal_bleio_scanner_scan(self, timeout, interval, window);
}
-STATIC MP_DEFINE_CONST_FUN_OBJ_2(bleio_scanner_set_window_obj, bleio_scanner_set_window);
+STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_scanner_scan_obj, 2, bleio_scanner_scan);
-const mp_obj_property_t bleio_scanner_window_obj = {
- .base.type = &mp_type_property,
- .proxy = { (mp_obj_t)&bleio_scanner_get_window_obj,
- (mp_obj_t)&bleio_scanner_set_window_obj,
- (mp_obj_t)&mp_const_none_obj },
-};
STATIC const mp_rom_map_elem_t bleio_scanner_locals_dict_table[] = {
- { MP_ROM_QSTR(MP_QSTR_interval), MP_ROM_PTR(&bleio_scanner_interval_obj) },
{ MP_ROM_QSTR(MP_QSTR_scan), MP_ROM_PTR(&bleio_scanner_scan_obj) },
- { MP_ROM_QSTR(MP_QSTR_window), MP_ROM_PTR(&bleio_scanner_window_obj) },
};
STATIC MP_DEFINE_CONST_DICT(bleio_scanner_locals_dict, bleio_scanner_locals_dict_table);
@@ -162,7 +124,6 @@ STATIC MP_DEFINE_CONST_DICT(bleio_scanner_locals_dict, bleio_scanner_locals_dict
const mp_obj_type_t bleio_scanner_type = {
{ &mp_type_type },
.name = MP_QSTR_Scanner,
- .print = bleio_scanner_print,
.make_new = bleio_scanner_make_new,
.locals_dict = (mp_obj_dict_t*)&bleio_scanner_locals_dict
};
diff --git a/shared-bindings/bleio/Scanner.h b/shared-bindings/bleio/Scanner.h
index 9bd071747..3a0ce7eae 100644
--- a/shared-bindings/bleio/Scanner.h
+++ b/shared-bindings/bleio/Scanner.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2017 Glenn Ruben Bakke
+ * Copyright (c) 2019 Dan Halbert for Adafruit Industries
* Copyright (c) 2018 Artur Pacholec
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -29,11 +29,12 @@
#define MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_SCANNER_H
#include "py/objtype.h"
-#include "shared-module/bleio/Scanner.h"
+#include "common-hal/bleio/Scanner.h"
extern const mp_obj_type_t bleio_scanner_type;
-extern void common_hal_bleio_scanner_scan(bleio_scanner_obj_t *self, mp_int_t timeout);
+extern void common_hal_bleio_scanner_construct(bleio_scanner_obj_t *self);
+extern mp_obj_t common_hal_bleio_scanner_scan(bleio_scanner_obj_t *self, mp_float_t timeout, mp_float_t interval, mp_float_t window);
extern void common_hal_bleio_scanner_stop(bleio_scanner_obj_t *self);
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_SCANNER_H
diff --git a/shared-bindings/bleio/Service.c b/shared-bindings/bleio/Service.c
index c3be26260..db0606991 100644
--- a/shared-bindings/bleio/Service.c
+++ b/shared-bindings/bleio/Service.c
@@ -3,8 +3,9 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2017 Glenn Ruben Bakke
+ * Copyright (c) 2019 Dan Halbert for Adafruit Industries
* Copyright (c) 2018 Artur Pacholec
+ * 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
@@ -60,53 +61,53 @@ STATIC mp_obj_t bleio_service_make_new(const mp_obj_type_t *type, size_t n_args,
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
- const mp_obj_t uuid = args[ARG_uuid].u_obj;
+ const mp_obj_t uuid_obj = args[ARG_uuid].u_obj;
- if (!MP_OBJ_IS_TYPE(uuid, &bleio_uuid_type)) {
+ if (!MP_OBJ_IS_TYPE(uuid_obj, &bleio_uuid_type)) {
mp_raise_ValueError(translate("Expected a UUID"));
}
bleio_service_obj_t *self = m_new_obj(bleio_service_obj_t);
- self->char_list = mp_obj_new_list(0, NULL);
self->base.type = &bleio_service_type;
- self->device = mp_const_none;
- self->handle = 0xFFFF;
- self->is_secondary = args[ARG_secondary].u_bool;
- self->uuid = MP_OBJ_TO_PTR(uuid);
+
+ const bool is_secondary = args[ARG_secondary].u_bool;
+ bleio_uuid_obj_t *uuid = MP_OBJ_TO_PTR(uuid_obj);
// If characteristics is not an iterable, an exception will be thrown.
mp_obj_iter_buf_t iter_buf;
mp_obj_t iterable = mp_getiter(args[ARG_characteristics].u_obj, &iter_buf);
- mp_obj_t characteristic;
+ mp_obj_t characteristic_obj;
- while ((characteristic = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) {
- if (!MP_OBJ_IS_TYPE(characteristic, &bleio_characteristic_type)) {
+ // Copy the characteristics list and validate its items.
+ mp_obj_t char_list_obj = mp_obj_new_list(0, NULL);
+ mp_obj_list_t *char_list = MP_OBJ_TO_PTR(char_list_obj);
+
+ while ((characteristic_obj = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) {
+ if (!MP_OBJ_IS_TYPE(characteristic_obj, &bleio_characteristic_type)) {
mp_raise_ValueError(translate("characteristics includes an object that is not a Characteristic"));
}
- bleio_characteristic_obj_t *characteristic_ptr = MP_OBJ_TO_PTR(characteristic);
+ bleio_characteristic_obj_t *characteristic = MP_OBJ_TO_PTR(characteristic_obj);
if (common_hal_bleio_uuid_get_uuid128_reference(uuid) !=
- common_hal_bleio_uuid_get_uuid128_reference(characteristic_ptr->uuid)) {
+ common_hal_bleio_uuid_get_uuid128_reference(characteristic->uuid)) {
// The descriptor base UUID doesn't match the characteristic base UUID.
mp_raise_ValueError(translate("Characteristic UUID doesn't match Service UUID"));
}
- characteristic_ptr->service = self;
- mp_obj_list_append(self->char_list, characteristic);
+ mp_obj_list_append(char_list_obj, characteristic_obj);
}
- // Do port-specific initialization.
- common_hal_bleio_service_construct(self);
+ common_hal_bleio_service_construct(self, uuid, char_list, is_secondary);
return MP_OBJ_FROM_PTR(self);
}
//| .. attribute:: characteristics
//|
-//| A `list` of `bleio.Characteristic` that are offered by this service. (read-only)
+//| A tuple of `bleio.Characteristic` that are offered by this service. (read-only)
//|
STATIC mp_obj_t bleio_service_get_characteristics(mp_obj_t self_in) {
bleio_service_obj_t *self = MP_OBJ_TO_PTR(self_in);
// Return list as a tuple so user won't be able to change it.
- mp_obj_list_t *char_list = MP_OBJ_TO_PTR(self->char_list);
+ mp_obj_list_t *char_list = common_hal_bleio_service_get_characteristic_list(self);
return mp_obj_new_tuple(char_list->len, char_list->items);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_service_get_characteristics_obj, bleio_service_get_characteristics);
@@ -118,14 +119,34 @@ const mp_obj_property_t bleio_service_characteristics_obj = {
(mp_obj_t)&mp_const_none_obj },
};
+//| .. attribute:: secondary
+//|
+//| True if this is a secondary service. (read-only)
+//|
+STATIC mp_obj_t bleio_service_get_secondary(mp_obj_t self_in) {
+ bleio_service_obj_t *self = MP_OBJ_TO_PTR(self_in);
+
+ return mp_obj_new_bool(common_hal_bleio_service_get_is_secondary(self));
+}
+STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_service_get_secondary_obj, bleio_service_get_secondary);
+
+const mp_obj_property_t bleio_service_secondary_obj = {
+ .base.type = &mp_type_property,
+ .proxy = { (mp_obj_t)&bleio_service_get_secondary_obj,
+ (mp_obj_t)&mp_const_none_obj,
+ (mp_obj_t)&mp_const_none_obj },
+};
+
//| .. attribute:: uuid
//|
//| The UUID of this service. (read-only)
+//| Will be ``None`` if the 128-bit UUID for this service is not known.
//|
STATIC mp_obj_t bleio_service_get_uuid(mp_obj_t self_in) {
bleio_service_obj_t *self = MP_OBJ_TO_PTR(self_in);
- return MP_OBJ_FROM_PTR(self->uuid);
+ bleio_uuid_obj_t *uuid = common_hal_bleio_service_get_uuid(self);
+ return uuid ? MP_OBJ_FROM_PTR(uuid) : mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(bleio_service_get_uuid_obj, bleio_service_get_uuid);
@@ -138,14 +159,26 @@ const mp_obj_property_t bleio_service_uuid_obj = {
STATIC const mp_rom_map_elem_t bleio_service_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_characteristics), MP_ROM_PTR(&bleio_service_characteristics_obj) },
+ { MP_ROM_QSTR(MP_QSTR_secondary), MP_ROM_PTR(&bleio_service_secondary_obj) },
{ MP_ROM_QSTR(MP_QSTR_uuid), MP_ROM_PTR(&bleio_service_uuid_obj) },
};
-
STATIC MP_DEFINE_CONST_DICT(bleio_service_locals_dict, bleio_service_locals_dict_table);
+STATIC void bleio_service_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
+ bleio_service_obj_t *self = MP_OBJ_TO_PTR(self_in);
+ if (self->uuid) {
+ mp_printf(print, "Service(");
+ bleio_uuid_print(print, MP_OBJ_FROM_PTR(self->uuid), kind);
+ mp_printf(print, ")");
+ } else {
+ mp_printf(print, "<Service with unregistered UUID>");
+ }
+}
+
const mp_obj_type_t bleio_service_type = {
{ &mp_type_type },
.name = MP_QSTR_Service,
.make_new = bleio_service_make_new,
+ .print = bleio_service_print,
.locals_dict = (mp_obj_dict_t*)&bleio_service_locals_dict
};
diff --git a/shared-bindings/bleio/Service.h b/shared-bindings/bleio/Service.h
index 389db3b2e..f646c81a9 100644
--- a/shared-bindings/bleio/Service.h
+++ b/shared-bindings/bleio/Service.h
@@ -3,6 +3,7 @@
*
* The MIT License (MIT)
*
+ * Copyright (c) 2019 Dan Halbert for Adafruit Industries
* Copyright (c) 2018 Artur Pacholec
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -27,12 +28,14 @@
#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_SERVICE_H
#define MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_SERVICE_H
-#include "shared-module/bleio/Characteristic.h"
-#include "shared-module/bleio/Service.h"
+#include "common-hal/bleio/Service.h"
const mp_obj_type_t bleio_service_type;
-extern void common_hal_bleio_service_construct(bleio_service_obj_t *self);
+extern void common_hal_bleio_service_construct(bleio_service_obj_t *self, bleio_uuid_obj_t *uuid, mp_obj_list_t *characteristic_list, bool is_secondary);
+extern bleio_uuid_obj_t *common_hal_bleio_service_get_uuid(bleio_service_obj_t *self);
+extern mp_obj_list_t *common_hal_bleio_service_get_characteristic_list(bleio_service_obj_t *self);
+extern bool common_hal_bleio_service_get_is_secondary(bleio_service_obj_t *self);
extern void common_hal_bleio_service_add_all_characteristics(bleio_service_obj_t *self);
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_SERVICE_H
diff --git a/shared-bindings/bleio/UUID.c b/shared-bindings/bleio/UUID.c
index fa2472b48..dca7ea010 100644
--- a/shared-bindings/bleio/UUID.c
+++ b/shared-bindings/bleio/UUID.c
@@ -3,9 +3,9 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2017 Glenn Ruben Bakke
+ * Copyright (c) 2019 Dan Halbert for Adafruit Industries
* Copyright (c) 2018 Artur Pacholec
- * Copyright (c) 2018 Dan Halbert for Adafruit Industries
+ * 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
@@ -48,6 +48,10 @@
//|
//| - an `int` value in range 0 to 0xFFFF (Bluetooth SIG 16-bit UUID)
//| - a buffer object (bytearray, bytes) of 16 bytes in little-endian order (128-bit UUID)
+//| - a string of hex digits of the form 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
+//|
+//| Creating a 128-bit UUID registers the UUID with the onboard BLE software, and provides a
+//| temporary 16-bit UUID that can be used in place of the full 128-bit UUID.
//|
//| :param value: The uuid value to encapsulate
//| :type value: int or typing.ByteString
@@ -64,7 +68,7 @@ STATIC mp_obj_t bleio_uuid_make_new(const mp_obj_type_t *type, size_t n_args, co
if (MP_OBJ_IS_INT(value)) {
mp_int_t uuid16 = mp_obj_get_int(value);
if (uuid16 < 0 || uuid16 > 0xffff) {
- mp_raise_ValueError(translate("UUID integer value not in range 0 to 0xffff"));
+ mp_raise_ValueError(translate("UUID integer value must be 0-0xffff"));
}
// NULL means no 128-bit value.
@@ -219,6 +223,12 @@ STATIC mp_obj_t bleio_uuid_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
}
}
+//|
+
+//| .. method:: __eq__(other)
+//|
+//| Two UUID objects are equal if their values match and they are both 128-bit or both 16-bit.
+//|
STATIC mp_obj_t bleio_uuid_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
switch (op) {
// Two UUID's are equal if their uuid16 values and uuid128 references match.
diff --git a/shared-bindings/bleio/UUID.h b/shared-bindings/bleio/UUID.h
index aef2c1e29..caf039aec 100644
--- a/shared-bindings/bleio/UUID.h
+++ b/shared-bindings/bleio/UUID.h
@@ -3,6 +3,7 @@
*
* The MIT License (MIT)
*
+ * Copyright (c) 2019 Dan Halbert for Adafruit Industries
* Copyright (c) 2018 Artur Pacholec
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
diff --git a/shared-bindings/bleio/__init__.c b/shared-bindings/bleio/__init__.c
index 7348655ac..ba3bae6c7 100644
--- a/shared-bindings/bleio/__init__.c
+++ b/shared-bindings/bleio/__init__.c
@@ -3,8 +3,9 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2016 Glenn Ruben Bakke
+ * Copyright (c) 2019 Dan Halbert for Adafruit Industries
* Copyright (c) 2018 Artur Pacholec
+ * Copyright (c) 2016 Glenn Ruben Bakke
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -27,12 +28,10 @@
#include "shared-bindings/bleio/__init__.h"
#include "shared-bindings/bleio/Address.h"
-#include "shared-bindings/bleio/AddressType.h"
-#include "shared-bindings/bleio/AdvertisementData.h"
-#include "shared-bindings/bleio/Broadcaster.h"
+#include "shared-bindings/bleio/Central.h"
#include "shared-bindings/bleio/Characteristic.h"
#include "shared-bindings/bleio/CharacteristicBuffer.h"
-#include "shared-bindings/bleio/Descriptor.h"
+// #include "shared-bindings/bleio/Descriptor.h"
#include "shared-bindings/bleio/Peripheral.h"
#include "shared-bindings/bleio/ScanEntry.h"
#include "shared-bindings/bleio/Scanner.h"
@@ -54,18 +53,14 @@
//| :maxdepth: 3
//|
//| Address
-//| AddressType
-//| AdvertisementData
//| Adapter
-//| Broadcaster
+//| Central
//| Characteristic
//| CharacteristicBuffer
-// Work-in-progress classes are omitted, and marked as :orphan: in their files.
-// Descriptor
-// Device
+//| Descriptor
//| Peripheral
-// ScanEntry
-// Scanner
+//| ScanEntry
+//| Scanner
//| Service
//| UUID
//|
@@ -79,23 +74,18 @@
STATIC const mp_rom_map_elem_t bleio_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_bleio) },
{ MP_ROM_QSTR(MP_QSTR_Address), MP_ROM_PTR(&bleio_address_type) },
- { MP_ROM_QSTR(MP_QSTR_AdvertisementData), MP_ROM_PTR(&bleio_advertisementdata_type) },
- { MP_ROM_QSTR(MP_QSTR_Broadcaster), MP_ROM_PTR(&bleio_broadcaster_type) },
+ { MP_ROM_QSTR(MP_QSTR_Central), MP_ROM_PTR(&bleio_central_type) },
{ MP_ROM_QSTR(MP_QSTR_Characteristic), MP_ROM_PTR(&bleio_characteristic_type) },
{ MP_ROM_QSTR(MP_QSTR_CharacteristicBuffer), MP_ROM_PTR(&bleio_characteristic_buffer_type) },
// { MP_ROM_QSTR(MP_QSTR_Descriptor), MP_ROM_PTR(&bleio_descriptor_type) },
{ MP_ROM_QSTR(MP_QSTR_Peripheral), MP_ROM_PTR(&bleio_peripheral_type) },
-// Hide work-in-progress.
-// { MP_ROM_QSTR(MP_QSTR_ScanEntry), MP_ROM_PTR(&bleio_scanentry_type) },
-// { MP_ROM_QSTR(MP_QSTR_Scanner), MP_ROM_PTR(&bleio_scanner_type) },
+ { MP_ROM_QSTR(MP_QSTR_ScanEntry), MP_ROM_PTR(&bleio_scanentry_type) },
+ { MP_ROM_QSTR(MP_QSTR_Scanner), MP_ROM_PTR(&bleio_scanner_type) },
{ MP_ROM_QSTR(MP_QSTR_Service), MP_ROM_PTR(&bleio_service_type) },
{ MP_ROM_QSTR(MP_QSTR_UUID), MP_ROM_PTR(&bleio_uuid_type) },
// Properties
{ MP_ROM_QSTR(MP_QSTR_adapter), MP_ROM_PTR(&common_hal_bleio_adapter_obj) },
-
- // Enum-like Classes.
- { MP_ROM_QSTR(MP_QSTR_AddressType), MP_ROM_PTR(&bleio_addresstype_type) },
};
STATIC MP_DEFINE_CONST_DICT(bleio_module_globals, bleio_module_globals_table);
diff --git a/shared-bindings/bleio/__init__.h b/shared-bindings/bleio/__init__.h
index 1f4e0a66f..4aa6dd45b 100644
--- a/shared-bindings/bleio/__init__.h
+++ b/shared-bindings/bleio/__init__.h
@@ -3,8 +3,9 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2016 Glenn Ruben Bakke
+ * Copyright (c) 2019 Dan Halbert for Adafruit Industries
* Copyright (c) 2018 Artur Pacholec
+ * Copyright (c) 2016 Glenn Ruben Bakke
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/shared-bindings/busio/I2C.h b/shared-bindings/busio/I2C.h
index 739732e97..a2d5dbf50 100644
--- a/shared-bindings/busio/I2C.h
+++ b/shared-bindings/busio/I2C.h
@@ -69,4 +69,7 @@ extern uint8_t common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t addres
extern uint8_t common_hal_busio_i2c_read(busio_i2c_obj_t *self, uint16_t address,
uint8_t * data, size_t len);
+// This is used by the supervisor to claim I2C devices indefinitely.
+extern void common_hal_busio_i2c_never_reset(busio_i2c_obj_t *self);
+
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_BUSIO_I2C_H
diff --git a/shared-bindings/busio/UART.h b/shared-bindings/busio/UART.h
index e171f8bb4..776a996be 100644
--- a/shared-bindings/busio/UART.h
+++ b/shared-bindings/busio/UART.h
@@ -42,7 +42,7 @@ typedef enum {
extern void common_hal_busio_uart_construct(busio_uart_obj_t *self,
const mcu_pin_obj_t * tx, const mcu_pin_obj_t * rx, uint32_t baudrate,
uint8_t bits, uart_parity_t parity, uint8_t stop, mp_float_t timeout,
- uint8_t receiver_buffer_size);
+ uint16_t receiver_buffer_size);
extern void common_hal_busio_uart_deinit(busio_uart_obj_t *self);
extern bool common_hal_busio_uart_deinited(busio_uart_obj_t *self);
diff --git a/shared-bindings/displayio/ColorConverter.c b/shared-bindings/displayio/ColorConverter.c
index 561883810..d9524870d 100644
--- a/shared-bindings/displayio/ColorConverter.c
+++ b/shared-bindings/displayio/ColorConverter.c
@@ -62,6 +62,8 @@ STATIC mp_obj_t displayio_colorconverter_make_new(const mp_obj_type_t *type, siz
//| .. method:: convert(color)
//|
+//| Converts the given RGB888 color to RGB565
+//|
STATIC mp_obj_t displayio_colorconverter_obj_convert(mp_obj_t self_in, mp_obj_t color_obj) {
displayio_colorconverter_t *self = MP_OBJ_TO_PTR(self_in);
@@ -69,8 +71,10 @@ STATIC mp_obj_t displayio_colorconverter_obj_convert(mp_obj_t self_in, mp_obj_t
if (!mp_obj_get_int_maybe(color_obj, &color)) {
mp_raise_ValueError(translate("color should be an int"));
}
- uint16_t output_color;
- common_hal_displayio_colorconverter_convert(self, color, &output_color);
+ _displayio_colorspace_t colorspace;
+ colorspace.depth = 16;
+ uint32_t output_color;
+ common_hal_displayio_colorconverter_convert(self, &colorspace, color, &output_color);
return MP_OBJ_NEW_SMALL_INT(output_color);
}
MP_DEFINE_CONST_FUN_OBJ_2(displayio_colorconverter_convert_obj, displayio_colorconverter_obj_convert);
diff --git a/shared-bindings/displayio/ColorConverter.h b/shared-bindings/displayio/ColorConverter.h
index 71be7f543..24895500e 100644
--- a/shared-bindings/displayio/ColorConverter.h
+++ b/shared-bindings/displayio/ColorConverter.h
@@ -29,9 +29,11 @@
#include "shared-module/displayio/ColorConverter.h"
+#include "shared-module/displayio/Palette.h"
+
extern const mp_obj_type_t displayio_colorconverter_type;
void common_hal_displayio_colorconverter_construct(displayio_colorconverter_t* self);
-bool common_hal_displayio_colorconverter_convert(displayio_colorconverter_t *colorconverter, uint32_t input_color, uint16_t* output_color);
+void common_hal_displayio_colorconverter_convert(displayio_colorconverter_t *colorconverter, const _displayio_colorspace_t* colorspace, uint32_t input_color, uint32_t* output_color);
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYIO_COLORCONVERTER_H
diff --git a/shared-bindings/displayio/Display.c b/shared-bindings/displayio/Display.c
index 1a36872a6..361a37ece 100644
--- a/shared-bindings/displayio/Display.c
+++ b/shared-bindings/displayio/Display.c
@@ -51,7 +51,7 @@
//| Most people should not use this class directly. Use a specific display driver instead that will
//| contain the initialization sequence at minimum.
//|
-//| .. class:: Display(display_bus, init_sequence, *, width, height, colstart=0, rowstart=0, rotation=0, color_depth=16, set_column_command=0x2a, set_row_command=0x2b, write_ram_command=0x2c, set_vertical_scroll=0, backlight_pin=None, brightness=1.0, auto_brightness=False, single_byte_bounds=False, data_as_commands=False)
+//| .. class:: Display(display_bus, init_sequence, *, width, height, colstart=0, rowstart=0, rotation=0, color_depth=16, grayscale=False, pixels_in_byte_share_row=True, set_column_command=0x2a, set_row_command=0x2b, write_ram_command=0x2c, set_vertical_scroll=0, backlight_pin=None, brightness_command=None, brightness=1.0, auto_brightness=False, single_byte_bounds=False, data_as_commands=False)
//|
//| Create a Display object on the given display bus (`displayio.FourWire` or `displayio.ParallelBus`).
//|
@@ -88,18 +88,21 @@
//| :param int rotation: The rotation of the display in degrees clockwise. Must be in 90 degree increments (0, 90, 180, 270)
//| :param int color_depth: The number of bits of color per pixel transmitted. (Some displays
//| support 18 bit but 16 is easier to transmit. The last bit is extrapolated.)
+//| :param bool grayscale: True if the display only shows a single color.
+//| :param bool pixels_in_byte_share_row: True when pixels are less than a byte and a byte includes pixels from the same row of the display. When False, pixels share a column.
//| :param int set_column_command: Command used to set the start and end columns to update
//| :param int set_row_command: Command used so set the start and end rows to update
-//| :param int write_ram_command: Command used to write pixels values into the update region
+//| :param int write_ram_command: Command used to write pixels values into the update region. Ignored if data_as_commands is set.
//| :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 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.
//|
STATIC mp_obj_t displayio_display_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
- enum { ARG_display_bus, ARG_init_sequence, ARG_width, ARG_height, ARG_colstart, ARG_rowstart, ARG_rotation, ARG_color_depth, ARG_set_column_command, ARG_set_row_command, ARG_write_ram_command, ARG_set_vertical_scroll, ARG_backlight_pin, ARG_brightness, ARG_auto_brightness, ARG_single_byte_bounds, ARG_data_as_commands };
+ enum { ARG_display_bus, ARG_init_sequence, ARG_width, ARG_height, ARG_colstart, ARG_rowstart, ARG_rotation, ARG_color_depth, ARG_grayscale, ARG_pixels_in_byte_share_row, ARG_set_column_command, ARG_set_row_command, ARG_write_ram_command, ARG_set_vertical_scroll, ARG_backlight_pin, ARG_brightness_command, ARG_brightness, ARG_auto_brightness, ARG_single_byte_bounds, ARG_data_as_commands };
static const mp_arg_t allowed_args[] = {
{ MP_QSTR_display_bus, MP_ARG_REQUIRED | MP_ARG_OBJ },
{ MP_QSTR_init_sequence, MP_ARG_REQUIRED | MP_ARG_OBJ },
@@ -109,11 +112,14 @@ STATIC mp_obj_t displayio_display_make_new(const mp_obj_type_t *type, size_t n_a
{ MP_QSTR_rowstart, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 0} },
{ MP_QSTR_rotation, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 0} },
{ MP_QSTR_color_depth, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 16} },
+ { MP_QSTR_grayscale, MP_ARG_BOOL | MP_ARG_KW_ONLY, {.u_bool = false} },
+ { MP_QSTR_pixels_in_byte_share_row, MP_ARG_BOOL | MP_ARG_KW_ONLY, {.u_bool = true} },
{ MP_QSTR_set_column_command, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 0x2a} },
{ MP_QSTR_set_row_command, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 0x2b} },
{ MP_QSTR_write_ram_command, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 0x2c} },
{ MP_QSTR_set_vertical_scroll, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 0x0} },
{ MP_QSTR_backlight_pin, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = mp_const_none} },
+ { MP_QSTR_brightness_command, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = NO_BRIGHTNESS_COMMAND} },
{ MP_QSTR_brightness, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = MP_OBJ_NEW_SMALL_INT(1)} },
{ MP_QSTR_auto_brightness, MP_ARG_BOOL | MP_ARG_KW_ONLY, {.u_bool = false} },
{ MP_QSTR_single_byte_bounds, MP_ARG_BOOL | MP_ARG_KW_ONLY, {.u_bool = false} },
@@ -157,11 +163,13 @@ STATIC mp_obj_t displayio_display_make_new(const mp_obj_type_t *type, size_t n_a
common_hal_displayio_display_construct(
self,
display_bus, args[ARG_width].u_int, args[ARG_height].u_int, args[ARG_colstart].u_int, args[ARG_rowstart].u_int, rotation,
- args[ARG_color_depth].u_int, args[ARG_set_column_command].u_int, args[ARG_set_row_command].u_int,
+ args[ARG_color_depth].u_int, args[ARG_grayscale].u_bool, args[ARG_pixels_in_byte_share_row].u_bool,
+ args[ARG_set_column_command].u_int, args[ARG_set_row_command].u_int,
args[ARG_write_ram_command].u_int,
args[ARG_set_vertical_scroll].u_int,
bufinfo.buf, bufinfo.len,
MP_OBJ_TO_PTR(backlight_pin),
+ args[ARG_brightness_command].u_int,
brightness,
args[ARG_auto_brightness].u_bool,
args[ARG_single_byte_bounds].u_bool,
@@ -234,10 +242,14 @@ STATIC mp_obj_t displayio_display_obj_get_brightness(mp_obj_t self_in) {
}
MP_DEFINE_CONST_FUN_OBJ_1(displayio_display_get_brightness_obj, displayio_display_obj_get_brightness);
-STATIC mp_obj_t displayio_display_obj_set_brightness(mp_obj_t self_in, mp_obj_t brightness) {
+STATIC mp_obj_t displayio_display_obj_set_brightness(mp_obj_t self_in, mp_obj_t brightness_obj) {
displayio_display_obj_t *self = native_display(self_in);
common_hal_displayio_display_set_auto_brightness(self, false);
- bool ok = common_hal_displayio_display_set_brightness(self, mp_obj_get_float(brightness));
+ mp_float_t brightness = mp_obj_get_float(brightness_obj);
+ if (brightness < 0 || brightness > 1.0) {
+ mp_raise_ValueError(translate("Brightness must be 0-1.0"));
+ }
+ bool ok = common_hal_displayio_display_set_brightness(self, brightness);
if (!ok) {
mp_raise_RuntimeError(translate("Brightness not adjustable"));
}
diff --git a/shared-bindings/displayio/Display.h b/shared-bindings/displayio/Display.h
index 5a027561b..e765e6f25 100644
--- a/shared-bindings/displayio/Display.h
+++ b/shared-bindings/displayio/Display.h
@@ -36,11 +36,13 @@ extern const mp_obj_type_t displayio_display_type;
#define DELAY 0x80
+#define NO_BRIGHTNESS_COMMAND 0x100
+
void common_hal_displayio_display_construct(displayio_display_obj_t* self,
mp_obj_t bus, uint16_t width, uint16_t height,
- int16_t colstart, int16_t rowstart, uint16_t rotation, uint16_t color_depth,
+ int16_t colstart, int16_t rowstart, uint16_t rotation, uint16_t color_depth, bool grayscale, bool pixels_in_byte_share_row,
uint8_t set_column_command, uint8_t set_row_command, uint8_t write_ram_command, uint8_t set_vertical_scroll,
- uint8_t* init_sequence, uint16_t init_sequence_len, const mcu_pin_obj_t* backlight_pin,
+ uint8_t* init_sequence, uint16_t init_sequence_len, const mcu_pin_obj_t* backlight_pin, uint16_t brightness_command,
mp_float_t brightness, bool auto_brightness,
bool single_byte_bounds, bool data_as_commands);
@@ -54,7 +56,7 @@ bool displayio_display_begin_transaction(displayio_display_obj_t* self);
void displayio_display_end_transaction(displayio_display_obj_t* self);
// The second point of the region is exclusive.
-void displayio_display_set_region_to_update(displayio_display_obj_t* self, uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1);
+void displayio_display_set_region_to_update(displayio_display_obj_t* self, displayio_area_t* area);
bool displayio_display_frame_queued(displayio_display_obj_t* self);
bool displayio_display_refresh_queued(displayio_display_obj_t* self);
diff --git a/shared-bindings/displayio/Group.c b/shared-bindings/displayio/Group.c
index 76719c580..5a35424ce 100644
--- a/shared-bindings/displayio/Group.c
+++ b/shared-bindings/displayio/Group.c
@@ -295,7 +295,7 @@ STATIC mp_obj_t group_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t valu
if (value == MP_OBJ_SENTINEL) {
// load
return common_hal_displayio_group_get(self, index);
- } else if (value == mp_const_none) {
+ } else if (value == MP_OBJ_NULL) {
common_hal_displayio_group_pop(self, index);
} else {
common_hal_displayio_group_set(self, index, value);
diff --git a/shared-bindings/displayio/I2CDisplay.c b/shared-bindings/displayio/I2CDisplay.c
new file mode 100644
index 000000000..1f74e8c9e
--- /dev/null
+++ b/shared-bindings/displayio/I2CDisplay.c
@@ -0,0 +1,138 @@
+/*
+ * This file is part of the Micro Python project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019 Scott Shawcroft for Adafruit Industries
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include "shared-bindings/displayio/I2CDisplay.h"
+
+#include <stdint.h>
+#include <string.h>
+
+#include "lib/utils/context_manager_helpers.h"
+#include "py/binary.h"
+#include "py/objproperty.h"
+#include "py/runtime.h"
+#include "shared-bindings/microcontroller/Pin.h"
+#include "shared-bindings/util.h"
+#include "shared-module/displayio/__init__.h"
+#include "supervisor/shared/translate.h"
+
+//| .. currentmodule:: displayio
+//|
+//| :class:`I2CDisplay` -- Manage updating a display over I2C
+//| ==========================================================================
+//|
+//| Manage updating a display over I2C in the background while Python code runs.
+//| It doesn't handle display initialization.
+//|
+//| .. class:: I2CDisplay(i2c_bus, *, device_address, reset=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
+//| called even after a reload. (It does this so CircuitPython can use the display after your code
+//| is done.) So, the first time you initialize a display bus in code.py you should call
+//| :py:func`displayio.release_displays` first, otherwise it will error after the first code.py run.
+//|
+//| :param busio.I2C i2c_bus: The I2C bus that make up the clock and data lines
+//| :param int device_address: The I2C address of the device
+//| :param microcontroller.Pin reset: Reset pin. When None only software reset can be used
+//|
+STATIC mp_obj_t displayio_i2cdisplay_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
+ enum { ARG_i2c_bus, ARG_device_address, ARG_reset };
+ static const mp_arg_t allowed_args[] = {
+ { MP_QSTR_i2c_bus, MP_ARG_REQUIRED | MP_ARG_OBJ },
+ { MP_QSTR_device_address, MP_ARG_INT | MP_ARG_KW_ONLY | MP_ARG_REQUIRED },
+ { MP_QSTR_reset, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = mp_const_none} },
+ };
+ mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
+ mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
+
+ mp_obj_t reset = args[ARG_reset].u_obj;
+ if (reset != mp_const_none) {
+ assert_pin_free(reset);
+ } else {
+ reset = NULL;
+ }
+
+ displayio_i2cdisplay_obj_t* self = NULL;
+ mp_obj_t i2c = args[ARG_i2c_bus].u_obj;
+ for (uint8_t i = 0; i < CIRCUITPY_DISPLAY_LIMIT; i++) {
+ if (displays[i].i2cdisplay_bus.base.type == NULL ||
+ displays[i].i2cdisplay_bus.base.type == &mp_type_NoneType) {
+ self = &displays[i].i2cdisplay_bus;
+ self->base.type = &displayio_i2cdisplay_type;
+ break;
+ }
+ }
+ if (self == NULL) {
+ mp_raise_RuntimeError(translate("Too many display busses"));
+ }
+
+ common_hal_displayio_i2cdisplay_construct(self,
+ MP_OBJ_TO_PTR(i2c), args[ARG_device_address].u_int, reset);
+ return self;
+}
+
+//| .. method:: send(command, data)
+//|
+//| 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.
+//|
+STATIC mp_obj_t displayio_i2cdisplay_obj_send(mp_obj_t self, mp_obj_t command_obj, mp_obj_t data_obj) {
+ mp_int_t command_int = MP_OBJ_SMALL_INT_VALUE(command_obj);
+ if (!MP_OBJ_IS_SMALL_INT(command_obj) || command_int > 255 || command_int < 0) {
+ mp_raise_ValueError(translate("Command must be 0-255"));
+ }
+ uint8_t command = command_int;
+ mp_buffer_info_t bufinfo;
+ mp_get_buffer_raise(data_obj, &bufinfo, MP_BUFFER_READ);
+
+ // Wait for display bus to be available.
+ while (!common_hal_displayio_i2cdisplay_begin_transaction(self)) {
+#ifdef MICROPY_VM_HOOK_LOOP
+ MICROPY_VM_HOOK_LOOP ;
+#endif
+ }
+ uint8_t full_command[bufinfo.len + 1];
+ full_command[0] = command;
+ memcpy(full_command + 1, ((uint8_t*) bufinfo.buf), bufinfo.len);
+ common_hal_displayio_i2cdisplay_send(self, true, full_command, bufinfo.len + 1);
+ common_hal_displayio_i2cdisplay_end_transaction(self);
+
+ return mp_const_none;
+}
+MP_DEFINE_CONST_FUN_OBJ_3(displayio_i2cdisplay_send_obj, displayio_i2cdisplay_obj_send);
+
+STATIC const mp_rom_map_elem_t displayio_i2cdisplay_locals_dict_table[] = {
+ { MP_ROM_QSTR(MP_QSTR_send), MP_ROM_PTR(&displayio_i2cdisplay_send_obj) },
+};
+STATIC MP_DEFINE_CONST_DICT(displayio_i2cdisplay_locals_dict, displayio_i2cdisplay_locals_dict_table);
+
+const mp_obj_type_t displayio_i2cdisplay_type = {
+ { &mp_type_type },
+ .name = MP_QSTR_I2CDisplay,
+ .make_new = displayio_i2cdisplay_make_new,
+ .locals_dict = (mp_obj_dict_t*)&displayio_i2cdisplay_locals_dict,
+};
diff --git a/shared-bindings/bleio/AddressType.h b/shared-bindings/displayio/I2CDisplay.h
index e69caffab..cc4162800 100644
--- a/shared-bindings/bleio/AddressType.h
+++ b/shared-bindings/displayio/I2CDisplay.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2018 Artur Pacholec
+ * Copyright (c) 2017, 2018 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
@@ -24,27 +24,23 @@
* THE SOFTWARE.
*/
-#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_ADDRESSTYPE_H
-#define MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_ADDRESSTYPE_H
+#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYBUSIO_I2CDISPLAY_H
+#define MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYBUSIO_I2CDISPLAY_H
-#include "py/obj.h"
+#include "shared-module/displayio/I2CDisplay.h"
+#include "common-hal/microcontroller/Pin.h"
-typedef enum {
- ADDRESS_PUBLIC,
- ADDRESS_RANDOM_STATIC,
- ADDRESS_RANDOM_PRIVATE_RESOLVABLE,
- ADDRESS_RANDOM_PRIVATE_NON_RESOLVABLE
-} bleio_address_type_t;
+extern const mp_obj_type_t displayio_i2cdisplay_type;
-extern const mp_obj_type_t bleio_addresstype_type;
+void common_hal_displayio_i2cdisplay_construct(displayio_i2cdisplay_obj_t* self,
+ busio_i2c_obj_t* i2c, uint16_t device_address, const mcu_pin_obj_t* reset);
-typedef struct {
- mp_obj_base_t base;
-} bleio_addresstype_obj_t;
+void common_hal_displayio_i2cdisplay_deinit(displayio_i2cdisplay_obj_t* self);
-extern const bleio_addresstype_obj_t bleio_addresstype_public_obj;
-extern const bleio_addresstype_obj_t bleio_addresstype_random_static_obj;
-extern const bleio_addresstype_obj_t bleio_addresstype_random_private_resolvable_obj;
-extern const bleio_addresstype_obj_t bleio_addresstype_random_private_non_resolvable_obj;
+bool common_hal_displayio_i2cdisplay_begin_transaction(mp_obj_t self);
-#endif // MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_ADDRESSTYPE_H
+void common_hal_displayio_i2cdisplay_send(mp_obj_t self, bool command, uint8_t *data, uint32_t data_length);
+
+void common_hal_displayio_i2cdisplay_end_transaction(mp_obj_t self);
+
+#endif // MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYBUSIO_I2CDISPLAY_H
diff --git a/shared-bindings/displayio/Palette.c b/shared-bindings/displayio/Palette.c
index 11c2f677c..dda58e3c5 100644
--- a/shared-bindings/displayio/Palette.c
+++ b/shared-bindings/displayio/Palette.c
@@ -66,11 +66,26 @@ STATIC mp_obj_t displayio_palette_make_new(const mp_obj_type_t *type, size_t n_a
return MP_OBJ_FROM_PTR(self);
}
+
+//| .. method:: __len__()
+//|
+//| Returns the number of colors in a Palette
+//|
+STATIC mp_obj_t group_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
+ displayio_palette_t *self = MP_OBJ_TO_PTR(self_in);
+ switch (op) {
+ case MP_UNARY_OP_BOOL: return mp_const_true;
+ case MP_UNARY_OP_LEN:
+ return MP_OBJ_NEW_SMALL_INT(common_hal_displayio_palette_get_len(self));
+ default: return MP_OBJ_NULL; // op not supported
+ }
+}
+
//| .. method:: __setitem__(index, value)
//|
//| 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).
+//| The value argument represents a color, and can be from 0x000000 to 0xFFFFFF (to represent an RGB value).
//| Value can be an int, bytes (3 bytes (RGB) or 4 bytes (RGB + pad byte)), or bytearray.
//|
//| This allows you to::
@@ -89,12 +104,12 @@ STATIC mp_obj_t palette_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t val
if (MP_OBJ_IS_TYPE(index_in, &mp_type_slice)) {
return MP_OBJ_NULL;
}
- // index read is not supported
- if (value == MP_OBJ_SENTINEL) {
- return MP_OBJ_NULL;
- }
displayio_palette_t *self = MP_OBJ_TO_PTR(self_in);
size_t index = mp_get_index(&displayio_palette_type, self->color_count, index_in, false);
+ // index read
+ if (value == MP_OBJ_SENTINEL) {
+ return MP_OBJ_NEW_SMALL_INT(common_hal_displayio_palette_get_color(self, index));
+ }
uint32_t color;
mp_int_t int_value;
@@ -160,5 +175,7 @@ const mp_obj_type_t displayio_palette_type = {
.name = MP_QSTR_Palette,
.make_new = displayio_palette_make_new,
.subscr = palette_subscr,
+ .unary_op = group_unary_op,
+ .getiter = mp_obj_new_generic_iterator,
.locals_dict = (mp_obj_dict_t*)&displayio_palette_locals_dict,
};
diff --git a/shared-bindings/displayio/Palette.h b/shared-bindings/displayio/Palette.h
index 767fc7b63..8c9fe11e3 100644
--- a/shared-bindings/displayio/Palette.h
+++ b/shared-bindings/displayio/Palette.h
@@ -33,6 +33,8 @@ extern const mp_obj_type_t displayio_palette_type;
void common_hal_displayio_palette_construct(displayio_palette_t* self, uint16_t color_count);
void common_hal_displayio_palette_set_color(displayio_palette_t* self, uint32_t palette_index, uint32_t color);
+uint32_t common_hal_displayio_palette_get_color(displayio_palette_t* self, uint32_t palette_index);
+uint32_t common_hal_displayio_palette_get_len(displayio_palette_t* self);
void common_hal_displayio_palette_make_opaque(displayio_palette_t* self, uint32_t palette_index);
void common_hal_displayio_palette_make_transparent(displayio_palette_t* self, uint32_t palette_index);
diff --git a/shared-bindings/displayio/__init__.c b/shared-bindings/displayio/__init__.c
index 9dc17103b..fd3dc4233 100644
--- a/shared-bindings/displayio/__init__.c
+++ b/shared-bindings/displayio/__init__.c
@@ -35,6 +35,7 @@
#include "shared-bindings/displayio/Display.h"
#include "shared-bindings/displayio/FourWire.h"
#include "shared-bindings/displayio/Group.h"
+#include "shared-bindings/displayio/I2CDisplay.h"
#include "shared-bindings/displayio/OnDiskBitmap.h"
#include "shared-bindings/displayio/Palette.h"
#include "shared-bindings/displayio/ParallelBus.h"
@@ -61,6 +62,7 @@
//| Display
//| FourWire
//| Group
+//| I2CDisplay
//| OnDiskBitmap
//| Palette
//| ParallelBus
@@ -96,6 +98,7 @@ STATIC const mp_rom_map_elem_t displayio_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR_TileGrid), MP_ROM_PTR(&displayio_tilegrid_type) },
{ MP_ROM_QSTR(MP_QSTR_FourWire), MP_ROM_PTR(&displayio_fourwire_type) },
+ { MP_ROM_QSTR(MP_QSTR_I2CDisplay), MP_ROM_PTR(&displayio_i2cdisplay_type) },
{ MP_ROM_QSTR(MP_QSTR_ParallelBus), MP_ROM_PTR(&displayio_parallelbus_type) },
{ MP_ROM_QSTR(MP_QSTR_release_displays), MP_ROM_PTR(&displayio_release_displays_obj) },
diff --git a/shared-module/audioio/Mixer.c b/shared-module/audiocore/Mixer.c
index 8020a621e..da66bb36e 100644
--- a/shared-module/audioio/Mixer.c
+++ b/shared-module/audiocore/Mixer.c
@@ -24,13 +24,13 @@
* THE SOFTWARE.
*/
-#include "shared-bindings/audioio/Mixer.h"
+#include "shared-bindings/audiocore/Mixer.h"
#include <stdint.h>
#include "py/runtime.h"
-#include "shared-module/audioio/__init__.h"
-#include "shared-module/audioio/RawSample.h"
+#include "shared-module/audiocore/__init__.h"
+#include "shared-module/audiocore/RawSample.h"
void common_hal_audioio_mixer_construct(audioio_mixer_obj_t* self,
uint8_t voice_count,
diff --git a/shared-module/audioio/Mixer.h b/shared-module/audiocore/Mixer.h
index 6a88fe0bd..22eb6a37f 100644
--- a/shared-module/audioio/Mixer.h
+++ b/shared-module/audiocore/Mixer.h
@@ -29,7 +29,7 @@
#include "py/obj.h"
-#include "shared-module/audioio/__init__.h"
+#include "shared-module/audiocore/__init__.h"
typedef struct {
mp_obj_t sample;
diff --git a/shared-module/audioio/RawSample.c b/shared-module/audiocore/RawSample.c
index 6422e346b..d6bf3a567 100644
--- a/shared-module/audioio/RawSample.c
+++ b/shared-module/audiocore/RawSample.c
@@ -24,11 +24,11 @@
* THE SOFTWARE.
*/
-#include "shared-bindings/audioio/RawSample.h"
+#include "shared-bindings/audiocore/RawSample.h"
#include <stdint.h>
-#include "shared-module/audioio/RawSample.h"
+#include "shared-module/audiocore/RawSample.h"
void common_hal_audioio_rawsample_construct(audioio_rawsample_obj_t* self,
uint8_t* buffer,
diff --git a/shared-module/audioio/RawSample.h b/shared-module/audiocore/RawSample.h
index fe5283db4..6c2c19c9b 100644
--- a/shared-module/audioio/RawSample.h
+++ b/shared-module/audiocore/RawSample.h
@@ -29,7 +29,7 @@
#include "py/obj.h"
-#include "shared-module/audioio/__init__.h"
+#include "shared-module/audiocore/__init__.h"
typedef struct {
mp_obj_base_t base;
diff --git a/shared-module/audioio/WaveFile.c b/shared-module/audiocore/WaveFile.c
index d5dd9419c..810d9c33b 100644
--- a/shared-module/audioio/WaveFile.c
+++ b/shared-module/audiocore/WaveFile.c
@@ -24,7 +24,7 @@
* THE SOFTWARE.
*/
-#include "shared-bindings/audioio/WaveFile.h"
+#include "shared-bindings/audiocore/WaveFile.h"
#include <stdint.h>
#include <string.h>
@@ -32,7 +32,7 @@
#include "py/mperrno.h"
#include "py/runtime.h"
-#include "shared-module/audioio/WaveFile.h"
+#include "shared-module/audiocore/WaveFile.h"
#include "supervisor/shared/translate.h"
struct wave_format_chunk {
diff --git a/shared-module/audioio/WaveFile.h b/shared-module/audiocore/WaveFile.h
index 2cee2b1d2..97dd6a46f 100644
--- a/shared-module/audioio/WaveFile.h
+++ b/shared-module/audiocore/WaveFile.h
@@ -29,7 +29,7 @@
#include "py/obj.h"
-#include "shared-module/audioio/__init__.h"
+#include "shared-module/audiocore/__init__.h"
typedef struct {
mp_obj_base_t base;
diff --git a/shared-module/audiocore/__init__.c b/shared-module/audiocore/__init__.c
new file mode 100644
index 000000000..067cae5dd
--- /dev/null
+++ b/shared-module/audiocore/__init__.c
@@ -0,0 +1,125 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2018 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-module/audioio/__init__.h"
+
+#include "py/obj.h"
+#include "shared-bindings/audiocore/Mixer.h"
+#include "shared-bindings/audiocore/RawSample.h"
+#include "shared-bindings/audiocore/WaveFile.h"
+#include "shared-module/audiocore/Mixer.h"
+#include "shared-module/audiocore/RawSample.h"
+#include "shared-module/audiocore/WaveFile.h"
+
+uint32_t audiosample_sample_rate(mp_obj_t sample_obj) {
+ if (MP_OBJ_IS_TYPE(sample_obj, &audioio_rawsample_type)) {
+ audioio_rawsample_obj_t* sample = MP_OBJ_TO_PTR(sample_obj);
+ return sample->sample_rate;
+ } else if (MP_OBJ_IS_TYPE(sample_obj, &audioio_wavefile_type)) {
+ audioio_wavefile_obj_t* file = MP_OBJ_TO_PTR(sample_obj);
+ return file->sample_rate;
+ } else if (MP_OBJ_IS_TYPE(sample_obj, &audioio_mixer_type)) {
+ audioio_mixer_obj_t* mixer = MP_OBJ_TO_PTR(sample_obj);
+ return mixer->sample_rate;
+ }
+ return 16000;
+}
+
+uint8_t audiosample_bits_per_sample(mp_obj_t sample_obj) {
+ if (MP_OBJ_IS_TYPE(sample_obj, &audioio_rawsample_type)) {
+ audioio_rawsample_obj_t* sample = MP_OBJ_TO_PTR(sample_obj);
+ return sample->bits_per_sample;
+ } else if (MP_OBJ_IS_TYPE(sample_obj, &audioio_wavefile_type)) {
+ audioio_wavefile_obj_t* file = MP_OBJ_TO_PTR(sample_obj);
+ return file->bits_per_sample;
+ } else if (MP_OBJ_IS_TYPE(sample_obj, &audioio_mixer_type)) {
+ audioio_mixer_obj_t* mixer = MP_OBJ_TO_PTR(sample_obj);
+ return mixer->bits_per_sample;
+ }
+ return 8;
+}
+
+uint8_t audiosample_channel_count(mp_obj_t sample_obj) {
+ if (MP_OBJ_IS_TYPE(sample_obj, &audioio_rawsample_type)) {
+ audioio_rawsample_obj_t* sample = MP_OBJ_TO_PTR(sample_obj);
+ return sample->channel_count;
+ } else if (MP_OBJ_IS_TYPE(sample_obj, &audioio_wavefile_type)) {
+ audioio_wavefile_obj_t* file = MP_OBJ_TO_PTR(sample_obj);
+ return file->channel_count;
+ } else if (MP_OBJ_IS_TYPE(sample_obj, &audioio_mixer_type)) {
+ audioio_mixer_obj_t* mixer = MP_OBJ_TO_PTR(sample_obj);
+ return mixer->channel_count;
+ }
+ return 1;
+}
+
+void audiosample_reset_buffer(mp_obj_t sample_obj, bool single_channel, uint8_t audio_channel) {
+ if (MP_OBJ_IS_TYPE(sample_obj, &audioio_rawsample_type)) {
+ audioio_rawsample_obj_t* sample = MP_OBJ_TO_PTR(sample_obj);
+ audioio_rawsample_reset_buffer(sample, single_channel, audio_channel);
+ } else if (MP_OBJ_IS_TYPE(sample_obj, &audioio_wavefile_type)) {
+ audioio_wavefile_obj_t* file = MP_OBJ_TO_PTR(sample_obj);
+ audioio_wavefile_reset_buffer(file, single_channel, audio_channel);
+ } else if (MP_OBJ_IS_TYPE(sample_obj, &audioio_mixer_type)) {
+ audioio_mixer_obj_t* file = MP_OBJ_TO_PTR(sample_obj);
+ audioio_mixer_reset_buffer(file, single_channel, audio_channel);
+ }
+}
+
+audioio_get_buffer_result_t audiosample_get_buffer(mp_obj_t sample_obj,
+ bool single_channel,
+ uint8_t channel,
+ uint8_t** buffer, uint32_t* buffer_length) {
+ if (MP_OBJ_IS_TYPE(sample_obj, &audioio_rawsample_type)) {
+ audioio_rawsample_obj_t* sample = MP_OBJ_TO_PTR(sample_obj);
+ return audioio_rawsample_get_buffer(sample, single_channel, channel, buffer, buffer_length);
+ } else if (MP_OBJ_IS_TYPE(sample_obj, &audioio_wavefile_type)) {
+ audioio_wavefile_obj_t* file = MP_OBJ_TO_PTR(sample_obj);
+ return audioio_wavefile_get_buffer(file, single_channel, channel, buffer, buffer_length);
+ } else if (MP_OBJ_IS_TYPE(sample_obj, &audioio_mixer_type)) {
+ audioio_mixer_obj_t* file = MP_OBJ_TO_PTR(sample_obj);
+ return audioio_mixer_get_buffer(file, single_channel, channel, buffer, buffer_length);
+ }
+ return GET_BUFFER_DONE;
+}
+
+void audiosample_get_buffer_structure(mp_obj_t sample_obj, bool single_channel,
+ bool* single_buffer, bool* samples_signed,
+ uint32_t* max_buffer_length, uint8_t* spacing) {
+ if (MP_OBJ_IS_TYPE(sample_obj, &audioio_rawsample_type)) {
+ audioio_rawsample_obj_t* sample = MP_OBJ_TO_PTR(sample_obj);
+ audioio_rawsample_get_buffer_structure(sample, single_channel, single_buffer,
+ samples_signed, max_buffer_length, spacing);
+ } else if (MP_OBJ_IS_TYPE(sample_obj, &audioio_wavefile_type)) {
+ audioio_wavefile_obj_t* file = MP_OBJ_TO_PTR(sample_obj);
+ audioio_wavefile_get_buffer_structure(file, single_channel, single_buffer, samples_signed,
+ max_buffer_length, spacing);
+ } else if (MP_OBJ_IS_TYPE(sample_obj, &audioio_mixer_type)) {
+ audioio_mixer_obj_t* file = MP_OBJ_TO_PTR(sample_obj);
+ audioio_mixer_get_buffer_structure(file, single_channel, single_buffer, samples_signed,
+ max_buffer_length, spacing);
+ }
+}
diff --git a/shared-module/audiocore/__init__.h b/shared-module/audiocore/__init__.h
new file mode 100644
index 000000000..7aa0c1824
--- /dev/null
+++ b/shared-module/audiocore/__init__.h
@@ -0,0 +1,53 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2018 Dan Halbert for Adafruit Industries
+ *
+ * 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_AUDIOCORE__INIT__H
+#define MICROPY_INCLUDED_SHARED_MODULE_AUDIOCORE__INIT__H
+
+#include <stdbool.h>
+#include <stdint.h>
+
+#include "py/obj.h"
+
+typedef enum {
+ GET_BUFFER_DONE, // No more data to read
+ GET_BUFFER_MORE_DATA, // More data to read.
+ GET_BUFFER_ERROR, // Error while reading data.
+} audioio_get_buffer_result_t;
+
+uint32_t audiosample_sample_rate(mp_obj_t sample_obj);
+uint8_t audiosample_bits_per_sample(mp_obj_t sample_obj);
+uint8_t audiosample_channel_count(mp_obj_t sample_obj);
+void audiosample_reset_buffer(mp_obj_t sample_obj, bool single_channel, uint8_t audio_channel);
+audioio_get_buffer_result_t audiosample_get_buffer(mp_obj_t sample_obj,
+ bool single_channel,
+ uint8_t channel,
+ uint8_t** buffer, uint32_t* buffer_length);
+void audiosample_get_buffer_structure(mp_obj_t sample_obj, bool single_channel,
+ bool* single_buffer, bool* samples_signed,
+ uint32_t* max_buffer_length, uint8_t* spacing);
+
+#endif // MICROPY_INCLUDED_SHARED_MODULE_AUDIOCORE__INIT__H
diff --git a/shared-module/audioio/__init__.c b/shared-module/audioio/__init__.c
index b87b06a83..e69de29bb 100644
--- a/shared-module/audioio/__init__.c
+++ b/shared-module/audioio/__init__.c
@@ -1,125 +0,0 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2018 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-module/audioio/__init__.h"
-
-#include "py/obj.h"
-#include "shared-bindings/audioio/Mixer.h"
-#include "shared-bindings/audioio/RawSample.h"
-#include "shared-bindings/audioio/WaveFile.h"
-#include "shared-module/audioio/Mixer.h"
-#include "shared-module/audioio/RawSample.h"
-#include "shared-module/audioio/WaveFile.h"
-
-uint32_t audiosample_sample_rate(mp_obj_t sample_obj) {
- if (MP_OBJ_IS_TYPE(sample_obj, &audioio_rawsample_type)) {
- audioio_rawsample_obj_t* sample = MP_OBJ_TO_PTR(sample_obj);
- return sample->sample_rate;
- } else if (MP_OBJ_IS_TYPE(sample_obj, &audioio_wavefile_type)) {
- audioio_wavefile_obj_t* file = MP_OBJ_TO_PTR(sample_obj);
- return file->sample_rate;
- } else if (MP_OBJ_IS_TYPE(sample_obj, &audioio_mixer_type)) {
- audioio_mixer_obj_t* mixer = MP_OBJ_TO_PTR(sample_obj);
- return mixer->sample_rate;
- }
- return 16000;
-}
-
-uint8_t audiosample_bits_per_sample(mp_obj_t sample_obj) {
- if (MP_OBJ_IS_TYPE(sample_obj, &audioio_rawsample_type)) {
- audioio_rawsample_obj_t* sample = MP_OBJ_TO_PTR(sample_obj);
- return sample->bits_per_sample;
- } else if (MP_OBJ_IS_TYPE(sample_obj, &audioio_wavefile_type)) {
- audioio_wavefile_obj_t* file = MP_OBJ_TO_PTR(sample_obj);
- return file->bits_per_sample;
- } else if (MP_OBJ_IS_TYPE(sample_obj, &audioio_mixer_type)) {
- audioio_mixer_obj_t* mixer = MP_OBJ_TO_PTR(sample_obj);
- return mixer->bits_per_sample;
- }
- return 8;
-}
-
-uint8_t audiosample_channel_count(mp_obj_t sample_obj) {
- if (MP_OBJ_IS_TYPE(sample_obj, &audioio_rawsample_type)) {
- audioio_rawsample_obj_t* sample = MP_OBJ_TO_PTR(sample_obj);
- return sample->channel_count;
- } else if (MP_OBJ_IS_TYPE(sample_obj, &audioio_wavefile_type)) {
- audioio_wavefile_obj_t* file = MP_OBJ_TO_PTR(sample_obj);
- return file->channel_count;
- } else if (MP_OBJ_IS_TYPE(sample_obj, &audioio_mixer_type)) {
- audioio_mixer_obj_t* mixer = MP_OBJ_TO_PTR(sample_obj);
- return mixer->channel_count;
- }
- return 1;
-}
-
-void audiosample_reset_buffer(mp_obj_t sample_obj, bool single_channel, uint8_t audio_channel) {
- if (MP_OBJ_IS_TYPE(sample_obj, &audioio_rawsample_type)) {
- audioio_rawsample_obj_t* sample = MP_OBJ_TO_PTR(sample_obj);
- audioio_rawsample_reset_buffer(sample, single_channel, audio_channel);
- } else if (MP_OBJ_IS_TYPE(sample_obj, &audioio_wavefile_type)) {
- audioio_wavefile_obj_t* file = MP_OBJ_TO_PTR(sample_obj);
- audioio_wavefile_reset_buffer(file, single_channel, audio_channel);
- } else if (MP_OBJ_IS_TYPE(sample_obj, &audioio_mixer_type)) {
- audioio_mixer_obj_t* file = MP_OBJ_TO_PTR(sample_obj);
- audioio_mixer_reset_buffer(file, single_channel, audio_channel);
- }
-}
-
-audioio_get_buffer_result_t audiosample_get_buffer(mp_obj_t sample_obj,
- bool single_channel,
- uint8_t channel,
- uint8_t** buffer, uint32_t* buffer_length) {
- if (MP_OBJ_IS_TYPE(sample_obj, &audioio_rawsample_type)) {
- audioio_rawsample_obj_t* sample = MP_OBJ_TO_PTR(sample_obj);
- return audioio_rawsample_get_buffer(sample, single_channel, channel, buffer, buffer_length);
- } else if (MP_OBJ_IS_TYPE(sample_obj, &audioio_wavefile_type)) {
- audioio_wavefile_obj_t* file = MP_OBJ_TO_PTR(sample_obj);
- return audioio_wavefile_get_buffer(file, single_channel, channel, buffer, buffer_length);
- } else if (MP_OBJ_IS_TYPE(sample_obj, &audioio_mixer_type)) {
- audioio_mixer_obj_t* file = MP_OBJ_TO_PTR(sample_obj);
- return audioio_mixer_get_buffer(file, single_channel, channel, buffer, buffer_length);
- }
- return GET_BUFFER_DONE;
-}
-
-void audiosample_get_buffer_structure(mp_obj_t sample_obj, bool single_channel,
- bool* single_buffer, bool* samples_signed,
- uint32_t* max_buffer_length, uint8_t* spacing) {
- if (MP_OBJ_IS_TYPE(sample_obj, &audioio_rawsample_type)) {
- audioio_rawsample_obj_t* sample = MP_OBJ_TO_PTR(sample_obj);
- audioio_rawsample_get_buffer_structure(sample, single_channel, single_buffer,
- samples_signed, max_buffer_length, spacing);
- } else if (MP_OBJ_IS_TYPE(sample_obj, &audioio_wavefile_type)) {
- audioio_wavefile_obj_t* file = MP_OBJ_TO_PTR(sample_obj);
- audioio_wavefile_get_buffer_structure(file, single_channel, single_buffer, samples_signed,
- max_buffer_length, spacing);
- } else if (MP_OBJ_IS_TYPE(sample_obj, &audioio_mixer_type)) {
- audioio_mixer_obj_t* file = MP_OBJ_TO_PTR(sample_obj);
- audioio_mixer_get_buffer_structure(file, single_channel, single_buffer, samples_signed,
- max_buffer_length, spacing);
- }
-}
diff --git a/shared-module/audioio/__init__.h b/shared-module/audioio/__init__.h
index c805f3116..53b2d4a16 100644
--- a/shared-module/audioio/__init__.h
+++ b/shared-module/audioio/__init__.h
@@ -27,27 +27,6 @@
#ifndef MICROPY_INCLUDED_SHARED_MODULE_AUDIOIO__INIT__H
#define MICROPY_INCLUDED_SHARED_MODULE_AUDIOIO__INIT__H
-#include <stdbool.h>
-#include <stdint.h>
-
-#include "py/obj.h"
-
-typedef enum {
- GET_BUFFER_DONE, // No more data to read
- GET_BUFFER_MORE_DATA, // More data to read.
- GET_BUFFER_ERROR, // Error while reading data.
-} audioio_get_buffer_result_t;
-
-uint32_t audiosample_sample_rate(mp_obj_t sample_obj);
-uint8_t audiosample_bits_per_sample(mp_obj_t sample_obj);
-uint8_t audiosample_channel_count(mp_obj_t sample_obj);
-void audiosample_reset_buffer(mp_obj_t sample_obj, bool single_channel, uint8_t audio_channel);
-audioio_get_buffer_result_t audiosample_get_buffer(mp_obj_t sample_obj,
- bool single_channel,
- uint8_t channel,
- uint8_t** buffer, uint32_t* buffer_length);
-void audiosample_get_buffer_structure(mp_obj_t sample_obj, bool single_channel,
- bool* single_buffer, bool* samples_signed,
- uint32_t* max_buffer_length, uint8_t* spacing);
+#include "shared-module/audiocore/__init__.h"
#endif // MICROPY_INCLUDED_SHARED_MODULE_AUDIOIO__INIT__H
diff --git a/shared-module/bleio/Address.c b/shared-module/bleio/Address.c
new file mode 100644
index 000000000..6bc458b7c
--- /dev/null
+++ b/shared-module/bleio/Address.c
@@ -0,0 +1,45 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019 Dan Halbert for Adafruit Industries
+ * Copyright (c) 2018 Artur Pacholec
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include <string.h>
+
+#include "py/objstr.h"
+#include "shared-bindings/bleio/Address.h"
+#include "shared-module/bleio/Address.h"
+
+void common_hal_bleio_address_construct(bleio_address_obj_t *self, uint8_t *bytes, uint8_t address_type) {
+ self->bytes = mp_obj_new_bytes(bytes, NUM_BLEIO_ADDRESS_BYTES);
+ self->type = address_type;
+}
+
+mp_obj_t common_hal_bleio_address_get_address_bytes(bleio_address_obj_t *self) {
+ return self->bytes;
+}
+
+uint8_t common_hal_bleio_address_get_type(bleio_address_obj_t *self) {
+ return self->type;
+}
diff --git a/shared-module/bleio/Address.h b/shared-module/bleio/Address.h
index f0998c163..39789842f 100644
--- a/shared-module/bleio/Address.h
+++ b/shared-module/bleio/Address.h
@@ -3,6 +3,7 @@
*
* The MIT License (MIT)
*
+ * Copyright (c) 2019 Dan Halbert for Adafruit Industries
* Copyright (c) 2018 Artur Pacholec
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -27,14 +28,14 @@
#ifndef MICROPY_INCLUDED_SHARED_MODULE_BLEIO_ADDRESS_H
#define MICROPY_INCLUDED_SHARED_MODULE_BLEIO_ADDRESS_H
-#include "shared-bindings/bleio/AddressType.h"
+#include "py/obj.h"
-#define BLEIO_ADDRESS_BYTES 6
+#define NUM_BLEIO_ADDRESS_BYTES 6
typedef struct {
mp_obj_base_t base;
- bleio_address_type_t type;
- uint8_t value[BLEIO_ADDRESS_BYTES];
+ uint8_t type;
+ mp_obj_t bytes; // a bytes() object
} bleio_address_obj_t;
#endif // MICROPY_INCLUDED_SHARED_MODULE_BLEIO_ADDRESS_H
diff --git a/shared-module/bleio/AdvertisementData.h b/shared-module/bleio/AdvertisementData.h
deleted file mode 100644
index 738d53b23..000000000
--- a/shared-module/bleio/AdvertisementData.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2018 Artur Pacholec
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-#ifndef MICROPY_INCLUDED_SHARED_MODULE_BLEIO_ADVERTISEMENTDATA_H
-#define MICROPY_INCLUDED_SHARED_MODULE_BLEIO_ADVERTISEMENTDATA_H
-
-#include "py/obj.h"
-
-// Taken from https://www.bluetooth.com/specifications/assigned-numbers/generic-access-profile
-enum {
- AdFlags = 0x01,
- AdIncompleteListOf16BitServiceClassUUIDs = 0x02,
- AdCompleteListOf16BitServiceClassUUIDs = 0x03,
- AdIncompleteListOf32BitServiceClassUUIDs = 0x04,
- AdCompleteListOf32BitServiceClassUUIDs = 0x05,
- AdIncompleteListOf128BitServiceClassUUIDs = 0x06,
- AdCompleteListOf128BitServiceClassUUIDs = 0x07,
- AdShortenedLocalName = 0x08,
- AdCompleteLocalName = 0x09,
- AdTxPowerLevel = 0x0A,
- AdClassOfDevice = 0x0D,
- AdSimplePairingHashC = 0x0E,
- AdSimplePairingRandomizerR = 0x0F,
- AdSecurityManagerTKValue = 0x10,
- AdSecurityManagerOOBFlags = 0x11,
- AdSlaveConnectionIntervalRange = 0x12,
- AdListOf16BitServiceSolicitationUUIDs = 0x14,
- AdListOf128BitServiceSolicitationUUIDs = 0x15,
- AdServiceData = 0x16,
- AdPublicTargetAddress = 0x17,
- AdRandomTargetAddress = 0x18,
- AdAppearance = 0x19,
- AdAdvertisingInterval = 0x1A,
- AdLEBluetoothDeviceAddress = 0x1B,
- AdLERole = 0x1C,
- AdSimplePairingHashC256 = 0x1D,
- AdSimplePairingRandomizerR256 = 0x1E,
- AdListOf32BitServiceSolicitationUUIDs = 0x1F,
- AdServiceData32BitUUID = 0x20,
- AdServiceData128BitUUID = 0x21,
- AdLESecureConnectionsConfirmationValue = 0x22,
- AdLESecureConnectionsRandomValue = 0x23,
- AdURI = 0x24,
- AdIndoorPositioning = 0x25,
- AdTransportDiscoveryData = 0x26,
- AdLESupportedFeatures = 0x27,
- AdChannelMapUpdateIndication = 0x28,
- AdPBADV = 0x29,
- AdMeshMessage = 0x2A,
- AdMeshBeacon = 0x2B,
- Ad3DInformationData = 0x3D,
- AdManufacturerSpecificData = 0xFF,
-};
-
-typedef struct {
- mp_obj_t device_name;
- mp_obj_t services;
- mp_obj_t data;
- bool connectable;
-} bleio_advertisement_data_t;
-
-#endif // MICROPY_INCLUDED_SHARED_MODULE_BLEIO_ADVERTISEMENTDATA_H
diff --git a/shared-module/bleio/Characteristic.h b/shared-module/bleio/Characteristic.h
index 958837e64..27b43588f 100644
--- a/shared-module/bleio/Characteristic.h
+++ b/shared-module/bleio/Characteristic.h
@@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2018 Artur Pacholec
+ * 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
@@ -37,5 +37,4 @@ typedef struct {
bool indicate : 1;
} bleio_characteristic_properties_t;
-
#endif // MICROPY_INCLUDED_SHARED_MODULE_BLEIO_CHARACTERISTIC_H
diff --git a/shared-bindings/bleio/Broadcaster.h b/shared-module/bleio/ScanEntry.c
index 8aa125af9..306ac33c5 100644
--- a/shared-bindings/bleio/Broadcaster.h
+++ b/shared-module/bleio/ScanEntry.c
@@ -3,7 +3,9 @@
*
* The MIT License (MIT)
*
+ * Copyright (c) 2019 Dan Halbert for Adafruit Industries
* Copyright (c) 2018 Artur Pacholec
+ * 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
@@ -24,15 +26,20 @@
* THE SOFTWARE.
*/
-#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_BROADCASTER_H
-#define MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_BROADCASTER_H
+#include <string.h>
-#include "common-hal/bleio/Broadcaster.h"
+#include "shared-bindings/bleio/Address.h"
+#include "shared-module/bleio/Address.h"
+#include "shared-module/bleio/ScanEntry.h"
-extern const mp_obj_type_t bleio_broadcaster_type;
+mp_obj_t common_hal_bleio_scanentry_get_address(bleio_scanentry_obj_t *self) {
+ return MP_OBJ_FROM_PTR(self->address);
+}
-extern void common_hal_bleio_broadcaster_construct(bleio_broadcaster_obj_t *self, mp_float_t interval);
-extern void common_hal_bleio_broadcaster_start_advertising(bleio_broadcaster_obj_t *self, mp_buffer_info_t *data);
-extern void common_hal_bleio_broadcaster_stop_advertising(bleio_broadcaster_obj_t *self);
+mp_obj_t common_hal_bleio_scanentry_get_advertisement_bytes(bleio_scanentry_obj_t *self) {
+ return self->data;
+}
-#endif // MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_BROADCASTER_H
+mp_int_t common_hal_bleio_scanentry_get_rssi(bleio_scanentry_obj_t *self) {
+ return self->rssi;
+}
diff --git a/shared-module/bleio/ScanEntry.h b/shared-module/bleio/ScanEntry.h
index 2f01669e2..b302460e6 100644
--- a/shared-module/bleio/ScanEntry.h
+++ b/shared-module/bleio/ScanEntry.h
@@ -3,6 +3,7 @@
*
* The MIT License (MIT)
*
+ * Copyright (c) 2019 Dan Halbert for Adafruit Industries
* Copyright (c) 2018 Artur Pacholec
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -27,13 +28,14 @@
#ifndef MICROPY_INCLUDED_SHARED_MODULE_BLEIO_SCANENTRY_H
#define MICROPY_INCLUDED_SHARED_MODULE_BLEIO_SCANENTRY_H
-#include "shared-module/bleio/Address.h"
+#include "py/obj.h"
+#include "shared-bindings/bleio/Address.h"
typedef struct {
mp_obj_base_t base;
- bleio_address_obj_t address;
bool connectable;
int8_t rssi;
+ bleio_address_obj_t *address;
mp_obj_t data;
} bleio_scanentry_obj_t;
diff --git a/shared-module/board/__init__.c b/shared-module/board/__init__.c
index be8502bc0..5a1dead78 100644
--- a/shared-module/board/__init__.c
+++ b/shared-module/board/__init__.c
@@ -24,16 +24,18 @@
* THE SOFTWARE.
*/
-#include "shared-bindings/busio/I2C.h"
-#include "shared-bindings/busio/SPI.h"
-#include "shared-bindings/busio/UART.h"
-
#include "shared-bindings/microcontroller/Pin.h"
#include "supervisor/shared/translate.h"
#include "mpconfigboard.h"
#include "py/runtime.h"
-#ifdef CIRCUITPY_DISPLAYIO
+#if CIRCUITPY_BUSIO
+#include "shared-bindings/busio/I2C.h"
+#include "shared-bindings/busio/SPI.h"
+#include "shared-bindings/busio/UART.h"
+#endif
+
+#if CIRCUITPY_DISPLAYIO
#include "shared-module/displayio/__init__.h"
#endif
diff --git a/shared-module/displayio/ColorConverter.c b/shared-module/displayio/ColorConverter.c
index 3928e115a..6b9bd5840 100644
--- a/shared-module/displayio/ColorConverter.c
+++ b/shared-module/displayio/ColorConverter.c
@@ -29,15 +29,36 @@
void common_hal_displayio_colorconverter_construct(displayio_colorconverter_t* self) {
}
-bool common_hal_displayio_colorconverter_convert(displayio_colorconverter_t *self, uint32_t input_color, uint16_t* output_color) {
- // TODO(tannewt): Validate the color input against the input format.
- uint32_t r5 = (input_color >> 19);
- uint32_t g6 = (input_color >> 10) & 0x3f;
- uint32_t b5 = (input_color >> 3) & 0x1f;
+uint16_t displayio_colorconverter_compute_rgb565(uint32_t color_rgb888) {
+ uint32_t r5 = (color_rgb888 >> 19);
+ uint32_t g6 = (color_rgb888 >> 10) & 0x3f;
+ uint32_t b5 = (color_rgb888 >> 3) & 0x1f;
uint32_t packed = r5 << 11 | g6 << 5 | b5;
// swap bytes
- *output_color = __builtin_bswap16(packed);
- return true;
+ return __builtin_bswap16(packed);
+}
+
+uint8_t displayio_colorconverter_compute_luma(uint32_t color_rgb888) {
+ uint32_t r8 = (color_rgb888 >> 16);
+ uint32_t g8 = (color_rgb888 >> 8) & 0xff;
+ uint32_t b8 = color_rgb888 & 0xff;
+ return (r8 * 19) / 255 + (g8 * 182) / 255 + (b8 + 54) / 255;
+}
+
+bool displayio_colorconverter_convert(displayio_colorconverter_t *self, const _displayio_colorspace_t* colorspace, uint32_t input_color, uint32_t* output_color) {
+ if (colorspace->depth == 16) {
+ *output_color = displayio_colorconverter_compute_rgb565(input_color);
+ return true;
+ } else if (colorspace->grayscale && colorspace->depth <= 8) {
+ uint8_t luma = displayio_colorconverter_compute_luma(input_color);
+ *output_color = luma >> (8 - colorspace->depth);
+ return true;
+ }
+ return false;
+}
+
+void common_hal_displayio_colorconverter_convert(displayio_colorconverter_t *self, const _displayio_colorspace_t* colorspace, uint32_t input_color, uint32_t* output_color) {
+ displayio_colorconverter_convert(self, colorspace, input_color, output_color);
}
// Currently no refresh logic is needed for a ColorConverter.
diff --git a/shared-module/displayio/ColorConverter.h b/shared-module/displayio/ColorConverter.h
index 7f3c1a0a0..c48b98e6d 100644
--- a/shared-module/displayio/ColorConverter.h
+++ b/shared-module/displayio/ColorConverter.h
@@ -31,6 +31,7 @@
#include <stdint.h>
#include "py/obj.h"
+#include "shared-module/displayio/Palette.h"
typedef struct {
mp_obj_base_t base;
@@ -38,5 +39,8 @@ typedef struct {
bool displayio_colorconverter_needs_refresh(displayio_colorconverter_t *self);
void displayio_colorconverter_finish_refresh(displayio_colorconverter_t *self);
+bool displayio_colorconverter_convert(displayio_colorconverter_t *self, const _displayio_colorspace_t* colorspace, uint32_t input_color, uint32_t* output_color);
+uint16_t displayio_colorconverter_compute_rgb565(uint32_t color_rgb888);
+uint8_t displayio_colorconverter_compute_luma(uint32_t color_rgb888);
#endif // MICROPY_INCLUDED_SHARED_MODULE_DISPLAYIO_COLORCONVERTER_H
diff --git a/shared-module/displayio/Display.c b/shared-module/displayio/Display.c
index 0ae88300a..a8515b9e5 100644
--- a/shared-module/displayio/Display.c
+++ b/shared-module/displayio/Display.c
@@ -28,6 +28,7 @@
#include "py/runtime.h"
#include "shared-bindings/displayio/FourWire.h"
+#include "shared-bindings/displayio/I2CDisplay.h"
#include "shared-bindings/displayio/ParallelBus.h"
#include "shared-bindings/microcontroller/Pin.h"
#include "shared-bindings/time/__init__.h"
@@ -35,6 +36,7 @@
#include "supervisor/shared/display.h"
#include <stdint.h>
+#include <string.h>
#include "tick.h"
@@ -42,11 +44,14 @@
void common_hal_displayio_display_construct(displayio_display_obj_t* self,
mp_obj_t bus, uint16_t width, uint16_t height, int16_t colstart, int16_t rowstart, uint16_t rotation,
- uint16_t color_depth, uint8_t set_column_command, uint8_t set_row_command,
+ uint16_t color_depth, bool grayscale, bool pixels_in_byte_share_row,
+ uint8_t set_column_command, uint8_t set_row_command,
uint8_t write_ram_command, uint8_t set_vertical_scroll, uint8_t* init_sequence, uint16_t init_sequence_len,
- const mcu_pin_obj_t* backlight_pin, mp_float_t brightness, bool auto_brightness,
+ const mcu_pin_obj_t* backlight_pin, uint16_t brightness_command, mp_float_t brightness, bool auto_brightness,
bool single_byte_bounds, bool data_as_commands) {
- self->color_depth = color_depth;
+ self->colorspace.depth = color_depth;
+ self->colorspace.grayscale = grayscale;
+ self->colorspace.pixels_in_byte_share_row = pixels_in_byte_share_row;
self->set_column_command = set_column_command;
self->set_row_command = set_row_command;
self->write_ram_command = write_ram_command;
@@ -54,6 +59,7 @@ void common_hal_displayio_display_construct(displayio_display_obj_t* self,
self->current_group = NULL;
self->colstart = colstart;
self->rowstart = rowstart;
+ self->brightness_command = brightness_command;
self->auto_brightness = auto_brightness;
self->data_as_commands = data_as_commands;
self->single_byte_bounds = single_byte_bounds;
@@ -66,6 +72,10 @@ void common_hal_displayio_display_construct(displayio_display_obj_t* self,
self->begin_transaction = common_hal_displayio_fourwire_begin_transaction;
self->send = common_hal_displayio_fourwire_send;
self->end_transaction = common_hal_displayio_fourwire_end_transaction;
+ } else if (MP_OBJ_IS_TYPE(bus, &displayio_i2cdisplay_type)) {
+ self->begin_transaction = common_hal_displayio_i2cdisplay_begin_transaction;
+ self->send = common_hal_displayio_i2cdisplay_send;
+ self->end_transaction = common_hal_displayio_i2cdisplay_end_transaction;
} else {
mp_raise_ValueError(translate("Unsupported display bus type"));
}
@@ -83,13 +93,13 @@ void common_hal_displayio_display_construct(displayio_display_obj_t* self,
bool delay = (data_size & DELAY) != 0;
data_size &= ~DELAY;
uint8_t *data = cmd + 2;
- self->send(self->bus, true, cmd, 1);
if (self->data_as_commands) {
- // Loop through each parameter to force a CS toggle
- for (uint32_t j=0; j < data_size; j++) {
- self->send(self->bus, true, data + j, 1);
- }
+ uint8_t full_command[data_size + 1];
+ full_command[0] = cmd[0];
+ memcpy(full_command + 1, data, data_size);
+ self->send(self->bus, true, full_command, data_size + 1);
} else {
+ self->send(self->bus, true, cmd, 1);
self->send(self->bus, false, data, data_size);
}
uint16_t delay_length_ms = 10;
@@ -141,11 +151,14 @@ void common_hal_displayio_display_construct(displayio_display_obj_t* self,
} else {
self->backlight_pwm.base.type = &pulseio_pwmout_type;
common_hal_pulseio_pwmout_never_reset(&self->backlight_pwm);
- if (!self->auto_brightness) {
- common_hal_displayio_display_set_brightness(self, brightness);
- }
}
}
+ if (!self->auto_brightness && (self->backlight_inout.base.type != &mp_type_NoneType ||
+ brightness_command != NO_BRIGHTNESS_COMMAND)) {
+ common_hal_displayio_display_set_brightness(self, brightness);
+ } else {
+ self->current_brightness = -1.0;
+ }
self->area.x1 = 0;
self->area.y1 = 0;
@@ -234,17 +247,7 @@ void common_hal_displayio_display_set_auto_brightness(displayio_display_obj_t* s
}
mp_float_t common_hal_displayio_display_get_brightness(displayio_display_obj_t* self) {
- if (self->backlight_pwm.base.type == &pulseio_pwmout_type) {
- uint16_t duty_cycle = common_hal_pulseio_pwmout_get_duty_cycle(&self->backlight_pwm);
- return duty_cycle / ((mp_float_t) 0xffff);
- } else if (self->backlight_inout.base.type == &digitalio_digitalinout_type) {
- if (common_hal_digitalio_digitalinout_get_value(&self->backlight_inout)) {
- return 1.0;
- } else {
- return 0.0;
- }
- }
- return -1.0;
+ return self->current_brightness;
}
bool common_hal_displayio_display_set_brightness(displayio_display_obj_t* self, mp_float_t brightness) {
@@ -256,8 +259,26 @@ bool common_hal_displayio_display_set_brightness(displayio_display_obj_t* self,
} else if (self->backlight_inout.base.type == &digitalio_digitalinout_type) {
common_hal_digitalio_digitalinout_set_value(&self->backlight_inout, brightness > 0.99);
ok = true;
+ } else if (self->brightness_command != NO_BRIGHTNESS_COMMAND) {
+ ok = self->begin_transaction(self->bus);
+ if (ok) {
+ if (self->data_as_commands) {
+ uint8_t set_brightness[2] = {self->brightness_command, (uint8_t) (0xff * brightness)};
+ self->send(self->bus, true, set_brightness, 2);
+ } else {
+ uint8_t command = self->brightness_command;
+ uint8_t hex_brightness = 0xff * brightness;
+ self->send(self->bus, true, &command, 1);
+ self->send(self->bus, false, &hex_brightness, 1);
+ }
+ self->end_transaction(self->bus);
+ }
+
}
self->updating_backlight = false;
+ if (ok) {
+ self->current_brightness = brightness;
+ }
return ok;
}
@@ -269,35 +290,64 @@ void displayio_display_end_transaction(displayio_display_obj_t* self) {
self->end_transaction(self->bus);
}
-void displayio_display_set_region_to_update(displayio_display_obj_t* self, uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) {
- self->send(self->bus, true, &self->set_column_command, 1);
- bool isCommand = self->data_as_commands;
- if (self->single_byte_bounds) {
- uint8_t data[2];
- data[0] = x0 + self->colstart;
- data[1] = x1 - 1 + self->colstart;
- self->send(self->bus, isCommand, (uint8_t*) data, 2);
- } else {
- uint16_t data[2];
- data[0] = __builtin_bswap16(x0 + self->colstart);
- data[1] = __builtin_bswap16(x1 - 1 + self->colstart);
- self->send(self->bus, isCommand, (uint8_t*) data, 4);
+void displayio_display_set_region_to_update(displayio_display_obj_t* self, displayio_area_t* area) {
+ uint16_t x1 = area->x1;
+ uint16_t x2 = area->x2;
+ uint16_t y1 = area->y1;
+ uint16_t y2 = area->y2;
+ // Collapse down the dimension where multiple pixels are in a byte.
+ if (self->colorspace.depth < 8) {
+ uint8_t pixels_per_byte = 8 / self->colorspace.depth;
+ if (self->colorspace.pixels_in_byte_share_row) {
+ x1 /= pixels_per_byte;
+ x2 /= pixels_per_byte;
+ } else {
+ y1 /= pixels_per_byte;
+ y2 /= pixels_per_byte;
+ }
+ }
+
+ // Set column.
+ uint8_t data[5];
+ data[0] = self->set_column_command;
+ uint8_t data_length = 1;
+ if (!self->data_as_commands) {
+ self->send(self->bus, true, data, 1);
+ data_length = 0;
}
- self->send(self->bus, true, &self->set_row_command, 1);
if (self->single_byte_bounds) {
- uint8_t data[2];
- data[0] = y0 + self->rowstart;
- data[1] = y1 - 1 + self->rowstart;
- self->send(self->bus, isCommand, (uint8_t*) data, 2);
+ data[data_length++] = x1 + self->colstart;
+ data[data_length++] = x2 - 1 + self->colstart;
+ data_length += 2;
} else {
- uint16_t data[2];
- data[0] = __builtin_bswap16(y0 + self->rowstart);
- data[1] = __builtin_bswap16(y1 - 1 + self->rowstart);
- self->send(self->bus, isCommand, (uint8_t*) data, 4);
+ x1 += self->colstart;
+ x2 += self->colstart - 1;
+ data[data_length++] = x1 >> 8;
+ data[data_length++] = x1 & 0xff;
+ data[data_length++] = x2 >> 8;
+ data[data_length++] = x2 & 0xff;
}
+ self->send(self->bus, self->data_as_commands, data, data_length);
+
+ // Set row.
+ data[0] = self->set_row_command;
+ data_length = 1;
if (!self->data_as_commands) {
- self->send(self->bus, true, &self->write_ram_command, 1);
+ self->send(self->bus, true, data, 1);
+ data_length = 0;
}
+ if (self->single_byte_bounds) {
+ data[data_length++] = y1 + self->rowstart;
+ data[data_length++] = y2 - 1 + self->rowstart;
+ } else {
+ y1 += self->rowstart;
+ y2 += self->rowstart - 1;
+ data[data_length++] = y1 >> 8;
+ data[data_length++] = y1 & 0xff;
+ data[data_length++] = y2 >> 8;
+ data[data_length++] = y2 & 0xff;
+ }
+ self->send(self->bus, self->data_as_commands, data, data_length);
}
void displayio_display_start_refresh(displayio_display_obj_t* self) {
@@ -322,6 +372,9 @@ void displayio_display_finish_refresh(displayio_display_obj_t* self) {
}
void displayio_display_send_pixels(displayio_display_obj_t* self, uint8_t* pixels, uint32_t length) {
+ if (!self->data_as_commands) {
+ self->send(self->bus, true, &self->write_ram_command, 1);
+ }
self->send(self->bus, false, pixels, length);
}
@@ -349,9 +402,33 @@ void release_display(displayio_display_obj_t* self) {
}
bool displayio_display_fill_area(displayio_display_obj_t *self, displayio_area_t* area, uint32_t* mask, uint32_t *buffer) {
- return displayio_group_fill_area(self->current_group, area, mask, buffer);
+ return displayio_group_fill_area(self->current_group, &self->colorspace, area, mask, buffer);
}
bool displayio_display_clip_area(displayio_display_obj_t *self, const displayio_area_t* area, displayio_area_t* clipped) {
- return displayio_area_compute_overlap(&self->area, area, clipped);
+ bool overlaps = displayio_area_compute_overlap(&self->area, area, clipped);
+ if (!overlaps) {
+ return false;
+ }
+ // Expand the area if we have multiple pixels per byte and we need to byte
+ // align the bounds.
+ if (self->colorspace.depth < 8) {
+ uint8_t pixels_per_byte = 8 / self->colorspace.depth;
+ if (self->colorspace.pixels_in_byte_share_row) {
+ if (clipped->x1 % pixels_per_byte != 0) {
+ clipped->x1 -= clipped->x1 % pixels_per_byte;
+ }
+ if (clipped->x2 % pixels_per_byte != 0) {
+ clipped->x2 += pixels_per_byte - clipped->x2 % pixels_per_byte;
+ }
+ } else {
+ if (clipped->y1 % pixels_per_byte != 0) {
+ clipped->y1 -= clipped->y1 % pixels_per_byte;
+ }
+ if (clipped->y2 % pixels_per_byte != 0) {
+ clipped->y2 += pixels_per_byte - clipped->y2 % pixels_per_byte;
+ }
+ }
+ }
+ return true;
}
diff --git a/shared-module/displayio/Display.h b/shared-module/displayio/Display.h
index fa8902ced..96d1c06d5 100644
--- a/shared-module/displayio/Display.h
+++ b/shared-module/displayio/Display.h
@@ -52,11 +52,13 @@ typedef struct {
uint64_t last_backlight_refresh;
displayio_buffer_transform_t transform;
displayio_area_t area;
+ mp_float_t current_brightness;
uint16_t width;
uint16_t height;
- uint16_t color_depth;
+ _displayio_colorspace_t colorspace;
int16_t colstart;
int16_t rowstart;
+ uint16_t brightness_command;
uint8_t set_column_command;
uint8_t set_row_command;
uint8_t write_ram_command;
diff --git a/shared-module/displayio/FourWire.c b/shared-module/displayio/FourWire.c
index d38da56fc..913635db8 100644
--- a/shared-module/displayio/FourWire.c
+++ b/shared-module/displayio/FourWire.c
@@ -59,6 +59,11 @@ void common_hal_displayio_fourwire_construct(displayio_fourwire_obj_t* self,
common_hal_digitalio_digitalinout_construct(&self->reset, reset);
common_hal_digitalio_digitalinout_switch_to_output(&self->reset, true, DRIVE_MODE_PUSH_PULL);
never_reset_pin_number(reset->number);
+
+ common_hal_digitalio_digitalinout_set_value(&self->reset, false);
+ common_hal_mcu_delay_us(10);
+ common_hal_digitalio_digitalinout_set_value(&self->reset, true);
+ common_hal_mcu_delay_us(10);
}
never_reset_pin_number(command->number);
@@ -88,13 +93,19 @@ bool common_hal_displayio_fourwire_begin_transaction(mp_obj_t obj) {
void common_hal_displayio_fourwire_send(mp_obj_t obj, bool command, uint8_t *data, uint32_t data_length) {
displayio_fourwire_obj_t* self = MP_OBJ_TO_PTR(obj);
+ common_hal_digitalio_digitalinout_set_value(&self->command, !command);
if (command) {
- common_hal_digitalio_digitalinout_set_value(&self->chip_select, true);
- common_hal_mcu_delay_us(1);
- common_hal_digitalio_digitalinout_set_value(&self->chip_select, false);
+ // Toggle chip select after each command byte in case the display driver
+ // IC latches commands based on it.
+ for (size_t i = 0; i < data_length; i++) {
+ common_hal_busio_spi_write(self->bus, &data[i], 1);
+ common_hal_digitalio_digitalinout_set_value(&self->chip_select, true);
+ common_hal_mcu_delay_us(1);
+ common_hal_digitalio_digitalinout_set_value(&self->chip_select, false);
+ }
+ } else {
+ common_hal_busio_spi_write(self->bus, data, data_length);
}
- common_hal_digitalio_digitalinout_set_value(&self->command, !command);
- common_hal_busio_spi_write(self->bus, data, data_length);
}
void common_hal_displayio_fourwire_end_transaction(mp_obj_t obj) {
diff --git a/shared-module/displayio/FourWire.h b/shared-module/displayio/FourWire.h
index 743139e62..a4260a3ac 100644
--- a/shared-module/displayio/FourWire.h
+++ b/shared-module/displayio/FourWire.h
@@ -24,8 +24,8 @@
* THE SOFTWARE.
*/
-#ifndef MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_DISPLAYIO_FOURWIRE_H
-#define MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_DISPLAYIO_FOURWIRE_H
+#ifndef MICROPY_INCLUDED_SHARED_MODULE_DISPLAYIO_FOURWIRE_H
+#define MICROPY_INCLUDED_SHARED_MODULE_DISPLAYIO_FOURWIRE_H
#include "common-hal/busio/SPI.h"
#include "common-hal/digitalio/DigitalInOut.h"
@@ -43,4 +43,4 @@ typedef struct {
uint8_t phase;
} displayio_fourwire_obj_t;
-#endif // MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_DISPLAYIO_FOURWIRE_H
+#endif // MICROPY_INCLUDED_SHARED_MODULE_DISPLAYIO_FOURWIRE_H
diff --git a/shared-module/displayio/Group.c b/shared-module/displayio/Group.c
index 15060e87b..38418a029 100644
--- a/shared-module/displayio/Group.c
+++ b/shared-module/displayio/Group.c
@@ -270,19 +270,19 @@ void displayio_group_construct(displayio_group_t* self, displayio_group_child_t*
self->in_group = false;
}
-bool displayio_group_fill_area(displayio_group_t *self, const displayio_area_t* area, uint32_t* mask, uint32_t* buffer) {
+bool displayio_group_fill_area(displayio_group_t *self, const _displayio_colorspace_t* colorspace, const displayio_area_t* area, uint32_t* mask, uint32_t* buffer) {
// Track if any of the layers finishes filling in the given area. We can ignore any remaining
// layers at that point.
bool full_coverage = false;
for (int32_t i = self->size - 1; i >= 0 ; i--) {
mp_obj_t layer = self->children[i].native;
if (MP_OBJ_IS_TYPE(layer, &displayio_tilegrid_type)) {
- if (displayio_tilegrid_fill_area(layer, area, mask, buffer)) {
+ if (displayio_tilegrid_fill_area(layer, colorspace, area, mask, buffer)) {
full_coverage = true;
break;
}
} else if (MP_OBJ_IS_TYPE(layer, &displayio_group_type)) {
- if (displayio_group_fill_area(layer, area, mask, buffer)) {
+ if (displayio_group_fill_area(layer, colorspace, area, mask, buffer)) {
full_coverage = true;
break;
}
diff --git a/shared-module/displayio/Group.h b/shared-module/displayio/Group.h
index 7ce19a4cd..4e2308e56 100644
--- a/shared-module/displayio/Group.h
+++ b/shared-module/displayio/Group.h
@@ -32,6 +32,7 @@
#include "py/obj.h"
#include "shared-module/displayio/area.h"
+#include "shared-module/displayio/Palette.h"
typedef struct {
mp_obj_t native;
@@ -54,7 +55,7 @@ typedef struct {
void displayio_group_construct(displayio_group_t* self, displayio_group_child_t* child_array, uint32_t max_size, uint32_t scale, mp_int_t x, mp_int_t y);
bool displayio_group_get_previous_area(displayio_group_t *group, displayio_area_t* area);
-bool displayio_group_fill_area(displayio_group_t *group, const displayio_area_t* area, uint32_t* mask, uint32_t *buffer);
+bool displayio_group_fill_area(displayio_group_t *group, const _displayio_colorspace_t* colorspace, const displayio_area_t* area, uint32_t* mask, uint32_t *buffer);
void displayio_group_update_transform(displayio_group_t *group, const displayio_buffer_transform_t* parent_transform);
void displayio_group_finish_refresh(displayio_group_t *self);
displayio_area_t* displayio_group_get_refresh_areas(displayio_group_t *self, displayio_area_t* tail);
diff --git a/shared-module/displayio/I2CDisplay.c b/shared-module/displayio/I2CDisplay.c
new file mode 100644
index 000000000..9d8949528
--- /dev/null
+++ b/shared-module/displayio/I2CDisplay.c
@@ -0,0 +1,105 @@
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2018 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/displayio/I2CDisplay.h"
+
+#include <stdint.h>
+#include <string.h>
+
+#include "py/gc.h"
+#include "py/runtime.h"
+#include "shared-bindings/busio/I2C.h"
+#include "shared-bindings/digitalio/DigitalInOut.h"
+#include "shared-bindings/microcontroller/__init__.h"
+#include "shared-bindings/time/__init__.h"
+
+#include "tick.h"
+
+void common_hal_displayio_i2cdisplay_construct(displayio_i2cdisplay_obj_t* self,
+ busio_i2c_obj_t* i2c, uint16_t device_address, const mcu_pin_obj_t* reset) {
+
+ // Probe the bus to see if a device acknowledges the given address.
+ if (!common_hal_busio_i2c_probe(i2c, device_address)) {
+ mp_raise_ValueError_varg(translate("Unable to find I2C Display at %x"), device_address);
+ }
+
+ // Write to the device and return 0 on success or an appropriate error code from mperrno.h
+ self->bus = i2c;
+ common_hal_busio_i2c_never_reset(self->bus);
+ // Our object is statically allocated off the heap so make sure the bus object lives to the end
+ // of the heap as well.
+ gc_never_free(self->bus);
+
+ self->address = device_address;
+
+ if (reset != NULL) {
+ common_hal_digitalio_digitalinout_construct(&self->reset, reset);
+ common_hal_digitalio_digitalinout_switch_to_output(&self->reset, true, DRIVE_MODE_PUSH_PULL);
+ never_reset_pin_number(reset->number);
+
+ common_hal_digitalio_digitalinout_set_value(&self->reset, false);
+ common_hal_mcu_delay_us(1);
+ common_hal_digitalio_digitalinout_set_value(&self->reset, true);
+ }
+}
+
+void common_hal_displayio_i2cdisplay_deinit(displayio_i2cdisplay_obj_t* self) {
+ if (self->bus == &self->inline_bus) {
+ common_hal_busio_i2c_deinit(self->bus);
+ }
+
+ reset_pin_number(self->reset.pin->number);
+}
+
+bool common_hal_displayio_i2cdisplay_begin_transaction(mp_obj_t obj) {
+ displayio_i2cdisplay_obj_t* self = MP_OBJ_TO_PTR(obj);
+ if (!common_hal_busio_i2c_try_lock(self->bus)) {
+ return false;
+ }
+ return true;
+}
+
+void common_hal_displayio_i2cdisplay_send(mp_obj_t obj, bool command, uint8_t *data, uint32_t data_length) {
+ displayio_i2cdisplay_obj_t* self = MP_OBJ_TO_PTR(obj);
+ if (command) {
+ uint8_t command_bytes[2 * data_length];
+ for (uint32_t i = 0; i < data_length; i++) {
+ command_bytes[2 * i] = 0x80;
+ command_bytes[2 * i + 1] = data[i];
+ }
+ common_hal_busio_i2c_write(self->bus, self->address, command_bytes, 2 * data_length, true);
+ } else {
+ uint8_t data_bytes[data_length + 1];
+ data_bytes[0] = 0x40;
+ memcpy(data_bytes + 1, data, data_length);
+ common_hal_busio_i2c_write(self->bus, self->address, data_bytes, data_length + 1, true);
+ }
+}
+
+void common_hal_displayio_i2cdisplay_end_transaction(mp_obj_t obj) {
+ displayio_i2cdisplay_obj_t* self = MP_OBJ_TO_PTR(obj);
+ common_hal_busio_i2c_unlock(self->bus);
+}
diff --git a/shared-module/displayio/I2CDisplay.h b/shared-module/displayio/I2CDisplay.h
new file mode 100644
index 000000000..4636c3f73
--- /dev/null
+++ b/shared-module/displayio/I2CDisplay.h
@@ -0,0 +1,41 @@
+/*
+ * 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.
+ */
+
+#ifndef MICROPY_INCLUDED_SHARED_MODULE_DISPLAYIO_I2CDISPLAY_H
+#define MICROPY_INCLUDED_SHARED_MODULE_DISPLAYIO_I2CDISPLAY_H
+
+#include "common-hal/busio/I2C.h"
+#include "common-hal/digitalio/DigitalInOut.h"
+
+typedef struct {
+ mp_obj_base_t base;
+ busio_i2c_obj_t* bus;
+ busio_i2c_obj_t inline_bus;
+ digitalio_digitalinout_obj_t reset;
+ uint16_t address;
+} displayio_i2cdisplay_obj_t;
+
+#endif // MICROPY_INCLUDED_SHARED_MODULE_DISPLAYIO_I2CDISPLAY_H
diff --git a/shared-module/displayio/Palette.c b/shared-module/displayio/Palette.c
index 8dc6e766b..444151b3c 100644
--- a/shared-module/displayio/Palette.c
+++ b/shared-module/displayio/Palette.c
@@ -26,49 +26,49 @@
#include "shared-bindings/displayio/Palette.h"
+#include "shared-module/displayio/ColorConverter.h"
+
void common_hal_displayio_palette_construct(displayio_palette_t* self, uint16_t color_count) {
self->color_count = color_count;
- self->colors = (uint32_t *) m_malloc(color_count * sizeof(uint16_t), false);
- uint32_t opaque_byte_count = color_count / 8;
- if (color_count % 8 > 0) {
- opaque_byte_count += 1;
- }
- self->opaque = (uint32_t *) m_malloc(opaque_byte_count, false);
+ self->colors = (_displayio_color_t *) m_malloc(color_count * sizeof(_displayio_color_t), false);
}
void common_hal_displayio_palette_make_opaque(displayio_palette_t* self, uint32_t palette_index) {
- self->opaque[palette_index / 32] &= ~(0x1 << (palette_index % 32));
+ self->colors[palette_index].transparent = false;
}
void common_hal_displayio_palette_make_transparent(displayio_palette_t* self, uint32_t palette_index) {
- self->opaque[palette_index / 32] |= (0x1 << (palette_index % 32));
+ self->colors[palette_index].transparent = true;
+}
+
+uint32_t common_hal_displayio_palette_get_len(displayio_palette_t* self) {
+ return self->color_count;
}
void common_hal_displayio_palette_set_color(displayio_palette_t* self, uint32_t palette_index, uint32_t color) {
- uint32_t shift = (palette_index % 2) * 16;
- uint32_t masked = self->colors[palette_index / 2] & ~(0xffff << shift);
- uint32_t r5 = (color >> 19);
- uint32_t g6 = (color >> 10) & 0x3f;
- uint32_t b5 = (color >> 3) & 0x1f;
- uint32_t packed = r5 << 11 | g6 << 5 | b5;
- // swap bytes
- packed = __builtin_bswap16(packed);
- uint32_t final_color = masked | packed << shift;
- if (self->colors[palette_index / 2] == final_color) {
+ if (self->colors[palette_index].rgb888 == color) {
return;
}
- self->colors[palette_index / 2] = final_color;
+ self->colors[palette_index].rgb888 = color;
+ self->colors[palette_index].luma = displayio_colorconverter_compute_luma(color);
+ self->colors[palette_index].rgb565 = displayio_colorconverter_compute_rgb565(color);
self->needs_refresh = true;
}
-bool displayio_palette_get_color(displayio_palette_t *self, uint32_t palette_index, uint16_t* color) {
- if (palette_index > self->color_count) {
- return false;
+uint32_t common_hal_displayio_palette_get_color(displayio_palette_t* self, uint32_t palette_index) {
+ return self->colors[palette_index].rgb888;
+}
+
+bool displayio_palette_get_color(displayio_palette_t *self, const _displayio_colorspace_t* colorspace, uint32_t palette_index, uint32_t* color) {
+ if (palette_index > self->color_count || self->colors[palette_index].transparent) {
+ return false; // returns opaque
}
- if ((self->opaque[palette_index / 32] & (0x1 << (palette_index % 32))) != 0) {
- return false;
+
+ if (colorspace->grayscale) {
+ *color = self->colors[palette_index].luma >> (8 - colorspace->depth);
+ } else {
+ *color = self->colors[palette_index].rgb565;
}
- *color = (self->colors[palette_index / 2] >> (16 * (palette_index % 2))) & 0xffff;
return true;
}
diff --git a/shared-module/displayio/Palette.h b/shared-module/displayio/Palette.h
index 3813e8bdd..19c05baf5 100644
--- a/shared-module/displayio/Palette.h
+++ b/shared-module/displayio/Palette.h
@@ -33,14 +33,29 @@
#include "py/obj.h"
typedef struct {
+ uint8_t depth;
+ bool grayscale;
+ bool pixels_in_byte_share_row;
+ uint8_t hue;
+} _displayio_colorspace_t;
+
+typedef struct {
+ uint32_t rgb888;
+ uint16_t rgb565;
+ uint8_t luma;
+ bool transparent; // This may have additional bits added later for blending.
+} _displayio_color_t;
+
+typedef struct {
mp_obj_base_t base;
- uint32_t* opaque;
- uint32_t* colors;
+ _displayio_color_t* colors;
uint32_t color_count;
bool needs_refresh;
} displayio_palette_t;
-bool displayio_palette_get_color(displayio_palette_t *palette, uint32_t palette_index, uint16_t* color);
+// Returns false if color fetch did not succeed (out of range or transparent).
+// Returns true if color is opaque, and sets color.
+bool displayio_palette_get_color(displayio_palette_t *palette, const _displayio_colorspace_t* colorspace, uint32_t palette_index, uint32_t* color);
bool displayio_palette_needs_refresh(displayio_palette_t *self);
void displayio_palette_finish_refresh(displayio_palette_t *self);
diff --git a/shared-module/displayio/TileGrid.c b/shared-module/displayio/TileGrid.c
index cdca45a29..88873d3a9 100644
--- a/shared-module/displayio/TileGrid.c
+++ b/shared-module/displayio/TileGrid.c
@@ -291,7 +291,7 @@ void common_hal_displayio_tilegrid_set_top_left(displayio_tilegrid_t *self, uint
self->full_change = true;
}
-bool displayio_tilegrid_fill_area(displayio_tilegrid_t *self, const displayio_area_t* area, uint32_t* mask, uint32_t *buffer) {
+bool displayio_tilegrid_fill_area(displayio_tilegrid_t *self, const _displayio_colorspace_t* colorspace, const displayio_area_t* area, uint32_t* mask, uint32_t *buffer) {
// If no tiles are present we have no impact.
uint8_t* tiles = self->tiles;
if (self->inline_tiles) {
@@ -371,14 +371,15 @@ bool displayio_tilegrid_fill_area(displayio_tilegrid_t *self, const displayio_ar
y_shift = temp_shift;
}
+ uint8_t pixels_per_byte = 8 / colorspace->depth;
for (int16_t y = start_y; y < end_y; y++) {
- int16_t row_start = start + (y - start_y + y_shift) * y_stride;
+ int16_t row_start = start + (y - start_y + y_shift) * y_stride; // in pixels
int16_t local_y = y / self->absolute_transform->scale;
for (int16_t x = start_x; x < end_x; x++) {
// Compute the destination pixel in the buffer and mask based on the transformations.
- int16_t offset = row_start + (x - start_x + x_shift) * x_stride;
+ int16_t offset = row_start + (x - start_x + x_shift) * x_stride; // in pixels
- // This is super useful for debugging out range accesses. Uncomment to use.
+ // This is super useful for debugging out of range accesses. Uncomment to use.
// if (offset < 0 || offset >= (int32_t) displayio_area_size(area)) {
// asm("bkpt");
// }
@@ -404,23 +405,38 @@ bool displayio_tilegrid_fill_area(displayio_tilegrid_t *self, const displayio_ar
value = common_hal_displayio_ondiskbitmap_get_pixel(self->bitmap, tile_x, tile_y);
}
- uint16_t* pixel = ((uint16_t*) buffer) + offset;
+ uint32_t pixel;
+ bool opaque = true;
if (self->pixel_shader == mp_const_none) {
- *pixel = value;
- return true;
+ pixel = value;
} else if (MP_OBJ_IS_TYPE(self->pixel_shader, &displayio_palette_type)) {
- if (!displayio_palette_get_color(self->pixel_shader, value, pixel)) {
- // A pixel is transparent so we haven't fully covered the area ourselves.
- full_coverage = false;
- } else {
- mask[offset / 32] |= 1 << (offset % 32);
- }
+ opaque = displayio_palette_get_color(self->pixel_shader, colorspace, value, &pixel);
} else if (MP_OBJ_IS_TYPE(self->pixel_shader, &displayio_colorconverter_type)) {
- if (!common_hal_displayio_colorconverter_convert(self->pixel_shader, value, pixel)) {
- // A pixel is transparent so we haven't fully covered the area ourselves.
- full_coverage = false;
- } else {
- mask[offset / 32] |= 1 << (offset % 32);
+ opaque = displayio_colorconverter_convert(self->pixel_shader, colorspace, value, &pixel);
+ }
+ if (!opaque) {
+ // A pixel is transparent so we haven't fully covered the area ourselves.
+ full_coverage = false;
+ } else {
+ mask[offset / 32] |= 1 << (offset % 32);
+ if (colorspace->depth == 16) {
+ *(((uint16_t*) buffer) + offset) = pixel;
+ } else if (colorspace->depth == 8) {
+ *(((uint8_t*) buffer) + offset) = pixel;
+ } else if (colorspace->depth < 8) {
+ // Reorder the offsets to pack multiple rows into a byte (meaning they share a column).
+ if (!colorspace->pixels_in_byte_share_row) {
+ uint16_t width = displayio_area_width(area);
+ uint16_t row = offset / width;
+ uint16_t col = offset % width;
+ // Dividing by pixels_per_byte does truncated division even if we multiply it back out.
+ offset = col * pixels_per_byte + (row / pixels_per_byte) * pixels_per_byte * width + row % pixels_per_byte;
+ // Also useful for validating that the bitpacking worked correctly.
+ // if (offset > displayio_area_size(area)) {
+ // asm("bkpt");
+ // }
+ }
+ ((uint8_t*)buffer)[offset / pixels_per_byte] |= pixel << ((offset % pixels_per_byte) * colorspace->depth);
}
}
}
@@ -449,7 +465,7 @@ void displayio_tilegrid_finish_refresh(displayio_tilegrid_t *self) {
displayio_area_t* displayio_tilegrid_get_refresh_areas(displayio_tilegrid_t *self, displayio_area_t* tail) {
if (self->moved && !self->first_draw) {
displayio_area_union(&self->previous_area, &self->current_area, &self->dirty_area);
- if (displayio_area_size(&self->dirty_area) <= 2 * self->pixel_width * self->pixel_height) {
+ if (displayio_area_size(&self->dirty_area) <= 2U * self->pixel_width * self->pixel_height) {
self->dirty_area.next = tail;
return &self->dirty_area;
}
diff --git a/shared-module/displayio/TileGrid.h b/shared-module/displayio/TileGrid.h
index 4d97eccc2..fb6033e9c 100644
--- a/shared-module/displayio/TileGrid.h
+++ b/shared-module/displayio/TileGrid.h
@@ -32,6 +32,7 @@
#include "py/obj.h"
#include "shared-module/displayio/area.h"
+#include "shared-module/displayio/Palette.h"
typedef struct {
mp_obj_base_t base;
@@ -71,7 +72,7 @@ displayio_area_t* displayio_tilegrid_get_refresh_areas(displayio_tilegrid_t *sel
// Area is always in absolute screen coordinates. Update transform is used to inform TileGrids how
// they relate to it.
-bool displayio_tilegrid_fill_area(displayio_tilegrid_t *self, const displayio_area_t* area, uint32_t* mask, uint32_t *buffer);
+bool displayio_tilegrid_fill_area(displayio_tilegrid_t *self, const _displayio_colorspace_t* colorspace, const displayio_area_t* area, uint32_t* mask, uint32_t *buffer);
void displayio_tilegrid_update_transform(displayio_tilegrid_t *group, const displayio_buffer_transform_t* parent_transform);
// Fills in area with the maximum bounds of all related pixels in the last rendered frame. Returns
diff --git a/shared-module/displayio/__init__.c b/shared-module/displayio/__init__.c
index b6709e0eb..97060aaeb 100644
--- a/shared-module/displayio/__init__.c
+++ b/shared-module/displayio/__init__.c
@@ -19,9 +19,10 @@
#include "supervisor/usb.h"
primary_display_t displays[CIRCUITPY_DISPLAY_LIMIT];
+uint32_t frame_count = 0;
bool refresh_area(displayio_display_obj_t* display, const displayio_area_t* area) {
- uint16_t buffer_size = 512;
+ uint16_t buffer_size = 128; // In uint32_ts
displayio_area_t clipped;
// Clip the area to the display by overlapping the areas. If there is no overlap then we're done.
@@ -30,15 +31,36 @@ bool refresh_area(displayio_display_obj_t* display, const displayio_area_t* area
}
uint16_t subrectangles = 1;
uint16_t rows_per_buffer = displayio_area_height(&clipped);
- if (displayio_area_size(area) > buffer_size) {
- rows_per_buffer = buffer_size / displayio_area_width(&clipped);
+ uint8_t pixels_per_word = (sizeof(uint32_t) * 8) / display->colorspace.depth;
+ uint16_t pixels_per_buffer = displayio_area_size(&clipped);
+ if (displayio_area_size(&clipped) > buffer_size * pixels_per_word) {
+ rows_per_buffer = buffer_size * pixels_per_word / displayio_area_width(&clipped);
+ if (rows_per_buffer == 0) {
+ rows_per_buffer = 1;
+ }
+ // If pixels are packed by column then ensure rows_per_buffer is on a byte boundary.
+ if (display->colorspace.depth < 8 && !display->colorspace.pixels_in_byte_share_row) {
+ uint8_t pixels_per_byte = 8 / display->colorspace.depth;
+ if (rows_per_buffer % pixels_per_byte != 0) {
+ rows_per_buffer -= rows_per_buffer % pixels_per_byte;
+ }
+ }
subrectangles = displayio_area_height(&clipped) / rows_per_buffer;
if (displayio_area_height(&clipped) % rows_per_buffer != 0) {
subrectangles++;
}
- buffer_size = rows_per_buffer * displayio_area_width(&clipped);
+ pixels_per_buffer = rows_per_buffer * displayio_area_width(&clipped);
+ buffer_size = pixels_per_buffer / pixels_per_word;
+ if (pixels_per_buffer % pixels_per_word) {
+ buffer_size += 1;
+ }
}
- uint32_t buffer[buffer_size / 2];
+
+ // Allocated and shared as a uint32_t array so the compiler knows the
+ // alignment everywhere.
+ uint32_t buffer[buffer_size];
+ volatile uint32_t mask_length = (pixels_per_buffer / 32) + 1;
+ uint32_t mask[mask_length];
uint16_t remaining_rows = displayio_area_height(&clipped);
for (uint16_t j = 0; j < subrectangles; j++) {
@@ -54,37 +76,30 @@ bool refresh_area(displayio_display_obj_t* display, const displayio_area_t* area
remaining_rows -= rows_per_buffer;
displayio_display_begin_transaction(display);
- displayio_display_set_region_to_update(display, subrectangle.x1, subrectangle.y1,
- subrectangle.x2, subrectangle.y2);
+ displayio_display_set_region_to_update(display, &subrectangle);
displayio_display_end_transaction(display);
- uint32_t mask[(buffer_size / 32) + 1];
- for (uint16_t k = 0; k < (buffer_size / 32) + 1; k++) {
- mask[k] = 0x00000000;
+ uint16_t subrectangle_size_bytes;
+ if (display->colorspace.depth >= 8) {
+ subrectangle_size_bytes = displayio_area_size(&subrectangle) * (display->colorspace.depth / 8);
+ } else {
+ subrectangle_size_bytes = displayio_area_size(&subrectangle) / (8 / display->colorspace.depth);
}
- bool full_coverage = displayio_display_fill_area(display, &subrectangle, mask, buffer);
- if (!full_coverage) {
- uint32_t index = 0;
- uint32_t current_mask = 0;
- for (int16_t y = subrectangle.y1; y < subrectangle.y2; y++) {
- for (int16_t x = subrectangle.x1; x < subrectangle.x2; x++) {
- if (index % 32 == 0) {
- current_mask = mask[index / 32];
- }
- if ((current_mask & (1 << (index % 32))) == 0) {
- ((uint16_t*) buffer)[index] = 0x0000;
- }
- index++;
- }
- }
+ for (uint16_t k = 0; k < mask_length; k++) {
+ mask[k] = 0x00000000;
+ }
+ for (uint16_t k = 0; k < buffer_size; k++) {
+ buffer[k] = 0x00000000;
}
+ displayio_display_fill_area(display, &subrectangle, mask, buffer);
+
if (!displayio_display_begin_transaction(display)) {
// Can't acquire display bus; skip the rest of the data. Try next display.
return false;
}
- displayio_display_send_pixels(display, (uint8_t*) buffer, displayio_area_size(&subrectangle) * sizeof(uint16_t));
+ displayio_display_send_pixels(display, (uint8_t*) buffer, subrectangle_size_bytes);
displayio_display_end_transaction(display);
// TODO(tannewt): Make refresh displays faster so we don't starve other
@@ -96,7 +111,6 @@ bool refresh_area(displayio_display_obj_t* display, const displayio_area_t* area
// Check for recursive calls to displayio_refresh_displays.
bool refresh_displays_in_progress = false;
-uint32_t frame_count = 0;
void displayio_refresh_displays(void) {
if (mp_hal_is_interrupted()) {
@@ -153,6 +167,8 @@ void common_hal_displayio_release_displays(void) {
continue;
} else if (bus_type == &displayio_fourwire_type) {
common_hal_displayio_fourwire_deinit(&displays[i].fourwire_bus);
+ } else if (bus_type == &displayio_i2cdisplay_type) {
+ common_hal_displayio_i2cdisplay_deinit(&displays[i].i2cdisplay_bus);
} else if (bus_type == &displayio_parallelbus_type) {
common_hal_displayio_parallelbus_deinit(&displays[i].parallel_bus);
}
@@ -169,30 +185,53 @@ void common_hal_displayio_release_displays(void) {
void reset_displays(void) {
// The SPI buses used by FourWires may be allocated on the heap so we need to move them inline.
for (uint8_t i = 0; i < CIRCUITPY_DISPLAY_LIMIT; i++) {
- if (displays[i].fourwire_bus.base.type != &displayio_fourwire_type) {
- continue;
- }
- displayio_fourwire_obj_t* fourwire = &displays[i].fourwire_bus;
- if (((uint32_t) fourwire->bus) < ((uint32_t) &displays) ||
- ((uint32_t) fourwire->bus) > ((uint32_t) &displays + CIRCUITPY_DISPLAY_LIMIT)) {
- busio_spi_obj_t* original_spi = fourwire->bus;
- #if BOARD_SPI
- // We don't need to move original_spi if it is the board.SPI object because it is
- // statically allocated already. (Doing so would also make it impossible to reference in
- // a subsequent VM run.)
- if (original_spi == common_hal_board_get_spi()) {
- continue;
+ if (displays[i].fourwire_bus.base.type == &displayio_fourwire_type) {
+ displayio_fourwire_obj_t* fourwire = &displays[i].fourwire_bus;
+ if (((uint32_t) fourwire->bus) < ((uint32_t) &displays) ||
+ ((uint32_t) fourwire->bus) > ((uint32_t) &displays + CIRCUITPY_DISPLAY_LIMIT)) {
+ busio_spi_obj_t* original_spi = fourwire->bus;
+ #if BOARD_SPI
+ // We don't need to move original_spi if it is the board.SPI object because it is
+ // statically allocated already. (Doing so would also make it impossible to reference in
+ // a subsequent VM run.)
+ if (original_spi == common_hal_board_get_spi()) {
+ continue;
+ }
+ #endif
+ memcpy(&fourwire->inline_bus, original_spi, sizeof(busio_spi_obj_t));
+ fourwire->bus = &fourwire->inline_bus;
+ // Check for other displays that use the same spi bus and swap them too.
+ for (uint8_t j = i + 1; j < CIRCUITPY_DISPLAY_LIMIT; j++) {
+ if (displays[i].fourwire_bus.base.type == &displayio_fourwire_type &&
+ displays[i].fourwire_bus.bus == original_spi) {
+ displays[i].fourwire_bus.bus = &fourwire->inline_bus;
+ }
}
- #endif
- memcpy(&fourwire->inline_bus, original_spi, sizeof(busio_spi_obj_t));
- fourwire->bus = &fourwire->inline_bus;
- // Check for other displays that use the same spi bus and swap them too.
- for (uint8_t j = i + 1; j < CIRCUITPY_DISPLAY_LIMIT; j++) {
- if (displays[i].fourwire_bus.bus == original_spi) {
- displays[i].fourwire_bus.bus = &fourwire->inline_bus;
+ }
+ } else if (displays[i].i2cdisplay_bus.base.type == &displayio_i2cdisplay_type) {
+ displayio_i2cdisplay_obj_t* i2c = &displays[i].i2cdisplay_bus;
+ if (((uint32_t) i2c->bus) < ((uint32_t) &displays) ||
+ ((uint32_t) i2c->bus) > ((uint32_t) &displays + CIRCUITPY_DISPLAY_LIMIT)) {
+ busio_i2c_obj_t* original_i2c = i2c->bus;
+ #if BOARD_I2C
+ // We don't need to move original_i2c if it is the board.SPI object because it is
+ // statically allocated already. (Doing so would also make it impossible to reference in
+ // a subsequent VM run.)
+ if (original_i2c == common_hal_board_get_i2c()) {
+ continue;
+ }
+ #endif
+ memcpy(&i2c->inline_bus, original_i2c, sizeof(busio_i2c_obj_t));
+ i2c->bus = &i2c->inline_bus;
+ // Check for other displays that use the same i2c bus and swap them too.
+ for (uint8_t j = i + 1; j < CIRCUITPY_DISPLAY_LIMIT; j++) {
+ if (displays[i].i2cdisplay_bus.base.type == &displayio_i2cdisplay_type &&
+ displays[i].i2cdisplay_bus.bus == original_i2c) {
+ displays[i].i2cdisplay_bus.bus = &i2c->inline_bus;
+ }
+ }
}
}
- }
}
for (uint8_t i = 0; i < CIRCUITPY_DISPLAY_LIMIT; i++) {
diff --git a/shared-module/displayio/__init__.h b/shared-module/displayio/__init__.h
index 18c1a4f4a..caa5ce36d 100644
--- a/shared-module/displayio/__init__.h
+++ b/shared-module/displayio/__init__.h
@@ -30,11 +30,13 @@
#include "shared-bindings/displayio/Display.h"
#include "shared-bindings/displayio/FourWire.h"
#include "shared-bindings/displayio/Group.h"
+#include "shared-bindings/displayio/I2CDisplay.h"
#include "shared-bindings/displayio/ParallelBus.h"
typedef struct {
union {
displayio_fourwire_obj_t fourwire_bus;
+ displayio_i2cdisplay_obj_t i2cdisplay_bus;
displayio_parallelbus_obj_t parallel_bus;
};
displayio_display_obj_t display;
diff --git a/shared-module/terminalio/Terminal.c b/shared-module/terminalio/Terminal.c
index 7adf9d032..86c3e903e 100644
--- a/shared-module/terminalio/Terminal.c
+++ b/shared-module/terminalio/Terminal.c
@@ -35,6 +35,8 @@ void common_hal_terminalio_terminal_construct(terminalio_terminal_obj_t *self, d
self->font = font;
self->tilegrid = tilegrid;
self->first_row = 0;
+
+ common_hal_displayio_tilegrid_set_top_left(self->tilegrid, 0, 1);
}
size_t common_hal_terminalio_terminal_write(terminalio_terminal_obj_t *self, const byte *data, size_t len, int *errcode) {
diff --git a/shared-module/usb_hid/Device.c b/shared-module/usb_hid/Device.c
index 0e256cb5e..a5a57419c 100644
--- a/shared-module/usb_hid/Device.c
+++ b/shared-module/usb_hid/Device.c
@@ -47,15 +47,15 @@ void common_hal_usb_hid_device_send_report(usb_hid_device_obj_t *self, uint8_t*
// Wait until interface is ready, timeout = 2 seconds
uint64_t end_ticks = ticks_ms + 2000;
- while ( (ticks_ms < end_ticks) && !tud_hid_generic_ready() ) { }
+ while ( (ticks_ms < end_ticks) && !tud_hid_ready() ) { }
- if ( !tud_hid_generic_ready() ) {
+ if ( !tud_hid_ready() ) {
mp_raise_msg(&mp_type_OSError, translate("USB Busy"));
}
memcpy(self->report_buffer, report, len);
- if ( !tud_hid_generic_report(self->report_id, self->report_buffer, len) ) {
+ if ( !tud_hid_report(self->report_id, self->report_buffer, len) ) {
mp_raise_msg(&mp_type_OSError, translate("USB Error"));
}
}
@@ -70,7 +70,7 @@ static usb_hid_device_obj_t* get_hid_device(uint8_t report_id) {
}
// Callbacks invoked when receive Get_Report request through control endpoint
-uint16_t tud_hid_generic_get_report_cb(uint8_t report_id, hid_report_type_t report_type, uint8_t* buffer, uint16_t reqlen) {
+uint16_t tud_hid_get_report_cb(uint8_t report_id, hid_report_type_t report_type, uint8_t* buffer, uint16_t reqlen) {
// only support Input Report
if ( report_type != HID_REPORT_TYPE_INPUT ) return 0;
@@ -80,7 +80,7 @@ uint16_t tud_hid_generic_get_report_cb(uint8_t report_id, hid_report_type_t repo
}
// Callbacks invoked when receive Set_Report request through control endpoint
-void tud_hid_generic_set_report_cb(uint8_t report_id, hid_report_type_t report_type, uint8_t const* buffer, uint16_t bufsize) {
+void tud_hid_set_report_cb(uint8_t report_id, hid_report_type_t report_type, uint8_t const* buffer, uint16_t bufsize) {
usb_hid_device_obj_t* hid_device = get_hid_device(report_id);
if ( report_type == HID_REPORT_TYPE_OUTPUT ) {
diff --git a/shared-module/usb_midi/PortOut.c b/shared-module/usb_midi/PortOut.c
index 99a4fad43..0b37dcfd4 100644
--- a/shared-module/usb_midi/PortOut.c
+++ b/shared-module/usb_midi/PortOut.c
@@ -33,5 +33,5 @@ size_t common_hal_usb_midi_portout_write(usb_midi_portout_obj_t *self, const uin
}
bool common_hal_usb_midi_portout_ready_to_tx(usb_midi_portout_obj_t *self) {
- return tud_midi_connected();
+ return tud_midi_mounted();
}
diff --git a/supervisor/shared/display.c b/supervisor/shared/display.c
index 414f85034..6a39cbe8e 100644
--- a/supervisor/shared/display.c
+++ b/supervisor/shared/display.c
@@ -82,8 +82,7 @@ void supervisor_start_terminal(uint16_t width_px, uint16_t height_px) {
grid->pixel_height = height_in_tiles * grid->tile_height;
grid->tiles = tiles;
- supervisor_terminal.cursor_x = 0;
- supervisor_terminal.cursor_y = 0;
+ common_hal_terminalio_terminal_construct(&supervisor_terminal, grid, &supervisor_terminal_font);
}
void supervisor_stop_terminal(void) {
@@ -147,17 +146,49 @@ displayio_bitmap_t blinka_bitmap = {
.read_only = true
};
-uint32_t blinka_transparency[1] = {0x80000000};
-
-// These colors are RGB 565 with the bytes swapped.
-uint32_t blinka_colors[8] = {0x78890000, 0x9F86B8FC, 0xffff0D5A, 0x0000f501,
- 0x00000000, 0x00000000, 0x00000000, 0x00000000};
+_displayio_color_t blinka_colors[7] = {
+ {
+ .rgb888 = 0x000000,
+ .rgb565 = 0x0000,
+ .luma = 0x00,
+ .transparent = true
+ },
+ {
+ .rgb888 = 0x8428bc,
+ .rgb565 = 0x7889,
+ .luma = 0xff // We cheat the luma here. It is actually 0x60
+ },
+ {
+ .rgb888 = 0xff89bc,
+ .rgb565 = 0xB8FC,
+ .luma = 0xb5
+ },
+ {
+ .rgb888 = 0x7beffe,
+ .rgb565 = 0x9F86,
+ .luma = 0xe0
+ },
+ {
+ .rgb888 = 0x51395f,
+ .rgb565 = 0x0D5A,
+ .luma = 0x47
+ },
+ {
+ .rgb888 = 0xffffff,
+ .rgb565 = 0xffff,
+ .luma = 0xff
+ },
+ {
+ .rgb888 = 0x0736a0,
+ .rgb565 = 0xf501,
+ .luma = 0x44
+ },
+};
displayio_palette_t blinka_palette = {
.base = {.type = &displayio_palette_type },
- .opaque = blinka_transparency,
.colors = blinka_colors,
- .color_count = 16,
+ .color_count = 7,
.needs_refresh = false
};
diff --git a/supervisor/shared/rgb_led_status.c b/supervisor/shared/rgb_led_status.c
index 209eef55e..0e69cd2e0 100644
--- a/supervisor/shared/rgb_led_status.c
+++ b/supervisor/shared/rgb_led_status.c
@@ -50,10 +50,28 @@ busio_spi_obj_t status_apa102;
#endif
#endif
-#if defined(MICROPY_HW_NEOPIXEL) || (defined(MICROPY_HW_APA102_MOSI) && defined(MICROPY_HW_APA102_SCK))
+#if defined(CP_RGB_STATUS_R) || defined(CP_RGB_STATUS_G) || defined(CP_RGB_STATUS_B)
+#define CP_RGB_STATUS_LED
+
+#include "shared-bindings/pulseio/PWMOut.h"
+#include "shared-bindings/microcontroller/Pin.h"
+
+pulseio_pwmout_obj_t rgb_status_r;
+pulseio_pwmout_obj_t rgb_status_g;
+pulseio_pwmout_obj_t rgb_status_b;
+
+uint8_t rgb_status_brightness = 0xFF;
+
+uint16_t status_rgb_color[3] = {
+ 0 /* red */, 0 /* green */, 0 /* blue */
+};
+#endif
+
+#if defined(MICROPY_HW_NEOPIXEL) || (defined(MICROPY_HW_APA102_MOSI) && defined(MICROPY_HW_APA102_SCK)) || (defined(CP_RGB_STATUS_LED))
static uint32_t current_status_color = 0;
#endif
+
void rgb_led_status_init() {
#ifdef MICROPY_HW_NEOPIXEL
common_hal_digitalio_digitalinout_construct(&status_neopixel, MICROPY_HW_NEOPIXEL);
@@ -93,7 +111,34 @@ void rgb_led_status_init() {
#endif
#endif
- #if defined(MICROPY_HW_NEOPIXEL) || (defined(MICROPY_HW_APA102_MOSI) && defined(MICROPY_HW_APA102_SCK))
+
+ #if defined(CP_RGB_STATUS_LED)
+ if (common_hal_mcu_pin_is_free(CP_RGB_STATUS_R)) {
+ pwmout_result_t red_result = common_hal_pulseio_pwmout_construct(&rgb_status_r, CP_RGB_STATUS_R, 0, 50000, false);
+
+ if (PWMOUT_OK == red_result) {
+ common_hal_pulseio_pwmout_never_reset(&rgb_status_r);
+ }
+ }
+
+ if (common_hal_mcu_pin_is_free(CP_RGB_STATUS_G)) {
+ pwmout_result_t green_result = common_hal_pulseio_pwmout_construct(&rgb_status_g, CP_RGB_STATUS_G, 0, 50000, false);
+
+ if (PWMOUT_OK == green_result) {
+ common_hal_pulseio_pwmout_never_reset(&rgb_status_g);
+ }
+ }
+
+ if (common_hal_mcu_pin_is_free(CP_RGB_STATUS_B)) {
+ pwmout_result_t blue_result = common_hal_pulseio_pwmout_construct(&rgb_status_b, CP_RGB_STATUS_B, 0, 50000, false);
+
+ if (PWMOUT_OK == blue_result) {
+ common_hal_pulseio_pwmout_never_reset(&rgb_status_b);
+ }
+ }
+ #endif
+
+ #if defined(MICROPY_HW_NEOPIXEL) || (defined(MICROPY_HW_APA102_MOSI) && defined(MICROPY_HW_APA102_SCK)) || (defined(CP_RGB_STATUS_LED))
// Force a write of the current status color.
uint32_t rgb = current_status_color;
current_status_color = 0x1000000; // Not a valid color
@@ -109,10 +154,13 @@ void reset_status_led() {
reset_pin_number(MICROPY_HW_APA102_MOSI->number);
reset_pin_number(MICROPY_HW_APA102_SCK->number);
#endif
+ #if defined(CP_RGB_STATUS_LED)
+ // TODO: Support sharing status LED with user.
+ #endif
}
void new_status_color(uint32_t rgb) {
- #if defined(MICROPY_HW_NEOPIXEL) || (defined(MICROPY_HW_APA102_MOSI) && defined(MICROPY_HW_APA102_SCK))
+ #if defined(MICROPY_HW_NEOPIXEL) || (defined(MICROPY_HW_APA102_MOSI) && defined(MICROPY_HW_APA102_SCK)) || (defined(CP_RGB_STATUS_LED))
if (current_status_color == rgb) {
return;
}
@@ -143,10 +191,30 @@ void new_status_color(uint32_t rgb) {
common_hal_busio_spi_write(&status_apa102, status_apa102_color, 8);
#endif
#endif
+
+ #if defined(CP_RGB_STATUS_LED)
+ uint8_t red_u8 = (rgb_adjusted >> 16) & 0xFF;
+ uint8_t green_u8 = (rgb_adjusted >> 8) & 0xFF;
+ uint8_t blue_u8 = rgb_adjusted & 0xFF;
+
+ #if defined(CP_RGB_STATUS_INVERTED_PWM)
+ status_rgb_color[0] = (1 << 16) - 1 - ((uint16_t) (red_u8 << 8) + red_u8);
+ status_rgb_color[1] = (1 << 16) - 1 - ((uint16_t) (green_u8 << 8) + green_u8);
+ status_rgb_color[2] = (1 << 16) - 1 - ((uint16_t) (blue_u8 << 8) + blue_u8);
+ #else
+ status_rgb_color[0] = (uint16_t) (red_u8 << 8) + red_u8;
+ status_rgb_color[1] = (uint16_t) (green_u8 << 8) + green_u8;
+ status_rgb_color[2] = (uint16_t) (blue_u8 << 8) + blue_u8;
+ #endif
+
+ common_hal_pulseio_pwmout_set_duty_cycle(&rgb_status_r, status_rgb_color[0]);
+ common_hal_pulseio_pwmout_set_duty_cycle(&rgb_status_g, status_rgb_color[1]);
+ common_hal_pulseio_pwmout_set_duty_cycle(&rgb_status_b, status_rgb_color[2]);
+ #endif
}
void temp_status_color(uint32_t rgb) {
- #if defined(MICROPY_HW_NEOPIXEL) || (defined(MICROPY_HW_APA102_MOSI) && defined(MICROPY_HW_APA102_SCK))
+ #if defined(MICROPY_HW_NEOPIXEL) || (defined(MICROPY_HW_APA102_MOSI) && defined(MICROPY_HW_APA102_SCK)) || (defined(CP_RGB_STATUS_LED))
uint32_t rgb_adjusted = rgb;
rgb_adjusted = color_brightness(rgb, rgb_status_brightness);
#endif
@@ -168,6 +236,27 @@ void temp_status_color(uint32_t rgb) {
common_hal_busio_spi_write(&status_apa102, colors, 12);
#endif
#endif
+ #if defined(CP_RGB_STATUS_LED)
+ uint8_t red_u8 = (rgb_adjusted >> 16) & 0xFF;
+ uint8_t green_u8 = (rgb_adjusted >> 8) & 0xFF;
+ uint8_t blue_u8 = rgb_adjusted & 0xFF;
+
+ uint16_t temp_status_color_rgb[3] = {0};
+
+ #if defined(CP_RGB_STATUS_INVERTED_PWM)
+ temp_status_color_rgb[0] = (1 << 16) - 1 - ((uint16_t) (red_u8 << 8) + red_u8);
+ temp_status_color_rgb[1] = (1 << 16) - 1 - ((uint16_t) (green_u8 << 8) + green_u8);
+ temp_status_color_rgb[2] = (1 << 16) - 1 - ((uint16_t) (blue_u8 << 8) + blue_u8);
+ #else
+ temp_status_color_rgb[0] = (uint16_t) (red_u8 << 8) + red_u8;
+ temp_status_color_rgb[1] = (uint16_t) (green_u8 << 8) + green_u8;
+ temp_status_color_rgb[2] = (uint16_t) (blue_u8 << 8) + blue_u8;
+ #endif
+
+ common_hal_pulseio_pwmout_set_duty_cycle(&rgb_status_r, temp_status_color_rgb[0]);
+ common_hal_pulseio_pwmout_set_duty_cycle(&rgb_status_g, temp_status_color_rgb[1]);
+ common_hal_pulseio_pwmout_set_duty_cycle(&rgb_status_b, temp_status_color_rgb[2]);
+ #endif
}
void clear_temp_status() {
@@ -181,10 +270,30 @@ void clear_temp_status() {
common_hal_busio_spi_write(&status_apa102, status_apa102_color, 8);
#endif
#endif
+ #if defined(CP_RGB_STATUS_LED)
+
+ uint16_t red = 0;
+ uint16_t green = 0;
+ uint16_t blue = 0;
+
+ #if defined(CP_RGB_STATUS_INVERTED_PWM)
+ red = (1 << 16) - 1 - status_rgb_color[0];
+ green = (1 << 16) - 1 - status_rgb_color[1];
+ blue = (1 << 16) - 1 - status_rgb_color[2];
+ #else
+ red = status_rgb_color[0];
+ green = status_rgb_color[1];
+ blue = status_rgb_color[2];
+ #endif
+
+ common_hal_pulseio_pwmout_set_duty_cycle(&rgb_status_r, red);
+ common_hal_pulseio_pwmout_set_duty_cycle(&rgb_status_g, green);
+ common_hal_pulseio_pwmout_set_duty_cycle(&rgb_status_b, blue);
+ #endif
}
uint32_t color_brightness(uint32_t color, uint8_t brightness) {
- #if defined(MICROPY_HW_NEOPIXEL) || (defined(MICROPY_HW_APA102_MOSI) && defined(MICROPY_HW_APA102_SCK))
+ #if defined(MICROPY_HW_NEOPIXEL) || (defined(MICROPY_HW_APA102_MOSI) && defined(MICROPY_HW_APA102_SCK)) || (defined(CP_RGB_STATUS_LED))
uint32_t result = ((color & 0xff0000) * brightness / 255) & 0xff0000;
result += ((color & 0xff00) * brightness / 255) & 0xff00;
result += ((color & 0xff) * brightness / 255) & 0xff;
@@ -195,7 +304,7 @@ uint32_t color_brightness(uint32_t color, uint8_t brightness) {
}
void set_rgb_status_brightness(uint8_t level){
- #if defined(MICROPY_HW_NEOPIXEL) || (defined(MICROPY_HW_APA102_MOSI) && defined(MICROPY_HW_APA102_SCK))
+ #if defined(MICROPY_HW_NEOPIXEL) || (defined(MICROPY_HW_APA102_MOSI) && defined(MICROPY_HW_APA102_SCK)) || (defined(CP_RGB_STATUS_LED))
rgb_status_brightness = level;
uint32_t current_color = current_status_color;
// Temporarily change the current color global to force the new_status_color call to update the
@@ -210,7 +319,7 @@ void prep_rgb_status_animation(const pyexec_result_t* result,
bool found_main,
safe_mode_t safe_mode,
rgb_status_animation_t* status) {
- #if defined(MICROPY_HW_NEOPIXEL) || (defined(MICROPY_HW_APA102_MOSI) && defined(MICROPY_HW_APA102_SCK))
+ #if defined(MICROPY_HW_NEOPIXEL) || (defined(MICROPY_HW_APA102_MOSI) && defined(MICROPY_HW_APA102_SCK)) || (defined(CP_RGB_STATUS_LED))
new_status_color(ALL_DONE);
status->pattern_start = ticks_ms;
status->safe_mode = safe_mode;
@@ -256,7 +365,7 @@ void prep_rgb_status_animation(const pyexec_result_t* result,
}
void tick_rgb_status_animation(rgb_status_animation_t* status) {
- #if defined(MICROPY_HW_NEOPIXEL) || (defined(MICROPY_HW_APA102_MOSI) && defined(MICROPY_HW_APA102_SCK))
+ #if defined(MICROPY_HW_NEOPIXEL) || (defined(MICROPY_HW_APA102_MOSI) && defined(MICROPY_HW_APA102_SCK)) || (defined(CP_RGB_STATUS_LED))
uint32_t tick_diff = ticks_ms - status->pattern_start;
if (status->ok) {
// All is good. Ramp ALL_DONE up and down.
diff --git a/supervisor/shared/status_leds.c b/supervisor/shared/status_leds.c
index d99853ceb..672242a96 100644
--- a/supervisor/shared/status_leds.c
+++ b/supervisor/shared/status_leds.c
@@ -26,8 +26,10 @@
#include "supervisor/shared/status_leds.h"
+#if CIRCUITPY_DIGITALIO
#include "common-hal/digitalio/DigitalInOut.h"
#include "shared-bindings/digitalio/DigitalInOut.h"
+#endif
#ifdef MICROPY_HW_LED_RX
digitalio_digitalinout_obj_t rx_led;
diff --git a/supervisor/shared/usb/tusb_config.h b/supervisor/shared/usb/tusb_config.h
index 301805275..ad5825b6c 100644
--- a/supervisor/shared/usb/tusb_config.h
+++ b/supervisor/shared/usb/tusb_config.h
@@ -107,7 +107,7 @@
// USB RAM PLACEMENT
//--------------------------------------------------------------------+
#define CFG_TUSB_ATTR_USBRAM
-#define CFG_TUSB_MEM_ALIGN ATTR_ALIGNED(4)
+#define CFG_TUSB_MEM_ALIGN __attribute__ ((aligned(4)))
#ifdef __cplusplus
diff --git a/supervisor/shared/usb/usb_desc.c b/supervisor/shared/usb/usb_desc.c
index 5a0de1ffc..9b333d6fe 100644
--- a/supervisor/shared/usb/usb_desc.c
+++ b/supervisor/shared/usb/usb_desc.c
@@ -24,23 +24,35 @@
* THE SOFTWARE.
*/
-#include "supervisor/shared/usb/usb_desc.h"
+#include "lib/tinyusb/src/tusb.h"
#include "shared-module/usb_hid/Device.h"
#include "genhdr/autogen_usb_descriptor.h"
-// tud_desc_set is required by tinyusb stack
-tud_desc_set_t tud_desc_set =
-{
- .device = &usb_desc_dev,
- .config = &usb_desc_cfg,
- .string_arr = (uint8_t const **) string_desc_arr,
- .string_count = sizeof(string_desc_arr)/sizeof(string_desc_arr[0]),
+// Invoked when received GET DEVICE DESCRIPTOR
+// Application return pointer to descriptor
+uint8_t const * tud_descriptor_device_cb(void) {
+ return usb_desc_dev;
+}
- .hid_report =
- {
- .generic = hid_report_descriptor,
- .boot_keyboard = NULL,
- .boot_mouse = NULL
- }
-};
+// Invoked when received GET CONFIGURATION DESCRIPTOR
+// Application return pointer to descriptor
+// Descriptor contents must exist long enough for transfer to complete
+uint8_t const * tud_descriptor_configuration_cb(uint8_t index) {
+ (void) index; // for multiple configurations
+ return usb_desc_cfg;
+}
+
+// Invoked when received GET HID REPORT DESCRIPTOR
+// Application return pointer to descriptor
+// Descriptor contents must exist long enough for transfer to complete
+uint8_t const * tud_hid_descriptor_report_cb(void) {
+ return hid_report_descriptor;
+}
+
+// Invoked when received GET STRING DESCRIPTOR request
+// Application return pointer to descriptor, whose contents must exist long enough for transfer to complete
+uint16_t const* tud_descriptor_string_cb(uint8_t index) {
+ uint8_t const max_index = sizeof(string_desc_arr)/sizeof(string_desc_arr[0]);
+ return (index < max_index) ? string_desc_arr[index] : NULL;
+}
diff --git a/supervisor/shared/usb/usb_msc_flash.c b/supervisor/shared/usb/usb_msc_flash.c
index f6f0fa9c3..205cb7b50 100644
--- a/supervisor/shared/usb/usb_msc_flash.c
+++ b/supervisor/shared/usb/usb_msc_flash.c
@@ -59,59 +59,18 @@ static fs_user_mount_t* get_vfs(int lun) {
}
// Callback invoked when received an SCSI command not in built-in list below
-// - READ_CAPACITY10, READ_FORMAT_CAPACITY, INQUIRY, MODE_SENSE6, REQUEST_SENSE
+// - READ_CAPACITY10, READ_FORMAT_CAPACITY, INQUIRY, TEST_UNIT_READY, START_STOP_UNIT, MODE_SENSE6, REQUEST_SENSE
// - READ10 and WRITE10 have their own callbacks
int32_t tud_msc_scsi_cb (uint8_t lun, const uint8_t scsi_cmd[16], void* buffer, uint16_t bufsize) {
const void* response = NULL;
int32_t resplen = 0;
switch ( scsi_cmd[0] ) {
- case SCSI_CMD_TEST_UNIT_READY:
- // Command that host uses to check our readiness before sending other commands
- resplen = 0;
- if (lun > 1) {
- resplen = -1;
- } else {
- fs_user_mount_t* current_mount = get_vfs(lun);
- if (current_mount == NULL) {
- resplen = -1;
- }
- if (ejected[lun]) {
- resplen = -1;
- }
- }
- break;
-
case SCSI_CMD_PREVENT_ALLOW_MEDIUM_REMOVAL:
// Host is about to read/write etc ... better not to disconnect disk
resplen = 0;
break;
- case SCSI_CMD_START_STOP_UNIT:
- {
- // Host try to eject/safe remove/poweroff us. We could safely disconnect with disk storage, or go into lower power
- const scsi_start_stop_unit_t* start_stop = (const scsi_start_stop_unit_t*) scsi_cmd;
- // Start bit = 0 : low power mode, if load_eject = 1 : unmount disk storage as well
- // Start bit = 1 : Ready mode, if load_eject = 1 : mount disk storage
- resplen = 0;
- if (start_stop->load_eject == 1) {
- if (lun > 1) {
- resplen = -1;
- } else {
- fs_user_mount_t* current_mount = get_vfs(lun);
- if (current_mount == NULL) {
- resplen = -1;
- }
- if (disk_ioctl(current_mount, CTRL_SYNC, NULL) != RES_OK) {
- resplen = -1;
- } else {
- ejected[lun] = true;
- }
- }
- }
- }
- break;
-
default:
// Set Sense = Invalid Command Operation
tud_msc_set_sense(lun, SCSI_SENSE_ILLEGAL_REQUEST, 0x20, 0x00);
@@ -127,7 +86,7 @@ int32_t tud_msc_scsi_cb (uint8_t lun, const uint8_t scsi_cmd[16], void* buffer,
}
// copy response to stack's buffer if any
- if ( response && resplen ) {
+ if ( response && (resplen > 0) ) {
memcpy(buffer, response, resplen);
}
@@ -206,3 +165,54 @@ void tud_msc_write10_complete_cb (uint8_t lun) {
// This write is complete, start the autoreload clock.
autoreload_start();
}
+
+// Invoked when received SCSI_CMD_INQUIRY
+// Application fill vendor id, product id and revision with string up to 8, 16, 4 characters respectively
+void tud_msc_inquiry_cb(uint8_t lun, uint8_t vendor_id[8], uint8_t product_id[16], uint8_t product_rev[4]) {
+ (void) lun;
+
+ memcpy(vendor_id , CFG_TUD_MSC_VENDOR , strlen(CFG_TUD_MSC_VENDOR));
+ memcpy(product_id , CFG_TUD_MSC_PRODUCT , strlen(CFG_TUD_MSC_PRODUCT));
+ memcpy(product_rev, CFG_TUD_MSC_PRODUCT_REV, strlen(CFG_TUD_MSC_PRODUCT_REV));
+}
+
+// Invoked when received Test Unit Ready command.
+// return true allowing host to read/write this LUN e.g SD card inserted
+bool tud_msc_test_unit_ready_cb(uint8_t lun) {
+ if (lun > 1) {
+ return false;
+ }
+
+ fs_user_mount_t* current_mount = get_vfs(lun);
+ if (current_mount == NULL) {
+ return false;
+ }
+ if (ejected[lun]) {
+ return false;
+ }
+
+ return true;
+}
+
+// Invoked when received Start Stop Unit command
+// - Start = 0 : stopped power mode, if load_eject = 1 : unload disk storage
+// - Start = 1 : active mode, if load_eject = 1 : load disk storage
+bool tud_msc_start_stop_cb(uint8_t lun, uint8_t power_condition, bool start, bool load_eject) {
+ if (load_eject) {
+ if (lun > 1) {
+ return false;
+ } else {
+ fs_user_mount_t* current_mount = get_vfs(lun);
+ if (current_mount == NULL) {
+ return false;
+ }
+ if (disk_ioctl(current_mount, CTRL_SYNC, NULL) != RES_OK) {
+ return false;
+ } else {
+ ejected[lun] = true;
+ }
+ }
+ }
+
+ return true;
+}
diff --git a/tools/build_board_info.py b/tools/build_board_info.py
index 307d90d7a..8731a6feb 100644
--- a/tools/build_board_info.py
+++ b/tools/build_board_info.py
@@ -39,7 +39,8 @@ extension_by_board = {
"makerdiary_nrf52840_mdk": HEX,
"makerdiary_nrf52840_mdk_usb_dongle": HEX,
"pca10056": BIN_UF2,
- "pca10059": BIN_UF2
+ "pca10059": BIN_UF2,
+ "electronut_labs_blip": HEX
}
aliases_by_board = {
diff --git a/tools/gen_display_resources.py b/tools/gen_display_resources.py
index 7b28c3105..a731cbd9c 100644
--- a/tools/gen_display_resources.py
+++ b/tools/gen_display_resources.py
@@ -29,7 +29,6 @@ class BitmapStub:
self.rows[y] = bytes(row)
f = bitmap_font.load_font(args.font, BitmapStub)
-real_bb = [0, 0]
# Load extra characters from the sample file.
sample_characters = set()
@@ -61,13 +60,11 @@ for c in all_characters:
print("Font missing character:", c, ord(c))
filtered_characters = filtered_characters.replace(c, "")
continue
- x, y, dx, dy = g["bounds"]
if g["shift"][1] != 0:
raise RuntimeError("y shift")
- real_bb[0] = max(real_bb[0], x - dx)
- real_bb[1] = max(real_bb[1], y - dy)
-tile_x, tile_y = real_bb
+x, y, dx, dy = f.get_bounding_box()
+tile_x, tile_y = x - dx, y - dy
total_bits = tile_x * len(all_characters)
total_bits += 32 - total_bits % 32
bytes_per_row = total_bits // 8
@@ -101,14 +98,21 @@ c_file.write("""\
""")
c_file.write("""\
-uint32_t terminal_transparency[1] = {0x00000000};
-
-// These colors are RGB 565 with the bytes swapped.
-uint32_t terminal_colors[1] = {0xffff0000};
+_displayio_color_t terminal_colors[2] = {
+ {
+ .rgb888 = 0x000000,
+ .rgb565 = 0x0000,
+ .luma = 0x00
+ },
+ {
+ .rgb888 = 0xffffff,
+ .rgb565 = 0xffff,
+ .luma = 0xff
+ },
+};
displayio_palette_t supervisor_terminal_color = {
.base = {.type = &displayio_palette_type },
- .opaque = terminal_transparency,
.colors = terminal_colors,
.color_count = 2,
.needs_refresh = false