Skip to content

Commit

Permalink
Add STM32F1 target to libopencm3 blink example
Browse files Browse the repository at this point in the history
  • Loading branch information
valeros committed Jun 28, 2019
1 parent 142a07c commit 1ba1726
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions examples/libopencm3-blink/src/main.c
Expand Up @@ -25,6 +25,12 @@
#define RCCLEDPORT (RCC_GPIOB)
#define LEDPORT (GPIOB)
#define LEDPIN (GPIO6)
#elif STM32F1
#define RCCLEDPORT (RCC_GPIOC)
#define LEDPORT (GPIOC)
#define LEDPIN (GPIO13)
#define GPIO_MODE_OUTPUT GPIO_MODE_OUTPUT_2_MHZ
#define GPIO_PUPD_NONE GPIO_CNF_OUTPUT_PUSHPULL
#elif STM32F3
#define RCCLEDPORT (RCC_GPIOE)
#define LEDPORT (GPIOE)
Expand All @@ -33,6 +39,8 @@
#define RCCLEDPORT (RCC_GPIOD)
#define LEDPORT (GPIOD)
#define LEDPIN (GPIO12)
#else
#error "This example doesn't support this target!"
#endif

static void gpio_setup(void)
Expand All @@ -42,7 +50,11 @@ static void gpio_setup(void)
rcc_periph_clock_enable(RCCLEDPORT);
/* Set pin to 'output push-pull'. */
/* Using API functions: */
#ifdef STM32F1
gpio_set_mode(LEDPORT, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, LEDPIN);
#else
gpio_mode_setup(LEDPORT, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, LEDPIN);
#endif
}

int main(void)
Expand Down

0 comments on commit 1ba1726

Please sign in to comment.