summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--py/mpconfig.h5
-rw-r--r--shared/libc/printf.c4
2 files changed, 7 insertions, 2 deletions
diff --git a/py/mpconfig.h b/py/mpconfig.h
index 564580c02..db9c623f4 100644
--- a/py/mpconfig.h
+++ b/py/mpconfig.h
@@ -904,6 +904,11 @@ typedef double mp_float_t;
#define MICROPY_USE_INTERNAL_PRINTF (1)
#endif
+// The mp_print_t printer used for printf output when MICROPY_USE_INTERNAL_PRINTF is enabled
+#ifndef MICROPY_INTERNAL_PRINTF_PRINTER
+#define MICROPY_INTERNAL_PRINTF_PRINTER (&mp_plat_print)
+#endif
+
// Support for internal scheduler
#ifndef MICROPY_ENABLE_SCHEDULER
#define MICROPY_ENABLE_SCHEDULER (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
diff --git a/shared/libc/printf.c b/shared/libc/printf.c
index e8db2b999..6b5373188 100644
--- a/shared/libc/printf.c
+++ b/shared/libc/printf.c
@@ -60,13 +60,13 @@ int snprintf(char *str, size_t size, const char *fmt, ...);
int printf(const char *fmt, ...) {
va_list ap;
va_start(ap, fmt);
- int ret = mp_vprintf(&mp_plat_print, fmt, ap);
+ int ret = mp_vprintf(MICROPY_INTERNAL_PRINTF_PRINTER, fmt, ap);
va_end(ap);
return ret;
}
int vprintf(const char *fmt, va_list ap) {
- return mp_vprintf(&mp_plat_print, fmt, ap);
+ return mp_vprintf(MICROPY_INTERNAL_PRINTF_PRINTER, fmt, ap);
}
// need this because gcc optimises printf("%c", c) -> putchar(c), and printf("a") -> putchar('a')