FreeEMS  0.2.0-SNAPSHOT-285-g028e24c
Macros | Functions
blockDetailsLookup.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define EXTERN   extern

Functions

unsigned short lookupBlockDetails (unsigned short, blockDetails *) FPAGE_FE
 Lookup memory block details.

Detailed Description

Definition in file blockDetailsLookup.h.

Macro Definition Documentation

#define EXTERN   extern

Definition at line 48 of file blockDetailsLookup.h.

Function Documentation

unsigned short lookupBlockDetails ( unsigned short  locationID,
blockDetails details 
)

Lookup memory block details.

Flash only blocks leave the RAM address and page values set to zero. ID's that don't exist return an error code.

Note
This function is an exception to the style rule switch statement blocks of using a {} pair for each case statement. Readability is better without them in this case.
Parameters
locationIDis the ID of the memory location for which details are required.
detailsis a pointer to the blockDetails struct to populate with the details.
Returns
An error code. Zero means success, anything else is a failure.

Definition at line 60 of file blockDetailsLookup.c.

References ADCBuffers, ADCRegistersLocationID, AirflowTable2LocationID, AirflowTableFlash2Location, AirflowTableFlashLocation, AirflowTableLocationID, fixedConfig2::algorithmSettings, algorithmSettingsLocationID, blendVersusRPMTable2Location, blendVersusRPMTable2LocationID, blendVersusRPMTableLocation, blendVersusRPMTableLocationID, block_for_backup_restore, block_gets_verified, block_has_parent, block_is_2dus_table, block_is_configuration, block_is_in_flash, block_is_in_ram, block_is_indexable, block_is_lookup_data, block_is_main_table, block_is_read_only, CHTTransferTable, CHTTransferTableLocation, CHTTransferTableLocationID, Clocks, ClocksLocationID, coarseBBSettingsLocationID, fixedConfig1::coarseBitBangSettings, CoreVars, coreVarsLocationID, Counters, CountersLocationID, fixedConfig1::cutAndLimiterSettings, cutAndLimiterSettingsLocationID, fixedConfig2::decoderSettings, decoderSettingsLocationID, DerivedVars, DerivedVarsLocationID, dwellDesiredVersusVoltageTable2Location, dwellDesiredVersusVoltageTable2LocationID, dwellDesiredVersusVoltageTableLocation, dwellDesiredVersusVoltageTableLocationID, dwellVersusRPMTable2Location, dwellVersusRPMTable2LocationID, dwellVersusRPMTableLocation, dwellVersusRPMTableLocationID, fixedConfig1::engineSettings, engineSettingsLocationID, engineTempEnrichmentTableFixed2Location, engineTempEnrichmentTableFixed2LocationID, engineTempEnrichmentTableFixedLocation, engineTempEnrichmentTableFixedLocationID, engineTempEnrichmentTablePercent2Location, engineTempEnrichmentTablePercent2LocationID, engineTempEnrichmentTablePercentLocation, engineTempEnrichmentTablePercentLocationID, fillerA2Location, fillerA2LocationID, fillerALocation, fillerALocationID, fillerB2Location, fillerB2LocationID, fillerBLocation, fillerBLocationID, fillerC2Location, fillerC2LocationID, fillerCLocation, fillerCLocationID, fillerD2Location, fillerD2LocationID, fillerDLocation, fillerDLocationID, FixedConfig1LocationID, FixedConfig2LocationID, fixedConfigs1, fixedConfigs2, Flaggables, Flaggables2, Flaggables2LocationID, FlaggablesLocationID, blockDetails::flags, blockDetails::FlashAddress, blockDetails::FlashPage, FUELTABLES_PPAGE, IATTransferTable, IATTransferTableLocation, IATTransferTableLocationID, IgnitionAdvanceTableMain2LocationID, IgnitionAdvanceTableMainFlash2Location, IgnitionAdvanceTableMainFlashLocation, IgnitionAdvanceTableMainLocationID, IgnitionAdvanceTableSecondary2LocationID, IgnitionAdvanceTableSecondaryFlash2Location, IgnitionAdvanceTableSecondaryFlashLocation, IgnitionAdvanceTableSecondaryLocationID, InjectionAdvanceTableMain2LocationID, InjectionAdvanceTableMainFlash2Location, InjectionAdvanceTableMainFlashLocation, InjectionAdvanceTableMainLocationID, InjectionAdvanceTableSecondary2LocationID, InjectionAdvanceTableSecondaryFlash2Location, InjectionAdvanceTableSecondaryFlashLocation, InjectionAdvanceTableSecondaryLocationID, injectorDeadTimeTable2Location, injectorDeadTimeTable2LocationID, injectorDeadTimeTableLocation, injectorDeadTimeTableLocationID, fixedConfig2::inputOutputSettings, inputOutputSettingsLocationID, KeyUserDebugLocationID, KeyUserDebugs, LambdaTable2LocationID, LambdaTableFlash2Location, LambdaTableFlashLocation, LambdaTableLocationID, locationIDNotFound, loggingSettings2Location, loggingSettings2LocationID, loggingSettingsLocation, loggingSettingsLocationID, LOOKUP_PPAGE, MAFTransferTable, MAFTransferTableLocation, MAFTransferTableLocationID, blockDetails::parent, postStartEnrichmentTable2Location, postStartEnrichmentTable2LocationID, postStartEnrichmentTableLocation, postStartEnrichmentTableLocationID, PPAGE, primingVolumeTable2Location, primingVolumeTable2LocationID, primingVolumeTableLocation, primingVolumeTableLocationID, blockDetails::RAMAddress, blockDetails::RAMPage, RPAGE_FUEL_ONE, RPAGE_FUEL_TWO, RPAGE_LINEAR, RPAGE_TIME_ONE, RPAGE_TIME_TWO, RPAGE_TUNE_ONE, RPAGE_TUNE_TWO, fixedConfig1::schedulingSettings, schedulingSettingsLocationID, fixedConfig2::sensorPresets, sensorPresetsLocationID, fixedConfig2::sensorRanges, sensorRangesLocationID, fixedConfig2::sensorSettings, sensorSettingsLocationID, fixedConfig2::sensorSources, sensorSourcesLocationID, fixedConfig1::serialSettings, serialSettingsLocationID, fixedConfig1::simpleGPIOSettings, simpleGPIOSettingsLocationID, blockDetails::size, SMALL_TABLES_1_FILLER_SIZE, SMALL_TABLES_2_FILLER_SIZE, SMALL_TABLES_3_FILLER_SIZE, SMALL_TABLES_4_FILLER_SIZE, SmallTablesA2LocationID, SmallTablesAFlash2Location, SmallTablesAFlashLocation, SmallTablesALocationID, SmallTablesB2LocationID, SmallTablesBFlash2Location, SmallTablesBFlashLocation, SmallTablesBLocationID, SmallTablesC2LocationID, SmallTablesCFlash2Location, SmallTablesCFlashLocation, SmallTablesCLocationID, SmallTablesD2LocationID, SmallTablesDFlash2Location, SmallTablesDFlashLocation, SmallTablesDLocationID, TestTransferTable, TestTransferTableLocation, TestTransferTableLocationID, TIMETABLES_PPAGE, TUNETABLES_PPAGE, fixedConfig1::userTextField, fixedConfig2::userTextField2, userTextField2LocationID, userTextFieldArrayLength1, userTextFieldArrayLength2, userTextFieldLocationID, VETableMain2LocationID, VETableMainFlash2Location, VETableMainFlashLocation, VETableMainLocationID, VETableSecondary2LocationID, VETableSecondaryFlash2Location, VETableSecondaryFlashLocation, and VETableSecondaryLocationID.

Referenced by decodePacketAndRespond(), and lookupMainTable().

{
/* Initialise the four values needed for operations on memory at 0 for error checking */
details->RAMPage = 0;
details->FlashPage = 0;
details->RAMAddress = 0;
details->FlashAddress = 0;
/* Initialise the block size to 1024 to save code space and increase readability */
details->size = sizeof(mainTable);
// No need to set parent value to zero as ignored unless flag set, done for clarity in hex stream.
details->parent = 0;
/* Look up the locations and set non default sizes */
switch (locationID) {
/* flash only fixed conf full blocks */
details->FlashPage = PPAGE;
details->FlashAddress = (void*)&fixedConfigs1;
break;
details->FlashPage = PPAGE;
details->FlashAddress = (void*)&fixedConfigs2;
break;
/* lookup tables */
details->size = sizeof(IATTransferTable);
details->FlashPage = LOOKUP_PPAGE;
break;
details->size = sizeof(CHTTransferTable);
details->FlashPage = LOOKUP_PPAGE;
break;
#ifdef ALL_CONFIG
details->size = sizeof(MAFTransferTable);
details->FlashPage = LOOKUP_PPAGE;
break;
details->size = sizeof(TestTransferTable);
details->FlashPage = LOOKUP_PPAGE;
break;
#endif
/* fuel tables */
details->RAMPage = RPAGE_FUEL_ONE;
details->RAMAddress = (void*)&TablesA;
break;
#ifdef ALL_CONFIG
details->RAMPage = RPAGE_FUEL_ONE;
details->RAMAddress = (void*)&TablesB;
break;
#endif
details->RAMPage = RPAGE_FUEL_ONE;
details->RAMAddress = (void*)&TablesC;
break;
details->RAMPage = RPAGE_FUEL_ONE;
details->RAMAddress = (void*)&TablesD;
break;
#ifdef ALL_CONFIG
details->RAMPage = RPAGE_FUEL_TWO;
details->RAMAddress = (void*)&TablesA;
break;
details->RAMPage = RPAGE_FUEL_TWO;
details->RAMAddress = (void*)&TablesB;
break;
details->RAMPage = RPAGE_FUEL_TWO;
details->RAMAddress = (void*)&TablesC;
break;
details->RAMPage = RPAGE_FUEL_TWO;
details->RAMAddress = (void*)&TablesD;
break;
#endif
/* timing tables */
details->RAMPage = RPAGE_TIME_ONE;
details->RAMAddress = (void*)&TablesA;
break;
#ifdef ALL_CONFIG
details->RAMPage = RPAGE_TIME_ONE;
details->RAMAddress = (void*)&TablesB;
break;
details->RAMPage = RPAGE_TIME_ONE;
details->RAMAddress = (void*)&TablesC;
break;
details->RAMPage = RPAGE_TIME_ONE;
details->RAMAddress = (void*)&TablesD;
break;
details->RAMPage = RPAGE_TIME_TWO;
details->RAMAddress = (void*)&TablesA;
break;
details->RAMPage = RPAGE_TIME_TWO;
details->RAMAddress = (void*)&TablesB;
break;
details->RAMPage = RPAGE_TIME_TWO;
details->RAMAddress = (void*)&TablesC;
break;
details->RAMPage = RPAGE_TIME_TWO;
details->RAMAddress = (void*)&TablesD;
break;
#endif
/* small table full blocks */
details->RAMPage = RPAGE_TUNE_ONE;
details->RAMAddress = (void*)&TablesA;
break;
details->RAMPage = RPAGE_TUNE_ONE;
details->RAMAddress = (void*)&TablesB;
break;
#ifdef ALL_CONFIG
details->RAMPage = RPAGE_TUNE_ONE;
details->RAMAddress = (void*)&TablesC;
break;
details->RAMPage = RPAGE_TUNE_ONE;
details->RAMAddress = (void*)&TablesD;
break;
details->RAMPage = RPAGE_TUNE_TWO;
details->RAMAddress = (void*)&TablesA;
break;
details->RAMPage = RPAGE_TUNE_TWO;
details->RAMAddress = (void*)&TablesB;
break;
details->RAMPage = RPAGE_TUNE_TWO;
details->RAMAddress = (void*)&TablesC;
break;
details->RAMPage = RPAGE_TUNE_TWO;
details->RAMAddress = (void*)&TablesD;
break;
#endif
/* TablesA small tables */
details->size = sizeof(twoDTableUS);
details->RAMPage = RPAGE_TUNE_ONE;
details->RAMAddress = (void*)&TablesA.SmallTablesA.dwellDesiredVersusVoltageTable;
break;
details->size = sizeof(twoDTableUS);
details->RAMPage = RPAGE_TUNE_ONE;
details->RAMAddress = (void*)&TablesA.SmallTablesA.injectorDeadTimeTable;
break;
#ifdef ALL_CONFIG
details->size = sizeof(twoDTableUS);
details->RAMPage = RPAGE_TUNE_ONE;
details->RAMAddress = (void*)&TablesA.SmallTablesA.postStartEnrichmentTable;
break;
details->size = sizeof(twoDTableUS);
details->RAMPage = RPAGE_TUNE_ONE;
details->RAMAddress = (void*)&TablesA.SmallTablesA.engineTempEnrichmentTableFixed;
break;
#endif
details->size = sizeof(twoDTableUS);
details->RAMPage = RPAGE_TUNE_ONE;
details->RAMAddress = (void*)&TablesA.SmallTablesA.primingVolumeTable;
break;
details->size = sizeof(twoDTableUS);
details->RAMPage = RPAGE_TUNE_ONE;
details->RAMAddress = (void*)&TablesA.SmallTablesA.engineTempEnrichmentTablePercent;
break;
details->size = sizeof(twoDTableUS);
details->RAMPage = RPAGE_TUNE_ONE;
details->RAMAddress = (void*)&TablesA.SmallTablesA.dwellVersusRPMTable;
break;
details->size = sizeof(twoDTableUS);
details->RAMPage = RPAGE_TUNE_ONE;
details->RAMAddress = (void*)&TablesA.SmallTablesA.blendVersusRPMTable;
break;
#ifdef ALL_CONFIG
details->size = sizeof(twoDTableUS);
details->RAMPage = RPAGE_TUNE_TWO;
details->RAMAddress = (void*)&TablesA.SmallTablesA.dwellDesiredVersusVoltageTable;
break;
details->size = sizeof(twoDTableUS);
details->RAMPage = RPAGE_TUNE_TWO;
details->RAMAddress = (void*)&TablesA.SmallTablesA.injectorDeadTimeTable;
break;
details->size = sizeof(twoDTableUS);
details->RAMPage = RPAGE_TUNE_TWO;
details->RAMAddress = (void*)&TablesA.SmallTablesA.postStartEnrichmentTable;
break;
details->size = sizeof(twoDTableUS);
details->RAMPage = RPAGE_TUNE_TWO;
details->RAMAddress = (void*)&TablesA.SmallTablesA.engineTempEnrichmentTableFixed;
break;
details->size = sizeof(twoDTableUS);
details->RAMPage = RPAGE_TUNE_TWO;
details->RAMAddress = (void*)&TablesA.SmallTablesA.primingVolumeTable;
break;
details->size = sizeof(twoDTableUS);
details->RAMPage = RPAGE_TUNE_TWO;
details->RAMAddress = (void*)&TablesA.SmallTablesA.engineTempEnrichmentTablePercent;
break;
details->size = sizeof(twoDTableUS);
details->RAMPage = RPAGE_TUNE_TWO;
details->RAMAddress = (void*)&TablesA.SmallTablesA.dwellVersusRPMTable;
break;
details->size = sizeof(twoDTableUS);
details->RAMPage = RPAGE_TUNE_TWO;
details->RAMAddress = (void*)&TablesA.SmallTablesA.blendVersusRPMTable;
break;
#endif
/* TablesB small tables */
details->size = sizeof(loggingSetting);
details->RAMPage = RPAGE_TUNE_ONE;
details->RAMAddress = (void*)&TablesB.SmallTablesB.loggingSettings;
break;
#ifdef ALL_CONFIG
details->size = sizeof(loggingSetting);
details->RAMPage = RPAGE_TUNE_TWO;
details->RAMAddress = (void*)&TablesB.SmallTablesB.loggingSettings;
break;
#endif
/* TablesC small tables */
// TODO add data chunks from TablesC when some are put in
/* TablesD small tables */
// TODO add data chunks from TablesD when some are put in
#ifdef ALL_CONFIG
/* filler block entries */
details->RAMPage = RPAGE_TUNE_ONE;
details->RAMAddress = (void*)&TablesA.SmallTablesA.filler;
break;
details->RAMPage = RPAGE_TUNE_TWO;
details->RAMAddress = (void*)&TablesA.SmallTablesA.filler;
break;
details->RAMPage = RPAGE_TUNE_ONE;
details->RAMAddress = (void*)&TablesB.SmallTablesB.filler;
break;
details->RAMPage = RPAGE_TUNE_TWO;
details->RAMAddress = (void*)&TablesB.SmallTablesB.filler;
break;
details->RAMPage = RPAGE_TUNE_ONE;
details->RAMAddress = (void*)&TablesC.SmallTablesC.filler;
break;
details->RAMPage = RPAGE_TUNE_TWO;
details->RAMAddress = (void*)&TablesC.SmallTablesC.filler;
break;
details->RAMPage = RPAGE_TUNE_ONE;
details->RAMAddress = (void*)&TablesD.SmallTablesD.filler;
break;
details->RAMPage = RPAGE_TUNE_TWO;
details->RAMAddress = (void*)&TablesD.SmallTablesD.filler;
break;
#endif
/* Fixed conf 1 small chunks */
details->size = sizeof(engineSetting);
details->FlashPage = PPAGE;
break;
details->size = sizeof(serialSetting);
details->FlashPage = PPAGE;
break;
details->size = sizeof(coarseBitBangSetting);
details->FlashPage = PPAGE;
break;
details->size = sizeof(schedulingSetting);
details->FlashPage = PPAGE;
break;
details->size = sizeof(cutAndLimiterSetting);
details->FlashPage = PPAGE;
break;
details->size = sizeof(simpleGPIOSetting);
details->FlashPage = PPAGE;
break;
details->FlashPage = PPAGE;
break;
/* Fixed conf 2 small chunks */
details->size = sizeof(sensorSource);
details->FlashPage = PPAGE;
break;
details->size = sizeof(sensorPreset);
details->FlashPage = PPAGE;
break;
details->size = sizeof(sensorRange);
details->FlashPage = PPAGE;
details->FlashAddress = (void*)&(fixedConfigs2.sensorRanges);
break;
details->size = sizeof(sensorSetting);
details->FlashPage = PPAGE;
break;
details->size = sizeof(algorithmSetting);
details->FlashPage = PPAGE;
break;
details->size = sizeof(inputOutputSetting);
details->FlashPage = PPAGE;
break;
details->size = sizeof(decoderSetting);
details->FlashPage = PPAGE;
break;
details->FlashPage = PPAGE;
break;
// Internal blocks of variables that are sometimes useful to read out
details->size = sizeof(ADCBuffer);
details->RAMPage = RPAGE_LINEAR;
details->RAMAddress = (void*)ADCBuffers;
break;
details->size = sizeof(CoreVar);
details->RAMPage = RPAGE_LINEAR;
details->RAMAddress = (void*)CoreVars;
break;
details->size = sizeof(DerivedVar);
details->RAMPage = RPAGE_LINEAR;
details->RAMAddress = (void*)DerivedVars;
break;
details->size = sizeof(KeyUserDebug);
details->RAMPage = RPAGE_LINEAR;
break;
details->size = sizeof(Counter);
details->RAMPage = RPAGE_LINEAR;
details->RAMAddress = &Counters;
break;
details->size = sizeof(Clock);
details->RAMPage = RPAGE_LINEAR;
details->RAMAddress = &Clocks;
break;
details->size = sizeof(Flaggable);
details->RAMPage = RPAGE_LINEAR;
details->RAMAddress = &Flaggables;
break;
details->size = sizeof(Flaggable2);
details->RAMPage = RPAGE_LINEAR;
details->RAMAddress = &Flaggables2;
break;
default:
/* Return early if locationID is not valid. */
}
// Setup all of the flags for various groups here
// Setting flags above is wrong, keep it all in one place, here!
// Initialise the flags to having flash, everything does at the moment, and indexable, most is, negate at end for those that don't.
if(locationID < MainTable_TwoDTableUS_Border){
}else if(locationID < TwoDTableUS_SmallTableFullBlocks_Border){
}else if(locationID < SmallTableFullBlocks_SmallTableFillers_Border){
details->flags &= ~block_is_indexable;
}else if(locationID < SmallTableFillers_FlashLookupTables_Border){
details->flags &= ~block_is_indexable;
}else if(locationID < FlashLookupTables_SmallTableConfigs_Border){
details->flags &= ~block_is_indexable;
}else if(locationID < SmallTableConfigs_FixedConfigBlocks_Border){
}else if(locationID < FixedConfigBlocks_FixedConfigSubBlocks_Border){
}else if(locationID < FixedConfigSubBlocks_Border_ReadOnlyVarBlocks){
}else{ // RO variable blocks exposed polling and streaming
details->flags &= ~block_is_in_flash;
}
/* Fall through to not return error */
return 0;
}

Here is the caller graph for this function: