3 typedef unsigned int uint32_t;
6 /* hardware configuration */
8 #if CONFIG_STM32VL_DISCOVERY
10 # define GPIOC 0x40011000 /* port C */
11 # define GPIOC_CRH (GPIOC + 0x04) /* port configuration register high */
12 # define GPIOC_ODR (GPIOC + 0x0c) /* port output data register */
14 # define LED_BLUE (1 << 8) /* port C, pin 8 */
15 # define LED_GREEN (1 << 9) /* port C, pin 9 */
17 static inline void setup_leds(void)
19 *(volatile uint32_t*)GPIOC_CRH = 0x44444411;
22 static inline void switch_leds_on(void)
24 *(volatile uint32_t*)GPIOC_ODR = LED_BLUE | LED_GREEN;
27 static inline void switch_leds_off(void)
29 *(volatile uint32_t*)GPIOC_ODR = 0;
32 #elif CONFIG_STM32L_DISCOVERY
34 # define GPIOB 0x40020400 /* port B */
35 # define GPIOB_MODER (GPIOB + 0x00) /* port mode register */
36 # define GPIOB_ODR (GPIOB + 0x14) /* port output data register */
38 # define LED_BLUE (1 << 6) /* port B, pin 6 */
39 # define LED_GREEN (1 << 7) /* port B, pin 7 */
41 static inline void setup_leds(void)
43 /* configure port 6 and 7 as output */
44 *(volatile uint32_t*)GPIOB_MODER |= (1 << (7 * 2)) | (1 << (6 * 2));
47 static inline void switch_leds_on(void)
49 *(volatile uint32_t*)GPIOB_ODR = LED_BLUE | LED_GREEN;
52 static inline void switch_leds_off(void)
54 *(volatile uint32_t*)GPIOB_ODR = 0;
57 #endif /* otherwise, error */
62 register unsigned int i; \
63 for (i = 0; i < 1000000; ++i) \
64 __asm__ __volatile__ ("nop\n\t":::"memory"); \