auto-sync

This commit is contained in:
rusEfi 2015-02-15 13:06:59 -06:00
parent ce3adc326f
commit de3b9266f3
4 changed files with 39 additions and 10 deletions

View File

@ -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;i<strlen(msg);i++) {
// ITM_SendChar(msg[i]);
// }
engine_configuration_s *engineConfiguration = engine->engineConfiguration;
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();

View File

@ -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_ */

View File

@ -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) {

View File

@ -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
*/