diff options
Diffstat (limited to 'src/devices/machine/i2cmem.cpp')
-rw-r--r-- | src/devices/machine/i2cmem.cpp | 40 |
1 files changed, 27 insertions, 13 deletions
diff --git a/src/devices/machine/i2cmem.cpp b/src/devices/machine/i2cmem.cpp index 8c64c372358..1197eb00c0c 100644 --- a/src/devices/machine/i2cmem.cpp +++ b/src/devices/machine/i2cmem.cpp @@ -23,7 +23,9 @@ there are two standard values. ***************************************************************************/ #include "emu.h" -#include "machine/i2cmem.h" +#include "i2cmem.h" + +#include <cstdarg> constexpr int STATE_IDLE(0); constexpr int STATE_DEVSEL(1); @@ -50,7 +52,7 @@ static inline void ATTR_PRINTF( 3, 4 ) verboselog( device_t *device, int n_level va_list v; char buf[ 32768 ]; va_start( v, s_fmt ); - vsprintf( buf, s_fmt, v ); + vsnprintf( buf, 32768, s_fmt, v ); va_end( v ); device->logerror( "%s: I2CMEM %s", device->machine().describe_context(), buf ); } @@ -73,6 +75,8 @@ DEFINE_DEVICE_TYPE(I2C_X2404P, i2c_x2404p_device, "x2404p", "X2404P I2C Memor DEFINE_DEVICE_TYPE(I2C_24C08, i2c_24c08_device, "24c08", "24C08 I2C Memory") DEFINE_DEVICE_TYPE(I2C_24C16, i2c_24c16_device, "24c16", "24C16 I2C Memory") DEFINE_DEVICE_TYPE(I2C_24C64, i2c_24c64_device, "24c64", "24C64 I2C Memory") +DEFINE_DEVICE_TYPE(I2C_24C128, i2c_24c128_device, "24c128", "24C128 I2C Memory") +DEFINE_DEVICE_TYPE(I2C_24C256, i2c_24c256_device, "24c256", "24C256 I2C Memory") DEFINE_DEVICE_TYPE(I2C_24C512, i2c_24c512_device, "24c512", "24C512 I2C Memory") //************************************************************************** @@ -181,6 +185,16 @@ i2c_24c64_device::i2c_24c64_device(const machine_config &mconfig, const char *ta { } +i2c_24c128_device::i2c_24c128_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : + i2cmem_device(mconfig, I2C_24C128, tag, owner, clock, 0, 64, 0x4000) +{ +} + +i2c_24c256_device::i2c_24c256_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : + i2cmem_device(mconfig, I2C_24C256, tag, owner, clock, 0, 64, 0x8000) +{ +} + i2c_24c512_device::i2c_24c512_device(const machine_config& mconfig, const char* tag, device_t* owner, uint32_t clock) : i2cmem_device(mconfig, I2C_24C512, tag, owner, clock, 0, 128, 0x10000) { @@ -253,8 +267,8 @@ void i2cmem_device::nvram_default() bool i2cmem_device::nvram_read( util::read_stream &file ) { - size_t actual; - return !file.read( &m_data[0], m_data_size, actual ) && actual == m_data_size; + auto const [err, actual] = read( file, &m_data[0], m_data_size ); + return !err && ( actual == m_data_size ); } //------------------------------------------------- @@ -264,8 +278,8 @@ bool i2cmem_device::nvram_read( util::read_stream &file ) bool i2cmem_device::nvram_write( util::write_stream &file ) { - size_t actual; - return !file.write( &m_data[0], m_data_size, actual ) && actual == m_data_size; + auto const [err, actual] = write( file, &m_data[0], m_data_size ); + return !err; } @@ -274,7 +288,7 @@ bool i2cmem_device::nvram_write( util::write_stream &file ) // READ/WRITE HANDLERS //************************************************************************** -WRITE_LINE_MEMBER( i2cmem_device::write_e0 ) +void i2cmem_device::write_e0(int state) { state &= 1; if( m_e0 != state ) @@ -285,7 +299,7 @@ WRITE_LINE_MEMBER( i2cmem_device::write_e0 ) } -WRITE_LINE_MEMBER( i2cmem_device::write_e1 ) +void i2cmem_device::write_e1(int state) { state &= 1; if( m_e1 != state ) @@ -296,7 +310,7 @@ WRITE_LINE_MEMBER( i2cmem_device::write_e1 ) } -WRITE_LINE_MEMBER( i2cmem_device::write_e2 ) +void i2cmem_device::write_e2(int state) { state &= 1; if( m_e2 != state ) @@ -307,7 +321,7 @@ WRITE_LINE_MEMBER( i2cmem_device::write_e2 ) } -WRITE_LINE_MEMBER( i2cmem_device::write_sda ) +void i2cmem_device::write_sda(int state) { state &= 1; if( m_sdaw != state ) @@ -344,7 +358,7 @@ WRITE_LINE_MEMBER( i2cmem_device::write_sda ) } } -WRITE_LINE_MEMBER( i2cmem_device::write_scl ) +void i2cmem_device::write_scl(int state) { if( m_scl != state ) { @@ -549,7 +563,7 @@ WRITE_LINE_MEMBER( i2cmem_device::write_scl ) } -WRITE_LINE_MEMBER( i2cmem_device::write_wc ) +void i2cmem_device::write_wc(int state) { state &= 1; if( m_wc != state ) @@ -560,7 +574,7 @@ WRITE_LINE_MEMBER( i2cmem_device::write_wc ) } -READ_LINE_MEMBER( i2cmem_device::read_sda ) +int i2cmem_device::read_sda() { int res = m_sdar & 1; verboselog( this, 2, "read sda %d\n", res ); |