diff options
Diffstat (limited to 'cc3200')
-rw-r--r-- | cc3200/misc/pin_named_pins.c | 4 | ||||
-rw-r--r-- | cc3200/mods/modwlan.c | 10 | ||||
-rw-r--r-- | cc3200/mods/pybadc.c | 4 | ||||
-rw-r--r-- | cc3200/mods/pybi2c.c | 6 | ||||
-rw-r--r-- | cc3200/mods/pybpin.c | 10 | ||||
-rw-r--r-- | cc3200/mods/pybspi.c | 6 | ||||
-rw-r--r-- | cc3200/mods/pybuart.c | 20 | ||||
-rw-r--r-- | cc3200/mpconfigport.h | 3 |
8 files changed, 33 insertions, 30 deletions
diff --git a/cc3200/misc/pin_named_pins.c b/cc3200/misc/pin_named_pins.c index 590e013d44..a3e99757e3 100644 --- a/cc3200/misc/pin_named_pins.c +++ b/cc3200/misc/pin_named_pins.c @@ -37,9 +37,9 @@ #include "pybpin.h" #include MICROPY_HAL_H -STATIC void pin_named_pins_obj_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) { +STATIC void pin_named_pins_obj_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { pin_named_pins_obj_t *self = self_in; - print(env, "<Pin.%s>", qstr_str(self->name)); + mp_printf(print, "<Pin.%s>", qstr_str(self->name)); } const mp_obj_type_t pin_cpu_pins_obj_type = { diff --git a/cc3200/mods/modwlan.c b/cc3200/mods/modwlan.c index 9a7a86775e..cf7519a0dd 100644 --- a/cc3200/mods/modwlan.c +++ b/cc3200/mods/modwlan.c @@ -691,19 +691,19 @@ STATIC mp_obj_t wlan_make_new (mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_k return &wlan_obj; } -STATIC void wlan_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) { +STATIC void wlan_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { wlan_obj_t *self = self_in; - print(env, "<WLAN, mode=%u", self->mode); + mp_printf(print, "<WLAN, mode=%u", self->mode); // only print the bssid if in station mode if (self->mode != ROLE_AP && GET_STATUS_BIT(self->status, STATUS_BIT_CONNECTION)) { - print(env, ", connected to: ssid=%s, bssid=%02x:%02x:%02x:%02x:%02x:%02x", self->ssid, + mp_printf(print, ", connected to: ssid=%s, bssid=%02x:%02x:%02x:%02x:%02x:%02x", self->ssid, self->bssid[0], self->bssid[1], self->bssid[2], self->bssid[3], self->bssid[4], self->bssid[5]); } else { - print(env, ", ssid=%s", self->ssid); + mp_printf(print, ", ssid=%s", self->ssid); } - print(env, ", security=%u>", self->security); + mp_printf(print, ", security=%u>", self->security); } /// \method connect(ssid, security=OPEN, key=None, bssid=None) diff --git a/cc3200/mods/pybadc.c b/cc3200/mods/pybadc.c index c377d51089..ae7de73eb9 100644 --- a/cc3200/mods/pybadc.c +++ b/cc3200/mods/pybadc.c @@ -100,9 +100,9 @@ STATIC pyb_adc_obj_t pyb_adc_obj[PYB_ADC_NUM_CHANNELS]; /******************************************************************************/ /* Micro Python bindings : adc object */ -STATIC void adc_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) { +STATIC void adc_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { pyb_adc_obj_t *self = self_in; - print(env, "<ADC, channel=%u>", self->num); + mp_printf(print, "<ADC, channel=%u>", self->num); } /// \classmethod \constructor(channel) diff --git a/cc3200/mods/pybi2c.c b/cc3200/mods/pybi2c.c index 6fd58b0c07..79a425d217 100644 --- a/cc3200/mods/pybi2c.c +++ b/cc3200/mods/pybi2c.c @@ -294,13 +294,13 @@ STATIC mp_obj_t pyb_i2c_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n return (mp_obj_t)self; } -STATIC void pyb_i2c_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) { +STATIC void pyb_i2c_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { pyb_i2c_obj_t *self = self_in; if (self->baudrate > 0) { - print(env, "<I2C0, I2C.MASTER, baudrate=%u>)", self->baudrate); + mp_printf(print, "<I2C0, I2C.MASTER, baudrate=%u>)", self->baudrate); } else { - print(env, "<I2C0>"); + mp_print_str(print, "<I2C0>"); } } diff --git a/cc3200/mods/pybpin.c b/cc3200/mods/pybpin.c index b8db319419..dbfc34866e 100644 --- a/cc3200/mods/pybpin.c +++ b/cc3200/mods/pybpin.c @@ -429,14 +429,14 @@ STATIC mp_obj_t pin_obj_init_helper(pin_obj_t *self, mp_uint_t n_args, const mp_ /// \method print() /// Return a string describing the pin object. -STATIC void pin_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) { +STATIC void pin_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { pin_obj_t *self = self_in; uint32_t af = MAP_PinModeGet(self->pin_num); uint32_t type = pin_get_type(self); uint32_t strength = pin_get_strenght(self); // pin name - print(env, "<Pin.cpu.%s, af=%u", qstr_str(self->name), af); + mp_printf(print, "<Pin.cpu.%s, af=%u", qstr_str(self->name), af); if (af == PIN_MODE_0) { // IO mode @@ -447,7 +447,7 @@ STATIC void pin_print(void (*print)(void *env, const char *fmt, ...), void *env, } else { mode_qst = MP_QSTR_OUT; } - print(env, ", mode=Pin.%s", qstr_str(mode_qst)); // safe because mode_qst has no formatting chars + mp_printf(print, ", mode=Pin.%s", qstr_str(mode_qst)); } // pin type @@ -465,7 +465,7 @@ STATIC void pin_print(void (*print)(void *env, const char *fmt, ...), void *env, } else { type_qst = MP_QSTR_OD_PD; } - print(env, ", pull=Pin.%s", qstr_str(type_qst)); + mp_printf(print, ", pull=Pin.%s", qstr_str(type_qst)); // Strength qstr str_qst; @@ -476,7 +476,7 @@ STATIC void pin_print(void (*print)(void *env, const char *fmt, ...), void *env, } else { str_qst = MP_QSTR_S6MA; } - print(env, ", strength=Pin.%s>", qstr_str(str_qst)); + mp_printf(print, ", strength=Pin.%s>", qstr_str(str_qst)); } /// \classmethod \constructor(id, ...) diff --git a/cc3200/mods/pybspi.c b/cc3200/mods/pybspi.c index ceddd22804..bcd673225d 100644 --- a/cc3200/mods/pybspi.c +++ b/cc3200/mods/pybspi.c @@ -163,15 +163,15 @@ STATIC void pybspi_transfer (pyb_spi_obj_t *self, const char *txdata, char *rxda /******************************************************************************/ /* Micro Python bindings */ /******************************************************************************/ -STATIC void pyb_spi_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) { +STATIC void pyb_spi_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { pyb_spi_obj_t *self = self_in; if (self->baudrate > 0) { - print(env, "<SPI0, SPI.MASTER, baudrate=%u, config=%u, submode=%u, bits=%u>", + mp_printf(print, "<SPI0, SPI.MASTER, baudrate=%u, config=%u, submode=%u, bits=%u>", self->baudrate, self->config, self->submode, (self->wlen * 8)); } else { - print(env, "<SPI0>"); + mp_print_str(print, "<SPI0>"); } } diff --git a/cc3200/mods/pybuart.c b/cc3200/mods/pybuart.c index 8b998872a5..9465cef080 100644 --- a/cc3200/mods/pybuart.c +++ b/cc3200/mods/pybuart.c @@ -312,37 +312,37 @@ STATIC void uart_callback_disable (mp_obj_t self_in) { /******************************************************************************/ /* Micro Python bindings */ -STATIC void pyb_uart_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) { +STATIC void pyb_uart_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { pyb_uart_obj_t *self = self_in; if (self->baudrate > 0) { - print(env, "<UART%u, baudrate=%u, bits=", self->uart_id, self->baudrate); + mp_printf(print, "<UART%u, baudrate=%u, bits=", self->uart_id, self->baudrate); switch (self->config & UART_CONFIG_WLEN_MASK) { case UART_CONFIG_WLEN_5: - print(env, "5"); + mp_print_str(print, "5"); break; case UART_CONFIG_WLEN_6: - print(env, "6"); + mp_print_str(print, "6"); break; case UART_CONFIG_WLEN_7: - print(env, "7"); + mp_print_str(print, "7"); break; case UART_CONFIG_WLEN_8: - print(env, "8"); + mp_print_str(print, "8"); break; default: break; } if ((self->config & UART_CONFIG_PAR_MASK) == UART_CONFIG_PAR_NONE) { - print(env, ", parity=None"); + mp_print_str(print, ", parity=None"); } else { - print(env, ", parity=%u", (self->config & UART_CONFIG_PAR_MASK) == UART_CONFIG_PAR_EVEN ? 0 : 1); + mp_printf(print, ", parity=%u", (self->config & UART_CONFIG_PAR_MASK) == UART_CONFIG_PAR_EVEN ? 0 : 1); } - print(env, ", stop=%u, timeout=%u, timeout_char=%u, read_buf_len=%u>", + mp_printf(print, ", stop=%u, timeout=%u, timeout_char=%u, read_buf_len=%u>", (self->config & UART_CONFIG_STOP_MASK) == UART_CONFIG_STOP_ONE ? 1 : 2, self->timeout, self->timeout_char, self->read_buf_len); } else { - print(env, "<UART%u>", self->uart_id); + mp_printf(print, "<UART%u>", self->uart_id); } } diff --git a/cc3200/mpconfigport.h b/cc3200/mpconfigport.h index c5caa21209..fa1207d745 100644 --- a/cc3200/mpconfigport.h +++ b/cc3200/mpconfigport.h @@ -146,6 +146,9 @@ typedef void *machine_ptr_t; // must be of pointer size typedef const void *machine_const_ptr_t; // must be of pointer size typedef long mp_off_t; +void mp_hal_stdout_tx_strn_cooked(const char *str, uint32_t len); +#define MP_PLAT_PRINT_STRN(str, len) mp_hal_stdout_tx_strn_cooked(str, len) + #define MICROPY_BEGIN_ATOMIC_SECTION() disable_irq() #define MICROPY_END_ATOMIC_SECTION(state) enable_irq(state) |