static void runBench(brain_pin_e brainPin, io_pin_e pin, float delayMs, float onTimeMs, float offTimeMs, int count) { scheduleMsg(&logger, "Running bench: ON_TIME=%f ms OFF_TIME=%fms Counter=%d", onTimeMs, offTimeMs, count); scheduleMsg(&logger, "output on %s", hwPortname(brainPin)); int delaySt = (int) (delayMs * CH_FREQUENCY / 1000); if (delaySt != 0) { chThdSleep(delaySt); } for (int i = 0; i < count; i++) { setOutputPinValue(pin, TRUE); chThdSleep((int) (onTimeMs * CH_FREQUENCY / 1000)); setOutputPinValue(pin, FALSE); int offTimeSt = (int) (offTimeMs * CH_FREQUENCY / 1000); if (offTimeSt > 0) { chThdSleep(offTimeSt); } } scheduleMsg(&logger, "Done!"); }
void turnPinLow(io_pin_e pin) { // turn off the output // todo: this XOR should go inside the setOutputPinValue method setOutputPinValue(pin, false); #if EFI_DEFAILED_LOGGING systime_t after = hTimeNow(); debugInt(&signal->logging, "a_time", after - signal->hi_time); scheduleLogging(&signal->logging); #endif /* EFI_DEFAILED_LOGGING */ #if EFI_WAVE_CHART addWaveChartEvent(getPinName(pin), WC_DOWN, ""); #endif /* EFI_WAVE_ANALYZER */ }
void turnPinHigh(io_pin_e pin) { #if EFI_DEFAILED_LOGGING // signal->hi_time = hTimeNow(); #endif /* EFI_DEFAILED_LOGGING */ // turn the output level ACTIVE // todo: this XOR should go inside the setOutputPinValue method setOutputPinValue(pin, TRUE); // sleep for the needed duration #if EFI_PROD_CODE || EFI_SIMULATOR if (pin == SPARKOUT_1_OUTPUT || pin == SPARKOUT_3_OUTPUT) { // time_t now = hTimeNow(); // float an = getCrankshaftAngle(now); // scheduleMsg(&logger, "spark up%d %d", pin, now); // scheduleMsg(&logger, "spark angle %d %f", (int)an, an); } #endif #if EFI_WAVE_CHART addWaveChartEvent(getPinName(pin), WC_UP, ""); #endif /* EFI_WAVE_ANALYZER */ }
// todo: why is this method here and not in error_handling.c ? void firmwareError(const char *fmt, ...) { if (hasFirmwareErrorFlag) return; setOutputPinValue(LED_ERROR, 1); turnAllPinsOff(); hasFirmwareErrorFlag = TRUE; if (indexOf(fmt, '%') == -1) { /** * in case of simple error message let's reduce stack usage * because chvprintf might be causing an error */ strcpy((char*) errorMessageBuffer, fmt); } else { firmwareErrorMessageStream.eos = 0; // reset va_list ap; va_start(ap, fmt); chvprintf((BaseSequentialStream *) &firmwareErrorMessageStream, fmt, ap); va_end(ap); firmwareErrorMessageStream.buffer[firmwareErrorMessageStream.eos] = 0; // need to terminate explicitly } }