2#include <libopencm3/stm32/rcc.h>
5#define ASC_USART USART2
13 rcc_periph_clock_enable(RCC_GPIOA);
14 rcc_periph_clock_enable(RCC_USART2);
15 setup_usart(ASC_USART, 9600, GPIOA, GPIO2, GPIO_AF1, GPIOA, GPIO3, GPIO_AF1);
16 usart_enable(ASC_USART);
19 if ((USART_ISR(ASC_USART) & USART_ISR_RXNE)) {
20 tmp_byte = (uint8_t)usart_recv(ASC_USART) & 0xFF;
22 if (tmp_byte && (USART_ISR(ASC_USART) & USART_ISR_TXE)) {
23 usart_send(ASC_USART, tmp_byte);
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.