summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/machine/clock.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/machine/clock.h')
-rw-r--r--src/devices/machine/clock.h37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/devices/machine/clock.h b/src/devices/machine/clock.h
new file mode 100644
index 00000000000..9f3712327aa
--- /dev/null
+++ b/src/devices/machine/clock.h
@@ -0,0 +1,37 @@
+// license:BSD-3-Clause
+// copyright-holders:smf
+#ifndef __CLOCK_H__
+#define __CLOCK_H__
+
+#pragma once
+
+#include "emu.h"
+
+#define MCFG_CLOCK_SIGNAL_HANDLER(_devcb) \
+ devcb = &clock_device::set_signal_handler(*device, DEVCB_##_devcb);
+
+class clock_device : public device_t
+{
+public:
+ clock_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
+
+ template<class _Object> static devcb_base &set_signal_handler(device_t &device, _Object object) { return downcast<clock_device &>(device).m_signal_handler.set_callback(object); }
+
+protected:
+ virtual void device_start();
+ virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
+ virtual void device_clock_changed();
+
+private:
+ void update_timer();
+ attotime period();
+
+ int m_signal;
+ emu_timer *m_timer;
+
+ devcb_write_line m_signal_handler;
+};
+
+extern const device_type CLOCK;
+
+#endif