summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhierophect <hierophect@gmail.com>2020-03-12 15:39:54 -0400
committerGitHub <noreply@github.com>2020-03-12 15:39:54 -0400
commitdd21ec048a71c669e76904edaa31c79ae16f5704 (patch)
treeeae68289c0e305c21ebc6beed4c3045380c61bd7
parentd988af02d13a24d2b2b62d2c64d053c3b089caea (diff)
parent0155fab356d5e41681e9d7a18355a70910d5200a (diff)
Merge pull request #2697 from hierophect/stm32-pulsein
STM32: add PulseIn module
-rw-r--r--locale/ID.po16
-rw-r--r--locale/circuitpython.pot16
-rw-r--r--locale/de_DE.po16
-rw-r--r--locale/en_US.po16
-rw-r--r--locale/en_x_pirate.po16
-rw-r--r--locale/es.po16
-rw-r--r--locale/fil.po16
-rw-r--r--locale/fr.po16
-rw-r--r--locale/it_IT.po16
-rw-r--r--locale/ko.po16
-rw-r--r--locale/pl.po16
-rw-r--r--locale/pt_BR.po16
-rw-r--r--locale/zh_Latn_pinyin.po19
-rw-r--r--ports/stm32f4/common-hal/pulseio/PulseIn.c238
-rw-r--r--ports/stm32f4/common-hal/pulseio/PulseIn.h3
-rw-r--r--ports/stm32f4/supervisor/port.c2
16 files changed, 368 insertions, 86 deletions
diff --git a/locale/ID.po b/locale/ID.po
index dff59c1ce..03111a7a8 100644
--- a/locale/ID.po
+++ b/locale/ID.po
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2020-03-09 08:19-0500\n"
+"POT-Creation-Date: 2020-03-11 17:52-0400\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"
@@ -709,6 +709,7 @@ msgstr "Gagal untuk mengalokasikan buffer RX"
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c
#: ports/cxd56/common-hal/pulseio/PulseIn.c
#: ports/nrf/common-hal/pulseio/PulseIn.c
+#: ports/stm32f4/common-hal/pulseio/PulseIn.c
#, c-format
msgid "Failed to allocate RX buffer of %d bytes"
msgstr "Gagal untuk megalokasikan buffer RX dari %d byte"
@@ -1165,6 +1166,10 @@ msgstr ""
msgid "Pin does not have ADC capabilities"
msgstr "Pin tidak mempunya kemampuan untuk ADC (Analog Digital Converter)"
+#: ports/stm32f4/common-hal/pulseio/PulseIn.c
+msgid "Pin number already reserved by EXTI"
+msgstr ""
+
#: py/builtinhelp.c
msgid "Plus any modules on the filesystem\n"
msgstr "Tambahkan module apapun pada filesystem\n"
@@ -1187,10 +1192,6 @@ msgstr ""
msgid "Pull not used when direction is output."
msgstr ""
-#: ports/stm32f4/common-hal/pulseio/PulseIn.c
-msgid "PulseIn not yet supported"
-msgstr ""
-
#: ports/stm32f4/common-hal/pulseio/PulseOut.c
msgid "PulseOut not supported on this chip"
msgstr ""
@@ -2231,7 +2232,8 @@ msgstr ""
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c
#: ports/cxd56/common-hal/pulseio/PulseIn.c
-#: ports/nrf/common-hal/pulseio/PulseIn.c py/obj.c
+#: ports/nrf/common-hal/pulseio/PulseIn.c
+#: ports/stm32f4/common-hal/pulseio/PulseIn.c py/obj.c
msgid "index out of range"
msgstr "index keluar dari jangkauan"
@@ -2718,6 +2720,7 @@ msgstr ""
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c
#: ports/cxd56/common-hal/pulseio/PulseIn.c
#: ports/nrf/common-hal/pulseio/PulseIn.c
+#: ports/stm32f4/common-hal/pulseio/PulseIn.c
msgid "pop from an empty PulseIn"
msgstr "Muncul dari PulseIn yang kosong"
@@ -2949,6 +2952,7 @@ msgstr ""
#: ports/atmel-samd/common-hal/busio/UART.c
#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c
+#: shared-bindings/busio/UART.c
msgid "tx and rx cannot both be None"
msgstr "tx dan rx keduanya tidak boleh kosong"
diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot
index e9afe41c2..7b56d28dc 100644
--- a/locale/circuitpython.pot
+++ b/locale/circuitpython.pot
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2020-03-09 08:19-0500\n"
+"POT-Creation-Date: 2020-03-11 17:52-0400\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"
@@ -698,6 +698,7 @@ msgstr ""
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c
#: ports/cxd56/common-hal/pulseio/PulseIn.c
#: ports/nrf/common-hal/pulseio/PulseIn.c
+#: ports/stm32f4/common-hal/pulseio/PulseIn.c
#, c-format
msgid "Failed to allocate RX buffer of %d bytes"
msgstr ""
@@ -1153,6 +1154,10 @@ msgstr ""
msgid "Pin does not have ADC capabilities"
msgstr ""
+#: ports/stm32f4/common-hal/pulseio/PulseIn.c
+msgid "Pin number already reserved by EXTI"
+msgstr ""
+
#: py/builtinhelp.c
msgid "Plus any modules on the filesystem\n"
msgstr ""
@@ -1173,10 +1178,6 @@ msgstr ""
msgid "Pull not used when direction is output."
msgstr ""
-#: ports/stm32f4/common-hal/pulseio/PulseIn.c
-msgid "PulseIn not yet supported"
-msgstr ""
-
#: ports/stm32f4/common-hal/pulseio/PulseOut.c
msgid "PulseOut not supported on this chip"
msgstr ""
@@ -2207,7 +2208,8 @@ msgstr ""
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c
#: ports/cxd56/common-hal/pulseio/PulseIn.c
-#: ports/nrf/common-hal/pulseio/PulseIn.c py/obj.c
+#: ports/nrf/common-hal/pulseio/PulseIn.c
+#: ports/stm32f4/common-hal/pulseio/PulseIn.c py/obj.c
msgid "index out of range"
msgstr ""
@@ -2693,6 +2695,7 @@ msgstr ""
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c
#: ports/cxd56/common-hal/pulseio/PulseIn.c
#: ports/nrf/common-hal/pulseio/PulseIn.c
+#: ports/stm32f4/common-hal/pulseio/PulseIn.c
msgid "pop from an empty PulseIn"
msgstr ""
@@ -2923,6 +2926,7 @@ msgstr ""
#: ports/atmel-samd/common-hal/busio/UART.c
#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c
+#: shared-bindings/busio/UART.c
msgid "tx and rx cannot both be None"
msgstr ""
diff --git a/locale/de_DE.po b/locale/de_DE.po
index b1ddf050e..78cecce64 100644
--- a/locale/de_DE.po
+++ b/locale/de_DE.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2020-03-09 08:19-0500\n"
+"POT-Creation-Date: 2020-03-11 17:52-0400\n"
"PO-Revision-Date: 2018-07-27 11:55-0700\n"
"Last-Translator: Pascal Deneaux\n"
"Language-Team: Sebastian Plamauer, Pascal Deneaux\n"
@@ -702,6 +702,7 @@ msgstr "Konnte keinen RX Buffer allozieren"
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c
#: ports/cxd56/common-hal/pulseio/PulseIn.c
#: ports/nrf/common-hal/pulseio/PulseIn.c
+#: ports/stm32f4/common-hal/pulseio/PulseIn.c
#, c-format
msgid "Failed to allocate RX buffer of %d bytes"
msgstr "Konnte keine RX Buffer mit %d allozieren"
@@ -1168,6 +1169,10 @@ msgstr "Zugang verweigert"
msgid "Pin does not have ADC capabilities"
msgstr "Pin hat keine ADC Funktionalität"
+#: ports/stm32f4/common-hal/pulseio/PulseIn.c
+msgid "Pin number already reserved by EXTI"
+msgstr ""
+
#: py/builtinhelp.c
msgid "Plus any modules on the filesystem\n"
msgstr "und alle Module im Dateisystem \n"
@@ -1190,10 +1195,6 @@ msgstr ""
msgid "Pull not used when direction is output."
msgstr "Pull wird nicht verwendet, wenn die Richtung output ist."
-#: ports/stm32f4/common-hal/pulseio/PulseIn.c
-msgid "PulseIn not yet supported"
-msgstr ""
-
#: ports/stm32f4/common-hal/pulseio/PulseOut.c
msgid "PulseOut not supported on this chip"
msgstr ""
@@ -2237,7 +2238,8 @@ msgstr ""
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c
#: ports/cxd56/common-hal/pulseio/PulseIn.c
-#: ports/nrf/common-hal/pulseio/PulseIn.c py/obj.c
+#: ports/nrf/common-hal/pulseio/PulseIn.c
+#: ports/stm32f4/common-hal/pulseio/PulseIn.c py/obj.c
msgid "index out of range"
msgstr "index außerhalb der Reichweite"
@@ -2731,6 +2733,7 @@ msgstr "pixel_shader muss displayio.Palette oder displayio.ColorConverter sein"
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c
#: ports/cxd56/common-hal/pulseio/PulseIn.c
#: ports/nrf/common-hal/pulseio/PulseIn.c
+#: ports/stm32f4/common-hal/pulseio/PulseIn.c
msgid "pop from an empty PulseIn"
msgstr "pop von einem leeren PulseIn"
@@ -2964,6 +2967,7 @@ msgstr ""
#: ports/atmel-samd/common-hal/busio/UART.c
#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c
+#: shared-bindings/busio/UART.c
msgid "tx and rx cannot both be None"
msgstr "tx und rx können nicht beide None sein"
diff --git a/locale/en_US.po b/locale/en_US.po
index b41734976..f452fdaad 100644
--- a/locale/en_US.po
+++ b/locale/en_US.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2020-03-09 08:19-0500\n"
+"POT-Creation-Date: 2020-03-11 17:52-0400\n"
"PO-Revision-Date: 2018-07-27 11:55-0700\n"
"Last-Translator: \n"
"Language-Team: \n"
@@ -698,6 +698,7 @@ msgstr ""
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c
#: ports/cxd56/common-hal/pulseio/PulseIn.c
#: ports/nrf/common-hal/pulseio/PulseIn.c
+#: ports/stm32f4/common-hal/pulseio/PulseIn.c
#, c-format
msgid "Failed to allocate RX buffer of %d bytes"
msgstr ""
@@ -1153,6 +1154,10 @@ msgstr ""
msgid "Pin does not have ADC capabilities"
msgstr ""
+#: ports/stm32f4/common-hal/pulseio/PulseIn.c
+msgid "Pin number already reserved by EXTI"
+msgstr ""
+
#: py/builtinhelp.c
msgid "Plus any modules on the filesystem\n"
msgstr ""
@@ -1173,10 +1178,6 @@ msgstr ""
msgid "Pull not used when direction is output."
msgstr ""
-#: ports/stm32f4/common-hal/pulseio/PulseIn.c
-msgid "PulseIn not yet supported"
-msgstr ""
-
#: ports/stm32f4/common-hal/pulseio/PulseOut.c
msgid "PulseOut not supported on this chip"
msgstr ""
@@ -2207,7 +2208,8 @@ msgstr ""
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c
#: ports/cxd56/common-hal/pulseio/PulseIn.c
-#: ports/nrf/common-hal/pulseio/PulseIn.c py/obj.c
+#: ports/nrf/common-hal/pulseio/PulseIn.c
+#: ports/stm32f4/common-hal/pulseio/PulseIn.c py/obj.c
msgid "index out of range"
msgstr ""
@@ -2693,6 +2695,7 @@ msgstr ""
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c
#: ports/cxd56/common-hal/pulseio/PulseIn.c
#: ports/nrf/common-hal/pulseio/PulseIn.c
+#: ports/stm32f4/common-hal/pulseio/PulseIn.c
msgid "pop from an empty PulseIn"
msgstr ""
@@ -2923,6 +2926,7 @@ msgstr ""
#: ports/atmel-samd/common-hal/busio/UART.c
#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c
+#: shared-bindings/busio/UART.c
msgid "tx and rx cannot both be None"
msgstr ""
diff --git a/locale/en_x_pirate.po b/locale/en_x_pirate.po
index b079dcd09..709571f31 100644
--- a/locale/en_x_pirate.po
+++ b/locale/en_x_pirate.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2020-03-09 08:19-0500\n"
+"POT-Creation-Date: 2020-03-11 17:52-0400\n"
"PO-Revision-Date: 2018-07-27 11:55-0700\n"
"Last-Translator: \n"
"Language-Team: @sommersoft, @MrCertainly\n"
@@ -702,6 +702,7 @@ msgstr ""
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c
#: ports/cxd56/common-hal/pulseio/PulseIn.c
#: ports/nrf/common-hal/pulseio/PulseIn.c
+#: ports/stm32f4/common-hal/pulseio/PulseIn.c
#, c-format
msgid "Failed to allocate RX buffer of %d bytes"
msgstr ""
@@ -1157,6 +1158,10 @@ msgstr ""
msgid "Pin does not have ADC capabilities"
msgstr "Belay that! Th' Pin be not ADC capable"
+#: ports/stm32f4/common-hal/pulseio/PulseIn.c
+msgid "Pin number already reserved by EXTI"
+msgstr ""
+
#: py/builtinhelp.c
msgid "Plus any modules on the filesystem\n"
msgstr ""
@@ -1177,10 +1182,6 @@ msgstr ""
msgid "Pull not used when direction is output."
msgstr ""
-#: ports/stm32f4/common-hal/pulseio/PulseIn.c
-msgid "PulseIn not yet supported"
-msgstr ""
-
#: ports/stm32f4/common-hal/pulseio/PulseOut.c
msgid "PulseOut not supported on this chip"
msgstr ""
@@ -2211,7 +2212,8 @@ msgstr ""
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c
#: ports/cxd56/common-hal/pulseio/PulseIn.c
-#: ports/nrf/common-hal/pulseio/PulseIn.c py/obj.c
+#: ports/nrf/common-hal/pulseio/PulseIn.c
+#: ports/stm32f4/common-hal/pulseio/PulseIn.c py/obj.c
msgid "index out of range"
msgstr ""
@@ -2697,6 +2699,7 @@ msgstr ""
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c
#: ports/cxd56/common-hal/pulseio/PulseIn.c
#: ports/nrf/common-hal/pulseio/PulseIn.c
+#: ports/stm32f4/common-hal/pulseio/PulseIn.c
msgid "pop from an empty PulseIn"
msgstr ""
@@ -2927,6 +2930,7 @@ msgstr ""
#: ports/atmel-samd/common-hal/busio/UART.c
#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c
+#: shared-bindings/busio/UART.c
msgid "tx and rx cannot both be None"
msgstr ""
diff --git a/locale/es.po b/locale/es.po
index 772c38f69..9c7f3e3cb 100644
--- a/locale/es.po
+++ b/locale/es.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2020-03-09 08:19-0500\n"
+"POT-Creation-Date: 2020-03-11 17:52-0400\n"
"PO-Revision-Date: 2018-08-24 22:56-0500\n"
"Last-Translator: \n"
"Language-Team: \n"
@@ -704,6 +704,7 @@ msgstr "Ha fallado la asignación del buffer RX"
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c
#: ports/cxd56/common-hal/pulseio/PulseIn.c
#: ports/nrf/common-hal/pulseio/PulseIn.c
+#: ports/stm32f4/common-hal/pulseio/PulseIn.c
#, c-format
msgid "Failed to allocate RX buffer of %d bytes"
msgstr "Falló la asignación del buffer RX de %d bytes"
@@ -1167,6 +1168,10 @@ msgstr "Permiso denegado"
msgid "Pin does not have ADC capabilities"
msgstr "Pin no tiene capacidad ADC"
+#: ports/stm32f4/common-hal/pulseio/PulseIn.c
+msgid "Pin number already reserved by EXTI"
+msgstr ""
+
#: py/builtinhelp.c
#, fuzzy
msgid "Plus any modules on the filesystem\n"
@@ -1189,10 +1194,6 @@ msgstr ""
msgid "Pull not used when direction is output."
msgstr "Pull no se usa cuando la dirección es output."
-#: ports/stm32f4/common-hal/pulseio/PulseIn.c
-msgid "PulseIn not yet supported"
-msgstr ""
-
#: ports/stm32f4/common-hal/pulseio/PulseOut.c
msgid "PulseOut not supported on this chip"
msgstr ""
@@ -2238,7 +2239,8 @@ msgstr ""
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c
#: ports/cxd56/common-hal/pulseio/PulseIn.c
-#: ports/nrf/common-hal/pulseio/PulseIn.c py/obj.c
+#: ports/nrf/common-hal/pulseio/PulseIn.c
+#: ports/stm32f4/common-hal/pulseio/PulseIn.c py/obj.c
msgid "index out of range"
msgstr "index fuera de rango"
@@ -2731,6 +2733,7 @@ msgstr "pixel_shader debe ser displayio.Palette o displayio.ColorConverter"
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c
#: ports/cxd56/common-hal/pulseio/PulseIn.c
#: ports/nrf/common-hal/pulseio/PulseIn.c
+#: ports/stm32f4/common-hal/pulseio/PulseIn.c
msgid "pop from an empty PulseIn"
msgstr "pop de un PulseIn vacío"
@@ -2964,6 +2967,7 @@ msgstr "tuple/lista se require en RHS"
#: ports/atmel-samd/common-hal/busio/UART.c
#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c
+#: shared-bindings/busio/UART.c
msgid "tx and rx cannot both be None"
msgstr "Ambos tx y rx no pueden ser None"
diff --git a/locale/fil.po b/locale/fil.po
index 450ed5f0e..ed31a176b 100644
--- a/locale/fil.po
+++ b/locale/fil.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2020-03-09 08:19-0500\n"
+"POT-Creation-Date: 2020-03-11 17:52-0400\n"
"PO-Revision-Date: 2018-12-20 22:15-0800\n"
"Last-Translator: Timothy <me@timothygarcia.ca>\n"
"Language-Team: fil\n"
@@ -712,6 +712,7 @@ msgstr "Nabigong ilaan ang RX buffer"
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c
#: ports/cxd56/common-hal/pulseio/PulseIn.c
#: ports/nrf/common-hal/pulseio/PulseIn.c
+#: ports/stm32f4/common-hal/pulseio/PulseIn.c
#, c-format
msgid "Failed to allocate RX buffer of %d bytes"
msgstr "Nabigong ilaan ang RX buffer ng %d bytes"
@@ -1173,6 +1174,10 @@ msgstr "Walang pahintulot"
msgid "Pin does not have ADC capabilities"
msgstr "Ang pin ay walang kakayahan sa ADC"
+#: ports/stm32f4/common-hal/pulseio/PulseIn.c
+msgid "Pin number already reserved by EXTI"
+msgstr ""
+
#: py/builtinhelp.c
msgid "Plus any modules on the filesystem\n"
msgstr "Kasama ang kung ano pang modules na sa filesystem\n"
@@ -1195,10 +1200,6 @@ msgstr ""
msgid "Pull not used when direction is output."
msgstr "Pull hindi ginagamit kapag ang direksyon ay output."
-#: ports/stm32f4/common-hal/pulseio/PulseIn.c
-msgid "PulseIn not yet supported"
-msgstr ""
-
#: ports/stm32f4/common-hal/pulseio/PulseOut.c
msgid "PulseOut not supported on this chip"
msgstr ""
@@ -2253,7 +2254,8 @@ msgstr ""
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c
#: ports/cxd56/common-hal/pulseio/PulseIn.c
-#: ports/nrf/common-hal/pulseio/PulseIn.c py/obj.c
+#: ports/nrf/common-hal/pulseio/PulseIn.c
+#: ports/stm32f4/common-hal/pulseio/PulseIn.c py/obj.c
msgid "index out of range"
msgstr "index wala sa sakop"
@@ -2745,6 +2747,7 @@ msgstr "pixel_shader ay dapat displayio.Palette o displayio.ColorConverter"
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c
#: ports/cxd56/common-hal/pulseio/PulseIn.c
#: ports/nrf/common-hal/pulseio/PulseIn.c
+#: ports/stm32f4/common-hal/pulseio/PulseIn.c
msgid "pop from an empty PulseIn"
msgstr "pop mula sa walang laman na PulseIn"
@@ -2979,6 +2982,7 @@ msgstr ""
#: ports/atmel-samd/common-hal/busio/UART.c
#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c
+#: shared-bindings/busio/UART.c
msgid "tx and rx cannot both be None"
msgstr "tx at rx hindi pwedeng parehas na None"
diff --git a/locale/fr.po b/locale/fr.po
index 708176c6b..9345787c5 100644
--- a/locale/fr.po
+++ b/locale/fr.po
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: 0.1\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2020-03-09 08:19-0500\n"
+"POT-Creation-Date: 2020-03-11 17:52-0400\n"
"PO-Revision-Date: 2019-04-14 20:05+0100\n"
"Last-Translator: Pierrick Couturier <arofarn@arofarn.info>\n"
"Language-Team: fr\n"
@@ -715,6 +715,7 @@ msgstr "Echec de l'allocation du tampon RX"
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c
#: ports/cxd56/common-hal/pulseio/PulseIn.c
#: ports/nrf/common-hal/pulseio/PulseIn.c
+#: ports/stm32f4/common-hal/pulseio/PulseIn.c
#, c-format
msgid "Failed to allocate RX buffer of %d bytes"
msgstr "Echec de l'allocation de %d octets du tampon RX"
@@ -1187,6 +1188,10 @@ msgstr "Permission refusée"
msgid "Pin does not have ADC capabilities"
msgstr "La broche ne peut être utilisée pour l'ADC"
+#: ports/stm32f4/common-hal/pulseio/PulseIn.c
+msgid "Pin number already reserved by EXTI"
+msgstr ""
+
#: py/builtinhelp.c
#, fuzzy
msgid "Plus any modules on the filesystem\n"
@@ -1208,10 +1213,6 @@ 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/stm32f4/common-hal/pulseio/PulseIn.c
-msgid "PulseIn not yet supported"
-msgstr ""
-
#: ports/stm32f4/common-hal/pulseio/PulseOut.c
msgid "PulseOut not supported on this chip"
msgstr ""
@@ -2277,7 +2278,8 @@ msgstr ""
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c
#: ports/cxd56/common-hal/pulseio/PulseIn.c
-#: ports/nrf/common-hal/pulseio/PulseIn.c py/obj.c
+#: ports/nrf/common-hal/pulseio/PulseIn.c
+#: ports/stm32f4/common-hal/pulseio/PulseIn.c py/obj.c
msgid "index out of range"
msgstr "index hors gamme"
@@ -2777,6 +2779,7 @@ msgstr ""
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c
#: ports/cxd56/common-hal/pulseio/PulseIn.c
#: ports/nrf/common-hal/pulseio/PulseIn.c
+#: ports/stm32f4/common-hal/pulseio/PulseIn.c
msgid "pop from an empty PulseIn"
msgstr "'pop' d'une entrée PulseIn vide"
@@ -3012,6 +3015,7 @@ msgstr "tuple ou liste requis en partie droite"
#: ports/atmel-samd/common-hal/busio/UART.c
#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c
+#: shared-bindings/busio/UART.c
msgid "tx and rx cannot both be None"
msgstr "tx et rx ne peuvent être 'None' tous les deux"
diff --git a/locale/it_IT.po b/locale/it_IT.po
index f4eeea46f..68cd7dd41 100644
--- a/locale/it_IT.po
+++ b/locale/it_IT.po
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2020-03-09 08:19-0500\n"
+"POT-Creation-Date: 2020-03-11 17:52-0400\n"
"PO-Revision-Date: 2018-10-02 16:27+0200\n"
"Last-Translator: Enrico Paganin <enrico.paganin@mail.com>\n"
"Language-Team: \n"
@@ -712,6 +712,7 @@ msgstr "Impossibile allocare buffer RX"
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c
#: ports/cxd56/common-hal/pulseio/PulseIn.c
#: ports/nrf/common-hal/pulseio/PulseIn.c
+#: ports/stm32f4/common-hal/pulseio/PulseIn.c
#, c-format
msgid "Failed to allocate RX buffer of %d bytes"
msgstr "Fallita allocazione del buffer RX di %d byte"
@@ -1182,6 +1183,10 @@ msgstr "Permesso negato"
msgid "Pin does not have ADC capabilities"
msgstr "Il pin non ha capacità di ADC"
+#: ports/stm32f4/common-hal/pulseio/PulseIn.c
+msgid "Pin number already reserved by EXTI"
+msgstr ""
+
#: py/builtinhelp.c
#, fuzzy
msgid "Plus any modules on the filesystem\n"
@@ -1204,10 +1209,6 @@ msgstr ""
msgid "Pull not used when direction is output."
msgstr ""
-#: ports/stm32f4/common-hal/pulseio/PulseIn.c
-msgid "PulseIn not yet supported"
-msgstr ""
-
#: ports/stm32f4/common-hal/pulseio/PulseOut.c
msgid "PulseOut not supported on this chip"
msgstr ""
@@ -2254,7 +2255,8 @@ msgstr ""
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c
#: ports/cxd56/common-hal/pulseio/PulseIn.c
-#: ports/nrf/common-hal/pulseio/PulseIn.c py/obj.c
+#: ports/nrf/common-hal/pulseio/PulseIn.c
+#: ports/stm32f4/common-hal/pulseio/PulseIn.c py/obj.c
msgid "index out of range"
msgstr "indice fuori intervallo"
@@ -2752,6 +2754,7 @@ msgstr "pixel_shader deve essere displayio.Palette o displayio.ColorConverter"
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c
#: ports/cxd56/common-hal/pulseio/PulseIn.c
#: ports/nrf/common-hal/pulseio/PulseIn.c
+#: ports/stm32f4/common-hal/pulseio/PulseIn.c
msgid "pop from an empty PulseIn"
msgstr "pop sun un PulseIn vuoto"
@@ -2986,6 +2989,7 @@ msgstr ""
#: ports/atmel-samd/common-hal/busio/UART.c
#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c
+#: shared-bindings/busio/UART.c
msgid "tx and rx cannot both be None"
msgstr "tx e rx non possono essere entrambi None"
diff --git a/locale/ko.po b/locale/ko.po
index 96bb26d09..656adf2cb 100644
--- a/locale/ko.po
+++ b/locale/ko.po
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2020-03-09 08:19-0500\n"
+"POT-Creation-Date: 2020-03-11 17:52-0400\n"
"PO-Revision-Date: 2019-05-06 14:22-0700\n"
"Last-Translator: \n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -702,6 +702,7 @@ msgstr ""
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c
#: ports/cxd56/common-hal/pulseio/PulseIn.c
#: ports/nrf/common-hal/pulseio/PulseIn.c
+#: ports/stm32f4/common-hal/pulseio/PulseIn.c
#, c-format
msgid "Failed to allocate RX buffer of %d bytes"
msgstr ""
@@ -1157,6 +1158,10 @@ msgstr ""
msgid "Pin does not have ADC capabilities"
msgstr ""
+#: ports/stm32f4/common-hal/pulseio/PulseIn.c
+msgid "Pin number already reserved by EXTI"
+msgstr ""
+
#: py/builtinhelp.c
msgid "Plus any modules on the filesystem\n"
msgstr ""
@@ -1177,10 +1182,6 @@ msgstr ""
msgid "Pull not used when direction is output."
msgstr ""
-#: ports/stm32f4/common-hal/pulseio/PulseIn.c
-msgid "PulseIn not yet supported"
-msgstr ""
-
#: ports/stm32f4/common-hal/pulseio/PulseOut.c
msgid "PulseOut not supported on this chip"
msgstr ""
@@ -2212,7 +2213,8 @@ msgstr ""
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c
#: ports/cxd56/common-hal/pulseio/PulseIn.c
-#: ports/nrf/common-hal/pulseio/PulseIn.c py/obj.c
+#: ports/nrf/common-hal/pulseio/PulseIn.c
+#: ports/stm32f4/common-hal/pulseio/PulseIn.c py/obj.c
msgid "index out of range"
msgstr ""
@@ -2698,6 +2700,7 @@ msgstr ""
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c
#: ports/cxd56/common-hal/pulseio/PulseIn.c
#: ports/nrf/common-hal/pulseio/PulseIn.c
+#: ports/stm32f4/common-hal/pulseio/PulseIn.c
msgid "pop from an empty PulseIn"
msgstr ""
@@ -2928,6 +2931,7 @@ msgstr ""
#: ports/atmel-samd/common-hal/busio/UART.c
#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c
+#: shared-bindings/busio/UART.c
msgid "tx and rx cannot both be None"
msgstr ""
diff --git a/locale/pl.po b/locale/pl.po
index 581dac8d0..6eb37254b 100644
--- a/locale/pl.po
+++ b/locale/pl.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2020-03-09 08:19-0500\n"
+"POT-Creation-Date: 2020-03-11 17:52-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"
@@ -701,6 +701,7 @@ msgstr "Nie udała się alokacja bufora RX"
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c
#: ports/cxd56/common-hal/pulseio/PulseIn.c
#: ports/nrf/common-hal/pulseio/PulseIn.c
+#: ports/stm32f4/common-hal/pulseio/PulseIn.c
#, c-format
msgid "Failed to allocate RX buffer of %d bytes"
msgstr "Nie udała się alokacja %d bajtów na bufor RX"
@@ -1158,6 +1159,10 @@ msgstr "Odmowa dostępu"
msgid "Pin does not have ADC capabilities"
msgstr "Nóżka nie obsługuje ADC"
+#: ports/stm32f4/common-hal/pulseio/PulseIn.c
+msgid "Pin number already reserved by EXTI"
+msgstr ""
+
#: py/builtinhelp.c
msgid "Plus any modules on the filesystem\n"
msgstr "Oraz moduły w systemie plików\n"
@@ -1178,10 +1183,6 @@ 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/stm32f4/common-hal/pulseio/PulseIn.c
-msgid "PulseIn not yet supported"
-msgstr ""
-
#: ports/stm32f4/common-hal/pulseio/PulseOut.c
msgid "PulseOut not supported on this chip"
msgstr ""
@@ -2216,7 +2217,8 @@ msgstr ""
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c
#: ports/cxd56/common-hal/pulseio/PulseIn.c
-#: ports/nrf/common-hal/pulseio/PulseIn.c py/obj.c
+#: ports/nrf/common-hal/pulseio/PulseIn.c
+#: ports/stm32f4/common-hal/pulseio/PulseIn.c py/obj.c
msgid "index out of range"
msgstr "indeks poza zakresem"
@@ -2703,6 +2705,7 @@ msgstr ""
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c
#: ports/cxd56/common-hal/pulseio/PulseIn.c
#: ports/nrf/common-hal/pulseio/PulseIn.c
+#: ports/stm32f4/common-hal/pulseio/PulseIn.c
msgid "pop from an empty PulseIn"
msgstr "pop z pustego PulseIn"
@@ -2934,6 +2937,7 @@ msgstr "wymagana krotka/lista po prawej stronie"
#: ports/atmel-samd/common-hal/busio/UART.c
#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c
+#: shared-bindings/busio/UART.c
msgid "tx and rx cannot both be None"
msgstr "tx i rx nie mogą być oba None"
diff --git a/locale/pt_BR.po b/locale/pt_BR.po
index 3dce592e3..a0f2024eb 100644
--- a/locale/pt_BR.po
+++ b/locale/pt_BR.po
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2020-03-09 08:19-0500\n"
+"POT-Creation-Date: 2020-03-11 17:52-0400\n"
"PO-Revision-Date: 2018-10-02 21:14-0000\n"
"Last-Translator: \n"
"Language-Team: \n"
@@ -707,6 +707,7 @@ msgstr "Falha ao alocar buffer RX"
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c
#: ports/cxd56/common-hal/pulseio/PulseIn.c
#: ports/nrf/common-hal/pulseio/PulseIn.c
+#: ports/stm32f4/common-hal/pulseio/PulseIn.c
#, c-format
msgid "Failed to allocate RX buffer of %d bytes"
msgstr "Falha ao alocar buffer RX de %d bytes"
@@ -1168,6 +1169,10 @@ msgstr "Permissão negada"
msgid "Pin does not have ADC capabilities"
msgstr "O pino não tem recursos de ADC"
+#: ports/stm32f4/common-hal/pulseio/PulseIn.c
+msgid "Pin number already reserved by EXTI"
+msgstr ""
+
#: py/builtinhelp.c
#, fuzzy
msgid "Plus any modules on the filesystem\n"
@@ -1189,10 +1194,6 @@ msgstr ""
msgid "Pull not used when direction is output."
msgstr ""
-#: ports/stm32f4/common-hal/pulseio/PulseIn.c
-msgid "PulseIn not yet supported"
-msgstr ""
-
#: ports/stm32f4/common-hal/pulseio/PulseOut.c
msgid "PulseOut not supported on this chip"
msgstr ""
@@ -2229,7 +2230,8 @@ msgstr ""
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c
#: ports/cxd56/common-hal/pulseio/PulseIn.c
-#: ports/nrf/common-hal/pulseio/PulseIn.c py/obj.c
+#: ports/nrf/common-hal/pulseio/PulseIn.c
+#: ports/stm32f4/common-hal/pulseio/PulseIn.c py/obj.c
msgid "index out of range"
msgstr "Índice fora do intervalo"
@@ -2715,6 +2717,7 @@ msgstr ""
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c
#: ports/cxd56/common-hal/pulseio/PulseIn.c
#: ports/nrf/common-hal/pulseio/PulseIn.c
+#: ports/stm32f4/common-hal/pulseio/PulseIn.c
msgid "pop from an empty PulseIn"
msgstr ""
@@ -2947,6 +2950,7 @@ msgstr ""
#: ports/atmel-samd/common-hal/busio/UART.c
#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c
+#: shared-bindings/busio/UART.c
msgid "tx and rx cannot both be None"
msgstr "TX e RX não podem ser ambos"
diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po
index cc23d7fc8..e93bcb1d2 100644
--- a/locale/zh_Latn_pinyin.po
+++ b/locale/zh_Latn_pinyin.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: circuitpython-cn\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2020-03-09 08:19-0500\n"
+"POT-Creation-Date: 2020-03-11 17:52-0400\n"
"PO-Revision-Date: 2019-04-13 10:10-0700\n"
"Last-Translator: hexthat\n"
"Language-Team: Chinese Hanyu Pinyin\n"
@@ -709,6 +709,7 @@ msgstr "Fēnpèi RX huǎnchōng shībài"
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c
#: ports/cxd56/common-hal/pulseio/PulseIn.c
#: ports/nrf/common-hal/pulseio/PulseIn.c
+#: ports/stm32f4/common-hal/pulseio/PulseIn.c
#, c-format
msgid "Failed to allocate RX buffer of %d bytes"
msgstr "Fēnpèi RX huǎnchōng qū%d zì jié shībài"
@@ -1172,6 +1173,10 @@ msgstr "Quánxiàn bèi jùjué"
msgid "Pin does not have ADC capabilities"
msgstr "Pin méiyǒu ADC nénglì"
+#: ports/stm32f4/common-hal/pulseio/PulseIn.c
+msgid "Pin number already reserved by EXTI"
+msgstr ""
+
#: py/builtinhelp.c
msgid "Plus any modules on the filesystem\n"
msgstr "Zài wénjiàn xìtǒng shàng tiānjiā rènhé mókuài\n"
@@ -1192,10 +1197,6 @@ 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/stm32f4/common-hal/pulseio/PulseIn.c
-msgid "PulseIn not yet supported"
-msgstr "Shàng bù zhīchí PulseIn"
-
#: ports/stm32f4/common-hal/pulseio/PulseOut.c
msgid "PulseOut not supported on this chip"
msgstr ""
@@ -2244,7 +2245,8 @@ msgstr ""
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c
#: ports/cxd56/common-hal/pulseio/PulseIn.c
-#: ports/nrf/common-hal/pulseio/PulseIn.c py/obj.c
+#: ports/nrf/common-hal/pulseio/PulseIn.c
+#: ports/stm32f4/common-hal/pulseio/PulseIn.c py/obj.c
msgid "index out of range"
msgstr "suǒyǐn chāochū fànwéi"
@@ -2732,6 +2734,7 @@ msgstr "pixel_shader bìxū shì displayio.Palette huò displayio.ColorConverter
#: ports/atmel-samd/common-hal/pulseio/PulseIn.c
#: ports/cxd56/common-hal/pulseio/PulseIn.c
#: ports/nrf/common-hal/pulseio/PulseIn.c
+#: ports/stm32f4/common-hal/pulseio/PulseIn.c
msgid "pop from an empty PulseIn"
msgstr "cóng kōng de PulseIn dànchū dànchū"
@@ -2964,6 +2967,7 @@ msgstr "RHS yāoqiú de yuán zǔ/lièbiǎo"
#: ports/atmel-samd/common-hal/busio/UART.c
#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c
+#: shared-bindings/busio/UART.c
msgid "tx and rx cannot both be None"
msgstr "tx hé rx bùnéng dōu shì wú"
@@ -3325,6 +3329,9 @@ msgstr "líng bù"
#~ msgid "Pixel beyond bounds of buffer"
#~ msgstr "Xiàngsù chāochū huǎnchōng qū biānjiè"
+#~ msgid "PulseIn not yet supported"
+#~ msgstr "Shàng bù zhīchí PulseIn"
+
#~ msgid "PulseOut not yet supported"
#~ msgstr "Shàng bù zhīchí PulseOut"
diff --git a/ports/stm32f4/common-hal/pulseio/PulseIn.c b/ports/stm32f4/common-hal/pulseio/PulseIn.c
index 068936bdd..8428a2278 100644
--- a/ports/stm32f4/common-hal/pulseio/PulseIn.c
+++ b/ports/stm32f4/common-hal/pulseio/PulseIn.c
@@ -34,46 +34,270 @@
#include "shared-bindings/pulseio/PulseIn.h"
#include "tick.h"
+#include "stm32f4xx_hal.h"
+
+#define STM32_GPIO_PORT_SIZE 16
+
+static pulseio_pulsein_obj_t* _objs[STM32_GPIO_PORT_SIZE];
+
+static void assign_EXTI_Interrupt(pulseio_pulsein_obj_t* self, uint8_t num);
+
+static void pulsein_handler(uint8_t num) {
+ // Interrupt register must be cleared manually
+ EXTI->PR = 1 << num;
+
+ // Grab the current time first.
+ uint32_t current_us;
+ uint64_t current_ms;
+ current_tick(&current_ms, &current_us);
+
+ // current_tick gives us the remaining us until the next tick but we want the number since the last ms.
+ current_us = 1000 - current_us;
+
+ pulseio_pulsein_obj_t* self = _objs[num];
+ if ( !self ) return;
+
+ if (self->first_edge) {
+ // first pulse is opposite state from idle
+ bool state = HAL_GPIO_ReadPin(pin_port(self->pin->port), pin_mask(self->pin->number));
+ if ( self->idle_state != state ) {
+ self->first_edge = false;
+ }
+ } else {
+ uint32_t ms_diff = current_ms - self->last_ms;
+ uint16_t us_diff = current_us - self->last_us;
+ uint32_t total_diff = us_diff;
+
+ if (self->last_us > current_us) {
+ total_diff = 1000 + current_us - self->last_us;
+ if (ms_diff > 1) {
+ total_diff += (ms_diff - 1) * 1000;
+ }
+ } else {
+ total_diff += ms_diff * 1000;
+ }
+ uint16_t duration = 0xffff;
+ if (total_diff < duration) {
+ duration = total_diff;
+ }
+
+ uint16_t i = (self->start + self->len) % self->maxlen;
+ self->buffer[i] = duration;
+ if (self->len < self->maxlen) {
+ self->len++;
+ } else {
+ self->start++;
+ }
+ }
+
+ self->last_ms = current_ms;
+ self->last_us = current_us;
+}
+
void pulsein_reset(void) {
+ // Disable all active interrupts and clear array
+ for (uint i = 0; i < STM32_GPIO_PORT_SIZE; i++) {
+ if (_objs[i] != NULL) {
+ HAL_NVIC_DisableIRQ(_objs[i]->irq);
+ }
+ }
+ memset(_objs, 0, sizeof(_objs));
}
void common_hal_pulseio_pulsein_construct(pulseio_pulsein_obj_t* self, const mcu_pin_obj_t* pin,
uint16_t maxlen, bool idle_state) {
- mp_raise_NotImplementedError(translate("PulseIn not yet supported"));
+ // STM32 has one shared EXTI for each pin number, 0-15
+ uint8_t p_num = pin->number;
+ if(_objs[p_num]) {
+ mp_raise_ValueError(translate("Pin number already reserved by EXTI"));
+ }
+ _objs[p_num] = self;
+
+ // Allocate pulse buffer
+ 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));
+ }
+
+ // Set internal variables
+ self->pin = pin;
+ self->maxlen = maxlen;
+ self->idle_state = idle_state;
+ self->start = 0;
+ self->len = 0;
+ self->first_edge = true;
+ self->paused = false;
+ self->last_us = 0;
+ self->last_ms = 0;
+
+ // EXTI pins can also be read as an input
+ GPIO_InitTypeDef GPIO_InitStruct = {0};
+ GPIO_InitStruct.Pin = pin_mask(pin->number);
+ GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ HAL_GPIO_Init(pin_port(pin->port), &GPIO_InitStruct);
+
+ // Interrupt starts immediately
+ assign_EXTI_Interrupt(self, pin->number);
+ HAL_NVIC_EnableIRQ(self->irq);
+ claim_pin(pin);
}
bool common_hal_pulseio_pulsein_deinited(pulseio_pulsein_obj_t* self) {
- return true;
+ return (self->pin == NULL);
}
void common_hal_pulseio_pulsein_deinit(pulseio_pulsein_obj_t* self) {
+ if (common_hal_pulseio_pulsein_deinited(self)) {
+ return;
+ }
+ //Remove pulsein slot from shared array
+ HAL_NVIC_DisableIRQ(self->irq);
+ _objs[self->pin->number] = NULL;
+ reset_pin_number(self->pin->port, self->pin->number);
+ self->pin = NULL;
}
void common_hal_pulseio_pulsein_pause(pulseio_pulsein_obj_t* self) {
+ HAL_NVIC_DisableIRQ(self->irq);
+ self->paused = true;
}
void common_hal_pulseio_pulsein_resume(pulseio_pulsein_obj_t* self, uint16_t trigger_duration) {
+ // Make sure we're paused.
+ if ( !self->paused ) {
+ common_hal_pulseio_pulsein_pause(self);
+ }
+
+ // Send the trigger pulse.
+ if (trigger_duration > 0) {
+ GPIO_InitTypeDef GPIO_InitStruct = {0};
+ GPIO_InitStruct.Pin = pin_mask(self->pin->number);
+ GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
+ HAL_GPIO_Init(pin_port(self->pin->port), &GPIO_InitStruct);
+
+ HAL_GPIO_WritePin(pin_port(self->pin->port), pin_mask(self->pin->number), !self->idle_state);
+ common_hal_mcu_delay_us((uint32_t)trigger_duration);
+ HAL_GPIO_WritePin(pin_port(self->pin->port), pin_mask(self->pin->number), self->idle_state);
+
+ GPIO_InitStruct.Pin = pin_mask(self->pin->number);
+ GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ HAL_GPIO_Init(pin_port(self->pin->port), &GPIO_InitStruct);
+ }
+
+ self->first_edge = true;
+ self->paused = false;
+ self->last_ms = 0;
+ self->last_us = 0;
+
+ HAL_NVIC_EnableIRQ(self->irq);
}
void common_hal_pulseio_pulsein_clear(pulseio_pulsein_obj_t* self) {
+ HAL_NVIC_DisableIRQ(self->irq);
+ self->start = 0;
+ self->len = 0;
+ HAL_NVIC_EnableIRQ(self->irq);
}
uint16_t common_hal_pulseio_pulsein_get_item(pulseio_pulsein_obj_t* self, int16_t index) {
- return 0;
+ HAL_NVIC_DisableIRQ(self->irq);
+ if (index < 0) {
+ index += self->len;
+ }
+ if (index < 0 || index >= self->len) {
+ HAL_NVIC_EnableIRQ(self->irq);
+ mp_raise_IndexError(translate("index out of range"));
+ }
+ uint16_t value = self->buffer[(self->start + index) % self->maxlen];
+ HAL_NVIC_EnableIRQ(self->irq);
+ return value;
}
uint16_t common_hal_pulseio_pulsein_popleft(pulseio_pulsein_obj_t* self) {
- return 0;
+ if (self->len == 0) {
+ mp_raise_IndexError(translate("pop from an empty PulseIn"));
+ }
+ HAL_NVIC_DisableIRQ(self->irq);
+ uint16_t value = self->buffer[self->start];
+ self->start = (self->start + 1) % self->maxlen;
+ self->len--;
+ HAL_NVIC_EnableIRQ(self->irq);
+
+ return value;
}
uint16_t common_hal_pulseio_pulsein_get_maxlen(pulseio_pulsein_obj_t* self) {
- return 0;
+ return self->maxlen;
}
bool common_hal_pulseio_pulsein_get_paused(pulseio_pulsein_obj_t* self) {
- return 0;
+ return self->paused;
}
uint16_t common_hal_pulseio_pulsein_get_len(pulseio_pulsein_obj_t* self) {
- return 0;
+ return self->len;
+}
+
+static void assign_EXTI_Interrupt(pulseio_pulsein_obj_t* self, uint8_t num) {
+ if (num == 0) {
+ self->irq = EXTI0_IRQn;
+ } else if (num == 1) {
+ self->irq = EXTI1_IRQn;
+ } else if (num == 2) {
+ self->irq = EXTI2_IRQn;
+ } else if (num == 3) {
+ self->irq = EXTI3_IRQn;
+ } else if (num == 4) {
+ self->irq = EXTI4_IRQn;
+ } else if (num >= 5 && num <= 9 ) {
+ self->irq = EXTI9_5_IRQn;
+ } else if (num >= 10 && num <= 15) {
+ self->irq = EXTI15_10_IRQn;
+ }
+}
+
+void EXTI0_IRQHandler(void)
+{
+ pulsein_handler(0);
+}
+void EXTI1_IRQHandler(void)
+{
+ pulsein_handler(1);
+}
+void EXTI2_IRQHandler(void)
+{
+ pulsein_handler(2);
+}
+void EXTI3_IRQHandler(void)
+{
+ pulsein_handler(3);
+}
+void EXTI4_IRQHandler(void)
+{
+ pulsein_handler(4);
+}
+
+void EXTI9_5_IRQHandler(void)
+{
+ uint32_t pending = EXTI->PR;
+ for (uint i = 5; i <= 9; i++) {
+ if(pending & (1 << i)) {
+ pulsein_handler(i);
+ }
+ }
+}
+
+void EXTI15_10_IRQHandler(void)
+{
+ uint32_t pending = EXTI->PR;
+ for (uint i = 10; i <= 15; i++) {
+ if(pending & (1 << i)) {
+ pulsein_handler(i);
+ }
+ }
}
diff --git a/ports/stm32f4/common-hal/pulseio/PulseIn.h b/ports/stm32f4/common-hal/pulseio/PulseIn.h
index 2538b07ab..5456613c6 100644
--- a/ports/stm32f4/common-hal/pulseio/PulseIn.h
+++ b/ports/stm32f4/common-hal/pulseio/PulseIn.h
@@ -34,7 +34,8 @@
typedef struct {
mp_obj_base_t base;
- uint8_t pin;
+ const mcu_pin_obj_t* pin;
+ IRQn_Type irq;
bool idle_state;
bool paused;
volatile bool first_edge;
diff --git a/ports/stm32f4/supervisor/port.c b/ports/stm32f4/supervisor/port.c
index ecb4d3d15..948e9f2e4 100644
--- a/ports/stm32f4/supervisor/port.c
+++ b/ports/stm32f4/supervisor/port.c
@@ -36,6 +36,7 @@
#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 "stm32f4/clocks.h"
#include "stm32f4/gpio.h"
@@ -62,6 +63,7 @@ void reset_port(void) {
uart_reset();
pwmout_reset();
pulseout_reset();
+ pulsein_reset();
}
void reset_to_bootloader(void) {