summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/machine/acorn_bmu.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/machine/acorn_bmu.cpp')
-rw-r--r--src/devices/machine/acorn_bmu.cpp116
1 files changed, 60 insertions, 56 deletions
diff --git a/src/devices/machine/acorn_bmu.cpp b/src/devices/machine/acorn_bmu.cpp
index 3ff529525ff..94f5e953a53 100644
--- a/src/devices/machine/acorn_bmu.cpp
+++ b/src/devices/machine/acorn_bmu.cpp
@@ -16,8 +16,8 @@
#include "emu.h"
#include "acorn_bmu.h"
-#define LOG_DATA (1 << 1)
-#define LOG_LINE (1 << 2)
+#define LOG_DATA (1U << 1)
+#define LOG_LINE (1U << 2)
#define VERBOSE (0)
#include "logmacro.h"
@@ -72,7 +72,7 @@ void acorn_bmu_device::device_start()
// READ/WRITE HANDLERS
//**************************************************************************
-WRITE_LINE_MEMBER(acorn_bmu_device::scl_w)
+void acorn_bmu_device::scl_w(int state)
{
if (m_scl != state)
{
@@ -96,57 +96,60 @@ WRITE_LINE_MEMBER(acorn_bmu_device::scl_w)
{
if (m_scl)
{
- switch (m_state)
+ m_bits++;
+ }
+ else
+ {
+ if (m_bits == 8)
{
- case STATE_DEVSEL:
- m_devsel = m_shift;
-
- if ((m_devsel & 0xfe) != m_slave_address)
+ switch (m_state)
{
- LOGMASKED(LOG_DATA, "devsel %02x: not this device\n", m_devsel);
- m_state = STATE_IDLE;
- }
- else if ((m_devsel & 1) == 0)
- {
- LOGMASKED(LOG_DATA, "devsel %02x: write\n", m_devsel);
- m_state = STATE_REGISTER;
- }
- else
- {
- LOGMASKED(LOG_DATA, "devsel %02x: read\n", m_devsel);
- m_state = STATE_DATAOUT;
- }
- break;
+ case STATE_DEVSEL:
+ m_devsel = m_shift;
+
+ if ((m_devsel & 0xfe) != m_slave_address)
+ {
+ LOGMASKED(LOG_DATA, "devsel %02x: not this device\n", m_devsel);
+ m_state = STATE_IDLE;
+ }
+ else if ((m_devsel & 1) == 0)
+ {
+ LOGMASKED(LOG_DATA, "devsel %02x: write\n", m_devsel);
+ m_state = STATE_REGISTER;
+ }
+ else
+ {
+ LOGMASKED(LOG_DATA, "devsel %02x: read\n", m_devsel);
+ m_state = STATE_READSELACK;
+ }
+ break;
- case STATE_REGISTER:
- m_register = m_shift;
+ case STATE_REGISTER:
+ m_register = m_shift;
- LOGMASKED(LOG_DATA, "register %02x\n", m_register);
+ LOGMASKED(LOG_DATA, "register %02x\n", m_register);
- m_state = STATE_DATAIN;
- break;
+ m_state = STATE_DATAIN;
+ break;
- case STATE_DATAIN:
- LOGMASKED(LOG_DATA, "register[ %02x ] <- %02x\n", m_register, m_shift);
+ case STATE_DATAIN:
+ LOGMASKED(LOG_DATA, "register[ %02x ] <- %02x\n", m_register, m_shift);
- switch (m_register)
- {
- case BMU_CHARGE_ESTIMATE:
- m_estimate = m_shift;
+ switch (m_register)
+ {
+ case BMU_CHARGE_ESTIMATE:
+ m_estimate = m_shift;
+ break;
+ }
+
+ m_register++;
break;
}
- m_register++;
- break;
- }
-
- m_bits++;
- }
- else
- {
- if (m_bits == 8)
- {
- m_sdar = 0;
+ if( m_state != STATE_IDLE )
+ {
+ m_sdar = 0 ;
+ }
}
else
{
@@ -157,11 +160,20 @@ WRITE_LINE_MEMBER(acorn_bmu_device::scl_w)
}
break;
+ case STATE_READSELACK:
+ m_bits = 0;
+ m_state = STATE_DATAOUT;
+ break;
+
case STATE_DATAOUT:
if (m_bits < 8)
{
if (m_scl)
{
+ m_bits++;
+ }
+ else
+ {
if (m_bits == 0)
{
switch (m_register)
@@ -194,7 +206,6 @@ WRITE_LINE_MEMBER(acorn_bmu_device::scl_w)
m_sdar = (m_shift >> 7) & 1;
m_shift = (m_shift << 1) & 0xff;
- m_bits++;
}
}
else
@@ -207,18 +218,11 @@ WRITE_LINE_MEMBER(acorn_bmu_device::scl_w)
m_state = STATE_IDLE;
}
- m_bits++;
+ m_bits = 0;
}
else
{
- if (m_bits == 8)
- {
- m_sdar = 1;
- }
- else
- {
- m_bits = 0;
- }
+ m_sdar = 1;
}
}
break;
@@ -226,7 +230,7 @@ WRITE_LINE_MEMBER(acorn_bmu_device::scl_w)
}
}
-WRITE_LINE_MEMBER(acorn_bmu_device::sda_w)
+void acorn_bmu_device::sda_w(int state)
{
state &= 1;
if (m_sdaw != state)
@@ -253,7 +257,7 @@ WRITE_LINE_MEMBER(acorn_bmu_device::sda_w)
}
}
-READ_LINE_MEMBER(acorn_bmu_device::sda_r)
+int acorn_bmu_device::sda_r()
{
int res = m_sdar & 1;