From ca53311bfc3182212d53386c5f49f0bc57350266 Mon Sep 17 00:00:00 2001 From: Uwe Hermann Date: Mon, 3 Jan 2011 01:12:07 +0100 Subject: Use __asm__("nop") in the loop-based delays. Since we recently switched from -O0 to -Os, an increase in the loop count as well as the addition of __asm__("nop") is required (so that the loop doesn't get optimized/removed). The real fix is to add a proper timer-based delay function, of course. Also, fix a bunch of cosmetic issues and typos. --- examples/stm32/mb525/fancyblink/fancyblink.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'examples/stm32/mb525') diff --git a/examples/stm32/mb525/fancyblink/fancyblink.c b/examples/stm32/mb525/fancyblink/fancyblink.c index 65e1728..e9a3564 100644 --- a/examples/stm32/mb525/fancyblink/fancyblink.c +++ b/examples/stm32/mb525/fancyblink/fancyblink.c @@ -27,7 +27,6 @@ void clock_setup(void) /* Enable GPIOC clock. */ rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPCEN); - } void gpio_setup(void) @@ -49,22 +48,28 @@ int main(void) while (1) { gpio_toggle(GPIOC, GPIO6); /* LED on/off */ gpio_toggle(GPIOC, GPIO7); /* LED on/off */ - for (i = 0; i < 400000; i++); /* Wait (needs -O0 CFLAGS). */ + for (i = 0; i < 4000000; i++) /* Wait a bit. */ + __asm__("nop"); gpio_toggle(GPIOC, GPIO7); /* LED on/off */ gpio_toggle(GPIOC, GPIO8); /* LED on/off */ - for (i = 0; i < 400000; i++); /* Wait (needs -O0 CFLAGS). */ + for (i = 0; i < 4000000; i++) /* Wait a bit. */ + __asm__("nop"); gpio_toggle(GPIOC, GPIO8); /* LED on/off */ gpio_toggle(GPIOC, GPIO9); /* LED on/off */ - for (i = 0; i < 400000; i++); /* Wait (needs -O0 CFLAGS). */ + for (i = 0; i < 4000000; i++) /* Wait a bit. */ + __asm__("nop"); gpio_toggle(GPIOC, GPIO8); /* LED on/off */ gpio_toggle(GPIOC, GPIO9); /* LED on/off */ - for (i = 0; i < 400000; i++); /* Wait (needs -O0 CFLAGS). */ + for (i = 0; i < 4000000; i++) /* Wait a bit. */ + __asm__("nop"); gpio_toggle(GPIOC, GPIO7); /* LED on/off */ gpio_toggle(GPIOC, GPIO8); /* LED on/off */ - for (i = 0; i < 400000; i++); /* Wait (needs -O0 CFLAGS). */ + for (i = 0; i < 4000000; i++) /* Wait a bit. */ + __asm__("nop"); gpio_toggle(GPIOC, GPIO6); /* LED on/off */ gpio_toggle(GPIOC, GPIO7); /* LED on/off */ - for (i = 0; i < 400000; i++); /* Wait (needs -O0 CFLAGS). */ + for (i = 0; i < 4000000; i++) /* Wait a bit. */ + __asm__("nop"); } return 0; -- cgit v1.2.3