summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/machine/eepromser.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/machine/eepromser.cpp')
-rw-r--r--src/devices/machine/eepromser.cpp106
1 files changed, 49 insertions, 57 deletions
diff --git a/src/devices/machine/eepromser.cpp b/src/devices/machine/eepromser.cpp
index a8502e72fe3..e060eaed79a 100644
--- a/src/devices/machine/eepromser.cpp
+++ b/src/devices/machine/eepromser.cpp
@@ -112,7 +112,7 @@
***************************************************************************/
#include "emu.h"
-#include "machine/eepromser.h"
+#include "eepromser.h"
@@ -190,9 +190,6 @@ void eeprom_serial_base_device::device_start()
// start the base class
eeprom_base_device::device_start();
- // resolve callback
- m_do_cb.resolve_safe();
-
// save the current state
save_item(NAME(m_state));
save_item(NAME(m_cs_state));
@@ -340,8 +337,8 @@ void eeprom_serial_base_device::set_state(eeprom_state newstate)
// switch to the new state
m_state = newstate;
- // set DO high (actually high impedance; pullup assumed)
- m_do_cb(1);
+ // set DO high (actually high impedance; pullup assumed) except when entering STATE_READING_DATA
+ m_do_cb(m_state != STATE_READING_DATA);
}
@@ -656,16 +653,16 @@ void eeprom_serial_93cxx_device::parse_command_and_address()
// do_read - read handlers
//-------------------------------------------------
-READ_LINE_MEMBER(eeprom_serial_93cxx_device::do_read) { return base_do_read() & ((m_state == STATE_WAIT_FOR_START_BIT) ? base_ready_read() : 1); }
+int eeprom_serial_93cxx_device::do_read() { return base_do_read() & ((m_state == STATE_WAIT_FOR_START_BIT) ? base_ready_read() : 1); }
//-------------------------------------------------
// cs_write/clk_write/di_write - write handlers
//-------------------------------------------------
-WRITE_LINE_MEMBER(eeprom_serial_93cxx_device::cs_write) { base_cs_write(state); }
-WRITE_LINE_MEMBER(eeprom_serial_93cxx_device::clk_write) { base_clk_write(state); }
-WRITE_LINE_MEMBER(eeprom_serial_93cxx_device::di_write) { base_di_write(state); }
+void eeprom_serial_93cxx_device::cs_write(int state) { base_cs_write(state); }
+void eeprom_serial_93cxx_device::clk_write(int state) { base_clk_write(state); }
+void eeprom_serial_93cxx_device::di_write(int state) { base_di_write(state); }
@@ -713,17 +710,17 @@ void eeprom_serial_er5911_device::parse_command_and_address()
// do_read/ready_read - read handlers
//-------------------------------------------------
-READ_LINE_MEMBER(eeprom_serial_er5911_device::do_read) { return base_do_read(); }
-READ_LINE_MEMBER(eeprom_serial_er5911_device::ready_read) { return base_ready_read(); }
+int eeprom_serial_er5911_device::do_read() { return base_do_read(); }
+int eeprom_serial_er5911_device::ready_read() { return base_ready_read(); }
//-------------------------------------------------
// cs_write/clk_write/di_write - write handlers
//-------------------------------------------------
-WRITE_LINE_MEMBER(eeprom_serial_er5911_device::cs_write) { base_cs_write(state); }
-WRITE_LINE_MEMBER(eeprom_serial_er5911_device::clk_write) { base_clk_write(state); }
-WRITE_LINE_MEMBER(eeprom_serial_er5911_device::di_write) { base_di_write(state); }
+void eeprom_serial_er5911_device::cs_write(int state) { base_cs_write(state); }
+void eeprom_serial_er5911_device::clk_write(int state) { base_clk_write(state); }
+void eeprom_serial_er5911_device::di_write(int state) { base_di_write(state); }
@@ -740,14 +737,13 @@ void eeprom_serial_x24c44_device::device_start()
// start the base class
eeprom_serial_base_device::device_start();
- int16_t i=0;
- m_ram_length=0xf;
+ m_ram_length = 0xf;
- for (i=0;i<16;i++){
- m_ram_data[i]=read(i); //autoreload at power up
- }
- m_reading=0;
- m_store_latch=0;
+ for (int i = 0; i < 16; i++)
+ m_ram_data[i] = read(i); // autoreload at power up
+
+ m_reading = 0;
+ m_store_latch = 0;
// save the current state
save_item(NAME(m_ram_data));
@@ -755,31 +751,28 @@ void eeprom_serial_x24c44_device::device_start()
save_item(NAME(m_store_latch));
}
-void eeprom_serial_x24c44_device::copy_eeprom_to_ram(){
- uint16_t i=0;
+void eeprom_serial_x24c44_device::copy_eeprom_to_ram()
+{
LOG1("EEPROM TO RAM COPY!!!\n");
- for (i=0;i<16;i++){
- m_ram_data[i]=read(i);
- }
- m_store_latch=1;
+ for (int i = 0; i < 16; i++)
+ m_ram_data[i] = read(i);
+ m_store_latch = 1;
}
-
-
-void eeprom_serial_x24c44_device::copy_ram_to_eeprom(){
- uint16_t i=0;
- if (m_store_latch){
+void eeprom_serial_x24c44_device::copy_ram_to_eeprom()
+{
+ if (m_store_latch)
+ {
LOG1("RAM TO EEPROM COPY\n");
- for (i=0;i<16;i++){
+ for (int i = 0; i < 16; i++)
write(i, m_ram_data[i]);
- }
- m_store_latch=0;
- }else{
- LOG0("Store command with store latch not set!\n");
+ m_store_latch = 0;
}
-
+ else
+ LOG0("Store command with store latch not set!\n");
}
+
//-------------------------------------------------
// execute_command - execute a command once we
// have enough bits for one
@@ -829,14 +822,14 @@ void eeprom_serial_x24c44_device::execute_command()
// lock the chip; return to IN_RESET state
case COMMAND_LOCK:
m_locked = true;
- m_store_latch=0;
+ m_store_latch = 0;
set_state(STATE_IN_RESET);
break;
// unlock the chip; return to IN_RESET state
case COMMAND_UNLOCK:
m_locked = false;
- m_store_latch=1;
+ m_store_latch = 1;
set_state(STATE_IN_RESET);
break;
@@ -909,20 +902,18 @@ void eeprom_serial_x24c44_device::handle_event(eeprom_event event)
// if we have enough bits for a command + address, check it out
m_command_address_accum = (m_command_address_accum << 1) | m_di_state;
- m_bits_accum=m_bits_accum+1;
+ m_bits_accum = m_bits_accum + 1;
- if (m_bits_accum == 2 + m_command_address_bits){
+ if (m_bits_accum == 2 + m_command_address_bits)
+ {
//read command is only 2 bits all other are 3 bits!!!
-
- parse_command_and_address_2_bit();
-
+ parse_command_and_address_2_bit();
}
- if (!m_reading){
- if (m_bits_accum == 3 + m_command_address_bits){
+ if (!m_reading && m_bits_accum == 3 + m_command_address_bits)
+ {
execute_command();
}
- }
}
else if (event == EVENT_CS_FALLING_EDGE)
set_state(STATE_IN_RESET);
@@ -934,8 +925,9 @@ void eeprom_serial_x24c44_device::handle_event(eeprom_event event)
{
int bit_index = m_bits_accum++;
- if (bit_index % m_data_bits == 0 && (bit_index == 0 || m_streaming_enabled)){
- m_shift_register=m_ram_data[m_address];
+ if (bit_index % m_data_bits == 0 && (bit_index == 0 || m_streaming_enabled))
+ {
+ m_shift_register = m_ram_data[m_address];
//m_shift_register=bitswap<16>(m_shift_register,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
//m_shift_register=bitswap<16>(m_shift_register,7,6,5,4,3,2,1,0,15,14,13,12,11,10,9,8);
@@ -979,7 +971,7 @@ void eeprom_serial_x24c44_device::handle_event(eeprom_event event)
//m_shift_register=bitswap<16>(m_shift_register, 0, 1, 2, 3, 4, 5,6,7, 8, 9,10,11,12,13,14,15);
//m_shift_register=bitswap<16>(m_shift_register, 7, 6, 5, 4, 3, 2,1,0,15,14,13,12,11,10, 9, 8);
m_shift_register=bitswap<16>(m_shift_register,8,9,10,11,12,13,14,15,0,1,2,3,4,5,6,7);
- m_ram_data[m_address]=m_shift_register;
+ m_ram_data[m_address] = m_shift_register;
LOG1("write to RAM addr=%02X data=%04X\n",m_address,m_shift_register);
}
@@ -1015,7 +1007,7 @@ void eeprom_serial_x24c44_device::parse_command_and_address()
m_address = (m_command_address_accum >> 3) & 0x0f;
- LOG1("EEPROM: command= %04X, address %02X\n", m_command_address_accum& 0x07, m_address);
+ LOG1("EEPROM: command= %04X, address %02X\n", m_command_address_accum & 0x07, m_address);
switch (m_command_address_accum & 0x07)
{
@@ -1069,16 +1061,16 @@ void eeprom_serial_x24c44_device::parse_command_and_address_2_bit()
// do_read/ready_read - read handlers
//-------------------------------------------------
-READ_LINE_MEMBER(eeprom_serial_x24c44_device::do_read) { return base_do_read(); }
+int eeprom_serial_x24c44_device::do_read() { return base_do_read(); }
//-------------------------------------------------
// cs_write/clk_write/di_write - write handlers
//-------------------------------------------------
-WRITE_LINE_MEMBER(eeprom_serial_x24c44_device::cs_write) { base_cs_write(state); }
-WRITE_LINE_MEMBER(eeprom_serial_x24c44_device::clk_write) { base_clk_write(state); }
-WRITE_LINE_MEMBER(eeprom_serial_x24c44_device::di_write) { base_di_write(state); }
+void eeprom_serial_x24c44_device::cs_write(int state) { base_cs_write(state); }
+void eeprom_serial_x24c44_device::clk_write(int state) { base_clk_write(state); }
+void eeprom_serial_x24c44_device::di_write(int state) { base_di_write(state); }
//**************************************************************************