Last active
June 25, 2024 08:27
-
-
Save vurdalakov/07f032139d26afd56dd62b5ed19a2389 to your computer and use it in GitHub Desktop.
Blinks all 3 user LEDs on STM32 NUCLEO-F767ZI board using libopencm3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <libopencm3/stm32/rcc.h> | |
#include <libopencm3/stm32/gpio.h> | |
#define LED_RCC RCC_GPIOB | |
#define LED_PORT GPIOB | |
#define LED_PIN1 GPIO0 | |
#define LED_PIN2 GPIO7 | |
#define LED_PIN3 GPIO14 | |
void wait() | |
{ | |
for (int i = 0; i < 1000000; i++) | |
{ | |
__asm__("nop"); | |
} | |
} | |
int main(void) | |
{ | |
rcc_periph_clock_enable(LED_RCC); | |
gpio_mode_setup(LED_PORT, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, LED_PIN1); | |
gpio_mode_setup(LED_PORT, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, LED_PIN2); | |
gpio_mode_setup(LED_PORT, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, LED_PIN3); | |
while (1) | |
{ | |
gpio_toggle(LED_PORT, LED_PIN1); | |
wait(); | |
gpio_toggle(LED_PORT, LED_PIN1); | |
wait(); | |
gpio_toggle(LED_PORT, LED_PIN2); | |
wait(); | |
gpio_toggle(LED_PORT, LED_PIN2); | |
wait(); | |
gpio_toggle(LED_PORT, LED_PIN3); | |
wait(); | |
gpio_toggle(LED_PORT, LED_PIN3); | |
wait(); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment