aboutsummaryrefslogtreecommitdiff
path: root/examples/stm32/stm32-h103
diff options
context:
space:
mode:
Diffstat (limited to 'examples/stm32/stm32-h103')
-rw-r--r--examples/stm32/stm32-h103/fancyblink/fancyblink.c3
-rw-r--r--examples/stm32/stm32-h103/miniblink/miniblink.c17
-rw-r--r--examples/stm32/stm32-h103/usart/usart.c5
-rw-r--r--examples/stm32/stm32-h103/usb_cdcacm/cdcacm.c5
4 files changed, 20 insertions, 10 deletions
diff --git a/examples/stm32/stm32-h103/fancyblink/fancyblink.c b/examples/stm32/stm32-h103/fancyblink/fancyblink.c
index 876fb2d..eeb3f34 100644
--- a/examples/stm32/stm32-h103/fancyblink/fancyblink.c
+++ b/examples/stm32/stm32-h103/fancyblink/fancyblink.c
@@ -47,7 +47,8 @@ int main(void)
/* Blink the LED (PC12) on the board. */
while (1) {
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;
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;
diff --git a/examples/stm32/stm32-h103/usart/usart.c b/examples/stm32/stm32-h103/usart/usart.c
index c3d24ca..487ee84 100644
--- a/examples/stm32/stm32-h103/usart/usart.c
+++ b/examples/stm32/stm32-h103/usart/usart.c
@@ -69,13 +69,14 @@ int main(void)
/* Blink the LED (PC12) on the board with every transmitted byte. */
while (1) {
gpio_toggle(GPIOC, GPIO12); /* LED on/off */
- usart_send_blocking(USART3, c + '0'); /* Send one byte on USART3. */
+ usart_send_blocking(USART3, c + '0'); /* USART3: Send byte. */
c = (c == 9) ? 0 : c + 1; /* Increment c. */
if ((j++ % 80) == 0) { /* Newline after line full. */
usart_send_blocking(USART3, '\r');
usart_send_blocking(USART3, '\n');
}
- for (i = 0; i < 80000; i++); /* Wait (needs -O0 CFLAGS). */
+ for (i = 0; i < 800000; i++) /* Wait a bit. */
+ __asm__("NOP");
}
return 0;
diff --git a/examples/stm32/stm32-h103/usb_cdcacm/cdcacm.c b/examples/stm32/stm32-h103/usb_cdcacm/cdcacm.c
index fa545a7..fd8847c 100644
--- a/examples/stm32/stm32-h103/usb_cdcacm/cdcacm.c
+++ b/examples/stm32/stm32-h103/usb_cdcacm/cdcacm.c
@@ -224,6 +224,8 @@ static void cdcacm_set_config(u16 wValue)
int main(void)
{
+ int i;
+
rcc_clock_setup_in_hsi_out_48mhz();
rcc_peripheral_enable_clock(&RCC_APB1ENR, RCC_APB1ENR_USBEN);
@@ -236,7 +238,8 @@ int main(void)
usbd_init(&dev, &config, usb_strings);
usbd_register_set_config_callback(cdcacm_set_config);
- {int i; for (i=0;i<0x80000;i++);}
+ for (i = 0; i < 0x800000; i++)
+ __asm__("nop");
gpio_clear(GPIOC, GPIO11);
while (1)