merge translations; add bleio comments; fix minor sphinx issues in midi
This commit is contained in:
commit
50ee5ef24c
@ -25,7 +25,7 @@ env:
|
||||
- TRAVIS_BOARDS="metro_m0_express metro_m4_express pirkey_m0 trellis_m4_express trinket_m0" TRAVIS_SDK=arm
|
||||
- TRAVIS_BOARDS="feather_radiofruit_zigbee gemma_m0 hallowing_m0_express itsybitsy_m0_express itsybitsy_m4_express meowmeow" TRAVIS_SDK=arm
|
||||
- TRAVIS_BOARDS="feather_m0_express_crickit feather_m0_rfm69 feather_m0_rfm9x feather_m4_express arduino_zero arduino_mkr1300 arduino_mkrzero" TRAVIS_SDK=arm
|
||||
- TRAVIS_BOARDS="circuitplayground_express_crickit feather_m0_adalogger feather_m0_basic feather_m0_express catwan_usbstick pyportal" TRAVIS_SDK=arm
|
||||
- TRAVIS_BOARDS="circuitplayground_express_crickit feather_m0_adalogger feather_m0_basic feather_m0_express catwan_usbstick pyportal sparkfun_samd21_mini" TRAVIS_SDK=arm
|
||||
|
||||
addons:
|
||||
artifacts:
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 3bb53273cd3770328f55ba317af3df0cce4333c1
|
||||
Subproject commit 5804e56e3c2ab4480bf72d94d997f769a645af47
|
2587
locale/ID.po
Normal file
2587
locale/ID.po
Normal file
File diff suppressed because it is too large
Load Diff
@ -2694,12 +2694,23 @@ msgstr ""
|
||||
#~ msgid "Can not apply advertisement data. status: 0x%02x"
|
||||
#~ msgstr "Kann advertisement data nicht anwenden. Status: 0x%02x"
|
||||
|
||||
#~ msgid ""
|
||||
#~ "Please file an issue here with the contents of your CIRCUITPY drive:\n"
|
||||
#~ msgstr ""
|
||||
#~ "Bitte erstelle ein issue hier mit dem Inhalt deines CIRCUITPY-speichers:\n"
|
||||
|
||||
#~ msgid "Can not encode UUID, to check length."
|
||||
#~ msgstr "Kann UUID nicht kodieren, um die Länge zu überprüfen."
|
||||
|
||||
#~ msgid "Can not add Characteristic."
|
||||
#~ msgstr "Kann das Merkmal nicht hinzufügen."
|
||||
|
||||
#~ msgid "Looks like our core CircuitPython code crashed hard. Whoops!\n"
|
||||
#~ msgstr "CircuitPython ist abgestürzt. Ups!\n"
|
||||
|
||||
#~ msgid "Cannot apply GAP parameters."
|
||||
#~ msgstr "Kann GAP Parameter nicht anwenden."
|
||||
|
||||
#~ msgid "Can not apply device name in the stack."
|
||||
#~ msgstr "Der Gerätename kann nicht im Stack verwendet werden."
|
||||
|
||||
#~ msgid ""
|
||||
#~ "enough power for the whole circuit and press reset (after ejecting "
|
||||
#~ "CIRCUITPY).\n"
|
||||
@ -2707,22 +2718,14 @@ msgstr ""
|
||||
#~ "genug Strom für den ganzen Schaltkreis liefert und drücke reset (nach dem "
|
||||
#~ "sicheren Auswerfen von CIRCUITPY.)\n"
|
||||
|
||||
#~ msgid "Can not query for the device address."
|
||||
#~ msgstr "Kann nicht nach der Geräteadresse suchen."
|
||||
|
||||
#~ msgid "Can not encode UUID, to check length."
|
||||
#~ msgstr "Kann UUID nicht kodieren, um die Länge zu überprüfen."
|
||||
|
||||
#~ msgid "Can encode UUID into the advertisement packet."
|
||||
#~ msgstr "Kann UUID in das advertisement packet kodieren."
|
||||
|
||||
#~ msgid "Can not query for the device address."
|
||||
#~ msgstr "Kann nicht nach der Geräteadresse suchen."
|
||||
|
||||
#~ msgid "Can not add Service."
|
||||
#~ msgstr "Kann den Dienst nicht hinzufügen."
|
||||
|
||||
#~ msgid ""
|
||||
#~ "Please file an issue here with the contents of your CIRCUITPY drive:\n"
|
||||
#~ msgstr ""
|
||||
#~ "Bitte erstelle ein issue hier mit dem Inhalt deines CIRCUITPY-speichers:\n"
|
||||
|
||||
#~ msgid "Looks like our core CircuitPython code crashed hard. Whoops!\n"
|
||||
#~ msgstr "CircuitPython ist abgestürzt. Ups!\n"
|
||||
#~ msgid "Can not apply device name in the stack."
|
||||
#~ msgstr "Der Gerätename kann nicht im Stack verwendet werden."
|
||||
|
35
locale/es.po
35
locale/es.po
@ -2710,15 +2710,33 @@ msgstr ""
|
||||
#~ msgid "Wrong number of bytes provided"
|
||||
#~ msgstr "Numero erroneo de bytes dados"
|
||||
|
||||
|
||||
#~ msgid "Cannot apply GAP parameters."
|
||||
#~ msgstr "No se pueden aplicar los parámetros GAP."
|
||||
|
||||
#~ msgid "Can not apply device name in the stack."
|
||||
#~ msgstr "No se puede aplicar el nombre del dispositivo en el stack."
|
||||
|
||||
#~ msgid "Looks like our core CircuitPython code crashed hard. Whoops!\n"
|
||||
#~ msgstr ""
|
||||
#~ "Parece que nuestro código CircuitPython dejó de funcionar. Whoops!\n"
|
||||
|
||||
#~ msgid "Baud rate too high for this SPI peripheral"
|
||||
#~ msgstr "Baud rate demasiado alto para este periférico SPI"
|
||||
|
||||
#~ msgid "Can not encode UUID, to check length."
|
||||
#~ msgstr "No se puede codificar el UUID, para revisar la longitud."
|
||||
|
||||
#~ msgid "Can not query for the device address."
|
||||
#~ msgstr "No se puede consultar la dirección del dispositivo."
|
||||
|
||||
#, fuzzy
|
||||
#~ msgid ""
|
||||
#~ "Please file an issue here with the contents of your CIRCUITPY drive:\n"
|
||||
#~ msgstr ""
|
||||
#~ "Por favor registra un issue en la siguiente URL con el contenidos de tu "
|
||||
#~ "unidad de almacenamiento CIRCUITPY:\n"
|
||||
|
||||
#~ msgid "Can encode UUID into the advertisement packet."
|
||||
#~ msgstr "Se puede codificar el UUID en el paquete de anuncio."
|
||||
|
||||
@ -2728,12 +2746,6 @@ msgstr ""
|
||||
#~ msgid "Can not add Service."
|
||||
#~ msgstr "No se puede agregar el Servicio."
|
||||
|
||||
#~ msgid "Can not query for the device address."
|
||||
#~ msgstr "No se puede consultar la dirección del dispositivo."
|
||||
|
||||
#~ msgid "Baud rate too high for this SPI peripheral"
|
||||
#~ msgstr "Baud rate demasiado alto para este periférico SPI"
|
||||
|
||||
#~ msgid "Can not apply advertisement data. status: 0x%02x"
|
||||
#~ msgstr "No se puede aplicar los datos de anuncio. status: 0x%02x"
|
||||
|
||||
@ -2746,14 +2758,3 @@ msgstr ""
|
||||
#~ msgstr ""
|
||||
#~ "suficiente poder para todo el circuito y presiona reset (después de "
|
||||
#~ "expulsar CIRCUITPY).\n"
|
||||
|
||||
#~ msgid "Looks like our core CircuitPython code crashed hard. Whoops!\n"
|
||||
#~ msgstr ""
|
||||
#~ "Parece que nuestro código CircuitPython dejó de funcionar. Whoops!\n"
|
||||
|
||||
#, fuzzy
|
||||
#~ msgid ""
|
||||
#~ "Please file an issue here with the contents of your CIRCUITPY drive:\n"
|
||||
#~ msgstr ""
|
||||
#~ "Por favor registra un issue en la siguiente URL con el contenidos de tu "
|
||||
#~ "unidad de almacenamiento CIRCUITPY:\n"
|
||||
|
@ -2727,15 +2727,33 @@ msgstr ""
|
||||
#~ msgid "Wrong number of bytes provided"
|
||||
#~ msgstr "Mali ang bilang ng bytes"
|
||||
|
||||
|
||||
#~ msgid "Cannot apply GAP parameters."
|
||||
#~ msgstr "Hindi ma-apply ang GAP parameters."
|
||||
|
||||
#~ msgid "Can not apply device name in the stack."
|
||||
#~ msgstr "Hindi maaaring ma-aplay ang device name sa stack."
|
||||
|
||||
#~ msgid "Looks like our core CircuitPython code crashed hard. Whoops!\n"
|
||||
#~ msgstr ""
|
||||
#~ "Mukhang ang core CircuitPython code ay nag-crash ng malakas. Aray!\n"
|
||||
|
||||
#, fuzzy
|
||||
#~ msgid "palette must be displayio.Palette"
|
||||
#~ msgstr "ang palette ay dapat 32 bytes ang haba"
|
||||
|
||||
#~ msgid "Can not encode UUID, to check length."
|
||||
#~ msgstr "Hindi ma-encode UUID, para suriin ang haba."
|
||||
|
||||
#~ msgid "Can not query for the device address."
|
||||
#~ msgstr "Hindi maaaring mag-query para sa address ng device."
|
||||
|
||||
#~ msgid ""
|
||||
#~ "Please file an issue here with the contents of your CIRCUITPY drive:\n"
|
||||
#~ msgstr ""
|
||||
#~ "Mag-file ng isang isyu dito gamit ang mga nilalaman ng iyong CIRCUITPY "
|
||||
#~ "drive:\n"
|
||||
|
||||
#~ msgid "Can encode UUID into the advertisement packet."
|
||||
#~ msgstr "Maaring i-encode ang UUID sa advertisement packet."
|
||||
|
||||
@ -2745,13 +2763,6 @@ msgstr ""
|
||||
#~ msgid "Can not add Service."
|
||||
#~ msgstr "Hindi maidaragdag ang serbisyo."
|
||||
|
||||
#~ msgid "Can not query for the device address."
|
||||
#~ msgstr "Hindi maaaring mag-query para sa address ng device."
|
||||
|
||||
#, fuzzy
|
||||
#~ msgid "palette must be displayio.Palette"
|
||||
#~ msgstr "ang palette ay dapat 32 bytes ang haba"
|
||||
|
||||
#~ msgid "Can not apply advertisement data. status: 0x%02x"
|
||||
#~ msgstr "Hindi ma i-apply ang advertisement data. status: 0x%02x"
|
||||
|
||||
@ -2764,13 +2775,3 @@ msgstr ""
|
||||
#~ msgstr ""
|
||||
#~ "ay nagbibigay ng sapat na power para sa buong circuit at i-press ang "
|
||||
#~ "reset (pagkatapos i-eject ang CIRCUITPY).\n"
|
||||
|
||||
#~ msgid "Looks like our core CircuitPython code crashed hard. Whoops!\n"
|
||||
#~ msgstr ""
|
||||
#~ "Mukhang ang core CircuitPython code ay nag-crash ng malakas. Aray!\n"
|
||||
|
||||
#~ msgid ""
|
||||
#~ "Please file an issue here with the contents of your CIRCUITPY drive:\n"
|
||||
#~ msgstr ""
|
||||
#~ "Mag-file ng isang isyu dito gamit ang mga nilalaman ng iyong CIRCUITPY "
|
||||
#~ "drive:\n"
|
||||
|
41
locale/fr.po
41
locale/fr.po
@ -2766,17 +2766,12 @@ msgstr ""
|
||||
#~ msgstr ""
|
||||
#~ "SVP, remontez le problème là avec le contenu du lecteur CIRCUITPY:\n"
|
||||
|
||||
#~ msgid "Can not add Service."
|
||||
#~ msgstr "Impossible d'ajouter le Service"
|
||||
#, fuzzy
|
||||
#~ msgid "value_size must be power of two"
|
||||
#~ msgstr "value_size doit être une puissance de 2"
|
||||
|
||||
#~ msgid "Invalid Service type"
|
||||
#~ msgstr "Type de service invalide"
|
||||
|
||||
#~ msgid "Can not encode UUID, to check length."
|
||||
#~ msgstr "Impossible d'encoder l'UUID pour vérifier la longueur."
|
||||
|
||||
#~ msgid "Can not query for the device address."
|
||||
#~ msgstr "Impossible d'obtenir l'adresse du périphérique"
|
||||
#~ msgid "Cannot set PPCP parameters."
|
||||
#~ msgstr "Impossible d'appliquer les paramètres PPCP"
|
||||
|
||||
#~ msgid ""
|
||||
#~ "enough power for the whole circuit and press reset (after ejecting "
|
||||
@ -2785,19 +2780,27 @@ msgstr ""
|
||||
#~ "assez de puissance pour l'ensemble du circuit et appuyez sur "
|
||||
#~ "'reset' (après avoir éjecter CIRCUITPY).\n"
|
||||
|
||||
#~ msgid "Cannot set PPCP parameters."
|
||||
#~ msgstr "Impossible d'appliquer les paramètres PPCP"
|
||||
#, fuzzy
|
||||
#~ msgid "palette must be displayio.Palette"
|
||||
#~ msgstr "la palette doit être une displayio.Palette"
|
||||
|
||||
#~ msgid "Can not encode UUID, to check length."
|
||||
#~ msgstr "Impossible d'encoder l'UUID pour vérifier la longueur."
|
||||
|
||||
#~ msgid "Can not add Service."
|
||||
#~ msgstr "Impossible d'ajouter le Service"
|
||||
|
||||
#~ msgid "Can not add Characteristic."
|
||||
#~ msgstr "Impossible d'ajouter la Characteristic."
|
||||
|
||||
#~ msgid "Can not apply device name in the stack."
|
||||
#~ msgstr "Impossible d'appliquer le nom de périphérique dans la pile"
|
||||
|
||||
#~ msgid "Can not query for the device address."
|
||||
#~ msgstr "Impossible d'obtenir l'adresse du périphérique"
|
||||
|
||||
#~ msgid "Cannot apply GAP parameters."
|
||||
#~ msgstr "Impossible d'appliquer les paramètres GAP"
|
||||
|
||||
#, fuzzy
|
||||
#~ msgid "value_size must be power of two"
|
||||
#~ msgstr "value_size doit être une puissance de 2"
|
||||
|
||||
#, fuzzy
|
||||
#~ msgid "palette must be displayio.Palette"
|
||||
#~ msgstr "la palette doit être une displayio.Palette"
|
||||
#~ msgid "Invalid Service type"
|
||||
#~ msgstr "Type de service invalide"
|
||||
|
@ -2729,15 +2729,29 @@ msgstr ""
|
||||
#~ msgid "Can not apply advertisement data. status: 0x%02x"
|
||||
#~ msgstr "Impossible inserire dati advertisement. status: 0x%02x"
|
||||
|
||||
#~ msgid "Cannot apply GAP parameters."
|
||||
#~ msgstr "Impossibile applicare i parametri GAP."
|
||||
#~ msgid ""
|
||||
#~ "Please file an issue here with the contents of your CIRCUITPY drive:\n"
|
||||
#~ msgstr ""
|
||||
#~ "Ti preghiamo di compilare una issue con il contenuto del tuo drie "
|
||||
#~ "CIRCUITPY:\n"
|
||||
|
||||
#~ msgid "Can not apply device name in the stack."
|
||||
#~ msgstr "Non è possibile inserire il nome del dipositivo nella lista."
|
||||
#~ msgid "Can not encode UUID, to check length."
|
||||
#~ msgstr "Non è possibile codificare l'UUID, lunghezza da controllare."
|
||||
|
||||
#~ msgid "Can not add Characteristic."
|
||||
#~ msgstr "Non è possibile aggiungere Characteristic."
|
||||
|
||||
#~ msgid "Looks like our core CircuitPython code crashed hard. Whoops!\n"
|
||||
#~ msgstr ""
|
||||
#~ "Sembra che il codice del core di CircuitPython sia crashato malamente. "
|
||||
#~ "Whoops!\n"
|
||||
|
||||
#~ msgid "Cannot set PPCP parameters."
|
||||
#~ msgstr "Impossibile impostare i parametri PPCP."
|
||||
|
||||
#~ msgid "Cannot apply GAP parameters."
|
||||
#~ msgstr "Impossibile applicare i parametri GAP."
|
||||
|
||||
#~ msgid ""
|
||||
#~ "enough power for the whole circuit and press reset (after ejecting "
|
||||
#~ "CIRCUITPY).\n"
|
||||
@ -2745,25 +2759,14 @@ msgstr ""
|
||||
#~ "abbastanza potenza per l'intero circuito e premere reset (dopo aver "
|
||||
#~ "espulso CIRCUITPY).\n"
|
||||
|
||||
#~ msgid "Can not query for the device address."
|
||||
#~ msgstr "Non è possibile trovare l'indirizzo del dispositivo."
|
||||
|
||||
#~ msgid "Can not encode UUID, to check length."
|
||||
#~ msgstr "Non è possibile codificare l'UUID, lunghezza da controllare."
|
||||
|
||||
#~ msgid "Can encode UUID into the advertisement packet."
|
||||
#~ msgstr "È possibile codificare l'UUID nel pacchetto di advertisement."
|
||||
|
||||
#~ msgid "Can not query for the device address."
|
||||
#~ msgstr "Non è possibile trovare l'indirizzo del dispositivo."
|
||||
|
||||
#~ msgid "Can not add Service."
|
||||
#~ msgstr "Non è possibile aggiungere Service."
|
||||
|
||||
#~ msgid ""
|
||||
#~ "Please file an issue here with the contents of your CIRCUITPY drive:\n"
|
||||
#~ msgstr ""
|
||||
#~ "Ti preghiamo di compilare una issue con il contenuto del tuo drie "
|
||||
#~ "CIRCUITPY:\n"
|
||||
|
||||
#~ msgid "Looks like our core CircuitPython code crashed hard. Whoops!\n"
|
||||
#~ msgstr ""
|
||||
#~ "Sembra che il codice del core di CircuitPython sia crashato malamente. "
|
||||
#~ "Whoops!\n"
|
||||
#~ msgid "Can not apply device name in the stack."
|
||||
#~ msgstr "Non è possibile inserire il nome del dipositivo nella lista."
|
||||
|
@ -2670,17 +2670,23 @@ msgstr ""
|
||||
#~ msgid "Invalid UUID parameter"
|
||||
#~ msgstr "Parâmetro UUID inválido"
|
||||
|
||||
#~ msgid "Can not apply advertisement data. status: 0x%02x"
|
||||
#~ msgstr "Não é possível aplicar dados de anúncio. status: 0x%02x"
|
||||
|
||||
#~ msgid "Can not apply device name in the stack."
|
||||
#~ msgstr "Não é possível aplicar o nome do dispositivo na pilha."
|
||||
|
||||
#~ msgid "Can encode UUID into the advertisement packet."
|
||||
#~ msgstr "Pode codificar o UUID no pacote de anúncios."
|
||||
#~ msgid "Baud rate too high for this SPI peripheral"
|
||||
#~ msgstr "Taxa de transmissão muito alta para esse periférico SPI"
|
||||
|
||||
#~ msgid "Cannot apply GAP parameters."
|
||||
#~ msgstr "Não é possível aplicar parâmetros GAP."
|
||||
|
||||
#~ msgid "Invalid Service type"
|
||||
#~ msgstr "Tipo de serviço inválido"
|
||||
|
||||
#~ msgid "Cannot apply GAP parameters."
|
||||
#~ msgstr "Não é possível aplicar parâmetros GAP."
|
||||
#~ msgid "Can encode UUID into the advertisement packet."
|
||||
#~ msgstr "Pode codificar o UUID no pacote de anúncios."
|
||||
|
||||
#~ msgid "Cannot set PPCP parameters."
|
||||
#~ msgstr "Não é possível definir parâmetros PPCP."
|
||||
@ -2688,11 +2694,8 @@ msgstr ""
|
||||
#~ msgid "Can not query for the device address."
|
||||
#~ msgstr "Não é possível consultar o endereço do dispositivo."
|
||||
|
||||
#~ msgid "Baud rate too high for this SPI peripheral"
|
||||
#~ msgstr "Taxa de transmissão muito alta para esse periférico SPI"
|
||||
#~ msgid "Can not add Characteristic."
|
||||
#~ msgstr "Não é possível adicionar Característica."
|
||||
|
||||
#~ msgid "Can not apply advertisement data. status: 0x%02x"
|
||||
#~ msgstr "Não é possível aplicar dados de anúncio. status: 0x%02x"
|
||||
|
||||
#~ msgid "Can not add Service."
|
||||
#~ msgstr "Não é possível adicionar o serviço."
|
||||
#~ msgid "Cannot set PPCP parameters."
|
||||
#~ msgstr "Não é possível definir parâmetros PPCP."
|
||||
|
@ -90,13 +90,13 @@ BASE_CFLAGS = \
|
||||
ifeq ($(CHIP_FAMILY), samd21)
|
||||
CFLAGS += -Os -DNDEBUG
|
||||
# TinyUSB defines
|
||||
CFLAGS += -DCFG_TUSB_MCU=OPT_MCU_SAMD21 -DCFG_TUD_CDC_RX_BUFSIZE=128 -DCFG_TUD_CDC_TX_BUFSIZE=128 -DCFG_TUD_MSC_BUFSIZE=512
|
||||
CFLAGS += -DCFG_TUSB_MCU=OPT_MCU_SAMD21 -DCFG_TUD_MIDI_RX_BUFSIZE=128 -DCFG_TUD_CDC_RX_BUFSIZE=128 -DCFG_TUD_MIDI_TX_BUFSIZE=128 -DCFG_TUD_CDC_TX_BUFSIZE=128 -DCFG_TUD_MSC_BUFSIZE=512
|
||||
endif
|
||||
|
||||
ifeq ($(CHIP_FAMILY), samd51)
|
||||
CFLAGS += -Os -DNDEBUG
|
||||
# TinyUSB defines
|
||||
CFLAGS += -DCFG_TUSB_MCU=OPT_MCU_SAMD51 -DCFG_TUD_CDC_RX_BUFSIZE=256 -DCFG_TUD_CDC_TX_BUFSIZE=256 -DCFG_TUD_MSC_BUFSIZE=1024
|
||||
CFLAGS += -DCFG_TUSB_MCU=OPT_MCU_SAMD51 -DCFG_TUD_MIDI_RX_BUFSIZE=128 -DCFG_TUD_CDC_RX_BUFSIZE=256 -DCFG_TUD_MIDI_TX_BUFSIZE=128 -DCFG_TUD_CDC_TX_BUFSIZE=256 -DCFG_TUD_MSC_BUFSIZE=1024
|
||||
endif
|
||||
|
||||
#Debugging/Optimization
|
||||
@ -104,9 +104,9 @@ ifeq ($(DEBUG), 1)
|
||||
# Turn on Python modules useful for debugging (e.g. uheap, ustack).
|
||||
CFLAGS += -ggdb
|
||||
# You may want to disable -flto if it interferes with debugging.
|
||||
CFLAGS += -flto
|
||||
# CFLAGS += -flto
|
||||
# You may want to enable these flags to make setting breakpoints easier.
|
||||
# CFLAGS += -fno-inline -fno-ipa-sra
|
||||
CFLAGS += -fno-inline -fno-ipa-sra
|
||||
ifeq ($(CHIP_FAMILY), samd21)
|
||||
CFLAGS += -DENABLE_MICRO_TRACE_BUFFER
|
||||
endif
|
||||
@ -267,7 +267,6 @@ SRC_C = \
|
||||
lib/oofatfs/option/ccsbcs.c \
|
||||
lib/timeutils/timeutils.c \
|
||||
lib/tinyusb/src/portable/microchip/$(CHIP_FAMILY)/dcd_$(CHIP_FAMILY).c \
|
||||
lib/tinyusb/src/portable/microchip/$(CHIP_FAMILY)/hal_$(CHIP_FAMILY).c \
|
||||
lib/utils/buffer_helper.c \
|
||||
lib/utils/context_manager_helpers.c \
|
||||
lib/utils/interrupt_char.c \
|
||||
|
@ -22,51 +22,51 @@ different names. The table below matches the pin order in
|
||||
and omits the pins only available on the largest package because all supported
|
||||
boards use smaller version.
|
||||
|
||||
===================== =================== =============== =========================== ====================== ================ ================== ========================= ================ ================
|
||||
===================== =================== =============== =========================== ====================== ================ ================== ========================= ================ ================================ ================
|
||||
`microcontroller.pin` `board`
|
||||
--------------------- ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
Datasheet arduino_mkrzero arduino_zero circuitplayground_express feather_m0_adalogger feather_m0_basic feather_m0_express gemma_m0 metro_m0_express trinket_m0
|
||||
===================== =================== =============== =========================== ====================== ================ ================== ========================= ================ ================
|
||||
--------------------- --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
Datasheet arduino_mkrzero arduino_zero circuitplayground_express feather_m0_adalogger feather_m0_basic feather_m0_express gemma_m0 metro_m0_express sparkfun_samd21_mini trinket_m0
|
||||
===================== =================== =============== =========================== ====================== ================ ================== ========================= ================ ================================ ================
|
||||
PA00 ``ACCELEROMETER_SDA`` ``APA102_MOSI`` ``APA102_MOSI``
|
||||
PA01 ``ACCELEROMETER_SCL`` ``APA102_SCK`` ``APA102_SCK``
|
||||
PA02 ``A0`` ``A0`` ``A0`` / ``SPEAKER`` ``A0`` ``A0`` ``A0`` ``A0`` / ``D1`` ``A0`` ``D1`` / ``A0``
|
||||
PA02 ``A0`` ``A0`` ``A0`` / ``SPEAKER`` ``A0`` ``A0`` ``A0`` ``A0`` / ``D1`` ``A0`` ``A0`` ``D1`` / ``A0``
|
||||
PA03
|
||||
PB08 ``L`` ``A1`` ``A7`` / ``TX`` ``A1`` ``A1`` ``A1`` ``A1``
|
||||
PB09 ``BATTERY`` ``A2`` ``A6`` / ``RX`` ``A2`` ``A2`` ``A2`` ``A2``
|
||||
PA04 ``A3`` ``A3`` ``IR_PROXIMITY`` ``A3`` ``A3`` ``A3`` ``D0`` / ``TX`` / ``SDA`` ``A3``
|
||||
PB08 ``L`` ``A1`` ``A7`` / ``TX`` ``A1`` ``A1`` ``A1`` ``A1`` ``A1``
|
||||
PB09 ``BATTERY`` ``A2`` ``A6`` / ``RX`` ``A2`` ``A2`` ``A2`` ``A2`` ``A2``
|
||||
PA04 ``A3`` ``A3`` ``IR_PROXIMITY`` ``A3`` ``A3`` ``A3`` ``D0`` / ``TX`` / ``SDA`` ``A3`` ``A3``
|
||||
PA05 ``A4`` ``A4`` ``A1`` ``A4`` ``A4`` ``A4`` ``D2`` / ``RX`` / ``SCL`` ``A4``
|
||||
PA06 ``A5`` ``D8`` ``A2`` ``D8`` / ``GREEN_LED`` ``NEOPIXEL`` ``D8`` ``D4`` / ``TX``
|
||||
PA07 ``A6`` ``D9`` ``A3`` ``D9`` ``D9`` ``D9`` ``D9`` ``D3`` / ``RX``
|
||||
PA08 ``D11`` / ``SDA`` ``D4`` ``MICROPHONE_DO`` ``D4`` / ``SD_CS`` ``D4`` ``D0`` / ``SDA``
|
||||
PA09 ``D12`` / ``SCL`` ``D3`` ``TEMPERATURE`` / ``A9`` ``D3`` ``D2`` / ``SCL``
|
||||
PA10 ``D2`` ``D1`` / ``TX`` ``MICROPHONE_SCK`` ``D1`` / ``TX`` ``D1`` / ``TX`` ``D1`` / ``TX`` ``D1`` / ``TX`` ``D13``
|
||||
PA11 ``D3`` ``D0`` / ``RX`` ``LIGHT`` / ``A8`` ``D0`` / ``RX`` ``D0`` / ``RX`` ``D0`` / ``RX`` ``D0`` / ``RX``
|
||||
PA06 ``A5`` ``D8`` ``A2`` ``D8`` / ``GREEN_LED`` ``NEOPIXEL`` ``D8`` ``D8`` ``D4`` / ``TX``
|
||||
PA07 ``A6`` ``D9`` ``A3`` ``D9`` ``D9`` ``D9`` ``D9`` ``D9`` ``D3`` / ``RX``
|
||||
PA08 ``D11`` / ``SDA`` ``D4`` ``MICROPHONE_DO`` ``D4`` / ``SD_CS`` ``D4`` ``D4`` ``D0`` / ``SDA``
|
||||
PA09 ``D12`` / ``SCL`` ``D3`` ``TEMPERATURE`` / ``A9`` ``D3`` ``D3`` ``D2`` / ``SCL``
|
||||
PA10 ``D2`` ``D1`` / ``TX`` ``MICROPHONE_SCK`` ``D1`` / ``TX`` ``D1`` / ``TX`` ``D1`` / ``TX`` ``D1`` / ``TX`` ``D1`` / ``TX`` ``D13``
|
||||
PA11 ``D3`` ``D0`` / ``RX`` ``LIGHT`` / ``A8`` ``D0`` / ``RX`` ``D0`` / ``RX`` ``D0`` / ``RX`` ``D0`` / ``RX`` ``D0`` / ``RX``
|
||||
PB10 ``D4`` ``MOSI`` ``MOSI`` ``MOSI`` ``MOSI`` ``MOSI``
|
||||
PB11 ``D5`` ``SCK`` ``SCK`` ``SCK`` ``SCK`` ``SCK``
|
||||
PA12 ``SD_MOSI`` ``MISO`` ``REMOTEIN`` / ``IR_RX`` ``MISO`` ``MISO`` ``MISO`` ``MISO``
|
||||
PA13 ``SD_SCK`` ``ACCELEROMETER_INTERRUPT`` ``FLASH_CS``
|
||||
PA14 ``SD_CS`` ``D2`` ``BUTTON_B`` / ``D5`` ``D2``
|
||||
PA15 ``SD_MISO`` ``D5`` ``SLIDE_SWITCH`` / ``D7`` ``D5`` ``D5`` ``D5`` ``D5``
|
||||
PA16 ``D8`` / ``MOSI`` ``D11`` ``MISO`` ``D11`` ``D11`` ``D11`` ``D11``
|
||||
PA17 ``D9`` / ``SCK`` ``D13`` ``D13`` ``D13`` / ``RED_LED`` ``D13`` ``D13`` ``D13``
|
||||
PA18 ``D10`` ``D10`` ``D10`` ``D10`` ``D10``
|
||||
PA19 ``D10`` / ``MISO`` ``D12`` ``D12`` ``D12`` ``D12`` ``D12``
|
||||
PA20 ``D6`` ``D6`` ``MOSI`` ``D6`` ``D6`` ``D6`` ``D6``
|
||||
PA21 ``D7`` ``D7`` ``SCK`` ``D7`` / ``SD_CD`` ``D7``
|
||||
PA22 ``D0`` ``SDA`` ``SDA`` ``SDA`` ``SDA`` ``SDA``
|
||||
PA23 ``D1`` ``SCL`` ``REMOTEOUT`` / ``IR_TX`` ``SCL`` ``SCL`` ``SCL`` ``L`` / ``D13`` ``SCL``
|
||||
PA14 ``SD_CS`` ``D2`` ``BUTTON_B`` / ``D5`` ``D2`` ``D2``
|
||||
PA15 ``SD_MISO`` ``D5`` ``SLIDE_SWITCH`` / ``D7`` ``D5`` ``D5`` ``D5`` ``D5`` ``D5``
|
||||
PA16 ``D8`` / ``MOSI`` ``D11`` ``MISO`` ``D11`` ``D11`` ``D11`` ``D11`` ``D11`` / ``MOSI``
|
||||
PA17 ``D9`` / ``SCK`` ``D13`` ``D13`` ``D13`` / ``RED_LED`` ``D13`` ``D13`` ``D13`` ``D13`` / ``SCK`` / ``BLUE_LED``
|
||||
PA18 ``D10`` ``D10`` ``D10`` ``D10`` ``D10`` ``D10``
|
||||
PA19 ``D10`` / ``MISO`` ``D12`` ``D12`` ``D12`` ``D12`` ``D12`` ``D12`` / ``MISO``
|
||||
PA20 ``D6`` ``D6`` ``MOSI`` ``D6`` ``D6`` ``D6`` ``D6`` ``D6``
|
||||
PA21 ``D7`` ``D7`` ``SCK`` ``D7`` / ``SD_CD`` ``D7`` ``D7``
|
||||
PA22 ``D0`` ``SDA`` ``SDA`` ``SDA`` ``SDA`` ``SDA`` ``SDA``
|
||||
PA23 ``D1`` ``SCL`` ``REMOTEOUT`` / ``IR_TX`` ``SCL`` ``SCL`` ``SCL`` ``L`` / ``D13`` ``SCL`` ``SCL``
|
||||
PA24
|
||||
PA25
|
||||
PB22 ``D14`` / ``TX`` ``FLASH_CS``
|
||||
PB23 ``D13`` / ``RX`` ``NEOPIXEL`` / ``D8``
|
||||
PA27 ``SD_CD``
|
||||
PA27 ``SD_CD`` ``GREEN_LED``
|
||||
PA28 ``BUTTON_A`` / ``D4``
|
||||
PA29
|
||||
PA30 ``SPEAKER_ENABLE`` ``NEOPIXEL``
|
||||
PA31
|
||||
PB02 ``A1`` ``A5`` ``A5`` / ``SDA`` ``A5`` ``A5`` ``A5`` ``A5``
|
||||
PB03 ``A2`` ``A4`` / ``SCL``
|
||||
===================== =================== =============== =========================== ====================== ================ ================== ========================= ================ ================
|
||||
PB03 ``A2`` ``A4`` / ``SCL`` ``YELLOW_LED``
|
||||
===================== =================== =============== =========================== ====================== ================ ================== ========================= ================ ================================ ================
|
||||
|
||||
Here is a table about which pins can do what in CircuitPython terms. However,
|
||||
just because something is listed, doesn't mean it will always work. Existing use
|
||||
|
39
ports/atmel-samd/boards/sparkfun_samd21_mini/board.c
Normal file
39
ports/atmel-samd/boards/sparkfun_samd21_mini/board.c
Normal file
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* This file is part of the MicroPython project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "boards/board.h"
|
||||
#include "mpconfigboard.h"
|
||||
#include "hal/include/hal_gpio.h"
|
||||
|
||||
void board_init(void) {
|
||||
}
|
||||
|
||||
bool board_requests_safe_mode(void) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void reset_board(void) {
|
||||
}
|
24
ports/atmel-samd/boards/sparkfun_samd21_mini/mpconfigboard.h
Normal file
24
ports/atmel-samd/boards/sparkfun_samd21_mini/mpconfigboard.h
Normal file
@ -0,0 +1,24 @@
|
||||
#define MICROPY_HW_BOARD_NAME "SparkFun SAMD21 Mini Breakout"
|
||||
#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 0
|
||||
|
||||
#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000)
|
||||
|
||||
#define DEFAULT_I2C_BUS_SCL (&pin_PA23)
|
||||
#define DEFAULT_I2C_BUS_SDA (&pin_PA22)
|
||||
|
||||
#define DEFAULT_SPI_BUS_SCK (&pin_PA17)
|
||||
#define DEFAULT_SPI_BUS_MOSI (&pin_PA16)
|
||||
#define DEFAULT_SPI_BUS_MISO (&pin_PA19)
|
||||
|
||||
#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
|
@ -0,0 +1,11 @@
|
||||
LD_FILE = boards/samd21x18-bootloader.ld
|
||||
USB_VID = 0x1B4F
|
||||
USB_PID = 0x8D22
|
||||
USB_PRODUCT = "SparkFun SAMD21 Mini Breakout"
|
||||
USB_MANUFACTURER = "SparkFun"
|
||||
|
||||
INTERNAL_FLASH_FILESYSTEM = 1
|
||||
LONGINT_IMPL = NONE
|
||||
|
||||
CHIP_VARIANT = SAMD21G18A
|
||||
CHIP_FAMILY = samd21
|
53
ports/atmel-samd/boards/sparkfun_samd21_mini/pins.c
Normal file
53
ports/atmel-samd/boards/sparkfun_samd21_mini/pins.c
Normal file
@ -0,0 +1,53 @@
|
||||
#include "shared-bindings/board/__init__.h"
|
||||
|
||||
#include "board_busses.h"
|
||||
|
||||
STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
|
||||
|
||||
// Analog pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA02) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PB08) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PB09) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PA04) },
|
||||
|
||||
// Digital pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_PA11) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_PA10) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_PA14) },
|
||||
{ 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_D5), MP_ROM_PTR(&pin_PA15) },
|
||||
{ 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) },
|
||||
|
||||
// UART pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PA10) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PA11) },
|
||||
|
||||
// SPI pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PA16) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PA17) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PA19) },
|
||||
|
||||
// I2C pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PA23) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PA22) },
|
||||
|
||||
// LED pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_PA17) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_BLUE_LED), MP_ROM_PTR(&pin_PA17) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_GREEN_LED), MP_ROM_PTR(&pin_PA27) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_YELLOW_LED), MP_ROM_PTR(&pin_PB03) },
|
||||
|
||||
// Comm objects
|
||||
{ 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);
|
@ -237,6 +237,7 @@ extern const struct _mp_obj_module_t gamepad_module;
|
||||
extern const struct _mp_obj_module_t stage_module;
|
||||
extern const struct _mp_obj_module_t touchio_module;
|
||||
extern const struct _mp_obj_module_t usb_hid_module;
|
||||
extern const struct _mp_obj_module_t usb_midi_module;
|
||||
extern const struct _mp_obj_module_t network_module;
|
||||
extern const struct _mp_obj_module_t socket_module;
|
||||
extern const struct _mp_obj_module_t wiznet_module;
|
||||
@ -382,6 +383,7 @@ extern const struct _mp_obj_module_t wiznet_module;
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_math), (mp_obj_t)&math_module }, \
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR__time), (mp_obj_t)&time_module }, \
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_usb_hid),(mp_obj_t)&usb_hid_module }, \
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_usb_midi),(mp_obj_t)&usb_midi_module }, \
|
||||
TOUCHIO_MODULE \
|
||||
EXTRA_BUILTIN_MODULES
|
||||
|
||||
@ -410,6 +412,7 @@ extern const struct _mp_obj_module_t wiznet_module;
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_math), (mp_obj_t)&math_module }, \
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_time), (mp_obj_t)&time_module }, \
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_usb_hid),(mp_obj_t)&usb_hid_module }, \
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_usb_midi),(mp_obj_t)&usb_midi_module }, \
|
||||
TOUCHIO_MODULE \
|
||||
EXTRA_BUILTIN_MODULES
|
||||
#endif
|
||||
|
@ -75,7 +75,7 @@ LDFLAGS += -mthumb -mabi=aapcs -T $(LD_FILE) -L boards/
|
||||
LDFLAGS += -Wl,--gc-sections
|
||||
|
||||
# TinyUSB defines
|
||||
CFLAGS += -DCFG_TUSB_MCU=OPT_MCU_NRF5X -DCFG_TUD_CDC_RX_BUFSIZE=1024 -DCFG_TUD_CDC_TX_BUFSIZE=1024 -DCFG_TUD_MSC_BUFSIZE=4096
|
||||
CFLAGS += -DCFG_TUSB_MCU=OPT_MCU_NRF5X -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
|
||||
|
||||
#Debugging/Optimization
|
||||
ifeq ($(DEBUG), 1)
|
||||
@ -103,6 +103,7 @@ SRC_NRFX = $(addprefix nrfx/,\
|
||||
drivers/src/nrfx_timer.c \
|
||||
drivers/src/nrfx_twim.c \
|
||||
drivers/src/nrfx_uarte.c \
|
||||
drivers/src/nrfx_gpiote.c \
|
||||
)
|
||||
|
||||
ifdef EXTERNAL_FLASH_DEVICES
|
||||
|
@ -100,6 +100,10 @@ STATIC uint32_t add_services_to_advertisement(bleio_peripheral_obj_t *self, size
|
||||
|
||||
|
||||
|
||||
// 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);
|
||||
|
||||
|
@ -141,7 +141,7 @@ void common_hal_neopixel_write (const digitalio_digitalinout_obj_t* digitalinout
|
||||
for ( uint16_t n = 0; n < numBytes; n++ ) {
|
||||
uint8_t pix = pixels[n];
|
||||
|
||||
for ( uint8_t mask = 0x80, i = 0; mask > 0; mask >>= 1, i++ ) {
|
||||
for ( uint8_t mask = 0x80; mask > 0; mask >>= 1 ) {
|
||||
pixels_pattern[pos] = (pix & mask) ? MAGIC_T1H : MAGIC_T0H;
|
||||
pos++;
|
||||
}
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "common-hal/pulseio/PulseIn.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "py/mpconfig.h"
|
||||
#include "py/gc.h"
|
||||
@ -35,50 +36,247 @@
|
||||
#include "shared-bindings/microcontroller/__init__.h"
|
||||
#include "shared-bindings/pulseio/PulseIn.h"
|
||||
|
||||
void pulsein_reset(void) {
|
||||
#include "tick.h"
|
||||
#include "nrfx_gpiote.h"
|
||||
|
||||
// obj array to map pin -> self since nrfx hide the mapping
|
||||
static pulseio_pulsein_obj_t* _objs[GPIOTE_CH_NUM];
|
||||
|
||||
// return index of the object in array
|
||||
static int _find_pulsein_obj(pulseio_pulsein_obj_t* obj) {
|
||||
for(int i = 0; i < NRFX_ARRAY_SIZE(_objs); i++ ) {
|
||||
if ( _objs[i] == obj) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void _pulsein_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action) {
|
||||
// Grab the current time first.
|
||||
uint32_t current_us;
|
||||
uint64_t current_ms;
|
||||
current_tick(¤t_ms, ¤t_us);
|
||||
|
||||
// current_tick gives us the remaining us until the next tick but we want the number since the last ms.
|
||||
current_us = 1000 - current_us;
|
||||
|
||||
pulseio_pulsein_obj_t* self = NULL;
|
||||
for(int i = 0; i < NRFX_ARRAY_SIZE(_objs); i++ ) {
|
||||
if ( _objs[i] && _objs[i]->pin == pin ) {
|
||||
self = _objs[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( !self ) return;
|
||||
|
||||
if (self->first_edge) {
|
||||
// first pulse is opposite state from idle
|
||||
bool state = nrf_gpio_pin_read(self->pin);
|
||||
if ( self->idle_state != state ) {
|
||||
self->first_edge = false;
|
||||
}
|
||||
}else {
|
||||
uint32_t ms_diff = current_ms - self->last_ms;
|
||||
uint16_t us_diff = current_us - self->last_us;
|
||||
uint32_t total_diff = us_diff;
|
||||
|
||||
if (self->last_us > current_us) {
|
||||
total_diff = 1000 + current_us - self->last_us;
|
||||
if (ms_diff > 1) {
|
||||
total_diff += (ms_diff - 1) * 1000;
|
||||
}
|
||||
} else {
|
||||
total_diff += ms_diff * 1000;
|
||||
}
|
||||
uint16_t duration = 0xffff;
|
||||
if (total_diff < duration) {
|
||||
duration = total_diff;
|
||||
}
|
||||
|
||||
uint16_t i = (self->start + self->len) % self->maxlen;
|
||||
self->buffer[i] = duration;
|
||||
if (self->len < self->maxlen) {
|
||||
self->len++;
|
||||
} else {
|
||||
self->start++;
|
||||
}
|
||||
}
|
||||
|
||||
self->last_ms = current_ms;
|
||||
self->last_us = current_us;
|
||||
}
|
||||
|
||||
void pulsein_reset(void) {
|
||||
if ( nrfx_gpiote_is_init() ) {
|
||||
nrfx_gpiote_uninit();
|
||||
}
|
||||
nrfx_gpiote_init();
|
||||
|
||||
memset(_objs, 0, sizeof(_objs));
|
||||
}
|
||||
|
||||
void common_hal_pulseio_pulsein_construct(pulseio_pulsein_obj_t* self, const mcu_pin_obj_t* pin, uint16_t maxlen, bool idle_state) {
|
||||
int idx = _find_pulsein_obj(NULL);
|
||||
if ( idx < 0 ) {
|
||||
mp_raise_NotImplementedError(NULL);
|
||||
}
|
||||
_objs[idx] = self;
|
||||
|
||||
self->buffer = (uint16_t *) m_malloc(maxlen * sizeof(uint16_t), false);
|
||||
if (self->buffer == NULL) {
|
||||
mp_raise_msg_varg(&mp_type_MemoryError, translate("Failed to allocate RX buffer of %d bytes"), maxlen * sizeof(uint16_t));
|
||||
}
|
||||
|
||||
self->pin = pin->number;
|
||||
self->maxlen = maxlen;
|
||||
self->idle_state = idle_state;
|
||||
self->start = 0;
|
||||
self->len = 0;
|
||||
self->first_edge = true;
|
||||
self->paused = false;
|
||||
self->last_us = 0;
|
||||
self->last_ms = 0;
|
||||
|
||||
claim_pin(pin);
|
||||
|
||||
nrfx_gpiote_in_config_t cfg = {
|
||||
.sense = NRF_GPIOTE_POLARITY_TOGGLE,
|
||||
.pull = NRF_GPIO_PIN_NOPULL, // idle_state ? NRF_GPIO_PIN_PULLDOWN : NRF_GPIO_PIN_PULLUP,
|
||||
.is_watcher = false, // nrf_gpio_cfg_watcher vs nrf_gpio_cfg_input
|
||||
.hi_accuracy = true,
|
||||
.skip_gpio_setup = false
|
||||
};
|
||||
nrfx_gpiote_in_init(self->pin, &cfg, _pulsein_handler);
|
||||
nrfx_gpiote_in_event_enable(self->pin, true);
|
||||
}
|
||||
|
||||
bool common_hal_pulseio_pulsein_deinited(pulseio_pulsein_obj_t* self) {
|
||||
return 1;
|
||||
return self->pin == NO_PIN;
|
||||
}
|
||||
|
||||
void common_hal_pulseio_pulsein_deinit(pulseio_pulsein_obj_t* self) {
|
||||
if (common_hal_pulseio_pulsein_deinited(self)) {
|
||||
return;
|
||||
}
|
||||
|
||||
nrfx_gpiote_in_event_disable(self->pin);
|
||||
nrfx_gpiote_in_uninit(self->pin);
|
||||
|
||||
// mark local array as invalid
|
||||
int idx = _find_pulsein_obj(self);
|
||||
if ( idx < 0 ) {
|
||||
mp_raise_NotImplementedError(NULL);
|
||||
}
|
||||
_objs[idx] = NULL;
|
||||
|
||||
reset_pin_number(self->pin);
|
||||
self->pin = NO_PIN;
|
||||
}
|
||||
|
||||
void common_hal_pulseio_pulsein_pause(pulseio_pulsein_obj_t* self) {
|
||||
|
||||
nrfx_gpiote_in_event_disable(self->pin);
|
||||
self->paused = true;
|
||||
}
|
||||
|
||||
void common_hal_pulseio_pulsein_resume(pulseio_pulsein_obj_t* self, uint16_t trigger_duration) {
|
||||
// Make sure we're paused.
|
||||
if ( !self->paused ) {
|
||||
common_hal_pulseio_pulsein_pause(self);
|
||||
}
|
||||
|
||||
// Send the trigger pulse.
|
||||
if (trigger_duration > 0) {
|
||||
nrfx_gpiote_in_uninit(self->pin);
|
||||
|
||||
nrf_gpio_cfg_output(self->pin);
|
||||
nrf_gpio_pin_write(self->pin, !self->idle_state);
|
||||
common_hal_mcu_delay_us((uint32_t)trigger_duration);
|
||||
nrf_gpio_pin_write(self->pin, self->idle_state);
|
||||
|
||||
nrfx_gpiote_in_config_t cfg = {
|
||||
.sense = NRF_GPIOTE_POLARITY_TOGGLE,
|
||||
.pull = NRF_GPIO_PIN_NOPULL, // idle_state ? NRF_GPIO_PIN_PULLDOWN : NRF_GPIO_PIN_PULLUP,
|
||||
.is_watcher = false, // nrf_gpio_cfg_watcher vs nrf_gpio_cfg_input
|
||||
.hi_accuracy = true,
|
||||
.skip_gpio_setup = false
|
||||
};
|
||||
nrfx_gpiote_in_init(self->pin, &cfg, _pulsein_handler);
|
||||
}
|
||||
|
||||
self->first_edge = true;
|
||||
self->paused = false;
|
||||
self->last_ms = 0;
|
||||
self->last_us = 0;
|
||||
|
||||
nrfx_gpiote_in_event_enable(self->pin, true);
|
||||
}
|
||||
|
||||
void common_hal_pulseio_pulsein_clear(pulseio_pulsein_obj_t* self) {
|
||||
|
||||
if ( !self->paused ) {
|
||||
nrfx_gpiote_in_event_disable(self->pin);
|
||||
}
|
||||
|
||||
uint16_t common_hal_pulseio_pulsein_popleft(pulseio_pulsein_obj_t* self) {
|
||||
return 0;
|
||||
}
|
||||
self->start = 0;
|
||||
self->len = 0;
|
||||
|
||||
uint16_t common_hal_pulseio_pulsein_get_maxlen(pulseio_pulsein_obj_t* self) {
|
||||
return 0xadaf;
|
||||
if ( !self->paused ) {
|
||||
nrfx_gpiote_in_event_enable(self->pin, true);
|
||||
}
|
||||
|
||||
bool common_hal_pulseio_pulsein_get_paused(pulseio_pulsein_obj_t* self) {
|
||||
return false;
|
||||
}
|
||||
|
||||
uint16_t common_hal_pulseio_pulsein_get_len(pulseio_pulsein_obj_t* self) {
|
||||
return 0xadaf;
|
||||
}
|
||||
|
||||
uint16_t common_hal_pulseio_pulsein_get_item(pulseio_pulsein_obj_t* self, int16_t index) {
|
||||
return 0xadaf;
|
||||
if ( !self->paused ) {
|
||||
nrfx_gpiote_in_event_disable(self->pin);
|
||||
}
|
||||
|
||||
if (index < 0) {
|
||||
index += self->len;
|
||||
}
|
||||
if (index < 0 || index >= self->len) {
|
||||
if ( !self->paused ) {
|
||||
nrfx_gpiote_in_event_enable(self->pin, true);
|
||||
}
|
||||
mp_raise_IndexError(translate("index out of range"));
|
||||
}
|
||||
uint16_t value = self->buffer[(self->start + index) % self->maxlen];
|
||||
|
||||
if ( !self->paused ) {
|
||||
nrfx_gpiote_in_event_enable(self->pin, true);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
uint16_t common_hal_pulseio_pulsein_popleft(pulseio_pulsein_obj_t* self) {
|
||||
if (self->len == 0) {
|
||||
mp_raise_IndexError(translate("pop from an empty PulseIn"));
|
||||
}
|
||||
|
||||
if ( !self->paused ) {
|
||||
nrfx_gpiote_in_event_disable(self->pin);
|
||||
}
|
||||
|
||||
uint16_t value = self->buffer[self->start];
|
||||
self->start = (self->start + 1) % self->maxlen;
|
||||
self->len--;
|
||||
|
||||
if ( !self->paused ) {
|
||||
nrfx_gpiote_in_event_enable(self->pin, true);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
uint16_t common_hal_pulseio_pulsein_get_maxlen(pulseio_pulsein_obj_t* self) {
|
||||
return self->maxlen;
|
||||
}
|
||||
|
||||
bool common_hal_pulseio_pulsein_get_paused(pulseio_pulsein_obj_t* self) {
|
||||
return self->paused;
|
||||
}
|
||||
|
||||
uint16_t common_hal_pulseio_pulsein_get_len(pulseio_pulsein_obj_t* self) {
|
||||
return self->len;
|
||||
}
|
||||
|
@ -33,15 +33,19 @@
|
||||
|
||||
typedef struct {
|
||||
mp_obj_base_t base;
|
||||
uint8_t channel;
|
||||
|
||||
uint8_t pin;
|
||||
bool idle_state;
|
||||
bool paused;
|
||||
volatile bool first_edge;
|
||||
|
||||
uint16_t* buffer;
|
||||
uint16_t maxlen;
|
||||
bool idle_state;
|
||||
|
||||
volatile uint16_t start;
|
||||
volatile uint16_t len;
|
||||
volatile bool first_edge;
|
||||
uint16_t ticks_per_ms;
|
||||
volatile uint16_t last_us;
|
||||
volatile uint64_t last_ms;
|
||||
} pulseio_pulsein_obj_t;
|
||||
|
||||
void pulsein_reset(void);
|
||||
|
@ -175,6 +175,7 @@ extern const struct _mp_obj_module_t supervisor_module;
|
||||
extern const struct _mp_obj_module_t gamepad_module;
|
||||
extern const struct _mp_obj_module_t neopixel_write_module;
|
||||
extern const struct _mp_obj_module_t usb_hid_module;
|
||||
extern const struct _mp_obj_module_t usb_midi_module;
|
||||
extern const struct _mp_obj_module_t bleio_module;
|
||||
|
||||
#if MICROPY_PY_BLEIO
|
||||
@ -207,6 +208,7 @@ extern const struct _mp_obj_module_t bleio_module;
|
||||
{ MP_OBJ_NEW_QSTR (MP_QSTR_time ), (mp_obj_t)&time_module }, \
|
||||
{ MP_OBJ_NEW_QSTR (MP_QSTR_json ), (mp_obj_t)&mp_module_ujson }, \
|
||||
USBHID_MODULE \
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_usb_midi),(mp_obj_t)&usb_midi_module }, \
|
||||
BLEIO_MODULE
|
||||
|
||||
// extra built in names to add to the global namespace
|
||||
|
@ -84,4 +84,9 @@
|
||||
|
||||
#define NRFX_TIMER_DEFAULT_CONFIG_IRQ_PRIORITY 7
|
||||
|
||||
// GPIO interrupt
|
||||
#define NRFX_GPIOTE_ENABLED 1
|
||||
#define NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS 1
|
||||
#define NRFX_GPIOTE_CONFIG_IRQ_PRIORITY 7
|
||||
|
||||
#endif // NRFX_CONFIG_H__
|
||||
|
@ -43,6 +43,7 @@
|
||||
#include "common-hal/busio/SPI.h"
|
||||
#include "common-hal/pulseio/PWMOut.h"
|
||||
#include "common-hal/pulseio/PulseOut.h"
|
||||
#include "common-hal/pulseio/PulseIn.h"
|
||||
#include "tick.h"
|
||||
|
||||
static void power_warning_handler(void) {
|
||||
@ -85,6 +86,7 @@ void reset_port(void) {
|
||||
spi_reset();
|
||||
pwmout_reset();
|
||||
pulseout_reset();
|
||||
pulsein_reset();
|
||||
timers_reset();
|
||||
|
||||
bleio_reset();
|
||||
|
@ -192,7 +192,8 @@ const mp_obj_property_t bleio_peripheral_name_obj = {
|
||||
//| services are included in the advertisement packets.
|
||||
//|
|
||||
//| :param bool connectable: If `True` then other devices are allowed to connect to this peripheral.
|
||||
//| :param buf data: If not None, then send data bytes in advertising packets.
|
||||
//| :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.
|
||||
//|
|
||||
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]);
|
||||
|
128
shared-bindings/usb_midi/PortIn.c
Normal file
128
shared-bindings/usb_midi/PortIn.c
Normal file
@ -0,0 +1,128 @@
|
||||
/*
|
||||
* This file is part of the Micro Python 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 <stdint.h>
|
||||
|
||||
#include "shared-bindings/usb_midi/PortIn.h"
|
||||
#include "shared-bindings/util.h"
|
||||
|
||||
#include "py/ioctl.h"
|
||||
#include "py/objproperty.h"
|
||||
#include "py/runtime.h"
|
||||
#include "py/stream.h"
|
||||
#include "supervisor/shared/translate.h"
|
||||
|
||||
|
||||
//| .. currentmodule:: usb_midi
|
||||
//|
|
||||
//| :class:`PortIn` -- receives midi commands over USB
|
||||
//| ===================================================
|
||||
//|
|
||||
//| .. class:: PortIn()
|
||||
//|
|
||||
//| Not currently dynamically supported.
|
||||
//|
|
||||
//| PortIn objects are constructed for every corresponding entry in the USB descriptor and added
|
||||
//| to the ``usb_midi.ports`` tuple.
|
||||
//|
|
||||
|
||||
STATIC mp_obj_t usb_midi_portin_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *pos_args) {
|
||||
return mp_const_none;
|
||||
}
|
||||
|
||||
// These are standard stream methods. Code is in py/stream.c.
|
||||
//
|
||||
//| .. method:: read(nbytes=None)
|
||||
//|
|
||||
//| Read characters. If ``nbytes`` is specified then read at most that many
|
||||
//| bytes. Otherwise, read everything that arrives until the connection
|
||||
//| times out. Providing the number of bytes expected is highly recommended
|
||||
//| because it will be faster.
|
||||
//|
|
||||
//| :return: Data read
|
||||
//| :rtype: bytes or None
|
||||
//|
|
||||
//| .. method:: readinto(buf, nbytes=None)
|
||||
//|
|
||||
//| Read bytes into the ``buf``. If ``nbytes`` is specified then read at most
|
||||
//| that many bytes. Otherwise, read at most ``len(buf)`` bytes.
|
||||
//|
|
||||
//| :return: number of bytes read and stored into ``buf``
|
||||
//| :rtype: bytes or None
|
||||
//|
|
||||
|
||||
// These three methods are used by the shared stream methods.
|
||||
STATIC mp_uint_t usb_midi_portin_read(mp_obj_t self_in, void *buf_in, mp_uint_t size, int *errcode) {
|
||||
usb_midi_portin_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
byte *buf = buf_in;
|
||||
|
||||
// make sure we want at least 1 char
|
||||
if (size == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return common_hal_usb_midi_portin_read(self, buf, size, errcode);
|
||||
}
|
||||
|
||||
STATIC mp_uint_t usb_midi_portin_ioctl(mp_obj_t self_in, mp_uint_t request, mp_uint_t arg, int *errcode) {
|
||||
usb_midi_portin_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
mp_uint_t ret;
|
||||
if (request == MP_IOCTL_POLL) {
|
||||
mp_uint_t flags = arg;
|
||||
ret = 0;
|
||||
if ((flags & MP_IOCTL_POLL_RD) && common_hal_usb_midi_portin_bytes_available(self) > 0) {
|
||||
ret |= MP_IOCTL_POLL_RD;
|
||||
}
|
||||
} else {
|
||||
*errcode = MP_EINVAL;
|
||||
ret = MP_STREAM_ERROR;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
STATIC const mp_rom_map_elem_t usb_midi_portin_locals_dict_table[] = {
|
||||
// Standard stream methods.
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_read), MP_ROM_PTR(&mp_stream_read_obj) },
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_readinto), MP_ROM_PTR(&mp_stream_readinto_obj) },
|
||||
};
|
||||
STATIC MP_DEFINE_CONST_DICT(usb_midi_portin_locals_dict, usb_midi_portin_locals_dict_table);
|
||||
|
||||
STATIC const mp_stream_p_t usb_midi_portin_stream_p = {
|
||||
.read = usb_midi_portin_read,
|
||||
.write = NULL,
|
||||
.ioctl = usb_midi_portin_ioctl,
|
||||
.is_text = false,
|
||||
};
|
||||
|
||||
const mp_obj_type_t usb_midi_portin_type = {
|
||||
{ &mp_type_type },
|
||||
.name = MP_QSTR_PortIn,
|
||||
.make_new = usb_midi_portin_make_new,
|
||||
.getiter = mp_identity_getiter,
|
||||
.iternext = mp_stream_unbuffered_iter,
|
||||
.protocol = &usb_midi_portin_stream_p,
|
||||
.locals_dict = (mp_obj_dict_t*)&usb_midi_portin_locals_dict,
|
||||
};
|
44
shared-bindings/usb_midi/PortIn.h
Normal file
44
shared-bindings/usb_midi/PortIn.h
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* This file is part of the Micro Python 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.
|
||||
*/
|
||||
|
||||
#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_USB_MIDI_PORTIN_H
|
||||
#define MICROPY_INCLUDED_SHARED_BINDINGS_USB_MIDI_PORTIN_H
|
||||
|
||||
#include "shared-module/usb_midi/PortIn.h"
|
||||
|
||||
extern const mp_obj_type_t usb_midi_portin_type;
|
||||
|
||||
// Construct an underlying UART object.
|
||||
extern void common_hal_usb_midi_portin_construct(usb_midi_portin_obj_t *self,
|
||||
uint8_t receiver_buffer_size);
|
||||
// Read characters.
|
||||
extern size_t common_hal_usb_midi_portin_read(usb_midi_portin_obj_t *self,
|
||||
uint8_t *data, size_t len, int *errcode);
|
||||
|
||||
extern uint32_t common_hal_usb_midi_portin_bytes_available(usb_midi_portin_obj_t *self);
|
||||
extern void common_hal_usb_midi_portin_clear_buffer(usb_midi_portin_obj_t *self);
|
||||
|
||||
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_USB_MIDI_PORTIN_H
|
110
shared-bindings/usb_midi/PortOut.c
Normal file
110
shared-bindings/usb_midi/PortOut.c
Normal file
@ -0,0 +1,110 @@
|
||||
/*
|
||||
* This file is part of the Micro Python 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 <stdint.h>
|
||||
|
||||
#include "shared-bindings/usb_midi/PortOut.h"
|
||||
#include "shared-bindings/util.h"
|
||||
|
||||
#include "py/ioctl.h"
|
||||
#include "py/objproperty.h"
|
||||
#include "py/runtime.h"
|
||||
#include "py/stream.h"
|
||||
#include "supervisor/shared/translate.h"
|
||||
|
||||
|
||||
//| .. currentmodule:: usb_midi
|
||||
//|
|
||||
//| :class:`PortOut` -- sends midi messages to a computer over USB
|
||||
//| ==============================================================
|
||||
//|
|
||||
//| .. class:: PortOut()
|
||||
//|
|
||||
//| Not currently dynamically supported.
|
||||
//|
|
||||
//| PortOut objects are constructed for every corresponding entry in the USB descriptor and added
|
||||
//| to the ``usb_midi.ports`` tuple.
|
||||
//|
|
||||
|
||||
STATIC mp_obj_t usb_midi_portout_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *pos_args) {
|
||||
return mp_const_none;
|
||||
}
|
||||
|
||||
// These are standard stream methods. Code is in py/stream.c.
|
||||
//
|
||||
//| .. method:: write(buf)
|
||||
//|
|
||||
//| Write the buffer of bytes to the bus.
|
||||
//|
|
||||
//| :return: the number of bytes written
|
||||
//| :rtype: int or None
|
||||
//|
|
||||
|
||||
STATIC mp_uint_t usb_midi_portout_write(mp_obj_t self_in, const void *buf_in, mp_uint_t size, int *errcode) {
|
||||
usb_midi_portout_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
const byte *buf = buf_in;
|
||||
|
||||
return common_hal_usb_midi_portout_write(self, buf, size, errcode);
|
||||
}
|
||||
|
||||
STATIC mp_uint_t usb_midi_portout_ioctl(mp_obj_t self_in, mp_uint_t request, mp_uint_t arg, int *errcode) {
|
||||
usb_midi_portout_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
mp_uint_t ret;
|
||||
if (request == MP_IOCTL_POLL) {
|
||||
mp_uint_t flags = arg;
|
||||
ret = 0;
|
||||
if ((flags & MP_IOCTL_POLL_WR) && common_hal_usb_midi_portout_ready_to_tx(self)) {
|
||||
ret |= MP_IOCTL_POLL_WR;
|
||||
}
|
||||
} else {
|
||||
*errcode = MP_EINVAL;
|
||||
ret = MP_STREAM_ERROR;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
STATIC const mp_rom_map_elem_t usb_midi_portout_locals_dict_table[] = {
|
||||
// Standard stream methods.
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_write), MP_ROM_PTR(&mp_stream_write_obj) },
|
||||
};
|
||||
STATIC MP_DEFINE_CONST_DICT(usb_midi_portout_locals_dict, usb_midi_portout_locals_dict_table);
|
||||
|
||||
STATIC const mp_stream_p_t usb_midi_portout_stream_p = {
|
||||
.read = NULL,
|
||||
.write = usb_midi_portout_write,
|
||||
.ioctl = usb_midi_portout_ioctl,
|
||||
.is_text = false,
|
||||
};
|
||||
|
||||
const mp_obj_type_t usb_midi_portout_type = {
|
||||
{ &mp_type_type },
|
||||
.name = MP_QSTR_PortOut,
|
||||
.make_new = usb_midi_portout_make_new,
|
||||
.getiter = mp_identity_getiter,
|
||||
.iternext = mp_stream_unbuffered_iter,
|
||||
.protocol = &usb_midi_portout_stream_p,
|
||||
.locals_dict = (mp_obj_dict_t*)&usb_midi_portout_locals_dict,
|
||||
};
|
44
shared-bindings/usb_midi/PortOut.h
Normal file
44
shared-bindings/usb_midi/PortOut.h
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* This file is part of the Micro Python 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.
|
||||
*/
|
||||
|
||||
#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_USB_MIDI_PORTOUT_H
|
||||
#define MICROPY_INCLUDED_SHARED_BINDINGS_USB_MIDI_PORTOUT_H
|
||||
|
||||
#include "shared-module/usb_midi/PortOut.h"
|
||||
|
||||
extern const mp_obj_type_t usb_midi_portout_type;
|
||||
|
||||
// Construct an underlying UART object.
|
||||
extern void common_hal_usb_midi_portout_construct(usb_midi_portout_obj_t *self,
|
||||
uint8_t receiver_buffer_size);
|
||||
|
||||
// Write characters. len is in characters NOT bytes!
|
||||
extern size_t common_hal_usb_midi_portout_write(usb_midi_portout_obj_t *self,
|
||||
const uint8_t *data, size_t len, int *errcode);
|
||||
|
||||
extern bool common_hal_usb_midi_portout_ready_to_tx(usb_midi_portout_obj_t *self);
|
||||
|
||||
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_USB_MIDI_PORTOUT_H
|
78
shared-bindings/usb_midi/__init__.c
Normal file
78
shared-bindings/usb_midi/__init__.c
Normal file
@ -0,0 +1,78 @@
|
||||
/*
|
||||
* 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 <stdint.h>
|
||||
|
||||
#include "py/obj.h"
|
||||
#include "py/runtime.h"
|
||||
|
||||
#include "shared-bindings/usb_midi/__init__.h"
|
||||
#include "shared-bindings/usb_midi/PortIn.h"
|
||||
#include "shared-bindings/usb_midi/PortOut.h"
|
||||
|
||||
#include "py/runtime.h"
|
||||
|
||||
//| :mod:`usb_midi` --- MIDI over USB
|
||||
//| =================================================
|
||||
//|
|
||||
//| .. module:: usb_midi
|
||||
//| :synopsis: MIDI over USB
|
||||
//|
|
||||
//| The `usb_midi` module contains classes to transmit and receive MIDI messages over USB
|
||||
//|
|
||||
//| Libraries
|
||||
//|
|
||||
//| .. toctree::
|
||||
//| :maxdepth: 3
|
||||
//|
|
||||
//| PortIn
|
||||
//| PortOut
|
||||
//|
|
||||
//|
|
||||
mp_map_elem_t usb_midi_module_globals_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_usb_midi) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_ports), mp_const_empty_tuple },
|
||||
{ MP_ROM_QSTR(MP_QSTR_PortIn), MP_OBJ_FROM_PTR(&usb_midi_portin_type) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_PortOut), MP_OBJ_FROM_PTR(&usb_midi_portout_type) },
|
||||
};
|
||||
|
||||
// This isn't const so we can set ports dynamically.
|
||||
mp_obj_dict_t usb_midi_module_globals = {
|
||||
.base = {&mp_type_dict},
|
||||
.map = {
|
||||
.all_keys_are_qstrs = 1,
|
||||
.is_fixed = 1,
|
||||
.is_ordered = 1,
|
||||
.used = MP_ARRAY_SIZE(usb_midi_module_globals_table),
|
||||
.alloc = MP_ARRAY_SIZE(usb_midi_module_globals_table),
|
||||
.table = usb_midi_module_globals_table,
|
||||
},
|
||||
};
|
||||
|
||||
const mp_obj_module_t usb_midi_module = {
|
||||
.base = { &mp_type_module },
|
||||
.globals = (mp_obj_dict_t*)&usb_midi_module_globals,
|
||||
};
|
34
shared-bindings/usb_midi/__init__.h
Normal file
34
shared-bindings/usb_midi/__init__.h
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* This file is part of the MicroPython project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2018 Scott Shawcroft
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_USB_MIDI___INIT___H
|
||||
#define MICROPY_INCLUDED_SHARED_BINDINGS_USB_MIDI___INIT___H
|
||||
|
||||
#include "py/obj.h"
|
||||
|
||||
extern mp_obj_dict_t usb_midi_module_globals;
|
||||
|
||||
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_USB_MIDI___INIT___H
|
40
shared-module/usb_midi/PortIn.c
Normal file
40
shared-module/usb_midi/PortIn.c
Normal file
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* 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/usb_midi/PortIn.h"
|
||||
#include "supervisor/shared/translate.h"
|
||||
#include "tusb.h"
|
||||
|
||||
void common_hal_usb_midi_portin_construct(usb_midi_portin_obj_t *self, uint8_t receiver_buffer_size) {
|
||||
}
|
||||
|
||||
size_t common_hal_usb_midi_portin_read(usb_midi_portin_obj_t *self, uint8_t *data, size_t len, int *errcode) {
|
||||
return tud_midi_read(data, len);
|
||||
}
|
||||
|
||||
uint32_t common_hal_usb_midi_portin_bytes_available(usb_midi_portin_obj_t *self) {
|
||||
return tud_midi_available();
|
||||
}
|
39
shared-module/usb_midi/PortIn.h
Normal file
39
shared-module/usb_midi/PortIn.h
Normal file
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef SHARED_MODULE_USB_MIDI_PORTIN_H
|
||||
#define SHARED_MODULE_USB_MIDI_PORTIN_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "py/obj.h"
|
||||
|
||||
typedef struct {
|
||||
mp_obj_base_t base;
|
||||
} usb_midi_portin_obj_t;
|
||||
|
||||
#endif /* SHARED_MODULE_USB_MIDI_PORTIN_H */
|
40
shared-module/usb_midi/PortOut.c
Normal file
40
shared-module/usb_midi/PortOut.c
Normal file
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* 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/usb_midi/PortOut.h"
|
||||
#include "supervisor/shared/translate.h"
|
||||
#include "tusb.h"
|
||||
|
||||
void common_hal_usb_midi_portout_construct(usb_midi_portout_obj_t *self) {
|
||||
}
|
||||
|
||||
size_t common_hal_usb_midi_portout_write(usb_midi_portout_obj_t *self, const uint8_t *data, size_t len, int *errcode) {
|
||||
return tud_midi_write(0, data, len);
|
||||
}
|
||||
|
||||
bool common_hal_usb_midi_portout_ready_to_tx(usb_midi_portout_obj_t *self) {
|
||||
return tud_midi_connected();
|
||||
}
|
39
shared-module/usb_midi/PortOut.h
Normal file
39
shared-module/usb_midi/PortOut.h
Normal file
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef SHARED_MODULE_USB_MIDI_PORTOUT_H
|
||||
#define SHARED_MODULE_USB_MIDI_PORTOUT_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "py/obj.h"
|
||||
|
||||
typedef struct {
|
||||
mp_obj_base_t base;
|
||||
} usb_midi_portout_obj_t;
|
||||
|
||||
#endif /* SHARED_MODULE_USB_MIDI_PORTOUT_H */
|
63
shared-module/usb_midi/__init__.c
Normal file
63
shared-module/usb_midi/__init__.c
Normal file
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* This file is part of the MicroPython 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 "shared-bindings/usb_midi/__init__.h"
|
||||
|
||||
#include "genhdr/autogen_usb_descriptor.h"
|
||||
#include "py/obj.h"
|
||||
#include "py/mphal.h"
|
||||
#include "py/runtime.h"
|
||||
#include "py/objtuple.h"
|
||||
#include "shared-bindings/usb_midi/PortIn.h"
|
||||
#include "shared-bindings/usb_midi/PortOut.h"
|
||||
#include "supervisor/memory.h"
|
||||
#include "tusb.h"
|
||||
|
||||
supervisor_allocation* usb_midi_allocation;
|
||||
|
||||
void usb_midi_init(void) {
|
||||
// TODO(tannewt): Make this dynamic.
|
||||
uint16_t tuple_size = align32_size(sizeof(mp_obj_tuple_t) + sizeof(mp_obj_t*) * 2);
|
||||
uint16_t portin_size = align32_size(sizeof(usb_midi_portin_obj_t));
|
||||
uint16_t portout_size = align32_size(sizeof(usb_midi_portout_obj_t));
|
||||
|
||||
// For each embedded MIDI Jack in the descriptor we create a Port
|
||||
usb_midi_allocation = allocate_memory(tuple_size + portin_size + portout_size, false);
|
||||
|
||||
mp_obj_tuple_t *ports = (mp_obj_tuple_t *) usb_midi_allocation->ptr;
|
||||
ports->base.type = &mp_type_tuple;
|
||||
ports->len = 2;
|
||||
|
||||
usb_midi_portin_obj_t* in = (usb_midi_portin_obj_t *) (usb_midi_allocation->ptr + tuple_size / 4);
|
||||
in->base.type = &usb_midi_portin_type;
|
||||
ports->items[0] = MP_OBJ_FROM_PTR(in);
|
||||
|
||||
usb_midi_portout_obj_t* out = (usb_midi_portout_obj_t *) (usb_midi_allocation->ptr + tuple_size / 4 + portin_size / 4);
|
||||
out->base.type = &usb_midi_portout_type;
|
||||
ports->items[1] = MP_OBJ_FROM_PTR(out);
|
||||
|
||||
mp_map_lookup(&usb_midi_module_globals.map, MP_ROM_QSTR(MP_QSTR_ports), MP_MAP_LOOKUP)->value = MP_OBJ_FROM_PTR(ports);
|
||||
}
|
32
shared-module/usb_midi/__init__.h
Normal file
32
shared-module/usb_midi/__init__.h
Normal file
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef SHARED_MODULE_USB_MIDI___INIT___H
|
||||
#define SHARED_MODULE_USB_MIDI___INIT___H
|
||||
|
||||
void usb_midi_init(void);
|
||||
|
||||
#endif /* SHARED_MODULE_USB_MIDI___INIT___H */
|
@ -39,6 +39,8 @@ typedef struct {
|
||||
uint32_t length; // in bytes
|
||||
} supervisor_allocation;
|
||||
|
||||
|
||||
|
||||
void memory_init(void);
|
||||
void free_memory(supervisor_allocation* allocation);
|
||||
supervisor_allocation* allocate_remaining_memory(void);
|
||||
@ -48,4 +50,11 @@ supervisor_allocation* allocate_remaining_memory(void);
|
||||
// statically allocated memory.
|
||||
supervisor_allocation* allocate_memory(uint32_t length, bool high_address);
|
||||
|
||||
static inline uint16_t align32_size(uint16_t size) {
|
||||
if (size % 4 != 0) {
|
||||
return (size & 0xfffc) + 0x4;
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
#endif // MICROPY_INCLUDED_SUPERVISOR_MEMORY_H
|
||||
|
@ -75,6 +75,7 @@
|
||||
#define CFG_TUD_CDC 1
|
||||
#define CFG_TUD_MSC 1
|
||||
#define CFG_TUD_HID 1
|
||||
#define CFG_TUD_MIDI 1
|
||||
#define CFG_TUD_CUSTOM_CLASS 0
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
#include "tick.h"
|
||||
#include "shared-bindings/microcontroller/Processor.h"
|
||||
#include "shared-module/usb_midi/__init__.h"
|
||||
#include "supervisor/port.h"
|
||||
#include "supervisor/usb.h"
|
||||
#include "lib/utils/interrupt_char.h"
|
||||
@ -71,11 +72,13 @@ void usb_init(void) {
|
||||
// This callback always got invoked regardless of mp_interrupt_char value since we only set it once here
|
||||
tud_cdc_set_wanted_char(CHAR_CTRL_C);
|
||||
#endif
|
||||
|
||||
usb_midi_init();
|
||||
}
|
||||
|
||||
void usb_background(void) {
|
||||
if (usb_enabled()) {
|
||||
tusb_task();
|
||||
tud_task();
|
||||
tud_cdc_write_flush();
|
||||
}
|
||||
}
|
||||
|
@ -49,6 +49,7 @@ else
|
||||
lib/tinyusb/src/class/msc/msc_device.c \
|
||||
lib/tinyusb/src/class/cdc/cdc_device.c \
|
||||
lib/tinyusb/src/class/hid/hid_device.c \
|
||||
lib/tinyusb/src/class/midi/midi_device.c \
|
||||
lib/tinyusb/src/tusb.c \
|
||||
supervisor/shared/serial.c \
|
||||
supervisor/usb.c \
|
||||
@ -57,8 +58,14 @@ else
|
||||
supervisor/shared/usb/usb_msc_flash.c \
|
||||
shared-bindings/usb_hid/__init__.c \
|
||||
shared-bindings/usb_hid/Device.c \
|
||||
shared-bindings/usb_midi/__init__.c \
|
||||
shared-bindings/usb_midi/PortIn.c \
|
||||
shared-bindings/usb_midi/PortOut.c \
|
||||
shared-module/usb_hid/__init__.c \
|
||||
shared-module/usb_hid/Device.c \
|
||||
shared-module/usb_midi/__init__.c \
|
||||
shared-module/usb_midi/PortIn.c \
|
||||
shared-module/usb_midi/PortOut.c \
|
||||
$(BUILD)/autogen_usb_descriptor.c
|
||||
CFLAGS += -DUSB_AVAILABLE
|
||||
endif
|
||||
|
@ -176,16 +176,33 @@ hid_interfaces = [
|
||||
]
|
||||
|
||||
# Audio!
|
||||
midi_in_jack = midi.InJackDescriptor(
|
||||
description="MIDI PC <- CircuitPython internals",
|
||||
# In and out here are relative to CircuitPython
|
||||
|
||||
# USB OUT -> midi_in_jack_emb -> midi_out_jack_ext -> CircuitPython
|
||||
midi_in_jack_emb = midi.InJackDescriptor(
|
||||
description="MIDI PC -> CircuitPython",
|
||||
bJackType=midi.JACK_TYPE_EMBEDDED,
|
||||
iJack=StringIndex.index("CircuitPython usb_midi.ports[0]"))
|
||||
midi_out_jack_ext = midi.OutJackDescriptor(
|
||||
description="MIDI data out to user code.",
|
||||
bJackType=midi.JACK_TYPE_EXTERNAL,
|
||||
input_pins=[(midi_in_jack_emb, 1)],
|
||||
iJack=0)
|
||||
midi_out_jack = midi.OutJackDescriptor(
|
||||
description="MIDI PC -> CircuitPython internals",
|
||||
|
||||
# USB IN <- midi_out_jack_emb <- midi_in_jack_ext <- CircuitPython
|
||||
midi_in_jack_ext = midi.InJackDescriptor(
|
||||
description="MIDI data in from user code.",
|
||||
bJackType=midi.JACK_TYPE_EXTERNAL,
|
||||
iJack=0)
|
||||
midi_out_jack_emb = midi.OutJackDescriptor(
|
||||
description="MIDI PC <- CircuitPython",
|
||||
bJackType=midi.JACK_TYPE_EMBEDDED,
|
||||
iJack=0)
|
||||
input_pins=[(midi_in_jack_ext, 1)],
|
||||
iJack=StringIndex.index("CircuitPython usb_midi.ports[1]"))
|
||||
|
||||
|
||||
audio_midi_interface = standard.InterfaceDescriptor(
|
||||
description="All the audio",
|
||||
description="Midi goodness",
|
||||
bInterfaceClass=audio.AUDIO_CLASS_DEVICE,
|
||||
bInterfaceSubClass=audio.AUDIO_SUBCLASS_MIDI_STREAMING,
|
||||
bInterfaceProtocol=audio.AUDIO_PROTOCOL_V1,
|
||||
@ -193,26 +210,23 @@ audio_midi_interface = standard.InterfaceDescriptor(
|
||||
subdescriptors=[
|
||||
midi.Header(
|
||||
jacks_and_elements=[
|
||||
midi_in_jack,
|
||||
midi.InJackDescriptor(
|
||||
description="MIDI data in from user code.",
|
||||
bJackType=midi.JACK_TYPE_EXTERNAL, iJack=0),
|
||||
midi_out_jack,
|
||||
midi.OutJackDescriptor(
|
||||
description="MIDI data out to user code.",
|
||||
bJackType=midi.JACK_TYPE_EXTERNAL, iJack=0),
|
||||
]
|
||||
midi_in_jack_emb,
|
||||
midi_in_jack_ext,
|
||||
midi_out_jack_emb,
|
||||
midi_out_jack_ext
|
||||
],
|
||||
),
|
||||
standard.EndpointDescriptor(
|
||||
description="MIDI data out",
|
||||
description="MIDI data out to CircuitPython",
|
||||
bEndpointAddress=0x0 | standard.EndpointDescriptor.DIRECTION_OUT,
|
||||
bmAttributes=standard.EndpointDescriptor.TYPE_BULK),
|
||||
midi.DataEndpointDescriptor(baAssocJack=[midi_out_jack]),
|
||||
midi.DataEndpointDescriptor(baAssocJack=[midi_in_jack_emb]),
|
||||
standard.EndpointDescriptor(
|
||||
description="MIDI data in",
|
||||
description="MIDI data in from CircuitPython",
|
||||
bEndpointAddress=0x0 | standard.EndpointDescriptor.DIRECTION_IN,
|
||||
bmAttributes=standard.EndpointDescriptor.TYPE_BULK),
|
||||
midi.DataEndpointDescriptor(baAssocJack=[midi_in_jack]),
|
||||
bmAttributes=standard.EndpointDescriptor.TYPE_BULK,
|
||||
bInterval = 0x0),
|
||||
midi.DataEndpointDescriptor(baAssocJack=[midi_out_jack_emb]),
|
||||
])
|
||||
|
||||
cs_ac_interface = audio10.AudioControlInterface(
|
||||
@ -234,12 +248,12 @@ audio_control_interface = standard.InterfaceDescriptor(
|
||||
])
|
||||
|
||||
# Audio streaming interfaces must occur before MIDI ones.
|
||||
# audio_interfaces = [audio_control_interface] + cs_ac_interface.audio_streaming_interfaces + cs_ac_interface.midi_streaming_interfaces
|
||||
audio_interfaces = [audio_control_interface] + cs_ac_interface.audio_streaming_interfaces + cs_ac_interface.midi_streaming_interfaces
|
||||
|
||||
# This will renumber the endpoints to make them unique across descriptors,
|
||||
# and renumber the interfaces in order. But we still need to fix up certain
|
||||
# interface cross-references.
|
||||
interfaces = util.join_interfaces(cdc_interfaces, msc_interfaces, hid_interfaces)
|
||||
interfaces = util.join_interfaces(cdc_interfaces, msc_interfaces, hid_interfaces, audio_interfaces)
|
||||
|
||||
# Now adjust the CDC interface cross-references.
|
||||
|
||||
@ -256,21 +270,13 @@ cdc_iad = standard.InterfaceAssociationDescriptor(
|
||||
bFunctionSubClass=cdc.CDC_SUBCLASS_ACM, # Abstract control model
|
||||
bFunctionProtocol=cdc.CDC_PROTOCOL_NONE)
|
||||
|
||||
# audio_iad = standard.InterfaceAssociationDescriptor(
|
||||
# description="Audio IAD",
|
||||
# bFirstInterface=audio_control_interface.bInterfaceNumber,
|
||||
# bInterfaceCount=len(audio_interfaces),
|
||||
# bFunctionClass=audio.AUDIO_CLASS_DEVICE,
|
||||
# bFunctionSubClass=audio.AUDIO_SUBCLASS_UNKNOWN,
|
||||
# bFunctionProtocol=audio.AUDIO_PROTOCOL_V1)
|
||||
|
||||
|
||||
descriptor_list = []
|
||||
descriptor_list.append(cdc_iad)
|
||||
# descriptor_list.append(audio_iad)
|
||||
descriptor_list.extend(cdc_interfaces)
|
||||
descriptor_list.extend(msc_interfaces)
|
||||
# descriptor_list.append(audio_control_interface)
|
||||
# Only add the control interface because other audio interfaces are managed by it to ensure the
|
||||
# correct ordering.
|
||||
descriptor_list.append(audio_control_interface)
|
||||
# Put the CDC IAD just before the CDC interfaces.
|
||||
# There appears to be a bug in the Windows composite USB driver that requests the
|
||||
# HID report descriptor with the wrong interface number if the HID interface is not given
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 57bf602dac9cba8c4226f764c286cbc60103d67d
|
||||
Subproject commit e2e79566a807b7230dddbc53a103c19b2f65e2cb
|
Loading…
Reference in New Issue
Block a user