diff options
Diffstat (limited to 'src/emu/machine')
-rw-r--r-- | src/emu/machine/adc1038.c | 210 | ||||
-rw-r--r-- | src/emu/machine/adc1038.h | 36 | ||||
-rw-r--r-- | src/emu/machine/adc1213x.c | 314 | ||||
-rw-r--r-- | src/emu/machine/adc1213x.h | 69 |
4 files changed, 262 insertions, 367 deletions
diff --git a/src/emu/machine/adc1038.c b/src/emu/machine/adc1038.c index 05675c3de89..d40614343d3 100644 --- a/src/emu/machine/adc1038.c +++ b/src/emu/machine/adc1038.c @@ -10,185 +10,129 @@ #include "emu.h" #include "adc1038.h" -/*************************************************************************** - TYPE DEFINITIONS -***************************************************************************/ -struct adc1038_state +const device_type ADC1038 = &device_creator<adc1038_device>; + +adc1038_device::adc1038_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) + : device_t(mconfig, ADC1038, "A/D Converters 1038", tag, owner, clock) { - int cycle; - int clk; - int adr; - int data_in; - int data_out; - int adc_data; - int sars; - adc1038_input_read_func input_callback_r; - - int gticlub_hack; -}; +} -/***************************************************************************** - INLINE FUNCTIONS -*****************************************************************************/ +//------------------------------------------------- +// device_config_complete - perform any +// operations now that the configuration is +// complete +//------------------------------------------------- -INLINE adc1038_state *adc1038_get_safe_token( device_t *device ) +void adc1038_device::device_config_complete() { - assert(device != NULL); - assert(device->type() == ADC1038); + // inherit a copy of the static data + const adc1038_interface *intf = reinterpret_cast<const adc1038_interface *>(static_config()); + if (intf != NULL) + *static_cast<adc1038_interface *>(this) = *intf; - return (adc1038_state *)downcast<adc1038_device *>(device)->token(); + // or initialize to defaults if none provided + else + { + input_callback_r = NULL; + } } -INLINE const adc1038_interface *adc1038_get_interface( device_t *device ) +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- + +void adc1038_device::device_start() +{ + m_input_callback_r_func = input_callback_r; + + save_item(NAME(m_cycle)); + save_item(NAME(m_clk)); + save_item(NAME(m_adr)); + save_item(NAME(m_data_in)); + save_item(NAME(m_data_out)); + save_item(NAME(m_adc_data)); + save_item(NAME(m_sars)); +} + +//------------------------------------------------- +// device_reset - device-specific reset +//------------------------------------------------- + +void adc1038_device::device_reset() { - assert(device != NULL); - assert((device->type() == ADC1038)); - return (const adc1038_interface *) device->static_config(); + m_cycle = 0; + m_clk = 0; + m_adr = 0; + m_data_in = 0; + m_data_out = 0; + m_adc_data = 0; + m_sars = 1; } /***************************************************************************** DEVICE HANDLERS *****************************************************************************/ -READ_LINE_DEVICE_HANDLER( adc1038_do_read ) +READ_LINE_MEMBER( adc1038_device::do_read ) { - adc1038_state *adc1038 = adc1038_get_safe_token(device); - - adc1038->data_out = (adc1038->adc_data & 0x200) ? 1 : 0; - adc1038->adc_data <<= 1; + m_data_out = (m_adc_data & 0x200) ? 1 : 0; + m_adc_data <<= 1; //printf("ADC DO\n"); - return adc1038->data_out; + return m_data_out; } -WRITE_LINE_DEVICE_HANDLER( adc1038_di_write ) +WRITE_LINE_MEMBER( adc1038_device::di_write ) { - adc1038_state *adc1038 = adc1038_get_safe_token(device); - - adc1038->data_in = state; + m_data_in = state; } -WRITE_LINE_DEVICE_HANDLER( adc1038_clk_write ) +WRITE_LINE_MEMBER( adc1038_device::clk_write ) { - adc1038_state *adc1038 = adc1038_get_safe_token(device); - // GTI Club doesn't sync on SARS - if (adc1038->gticlub_hack) + if (m_gticlub_hack) { - if (adc1038->clk == 0 && state == 0) + if (m_clk == 0 && state == 0) { - adc1038->cycle = 0; + m_cycle = 0; - /* notice that adc1038->adr is always < 7! */ - adc1038->adc_data = adc1038->input_callback_r(device, adc1038->adr); + /* notice that m_adr is always < 7! */ + m_adc_data = m_input_callback_r_func(this, m_adr); } } if (state == 1) { - //printf("ADC CLK, DI = %d, cycle = %d\n", adc1038->data_in, adc1038->cycle); + //printf("ADC CLK, DI = %d, cycle = %d\n", m_data_in, m_cycle); - if (adc1038->cycle == 0) // A2 + if (m_cycle == 0) // A2 { - adc1038->adr = 0; - adc1038->adr |= (adc1038->data_in << 2); + m_adr = 0; + m_adr |= (m_data_in << 2); } - else if (adc1038->cycle == 1) // A1 + else if (m_cycle == 1) // A1 { - adc1038->adr |= (adc1038->data_in << 1); + m_adr |= (m_data_in << 1); } - else if (adc1038->cycle == 2) // A0 + else if (m_cycle == 2) // A0 { - adc1038->adr |= (adc1038->data_in << 0); + m_adr |= (m_data_in << 0); } - adc1038->cycle++; + m_cycle++; } - adc1038->clk = state; + m_clk = state; } -READ_LINE_DEVICE_HANDLER( adc1038_sars_read ) +READ_LINE_MEMBER( adc1038_device::sars_read ) { - adc1038_state *adc1038 = adc1038_get_safe_token(device); + m_cycle = 0; - adc1038->cycle = 0; + /* notice that m_adr is always < 7! */ + m_adc_data = m_input_callback_r_func(this, m_adr); - /* notice that adc1038->adr is always < 7! */ - adc1038->adc_data = adc1038->input_callback_r(device, adc1038->adr); - - adc1038->sars ^= 1; - return adc1038->sars; -} - - -/***************************************************************************** - DEVICE INTERFACE -*****************************************************************************/ - -static DEVICE_START( adc1038 ) -{ - adc1038_state *adc1038 = adc1038_get_safe_token(device); - const adc1038_interface *intf = adc1038_get_interface(device); - - adc1038->gticlub_hack = intf->gticlub_hack; - adc1038->input_callback_r = intf->input_callback_r; - - device->save_item(NAME(adc1038->cycle)); - device->save_item(NAME(adc1038->clk)); - device->save_item(NAME(adc1038->adr)); - device->save_item(NAME(adc1038->data_in)); - device->save_item(NAME(adc1038->data_out)); - device->save_item(NAME(adc1038->adc_data)); - device->save_item(NAME(adc1038->sars)); -} - -static DEVICE_RESET( adc1038 ) -{ - adc1038_state *adc1038 = adc1038_get_safe_token(device); - - adc1038->cycle = 0; - adc1038->clk = 0; - adc1038->adr = 0; - adc1038->data_in = 0; - adc1038->data_out = 0; - adc1038->adc_data = 0; - adc1038->sars = 1; -} - -const device_type ADC1038 = &device_creator<adc1038_device>; - -adc1038_device::adc1038_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : device_t(mconfig, ADC1038, "A/D Converters 1038", tag, owner, clock) -{ - m_token = global_alloc_clear(adc1038_state); -} - -//------------------------------------------------- -// device_config_complete - perform any -// operations now that the configuration is -// complete -//------------------------------------------------- - -void adc1038_device::device_config_complete() -{ -} - -//------------------------------------------------- -// device_start - device-specific startup -//------------------------------------------------- - -void adc1038_device::device_start() -{ - DEVICE_START_NAME( adc1038 )(this); -} - -//------------------------------------------------- -// device_reset - device-specific reset -//------------------------------------------------- - -void adc1038_device::device_reset() -{ - DEVICE_RESET_NAME( adc1038 )(this); + m_sars ^= 1; + return m_sars; } diff --git a/src/emu/machine/adc1038.h b/src/emu/machine/adc1038.h index 931b323a071..06ab61e3e7a 100644 --- a/src/emu/machine/adc1038.h +++ b/src/emu/machine/adc1038.h @@ -21,7 +21,7 @@ typedef int (*adc1038_input_read_func)(device_t *device, int input); struct adc1038_interface { - int gticlub_hack; + int m_gticlub_hack; adc1038_input_read_func input_callback_r; }; @@ -30,22 +30,35 @@ struct adc1038_interface MACROS / CONSTANTS ***************************************************************************/ -class adc1038_device : public device_t +class adc1038_device : public device_t, + public adc1038_interface { public: adc1038_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - ~adc1038_device() { global_free(m_token); } + ~adc1038_device() {} + + DECLARE_READ_LINE_MEMBER( do_read ); + DECLARE_READ_LINE_MEMBER( sars_read ); + DECLARE_WRITE_LINE_MEMBER( di_write ); + DECLARE_WRITE_LINE_MEMBER( clk_write ); - // access to legacy token - void *token() const { assert(m_token != NULL); return m_token; } protected: // device-level overrides virtual void device_config_complete(); virtual void device_start(); virtual void device_reset(); -private: + + adc1038_input_read_func m_input_callback_r_func; + + private: // internal state - void *m_token; + int m_cycle; + int m_clk; + int m_adr; + int m_data_in; + int m_data_out; + int m_adc_data; + int m_sars; }; extern const device_type ADC1038; @@ -56,13 +69,4 @@ extern const device_type ADC1038; MCFG_DEVICE_CONFIG(_config) -/*************************************************************************** - DEVICE I/O FUNCTIONS -***************************************************************************/ - -extern READ_LINE_DEVICE_HANDLER( adc1038_do_read ); -extern READ_LINE_DEVICE_HANDLER( adc1038_sars_read ); -extern WRITE_LINE_DEVICE_HANDLER( adc1038_di_write ); -extern WRITE_LINE_DEVICE_HANDLER( adc1038_clk_write ); - #endif /* __ADC1038_H__ */ diff --git a/src/emu/machine/adc1213x.c b/src/emu/machine/adc1213x.c index a87ea7aa991..45476999023 100644 --- a/src/emu/machine/adc1213x.c +++ b/src/emu/machine/adc1213x.c @@ -20,25 +20,6 @@ TYPE DEFINITIONS ***************************************************************************/ -struct adc12138_state -{ - adc1213x_input_convert_func input_callback_r; - - int cycle; - int data_out; - int data_in; - int conv_mode; - int auto_cal; - int auto_zero; - int acq_time; - int data_out_sign; - int mode; - int input_shift_reg; - int output_shift_reg; - int end_conv; -}; - - #define ADC1213X_CONV_MODE_12_MSB_FIRST 0 #define ADC1213X_CONV_MODE_16_MSB_FIRST 1 #define ADC1213X_CONV_MODE_12_LSB_FIRST 2 @@ -49,46 +30,111 @@ struct adc12138_state #define ADC1213X_ACQUISITION_TIME_18_CCLK 2 #define ADC1213X_ACQUISITION_TIME_34_CCLK 3 -/*************************************************************************** - INLINE FUNCTIONS -***************************************************************************/ -INLINE adc12138_state *get_safe_token(device_t *device) + +const device_type ADC12130 = &device_creator<adc12130_device>; + +adc12130_device::adc12130_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) + : adc12138_device(mconfig, ADC12130, "A/D Converter 12130", tag, owner, clock) +{ +} + + +const device_type ADC12132 = &device_creator<adc12132_device>; + +adc12132_device::adc12132_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) + : adc12138_device(mconfig, ADC12132, "A/D Converter 12132", tag, owner, clock) +{ +} + + +const device_type ADC12138 = &device_creator<adc12138_device>; + +adc12138_device::adc12138_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) + : device_t(mconfig, ADC12138, "A/D Converter 12138", tag, owner, clock) +{ +} +adc12138_device::adc12138_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock) + : device_t(mconfig, type, name, tag, owner, clock) +{ +} + +//------------------------------------------------- +// device_config_complete - perform any +// operations now that the configuration is +// complete +//------------------------------------------------- + +void adc12138_device::device_config_complete() { - assert(device != NULL); - assert((device->type() == ADC12130) || (device->type() == ADC12132) || (device->type() == ADC12138)); - return (adc12138_state *)downcast<adc12138_device *>(device)->token(); + // inherit a copy of the static data + const adc12138_interface *intf = reinterpret_cast<const adc12138_interface *>(static_config()); + if (intf != NULL) + *static_cast<adc12138_interface *>(this) = *intf; + + // or initialize to defaults if none provided + else + { + input_callback_r = NULL; + } } -INLINE const adc12138_interface *get_interface(device_t *device) +//------------------------------------------------- +// device_start - device-specific startup +//------------------------------------------------- + +void adc12138_device::device_start() { - assert(device != NULL); - assert((device->type() == ADC12130) || (device->type() == ADC12132) || (device->type() == ADC12138)); - return (const adc12138_interface *) device->static_config(); + /* resolve callbacks */ + m_input_callback_r_func = input_callback_r; + + /* register for state saving */ + save_item(NAME(m_cycle)); + save_item(NAME(m_data_out)); + save_item(NAME(m_data_in)); + save_item(NAME(m_conv_mode)); + save_item(NAME(m_auto_cal)); + save_item(NAME(m_auto_zero)); + save_item(NAME(m_acq_time)); + save_item(NAME(m_data_out_sign)); + save_item(NAME(m_mode)); + save_item(NAME(m_input_shift_reg)); + save_item(NAME(m_output_shift_reg)); + save_item(NAME(m_end_conv)); } +//------------------------------------------------- +// device_reset - device-specific reset +//------------------------------------------------- + +void adc12138_device::device_reset() +{ + m_conv_mode = ADC1213X_CONV_MODE_12_MSB_FIRST; + m_data_out_sign = 1; + m_auto_cal = 0; + m_auto_zero = 0; + m_acq_time = ADC1213X_ACQUISITION_TIME_10_CCLK; +} /*************************************************************************** IMPLEMENTATION ***************************************************************************/ /*------------------------------------------------- - adc1213x_di_w + di_w -------------------------------------------------*/ -WRITE8_DEVICE_HANDLER( adc1213x_di_w ) +WRITE8_MEMBER( adc12138_device::di_w ) { - adc12138_state *adc1213x = get_safe_token(device); - adc1213x->data_in = data & 1; + m_data_in = data & 1; } /*------------------------------------------------- - adc1213x_convert + convert -------------------------------------------------*/ -static void adc1213x_convert(device_t *device, int channel, int bits16, int lsbfirst) +void adc12138_device::convert(int channel, int bits16, int lsbfirst) { - adc12138_state *adc1213x = get_safe_token(device); int i; int bits; int input_value; @@ -104,42 +150,42 @@ static void adc1213x_convert(device_t *device, int channel, int bits16, int lsbf { case 0x8: // H L L L - CH0 (single-ended) { - input = adc1213x->input_callback_r(device, 0); + input = m_input_callback_r_func(this, 0); break; } case 0xc: // H H L L - CH1 (single-ended) { - input = adc1213x->input_callback_r(device, 1); + input = m_input_callback_r_func(this, 1); break; } case 0x9: // H L L H - CH2 (single-ended) { - input = adc1213x->input_callback_r(device, 2); + input = m_input_callback_r_func(this, 2); break; } case 0xd: // H H L H - CH3 (single-ended) { - input = adc1213x->input_callback_r(device, 3); + input = m_input_callback_r_func(this, 3); break; } case 0xa: // H L H L - CH4 (single-ended) { - input = adc1213x->input_callback_r(device, 4); + input = m_input_callback_r_func(this, 4); break; } case 0xe: // H H H L - CH5 (single-ended) { - input = adc1213x->input_callback_r(device, 5); + input = m_input_callback_r_func(this, 5); break; } case 0xb: // H L H H - CH6 (single-ended) { - input = adc1213x->input_callback_r(device, 6); + input = m_input_callback_r_func(this, 6); break; } case 0xf: // H H H H - CH7 (single-ended) { - input = adc1213x->input_callback_r(device, 7); + input = m_input_callback_r_func(this, 7); break; } default: @@ -153,62 +199,60 @@ static void adc1213x_convert(device_t *device, int channel, int bits16, int lsbf bits = 12; // sign-extend if needed - if (adc1213x->data_out_sign) + if (m_data_out_sign) { input_value = input_value | ((input_value & 0x800) << 1); bits++; } - adc1213x->output_shift_reg = 0; + m_output_shift_reg = 0; for (i=0; i < bits; i++) { if (input_value & (1 << ((bits-1) - i))) { - adc1213x->output_shift_reg |= (1 << i); + m_output_shift_reg |= (1 << i); } } - adc1213x->data_out = adc1213x->output_shift_reg & 1; - adc1213x->output_shift_reg >>= 1; + m_data_out = m_output_shift_reg & 1; + m_output_shift_reg >>= 1; } /*------------------------------------------------- - adc1213x_cs_w + cs_w -------------------------------------------------*/ -WRITE8_DEVICE_HANDLER( adc1213x_cs_w ) +WRITE8_MEMBER( adc12138_device::cs_w ) { - adc12138_state *adc1213x = get_safe_token(device); - if (data) { //printf("ADC: CS\n"); - if (adc1213x->cycle >= 7) + if (m_cycle >= 7) { - int mode = adc1213x->input_shift_reg >> (adc1213x->cycle - 8); + int mode = m_input_shift_reg >> (m_cycle - 8); switch (mode & 0xf) { case 0x0: // X X X X L L L L - 12 or 13 Bit MSB First conversion { - adc1213x_convert(device, (mode >> 4) & 0xf, 0, 0); + convert((mode >> 4) & 0xf, 0, 0); break; } case 0x1: // X X X X L L L H - 16 or 17 Bit MSB First conversion { - adc1213x_convert(device, (mode >> 4) & 0xf, 1, 0); + convert((mode >> 4) & 0xf, 1, 0); break; } case 0x4: // X X X X L H L L - 12 or 13 Bit LSB First conversion { - adc1213x_convert(device, (mode >> 4) & 0xf, 0, 1); + convert((mode >> 4) & 0xf, 0, 1); break; } case 0x5: // X X X X L H L H - 16 or 17 Bit LSB First conversion { - adc1213x_convert(device, (mode >> 4) & 0xf, 1, 1); + convert((mode >> 4) & 0xf, 1, 1); break; } @@ -218,19 +262,19 @@ WRITE8_DEVICE_HANDLER( adc1213x_cs_w ) { case 0x08: // L L L L H L L L - Auto cal { - adc1213x->auto_cal = 1; + m_auto_cal = 1; break; } case 0x0e: // L L L L H H H L - Acquisition time 6 CCLK cycles { - adc1213x->acq_time = ADC1213X_ACQUISITION_TIME_6_CCLK; + m_acq_time = ADC1213X_ACQUISITION_TIME_6_CCLK; break; } case 0x8d: // H L L L H H L H - Data out with sign { - adc1213x->data_out_sign = 1; + m_data_out_sign = 1; break; } @@ -249,163 +293,57 @@ WRITE8_DEVICE_HANDLER( adc1213x_cs_w ) } } - adc1213x->cycle = 0; - adc1213x->input_shift_reg = 0; + m_cycle = 0; + m_input_shift_reg = 0; - adc1213x->end_conv = 0; + m_end_conv = 0; } } /*------------------------------------------------- - adc1213x_sclk_w + sclk_w -------------------------------------------------*/ -WRITE8_DEVICE_HANDLER( adc1213x_sclk_w ) +WRITE8_MEMBER( adc12138_device::sclk_w ) { - adc12138_state *adc1213x = get_safe_token(device); - if (data) { //printf("ADC: cycle %d, DI = %d\n", adc1213x->cycle, adc1213x->data_in); - adc1213x->input_shift_reg <<= 1; - adc1213x->input_shift_reg |= adc1213x->data_in; + m_input_shift_reg <<= 1; + m_input_shift_reg |= m_data_in; - adc1213x->data_out = adc1213x->output_shift_reg & 1; - adc1213x->output_shift_reg >>= 1; + m_data_out = m_output_shift_reg & 1; + m_output_shift_reg >>= 1; - adc1213x->cycle++; + m_cycle++; } } /*------------------------------------------------- - adc1213x_conv_w + conv_w -------------------------------------------------*/ -WRITE8_DEVICE_HANDLER( adc1213x_conv_w ) +WRITE8_MEMBER( adc12138_device::conv_w ) { - adc12138_state *adc1213x = get_safe_token(device); - adc1213x->end_conv = 1; + m_end_conv = 1; } /*------------------------------------------------- - adc1213x_do_r + do_r -------------------------------------------------*/ -READ8_DEVICE_HANDLER( adc1213x_do_r ) +READ8_MEMBER( adc12138_device::do_r ) { - adc12138_state *adc1213x = get_safe_token(device); - //printf("ADC: DO\n"); - return adc1213x->data_out; -} - -/*------------------------------------------------- - adc1213x_eoc_r --------------------------------------------------*/ - -READ8_DEVICE_HANDLER( adc1213x_eoc_r ) -{ - adc12138_state *adc1213x = get_safe_token(device); - return adc1213x->end_conv; + return m_data_out; } /*------------------------------------------------- - DEVICE_START( adc1213x ) + eoc_r -------------------------------------------------*/ -static DEVICE_START( adc12138 ) -{ - adc12138_state *adc1213x = get_safe_token(device); - const adc12138_interface *intf = get_interface(device); - - /* resolve callbacks */ - adc1213x->input_callback_r = intf->input_callback_r; - - /* register for state saving */ - device->save_item(NAME(adc1213x->cycle)); - device->save_item(NAME(adc1213x->data_out)); - device->save_item(NAME(adc1213x->data_in)); - device->save_item(NAME(adc1213x->conv_mode)); - device->save_item(NAME(adc1213x->auto_cal)); - device->save_item(NAME(adc1213x->auto_zero)); - device->save_item(NAME(adc1213x->acq_time)); - device->save_item(NAME(adc1213x->data_out_sign)); - device->save_item(NAME(adc1213x->mode)); - device->save_item(NAME(adc1213x->input_shift_reg)); - device->save_item(NAME(adc1213x->output_shift_reg)); - device->save_item(NAME(adc1213x->end_conv)); -} - - -/*------------------------------------------------- - DEVICE_RESET( adc1213x ) --------------------------------------------------*/ - -static DEVICE_RESET( adc12138 ) -{ - adc12138_state *adc1213x = get_safe_token(device); - - adc1213x->conv_mode = ADC1213X_CONV_MODE_12_MSB_FIRST; - adc1213x->data_out_sign = 1; - adc1213x->auto_cal = 0; - adc1213x->auto_zero = 0; - adc1213x->acq_time = ADC1213X_ACQUISITION_TIME_10_CCLK; -} - -const device_type ADC12130 = &device_creator<adc12130_device>; - -adc12130_device::adc12130_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : adc12138_device(mconfig, ADC12130, "A/D Converter 12130", tag, owner, clock) -{ -} - - -const device_type ADC12132 = &device_creator<adc12132_device>; - -adc12132_device::adc12132_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : adc12138_device(mconfig, ADC12132, "A/D Converter 12132", tag, owner, clock) -{ -} - - -const device_type ADC12138 = &device_creator<adc12138_device>; - -adc12138_device::adc12138_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : device_t(mconfig, ADC12138, "A/D Converter 12138", tag, owner, clock) -{ - m_token = global_alloc_clear(adc12138_state); -} -adc12138_device::adc12138_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock) - : device_t(mconfig, type, name, tag, owner, clock) -{ - m_token = global_alloc_clear(adc12138_state); -} - -//------------------------------------------------- -// device_config_complete - perform any -// operations now that the configuration is -// complete -//------------------------------------------------- - -void adc12138_device::device_config_complete() -{ -} - -//------------------------------------------------- -// device_start - device-specific startup -//------------------------------------------------- - -void adc12138_device::device_start() -{ - DEVICE_START_NAME( adc12138 )(this); -} - -//------------------------------------------------- -// device_reset - device-specific reset -//------------------------------------------------- - -void adc12138_device::device_reset() +READ8_MEMBER( adc12138_device::eoc_r ) { - DEVICE_RESET_NAME( adc12138 )(this); + return m_end_conv; } diff --git a/src/emu/machine/adc1213x.h b/src/emu/machine/adc1213x.h index bb12cddaca7..aa2209884fa 100644 --- a/src/emu/machine/adc1213x.h +++ b/src/emu/machine/adc1213x.h @@ -10,30 +10,61 @@ #ifndef __ADC1213X_H__ #define __ADC1213X_H__ -#include "devlegcy.h" +/*************************************************************************** + TYPE DEFINITIONS +***************************************************************************/ + +typedef double (*adc1213x_input_convert_func)(device_t *device, UINT8 input); + +struct adc12138_interface +{ + adc1213x_input_convert_func input_callback_r; +}; /*************************************************************************** MACROS / CONSTANTS ***************************************************************************/ -class adc12138_device : public device_t +class adc12138_device : public device_t, + public adc12138_interface { public: adc12138_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); adc12138_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock); - ~adc12138_device() { global_free(m_token); } - - // access to legacy token - void *token() const { assert(m_token != NULL); return m_token; } + ~adc12138_device() {} + + DECLARE_WRITE8_MEMBER( di_w ); + DECLARE_WRITE8_MEMBER( cs_w ); + DECLARE_WRITE8_MEMBER( sclk_w ); + DECLARE_WRITE8_MEMBER( conv_w ); + DECLARE_READ8_MEMBER( do_r ); + DECLARE_READ8_MEMBER( eoc_r ); + protected: // device-level overrides virtual void device_config_complete(); virtual void device_start(); virtual void device_reset(); -private: + + void convert(int channel, int bits16, int lsbfirst); + + adc1213x_input_convert_func m_input_callback_r_func; + + private: // internal state - void *m_token; + int m_cycle; + int m_data_out; + int m_data_in; + int m_conv_mode; + int m_auto_cal; + int m_auto_zero; + int m_acq_time; + int m_data_out_sign; + int m_mode; + int m_input_shift_reg; + int m_output_shift_reg; + int m_end_conv; }; extern const device_type ADC12138; @@ -67,26 +98,4 @@ extern const device_type ADC12132; MCFG_DEVICE_CONFIG(_config) -/*************************************************************************** - TYPE DEFINITIONS -***************************************************************************/ - -typedef double (*adc1213x_input_convert_func)(device_t *device, UINT8 input); - -struct adc12138_interface -{ - adc1213x_input_convert_func input_callback_r; -}; - -/*************************************************************************** - PROTOTYPES -***************************************************************************/ - -extern DECLARE_WRITE8_DEVICE_HANDLER( adc1213x_di_w ); -extern DECLARE_WRITE8_DEVICE_HANDLER( adc1213x_cs_w ); -extern DECLARE_WRITE8_DEVICE_HANDLER( adc1213x_sclk_w ); -extern DECLARE_WRITE8_DEVICE_HANDLER( adc1213x_conv_w ); -extern DECLARE_READ8_DEVICE_HANDLER( adc1213x_do_r ); -extern DECLARE_READ8_DEVICE_HANDLER( adc1213x_eoc_r ); - #endif /* __ADC1213X_H__ */ |