summaryrefslogtreecommitdiff
path: root/stmhal/printf.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-07-20 13:57:43 +0100
committerDamien George <damien.p.george@gmail.com>2014-07-20 13:57:43 +0100
commit951ed9d02ffc826c68ee3af26c3530477e7e6156 (patch)
treeeb70f46b030031c8601d71d575e36771cf6c5564 /stmhal/printf.c
parent1163cb9cb5e48153d1a6d723e8577d8ec3821692 (diff)
stmhal: Fix REPL printing by cooking output sent to stdout_obj.
Recent changes to builtin print meant that print was printing to the mp_sys_stdout_obj, which was sending data raw to the USB CDC device. The data should be cooked so that \n turns into \r\n.
Diffstat (limited to 'stmhal/printf.c')
-rw-r--r--stmhal/printf.c18
1 files changed, 4 insertions, 14 deletions
diff --git a/stmhal/printf.c b/stmhal/printf.c
index 53c47c633..db611f3d9 100644
--- a/stmhal/printf.c
+++ b/stmhal/printf.c
@@ -40,6 +40,7 @@
#endif
#include "uart.h"
#include "usb.h"
+#include "pybstdio.h"
#if MICROPY_PY_BUILTINS_FLOAT
#include "formatfloat.h"
@@ -47,22 +48,11 @@
int pfenv_vprintf(const pfenv_t *pfenv, const char *fmt, va_list args);
-void pfenv_prints(const pfenv_t *pfenv, const char *str) {
- pfenv->print_strn(pfenv->data, str, strlen(str));
+STATIC void stdout_print_strn(void *dummy_env, const char *str, unsigned int len) {
+ stdout_tx_strn_cooked(str, len);
}
-STATIC void stdout_print_strn(void *data, const char *str, unsigned int len) {
- // TODO this needs to be replaced with a proper stdio interface ala CPython
- // send stdout to UART and USB CDC VCP
- if (pyb_uart_global_debug != PYB_UART_NONE) {
- uart_tx_strn_cooked(pyb_uart_global_debug, str, len);
- }
- if (usb_vcp_is_enabled()) {
- usb_vcp_send_strn_cooked(str, len);
- }
-}
-
-static const pfenv_t pfenv_stdout = {0, stdout_print_strn};
+STATIC const pfenv_t pfenv_stdout = {0, stdout_print_strn};
int printf(const char *fmt, ...) {
va_list ap;