Browse Source

Ukázka debugovacích výpisů přes debug_*

master
Martin Mareš 3 months ago
parent
commit
aef09d6578
  1. 6
      src/usart-debug/Makefile
  2. 14
      src/usart-debug/config.h
  3. 34
      src/usart-debug/test.c

6
src/usart-debug/Makefile

@ -0,0 +1,6 @@
ROOT=..
BINARY=test
OBJS=test.o
LIB_OBJS=util-debug.o
include $(ROOT)/example.mk

14
src/usart-debug/config.h

@ -0,0 +1,14 @@
/*
* DMX512 Interface -- Configuration
*
* (c) 2020 Martin Mareš <mj@ucw.cz>
*/
// Processor clock
#define CPU_CLOCK_MHZ 72
// Debugging port
#define DEBUG_USART USART1
#define DEBUG_LED_BLUEPILL

34
src/usart-debug/test.c

@ -0,0 +1,34 @@
#include <libopencm3/stm32/rcc.h>
#include <libopencm3/stm32/gpio.h>
#include <libopencm3/stm32/usart.h>
#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++;
}
}
Loading…
Cancel
Save