Example #1
0
/**
 * this thread has a lower-then-usual stack size so we cannot afford *print* methods here
 */
static void blinkingThread(void *arg) {
	(void) arg;
	chRegSetThreadName("communication blinking");

	initialLedsBlink();

	while (true) {
		int delayMs = isConsoleReady() ? 3 * blinkingPeriod : blinkingPeriod;

#if EFI_INTERNAL_FLASH || defined(__DOXYGEN__)
		if (getNeedToWriteConfiguration()) {
			delayMs = 2 * delayMs;
		}
#endif

		communicationPin.setValue(0);
		warningPin.setValue(0);
		chThdSleepMilliseconds(delayMs);

		communicationPin.setValue(1);
#if EFI_ENGINE_CONTROL || defined(__DOXYGEN__)
		if (isTriggerErrorNow() || isIgnitionTimingError())
			warningPin.setValue(1);
#endif
		chThdSleepMilliseconds(delayMs);

	}
}
Example #2
0
void writeToFlashIfPending() {
	if (!getNeedToWriteConfiguration()) {
		return;
	}
	// todo: technically we need a lock here, realistically we should be fine.
	needToWriteConfiguration = false;
	scheduleMsg(&logger, "Writing pending configuration");
	writeToFlash();
}