25 lines
758 B
C
25 lines
758 B
C
#include "uart.h"
|
|
#include <libopencm3/cm3/nvic.h>
|
|
#include <libopencm3/stm32/rcc.h>
|
|
#include <libopencm3/stm32/gpio.h>
|
|
|
|
void uart_setup() {
|
|
rcc_periph_clock_enable(RCC_GPIOB);
|
|
rcc_periph_clock_enable(RCC_USART3);
|
|
|
|
gpio_mode_setup(GPIOB, GPIO_MODE_AF, GPIO_PUPD_NONE, GPIO10 | GPIO11);
|
|
gpio_set_af(GPIOB, GPIO_AF7, GPIO10 | GPIO11);
|
|
|
|
usart_set_baudrate(USART3, 115200);
|
|
usart_set_databits(USART3, 8);
|
|
usart_set_stopbits(USART3, USART_STOPBITS_1);
|
|
usart_set_mode(USART3, USART_MODE_TX_RX);
|
|
usart_set_parity(USART3, USART_PARITY_NONE);
|
|
usart_set_flow_control(USART3, USART_FLOWCONTROL_NONE);
|
|
usart_enable(USART3);
|
|
|
|
usart_disable_tx_complete_interrupt(USART3);
|
|
usart_enable_tx_interrupt(USART3);
|
|
usart_enable_rx_interrupt(USART3);
|
|
}
|