summaryrefslogtreecommitdiffstatshomepage
path: root/stmhal/pybstdio.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2015-01-07 23:38:50 +0000
committerDamien George <damien.p.george@gmail.com>2015-01-07 23:38:50 +0000
commit3b51b3e90f1d513031ad2c6b6a2a0d5d391f753d (patch)
tree6903d1a13bdc49860c325e531e81582beb6063bf /stmhal/pybstdio.c
parent7a0636e80aea2ce1af03c890e024dabcdffcdf78 (diff)
downloadmicropython-3b51b3e90f1d513031ad2c6b6a2a0d5d391f753d.tar.gz
micropython-3b51b3e90f1d513031ad2c6b6a2a0d5d391f753d.zip
stmhal: Collect all root pointers together in 1 place.
A GC in stmhal port now only scans true root pointers, not entire BSS. This reduces base GC time from 1700ms to 900ms.
Diffstat (limited to 'stmhal/pybstdio.c')
-rw-r--r--stmhal/pybstdio.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/stmhal/pybstdio.c b/stmhal/pybstdio.c
index 5597bbd689..d8ccc1be0a 100644
--- a/stmhal/pybstdio.c
+++ b/stmhal/pybstdio.c
@@ -29,6 +29,7 @@
#include <string.h>
#include <errno.h>
+#include "py/mpstate.h"
#include "py/obj.h"
#include "py/stream.h"
#include "usb.h"
@@ -40,16 +41,13 @@
// be changed by Python code. This requires some changes, as these
// objects are in a read-only module (py/modsys.c).
-// stdio is repeated on this UART object if it's not null
-pyb_uart_obj_t *pyb_stdio_uart = NULL;
-
void stdout_tx_str(const char *str) {
stdout_tx_strn(str, strlen(str));
}
void stdout_tx_strn(const char *str, mp_uint_t len) {
- if (pyb_stdio_uart != PYB_UART_NONE) {
- uart_tx_strn(pyb_stdio_uart, str, len);
+ if (MP_STATE_PORT(pyb_stdio_uart) != NULL) {
+ uart_tx_strn(MP_STATE_PORT(pyb_stdio_uart), str, len);
}
#if 0 && defined(USE_HOST_MODE) && MICROPY_HW_HAS_LCD
lcd_print_strn(str, len);
@@ -61,8 +59,8 @@ void stdout_tx_strn(const char *str, mp_uint_t len) {
void stdout_tx_strn_cooked(const char *str, mp_uint_t len) {
// send stdout to UART and USB CDC VCP
- if (pyb_stdio_uart != PYB_UART_NONE) {
- uart_tx_strn_cooked(pyb_stdio_uart, str, len);
+ if (MP_STATE_PORT(pyb_stdio_uart) != NULL) {
+ uart_tx_strn_cooked(MP_STATE_PORT(pyb_stdio_uart), str, len);
}
if (usb_vcp_is_enabled()) {
usb_vcp_send_strn_cooked(str, len);
@@ -84,8 +82,8 @@ int stdin_rx_chr(void) {
byte c;
if (usb_vcp_recv_byte(&c) != 0) {
return c;
- } else if (pyb_stdio_uart != PYB_UART_NONE && uart_rx_any(pyb_stdio_uart)) {
- return uart_rx_char(pyb_stdio_uart);
+ } else if (MP_STATE_PORT(pyb_stdio_uart) != NULL && uart_rx_any(MP_STATE_PORT(pyb_stdio_uart))) {
+ return uart_rx_char(MP_STATE_PORT(pyb_stdio_uart));
}
__WFI();
}