From 3319780e960f5a7cba6d10b58fe53f7117402123 Mon Sep 17 00:00:00 2001 From: Daniel Campora Date: Tue, 9 Jun 2015 17:14:31 +0200 Subject: [PATCH] cc3200: Add sendbreak method to the UART. --- cc3200/mods/pybuart.c | 14 ++++++++++++++ cc3200/qstrdefsport.h | 1 + 2 files changed, 15 insertions(+) diff --git a/cc3200/mods/pybuart.c b/cc3200/mods/pybuart.c index a47a01165a..41a0a2ec34 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 3d7169b0c2..6fa176d1ac 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)