From e11345f6a357cf61b26785c5fca56d069ea0ff07 Mon Sep 17 00:00:00 2001 From: rusEfi Date: Thu, 11 Feb 2016 21:03:53 -0500 Subject: [PATCH] auto-sync --- firmware/.cproject | 7 +++ firmware/Makefile | 3 ++ firmware/console_util/console_util.mk | 2 + firmware/console_util/rfiutil.c | 73 +++++++++++++++++++++++++++ firmware/console_util/rfiutil.h | 37 ++++++++++++++ firmware/hw_layer/hardware.cpp | 2 - firmware/iar/ch.ewp | 18 ++++--- firmware/svnversion.h | 4 +- firmware/util/util.mk | 1 - win32_functional_tests/Makefile | 3 ++ 10 files changed, 138 insertions(+), 12 deletions(-) create mode 100644 firmware/console_util/console_util.mk create mode 100644 firmware/console_util/rfiutil.c create mode 100644 firmware/console_util/rfiutil.h diff --git a/firmware/.cproject b/firmware/.cproject index 2b761b8cec..967ab67bd7 100644 --- a/firmware/.cproject +++ b/firmware/.cproject @@ -69,6 +69,7 @@ + @@ -122,6 +123,7 @@ + @@ -345,6 +347,7 @@ + @@ -393,6 +396,7 @@ + @@ -515,6 +519,7 @@ + @@ -632,6 +637,7 @@ + @@ -685,6 +691,7 @@ + diff --git a/firmware/Makefile b/firmware/Makefile index 6b72d98c32..35d0e1d7ae 100644 --- a/firmware/Makefile +++ b/firmware/Makefile @@ -112,6 +112,7 @@ include $(PROJECT_DIR)/controllers/sensors/sensors.mk include $(PROJECT_DIR)/controllers/system/system.mk include $(PROJECT_DIR)/controllers/trigger/trigger.mk include $(PROJECT_DIR)/console/console.mk +include $(PROJECT_DIR)/console_util/console_util.mk # Define linker script file here @@ -128,6 +129,7 @@ CSRC = $(PORTSRC) \ $(UTILSRC) \ $(ENGINES_SRC) \ $(CONSOLESRC) \ + $(CONSOLEUTILSRC) \ $(HALSRC) \ $(DEV_SRC) \ $(HW_LAYER_EMS) \ @@ -196,6 +198,7 @@ INCDIR = $(PORTINC) $(KERNINC) $(TESTINC) \ ext \ ext_algo \ util \ + console_util \ console \ console/binary \ hw_layer \ diff --git a/firmware/console_util/console_util.mk b/firmware/console_util/console_util.mk new file mode 100644 index 0000000000..18660005bd --- /dev/null +++ b/firmware/console_util/console_util.mk @@ -0,0 +1,2 @@ + +CONSOLEUTILSRC = $(PROJECT_DIR)/console_util/rfiutil.c \ No newline at end of file diff --git a/firmware/console_util/rfiutil.c b/firmware/console_util/rfiutil.c new file mode 100644 index 0000000000..ca5a6c32b8 --- /dev/null +++ b/firmware/console_util/rfiutil.c @@ -0,0 +1,73 @@ +/** + * @file rfiutil.c + * @brief Number to string conversion code + * + * @date Nov 15, 2012 + * @author Andrey Belomutskiy, (c) 2012-2016 + * + * This file is part of rusEfi - see http://rusefi.com + * + * rusEfi is free software; you can redistribute it and/or modify it under the terms of + * the GNU General Public License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * rusEfi is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program. + * If not, see . + */ + +#include +#include "main.h" +#include "rfiutil.h" + +/* + not used, not sure if we still need it. I guess we will remove it in 2015 + int mylog10(int param) { + if (param < 10) + return 0; + if (param < 100) + return 1; + if (param < 1000) + return 2; + if (param < 10000) + return 3; + if (param < 100000) + return 4; + if (param < 1000000) + return 5; + if (param < 10000000) + return 6; + if (param < 100000000) + return 7; + #warning This would be better without recursion + return mylog10(param / 10) + 1; + } + */ +/* + char hexChar(int v) { + v = v & 0xF; + if (v < 10) + return (char)('0' + v); + return 'A' - 10 + v; + } + */ + +void chVTSetAny(virtual_timer_t *vtp, systime_t time, vtfunc_t vtfunc, void *par) { + bool wasLocked = lockAnyContext(); + + /** + * todo: this could be simplified once we migrate to ChibiOS 3.0 + * See http://www.chibios.org/dokuwiki/doku.php?id=chibios:howtos:porting_from_2_to_3 + */ + if (chVTIsArmedI(vtp)) { + chVTResetI(vtp); + } + + chVTSetI(vtp, time, vtfunc, par); + if (!wasLocked) { + unlockAnyContext(); + } +} diff --git a/firmware/console_util/rfiutil.h b/firmware/console_util/rfiutil.h new file mode 100644 index 0000000000..e19712e7a5 --- /dev/null +++ b/firmware/console_util/rfiutil.h @@ -0,0 +1,37 @@ +/* + * @file rfiutil.h + * @brief Number to string conversion header + * + * @date Nov 15, 2012 + * @author Andrey Belomutskiy, (c) 2012-2016 + */ + +#ifndef RFIUTIL_H_ +#define RFIUTIL_H_ + +#include "global.h" +#include "histogram.h" + +#define isLocked() (dbg_lock_cnt > 0) + + /** + * Unfortunately ChibiOS has two versions of methods for different + * contexts. + */ + +#define isIsrContext() (dbg_isr_cnt > 0) + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +//char hexC(int v); +void chVTSetAny(virtual_timer_t *vtp, systime_t time, vtfunc_t vtfunc, void *par); + +#ifdef __cplusplus +} +void printHistogram(Logging *logging, histogram_s *histogram); +#endif /* __cplusplus */ + +#endif /* RFIUTIL_H_ */ diff --git a/firmware/hw_layer/hardware.cpp b/firmware/hw_layer/hardware.cpp index bfd083095c..426644448c 100644 --- a/firmware/hw_layer/hardware.cpp +++ b/firmware/hw_layer/hardware.cpp @@ -372,9 +372,7 @@ void initHardware(Logging *l) { initVehicleSpeed(sharedLogger); #endif -#if HAL_USE_EXT || defined(__DOXYGEN__) initJoystick(sharedLogger); -#endif calcFastAdcIndexes(); engine->addConfigurationListener(adcConfigListener); diff --git a/firmware/iar/ch.ewp b/firmware/iar/ch.ewp index 6382382a67..153faea7e7 100644 --- a/firmware/iar/ch.ewp +++ b/firmware/iar/ch.ewp @@ -329,6 +329,7 @@ $PROJ_DIR$\..\config\engines $PROJ_DIR$\..\config\stm32f4ems $PROJ_DIR$\..\console\binary + $PROJ_DIR$\..\console_util $PROJ_DIR$\..\development $PROJ_DIR$\..\development\test $PROJ_DIR$\..\development\hw_layer @@ -2172,6 +2173,15 @@ $PROJ_DIR$\..\console\status_loop.h + + console_util + + $PROJ_DIR$\..\console_util\rfiutil.c + + + $PROJ_DIR$\..\console_util\rfiutil.h + + controllers @@ -2255,7 +2265,7 @@ $PROJ_DIR$\..\controllers\algo\main_trigger_callback.h - $PROJ_DIR$\..\controllers\algo\malfunction_central.cpp + $PROJ_DIR$\..\controllers\algo\malfunction_central.c $PROJ_DIR$\..\controllers\algo\malfunction_central.h @@ -3323,12 +3333,6 @@ util - - $PROJ_DIR$\..\util\rfiutil.c - - - $PROJ_DIR$\..\util\rfiutil.h - $PROJ_DIR$\..\util\cli_registry.cpp diff --git a/firmware/svnversion.h b/firmware/svnversion.h index 1361a537bb..73b7398241 100644 --- a/firmware/svnversion.h +++ b/firmware/svnversion.h @@ -1,5 +1,5 @@ // This file was generated by Version2Header -// Thu Feb 11 19:42:49 EST 2016 +// Thu Feb 11 14:16:47 EST 2016 #ifndef VCS_VERSION -#define VCS_VERSION "9550" +#define VCS_VERSION "9535" #endif diff --git a/firmware/util/util.mk b/firmware/util/util.mk index 2ff4b2bdc7..7396075209 100644 --- a/firmware/util/util.mk +++ b/firmware/util/util.mk @@ -1,6 +1,5 @@ UTIL_TEST_SRC = $(PROJECT_DIR)/util/crc.c \ - $(PROJECT_DIR)/rfiutil.c \ $(PROJECT_DIR)/util/data_buffer.c \ $(PROJECT_DIR)/util/histogram.c diff --git a/win32_functional_tests/Makefile b/win32_functional_tests/Makefile index beadfe8828..ab239be2f6 100644 --- a/win32_functional_tests/Makefile +++ b/win32_functional_tests/Makefile @@ -80,6 +80,7 @@ include $(PROJECT_DIR)/controllers/trigger/trigger.mk include $(PROJECT_DIR)/controllers/system/system.mk include $(PROJECT_DIR)/console/console.mk include $(PROJECT_DIR)/console/binary/tunerstudio.mk +include $(PROJECT_DIR)/console_util/console_util.mk include $(PROJECT_DIR)/development/development.mk include $(CHIBIOS)/boards/simulator/board.mk @@ -102,6 +103,7 @@ CSRC = ${PORTSRC} \ $(TRIGGER_SRC) \ $(SYSTEMSRC) \ $(CONSOLESRC) \ + $(CONSOLEUTILSRC) \ $(CONTROLLERS_ALGO_SRC) \ $(CONTROLLERS_CORE_SRC) \ $(CONTROLLERS_MATH_SRC) \ @@ -165,6 +167,7 @@ $(PORTINC) $(KERNINC) $(TESTINC) \ $(PROJECT_DIR)/util \ $(PROJECT_DIR)/console \ $(PROJECT_DIR)/console/binary \ + $(PROJECT_DIR)/console_util \ $(PROJECT_DIR)/config/engines \ $(PROJECT_DIR)/ext_algo \ $(PROJECT_DIR)/controllers \