# HG changeset patch # User Michael Pavone # Date 1437456169 25200 # Node ID ba38e36559b044bfb2a08c33d143222e68896300 # Parent 6e1711d566337d32d56eefcf58af448d82343e8c EEPROM writes now seem to work for NFL Quarterback Club 96 diff -r 6e1711d56633 -r ba38e36559b0 romdb.c --- a/romdb.c Mon Jul 20 21:58:31 2015 -0700 +++ b/romdb.c Mon Jul 20 22:22:49 2015 -0700 @@ -99,9 +99,6 @@ case I2C_WRITE: state->buffer[state->address] = state->latch; state->state = I2C_WRITE_ACK; - state->address++; - //TODO: page mask - state->address &= state->size-1; break; } } @@ -111,15 +108,12 @@ state->state = I2C_READ; state->counter = 8; state->latch = state->buffer[state->address]; - state->address++; - //TODO: page mask - state->address &= state->size-1; } else { if (state->size < 256) { state->address = state->latch >> 1; state->state = I2C_WRITE; - } else if (state->size < 8192) { - state->address = state->latch << 8; + } else if (state->size < 4096) { + state->address = (state->latch & 0xE) << 7; state->state = I2C_ADDRESS; } else { state->state = I2C_ADDRESS_HI; @@ -133,6 +127,8 @@ break; case I2C_ADDRESS_ACK: state->state = I2C_WRITE; + state->address &= state->size-1; + printf("EEPROM address is %X\n", state->address); state->counter = 8; break; case I2C_READ: @@ -144,10 +140,16 @@ case I2C_READ_ACK: state->state = I2C_READ; state->counter = 8; + state->address++; + //TODO: page mask + state->address &= state->size-1; break; case I2C_WRITE_ACK: state->state = I2C_WRITE; state->counter = 8; + state->address++; + //TODO: page mask + state->address &= state->size-1; break; } } else if (~val & state->scl) { @@ -349,8 +351,8 @@ } printf("EEPROM byte write: %X - %X (using mask %X and expanded val %X)\n", address, value, mask, expanded); if (map->scl_mask & mask) { - printf("scl: %d, state: %s\n", (expanded & map->scl_mask) != 0, i2c_states[gen->eeprom.state]); set_scl(&gen->eeprom, (expanded & map->scl_mask) != 0); + printf("scl: %d, state: %s, counter: %d, latch: %X\n", (expanded & map->scl_mask) != 0, i2c_states[gen->eeprom.state], gen->eeprom.counter, gen->eeprom.latch); } if (map->sda_write_mask & mask) { printf("sda: %d\n", (expanded & map->sda_write_mask) != 0);