summaryrefslogtreecommitdiffstatshomepage
path: root/src/mess/machine/md_stm95.h
blob: 77bbad98e735cad8133abbe60868fb1e4fbf9c48 (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
#ifndef __MD_STM95_H
#define __MD_STM95_H

#include "machine/md_slot.h"

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

/* ST M95320 32Kbit serial EEPROM implementation */
// TO DO: STM95 should be made a separate EEPROM device and this should be merged with md_eeprom.c!

#define M95320_SIZE 0x1000

enum STMSTATE
{
	IDLE = 0,
	CMD_WRSR,
	CMD_RDSR,
	M95320_CMD_READ,
	CMD_WRITE,
	READING,
	WRITING
};

class stm95_eeprom_device
{
public:
	stm95_eeprom_device() : 
	stm_state(IDLE), 
	stream_pos(0) 
	{};
	
	UINT8   *eeprom_data;
	void    set_cs_line(int);
	void    set_halt_line(int state) {}; // not implemented
	void    set_si_line(int);
	void    set_sck_line(int state);
	int     get_so_line(void);

protected:
	int     latch;
	int     reset_line;
	int     sck_line;
	int     WEL;
	
	STMSTATE    stm_state;
	int     stream_pos;
	int     stream_data;
	int     eeprom_addr;
};


// ======================> md_eeprom_stm95_device

class md_eeprom_stm95_device : public device_t,
					  public device_md_cart_interface
{
public:
	// construction/destruction
	md_eeprom_stm95_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock);
	md_eeprom_stm95_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
	
	// device-level overrides
	virtual void device_start();
	virtual void device_config_complete() { m_shortname = "md_eeprom_stm95"; }
		
	// reading and writing
	virtual DECLARE_READ16_MEMBER(read);
	virtual DECLARE_READ16_MEMBER(read_a13);
	virtual DECLARE_WRITE16_MEMBER(write_a13);

private:
	UINT8 m_bank[3];
	int m_rdcnt;

	stm95_eeprom_device m_stm95;
};


// device type definition
extern const device_type MD_EEPROM_STM95;

#endif