summaryrefslogtreecommitdiffstatshomepage
path: root/esp8266/esp_mphal.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2015-02-13 15:04:53 +0000
committerDamien George <damien.p.george@gmail.com>2015-02-13 15:04:53 +0000
commit0b32e50365b6e36474e183a7240ccfc8fa56830a (patch)
tree101cf35f6844c50672af4f15b5866e226bcb47d9 /esp8266/esp_mphal.c
parentc385a639e6316cba4ff0e7a859325807857d8f00 (diff)
downloadmicropython-0b32e50365b6e36474e183a7240ccfc8fa56830a.tar.gz
micropython-0b32e50365b6e36474e183a7240ccfc8fa56830a.zip
stmhal: Make pybstdio usable by other ports, and use it.
Now all ports can use pybstdio.c to provide sys.stdin/stdout/stderr, so long as they implement mp_hal_stdin_* and mp_hal_stdout_* functions.
Diffstat (limited to 'esp8266/esp_mphal.c')
-rw-r--r--esp8266/esp_mphal.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/esp8266/esp_mphal.c b/esp8266/esp_mphal.c
index 821866f689..53a1700277 100644
--- a/esp8266/esp_mphal.c
+++ b/esp8266/esp_mphal.c
@@ -49,23 +49,30 @@ void mp_hal_udelay(uint32_t us) {
ets_delay_us(us);
}
-int mp_hal_uart0_rx_chr(void) {
- return uart0_rx();
+int mp_hal_stdin_rx_chr(void) {
+ for (;;) {
+ int c = uart0_rx();
+ if (c != -1) {
+ return c;
+ }
+ mp_hal_udelay(1);
+ mp_hal_feed_watchdog();
+ }
}
-void mp_hal_uart0_write_str(const char *str) {
+void mp_hal_stdout_tx_str(const char *str) {
while (*str) {
uart_tx_one_char(UART0, *str++);
}
}
-void mp_hal_uart0_write_strn(const char *str, uint32_t len) {
+void mp_hal_stdout_tx_strn(const char *str, uint32_t len) {
while (len--) {
uart_tx_one_char(UART0, *str++);
}
}
-void mp_hal_uart0_write_strn_cooked(const char *str, uint32_t len) {
+void mp_hal_stdout_tx_strn_cooked(const char *str, uint32_t len) {
while (len--) {
if (*str == '\n') {
uart_tx_one_char(UART0, '\r');