[En-Nut-Discussion] Problem with write eeprom

Peter pgaskell at darkwing.uoregon.edu
Sun Jan 1 22:11:17 CET 2006


i asked the discussion group about this a while ago and i got a  
solution from them, it should be in the archive, but here's what i did.

function looks almost right, at least a lot like mine except i use  
sizeof() to pass the length to the function, yours would probably  
work too:

	/*
	 * Save a binary into the EEPROM.
	 */
	static int ConfigSaveBinary(int addr, void *val, size_t len)
	{
     	size_t i;
     	u_char *cp = val;
	
	    for (i = 0; i < len; cp++, i++)
	        if (eeprom_read_byte((void *) (addr + i)) != *cp)
     	        eeprom_write_byte((void *) (addr + i), *cp);

     	return len;
	}

for the addr, i do
	
	#define CONFAPP_EE_OFFSET   512

and then set addr to it before i do all my saves
	
	/*save variable to eeprom*/
	addr = CONFAPP_EE_OFFSET;
	addr += ConfigSaveBinary(addr, &variable, sizeof(variable));

this puts the stuff out of the way of the OS's stuff in eeprom

-peter

On Jan 1, 2006, at 9:18 AM, Stoffel Armin wrote:

> I must store 200byte into the EEPROM. (need the data also after a  
> power failure)
> I programmed a function ConfigSaveString.
> Where is the address range which I can use?
> Is my Function ConfigSaveString correct?
>
>
> Programm:
>
> ConfigSaveString(???,"255.255.255.224");
>
> int ConfigSaveString(int addr, u_char * str)
> {
>    int rc = 0;
>    do {
>        if (eeprom_read_byte((void *) (addr + rc)) != *str)
>            eeprom_write_byte((void *) (addr + rc), *str);
>        rc++;
>    } while (*str++);
>
>    return rc;
> }
>
> _______________________________________________
> En-Nut-Discussion mailing list
> En-Nut-Discussion at egnite.de
> http://www.egnite.de/mailman/listinfo.cgi/en-nut-discussion




More information about the En-Nut-Discussion mailing list