Commit cb3456dd authored by Damien George's avatar Damien George

stm32: Don't use %lu or %lx for formatting, use just %u or %x.

On this 32-bit arch there's no need to use the long version of the format
specifier.  It's only there to appease the compiler which checks the type
of the args passed to printf.  Removing the "l" saves a bit of code space.
parent b614dc73
...@@ -310,7 +310,7 @@ STATIC void adc_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t ...@@ -310,7 +310,7 @@ STATIC void adc_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t
pyb_obj_adc_t *self = self_in; pyb_obj_adc_t *self = self_in;
mp_print_str(print, "<ADC on "); mp_print_str(print, "<ADC on ");
mp_obj_print_helper(print, self->pin_name, PRINT_STR); mp_obj_print_helper(print, self->pin_name, PRINT_STR);
mp_printf(print, " channel=%lu>", self->channel); mp_printf(print, " channel=%u>", self->channel);
} }
/// \classmethod \constructor(pin) /// \classmethod \constructor(pin)
......
...@@ -387,44 +387,44 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(extint_obj_swint_obj, extint_obj_swint); ...@@ -387,44 +387,44 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(extint_obj_swint_obj, extint_obj_swint);
/// Dump the values of the EXTI registers. /// Dump the values of the EXTI registers.
STATIC mp_obj_t extint_regs(void) { STATIC mp_obj_t extint_regs(void) {
#if defined(STM32L4) #if defined(STM32L4)
printf("EXTI_IMR1 %08lx\n", EXTI->IMR1); printf("EXTI_IMR1 %08x\n", (unsigned int)EXTI->IMR1);
printf("EXTI_IMR2 %08lx\n", EXTI->IMR2); printf("EXTI_IMR2 %08x\n", (unsigned int)EXTI->IMR2);
printf("EXTI_EMR1 %08lx\n", EXTI->EMR1); printf("EXTI_EMR1 %08x\n", (unsigned int)EXTI->EMR1);
printf("EXTI_EMR2 %08lx\n", EXTI->EMR2); printf("EXTI_EMR2 %08x\n", (unsigned int)EXTI->EMR2);
printf("EXTI_RTSR1 %08lx\n", EXTI->RTSR1); printf("EXTI_RTSR1 %08x\n", (unsigned int)EXTI->RTSR1);
printf("EXTI_RTSR2 %08lx\n", EXTI->RTSR2); printf("EXTI_RTSR2 %08x\n", (unsigned int)EXTI->RTSR2);
printf("EXTI_FTSR1 %08lx\n", EXTI->FTSR1); printf("EXTI_FTSR1 %08x\n", (unsigned int)EXTI->FTSR1);
printf("EXTI_FTSR2 %08lx\n", EXTI->FTSR2); printf("EXTI_FTSR2 %08x\n", (unsigned int)EXTI->FTSR2);
printf("EXTI_SWIER1 %08lx\n", EXTI->SWIER1); printf("EXTI_SWIER1 %08x\n", (unsigned int)EXTI->SWIER1);
printf("EXTI_SWIER2 %08lx\n", EXTI->SWIER2); printf("EXTI_SWIER2 %08x\n", (unsigned int)EXTI->SWIER2);
printf("EXTI_PR1 %08lx\n", EXTI->PR1); printf("EXTI_PR1 %08x\n", (unsigned int)EXTI->PR1);
printf("EXTI_PR2 %08lx\n", EXTI->PR2); printf("EXTI_PR2 %08x\n", (unsigned int)EXTI->PR2);
#elif defined(STM32H7) #elif defined(STM32H7)
printf("EXTI_IMR1 %08lx\n", EXTI_D1->IMR1); printf("EXTI_IMR1 %08x\n", (unsigned int)EXTI_D1->IMR1);
printf("EXTI_IMR2 %08lx\n", EXTI_D1->IMR2); printf("EXTI_IMR2 %08x\n", (unsigned int)EXTI_D1->IMR2);
printf("EXTI_IMR3 %08lx\n", EXTI_D1->IMR3); printf("EXTI_IMR3 %08x\n", (unsigned int)EXTI_D1->IMR3);
printf("EXTI_EMR1 %08lx\n", EXTI_D1->EMR1); printf("EXTI_EMR1 %08x\n", (unsigned int)EXTI_D1->EMR1);
printf("EXTI_EMR2 %08lx\n", EXTI_D1->EMR2); printf("EXTI_EMR2 %08x\n", (unsigned int)EXTI_D1->EMR2);
printf("EXTI_EMR3 %08lx\n", EXTI_D1->EMR3); printf("EXTI_EMR3 %08x\n", (unsigned int)EXTI_D1->EMR3);
printf("EXTI_RTSR1 %08lx\n", EXTI->RTSR1); printf("EXTI_RTSR1 %08x\n", (unsigned int)EXTI->RTSR1);
printf("EXTI_RTSR2 %08lx\n", EXTI->RTSR2); printf("EXTI_RTSR2 %08x\n", (unsigned int)EXTI->RTSR2);
printf("EXTI_RTSR3 %08lx\n", EXTI->RTSR3); printf("EXTI_RTSR3 %08x\n", (unsigned int)EXTI->RTSR3);
printf("EXTI_FTSR1 %08lx\n", EXTI->FTSR1); printf("EXTI_FTSR1 %08x\n", (unsigned int)EXTI->FTSR1);
printf("EXTI_FTSR2 %08lx\n", EXTI->FTSR2); printf("EXTI_FTSR2 %08x\n", (unsigned int)EXTI->FTSR2);
printf("EXTI_FTSR3 %08lx\n", EXTI->FTSR3); printf("EXTI_FTSR3 %08x\n", (unsigned int)EXTI->FTSR3);
printf("EXTI_SWIER1 %08lx\n", EXTI->SWIER1); printf("EXTI_SWIER1 %08x\n", (unsigned int)EXTI->SWIER1);
printf("EXTI_SWIER2 %08lx\n", EXTI->SWIER2); printf("EXTI_SWIER2 %08x\n", (unsigned int)EXTI->SWIER2);
printf("EXTI_SWIER3 %08lx\n", EXTI->SWIER3); printf("EXTI_SWIER3 %08x\n", (unsigned int)EXTI->SWIER3);
printf("EXTI_PR1 %08lx\n", EXTI_D1->PR1); printf("EXTI_PR1 %08x\n", (unsigned int)EXTI_D1->PR1);
printf("EXTI_PR2 %08lx\n", EXTI_D1->PR2); printf("EXTI_PR2 %08x\n", (unsigned int)EXTI_D1->PR2);
printf("EXTI_PR3 %08lx\n", EXTI_D1->PR3); printf("EXTI_PR3 %08x\n", (unsigned int)EXTI_D1->PR3);
#else #else
printf("EXTI_IMR %08lx\n", EXTI->IMR); printf("EXTI_IMR %08x\n", (unsigned int)EXTI->IMR);
printf("EXTI_EMR %08lx\n", EXTI->EMR); printf("EXTI_EMR %08x\n", (unsigned int)EXTI->EMR);
printf("EXTI_RTSR %08lx\n", EXTI->RTSR); printf("EXTI_RTSR %08x\n", (unsigned int)EXTI->RTSR);
printf("EXTI_FTSR %08lx\n", EXTI->FTSR); printf("EXTI_FTSR %08x\n", (unsigned int)EXTI->FTSR);
printf("EXTI_SWIER %08lx\n", EXTI->SWIER); printf("EXTI_SWIER %08x\n", (unsigned int)EXTI->SWIER);
printf("EXTI_PR %08lx\n", EXTI->PR); printf("EXTI_PR %08x\n", (unsigned int)EXTI->PR);
#endif #endif
return mp_const_none; return mp_const_none;
} }
...@@ -534,7 +534,7 @@ void Handle_EXTI_Irq(uint32_t line) { ...@@ -534,7 +534,7 @@ void Handle_EXTI_Irq(uint32_t line) {
// Uncaught exception; disable the callback so it doesn't run again. // Uncaught exception; disable the callback so it doesn't run again.
*cb = mp_const_none; *cb = mp_const_none;
extint_disable(line); extint_disable(line);
printf("Uncaught exception in ExtInt interrupt handler line %lu\n", line); printf("Uncaught exception in ExtInt interrupt handler line %u\n", (unsigned int)line);
mp_obj_print_exception(&mp_plat_print, (mp_obj_t)nlr.ret_val); mp_obj_print_exception(&mp_plat_print, (mp_obj_t)nlr.ret_val);
} }
gc_unlock(); gc_unlock();
......
...@@ -281,7 +281,7 @@ void led_debug(int n, int delay) { ...@@ -281,7 +281,7 @@ void led_debug(int n, int delay) {
void led_obj_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { void led_obj_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
pyb_led_obj_t *self = self_in; pyb_led_obj_t *self = self_in;
mp_printf(print, "LED(%lu)", self->led_id); mp_printf(print, "LED(%u)", self->led_id);
} }
/// \classmethod \constructor(id) /// \classmethod \constructor(id)
......
...@@ -140,11 +140,11 @@ STATIC mp_obj_t machine_info(size_t n_args, const mp_obj_t *args) { ...@@ -140,11 +140,11 @@ STATIC mp_obj_t machine_info(size_t n_args, const mp_obj_t *args) {
// get and print clock speeds // get and print clock speeds
// SYSCLK=168MHz, HCLK=168MHz, PCLK1=42MHz, PCLK2=84MHz // SYSCLK=168MHz, HCLK=168MHz, PCLK1=42MHz, PCLK2=84MHz
{ {
printf("S=%lu\nH=%lu\nP1=%lu\nP2=%lu\n", printf("S=%u\nH=%u\nP1=%u\nP2=%u\n",
HAL_RCC_GetSysClockFreq(), (unsigned int)HAL_RCC_GetSysClockFreq(),
HAL_RCC_GetHCLKFreq(), (unsigned int)HAL_RCC_GetHCLKFreq(),
HAL_RCC_GetPCLK1Freq(), (unsigned int)HAL_RCC_GetPCLK1Freq(),
HAL_RCC_GetPCLK2Freq()); (unsigned int)HAL_RCC_GetPCLK2Freq());
} }
// to print info about memory // to print info about memory
......
...@@ -198,7 +198,7 @@ STATIC void i2c_set_baudrate(I2C_InitTypeDef *init, uint32_t baudrate) { ...@@ -198,7 +198,7 @@ STATIC void i2c_set_baudrate(I2C_InitTypeDef *init, uint32_t baudrate) {
} }
} }
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError,
"Unsupported I2C baudrate: %lu", baudrate)); "Unsupported I2C baudrate: %u", baudrate));
} }
uint32_t pyb_i2c_get_baudrate(I2C_HandleTypeDef *i2c) { uint32_t pyb_i2c_get_baudrate(I2C_HandleTypeDef *i2c) {
......
...@@ -176,7 +176,7 @@ MP_DEFINE_CONST_FUN_OBJ_2(pyb_pwm_set_obj, pyb_pwm_set); ...@@ -176,7 +176,7 @@ MP_DEFINE_CONST_FUN_OBJ_2(pyb_pwm_set_obj, pyb_pwm_set);
STATIC void pyb_servo_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { STATIC void pyb_servo_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
pyb_servo_obj_t *self = self_in; pyb_servo_obj_t *self = self_in;
mp_printf(print, "<Servo %lu at %luus>", self - &pyb_servo_obj[0] + 1, 10 * self->pulse_cur); mp_printf(print, "<Servo %u at %uus>", self - &pyb_servo_obj[0] + 1, 10 * self->pulse_cur);
} }
/// \classmethod \constructor(id) /// \classmethod \constructor(id)
......
...@@ -1459,7 +1459,7 @@ void timer_irq_handler(uint tim_id) { ...@@ -1459,7 +1459,7 @@ void timer_irq_handler(uint tim_id) {
if (unhandled != 0) { if (unhandled != 0) {
__HAL_TIM_DISABLE_IT(&tim->tim, unhandled); __HAL_TIM_DISABLE_IT(&tim->tim, unhandled);
__HAL_TIM_CLEAR_IT(&tim->tim, unhandled); __HAL_TIM_CLEAR_IT(&tim->tim, unhandled);
printf("Unhandled interrupt SR=0x%02lx (now disabled)\n", unhandled); printf("Unhandled interrupt SR=0x%02x (now disabled)\n", (unsigned int)unhandled);
} }
} }
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment