summaryrefslogtreecommitdiff
path: root/minimal/uart_core.c
diff options
context:
space:
mode:
Diffstat (limited to 'minimal/uart_core.c')
-rw-r--r--minimal/uart_core.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/minimal/uart_core.c b/minimal/uart_core.c
new file mode 100644
index 000000000..92c81ecc9
--- /dev/null
+++ b/minimal/uart_core.c
@@ -0,0 +1,24 @@
+#include <unistd.h>
+#include "py/mpconfig.h"
+
+/*
+ * Core UART functions to implement for a port
+ */
+
+// Receive single character
+int stdin_rx_chr(void) {
+ unsigned char c = 0;
+#if MICROPY_MIN_USE_STDOUT
+ int r = read(0, &c, 1);
+ (void)r;
+#endif
+ return c;
+}
+
+// Send string of given length
+void stdout_tx_strn(const char *str, mp_uint_t len) {
+#if MICROPY_MIN_USE_STDOUT
+ int r = write(1, str, len);
+ (void)r;
+#endif
+}