26
26
27
27
#include "shared-bindings/busio/I2C.h"
28
28
#include "shared-bindings/busio/SPI.h"
29
- // #include "shared-bindings/busio/UART.h"
29
+ #include "shared-bindings/busio/UART.h"
30
30
31
31
#include "shared-bindings/microcontroller/Pin.h"
32
32
#include "mpconfigboard.h"
@@ -87,27 +87,26 @@ MP_DEFINE_CONST_FUN_OBJ_0(board_i2c_obj, board_i2c);
87
87
#endif
88
88
MP_DEFINE_CONST_FUN_OBJ_0 (board_spi_obj , board_spi );
89
89
90
- #if !defined(DEFAULT_SERIAL_BUS_RX ) || !defined(DEFAULT_SERIAL_BUS_TX )
91
- STATIC mp_obj_t board_serial (void ) {
92
- mp_raise_NotImplementedError ("No default serial bus" );
90
+ #if !defined(DEFAULT_UART_BUS_RX ) || !defined(DEFAULT_UART_BUS_TX )
91
+ STATIC mp_obj_t board_uart (void ) {
92
+ mp_raise_NotImplementedError ("No default UART bus" );
93
93
return NULL ;
94
94
}
95
95
#else
96
- STATIC mp_obj_t serial_singleton = NULL ;
96
+ STATIC mp_obj_t uart_singleton = NULL ;
97
97
98
- STATIC mp_obj_t board_serial (void ) {
99
- if (serial_singleton == NULL ) {
100
- // busio_uart_obj_t *self = m_new_obj(busio_uart_obj_t);
101
- // self->base.type = &busio_uart_type;
98
+ STATIC mp_obj_t board_uart (void ) {
99
+ if (uart_singleton == NULL ) {
100
+ busio_uart_obj_t * self = m_new_obj (busio_uart_obj_t );
101
+ self -> base .type = & busio_uart_type ;
102
102
103
- assert_pin_free (DEFAULT_SERIAL_BUS_RX );
104
- assert_pin_free (DEFAULT_SERIAL_BUS_TX );
103
+ assert_pin_free (DEFAULT_UART_BUS_RX );
104
+ assert_pin_free (DEFAULT_UART_BUS_TX );
105
105
106
- //common_hal_busio_uart_construct(self, DEFAULT_SERIAL_BUS_TX, DEFAULT_SERIAL_BUS_RX, 9600, 8, PARITY_NONE, 1, 1000, 64);
107
- //serial_singleton = (mp_obj_t)self;
108
- serial_singleton = NULL ;
106
+ common_hal_busio_uart_construct (self , DEFAULT_UART_BUS_TX , DEFAULT_UART_BUS_RX , 9600 , 8 , PARITY_NONE , 1 , 1000 , 64 );
107
+ uart_singleton = (mp_obj_t )self ;
109
108
}
110
- return serial_singleton ;
109
+ return uart_singleton ;
111
110
}
112
111
#endif
113
- MP_DEFINE_CONST_FUN_OBJ_0 (board_serial_obj , board_serial );
112
+ MP_DEFINE_CONST_FUN_OBJ_0 (board_uart_obj , board_uart );
0 commit comments