View Single Post
  #4   Spotlight this post!  
Unread 28-01-2007, 22:56
htwiz2002's Avatar
htwiz2002 htwiz2002 is offline
Htwizard
AKA: Anthony Takata Bawahawba
#1290
Team Role: Engineer
 
Join Date: Jan 2004
Location: Chandler, AZ
Posts: 23
htwiz2002 will become famous soon enough
Red face Re: Pointers/References?

I think I (might) have fixed it. (at least, it's not giving me errors anymore...)
The following is the example in entirety:
Code:
// Eepromhelper.c
#include "eeprom.h"
//Version verify codes:
unsigned char version1 = 0;
unsigned char version2 = 1;
unsigned char version3 = 1;
unsigned char version4 = 0;
//end verify codes...
// Verify codes are supposed to be for version check so in case the wrong version data is stored the robot will not use it (until saveing, which the robot will post a warning of overwrite (still in the works...))

// EEprom section:
void Terminal_eepromwriteset(char data1, char data2, char data3, char data4, unsigned char set) 
{
    //Consolidate this on verify that it works!!!
    unsigned int address = set * 4 -1;
    EEPROM_Write(address + 1, data1);
    EEPROM_Write(address + 2, data2);
    EEPROM_Write(address + 3, data3);
    EEPROM_Write(address + 4, data4);
}
void Terminal_eepromreadset(unsigned char set, unsigned char *data1, unsigned char *data2, unsigned char *data3, unsigned char *data4)
{
    //Consolidate this on verify that it works!!!
    unsigned int address = set * 4 -1;
    *data1 = EEPROM_Read(address + 1);
    *data2 = EEPROM_Read(address + 2);
    *data3 = EEPROM_Read(address + 3);
    *data4 = EEPROM_Read(address + 4);
}
void Limit_S0witch_Max(unsigned char switch_state, unsigned char *input_value, unsigned char *yep){}
char Terminal_loadFromEeprom(char set)
{
char rtn = 0;
    //This routine loads four char values from eeprom using a set switch te determine which bits to load.
    //Set starts with zero and also indicates what address to use (starting with zero)
    //Returns 0 if send to buffer success, 1 if read failed, 999 if set number is invalid
    //Make sure this information is mirrored in Terminal_saveToEeprom() !!!
switch (set)
{
case 0: //this is an example set, meant only for verification of data...
        //This is also viable for version verify, for automatic reset...
        Terminal_eepromreadset(0, &version1, &version2, &version3, &version4); break;
default: return 999; break;
}
return rtn;
}
//
char Terminal_saveToEeprom(char set)
{
    //This routine saves four char values to eeprom using a set switch te determine which bites to save.
    //Set starts with zero and also indicates what address to use (starting with zero)
    //Returns 0 if send to buffer success, 1 if buffer is full, 999 if set number is invalid
    //Make sure this information is mirrored in Terminal_loadFromEeprom() !!!
if (EEPROM_Queue_Free_Space() > 4)
{
switch (set)
{
case 0: //this is an example set, meant only for verification of data...
        //This is also viable for version verify, for automatic reset...
Terminal_eepromwriteset(version1, version2, version3, version4, 0); break;

default: return 999; break;
}
}
else
{
    return 1;
}
return 0;
}
// End eeprom section...
The full source is included (just in case someone wants to see a W.I.P.

Hope this can be helpful to some others
Attached Files
File Type: c terminal.c (19.4 KB, 108 views)
__________________
TsAuKpAeTrA (Anthony)