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/stm32-h103/miniblink/miniblink.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'examples/stm32/stm32-h103/miniblink') diff --git a/examples/stm32/stm32-h103/miniblink/miniblink.c b/examples/stm32/stm32-h103/miniblink/miniblink.c index 4bc781b..6f8bc2c 100644 --- a/examples/stm32/stm32-h103/miniblink/miniblink.c +++ b/examples/stm32/stm32-h103/miniblink/miniblink.c @@ -24,7 +24,7 @@ void gpio_setup(void) { /* Enable GPIOC clock. */ /* Manually: */ - // RCC_APB2ENR |= IOPCEN; + // RCC_APB2ENR |= RCC_APB2ENR_IOPCEN; /* Using API functions: */ rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPCEN); @@ -47,19 +47,24 @@ int main(void) while (1) { /* Manually: */ // GPIOC_BSRR = GPIO12; /* LED off */ - // for (i = 0; i < 80000; i++); /* Wait (needs -O0 CFLAGS). */ + // for (i = 0; i < 800000; i++) /* Wait a bit. */ + // __asm__("nop"); // GPIOC_BRR = GPIO12; /* LED on */ - // for (i = 0; i < 80000; i++); /* Wait (needs -O0 CFLAGS). */ + // for (i = 0; i < 800000; i++) /* Wait a bit. */ + // __asm__("nop"); /* Using API functions gpio_set()/gpio_clear(): */ // gpio_set(GPIOC, GPIO12); /* LED off */ - // for (i = 0; i < 80000; i++); /* Wait (needs -O0 CFLAGS). */ + // for (i = 0; i < 800000; i++) /* Wait a bit. */ + // __asm__("nop"); // gpio_clear(GPIOC, GPIO12); /* LED on */ - // for (i = 0; i < 80000; i++); /* Wait (needs -O0 CFLAGS). */ + // for (i = 0; i < 800000; i++) /* Wait a bit. */ + // __asm__("nop"); /* Using API function gpio_toggle(): */ gpio_toggle(GPIOC, GPIO12); /* LED on/off */ - for (i = 0; i < 80000; i++); /* Wait (needs -O0 CFLAGS). */ + for (i = 0; i < 800000; i++) /* Wait a bit. */ + __asm__("nop"); } return 0; -- cgit v1.2.3