Previous 15994 Revisions Next

r6215 Thursday 29th October, 2009 at 11:23:47 UTC by Dirk Best
[TF20] Connected µPD7201
[src/mess/machine]tf20.c tf20.h upd7201.c upd7201.h

src/mess/machine/upd7201.c
r6214r6215
11/**********************************************************************
22
3    NEC ?PD7201 Multiprotocol Serial Communications Controller emulation
3    NEC µPD7201 Multiprotocol Serial Communications Controller
44
55    Copyright MESS Team.
66    Visit http://mamedev.org for licensing and usage restrictions.
r6214r6215
1010#include "driver.h"
1111#include "upd7201.h"
1212
13
1314/***************************************************************************
1415    PARAMETERS
1516***************************************************************************/
r6214r6215
1920    TYPE DEFINITIONS
2021***************************************************************************/
2122
22typedef struct _upd7201_t upd7201_t;
23struct _upd7201_t
23typedef struct _upd7201_state upd7201_state;
24struct _upd7201_state
2425{
25   int dummy;
26   devcb_resolved_write_line out_int_func;
2627};
2728
29
2830/***************************************************************************
2931    INLINE FUNCTIONS
3032***************************************************************************/
3133
32INLINE upd7201_t *get_safe_token(const device_config *device)
34INLINE upd7201_state *get_safe_token(const device_config *device)
3335{
3436   assert(device != NULL);
3537   assert(device->token != NULL);
38   assert(device->type == UPD7201);
3639
37   return (upd7201_t *)device->token;
40   return (upd7201_state *)device->token;
3841}
3942
40INLINE const upd7201_interface *get_interface(const device_config *device)
41{
42   assert(device != NULL);
43   assert((device->type == UPD7201));
44   return (const upd7201_interface *) device->static_config;
45}
4643
4744/***************************************************************************
4845    IMPLEMENTATION
r6214r6215
8885{
8986}
9087
88WRITE_LINE_DEVICE_HANDLER( upd7201_ctsa_w )
89{
90
91}
92
93WRITE_LINE_DEVICE_HANDLER( upd7201_ctsb_w )
94{
95
96}
97
98/* data terminal ready a, hold acknowledge output */
99READ_LINE_DEVICE_HANDLER( upd7201_dtra_r )
100{
101   return 0;
102}
103
104/* data terminal ready b */
105READ_LINE_DEVICE_HANDLER( upd7201_dtrb_r )
106{
107   return 0;
108}
109
110/* hold acknowledge input (same pin as dtrb) */
111WRITE_LINE_DEVICE_HANDLER( upd7201_hoi_w )
112{
113
114}
115
116WRITE_LINE_DEVICE_HANDLER( upd7201_rxda_w )
117{
118
119}
120
121READ_LINE_DEVICE_HANDLER( upd7201_txda_r )
122{
123   return 0;
124}
125
126WRITE_LINE_DEVICE_HANDLER( upd7201_rxdb_w )
127{
128
129}
130
131READ_LINE_DEVICE_HANDLER( upd7201_txdb_r )
132{
133   return 0;
134}
135
91136WRITE_LINE_DEVICE_HANDLER( upd7201_rxca_w )
92137{
93138}
r6214r6215
104149{
105150}
106151
107/*-------------------------------------------------
108    DEVICE_START( upd7201 )
109-------------------------------------------------*/
110152
153/*****************************************************************************
154    DEVICE INTERFACE
155*****************************************************************************/
156
111157static DEVICE_START( upd7201 )
112158{
113//  upd7201_t *upd7201 = get_safe_token(device);
114//  const upd7201_interface *intf = get_interface(device);
159   upd7201_state *upd7201 = get_safe_token(device);
160   const upd7201_interface *intf = device->static_config;
115161
162   assert(device->static_config != NULL);
163
116164   /* resolve callbacks */
165   devcb_resolve_write_line(&upd7201->out_int_func, &intf->out_int_func, device);
117166
118   /* set initial values */
119
120167   /* create the timers */
121168
122169   /* register for state saving */
123170//  state_save_register_device_item(device, 0, upd7201->);
124171}
125172
126/*-------------------------------------------------
127    DEVICE_GET_INFO( upd7201 )
128-------------------------------------------------*/
173static DEVICE_RESET( upd7201 )
174{
175   /* set initial values */
176}
129177
130178DEVICE_GET_INFO( upd7201 )
131179{
132180   switch (state)
133181   {
134182      /* --- the following bits of info are returned as 64-bit signed integers --- */
135      case DEVINFO_INT_TOKEN_BYTES:               info->i = sizeof(upd7201_t);            break;
183      case DEVINFO_INT_TOKEN_BYTES:               info->i = sizeof(upd7201_state);         break;
136184      case DEVINFO_INT_INLINE_CONFIG_BYTES:         info->i = 0;                        break;
137185      case DEVINFO_INT_CLASS:                     info->i = DEVICE_CLASS_PERIPHERAL;         break;
138186
139187      /* --- the following bits of info are returned as pointers to data or functions --- */
140188      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(upd7201);   break;
141189      case DEVINFO_FCT_STOP:                     /* Nothing */                        break;
142      case DEVINFO_FCT_RESET:                     /* Nothing */                        break;
190      case DEVINFO_FCT_RESET:                     info->start = DEVICE_RESET_NAME(upd7201);   break;
143191
144192      /* --- the following bits of info are returned as NULL-terminated strings --- */
145193      case DEVINFO_STR_NAME:                     strcpy(info->s, "NEC ?PD7201");            break;
src/mess/machine/upd7201.h
r6214r6215
11/**********************************************************************
22
3    NEC ?PD7201 Multiprotocol Serial Communications Controller emulation
3    NEC µPD7201 Multiprotocol Serial Communications Controller
44
55    Copyright MESS Team.
66    Visit http://mamedev.org for licensing and usage restrictions.
r6214r6215
3030
3131**********************************************************************/
3232
33#ifndef __UPD7201__
34#define __UPD7201__
33#ifndef __UPD7201_H__
34#define __UPD7201_H__
3535
3636#include "devcb.h"
3737
r6214r6215
9393READ8_DEVICE_HANDLER( upd7201_ba_cd_r );
9494WRITE8_DEVICE_HANDLER( upd7201_ba_cd_w );
9595
96/* hold acknowledge input */
97READ8_DEVICE_HANDLER( upd7201_hai_r );
98WRITE8_DEVICE_HANDLER( upd7201_hai_w );
99
10096/* interrupt acknowledge */
10197READ8_DEVICE_HANDLER( upd7201_intak_r );
10298
r6214r6215
104100WRITE_LINE_DEVICE_HANDLER( upd7201_synca_w );
105101WRITE_LINE_DEVICE_HANDLER( upd7201_syncb_w );
106102
103/* clear to send */
104WRITE_LINE_DEVICE_HANDLER( upd7201_ctsa_w );
105WRITE_LINE_DEVICE_HANDLER( upd7201_ctsb_w );
106
107/* data terminal ready, hold acknowledge */
108READ_LINE_DEVICE_HANDLER( upd7201_dtra_r );
109READ_LINE_DEVICE_HANDLER( upd7201_dtrb_r );
110WRITE_LINE_DEVICE_HANDLER( upd7201_hoi_w );
111
112/* serial data */
113WRITE_LINE_DEVICE_HANDLER( upd7201_rxda_w );
114READ_LINE_DEVICE_HANDLER( upd7201_txda_r );
115WRITE_LINE_DEVICE_HANDLER( upd7201_rxdb_w );
116READ_LINE_DEVICE_HANDLER( upd7201_txdb_r );
117
107118/* clock inputs */
108119WRITE_LINE_DEVICE_HANDLER( upd7201_rxca_w );
109120WRITE_LINE_DEVICE_HANDLER( upd7201_rxcb_w );
110121WRITE_LINE_DEVICE_HANDLER( upd7201_txca_w );
111122WRITE_LINE_DEVICE_HANDLER( upd7201_txcb_w );
112123
113#endif
124
125#endif   /* __UPD7201_H__ */
src/mess/machine/tf20.c
r6214r6215
5656    IMPLEMENTATION
5757***************************************************************************/
5858 
59/* serial clock, 38400 baud by default */
60static TIMER_DEVICE_CALLBACK( serial_clock )
61{
62   tf20_state *tf20 = get_safe_token(timer->owner);
63 
64   upd7201_rxca_w(tf20->upd7201, ASSERT_LINE);
65   upd7201_txca_w(tf20->upd7201, ASSERT_LINE);
66   upd7201_rxcb_w(tf20->upd7201, ASSERT_LINE);
67   upd7201_txcb_w(tf20->upd7201, ASSERT_LINE);
68}
69 
5970/* a read from this location disables the rom */
6071static READ8_HANDLER( tf20_rom_disable )
6172{
r6214r6215
8293   /* bit 0, motor on signal */
8394}
8495 
96 
97/***************************************************************************
98    EXTERNAL INTERFACE
99***************************************************************************/
100 
85101/* serial output signal (to the host computer) */
86102READ_LINE_DEVICE_HANDLER( tf20_rxs_r )
87103{
104   tf20_state *tf20 = get_safe_token(device);
88105   logerror("%s: tf20_rxs_r\n", cpuexec_describe_context(device->machine));
89106 
90   return 0;
107   return upd7201_txda_r(tf20->upd7201);
91108}
92109 
93110READ_LINE_DEVICE_HANDLER( tf20_pins_r )
94111{
112   tf20_state *tf20 = get_safe_token(device);
95113   logerror("%s: tf20_pins_r\n", cpuexec_describe_context(device->machine));
96114 
97   return 0;
115   return upd7201_dtra_r(tf20->upd7201);
98116}
99117 
100118/* serial input signal (from host computer) */
101119WRITE_LINE_DEVICE_HANDLER( tf20_txs_w )
102120{
121   tf20_state *tf20 = get_safe_token(device);
103122   logerror("%s: tf20_rxd1_w %u\n", cpuexec_describe_context(device->machine), state);
123 
124   upd7201_rxda_w(tf20->upd7201, state);
104125}
105126 
106127WRITE_LINE_DEVICE_HANDLER( tf20_pouts_w )
107128{
129   tf20_state *tf20 = get_safe_token(device);
108130   logerror("%s: tf20_pouts_w %u\n", cpuexec_describe_context(device->machine), state);
131 
132   upd7201_ctsa_w(tf20->upd7201, state);
109133}
110134 
111135/* serial output signal (to another terminal) */
112READ_LINE_DEVICE_HANDLER( tf20_txc_r )
136WRITE_LINE_DEVICE_HANDLER( tf20_txc_w )
113137{
114   logerror("%s: tf20_txc_r\n", cpuexec_describe_context(device->machine));
138   tf20_state *tf20 = get_safe_token(device);
139   logerror("%s: tf20_txc_w %u\n", cpuexec_describe_context(device->machine), state);
115140 
116   return 0;
141   upd7201_rxda_w(tf20->upd7201, state);
117142}
118143 
119144/* serial input signal (from another terminal) */
120WRITE_LINE_DEVICE_HANDLER( tf20_rxc_w )
145READ_LINE_DEVICE_HANDLER( tf20_rxc_r )
121146{
122   logerror("%s: tf20_rxc_w %u\n", cpuexec_describe_context(device->machine), state);
147   tf20_state *tf20 = get_safe_token(device);
148   logerror("%s: tf20_rxc_r\n", cpuexec_describe_context(device->machine));
149 
150   return upd7201_txda_r(tf20->upd7201);
123151}
124152 
125READ_LINE_DEVICE_HANDLER( tf20_poutc_r )
153WRITE_LINE_DEVICE_HANDLER( tf20_poutc_w )
126154{
127   logerror("%s: tf20_poutc_r\n", cpuexec_describe_context(device->machine));
155   tf20_state *tf20 = get_safe_token(device);
156   logerror("%s: tf20_poutc_w %u\n", cpuexec_describe_context(device->machine), state);
128157 
129   return 0;
158   upd7201_ctsa_w(tf20->upd7201, state);
130159}
131160 
132WRITE_LINE_DEVICE_HANDLER( tf20_pinc_w )
161READ_LINE_DEVICE_HANDLER( tf20_pinc_r )
133162{
134   logerror("%s: tf20_pinc_w %u\n", cpuexec_describe_context(device->machine), state);
163   tf20_state *tf20 = get_safe_token(device);
164   logerror("%s: tf20_pinc_r\n", cpuexec_describe_context(device->machine));
165 
166   return upd7201_dtra_r(tf20->upd7201);
135167}
136168 
137169 
r6214r6215
229261 
230262   /* upd7201 serial interface */
231263   MDRV_UPD7201_ADD("3a", XTAL_CR1 / 2, tf20_upd7201_intf)
264   MDRV_TIMER_ADD_PERIODIC("serial_timer", serial_clock, HZ(XTAL_CR2 / 128))
232265 
233266   /* 2 floppy drives */
234267   MDRV_FLOPPY_2_DRIVES_ADD(tf20_floppy_config)
r6214r6215
253286{
254287   tf20_state *tf20 = get_safe_token(device);
255288 
289   /* ram device */
290   tf20->ram = device_find_child_by_tag(device, "ram");
291 
292   /* make sure its already running */
293   if (!tf20->ram->started)
294   {
295      device_delay_init(device);
296      return;
297   }
298 
256299   /* locate child devices */
257   tf20->ram = device_find_child_by_tag(device, "ram");
258300   tf20->upd765a = device_find_child_by_tag(device, "5a");
259301   tf20->upd7201 = device_find_child_by_tag(device, "3a");
260302 
src/mess/machine/tf20.h
r6214r6215
3131DEVICE_GET_INFO( tf20 );
3232 
3333/* serial interface in (to the host computer) */
34WRITE_LINE_DEVICE_HANDLER( tf20_txs_w );
3435READ_LINE_DEVICE_HANDLER( tf20_rxs_r );
36WRITE_LINE_DEVICE_HANDLER( tf20_pouts_w );
3537READ_LINE_DEVICE_HANDLER( tf20_pins_r );
36WRITE_LINE_DEVICE_HANDLER( tf20_txs_w );
37WRITE_LINE_DEVICE_HANDLER( tf20_pouts_w );
3838 
3939/* serial interface out (to another terminal) */
40READ_LINE_DEVICE_HANDLER( tf20_txc_r );
41WRITE_LINE_DEVICE_HANDLER( tf20_rxc_w );
42READ_LINE_DEVICE_HANDLER( tf20_poutc_r );
43WRITE_LINE_DEVICE_HANDLER( tf20_pinc_w );
40WRITE_LINE_DEVICE_HANDLER( tf20_txc_r );
41READ_LINE_DEVICE_HANDLER( tf20_rxc_w );
42WRITE_LINE_DEVICE_HANDLER( tf20_poutc_r );
43READ_LINE_DEVICE_HANDLER( tf20_pinc_w );
4444 
4545 
4646/***************************************************************************

Previous 15994 Revisions Next


© 1998-2018 The MESS Team