31 lines
633 B
C
31 lines
633 B
C
#include <libopencm3/stm32/rcc.h>
|
|
#include <libopencm3/stm32/gpio.h>
|
|
|
|
#include <SEGGER_RTT.h>
|
|
|
|
static void gpio_setup(void)
|
|
{
|
|
rcc_periph_clock_enable(RCC_GPIOB);
|
|
gpio_set_mode(GPIOB, GPIO_MODE_OUTPUT_2_MHZ,
|
|
GPIO_CNF_OUTPUT_PUSHPULL, GPIO1);
|
|
}
|
|
|
|
int main(void)
|
|
{
|
|
int i;
|
|
|
|
gpio_setup();
|
|
|
|
/* Blink the LED (PA5) on the board. */
|
|
while (1) {
|
|
|
|
/* Using API function gpio_toggle(): */
|
|
gpio_toggle(GPIOB, GPIO1); /* LED on/off */
|
|
SEGGER_RTT_WriteString(0, "Hello World\n");
|
|
for (i = 0; i < 800000; i++) /* Wait a bit. */
|
|
__asm__("nop");
|
|
}
|
|
|
|
return 0;
|
|
}
|