@@ -239,9 +239,9 @@ void uart_tx_strn_cooked(pyb_uart_obj_t *uart_obj, const char *str, uint len) {
239239STATIC void pyb_uart_print (void (* print )(void * env , const char * fmt , ...), void * env , mp_obj_t self_in , mp_print_kind_t kind ) {
240240 pyb_uart_obj_t * self = self_in ;
241241 if (!self -> is_enabled ) {
242- print (env , "UART(%lu )" , self -> uart_id );
242+ print (env , "UART(%u )" , self -> uart_id );
243243 } else {
244- print (env , "UART(%lu , baudrate=%u, bits=%u, stop=%u" ,
244+ print (env , "UART(%u , baudrate=%u, bits=%u, stop=%u" ,
245245 self -> uart_id , self -> uart .Init .BaudRate ,
246246 self -> uart .Init .WordLength == UART_WORDLENGTH_8B ? 8 : 9 ,
247247 self -> uart .Init .StopBits == UART_STOPBITS_1 ? 1 : 2 );
@@ -255,7 +255,7 @@ STATIC void pyb_uart_print(void (*print)(void *env, const char *fmt, ...), void
255255
256256/// \method init(baudrate, *, bits=8, stop=1, parity=None)
257257///
258- /// Initialise the SPI bus with the given parameters:
258+ /// Initialise the UART bus with the given parameters:
259259///
260260/// - `baudrate` is the clock rate.
261261/// - `bits` is the number of bits per byte, 8 or 9.
@@ -323,6 +323,7 @@ STATIC mp_obj_t pyb_uart_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t
323323 // create object
324324 pyb_uart_obj_t * o = m_new_obj (pyb_uart_obj_t );
325325 o -> base .type = & pyb_uart_type ;
326+ o -> is_enabled = false;
326327
327328 // work out port
328329 o -> uart_id = 0 ;
@@ -494,7 +495,7 @@ mp_uint_t uart_ioctl(mp_obj_t self_in, mp_uint_t request, int *errcode, ...) {
494495 }
495496 } else {
496497 * errcode = EINVAL ;
497- ret = -1 ;
498+ ret = MP_STREAM_ERROR ;
498499 }
499500 va_end (vargs );
500501 return ret ;
0 commit comments