aboutsummaryrefslogtreecommitdiff
path: root/examples/stm32/obldc/usart
diff options
context:
space:
mode:
authorUwe Hermann2011-01-03 01:12:07 +0100
committerUwe Hermann2011-01-03 01:12:07 +0100
commitca53311bfc3182212d53386c5f49f0bc57350266 (patch)
tree2a81b20c486717d0fea3d1987549c15d2bb529b2 /examples/stm32/obldc/usart
parent05f66cde4cc2d9e57e495f6d8b51619f08191c68 (diff)
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.
Diffstat (limited to 'examples/stm32/obldc/usart')
-rw-r--r--examples/stm32/obldc/usart/usart.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/examples/stm32/obldc/usart/usart.c b/examples/stm32/obldc/usart/usart.c
index 1605a06..ea5ec0e 100644
--- a/examples/stm32/obldc/usart/usart.c
+++ b/examples/stm32/obldc/usart/usart.c
@@ -25,7 +25,7 @@ void clock_setup(void)
{
rcc_clock_setup_in_hse_8mhz_out_72mhz();
- /* Enable GPIOA clock. For LED gpio's */
+ /* Enable GPIOA clock (for LED GPIOs). */
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPAEN);
/* Enable clocks for GPIO port B (for GPIO_USART1_TX) and USART1. */
@@ -36,11 +36,9 @@ void clock_setup(void)
void usart_setup(void)
{
-
- /* Setup GPIO6 (in GPIO port A) to 'output push-pull' for led use. */
+ /* Setup GPIO6 (in GPIO port A) to 'output push-pull' for LED use. */
gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_50_MHZ,
- GPIO_CNF_OUTPUT_PUSHPULL,
- GPIO6);
+ GPIO_CNF_OUTPUT_PUSHPULL, GPIO6);
AFIO_MAPR |= AFIO_MAPR_USART1_REMAP;
@@ -78,13 +76,14 @@ int main(void)
/* Blink the LED (PC12) on the board with every transmitted byte. */
while (1) {
gpio_toggle(GPIOA, GPIO6); /* LED on/off */
- usart_send_blocking(USART1, c + '0'); /* Send one byte on USART3. */
+ usart_send_blocking(USART1, c + '0'); /* Send a byte. */
c = (c == 9) ? 0 : c + 1; /* Increment c. */
if ((j++ % 80) == 0) { /* Newline after line full. */
usart_send_blocking(USART1, '\r');
usart_send_blocking(USART1, '\n');
}
- for (i = 0; i < 80000; i++); /* Wait (needs -O0 CFLAGS). */
+ for (i = 0; i < 800000; i++) /* Wait a bit. */
+ __asm__("nop");
}
return 0;