Quote:
Originally Posted by buddy.smith
Why not do this:
Code:
void Terminal_eepromreadset(unsigned char set, unsigned char data[4])
{
//Consolidate this on verify that it works!!!
unsigned int address = set * 4;
data[0] = EEPROM_Read(address);
data[1] = EEPROM_Read(address + 1);
data[2] = EEPROM_Read(address + 2);
data[3] = EEPROM_Read(address + 3);
}
Note that this is the same as:
Code:
void Terminal_eepromreadset(unsigned char set, unsigned char *data)
version1 is a 'char'. Terminal_eepromreadset wants a char*. To convert a char to a char *, you use the addressof operator (&):
Code:
Terminal_eepromreadset(0, &version1,.....)
Alternately, you can use my suggestion:
Code:
unsigned char version[4];
Terminal_eepromreadset(0, version);
In C, an array and a pointer are mostly equivalent. version is a char*, version[N] is a char.
Confusing as dirt?
ttyl,
--buddy
|
Well, the idea is that I can simply specify a variable into the function so that the function can load the value into the variable, rather than having to call it and
then store the information. its' purpose is to save space and ease of use, not reverse it. The point is to simply call the function to load four variables in the set (part of the autonomous routine). The other half of the function uses the same input to save it.
Is there a way to make the multi-variable-in-the-input idea work? It cleans the code up so much that I would rather keep it that way. Can someone at least tell me why I get that message about a "suspicious pointer conversion"? I'm sure the code would work if I could pass more than just one variable into the function (which is what it seems).