📄 eeprom.c
字号:
#include <hidef.h> // common defines and macros
#include <mc9s12dg128.h> // derivative information
#define uchar unsigned char
#define uint unsigned int
void write(uint add, uint con) //写con 入 add 地址中
{
unsigned int *eeaddr; //eeprom pointer
eeaddr=(volatile unsigned int*)(add);
// ramaddr=(volatile unsigned int*)(0x100a);
while(!(ECLKDIV&0x80)) //whether the eclkdiv has been writen once after rest
{}
while(!(ESTAT&0x80)) //whether the command buffer is empty
{}
while(!(EPROT&0x80)) //whether the eeprom is enabled to program or erase
{}
*eeaddr=con;
ECMD=0x20;
ESTAT|=0x80;
while(!(ESTAT&0x40)) //whether the command is complete
{}
}
uint read (uint add) //read a data from eeprom
{
uint ret;
ret = *(volatile word *) add;
// *Data = *(volatile byte *) Addr
return ret;
} //*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -