8 : sram(NUM_ADDRESSES, xml,
SRAM::DontLoadTag{})
13 : sram(name +
" EEPROM", NUM_ADDRESSES, config)
19 completionTime = EmuTime::zero();
21 writeProtected =
true;
27uint8_t EEPROM_93C46::read(
unsigned addr)
const
32void EEPROM_93C46::write(
unsigned addr, uint8_t value, EmuTime::param time)
36 sram.
write(addr, value);
40void EEPROM_93C46::writeAll(uint8_t value, EmuTime::param time)
49void EEPROM_93C46::erase(
unsigned addr, EmuTime::param time)
51 sram.
write(addr, 255);
55void EEPROM_93C46::eraseAll(EmuTime::param time)
61bool EEPROM_93C46::ready(EmuTime::param time)
const
63 return time >= completionTime;
69 return shiftRegister & (1 << (SHIFT_REG_BITS - 1));
79 if (pinCS == value)
return;
94 if (pinCLK == value)
return;
107void EEPROM_93C46::clockEvent(EmuTime::param time)
117 if (pinDI && ready(time) && (time > csTime)) {
125 shiftRegister = narrow_cast<uint16_t>((shiftRegister << 1) |
int(pinDI));
128 execute_command(time);
134 uint8_t value = read(address);
135 shiftRegister = uint16_t(value << (SHIFT_REG_BITS -
DATA_BITS));
144 shiftRegister = narrow_cast<uint16_t>((shiftRegister << 1) |
int(pinDI));
147 if (writeProtected) {
151 write(address, narrow_cast<uint8_t>(shiftRegister), time);
157 shiftRegister = narrow_cast<uint16_t>((shiftRegister << 1) |
int(pinDI));
160 if (writeProtected) {
164 writeAll(narrow_cast<uint8_t>(shiftRegister), time);
171void EEPROM_93C46::execute_command(EmuTime::param time)
181 writeProtected =
true;
191 if (writeProtected) {
200 writeProtected =
false;
220 if (writeProtected) {
224 erase(address, time);
230static constexpr std::initializer_list<enum_string<EEPROM_93C46::State>> stateInfo = {
240template<
typename Archive>
243 ar.serialize(
"sram", sram,
244 "completionTime", completionTime,
247 "shiftRegister", shiftRegister,
253 "writeProtected", writeProtected);
static constexpr uint32_t ADDRESS_MASK
static constexpr uint8_t ADDRESS_BITS
void write_CS(bool value, EmuTime::param time)
static constexpr uint32_t NUM_ADDRESSES
static constexpr uint8_t DATA_BITS
void serialize(Archive &ar, unsigned version)
EEPROM_93C46(const XMLElement &xml)
void write_CLK(bool value, EmuTime::param time)
bool read_DO(EmuTime::param time) const
void write_DI(bool value, EmuTime::param time)
static constexpr EmuDuration usec(unsigned x)
void write(size_t addr, byte value)
void memset(size_t addr, byte c, size_t size)
This file implemented 3 utility functions:
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)
#define SERIALIZE_ENUM(TYPE, INFO)