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
|
// license:BSD-3-Clause
// copyright-holders:AJR
/***************************************************************************
National Semiconductor MM5307 Baud Rate Generator/Programmable Divider
****************************************************************************
___ ___
EXTERNAL FREQ 1 |* \__/ | 14 ϕOUT
NC 2 | | 13 RESET
OUTPUT 3 | | 12 Vgg
Vss 4 | MM5307 | 11 A
EXTERNAL CLOCK 5 | | 10 B
CRYSTAL 6 | | 9 C
CRYSTAL 7 |__________| 8 D
***************************************************************************/
#ifndef MAME_MACHINE_MM5307_H
#define MAME_MACHINE_MM5307_H
#pragma once
//**************************************************************************
// TYPE DEFINITIONS
//**************************************************************************
// ======================> mm5307_device
class mm5307_device : public device_t
{
public:
// configuration
void set_ext_freq(u32 freq) { m_ext_freq = freq; }
void set_ext_freq(const XTAL &freq) { m_ext_freq = freq.value(); }
auto output_cb() { return m_output_cb.bind(); }
// frequency control
void control_w(u8 data);
protected:
// base class constructor
mm5307_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock, const std::array<u16, 16> &divisors_x2);
// device-specific overrides
virtual void device_resolve_objects() override;
virtual void device_start() override;
virtual void device_reset() override;
private:
// timed update callback
TIMER_CALLBACK_MEMBER(periodic_update);
// internal divisors
const std::array<u16, 16> &m_divisors_x2;
// callbacks
devcb_write_line m_output_cb;
// external input frequency
u32 m_ext_freq;
// internal state
u8 m_freq_control;
u8 m_phase;
// timer
emu_timer *m_periodic_timer;
};
// ======================> mm5307aa_device
class mm5307aa_device : public mm5307_device
{
public:
// construction/destruction
mm5307aa_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock);
private:
static const std::array<u16, 16> s_divisors_x2;
};
// ======================> mm5307ab_device
class mm5307ab_device : public mm5307_device
{
public:
// construction/destruction
mm5307ab_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock);
private:
static const std::array<u16, 16> s_divisors_x2;
};
// device type declarations
DECLARE_DEVICE_TYPE(MM5307AA, mm5307aa_device)
DECLARE_DEVICE_TYPE(MM5307AB, mm5307ab_device)
#endif // MAME_MACHINE_MM5307_H
|