summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/apricot
diff options
context:
space:
mode:
author Dirk Best <mail@dirk-best.de>2016-07-31 22:29:13 +0200
committer Dirk Best <mail@dirk-best.de>2016-07-31 22:29:56 +0200
commit93093bbf3fdc4f41bc3bbf16849342955cef614d (patch)
tree5ff6d2529f67d8947f42ca800acee5737ce3f26d /src/devices/bus/apricot
parent8b9b6abc5a9744068e9ba8b7e0cd21cb3f299675 (diff)
apricot: add rtc support to keyboard
Diffstat (limited to 'src/devices/bus/apricot')
-rw-r--r--src/devices/bus/apricot/keyboard/hle.cpp87
-rw-r--r--src/devices/bus/apricot/keyboard/hle.h14
2 files changed, 84 insertions, 17 deletions
diff --git a/src/devices/bus/apricot/keyboard/hle.cpp b/src/devices/bus/apricot/keyboard/hle.cpp
index 4fb94c1f1a4..5315cb6e31a 100644
--- a/src/devices/bus/apricot/keyboard/hle.cpp
+++ b/src/devices/bus/apricot/keyboard/hle.cpp
@@ -189,6 +189,15 @@ ioport_constructor apricot_keyboard_hle_device::device_input_ports() const
return INPUT_PORTS_NAME( keyboard );
}
+static MACHINE_CONFIG_FRAGMENT( keyboard_components )
+ MCFG_MSM5832_ADD("rtc", XTAL_32_768kHz)
+MACHINE_CONFIG_END
+
+machine_config_constructor apricot_keyboard_hle_device::device_mconfig_additions() const
+{
+ return MACHINE_CONFIG_NAME( keyboard_components );
+}
+
//**************************************************************************
// LIVE DEVICE
@@ -202,7 +211,9 @@ apricot_keyboard_hle_device::apricot_keyboard_hle_device(const machine_config &m
device_t(mconfig, APRICOT_KEYBOARD_HLE, "Apricot Keyboard (HLE)", tag, owner, clock, "apricotkb_hle", __FILE__),
device_apricot_keyboard_interface(mconfig, *this),
device_buffered_serial_interface(mconfig, *this),
- device_matrix_keyboard_interface(mconfig, *this, "row_0", "row_1", "row_2", "row_3", "row_4", "row_5", "row_6", "row_7", "row_8", "row_9", "row_a", "row_b", "row_c")
+ device_matrix_keyboard_interface(mconfig, *this, "row_0", "row_1", "row_2", "row_3", "row_4", "row_5", "row_6", "row_7", "row_8", "row_9", "row_a", "row_b", "row_c"),
+ m_rtc(*this, "rtc"),
+ m_rtc_index(0)
{
}
@@ -234,19 +245,72 @@ void apricot_keyboard_hle_device::device_reset()
start_processing(attotime::from_hz(7800));
}
+//-------------------------------------------------
+// tra_callback - send bit to host
+//-------------------------------------------------
+
void apricot_keyboard_hle_device::tra_callback()
{
m_host->in_w(transmit_register_get_data_bit());
}
-void apricot_keyboard_hle_device::tra_complete()
-{
- device_buffered_serial_interface::tra_complete();
-}
+//-------------------------------------------------
+// received_byte - handle received byte
+//-------------------------------------------------
void apricot_keyboard_hle_device::received_byte(UINT8 byte)
{
- logerror("received command: %02x\n", byte);
+ if ((byte & 0xf0) == 0xf0)
+ {
+ // rtc data
+ if (m_rtc_index >= 0)
+ {
+ m_rtc->address_w(m_rtc_index--);
+ m_rtc->data_w(machine().driver_data()->generic_space(), 0, byte);
+ }
+ }
+ else
+ {
+ switch (byte)
+ {
+ case CMD_REQ_TIME_AND_DATE:
+ logerror("System requests current time\n");
+
+ // remove pending keys just in case
+ clear_fifo();
+
+ // send time prefix
+ transmit_byte(0xed);
+
+ // make rtc chip ready
+ m_rtc->cs_w(1);
+ m_rtc->read_w(1);
+
+ // send bcd encoded date and time to system
+ for (int i = 12; i >= 0; i--)
+ {
+ m_rtc->address_w(i);
+ transmit_byte(0xf0 | m_rtc->data_r(machine().driver_data()->generic_space(), 0));
+ }
+
+ break;
+
+ case CMD_SET_TIME_AND_DATE:
+ logerror("System requests to set time\n");
+
+ // we start with the year
+ m_rtc_index = 12;
+
+ // make rtc chip ready
+ m_rtc->cs_w(1);
+ m_rtc->write_w(1);
+
+ break;
+
+ default:
+ logerror("Unhandled command: %02x\n", byte);
+ }
+ }
}
//-------------------------------------------------
@@ -269,18 +333,13 @@ void apricot_keyboard_hle_device::key_break(UINT8 row, UINT8 column)
transmit_byte(0x80 | (row << 3) | column);
}
-void apricot_keyboard_hle_device::out_w(int state)
-{
- device_buffered_serial_interface::rx_w(state);
-}
-
//-------------------------------------------------
-// transmit_byte - send a byte or queue it
+// out_w - receive bit from host
//-------------------------------------------------
-void apricot_keyboard_hle_device::transmit_byte(UINT8 byte)
+void apricot_keyboard_hle_device::out_w(int state)
{
- device_buffered_serial_interface::transmit_byte(byte);
+ device_buffered_serial_interface::rx_w(state);
}
//-------------------------------------------------
diff --git a/src/devices/bus/apricot/keyboard/hle.h b/src/devices/bus/apricot/keyboard/hle.h
index a0d8b1b306f..139fa9da1c7 100644
--- a/src/devices/bus/apricot/keyboard/hle.h
+++ b/src/devices/bus/apricot/keyboard/hle.h
@@ -14,6 +14,7 @@
#include "emu.h"
#include "keyboard.h"
#include "machine/keyboard.h"
+#include "machine/msm5832.h"
//**************************************************************************
@@ -24,7 +25,7 @@
class apricot_keyboard_hle_device : public device_t,
public device_apricot_keyboard_interface,
- public device_buffered_serial_interface<8>,
+ public device_buffered_serial_interface<16>,
protected device_matrix_keyboard_interface<13>
{
public:
@@ -37,22 +38,29 @@ public:
protected:
// device_t overrides
virtual ioport_constructor device_input_ports() const override;
+ virtual machine_config_constructor device_mconfig_additions() const override;
virtual void device_start() override;
virtual void device_reset() override;
// device_buffered_serial_interface overrides
virtual void tra_callback() override;
- virtual void tra_complete() override;
virtual void received_byte(UINT8 byte) override;
// device_matrix_keyboard_interface overrides
virtual void key_make(UINT8 row, UINT8 column) override;
virtual void key_break(UINT8 row, UINT8 column) override;
- void transmit_byte(UINT8 byte);
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
private:
+ required_device<msm5832_device> m_rtc;
+
+ enum {
+ CMD_REQ_TIME_AND_DATE = 0xe1,
+ CMD_SET_TIME_AND_DATE = 0xe4
+ };
+
+ int m_rtc_index;
};