]> mj.ucw.cz Git - home-hw.git/commitdiff
Modbus: Genericized debugging
authorMartin Mares <mj@ucw.cz>
Mon, 8 Jul 2019 17:11:22 +0000 (19:11 +0200)
committerMartin Mares <mj@ucw.cz>
Mon, 8 Jul 2019 17:11:22 +0000 (19:11 +0200)
test-modbus/config.h
test-modbus/modbus.c
test-modbus/util-debug.c
test-modbus/util.h

index 1b116d6a7f18cfcf12a7205941b36548cf3ac7fa..439cd7bf406d43ee9d25cfead7ed2c6962335116 100644 (file)
@@ -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
index df37adff068098cedacab26a19c43426fc62cc38..c6336460d307d1a8fe814e77b3159409ddaeb113 100644 (file)
@@ -4,7 +4,6 @@
  *     (c) 2019 Martin Mareš <mj@ucw.cz>
  */
 
-#include "config.h"
 #include "util.h"
 #include "modbus.h"
 
index 03671829d8946aab83ff951d5bc385cb7b9188fb..e47ff46c9bd04c6f119216381e0a903ebcce9a1d 100644 (file)
@@ -5,6 +5,18 @@
 #include <stdarg.h>
 #include <string.h>
 
+/*** 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)
index 09f8bbc94f56e83d5d307e30e3d914c36493ff8b..a84d09975475d03fe05a7bca1715aeb57b3c25b6 100644 (file)
@@ -2,6 +2,8 @@
 #include <stddef.h>
 #include <stdint.h>
 
+#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);