3030#include "py/mpstate.h"
3131#include "py/mphal.h"
3232#include "py/mperrno.h"
33- #include "uart .h"
33+ #include "hal_uart .h"
3434
35+ #define UART_INSTANCE UART_BASE(0)
3536FIL * boot_output_file ;
3637
3738// this table converts from HAL_StatusTypeDef to POSIX errno
@@ -46,36 +47,36 @@ NORETURN void mp_hal_raise(HAL_StatusTypeDef status) {
4647 nlr_raise (mp_obj_new_exception_arg1 (& mp_type_OSError , MP_OBJ_NEW_SMALL_INT (mp_hal_status_to_errno_table [status ])));
4748}
4849
49- void mp_hal_set_interrupt_char (int c ) {
50-
51- }
52-
5350#if (MICROPY_PY_BLE_NUS == 0 )
5451int mp_hal_stdin_rx_chr (void ) {
5552 for (;;) {
56- if (MP_STATE_PORT (pyb_stdio_uart ) != NULL && uart_rx_any (MP_STATE_PORT (pyb_stdio_uart ))) {
57- return uart_rx_char (MP_STATE_PORT (pyb_stdio_uart ));
53+ if ( hal_uart_available (UART_INSTANCE ) ) {
54+ uint8_t ch ;
55+ hal_uart_char_read (UART_INSTANCE , & ch );
56+ return (int ) ch ;
5857 }
5958 }
6059
6160 return 0 ;
6261}
6362
64- bool mp_hal_stdin_any (void )
65- {
66- return uart_rx_any (MP_STATE_PORT (pyb_stdio_uart ));
63+ bool mp_hal_stdin_any (void ) {
64+ return hal_uart_available (UART_INSTANCE );
6765}
6866
6967void mp_hal_stdout_tx_strn (const char * str , mp_uint_t len ) {
70- if ( MP_STATE_PORT ( pyb_stdio_uart ) != NULL ) {
71- uart_tx_strn ( MP_STATE_PORT ( pyb_stdio_uart ), str , len );
72- }
68+ while ( len -- ) {
69+ hal_uart_char_write ( UART_INSTANCE , * str ++ );
70+ }
7371}
7472
7573void mp_hal_stdout_tx_strn_cooked (const char * str , mp_uint_t len ) {
76- if (MP_STATE_PORT (pyb_stdio_uart ) != NULL ) {
77- uart_tx_strn_cooked (MP_STATE_PORT (pyb_stdio_uart ), str , len );
74+ while (len -- ){
75+ if (* str == '\n' ) {
76+ hal_uart_char_write (UART_INSTANCE , '\r' );
7877 }
78+ hal_uart_char_write (UART_INSTANCE , * str ++ );
79+ }
7980}
8081#endif
8182
0 commit comments