diff --git a/firmware/Makefile b/firmware/Makefile index 4bc6638b65..b5c9c7a9c4 100644 --- a/firmware/Makefile +++ b/firmware/Makefile @@ -90,7 +90,7 @@ include $(CHIBIOS)/os/various/fatfs_bindings/fatfs.mk include console/tunerstudio/tunerstudio.mk include ext/ext.mk include hw_layer/hw_layer.mk -include emulation/emulation.mk +include emulation/development.mk include controllers/controllers.mk include $(PROJECT_DIR)/util/util.mk diff --git a/firmware/controllers/controllers.mk b/firmware/controllers/controllers.mk index 97980ffc64..a1c7c2fd45 100644 --- a/firmware/controllers/controllers.mk +++ b/firmware/controllers/controllers.mk @@ -1,12 +1,10 @@ CONTROLLERSSRC = \ - controllers/ignition_central.c \ $(PROJECT_DIR)/controllers/error_handling.c CONTROLLERS_SRC_CPP = $(PROJECT_DIR)/controllers/settings.cpp \ controllers/electronic_throttle.cpp \ controllers/map_averaging.cpp \ - controllers/map_multiplier_thread.cpp \ controllers/flash_main.cpp \ controllers/injector_central.cpp \ controllers/idle_thread.cpp \ diff --git a/firmware/controllers/engine_controller.cpp b/firmware/controllers/engine_controller.cpp index bf87143e57..8e96227ccd 100644 --- a/firmware/controllers/engine_controller.cpp +++ b/firmware/controllers/engine_controller.cpp @@ -31,12 +31,10 @@ #include "rpm_calculator.h" #include "signal_executor.h" #include "main_trigger_callback.h" -#include "map_multiplier_thread.h" #include "io_pins.h" #include "flash_main.h" #include "tunerstudio.h" #include "injector_central.h" -#include "ignition_central.h" #include "rfiutil.h" #include "engine_math.h" #include "wave_analyzer.h" diff --git a/firmware/controllers/ignition_central.c b/firmware/controllers/ignition_central.c deleted file mode 100644 index 717d85795a..0000000000 --- a/firmware/controllers/ignition_central.c +++ /dev/null @@ -1,44 +0,0 @@ -/** - * @file ignition_central.c - * @brief TODO - * - * @date Nov 15, 2013 - * @author Andrey Belomutskiy, (c) 2012-2014 - * - * This file is part of rusEfi - see http://rusefi.com - * - * rusEfi is free software; you can redistribute it and/or modify it under the terms of - * the GNU General Public License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * rusEfi is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without - * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with this program. - * If not, see . - */ - -#include "main.h" - -#if EFI_ENGINE_CONTROL || defined(__DOXYGEN__) - -#include "ignition_central.h" -#include "io_pins.h" -#include "signal_executor.h" -#include "main_trigger_callback.h" -#include "engine_configuration.h" -#include "efiGpio.h" - -extern engine_configuration_s *engineConfiguration; -extern board_configuration_s *boardConfiguration; - -void initIgnitionCentral(void) { - - for (int i = 0; i < engineConfiguration->cylindersCount; i++) { - io_pin_e pin = (io_pin_e)((int)SPARKOUT_1_OUTPUT + i); - outputPinRegisterExt2(getPinName(pin), pin, boardConfiguration->ignitionPins[i], &boardConfiguration->ignitionPinMode); - } -} - -#endif diff --git a/firmware/controllers/ignition_central.h b/firmware/controllers/ignition_central.h deleted file mode 100644 index 4dd21f47a6..0000000000 --- a/firmware/controllers/ignition_central.h +++ /dev/null @@ -1,25 +0,0 @@ -/** - * @file ignition_central.h - * @brief TODO - * - * @date Nov 15, 2013 - * @author Andrey Belomutskiy, (c) 2012-2014 - */ - -#ifndef IGNITION_CENTRAL_H_ -#define IGNITION_CENTRAL_H_ - -#include "signal_executor.h" - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -void initIgnitionCentral(void); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* IGNITION_CENTRAL_H_ */ diff --git a/firmware/controllers/injector_central.cpp b/firmware/controllers/injector_central.cpp index 4dcbae2962..4a69b79eb8 100644 --- a/firmware/controllers/injector_central.cpp +++ b/firmware/controllers/injector_central.cpp @@ -20,7 +20,7 @@ * If not, see . */ -// todo: merge with ignition_central and rename this file? +// todo: this file? #include "main.h" @@ -43,6 +43,14 @@ static bool_t isRunningBench = false; static int is_injector_enabled[MAX_INJECTOR_COUNT]; +void initIgnitionCentral(void) { + + for (int i = 0; i < engineConfiguration->cylindersCount; i++) { + io_pin_e pin = (io_pin_e)((int)SPARKOUT_1_OUTPUT + i); + outputPinRegisterExt2(getPinName(pin), pin, boardConfiguration->ignitionPins[i], &boardConfiguration->ignitionPinMode); + } +} + bool_t isRunningBenchTest(void) { return isRunningBench; } diff --git a/firmware/controllers/injector_central.h b/firmware/controllers/injector_central.h index 3520d14f91..1e34378d15 100644 --- a/firmware/controllers/injector_central.h +++ b/firmware/controllers/injector_central.h @@ -14,6 +14,7 @@ #include "engine.h" void initInjectorCentral(Engine *engine); +void initIgnitionCentral(void); bool_t isRunningBenchTest(void); int isInjectorEnabled(int cylinderId); void assertCylinderId(int cylinderId, const char *msg); diff --git a/firmware/controllers/map_multiplier_thread.cpp b/firmware/controllers/map_multiplier_thread.cpp deleted file mode 100644 index 57c9ca745c..0000000000 --- a/firmware/controllers/map_multiplier_thread.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/* - * @brief dead code - * - * - * map_multiplier.cpp - * - * @date Jul 23, 2013 - * @author Andrey Belomutskiy, (c) 2012-2014 - */ - -#include "main.h" -#include "map_multiplier_thread.h" -#include "map_adjuster.h" -#include "rpm_calculator.h" -#include "main_trigger_callback.h" -#include "allsensors.h" -#include "engine_math.h" -#include "engine.h" - -extern engine_configuration_s *engineConfiguration; - -static Logging logger; - -EXTERN_ENGINE; - -static THD_WORKING_AREA(maThreadStack, UTILITY_THREAD_STACK_SIZE); - -static void mapCallback(int rpm, float key, float value) { - Logging *logging = &logger; - appendPrintf(logging, "msg%s", DELIMETER); - - appendPrintf(logging, "map_adjusted: "); - appendPrintf(logging, "%d", rpm); - appendPrintf(logging, " "); - appendPrintf(logging, "%d", 100 * key); - appendPrintf(logging, " "); - appendPrintf(logging, "%d", 100 * value); - - appendMsgPostfix(logging); - scheduleLogging(logging); -} - -static int timeAtNotRunning = 0; - -static int isNewState = TRUE; - -static void maThread(int param) { - chRegSetThreadName("map adjustment"); - - while (TRUE) { - chThdSleepMilliseconds(100); - - systime_t now = chTimeNow(); -//todo? if (!isRunning()) { -// timeAtNotRunning = now; -// continue; -// } - - int wasNotRunningRecently = overflowDiff(now, timeAtNotRunning) < 60 * CH_FREQUENCY; - if (!wasNotRunningRecently) - continue; - if (isNewState) - scheduleMsg(&logger, "starting fuel map adjustment at %d", now); - isNewState = FALSE; - - // ideally this should be atomic, but hopefully it's good enough - int rpm = getRpm(); - float load = getEngineLoadT(PASS_ENGINE_PARAMETER); - float afr = getAfr(); - - addAfr(rpm, load, afr); - int total = runMapAdjustments(mapCallback); - if (total > 0) { -// scheduleSimpleMsg(&logger, "map adjusted for maf ", 100 * key); - } - } -} - -void initMapAdjusterThread(void) { - initLogging(&logger, "Map self learning thread"); - - initMapAdjuster(); - - chThdCreateStatic(maThreadStack, sizeof(maThreadStack), NORMALPRIO, (tfunc_t)maThread, NULL); -} diff --git a/firmware/controllers/map_multiplier_thread.h b/firmware/controllers/map_multiplier_thread.h deleted file mode 100644 index 4ee5d00149..0000000000 --- a/firmware/controllers/map_multiplier_thread.h +++ /dev/null @@ -1,15 +0,0 @@ -/** - * @file map_multiplier.h - * @brief dead code - * - * - * @date Jul 23, 2013 - * @author Andrey Belomutskiy, (c) 2012-2014 - */ - -#ifndef MAP_MULTIPLIER_H_ -#define MAP_MULTIPLIER_H_ - -void initMapAdjusterThread(void); - -#endif /* MAP_MULTIPLIER_H_ */ diff --git a/firmware/emulation/emulation.mk b/firmware/emulation/development.mk similarity index 100% rename from firmware/emulation/emulation.mk rename to firmware/emulation/development.mk diff --git a/firmware/hw_layer/HIP9011.cpp b/firmware/hw_layer/HIP9011.cpp index 9ba94e9002..7e453f5228 100644 --- a/firmware/hw_layer/HIP9011.cpp +++ b/firmware/hw_layer/HIP9011.cpp @@ -114,19 +114,19 @@ static msg_t ivThread(int param) { // spiExchange(driver, 1, tx_buff, rx_buff); // BAND_PASS_CMD - tx_buff[0] = 0b00000000 | (40 & 0x3F); + tx_buff[0] = 0x0 | (40 & 0x3F); spiExchange(driver, 1, tx_buff, rx_buff); - // Set the gain - tx_buff[0] = 0b10000000 | (49 & 0x3F); + // Set the gain 0b10000000 + tx_buff[0] = 0x80 | (49 & 0x3F); spiExchange(driver, 1, tx_buff, rx_buff); - // Set the integration time constant - tx_buff[0] = 0b11000000 | (31 & 0x1F); + // Set the integration time constant 0b11000000 + tx_buff[0] = 0xC0 | (31 & 0x1F); spiExchange(driver, 1, tx_buff, rx_buff); - // SET_ADVANCED_MODE - tx_buff[0] = 0b01110001; + // SET_ADVANCED_MODE 0b01110001 + tx_buff[0] = 0x71; spiExchange(driver, 1, tx_buff, rx_buff); spiUnselect(driver); diff --git a/firmware/iar/ch.ewp b/firmware/iar/ch.ewp index aa6cf27155..d78f06e151 100644 --- a/firmware/iar/ch.ewp +++ b/firmware/iar/ch.ewp @@ -2469,12 +2469,6 @@ $PROJ_DIR$\..\controllers\idle_thread.h - - $PROJ_DIR$\..\controllers\ignition_central.c - - - $PROJ_DIR$\..\controllers\ignition_central.h - $PROJ_DIR$\..\controllers\injector_central.cpp @@ -2499,12 +2493,6 @@ $PROJ_DIR$\..\controllers\map_averaging.h - - $PROJ_DIR$\..\controllers\map_multiplier_thread.cpp - - - $PROJ_DIR$\..\controllers\map_multiplier_thread.h - $PROJ_DIR$\..\controllers\obd2viaCAN.c @@ -2692,7 +2680,7 @@ $PROJ_DIR$\..\hw_layer\io_pins.c - $PROJ_DIR$\..\hw_layer\max31855.c + $PROJ_DIR$\..\hw_layer\max31855.cpp $PROJ_DIR$\..\hw_layer\max31855.h