CJ125 unit-tests coverage #617

This commit is contained in:
rusefi 2018-11-03 11:44:57 -04:00
parent f9fb3d8168
commit b7b2e53d55
3 changed files with 18 additions and 10 deletions

View File

@ -72,9 +72,12 @@ extern bool main_loop_started;
#include "max31855.h" #include "max31855.h"
#include "vehicle_speed.h" #include "vehicle_speed.h"
#include "SingleTimerExecutor.h" #include "SingleTimerExecutor.h"
#include "CJ125.h"
#endif /* EFI_PROD_CODE */ #endif /* EFI_PROD_CODE */
#if EFI_CJ125 || defined(__DOXYGEN__)
#include "CJ125.h"
#endif /* EFI_CJ125 */
#if EFI_MAP_AVERAGING #if EFI_MAP_AVERAGING
#include "map_averaging.h" #include "map_averaging.h"
#endif #endif

View File

@ -14,9 +14,9 @@
#include "analog_input.h" #include "analog_input.h"
#include "cyclic_buffer.h" #include "cyclic_buffer.h"
#if EFI_PROD_CODE || defined(__DOXYGEN__) #if EFI_CJ125 || defined(__DOXYGEN__)
#include "CJ125.h" #include "CJ125.h"
#endif /* EFI_PROD_CODE */ #endif /* EFI_CJ125 */
EXTERN_ENGINE; EXTERN_ENGINE;

View File

@ -47,10 +47,11 @@ static THD_WORKING_AREA(cjThreadStack, UTILITY_THREAD_STACK_SIZE);
static SPIDriver *driver; static SPIDriver *driver;
#if EFI_PROD_CODE
static SPIConfig cj125spicfg = { NULL, static SPIConfig cj125spicfg = { NULL,
/* HW dependent part.*/ /* HW dependent part.*/
NULL, 0, SPI_CR1_MSTR | SPI_CR1_CPHA | SPI_CR1_BR_0 | SPI_CR1_BR_1 | SPI_CR1_BR_2 }; NULL, 0, SPI_CR1_MSTR | SPI_CR1_CPHA | SPI_CR1_BR_0 | SPI_CR1_BR_1 | SPI_CR1_BR_2 };
#endif
// Used by CJ125 driver state machine // Used by CJ125 driver state machine
static volatile cj125_state_e state = CJ125_IDLE; static volatile cj125_state_e state = CJ125_IDLE;
@ -125,24 +126,28 @@ static void cjWriteRegister(unsigned char regAddr, unsigned char regValue) {
static float getUr() { static float getUr() {
if (CONFIG(cj125ur) != EFI_ADC_NONE) { if (CONFIG(cj125ur) != EFI_ADC_NONE) {
#if EFI_PROD_CODE
#ifdef EFI_CJ125_DIRECTLY_CONNECTED_UR #ifdef EFI_CJ125_DIRECTLY_CONNECTED_UR
// in case of directly connected Ur signal from CJ125 to the ADC pin of MCU // in case of directly connected Ur signal from CJ125 to the ADC pin of MCU
return getVoltage("cj125ur", CONFIG(cj125ur)); return getVoltage("cj125ur", CONFIG(cj125ur));
#else #else
// if a standard voltage division scheme with OpAmp is used // if a standard voltage division scheme with OpAmp is used
return getVoltageDivided("cj125ur", CONFIG(cj125ur)); return getVoltageDivided("cj125ur", CONFIG(cj125ur));
#endif #endif /* EFI_CJ125_DIRECTLY_CONNECTED_UR */
#endif /* EFI_PROD_CODE */
} }
return 0.0f; return 0.0f;
} }
static float getUa() { static float getUa() {
if (CONFIG(cj125ua) != EFI_ADC_NONE) { if (CONFIG(cj125ua) != EFI_ADC_NONE) {
#if EFI_PROD_CODE
if (engineConfiguration->cj125isUaDivided) { if (engineConfiguration->cj125isUaDivided) {
return getVoltageDivided("cj125ua", CONFIG(cj125ua)); return getVoltageDivided("cj125ua", CONFIG(cj125ua));
} else { } else {
return getVoltage("cj125ua", CONFIG(cj125ua)); return getVoltage("cj125ua", CONFIG(cj125ua));
} }
#endif /* EFI_PROD_CODE */
} }
return 0.0f; return 0.0f;
@ -400,16 +405,16 @@ void cj125defaultPinout() {
} }
static void cjStartSpi(void) { static void cjStartSpi(void) {
cj125spicfg.ssport = getHwPort("cj125", boardConfiguration->cj125CsPin);
cj125spicfg.sspad = getHwPin("cj125", boardConfiguration->cj125CsPin);
driver = getSpiDevice(engineConfiguration->cj125SpiDevice);
cj125Cs.initPin("cj125 CS", boardConfiguration->cj125CsPin, cj125Cs.initPin("cj125 CS", boardConfiguration->cj125CsPin,
&engineConfiguration->cj125CsPinMode); &engineConfiguration->cj125CsPinMode);
#if EFI_PROD_CODE
cj125spicfg.ssport = getHwPort("cj125", boardConfiguration->cj125CsPin);
cj125spicfg.sspad = getHwPin("cj125", boardConfiguration->cj125CsPin);
driver = getSpiDevice(engineConfiguration->cj125SpiDevice);
scheduleMsg(logger, "cj125: Starting SPI driver"); scheduleMsg(logger, "cj125: Starting SPI driver");
spiStart(driver, &cj125spicfg); spiStart(driver, &cj125spicfg);
#endif
} }
static msg_t cjThread(void) static msg_t cjThread(void)