Merge remote-tracking branch 'adafruit/main' into fix_samd_timer_leak
This commit is contained in:
commit
3ffab36cdc
7
.github/workflows/build.yml
vendored
7
.github/workflows/build.yml
vendored
@ -326,11 +326,13 @@ jobs:
|
||||
- "pewpew10"
|
||||
- "pewpew_m4"
|
||||
- "picoplanet"
|
||||
- "pimoroni_interstate75"
|
||||
- "pimoroni_keybow2040"
|
||||
- "pimoroni_pga2040"
|
||||
- "pimoroni_picolipo_16mb"
|
||||
- "pimoroni_picolipo_4mb"
|
||||
- "pimoroni_picosystem"
|
||||
- "pimoroni_plasma2040"
|
||||
- "pimoroni_tiny2040"
|
||||
- "pitaya_go"
|
||||
- "pyb_nano_v2"
|
||||
@ -370,6 +372,7 @@ jobs:
|
||||
- "sparkfun_samd21_mini"
|
||||
- "sparkfun_samd51_micromod"
|
||||
- "sparkfun_samd51_thing_plus"
|
||||
- "sparkfun_stm32f405_micromod"
|
||||
- "sparkfun_thing_plus_rp2040"
|
||||
- "spresense"
|
||||
- "stackrduino_m0_pro"
|
||||
@ -461,7 +464,7 @@ jobs:
|
||||
- name: Install deps
|
||||
run: |
|
||||
sudo apt-get install -y gettext
|
||||
pip install requests sh click setuptools awscli
|
||||
pip install -r requirements-dev.txt
|
||||
wget https://static.dev.sifive.com/dev-tools/riscv64-unknown-elf-gcc-8.3.0-2019.08.0-x86_64-linux-centos6.tar.gz
|
||||
sudo tar -C /usr --strip-components=1 -xaf riscv64-unknown-elf-gcc-8.3.0-2019.08.0-x86_64-linux-centos6.tar.gz
|
||||
- name: Versions
|
||||
@ -503,6 +506,7 @@ jobs:
|
||||
- "adafruit_metro_esp32s2"
|
||||
- "artisense_rd00"
|
||||
- "atmegazero_esp32s2"
|
||||
- "crumpspace_crumps2"
|
||||
- "electroniccats_bastwifi"
|
||||
- "espressif_kaluga_1"
|
||||
- "espressif_kaluga_1.3"
|
||||
@ -516,6 +520,7 @@ jobs:
|
||||
- "gravitech_cucumber_rs"
|
||||
- "lilygo_ttgo_t8_s2_st7789"
|
||||
- "microdev_micro_s2"
|
||||
- "morpheans_morphesp-240"
|
||||
- "muselab_nanoesp32_s2_wroom"
|
||||
- "muselab_nanoesp32_s2_wrover"
|
||||
- "targett_module_clip_wroom"
|
||||
|
@ -21,7 +21,7 @@ besides a text editor (we recommend `Mu <https://codewith.mu/>`_ for beginners.)
|
||||
Starting with CircuitPython 7.0.0, some boards may only be connectable over Bluetooth Low Energy
|
||||
(BLE). Those boards provide serial and file access over BLE instead of USB using open protocols.
|
||||
(Some boards may use both USB and BLE.) BLE access can be done from a variety of apps including
|
||||
`code.circuitpythonn.org <https://code.circuitpython.org>`_.
|
||||
`code.circuitpython.org <https://code.circuitpython.org>`_.
|
||||
|
||||
CircuitPython features unified Python core APIs and a growing list of 300+ device libraries and
|
||||
drivers that work with it. These libraries also work on single board computers with regular
|
||||
|
@ -149,7 +149,7 @@ STATIC int parse_compile_execute(const void *source, mp_parse_input_kind_t input
|
||||
mp_hal_stdout_tx_strn("\x04", 1);
|
||||
}
|
||||
// check for SystemExit
|
||||
if (mp_obj_is_subclass_fast(MP_OBJ_FROM_PTR(((mp_obj_base_t *)nlr.ret_val)->type), MP_OBJ_FROM_PTR(&mp_type_SystemExit))) {
|
||||
if (mp_obj_is_subclass_fast(mp_obj_get_type((mp_obj_t)nlr.ret_val), MP_OBJ_FROM_PTR(&mp_type_SystemExit))) {
|
||||
// at the moment, the value of SystemExit is unused
|
||||
ret = pyexec_system_exit;
|
||||
#if CIRCUITPY_ALARM
|
||||
|
@ -500,6 +500,10 @@ msgstr ""
|
||||
msgid "Attempted heap allocation when VM not running."
|
||||
msgstr ""
|
||||
|
||||
#: ports/raspberrypi/audio_dma.c
|
||||
msgid "Audio conversion not implemented"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/wifi/Radio.c
|
||||
msgid "AuthMode.OPEN is not used with password"
|
||||
msgstr ""
|
||||
@ -1237,6 +1241,10 @@ msgstr "Otentikasi tidak cukup"
|
||||
msgid "Insufficient encryption"
|
||||
msgstr "Enkripsi tidak cukup"
|
||||
|
||||
#: ports/raspberrypi/audio_dma.c
|
||||
msgid "Internal audio buffer too small"
|
||||
msgstr ""
|
||||
|
||||
#: ports/stm/common-hal/busio/UART.c
|
||||
msgid "Internal define error"
|
||||
msgstr "Kesalahan definisi internal"
|
||||
|
@ -493,6 +493,10 @@ msgstr ""
|
||||
msgid "Attempted heap allocation when VM not running."
|
||||
msgstr ""
|
||||
|
||||
#: ports/raspberrypi/audio_dma.c
|
||||
msgid "Audio conversion not implemented"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/wifi/Radio.c
|
||||
msgid "AuthMode.OPEN is not used with password"
|
||||
msgstr ""
|
||||
@ -1217,6 +1221,10 @@ msgstr ""
|
||||
msgid "Insufficient encryption"
|
||||
msgstr ""
|
||||
|
||||
#: ports/raspberrypi/audio_dma.c
|
||||
msgid "Internal audio buffer too small"
|
||||
msgstr ""
|
||||
|
||||
#: ports/stm/common-hal/busio/UART.c
|
||||
msgid "Internal define error"
|
||||
msgstr ""
|
||||
|
@ -496,6 +496,10 @@ msgstr ""
|
||||
msgid "Attempted heap allocation when VM not running."
|
||||
msgstr ""
|
||||
|
||||
#: ports/raspberrypi/audio_dma.c
|
||||
msgid "Audio conversion not implemented"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/wifi/Radio.c
|
||||
msgid "AuthMode.OPEN is not used with password"
|
||||
msgstr ""
|
||||
@ -1220,6 +1224,10 @@ msgstr ""
|
||||
msgid "Insufficient encryption"
|
||||
msgstr ""
|
||||
|
||||
#: ports/raspberrypi/audio_dma.c
|
||||
msgid "Internal audio buffer too small"
|
||||
msgstr ""
|
||||
|
||||
#: ports/stm/common-hal/busio/UART.c
|
||||
msgid "Internal define error"
|
||||
msgstr ""
|
||||
|
@ -502,6 +502,10 @@ msgstr "Versuche %d Blöcke zu allokieren"
|
||||
msgid "Attempted heap allocation when VM not running."
|
||||
msgstr ""
|
||||
|
||||
#: ports/raspberrypi/audio_dma.c
|
||||
msgid "Audio conversion not implemented"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/wifi/Radio.c
|
||||
msgid "AuthMode.OPEN is not used with password"
|
||||
msgstr ""
|
||||
@ -1237,6 +1241,10 @@ msgstr "Unzureichende Authentifizierung"
|
||||
msgid "Insufficient encryption"
|
||||
msgstr "Unzureichende Verschlüsselung"
|
||||
|
||||
#: ports/raspberrypi/audio_dma.c
|
||||
msgid "Internal audio buffer too small"
|
||||
msgstr ""
|
||||
|
||||
#: ports/stm/common-hal/busio/UART.c
|
||||
msgid "Internal define error"
|
||||
msgstr "Interner Definitionsfehler"
|
||||
|
@ -493,6 +493,10 @@ msgstr ""
|
||||
msgid "Attempted heap allocation when VM not running."
|
||||
msgstr ""
|
||||
|
||||
#: ports/raspberrypi/audio_dma.c
|
||||
msgid "Audio conversion not implemented"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/wifi/Radio.c
|
||||
msgid "AuthMode.OPEN is not used with password"
|
||||
msgstr ""
|
||||
@ -1217,6 +1221,10 @@ msgstr ""
|
||||
msgid "Insufficient encryption"
|
||||
msgstr ""
|
||||
|
||||
#: ports/raspberrypi/audio_dma.c
|
||||
msgid "Internal audio buffer too small"
|
||||
msgstr ""
|
||||
|
||||
#: ports/stm/common-hal/busio/UART.c
|
||||
msgid "Internal define error"
|
||||
msgstr ""
|
||||
|
@ -502,6 +502,10 @@ msgstr "Attempt to allocate %d blocks"
|
||||
msgid "Attempted heap allocation when VM not running."
|
||||
msgstr ""
|
||||
|
||||
#: ports/raspberrypi/audio_dma.c
|
||||
msgid "Audio conversion not implemented"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/wifi/Radio.c
|
||||
msgid "AuthMode.OPEN is not used with password"
|
||||
msgstr ""
|
||||
@ -1232,6 +1236,10 @@ msgstr "Insufficient authentication"
|
||||
msgid "Insufficient encryption"
|
||||
msgstr "Insufficient encryption"
|
||||
|
||||
#: ports/raspberrypi/audio_dma.c
|
||||
msgid "Internal audio buffer too small"
|
||||
msgstr ""
|
||||
|
||||
#: ports/stm/common-hal/busio/UART.c
|
||||
msgid "Internal define error"
|
||||
msgstr "Internal define error"
|
||||
|
@ -506,6 +506,10 @@ msgstr "Tratando de localizar %d bloques"
|
||||
msgid "Attempted heap allocation when VM not running."
|
||||
msgstr "Asignación del montículo mientras la VM no esta ejecutándose."
|
||||
|
||||
#: ports/raspberrypi/audio_dma.c
|
||||
msgid "Audio conversion not implemented"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/wifi/Radio.c
|
||||
msgid "AuthMode.OPEN is not used with password"
|
||||
msgstr "AuthMode.OPEN no se usa con contraseña"
|
||||
@ -1250,6 +1254,10 @@ msgstr "Autenticación insuficiente"
|
||||
msgid "Insufficient encryption"
|
||||
msgstr "Cifrado insuficiente"
|
||||
|
||||
#: ports/raspberrypi/audio_dma.c
|
||||
msgid "Internal audio buffer too small"
|
||||
msgstr ""
|
||||
|
||||
#: ports/stm/common-hal/busio/UART.c
|
||||
msgid "Internal define error"
|
||||
msgstr "Error interno de definición"
|
||||
|
@ -496,6 +496,10 @@ msgstr ""
|
||||
msgid "Attempted heap allocation when VM not running."
|
||||
msgstr ""
|
||||
|
||||
#: ports/raspberrypi/audio_dma.c
|
||||
msgid "Audio conversion not implemented"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/wifi/Radio.c
|
||||
msgid "AuthMode.OPEN is not used with password"
|
||||
msgstr ""
|
||||
@ -1232,6 +1236,10 @@ msgstr ""
|
||||
msgid "Insufficient encryption"
|
||||
msgstr ""
|
||||
|
||||
#: ports/raspberrypi/audio_dma.c
|
||||
msgid "Internal audio buffer too small"
|
||||
msgstr ""
|
||||
|
||||
#: ports/stm/common-hal/busio/UART.c
|
||||
msgid "Internal define error"
|
||||
msgstr ""
|
||||
|
@ -508,6 +508,10 @@ msgstr ""
|
||||
"Tentative d'allocation à la pile quand la Machine Virtuelle n'est pas en "
|
||||
"exécution."
|
||||
|
||||
#: ports/raspberrypi/audio_dma.c
|
||||
msgid "Audio conversion not implemented"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/wifi/Radio.c
|
||||
msgid "AuthMode.OPEN is not used with password"
|
||||
msgstr "AuthMode.OPEN n'est pas utilisé avec un mot de passe"
|
||||
@ -1260,6 +1264,10 @@ msgstr "Authentification insuffisante"
|
||||
msgid "Insufficient encryption"
|
||||
msgstr "Chiffrement insuffisant"
|
||||
|
||||
#: ports/raspberrypi/audio_dma.c
|
||||
msgid "Internal audio buffer too small"
|
||||
msgstr ""
|
||||
|
||||
#: ports/stm/common-hal/busio/UART.c
|
||||
msgid "Internal define error"
|
||||
msgstr "Erreur de définition interne"
|
||||
|
@ -493,6 +493,10 @@ msgstr ""
|
||||
msgid "Attempted heap allocation when VM not running."
|
||||
msgstr ""
|
||||
|
||||
#: ports/raspberrypi/audio_dma.c
|
||||
msgid "Audio conversion not implemented"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/wifi/Radio.c
|
||||
msgid "AuthMode.OPEN is not used with password"
|
||||
msgstr ""
|
||||
@ -1217,6 +1221,10 @@ msgstr ""
|
||||
msgid "Insufficient encryption"
|
||||
msgstr ""
|
||||
|
||||
#: ports/raspberrypi/audio_dma.c
|
||||
msgid "Internal audio buffer too small"
|
||||
msgstr ""
|
||||
|
||||
#: ports/stm/common-hal/busio/UART.c
|
||||
msgid "Internal define error"
|
||||
msgstr ""
|
||||
|
@ -505,6 +505,10 @@ msgstr "Provo ad allocare %d blocchi"
|
||||
msgid "Attempted heap allocation when VM not running."
|
||||
msgstr ""
|
||||
|
||||
#: ports/raspberrypi/audio_dma.c
|
||||
msgid "Audio conversion not implemented"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/wifi/Radio.c
|
||||
msgid "AuthMode.OPEN is not used with password"
|
||||
msgstr ""
|
||||
@ -1241,6 +1245,10 @@ msgstr ""
|
||||
msgid "Insufficient encryption"
|
||||
msgstr ""
|
||||
|
||||
#: ports/raspberrypi/audio_dma.c
|
||||
msgid "Internal audio buffer too small"
|
||||
msgstr ""
|
||||
|
||||
#: ports/stm/common-hal/busio/UART.c
|
||||
msgid "Internal define error"
|
||||
msgstr ""
|
||||
|
@ -498,6 +498,10 @@ msgstr "%d個のブロックの確保を試みました"
|
||||
msgid "Attempted heap allocation when VM not running."
|
||||
msgstr ""
|
||||
|
||||
#: ports/raspberrypi/audio_dma.c
|
||||
msgid "Audio conversion not implemented"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/wifi/Radio.c
|
||||
msgid "AuthMode.OPEN is not used with password"
|
||||
msgstr ""
|
||||
@ -1228,6 +1232,10 @@ msgstr "認証が不十分"
|
||||
msgid "Insufficient encryption"
|
||||
msgstr "暗号化が不十分"
|
||||
|
||||
#: ports/raspberrypi/audio_dma.c
|
||||
msgid "Internal audio buffer too small"
|
||||
msgstr ""
|
||||
|
||||
#: ports/stm/common-hal/busio/UART.c
|
||||
msgid "Internal define error"
|
||||
msgstr "内部定義エラー"
|
||||
|
@ -494,6 +494,10 @@ msgstr ""
|
||||
msgid "Attempted heap allocation when VM not running."
|
||||
msgstr ""
|
||||
|
||||
#: ports/raspberrypi/audio_dma.c
|
||||
msgid "Audio conversion not implemented"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/wifi/Radio.c
|
||||
msgid "AuthMode.OPEN is not used with password"
|
||||
msgstr ""
|
||||
@ -1220,6 +1224,10 @@ msgstr ""
|
||||
msgid "Insufficient encryption"
|
||||
msgstr ""
|
||||
|
||||
#: ports/raspberrypi/audio_dma.c
|
||||
msgid "Internal audio buffer too small"
|
||||
msgstr ""
|
||||
|
||||
#: ports/stm/common-hal/busio/UART.c
|
||||
msgid "Internal define error"
|
||||
msgstr ""
|
||||
|
@ -496,6 +496,10 @@ msgstr "Poging om %d blokken toe te wijzen"
|
||||
msgid "Attempted heap allocation when VM not running."
|
||||
msgstr ""
|
||||
|
||||
#: ports/raspberrypi/audio_dma.c
|
||||
msgid "Audio conversion not implemented"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/wifi/Radio.c
|
||||
msgid "AuthMode.OPEN is not used with password"
|
||||
msgstr ""
|
||||
@ -1229,6 +1233,10 @@ msgstr "Onvoldoende authenticatie"
|
||||
msgid "Insufficient encryption"
|
||||
msgstr "Onvoldoende encryptie"
|
||||
|
||||
#: ports/raspberrypi/audio_dma.c
|
||||
msgid "Internal audio buffer too small"
|
||||
msgstr ""
|
||||
|
||||
#: ports/stm/common-hal/busio/UART.c
|
||||
msgid "Internal define error"
|
||||
msgstr "Interne define fout"
|
||||
|
@ -498,6 +498,10 @@ msgstr "Próba przydzielenia %d bloków"
|
||||
msgid "Attempted heap allocation when VM not running."
|
||||
msgstr ""
|
||||
|
||||
#: ports/raspberrypi/audio_dma.c
|
||||
msgid "Audio conversion not implemented"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/wifi/Radio.c
|
||||
msgid "AuthMode.OPEN is not used with password"
|
||||
msgstr ""
|
||||
@ -1228,6 +1232,10 @@ msgstr "Niewystarczające uwierzytelnienie"
|
||||
msgid "Insufficient encryption"
|
||||
msgstr "Niewystarczające szyfrowanie"
|
||||
|
||||
#: ports/raspberrypi/audio_dma.c
|
||||
msgid "Internal audio buffer too small"
|
||||
msgstr ""
|
||||
|
||||
#: ports/stm/common-hal/busio/UART.c
|
||||
msgid "Internal define error"
|
||||
msgstr ""
|
||||
|
@ -6,7 +6,7 @@ msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2021-01-04 12:55-0600\n"
|
||||
"PO-Revision-Date: 2021-08-10 02:41+0000\n"
|
||||
"PO-Revision-Date: 2021-08-13 12:33+0000\n"
|
||||
"Last-Translator: Wellington Terumi Uemura <wellingtonuemura@gmail.com>\n"
|
||||
"Language-Team: \n"
|
||||
"Language: pt_BR\n"
|
||||
@ -507,6 +507,10 @@ msgid "Attempted heap allocation when VM not running."
|
||||
msgstr ""
|
||||
"Tentativa de alocação das pilhas quando o VM não estiver em funcionamento."
|
||||
|
||||
#: ports/raspberrypi/audio_dma.c
|
||||
msgid "Audio conversion not implemented"
|
||||
msgstr "A conversão de áudio ainda não foi implementada"
|
||||
|
||||
#: shared-bindings/wifi/Radio.c
|
||||
msgid "AuthMode.OPEN is not used with password"
|
||||
msgstr "O AuthMode.OPEN não é usado com senha"
|
||||
@ -1251,6 +1255,10 @@ msgstr "Autenticação insuficiente"
|
||||
msgid "Insufficient encryption"
|
||||
msgstr "Criptografia insuficiente"
|
||||
|
||||
#: ports/raspberrypi/audio_dma.c
|
||||
msgid "Internal audio buffer too small"
|
||||
msgstr "O buffer interno de áudio é muito pequeno"
|
||||
|
||||
#: ports/stm/common-hal/busio/UART.c
|
||||
msgid "Internal define error"
|
||||
msgstr "Erro interno de definição"
|
||||
|
10
locale/sv.po
10
locale/sv.po
@ -6,7 +6,7 @@ msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2021-01-04 12:55-0600\n"
|
||||
"PO-Revision-Date: 2021-08-10 02:41+0000\n"
|
||||
"PO-Revision-Date: 2021-08-13 12:33+0000\n"
|
||||
"Last-Translator: Jonny Bergdahl <jonny@bergdahl.it>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"Language: sv\n"
|
||||
@ -501,6 +501,10 @@ msgstr "Försök att tilldela %d block"
|
||||
msgid "Attempted heap allocation when VM not running."
|
||||
msgstr "Försök till heap-allokering när den virtuella maskinen inte är igång."
|
||||
|
||||
#: ports/raspberrypi/audio_dma.c
|
||||
msgid "Audio conversion not implemented"
|
||||
msgstr "Ljudkonvertering inte implementerad"
|
||||
|
||||
#: shared-bindings/wifi/Radio.c
|
||||
msgid "AuthMode.OPEN is not used with password"
|
||||
msgstr "AuthMode.OPEN används inte med lösenord"
|
||||
@ -1236,6 +1240,10 @@ msgstr "Otillräcklig autentisering"
|
||||
msgid "Insufficient encryption"
|
||||
msgstr "Otillräcklig kryptering"
|
||||
|
||||
#: ports/raspberrypi/audio_dma.c
|
||||
msgid "Internal audio buffer too small"
|
||||
msgstr "Intern ljudbuffert för liten"
|
||||
|
||||
#: ports/stm/common-hal/busio/UART.c
|
||||
msgid "Internal define error"
|
||||
msgstr "Internt define-fel"
|
||||
|
@ -503,6 +503,10 @@ msgstr "cháng shì fēn pèi %d kuài"
|
||||
msgid "Attempted heap allocation when VM not running."
|
||||
msgstr "dāng VM bú yùn xíng shí, cháng shì duī fēn pèi."
|
||||
|
||||
#: ports/raspberrypi/audio_dma.c
|
||||
msgid "Audio conversion not implemented"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/wifi/Radio.c
|
||||
msgid "AuthMode.OPEN is not used with password"
|
||||
msgstr "AuthMode.OPEN wèi shǐ yòng mì mǎ"
|
||||
@ -1239,6 +1243,10 @@ msgstr "Rènzhèng bùzú"
|
||||
msgid "Insufficient encryption"
|
||||
msgstr "Jiāmì bùzú"
|
||||
|
||||
#: ports/raspberrypi/audio_dma.c
|
||||
msgid "Internal audio buffer too small"
|
||||
msgstr ""
|
||||
|
||||
#: ports/stm/common-hal/busio/UART.c
|
||||
msgid "Internal define error"
|
||||
msgstr "Nèibù dìngyì cuòwù"
|
||||
|
@ -157,7 +157,13 @@ void audio_dma_load_next_block(audio_dma_t *dma) {
|
||||
if (dma->loop) {
|
||||
audiosample_reset_buffer(dma->sample, dma->single_channel_output, dma->audio_channel);
|
||||
} else {
|
||||
descriptor->DESCADDR.reg = 0;
|
||||
if ((output_buffer_length == 0) && dma_transfer_status(SHARED_RX_CHANNEL) & 0x3) {
|
||||
// Nothing further to read and previous buffer is finished.
|
||||
audio_dma_stop(dma);
|
||||
} else {
|
||||
// Break descriptor chain.
|
||||
descriptor->DESCADDR.reg = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
descriptor->BTCTRL.bit.VALID = true;
|
||||
@ -214,21 +220,23 @@ audio_dma_result audio_dma_setup_playback(audio_dma_t *dma,
|
||||
if (output_signed != samples_signed) {
|
||||
output_spacing = 1;
|
||||
max_buffer_length /= dma->spacing;
|
||||
dma->first_buffer = (uint8_t *)m_realloc(dma->first_buffer, max_buffer_length);
|
||||
if (dma->first_buffer == NULL) {
|
||||
}
|
||||
|
||||
dma->first_buffer = (uint8_t *)m_realloc(dma->first_buffer, max_buffer_length);
|
||||
if (dma->first_buffer == NULL) {
|
||||
return AUDIO_DMA_MEMORY_ERROR;
|
||||
}
|
||||
dma->first_buffer_free = true;
|
||||
if (!single_buffer) {
|
||||
dma->second_buffer = (uint8_t *)m_realloc(dma->second_buffer, max_buffer_length);
|
||||
if (dma->second_buffer == NULL) {
|
||||
return AUDIO_DMA_MEMORY_ERROR;
|
||||
}
|
||||
dma->first_buffer_free = true;
|
||||
if (!single_buffer) {
|
||||
dma->second_buffer = (uint8_t *)m_realloc(dma->second_buffer, max_buffer_length);
|
||||
if (dma->second_buffer == NULL) {
|
||||
return AUDIO_DMA_MEMORY_ERROR;
|
||||
}
|
||||
}
|
||||
dma->signed_to_unsigned = !output_signed && samples_signed;
|
||||
dma->unsigned_to_signed = output_signed && !samples_signed;
|
||||
}
|
||||
|
||||
dma->signed_to_unsigned = !output_signed && samples_signed;
|
||||
dma->unsigned_to_signed = output_signed && !samples_signed;
|
||||
|
||||
dma->event_channel = 0xff;
|
||||
if (!single_buffer) {
|
||||
dma->second_descriptor = (DmacDescriptor *)m_malloc(sizeof(DmacDescriptor), false);
|
||||
@ -265,13 +273,13 @@ audio_dma_result audio_dma_setup_playback(audio_dma_t *dma,
|
||||
|
||||
#ifdef SAM_D5X_E5X
|
||||
int irq = dma->event_channel < 4 ? EVSYS_0_IRQn + dma->event_channel : EVSYS_4_IRQn;
|
||||
// Only disable and clear on SAMD51 because the SAMD21 shares EVSYS with ticks.
|
||||
NVIC_DisableIRQ(irq);
|
||||
NVIC_ClearPendingIRQ(irq);
|
||||
#else
|
||||
int irq = EVSYS_IRQn;
|
||||
#endif
|
||||
|
||||
NVIC_DisableIRQ(irq);
|
||||
NVIC_ClearPendingIRQ(irq);
|
||||
|
||||
DmacDescriptor *first_descriptor = dma_descriptor(dma_channel);
|
||||
setup_audio_descriptor(first_descriptor, dma->beat_size, output_spacing, output_register_address);
|
||||
if (single_buffer) {
|
||||
@ -366,7 +374,7 @@ STATIC void dma_callback_fun(void *arg) {
|
||||
audio_dma_load_next_block(dma);
|
||||
}
|
||||
|
||||
void evsyshandler_common(void) {
|
||||
void audio_evsys_handler(void) {
|
||||
for (uint8_t i = 0; i < AUDIO_DMA_CHANNEL_COUNT; i++) {
|
||||
audio_dma_t *dma = audio_dma_state[i];
|
||||
if (dma == NULL) {
|
||||
@ -380,26 +388,4 @@ void evsyshandler_common(void) {
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef SAM_D5X_E5X
|
||||
void EVSYS_0_Handler(void) {
|
||||
evsyshandler_common();
|
||||
}
|
||||
void EVSYS_1_Handler(void) {
|
||||
evsyshandler_common();
|
||||
}
|
||||
void EVSYS_2_Handler(void) {
|
||||
evsyshandler_common();
|
||||
}
|
||||
void EVSYS_3_Handler(void) {
|
||||
evsyshandler_common();
|
||||
}
|
||||
void EVSYS_4_Handler(void) {
|
||||
evsyshandler_common();
|
||||
}
|
||||
#else
|
||||
void EVSYS_Handler(void) {
|
||||
evsyshandler_common();
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -99,4 +99,6 @@ void audio_dma_background(void);
|
||||
|
||||
uint8_t find_sync_event_channel_raise(void);
|
||||
|
||||
void audio_evsys_handler(void);
|
||||
|
||||
#endif // MICROPY_INCLUDED_ATMEL_SAMD_AUDIO_DMA_H
|
||||
|
@ -2,6 +2,7 @@
|
||||
#define MICROPY_HW_MCU_NAME "samd21e18"
|
||||
|
||||
#define MICROPY_HW_NEOPIXEL (&pin_PA15)
|
||||
#define MICROPY_HW_NEOPIXEL_COUNT (2)
|
||||
|
||||
#define IGNORE_PIN_PA01 1
|
||||
#define IGNORE_PIN_PA02 1
|
||||
|
@ -14,6 +14,7 @@ CIRCUITPY_FULL_BUILD = 0
|
||||
CIRCUITPY_ANALOGIO = 0
|
||||
CIRCUITPY_AUDIOCORE = 0
|
||||
CIRCUITPY_BUSIO_SPI = 0
|
||||
CIRCUITPY_BUSIO_UART = 0
|
||||
CIRCUITPY_PULSEIO = 0
|
||||
CIRCUITPY_PWMIO = 0
|
||||
CIRCUITPY_ROTARYIO = 0
|
||||
|
@ -16,3 +16,16 @@
|
||||
// USB is always used internally so skip the pin objects for it.
|
||||
#define IGNORE_PIN_PA24 1
|
||||
#define IGNORE_PIN_PA25 1
|
||||
// USD ID
|
||||
#define IGNORE_PIN_PA18 1
|
||||
|
||||
// Hooked to the external crystal
|
||||
#define IGNORE_PIN_PA00 1
|
||||
#define IGNORE_PIN_PA01 1
|
||||
|
||||
// SWD only
|
||||
#define IGNORE_PIN_PA30 1
|
||||
#define IGNORE_PIN_PA31 1
|
||||
|
||||
// Not connected
|
||||
#define IGNORE_PIN_PA28 1
|
||||
|
@ -16,3 +16,11 @@
|
||||
// USB is always used internally so skip the pin objects for it.
|
||||
#define IGNORE_PIN_PA24 1
|
||||
#define IGNORE_PIN_PA25 1
|
||||
|
||||
// Not connected
|
||||
#define IGNORE_PIN_PA00 1
|
||||
#define IGNORE_PIN_PA01 1
|
||||
|
||||
// SWD only
|
||||
#define IGNORE_PIN_PA30 1
|
||||
#define IGNORE_PIN_PA31 1
|
||||
|
@ -1,8 +1,11 @@
|
||||
#define MICROPY_HW_BOARD_NAME "SparkFun MicroMod SAMD51"
|
||||
#define MICROPY_HW_BOARD_NAME "SparkFun MicroMod SAMD51 Processor"
|
||||
#define MICROPY_HW_MCU_NAME "samd51j20"
|
||||
|
||||
#define CIRCUITPY_MCU_FAMILY samd51
|
||||
|
||||
// Status LED
|
||||
#define MICROPY_HW_LED_STATUS (&pin_PA23)
|
||||
|
||||
// On-board flash
|
||||
#define SPI_FLASH_MOSI_PIN &pin_PA09
|
||||
#define SPI_FLASH_MISO_PIN &pin_PA10
|
||||
|
@ -1,7 +1,7 @@
|
||||
LD_FILE = boards/samd51x20-bootloader-external-flash.ld
|
||||
USB_VID = 0x1b4f
|
||||
USB_PID = 0x0020 # Used by uf2 bootloader
|
||||
USB_PRODUCT = "SparkFun MicroMod SAMD51"
|
||||
USB_PRODUCT = "SparkFun MicroMod SAMD51 Processor"
|
||||
USB_MANUFACTURER = "SparkFun Electronics"
|
||||
|
||||
CHIP_VARIANT = SAMD51J20A
|
||||
|
@ -1,97 +1,224 @@
|
||||
/*
|
||||
* 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) 2021 Chris Wilson
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "shared-bindings/board/__init__.h"
|
||||
|
||||
STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
|
||||
// D (digital only) pins (D0,D1)
|
||||
{ MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_PB04) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_PB05) },
|
||||
// The SparkFun MicroMod spec uses a zero-based peripheral numbering scheme.
|
||||
// The 0th peripheral is the default and the "0" is omitted from the
|
||||
// peripheral name (e.g. "I2C" instead of "I2C0").
|
||||
//
|
||||
// For more details, see https://www.sparkfun.com/micromod#tech-specs
|
||||
|
||||
// A (ADC) pins (A0-A4)
|
||||
{ MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA02) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PB00) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_PB01) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_PB02) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_PB03) },
|
||||
// MicroMod built-in status LED pin
|
||||
// Requirement from the "Designing with MicroMod" SparkFun article:
|
||||
// "... every Processor Board shall include one status LED connected to a
|
||||
// pin that is not connected to the board edge."
|
||||
{ MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_PA23) }, // MicroMod LED (PA23)
|
||||
|
||||
// DAC
|
||||
{ MP_ROM_QSTR(MP_QSTR_DAC), MP_ROM_PTR(&pin_PA02) },
|
||||
// MicroMod USB bus input voltage (+5V) pin
|
||||
// { MP_ROM_QSTR(MP_QSTR_USB_VIN), MP_ROM_PTR() }, // MicroMod USB_VIN (not connected)
|
||||
|
||||
// G (General/BUS) pins (G0-G9)
|
||||
{ MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_PA06) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_G0), MP_ROM_PTR(&pin_PA06) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_PA15) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_G1), MP_ROM_PTR(&pin_PA06) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_PB08) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_G2), MP_ROM_PTR(&pin_PB08) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_PB09) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_G3), MP_ROM_PTR(&pin_PB09) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PB10) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_G4), MP_ROM_PTR(&pin_PB10) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_PB11) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_G5), MP_ROM_PTR(&pin_PB11) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_PB12) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_G6), MP_ROM_PTR(&pin_PB12) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_PB13) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_G7), MP_ROM_PTR(&pin_PB13) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_PA14) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_G8), MP_ROM_PTR(&pin_PA14) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_PA15) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_G9), MP_ROM_PTR(&pin_PA15) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_D32), MP_ROM_PTR(&pin_PB31) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_D33), MP_ROM_PTR(&pin_PB30) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_D38), MP_ROM_PTR(&pin_PB14) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_G10), MP_ROM_PTR(&pin_PB14) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_D39), MP_ROM_PTR(&pin_PB15) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_G11), MP_ROM_PTR(&pin_PB15) },
|
||||
// MicroMod +3.3V enable pin
|
||||
{ MP_ROM_QSTR(MP_QSTR_P3V3_EN), MP_ROM_PTR(&pin_PA19) }, // MicroMod 3.3V_EN (PA19)
|
||||
|
||||
// PWM pins (PWM0, PWM1)
|
||||
{ MP_ROM_QSTR(MP_QSTR_PWM0), MP_ROM_PTR(&pin_PB01) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_PWM1), MP_ROM_PTR(&pin_PB02) },
|
||||
// MicroMod battery voltage sense pin
|
||||
{ MP_ROM_QSTR(MP_QSTR_BATT_VIN3), MP_ROM_PTR(&pin_PB03) }, // MicroMod BATT_VIN/3 (PB03)
|
||||
|
||||
// AUD (audio)
|
||||
{ MP_ROM_QSTR(MP_QSTR_AUD_MCLK), MP_ROM_PTR(&pin_PB17) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_AUD_OUT), MP_ROM_PTR(&pin_PA21) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_AUD_IN), MP_ROM_PTR(&pin_PA22) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_AUD_LRCLK), MP_ROM_PTR(&pin_PA20) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_AUD_BCLK), MP_ROM_PTR(&pin_PB16) },
|
||||
// MicroMod reset pin
|
||||
// { MP_ROM_QSTR(MP_QSTR_RESET), MP_ROM_PTR() }, // MicroMod RESET# (SAMD51 has a dedicated HW RESETN pin)
|
||||
|
||||
// I2C
|
||||
{ MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PA17) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_SDA1), MP_ROM_PTR(&pin_PA17) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PA16) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_SCL1), MP_ROM_PTR(&pin_PA16) },
|
||||
// MicroMod boot pin
|
||||
// { MP_ROM_QSTR(MP_QSTR_BOOT), MP_ROM_PTR() }, // MicroMod BOOT (not connected)
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_I2C_INT), MP_ROM_PTR(&pin_PA18) },
|
||||
// MicroMod USB device pins
|
||||
// USB device is always used internally by CircuitPython, so skip creating
|
||||
// the pin objects for it. See explicit ignores in mpconfigboard.h.
|
||||
// { MP_ROM_QSTR(MP_QSTR_USB_DM), MP_ROM_PTR(&pin_PA24) }, // MicroMod USB_D- (PA24)
|
||||
// { MP_ROM_QSTR(MP_QSTR_USB_DP), MP_ROM_PTR(&pin_PA25) }, // MicroMod USB_D+ (PA25)
|
||||
|
||||
// I2C2
|
||||
{ MP_ROM_QSTR(MP_QSTR_SDA2), MP_ROM_PTR(&pin_PA13) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_SCL2), MP_ROM_PTR(&pin_PA12) },
|
||||
// MicroMod USB host pins
|
||||
// { MP_ROM_QSTR(MP_QSTR_USBHOST_DM), MP_ROM_PTR() }, // MicroMod USBHOST_D- (not connected)
|
||||
// { MP_ROM_QSTR(MP_QSTR_USBHOST_DP), MP_ROM_PTR() }, // MicroMod USBHOST_D+ (not connected)
|
||||
|
||||
// SPI
|
||||
{ MP_ROM_QSTR(MP_QSTR_CIPO), MP_ROM_PTR(&pin_PA06) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PA06) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_COPI), MP_ROM_PTR(&pin_PA04) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PA04) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PA05) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_CS), MP_ROM_PTR(&pin_PA07) },
|
||||
// MicroMod CAN pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_CAN_RX), MP_ROM_PTR(&pin_PB15) }, // MicroMod CAN_RX (PB15)
|
||||
{ MP_ROM_QSTR(MP_QSTR_CAN_TX), MP_ROM_PTR(&pin_PB14) }, // MicroMod CAN_TX (PB14)
|
||||
|
||||
// Status LED
|
||||
{ MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_PA23) },
|
||||
// Note: MicroMod UART (UART0) is not present in the edge connector pinout
|
||||
// because the primary debug serial port is exposed as a virtual serial port
|
||||
// over USB.
|
||||
|
||||
// UART
|
||||
{ MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PB30) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_RX1), MP_ROM_PTR(&pin_PB30) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PB31) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_TX1), MP_ROM_PTR(&pin_PB31) },
|
||||
// MicroMod UART1 pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_UART_TX1), MP_ROM_PTR(&pin_PB31) }, // MicroMod UART_TX1 | CircuitPython TX (PB31)
|
||||
{ MP_ROM_QSTR(MP_QSTR_UART_RX1), MP_ROM_PTR(&pin_PB30) }, // MicroMod UART_RX1 | CircuitPython RX (PB30)
|
||||
// { MP_ROM_QSTR(MP_QSTR_UART_RTS1), MP_ROM_PTR() }, // MicroMod RTS1 (not connected)
|
||||
// { MP_ROM_QSTR(MP_QSTR_UART_CTS1), MP_ROM_PTR() }, // MicroMod CTS1 (not connected)
|
||||
|
||||
// UART2
|
||||
{ MP_ROM_QSTR(MP_QSTR_RX2), MP_ROM_PTR(&pin_PA13) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_TX2), MP_ROM_PTR(&pin_PA12) },
|
||||
// CircuitPython default UART pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PB31) }, // CircuitPython TX | MicroMod UART_TX1 (PB31)
|
||||
{ MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PB30) }, // CircuitPython RX | MicroMod UART_RX1 (PB30)
|
||||
|
||||
// MicroMod UART2 pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_UART_TX2), MP_ROM_PTR(&pin_PA12) }, // MicroMod UART_TX2 (PA12)
|
||||
{ MP_ROM_QSTR(MP_QSTR_UART_RX2), MP_ROM_PTR(&pin_PA13) }, // MicroMod UART_RX2 (PA13)
|
||||
|
||||
// Board 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) },
|
||||
// MicroMod I2C pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_I2C_SDA), MP_ROM_PTR(&pin_PA17) }, // MicroMod I2C_SDA | CircuitPython SDA (PA17)
|
||||
{ MP_ROM_QSTR(MP_QSTR_I2C_SCL), MP_ROM_PTR(&pin_PA16) }, // MicroMod I2C_SCL | CircuitPython SCL (PA16)
|
||||
|
||||
// CircuitPython default I2C pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PA17) }, // CircuitPython SDA | MicroMod I2C_SDA (PA17)
|
||||
{ MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PA16) }, // CircuitPython SCL | MicroMod I2C_SCL (PA16)
|
||||
|
||||
// MicroMod I2C interrupt pin
|
||||
{ MP_ROM_QSTR(MP_QSTR_I2C_INT), MP_ROM_PTR(&pin_PA18) }, // MicroMod I2C_INT (PA18)
|
||||
|
||||
// MicroMod I2C1 pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_I2C_SDA1), MP_ROM_PTR(&pin_PA13) }, // MicroMod I2C_SDA1 (PA13)
|
||||
{ MP_ROM_QSTR(MP_QSTR_I2C_SCL1), MP_ROM_PTR(&pin_PA12) }, // MicroMod I2C_SCL1 (PA12)
|
||||
|
||||
// MicroMod SPI pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_SPI_CIPO), MP_ROM_PTR(&pin_PA06) }, // MicroMod SPI_CIPO | CircuitPython CIPO (PA06)
|
||||
{ MP_ROM_QSTR(MP_QSTR_SPI_MISO), MP_ROM_PTR(&pin_PA06) }, // MicroMod SPI_MISO | CircuitPython MISO (PA06)
|
||||
{ MP_ROM_QSTR(MP_QSTR_SPI_COPI), MP_ROM_PTR(&pin_PA04) }, // MicroMod SPI_COPI | CircuitPython COPI | LED_DAT (PA04)
|
||||
{ MP_ROM_QSTR(MP_QSTR_SPI_MOSI), MP_ROM_PTR(&pin_PA04) }, // MicroMod SPI_MOSI | CircuitPython MOSI (PA04)
|
||||
{ MP_ROM_QSTR(MP_QSTR_SPI_SCK), MP_ROM_PTR(&pin_PA05) }, // MicroMod SPI_SCK | CircuitPython SCK | LED_CLK (PA05)
|
||||
{ MP_ROM_QSTR(MP_QSTR_SPI_CS), MP_ROM_PTR(&pin_PA07) }, // MicroMod SPI_CS | CircuitPython CS (PA07)
|
||||
|
||||
// CircuitPython default SPI pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_CIPO), MP_ROM_PTR(&pin_PA06) }, // CircuitPython CIPO | MicroMod SPI_CIPO (PA06)
|
||||
{ MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PA06) }, // CircuitPython MISO | MicroMod SPI_MISO (PA06)
|
||||
{ MP_ROM_QSTR(MP_QSTR_COPI), MP_ROM_PTR(&pin_PA04) }, // CircuitPython COPI | MicroMod SPI_COPI | LED_DAT (PA04)
|
||||
{ MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PA04) }, // CircuitPython MOSI | MicroMod SPI_MOSI (PA04)
|
||||
{ MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PA05) }, // CircuitPython SCK | MicroMod SPI_SCK | LED_CLK (PA05)
|
||||
{ MP_ROM_QSTR(MP_QSTR_CS), MP_ROM_PTR(&pin_PA07) }, // CircuitPython CS | MicroMod SPI_CS (PA07)
|
||||
|
||||
// MicroMod 2-wire serial LED pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_LED_DAT), MP_ROM_PTR(&pin_PA04) }, // MicroMod LED_DAT | SPI_COPI (PA04)
|
||||
{ MP_ROM_QSTR(MP_QSTR_LED_CLK), MP_ROM_PTR(&pin_PA05) }, // MicroMod LED_CLK | SPI_SCK (PA05)
|
||||
|
||||
// MicroMod SDIO pins
|
||||
// { MP_ROM_QSTR(MP_QSTR_SDIO_CLK), MP_ROM_PTR() }, // MicroMod SDIO_SCK | SPI_SCK1 (not connected)
|
||||
// { MP_ROM_QSTR(MP_QSTR_SDIO_CMD), MP_ROM_PTR() }, // MicroMod SDIO_CMD | SPI_COPI1 (not connected)
|
||||
// { MP_ROM_QSTR(MP_QSTR_SDIO_DATA0), MP_ROM_PTR() }, // MicroMod SDIO_DATA0 | SPI_CIPO1 (not connected)
|
||||
// { MP_ROM_QSTR(MP_QSTR_SDIO_DATA1), MP_ROM_PTR() }, // MicroMod SDIO_DATA1 (not connected)
|
||||
// { MP_ROM_QSTR(MP_QSTR_SDIO_DATA2), MP_ROM_PTR() }, // MicroMod SDIO_DATA2 (not connected)
|
||||
// { MP_ROM_QSTR(MP_QSTR_SDIO_DATA3), MP_ROM_PTR() }, // MicroMod SDIO_DATA3 | SPI_CS1 (not connected)
|
||||
|
||||
// MicroMod SPI1 pins
|
||||
// { MP_ROM_QSTR(MP_QSTR_SPI_CIPO1), MP_ROM_PTR() }, // MicroMod SPI_CIPO1 | SDIO_DATA0 (not connected)
|
||||
// { MP_ROM_QSTR(MP_QSTR_SPI_MISO1), MP_ROM_PTR() }, // MicroMod SPI_MISO1 (not connected)
|
||||
// { MP_ROM_QSTR(MP_QSTR_SPI_COPI1), MP_ROM_PTR() }, // MicroMod SPI_COPI1 | SDIO_CMD (not connected)
|
||||
// { MP_ROM_QSTR(MP_QSTR_SPI_MOSI1), MP_ROM_PTR() }, // MicroMod SPI_MOSI1 (not connected)
|
||||
// { MP_ROM_QSTR(MP_QSTR_SPI_SCK1), MP_ROM_PTR() }, // MicroMod SPI_SCK1 | SDIO_SCK (not connected)
|
||||
// { MP_ROM_QSTR(MP_QSTR_SPI_CS1), MP_ROM_PTR() }, // MicroMod SPI_CS1 | SDIO_DATA3 (not connected)
|
||||
|
||||
// MicroMod audio pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_AUD_MCLK), MP_ROM_PTR(&pin_PB17) }, // MicroMod AUD_MCLK (PB17)
|
||||
{ MP_ROM_QSTR(MP_QSTR_AUD_OUT), MP_ROM_PTR(&pin_PA21) }, // MicroMod AUD_OUT | I2S_OUT | PCM_OUT | CAM_MCLK (PA21)
|
||||
{ MP_ROM_QSTR(MP_QSTR_AUD_IN), MP_ROM_PTR(&pin_PA22) }, // MicroMod AUD_IN | I2S_IN | PCM_IN | CAM_PCLK (PA22)
|
||||
{ MP_ROM_QSTR(MP_QSTR_AUD_LRCLK), MP_ROM_PTR(&pin_PA20) }, // MicroMod AUD_LRCLK | I2S_WS | PCM_SYNC | PDM_DATA (PA20)
|
||||
{ MP_ROM_QSTR(MP_QSTR_AUD_BCLK), MP_ROM_PTR(&pin_PB16) }, // MicroMod AUD_BCLK | I2S_SCK | PCM_CLK | PDM_CLK (PB16)
|
||||
|
||||
// MicroMod I2S pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_I2S_OUT), MP_ROM_PTR(&pin_PA21) }, // MicroMod I2S_OUT | AUD_OUT | PCM_OUT | CAM_MCLK (PA21)
|
||||
{ MP_ROM_QSTR(MP_QSTR_I2S_IN), MP_ROM_PTR(&pin_PA22) }, // MicroMod I2S_IN | AUD_IN | PCM_IN | CAM_PCLK (PA22)
|
||||
{ MP_ROM_QSTR(MP_QSTR_I2S_WS), MP_ROM_PTR(&pin_PA20) }, // MicroMod I2S_WS | AUD_LRCLK | PCM_SYNC | PDM_DATA (PA20)
|
||||
{ MP_ROM_QSTR(MP_QSTR_I2S_SCK), MP_ROM_PTR(&pin_PB16) }, // MicroMod I2S_SCK | AUD_BCLK | PCM_CLK | PDM_CLK (PB16)
|
||||
|
||||
// MicroMod PCM pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_PCM_OUT), MP_ROM_PTR(&pin_PA21) }, // MicroMod PCM_OUT | AUD_OUT | I2S_OUT | CAM_MCLK (PA21)
|
||||
{ MP_ROM_QSTR(MP_QSTR_PCM_IN), MP_ROM_PTR(&pin_PA22) }, // MicroMod PCM_IN | AUD_IN | I2S_IN | CAM_PCLK (PA22)
|
||||
{ MP_ROM_QSTR(MP_QSTR_PCM_SYNC), MP_ROM_PTR(&pin_PA20) }, // MicroMod PCM_SYNC | AUD_LRCLK | I2S_WS | PDM_DATA (PA20)
|
||||
{ MP_ROM_QSTR(MP_QSTR_PCM_CLK), MP_ROM_PTR(&pin_PB16) }, // MicroMod PCM_CLK | AUD_BCLK | I2S_SCK | PDM_CLK (PB16)
|
||||
|
||||
// MicroMod PDM pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_PDM_DATA), MP_ROM_PTR(&pin_PA20) }, // MicroMod PDM_DATA | AUD_LRCLK | I2S_WS | PCM_SYNC (PA20)
|
||||
{ MP_ROM_QSTR(MP_QSTR_PDM_CLK), MP_ROM_PTR(&pin_PB16) }, // MicroMod PDM_CLK | AUD_BCLK | I2S_SCK | PCM_CLK (PB16)
|
||||
|
||||
// MicroMod SWD pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_SWDIO), MP_ROM_PTR(&pin_PA31) }, // MicroMod SWDIO (PA31)
|
||||
{ MP_ROM_QSTR(MP_QSTR_SWCLK), MP_ROM_PTR(&pin_PA30) }, // MicroMod SWDCK (PA30)
|
||||
// { MP_ROM_QSTR(MP_QSTR_SWO), MP_ROM_PTR() }, // MicroMod SWO | G11 (not connected)
|
||||
|
||||
// MicroMod ADC pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PA02) }, // MicroMod A0 (PA02)
|
||||
{ MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PB00) }, // MicroMod A1 (PB00)
|
||||
|
||||
// MicroMod PWM pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_PWM0), MP_ROM_PTR(&pin_PB01) }, // MicroMod PWM0 (PB01)
|
||||
{ MP_ROM_QSTR(MP_QSTR_PWM1), MP_ROM_PTR(&pin_PB02) }, // MicroMod PWM1 (PB02)
|
||||
|
||||
// MicroMod digital pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_PB04) }, // MicroMod D0 (PB04)
|
||||
{ MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_PB05) }, // MicroMod D1 | CAM_TRIG (PB05)
|
||||
|
||||
// MicroMod general purpose pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_G0), MP_ROM_PTR(&pin_PB06) }, // MicroMod G0 | BUS0 (PB06)
|
||||
{ MP_ROM_QSTR(MP_QSTR_G1), MP_ROM_PTR(&pin_PB07) }, // MicroMod G1 | BUS1 (PB07)
|
||||
{ MP_ROM_QSTR(MP_QSTR_G2), MP_ROM_PTR(&pin_PB08) }, // MicroMod G2 | BUS2 (PB08)
|
||||
{ MP_ROM_QSTR(MP_QSTR_G3), MP_ROM_PTR(&pin_PB09) }, // MicroMod G3 | BUS3 (PB09)
|
||||
{ MP_ROM_QSTR(MP_QSTR_G4), MP_ROM_PTR(&pin_PB10) }, // MicroMod G4 | BUS4 (PB10)
|
||||
{ MP_ROM_QSTR(MP_QSTR_G5), MP_ROM_PTR(&pin_PB11) }, // MicroMod G5 | BUS5 (PB11)
|
||||
{ MP_ROM_QSTR(MP_QSTR_G6), MP_ROM_PTR(&pin_PB12) }, // MicroMod G6 | BUS6 (PB12)
|
||||
{ MP_ROM_QSTR(MP_QSTR_G7), MP_ROM_PTR(&pin_PB13) }, // MicroMod G7 | BUS7 (PB13)
|
||||
{ MP_ROM_QSTR(MP_QSTR_G8), MP_ROM_PTR(&pin_PA14) }, // MicroMod G8 (PA14)
|
||||
{ MP_ROM_QSTR(MP_QSTR_G9), MP_ROM_PTR(&pin_PA15) }, // MicroMod G9 | ADC_D- | CAM_HSYNC (PA15)
|
||||
// { MP_ROM_QSTR(MP_QSTR_G10), MP_ROM_PTR() }, // MicroMod G10 | ADC_D+ | CAM_VSYNC (not connected)
|
||||
{ MP_ROM_QSTR(MP_QSTR_G11), MP_ROM_PTR(&pin_PA27) }, // MicroMod G11 | SWO (PA27)
|
||||
|
||||
// MicroMod 8-bit bus pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_BUS0), MP_ROM_PTR(&pin_PB06) }, // MicroMod BUS0 | G0 (PB06)
|
||||
{ MP_ROM_QSTR(MP_QSTR_BUS1), MP_ROM_PTR(&pin_PB07) }, // MicroMod BUS1 | G1 (PB07)
|
||||
{ MP_ROM_QSTR(MP_QSTR_BUS2), MP_ROM_PTR(&pin_PB08) }, // MicroMod BUS2 | G2 (PB08)
|
||||
{ MP_ROM_QSTR(MP_QSTR_BUS3), MP_ROM_PTR(&pin_PB09) }, // MicroMod BUS3 | G3 (PB09)
|
||||
{ MP_ROM_QSTR(MP_QSTR_BUS4), MP_ROM_PTR(&pin_PB10) }, // MicroMod BUS4 | G4 (PB10)
|
||||
{ MP_ROM_QSTR(MP_QSTR_BUS5), MP_ROM_PTR(&pin_PB11) }, // MicroMod BUS5 | G5 (PB11)
|
||||
{ MP_ROM_QSTR(MP_QSTR_BUS6), MP_ROM_PTR(&pin_PB12) }, // MicroMod BUS6 | G6 (PB12)
|
||||
{ MP_ROM_QSTR(MP_QSTR_BUS7), MP_ROM_PTR(&pin_PB13) }, // MicroMod BUS7 | G7 (PB13)
|
||||
|
||||
// MicroMod differential ADC input pins
|
||||
// { MP_ROM_QSTR(MP_QSTR_ADC_DM), MP_ROM_PTR(&pin_PA15) }, // MicroMod ADC_D- | G9 | CAM_HSYNC (PA15)
|
||||
// { MP_ROM_QSTR(MP_QSTR_ADC_DP), MP_ROM_PTR() }, // MicroMod ADC_D+ | G10 | CAM_VSYNC (not connected)
|
||||
|
||||
// MicroMod camera pins
|
||||
// { MP_ROM_QSTR(MP_QSTR_CAM_MCLK), MP_ROM_PTR(&pin_PA21) }, // MicroMod CAM_MCLK | AUD_OUT | I2S_OUT | PCM_OUT (PA21)
|
||||
// { MP_ROM_QSTR(MP_QSTR_CAM_PCLK), MP_ROM_PTR(&pin_PA22) }, // MicroMod CAM_PCLK | AUD_IN | I2S_IN | PCM_IN (PA22)
|
||||
// { MP_ROM_QSTR(MP_QSTR_CAM_TRIG), MP_ROM_PTR(&pin_PB05) }, // MicroMod CAM_TRIG | D1 (PB05)
|
||||
// { MP_ROM_QSTR(MP_QSTR_CAM_HSYNC), MP_ROM_PTR(&pin_PA15 }, // MicroMod CAM_HSYNC | ADC_D- | G9 (PA15)
|
||||
// { MP_ROM_QSTR(MP_QSTR_CAM_VSYNC), MP_ROM_PTR() }, // MicroMod CAM_VSYNC | ADC_D+ | G10 (not connected)
|
||||
|
||||
// Module-specific aliases (not part of the MicroMod spec)
|
||||
{ MP_ROM_QSTR(MP_QSTR_HOST_ENABLE), MP_ROM_PTR(&pin_PA27) }, // HOST_ENABLE | G11 | SWO (PA27)
|
||||
|
||||
// CircuitPython board objects
|
||||
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, // CircuitPython I2C
|
||||
{ MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, // CircuitPython SPI
|
||||
{ MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, // CircuitPython UART
|
||||
};
|
||||
MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);
|
||||
|
@ -71,7 +71,7 @@
|
||||
void i2sout_reset(void) {
|
||||
// Make sure the I2S peripheral is running so we can see if the resources we need are free.
|
||||
#ifdef SAM_D5X_E5X
|
||||
// Connect the clock units to the 2mhz clock. It can't disable without it.
|
||||
// Connect the clock units to the 2MHz clock. It can't disable without it.
|
||||
connect_gclk_to_peripheral(5, I2S_GCLK_ID_0);
|
||||
connect_gclk_to_peripheral(5, I2S_GCLK_ID_1);
|
||||
#endif
|
||||
@ -83,7 +83,7 @@ void i2sout_reset(void) {
|
||||
|
||||
// Make sure the I2S peripheral is running so we can see if the resources we need are free.
|
||||
#ifdef SAM_D5X_E5X
|
||||
// Connect the clock units to the 2mhz clock by default. They can't reset without it.
|
||||
// Connect the clock units to the 2MHz clock by default. They can't reset without it.
|
||||
disconnect_gclk_from_peripheral(5, I2S_GCLK_ID_0);
|
||||
disconnect_gclk_from_peripheral(5, I2S_GCLK_ID_1);
|
||||
|
||||
@ -222,7 +222,6 @@ void common_hal_audiobusio_i2sout_deinit(audiobusio_i2sout_obj_t *self) {
|
||||
reset_pin_number(self->word_select->number);
|
||||
self->word_select = NULL;
|
||||
reset_pin_number(self->data->number);
|
||||
self->data = NULL;
|
||||
}
|
||||
|
||||
void common_hal_audiobusio_i2sout_play(audiobusio_i2sout_obj_t *self,
|
||||
@ -288,7 +287,7 @@ void common_hal_audiobusio_i2sout_play(audiobusio_i2sout_obj_t *self,
|
||||
I2S->TXCTRL.reg = serctrl;
|
||||
#endif
|
||||
|
||||
// The DFLL is always a 48mhz clock
|
||||
// The DFLL is always a 48MHz clock
|
||||
enable_clock_generator(self->gclk, CLOCK_48MHZ, divisor);
|
||||
connect_gclk_to_peripheral(self->gclk, I2S_GCLK_ID_0 + self->clock_unit);
|
||||
|
||||
|
@ -272,6 +272,9 @@ void common_hal_pulseio_pulsein_deinit(pulseio_pulsein_obj_t *self) {
|
||||
void common_hal_pulseio_pulsein_pause(pulseio_pulsein_obj_t *self) {
|
||||
uint32_t mask = 1 << self->channel;
|
||||
EIC->INTENCLR.reg = mask << EIC_INTENSET_EXTINT_Pos;
|
||||
#ifdef SAMD21
|
||||
rtc_end_pulse();
|
||||
#endif
|
||||
}
|
||||
|
||||
void common_hal_pulseio_pulsein_resume(pulseio_pulsein_obj_t *self,
|
||||
@ -299,6 +302,9 @@ void common_hal_pulseio_pulsein_resume(pulseio_pulsein_obj_t *self,
|
||||
EIC->INTFLAG.reg = mask << EIC_INTFLAG_EXTINT_Pos;
|
||||
EIC->INTENSET.reg = mask << EIC_INTENSET_EXTINT_Pos;
|
||||
|
||||
#ifdef SAMD21
|
||||
rtc_start_pulse();
|
||||
#endif
|
||||
pulsein_set_config(self, true);
|
||||
}
|
||||
|
||||
|
@ -92,26 +92,19 @@
|
||||
#if CIRCUITPY_PEW
|
||||
#include "common-hal/_pew/PewPew.h"
|
||||
#endif
|
||||
volatile bool hold_interrupt = false;
|
||||
static volatile bool sleep_ok = true;
|
||||
#ifdef SAMD21
|
||||
static void rtc_set_continuous(bool continuous) {
|
||||
while (RTC->MODE0.STATUS.bit.SYNCBUSY) {
|
||||
;
|
||||
}
|
||||
RTC->MODE0.READREQ.reg = (continuous ? RTC_READREQ_RCONT : 0) | 0x0010;
|
||||
while (RTC->MODE0.STATUS.bit.SYNCBUSY) {
|
||||
;
|
||||
}
|
||||
}
|
||||
static uint8_t _tick_event_channel = 0;
|
||||
|
||||
// Sleeping requires a register write that can stall interrupt handling. Turning
|
||||
// off sleeps allows for more accurate interrupt timing. (Python still thinks
|
||||
// it is sleeping though.)
|
||||
void rtc_start_pulse(void) {
|
||||
rtc_set_continuous(true);
|
||||
hold_interrupt = true;
|
||||
sleep_ok = false;
|
||||
}
|
||||
|
||||
void rtc_end_pulse(void) {
|
||||
hold_interrupt = false;
|
||||
rtc_set_continuous(false);
|
||||
sleep_ok = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -162,6 +155,20 @@ static void save_usb_clock_calibration(void) {
|
||||
}
|
||||
#endif
|
||||
|
||||
static void rtc_continuous_mode(void) {
|
||||
#ifdef SAMD21
|
||||
while (RTC->MODE0.STATUS.bit.SYNCBUSY) {
|
||||
}
|
||||
RTC->MODE0.READREQ.reg = RTC_READREQ_RCONT | 0x0010;
|
||||
while (RTC->MODE0.STATUS.bit.SYNCBUSY) {
|
||||
}
|
||||
// Do the first request and wait for it.
|
||||
RTC->MODE0.READREQ.reg = RTC_READREQ_RREQ | RTC_READREQ_RCONT | 0x0010;
|
||||
while (RTC->MODE0.STATUS.bit.SYNCBUSY) {
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void rtc_init(void) {
|
||||
#ifdef SAMD21
|
||||
_gclk_enable_channel(RTC_GCLK_ID, GCLK_CLKCTRL_GEN_GCLK2_Val);
|
||||
@ -169,9 +176,17 @@ static void rtc_init(void) {
|
||||
while (RTC->MODE0.CTRL.bit.SWRST != 0) {
|
||||
}
|
||||
|
||||
// Turn on periodic events to use as tick. We control whether it interrupts
|
||||
// us with the EVSYS INTEN register.
|
||||
RTC->MODE0.EVCTRL.reg = RTC_MODE0_EVCTRL_PEREO2;
|
||||
|
||||
RTC->MODE0.CTRL.reg = RTC_MODE0_CTRL_ENABLE |
|
||||
RTC_MODE0_CTRL_MODE_COUNT32 |
|
||||
RTC_MODE0_CTRL_PRESCALER_DIV2;
|
||||
|
||||
// Turn on continuous sync of the count register. This will speed up all
|
||||
// tick reads.
|
||||
rtc_continuous_mode();
|
||||
#endif
|
||||
#ifdef SAM_D5X_E5X
|
||||
hri_mclk_set_APBAMASK_RTC_bit(MCLK);
|
||||
@ -367,6 +382,9 @@ void reset_port(void) {
|
||||
#endif
|
||||
|
||||
reset_event_system();
|
||||
#ifdef SAMD21
|
||||
_tick_event_channel = EVSYS_SYNCH_NUM;
|
||||
#endif
|
||||
|
||||
reset_all_pins();
|
||||
|
||||
@ -434,21 +452,14 @@ uint32_t port_get_saved_word(void) {
|
||||
// TODO: Move this to an RTC backup register so we can preserve it when only the BACKUP power domain
|
||||
// is enabled.
|
||||
static volatile uint64_t overflowed_ticks = 0;
|
||||
#ifdef SAMD21
|
||||
static volatile bool _ticks_enabled = false;
|
||||
#endif
|
||||
|
||||
static uint32_t _get_count(uint64_t *overflow_count) {
|
||||
#ifdef SAM_D5X_E5X
|
||||
while ((RTC->MODE0.SYNCBUSY.reg & (RTC_MODE0_SYNCBUSY_COUNTSYNC | RTC_MODE0_SYNCBUSY_COUNT)) != 0) {
|
||||
}
|
||||
#endif
|
||||
#ifdef SAMD21
|
||||
// Request a read so we don't stall the bus later. See section 14.3.1.5 Read Request
|
||||
RTC->MODE0.READREQ.reg = RTC_READREQ_RREQ | 0x0010;
|
||||
while (RTC->MODE0.STATUS.bit.SYNCBUSY != 0) {
|
||||
}
|
||||
#endif
|
||||
// SAMD21 does continuous sync so we don't need to wait here.
|
||||
|
||||
// Disable interrupts so we can grab the count and the overflow.
|
||||
common_hal_mcu_disable_interrupts();
|
||||
uint32_t count = RTC->MODE0.COUNT.reg;
|
||||
@ -462,29 +473,6 @@ static uint32_t _get_count(uint64_t *overflow_count) {
|
||||
|
||||
volatile bool _woken_up;
|
||||
|
||||
static void _port_interrupt_after_ticks(uint32_t ticks) {
|
||||
uint32_t current_ticks = _get_count(NULL);
|
||||
if (ticks > 1 << 28) {
|
||||
// We'll interrupt sooner with an overflow.
|
||||
return;
|
||||
}
|
||||
#ifdef SAMD21
|
||||
if (hold_interrupt) {
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
uint32_t target = current_ticks + (ticks << 4);
|
||||
RTC->MODE0.COMP[0].reg = target;
|
||||
#ifdef SAM_D5X_E5X
|
||||
while ((RTC->MODE0.SYNCBUSY.reg & (RTC_MODE0_SYNCBUSY_COMP0)) != 0) {
|
||||
}
|
||||
#endif
|
||||
RTC->MODE0.INTFLAG.reg = RTC_MODE0_INTFLAG_CMP0;
|
||||
RTC->MODE0.INTENSET.reg = RTC_MODE0_INTENSET_CMP0;
|
||||
current_ticks = _get_count(NULL);
|
||||
_woken_up = current_ticks >= target;
|
||||
}
|
||||
|
||||
void RTC_Handler(void) {
|
||||
uint32_t intflag = RTC->MODE0.INTFLAG.reg;
|
||||
if (intflag & RTC_MODE0_INTFLAG_OVF) {
|
||||
@ -501,19 +489,10 @@ void RTC_Handler(void) {
|
||||
}
|
||||
#endif
|
||||
if (intflag & RTC_MODE0_INTFLAG_CMP0) {
|
||||
// Clear the interrupt because we may have hit a sleep and _ticks_enabled
|
||||
// Clear the interrupt because we may have hit a sleep
|
||||
RTC->MODE0.INTFLAG.reg = RTC_MODE0_INTFLAG_CMP0;
|
||||
_woken_up = true;
|
||||
#ifdef SAMD21
|
||||
if (_ticks_enabled) {
|
||||
// Do things common to all ports when the tick occurs.
|
||||
supervisor_tick();
|
||||
// Check _ticks_enabled again because a tick handler may have turned it off.
|
||||
if (_ticks_enabled) {
|
||||
_port_interrupt_after_ticks(1);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
// SAMD21 ticks are handled by EVSYS
|
||||
#ifdef SAM_D5X_E5X
|
||||
RTC->MODE0.INTENCLR.reg = RTC_MODE0_INTENCLR_CMP0;
|
||||
#endif
|
||||
@ -530,6 +509,39 @@ uint64_t port_get_raw_ticks(uint8_t *subticks) {
|
||||
return overflow_count + current_ticks / 16;
|
||||
}
|
||||
|
||||
void evsyshandler_common(void) {
|
||||
#ifdef SAMD21
|
||||
if (_tick_event_channel < EVSYS_SYNCH_NUM && event_interrupt_active(_tick_event_channel)) {
|
||||
supervisor_tick();
|
||||
}
|
||||
#endif
|
||||
#if CIRCUITPY_AUDIOIO || CIRCUITPY_AUDIOBUSIO
|
||||
audio_evsys_handler();
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef SAM_D5X_E5X
|
||||
void EVSYS_0_Handler(void) {
|
||||
evsyshandler_common();
|
||||
}
|
||||
void EVSYS_1_Handler(void) {
|
||||
evsyshandler_common();
|
||||
}
|
||||
void EVSYS_2_Handler(void) {
|
||||
evsyshandler_common();
|
||||
}
|
||||
void EVSYS_3_Handler(void) {
|
||||
evsyshandler_common();
|
||||
}
|
||||
void EVSYS_4_Handler(void) {
|
||||
evsyshandler_common();
|
||||
}
|
||||
#else
|
||||
void EVSYS_Handler(void) {
|
||||
evsyshandler_common();
|
||||
}
|
||||
#endif
|
||||
|
||||
// Enable 1/1024 second tick.
|
||||
void port_enable_tick(void) {
|
||||
#ifdef SAM_D5X_E5X
|
||||
@ -537,9 +549,23 @@ void port_enable_tick(void) {
|
||||
RTC->MODE0.INTENSET.reg = RTC_MODE0_INTENSET_PER2;
|
||||
#endif
|
||||
#ifdef SAMD21
|
||||
// TODO: Switch to using the PER *event* from the RTC to generate an interrupt via EVSYS.
|
||||
_ticks_enabled = true;
|
||||
_port_interrupt_after_ticks(1);
|
||||
// SAMD21 ticks won't survive port_reset(). This *should* be ok since it'll
|
||||
// be triggered by ticks and no Python will be running.
|
||||
if (_tick_event_channel >= EVSYS_SYNCH_NUM) {
|
||||
turn_on_event_system();
|
||||
_tick_event_channel = find_sync_event_channel();
|
||||
}
|
||||
// This turns on both the event detected interrupt (EVD) and overflow (OVR).
|
||||
init_event_channel_interrupt(_tick_event_channel, CORE_GCLK, EVSYS_ID_GEN_RTC_PER_2);
|
||||
// Disable overflow interrupt because we ignore it.
|
||||
if (_tick_event_channel >= 8) {
|
||||
uint8_t value = 1 << (_tick_event_channel - 8);
|
||||
EVSYS->INTENCLR.reg = EVSYS_INTENSET_OVRp8(value);
|
||||
} else {
|
||||
uint8_t value = 1 << _tick_event_channel;
|
||||
EVSYS->INTENCLR.reg = EVSYS_INTENSET_OVR(value);
|
||||
}
|
||||
NVIC_EnableIRQ(EVSYS_IRQn);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -549,21 +575,48 @@ void port_disable_tick(void) {
|
||||
RTC->MODE0.INTENCLR.reg = RTC_MODE0_INTENCLR_PER2;
|
||||
#endif
|
||||
#ifdef SAMD21
|
||||
_ticks_enabled = false;
|
||||
RTC->MODE0.INTENCLR.reg = RTC_MODE0_INTENCLR_CMP0;
|
||||
if (_tick_event_channel >= 8) {
|
||||
uint8_t value = 1 << (_tick_event_channel - 8);
|
||||
EVSYS->INTENCLR.reg = EVSYS_INTENSET_EVDp8(value);
|
||||
} else {
|
||||
uint8_t value = 1 << _tick_event_channel;
|
||||
EVSYS->INTENCLR.reg = EVSYS_INTENSET_EVD(value);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// This is called by sleep, we ignore it when our ticks are enabled because
|
||||
// they'll wake us up earlier. If we don't, we'll mess up ticks by overwriting
|
||||
// the next RTC wake up time.
|
||||
void port_interrupt_after_ticks(uint32_t ticks) {
|
||||
uint32_t current_ticks = _get_count(NULL);
|
||||
if (ticks > 1 << 28) {
|
||||
// We'll interrupt sooner with an overflow.
|
||||
return;
|
||||
}
|
||||
#ifdef SAMD21
|
||||
if (_ticks_enabled) {
|
||||
if (!sleep_ok) {
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
_port_interrupt_after_ticks(ticks);
|
||||
|
||||
uint32_t target = current_ticks + (ticks << 4);
|
||||
#ifdef SAMD21
|
||||
// Try and avoid a bus stall when writing COMP by checking for an obvious
|
||||
// existing sync.
|
||||
while (RTC->MODE0.STATUS.bit.SYNCBUSY == 1) {
|
||||
}
|
||||
#endif
|
||||
// Writing the COMP register can take up to 180us to synchronize. During
|
||||
// this time, the bus will stall and no interrupts will be serviced.
|
||||
RTC->MODE0.COMP[0].reg = target;
|
||||
#ifdef SAM_D5X_E5X
|
||||
while ((RTC->MODE0.SYNCBUSY.reg & (RTC_MODE0_SYNCBUSY_COMP0)) != 0) {
|
||||
}
|
||||
#endif
|
||||
RTC->MODE0.INTFLAG.reg = RTC_MODE0_INTFLAG_CMP0;
|
||||
RTC->MODE0.INTENSET.reg = RTC_MODE0_INTENSET_CMP0;
|
||||
// Set continuous mode again because setting COMP may disable it.
|
||||
rtc_continuous_mode();
|
||||
current_ticks = _get_count(NULL);
|
||||
_woken_up = current_ticks >= target;
|
||||
}
|
||||
|
||||
void port_idle_until_interrupt(void) {
|
||||
@ -575,7 +628,7 @@ void port_idle_until_interrupt(void) {
|
||||
}
|
||||
#endif
|
||||
common_hal_mcu_disable_interrupts();
|
||||
if (!tud_task_event_ready() && !hold_interrupt && !_woken_up) {
|
||||
if (!tud_task_event_ready() && sleep_ok && !_woken_up) {
|
||||
__DSB();
|
||||
__WFI();
|
||||
}
|
||||
|
@ -1,33 +0,0 @@
|
||||
/*
|
||||
* This file is part of the MicroPython project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright 2019 Sony Semiconductor Solutions Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef MICROPY_INCLUDED_CXD56_COMMON_HAL_BUSIO_ONEWIRE_H
|
||||
#define MICROPY_INCLUDED_CXD56_COMMON_HAL_BUSIO_ONEWIRE_H
|
||||
|
||||
// Use bitbangio.
|
||||
#include "shared-module/busio/OneWire.h"
|
||||
|
||||
#endif // MICROPY_INCLUDED_CXD56_COMMON_HAL_BUSIO_ONEWIRE_H
|
@ -3,7 +3,7 @@
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
|
||||
* Copyright (c) 2020 Scott Shawcroft for Adafruit Industries
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@ -24,16 +24,29 @@
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef MICROPY_INCLUDED_ATMEL_SAMD_SHARED_MODULE_BUSIO_ONEWIRE_H
|
||||
#define MICROPY_INCLUDED_ATMEL_SAMD_SHARED_MODULE_BUSIO_ONEWIRE_H
|
||||
#include "supervisor/board.h"
|
||||
#include "mpconfigboard.h"
|
||||
#include "shared-bindings/microcontroller/Pin.h"
|
||||
|
||||
#include "shared-module/bitbangio/OneWire.h"
|
||||
void board_init(void) {
|
||||
// USB
|
||||
common_hal_never_reset_pin(&pin_GPIO19);
|
||||
common_hal_never_reset_pin(&pin_GPIO20);
|
||||
|
||||
#include "py/obj.h"
|
||||
// Debug UART
|
||||
#ifdef DEBUG
|
||||
common_hal_never_reset_pin(&pin_GPIO43);
|
||||
common_hal_never_reset_pin(&pin_GPIO44);
|
||||
#endif /* DEBUG */
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
mp_obj_base_t base;
|
||||
bitbangio_onewire_obj_t bitbang;
|
||||
} busio_onewire_obj_t;
|
||||
bool board_requests_safe_mode(void) {
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif // MICROPY_INCLUDED_ATMEL_SAMD_SHARED_MODULE_BUSIO_ONEWIRE_H
|
||||
void reset_board(void) {
|
||||
|
||||
}
|
||||
|
||||
void board_deinit(void) {
|
||||
}
|
@ -3,7 +3,7 @@
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2016 Scott Shawcroft
|
||||
* 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
|
||||
@ -24,10 +24,12 @@
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_BUSIO_ONEWIRE_H
|
||||
#define MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_BUSIO_ONEWIRE_H
|
||||
// Micropython setup
|
||||
|
||||
// Use bitbangio.
|
||||
#include "shared-module/busio/OneWire.h"
|
||||
#define MICROPY_HW_BOARD_NAME "CrumpS2"
|
||||
#define MICROPY_HW_MCU_NAME "ESP32S2"
|
||||
|
||||
#endif // MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_BUSIO_ONEWIRE_H
|
||||
#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0)
|
||||
#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n")
|
||||
|
||||
#define AUTORESET_DELAY_MS 500
|
22
ports/esp32s2/boards/crumpspace_crumps2/mpconfigboard.mk
Normal file
22
ports/esp32s2/boards/crumpspace_crumps2/mpconfigboard.mk
Normal file
@ -0,0 +1,22 @@
|
||||
USB_VID = 0x1209
|
||||
USB_PID = 0x3141
|
||||
USB_PRODUCT = "CrumpS2"
|
||||
USB_MANUFACTURER = "CrumpSpace"
|
||||
|
||||
INTERNAL_FLASH_FILESYSTEM = 1
|
||||
LONGINT_IMPL = MPZ
|
||||
|
||||
# The default queue depth of 16 overflows on release builds,
|
||||
# so increase it to 32.
|
||||
CFLAGS += -DCFG_TUD_TASK_QUEUE_SZ=32
|
||||
|
||||
CIRCUITPY_ESP_FLASH_MODE=dio
|
||||
CIRCUITPY_ESP_FLASH_FREQ=40m
|
||||
CIRCUITPY_ESP_FLASH_SIZE=4MB
|
||||
|
||||
CIRCUITPY_BITBANG_APA102 = 1
|
||||
|
||||
CIRCUITPY_MODULE=wrover
|
||||
|
||||
# Include these Python libraries in firmware.
|
||||
# FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_DotStar
|
53
ports/esp32s2/boards/crumpspace_crumps2/pins.c
Normal file
53
ports/esp32s2/boards/crumpspace_crumps2/pins.c
Normal file
@ -0,0 +1,53 @@
|
||||
#include "shared-bindings/board/__init__.h"
|
||||
|
||||
STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO0), MP_ROM_PTR(&pin_GPIO0) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO1), MP_ROM_PTR(&pin_GPIO1) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO2), MP_ROM_PTR(&pin_GPIO2) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO3), MP_ROM_PTR(&pin_GPIO3) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO4), MP_ROM_PTR(&pin_GPIO4) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO5), MP_ROM_PTR(&pin_GPIO5) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO6), MP_ROM_PTR(&pin_GPIO6) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO7), MP_ROM_PTR(&pin_GPIO7) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO8), MP_ROM_PTR(&pin_GPIO8) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO9), MP_ROM_PTR(&pin_GPIO9) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO10), MP_ROM_PTR(&pin_GPIO10) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO11), MP_ROM_PTR(&pin_GPIO11) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO12), MP_ROM_PTR(&pin_GPIO12) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO13), MP_ROM_PTR(&pin_GPIO13) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO14), MP_ROM_PTR(&pin_GPIO14) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO15), MP_ROM_PTR(&pin_GPIO15) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO16), MP_ROM_PTR(&pin_GPIO16) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO17), MP_ROM_PTR(&pin_GPIO17) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO18), MP_ROM_PTR(&pin_GPIO18) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO21), MP_ROM_PTR(&pin_GPIO21) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO26), MP_ROM_PTR(&pin_GPIO26) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO33), MP_ROM_PTR(&pin_GPIO33) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO34), MP_ROM_PTR(&pin_GPIO34) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO35), MP_ROM_PTR(&pin_GPIO35) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO36), MP_ROM_PTR(&pin_GPIO36) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO37), MP_ROM_PTR(&pin_GPIO37) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO38), MP_ROM_PTR(&pin_GPIO38) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO39), MP_ROM_PTR(&pin_GPIO39) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO40), MP_ROM_PTR(&pin_GPIO40) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_APA102_MOSI), MP_ROM_PTR(&pin_GPIO40) }, // APA102
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO41), MP_ROM_PTR(&pin_GPIO41) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO42), MP_ROM_PTR(&pin_GPIO42) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO43), MP_ROM_PTR(&pin_GPIO43) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO43) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO44), MP_ROM_PTR(&pin_GPIO44) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO44) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO45), MP_ROM_PTR(&pin_GPIO45) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_APA102_SCK), MP_ROM_PTR(&pin_GPIO45) }, // APA102
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO46), MP_ROM_PTR(&pin_GPIO46) },
|
||||
};
|
||||
MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);
|
39
ports/esp32s2/boards/crumpspace_crumps2/sdkconfig
Normal file
39
ports/esp32s2/boards/crumpspace_crumps2/sdkconfig
Normal file
@ -0,0 +1,39 @@
|
||||
CONFIG_ESP32S2_SPIRAM_SUPPORT=y
|
||||
|
||||
#
|
||||
# SPI RAM config
|
||||
#
|
||||
# CONFIG_SPIRAM_TYPE_AUTO is not set
|
||||
CONFIG_SPIRAM_TYPE_ESPPSRAM16=y
|
||||
# CONFIG_SPIRAM_TYPE_ESPPSRAM32 is not set
|
||||
# CONFIG_SPIRAM_TYPE_ESPPSRAM64 is not set
|
||||
CONFIG_SPIRAM_SIZE=2097152
|
||||
|
||||
#
|
||||
# PSRAM clock and cs IO for ESP32S2
|
||||
#
|
||||
CONFIG_DEFAULT_PSRAM_CLK_IO=30
|
||||
CONFIG_DEFAULT_PSRAM_CS_IO=26
|
||||
# end of PSRAM clock and cs IO for ESP32S2
|
||||
|
||||
# CONFIG_SPIRAM_FETCH_INSTRUCTIONS is not set
|
||||
# CONFIG_SPIRAM_RODATA is not set
|
||||
# CONFIG_SPIRAM_SPEED_80M is not set
|
||||
CONFIG_SPIRAM_SPEED_40M=y
|
||||
# CONFIG_SPIRAM_SPEED_26M is not set
|
||||
# CONFIG_SPIRAM_SPEED_20M is not set
|
||||
CONFIG_SPIRAM=y
|
||||
CONFIG_SPIRAM_BOOT_INIT=y
|
||||
# CONFIG_SPIRAM_IGNORE_NOTFOUND is not set
|
||||
CONFIG_SPIRAM_USE_MEMMAP=y
|
||||
# CONFIG_SPIRAM_USE_CAPS_ALLOC is not set
|
||||
# CONFIG_SPIRAM_USE_MALLOC is not set
|
||||
CONFIG_SPIRAM_MEMTEST=y
|
||||
# CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY is not set
|
||||
# end of SPI RAM config
|
||||
|
||||
#
|
||||
# LWIP
|
||||
#
|
||||
CONFIG_LWIP_LOCAL_HOSTNAME="CrumpS2"
|
||||
# end of LWIP
|
227
ports/esp32s2/boards/morpheans_morphesp-240/board.c
Normal file
227
ports/esp32s2/boards/morpheans_morphesp-240/board.c
Normal file
@ -0,0 +1,227 @@
|
||||
/*
|
||||
* This file is part of the MicroPython project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2020 Scott Shawcroft for Adafruit Industries
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "supervisor/board.h"
|
||||
#include "mpconfigboard.h"
|
||||
#include "shared-bindings/microcontroller/Pin.h"
|
||||
#include "shared-module/displayio/__init__.h"
|
||||
#include "shared-module/displayio/mipi_constants.h"
|
||||
|
||||
#define DELAY 0x80
|
||||
|
||||
// From Arduino-ST7789 library https://github.com/ananevilya/Arduino-ST7789-Library/blob/master/Arduino_ST7789.cpp
|
||||
#define ST7789_TFTWIDTH 240
|
||||
#define ST7789_TFTHEIGHT 240
|
||||
|
||||
#define ST7789_240x240_XSTART 0
|
||||
#define ST7789_240x240_YSTART 0
|
||||
|
||||
#define ST7789_NOP 0x00
|
||||
#define ST7789_SWRESET 0x01
|
||||
#define ST7789_RDDID 0x04
|
||||
#define ST7789_RDDST 0x09
|
||||
|
||||
#define ST7789_SLPIN 0x10
|
||||
#define ST7789_SLPOUT 0x11
|
||||
#define ST7789_PTLON 0x12
|
||||
#define ST7789_NORON 0x13
|
||||
|
||||
#define ST7789_INVOFF 0x20
|
||||
#define ST7789_INVON 0x21
|
||||
#define ST7789_DISPOFF 0x28
|
||||
#define ST7789_DISPON 0x29
|
||||
#define ST7789_CASET 0x2A
|
||||
#define ST7789_RASET 0x2B
|
||||
#define ST7789_RAMWR 0x2C
|
||||
#define ST7789_RAMRD 0x2E
|
||||
|
||||
#define ST7789_PTLAR 0x30
|
||||
#define ST7789_COLMOD 0x3A
|
||||
#define ST7789_MADCTL 0x36
|
||||
#define ST7789_VSCSAD 0x37
|
||||
#define ST7789_PORCTRL 0xB2
|
||||
#define ST7789_GCTRL 0xB7
|
||||
#define ST7789_VCOMS 0xBB
|
||||
#define ST7789_LCMCTRL 0xC0
|
||||
#define ST7789_IDSET 0xC1
|
||||
#define ST7789_VDVVRHEN 0xC2
|
||||
#define ST7789_VRHS 0xC3
|
||||
#define ST7789_VDVS 0xC4
|
||||
#define ST7789_VCMOFSET 0xC5
|
||||
#define ST7789_FRCTRL2 0xC6
|
||||
#define ST7789_CABCCTRL 0xC7
|
||||
#define ST7789_REGSEL1 0xC8
|
||||
#define ST7789_REGSEL2 0xCA
|
||||
#define ST7789_PWMFRSEL 0xCC
|
||||
#define ST7789_PWCTRL1 0xD0
|
||||
#define ST7789_VAPVANEN 0xD2
|
||||
#define ST7789_PVGAMCTRL 0xE0
|
||||
#define ST7789_NVGAMCTRL 0xE1
|
||||
|
||||
#define ST7789_MADCTL_MY 0x80
|
||||
#define ST7789_MADCTL_MX 0x40
|
||||
#define ST7789_MADCTL_MV 0x20
|
||||
#define ST7789_MADCTL_ML 0x10
|
||||
#define ST7789_MADCTL_RGB 0x00
|
||||
|
||||
#define ST7789_RDID1 0xDA
|
||||
#define ST7789_RDID2 0xDB
|
||||
#define ST7789_RDID3 0xDC
|
||||
#define ST7789_RDID4 0xDD
|
||||
|
||||
#define DISPLAY_MADCTL (ST7789_MADCTL_RGB)
|
||||
#define DISPLAY_VSCSAD 0
|
||||
|
||||
// The init_sequence is bitpacked to minimize the ram impact. Every command begins with a
|
||||
// command byte followed by a byte to determine the parameter count and delay. When the top bit
|
||||
// of the second byte is 1 (0x80), a delay will occur after the command parameters are sent.
|
||||
// The remaining 7 bits are the parameter count excluding any delay byte. The bytes following
|
||||
// are the parameters. When the delay bit is set, a single byte after the parameters specifies
|
||||
// the delay duration in milliseconds. The value 0xff will lead to an extra long 500 ms delay
|
||||
// instead of 255 ms.uint8_t display_init_sequence[] = {
|
||||
// display init sequence according to LilyGO example app
|
||||
|
||||
uint8_t display_init_sequence[] = {
|
||||
// From Lilygo example
|
||||
// sw reset
|
||||
0x01, 0 | DELAY, 150,
|
||||
// sleep out
|
||||
0x11, 0 | DELAY, 120,
|
||||
// normal display mode on
|
||||
0x13, 0,
|
||||
// display and color format settings
|
||||
0x36, 1, DISPLAY_MADCTL,
|
||||
0xB6, 2, 0x0A, 0x82,
|
||||
0x3A, 1 | DELAY, 0x55, 10,
|
||||
// ST7789V frame rate setting
|
||||
0xB2, 5, 0x0C, 0x0C, 0x00, 0x33, 0x33,
|
||||
// voltages: VGH / VGL
|
||||
0xB7, 1, 0x35,
|
||||
// ST7789V power setting
|
||||
0xBB, 1, 0x28,
|
||||
0xC0, 1, 0x0C,
|
||||
0xC2, 2, 0x01, 0xFF,
|
||||
0xC3, 1, 0x10,
|
||||
0xC4, 1, 0x20,
|
||||
0xC6, 1, 0x0F,
|
||||
0xD0, 2, 0xA4, 0xA1,
|
||||
// ST7789V gamma setting
|
||||
0xE0, 14, 0xD0, 0x00, 0x02, 0x07, 0x0A, 0x28, 0x32, 0x44, 0x42, 0x06, 0x0E, 0x12, 0x14, 0x17,
|
||||
0xE1, 14, 0xD0, 0x00, 0x02, 0x07, 0x0A, 0x28, 0x31, 0x54, 0x47, 0x0E, 0x1C, 0x17, 0x1B, 0x1E,
|
||||
0x21, 0,
|
||||
// display on
|
||||
0x21, 0 | DELAY, 10, // _INVON
|
||||
0x29, 0 | DELAY, 120
|
||||
};
|
||||
|
||||
|
||||
void board_init(void) {
|
||||
// USB
|
||||
common_hal_never_reset_pin(&pin_GPIO19);
|
||||
common_hal_never_reset_pin(&pin_GPIO20);
|
||||
|
||||
// Debug UART
|
||||
#ifdef DEBUG
|
||||
common_hal_never_reset_pin(&pin_GPIO6);
|
||||
common_hal_never_reset_pin(&pin_GPIO7);
|
||||
#endif /* DEBUG */
|
||||
|
||||
// Display
|
||||
|
||||
busio_spi_obj_t *spi = &displays[0].fourwire_bus.inline_bus;
|
||||
|
||||
common_hal_busio_spi_construct(
|
||||
spi,
|
||||
&pin_GPIO12, // CLK
|
||||
&pin_GPIO11, // MOSI
|
||||
NULL // MISO not connected
|
||||
);
|
||||
|
||||
common_hal_busio_spi_never_reset(spi);
|
||||
|
||||
displayio_fourwire_obj_t *bus = &displays[0].fourwire_bus;
|
||||
bus->base.type = &displayio_fourwire_type;
|
||||
|
||||
common_hal_displayio_fourwire_construct(
|
||||
bus,
|
||||
spi,
|
||||
&pin_GPIO14, // DC
|
||||
&pin_GPIO10, // CS
|
||||
&pin_GPIO9, // RST
|
||||
40000000, // baudrate
|
||||
0, // polarity
|
||||
0 // phase
|
||||
);
|
||||
|
||||
// workaround as board_init() is called before reset_port() in main.c
|
||||
pwmout_reset();
|
||||
|
||||
displayio_display_obj_t *display = &displays[0].display;
|
||||
display->base.type = &displayio_display_type;
|
||||
common_hal_displayio_display_construct(
|
||||
display,
|
||||
bus,
|
||||
240, // width (after rotation)
|
||||
240, // height (after rotation)
|
||||
0, // column start
|
||||
80, // row start
|
||||
0, // rotation
|
||||
16, // color depth
|
||||
false, // grayscale
|
||||
false, // pixels in a byte share a row. Only valid for depths < 8
|
||||
1, // bytes per cell. Only valid for depths < 8
|
||||
false, // reverse_pixels_in_byte. Only valid for depths < 8
|
||||
true, // reverse_pixels_in_word
|
||||
MIPI_COMMAND_SET_COLUMN_ADDRESS, // set column command
|
||||
MIPI_COMMAND_SET_PAGE_ADDRESS, // set row command
|
||||
MIPI_COMMAND_WRITE_MEMORY_START, // write memory command
|
||||
0x37, // set vertical scroll command
|
||||
display_init_sequence,
|
||||
sizeof(display_init_sequence),
|
||||
NULL, // There is no backlight pin, defined for now.
|
||||
NO_BRIGHTNESS_COMMAND,
|
||||
1.0f, // brightness (ignored)
|
||||
true, // auto_brightness
|
||||
false, // single_byte_bounds
|
||||
false, // data_as_commands
|
||||
true, // auto_refresh
|
||||
60, // native_frames_per_second
|
||||
false, // backlight_on_high
|
||||
false // SH1107_addressing
|
||||
);
|
||||
}
|
||||
|
||||
bool board_requests_safe_mode(void) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void reset_board(void) {
|
||||
|
||||
}
|
||||
|
||||
void board_deinit(void) {
|
||||
common_hal_displayio_release_displays();
|
||||
}
|
44
ports/esp32s2/boards/morpheans_morphesp-240/mpconfigboard.h
Normal file
44
ports/esp32s2/boards/morpheans_morphesp-240/mpconfigboard.h
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* This file is part of the MicroPython project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2019 Scott Shawcroft for Adafruit Industries
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
// Micropython setup
|
||||
|
||||
#define MICROPY_HW_BOARD_NAME "MORPHEANS MorphESP-240"
|
||||
#define MICROPY_HW_MCU_NAME "ESP32S2"
|
||||
|
||||
#define MICROPY_HW_NEOPIXEL (&pin_GPIO16)
|
||||
#define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0)
|
||||
|
||||
#define BOARD_USER_SAFE_MODE_ACTION translate("pressing boot button at start up.\n")
|
||||
|
||||
#define AUTORESET_DELAY_MS 500
|
||||
|
||||
#define DEFAULT_I2C_BUS_SCL (&pin_GPIO7)
|
||||
#define DEFAULT_I2C_BUS_SDA (&pin_GPIO6)
|
||||
|
||||
#define DEFAULT_SPI_BUS_SCK (&pin_GPIO12)
|
||||
#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO11)
|
||||
#define DEFAULT_SPI_BUS_MISO (&pin_GPIO13)
|
17
ports/esp32s2/boards/morpheans_morphesp-240/mpconfigboard.mk
Normal file
17
ports/esp32s2/boards/morpheans_morphesp-240/mpconfigboard.mk
Normal file
@ -0,0 +1,17 @@
|
||||
USB_VID = 0x303a
|
||||
USB_PID = 0x80B7
|
||||
USB_PRODUCT = "MORPHESP-240"
|
||||
USB_MANUFACTURER = "MORPHEANS"
|
||||
|
||||
INTERNAL_FLASH_FILESYSTEM = 1
|
||||
LONGINT_IMPL = MPZ
|
||||
|
||||
# The default queue depth of 16 overflows on release builds,
|
||||
# so increase it to 32.
|
||||
CFLAGS += -DCFG_TUD_TASK_QUEUE_SZ=32
|
||||
|
||||
CIRCUITPY_ESP_FLASH_MODE = dio
|
||||
CIRCUITPY_ESP_FLASH_FREQ = 40m
|
||||
CIRCUITPY_ESP_FLASH_SIZE = 4MB
|
||||
|
||||
CIRCUITPY_MODULE = wroom
|
58
ports/esp32s2/boards/morpheans_morphesp-240/pins.c
Normal file
58
ports/esp32s2/boards/morpheans_morphesp-240/pins.c
Normal file
@ -0,0 +1,58 @@
|
||||
#include "shared-bindings/board/__init__.h"
|
||||
#include "shared-module/displayio/__init__.h"
|
||||
|
||||
STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO0), MP_ROM_PTR(&pin_GPIO0) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO1), MP_ROM_PTR(&pin_GPIO1) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO2), MP_ROM_PTR(&pin_GPIO2) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO3), MP_ROM_PTR(&pin_GPIO3) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO4), MP_ROM_PTR(&pin_GPIO4) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO5), MP_ROM_PTR(&pin_GPIO5) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO6), MP_ROM_PTR(&pin_GPIO6) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO7), MP_ROM_PTR(&pin_GPIO7) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO8), MP_ROM_PTR(&pin_GPIO8) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO11), MP_ROM_PTR(&pin_GPIO11) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO12), MP_ROM_PTR(&pin_GPIO12) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO13), MP_ROM_PTR(&pin_GPIO13) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO15), MP_ROM_PTR(&pin_GPIO15) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO16), MP_ROM_PTR(&pin_GPIO16) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO17), MP_ROM_PTR(&pin_GPIO17) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO18), MP_ROM_PTR(&pin_GPIO18) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO19), MP_ROM_PTR(&pin_GPIO19) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO20), MP_ROM_PTR(&pin_GPIO20) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO21), MP_ROM_PTR(&pin_GPIO21) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO39), MP_ROM_PTR(&pin_GPIO39) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO40), MP_ROM_PTR(&pin_GPIO40) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO41), MP_ROM_PTR(&pin_GPIO41) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO42), MP_ROM_PTR(&pin_GPIO42) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO45), MP_ROM_PTR(&pin_GPIO45) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_IO46), MP_ROM_PTR(&pin_GPIO46) },
|
||||
|
||||
// Serial UART on breakout board
|
||||
{ MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO17) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO18) },
|
||||
|
||||
// I2C on breakout board.
|
||||
{ MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO6) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO7) },
|
||||
|
||||
// WS2812B RGB LED
|
||||
{ MP_ROM_QSTR(MP_QSTR_NEOPIXEL), MP_ROM_PTR(&pin_GPIO16) },
|
||||
|
||||
// SPI on breakout board
|
||||
{ MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO11) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_CLK), MP_ROM_PTR(&pin_GPIO12) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO13) },
|
||||
|
||||
// 1.3" 240x240 LCD ST7789
|
||||
{ MP_ROM_QSTR(MP_QSTR_LCD_MOSI), MP_ROM_PTR(&pin_GPIO11) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_LCD_CLK), MP_ROM_PTR(&pin_GPIO12) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_LCD_CS), MP_ROM_PTR(&pin_GPIO10) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_LCD_RST), MP_ROM_PTR(&pin_GPIO9) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_LCD_D_C), MP_ROM_PTR(&pin_GPIO14) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display) },
|
||||
|
||||
};
|
||||
MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);
|
6
ports/esp32s2/boards/morpheans_morphesp-240/sdkconfig
Normal file
6
ports/esp32s2/boards/morpheans_morphesp-240/sdkconfig
Normal file
@ -0,0 +1,6 @@
|
||||
#
|
||||
# LWIP
|
||||
#
|
||||
CONFIG_LWIP_LOCAL_HOSTNAME="MORPHESP-240"
|
||||
CONFIG_LWIP_DNS_SUPPORT_MDNS_QUERIES=y
|
||||
# end of LWIP
|
@ -10,56 +10,64 @@ We've also routed two I<sup>2</sup>C buses, 2 SPI buses, eleven GPIO, dedicated
|
||||
|
||||
CircuitPython pin definitions, while simialr to other boards represent a slight departure from just the typical `A` and `D` pin definitions. The majority of general pins are labled as `G` (or alternatively, `BUS`,) as the MicroMod system they build on uses those names to specify pins that may not be specficially analog or digital.
|
||||
|
||||
This can be somewhat confusing, especially around the analog pins. Here's a quick pin-map. This pin map will use the label either on the [SparkFun MicroMod ATP Carrier Board](https://www.sparkfun.com/products/16885), or the pin name on the [graphical datasheet](https://cdn.sparkfun.com/assets/learn_tutorials/1/4/0/1/MicroMod_nRF52840_v1.0_Graphical_Datasheet.pdf). Some of the aditional aliases are just names to make naming consistent (e.g.: RTS/CTS), but they also can refer to additional functionality a pin may have (e.g.: NFC pins)
|
||||
This can be somewhat confusing, especially around the analog pins. Here's a quick pin-map:
|
||||
|
||||
MicroMod Pin # | ATP Pin Label | Pin Definition | Additional Definitons | Pin/Port Reference | Notes
|
||||
:--------------|:--------------|:--------------|:-----------------------|:-------------------|:------
|
||||
8 | G11 | | | (Not Connected) |
|
||||
10 | D0 | D0 | | P0_27 |
|
||||
11 | BOOT | BOOT | BUTTON1 | P0_07 |
|
||||
12 | SDA | SDA | | P0_08 |
|
||||
13 | RTS1 | RTS | RTS1 | P1_02 |
|
||||
14 | SCL | SCL | | P0_11 |
|
||||
15 | CTS1 | CTS | CTS1 | P1_09 |
|
||||
16 | /I2C INT | I2C_INT | P0_15 |
|
||||
17 | TX | TX | TX1 | P1_03 |
|
||||
18 | D1 | D1 | CAM_TRIG | P1_08 |
|
||||
19 | RX | RX | RX1 | P1_10 |
|
||||
20 | RX2 | RX2 | | P1_05 |
|
||||
22 | TX2 | TX2 | | P1_07 |
|
||||
32 | PWM0 | PWM0 | P0_06 |
|
||||
34 | A0 | A0 | ADC0 | P0_04 | Attached to AIN2
|
||||
38 | A1 | A1 | ADC1 | P0_05 | Attached to AIN3
|
||||
11 | BOOT | BOOT | | P0_07 |
|
||||
12 | SDA | I2C_SDA | SDA | P0_08 |
|
||||
13 | RTS1 | UART_RTS1 | | P1_02 |
|
||||
14 | SCL | I2C_SCL | SCL | P0_11 |
|
||||
15 | CTS1 | UART_CTS1 | | P1_09 |
|
||||
16 | /I2C INT | I2C_INT | |P0_15|
|
||||
17 | TX | UART_TX1 | TX | P1_03 |
|
||||
18 | D1 | D1 | | P1_08 |
|
||||
19 | RX | UART_RX1 | RX | P1_10 |
|
||||
20 | RX2 | UART_RX2 | | P1_05 |
|
||||
22 | TX2 | UART_TX2 | | P1_07 |
|
||||
32 | PWM0 | PWM0 | |P0_06|
|
||||
34 | A0 | A0 | | P0_04 | Attached to AIN2
|
||||
38 | A1 | A1 | | P0_05 | Attached to AIN3
|
||||
40 | G0 | G0 | BUS0 | P0_29 | Attached to AIN5
|
||||
42 | G1 | G1 | BUS1 | P0_03 | Attached to AIN1
|
||||
44 | G2 | G2 | BUS2 | P1_13 |
|
||||
46 | G3 | G3 | BUS3 | P1_12 |
|
||||
47 | PWM1 | PWM1 | P0_16 |
|
||||
47 | PWM1 | PWM1 | |P0_16|
|
||||
48 | G4 | G4 | BUS4 | P1_11 |
|
||||
49 | BATT_VIN | BATT_VIN3 | | P0_30 | Attached to AIN6, will be battery voltage / 3. |
|
||||
49 | BATT_VIN | BATT_VIN3 | | P0_30 | Attached to AIN6, will be battery voltage / 3.
|
||||
50 | PDM_CLK | PDM_CLK | | P0_25 |
|
||||
51 | SDA1 | SDA1 | | P1_01 |
|
||||
51 | SDA1 | I2C_SDA1 | | P1_01 |
|
||||
52 | PDM_DATA | PDM_DATA | | P0_26 |
|
||||
53 | SCL1 | SCL1 | | P0_24 |
|
||||
55 | /CS | CS | | P0_20 |
|
||||
57 | SCK | SCK | | P0_28 | Attached to AIN4
|
||||
59 | COPI | COPI | MOSI | P0_31 | Attached to AIN7
|
||||
61 | CIPO | CIPO | MISO | P0_02 |
|
||||
63 | G10 | G10 | NFC2, ADC_DP, CAM_VSYNC | P0_10 | Attached to NFC2
|
||||
65 | G9 | G9 | NFC1, ADC_DM, CAM_HSYNC | P0_09 | Attached to NFC1
|
||||
53 | SCL1 | I2C_SCL1 | | P0_24 |
|
||||
55 | /CS | SPI_CS | | P0_20 |
|
||||
57 | SCK | SPI_SCK | LED_CLK | P0_28 | Attached to AIN4
|
||||
59 | COPI | SPI_COPI | SPI_MOSI, LED_DAT | P0_31 | Attached to AIN7
|
||||
60 | SCK1 | SDIO_SCK | SPI_SCK1 | |
|
||||
61 | CIPO | SPI_CIPO | SPI_MISO | P0_02 |
|
||||
62 | COPI1 | SDIO_CMD | SPI_COPI1 | |
|
||||
63 | G10 | G10 | | P0_10 | Attached to NFC2
|
||||
64 | CIPO1 | SDIO_DATA0 | SPI_CIPO1 | |
|
||||
65 | G9 | G9 | | P0_09 | Attached to NFC1
|
||||
66 | DAT1 | SDIO_DATA1 | | |
|
||||
67 | G8 | G8 | | P1_14 |
|
||||
68 | DAT2 | SDIO_DATA2 | | |
|
||||
69 | G7 | G7 | BUS7 | P1_04 |
|
||||
70 | CS1 | SDIO_DATA3 | SPI_CS1 | |
|
||||
71 | G6 | G6 | BUS6 | P1_06 |
|
||||
73 | G5 | G5 | BUS5 | P0_15 |
|
||||
|
||||
## Peripheral Naming
|
||||
|
||||
CircuitPython attempts to stay in line with the naming of the serial peripheral naming in the MicroMod system. The bare UART pins are also named <pin>1. The UART 2 pins are named <pin>2. However, the I2C names on MicroMod are <I2C pin> and <I2C pin>1. Perhaps this will change in the future, but as of [Interface v1](https://cdn.sparkfun.com/assets/learn_tutorials/1/2/0/6/SparkFun_MicroMod_Interface_v1.0_-_Pin_Descriptions.pdf), it may lead to some confusion.
|
||||
The SparkFun MicroMod spec uses a zero-based peripheral numbering scheme. The 0th peripheral is the default and the "0" is omitted from the peripheral name. For example, the first I2C peripheral is named `I2C` (instead of `I2C0`) and the second I2C peripheral is named `I2C1`. Note: MicroMod `UART` is not present in the edge connector pinout because the primary debug serial port (i.e.`UART0`) is exposed as a virtual serial port over USB. As a result, the first UART peripheral in the edge connector pinout is `UART1` and the second UART peripheral is `UART2`.
|
||||
|
||||
For more details, see https://www.sparkfun.com/micromod#tech-specs.
|
||||
|
||||
|
||||
## Bootloader Notes
|
||||
|
||||
The MicroMod nRF52840 Processor needs to have the [Adafruit nRF52 UF2 bootloader](https://github.com/adafruit/Adafruit_nRF52_Bootloader/pull/194) flashed on it. [[TODO: LINK TO BUILD]]
|
||||
The MicroMod nRF52840 Processor needs to have the [Adafruit nRF52 UF2 bootloader](https://github.com/adafruit/Adafruit_nRF52_Bootloader/releases/latest) flashed on it.
|
||||
|
||||
## Hardware Reference
|
||||
|
||||
|
@ -27,9 +27,12 @@
|
||||
|
||||
#include "nrfx/hal/nrf_gpio.h"
|
||||
|
||||
#define MICROPY_HW_BOARD_NAME "SparkFun MicroMod nRF52840"
|
||||
#define MICROPY_HW_BOARD_NAME "SparkFun MicroMod nRF52840 Processor"
|
||||
#define MICROPY_HW_MCU_NAME "nRF52840"
|
||||
|
||||
// Status LED
|
||||
#define MICROPY_HW_LED_STATUS (&pin_P0_13)
|
||||
|
||||
#define DEFAULT_I2C_BUS_SCL (&pin_P0_11)
|
||||
#define DEFAULT_I2C_BUS_SDA (&pin_P0_08)
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
USB_VID = 0x1B4F
|
||||
USB_PID = 0x0021
|
||||
USB_PRODUCT = "SFE_nRF52840_MicroMod"
|
||||
USB_PRODUCT = "SparkFun MicroMod nRF52840 Processor"
|
||||
USB_MANUFACTURER = "SparkFun Electronics"
|
||||
|
||||
MCU_CHIP = nrf52840
|
||||
|
@ -1,113 +1,221 @@
|
||||
/*
|
||||
* 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) 2021 Chris Wilson
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "shared-bindings/board/__init__.h"
|
||||
|
||||
STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
|
||||
// D pins (D0-D1)
|
||||
{ MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_P0_27) }, // 0.27 - D0
|
||||
{ MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_P1_08) }, // 1.08 - D1 | CAM_TRIG
|
||||
{ MP_ROM_QSTR(MP_QSTR_CAM_TRIG), MP_ROM_PTR(&pin_P1_08) }, // CAM_TRIG alias
|
||||
// The SparkFun MicroMod spec uses a zero-based peripheral numbering scheme.
|
||||
// The 0th peripheral is the default and the "0" is omitted from the
|
||||
// peripheral name (e.g. "I2C" instead of "I2C0").
|
||||
//
|
||||
// For more details, see https://www.sparkfun.com/micromod#tech-specs
|
||||
|
||||
// A pins (A0-A1)
|
||||
{ MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_P0_04) }, // 0.04 - A0 | ADC0 (AIN2)
|
||||
{ MP_ROM_QSTR(MP_QSTR_ADC0), MP_ROM_PTR(&pin_P0_04) }, // ADC0 alias
|
||||
{ MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_P0_05) }, // 0.05 - A1 | ADC1 (AIN3)
|
||||
{ MP_ROM_QSTR(MP_QSTR_ADC1), MP_ROM_PTR(&pin_P0_05) }, // ADC1 alias
|
||||
// MicroMod built-in status LED pin
|
||||
// Requirement from the "Designing with MicroMod" SparkFun article:
|
||||
// "... every Processor Board shall include one status LED connected to a
|
||||
// pin that is not connected to the board edge."
|
||||
{ MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_P0_13) }, // MicroMod LED (P0.13)
|
||||
|
||||
// G pins (G0-G11, G11 NC)
|
||||
{ MP_ROM_QSTR(MP_QSTR_G0), MP_ROM_PTR(&pin_P0_29) }, // 0.29 - G0 | GPIO0 | BUS0 (AIN5)
|
||||
{ MP_ROM_QSTR(MP_QSTR_BUS0), MP_ROM_PTR(&pin_P0_29) }, // BUS0 alias
|
||||
{ MP_ROM_QSTR(MP_QSTR_G1), MP_ROM_PTR(&pin_P0_03) }, // 0.03 - G1 | GPIO1 | BUS1 (AIN1)
|
||||
{ MP_ROM_QSTR(MP_QSTR_BUS1), MP_ROM_PTR(&pin_P0_03) }, // BUS1 alias
|
||||
{ MP_ROM_QSTR(MP_QSTR_G2), MP_ROM_PTR(&pin_P1_13) }, // 1.13 - G2 | GPIO2 | BUS2
|
||||
{ MP_ROM_QSTR(MP_QSTR_BUS2), MP_ROM_PTR(&pin_P1_13) }, // BUS2 alias
|
||||
{ MP_ROM_QSTR(MP_QSTR_G3), MP_ROM_PTR(&pin_P1_12) }, // 1.12 - G3 | GPIO3 | BUS3
|
||||
{ MP_ROM_QSTR(MP_QSTR_BUS3), MP_ROM_PTR(&pin_P1_12) }, // BUS3 alias
|
||||
{ MP_ROM_QSTR(MP_QSTR_G4), MP_ROM_PTR(&pin_P1_11) }, // 1.11 - G4 | GPIO4 | BUS4
|
||||
{ MP_ROM_QSTR(MP_QSTR_BUS4), MP_ROM_PTR(&pin_P1_11) }, // BUS4 alias
|
||||
{ MP_ROM_QSTR(MP_QSTR_G5), MP_ROM_PTR(&pin_P0_17) }, // 0.17 - G5 | GPIO5 | BUS5
|
||||
{ MP_ROM_QSTR(MP_QSTR_BUS5), MP_ROM_PTR(&pin_P0_17) }, // BUS5 alias
|
||||
{ MP_ROM_QSTR(MP_QSTR_G6), MP_ROM_PTR(&pin_P1_06) }, // 1.06 - G6 | GPIO6 | BUS6
|
||||
{ MP_ROM_QSTR(MP_QSTR_BUS6), MP_ROM_PTR(&pin_P1_06) }, // BUS6 alias
|
||||
{ MP_ROM_QSTR(MP_QSTR_G7), MP_ROM_PTR(&pin_P1_04) }, // 1.04 - G7 | GPIO7 | BUS7
|
||||
{ MP_ROM_QSTR(MP_QSTR_BUS7), MP_ROM_PTR(&pin_P1_04) }, // BUS7 alias
|
||||
{ MP_ROM_QSTR(MP_QSTR_G8), MP_ROM_PTR(&pin_P1_14) }, // 1.14 - G8 | GPIO8
|
||||
{ MP_ROM_QSTR(MP_QSTR_G9), MP_ROM_PTR(&pin_P0_09) }, // 0.09 - G9 | GPIO9/NFC1 | ADC_D- | CAM_HSYNC (NFC1)
|
||||
{ MP_ROM_QSTR(MP_QSTR_NFC1), MP_ROM_PTR(&pin_P0_09) }, // NFC1 alias
|
||||
{ MP_ROM_QSTR(MP_QSTR_ADC_DM), MP_ROM_PTR(&pin_P0_09) }, // ADC_DM alias
|
||||
{ MP_ROM_QSTR(MP_QSTR_CAM_HSYNC), MP_ROM_PTR(&pin_P0_09) }, // CAM_HSYNC alias
|
||||
{ MP_ROM_QSTR(MP_QSTR_G10), MP_ROM_PTR(&pin_P0_10) }, // 0.10 - G10 | GPIO10/NFC2 | ADC_D+ | CAM_VSYNC (NFC2)
|
||||
{ MP_ROM_QSTR(MP_QSTR_NFC2), MP_ROM_PTR(&pin_P0_10) }, // NFC2 alias
|
||||
{ MP_ROM_QSTR(MP_QSTR_ADC_DP), MP_ROM_PTR(&pin_P0_10) }, // ADC_DP alias
|
||||
{ MP_ROM_QSTR(MP_QSTR_CAM_VSYNC), MP_ROM_PTR(&pin_P0_10) }, // CAM_VSYNC alias
|
||||
// NC - G11
|
||||
// MicroMod USB bus input voltage (+5V) pin
|
||||
// { MP_ROM_QSTR(MP_QSTR_USB_VIN), MP_ROM_PTR() }, // MicroMod USB_VIN (MDBT50Q-P1M has a dedicated HW VBUS pin)
|
||||
|
||||
// PWM pins (PWM0-PWM1)
|
||||
{ MP_ROM_QSTR(MP_QSTR_PWM0), MP_ROM_PTR(&pin_P0_06) }, // 0.06 - PWM0
|
||||
{ MP_ROM_QSTR(MP_QSTR_PWM1), MP_ROM_PTR(&pin_P0_16) }, // 0.16 - PWM1
|
||||
// MicroMod +3.3V enable pin
|
||||
{ MP_ROM_QSTR(MP_QSTR_P3V3_EN), MP_ROM_PTR(&pin_P1_15) }, // MicroMod 3.3V_EN (P1.15)
|
||||
|
||||
// PDM
|
||||
{ MP_ROM_QSTR(MP_QSTR_PDM_CLK), MP_ROM_PTR(&pin_P0_25) }, // 0.25 - PDM_CLK | AUD_BCLK
|
||||
{ MP_ROM_QSTR(MP_QSTR_PDM_DATA), MP_ROM_PTR(&pin_P0_26) }, // 0.26 - PDM_DATA | AUD_LRCLK
|
||||
// MicroMod battery voltage sense pin
|
||||
{ MP_ROM_QSTR(MP_QSTR_BATT_VIN3), MP_ROM_PTR(&pin_P0_30) }, // MicroMod BATT_VIN/3 (P0.30)
|
||||
|
||||
// Battery Voltage Monitor
|
||||
{ MP_ROM_QSTR(MP_QSTR_BATT_VIN3), MP_ROM_PTR(&pin_P0_30) }, // 0.30 - BATT_VIN/3 (AIN6)
|
||||
// MicroMod reset pin
|
||||
{ MP_ROM_QSTR(MP_QSTR_RESET), MP_ROM_PTR(&pin_P0_18) }, // MicroMod RESET# (P0.18)
|
||||
|
||||
// I2C
|
||||
{ MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_P0_08) }, // 0.08 - SDA
|
||||
{ MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_P0_11) }, // 0.11 - SCL (TRACEDATA2)
|
||||
// MicroMod boot pin
|
||||
{ MP_ROM_QSTR(MP_QSTR_BOOT), MP_ROM_PTR(&pin_P0_07) }, // MicroMod BOOT (P0.07)
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_I2C_INT), MP_ROM_PTR(&pin_P0_15) }, // 0.15 - I2C_INT
|
||||
// MicroMod USB device pins
|
||||
// USB device is always used internally by CircuitPython, so skip creating
|
||||
// the pin objects for it.
|
||||
// { MP_ROM_QSTR(MP_QSTR_USB_DM), MP_ROM_PTR() }, // MicroMod USB_D- (MDBT50Q-P1M has a dedicated HW D- pin)
|
||||
// { MP_ROM_QSTR(MP_QSTR_USB_DP), MP_ROM_PTR() }, // MicroMod USB_D+ (MDBT50Q-P1M has a dedicated HW D+ pin)
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_SDA1), MP_ROM_PTR(&pin_P1_01) }, // 1.01 - SDA1
|
||||
{ MP_ROM_QSTR(MP_QSTR_SCL1), MP_ROM_PTR(&pin_P0_24) }, // 0.24 - SCL1
|
||||
// MicroMod USB host pins
|
||||
// { MP_ROM_QSTR(MP_QSTR_USBHOST_DM), MP_ROM_PTR() }, // MicroMod USBHOST_D- (not supported)
|
||||
// { MP_ROM_QSTR(MP_QSTR_USBHOST_DP), MP_ROM_PTR() }, // MicroMod USBHOST_D+ (not supported)
|
||||
|
||||
// SPI
|
||||
{ MP_ROM_QSTR(MP_QSTR_CIPO), MP_ROM_PTR(&pin_P0_02) }, // 0.02 - CIPO | SPI_CIPO
|
||||
{ MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_P0_02) }, // MISO alias
|
||||
{ MP_ROM_QSTR(MP_QSTR_COPI), MP_ROM_PTR(&pin_P0_31) }, // 0.31 - COPI | SPI_COPI (AIN7)
|
||||
{ MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_P0_31) }, // MOSI alias
|
||||
{ MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_P0_28) }, // 0.28 - SCK | SPI_SCK (AIN4)
|
||||
{ MP_ROM_QSTR(MP_QSTR_CS), MP_ROM_PTR(&pin_P0_20) }, // 0.20 - /CS | SPI_/CS
|
||||
// MicroMod CAN pins
|
||||
// { MP_ROM_QSTR(MP_QSTR_CAN_RX), MP_ROM_PTR() }, // MicroMod CAN_RX (not supported)
|
||||
// { MP_ROM_QSTR(MP_QSTR_CAN_TX), MP_ROM_PTR() }, // MicroMod CAN_TX (not supported)
|
||||
|
||||
// QSPI, used by flash on this board, but is broken out
|
||||
// on the MicroMod connector, to to the SDIO pins.
|
||||
{ MP_ROM_QSTR(MP_QSTR_SDIO_CLK), MP_ROM_PTR(&pin_P0_19) }, // 0.00 - SDIO SCK | Used as: QSPI flash SCK
|
||||
{ MP_ROM_QSTR(MP_QSTR_SPI_SCK1), MP_ROM_PTR(&pin_P0_19) }, // SPI_SCK1 alias
|
||||
{ MP_ROM_QSTR(MP_QSTR_SDIO_CMD), MP_ROM_PTR(&pin_P0_14) }, // 0.00 - SDIO CMD | Used as: QSPI flash D0 (or SDI)
|
||||
{ MP_ROM_QSTR(MP_QSTR_SPI_COPI1), MP_ROM_PTR(&pin_P0_14) }, // SPI_COPI1 alias
|
||||
{ MP_ROM_QSTR(MP_QSTR_SDIO_DATA0), MP_ROM_PTR(&pin_P0_21) },// 0.00 - SDIO DATA0 | Used as: QSPI flash D1 (or SDO)
|
||||
{ MP_ROM_QSTR(MP_QSTR_SPI_CIPO1), MP_ROM_PTR(&pin_P0_21) }, // SPI_CIPO1 alias
|
||||
{ MP_ROM_QSTR(MP_QSTR_SDIO_DATA1), MP_ROM_PTR(&pin_P0_22) },// 0.00 - SDIO DATA1 | Unused for flash.
|
||||
{ MP_ROM_QSTR(MP_QSTR_SDIO_DATA2), MP_ROM_PTR(&pin_P0_23) },// 0.00 - SDIO DATA2 | Used as: QSPI flash D2
|
||||
{ MP_ROM_QSTR(MP_QSTR_SDIO_DATA3), MP_ROM_PTR(&pin_P1_00) },// 0.00 - SDIO DATA3 | Use das: QSPI flash D3 (or /HOLD)
|
||||
{ MP_ROM_QSTR(MP_QSTR_SPI_CS1), MP_ROM_PTR(&pin_P1_00) }, // SPI_CS1 alias
|
||||
// Note: MicroMod UART (UART0) is not present in the edge connector pinout
|
||||
// because the primary debug serial port is exposed as a virtual serial port
|
||||
// over USB.
|
||||
|
||||
// Reset Pin
|
||||
{ MP_ROM_QSTR(MP_QSTR_RESET), MP_ROM_PTR(&pin_P1_14) }, // 0.18 - /RESET (NRESET)
|
||||
// MicroMod UART1 pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_UART_TX1), MP_ROM_PTR(&pin_P1_03) }, // MicroMod UART_TX1 | CircuitPython TX (P1.03)
|
||||
{ MP_ROM_QSTR(MP_QSTR_UART_RX1), MP_ROM_PTR(&pin_P1_10) }, // MicroMod UART_RX1 | CircuitPython RX (P1.10)
|
||||
{ MP_ROM_QSTR(MP_QSTR_UART_RTS1), MP_ROM_PTR(&pin_P1_02) }, // MicroMod RTS1 (P1.02)
|
||||
{ MP_ROM_QSTR(MP_QSTR_UART_CTS1), MP_ROM_PTR(&pin_P1_09) }, // MicroMod CTS1 (P1.09)
|
||||
|
||||
// LED
|
||||
{ MP_ROM_QSTR(MP_QSTR_LED1), MP_ROM_PTR(&pin_P0_13) }, // 0.13 - LED_BUILTIN | STAT | Blue LED
|
||||
// CircuitPython default UART pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_P1_03) }, // CircuitPython TX | MicroMod UART_TX1 (P1.03)
|
||||
{ MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_P1_10) }, // CircuitPython RX | MicroMod UART_RX1 (P1.10)
|
||||
|
||||
// Button
|
||||
{ MP_ROM_QSTR(MP_QSTR_BUTTON1), MP_ROM_PTR(&pin_P0_07) }, // 0.07 - /BOOT [Active Low] (TRACECLK) - Is button on carriers.
|
||||
{ MP_ROM_QSTR(MP_QSTR_BOOT), MP_ROM_PTR(&pin_P0_07) }, // BOOT alias
|
||||
// MicroMod UART2 pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_UART_TX2), MP_ROM_PTR(&pin_P1_07) }, // MicroMod UART_TX2 (P1.07)
|
||||
{ MP_ROM_QSTR(MP_QSTR_UART_RX2), MP_ROM_PTR(&pin_P1_05) }, // MicroMod UART_RX2 (P1.05)
|
||||
|
||||
// UART
|
||||
{ MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_P1_10) }, // 1.10 - UART RX | RX1
|
||||
{ MP_ROM_QSTR(MP_QSTR_RX1), MP_ROM_PTR(&pin_P1_10) }, // RX1 alias
|
||||
{ MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_P1_03) }, // 1.03 - UART TX | TX1
|
||||
{ MP_ROM_QSTR(MP_QSTR_TX1), MP_ROM_PTR(&pin_P1_03) }, // TX1 alias
|
||||
{ MP_ROM_QSTR(MP_QSTR_CTS), MP_ROM_PTR(&pin_P1_09) }, // 1.09 - UART CTS | CTS1 (TRACEDATA3)
|
||||
{ MP_ROM_QSTR(MP_QSTR_CTS1), MP_ROM_PTR(&pin_P1_09) }, // CTS1 alias
|
||||
{ MP_ROM_QSTR(MP_QSTR_RTS), MP_ROM_PTR(&pin_P1_02) }, // 1.02 - UART RTS | RTS1
|
||||
{ MP_ROM_QSTR(MP_QSTR_RTS1), MP_ROM_PTR(&pin_P1_02) }, // RTS1 alias
|
||||
// MicroMod I2C pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_I2C_SDA), MP_ROM_PTR(&pin_P0_08) }, // MicroMod I2C_SDA (P0.08)
|
||||
{ MP_ROM_QSTR(MP_QSTR_I2C_SCL), MP_ROM_PTR(&pin_P0_11) }, // MicroMod I2C_SCL (P0.11)
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_RX2), MP_ROM_PTR(&pin_P1_05) }, // 1.05 - UART RX | RX2
|
||||
{ MP_ROM_QSTR(MP_QSTR_TX2), MP_ROM_PTR(&pin_P1_07) }, // 1.07 - UART TX | TX2
|
||||
// CircuitPython default I2C pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_P0_08) }, // CircuitPython SDA | MicroMod I2C_SDA (P0.08)
|
||||
{ MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_P0_11) }, // CircuitPython SCL | MicroMod I2C_SCL (P0.11)
|
||||
|
||||
// Board Objects
|
||||
{ MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
|
||||
// MicroMod I2C interrupt pin
|
||||
{ MP_ROM_QSTR(MP_QSTR_I2C_INT), MP_ROM_PTR(&pin_P0_15) }, // MicroMod I2C_INT (P0.15)
|
||||
|
||||
// MicroMod I2C1 pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_I2C_SDA1), MP_ROM_PTR(&pin_P1_01) }, // MicroMod I2C_SDA1 (P1.01)
|
||||
{ MP_ROM_QSTR(MP_QSTR_I2C_SCL1), MP_ROM_PTR(&pin_P0_24) }, // MicroMod I2C_SCL1 (P0.24)
|
||||
|
||||
// MicroMod SPI pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_SPI_CIPO), MP_ROM_PTR(&pin_P0_02) }, // MicroMod SPI_CIPO | CircuitPython CIPO (P0.02)
|
||||
{ MP_ROM_QSTR(MP_QSTR_SPI_MISO), MP_ROM_PTR(&pin_P0_02) }, // MicroMod SPI_MISO | CircuitPython MISO (P0.02)
|
||||
{ MP_ROM_QSTR(MP_QSTR_SPI_COPI), MP_ROM_PTR(&pin_P0_31) }, // MicroMod SPI_COPI | CircuitPython COPI | LED_DAT (P0.31)
|
||||
{ MP_ROM_QSTR(MP_QSTR_SPI_MOSI), MP_ROM_PTR(&pin_P0_31) }, // MicroMod SPI_MOSI | CircuitPython MOSI (P0.31)
|
||||
{ MP_ROM_QSTR(MP_QSTR_SPI_SCK), MP_ROM_PTR(&pin_P0_28) }, // MicroMod SPI_SCK | CircuitPython SCK | LED_CLK (P0.28)
|
||||
{ MP_ROM_QSTR(MP_QSTR_SPI_CS), MP_ROM_PTR(&pin_P0_20) }, // MicroMod SPI_CS | CircuitPython CS (P0.20)
|
||||
|
||||
// CircuitPython default SPI pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_CIPO), MP_ROM_PTR(&pin_P0_02) }, // CircuitPython CIPO | MicroMod SPI_CIPO (P0.02)
|
||||
{ MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_P0_02) }, // CircuitPython MISO | MicroMod SPI_MISO (P0.02)
|
||||
{ MP_ROM_QSTR(MP_QSTR_COPI), MP_ROM_PTR(&pin_P0_31) }, // CircuitPython COPI | MicroMod SPI_COPI | LED_DAT (P0.31)
|
||||
{ MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_P0_31) }, // CircuitPython MOSI | MicroMod SPI_MOSI (P0.31)
|
||||
{ MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_P0_28) }, // CircuitPython SCK | MicroMod SPI_SCK | LED_CLK (P0.28)
|
||||
{ MP_ROM_QSTR(MP_QSTR_CS), MP_ROM_PTR(&pin_P0_20) }, // CircuitPython CS | MicroMod SPI_CS (P0.20)
|
||||
|
||||
// MicroMod 2-wire serial LED pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_LED_DAT), MP_ROM_PTR(&pin_P0_31) }, // MicroMod LED_DAT | SPI_COPI (P0.31)
|
||||
{ MP_ROM_QSTR(MP_QSTR_LED_CLK), MP_ROM_PTR(&pin_P0_28) }, // MicroMod LED_CLK | SPI_SCK (P0.28)
|
||||
|
||||
// MicroMod SDIO pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_SDIO_CLK), MP_ROM_PTR(&pin_P0_19) }, // MicroMod SDIO_SCK | SPI_SCK1 (P0.19)
|
||||
{ MP_ROM_QSTR(MP_QSTR_SDIO_CMD), MP_ROM_PTR(&pin_P0_14) }, // MicroMod SDIO_CMD | SPI_COPI1 (P0.14)
|
||||
{ MP_ROM_QSTR(MP_QSTR_SDIO_DATA0), MP_ROM_PTR(&pin_P0_21) }, // MicroMod SDIO_DATA0 | SPI_CIPO1 (P0.21)
|
||||
{ MP_ROM_QSTR(MP_QSTR_SDIO_DATA1), MP_ROM_PTR(&pin_P0_22) }, // MicroMod SDIO_DATA1 (P0.22)
|
||||
{ MP_ROM_QSTR(MP_QSTR_SDIO_DATA2), MP_ROM_PTR(&pin_P0_23) }, // MicroMod SDIO_DATA2 (P0.23)
|
||||
{ MP_ROM_QSTR(MP_QSTR_SDIO_DATA3), MP_ROM_PTR(&pin_P1_00) }, // MicroMod SDIO_DATA3 | SPI_CS1 (P1.00)
|
||||
|
||||
// MicroMod SPI1 pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_SPI_CIPO1), MP_ROM_PTR(&pin_P0_21) }, // MicroMod SPI_CIPO1 | SDIO_DATA0 (P0.21)
|
||||
{ MP_ROM_QSTR(MP_QSTR_SPI_MISO1), MP_ROM_PTR(&pin_P0_21) }, // MicroMod SPI_MISO1 (P0.21)
|
||||
{ MP_ROM_QSTR(MP_QSTR_SPI_COPI1), MP_ROM_PTR(&pin_P0_14) }, // MicroMod SPI_COPI1 | SDIO_CMD (P0.14)
|
||||
{ MP_ROM_QSTR(MP_QSTR_SPI_MOSI1), MP_ROM_PTR(&pin_P0_14) }, // MicroMod SPI_MOSI1 (P0.14)
|
||||
{ MP_ROM_QSTR(MP_QSTR_SPI_SCK1), MP_ROM_PTR(&pin_P0_19) }, // MicroMod SPI_SCK1 | SDIO_SCK (P0.19)
|
||||
{ MP_ROM_QSTR(MP_QSTR_SPI_CS1), MP_ROM_PTR(&pin_P1_00) }, // MicroMod SPI_CS1 | SDIO_DATA3 (P1.00)
|
||||
|
||||
// MicroMod audio pins (not supported by MDBT50Q-P1M)
|
||||
// { MP_ROM_QSTR(MP_QSTR_AUD_MCLK), MP_ROM_PTR() }, // MicroMod AUD_MCLK (not connected)
|
||||
// { MP_ROM_QSTR(MP_QSTR_AUD_OUT), MP_ROM_PTR() }, // MicroMod AUD_OUT | I2S_OUT | PCM_OUT | CAM_MCLK (not connected)
|
||||
// { MP_ROM_QSTR(MP_QSTR_AUD_IN), MP_ROM_PTR() }, // MicroMod AUD_IN | I2S_IN | PCM_IN | CAM_PCLK (not connected)
|
||||
// { MP_ROM_QSTR(MP_QSTR_AUD_LRCLK), MP_ROM_PTR(&pin_P0_26) },// MicroMod AUD_LRCLK | I2S_WS | PCM_SYNC | PDM_DATA (P0.26)
|
||||
// { MP_ROM_QSTR(MP_QSTR_AUD_BCLK), MP_ROM_PTR(&pin_P0_25) }, // MicroMod AUD_BCLK | I2S_SCK | PCM_CLK | PDM_CLK (P0.25)
|
||||
|
||||
// MicroMod I2S pins (not supported by MDBT50Q-P1M)
|
||||
// { MP_ROM_QSTR(MP_QSTR_I2S_OUT), MP_ROM_PTR() }, // MicroMod I2S_OUT | AUD_OUT | PCM_OUT | CAM_MCLK (not connected)
|
||||
// { MP_ROM_QSTR(MP_QSTR_I2S_IN), MP_ROM_PTR() }, // MicroMod I2S_IN | AUD_IN | PCM_IN | CAM_PCLK (not connected)
|
||||
// { MP_ROM_QSTR(MP_QSTR_I2S_WS), MP_ROM_PTR(&pin_P0_26) }, // MicroMod I2S_WS | AUD_LRCLK | PCM_SYNC | PDM_DATA (P0.26)
|
||||
// { MP_ROM_QSTR(MP_QSTR_I2S_SCK), MP_ROM_PTR(&pin_P0_25) }, // MicroMod I2S_SCK | AUD_BCLK | PCM_CLK | PDM_CLK (P0.25)
|
||||
|
||||
// MicroMod PCM pins (not supported by MDBT50Q-P1M)
|
||||
// { MP_ROM_QSTR(MP_QSTR_PCM_OUT), MP_ROM_PTR() }, // MicroMod PCM_OUT | AUD_OUT | I2S_OUT | CAM_MCLK (not connected)
|
||||
// { MP_ROM_QSTR(MP_QSTR_PCM_IN), MP_ROM_PTR() }, // MicroMod PCM_IN | AUD_IN | I2S_IN | CAM_PCLK (not connected)
|
||||
// { MP_ROM_QSTR(MP_QSTR_PCM_SYNC), MP_ROM_PTR(&pin_P0_26) }, // MicroMod PCM_SYNC | AUD_LRCLK | I2S_WS | PDM_DATA (P0.26)
|
||||
// { MP_ROM_QSTR(MP_QSTR_PCM_CLK), MP_ROM_PTR(&pin_P0_25) }, // MicroMod PCM_CLK | AUD_BCLK | I2S_SCK | PDM_CLK (P0.25)
|
||||
|
||||
// MicroMod PDM pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_PDM_DATA), MP_ROM_PTR(&pin_P0_26) }, // MicroMod PDM_DATA | AUD_LRCLK | I2S_WS | PCM_SYNC (P0.26)
|
||||
{ MP_ROM_QSTR(MP_QSTR_PDM_CLK), MP_ROM_PTR(&pin_P0_25) }, // MicroMod PDM_CLK | AUD_BCLK | I2S_SCK | PCM_CLK (P0.25)
|
||||
|
||||
// MicroMod SWD pins
|
||||
// { MP_ROM_QSTR(MP_QSTR_SWDIO), MP_ROM_PTR() }, // MicroMod SWDIO (MDBT50Q-P1M has a dedicated HW SWDIO pin)
|
||||
// { MP_ROM_QSTR(MP_QSTR_SWCLK), MP_ROM_PTR() }, // MicroMod SWDCK (MDBT50Q-P1M has a dedicated HW SWDCLK pin)
|
||||
// { MP_ROM_QSTR(MP_QSTR_SWO), MP_ROM_PTR() }, // MicroMod SWO | G11 (not supported)
|
||||
|
||||
// MicroMod ADC pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_P0_05) }, // MicroMod A0 (P0.05)
|
||||
{ MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_P0_04) }, // MicroMod A1 (P0.04)
|
||||
|
||||
// MicroMod PWM pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_PWM0), MP_ROM_PTR(&pin_P0_06) }, // MicroMod PWM0 (P0.06)
|
||||
{ MP_ROM_QSTR(MP_QSTR_PWM1), MP_ROM_PTR(&pin_P0_16) }, // MicroMod PWM1 (P0.16)
|
||||
|
||||
// MicroMod digital pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_P0_27) }, // MicroMod D0 (P0.27)
|
||||
{ MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_P1_08) }, // MicroMod D1 | CAM_TRIG (P1.08)
|
||||
|
||||
// MicroMod general purpose pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_G0), MP_ROM_PTR(&pin_P0_29) }, // MicroMod G0 | BUS0 (P0.29)
|
||||
{ MP_ROM_QSTR(MP_QSTR_G1), MP_ROM_PTR(&pin_P0_03) }, // MicroMod G1 | BUS1 (P0.03)
|
||||
{ MP_ROM_QSTR(MP_QSTR_G2), MP_ROM_PTR(&pin_P1_13) }, // MicroMod G2 | BUS2 (P1.13)
|
||||
{ MP_ROM_QSTR(MP_QSTR_G3), MP_ROM_PTR(&pin_P1_12) }, // MicroMod G3 | BUS3 (P1.12)
|
||||
{ MP_ROM_QSTR(MP_QSTR_G4), MP_ROM_PTR(&pin_P1_11) }, // MicroMod G4 | BUS4 (P1.11)
|
||||
{ MP_ROM_QSTR(MP_QSTR_G5), MP_ROM_PTR(&pin_P0_17) }, // MicroMod G5 | BUS5 (P0.17)
|
||||
{ MP_ROM_QSTR(MP_QSTR_G6), MP_ROM_PTR(&pin_P1_06) }, // MicroMod G6 | BUS6 (P1.06)
|
||||
{ MP_ROM_QSTR(MP_QSTR_G7), MP_ROM_PTR(&pin_P1_04) }, // MicroMod G7 | BUS7 (P1.04)
|
||||
{ MP_ROM_QSTR(MP_QSTR_G8), MP_ROM_PTR(&pin_P1_14) }, // MicroMod G8 (P1.14)
|
||||
{ MP_ROM_QSTR(MP_QSTR_G9), MP_ROM_PTR(&pin_P0_09) }, // MicroMod G9 | ADC_D- | CAM_HSYNC (P0.09)
|
||||
{ MP_ROM_QSTR(MP_QSTR_G10), MP_ROM_PTR(&pin_P0_10) }, // MicroMod G10 | ADC_D+ | CAM_VSYNC (P0.10)
|
||||
// { MP_ROM_QSTR(MP_QSTR_G11), MP_ROM_PTR() }, // MicroMod G11 | SWO (not connected)
|
||||
|
||||
// MicroMod 8-bit bus pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_BUS0), MP_ROM_PTR(&pin_P0_29) }, // MicroMod BUS0 | G0 (P0.29)
|
||||
{ MP_ROM_QSTR(MP_QSTR_BUS1), MP_ROM_PTR(&pin_P0_03) }, // MicroMod BUS1 | G1 (P0.03)
|
||||
{ MP_ROM_QSTR(MP_QSTR_BUS2), MP_ROM_PTR(&pin_P1_13) }, // MicroMod BUS2 | G2 (P1.13)
|
||||
{ MP_ROM_QSTR(MP_QSTR_BUS3), MP_ROM_PTR(&pin_P1_12) }, // MicroMod BUS3 | G3 (P1.12)
|
||||
{ MP_ROM_QSTR(MP_QSTR_BUS4), MP_ROM_PTR(&pin_P1_11) }, // MicroMod BUS4 | G4 (P1.11)
|
||||
{ MP_ROM_QSTR(MP_QSTR_BUS5), MP_ROM_PTR(&pin_P0_17) }, // MicroMod BUS5 | G5 (P0.17)
|
||||
{ MP_ROM_QSTR(MP_QSTR_BUS6), MP_ROM_PTR(&pin_P1_06) }, // MicroMod BUS6 | G6 (P1.06)
|
||||
{ MP_ROM_QSTR(MP_QSTR_BUS7), MP_ROM_PTR(&pin_P1_04) }, // MicroMod BUS7 | G7 (P1.04)
|
||||
|
||||
// MicroMod differential ADC input pins (not supported by MDBT50Q-P1M)
|
||||
// { MP_ROM_QSTR(MP_QSTR_ADC_DM), MP_ROM_PTR(&pin_P0_09) }, // MicroMod ADC_D- | G9 | CAM_HSYNC (P0.09)
|
||||
// { MP_ROM_QSTR(MP_QSTR_ADC_DP), MP_ROM_PTR(&pin_P0_10) }, // MicroMod ADC_D+ | G10 | CAM_VSYNC (P0.10)
|
||||
|
||||
// MicroMod camera pins (not supported by MDBT50Q-P1M)
|
||||
// { MP_ROM_QSTR(MP_QSTR_CAM_MCLK), MP_ROM_PTR() }, // MicroMod CAM_MCLK | AUD_OUT | I2S_OUT | PCM_OUT (not connected)
|
||||
// { MP_ROM_QSTR(MP_QSTR_CAM_PCLK), MP_ROM_PTR() }, // MicroMod CAM_PCLK | AUD_IN | I2S_IN | PCM_IN (not connected)
|
||||
// { MP_ROM_QSTR(MP_QSTR_CAM_TRIG), MP_ROM_PTR(&pin_P1_08) }, // MicroMod CAM_TRIG | D1 (P1.08)
|
||||
// { MP_ROM_QSTR(MP_QSTR_CAM_HSYNC), MP_ROM_PTR(&pin_P0_09) },// MicroMod CAM_HSYNC | ADC_D- | G9 (P0.09)
|
||||
// { MP_ROM_QSTR(MP_QSTR_CAM_VSYNC), MP_ROM_PTR(&pin_P0_10) },// MicroMod CAM_VSYNC | ADC_D+ | G10 (P0.10)
|
||||
|
||||
// CircuitPython board objects
|
||||
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, // CircuitPython I2C
|
||||
{ MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, // CircuitPython SPI
|
||||
{ MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, // CircuitPython UART
|
||||
};
|
||||
|
||||
MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);
|
||||
|
@ -28,6 +28,7 @@
|
||||
|
||||
#include "shared-bindings/audiocore/RawSample.h"
|
||||
#include "shared-bindings/audiocore/WaveFile.h"
|
||||
#include "shared-bindings/microcontroller/__init__.h"
|
||||
#include "supervisor/background_callback.h"
|
||||
|
||||
#include "py/mpstate.h"
|
||||
@ -37,10 +38,8 @@
|
||||
|
||||
#if CIRCUITPY_AUDIOPWMIO || CIRCUITPY_AUDIOBUSIO
|
||||
|
||||
#define AUDIO_DMA_CHANNEL_COUNT NUM_DMA_CHANNELS
|
||||
|
||||
void audio_dma_reset(void) {
|
||||
for (size_t channel = 0; channel < AUDIO_DMA_CHANNEL_COUNT; channel++) {
|
||||
for (size_t channel = 0; channel < NUM_DMA_CHANNELS; channel++) {
|
||||
if (MP_STATE_PORT(playing_audio)[channel] == NULL) {
|
||||
continue;
|
||||
}
|
||||
@ -49,116 +48,152 @@ void audio_dma_reset(void) {
|
||||
}
|
||||
}
|
||||
|
||||
void audio_dma_convert_signed(audio_dma_t *dma, uint8_t *buffer, uint32_t buffer_length,
|
||||
uint8_t **output_buffer, uint32_t *output_buffer_length) {
|
||||
if (dma->first_buffer_free) {
|
||||
*output_buffer = dma->first_buffer;
|
||||
} else {
|
||||
*output_buffer = dma->second_buffer;
|
||||
}
|
||||
|
||||
STATIC void audio_dma_convert_samples(
|
||||
audio_dma_t *dma,
|
||||
uint8_t *input, uint32_t input_length,
|
||||
uint8_t *available_output_buffer, uint32_t available_output_buffer_length,
|
||||
uint8_t **output, uint32_t *output_length) {
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wcast-align"
|
||||
|
||||
// Check whether a conversion is necessary
|
||||
if (dma->signed_to_unsigned ||
|
||||
dma->unsigned_to_signed ||
|
||||
dma->sample_spacing > 1 ||
|
||||
(dma->sample_resolution != dma->output_resolution)) {
|
||||
*output_buffer_length = buffer_length / dma->sample_spacing;
|
||||
|
||||
// Must convert.
|
||||
// Write the conversion into the passed-in output buffer
|
||||
*output = available_output_buffer;
|
||||
*output_length = input_length / dma->sample_spacing;
|
||||
|
||||
if (*output_length > available_output_buffer_length) {
|
||||
mp_raise_RuntimeError(translate("Internal audio buffer too small"));
|
||||
}
|
||||
|
||||
uint32_t out_i = 0;
|
||||
if (dma->sample_resolution <= 8 && dma->output_resolution > 8) {
|
||||
// reading bytes, writing 16-bit words, so output buffer will be bigger.
|
||||
|
||||
*output_length = *output_length * 2;
|
||||
if (*output_length > available_output_buffer_length) {
|
||||
mp_raise_RuntimeError(translate("Internal audio buffer too small"));
|
||||
}
|
||||
|
||||
size_t shift = dma->output_resolution - dma->sample_resolution;
|
||||
|
||||
for (uint32_t i = 0; i < buffer_length; i += dma->sample_spacing) {
|
||||
for (uint32_t i = 0; i < input_length; i += dma->sample_spacing) {
|
||||
if (dma->signed_to_unsigned) {
|
||||
((uint16_t *)*output_buffer)[out_i] = ((uint16_t)((int8_t *)buffer)[i] + 0x80) << shift;
|
||||
((uint16_t *)*output)[out_i] = ((uint16_t)((int8_t *)input)[i] + 0x80) << shift;
|
||||
} else if (dma->unsigned_to_signed) {
|
||||
((int16_t *)*output_buffer)[out_i] = ((int16_t)((uint8_t *)buffer)[i] - 0x80) << shift;
|
||||
((int16_t *)*output)[out_i] = ((int16_t)((uint8_t *)input)[i] - 0x80) << shift;
|
||||
} else {
|
||||
((uint16_t *)*output_buffer)[out_i] = ((uint16_t)((uint8_t *)buffer)[i]) << shift;
|
||||
((uint16_t *)*output)[out_i] = ((uint16_t)((uint8_t *)input)[i]) << shift;
|
||||
}
|
||||
out_i += 1;
|
||||
}
|
||||
} else if (dma->sample_resolution <= 8 && dma->output_resolution <= 8) {
|
||||
for (uint32_t i = 0; i < buffer_length; i += dma->sample_spacing) {
|
||||
for (uint32_t i = 0; i < input_length; i += dma->sample_spacing) {
|
||||
if (dma->signed_to_unsigned) {
|
||||
((uint8_t *)*output_buffer)[out_i] = ((int8_t *)buffer)[i] + 0x80;
|
||||
((uint8_t *)*output)[out_i] = ((int8_t *)input)[i] + 0x80;
|
||||
} else if (dma->unsigned_to_signed) {
|
||||
((int8_t *)*output_buffer)[out_i] = ((uint8_t *)buffer)[i] - 0x80;
|
||||
((int8_t *)*output)[out_i] = ((uint8_t *)input)[i] - 0x80;
|
||||
} else {
|
||||
((uint8_t *)*output_buffer)[out_i] = ((uint8_t *)buffer)[i];
|
||||
((uint8_t *)*output)[out_i] = ((uint8_t *)input)[i];
|
||||
}
|
||||
out_i += 1;
|
||||
}
|
||||
} else if (dma->sample_resolution > 8 && dma->output_resolution > 8) {
|
||||
size_t shift = 16 - dma->output_resolution;
|
||||
for (uint32_t i = 0; i < buffer_length / 2; i += dma->sample_spacing) {
|
||||
for (uint32_t i = 0; i < input_length / 2; i += dma->sample_spacing) {
|
||||
if (dma->signed_to_unsigned) {
|
||||
((uint16_t *)*output_buffer)[out_i] = ((int16_t *)buffer)[i] + 0x8000;
|
||||
((uint16_t *)*output)[out_i] = ((int16_t *)input)[i] + 0x8000;
|
||||
} else if (dma->unsigned_to_signed) {
|
||||
((int16_t *)*output_buffer)[out_i] = ((uint16_t *)buffer)[i] - 0x8000;
|
||||
((int16_t *)*output)[out_i] = ((uint16_t *)input)[i] - 0x8000;
|
||||
} else {
|
||||
((uint16_t *)*output_buffer)[out_i] = ((uint16_t *)buffer)[i];
|
||||
((uint16_t *)*output)[out_i] = ((uint16_t *)input)[i];
|
||||
}
|
||||
if (dma->output_resolution < 16) {
|
||||
if (dma->output_signed) {
|
||||
((int16_t *)*output_buffer)[out_i] = ((int16_t *)*output_buffer)[out_i] >> shift;
|
||||
((int16_t *)*output)[out_i] = ((int16_t *)*output)[out_i] >> shift;
|
||||
} else {
|
||||
((uint16_t *)*output_buffer)[out_i] = ((uint16_t *)*output_buffer)[out_i] >> shift;
|
||||
((uint16_t *)*output)[out_i] = ((uint16_t *)*output)[out_i] >> shift;
|
||||
}
|
||||
}
|
||||
out_i += 1;
|
||||
}
|
||||
} else {
|
||||
// (dma->sample_resolution > 8 && dma->output_resolution <= 8)
|
||||
// Not currently used, but might be in the future.
|
||||
mp_raise_RuntimeError(translate("Audio conversion not implemented"));
|
||||
}
|
||||
} else {
|
||||
*output_buffer = buffer;
|
||||
*output_buffer_length = buffer_length;
|
||||
// No conversion necessary. Designate the input buffer as the output buffer.
|
||||
*output = input;
|
||||
*output_length = input_length;
|
||||
}
|
||||
#pragma GCC diagnostic pop
|
||||
dma->first_buffer_free = !dma->first_buffer_free;
|
||||
}
|
||||
|
||||
void audio_dma_load_next_block(audio_dma_t *dma) {
|
||||
uint8_t dma_channel = dma->channel[1];
|
||||
if (dma->first_channel_free) {
|
||||
dma_channel = dma->channel[0];
|
||||
}
|
||||
dma->first_channel_free = !dma->first_channel_free;
|
||||
// channel_idx is 0 or 1.
|
||||
STATIC void audio_dma_load_next_block(audio_dma_t *dma, size_t buffer_idx) {
|
||||
size_t dma_channel = dma->channel[buffer_idx];
|
||||
|
||||
uint8_t *output_buffer;
|
||||
uint32_t output_buffer_length;
|
||||
audioio_get_buffer_result_t get_buffer_result;
|
||||
uint8_t *buffer;
|
||||
uint32_t buffer_length;
|
||||
uint8_t *sample_buffer;
|
||||
uint32_t sample_buffer_length;
|
||||
get_buffer_result = audiosample_get_buffer(dma->sample,
|
||||
dma->single_channel_output, dma->audio_channel, &buffer, &buffer_length);
|
||||
dma->single_channel_output, dma->audio_channel, &sample_buffer, &sample_buffer_length);
|
||||
|
||||
if (get_buffer_result == GET_BUFFER_ERROR) {
|
||||
audio_dma_stop(dma);
|
||||
return;
|
||||
}
|
||||
|
||||
audio_dma_convert_signed(dma, buffer, buffer_length, &output_buffer, &output_buffer_length);
|
||||
// Convert the sample format resolution and signedness, as necessary.
|
||||
// The input sample buffer is what was read from a file, Mixer, or a raw sample buffer.
|
||||
// The output buffer is one of the DMA buffers (passed in), or if no conversion was done,
|
||||
// the original sample buffer (to save copying).
|
||||
|
||||
// If we don't have an output buffer, save the pointer to first_buffer for use in the single
|
||||
// buffer special case.
|
||||
if (dma->first_buffer == NULL) {
|
||||
dma->first_buffer = output_buffer;
|
||||
}
|
||||
// audio_dma_convert_samples() will write the converted samples into the given output
|
||||
// buffer if necessary. If no conversion was needed, it will return the sample buffer
|
||||
// as the output buffer.
|
||||
uint8_t *output_buffer;
|
||||
uint32_t output_buffer_length;
|
||||
|
||||
audio_dma_convert_samples(dma, sample_buffer, sample_buffer_length,
|
||||
dma->buffer[buffer_idx], dma->buffer_length[buffer_idx],
|
||||
&output_buffer, &output_buffer_length);
|
||||
|
||||
dma_channel_set_trans_count(dma_channel, output_buffer_length / dma->output_size, false /* trigger */);
|
||||
dma_channel_set_read_addr(dma_channel, output_buffer, false /* trigger */);
|
||||
dma_channel_set_trans_count(dma_channel, output_buffer_length / dma->output_size, false /* trigger */);
|
||||
|
||||
if (get_buffer_result == GET_BUFFER_DONE) {
|
||||
if (dma->loop) {
|
||||
audiosample_reset_buffer(dma->sample, dma->single_channel_output, dma->audio_channel);
|
||||
} else {
|
||||
// Set channel trigger to ourselves so we don't keep going.
|
||||
dma_channel_hw_t *c = &dma_hw->ch[dma_channel];
|
||||
c->al1_ctrl = (c->al1_ctrl & ~DMA_CH0_CTRL_TRIG_CHAIN_TO_BITS) | (dma_channel << DMA_CH0_CTRL_TRIG_CHAIN_TO_LSB);
|
||||
c->al1_ctrl =
|
||||
(c->al1_ctrl & ~DMA_CH0_CTRL_TRIG_CHAIN_TO_BITS) |
|
||||
(dma_channel << DMA_CH0_CTRL_TRIG_CHAIN_TO_LSB);
|
||||
|
||||
if (output_buffer_length == 0 &&
|
||||
!dma_channel_is_busy(dma->channel[0]) &&
|
||||
!dma_channel_is_busy(dma->channel[1])) {
|
||||
// No data has been read, and both DMA channels have now finished, so it's safe to stop.
|
||||
audio_dma_stop(dma);
|
||||
dma->playing_in_progress = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Playback should be shutdown before calling this.
|
||||
audio_dma_result audio_dma_setup_playback(audio_dma_t *dma,
|
||||
audio_dma_result audio_dma_setup_playback(
|
||||
audio_dma_t *dma,
|
||||
mp_obj_t sample,
|
||||
bool loop,
|
||||
bool single_channel_output,
|
||||
@ -167,6 +202,7 @@ audio_dma_result audio_dma_setup_playback(audio_dma_t *dma,
|
||||
uint8_t output_resolution,
|
||||
uint32_t output_register_address,
|
||||
uint8_t dma_trigger_source) {
|
||||
|
||||
// Use two DMA channels to play because the DMA can't wrap to itself without the
|
||||
// buffer being power of two aligned.
|
||||
int dma_channel_0_maybe = dma_claim_unused_channel(false);
|
||||
@ -191,12 +227,15 @@ audio_dma_result audio_dma_setup_playback(audio_dma_t *dma,
|
||||
dma->unsigned_to_signed = false;
|
||||
dma->output_signed = output_signed;
|
||||
dma->sample_spacing = 1;
|
||||
dma->first_channel_free = true;
|
||||
dma->output_resolution = output_resolution;
|
||||
dma->sample_resolution = audiosample_bits_per_sample(sample);
|
||||
dma->output_register_address = output_register_address;
|
||||
|
||||
audiosample_reset_buffer(sample, single_channel_output, audio_channel);
|
||||
|
||||
bool single_buffer;
|
||||
|
||||
bool single_buffer; // True if data fits in one single buffer.
|
||||
|
||||
bool samples_signed;
|
||||
uint32_t max_buffer_length;
|
||||
audiosample_get_buffer_structure(sample, single_channel_output, &single_buffer, &samples_signed,
|
||||
@ -210,22 +249,25 @@ audio_dma_result audio_dma_setup_playback(audio_dma_t *dma,
|
||||
dma->sample_spacing > 1 ||
|
||||
(dma->sample_resolution != dma->output_resolution)) {
|
||||
max_buffer_length /= dma->sample_spacing;
|
||||
dma->first_buffer = (uint8_t *)m_realloc(dma->first_buffer, max_buffer_length);
|
||||
if (dma->first_buffer == NULL) {
|
||||
}
|
||||
|
||||
dma->buffer[0] = (uint8_t *)m_realloc(dma->buffer[0], max_buffer_length);
|
||||
dma->buffer_length[0] = max_buffer_length;
|
||||
if (dma->buffer[0] == NULL) {
|
||||
return AUDIO_DMA_MEMORY_ERROR;
|
||||
}
|
||||
|
||||
if (!single_buffer) {
|
||||
dma->buffer[1] = (uint8_t *)m_realloc(dma->buffer[1], max_buffer_length);
|
||||
dma->buffer_length[1] = max_buffer_length;
|
||||
if (dma->buffer[1] == NULL) {
|
||||
return AUDIO_DMA_MEMORY_ERROR;
|
||||
}
|
||||
|
||||
dma->first_buffer_free = true;
|
||||
if (!single_buffer) {
|
||||
dma->second_buffer = (uint8_t *)m_realloc(dma->second_buffer, max_buffer_length);
|
||||
if (dma->second_buffer == NULL) {
|
||||
return AUDIO_DMA_MEMORY_ERROR;
|
||||
}
|
||||
}
|
||||
dma->signed_to_unsigned = !output_signed && samples_signed;
|
||||
dma->unsigned_to_signed = output_signed && !samples_signed;
|
||||
}
|
||||
|
||||
dma->signed_to_unsigned = !output_signed && samples_signed;
|
||||
dma->unsigned_to_signed = output_signed && !samples_signed;
|
||||
|
||||
if (output_resolution > 8) {
|
||||
dma->output_size = 2;
|
||||
} else {
|
||||
@ -248,9 +290,11 @@ audio_dma_result audio_dma_setup_playback(audio_dma_t *dma,
|
||||
channel_config_set_dreq(&c, dma_trigger_source);
|
||||
channel_config_set_read_increment(&c, true);
|
||||
channel_config_set_write_increment(&c, false);
|
||||
|
||||
// Chain to the other channel by default.
|
||||
channel_config_set_chain_to(&c, dma->channel[(i + 1) % 2]);
|
||||
dma_channel_set_config(dma->channel[i], &c, false /* trigger */);
|
||||
|
||||
dma_channel_set_write_addr(dma->channel[i], (void *)output_register_address, false /* trigger */);
|
||||
}
|
||||
|
||||
@ -260,9 +304,9 @@ audio_dma_result audio_dma_setup_playback(audio_dma_t *dma,
|
||||
MP_STATE_PORT(playing_audio)[dma->channel[1]] = dma;
|
||||
|
||||
// Load the first two blocks up front.
|
||||
audio_dma_load_next_block(dma);
|
||||
audio_dma_load_next_block(dma, 0);
|
||||
if (!single_buffer) {
|
||||
audio_dma_load_next_block(dma);
|
||||
audio_dma_load_next_block(dma, 1);
|
||||
}
|
||||
|
||||
// Special case the DMA for a single buffer. It's commonly used for a single wave length of sound
|
||||
@ -279,16 +323,17 @@ audio_dma_result audio_dma_setup_playback(audio_dma_t *dma,
|
||||
channel_config_set_chain_to(&c, dma->channel[1]); // Chain to ourselves so we stop.
|
||||
dma_channel_configure(dma->channel[1], &c,
|
||||
&dma_hw->ch[dma->channel[0]].al3_read_addr_trig, // write address
|
||||
&dma->first_buffer, // read address
|
||||
&dma->buffer[0], // read address
|
||||
1, // transaction count
|
||||
false); // trigger
|
||||
} else {
|
||||
// Enable our DMA channels on DMA0 to the CPU. This will wake us up when
|
||||
// Enable our DMA channels on DMA_IRQ_0 to the CPU. This will wake us up when
|
||||
// we're WFI.
|
||||
dma_hw->inte0 |= (1 << dma->channel[0]) | (1 << dma->channel[1]);
|
||||
irq_set_mask_enabled(1 << DMA_IRQ_0, true);
|
||||
}
|
||||
|
||||
dma->playing_in_progress = true;
|
||||
dma_channel_start(dma->channel[0]);
|
||||
|
||||
return AUDIO_DMA_OK;
|
||||
@ -296,7 +341,14 @@ audio_dma_result audio_dma_setup_playback(audio_dma_t *dma,
|
||||
|
||||
void audio_dma_stop(audio_dma_t *dma) {
|
||||
// Disable our interrupts.
|
||||
dma_hw->inte0 &= ~((1 << dma->channel[0]) | (1 << dma->channel[1]));
|
||||
uint32_t channel_mask = 0;
|
||||
if (dma->channel[0] < NUM_DMA_CHANNELS) {
|
||||
channel_mask |= 1 << dma->channel[0];
|
||||
}
|
||||
if (dma->channel[1] < NUM_DMA_CHANNELS) {
|
||||
channel_mask |= 1 << dma->channel[1];
|
||||
}
|
||||
dma_hw->inte0 &= ~channel_mask;
|
||||
irq_set_mask_enabled(1 << DMA_IRQ_0, false);
|
||||
|
||||
// Run any remaining audio tasks because we remove ourselves from
|
||||
@ -305,6 +357,10 @@ void audio_dma_stop(audio_dma_t *dma) {
|
||||
|
||||
for (size_t i = 0; i < 2; i++) {
|
||||
size_t channel = dma->channel[i];
|
||||
if (channel == NUM_DMA_CHANNELS) {
|
||||
// Channel not in use.
|
||||
continue;
|
||||
}
|
||||
|
||||
dma_channel_config c = dma_channel_get_default_config(dma->channel[i]);
|
||||
channel_config_set_enable(&c, false);
|
||||
@ -313,6 +369,7 @@ void audio_dma_stop(audio_dma_t *dma) {
|
||||
if (dma_channel_is_busy(channel)) {
|
||||
dma_channel_abort(channel);
|
||||
}
|
||||
|
||||
dma_channel_set_read_addr(channel, NULL, false /* trigger */);
|
||||
dma_channel_set_write_addr(channel, NULL, false /* trigger */);
|
||||
dma_channel_set_trans_count(channel, 0, false /* trigger */);
|
||||
@ -320,6 +377,7 @@ void audio_dma_stop(audio_dma_t *dma) {
|
||||
MP_STATE_PORT(playing_audio)[channel] = NULL;
|
||||
dma->channel[i] = NUM_DMA_CHANNELS;
|
||||
}
|
||||
dma->playing_in_progress = false;
|
||||
|
||||
// Hold onto our buffers.
|
||||
}
|
||||
@ -344,7 +402,7 @@ void audio_dma_resume(audio_dma_t *dma) {
|
||||
}
|
||||
|
||||
bool audio_dma_get_paused(audio_dma_t *dma) {
|
||||
if (dma->channel[0] >= AUDIO_DMA_CHANNEL_COUNT) {
|
||||
if (dma->channel[0] >= NUM_DMA_CHANNELS) {
|
||||
return false;
|
||||
}
|
||||
uint32_t control = dma_hw->ch[dma->channel[0]].ctrl_trig;
|
||||
@ -353,30 +411,26 @@ bool audio_dma_get_paused(audio_dma_t *dma) {
|
||||
}
|
||||
|
||||
void audio_dma_init(audio_dma_t *dma) {
|
||||
dma->first_buffer = NULL;
|
||||
dma->second_buffer = NULL;
|
||||
dma->buffer[0] = NULL;
|
||||
dma->buffer[1] = NULL;
|
||||
|
||||
dma->channel[0] = NUM_DMA_CHANNELS;
|
||||
dma->channel[1] = NUM_DMA_CHANNELS;
|
||||
}
|
||||
|
||||
void audio_dma_deinit(audio_dma_t *dma) {
|
||||
m_free(dma->first_buffer);
|
||||
dma->first_buffer = NULL;
|
||||
m_free(dma->buffer[0]);
|
||||
dma->buffer[0] = NULL;
|
||||
|
||||
m_free(dma->second_buffer);
|
||||
dma->second_buffer = NULL;
|
||||
m_free(dma->buffer[1]);
|
||||
dma->buffer[1] = NULL;
|
||||
}
|
||||
|
||||
bool audio_dma_get_playing(audio_dma_t *dma) {
|
||||
if (dma->channel[0] == NUM_DMA_CHANNELS) {
|
||||
return false;
|
||||
}
|
||||
if (!dma_channel_is_busy(dma->channel[0]) &&
|
||||
!dma_channel_is_busy(dma->channel[1])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return dma->playing_in_progress;
|
||||
}
|
||||
|
||||
// WARN(tannewt): DO NOT print from here, or anything it calls. Printing calls
|
||||
@ -389,7 +443,25 @@ STATIC void dma_callback_fun(void *arg) {
|
||||
return;
|
||||
}
|
||||
|
||||
audio_dma_load_next_block(dma);
|
||||
common_hal_mcu_disable_interrupts();
|
||||
uint32_t channels_to_load_mask = dma->channels_to_load_mask;
|
||||
dma->channels_to_load_mask = 0;
|
||||
common_hal_mcu_enable_interrupts();
|
||||
|
||||
// Load the blocks for the requested channels.
|
||||
uint32_t channel = 0;
|
||||
while (channels_to_load_mask) {
|
||||
if (channels_to_load_mask & 1) {
|
||||
if (dma->channel[0] == channel) {
|
||||
audio_dma_load_next_block(dma, 0);
|
||||
}
|
||||
if (dma->channel[1] == channel) {
|
||||
audio_dma_load_next_block(dma, 1);
|
||||
}
|
||||
}
|
||||
channels_to_load_mask >>= 1;
|
||||
channel++;
|
||||
}
|
||||
}
|
||||
|
||||
void isr_dma_0(void) {
|
||||
@ -397,6 +469,8 @@ void isr_dma_0(void) {
|
||||
uint32_t mask = 1 << i;
|
||||
if ((dma_hw->intr & mask) != 0 && MP_STATE_PORT(playing_audio)[i] != NULL) {
|
||||
audio_dma_t *dma = MP_STATE_PORT(playing_audio)[i];
|
||||
// Record all channels whose DMA has completed; they need loading.
|
||||
dma->channels_to_load_mask |= mask;
|
||||
background_callback_add(&dma->callback, dma_callback_fun, (void *)dma);
|
||||
dma_hw->ints0 = mask;
|
||||
}
|
||||
|
@ -43,12 +43,13 @@ typedef struct {
|
||||
bool signed_to_unsigned;
|
||||
bool unsigned_to_signed;
|
||||
bool output_signed;
|
||||
bool first_channel_free;
|
||||
bool first_buffer_free;
|
||||
bool playing_in_progress;
|
||||
uint8_t output_resolution; // in bits
|
||||
uint8_t sample_resolution; // in bits
|
||||
uint8_t *first_buffer;
|
||||
uint8_t *second_buffer;
|
||||
uint8_t *buffer[2];
|
||||
size_t buffer_length[2];
|
||||
uint32_t channels_to_load_mask;
|
||||
uint32_t output_register_address;
|
||||
background_callback_t callback;
|
||||
} audio_dma_t;
|
||||
|
||||
|
@ -69,7 +69,7 @@ void board_init(void) {
|
||||
&pin_GPIO24, // Command or data
|
||||
&pin_GPIO22, // Chip select
|
||||
&pin_GPIO23, // Reset
|
||||
1000000, // Baudrate
|
||||
10000000, // Baudrate
|
||||
0, // Polarity
|
||||
0); // Phase
|
||||
|
||||
|
@ -24,10 +24,17 @@
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef MICROPY_INCLUDED_RASPBERRYPI_COMMON_HAL_BUSIO_ONEWIRE_H
|
||||
#define MICROPY_INCLUDED_RASPBERRYPI_COMMON_HAL_BUSIO_ONEWIRE_H
|
||||
#include "supervisor/board.h"
|
||||
|
||||
// Use bitbangio.
|
||||
#include "shared-module/busio/OneWire.h"
|
||||
void board_init(void) {
|
||||
}
|
||||
|
||||
#endif // MICROPY_INCLUDED_RASPBERRYPI_COMMON_HAL_BUSIO_ONEWIRE_H
|
||||
bool board_requests_safe_mode(void) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void reset_board(void) {
|
||||
}
|
||||
|
||||
void board_deinit(void) {
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
#define MICROPY_HW_BOARD_NAME "Pimoroni Interstate 75"
|
||||
#define MICROPY_HW_MCU_NAME "rp2040"
|
||||
|
||||
#define CIRCUITPY_RGB_STATUS_INVERTED_PWM
|
||||
#define CIRCUITPY_RGB_STATUS_R (&pin_GPIO16)
|
||||
#define CIRCUITPY_RGB_STATUS_G (&pin_GPIO17)
|
||||
#define CIRCUITPY_RGB_STATUS_B (&pin_GPIO18)
|
||||
|
||||
#define DEFAULT_I2C_BUS_SCL (&pin_GPIO21)
|
||||
#define DEFAULT_I2C_BUS_SDA (&pin_GPIO20)
|
@ -0,0 +1,11 @@
|
||||
USB_VID = 0x2E8A
|
||||
USB_PID = 0x1009
|
||||
USB_PRODUCT = "Interstate 75"
|
||||
USB_MANUFACTURER = "Pimoroni"
|
||||
|
||||
CHIP_VARIANT = RP2040
|
||||
CHIP_FAMILY = rp2
|
||||
|
||||
EXTERNAL_FLASH_DEVICES = "W25Q64JVxQ"
|
||||
|
||||
CIRCUITPY__EVE = 1
|
@ -0,0 +1 @@
|
||||
// Put board-specific pico-sdk definitions here. This file must exist.
|
52
ports/raspberrypi/boards/pimoroni_interstate75/pins.c
Normal file
52
ports/raspberrypi/boards/pimoroni_interstate75/pins.c
Normal file
@ -0,0 +1,52 @@
|
||||
#include "shared-bindings/board/__init__.h"
|
||||
|
||||
STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR_R0), MP_ROM_PTR(&pin_GPIO0) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_G0), MP_ROM_PTR(&pin_GPIO1) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_B0), MP_ROM_PTR(&pin_GPIO2) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_R1), MP_ROM_PTR(&pin_GPIO3) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_G1), MP_ROM_PTR(&pin_GPIO4) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_B1), MP_ROM_PTR(&pin_GPIO5) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_ROW_A), MP_ROM_PTR(&pin_GPIO6) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_ROW_B), MP_ROM_PTR(&pin_GPIO7) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_ROW_C), MP_ROM_PTR(&pin_GPIO8) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_ROW_D), MP_ROM_PTR(&pin_GPIO9) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_ROW_E), MP_ROM_PTR(&pin_GPIO10) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_CLK), MP_ROM_PTR(&pin_GPIO11) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_LAT), MP_ROM_PTR(&pin_GPIO12) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_OE), MP_ROM_PTR(&pin_GPIO13) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_SW_A), MP_ROM_PTR(&pin_GPIO14) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_LED_R), MP_ROM_PTR(&pin_GPIO16) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_LED_G), MP_ROM_PTR(&pin_GPIO17) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_LED_B), MP_ROM_PTR(&pin_GPIO18) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_INT), MP_ROM_PTR(&pin_GPIO19) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP19), MP_ROM_PTR(&pin_GPIO19) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO20) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP20), MP_ROM_PTR(&pin_GPIO20) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO21) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP21), MP_ROM_PTR(&pin_GPIO21) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_USER_SW), MP_ROM_PTR(&pin_GPIO23) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP26_A0), MP_ROM_PTR(&pin_GPIO26) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP26), MP_ROM_PTR(&pin_GPIO26) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO26) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP27_A1), MP_ROM_PTR(&pin_GPIO27) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP27), MP_ROM_PTR(&pin_GPIO27) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO27) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP28_A2), MP_ROM_PTR(&pin_GPIO28) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP28), MP_ROM_PTR(&pin_GPIO28) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO28) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_CURRENT_SENSE), MP_ROM_PTR(&pin_GPIO29) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
|
||||
};
|
||||
MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);
|
@ -3,7 +3,7 @@
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2020 Scott Shawcroft
|
||||
* Copyright (c) 2021 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,10 +24,17 @@
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef MICROPY_INCLUDED_ESP32S2_COMMON_HAL_BUSIO_ONEWIRE_H
|
||||
#define MICROPY_INCLUDED_ESP32S2_COMMON_HAL_BUSIO_ONEWIRE_H
|
||||
#include "supervisor/board.h"
|
||||
|
||||
// Use bitbangio.
|
||||
#include "shared-module/busio/OneWire.h"
|
||||
void board_init(void) {
|
||||
}
|
||||
|
||||
#endif // MICROPY_INCLUDED_ESP32S2_COMMON_HAL_BUSIO_ONEWIRE_H
|
||||
bool board_requests_safe_mode(void) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void reset_board(void) {
|
||||
}
|
||||
|
||||
void board_deinit(void) {
|
||||
}
|
10
ports/raspberrypi/boards/pimoroni_plasma2040/mpconfigboard.h
Normal file
10
ports/raspberrypi/boards/pimoroni_plasma2040/mpconfigboard.h
Normal file
@ -0,0 +1,10 @@
|
||||
#define MICROPY_HW_BOARD_NAME "Pimoroni Plasma 2040"
|
||||
#define MICROPY_HW_MCU_NAME "rp2040"
|
||||
|
||||
#define CIRCUITPY_RGB_STATUS_INVERTED_PWM
|
||||
#define CIRCUITPY_RGB_STATUS_R (&pin_GPIO16)
|
||||
#define CIRCUITPY_RGB_STATUS_G (&pin_GPIO17)
|
||||
#define CIRCUITPY_RGB_STATUS_B (&pin_GPIO18)
|
||||
|
||||
#define DEFAULT_I2C_BUS_SCL (&pin_GPIO21)
|
||||
#define DEFAULT_I2C_BUS_SDA (&pin_GPIO20)
|
@ -0,0 +1,11 @@
|
||||
USB_VID = 0x2E8A
|
||||
USB_PID = 0x100a
|
||||
USB_PRODUCT = "Plasma 2040"
|
||||
USB_MANUFACTURER = "Pimoroni"
|
||||
|
||||
CHIP_VARIANT = RP2040
|
||||
CHIP_FAMILY = rp2
|
||||
|
||||
EXTERNAL_FLASH_DEVICES = "W25Q64JVxQ"
|
||||
|
||||
CIRCUITPY__EVE = 1
|
@ -0,0 +1 @@
|
||||
// Put board-specific pico-sdk definitions here. This file must exist.
|
41
ports/raspberrypi/boards/pimoroni_plasma2040/pins.c
Normal file
41
ports/raspberrypi/boards/pimoroni_plasma2040/pins.c
Normal file
@ -0,0 +1,41 @@
|
||||
#include "shared-bindings/board/__init__.h"
|
||||
|
||||
STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR_SW_A), MP_ROM_PTR(&pin_GPIO12) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_SW_B), MP_ROM_PTR(&pin_GPIO13) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_CLK), MP_ROM_PTR(&pin_GPIO14) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP14), MP_ROM_PTR(&pin_GPIO14) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_DATA), MP_ROM_PTR(&pin_GPIO15) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP15), MP_ROM_PTR(&pin_GPIO15) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_LED_R), MP_ROM_PTR(&pin_GPIO16) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_LED_G), MP_ROM_PTR(&pin_GPIO17) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_LED_B), MP_ROM_PTR(&pin_GPIO18) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_INT), MP_ROM_PTR(&pin_GPIO19) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP19), MP_ROM_PTR(&pin_GPIO19) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO20) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP20), MP_ROM_PTR(&pin_GPIO20) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO21) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP21), MP_ROM_PTR(&pin_GPIO21) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_USER_SW), MP_ROM_PTR(&pin_GPIO23) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP26_A0), MP_ROM_PTR(&pin_GPIO26) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP26), MP_ROM_PTR(&pin_GPIO26) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO26) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP27_A1), MP_ROM_PTR(&pin_GPIO27) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP27), MP_ROM_PTR(&pin_GPIO27) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO27) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP28_A2), MP_ROM_PTR(&pin_GPIO28) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_GP28), MP_ROM_PTR(&pin_GPIO28) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO28) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_CURRENT_SENSE), MP_ROM_PTR(&pin_GPIO29) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
|
||||
};
|
||||
MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);
|
@ -1,12 +1,15 @@
|
||||
#define MICROPY_HW_BOARD_NAME "SparkFun MicroMod ATP - RP2040"
|
||||
#define MICROPY_HW_BOARD_NAME "SparkFun MicroMod RP2040 Processor"
|
||||
#define MICROPY_HW_MCU_NAME "rp2040"
|
||||
|
||||
// Status LED
|
||||
#define MICROPY_HW_LED_STATUS (&pin_GPIO25)
|
||||
|
||||
#define DEFAULT_I2C_BUS_SCL (&pin_GPIO5)
|
||||
#define DEFAULT_I2C_BUS_SDA (&pin_GPIO4)
|
||||
|
||||
#define DEFAULT_SPI_BUS_SCK (&pin_GPIO14)
|
||||
#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO15)
|
||||
#define DEFAULT_SPI_BUS_MISO (&pin_GPIO12)
|
||||
#define DEFAULT_SPI_BUS_SCK (&pin_GPIO22)
|
||||
#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO23)
|
||||
#define DEFAULT_SPI_BUS_MISO (&pin_GPIO20)
|
||||
|
||||
#define DEFAULT_UART_BUS_RX (&pin_GPIO1)
|
||||
#define DEFAULT_UART_BUS_TX (&pin_GPIO0)
|
||||
|
@ -1,7 +1,7 @@
|
||||
USB_VID = 0x1B4F
|
||||
USB_PID = 0x0024
|
||||
USB_PRODUCT = "MicroMod RP2040"
|
||||
USB_MANUFACTURER = "SparkFun"
|
||||
USB_PRODUCT = "SparkFun MicroMod RP2040 Processor"
|
||||
USB_MANUFACTURER = "SparkFun Electronics"
|
||||
|
||||
CHIP_VARIANT = RP2040
|
||||
CHIP_FAMILY = rp2
|
||||
|
@ -1,105 +1,223 @@
|
||||
/*
|
||||
* 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) 2021 Chris Wilson
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "shared-bindings/board/__init__.h"
|
||||
|
||||
STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
|
||||
// D (Digital only) pins (D0,D1)
|
||||
{ MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_GPIO6) }, // GPIO6 - D0
|
||||
{ MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_GPIO7) }, // GPIO7 - D1
|
||||
// The SparkFun MicroMod spec uses a zero-based peripheral numbering scheme.
|
||||
// The 0th peripheral is the default and the "0" is omitted from the
|
||||
// peripheral name (e.g. "I2C" instead of "I2C0").
|
||||
//
|
||||
// For more details, see https://www.sparkfun.com/micromod#tech-specs
|
||||
|
||||
// A (ADC) pins (A0,A1)
|
||||
{ MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO26) }, // GPIO26 - A0 | ADC0
|
||||
{ MP_ROM_QSTR(MP_QSTR_ADC0), MP_ROM_PTR(&pin_GPIO26) }, // ADC0 alias
|
||||
{ MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO27) }, // GPIO27 - A1 | ADC1
|
||||
{ MP_ROM_QSTR(MP_QSTR_ADC1), MP_ROM_PTR(&pin_GPIO27) }, // ADC1 alias
|
||||
// MicroMod built-in status LED pin
|
||||
// Requirement from the "Designing with MicroMod" SparkFun article:
|
||||
// "... every Processor Board shall include one status LED connected to a
|
||||
// pin that is not connected to the board edge."
|
||||
// Note: GPIO25 is connected to both the status LED and edge connector pin
|
||||
// G10, which doesn't comply with the requirement above...
|
||||
{ MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO25) }, // MicroMod LED (GPIO25)
|
||||
|
||||
// G (General/BUS) pins (G0-G7, G8 NC, G9-G10, G11 NC)
|
||||
{ MP_ROM_QSTR(MP_QSTR_G0), MP_ROM_PTR(&pin_GPIO16) }, // GPIO16 - G0 | BUS0
|
||||
{ MP_ROM_QSTR(MP_QSTR_BUS0), MP_ROM_PTR(&pin_GPIO16) }, // BUS0 alias
|
||||
{ MP_ROM_QSTR(MP_QSTR_G1), MP_ROM_PTR(&pin_GPIO17) }, // GPIO17 - G1 | BUS1
|
||||
{ MP_ROM_QSTR(MP_QSTR_BUS1), MP_ROM_PTR(&pin_GPIO17) }, // BUS1 alias
|
||||
{ MP_ROM_QSTR(MP_QSTR_G2), MP_ROM_PTR(&pin_GPIO18) }, // GPIO18 - G2 | BUS2
|
||||
{ MP_ROM_QSTR(MP_QSTR_BUS2), MP_ROM_PTR(&pin_GPIO18) }, // BUS2 alias
|
||||
{ MP_ROM_QSTR(MP_QSTR_G3), MP_ROM_PTR(&pin_GPIO19) }, // GPIO19 - G3 | BUS3
|
||||
{ MP_ROM_QSTR(MP_QSTR_BUS3), MP_ROM_PTR(&pin_GPIO19) }, // BUS3 alias
|
||||
{ MP_ROM_QSTR(MP_QSTR_G4), MP_ROM_PTR(&pin_GPIO20) }, // GPIO20 - G4 | BUS4 | SPI_CIPO
|
||||
{ MP_ROM_QSTR(MP_QSTR_BUS4), MP_ROM_PTR(&pin_GPIO20) }, // BUS4 alias
|
||||
{ MP_ROM_QSTR(MP_QSTR_G5), MP_ROM_PTR(&pin_GPIO21) }, // GPIO21 - G5 | BUS5 | SPI_CS
|
||||
{ MP_ROM_QSTR(MP_QSTR_BUS5), MP_ROM_PTR(&pin_GPIO21) }, // BUS5 alias
|
||||
{ MP_ROM_QSTR(MP_QSTR_G6), MP_ROM_PTR(&pin_GPIO22) }, // GPIO22 - G6 | BUS6 | SPI_SCK
|
||||
{ MP_ROM_QSTR(MP_QSTR_BUS6), MP_ROM_PTR(&pin_GPIO22) }, // BUS6 alias
|
||||
{ MP_ROM_QSTR(MP_QSTR_G7), MP_ROM_PTR(&pin_GPIO23) }, // GPIO23 - G7 | BUS7 | SPI_COPI
|
||||
{ MP_ROM_QSTR(MP_QSTR_BUS7), MP_ROM_PTR(&pin_GPIO23) }, // BUS7 alias
|
||||
// NC - G8
|
||||
{ MP_ROM_QSTR(MP_QSTR_G9), MP_ROM_PTR(&pin_GPIO28) }, // GPIO28- G9 | BUS9 | ADC_D- | CAM_HSYNC
|
||||
{ MP_ROM_QSTR(MP_QSTR_BUS9), MP_ROM_PTR(&pin_GPIO28) }, // BUS9 alias
|
||||
{ MP_ROM_QSTR(MP_QSTR_ADC_DM), MP_ROM_PTR(&pin_GPIO28) }, // ADC_DM alias
|
||||
{ MP_ROM_QSTR(MP_QSTR_CAM_HSYNC), MP_ROM_PTR(&pin_GPIO28) }, // CAM_HSYNC alias
|
||||
{ MP_ROM_QSTR(MP_QSTR_G10), MP_ROM_PTR(&pin_GPIO25) }, // GPIO25 - G10 | BUS10 | ADC_D+ | CAM_VSYNC
|
||||
{ MP_ROM_QSTR(MP_QSTR_BUS10), MP_ROM_PTR(&pin_GPIO25) }, // BUS10 alias
|
||||
{ MP_ROM_QSTR(MP_QSTR_ADC_DP), MP_ROM_PTR(&pin_GPIO25) }, // ADC_DP alias
|
||||
{ MP_ROM_QSTR(MP_QSTR_CAM_VSYNC), MP_ROM_PTR(&pin_GPIO25) }, // CAM_VSYNC alias
|
||||
// NC - G11
|
||||
// MicroMod USB bus input voltage (+5V) pin
|
||||
// { MP_ROM_QSTR(MP_QSTR_USB_VIN), MP_ROM_PTR() }, // MicroMod USB_VIN (not connected)
|
||||
|
||||
// PWM pins (PWM0,PWM1)
|
||||
{ MP_ROM_QSTR(MP_QSTR_PWM0), MP_ROM_PTR(&pin_GPIO13) }, // GPIO13 - PWM0
|
||||
{ MP_ROM_QSTR(MP_QSTR_PWM1), MP_ROM_PTR(&pin_GPIO24) }, // GPIO24 - PWM1 | AUD_MCLK
|
||||
// MicroMod +3.3V enable pin
|
||||
// { MP_ROM_QSTR(MP_QSTR_P3V3_EN), MP_ROM_PTR() }, // MicroMod 3.3V_EN (not connected)
|
||||
|
||||
// AUD (audio)
|
||||
{ MP_ROM_QSTR(MP_QSTR_AUD_MCLK), MP_ROM_PTR(&pin_GPIO24) }, // GPIO24 - AUD_MCLK | PWM1
|
||||
{ MP_ROM_QSTR(MP_QSTR_AUD_OUT), MP_ROM_PTR(&pin_GPIO10) }, // GPIO10 - AUD_OUT | SDIO_DAT2
|
||||
{ MP_ROM_QSTR(MP_QSTR_AUD_IN), MP_ROM_PTR(&pin_GPIO11) }, // GPIO11 - AUD_IN | SDIO_DAT1
|
||||
{ MP_ROM_QSTR(MP_QSTR_AUD_LRCLK), MP_ROM_PTR(&pin_GPIO2) }, // GPIO2 - AUD_LRCLK | CTS1
|
||||
{ MP_ROM_QSTR(MP_QSTR_AUD_BCLK), MP_ROM_PTR(&pin_GPIO3) }, // GPIO3 - AUD_BCLK | UART_RTS1
|
||||
// MicroMod battery voltage sense pin
|
||||
{ MP_ROM_QSTR(MP_QSTR_BATT_VIN3), MP_ROM_PTR(&pin_GPIO29) }, // MicroMod BATT_VIN/3 (GPIO29)
|
||||
|
||||
// Battery Voltage Monitor
|
||||
{ MP_ROM_QSTR(MP_QSTR_BATT_VIN3), MP_ROM_PTR(&pin_GPIO29) }, // GPIO29 - BATT_VIN/3 (ADC03)
|
||||
// MicroMod reset pin
|
||||
// { MP_ROM_QSTR(MP_QSTR_RESET), MP_ROM_PTR() }, // MicroMod RESET# (RP2040 has a dedicated HW RUN pin)
|
||||
|
||||
// MicroMod boot pin
|
||||
// { MP_ROM_QSTR(MP_QSTR_BOOT), MP_ROM_PTR() }, // MicroMod BOOT (RP2040 does not have a dedicated BOOT pin)
|
||||
|
||||
// I2C
|
||||
{ MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO4) }, // GPIO4 - SDA
|
||||
{ MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO5) }, // GPIO5 - SCL
|
||||
// MicroMod USB device pins
|
||||
// USB device is always used internally by CircuitPython, so skip creating
|
||||
// the pin objects for it.
|
||||
// { MP_ROM_QSTR(MP_QSTR_USB_DM), MP_ROM_PTR() }, // MicroMod USB_D- (RP2040 has a dedicated HW USB_DM pin)
|
||||
// { MP_ROM_QSTR(MP_QSTR_USB_DP), MP_ROM_PTR() }, // MicroMod USB_D+ (RP2040 has a dedicated HW USB_DP pin)
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_I2C_INT), MP_ROM_PTR(&pin_GPIO8) }, // GPIO9 - I2C_INT | TX2
|
||||
// MicroMod USB host pins
|
||||
// { MP_ROM_QSTR(MP_QSTR_USBHOST_DM), MP_ROM_PTR() }, // MicroMod USBHOST_D- (RP2040 has a dedicated HW USB_DM pin)
|
||||
// { MP_ROM_QSTR(MP_QSTR_USBHOST_DP), MP_ROM_PTR() }, // MicroMod USBHOST_D+ (RP2040 has a dedicated HW USB_DP pin)
|
||||
|
||||
// SPI
|
||||
{ MP_ROM_QSTR(MP_QSTR_CIPO), MP_ROM_PTR(&pin_GPIO20) }, // GPIO20 - CIPO | SPI_CIPO | G4
|
||||
{ MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO20) }, // MISO alias
|
||||
{ MP_ROM_QSTR(MP_QSTR_COPI), MP_ROM_PTR(&pin_GPIO23) }, // GPIO23 - COPI | SPI_COPI | G7
|
||||
{ MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO23) }, // MOSI alias
|
||||
{ MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO22) }, // GPIO22 - SCK | SPI_SCK | G6
|
||||
{ MP_ROM_QSTR(MP_QSTR_CS), MP_ROM_PTR(&pin_GPIO21) }, // GPIO21 - /CS | SPI_/CS | G5
|
||||
// MicroMod CAN pins
|
||||
// { MP_ROM_QSTR(MP_QSTR_CAN_RX), MP_ROM_PTR() }, // MicroMod CAN_RX (not supported)
|
||||
// { MP_ROM_QSTR(MP_QSTR_CAN_TX), MP_ROM_PTR() }, // MicroMod CAN_TX (not supported)
|
||||
|
||||
// SDI/SPI1
|
||||
{ MP_ROM_QSTR(MP_QSTR_SDIO_CLK), MP_ROM_PTR(&pin_GPIO14) }, // GPIO14 - SDIO SCK | SDIO_CLK
|
||||
{ MP_ROM_QSTR(MP_QSTR_SPI_SCK1), MP_ROM_PTR(&pin_GPIO14) }, // SPI_SCK1 alias
|
||||
{ MP_ROM_QSTR(MP_QSTR_SDIO_CMD), MP_ROM_PTR(&pin_GPIO15) }, // GPIO15 - SDIO CMD | SDIO_CMD
|
||||
{ MP_ROM_QSTR(MP_QSTR_SPI_COPI1), MP_ROM_PTR(&pin_GPIO15) },// SPI_COPI1 alias
|
||||
{ MP_ROM_QSTR(MP_QSTR_SDIO_DATA0), MP_ROM_PTR(&pin_GPIO12) },// GPIO12 - SDIO DATA0 | SDIO_DATA0
|
||||
{ MP_ROM_QSTR(MP_QSTR_SPI_CIPO1), MP_ROM_PTR(&pin_GPIO12) }, // SPI_CIPO1 alias
|
||||
{ MP_ROM_QSTR(MP_QSTR_SDIO_DATA1), MP_ROM_PTR(&pin_GPIO11) },// GPIO11 - SDIO DATA1 | SDIO_DATA1 | AUD_IN
|
||||
{ MP_ROM_QSTR(MP_QSTR_SDIO_DATA2), MP_ROM_PTR(&pin_GPIO10) },// GPIO10 - SDIO DATA2 | SDIO_DATA2 | AUD_OUT
|
||||
{ MP_ROM_QSTR(MP_QSTR_SDIO_DATA3), MP_ROM_PTR(&pin_GPIO9) },// GPIO9 - SDIO DATA3 | SDIO_DATA3 | SPI_CS1
|
||||
{ MP_ROM_QSTR(MP_QSTR_SPI_CS1), MP_ROM_PTR(&pin_GPIO9) }, // SPI_CS1 alias
|
||||
// Note: MicroMod UART (UART0) is not present in the edge connector pinout
|
||||
// because the primary debug serial port is exposed as a virtual serial port
|
||||
// over USB.
|
||||
|
||||
// Status LED
|
||||
{ MP_ROM_QSTR(MP_QSTR_LED1), MP_ROM_PTR(&pin_GPIO25) }, // GPIO25 - LED_BUILTIN | STAT | Blue LED | G10
|
||||
// MicroMod UART1 pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_UART_TX1), MP_ROM_PTR(&pin_GPIO0) }, // MicroMod UART_TX1 | CircuitPython TX (GPIO0)
|
||||
{ MP_ROM_QSTR(MP_QSTR_UART_RX1), MP_ROM_PTR(&pin_GPIO1) }, // MicroMod UART_RX1 | CircuitPython RX (GPIO1)
|
||||
{ MP_ROM_QSTR(MP_QSTR_UART_RTS1), MP_ROM_PTR(&pin_GPIO3) }, // MicroMod RTS1 (GPIO3)
|
||||
{ MP_ROM_QSTR(MP_QSTR_UART_CTS1), MP_ROM_PTR(&pin_GPIO2) }, // MicroMod CTS1 (GPIO2)
|
||||
|
||||
// UART
|
||||
{ MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO1) }, // GPIO1 - UART RX | UART_RX1 | RX1
|
||||
{ MP_ROM_QSTR(MP_QSTR_RX1), MP_ROM_PTR(&pin_GPIO1) }, // RX1 alias
|
||||
{ MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO0) }, // GPIO0 - UART TX | UART_TX1 | TX1
|
||||
{ MP_ROM_QSTR(MP_QSTR_TX1), MP_ROM_PTR(&pin_GPIO0) }, // TX1 alias
|
||||
{ MP_ROM_QSTR(MP_QSTR_CTS), MP_ROM_PTR(&pin_GPIO2) }, // GPIO2 - UART CTS | CTS1 (TRACEDATA3)
|
||||
{ MP_ROM_QSTR(MP_QSTR_CTS1), MP_ROM_PTR(&pin_GPIO2) }, // CTS1 alias
|
||||
{ MP_ROM_QSTR(MP_QSTR_RTS), MP_ROM_PTR(&pin_GPIO3) }, // GPIO3 - UART RTS | RTS1
|
||||
{ MP_ROM_QSTR(MP_QSTR_RTS1), MP_ROM_PTR(&pin_GPIO3) }, // RTS1 alias
|
||||
// CircuitPython default UART pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_GPIO0) }, // CircuitPython TX | MicroMod UART_TX1 (GPIO0)
|
||||
{ MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_GPIO1) }, // CircuitPython RX | MicroMod UART_RX1 (GPIO1)
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_RX2), MP_ROM_PTR(&pin_GPIO9) }, // GPIO9 - UART RX | UART_RX2 | RX2 | SDIO_DAT3 | SPI_CS1
|
||||
{ MP_ROM_QSTR(MP_QSTR_TX2), MP_ROM_PTR(&pin_GPIO8) }, // GPIO8 - UART TX | UART_TX2 | TX2 | I2C_INT
|
||||
// MicroMod UART2 pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_UART_TX2), MP_ROM_PTR(&pin_GPIO8) }, // MicroMod UART_TX2 (GPIO8)
|
||||
{ MP_ROM_QSTR(MP_QSTR_UART_RX2), MP_ROM_PTR(&pin_GPIO9) }, // MicroMod UART_RX2 (GPIO9)
|
||||
|
||||
// Board 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) },
|
||||
// MicroMod I2C pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_I2C_SDA), MP_ROM_PTR(&pin_GPIO4) }, // MicroMod I2C_SDA | CircuitPython SDA (GPIO4)
|
||||
{ MP_ROM_QSTR(MP_QSTR_I2C_SCL), MP_ROM_PTR(&pin_GPIO5) }, // MicroMod I2C_SCL | CircuitPython SCL (GPIO5)
|
||||
|
||||
// CircuitPython default I2C pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_GPIO4) }, // CircuitPython SDA | MicroMod I2C_SDA (GPIO4)
|
||||
{ MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_GPIO5) }, // CircuitPython SCL | MicroMod I2C_SCL (GPIO5)
|
||||
|
||||
// MicroMod I2C interrupt pin
|
||||
{ MP_ROM_QSTR(MP_QSTR_I2C_INT), MP_ROM_PTR(&pin_GPIO8) }, // MicroMod I2C_INT (GPIO8)
|
||||
|
||||
// MicroMod I2C1 pins
|
||||
// { MP_ROM_QSTR(MP_QSTR_I2C_SDA1), MP_ROM_PTR() }, // MicroMod I2C_SDA1 (not connected)
|
||||
// { MP_ROM_QSTR(MP_QSTR_I2C_SCL1), MP_ROM_PTR() }, // MicroMod I2C_SCL1 (not connected)
|
||||
|
||||
// MicroMod SPI pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_SPI_CIPO), MP_ROM_PTR(&pin_GPIO20) }, // MicroMod SPI_CIPO | CircuitPython CIPO (GPIO20)
|
||||
{ MP_ROM_QSTR(MP_QSTR_SPI_MISO), MP_ROM_PTR(&pin_GPIO20) }, // MicroMod SPI_MISO | CircuitPython MISO (GPIO20)
|
||||
{ MP_ROM_QSTR(MP_QSTR_SPI_COPI), MP_ROM_PTR(&pin_GPIO23) }, // MicroMod SPI_COPI | CircuitPython COPI | LED_DAT (GPIO23)
|
||||
{ MP_ROM_QSTR(MP_QSTR_SPI_MOSI), MP_ROM_PTR(&pin_GPIO23) }, // MicroMod SPI_MOSI | CircuitPython MOSI (GPIO23)
|
||||
{ MP_ROM_QSTR(MP_QSTR_SPI_SCK), MP_ROM_PTR(&pin_GPIO22) }, // MicroMod SPI_SCK | CircuitPython SCK | LED_CLK (GPIO22)
|
||||
{ MP_ROM_QSTR(MP_QSTR_SPI_CS), MP_ROM_PTR(&pin_GPIO21) }, // MicroMod SPI_CS | CircuitPython CS (GPIO21)
|
||||
|
||||
// CircuitPython default SPI pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_CIPO), MP_ROM_PTR(&pin_GPIO20) }, // CircuitPython CIPO | MicroMod SPI_CIPO (GPIO20)
|
||||
{ MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_GPIO20) }, // CircuitPython MISO | MicroMod SPI_MISO (GPIO20)
|
||||
{ MP_ROM_QSTR(MP_QSTR_COPI), MP_ROM_PTR(&pin_GPIO23) }, // CircuitPython COPI | MicroMod SPI_COPI | LED_DAT (GPIO23)
|
||||
{ MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_GPIO23) }, // CircuitPython MOSI | MicroMod SPI_MOSI (GPIO23)
|
||||
{ MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_GPIO22) }, // CircuitPython SCK | MicroMod SPI_SCK | LED_CLK (GPIO22)
|
||||
{ MP_ROM_QSTR(MP_QSTR_CS), MP_ROM_PTR(&pin_GPIO21) }, // CircuitPython CS | MicroMod SPI_CS (GPIO21)
|
||||
|
||||
// MicroMod 2-wire serial LED pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_LED_DAT), MP_ROM_PTR(&pin_GPIO23) }, // MicroMod LED_DAT | SPI_COPI
|
||||
{ MP_ROM_QSTR(MP_QSTR_LED_CLK), MP_ROM_PTR(&pin_GPIO22) }, // MicroMod LED_CLK | SPI_SCK
|
||||
|
||||
// MicroMod SDIO pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_SDIO_CLK), MP_ROM_PTR(&pin_GPIO14) }, // MicroMod SDIO_SCK | SPI_SCK1 (GPIO14)
|
||||
{ MP_ROM_QSTR(MP_QSTR_SDIO_CMD), MP_ROM_PTR(&pin_GPIO15) }, // MicroMod SDIO_CMD | SPI_COPI1 (GPIO15)
|
||||
{ MP_ROM_QSTR(MP_QSTR_SDIO_DATA0), MP_ROM_PTR(&pin_GPIO12) }, // MicroMod SDIO_DATA0 | SPI_CIPO1 (GPIO12)
|
||||
{ MP_ROM_QSTR(MP_QSTR_SDIO_DATA1), MP_ROM_PTR(&pin_GPIO11) }, // MicroMod SDIO_DATA1 (GPIO11)
|
||||
{ MP_ROM_QSTR(MP_QSTR_SDIO_DATA2), MP_ROM_PTR(&pin_GPIO10) }, // MicroMod SDIO_DATA2 (GPIO10)
|
||||
{ MP_ROM_QSTR(MP_QSTR_SDIO_DATA3), MP_ROM_PTR(&pin_GPIO9) }, // MicroMod SDIO_DATA3 | SPI_CS1 (GPIO9)
|
||||
|
||||
// MicroMod SPI1 pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_SPI_CIPO1), MP_ROM_PTR(&pin_GPIO12) }, // MicroMod SPI_CIPO1 | SDIO_DATA0 (GPIO12)
|
||||
{ MP_ROM_QSTR(MP_QSTR_SPI_MISO1), MP_ROM_PTR(&pin_GPIO12) }, // MicroMod SPI_MISO1 (GPIO12)
|
||||
{ MP_ROM_QSTR(MP_QSTR_SPI_COPI1), MP_ROM_PTR(&pin_GPIO15) }, // MicroMod SPI_COPI1 | SDIO_CMD (GPIO15)
|
||||
{ MP_ROM_QSTR(MP_QSTR_SPI_MOSI1), MP_ROM_PTR(&pin_GPIO15) }, // MicroMod SPI_MOSI1 (GPIO15)
|
||||
{ MP_ROM_QSTR(MP_QSTR_SPI_SCK1), MP_ROM_PTR(&pin_GPIO14) }, // MicroMod SPI_SCK1 | SDIO_SCK (GPIO14)
|
||||
{ MP_ROM_QSTR(MP_QSTR_SPI_CS1), MP_ROM_PTR(&pin_GPIO9) }, // MicroMod SPI_CS1 | SDIO_DATA3 (GPIO9)
|
||||
|
||||
// MicroMod audio pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_AUD_MCLK), MP_ROM_PTR(&pin_GPIO24) }, // MicroMod AUD_MCLK (GPIO24)
|
||||
{ MP_ROM_QSTR(MP_QSTR_AUD_OUT), MP_ROM_PTR(&pin_GPIO10) }, // MicroMod AUD_OUT | I2S_OUT | PCM_OUT | CAM_MCLK (GPIO10)
|
||||
{ MP_ROM_QSTR(MP_QSTR_AUD_IN), MP_ROM_PTR(&pin_GPIO11) }, // MicroMod AUD_IN | I2S_IN | PCM_IN | CAM_PCLK (GPIO11)
|
||||
{ MP_ROM_QSTR(MP_QSTR_AUD_LRCLK), MP_ROM_PTR(&pin_GPIO2) }, // MicroMod AUD_LRCLK | I2S_WS | PCM_SYNC | PDM_DATA (GPIO2)
|
||||
{ MP_ROM_QSTR(MP_QSTR_AUD_BCLK), MP_ROM_PTR(&pin_GPIO3) }, // MicroMod AUD_BCLK | I2S_SCK | PCM_CLK | PDM_CLK (GPIO3)
|
||||
|
||||
// MicroMod I2S pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_I2S_OUT), MP_ROM_PTR(&pin_GPIO10) }, // MicroMod I2S_OUT | AUD_OUT | PCM_OUT | CAM_MCLK (GPIO10)
|
||||
{ MP_ROM_QSTR(MP_QSTR_I2S_IN), MP_ROM_PTR(&pin_GPIO11) }, // MicroMod I2S_IN | AUD_IN | PCM_IN | CAM_PCLK (GPIO11)
|
||||
{ MP_ROM_QSTR(MP_QSTR_I2S_WS), MP_ROM_PTR(&pin_GPIO2) }, // MicroMod I2S_WS | AUD_LRCLK | PCM_SYNC | PDM_DATA (GPIO2)
|
||||
{ MP_ROM_QSTR(MP_QSTR_I2S_SCK), MP_ROM_PTR(&pin_GPIO3) }, // MicroMod I2S_SCK | AUD_BCLK | PCM_CLK | PDM_CLK (GPIO3)
|
||||
|
||||
// MicroMod PCM pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_PCM_OUT), MP_ROM_PTR(&pin_GPIO10) }, // MicroMod PCM_OUT | AUD_OUT | I2S_OUT | CAM_MCLK (GPIO10)
|
||||
{ MP_ROM_QSTR(MP_QSTR_PCM_IN), MP_ROM_PTR(&pin_GPIO11) }, // MicroMod PCM_IN | AUD_IN | I2S_IN | CAM_PCLK (GPIO11)
|
||||
{ MP_ROM_QSTR(MP_QSTR_PCM_SYNC), MP_ROM_PTR(&pin_GPIO2) }, // MicroMod PCM_SYNC | AUD_LRCLK | I2S_WS | PDM_DATA (GPIO2)
|
||||
{ MP_ROM_QSTR(MP_QSTR_PCM_CLK), MP_ROM_PTR(&pin_GPIO3) }, // MicroMod PCM_CLK | AUD_BCLK | I2S_SCK | PDM_CLK (GPIO3)
|
||||
|
||||
// MicroMod PDM pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_PDM_DATA), MP_ROM_PTR(&pin_GPIO2) }, // MicroMod PDM_DATA | AUD_LRCLK | I2S_WS | PCM_SYNC (GPIO2)
|
||||
{ MP_ROM_QSTR(MP_QSTR_PDM_CLK), MP_ROM_PTR(&pin_GPIO3) }, // MicroMod PDM_CLK | AUD_BCLK | I2S_SCK | PCM_CLK (GPIO3)
|
||||
|
||||
// MicroMod SWD pins
|
||||
// { MP_ROM_QSTR(MP_QSTR_SWDIO), MP_ROM_PTR() }, // MicroMod SWDIO (RP2040 has a dedicated HW SWDIO pin)
|
||||
// { MP_ROM_QSTR(MP_QSTR_SWCLK), MP_ROM_PTR() }, // MicroMod SWDCK (RP2040 has a dedicated HW SWCLK pin)
|
||||
// { MP_ROM_QSTR(MP_QSTR_SWO), MP_ROM_PTR() }, // MicroMod SWO | G11 (not supported)
|
||||
|
||||
// MicroMod ADC pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_GPIO26) }, // MicroMod A0 (GPIO26)
|
||||
{ MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_GPIO27) }, // MicroMod A1 (GPIO27)
|
||||
|
||||
// MicroMod PWM pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_PWM0), MP_ROM_PTR(&pin_GPIO13) }, // MicroMod PWM0 (GPIO13)
|
||||
{ MP_ROM_QSTR(MP_QSTR_PWM1), MP_ROM_PTR(&pin_GPIO24) }, // MicroMod PWM1 (GPIO24)
|
||||
|
||||
// MicroMod digital pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_GPIO6) }, // MicroMod D0 (GPIO6)
|
||||
{ MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_GPIO7) }, // MicroMod D1 | CAM_TRIG (GPIO7)
|
||||
|
||||
// MicroMod general purpose pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_G0), MP_ROM_PTR(&pin_GPIO16) }, // MicroMod G0 | BUS0 (GPIO16)
|
||||
{ MP_ROM_QSTR(MP_QSTR_G1), MP_ROM_PTR(&pin_GPIO17) }, // MicroMod G1 | BUS1 (GPIO17)
|
||||
{ MP_ROM_QSTR(MP_QSTR_G2), MP_ROM_PTR(&pin_GPIO18) }, // MicroMod G2 | BUS2 (GPIO18)
|
||||
{ MP_ROM_QSTR(MP_QSTR_G3), MP_ROM_PTR(&pin_GPIO19) }, // MicroMod G3 | BUS3 (GPIO19)
|
||||
{ MP_ROM_QSTR(MP_QSTR_G4), MP_ROM_PTR(&pin_GPIO20) }, // MicroMod G4 | BUS4 (GPIO20)
|
||||
{ MP_ROM_QSTR(MP_QSTR_G5), MP_ROM_PTR(&pin_GPIO21) }, // MicroMod G5 | BUS5 (GPIO21)
|
||||
{ MP_ROM_QSTR(MP_QSTR_G6), MP_ROM_PTR(&pin_GPIO22) }, // MicroMod G6 | BUS6 (GPIO22)
|
||||
{ MP_ROM_QSTR(MP_QSTR_G7), MP_ROM_PTR(&pin_GPIO23) }, // MicroMod G7 | BUS7 (GPIO23)
|
||||
// { MP_ROM_QSTR(MP_QSTR_G8), MP_ROM_PTR() }, // MicroMod G8 (not connected)
|
||||
{ MP_ROM_QSTR(MP_QSTR_G9), MP_ROM_PTR(&pin_GPIO28) }, // MicroMod G9 | ADC_D- | CAM_HSYNC (GPIO28)
|
||||
{ MP_ROM_QSTR(MP_QSTR_G10), MP_ROM_PTR(&pin_GPIO25) }, // MicroMod G10 | ADC_D+ | CAM_VSYNC (GPIO25)
|
||||
// { MP_ROM_QSTR(MP_QSTR_G11), MP_ROM_PTR() }, // MicroMod G11 | SWO (not connected)
|
||||
|
||||
// MicroMod 8-bit bus pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_BUS0), MP_ROM_PTR(&pin_GPIO16) }, // MicroMod BUS0 | G0 (GPIO16)
|
||||
{ MP_ROM_QSTR(MP_QSTR_BUS1), MP_ROM_PTR(&pin_GPIO17) }, // MicroMod BUS1 | G1 (GPIO17)
|
||||
{ MP_ROM_QSTR(MP_QSTR_BUS2), MP_ROM_PTR(&pin_GPIO18) }, // MicroMod BUS2 | G2 (GPIO18)
|
||||
{ MP_ROM_QSTR(MP_QSTR_BUS3), MP_ROM_PTR(&pin_GPIO19) }, // MicroMod BUS3 | G3 (GPIO19)
|
||||
{ MP_ROM_QSTR(MP_QSTR_BUS4), MP_ROM_PTR(&pin_GPIO20) }, // MicroMod BUS4 | G4 (GPIO20)
|
||||
{ MP_ROM_QSTR(MP_QSTR_BUS5), MP_ROM_PTR(&pin_GPIO21) }, // MicroMod BUS5 | G5 (GPIO21)
|
||||
{ MP_ROM_QSTR(MP_QSTR_BUS6), MP_ROM_PTR(&pin_GPIO22) }, // MicroMod BUS6 | G6 (GPIO22)
|
||||
{ MP_ROM_QSTR(MP_QSTR_BUS7), MP_ROM_PTR(&pin_GPIO23) }, // MicroMod BUS7 | G7 (GPIO23)
|
||||
|
||||
// MicroMod differential ADC input pins (not supported by RP2040)
|
||||
// { MP_ROM_QSTR(MP_QSTR_ADC_DM), MP_ROM_PTR(&pin_GPIO28) }, // MicroMod ADC_D- | G9 | CAM_HSYNC (GPIO28)
|
||||
// { MP_ROM_QSTR(MP_QSTR_ADC_DP), MP_ROM_PTR(&pin_GPIO25) }, // MicroMod ADC_D+ | G10 | CAM_VSYNC (GPIO25)
|
||||
|
||||
// MicroMod camera pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_CAM_MCLK), MP_ROM_PTR(&pin_GPIO10) }, // MicroMod CAM_MCLK | AUD_OUT | I2S_OUT | PCM_OUT (GPIO10)
|
||||
{ MP_ROM_QSTR(MP_QSTR_CAM_PCLK), MP_ROM_PTR(&pin_GPIO11) }, // MicroMod CAM_PCLK | AUD_IN | I2S_IN | PCM_IN (GPIO11)
|
||||
{ MP_ROM_QSTR(MP_QSTR_CAM_TRIG), MP_ROM_PTR(&pin_GPIO7) }, // MicroMod CAM_TRIG | D1 (GPIO7)
|
||||
{ MP_ROM_QSTR(MP_QSTR_CAM_HSYNC), MP_ROM_PTR(&pin_GPIO28) }, // MicroMod CAM_HSYNC | ADC_D- | G9 (GPIO28)
|
||||
{ MP_ROM_QSTR(MP_QSTR_CAM_VSYNC), MP_ROM_PTR(&pin_GPIO25) }, // MicroMod CAM_VSYNC | ADC_D+ | G10 (GPIO25)
|
||||
|
||||
// CircuitPython board objects
|
||||
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, // CircuitPython I2C
|
||||
{ MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, // CircuitPython SPI
|
||||
{ MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, // CircuitPython UART
|
||||
};
|
||||
MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);
|
||||
|
@ -117,7 +117,8 @@ void common_hal_audiobusio_i2sout_construct(audiobusio_i2sout_obj_t *self,
|
||||
}
|
||||
|
||||
// Use the state machine to manage pins.
|
||||
common_hal_rp2pio_statemachine_construct(&self->state_machine,
|
||||
common_hal_rp2pio_statemachine_construct(
|
||||
&self->state_machine,
|
||||
program, program_len,
|
||||
44100 * 32 * 6, // Clock at 44.1 khz to warm the DAC up.
|
||||
NULL, 0,
|
||||
|
@ -38,7 +38,6 @@
|
||||
#include "shared-bindings/microcontroller/__init__.h"
|
||||
#include "shared-bindings/microcontroller/Pin.h"
|
||||
#include "shared-bindings/microcontroller/Processor.h"
|
||||
#include "supervisor/shared/tick.h"
|
||||
#include "supervisor/shared/translate.h"
|
||||
|
||||
#include "src/rp2040/hardware_structs/include/hardware/structs/dma.h"
|
||||
@ -158,27 +157,6 @@ void common_hal_audiopwmio_pwmaudioout_play(audiopwmio_pwmaudioout_obj_t *self,
|
||||
tx_register += self->left_pwm.channel * sizeof(uint16_t);
|
||||
}
|
||||
|
||||
audio_dma_result result = audio_dma_setup_playback(
|
||||
&self->dma,
|
||||
sample,
|
||||
loop,
|
||||
false, // single channel
|
||||
0, // audio channel
|
||||
false, // output signed
|
||||
BITS_PER_SAMPLE,
|
||||
(uint32_t)tx_register, // output register: PWM cc register
|
||||
0x3b + pacing_timer); // data request line
|
||||
|
||||
if (result == AUDIO_DMA_DMA_BUSY) {
|
||||
common_hal_audiopwmio_pwmaudioout_stop(self);
|
||||
mp_raise_RuntimeError(translate("No DMA channel found"));
|
||||
}
|
||||
if (result == AUDIO_DMA_MEMORY_ERROR) {
|
||||
common_hal_audiopwmio_pwmaudioout_stop(self);
|
||||
mp_raise_RuntimeError(translate("Unable to allocate buffers for signed conversion"));
|
||||
}
|
||||
|
||||
// OK! We got all of the resources we need and dma is ready.
|
||||
self->pacing_timer = pacing_timer;
|
||||
|
||||
// Playback with two independent clocks. One is the sample rate which
|
||||
@ -215,6 +193,27 @@ void common_hal_audiopwmio_pwmaudioout_play(audiopwmio_pwmaudioout_obj_t *self,
|
||||
}
|
||||
|
||||
dma_hw->timer[pacing_timer] = best_numerator << 16 | best_denominator;
|
||||
|
||||
audio_dma_result result = audio_dma_setup_playback(
|
||||
&self->dma,
|
||||
sample,
|
||||
loop,
|
||||
false, // single channel
|
||||
0, // audio channel
|
||||
false, // output signed
|
||||
BITS_PER_SAMPLE,
|
||||
(uint32_t)tx_register, // output register: PWM cc register
|
||||
0x3b + pacing_timer); // data request line
|
||||
|
||||
if (result == AUDIO_DMA_DMA_BUSY) {
|
||||
common_hal_audiopwmio_pwmaudioout_stop(self);
|
||||
mp_raise_RuntimeError(translate("No DMA channel found"));
|
||||
}
|
||||
if (result == AUDIO_DMA_MEMORY_ERROR) {
|
||||
common_hal_audiopwmio_pwmaudioout_stop(self);
|
||||
mp_raise_RuntimeError(translate("Unable to allocate buffers for signed conversion"));
|
||||
}
|
||||
// OK! We got all of the resources we need and dma is ready.
|
||||
}
|
||||
|
||||
void common_hal_audiopwmio_pwmaudioout_stop(audiopwmio_pwmaudioout_obj_t *self) {
|
||||
@ -226,9 +225,11 @@ void common_hal_audiopwmio_pwmaudioout_stop(audiopwmio_pwmaudioout_obj_t *self)
|
||||
audio_dma_stop(&self->dma);
|
||||
|
||||
// Set to quiescent level.
|
||||
pwm_hw->slice[self->left_pwm.slice].cc = self->quiescent_value;
|
||||
common_hal_pwmio_pwmout_set_duty_cycle(&self->left_pwm, self->quiescent_value);
|
||||
pwmio_pwmout_set_top(&self->left_pwm, PWM_TOP);
|
||||
if (self->stereo) {
|
||||
pwm_hw->slice[self->right_pwm.slice].cc = self->quiescent_value;
|
||||
common_hal_pwmio_pwmout_set_duty_cycle(&self->right_pwm, self->quiescent_value);
|
||||
pwmio_pwmout_set_top(&self->right_pwm, PWM_TOP);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2016 Scott Shawcroft
|
||||
* 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,10 +24,16 @@
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_BUSIO_ONEWIRE_H
|
||||
#define MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_BUSIO_ONEWIRE_H
|
||||
#include "supervisor/board.h"
|
||||
#include "mpconfigboard.h"
|
||||
|
||||
// Use bitbangio.
|
||||
#include "shared-module/busio/OneWire.h"
|
||||
void board_init(void) {
|
||||
}
|
||||
|
||||
#endif // MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_BUSIO_ONEWIRE_H
|
||||
bool board_requests_safe_mode(void) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void reset_board(void) {
|
||||
|
||||
}
|
65
ports/stm/boards/sparkfun_stm32f405_micromod/mpconfigboard.h
Normal file
65
ports/stm/boards/sparkfun_stm32f405_micromod/mpconfigboard.h
Normal file
@ -0,0 +1,65 @@
|
||||
/*
|
||||
* This file is part of the MicroPython project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2021 Chris Wilson
|
||||
*
|
||||
* 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 "SparkFun STM32 MicroMod Processor"
|
||||
#define MICROPY_HW_MCU_NAME "STM32F405RG"
|
||||
|
||||
#define FLASH_SIZE (0x100000)
|
||||
#define FLASH_PAGE_SIZE (0x4000)
|
||||
|
||||
#define HSE_VALUE ((uint32_t)12000000)
|
||||
#define LSE_VALUE ((uint32_t)32768)
|
||||
#define BOARD_HAS_LOW_SPEED_CRYSTAL (1)
|
||||
|
||||
// Status LED
|
||||
#define MICROPY_HW_LED_STATUS (&pin_PA15)
|
||||
|
||||
// On-board SPI flash
|
||||
#define SPI_FLASH_MOSI_PIN (&pin_PC12)
|
||||
#define SPI_FLASH_MISO_PIN (&pin_PC11)
|
||||
#define SPI_FLASH_SCK_PIN (&pin_PC10)
|
||||
#define SPI_FLASH_CS_PIN (&pin_PC03)
|
||||
|
||||
// Bootloader only
|
||||
#ifdef UF2_BOOTLOADER_ENABLED
|
||||
#define BOARD_VTOR_DEFER (1) // Leave VTOR relocation to bootloader
|
||||
#endif
|
||||
|
||||
#define DEFAULT_I2C_BUS_SCL (&pin_PB10)
|
||||
#define DEFAULT_I2C_BUS_SDA (&pin_PB11)
|
||||
|
||||
#define DEFAULT_SPI_BUS_SCK (&pin_PA05)
|
||||
#define DEFAULT_SPI_BUS_MOSI (&pin_PA07)
|
||||
#define DEFAULT_SPI_BUS_MISO (&pin_PA06)
|
||||
|
||||
#define DEFAULT_UART_BUS_RX (&pin_PA03)
|
||||
#define DEFAULT_UART_BUS_TX (&pin_PA02)
|
||||
|
||||
// USB is always used internally so skip the pin objects for it.
|
||||
#define IGNORE_PIN_PA11 (1)
|
||||
#define IGNORE_PIN_PA12 (1)
|
@ -0,0 +1,19 @@
|
||||
USB_VID = 0X1B4F
|
||||
USB_PID = 0x0027
|
||||
USB_PRODUCT = "SparkFun STM32 MicroMod Processor"
|
||||
USB_MANUFACTURER = "SparkFun Electronics"
|
||||
|
||||
SPI_FLASH_FILESYSTEM = 1
|
||||
EXTERNAL_FLASH_DEVICES = W25Q128JVxM
|
||||
|
||||
MCU_SERIES = F4
|
||||
MCU_VARIANT = STM32F405xx
|
||||
MCU_PACKAGE = LQFP64
|
||||
|
||||
LD_COMMON = boards/common_default.ld
|
||||
LD_DEFAULT = boards/STM32F405_default.ld
|
||||
# UF2 boot option
|
||||
LD_BOOT = boards/STM32F405_boot.ld
|
||||
UF2_OFFSET = 0x8010000
|
||||
|
||||
CIRCUITPY_RGBMATRIX ?= 1
|
224
ports/stm/boards/sparkfun_stm32f405_micromod/pins.c
Normal file
224
ports/stm/boards/sparkfun_stm32f405_micromod/pins.c
Normal file
@ -0,0 +1,224 @@
|
||||
/*
|
||||
* This file is part of the MicroPython project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2021 Chris Wilson
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "shared-bindings/board/__init__.h"
|
||||
|
||||
STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
|
||||
// The SparkFun MicroMod spec uses a zero-based peripheral numbering scheme.
|
||||
// The 0th peripheral is the default and the "0" is omitted from the
|
||||
// peripheral name (e.g. "I2C" instead of "I2C0").
|
||||
//
|
||||
// For more details, see https://www.sparkfun.com/micromod#tech-specs
|
||||
|
||||
// MicroMod built-in status LED pin
|
||||
// Requirement from the "Designing with MicroMod" SparkFun article:
|
||||
// "... every Processor Board shall include one status LED connected to a
|
||||
// pin that is not connected to the board edge."
|
||||
{ MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_PA15) }, // MicroMod LED (PA15)
|
||||
|
||||
// MicroMod USB bus input voltage (+5V) pin
|
||||
// { MP_ROM_QSTR(MP_QSTR_USB_VIN), MP_ROM_PTR() }, // MicroMod USB_VIN (not connected)
|
||||
|
||||
// MicroMod +3.3V enable pin
|
||||
// { MP_ROM_QSTR(MP_QSTR_P3V3_EN), MP_ROM_PTR() }, // MicroMod 3.3V_EN (not connected)
|
||||
|
||||
// MicroMod battery voltage sense pin
|
||||
{ MP_ROM_QSTR(MP_QSTR_BATT_VIN3), MP_ROM_PTR(&pin_PA01) }, // MicroMod BATT_VIN/3 (PA1)
|
||||
|
||||
// MicroMod reset pin
|
||||
// { MP_ROM_QSTR(MP_QSTR_RESET), MP_ROM_PTR() }, // MicroMod RESET# (STM32 has a dedicated HW NRST pin)
|
||||
|
||||
// MicroMod boot pin
|
||||
// { MP_ROM_QSTR(MP_QSTR_BOOT), MP_ROM_PTR() }, // MicroMod BOOT (STM32 has a dedicated HW BOOT0 pin)
|
||||
|
||||
// MicroMod USB device pins
|
||||
// USB device is always used internally by CircuitPython, so skip creating
|
||||
// the pin objects for it. See explicit ignores in mpconfigboard.h.
|
||||
// { MP_ROM_QSTR(MP_QSTR_USB_DM), MP_ROM_PTR(&pin_PA11) }, // MicroMod USB_D- (PA11)
|
||||
// { MP_ROM_QSTR(MP_QSTR_USB_DP), MP_ROM_PTR(&pin_PA12) }, // MicroMod USB_D+ (PA12)
|
||||
|
||||
// MicroMod USB host pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_USBHOST_DM), MP_ROM_PTR(&pin_PB14) }, // MicroMod USBHOST_D- (PB14)
|
||||
{ MP_ROM_QSTR(MP_QSTR_USBHOST_DP), MP_ROM_PTR(&pin_PB15) }, // MicroMod USBHOST_D+ (PB15)
|
||||
|
||||
// MicroMod CAN pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_CAN_RX), MP_ROM_PTR(&pin_PB08) }, // MicroMod CAN_RX (PB8)
|
||||
{ MP_ROM_QSTR(MP_QSTR_CAN_TX), MP_ROM_PTR(&pin_PB09) }, // MicroMod CAN_TX (PB9)
|
||||
|
||||
// Note: MicroMod UART (UART0) is not present in the edge connector pinout
|
||||
// because the primary debug serial port is exposed as a virtual serial port
|
||||
// over USB.
|
||||
|
||||
// MicroMod UART1 pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_UART_TX1), MP_ROM_PTR(&pin_PA02) }, // MicroMod UART_TX1 | CircuitPython TX (PA2)
|
||||
{ MP_ROM_QSTR(MP_QSTR_UART_RX1), MP_ROM_PTR(&pin_PA03) }, // MicroMod UART_RX1 | CircuitPython RX (PA3)
|
||||
// { MP_ROM_QSTR(MP_QSTR_UART_RTS1), MP_ROM_PTR() }, // MicroMod RTS1 (not connected)
|
||||
// { MP_ROM_QSTR(MP_QSTR_UART_CTS1), MP_ROM_PTR() }, // MicroMod CTS1 (not connected)
|
||||
|
||||
// CircuitPython default UART pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_PA02) }, // CircuitPython TX | MicroMod UART_TX1 (PA2)
|
||||
{ MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_PA03) }, // CircuitPython RX | MicroMod UART_RX1 (PA3)
|
||||
|
||||
// MicroMod UART2 pins
|
||||
// { MP_ROM_QSTR(MP_QSTR_UART_TX2), MP_ROM_PTR() }, // MicroMod UART_TX2 (not connected)
|
||||
// { MP_ROM_QSTR(MP_QSTR_UART_RX2), MP_ROM_PTR() }, // MicroMod UART_RX2 (not connected)
|
||||
|
||||
// MicroMod I2C pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_I2C_SDA), MP_ROM_PTR(&pin_PB11) }, // MicroMod I2C_SDA | CircuitPython SDA (PB11)
|
||||
{ MP_ROM_QSTR(MP_QSTR_I2C_SCL), MP_ROM_PTR(&pin_PB10) }, // MicroMod I2C_SCL | CircuitPython SCL (PB10)
|
||||
|
||||
// CircuitPython default I2C pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_PB11) }, // CircuitPython SDA | MicroMod I2C_SDA (PB11)
|
||||
{ MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_PB10) }, // CircuitPython SCL | MicroMod I2C_SCL (PB10)
|
||||
|
||||
// MicroMod I2C interrupt pin
|
||||
{ MP_ROM_QSTR(MP_QSTR_I2C_INT), MP_ROM_PTR(&pin_PB01) }, // MicroMod I2C_INT (PB1)
|
||||
|
||||
// MicroMod I2C1 pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_I2C_SDA1), MP_ROM_PTR(&pin_PB07) }, // MicroMod I2C_SDA1 (PB7)
|
||||
{ MP_ROM_QSTR(MP_QSTR_I2C_SCL1), MP_ROM_PTR(&pin_PB06) }, // MicroMod I2C_SCL1 (PB6)
|
||||
|
||||
// MicroMod SPI pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_SPI_CIPO), MP_ROM_PTR(&pin_PA06) }, // MicroMod SPI_CIPO | CircuitPython CIPO (PA6)
|
||||
{ MP_ROM_QSTR(MP_QSTR_SPI_MISO), MP_ROM_PTR(&pin_PA06) }, // MicroMod SPI_MISO | CircuitPython MISO (PA6)
|
||||
{ MP_ROM_QSTR(MP_QSTR_SPI_COPI), MP_ROM_PTR(&pin_PA07) }, // MicroMod SPI_COPI | CircuitPython COPI | LED_DAT (PA7)
|
||||
{ MP_ROM_QSTR(MP_QSTR_SPI_MOSI), MP_ROM_PTR(&pin_PA07) }, // MicroMod SPI_MOSI | CircuitPython MOSI (PA7)
|
||||
{ MP_ROM_QSTR(MP_QSTR_SPI_SCK), MP_ROM_PTR(&pin_PA05) }, // MicroMod SPI_SCK | CircuitPython SCK | LED_CLK (PA5)
|
||||
{ MP_ROM_QSTR(MP_QSTR_SPI_CS), MP_ROM_PTR(&pin_PA04) }, // MicroMod SPI_CS | CircuitPython CS (PC4)
|
||||
|
||||
// CircuitPython default SPI pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_CIPO), MP_ROM_PTR(&pin_PA06) }, // CircuitPython CIPO | MicroMod SPI_CIPO (PA6)
|
||||
{ MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_PA06) }, // CircuitPython MISO | MicroMod SPI_MISO (PA6)
|
||||
{ MP_ROM_QSTR(MP_QSTR_COPI), MP_ROM_PTR(&pin_PA07) }, // CircuitPython COPI | MicroMod SPI_COPI | LED_DAT (PA7)
|
||||
{ MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PA07) }, // CircuitPython MOSI | MicroMod SPI_MOSI (PA7)
|
||||
{ MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PA05) }, // CircuitPython SCK | MicroMod SPI_SCK | LED_CLK (PA5)
|
||||
{ MP_ROM_QSTR(MP_QSTR_CS), MP_ROM_PTR(&pin_PA04) }, // CircuitPython CS | MicroMod SPI_CS (PC4)
|
||||
|
||||
// MicroMod 2-wire serial LED pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_LED_DAT), MP_ROM_PTR(&pin_PA07) }, // MicroMod LED_DAT | SPI_COPI (PA7)
|
||||
{ MP_ROM_QSTR(MP_QSTR_LED_CLK), MP_ROM_PTR(&pin_PA05) }, // MicroMod LED_CLK | SPI_SCK (PA5)
|
||||
|
||||
// MicroMod SDIO pins
|
||||
// { MP_ROM_QSTR(MP_QSTR_SDIO_CLK), MP_ROM_PTR() }, // MicroMod SDIO_SCK | SPI_SCK1 (not connected)
|
||||
// { MP_ROM_QSTR(MP_QSTR_SDIO_CMD), MP_ROM_PTR() }, // MicroMod SDIO_CMD | SPI_COPI1 (not connected)
|
||||
// { MP_ROM_QSTR(MP_QSTR_SDIO_DATA0), MP_ROM_PTR() }, // MicroMod SDIO_DATA0 | SPI_CIPO1 (not connected)
|
||||
// { MP_ROM_QSTR(MP_QSTR_SDIO_DATA1), MP_ROM_PTR() }, // MicroMod SDIO_DATA1 (not connected)
|
||||
// { MP_ROM_QSTR(MP_QSTR_SDIO_DATA2), MP_ROM_PTR() }, // MicroMod SDIO_DATA2 (not connected)
|
||||
// { MP_ROM_QSTR(MP_QSTR_SDIO_DATA3), MP_ROM_PTR() }, // MicroMod SDIO_DATA3 | SPI_CS1 (not connected)
|
||||
|
||||
// MicroMod SPI1 pins
|
||||
// { MP_ROM_QSTR(MP_QSTR_SPI_CIPO1), MP_ROM_PTR() }, // MicroMod SPI_CIPO1 | SDIO_DATA0 (not connected)
|
||||
// { MP_ROM_QSTR(MP_QSTR_SPI_MISO1), MP_ROM_PTR() }, // MicroMod SPI_MISO1 (not connected)
|
||||
// { MP_ROM_QSTR(MP_QSTR_SPI_COPI1), MP_ROM_PTR() }, // MicroMod SPI_COPI1 | SDIO_CMD (not connected)
|
||||
// { MP_ROM_QSTR(MP_QSTR_SPI_MOSI1), MP_ROM_PTR() }, // MicroMod SPI_MOSI1 (not connected)
|
||||
// { MP_ROM_QSTR(MP_QSTR_SPI_SCK1), MP_ROM_PTR() }, // MicroMod SPI_SCK1 | SDIO_SCK (not connected)
|
||||
// { MP_ROM_QSTR(MP_QSTR_SPI_CS1), MP_ROM_PTR() }, // MicroMod SPI_CS1 | SDIO_DATA3 (not connected)
|
||||
|
||||
// MicroMod audio pins
|
||||
// { MP_ROM_QSTR(MP_QSTR_AUD_MCLK), MP_ROM_PTR() }, // MicroMod AUD_MCLK (not connected)
|
||||
// { MP_ROM_QSTR(MP_QSTR_AUD_OUT), MP_ROM_PTR(&pin_PB04) }, // MicroMod AUD_OUT | I2S_OUT | PCM_OUT | CAM_MCLK (PB4)
|
||||
// { MP_ROM_QSTR(MP_QSTR_AUD_IN), MP_ROM_PTR(&pin_PB05) }, // MicroMod AUD_IN | I2S_IN | PCM_IN | CAM_PCLK (PB5)
|
||||
// { MP_ROM_QSTR(MP_QSTR_AUD_LRCLK), MP_ROM_PTR(&pin_PA04) }, // MicroMod AUD_LRCLK | I2S_WS | PCM_SYNC | PDM_DATA (PA4)
|
||||
// { MP_ROM_QSTR(MP_QSTR_AUD_BCLK), MP_ROM_PTR(&pin_PB03) }, // MicroMod AUD_BCLK | I2S_SCK | PCM_CLK | PDM_CLK (PB3)
|
||||
|
||||
// MicroMod I2S pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_I2S_OUT), MP_ROM_PTR(&pin_PB04) }, // MicroMod I2S_OUT | AUD_OUT | PCM_OUT | CAM_MCLK (PB4)
|
||||
{ MP_ROM_QSTR(MP_QSTR_I2S_IN), MP_ROM_PTR(&pin_PB05) }, // MicroMod I2S_IN | AUD_IN | PCM_IN | CAM_PCLK (PB5)
|
||||
{ MP_ROM_QSTR(MP_QSTR_I2S_WS), MP_ROM_PTR(&pin_PA04) }, // MicroMod I2S_WS | AUD_LRCLK | PCM_SYNC | PDM_DATA (PA4)
|
||||
{ MP_ROM_QSTR(MP_QSTR_I2S_SCK), MP_ROM_PTR(&pin_PB03) }, // MicroMod I2S_SCK | AUD_BCLK | PCM_CLK | PDM_CLK (PB3)
|
||||
|
||||
// MicroMod PCM pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_PCM_OUT), MP_ROM_PTR(&pin_PB04) }, // MicroMod PCM_OUT | AUD_OUT | I2S_OUT | CAM_MCLK (PB4)
|
||||
{ MP_ROM_QSTR(MP_QSTR_PCM_IN), MP_ROM_PTR(&pin_PB05) }, // MicroMod PCM_IN | AUD_IN | I2S_IN | CAM_PCLK (PB5)
|
||||
{ MP_ROM_QSTR(MP_QSTR_PCM_SYNC), MP_ROM_PTR(&pin_PA04) }, // MicroMod PCM_SYNC | AUD_LRCLK | I2S_WS | PDM_DATA (PA4)
|
||||
{ MP_ROM_QSTR(MP_QSTR_PCM_CLK), MP_ROM_PTR(&pin_PB03) }, // MicroMod PCM_CLK | AUD_BCLK | I2S_SCK | PDM_CLK (PB3)
|
||||
|
||||
// MicroMod PDM pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_PDM_DATA), MP_ROM_PTR(&pin_PA04) }, // MicroMod PDM_DATA | AUD_LRCLK | I2S_WS | PCM_SYNC (PA4)
|
||||
{ MP_ROM_QSTR(MP_QSTR_PDM_CLK), MP_ROM_PTR(&pin_PB03) }, // MicroMod PDM_CLK | AUD_BCLK | I2S_SCK | PCM_CLK (PB3)
|
||||
|
||||
// MicroMod SWD pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_SWDIO), MP_ROM_PTR(&pin_PA13) }, // MicroMod SWDIO (PA13)
|
||||
{ MP_ROM_QSTR(MP_QSTR_SWCLK), MP_ROM_PTR(&pin_PA14) }, // MicroMod SWDCK (PA14)
|
||||
// { MP_ROM_QSTR(MP_QSTR_SWO), MP_ROM_PTR() }, // MicroMod SWO | G11 (not connected)
|
||||
|
||||
// MicroMod ADC pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_PC05) }, // MicroMod A0 (PC5)
|
||||
{ MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_PB00) }, // MicroMod A1 (PB0)
|
||||
|
||||
// MicroMod PWM pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_PWM0), MP_ROM_PTR(&pin_PC06) }, // MicroMod PWM0 (PC6)
|
||||
{ MP_ROM_QSTR(MP_QSTR_PWM1), MP_ROM_PTR(&pin_PC07) }, // MicroMod PWM1 (PC7)
|
||||
|
||||
// MicroMod digital pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_PC00) }, // MicroMod D0 (PC0)
|
||||
{ MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_PC01) }, // MicroMod D1 | CAM_TRIG (PC1)
|
||||
|
||||
// MicroMod general purpose pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_G0), MP_ROM_PTR(&pin_PD02) }, // MicroMod G0 | BUS0 (PD2)
|
||||
{ MP_ROM_QSTR(MP_QSTR_G1), MP_ROM_PTR(&pin_PA08) }, // MicroMod G1 | BUS1 (PA8)
|
||||
{ MP_ROM_QSTR(MP_QSTR_G2), MP_ROM_PTR(&pin_PA00) }, // MicroMod G2 | BUS2 (PA0)
|
||||
{ MP_ROM_QSTR(MP_QSTR_G3), MP_ROM_PTR(&pin_PC08) }, // MicroMod G3 | BUS3 (PC8)
|
||||
{ MP_ROM_QSTR(MP_QSTR_G4), MP_ROM_PTR(&pin_PC09) }, // MicroMod G4 | BUS4 (PC9)
|
||||
{ MP_ROM_QSTR(MP_QSTR_G5), MP_ROM_PTR(&pin_PC13) }, // MicroMod G5 | BUS5 (PC13)
|
||||
{ MP_ROM_QSTR(MP_QSTR_G6), MP_ROM_PTR(&pin_PC02) }, // MicroMod G6 | BUS6 (PC2)
|
||||
// { MP_ROM_QSTR(MP_QSTR_G7), MP_ROM_PTR() }, // MicroMod G7 | BUS7 (not connected)
|
||||
// { MP_ROM_QSTR(MP_QSTR_G8), MP_ROM_PTR() }, // MicroMod G8 (not connected)
|
||||
// { MP_ROM_QSTR(MP_QSTR_G9), MP_ROM_PTR() }, // MicroMod G9 | ADC_D- | CAM_HSYNC (not connected)
|
||||
{ MP_ROM_QSTR(MP_QSTR_G10), MP_ROM_PTR(&pin_PB13) }, // MicroMod G10 | ADC_D+ | CAM_VSYNC (PB13)
|
||||
{ MP_ROM_QSTR(MP_QSTR_G11), MP_ROM_PTR(&pin_PB12) }, // MicroMod G11 | SWO (PB12)
|
||||
|
||||
// MicroMod 8-bit bus pins
|
||||
{ MP_ROM_QSTR(MP_QSTR_BUS0), MP_ROM_PTR(&pin_PD02) }, // MicroMod BUS0 | G0 (PD2)
|
||||
{ MP_ROM_QSTR(MP_QSTR_BUS1), MP_ROM_PTR(&pin_PA08) }, // MicroMod BUS1 | G1 (PA8)
|
||||
{ MP_ROM_QSTR(MP_QSTR_BUS2), MP_ROM_PTR(&pin_PA00) }, // MicroMod BUS2 | G2 (PA0)
|
||||
{ MP_ROM_QSTR(MP_QSTR_BUS3), MP_ROM_PTR(&pin_PC08) }, // MicroMod BUS3 | G3 (PC8)
|
||||
{ MP_ROM_QSTR(MP_QSTR_BUS4), MP_ROM_PTR(&pin_PC09) }, // MicroMod BUS4 | G4 (PC9)
|
||||
{ MP_ROM_QSTR(MP_QSTR_BUS5), MP_ROM_PTR(&pin_PC13) }, // MicroMod BUS5 | G5 (PC13)
|
||||
{ MP_ROM_QSTR(MP_QSTR_BUS6), MP_ROM_PTR(&pin_PC02) }, // MicroMod BUS6 | G6 (PC2)
|
||||
// { MP_ROM_QSTR(MP_QSTR_BUS7), MP_ROM_PTR() }, // MicroMod BUS7 | G7 (not connected)
|
||||
|
||||
// MicroMod differential ADC input pins
|
||||
// { MP_ROM_QSTR(MP_QSTR_ADC_DM), MP_ROM_PTR() }, // MicroMod ADC_D- | G9 | CAM_HSYNC (not connected)
|
||||
// { MP_ROM_QSTR(MP_QSTR_ADC_DP), MP_ROM_PTR(&pin_PB13) }, // MicroMod ADC_D+ | G10 | CAM_VSYNC (PB13)
|
||||
|
||||
// MicroMod camera pins
|
||||
// { MP_ROM_QSTR(MP_QSTR_CAM_MCLK), MP_ROM_PTR(&pin_PB04) }, // MicroMod CAM_MCLK | AUD_OUT | I2S_OUT | PCM_OUT (PB4)
|
||||
// { MP_ROM_QSTR(MP_QSTR_CAM_PCLK), MP_ROM_PTR(&pin_PB05) }, // MicroMod CAM_PCLK | AUD_IN | I2S_IN | PCM_IN (PB5)
|
||||
// { MP_ROM_QSTR(MP_QSTR_CAM_TRIG), MP_ROM_PTR(&pin_PC01) }, // MicroMod CAM_TRIG | D1 (PC1)
|
||||
// { MP_ROM_QSTR(MP_QSTR_CAM_HSYNC), MP_ROM_PTR() }, // MicroMod CAM_HSYNC | ADC_D- | G9 (not connected)
|
||||
// { MP_ROM_QSTR(MP_QSTR_CAM_VSYNC), MP_ROM_PTR(&pin_PB13) }, // MicroMod CAM_VSYNC | ADC_D+ | G10 (PB13)
|
||||
|
||||
// Module-specific aliases (not part of the MicroMod spec)
|
||||
{ MP_ROM_QSTR(MP_QSTR_HOST_VBUS), MP_ROM_PTR(&pin_PB13) }, // HOST_VBUS | G10 | ADC_D+ | CAM_VSYNC (PB13)
|
||||
{ MP_ROM_QSTR(MP_QSTR_HOST_ID), MP_ROM_PTR(&pin_PB12) }, // HOST_ID | G11 | SWO (PB12)
|
||||
|
||||
// CircuitPython board objects
|
||||
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, // CircuitPython I2C
|
||||
{ MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, // CircuitPython SPI
|
||||
{ MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, // CircuitPython UART
|
||||
};
|
||||
MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);
|
@ -155,7 +155,7 @@ ifeq ($(CIRCUITPY_BUSDEVICE),1)
|
||||
SRC_PATTERNS += adafruit_bus_device/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_BUSIO),1)
|
||||
SRC_PATTERNS += busio/% bitbangio/OneWire.%
|
||||
SRC_PATTERNS += busio/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_CAMERA),1)
|
||||
SRC_PATTERNS += camera/%
|
||||
@ -218,6 +218,9 @@ endif
|
||||
ifeq ($(CIRCUITPY_NVM),1)
|
||||
SRC_PATTERNS += nvm/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_ONEWIREIO),1)
|
||||
SRC_PATTERNS += onewireio/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_OS),1)
|
||||
SRC_PATTERNS += os/%
|
||||
endif
|
||||
@ -493,7 +496,6 @@ SRC_SHARED_MODULE_ALL = \
|
||||
audiomp3/__init__.c \
|
||||
audiopwmio/__init__.c \
|
||||
bitbangio/I2C.c \
|
||||
bitbangio/OneWire.c \
|
||||
bitbangio/SPI.c \
|
||||
bitbangio/__init__.c \
|
||||
bitmaptools/__init__.c \
|
||||
@ -502,7 +504,6 @@ SRC_SHARED_MODULE_ALL = \
|
||||
adafruit_bus_device/__init__.c \
|
||||
adafruit_bus_device/I2CDevice.c \
|
||||
adafruit_bus_device/SPIDevice.c \
|
||||
busio/OneWire.c \
|
||||
canio/Match.c \
|
||||
canio/Message.c \
|
||||
canio/RemoteTransmissionRequest.c \
|
||||
@ -522,6 +523,8 @@ SRC_SHARED_MODULE_ALL = \
|
||||
fontio/__init__.c \
|
||||
framebufferio/FramebufferDisplay.c \
|
||||
framebufferio/__init__.c \
|
||||
gamepadshift/GamePadShift.c \
|
||||
gamepadshift/__init__.c \
|
||||
getpass/__init__.c \
|
||||
ipaddress/IPv4Address.c \
|
||||
ipaddress/__init__.c \
|
||||
@ -531,15 +534,13 @@ SRC_SHARED_MODULE_ALL = \
|
||||
keypad/KeyMatrix.c \
|
||||
keypad/ShiftRegisterKeys.c \
|
||||
keypad/Keys.c \
|
||||
sdcardio/SDCard.c \
|
||||
sdcardio/__init__.c \
|
||||
gamepadshift/GamePadShift.c \
|
||||
gamepadshift/__init__.c \
|
||||
memorymonitor/__init__.c \
|
||||
memorymonitor/AllocationAlarm.c \
|
||||
memorymonitor/AllocationSize.c \
|
||||
network/__init__.c \
|
||||
msgpack/__init__.c \
|
||||
onewireio/__init__.c \
|
||||
onewireio/OneWire.c \
|
||||
os/__init__.c \
|
||||
qrio/__init__.c \
|
||||
qrio/QRDecoder.c \
|
||||
@ -548,6 +549,8 @@ SRC_SHARED_MODULE_ALL = \
|
||||
rgbmatrix/RGBMatrix.c \
|
||||
rgbmatrix/__init__.c \
|
||||
rotaryio/IncrementalEncoder.c \
|
||||
sdcardio/SDCard.c \
|
||||
sdcardio/__init__.c \
|
||||
sharpdisplay/SharpMemoryFramebuffer.c \
|
||||
sharpdisplay/__init__.c \
|
||||
socket/__init__.c \
|
||||
|
@ -583,6 +583,13 @@ extern const struct _mp_obj_module_t neopixel_write_module;
|
||||
extern const struct _mp_obj_module_t nvm_module;
|
||||
#endif
|
||||
|
||||
#if CIRCUITPY_ONEWIREIO
|
||||
extern const struct _mp_obj_module_t onewireio_module;
|
||||
#define ONEWIREIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_onewireio), (mp_obj_t)&onewireio_module },
|
||||
#else
|
||||
#define ONEWIREIO_MODULE
|
||||
#endif
|
||||
|
||||
#if CIRCUITPY_OS
|
||||
extern const struct _mp_obj_module_t os_module;
|
||||
#define OS_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_os), (mp_obj_t)&os_module },
|
||||
@ -915,6 +922,7 @@ extern const struct _mp_obj_module_t msgpack_module;
|
||||
MICROCONTROLLER_MODULE \
|
||||
MSGPACK_MODULE \
|
||||
NEOPIXEL_WRITE_MODULE \
|
||||
ONEWIREIO_MODULE \
|
||||
PEW_MODULE \
|
||||
PIXELBUF_MODULE \
|
||||
PS2IO_MODULE \
|
||||
|
@ -121,9 +121,15 @@ CFLAGS += -DCIRCUITPY_BUILTINS_POW3=$(CIRCUITPY_BUILTINS_POW3)
|
||||
CIRCUITPY_BUSIO ?= 1
|
||||
CFLAGS += -DCIRCUITPY_BUSIO=$(CIRCUITPY_BUSIO)
|
||||
|
||||
# These two flags pretend to implement their class but raise a ValueError due to
|
||||
# unsupported pins. This should be used sparingly on boards that don't break out
|
||||
# generic IO but need parts of busio.
|
||||
CIRCUITPY_BUSIO_SPI ?= 1
|
||||
CFLAGS += -DCIRCUITPY_BUSIO_SPI=$(CIRCUITPY_BUSIO_SPI)
|
||||
|
||||
CIRCUITPY_BUSIO_UART ?= 1
|
||||
CFLAGS += -DCIRCUITPY_BUSIO_UART=$(CIRCUITPY_BUSIO_UART)
|
||||
|
||||
CIRCUITPY_CAMERA ?= 0
|
||||
CFLAGS += -DCIRCUITPY_CAMERA=$(CIRCUITPY_CAMERA)
|
||||
|
||||
@ -184,7 +190,7 @@ CFLAGS += -DCIRCUITPY_FREQUENCYIO=$(CIRCUITPY_FREQUENCYIO)
|
||||
CIRCUITPY_GAMEPADSHIFT ?= 0
|
||||
CFLAGS += -DCIRCUITPY_GAMEPADSHIFT=$(CIRCUITPY_GAMEPADSHIFT)
|
||||
|
||||
CIRCUITPY_GETPASS ?= 1
|
||||
CIRCUITPY_GETPASS ?= $(CIRCUITPY_FULL_BUILD)
|
||||
CFLAGS += -DCIRCUITPY_GETPASS=$(CIRCUITPY_GETPASS)
|
||||
|
||||
CIRCUITPY_GNSS ?= 0
|
||||
@ -193,6 +199,9 @@ CFLAGS += -DCIRCUITPY_GNSS=$(CIRCUITPY_GNSS)
|
||||
CIRCUITPY_I2CPERIPHERAL ?= $(CIRCUITPY_FULL_BUILD)
|
||||
CFLAGS += -DCIRCUITPY_I2CPERIPHERAL=$(CIRCUITPY_I2CPERIPHERAL)
|
||||
|
||||
CIRCUITPY_IMAGECAPTURE ?= 0
|
||||
CFLAGS += -DCIRCUITPY_IMAGECAPTURE=$(CIRCUITPY_IMAGECAPTURE)
|
||||
|
||||
CIRCUITPY_IPADDRESS ?= $(CIRCUITPY_WIFI)
|
||||
CFLAGS += -DCIRCUITPY_IPADDRESS=$(CIRCUITPY_IPADDRESS)
|
||||
|
||||
@ -220,12 +229,12 @@ CFLAGS += -DCIRCUITPY_NEOPIXEL_WRITE=$(CIRCUITPY_NEOPIXEL_WRITE)
|
||||
CIRCUITPY_NVM ?= 1
|
||||
CFLAGS += -DCIRCUITPY_NVM=$(CIRCUITPY_NVM)
|
||||
|
||||
CIRCUITPY_ONEWIREIO ?= $(CIRCUITPY_BUSIO)
|
||||
CFLAGS += -DCIRCUITPY_ONEWIREIO=$(CIRCUITPY_ONEWIREIO)
|
||||
|
||||
CIRCUITPY_OS ?= 1
|
||||
CFLAGS += -DCIRCUITPY_OS=$(CIRCUITPY_OS)
|
||||
|
||||
CIRCUITPY_IMAGECAPTURE ?= 0
|
||||
CFLAGS += -DCIRCUITPY_IMAGECAPTURE=$(CIRCUITPY_IMAGECAPTURE)
|
||||
|
||||
CIRCUITPY_PEW ?= 0
|
||||
CFLAGS += -DCIRCUITPY_PEW=$(CIRCUITPY_PEW)
|
||||
|
||||
@ -330,7 +339,7 @@ CFLAGS += -DCIRCUITPY_TOUCHIO_USE_NATIVE=$(CIRCUITPY_TOUCHIO_USE_NATIVE)
|
||||
CIRCUITPY_TOUCHIO ?= 1
|
||||
CFLAGS += -DCIRCUITPY_TOUCHIO=$(CIRCUITPY_TOUCHIO)
|
||||
|
||||
CIRCUITPY_TRACEBACK ?= 1
|
||||
CIRCUITPY_TRACEBACK ?= $(CIRCUITPY_FULL_BUILD)
|
||||
CFLAGS += -DCIRCUITPY_TRACEBACK=$(CIRCUITPY_TRACEBACK)
|
||||
|
||||
# For debugging.
|
||||
|
@ -7,6 +7,7 @@ jinja2
|
||||
typer
|
||||
|
||||
requests
|
||||
requests-cache
|
||||
sh
|
||||
click
|
||||
setuptools
|
||||
|
@ -197,10 +197,10 @@ const mp_obj_property_t bleio_adapter_name_obj = {
|
||||
//| """Starts advertising until `stop_advertising` is called or if connectable, another device
|
||||
//| connects to us.
|
||||
//|
|
||||
//| .. warning: If data is longer than 31 bytes, then this will automatically advertise as an
|
||||
//| .. warning:: If data is longer than 31 bytes, then this will automatically advertise as an
|
||||
//| extended advertisement that older BLE 4.x clients won't be able to scan for.
|
||||
//|
|
||||
//| .. note: If you set ``anonymous=True``, then a timeout must be specified. If no timeout is
|
||||
//| .. note:: If you set ``anonymous=True``, then a timeout must be specified. If no timeout is
|
||||
//| specified, then the maximum allowed timeout will be selected automatically.
|
||||
//|
|
||||
//| :param ~_typing.ReadableBuffer data: advertising data packet bytes
|
||||
|
@ -1,172 +0,0 @@
|
||||
/*
|
||||
* This file is part of the Micro Python 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 "lib/utils/context_manager_helpers.h"
|
||||
#include "py/objproperty.h"
|
||||
#include "py/runtime.h"
|
||||
#include "py/runtime0.h"
|
||||
#include "shared-bindings/microcontroller/Pin.h"
|
||||
#include "shared-bindings/bitbangio/OneWire.h"
|
||||
#include "shared-bindings/util.h"
|
||||
|
||||
//| class OneWire:
|
||||
//| """Lowest-level of the Maxim OneWire protocol
|
||||
//|
|
||||
//| :class:`~bitbangio.OneWire` implements the timing-sensitive foundation of
|
||||
//| the Maxim (formerly Dallas Semi) OneWire protocol.
|
||||
//|
|
||||
//| Protocol definition is here: https://www.maximintegrated.com/en/app-notes/index.mvp/id/126"""
|
||||
//|
|
||||
//| def __init__(self, pin: microcontroller.Pin) -> None:
|
||||
//|
|
||||
//| """Create a OneWire object associated with the given pin. The object
|
||||
//| implements the lowest level timing-sensitive bits of the protocol.
|
||||
//|
|
||||
//| :param ~microcontroller.Pin pin: Pin to read pulses from.
|
||||
//|
|
||||
//| Read a short series of pulses::
|
||||
//|
|
||||
//| import bitbangio
|
||||
//| import board
|
||||
//|
|
||||
//| onewire = bitbangio.OneWire(board.D7)
|
||||
//| onewire.reset()
|
||||
//| onewire.write_bit(True)
|
||||
//| onewire.write_bit(False)
|
||||
//| print(onewire.read_bit())"""
|
||||
//| ...
|
||||
//|
|
||||
STATIC mp_obj_t bitbangio_onewire_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_pin };
|
||||
static const mp_arg_t allowed_args[] = {
|
||||
{ MP_QSTR_pin, MP_ARG_REQUIRED | MP_ARG_OBJ },
|
||||
};
|
||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||
|
||||
const mcu_pin_obj_t *pin = validate_obj_is_free_pin(args[ARG_pin].u_obj);
|
||||
|
||||
bitbangio_onewire_obj_t *self = m_new_obj(bitbangio_onewire_obj_t);
|
||||
self->base.type = &bitbangio_onewire_type;
|
||||
|
||||
shared_module_bitbangio_onewire_construct(self, pin);
|
||||
return MP_OBJ_FROM_PTR(self);
|
||||
}
|
||||
|
||||
//| def deinit(self) -> None:
|
||||
//| """Deinitialize the OneWire bus and release any hardware resources for reuse."""
|
||||
//| ...
|
||||
//|
|
||||
STATIC mp_obj_t bitbangio_onewire_deinit(mp_obj_t self_in) {
|
||||
bitbangio_onewire_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
shared_module_bitbangio_onewire_deinit(self);
|
||||
return mp_const_none;
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(bitbangio_onewire_deinit_obj, bitbangio_onewire_deinit);
|
||||
|
||||
STATIC void check_for_deinit(bitbangio_onewire_obj_t *self) {
|
||||
if (shared_module_bitbangio_onewire_deinited(self)) {
|
||||
raise_deinited_error();
|
||||
}
|
||||
}
|
||||
|
||||
//| def __enter__(self) -> OneWire:
|
||||
//| """No-op used by Context Managers."""
|
||||
//| ...
|
||||
//|
|
||||
// Provided by context manager helper.
|
||||
|
||||
//| def __exit__(self) -> None:
|
||||
//| """Automatically deinitializes the hardware when exiting a context. See
|
||||
//| :ref:`lifetime-and-contextmanagers` for more info."""
|
||||
//| ...
|
||||
//|
|
||||
STATIC mp_obj_t bitbangio_onewire_obj___exit__(size_t n_args, const mp_obj_t *args) {
|
||||
(void)n_args;
|
||||
shared_module_bitbangio_onewire_deinit(args[0]);
|
||||
return mp_const_none;
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bitbangio_onewire___exit___obj, 4, 4, bitbangio_onewire_obj___exit__);
|
||||
|
||||
//| def reset(self) -> bool:
|
||||
//| """Reset the OneWire bus"""
|
||||
//| ...
|
||||
//|
|
||||
STATIC mp_obj_t bitbangio_onewire_obj_reset(mp_obj_t self_in) {
|
||||
bitbangio_onewire_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
check_for_deinit(self);
|
||||
|
||||
return mp_obj_new_bool(shared_module_bitbangio_onewire_reset(self));
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(bitbangio_onewire_reset_obj, bitbangio_onewire_obj_reset);
|
||||
|
||||
//| def read_bit(self) -> bool:
|
||||
//| """Read in a bit
|
||||
//|
|
||||
//| :returns: bit state read
|
||||
//| :rtype: bool"""
|
||||
//| ...
|
||||
//|
|
||||
STATIC mp_obj_t bitbangio_onewire_obj_read_bit(mp_obj_t self_in) {
|
||||
bitbangio_onewire_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
check_for_deinit(self);
|
||||
|
||||
return mp_obj_new_bool(shared_module_bitbangio_onewire_read_bit(self));
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(bitbangio_onewire_read_bit_obj, bitbangio_onewire_obj_read_bit);
|
||||
|
||||
//| def write_bit(self, value: bool) -> None:
|
||||
//| """Write out a bit based on value."""
|
||||
//| ...
|
||||
//|
|
||||
STATIC mp_obj_t bitbangio_onewire_obj_write_bit(mp_obj_t self_in, mp_obj_t bool_obj) {
|
||||
bitbangio_onewire_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
check_for_deinit(self);
|
||||
|
||||
shared_module_bitbangio_onewire_write_bit(self, mp_obj_is_true(bool_obj));
|
||||
return mp_const_none;
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_2(bitbangio_onewire_write_bit_obj, bitbangio_onewire_obj_write_bit);
|
||||
|
||||
STATIC const mp_rom_map_elem_t bitbangio_onewire_locals_dict_table[] = {
|
||||
// Methods
|
||||
{ MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&bitbangio_onewire_deinit_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&default___enter___obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&bitbangio_onewire___exit___obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_reset), MP_ROM_PTR(&bitbangio_onewire_reset_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_read_bit), MP_ROM_PTR(&bitbangio_onewire_read_bit_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_write_bit), MP_ROM_PTR(&bitbangio_onewire_write_bit_obj) },
|
||||
};
|
||||
STATIC MP_DEFINE_CONST_DICT(bitbangio_onewire_locals_dict, bitbangio_onewire_locals_dict_table);
|
||||
|
||||
const mp_obj_type_t bitbangio_onewire_type = {
|
||||
{ &mp_type_type },
|
||||
.name = MP_QSTR_OneWire,
|
||||
.make_new = bitbangio_onewire_make_new,
|
||||
.locals_dict = (mp_obj_dict_t *)&bitbangio_onewire_locals_dict,
|
||||
};
|
@ -34,7 +34,7 @@
|
||||
|
||||
#include "shared-bindings/bitbangio/__init__.h"
|
||||
#include "shared-bindings/bitbangio/I2C.h"
|
||||
#include "shared-bindings/bitbangio/OneWire.h"
|
||||
#include "shared-bindings/onewireio/OneWire.h"
|
||||
#include "shared-bindings/bitbangio/SPI.h"
|
||||
|
||||
#include "py/runtime.h"
|
||||
@ -72,7 +72,7 @@
|
||||
STATIC const mp_rom_map_elem_t bitbangio_module_globals_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_bitbangio) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&bitbangio_i2c_type) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_OneWire), MP_ROM_PTR(&bitbangio_onewire_type) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_OneWire), MP_ROM_PTR(&onewireio_onewire_type) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&bitbangio_spi_type) },
|
||||
};
|
||||
|
||||
|
@ -1,43 +0,0 @@
|
||||
/*
|
||||
* This file is part of the Micro Python 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_SHARED_BINDINGS_BUSIO_ONEWIRE_H
|
||||
#define MICROPY_INCLUDED_SHARED_BINDINGS_BUSIO_ONEWIRE_H
|
||||
|
||||
#include "common-hal/microcontroller/Pin.h"
|
||||
#include "common-hal/busio/OneWire.h"
|
||||
|
||||
extern const mp_obj_type_t busio_onewire_type;
|
||||
|
||||
extern void common_hal_busio_onewire_construct(busio_onewire_obj_t *self,
|
||||
const mcu_pin_obj_t *pin);
|
||||
extern void common_hal_busio_onewire_deinit(busio_onewire_obj_t *self);
|
||||
extern bool common_hal_busio_onewire_deinited(busio_onewire_obj_t *self);
|
||||
extern bool common_hal_busio_onewire_reset(busio_onewire_obj_t *self);
|
||||
extern bool common_hal_busio_onewire_read_bit(busio_onewire_obj_t *self);
|
||||
extern void common_hal_busio_onewire_write_bit(busio_onewire_obj_t *self, bool bit);
|
||||
|
||||
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_BUSIO_ONEWIRE_H
|
@ -104,7 +104,7 @@ STATIC mp_obj_t busio_spi_make_new(const mp_obj_type_t *type, size_t n_args, con
|
||||
common_hal_busio_spi_construct(self, clock, mosi, miso);
|
||||
return MP_OBJ_FROM_PTR(self);
|
||||
#else
|
||||
mp_raise_NotImplementedError(NULL);
|
||||
mp_raise_ValueError(translate("Invalid pins"));
|
||||
#endif // CIRCUITPY_BUSIO_SPI
|
||||
}
|
||||
|
||||
|
@ -72,13 +72,16 @@ typedef struct {
|
||||
extern const busio_uart_parity_obj_t busio_uart_parity_even_obj;
|
||||
extern const busio_uart_parity_obj_t busio_uart_parity_odd_obj;
|
||||
|
||||
#if CIRCUITPY_BUSIO_UART
|
||||
STATIC void validate_timeout(mp_float_t timeout) {
|
||||
if (timeout < (mp_float_t)0.0f || timeout > (mp_float_t)100.0f) {
|
||||
mp_raise_ValueError(translate("timeout must be 0.0-100.0 seconds"));
|
||||
}
|
||||
}
|
||||
#endif // CIRCUITPY_BUSIO_UART
|
||||
|
||||
STATIC mp_obj_t busio_uart_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||
#if CIRCUITPY_BUSIO_UART
|
||||
// Always initially allocate the UART object within the long-lived heap.
|
||||
// This is needed to avoid crashes with certain UART implementations which
|
||||
// cannot accomodate being moved after creation. (See
|
||||
@ -141,8 +144,12 @@ STATIC mp_obj_t busio_uart_make_new(const mp_obj_type_t *type, size_t n_args, co
|
||||
args[ARG_baudrate].u_int, bits, parity, stop, timeout,
|
||||
args[ARG_receiver_buffer_size].u_int, NULL, false);
|
||||
return (mp_obj_t)self;
|
||||
#else
|
||||
mp_raise_ValueError(translate("Invalid pins"));
|
||||
#endif // CIRCUITPY_BUSIO_UART
|
||||
}
|
||||
|
||||
#if CIRCUITPY_BUSIO_UART
|
||||
|
||||
// Helper to ensure we have the native super class instead of a subclass.
|
||||
busio_uart_obj_t *native_uart(mp_obj_t uart_obj) {
|
||||
@ -358,6 +365,7 @@ STATIC mp_obj_t busio_uart_obj_reset_input_buffer(mp_obj_t self_in) {
|
||||
return mp_const_none;
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(busio_uart_reset_input_buffer_obj, busio_uart_obj_reset_input_buffer);
|
||||
#endif // CIRCUITPY_BUSIO_UART
|
||||
|
||||
//| class Parity:
|
||||
//| """Enum-like class to define the parity used to verify correct data transfer."""
|
||||
@ -400,6 +408,7 @@ const mp_obj_type_t busio_uart_parity_type = {
|
||||
};
|
||||
|
||||
STATIC const mp_rom_map_elem_t busio_uart_locals_dict_table[] = {
|
||||
#if CIRCUITPY_BUSIO_UART
|
||||
{ MP_ROM_QSTR(MP_QSTR___del__), MP_ROM_PTR(&busio_uart_deinit_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&busio_uart_deinit_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&default___enter___obj) },
|
||||
@ -417,12 +426,14 @@ STATIC const mp_rom_map_elem_t busio_uart_locals_dict_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR_baudrate), MP_ROM_PTR(&busio_uart_baudrate_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_in_waiting), MP_ROM_PTR(&busio_uart_in_waiting_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_timeout), MP_ROM_PTR(&busio_uart_timeout_obj) },
|
||||
#endif // CIRCUITPY_BUSIO_UART
|
||||
|
||||
// Nested Enum-like Classes.
|
||||
{ MP_ROM_QSTR(MP_QSTR_Parity), MP_ROM_PTR(&busio_uart_parity_type) },
|
||||
};
|
||||
STATIC MP_DEFINE_CONST_DICT(busio_uart_locals_dict, busio_uart_locals_dict_table);
|
||||
|
||||
#if CIRCUITPY_BUSIO_UART
|
||||
STATIC const mp_stream_p_t uart_stream_p = {
|
||||
MP_PROTO_IMPLEMENT(MP_QSTR_protocol_stream)
|
||||
.read = busio_uart_read,
|
||||
@ -445,3 +456,11 @@ const mp_obj_type_t busio_uart_type = {
|
||||
.protocol = &uart_stream_p,
|
||||
),
|
||||
};
|
||||
#else
|
||||
const mp_obj_type_t busio_uart_type = {
|
||||
{ &mp_type_type },
|
||||
.name = MP_QSTR_UART,
|
||||
.make_new = busio_uart_make_new,
|
||||
.locals_dict = (mp_obj_dict_t *)&busio_uart_locals_dict,
|
||||
};
|
||||
#endif // CIRCUITPY_BUSIO_UART
|
||||
|
@ -32,9 +32,9 @@
|
||||
#include "shared-bindings/microcontroller/Pin.h"
|
||||
#include "shared-bindings/busio/__init__.h"
|
||||
#include "shared-bindings/busio/I2C.h"
|
||||
#include "shared-bindings/busio/OneWire.h"
|
||||
#include "shared-bindings/busio/SPI.h"
|
||||
#include "shared-bindings/busio/UART.h"
|
||||
#include "shared-bindings/onewireio/OneWire.h"
|
||||
|
||||
#include "py/runtime.h"
|
||||
|
||||
@ -73,7 +73,7 @@ STATIC const mp_rom_map_elem_t busio_module_globals_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_busio) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&busio_i2c_type) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&busio_spi_type) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_OneWire), MP_ROM_PTR(&busio_onewire_type) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_OneWire), MP_ROM_PTR(&onewireio_onewire_type) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&busio_uart_type) },
|
||||
};
|
||||
|
||||
|
@ -80,7 +80,7 @@ MAKE_ENUM_VALUE(canio_bus_state_type, bus_state, BUS_OFF, BUS_STATE_OFF);
|
||||
//| ERROR_WARNING: object
|
||||
//| """The bus is in the normal (active) state, but a moderate number of errors have occurred recently.
|
||||
//|
|
||||
//| NOTE: Not all implementations may use ERROR_WARNING. Do not rely on seeing ERROR_WARNING before ERROR_PASSIVE."""
|
||||
//| .. note:: Not all implementations may use ``ERROR_WARNING``. Do not rely on seeing ``ERROR_WARNING`` before ``ERROR_PASSIVE``."""
|
||||
//|
|
||||
//| ERROR_PASSIVE: object
|
||||
//| """The bus is in the passive state due to the number of errors that have occurred recently.
|
||||
|
@ -230,14 +230,14 @@ STATIC mp_obj_t displayio_display_obj_show(mp_obj_t self_in, mp_obj_t group_in)
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_2(displayio_display_show_obj, displayio_display_obj_show);
|
||||
|
||||
//| def refresh(self, *, target_frames_per_second: Optional[int] = None, minimum_frames_per_second: int = 1) -> bool:
|
||||
//| def refresh(self, *, target_frames_per_second: Optional[int] = None, minimum_frames_per_second: int = 0) -> bool:
|
||||
//| """When auto refresh is off, waits for the target frame rate and then refreshes the display,
|
||||
//| returning True. If the call has taken too long since the last refresh call for the given
|
||||
//| target frame rate, then the refresh returns False immediately without updating the screen to
|
||||
//| hopefully help getting caught up.
|
||||
//|
|
||||
//| If the time since the last successful refresh is below the minimum frame rate, then an
|
||||
//| exception will be raised. Set ``minimum_frames_per_second`` to 0 to disable.
|
||||
//| exception will be raised. The default ``minimum_frames_per_second`` of 0 disables this behavior.
|
||||
//|
|
||||
//| When auto refresh is off, ``display.refresh()`` or ``display.refresh(target_frames_per_second=None)``
|
||||
//| will update the display immediately.
|
||||
@ -254,7 +254,7 @@ STATIC mp_obj_t displayio_display_obj_refresh(size_t n_args, const mp_obj_t *pos
|
||||
enum { ARG_target_frames_per_second, ARG_minimum_frames_per_second };
|
||||
static const mp_arg_t allowed_args[] = {
|
||||
{ MP_QSTR_target_frames_per_second, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = mp_const_none} },
|
||||
{ MP_QSTR_minimum_frames_per_second, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 1} },
|
||||
{ MP_QSTR_minimum_frames_per_second, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} },
|
||||
};
|
||||
|
||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||
|
@ -54,7 +54,9 @@
|
||||
//| width: int, height: int, ram_width: int, ram_height: int,
|
||||
//| colstart: int = 0, rowstart: int = 0, rotation: int = 0,
|
||||
//| set_column_window_command: Optional[int] = None,
|
||||
//| set_row_window_command: Optional[int] = None, single_byte_bounds: bool = False,
|
||||
//| set_row_window_command: Optional[int] = None,
|
||||
//| set_current_column_command: Optional[int] = None,
|
||||
//| set_current_row_command: Optional[int] = None,
|
||||
//| write_black_ram_command: int, black_bits_inverted: bool = False,
|
||||
//| write_color_ram_command: Optional[int] = None,
|
||||
//| color_bits_inverted: bool = False, highlight_color: int = 0x000000,
|
||||
|
@ -68,7 +68,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(keypad_eventqueue_get_obj, keypad_eventqueue_get);
|
||||
//| Note that the queue size is limited; see ``max_events`` in the constructor of
|
||||
//| a scanner such as `Keys` or `KeyMatrix`.
|
||||
//|
|
||||
//| :return ``True`` if an event was available and stored, ``False`` if not.
|
||||
//| :return: ``True`` if an event was available and stored, ``False`` if not.
|
||||
//| :rtype: bool
|
||||
//| """
|
||||
//| ...
|
||||
|
@ -31,37 +31,33 @@
|
||||
#include "py/runtime.h"
|
||||
#include "py/runtime0.h"
|
||||
#include "shared-bindings/microcontroller/Pin.h"
|
||||
#include "shared-bindings/busio/OneWire.h"
|
||||
#include "shared-bindings/onewireio/OneWire.h"
|
||||
#include "shared-bindings/util.h"
|
||||
|
||||
//| class OneWire:
|
||||
//| """Lowest-level of the Maxim OneWire protocol"""
|
||||
//|
|
||||
//| def __init__(self, pin: microcontroller.Pin) -> None:
|
||||
//| """(formerly Dallas Semi) OneWire protocol.
|
||||
//| """Create a OneWire object associated with the given pin.
|
||||
//|
|
||||
//| Protocol definition is here: https://www.maximintegrated.com/en/app-notes/index.mvp/id/126
|
||||
//|
|
||||
//| .. class:: OneWire(pin)
|
||||
//|
|
||||
//| Create a OneWire object associated with the given pin. The object
|
||||
//| implements the lowest level timing-sensitive bits of the protocol.
|
||||
//| The object implements the lowest level timing-sensitive bits of the protocol.
|
||||
//|
|
||||
//| :param ~microcontroller.Pin pin: Pin connected to the OneWire bus
|
||||
//|
|
||||
//| .. note:: The OneWire class is available on `busio` and `bitbangio` in CircuitPython
|
||||
//| 7.x for backwards compatibility but will be removed in CircuitPython 8.0.0.
|
||||
//|
|
||||
//| Read a short series of pulses::
|
||||
//|
|
||||
//| import busio
|
||||
//| import onewireio
|
||||
//| import board
|
||||
//|
|
||||
//| onewire = busio.OneWire(board.D7)
|
||||
//| onewire = onewireio.OneWire(board.D7)
|
||||
//| onewire.reset()
|
||||
//| onewire.write_bit(True)
|
||||
//| onewire.write_bit(False)
|
||||
//| print(onewire.read_bit())"""
|
||||
//| ...
|
||||
//|
|
||||
STATIC mp_obj_t busio_onewire_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||
STATIC mp_obj_t onewireio_onewire_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_pin };
|
||||
static const mp_arg_t allowed_args[] = {
|
||||
{ MP_QSTR_pin, MP_ARG_REQUIRED | MP_ARG_OBJ },
|
||||
@ -70,10 +66,10 @@ STATIC mp_obj_t busio_onewire_make_new(const mp_obj_type_t *type, size_t n_args,
|
||||
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||
const mcu_pin_obj_t *pin = validate_obj_is_free_pin(args[ARG_pin].u_obj);
|
||||
|
||||
busio_onewire_obj_t *self = m_new_obj(busio_onewire_obj_t);
|
||||
self->base.type = &busio_onewire_type;
|
||||
onewireio_onewire_obj_t *self = m_new_obj(onewireio_onewire_obj_t);
|
||||
self->base.type = &onewireio_onewire_type;
|
||||
|
||||
common_hal_busio_onewire_construct(self, pin);
|
||||
common_hal_onewireio_onewire_construct(self, pin);
|
||||
return MP_OBJ_FROM_PTR(self);
|
||||
}
|
||||
|
||||
@ -81,15 +77,15 @@ STATIC mp_obj_t busio_onewire_make_new(const mp_obj_type_t *type, size_t n_args,
|
||||
//| """Deinitialize the OneWire bus and release any hardware resources for reuse."""
|
||||
//| ...
|
||||
//|
|
||||
STATIC mp_obj_t busio_onewire_deinit(mp_obj_t self_in) {
|
||||
busio_onewire_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
common_hal_busio_onewire_deinit(self);
|
||||
STATIC mp_obj_t onewireio_onewire_deinit(mp_obj_t self_in) {
|
||||
onewireio_onewire_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
common_hal_onewireio_onewire_deinit(self);
|
||||
return mp_const_none;
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(busio_onewire_deinit_obj, busio_onewire_deinit);
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(onewireio_onewire_deinit_obj, onewireio_onewire_deinit);
|
||||
|
||||
STATIC void check_for_deinit(busio_onewire_obj_t *self) {
|
||||
if (common_hal_busio_onewire_deinited(self)) {
|
||||
STATIC void check_for_deinit(onewireio_onewire_obj_t *self) {
|
||||
if (common_hal_onewireio_onewire_deinited(self)) {
|
||||
raise_deinited_error();
|
||||
}
|
||||
}
|
||||
@ -105,12 +101,12 @@ STATIC void check_for_deinit(busio_onewire_obj_t *self) {
|
||||
//| :ref:`lifetime-and-contextmanagers` for more info."""
|
||||
//| ...
|
||||
//|
|
||||
STATIC mp_obj_t busio_onewire_obj___exit__(size_t n_args, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t onewireio_onewire_obj___exit__(size_t n_args, const mp_obj_t *args) {
|
||||
(void)n_args;
|
||||
common_hal_busio_onewire_deinit(args[0]);
|
||||
common_hal_onewireio_onewire_deinit(args[0]);
|
||||
return mp_const_none;
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(busio_onewire___exit___obj, 4, 4, busio_onewire_obj___exit__);
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(onewireio_onewire___exit___obj, 4, 4, onewireio_onewire_obj___exit__);
|
||||
|
||||
//| def reset(self) -> bool:
|
||||
//| """Reset the OneWire bus and read presence
|
||||
@ -119,13 +115,13 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(busio_onewire___exit___obj, 4, 4, bus
|
||||
//| :rtype: bool"""
|
||||
//| ...
|
||||
//|
|
||||
STATIC mp_obj_t busio_onewire_obj_reset(mp_obj_t self_in) {
|
||||
busio_onewire_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
STATIC mp_obj_t onewireio_onewire_obj_reset(mp_obj_t self_in) {
|
||||
onewireio_onewire_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
check_for_deinit(self);
|
||||
|
||||
return mp_obj_new_bool(common_hal_busio_onewire_reset(self));
|
||||
return mp_obj_new_bool(common_hal_onewireio_onewire_reset(self));
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(busio_onewire_reset_obj, busio_onewire_obj_reset);
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(onewireio_onewire_reset_obj, onewireio_onewire_obj_reset);
|
||||
|
||||
//| def read_bit(self) -> bool:
|
||||
//| """Read in a bit
|
||||
@ -134,41 +130,41 @@ MP_DEFINE_CONST_FUN_OBJ_1(busio_onewire_reset_obj, busio_onewire_obj_reset);
|
||||
//| :rtype: bool"""
|
||||
//| ...
|
||||
//|
|
||||
STATIC mp_obj_t busio_onewire_obj_read_bit(mp_obj_t self_in) {
|
||||
busio_onewire_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
STATIC mp_obj_t onewireio_onewire_obj_read_bit(mp_obj_t self_in) {
|
||||
onewireio_onewire_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
check_for_deinit(self);
|
||||
|
||||
return mp_obj_new_bool(common_hal_busio_onewire_read_bit(self));
|
||||
return mp_obj_new_bool(common_hal_onewireio_onewire_read_bit(self));
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(busio_onewire_read_bit_obj, busio_onewire_obj_read_bit);
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(onewireio_onewire_read_bit_obj, onewireio_onewire_obj_read_bit);
|
||||
|
||||
//| def write_bit(self, value: bool) -> None:
|
||||
//| """Write out a bit based on value."""
|
||||
//| ...
|
||||
//|
|
||||
STATIC mp_obj_t busio_onewire_obj_write_bit(mp_obj_t self_in, mp_obj_t bool_obj) {
|
||||
busio_onewire_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
STATIC mp_obj_t onewireio_onewire_obj_write_bit(mp_obj_t self_in, mp_obj_t bool_obj) {
|
||||
onewireio_onewire_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
check_for_deinit(self);
|
||||
|
||||
common_hal_busio_onewire_write_bit(self, mp_obj_is_true(bool_obj));
|
||||
common_hal_onewireio_onewire_write_bit(self, mp_obj_is_true(bool_obj));
|
||||
return mp_const_none;
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_2(busio_onewire_write_bit_obj, busio_onewire_obj_write_bit);
|
||||
MP_DEFINE_CONST_FUN_OBJ_2(onewireio_onewire_write_bit_obj, onewireio_onewire_obj_write_bit);
|
||||
|
||||
STATIC const mp_rom_map_elem_t busio_onewire_locals_dict_table[] = {
|
||||
STATIC const mp_rom_map_elem_t onewireio_onewire_locals_dict_table[] = {
|
||||
// Methods
|
||||
{ MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&busio_onewire_deinit_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&onewireio_onewire_deinit_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&default___enter___obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&busio_onewire___exit___obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_reset), MP_ROM_PTR(&busio_onewire_reset_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_read_bit), MP_ROM_PTR(&busio_onewire_read_bit_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_write_bit), MP_ROM_PTR(&busio_onewire_write_bit_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&onewireio_onewire___exit___obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_reset), MP_ROM_PTR(&onewireio_onewire_reset_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_read_bit), MP_ROM_PTR(&onewireio_onewire_read_bit_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_write_bit), MP_ROM_PTR(&onewireio_onewire_write_bit_obj) },
|
||||
};
|
||||
STATIC MP_DEFINE_CONST_DICT(busio_onewire_locals_dict, busio_onewire_locals_dict_table);
|
||||
STATIC MP_DEFINE_CONST_DICT(onewireio_onewire_locals_dict, onewireio_onewire_locals_dict_table);
|
||||
|
||||
const mp_obj_type_t busio_onewire_type = {
|
||||
const mp_obj_type_t onewireio_onewire_type = {
|
||||
{ &mp_type_type },
|
||||
.name = MP_QSTR_OneWire,
|
||||
.make_new = busio_onewire_make_new,
|
||||
.locals_dict = (mp_obj_dict_t *)&busio_onewire_locals_dict,
|
||||
.make_new = onewireio_onewire_make_new,
|
||||
.locals_dict = (mp_obj_dict_t *)&onewireio_onewire_locals_dict,
|
||||
};
|
@ -24,20 +24,20 @@
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_BITBANGIO_ONEWIRE_H
|
||||
#define MICROPY_INCLUDED_SHARED_BINDINGS_BITBANGIO_ONEWIRE_H
|
||||
#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_ONEWIREIO_ONEWIRE_H
|
||||
#define MICROPY_INCLUDED_SHARED_BINDINGS_ONEWIREIO_ONEWIRE_H
|
||||
|
||||
#include "common-hal/microcontroller/Pin.h"
|
||||
#include "shared-module/bitbangio/OneWire.h"
|
||||
#include "shared-module/onewireio/OneWire.h"
|
||||
|
||||
extern const mp_obj_type_t bitbangio_onewire_type;
|
||||
extern const mp_obj_type_t onewireio_onewire_type;
|
||||
|
||||
extern void shared_module_bitbangio_onewire_construct(bitbangio_onewire_obj_t *self,
|
||||
extern void common_hal_onewireio_onewire_construct(onewireio_onewire_obj_t *self,
|
||||
const mcu_pin_obj_t *pin);
|
||||
extern void shared_module_bitbangio_onewire_deinit(bitbangio_onewire_obj_t *self);
|
||||
extern bool shared_module_bitbangio_onewire_deinited(bitbangio_onewire_obj_t *self);
|
||||
extern bool shared_module_bitbangio_onewire_reset(bitbangio_onewire_obj_t *self);
|
||||
extern bool shared_module_bitbangio_onewire_read_bit(bitbangio_onewire_obj_t *self);
|
||||
extern void shared_module_bitbangio_onewire_write_bit(bitbangio_onewire_obj_t *self, bool bit);
|
||||
extern void common_hal_onewireio_onewire_deinit(onewireio_onewire_obj_t *self);
|
||||
extern bool common_hal_onewireio_onewire_deinited(onewireio_onewire_obj_t *self);
|
||||
extern bool common_hal_onewireio_onewire_reset(onewireio_onewire_obj_t *self);
|
||||
extern bool common_hal_onewireio_onewire_read_bit(onewireio_onewire_obj_t *self);
|
||||
extern void common_hal_onewireio_onewire_write_bit(onewireio_onewire_obj_t *self, bool bit);
|
||||
|
||||
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_BITBANGIO_ONEWIRE_H
|
||||
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_ONEWIREIO_ONEWIRE_H
|
53
shared-bindings/onewireio/__init__.c
Normal file
53
shared-bindings/onewireio/__init__.c
Normal file
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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 <stdint.h>
|
||||
|
||||
#include "py/obj.h"
|
||||
#include "py/runtime.h"
|
||||
|
||||
#include "shared-bindings/microcontroller/Pin.h"
|
||||
#include "shared-bindings/onewireio/__init__.h"
|
||||
#include "shared-bindings/onewireio/OneWire.h"
|
||||
|
||||
#include "py/runtime.h"
|
||||
|
||||
//| """Low-level bit primitives for Maxim (formerly Dallas Semi) one-wire protocol.
|
||||
//|
|
||||
//| Protocol definition is here: https://www.maximintegrated.com/en/app-notes/index.mvp/id/126"""
|
||||
//|
|
||||
|
||||
STATIC const mp_rom_map_elem_t onewireio_module_globals_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_onewireio) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_OneWire), MP_ROM_PTR(&onewireio_onewire_type) },
|
||||
};
|
||||
|
||||
STATIC MP_DEFINE_CONST_DICT(onewireio_module_globals, onewireio_module_globals_table);
|
||||
|
||||
const mp_obj_module_t onewireio_module = {
|
||||
.base = { &mp_type_module },
|
||||
.globals = (mp_obj_dict_t *)&onewireio_module_globals,
|
||||
};
|
@ -24,10 +24,11 @@
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef MICROPY_INCLUDED_NRF_COMMON_HAL_BUSIO_ONEWIRE_H
|
||||
#define MICROPY_INCLUDED_NRF_COMMON_HAL_BUSIO_ONEWIRE_H
|
||||
#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_ONEWIREIO___INIT___H
|
||||
#define MICROPY_INCLUDED_SHARED_BINDINGS_ONEWIREIO___INIT___H
|
||||
|
||||
// Use bitbangio.
|
||||
#include "shared-module/busio/OneWire.h"
|
||||
#include "py/obj.h"
|
||||
|
||||
#endif // MICROPY_INCLUDED_NRF_COMMON_HAL_BUSIO_ONEWIRE_H
|
||||
// Nothing now.
|
||||
|
||||
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_ONEWIREIO___INIT___H
|
@ -73,7 +73,7 @@ STATIC void traceback_exception_common(mp_print_t *print, mp_obj_t value, mp_obj
|
||||
//| these lines are concatenated and printed, exactly the same text is
|
||||
//| printed as does print_exception().
|
||||
//|
|
||||
//| .. note: Setting `chain` will have no effect as chained exceptions are not yet implemented.
|
||||
//| .. note:: Setting ``chain`` will have no effect as chained exceptions are not yet implemented.
|
||||
//|
|
||||
//| :param Type[BaseException] etype: This is ignored and inferred from the type of ``value``.
|
||||
//| :param BaseException value: The exception. Must be an instance of `BaseException`.
|
||||
@ -112,7 +112,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(traceback_format_exception_obj, 3, traceback_f
|
||||
//|
|
||||
//| """Prints exception information and stack trace entries.
|
||||
//|
|
||||
//| .. note: Setting `chain` will have no effect as chained exceptions are not yet implemented.
|
||||
//| .. note:: Setting ``chain`` will have no effect as chained exceptions are not yet implemented.
|
||||
//|
|
||||
//| :param Type[BaseException] etype: This is ignored and inferred from the type of ``value``.
|
||||
//| :param BaseException value: The exception. Must be an instance of `BaseException`.
|
||||
|
@ -206,7 +206,7 @@ audioio_get_buffer_result_t audioio_wavefile_get_buffer(audioio_wavefile_obj_t *
|
||||
}
|
||||
|
||||
if (need_more_data) {
|
||||
uint16_t num_bytes_to_load = self->len;
|
||||
uint32_t num_bytes_to_load = self->len;
|
||||
if (num_bytes_to_load > self->bytes_remaining) {
|
||||
num_bytes_to_load = self->bytes_remaining;
|
||||
}
|
||||
|
@ -1,59 +0,0 @@
|
||||
/*
|
||||
* This file is part of the Micro Python 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.
|
||||
*/
|
||||
|
||||
// Wraps the bitbangio implementation of OneWire for use in busio.
|
||||
#include "common-hal/microcontroller/Pin.h"
|
||||
#include "shared-bindings/bitbangio/OneWire.h"
|
||||
#include "shared-module/busio/OneWire.h"
|
||||
|
||||
void common_hal_busio_onewire_construct(busio_onewire_obj_t *self,
|
||||
const mcu_pin_obj_t *pin) {
|
||||
shared_module_bitbangio_onewire_construct(&self->bitbang, pin);
|
||||
}
|
||||
|
||||
bool common_hal_busio_onewire_deinited(busio_onewire_obj_t *self) {
|
||||
return shared_module_bitbangio_onewire_deinited(&self->bitbang);
|
||||
}
|
||||
|
||||
void common_hal_busio_onewire_deinit(busio_onewire_obj_t *self) {
|
||||
if (common_hal_busio_onewire_deinited(self)) {
|
||||
return;
|
||||
}
|
||||
shared_module_bitbangio_onewire_deinit(&self->bitbang);
|
||||
}
|
||||
|
||||
bool common_hal_busio_onewire_reset(busio_onewire_obj_t *self) {
|
||||
return shared_module_bitbangio_onewire_reset(&self->bitbang);
|
||||
}
|
||||
|
||||
bool common_hal_busio_onewire_read_bit(busio_onewire_obj_t *self) {
|
||||
return shared_module_bitbangio_onewire_read_bit(&self->bitbang);
|
||||
}
|
||||
|
||||
void common_hal_busio_onewire_write_bit(busio_onewire_obj_t *self,
|
||||
bool bit) {
|
||||
shared_module_bitbangio_onewire_write_bit(&self->bitbang, bit);
|
||||
}
|
@ -77,8 +77,6 @@ void common_hal_keypad_keymatrix_construct(keypad_keymatrix_obj_t *self, mp_uint
|
||||
|
||||
// Add self to the list of active keypad scanners.
|
||||
keypad_register_scanner((keypad_scanner_obj_t *)self);
|
||||
|
||||
supervisor_enable_tick();
|
||||
}
|
||||
|
||||
void common_hal_keypad_keymatrix_deinit(keypad_keymatrix_obj_t *self) {
|
||||
|
@ -63,8 +63,6 @@ void common_hal_keypad_keys_construct(keypad_keys_obj_t *self, mp_uint_t num_pin
|
||||
|
||||
// Add self to the list of active keypad scanners.
|
||||
keypad_register_scanner((keypad_scanner_obj_t *)self);
|
||||
|
||||
supervisor_enable_tick();
|
||||
}
|
||||
|
||||
void common_hal_keypad_keys_deinit(keypad_keys_obj_t *self) {
|
||||
|
@ -71,8 +71,6 @@ void common_hal_keypad_shiftregisterkeys_construct(keypad_shiftregisterkeys_obj_
|
||||
|
||||
// Add self to the list of active keypad scanners.
|
||||
keypad_register_scanner((keypad_scanner_obj_t *)self);
|
||||
|
||||
supervisor_enable_tick();
|
||||
}
|
||||
|
||||
void common_hal_keypad_shiftregisterkeys_deinit(keypad_shiftregisterkeys_obj_t *self) {
|
||||
|
@ -57,12 +57,9 @@ void keypad_tick(void) {
|
||||
}
|
||||
|
||||
void keypad_reset(void) {
|
||||
if (MP_STATE_VM(keypad_scanners_linked_list)) {
|
||||
supervisor_disable_tick();
|
||||
while (MP_STATE_VM(keypad_scanners_linked_list)) {
|
||||
keypad_deregister_scanner(MP_STATE_VM(keypad_scanners_linked_list));
|
||||
}
|
||||
|
||||
MP_STATE_VM(keypad_scanners_linked_list) = NULL;
|
||||
keypad_scanners_linked_list_lock = false;
|
||||
}
|
||||
|
||||
// Register a Keys, KeyMatrix, etc. that will be scanned in the background
|
||||
@ -71,10 +68,16 @@ void keypad_register_scanner(keypad_scanner_obj_t *scanner) {
|
||||
scanner->next = MP_STATE_VM(keypad_scanners_linked_list);
|
||||
MP_STATE_VM(keypad_scanners_linked_list) = scanner;
|
||||
supervisor_release_lock(&keypad_scanners_linked_list_lock);
|
||||
|
||||
// One more request for ticks.
|
||||
supervisor_enable_tick();
|
||||
}
|
||||
|
||||
// Remove scanner from the list of active scanners.
|
||||
void keypad_deregister_scanner(keypad_scanner_obj_t *scanner) {
|
||||
// One less request for ticks.
|
||||
supervisor_disable_tick();
|
||||
|
||||
supervisor_acquire_lock(&keypad_scanners_linked_list_lock);
|
||||
if (MP_STATE_VM(keypad_scanners_linked_list) == scanner) {
|
||||
// Scanner is at the front; splice it out.
|
||||
|
@ -25,24 +25,24 @@
|
||||
*/
|
||||
|
||||
#include "common-hal/microcontroller/Pin.h"
|
||||
#include "shared-bindings/bitbangio/OneWire.h"
|
||||
#include "shared-bindings/onewireio/OneWire.h"
|
||||
#include "shared-bindings/microcontroller/__init__.h"
|
||||
#include "shared-bindings/digitalio/DigitalInOut.h"
|
||||
|
||||
// Durations are taken from here: https://www.maximintegrated.com/en/app-notes/index.mvp/id/126
|
||||
|
||||
void shared_module_bitbangio_onewire_construct(bitbangio_onewire_obj_t *self,
|
||||
void common_hal_onewireio_onewire_construct(onewireio_onewire_obj_t *self,
|
||||
const mcu_pin_obj_t *pin) {
|
||||
self->pin.base.type = &digitalio_digitalinout_type;
|
||||
common_hal_digitalio_digitalinout_construct(&self->pin, pin);
|
||||
}
|
||||
|
||||
bool shared_module_bitbangio_onewire_deinited(bitbangio_onewire_obj_t *self) {
|
||||
bool common_hal_onewireio_onewire_deinited(onewireio_onewire_obj_t *self) {
|
||||
return common_hal_digitalio_digitalinout_deinited(&self->pin);
|
||||
}
|
||||
|
||||
void shared_module_bitbangio_onewire_deinit(bitbangio_onewire_obj_t *self) {
|
||||
if (shared_module_bitbangio_onewire_deinited(self)) {
|
||||
void common_hal_onewireio_onewire_deinit(onewireio_onewire_obj_t *self) {
|
||||
if (common_hal_onewireio_onewire_deinited(self)) {
|
||||
return;
|
||||
}
|
||||
common_hal_digitalio_digitalinout_deinit(&self->pin);
|
||||
@ -51,7 +51,7 @@ void shared_module_bitbangio_onewire_deinit(bitbangio_onewire_obj_t *self) {
|
||||
// We use common_hal_mcu_delay_us(). It should not be dependent on interrupts
|
||||
// to do accurate timekeeping, since we disable interrupts during the delays below.
|
||||
|
||||
bool shared_module_bitbangio_onewire_reset(bitbangio_onewire_obj_t *self) {
|
||||
bool common_hal_onewireio_onewire_reset(onewireio_onewire_obj_t *self) {
|
||||
common_hal_mcu_disable_interrupts();
|
||||
common_hal_digitalio_digitalinout_switch_to_output(&self->pin, false, DRIVE_MODE_OPEN_DRAIN);
|
||||
common_hal_mcu_delay_us(480);
|
||||
@ -63,7 +63,7 @@ bool shared_module_bitbangio_onewire_reset(bitbangio_onewire_obj_t *self) {
|
||||
return value;
|
||||
}
|
||||
|
||||
bool shared_module_bitbangio_onewire_read_bit(bitbangio_onewire_obj_t *self) {
|
||||
bool common_hal_onewireio_onewire_read_bit(onewireio_onewire_obj_t *self) {
|
||||
common_hal_mcu_disable_interrupts();
|
||||
common_hal_digitalio_digitalinout_switch_to_output(&self->pin, false, DRIVE_MODE_OPEN_DRAIN);
|
||||
common_hal_mcu_delay_us(6);
|
||||
@ -78,7 +78,7 @@ bool shared_module_bitbangio_onewire_read_bit(bitbangio_onewire_obj_t *self) {
|
||||
return value;
|
||||
}
|
||||
|
||||
void shared_module_bitbangio_onewire_write_bit(bitbangio_onewire_obj_t *self,
|
||||
void common_hal_onewireio_onewire_write_bit(onewireio_onewire_obj_t *self,
|
||||
bool bit) {
|
||||
common_hal_mcu_disable_interrupts();
|
||||
common_hal_digitalio_digitalinout_switch_to_output(&self->pin, false, DRIVE_MODE_OPEN_DRAIN);
|
@ -24,8 +24,8 @@
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef MICROPY_INCLUDED_SHARED_MODULE_BITBANGIO_ONEWIRE_H
|
||||
#define MICROPY_INCLUDED_SHARED_MODULE_BITBANGIO_ONEWIRE_H
|
||||
#ifndef MICROPY_INCLUDED_SHARED_MODULE_ONEWIREIO_ONEWIRE_H
|
||||
#define MICROPY_INCLUDED_SHARED_MODULE_ONEWIREIO_ONEWIRE_H
|
||||
|
||||
#include "common-hal/digitalio/DigitalInOut.h"
|
||||
|
||||
@ -34,6 +34,6 @@
|
||||
typedef struct {
|
||||
mp_obj_base_t base;
|
||||
digitalio_digitalinout_obj_t pin;
|
||||
} bitbangio_onewire_obj_t;
|
||||
} onewireio_onewire_obj_t;
|
||||
|
||||
#endif // MICROPY_INCLUDED_SHARED_MODULE_BITBANGIO_ONEWIRE_H
|
||||
#endif // MICROPY_INCLUDED_SHARED_MODULE_ONEWIREIO_ONEWIRE_H
|
@ -24,10 +24,4 @@
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef MICROPY_INCLUDED_STM32_COMMON_HAL_BUSIO_ONEWIRE_H
|
||||
#define MICROPY_INCLUDED_STM32_COMMON_HAL_BUSIO_ONEWIRE_H
|
||||
|
||||
// Use bitbangio.
|
||||
#include "shared-module/busio/OneWire.h"
|
||||
|
||||
#endif // MICROPY_INCLUDED_STM32F_COMMON_HAL_BUSIO_ONEWIRE_H
|
||||
// Nothing now.
|
@ -56,7 +56,7 @@
|
||||
|
||||
// This standard advertisement advertises the CircuitPython editing service and a CIRCUITPY short name.
|
||||
const uint8_t public_advertising_data[] = { 0x02, 0x01, 0x06, // 0-2 Flags
|
||||
0x02, 0x0a, 0xd8, // 3-5 TX power level -40
|
||||
0x02, 0x0a, 0xec, // 3-5 TX power level -20
|
||||
#if CIRCUITPY_BLE_FILE_SERVICE
|
||||
0x03, 0x02, 0xbb, 0xfe, // 6 - 9 Incomplete service list (File Transfer service)
|
||||
#endif
|
||||
@ -121,7 +121,7 @@ STATIC void supervisor_bluetooth_start_advertising(void) {
|
||||
// Advertise with less power when doing so publicly to reduce who can hear us. This will make it
|
||||
// harder for someone with bad intentions to pair from a distance.
|
||||
if (!bonded) {
|
||||
tx_power = -40;
|
||||
tx_power = -20;
|
||||
adv = public_advertising_data;
|
||||
adv_len = sizeof(public_advertising_data);
|
||||
scan_response = circuitpython_scan_response_data;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user