?? _256eeprom.c
字號:
/* Modified for 2313 by Richard Man, ImageCraft */
/*
** 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
**/
#include <io2313v.h> // or io4414.h, or...
int _256EEPROMwrite( int location, unsigned char byte)
{
unsigned char oldSREG;
while (EECR & 0x02); // Wait until any earlier write is done
EEAR = location & 0xFF; // Set EEPROM address
EEDR = byte;
oldSREG = SREG;
SREG &= ~0x80; // interrupt off
EECR |= 0x04; // Set MASTER WRITE enable
EECR |= 0x02; // Set WRITE strobe
SREG = oldSREG;
return 0; // return Success.
// Could be expanded so that
// the routine checks that the address
// is within the range of the chip.
}
unsigned char _256EEPROMread( 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 & 0xFF; // Set EEPROM address
EECR |= 0x01; // Set READ strobe
return (EEDR); // Return byte
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -