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.
This commit is contained in:
@@ -54,13 +54,17 @@ int main(void)
|
||||
/* Blink the LEDs on the board. */
|
||||
while (1) {
|
||||
gpio_toggle(GPIOA, GPIO6); /* LED on/off */
|
||||
for (i = 0; i < 800000; i++); /* Wait (needs -O0 CFLAGS). */
|
||||
for (i = 0; i < 8000000; i++) /* Wait a bit. */
|
||||
__asm__("nop");
|
||||
gpio_toggle(GPIOA, GPIO7); /* LED on/off */
|
||||
for (i = 0; i < 800000; i++); /* Wait (needs -O0 CFLAGS). */
|
||||
for (i = 0; i < 8000000; i++) /* Wait a bit. */
|
||||
__asm__("nop");
|
||||
gpio_toggle(GPIOB, GPIO0); /* LED on/off */
|
||||
for (i = 0; i < 800000; i++); /* Wait (needs -O0 CFLAGS). */
|
||||
for (i = 0; i < 8000000; i++) /* Wait a bit. */
|
||||
__asm__("nop");
|
||||
gpio_toggle(GPIOB, GPIO1); /* LED on/off */
|
||||
for (i = 0; i < 800000; i++); /* Wait (needs -O0 CFLAGS). */
|
||||
for (i = 0; i < 8000000; i++) /* Wait a bit. */
|
||||
__asm__("nop");
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user