www.pudn.com > iccavr_lib.rar > eepromr.c, change:2003-10-28,size:1449b
/* Modified by Richard Man */ /* ** Purpose: EEPROM read & write routines ** ** Version: 1.0.0, 8:th of May 1999 ** ** Author: Lars Wictorsson ** LAWICEL / SWEDEN ** http://www.lawicel.com lars@lawicel.com ** ** History: 1999-05-08 Created **/ /* These routines work for all AVR devices except for 2313 and below * The "location" argument is not bound so in theory you should call it * with something like * * #include <io????.h> * * ... * EEPROMwrite(addr & E2END, byte); */ #ifdef _M169 #include <iom169v.h> #else #include <io8515v.h> // ALL devices have the same EEPROM reg locations #endif #include <eeprom.h> unsigned char EEPROMread( int location) { while (EECR & 0x02); // Wait until any earlier write is done. // This is just a safety incase a write // was done and is not completed when // the read was called. If this test is // not done, the current write operation // will fail due to that the address or // data is changed. EEAR = location; EECR |= 0x01; // Set READ strobe return (EEDR); // Return byte }