File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -134,3 +134,9 @@ Methods
134134
135135 Write a single character on the bus. ``char `` is an integer to write.
136136 Return value: ``None ``.
137+
138+ .. method :: uart.sendbreak()
139+
140+ Send a break condition on the bus. This drives the bus low for a duration
141+ of 13 bits.
142+ Return value: ``None ``.
Original file line number Diff line number Diff line change @@ -186,6 +186,7 @@ Q(any)
186186Q (writechar )
187187Q (readchar )
188188Q (readinto )
189+ Q (sendbreak )
189190Q (RTS )
190191Q (CTS )
191192
Original file line number Diff line number Diff line change @@ -614,6 +614,14 @@ STATIC mp_obj_t pyb_uart_readchar(mp_obj_t self_in) {
614614}
615615STATIC MP_DEFINE_CONST_FUN_OBJ_1 (pyb_uart_readchar_obj , pyb_uart_readchar );
616616
617+ // uart.sendbreak()
618+ STATIC mp_obj_t pyb_uart_sendbreak (mp_obj_t self_in ) {
619+ pyb_uart_obj_t * self = self_in ;
620+ self -> uart .Instance -> CR1 |= USART_CR1_SBK ;
621+ return mp_const_none ;
622+ }
623+ STATIC MP_DEFINE_CONST_FUN_OBJ_1 (pyb_uart_sendbreak_obj , pyb_uart_sendbreak );
624+
617625STATIC const mp_map_elem_t pyb_uart_locals_dict_table [] = {
618626 // instance methods
619627
@@ -634,6 +642,7 @@ STATIC const mp_map_elem_t pyb_uart_locals_dict_table[] = {
634642
635643 { MP_OBJ_NEW_QSTR (MP_QSTR_writechar ), (mp_obj_t )& pyb_uart_writechar_obj },
636644 { MP_OBJ_NEW_QSTR (MP_QSTR_readchar ), (mp_obj_t )& pyb_uart_readchar_obj },
645+ { MP_OBJ_NEW_QSTR (MP_QSTR_sendbreak ), (mp_obj_t )& pyb_uart_sendbreak_obj },
637646
638647 // class constants
639648 { MP_OBJ_NEW_QSTR (MP_QSTR_RTS ), MP_OBJ_NEW_SMALL_INT (UART_HWCONTROL_RTS ) },
Original file line number Diff line number Diff line change 1212print (uart .write ('123' ))
1313print (uart .write (b'abcd' ))
1414print (uart .writechar (1 ))
15+
16+ # make sure this method exists
17+ uart .sendbreak ()
You can’t perform that action at this time.
0 commit comments