eepromr.c

来自「avr的icc编译器的源代码」· C语言 代码 · 共 50 行

C
50
字号
/* 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
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?