⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 eepromr.c

📁 ICCAVR中所有的库函数源码
💻 C
字号:
/* 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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -