For EEPROM read and write function
This commit is contained in:
34
src/eeprom_rw.c
Normal file
34
src/eeprom_rw.c
Normal file
@@ -0,0 +1,34 @@
|
||||
#include "BA45F5250.h"
|
||||
#include "stdint.h"
|
||||
#include "build-in.h"
|
||||
#include "eeprom_rw.h"
|
||||
|
||||
void eeprom_write(uint8_t addr, uint8_t data)
|
||||
{
|
||||
_emi = 0;
|
||||
_eea = addr;
|
||||
_eed = data;
|
||||
_mp1l = 0x40;
|
||||
_mp1h = 0x01;
|
||||
_iar1 |= 0b00001000;
|
||||
_iar1 |= 0b00000100;
|
||||
while(_iar1 & 0b00000100);
|
||||
_iar1 = 0x00;
|
||||
_mp1h = 0x00;
|
||||
_emi = 1;
|
||||
}
|
||||
|
||||
uint8_t eeprom_read(uint8_t addr)
|
||||
{
|
||||
_emi = 0;
|
||||
_eea = addr;
|
||||
_mp1l = 0x40;
|
||||
_mp1h = 0x01;
|
||||
_iar1 |= 0b00000010;
|
||||
_iar1 |= 0b00000001;
|
||||
while(_iar1 & 0b00000001);
|
||||
_iar1 = 0x00;
|
||||
_mp1h = 0x00;
|
||||
_emi = 1;
|
||||
return _eed;
|
||||
}
|
||||
Reference in New Issue
Block a user