blob: 9a5bdfb528ebffd976e1e9125783e0f99ac5cfde (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
/*
* Copyright 2024 Birte Kristina Friesel
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include "driver/stdout.h"
#include <libopencm3/stm32/rcc.h>
#include <libopencm3/stm32/gpio.h>
#include <libopencm3/stm32/usart.h>
void StandardOutput::setup()
{
rcc_periph_clock_enable(RCC_USART3);
gpio_mode_setup(GPIOD, GPIO_MODE_AF, GPIO_PUPD_NONE, GPIO8);
gpio_set_af(GPIOD, GPIO_AF7, GPIO8);
usart_set_baudrate(USART3, 115200);
usart_set_databits(USART3, 8);
usart_set_stopbits(USART3, USART_STOPBITS_1);
usart_set_mode(USART3, USART_MODE_TX);
usart_set_parity(USART3, USART_PARITY_NONE);
usart_set_flow_control(USART3, USART_FLOWCONTROL_NONE);
usart_enable(USART3);
}
void StandardOutput::put(char c)
{
usart_send_blocking(USART3, c);
if (c == '\n') {
put('\r');
}
}
StandardOutput kout;
|