diff --git a/unit_tests/.cproject b/unit_tests/.cproject
index 71e7c9e65e..cb910d6b94 100644
--- a/unit_tests/.cproject
+++ b/unit_tests/.cproject
@@ -1,141 +1,156 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/unit_tests/.project b/unit_tests/.project
index 3238f268dc..771bc268c3 100644
--- a/unit_tests/.project
+++ b/unit_tests/.project
@@ -1,27 +1,27 @@
-
-
- unit_tests
-
-
-
-
-
- org.eclipse.cdt.managedbuilder.core.genmakebuilder
- clean,full,incremental,
-
-
-
-
- org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
- full,incremental,
-
-
-
-
-
- org.eclipse.cdt.core.cnature
- org.eclipse.cdt.core.ccnature
- org.eclipse.cdt.managedbuilder.core.managedBuildNature
- org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
-
-
+
+
+ unit_tests
+
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.genmakebuilder
+ clean,full,incremental,
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
+ full,incremental,
+
+
+
+
+
+ org.eclipse.cdt.core.cnature
+ org.eclipse.cdt.core.ccnature
+ org.eclipse.cdt.managedbuilder.core.managedBuildNature
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
+
+
diff --git a/unit_tests/Makefile b/unit_tests/Makefile
index 1eb54405fd..2cc0a88e0d 100644
--- a/unit_tests/Makefile
+++ b/unit_tests/Makefile
@@ -1,221 +1,228 @@
-##############################################################################
-# Build global options
-# NOTE: Can be overridden externally.
-#
-
-PROJECT_DIR = ../firmware
-#CHIBIOS = $(PROJECT_DIR)/chibios
-
-# Compiler options here.
-ifeq ($(USE_OPT),)
-# -O2 is needed for mingw, without it there is a linking issue to isnanf?!?!
- #USE_OPT = $(RFLAGS) -O2 -fgnu89-inline -ggdb -fomit-frame-pointer -falign-functions=16 -std=gnu99 -Werror-implicit-function-declaration -Werror -Wno-error=pointer-sign -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=sign-compare -Wno-error=unused-parameter -Wno-error=missing-field-initializers
- USE_OPT = -c -Wall -O2
-endif
-
-# C specific options here (added to USE_OPT).
-ifeq ($(USE_COPT),)
- USE_COPT = -std=gnu99 -fgnu89-inline
-endif
-
-# C++ specific options here (added to USE_OPT).
-ifeq ($(USE_CPPOPT),)
- USE_CPPOPT = -fno-rtti -fpermissive -fno-exceptions -fno-use-cxa-atexit
-endif
-
-# Enable this if you want the linker to remove unused code and data
-ifeq ($(USE_LINK_GC),)
- USE_LINK_GC = yes
-endif
-
-# If enabled, this option allows to compile the application in THUMB mode.
-ifeq ($(USE_THUMB),)
- USE_THUMB = no
-endif
-
-# Enable this if you want to see the full log while compiling.
-ifeq ($(USE_VERBOSE_COMPILE),)
- USE_VERBOSE_COMPILE = no
-endif
-
-#
-# Build global options
-##############################################################################
-
-##############################################################################
-# Architecture or project specific options
-#
-
-
-# List all default C defines here, like -D_DEBUG=1
-DDEFS =
-
-#
-# Architecture or project specific options
-##############################################################################
-
-##############################################################################
-# Project, sources and paths
-#
-
-# Define project name here
-PROJECT = rusefi_test
-
-#PROJECT_BOARD = OLIMEX_STM32_E407
-#ifneq ($(PROJECT_BOARD),OLIMEX_STM32_E407)
-# PROJECT_BOARD = ST_STM32F4_DISCOVERY
-#endif
-#DDEFS += -D$(PROJECT_BOARD)
-
-# Imported source files and paths
-include $(PROJECT_DIR)/util/util.mk
-include $(PROJECT_DIR)/config/engines/engines.mk
-include $(PROJECT_DIR)/controllers/algo/algo.mk
-include $(PROJECT_DIR)/controllers/math/math.mk
-include $(PROJECT_DIR)/controllers/sensors/sensors.mk
-include test.mk
-
-# Define linker script file here
-#LDSCRIPT= config/system/STM32F407xG.ld
-#LDSCRIPT= $(PORTLD)/STM32F407xG_CCM.ld
-
-# C sources that can be compiled in ARM or THUMB mode depending on the global
-# setting.
-CSRC = $(UTILSRC) \
- $(CONTROLLERS_ALGO_SRC) \
- $(CONTROLLERS_MATH_SRC) \
- $(CONTROLLERS_SENSORS_SRC) \
- $(ENGINES_SRC) \
- $(TEST_SRC_C)
-
-# C++ sources that can be compiled in ARM or THUMB mode depending on the global
-# setting.
-CPPSRC = $(UTILSRC_CPP) \
- $(CONTROLLERS_ALGO_SRC_CPP) \
- $(ENGINES_SRC_CPP) \
- $(TEST_SRC_CPP) \
- main.cpp
-
-# C sources to be compiled in ARM mode regardless of the global setting.
-# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
-# option that results in lower performance and larger code size.
-ACSRC =
-
-# C++ sources to be compiled in ARM mode regardless of the global setting.
-# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
-# option that results in lower performance and larger code size.
-ACPPSRC =
-
-# C sources to be compiled in THUMB mode regardless of the global setting.
-# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
-# option that results in lower performance and larger code size.
-TCSRC =
-
-# C sources to be compiled in THUMB mode regardless of the global setting.
-# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
-# option that results in lower performance and larger code size.
-TCPPSRC =
-
-# List ASM source files here
-ASMSRC = $(PORTASM)
-
-INCDIR = . \
- $(PROJECT_DIR)/util \
- $(PROJECT_DIR)/config/engines \
- $(PROJECT_DIR)/controllers/sensors \
- $(PROJECT_DIR)/controllers/algo \
- $(PROJECT_DIR)/controllers/math \
- $(PROJECT_DIR)/ext_algo \
- test_data_structures \
- test_basic_math
-
-
-#
-# Project, sources and paths
-##############################################################################
-
-##############################################################################
-# Compiler settings
-#
-
-#MCU = cortex-m4
-
-ifeq ($(OS),Windows_NT)
- TRGT = i686-pc-mingw32-
-else
- TRGT =
-endif
-
-CC = $(TRGT)gcc
-CPPC = $(TRGT)g++
-# Enable loading with g++ only if you need C++ runtime support.
-# NOTE: You can use C++ even without C++ support if you are careful. C++
-# runtime support makes code size explode.
-#LD = $(TRGT)gcc
-LD = $(TRGT)g++
-CP = $(TRGT)objcopy
-AS = $(TRGT)gcc -x assembler-with-cpp
-OD = $(TRGT)objdump
-HEX = $(CP) -O ihex
-BIN = $(CP) -O binary
-
-# ARM-specific options here
-AOPT =
-
-# THUMB-specific options here
-TOPT = -mthumb -DTHUMB
-
-# Define C warning options here
-CWARN = -Wall -Wextra -Wstrict-prototypes
-
-# Define C++ warning options here
-CPPWARN = -Wall -Wextra
-
-#
-# Compiler settings
-##############################################################################
-
-##############################################################################
-# Start of default section
-#
-
-# List all default ASM defines here, like -D_DEBUG=1
-DADEFS =
-
-# List all default directories to look for include files here
-DINCDIR =
-
-# List the default directory to look for the libraries here
-DLIBDIR =
-
-# List all default libraries here
-DLIBS = -static-libgcc -static-libstdc++
-
-#
-# End of default section
-##############################################################################
-
-##############################################################################
-# Start of user section
-#
-
-# List all user C define here, like -D_DEBUG=1
-UDEFS =
-
-# Define ASM defines here
-UADEFS =
-
-# List all user directories here
-UINCDIR =
-
-# List the user directory to look for the libraries here
-ULIBDIR =
-
-# List all user libraries here
-ULIBS = -lm
-
-#
-# End of user defines
-##############################################################################
-
-include rules.mk
+##############################################################################
+# Build global options
+# NOTE: Can be overridden externally.
+#
+
+PROJECT_DIR = ../firmware
+#CHIBIOS = $(PROJECT_DIR)/chibios
+
+# Compiler options here.
+ifeq ($(USE_OPT),)
+# -O2 is needed for mingw, without it there is a linking issue to isnanf?!?!
+ #USE_OPT = $(RFLAGS) -O2 -fgnu89-inline -ggdb -fomit-frame-pointer -falign-functions=16 -std=gnu99 -Werror-implicit-function-declaration -Werror -Wno-error=pointer-sign -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=sign-compare -Wno-error=unused-parameter -Wno-error=missing-field-initializers
+ USE_OPT = -c -Wall -O0 -ggdb -g3
+endif
+
+# C specific options here (added to USE_OPT).
+ifeq ($(USE_COPT),)
+ USE_COPT = -std=gnu99 -fgnu89-inline
+endif
+
+# C++ specific options here (added to USE_OPT).
+ifeq ($(USE_CPPOPT),)
+ USE_CPPOPT = -fno-rtti -fpermissive -fno-exceptions -fno-use-cxa-atexit
+endif
+
+# Enable this if you want the linker to remove unused code and data
+ifeq ($(USE_LINK_GC),)
+ USE_LINK_GC = yes
+endif
+
+# If enabled, this option allows to compile the application in THUMB mode.
+ifeq ($(USE_THUMB),)
+ USE_THUMB = no
+endif
+
+# Enable this if you want to see the full log while compiling.
+ifeq ($(USE_VERBOSE_COMPILE),)
+ USE_VERBOSE_COMPILE = no
+endif
+
+#
+# Build global options
+##############################################################################
+
+##############################################################################
+# Architecture or project specific options
+#
+
+
+# List all default C defines here, like -D_DEBUG=1
+DDEFS =
+
+#
+# Architecture or project specific options
+##############################################################################
+
+##############################################################################
+# Project, sources and paths
+#
+
+# Define project name here
+PROJECT = rusefi_test
+
+#PROJECT_BOARD = OLIMEX_STM32_E407
+#ifneq ($(PROJECT_BOARD),OLIMEX_STM32_E407)
+# PROJECT_BOARD = ST_STM32F4_DISCOVERY
+#endif
+#DDEFS += -D$(PROJECT_BOARD)
+
+# Imported source files and paths
+include $(PROJECT_DIR)/util/util.mk
+include $(PROJECT_DIR)/config/engines/engines.mk
+include $(PROJECT_DIR)/controllers/algo/algo.mk
+include $(PROJECT_DIR)/controllers/math/math.mk
+include $(PROJECT_DIR)/controllers/sensors/sensors.mk
+include test.mk
+
+# Define linker script file here
+#LDSCRIPT= config/system/STM32F407xG.ld
+#LDSCRIPT= $(PORTLD)/STM32F407xG_CCM.ld
+
+# C sources that can be compiled in ARM or THUMB mode depending on the global
+# setting.
+CSRC = $(UTILSRC) \
+ $(CONTROLLERS_ALGO_SRC) \
+ $(CONTROLLERS_MATH_SRC) \
+ $(CONTROLLERS_SENSORS_SRC) \
+ $(ENGINES_SRC) \
+ $(PROJECT_DIR)/controllers/trigger/trigger_mazda.c \
+ $(PROJECT_DIR)/controllers/trigger/trigger_structure.c \
+ $(TEST_SRC_C)
+
+# C++ sources that can be compiled in ARM or THUMB mode depending on the global
+# setting.
+CPPSRC = $(UTILSRC_CPP) \
+ $(CONTROLLERS_ALGO_SRC_CPP) \
+ $(PROJECT_DIR)/controllers/trigger/trigger_chrysler.cpp \
+ $(PROJECT_DIR)/controllers/trigger/trigger_gm.cpp \
+ $(PROJECT_DIR)/controllers/trigger/trigger_decoder.cpp \
+ $(ENGINES_SRC_CPP) \
+ $(CONTROLLERS_MATH_SRC_CPP) \
+ $(TEST_SRC_CPP) \
+ main.cpp
+
+# C sources to be compiled in ARM mode regardless of the global setting.
+# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
+# option that results in lower performance and larger code size.
+ACSRC =
+
+# C++ sources to be compiled in ARM mode regardless of the global setting.
+# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
+# option that results in lower performance and larger code size.
+ACPPSRC =
+
+# C sources to be compiled in THUMB mode regardless of the global setting.
+# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
+# option that results in lower performance and larger code size.
+TCSRC =
+
+# C sources to be compiled in THUMB mode regardless of the global setting.
+# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
+# option that results in lower performance and larger code size.
+TCPPSRC =
+
+# List ASM source files here
+ASMSRC = $(PORTASM)
+
+INCDIR = . \
+ $(PROJECT_DIR)/util \
+ $(PROJECT_DIR)/config/engines \
+ $(PROJECT_DIR)/controllers/sensors \
+ $(PROJECT_DIR)/controllers/algo \
+ $(PROJECT_DIR)/controllers/math \
+ $(PROJECT_DIR)/controllers/trigger \
+ $(PROJECT_DIR)/ext_algo \
+ test_data_structures \
+ test_basic_math
+
+
+#
+# Project, sources and paths
+##############################################################################
+
+##############################################################################
+# Compiler settings
+#
+
+#MCU = cortex-m4
+
+ifeq ($(OS),Windows_NT)
+ TRGT = i686-pc-mingw32-
+else
+ TRGT =
+endif
+
+CC = $(TRGT)gcc
+CPPC = $(TRGT)g++
+# Enable loading with g++ only if you need C++ runtime support.
+# NOTE: You can use C++ even without C++ support if you are careful. C++
+# runtime support makes code size explode.
+#LD = $(TRGT)gcc
+LD = $(TRGT)g++
+CP = $(TRGT)objcopy
+AS = $(TRGT)gcc -x assembler-with-cpp
+OD = $(TRGT)objdump
+HEX = $(CP) -O ihex
+BIN = $(CP) -O binary
+
+# ARM-specific options here
+AOPT =
+
+# THUMB-specific options here
+TOPT = -mthumb -DTHUMB
+
+# Define C warning options here
+CWARN = -Wall -Wextra -Wstrict-prototypes
+
+# Define C++ warning options here
+CPPWARN = -Wall -Wextra
+
+#
+# Compiler settings
+##############################################################################
+
+##############################################################################
+# Start of default section
+#
+
+# List all default ASM defines here, like -D_DEBUG=1
+DADEFS =
+
+# List all default directories to look for include files here
+DINCDIR =
+
+# List the default directory to look for the libraries here
+DLIBDIR =
+
+# List all default libraries here
+DLIBS = -static-libgcc -static-libstdc++
+
+#
+# End of default section
+##############################################################################
+
+##############################################################################
+# Start of user section
+#
+
+# List all user C define here, like -D_DEBUG=1
+UDEFS =
+
+# Define ASM defines here
+UADEFS =
+
+# List all user directories here
+UINCDIR =
+
+# List the user directory to look for the libraries here
+ULIBDIR =
+
+# List all user libraries here
+ULIBS = -lm
+
+#
+# End of user defines
+##############################################################################
+
+include rules.mk
diff --git a/unit_tests/adc_inputs.h b/unit_tests/adc_inputs.h
index 5c526173a7..5d6dca110b 100644
--- a/unit_tests/adc_inputs.h
+++ b/unit_tests/adc_inputs.h
@@ -1,11 +1,11 @@
-/**
- * @file adc_inputs.h
- *
- * @date Dec 7, 2013
- * @author Andrey Belomutskiy, (c) 2012-2013
- */
-
-#ifndef ADC_INPUTS_H_
-#define ADC_INPUTS_H_
-
-#endif /* ADC_INPUTS_H_ */
+/**
+ * @file adc_inputs.h
+ *
+ * @date Dec 7, 2013
+ * @author Andrey Belomutskiy, (c) 2012-2013
+ */
+
+#ifndef ADC_INPUTS_H_
+#define ADC_INPUTS_H_
+
+#endif /* ADC_INPUTS_H_ */
diff --git a/unit_tests/boards.c b/unit_tests/boards.c
index 5755c03f80..1b1a9651eb 100644
--- a/unit_tests/boards.c
+++ b/unit_tests/boards.c
@@ -1,23 +1,22 @@
-/**
- * @file board.c
- *
- * @date Nov 15, 2013
- * @author Andrey Belomutskiy, (c) 2012-2013
- */
-
-#include "boards.h"
-
-float getVoltageDivided(int channel) {
- return 0;
-}
-
-float getVoltage(int channel) {
- return 0;
-}
-
-
-int getAdcValue(int channel) {
- return 0;
-}
-
-
+/**
+ * @file board.c
+ *
+ * @date Nov 15, 2013
+ * @author Andrey Belomutskiy, (c) 2012-2013
+ */
+
+#include "boards.h"
+
+float getVoltageDivided(int channel) {
+ return 0;
+}
+
+float getVoltage(int channel) {
+ return 0;
+}
+
+int getAdcValue(int channel) {
+ return 0;
+}
+
+
diff --git a/unit_tests/boards.h b/unit_tests/boards.h
index bbcf9f6256..8a162b459f 100644
--- a/unit_tests/boards.h
+++ b/unit_tests/boards.h
@@ -1,24 +1,24 @@
-/*
- * boards.h
- *
- * Created on: Nov 15, 2013
- * Author: Andrey Belomutskiy, (c) 2012-2013
- */
-
-#ifndef BOARDS_H_
-#define BOARDS_H_
-
-#define ADC_LOGIC_TPS 0
-#define ADC_LOGIC_AFR 0
-#define ADC_LOGIC_MAF 0
-#define ADC_LOGIC_MAP 0
-#define ADC_CHANNEL_VREF 0
-#define ADC_CHANNEL_VBATT 0
-#define ADC_LOGIC_INTAKE_AIR 0
-#define ADC_LOGIC_COOLANT 0
-
-float getVoltageDivided(int);
-float getVoltage(int channel);
-int getAdcValue(int channel);
-
-#endif /* BOARDS_H_ */
+/*
+ * boards.h
+ *
+ * Created on: Nov 15, 2013
+ * Author: Andrey Belomutskiy, (c) 2012-2013
+ */
+
+#ifndef BOARDS_H_
+#define BOARDS_H_
+
+#define ADC_LOGIC_TPS 0
+#define ADC_LOGIC_AFR 0
+#define ADC_LOGIC_MAF 0
+#define ADC_LOGIC_MAP 0
+#define ADC_CHANNEL_VREF 0
+#define ADC_CHANNEL_VBATT 0
+#define ADC_LOGIC_INTAKE_AIR 0
+#define ADC_LOGIC_COOLANT 0
+
+float getVoltageDivided(int);
+float getVoltage(int channel);
+int getAdcValue(int channel);
+
+#endif /* BOARDS_H_ */
diff --git a/unit_tests/compile.bat b/unit_tests/compile.bat
index 1c9d2c2e35..5d15e43e5b 100644
--- a/unit_tests/compile.bat
+++ b/unit_tests/compile.bat
@@ -1,3 +1,3 @@
-rm -rf .dep/
-rm -rf build/
-make
+rm -rf .dep/
+rm -rf build/
+make
diff --git a/unit_tests/efifeatures.h b/unit_tests/efifeatures.h
index 8845e51ac7..5827283bd1 100644
--- a/unit_tests/efifeatures.h
+++ b/unit_tests/efifeatures.h
@@ -1,13 +1,20 @@
-/*
- * efifeatures.h
- *
- * Created on: Mar 7, 2014
- * Author: Andrey
- */
-
-#ifndef EFIFEATURES_H_
-#define EFIFEATURES_H_
-
-#define EFI_CLI_SUPPORT FALSE
-
-#endif /* EFIFEATURES_H_ */
+/*
+ * efifeatures.h
+ *
+ * Created on: Mar 7, 2014
+ * Author: Andrey
+ */
+
+#ifndef EFIFEATURES_H_
+#define EFIFEATURES_H_
+
+#define EFI_CLI_SUPPORT FALSE
+
+#define EFI_SUPPORT_FORD_ASPIRE TRUE
+#define EFI_SUPPORT_DODGE_NEON TRUE
+#define EFI_SUPPORT_1995_FORD_INLINE_6 TRUE
+#define EFI_SUPPORT_FORD_FIESTA TRUE
+#define EFI_SUPPORT_NISSAN_PRIMERA TRUE
+
+
+#endif /* EFIFEATURES_H_ */
diff --git a/unit_tests/global.h b/unit_tests/global.h
index fd7f9e766f..8cf7b254cf 100644
--- a/unit_tests/global.h
+++ b/unit_tests/global.h
@@ -1,23 +1,19 @@
-/*
- * @file global.h
- *
- * @date Nov 28, 2013
- * @author pc
- */
-
-#ifndef GLOBAL_H_
-#define GLOBAL_H_
-
-#include
-#include
-
-#define EFI_SUPPORT_FORD_ASPIRE TRUE
-#define EFI_SUPPORT_DODGE_NEON TRUE
-#define EFI_SUPPORT_1995_FORD_INLINE_6 TRUE
-#define EFI_SUPPORT_FORD_FIESTA TRUE
-#define EFI_SUPPORT_NISSAN_PRIMERA TRUE
-
-#define TRUE 1
-#define FALSE 0
-
-#endif /* GLOBAL_H_ */
+/*
+ * @file global.h
+ *
+ * @date Nov 28, 2013
+ * @author pc
+ */
+
+#ifndef GLOBAL_H_
+#define GLOBAL_H_
+
+#include
+#include
+
+#include "efitime.h"
+
+#define TRUE 1
+#define FALSE 0
+
+#endif /* GLOBAL_H_ */
diff --git a/unit_tests/jenkins.sh b/unit_tests/jenkins.sh
index 67df86f044..0154067250 100644
--- a/unit_tests/jenkins.sh
+++ b/unit_tests/jenkins.sh
@@ -1,40 +1,40 @@
-#!/bin/bash
- echo "The PATH is ${PATH}"
- cd "${WORKSPACE}"
- echo "start in workspace ${PWD}"
-
- cd firmware
- echo "CD to ${PWD}"
-
- rm -fR .dep
- rm -fR build
- make
-
- if [ ! -f build/rusefi.hex ]; then
- echo "Firmware compilation failed"
- exit -1
- fi
-
- cd "${WORKSPACE}/win32_algo_tests"
- echo "CD to ${PWD}"
-
- rm -fR .dep
- rm -fR build
- make
- if [ ! -f build/rusefi_test ]; then
- echo "test compilation failed"
- exit -1
- fi
-
-# we want to terminate if test fails
-set -e
-
- # invoke the tests - hopefully error code would be propagated?
- build/rusefi_test
-
-cd "${WORKSPACE}/java_console"
-echo "CD to ${PWD}"
-
-#JAVA_HOME=/usr/lib/jvm/java-6-openjdk-amd64
-#ant
-
+#!/bin/bash
+ echo "The PATH is ${PATH}"
+ cd "${WORKSPACE}"
+ echo "start in workspace ${PWD}"
+
+ cd firmware
+ echo "CD to ${PWD}"
+
+ rm -fR .dep
+ rm -fR build
+ make
+
+ if [ ! -f build/rusefi.hex ]; then
+ echo "Firmware compilation failed"
+ exit -1
+ fi
+
+ cd "${WORKSPACE}/win32_algo_tests"
+ echo "CD to ${PWD}"
+
+ rm -fR .dep
+ rm -fR build
+ make
+ if [ ! -f build/rusefi_test ]; then
+ echo "test compilation failed"
+ exit -1
+ fi
+
+# we want to terminate if test fails
+set -e
+
+ # invoke the tests - hopefully error code would be propagated?
+ build/rusefi_test
+
+cd "${WORKSPACE}/java_console"
+echo "CD to ${PWD}"
+
+#JAVA_HOME=/usr/lib/jvm/java-6-openjdk-amd64
+#ant
+
diff --git a/unit_tests/main.cpp b/unit_tests/main.cpp
index 3335c4cd69..cfb61a912d 100644
--- a/unit_tests/main.cpp
+++ b/unit_tests/main.cpp
@@ -13,6 +13,7 @@
#include
#include "main.h"
+#include "error_handling.h"
extern "C"
{
@@ -28,10 +29,10 @@ extern "C"
#include "test_signal_executor.h"
#include "test_util.h"
#include "engine_configuration.h"
-#include "test_trigger_decoder.h"
-
+#include "engine_math.h"
}
+#include "test_trigger_decoder.h"
static engine_configuration_s ec;
engine_configuration_s *engineConfiguration = &ec;
@@ -40,8 +41,12 @@ static float absF(float value) {
return value > 0 ? value : -value;
}
+uint64_t getTimeNowUs(void) {
+ return 0;
+}
+
void assertEqualsM(char *msg, float expected, float actual) {
- if (isnan(actual) && !isnan(expected)) {
+ if (cisnan(actual) && !cisnan(expected)) {
printf("Unexpected: %s %.4f while expected %.4f\r\n", msg, actual, expected);
exit(-1);
}
@@ -86,6 +91,7 @@ static engine_configuration2_s ec2;
engine_configuration2_s *engineConfiguration2 = &ec2;
int main(void) {
+ testOverflow64Counter();
testInterpolate3d();
testFindIndex();
testInterpolate2d();
@@ -111,15 +117,16 @@ int main(void) {
testPinHelper();
testSetTableValue();
- printf("Success 20130319\r\n");
+ printf("Success 20130422\r\n");
// resizeMap();
return EXIT_SUCCESS;
}
-void warning(char *msg, float value) {
- printf("Warning: %s %f\r\n", msg, value);
+
+int warning(obd_code_e code, const char *fmt, ...) {
+ printf("Warning: %s\r\n", fmt);
}
void firmwareError(const char *fmt, ...) {
diff --git a/unit_tests/main.h b/unit_tests/main.h
index 23f1765c86..e605c6e613 100644
--- a/unit_tests/main.h
+++ b/unit_tests/main.h
@@ -1,58 +1,62 @@
-/**
- * @file main.h
- * @brief Test version of main.h
- *
- * Created on: Oct 17, 2013
- * Author: Andrey Belomutskiy (C) 2012-2013
- */
-
-#ifndef MAIN_H_
-#define MAIN_H_
-
-#include
-#include
-#include "error_handling.h"
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-#include "efilib.h"
-
-#include "global.h"
-#include "boards.h"
-#include "engines.h"
-
-typedef int bool_t;
-
-void chDbgAssert(int c, char *msg, void *arg);
-
-void print(const char *fmt, ...);
-
-#define TICKS_IN_MS 100
-
-#define DEBUG_INTERPOLATION 1
-
-#define chDbgCheck(x, y) chDbgAssert(x, y, NULL)
-
-void assertEqualsM(char *msg, float expected, float actual);
-void assertEquals(float expected, float actual);
-void assertTrue(float actual);
-void assertTrueM(char *msg, float actual);
-void assertFalse(float actual);
-void assertFalseM(char *msg, float actual);
-
-float getIntakeAirTemperature(void);
-float getCoolantTemperature(void);
-float getVBatt(void);
-float getMaf(void);
-
-#define systicks2ms(x) (0)
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif /* MAIN_H_ */
+/**
+ * @file main.h
+ * @brief Test version of main.h
+ *
+ * Created on: Oct 17, 2013
+ * Author: Andrey Belomutskiy (C) 2012-2013
+ */
+
+#ifndef MAIN_H_
+#define MAIN_H_
+
+#include
+#include
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#define CH_FREQUENCY 1000
+
+#include "global.h"
+#include "error_handling.h"
+
+#include "efilib.h"
+#include "efitime.h"
+
+#include "boards.h"
+#include "engines.h"
+
+typedef int bool_t;
+
+void chDbgAssert(int c, char *msg, void *arg);
+
+void print(const char *fmt, ...);
+
+#define TICKS_IN_MS 100
+
+#define DEBUG_INTERPOLATION 1
+
+#define chDbgCheck(x, y) chDbgAssert(x, y, NULL)
+
+void assertEqualsM(char *msg, float expected, float actual);
+void assertEquals(float expected, float actual);
+void assertTrue(float actual);
+void assertTrueM(char *msg, float actual);
+void assertFalse(float actual);
+void assertFalseM(char *msg, float actual);
+
+float getIntakeAirTemperature(void);
+float getCoolantTemperature(void);
+float getVBatt(void);
+float getMaf(void);
+
+#define systicks2ms(x) (0)
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* MAIN_H_ */
diff --git a/unit_tests/makelinks.bat b/unit_tests/makelinks.bat
index a700673682..95cde49cba 100644
--- a/unit_tests/makelinks.bat
+++ b/unit_tests/makelinks.bat
@@ -1,8 +1,9 @@
-
-junction controllers_algo ..\firmware\controllers\algo
-junction controllers_math ..\firmware\controllers\math
-junction engines ..\firmware\config\engines
-junction controllers_sensors ..\firmware\controllers\sensors
-junction util ..\firmware\util
-junction ext_algo ..\firmware\ext_algo
-
+
+junction controllers_algo ..\firmware\controllers\algo
+junction controllers_math ..\firmware\controllers\math
+junction controllers_trigger ..\firmware\controllers\trigger
+junction engines ..\firmware\config\engines
+junction controllers_sensors ..\firmware\controllers\sensors
+junction util ..\firmware\util
+junction ext_algo ..\firmware\ext_algo
+
diff --git a/unit_tests/map_resize.c b/unit_tests/map_resize.c
index 44b7f5a6e7..cc876a1020 100644
--- a/unit_tests/map_resize.c
+++ b/unit_tests/map_resize.c
@@ -1,176 +1,176 @@
-/**
- * @file map_resize.c
- *
- * @date Jan 12, 2014
- * @author Andrey Belomutskiy, (c) 2012-2013
- */
-
-#include
-#include "fuel_math.h"
-#include "interpolation.h"
-#include "engines.h"
-#include "engine_configuration.h"
-#include "main.h"
-#include "idle_controller.h"
-
-#if 1
-
-#define AD_LOAD_COUNT 16
-#define AD_RPM_COUNT 16
-
-
-static float ad_rpm_table[] = {/*0*/ 800.000000,
- /*1*/ 1213.333374,
- /*2*/ 1626.666748,
- /*3*/ 2040.000000,
- /*4*/ 2453.333496,
- /*5*/ 2866.666748,
- /*6*/ 3280.000000,
- /*7*/ 3693.333496,
- /*8*/ 4106.666992,
- /*9*/ 4520.000000,
- /*10*/ 4933.333496,
- /*11*/ 5346.666992,
- /*12*/ 5760.000000,
- /*13*/ 6173.333496,
- /*14*/ 6586.666992,
- /*15*/ 7000.000000,
- };;
-
-static float ad_maf_table[] =
-{/*0*/ 1.200000,
-/*1*/ 1.413333,
-/*2*/ 1.626667,
-/*3*/ 1.840000,
-/*4*/ 2.053333,
-/*5*/ 2.266667,
-/*6*/ 2.480000,
-/*7*/ 2.693333,
-/*8*/ 2.906667,
-/*9*/ 3.120000,
-/*10*/ 3.333333,
-/*11*/ 3.546667,
-/*12*/ 3.760000,
-/*13*/ 3.973333,
-/*14*/ 4.186667,
-/*15*/ 4.400000,
-};
-
-static float ad_table[AD_LOAD_COUNT][AD_RPM_COUNT] = {
- /* RPM 800.000000 1213.333374 1626.666748 2040.000000 2453.333496 2866.666748 3280.000000 3693.333496 4106.666992 4520.000000 4933.333496 5346.666992 5760.000000 6173.333496 6586.666992 7000.000000*/
- /* Load 1.200000 */{ 0.662000, -7.730000, -16.722000, -23.139999, -29.398001, -31.268000, -32.108002, -30.436001, -30.896000, -26.656000, -24.704000, -25.108000, -25.132000, -25.459999, -25.459999, -25.459999},
- /* Load 1.413333 */{ 0.546000, -7.662000, -16.882000, -23.482000, -29.520000, -31.323999, -32.108002, -30.656000, -30.468000, -26.879999, -24.746000, -24.742001, -29.032000, -25.562000, -25.562000, -25.562000},
- /* Load 1.626667 */{ 0.584000, -7.870000, -16.714001, -23.025999, -29.542000, -31.166000, -32.175999, -30.540001, -30.268000, -26.416000, -24.134001, -25.007999, -24.698000, -26.167999, -26.167999, -26.167999},
- /* Load 1.840000 */{ 0.584000, -7.658000, -16.714001, -23.254000, -29.351999, -30.978001, -32.141998, -30.874001, -30.896000, -26.507999, -24.558001, -24.389999, -25.761999, -35.492001, -35.492001, -35.492001},
- /* Load 2.053333 */{ 0.584000, -7.862000, -16.538000, -23.254000, -29.232000, -31.296000, -32.520000, -30.142000, -30.388000, -25.903999, -24.370001, -24.082001, -24.792000, -24.351999, -24.351999, -24.351999},
- /* Load 2.266667 */{ -1.364000, -7.726000, -16.806000, -23.254000, -29.639999, -31.006001, -32.298000, -30.912001, -29.882000, -26.392000, -24.664000, -27.233999, -25.374001, -25.417999, -25.417999, -25.417999},
- /* Load 2.480000 */{ 1.364000, -10.490000, -16.705999, -22.441999, -28.101999, -30.238001, -32.363998, -30.719999, -30.896000, -26.608000, -24.664000, -24.431999, -24.500000, -25.510000, -25.510000, -25.510000},
- /* Load 2.693333 */{ 9.864000, -10.416000, -11.680000, -19.150000, -25.754000, -27.936001, -32.554001, -30.656000, -30.153999, -27.184000, -25.252001, -22.812000, -24.452000, -25.219999, -25.219999, -25.219999},
- /* Load 2.906667 */{ 9.866000, 5.452000, 2.854000, -17.212000, -17.552000, -20.688000, -25.660000, -27.809999, -27.691999, -27.224001, -25.882000, -25.360001, -26.100000, -27.992001, -27.992001, -27.992001},
- /* Load 3.120000 */{ 9.864000, 5.452000, 2.854000, -0.342000, -12.526000, -16.218000, -21.364000, -27.590000, -25.780001, -24.170000, -24.664000, -25.584000, -26.490000, -31.968000, -31.968000, -31.968000},
- /* Load 3.333333 */{ 9.864000, 5.516000, 2.854000, -0.226000, -2.738000, -3.816000, -11.924000, -18.808001, -21.038000, -21.538000, -21.209999, -22.228001, -25.046000, -25.156000, -25.156000, -25.156000},
- /* Load 3.546667 */{ 9.866000, 5.518000, 2.854000, 0.000000, -3.022000, -3.816000, -6.428000, -7.788000, -19.426001, -20.860001, -19.966000, -21.030001, -21.396000, -21.570000, -21.570000, -21.570000},
- /* Load 3.760000 */{ 9.864000, 5.516000, 2.772000, -0.226000, -2.732000, -3.500000, -6.798000, -8.102000, -8.660000, -9.500000, -11.788000, -20.132000, -20.072001, -20.510000, -20.510000, -20.510000},
- /* Load 3.973333 */{ 9.864000, 5.518000, 2.854000, 0.000000, -2.880000, -3.816000, -6.420000, -8.320000, -8.426000, -8.532000, -11.470000, -11.442000, -13.610000, -12.022000, -12.022000, -12.022000},
- /* Load 4.186667 */{ 9.750000, 5.518000, 2.604000, 0.000000, -2.880000, -3.654000, -6.050000, -6.888000, -8.372000, -9.364000, -11.764000, -11.732000, -11.864000, -12.376000, -12.376000, -12.376000},
- /* Load 4.400000 */{ 0.350000, 5.590000, 0.502000, 0.910000, 0.864000, 0.954000, 1.324000, -7.436000, 1.170000, 1.054000, 2.058000, 2.098000, 2.636000, -12.352000, -12.352000, -12.352000}
- };
-
-//float getBaseAdvance(int rpm, float key) {
-// // todo: use interpolation
-// int rpm_index = findIndex(ad_rpm_table, AD_RPM_COUNT, rpm);
-// rpm_index = max(rpm_index, 0);
-// int maf_index = findIndex(ad_maf_table, AD_LOAD_COUNT, key);
-// maf_index = max(maf_index, 0);
-//
-// return ad_table[rpm_index][maf_index];
-//}
-
-
-
-#define newRpmSize 16
-#define newKeySize 16
-
-static float newRpmBin[newRpmSize];
-static float newKeyBin[newKeySize];
-
-//static float *fuel_ptrs[FUEL_LOAD_COUNT];
-
-//EngineConfiguration *engineConfiguration;
-
-extern int needInterpolationLogging;
-
-void resizeMap(void) {
-// float keyMin = 1.2;
-// float keyMax = 4.4;
-//
-// float rpmMin = 800;
-// float rpmMax = 7000;
-
-// for (int k = 0; k < FUEL_LOAD_COUNT; k++)
-// fuel_ptrs[k] = engineConfiguration->fuelTable[k];
-
-// for (int i = 0; i < FUEL_MAF_COUNT; i++)
-// engineConfiguration->fuelKeyBins[i] = default_fuel_maf_bins[i];
-// for (int i = 0; i < FUEL_RPM_COUNT; i++)
-// engineConfiguration->fuelRpmBins[i] = default_fuel_rpm_bins[i];
-// for (int k = 0; k < FUEL_MAF_COUNT; k++) {
-// for (int r = 0; r < FUEL_RPM_COUNT; r++) {
-// // todo: this is BAD, this needs to be fixed - TS table indexes are different from default indexes
-// engineConfiguration->fuelTable[k][r] = default_fuel_table[r][k];
-// }
-// }
-
-// assertEquals(15, interpolate3d(1.2, engineConfiguration->fuelKeyBins, FUEL_MAF_COUNT, 8000,
-// engineConfiguration->fuelRpmBins,
-// FUEL_RPM_COUNT, fuel_ptrs));
-
- needInterpolationLogging = 0;
-
-// printf("static float ad_maf_table[AD_LOAD_COUNT] = {");
-// for (int i = 0; i < newKeySize; i++) {
-// newKeyBin[i] = interpolate(0, keyMin, newKeySize - 1, keyMax, i);
-// printf("/*%d*/ %f,\r\n", i, newKeyBin[i]);
-// }
-// printf("};\r\n");
-//
-// printf("static float ad_rpm_table[AD_RPM_COUNT] = {");
-// for (int i = 0; i < newRpmSize; i++) {
-// newRpmBin[i] = interpolate(0, rpmMin, newRpmSize - 1, rpmMax, i);
-// printf("/*%d*/ %f,\r\n", i, newRpmBin[i]);
-// }
-// printf("};\r\n");
-
- printf("static float ad_table[AD_RPM_COUNT][AD_LOAD_COUNT] = {\r\n");
-
- printf("/* RPM\t\t");
- for (int r = 0; r < newRpmSize; r++) {
- float rpm = newRpmBin[r];
- printf("\t%f", rpm);
- }
- printf("*/\r\n");
-
- for (int k = 0; k < newKeySize; k++) {
- float load = newKeyBin[k];
- printf("/* Load %f */{", load);
-
- for (int r = 0; r < newRpmSize; r++) {
- float rpm = newRpmBin[r];
-
- float v = ad_table[k][r];
-
- printf("\t%f", v);
- if (r != newRpmSize - 1)
- printf(",");
-
- }
- printf("}");
- if (k != newKeySize - 1)
- printf(",");
- printf("\r\n");
- }
- printf("};\r\n");
-
-}
-
-#endif
+/**
+ * @file map_resize.c
+ *
+ * @date Jan 12, 2014
+ * @author Andrey Belomutskiy, (c) 2012-2013
+ */
+
+#include
+#include "fuel_math.h"
+#include "interpolation.h"
+#include "engines.h"
+#include "engine_configuration.h"
+#include "main.h"
+#include "idle_controller.h"
+
+#if 1
+
+#define AD_LOAD_COUNT 16
+#define AD_RPM_COUNT 16
+
+
+static float ad_rpm_table[] = {/*0*/ 800.000000,
+ /*1*/ 1213.333374,
+ /*2*/ 1626.666748,
+ /*3*/ 2040.000000,
+ /*4*/ 2453.333496,
+ /*5*/ 2866.666748,
+ /*6*/ 3280.000000,
+ /*7*/ 3693.333496,
+ /*8*/ 4106.666992,
+ /*9*/ 4520.000000,
+ /*10*/ 4933.333496,
+ /*11*/ 5346.666992,
+ /*12*/ 5760.000000,
+ /*13*/ 6173.333496,
+ /*14*/ 6586.666992,
+ /*15*/ 7000.000000,
+ };;
+
+static float ad_maf_table[] =
+{/*0*/ 1.200000,
+/*1*/ 1.413333,
+/*2*/ 1.626667,
+/*3*/ 1.840000,
+/*4*/ 2.053333,
+/*5*/ 2.266667,
+/*6*/ 2.480000,
+/*7*/ 2.693333,
+/*8*/ 2.906667,
+/*9*/ 3.120000,
+/*10*/ 3.333333,
+/*11*/ 3.546667,
+/*12*/ 3.760000,
+/*13*/ 3.973333,
+/*14*/ 4.186667,
+/*15*/ 4.400000,
+};
+
+static float ad_table[AD_LOAD_COUNT][AD_RPM_COUNT] = {
+ /* RPM 800.000000 1213.333374 1626.666748 2040.000000 2453.333496 2866.666748 3280.000000 3693.333496 4106.666992 4520.000000 4933.333496 5346.666992 5760.000000 6173.333496 6586.666992 7000.000000*/
+ /* Load 1.200000 */{ 0.662000, -7.730000, -16.722000, -23.139999, -29.398001, -31.268000, -32.108002, -30.436001, -30.896000, -26.656000, -24.704000, -25.108000, -25.132000, -25.459999, -25.459999, -25.459999},
+ /* Load 1.413333 */{ 0.546000, -7.662000, -16.882000, -23.482000, -29.520000, -31.323999, -32.108002, -30.656000, -30.468000, -26.879999, -24.746000, -24.742001, -29.032000, -25.562000, -25.562000, -25.562000},
+ /* Load 1.626667 */{ 0.584000, -7.870000, -16.714001, -23.025999, -29.542000, -31.166000, -32.175999, -30.540001, -30.268000, -26.416000, -24.134001, -25.007999, -24.698000, -26.167999, -26.167999, -26.167999},
+ /* Load 1.840000 */{ 0.584000, -7.658000, -16.714001, -23.254000, -29.351999, -30.978001, -32.141998, -30.874001, -30.896000, -26.507999, -24.558001, -24.389999, -25.761999, -35.492001, -35.492001, -35.492001},
+ /* Load 2.053333 */{ 0.584000, -7.862000, -16.538000, -23.254000, -29.232000, -31.296000, -32.520000, -30.142000, -30.388000, -25.903999, -24.370001, -24.082001, -24.792000, -24.351999, -24.351999, -24.351999},
+ /* Load 2.266667 */{ -1.364000, -7.726000, -16.806000, -23.254000, -29.639999, -31.006001, -32.298000, -30.912001, -29.882000, -26.392000, -24.664000, -27.233999, -25.374001, -25.417999, -25.417999, -25.417999},
+ /* Load 2.480000 */{ 1.364000, -10.490000, -16.705999, -22.441999, -28.101999, -30.238001, -32.363998, -30.719999, -30.896000, -26.608000, -24.664000, -24.431999, -24.500000, -25.510000, -25.510000, -25.510000},
+ /* Load 2.693333 */{ 9.864000, -10.416000, -11.680000, -19.150000, -25.754000, -27.936001, -32.554001, -30.656000, -30.153999, -27.184000, -25.252001, -22.812000, -24.452000, -25.219999, -25.219999, -25.219999},
+ /* Load 2.906667 */{ 9.866000, 5.452000, 2.854000, -17.212000, -17.552000, -20.688000, -25.660000, -27.809999, -27.691999, -27.224001, -25.882000, -25.360001, -26.100000, -27.992001, -27.992001, -27.992001},
+ /* Load 3.120000 */{ 9.864000, 5.452000, 2.854000, -0.342000, -12.526000, -16.218000, -21.364000, -27.590000, -25.780001, -24.170000, -24.664000, -25.584000, -26.490000, -31.968000, -31.968000, -31.968000},
+ /* Load 3.333333 */{ 9.864000, 5.516000, 2.854000, -0.226000, -2.738000, -3.816000, -11.924000, -18.808001, -21.038000, -21.538000, -21.209999, -22.228001, -25.046000, -25.156000, -25.156000, -25.156000},
+ /* Load 3.546667 */{ 9.866000, 5.518000, 2.854000, 0.000000, -3.022000, -3.816000, -6.428000, -7.788000, -19.426001, -20.860001, -19.966000, -21.030001, -21.396000, -21.570000, -21.570000, -21.570000},
+ /* Load 3.760000 */{ 9.864000, 5.516000, 2.772000, -0.226000, -2.732000, -3.500000, -6.798000, -8.102000, -8.660000, -9.500000, -11.788000, -20.132000, -20.072001, -20.510000, -20.510000, -20.510000},
+ /* Load 3.973333 */{ 9.864000, 5.518000, 2.854000, 0.000000, -2.880000, -3.816000, -6.420000, -8.320000, -8.426000, -8.532000, -11.470000, -11.442000, -13.610000, -12.022000, -12.022000, -12.022000},
+ /* Load 4.186667 */{ 9.750000, 5.518000, 2.604000, 0.000000, -2.880000, -3.654000, -6.050000, -6.888000, -8.372000, -9.364000, -11.764000, -11.732000, -11.864000, -12.376000, -12.376000, -12.376000},
+ /* Load 4.400000 */{ 0.350000, 5.590000, 0.502000, 0.910000, 0.864000, 0.954000, 1.324000, -7.436000, 1.170000, 1.054000, 2.058000, 2.098000, 2.636000, -12.352000, -12.352000, -12.352000}
+ };
+
+//float getBaseAdvance(int rpm, float key) {
+// // todo: use interpolation
+// int rpm_index = findIndex(ad_rpm_table, AD_RPM_COUNT, rpm);
+// rpm_index = max(rpm_index, 0);
+// int maf_index = findIndex(ad_maf_table, AD_LOAD_COUNT, key);
+// maf_index = max(maf_index, 0);
+//
+// return ad_table[rpm_index][maf_index];
+//}
+
+
+
+#define newRpmSize 16
+#define newKeySize 16
+
+static float newRpmBin[newRpmSize];
+static float newKeyBin[newKeySize];
+
+//static float *fuel_ptrs[FUEL_LOAD_COUNT];
+
+//EngineConfiguration *engineConfiguration;
+
+extern int needInterpolationLogging;
+
+void resizeMap(void) {
+// float keyMin = 1.2;
+// float keyMax = 4.4;
+//
+// float rpmMin = 800;
+// float rpmMax = 7000;
+
+// for (int k = 0; k < FUEL_LOAD_COUNT; k++)
+// fuel_ptrs[k] = engineConfiguration->fuelTable[k];
+
+// for (int i = 0; i < FUEL_MAF_COUNT; i++)
+// engineConfiguration->fuelKeyBins[i] = default_fuel_maf_bins[i];
+// for (int i = 0; i < FUEL_RPM_COUNT; i++)
+// engineConfiguration->fuelRpmBins[i] = default_fuel_rpm_bins[i];
+// for (int k = 0; k < FUEL_MAF_COUNT; k++) {
+// for (int r = 0; r < FUEL_RPM_COUNT; r++) {
+// // todo: this is BAD, this needs to be fixed - TS table indexes are different from default indexes
+// engineConfiguration->fuelTable[k][r] = default_fuel_table[r][k];
+// }
+// }
+
+// assertEquals(15, interpolate3d(1.2, engineConfiguration->fuelKeyBins, FUEL_MAF_COUNT, 8000,
+// engineConfiguration->fuelRpmBins,
+// FUEL_RPM_COUNT, fuel_ptrs));
+
+ needInterpolationLogging = 0;
+
+// printf("static float ad_maf_table[AD_LOAD_COUNT] = {");
+// for (int i = 0; i < newKeySize; i++) {
+// newKeyBin[i] = interpolate(0, keyMin, newKeySize - 1, keyMax, i);
+// printf("/*%d*/ %f,\r\n", i, newKeyBin[i]);
+// }
+// printf("};\r\n");
+//
+// printf("static float ad_rpm_table[AD_RPM_COUNT] = {");
+// for (int i = 0; i < newRpmSize; i++) {
+// newRpmBin[i] = interpolate(0, rpmMin, newRpmSize - 1, rpmMax, i);
+// printf("/*%d*/ %f,\r\n", i, newRpmBin[i]);
+// }
+// printf("};\r\n");
+
+ printf("static float ad_table[AD_RPM_COUNT][AD_LOAD_COUNT] = {\r\n");
+
+ printf("/* RPM\t\t");
+ for (int r = 0; r < newRpmSize; r++) {
+ float rpm = newRpmBin[r];
+ printf("\t%f", rpm);
+ }
+ printf("*/\r\n");
+
+ for (int k = 0; k < newKeySize; k++) {
+ float load = newKeyBin[k];
+ printf("/* Load %f */{", load);
+
+ for (int r = 0; r < newRpmSize; r++) {
+ float rpm = newRpmBin[r];
+
+ float v = ad_table[k][r];
+
+ printf("\t%f", v);
+ if (r != newRpmSize - 1)
+ printf(",");
+
+ }
+ printf("}");
+ if (k != newKeySize - 1)
+ printf(",");
+ printf("\r\n");
+ }
+ printf("};\r\n");
+
+}
+
+#endif
diff --git a/unit_tests/map_resize.h b/unit_tests/map_resize.h
index 3d105a434e..4157379c9e 100644
--- a/unit_tests/map_resize.h
+++ b/unit_tests/map_resize.h
@@ -1,13 +1,13 @@
-/**
- * @file map_resize.h
- *
- * @date Jan 12, 2014
- * @author Andrey Belomutskiy, (c) 2012-2013
- */
-
-#ifndef MAP_RESIZE_H_
-#define MAP_RESIZE_H_
-
-void resizeMap(void);
-
-#endif /* MAP_RESIZE_H_ */
+/**
+ * @file map_resize.h
+ *
+ * @date Jan 12, 2014
+ * @author Andrey Belomutskiy, (c) 2012-2013
+ */
+
+#ifndef MAP_RESIZE_H_
+#define MAP_RESIZE_H_
+
+void resizeMap(void);
+
+#endif /* MAP_RESIZE_H_ */
diff --git a/unit_tests/readme.txt b/unit_tests/readme.txt
index 621959dacd..d587160641 100644
--- a/unit_tests/readme.txt
+++ b/unit_tests/readme.txt
@@ -1,6 +1,6 @@
-In this folder we have a naive test set. I am not sure what is the best approach to tests in C (someone can educate me), but my approach is:
-
-1) with a symlink linking some (only some, not all) folders of the firmware implementation, we can compile some files of the firmware as win32 code.
-Please execute the 'makelinks.bat' file to get the links. On XP you might need to execute 'junction.exe' before exuting the .bat file.
-
+In this folder we have a naive test set. I am not sure what is the best approach to tests in C (someone can educate me), but my approach is:
+
+1) with a symlink linking some (only some, not all) folders of the firmware implementation, we can compile some files of the firmware as win32 code.
+Please execute the 'makelinks.bat' file to get the links. On XP you might need to execute 'junction.exe' before exuting the .bat file.
+
2) we then compile & run the .exe, which is expected to say SUCCESS and not fail :)
\ No newline at end of file
diff --git a/unit_tests/rules.mk b/unit_tests/rules.mk
index 5e93b3e311..c2a8b23a79 100644
--- a/unit_tests/rules.mk
+++ b/unit_tests/rules.mk
@@ -1,168 +1,168 @@
-# ARM Cortex-Mx common makefile scripts and rules.
-
-# Output directory and files
-ifeq ($(BUILDDIR),)
- BUILDDIR = build
-endif
-ifeq ($(BUILDDIR),.)
- BUILDDIR = build
-endif
-OUTFILES = $(BUILDDIR)/$(PROJECT)
-
-# Automatic compiler options
-OPT = $(USE_OPT)
-COPT = $(USE_COPT)
-CPPOPT = $(USE_CPPOPT)
-ifeq ($(USE_LINK_GC),yes)
- OPT += -ffunction-sections -fdata-sections -fno-common
-endif
-
-# Source files groups and paths
-ifeq ($(USE_THUMB),yes)
- TCSRC += $(CSRC)
- TCPPSRC += $(CPPSRC)
-else
- ACSRC += $(CSRC)
- ACPPSRC += $(CPPSRC)
-endif
-ASRC = $(ACSRC)$(ACPPSRC)
-TSRC = $(TCSRC)$(TCPPSRC)
-SRCPATHS = $(sort $(dir $(ASMXSRC)) $(dir $(ASMSRC)) $(dir $(ASRC)) $(dir $(TSRC)))
-
-# Various directories
-OBJDIR = $(BUILDDIR)/obj
-LSTDIR = $(BUILDDIR)/lst
-
-# Object files groups
-ACOBJS = $(addprefix $(OBJDIR)/, $(notdir $(ACSRC:.c=.o)))
-ACPPOBJS = $(addprefix $(OBJDIR)/, $(notdir $(ACPPSRC:.cpp=.o)))
-TCOBJS = $(addprefix $(OBJDIR)/, $(notdir $(TCSRC:.c=.o)))
-TCPPOBJS = $(addprefix $(OBJDIR)/, $(notdir $(TCPPSRC:.cpp=.o)))
-ASMOBJS = $(addprefix $(OBJDIR)/, $(notdir $(ASMSRC:.s=.o)))
-ASMXOBJS = $(addprefix $(OBJDIR)/, $(notdir $(ASMXSRC:.S=.o)))
-OBJS = $(ASMXOBJS) $(ASMOBJS) $(ACOBJS) $(TCOBJS) $(ACPPOBJS) $(TCPPOBJS)
-
-# Paths
-IINCDIR = $(patsubst %,-I%,$(INCDIR) $(DINCDIR) $(UINCDIR))
-LLIBDIR = $(patsubst %,-L%,$(DLIBDIR) $(ULIBDIR))
-
-# Macros
-DEFS = $(DDEFS) $(UDEFS)
-ADEFS = $(DADEFS) $(UADEFS)
-
-# Libs
-LIBS = $(DLIBS) $(ULIBS)
-
-# Various settings
-#MCFLAGS = -mcpu=$(MCU)
-ODFLAGS = -x --syms
-ASFLAGS = $(MCFLAGS) -Wa,-amhls=$(LSTDIR)/$(notdir $(<:.s=.lst)) $(ADEFS)
-ASXFLAGS = $(MCFLAGS) -Wa,-amhls=$(LSTDIR)/$(notdir $(<:.S=.lst)) $(ADEFS)
-CFLAGS = $(MCFLAGS) $(OPT) $(COPT) $(CWARN) -Wa,-alms=$(LSTDIR)/$(notdir $(<:.c=.lst)) $(DEFS)
-CPPFLAGS = $(MCFLAGS) $(OPT) $(CPPOPT) $(CPPWARN) -Wa,-alms=$(LSTDIR)/$(notdir $(<:.cpp=.lst)) $(DEFS)
-ifeq ($(USE_LINK_GC),yes)
- LDFLAGS = $(MCFLAGS) -Wl,-Map=$(BUILDDIR)/$(PROJECT).map,--cref,--no-warn-mismatch,--gc-sections $(LLIBDIR)
-else
- LDFLAGS = $(MCFLAGS) -Wl,-Map=$(BUILDDIR)/$(PROJECT).map,--cref,--no-warn-mismatch $(LLIBDIR)
-endif
-
-# Generate dependency information
-CFLAGS += -MD -MP -MF .dep/$(@F).d
-CPPFLAGS += -MD -MP -MF .dep/$(@F).d
-
-# Paths where to search for sources
-VPATH = $(SRCPATHS)
-
-#
-# Makefile rules
-#
-
-all: $(OBJS) $(OUTFILES) MAKE_ALL_RULE_HOOK
-
-MAKE_ALL_RULE_HOOK:
-
-$(OBJS): | $(BUILDDIR)
-
-$(BUILDDIR) $(OBJDIR) $(LSTDIR):
-ifneq ($(USE_VERBOSE_COMPILE),yes)
- @echo Compiler Options
- @echo $(CPPC) -c $(CPPFLAGS) -I. $(IINCDIR) main.cpp -o main.o
- @echo
-endif
- mkdir -p $(OBJDIR)
- mkdir -p $(LSTDIR)
-
-$(ACPPOBJS) : $(OBJDIR)/%.o : %.cpp Makefile
-ifeq ($(USE_VERBOSE_COMPILE),yes)
- @echo
- $(CPPC) -c $(CPPFLAGS) $(AOPT) -I. $(IINCDIR) $< -o $@
-else
- @echo Compiling $(/dev/null) $(wildcard .dep/*)
-
-# *** EOF ***
+# ARM Cortex-Mx common makefile scripts and rules.
+
+# Output directory and files
+ifeq ($(BUILDDIR),)
+ BUILDDIR = build
+endif
+ifeq ($(BUILDDIR),.)
+ BUILDDIR = build
+endif
+OUTFILES = $(BUILDDIR)/$(PROJECT)
+
+# Automatic compiler options
+OPT = $(USE_OPT)
+COPT = $(USE_COPT)
+CPPOPT = $(USE_CPPOPT)
+ifeq ($(USE_LINK_GC),yes)
+ OPT += -ffunction-sections -fdata-sections -fno-common
+endif
+
+# Source files groups and paths
+ifeq ($(USE_THUMB),yes)
+ TCSRC += $(CSRC)
+ TCPPSRC += $(CPPSRC)
+else
+ ACSRC += $(CSRC)
+ ACPPSRC += $(CPPSRC)
+endif
+ASRC = $(ACSRC)$(ACPPSRC)
+TSRC = $(TCSRC)$(TCPPSRC)
+SRCPATHS = $(sort $(dir $(ASMXSRC)) $(dir $(ASMSRC)) $(dir $(ASRC)) $(dir $(TSRC)))
+
+# Various directories
+OBJDIR = $(BUILDDIR)/obj
+LSTDIR = $(BUILDDIR)/lst
+
+# Object files groups
+ACOBJS = $(addprefix $(OBJDIR)/, $(notdir $(ACSRC:.c=.o)))
+ACPPOBJS = $(addprefix $(OBJDIR)/, $(notdir $(ACPPSRC:.cpp=.o)))
+TCOBJS = $(addprefix $(OBJDIR)/, $(notdir $(TCSRC:.c=.o)))
+TCPPOBJS = $(addprefix $(OBJDIR)/, $(notdir $(TCPPSRC:.cpp=.o)))
+ASMOBJS = $(addprefix $(OBJDIR)/, $(notdir $(ASMSRC:.s=.o)))
+ASMXOBJS = $(addprefix $(OBJDIR)/, $(notdir $(ASMXSRC:.S=.o)))
+OBJS = $(ASMXOBJS) $(ASMOBJS) $(ACOBJS) $(TCOBJS) $(ACPPOBJS) $(TCPPOBJS)
+
+# Paths
+IINCDIR = $(patsubst %,-I%,$(INCDIR) $(DINCDIR) $(UINCDIR))
+LLIBDIR = $(patsubst %,-L%,$(DLIBDIR) $(ULIBDIR))
+
+# Macros
+DEFS = $(DDEFS) $(UDEFS)
+ADEFS = $(DADEFS) $(UADEFS)
+
+# Libs
+LIBS = $(DLIBS) $(ULIBS)
+
+# Various settings
+#MCFLAGS = -mcpu=$(MCU)
+ODFLAGS = -x --syms
+ASFLAGS = $(MCFLAGS) -Wa,-amhls=$(LSTDIR)/$(notdir $(<:.s=.lst)) $(ADEFS)
+ASXFLAGS = $(MCFLAGS) -Wa,-amhls=$(LSTDIR)/$(notdir $(<:.S=.lst)) $(ADEFS)
+CFLAGS = $(MCFLAGS) $(OPT) $(COPT) $(CWARN) -Wa,-alms=$(LSTDIR)/$(notdir $(<:.c=.lst)) $(DEFS)
+CPPFLAGS = $(MCFLAGS) $(OPT) $(CPPOPT) $(CPPWARN) -Wa,-alms=$(LSTDIR)/$(notdir $(<:.cpp=.lst)) $(DEFS)
+ifeq ($(USE_LINK_GC),yes)
+ LDFLAGS = $(MCFLAGS) -Wl,-Map=$(BUILDDIR)/$(PROJECT).map,--cref,--no-warn-mismatch,--gc-sections $(LLIBDIR)
+else
+ LDFLAGS = $(MCFLAGS) -Wl,-Map=$(BUILDDIR)/$(PROJECT).map,--cref,--no-warn-mismatch $(LLIBDIR)
+endif
+
+# Generate dependency information
+CFLAGS += -MD -MP -MF .dep/$(@F).d
+CPPFLAGS += -MD -MP -MF .dep/$(@F).d
+
+# Paths where to search for sources
+VPATH = $(SRCPATHS)
+
+#
+# Makefile rules
+#
+
+all: $(OBJS) $(OUTFILES) MAKE_ALL_RULE_HOOK
+
+MAKE_ALL_RULE_HOOK:
+
+$(OBJS): | $(BUILDDIR)
+
+$(BUILDDIR) $(OBJDIR) $(LSTDIR):
+ifneq ($(USE_VERBOSE_COMPILE),yes)
+ @echo Compiler Options
+ @echo $(CPPC) -c $(CPPFLAGS) -I. $(IINCDIR) main.cpp -o main.o
+ @echo
+endif
+ mkdir -p $(OBJDIR)
+ mkdir -p $(LSTDIR)
+
+$(ACPPOBJS) : $(OBJDIR)/%.o : %.cpp Makefile
+ifeq ($(USE_VERBOSE_COMPILE),yes)
+ @echo
+ $(CPPC) -c $(CPPFLAGS) $(AOPT) -I. $(IINCDIR) $< -o $@
+else
+ @echo Compiling $(/dev/null) $(wildcard .dep/*)
+
+# *** EOF ***
diff --git a/unit_tests/settings.h b/unit_tests/settings.h
index 31327e150e..208d4ebcf6 100644
--- a/unit_tests/settings.h
+++ b/unit_tests/settings.h
@@ -1,13 +1,13 @@
-/**
- * @file settings.h
- *
- * @date Feb 13, 2014
- * @author Andrey Belomutskiy, (c) 2012-2014
- */
-
-#ifndef SETTINGS_H_
-#define SETTINGS_H_
-
-
-
-#endif /* SETTINGS_H_ */
+/**
+ * @file settings.h
+ *
+ * @date Feb 13, 2014
+ * @author Andrey Belomutskiy, (c) 2012-2014
+ */
+
+#ifndef SETTINGS_H_
+#define SETTINGS_H_
+
+
+
+#endif /* SETTINGS_H_ */
diff --git a/unit_tests/test.mk b/unit_tests/test.mk
index 8929ffc1f6..e983a44c70 100644
--- a/unit_tests/test.mk
+++ b/unit_tests/test.mk
@@ -1,14 +1,15 @@
-TEST_SRC_C = boards.c \
- test_data_structures/test_engine_math.c \
- test_event_registry.c \
- test_basic_math/test_find_index.c \
- test_basic_math/test_interpolation_3d.c \
- test_fuel_map.c \
- test_idle_controller.c \
- test_trigger_decoder.c \
- test_sensors.c \
- test_signal_executor.c
-
-TEST_SRC_CPP = test_util.cpp
-
-
+TEST_SRC_C = boards.c \
+ test_data_structures/test_engine_math.c \
+ test_basic_math/test_find_index.c \
+ test_basic_math/test_interpolation_3d.c \
+ test_idle_controller.c \
+ test_sensors.c
+
+TEST_SRC_CPP = test_util.cpp \
+ test_data_structures/test_event_registry.cpp \
+ test_trigger_decoder.cpp \
+ test_fuel_map.cpp \
+ test_signal_executor.cpp
+
+
+
diff --git a/unit_tests/test_basic_math/test_find_index.c b/unit_tests/test_basic_math/test_find_index.c
index 47d34d851a..1785336c4b 100644
--- a/unit_tests/test_basic_math/test_find_index.c
+++ b/unit_tests/test_basic_math/test_find_index.c
@@ -1,120 +1,120 @@
-/*
- * test_find_index.c
- *
- * Created on: Oct 30, 2013
- * Author: Andrey Belomutskiy, (c) 2012-2013
- */
-
-#include "engine_math.h"
-#include "main.h"
-#include "interpolation.h"
-#include
-#include "engine_configuration.h"
-
-void testFindIndex(void) {
- printf("*************************************************** testFindIndex\r\n");
-
- float array[] = { 1, 2, 3, 4, 5 };
- int size = 4;
- int result;
-
- printf("To the left\r\n");
- result = findIndex(array, size, -1.0);
- assertEquals(-1, result);
-
- printf("To the right4\r\n");
- result = findIndex(array, size, 10.0);
- assertEquals(3, result);
-
- printf("To the right5\r\n");
- result = findIndex(array, 5, 10.0);
- assertEquals(4, result);
-
- printf("On the edge\r\n");
- result = findIndex(array, size, 4.0);
- assertEquals(3, result);
-
- printf("Another1\r\n");
- result = findIndex(array, size, 3.9);
- assertEquals(2, result);
-
- printf("Another2\r\n");
- result = findIndex(array, size, 4.1);
- assertEquals(3, result);
-
- printf("Another3\r\n");
- result = findIndex(array, size, 2);
- assertEquals(1, result);
-
- printf("Left edge1\r\n");
- result = findIndex(array, size, 1);
- assertEquals(0, result);
-
- printf("Left edge2\r\n");
- result = findIndex(array, size, 1.1);
- assertEquals(0, result);
-
- printf("Middle\r\n");
- result = findIndex(array, size, 3);
- assertEquals(2, result);
-
- size = 5; // now test with off array size
-
- printf("Middle2\r\n");
- result = findIndex(array, size, 4);
- assertEquals(3, result);
-
- printf("Middle2\r\n");
- result = findIndex(array, size, 3.1);
- assertEquals(2, result);
-}
-
-//static float getValue2(float key, float maf) {
-//
-//}
-
-void testInterpolate2d(void) {
- printf("*************************************************** testInterpolate2d\r\n");
-
- float bins4[] = { 1, 2, 3, 4 };
- float values4[] = { 1, 20, 30, 400 };
- int size = 4;
-
- int result;
-
- printf("Left size\r\n");
- result = interpolate2d(0, bins4, values4, size);
- assertEquals(1, result);
-
- printf("Right size\r\n");
- result = interpolate2d(10, bins4, values4, size);
- assertEquals(400, result);
-
- printf("Middle1\r\n");
- result = interpolate2d(3, bins4, values4, size);
- assertEquals(30, result);
-
- printf("Middle1\r\n");
- result = interpolate2d(3.5, bins4, values4, size);
- assertEquals(215, result);
-}
-
-static engine_configuration_s engineConfiguration;
-
-void testSetTableValue(void) {
- printf("*************************************************** testSetTableValue\r\n");
-
- for (int i = 0; i < CLT_CURVE_SIZE; i++) {
- engineConfiguration.cltFuelCorrBins[i] = -40 + i * 10;
- engineConfiguration.cltFuelCorr[i] = 1;
- }
-
- assertEquals(1, engineConfiguration.cltFuelCorr[0]);
-
- setTableValue(engineConfiguration.cltFuelCorrBins, engineConfiguration.cltFuelCorr, CLT_CURVE_SIZE, -40, 1.5);
- assertEquals(1.5, engineConfiguration.cltFuelCorr[0]);
-
- setTableValue(engineConfiguration.cltFuelCorrBins, engineConfiguration.cltFuelCorr, CLT_CURVE_SIZE, -50, 1.4);
- assertEquals(1.4, engineConfiguration.cltFuelCorr[0]);
-
-}
+/*
+ * test_find_index.c
+ *
+ * Created on: Oct 30, 2013
+ * Author: Andrey Belomutskiy, (c) 2012-2013
+ */
+
+#include "engine_math.h"
+#include "main.h"
+#include "interpolation.h"
+#include
+#include "engine_configuration.h"
+
+void testFindIndex(void) {
+ printf("*************************************************** testFindIndex\r\n");
+
+ float array[] = { 1, 2, 3, 4, 5 };
+ int size = 4;
+ int result;
+
+ printf("To the left\r\n");
+ result = findIndex(array, size, -1.0);
+ assertEquals(-1, result);
+
+ printf("To the right4\r\n");
+ result = findIndex(array, size, 10.0);
+ assertEquals(3, result);
+
+ printf("To the right5\r\n");
+ result = findIndex(array, 5, 10.0);
+ assertEquals(4, result);
+
+ printf("On the edge\r\n");
+ result = findIndex(array, size, 4.0);
+ assertEquals(3, result);
+
+ printf("Another1\r\n");
+ result = findIndex(array, size, 3.9);
+ assertEquals(2, result);
+
+ printf("Another2\r\n");
+ result = findIndex(array, size, 4.1);
+ assertEquals(3, result);
+
+ printf("Another3\r\n");
+ result = findIndex(array, size, 2);
+ assertEquals(1, result);
+
+ printf("Left edge1\r\n");
+ result = findIndex(array, size, 1);
+ assertEquals(0, result);
+
+ printf("Left edge2\r\n");
+ result = findIndex(array, size, 1.1);
+ assertEquals(0, result);
+
+ printf("Middle\r\n");
+ result = findIndex(array, size, 3);
+ assertEquals(2, result);
+
+ size = 5; // now test with off array size
+
+ printf("Middle2\r\n");
+ result = findIndex(array, size, 4);
+ assertEquals(3, result);
+
+ printf("Middle2\r\n");
+ result = findIndex(array, size, 3.1);
+ assertEquals(2, result);
+}
+
+//static float getValue2(float key, float maf) {
+//
+//}
+
+void testInterpolate2d(void) {
+ printf("*************************************************** testInterpolate2d\r\n");
+
+ float bins4[] = { 1, 2, 3, 4 };
+ float values4[] = { 1, 20, 30, 400 };
+ int size = 4;
+
+ int result;
+
+ printf("Left size\r\n");
+ result = interpolate2d(0, bins4, values4, size);
+ assertEquals(1, result);
+
+ printf("Right size\r\n");
+ result = interpolate2d(10, bins4, values4, size);
+ assertEquals(400, result);
+
+ printf("Middle1\r\n");
+ result = interpolate2d(3, bins4, values4, size);
+ assertEquals(30, result);
+
+ printf("Middle1\r\n");
+ result = interpolate2d(3.5, bins4, values4, size);
+ assertEquals(215, result);
+}
+
+static engine_configuration_s engineConfiguration;
+
+void testSetTableValue(void) {
+ printf("*************************************************** testSetTableValue\r\n");
+
+ for (int i = 0; i < CLT_CURVE_SIZE; i++) {
+ engineConfiguration.cltFuelCorrBins[i] = -40 + i * 10;
+ engineConfiguration.cltFuelCorr[i] = 1;
+ }
+
+ assertEquals(1, engineConfiguration.cltFuelCorr[0]);
+
+ setTableValue(engineConfiguration.cltFuelCorrBins, engineConfiguration.cltFuelCorr, CLT_CURVE_SIZE, -40, 1.5);
+ assertEquals(1.5, engineConfiguration.cltFuelCorr[0]);
+
+ setTableValue(engineConfiguration.cltFuelCorrBins, engineConfiguration.cltFuelCorr, CLT_CURVE_SIZE, -50, 1.4);
+ assertEquals(1.4, engineConfiguration.cltFuelCorr[0]);
+
+}
diff --git a/unit_tests/test_basic_math/test_find_index.h b/unit_tests/test_basic_math/test_find_index.h
index 3a611751c1..b156d57e8e 100644
--- a/unit_tests/test_basic_math/test_find_index.h
+++ b/unit_tests/test_basic_math/test_find_index.h
@@ -1,15 +1,15 @@
-/*
- * test_find_index.h
- *
- * Created on: Oct 30, 2013
- * Author: Andrey Belomutskiy, (c) 2012-2013
- */
-
-#ifndef TEST_FIND_INDEX_H_
-#define TEST_FIND_INDEX_H_
-
-void testFindIndex(void);
-void testInterpolate2d(void);
-void testSetTableValue(void);
-
-#endif /* TEST_FIND_INDEX_H_ */
+/*
+ * test_find_index.h
+ *
+ * Created on: Oct 30, 2013
+ * Author: Andrey Belomutskiy, (c) 2012-2013
+ */
+
+#ifndef TEST_FIND_INDEX_H_
+#define TEST_FIND_INDEX_H_
+
+void testFindIndex(void);
+void testInterpolate2d(void);
+void testSetTableValue(void);
+
+#endif /* TEST_FIND_INDEX_H_ */
diff --git a/unit_tests/test_basic_math/test_interpolation_3d.c b/unit_tests/test_basic_math/test_interpolation_3d.c
index 6fa875b94c..117d1c2073 100644
--- a/unit_tests/test_basic_math/test_interpolation_3d.c
+++ b/unit_tests/test_basic_math/test_interpolation_3d.c
@@ -1,70 +1,70 @@
-/*
- * Created on: Oct 17, 2013
- * Author: Andrey Belomutskiy, (c) 2012-2013
- */
-
-/**
- * @file test_interpolation_3d.c
- */
-
-#include "test_interpolation_3d.h"
-#include
-#include
-
-#include "interpolation.h"
-#include "main.h"
-
-float rpmBins[5] = { 100, 200, 300, 400, 500 };
-float mafBins[4] = { 1, 2, 3, 4 };
-
-float map0[4] = { 1, 2, 3, 4 };
-float map1[4] = { 2, 3, 4, 5 };
-float map2[4] = { 3, 4, 200, 300 };
-float map3[4] = { 4, 200, 500, 600 };
-float map4[4] = { 4, 200, 500, 600 };
-
-float *map[5] = { map0, map1, map2, map3, map4 };
-
-
-static float getValue(float rpm, float maf) {
- return interpolate3d(rpm, rpmBins, 5, maf, mafBins, 4, map);
-}
-
-void testInterpolate3d(void) {
- printf("*************************************************** testInterpolate3d\r\n");
- float dwell;
- printf("*** no interpolation here 1\r\n");
- dwell = getValue(100, 2);
- assertEquals(2, dwell);
-
- printf("*** no interpolation here 2\r\n");
- dwell = getValue(200, 4);
- assertEquals(5, dwell);
-
- printf("*** rpm interpolated value expected1\r\n");
- dwell = getValue(150, 2);
- assertEquals(2.5, dwell);
-
- printf("*** rpm interpolated value expected2\r\n");
- dwell = getValue(250, 3);
- assertEquals(102, dwell);
-
- printf("*** both rpm and maf interpolated value expected\r\n");
- dwell = getValue(335.3, 3.551);
- assertEquals(361, dwell);
-
- printf("*** both rpm and maf interpolated value expected 2\r\n");
- dwell = getValue(410.01, 2.012);
- assertEquals(203.6, dwell);
-
- printf("*** both rpm and maf interpolated value expected 3\r\n");
- dwell = getValue(1000000, 1000);
- assertEquals(600, dwell);
-
- printf("*** both rpm and maf interpolated value expected 4\r\n");
- dwell = getValue(410.01, -1);
- assertEquals(4, dwell);
-
- dwell = getValue(-1, -1);
- assertEquals(1, dwell);
-}
+/*
+ * Created on: Oct 17, 2013
+ * Author: Andrey Belomutskiy, (c) 2012-2013
+ */
+
+/**
+ * @file test_interpolation_3d.c
+ */
+
+#include "test_interpolation_3d.h"
+#include
+#include
+
+#include "interpolation.h"
+#include "main.h"
+
+float rpmBins[5] = { 100, 200, 300, 400, 500 };
+float mafBins[4] = { 1, 2, 3, 4 };
+
+float map0[4] = { 1, 2, 3, 4 };
+float map1[4] = { 2, 3, 4, 5 };
+float map2[4] = { 3, 4, 200, 300 };
+float map3[4] = { 4, 200, 500, 600 };
+float map4[4] = { 4, 200, 500, 600 };
+
+float *map[5] = { map0, map1, map2, map3, map4 };
+
+
+static float getValue(float rpm, float maf) {
+ return interpolate3d(rpm, rpmBins, 5, maf, mafBins, 4, map);
+}
+
+void testInterpolate3d(void) {
+ printf("*************************************************** testInterpolate3d\r\n");
+ float dwell;
+ printf("*** no interpolation here 1\r\n");
+ dwell = getValue(100, 2);
+ assertEquals(2, dwell);
+
+ printf("*** no interpolation here 2\r\n");
+ dwell = getValue(200, 4);
+ assertEquals(5, dwell);
+
+ printf("*** rpm interpolated value expected1\r\n");
+ dwell = getValue(150, 2);
+ assertEquals(2.5, dwell);
+
+ printf("*** rpm interpolated value expected2\r\n");
+ dwell = getValue(250, 3);
+ assertEquals(102, dwell);
+
+ printf("*** both rpm and maf interpolated value expected\r\n");
+ dwell = getValue(335.3, 3.551);
+ assertEquals(361, dwell);
+
+ printf("*** both rpm and maf interpolated value expected 2\r\n");
+ dwell = getValue(410.01, 2.012);
+ assertEquals(203.6, dwell);
+
+ printf("*** both rpm and maf interpolated value expected 3\r\n");
+ dwell = getValue(1000000, 1000);
+ assertEquals(600, dwell);
+
+ printf("*** both rpm and maf interpolated value expected 4\r\n");
+ dwell = getValue(410.01, -1);
+ assertEquals(4, dwell);
+
+ dwell = getValue(-1, -1);
+ assertEquals(1, dwell);
+}
diff --git a/unit_tests/test_basic_math/test_interpolation_3d.h b/unit_tests/test_basic_math/test_interpolation_3d.h
index 684c26ba74..d5f208743c 100644
--- a/unit_tests/test_basic_math/test_interpolation_3d.h
+++ b/unit_tests/test_basic_math/test_interpolation_3d.h
@@ -1,16 +1,16 @@
-/*
- * Created on: Oct 17, 2013
- * Author: Andrey Belomutskiy, (c) 2012-2013
- */
-
-/**
- * @file test_interpolation_3d.h
- */
-
-
-#ifndef TEST_INTERPOLATION_3D_H_
-#define TEST_INTERPOLATION_3D_H_
-
-void testInterpolate3d(void);
-
-#endif /* TEST_INTERPOLATION_3D_H_ */
+/*
+ * Created on: Oct 17, 2013
+ * Author: Andrey Belomutskiy, (c) 2012-2013
+ */
+
+/**
+ * @file test_interpolation_3d.h
+ */
+
+
+#ifndef TEST_INTERPOLATION_3D_H_
+#define TEST_INTERPOLATION_3D_H_
+
+void testInterpolate3d(void);
+
+#endif /* TEST_INTERPOLATION_3D_H_ */
diff --git a/unit_tests/test_data_structures/test_event_registry.h b/unit_tests/test_data_structures/test_event_registry.h
index 593a291844..28c5e31dfb 100644
--- a/unit_tests/test_data_structures/test_event_registry.h
+++ b/unit_tests/test_data_structures/test_event_registry.h
@@ -1,13 +1,22 @@
-/*
- * test_event_registry.h
- *
- * Created on: Nov 27, 2013
- * Author: Andrey Belomutskiy, (c) 2012-2013
- */
-
-#ifndef TEST_EVENT_REGISTRY_H_
-#define TEST_EVENT_REGISTRY_H_
-
-void testEventRegistry(void);
-
-#endif /* TEST_EVENT_REGISTRY_H_ */
+/*
+ * test_event_registry.h
+ *
+ * Created on: Nov 27, 2013
+ * Author: Andrey Belomutskiy, (c) 2012-2013
+ */
+
+#ifndef TEST_EVENT_REGISTRY_H_
+#define TEST_EVENT_REGISTRY_H_
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif /* __cplusplus */
+
+void testEventRegistry(void);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* TEST_EVENT_REGISTRY_H_ */
diff --git a/unit_tests/test_engine_math.c b/unit_tests/test_engine_math.c
index b2898892c7..f6deca3558 100644
--- a/unit_tests/test_engine_math.c
+++ b/unit_tests/test_engine_math.c
@@ -1,27 +1,27 @@
-/*
- * @file test_engine_math.c
- *
- * Created on: Nov 14, 2013
- * Author: Andrey Belomutskiy, (c) 2012-2013
- */
-
-#include "test_engine_math.h"
-#include "main.h"
-#include "engine_math.h"
-#include "engine_configuration.h"
-
-extern engine_configuration_s *engineConfiguration;
-extern engine_configuration2_s *engineConfiguration2;
-
-void testEngineMath(void) {
- printf("*************************************************** testEngineMath\r\n");
-
- engineConfiguration->rpmMultiplier = 0.5;
-
- assertEqualsM("600 RPM", 5000, getOneDegreeTime(600) * 180);
- assertEqualsM("6000 RPM", 500, getOneDegreeTime(6000) * 180);
-}
-
-float getMap(void) {
- return 0;
-}
+/*
+ * @file test_engine_math.c
+ *
+ * Created on: Nov 14, 2013
+ * Author: Andrey Belomutskiy, (c) 2012-2013
+ */
+
+#include "test_engine_math.h"
+#include "main.h"
+#include "engine_math.h"
+#include "engine_configuration.h"
+
+extern engine_configuration_s *engineConfiguration;
+extern engine_configuration2_s *engineConfiguration2;
+
+void testEngineMath(void) {
+ printf("*************************************************** testEngineMath\r\n");
+
+ engineConfiguration->rpmMultiplier = 0.5;
+
+ assertEqualsM("600 RPM", 5000, getOneDegreeTime(600) * 180);
+ assertEqualsM("6000 RPM", 500, getOneDegreeTime(6000) * 180);
+}
+
+float getMap(void) {
+ return 0;
+}
diff --git a/unit_tests/test_engine_math.h b/unit_tests/test_engine_math.h
index 8f80cc7f41..0ca049a2f0 100644
--- a/unit_tests/test_engine_math.h
+++ b/unit_tests/test_engine_math.h
@@ -1,13 +1,13 @@
-/*
- * @file test_engine_math.h
- *
- * Created on: Nov 14, 2013
- * Author: Andrey Belomutskiy, (c) 2012-2013
- */
-
-#ifndef TEST_ENGINE_MATH_H_
-#define TEST_ENGINE_MATH_H_
-
-void testEngineMath(void);
-
-#endif /* TEST_ENGINE_MATH_H_ */
+/*
+ * @file test_engine_math.h
+ *
+ * Created on: Nov 14, 2013
+ * Author: Andrey Belomutskiy, (c) 2012-2013
+ */
+
+#ifndef TEST_ENGINE_MATH_H_
+#define TEST_ENGINE_MATH_H_
+
+void testEngineMath(void);
+
+#endif /* TEST_ENGINE_MATH_H_ */
diff --git a/unit_tests/test_fuel_map.h b/unit_tests/test_fuel_map.h
index 4f68e7daf5..e0c08dcb2d 100644
--- a/unit_tests/test_fuel_map.h
+++ b/unit_tests/test_fuel_map.h
@@ -1,15 +1,24 @@
-/*
- * test_fuel_map.h
- *
- * Created on: Nov 6, 2013
- * Author: pc
- */
-
-#ifndef TEST_FUEL_MAP_H_
-#define TEST_FUEL_MAP_H_
-
-void testFuelMap(void);
-void testAngleResolver(void);
-void testPinHelper(void);
-
-#endif /* TEST_FUEL_MAP_H_ */
+/*
+ * test_fuel_map.h
+ *
+ * Created on: Nov 6, 2013
+ * Author: pc
+ */
+
+#ifndef TEST_FUEL_MAP_H_
+#define TEST_FUEL_MAP_H_
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif /* __cplusplus */
+
+void testFuelMap(void);
+void testAngleResolver(void);
+void testPinHelper(void);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* TEST_FUEL_MAP_H_ */
diff --git a/unit_tests/test_idle_controller.c b/unit_tests/test_idle_controller.c
index 8150a638fe..d8fa0e8b25 100644
--- a/unit_tests/test_idle_controller.c
+++ b/unit_tests/test_idle_controller.c
@@ -1,17 +1,17 @@
-/*
- * test_idle_controller.c
- *
- * Created on: Oct 17, 2013
- * Author: Andrey
- */
-
-#include
-
-
-void idleDebug(char *msg, int value) {
- printf("%s\r\n", msg);
-}
-
-void isCranking(void) {
- return;
-}
+/*
+ * test_idle_controller.c
+ *
+ * Created on: Oct 17, 2013
+ * Author: Andrey
+ */
+
+#include
+
+
+void idleDebug(char *msg, int value) {
+ printf("%s\r\n", msg);
+}
+
+void isCranking(void) {
+ return;
+}
diff --git a/unit_tests/test_idle_controller.h b/unit_tests/test_idle_controller.h
index ff3aa90ac1..75a204acaf 100644
--- a/unit_tests/test_idle_controller.h
+++ b/unit_tests/test_idle_controller.h
@@ -1,7 +1,7 @@
-#ifndef TEST_IDLE_CONTROLLER_H
-#define TEST_IDLE_CONTROLLER_H
-
-void idleDebug(char *msg, int value);
-void isCranking(void);
-
-#endif
+#ifndef TEST_IDLE_CONTROLLER_H
+#define TEST_IDLE_CONTROLLER_H
+
+void idleDebug(char *msg, int value);
+void isCranking(void);
+
+#endif
diff --git a/unit_tests/test_sensors.c b/unit_tests/test_sensors.c
index cf4a72c7df..33c8bb43a8 100644
--- a/unit_tests/test_sensors.c
+++ b/unit_tests/test_sensors.c
@@ -1,35 +1,52 @@
-/**
- * @file test_sensors.c
- *
- * @date Dec 7, 2013
- * @author Andrey Belomutskiy, (c) 2012-2013
- */
-
-#include "main.h"
-#include "thermistors.h"
-#include "map.h"
-
-static ThermistorConf tc;
-
-static void testMapDecoding() {
- assertEqualsM("denso 0 volts", -6.64, getMAPValueHonda_Denso183(0));
- assertEquals(31.244, getMAPValueHonda_Denso183(1));
-
- assertEqualsM("MPX_4250 0 volts", 8, getMAPValueMPX_4250(0));
- assertEquals(58.4, getMAPValueMPX_4250(1));
-}
-
-void testSensors(void) {
- print("************************************************** testSensors\r\n");
- testMapDecoding();
- setThermistorConfiguration(&tc, 32, 9500, 75, 2100, 120, 1000);
-
- prepareThermistorCurve(&tc);
-
- assertEquals(-0.003, tc.s_h_a);
- assertEquals(0.001, tc.s_h_b);
- assertEquals(0.0, tc.s_h_c);
-
- float t = convertResistanceToKelvinTemperature(2100, &tc);
- assertEquals(75 + KELV, t);
-}
+/**
+ * @file test_sensors.c
+ *
+ * @date Dec 7, 2013
+ * @author Andrey Belomutskiy, (c) 2012-2013
+ */
+
+#include "main.h"
+#include "thermistors.h"
+#include "allsensors.h"
+
+static ThermistorConf tc;
+
+static void testMapDecoding(void) {
+ assertEqualsM("denso 0 volts", -6.64, getMAPValueHonda_Denso183(0));
+ assertEquals(31.244, getMAPValueHonda_Denso183(1));
+
+ assertEqualsM("MPX_4250 0 volts", 8, getMAPValueMPX_4250(0));
+ assertEquals(58.4, getMAPValueMPX_4250(1));
+}
+
+void testTpsRateOfChange(void) {
+ print("************************************************** testTpsRateOfChange\r\n");
+ saveTpsState(0, 0);
+ saveTpsState(CH_FREQUENCY, 50);
+ assertEquals(50, getTpsRateOfChange());
+
+ saveTpsState(2 * CH_FREQUENCY, 50);
+ assertEquals(0, getTpsRateOfChange());
+
+ saveTpsState(3 * CH_FREQUENCY, 75);
+ assertEquals(25, getTpsRateOfChange());
+
+
+}
+
+void testSensors(void) {
+ print("************************************************** testSensors\r\n");
+ testMapDecoding();
+ testTpsRateOfChange();
+
+ setThermistorConfiguration(&tc, 32, 9500, 75, 2100, 120, 1000);
+
+ prepareThermistorCurve(&tc);
+
+ assertEquals(-0.003, tc.s_h_a);
+ assertEquals(0.001, tc.s_h_b);
+ assertEquals(0.0, tc.s_h_c);
+
+ float t = convertResistanceToKelvinTemperature(2100, &tc);
+ assertEquals(75 + KELV, t);
+}
diff --git a/unit_tests/test_sensors.h b/unit_tests/test_sensors.h
index b59fd418fd..4f82601d16 100644
--- a/unit_tests/test_sensors.h
+++ b/unit_tests/test_sensors.h
@@ -1,13 +1,13 @@
-/**
- * @file test_sensors.h
- *
- * @date Dec 7, 2013
- * @author Andrey Belomutskiy, (c) 2012-2013
- */
-
-#ifndef TEST_SENSORS_H_
-#define TEST_SENSORS_H_
-
-void testSensors(void);
-
-#endif /* TEST_SENSORS_H_ */
+/**
+ * @file test_sensors.h
+ *
+ * @date Dec 7, 2013
+ * @author Andrey Belomutskiy, (c) 2012-2013
+ */
+
+#ifndef TEST_SENSORS_H_
+#define TEST_SENSORS_H_
+
+void testSensors(void);
+
+#endif /* TEST_SENSORS_H_ */
diff --git a/unit_tests/test_signal_executor.h b/unit_tests/test_signal_executor.h
index e61fcf3b38..141bde5957 100644
--- a/unit_tests/test_signal_executor.h
+++ b/unit_tests/test_signal_executor.h
@@ -1,13 +1,23 @@
-/**
- * @file test_signal_executor.h
- *
- * @date Nov 28, 2013
- * @author Andrey Belomutskiy, (c) 2012-2013
- */
-
-#ifndef TEST_SIGNAL_EXECUTOR_H_
-#define TEST_SIGNAL_EXECUTOR_H_
-
-void testSignalExecutor(void);
-
-#endif /* TEST_SIGNAL_EXECUTOR_H_ */
+/**
+ * @file test_signal_executor.h
+ *
+ * @date Nov 28, 2013
+ * @author Andrey Belomutskiy, (c) 2012-2013
+ */
+
+#ifndef TEST_SIGNAL_EXECUTOR_H_
+#define TEST_SIGNAL_EXECUTOR_H_
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif /* __cplusplus */
+
+void testSignalExecutor(void);
+int getRevolutionCounter(void);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* TEST_SIGNAL_EXECUTOR_H_ */
diff --git a/unit_tests/test_trigger_decoder.h b/unit_tests/test_trigger_decoder.h
index 916227865c..0a06b7e352 100644
--- a/unit_tests/test_trigger_decoder.h
+++ b/unit_tests/test_trigger_decoder.h
@@ -1,13 +1,13 @@
-/**
- * @file test_trigger_decoder.h
- *
- * @date Dec 24, 2013
- * @author Andrey Belomutskiy, (c) 2012-2013
- */
-
-#ifndef TEST_TRIGGER_DECODER_H_
-#define TEST_TRIGGER_DECODER_H_
-
-void testTriggerDecoder(void);
-
-#endif /* TEST_TRIGGER_DECODER_H_ */
+/**
+ * @file test_trigger_decoder.h
+ *
+ * @date Dec 24, 2013
+ * @author Andrey Belomutskiy, (c) 2012-2013
+ */
+
+#ifndef TEST_TRIGGER_DECODER_H_
+#define TEST_TRIGGER_DECODER_H_
+
+void testTriggerDecoder(void);
+
+#endif /* TEST_TRIGGER_DECODER_H_ */
diff --git a/unit_tests/test_util.cpp b/unit_tests/test_util.cpp
index c04bfb6374..b62b9ec7dd 100644
--- a/unit_tests/test_util.cpp
+++ b/unit_tests/test_util.cpp
@@ -1,278 +1,294 @@
-/**
- * @file test_util.c
- *
- * @date Dec 8, 2013
- * @author Andrey Belomutskiy, (c) 2012-2013
- */
-
-#include
-
-#include "test_util.h"
-#include "cyclic_buffer.h"
-#include "main.h"
-#include "histogram.h"
-
-#include "malfunction_central.h"
-#include "eficonsole_logic.h"
-
-#include "nmea.h"
-
-static cyclic_buffer sb;
-
-
-void testCyclicBuffer(void) {
- print("*************************************** testCyclicBuffer\r\n");
-
- sb.add(10);
-
- assertEquals(10, sb.sum(3));
-
- sb.add(2);
- assertEquals(12, sb.sum(2));
-}
-
-void testHistogram(void) {
- print("******************************************* testHistogram\r\n");
-
- initHistogramsModule();
-
- assertEquals(80, histogramGetIndex(239));
- assertEquals(223, histogramGetIndex(239239));
- assertEquals(364, histogramGetIndex(239239239));
-
- histogram_s h;
-
- initHistogram(&h, "test");
-
- int result[5];
- assertEquals(0, hsReport(&h, result));
-
- hsAdd(&h, 10);
- assertEquals(1, hsReport(&h, result));
- assertEquals(10, result[0]);
-
- // let's add same value one more time
- hsAdd(&h, 10);
- assertEquals(2, hsReport(&h, result));
- assertEquals(10, result[0]);
- assertEquals(10, result[1]);
-
- hsAdd(&h, 10);
- hsAdd(&h, 10);
- hsAdd(&h, 10);
-
- hsAdd(&h, 1000);
- hsAdd(&h, 100);
-
- assertEquals(5, hsReport(&h, result));
-
- assertEquals(5, result[0]);
- assertEquals(10, result[1]);
- assertEquals(10, result[2]);
- assertEquals(100, result[3]);
- // values are not expected to be exactly the same, it's the shape what matters
- assertEquals(1011, result[4]);
-}
-
-static void testMalfunctionCentralRemoveNonExistent() {
- print("******************************************* testMalfunctionCentralRemoveNonExistent\r\n");
- initMalfunctionCentral();
-
- // this should not crash
- removeError(OBD_Engine_Coolant_Temperature_Circuit_Malfunction);
-}
-
-static void testMalfunctionCentralSameElementAgain() {
- initMalfunctionCentral();
- print("******************************************* testMalfunctionCentralSameElementAgain\r\n");
- error_codes_set_s localCopy;
-
- addError(OBD_Engine_Coolant_Temperature_Circuit_Malfunction);
- addError(OBD_Engine_Coolant_Temperature_Circuit_Malfunction);
- getErrorCodes(&localCopy);
- assertEquals(1, localCopy.count);
-}
-
-static void testMalfunctionCentralRemoveFirstElement() {
- initMalfunctionCentral();
- print("******************************************* testMalfunctionCentralRemoveFirstElement\r\n");
- error_codes_set_s localCopy;
-
- obd_code_e firstElement = OBD_Engine_Coolant_Temperature_Circuit_Malfunction;
- addError(firstElement);
-
- obd_code_e secondElement = OBD_Intake_Air_Temperature_Circuit_Malfunction;
- addError(secondElement);
- getErrorCodes(&localCopy);
- assertEquals(2, localCopy.count);
-
- // let's remove first element - code
- removeError(firstElement);
-
- getErrorCodes(&localCopy);
- assertEquals(1, localCopy.count);
- assertEquals(secondElement, localCopy.error_codes[0]);
-}
-
-void testMalfunctionCentral(void) {
- testMalfunctionCentralRemoveNonExistent();
- testMalfunctionCentralSameElementAgain();
- testMalfunctionCentralRemoveFirstElement();
-
- print("******************************************* testMalfunctionCentral\r\n");
- initMalfunctionCentral();
-
- error_codes_set_s localCopy;
-
- // on start-up error storage should be empty
- getErrorCodes(&localCopy);
- assertEquals(0, localCopy.count);
-
- obd_code_e code = OBD_Engine_Coolant_Temperature_Circuit_Malfunction;
- // let's add one error and validate
- addError(code);
-
- getErrorCodes(&localCopy);
- assertEqualsM("count #1", 1, localCopy.count);
- assertEquals(code, localCopy.error_codes[0]);
-
- // let's remove value which is not in the collection
- removeError((obd_code_e)22);
- // element not present - nothing to removed
- assertEquals(1, localCopy.count);
- assertEquals(code, localCopy.error_codes[0]);
-
- code = OBD_Intake_Air_Temperature_Circuit_Malfunction;
- addError(code);
- getErrorCodes(&localCopy);
- // todo: assertEquals(2, localCopy.count);
-
- for (int code = 0; code < 100; code++) {
- addError((obd_code_e) code);
- }
- getErrorCodes(&localCopy);
- assertEquals(MAX_ERROR_CODES_COUNT, localCopy.count);
-
- // now we have full array and code below present
- removeError(code);
- getErrorCodes(&localCopy);
- assertEquals(MAX_ERROR_CODES_COUNT - 1, localCopy.count);
-}
-
-static int lastInteger = -1;
-static int lastInteger2 = -1;
-
-static void testEchoI(int param) {
- lastInteger = param;
-}
-
-static void testEchoII(int param, int param2) {
- lastInteger = param;
- lastInteger2 = param2;
-}
-
-static char *lastFirst = NULL;
-static char *lastThird = NULL;
-
-static void testEchoSSS(char *first, char *second, char *third) {
- lastFirst = first;
- lastThird = third;
-}
-
-#define UNKNOWN_COMMAND "dfadasdasd"
-
-static loc_t GPSdata;
-
-static char nmeaMessage[1000];
-
-void testGpsParser(void) {
- print("******************************************* testGpsParser\r\n");
-
- strcpy(nmeaMessage, "");
- gps_location(&GPSdata, nmeaMessage);
-
- // we need to pass a mutable string, not a constant because the parser would be modifying the string
- strcpy(nmeaMessage, "$GPRMC,173843,A,3349.896,N,11808.521,W,000.0,360.0,230108,013.4,E*69");
- gps_location(&GPSdata, nmeaMessage);
- assertEqualsM("1 valid", 4, GPSdata.quality);
- assertEqualsM("1 latitude", 3349.896, GPSdata.latitude);
- assertEqualsM("1 longitude", 11808.521, GPSdata.longitude);
- assertEqualsM("1 speed", 0, GPSdata.speed);
-// assertEqualsM("1 altitude", 0, GPSdata.altitude); // GPRMC not overwrite altitude
- assertEqualsM("1 course", 360, GPSdata.course);
-
- strcpy(nmeaMessage, "$GPGGA,111609.14,5001.27,N,3613.06,E,3,08,0.0,10.2,M,0.0,M,0.0,0000*70");
- gps_location(&GPSdata, nmeaMessage);
- assertEqualsM("2 valid", 3, GPSdata.quality); // see field details
- assertEqualsM("2 latitude", 50.0212, GPSdata.latitude);
- assertEqualsM("2 longitude", 36.2177, GPSdata.longitude);
- assertEqualsM("2 speed", 0, GPSdata.speed);
- assertEqualsM("2 altitude", 10.2, GPSdata.altitude);
-// assertEqualsM("2 course", 0, GPSdata.course); // GPGGA not overwrite course
-
- strcpy(nmeaMessage, "$GPRMC,111609.14,A,5001.27,N,3613.06,E,11.2,0.0,261206,0.0,E*50");
- gps_location(&GPSdata, nmeaMessage);
- assertEqualsM("3 valid", 4, GPSdata.quality);
- assertEqualsM("3 latitude", 5001.27, GPSdata.latitude);
- assertEqualsM("3 longitude", 3613.06, GPSdata.longitude);
- assertEqualsM("3 speed", 11.2, GPSdata.speed);
-// assertEqualsM("3 altitude", 0, GPSdata.altitude); // GPRMC not overwrite altitude
- assertEqualsM("3 course", 0, GPSdata.course);
- assertEqualsM("3 GPS yy",2006, GPSdata.GPStm.tm_year+1900);
- assertEqualsM("3 GPS mm",12, GPSdata.GPStm.tm_mon);
- assertEqualsM("3 GPS yy",26, GPSdata.GPStm.tm_mday);
- assertEqualsM("3 GPS hh",11, GPSdata.GPStm.tm_hour);
- assertEqualsM("3 GPS mm",16, GPSdata.GPStm.tm_min);
- assertEqualsM("3 GPS ss",9, GPSdata.GPStm.tm_sec);
-
- // check again first one
- // we need to pass a mutable string, not a constant because the parser would be modifying the string
- strcpy(nmeaMessage, "$GPRMC,173843,A,3349.896,N,11808.521,W,000.0,360.0,230108,013.4,E*69");
- gps_location(&GPSdata, nmeaMessage);
- assertEqualsM("4 valid", 4, GPSdata.quality);
- assertEqualsM("4 latitude", 3349.896, GPSdata.latitude);
- assertEqualsM("4 longitude", 11808.521, GPSdata.longitude);
- assertEqualsM("4 speed", 0, GPSdata.speed);
- assertEqualsM("4 course", 360, GPSdata.course);
-}
-
-// this buffer is needed because on Unix you would not be able to change static char constants
-static char buffer[300];
-
-void testConsoleLogic(void) {
- print("******************************************* testConsoleLogic\r\n");
- resetConsoleActions();
-
- helpCommand();
-
- char *ptr = validateSecureLine(UNKNOWN_COMMAND);
- assertEquals(0, strcmp(UNKNOWN_COMMAND, ptr));
- assertEquals(10, tokenLength(UNKNOWN_COMMAND));
-
- // handling invalid token should work
- strcpy(buffer, "sdasdafasd asd");
- handleConsoleLine(buffer);
-
- print("\r\naddConsoleActionI\r\n");
- addConsoleActionI("echoi", testEchoI);
- strcpy(buffer, "echoi 239");
- handleConsoleLine(buffer);
- assertEquals(239, lastInteger);
-
- print("\r\naddConsoleActionII\r\n");
- addConsoleActionII("echoii", testEchoII);
- strcpy(buffer, "echoii 22 239");
- handleConsoleLine(buffer);
- assertEquals(22, lastInteger);
- assertEquals(239, lastInteger2);
-
- print("\r\addConsoleActionSSS\r\n");
- addConsoleActionSSS("echosss", testEchoSSS);
- strcpy(buffer, "echosss 111 222 333");
- handleConsoleLine(buffer);
- assertEquals(111, atoi(lastFirst));
- assertEquals(333, atoi(lastThird));
-
- //addConsoleActionSSS("GPS", testGpsParser);
-}
-
+/**
+ * @file test_util.c
+ *
+ * @date Dec 8, 2013
+ * @author Andrey Belomutskiy, (c) 2012-2013
+ */
+
+#include
+
+#include "test_util.h"
+#include "cyclic_buffer.h"
+#include "main.h"
+#include "histogram.h"
+
+#include "malfunction_central.h"
+#include "eficonsole_logic.h"
+
+#include "nmea.h"
+#include "efilib2.h"
+
+static cyclic_buffer sb;
+
+
+void testOverflow64Counter(void) {
+ print("*************************************** testOverflow64Counter\r\n");
+
+ Overflow64Counter o;
+ assertEquals(0, o.get());
+ o.offer(10);
+ assertEquals(10, o.get());
+
+ o.offer(20);
+ assertEquals(20, o.get());
+
+ o.offer(0); // overflow
+ assertEquals(4294967296, o.get());
+}
+
+void testCyclicBuffer(void) {
+ print("*************************************** testCyclicBuffer\r\n");
+
+ sb.add(10);
+
+ assertEquals(10, sb.sum(3));
+
+ sb.add(2);
+ assertEquals(12, sb.sum(2));
+}
+
+void testHistogram(void) {
+ print("******************************************* testHistogram\r\n");
+
+ initHistogramsModule();
+
+ assertEquals(80, histogramGetIndex(239));
+ assertEquals(223, histogramGetIndex(239239));
+ assertEquals(364, histogramGetIndex(239239239));
+
+ histogram_s h;
+
+ initHistogram(&h, "test");
+
+ int result[5];
+ assertEquals(0, hsReport(&h, result));
+
+ hsAdd(&h, 10);
+ assertEquals(1, hsReport(&h, result));
+ assertEquals(10, result[0]);
+
+ // let's add same value one more time
+ hsAdd(&h, 10);
+ assertEquals(2, hsReport(&h, result));
+ assertEquals(10, result[0]);
+ assertEquals(10, result[1]);
+
+ hsAdd(&h, 10);
+ hsAdd(&h, 10);
+ hsAdd(&h, 10);
+
+ hsAdd(&h, 1000);
+ hsAdd(&h, 100);
+
+ assertEquals(5, hsReport(&h, result));
+
+ assertEquals(5, result[0]);
+ assertEquals(10, result[1]);
+ assertEquals(10, result[2]);
+ assertEquals(100, result[3]);
+ // values are not expected to be exactly the same, it's the shape what matters
+ assertEquals(1011, result[4]);
+}
+
+static void testMalfunctionCentralRemoveNonExistent() {
+ print("******************************************* testMalfunctionCentralRemoveNonExistent\r\n");
+ initMalfunctionCentral();
+
+ // this should not crash
+ removeError(OBD_Engine_Coolant_Temperature_Circuit_Malfunction);
+}
+
+static void testMalfunctionCentralSameElementAgain() {
+ initMalfunctionCentral();
+ print("******************************************* testMalfunctionCentralSameElementAgain\r\n");
+ error_codes_set_s localCopy;
+
+ addError(OBD_Engine_Coolant_Temperature_Circuit_Malfunction);
+ addError(OBD_Engine_Coolant_Temperature_Circuit_Malfunction);
+ getErrorCodes(&localCopy);
+ assertEquals(1, localCopy.count);
+}
+
+static void testMalfunctionCentralRemoveFirstElement() {
+ initMalfunctionCentral();
+ print("******************************************* testMalfunctionCentralRemoveFirstElement\r\n");
+ error_codes_set_s localCopy;
+
+ obd_code_e firstElement = OBD_Engine_Coolant_Temperature_Circuit_Malfunction;
+ addError(firstElement);
+
+ obd_code_e secondElement = OBD_Intake_Air_Temperature_Circuit_Malfunction;
+ addError(secondElement);
+ getErrorCodes(&localCopy);
+ assertEquals(2, localCopy.count);
+
+ // let's remove first element - code
+ removeError(firstElement);
+
+ getErrorCodes(&localCopy);
+ assertEquals(1, localCopy.count);
+ assertEquals(secondElement, localCopy.error_codes[0]);
+}
+
+void testMalfunctionCentral(void) {
+ testMalfunctionCentralRemoveNonExistent();
+ testMalfunctionCentralSameElementAgain();
+ testMalfunctionCentralRemoveFirstElement();
+
+ print("******************************************* testMalfunctionCentral\r\n");
+ initMalfunctionCentral();
+
+ error_codes_set_s localCopy;
+
+ // on start-up error storage should be empty
+ getErrorCodes(&localCopy);
+ assertEquals(0, localCopy.count);
+
+ obd_code_e code = OBD_Engine_Coolant_Temperature_Circuit_Malfunction;
+ // let's add one error and validate
+ addError(code);
+
+ getErrorCodes(&localCopy);
+ assertEqualsM("count #1", 1, localCopy.count);
+ assertEquals(code, localCopy.error_codes[0]);
+
+ // let's remove value which is not in the collection
+ removeError((obd_code_e)22);
+ // element not present - nothing to removed
+ assertEquals(1, localCopy.count);
+ assertEquals(code, localCopy.error_codes[0]);
+
+ code = OBD_Intake_Air_Temperature_Circuit_Malfunction;
+ addError(code);
+ getErrorCodes(&localCopy);
+ // todo: assertEquals(2, localCopy.count);
+
+ for (int code = 0; code < 100; code++) {
+ addError((obd_code_e) code);
+ }
+ getErrorCodes(&localCopy);
+ assertEquals(MAX_ERROR_CODES_COUNT, localCopy.count);
+
+ // now we have full array and code below present
+ removeError(code);
+ getErrorCodes(&localCopy);
+ assertEquals(MAX_ERROR_CODES_COUNT - 1, localCopy.count);
+}
+
+static int lastInteger = -1;
+static int lastInteger2 = -1;
+
+static void testEchoI(int param) {
+ lastInteger = param;
+}
+
+static void testEchoII(int param, int param2) {
+ lastInteger = param;
+ lastInteger2 = param2;
+}
+
+static char *lastFirst = NULL;
+static char *lastThird = NULL;
+
+static void testEchoSSS(char *first, char *second, char *third) {
+ lastFirst = first;
+ lastThird = third;
+}
+
+#define UNKNOWN_COMMAND "dfadasdasd"
+
+static loc_t GPSdata;
+
+static char nmeaMessage[1000];
+
+void testGpsParser(void) {
+ print("******************************************* testGpsParser\r\n");
+
+ strcpy(nmeaMessage, "");
+ gps_location(&GPSdata, nmeaMessage);
+
+ // we need to pass a mutable string, not a constant because the parser would be modifying the string
+ strcpy(nmeaMessage, "$GPRMC,173843,A,3349.896,N,11808.521,W,000.0,360.0,230108,013.4,E*69");
+ gps_location(&GPSdata, nmeaMessage);
+ assertEqualsM("1 valid", 4, GPSdata.quality);
+ assertEqualsM("1 latitude", 3349.896, GPSdata.latitude);
+ assertEqualsM("1 longitude", 11808.521, GPSdata.longitude);
+ assertEqualsM("1 speed", 0, GPSdata.speed);
+// assertEqualsM("1 altitude", 0, GPSdata.altitude); // GPRMC not overwrite altitude
+ assertEqualsM("1 course", 360, GPSdata.course);
+
+ strcpy(nmeaMessage, "$GPGGA,111609.14,5001.27,N,3613.06,E,3,08,0.0,10.2,M,0.0,M,0.0,0000*70");
+ gps_location(&GPSdata, nmeaMessage);
+ assertEqualsM("2 valid", 3, GPSdata.quality); // see field details
+ assertEqualsM("2 latitude", 50.0212, GPSdata.latitude);
+ assertEqualsM("2 longitude", 36.2177, GPSdata.longitude);
+ assertEqualsM("2 speed", 0, GPSdata.speed);
+ assertEqualsM("2 altitude", 10.2, GPSdata.altitude);
+// assertEqualsM("2 course", 0, GPSdata.course); // GPGGA not overwrite course
+
+ strcpy(nmeaMessage, "$GPRMC,111609.14,A,5001.27,N,3613.06,E,11.2,0.0,261206,0.0,E*50");
+ gps_location(&GPSdata, nmeaMessage);
+ assertEqualsM("3 valid", 4, GPSdata.quality);
+ assertEqualsM("3 latitude", 5001.27, GPSdata.latitude);
+ assertEqualsM("3 longitude", 3613.06, GPSdata.longitude);
+ assertEqualsM("3 speed", 11.2, GPSdata.speed);
+// assertEqualsM("3 altitude", 0, GPSdata.altitude); // GPRMC not overwrite altitude
+ assertEqualsM("3 course", 0, GPSdata.course);
+ assertEqualsM("3 GPS yy",2006, GPSdata.GPStm.tm_year+1900);
+ assertEqualsM("3 GPS mm",12, GPSdata.GPStm.tm_mon);
+ assertEqualsM("3 GPS yy",26, GPSdata.GPStm.tm_mday);
+ assertEqualsM("3 GPS hh",11, GPSdata.GPStm.tm_hour);
+ assertEqualsM("3 GPS mm",16, GPSdata.GPStm.tm_min);
+ assertEqualsM("3 GPS ss",9, GPSdata.GPStm.tm_sec);
+
+ // check again first one
+ // we need to pass a mutable string, not a constant because the parser would be modifying the string
+ strcpy(nmeaMessage, "$GPRMC,173843,A,3349.896,N,11808.521,W,000.0,360.0,230108,013.4,E*69");
+ gps_location(&GPSdata, nmeaMessage);
+ assertEqualsM("4 valid", 4, GPSdata.quality);
+ assertEqualsM("4 latitude", 3349.896, GPSdata.latitude);
+ assertEqualsM("4 longitude", 11808.521, GPSdata.longitude);
+ assertEqualsM("4 speed", 0, GPSdata.speed);
+ assertEqualsM("4 course", 360, GPSdata.course);
+}
+
+// this buffer is needed because on Unix you would not be able to change static char constants
+static char buffer[300];
+
+void testConsoleLogic(void) {
+ print("******************************************* testConsoleLogic\r\n");
+ resetConsoleActions();
+
+ helpCommand();
+
+ char *ptr = validateSecureLine(UNKNOWN_COMMAND);
+ assertEquals(0, strcmp(UNKNOWN_COMMAND, ptr));
+ assertEquals(10, tokenLength(UNKNOWN_COMMAND));
+
+ // handling invalid token should work
+ strcpy(buffer, "sdasdafasd asd");
+ handleConsoleLine(buffer);
+
+ print("\r\naddConsoleActionI\r\n");
+ addConsoleActionI("echoi", testEchoI);
+ strcpy(buffer, "echoi 239");
+ handleConsoleLine(buffer);
+ assertEquals(239, lastInteger);
+
+ print("\r\naddConsoleActionII\r\n");
+ addConsoleActionII("echoii", testEchoII);
+ strcpy(buffer, "echoii 22 239");
+ handleConsoleLine(buffer);
+ assertEquals(22, lastInteger);
+ assertEquals(239, lastInteger2);
+
+ print("\r\addConsoleActionSSS\r\n");
+ addConsoleActionSSS("echosss", testEchoSSS);
+ strcpy(buffer, "echosss 111 222 333");
+ handleConsoleLine(buffer);
+ assertEquals(111, atoi(lastFirst));
+ assertEquals(333, atoi(lastThird));
+
+ //addConsoleActionSSS("GPS", testGpsParser);
+}
+
diff --git a/unit_tests/test_util.h b/unit_tests/test_util.h
index e77940bcc7..0bd3c24cb6 100644
--- a/unit_tests/test_util.h
+++ b/unit_tests/test_util.h
@@ -1,30 +1,31 @@
-/**
- * @file test_cyclic_buffer.h
- *
- * @date Dec 8, 2013
- * @author Andrey Belomutskiy, (c) 2012-2013
- */
-
-#ifndef TEST_CYCLIC_BUFFER_H_
-#define TEST_CYCLIC_BUFFER_H_
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif /* __cplusplus */
-
-
-
-void testCyclicBuffer(void);
-void testHistogram(void);
-void testMalfunctionCentral(void);
-void testConsoleLogic(void);
-void testGpsParser(void);
-
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-
-#endif /* TEST_CYCLIC_BUFFER_H_ */
+/**
+ * @file test_cyclic_buffer.h
+ *
+ * @date Dec 8, 2013
+ * @author Andrey Belomutskiy, (c) 2012-2013
+ */
+
+#ifndef TEST_CYCLIC_BUFFER_H_
+#define TEST_CYCLIC_BUFFER_H_
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif /* __cplusplus */
+
+
+
+void testCyclicBuffer(void);
+void testOverflow64Counter(void);
+void testHistogram(void);
+void testMalfunctionCentral(void);
+void testConsoleLogic(void);
+void testGpsParser(void);
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+
+#endif /* TEST_CYCLIC_BUFFER_H_ */
diff --git a/win32_functional_tests/.cproject b/win32_functional_tests/.cproject
index 2480081e74..9301815720 100644
--- a/win32_functional_tests/.cproject
+++ b/win32_functional_tests/.cproject
@@ -1,42 +1,42 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/win32_functional_tests/.project b/win32_functional_tests/.project
index b8ba745391..f6e6c46757 100644
--- a/win32_functional_tests/.project
+++ b/win32_functional_tests/.project
@@ -1,27 +1,27 @@
-
-
- win32_functional_tests
-
-
-
-
-
- org.eclipse.cdt.managedbuilder.core.genmakebuilder
- clean,full,incremental,
-
-
-
-
- org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
- full,incremental,
-
-
-
-
-
- org.eclipse.cdt.core.cnature
- org.eclipse.cdt.core.ccnature
- org.eclipse.cdt.managedbuilder.core.managedBuildNature
- org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
-
-
+
+
+ win32_functional_tests
+
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.genmakebuilder
+ clean,full,incremental,
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
+ full,incremental,
+
+
+
+
+
+ org.eclipse.cdt.core.cnature
+ org.eclipse.cdt.core.ccnature
+ org.eclipse.cdt.managedbuilder.core.managedBuildNature
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
+
+
diff --git a/win32_functional_tests/Makefile b/win32_functional_tests/Makefile
index 60329fbec8..1d12a3e82e 100644
--- a/win32_functional_tests/Makefile
+++ b/win32_functional_tests/Makefile
@@ -1,256 +1,259 @@
-##############################################################################
-# Build global options
-# NOTE: Can be overridden externally.
-#
-
-PROJECT_DIR = ../firmware
-#CHIBIOS = $(PROJECT_DIR)/chibios
-
-# Compiler options here.
-ifeq ($(USE_OPT),)
-# this config if debugging is needed, but the binary is about 30M
-# USE_OPT = -c -Wall -O0 -ggdb -g3 -Werror-implicit-function-declaration -Werror -Wno-error=pointer-sign -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=sign-compare -Wno-error=unused-parameter -Wno-error=missing-field-initializers -Wno-error=write-strings
-# this config producec a smaller binary file
- USE_OPT = -c -Wall -O2 -Werror-implicit-function-declaration -Werror -Wno-error=pointer-sign -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=sign-compare -Wno-error=unused-parameter -Wno-error=missing-field-initializers -Wno-error=write-strings -Wno-error=strict-aliasing
-endif
-
-# C specific options here (added to USE_OPT).
-ifeq ($(USE_COPT),)
- USE_COPT = -std=gnu99 -fgnu89-inline
-endif
-
-# C++ specific options here (added to USE_OPT).
-ifeq ($(USE_CPPOPT),)
- USE_CPPOPT = -fno-rtti -fpermissive -fno-exceptions -fno-use-cxa-atexit
-endif
-
-# Enable this if you want the linker to remove unused code and data
-ifeq ($(USE_LINK_GC),)
- USE_LINK_GC = yes
-endif
-
-# If enabled, this option allows to compile the application in THUMB mode.
-ifeq ($(USE_THUMB),)
- USE_THUMB = no
-endif
-
-# Enable this if you want to see the full log while compiling.
-ifeq ($(USE_VERBOSE_COMPILE),)
- USE_VERBOSE_COMPILE = no
-endif
-
-#
-# Build global options
-##############################################################################
-
-##############################################################################
-# Architecture or project specific options
-#
-
-
-# List all default C defines here, like -D_DEBUG=1
-DDEFS =
-
-#
-# Architecture or project specific options
-##############################################################################
-
-##############################################################################
-# Project, sources and paths
-#
-
- # Define project name here
-PROJECT = rusefi_simulator
-
-#PROJECT_BOARD = OLIMEX_STM32_E407
-#ifneq ($(PROJECT_BOARD),OLIMEX_STM32_E407)
-# PROJECT_BOARD = ST_STM32F4_DISCOVERY
-#endif
-#DDEFS += -D$(PROJECT_BOARD)
-
-CHIBIOS = ../firmware/chibios
-# Imported source files and paths
-include $(PROJECT_DIR)/util/util.mk
-include $(PROJECT_DIR)/config/engines/engines.mk
-include $(PROJECT_DIR)/controllers/algo/algo.mk
-include $(PROJECT_DIR)/controllers/math/math.mk
-include $(PROJECT_DIR)/controllers/sensors/sensors.mk
-include $(PROJECT_DIR)/controllers/trigger/trigger.mk
-include $(PROJECT_DIR)/controllers/system/system.mk
-include $(PROJECT_DIR)/console/console.mk
-include $(PROJECT_DIR)/console_util/console_util.mk
-
-include $(CHIBIOS)/boards/simulator/board.mk
-include ${CHIBIOS}/os/hal/hal.mk
-include ${CHIBIOS}/os/hal/platforms/Win32/platform.mk
-include ${CHIBIOS}/os/ports/GCC/SIMIA32/port.mk
-include ${CHIBIOS}/os/kernel/kernel.mk
-
-# Define linker script file here
-#LDSCRIPT= config/system/STM32F407xG.ld
-#LDSCRIPT= $(PORTLD)/STM32F407xG_CCM.ld
-
-# C sources that can be compiled in ARM or THUMB mode depending on the global
-# setting.
-CSRC = ${PORTSRC} \
- ${KERNSRC} \
- ${TESTSRC} \
- ${HALSRC} \
- ${PLATFORMSRC} \
- $(TRIGGERSRC) \
- $(SYSTEMSRC) \
- $(CONSOLESRC) \
- $(CONSOLEUTILSRC) \
- $(CONTROLLERS_ALGO_SRC) \
- $(CONTROLLERS_MATH_SRC) \
- $(CONTROLLERS_SENSORS_SRC) \
- $(ENGINES_SRC) \
- $(BOARDSRC) \
- ${CHIBIOS}/os/various/chprintf.c \
- ${CHIBIOS}/os/various/memstreams.c \
- $(UTILSRC) \
- simulator/rusEfiFunctionalTest.c \
- $(PROJECT_DIR)/controllers/settings.c \
- simulator/boards.c \
- main.c
-
-# C++ sources that can be compiled in ARM or THUMB mode depending on the global
-# setting.
-CPPSRC = $(UTILSRC_CPP) \
- $(CONTROLLERS_ALGO_SRC_CPP) \
- $(CONTROLLERSSRC_CPP) \
- $(SYSTEMSRC_CPP) \
- $(ENGINES_SRC_CPP) \
- $(TEST_SRC_CPP)
-# C sources to be compiled in ARM mode regardless of the global setting.
-# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
-# option that results in lower performance and larger code size.
-ACSRC =
-
-# C++ sources to be compiled in ARM mode regardless of the global setting.
-# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
-# option that results in lower performance and larger code size.
-ACPPSRC =
-
-# C sources to be compiled in THUMB mode regardless of the global setting.
-# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
-# option that results in lower performance and larger code size.
-TCSRC =
-
-# C sources to be compiled in THUMB mode regardless of the global setting.
-# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
-# option that results in lower performance and larger code size.
-TCPPSRC =
-
-# List ASM source files here
-ASMSRC = $(PORTASM)
-
-INCDIR = . \
-$(PORTINC) $(KERNINC) $(TESTINC) \
- $(HALINC) $(PLATFORMINC) $(BOARDINC) \
- $(PROJECT_DIR)/util \
- $(PROJECT_DIR)/console \
- $(PROJECT_DIR)/console_util \
- $(PROJECT_DIR)/config/engines \
- $(PROJECT_DIR)/ext_algo \
- $(PROJECT_DIR)/controllers \
- $(PROJECT_DIR)/controllers/sensors \
- $(PROJECT_DIR)/controllers/system \
- $(PROJECT_DIR)/hw_layer/algo \
- $(PROJECT_DIR)/controllers/algo \
- $(PROJECT_DIR)/controllers/math \
- $(PROJECT_DIR)/controllers/math \
- $(PROJECT_DIR)/controllers/trigger \
- ${CHIBIOS}/os/various \
- simulator
-
-
-#
-# Project, sources and paths
-##############################################################################
-
-##############################################################################
-# Compiler settings
-#
-
-#MCU = cortex-m4
-
-ifeq ($(OS),Windows_NT)
- TRGT = i686-pc-mingw32-
-else
- TRGT =
-endif
-
-CC = $(TRGT)gcc
-CPPC = $(TRGT)g++
-# Enable loading with g++ only if you need C++ runtime support.
-# NOTE: You can use C++ even without C++ support if you are careful. C++
-# runtime support makes code size explode.
-#LD = $(TRGT)gcc
-LD = $(TRGT)g++
-CP = $(TRGT)objcopy
-AS = $(TRGT)gcc -x assembler-with-cpp
-OD = $(TRGT)objdump
-HEX = $(CP) -O ihex
-BIN = $(CP) -O binary
-
-# ARM-specific options here
-AOPT =
-
-# THUMB-specific options here
-TOPT = -mthumb -DTHUMB
-
-# Define C warning options here
-CWARN = -Wall -Wextra -Wstrict-prototypes
-
-# Define C++ warning options here
-CPPWARN = -Wall -Wextra
-
-#
-# Compiler settings
-##############################################################################
-
-##############################################################################
-# Start of default section
-#
-
-# List all default ASM defines here, like -D_DEBUG=1
-DADEFS =
-
-# List all default directories to look for include files here
-DINCDIR =
-
-# List the default directory to look for the libraries here
-DLIBDIR =
-
-# List all default libraries here
-DLIBS = -static-libgcc -static-libstdc++ -lws2_32
-
-#
-# End of default section
-##############################################################################
-
-##############################################################################
-# Start of user section
-#
-
-# List all user C define here, like -D_DEBUG=1
-UDEFS =
-
-# Define ASM defines here
-UADEFS =
-
-# List all user directories here
-UINCDIR =
-
-# List the user directory to look for the libraries here
-ULIBDIR =
-
-# List all user libraries here
-ULIBS = -lm
-
-#
-# End of user defines
-##############################################################################
-
-include rules.mk
+##############################################################################
+# Build global options
+# NOTE: Can be overridden externally.
+#
+
+PROJECT_DIR = ../firmware
+#CHIBIOS = $(PROJECT_DIR)/chibios
+
+# Compiler options here.
+ifeq ($(USE_OPT),)
+# this config if debugging is needed, but the binary is about 30M
+# USE_OPT = -c -Wall -O0 -ggdb -g3 -Werror-implicit-function-declaration -Werror -Wno-error=pointer-sign -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=sign-compare -Wno-error=unused-parameter -Wno-error=missing-field-initializers -Wno-error=write-strings
+# this config producec a smaller binary file
+ USE_OPT = -c -Wall -O2 -Werror-implicit-function-declaration -Werror -Wno-error=pointer-sign -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=sign-compare -Wno-error=unused-parameter -Wno-error=missing-field-initializers -Wno-error=write-strings -Wno-error=strict-aliasing
+endif
+
+# C specific options here (added to USE_OPT).
+ifeq ($(USE_COPT),)
+ USE_COPT = -std=gnu99 -fgnu89-inline
+endif
+
+# C++ specific options here (added to USE_OPT).
+ifeq ($(USE_CPPOPT),)
+ USE_CPPOPT = -fno-rtti -fpermissive -fno-exceptions -fno-use-cxa-atexit
+endif
+
+# Enable this if you want the linker to remove unused code and data
+ifeq ($(USE_LINK_GC),)
+ USE_LINK_GC = yes
+endif
+
+# If enabled, this option allows to compile the application in THUMB mode.
+ifeq ($(USE_THUMB),)
+ USE_THUMB = no
+endif
+
+# Enable this if you want to see the full log while compiling.
+ifeq ($(USE_VERBOSE_COMPILE),)
+ USE_VERBOSE_COMPILE = no
+endif
+
+#
+# Build global options
+##############################################################################
+
+##############################################################################
+# Architecture or project specific options
+#
+
+
+# List all default C defines here, like -D_DEBUG=1
+DDEFS =
+
+#
+# Architecture or project specific options
+##############################################################################
+
+##############################################################################
+# Project, sources and paths
+#
+
+ # Define project name here
+PROJECT = rusefi_simulator
+
+#PROJECT_BOARD = OLIMEX_STM32_E407
+#ifneq ($(PROJECT_BOARD),OLIMEX_STM32_E407)
+# PROJECT_BOARD = ST_STM32F4_DISCOVERY
+#endif
+#DDEFS += -D$(PROJECT_BOARD)
+
+CHIBIOS = ../firmware/chibios
+# Imported source files and paths
+include $(PROJECT_DIR)/util/util.mk
+include $(PROJECT_DIR)/config/engines/engines.mk
+include $(PROJECT_DIR)/controllers/algo/algo.mk
+include $(PROJECT_DIR)/controllers/math/math.mk
+include $(PROJECT_DIR)/controllers/sensors/sensors.mk
+include $(PROJECT_DIR)/controllers/trigger/trigger.mk
+include $(PROJECT_DIR)/controllers/system/system.mk
+include $(PROJECT_DIR)/console/console.mk
+include $(PROJECT_DIR)/console_util/console_util.mk
+
+include $(CHIBIOS)/boards/simulator/board.mk
+include ${CHIBIOS}/os/hal/hal.mk
+include ${CHIBIOS}/os/hal/platforms/Win32/platform.mk
+include ${CHIBIOS}/os/ports/GCC/SIMIA32/port.mk
+include ${CHIBIOS}/os/kernel/kernel.mk
+
+# Define linker script file here
+#LDSCRIPT= config/system/STM32F407xG.ld
+#LDSCRIPT= $(PORTLD)/STM32F407xG_CCM.ld
+
+# C sources that can be compiled in ARM or THUMB mode depending on the global
+# setting.
+CSRC = ${PORTSRC} \
+ ${KERNSRC} \
+ ${TESTSRC} \
+ ${HALSRC} \
+ ${PLATFORMSRC} \
+ $(TRIGGER_SRC) \
+ $(SYSTEMSRC) \
+ $(CONSOLESRC) \
+ $(CONSOLEUTILSRC) \
+ $(CONTROLLERS_ALGO_SRC) \
+ $(CONTROLLERS_MATH_SRC) \
+ $(CONTROLLERS_SENSORS_SRC) \
+ $(ENGINES_SRC) \
+ $(BOARDSRC) \
+ ${CHIBIOS}/os/various/chprintf.c \
+ ${CHIBIOS}/os/various/memstreams.c \
+ $(UTILSRC) \
+ simulator/rusEfiFunctionalTest.c \
+ simulator/boards.c \
+ $(PROJECT_DIR)/emulation/analog_chart.c \
+ main.c
+
+# C++ sources that can be compiled in ARM or THUMB mode depending on the global
+# setting.
+CPPSRC = $(UTILSRC_CPP) \
+ $(CONTROLLERS_ALGO_SRC_CPP) \
+ $(PROJECT_DIR)/controllers/settings.cpp \
+ $(TRIGGER_SRC_CPP) \
+ $(SYSTEMSRC_CPP) \
+ $(CONTROLLERS_MATH_SRC_CPP) \
+ $(ENGINES_SRC_CPP) \
+ $(TEST_SRC_CPP)
+# C sources to be compiled in ARM mode regardless of the global setting.
+# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
+# option that results in lower performance and larger code size.
+ACSRC =
+
+# C++ sources to be compiled in ARM mode regardless of the global setting.
+# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
+# option that results in lower performance and larger code size.
+ACPPSRC =
+
+# C sources to be compiled in THUMB mode regardless of the global setting.
+# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
+# option that results in lower performance and larger code size.
+TCSRC =
+
+# C sources to be compiled in THUMB mode regardless of the global setting.
+# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
+# option that results in lower performance and larger code size.
+TCPPSRC =
+
+# List ASM source files here
+ASMSRC = $(PORTASM)
+
+INCDIR = . \
+$(PORTINC) $(KERNINC) $(TESTINC) \
+ $(HALINC) $(PLATFORMINC) $(BOARDINC) \
+ $(PROJECT_DIR)/util \
+ $(PROJECT_DIR)/console \
+ $(PROJECT_DIR)/console_util \
+ $(PROJECT_DIR)/config/engines \
+ $(PROJECT_DIR)/ext_algo \
+ $(PROJECT_DIR)/controllers \
+ $(PROJECT_DIR)/controllers/sensors \
+ $(PROJECT_DIR)/controllers/system \
+ $(PROJECT_DIR)/hw_layer/algo \
+ $(PROJECT_DIR)/emulation \
+ $(PROJECT_DIR)/controllers/algo \
+ $(PROJECT_DIR)/controllers/math \
+ $(PROJECT_DIR)/controllers/math \
+ $(PROJECT_DIR)/controllers/trigger \
+ ${CHIBIOS}/os/various \
+ simulator
+
+
+#
+# Project, sources and paths
+##############################################################################
+
+##############################################################################
+# Compiler settings
+#
+
+#MCU = cortex-m4
+
+ifeq ($(OS),Windows_NT)
+ TRGT = i686-pc-mingw32-
+else
+ TRGT =
+endif
+
+CC = $(TRGT)gcc
+CPPC = $(TRGT)g++
+# Enable loading with g++ only if you need C++ runtime support.
+# NOTE: You can use C++ even without C++ support if you are careful. C++
+# runtime support makes code size explode.
+#LD = $(TRGT)gcc
+LD = $(TRGT)g++
+CP = $(TRGT)objcopy
+AS = $(TRGT)gcc -x assembler-with-cpp
+OD = $(TRGT)objdump
+HEX = $(CP) -O ihex
+BIN = $(CP) -O binary
+
+# ARM-specific options here
+AOPT =
+
+# THUMB-specific options here
+TOPT = -mthumb -DTHUMB
+
+# Define C warning options here
+CWARN = -Wall -Wextra -Wstrict-prototypes
+
+# Define C++ warning options here
+CPPWARN = -Wall -Wextra
+
+#
+# Compiler settings
+##############################################################################
+
+##############################################################################
+# Start of default section
+#
+
+# List all default ASM defines here, like -D_DEBUG=1
+DADEFS =
+
+# List all default directories to look for include files here
+DINCDIR =
+
+# List the default directory to look for the libraries here
+DLIBDIR =
+
+# List all default libraries here
+DLIBS = -static-libgcc -static-libstdc++ -lws2_32
+
+#
+# End of default section
+##############################################################################
+
+##############################################################################
+# Start of user section
+#
+
+# List all user C define here, like -D_DEBUG=1
+UDEFS =
+
+# Define ASM defines here
+UADEFS =
+
+# List all user directories here
+UINCDIR =
+
+# List the user directory to look for the libraries here
+ULIBDIR =
+
+# List all user libraries here
+ULIBS = -lm
+
+#
+# End of user defines
+##############################################################################
+
+include rules.mk
diff --git a/win32_functional_tests/chconf.h b/win32_functional_tests/chconf.h
index a96eeea1cb..c364f3cc23 100644
--- a/win32_functional_tests/chconf.h
+++ b/win32_functional_tests/chconf.h
@@ -1,534 +1,534 @@
-/*
- ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-/**
- * @file templates/chconf.h
- * @brief Configuration file template.
- * @details A copy of this file must be placed in each project directory, it
- * contains the application specific kernel settings.
- *
- * @addtogroup config
- * @details Kernel related settings and hooks.
- * @{
- */
-
-#ifndef _CHCONF_H_
-#define _CHCONF_H_
-
-#define CHPRINTF_USE_FLOAT TRUE
-
-/*===========================================================================*/
-/**
- * @name Kernel parameters and options
- * @{
- */
-/*===========================================================================*/
-
-/**
- * @brief System tick frequency.
- * @details Frequency of the system timer that drives the system ticks. This
- * setting also defines the system tick time unit.
- */
-#if !defined(CH_FREQUENCY) || defined(__DOXYGEN__)
-#define CH_FREQUENCY 100000
-#endif
-
-/**
- * @brief Round robin interval.
- * @details This constant is the number of system ticks allowed for the
- * threads before preemption occurs. Setting this value to zero
- * disables the preemption for threads with equal priority and the
- * round robin becomes cooperative. Note that higher priority
- * threads can still preempt, the kernel is always preemptive.
- *
- * @note Disabling the round robin preemption makes the kernel more compact
- * and generally faster.
- */
-#if !defined(CH_TIME_QUANTUM) || defined(__DOXYGEN__)
-#define CH_TIME_QUANTUM 20
-#endif
-
-/**
- * @brief Managed RAM size.
- * @details Size of the RAM area to be managed by the OS. If set to zero
- * then the whole available RAM is used. The core memory is made
- * available to the heap allocator and/or can be used directly through
- * the simplified core memory allocator.
- *
- * @note In order to let the OS manage the whole RAM the linker script must
- * provide the @p __heap_base__ and @p __heap_end__ symbols.
- * @note Requires @p CH_USE_MEMCORE.
- */
-#if !defined(CH_MEMCORE_SIZE) || defined(__DOXYGEN__)
-#define CH_MEMCORE_SIZE 0x20000
-#endif
-
-/**
- * @brief Idle thread automatic spawn suppression.
- * @details When this option is activated the function @p chSysInit()
- * does not spawn the idle thread automatically. The application has
- * then the responsibility to do one of the following:
- * - Spawn a custom idle thread at priority @p IDLEPRIO.
- * - Change the main() thread priority to @p IDLEPRIO then enter
- * an endless loop. In this scenario the @p main() thread acts as
- * the idle thread.
- * .
- * @note Unless an idle thread is spawned the @p main() thread must not
- * enter a sleep state.
- */
-#if !defined(CH_NO_IDLE_THREAD) || defined(__DOXYGEN__)
-#define CH_NO_IDLE_THREAD FALSE
-#endif
-
-/** @} */
-
-/*===========================================================================*/
-/**
- * @name Performance options
- * @{
- */
-/*===========================================================================*/
-
-/**
- * @brief OS optimization.
- * @details If enabled then time efficient rather than space efficient code
- * is used when two possible implementations exist.
- *
- * @note This is not related to the compiler optimization options.
- * @note The default is @p TRUE.
- */
-#if !defined(CH_OPTIMIZE_SPEED) || defined(__DOXYGEN__)
-#define CH_OPTIMIZE_SPEED TRUE
-#endif
-
-/** @} */
-
-/*===========================================================================*/
-/**
- * @name Subsystem options
- * @{
- */
-/*===========================================================================*/
-
-/**
- * @brief Threads registry APIs.
- * @details If enabled then the registry APIs are included in the kernel.
- *
- * @note The default is @p TRUE.
- */
-#if !defined(CH_USE_REGISTRY) || defined(__DOXYGEN__)
-#define CH_USE_REGISTRY TRUE
-#endif
-
-/**
- * @brief Threads synchronization APIs.
- * @details If enabled then the @p chThdWait() function is included in
- * the kernel.
- *
- * @note The default is @p TRUE.
- */
-#if !defined(CH_USE_WAITEXIT) || defined(__DOXYGEN__)
-#define CH_USE_WAITEXIT TRUE
-#endif
-
-/**
- * @brief Semaphores APIs.
- * @details If enabled then the Semaphores APIs are included in the kernel.
- *
- * @note The default is @p TRUE.
- */
-#if !defined(CH_USE_SEMAPHORES) || defined(__DOXYGEN__)
-#define CH_USE_SEMAPHORES TRUE
-#endif
-
-/**
- * @brief Semaphores queuing mode.
- * @details If enabled then the threads are enqueued on semaphores by
- * priority rather than in FIFO order.
- *
- * @note The default is @p FALSE. Enable this if you have special requirements.
- * @note Requires @p CH_USE_SEMAPHORES.
- */
-#if !defined(CH_USE_SEMAPHORES_PRIORITY) || defined(__DOXYGEN__)
-#define CH_USE_SEMAPHORES_PRIORITY FALSE
-#endif
-
-/**
- * @brief Atomic semaphore API.
- * @details If enabled then the semaphores the @p chSemSignalWait() API
- * is included in the kernel.
- *
- * @note The default is @p TRUE.
- * @note Requires @p CH_USE_SEMAPHORES.
- */
-#if !defined(CH_USE_SEMSW) || defined(__DOXYGEN__)
-#define CH_USE_SEMSW TRUE
-#endif
-
-/**
- * @brief Mutexes APIs.
- * @details If enabled then the mutexes APIs are included in the kernel.
- *
- * @note The default is @p TRUE.
- */
-#if !defined(CH_USE_MUTEXES) || defined(__DOXYGEN__)
-#define CH_USE_MUTEXES TRUE
-#endif
-
-/**
- * @brief Conditional Variables APIs.
- * @details If enabled then the conditional variables APIs are included
- * in the kernel.
- *
- * @note The default is @p TRUE.
- * @note Requires @p CH_USE_MUTEXES.
- */
-#if !defined(CH_USE_CONDVARS) || defined(__DOXYGEN__)
-#define CH_USE_CONDVARS TRUE
-#endif
-
-/**
- * @brief Conditional Variables APIs with timeout.
- * @details If enabled then the conditional variables APIs with timeout
- * specification are included in the kernel.
- *
- * @note The default is @p TRUE.
- * @note Requires @p CH_USE_CONDVARS.
- */
-#if !defined(CH_USE_CONDVARS_TIMEOUT) || defined(__DOXYGEN__)
-#define CH_USE_CONDVARS_TIMEOUT TRUE
-#endif
-
-/**
- * @brief Events Flags APIs.
- * @details If enabled then the event flags APIs are included in the kernel.
- *
- * @note The default is @p TRUE.
- */
-#if !defined(CH_USE_EVENTS) || defined(__DOXYGEN__)
-#define CH_USE_EVENTS TRUE
-#endif
-
-/**
- * @brief Events Flags APIs with timeout.
- * @details If enabled then the events APIs with timeout specification
- * are included in the kernel.
- *
- * @note The default is @p TRUE.
- * @note Requires @p CH_USE_EVENTS.
- */
-#if !defined(CH_USE_EVENTS_TIMEOUT) || defined(__DOXYGEN__)
-#define CH_USE_EVENTS_TIMEOUT TRUE
-#endif
-
-/**
- * @brief Synchronous Messages APIs.
- * @details If enabled then the synchronous messages APIs are included
- * in the kernel.
- *
- * @note The default is @p TRUE.
- */
-#if !defined(CH_USE_MESSAGES) || defined(__DOXYGEN__)
-#define CH_USE_MESSAGES TRUE
-#endif
-
-/**
- * @brief Synchronous Messages queuing mode.
- * @details If enabled then messages are served by priority rather than in
- * FIFO order.
- *
- * @note The default is @p FALSE. Enable this if you have special requirements.
- * @note Requires @p CH_USE_MESSAGES.
- */
-#if !defined(CH_USE_MESSAGES_PRIORITY) || defined(__DOXYGEN__)
-#define CH_USE_MESSAGES_PRIORITY FALSE
-#endif
-
-/**
- * @brief Mailboxes APIs.
- * @details If enabled then the asynchronous messages (mailboxes) APIs are
- * included in the kernel.
- *
- * @note The default is @p TRUE.
- * @note Requires @p CH_USE_SEMAPHORES.
- */
-#if !defined(CH_USE_MAILBOXES) || defined(__DOXYGEN__)
-#define CH_USE_MAILBOXES TRUE
-#endif
-
-/**
- * @brief I/O Queues APIs.
- * @details If enabled then the I/O queues APIs are included in the kernel.
- *
- * @note The default is @p TRUE.
- */
-#if !defined(CH_USE_QUEUES) || defined(__DOXYGEN__)
-#define CH_USE_QUEUES TRUE
-#endif
-
-/**
- * @brief Core Memory Manager APIs.
- * @details If enabled then the core memory manager APIs are included
- * in the kernel.
- *
- * @note The default is @p TRUE.
- */
-#if !defined(CH_USE_MEMCORE) || defined(__DOXYGEN__)
-#define CH_USE_MEMCORE TRUE
-#endif
-
-/**
- * @brief Heap Allocator APIs.
- * @details If enabled then the memory heap allocator APIs are included
- * in the kernel.
- *
- * @note The default is @p TRUE.
- * @note Requires @p CH_USE_MEMCORE and either @p CH_USE_MUTEXES or
- * @p CH_USE_SEMAPHORES.
- * @note Mutexes are recommended.
- */
-#if !defined(CH_USE_HEAP) || defined(__DOXYGEN__)
-#define CH_USE_HEAP TRUE
-#endif
-
-/**
- * @brief C-runtime allocator.
- * @details If enabled the the heap allocator APIs just wrap the C-runtime
- * @p malloc() and @p free() functions.
- *
- * @note The default is @p FALSE.
- * @note Requires @p CH_USE_HEAP.
- * @note The C-runtime may or may not require @p CH_USE_MEMCORE, see the
- * appropriate documentation.
- */
-#if !defined(CH_USE_MALLOC_HEAP) || defined(__DOXYGEN__)
-#define CH_USE_MALLOC_HEAP FALSE
-#endif
-
-/**
- * @brief Memory Pools Allocator APIs.
- * @details If enabled then the memory pools allocator APIs are included
- * in the kernel.
- *
- * @note The default is @p TRUE.
- */
-#if !defined(CH_USE_MEMPOOLS) || defined(__DOXYGEN__)
-#define CH_USE_MEMPOOLS TRUE
-#endif
-
-/**
- * @brief Dynamic Threads APIs.
- * @details If enabled then the dynamic threads creation APIs are included
- * in the kernel.
- *
- * @note The default is @p TRUE.
- * @note Requires @p CH_USE_WAITEXIT.
- * @note Requires @p CH_USE_HEAP and/or @p CH_USE_MEMPOOLS.
- */
-#if !defined(CH_USE_DYNAMIC) || defined(__DOXYGEN__)
-#define CH_USE_DYNAMIC TRUE
-#endif
-
-/** @} */
-
-/*===========================================================================*/
-/**
- * @name Debug options
- * @{
- */
-/*===========================================================================*/
-
-/**
- * @brief Debug option, system state check.
- * @details If enabled the correct call protocol for system APIs is checked
- * at runtime.
- *
- * @note The default is @p FALSE.
- */
-#if !defined(CH_DBG_SYSTEM_STATE_CHECK) || defined(__DOXYGEN__)
-#define CH_DBG_SYSTEM_STATE_CHECK TRUE
-#endif
-
-/**
- * @brief Debug option, parameters checks.
- * @details If enabled then the checks on the API functions input
- * parameters are activated.
- *
- * @note The default is @p FALSE.
- */
-#if !defined(CH_DBG_ENABLE_CHECKS) || defined(__DOXYGEN__)
-#define CH_DBG_ENABLE_CHECKS TRUE
-#endif
-
-/**
- * @brief Debug option, consistency checks.
- * @details If enabled then all the assertions in the kernel code are
- * activated. This includes consistency checks inside the kernel,
- * runtime anomalies and port-defined checks.
- *
- * @note The default is @p FALSE.
- */
-#if !defined(CH_DBG_ENABLE_ASSERTS) || defined(__DOXYGEN__)
-#define CH_DBG_ENABLE_ASSERTS TRUE
-#endif
-
-/**
- * @brief Debug option, trace buffer.
- * @details If enabled then the context switch circular trace buffer is
- * activated.
- *
- * @note The default is @p FALSE.
- */
-#if !defined(CH_DBG_ENABLE_TRACE) || defined(__DOXYGEN__)
-#define CH_DBG_ENABLE_TRACE FALSE
-#endif
-
-/**
- * @brief Debug option, stack checks.
- * @details If enabled then a runtime stack check is performed.
- *
- * @note The default is @p FALSE.
- * @note The stack check is performed in a architecture/port dependent way.
- * It may not be implemented or some ports.
- * @note The default failure mode is to halt the system with the global
- * @p panic_msg variable set to @p NULL.
- */
-#if !defined(CH_DBG_ENABLE_STACK_CHECK) || defined(__DOXYGEN__)
-#define CH_DBG_ENABLE_STACK_CHECK FALSE
-#endif
-
-/**
- * @brief Debug option, stacks initialization.
- * @details If enabled then the threads working area is filled with a byte
- * value when a thread is created. This can be useful for the
- * runtime measurement of the used stack.
- *
- * @note The default is @p FALSE.
- */
-#if !defined(CH_DBG_FILL_THREADS) || defined(__DOXYGEN__)
-#define CH_DBG_FILL_THREADS FALSE
-#endif
-
-/**
- * @brief Debug option, threads profiling.
- * @details If enabled then a field is added to the @p Thread structure that
- * counts the system ticks occurred while executing the thread.
- *
- * @note The default is @p TRUE.
- * @note This debug option is defaulted to TRUE because it is required by
- * some test cases into the test suite.
- */
-#if !defined(CH_DBG_THREADS_PROFILING) || defined(__DOXYGEN__)
-#define CH_DBG_THREADS_PROFILING TRUE
-#endif
-
-/** @} */
-
-/*===========================================================================*/
-/**
- * @name Kernel hooks
- * @{
- */
-/*===========================================================================*/
-
-/**
- * @brief Threads descriptor structure extension.
- * @details User fields added to the end of the @p Thread structure.
- */
-#if !defined(THREAD_EXT_FIELDS) || defined(__DOXYGEN__)
-#define THREAD_EXT_FIELDS \
- /* Add threads custom fields here.*/
-#endif
-
-/**
- * @brief Threads initialization hook.
- * @details User initialization code added to the @p chThdInit() API.
- *
- * @note It is invoked from within @p chThdInit() and implicitly from all
- * the threads creation APIs.
- */
-#if !defined(THREAD_EXT_INIT_HOOK) || defined(__DOXYGEN__)
-#define THREAD_EXT_INIT_HOOK(tp) { \
- /* Add threads initialization code here.*/ \
-}
-#endif
-
-/**
- * @brief Threads finalization hook.
- * @details User finalization code added to the @p chThdExit() API.
- *
- * @note It is inserted into lock zone.
- * @note It is also invoked when the threads simply return in order to
- * terminate.
- */
-#if !defined(THREAD_EXT_EXIT_HOOK) || defined(__DOXYGEN__)
-#define THREAD_EXT_EXIT_HOOK(tp) { \
- /* Add threads finalization code here.*/ \
-}
-#endif
-
-/**
- * @brief Context switch hook.
- * @details This hook is invoked just before switching between threads.
- */
-#if !defined(THREAD_CONTEXT_SWITCH_HOOK) || defined(__DOXYGEN__)
-#define THREAD_CONTEXT_SWITCH_HOOK(ntp, otp) { \
- /* System halt code here.*/ \
-}
-#endif
-
-/**
- * @brief Idle Loop hook.
- * @details This hook is continuously invoked by the idle thread loop.
- */
-#if !defined(IDLE_LOOP_HOOK) || defined(__DOXYGEN__)
-#define IDLE_LOOP_HOOK() { \
- /* Idle loop code here.*/ \
-}
-#endif
-
-/**
- * @brief System tick event hook.
- * @details This hook is invoked in the system tick handler immediately
- * after processing the virtual timers queue.
- */
-#if !defined(SYSTEM_TICK_EVENT_HOOK) || defined(__DOXYGEN__)
-#define SYSTEM_TICK_EVENT_HOOK() { \
- /* System tick event code here.*/ \
-}
-#endif
-
-
-/**
- * @brief System halt hook.
- * @details This hook is invoked in case to a system halting error before
- * the system is halted.
- */
-#if !defined(SYSTEM_HALT_HOOK) || defined(__DOXYGEN__)
-#define SYSTEM_HALT_HOOK() { \
- /* System halt code here.*/ \
-}
-#endif
-
-/** @} */
-
-/*===========================================================================*/
-/* Port-specific settings (override port settings defaulted in chcore.h). */
-/*===========================================================================*/
-
-#endif /* _CHCONF_H_ */
-
-/** @} */
+/*
+ ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+/**
+ * @file templates/chconf.h
+ * @brief Configuration file template.
+ * @details A copy of this file must be placed in each project directory, it
+ * contains the application specific kernel settings.
+ *
+ * @addtogroup config
+ * @details Kernel related settings and hooks.
+ * @{
+ */
+
+#ifndef _CHCONF_H_
+#define _CHCONF_H_
+
+#define CHPRINTF_USE_FLOAT TRUE
+
+/*===========================================================================*/
+/**
+ * @name Kernel parameters and options
+ * @{
+ */
+/*===========================================================================*/
+
+/**
+ * @brief System tick frequency.
+ * @details Frequency of the system timer that drives the system ticks. This
+ * setting also defines the system tick time unit.
+ */
+#if !defined(CH_FREQUENCY) || defined(__DOXYGEN__)
+#define CH_FREQUENCY 100000
+#endif
+
+/**
+ * @brief Round robin interval.
+ * @details This constant is the number of system ticks allowed for the
+ * threads before preemption occurs. Setting this value to zero
+ * disables the preemption for threads with equal priority and the
+ * round robin becomes cooperative. Note that higher priority
+ * threads can still preempt, the kernel is always preemptive.
+ *
+ * @note Disabling the round robin preemption makes the kernel more compact
+ * and generally faster.
+ */
+#if !defined(CH_TIME_QUANTUM) || defined(__DOXYGEN__)
+#define CH_TIME_QUANTUM 20
+#endif
+
+/**
+ * @brief Managed RAM size.
+ * @details Size of the RAM area to be managed by the OS. If set to zero
+ * then the whole available RAM is used. The core memory is made
+ * available to the heap allocator and/or can be used directly through
+ * the simplified core memory allocator.
+ *
+ * @note In order to let the OS manage the whole RAM the linker script must
+ * provide the @p __heap_base__ and @p __heap_end__ symbols.
+ * @note Requires @p CH_USE_MEMCORE.
+ */
+#if !defined(CH_MEMCORE_SIZE) || defined(__DOXYGEN__)
+#define CH_MEMCORE_SIZE 0x20000
+#endif
+
+/**
+ * @brief Idle thread automatic spawn suppression.
+ * @details When this option is activated the function @p chSysInit()
+ * does not spawn the idle thread automatically. The application has
+ * then the responsibility to do one of the following:
+ * - Spawn a custom idle thread at priority @p IDLEPRIO.
+ * - Change the main() thread priority to @p IDLEPRIO then enter
+ * an endless loop. In this scenario the @p main() thread acts as
+ * the idle thread.
+ * .
+ * @note Unless an idle thread is spawned the @p main() thread must not
+ * enter a sleep state.
+ */
+#if !defined(CH_NO_IDLE_THREAD) || defined(__DOXYGEN__)
+#define CH_NO_IDLE_THREAD FALSE
+#endif
+
+/** @} */
+
+/*===========================================================================*/
+/**
+ * @name Performance options
+ * @{
+ */
+/*===========================================================================*/
+
+/**
+ * @brief OS optimization.
+ * @details If enabled then time efficient rather than space efficient code
+ * is used when two possible implementations exist.
+ *
+ * @note This is not related to the compiler optimization options.
+ * @note The default is @p TRUE.
+ */
+#if !defined(CH_OPTIMIZE_SPEED) || defined(__DOXYGEN__)
+#define CH_OPTIMIZE_SPEED TRUE
+#endif
+
+/** @} */
+
+/*===========================================================================*/
+/**
+ * @name Subsystem options
+ * @{
+ */
+/*===========================================================================*/
+
+/**
+ * @brief Threads registry APIs.
+ * @details If enabled then the registry APIs are included in the kernel.
+ *
+ * @note The default is @p TRUE.
+ */
+#if !defined(CH_USE_REGISTRY) || defined(__DOXYGEN__)
+#define CH_USE_REGISTRY TRUE
+#endif
+
+/**
+ * @brief Threads synchronization APIs.
+ * @details If enabled then the @p chThdWait() function is included in
+ * the kernel.
+ *
+ * @note The default is @p TRUE.
+ */
+#if !defined(CH_USE_WAITEXIT) || defined(__DOXYGEN__)
+#define CH_USE_WAITEXIT TRUE
+#endif
+
+/**
+ * @brief Semaphores APIs.
+ * @details If enabled then the Semaphores APIs are included in the kernel.
+ *
+ * @note The default is @p TRUE.
+ */
+#if !defined(CH_USE_SEMAPHORES) || defined(__DOXYGEN__)
+#define CH_USE_SEMAPHORES TRUE
+#endif
+
+/**
+ * @brief Semaphores queuing mode.
+ * @details If enabled then the threads are enqueued on semaphores by
+ * priority rather than in FIFO order.
+ *
+ * @note The default is @p FALSE. Enable this if you have special requirements.
+ * @note Requires @p CH_USE_SEMAPHORES.
+ */
+#if !defined(CH_USE_SEMAPHORES_PRIORITY) || defined(__DOXYGEN__)
+#define CH_USE_SEMAPHORES_PRIORITY FALSE
+#endif
+
+/**
+ * @brief Atomic semaphore API.
+ * @details If enabled then the semaphores the @p chSemSignalWait() API
+ * is included in the kernel.
+ *
+ * @note The default is @p TRUE.
+ * @note Requires @p CH_USE_SEMAPHORES.
+ */
+#if !defined(CH_USE_SEMSW) || defined(__DOXYGEN__)
+#define CH_USE_SEMSW TRUE
+#endif
+
+/**
+ * @brief Mutexes APIs.
+ * @details If enabled then the mutexes APIs are included in the kernel.
+ *
+ * @note The default is @p TRUE.
+ */
+#if !defined(CH_USE_MUTEXES) || defined(__DOXYGEN__)
+#define CH_USE_MUTEXES TRUE
+#endif
+
+/**
+ * @brief Conditional Variables APIs.
+ * @details If enabled then the conditional variables APIs are included
+ * in the kernel.
+ *
+ * @note The default is @p TRUE.
+ * @note Requires @p CH_USE_MUTEXES.
+ */
+#if !defined(CH_USE_CONDVARS) || defined(__DOXYGEN__)
+#define CH_USE_CONDVARS TRUE
+#endif
+
+/**
+ * @brief Conditional Variables APIs with timeout.
+ * @details If enabled then the conditional variables APIs with timeout
+ * specification are included in the kernel.
+ *
+ * @note The default is @p TRUE.
+ * @note Requires @p CH_USE_CONDVARS.
+ */
+#if !defined(CH_USE_CONDVARS_TIMEOUT) || defined(__DOXYGEN__)
+#define CH_USE_CONDVARS_TIMEOUT TRUE
+#endif
+
+/**
+ * @brief Events Flags APIs.
+ * @details If enabled then the event flags APIs are included in the kernel.
+ *
+ * @note The default is @p TRUE.
+ */
+#if !defined(CH_USE_EVENTS) || defined(__DOXYGEN__)
+#define CH_USE_EVENTS TRUE
+#endif
+
+/**
+ * @brief Events Flags APIs with timeout.
+ * @details If enabled then the events APIs with timeout specification
+ * are included in the kernel.
+ *
+ * @note The default is @p TRUE.
+ * @note Requires @p CH_USE_EVENTS.
+ */
+#if !defined(CH_USE_EVENTS_TIMEOUT) || defined(__DOXYGEN__)
+#define CH_USE_EVENTS_TIMEOUT TRUE
+#endif
+
+/**
+ * @brief Synchronous Messages APIs.
+ * @details If enabled then the synchronous messages APIs are included
+ * in the kernel.
+ *
+ * @note The default is @p TRUE.
+ */
+#if !defined(CH_USE_MESSAGES) || defined(__DOXYGEN__)
+#define CH_USE_MESSAGES TRUE
+#endif
+
+/**
+ * @brief Synchronous Messages queuing mode.
+ * @details If enabled then messages are served by priority rather than in
+ * FIFO order.
+ *
+ * @note The default is @p FALSE. Enable this if you have special requirements.
+ * @note Requires @p CH_USE_MESSAGES.
+ */
+#if !defined(CH_USE_MESSAGES_PRIORITY) || defined(__DOXYGEN__)
+#define CH_USE_MESSAGES_PRIORITY FALSE
+#endif
+
+/**
+ * @brief Mailboxes APIs.
+ * @details If enabled then the asynchronous messages (mailboxes) APIs are
+ * included in the kernel.
+ *
+ * @note The default is @p TRUE.
+ * @note Requires @p CH_USE_SEMAPHORES.
+ */
+#if !defined(CH_USE_MAILBOXES) || defined(__DOXYGEN__)
+#define CH_USE_MAILBOXES TRUE
+#endif
+
+/**
+ * @brief I/O Queues APIs.
+ * @details If enabled then the I/O queues APIs are included in the kernel.
+ *
+ * @note The default is @p TRUE.
+ */
+#if !defined(CH_USE_QUEUES) || defined(__DOXYGEN__)
+#define CH_USE_QUEUES TRUE
+#endif
+
+/**
+ * @brief Core Memory Manager APIs.
+ * @details If enabled then the core memory manager APIs are included
+ * in the kernel.
+ *
+ * @note The default is @p TRUE.
+ */
+#if !defined(CH_USE_MEMCORE) || defined(__DOXYGEN__)
+#define CH_USE_MEMCORE TRUE
+#endif
+
+/**
+ * @brief Heap Allocator APIs.
+ * @details If enabled then the memory heap allocator APIs are included
+ * in the kernel.
+ *
+ * @note The default is @p TRUE.
+ * @note Requires @p CH_USE_MEMCORE and either @p CH_USE_MUTEXES or
+ * @p CH_USE_SEMAPHORES.
+ * @note Mutexes are recommended.
+ */
+#if !defined(CH_USE_HEAP) || defined(__DOXYGEN__)
+#define CH_USE_HEAP TRUE
+#endif
+
+/**
+ * @brief C-runtime allocator.
+ * @details If enabled the the heap allocator APIs just wrap the C-runtime
+ * @p malloc() and @p free() functions.
+ *
+ * @note The default is @p FALSE.
+ * @note Requires @p CH_USE_HEAP.
+ * @note The C-runtime may or may not require @p CH_USE_MEMCORE, see the
+ * appropriate documentation.
+ */
+#if !defined(CH_USE_MALLOC_HEAP) || defined(__DOXYGEN__)
+#define CH_USE_MALLOC_HEAP FALSE
+#endif
+
+/**
+ * @brief Memory Pools Allocator APIs.
+ * @details If enabled then the memory pools allocator APIs are included
+ * in the kernel.
+ *
+ * @note The default is @p TRUE.
+ */
+#if !defined(CH_USE_MEMPOOLS) || defined(__DOXYGEN__)
+#define CH_USE_MEMPOOLS TRUE
+#endif
+
+/**
+ * @brief Dynamic Threads APIs.
+ * @details If enabled then the dynamic threads creation APIs are included
+ * in the kernel.
+ *
+ * @note The default is @p TRUE.
+ * @note Requires @p CH_USE_WAITEXIT.
+ * @note Requires @p CH_USE_HEAP and/or @p CH_USE_MEMPOOLS.
+ */
+#if !defined(CH_USE_DYNAMIC) || defined(__DOXYGEN__)
+#define CH_USE_DYNAMIC TRUE
+#endif
+
+/** @} */
+
+/*===========================================================================*/
+/**
+ * @name Debug options
+ * @{
+ */
+/*===========================================================================*/
+
+/**
+ * @brief Debug option, system state check.
+ * @details If enabled the correct call protocol for system APIs is checked
+ * at runtime.
+ *
+ * @note The default is @p FALSE.
+ */
+#if !defined(CH_DBG_SYSTEM_STATE_CHECK) || defined(__DOXYGEN__)
+#define CH_DBG_SYSTEM_STATE_CHECK TRUE
+#endif
+
+/**
+ * @brief Debug option, parameters checks.
+ * @details If enabled then the checks on the API functions input
+ * parameters are activated.
+ *
+ * @note The default is @p FALSE.
+ */
+#if !defined(CH_DBG_ENABLE_CHECKS) || defined(__DOXYGEN__)
+#define CH_DBG_ENABLE_CHECKS TRUE
+#endif
+
+/**
+ * @brief Debug option, consistency checks.
+ * @details If enabled then all the assertions in the kernel code are
+ * activated. This includes consistency checks inside the kernel,
+ * runtime anomalies and port-defined checks.
+ *
+ * @note The default is @p FALSE.
+ */
+#if !defined(CH_DBG_ENABLE_ASSERTS) || defined(__DOXYGEN__)
+#define CH_DBG_ENABLE_ASSERTS TRUE
+#endif
+
+/**
+ * @brief Debug option, trace buffer.
+ * @details If enabled then the context switch circular trace buffer is
+ * activated.
+ *
+ * @note The default is @p FALSE.
+ */
+#if !defined(CH_DBG_ENABLE_TRACE) || defined(__DOXYGEN__)
+#define CH_DBG_ENABLE_TRACE FALSE
+#endif
+
+/**
+ * @brief Debug option, stack checks.
+ * @details If enabled then a runtime stack check is performed.
+ *
+ * @note The default is @p FALSE.
+ * @note The stack check is performed in a architecture/port dependent way.
+ * It may not be implemented or some ports.
+ * @note The default failure mode is to halt the system with the global
+ * @p panic_msg variable set to @p NULL.
+ */
+#if !defined(CH_DBG_ENABLE_STACK_CHECK) || defined(__DOXYGEN__)
+#define CH_DBG_ENABLE_STACK_CHECK FALSE
+#endif
+
+/**
+ * @brief Debug option, stacks initialization.
+ * @details If enabled then the threads working area is filled with a byte
+ * value when a thread is created. This can be useful for the
+ * runtime measurement of the used stack.
+ *
+ * @note The default is @p FALSE.
+ */
+#if !defined(CH_DBG_FILL_THREADS) || defined(__DOXYGEN__)
+#define CH_DBG_FILL_THREADS FALSE
+#endif
+
+/**
+ * @brief Debug option, threads profiling.
+ * @details If enabled then a field is added to the @p Thread structure that
+ * counts the system ticks occurred while executing the thread.
+ *
+ * @note The default is @p TRUE.
+ * @note This debug option is defaulted to TRUE because it is required by
+ * some test cases into the test suite.
+ */
+#if !defined(CH_DBG_THREADS_PROFILING) || defined(__DOXYGEN__)
+#define CH_DBG_THREADS_PROFILING TRUE
+#endif
+
+/** @} */
+
+/*===========================================================================*/
+/**
+ * @name Kernel hooks
+ * @{
+ */
+/*===========================================================================*/
+
+/**
+ * @brief Threads descriptor structure extension.
+ * @details User fields added to the end of the @p Thread structure.
+ */
+#if !defined(THREAD_EXT_FIELDS) || defined(__DOXYGEN__)
+#define THREAD_EXT_FIELDS \
+ /* Add threads custom fields here.*/
+#endif
+
+/**
+ * @brief Threads initialization hook.
+ * @details User initialization code added to the @p chThdInit() API.
+ *
+ * @note It is invoked from within @p chThdInit() and implicitly from all
+ * the threads creation APIs.
+ */
+#if !defined(THREAD_EXT_INIT_HOOK) || defined(__DOXYGEN__)
+#define THREAD_EXT_INIT_HOOK(tp) { \
+ /* Add threads initialization code here.*/ \
+}
+#endif
+
+/**
+ * @brief Threads finalization hook.
+ * @details User finalization code added to the @p chThdExit() API.
+ *
+ * @note It is inserted into lock zone.
+ * @note It is also invoked when the threads simply return in order to
+ * terminate.
+ */
+#if !defined(THREAD_EXT_EXIT_HOOK) || defined(__DOXYGEN__)
+#define THREAD_EXT_EXIT_HOOK(tp) { \
+ /* Add threads finalization code here.*/ \
+}
+#endif
+
+/**
+ * @brief Context switch hook.
+ * @details This hook is invoked just before switching between threads.
+ */
+#if !defined(THREAD_CONTEXT_SWITCH_HOOK) || defined(__DOXYGEN__)
+#define THREAD_CONTEXT_SWITCH_HOOK(ntp, otp) { \
+ /* System halt code here.*/ \
+}
+#endif
+
+/**
+ * @brief Idle Loop hook.
+ * @details This hook is continuously invoked by the idle thread loop.
+ */
+#if !defined(IDLE_LOOP_HOOK) || defined(__DOXYGEN__)
+#define IDLE_LOOP_HOOK() { \
+ /* Idle loop code here.*/ \
+}
+#endif
+
+/**
+ * @brief System tick event hook.
+ * @details This hook is invoked in the system tick handler immediately
+ * after processing the virtual timers queue.
+ */
+#if !defined(SYSTEM_TICK_EVENT_HOOK) || defined(__DOXYGEN__)
+#define SYSTEM_TICK_EVENT_HOOK() { \
+ /* System tick event code here.*/ \
+}
+#endif
+
+
+/**
+ * @brief System halt hook.
+ * @details This hook is invoked in case to a system halting error before
+ * the system is halted.
+ */
+#if !defined(SYSTEM_HALT_HOOK) || defined(__DOXYGEN__)
+#define SYSTEM_HALT_HOOK() { \
+ /* System halt code here.*/ \
+}
+#endif
+
+/** @} */
+
+/*===========================================================================*/
+/* Port-specific settings (override port settings defaulted in chcore.h). */
+/*===========================================================================*/
+
+#endif /* _CHCONF_H_ */
+
+/** @} */
diff --git a/win32_functional_tests/compile.bat b/win32_functional_tests/compile.bat
index dde7b05a30..b77473ac9f 100644
--- a/win32_functional_tests/compile.bat
+++ b/win32_functional_tests/compile.bat
@@ -1,4 +1,4 @@
-rem this is about CygWin colon issue, .dep files are invalid because of that
-rem rm -rf .dep
-rm -f build/rusefi_simulator.exe
-make
+rem this is about CygWin colon issue, .dep files are invalid because of that
+rem rm -rf .dep
+rm -f build/rusefi_simulator.exe
+make
diff --git a/win32_functional_tests/halconf.h b/win32_functional_tests/halconf.h
index 37c0489640..3fe9b9714e 100644
--- a/win32_functional_tests/halconf.h
+++ b/win32_functional_tests/halconf.h
@@ -1,312 +1,312 @@
-/*
- ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-/**
- * @file templates/halconf.h
- * @brief HAL configuration header.
- * @details HAL configuration file, this file allows to enable or disable the
- * various device drivers from your application. You may also use
- * this file in order to override the device drivers default settings.
- *
- * @addtogroup HAL_CONF
- * @{
- */
-
-#ifndef _HALCONF_H_
-#define _HALCONF_H_
-
-/*#include "mcuconf.h"*/
-
-/**
- * @brief Enables the TM subsystem.
- */
-#if !defined(HAL_USE_TM) || defined(__DOXYGEN__)
-#define HAL_USE_TM FALSE
-#endif
-
-/**
- * @brief Enables the PAL subsystem.
- */
-#if !defined(HAL_USE_PAL) || defined(__DOXYGEN__)
-#define HAL_USE_PAL TRUE
-#endif
-
-/**
- * @brief Enables the ADC subsystem.
- */
-#if !defined(HAL_USE_ADC) || defined(__DOXYGEN__)
-#define HAL_USE_ADC FALSE
-#endif
-
-/**
- * @brief Enables the CAN subsystem.
- */
-#if !defined(HAL_USE_CAN) || defined(__DOXYGEN__)
-#define HAL_USE_CAN FALSE
-#endif
-
-/**
- * @brief Enables the EXT subsystem.
- */
-#if !defined(HAL_USE_EXT) || defined(__DOXYGEN__)
-#define HAL_USE_EXT FALSE
-#endif
-
-/**
- * @brief Enables the GPT subsystem.
- */
-#if !defined(HAL_USE_GPT) || defined(__DOXYGEN__)
-#define HAL_USE_GPT FALSE
-#endif
-
-/**
- * @brief Enables the I2C subsystem.
- */
-#if !defined(HAL_USE_I2C) || defined(__DOXYGEN__)
-#define HAL_USE_I2C FALSE
-#endif
-
-/**
- * @brief Enables the ICU subsystem.
- */
-#if !defined(HAL_USE_ICU) || defined(__DOXYGEN__)
-#define HAL_USE_ICU FALSE
-#endif
-
-/**
- * @brief Enables the MAC subsystem.
- */
-#if !defined(HAL_USE_MAC) || defined(__DOXYGEN__)
-#define HAL_USE_MAC FALSE
-#endif
-
-/**
- * @brief Enables the MMC_SPI subsystem.
- */
-#if !defined(HAL_USE_MMC_SPI) || defined(__DOXYGEN__)
-#define HAL_USE_MMC_SPI FALSE
-#endif
-
-/**
- * @brief Enables the PWM subsystem.
- */
-#if !defined(HAL_USE_PWM) || defined(__DOXYGEN__)
-#define HAL_USE_PWM FALSE
-#endif
-
-/**
- * @brief Enables the RTC subsystem.
- */
-#if !defined(HAL_USE_RTC) || defined(__DOXYGEN__)
-#define HAL_USE_RTC FALSE
-#endif
-
-/**
- * @brief Enables the SDC subsystem.
- */
-#if !defined(HAL_USE_SDC) || defined(__DOXYGEN__)
-#define HAL_USE_SDC FALSE
-#endif
-
-/**
- * @brief Enables the SERIAL subsystem.
- */
-#if !defined(HAL_USE_SERIAL) || defined(__DOXYGEN__)
-#define HAL_USE_SERIAL TRUE
-#endif
-
-/**
- * @brief Enables the SERIAL over USB subsystem.
- */
-#if !defined(HAL_USE_SERIAL_USB) || defined(__DOXYGEN__)
-#define HAL_USE_SERIAL_USB FALSE
-#endif
-
-/**
- * @brief Enables the SPI subsystem.
- */
-#if !defined(HAL_USE_SPI) || defined(__DOXYGEN__)
-#define HAL_USE_SPI FALSE
-#endif
-
-/**
- * @brief Enables the UART subsystem.
- */
-#if !defined(HAL_USE_UART) || defined(__DOXYGEN__)
-#define HAL_USE_UART FALSE
-#endif
-
-/**
- * @brief Enables the USB subsystem.
- */
-#if !defined(HAL_USE_USB) || defined(__DOXYGEN__)
-#define HAL_USE_USB FALSE
-#endif
-
-/*===========================================================================*/
-/* ADC driver related settings. */
-/*===========================================================================*/
-
-/**
- * @brief Enables synchronous APIs.
- * @note Disabling this option saves both code and data space.
- */
-#if !defined(ADC_USE_WAIT) || defined(__DOXYGEN__)
-#define ADC_USE_WAIT TRUE
-#endif
-
-/**
- * @brief Enables the @p adcAcquireBus() and @p adcReleaseBus() APIs.
- * @note Disabling this option saves both code and data space.
- */
-#if !defined(ADC_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
-#define ADC_USE_MUTUAL_EXCLUSION TRUE
-#endif
-
-/*===========================================================================*/
-/* CAN driver related settings. */
-/*===========================================================================*/
-
-/**
- * @brief Sleep mode related APIs inclusion switch.
- */
-#if !defined(CAN_USE_SLEEP_MODE) || defined(__DOXYGEN__)
-#define CAN_USE_SLEEP_MODE TRUE
-#endif
-
-/*===========================================================================*/
-/* I2C driver related settings. */
-/*===========================================================================*/
-
-/**
- * @brief Enables the mutual exclusion APIs on the I2C bus.
- */
-#if !defined(I2C_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
-#define I2C_USE_MUTUAL_EXCLUSION TRUE
-#endif
-
-/*===========================================================================*/
-/* MAC driver related settings. */
-/*===========================================================================*/
-
-/**
- * @brief Enables an event sources for incoming packets.
- */
-#if !defined(MAC_USE_ZERO_COPY) || defined(__DOXYGEN__)
-#define MAC_USE_ZERO_COPY FALSE
-#endif
-
-/**
- * @brief Enables an event sources for incoming packets.
- */
-#if !defined(MAC_USE_EVENTS) || defined(__DOXYGEN__)
-#define MAC_USE_EVENTS TRUE
-#endif
-
-/*===========================================================================*/
-/* MMC_SPI driver related settings. */
-/*===========================================================================*/
-
-/**
- * @brief Delays insertions.
- * @details If enabled this options inserts delays into the MMC waiting
- * routines releasing some extra CPU time for the threads with
- * lower priority, this may slow down the driver a bit however.
- * This option is recommended also if the SPI driver does not
- * use a DMA channel and heavily loads the CPU.
- */
-#if !defined(MMC_NICE_WAITING) || defined(__DOXYGEN__)
-#define MMC_NICE_WAITING TRUE
-#endif
-
-/*===========================================================================*/
-/* SDC driver related settings. */
-/*===========================================================================*/
-
-/**
- * @brief Number of initialization attempts before rejecting the card.
- * @note Attempts are performed at 10mS intervals.
- */
-#if !defined(SDC_INIT_RETRY) || defined(__DOXYGEN__)
-#define SDC_INIT_RETRY 100
-#endif
-
-/**
- * @brief Include support for MMC cards.
- * @note MMC support is not yet implemented so this option must be kept
- * at @p FALSE.
- */
-#if !defined(SDC_MMC_SUPPORT) || defined(__DOXYGEN__)
-#define SDC_MMC_SUPPORT FALSE
-#endif
-
-/**
- * @brief Delays insertions.
- * @details If enabled this options inserts delays into the MMC waiting
- * routines releasing some extra CPU time for the threads with
- * lower priority, this may slow down the driver a bit however.
- */
-#if !defined(SDC_NICE_WAITING) || defined(__DOXYGEN__)
-#define SDC_NICE_WAITING TRUE
-#endif
-
-/*===========================================================================*/
-/* SERIAL driver related settings. */
-/*===========================================================================*/
-
-/**
- * @brief Default bit rate.
- * @details Configuration parameter, this is the baud rate selected for the
- * default configuration.
- */
-#if !defined(SERIAL_DEFAULT_BITRATE) || defined(__DOXYGEN__)
-#define SERIAL_DEFAULT_BITRATE 38400
-#endif
-
-/**
- * @brief Serial buffers size.
- * @details Configuration parameter, you can change the depth of the queue
- * buffers depending on the requirements of your application.
- * @note The default is 64 bytes for both the transmission and receive
- * buffers.
- */
-#if !defined(SERIAL_BUFFERS_SIZE) || defined(__DOXYGEN__)
-#define SERIAL_BUFFERS_SIZE 32
-#endif
-
-/*===========================================================================*/
-/* SPI driver related settings. */
-/*===========================================================================*/
-
-/**
- * @brief Enables synchronous APIs.
- * @note Disabling this option saves both code and data space.
- */
-#if !defined(SPI_USE_WAIT) || defined(__DOXYGEN__)
-#define SPI_USE_WAIT TRUE
-#endif
-
-/**
- * @brief Enables the @p spiAcquireBus() and @p spiReleaseBus() APIs.
- * @note Disabling this option saves both code and data space.
- */
-#if !defined(SPI_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
-#define SPI_USE_MUTUAL_EXCLUSION TRUE
-#endif
-
-#endif /* _HALCONF_H_ */
-
-/** @} */
+/*
+ ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+/**
+ * @file templates/halconf.h
+ * @brief HAL configuration header.
+ * @details HAL configuration file, this file allows to enable or disable the
+ * various device drivers from your application. You may also use
+ * this file in order to override the device drivers default settings.
+ *
+ * @addtogroup HAL_CONF
+ * @{
+ */
+
+#ifndef _HALCONF_H_
+#define _HALCONF_H_
+
+/*#include "mcuconf.h"*/
+
+/**
+ * @brief Enables the TM subsystem.
+ */
+#if !defined(HAL_USE_TM) || defined(__DOXYGEN__)
+#define HAL_USE_TM FALSE
+#endif
+
+/**
+ * @brief Enables the PAL subsystem.
+ */
+#if !defined(HAL_USE_PAL) || defined(__DOXYGEN__)
+#define HAL_USE_PAL TRUE
+#endif
+
+/**
+ * @brief Enables the ADC subsystem.
+ */
+#if !defined(HAL_USE_ADC) || defined(__DOXYGEN__)
+#define HAL_USE_ADC FALSE
+#endif
+
+/**
+ * @brief Enables the CAN subsystem.
+ */
+#if !defined(HAL_USE_CAN) || defined(__DOXYGEN__)
+#define HAL_USE_CAN FALSE
+#endif
+
+/**
+ * @brief Enables the EXT subsystem.
+ */
+#if !defined(HAL_USE_EXT) || defined(__DOXYGEN__)
+#define HAL_USE_EXT FALSE
+#endif
+
+/**
+ * @brief Enables the GPT subsystem.
+ */
+#if !defined(HAL_USE_GPT) || defined(__DOXYGEN__)
+#define HAL_USE_GPT FALSE
+#endif
+
+/**
+ * @brief Enables the I2C subsystem.
+ */
+#if !defined(HAL_USE_I2C) || defined(__DOXYGEN__)
+#define HAL_USE_I2C FALSE
+#endif
+
+/**
+ * @brief Enables the ICU subsystem.
+ */
+#if !defined(HAL_USE_ICU) || defined(__DOXYGEN__)
+#define HAL_USE_ICU FALSE
+#endif
+
+/**
+ * @brief Enables the MAC subsystem.
+ */
+#if !defined(HAL_USE_MAC) || defined(__DOXYGEN__)
+#define HAL_USE_MAC FALSE
+#endif
+
+/**
+ * @brief Enables the MMC_SPI subsystem.
+ */
+#if !defined(HAL_USE_MMC_SPI) || defined(__DOXYGEN__)
+#define HAL_USE_MMC_SPI FALSE
+#endif
+
+/**
+ * @brief Enables the PWM subsystem.
+ */
+#if !defined(HAL_USE_PWM) || defined(__DOXYGEN__)
+#define HAL_USE_PWM FALSE
+#endif
+
+/**
+ * @brief Enables the RTC subsystem.
+ */
+#if !defined(HAL_USE_RTC) || defined(__DOXYGEN__)
+#define HAL_USE_RTC FALSE
+#endif
+
+/**
+ * @brief Enables the SDC subsystem.
+ */
+#if !defined(HAL_USE_SDC) || defined(__DOXYGEN__)
+#define HAL_USE_SDC FALSE
+#endif
+
+/**
+ * @brief Enables the SERIAL subsystem.
+ */
+#if !defined(HAL_USE_SERIAL) || defined(__DOXYGEN__)
+#define HAL_USE_SERIAL TRUE
+#endif
+
+/**
+ * @brief Enables the SERIAL over USB subsystem.
+ */
+#if !defined(HAL_USE_SERIAL_USB) || defined(__DOXYGEN__)
+#define HAL_USE_SERIAL_USB FALSE
+#endif
+
+/**
+ * @brief Enables the SPI subsystem.
+ */
+#if !defined(HAL_USE_SPI) || defined(__DOXYGEN__)
+#define HAL_USE_SPI FALSE
+#endif
+
+/**
+ * @brief Enables the UART subsystem.
+ */
+#if !defined(HAL_USE_UART) || defined(__DOXYGEN__)
+#define HAL_USE_UART FALSE
+#endif
+
+/**
+ * @brief Enables the USB subsystem.
+ */
+#if !defined(HAL_USE_USB) || defined(__DOXYGEN__)
+#define HAL_USE_USB FALSE
+#endif
+
+/*===========================================================================*/
+/* ADC driver related settings. */
+/*===========================================================================*/
+
+/**
+ * @brief Enables synchronous APIs.
+ * @note Disabling this option saves both code and data space.
+ */
+#if !defined(ADC_USE_WAIT) || defined(__DOXYGEN__)
+#define ADC_USE_WAIT TRUE
+#endif
+
+/**
+ * @brief Enables the @p adcAcquireBus() and @p adcReleaseBus() APIs.
+ * @note Disabling this option saves both code and data space.
+ */
+#if !defined(ADC_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
+#define ADC_USE_MUTUAL_EXCLUSION TRUE
+#endif
+
+/*===========================================================================*/
+/* CAN driver related settings. */
+/*===========================================================================*/
+
+/**
+ * @brief Sleep mode related APIs inclusion switch.
+ */
+#if !defined(CAN_USE_SLEEP_MODE) || defined(__DOXYGEN__)
+#define CAN_USE_SLEEP_MODE TRUE
+#endif
+
+/*===========================================================================*/
+/* I2C driver related settings. */
+/*===========================================================================*/
+
+/**
+ * @brief Enables the mutual exclusion APIs on the I2C bus.
+ */
+#if !defined(I2C_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
+#define I2C_USE_MUTUAL_EXCLUSION TRUE
+#endif
+
+/*===========================================================================*/
+/* MAC driver related settings. */
+/*===========================================================================*/
+
+/**
+ * @brief Enables an event sources for incoming packets.
+ */
+#if !defined(MAC_USE_ZERO_COPY) || defined(__DOXYGEN__)
+#define MAC_USE_ZERO_COPY FALSE
+#endif
+
+/**
+ * @brief Enables an event sources for incoming packets.
+ */
+#if !defined(MAC_USE_EVENTS) || defined(__DOXYGEN__)
+#define MAC_USE_EVENTS TRUE
+#endif
+
+/*===========================================================================*/
+/* MMC_SPI driver related settings. */
+/*===========================================================================*/
+
+/**
+ * @brief Delays insertions.
+ * @details If enabled this options inserts delays into the MMC waiting
+ * routines releasing some extra CPU time for the threads with
+ * lower priority, this may slow down the driver a bit however.
+ * This option is recommended also if the SPI driver does not
+ * use a DMA channel and heavily loads the CPU.
+ */
+#if !defined(MMC_NICE_WAITING) || defined(__DOXYGEN__)
+#define MMC_NICE_WAITING TRUE
+#endif
+
+/*===========================================================================*/
+/* SDC driver related settings. */
+/*===========================================================================*/
+
+/**
+ * @brief Number of initialization attempts before rejecting the card.
+ * @note Attempts are performed at 10mS intervals.
+ */
+#if !defined(SDC_INIT_RETRY) || defined(__DOXYGEN__)
+#define SDC_INIT_RETRY 100
+#endif
+
+/**
+ * @brief Include support for MMC cards.
+ * @note MMC support is not yet implemented so this option must be kept
+ * at @p FALSE.
+ */
+#if !defined(SDC_MMC_SUPPORT) || defined(__DOXYGEN__)
+#define SDC_MMC_SUPPORT FALSE
+#endif
+
+/**
+ * @brief Delays insertions.
+ * @details If enabled this options inserts delays into the MMC waiting
+ * routines releasing some extra CPU time for the threads with
+ * lower priority, this may slow down the driver a bit however.
+ */
+#if !defined(SDC_NICE_WAITING) || defined(__DOXYGEN__)
+#define SDC_NICE_WAITING TRUE
+#endif
+
+/*===========================================================================*/
+/* SERIAL driver related settings. */
+/*===========================================================================*/
+
+/**
+ * @brief Default bit rate.
+ * @details Configuration parameter, this is the baud rate selected for the
+ * default configuration.
+ */
+#if !defined(SERIAL_DEFAULT_BITRATE) || defined(__DOXYGEN__)
+#define SERIAL_DEFAULT_BITRATE 38400
+#endif
+
+/**
+ * @brief Serial buffers size.
+ * @details Configuration parameter, you can change the depth of the queue
+ * buffers depending on the requirements of your application.
+ * @note The default is 64 bytes for both the transmission and receive
+ * buffers.
+ */
+#if !defined(SERIAL_BUFFERS_SIZE) || defined(__DOXYGEN__)
+#define SERIAL_BUFFERS_SIZE 32
+#endif
+
+/*===========================================================================*/
+/* SPI driver related settings. */
+/*===========================================================================*/
+
+/**
+ * @brief Enables synchronous APIs.
+ * @note Disabling this option saves both code and data space.
+ */
+#if !defined(SPI_USE_WAIT) || defined(__DOXYGEN__)
+#define SPI_USE_WAIT TRUE
+#endif
+
+/**
+ * @brief Enables the @p spiAcquireBus() and @p spiReleaseBus() APIs.
+ * @note Disabling this option saves both code and data space.
+ */
+#if !defined(SPI_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
+#define SPI_USE_MUTUAL_EXCLUSION TRUE
+#endif
+
+#endif /* _HALCONF_H_ */
+
+/** @} */
diff --git a/win32_functional_tests/main.c b/win32_functional_tests/main.c
index 880904d8c7..e591c04edc 100644
--- a/win32_functional_tests/main.c
+++ b/win32_functional_tests/main.c
@@ -1,189 +1,189 @@
-/*
- ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- */
-
-#include "main.h"
-#include "chprintf.h"
-#include "rusEfiFunctionalTest.h"
-
-#define SHELL_WA_SIZE THD_WA_SIZE(4096)
-#define CONSOLE_WA_SIZE THD_WA_SIZE(4096)
-
-static Thread *cdtp;
-//static Thread *shelltp1;
-//static Thread *shelltp2;
-
-#define cputs(msg) chMsgSend(cdtp, (msg_t)msg)
-
-void printToWin32Console(char *p) {
- cputs(p);
-}
-
-TestStream testStream;
-
-/*
- * Console print server done using synchronous messages. This makes the access
- * to the C printf() thread safe and the print operation atomic among threads.
- * In this example the message is the zero terminated string itself.
- */
-static msg_t console_thread(void *arg) {
-
- (void) arg;
- while (!chThdShouldTerminate()) {
- Thread *tp = chMsgWait();
- puts((char *) chMsgGet(tp));
- fflush(stdout);
- chMsgRelease(tp, RDY_OK);
- }
- return 0;
-}
-
-extern int isSerialOverTcpReady;
-
-/**
- * @brief Shell termination handler.
- *
- * @param[in] id event id.
- */
-static void termination_handler(eventid_t id) {
-
- chThdSleepMilliseconds(10);
-
- cputs("Init: shell on SD1 terminated");
- chSysLock();
- chOQResetI(&SD1.oqueue);
- chSysUnlock();
-
-// if (shelltp2 && chThdTerminated(shelltp2)) {
-// chThdWait(shelltp2);
-// shelltp2 = NULL;
-// chThdSleepMilliseconds(10);
-// cputs("Init: shell on SD2 terminated");
-// chSysLock();
-// chOQResetI(&SD2.oqueue);
-// chSysUnlock();
-// }
-}
-
-static EventListener sd1fel, sd2fel;
-
-/**
- * @brief SD1 status change handler.
- *
- * @param[in] id event id.
- */
-static void sd1_handler(eventid_t id) {
- flagsmask_t flags;
-
- (void) id;
- flags = chEvtGetAndClearFlags(&sd1fel);
- if ((flags & CHN_CONNECTED)) {
- cputs("Init: connection on SD1");
- isSerialOverTcpReady = TRUE;
-
- }
- if (flags & CHN_DISCONNECTED) {
- cputs("Init: disconnection on SD1");
- isSerialOverTcpReady = FALSE;
- chSysLock();
- chIQResetI(&SD1.iqueue);
- chSysUnlock();
- }
-}
-
-/**
- * @brief SD2 status change handler.
- *
- * @param[in] id event id.
- */
-static void sd2_handler(eventid_t id) {
- flagsmask_t flags;
-
- (void) id;
- flags = chEvtGetAndClearFlags(&sd2fel);
- if ((flags & CHN_CONNECTED)) {
- cputs("Init: connection on SD2");
- }
- if (flags & CHN_DISCONNECTED) {
- cputs("Init: disconnection on SD2");
- chSysLock();
- chIQResetI(&SD2.iqueue);
- chSysUnlock();
- }
-}
-
-static evhandler_t fhandlers[] = { termination_handler, sd1_handler, sd2_handler };
-
-/*------------------------------------------------------------------------*
- * Simulator main. *
- *------------------------------------------------------------------------*/
-int main(void) {
-
- initTestStream(&testStream);
-
- EventListener tel;
-
- /*
- * System initializations.
- * - HAL initialization, this also initializes the configured device drivers
- * and performs the board-specific initializations.
- * - Kernel initialization, the main() function becomes a thread and the
- * RTOS is active.
- */
- halInit();
- chSysInit();
-
- /*
- * Serial ports (simulated) initialization.
- */
- sdStart(&SD1, NULL);
- sdStart(&SD2, NULL);
-
- /*
- * Console thread started.
- */
- cdtp = chThdCreateFromHeap(NULL, CONSOLE_WA_SIZE, NORMALPRIO + 1, console_thread, NULL);
-
- /*
- * Initializing connection/disconnection events.
- */
- cputs("Shell service started on SD1, SD2");
- cputs(" - Listening for connections on SD1");
- chEvtRegister(chnGetEventSource(&SD1), &sd1fel, 1);
- cputs(" - Listening for connections on SD2");
- chEvtRegister(chnGetEventSource(&SD2), &sd2fel, 2);
-
- rusEfiFunctionalTest();
-
- /*
- * Events servicing loop.
- */
- while (!chThdShouldTerminate()) {
- chEvtDispatch(fhandlers, chEvtWaitOne(ALL_EVENTS));
- printPendingMessages();
- chThdSleepMilliseconds(100);
- }
-
- /*
- * Clean simulator exit.
- */
- chEvtUnregister(chnGetEventSource(&SD1), &sd1fel);
- chEvtUnregister(chnGetEventSource(&SD2), &sd2fel);
- return 0;
-}
-
-int systicks2ms(int systicks) {
- return systicks / TICKS_IN_MS;
-}
+/*
+ ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ */
+
+#include "main.h"
+#include "chprintf.h"
+#include "rusEfiFunctionalTest.h"
+
+#define SHELL_WA_SIZE THD_WA_SIZE(4096)
+#define CONSOLE_WA_SIZE THD_WA_SIZE(4096)
+
+static Thread *cdtp;
+//static Thread *shelltp1;
+//static Thread *shelltp2;
+
+#define cputs(msg) chMsgSend(cdtp, (msg_t)msg)
+
+void printToWin32Console(char *p) {
+ cputs(p);
+}
+
+TestStream testStream;
+
+/*
+ * Console print server done using synchronous messages. This makes the access
+ * to the C printf() thread safe and the print operation atomic among threads.
+ * In this example the message is the zero terminated string itself.
+ */
+static msg_t console_thread(void *arg) {
+
+ (void) arg;
+ while (!chThdShouldTerminate()) {
+ Thread *tp = chMsgWait();
+ puts((char *) chMsgGet(tp));
+ fflush(stdout);
+ chMsgRelease(tp, RDY_OK);
+ }
+ return 0;
+}
+
+extern int isSerialOverTcpReady;
+
+/**
+ * @brief Shell termination handler.
+ *
+ * @param[in] id event id.
+ */
+static void termination_handler(eventid_t id) {
+
+ chThdSleepMilliseconds(10);
+
+ cputs("Init: shell on SD1 terminated");
+ chSysLock();
+ chOQResetI(&SD1.oqueue);
+ chSysUnlock();
+
+// if (shelltp2 && chThdTerminated(shelltp2)) {
+// chThdWait(shelltp2);
+// shelltp2 = NULL;
+// chThdSleepMilliseconds(10);
+// cputs("Init: shell on SD2 terminated");
+// chSysLock();
+// chOQResetI(&SD2.oqueue);
+// chSysUnlock();
+// }
+}
+
+static EventListener sd1fel, sd2fel;
+
+/**
+ * @brief SD1 status change handler.
+ *
+ * @param[in] id event id.
+ */
+static void sd1_handler(eventid_t id) {
+ flagsmask_t flags;
+
+ (void) id;
+ flags = chEvtGetAndClearFlags(&sd1fel);
+ if ((flags & CHN_CONNECTED)) {
+ cputs("Init: connection on SD1");
+ isSerialOverTcpReady = TRUE;
+
+ }
+ if (flags & CHN_DISCONNECTED) {
+ cputs("Init: disconnection on SD1");
+ isSerialOverTcpReady = FALSE;
+ chSysLock();
+ chIQResetI(&SD1.iqueue);
+ chSysUnlock();
+ }
+}
+
+/**
+ * @brief SD2 status change handler.
+ *
+ * @param[in] id event id.
+ */
+static void sd2_handler(eventid_t id) {
+ flagsmask_t flags;
+
+ (void) id;
+ flags = chEvtGetAndClearFlags(&sd2fel);
+ if ((flags & CHN_CONNECTED)) {
+ cputs("Init: connection on SD2");
+ }
+ if (flags & CHN_DISCONNECTED) {
+ cputs("Init: disconnection on SD2");
+ chSysLock();
+ chIQResetI(&SD2.iqueue);
+ chSysUnlock();
+ }
+}
+
+static evhandler_t fhandlers[] = { termination_handler, sd1_handler, sd2_handler };
+
+/*------------------------------------------------------------------------*
+ * Simulator main. *
+ *------------------------------------------------------------------------*/
+int main(void) {
+
+ initTestStream(&testStream);
+
+ EventListener tel;
+
+ /*
+ * System initializations.
+ * - HAL initialization, this also initializes the configured device drivers
+ * and performs the board-specific initializations.
+ * - Kernel initialization, the main() function becomes a thread and the
+ * RTOS is active.
+ */
+ halInit();
+ chSysInit();
+
+ /*
+ * Serial ports (simulated) initialization.
+ */
+ sdStart(&SD1, NULL);
+ sdStart(&SD2, NULL);
+
+ /*
+ * Console thread started.
+ */
+ cdtp = chThdCreateFromHeap(NULL, CONSOLE_WA_SIZE, NORMALPRIO + 1, console_thread, NULL);
+
+ /*
+ * Initializing connection/disconnection events.
+ */
+ cputs("Shell service started on SD1, SD2");
+ cputs(" - Listening for connections on SD1");
+ chEvtRegister(chnGetEventSource(&SD1), &sd1fel, 1);
+ cputs(" - Listening for connections on SD2");
+ chEvtRegister(chnGetEventSource(&SD2), &sd2fel, 2);
+
+ rusEfiFunctionalTest();
+
+ /*
+ * Events servicing loop.
+ */
+ while (!chThdShouldTerminate()) {
+ chEvtDispatch(fhandlers, chEvtWaitOne(ALL_EVENTS));
+ printPendingMessages();
+ chThdSleepMilliseconds(100);
+ }
+
+ /*
+ * Clean simulator exit.
+ */
+ chEvtUnregister(chnGetEventSource(&SD1), &sd1fel);
+ chEvtUnregister(chnGetEventSource(&SD2), &sd2fel);
+ return 0;
+}
+
+int systicks2ms(int systicks) {
+ return systicks / TICKS_IN_MS;
+}
diff --git a/win32_functional_tests/main.h b/win32_functional_tests/main.h
index e00280b6da..da94da7234 100644
--- a/win32_functional_tests/main.h
+++ b/win32_functional_tests/main.h
@@ -1,31 +1,2 @@
-
-#include "global.h"
-#include "boards.h"
-#include "eficonsole.h"
-#include "efilib.h"
-#include "datalogging.h"
-#include "error_handling.h"
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif /* __cplusplus */
-
-void printToWin32Console(char *p);
-int systicks2ms(int systicks);
-
-// todo: move somewhere else?
-void lockAnyContext(void);
-void unlockAnyContext(void);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-
-/**
- * number of SysClock ticks in one ms
- */
-#define TICKS_IN_MS (CH_FREQUENCY / 1000)
-
-#define hal_lld_get_counter_value() 0
+
+#include "global.h"
diff --git a/win32_functional_tests/rules.mk b/win32_functional_tests/rules.mk
index 5e93b3e311..c2a8b23a79 100644
--- a/win32_functional_tests/rules.mk
+++ b/win32_functional_tests/rules.mk
@@ -1,168 +1,168 @@
-# ARM Cortex-Mx common makefile scripts and rules.
-
-# Output directory and files
-ifeq ($(BUILDDIR),)
- BUILDDIR = build
-endif
-ifeq ($(BUILDDIR),.)
- BUILDDIR = build
-endif
-OUTFILES = $(BUILDDIR)/$(PROJECT)
-
-# Automatic compiler options
-OPT = $(USE_OPT)
-COPT = $(USE_COPT)
-CPPOPT = $(USE_CPPOPT)
-ifeq ($(USE_LINK_GC),yes)
- OPT += -ffunction-sections -fdata-sections -fno-common
-endif
-
-# Source files groups and paths
-ifeq ($(USE_THUMB),yes)
- TCSRC += $(CSRC)
- TCPPSRC += $(CPPSRC)
-else
- ACSRC += $(CSRC)
- ACPPSRC += $(CPPSRC)
-endif
-ASRC = $(ACSRC)$(ACPPSRC)
-TSRC = $(TCSRC)$(TCPPSRC)
-SRCPATHS = $(sort $(dir $(ASMXSRC)) $(dir $(ASMSRC)) $(dir $(ASRC)) $(dir $(TSRC)))
-
-# Various directories
-OBJDIR = $(BUILDDIR)/obj
-LSTDIR = $(BUILDDIR)/lst
-
-# Object files groups
-ACOBJS = $(addprefix $(OBJDIR)/, $(notdir $(ACSRC:.c=.o)))
-ACPPOBJS = $(addprefix $(OBJDIR)/, $(notdir $(ACPPSRC:.cpp=.o)))
-TCOBJS = $(addprefix $(OBJDIR)/, $(notdir $(TCSRC:.c=.o)))
-TCPPOBJS = $(addprefix $(OBJDIR)/, $(notdir $(TCPPSRC:.cpp=.o)))
-ASMOBJS = $(addprefix $(OBJDIR)/, $(notdir $(ASMSRC:.s=.o)))
-ASMXOBJS = $(addprefix $(OBJDIR)/, $(notdir $(ASMXSRC:.S=.o)))
-OBJS = $(ASMXOBJS) $(ASMOBJS) $(ACOBJS) $(TCOBJS) $(ACPPOBJS) $(TCPPOBJS)
-
-# Paths
-IINCDIR = $(patsubst %,-I%,$(INCDIR) $(DINCDIR) $(UINCDIR))
-LLIBDIR = $(patsubst %,-L%,$(DLIBDIR) $(ULIBDIR))
-
-# Macros
-DEFS = $(DDEFS) $(UDEFS)
-ADEFS = $(DADEFS) $(UADEFS)
-
-# Libs
-LIBS = $(DLIBS) $(ULIBS)
-
-# Various settings
-#MCFLAGS = -mcpu=$(MCU)
-ODFLAGS = -x --syms
-ASFLAGS = $(MCFLAGS) -Wa,-amhls=$(LSTDIR)/$(notdir $(<:.s=.lst)) $(ADEFS)
-ASXFLAGS = $(MCFLAGS) -Wa,-amhls=$(LSTDIR)/$(notdir $(<:.S=.lst)) $(ADEFS)
-CFLAGS = $(MCFLAGS) $(OPT) $(COPT) $(CWARN) -Wa,-alms=$(LSTDIR)/$(notdir $(<:.c=.lst)) $(DEFS)
-CPPFLAGS = $(MCFLAGS) $(OPT) $(CPPOPT) $(CPPWARN) -Wa,-alms=$(LSTDIR)/$(notdir $(<:.cpp=.lst)) $(DEFS)
-ifeq ($(USE_LINK_GC),yes)
- LDFLAGS = $(MCFLAGS) -Wl,-Map=$(BUILDDIR)/$(PROJECT).map,--cref,--no-warn-mismatch,--gc-sections $(LLIBDIR)
-else
- LDFLAGS = $(MCFLAGS) -Wl,-Map=$(BUILDDIR)/$(PROJECT).map,--cref,--no-warn-mismatch $(LLIBDIR)
-endif
-
-# Generate dependency information
-CFLAGS += -MD -MP -MF .dep/$(@F).d
-CPPFLAGS += -MD -MP -MF .dep/$(@F).d
-
-# Paths where to search for sources
-VPATH = $(SRCPATHS)
-
-#
-# Makefile rules
-#
-
-all: $(OBJS) $(OUTFILES) MAKE_ALL_RULE_HOOK
-
-MAKE_ALL_RULE_HOOK:
-
-$(OBJS): | $(BUILDDIR)
-
-$(BUILDDIR) $(OBJDIR) $(LSTDIR):
-ifneq ($(USE_VERBOSE_COMPILE),yes)
- @echo Compiler Options
- @echo $(CPPC) -c $(CPPFLAGS) -I. $(IINCDIR) main.cpp -o main.o
- @echo
-endif
- mkdir -p $(OBJDIR)
- mkdir -p $(LSTDIR)
-
-$(ACPPOBJS) : $(OBJDIR)/%.o : %.cpp Makefile
-ifeq ($(USE_VERBOSE_COMPILE),yes)
- @echo
- $(CPPC) -c $(CPPFLAGS) $(AOPT) -I. $(IINCDIR) $< -o $@
-else
- @echo Compiling $(/dev/null) $(wildcard .dep/*)
-
-# *** EOF ***
+# ARM Cortex-Mx common makefile scripts and rules.
+
+# Output directory and files
+ifeq ($(BUILDDIR),)
+ BUILDDIR = build
+endif
+ifeq ($(BUILDDIR),.)
+ BUILDDIR = build
+endif
+OUTFILES = $(BUILDDIR)/$(PROJECT)
+
+# Automatic compiler options
+OPT = $(USE_OPT)
+COPT = $(USE_COPT)
+CPPOPT = $(USE_CPPOPT)
+ifeq ($(USE_LINK_GC),yes)
+ OPT += -ffunction-sections -fdata-sections -fno-common
+endif
+
+# Source files groups and paths
+ifeq ($(USE_THUMB),yes)
+ TCSRC += $(CSRC)
+ TCPPSRC += $(CPPSRC)
+else
+ ACSRC += $(CSRC)
+ ACPPSRC += $(CPPSRC)
+endif
+ASRC = $(ACSRC)$(ACPPSRC)
+TSRC = $(TCSRC)$(TCPPSRC)
+SRCPATHS = $(sort $(dir $(ASMXSRC)) $(dir $(ASMSRC)) $(dir $(ASRC)) $(dir $(TSRC)))
+
+# Various directories
+OBJDIR = $(BUILDDIR)/obj
+LSTDIR = $(BUILDDIR)/lst
+
+# Object files groups
+ACOBJS = $(addprefix $(OBJDIR)/, $(notdir $(ACSRC:.c=.o)))
+ACPPOBJS = $(addprefix $(OBJDIR)/, $(notdir $(ACPPSRC:.cpp=.o)))
+TCOBJS = $(addprefix $(OBJDIR)/, $(notdir $(TCSRC:.c=.o)))
+TCPPOBJS = $(addprefix $(OBJDIR)/, $(notdir $(TCPPSRC:.cpp=.o)))
+ASMOBJS = $(addprefix $(OBJDIR)/, $(notdir $(ASMSRC:.s=.o)))
+ASMXOBJS = $(addprefix $(OBJDIR)/, $(notdir $(ASMXSRC:.S=.o)))
+OBJS = $(ASMXOBJS) $(ASMOBJS) $(ACOBJS) $(TCOBJS) $(ACPPOBJS) $(TCPPOBJS)
+
+# Paths
+IINCDIR = $(patsubst %,-I%,$(INCDIR) $(DINCDIR) $(UINCDIR))
+LLIBDIR = $(patsubst %,-L%,$(DLIBDIR) $(ULIBDIR))
+
+# Macros
+DEFS = $(DDEFS) $(UDEFS)
+ADEFS = $(DADEFS) $(UADEFS)
+
+# Libs
+LIBS = $(DLIBS) $(ULIBS)
+
+# Various settings
+#MCFLAGS = -mcpu=$(MCU)
+ODFLAGS = -x --syms
+ASFLAGS = $(MCFLAGS) -Wa,-amhls=$(LSTDIR)/$(notdir $(<:.s=.lst)) $(ADEFS)
+ASXFLAGS = $(MCFLAGS) -Wa,-amhls=$(LSTDIR)/$(notdir $(<:.S=.lst)) $(ADEFS)
+CFLAGS = $(MCFLAGS) $(OPT) $(COPT) $(CWARN) -Wa,-alms=$(LSTDIR)/$(notdir $(<:.c=.lst)) $(DEFS)
+CPPFLAGS = $(MCFLAGS) $(OPT) $(CPPOPT) $(CPPWARN) -Wa,-alms=$(LSTDIR)/$(notdir $(<:.cpp=.lst)) $(DEFS)
+ifeq ($(USE_LINK_GC),yes)
+ LDFLAGS = $(MCFLAGS) -Wl,-Map=$(BUILDDIR)/$(PROJECT).map,--cref,--no-warn-mismatch,--gc-sections $(LLIBDIR)
+else
+ LDFLAGS = $(MCFLAGS) -Wl,-Map=$(BUILDDIR)/$(PROJECT).map,--cref,--no-warn-mismatch $(LLIBDIR)
+endif
+
+# Generate dependency information
+CFLAGS += -MD -MP -MF .dep/$(@F).d
+CPPFLAGS += -MD -MP -MF .dep/$(@F).d
+
+# Paths where to search for sources
+VPATH = $(SRCPATHS)
+
+#
+# Makefile rules
+#
+
+all: $(OBJS) $(OUTFILES) MAKE_ALL_RULE_HOOK
+
+MAKE_ALL_RULE_HOOK:
+
+$(OBJS): | $(BUILDDIR)
+
+$(BUILDDIR) $(OBJDIR) $(LSTDIR):
+ifneq ($(USE_VERBOSE_COMPILE),yes)
+ @echo Compiler Options
+ @echo $(CPPC) -c $(CPPFLAGS) -I. $(IINCDIR) main.cpp -o main.o
+ @echo
+endif
+ mkdir -p $(OBJDIR)
+ mkdir -p $(LSTDIR)
+
+$(ACPPOBJS) : $(OBJDIR)/%.o : %.cpp Makefile
+ifeq ($(USE_VERBOSE_COMPILE),yes)
+ @echo
+ $(CPPC) -c $(CPPFLAGS) $(AOPT) -I. $(IINCDIR) $< -o $@
+else
+ @echo Compiling $(/dev/null) $(wildcard .dep/*)
+
+# *** EOF ***
diff --git a/win32_functional_tests/simulator/adc_inputs.h b/win32_functional_tests/simulator/adc_inputs.h
index b201c63ddb..d88551ee18 100644
--- a/win32_functional_tests/simulator/adc_inputs.h
+++ b/win32_functional_tests/simulator/adc_inputs.h
@@ -1,13 +1,13 @@
-/**
- * @file adc_inputs.h
- *
- * @date Dec 7, 2013
- * @author Andrey Belomutskiy, (c) 2012-2013
- */
-
-#ifndef ADC_INPUTS_H_
-#define ADC_INPUTS_H_
-
-#include "adc_math.h"
-
-#endif /* ADC_INPUTS_H_ */
+/**
+ * @file adc_inputs.h
+ *
+ * @date Dec 7, 2013
+ * @author Andrey Belomutskiy, (c) 2012-2013
+ */
+
+#ifndef ADC_INPUTS_H_
+#define ADC_INPUTS_H_
+
+#include "adc_math.h"
+
+#endif /* ADC_INPUTS_H_ */
diff --git a/win32_functional_tests/simulator/boards.c b/win32_functional_tests/simulator/boards.c
index f5a53754d3..5e76443589 100644
--- a/win32_functional_tests/simulator/boards.c
+++ b/win32_functional_tests/simulator/boards.c
@@ -1,57 +1,57 @@
-/**
- * @file board.c
- *
- * @date Nov 15, 2013
- * @author Andrey Belomutskiy, (c) 2012-2013
- */
-
-#include "main.h"
-#include "boards.h"
-#include "engine_configuration.h"
-#include "adc_math.h"
-
-static Logging logger;
-extern engine_configuration_s *engineConfiguration;
-
-
-//float getVoltageDivided(int channel) {
-// return 0;
-//}
-//
-static float fakeAdcValues[16];
-
-int getAdcValue(int hwChannel) {
- return fakeAdcValues[hwChannel];
-}
-
-static void setVoltage(int hwChannel, float voltage) {
- scheduleMsg(&logger, "fake voltage: channel %d value %f", hwChannel, voltage);
- fakeAdcValues[hwChannel] = voltsToAdc(voltage);
-}
-
-static void setCltVoltage(float voltage) {
- setVoltage(engineConfiguration->cltAdcChannel, voltage);
-}
-
-static void setIatVoltage(float voltage) {
- setVoltage(engineConfiguration->iatAdcChannel, voltage);
-}
-
-static void setMafVoltage(float voltage) {
- setVoltage(engineConfiguration->mafAdcChannel, voltage);
-}
-
-static void setAfrVoltage(float voltage) {
- setVoltage(engineConfiguration->afrSensor.afrAdcChannel, voltage);
-}
-
-void initFakeBoard(void) {
- initLogging(&logger, "simulator board");
-
- addConsoleActionF("set_fake_clt_voltage", setCltVoltage);
- addConsoleActionF("set_fake_iat_voltage", setIatVoltage);
- addConsoleActionF("set_fake_maf_voltage", setMafVoltage);
- addConsoleActionF("set_fake_afr_voltage", setAfrVoltage);
-}
-
-
+/**
+ * @file board.c
+ *
+ * @date Nov 15, 2013
+ * @author Andrey Belomutskiy, (c) 2012-2013
+ */
+
+#include "main.h"
+#include "boards.h"
+#include "engine_configuration.h"
+#include "adc_math.h"
+
+static Logging logger;
+extern engine_configuration_s *engineConfiguration;
+
+
+//float getVoltageDivided(int channel) {
+// return 0;
+//}
+//
+static float fakeAdcValues[16];
+
+int getAdcValue(int hwChannel) {
+ return fakeAdcValues[hwChannel];
+}
+
+static void setVoltage(int hwChannel, float voltage) {
+ scheduleMsg(&logger, "fake voltage: channel %d value %f", hwChannel, voltage);
+ fakeAdcValues[hwChannel] = voltsToAdc(voltage);
+}
+
+static void setCltVoltage(float voltage) {
+ setVoltage(engineConfiguration->cltAdcChannel, voltage);
+}
+
+static void setIatVoltage(float voltage) {
+ setVoltage(engineConfiguration->iatAdcChannel, voltage);
+}
+
+static void setMafVoltage(float voltage) {
+ setVoltage(engineConfiguration->mafAdcChannel, voltage);
+}
+
+static void setAfrVoltage(float voltage) {
+ setVoltage(engineConfiguration->afrSensor.afrAdcChannel, voltage);
+}
+
+void initFakeBoard(void) {
+ initLogging(&logger, "simulator board");
+
+ addConsoleActionF("set_fake_clt_voltage", setCltVoltage);
+ addConsoleActionF("set_fake_iat_voltage", setIatVoltage);
+ addConsoleActionF("set_fake_maf_voltage", setMafVoltage);
+ addConsoleActionF("set_fake_afr_voltage", setAfrVoltage);
+}
+
+
diff --git a/win32_functional_tests/simulator/boards.h b/win32_functional_tests/simulator/boards.h
index b581b1ab2f..c9059959e8 100644
--- a/win32_functional_tests/simulator/boards.h
+++ b/win32_functional_tests/simulator/boards.h
@@ -1,23 +1,32 @@
-
-#ifndef BOARDS_FT_H_
-#define BOARDS_FT_H_
-
-
-#define ADC_LOGIC_TPS 0
-#define ADC_LOGIC_AFR 0
-#define ADC_LOGIC_MAF 0
-#define ADC_LOGIC_MAP 0
-#define ADC_CHANNEL_VREF 0
-#define ADC_CHANNEL_VBATT 0
-#define ADC_LOGIC_INTAKE_AIR 0
-#define ADC_LOGIC_COOLANT 0
-
-#define DELEGATE (&SD1)
-
-#define EFI_CONSOLE_UART_DEVICE (&testStream)
-
-//float getVoltageDivided(int);
-int getAdcValue(int channel);
-void initFakeBoard(void);
-
-#endif /* BOARDS_FT_H_ */
+
+#ifndef BOARDS_FT_H_
+#define BOARDS_FT_H_
+
+
+#define ADC_LOGIC_TPS 0
+#define ADC_LOGIC_AFR 0
+#define ADC_LOGIC_MAF 0
+#define ADC_LOGIC_MAP 0
+#define ADC_CHANNEL_VREF 0
+#define ADC_CHANNEL_VBATT 0
+#define ADC_LOGIC_INTAKE_AIR 0
+#define ADC_LOGIC_COOLANT 0
+
+#define DELEGATE (&SD1)
+
+#define EFI_CONSOLE_UART_DEVICE (&testStream)
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif /* __cplusplus */
+
+//float getVoltageDivided(int);
+int getAdcValue(int channel);
+void initFakeBoard(void);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* BOARDS_FT_H_ */
diff --git a/win32_functional_tests/simulator/efifeatures.h b/win32_functional_tests/simulator/efifeatures.h
index 86a840af11..eab9a10748 100644
--- a/win32_functional_tests/simulator/efifeatures.h
+++ b/win32_functional_tests/simulator/efifeatures.h
@@ -1,13 +1,24 @@
-/*
- * efifeatures.h
- *
- * Created on: Mar 7, 2014
- * Author: Andrey
- */
-
-#ifndef EFIFEATURES_H_
-#define EFIFEATURES_H_
-
-
-
-#endif /* EFIFEATURES_H_ */
+/*
+ * efifeatures.h
+ *
+ * Created on: Mar 7, 2014
+ * Author: Andrey
+ */
+
+#ifndef EFIFEATURES_H_
+#define EFIFEATURES_H_
+
+#define EFI_SIMULATOR TRUE
+
+#define EFI_SUPPORT_DODGE_NEON TRUE
+#define EFI_SUPPORT_FORD_ASPIRE TRUE
+#define EFI_SUPPORT_FORD_FIESTA TRUE
+#define EFI_SUPPORT_NISSAN_PRIMERA TRUE
+#define EFI_SUPPORT_1995_FORD_INLINE_6 TRUE
+
+#define EFI_SIGNAL_EXECUTOR_SLEEP TRUE
+
+#define EFI_WAVE_CHART TRUE
+
+
+#endif /* EFIFEATURES_H_ */
diff --git a/win32_functional_tests/simulator/idle_thread.h b/win32_functional_tests/simulator/idle_thread.h
index 8b13789179..d3f5a12faa 100644
--- a/win32_functional_tests/simulator/idle_thread.h
+++ b/win32_functional_tests/simulator/idle_thread.h
@@ -1 +1 @@
-
+
diff --git a/win32_functional_tests/simulator/mmc_card.h b/win32_functional_tests/simulator/mmc_card.h
index 8b13789179..d3f5a12faa 100644
--- a/win32_functional_tests/simulator/mmc_card.h
+++ b/win32_functional_tests/simulator/mmc_card.h
@@ -1 +1 @@
-
+
diff --git a/win32_functional_tests/simulator/rusEfiFunctionalTest.c b/win32_functional_tests/simulator/rusEfiFunctionalTest.c
index 8de87a43f5..9da4c72001 100644
--- a/win32_functional_tests/simulator/rusEfiFunctionalTest.c
+++ b/win32_functional_tests/simulator/rusEfiFunctionalTest.c
@@ -1,163 +1,174 @@
-/**
- * @file rusEfiFunctionalTest.c
- *
- * @date Mar 1, 2014
- * @author Andrey Belomutskiy, (c) 2012-2013
- */
-
-#include "global.h"
-#include "rusEfiFunctionalTest.h"
-#include "eficonsole.h"
-#include "engine_configuration.h"
-#include "rusefi_enums.h"
-#include "pwm_generator_logic.h"
-#include "wave_math.h"
-#include "boards.h"
-#include "trigger_central.h"
-#include "datalogging.h"
-#include "algo.h"
-#include "rpm_calculator.h"
-#include "wave_chart.h"
-#include "status_loop.h"
-#include "trigger_emulator_algo.h"
-#include "main_trigger_callback.h"
-#include "allsensors.h"
-
-
-extern WaveChart waveChart;
-
-static engine_configuration_s ec;
-static engine_configuration2_s ec2;
-
-engine_configuration_s * engineConfiguration = &ec;
-engine_configuration2_s *engineConfiguration2 = &ec2;
-
-void setOutputPinValue(io_pin_e pin, int logicValue) {
-}
-
-int isInjectionEnabled(void) {
- return TRUE;
-}
-
-
-//void initOutputSignal(OutputSignal *signal, io_pin_e ioPin) {
-//
-//}
-
-void idleDebug(char *msg, int value) {
-
-}
-
-float getMap(void) {
- return 0;
-}
-
-static int primaryWheelState = FALSE;
-static int secondaryWheelState = FALSE;
-
-static void triggerEmulatorCallback(PwmConfig *state, int stateIndex) {
- int newPrimaryWheelState = state->multiWave.waves[0].pinStates[stateIndex];
- int newSecondaryWheelState = state->multiWave.waves[1].pinStates[stateIndex];
-
- if (primaryWheelState != newPrimaryWheelState) {
- primaryWheelState = newPrimaryWheelState;
- hwHandleShaftSignal(primaryWheelState ? SHAFT_PRIMARY_UP : SHAFT_PRIMARY_DOWN);
- }
-
- if (secondaryWheelState != newSecondaryWheelState) {
- secondaryWheelState = newSecondaryWheelState;
- hwHandleShaftSignal(secondaryWheelState ? SHAFT_SECONDARY_UP : SHAFT_SECONDARY_DOWN);
- }
-
-// print("hello %d\r\n", chTimeNow());
-}
-
-void rusEfiFunctionalTest(void) {
- initializeConsole();
-
- initFakeBoard();
-
- initStatusLoop();
-
- resetConfigurationExt(FORD_ASPIRE_1996, engineConfiguration, engineConfiguration2);
-
- initThermistors();
- initAlgo();
- initRpmCalculator();
-
- initTriggerEmulatorLogic(triggerEmulatorCallback);
-
- initMainEventListener();
-
- initTriggerCentral();
-
-}
-
-void printPendingMessages(void) {
- printPending();
- if (getFullLog()) {
- printSensors();
- finishStatusLine();
- publishChartIfFull(&waveChart);
- }
-}
-
-static size_t wt_writes(void *ip, const uint8_t *bp, size_t n) {
- printToWin32Console((char*)bp);
- return DELEGATE->vmt->write(DELEGATE, bp, n);
-}
-
-static size_t wt_reads(void *ip, uint8_t *bp, size_t n) {
- return DELEGATE->vmt->read(DELEGATE, bp, n);
-}
-
-static char putMessageBuffer[2];
-
-static msg_t wt_put(void *ip, uint8_t b) {
- putMessageBuffer[0] = b;
- putMessageBuffer[1] = 0;
- printToWin32Console((char*)putMessageBuffer);
-// cputs("wt_put");
- return DELEGATE->vmt->put(DELEGATE, b);
-}
-
-static msg_t wt_get(void *ip) {
-// cputs("wt_get");
- //return 0;
- return DELEGATE->vmt->get(DELEGATE);
-}
-
-static const struct Win32TestStreamVMT vmt = { wt_writes, wt_reads, wt_put, wt_get };
-
-void initTestStream(TestStream *ts) {
- ts->vmt = &vmt;
-}
-
-int isSerialOverTcpReady;
-
-int is_serial_ready(void) {
- return isSerialOverTcpReady;
-}
-
-void onFatalError(const char *msg, char * file, int line) {
- printf("onFatalError %s %s%d", msg, file, line);
- exit(-1);
-}
-
-int warning(const char *fmt, ...) {
- printf("Warning: %s\r\n", fmt);
- return 0;
-}
-
-
-void firmwareError(const char *fmt, ...) {
- fatal3((char*)fmt, __FILE__, __LINE__);
-}
-
-int hasFatalError(void) {
- return false;
-}
-
-int getVersion(void) {
- return 239;
-}
+/**
+ * @file rusEfiFunctionalTest.c
+ *
+ * @date Mar 1, 2014
+ * @author Andrey Belomutskiy, (c) 2012-2013
+ */
+
+#include "global.h"
+#include "rusEfiFunctionalTest.h"
+#include "eficonsole.h"
+#include "engine_configuration.h"
+#include "rusefi_enums.h"
+#include "pwm_generator_logic.h"
+#include "wave_math.h"
+#include "boards.h"
+#include "trigger_central.h"
+#include "datalogging.h"
+#include "algo.h"
+#include "rpm_calculator.h"
+#include "wave_chart.h"
+#include "status_loop.h"
+#include "trigger_emulator_algo.h"
+#include "main_trigger_callback.h"
+#include "allsensors.h"
+#include "analog_chart.h"
+
+extern WaveChart waveChart;
+
+static persistent_config_s config;
+static engine_configuration2_s ec2;
+
+engine_configuration_s * engineConfiguration = &config.engineConfiguration;
+board_configuration_s *boardConfiguration = &config.boardConfiguration;
+engine_configuration2_s *engineConfiguration2 = &ec2;
+
+void setOutputPinValue(io_pin_e pin, int logicValue) {
+}
+
+int isInjectionEnabled(void) {
+ return TRUE;
+}
+
+
+//void initOutputSignal(OutputSignal *signal, io_pin_e ioPin) {
+//
+//}
+
+void idleDebug(char *msg, int value) {
+
+}
+
+float getMap(void) {
+ return 0;
+}
+
+static int primaryWheelState = FALSE;
+static int secondaryWheelState = FALSE;
+
+static void triggerEmulatorCallback(PwmConfig *state, int stateIndex) {
+ int newPrimaryWheelState = state->multiWave.waves[0].pinStates[stateIndex];
+ int newSecondaryWheelState = state->multiWave.waves[1].pinStates[stateIndex];
+
+ if (primaryWheelState != newPrimaryWheelState) {
+ primaryWheelState = newPrimaryWheelState;
+ hwHandleShaftSignal(primaryWheelState ? SHAFT_PRIMARY_UP : SHAFT_PRIMARY_DOWN);
+ }
+
+ if (secondaryWheelState != newSecondaryWheelState) {
+ secondaryWheelState = newSecondaryWheelState;
+ hwHandleShaftSignal(secondaryWheelState ? SHAFT_SECONDARY_UP : SHAFT_SECONDARY_DOWN);
+ }
+
+// print("hello %d\r\n", chTimeNow());
+}
+
+void rusEfiFunctionalTest(void) {
+ initializeConsole();
+
+ initFakeBoard();
+
+ initStatusLoop();
+
+ resetConfigurationExt(FORD_ASPIRE_1996, engineConfiguration, engineConfiguration2, boardConfiguration);
+
+ initThermistors();
+ initAlgo();
+ initRpmCalculator();
+
+ initAnalogChart();
+
+ initTriggerEmulatorLogic(triggerEmulatorCallback);
+
+ initMainEventListener();
+
+ initTriggerCentral();
+
+}
+
+void printPendingMessages(void) {
+ printPending();
+ if (getFullLog()) {
+ printState(getCrankEventCounter());
+ finishStatusLine();
+ publishChartIfFull(&waveChart);
+ }
+}
+
+static size_t wt_writes(void *ip, const uint8_t *bp, size_t n) {
+ printToWin32Console((char*)bp);
+ return DELEGATE->vmt->write(DELEGATE, bp, n);
+}
+
+static size_t wt_reads(void *ip, uint8_t *bp, size_t n) {
+ return DELEGATE->vmt->read(DELEGATE, bp, n);
+}
+
+static char putMessageBuffer[2];
+
+static msg_t wt_put(void *ip, uint8_t b) {
+ putMessageBuffer[0] = b;
+ putMessageBuffer[1] = 0;
+ printToWin32Console((char*)putMessageBuffer);
+// cputs("wt_put");
+ return DELEGATE->vmt->put(DELEGATE, b);
+}
+
+static msg_t wt_get(void *ip) {
+// cputs("wt_get");
+ //return 0;
+ return DELEGATE->vmt->get(DELEGATE);
+}
+
+static const struct Win32TestStreamVMT vmt = { wt_writes, wt_reads, wt_put, wt_get };
+
+void initTestStream(TestStream *ts) {
+ ts->vmt = &vmt;
+}
+
+int isSerialOverTcpReady;
+
+int is_serial_ready(void) {
+ return isSerialOverTcpReady;
+}
+
+void onFatalError(const char *msg, char * file, int line) {
+ printf("onFatalError %s %s%d", msg, file, line);
+ exit(-1);
+}
+
+int warning(obd_code_e code, const char *fmt, ...) {
+ printf("Warning: %s\r\n", fmt);
+ return 0;
+}
+
+void firmwareError(const char *fmt, ...) {
+ fatal3((char*)fmt, __FILE__, __LINE__);
+}
+
+int hasFatalError(void) {
+ return false;
+}
+
+void chDbgPanic3(const char *msg, char * file, int line) {
+ onFatalError(msg, file, line);
+}
+
+uint64_t getTimeNowUs(void) {
+
+ return chTimeNow() * (1000000 / CH_FREQUENCY);
+}
+
+int getRusEfiVersion(void) {
+ return 239;
+}
diff --git a/win32_functional_tests/simulator/rusEfiFunctionalTest.h b/win32_functional_tests/simulator/rusEfiFunctionalTest.h
index 7679f5dc2d..677350f8b0 100644
--- a/win32_functional_tests/simulator/rusEfiFunctionalTest.h
+++ b/win32_functional_tests/simulator/rusEfiFunctionalTest.h
@@ -1,15 +1,15 @@
-/**
- * @file rusEfiFunctionalTest.h
- *
- * @date Mar 1, 2014
- * @author Andrey Belomutskiy, (c) 2012-2013
- */
-
-#ifndef RUSEFIFUNCTIONALTEST_H_
-#define RUSEFIFUNCTIONALTEST_H_
-
-void rusEfiFunctionalTest(void);
-void initTestStream(TestStream *ts);
-void printPendingMessages(void);
-
-#endif /* RUSEFIFUNCTIONALTEST_H_ */
+/**
+ * @file rusEfiFunctionalTest.h
+ *
+ * @date Mar 1, 2014
+ * @author Andrey Belomutskiy, (c) 2012-2013
+ */
+
+#ifndef RUSEFIFUNCTIONALTEST_H_
+#define RUSEFIFUNCTIONALTEST_H_
+
+void rusEfiFunctionalTest(void);
+void initTestStream(TestStream *ts);
+void printPendingMessages(void);
+
+#endif /* RUSEFIFUNCTIONALTEST_H_ */
diff --git a/win32_functional_tests/simulator/rusefi.h b/win32_functional_tests/simulator/rusefi.h
index ca65535f63..02251b27d3 100644
--- a/win32_functional_tests/simulator/rusefi.h
+++ b/win32_functional_tests/simulator/rusefi.h
@@ -1,2 +1,2 @@
-
-int getVersion(void);
+
+int getRusEfiVersion(void);