mirror of
https://github.com/holub/mame
synced 2025-10-06 09:00:04 +03:00
s3c44b0_device: converted to devcb2 (nw)
This commit is contained in:
parent
06e4798595
commit
1237836711
@ -31,7 +31,14 @@ INLINE void ATTR_PRINTF(3,4) verboselog( running_machine &machine, int n_level,
|
||||
const device_type S3C44B0 = &device_creator<s3c44b0_device>;
|
||||
|
||||
s3c44b0_device::s3c44b0_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
|
||||
: device_t(mconfig, S3C44B0, "Samsung S3C44B0", tag, owner, clock, "s3c44b0", __FILE__)
|
||||
: device_t(mconfig, S3C44B0, "Samsung S3C44B0", tag, owner, clock, "s3c44b0", __FILE__),
|
||||
m_port_r_cb(*this),
|
||||
m_port_w_cb(*this),
|
||||
m_scl_w_cb(*this),
|
||||
m_sda_r_cb(*this),
|
||||
m_sda_w_cb(*this),
|
||||
m_data_r_cb(*this),
|
||||
m_data_w_cb(*this)
|
||||
{
|
||||
memset(&m_irq, 0, sizeof(s3c44b0_irq_t));
|
||||
memset(m_zdma, 0, sizeof(s3c44b0_dma_t)*2);
|
||||
@ -49,25 +56,6 @@ s3c44b0_device::s3c44b0_device(const machine_config &mconfig, const char *tag, d
|
||||
memset(&m_cpuwrap, 0, sizeof(s3c44b0_cpuwrap_t));
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// device_config_complete - perform any
|
||||
// operations now that the configuration is
|
||||
// complete
|
||||
//-------------------------------------------------
|
||||
|
||||
void s3c44b0_device::device_config_complete()
|
||||
{
|
||||
// inherit a copy of the static data
|
||||
const s3c44b0_interface *intf = reinterpret_cast<const s3c44b0_interface *>(static_config());
|
||||
if (intf != NULL)
|
||||
*static_cast<s3c44b0_interface *>(this) = *intf;
|
||||
|
||||
// or initialize to defaults if none provided
|
||||
else
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
// device_start - device-specific startup
|
||||
//-------------------------------------------------
|
||||
@ -76,13 +64,13 @@ void s3c44b0_device::device_start()
|
||||
{
|
||||
m_cpu = machine().device<cpu_device>("maincpu");
|
||||
|
||||
m_port_r.resolve(gpio_itf.port_r, *this);
|
||||
m_port_w.resolve(gpio_itf.port_w, *this);
|
||||
m_scl_w.resolve(i2c_itf.scl_w, *this);
|
||||
m_sda_r.resolve(i2c_itf.sda_r, *this);
|
||||
m_sda_w.resolve(i2c_itf.sda_w, *this);
|
||||
m_adc_data_r.resolve(adc_itf.data_r, *this);
|
||||
m_i2s_data_w.resolve(i2s_itf.data_w, *this);
|
||||
m_port_r_cb.resolve();
|
||||
m_port_w_cb.resolve();
|
||||
m_scl_w_cb.resolve();
|
||||
m_sda_r_cb.resolve();
|
||||
m_sda_w_cb.resolve();
|
||||
m_data_r_cb.resolve_safe(0);
|
||||
m_data_w_cb.resolve();
|
||||
|
||||
|
||||
for (int i = 0; i < 6; i++) m_pwm.timer[i] = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(s3c44b0_device::pwm_timer_exp),this));
|
||||
@ -1060,20 +1048,20 @@ TIMER_CALLBACK_MEMBER( s3c44b0_device::pwm_timer_exp )
|
||||
|
||||
inline void s3c44b0_device::iface_i2c_scl_w(int state)
|
||||
{
|
||||
if (!m_scl_w.isnull())
|
||||
(m_scl_w)( state);
|
||||
if (!m_scl_w_cb.isnull())
|
||||
(m_scl_w_cb)( state);
|
||||
}
|
||||
|
||||
inline void s3c44b0_device::iface_i2c_sda_w(int state)
|
||||
{
|
||||
if (!m_sda_w.isnull())
|
||||
(m_sda_w)( state);
|
||||
if (!m_sda_w_cb.isnull())
|
||||
(m_sda_w_cb)( state);
|
||||
}
|
||||
|
||||
inline int s3c44b0_device::iface_i2c_sda_r()
|
||||
{
|
||||
if (!m_sda_r.isnull())
|
||||
return (m_sda_r)();
|
||||
if (!m_sda_r_cb.isnull())
|
||||
return (m_sda_r_cb)();
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
@ -1282,16 +1270,16 @@ TIMER_CALLBACK_MEMBER( s3c44b0_device::iic_timer_exp )
|
||||
|
||||
inline UINT32 s3c44b0_device::iface_gpio_port_r(int port)
|
||||
{
|
||||
if (!m_port_r.isnull())
|
||||
return (m_port_r)(port);
|
||||
if (!m_port_r_cb.isnull())
|
||||
return (m_port_r_cb)(port);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline void s3c44b0_device::iface_gpio_port_w(int port, UINT32 data)
|
||||
{
|
||||
if (!m_port_w.isnull())
|
||||
(m_port_w)(port, data);
|
||||
if (!m_port_w_cb.isnull())
|
||||
(m_port_w_cb)(port, data, 0xffff);
|
||||
}
|
||||
|
||||
READ32_MEMBER( s3c44b0_device::gpio_r )
|
||||
@ -1720,8 +1708,8 @@ TIMER_CALLBACK_MEMBER( s3c44b0_device::sio_timer_exp )
|
||||
|
||||
inline void s3c44b0_device::iface_i2s_data_w(address_space &space, int ch, UINT16 data)
|
||||
{
|
||||
if (!m_i2s_data_w.isnull())
|
||||
(m_i2s_data_w)(ch, data, 0);
|
||||
if (!m_data_w_cb.isnull())
|
||||
(m_data_w_cb)(ch, data, 0);
|
||||
}
|
||||
|
||||
void s3c44b0_device::iis_start()
|
||||
|
@ -276,40 +276,6 @@
|
||||
#define S3C44B0_GPIO_PORT_F S3C44B0_GPIO_PORT_F
|
||||
#define S3C44B0_GPIO_PORT_G S3C44B0_GPIO_PORT_G
|
||||
|
||||
/*******************************************************************************
|
||||
TYPE DEFINITIONS
|
||||
*******************************************************************************/
|
||||
|
||||
struct s3c44b0_interface_gpio
|
||||
{
|
||||
devcb_read32 port_r;
|
||||
devcb_write32 port_w;
|
||||
};
|
||||
|
||||
struct s3c44b0_interface_i2c
|
||||
{
|
||||
devcb_write_line scl_w;
|
||||
devcb_read_line sda_r;
|
||||
devcb_write_line sda_w;
|
||||
};
|
||||
|
||||
struct s3c44b0_interface_adc
|
||||
{
|
||||
devcb_read32 data_r;
|
||||
};
|
||||
|
||||
struct s3c44b0_interface_i2s
|
||||
{
|
||||
devcb_write16 data_w;
|
||||
};
|
||||
|
||||
struct s3c44b0_interface
|
||||
{
|
||||
s3c44b0_interface_gpio gpio_itf;
|
||||
s3c44b0_interface_i2c i2c_itf;
|
||||
s3c44b0_interface_adc adc_itf;
|
||||
s3c44b0_interface_i2s i2s_itf;
|
||||
};
|
||||
|
||||
/*******************************************************************************
|
||||
MACROS / CONSTANTS
|
||||
@ -629,12 +595,19 @@ enum
|
||||
S3C44B0_GPIO_PORT_G
|
||||
};
|
||||
|
||||
class s3c44b0_device : public device_t,
|
||||
public s3c44b0_interface
|
||||
class s3c44b0_device : public device_t
|
||||
{
|
||||
public:
|
||||
s3c44b0_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
|
||||
~s3c44b0_device() {}
|
||||
|
||||
template<class _Object> static devcb2_base &set_gpio_port_r_callback(device_t &device, _Object object) { return downcast<s3c44b0_device &>(device).m_port_r_cb.set_callback(object); }
|
||||
template<class _Object> static devcb2_base &set_gpio_port_w_callback(device_t &device, _Object object) { return downcast<s3c44b0_device &>(device).m_port_w_cb.set_callback(object); }
|
||||
template<class _Object> static devcb2_base &set_i2c_scl_w_callback(device_t &device, _Object object) { return downcast<s3c44b0_device &>(device).m_scl_w_cb.set_callback(object); }
|
||||
template<class _Object> static devcb2_base &set_i2c_sda_r_callback(device_t &device, _Object object) { return downcast<s3c44b0_device &>(device).m_sda_r_cb.set_callback(object); }
|
||||
template<class _Object> static devcb2_base &set_i2c_sda_w_callback(device_t &device, _Object object) { return downcast<s3c44b0_device &>(device).m_sda_w_cb.set_callback(object); }
|
||||
template<class _Object> static devcb2_base &set_adc_data_r_callback(device_t &device, _Object object) { return downcast<s3c44b0_device &>(device).m_data_r_cb.set_callback(object); }
|
||||
template<class _Object> static devcb2_base &set_i2s_data_w_callback(device_t &device, _Object object) { return downcast<s3c44b0_device &>(device).m_data_w_cb.set_callback(object); }
|
||||
|
||||
DECLARE_READ32_MEMBER(lcd_r);
|
||||
DECLARE_READ32_MEMBER(clkpow_r);
|
||||
@ -677,7 +650,6 @@ public:
|
||||
|
||||
protected:
|
||||
// device-level overrides
|
||||
virtual void device_config_complete();
|
||||
virtual void device_start();
|
||||
virtual void device_reset();
|
||||
|
||||
@ -800,13 +772,14 @@ private:
|
||||
//s3c44b0_rtc_t m_rtc;
|
||||
s3c44b0_adc_t m_adc;
|
||||
s3c44b0_cpuwrap_t m_cpuwrap;
|
||||
devcb_resolved_read32 m_port_r;
|
||||
devcb_resolved_write32 m_port_w;
|
||||
devcb_resolved_write_line m_scl_w;
|
||||
devcb_resolved_read_line m_sda_r;
|
||||
devcb_resolved_write_line m_sda_w;
|
||||
devcb_resolved_read32 m_adc_data_r;
|
||||
devcb_resolved_write16 m_i2s_data_w;
|
||||
|
||||
devcb2_read32 m_port_r_cb;
|
||||
devcb2_write32 m_port_w_cb;
|
||||
devcb2_write_line m_scl_w_cb;
|
||||
devcb2_read_line m_sda_r_cb;
|
||||
devcb2_write_line m_sda_w_cb;
|
||||
devcb2_read32 m_data_r_cb;
|
||||
devcb2_write16 m_data_w_cb;
|
||||
|
||||
void s3c44b0_postload();
|
||||
};
|
||||
@ -814,12 +787,26 @@ private:
|
||||
extern const device_type S3C44B0;
|
||||
|
||||
|
||||
#define MCFG_S3C44B0_ADD(_tag, _clock, _config) \
|
||||
MCFG_DEVICE_ADD(_tag, S3C44B0, _clock) \
|
||||
MCFG_DEVICE_CONFIG(_config)
|
||||
#define MCFG_S3C44B0_GPIO_PORT_R_CB(_devcb) \
|
||||
devcb = &s3c44b0_device::set_gpio_port_r_callback(*device, DEVCB2_##_devcb);
|
||||
|
||||
#define S3C44B0_INTERFACE(name) \
|
||||
const s3c44b0_interface(name) =
|
||||
#define MCFG_S3C44B0_GPIO_PORT_W_CB(_devcb) \
|
||||
devcb = &s3c44b0_device::set_gpio_port_w_callback(*device, DEVCB2_##_devcb);
|
||||
|
||||
#define MCFG_S3C44B0_I2C_SCL_W_CB(_devcb) \
|
||||
devcb = &s3c44b0_device::set_i2c_scl_w_callback(*device, DEVCB2_##_devcb);
|
||||
|
||||
#define MCFG_S3C44B0_I2C_SDA_R_CB(_devcb) \
|
||||
devcb = &s3c44b0_device::set_i2c_sda_r_callback(*device, DEVCB2_##_devcb);
|
||||
|
||||
#define MCFG_S3C44B0_I2C_SDA_W_CB(_devcb) \
|
||||
devcb = &s3c44b0_device::set_i2c_sda_w_callback(*device, DEVCB2_##_devcb);
|
||||
|
||||
#define MCFG_S3C44B0_ADC_DATA_R_CB(_devcb) \
|
||||
devcb = &s3c44b0_device::set_adc_data_r_callback(*device, DEVCB2_##_devcb);
|
||||
|
||||
#define MCFG_S3C44B0_I2S_DATA_W_CB(_devcb) \
|
||||
devcb = &s3c44b0_device::set_i2s_data_w_callback(*device, DEVCB2_##_devcb);
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -303,18 +303,6 @@ DRIVER_INIT_MEMBER(juicebox_state,juicebox)
|
||||
// do nothing
|
||||
}
|
||||
|
||||
static S3C44B0_INTERFACE( juicebox_s3c44b0_intf )
|
||||
{
|
||||
// GPIO (port read / port write)
|
||||
{ DEVCB_DRIVER_MEMBER32(juicebox_state,s3c44b0_gpio_port_r), DEVCB_DRIVER_MEMBER32(juicebox_state,s3c44b0_gpio_port_w) },
|
||||
// I2C (scl write / sda read / sda write)
|
||||
{ DEVCB_NULL, DEVCB_NULL, DEVCB_NULL },
|
||||
// ADC (data read)
|
||||
{ DEVCB_NULL },
|
||||
// I2S (data write)
|
||||
{ DEVCB_DRIVER_MEMBER16(juicebox_state,s3c44b0_i2s_data_w) }
|
||||
};
|
||||
|
||||
static MACHINE_CONFIG_START( juicebox, juicebox_state )
|
||||
MCFG_CPU_ADD("maincpu", ARM7, 66000000)
|
||||
MCFG_CPU_PROGRAM_MAP(juicebox_map)
|
||||
@ -335,7 +323,10 @@ static MACHINE_CONFIG_START( juicebox, juicebox_state )
|
||||
MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
|
||||
|
||||
|
||||
MCFG_S3C44B0_ADD("s3c44b0", 10000000, juicebox_s3c44b0_intf)
|
||||
MCFG_DEVICE_ADD("s3c44b0", S3C44B0, 10000000)
|
||||
MCFG_S3C44B0_GPIO_PORT_R_CB(READ32(juicebox_state, s3c44b0_gpio_port_r))
|
||||
MCFG_S3C44B0_GPIO_PORT_W_CB(WRITE32(juicebox_state, s3c44b0_gpio_port_w))
|
||||
MCFG_S3C44B0_I2S_DATA_W_CB(WRITE16(juicebox_state, s3c44b0_i2s_data_w))
|
||||
|
||||
MCFG_SMARTMEDIA_ADD("smartmedia")
|
||||
MCFG_SMARTMEDIA_INTERFACE("smartmedia")
|
||||
|
Loading…
Reference in New Issue
Block a user