Merge remote-tracking branch 'adafruit/main' into native_wifi
This commit is contained in:
commit
8b71e26abd
@ -144,7 +144,7 @@ int readline_process_char(int c) {
|
||||
goto right_arrow_key;
|
||||
} else if (c == CHAR_CTRL_K) {
|
||||
// CTRL-K is kill from cursor to end-of-line, inclusive
|
||||
vstr_cut_tail_bytes(rl.line, last_line_len - rl.cursor_pos);
|
||||
vstr_cut_tail_bytes(rl.line, rl.line->len - rl.cursor_pos);
|
||||
// set redraw parameters
|
||||
redraw_from_cursor = true;
|
||||
} else if (c == CHAR_CTRL_N) {
|
||||
@ -155,6 +155,7 @@ int readline_process_char(int c) {
|
||||
goto up_arrow_key;
|
||||
} else if (c == CHAR_CTRL_U) {
|
||||
// CTRL-U is kill from beginning-of-line up to cursor
|
||||
cont_chars = count_cont_bytes(rl.line->buf+rl.orig_line_len, rl.line->buf+rl.cursor_pos);
|
||||
vstr_cut_out_bytes(rl.line, rl.orig_line_len, rl.cursor_pos - rl.orig_line_len);
|
||||
// set redraw parameters
|
||||
redraw_step_back = rl.cursor_pos - rl.orig_line_len;
|
||||
@ -342,6 +343,7 @@ left_arrow_key:
|
||||
if (c == '~') {
|
||||
if (rl.escape_seq_buf[0] == '1' || rl.escape_seq_buf[0] == '7') {
|
||||
home_key:
|
||||
cont_chars = count_cont_bytes(rl.line->buf+rl.orig_line_len, rl.line->buf+rl.cursor_pos);
|
||||
redraw_step_back = rl.cursor_pos - rl.orig_line_len;
|
||||
} else if (rl.escape_seq_buf[0] == '4' || rl.escape_seq_buf[0] == '8') {
|
||||
end_key:
|
||||
@ -352,7 +354,12 @@ end_key:
|
||||
delete_key:
|
||||
#endif
|
||||
if (rl.cursor_pos < rl.line->len) {
|
||||
vstr_cut_out_bytes(rl.line, rl.cursor_pos, 1);
|
||||
size_t len = 1;
|
||||
while (UTF8_IS_CONT(rl.line->buf[rl.cursor_pos+len]) &&
|
||||
rl.cursor_pos+len < rl.line->len) {
|
||||
len++;
|
||||
}
|
||||
vstr_cut_out_bytes(rl.line, rl.cursor_pos, len);
|
||||
redraw_from_cursor = true;
|
||||
}
|
||||
} else {
|
||||
|
17
locale/ID.po
17
locale/ID.po
@ -5,7 +5,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2020-08-14 09:36-0400\n"
|
||||
"POT-Creation-Date: 2020-08-18 11:19-0400\n"
|
||||
"PO-Revision-Date: 2020-07-06 18:10+0000\n"
|
||||
"Last-Translator: oon arfiandwi <oon.arfiandwi@gmail.com>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
@ -764,7 +764,7 @@ msgstr "Error pada regex"
|
||||
|
||||
#: shared-bindings/aesio/aes.c shared-bindings/busio/SPI.c
|
||||
#: shared-bindings/microcontroller/Pin.c
|
||||
#: shared-bindings/neopixel_write/__init__.c shared-bindings/pulseio/PulseOut.c
|
||||
#: shared-bindings/neopixel_write/__init__.c
|
||||
#: shared-bindings/terminalio/Terminal.c
|
||||
msgid "Expected a %q"
|
||||
msgstr "Diharapkan %q"
|
||||
@ -1352,6 +1352,15 @@ msgstr "Tambahkan module apapun pada filesystem\n"
|
||||
msgid "Polygon needs at least 3 points"
|
||||
msgstr ""
|
||||
|
||||
#: ports/atmel-samd/common-hal/pulseio/PulseOut.c
|
||||
#: ports/cxd56/common-hal/pulseio/PulseOut.c
|
||||
#: ports/nrf/common-hal/pulseio/PulseOut.c
|
||||
#: ports/stm/common-hal/pulseio/PulseOut.c
|
||||
msgid ""
|
||||
"Port does not accept pins or frequency. "
|
||||
"Construct and pass a PWMOut Carrier instead"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/_bleio/Adapter.c
|
||||
msgid "Prefix buffer must be on the heap"
|
||||
msgstr ""
|
||||
@ -1366,6 +1375,10 @@ msgstr ""
|
||||
msgid "Pull not used when direction is output."
|
||||
msgstr ""
|
||||
|
||||
#: ports/stm/ref/pulseout-pre-timeralloc.c
|
||||
msgid "PulseOut not supported on this chip"
|
||||
msgstr ""
|
||||
|
||||
#: ports/stm/common-hal/os/__init__.c
|
||||
msgid "RNG DeInit Error"
|
||||
msgstr ""
|
||||
|
@ -8,7 +8,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2020-08-14 09:36-0400\n"
|
||||
"POT-Creation-Date: 2020-08-21 21:39-0500\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
@ -744,7 +744,7 @@ msgstr ""
|
||||
|
||||
#: shared-bindings/aesio/aes.c shared-bindings/busio/SPI.c
|
||||
#: shared-bindings/microcontroller/Pin.c
|
||||
#: shared-bindings/neopixel_write/__init__.c shared-bindings/pulseio/PulseOut.c
|
||||
#: shared-bindings/neopixel_write/__init__.c
|
||||
#: shared-bindings/terminalio/Terminal.c
|
||||
msgid "Expected a %q"
|
||||
msgstr ""
|
||||
@ -1328,6 +1328,15 @@ msgstr ""
|
||||
msgid "Polygon needs at least 3 points"
|
||||
msgstr ""
|
||||
|
||||
#: ports/atmel-samd/common-hal/pulseio/PulseOut.c
|
||||
#: ports/cxd56/common-hal/pulseio/PulseOut.c
|
||||
#: ports/nrf/common-hal/pulseio/PulseOut.c
|
||||
#: ports/stm/common-hal/pulseio/PulseOut.c
|
||||
msgid ""
|
||||
"Port does not accept pins or frequency. "
|
||||
"Construct and pass a PWMOut Carrier instead"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/_bleio/Adapter.c
|
||||
msgid "Prefix buffer must be on the heap"
|
||||
msgstr ""
|
||||
@ -2866,6 +2875,14 @@ msgstr ""
|
||||
msgid "ord() expected a character, but string of length %d found"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/displayio/Bitmap.c
|
||||
msgid "out of range of source"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/displayio/Bitmap.c
|
||||
msgid "out of range of target"
|
||||
msgstr ""
|
||||
|
||||
#: py/objint_mpz.c
|
||||
msgid "overflow converting long int to machine word"
|
||||
msgstr ""
|
||||
@ -3043,6 +3060,10 @@ msgstr ""
|
||||
msgid "sosfilt requires iterable arguments"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/displayio/Bitmap.c
|
||||
msgid "source palette too large"
|
||||
msgstr ""
|
||||
|
||||
#: py/objstr.c
|
||||
msgid "start/end indices"
|
||||
msgstr ""
|
||||
|
17
locale/cs.po
17
locale/cs.po
@ -5,7 +5,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2020-08-14 09:36-0400\n"
|
||||
"POT-Creation-Date: 2020-08-18 11:19-0400\n"
|
||||
"PO-Revision-Date: 2020-05-24 03:22+0000\n"
|
||||
"Last-Translator: dronecz <mzuzelka@gmail.com>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
@ -750,7 +750,7 @@ msgstr ""
|
||||
|
||||
#: shared-bindings/aesio/aes.c shared-bindings/busio/SPI.c
|
||||
#: shared-bindings/microcontroller/Pin.c
|
||||
#: shared-bindings/neopixel_write/__init__.c shared-bindings/pulseio/PulseOut.c
|
||||
#: shared-bindings/neopixel_write/__init__.c
|
||||
#: shared-bindings/terminalio/Terminal.c
|
||||
msgid "Expected a %q"
|
||||
msgstr ""
|
||||
@ -1334,6 +1334,15 @@ msgstr ""
|
||||
msgid "Polygon needs at least 3 points"
|
||||
msgstr ""
|
||||
|
||||
#: ports/atmel-samd/common-hal/pulseio/PulseOut.c
|
||||
#: ports/cxd56/common-hal/pulseio/PulseOut.c
|
||||
#: ports/nrf/common-hal/pulseio/PulseOut.c
|
||||
#: ports/stm/common-hal/pulseio/PulseOut.c
|
||||
msgid ""
|
||||
"Port does not accept pins or frequency. "
|
||||
"Construct and pass a PWMOut Carrier instead"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/_bleio/Adapter.c
|
||||
msgid "Prefix buffer must be on the heap"
|
||||
msgstr ""
|
||||
@ -1346,6 +1355,10 @@ msgstr ""
|
||||
msgid "Pull not used when direction is output."
|
||||
msgstr ""
|
||||
|
||||
#: ports/stm/ref/pulseout-pre-timeralloc.c
|
||||
msgid "PulseOut not supported on this chip"
|
||||
msgstr ""
|
||||
|
||||
#: ports/stm/common-hal/os/__init__.c
|
||||
msgid "RNG DeInit Error"
|
||||
msgstr ""
|
||||
|
@ -5,7 +5,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2020-08-14 09:36-0400\n"
|
||||
"POT-Creation-Date: 2020-08-18 11:19-0400\n"
|
||||
"PO-Revision-Date: 2020-06-16 18:24+0000\n"
|
||||
"Last-Translator: Andreas Buchen <andreas.buchen@gmail.com>\n"
|
||||
"Language: de_DE\n"
|
||||
@ -760,7 +760,7 @@ msgstr "Fehler in regex"
|
||||
|
||||
#: shared-bindings/aesio/aes.c shared-bindings/busio/SPI.c
|
||||
#: shared-bindings/microcontroller/Pin.c
|
||||
#: shared-bindings/neopixel_write/__init__.c shared-bindings/pulseio/PulseOut.c
|
||||
#: shared-bindings/neopixel_write/__init__.c
|
||||
#: shared-bindings/terminalio/Terminal.c
|
||||
msgid "Expected a %q"
|
||||
msgstr "Erwartet ein(e) %q"
|
||||
@ -1362,6 +1362,15 @@ msgstr "und alle Module im Dateisystem \n"
|
||||
msgid "Polygon needs at least 3 points"
|
||||
msgstr "Polygone brauchen mindestens 3 Punkte"
|
||||
|
||||
#: ports/atmel-samd/common-hal/pulseio/PulseOut.c
|
||||
#: ports/cxd56/common-hal/pulseio/PulseOut.c
|
||||
#: ports/nrf/common-hal/pulseio/PulseOut.c
|
||||
#: ports/stm/common-hal/pulseio/PulseOut.c
|
||||
msgid ""
|
||||
"Port does not accept pins or frequency. "
|
||||
"Construct and pass a PWMOut Carrier instead"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/_bleio/Adapter.c
|
||||
msgid "Prefix buffer must be on the heap"
|
||||
msgstr "Der Präfixbuffer muss sich auf dem Heap befinden"
|
||||
@ -1376,6 +1385,10 @@ msgstr ""
|
||||
msgid "Pull not used when direction is output."
|
||||
msgstr "Pull wird nicht verwendet, wenn die Richtung output ist."
|
||||
|
||||
#: ports/stm/ref/pulseout-pre-timeralloc.c
|
||||
msgid "PulseOut not supported on this chip"
|
||||
msgstr "PulseOut wird auf diesem Chip nicht unterstützt"
|
||||
|
||||
#: ports/stm/common-hal/os/__init__.c
|
||||
msgid "RNG DeInit Error"
|
||||
msgstr "RNG DeInit-Fehler"
|
||||
@ -3553,9 +3566,6 @@ msgstr ""
|
||||
#~ msgid "'async for' or 'async with' outside async function"
|
||||
#~ msgstr "'async for' oder 'async with' außerhalb der asynchronen Funktion"
|
||||
|
||||
#~ msgid "PulseOut not supported on this chip"
|
||||
#~ msgstr "PulseOut wird auf diesem Chip nicht unterstützt"
|
||||
|
||||
#~ msgid "PulseIn not supported on this chip"
|
||||
#~ msgstr "PulseIn wird auf diesem Chip nicht unterstützt"
|
||||
|
||||
|
20
locale/es.po
20
locale/es.po
@ -7,7 +7,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2020-08-14 09:36-0400\n"
|
||||
"POT-Creation-Date: 2020-08-18 11:19-0400\n"
|
||||
"PO-Revision-Date: 2020-08-17 21:11+0000\n"
|
||||
"Last-Translator: Alvaro Figueroa <alvaro@greencore.co.cr>\n"
|
||||
"Language-Team: \n"
|
||||
@ -765,7 +765,7 @@ msgstr "Error en regex"
|
||||
|
||||
#: shared-bindings/aesio/aes.c shared-bindings/busio/SPI.c
|
||||
#: shared-bindings/microcontroller/Pin.c
|
||||
#: shared-bindings/neopixel_write/__init__.c shared-bindings/pulseio/PulseOut.c
|
||||
#: shared-bindings/neopixel_write/__init__.c
|
||||
#: shared-bindings/terminalio/Terminal.c
|
||||
msgid "Expected a %q"
|
||||
msgstr "Se espera un %q"
|
||||
@ -1362,6 +1362,15 @@ msgstr "Además de cualquier módulo en el sistema de archivos\n"
|
||||
msgid "Polygon needs at least 3 points"
|
||||
msgstr "El polígono necesita al menos 3 puntos"
|
||||
|
||||
#: ports/atmel-samd/common-hal/pulseio/PulseOut.c
|
||||
#: ports/cxd56/common-hal/pulseio/PulseOut.c
|
||||
#: ports/nrf/common-hal/pulseio/PulseOut.c
|
||||
#: ports/stm/common-hal/pulseio/PulseOut.c
|
||||
msgid ""
|
||||
"Port does not accept pins or frequency. "
|
||||
"Construct and pass a PWMOut Carrier instead"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/_bleio/Adapter.c
|
||||
msgid "Prefix buffer must be on the heap"
|
||||
msgstr "El búfer de prefijo debe estar en el montículo"
|
||||
@ -1375,6 +1384,10 @@ msgstr ""
|
||||
msgid "Pull not used when direction is output."
|
||||
msgstr "Pull no se usa cuando la dirección es output."
|
||||
|
||||
#: ports/stm/ref/pulseout-pre-timeralloc.c
|
||||
msgid "PulseOut not supported on this chip"
|
||||
msgstr "PulseOut no es compatible con este chip"
|
||||
|
||||
#: ports/stm/common-hal/os/__init__.c
|
||||
msgid "RNG DeInit Error"
|
||||
msgstr "Error de desinicializado del RNG"
|
||||
@ -3539,9 +3552,6 @@ msgstr "zi debe ser una forma (n_section,2)"
|
||||
#~ msgid "'async for' or 'async with' outside async function"
|
||||
#~ msgstr "'async for' o 'async with' fuera de la función async"
|
||||
|
||||
#~ msgid "PulseOut not supported on this chip"
|
||||
#~ msgstr "PulseOut no es compatible con este chip"
|
||||
|
||||
#~ msgid "PulseIn not supported on this chip"
|
||||
#~ msgstr "PulseIn no es compatible con este chip"
|
||||
|
||||
|
@ -5,7 +5,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2020-08-14 09:36-0400\n"
|
||||
"POT-Creation-Date: 2020-08-18 11:19-0400\n"
|
||||
"PO-Revision-Date: 2018-12-20 22:15-0800\n"
|
||||
"Last-Translator: Timothy <me@timothygarcia.ca>\n"
|
||||
"Language-Team: fil\n"
|
||||
@ -754,7 +754,7 @@ msgstr "May pagkakamali sa REGEX"
|
||||
|
||||
#: shared-bindings/aesio/aes.c shared-bindings/busio/SPI.c
|
||||
#: shared-bindings/microcontroller/Pin.c
|
||||
#: shared-bindings/neopixel_write/__init__.c shared-bindings/pulseio/PulseOut.c
|
||||
#: shared-bindings/neopixel_write/__init__.c
|
||||
#: shared-bindings/terminalio/Terminal.c
|
||||
msgid "Expected a %q"
|
||||
msgstr "Umasa ng %q"
|
||||
@ -1346,6 +1346,15 @@ msgstr "Kasama ang kung ano pang modules na sa filesystem\n"
|
||||
msgid "Polygon needs at least 3 points"
|
||||
msgstr ""
|
||||
|
||||
#: ports/atmel-samd/common-hal/pulseio/PulseOut.c
|
||||
#: ports/cxd56/common-hal/pulseio/PulseOut.c
|
||||
#: ports/nrf/common-hal/pulseio/PulseOut.c
|
||||
#: ports/stm/common-hal/pulseio/PulseOut.c
|
||||
msgid ""
|
||||
"Port does not accept pins or frequency. "
|
||||
"Construct and pass a PWMOut Carrier instead"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/_bleio/Adapter.c
|
||||
msgid "Prefix buffer must be on the heap"
|
||||
msgstr ""
|
||||
@ -1360,6 +1369,10 @@ msgstr ""
|
||||
msgid "Pull not used when direction is output."
|
||||
msgstr "Pull hindi ginagamit kapag ang direksyon ay output."
|
||||
|
||||
#: ports/stm/ref/pulseout-pre-timeralloc.c
|
||||
msgid "PulseOut not supported on this chip"
|
||||
msgstr ""
|
||||
|
||||
#: ports/stm/common-hal/os/__init__.c
|
||||
msgid "RNG DeInit Error"
|
||||
msgstr ""
|
||||
|
20
locale/fr.po
20
locale/fr.po
@ -7,7 +7,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: 0.1\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2020-08-14 09:36-0400\n"
|
||||
"POT-Creation-Date: 2020-08-18 11:19-0400\n"
|
||||
"PO-Revision-Date: 2020-07-27 21:27+0000\n"
|
||||
"Last-Translator: Nathan <bonnemainsnathan@gmail.com>\n"
|
||||
"Language: fr\n"
|
||||
@ -768,7 +768,7 @@ msgstr "Erreur dans l'expression régulière"
|
||||
|
||||
#: shared-bindings/aesio/aes.c shared-bindings/busio/SPI.c
|
||||
#: shared-bindings/microcontroller/Pin.c
|
||||
#: shared-bindings/neopixel_write/__init__.c shared-bindings/pulseio/PulseOut.c
|
||||
#: shared-bindings/neopixel_write/__init__.c
|
||||
#: shared-bindings/terminalio/Terminal.c
|
||||
msgid "Expected a %q"
|
||||
msgstr "Attendu un %q"
|
||||
@ -1369,6 +1369,15 @@ msgstr "Ainsi que tout autre module présent sur le système de fichiers\n"
|
||||
msgid "Polygon needs at least 3 points"
|
||||
msgstr "Polygone a besoin d’au moins 3 points"
|
||||
|
||||
#: ports/atmel-samd/common-hal/pulseio/PulseOut.c
|
||||
#: ports/cxd56/common-hal/pulseio/PulseOut.c
|
||||
#: ports/nrf/common-hal/pulseio/PulseOut.c
|
||||
#: ports/stm/common-hal/pulseio/PulseOut.c
|
||||
msgid ""
|
||||
"Port does not accept pins or frequency. "
|
||||
"Construct and pass a PWMOut Carrier instead"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/_bleio/Adapter.c
|
||||
msgid "Prefix buffer must be on the heap"
|
||||
msgstr "Le tampon de préfixe doit être sur le tas"
|
||||
@ -1381,6 +1390,10 @@ msgstr "Appuyez sur une touche pour entrer sur REPL ou CTRL-D pour recharger."
|
||||
msgid "Pull not used when direction is output."
|
||||
msgstr "Le tirage 'pull' n'est pas utilisé quand la direction est 'output'."
|
||||
|
||||
#: ports/stm/ref/pulseout-pre-timeralloc.c
|
||||
msgid "PulseOut not supported on this chip"
|
||||
msgstr "PulseOut non pris en charge sur cette puce"
|
||||
|
||||
#: ports/stm/common-hal/os/__init__.c
|
||||
msgid "RNG DeInit Error"
|
||||
msgstr "Erreur RNG DeInit"
|
||||
@ -3557,9 +3570,6 @@ msgstr ""
|
||||
#~ msgid "'async for' or 'async with' outside async function"
|
||||
#~ msgstr "'async for' ou 'async with' sans fonction asynchrone extérieure"
|
||||
|
||||
#~ msgid "PulseOut not supported on this chip"
|
||||
#~ msgstr "PulseOut non pris en charge sur cette puce"
|
||||
|
||||
#~ msgid "PulseIn not supported on this chip"
|
||||
#~ msgstr "PulseIn non pris en charge sur cette puce"
|
||||
|
||||
|
17
locale/hi.po
17
locale/hi.po
@ -7,7 +7,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2020-08-14 09:36-0400\n"
|
||||
"POT-Creation-Date: 2020-08-18 11:19-0400\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: Automatically generated\n"
|
||||
"Language-Team: none\n"
|
||||
@ -743,7 +743,7 @@ msgstr ""
|
||||
|
||||
#: shared-bindings/aesio/aes.c shared-bindings/busio/SPI.c
|
||||
#: shared-bindings/microcontroller/Pin.c
|
||||
#: shared-bindings/neopixel_write/__init__.c shared-bindings/pulseio/PulseOut.c
|
||||
#: shared-bindings/neopixel_write/__init__.c
|
||||
#: shared-bindings/terminalio/Terminal.c
|
||||
msgid "Expected a %q"
|
||||
msgstr ""
|
||||
@ -1327,6 +1327,15 @@ msgstr ""
|
||||
msgid "Polygon needs at least 3 points"
|
||||
msgstr ""
|
||||
|
||||
#: ports/atmel-samd/common-hal/pulseio/PulseOut.c
|
||||
#: ports/cxd56/common-hal/pulseio/PulseOut.c
|
||||
#: ports/nrf/common-hal/pulseio/PulseOut.c
|
||||
#: ports/stm/common-hal/pulseio/PulseOut.c
|
||||
msgid ""
|
||||
"Port does not accept pins or frequency. "
|
||||
"Construct and pass a PWMOut Carrier instead"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/_bleio/Adapter.c
|
||||
msgid "Prefix buffer must be on the heap"
|
||||
msgstr ""
|
||||
@ -1339,6 +1348,10 @@ msgstr ""
|
||||
msgid "Pull not used when direction is output."
|
||||
msgstr ""
|
||||
|
||||
#: ports/stm/ref/pulseout-pre-timeralloc.c
|
||||
msgid "PulseOut not supported on this chip"
|
||||
msgstr ""
|
||||
|
||||
#: ports/stm/common-hal/os/__init__.c
|
||||
msgid "RNG DeInit Error"
|
||||
msgstr ""
|
||||
|
@ -6,7 +6,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2020-08-14 09:36-0400\n"
|
||||
"POT-Creation-Date: 2020-08-18 11:19-0400\n"
|
||||
"PO-Revision-Date: 2018-10-02 16:27+0200\n"
|
||||
"Last-Translator: Enrico Paganin <enrico.paganin@mail.com>\n"
|
||||
"Language-Team: \n"
|
||||
@ -754,7 +754,7 @@ msgstr "Errore nella regex"
|
||||
|
||||
#: shared-bindings/aesio/aes.c shared-bindings/busio/SPI.c
|
||||
#: shared-bindings/microcontroller/Pin.c
|
||||
#: shared-bindings/neopixel_write/__init__.c shared-bindings/pulseio/PulseOut.c
|
||||
#: shared-bindings/neopixel_write/__init__.c
|
||||
#: shared-bindings/terminalio/Terminal.c
|
||||
msgid "Expected a %q"
|
||||
msgstr "Atteso un %q"
|
||||
@ -1356,6 +1356,15 @@ msgstr "Imposssibile rimontare il filesystem"
|
||||
msgid "Polygon needs at least 3 points"
|
||||
msgstr ""
|
||||
|
||||
#: ports/atmel-samd/common-hal/pulseio/PulseOut.c
|
||||
#: ports/cxd56/common-hal/pulseio/PulseOut.c
|
||||
#: ports/nrf/common-hal/pulseio/PulseOut.c
|
||||
#: ports/stm/common-hal/pulseio/PulseOut.c
|
||||
msgid ""
|
||||
"Port does not accept pins or frequency. "
|
||||
"Construct and pass a PWMOut Carrier instead"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/_bleio/Adapter.c
|
||||
msgid "Prefix buffer must be on the heap"
|
||||
msgstr ""
|
||||
@ -1369,6 +1378,10 @@ msgstr ""
|
||||
msgid "Pull not used when direction is output."
|
||||
msgstr ""
|
||||
|
||||
#: ports/stm/ref/pulseout-pre-timeralloc.c
|
||||
msgid "PulseOut not supported on this chip"
|
||||
msgstr ""
|
||||
|
||||
#: ports/stm/common-hal/os/__init__.c
|
||||
msgid "RNG DeInit Error"
|
||||
msgstr ""
|
||||
|
17
locale/ja.po
17
locale/ja.po
@ -7,7 +7,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2020-08-14 09:36-0400\n"
|
||||
"POT-Creation-Date: 2020-08-18 11:19-0400\n"
|
||||
"PO-Revision-Date: 2020-08-16 13:25+0000\n"
|
||||
"Last-Translator: Taku Fukada <naninunenor@gmail.com>\n"
|
||||
"Language-Team: none\n"
|
||||
@ -759,7 +759,7 @@ msgstr "正規表現にエラーがあります"
|
||||
|
||||
#: shared-bindings/aesio/aes.c shared-bindings/busio/SPI.c
|
||||
#: shared-bindings/microcontroller/Pin.c
|
||||
#: shared-bindings/neopixel_write/__init__.c shared-bindings/pulseio/PulseOut.c
|
||||
#: shared-bindings/neopixel_write/__init__.c
|
||||
#: shared-bindings/terminalio/Terminal.c
|
||||
msgid "Expected a %q"
|
||||
msgstr ""
|
||||
@ -1348,6 +1348,15 @@ msgstr ""
|
||||
msgid "Polygon needs at least 3 points"
|
||||
msgstr "ポリゴンには少なくとも3つの点が必要"
|
||||
|
||||
#: ports/atmel-samd/common-hal/pulseio/PulseOut.c
|
||||
#: ports/cxd56/common-hal/pulseio/PulseOut.c
|
||||
#: ports/nrf/common-hal/pulseio/PulseOut.c
|
||||
#: ports/stm/common-hal/pulseio/PulseOut.c
|
||||
msgid ""
|
||||
"Port does not accept pins or frequency. "
|
||||
"Construct and pass a PWMOut Carrier instead"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/_bleio/Adapter.c
|
||||
msgid "Prefix buffer must be on the heap"
|
||||
msgstr "Prefixバッファはヒープ上になければなりません"
|
||||
@ -1361,6 +1370,10 @@ msgstr "何らかのキーを押すとREPLに入ります。CTRL-Dでリロー
|
||||
msgid "Pull not used when direction is output."
|
||||
msgstr "方向がoutputのときpullは使われません"
|
||||
|
||||
#: ports/stm/ref/pulseout-pre-timeralloc.c
|
||||
msgid "PulseOut not supported on this chip"
|
||||
msgstr ""
|
||||
|
||||
#: ports/stm/common-hal/os/__init__.c
|
||||
msgid "RNG DeInit Error"
|
||||
msgstr "乱数生成器の解体エラー"
|
||||
|
17
locale/ko.po
17
locale/ko.po
@ -6,7 +6,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2020-08-14 09:36-0400\n"
|
||||
"POT-Creation-Date: 2020-08-18 11:19-0400\n"
|
||||
"PO-Revision-Date: 2019-05-06 14:22-0700\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
@ -746,7 +746,7 @@ msgstr "Regex에 오류가 있습니다."
|
||||
|
||||
#: shared-bindings/aesio/aes.c shared-bindings/busio/SPI.c
|
||||
#: shared-bindings/microcontroller/Pin.c
|
||||
#: shared-bindings/neopixel_write/__init__.c shared-bindings/pulseio/PulseOut.c
|
||||
#: shared-bindings/neopixel_write/__init__.c
|
||||
#: shared-bindings/terminalio/Terminal.c
|
||||
msgid "Expected a %q"
|
||||
msgstr "%q 이 예상되었습니다."
|
||||
@ -1330,6 +1330,15 @@ msgstr ""
|
||||
msgid "Polygon needs at least 3 points"
|
||||
msgstr ""
|
||||
|
||||
#: ports/atmel-samd/common-hal/pulseio/PulseOut.c
|
||||
#: ports/cxd56/common-hal/pulseio/PulseOut.c
|
||||
#: ports/nrf/common-hal/pulseio/PulseOut.c
|
||||
#: ports/stm/common-hal/pulseio/PulseOut.c
|
||||
msgid ""
|
||||
"Port does not accept pins or frequency. "
|
||||
"Construct and pass a PWMOut Carrier instead"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/_bleio/Adapter.c
|
||||
msgid "Prefix buffer must be on the heap"
|
||||
msgstr ""
|
||||
@ -1342,6 +1351,10 @@ msgstr ""
|
||||
msgid "Pull not used when direction is output."
|
||||
msgstr ""
|
||||
|
||||
#: ports/stm/ref/pulseout-pre-timeralloc.c
|
||||
msgid "PulseOut not supported on this chip"
|
||||
msgstr ""
|
||||
|
||||
#: ports/stm/common-hal/os/__init__.c
|
||||
msgid "RNG DeInit Error"
|
||||
msgstr ""
|
||||
|
20
locale/nl.po
20
locale/nl.po
@ -5,7 +5,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2020-08-14 09:36-0400\n"
|
||||
"POT-Creation-Date: 2020-08-18 11:19-0400\n"
|
||||
"PO-Revision-Date: 2020-08-10 19:59+0000\n"
|
||||
"Last-Translator: _fonzlate <vooralfred@gmail.com>\n"
|
||||
"Language-Team: none\n"
|
||||
@ -762,7 +762,7 @@ msgstr "Fout in regex"
|
||||
|
||||
#: shared-bindings/aesio/aes.c shared-bindings/busio/SPI.c
|
||||
#: shared-bindings/microcontroller/Pin.c
|
||||
#: shared-bindings/neopixel_write/__init__.c shared-bindings/pulseio/PulseOut.c
|
||||
#: shared-bindings/neopixel_write/__init__.c
|
||||
#: shared-bindings/terminalio/Terminal.c
|
||||
msgid "Expected a %q"
|
||||
msgstr "Verwacht een %q"
|
||||
@ -1364,6 +1364,15 @@ msgstr "En iedere module in het bestandssysteem\n"
|
||||
msgid "Polygon needs at least 3 points"
|
||||
msgstr "Polygon heeft op zijn minst 3 punten nodig"
|
||||
|
||||
#: ports/atmel-samd/common-hal/pulseio/PulseOut.c
|
||||
#: ports/cxd56/common-hal/pulseio/PulseOut.c
|
||||
#: ports/nrf/common-hal/pulseio/PulseOut.c
|
||||
#: ports/stm/common-hal/pulseio/PulseOut.c
|
||||
msgid ""
|
||||
"Port does not accept pins or frequency. "
|
||||
"Construct and pass a PWMOut Carrier instead"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/_bleio/Adapter.c
|
||||
msgid "Prefix buffer must be on the heap"
|
||||
msgstr "Prefix buffer moet op de heap zijn"
|
||||
@ -1378,6 +1387,10 @@ msgstr ""
|
||||
msgid "Pull not used when direction is output."
|
||||
msgstr "Pull niet gebruikt wanneer de richting output is."
|
||||
|
||||
#: ports/stm/ref/pulseout-pre-timeralloc.c
|
||||
msgid "PulseOut not supported on this chip"
|
||||
msgstr "PulseOut niet ondersteund door deze chip"
|
||||
|
||||
#: ports/stm/common-hal/os/__init__.c
|
||||
msgid "RNG DeInit Error"
|
||||
msgstr "RNG DeInit Fout"
|
||||
@ -3531,9 +3544,6 @@ msgstr "zi moet vorm (n_section, 2) hebben"
|
||||
#~ msgid "PulseIn not supported on this chip"
|
||||
#~ msgstr "PusleIn niet ondersteund door deze chip"
|
||||
|
||||
#~ msgid "PulseOut not supported on this chip"
|
||||
#~ msgstr "PulseOut niet ondersteund door deze chip"
|
||||
|
||||
#~ msgid "I2C operation not supported"
|
||||
#~ msgstr "I2C actie niet ondersteund"
|
||||
|
||||
|
17
locale/pl.po
17
locale/pl.po
@ -6,7 +6,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2020-08-14 09:36-0400\n"
|
||||
"POT-Creation-Date: 2020-08-18 11:19-0400\n"
|
||||
"PO-Revision-Date: 2019-03-19 18:37-0700\n"
|
||||
"Last-Translator: Radomir Dopieralski <circuitpython@sheep.art.pl>\n"
|
||||
"Language-Team: pl\n"
|
||||
@ -746,7 +746,7 @@ msgstr "Błąd w regex"
|
||||
|
||||
#: shared-bindings/aesio/aes.c shared-bindings/busio/SPI.c
|
||||
#: shared-bindings/microcontroller/Pin.c
|
||||
#: shared-bindings/neopixel_write/__init__.c shared-bindings/pulseio/PulseOut.c
|
||||
#: shared-bindings/neopixel_write/__init__.c
|
||||
#: shared-bindings/terminalio/Terminal.c
|
||||
msgid "Expected a %q"
|
||||
msgstr "Oczekiwano %q"
|
||||
@ -1332,6 +1332,15 @@ msgstr "Oraz moduły w systemie plików\n"
|
||||
msgid "Polygon needs at least 3 points"
|
||||
msgstr ""
|
||||
|
||||
#: ports/atmel-samd/common-hal/pulseio/PulseOut.c
|
||||
#: ports/cxd56/common-hal/pulseio/PulseOut.c
|
||||
#: ports/nrf/common-hal/pulseio/PulseOut.c
|
||||
#: ports/stm/common-hal/pulseio/PulseOut.c
|
||||
msgid ""
|
||||
"Port does not accept pins or frequency. "
|
||||
"Construct and pass a PWMOut Carrier instead"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/_bleio/Adapter.c
|
||||
msgid "Prefix buffer must be on the heap"
|
||||
msgstr ""
|
||||
@ -1344,6 +1353,10 @@ msgstr "Dowolny klawisz aby uruchomić konsolę. CTRL-D aby przeładować."
|
||||
msgid "Pull not used when direction is output."
|
||||
msgstr "Podciągnięcie nieużywane w trybie wyjścia."
|
||||
|
||||
#: ports/stm/ref/pulseout-pre-timeralloc.c
|
||||
msgid "PulseOut not supported on this chip"
|
||||
msgstr ""
|
||||
|
||||
#: ports/stm/common-hal/os/__init__.c
|
||||
msgid "RNG DeInit Error"
|
||||
msgstr ""
|
||||
|
@ -5,8 +5,8 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2020-08-14 09:36-0400\n"
|
||||
"PO-Revision-Date: 2020-08-16 02:25+0000\n"
|
||||
"POT-Creation-Date: 2020-08-18 11:19-0400\n"
|
||||
"PO-Revision-Date: 2020-08-21 18:19+0000\n"
|
||||
"Last-Translator: Wellington Terumi Uemura <wellingtonuemura@gmail.com>\n"
|
||||
"Language-Team: \n"
|
||||
"Language: pt_BR\n"
|
||||
@ -14,7 +14,7 @@ msgstr ""
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=n > 1;\n"
|
||||
"X-Generator: Weblate 4.2-dev\n"
|
||||
"X-Generator: Weblate 4.2.1-dev\n"
|
||||
|
||||
#: main.c
|
||||
msgid ""
|
||||
@ -767,7 +767,7 @@ msgstr "Erro no regex"
|
||||
|
||||
#: shared-bindings/aesio/aes.c shared-bindings/busio/SPI.c
|
||||
#: shared-bindings/microcontroller/Pin.c
|
||||
#: shared-bindings/neopixel_write/__init__.c shared-bindings/pulseio/PulseOut.c
|
||||
#: shared-bindings/neopixel_write/__init__.c
|
||||
#: shared-bindings/terminalio/Terminal.c
|
||||
msgid "Expected a %q"
|
||||
msgstr "Esperado um"
|
||||
@ -1367,6 +1367,17 @@ msgstr "Além de quaisquer módulos no sistema de arquivos\n"
|
||||
msgid "Polygon needs at least 3 points"
|
||||
msgstr "O Polígono precisa de pelo menos 3 pontos"
|
||||
|
||||
#: ports/atmel-samd/common-hal/pulseio/PulseOut.c
|
||||
#: ports/cxd56/common-hal/pulseio/PulseOut.c
|
||||
#: ports/nrf/common-hal/pulseio/PulseOut.c
|
||||
#: ports/stm/common-hal/pulseio/PulseOut.c
|
||||
msgid ""
|
||||
"Port does not accept pins or frequency. "
|
||||
"Construct and pass a PWMOut Carrier instead"
|
||||
msgstr ""
|
||||
"A porta não aceita pinos ou frequência. "
|
||||
"Em vez disso, Construa e encaminhe um PWMOut Carrier"
|
||||
|
||||
#: shared-bindings/_bleio/Adapter.c
|
||||
msgid "Prefix buffer must be on the heap"
|
||||
msgstr ""
|
||||
@ -1382,6 +1393,10 @@ msgstr ""
|
||||
msgid "Pull not used when direction is output."
|
||||
msgstr "O Pull não foi usado quando a direção for gerada."
|
||||
|
||||
#: ports/stm/ref/pulseout-pre-timeralloc.c
|
||||
msgid "PulseOut not supported on this chip"
|
||||
msgstr "O PulseOut não é compatível neste CI"
|
||||
|
||||
#: ports/stm/common-hal/os/__init__.c
|
||||
msgid "RNG DeInit Error"
|
||||
msgstr "Erro DeInit RNG"
|
||||
@ -3552,9 +3567,6 @@ msgstr "zi deve estar na forma (n_section, 2)"
|
||||
#~ msgid "'async for' or 'async with' outside async function"
|
||||
#~ msgstr "'assíncrono para' ou 'assíncrono com' função assíncrona externa"
|
||||
|
||||
#~ msgid "PulseOut not supported on this chip"
|
||||
#~ msgstr "O PulseOut não é compatível neste CI"
|
||||
|
||||
#~ msgid "PulseIn not supported on this chip"
|
||||
#~ msgstr "O PulseIn não é compatível neste CI"
|
||||
|
||||
|
20
locale/sv.po
20
locale/sv.po
@ -5,7 +5,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2020-08-14 09:36-0400\n"
|
||||
"POT-Creation-Date: 2020-08-18 11:19-0400\n"
|
||||
"PO-Revision-Date: 2020-07-25 20:58+0000\n"
|
||||
"Last-Translator: Jonny Bergdahl <jonny@bergdahl.it>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
@ -758,7 +758,7 @@ msgstr "Fel i regex"
|
||||
|
||||
#: shared-bindings/aesio/aes.c shared-bindings/busio/SPI.c
|
||||
#: shared-bindings/microcontroller/Pin.c
|
||||
#: shared-bindings/neopixel_write/__init__.c shared-bindings/pulseio/PulseOut.c
|
||||
#: shared-bindings/neopixel_write/__init__.c
|
||||
#: shared-bindings/terminalio/Terminal.c
|
||||
msgid "Expected a %q"
|
||||
msgstr "Förväntade %q"
|
||||
@ -1355,6 +1355,15 @@ msgstr "Plus eventuella moduler i filsystemet\n"
|
||||
msgid "Polygon needs at least 3 points"
|
||||
msgstr "Polygonen behöver minst 3 punkter"
|
||||
|
||||
#: ports/atmel-samd/common-hal/pulseio/PulseOut.c
|
||||
#: ports/cxd56/common-hal/pulseio/PulseOut.c
|
||||
#: ports/nrf/common-hal/pulseio/PulseOut.c
|
||||
#: ports/stm/common-hal/pulseio/PulseOut.c
|
||||
msgid ""
|
||||
"Port does not accept pins or frequency. "
|
||||
"Construct and pass a PWMOut Carrier instead"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/_bleio/Adapter.c
|
||||
msgid "Prefix buffer must be on the heap"
|
||||
msgstr "Prefixbufferten måste finnas på heap"
|
||||
@ -1368,6 +1377,10 @@ msgstr ""
|
||||
msgid "Pull not used when direction is output."
|
||||
msgstr "Pull används inte när riktningen är output."
|
||||
|
||||
#: ports/stm/ref/pulseout-pre-timeralloc.c
|
||||
msgid "PulseOut not supported on this chip"
|
||||
msgstr "PulseIn stöds inte av detta chip"
|
||||
|
||||
#: ports/stm/common-hal/os/__init__.c
|
||||
msgid "RNG DeInit Error"
|
||||
msgstr "RNG DeInit-fel"
|
||||
@ -3519,9 +3532,6 @@ msgstr "zi måste vara i formen (n_section, 2)"
|
||||
#~ msgid "'async for' or 'async with' outside async function"
|
||||
#~ msgstr "'async for' eller 'async with' utanför async-funktion"
|
||||
|
||||
#~ msgid "PulseOut not supported on this chip"
|
||||
#~ msgstr "PulseIn stöds inte av detta chip"
|
||||
|
||||
#~ msgid "PulseIn not supported on this chip"
|
||||
#~ msgstr "PulseIn stöds inte av detta chip"
|
||||
|
||||
|
@ -6,7 +6,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: circuitpython-cn\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2020-08-14 09:36-0400\n"
|
||||
"POT-Creation-Date: 2020-08-18 11:19-0400\n"
|
||||
"PO-Revision-Date: 2019-04-13 10:10-0700\n"
|
||||
"Last-Translator: hexthat\n"
|
||||
"Language-Team: Chinese Hanyu Pinyin\n"
|
||||
@ -755,7 +755,7 @@ msgstr "Zhèngzé biǎodá shì cuòwù"
|
||||
|
||||
#: shared-bindings/aesio/aes.c shared-bindings/busio/SPI.c
|
||||
#: shared-bindings/microcontroller/Pin.c
|
||||
#: shared-bindings/neopixel_write/__init__.c shared-bindings/pulseio/PulseOut.c
|
||||
#: shared-bindings/neopixel_write/__init__.c
|
||||
#: shared-bindings/terminalio/Terminal.c
|
||||
msgid "Expected a %q"
|
||||
msgstr "Yùqí %q"
|
||||
@ -1350,6 +1350,15 @@ msgstr "Zài wénjiàn xìtǒng shàng tiānjiā rènhé mókuài\n"
|
||||
msgid "Polygon needs at least 3 points"
|
||||
msgstr "Duōbiānxíng zhìshǎo xūyào 3 diǎn"
|
||||
|
||||
#: ports/atmel-samd/common-hal/pulseio/PulseOut.c
|
||||
#: ports/cxd56/common-hal/pulseio/PulseOut.c
|
||||
#: ports/nrf/common-hal/pulseio/PulseOut.c
|
||||
#: ports/stm/common-hal/pulseio/PulseOut.c
|
||||
msgid ""
|
||||
"Port does not accept pins or frequency. "
|
||||
"Construct and pass a PWMOut Carrier instead"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/_bleio/Adapter.c
|
||||
msgid "Prefix buffer must be on the heap"
|
||||
msgstr "Qiánzhuì huǎnchōng qū bìxū zài duī shàng"
|
||||
@ -1362,6 +1371,10 @@ msgstr "Àn xià rènhé jiàn jìnrù REPL. Shǐyòng CTRL-D chóngxīn jiāzà
|
||||
msgid "Pull not used when direction is output."
|
||||
msgstr "Fāngxiàng shūchū shí Pull méiyǒu shǐyòng."
|
||||
|
||||
#: ports/stm/ref/pulseout-pre-timeralloc.c
|
||||
msgid "PulseOut not supported on this chip"
|
||||
msgstr ""
|
||||
|
||||
#: ports/stm/common-hal/os/__init__.c
|
||||
msgid "RNG DeInit Error"
|
||||
msgstr "RNG qǔxiāo chūshǐhuà cuòwù"
|
||||
|
@ -103,7 +103,7 @@ ifeq ($(CHIP_FAMILY), same54)
|
||||
PERIPHERALS_CHIP_FAMILY=sam_d5x_e5x
|
||||
OPTIMIZATION_FLAGS ?= -O2
|
||||
# TinyUSB defines
|
||||
CFLAGS += -DCFG_TUSB_MCU=OPT_MCU_SAMD51 -DCFG_TUD_MIDI_RX_BUFSIZE=128 -DCFG_TUD_CDC_RX_BUFSIZE=256 -DCFG_TUD_MIDI_TX_BUFSIZE=128 -DCFG_TUD_CDC_TX_BUFSIZE=256 -DCFG_TUD_MSC_BUFSIZE=1024
|
||||
CFLAGS += -DCFG_TUSB_MCU=OPT_MCU_SAME5X -DCFG_TUD_MIDI_RX_BUFSIZE=128 -DCFG_TUD_CDC_RX_BUFSIZE=256 -DCFG_TUD_MIDI_TX_BUFSIZE=128 -DCFG_TUD_CDC_TX_BUFSIZE=256 -DCFG_TUD_MSC_BUFSIZE=1024
|
||||
endif
|
||||
|
||||
# option to override default optimization level, set in boards/$(BOARD)/mpconfigboard.mk
|
||||
|
@ -7,8 +7,8 @@ CHIP_VARIANT = SAMD51G19A
|
||||
CHIP_FAMILY = samd51
|
||||
|
||||
QSPI_FLASH_FILESYSTEM = 1
|
||||
EXTERNAL_FLASH_DEVICE_COUNT = 1
|
||||
EXTERNAL_FLASH_DEVICES = "W25Q16JV_IM"
|
||||
EXTERNAL_FLASH_DEVICE_COUNT = 2
|
||||
EXTERNAL_FLASH_DEVICES = "W25Q16JV_IM, W25Q16JV_IQ"
|
||||
LONGINT_IMPL = MPZ
|
||||
|
||||
# No I2S on SAMD51G
|
||||
|
@ -32,7 +32,7 @@
|
||||
#include "shared-bindings/nvm/ByteArray.h"
|
||||
#include "common-hal/microcontroller/Pin.h"
|
||||
#include "hal/include/hal_gpio.h"
|
||||
#include "shared-bindings/pulseio/PWMOut.h"
|
||||
#include "shared-bindings/pwmio/PWMOut.h"
|
||||
|
||||
nvm_bytearray_obj_t bootcnt = {
|
||||
.base = {
|
||||
@ -44,9 +44,9 @@ nvm_bytearray_obj_t bootcnt = {
|
||||
|
||||
|
||||
void board_init(void) {
|
||||
pulseio_pwmout_obj_t pwm;
|
||||
common_hal_pulseio_pwmout_construct(&pwm, &pin_PA23, 4096, 2, false);
|
||||
common_hal_pulseio_pwmout_never_reset(&pwm);
|
||||
pwmio_pwmout_obj_t pwm;
|
||||
common_hal_pwmio_pwmout_construct(&pwm, &pin_PA23, 4096, 2, false);
|
||||
common_hal_pwmio_pwmout_never_reset(&pwm);
|
||||
}
|
||||
|
||||
bool board_requests_safe_mode(void) {
|
||||
|
@ -32,7 +32,7 @@
|
||||
#include "shared-bindings/nvm/ByteArray.h"
|
||||
#include "common-hal/microcontroller/Pin.h"
|
||||
#include "hal/include/hal_gpio.h"
|
||||
#include "shared-bindings/pulseio/PWMOut.h"
|
||||
#include "shared-bindings/pwmio/PWMOut.h"
|
||||
|
||||
nvm_bytearray_obj_t bootcnt = {
|
||||
.base = {
|
||||
@ -44,9 +44,9 @@ nvm_bytearray_obj_t bootcnt = {
|
||||
|
||||
|
||||
void board_init(void) {
|
||||
pulseio_pwmout_obj_t pwm;
|
||||
common_hal_pulseio_pwmout_construct(&pwm, &pin_PA23, 4096, 2, false);
|
||||
common_hal_pulseio_pwmout_never_reset(&pwm);
|
||||
pwmio_pwmout_obj_t pwm;
|
||||
common_hal_pwmio_pwmout_construct(&pwm, &pin_PA23, 4096, 2, false);
|
||||
common_hal_pwmio_pwmout_never_reset(&pwm);
|
||||
}
|
||||
|
||||
bool board_requests_safe_mode(void) {
|
||||
|
@ -96,7 +96,15 @@ void pulseout_reset() {
|
||||
}
|
||||
|
||||
void common_hal_pulseio_pulseout_construct(pulseio_pulseout_obj_t* self,
|
||||
const pulseio_pwmout_obj_t* carrier) {
|
||||
const pwmio_pwmout_obj_t* carrier,
|
||||
const mcu_pin_obj_t* pin,
|
||||
uint32_t frequency,
|
||||
uint16_t duty_cycle) {
|
||||
if (!carrier || pin || frequency) {
|
||||
mp_raise_NotImplementedError(translate("Port does not accept pins or frequency. \
|
||||
Construct and pass a PWMOut Carrier instead"));
|
||||
}
|
||||
|
||||
if (refcount == 0) {
|
||||
// Find a spare timer.
|
||||
Tc *tc = NULL;
|
||||
|
@ -28,8 +28,8 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include "py/runtime.h"
|
||||
#include "common-hal/pulseio/PWMOut.h"
|
||||
#include "shared-bindings/pulseio/PWMOut.h"
|
||||
#include "common-hal/pwmio/PWMOut.h"
|
||||
#include "shared-bindings/pwmio/PWMOut.h"
|
||||
#include "shared-bindings/microcontroller/Processor.h"
|
||||
#include "timer_handler.h"
|
||||
|
||||
@ -78,13 +78,13 @@ void timer_reset_ok(int index, bool is_tc) {
|
||||
}
|
||||
|
||||
|
||||
void common_hal_pulseio_pwmout_never_reset(pulseio_pwmout_obj_t *self) {
|
||||
void common_hal_pwmio_pwmout_never_reset(pwmio_pwmout_obj_t *self) {
|
||||
timer_never_reset(self->timer->index, self->timer->is_tc);
|
||||
|
||||
never_reset_pin_number(self->pin->number);
|
||||
}
|
||||
|
||||
void common_hal_pulseio_pwmout_reset_ok(pulseio_pwmout_obj_t *self) {
|
||||
void common_hal_pwmio_pwmout_reset_ok(pwmio_pwmout_obj_t *self) {
|
||||
timer_reset_ok(self->timer->index, self->timer->is_tc);
|
||||
}
|
||||
|
||||
@ -137,7 +137,7 @@ bool channel_ok(const pin_timer_t* t) {
|
||||
t->is_tc;
|
||||
}
|
||||
|
||||
pwmout_result_t common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self,
|
||||
pwmout_result_t common_hal_pwmio_pwmout_construct(pwmio_pwmout_obj_t* self,
|
||||
const mcu_pin_obj_t* pin,
|
||||
uint16_t duty,
|
||||
uint32_t frequency,
|
||||
@ -296,16 +296,16 @@ pwmout_result_t common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self,
|
||||
|
||||
gpio_set_pin_function(pin->number, GPIO_PIN_FUNCTION_E + mux_position);
|
||||
|
||||
common_hal_pulseio_pwmout_set_duty_cycle(self, duty);
|
||||
common_hal_pwmio_pwmout_set_duty_cycle(self, duty);
|
||||
return PWMOUT_OK;
|
||||
}
|
||||
|
||||
bool common_hal_pulseio_pwmout_deinited(pulseio_pwmout_obj_t* self) {
|
||||
bool common_hal_pwmio_pwmout_deinited(pwmio_pwmout_obj_t* self) {
|
||||
return self->pin == NULL;
|
||||
}
|
||||
|
||||
void common_hal_pulseio_pwmout_deinit(pulseio_pwmout_obj_t* self) {
|
||||
if (common_hal_pulseio_pwmout_deinited(self)) {
|
||||
void common_hal_pwmio_pwmout_deinit(pwmio_pwmout_obj_t* self) {
|
||||
if (common_hal_pwmio_pwmout_deinited(self)) {
|
||||
return;
|
||||
}
|
||||
const pin_timer_t* t = self->timer;
|
||||
@ -331,7 +331,7 @@ void common_hal_pulseio_pwmout_deinit(pulseio_pwmout_obj_t* self) {
|
||||
self->pin = NULL;
|
||||
}
|
||||
|
||||
extern void common_hal_pulseio_pwmout_set_duty_cycle(pulseio_pwmout_obj_t* self, uint16_t duty) {
|
||||
extern void common_hal_pwmio_pwmout_set_duty_cycle(pwmio_pwmout_obj_t* self, uint16_t duty) {
|
||||
// Store the unadjusted duty cycle. It turns out the the process of adjusting and calculating
|
||||
// the duty cycle here and reading it back is lossy - the value will decay over time.
|
||||
// Track it here so that if frequency is changed we can use this value to recalculate the
|
||||
@ -373,7 +373,7 @@ extern void common_hal_pulseio_pwmout_set_duty_cycle(pulseio_pwmout_obj_t* self,
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t common_hal_pulseio_pwmout_get_duty_cycle(pulseio_pwmout_obj_t* self) {
|
||||
uint16_t common_hal_pwmio_pwmout_get_duty_cycle(pwmio_pwmout_obj_t* self) {
|
||||
const pin_timer_t* t = self->timer;
|
||||
if (t->is_tc) {
|
||||
Tc* tc = tc_insts[t->index];
|
||||
@ -411,7 +411,7 @@ uint16_t common_hal_pulseio_pwmout_get_duty_cycle(pulseio_pwmout_obj_t* self) {
|
||||
}
|
||||
|
||||
|
||||
void common_hal_pulseio_pwmout_set_frequency(pulseio_pwmout_obj_t* self,
|
||||
void common_hal_pwmio_pwmout_set_frequency(pwmio_pwmout_obj_t* self,
|
||||
uint32_t frequency) {
|
||||
if (frequency == 0 || frequency > 6000000) {
|
||||
mp_raise_ValueError(translate("Invalid PWM frequency"));
|
||||
@ -466,10 +466,10 @@ void common_hal_pulseio_pwmout_set_frequency(pulseio_pwmout_obj_t* self,
|
||||
#endif
|
||||
}
|
||||
|
||||
common_hal_pulseio_pwmout_set_duty_cycle(self, self->duty_cycle);
|
||||
common_hal_pwmio_pwmout_set_duty_cycle(self, self->duty_cycle);
|
||||
}
|
||||
|
||||
uint32_t common_hal_pulseio_pwmout_get_frequency(pulseio_pwmout_obj_t* self) {
|
||||
uint32_t common_hal_pwmio_pwmout_get_frequency(pwmio_pwmout_obj_t* self) {
|
||||
uint32_t system_clock = common_hal_mcu_processor_get_frequency();
|
||||
const pin_timer_t* t = self->timer;
|
||||
uint8_t divisor;
|
||||
@ -484,6 +484,6 @@ uint32_t common_hal_pulseio_pwmout_get_frequency(pulseio_pwmout_obj_t* self) {
|
||||
return (system_clock / prescaler[divisor]) / (top + 1);
|
||||
}
|
||||
|
||||
bool common_hal_pulseio_pwmout_get_variable_frequency(pulseio_pwmout_obj_t* self) {
|
||||
bool common_hal_pwmio_pwmout_get_variable_frequency(pwmio_pwmout_obj_t* self) {
|
||||
return self->variable_frequency;
|
||||
}
|
@ -24,8 +24,8 @@
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_PULSEIO_PWMOUT_H
|
||||
#define MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_PULSEIO_PWMOUT_H
|
||||
#ifndef MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_PWMIO_PWMOUT_H
|
||||
#define MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_PWMIO_PWMOUT_H
|
||||
|
||||
#include "common-hal/microcontroller/Pin.h"
|
||||
|
||||
@ -37,8 +37,8 @@ typedef struct {
|
||||
const pin_timer_t* timer;
|
||||
bool variable_frequency;
|
||||
uint16_t duty_cycle;
|
||||
} pulseio_pwmout_obj_t;
|
||||
} pwmio_pwmout_obj_t;
|
||||
|
||||
void pwmout_reset(void);
|
||||
|
||||
#endif // MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_PULSEIO_PWMOUT_H
|
||||
#endif // MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_PWMIO_PWMOUT_H
|
1
ports/atmel-samd/common-hal/pwmio/__init__.c
Normal file
1
ports/atmel-samd/common-hal/pwmio/__init__.c
Normal file
@ -0,0 +1 @@
|
||||
// No pwmio module functions.
|
@ -91,3 +91,5 @@ endif # samd51
|
||||
INTERNAL_LIBM = 1
|
||||
|
||||
USB_SERIAL_NUMBER_LENGTH = 32
|
||||
|
||||
USB_NUM_EP = 8
|
||||
|
@ -59,7 +59,7 @@
|
||||
#include "common-hal/microcontroller/Pin.h"
|
||||
#include "common-hal/pulseio/PulseIn.h"
|
||||
#include "common-hal/pulseio/PulseOut.h"
|
||||
#include "common-hal/pulseio/PWMOut.h"
|
||||
#include "common-hal/pwmio/PWMOut.h"
|
||||
#include "common-hal/ps2io/Ps2.h"
|
||||
#include "common-hal/rtc/RTC.h"
|
||||
|
||||
@ -335,6 +335,8 @@ void reset_port(void) {
|
||||
#if CIRCUITPY_PULSEIO
|
||||
pulsein_reset();
|
||||
pulseout_reset();
|
||||
#endif
|
||||
#if CIRCUITPY_PWMIO
|
||||
pwmout_reset();
|
||||
#endif
|
||||
|
||||
|
@ -35,6 +35,6 @@ typedef struct {
|
||||
mp_obj_base_t base;
|
||||
} mcu_processor_obj_t;
|
||||
|
||||
const mp_obj_type_t mcu_processor_type;
|
||||
extern const mp_obj_type_t mcu_processor_type;
|
||||
|
||||
#endif // MICROPY_INCLUDED_CXD56_COMMON_HAL_MICROCONTROLLER_PROCESSOR_H
|
||||
|
@ -58,8 +58,16 @@ static bool pulseout_timer_handler(unsigned int *next_interval_us, void *arg)
|
||||
return true;
|
||||
}
|
||||
|
||||
void common_hal_pulseio_pulseout_construct(pulseio_pulseout_obj_t *self,
|
||||
const pulseio_pwmout_obj_t *carrier) {
|
||||
void common_hal_pulseio_pulseout_construct(pulseio_pulseout_obj_t* self,
|
||||
const pwmio_pwmout_obj_t* carrier,
|
||||
const mcu_pin_obj_t* pin,
|
||||
uint32_t frequency,
|
||||
uint16_t duty_cycle) {
|
||||
if (!carrier || pin || frequency) {
|
||||
mp_raise_NotImplementedError(translate("Port does not accept pins or frequency. \
|
||||
Construct and pass a PWMOut Carrier instead"));
|
||||
}
|
||||
|
||||
if (pulse_fd < 0) {
|
||||
pulse_fd = open("/dev/timer0", O_RDONLY);
|
||||
}
|
||||
|
@ -30,7 +30,7 @@
|
||||
|
||||
#include "py/runtime.h"
|
||||
|
||||
#include "shared-bindings/pulseio/PWMOut.h"
|
||||
#include "shared-bindings/pwmio/PWMOut.h"
|
||||
|
||||
typedef struct {
|
||||
const char* devpath;
|
||||
@ -46,7 +46,7 @@ STATIC pwmout_dev_t pwmout_dev[] = {
|
||||
{"/dev/pwm3", &pin_PWM3, -1, true}
|
||||
};
|
||||
|
||||
pwmout_result_t common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t *self,
|
||||
pwmout_result_t common_hal_pwmio_pwmout_construct(pwmio_pwmout_obj_t *self,
|
||||
const mcu_pin_obj_t *pin, uint16_t duty, uint32_t frequency,
|
||||
bool variable_frequency) {
|
||||
self->number = -1;
|
||||
@ -85,8 +85,8 @@ pwmout_result_t common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t *self,
|
||||
return PWMOUT_OK;
|
||||
}
|
||||
|
||||
void common_hal_pulseio_pwmout_deinit(pulseio_pwmout_obj_t *self) {
|
||||
if (common_hal_pulseio_pwmout_deinited(self)) {
|
||||
void common_hal_pwmio_pwmout_deinit(pwmio_pwmout_obj_t *self) {
|
||||
if (common_hal_pwmio_pwmout_deinited(self)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -98,21 +98,21 @@ void common_hal_pulseio_pwmout_deinit(pulseio_pwmout_obj_t *self) {
|
||||
self->pin = NULL;
|
||||
}
|
||||
|
||||
bool common_hal_pulseio_pwmout_deinited(pulseio_pwmout_obj_t *self) {
|
||||
bool common_hal_pwmio_pwmout_deinited(pwmio_pwmout_obj_t *self) {
|
||||
return pwmout_dev[self->number].fd < 0;
|
||||
}
|
||||
|
||||
void common_hal_pulseio_pwmout_set_duty_cycle(pulseio_pwmout_obj_t *self, uint16_t duty) {
|
||||
void common_hal_pwmio_pwmout_set_duty_cycle(pwmio_pwmout_obj_t *self, uint16_t duty) {
|
||||
self->info.duty = duty;
|
||||
|
||||
ioctl(pwmout_dev[self->number].fd, PWMIOC_SETCHARACTERISTICS, (unsigned long)((uintptr_t)&self->info));
|
||||
}
|
||||
|
||||
uint16_t common_hal_pulseio_pwmout_get_duty_cycle(pulseio_pwmout_obj_t *self) {
|
||||
uint16_t common_hal_pwmio_pwmout_get_duty_cycle(pwmio_pwmout_obj_t *self) {
|
||||
return self->info.duty;
|
||||
}
|
||||
|
||||
void common_hal_pulseio_pwmout_set_frequency(pulseio_pwmout_obj_t *self, uint32_t frequency) {
|
||||
void common_hal_pwmio_pwmout_set_frequency(pwmio_pwmout_obj_t *self, uint32_t frequency) {
|
||||
self->info.frequency = frequency;
|
||||
|
||||
if (ioctl(pwmout_dev[self->number].fd, PWMIOC_SETCHARACTERISTICS, (unsigned long)((uintptr_t)&self->info)) < 0) {
|
||||
@ -120,21 +120,21 @@ void common_hal_pulseio_pwmout_set_frequency(pulseio_pwmout_obj_t *self, uint32_
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t common_hal_pulseio_pwmout_get_frequency(pulseio_pwmout_obj_t *self) {
|
||||
uint32_t common_hal_pwmio_pwmout_get_frequency(pwmio_pwmout_obj_t *self) {
|
||||
return self->info.frequency;
|
||||
}
|
||||
|
||||
bool common_hal_pulseio_pwmout_get_variable_frequency(pulseio_pwmout_obj_t *self) {
|
||||
bool common_hal_pwmio_pwmout_get_variable_frequency(pwmio_pwmout_obj_t *self) {
|
||||
return self->variable_frequency;
|
||||
}
|
||||
|
||||
void common_hal_pulseio_pwmout_never_reset(pulseio_pwmout_obj_t *self) {
|
||||
void common_hal_pwmio_pwmout_never_reset(pwmio_pwmout_obj_t *self) {
|
||||
never_reset_pin_number(self->pin->number);
|
||||
|
||||
pwmout_dev[self->number].reset = false;
|
||||
}
|
||||
|
||||
void common_hal_pulseio_pwmout_reset_ok(pulseio_pwmout_obj_t *self) {
|
||||
void common_hal_pwmio_pwmout_reset_ok(pwmio_pwmout_obj_t *self) {
|
||||
pwmout_dev[self->number].reset = true;
|
||||
}
|
||||
|
@ -24,8 +24,8 @@
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef MICROPY_INCLUDED_CXD56_COMMON_HAL_PULSEIO_PWMOUT_H
|
||||
#define MICROPY_INCLUDED_CXD56_COMMON_HAL_PULSEIO_PWMOUT_H
|
||||
#ifndef MICROPY_INCLUDED_CXD56_COMMON_HAL_PWMIO_PWMOUT_H
|
||||
#define MICROPY_INCLUDED_CXD56_COMMON_HAL_PWMIO_PWMOUT_H
|
||||
|
||||
#include <nuttx/timers/pwm.h>
|
||||
|
||||
@ -39,10 +39,10 @@ typedef struct {
|
||||
struct pwm_info_s info;
|
||||
bool variable_frequency;
|
||||
int8_t number;
|
||||
} pulseio_pwmout_obj_t;
|
||||
} pwmio_pwmout_obj_t;
|
||||
|
||||
void pwmout_reset(void);
|
||||
void pwmout_start(uint8_t pwm_num);
|
||||
void pwmout_stop(uint8_t pwm_num);
|
||||
|
||||
#endif // MICROPY_INCLUDED_CXD56_COMMON_HAL_PULSEIO_PWMOUT_H
|
||||
#endif // MICROPY_INCLUDED_CXD56_COMMON_HAL_PWMIO_PWMOUT_H
|
1
ports/cxd56/common-hal/pwmio/__init__.c
Normal file
1
ports/cxd56/common-hal/pwmio/__init__.c
Normal file
@ -0,0 +1 @@
|
||||
// No pwmio module functions.
|
@ -36,12 +36,14 @@
|
||||
#include "boards/board.h"
|
||||
|
||||
#include "supervisor/port.h"
|
||||
#include "supervisor/background_callback.h"
|
||||
#include "supervisor/usb.h"
|
||||
#include "supervisor/shared/tick.h"
|
||||
|
||||
#include "common-hal/microcontroller/Pin.h"
|
||||
#include "common-hal/analogio/AnalogIn.h"
|
||||
#include "common-hal/pulseio/PulseOut.h"
|
||||
#include "common-hal/pulseio/PWMOut.h"
|
||||
#include "common-hal/pwmio/PWMOut.h"
|
||||
#include "common-hal/busio/UART.h"
|
||||
|
||||
safe_mode_t port_init(void) {
|
||||
@ -67,6 +69,8 @@ void reset_port(void) {
|
||||
#endif
|
||||
#if CIRCUITPY_PULSEIO
|
||||
pulseout_reset();
|
||||
#endif
|
||||
#if CIRCUITPY_PWMIO
|
||||
pwmout_reset();
|
||||
#endif
|
||||
#if CIRCUITPY_BUSIO
|
||||
@ -114,6 +118,11 @@ uint32_t port_get_saved_word(void) {
|
||||
return _ebss;
|
||||
}
|
||||
|
||||
static background_callback_t callback;
|
||||
static void usb_background_do(void* unused) {
|
||||
usb_background();
|
||||
}
|
||||
|
||||
volatile bool _tick_enabled;
|
||||
void board_timerhook(void)
|
||||
{
|
||||
@ -121,6 +130,8 @@ void board_timerhook(void)
|
||||
if (_tick_enabled) {
|
||||
supervisor_tick();
|
||||
}
|
||||
|
||||
background_callback_add(&callback, usb_background_do, NULL);
|
||||
}
|
||||
|
||||
uint64_t port_get_raw_ticks(uint8_t* subticks) {
|
||||
|
@ -35,10 +35,17 @@
|
||||
#include "shared-module/displayio/__init__.h"
|
||||
#endif
|
||||
|
||||
#if CIRCUITPY_PULSEIO
|
||||
#include "common-hal/pulseio/PulseIn.h"
|
||||
#endif
|
||||
|
||||
|
||||
void port_background_task(void) {
|
||||
// Zero delay in case FreeRTOS wants to switch to something else.
|
||||
vTaskDelay(0);
|
||||
#if CIRCUITPY_PULSEIO
|
||||
pulsein_background();
|
||||
#endif
|
||||
}
|
||||
|
||||
void port_start_background_task(void) {}
|
||||
|
@ -93,6 +93,9 @@ void common_hal_neopixel_write (const digitalio_digitalinout_obj_t* digitalinout
|
||||
// Reserve channel
|
||||
uint8_t number = digitalinout->pin->number;
|
||||
rmt_channel_t channel = esp32s2_peripherals_find_and_reserve_rmt();
|
||||
if (channel == RMT_CHANNEL_MAX) {
|
||||
mp_raise_RuntimeError(translate("All timers in use"));
|
||||
}
|
||||
|
||||
// Configure Channel
|
||||
rmt_config_t config = RMT_DEFAULT_CONFIG_TX(number, channel);
|
||||
|
@ -25,51 +25,184 @@
|
||||
*/
|
||||
|
||||
#include "common-hal/pulseio/PulseIn.h"
|
||||
#include "shared-bindings/microcontroller/__init__.h"
|
||||
#include "py/runtime.h"
|
||||
|
||||
// STATIC void pulsein_handler(uint8_t num) {
|
||||
// }
|
||||
STATIC uint8_t refcount = 0;
|
||||
STATIC pulseio_pulsein_obj_t * handles[RMT_CHANNEL_MAX];
|
||||
|
||||
// Requires rmt.c void esp32s2_peripherals_reset_all(void) to reset
|
||||
|
||||
STATIC void update_internal_buffer(pulseio_pulsein_obj_t* self) {
|
||||
uint32_t length = 0;
|
||||
rmt_item32_t *items = (rmt_item32_t *) xRingbufferReceive(self->buf_handle, &length, 0);
|
||||
if (items) {
|
||||
length /= 4;
|
||||
for (size_t i=0; i < length; i++) {
|
||||
uint16_t pos = (self->start + self->len) % self->maxlen;
|
||||
self->buffer[pos] = items[i].duration0 * 3;
|
||||
// Check if second item exists before incrementing
|
||||
if (items[i].duration1) {
|
||||
self->buffer[pos+1] = items[i].duration1 * 3;
|
||||
if (self->len < (self->maxlen - 1)) {
|
||||
self->len += 2;
|
||||
} else {
|
||||
self->start += 2;
|
||||
}
|
||||
} else {
|
||||
if (self->len < self->maxlen) {
|
||||
self->len++;
|
||||
} else {
|
||||
self->start++;
|
||||
}
|
||||
}
|
||||
}
|
||||
vRingbufferReturnItem(self->buf_handle, (void *) items);
|
||||
}
|
||||
}
|
||||
|
||||
// We can't access the RMT interrupt, so we need a global service to prevent
|
||||
// the ringbuffer from overflowing and crashing the peripheral
|
||||
void pulsein_background(void) {
|
||||
for (size_t i = 0; i < RMT_CHANNEL_MAX; i++) {
|
||||
if (handles[i]) {
|
||||
update_internal_buffer(handles[i]);
|
||||
UBaseType_t items_waiting;
|
||||
vRingbufferGetInfo(handles[i]->buf_handle, NULL, NULL, NULL, NULL, &items_waiting);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void pulsein_reset(void) {
|
||||
for (size_t i = 0; i < RMT_CHANNEL_MAX; i++) {
|
||||
handles[i] = NULL;
|
||||
}
|
||||
supervisor_disable_tick();
|
||||
refcount = 0;
|
||||
}
|
||||
|
||||
void common_hal_pulseio_pulsein_construct(pulseio_pulsein_obj_t* self, const mcu_pin_obj_t* pin,
|
||||
uint16_t maxlen, bool idle_state) {
|
||||
mp_raise_NotImplementedError(translate("PulseIn not supported on this chip"));
|
||||
self->buffer = (uint16_t *) m_malloc(maxlen * sizeof(uint16_t), false);
|
||||
if (self->buffer == NULL) {
|
||||
mp_raise_msg_varg(&mp_type_MemoryError, translate("Failed to allocate RX buffer of %d bytes"), maxlen * sizeof(uint16_t));
|
||||
}
|
||||
self->pin = pin;
|
||||
self->maxlen = maxlen;
|
||||
self->idle_state = idle_state;
|
||||
self->start = 0;
|
||||
self->len = 0;
|
||||
self->paused = false;
|
||||
|
||||
// Set pull settings
|
||||
gpio_pullup_dis(pin->number);
|
||||
gpio_pulldown_dis(pin->number);
|
||||
if (idle_state) {
|
||||
gpio_pullup_en(pin->number);
|
||||
} else {
|
||||
gpio_pulldown_en(pin->number);
|
||||
}
|
||||
|
||||
// Find a free RMT Channel and configure it
|
||||
rmt_channel_t channel = esp32s2_peripherals_find_and_reserve_rmt();
|
||||
if (channel == RMT_CHANNEL_MAX) {
|
||||
mp_raise_RuntimeError(translate("All timers in use"));
|
||||
}
|
||||
rmt_config_t config = RMT_DEFAULT_CONFIG_RX(pin->number, channel);
|
||||
config.rx_config.filter_en = true;
|
||||
config.rx_config.idle_threshold = 30000; // 30*3=90ms idle required to register a sequence
|
||||
config.clk_div = 240; // All measurements are divided by 3 to accomodate 65ms pulses
|
||||
rmt_config(&config);
|
||||
rmt_driver_install(channel, 1000, 0); //TODO: pick a more specific buffer size?
|
||||
|
||||
// Store this object and the buffer handle for background updates
|
||||
self->channel = channel;
|
||||
handles[channel] = self;
|
||||
rmt_get_ringbuf_handle(channel, &(self->buf_handle));
|
||||
|
||||
// start RMT RX, and enable ticks so the core doesn't turn off.
|
||||
rmt_rx_start(channel, true);
|
||||
supervisor_enable_tick();
|
||||
refcount++;
|
||||
}
|
||||
|
||||
bool common_hal_pulseio_pulsein_deinited(pulseio_pulsein_obj_t* self) {
|
||||
return false;
|
||||
return handles[self->channel] ? false : true;
|
||||
}
|
||||
|
||||
void common_hal_pulseio_pulsein_deinit(pulseio_pulsein_obj_t* self) {
|
||||
handles[self->channel] = NULL;
|
||||
esp32s2_peripherals_free_rmt(self->channel);
|
||||
reset_pin_number(self->pin->number);
|
||||
refcount--;
|
||||
if (refcount == 0) {
|
||||
supervisor_disable_tick();
|
||||
}
|
||||
}
|
||||
|
||||
void common_hal_pulseio_pulsein_pause(pulseio_pulsein_obj_t* self) {
|
||||
self->paused = true;
|
||||
rmt_rx_stop(self->channel);
|
||||
}
|
||||
|
||||
void common_hal_pulseio_pulsein_resume(pulseio_pulsein_obj_t* self, uint16_t trigger_duration) {
|
||||
// Make sure we're paused.
|
||||
if ( !self->paused ) {
|
||||
common_hal_pulseio_pulsein_pause(self);
|
||||
}
|
||||
|
||||
if (trigger_duration > 0) {
|
||||
gpio_set_direction(self->pin->number, GPIO_MODE_DEF_OUTPUT);
|
||||
gpio_set_level(self->pin->number, !self->idle_state);
|
||||
common_hal_mcu_delay_us((uint32_t)trigger_duration);
|
||||
gpio_set_level(self->pin->number, self->idle_state);
|
||||
gpio_set_direction(self->pin->number, GPIO_MODE_INPUT); // should revert to pull direction
|
||||
}
|
||||
|
||||
self->paused = false;
|
||||
rmt_rx_start(self->channel, false);
|
||||
}
|
||||
|
||||
void common_hal_pulseio_pulsein_clear(pulseio_pulsein_obj_t* self) {
|
||||
// Buffer only updates in BG tasks or fetches, so no extra protection is needed
|
||||
self->start = 0;
|
||||
self->len = 0;
|
||||
}
|
||||
|
||||
uint16_t common_hal_pulseio_pulsein_get_item(pulseio_pulsein_obj_t* self, int16_t index) {
|
||||
return false;
|
||||
update_internal_buffer(self);
|
||||
if (index < 0) {
|
||||
index += self->len;
|
||||
}
|
||||
if (index < 0 || index >= self->len) {
|
||||
mp_raise_IndexError(translate("index out of range"));
|
||||
}
|
||||
uint16_t value = self->buffer[(self->start + index) % self->maxlen];
|
||||
return value;
|
||||
}
|
||||
|
||||
uint16_t common_hal_pulseio_pulsein_popleft(pulseio_pulsein_obj_t* self) {
|
||||
return false;
|
||||
update_internal_buffer(self);
|
||||
|
||||
if (self->len == 0) {
|
||||
mp_raise_IndexError(translate("pop from an empty PulseIn"));
|
||||
}
|
||||
|
||||
uint16_t value = self->buffer[self->start];
|
||||
self->start = (self->start + 1) % self->maxlen;
|
||||
self->len--;
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
uint16_t common_hal_pulseio_pulsein_get_maxlen(pulseio_pulsein_obj_t* self) {
|
||||
return false;
|
||||
return self->maxlen;
|
||||
}
|
||||
|
||||
bool common_hal_pulseio_pulsein_get_paused(pulseio_pulsein_obj_t* self) {
|
||||
return false;
|
||||
return self->paused;
|
||||
}
|
||||
|
||||
uint16_t common_hal_pulseio_pulsein_get_len(pulseio_pulsein_obj_t* self) {
|
||||
return false;
|
||||
return self->len;
|
||||
}
|
||||
|
@ -30,24 +30,27 @@
|
||||
#include "common-hal/microcontroller/Pin.h"
|
||||
|
||||
#include "py/obj.h"
|
||||
#include "driver/rmt.h"
|
||||
#include "rmt.h"
|
||||
|
||||
typedef struct {
|
||||
mp_obj_base_t base;
|
||||
|
||||
const mcu_pin_obj_t* pin;
|
||||
rmt_channel_t channel;
|
||||
bool idle_state;
|
||||
bool paused;
|
||||
volatile bool first_edge;
|
||||
|
||||
RingbufHandle_t buf_handle;
|
||||
|
||||
uint16_t* buffer;
|
||||
uint16_t maxlen;
|
||||
|
||||
volatile uint16_t start;
|
||||
volatile uint16_t len;
|
||||
volatile uint32_t last_overflow;
|
||||
volatile uint16_t last_count;
|
||||
} pulseio_pulsein_obj_t;
|
||||
|
||||
void pulsein_reset(void);
|
||||
void pulsein_background(void);
|
||||
|
||||
#endif // MICROPY_INCLUDED_ESP32S2_COMMON_HAL_PULSEIO_PULSEIN_H
|
||||
|
@ -26,35 +26,66 @@
|
||||
|
||||
#include "common-hal/pulseio/PulseOut.h"
|
||||
|
||||
#include "shared-bindings/pulseio/PWMOut.h"
|
||||
#include "shared-bindings/pwmio/PWMOut.h"
|
||||
#include "py/runtime.h"
|
||||
|
||||
// STATIC void turn_on(pulseio_pulseout_obj_t *pulseout) {
|
||||
// }
|
||||
|
||||
// STATIC void turn_off(pulseio_pulseout_obj_t *pulseout) {
|
||||
// }
|
||||
|
||||
// STATIC void start_timer(void) {
|
||||
// }
|
||||
|
||||
// STATIC void pulseout_event_handler(void) {
|
||||
// }
|
||||
|
||||
void pulseout_reset() {
|
||||
}
|
||||
// Requires rmt.c void esp32s2_peripherals_reset_all(void) to reset
|
||||
|
||||
void common_hal_pulseio_pulseout_construct(pulseio_pulseout_obj_t* self,
|
||||
const pulseio_pwmout_obj_t* carrier) {
|
||||
mp_raise_NotImplementedError(translate("PulseOut not supported on this chip"));
|
||||
const pwmio_pwmout_obj_t* carrier,
|
||||
const mcu_pin_obj_t* pin,
|
||||
uint32_t frequency,
|
||||
uint16_t duty_cycle) {
|
||||
if (carrier || !pin || !frequency) {
|
||||
mp_raise_NotImplementedError(translate("Port does not accept PWM carrier. \
|
||||
Pass a pin, frequency and duty cycle instead"));
|
||||
}
|
||||
|
||||
rmt_channel_t channel = esp32s2_peripherals_find_and_reserve_rmt();
|
||||
if (channel == RMT_CHANNEL_MAX) {
|
||||
mp_raise_RuntimeError(translate("All timers in use"));
|
||||
}
|
||||
|
||||
// Configure Channel
|
||||
rmt_config_t config = RMT_DEFAULT_CONFIG_TX(pin->number, channel);
|
||||
config.tx_config.carrier_en = true;
|
||||
config.tx_config.carrier_duty_percent = (duty_cycle * 100) / (1<<16);
|
||||
config.tx_config.carrier_freq_hz = frequency;
|
||||
config.clk_div = 80;
|
||||
|
||||
rmt_config(&config);
|
||||
rmt_driver_install(channel, 0, 0);
|
||||
|
||||
self->channel = channel;
|
||||
}
|
||||
|
||||
bool common_hal_pulseio_pulseout_deinited(pulseio_pulseout_obj_t* self) {
|
||||
return false;
|
||||
return (self->channel == RMT_CHANNEL_MAX);
|
||||
}
|
||||
|
||||
void common_hal_pulseio_pulseout_deinit(pulseio_pulseout_obj_t* self) {
|
||||
esp32s2_peripherals_free_rmt(self->channel);
|
||||
self->channel = RMT_CHANNEL_MAX;
|
||||
|
||||
}
|
||||
|
||||
void common_hal_pulseio_pulseout_send(pulseio_pulseout_obj_t* self, uint16_t* pulses, uint16_t length) {
|
||||
rmt_item32_t items[length];
|
||||
|
||||
// Circuitpython allows 16 bit pulse values, while ESP32 only allows 15 bits
|
||||
// Thus, we use entire items for one pulse, rather than switching inside each item
|
||||
for (size_t i = 0; i < length; i++) {
|
||||
// Setting the RMT duration to 0 has undefined behavior, so avoid that pre-emptively.
|
||||
if (pulses[i] == 0) {
|
||||
pulses[i] = 1;
|
||||
}
|
||||
uint32_t level = (i % 2) ? 0 : 1;
|
||||
const rmt_item32_t item = {{{ (pulses[i] & 0x8000 ? 0x7FFF : 1), level, (pulses[i] & 0x7FFF), level}}};
|
||||
items[i] = item;
|
||||
}
|
||||
|
||||
rmt_write_items(self->channel, items, length, true);
|
||||
while (rmt_wait_tx_done(self->channel, 0) != ESP_OK) {
|
||||
RUN_BACKGROUND_TASKS;
|
||||
}
|
||||
}
|
||||
|
@ -28,15 +28,14 @@
|
||||
#define MICROPY_INCLUDED_ESP32S2_COMMON_HAL_PULSEIO_PULSEOUT_H
|
||||
|
||||
#include "common-hal/microcontroller/Pin.h"
|
||||
#include "common-hal/pulseio/PWMOut.h"
|
||||
#include "driver/rmt.h"
|
||||
#include "rmt.h"
|
||||
|
||||
#include "py/obj.h"
|
||||
|
||||
typedef struct {
|
||||
mp_obj_base_t base;
|
||||
pulseio_pwmout_obj_t *pwmout;
|
||||
rmt_channel_t channel;
|
||||
} pulseio_pulseout_obj_t;
|
||||
|
||||
void pulseout_reset(void);
|
||||
|
||||
#endif // MICROPY_INCLUDED_ESP32S2_COMMON_HAL_PULSEIO_PULSEOUT_H
|
||||
|
@ -25,8 +25,8 @@
|
||||
*/
|
||||
#include <math.h>
|
||||
|
||||
#include "common-hal/pulseio/PWMOut.h"
|
||||
#include "shared-bindings/pulseio/PWMOut.h"
|
||||
#include "common-hal/pwmio/PWMOut.h"
|
||||
#include "shared-bindings/pwmio/PWMOut.h"
|
||||
#include "py/runtime.h"
|
||||
#include "driver/ledc.h"
|
||||
|
||||
@ -58,7 +58,7 @@ void pwmout_reset(void) {
|
||||
not_first_reset = true;
|
||||
}
|
||||
|
||||
pwmout_result_t common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self,
|
||||
pwmout_result_t common_hal_pwmio_pwmout_construct(pwmio_pwmout_obj_t* self,
|
||||
const mcu_pin_obj_t* pin,
|
||||
uint16_t duty,
|
||||
uint32_t frequency,
|
||||
@ -140,27 +140,27 @@ pwmout_result_t common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self,
|
||||
claim_pin(pin);
|
||||
|
||||
// Set initial duty
|
||||
common_hal_pulseio_pwmout_set_duty_cycle(self, duty);
|
||||
common_hal_pwmio_pwmout_set_duty_cycle(self, duty);
|
||||
|
||||
return PWMOUT_OK;
|
||||
}
|
||||
|
||||
void common_hal_pulseio_pwmout_never_reset(pulseio_pwmout_obj_t *self) {
|
||||
void common_hal_pwmio_pwmout_never_reset(pwmio_pwmout_obj_t *self) {
|
||||
never_reset_tim[self->tim_handle.timer_num] = true;
|
||||
never_reset_chan[self->chan_handle.channel] = true;
|
||||
}
|
||||
|
||||
void common_hal_pulseio_pwmout_reset_ok(pulseio_pwmout_obj_t *self) {
|
||||
void common_hal_pwmio_pwmout_reset_ok(pwmio_pwmout_obj_t *self) {
|
||||
never_reset_tim[self->tim_handle.timer_num] = false;
|
||||
never_reset_chan[self->chan_handle.channel] = false;
|
||||
}
|
||||
|
||||
bool common_hal_pulseio_pwmout_deinited(pulseio_pwmout_obj_t* self) {
|
||||
bool common_hal_pwmio_pwmout_deinited(pwmio_pwmout_obj_t* self) {
|
||||
return self->deinited == true;
|
||||
}
|
||||
|
||||
void common_hal_pulseio_pwmout_deinit(pulseio_pwmout_obj_t* self) {
|
||||
if (common_hal_pulseio_pwmout_deinited(self)) {
|
||||
void common_hal_pwmio_pwmout_deinit(pwmio_pwmout_obj_t* self) {
|
||||
if (common_hal_pwmio_pwmout_deinited(self)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -186,23 +186,23 @@ void common_hal_pulseio_pwmout_deinit(pulseio_pwmout_obj_t* self) {
|
||||
self->deinited = true;
|
||||
}
|
||||
|
||||
void common_hal_pulseio_pwmout_set_duty_cycle(pulseio_pwmout_obj_t* self, uint16_t duty) {
|
||||
void common_hal_pwmio_pwmout_set_duty_cycle(pwmio_pwmout_obj_t* self, uint16_t duty) {
|
||||
ledc_set_duty(LEDC_LOW_SPEED_MODE, self->chan_handle.channel, duty >> (16 - self->duty_resolution));
|
||||
ledc_update_duty(LEDC_LOW_SPEED_MODE, self->chan_handle.channel);
|
||||
}
|
||||
|
||||
uint16_t common_hal_pulseio_pwmout_get_duty_cycle(pulseio_pwmout_obj_t* self) {
|
||||
uint16_t common_hal_pwmio_pwmout_get_duty_cycle(pwmio_pwmout_obj_t* self) {
|
||||
return ledc_get_duty(LEDC_LOW_SPEED_MODE, self->chan_handle.channel) << (16 - self->duty_resolution);
|
||||
}
|
||||
|
||||
void common_hal_pulseio_pwmout_set_frequency(pulseio_pwmout_obj_t* self, uint32_t frequency) {
|
||||
void common_hal_pwmio_pwmout_set_frequency(pwmio_pwmout_obj_t* self, uint32_t frequency) {
|
||||
ledc_set_freq(LEDC_LOW_SPEED_MODE, self->tim_handle.timer_num, frequency);
|
||||
}
|
||||
|
||||
uint32_t common_hal_pulseio_pwmout_get_frequency(pulseio_pwmout_obj_t* self) {
|
||||
uint32_t common_hal_pwmio_pwmout_get_frequency(pwmio_pwmout_obj_t* self) {
|
||||
return ledc_get_freq(LEDC_LOW_SPEED_MODE, self->tim_handle.timer_num);
|
||||
}
|
||||
|
||||
bool common_hal_pulseio_pwmout_get_variable_frequency(pulseio_pwmout_obj_t* self) {
|
||||
bool common_hal_pwmio_pwmout_get_variable_frequency(pwmio_pwmout_obj_t* self) {
|
||||
return self->variable_frequency;
|
||||
}
|
@ -24,8 +24,8 @@
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef MICROPY_INCLUDED_ESP32S2_COMMON_HAL_PULSEIO_PWMOUT_H
|
||||
#define MICROPY_INCLUDED_ESP32S2_COMMON_HAL_PULSEIO_PWMOUT_H
|
||||
#ifndef MICROPY_INCLUDED_ESP32S2_COMMON_HAL_PWMIO_PWMOUT_H
|
||||
#define MICROPY_INCLUDED_ESP32S2_COMMON_HAL_PWMIO_PWMOUT_H
|
||||
|
||||
#include "common-hal/microcontroller/Pin.h"
|
||||
#include "driver/ledc.h"
|
||||
@ -38,8 +38,8 @@ typedef struct {
|
||||
uint8_t duty_resolution;
|
||||
bool variable_frequency: 1;
|
||||
bool deinited: 1;
|
||||
} pulseio_pwmout_obj_t;
|
||||
} pwmio_pwmout_obj_t;
|
||||
|
||||
void pwmout_reset(void);
|
||||
|
||||
#endif // MICROPY_INCLUDED_ESP32S2_COMMON_HAL_PULSEIO_PWMOUT_H
|
||||
#endif // MICROPY_INCLUDED_ESP32S2_COMMON_HAL_PWMIO_PWMOUT_H
|
1
ports/esp32s2/common-hal/pwmio/__init__.c
Normal file
1
ports/esp32s2/common-hal/pwmio/__init__.c
Normal file
@ -0,0 +1 @@
|
||||
// No pwmio module functions.
|
@ -29,6 +29,14 @@
|
||||
|
||||
bool rmt_reserved_channels[RMT_CHANNEL_MAX];
|
||||
|
||||
void esp32s2_peripherals_rmt_reset(void) {
|
||||
for (size_t i = 0; i < RMT_CHANNEL_MAX; i++) {
|
||||
if (rmt_reserved_channels[i]) {
|
||||
esp32s2_peripherals_free_rmt(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rmt_channel_t esp32s2_peripherals_find_and_reserve_rmt(void) {
|
||||
for (size_t i = 0; i < RMT_CHANNEL_MAX; i++) {
|
||||
if (!rmt_reserved_channels[i]) {
|
||||
@ -36,8 +44,8 @@ rmt_channel_t esp32s2_peripherals_find_and_reserve_rmt(void) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
mp_raise_RuntimeError(translate("All timers in use"));
|
||||
return false;
|
||||
// Returning the max indicates a reservation failure.
|
||||
return RMT_CHANNEL_MAX;
|
||||
}
|
||||
|
||||
void esp32s2_peripherals_free_rmt(rmt_channel_t chan) {
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "driver/rmt.h"
|
||||
#include <stdint.h>
|
||||
|
||||
void esp32s2_peripherals_rmt_reset(void);
|
||||
rmt_channel_t esp32s2_peripherals_find_and_reserve_rmt(void);
|
||||
void esp32s2_peripherals_free_rmt(rmt_channel_t chan);
|
||||
|
||||
|
@ -38,12 +38,14 @@
|
||||
#include "common-hal/busio/I2C.h"
|
||||
#include "common-hal/busio/SPI.h"
|
||||
#include "common-hal/busio/UART.h"
|
||||
#include "common-hal/pulseio/PWMOut.h"
|
||||
#include "common-hal/pulseio/PulseIn.h"
|
||||
#include "common-hal/pwmio/PWMOut.h"
|
||||
#include "common-hal/wifi/__init__.h"
|
||||
#include "supervisor/memory.h"
|
||||
#include "supervisor/shared/tick.h"
|
||||
|
||||
#include "esp-idf/components/heap/include/esp_heap_caps.h"
|
||||
#include "rmt.h"
|
||||
|
||||
#define HEAP_SIZE (48 * 1024)
|
||||
|
||||
@ -75,8 +77,14 @@ void reset_port(void) {
|
||||
vTaskDelay(4);
|
||||
|
||||
#if CIRCUITPY_PULSEIO
|
||||
esp32s2_peripherals_rmt_reset();
|
||||
pulsein_reset();
|
||||
#endif
|
||||
|
||||
#if CIRCUITPY_PWMIO
|
||||
pwmout_reset();
|
||||
#endif
|
||||
|
||||
#if CIRCUITPY_BUSIO
|
||||
i2c_reset();
|
||||
spi_reset();
|
||||
|
@ -94,7 +94,10 @@ void pulseout_reset() {
|
||||
}
|
||||
|
||||
void common_hal_pulseio_pulseout_construct(pulseio_pulseout_obj_t* self,
|
||||
const pulseio_pwmout_obj_t* carrier) {
|
||||
const pwmio_pwmout_obj_t* carrier,
|
||||
const mcu_pin_obj_t* pin,
|
||||
uint32_t frequency,
|
||||
uint16_t duty_cycle) {
|
||||
// if (refcount == 0) {
|
||||
// // Find a spare timer.
|
||||
// Tc *tc = NULL;
|
||||
|
@ -29,8 +29,8 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include "py/runtime.h"
|
||||
#include "common-hal/pulseio/PWMOut.h"
|
||||
#include "shared-bindings/pulseio/PWMOut.h"
|
||||
#include "common-hal/pwmio/PWMOut.h"
|
||||
#include "shared-bindings/pwmio/PWMOut.h"
|
||||
#include "shared-bindings/microcontroller/Processor.h"
|
||||
|
||||
#include "fsl_pwm.h"
|
||||
@ -64,7 +64,7 @@
|
||||
//
|
||||
//static uint8_t never_reset_tc_or_tcc[TC_INST_NUM + TCC_INST_NUM];
|
||||
|
||||
void common_hal_pulseio_pwmout_never_reset(pulseio_pwmout_obj_t *self) {
|
||||
void common_hal_pwmio_pwmout_never_reset(pwmio_pwmout_obj_t *self) {
|
||||
// if (self->timer->is_tc) {
|
||||
// never_reset_tc_or_tcc[self->timer->index] += 1;
|
||||
// } else {
|
||||
@ -74,7 +74,7 @@ void common_hal_pulseio_pwmout_never_reset(pulseio_pwmout_obj_t *self) {
|
||||
// never_reset_pin_number(self->pin->number);
|
||||
}
|
||||
|
||||
void common_hal_pulseio_pwmout_reset_ok(pulseio_pwmout_obj_t *self) {
|
||||
void common_hal_pwmio_pwmout_reset_ok(pwmio_pwmout_obj_t *self) {
|
||||
// if (self->timer->is_tc) {
|
||||
// never_reset_tc_or_tcc[self->timer->index] -= 1;
|
||||
// } else {
|
||||
@ -133,7 +133,7 @@ void pwmout_reset(void) {
|
||||
|
||||
#define PWM_SRC_CLK_FREQ CLOCK_GetFreq(kCLOCK_IpgClk)
|
||||
|
||||
pwmout_result_t common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t *self,
|
||||
pwmout_result_t common_hal_pwmio_pwmout_construct(pwmio_pwmout_obj_t *self,
|
||||
const mcu_pin_obj_t *pin,
|
||||
uint16_t duty,
|
||||
uint32_t frequency,
|
||||
@ -359,17 +359,17 @@ pwmout_result_t common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t *self,
|
||||
//
|
||||
// gpio_set_pin_function(pin->number, GPIO_PIN_FUNCTION_E + mux_position);
|
||||
|
||||
common_hal_pulseio_pwmout_set_duty_cycle(self, duty);
|
||||
common_hal_pwmio_pwmout_set_duty_cycle(self, duty);
|
||||
|
||||
return PWMOUT_OK;
|
||||
}
|
||||
|
||||
bool common_hal_pulseio_pwmout_deinited(pulseio_pwmout_obj_t* self) {
|
||||
bool common_hal_pwmio_pwmout_deinited(pwmio_pwmout_obj_t* self) {
|
||||
return self->pin == NULL;
|
||||
}
|
||||
|
||||
void common_hal_pulseio_pwmout_deinit(pulseio_pwmout_obj_t* self) {
|
||||
if (common_hal_pulseio_pwmout_deinited(self)) {
|
||||
void common_hal_pwmio_pwmout_deinit(pwmio_pwmout_obj_t* self) {
|
||||
if (common_hal_pwmio_pwmout_deinited(self)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -396,7 +396,7 @@ void common_hal_pulseio_pwmout_deinit(pulseio_pwmout_obj_t* self) {
|
||||
self->pin = NULL;
|
||||
}
|
||||
|
||||
void common_hal_pulseio_pwmout_set_duty_cycle(pulseio_pwmout_obj_t *self, uint16_t duty) {
|
||||
void common_hal_pwmio_pwmout_set_duty_cycle(pwmio_pwmout_obj_t *self, uint16_t duty) {
|
||||
PWM_UpdatePwmDutycycle(PWM1, self->pwm->submodule, self->pwm->channel, kPWM_SignedCenterAligned, duty);
|
||||
|
||||
// const pin_timer_t* t = self->timer;
|
||||
@ -433,7 +433,7 @@ void common_hal_pulseio_pwmout_set_duty_cycle(pulseio_pwmout_obj_t *self, uint16
|
||||
// }
|
||||
}
|
||||
|
||||
uint16_t common_hal_pulseio_pwmout_get_duty_cycle(pulseio_pwmout_obj_t* self) {
|
||||
uint16_t common_hal_pwmio_pwmout_get_duty_cycle(pwmio_pwmout_obj_t* self) {
|
||||
return 0;
|
||||
// const pin_timer_t* t = self->timer;
|
||||
// if (t->is_tc) {
|
||||
@ -471,7 +471,7 @@ uint16_t common_hal_pulseio_pwmout_get_duty_cycle(pulseio_pwmout_obj_t* self) {
|
||||
// }
|
||||
}
|
||||
|
||||
void common_hal_pulseio_pwmout_set_frequency(pulseio_pwmout_obj_t* self,
|
||||
void common_hal_pwmio_pwmout_set_frequency(pwmio_pwmout_obj_t* self,
|
||||
uint32_t frequency) {
|
||||
// if (frequency == 0 || frequency > 6000000) {
|
||||
// mp_raise_ValueError(translate("Invalid PWM frequency"));
|
||||
@ -492,7 +492,7 @@ void common_hal_pulseio_pwmout_set_frequency(pulseio_pwmout_obj_t* self,
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// uint16_t old_duty = common_hal_pulseio_pwmout_get_duty_cycle(self);
|
||||
// uint16_t old_duty = common_hal_pwmio_pwmout_get_duty_cycle(self);
|
||||
// if (t->is_tc) {
|
||||
// Tc* tc = tc_insts[t->index];
|
||||
// uint8_t old_divisor = tc->COUNT16.CTRLA.bit.PRESCALER;
|
||||
@ -527,10 +527,10 @@ void common_hal_pulseio_pwmout_set_frequency(pulseio_pwmout_obj_t* self,
|
||||
// #endif
|
||||
// }
|
||||
|
||||
// common_hal_pulseio_pwmout_set_duty_cycle(self, old_duty);
|
||||
// common_hal_pwmio_pwmout_set_duty_cycle(self, old_duty);
|
||||
}
|
||||
|
||||
uint32_t common_hal_pulseio_pwmout_get_frequency(pulseio_pwmout_obj_t* self) {
|
||||
uint32_t common_hal_pwmio_pwmout_get_frequency(pwmio_pwmout_obj_t* self) {
|
||||
// uint32_t system_clock = common_hal_mcu_processor_get_frequency();
|
||||
// const pin_timer_t* t = self->timer;
|
||||
// uint8_t divisor;
|
||||
@ -546,6 +546,6 @@ uint32_t common_hal_pulseio_pwmout_get_frequency(pulseio_pwmout_obj_t* self) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool common_hal_pulseio_pwmout_get_variable_frequency(pulseio_pwmout_obj_t* self) {
|
||||
bool common_hal_pwmio_pwmout_get_variable_frequency(pwmio_pwmout_obj_t* self) {
|
||||
return self->variable_frequency;
|
||||
}
|
@ -25,8 +25,8 @@
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_PULSEIO_PWMOUT_H
|
||||
#define MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_PULSEIO_PWMOUT_H
|
||||
#ifndef MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_PWMIO_PWMOUT_H
|
||||
#define MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_PWMIO_PWMOUT_H
|
||||
|
||||
#include "common-hal/microcontroller/Pin.h"
|
||||
#include "periph.h"
|
||||
@ -37,8 +37,8 @@ typedef struct {
|
||||
const mcu_pin_obj_t *pin;
|
||||
const mcu_pwm_obj_t *pwm;
|
||||
bool variable_frequency;
|
||||
} pulseio_pwmout_obj_t;
|
||||
} pwmio_pwmout_obj_t;
|
||||
|
||||
void pwmout_reset(void);
|
||||
|
||||
#endif // MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_PULSEIO_PWMOUT_H
|
||||
#endif // MICROPY_INCLUDED_MIMXRT10XX_COMMON_HAL_PWMIO_PWMOUT_H
|
1
ports/mimxrt10xx/common-hal/pwmio/__init__.c
Normal file
1
ports/mimxrt10xx/common-hal/pwmio/__init__.c
Normal file
@ -0,0 +1 @@
|
||||
// No pwmio module functions.
|
@ -39,8 +39,8 @@ static inline mp_uint_t mp_hal_ticks_ms(void) {
|
||||
return supervisor_ticks_ms32();
|
||||
}
|
||||
// Number of bytes in receive buffer
|
||||
volatile uint8_t usb_rx_count;
|
||||
volatile bool mp_cdc_enabled;
|
||||
extern volatile uint8_t usb_rx_count;
|
||||
extern volatile bool mp_cdc_enabled;
|
||||
|
||||
int receive_usb(void);
|
||||
|
||||
|
@ -27,18 +27,18 @@
|
||||
#ifndef MICROPY_INCLUDED_MIMXRT10XX_PERIPHERALS_MIMXRT1011_PERIPH_H
|
||||
#define MICROPY_INCLUDED_MIMXRT10XX_PERIPHERALS_MIMXRT1011_PERIPH_H
|
||||
|
||||
LPI2C_Type *mcu_i2c_banks[2];
|
||||
extern LPI2C_Type *mcu_i2c_banks[2];
|
||||
|
||||
extern const mcu_periph_obj_t mcu_i2c_sda_list[8];
|
||||
extern const mcu_periph_obj_t mcu_i2c_scl_list[8];
|
||||
|
||||
LPSPI_Type *mcu_spi_banks[2];
|
||||
extern LPSPI_Type *mcu_spi_banks[2];
|
||||
|
||||
extern const mcu_periph_obj_t mcu_spi_sck_list[4];
|
||||
extern const mcu_periph_obj_t mcu_spi_mosi_list[4];
|
||||
extern const mcu_periph_obj_t mcu_spi_miso_list[4];
|
||||
|
||||
LPUART_Type *mcu_uart_banks[4];
|
||||
extern LPUART_Type *mcu_uart_banks[4];
|
||||
|
||||
extern const mcu_periph_obj_t mcu_uart_rx_list[9];
|
||||
extern const mcu_periph_obj_t mcu_uart_tx_list[9];
|
||||
|
@ -28,18 +28,18 @@
|
||||
#ifndef MICROPY_INCLUDED_MIMXRT10XX_PERIPHERALS_MIMXRT1021_PERIPH_H
|
||||
#define MICROPY_INCLUDED_MIMXRT10XX_PERIPHERALS_MIMXRT1021_PERIPH_H
|
||||
|
||||
LPI2C_Type *mcu_i2c_banks[4];
|
||||
extern LPI2C_Type *mcu_i2c_banks[4];
|
||||
|
||||
extern const mcu_periph_obj_t mcu_i2c_sda_list[8];
|
||||
extern const mcu_periph_obj_t mcu_i2c_scl_list[8];
|
||||
|
||||
LPSPI_Type *mcu_spi_banks[4];
|
||||
extern LPSPI_Type *mcu_spi_banks[4];
|
||||
|
||||
extern const mcu_periph_obj_t mcu_spi_sck_list[8];
|
||||
extern const mcu_periph_obj_t mcu_spi_mosi_list[8];
|
||||
extern const mcu_periph_obj_t mcu_spi_miso_list[8];
|
||||
|
||||
LPUART_Type *mcu_uart_banks[8];
|
||||
extern LPUART_Type *mcu_uart_banks[8];
|
||||
|
||||
extern const mcu_periph_obj_t mcu_uart_rx_list[16];
|
||||
extern const mcu_periph_obj_t mcu_uart_tx_list[16];
|
||||
|
@ -27,18 +27,18 @@
|
||||
#ifndef MICROPY_INCLUDED_MIMXRT10XX_PERIPHERALS_MIMXRT1011_PERIPH_H
|
||||
#define MICROPY_INCLUDED_MIMXRT10XX_PERIPHERALS_MIMXRT1011_PERIPH_H
|
||||
|
||||
LPI2C_Type *mcu_i2c_banks[4];
|
||||
extern LPI2C_Type *mcu_i2c_banks[4];
|
||||
|
||||
extern const mcu_periph_obj_t mcu_i2c_sda_list[9];
|
||||
extern const mcu_periph_obj_t mcu_i2c_scl_list[9];
|
||||
|
||||
LPSPI_Type *mcu_spi_banks[4];
|
||||
extern LPSPI_Type *mcu_spi_banks[4];
|
||||
|
||||
extern const mcu_periph_obj_t mcu_spi_sck_list[8];
|
||||
extern const mcu_periph_obj_t mcu_spi_mosi_list[8];
|
||||
extern const mcu_periph_obj_t mcu_spi_miso_list[8];
|
||||
|
||||
LPUART_Type *mcu_uart_banks[8];
|
||||
extern LPUART_Type *mcu_uart_banks[8];
|
||||
|
||||
extern const mcu_periph_obj_t mcu_uart_rx_list[18];
|
||||
extern const mcu_periph_obj_t mcu_uart_tx_list[18];
|
||||
|
@ -39,7 +39,7 @@
|
||||
#include "common-hal/microcontroller/Pin.h"
|
||||
#include "common-hal/pulseio/PulseIn.h"
|
||||
#include "common-hal/pulseio/PulseOut.h"
|
||||
#include "common-hal/pulseio/PWMOut.h"
|
||||
#include "common-hal/pwmio/PWMOut.h"
|
||||
#include "common-hal/rtc/RTC.h"
|
||||
#include "common-hal/busio/SPI.h"
|
||||
|
||||
@ -289,6 +289,8 @@ void reset_port(void) {
|
||||
|
||||
#if CIRCUITPY_PULSEIO
|
||||
pulseout_reset();
|
||||
#endif
|
||||
#if CIRCUITPY_PWMIO
|
||||
pwmout_reset();
|
||||
#endif
|
||||
|
||||
|
@ -87,6 +87,8 @@ void check_sec_status(uint8_t sec_status) {
|
||||
}
|
||||
}
|
||||
|
||||
bool vm_used_ble;
|
||||
|
||||
// Turn off BLE on a reset or reload.
|
||||
void bleio_reset() {
|
||||
if (!common_hal_bleio_adapter_get_enabled(&common_hal_bleio_adapter_obj)) {
|
||||
|
@ -45,6 +45,6 @@ void check_gatt_status(uint16_t gatt_status);
|
||||
void check_sec_status(uint8_t sec_status);
|
||||
|
||||
// Track if the user code modified the BLE state to know if we need to undo it on reload.
|
||||
bool vm_used_ble;
|
||||
extern bool vm_used_ble;
|
||||
|
||||
#endif // MICROPY_INCLUDED_NRF_COMMON_HAL_BLEIO_INIT_H
|
||||
|
@ -32,7 +32,7 @@
|
||||
#include "py/mperrno.h"
|
||||
#include "py/runtime.h"
|
||||
#include "common-hal/audiopwmio/PWMAudioOut.h"
|
||||
#include "common-hal/pulseio/PWMOut.h"
|
||||
#include "common-hal/pwmio/PWMOut.h"
|
||||
#include "shared-bindings/audiopwmio/PWMAudioOut.h"
|
||||
#include "shared-bindings/microcontroller/__init__.h"
|
||||
#include "shared-bindings/microcontroller/Pin.h"
|
||||
|
@ -34,7 +34,7 @@
|
||||
#include "py/gc.h"
|
||||
#include "py/runtime.h"
|
||||
#include "shared-bindings/pulseio/PulseOut.h"
|
||||
#include "shared-bindings/pulseio/PWMOut.h"
|
||||
#include "shared-bindings/pwmio/PWMOut.h"
|
||||
#include "supervisor/shared/translate.h"
|
||||
|
||||
// A single timer is shared amongst all PulseOut objects under the assumption that
|
||||
@ -100,7 +100,15 @@ void pulseout_reset() {
|
||||
}
|
||||
|
||||
void common_hal_pulseio_pulseout_construct(pulseio_pulseout_obj_t* self,
|
||||
const pulseio_pwmout_obj_t* carrier) {
|
||||
const pwmio_pwmout_obj_t* carrier,
|
||||
const mcu_pin_obj_t* pin,
|
||||
uint32_t frequency,
|
||||
uint16_t duty_cycle) {
|
||||
if (!carrier || pin || frequency) {
|
||||
mp_raise_NotImplementedError(translate("Port does not accept pins or frequency. \
|
||||
Construct and pass a PWMOut Carrier instead"));
|
||||
}
|
||||
|
||||
if (refcount == 0) {
|
||||
timer = nrf_peripherals_allocate_timer_or_throw();
|
||||
}
|
||||
|
@ -28,13 +28,13 @@
|
||||
#define MICROPY_INCLUDED_NRF_COMMON_HAL_PULSEIO_PULSEOUT_H
|
||||
|
||||
#include "common-hal/microcontroller/Pin.h"
|
||||
#include "common-hal/pulseio/PWMOut.h"
|
||||
#include "common-hal/pwmio/PWMOut.h"
|
||||
|
||||
#include "py/obj.h"
|
||||
|
||||
typedef struct {
|
||||
mp_obj_base_t base;
|
||||
const pulseio_pwmout_obj_t *pwmout;
|
||||
const pwmio_pwmout_obj_t *pwmout;
|
||||
} pulseio_pulseout_obj_t;
|
||||
|
||||
void pulseout_reset(void);
|
||||
|
@ -28,8 +28,8 @@
|
||||
#include "nrf.h"
|
||||
|
||||
#include "py/runtime.h"
|
||||
#include "common-hal/pulseio/PWMOut.h"
|
||||
#include "shared-bindings/pulseio/PWMOut.h"
|
||||
#include "common-hal/pwmio/PWMOut.h"
|
||||
#include "shared-bindings/pwmio/PWMOut.h"
|
||||
#include "supervisor/shared/translate.h"
|
||||
|
||||
#include "nrf_gpio.h"
|
||||
@ -63,7 +63,7 @@ STATIC int pwm_idx(NRF_PWM_Type *pwm) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
void common_hal_pulseio_pwmout_never_reset(pulseio_pwmout_obj_t *self) {
|
||||
void common_hal_pwmio_pwmout_never_reset(pwmio_pwmout_obj_t *self) {
|
||||
for(size_t i=0; i < MP_ARRAY_SIZE(pwms); i++) {
|
||||
NRF_PWM_Type* pwm = pwms[i];
|
||||
if (pwm == self->pwm) {
|
||||
@ -74,7 +74,7 @@ void common_hal_pulseio_pwmout_never_reset(pulseio_pwmout_obj_t *self) {
|
||||
never_reset_pin_number(self->pin_number);
|
||||
}
|
||||
|
||||
void common_hal_pulseio_pwmout_reset_ok(pulseio_pwmout_obj_t *self) {
|
||||
void common_hal_pwmio_pwmout_reset_ok(pwmio_pwmout_obj_t *self) {
|
||||
for(size_t i=0; i < MP_ARRAY_SIZE(pwms); i++) {
|
||||
NRF_PWM_Type* pwm = pwms[i];
|
||||
if (pwm == self->pwm) {
|
||||
@ -204,7 +204,7 @@ void pwmout_free_channel(NRF_PWM_Type *pwm, int8_t channel) {
|
||||
nrf_pwm_disable(pwm);
|
||||
}
|
||||
|
||||
pwmout_result_t common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self,
|
||||
pwmout_result_t common_hal_pwmio_pwmout_construct(pwmio_pwmout_obj_t* self,
|
||||
const mcu_pin_obj_t* pin,
|
||||
uint16_t duty,
|
||||
uint32_t frequency,
|
||||
@ -251,16 +251,16 @@ pwmout_result_t common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self,
|
||||
|
||||
nrf_pwm_enable(self->pwm);
|
||||
|
||||
common_hal_pulseio_pwmout_set_duty_cycle(self, duty);
|
||||
common_hal_pwmio_pwmout_set_duty_cycle(self, duty);
|
||||
return PWMOUT_OK;
|
||||
}
|
||||
|
||||
bool common_hal_pulseio_pwmout_deinited(pulseio_pwmout_obj_t* self) {
|
||||
bool common_hal_pwmio_pwmout_deinited(pwmio_pwmout_obj_t* self) {
|
||||
return self->pwm == NULL;
|
||||
}
|
||||
|
||||
void common_hal_pulseio_pwmout_deinit(pulseio_pwmout_obj_t* self) {
|
||||
if (common_hal_pulseio_pwmout_deinited(self)) {
|
||||
void common_hal_pwmio_pwmout_deinit(pwmio_pwmout_obj_t* self) {
|
||||
if (common_hal_pwmio_pwmout_deinited(self)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -275,7 +275,7 @@ void common_hal_pulseio_pwmout_deinit(pulseio_pwmout_obj_t* self) {
|
||||
self->pin_number = NO_PIN;
|
||||
}
|
||||
|
||||
void common_hal_pulseio_pwmout_set_duty_cycle(pulseio_pwmout_obj_t* self, uint16_t duty_cycle) {
|
||||
void common_hal_pwmio_pwmout_set_duty_cycle(pwmio_pwmout_obj_t* self, uint16_t duty_cycle) {
|
||||
self->duty_cycle = duty_cycle;
|
||||
|
||||
uint16_t* p_value = ((uint16_t*)self->pwm->SEQ[0].PTR) + self->channel;
|
||||
@ -284,11 +284,11 @@ void common_hal_pulseio_pwmout_set_duty_cycle(pulseio_pwmout_obj_t* self, uint16
|
||||
self->pwm->TASKS_SEQSTART[0] = 1;
|
||||
}
|
||||
|
||||
uint16_t common_hal_pulseio_pwmout_get_duty_cycle(pulseio_pwmout_obj_t* self) {
|
||||
uint16_t common_hal_pwmio_pwmout_get_duty_cycle(pwmio_pwmout_obj_t* self) {
|
||||
return self->duty_cycle;
|
||||
}
|
||||
|
||||
void common_hal_pulseio_pwmout_set_frequency(pulseio_pwmout_obj_t* self, uint32_t frequency) {
|
||||
void common_hal_pwmio_pwmout_set_frequency(pwmio_pwmout_obj_t* self, uint32_t frequency) {
|
||||
// COUNTERTOP is 3..32767, so highest available frequency is PWM_MAX_FREQ / 3.
|
||||
uint16_t countertop;
|
||||
nrf_pwm_clk_t base_clock;
|
||||
@ -300,13 +300,13 @@ void common_hal_pulseio_pwmout_set_frequency(pulseio_pwmout_obj_t* self, uint32_
|
||||
nrf_pwm_configure(self->pwm, base_clock, NRF_PWM_MODE_UP, countertop);
|
||||
// Set the duty cycle again, because it depends on COUNTERTOP, which probably changed.
|
||||
// Setting the duty cycle will also do a SEQSTART.
|
||||
common_hal_pulseio_pwmout_set_duty_cycle(self, self->duty_cycle);
|
||||
common_hal_pwmio_pwmout_set_duty_cycle(self, self->duty_cycle);
|
||||
}
|
||||
|
||||
uint32_t common_hal_pulseio_pwmout_get_frequency(pulseio_pwmout_obj_t* self) {
|
||||
uint32_t common_hal_pwmio_pwmout_get_frequency(pwmio_pwmout_obj_t* self) {
|
||||
return self->frequency;
|
||||
}
|
||||
|
||||
bool common_hal_pulseio_pwmout_get_variable_frequency(pulseio_pwmout_obj_t* self) {
|
||||
bool common_hal_pwmio_pwmout_get_variable_frequency(pwmio_pwmout_obj_t* self) {
|
||||
return self->variable_frequency;
|
||||
}
|
@ -24,8 +24,8 @@
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef MICROPY_INCLUDED_NRF_COMMON_HAL_PULSEIO_PWMOUT_H
|
||||
#define MICROPY_INCLUDED_NRF_COMMON_HAL_PULSEIO_PWMOUT_H
|
||||
#ifndef MICROPY_INCLUDED_NRF_COMMON_HAL_PWMIO_PWMOUT_H
|
||||
#define MICROPY_INCLUDED_NRF_COMMON_HAL_PWMIO_PWMOUT_H
|
||||
|
||||
#include "nrfx_pwm.h"
|
||||
#include "py/obj.h"
|
||||
@ -38,7 +38,7 @@ typedef struct {
|
||||
bool variable_frequency: 1;
|
||||
uint16_t duty_cycle;
|
||||
uint32_t frequency;
|
||||
} pulseio_pwmout_obj_t;
|
||||
} pwmio_pwmout_obj_t;
|
||||
|
||||
void pwmout_reset(void);
|
||||
NRF_PWM_Type *pwmout_allocate(uint16_t countertop, nrf_pwm_clk_t base_clock,
|
||||
@ -46,4 +46,4 @@ NRF_PWM_Type *pwmout_allocate(uint16_t countertop, nrf_pwm_clk_t base_clock,
|
||||
IRQn_Type *irq);
|
||||
void pwmout_free_channel(NRF_PWM_Type *pwm, int8_t channel);
|
||||
|
||||
#endif // MICROPY_INCLUDED_NRF_COMMON_HAL_PULSEIO_PWMOUT_H
|
||||
#endif // MICROPY_INCLUDED_NRF_COMMON_HAL_PWMIO_PWMOUT_H
|
1
ports/nrf/common-hal/pwmio/__init__.c
Normal file
1
ports/nrf/common-hal/pwmio/__init__.c
Normal file
@ -0,0 +1 @@
|
||||
// No pwmio module functions.
|
@ -45,9 +45,9 @@
|
||||
#include "common-hal/busio/I2C.h"
|
||||
#include "common-hal/busio/SPI.h"
|
||||
#include "common-hal/busio/UART.h"
|
||||
#include "common-hal/pulseio/PWMOut.h"
|
||||
#include "common-hal/pulseio/PulseOut.h"
|
||||
#include "common-hal/pulseio/PulseIn.h"
|
||||
#include "common-hal/pwmio/PWMOut.h"
|
||||
#include "common-hal/rtc/RTC.h"
|
||||
#include "common-hal/neopixel_write/__init__.h"
|
||||
#include "common-hal/watchdog/WatchDogTimer.h"
|
||||
@ -196,11 +196,14 @@ void reset_port(void) {
|
||||
|
||||
|
||||
#if CIRCUITPY_PULSEIO
|
||||
pwmout_reset();
|
||||
pulseout_reset();
|
||||
pulsein_reset();
|
||||
#endif
|
||||
|
||||
#if CIRCUITPY_PWMIO
|
||||
pwmout_reset();
|
||||
#endif
|
||||
|
||||
#if CIRCUITPY_RTC
|
||||
rtc_reset();
|
||||
#endif
|
||||
|
@ -32,7 +32,7 @@
|
||||
#include "py/gc.h"
|
||||
#include "py/runtime.h"
|
||||
#include "shared-bindings/pulseio/PulseOut.h"
|
||||
#include "shared-bindings/pulseio/PWMOut.h"
|
||||
#include "shared-bindings/pwmio/PWMOut.h"
|
||||
#include "supervisor/shared/translate.h"
|
||||
|
||||
#include STM32_HAL_H
|
||||
@ -113,7 +113,15 @@ void pulseout_reset() {
|
||||
}
|
||||
|
||||
void common_hal_pulseio_pulseout_construct(pulseio_pulseout_obj_t* self,
|
||||
const pulseio_pwmout_obj_t* carrier) {
|
||||
const pwmio_pwmout_obj_t* carrier,
|
||||
const mcu_pin_obj_t* pin,
|
||||
uint32_t frequency,
|
||||
uint16_t duty_cycle) {
|
||||
if (!carrier || pin || frequency) {
|
||||
mp_raise_NotImplementedError(translate("Port does not accept pins or frequency. \
|
||||
Construct and pass a PWMOut Carrier instead"));
|
||||
}
|
||||
|
||||
// Add to active PulseOuts
|
||||
refcount++;
|
||||
TIM_TypeDef * tim_instance = stm_peripherals_find_timer();
|
||||
@ -135,7 +143,7 @@ void common_hal_pulseio_pulseout_construct(pulseio_pulseout_obj_t* self,
|
||||
tim_handle.Instance->SR = 0;
|
||||
|
||||
// The HAL can't work with const, recast required.
|
||||
self->pwmout = (pulseio_pwmout_obj_t*)carrier;
|
||||
self->pwmout = (pwmio_pwmout_obj_t*)carrier;
|
||||
turn_off(self);
|
||||
}
|
||||
|
||||
|
@ -28,13 +28,13 @@
|
||||
#define MICROPY_INCLUDED_STM32F4_COMMON_HAL_PULSEIO_PULSEOUT_H
|
||||
|
||||
#include "common-hal/microcontroller/Pin.h"
|
||||
#include "common-hal/pulseio/PWMOut.h"
|
||||
#include "common-hal/pwmio/PWMOut.h"
|
||||
|
||||
#include "py/obj.h"
|
||||
|
||||
typedef struct {
|
||||
mp_obj_base_t base;
|
||||
pulseio_pwmout_obj_t *pwmout;
|
||||
pwmio_pwmout_obj_t *pwmout;
|
||||
} pulseio_pulseout_obj_t;
|
||||
|
||||
void pulseout_reset(void);
|
||||
|
@ -27,8 +27,8 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include "py/runtime.h"
|
||||
#include "common-hal/pulseio/PWMOut.h"
|
||||
#include "shared-bindings/pulseio/PWMOut.h"
|
||||
#include "common-hal/pwmio/PWMOut.h"
|
||||
#include "shared-bindings/pwmio/PWMOut.h"
|
||||
#include "supervisor/shared/translate.h"
|
||||
|
||||
#include "shared-bindings/microcontroller/__init__.h"
|
||||
@ -75,7 +75,7 @@ void pwmout_reset(void) {
|
||||
}
|
||||
}
|
||||
|
||||
pwmout_result_t common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self,
|
||||
pwmout_result_t common_hal_pwmio_pwmout_construct(pwmio_pwmout_obj_t* self,
|
||||
const mcu_pin_obj_t* pin,
|
||||
uint16_t duty,
|
||||
uint32_t frequency,
|
||||
@ -96,7 +96,7 @@ pwmout_result_t common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self,
|
||||
//if pin is same
|
||||
if (l_tim->pin == pin) {
|
||||
//check if the timer has a channel active, or is reserved by main timer system
|
||||
if (reserved_tim[l_tim_index] != 0) {
|
||||
if (l_tim_index < TIM_BANK_ARRAY_LEN && reserved_tim[l_tim_index] != 0) {
|
||||
// Timer has already been reserved by an internal module
|
||||
if (stm_peripherals_timer_is_reserved(mcu_tim_banks[l_tim_index])) {
|
||||
tim_taken_internal = true;
|
||||
@ -204,7 +204,7 @@ pwmout_result_t common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self,
|
||||
return PWMOUT_OK;
|
||||
}
|
||||
|
||||
void common_hal_pulseio_pwmout_never_reset(pulseio_pwmout_obj_t *self) {
|
||||
void common_hal_pwmio_pwmout_never_reset(pwmio_pwmout_obj_t *self) {
|
||||
for (size_t i = 0; i < TIM_BANK_ARRAY_LEN; i++) {
|
||||
if (mcu_tim_banks[i] == self->handle.Instance) {
|
||||
never_reset_tim[i] = true;
|
||||
@ -214,7 +214,7 @@ void common_hal_pulseio_pwmout_never_reset(pulseio_pwmout_obj_t *self) {
|
||||
}
|
||||
}
|
||||
|
||||
void common_hal_pulseio_pwmout_reset_ok(pulseio_pwmout_obj_t *self) {
|
||||
void common_hal_pwmio_pwmout_reset_ok(pwmio_pwmout_obj_t *self) {
|
||||
for(size_t i = 0; i < TIM_BANK_ARRAY_LEN; i++) {
|
||||
if (mcu_tim_banks[i] == self->handle.Instance) {
|
||||
never_reset_tim[i] = false;
|
||||
@ -223,12 +223,12 @@ void common_hal_pulseio_pwmout_reset_ok(pulseio_pwmout_obj_t *self) {
|
||||
}
|
||||
}
|
||||
|
||||
bool common_hal_pulseio_pwmout_deinited(pulseio_pwmout_obj_t* self) {
|
||||
bool common_hal_pwmio_pwmout_deinited(pwmio_pwmout_obj_t* self) {
|
||||
return self->tim == NULL;
|
||||
}
|
||||
|
||||
void common_hal_pulseio_pwmout_deinit(pulseio_pwmout_obj_t* self) {
|
||||
if (common_hal_pulseio_pwmout_deinited(self)) {
|
||||
void common_hal_pwmio_pwmout_deinit(pwmio_pwmout_obj_t* self) {
|
||||
if (common_hal_pwmio_pwmout_deinited(self)) {
|
||||
return;
|
||||
}
|
||||
//var freq shuts down entire timer, others just their channel
|
||||
@ -248,17 +248,17 @@ void common_hal_pulseio_pwmout_deinit(pulseio_pwmout_obj_t* self) {
|
||||
}
|
||||
}
|
||||
|
||||
void common_hal_pulseio_pwmout_set_duty_cycle(pulseio_pwmout_obj_t* self, uint16_t duty) {
|
||||
void common_hal_pwmio_pwmout_set_duty_cycle(pwmio_pwmout_obj_t* self, uint16_t duty) {
|
||||
uint32_t internal_duty_cycle = timer_get_internal_duty(duty, self->period);
|
||||
__HAL_TIM_SET_COMPARE(&self->handle, self->channel, internal_duty_cycle);
|
||||
self->duty_cycle = duty;
|
||||
}
|
||||
|
||||
uint16_t common_hal_pulseio_pwmout_get_duty_cycle(pulseio_pwmout_obj_t* self) {
|
||||
uint16_t common_hal_pwmio_pwmout_get_duty_cycle(pwmio_pwmout_obj_t* self) {
|
||||
return self->duty_cycle;
|
||||
}
|
||||
|
||||
void common_hal_pulseio_pwmout_set_frequency(pulseio_pwmout_obj_t* self, uint32_t frequency) {
|
||||
void common_hal_pwmio_pwmout_set_frequency(pwmio_pwmout_obj_t* self, uint32_t frequency) {
|
||||
//don't halt setup for the same frequency
|
||||
if (frequency == self->frequency) {
|
||||
return;
|
||||
@ -295,10 +295,10 @@ void common_hal_pulseio_pwmout_set_frequency(pulseio_pwmout_obj_t* self, uint32_
|
||||
self->period = period;
|
||||
}
|
||||
|
||||
uint32_t common_hal_pulseio_pwmout_get_frequency(pulseio_pwmout_obj_t* self) {
|
||||
uint32_t common_hal_pwmio_pwmout_get_frequency(pwmio_pwmout_obj_t* self) {
|
||||
return self->frequency;
|
||||
}
|
||||
|
||||
bool common_hal_pulseio_pwmout_get_variable_frequency(pulseio_pwmout_obj_t* self) {
|
||||
bool common_hal_pwmio_pwmout_get_variable_frequency(pwmio_pwmout_obj_t* self) {
|
||||
return self->variable_frequency;
|
||||
}
|
@ -24,8 +24,8 @@
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef MICROPY_INCLUDED_STM32F4_COMMON_HAL_PULSEIO_PWMOUT_H
|
||||
#define MICROPY_INCLUDED_STM32F4_COMMON_HAL_PULSEIO_PWMOUT_H
|
||||
#ifndef MICROPY_INCLUDED_STM32F4_COMMON_HAL_PWMIO_PWMOUT_H
|
||||
#define MICROPY_INCLUDED_STM32F4_COMMON_HAL_PWMIO_PWMOUT_H
|
||||
|
||||
#include "common-hal/microcontroller/Pin.h"
|
||||
|
||||
@ -44,8 +44,8 @@ typedef struct {
|
||||
uint16_t duty_cycle;
|
||||
uint32_t frequency;
|
||||
uint32_t period;
|
||||
} pulseio_pwmout_obj_t;
|
||||
} pwmio_pwmout_obj_t;
|
||||
|
||||
void pwmout_reset(void);
|
||||
|
||||
#endif // MICROPY_INCLUDED_STM32F4_COMMON_HAL_PULSEIO_PWMOUT_H
|
||||
#endif // MICROPY_INCLUDED_STM32F4_COMMON_HAL_PWMIO_PWMOUT_H
|
1
ports/stm/common-hal/pwmio/__init__.c
Normal file
1
ports/stm/common-hal/pwmio/__init__.c
Normal file
@ -0,0 +1 @@
|
||||
// No pwmio module functions.
|
@ -38,8 +38,8 @@ static inline mp_uint_t mp_hal_ticks_ms(void) {
|
||||
return supervisor_ticks_ms32();
|
||||
}
|
||||
// Number of bytes in receive buffer
|
||||
volatile uint8_t usb_rx_count;
|
||||
volatile bool mp_cdc_enabled;
|
||||
extern volatile uint8_t usb_rx_count;
|
||||
extern volatile bool mp_cdc_enabled;
|
||||
|
||||
int receive_usb(void);
|
||||
|
||||
|
@ -51,7 +51,7 @@ extern const mcu_periph_obj_t mcu_uart_rx_list[6];
|
||||
//Timers
|
||||
#define TIM_BANK_ARRAY_LEN 14
|
||||
#define TIM_PIN_ARRAY_LEN 44
|
||||
TIM_TypeDef * mcu_tim_banks[TIM_BANK_ARRAY_LEN];
|
||||
const mcu_tim_pin_obj_t mcu_tim_pin_list[TIM_PIN_ARRAY_LEN];
|
||||
extern TIM_TypeDef * mcu_tim_banks[TIM_BANK_ARRAY_LEN];
|
||||
extern const mcu_tim_pin_obj_t mcu_tim_pin_list[TIM_PIN_ARRAY_LEN];
|
||||
|
||||
#endif // MICROPY_INCLUDED_STM32_PERIPHERALS_STM32F401XE_PERIPH_H
|
||||
|
@ -58,8 +58,8 @@ extern const mcu_periph_obj_t mcu_uart_rx_list[UART_RX_ARRAY_LEN];
|
||||
//Timers
|
||||
#define TIM_BANK_ARRAY_LEN 14
|
||||
#define TIM_PIN_ARRAY_LEN 67
|
||||
TIM_TypeDef * mcu_tim_banks[TIM_BANK_ARRAY_LEN];
|
||||
const mcu_tim_pin_obj_t mcu_tim_pin_list[TIM_PIN_ARRAY_LEN];
|
||||
extern TIM_TypeDef * mcu_tim_banks[TIM_BANK_ARRAY_LEN];
|
||||
extern const mcu_tim_pin_obj_t mcu_tim_pin_list[TIM_PIN_ARRAY_LEN];
|
||||
|
||||
//SDIO
|
||||
extern SDIO_TypeDef * mcu_sdio_banks[1];
|
||||
|
@ -51,7 +51,7 @@ extern const mcu_periph_obj_t mcu_uart_rx_list[12];
|
||||
//Timers
|
||||
#define TIM_BANK_ARRAY_LEN 14
|
||||
#define TIM_PIN_ARRAY_LEN 56
|
||||
TIM_TypeDef * mcu_tim_banks[TIM_BANK_ARRAY_LEN];
|
||||
const mcu_tim_pin_obj_t mcu_tim_pin_list[TIM_PIN_ARRAY_LEN];
|
||||
extern TIM_TypeDef * mcu_tim_banks[TIM_BANK_ARRAY_LEN];
|
||||
extern const mcu_tim_pin_obj_t mcu_tim_pin_list[TIM_PIN_ARRAY_LEN];
|
||||
|
||||
#endif // MICROPY_INCLUDED_STM32_PERIPHERALS_STM32F407XX_PERIPH_H
|
||||
|
@ -51,7 +51,7 @@ extern const mcu_periph_obj_t mcu_uart_rx_list[7];
|
||||
//Timers
|
||||
#define TIM_BANK_ARRAY_LEN 14
|
||||
#define TIM_PIN_ARRAY_LEN 44
|
||||
TIM_TypeDef * mcu_tim_banks[TIM_BANK_ARRAY_LEN];
|
||||
const mcu_tim_pin_obj_t mcu_tim_pin_list[TIM_PIN_ARRAY_LEN];
|
||||
extern TIM_TypeDef * mcu_tim_banks[TIM_BANK_ARRAY_LEN];
|
||||
extern const mcu_tim_pin_obj_t mcu_tim_pin_list[TIM_PIN_ARRAY_LEN];
|
||||
|
||||
#endif // MICROPY_INCLUDED_STM32_PERIPHERALS_STM32F411XE_PERIPH_H
|
||||
|
@ -52,7 +52,7 @@ extern const mcu_periph_obj_t mcu_uart_rx_list[12];
|
||||
//Timers
|
||||
#define TIM_BANK_ARRAY_LEN 14
|
||||
#define TIM_PIN_ARRAY_LEN 60
|
||||
TIM_TypeDef * mcu_tim_banks[TIM_BANK_ARRAY_LEN];
|
||||
const mcu_tim_pin_obj_t mcu_tim_pin_list[TIM_PIN_ARRAY_LEN];
|
||||
extern TIM_TypeDef * mcu_tim_banks[TIM_BANK_ARRAY_LEN];
|
||||
extern const mcu_tim_pin_obj_t mcu_tim_pin_list[TIM_PIN_ARRAY_LEN];
|
||||
|
||||
#endif // MICROPY_INCLUDED_STM32_PERIPHERALS_STM32F412ZX_PERIPH_H
|
||||
|
@ -31,28 +31,28 @@
|
||||
//I2C
|
||||
extern I2C_TypeDef * mcu_i2c_banks[4];
|
||||
|
||||
const mcu_periph_obj_t mcu_i2c_sda_list[10];
|
||||
const mcu_periph_obj_t mcu_i2c_scl_list[10];
|
||||
extern const mcu_periph_obj_t mcu_i2c_sda_list[10];
|
||||
extern const mcu_periph_obj_t mcu_i2c_scl_list[10];
|
||||
|
||||
//SPI
|
||||
extern SPI_TypeDef * mcu_spi_banks[6];
|
||||
|
||||
const mcu_periph_obj_t mcu_spi_sck_list[14];
|
||||
const mcu_periph_obj_t mcu_spi_mosi_list[15];
|
||||
const mcu_periph_obj_t mcu_spi_miso_list[12];
|
||||
extern const mcu_periph_obj_t mcu_spi_sck_list[14];
|
||||
extern const mcu_periph_obj_t mcu_spi_mosi_list[15];
|
||||
extern const mcu_periph_obj_t mcu_spi_miso_list[12];
|
||||
|
||||
//UART
|
||||
extern USART_TypeDef * mcu_uart_banks[MAX_UART];
|
||||
extern bool mcu_uart_has_usart[MAX_UART];
|
||||
|
||||
const mcu_periph_obj_t mcu_uart_tx_list[15];
|
||||
const mcu_periph_obj_t mcu_uart_rx_list[15];
|
||||
extern const mcu_periph_obj_t mcu_uart_tx_list[15];
|
||||
extern const mcu_periph_obj_t mcu_uart_rx_list[15];
|
||||
|
||||
//Timers
|
||||
#define TIM_BANK_ARRAY_LEN 14
|
||||
#define TIM_PIN_ARRAY_LEN 55
|
||||
extern TIM_TypeDef * mcu_tim_banks[TIM_BANK_ARRAY_LEN];
|
||||
|
||||
const mcu_tim_pin_obj_t mcu_tim_pin_list[TIM_PIN_ARRAY_LEN];
|
||||
extern const mcu_tim_pin_obj_t mcu_tim_pin_list[TIM_PIN_ARRAY_LEN];
|
||||
|
||||
#endif // MICROPY_INCLUDED_STM32_PERIPHERALS_STM32F746XX_PERIPH_H
|
||||
|
@ -30,28 +30,28 @@
|
||||
//I2C
|
||||
extern I2C_TypeDef * mcu_i2c_banks[4];
|
||||
|
||||
const mcu_periph_obj_t mcu_i2c_sda_list[12];
|
||||
const mcu_periph_obj_t mcu_i2c_scl_list[12];
|
||||
extern const mcu_periph_obj_t mcu_i2c_sda_list[12];
|
||||
extern const mcu_periph_obj_t mcu_i2c_scl_list[12];
|
||||
|
||||
//SPI
|
||||
extern SPI_TypeDef * mcu_spi_banks[6];
|
||||
|
||||
const mcu_periph_obj_t mcu_spi_sck_list[18];
|
||||
const mcu_periph_obj_t mcu_spi_mosi_list[18];
|
||||
const mcu_periph_obj_t mcu_spi_miso_list[15];
|
||||
extern const mcu_periph_obj_t mcu_spi_sck_list[18];
|
||||
extern const mcu_periph_obj_t mcu_spi_mosi_list[18];
|
||||
extern const mcu_periph_obj_t mcu_spi_miso_list[15];
|
||||
|
||||
//UART
|
||||
extern USART_TypeDef * mcu_uart_banks[MAX_UART];
|
||||
extern bool mcu_uart_has_usart[MAX_UART];
|
||||
|
||||
const mcu_periph_obj_t mcu_uart_tx_list[24];
|
||||
const mcu_periph_obj_t mcu_uart_rx_list[25];
|
||||
extern const mcu_periph_obj_t mcu_uart_tx_list[24];
|
||||
extern const mcu_periph_obj_t mcu_uart_rx_list[25];
|
||||
|
||||
//Timers
|
||||
#define TIM_BANK_ARRAY_LEN 14
|
||||
#define TIM_PIN_ARRAY_LEN 55
|
||||
TIM_TypeDef * mcu_tim_banks[TIM_BANK_ARRAY_LEN];
|
||||
extern TIM_TypeDef * mcu_tim_banks[TIM_BANK_ARRAY_LEN];
|
||||
|
||||
const mcu_tim_pin_obj_t mcu_tim_pin_list[TIM_PIN_ARRAY_LEN];
|
||||
extern const mcu_tim_pin_obj_t mcu_tim_pin_list[TIM_PIN_ARRAY_LEN];
|
||||
|
||||
#endif // MICROPY_INCLUDED_STM32_PERIPHERALS_STM32F767XX_PERIPH_H
|
||||
|
@ -30,26 +30,26 @@
|
||||
//I2C
|
||||
extern I2C_TypeDef * mcu_i2c_banks[4];
|
||||
|
||||
const mcu_periph_obj_t mcu_i2c_sda_list[12];
|
||||
const mcu_periph_obj_t mcu_i2c_scl_list[12];
|
||||
extern const mcu_periph_obj_t mcu_i2c_sda_list[12];
|
||||
extern const mcu_periph_obj_t mcu_i2c_scl_list[12];
|
||||
|
||||
//SPI
|
||||
extern SPI_TypeDef * mcu_spi_banks[6];
|
||||
|
||||
const mcu_periph_obj_t mcu_spi_sck_list[19];
|
||||
const mcu_periph_obj_t mcu_spi_mosi_list[19];
|
||||
const mcu_periph_obj_t mcu_spi_miso_list[16];
|
||||
extern const mcu_periph_obj_t mcu_spi_sck_list[19];
|
||||
extern const mcu_periph_obj_t mcu_spi_mosi_list[19];
|
||||
extern const mcu_periph_obj_t mcu_spi_miso_list[16];
|
||||
|
||||
//UART
|
||||
extern USART_TypeDef * mcu_uart_banks[MAX_UART];
|
||||
extern bool mcu_uart_has_usart[MAX_UART];
|
||||
|
||||
const mcu_periph_obj_t mcu_uart_tx_list[25];
|
||||
const mcu_periph_obj_t mcu_uart_rx_list[26];
|
||||
extern const mcu_periph_obj_t mcu_uart_tx_list[25];
|
||||
extern const mcu_periph_obj_t mcu_uart_rx_list[26];
|
||||
|
||||
//Timers
|
||||
#define TIM_BANK_ARRAY_LEN 14
|
||||
#define TIM_PIN_ARRAY_LEN 58
|
||||
TIM_TypeDef * mcu_tim_banks[TIM_BANK_ARRAY_LEN];
|
||||
extern TIM_TypeDef * mcu_tim_banks[TIM_BANK_ARRAY_LEN];
|
||||
|
||||
#endif // MICROPY_INCLUDED_STM32_PERIPHERALS_STM32H743XX_PERIPH_H
|
||||
|
@ -177,13 +177,13 @@ void port_internal_flash_flush(void) {
|
||||
EraseInitStruct.VoltageRange = VOLTAGE_RANGE_3; // voltage range needs to be 2.7V to 3.6V
|
||||
// get the sector information
|
||||
uint32_t sector_size;
|
||||
uint32_t sector_start_addr;
|
||||
uint32_t sector_start_addr = 0xffffffff;
|
||||
#if defined(STM32H7)
|
||||
EraseInitStruct.Banks = get_bank(_cache_flash_addr);
|
||||
#endif
|
||||
EraseInitStruct.Sector = flash_get_sector_info(_cache_flash_addr, §or_start_addr, §or_size);
|
||||
EraseInitStruct.NbSectors = 1;
|
||||
if (sector_size > sizeof(_flash_cache)) {
|
||||
if (sector_size > sizeof(_flash_cache) || sector_start_addr == 0xffffffff) {
|
||||
reset_into_safe_mode(FLASH_WRITE_FAIL);
|
||||
}
|
||||
|
||||
|
@ -38,9 +38,13 @@
|
||||
#include "common-hal/busio/UART.h"
|
||||
#endif
|
||||
#if CIRCUITPY_PULSEIO
|
||||
#include "common-hal/pulseio/PWMOut.h"
|
||||
#include "common-hal/pulseio/PulseOut.h"
|
||||
#include "common-hal/pulseio/PulseIn.h"
|
||||
#endif
|
||||
#if CIRCUITPY_PWMIO
|
||||
#include "common-hal/pwmio/PWMOut.h"
|
||||
#endif
|
||||
#if CIRCUITPY_PULSEIO || CIRCUITPY_PWMIO
|
||||
#include "timers.h"
|
||||
#endif
|
||||
#if CIRCUITPY_SDIOIO
|
||||
@ -230,12 +234,16 @@ void reset_port(void) {
|
||||
#if CIRCUITPY_SDIOIO
|
||||
sdioio_reset();
|
||||
#endif
|
||||
#if CIRCUITPY_PULSEIO
|
||||
#if CIRCUITPY_PULSEIO || CIRCUITPY_PWMIO
|
||||
timers_reset();
|
||||
pwmout_reset();
|
||||
#endif
|
||||
#if CIRCUITPY_PULSEIO
|
||||
pulseout_reset();
|
||||
pulsein_reset();
|
||||
#endif
|
||||
#if CIRCUITPY_PWMIO
|
||||
pwmout_reset();
|
||||
#endif
|
||||
}
|
||||
|
||||
void reset_to_bootloader(void) {
|
||||
|
@ -201,11 +201,14 @@ endif
|
||||
ifeq ($(CIRCUITPY_RGBMATRIX),1)
|
||||
SRC_PATTERNS += rgbmatrix/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_PS2IO),1)
|
||||
SRC_PATTERNS += ps2io/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_PULSEIO),1)
|
||||
SRC_PATTERNS += pulseio/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_PS2IO),1)
|
||||
SRC_PATTERNS += ps2io/%
|
||||
ifeq ($(CIRCUITPY_PWMIO),1)
|
||||
SRC_PATTERNS += pwmio/%
|
||||
endif
|
||||
ifeq ($(CIRCUITPY_RANDOM),1)
|
||||
SRC_PATTERNS += random/%
|
||||
@ -328,10 +331,11 @@ SRC_COMMON_HAL_ALL = \
|
||||
os/__init__.c \
|
||||
ps2io/Ps2.c \
|
||||
ps2io/__init__.c \
|
||||
pulseio/PWMOut.c \
|
||||
pulseio/PulseIn.c \
|
||||
pulseio/PulseOut.c \
|
||||
pulseio/__init__.c \
|
||||
pwmio/PWMOut.c \
|
||||
pwmio/__init__.c \
|
||||
rgbmatrix/RGBMatrix.c \
|
||||
rgbmatrix/__init__.c \
|
||||
rotaryio/IncrementalEncoder.c \
|
||||
|
@ -517,6 +517,13 @@ extern const struct _mp_obj_module_t pixelbuf_module;
|
||||
#define PIXELBUF_MODULE
|
||||
#endif
|
||||
|
||||
#if CIRCUITPY_PS2IO
|
||||
extern const struct _mp_obj_module_t ps2io_module;
|
||||
#define PS2IO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_ps2io), (mp_obj_t)&ps2io_module },
|
||||
#else
|
||||
#define PS2IO_MODULE
|
||||
#endif
|
||||
|
||||
#if CIRCUITPY_PULSEIO
|
||||
extern const struct _mp_obj_module_t pulseio_module;
|
||||
#define PULSEIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_pulseio), (mp_obj_t)&pulseio_module },
|
||||
@ -524,11 +531,11 @@ extern const struct _mp_obj_module_t pulseio_module;
|
||||
#define PULSEIO_MODULE
|
||||
#endif
|
||||
|
||||
#if CIRCUITPY_PS2IO
|
||||
extern const struct _mp_obj_module_t ps2io_module;
|
||||
#define PS2IO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_ps2io), (mp_obj_t)&ps2io_module },
|
||||
#if CIRCUITPY_PWMIO
|
||||
extern const struct _mp_obj_module_t pwmio_module;
|
||||
#define PWMIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_pwmio), (mp_obj_t)&pwmio_module },
|
||||
#else
|
||||
#define PS2IO_MODULE
|
||||
#define PWMIO_MODULE
|
||||
#endif
|
||||
|
||||
#if CIRCUITPY_RGBMATRIX
|
||||
@ -778,6 +785,7 @@ extern const struct _mp_obj_module_t wifi_module;
|
||||
PIXELBUF_MODULE \
|
||||
PS2IO_MODULE \
|
||||
PULSEIO_MODULE \
|
||||
PWMIO_MODULE \
|
||||
RANDOM_MODULE \
|
||||
RE_MODULE \
|
||||
RGBMATRIX_MODULE \
|
||||
|
@ -157,19 +157,24 @@ CFLAGS += -DCIRCUITPY_OS=$(CIRCUITPY_OS)
|
||||
CIRCUITPY_PIXELBUF ?= $(CIRCUITPY_FULL_BUILD)
|
||||
CFLAGS += -DCIRCUITPY_PIXELBUF=$(CIRCUITPY_PIXELBUF)
|
||||
|
||||
CIRCUITPY_RGBMATRIX ?= 0
|
||||
CFLAGS += -DCIRCUITPY_RGBMATRIX=$(CIRCUITPY_RGBMATRIX)
|
||||
|
||||
CIRCUITPY_PULSEIO ?= 1
|
||||
CFLAGS += -DCIRCUITPY_PULSEIO=$(CIRCUITPY_PULSEIO)
|
||||
|
||||
# Only for SAMD boards for the moment
|
||||
CIRCUITPY_PS2IO ?= 0
|
||||
CFLAGS += -DCIRCUITPY_PS2IO=$(CIRCUITPY_PS2IO)
|
||||
|
||||
CIRCUITPY_PULSEIO ?= 1
|
||||
CFLAGS += -DCIRCUITPY_PULSEIO=$(CIRCUITPY_PULSEIO)
|
||||
|
||||
# For now we tie PWMIO to PULSEIO so they always both exist. In CircuitPython 7
|
||||
# we can enable and disable them separately once PWMOut is removed from `pulseio`.
|
||||
CIRCUITPY_PWMIO = $(CIRCUITPY_PULSEIO)
|
||||
CFLAGS += -DCIRCUITPY_PWMIO=$(CIRCUITPY_PWMIO)
|
||||
|
||||
CIRCUITPY_RANDOM ?= 1
|
||||
CFLAGS += -DCIRCUITPY_RANDOM=$(CIRCUITPY_RANDOM)
|
||||
|
||||
CIRCUITPY_RGBMATRIX ?= 0
|
||||
CFLAGS += -DCIRCUITPY_RGBMATRIX=$(CIRCUITPY_RGBMATRIX)
|
||||
|
||||
CIRCUITPY_ROTARYIO ?= 1
|
||||
CFLAGS += -DCIRCUITPY_ROTARYIO=$(CIRCUITPY_ROTARYIO)
|
||||
|
||||
|
@ -35,7 +35,7 @@
|
||||
#include "py/objstr.h"
|
||||
#include "shared-module/_bleio/Address.h"
|
||||
|
||||
const mp_obj_type_t bleio_adapter_type;
|
||||
extern const mp_obj_type_t bleio_adapter_type;
|
||||
|
||||
extern bool common_hal_bleio_adapter_get_advertising(bleio_adapter_obj_t *self);
|
||||
extern bool common_hal_bleio_adapter_get_enabled(bleio_adapter_obj_t *self);
|
||||
|
@ -34,7 +34,7 @@
|
||||
|
||||
#include "py/objtuple.h"
|
||||
|
||||
const mp_obj_type_t bleio_service_type;
|
||||
extern const mp_obj_type_t bleio_service_type;
|
||||
|
||||
// Private version that doesn't allocate on the heap
|
||||
extern uint32_t _common_hal_bleio_service_construct(bleio_service_obj_t *self, bleio_uuid_obj_t *uuid, bool is_secondary, mp_obj_list_t * characteristic_list);
|
||||
|
@ -172,7 +172,109 @@ STATIC mp_obj_t bitmap_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t val
|
||||
return mp_const_none;
|
||||
}
|
||||
|
||||
//| def fill(self, value: int) -> None:
|
||||
//| def blit(self, x: int, y: int, source_bitmap: bitmap, *, x1: int, y1: int, x2: int, y2: int, skip_index: int) -> None:
|
||||
//| """Inserts the source_bitmap region defined by rectangular boundaries
|
||||
//| (x1,y1) and (x2,y2) into the bitmap at the specified (x,y) location.
|
||||
//|
|
||||
//| :param int x: Horizontal pixel location in bitmap where source_bitmap upper-left
|
||||
//| corner will be placed
|
||||
//| :param int y: Vertical pixel location in bitmap where source_bitmap upper-left
|
||||
//| corner will be placed
|
||||
//| :param bitmap source_bitmap: Source bitmap that contains the graphical region to be copied
|
||||
//| :param int x1: Minimum x-value for rectangular bounding box to be copied from the source bitmap
|
||||
//| :param int y1: Minimum y-value for rectangular bounding box to be copied from the source bitmap
|
||||
//| :param int x2: Maximum x-value (exclusive) for rectangular bounding box to be copied from the source bitmap
|
||||
//| :param int y2: Maximum y-value (exclusive) for rectangular bounding box to be copied from the source bitmap
|
||||
//| :param int skip_index: bitmap palette index in the source that will not be copied,
|
||||
//| set to None to copy all pixels"""
|
||||
//| ...
|
||||
//|
|
||||
STATIC mp_obj_t displayio_bitmap_obj_blit(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args){
|
||||
enum {ARG_x, ARG_y, ARG_source, ARG_x1, ARG_y1, ARG_x2, ARG_y2, ARG_skip_index};
|
||||
static const mp_arg_t allowed_args[] = {
|
||||
{MP_QSTR_x, MP_ARG_REQUIRED | MP_ARG_INT},
|
||||
{MP_QSTR_y, MP_ARG_REQUIRED | MP_ARG_INT},
|
||||
{MP_QSTR_source_bitmap, MP_ARG_REQUIRED | MP_ARG_OBJ},
|
||||
{MP_QSTR_x1, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} },
|
||||
{MP_QSTR_y1, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} },
|
||||
{MP_QSTR_x2, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} }, // None convert to source->width
|
||||
{MP_QSTR_y2, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} }, // None convert to source->height
|
||||
{MP_QSTR_skip_index, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj=mp_const_none} },
|
||||
};
|
||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||
|
||||
displayio_bitmap_t *self = MP_OBJ_TO_PTR(pos_args[0]);
|
||||
|
||||
int16_t x = args[ARG_x].u_int;
|
||||
int16_t y = args[ARG_y].u_int;
|
||||
|
||||
displayio_bitmap_t *source = MP_OBJ_TO_PTR(args[ARG_source].u_obj);
|
||||
|
||||
// ensure that the target bitmap (self) has at least as many `bits_per_value` as the source
|
||||
if (self->bits_per_value < source->bits_per_value) {
|
||||
mp_raise_ValueError(translate("source palette too large"));
|
||||
}
|
||||
|
||||
int16_t x1 = args[ARG_x1].u_int;
|
||||
int16_t y1 = args[ARG_y1].u_int;
|
||||
int16_t x2, y2;
|
||||
// if x2 or y2 is None, then set as the maximum size of the source bitmap
|
||||
if ( args[ARG_x2].u_obj == mp_const_none ) {
|
||||
x2 = source->width;
|
||||
} else {
|
||||
x2 = mp_obj_get_int(args[ARG_x2].u_obj);
|
||||
}
|
||||
//int16_t y2;
|
||||
if ( args[ARG_y2].u_obj == mp_const_none ) {
|
||||
y2 = source->height;
|
||||
} else {
|
||||
y2 = mp_obj_get_int(args[ARG_y2].u_obj);
|
||||
}
|
||||
|
||||
// Check x,y are within self (target) bitmap boundary
|
||||
if ( (x < 0) || (y < 0) || (x > self->width) || (y > self->height) ) {
|
||||
mp_raise_ValueError(translate("out of range of target"));
|
||||
}
|
||||
// Check x1,y1,x2,y2 are within source bitmap boundary
|
||||
if ( (x1 < 0) || (x1 > source->width) ||
|
||||
(y1 < 0) || (y1 > source->height) ||
|
||||
(x2 < 0) || (x2 > source->width) ||
|
||||
(y2 < 0) || (y2 > source->height) ) {
|
||||
mp_raise_ValueError(translate("out of range of source"));
|
||||
}
|
||||
|
||||
// Ensure x1 < x2 and y1 < y2
|
||||
if (x1 > x2) {
|
||||
int16_t temp=x2;
|
||||
x2=x1;
|
||||
x1=temp;
|
||||
}
|
||||
if (y1 > y2) {
|
||||
int16_t temp=y2;
|
||||
y2=y1;
|
||||
y1=temp;
|
||||
}
|
||||
|
||||
uint32_t skip_index;
|
||||
bool skip_index_none; // flag whether skip_value was None
|
||||
|
||||
if (args[ARG_skip_index].u_obj == mp_const_none ) {
|
||||
skip_index = 0;
|
||||
skip_index_none = true;
|
||||
} else {
|
||||
skip_index = mp_obj_get_int(args[ARG_skip_index].u_obj);
|
||||
skip_index_none = false;
|
||||
}
|
||||
|
||||
common_hal_displayio_bitmap_blit(self, x, y, source, x1, y1, x2, y2, skip_index, skip_index_none);
|
||||
|
||||
return mp_const_none;
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_KW(displayio_bitmap_blit_obj, 4, displayio_bitmap_obj_blit);
|
||||
// `displayio_bitmap_obj_blit` requires at least 4 arguments
|
||||
|
||||
//| def fill(self, value: Any) -> None:
|
||||
//| """Fills the bitmap with the supplied palette index value."""
|
||||
//| ...
|
||||
//|
|
||||
@ -192,6 +294,7 @@ MP_DEFINE_CONST_FUN_OBJ_2(displayio_bitmap_fill_obj, displayio_bitmap_obj_fill);
|
||||
STATIC const mp_rom_map_elem_t displayio_bitmap_locals_dict_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR_height), MP_ROM_PTR(&displayio_bitmap_height_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_width), MP_ROM_PTR(&displayio_bitmap_width_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_blit), MP_ROM_PTR(&displayio_bitmap_blit_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_fill), MP_ROM_PTR(&displayio_bitmap_fill_obj) },
|
||||
|
||||
};
|
||||
|
@ -40,6 +40,9 @@ uint16_t common_hal_displayio_bitmap_get_height(displayio_bitmap_t *self);
|
||||
uint16_t common_hal_displayio_bitmap_get_width(displayio_bitmap_t *self);
|
||||
uint32_t common_hal_displayio_bitmap_get_bits_per_value(displayio_bitmap_t *self);
|
||||
void common_hal_displayio_bitmap_set_pixel(displayio_bitmap_t *bitmap, int16_t x, int16_t y, uint32_t value);
|
||||
void common_hal_displayio_bitmap_blit(displayio_bitmap_t *self, int16_t x, int16_t y, displayio_bitmap_t *source,
|
||||
int16_t x1, int16_t y1, int16_t x2, int16_t y2,
|
||||
uint32_t skip_index, bool skip_index_none);
|
||||
uint32_t common_hal_displayio_bitmap_get_pixel(displayio_bitmap_t *bitmap, int16_t x, int16_t y);
|
||||
void common_hal_displayio_bitmap_fill(displayio_bitmap_t *bitmap, uint32_t value);
|
||||
|
||||
|
@ -13,7 +13,7 @@ typedef enum {
|
||||
POSITIONFIX_3D,
|
||||
} gnss_positionfix_t;
|
||||
|
||||
const mp_obj_type_t gnss_positionfix_type;
|
||||
extern const mp_obj_type_t gnss_positionfix_type;
|
||||
|
||||
gnss_positionfix_t gnss_positionfix_obj_to_type(mp_obj_t obj);
|
||||
mp_obj_t gnss_positionfix_type_to_obj(gnss_positionfix_t mode);
|
||||
|
@ -16,7 +16,7 @@ typedef enum {
|
||||
SATELLITESYSTEM_QZSS_L1S = (1U << 4),
|
||||
} gnss_satellitesystem_t;
|
||||
|
||||
const mp_obj_type_t gnss_satellitesystem_type;
|
||||
extern const mp_obj_type_t gnss_satellitesystem_type;
|
||||
|
||||
gnss_satellitesystem_t gnss_satellitesystem_obj_to_type(mp_obj_t obj);
|
||||
mp_obj_t gnss_satellitesystem_type_to_obj(gnss_satellitesystem_t mode);
|
||||
|
@ -32,7 +32,7 @@
|
||||
|
||||
#include "shared-bindings/microcontroller/Pin.h"
|
||||
#include "shared-bindings/pulseio/PulseOut.h"
|
||||
#include "shared-bindings/pulseio/PWMOut.h"
|
||||
#include "shared-bindings/pwmio/PWMOut.h"
|
||||
#include "shared-bindings/util.h"
|
||||
#include "supervisor/shared/translate.h"
|
||||
|
||||
@ -41,19 +41,20 @@
|
||||
//| pulsed signal consists of timed on and off periods. Unlike PWM, there is no set duration
|
||||
//| for on and off pairs."""
|
||||
//|
|
||||
//| def __init__(self, carrier: PWMOut) -> None:
|
||||
//| def __init__(self, carrier: pwmio.PWMOut) -> None:
|
||||
//| """Create a PulseOut object associated with the given PWMout object.
|
||||
//|
|
||||
//| :param ~pulseio.PWMOut carrier: PWMOut that is set to output on the desired pin.
|
||||
//| :param ~pwmio.PWMOut carrier: PWMOut that is set to output on the desired pin.
|
||||
//|
|
||||
//| Send a short series of pulses::
|
||||
//|
|
||||
//| import array
|
||||
//| import pulseio
|
||||
//| import pwmio
|
||||
//| import board
|
||||
//|
|
||||
//| # 50% duty cycle at 38kHz.
|
||||
//| pwm = pulseio.PWMOut(board.D13, frequency=38000, duty_cycle=32768)
|
||||
//| pwm = pwmio.PWMOut(board.D13, frequency=38000, duty_cycle=32768)
|
||||
//| pulse = pulseio.PulseOut(pwm)
|
||||
//| # on off on off on
|
||||
//| pulses = array.array('H', [65000, 1000, 65000, 65000, 1000])
|
||||
@ -64,20 +65,28 @@
|
||||
//| pulse.send(pulses)"""
|
||||
//| ...
|
||||
//|
|
||||
STATIC mp_obj_t pulseio_pulseout_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
mp_arg_check_num(n_args, kw_args, 1, 1, false);
|
||||
mp_obj_t carrier_obj = args[0];
|
||||
|
||||
if (!MP_OBJ_IS_TYPE(carrier_obj, &pulseio_pwmout_type)) {
|
||||
mp_raise_TypeError_varg(translate("Expected a %q"), pulseio_pwmout_type.name);
|
||||
}
|
||||
|
||||
// create Pulse object from the given pin
|
||||
STATIC mp_obj_t pulseio_pulseout_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||
pulseio_pulseout_obj_t *self = m_new_obj(pulseio_pulseout_obj_t);
|
||||
self->base.type = &pulseio_pulseout_type;
|
||||
|
||||
common_hal_pulseio_pulseout_construct(self, (pulseio_pwmout_obj_t *)MP_OBJ_TO_PTR(carrier_obj));
|
||||
|
||||
mp_obj_t carrier_obj = pos_args[0];
|
||||
if (MP_OBJ_IS_TYPE(carrier_obj, &pwmio_pwmout_type)) {
|
||||
// Use a PWMOut Carrier
|
||||
mp_arg_check_num(n_args, kw_args, 1, 1, false);
|
||||
common_hal_pulseio_pulseout_construct(self, (pwmio_pwmout_obj_t *)MP_OBJ_TO_PTR(carrier_obj), NULL, 0, 0);
|
||||
} else {
|
||||
// Use a Pin, frequency, and duty cycle
|
||||
enum { ARG_pin, ARG_frequency};
|
||||
static const mp_arg_t allowed_args[] = {
|
||||
{ MP_QSTR_pin, MP_ARG_REQUIRED | MP_ARG_OBJ },
|
||||
{ MP_QSTR_frequency, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 38000} },
|
||||
{ MP_QSTR_duty_cycle, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 1<<15} },
|
||||
};
|
||||
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);
|
||||
common_hal_pulseio_pulseout_construct(self, NULL, pin, args[ARG_frequency].u_int, args[ARG_frequency].u_int);
|
||||
}
|
||||
return MP_OBJ_FROM_PTR(self);
|
||||
}
|
||||
|
||||
|
@ -29,12 +29,16 @@
|
||||
|
||||
#include "common-hal/microcontroller/Pin.h"
|
||||
#include "common-hal/pulseio/PulseOut.h"
|
||||
#include "common-hal/pulseio/PWMOut.h"
|
||||
#include "common-hal/pwmio/PWMOut.h"
|
||||
|
||||
extern const mp_obj_type_t pulseio_pulseout_type;
|
||||
|
||||
extern void common_hal_pulseio_pulseout_construct(pulseio_pulseout_obj_t* self,
|
||||
const pulseio_pwmout_obj_t* carrier);
|
||||
const pwmio_pwmout_obj_t* carrier,
|
||||
const mcu_pin_obj_t* pin,
|
||||
uint32_t frequency,
|
||||
uint16_t duty_cycle);
|
||||
|
||||
extern void common_hal_pulseio_pulseout_deinit(pulseio_pulseout_obj_t* self);
|
||||
extern bool common_hal_pulseio_pulseout_deinited(pulseio_pulseout_obj_t* self);
|
||||
extern void common_hal_pulseio_pulseout_send(pulseio_pulseout_obj_t* self,
|
||||
|
@ -33,40 +33,29 @@
|
||||
#include "shared-bindings/pulseio/__init__.h"
|
||||
#include "shared-bindings/pulseio/PulseIn.h"
|
||||
#include "shared-bindings/pulseio/PulseOut.h"
|
||||
#include "shared-bindings/pulseio/PWMOut.h"
|
||||
#include "shared-bindings/pwmio/PWMOut.h"
|
||||
|
||||
//| """Support for pulse based protocols
|
||||
//| """Support for individual pulse based protocols
|
||||
//|
|
||||
//| The `pulseio` module contains classes to provide access to basic pulse IO.
|
||||
//| Individual pulses are commonly used in infrared remotes and in DHT
|
||||
//| temperature sensors.
|
||||
//|
|
||||
//|
|
||||
//| .. warning:: PWMOut is moving to `pwmio` and will be removed from `pulseio`
|
||||
//| in CircuitPython 7.
|
||||
//|
|
||||
|
||||
//| All classes change hardware state and should be deinitialized when they
|
||||
//| are no longer needed if the program continues after use. To do so, either
|
||||
//| call :py:meth:`!deinit` or use a context manager. See
|
||||
//| :ref:`lifetime-and-contextmanagers` for more info.
|
||||
//|
|
||||
//| For example::
|
||||
//|
|
||||
//| import pulseio
|
||||
//| import time
|
||||
//| from board import *
|
||||
//|
|
||||
//| pwm = pulseio.PWMOut(D13)
|
||||
//| pwm.duty_cycle = 2 ** 15
|
||||
//| time.sleep(0.1)
|
||||
//|
|
||||
//| This example will initialize the the device, set
|
||||
//| :py:data:`~pulseio.PWMOut.duty_cycle`, and then sleep 0.1 seconds.
|
||||
//| CircuitPython will automatically turn off the PWM when it resets all
|
||||
//| hardware after program completion. Use ``deinit()`` or a ``with`` statement
|
||||
//| to do it yourself."""
|
||||
//| :ref:`lifetime-and-contextmanagers` for more info."""
|
||||
//|
|
||||
|
||||
STATIC const mp_rom_map_elem_t pulseio_module_globals_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_pulseio) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_PulseIn), MP_ROM_PTR(&pulseio_pulsein_type) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_PulseOut), MP_ROM_PTR(&pulseio_pulseout_type) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_PWMOut), MP_ROM_PTR(&pulseio_pwmout_type) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_PWMOut), MP_ROM_PTR(&pwmio_pwmout_type) },
|
||||
};
|
||||
|
||||
STATIC MP_DEFINE_CONST_DICT(pulseio_module_globals, pulseio_module_globals_table);
|
||||
|
@ -31,7 +31,7 @@
|
||||
#include "py/runtime.h"
|
||||
|
||||
#include "shared-bindings/microcontroller/Pin.h"
|
||||
#include "shared-bindings/pulseio/PWMOut.h"
|
||||
#include "shared-bindings/pwmio/PWMOut.h"
|
||||
#include "shared-bindings/util.h"
|
||||
#include "supervisor/shared/translate.h"
|
||||
|
||||
@ -55,33 +55,33 @@
|
||||
//|
|
||||
//| Simple LED fade::
|
||||
//|
|
||||
//| import pulseio
|
||||
//| import pwmio
|
||||
//| import board
|
||||
//|
|
||||
//| pwm = pulseio.PWMOut(board.D13) # output on D13
|
||||
//| pwm = pwmio.PWMOut(board.D13) # output on D13
|
||||
//| pwm.duty_cycle = 2 ** 15 # Cycles the pin with 50% duty cycle (half of 2 ** 16) at the default 500hz
|
||||
//|
|
||||
//| PWM at specific frequency (servos and motors)::
|
||||
//|
|
||||
//| import pulseio
|
||||
//| import pwmio
|
||||
//| import board
|
||||
//|
|
||||
//| pwm = pulseio.PWMOut(board.D13, frequency=50)
|
||||
//| pwm = pwmio.PWMOut(board.D13, frequency=50)
|
||||
//| pwm.duty_cycle = 2 ** 15 # Cycles the pin with 50% duty cycle (half of 2 ** 16) at 50hz
|
||||
//|
|
||||
//| Variable frequency (usually tones)::
|
||||
//|
|
||||
//| import pulseio
|
||||
//| import pwmio
|
||||
//| import board
|
||||
//| import time
|
||||
//|
|
||||
//| pwm = pulseio.PWMOut(board.D13, duty_cycle=2 ** 15, frequency=440, variable_frequency=True)
|
||||
//| pwm = pwmio.PWMOut(board.D13, duty_cycle=2 ** 15, frequency=440, variable_frequency=True)
|
||||
//| time.sleep(0.2)
|
||||
//| pwm.frequency = 880
|
||||
//| time.sleep(0.1)"""
|
||||
//| ...
|
||||
//|
|
||||
STATIC mp_obj_t pulseio_pwmout_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
STATIC mp_obj_t pwmio_pwmout_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
|
||||
enum { ARG_pin, ARG_duty_cycle, ARG_frequency, ARG_variable_frequency };
|
||||
static const mp_arg_t allowed_args[] = {
|
||||
{ MP_QSTR_pin, MP_ARG_REQUIRED | MP_ARG_OBJ, },
|
||||
@ -99,9 +99,9 @@ STATIC mp_obj_t pulseio_pwmout_make_new(const mp_obj_type_t *type, size_t n_args
|
||||
bool variable_frequency = parsed_args[ARG_variable_frequency].u_bool;
|
||||
|
||||
// create PWM object from the given pin
|
||||
pulseio_pwmout_obj_t *self = m_new_obj(pulseio_pwmout_obj_t);
|
||||
self->base.type = &pulseio_pwmout_type;
|
||||
pwmout_result_t result = common_hal_pulseio_pwmout_construct(self, pin, duty_cycle, frequency, variable_frequency);
|
||||
pwmio_pwmout_obj_t *self = m_new_obj(pwmio_pwmout_obj_t);
|
||||
self->base.type = &pwmio_pwmout_type;
|
||||
pwmout_result_t result = common_hal_pwmio_pwmout_construct(self, pin, duty_cycle, frequency, variable_frequency);
|
||||
if (result == PWMOUT_INVALID_PIN) {
|
||||
mp_raise_ValueError(translate("Invalid pin"));
|
||||
} else if (result == PWMOUT_INVALID_FREQUENCY) {
|
||||
@ -119,15 +119,15 @@ STATIC mp_obj_t pulseio_pwmout_make_new(const mp_obj_type_t *type, size_t n_args
|
||||
//| """Deinitialises the PWMOut and releases any hardware resources for reuse."""
|
||||
//| ...
|
||||
//|
|
||||
STATIC mp_obj_t pulseio_pwmout_deinit(mp_obj_t self_in) {
|
||||
pulseio_pwmout_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
common_hal_pulseio_pwmout_deinit(self);
|
||||
STATIC mp_obj_t pwmio_pwmout_deinit(mp_obj_t self_in) {
|
||||
pwmio_pwmout_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
common_hal_pwmio_pwmout_deinit(self);
|
||||
return mp_const_none;
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(pulseio_pwmout_deinit_obj, pulseio_pwmout_deinit);
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(pwmio_pwmout_deinit_obj, pwmio_pwmout_deinit);
|
||||
|
||||
STATIC void check_for_deinit(pulseio_pwmout_obj_t *self) {
|
||||
if (common_hal_pulseio_pwmout_deinited(self)) {
|
||||
STATIC void check_for_deinit(pwmio_pwmout_obj_t *self) {
|
||||
if (common_hal_pwmio_pwmout_deinited(self)) {
|
||||
raise_deinited_error();
|
||||
}
|
||||
}
|
||||
@ -143,12 +143,12 @@ STATIC void check_for_deinit(pulseio_pwmout_obj_t *self) {
|
||||
//| :ref:`lifetime-and-contextmanagers` for more info."""
|
||||
//| ...
|
||||
//|
|
||||
STATIC mp_obj_t pulseio_pwmout_obj___exit__(size_t n_args, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t pwmio_pwmout_obj___exit__(size_t n_args, const mp_obj_t *args) {
|
||||
(void)n_args;
|
||||
common_hal_pulseio_pwmout_deinit(args[0]);
|
||||
common_hal_pwmio_pwmout_deinit(args[0]);
|
||||
return mp_const_none;
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pulseio_pwmout___exit___obj, 4, 4, pulseio_pwmout_obj___exit__);
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pwmio_pwmout___exit___obj, 4, 4, pwmio_pwmout_obj___exit__);
|
||||
|
||||
//| duty_cycle: int
|
||||
//| """16 bit value that dictates how much of one cycle is high (1) versus low
|
||||
@ -160,29 +160,29 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pulseio_pwmout___exit___obj, 4, 4, pu
|
||||
//| Reading this property will return the value from the internal representation,
|
||||
//| so it may differ from the value set."""
|
||||
//|
|
||||
STATIC mp_obj_t pulseio_pwmout_obj_get_duty_cycle(mp_obj_t self_in) {
|
||||
pulseio_pwmout_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
STATIC mp_obj_t pwmio_pwmout_obj_get_duty_cycle(mp_obj_t self_in) {
|
||||
pwmio_pwmout_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
check_for_deinit(self);
|
||||
return MP_OBJ_NEW_SMALL_INT(common_hal_pulseio_pwmout_get_duty_cycle(self));
|
||||
return MP_OBJ_NEW_SMALL_INT(common_hal_pwmio_pwmout_get_duty_cycle(self));
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(pulseio_pwmout_get_duty_cycle_obj, pulseio_pwmout_obj_get_duty_cycle);
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(pwmio_pwmout_get_duty_cycle_obj, pwmio_pwmout_obj_get_duty_cycle);
|
||||
|
||||
STATIC mp_obj_t pulseio_pwmout_obj_set_duty_cycle(mp_obj_t self_in, mp_obj_t duty_cycle) {
|
||||
pulseio_pwmout_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
STATIC mp_obj_t pwmio_pwmout_obj_set_duty_cycle(mp_obj_t self_in, mp_obj_t duty_cycle) {
|
||||
pwmio_pwmout_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
check_for_deinit(self);
|
||||
mp_int_t duty = mp_obj_get_int(duty_cycle);
|
||||
if (duty < 0 || duty > 0xffff) {
|
||||
mp_raise_ValueError(translate("PWM duty_cycle must be between 0 and 65535 inclusive (16 bit resolution)"));
|
||||
}
|
||||
common_hal_pulseio_pwmout_set_duty_cycle(self, duty);
|
||||
common_hal_pwmio_pwmout_set_duty_cycle(self, duty);
|
||||
return mp_const_none;
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_2(pulseio_pwmout_set_duty_cycle_obj, pulseio_pwmout_obj_set_duty_cycle);
|
||||
MP_DEFINE_CONST_FUN_OBJ_2(pwmio_pwmout_set_duty_cycle_obj, pwmio_pwmout_obj_set_duty_cycle);
|
||||
|
||||
const mp_obj_property_t pulseio_pwmout_duty_cycle_obj = {
|
||||
const mp_obj_property_t pwmio_pwmout_duty_cycle_obj = {
|
||||
.base.type = &mp_type_property,
|
||||
.proxy = {(mp_obj_t)&pulseio_pwmout_get_duty_cycle_obj,
|
||||
(mp_obj_t)&pulseio_pwmout_set_duty_cycle_obj,
|
||||
.proxy = {(mp_obj_t)&pwmio_pwmout_get_duty_cycle_obj,
|
||||
(mp_obj_t)&pwmio_pwmout_set_duty_cycle_obj,
|
||||
(mp_obj_t)&mp_const_none_obj},
|
||||
};
|
||||
|
||||
@ -196,50 +196,50 @@ const mp_obj_property_t pulseio_pwmout_duty_cycle_obj = {
|
||||
//| from the original duty cycle value. This should happen without any need
|
||||
//| to manually re-set the duty cycle."""
|
||||
//|
|
||||
STATIC mp_obj_t pulseio_pwmout_obj_get_frequency(mp_obj_t self_in) {
|
||||
pulseio_pwmout_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
STATIC mp_obj_t pwmio_pwmout_obj_get_frequency(mp_obj_t self_in) {
|
||||
pwmio_pwmout_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
check_for_deinit(self);
|
||||
return MP_OBJ_NEW_SMALL_INT(common_hal_pulseio_pwmout_get_frequency(self));
|
||||
return MP_OBJ_NEW_SMALL_INT(common_hal_pwmio_pwmout_get_frequency(self));
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(pulseio_pwmout_get_frequency_obj, pulseio_pwmout_obj_get_frequency);
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(pwmio_pwmout_get_frequency_obj, pwmio_pwmout_obj_get_frequency);
|
||||
|
||||
STATIC mp_obj_t pulseio_pwmout_obj_set_frequency(mp_obj_t self_in, mp_obj_t frequency) {
|
||||
pulseio_pwmout_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
STATIC mp_obj_t pwmio_pwmout_obj_set_frequency(mp_obj_t self_in, mp_obj_t frequency) {
|
||||
pwmio_pwmout_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
check_for_deinit(self);
|
||||
if (!common_hal_pulseio_pwmout_get_variable_frequency(self)) {
|
||||
if (!common_hal_pwmio_pwmout_get_variable_frequency(self)) {
|
||||
mp_raise_AttributeError(translate(
|
||||
"PWM frequency not writable when variable_frequency is False on "
|
||||
"construction."));
|
||||
}
|
||||
common_hal_pulseio_pwmout_set_frequency(self, mp_obj_get_int(frequency));
|
||||
common_hal_pwmio_pwmout_set_frequency(self, mp_obj_get_int(frequency));
|
||||
return mp_const_none;
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_2(pulseio_pwmout_set_frequency_obj, pulseio_pwmout_obj_set_frequency);
|
||||
MP_DEFINE_CONST_FUN_OBJ_2(pwmio_pwmout_set_frequency_obj, pwmio_pwmout_obj_set_frequency);
|
||||
|
||||
const mp_obj_property_t pulseio_pwmout_frequency_obj = {
|
||||
const mp_obj_property_t pwmio_pwmout_frequency_obj = {
|
||||
.base.type = &mp_type_property,
|
||||
.proxy = {(mp_obj_t)&pulseio_pwmout_get_frequency_obj,
|
||||
(mp_obj_t)&pulseio_pwmout_set_frequency_obj,
|
||||
.proxy = {(mp_obj_t)&pwmio_pwmout_get_frequency_obj,
|
||||
(mp_obj_t)&pwmio_pwmout_set_frequency_obj,
|
||||
(mp_obj_t)&mp_const_none_obj},
|
||||
};
|
||||
|
||||
STATIC const mp_rom_map_elem_t pulseio_pwmout_locals_dict_table[] = {
|
||||
STATIC const mp_rom_map_elem_t pwmio_pwmout_locals_dict_table[] = {
|
||||
// Methods
|
||||
{ MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&pulseio_pwmout_deinit_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&pwmio_pwmout_deinit_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&default___enter___obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&pulseio_pwmout___exit___obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&pwmio_pwmout___exit___obj) },
|
||||
|
||||
// Properties
|
||||
{ MP_ROM_QSTR(MP_QSTR_duty_cycle), MP_ROM_PTR(&pulseio_pwmout_duty_cycle_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_frequency), MP_ROM_PTR(&pulseio_pwmout_frequency_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_duty_cycle), MP_ROM_PTR(&pwmio_pwmout_duty_cycle_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_frequency), MP_ROM_PTR(&pwmio_pwmout_frequency_obj) },
|
||||
// TODO(tannewt): Add enabled to determine whether the signal is output
|
||||
// without giving up the resources. Useful for IR output.
|
||||
};
|
||||
STATIC MP_DEFINE_CONST_DICT(pulseio_pwmout_locals_dict, pulseio_pwmout_locals_dict_table);
|
||||
STATIC MP_DEFINE_CONST_DICT(pwmio_pwmout_locals_dict, pwmio_pwmout_locals_dict_table);
|
||||
|
||||
const mp_obj_type_t pulseio_pwmout_type = {
|
||||
const mp_obj_type_t pwmio_pwmout_type = {
|
||||
{ &mp_type_type },
|
||||
.name = MP_QSTR_PWMOut,
|
||||
.make_new = pulseio_pwmout_make_new,
|
||||
.locals_dict = (mp_obj_dict_t*)&pulseio_pwmout_locals_dict,
|
||||
.make_new = pwmio_pwmout_make_new,
|
||||
.locals_dict = (mp_obj_dict_t*)&pwmio_pwmout_locals_dict,
|
||||
};
|
@ -24,13 +24,13 @@
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_PULSEIO_PWMOUT_H
|
||||
#define MICROPY_INCLUDED_SHARED_BINDINGS_PULSEIO_PWMOUT_H
|
||||
#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_PWMIO_PWMOUT_H
|
||||
#define MICROPY_INCLUDED_SHARED_BINDINGS_PWMIO_PWMOUT_H
|
||||
|
||||
#include "common-hal/microcontroller/Pin.h"
|
||||
#include "common-hal/pulseio/PWMOut.h"
|
||||
#include "common-hal/pwmio/PWMOut.h"
|
||||
|
||||
extern const mp_obj_type_t pulseio_pwmout_type;
|
||||
extern const mp_obj_type_t pwmio_pwmout_type;
|
||||
|
||||
typedef enum {
|
||||
PWMOUT_OK,
|
||||
@ -40,19 +40,19 @@ typedef enum {
|
||||
PWMOUT_ALL_TIMERS_IN_USE
|
||||
} pwmout_result_t;
|
||||
|
||||
extern pwmout_result_t common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self,
|
||||
extern pwmout_result_t common_hal_pwmio_pwmout_construct(pwmio_pwmout_obj_t* self,
|
||||
const mcu_pin_obj_t* pin, uint16_t duty, uint32_t frequency,
|
||||
bool variable_frequency);
|
||||
extern void common_hal_pulseio_pwmout_deinit(pulseio_pwmout_obj_t* self);
|
||||
extern bool common_hal_pulseio_pwmout_deinited(pulseio_pwmout_obj_t* self);
|
||||
extern void common_hal_pulseio_pwmout_set_duty_cycle(pulseio_pwmout_obj_t* self, uint16_t duty);
|
||||
extern uint16_t common_hal_pulseio_pwmout_get_duty_cycle(pulseio_pwmout_obj_t* self);
|
||||
extern void common_hal_pulseio_pwmout_set_frequency(pulseio_pwmout_obj_t* self, uint32_t frequency);
|
||||
extern uint32_t common_hal_pulseio_pwmout_get_frequency(pulseio_pwmout_obj_t* self);
|
||||
extern bool common_hal_pulseio_pwmout_get_variable_frequency(pulseio_pwmout_obj_t* self);
|
||||
extern void common_hal_pwmio_pwmout_deinit(pwmio_pwmout_obj_t* self);
|
||||
extern bool common_hal_pwmio_pwmout_deinited(pwmio_pwmout_obj_t* self);
|
||||
extern void common_hal_pwmio_pwmout_set_duty_cycle(pwmio_pwmout_obj_t* self, uint16_t duty);
|
||||
extern uint16_t common_hal_pwmio_pwmout_get_duty_cycle(pwmio_pwmout_obj_t* self);
|
||||
extern void common_hal_pwmio_pwmout_set_frequency(pwmio_pwmout_obj_t* self, uint32_t frequency);
|
||||
extern uint32_t common_hal_pwmio_pwmout_get_frequency(pwmio_pwmout_obj_t* self);
|
||||
extern bool common_hal_pwmio_pwmout_get_variable_frequency(pwmio_pwmout_obj_t* self);
|
||||
|
||||
// This is used by the supervisor to claim PWMOut devices indefinitely.
|
||||
extern void common_hal_pulseio_pwmout_never_reset(pulseio_pwmout_obj_t *self);
|
||||
extern void common_hal_pulseio_pwmout_reset_ok(pulseio_pwmout_obj_t *self);
|
||||
extern void common_hal_pwmio_pwmout_never_reset(pwmio_pwmout_obj_t *self);
|
||||
extern void common_hal_pwmio_pwmout_reset_ok(pwmio_pwmout_obj_t *self);
|
||||
|
||||
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_PULSEIO_PWMOUT_H
|
||||
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_PWMIO_PWMOUT_H
|
73
shared-bindings/pwmio/__init__.c
Normal file
73
shared-bindings/pwmio/__init__.c
Normal file
@ -0,0 +1,73 @@
|
||||
/*
|
||||
* 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/pwmio/__init__.h"
|
||||
#include "shared-bindings/pwmio/PWMOut.h"
|
||||
|
||||
//| """Support for PWM based protocols
|
||||
//|
|
||||
//| The `pwmio` module contains classes to provide access to basic pulse IO.
|
||||
//|
|
||||
|
||||
//| All classes change hardware state and should be deinitialized when they
|
||||
//| are no longer needed if the program continues after use. To do so, either
|
||||
//| call :py:meth:`!deinit` or use a context manager. See
|
||||
//| :ref:`lifetime-and-contextmanagers` for more info.
|
||||
//|
|
||||
//| For example::
|
||||
//|
|
||||
//| import pwmio
|
||||
//| import time
|
||||
//| from board import *
|
||||
//|
|
||||
//| pwm = pwmio.PWMOut(D13)
|
||||
//| pwm.duty_cycle = 2 ** 15
|
||||
//| time.sleep(0.1)
|
||||
//|
|
||||
//| This example will initialize the the device, set
|
||||
//| :py:data:`~pwmio.PWMOut.duty_cycle`, and then sleep 0.1 seconds.
|
||||
//| CircuitPython will automatically turn off the PWM when it resets all
|
||||
//| hardware after program completion. Use ``deinit()`` or a ``with`` statement
|
||||
//| to do it yourself."""
|
||||
//|
|
||||
|
||||
STATIC const mp_rom_map_elem_t pwmio_module_globals_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_pwmio) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_PWMOut), MP_ROM_PTR(&pwmio_pwmout_type) },
|
||||
};
|
||||
|
||||
STATIC MP_DEFINE_CONST_DICT(pwmio_module_globals, pwmio_module_globals_table);
|
||||
|
||||
const mp_obj_module_t pwmio_module = {
|
||||
.base = { &mp_type_module },
|
||||
.globals = (mp_obj_dict_t*)&pwmio_module_globals,
|
||||
};
|
34
shared-bindings/pwmio/__init__.h
Normal file
34
shared-bindings/pwmio/__init__.h
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* This file is part of the MicroPython project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2016 Scott Shawcroft
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_PWMIO___INIT___H
|
||||
#define MICROPY_INCLUDED_SHARED_BINDINGS_PWMIO___INIT___H
|
||||
|
||||
#include "py/obj.h"
|
||||
|
||||
// Nothing now.
|
||||
|
||||
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_PWMIO___INIT___H
|
@ -35,7 +35,7 @@ typedef enum {
|
||||
WATCHDOGMODE_RESET,
|
||||
} watchdog_watchdogmode_t;
|
||||
|
||||
const mp_obj_type_t watchdog_watchdogmode_type;
|
||||
extern const mp_obj_type_t watchdog_watchdogmode_type;
|
||||
|
||||
watchdog_watchdogmode_t watchdog_watchdogmode_obj_to_type(mp_obj_t obj);
|
||||
mp_obj_t watchdog_watchdogmode_type_to_obj(watchdog_watchdogmode_t mode);
|
||||
|
@ -105,6 +105,32 @@ uint32_t common_hal_displayio_bitmap_get_pixel(displayio_bitmap_t *self, int16_t
|
||||
return 0;
|
||||
}
|
||||
|
||||
void common_hal_displayio_bitmap_blit(displayio_bitmap_t *self, int16_t x, int16_t y, displayio_bitmap_t *source,
|
||||
int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint32_t skip_index, bool skip_index_none) {
|
||||
// Copy complete "source" bitmap into "self" bitmap at location x,y in the "self"
|
||||
// Add a boolean to determine if all values are copied, or only if non-zero
|
||||
// If skip_value is encountered in the source bitmap, it will not be copied.
|
||||
// If skip_value is `None`, then all pixels are copied.
|
||||
|
||||
if (self->read_only) {
|
||||
mp_raise_RuntimeError(translate("Read-only object"));
|
||||
}
|
||||
|
||||
// simplest version - use internal functions for get/set pixels
|
||||
for (int16_t i=0; i < (x2-x1) ; i++) {
|
||||
if ( (x+i >= 0) && (x+i < self->width) ) {
|
||||
for (int16_t j=0; j < (y2-y1) ; j++){
|
||||
if ((y+j >= 0) && (y+j < self->height) ) {
|
||||
uint32_t value = common_hal_displayio_bitmap_get_pixel(source, x1+i, y1+j);
|
||||
if ( (skip_index_none) || (value != skip_index) ) { // write if skip_value_none is True
|
||||
common_hal_displayio_bitmap_set_pixel(self, x+i, y+j, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void common_hal_displayio_bitmap_set_pixel(displayio_bitmap_t *self, int16_t x, int16_t y, uint32_t value) {
|
||||
if (self->read_only) {
|
||||
mp_raise_RuntimeError(translate("Read-only object"));
|
||||
|
@ -111,14 +111,14 @@ void common_hal_displayio_display_construct(displayio_display_obj_t* self,
|
||||
if (backlight_pin != NULL && common_hal_mcu_pin_is_free(backlight_pin)) {
|
||||
// Avoid PWM types and functions when the module isn't enabled
|
||||
#if (CIRCUITPY_PULSEIO)
|
||||
pwmout_result_t result = common_hal_pulseio_pwmout_construct(&self->backlight_pwm, backlight_pin, 0, 50000, false);
|
||||
pwmout_result_t result = common_hal_pwmio_pwmout_construct(&self->backlight_pwm, backlight_pin, 0, 50000, false);
|
||||
if (result != PWMOUT_OK) {
|
||||
self->backlight_inout.base.type = &digitalio_digitalinout_type;
|
||||
common_hal_digitalio_digitalinout_construct(&self->backlight_inout, backlight_pin);
|
||||
common_hal_never_reset_pin(backlight_pin);
|
||||
} else {
|
||||
self->backlight_pwm.base.type = &pulseio_pwmout_type;
|
||||
common_hal_pulseio_pwmout_never_reset(&self->backlight_pwm);
|
||||
self->backlight_pwm.base.type = &pwmio_pwmout_type;
|
||||
common_hal_pwmio_pwmout_never_reset(&self->backlight_pwm);
|
||||
}
|
||||
#else
|
||||
// Otherwise default to digital
|
||||
@ -173,14 +173,14 @@ bool common_hal_displayio_display_set_brightness(displayio_display_obj_t* self,
|
||||
|
||||
// Avoid PWM types and functions when the module isn't enabled
|
||||
#if (CIRCUITPY_PULSEIO)
|
||||
bool ispwm = (self->backlight_pwm.base.type == &pulseio_pwmout_type) ? true : false;
|
||||
bool ispwm = (self->backlight_pwm.base.type == &pwmio_pwmout_type) ? true : false;
|
||||
#else
|
||||
bool ispwm = false;
|
||||
#endif
|
||||
|
||||
if (ispwm) {
|
||||
#if (CIRCUITPY_PULSEIO)
|
||||
common_hal_pulseio_pwmout_set_duty_cycle(&self->backlight_pwm, (uint16_t) (0xffff * brightness));
|
||||
common_hal_pwmio_pwmout_set_duty_cycle(&self->backlight_pwm, (uint16_t) (0xffff * brightness));
|
||||
ok = true;
|
||||
#else
|
||||
ok = false;
|
||||
@ -419,9 +419,9 @@ void release_display(displayio_display_obj_t* self) {
|
||||
common_hal_displayio_display_set_auto_refresh(self, false);
|
||||
release_display_core(&self->core);
|
||||
#if (CIRCUITPY_PULSEIO)
|
||||
if (self->backlight_pwm.base.type == &pulseio_pwmout_type) {
|
||||
common_hal_pulseio_pwmout_reset_ok(&self->backlight_pwm);
|
||||
common_hal_pulseio_pwmout_deinit(&self->backlight_pwm);
|
||||
if (self->backlight_pwm.base.type == &pwmio_pwmout_type) {
|
||||
common_hal_pwmio_pwmout_reset_ok(&self->backlight_pwm);
|
||||
common_hal_pwmio_pwmout_deinit(&self->backlight_pwm);
|
||||
} else if (self->backlight_inout.base.type == &digitalio_digitalinout_type) {
|
||||
common_hal_digitalio_digitalinout_deinit(&self->backlight_inout);
|
||||
}
|
||||
|
@ -29,8 +29,8 @@
|
||||
|
||||
#include "shared-bindings/digitalio/DigitalInOut.h"
|
||||
#include "shared-bindings/displayio/Group.h"
|
||||
#if CIRCUITPY_PULSEIO
|
||||
#include "shared-bindings/pulseio/PWMOut.h"
|
||||
#if CIRCUITPY_PWMIO
|
||||
#include "shared-bindings/pwmio/PWMOut.h"
|
||||
#endif
|
||||
|
||||
#include "shared-module/displayio/area.h"
|
||||
@ -41,8 +41,8 @@ typedef struct {
|
||||
displayio_display_core_t core;
|
||||
union {
|
||||
digitalio_digitalinout_obj_t backlight_inout;
|
||||
#if CIRCUITPY_PULSEIO
|
||||
pulseio_pwmout_obj_t backlight_pwm;
|
||||
#if CIRCUITPY_PWMIO
|
||||
pwmio_pwmout_obj_t backlight_pwm;
|
||||
#endif
|
||||
};
|
||||
uint64_t last_backlight_refresh;
|
||||
|
@ -394,8 +394,8 @@ primary_display_t *allocate_display_or_raise(void) {
|
||||
}
|
||||
primary_display_t *allocate_display_bus(void) {
|
||||
for (uint8_t i = 0; i < CIRCUITPY_DISPLAY_LIMIT; i++) {
|
||||
mp_const_obj_t display_type = displays[i].display.base.type;
|
||||
if (display_type == NULL || display_type == &mp_type_NoneType) {
|
||||
mp_const_obj_t display_bus_type = displays[i].bus_base.type;
|
||||
if (display_bus_type == NULL || display_bus_type == &mp_type_NoneType) {
|
||||
return &displays[i];
|
||||
}
|
||||
}
|
||||
|
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