EECON2
This commit is contained in:
@ -78,6 +78,8 @@ public class DataRegister {
|
||||
|
||||
public static int getRegister(int fileAddress){
|
||||
int address = determineIndirectAndChange (fileAddress);
|
||||
if (bank () + address == EECON2)
|
||||
return 0;
|
||||
return dataRegister[bank() + address];
|
||||
}
|
||||
|
||||
@ -109,6 +111,8 @@ public class DataRegister {
|
||||
|
||||
public static int getBit(int fileAddress, int bit) {
|
||||
int address = determineIndirectAndChange (fileAddress);
|
||||
if (bank() + address == EECON2)
|
||||
return 0;
|
||||
return (dataRegister[bank() + address] >> bit) & 1;
|
||||
}
|
||||
|
||||
|
||||
@ -24,6 +24,7 @@ public class EEPROM {
|
||||
|
||||
private static boolean readControl = false;
|
||||
private static boolean writeControl = false;
|
||||
private static boolean [] eecon2stages = {false, false};
|
||||
|
||||
public static long read (int address) {
|
||||
FileReader reader;
|
||||
@ -72,6 +73,7 @@ public class EEPROM {
|
||||
DataRegister.setDirectBit(EECON1, WRERR, 1);
|
||||
return;
|
||||
}
|
||||
eecon2stages = new boolean[]{false, false};
|
||||
DataRegister.setDirectBit(EECON1, EEIF, 1);
|
||||
DataRegister.setDirectBit(EECON1, WR, 0);
|
||||
writeControl = false;
|
||||
@ -87,7 +89,7 @@ public class EEPROM {
|
||||
if(address == EECON1) {
|
||||
if (DataRegister.getDirectBit(address, content) == 1)
|
||||
setEECON1((int) (DataRegister.getDirectRegister(EECON1) - Math.pow(2, content)));
|
||||
} else if (address != EECON2) {
|
||||
} else {
|
||||
DataRegister.setDirectBit(address, content, 0);
|
||||
}
|
||||
break;
|
||||
@ -95,7 +97,7 @@ public class EEPROM {
|
||||
if(address == EECON1) {
|
||||
if (DataRegister.getDirectBit(address, content) == 0)
|
||||
setEECON1((int) (DataRegister.getDirectRegister(EECON1) + Math.pow(2, content)));
|
||||
} else if (address != EECON2) {
|
||||
} else {
|
||||
if (address == EEADR && content >= 0b01000000)
|
||||
DataRegister.setDirectBit(address, content, 0);
|
||||
else
|
||||
@ -105,9 +107,17 @@ public class EEPROM {
|
||||
case 0b11: // SET BYTE
|
||||
if(address == EECON1) {
|
||||
setEECON1 (content);
|
||||
} else if (address != EECON2) {
|
||||
} else {
|
||||
if (address == EEADR)
|
||||
content &= 0b00111111;
|
||||
else if (address == EECON2) {
|
||||
if (content == 0x55)
|
||||
eecon2stages [0] = true;
|
||||
else if (content == 0xAA && eecon2stages[0])
|
||||
eecon2stages [1] = true;
|
||||
else
|
||||
eecon2stages = new boolean[]{false, false};
|
||||
}
|
||||
DataRegister.setDirectRegister(address, content);
|
||||
}
|
||||
break;
|
||||
@ -127,7 +137,7 @@ public class EEPROM {
|
||||
else if ((content & 0b1) == 0 && readControl) // RD kann nicht manuell gecleart werden
|
||||
content |= 0b1;
|
||||
if (((content & 0b10) >> 1) == 1) { // WRITE CONTROL
|
||||
if (writeEnabled) {
|
||||
if (writeEnabled && eecon2stages[0] && eecon2stages[1]) {
|
||||
writeControl = true;
|
||||
DataRegister.setDirectRegister(EECON1, content);
|
||||
write(DataRegister.getDirectRegister(EEADR), DataRegister.getDirectRegister(EEDATA));
|
||||
|
||||
Reference in New Issue
Block a user