make possible to turn off at compile time online debugging, logging
authorAndrey Skvortsov <andrej.skvortzov@gmail.com>
Tue, 12 Sep 2017 16:49:35 +0300
changeset 1800 1711339585ce
parent 1799 9fd7bbf6ec45
child 1801 58ff55053518
make possible to turn off at compile time online debugging, logging
and external sync functionality

Defines TARGET_DEBUG_DISABLE, TARGET_LOGGING_DISABLE, TARGET_EXT_SYNC_DISABLE
allow to use generated PLC code in low-cost microcontrollers,
integrate into external programs and so on.

main.c:
extern void __run(void);
int main(void)
{
for(;;) {
__run();
// sleep common_ticktime__ ns
// add common_ticktime__ ns to __CURRENT_TIME
}
return 0;
}

Compile for example for arm bare-metal:
../build$ arm-none-eabi-gcc \
-DTARGET_DEBUG_DISABLE -DTARGET_LOGGER_DISABLE
-DTARGET_EXT_SYNC_DISABLE \
-flto -ffunction-sections -fdata-sections -I../../../../matiec/lib/C \
*.c \
-nodefaultlibs --specs=nano.specs -Wl,--static -Wl,--gc-section -Wl,--start-group -lc -lm -lnosys -lgcc -Wl,--end-group
targets/plc_debug.c
targets/plc_main_tail.c
--- a/targets/plc_debug.c	Tue Sep 12 14:22:17 2017 +0300
+++ b/targets/plc_debug.c	Tue Sep 12 16:49:35 2017 +0300
@@ -10,6 +10,16 @@
  *  
  * 
  * */
+
+#ifdef TARGET_DEBUG_DISABLE
+
+void __init_debug    (void){}
+void __cleanup_debug (void){}
+void __retrieve_debug(void){}
+void __publish_debug (void){}
+
+#else
+
 #include "iec_types_all.h"
 #include "POUS.h"
 /*for memcpy*/
@@ -328,3 +338,5 @@
     return wait_error;
 }
 
+#endif
+
--- a/targets/plc_main_tail.c	Tue Sep 12 14:22:17 2017 +0300
+++ b/targets/plc_main_tail.c	Tue Sep 12 16:49:35 2017 +0300
@@ -5,6 +5,7 @@
 /** 
  * LOGGING
  **/
+#ifndef TARGET_LOGGING_DISABLE
 
 #ifndef LOG_BUFFER_SIZE
 #define LOG_BUFFER_SIZE (1<<14) /*16Ko*/
@@ -134,6 +135,10 @@
     return 0;
 }
 
+#endif
+
+#ifndef TARGET_EXT_SYNC_DISABLE
+
 #define CALIBRATED -2
 #define NOT_CALIBRATED -1
 static int calibration_count = NOT_CALIBRATED;
@@ -219,3 +224,5 @@
 		}
 	}
 }
+
+#endif