diff options
| author | Daniel Campora | 2015-06-09 17:14:31 +0200 |
|---|---|---|
| committer | Daniel Campora | 2015-06-10 23:35:35 +0200 |
| commit | 3319780e960f5a7cba6d10b58fe53f7117402123 (patch) | |
| tree | cfa4b9e002503f9d4f105be44ae63a1c2da97980 | |
| parent | 8a6d93aeed7b1ef673cacb017a9f698e45e3c7e8 (diff) | |
cc3200: Add sendbreak method to the UART.
| -rw-r--r-- | cc3200/mods/pybuart.c | 14 | ||||
| -rw-r--r-- | cc3200/qstrdefsport.h | 1 |
2 files changed, 15 insertions, 0 deletions
diff --git a/cc3200/mods/pybuart.c b/cc3200/mods/pybuart.c index a47a01165..41a0a2ec3 100644 --- a/cc3200/mods/pybuart.c +++ b/cc3200/mods/pybuart.c @@ -51,6 +51,7 @@ #include "mpexception.h" #include "py/mpstate.h" #include "osi.h" +#include "utils.h" /// \moduleref pyb /// \class UART - duplex serial communication bus @@ -568,6 +569,18 @@ STATIC mp_obj_t pyb_uart_readchar(mp_obj_t self_in) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(pyb_uart_readchar_obj, pyb_uart_readchar); +/// \method sendbreak() +STATIC mp_obj_t pyb_uart_sendbreak(mp_obj_t self_in) { + pyb_uart_obj_t *self = self_in; + // send a break signal for at least 2 complete frames + MAP_UARTBreakCtl(self->reg, true); + UtilsDelay(UTILS_DELAY_US_TO_COUNT((22 * 1000000) / self->baudrate)); + MAP_UARTBreakCtl(self->reg, false); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(pyb_uart_sendbreak_obj, pyb_uart_sendbreak); + + STATIC const mp_map_elem_t pyb_uart_locals_dict_table[] = { // instance methods { MP_OBJ_NEW_QSTR(MP_QSTR_init), (mp_obj_t)&pyb_uart_init_obj }, @@ -588,6 +601,7 @@ STATIC const mp_map_elem_t pyb_uart_locals_dict_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_writechar), (mp_obj_t)&pyb_uart_writechar_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_readchar), (mp_obj_t)&pyb_uart_readchar_obj }, + { MP_OBJ_NEW_QSTR(MP_QSTR_sendbreak), (mp_obj_t)&pyb_uart_sendbreak_obj }, // class constants { MP_OBJ_NEW_QSTR(MP_QSTR_CTS), MP_OBJ_NEW_SMALL_INT(UART_FLOWCONTROL_TX) }, diff --git a/cc3200/qstrdefsport.h b/cc3200/qstrdefsport.h index 3d7169b0c..6fa176d1a 100644 --- a/cc3200/qstrdefsport.h +++ b/cc3200/qstrdefsport.h @@ -148,6 +148,7 @@ Q(deinit) Q(all) Q(writechar) Q(readchar) +Q(sendbreak) Q(readinto) Q(read_buf_len) Q(timeout) |
