summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices
diff options
context:
space:
mode:
author AJR <ajrhacker@users.noreply.github.com>2017-11-12 02:03:10 -0500
committer AJR <ajrhacker@users.noreply.github.com>2017-11-12 02:03:10 -0500
commitf171f5556807431f3d6388e385fdc4fde073a07c (patch)
treed0f1ed59b6fad4140f297da053b58b03a5bef2b4 /src/devices
parent3169eb94c55e63b8e63e09b0398c17befbd2eddd (diff)
tti: Add serial EEPROM using new DO write callback (nw)
Diffstat (limited to 'src/devices')
-rw-r--r--src/devices/machine/eepromser.cpp31
-rw-r--r--src/devices/machine/eepromser.h7
2 files changed, 22 insertions, 16 deletions
diff --git a/src/devices/machine/eepromser.cpp b/src/devices/machine/eepromser.cpp
index 74d51e980f3..0ca2a10a282 100644
--- a/src/devices/machine/eepromser.cpp
+++ b/src/devices/machine/eepromser.cpp
@@ -148,6 +148,7 @@ eeprom_serial_base_device::eeprom_serial_base_device(const machine_config &mconf
m_command_address_bits(0),
m_streaming_enabled(false),
m_output_on_falling_clock_enabled(false),
+ m_do_cb(*this),
m_state(STATE_IN_RESET),
m_cs_state(CLEAR_LINE),
m_last_cs_rising_edge_time(attotime::zero),
@@ -211,6 +212,9 @@ 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));
@@ -368,6 +372,9 @@ 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);
}
@@ -443,6 +450,9 @@ void eeprom_serial_base_device::handle_event(eeprom_event event)
m_shift_register = read((m_address + m_bits_accum / m_data_bits) & ((1 << m_address_bits) - 1)) << (32 - m_data_bits);
else
m_shift_register = (m_shift_register << 1) | 1;
+
+ // update DO
+ m_do_cb(BIT(m_shift_register, 31));
}
else if (event == EVENT_CS_FALLING_EDGE)
{
@@ -785,12 +795,8 @@ eeprom_serial_x24c44_device::eeprom_serial_x24c44_device(const machine_config &m
void eeprom_serial_x24c44_device::device_start()
{
- // if no command address bits set, just inherit from the address bits
- if (m_command_address_bits == 0)
- m_command_address_bits = m_address_bits;
-
// start the base class
- eeprom_base_device::device_start();
+ eeprom_serial_base_device::device_start();
int16_t i=0;
m_ram_length=0xf;
@@ -800,18 +806,8 @@ void eeprom_serial_x24c44_device::device_start()
}
m_reading=0;
m_store_latch=0;
+
// save the current state
- save_item(NAME(m_state));
- save_item(NAME(m_cs_state));
- save_item(NAME(m_oe_state));
- save_item(NAME(m_clk_state));
- save_item(NAME(m_di_state));
- save_item(NAME(m_locked));
- save_item(NAME(m_bits_accum));
- save_item(NAME(m_command_address_accum));
- save_item(NAME(m_command));
- save_item(NAME(m_address));
- save_item(NAME(m_shift_register));
save_item(NAME(m_ram_data));
save_item(NAME(m_reading));
save_item(NAME(m_store_latch));
@@ -1012,6 +1008,9 @@ void eeprom_serial_x24c44_device::handle_event(eeprom_event event)
m_shift_register = (m_shift_register << 1) | 1;
}
+
+ // update DO
+ m_do_cb(BIT(m_shift_register, 31));
}
else if (event == EVENT_CS_FALLING_EDGE)
{
diff --git a/src/devices/machine/eepromser.h b/src/devices/machine/eepromser.h
index 529fbeb5b04..d0d662948d8 100644
--- a/src/devices/machine/eepromser.h
+++ b/src/devices/machine/eepromser.h
@@ -91,6 +91,8 @@
#define MCFG_EEPROM_SERIAL_DATA MCFG_EEPROM_DATA
#define MCFG_EEPROM_SERIAL_DEFAULT_VALUE MCFG_EEPROM_DEFAULT_VALUE
+#define MCFG_EEPROM_SERIAL_DO_CALLBACK(_devcb) \
+ devcb = &eeprom_serial_base_device::static_set_do_callback(*device, DEVCB_##_devcb);
//**************************************************************************
@@ -107,6 +109,10 @@ public:
static void static_set_address_bits(device_t &device, int addrbits);
static void static_enable_streaming(device_t &device);
static void static_enable_output_on_falling_clock(device_t &device);
+ template<class Object> static devcb_base &static_set_do_callback(device_t &device, Object &&object)
+ {
+ return downcast<eeprom_serial_base_device &>(device).m_do_cb.set_callback(std::forward<Object>(object));
+ }
protected:
// construction/destruction
@@ -174,6 +180,7 @@ protected:
uint8_t m_command_address_bits; // number of address bits in a command
bool m_streaming_enabled; // true if streaming is enabled
bool m_output_on_falling_clock_enabled; // true if the output pin is updated on the falling edge of the clock
+ devcb_write_line m_do_cb; // callback to push state of DO line
// runtime state
eeprom_state m_state; // current internal state