|
|
@ -31,13 +31,16 @@ |
|
|
|
#include <stdio.h> |
|
|
|
#include <stdint.h> |
|
|
|
#include <string.h> |
|
|
|
|
|
|
|
|
|
|
|
#include "py/mpstate.h" |
|
|
|
#include MICROPY_HAL_H |
|
|
|
#include "py/runtime.h" |
|
|
|
#include "py/objstr.h" |
|
|
|
#include "inc/hw_types.h" |
|
|
|
#include "inc/hw_ints.h" |
|
|
|
#include "inc/hw_nvic.h" |
|
|
|
#include "hw_memmap.h" |
|
|
|
#include "py/mpstate.h" |
|
|
|
#include "py/runtime.h" |
|
|
|
#include MICROPY_HAL_H |
|
|
|
#include "rom_map.h" |
|
|
|
#include "interrupt.h" |
|
|
|
#include "systick.h" |
|
|
@ -142,7 +145,7 @@ void mp_hal_stdout_tx_strn(const char *str, uint32_t len) { |
|
|
|
if (MP_OBJ_IS_TYPE(MP_STATE_PORT(os_term_dup_obj)->stream_o, &pyb_uart_type)) { |
|
|
|
uart_tx_strn(MP_STATE_PORT(os_term_dup_obj)->stream_o, str, len); |
|
|
|
} else { |
|
|
|
MP_STATE_PORT(os_term_dup_obj)->write[2] = mp_obj_new_bytes((const byte*)str, len); |
|
|
|
MP_STATE_PORT(os_term_dup_obj)->write[2] = mp_obj_new_str_of_type(&mp_type_str, (const byte *)str, len); |
|
|
|
mp_call_method_n_kw(1, 0, MP_STATE_PORT(os_term_dup_obj)->write); |
|
|
|
} |
|
|
|
} |
|
|
@ -181,10 +184,11 @@ int mp_hal_stdin_rx_chr(void) { |
|
|
|
} |
|
|
|
} else { |
|
|
|
MP_STATE_PORT(os_term_dup_obj)->read[2] = mp_obj_new_int(1); |
|
|
|
mp_obj_t rbytes = mp_call_method_n_kw(1, 0, MP_STATE_PORT(os_term_dup_obj)->read); |
|
|
|
if (rbytes != mp_const_none) { |
|
|
|
mp_obj_t data = mp_call_method_n_kw(1, 0, MP_STATE_PORT(os_term_dup_obj)->read); |
|
|
|
// data len is > 0
|
|
|
|
if (mp_obj_is_true(data)) { |
|
|
|
mp_buffer_info_t bufinfo; |
|
|
|
mp_get_buffer_raise(rbytes, &bufinfo, MP_BUFFER_READ); |
|
|
|
mp_get_buffer_raise(data, &bufinfo, MP_BUFFER_READ); |
|
|
|
return ((int *)(bufinfo.buf))[0]; |
|
|
|
} |
|
|
|
} |
|
|
|