diff --git a/firmware/console/status_loop.cpp b/firmware/console/status_loop.cpp index 48ea1930ca..750c307248 100644 --- a/firmware/console/status_loop.cpp +++ b/firmware/console/status_loop.cpp @@ -220,6 +220,13 @@ static void printState(Engine *engine) { #if EFI_SHAFT_POSITION_INPUT || defined(__DOXYGEN__) printSensors(&logger, false, engine); + // todo: make SWO work +// char *msg = "hello\r\n"; +// for(int i=0;iengineConfiguration; int rpm = getRpmE(engine); @@ -532,10 +539,11 @@ void updateTunerStudioState(Engine *engine, TunerStudioOutputChannels *tsOutputC // engine state tsOutputChannels->rpm = rpm; tsOutputChannels->coolant_temperature = coolant; - tsOutputChannels->intake_air_temperature = intake; - tsOutputChannels->throttle_positon = tps; - tsOutputChannels->mass_air_flow = getMaf(); - tsOutputChannels->air_fuel_ratio = getAfr(); + tsOutputChannels->intakeAirTemperature = intake; + tsOutputChannels->throttlePositon = tps; + tsOutputChannels->massAirFlowVoltage = getMaf(); + tsOutputChannels->massAirFlowValue = getRealMaf(); + tsOutputChannels->airFuelRatio = getAfr(); tsOutputChannels->v_batt = getVBatt(engineConfiguration); tsOutputChannels->tpsADC = getTPS10bitAdc(PASS_ENGINE_PARAMETER_F); tsOutputChannels->atmospherePressure = getBaroPressure(); diff --git a/firmware/console/tunerstudio/tunerstudio_configuration.h b/firmware/console/tunerstudio/tunerstudio_configuration.h index a78b85f4db..07cb09fea2 100644 --- a/firmware/console/tunerstudio/tunerstudio_configuration.h +++ b/firmware/console/tunerstudio/tunerstudio_configuration.h @@ -32,10 +32,10 @@ typedef struct { // primary instrument cluster gauges int rpm; // size 4, offset 0 float coolant_temperature; // size 4, offset 4 - float intake_air_temperature; // size 4, offset 8 - float throttle_positon; // size 4, offset 12 - float mass_air_flow; // size 4, offset 16 - float air_fuel_ratio; // size 4, offset 20 + float intakeAirTemperature; // size 4, offset 8 + float throttlePositon; // size 4, offset 12 + float massAirFlowVoltage; // size 4, offset 16 + float airFuelRatio; // size 4, offset 20 float engineLoad; // size 4, offset 24 float v_batt; // size 4, offset 28 short int tpsADC; // size 2, offset 32 @@ -81,7 +81,8 @@ typedef struct { int tsConfigVersion; egt_values_s egtValues; float rpmAcceleration; - int unused3[2]; + float massAirFlowValue; + int unused3[1]; } TunerStudioOutputChannels; #endif /* TUNERSTUDIO_CONFIGURATION_H_ */ diff --git a/firmware/controllers/settings.cpp b/firmware/controllers/settings.cpp index c48303f4ba..09c0f1b553 100644 --- a/firmware/controllers/settings.cpp +++ b/firmware/controllers/settings.cpp @@ -763,7 +763,7 @@ static void setSpiMode(int index, bool mode) { scheduleMsg(&logger, "invalid spi index %d", index); return; } - scheduleMsg(&logger, "spi %d mode: %s", index, boolToString(mode)); + printSpiState(&logger, boardConfiguration); } static void enableOrDisable(const char *param, bool isEnabled) { diff --git a/firmware/rusefi.cpp b/firmware/rusefi.cpp index fa23965f5e..99668c1075 100644 --- a/firmware/rusefi.cpp +++ b/firmware/rusefi.cpp @@ -136,6 +136,24 @@ char *getFirmwareError(void) { return (char*) errorMessageBuffer; } + +void swo_init() +{ + // todo: make SWO work +// uint32_t SWOSpeed = 2000000; //2000kbps, default for ST-LINK +// // todo: use a macro to access clock speed +// uint32_t SWOPrescaler = (168000000 / SWOSpeed) - 1; // SWOSpeed in Hz, note that F_CPU is expected to be 96000000 in this case +// CoreDebug->DEMCR = CoreDebug_DEMCR_TRCENA_Msk; +// *((volatile unsigned *)(ITM_BASE + 0x400F0)) = 0x00000002; // "Selected PIN Protocol Register": Select which protocol to use for trace output (2: SWO) +// *((volatile unsigned *)(ITM_BASE + 0x40010)) = SWOPrescaler; // "Async Clock Prescaler Register". Scale the baud rate of the asynchronous output +// *((volatile unsigned *)(ITM_BASE + 0x00FB0)) = 0xC5ACCE55; // ITM Lock Access Register, C5ACCE55 enables more write access to Control Register 0xE00 :: 0xFFC +// ITM->TCR = ITM_TCR_TraceBusID_Msk | ITM_TCR_SWOENA_Msk | ITM_TCR_SYNCENA_Msk | ITM_TCR_ITMENA_Msk; // ITM Trace Control Register +// ITM->TPR = ITM_TPR_PRIVMASK_Msk; // ITM Trace Privilege Register +// ITM->TER = 0x00000001; // ITM Trace Enable Register. Enabled tracing on stimulus ports. One bit per stimulus port. +// *((volatile unsigned *)(ITM_BASE + 0x01000)) = 0x400003FE; // DWT_CTRL +// *((volatile unsigned *)(ITM_BASE + 0x40304)) = 0x00000100; // Formatter and Flush Control Register +} + void runRusEfi(void) { msObjectInit(&firmwareErrorMessageStream, errorMessageBuffer, sizeof(errorMessageBuffer), 0); @@ -147,6 +165,8 @@ void runRusEfi(void) { initErrorHandling(); + swo_init(); + /** * First data structure keeps track of which hardware I/O pins are used by whom */