Previous 15994 Revisions Next

r15349 Tuesday 29th May, 2012 at 15:05:48 UTC by Curt Coder
[WANGPC] Fixed POST serial and keyboard errors. (nw)
[src/emu]emu.mak
[src/emu/machine]im6402.c im6402.h mc2661.c* mc2661.h* scn2661.c scn2661.h
[src/mess/drivers]wangpc.c
[src/mess/includes]wangpc.h
[src/mess/machine]wangpckb.c wangpckb.h

src/emu/emu.mak
r15348r15349
208208   $(EMUMACHINE)/mb3773.o      \
209209   $(EMUMACHINE)/mb87078.o      \
210210   $(EMUMACHINE)/mc146818.o   \
211   $(EMUMACHINE)/mc2661.o      \
211212   $(EMUMACHINE)/mc6852.o      \
212213   $(EMUMACHINE)/mc68901.o      \
213214   $(EMUMACHINE)/mccs1850.o   \
r15348r15349
239240   $(EMUMACHINE)/s3c2400.o      \
240241   $(EMUMACHINE)/s3c2410.o      \
241242   $(EMUMACHINE)/s3c2440.o      \
242   $(EMUMACHINE)/scn2661.o      \
243243   $(EMUMACHINE)/scsi.o      \
244244   $(EMUMACHINE)/scsicd.o      \
245245   $(EMUMACHINE)/scsidev.o      \
src/emu/machine/scn2661.c
r15348r15349
1/***************************************************************************
2
3    Philips SCN2661 Enhanced Programmable Communications Interface emulation
4
5    Copyright the MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8***************************************************************************/
9
10#include "scn2661.h"
11
12
13
14//**************************************************************************
15//  DEVICE DEFINITIONS
16//**************************************************************************
17
18const device_type SCN2661 = &device_creator<scn2661_device>;
19
20
21
22//**************************************************************************
23//  MACROS / CONSTANTS
24//**************************************************************************
25
26#define LOG 1
27
28enum
29{
30   REGISTER_HOLDING = 0,
31   REGISTER_STATUS,
32   REGISTER_SYNC = REGISTER_STATUS,
33   REGISTER_MODE,
34   REGISTER_COMMAND
35};
36
37
38//**************************************************************************
39//  INLINE HELPERS
40//**************************************************************************
41
42//-------------------------------------------------
43//  receive -
44//-------------------------------------------------
45
46inline void scn2661_device::receive()
47{
48}
49
50
51//-------------------------------------------------
52//  transmit -
53//-------------------------------------------------
54
55inline void scn2661_device::transmit()
56{
57}
58
59
60
61//**************************************************************************
62//  LIVE DEVICE
63//**************************************************************************
64
65//-------------------------------------------------
66//  scn2661_device - constructor
67//-------------------------------------------------
68
69scn2661_device::scn2661_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
70    : device_t(mconfig, SCN2661, "SCN2661", tag, owner, clock),
71     device_serial_interface(mconfig, *this)
72{
73}
74
75
76//-------------------------------------------------
77//  device_config_complete - perform any
78//  operations now that the configuration is
79//  complete
80//-------------------------------------------------
81
82void scn2661_device::device_config_complete()
83{
84   // inherit a copy of the static data
85   const scn2661_interface *intf = reinterpret_cast<const scn2661_interface *>(static_config());
86   if (intf != NULL)
87      *static_cast<scn2661_interface *>(this) = *intf;
88
89   // or initialize to defaults if none provided
90   else
91   {
92      memset(&m_in_rxd_cb, 0, sizeof(m_in_rxd_cb));
93      memset(&m_out_txd_cb, 0, sizeof(m_out_txd_cb));
94      memset(&m_out_rxrdy_cb, 0, sizeof(m_out_rxrdy_cb));
95      memset(&m_out_txrdy_cb, 0, sizeof(m_out_txrdy_cb));
96      memset(&m_out_rts_cb, 0, sizeof(m_out_rts_cb));
97      memset(&m_out_dtr_cb, 0, sizeof(m_out_dtr_cb));
98      memset(&m_out_txemt_dschg_cb, 0, sizeof(m_out_txemt_dschg_cb));
99      memset(&m_out_bkdet_cb, 0, sizeof(m_out_bkdet_cb));
100      memset(&m_out_xsync_cb, 0, sizeof(m_out_xsync_cb));
101   }
102}
103
104
105//-------------------------------------------------
106//  device_start - device-specific startup
107//-------------------------------------------------
108
109void scn2661_device::device_start()
110{
111   // resolve callbacks
112   m_in_rxd_func.resolve(m_in_rxd_cb, *this);
113   m_out_txd_func.resolve(m_out_txd_cb, *this);
114   m_out_rxrdy_func.resolve(m_out_rxrdy_cb, *this);
115   m_out_txrdy_func.resolve(m_out_txrdy_cb, *this);
116   m_out_rts_func.resolve(m_out_rts_cb, *this);
117   m_out_dtr_func.resolve(m_out_dtr_cb, *this);
118   m_out_txemt_dschg_func.resolve(m_out_txemt_dschg_cb, *this);
119   m_out_bkdet_func.resolve(m_out_bkdet_cb, *this);
120   m_out_xsync_func.resolve(m_out_xsync_cb, *this);
121
122   // create the timers
123   if (m_rxc > 0)
124   {
125      m_rx_timer = timer_alloc(TIMER_RX);
126      m_rx_timer->adjust(attotime::zero, 0, attotime::from_hz(m_rxc));
127   }
128
129   if (m_txc > 0)
130   {
131      m_tx_timer = timer_alloc(TIMER_TX);
132      m_tx_timer->adjust(attotime::zero, 0, attotime::from_hz(m_txc));
133   }
134}
135
136
137//-------------------------------------------------
138//  device_reset - device-specific reset
139//-------------------------------------------------
140
141void scn2661_device::device_reset()
142{
143   transmit_register_reset();
144   receive_register_reset();
145}
146
147
148//-------------------------------------------------
149//  device_timer - handler timer events
150//-------------------------------------------------
151
152void scn2661_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
153{
154   switch (id)
155   {
156   case TIMER_RX:
157      rxc_w(1);
158      break;
159
160   case TIMER_TX:
161      txc_w(1);
162      break;
163   }
164}
165
166
167//-------------------------------------------------
168//  input_callback -
169//-------------------------------------------------
170
171void scn2661_device::input_callback(UINT8 state)
172{
173}
174
175
176//-------------------------------------------------
177//  read -
178//-------------------------------------------------
179
180READ8_MEMBER( scn2661_device::read )
181{
182   UINT8 data = 0;
183
184   switch (offset & 0x03)
185   {
186   case REGISTER_HOLDING:
187      data = m_rhr;
188      break;
189
190   case REGISTER_STATUS:
191      data = m_sr;
192      break;
193
194   case REGISTER_MODE:
195      break;
196
197   case REGISTER_COMMAND:
198      data = m_cr;
199      break;
200   }
201
202   return data;
203}
204
205
206//-------------------------------------------------
207//  write - transmitter buffer register write
208//-------------------------------------------------
209
210WRITE8_MEMBER( scn2661_device::write )
211{
212   switch (offset & 0x03)
213   {
214   case REGISTER_HOLDING:
215      m_thr = data;
216      break;
217
218   case REGISTER_SYNC:
219      break;
220
221   case REGISTER_MODE:
222      break;
223
224   case REGISTER_COMMAND:
225      m_cr = data;
226      break;
227   }
228}
229
230
231//-------------------------------------------------
232//  rxc_w - receiver clock
233//-------------------------------------------------
234
235WRITE_LINE_MEMBER( scn2661_device::rxc_w )
236{
237}
238
239
240//-------------------------------------------------
241//  txc_w - transmitter clock
242//-------------------------------------------------
243
244WRITE_LINE_MEMBER( scn2661_device::txc_w )
245{
246}
247
248
249//-------------------------------------------------
250//  dsr_w - data set ready
251//-------------------------------------------------
252
253WRITE_LINE_MEMBER( scn2661_device::dsr_w )
254{
255}
256
257
258//-------------------------------------------------
259//  dcd_w - data carrier detect
260//-------------------------------------------------
261
262WRITE_LINE_MEMBER( scn2661_device::dcd_w )
263{
264}
265
266
267//-------------------------------------------------
268//  cts_w - clear to send
269//-------------------------------------------------
270
271WRITE_LINE_MEMBER( scn2661_device::cts_w )
272{
273}
274
275
276//-------------------------------------------------
277//  rxrdy_r - receiver ready
278//-------------------------------------------------
279
280READ_LINE_MEMBER( scn2661_device::rxrdy_r )
281{
282   return CLEAR_LINE;
283}
284
285
286//-------------------------------------------------
287//  txemt_r - transmitter empty
288//-------------------------------------------------
289
290READ_LINE_MEMBER( scn2661_device::txemt_r )
291{
292   return CLEAR_LINE;
293}
src/emu/machine/scn2661.h
r15348r15349
1/***************************************************************************
2
3    Philips SCN2661 Enhanced Programmable Communications Interface emulation
4
5    Copyright the MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8****************************************************************************
9                            _____   _____
10                    D2   1 |*    \_/     | 28  D1
11                    D3   2 |             | 27  D0
12                   RxD   3 |             | 26  Vcc
13                   GND   4 |             | 25  _RxC/BKDET
14                    D4   5 |             | 24  _DTR
15                    D5   6 |             | 23  _RTS
16                    D6   7 |   SCN2661   | 22  _DSR
17                    D7   8 |             | 21  RESET
18            _TxC/XSYNC   9 |             | 20  BRCLK
19                    A1  10 |             | 19  TxD
20                   _CE  11 |             | 18  _TxEMT/DSCHG
21                    A0  12 |             | 17  _CTS
22                  _R/W  13 |             | 16  _DCD
23                _RxRDY  14 |_____________| 15  _TxRDY
24
25***************************************************************************/
26
27#pragma once
28
29#ifndef __SCN2661__
30#define __SCN2661__
31
32#include "emu.h"
33
34
35
36/***************************************************************************
37    DEVICE CONFIGURATION MACROS
38***************************************************************************/
39
40#define MCFG_SCN2661_ADD(_tag, _clock, _config) \
41   MCFG_DEVICE_ADD(_tag, SCN2661, _clock) \
42   MCFG_DEVICE_CONFIG(_config)
43
44
45#define SCN2661_INTERFACE(_name) \
46   const scn2661_interface (_name) =
47
48
49
50/***************************************************************************
51    TYPE DEFINITIONS
52***************************************************************************/
53
54// ======================> scn2661_interface
55
56struct scn2661_interface
57{
58   int m_rxc;
59   int m_txc;
60
61   devcb_read_line      m_in_rxd_cb;
62   devcb_write_line   m_out_txd_cb;
63
64   devcb_write_line   m_out_rxrdy_cb;
65   devcb_write_line   m_out_txrdy_cb;
66   devcb_write_line   m_out_rts_cb;
67   devcb_write_line   m_out_dtr_cb;
68   devcb_write_line   m_out_txemt_dschg_cb;
69   devcb_write_line   m_out_bkdet_cb;
70   devcb_write_line   m_out_xsync_cb;
71};
72
73
74// ======================> scn2661_device
75
76class scn2661_device :  public device_t,
77                   public device_serial_interface,
78                   public scn2661_interface
79{
80public:
81   // construction/destruction
82   scn2661_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
83
84   DECLARE_READ8_MEMBER( read );
85   DECLARE_WRITE8_MEMBER( write );
86
87   DECLARE_WRITE_LINE_MEMBER( rxc_w );
88   DECLARE_WRITE_LINE_MEMBER( txc_w );
89
90   DECLARE_WRITE_LINE_MEMBER( dsr_w );
91   DECLARE_WRITE_LINE_MEMBER( dcd_w );
92   DECLARE_WRITE_LINE_MEMBER( cts_w );
93
94   DECLARE_READ_LINE_MEMBER( rxrdy_r );
95   DECLARE_READ_LINE_MEMBER( txemt_r );
96
97protected:
98   // device-level overrides
99   virtual void device_config_complete();
100   virtual void device_start();
101   virtual void device_reset();
102   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
103
104   // device_serial_interface overrides
105   virtual void input_callback(UINT8 state);
106
107private:
108   inline void receive();
109   inline void transmit();
110
111   enum
112   {
113      TIMER_RX,
114      TIMER_TX
115   };
116
117   devcb_resolved_read_line   m_in_rxd_func;
118   devcb_resolved_write_line   m_out_txd_func;
119
120   devcb_resolved_write_line   m_out_rxrdy_func;
121   devcb_resolved_write_line   m_out_txrdy_func;
122   devcb_resolved_write_line   m_out_rts_func;
123   devcb_resolved_write_line   m_out_dtr_func;
124   devcb_resolved_write_line   m_out_txemt_dschg_func;
125   devcb_resolved_write_line   m_out_bkdet_func;
126   devcb_resolved_write_line   m_out_xsync_func;
127
128   UINT8 m_rhr;
129   UINT8 m_thr;
130   UINT8 m_cr;
131   UINT8 m_sr;
132   UINT8 m_mr1;
133   UINT8 m_mr2;
134   UINT8 m_syn1;
135   UINT8 m_syn2;
136   UINT8 m_dle;
137
138   int m_mr_index;
139   int m_sync_index;
140
141   // timers
142   emu_timer *m_rx_timer;
143   emu_timer *m_tx_timer;
144};
145
146
147// device type definition
148extern const device_type SCN2661;
149
150
151
152#endif
src/emu/machine/mc2661.c
r0r15349
1/***************************************************************************
2
3    Motorola MC2661/MC68661 Enhanced Programmable Communications Interface
4
5    Copyright the MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8***************************************************************************/
9
10#include "mc2661.h"
11
12
13
14//**************************************************************************
15//  DEVICE DEFINITIONS
16//**************************************************************************
17
18const device_type MC2661 = &device_creator<mc2661_device>;
19
20
21
22//**************************************************************************
23//  MACROS / CONSTANTS
24//**************************************************************************
25
26#define LOG 0
27
28
29enum
30{
31   REGISTER_HOLDING = 0,
32   REGISTER_STATUS,
33   REGISTER_SYNC = REGISTER_STATUS,
34   REGISTER_MODE,
35   REGISTER_COMMAND
36};
37
38
39#define MODE_BAUD_RATE      (m_mr[0] & 0x03)
40#define MODE_CHARACTER      ((m_mr[0] >> 2) & 0x03)
41#define MODE_PARITY         BIT(m_mr[0], 4)
42#define MODE_PARITY_EVEN   BIT(m_mr[0], 5)
43#define MODE_TRANSPARENT   BIT(m_mr[0], 6)
44#define MODE_SINGLE_SYN      BIT(m_mr[0], 7)
45#define MODE_STOP_BITS      ((m_mr[0] >> 6) & 0x03)
46
47
48enum
49{
50   STOP_BITS_INVALID = 0,
51   STOP_BITS_1,
52   STOP_BITS_1_5,
53   STOP_BITS_2
54};
55
56
57#define SYN1         m_sync[0]
58#define SYN2         m_sync[1]
59#define DLE            m_sync[2]
60
61
62#define COMMAND_TXEN   BIT(m_cr, 0)
63#define COMMAND_DTR      BIT(m_cr, 1)
64#define COMMAND_RXEN   BIT(m_cr, 2)
65#define COMMAND_BREAK   BIT(m_cr, 3)
66#define COMMAND_DLE      BIT(m_cr, 3)
67#define COMMAND_RESET   BIT(m_cr, 4)
68#define COMMAND_RTS      BIT(m_cr, 5)
69#define COMMAND_MODE   (m_cr >> 6)
70
71
72enum
73{
74   MODE_NORMAL = 0,
75   MODE_ASYNC,
76   MODE_LOCAL_LOOP_BACK,
77   MODE_REMOTE_LOOP_BACK
78};
79
80
81#define STATUS_TXRDY   0x01
82#define STATUS_RXRDY   0x02
83#define STATUS_TXEMT   0x04
84#define STATUS_PE      0x08
85#define STATUS_DLE      0x08
86#define STATUS_OVERRUN   0x10
87#define STATUS_FE      0x20
88#define STATUS_SYN      0x20
89#define STATUS_DCD      0x40
90#define STATUS_DSR      0x80
91
92
93
94//**************************************************************************
95//  INLINE HELPERS
96//**************************************************************************
97
98//-------------------------------------------------
99//  receive -
100//-------------------------------------------------
101
102inline void mc2661_device::receive()
103{
104}
105
106
107//-------------------------------------------------
108//  transmit -
109//-------------------------------------------------
110
111inline void mc2661_device::transmit()
112{
113}
114
115
116
117//**************************************************************************
118//  LIVE DEVICE
119//**************************************************************************
120
121//-------------------------------------------------
122//  mc2661_device - constructor
123//-------------------------------------------------
124
125mc2661_device::mc2661_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
126    : device_t(mconfig, MC2661, "MC2661", tag, owner, clock),
127     device_serial_interface(mconfig, *this)
128{
129}
130
131
132//-------------------------------------------------
133//  device_config_complete - perform any
134//  operations now that the configuration is
135//  complete
136//-------------------------------------------------
137
138void mc2661_device::device_config_complete()
139{
140   // inherit a copy of the static data
141   const mc2661_interface *intf = reinterpret_cast<const mc2661_interface *>(static_config());
142   if (intf != NULL)
143      *static_cast<mc2661_interface *>(this) = *intf;
144
145   // or initialize to defaults if none provided
146   else
147   {
148      memset(&m_in_rxd_cb, 0, sizeof(m_in_rxd_cb));
149      memset(&m_out_txd_cb, 0, sizeof(m_out_txd_cb));
150      memset(&m_out_rxrdy_cb, 0, sizeof(m_out_rxrdy_cb));
151      memset(&m_out_txrdy_cb, 0, sizeof(m_out_txrdy_cb));
152      memset(&m_out_rts_cb, 0, sizeof(m_out_rts_cb));
153      memset(&m_out_dtr_cb, 0, sizeof(m_out_dtr_cb));
154      memset(&m_out_txemt_dschg_cb, 0, sizeof(m_out_txemt_dschg_cb));
155      memset(&m_out_bkdet_cb, 0, sizeof(m_out_bkdet_cb));
156      memset(&m_out_xsync_cb, 0, sizeof(m_out_xsync_cb));
157   }
158}
159
160
161//-------------------------------------------------
162//  device_start - device-specific startup
163//-------------------------------------------------
164
165void mc2661_device::device_start()
166{
167   // resolve callbacks
168   m_in_rxd_func.resolve(m_in_rxd_cb, *this);
169   m_out_txd_func.resolve(m_out_txd_cb, *this);
170   m_out_rxrdy_func.resolve(m_out_rxrdy_cb, *this);
171   m_out_txrdy_func.resolve(m_out_txrdy_cb, *this);
172   m_out_rts_func.resolve(m_out_rts_cb, *this);
173   m_out_dtr_func.resolve(m_out_dtr_cb, *this);
174   m_out_txemt_dschg_func.resolve(m_out_txemt_dschg_cb, *this);
175   m_out_bkdet_func.resolve(m_out_bkdet_cb, *this);
176   m_out_xsync_func.resolve(m_out_xsync_cb, *this);
177
178   // create the timers
179   if (m_rxc > 0)
180   {
181      m_rx_timer = timer_alloc(TIMER_RX);
182      m_rx_timer->adjust(attotime::zero, 0, attotime::from_hz(m_rxc));
183   }
184
185   if (m_txc > 0)
186   {
187      m_tx_timer = timer_alloc(TIMER_TX);
188      m_tx_timer->adjust(attotime::zero, 0, attotime::from_hz(m_txc));
189   }
190
191   // save state
192   save_item(NAME(m_rhr));
193   save_item(NAME(m_thr));
194   save_item(NAME(m_cr));
195   save_item(NAME(m_sr));
196   save_item(NAME(m_mr));
197   save_item(NAME(m_sync));
198   save_item(NAME(m_mode_index));
199   save_item(NAME(m_sync_index));
200}
201
202
203//-------------------------------------------------
204//  device_reset - device-specific reset
205//-------------------------------------------------
206
207void mc2661_device::device_reset()
208{
209   transmit_register_reset();
210   receive_register_reset();
211
212   m_mr[0] = m_mr[1] = 0;
213   m_sync[0] = m_sync[1] = m_sync[2] = 0;
214   m_cr = 0;
215   m_sr = 0;
216
217   m_mode_index = 0;
218   m_sync_index = 0;
219
220   m_out_txd_func(1);
221   m_out_rxrdy_func(CLEAR_LINE);
222   m_out_txrdy_func(CLEAR_LINE);
223   m_out_rts_func(1);
224   m_out_dtr_func(1);
225   m_out_txemt_dschg_func(ASSERT_LINE);
226   m_out_bkdet_func(0);
227   m_out_xsync_func(0);
228}
229
230
231//-------------------------------------------------
232//  device_timer - handle timer events
233//-------------------------------------------------
234
235void mc2661_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
236{
237   switch (id)
238   {
239   case TIMER_RX:
240      rxc_w(1);
241      break;
242
243   case TIMER_TX:
244      txc_w(1);
245      break;
246   }
247}
248
249
250//-------------------------------------------------
251//  input_callback -
252//-------------------------------------------------
253
254void mc2661_device::input_callback(UINT8 state)
255{
256}
257
258
259//-------------------------------------------------
260//  read - register read
261//-------------------------------------------------
262
263READ8_MEMBER( mc2661_device::read )
264{
265   UINT8 data = 0;
266
267   switch (offset & 0x03)
268   {
269   case REGISTER_HOLDING:
270      data = m_rhr;
271      break;
272
273   case REGISTER_STATUS:
274      data = m_sr;
275      break;
276
277   case REGISTER_MODE:
278      data = m_mr[m_mode_index];
279
280      m_mode_index++;
281      m_mode_index &= 0x01;
282      break;
283
284   case REGISTER_COMMAND:
285      m_mode_index = 0;
286      m_sync_index = 0;
287
288      data = m_cr;
289      break;
290   }
291
292   return data;
293}
294
295
296//-------------------------------------------------
297//  write - register write
298//-------------------------------------------------
299
300WRITE8_MEMBER( mc2661_device::write )
301{
302   switch (offset & 0x03)
303   {
304   case REGISTER_HOLDING:
305      if (LOG) logerror("MC2661 '%s' Transmit Holding Register: %02x\n", tag(), data);
306
307      m_thr = data;
308      break;
309
310   case REGISTER_SYNC:
311      if (LOG) logerror("MC2661 '%s' Sync Register %u: %02x\n", tag(), m_sync_index + 1, data);
312     
313      m_sync[m_sync_index] = data;
314
315      m_sync_index++;
316      if (m_sync_index == 3) m_sync_index = 0;
317      break;
318
319   case REGISTER_MODE:
320      if (LOG) logerror("MC2661 '%s' Mode Register %u: %02x\n", tag(), m_mode_index + 1, data);
321
322      m_mr[m_mode_index] = data;
323
324      if (m_mode_index == 0)
325      {
326         int word_length = 5 + MODE_CHARACTER;
327         float stop_bits = 0;
328         int parity_code;
329
330         switch (MODE_STOP_BITS)
331         {
332         case STOP_BITS_1:    stop_bits = 1;       break;
333         case STOP_BITS_1_5: stop_bits = 1.5;    break;
334         case STOP_BITS_2:    stop_bits = 2;       break;
335         }
336
337         if (!MODE_PARITY) parity_code = SERIAL_PARITY_NONE;
338         else if (MODE_PARITY_EVEN) parity_code = SERIAL_PARITY_EVEN;
339         else parity_code = SERIAL_PARITY_ODD;
340
341         set_data_frame(word_length, stop_bits, parity_code);         
342      }
343
344      m_mode_index++;
345      m_mode_index &= 0x01;
346      break;
347
348   case REGISTER_COMMAND:
349      if (LOG) logerror("MC2661 '%s' Command Register: %02x\n", tag(), data);
350
351      m_cr = data & 0xef;
352
353      if (COMMAND_RESET)
354      {
355         m_sr &= ~(STATUS_FE | STATUS_OVERRUN | STATUS_PE);
356      }
357
358      m_out_dtr_func(!COMMAND_DTR);
359      m_out_rts_func(!COMMAND_RTS);
360      break;
361   }
362}
363
364
365//-------------------------------------------------
366//  rxc_w - receiver clock
367//-------------------------------------------------
368
369WRITE_LINE_MEMBER( mc2661_device::rxc_w )
370{
371}
372
373
374//-------------------------------------------------
375//  txc_w - transmitter clock
376//-------------------------------------------------
377
378WRITE_LINE_MEMBER( mc2661_device::txc_w )
379{
380}
381
382
383//-------------------------------------------------
384//  dsr_w - data set ready
385//-------------------------------------------------
386
387WRITE_LINE_MEMBER( mc2661_device::dsr_w )
388{
389   if (LOG) logerror("MC2661 '%s' Data Set Ready: %u\n", tag(), state);
390
391   if (state)
392   {
393      m_sr &= ~STATUS_DSR;
394   }
395   else
396   {
397      m_sr |= STATUS_DSR;
398   }
399}
400
401
402//-------------------------------------------------
403//  dcd_w - data carrier detect
404//-------------------------------------------------
405
406WRITE_LINE_MEMBER( mc2661_device::dcd_w )
407{
408   if (LOG) logerror("MC2661 '%s' Data Carrier Detect: %u\n", tag(), state);
409
410   if (state)
411   {
412      m_sr &= ~STATUS_DCD;
413   }
414   else
415   {
416      m_sr |= STATUS_DCD;
417   }
418}
419
420
421//-------------------------------------------------
422//  cts_w - clear to send
423//-------------------------------------------------
424
425WRITE_LINE_MEMBER( mc2661_device::cts_w )
426{
427   if (LOG) logerror("MC2661 '%s' Clear to Send: %u\n", tag(), state);
428}
429
430
431//-------------------------------------------------
432//  rxrdy_r - receiver ready
433//-------------------------------------------------
434
435READ_LINE_MEMBER( mc2661_device::rxrdy_r )
436{
437   return STATUS_RXRDY;
438}
439
440
441//-------------------------------------------------
442//  txemt_r - transmitter empty
443//-------------------------------------------------
444
445READ_LINE_MEMBER( mc2661_device::txemt_r )
446{
447   return STATUS_TXEMT;
448}
src/emu/machine/mc2661.h
r0r15349
1/***************************************************************************
2
3    Motorola MC2661/MC68661 Enhanced Programmable Communications Interface
4
5    Copyright the MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8****************************************************************************
9                            _____   _____
10                    D2   1 |*    \_/     | 28  D1
11                    D3   2 |             | 27  D0
12                   RxD   3 |             | 26  Vcc
13                   GND   4 |             | 25  _RxC/BKDET
14                    D4   5 |             | 24  _DTR
15                    D5   6 |             | 23  _RTS
16                    D6   7 |   MC2661    | 22  _DSR
17                    D7   8 |   MC68661   | 21  RESET
18            _TxC/XSYNC   9 |             | 20  BRCLK
19                    A1  10 |             | 19  TxD
20                   _CE  11 |             | 18  _TxEMT/DSCHG
21                    A0  12 |             | 17  _CTS
22                  _R/W  13 |             | 16  _DCD
23                _RxRDY  14 |_____________| 15  _TxRDY
24
25***************************************************************************/
26
27#pragma once
28
29#ifndef __MC2661__
30#define __MC2661__
31
32#include "emu.h"
33
34
35
36/***************************************************************************
37    DEVICE CONFIGURATION MACROS
38***************************************************************************/
39
40#define MCFG_MC2661_ADD(_tag, _clock, _config) \
41   MCFG_DEVICE_ADD(_tag, MC2661, _clock) \
42   MCFG_DEVICE_CONFIG(_config)
43
44
45#define MC2661_INTERFACE(_name) \
46   const mc2661_interface (_name) =
47
48
49
50/***************************************************************************
51    TYPE DEFINITIONS
52***************************************************************************/
53
54// ======================> mc2661_interface
55
56struct mc2661_interface
57{
58   int m_rxc;
59   int m_txc;
60
61   devcb_read_line      m_in_rxd_cb;
62   devcb_write_line   m_out_txd_cb;
63
64   devcb_write_line   m_out_rxrdy_cb;
65   devcb_write_line   m_out_txrdy_cb;
66   devcb_write_line   m_out_rts_cb;
67   devcb_write_line   m_out_dtr_cb;
68   devcb_write_line   m_out_txemt_dschg_cb;
69   devcb_write_line   m_out_bkdet_cb;
70   devcb_write_line   m_out_xsync_cb;
71};
72
73
74// ======================> mc2661_device
75
76class mc2661_device :  public device_t,
77                   public device_serial_interface,
78                   public mc2661_interface
79{
80public:
81   // construction/destruction
82   mc2661_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
83
84   DECLARE_READ8_MEMBER( read );
85   DECLARE_WRITE8_MEMBER( write );
86
87   DECLARE_WRITE_LINE_MEMBER( rxc_w );
88   DECLARE_WRITE_LINE_MEMBER( txc_w );
89
90   DECLARE_WRITE_LINE_MEMBER( dsr_w );
91   DECLARE_WRITE_LINE_MEMBER( dcd_w );
92   DECLARE_WRITE_LINE_MEMBER( cts_w );
93
94   DECLARE_READ_LINE_MEMBER( rxrdy_r );
95   DECLARE_READ_LINE_MEMBER( txemt_r );
96
97protected:
98   // device-level overrides
99   virtual void device_config_complete();
100   virtual void device_start();
101   virtual void device_reset();
102   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
103
104   // device_serial_interface overrides
105   virtual void input_callback(UINT8 state);
106
107private:
108   inline void receive();
109   inline void transmit();
110
111   enum
112   {
113      TIMER_RX,
114      TIMER_TX
115   };
116
117   devcb_resolved_read_line   m_in_rxd_func;
118   devcb_resolved_write_line   m_out_txd_func;
119
120   devcb_resolved_write_line   m_out_rxrdy_func;
121   devcb_resolved_write_line   m_out_txrdy_func;
122   devcb_resolved_write_line   m_out_rts_func;
123   devcb_resolved_write_line   m_out_dtr_func;
124   devcb_resolved_write_line   m_out_txemt_dschg_func;
125   devcb_resolved_write_line   m_out_bkdet_func;
126   devcb_resolved_write_line   m_out_xsync_func;
127
128   UINT8 m_rhr;
129   UINT8 m_thr;
130   UINT8 m_cr;
131   UINT8 m_sr;
132   UINT8 m_mr[2];
133   UINT8 m_sync[3];
134
135   int m_mode_index;
136   int m_sync_index;
137
138   // timers
139   emu_timer *m_rx_timer;
140   emu_timer *m_tx_timer;
141};
142
143
144// device type definition
145extern const device_type MC2661;
146
147
148
149#endif
src/emu/machine/im6402.c
r15348r15349
2323//  MACROS / CONSTANTS
2424//**************************************************************************
2525 
26#define LOG 1
26#define LOG 0
2727 
2828 
2929 
r15348r15349
6868 
6969 
7070//-------------------------------------------------
71//  receive -
71//  receive_bit -
7272//-------------------------------------------------
7373 
74inline void im6402_device::receive()
74inline void im6402_device::receive_bit(int state)
7575{
76   int bit = 1;
77 
78   if (m_in_rri_func.isnull())
79   {
80      bit = get_in_data_bit();
81   }
82   else
83   {
84      bit = m_in_rri_func();
85   }
86 
87//   if (LOG) logerror("IM6402 '%s' Receive Bit %u\n", tag(), bit);
76   if (LOG) logerror("IM6402 '%s' Receive Bit %u\n", tag(), state);
8877   
89   receive_register_update_bit(bit);
78   receive_register_update_bit(state);
9079 
9180   if (is_receive_register_full())
9281   {
r15348r15349
10190      }
10291 
10392      set_dr(ASSERT_LINE);
93   }   
94}
95 
96 
97//-------------------------------------------------
98//  receive -
99//-------------------------------------------------
100 
101inline void im6402_device::receive()
102{
103   int bit = 1;
104 
105   if (m_in_rri_func.isnull())
106   {
107      bit = get_in_data_bit();
104108   }
109   else
110   {
111      bit = m_in_rri_func();
112   }
113 
114   receive_bit(bit);
105115}
106116 
107117 
r15348r15349
272282 
273283void im6402_device::input_callback(UINT8 state)
274284{
285   int bit = (state & SERIAL_STATE_RX_DATA) ? 1 : 0;
286   
287   receive_bit(bit);
275288}
276289 
277290 
r15348r15349
452465      if (LOG) logerror("IM6402 '%s' Control Register Load\n", tag());
453466 
454467      int word_length = 5 + ((m_cls2 << 1) | m_cls1);
455      int stop_bits = 1 + (m_sbs ? ((word_length == 5) ? 0.5 : 1) : 0);
468      float stop_bits = 1 + (m_sbs ? ((word_length == 5) ? 0.5 : 1) : 0);
456469      int parity_code;
457470 
458471      if (m_pi) parity_code = SERIAL_PARITY_NONE;
src/emu/machine/im6402.h
r15348r15349
126126   inline void set_dr(int state);
127127   inline void set_tbre(int state);
128128   inline void set_tre(int state);
129   inline void receive_bit(int state);
129130   inline void receive();
130131   inline void transmit();
131132 
src/mess/machine/wangpckb.c
r15348r15349
4545 
4646    TODO:
4747 
48    - mcs51.c does not support 9-bit serial I/O
48    - rewrite the mcs51.c serial I/O to replace this horrible, horrible hack
49    - locate keys
4950 
5051*/
5152 
r15348r15349
5758//  MACROS / CONSTANTS
5859//**************************************************************************
5960 
61#define LOG 1
62 
6063#define I8051_TAG      "z5"
6164#define SN76496_TAG      "z4"
6265 
r15348r15349
99102   AM_RANGE(MCS51_PORT_P1, MCS51_PORT_P1) AM_READ(kb_p1_r) AM_WRITENOP
100103   AM_RANGE(MCS51_PORT_P2, MCS51_PORT_P2) AM_WRITE(kb_p2_w)
101104   AM_RANGE(MCS51_PORT_P3, MCS51_PORT_P3) AM_WRITE(kb_p3_w)
102   //AM_RANGE(0x0000, 0xfeff) AM_READNOP
105   AM_RANGE(0x0000, 0xfeff) AM_NOP
103106ADDRESS_MAP_END
104107 
105108 
r15348r15349
396399{
397400    transmit_register_reset();
398401    receive_register_reset();
402     
403    set_out_data_bit(1);
404    serial_connection_out();
399405}
400406 
401407 
402408//-------------------------------------------------
403//  device_timer - handler timer events
404//-------------------------------------------------
405 
406void wangpc_keyboard_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
407{
408}
409 
410 
411//-------------------------------------------------
412409//  input_callback -
413410//-------------------------------------------------
414411 
415412void wangpc_keyboard_device::input_callback(UINT8 state)
416413{
417    //logerror("input %02x\n", state);
418 
419    // receive
420414    int bit = (state & SERIAL_STATE_RX_DATA) ? 1 : 0;
421415 
422    //logerror("inbit %u \n", bit);
423416    receive_register_update_bit(bit);
424417 
425418    if (is_receive_register_full())
426419    {
427420        m_maincpu->set_input_line(MCS51_RX_LINE, ASSERT_LINE);
428421        receive_register_extract();
429        logerror("Wang PC keyboard receive data %02x\n", get_received_char());
422         
423        if (LOG) logerror("Wang PC keyboard receive data %02x\n", get_received_char());
430424    }
431 
432    // transmit
433    if (!is_transmit_register_empty())
434    {
435        transmit_register_get_data_bit();
436        serial_connection_out();
437    }
438425}
439426 
440427 
r15348r15349
458445{
459446   wangpc_keyboard_device *kb = static_cast<wangpc_keyboard_device *>(device->owner());
460447 
461    logerror("Wang PC keyboard transmit data %02x\n", data);
448    if (LOG) logerror("Wang PC keyboard transmit data %02x\n", data);
462449 
463450   kb->transmit_register_setup(data);
451 
452    // HACK bang the bits out immediately
453    while (!kb->is_transmit_register_empty())
454    {
455        kb->transmit_register_send_bit();
456    }
464457}
465458 
466459 
src/mess/machine/wangpckb.h
r15348r15349
8181   virtual void device_config_complete() { m_shortname = "wangpckb"; }
8282    virtual void device_start();
8383   virtual void device_reset();
84   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
8584 
8685   // device_serial_interface overrides
8786   virtual void input_callback(UINT8 state);
src/mess/includes/wangpc.h
r15348r15349
1313#include "machine/pic8259.h"
1414#include "machine/pit8253.h"
1515#include "machine/ram.h"
16#include "machine/scn2661.h"
16#include "machine/mc2661.h"
1717#include "machine/upd765.h"
1818#include "machine/wangpcbus.h"
1919#include "machine/wangpckb.h"
r15348r15349
7474   required_device<i8255_device> m_ppi;
7575   required_device<device_t> m_pit;
7676   required_device<im6402_device> m_uart;
77   required_device<scn2661_device> m_epci;
77   required_device<mc2661_device> m_epci;
7878   required_device<device_t> m_fdc;
7979   required_device<ram_device> m_ram;
8080   required_device<device_t> m_floppy0;
src/mess/drivers/wangpc.c
r15348r15349
1212 
1313   TODO:
1414 
15   - boot
1615   - keyboard
17   - floppy
18   - serial
16   - upd765.c drive polling (POST expects 4 consecutive Sense Interrupt Status commands to return xx,xx,xx,C3 = ready state changed on drive 3)
17   - floppy door disturbed interrupt
18   - floppy door open status
1919   - hard disk
2020 
2121*/
r15348r15349
4343 
4444void wangpc_state::select_drive(int drive, bool select)
4545{
46   if (LOG) logerror("%sselect drive %u\n", select ? "" : "De", drive + 1);
46   if (LOG) logerror("%s: %sselect drive %u\n", machine().describe_context(), select ? "" : "De", drive + 1);
4747 
4848   int state = select ? 0 : 1;
4949 
r15348r15349
5959 
6060void wangpc_state::set_motor(int drive, bool motor)
6161{
62   if (LOG) logerror("Motor %u %s\n", drive + 1, motor ? "on" : "off");
62   if (LOG) logerror("%s: Motor %u %s\n", machine().describe_context(), drive + 1, motor ? "on" : "off");
6363 
6464   int state = motor ? 0 : 1;
6565 
r15348r15349
7575 
7676void wangpc_state::fdc_reset()
7777{
78    if (LOG) logerror("FDC reset\n");
78    if (LOG) logerror("%s: FDC reset\n", machine().describe_context());
7979 
8080   upd765_reset_w(m_fdc, 1);
8181   upd765_reset_w(m_fdc, 0);
r15348r15349
8383 
8484void wangpc_state::fdc_tc()
8585{
86    if (LOG) logerror("FDC TC\n");
86    if (LOG) logerror("%s: FDC TC\n", machine().describe_context());
8787 
8888   upd765_tc_w(m_fdc, 1);
8989   upd765_tc_w(m_fdc, 0);
r15348r15349
109109   m_fdc_tc_enable = BIT(data, 0);
110110   m_fdc_dma_enable = BIT(data, 1);
111111 
112    if (LOG) logerror("Enable /EOP %u\n", m_fdc_tc_enable);
113    if (LOG) logerror("Disable /DREQ2 %u\n", m_fdc_dma_enable);
112    if (LOG) logerror("%s: Enable /EOP %u\n", machine().describe_context(), m_fdc_tc_enable);
113    if (LOG) logerror("%s: Disable /DREQ2 %u\n", machine().describe_context(), m_fdc_dma_enable);
114114 
115115   update_fdc_tc();
116116   update_fdc_drq();
r15348r15349
264264 
265265WRITE8_MEMBER( wangpc_state::dma_page_w )
266266{
267    if (LOG) logerror("DMA page %u: %01x\n", offset, data & 0x0f);
267    if (LOG) logerror("%s: DMA page %u: %01x\n", machine().describe_context(), offset, data & 0x0f);
268268 
269269   m_dma_page[offset] = data & 0x0f;
270270}
r15348r15349
306306 
307307WRITE8_MEMBER( wangpc_state::timer0_irq_clr_w )
308308{
309    //if (LOG) logerror("Timer 0 IRQ clear\n");
309    //if (LOG) logerror("%s: Timer 0 IRQ clear\n", machine().describe_context());
310310 
311311   pic8259_ir0_w(m_pic, CLEAR_LINE);
312312}
r15348r15349
318318 
319319READ8_MEMBER( wangpc_state::timer2_irq_clr_r )
320320{
321    //if (LOG) logerror("Timer 2 IRQ clear\n");
321    //if (LOG) logerror("%s: Timer 2 IRQ clear\n", machine().describe_context());
322322 
323323   m_timer2_irq = 1;
324324   check_level1_interrupts();
r15348r15349
333333 
334334WRITE8_MEMBER( wangpc_state::nmi_mask_w )
335335{
336    if (LOG) logerror("NMI mask %02x\n", data);
336    if (LOG) logerror("%s: NMI mask %02x\n", machine().describe_context(), data);
337337}
338338 
339339 
r15348r15349
343343 
344344READ8_MEMBER( wangpc_state::led_on_r )
345345{
346    if (LOG) logerror("LED on\n");
346    if (LOG) logerror("%s: Diagnostic LED on\n", machine().describe_context());
347347 
348348   output_set_led_value(LED_DIAGNOSTIC, 1);
349349 
r15348r15349
357357 
358358WRITE8_MEMBER( wangpc_state::fpu_mask_w )
359359{
360    if (LOG) logerror("FPU mask %02x\n", data);
360    if (LOG) logerror("%s: FPU mask %02x\n", machine().describe_context(), data);
361361}
362362 
363363 
r15348r15349
367367 
368368WRITE8_MEMBER( wangpc_state::uart_tbre_clr_w  )
369369{
370    if (LOG) logerror("TBRE clear\n");
370    if (LOG) logerror("%s: TBRE clear\n", machine().describe_context());
371371 
372372   m_uart_tbre = 0;
373373   check_level2_interrupts();
r15348r15349
382382{
383383   m_uart_dr = 0;
384384   check_level2_interrupts();
385   
386   UINT8 data = m_uart->read(space, 0);
385387 
386   return m_uart->read(space, 0);
388    if (LOG) logerror("%s: UART read %02x\n", machine().describe_context(), data);
389 
390   return data;
387391}
388392 
389393 
r15348r15349
393397 
394398WRITE8_MEMBER( wangpc_state::uart_w  )
395399{
396    if (LOG) logerror("UART write %02x\n", data);
400    if (LOG) logerror("%s: UART write %02x\n", machine().describe_context(), data);
397401 
398402    switch (data)
399403    {
r15348r15349
457461 
458462READ8_MEMBER( wangpc_state::busy_clr_r )
459463{
460    if (LOG) logerror("BUSY clear\n");
464    if (LOG) logerror("%s: BUSY clear\n", machine().describe_context());
461465 
462466   m_busy = 1;
463467   check_level1_interrupts();
r15348r15349
472476 
473477WRITE8_MEMBER( wangpc_state::acknlg_clr_w )
474478{
475    if (LOG) logerror("ACKNLG clear\n");
479    if (LOG) logerror("%s: ACKNLG clear\n", machine().describe_context());
476480 
477481   m_acknlg = 1;
478482   check_level1_interrupts();
r15348r15349
485489 
486490READ8_MEMBER( wangpc_state::led_off_r )
487491{
488    if (LOG) logerror("LED off\n");
492    if (LOG) logerror("%s: Diagnostic LED off\n", machine().describe_context());
489493 
490494   output_set_led_value(LED_DIAGNOSTIC, 0);
491495 
r15348r15349
499503 
500504WRITE8_MEMBER( wangpc_state::parity_nmi_clr_w )
501505{
502    if (LOG) logerror("Parity NMI clear\n");
506    if (LOG) logerror("%s: Parity NMI clear\n", machine().describe_context());
503507}
504508 
505509 
r15348r15349
572576   AM_RANGE(0x1020, 0x1027) AM_DEVREADWRITE8(I8255A_TAG, i8255_device, read, write, 0x00ff)
573577   AM_RANGE(0x1040, 0x1047) AM_DEVREADWRITE8_LEGACY(I8253_TAG, pit8253_r, pit8253_w, 0x00ff)
574578   AM_RANGE(0x1060, 0x1063) AM_DEVREADWRITE8_LEGACY(I8259A_TAG, pic8259_r, pic8259_w, 0x00ff)
575   AM_RANGE(0x1080, 0x1087) AM_DEVREAD8(SCN2661_TAG, scn2661_device, read, 0x00ff)
576   AM_RANGE(0x1088, 0x108f) AM_DEVWRITE8(SCN2661_TAG, scn2661_device, write, 0x00ff)
579   AM_RANGE(0x1080, 0x1087) AM_DEVREAD8(SCN2661_TAG, mc2661_device, read, 0x00ff)
580   AM_RANGE(0x1088, 0x108f) AM_DEVWRITE8(SCN2661_TAG, mc2661_device, write, 0x00ff)
577581   AM_RANGE(0x10a0, 0x10bf) AM_DEVREADWRITE8_LEGACY(AM9517A_TAG, i8237_r, i8237_w, 0x00ff)
578582   AM_RANGE(0x10c2, 0x10c7) AM_WRITE8(dma_page_w, 0x00ff)
579583   AM_RANGE(0x10e0, 0x10e1) AM_READWRITE8(status_r, timer0_irq_clr_w, 0x00ff)
r15348r15349
969973 
970974static IM6402_INTERFACE( uart_intf )
971975{
976   0, // HACK should be 62500
972977   62500,
973   62500,
974978   DEVCB_NULL,
975979   DEVCB_NULL,
976980   DEVCB_DRIVER_LINE_MEMBER(wangpc_state, uart_dr_w),
r15348r15349
988992   check_level1_interrupts();
989993}
990994 
991static SCN2661_INTERFACE( epci_intf )
995static MC2661_INTERFACE( epci_intf )
992996{
993997   0,
994998   0,
r15348r15349
12121216   MCFG_I8255A_ADD(I8255A_TAG, ppi_intf)
12131217   MCFG_PIT8253_ADD(I8253_TAG, pit_intf)
12141218   MCFG_IM6402_ADD(IM6402_TAG, uart_intf)
1215   MCFG_SCN2661_ADD(SCN2661_TAG, 0, epci_intf)
1219   MCFG_MC2661_ADD(SCN2661_TAG, 0, epci_intf)
12161220   MCFG_UPD765A_ADD(UPD765_TAG, fdc_intf)
12171221   MCFG_LEGACY_FLOPPY_2_DRIVES_ADD(floppy_intf)
12181222   MCFG_CENTRONICS_PRINTER_ADD(CENTRONICS_TAG, centronics_intf)

Previous 15994 Revisions Next


© 1998-2018 The MESS Team