2#include <libopencm3/stm32/gpio.h>
3#include <libopencm3/stm32/rcc.h>
7#define RCC_GPIO_LED RCC_GPIOA
10#define ASC_USART USART2
12static void gpio_setup(
void) {
13 rcc_periph_clock_enable(RCC_GPIO_LED);
15 gpio_mode_setup(PORT_LED, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, PIN_LED);
26 rcc_periph_clock_enable(RCC_GPIOA);
27 rcc_periph_clock_enable(RCC_USART2);
28 setup_usart(ASC_USART, 9600, GPIOA, GPIO2, GPIO_AF1, GPIOA, GPIO3, GPIO_AF1);
31 usart_enable(ASC_USART);
34 usart_send_blocking(ASC_USART,
'0' + counter);
To be used with the USART peripherals on STM32 microcontrollers.
#define setup_usart(usart, baud, tx_port, tx_pin, tx_af, rx_port, rx_pin, rx_af)
Setup a USART.