void initInjectorCentral(void) { initLogging(&logger, "InjectorCentral"); chThdCreateStatic(benchThreadStack, sizeof(benchThreadStack), NORMALPRIO, (tfunc_t) benchThread, NULL); for (int i = 0; i < engineConfiguration->cylindersCount; i++) { is_injector_enabled[i] = true; } // todo: should we move this code closer to the injection logic? for (int i = 0; i < engineConfiguration->cylindersCount; i++) { io_pin_e pin = (io_pin_e) ((int) INJECTOR_1_OUTPUT + i); outputPinRegisterExt2(getPinName(pin), pin, boardConfiguration->injectionPins[i], &boardConfiguration->injectionPinMode); } printStatus(); addConsoleActionII("injector", setInjectorEnabled); addConsoleActionII("fuelpumpbench", &fuelpumpbench); addConsoleActionSSS("fuelbench", &fuelbench); addConsoleActionSSS("sparkbench", &sparkbench); addConsoleActionSSSSS("fuelbench2", &fuelbench2); addConsoleActionSSSSS("sparkbench2", &sparkbench2); }
static void initConfigActions(void) { addConsoleActionSS("set_float", (VoidCharPtrCharPtr) setFloat); addConsoleActionII("set_int", (VoidIntInt) setInt); addConsoleActionII("set_short", (VoidIntInt) setShort); addConsoleActionSSS("set_bit", setBit); addConsoleActionI("get_float", getFloat); addConsoleActionI("get_int", getInt); addConsoleActionI("get_short", getShort); addConsoleActionII("get_bit", getBit); }
void initPotentiometers(Logging *sharedLogger, board_configuration_s *boardConfiguration) { logger = sharedLogger; #if EFI_POTENTIOMETER if (boardConfiguration->digitalPotentiometerSpiDevice == SPI_NONE) { scheduleMsg(logger, "digiPot spi disabled"); return; } turnOnSpi(boardConfiguration->digitalPotentiometerSpiDevice); for (int i = 0; i < DIGIPOT_COUNT; i++) { brain_pin_e csPin = boardConfiguration->digitalPotentiometerChipSelect[i]; if (csPin == GPIO_UNASSIGNED) { continue; } initPotentiometer(&potConfig[i], getSpiDevice(boardConfiguration->digitalPotentiometerSpiDevice), csPin); } addConsoleActionII("pot", setPotResistanceCommand); addConsoleActionI("potd1", setPotValue1); setPotResistance(&potConfig[0], 0, 3000); setPotResistance(&potConfig[0], 1, 7000); #else print("digiPot logic disabled\r\n"); #endif }
void initInjectorCentral(Logging *sharedLogger) { logger = sharedLogger; chThdCreateStatic(benchThreadStack, sizeof(benchThreadStack), NORMALPRIO, (tfunc_t) benchThread, NULL); for (int i = 0; i < engineConfiguration->specs.cylindersCount; i++) { is_injector_enabled[i] = true; } startInjectionPins(); startIgnitionPins(); printStatus(); addConsoleActionII("injector", setInjectorEnabled); addConsoleAction("fuelpumpbench", fuelPumpBench); addConsoleActionS("fuelpumpbench2", fuelPumpBenchExt); addConsoleAction("fanbench", fanBench); addConsoleAction("milbench", milBench); addConsoleActionSSS("fuelbench", fuelbench); addConsoleActionSSS("sparkbench", sparkbench); addConsoleActionSSSSS("fuelbench2", fuelbench2); addConsoleActionSSSSS("sparkbench2", sparkbench2); }
void startIdleThread(Logging*sharedLogger, Engine *engine) { logger = sharedLogger; // todo: re-initialize idle pins on the fly initIdleHardware(); idlePositionController.init(); scheduleMsg(logger, "initial idle %d", idlePositionController.value); chThdCreateStatic(ivThreadStack, sizeof(ivThreadStack), NORMALPRIO, (tfunc_t) ivThread, NULL); // this is idle switch INPUT - sometimes there is a switch on the throttle pedal // this switch is not used yet if (boardConfiguration->clutchDownPin != GPIO_UNASSIGNED) mySetPadMode2("clutch down switch", boardConfiguration->clutchDownPin, getInputMode(boardConfiguration->clutchDownPinMode)); if (boardConfiguration->clutchUpPin != GPIO_UNASSIGNED) mySetPadMode2("clutch up switch", boardConfiguration->clutchUpPin, getInputMode(boardConfiguration->clutchUpPinMode)); addConsoleAction("idleinfo", showIdleInfo); addConsoleActionI("set_idle_enabled", (VoidInt) setIdleControlEnabled); addConsoleActionII("blipidle", blipIdle); // split this whole file into manual controller and auto controller? move these commands into the file // which would be dedicated to just auto-controller? addConsoleAction("idlebench", startIdleBench); apply(); }
void initSettings(void) { initLoggingExt(&logger, "settings control", LOGGING_BUFFER, sizeof(LOGGING_BUFFER)); addConsoleAction("showconfig", doPrintConfiguration); addConsoleAction("tempinfo", printTemperatureInfo); addConsoleAction("tpsinfo", printTPSInfo); addConsoleActionI("set_ignition_offset", setIgnitionOffset); addConsoleActionI("set_injection_offset", setInjectionOffset); addConsoleActionI("set_global_trigger_offset_angle", setGlobalTriggerAngleOffset); addConsoleActionI("set_analog_chart_mode", setAnalogChartMode); addConsoleActionI("set_fixed_mode_timing", setFixedModeTiming); addConsoleActionI("set_timing_mode", setTimingMode); addConsoleActionI("set_engine_type", setEngineType); addConsoleActionI("set_injection_pin_mode", setInjectionPinMode); addConsoleActionI("set_ignition_pin_mode", setIgnitionPinMode); addConsoleActionI("set_idle_pin", setIdlePin); addConsoleActionI("set_idle_pin_mode", setIdlePinMode); addConsoleActionI("set_fuel_pump_pin_mode", setFuelPumpPinMode); addConsoleActionI("set_malfunction_indicator_pin_mode", setMalfunctionIndicatorPinMode); addConsoleActionI("set_rpm_multiplier", setRpmMultiplier); // todo: start saving values into flash right away? addConsoleActionF("set_global_fuel_correction", setGlobalFuelCorrection); addConsoleActionII("set_cranking_fuel_min", setCrankingFuelMin); addConsoleActionII("set_cranking_fuel_max", setCrankingFuelMax); addConsoleActionI("set_cranking_rpm", setCrankingRpm); addConsoleActionF("set_cranking_timing_angle", setCrankingTimingAngle); addConsoleActionF("set_cranking_charge_angle", setCrankingChargeAngle); addConsoleActionI("set_ignition_mode", setIgnitionMode); addConsoleActionI("set_cranking_injection_mode", setCrankingInjectionMode); addConsoleActionI("set_injection_mode", setInjectionMode); addConsoleActionF("set_whole_fuel_map", setWholeFuelMapCmd); addConsoleActionSSS("set_fuel_map", setFuelMap); addConsoleActionF("set_whole_timing_map", setWholeTimingMap); addConsoleActionSSS("set_timing_map", setTimingMap); addConsoleActionI("set_rpm_hard_limit", setRpmHardLimit); addConsoleActionI("set_firing_order", setFiringOrder); addConsoleAction("enable_injection", enableInjection); addConsoleAction("disable_injection", disableInjection); }
static void initECUstimulator(void) { mySetPadMode("TEN", DIAG_PORT, DIAG_PIN, PAL_MODE_OUTPUT_PUSHPULL); addConsoleActionI("diag", setDiag); addConsoleAction("emu", startEmulator); addConsoleActionII("ad", printAdvance); setDiag(1); chThdCreateStatic(eeThreadStack, sizeof(eeThreadStack), NORMALPRIO, (tfunc_t) eeThread, NULL); }
void initWaveAnalyzer(void) { #if EFI_WAVE_ANALYZER || defined(__DOXYGEN__) initLogging(&logger, "wave"); initWave(WA_CHANNEL_1, 0); initWave(WA_CHANNEL_2, 1); addTriggerEventListener(&waTriggerEventListener, "wave analyzer", (void*) NULL); addConsoleActionII("set_logic_input_mode", setWaveModeSilent); chThdCreateStatic(waThreadStack, sizeof(waThreadStack), NORMALPRIO, waThread, (void*) NULL); #else print("wave disabled\r\n"); #endif }
void initWaveAnalyzer(Logging *sharedLogger) { logger = sharedLogger; if (hasFirmwareError()) { return; } #if EFI_WAVE_ANALYZER initWave(WA_CHANNEL_1, 0); initWave(WA_CHANNEL_2, 1); addTriggerEventListener(waTriggerEventListener, "wave analyzer", engine); addConsoleAction("waveinfo", showWaveInfo); addConsoleActionII("set_logic_input_mode", setWaveModeSilent); chThdCreateStatic(waThreadStack, sizeof(waThreadStack), NORMALPRIO, (tfunc_t)waThread, NULL); #else print("wave disabled\r\n"); #endif }
void initHardware(Logging *logger, Engine *engine) { engine_configuration_s *engineConfiguration = engine->engineConfiguration; efiAssertVoid(engineConfiguration!=NULL, "engineConfiguration"); board_configuration_s *boardConfiguration = &engineConfiguration->bc; printMsg(logger, "initHardware()"); // todo: enable protection. it's disabled because it takes // 10 extra seconds to re-flash the chip //flashProtect(); chMtxInit(&spiMtx); #if EFI_HISTOGRAMS /** * histograms is a data structure for CPU monitor, it does not depend on configuration */ initHistogramsModule(); #endif /* EFI_HISTOGRAMS */ /** * This is so early because we want to init logger * which would be used while finding trigger synch index * while config read */ initTriggerDecoder(); /** * We need the LED_ERROR pin even before we read configuration */ initPrimaryPins(); if (hasFirmwareError()) { return; } initDataStructures(PASS_ENGINE_PARAMETER_F); #if EFI_INTERNAL_FLASH palSetPadMode(CONFIG_RESET_SWITCH_PORT, CONFIG_RESET_SWITCH_PIN, PAL_MODE_INPUT_PULLUP); initFlash(engine); /** * this call reads configuration from flash memory or sets default configuration * if flash state does not look right. */ if (SHOULD_INGORE_FLASH()) { engineConfiguration->engineType = FORD_ASPIRE_1996; resetConfigurationExt(logger, engineConfiguration->engineType, engine); writeToFlash(); } else { readFromFlash(); } #else engineConfiguration->engineType = FORD_ASPIRE_1996; resetConfigurationExt(logger, engineConfiguration->engineType, engineConfiguration, engineConfiguration2, boardConfiguration); #endif /* EFI_INTERNAL_FLASH */ if (hasFirmwareError()) { return; } mySetPadMode2("board test", boardConfiguration->boardTestModeJumperPin, PAL_MODE_INPUT_PULLUP); bool isBoardTestMode_b = GET_BOARD_TEST_MODE_VALUE(); initAdcInputs(isBoardTestMode_b); if (isBoardTestMode_b) { // this method never returns initBoardTest(); } initRtc(); initOutputPins(); #if EFI_HIP_9011 initHip9011(); #endif /* EFI_HIP_9011 */ #if EFI_MAX_31855 initMax31855(boardConfiguration); #endif /* EFI_MAX_31855 */ #if EFI_CAN_SUPPORT initCan(); #endif /* EFI_CAN_SUPPORT */ // init_adc_mcp3208(&adcState, &SPID2); // requestAdcValue(&adcState, 0); // todo: figure out better startup logic initTriggerCentral(engine); #if EFI_SHAFT_POSITION_INPUT initShaftPositionInputCapture(); #endif /* EFI_SHAFT_POSITION_INPUT */ initSpiModules(boardConfiguration); #if EFI_FILE_LOGGING initMmcCard(); #endif /* EFI_FILE_LOGGING */ // initFixedLeds(); // initBooleanInputs(); #if EFI_UART_GPS initGps(); #endif #if ADC_SNIFFER initAdcDriver(); #endif #if EFI_HD44780_LCD // initI2Cmodule(); lcd_HD44780_init(); if (hasFirmwareError()) return; lcd_HD44780_print_string(VCS_VERSION); #endif /* EFI_HD44780_LCD */ addConsoleActionII("i2c", sendI2Cbyte); // while (true) { // for (int addr = 0x20; addr < 0x28; addr++) { // sendI2Cbyte(addr, 0); // int err = i2cGetErrors(&I2CD1); // print("I2C: err=%x from %d\r\n", err, addr); // chThdSleepMilliseconds(5); // sendI2Cbyte(addr, 255); // chThdSleepMilliseconds(5); // } // } printMsg(logger, "initHardware() OK!"); }
void initSettings(engine_configuration_s *engineConfiguration) { addConsoleActionP("showconfig", (VoidPtr) doPrintConfiguration, &engine); addConsoleAction("tempinfo", printTemperatureInfo); addConsoleAction("tpsinfo", printTPSInfo); addConsoleAction("info", printAllInfo); addConsoleActionF("set_ignition_offset", setIgnitionOffset); addConsoleActionF("set_injection_offset", setInjectionOffset); addConsoleActionF("set_global_trigger_offset_angle", setGlobalTriggerAngleOffset); addConsoleActionI("set_sensor_chart_mode", setSensorChartMode); addConsoleActionI("set_fixed_mode_timing", setFixedModeTiming); addConsoleActionI("set_timing_mode", setTimingMode); addConsoleActionI("set_engine_type", setEngineType); addConsoleActionI("set_injection_pin_mode", setInjectionPinMode); addConsoleActionI("set_ignition_pin_mode", setIgnitionPinMode); addConsoleActionI("set_idle_pin_mode", setIdlePinMode); addConsoleActionI("set_fuel_pump_pin_mode", setFuelPumpPinMode); addConsoleActionI("set_malfunction_indicator_pin_mode", setMalfunctionIndicatorPinMode); addConsoleActionI("set_operation_mode", setOM); // todo: start saving values into flash right away? addConsoleActionF("set_global_fuel_correction", setGlobalFuelCorrection); addConsoleActionF("set_cranking_fuel", setCrankingFuel); addConsoleActionI("set_cranking_rpm", setCrankingRpm); addConsoleActionF("set_cranking_timing_angle", setCrankingTimingAngle); addConsoleActionF("set_cranking_charge_angle", setCrankingChargeAngle); addConsoleActionI("set_ignition_mode", setIgnitionMode); addConsoleActionI("set_cranking_injection_mode", setCrankingInjectionMode); addConsoleActionI("set_injection_mode", setInjectionMode); addConsoleActionF("set_whole_phase_map", setWholePhaseMapCmd); addConsoleActionF("set_whole_timing_map", setWholeTimingMapCmd); addConsoleActionF("set_whole_fuel_map", setWholeFuelMapCmd); addConsoleActionF("set_whole_ve_map", setWholeVeCmd); addConsoleActionSSS("set_fuel_map", setFuelMap); addConsoleActionF("set_whole_timing_map", setWholeTimingMap); addConsoleActionSSS("set_timing_map", setTimingMap); addConsoleActionI("set_rpm_hard_limit", setRpmHardLimit); addConsoleActionI("set_firing_order", setFiringOrder); addConsoleActionI("set_algorithm", setAlgorithmInt); addConsoleAction("stopengine", (Void) stopEngine); // todo: refactor this - looks like all boolean flags should be controlled with less code duplication addConsoleAction("enable_injection", enableInjection); addConsoleAction("disable_injection", disableInjection); addConsoleAction("enable_ignition", enableIgnition); addConsoleAction("disable_ignition", disableIgnition); addConsoleActionI("enable_spi", enableSpi); addConsoleActionI("disable_spi", disableSpi); addConsoleActionS("enable", enable); addConsoleActionS("disable", disable); addConsoleActionII("set_toothed_wheel", setToothedWheel); addConsoleActionI("set_trigger_type", setTriggerType); addConsoleActionF("set_vbatt_divider", setVBattDivider); addConsoleActionF("set_injector_lag", setInjectorLag); addConsoleActionF("set_clt_bias", setCltBias); addConsoleActionF("set_iat_bias", setIatBias); addConsoleActionI("set_idle_solenoid_freq", setIdleSolenoidFrequency); addConsoleActionFF("set_fan", setFanSetting); #if EFI_PROD_CODE addConsoleActionS("showpin", showPinFunction); addConsoleActionSS("set_injection_pin", setInjectionPin); addConsoleActionSS("set_ignition_pin", setIgnitionPin); addConsoleActionSS("set_trigger_input_pin", setTriggerInputPin); addConsoleActionSS("set_trigger_simulator_pin", setTriggerSimulatorPin); addConsoleActionSSP("set_egt_cs_pin", (VoidCharPtrCharPtrVoidPtr) setEgtCSPin, boardConfiguration); addConsoleActionI("set_egt_spi", setEgtSpi); addConsoleActionSS("set_trigger_simulator_mode", setTriggerSimulatorMode); addConsoleActionS("set_fuel_pump_pin", setFuelPumpPin); addConsoleActionS("set_ac_pin", setACPin); addConsoleActionS("set_alternator_pin", setAlternatorPin); addConsoleActionS("set_idle_pin", setIdlePin); addConsoleActionS("set_main_relay_pin", setMainRelayPin); addConsoleActionSS("set", setValue); addConsoleActionS("get", getValue); #if HAL_USE_ADC || defined(__DOXYGEN__) addConsoleActionSS("set_analog_input_pin", setAnalogInputPin); #endif addConsoleActionSS("set_logic_input_pin", setLogicInputPin); addConsoleActionI("set_pot_spi", setPotSpi); #endif /* EFI_PROD_CODE */ }
void initHardware(Logging *l) { efiAssertVoid(CUSTOM_IH_STACK, getRemainingStack(chThdGetSelfX()) > 256, "init h"); sharedLogger = l; engine_configuration_s *engineConfiguration = engine->engineConfigurationPtr; efiAssertVoid(CUSTOM_EC_NULL, engineConfiguration!=NULL, "engineConfiguration"); board_configuration_s *boardConfiguration = &engineConfiguration->bc; printMsg(sharedLogger, "initHardware()"); // todo: enable protection. it's disabled because it takes // 10 extra seconds to re-flash the chip //flashProtect(); chMtxObjectInit(&spiMtx); #if EFI_HISTOGRAMS /** * histograms is a data structure for CPU monitor, it does not depend on configuration */ initHistogramsModule(); #endif /* EFI_HISTOGRAMS */ /** * We need the LED_ERROR pin even before we read configuration */ initPrimaryPins(); if (hasFirmwareError()) { return; } #if EFI_INTERNAL_FLASH palSetPadMode(CONFIG_RESET_SWITCH_PORT, CONFIG_RESET_SWITCH_PIN, PAL_MODE_INPUT_PULLUP); initFlash(sharedLogger); /** * this call reads configuration from flash memory or sets default configuration * if flash state does not look right. */ if (SHOULD_INGORE_FLASH()) { engineConfiguration->engineType = DEFAULT_ENGINE_TYPE; resetConfigurationExt(sharedLogger, engineConfiguration->engineType PASS_ENGINE_PARAMETER_SUFFIX); writeToFlashNow(); } else { readFromFlash(); } #else engineConfiguration->engineType = DEFAULT_ENGINE_TYPE; resetConfigurationExt(sharedLogger, engineConfiguration->engineType PASS_ENGINE_PARAMETER_SUFFIX); #endif /* EFI_INTERNAL_FLASH */ #if EFI_HD44780_LCD // initI2Cmodule(); lcd_HD44780_init(sharedLogger); if (hasFirmwareError()) return; lcd_HD44780_print_string(VCS_VERSION); #endif /* EFI_HD44780_LCD */ if (hasFirmwareError()) { return; } #if EFI_SHAFT_POSITION_INPUT || defined(__DOXYGEN__) initTriggerDecoder(); #endif bool isBoardTestMode_b; if (CONFIGB(boardTestModeJumperPin) != GPIO_UNASSIGNED) { efiSetPadMode("board test", CONFIGB(boardTestModeJumperPin), PAL_MODE_INPUT_PULLUP); isBoardTestMode_b = (!efiReadPin(CONFIGB(boardTestModeJumperPin))); // we can now relese this pin, it is actually used as output sometimes unmarkPin(CONFIGB(boardTestModeJumperPin)); } else { isBoardTestMode_b = false; } #if HAL_USE_ADC || defined(__DOXYGEN__) initAdcInputs(isBoardTestMode_b); #endif if (isBoardTestMode_b) { // this method never returns initBoardTest(); } initRtc(); initOutputPins(); #if EFI_MAX_31855 initMax31855(sharedLogger, getSpiDevice(CONFIGB(max31855spiDevice)), CONFIGB(max31855_cs)); #endif /* EFI_MAX_31855 */ #if EFI_CAN_SUPPORT initCan(); #endif /* EFI_CAN_SUPPORT */ // init_adc_mcp3208(&adcState, &SPID2); // requestAdcValue(&adcState, 0); #if EFI_SHAFT_POSITION_INPUT || defined(__DOXYGEN__) // todo: figure out better startup logic initTriggerCentral(sharedLogger); #endif /* EFI_SHAFT_POSITION_INPUT */ turnOnHardware(sharedLogger); #if HAL_USE_SPI || defined(__DOXYGEN__) initSpiModules(boardConfiguration); #endif #if EFI_HIP_9011 || defined(__DOXYGEN__) initHip9011(sharedLogger); #endif /* EFI_HIP_9011 */ #if EFI_FILE_LOGGING || defined(__DOXYGEN__) initMmcCard(); #endif /* EFI_FILE_LOGGING */ #if EFI_MEMS || defined(__DOXYGEN__) initAccelerometer(PASS_ENGINE_PARAMETER_SIGNATURE); #endif // initFixedLeds(); #if EFI_BOSCH_YAW || defined(__DOXYGEN__) initBoschYawRateSensor(); #endif /* EFI_BOSCH_YAW */ // initBooleanInputs(); #if EFI_UART_GPS || defined(__DOXYGEN__) initGps(); #endif #if EFI_SERVO initServo(); #endif #if ADC_SNIFFER || defined(__DOXYGEN__) initAdcDriver(); #endif #if HAL_USE_I2C || defined(__DOXYGEN__) addConsoleActionII("i2c", sendI2Cbyte); #endif // USBMassStorageDriver UMSD1; // while (true) { // for (int addr = 0x20; addr < 0x28; addr++) { // sendI2Cbyte(addr, 0); // int err = i2cGetErrors(&I2CD1); // print("I2C: err=%x from %d\r\n", err, addr); // chThdSleepMilliseconds(5); // sendI2Cbyte(addr, 255); // chThdSleepMilliseconds(5); // } // } #if EFI_VEHICLE_SPEED || defined(__DOXYGEN__) initVehicleSpeed(sharedLogger); #endif #if EFI_CDM_INTEGRATION cdmIonInit(); #endif #if HAL_USE_EXT || defined(__DOXYGEN__) initJoystick(sharedLogger); #endif calcFastAdcIndexes(); printMsg(sharedLogger, "initHardware() OK!"); }
TEST(misc, testConsoleLogic) { print("******************************************* testConsoleLogic\r\n"); resetConsoleActions(); helpCommand(); char * cmd = "he ha"; ASSERT_EQ(2, findEndOfToken(cmd)); cmd = "\"hee\" ha"; ASSERT_EQ(5, findEndOfToken(cmd)); cmd = "\"h e\" ha"; ASSERT_EQ(5, findEndOfToken(cmd)); strcpy(buffer, "echo"); ASSERT_TRUE(strEqual("echo", unquote(buffer))); strcpy(buffer, "\"echo\""); ASSERT_TRUE(strEqual("echo", unquote(buffer))) << "unquote quoted"; char *ptr = validateSecureLine(UNKNOWN_COMMAND); ASSERT_EQ(0, strcmp(UNKNOWN_COMMAND, ptr)); ASSERT_EQ(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); ASSERT_EQ(239, lastInteger); print("\r\naddConsoleActionI 240 with two spaces\r\n"); strcpy(buffer, "echoi 240"); handleConsoleLine(buffer); ASSERT_EQ(240, lastInteger); print("\r\naddConsoleActionII\r\n"); addConsoleActionII("echoii", testEchoII); strcpy(buffer, "echoii 22 239"); handleConsoleLine(buffer); ASSERT_EQ(22, lastInteger); ASSERT_EQ(239, lastInteger2); print("\r\naddConsoleActionII three spaces\r\n"); strcpy(buffer, "echoii 21 220"); handleConsoleLine(buffer); ASSERT_EQ(21, lastInteger); ASSERT_EQ(220, lastInteger2); print("\r\addConsoleActionSSS\r\n"); addConsoleActionSSS("echosss", testEchoSSS); strcpy(buffer, "echosss 111 222 333"); handleConsoleLine(buffer); ASSERT_EQ(111, atoi(lastFirst)); ASSERT_EQ(333, atoi(lastThird)); strcpy(buffer, "echosss \" 1\" 222 333"); handleConsoleLine(buffer); ASSERT_TRUE(strEqual("\" 1\"", lastFirst)); //addConsoleActionSSS("GPS", testGpsParser); }
void initHardware() { // todo: enable protection. it's disabled because it takes // 10 extra seconds to re-flash the chip //flashProtect(); /** * histograms is a data structure for CPU monitor, it does not depend on configuration */ initHistogramsModule(); /** * We need the LED_ERROR pin even before we read configuration */ initPrimaryPins(); /** * this call reads configuration from flash memory or sets default configuration * if flash state does not look right. */ initFlash(); initRtc(); initOutputPins(); initAdcInputs(); #if EFI_HIP_9011 initHip9011(); #endif /* EFI_HIP_9011 */ #if EFI_CAN_SUPPORT initCan(); #endif /* EFI_CAN_SUPPORT */ // init_adc_mcp3208(&adcState, &SPID2); // requestAdcValue(&adcState, 0); // todo: figure out better startup logic initTriggerCentral(); initShaftPositionInputCapture(); initSpiModules(); #if EFI_FILE_LOGGING initMmcCard(); #endif /* EFI_FILE_LOGGING */ // initFixedLeds(); // initBooleanInputs(); #if EFI_UART_GPS initGps(); #endif #if ADC_SNIFFER initAdcDriver(); #endif #if EFI_HD44780_LCD // initI2Cmodule(); lcd_HD44780_init(); char buffer[16]; itoa10(buffer, SVN_VERSION); lcd_HD44780_print_string(buffer); #endif addConsoleActionII("i2c", sendI2Cbyte); // while (true) { // for (int addr = 0x20; addr < 0x28; addr++) { // sendI2Cbyte(addr, 0); // int err = i2cGetErrors(&I2CD1); // print("I2C: err=%x from %d\r\n", err, addr); // chThdSleepMilliseconds(5); // sendI2Cbyte(addr, 255); // chThdSleepMilliseconds(5); // } // } initBoardTest(); }