From: Martin Mares Date: Mon, 8 Jul 2019 17:11:22 +0000 (+0200) Subject: Modbus: Genericized debugging X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=85467d44920f4e69cc14d793fc1440520b80ac84;p=home-hw.git Modbus: Genericized debugging --- diff --git a/test-modbus/config.h b/test-modbus/config.h index 1b116d6..439cd7b 100644 --- a/test-modbus/config.h +++ b/test-modbus/config.h @@ -2,6 +2,11 @@ #define CPU_CLOCK_MHZ 72 +// Debugging port + +// #define DEBUG_SEMIHOSTING +#define DEBUG_USART USART1 + // MODBUS library parameters #define MODBUS_USART USART2 diff --git a/test-modbus/modbus.c b/test-modbus/modbus.c index df37adf..c633646 100644 --- a/test-modbus/modbus.c +++ b/test-modbus/modbus.c @@ -4,7 +4,6 @@ * (c) 2019 Martin Mareš */ -#include "config.h" #include "util.h" #include "modbus.h" diff --git a/test-modbus/util-debug.c b/test-modbus/util-debug.c index 0367182..e47ff46 100644 --- a/test-modbus/util-debug.c +++ b/test-modbus/util-debug.c @@ -5,6 +5,18 @@ #include #include +/*** Configuration ***/ + +// You should set the following parameters in config.h + +// Use the semi-hosting interface for debugging messages +// #define DEBUG_SEMIHOSTING + +// Use this USART for debugging messages +// #define DEBUG_USART USART1 + +/*** Implementation ***/ + #ifdef DEBUG_SEMIHOSTING void semi_put_char(char c) diff --git a/test-modbus/util.h b/test-modbus/util.h index 09f8bbc..a84d099 100644 --- a/test-modbus/util.h +++ b/test-modbus/util.h @@ -2,6 +2,8 @@ #include #include +#include "config.h" + typedef unsigned int uint; typedef uint8_t byte; typedef uint16_t u16; @@ -64,9 +66,6 @@ static inline void put_u32_le(byte *p, u32 x) // debug.c -// #define DEBUG_SEMIHOSTING -#define DEBUG_USART USART1 - void debug_printf(const char *fmt, ...); void debug_puts(const char *s); void debug_putc(int c);