diff options
| author | Damien George | 2014-01-22 14:35:10 +0000 |
|---|---|---|
| committer | Damien George | 2014-01-22 14:35:10 +0000 |
| commit | 5fa93b67557f21c22a41449c3266571c427f6798 (patch) | |
| tree | 3e009ed9369b7aba8cf5212509a784ecd86e06a3 /stm/usart.c | |
| parent | 8ae1c1beacc56d440b2cc1e4bd010b100ad4fdd0 (diff) | |
Second stage of qstr revamp: uPy str object can be qstr or not.
Diffstat (limited to 'stm/usart.c')
| -rw-r--r-- | stm/usart.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/stm/usart.c b/stm/usart.c index c687cff05..17ff146d5 100644 --- a/stm/usart.c +++ b/stm/usart.c @@ -151,6 +151,12 @@ void usart_tx_str(pyb_usart_t usart_id, const char *str) { } } +void usart_tx_bytes(pyb_usart_t usart_id, const byte *data, uint len) { + for (; len > 0; data++, len--) { + usart_tx_char(usart_id, *data); + } +} + 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') { @@ -201,8 +207,9 @@ static mp_obj_t usart_obj_tx_str(mp_obj_t self_in, mp_obj_t s) { pyb_usart_obj_t *self = self_in; if (self->is_enabled) { if (MP_OBJ_IS_TYPE(s, &str_type)) { - const char *str = qstr_str(mp_obj_get_qstr(s)); - usart_tx_str(self->usart_id, str); + uint len; + const byte *data = mp_obj_str_get_data(s, &len); + usart_tx_bytes(self->usart_id, data, len); } } return mp_const_none; |
