summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/machine/mb3773.c
blob: 925def0a33f79f32faec48c022132c2961bb31bd (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
/***************************************************************************

    Fujitsu MB3773

    Power Supply Monitor with Watch Dog Timer (i.e. Reset IC)


    Todo:
        Calculate the timeout from parameters.

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

#include "emu.h"
#include "mb3773.h"


//**************************************************************************
//  LIVE DEVICE
//**************************************************************************

// device type definition
const device_type MB3773 = &device_creator<mb3773_device>;

//-------------------------------------------------
//  mb3773_device - constructor
//-------------------------------------------------

mb3773_device::mb3773_device( const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock )
	: device_t(mconfig, MB3773, "MB3773", tag, owner, clock)
{
}


//-------------------------------------------------
//  device_config_complete - perform any
//  operations now that the configuration is
//  complete
//-------------------------------------------------

void mb3773_device::device_config_complete()
{
}


//-------------------------------------------------
//  device_validity_check - perform validity checks
//  on this device
//-------------------------------------------------

bool mb3773_device::device_validity_check( emu_options &options, const game_driver &driver ) const
{
	return false;
}


//-------------------------------------------------
//  device_start - device-specific startup
//-------------------------------------------------

void mb3773_device::device_start()
{
	m_watchdog_timer = machine().scheduler().timer_alloc( FUNC(watchdog_timeout), this );
	reset_timer();

	save_item( NAME(m_ck) );
}


//-------------------------------------------------
//  device_reset - device-specific reset
//-------------------------------------------------

void mb3773_device::device_reset()
{
	m_ck = 0;
}



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

WRITE_LINE_DEVICE_HANDLER( mb3773_set_ck )
{
	downcast<mb3773_device *>( device )->set_ck( state );
}

void mb3773_device::set_ck( int state )
{
	state &= 1;

	if( state == 0 && m_ck != 0 )
	{
		reset_timer();
	}

	m_ck = state;
}


//**************************************************************************
//  INTERNAL HELPERS
//**************************************************************************

void mb3773_device::reset_timer()
{
	m_watchdog_timer->adjust( attotime::from_seconds( 5 ) );
}

TIMER_CALLBACK( mb3773_device::watchdog_timeout )
{
	reinterpret_cast<mb3773_device *>(ptr)->machine().schedule_soft_reset();
}