From aef09d6578f25b0a2005035f892d746a0cdd7da1 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Wed, 18 Sep 2024 11:46:17 +0200 Subject: [PATCH] =?UTF-8?q?Uk=C3=A1zka=20debugovac=C3=ADch=20v=C3=BDpis?= =?UTF-8?q?=C5=AF=20p=C5=99es=20debug=5F*?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/usart-debug/Makefile | 6 ++++++ src/usart-debug/config.h | 14 ++++++++++++++ src/usart-debug/test.c | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 src/usart-debug/Makefile create mode 100644 src/usart-debug/config.h create mode 100644 src/usart-debug/test.c diff --git a/src/usart-debug/Makefile b/src/usart-debug/Makefile new file mode 100644 index 0000000..22fbb86 --- /dev/null +++ b/src/usart-debug/Makefile @@ -0,0 +1,6 @@ +ROOT=.. +BINARY=test +OBJS=test.o +LIB_OBJS=util-debug.o + +include $(ROOT)/example.mk diff --git a/src/usart-debug/config.h b/src/usart-debug/config.h new file mode 100644 index 0000000..9cd4bec --- /dev/null +++ b/src/usart-debug/config.h @@ -0,0 +1,14 @@ +/* + * DMX512 Interface -- Configuration + * + * (c) 2020 Martin Mareš + */ + +// Processor clock + +#define CPU_CLOCK_MHZ 72 + +// Debugging port + +#define DEBUG_USART USART1 +#define DEBUG_LED_BLUEPILL diff --git a/src/usart-debug/test.c b/src/usart-debug/test.c new file mode 100644 index 0000000..bf2e129 --- /dev/null +++ b/src/usart-debug/test.c @@ -0,0 +1,34 @@ +#include +#include +#include + +#include "util.h" + +int main(void) +{ + rcc_clock_setup_pll(&rcc_hse_configs[RCC_CLOCK_HSE8_72MHZ]); + rcc_periph_clock_enable(RCC_GPIOA); + rcc_periph_clock_enable(RCC_GPIOC); + rcc_periph_clock_enable(RCC_USART1); + + // PC13 = BluePill LED + gpio_set_mode(GPIOC, GPIO_MODE_OUTPUT_50_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO13); + + // PA10 = RX1, PA9 = TX1 + gpio_set_mode(GPIOA, GPIO_MODE_INPUT, GPIO_CNF_INPUT_FLOAT, GPIO10); + gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_50_MHZ, GPIO_CNF_OUTPUT_ALTFN_PUSHPULL, GPIO9); + + usart_set_baudrate(USART1, 115200); + usart_set_databits(USART1, 8); + usart_set_stopbits(USART1, USART_STOPBITS_1); + usart_set_mode(USART1, USART_MODE_TX_RX); + usart_set_parity(USART1, USART_PARITY_NONE); + usart_set_flow_control(USART1, USART_FLOWCONTROL_NONE); + usart_enable(USART1); + + int cnt = 0; + for (;;) { + debug_printf("%d\n", cnt); + cnt++; + } +}