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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
|
// license:BSD-3-Clause
// copyright-holders:Olivier Galibert
#ifndef MAME_CPU_M6502_M5074X_H
#define MAME_CPU_M6502_M5074X_H
#pragma once
#include "m740.h"
//**************************************************************************
// TYPE DEFINITIONS
//**************************************************************************
// ======================> m5074x_device
class m5074x_device : public m740_device
{
friend class m50740_device;
friend class m50741_device;
friend class m50753_device;
enum
{
M5074X_INT1_LINE = INPUT_LINE_IRQ0
};
enum
{
TIMER_1 = 0,
TIMER_2,
TIMER_X,
TIMER_ADC,
NUM_TIMERS
};
public:
const address_space_config m_program_config;
template <std::size_t Bit> auto read_p() { return m_read_p[Bit].bind(); }
template <std::size_t Bit> auto write_p() { return m_write_p[Bit].bind(); }
template <std::size_t Bit> void set_pullups(u8 mask) { m_pullups[Bit] = mask; }
uint8_t ports_r(offs_t offset);
void ports_w(offs_t offset, uint8_t data);
uint8_t tmrirq_r(offs_t offset);
void tmrirq_w(offs_t offset, uint8_t data);
bool are_port_bits_output(uint8_t port, uint8_t mask) { return ((m_ddrs[port] & mask) == mask) ? true : false; }
protected:
// construction/destruction
m5074x_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, const XTAL &clock, int addrbits, address_map_constructor internal_map);
// device-level overrides
virtual void device_start() override;
virtual void device_reset() override;
virtual space_config_vector memory_space_config() const override;
// device_execute_interface overrides (TODO: /8 in M50740A/41/52/57/58 SLW mode)
virtual uint64_t execute_clocks_to_cycles(uint64_t clocks) const noexcept override { return (clocks + 4 - 1) / 4; }
virtual uint64_t execute_cycles_to_clocks(uint64_t cycles) const noexcept override { return (cycles * 4); }
virtual void execute_set_input(int inputnum, int state) override;
TIMER_CALLBACK_MEMBER(timer1_tick);
TIMER_CALLBACK_MEMBER(timer2_tick);
TIMER_CALLBACK_MEMBER(timerx_tick);
virtual TIMER_CALLBACK_MEMBER(adc_complete) { }
void send_port(uint8_t offset, uint8_t data);
uint8_t read_port(uint8_t offset);
void recalc_irqs();
void recalc_timer(int timer);
devcb_read8::array<5> m_read_p;
devcb_write8::array<5> m_write_p;
uint8_t m_ports[5], m_ddrs[5], m_pullups[5];
uint8_t m_intctrl, m_tmrctrl;
uint8_t m_tmr12pre, m_tmr1, m_tmr2, m_tmrxpre, m_tmrx;
uint8_t m_tmr1latch, m_tmr2latch, m_tmrxlatch;
uint8_t m_last_all_ints;
private:
emu_timer *m_timers[NUM_TIMERS];
};
class m50740_device : public m5074x_device
{
public:
m50740_device(const machine_config &mconfig, const char *tag, device_t *owner, const XTAL &clock);
protected:
m50740_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, const XTAL &clock);
private:
void m50740_map(address_map &map);
};
class m50741_device : public m5074x_device
{
public:
m50741_device(const machine_config &mconfig, const char *tag, device_t *owner, const XTAL &clock);
protected:
m50741_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, const XTAL &clock);
private:
void m50741_map(address_map &map);
};
class m50753_device : public m5074x_device
{
public:
m50753_device(const machine_config &mconfig, const char *tag, device_t *owner, const XTAL &clock);
enum
{
M50753_INT1_LINE = INPUT_LINE_IRQ0,
M50753_INT2_LINE = INPUT_LINE_IRQ1
};
template <std::size_t Bit> auto ad_in() { return m_ad_in[Bit].bind(); }
auto read_in_p() { return m_in_p.bind(); }
protected:
m50753_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, const XTAL &clock);
// device-level overrides
virtual void device_start() override;
virtual void device_reset() override;
virtual void execute_set_input(int inputnum, int state) override;
virtual TIMER_CALLBACK_MEMBER(adc_complete) override;
private:
void m50753_map(address_map &map);
uint8_t ad_r();
uint8_t in_r();
void ad_start_w(uint8_t data);
uint8_t ad_control_r();
void ad_control_w(uint8_t data);
void ad_trigger_w(uint8_t data);
uint8_t pwm_control_r();
void pwm_control_w(uint8_t data);
devcb_read8::array<8> m_ad_in;
devcb_read8 m_in_p;
uint8_t m_ad_control;
bool m_pwm_enabled;
};
DECLARE_DEVICE_TYPE(M50740, m50740_device)
DECLARE_DEVICE_TYPE(M50741, m50741_device)
DECLARE_DEVICE_TYPE(M50753, m50753_device)
#endif // MAME_CPU_M6502_M5074X_H
|