Exemplo n.º 1
0
void runRusEfi(void) {
	msObjectInit(&firmwareErrorMessageStream, errorMessageBuffer, sizeof(errorMessageBuffer), 0);

	// that's dirty, this assignment should be nicer or in a better spot
	engine->engineConfiguration = engineConfiguration;
	engine->engineConfiguration2 = engineConfiguration2;
	engineConfiguration2->engineConfiguration = engineConfiguration;

	initErrorHandling();

	/**
	 * First data structure keeps track of which hardware I/O pins are used by whom
	 */
	initPinRepository();

	/**
	 * Next we should initialize serial port console, it's important to know what's going on
	 */
	initializeConsole();
	initLogging(&logging, "main");

	engine->init();

	addConsoleAction("reset", scheduleReset);

	/**
	 * Initialize hardware drivers
	 */
	initHardware(&logging, engine);

	initStatusLoop(engine);
	/**
	 * Now let's initialize actual engine control logic
	 * todo: should we initialize some? most? controllers before hardware?
	 */
	initEngineContoller(engine);

#if EFI_PERF_METRICS || defined(__DOXYGEN__)
	initTimePerfActions();
#endif

#if EFI_ENGINE_EMULATOR || defined(__DOXYGEN__)
	initEngineEmulator(engine);
#endif
	startStatusThreads(engine);

	print("Running main loop\r\n");
	main_loop_started = TRUE;
	/**
	 * This loop is the closes we have to 'main loop' - but here we only publish the status. The main logic of engine
	 * control is around main_trigger_callback
	 */
	while (TRUE) {
		efiAssertVoid(getRemainingStack(chThdSelf()) > 128, "stack#1");

#if (EFI_CLI_SUPPORT && !EFI_UART_ECHO_TEST_MODE) || defined(__DOXYGEN__)
		// sensor state + all pending messages for our own dev console
		updateDevConsoleState(engine);
#endif /* EFI_CLI_SUPPORT */

		chThdSleepMilliseconds(boardConfiguration->consoleLoopPeriod);
	}
}
Exemplo n.º 2
0
void runRusEfi(void) {
	efiAssertVoid(getRemainingStack(chThdGetSelfX()) > 512, "init s");
	assertEngineReference();
	initIntermediateLoggingBuffer();
	initErrorHandling();

#if EFI_SHAFT_POSITION_INPUT || defined(__DOXYGEN__)
	/**
	 * This is so early because we want to init logger
	 * which would be used while finding trigger sync index
	 * while reading configuration
	 */
	initTriggerDecoderLogger(&sharedLogger);
#endif /* EFI_SHAFT_POSITION_INPUT */

	/**
	 * we need to initialize table objects before default configuration can set values
	 */
	initDataStructures(PASS_ENGINE_PARAMETER_SIGNATURE);

	/**
	 * First thing is reading configuration from flash memory.
	 * In order to have complete flexibility configuration has to go before anything else.
	 */
	readConfiguration(&sharedLogger);
	prepareVoidConfiguration(&activeConfiguration);

	/**
	 * First data structure keeps track of which hardware I/O pins are used by whom
	 */
	initPinRepository();

	/**
	 * Next we should initialize serial port console, it's important to know what's going on
	 */
	initializeConsole(&sharedLogger);

	engine->setConfig(config);

	addConsoleAction("reboot", scheduleReboot);

	/**
	 * Initialize hardware drivers
	 */
	initHardware(&sharedLogger);

	initStatusLoop();
	/**
	 * Now let's initialize actual engine control logic
	 * todo: should we initialize some? most? controllers before hardware?
	 */
	initEngineContoller(&sharedLogger PASS_ENGINE_PARAMETER_SIGNATURE);

#if EFI_PERF_METRICS || defined(__DOXYGEN__)
	initTimePerfActions(&sharedLogger);
#endif
        
#if EFI_ENGINE_EMULATOR || defined(__DOXYGEN__)
	initEngineEmulator(&sharedLogger, engine);
#endif
	startStatusThreads();

	test557init();

	rememberCurrentConfiguration();

	print("Running main loop\r\n");
	main_loop_started = true;
	/**
	 * This loop is the closes we have to 'main loop' - but here we only publish the status. The main logic of engine
	 * control is around main_trigger_callback
	 */
	while (true) {
		efiAssertVoid(getRemainingStack(chThdGetSelfX()) > 128, "stack#1");

#if (EFI_CLI_SUPPORT && !EFI_UART_ECHO_TEST_MODE) || defined(__DOXYGEN__)
		// sensor state + all pending messages for our own dev console
		updateDevConsoleState();
#endif /* EFI_CLI_SUPPORT */

		chThdSleepMilliseconds(boardConfiguration->consoleLoopPeriod);
	}
}