mirror of
https://github.com/holub/mame
synced 2025-05-29 00:53:09 +03:00
Fixed problem with derived devices in devtempl.h. Fixed save state issues with adc083x.c and adc1213x.c. Changed adc083x.c & adc1213x.c to use derived devices for various types of converters.
This commit is contained in:
parent
81c71d5528
commit
3ce62e7831
@ -243,7 +243,7 @@ DEVICE_GET_INFO( DEVTEMPLATE_DERIVED_ID(,) )
|
||||
|
||||
/* --- the following bits of info are returned as pointers to data or functions --- */
|
||||
#if ((DEVTEMPLATE_DERIVED_FEATURES) & DT_HAS_START)
|
||||
case DEVINFO_FCT_START: info->start = DEVTEMPLATE_ID(device_start_,); break;
|
||||
case DEVINFO_FCT_START: info->start = DEVTEMPLATE_DERIVED_ID(device_start_,); break;
|
||||
#endif
|
||||
#if ((DEVTEMPLATE_DERIVED_FEATURES) & DT_HAS_RESET)
|
||||
case DEVINFO_FCT_RESET: info->reset = DEVTEMPLATE_DERIVED_ID(device_reset_,); break;
|
||||
|
@ -47,13 +47,12 @@ enum
|
||||
TYPE DEFINITIONS
|
||||
***************************************************************************/
|
||||
|
||||
typedef struct _adc083x_state adc083x_state;
|
||||
struct _adc083x_state
|
||||
typedef struct _adc0831_state adc0831_state;
|
||||
struct _adc0831_state
|
||||
{
|
||||
int type;
|
||||
|
||||
adc083x_input_convert_func input_callback_r;
|
||||
|
||||
int type;
|
||||
INT32 cs;
|
||||
INT32 clk;
|
||||
INT32 di;
|
||||
@ -76,19 +75,19 @@ struct _adc083x_state
|
||||
INLINE FUNCTIONS
|
||||
***************************************************************************/
|
||||
|
||||
INLINE adc083x_state *get_safe_token(const device_config *device)
|
||||
INLINE adc0831_state *get_safe_token(const device_config *device)
|
||||
{
|
||||
assert(device != NULL);
|
||||
assert(device->token != NULL);
|
||||
assert((device->type == ADC083X));
|
||||
return (adc083x_state *)device->token;
|
||||
assert((device->type == ADC0831) || (device->type == ADC0832) || (device->type == ADC0834) || (device->type == ADC0838));
|
||||
return (adc0831_state *)device->token;
|
||||
}
|
||||
|
||||
INLINE const adc083x_interface *get_interface(const device_config *device)
|
||||
INLINE const adc0831_interface *get_interface(const device_config *device)
|
||||
{
|
||||
assert(device != NULL);
|
||||
assert((device->type == ADC083X));
|
||||
return (const adc083x_interface *) device->static_config;
|
||||
assert((device->type == ADC0831) || (device->type == ADC0832) || (device->type == ADC0834) || (device->type == ADC0838));
|
||||
return (const adc0831_interface *) device->static_config;
|
||||
}
|
||||
|
||||
|
||||
@ -102,7 +101,7 @@ INLINE const adc083x_interface *get_interface(const device_config *device)
|
||||
|
||||
WRITE8_DEVICE_HANDLER( adc083x_cs_write )
|
||||
{
|
||||
adc083x_state *adc083x = get_safe_token(device);
|
||||
adc0831_state *adc083x = get_safe_token(device);
|
||||
|
||||
if (adc083x->cs != data)
|
||||
{
|
||||
@ -112,7 +111,7 @@ WRITE8_DEVICE_HANDLER( adc083x_cs_write )
|
||||
if (adc083x->cs == 0 && data != 0)
|
||||
{
|
||||
adc083x->state = STATE_IDLE;
|
||||
if (adc083x->type == ADC0834 || adc083x->type == ADC0838)
|
||||
if (adc083x->type == TYPE_ADC0834 || adc083x->type == TYPE_ADC0838)
|
||||
{
|
||||
adc083x->sars = 1;
|
||||
}
|
||||
@ -120,7 +119,7 @@ WRITE8_DEVICE_HANDLER( adc083x_cs_write )
|
||||
}
|
||||
if (adc083x->cs != 0 && data == 0)
|
||||
{
|
||||
if (adc083x->type == ADC0831)
|
||||
if (adc083x->type == TYPE_ADC0831)
|
||||
{
|
||||
adc083x->state = STATE_MUX_SETTLE;
|
||||
}
|
||||
@ -129,7 +128,7 @@ WRITE8_DEVICE_HANDLER( adc083x_cs_write )
|
||||
adc083x->state = STATE_WAIT_FOR_START;
|
||||
}
|
||||
|
||||
if (adc083x->type == ADC0834 || adc083x->type == ADC0838)
|
||||
if (adc083x->type == TYPE_ADC0834 || adc083x->type == TYPE_ADC0838)
|
||||
{
|
||||
adc083x->sars = 1;
|
||||
}
|
||||
@ -145,7 +144,7 @@ WRITE8_DEVICE_HANDLER( adc083x_cs_write )
|
||||
|
||||
static UINT8 adc083x_conversion( const device_config *device )
|
||||
{
|
||||
adc083x_state *adc083x = get_safe_token(device);
|
||||
adc0831_state *adc083x = get_safe_token(device);
|
||||
int result;
|
||||
int positive_channel = ADC083X_AGND;
|
||||
int negative_channel = ADC083X_AGND;
|
||||
@ -156,11 +155,11 @@ static UINT8 adc083x_conversion( const device_config *device )
|
||||
|
||||
switch (adc083x->type)
|
||||
{
|
||||
case ADC0831:
|
||||
case TYPE_ADC0831:
|
||||
positive_channel = ADC083X_CH0;
|
||||
negative_channel = ADC083X_CH1;
|
||||
break;
|
||||
case ADC0832:
|
||||
case TYPE_ADC0832:
|
||||
positive_channel = ADC083X_CH0 + adc083x->odd;
|
||||
if (adc083x->sgl == 0)
|
||||
{
|
||||
@ -171,7 +170,7 @@ static UINT8 adc083x_conversion( const device_config *device )
|
||||
negative_channel = ADC083X_AGND;
|
||||
}
|
||||
break;
|
||||
case ADC0834:
|
||||
case TYPE_ADC0834:
|
||||
positive_channel = ADC083X_CH0 + adc083x->odd + (adc083x->sel1 * 2);
|
||||
if (adc083x->sgl == 0)
|
||||
{
|
||||
@ -182,7 +181,7 @@ static UINT8 adc083x_conversion( const device_config *device )
|
||||
negative_channel = ADC083X_AGND;
|
||||
}
|
||||
break;
|
||||
case ADC0838:
|
||||
case TYPE_ADC0838:
|
||||
positive_channel = ADC083X_CH0 + adc083x->odd + (adc083x->sel0 * 2) + (adc083x->sel1 * 4);
|
||||
if (adc083x->sgl == 0)
|
||||
{
|
||||
@ -224,7 +223,7 @@ static UINT8 adc083x_conversion( const device_config *device )
|
||||
|
||||
WRITE8_DEVICE_HANDLER( adc083x_clk_write )
|
||||
{
|
||||
adc083x_state *adc083x = get_safe_token(device);
|
||||
adc0831_state *adc083x = get_safe_token(device);
|
||||
|
||||
if (adc083x->clk != data)
|
||||
{
|
||||
@ -294,7 +293,7 @@ WRITE8_DEVICE_HANDLER( adc083x_clk_write )
|
||||
break;
|
||||
case STATE_WAIT_FOR_SE:
|
||||
adc083x->sars = 0;
|
||||
if (adc083x->type == ADC0838 && adc083x->se != 0)
|
||||
if (adc083x->type == TYPE_ADC0838 && adc083x->se != 0)
|
||||
{
|
||||
verboselog(device->machine, 1, "adc083x %s not se\n", device->tag);
|
||||
}
|
||||
@ -316,7 +315,7 @@ WRITE8_DEVICE_HANDLER( adc083x_clk_write )
|
||||
adc083x->output = adc083x_conversion(device);
|
||||
adc083x->state = STATE_OUTPUT_MSB_FIRST;
|
||||
adc083x->bit = 7;
|
||||
if (adc083x->type == ADC0834 || adc083x->type == ADC0838)
|
||||
if (adc083x->type == TYPE_ADC0834 || adc083x->type == TYPE_ADC0838)
|
||||
{
|
||||
adc083x->sars = 1;
|
||||
}
|
||||
@ -328,7 +327,7 @@ WRITE8_DEVICE_HANDLER( adc083x_clk_write )
|
||||
adc083x->bit--;
|
||||
if (adc083x->bit < 0)
|
||||
{
|
||||
if (adc083x->type == ADC0831)
|
||||
if (adc083x->type == TYPE_ADC0831)
|
||||
{
|
||||
adc083x->state = STATE_FINISHED;
|
||||
}
|
||||
@ -364,7 +363,7 @@ WRITE8_DEVICE_HANDLER( adc083x_clk_write )
|
||||
|
||||
WRITE8_DEVICE_HANDLER( adc083x_di_write )
|
||||
{
|
||||
adc083x_state *adc083x = get_safe_token(device);
|
||||
adc0831_state *adc083x = get_safe_token(device);
|
||||
|
||||
if (adc083x->di != data)
|
||||
{
|
||||
@ -380,7 +379,7 @@ WRITE8_DEVICE_HANDLER( adc083x_di_write )
|
||||
|
||||
WRITE8_DEVICE_HANDLER( adc083x_se_write )
|
||||
{
|
||||
adc083x_state *adc083x = get_safe_token(device);
|
||||
adc0831_state *adc083x = get_safe_token(device);
|
||||
|
||||
if (adc083x->se != data)
|
||||
{
|
||||
@ -396,7 +395,7 @@ WRITE8_DEVICE_HANDLER( adc083x_se_write )
|
||||
|
||||
READ8_DEVICE_HANDLER( adc083x_sars_read )
|
||||
{
|
||||
adc083x_state *adc083x = get_safe_token(device);
|
||||
adc0831_state *adc083x = get_safe_token(device);
|
||||
|
||||
verboselog(device->machine, 1, "adc083x_sars_read( %s ) %d\n", device->tag, adc083x->sars);
|
||||
return adc083x->sars;
|
||||
@ -408,7 +407,7 @@ READ8_DEVICE_HANDLER( adc083x_sars_read )
|
||||
|
||||
READ8_DEVICE_HANDLER( adc083x_do_read )
|
||||
{
|
||||
adc083x_state *adc083x = get_safe_token(device);
|
||||
adc0831_state *adc083x = get_safe_token(device);
|
||||
|
||||
verboselog(device->machine, 1, "adc083x_sars_read( %s ) %d\n", device->tag, adc083x->_do);
|
||||
return adc083x->_do;
|
||||
@ -419,30 +418,26 @@ READ8_DEVICE_HANDLER( adc083x_do_read )
|
||||
DEVICE_START( adc083x )
|
||||
-------------------------------------------------*/
|
||||
|
||||
static DEVICE_START( adc083x )
|
||||
static void adc083x_common_start( const device_config *device )
|
||||
{
|
||||
adc083x_state *adc083x = get_safe_token(device);
|
||||
const adc083x_interface *intf = get_interface(device);
|
||||
adc0831_state *adc083x = get_safe_token(device);
|
||||
const adc0831_interface *intf = get_interface(device);
|
||||
|
||||
/* validate configuration */
|
||||
assert(intf->type >= ADC0831 && intf->type < MAX_ADC083X_TYPES);
|
||||
|
||||
adc083x->type = intf->type;
|
||||
switch (adc083x->type)
|
||||
{
|
||||
case ADC0831:
|
||||
case TYPE_ADC0831:
|
||||
adc083x->sars = 1;
|
||||
adc083x->mux_bits = 0;
|
||||
break;
|
||||
case ADC0832:
|
||||
case TYPE_ADC0832:
|
||||
adc083x->sars = 1;
|
||||
adc083x->mux_bits = 2;
|
||||
break;
|
||||
case ADC0834:
|
||||
case TYPE_ADC0834:
|
||||
adc083x->sars = 0;
|
||||
adc083x->mux_bits = 3;
|
||||
break;
|
||||
case ADC0838:
|
||||
case TYPE_ADC0838:
|
||||
adc083x->sars = 0;
|
||||
adc083x->mux_bits = 4;
|
||||
break;
|
||||
@ -452,29 +447,61 @@ static DEVICE_START( adc083x )
|
||||
adc083x->input_callback_r = intf->input_callback_r;
|
||||
|
||||
/* register for state saving */
|
||||
state_save_register_global(device->machine, adc083x->cs);
|
||||
state_save_register_global(device->machine, adc083x->clk);
|
||||
state_save_register_global(device->machine, adc083x->di);
|
||||
state_save_register_global(device->machine, adc083x->se);
|
||||
state_save_register_global(device->machine, adc083x->sars);
|
||||
state_save_register_global(device->machine, adc083x->_do);
|
||||
state_save_register_global(device->machine, adc083x->sgl);
|
||||
state_save_register_global(device->machine, adc083x->odd);
|
||||
state_save_register_global(device->machine, adc083x->sel1);
|
||||
state_save_register_global(device->machine, adc083x->sel0);
|
||||
state_save_register_global(device->machine, adc083x->state);
|
||||
state_save_register_global(device->machine, adc083x->bit);
|
||||
state_save_register_global(device->machine, adc083x->output);
|
||||
state_save_register_global(device->machine, adc083x->mux_bits);
|
||||
state_save_register_device_item(device, 0, adc083x->cs);
|
||||
state_save_register_device_item(device, 0, adc083x->clk);
|
||||
state_save_register_device_item(device, 0, adc083x->di);
|
||||
state_save_register_device_item(device, 0, adc083x->se);
|
||||
state_save_register_device_item(device, 0, adc083x->sars);
|
||||
state_save_register_device_item(device, 0, adc083x->_do);
|
||||
state_save_register_device_item(device, 0, adc083x->sgl);
|
||||
state_save_register_device_item(device, 0, adc083x->odd);
|
||||
state_save_register_device_item(device, 0, adc083x->sel1);
|
||||
state_save_register_device_item(device, 0, adc083x->sel0);
|
||||
state_save_register_device_item(device, 0, adc083x->state);
|
||||
state_save_register_device_item(device, 0, adc083x->bit);
|
||||
state_save_register_device_item(device, 0, adc083x->output);
|
||||
state_save_register_device_item(device, 0, adc083x->mux_bits);
|
||||
}
|
||||
|
||||
static DEVICE_START( adc0831 )
|
||||
{
|
||||
adc0831_state *adc083x = get_safe_token(device);
|
||||
|
||||
adc083x->type = TYPE_ADC0831;
|
||||
adc083x_common_start(device);
|
||||
}
|
||||
|
||||
static DEVICE_START( adc0832 )
|
||||
{
|
||||
adc0831_state *adc083x = get_safe_token(device);
|
||||
|
||||
adc083x->type = TYPE_ADC0832;
|
||||
adc083x_common_start(device);
|
||||
}
|
||||
|
||||
static DEVICE_START( adc0834 )
|
||||
{
|
||||
adc0831_state *adc083x = get_safe_token(device);
|
||||
|
||||
adc083x->type = TYPE_ADC0834;
|
||||
adc083x_common_start(device);
|
||||
}
|
||||
|
||||
static DEVICE_START( adc0838 )
|
||||
{
|
||||
adc0831_state *adc083x = get_safe_token(device);
|
||||
|
||||
adc083x->type = TYPE_ADC0838;
|
||||
adc083x_common_start(device);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------
|
||||
DEVICE_RESET( adc083x )
|
||||
-------------------------------------------------*/
|
||||
|
||||
static DEVICE_RESET( adc083x )
|
||||
static DEVICE_RESET( adc0831 )
|
||||
{
|
||||
adc083x_state *adc083x = get_safe_token(device);
|
||||
adc0831_state *adc083x = get_safe_token(device);
|
||||
|
||||
adc083x->cs = 0;
|
||||
adc083x->clk = 0;
|
||||
@ -494,24 +521,26 @@ static DEVICE_RESET( adc083x )
|
||||
device definition
|
||||
-------------------------------------------------*/
|
||||
|
||||
INLINE const char *get_adc083x_name(const device_config *device)
|
||||
{
|
||||
const adc083x_interface *intf = get_interface(device);
|
||||
switch (intf->type)
|
||||
{
|
||||
default:
|
||||
case ADC0831: return "A/D Converter 0831";
|
||||
case ADC0832: return "A/D Converter 0832";
|
||||
case ADC0834: return "A/D Converter 0834";
|
||||
case ADC0838: return "A/D Converter 0838";
|
||||
}
|
||||
}
|
||||
|
||||
static const char *DEVTEMPLATE_SOURCE = __FILE__;
|
||||
|
||||
#define DEVTEMPLATE_ID(p,s) p##adc083x##s
|
||||
#define DEVTEMPLATE_ID(p,s) p##adc0831##s
|
||||
#define DEVTEMPLATE_FEATURES DT_HAS_START | DT_HAS_RESET
|
||||
#define DEVTEMPLATE_NAME get_adc083x_name(device)
|
||||
#define DEVTEMPLATE_NAME "A/D Converters 0831"
|
||||
#define DEVTEMPLATE_FAMILY "National Semiconductor A/D Converters 083x"
|
||||
#define DEVTEMPLATE_CLASS DEVICE_CLASS_PERIPHERAL
|
||||
#include "devtempl.h"
|
||||
|
||||
#define DEVTEMPLATE_DERIVED_ID(p,s) p##adc0832##s
|
||||
#define DEVTEMPLATE_DERIVED_FEATURES DT_HAS_START
|
||||
#define DEVTEMPLATE_DERIVED_NAME "A/D Converters 0832"
|
||||
#include "devtempl.h"
|
||||
|
||||
#define DEVTEMPLATE_DERIVED_ID(p,s) p##adc0834##s
|
||||
#define DEVTEMPLATE_DERIVED_FEATURES DT_HAS_START
|
||||
#define DEVTEMPLATE_DERIVED_NAME "A/D Converters 0834"
|
||||
#include "devtempl.h"
|
||||
|
||||
#define DEVTEMPLATE_DERIVED_ID(p,s) p##adc0838##s
|
||||
#define DEVTEMPLATE_DERIVED_FEATURES DT_HAS_START
|
||||
#define DEVTEMPLATE_DERIVED_NAME "A/D Converters 0838"
|
||||
#include "devtempl.h"
|
||||
|
@ -18,11 +18,10 @@
|
||||
/* enumeration specifying which model we are emulating */
|
||||
enum
|
||||
{
|
||||
ADC0831,
|
||||
ADC0832,
|
||||
ADC0834,
|
||||
ADC0838,
|
||||
MAX_ADC083X_TYPES
|
||||
TYPE_ADC0831,
|
||||
TYPE_ADC0832,
|
||||
TYPE_ADC0834,
|
||||
TYPE_ADC0838
|
||||
};
|
||||
|
||||
#define ADC083X_CH0 0
|
||||
@ -41,13 +40,37 @@ enum
|
||||
MACROS / CONSTANTS
|
||||
***************************************************************************/
|
||||
|
||||
#define ADC083X DEVICE_GET_INFO_NAME(adc083x)
|
||||
#define ADC0831 DEVICE_GET_INFO_NAME(adc0831)
|
||||
#define ADC0832 DEVICE_GET_INFO_NAME(adc0832)
|
||||
#define ADC0834 DEVICE_GET_INFO_NAME(adc0834)
|
||||
#define ADC0838 DEVICE_GET_INFO_NAME(adc0838)
|
||||
|
||||
#define MDRV_ADC083X_ADD(_tag, _config) \
|
||||
MDRV_DEVICE_ADD(_tag, ADC083X, 0) \
|
||||
#define MDRV_ADC0831_ADD(_tag, _config) \
|
||||
MDRV_DEVICE_ADD(_tag, ADC0831, 0) \
|
||||
MDRV_DEVICE_CONFIG(_config)
|
||||
|
||||
#define MDRV_ADC083X_REMOVE(_tag) \
|
||||
#define MDRV_ADC0831_REMOVE(_tag) \
|
||||
MDRV_DEVICE_REMOVE(_tag)
|
||||
|
||||
#define MDRV_ADC0832_ADD(_tag, _config) \
|
||||
MDRV_DEVICE_ADD(_tag, ADC0832, 0) \
|
||||
MDRV_DEVICE_CONFIG(_config)
|
||||
|
||||
#define MDRV_ADC0832_REMOVE(_tag) \
|
||||
MDRV_DEVICE_REMOVE(_tag)
|
||||
|
||||
#define MDRV_ADC0834_ADD(_tag, _config) \
|
||||
MDRV_DEVICE_ADD(_tag, ADC0834, 0) \
|
||||
MDRV_DEVICE_CONFIG(_config)
|
||||
|
||||
#define MDRV_ADC0834_REMOVE(_tag) \
|
||||
MDRV_DEVICE_REMOVE(_tag)
|
||||
|
||||
#define MDRV_ADC0838_ADD(_tag, _config) \
|
||||
MDRV_DEVICE_ADD(_tag, ADC0838, 0) \
|
||||
MDRV_DEVICE_CONFIG(_config)
|
||||
|
||||
#define MDRV_ADC0838_REMOVE(_tag) \
|
||||
MDRV_DEVICE_REMOVE(_tag)
|
||||
|
||||
|
||||
@ -57,19 +80,22 @@ enum
|
||||
|
||||
typedef double (*adc083x_input_convert_func)(const device_config *device, UINT8 input);
|
||||
|
||||
typedef struct _adc083x_interface adc083x_interface;
|
||||
struct _adc083x_interface
|
||||
typedef struct _adc0831_interface adc0831_interface;
|
||||
struct _adc0831_interface
|
||||
{
|
||||
int type;
|
||||
adc083x_input_convert_func input_callback_r;
|
||||
};
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
PROTOTYPES
|
||||
***************************************************************************/
|
||||
|
||||
/* device interface */
|
||||
DEVICE_GET_INFO( adc083x );
|
||||
DEVICE_GET_INFO( adc0831 );
|
||||
DEVICE_GET_INFO( adc0832 );
|
||||
DEVICE_GET_INFO( adc0834 );
|
||||
DEVICE_GET_INFO( adc0838 );
|
||||
|
||||
extern WRITE8_DEVICE_HANDLER( adc083x_cs_write );
|
||||
extern WRITE8_DEVICE_HANDLER( adc083x_clk_write );
|
||||
|
@ -20,13 +20,12 @@
|
||||
TYPE DEFINITIONS
|
||||
***************************************************************************/
|
||||
|
||||
typedef struct _adc1213x_state adc1213x_state;
|
||||
struct _adc1213x_state
|
||||
typedef struct _adc12138_state adc12138_state;
|
||||
struct _adc12138_state
|
||||
{
|
||||
int type;
|
||||
|
||||
adc1213x_input_convert_func input_callback_r;
|
||||
|
||||
int type;
|
||||
int cycle;
|
||||
int data_out;
|
||||
int data_in;
|
||||
@ -56,19 +55,19 @@ struct _adc1213x_state
|
||||
INLINE FUNCTIONS
|
||||
***************************************************************************/
|
||||
|
||||
INLINE adc1213x_state *get_safe_token(const device_config *device)
|
||||
INLINE adc12138_state *get_safe_token(const device_config *device)
|
||||
{
|
||||
assert(device != NULL);
|
||||
assert(device->token != NULL);
|
||||
assert((device->type == ADC1213X));
|
||||
return (adc1213x_state *)device->token;
|
||||
assert((device->type == ADC12130) || (device->type == ADC12132) || (device->type == ADC12138));
|
||||
return (adc12138_state *)device->token;
|
||||
}
|
||||
|
||||
INLINE const adc1213x_interface *get_interface(const device_config *device)
|
||||
INLINE const adc12138_interface *get_interface(const device_config *device)
|
||||
{
|
||||
assert(device != NULL);
|
||||
assert((device->type == ADC1213X));
|
||||
return (const adc1213x_interface *) device->static_config;
|
||||
assert((device->type == ADC12130) || (device->type == ADC12132) || (device->type == ADC12138));
|
||||
return (const adc12138_interface *) device->static_config;
|
||||
}
|
||||
|
||||
|
||||
@ -82,7 +81,7 @@ INLINE const adc1213x_interface *get_interface(const device_config *device)
|
||||
|
||||
WRITE8_DEVICE_HANDLER( adc1213x_di_w )
|
||||
{
|
||||
adc1213x_state *adc1213x = get_safe_token(device);
|
||||
adc12138_state *adc1213x = get_safe_token(device);
|
||||
adc1213x->data_in = data & 1;
|
||||
}
|
||||
|
||||
@ -92,7 +91,7 @@ WRITE8_DEVICE_HANDLER( adc1213x_di_w )
|
||||
|
||||
static void adc1213x_convert(const device_config *device, int channel, int bits16, int lsbfirst)
|
||||
{
|
||||
adc1213x_state *adc1213x = get_safe_token(device);
|
||||
adc12138_state *adc1213x = get_safe_token(device);
|
||||
int i;
|
||||
int bits;
|
||||
int input_value;
|
||||
@ -183,7 +182,7 @@ static void adc1213x_convert(const device_config *device, int channel, int bits1
|
||||
|
||||
WRITE8_DEVICE_HANDLER( adc1213x_cs_w )
|
||||
{
|
||||
adc1213x_state *adc1213x = get_safe_token(device);
|
||||
adc12138_state *adc1213x = get_safe_token(device);
|
||||
|
||||
if (data)
|
||||
{
|
||||
@ -261,7 +260,7 @@ WRITE8_DEVICE_HANDLER( adc1213x_cs_w )
|
||||
|
||||
WRITE8_DEVICE_HANDLER( adc1213x_sclk_w )
|
||||
{
|
||||
adc1213x_state *adc1213x = get_safe_token(device);
|
||||
adc12138_state *adc1213x = get_safe_token(device);
|
||||
|
||||
if (data)
|
||||
{
|
||||
@ -283,7 +282,7 @@ WRITE8_DEVICE_HANDLER( adc1213x_sclk_w )
|
||||
|
||||
WRITE8_DEVICE_HANDLER( adc1213x_conv_w )
|
||||
{
|
||||
adc1213x_state *adc1213x = get_safe_token(device);
|
||||
adc12138_state *adc1213x = get_safe_token(device);
|
||||
adc1213x->end_conv = 1;
|
||||
}
|
||||
|
||||
@ -293,7 +292,7 @@ WRITE8_DEVICE_HANDLER( adc1213x_conv_w )
|
||||
|
||||
READ8_DEVICE_HANDLER( adc1213x_do_r )
|
||||
{
|
||||
adc1213x_state *adc1213x = get_safe_token(device);
|
||||
adc12138_state *adc1213x = get_safe_token(device);
|
||||
|
||||
//printf("ADC: DO\n");
|
||||
return adc1213x->data_out;
|
||||
@ -305,7 +304,7 @@ READ8_DEVICE_HANDLER( adc1213x_do_r )
|
||||
|
||||
READ8_DEVICE_HANDLER( adc1213x_eoc_r )
|
||||
{
|
||||
adc1213x_state *adc1213x = get_safe_token(device);
|
||||
adc12138_state *adc1213x = get_safe_token(device);
|
||||
return adc1213x->end_conv;
|
||||
}
|
||||
|
||||
@ -313,41 +312,44 @@ READ8_DEVICE_HANDLER( adc1213x_eoc_r )
|
||||
DEVICE_START( adc1213x )
|
||||
-------------------------------------------------*/
|
||||
|
||||
static DEVICE_START( adc1213x )
|
||||
static void adc1213x_common_start( const device_config *device )
|
||||
{
|
||||
adc1213x_state *adc1213x = get_safe_token(device);
|
||||
const adc1213x_interface *intf = get_interface(device);
|
||||
|
||||
/* validate configuration */
|
||||
assert(intf->type >= ADC12130 && intf->type < MAX_ADC1213X_TYPES);
|
||||
|
||||
adc1213x->type = intf->type;
|
||||
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 */
|
||||
state_save_register_global(device->machine, adc1213x->cycle);
|
||||
state_save_register_global(device->machine, adc1213x->data_out);
|
||||
state_save_register_global(device->machine, adc1213x->data_in);
|
||||
state_save_register_global(device->machine, adc1213x->conv_mode);
|
||||
state_save_register_global(device->machine, adc1213x->auto_cal);
|
||||
state_save_register_global(device->machine, adc1213x->auto_zero);
|
||||
state_save_register_global(device->machine, adc1213x->acq_time);
|
||||
state_save_register_global(device->machine, adc1213x->data_out_sign);
|
||||
state_save_register_global(device->machine, adc1213x->mode);
|
||||
state_save_register_global(device->machine, adc1213x->input_shift_reg);
|
||||
state_save_register_global(device->machine, adc1213x->output_shift_reg);
|
||||
state_save_register_global(device->machine, adc1213x->end_conv);
|
||||
state_save_register_device_item(device, 0, adc1213x->cycle);
|
||||
state_save_register_device_item(device, 0, adc1213x->data_out);
|
||||
state_save_register_device_item(device, 0, adc1213x->data_in);
|
||||
state_save_register_device_item(device, 0, adc1213x->conv_mode);
|
||||
state_save_register_device_item(device, 0, adc1213x->auto_cal);
|
||||
state_save_register_device_item(device, 0, adc1213x->auto_zero);
|
||||
state_save_register_device_item(device, 0, adc1213x->acq_time);
|
||||
state_save_register_device_item(device, 0, adc1213x->data_out_sign);
|
||||
state_save_register_device_item(device, 0, adc1213x->mode);
|
||||
state_save_register_device_item(device, 0, adc1213x->input_shift_reg);
|
||||
state_save_register_device_item(device, 0, adc1213x->output_shift_reg);
|
||||
state_save_register_device_item(device, 0, adc1213x->end_conv);
|
||||
}
|
||||
|
||||
static DEVICE_START( adc12138 )
|
||||
{
|
||||
adc12138_state *adc1213x = get_safe_token(device);
|
||||
|
||||
adc1213x->type = TYPE_ADC12138;
|
||||
adc1213x_common_start(device);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------
|
||||
DEVICE_RESET( adc1213x )
|
||||
-------------------------------------------------*/
|
||||
|
||||
static DEVICE_RESET( adc1213x )
|
||||
static DEVICE_RESET( adc12138 )
|
||||
{
|
||||
adc1213x_state *adc1213x = get_safe_token(device);
|
||||
adc12138_state *adc1213x = get_safe_token(device);
|
||||
|
||||
adc1213x->conv_mode = ADC1213X_CONV_MODE_12_MSB_FIRST;
|
||||
adc1213x->data_out_sign = 1;
|
||||
@ -362,9 +364,19 @@ static DEVICE_RESET( adc1213x )
|
||||
|
||||
static const char *DEVTEMPLATE_SOURCE = __FILE__;
|
||||
|
||||
#define DEVTEMPLATE_ID(p,s) p##adc1213x##s
|
||||
#define DEVTEMPLATE_ID(p,s) p##adc12138##s
|
||||
#define DEVTEMPLATE_FEATURES DT_HAS_START | DT_HAS_RESET
|
||||
#define DEVTEMPLATE_NAME "A/D Converter 12138"
|
||||
#define DEVTEMPLATE_FAMILY "National Semiconductor A/D Converters 1213x"
|
||||
#define DEVTEMPLATE_CLASS DEVICE_CLASS_PERIPHERAL
|
||||
#include "devtempl.h"
|
||||
|
||||
#define DEVTEMPLATE_DERIVED_ID(p,s) p##adc12130##s
|
||||
#define DEVTEMPLATE_DERIVED_FEATURES 0
|
||||
#define DEVTEMPLATE_DERIVED_NAME "A/D Converter 12130"
|
||||
#include "devtempl.h"
|
||||
|
||||
#define DEVTEMPLATE_DERIVED_ID(p,s) p##adc12132##s
|
||||
#define DEVTEMPLATE_DERIVED_FEATURES 0
|
||||
#define DEVTEMPLATE_DERIVED_NAME "A/D Converter 12132"
|
||||
#include "devtempl.h"
|
||||
|
@ -19,23 +19,38 @@
|
||||
/* enumeration specifying which model we are emulating */
|
||||
enum
|
||||
{
|
||||
ADC12130,
|
||||
ADC12132,
|
||||
ADC12138,
|
||||
MAX_ADC1213X_TYPES
|
||||
TYPE_ADC12130,
|
||||
TYPE_ADC12132,
|
||||
TYPE_ADC12138
|
||||
};
|
||||
|
||||
/***************************************************************************
|
||||
MACROS / CONSTANTS
|
||||
***************************************************************************/
|
||||
|
||||
#define ADC1213X DEVICE_GET_INFO_NAME(adc1213x)
|
||||
#define ADC12130 DEVICE_GET_INFO_NAME(adc12130)
|
||||
#define ADC12132 DEVICE_GET_INFO_NAME(adc12132)
|
||||
#define ADC12138 DEVICE_GET_INFO_NAME(adc12138)
|
||||
|
||||
#define MDRV_ADC1213X_ADD(_tag, _config) \
|
||||
MDRV_DEVICE_ADD(_tag, ADC1213X, 0) \
|
||||
#define MDRV_ADC12130_ADD(_tag, _config) \
|
||||
MDRV_DEVICE_ADD(_tag, ADC12130, 0) \
|
||||
MDRV_DEVICE_CONFIG(_config)
|
||||
|
||||
#define MDRV_ADC1213X_REMOVE(_tag) \
|
||||
#define MDRV_ADC12130_REMOVE(_tag) \
|
||||
MDRV_DEVICE_REMOVE(_tag)
|
||||
|
||||
#define MDRV_ADC12132_ADD(_tag, _config) \
|
||||
MDRV_DEVICE_ADD(_tag, ADC12132, 0) \
|
||||
MDRV_DEVICE_CONFIG(_config)
|
||||
|
||||
#define MDRV_ADC12132_REMOVE(_tag) \
|
||||
MDRV_DEVICE_REMOVE(_tag)
|
||||
|
||||
#define MDRV_ADC12138_ADD(_tag, _config) \
|
||||
MDRV_DEVICE_ADD(_tag, ADC12138, 0) \
|
||||
MDRV_DEVICE_CONFIG(_config)
|
||||
|
||||
#define MDRV_ADC12138_REMOVE(_tag) \
|
||||
MDRV_DEVICE_REMOVE(_tag)
|
||||
|
||||
|
||||
@ -45,10 +60,9 @@ enum
|
||||
|
||||
typedef double (*adc1213x_input_convert_func)(const device_config *device, UINT8 input);
|
||||
|
||||
typedef struct _adc1213x_interface adc1213x_interface;
|
||||
struct _adc1213x_interface
|
||||
typedef struct _adc12138_interface adc12138_interface;
|
||||
struct _adc12138_interface
|
||||
{
|
||||
int type;
|
||||
adc1213x_input_convert_func input_callback_r;
|
||||
};
|
||||
|
||||
@ -57,7 +71,9 @@ struct _adc1213x_interface
|
||||
***************************************************************************/
|
||||
|
||||
/* device interface */
|
||||
DEVICE_GET_INFO( adc1213x );
|
||||
DEVICE_GET_INFO( adc12130 );
|
||||
DEVICE_GET_INFO( adc12132 );
|
||||
DEVICE_GET_INFO( adc12138 );
|
||||
|
||||
extern WRITE8_DEVICE_HANDLER( adc1213x_di_w );
|
||||
extern WRITE8_DEVICE_HANDLER( adc1213x_cs_w );
|
||||
|
@ -874,8 +874,7 @@ static double adc0834_callback( const device_config *device, UINT8 input )
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const adc083x_interface konamigx_adc_interface = {
|
||||
ADC0834,
|
||||
static const adc0831_interface konamigx_adc_interface = {
|
||||
adc0834_callback
|
||||
};
|
||||
|
||||
@ -1400,7 +1399,7 @@ static MACHINE_DRIVER_START( konamigx )
|
||||
MDRV_SOUND_ROUTE(0, "lspeaker", 1.0)
|
||||
MDRV_SOUND_ROUTE(1, "rspeaker", 1.0)
|
||||
|
||||
MDRV_ADC083X_ADD( "adc0834", konamigx_adc_interface )
|
||||
MDRV_ADC0834_ADD( "adc0834", konamigx_adc_interface )
|
||||
MACHINE_DRIVER_END
|
||||
|
||||
static MACHINE_DRIVER_START( dragoonj )
|
||||
|
@ -2789,8 +2789,7 @@ static double analogue_inputs_callback( const device_config *device, UINT8 input
|
||||
}
|
||||
|
||||
|
||||
static const adc083x_interface konami573_adc_interface = {
|
||||
ADC0834,
|
||||
static const adc0831_interface konami573_adc_interface = {
|
||||
analogue_inputs_callback
|
||||
};
|
||||
|
||||
@ -2831,7 +2830,7 @@ static MACHINE_DRIVER_START( konami573 )
|
||||
|
||||
MDRV_M48T58_ADD( "m48t58" )
|
||||
|
||||
MDRV_ADC083X_ADD( "adc0834", konami573_adc_interface )
|
||||
MDRV_ADC0834_ADD( "adc0834", konami573_adc_interface )
|
||||
MACHINE_DRIVER_END
|
||||
|
||||
|
||||
|
@ -1025,8 +1025,7 @@ static double adc12138_input_callback( const device_config *device, UINT8 input
|
||||
return (double)(value) / 2047.0;
|
||||
}
|
||||
|
||||
static const adc1213x_interface nwktr_adc_interface = {
|
||||
ADC12138,
|
||||
static const adc12138_interface nwktr_adc_interface = {
|
||||
adc12138_input_callback
|
||||
};
|
||||
|
||||
@ -1080,7 +1079,7 @@ static MACHINE_DRIVER_START( nwktr )
|
||||
|
||||
MDRV_M48T58_ADD( "m48t58" )
|
||||
|
||||
MDRV_ADC1213X_ADD( "adc12138", nwktr_adc_interface )
|
||||
MDRV_ADC12138_ADD( "adc12138", nwktr_adc_interface )
|
||||
MACHINE_DRIVER_END
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -705,8 +705,7 @@ static double adc0838_callback( const device_config *device, UINT8 input )
|
||||
}
|
||||
|
||||
|
||||
static const adc083x_interface zr107_adc_interface = {
|
||||
ADC0838,
|
||||
static const adc0831_interface zr107_adc_interface = {
|
||||
adc0838_callback
|
||||
};
|
||||
|
||||
@ -771,7 +770,7 @@ static MACHINE_DRIVER_START( zr107 )
|
||||
MDRV_SOUND_ROUTE(0, "lspeaker", 0.75)
|
||||
MDRV_SOUND_ROUTE(1, "rspeaker", 0.75)
|
||||
|
||||
MDRV_ADC083X_ADD("adc0838", zr107_adc_interface)
|
||||
MDRV_ADC0838_ADD("adc0838", zr107_adc_interface)
|
||||
MACHINE_DRIVER_END
|
||||
|
||||
static MACHINE_DRIVER_START( jetwave )
|
||||
@ -818,7 +817,7 @@ static MACHINE_DRIVER_START( jetwave )
|
||||
MDRV_SOUND_ROUTE(0, "lspeaker", 0.75)
|
||||
MDRV_SOUND_ROUTE(1, "rspeaker", 0.75)
|
||||
|
||||
MDRV_ADC083X_ADD("adc0838", zr107_adc_interface)
|
||||
MDRV_ADC0838_ADD("adc0838", zr107_adc_interface)
|
||||
MACHINE_DRIVER_END
|
||||
|
||||
/*****************************************************************************/
|
||||
|
Loading…
Reference in New Issue
Block a user