aboutsummaryrefslogtreecommitdiff
path: root/examples/stm32/obldc/usart_irq/usart_irq.c
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_irq/usart_irq.c
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_irq/usart_irq.c')
-rw-r--r--examples/stm32/obldc/usart_irq/usart_irq.c20
1 files changed, 6 insertions, 14 deletions
diff --git a/examples/stm32/obldc/usart_irq/usart_irq.c b/examples/stm32/obldc/usart_irq/usart_irq.c
index ca8d390..2d4dd06 100644
--- a/examples/stm32/obldc/usart_irq/usart_irq.c
+++ b/examples/stm32/obldc/usart_irq/usart_irq.c
@@ -26,7 +26,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. */
@@ -37,7 +37,6 @@ void clock_setup(void)
void usart_setup(void)
{
-
/* Enable the USART1 interrupt. */
nvic_enable_irq(NVIC_USART1_IRQ);
@@ -69,14 +68,11 @@ void usart_setup(void)
void gpio_setup(void)
{
-
gpio_set(GPIOA, GPIO6 | GPIO7);
/* Setup GPIO6 and 7 (in GPIO port A) for led use. */
gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_50_MHZ,
- GPIO_CNF_OUTPUT_PUSHPULL,
- GPIO6 | GPIO7);
-
+ GPIO_CNF_OUTPUT_PUSHPULL, GPIO6 | GPIO7);
}
void usart1_isr(void)
@@ -85,7 +81,6 @@ void usart1_isr(void)
/* Check if we were called because of RXNE. */
if ((USART_SR(USART1) & USART_SR_RXNE) != 0) {
-
/* Indicate that we got data. */
gpio_toggle(GPIOA, GPIO6);
@@ -98,29 +93,26 @@ void usart1_isr(void)
/* Check if we were called because of TXE. */
if ((USART_SR(USART1) & USART_SR_TXE) != 0) {
-
/* Indicate that we are sending out data. */
gpio_toggle(GPIOA, GPIO7);
- /* Put data into the transmit register */
+ /* Put data into the transmit register. */
usart_send(USART1, data);
- /* Disable the TXE interrupt as we don't need it anymore */
+ /* Disable the TXE interrupt as we don't need it anymore. */
USART_CR1(USART1) &= ~USART_CR1_TXEIE;
}
}
int main(void)
{
-
clock_setup();
gpio_setup();
usart_setup();
/* Wait forever and do nothing. */
- while (1) {
- __asm("nop");
- }
+ while (1)
+ __asm__("nop");
return 0;
}