summaryrefslogtreecommitdiffstatshomepage
path: root/src/mess/machine/upd7002.h
blob: 4d93d0344eb2a1169335eb64142e7421522d7eec (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
/*****************************************************************************
 *
 * machine/upd7002.h
 *
 * uPD7002 Analogue to Digital Converter
 *
 * Driver by Gordon Jefferyes <mess_bbc@gjeffery.dircon.co.uk>
 *
 ****************************************************************************/

#ifndef UPD7002_H_
#define UPD7002_H_

/***************************************************************************
    MACROS
***************************************************************************/

class uPD7002_device : public device_t
{
public:
	uPD7002_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
	~uPD7002_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 UPD7002;


/***************************************************************************
    TYPE DEFINITIONS
***************************************************************************/

typedef int (*uPD7002_get_analogue_func)(device_t *device, int channel_number);
#define UPD7002_GET_ANALOGUE(name)	int name(device_t *device, int channel_number )

typedef void (*uPD7002_eoc_func)(device_t *device, int data);
#define UPD7002_EOC(name)	void name(device_t *device, int data )


struct uPD7002_interface
{
	uPD7002_get_analogue_func get_analogue_func;
	uPD7002_eoc_func		  EOC_func;
};

/***************************************************************************
    FUNCTION PROTOTYPES
***************************************************************************/

/* Standard handlers */

READ8_DEVICE_HANDLER ( uPD7002_EOC_r );
READ8_DEVICE_HANDLER ( uPD7002_r );
WRITE8_DEVICE_HANDLER ( uPD7002_w );


/***************************************************************************
    DEVICE CONFIGURATION MACROS
***************************************************************************/

#define MCFG_UPD7002_ADD(_tag, _intrf) \
	MCFG_DEVICE_ADD(_tag, UPD7002, 0) \
	MCFG_DEVICE_CONFIG(_intrf)


#endif /* UPD7002_H_ */