From 11898863e2187cde16f273c6d00d22ad41ca88fa Mon Sep 17 00:00:00 2001 From: rusEfi Date: Fri, 26 Sep 2014 08:02:50 -0500 Subject: [PATCH] auto-sync --- firmware/controllers/system/efiGpio.cpp | 18 +++++ firmware/controllers/system/efiGpio.h | 38 +++++++++++ firmware/controllers/system/system.mk | 1 + firmware/hw_layer/gpio_helper.c | 4 -- firmware/hw_layer/gpio_helper.h | 17 +---- firmware/hw_layer/io_pins.c | 2 +- firmware/rusefi.cpp | 2 +- win32_functional_tests/main.c | 1 + .../simulator/framework.cpp | 68 +++++++++++++++++++ win32_functional_tests/simulator/framework.h | 9 ++- .../simulator/rusEfiFunctionalTest.cpp | 68 ------------------- .../simulator/rusEfiFunctionalTest.h | 1 - 12 files changed, 138 insertions(+), 91 deletions(-) create mode 100644 firmware/controllers/system/efiGpio.cpp create mode 100644 firmware/controllers/system/efiGpio.h diff --git a/firmware/controllers/system/efiGpio.cpp b/firmware/controllers/system/efiGpio.cpp new file mode 100644 index 0000000000..34a124c4cf --- /dev/null +++ b/firmware/controllers/system/efiGpio.cpp @@ -0,0 +1,18 @@ +/** + * @file efiGpio.cpp + * + * @date Sep 26, 2014 + * @author Andrey Belomutskiy, (c) 2012-2014 + */ + +#include "main.h" +#include "efiGpio.h" +#include "io_pins.h" + +// todo: clean this mess, this should become 'static'/private +OutputPin outputs[IO_PIN_COUNT]; + + +int getLogicPinValue(OutputPin * outputPin) { + return outputPin->currentLogicValue; +} diff --git a/firmware/controllers/system/efiGpio.h b/firmware/controllers/system/efiGpio.h new file mode 100644 index 0000000000..790ce2ce4d --- /dev/null +++ b/firmware/controllers/system/efiGpio.h @@ -0,0 +1,38 @@ +/** + * @file efiGpio.h + * + * @date Sep 26, 2014 + * @author Andrey Belomutskiy, (c) 2012-2014 + */ +#ifndef EFIGPIO_H_ +#define EFIGPIO_H_ + +#include "main.h" + +/** + * @brief Single output pin reference and state + */ +typedef struct { +#if EFI_PROD_CODE + GPIO_TypeDef *port; + int pin; +#endif /* EFI_PROD_CODE */ + /** + * we track current pin status so that we do not touch the actual hardware if we want to write new pin bit + * which is same as current pin value. This maybe helps in case of status leds, but maybe it's a total over-engineering + */ + int currentLogicValue; +} OutputPin; + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +int getLogicPinValue(OutputPin * outputPin); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* EFIGPIO_H_ */ diff --git a/firmware/controllers/system/system.mk b/firmware/controllers/system/system.mk index 7fa596a215..811da105f7 100644 --- a/firmware/controllers/system/system.mk +++ b/firmware/controllers/system/system.mk @@ -4,4 +4,5 @@ SYSTEMSRC = \ SYSTEMSRC_CPP = $(PROJECT_DIR)/controllers/system/pwm_generator_logic.cpp \ $(PROJECT_DIR)/controllers/system/event_queue.cpp \ + $(PROJECT_DIR)/controllers/system/efiGpio.cpp \ $(PROJECT_DIR)/controllers/system/SingleTimerExecutor.cpp \ No newline at end of file diff --git a/firmware/hw_layer/gpio_helper.c b/firmware/hw_layer/gpio_helper.c index b3735f5c60..7c4d7df8a2 100644 --- a/firmware/hw_layer/gpio_helper.c +++ b/firmware/hw_layer/gpio_helper.c @@ -47,10 +47,6 @@ void initOutputPin(const char *msg, OutputPin *outputPin, GPIO_TypeDef *port, ui initOutputPinExt(msg, outputPin, port, pinNumber, PAL_MODE_OUTPUT_PUSHPULL); } -int getLogicPinValue(OutputPin * outputPin) { - return outputPin->currentLogicValue; -} - /** * Set's the value of the pin. On this layer the value is assigned as is, without any conversion. */ diff --git a/firmware/hw_layer/gpio_helper.h b/firmware/hw_layer/gpio_helper.h index 827634b2d9..5a9e6ac42a 100644 --- a/firmware/hw_layer/gpio_helper.h +++ b/firmware/hw_layer/gpio_helper.h @@ -9,25 +9,12 @@ #ifndef GPIO_HELPER_H_ #define GPIO_HELPER_H_ +#include "efiGpio.h" + #define INITIAL_PIN_STATE -1 - -/** - * @brief Single output pin reference and state - */ -typedef struct { - GPIO_TypeDef *port; - int pin; - /** - * we track current pin status so that we do not touch the actual hardware if we want to write new pin bit - * which is same as current pin value. This maybe helps in case of status leds, but maybe it's a total over-engineering - */ - int currentLogicValue; -} OutputPin; - void initOutputPin(const char *msg, OutputPin *outputPin, GPIO_TypeDef *port, uint32_t pinNumber); void initOutputPinExt(const char *msg, OutputPin *outputPin, GPIO_TypeDef *port, uint32_t pinNumber, iomode_t mode); -int getLogicPinValue(OutputPin * outputPin); void setPinValue(OutputPin * outputPin, int electricalValue, int logicValue); #endif /* GPIO_HELPER_H_ */ diff --git a/firmware/hw_layer/io_pins.c b/firmware/hw_layer/io_pins.c index b1c8deb12a..3080293040 100644 --- a/firmware/hw_layer/io_pins.c +++ b/firmware/hw_layer/io_pins.c @@ -26,7 +26,7 @@ extern board_configuration_s *boardConfiguration; static Logging logger; static pin_output_mode_e *pinDefaultState[IO_PIN_COUNT]; -static OutputPin outputs[IO_PIN_COUNT]; +extern OutputPin outputs[IO_PIN_COUNT]; static io_pin_e leds[] = { LED_WARNING, LED_RUNNING, LED_ERROR, LED_COMMUNICATION_1, LED_DEBUG, LED_EXT_1, LED_CHECK_ENGINE }; diff --git a/firmware/rusefi.cpp b/firmware/rusefi.cpp index 95098b6a93..c3d57652f5 100644 --- a/firmware/rusefi.cpp +++ b/firmware/rusefi.cpp @@ -235,5 +235,5 @@ void firmwareError(const char *fmt, ...) { } int getRusEfiVersion(void) { - return 20140925; + return 20140926; } diff --git a/win32_functional_tests/main.c b/win32_functional_tests/main.c index fa6de7c79e..dc2bfe76ac 100644 --- a/win32_functional_tests/main.c +++ b/win32_functional_tests/main.c @@ -17,6 +17,7 @@ #include "main.h" #include "chprintf.h" #include "rusEfiFunctionalTest.h" +#include "framework.h" #define SHELL_WA_SIZE THD_WA_SIZE(4096) #define CONSOLE_WA_SIZE THD_WA_SIZE(4096) diff --git a/win32_functional_tests/simulator/framework.cpp b/win32_functional_tests/simulator/framework.cpp index 2844a01504..1fce211485 100644 --- a/win32_functional_tests/simulator/framework.cpp +++ b/win32_functional_tests/simulator/framework.cpp @@ -5,5 +5,73 @@ * @author Andrey Belomutskiy, (c) 2012-2014 */ +#include "main.h" +#include "framework.h" +uint64_t getTimeNowNt(void) { + return getTimeNowUs() * US_TO_NT_MULTIPLIER; +} +uint64_t getTimeNowUs(void) { + return chTimeNow() * (1000000 / CH_FREQUENCY); +} + +efitimems_t currentTimeMillis(void) { + return getTimeNowUs() / 1000; +} + +int getTimeNowSeconds(void) { + return chTimeNow() / CH_FREQUENCY; +} + +int getRusEfiVersion(void) { + return 239; +} + +static size_t wt_writes(void *ip, const uint8_t *bp, size_t n) { + printToWin32Console((char*)bp); + return CONSOLE_PORT->vmt->write(CONSOLE_PORT, bp, n); +} + +static size_t wt_reads(void *ip, uint8_t *bp, size_t n) { + return CONSOLE_PORT->vmt->read(CONSOLE_PORT, bp, n); +} + +static msg_t wt_putt(void *instance, uint8_t b, systime_t time) { + return CONSOLE_PORT->vmt->putt(CONSOLE_PORT, b, time); +} + +static msg_t wt_gett(void *instance, systime_t time) { + return CONSOLE_PORT->vmt->gett(CONSOLE_PORT, time); +} + +static size_t wt_writet(void *instance, const uint8_t *bp, + size_t n, systime_t time) { + return CONSOLE_PORT->vmt->writet(CONSOLE_PORT, bp, n, time); +} + +static size_t wt_readt(void *instance, uint8_t *bp, size_t n, systime_t time) { + return CONSOLE_PORT->vmt->readt(CONSOLE_PORT, bp, n, time); +} + +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 CONSOLE_PORT->vmt->put(CONSOLE_PORT, b); +} + +static msg_t wt_get(void *ip) { +// cputs("wt_get"); + //return 0; + return CONSOLE_PORT->vmt->get(CONSOLE_PORT); +} + +static const struct Win32TestStreamVMT vmt = { wt_writes, wt_reads, wt_put, wt_get, wt_putt, wt_gett, wt_writet, wt_readt }; + +void initTestStream(TestStream *ts) { + ts->vmt = &vmt; +} diff --git a/win32_functional_tests/simulator/framework.h b/win32_functional_tests/simulator/framework.h index d3fa103e5f..5c2e130c7b 100644 --- a/win32_functional_tests/simulator/framework.h +++ b/win32_functional_tests/simulator/framework.h @@ -7,8 +7,15 @@ #ifndef FRAMEWORK_H_ #define FRAMEWORK_H_ +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ +void initTestStream(TestStream *ts); - +#ifdef __cplusplus +} +#endif /* __cplusplus */ #endif /* FRAMEWORK_H_ */ diff --git a/win32_functional_tests/simulator/rusEfiFunctionalTest.cpp b/win32_functional_tests/simulator/rusEfiFunctionalTest.cpp index f25badc738..f9c5671b51 100644 --- a/win32_functional_tests/simulator/rusEfiFunctionalTest.cpp +++ b/win32_functional_tests/simulator/rusEfiFunctionalTest.cpp @@ -103,54 +103,6 @@ void printPendingMessages(void) { waveChart.publishChartIfFull(); } -static size_t wt_writes(void *ip, const uint8_t *bp, size_t n) { - printToWin32Console((char*)bp); - return CONSOLE_PORT->vmt->write(CONSOLE_PORT, bp, n); -} - -static size_t wt_reads(void *ip, uint8_t *bp, size_t n) { - return CONSOLE_PORT->vmt->read(CONSOLE_PORT, bp, n); -} - -static msg_t wt_putt(void *instance, uint8_t b, systime_t time) { - return CONSOLE_PORT->vmt->putt(CONSOLE_PORT, b, time); -} - -static msg_t wt_gett(void *instance, systime_t time) { - return CONSOLE_PORT->vmt->gett(CONSOLE_PORT, time); -} - -static size_t wt_writet(void *instance, const uint8_t *bp, - size_t n, systime_t time) { - return CONSOLE_PORT->vmt->writet(CONSOLE_PORT, bp, n, time); -} - -static size_t wt_readt(void *instance, uint8_t *bp, size_t n, systime_t time) { - return CONSOLE_PORT->vmt->readt(CONSOLE_PORT, bp, n, time); -} - -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 CONSOLE_PORT->vmt->put(CONSOLE_PORT, b); -} - -static msg_t wt_get(void *ip) { -// cputs("wt_get"); - //return 0; - return CONSOLE_PORT->vmt->get(CONSOLE_PORT); -} - -static const struct Win32TestStreamVMT vmt = { wt_writes, wt_reads, wt_put, wt_get, wt_putt, wt_gett, wt_writet, wt_readt }; - -void initTestStream(TestStream *ts) { - ts->vmt = &vmt; -} - int isSerialOverTcpReady; bool isConsoleReady(void) { @@ -190,23 +142,3 @@ SerialDriver * getConsoleChannel(void) { void chDbgPanic3(const char *msg, const char * file, int line) { onFatalError(msg, file, line); } - -uint64_t getTimeNowNt(void) { - return getTimeNowUs() * US_TO_NT_MULTIPLIER; -} - -uint64_t getTimeNowUs(void) { - return chTimeNow() * (1000000 / CH_FREQUENCY); -} - -efitimems_t currentTimeMillis(void) { - return getTimeNowUs() / 1000; -} - -int getTimeNowSeconds(void) { - return chTimeNow() / CH_FREQUENCY; -} - -int getRusEfiVersion(void) { - return 239; -} diff --git a/win32_functional_tests/simulator/rusEfiFunctionalTest.h b/win32_functional_tests/simulator/rusEfiFunctionalTest.h index 8a82dbe52b..be03c0595b 100644 --- a/win32_functional_tests/simulator/rusEfiFunctionalTest.h +++ b/win32_functional_tests/simulator/rusEfiFunctionalTest.h @@ -14,7 +14,6 @@ extern "C" #endif /* __cplusplus */ void rusEfiFunctionalTest(void); -void initTestStream(TestStream *ts); void printPendingMessages(void); #ifdef __cplusplus