summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/machine/adc1213x.h
blob: 0fed72a1064f74d9de9a3065a164b59a99e8afc8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/***************************************************************************

    National Semiconductor ADC12130 / ADC12132 / ADC12138

    Self-calibrating 12-bit Plus Sign Serial I/O A/D Converters with MUX
        and Sample/Hold

***************************************************************************/

#ifndef __ADC1213X_H__
#define __ADC1213X_H__

#include "devlegcy.h"


/***************************************************************************
    MACROS / CONSTANTS
***************************************************************************/

class adc12138_device : public device_t
{
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; }
protected:
	// device-level overrides
	virtual void device_config_complete();
	virtual void device_start();
	virtual void device_reset();
private:
	// internal state
	void *m_token;
};

extern const device_type ADC12138;

class adc12130_device : public adc12138_device
{
public:
	adc12130_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
};

extern const device_type ADC12130;

class adc12132_device : public adc12138_device
{
public:
	adc12132_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
};

extern const device_type ADC12132;

#define MCFG_ADC12130_ADD(_tag, _config) \
	MCFG_DEVICE_ADD(_tag, ADC12130, 0) \
	MCFG_DEVICE_CONFIG(_config)

#define MCFG_ADC12132_ADD(_tag, _config) \
	MCFG_DEVICE_ADD(_tag, ADC12132, 0) \
	MCFG_DEVICE_CONFIG(_config)

#define MCFG_ADC12138_ADD(_tag, _config) \
	MCFG_DEVICE_ADD(_tag, ADC12138, 0) \
	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__ */