static void hipStartupCode(void) { // D[4:1] = 0000 : 4 MHz // D[4:1] = 0001 : 5 MHz // D[4:1] = 0010 : 6 MHz // D[4:1] = 0011 ; 8 MHz // D[4:1] = 0100 ; 10 MHz // D[4:1] = 0101 ; 12 MHz // D[4:1] = 0110 : 16 MHz // D[4:1] = 0111 : 20 MHz // D[4:1] = 1000 : 24 MHz // 0 for 4MHz // 6 for 8 MHz currentPrescaler = engineConfiguration->hip9011PrescalerAndSDO; SPI_SYNCHRONOUS(SET_PRESCALER_CMD + currentPrescaler); chThdSleepMilliseconds(10); // '0' for channel #1 SPI_SYNCHRONOUS(SET_CHANNEL_CMD + 0); chThdSleepMilliseconds(10); // band index depends on cylinder bore SPI_SYNCHRONOUS(SET_BAND_PASS_CMD + currentBandIndex); chThdSleepMilliseconds(10); if (correctResponse == 0) { warning(CUSTOM_OBD_41, "TPIC/HIP does not respond"); } if (boardConfiguration->useTpicAdvancedMode) { // enable advanced mode for digital integrator output SPI_SYNCHRONOUS(SET_ADVANCED_MODE); chThdSleepMilliseconds(10); } /** * Let's restart SPI to switch it from synchronous mode into * asynchronous mode */ spiStop(driver); hipSpiCfg.end_cb = endOfSpiExchange; spiStart(driver, &hipSpiCfg); state = READY_TO_INTEGRATE; }
void Hip9011Hardware::sendSyncCommand(unsigned char command) { SPI_SYNCHRONOUS(command); chThdSleepMilliseconds(10); }