diff --git a/src/devices/machine/68340.cpp b/src/devices/machine/68340.cpp index e3dbfd81e5d..6110a5345cb 100644 --- a/src/devices/machine/68340.cpp +++ b/src/devices/machine/68340.cpp @@ -86,11 +86,11 @@ WRITE32_MEMBER( m68340_cpu_device::m68340_internal_base_w ) read32_delegate(FUNC(m68340_cpu_device::m68340_internal_sim_cs_r),this), write32_delegate(FUNC(m68340_cpu_device::m68340_internal_sim_cs_w),this)); m_internal->install_readwrite_handler(base + 0x600, base + 0x63f, - READ16_DEVICE_DELEGATE(m_timer1, mc68340_timer_module_device, read), - WRITE16_DEVICE_DELEGATE(m_timer1, mc68340_timer_module_device, write),0xffffffff); + READ16_DEVICE_DELEGATE(m_timer[0], mc68340_timer_module_device, read), + WRITE16_DEVICE_DELEGATE(m_timer[0], mc68340_timer_module_device, write),0xffffffff); m_internal->install_readwrite_handler(base + 0x640, base + 0x67f, - READ16_DEVICE_DELEGATE(m_timer2, mc68340_timer_module_device, read), - WRITE16_DEVICE_DELEGATE(m_timer2, mc68340_timer_module_device, write),0xffffffff); + READ16_DEVICE_DELEGATE(m_timer[1], mc68340_timer_module_device, read), + WRITE16_DEVICE_DELEGATE(m_timer[1], mc68340_timer_module_device, write),0xffffffff); m_internal->install_readwrite_handler(base + 0x700, base + 0x723, read8sm_delegate(FUNC(mc68340_serial_module_device::read), &*m_serial), write8sm_delegate(FUNC(mc68340_serial_module_device::write), &*m_serial),0xffffffff); @@ -119,12 +119,14 @@ void m68340_cpu_device::m68340_internal_map(address_map &map) //------------------------------------------------- // device_add_mconfig - add device configuration //------------------------------------------------- -MACHINE_CONFIG_START(m68340_cpu_device::device_add_mconfig) - MCFG_DEVICE_ADD("serial", MC68340_SERIAL_MODULE, 0) - MCFG_MC68340SER_IRQ_CALLBACK(WRITELINE("serial", mc68340_serial_module_device, irq_w)) - MCFG_DEVICE_ADD("timer1", MC68340_TIMER_MODULE, 0) - MCFG_DEVICE_ADD("timer2", MC68340_TIMER_MODULE, 0) -MACHINE_CONFIG_END + +void m68340_cpu_device::device_add_mconfig(machine_config &config) +{ + MC68340_SERIAL_MODULE(config, m_serial); + m_serial->irq_cb().set(m_serial, FUNC(mc68340_serial_module_device::irq_w)); + MC68340_TIMER_MODULE(config, m_timer[0]); + MC68340_TIMER_MODULE(config, m_timer[1]); +} //************************************************************************** @@ -134,8 +136,7 @@ MACHINE_CONFIG_END m68340_cpu_device::m68340_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : fscpu32_device(mconfig, tag, owner, clock, M68340, 32,32, address_map_constructor(FUNC(m68340_cpu_device::m68340_internal_map), this)) , m_serial(*this, "serial") - , m_timer1(*this, "timer1") - , m_timer2(*this, "timer2") + , m_timer(*this, "timer%u", 1U) , m_clock_mode(0) , m_crystal(0) , m_extal(0) diff --git a/src/devices/machine/68340.h b/src/devices/machine/68340.h index e721b76a189..3a661ff742c 100644 --- a/src/devices/machine/68340.h +++ b/src/devices/machine/68340.h @@ -27,22 +27,22 @@ public: auto pb_in_callback() { return m_pb_in_cb.bind(); } auto pb_out_callback() { return m_pb_out_cb.bind(); } - auto tout1_out_callback() { return m_timer1->m_tout_out_cb.bind(); } - auto tin1_in_callback() { return m_timer1->m_tin_in_cb.bind(); } - auto tgate1_in_callback() { return m_timer1->m_tgate_in_cb.bind(); } - auto tout2_out_callback() { return m_timer2->m_tout_out_cb.bind(); } - auto tin2_in_callback() { return m_timer2->m_tin_in_cb.bind(); } - auto tgate2_in_callback() { return m_timer2->m_tgate_in_cb.bind(); } + auto tout1_out_callback() { return m_timer[0]->m_tout_out_cb.bind(); } + auto tin1_in_callback() { return m_timer[0]->m_tin_in_cb.bind(); } + auto tgate1_in_callback() { return m_timer[0]->m_tgate_in_cb.bind(); } + auto tout2_out_callback() { return m_timer[1]->m_tout_out_cb.bind(); } + auto tin2_in_callback() { return m_timer[1]->m_tin_in_cb.bind(); } + auto tgate2_in_callback() { return m_timer[1]->m_tgate_in_cb.bind(); } uint16_t get_cs(offs_t address); void set_crystal(const XTAL &crystal) { set_crystal(crystal.value()); } // Timer input methods, can be used instead of the corresponding polling MCFG callbacks - DECLARE_WRITE_LINE_MEMBER( tin1_w ) { m_timer1->tin_w(state); } - DECLARE_WRITE_LINE_MEMBER( tgate1_w ){ m_timer1->tgate_w(state); } - DECLARE_WRITE_LINE_MEMBER( tin2_w ) { m_timer2->tin_w(state); } - DECLARE_WRITE_LINE_MEMBER( tgate2_w ){ m_timer2->tgate_w(state); } + DECLARE_WRITE_LINE_MEMBER( tin1_w ) { m_timer[0]->tin_w(state); } + DECLARE_WRITE_LINE_MEMBER( tgate1_w ){ m_timer[0]->tgate_w(state); } + DECLARE_WRITE_LINE_MEMBER( tin2_w ) { m_timer[1]->tin_w(state); } + DECLARE_WRITE_LINE_MEMBER( tgate2_w ){ m_timer[1]->tgate_w(state); } protected: virtual void device_start() override; @@ -51,8 +51,7 @@ protected: private: required_device m_serial; - required_device m_timer1; - required_device m_timer2; + required_device_array m_timer; TIMER_CALLBACK_MEMBER(periodic_interrupt_timer_callback); @@ -61,7 +60,7 @@ private: void do_tick_pit(); int calc_cs(offs_t address) const; - int get_timer_index(mc68340_timer_module_device *timer) { return (timer == m_timer1) ? 0 : 1; } + int get_timer_index(mc68340_timer_module_device *timer) { return (timer == m_timer[0].target()) ? 0 : 1; } int m_currentcs; uint32_t m_clock_mode; diff --git a/src/devices/machine/68340ser.h b/src/devices/machine/68340ser.h index 5dfa58cc492..210edba58aa 100644 --- a/src/devices/machine/68340ser.h +++ b/src/devices/machine/68340ser.h @@ -19,7 +19,7 @@ class mc68340_serial_module_device : public mc68340_duart_device friend class m68340_cpu_device; public: - mc68340_serial_module_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + mc68340_serial_module_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); // device-level overrides virtual void device_start() override; diff --git a/src/devices/machine/68340tmu.h b/src/devices/machine/68340tmu.h index fd641714e24..005f66fba6d 100644 --- a/src/devices/machine/68340tmu.h +++ b/src/devices/machine/68340tmu.h @@ -12,7 +12,7 @@ class mc68340_timer_module_device : public device_t friend class m68340_cpu_device; public: - mc68340_timer_module_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + mc68340_timer_module_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); // device-level overrides virtual void device_start() override;