Merge pull request #64 from Autohome2/can-io

Can io
This commit is contained in:
Josh Stewart 2017-02-05 21:42:33 +11:00 committed by GitHub
commit b2ca13c9aa
7 changed files with 353 additions and 11 deletions

View File

@ -10,6 +10,7 @@
#define iacPage 7//Config Page 4
#define boostvvtPage 8
#define seqFuelPage 9
#define canbusPage 10//Config Page 10
#define packetSize 37
@ -27,7 +28,8 @@ const char pageTitles[] PROGMEM //This is being stored in the avr flash instead
"\nPage 3 Config\0"
"\nPage 4 Config\0"
"\nBoost Map\0"
"\nVVT Map"//No need to put a trailing null because it's the last string and the compliler does it for you.
"\nVVT Map\0"//No need to put a trailing null because it's the last string and the compliler does it for you.
"\nPage 10 Config"
};
void command();//This is the heart of the Command Line Interpeter. All that needed to be done was to make it human readable.

View File

@ -434,6 +434,15 @@ void receiveValue(int valueOffset, byte newValue)
else if (valueOffset < 192) { valueOffset = valueOffset - 186; trim4Table.axisY[(5 - valueOffset)] = int(newValue) * TABLE_LOAD_MULTIPLIER; } //New value is on the Y (Load) axis of the table
break;
case canbusPage:
pnt_configPage = &configPage10;
//For some reason, TunerStudio is sending offsets greater than the maximum page size. I'm not sure if it's their bug or mine, but the fix is to only update the config page if the offset is less than the maximum size
if (valueOffset < npage_size[currentPage])
{
*((byte *)pnt_configPage + (byte)valueOffset) = newValue;
}
break;
default:
break;
@ -743,6 +752,24 @@ void sendPage(bool useChar)
}
break;
}
case canbusPage:
{
//currentTitleIndex = 141;
if (useChar)
{
//To Display Values from Config Page 10
Serial.println((const __FlashStringHelper *)&pageTitles[141]);//special typecasting to enable suroutine that the F macro uses
for (pnt_configPage = &configPage10; pnt_configPage < ((byte *)pnt_configPage + 128); pnt_configPage = (byte *)pnt_configPage + 1)
{
Serial.println(*((byte *)pnt_configPage));// Displaying byte values of config page 3 up to but not including the first array
}
return;
}
else pnt_configPage = &configPage10; //Create a pointer to Page 10 in memory
break;
}
default:
{
Serial.println(F("\nPage has not been implemented yet. Change to another page."));
@ -847,8 +874,8 @@ void sendPage(bool useChar)
else
{*/
//All other bytes can simply be copied from the config table
byte response[page_size];
for (byte x = 0; x < page_size; x++)
byte response[npage_size[currentPage]];
for (byte x = 0; x < npage_size[currentPage]; x++)
{
response[x] = *((byte *)pnt_configPage + x); //Each byte is simply the location in memory of the configPage + the offset + the variable number (x)
//if ( (x & 31) == 1) { loop(); } //Every 32 loops, do a manual call to loop() to ensure that there is no misses

137
globals.h
View File

@ -93,6 +93,8 @@ const char TSfirmwareVersion[] = "Speeduino 2016.09";
const byte data_structure_version = 2; //This identifies the data structure when reading / writing.
const byte page_size = 64;
const int npage_size[11] ={0,288,64,288,64,288,64,64,160,192,128};
//const byte page10_size = 128;
const int map_page_size = 288;
struct table3D fuelTable; //16x16 fuel map
@ -451,6 +453,140 @@ struct config4 {
byte fanPWMBins[4]; //Temperature Bins for the PWM fan control
};
//Page 10 of the config mostly deals with CANBUS control
//See ini file for further info (Config Page 10 in the ini)
struct config10 {
byte unused10_0;
byte unused10_1;
byte unused10_2;
byte unused10_3;
byte unused10_4;
byte unused10_5;
byte unused10_6;
byte unused10_7;
byte unused10_8;
byte unused10_9;
byte unused10_10;
byte unused10_11;
byte unused10_12;
byte unused10_13;
byte unused10_14;
byte unused10_15;
byte unused10_16;
byte unused10_17;
byte unused10_18;
byte unused10_19;
byte unused10_20;
byte unused10_21;
byte unused10_22;
byte unused10_23;
byte unused10_24;
byte unused10_25;
byte unused10_26;
byte unused10_27;
byte unused10_28;
byte unused10_29;
byte unused10_30;
byte unused10_31;
byte unused10_32;
byte unused10_33;
byte unused10_34;
byte unused10_35;
byte unused10_36;
byte unused10_37;
byte unused10_38;
byte unused10_39;
byte unused10_40;
byte unused10_41;
byte unused10_42;
byte unused10_43;
byte unused10_44;
byte unused10_45;
byte unused10_46;
byte unused10_47;
byte unused10_48;
byte unused10_49;
byte unused10_50;
byte unused10_51;
byte unused10_52;
byte unused10_53;
byte unused10_54;
byte unused10_55;
byte unused10_56;
byte unused10_57;
byte unused10_58;
byte unused10_59;
byte unused10_60;
byte unused10_61;
byte unused10_62;
byte unused10_63;
byte unused10_64;
byte unused10_65;
byte unused10_66;
byte unused10_67;
byte unused10_68;
byte unused10_69;
byte unused10_70;
byte unused10_71;
byte unused10_72;
byte unused10_73;
byte unused10_74;
byte unused10_75;
byte unused10_76;
byte unused10_77;
byte unused10_78;
byte unused10_79;
byte unused10_80;
byte unused10_81;
byte unused10_82;
byte unused10_83;
byte unused10_84;
byte unused10_85;
byte unused10_86;
byte unused10_87;
byte unused10_88;
byte unused10_89;
byte unused10_90;
byte unused10_91;
byte unused10_92;
byte unused10_93;
byte unused10_94;
byte unused10_95;
byte unused10_96;
byte unused10_97;
byte unused10_98;
byte unused10_99;
byte unused10_100;
byte unused10_101;
byte unused10_102;
byte unused10_103;
byte unused10_104;
byte unused10_105;
byte unused10_106;
byte unused10_107;
byte unused10_108;
byte unused10_109;
byte unused10_110;
byte unused10_111;
byte unused10_112;
byte unused10_113;
byte unused10_114;
byte unused10_115;
byte unused10_116;
byte unused10_117;
byte unused10_118;
byte unused10_119;
byte unused10_120;
byte unused10_121;
byte unused10_122;
byte unused10_123;
byte unused10_124;
byte unused10_125;
byte unused10_126;
byte unused10_127;
};
byte pinInjector1; //Output pin injector 1
byte pinInjector2; //Output pin injector 2
byte pinInjector3; //Output pin injector 3 is on
@ -518,6 +654,7 @@ extern struct table2D WUETable; //10 bin Warm Up Enrichment map (2D)
extern struct config1 configPage1;
extern struct config2 configPage2;
extern struct config3 configPage3;
extern struct config10 configPage10;
extern unsigned long currentLoopTime; //The time the current loop started (uS)
extern unsigned long previousLoopTime; //The time the previous loop started (uS)
extern byte ignitionCount;

View File

@ -92,13 +92,13 @@
;----------------------------------------------------------------------------
endianness = little
nPages = 9
nPages = 10
burnCommand = "B"
pageSize = 288, 64, 288, 64, 288, 64, 64, 160, 192
pageSize = 288, 64, 288, 64, 288, 64, 64, 160, 192, 128
pageActivationDelay = 10
pageActivate = "P\001", "P\002", "P\003", "P\004", "P\005", "P\006", "P\007", "P\010", "P\011"
pageReadCommand = "V", "V", "V", "V", "V", "V", "V", "V", "V"
pageValueWrite = "W%2o%v", "W%o%v", "W%2o%v", "W%o%v", "W%2o%v", "W%o%v", "W%o%v", "W%o%v", "W%o%v"
pageActivate = "P\001", "P\002", "P\003", "P\004", "P\005", "P\006", "P\007", "P\010", "P\011", "P\012"
pageReadCommand = "V", "V", "V", "V", "V", "V", "V", "V", "V", "V"
pageValueWrite = "W%2o%v", "W%o%v", "W%2o%v", "W%o%v", "W%2o%v", "W%o%v", "W%o%v", "W%o%v", "W%o%v", "W%o%v"
; pageChunkWrite = "" ; No chunk write for standard MS
blockingFactor = 2048
@ -512,8 +512,140 @@ page = 9
#elif ALPHA_N
fuelTrim4loadBins = array, U08, 186,[ 6], "TPS", 2.0, 0.0, 0.0, 100.0, 0
#endif
;--------------------------------------------------
;CANBUS control (Page 10)
;--------------------------------------------------
page = 10
unused10_0 = scalar, U08, 0, "", 1, 0, 0, 255, 0
unused10_1 = scalar, U08, 1, "", 1, 0, 0, 255, 0
unused10_2 = scalar, U08, 2, "", 1, 0, 0, 255, 0
unused10_3 = scalar, U08, 3, "", 1, 0, 0, 255, 0
unused10_4 = scalar, U08, 4, "", 1, 0, 0, 255, 0
unused10_5 = scalar, U08, 5, "", 1, 0, 0, 255, 0
unused10_6 = scalar, U08, 6, "", 1, 0, 0, 255, 0
unused10_7 = scalar, U08, 7, "", 1, 0, 0, 255, 0
unused10_8 = scalar, U08, 8, "", 1, 0, 0, 255, 0
unused10_9 = scalar, U08, 9, "", 1, 0, 0, 255, 0
unused10_10 = scalar, U08, 10, "", 1, 0, 0, 255, 0
unused10_11 = scalar, U08, 11, "", 1, 0, 0, 255, 0
unused10_12 = scalar, U08, 12, "", 1, 0, 0, 255, 0
unused10_13 = scalar, U08, 13, "", 1, 0, 0, 255, 0
unused10_14 = scalar, U08, 14, "", 1, 0, 0, 255, 0
unused10_15 = scalar, U08, 15, "", 1, 0, 0, 255, 0
unused10_16 = scalar, U08, 16, "", 1, 0, 0, 255, 0
unused10_17 = scalar, U08, 17, "", 1, 0, 0, 255, 0
unused10_18 = scalar, U08, 18, "", 1, 0, 0, 255, 0
unused10_19 = scalar, U08, 19, "", 1, 0, 0, 255, 0
unused10_20 = scalar, U08, 20, "", 1, 0, 0, 255, 0
unused10_21 = scalar, U08, 21, "", 1, 0, 0, 255, 0
unused10_22 = scalar, U08, 22, "", 1, 0, 0, 255, 0
unused10_23 = scalar, U08, 23, "", 1, 0, 0, 255, 0
unused10_24 = scalar, U08, 24, "", 1, 0, 0, 255, 0
unused10_25 = scalar, U08, 25, "", 1, 0, 0, 255, 0
unused10_26 = scalar, U08, 26, "", 1, 0, 0, 255, 0
unused10_27 = scalar, U08, 27, "", 1, 0, 0, 255, 0
unused10_28 = scalar, U08, 28, "", 1, 0, 0, 255, 0
unused10_29 = scalar, U08, 29, "", 1, 0, 0, 255, 0
unused10_30 = scalar, U08, 30, "", 1, 0, 0, 255, 0
unused10_31 = scalar, U08, 31, "", 1, 0, 0, 255, 0
unused10_32 = scalar, U08, 32, "", 1, 0, 0, 255, 0
unused10_33 = scalar, U08, 33, "", 1, 0, 0, 255, 0
unused10_34 = scalar, U08, 34, "", 1, 0, 0, 255, 0
unused10_35 = scalar, U08, 35, "", 1, 0, 0, 255, 0
unused10_36 = scalar, U08, 36, "", 1, 0, 0, 255, 0
unused10_37 = scalar, U08, 37, "", 1, 0, 0, 255, 0
unused10_38 = scalar, U08, 38, "", 1, 0, 0, 255, 0
unused10_39 = scalar, U08, 39, "", 1, 0, 0, 255, 0
unused10_40 = scalar, U08, 40, "", 1, 0, 0, 255, 0
unused10_41 = scalar, U08, 41, "", 1, 0, 0, 255, 0
unused10_42 = scalar, U08, 42, "", 1, 0, 0, 255, 0
unused10_43 = scalar, U08, 43, "", 1, 0, 0, 255, 0
unused10_44 = scalar, U08, 44, "", 1, 0, 0, 255, 0
unused10_45 = scalar, U08, 45, "", 1, 0, 0, 255, 0
unused10_46 = scalar, U08, 46, "", 1, 0, 0, 255, 0
unused10_47 = scalar, U08, 47, "", 1, 0, 0, 255, 0
unused10_48 = scalar, U08, 48, "", 1, 0, 0, 255, 0
unused10_49 = scalar, U08, 49, "", 1, 0, 0, 255, 0
unused10_50 = scalar, U08, 50, "", 1, 0, 0, 255, 0
unused10_51 = scalar, U08, 51, "", 1, 0, 0, 255, 0
unused10_52 = scalar, U08, 52, "", 1, 0, 0, 255, 0
unused10_53 = scalar, U08, 53, "", 1, 0, 0, 255, 0
unused10_54 = scalar, U08, 54, "", 1, 0, 0, 255, 0
unused10_55 = scalar, U08, 55, "", 1, 0, 0, 255, 0
unused10_56 = scalar, U08, 56, "", 1, 0, 0, 255, 0
unused10_57 = scalar, U08, 57, "", 1, 0, 0, 255, 0
unused10_58 = scalar, U08, 58, "", 1, 0, 0, 255, 0
unused10_59 = scalar, U08, 59, "", 1, 0, 0, 255, 0
unused10_60 = scalar, U08, 60, "", 1, 0, 0, 255, 0
unused10_61 = scalar, U08, 61, "", 1, 0, 0, 255, 0
unused10_62 = scalar, U08, 62, "", 1, 0, 0, 255, 0
unused10_63 = scalar, U08, 63, "", 1, 0, 0, 255, 0
unused10_64 = scalar, U08, 64, "", 1, 0, 0, 255, 0
unused10_65 = scalar, U08, 65, "", 1, 0, 0, 255, 0
unused10_66 = scalar, U08, 66, "", 1, 0, 0, 255, 0
unused10_67 = scalar, U08, 67, "", 1, 0, 0, 255, 0
unused10_68 = scalar, U08, 68, "", 1, 0, 0, 255, 0
unused10_69 = scalar, U08, 69, "", 1, 0, 0, 255, 0
unused10_70 = scalar, U08, 70, "", 1, 0, 0, 255, 0
unused10_71 = scalar, U08, 71, "", 1, 0, 0, 255, 0
unused10_72 = scalar, U08, 72, "", 1, 0, 0, 255, 0
unused10_73 = scalar, U08, 73, "", 1, 0, 0, 255, 0
unused10_74 = scalar, U08, 74, "", 1, 0, 0, 255, 0
unused10_75 = scalar, U08, 75, "", 1, 0, 0, 255, 0
unused10_76 = scalar, U08, 76, "", 1, 0, 0, 255, 0
unused10_77 = scalar, U08, 77, "", 1, 0, 0, 255, 0
unused10_78 = scalar, U08, 78, "", 1, 0, 0, 255, 0
unused10_79 = scalar, U08, 79, "", 1, 0, 0, 255, 0
unused10_80 = scalar, U08, 80, "", 1, 0, 0, 255, 0
unused10_81 = scalar, U08, 81, "", 1, 0, 0, 255, 0
unused10_82 = scalar, U08, 82, "", 1, 0, 0, 255, 0
unused10_83 = scalar, U08, 83, "", 1, 0, 0, 255, 0
unused10_84 = scalar, U08, 84, "", 1, 0, 0, 255, 0
unused10_85 = scalar, U08, 85, "", 1, 0, 0, 255, 0
unused10_86 = scalar, U08, 86, "", 1, 0, 0, 255, 0
unused10_87 = scalar, U08, 87, "", 1, 0, 0, 255, 0
unused10_88 = scalar, U08, 88, "", 1, 0, 0, 255, 0
unused10_89 = scalar, U08, 89, "", 1, 0, 0, 255, 0
unused10_90 = scalar, U08, 90, "", 1, 0, 0, 255, 0
unused10_91 = scalar, U08, 91, "", 1, 0, 0, 255, 0
unused10_92 = scalar, U08, 92, "", 1, 0, 0, 255, 0
unused10_93 = scalar, U08, 93, "", 1, 0, 0, 255, 0
unused10_94 = scalar, U08, 94, "", 1, 0, 0, 255, 0
unused10_95 = scalar, U08, 95, "", 1, 0, 0, 255, 0
unused10_96 = scalar, U08, 96, "", 1, 0, 0, 255, 0
unused10_97 = scalar, U08, 97, "", 1, 0, 0, 255, 0
unused10_98 = scalar, U08, 98, "", 1, 0, 0, 255, 0
unused10_99 = scalar, U08, 99, "", 1, 0, 0, 255, 0
unused10_100 = scalar, U08, 100, "", 1, 0, 0, 255, 0
unused10_101 = scalar, U08, 101, "", 1, 0, 0, 255, 0
unused10_102 = scalar, U08, 102, "", 1, 0, 0, 255, 0
unused10_103 = scalar, U08, 103, "", 1, 0, 0, 255, 0
unused10_104 = scalar, U08, 104, "", 1, 0, 0, 255, 0
unused10_105 = scalar, U08, 105, "", 1, 0, 0, 255, 0
unused10_106 = scalar, U08, 106, "", 1, 0, 0, 255, 0
unused10_107 = scalar, U08, 107, "", 1, 0, 0, 255, 0
unused10_108 = scalar, U08, 108, "", 1, 0, 0, 255, 0
unused10_109 = scalar, U08, 109, "", 1, 0, 0, 255, 0
unused10_110 = scalar, U08, 110, "", 1, 0, 0, 255, 0
unused10_111 = scalar, U08, 111, "", 1, 0, 0, 255, 0
unused10_112 = scalar, U08, 112, "", 1, 0, 0, 255, 0
unused10_113 = scalar, U08, 113, "", 1, 0, 0, 255, 0
unused10_114 = scalar, U08, 114, "", 1, 0, 0, 255, 0
unused10_115 = scalar, U08, 115, "", 1, 0, 0, 255, 0
unused10_116 = scalar, U08, 116, "", 1, 0, 0, 255, 0
unused10_117 = scalar, U08, 117, "", 1, 0, 0, 255, 0
unused10_118 = scalar, U08, 118, "", 1, 0, 0, 255, 0
unused10_119 = scalar, U08, 119, "", 1, 0, 0, 255, 0
unused10_120 = scalar, U08, 120, "", 1, 0, 0, 255, 0
unused10_121 = scalar, U08, 121, "", 1, 0, 0, 255, 0
unused10_122 = scalar, U08, 122, "", 1, 0, 0, 255, 0
unused10_123 = scalar, U08, 123, "", 1, 0, 0, 255, 0
unused10_124 = scalar, U08, 124, "", 1, 0, 0, 255, 0
unused10_125 = scalar, U08, 125, "", 1, 0, 0, 255, 0
unused10_126 = scalar, U08, 126, "", 1, 0, 0, 255, 0
unused10_127 = scalar, U08, 127, "", 1, 0, 0, 255, 0
;-------------------------------------------------------------------------------
[ConstantsExtensions]

View File

@ -47,6 +47,7 @@ struct config1 configPage1;
struct config2 configPage2;
struct config3 configPage3;
struct config4 configPage4;
struct config10 configPage10;
int req_fuel_uS, inj_opentime_uS;

View File

@ -31,7 +31,25 @@ Current layout of EEPROM data (Version 3) is as follows (All sizes are in bytes)
| 1127 |2 | X and Y sizes for boost table |
| 1129 |64 | Boost Map (8x8) |
| 1193 |8 | Boost Table RPM bins |
| 1201 |8 | Bost Table TPS bins |
| 1201 |8 | Boost Table TPS bins |
| 1209 |2 | X and Y sizes |
| 1211 |64 | PAGE 8 MAP2 |
| 1275 |8 | Xbins Map2 |
| 1283 |8 | Ybins Map2 |
| 1291 |2 | X and Y sizes1 |
| 1293``|36 | PAGE 9 MAP1 |
| 1329 |12 | X and Y Bins1 |
| 1341 |2 | X and Y size2 |
| 1343 |36 | PAGE 9 MAP2 |
| 1379 |6 | X and Y Bins2 |
| 1391 |2 | X and Y sizes3 |
| 1393 |36 | PAGE 9 MAP3 |
| 1429 |6 | X and Y Bins3 |
| 1441 |2 | X and Y size4 |
| 1443 |36 | PAGE 9 MAP4 |
| 1479 |6 | X and Y Bins4 |
| 1500 |128 | CANBUS config and data |
| |
| 2559 |512 | Calibration data (O2) |
| 3071 |512 | Calibration data (IAT) |
| 3583 |512 | Calibration data (CLT) |
@ -93,6 +111,8 @@ Current layout of EEPROM data (Version 3) is as follows (All sizes are in bytes)
#define EEPROM_CONFIG9_MAP4 1443
#define EEPROM_CONFIG9_XBINS4 1479
#define EEPROM_CONFIG9_YBINS4 1485
#define EEPROM_CONFIG10_START 1500
#define EEPROM_CONFIG10_END 1628
//Calibration data is stored at the end of the EEPROM (This is in case any further calibration tables are needed as they are large blocks)
#define EEPROM_LAST_BARO 2558

View File

@ -263,6 +263,19 @@ void writeConfig()
z++;
i++;
}
//*********************************************************************************************************************************************************************************
/*---------------------------------------------------
| Config page 10 (See storage.h for data layout)
| 128 byte long config table
-----------------------------------------------------*/
pnt_configPage = (byte *)&configPage10; //Create a pointer to Page 10 in memory
for(int x=EEPROM_CONFIG10_START; x<EEPROM_CONFIG10_END; x++)
{
if(EEPROM.read(x) != *(pnt_configPage + byte(x - EEPROM_CONFIG10_START))) { EEPROM.write(x, *(pnt_configPage + byte(x - EEPROM_CONFIG10_START))); }
}
//*********************************************************************************************************************************************************************************
}
void loadConfig()
@ -467,6 +480,16 @@ void loadConfig()
z++;
i++;
}
//*********************************************************************************************************************************************************************************
//canbus control page load
pnt_configPage = (byte *)&configPage10; //Create a pointer to Page 10 in memory
for(int x=EEPROM_CONFIG10_START; x<EEPROM_CONFIG10_END; x++)
{
*(pnt_configPage + byte(x - EEPROM_CONFIG10_START)) = EEPROM.read(x);
}
//*********************************************************************************************************************************************************************************
}
/*