/stm32_example_blinky_nodate.cpp Secret
Created
October 29, 2020 11:19
Star
You must be signed in to star a gist
STM32 Blinky example
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 <gpio.h> | |
#include <timer.h> | |
int main () { | |
// Initialise. | |
Timer timer; | |
//const uint8_t led_pin = 3; // Nucleo-f042k6: Port B, pin 3. | |
//const GPIO_ports led_port = GPIO_PORT_B; | |
//const uint8_t led_pin = 13; // STM32F4-Discovery: Port D, pin 13 (orange) | |
//const GPIO_ports led_port = GPIO_PORT_D; | |
//const uint8_t led_pin = 7; // Nucleo-F746ZG: Port B, pin 7 (blue) | |
//const GPIO_ports led_port = GPIO_PORT_B; | |
const uint8_t led_pin = 13; // Blue Pill: Port C, pin 13. | |
const GPIO_ports led_port = GPIO_PORT_C; | |
// Set the pin mode on the LED pin. | |
GPIO::set_output(led_port, led_pin, GPIO_PULL_UP); | |
GPIO::write(led_port, led_pin, GPIO_LEVEL_LOW); | |
while (1) { | |
GPIO::write(led_port, led_pin, GPIO_LEVEL_HIGH); | |
timer.delay(1000); | |
GPIO::write(led_port, led_pin, GPIO_LEVEL_LOW); | |
timer.delay(1000); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment