예제 #1
0
파일: hardware.cpp 프로젝트: jharvey/rusefi
void stopSpi(spi_device_e device) {
#if HAL_USE_SPI || defined(__DOXYGEN__)
	if (!isSpiInitialized[device])
		return; // not turned on
	isSpiInitialized[device] = false;
	unmarkPin(getSckPin(device));
	unmarkPin(getMisoPin(device));
	unmarkPin(getMosiPin(device));
#endif /* HAL_USE_SPI */
}
예제 #2
0
파일: mpu_util.cpp 프로젝트: rusefi/rusefi
void turnOnSpi(spi_device_e device) {
	if (isSpiInitialized[device])
		return; // already initialized
	isSpiInitialized[device] = true;
	if (device == SPI_DEVICE_1) {
// todo: introduce a nice structure with all fields for same SPI
#if STM32_SPI_USE_SPI1
//	scheduleMsg(&logging, "Turning on SPI1 pins");
		initSpiModule(&SPID1, getSckPin(device),
				getMisoPin(device),
				getMosiPin(device),
				engineConfiguration->spi1SckMode,
				engineConfiguration->spi1MosiMode,
				engineConfiguration->spi1MisoMode);
#endif /* STM32_SPI_USE_SPI1 */
	}
	if (device == SPI_DEVICE_2) {
#if STM32_SPI_USE_SPI2
//	scheduleMsg(&logging, "Turning on SPI2 pins");
		initSpiModule(&SPID2, getSckPin(device),
				getMisoPin(device),
				getMosiPin(device),
				engineConfiguration->spi2SckMode,
				engineConfiguration->spi2MosiMode,
				engineConfiguration->spi2MisoMode);
#endif /* STM32_SPI_USE_SPI2 */
	}
	if (device == SPI_DEVICE_3) {
#if STM32_SPI_USE_SPI3
//	scheduleMsg(&logging, "Turning on SPI3 pins");
		initSpiModule(&SPID3, getSckPin(device),
				getMisoPin(device),
				getMosiPin(device),
				engineConfiguration->spi3SckMode,
				engineConfiguration->spi3MosiMode,
				engineConfiguration->spi3MisoMode);
#endif /* STM32_SPI_USE_SPI3 */
	}
}
예제 #3
0
파일: hip9011.cpp 프로젝트: rusefi/rusefi
static void showHipInfo(void) {
	if (!CONFIGB(isHip9011Enabled)) {
		scheduleMsg(logger, "hip9011 driver not active");
		return;
	}

	printSpiState(logger, boardConfiguration);
	scheduleMsg(logger, "enabled=%s state=%s bore=%.2fmm freq=%.2fkHz PaSDO=%d",
			boolToString(CONFIGB(isHip9011Enabled)),
			getHip_state_e(instance.state),
			engineConfiguration->cylinderBore, getHIP9011Band(PASS_HIP_PARAMS),
			engineConfiguration->hip9011PrescalerAndSDO);

	char *outputName = getPinNameByAdcChannel("hip", engineConfiguration->hipOutputChannel, hipPinNameBuffer);

	scheduleMsg(logger, "band_index=%d gain %.2f/index=%d output=%s", instance.currentBandIndex, engineConfiguration->hip9011Gain, instance.currentGainIndex,
			outputName);
	scheduleMsg(logger, "integrator index=%d knockVThreshold=%.2f knockCount=%d maxKnockSubDeg=%.2f",
	            instance.currentIntergratorIndex, engineConfiguration->knockVThreshold,
	            engine->knockCount, engineConfiguration->maxKnockSubDeg);

	const char * msg = instance.invalidHip9011ResponsesCount > 0 ? "NOT GOOD" : "ok";
	scheduleMsg(logger, "spi=%s IntHold@%s/%d response count=%d incorrect response=%d %s",
			getSpi_device_e(engineConfiguration->hip9011SpiDevice),
			hwPortname(CONFIGB(hip9011IntHoldPin)),
			CONFIGB(hip9011IntHoldPinMode),
			instance.correctResponsesCount, instance.invalidHip9011ResponsesCount,
			msg);
	scheduleMsg(logger, "CS@%s updateCount=%d", hwPortname(CONFIGB(hip9011CsPin)), instance.settingUpdateCount);

#if EFI_PROD_CODE
	scheduleMsg(logger, "hip %.2fv/last=%.2f@%s/max=%.2f adv=%d",
			engine->knockVolts,
			getVoltage("hipinfo", engineConfiguration->hipOutputChannel),
			getPinNameByAdcChannel("hip", engineConfiguration->hipOutputChannel, pinNameBuffer),
			hipValueMax,
			CONFIGB(useTpicAdvancedMode));
	scheduleMsg(logger, "mosi=%s", hwPortname(getMosiPin(engineConfiguration->hip9011SpiDevice)));
	scheduleMsg(logger, "miso=%s", hwPortname(getMisoPin(engineConfiguration->hip9011SpiDevice)));
	scheduleMsg(logger, "sck=%s", hwPortname(getSckPin(engineConfiguration->hip9011SpiDevice)));
#endif /* EFI_PROD_CODE */

	scheduleMsg(logger, "start %.2f end %.2f", engineConfiguration->knockDetectionWindowStart,
			engineConfiguration->knockDetectionWindowEnd);

	hipValueMax = 0;
	engine->printKnockState();
}
예제 #4
0
static void showHipInfo(void) {
	if (!boardConfiguration->isHip9011Enabled) {
		scheduleMsg(logger, "hip9011 driver not active");
		return;
	}

	printSpiState(logger, boardConfiguration);
	scheduleMsg(logger, "enabled=%s state=%d bore=%fmm freq=%fkHz PaSDO=%d",
			boolToString(boardConfiguration->isHip9011Enabled),
			state,
			engineConfiguration->cylinderBore, getBand(),
			engineConfiguration->hip9011PrescalerAndSDO);

	scheduleMsg(logger, "band_index=%d gain %f/index=%d", currentBandIndex, boardConfiguration->hip9011Gain, currentGainIndex);
	scheduleMsg(logger, "integrator index=%d knockVThreshold=%f knockCount=%d maxKnockSubDeg=%f",
	            currentIntergratorIndex, engineConfiguration->knockVThreshold,
	            engine->knockCount, engineConfiguration->maxKnockSubDeg);

	scheduleMsg(logger, "spi=%s IntHold@%s response count=%d incorrect response=%d",
			getSpi_device_e(hipSpiDevice),
			hwPortname(boardConfiguration->hip9011IntHoldPin),
			correctResponse, invalidResponse);
	scheduleMsg(logger, "CS@%s updateCount=%d", hwPortname(boardConfiguration->hip9011CsPin), settingUpdateCount);

	scheduleMsg(logger, "hip %fv/last=%f@%s/max=%f spiCount=%d adv=%d",
			engine->knockVolts,
			getVoltage("hipinfo", engineConfiguration->hipOutputChannel),
			getPinNameByAdcChannel("hip", engineConfiguration->hipOutputChannel, pinNameBuffer),
			hipValueMax,
			spiCount, boardConfiguration->useTpicAdvancedMode);
	scheduleMsg(logger, "mosi=%s", hwPortname(getMosiPin(hipSpiDevice)));
	scheduleMsg(logger, "miso=%s", hwPortname(getMisoPin(hipSpiDevice)));
	scheduleMsg(logger, "sck=%s", hwPortname(getSckPin(hipSpiDevice)));

	scheduleMsg(logger, "start %f end %f", engineConfiguration->knockDetectionWindowStart,
			engineConfiguration->knockDetectionWindowEnd);

	hipValueMax = 0;
	engine->printKnockState();
}