void usart_tx_strn_cooked(pyb_usart_t usart_id, const char *str, int len) { for (const char *top = str + len; str < top; str++) { if (*str == '\n') { usart_tx_char(usart_id, '\r'); } usart_tx_char(usart_id, *str); } }
static mp_obj_t usart_obj_tx_char(mp_obj_t self_in, mp_obj_t c) { pyb_usart_obj_t *self = self_in; if (self->is_enabled) { usart_tx_char(self->usart_id, mp_obj_get_int(c)); } return mp_const_none; }
static mp_obj_t usart_obj_tx_char(mp_obj_t self_in, mp_obj_t c) { pyb_usart_obj_t *self = self_in; uint len; const char *str = mp_obj_str_get_data(c, &len); if (len == 1 && self->is_enabled) { usart_tx_char(self->usart_id, str[0]); } return mp_const_none; }
void usart_tx_bytes(pyb_usart_t usart_id, const char *data, uint len) { for (; len > 0; data++, len--) { usart_tx_char(usart_id, *data); } }
void usart_tx_str(pyb_usart_t usart_id, const char *str) { for (; *str; str++) { usart_tx_char(usart_id, *str); } }
void usart_tx_strn(pyb_usart_obj_t *usart_obj, const char *str, uint len) { for (; len > 0; str++, len--) { usart_tx_char(usart_obj, *str); } }
void usart_tx_str(pyb_usart_obj_t *usart_obj, const char *str) { for (; *str; str++) { usart_tx_char(usart_obj, *str); } }