diff options
author | Daniel Friesel <derf@finalrewind.org> | 2020-07-26 11:55:32 +0200 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2020-07-26 12:03:45 +0200 |
commit | 8458978ad5512dc813ac700d59983c56917fa205 (patch) | |
tree | 4f34847064c98c5aca0ca0e95ef9f814d2edfb16 /src/arch/stm32f446re-nucleo/driver | |
parent | d0ea0a521a582549dfd9a98b47e7c12d8bcd0de6 (diff) |
Add minimal STM32F446RE Nucleo support. No interrupts yet.
Diffstat (limited to 'src/arch/stm32f446re-nucleo/driver')
-rw-r--r-- | src/arch/stm32f446re-nucleo/driver/gpio.cc | 3 | ||||
-rw-r--r-- | src/arch/stm32f446re-nucleo/driver/stdout.cc | 31 |
2 files changed, 34 insertions, 0 deletions
diff --git a/src/arch/stm32f446re-nucleo/driver/gpio.cc b/src/arch/stm32f446re-nucleo/driver/gpio.cc new file mode 100644 index 0000000..1403aed --- /dev/null +++ b/src/arch/stm32f446re-nucleo/driver/gpio.cc @@ -0,0 +1,3 @@ +#include "driver/gpio.h" + +GPIO gpio; diff --git a/src/arch/stm32f446re-nucleo/driver/stdout.cc b/src/arch/stm32f446re-nucleo/driver/stdout.cc new file mode 100644 index 0000000..2c20158 --- /dev/null +++ b/src/arch/stm32f446re-nucleo/driver/stdout.cc @@ -0,0 +1,31 @@ +#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_USART2); + gpio_mode_setup(GPIOA, GPIO_MODE_AF, GPIO_PUPD_NONE, GPIO2); + gpio_set_af(GPIOA, GPIO_AF7, GPIO2); + + usart_set_baudrate(USART2, 115200); + usart_set_databits(USART2, 8); + usart_set_stopbits(USART2, USART_STOPBITS_1); + usart_set_mode(USART2, USART_MODE_TX); + usart_set_parity(USART2, USART_PARITY_NONE); + usart_set_flow_control(USART2, USART_FLOWCONTROL_NONE); + + usart_enable(USART2); +} + +void StandardOutput::put(char c) +{ + usart_send_blocking(USART2, c); + if (c == '\n') { + put('\r'); + } +} + +StandardOutput kout; |