summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Halbert <halbert@halwitz.org>2018-10-03 23:57:56 -0400
committerGitHub <noreply@github.com>2018-10-03 23:57:56 -0400
commitf7ebbacf584a1d8d0870f1221fa329e30147520b (patch)
treee0a25a07a459a1b84610c4362fc5072a43b89da4
parent86ae707b0871f3b5f7766bfcd920635b337a6b29 (diff)
parent6049776b2665c2bc7d490a0630cf514a13aecf99 (diff)
Merge pull request #1212 from hathach/nrf52_uart_io
Nrf52 uart io
m---------lib/tinyusb0
-rw-r--r--locale/circuitpython.pot35
-rw-r--r--locale/de_DE.po37
-rw-r--r--locale/en_US.po35
-rw-r--r--locale/es.po37
-rw-r--r--locale/fil.po40
-rw-r--r--locale/fr.po40
-rw-r--r--locale/pt_BR.po44
-rwxr-xr-xports/nrf/Makefile3
-rw-r--r--ports/nrf/boards/feather_nrf52832/mpconfigboard.h1
-rw-r--r--ports/nrf/boards/feather_nrf52840_express/mpconfigboard.h2
-rw-r--r--ports/nrf/boards/pca10056/mpconfigboard.h8
-rw-r--r--ports/nrf/boards/pca10056/pins.c2
-rw-r--r--ports/nrf/common-hal/busio/UART.c317
-rw-r--r--ports/nrf/common-hal/busio/UART.h17
-rw-r--r--ports/nrf/mphalport.c36
-rw-r--r--ports/nrf/mphalport.h13
m---------ports/nrf/nrfx0
-rw-r--r--ports/nrf/nrfx_config.h9
-rw-r--r--ports/nrf/supervisor/serial.c43
20 files changed, 571 insertions, 148 deletions
diff --git a/lib/tinyusb b/lib/tinyusb
-Subproject 583326e535454f16b06ebdb9cc06869602a5564
+Subproject a660fb0cfc8641d5645d1cdea76027266b27838
diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot
index 82a0f95e6..232ad7c46 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: 2018-10-01 18:52-0400\n"
+"POT-Creation-Date: 2018-10-03 23:15+0700\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -378,10 +378,12 @@ msgid "bytes > 8 bits not supported"
msgstr ""
#: ports/atmel-samd/common-hal/busio/UART.c:72
+#: ports/nrf/common-hal/busio/UART.c:82
msgid "tx and rx cannot both be None"
msgstr ""
#: ports/atmel-samd/common-hal/busio/UART.c:145
+#: ports/nrf/common-hal/busio/UART.c:115
msgid "Failed to allocate RX buffer"
msgstr ""
@@ -390,10 +392,12 @@ msgid "Could not initialize UART"
msgstr ""
#: ports/atmel-samd/common-hal/busio/UART.c:240
+#: ports/nrf/common-hal/busio/UART.c:149
msgid "No RX pin"
msgstr ""
#: ports/atmel-samd/common-hal/busio/UART.c:294
+#: ports/nrf/common-hal/busio/UART.c:195
msgid "No TX pin"
msgstr ""
@@ -698,12 +702,29 @@ msgstr ""
msgid "All SPI peripherals are in use"
msgstr ""
-#: ports/nrf/common-hal/busio/UART.c:43 ports/nrf/common-hal/busio/UART.c:47
-#: ports/nrf/common-hal/busio/UART.c:51 ports/nrf/common-hal/busio/UART.c:60
-#: ports/nrf/common-hal/busio/UART.c:66 ports/nrf/common-hal/busio/UART.c:71
-#: ports/nrf/common-hal/busio/UART.c:76 ports/nrf/common-hal/busio/UART.c:81
-#: ports/nrf/common-hal/busio/UART.c:86 ports/nrf/common-hal/busio/UART.c:90
-msgid "busio.UART not yet implemented"
+#: ports/nrf/common-hal/busio/SPI.c:176
+msgid "Baud rate too high for this SPI peripheral"
+msgstr ""
+
+#: ports/nrf/common-hal/busio/UART.c:48
+#, c-format
+msgid "error = 0x%08lX"
+msgstr ""
+
+#: ports/nrf/common-hal/busio/UART.c:86
+msgid "Invalid buffer size"
+msgstr ""
+
+#: ports/nrf/common-hal/busio/UART.c:90
+msgid "Odd parity is not supported"
+msgstr ""
+
+#: ports/nrf/common-hal/busio/UART.c:322 ports/nrf/common-hal/busio/UART.c:326
+#: ports/nrf/common-hal/busio/UART.c:331 ports/nrf/common-hal/busio/UART.c:336
+#: ports/nrf/common-hal/busio/UART.c:342 ports/nrf/common-hal/busio/UART.c:347
+#: ports/nrf/common-hal/busio/UART.c:352 ports/nrf/common-hal/busio/UART.c:356
+#: ports/nrf/common-hal/busio/UART.c:364
+msgid "busio.UART not available"
msgstr ""
#: ports/nrf/common-hal/microcontroller/Processor.c:49
diff --git a/locale/de_DE.po b/locale/de_DE.po
index cbd981e48..790b23442 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: 2018-10-01 18:44-0400\n"
+"POT-Creation-Date: 2018-10-03 23:15+0700\n"
"PO-Revision-Date: 2018-07-27 11:55-0700\n"
"Last-Translator: Sebastian Plamauer\n"
"Language-Team: \n"
@@ -387,10 +387,12 @@ msgid "bytes > 8 bits not supported"
msgstr "bytes mit merh als 8 bits werden nicht unterstützt"
#: ports/atmel-samd/common-hal/busio/UART.c:72
+#: ports/nrf/common-hal/busio/UART.c:82
msgid "tx and rx cannot both be None"
msgstr "tx und rx können nicht beide None sein"
#: ports/atmel-samd/common-hal/busio/UART.c:145
+#: ports/nrf/common-hal/busio/UART.c:115
msgid "Failed to allocate RX buffer"
msgstr "Konnte keinen RX Buffer allozieren"
@@ -399,10 +401,12 @@ msgid "Could not initialize UART"
msgstr "Konnte UART nicht initialisieren"
#: ports/atmel-samd/common-hal/busio/UART.c:240
+#: ports/nrf/common-hal/busio/UART.c:149
msgid "No RX pin"
msgstr "Kein RX Pin"
#: ports/atmel-samd/common-hal/busio/UART.c:294
+#: ports/nrf/common-hal/busio/UART.c:195
msgid "No TX pin"
msgstr "Kein TX Pin"
@@ -709,12 +713,31 @@ msgstr "Alle timer werden benutzt"
msgid "All SPI peripherals are in use"
msgstr "Alle timer werden benutzt"
-#: ports/nrf/common-hal/busio/UART.c:43 ports/nrf/common-hal/busio/UART.c:47
-#: ports/nrf/common-hal/busio/UART.c:51 ports/nrf/common-hal/busio/UART.c:60
-#: ports/nrf/common-hal/busio/UART.c:66 ports/nrf/common-hal/busio/UART.c:71
-#: ports/nrf/common-hal/busio/UART.c:76 ports/nrf/common-hal/busio/UART.c:81
-#: ports/nrf/common-hal/busio/UART.c:86 ports/nrf/common-hal/busio/UART.c:90
-msgid "busio.UART not yet implemented"
+#: ports/nrf/common-hal/busio/SPI.c:176
+msgid "Baud rate too high for this SPI peripheral"
+msgstr ""
+
+#: ports/nrf/common-hal/busio/UART.c:48
+#, c-format
+msgid "error = 0x%08lX"
+msgstr ""
+
+#: ports/nrf/common-hal/busio/UART.c:86
+#, fuzzy
+msgid "Invalid buffer size"
+msgstr "ungültiger dupterm index"
+
+#: ports/nrf/common-hal/busio/UART.c:90
+#, fuzzy
+msgid "Odd parity is not supported"
+msgstr "bytes mit merh als 8 bits werden nicht unterstützt"
+
+#: ports/nrf/common-hal/busio/UART.c:322 ports/nrf/common-hal/busio/UART.c:326
+#: ports/nrf/common-hal/busio/UART.c:331 ports/nrf/common-hal/busio/UART.c:336
+#: ports/nrf/common-hal/busio/UART.c:342 ports/nrf/common-hal/busio/UART.c:347
+#: ports/nrf/common-hal/busio/UART.c:352 ports/nrf/common-hal/busio/UART.c:356
+#: ports/nrf/common-hal/busio/UART.c:364
+msgid "busio.UART not available"
msgstr ""
#: ports/nrf/common-hal/microcontroller/Processor.c:49
diff --git a/locale/en_US.po b/locale/en_US.po
index ca9e56444..6e576f150 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: 2018-10-01 18:44-0400\n"
+"POT-Creation-Date: 2018-10-03 23:15+0700\n"
"PO-Revision-Date: 2018-07-27 11:55-0700\n"
"Last-Translator: \n"
"Language-Team: \n"
@@ -378,10 +378,12 @@ msgid "bytes > 8 bits not supported"
msgstr ""
#: ports/atmel-samd/common-hal/busio/UART.c:72
+#: ports/nrf/common-hal/busio/UART.c:82
msgid "tx and rx cannot both be None"
msgstr ""
#: ports/atmel-samd/common-hal/busio/UART.c:145
+#: ports/nrf/common-hal/busio/UART.c:115
msgid "Failed to allocate RX buffer"
msgstr ""
@@ -390,10 +392,12 @@ msgid "Could not initialize UART"
msgstr ""
#: ports/atmel-samd/common-hal/busio/UART.c:240
+#: ports/nrf/common-hal/busio/UART.c:149
msgid "No RX pin"
msgstr ""
#: ports/atmel-samd/common-hal/busio/UART.c:294
+#: ports/nrf/common-hal/busio/UART.c:195
msgid "No TX pin"
msgstr ""
@@ -698,12 +702,29 @@ msgstr ""
msgid "All SPI peripherals are in use"
msgstr ""
-#: ports/nrf/common-hal/busio/UART.c:43 ports/nrf/common-hal/busio/UART.c:47
-#: ports/nrf/common-hal/busio/UART.c:51 ports/nrf/common-hal/busio/UART.c:60
-#: ports/nrf/common-hal/busio/UART.c:66 ports/nrf/common-hal/busio/UART.c:71
-#: ports/nrf/common-hal/busio/UART.c:76 ports/nrf/common-hal/busio/UART.c:81
-#: ports/nrf/common-hal/busio/UART.c:86 ports/nrf/common-hal/busio/UART.c:90
-msgid "busio.UART not yet implemented"
+#: ports/nrf/common-hal/busio/SPI.c:176
+msgid "Baud rate too high for this SPI peripheral"
+msgstr ""
+
+#: ports/nrf/common-hal/busio/UART.c:48
+#, c-format
+msgid "error = 0x%08lX"
+msgstr ""
+
+#: ports/nrf/common-hal/busio/UART.c:86
+msgid "Invalid buffer size"
+msgstr ""
+
+#: ports/nrf/common-hal/busio/UART.c:90
+msgid "Odd parity is not supported"
+msgstr ""
+
+#: ports/nrf/common-hal/busio/UART.c:322 ports/nrf/common-hal/busio/UART.c:326
+#: ports/nrf/common-hal/busio/UART.c:331 ports/nrf/common-hal/busio/UART.c:336
+#: ports/nrf/common-hal/busio/UART.c:342 ports/nrf/common-hal/busio/UART.c:347
+#: ports/nrf/common-hal/busio/UART.c:352 ports/nrf/common-hal/busio/UART.c:356
+#: ports/nrf/common-hal/busio/UART.c:364
+msgid "busio.UART not available"
msgstr ""
#: ports/nrf/common-hal/microcontroller/Processor.c:49
diff --git a/locale/es.po b/locale/es.po
index 87edf4ac4..2ac904943 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: 2018-10-01 18:44-0400\n"
+"POT-Creation-Date: 2018-10-03 23:15+0700\n"
"PO-Revision-Date: 2018-08-24 22:56-0500\n"
"Last-Translator: \n"
"Language-Team: \n"
@@ -393,10 +393,12 @@ msgid "bytes > 8 bits not supported"
msgstr "bytes > 8 bits no son soportados"
#: ports/atmel-samd/common-hal/busio/UART.c:72
+#: ports/nrf/common-hal/busio/UART.c:82
msgid "tx and rx cannot both be None"
msgstr "tx y rx no pueden ser ambos None"
#: ports/atmel-samd/common-hal/busio/UART.c:145
+#: ports/nrf/common-hal/busio/UART.c:115
msgid "Failed to allocate RX buffer"
msgstr "Fallo la asignación del buffer RX"
@@ -405,10 +407,12 @@ msgid "Could not initialize UART"
msgstr "No se pudo inicializar la UART"
#: ports/atmel-samd/common-hal/busio/UART.c:240
+#: ports/nrf/common-hal/busio/UART.c:149
msgid "No RX pin"
msgstr "Sin pin RX"
#: ports/atmel-samd/common-hal/busio/UART.c:294
+#: ports/nrf/common-hal/busio/UART.c:195
msgid "No TX pin"
msgstr "Sin pin TX"
@@ -715,12 +719,31 @@ msgstr "Todos los timers están siendo utilizados"
msgid "All SPI peripherals are in use"
msgstr "Todos los timers están siendo utilizados"
-#: ports/nrf/common-hal/busio/UART.c:43 ports/nrf/common-hal/busio/UART.c:47
-#: ports/nrf/common-hal/busio/UART.c:51 ports/nrf/common-hal/busio/UART.c:60
-#: ports/nrf/common-hal/busio/UART.c:66 ports/nrf/common-hal/busio/UART.c:71
-#: ports/nrf/common-hal/busio/UART.c:76 ports/nrf/common-hal/busio/UART.c:81
-#: ports/nrf/common-hal/busio/UART.c:86 ports/nrf/common-hal/busio/UART.c:90
-msgid "busio.UART not yet implemented"
+#: ports/nrf/common-hal/busio/SPI.c:176
+msgid "Baud rate too high for this SPI peripheral"
+msgstr ""
+
+#: ports/nrf/common-hal/busio/UART.c:48
+#, c-format
+msgid "error = 0x%08lX"
+msgstr ""
+
+#: ports/nrf/common-hal/busio/UART.c:86
+#, fuzzy
+msgid "Invalid buffer size"
+msgstr "index dupterm inválido"
+
+#: ports/nrf/common-hal/busio/UART.c:90
+#, fuzzy
+msgid "Odd parity is not supported"
+msgstr "bytes > 8 bits no son soportados"
+
+#: ports/nrf/common-hal/busio/UART.c:322 ports/nrf/common-hal/busio/UART.c:326
+#: ports/nrf/common-hal/busio/UART.c:331 ports/nrf/common-hal/busio/UART.c:336
+#: ports/nrf/common-hal/busio/UART.c:342 ports/nrf/common-hal/busio/UART.c:347
+#: ports/nrf/common-hal/busio/UART.c:352 ports/nrf/common-hal/busio/UART.c:356
+#: ports/nrf/common-hal/busio/UART.c:364
+msgid "busio.UART not available"
msgstr ""
#: ports/nrf/common-hal/microcontroller/Processor.c:49
diff --git a/locale/fil.po b/locale/fil.po
index d0ee49352..7c8c4fdfe 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: 2018-10-01 18:44-0400\n"
+"POT-Creation-Date: 2018-10-03 23:15+0700\n"
"PO-Revision-Date: 2018-08-30 23:04-0700\n"
"Last-Translator: Timothy <me@timothygarcia.ca>\n"
"Language-Team: fil\n"
@@ -390,10 +390,12 @@ msgid "bytes > 8 bits not supported"
msgstr "hindi sinusuportahan ang bytes > 8 bits"
#: ports/atmel-samd/common-hal/busio/UART.c:72
+#: ports/nrf/common-hal/busio/UART.c:82
msgid "tx and rx cannot both be None"
msgstr "tx at rx hindi pwedeng parehas na None"
#: ports/atmel-samd/common-hal/busio/UART.c:145
+#: ports/nrf/common-hal/busio/UART.c:115
msgid "Failed to allocate RX buffer"
msgstr "Nabigong ilaan ang RX buffer"
@@ -402,10 +404,12 @@ msgid "Could not initialize UART"
msgstr "Hindi ma-initialize ang UART"
#: ports/atmel-samd/common-hal/busio/UART.c:240
+#: ports/nrf/common-hal/busio/UART.c:149
msgid "No RX pin"
msgstr "Walang RX pin"
#: ports/atmel-samd/common-hal/busio/UART.c:294
+#: ports/nrf/common-hal/busio/UART.c:195
msgid "No TX pin"
msgstr "Walang TX pin"
@@ -715,13 +719,33 @@ msgstr "Lahat ng timer ginagamit"
msgid "All SPI peripherals are in use"
msgstr "Lahat ng timer ginagamit"
-#: ports/nrf/common-hal/busio/UART.c:43 ports/nrf/common-hal/busio/UART.c:47
-#: ports/nrf/common-hal/busio/UART.c:51 ports/nrf/common-hal/busio/UART.c:60
-#: ports/nrf/common-hal/busio/UART.c:66 ports/nrf/common-hal/busio/UART.c:71
-#: ports/nrf/common-hal/busio/UART.c:76 ports/nrf/common-hal/busio/UART.c:81
-#: ports/nrf/common-hal/busio/UART.c:86 ports/nrf/common-hal/busio/UART.c:90
-msgid "busio.UART not yet implemented"
-msgstr "hindi pa implemented ang busio.UART"
+#: ports/nrf/common-hal/busio/SPI.c:176
+msgid "Baud rate too high for this SPI peripheral"
+msgstr ""
+
+#: ports/nrf/common-hal/busio/UART.c:48
+#, c-format
+msgid "error = 0x%08lX"
+msgstr ""
+
+#: ports/nrf/common-hal/busio/UART.c:86
+#, fuzzy
+msgid "Invalid buffer size"
+msgstr "mali ang buffer length"
+
+#: ports/nrf/common-hal/busio/UART.c:90
+#, fuzzy
+msgid "Odd parity is not supported"
+msgstr "hindi sinusuportahan ang bytes > 8 bits"
+
+#: ports/nrf/common-hal/busio/UART.c:322 ports/nrf/common-hal/busio/UART.c:326
+#: ports/nrf/common-hal/busio/UART.c:331 ports/nrf/common-hal/busio/UART.c:336
+#: ports/nrf/common-hal/busio/UART.c:342 ports/nrf/common-hal/busio/UART.c:347
+#: ports/nrf/common-hal/busio/UART.c:352 ports/nrf/common-hal/busio/UART.c:356
+#: ports/nrf/common-hal/busio/UART.c:364
+#, fuzzy
+msgid "busio.UART not available"
+msgstr ""
#: ports/nrf/common-hal/microcontroller/Processor.c:49
#, c-format
diff --git a/locale/fr.po b/locale/fr.po
index 9d0786603..04d7a0665 100644
--- a/locale/fr.po
+++ b/locale/fr.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: 0.1\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2018-10-01 18:52-0400\n"
+"POT-Creation-Date: 2018-10-03 23:15+0700\n"
"PO-Revision-Date: 2018-08-14 11:01+0200\n"
"Last-Translator: Pierrick Couturier <arofarn@arofarn.info>\n"
"Language-Team: fr\n"
@@ -385,10 +385,12 @@ msgid "bytes > 8 bits not supported"
msgstr "octets > 8 bits non supporté"
#: ports/atmel-samd/common-hal/busio/UART.c:72
+#: ports/nrf/common-hal/busio/UART.c:82
msgid "tx and rx cannot both be None"
msgstr "TX et RX ne peuvent être None tous les deux"
#: ports/atmel-samd/common-hal/busio/UART.c:145
+#: ports/nrf/common-hal/busio/UART.c:115
msgid "Failed to allocate RX buffer"
msgstr "Echec de l'allocation du tampon RX"
@@ -397,10 +399,12 @@ msgid "Could not initialize UART"
msgstr "L'UART n'a pu être initialisé"
#: ports/atmel-samd/common-hal/busio/UART.c:240
+#: ports/nrf/common-hal/busio/UART.c:149
msgid "No RX pin"
msgstr "Pas de broche RX"
#: ports/atmel-samd/common-hal/busio/UART.c:294
+#: ports/nrf/common-hal/busio/UART.c:195
msgid "No TX pin"
msgstr "Pas de broche TX"
@@ -711,13 +715,33 @@ msgstr "Tous les timers sont utilisés"
msgid "All SPI peripherals are in use"
msgstr "Tous les timers sont utilisés"
-#: ports/nrf/common-hal/busio/UART.c:43 ports/nrf/common-hal/busio/UART.c:47
-#: ports/nrf/common-hal/busio/UART.c:51 ports/nrf/common-hal/busio/UART.c:60
-#: ports/nrf/common-hal/busio/UART.c:66 ports/nrf/common-hal/busio/UART.c:71
-#: ports/nrf/common-hal/busio/UART.c:76 ports/nrf/common-hal/busio/UART.c:81
-#: ports/nrf/common-hal/busio/UART.c:86 ports/nrf/common-hal/busio/UART.c:90
-msgid "busio.UART not yet implemented"
-msgstr "busio.UART pas encore implémenté"
+#: ports/nrf/common-hal/busio/SPI.c:176
+msgid "Baud rate too high for this SPI peripheral"
+msgstr ""
+
+#: ports/nrf/common-hal/busio/UART.c:48
+#, c-format
+msgid "error = 0x%08lX"
+msgstr ""
+
+#: ports/nrf/common-hal/busio/UART.c:86
+#, fuzzy
+msgid "Invalid buffer size"
+msgstr "longueur de tampon invalide"
+
+#: ports/nrf/common-hal/busio/UART.c:90
+#, fuzzy
+msgid "Odd parity is not supported"
+msgstr "octets > 8 bits non supporté"
+
+#: ports/nrf/common-hal/busio/UART.c:322 ports/nrf/common-hal/busio/UART.c:326
+#: ports/nrf/common-hal/busio/UART.c:331 ports/nrf/common-hal/busio/UART.c:336
+#: ports/nrf/common-hal/busio/UART.c:342 ports/nrf/common-hal/busio/UART.c:347
+#: ports/nrf/common-hal/busio/UART.c:352 ports/nrf/common-hal/busio/UART.c:356
+#: ports/nrf/common-hal/busio/UART.c:364
+#, fuzzy
+msgid "busio.UART not available"
+msgstr "busio.UART n'est pas disponible"
#: ports/nrf/common-hal/microcontroller/Processor.c:49
#, c-format
diff --git a/locale/pt_BR.po b/locale/pt_BR.po
index 723c9bc8e..d6b283c9f 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: 2018-10-02 01:19-0300\n"
+"POT-Creation-Date: 2018-10-03 23:15+0700\n"
"PO-Revision-Date: 2018-10-02 21:14-0000\n"
"Last-Translator: \n"
"Language-Team: \n"
@@ -361,7 +361,7 @@ msgstr "Não há pinos suficientes disponíveis"
#: ports/atmel-samd/common-hal/busio/SPI.c:132
#: ports/atmel-samd/common-hal/busio/UART.c:119
#: ports/atmel-samd/common-hal/i2cslave/I2CSlave.c:45
-#: ports/nrf/common-hal/busio/I2C.c:77
+#: ports/nrf/common-hal/busio/I2C.c:81
msgid "Invalid pins"
msgstr "Pinos inválidos"
@@ -378,10 +378,12 @@ msgid "bytes > 8 bits not supported"
msgstr "bytes > 8 bits não suportado"
#: ports/atmel-samd/common-hal/busio/UART.c:72
+#: ports/nrf/common-hal/busio/UART.c:82
msgid "tx and rx cannot both be None"
msgstr "TX e RX não podem ser ambos"
#: ports/atmel-samd/common-hal/busio/UART.c:145
+#: ports/nrf/common-hal/busio/UART.c:115
msgid "Failed to allocate RX buffer"
msgstr "Falha ao alocar buffer RX"
@@ -390,10 +392,12 @@ msgid "Could not initialize UART"
msgstr "Não foi possível inicializar o UART"
#: ports/atmel-samd/common-hal/busio/UART.c:240
+#: ports/nrf/common-hal/busio/UART.c:149
msgid "No RX pin"
msgstr "Nenhum pino RX"
#: ports/atmel-samd/common-hal/busio/UART.c:294
+#: ports/nrf/common-hal/busio/UART.c:195
msgid "No TX pin"
msgstr "Nenhum pino TX"
@@ -690,24 +694,39 @@ msgstr ""
msgid "AnalogOut functionality not supported"
msgstr ""
-#: ports/nrf/common-hal/busio/I2C.c:91
+#: ports/nrf/common-hal/busio/I2C.c:95
msgid "All I2C peripherals are in use"
msgstr ""
-#: ports/nrf/common-hal/busio/SPI.c:109
+#: ports/nrf/common-hal/busio/SPI.c:115
msgid "All SPI peripherals are in use"
msgstr ""
-#: ports/nrf/common-hal/busio/SPI.c:170
+#: ports/nrf/common-hal/busio/SPI.c:176
msgid "Baud rate too high for this SPI peripheral"
msgstr ""
-#: ports/nrf/common-hal/busio/UART.c:43 ports/nrf/common-hal/busio/UART.c:47
-#: ports/nrf/common-hal/busio/UART.c:51 ports/nrf/common-hal/busio/UART.c:60
-#: ports/nrf/common-hal/busio/UART.c:66 ports/nrf/common-hal/busio/UART.c:71
-#: ports/nrf/common-hal/busio/UART.c:76 ports/nrf/common-hal/busio/UART.c:81
-#: ports/nrf/common-hal/busio/UART.c:86 ports/nrf/common-hal/busio/UART.c:90
-msgid "busio.UART not yet implemented"
+#: ports/nrf/common-hal/busio/UART.c:48
+#, c-format
+msgid "error = 0x%08lX"
+msgstr ""
+
+#: ports/nrf/common-hal/busio/UART.c:86
+#, fuzzy
+msgid "Invalid buffer size"
+msgstr "Arquivo inválido"
+
+#: ports/nrf/common-hal/busio/UART.c:90
+#, fuzzy
+msgid "Odd parity is not supported"
+msgstr "I2C operação não suportada"
+
+#: ports/nrf/common-hal/busio/UART.c:322 ports/nrf/common-hal/busio/UART.c:326
+#: ports/nrf/common-hal/busio/UART.c:331 ports/nrf/common-hal/busio/UART.c:336
+#: ports/nrf/common-hal/busio/UART.c:342 ports/nrf/common-hal/busio/UART.c:347
+#: ports/nrf/common-hal/busio/UART.c:352 ports/nrf/common-hal/busio/UART.c:356
+#: ports/nrf/common-hal/busio/UART.c:364
+msgid "busio.UART not available"
msgstr ""
#: ports/nrf/common-hal/microcontroller/Processor.c:49
@@ -2254,7 +2273,8 @@ msgstr "Limite deve estar no alcance de 0-65536"
#: shared-bindings/util.c:38
msgid ""
"Object has been deinitialized and can no longer be used. Create a new object."
-msgstr "Objeto foi desinicializado e não pode ser mais usaado. Crie um novo objeto."
+msgstr ""
+"Objeto foi desinicializado e não pode ser mais usaado. Crie um novo objeto."
#: shared-module/audioio/WaveFile.c:61
msgid "Invalid wave file"
diff --git a/ports/nrf/Makefile b/ports/nrf/Makefile
index 0e9d224be..93ca78376 100755
--- a/ports/nrf/Makefile
+++ b/ports/nrf/Makefile
@@ -91,7 +91,7 @@ SRC_NRFX = $(addprefix nrfx/,\
drivers/src/nrfx_power.c \
drivers/src/nrfx_spim.c \
drivers/src/nrfx_twim.c \
- drivers/src/nrfx_uart.c \
+ drivers/src/nrfx_uarte.c \
)
SRC_C += \
@@ -100,6 +100,7 @@ SRC_C += \
internal_flash.c \
mphalport.c \
tick.c \
+ board_busses.c \
boards/$(BOARD)/board.c \
boards/$(BOARD)/pins.c \
device/$(MCU_VARIANT)/startup_$(MCU_SUB_VARIANT).c \
diff --git a/ports/nrf/boards/feather_nrf52832/mpconfigboard.h b/ports/nrf/boards/feather_nrf52832/mpconfigboard.h
index 0da1abfc4..e751ec182 100644
--- a/ports/nrf/boards/feather_nrf52832/mpconfigboard.h
+++ b/ports/nrf/boards/feather_nrf52832/mpconfigboard.h
@@ -30,7 +30,6 @@
#define MICROPY_HW_UART_RX NRF_GPIO_PIN_MAP(0, 8)
#define MICROPY_HW_UART_TX NRF_GPIO_PIN_MAP(0, 6)
-#define MICROPY_HW_UART_HWFC (0)
#define PORT_HEAP_SIZE (32 * 1024)
#define CIRCUITPY_AUTORELOAD_DELAY_MS 500
diff --git a/ports/nrf/boards/feather_nrf52840_express/mpconfigboard.h b/ports/nrf/boards/feather_nrf52840_express/mpconfigboard.h
index 81818741d..bd6d4b244 100644
--- a/ports/nrf/boards/feather_nrf52840_express/mpconfigboard.h
+++ b/ports/nrf/boards/feather_nrf52840_express/mpconfigboard.h
@@ -67,5 +67,5 @@
#define DEFAULT_SPI_BUS_MOSI (&pin_P0_23)
#define DEFAULT_SPI_BUS_MISO (&pin_P0_22)
-#define DEFAULT_UART_BUS_RX (&pin_P1_0)
+#define DEFAULT_UART_BUS_RX (&pin_P1_00)
#define DEFAULT_UART_BUS_TX (&pin_P0_24)
diff --git a/ports/nrf/boards/pca10056/mpconfigboard.h b/ports/nrf/boards/pca10056/mpconfigboard.h
index de4545d62..00a73005c 100644
--- a/ports/nrf/boards/pca10056/mpconfigboard.h
+++ b/ports/nrf/boards/pca10056/mpconfigboard.h
@@ -28,17 +28,9 @@
#define MICROPY_HW_MCU_NAME "nRF52840"
#define MICROPY_PY_SYS_PLATFORM "nRF52840-DK"
-// See legend on bottom of board
-#define MICROPY_HW_UART_RX NRF_GPIO_PIN_MAP(0, 8)
-#define MICROPY_HW_UART_TX NRF_GPIO_PIN_MAP(0, 6)
-#define MICROPY_HW_UART_HWFC (0)
-
#define PORT_HEAP_SIZE (128 * 1024)
#define CIRCUITPY_AUTORELOAD_DELAY_MS 500
-// Temp (could be removed) 0: usb cdc (default), 1 : hwuart (jlink)
-#define CFG_HWUART_FOR_SERIAL 0
-
#define DEFAULT_I2C_BUS_SCL (&pin_P0_27)
#define DEFAULT_I2C_BUS_SDA (&pin_P0_26)
diff --git a/ports/nrf/boards/pca10056/pins.c b/ports/nrf/boards/pca10056/pins.c
index 1c208f89b..a57c9d1c9 100644
--- a/ports/nrf/boards/pca10056/pins.c
+++ b/ports/nrf/boards/pca10056/pins.c
@@ -124,6 +124,8 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR_P1_15), MP_ROM_PTR(&pin_P1_15) },
{ MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_P1_15) },
{ MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_P1_15) },
+
+ { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) },
};
MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);
diff --git a/ports/nrf/common-hal/busio/UART.c b/ports/nrf/common-hal/busio/UART.c
index 06a348b76..b2dbb56a1 100644
--- a/ports/nrf/common-hal/busio/UART.c
+++ b/ports/nrf/common-hal/busio/UART.c
@@ -35,58 +35,333 @@
#include "supervisor/shared/translate.h"
#include "tick.h"
+#include "nrfx_uarte.h"
+#include <string.h>
-void common_hal_busio_uart_construct(busio_uart_obj_t *self,
- const mcu_pin_obj_t * tx, const mcu_pin_obj_t * rx, uint32_t baudrate,
- uint8_t bits, uart_parity_t parity, uint8_t stop, uint32_t timeout,
- uint8_t receiver_buffer_size) {
- mp_raise_NotImplementedError(translate("busio.UART not yet implemented"));
+#ifdef NRF52840_XXAA
+
+// expression to examine, and return value in case of failing
+#define _VERIFY_ERR(_exp) \
+ do {\
+ uint32_t _err = (_exp);\
+ if (NRFX_SUCCESS != _err ) {\
+ mp_raise_msg_varg(&mp_type_RuntimeError, translate("error = 0x%08lX"), _err);\
+ }\
+ }while(0)
+
+static uint32_t get_nrf_baud (uint32_t baudrate);
+
+static void uart_callback_irq (const nrfx_uarte_event_t * event, void * context) {
+ busio_uart_obj_t* self = (busio_uart_obj_t*) context;
+
+ switch ( event->type ) {
+ case NRFX_UARTE_EVT_RX_DONE:
+ self->rx_count = event->data.rxtx.bytes;
+ break;
+
+ case NRFX_UARTE_EVT_TX_DONE:
+ break;
+
+ case NRFX_UARTE_EVT_ERROR:
+ if ( self->rx_count == -1 ) {
+ self->rx_count = 0;
+ }
+ break;
+
+ default:
+ break;
+ }
+}
+
+
+void common_hal_busio_uart_construct (busio_uart_obj_t *self,
+ const mcu_pin_obj_t * tx, const mcu_pin_obj_t * rx, uint32_t baudrate,
+ uint8_t bits, uart_parity_t parity, uint8_t stop, uint32_t timeout,
+ uint8_t receiver_buffer_size) {
+ if ( (tx == mp_const_none) && (rx == mp_const_none) ) {
+ mp_raise_ValueError(translate("tx and rx cannot both be None"));
+ }
+
+ if ( receiver_buffer_size == 0 ) {
+ mp_raise_ValueError(translate("Invalid buffer size"));
+ }
+
+ if ( parity == PARITY_ODD ) {
+ mp_raise_ValueError(translate("Odd parity is not supported"));
+ }
+
+ nrfx_uarte_config_t config = {
+ .pseltxd = (tx == mp_const_none) ? NRF_UARTE_PSEL_DISCONNECTED : tx->number,
+ .pselrxd = (rx == mp_const_none) ? NRF_UARTE_PSEL_DISCONNECTED : rx->number,
+ .pselcts = NRF_UARTE_PSEL_DISCONNECTED,
+ .pselrts = NRF_UARTE_PSEL_DISCONNECTED,
+ .p_context = self,
+ .hwfc = NRF_UARTE_HWFC_DISABLED,
+ .parity = (parity == PARITY_NONE) ? NRF_UARTE_PARITY_EXCLUDED : NRF_UARTE_PARITY_INCLUDED,
+ .baudrate = get_nrf_baud(baudrate),
+ .interrupt_priority = 7
+ };
+
+ // support only 1 instance for now
+ self->uarte = (nrfx_uarte_t ) NRFX_UARTE_INSTANCE(0);
+ nrfx_uarte_uninit(&self->uarte);
+ _VERIFY_ERR(nrfx_uarte_init(&self->uarte, &config, uart_callback_irq));
+
+ // Init buffer for rx
+ if ( rx != mp_const_none ) {
+ self->buffer = (uint8_t *) gc_alloc(receiver_buffer_size, false, false);
+ if ( !self->buffer ) {
+ nrfx_uarte_uninit(&self->uarte);
+ mp_raise_msg(&mp_type_MemoryError, translate("Failed to allocate RX buffer"));
+ }
+ self->bufsize = receiver_buffer_size;
+
+ claim_pin(rx);
+ }
+
+ if ( tx != mp_const_none ) {
+ claim_pin(tx);
+ }
+
+ self->baudrate = baudrate;
+ self->timeout_ms = timeout;
+
+ // queue 1-byte transfer for rx_characters_available()
+ self->rx_count = -1;
+ _VERIFY_ERR(nrfx_uarte_rx(&self->uarte, self->buffer, 1));
}
bool common_hal_busio_uart_deinited(busio_uart_obj_t *self) {
- mp_raise_NotImplementedError(translate("busio.UART not yet implemented"));
+ return (nrf_uarte_rx_pin_get(self->uarte.p_reg) == NRF_UARTE_PSEL_DISCONNECTED) &&
+ (nrf_uarte_tx_pin_get(self->uarte.p_reg) == NRF_UARTE_PSEL_DISCONNECTED);
}
void common_hal_busio_uart_deinit(busio_uart_obj_t *self) {
- mp_raise_NotImplementedError(translate("busio.UART not yet implemented"));
- if (common_hal_busio_uart_deinited(self)) {
- return;
+ if ( !common_hal_busio_uart_deinited(self) ) {
+ nrfx_uarte_uninit(&self->uarte);
+ gc_free(self->buffer);
}
- // Do deinit;
}
// Read characters.
size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t len, int *errcode) {
- mp_raise_NotImplementedError(translate("busio.UART not yet implemented"));
- return 0;
+ if ( nrf_uarte_rx_pin_get(self->uarte.p_reg) == NRF_UARTE_PSEL_DISCONNECTED ) {
+ mp_raise_ValueError(translate("No RX pin"));
+ }
+
+ size_t remain = len;
+ uint64_t start_ticks = ticks_ms;
+
+ while ( 1 ) {
+ // Wait for on-going transfer to complete
+ while ( (self->rx_count == -1) && (ticks_ms - start_ticks < self->timeout_ms) ) {
+#ifdef MICROPY_VM_HOOK_LOOP
+ MICROPY_VM_HOOK_LOOP
+#endif
+ }
+
+ // copy received data
+ if ( self->rx_count > 0 ) {
+ memcpy(data, self->buffer, self->rx_count);
+ data += self->rx_count;
+ remain -= self->rx_count;
+
+ self->rx_count = 0;
+ }
+
+ // exit if complete or time up
+ if ( !remain || !(ticks_ms - start_ticks < self->timeout_ms) ) {
+ break;
+ }
+
+ // prepare next receiving
+ const size_t cnt = MIN(self->bufsize, remain);
+ self->rx_count = -1;
+ _VERIFY_ERR(nrfx_uarte_rx(&self->uarte, self->buffer, cnt));
+ }
+
+ // queue 1-byte transfer for rx_characters_available()
+ if ( self->rx_count == 0 ) {
+ self->rx_count = -1;
+ _VERIFY_ERR(nrfx_uarte_rx(&self->uarte, self->buffer, 1));
+ }
+
+ return len - remain;
}
// Write characters.
-size_t common_hal_busio_uart_write(busio_uart_obj_t *self, const uint8_t *data, size_t len, int *errcode) {
- mp_raise_NotImplementedError(translate("busio.UART not yet implemented"));
- return 0;
+size_t common_hal_busio_uart_write (busio_uart_obj_t *self, const uint8_t *data, size_t len, int *errcode) {
+ if ( nrf_uarte_tx_pin_get(self->uarte.p_reg) == NRF_UARTE_PSEL_DISCONNECTED ) {
+ mp_raise_ValueError(translate("No TX pin"));
+ }
+
+ if ( len == 0 ) return 0;
+
+ uint64_t start_ticks = ticks_ms;
+
+ // Wait for on-going transfer to complete
+ while ( nrfx_uarte_tx_in_progress(&self->uarte) && (ticks_ms - start_ticks < self->timeout_ms) ) {
+#ifdef MICROPY_VM_HOOK_LOOP
+ MICROPY_VM_HOOK_LOOP
+#endif
+ }
+
+ // Time up
+ if ( !(ticks_ms - start_ticks < self->timeout_ms) ) {
+ *errcode = MP_EAGAIN;
+ return MP_STREAM_ERROR;
+ }
+
+ // EasyDMA can only access SRAM
+ uint8_t * tx_buf = (uint8_t*) data;
+ if ( !nrfx_is_in_ram(data) ) {
+ tx_buf = (uint8_t *) gc_alloc(len, false, false);
+ memcpy(tx_buf, data, len);
+ }
+
+ (*errcode) = nrfx_uarte_tx(&self->uarte, tx_buf, len);
+ _VERIFY_ERR(*errcode);
+ (*errcode) = 0;
+
+ while ( nrfx_uarte_tx_in_progress(&self->uarte) && (ticks_ms - start_ticks < self->timeout_ms) ) {
+#ifdef MICROPY_VM_HOOK_LOOP
+ MICROPY_VM_HOOK_LOOP
+#endif
+ }
+
+ if ( !nrfx_is_in_ram(data) ) {
+ gc_free(tx_buf);
+ }
+
+ return len;
}
uint32_t common_hal_busio_uart_get_baudrate(busio_uart_obj_t *self) {
- mp_raise_NotImplementedError(translate("busio.UART not yet implemented"));
return self->baudrate;
}
void common_hal_busio_uart_set_baudrate(busio_uart_obj_t *self, uint32_t baudrate) {
- mp_raise_NotImplementedError(translate("busio.UART not yet implemented"));
self->baudrate = baudrate;
+ nrf_uarte_baudrate_set(self->uarte.p_reg, get_nrf_baud(baudrate));
}
uint32_t common_hal_busio_uart_rx_characters_available(busio_uart_obj_t *self) {
- mp_raise_NotImplementedError(translate("busio.UART not yet implemented"));
- return 0;
+ return (self->rx_count > 0) ? self->rx_count : 0;
}
void common_hal_busio_uart_clear_rx_buffer(busio_uart_obj_t *self) {
- mp_raise_NotImplementedError(translate("busio.UART not yet implemented"));
+ // Discard received byte, and queue 1-byte transfer for rx_characters_available()
+ if ( self->rx_count > 0 ) {
+ self->rx_count = -1;
+ _VERIFY_ERR(nrfx_uarte_rx(&self->uarte, self->buffer, 1));
+ }
}
bool common_hal_busio_uart_ready_to_tx(busio_uart_obj_t *self) {
- mp_raise_NotImplementedError(translate("busio.UART not yet implemented"));
+ return !nrfx_uarte_tx_in_progress(&self->uarte);
+}
+
+static uint32_t get_nrf_baud (uint32_t baudrate)
+{
+ if ( baudrate <= 1200 ) {
+ return NRF_UARTE_BAUDRATE_1200;
+ }
+ else if ( baudrate <= 2400 ) {
+ return NRF_UARTE_BAUDRATE_2400;
+ }
+ else if ( baudrate <= 4800 ) {
+ return NRF_UARTE_BAUDRATE_4800;
+ }
+ else if ( baudrate <= 9600 ) {
+ return NRF_UARTE_BAUDRATE_9600;
+ }
+ else if ( baudrate <= 14400 ) {
+ return NRF_UARTE_BAUDRATE_14400;
+ }
+ else if ( baudrate <= 19200 ) {
+ return NRF_UARTE_BAUDRATE_19200;
+ }
+ else if ( baudrate <= 28800 ) {
+ return NRF_UARTE_BAUDRATE_28800;
+ }
+ else if ( baudrate <= 38400 ) {
+ return NRF_UARTE_BAUDRATE_38400;
+ }
+ else if ( baudrate <= 57600 ) {
+ return NRF_UARTE_BAUDRATE_57600;
+ }
+ else if ( baudrate <= 76800 ) {
+ return NRF_UARTE_BAUDRATE_76800;
+ }
+ else if ( baudrate <= 115200 ) {
+ return NRF_UARTE_BAUDRATE_115200;
+ }
+ else if ( baudrate <= 230400 ) {
+ return NRF_UARTE_BAUDRATE_230400;
+ }
+ else if ( baudrate <= 250000 ) {
+ return NRF_UARTE_BAUDRATE_250000;
+ }
+ else if ( baudrate <= 460800 ) {
+ return NRF_UARTE_BAUDRATE_460800;
+ }
+ else if ( baudrate <= 921600 ) {
+ return NRF_UARTE_BAUDRATE_921600;
+ }
+ else {
+ return NRF_UARTE_BAUDRATE_1000000;
+ }
+}
+
+#else
+
+void common_hal_busio_uart_construct (busio_uart_obj_t *self,
+ const mcu_pin_obj_t * tx, const mcu_pin_obj_t * rx, uint32_t baudrate,
+ uint8_t bits, uart_parity_t parity, uint8_t stop, uint32_t timeout,
+ uint8_t receiver_buffer_size) {
+ mp_raise_NotImplementedError(translate("busio.UART not available"));
+}
+
+bool common_hal_busio_uart_deinited (busio_uart_obj_t *self) {
+ mp_raise_NotImplementedError(translate("busio.UART not available"));
+ return true;
+}
+
+void common_hal_busio_uart_deinit (busio_uart_obj_t *self) {
+ mp_raise_NotImplementedError(translate("busio.UART not available"));
+}
+
+// Read characters.
+size_t common_hal_busio_uart_read (busio_uart_obj_t *self, uint8_t *data, size_t len, int *errcode) {
+ mp_raise_NotImplementedError(translate("busio.UART not available"));
+ return 0;
+}
+
+// Write characters.
+size_t common_hal_busio_uart_write (busio_uart_obj_t *self, const uint8_t *data, size_t len, int *errcode) {
+ mp_raise_NotImplementedError(translate("busio.UART not available"));
+ return 0;
+}
+
+uint32_t common_hal_busio_uart_get_baudrate (busio_uart_obj_t *self) {
+ mp_raise_NotImplementedError(translate("busio.UART not available"));
+ return self->baudrate;
+}
+
+void common_hal_busio_uart_set_baudrate (busio_uart_obj_t *self, uint32_t baudrate) {
+ mp_raise_NotImplementedError(translate("busio.UART not available"));
+}
+
+uint32_t common_hal_busio_uart_rx_characters_available (busio_uart_obj_t *self) {
+ mp_raise_NotImplementedError(translate("busio.UART not available"));
+}
+
+void common_hal_busio_uart_clear_rx_buffer (busio_uart_obj_t *self) {
+
+}
+
+bool common_hal_busio_uart_ready_to_tx (busio_uart_obj_t *self) {
+ mp_raise_NotImplementedError(translate("busio.UART not available"));
return false;
}
+#endif
diff --git a/ports/nrf/common-hal/busio/UART.h b/ports/nrf/common-hal/busio/UART.h
index 7c0493e37..aef377f14 100644
--- a/ports/nrf/common-hal/busio/UART.h
+++ b/ports/nrf/common-hal/busio/UART.h
@@ -28,23 +28,22 @@
#define MICROPY_INCLUDED_NRF_COMMON_HAL_BUSIO_UART_H
#include "common-hal/microcontroller/Pin.h"
+#include "nrfx_uarte.h"
#include "py/obj.h"
+#include "py/ringbuf.h"
typedef struct {
mp_obj_base_t base;
- uint8_t rx_pin;
- uint8_t tx_pin;
- uint8_t character_bits;
- bool rx_error;
+
+ nrfx_uarte_t uarte;
+
uint32_t baudrate;
uint32_t timeout_ms;
- // Index of the oldest received character.
- uint32_t buffer_start;
- // Index of the next available spot to store a character.
- uint32_t buffer_size;
- uint32_t buffer_length;
+
uint8_t* buffer;
+ uint32_t bufsize;
+ volatile int32_t rx_count;
} busio_uart_obj_t;
#endif // MICROPY_INCLUDED_NRF_COMMON_HAL_BUSIO_UART_H
diff --git a/ports/nrf/mphalport.c b/ports/nrf/mphalport.c
index 1e1ebf32e..27ed57bf3 100644
--- a/ports/nrf/mphalport.c
+++ b/ports/nrf/mphalport.c
@@ -27,36 +27,40 @@
#include <string.h>
-#include "mphalport.h"
+#include "py/mphal.h"
#include "py/mpstate.h"
-
+#include "py/gc.h"
#if (MICROPY_PY_BLE_NUS == 0)
-#if !defined( NRF52840_XXAA) || ( defined(CFG_HWUART_FOR_SERIAL) && CFG_HWUART_FOR_SERIAL == 1 )
+#if !defined( NRF52840_XXAA)
int mp_hal_stdin_rx_chr(void) {
- uint8_t data = 0;
-
- while (!nrfx_uart_rx_ready(&serial_instance));
-
- const nrfx_err_t err = nrfx_uart_rx(&serial_instance, &data, sizeof(data));
- if (err == NRFX_SUCCESS)
- NRFX_ASSERT(err);
-
+ uint8_t data;
+ nrfx_uarte_rx(&serial_instance, &data, 1);
return data;
}
bool mp_hal_stdin_any(void) {
- return nrfx_uart_rx_ready(&serial_instance);
+ return nrf_uarte_event_check(serial_instance.p_reg, NRF_UARTE_EVENT_RXDRDY);
}
void mp_hal_stdout_tx_strn(const char *str, mp_uint_t len) {
- if (len == 0)
+ if (len == 0) {
return;
+ }
- const nrfx_err_t err = nrfx_uart_tx(&serial_instance, (uint8_t*)str, len);
- if (err == NRFX_SUCCESS)
- NRFX_ASSERT(err);
+ // EasyDMA can only access SRAM
+ uint8_t * tx_buf = (uint8_t*) str;
+ if ( !nrfx_is_in_ram(str) ) {
+ tx_buf = (uint8_t *) gc_alloc(len, false, false);
+ memcpy(tx_buf, str, len);
+ }
+
+ nrfx_uarte_tx(&serial_instance, tx_buf, len);
+
+ if ( !nrfx_is_in_ram(str) ) {
+ gc_free(tx_buf);
+ }
}
#else
diff --git a/ports/nrf/mphalport.h b/ports/nrf/mphalport.h
index f283cf38d..a1929a4ac 100644
--- a/ports/nrf/mphalport.h
+++ b/ports/nrf/mphalport.h
@@ -31,21 +31,16 @@
#include <stdint.h>
#include "lib/utils/interrupt_char.h"
-#include "nrfx_uart.h"
+#include "nrfx_uarte.h"
#include "py/mpconfig.h"
-extern nrfx_uart_t serial_instance;
+extern nrfx_uarte_t serial_instance;
extern volatile uint64_t ticks_ms;
-static inline mp_uint_t mp_hal_ticks_ms(void) {
- return ticks_ms;
-}
+#define mp_hal_ticks_ms() ((mp_uint_t) ticks_ms)
+#define mp_hal_delay_us(us) NRFX_DELAY_US((uint32_t) (us))
-int mp_hal_stdin_rx_chr(void);
-void mp_hal_stdout_tx_str(const char *str);
bool mp_hal_stdin_any(void);
-void mp_hal_delay_ms(mp_uint_t ms);
-#define mp_hal_delay_us(us) NRFX_DELAY_US((uint32_t) (us))
#endif
diff --git a/ports/nrf/nrfx b/ports/nrf/nrfx
-Subproject 293f553ed9551c1fdfd05eac48e75bbdeb4e729
+Subproject 67710e47c7313cc56a15748e485079831ee6a3a
diff --git a/ports/nrf/nrfx_config.h b/ports/nrf/nrfx_config.h
index cc4d19327..f217cb053 100644
--- a/ports/nrf/nrfx_config.h
+++ b/ports/nrf/nrfx_config.h
@@ -45,13 +45,8 @@
#define NRFX_TWIM_DEFAULT_CONFIG_HOLD_BUS_UNINIT 0
// UART
-#define NRFX_UART_ENABLED 1
-#define NRFX_UART0_ENABLED 1
-
-#define NRFX_UART_DEFAULT_CONFIG_IRQ_PRIORITY 7
-#define NRFX_UART_DEFAULT_CONFIG_HWFC NRF_UART_HWFC_DISABLED
-#define NRFX_UART_DEFAULT_CONFIG_PARITY NRF_UART_PARITY_EXCLUDED
-#define NRFX_UART_DEFAULT_CONFIG_BAUDRATE NRF_UART_BAUDRATE_115200
+#define NRFX_UARTE_ENABLED 1
+#define NRFX_UARTE0_ENABLED 1
// PWM
#define NRFX_PWM0_ENABLED 1
diff --git a/ports/nrf/supervisor/serial.c b/ports/nrf/supervisor/serial.c
index da7fe07fd..cfbcc4b31 100644
--- a/ports/nrf/supervisor/serial.c
+++ b/ports/nrf/supervisor/serial.c
@@ -24,19 +24,19 @@
* THE SOFTWARE.
*/
-#include "mphalport.h"
+#include "py/mphal.h"
#if MICROPY_PY_BLE_NUS
#include "ble_uart.h"
#else
#include "nrf_gpio.h"
+#include "nrfx_uarte.h"
#endif
-#if !defined( NRF52840_XXAA) || ( defined(CFG_HWUART_FOR_SERIAL) && CFG_HWUART_FOR_SERIAL == 1 )
+#if !defined(NRF52840_XXAA)
-#define INST_NO 0
-
-nrfx_uart_t serial_instance = NRFX_UART_INSTANCE(INST_NO);
+uint8_t serial_received_char;
+nrfx_uarte_t serial_instance = NRFX_UARTE_INSTANCE(0);
void serial_init(void) {
#if MICROPY_PY_BLE_NUS
@@ -45,22 +45,27 @@ void serial_init(void) {
;
}
#else
- nrfx_uart_config_t config = NRFX_UART_DEFAULT_CONFIG;
- config.pseltxd = MICROPY_HW_UART_TX;
- config.pselrxd = MICROPY_HW_UART_RX;
- config.hwfc = MICROPY_HW_UART_HWFC ? NRF_UART_HWFC_ENABLED : NRF_UART_HWFC_DISABLED;
-#ifdef MICROPY_HW_UART_CTS
- config.pselcts = MICROPY_HW_UART_CTS;
-#endif
-#ifdef MICROPY_HW_UART_RTS
- config.pselrts = MICROPY_HW_UART_RTS;
-#endif
-
- const nrfx_err_t err = nrfx_uart_init(&serial_instance, &config, NULL);
- if (err == NRFX_SUCCESS)
+ nrfx_uarte_config_t config = {
+ .pseltxd = MICROPY_HW_UART_TX,
+ .pselrxd = MICROPY_HW_UART_RX,
+ .pselcts = NRF_UARTE_PSEL_DISCONNECTED,
+ .pselrts = NRF_UARTE_PSEL_DISCONNECTED,
+ .p_context = NULL,
+ .hwfc = NRF_UARTE_HWFC_DISABLED,
+ .parity = NRF_UARTE_PARITY_EXCLUDED,
+ .baudrate = NRF_UARTE_BAUDRATE_115200,
+ .interrupt_priority = 7
+ };
+
+ nrfx_uarte_uninit(&serial_instance);
+ const nrfx_err_t err = nrfx_uarte_init(&serial_instance, &config, NULL); // no callback for blocking mode
+
+ if (err != NRFX_SUCCESS) {
NRFX_ASSERT(err);
+ }
- nrfx_uart_rx_enable(&serial_instance);
+ // enabled receiving
+ nrf_uarte_task_trigger(serial_instance.p_reg, NRF_UARTE_TASK_STARTRX);
#endif
}