From 6a2473ccc1c437b3c07405e64d9c4779c075f4fc Mon Sep 17 00:00:00 2001 From: rusefillc Date: Fri, 5 Feb 2021 23:45:47 -0500 Subject: [PATCH] reducing code duplication --- .../config/boards/hellen/cypress/chconf.h | 10 -------- firmware/config/boards/kinetis/chconf.h | 23 ++++--------------- firmware/config/chconf_common.h | 10 ++++++++ firmware/config/stm32f4ems/chconf.h | 10 -------- firmware/config/stm32f7ems/chconf.h | 10 -------- 5 files changed, 15 insertions(+), 48 deletions(-) diff --git a/firmware/config/boards/hellen/cypress/chconf.h b/firmware/config/boards/hellen/cypress/chconf.h index 1c1c471170..6962c70ea2 100644 --- a/firmware/config/boards/hellen/cypress/chconf.h +++ b/firmware/config/boards/hellen/cypress/chconf.h @@ -748,16 +748,6 @@ extern "C" void chDbgPanic3(const char *msg, const char * file, int line); #endif - -#define chDbgAssert(c, remark) do { \ - if (CH_DBG_ENABLE_ASSERTS != FALSE) { \ - if (!(c)) { \ - /*lint -restore*/ \ - chSysHalt(remark); \ - } \ - } \ -} while (false) - #undef ENABLE_PERF_TRACE #define ENABLE_PERF_TRACE FALSE #define TRACE_BUFFER_LENGTH 1 diff --git a/firmware/config/boards/kinetis/chconf.h b/firmware/config/boards/kinetis/chconf.h index 07a69b0075..4b13ce9496 100644 --- a/firmware/config/boards/kinetis/chconf.h +++ b/firmware/config/boards/kinetis/chconf.h @@ -742,24 +742,11 @@ /*===========================================================================*/ #ifndef __ASSEMBLER__ - -#ifdef __cplusplus -extern "C" -#endif -void chDbgPanic3(const char *msg, const char * file, int line); -#endif - - - - -#define chDbgAssert(c, remark) do { \ - if (CH_DBG_ENABLE_ASSERTS != FALSE) { \ - if (!(c)) { \ - /*lint -restore*/ \ - chSysHalt(remark); \ - } \ - } \ -} while (false) + #ifdef __cplusplus + extern "C" + #endif // __cplusplus + void chDbgPanic3(const char *msg, const char * file, int line); +#endif // __ASSEMBLER__ #undef ENABLE_PERF_TRACE #define ENABLE_PERF_TRACE FALSE diff --git a/firmware/config/chconf_common.h b/firmware/config/chconf_common.h index a6b33e2322..dfae9198f0 100644 --- a/firmware/config/chconf_common.h +++ b/firmware/config/chconf_common.h @@ -122,4 +122,14 @@ extern "C" { #define hasOsPanicError() (FALSE) #endif +#define chDbgAssert(c, remark) do { \ + if (CH_DBG_ENABLE_ASSERTS != FALSE) { \ + if (!(c)) { \ + /*lint -restore*/ \ + firmwareError(OBD_PCM_Processor_Fault, "chDbg %s", remark); \ + chSysHalt(remark); \ + } \ + } \ +} while (false) + #endif /* CONFIG_CHCONF_COMMON_H_ */ diff --git a/firmware/config/stm32f4ems/chconf.h b/firmware/config/stm32f4ems/chconf.h index 57cea7a7e2..80e8e2ef34 100644 --- a/firmware/config/stm32f4ems/chconf.h +++ b/firmware/config/stm32f4ems/chconf.h @@ -759,16 +759,6 @@ void chDbgPanic3(const char *msg, const char * file, int line); #endif -#define chDbgAssert(c, remark) do { \ - if (CH_DBG_ENABLE_ASSERTS != FALSE) { \ - if (!(c)) { \ - /*lint -restore*/ \ - firmwareError(OBD_PCM_Processor_Fault, "chDbg %s", remark); \ - chSysHalt(remark); \ - } \ - } \ -} while (false) - #endif /* CHCONF_H */ /** @} */ diff --git a/firmware/config/stm32f7ems/chconf.h b/firmware/config/stm32f7ems/chconf.h index 3badf19966..2d1ea1b603 100644 --- a/firmware/config/stm32f7ems/chconf.h +++ b/firmware/config/stm32f7ems/chconf.h @@ -761,16 +761,6 @@ void chDbgPanic3(const char *msg, const char * file, int line); #endif -#define chDbgAssert(c, remark) do { \ - if (CH_DBG_ENABLE_ASSERTS != FALSE) { \ - if (!(c)) { \ - /*lint -restore*/ \ - firmwareError(OBD_PCM_Processor_Fault, "chDbg %s", remark); \ - chSysHalt(remark); \ - } \ - } \ -} while (false) - #endif /* CHCONF_H */ /** @} */