From d03c6816083c8ce8a35d278ede48c4089012b055 Mon Sep 17 00:00:00 2001 From: Damien George Date: Sun, 5 Oct 2014 21:51:54 +0100 Subject: [PATCH] stmhal: Use mp_uint_t where appropriate. Found these by compiling stmhal with mp_uint_t of type uint32_t instead of unsigned int. This actually makes a difference to the code, but just a curiosity. --- stmhal/lcd.c | 4 ++-- stmhal/modpyb.c | 2 +- stmhal/modtime.c | 2 +- stmhal/printf.c | 4 ++-- stmhal/pyexec.c | 4 ++-- stmhal/timer.c | 6 ++---- 6 files changed, 10 insertions(+), 12 deletions(-) diff --git a/stmhal/lcd.c b/stmhal/lcd.c index a47fffcd94..dbe2be9ecc 100644 --- a/stmhal/lcd.c +++ b/stmhal/lcd.c @@ -389,7 +389,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(pyb_lcd_light_obj, pyb_lcd_light); /// Write the string `str` to the screen. It will appear immediately. STATIC mp_obj_t pyb_lcd_write(mp_obj_t self_in, mp_obj_t str) { pyb_lcd_obj_t *self = self_in; - uint len; + mp_uint_t len; const char *data = mp_obj_str_get_data(str, &len); lcd_write_strn(self, data, len); return mp_const_none; @@ -461,7 +461,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pyb_lcd_pixel_obj, 4, 4, pyb_lcd_pixe STATIC mp_obj_t pyb_lcd_text(mp_uint_t n_args, const mp_obj_t *args) { // extract arguments pyb_lcd_obj_t *self = args[0]; - uint len; + mp_uint_t len; const char *data = mp_obj_str_get_data(args[1], &len); int x0 = mp_obj_get_int(args[2]); int y0 = mp_obj_get_int(args[3]); diff --git a/stmhal/modpyb.c b/stmhal/modpyb.c index 8252b057a0..522f95017c 100644 --- a/stmhal/modpyb.c +++ b/stmhal/modpyb.c @@ -126,7 +126,7 @@ STATIC mp_obj_t pyb_info(mp_uint_t n_args, const mp_obj_t *args) { { mp_uint_t n_pool, n_qstr, n_str_data_bytes, n_total_bytes; qstr_pool_info(&n_pool, &n_qstr, &n_str_data_bytes, &n_total_bytes); - printf("qstr:\n n_pool=%u\n n_qstr=%u\n n_str_data_bytes=%u\n n_total_bytes=%u\n", n_pool, n_qstr, n_str_data_bytes, n_total_bytes); + printf("qstr:\n n_pool=" UINT_FMT "\n n_qstr=" UINT_FMT "\n n_str_data_bytes=" UINT_FMT "\n n_total_bytes=" UINT_FMT "\n", n_pool, n_qstr, n_str_data_bytes, n_total_bytes); } // GC info diff --git a/stmhal/modtime.c b/stmhal/modtime.c index 1bf8c30c4f..89df6ae994 100644 --- a/stmhal/modtime.c +++ b/stmhal/modtime.c @@ -233,7 +233,7 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(time_localtime_obj, 0, 1, time_localtime); /// the number of seconds since Jan 1, 2000. STATIC mp_obj_t time_mktime(mp_obj_t tuple) { - uint len; + mp_uint_t len; mp_obj_t *elem; mp_obj_get_array(tuple, &len, &elem); diff --git a/stmhal/printf.c b/stmhal/printf.c index db611f3d97..86b756f7d4 100644 --- a/stmhal/printf.c +++ b/stmhal/printf.c @@ -48,7 +48,7 @@ int pfenv_vprintf(const pfenv_t *pfenv, const char *fmt, va_list args); -STATIC void stdout_print_strn(void *dummy_env, const char *str, unsigned int len) { +STATIC void stdout_print_strn(void *dummy_env, const char *str, mp_uint_t len) { stdout_tx_strn_cooked(str, len); } @@ -97,7 +97,7 @@ typedef struct _strn_pfenv_t { size_t remain; } strn_pfenv_t; -void strn_print_strn(void *data, const char *str, unsigned int len) { +STATIC void strn_print_strn(void *data, const char *str, mp_uint_t len) { strn_pfenv_t *strn_pfenv = data; if (len > strn_pfenv->remain) { len = strn_pfenv->remain; diff --git a/stmhal/pyexec.c b/stmhal/pyexec.c index 0ce4882e20..f458bd0ff3 100644 --- a/stmhal/pyexec.c +++ b/stmhal/pyexec.c @@ -101,9 +101,9 @@ bool parse_compile_execute(mp_lexer_t *lex, mp_parse_input_kind_t input_kind, bo gc_collect(); // qstr info { - uint n_pool, n_qstr, n_str_data_bytes, n_total_bytes; + mp_uint_t n_pool, n_qstr, n_str_data_bytes, n_total_bytes; qstr_pool_info(&n_pool, &n_qstr, &n_str_data_bytes, &n_total_bytes); - printf("qstr:\n n_pool=%u\n n_qstr=%u\n n_str_data_bytes=%u\n n_total_bytes=%u\n", n_pool, n_qstr, n_str_data_bytes, n_total_bytes); + printf("qstr:\n n_pool=" UINT_FMT "\n n_qstr=" UINT_FMT "\n n_str_data_bytes=" UINT_FMT "\n n_total_bytes=" UINT_FMT "\n", n_pool, n_qstr, n_str_data_bytes, n_total_bytes); } // GC info diff --git a/stmhal/timer.c b/stmhal/timer.c index f33fe5afb3..787a6dd981 100644 --- a/stmhal/timer.c +++ b/stmhal/timer.c @@ -1157,11 +1157,9 @@ STATIC void timer_handle_irq_channel(pyb_timer_obj_t *tim, uint8_t channel, mp_o tim->callback = mp_const_none; __HAL_TIM_DISABLE_IT(&tim->tim, irq_mask); if (channel == 0) { - printf("Uncaught exception in Timer(" UINT_FMT - ") interrupt handler\n", tim->tim_id); + printf("uncaught exception in Timer(%u) interrupt handler\n", tim->tim_id); } else { - printf("Uncaught exception in Timer(" UINT_FMT ") channel " - UINT_FMT " interrupt handler\n", tim->tim_id, channel); + printf("uncaught exception in Timer(%u) channel %u interrupt handler\n", tim->tim_id, channel); } mp_obj_print_exception((mp_obj_t)nlr.ret_val); }