summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/machine/at28c16.h
blob: 6fb4765313e8b93a80d122e46d87ba6e7ff60658 (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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/***************************************************************************

    ATMEL AT28C16

    16K ( 2K x 8 ) Parallel EEPROM

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

#pragma once

#ifndef __AT28C16_H__
#define __AT28C16_H__


//**************************************************************************
//  INTERFACE CONFIGURATION MACROS
//**************************************************************************

#define MCFG_AT28C16_ADD( _tag, _interface ) \
	MCFG_DEVICE_ADD( _tag, AT28C16, 0 )


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

// ======================> at28c16_interface

struct at28c16_interface
{
};


// ======================> at28c16_device_config

class at28c16_device_config :
	public device_config,
	public device_config_memory_interface,
	public device_config_nvram_interface,
	public at28c16_interface
{
	friend class at28c16_device;

	// construction/destruction
	at28c16_device_config( const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock );

public:
	// allocators
	static device_config *static_alloc_device_config( const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock );
	virtual device_t *alloc_device( running_machine &machine ) const;

	// inline configuration indexes
	enum
	{
		INLINE_INTERFACE
	};

protected:
	// device_config overrides
	virtual void device_config_complete();
	virtual bool device_validity_check( const game_driver &driver ) const;

	// device_config_memory_interface overrides
	virtual const address_space_config *memory_space_config( int spacenum = 0 ) const;

	// device-specific configuration
	address_space_config m_space_config;
};


// ======================> at28c16_device

class at28c16_device :
	public device_t,
	public device_memory_interface,
	public device_nvram_interface
{
	friend class at28c16_device_config;

	// construction/destruction
	at28c16_device( running_machine &_machine, const at28c16_device_config &config );

public:
	// I/O operations
	void write( offs_t offset, UINT8 data );
	UINT8 read( offs_t offset );
	void set_a9_12v( int state );
	void set_oe_12v( int state );

protected:
	// device-level overrides
	virtual void device_start();
	virtual void device_reset();

	// device_nvram_interface overrides
	virtual void nvram_default();
	virtual void nvram_read( mame_file &file );
	virtual void nvram_write( mame_file &file );

	// internal helpers
	static TIMER_CALLBACK( write_finished );

	// internal state
	const at28c16_device_config &m_config;
	emu_timer *m_write_timer;
	int m_a9_12v;
	int m_oe_12v;
	int m_last_write;
};


// device type definition
extern const device_type AT28C16;


//**************************************************************************
//  READ/WRITE HANDLERS
//**************************************************************************

WRITE8_DEVICE_HANDLER( at28c16_w );
READ8_DEVICE_HANDLER( at28c16_r );
WRITE_LINE_DEVICE_HANDLER( at28c16_a9_12v );
WRITE_LINE_DEVICE_HANDLER( at28c16_oe_12v );

#endif