Previous 199869 Revisions Next

r26274 Monday 18th November, 2013 at 21:05:30 UTC by O. Galibert
diserial: Remove defines, cleanup clocks/timers, add sync support [O. Galibert]
[src/emu]diserial.c diserial.h
[src/emu/imagedev]midiin.c midiout.c midiout.h serial.c
[src/emu/machine]i8251.c i8251.h im6402.c im6402.h ins8250.c ins8250.h mc2661.c mc2661.h mc68901.c mc68901.h microtch.c microtch.h mos6551.c mos6551.h n68681.c n68681.h z80dart.c z80dart.h z80sti.c
[src/mame/machine]midikbd.c
[src/mess/drivers]atarist.c pc.c rainbow.c thomson.c x68k.c
[src/mess/machine]esqpanel.c esqpanel.h isa_sblaster.c keyboard.c keyboard.h ser_mouse.c ser_mouse.h terminal.c thomson.c wangpckb.c zx8302.c

trunk/src/mame/machine/midikbd.c
r26273r26274
7676
7777void midi_keyboard_device::device_start()
7878{
79   set_data_frame(8, 1, SERIAL_PARITY_NONE); //8N1?
79   set_data_frame(8, 1, PARITY_NONE, false); //8N1?
8080   set_tra_rate(clock());
8181   m_out_tx_func.resolve_safe();
8282   m_head = m_tail = 0;
trunk/src/emu/diserial.h
r26273r26274
77#ifndef __DISERIAL_H__
88#define __DISERIAL_H__
99
10//**************************************************************************
11//  TYPE DEFINITIONS
12//**************************************************************************
13/* parity selections */
14/* if all the bits are added in a byte, if the result is:
15    even -> parity is even
16    odd -> parity is odd
17*/
18enum
19{
20   SERIAL_PARITY_NONE,     /* no parity. a parity bit will not be in the transmitted/received data */
21   SERIAL_PARITY_ODD,      /* odd parity */
22   SERIAL_PARITY_EVEN,     /* even parity */
23   SERIAL_PARITY_MARK,     /* one parity */
24   SERIAL_PARITY_SPACE     /* zero parity */
25};
26
27/*
28    CTS = Clear to Send. (INPUT)
29    Other end of connection is ready to accept data
30
31
32    NOTE:
33
34      This output is active low on serial chips (e.g. 0 is CTS is set),
35      but here it is active high!
36*/
37#define SERIAL_STATE_CTS    0x0001
38
39/*
40    RTS = Request to Send. (OUTPUT)
41    This end is ready to send data, and requests if the other
42    end is ready to accept it
43
44    NOTE:
45
46      This output is active low on serial chips (e.g. 0 is RTS is set),
47      but here it is active high!
48*/
49#define SERIAL_STATE_RTS    0x0002
50
51/*
52    DSR = Data Set ready. (INPUT)
53    Other end of connection has data
54
55
56    NOTE:
57
58      This output is active low on serial chips (e.g. 0 is DSR is set),
59      but here it is active high!
60*/
61#define SERIAL_STATE_DSR    0x0004
62
63/*
64    DTR = Data terminal Ready. (OUTPUT)
65    TX contains new data.
66
67    NOTE:
68
69      This output is active low on serial chips (e.g. 0 is DTR is set),
70      but here it is active high!
71*/
72#define SERIAL_STATE_DTR    0x0008
73/* RX = Recieve data. (INPUT) */
74#define SERIAL_STATE_RX_DATA    0x00010
75/* TX = Transmit data. (OUTPUT) */
76#define SERIAL_STATE_TX_DATA    0x00020
77
7810// ======================> device_serial_interface
7911class device_serial_interface : public device_interface
8012{
8113public:
14   /* parity selections */
15   /* if all the bits are added in a byte, if the result is:
16      even -> parity is even
17      odd -> parity is odd
18   */
19   enum
20   {
21      PARITY_NONE,     /* no parity. a parity bit will not be in the transmitted/received data */
22      PARITY_ODD,      /* odd parity */
23      PARITY_EVEN,     /* even parity */
24      PARITY_MARK,     /* one parity */
25      PARITY_SPACE     /* zero parity */
26   };
27
28   /* Communication lines.  Beware, everything is active high */
29   enum
30   {
31      CTS = 0x0001, /* Clear to Send.       (INPUT)  Other end of connection is ready to accept data */
32      RTS = 0x0002, /* Request to Send.     (OUTPUT) This end is ready to send data, and requests if the other */
33                    /*                               end is ready to accept it */
34      DSR = 0x0004, /* Data Set ready.      (INPUT)  Other end of connection has data */
35      DTR = 0x0008, /* Data terminal Ready. (OUTPUT) TX contains new data. */
36      RX  = 0x0010, /* Recieve data.        (INPUT)  */
37      TX  = 0x0020  /* TX = Transmit data.  (OUTPUT) */
38   };
39
8240   // construction/destruction
8341   device_serial_interface(const machine_config &mconfig, device_t &device);
8442   virtual ~device_serial_interface();
8543
8644   virtual void input_callback(UINT8 state) = 0;
8745
88   void set_data_frame(int num_data_bits, int stop_bit_count, int parity_code);
46   void set_data_frame(int num_data_bits, int stop_bit_count, int parity_code, bool synchronous);
8947
9048   void receive_register_reset();
9149   void receive_register_update_bit(int bit);
r26273r26274
10159   void set_rate(UINT32 clock, int div) { set_rcv_rate(clock, div); set_tra_rate(clock, div); }
10260   void set_rate(int baud) { set_rcv_rate(baud); set_tra_rate(baud); }
10361
104   void tra_clock();
105   void rcv_clock();
62   DECLARE_WRITE_LINE_MEMBER(tx_clock_w);
63   DECLARE_WRITE_LINE_MEMBER(rx_clock_w);
64   DECLARE_WRITE_LINE_MEMBER(clock_w);
10665
10766   void transmit_register_reset();
10867   void transmit_register_add_bit(int bit);
r26273r26274
11271
11372   UINT8 serial_helper_get_parity(UINT8 data) { return m_serial_parity_table[data]; }
11473
115   UINT8 get_in_data_bit()  { return ((m_input_state & SERIAL_STATE_RX_DATA)>>4) & 1; }
116   void set_out_data_bit(UINT8 data)  { m_connection_state &=~SERIAL_STATE_TX_DATA; m_connection_state |=(data<<5); }
74   UINT8 get_in_data_bit()  { return ((m_input_state & RX)>>4) & 1; }
75   void set_out_data_bit(UINT8 data)  { m_connection_state &= ~TX; m_connection_state |=(data<<5); }
11776
11877   void serial_connection_out();
11978
r26273r26274
13695
13796   // interface-level overrides
13897   virtual void interface_pre_start();
98
99   // Must be called from device_timer in the underlying device
100   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
101
139102private:
140   void tra_timer(void *ptr, int param);
141   void rcv_timer(void *ptr, int param);
103   enum { TRA_TIMER_ID = 10000, RCV_TIMER_ID };
142104
143105   UINT8 m_serial_parity_table[256];
144106
r26273r26274
149111   UINT8 m_df_parity;
150112   // number of stop bits
151113   UINT8 m_df_stop_bit_count;
114   // synchronous or not
115   bool m_synchronous;
152116
153117   // Receive register
154118   /* data */
r26273r26274
178142   attotime m_tra_rate;
179143   UINT8 m_rcv_line;
180144
145   bool m_tra_clock_state, m_rcv_clock_state;
146
181147   device_serial_interface *m_other_connection;
148
149   void tra_edge();
150   void rcv_edge();
182151};
183152
184153
185154class serial_source_device :  public device_t,
186                        public device_serial_interface
155                       public device_serial_interface
187156{
188157public:
189158   // construction/destruction
r26273r26274
194163protected:
195164   // device-level overrides
196165   virtual void device_start();
166   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
197167};
198168
199169extern const device_type SERIAL_SOURCE;
trunk/src/emu/imagedev/midiin.c
r26273r26274
4646   // we don't Rx, we Tx at 31250 8-N-1
4747   set_rcv_rate(0);
4848   set_tra_rate(31250);
49   set_data_frame(8, 1, SERIAL_PARITY_NONE);
49   set_data_frame(8, 1, PARITY_NONE, false);
5050}
5151
5252/*-------------------------------------------------
r26273r26274
7373
7474void midiin_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
7575{
76   if (id) {
77      device_serial_interface::device_timer(timer, id, param, ptr);
78      return;
79   }
80
7681   UINT8 buf[8192*4];
7782   int bytesRead;
7883
trunk/src/emu/imagedev/midiout.c
r26273r26274
4040   // we don't Tx, we Rx at 31250 8-N-1
4141   set_rcv_rate(31250);
4242   set_tra_rate(0);
43   set_data_frame(8, 1, SERIAL_PARITY_NONE);
43   set_data_frame(8, 1, PARITY_NONE, false);
4444}
4545
46void midiout_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
47{
48   device_serial_interface::device_timer(timer, id, param, ptr);
49}
50
4651/*-------------------------------------------------
4752    device_config_complete
4853-------------------------------------------------*/
trunk/src/emu/imagedev/midiout.h
r26273r26274
5252   // device-level overrides
5353   virtual void device_start();
5454   virtual void device_reset();
55   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
5556
5657   virtual void device_config_complete();
5758
trunk/src/emu/imagedev/serial.c
r26273r26274
5151      m_baud_rate = 2400;
5252      m_data_bits = 8;
5353      m_stop_bits = 2;
54      m_parity = SERIAL_PARITY_NONE;
54      m_parity = PARITY_NONE;
5555      m_transmit_on_start = FALSE;
5656      m_tag_connected = NULL;
5757   }
r26273r26274
8080
8181void serial_image_device::device_start()
8282{
83   set_data_frame(m_data_bits, m_stop_bits,m_parity);
83   set_data_frame(m_data_bits, m_stop_bits, m_parity, false);
8484
8585   m_timer = machine().scheduler().timer_alloc(FUNC(serial_device_baud_rate_callback), this);
8686
8787   /* signal to other end it is clear to send! */
8888   /* data is initially high state */
8989   /* set /rts */
90   m_connection_state |= SERIAL_STATE_RTS;
90   m_connection_state |= RTS;
9191   /* signal to other end data is ready to be accepted */
9292   /* set /dtr */
93   m_connection_state |= SERIAL_STATE_DTR;
93   m_connection_state |= DTR;
9494
9595   set_out_data_bit(1);
9696   serial_connection_out();
r26273r26274
241241   }
242242
243243   /* other side says it is clear to send? */
244   if (m_connection_state & SERIAL_STATE_CTS)
244   if (m_connection_state & CTS)
245245   {
246246      /* send bit */
247247      transmit_register_send_bit();
trunk/src/emu/machine/mc68901.c
r26273r26274
800800
801801void mc68901_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
802802{
803   timer_count(id);
803   if(id >= TIMER_A && id <= TIMER_D)
804      timer_count(id);
805   else
806      device_serial_interface::device_timer(timer, id, param, ptr);
804807}
805808
806809
r26273r26274
12271230
12281231   case REGISTER_UCR:
12291232      {
1230      int parity_code = SERIAL_PARITY_NONE;
1233      int parity_code = PARITY_NONE;
12311234
12321235      if (data & UCR_PARITY_ENABLED)
12331236      {
r26273r26274
12351238         {
12361239            if (LOG) logerror("MC68901 '%s' Parity : Even\n", tag());
12371240
1238            parity_code = SERIAL_PARITY_EVEN;
1241            parity_code = PARITY_EVEN;
12391242         }
12401243         else
12411244         {
12421245            if (LOG) logerror("MC68901 '%s' Parity : Odd\n", tag());
12431246
1244            parity_code = SERIAL_PARITY_ODD;
1247            parity_code = PARITY_ODD;
12451248         }
12461249      }
12471250      else
r26273r26274
12591262
12601263      if (LOG) logerror("MC68901 '%s' Word Length : %u bits\n", tag(), m_rxtx_word);
12611264
1265      bool sync = false;
12621266      switch (data & 0x18)
12631267      {
12641268      case UCR_START_STOP_0_0:
12651269         m_rxtx_start = 0;
12661270         m_rxtx_stop = 0;
1271         sync = true;
12671272         if (LOG) logerror("MC68901 '%s' Start Bits : 0, Stop Bits : 0, Format : synchronous\n", tag());
12681273         break;
12691274      case UCR_START_STOP_1_1:
r26273r26274
12921297         if (LOG) logerror("MC68901 '%s' Rx/Tx Clock Divisor : 1\n", tag());
12931298      }
12941299
1295      set_data_frame(m_rxtx_word, m_rxtx_stop, parity_code);
1300      set_data_frame(m_rxtx_word, m_rxtx_stop, parity_code, sync);
12961301
12971302      m_ucr = data;
12981303      }
r26273r26274
14341439{
14351440   timer_input(TIMER_B, state);
14361441}
1437
1438
1439WRITE_LINE_MEMBER( mc68901_device::rc_w )
1440{
1441   if (state)
1442   {
1443      rcv_clock();
1444   }
1445}
1446
1447
1448WRITE_LINE_MEMBER( mc68901_device::tc_w )
1449{
1450   if (state)
1451   {
1452      tra_clock();
1453   }
1454}
trunk/src/emu/machine/microtch.c
r26273r26274
292292void microtouch_serial_device::device_start()
293293{
294294   microtouch_device::device_start();
295   set_data_frame(8, 1, SERIAL_PARITY_NONE); //8N1?
295   set_data_frame(8, 1, PARITY_NONE, false); //8N1?
296296   set_tra_rate(clock());
297297   set_rcv_rate(clock());
298298   m_out_stx_func.resolve_safe();
r26273r26274
302302   save_item(NAME(m_output));
303303}
304304
305void microtouch_serial_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
306{
307   if(id)
308      device_serial_interface::device_timer(timer, id, param, ptr);
309   else
310      microtouch_device::device_timer(timer, id, param, ptr);
311}
312
305313void microtouch_serial_device::tx(UINT8 data)
306314{
307315   m_output = data;
trunk/src/emu/machine/mc68901.h
r26273r26274
122122   DECLARE_WRITE_LINE_MEMBER( tai_w );
123123   DECLARE_WRITE_LINE_MEMBER( tbi_w );
124124
125   DECLARE_WRITE_LINE_MEMBER( rc_w );
126   DECLARE_WRITE_LINE_MEMBER( tc_w );
127
128125protected:
129126   // device-level overrides
130127   virtual void device_config_complete();
trunk/src/emu/machine/microtch.h
r26273r26274
7777   DECLARE_WRITE_LINE_MEMBER(rx) { device_serial_interface::rx_w(state); }
7878protected:
7979   virtual void device_start();
80   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
8081   virtual void tx(UINT8 data);
8182   virtual void input_callback(UINT8 state) { m_input_state = state; }
8283   virtual void tra_callback();
trunk/src/emu/machine/i8251.c
r26273r26274
4040   m_input_state = state;
4141
4242   /* did cts change state? */
43   if (changed & SERIAL_STATE_CTS)
43   if (changed & CTS)
4444   {
4545      /* yes */
4646      /* update tx ready */
r26273r26274
208208         //transmit_register_send_bit();
209209         m_out_txd_func(data);
210210
211         m_connection_state &=~SERIAL_STATE_TX_DATA;
211         m_connection_state &= ~TX;
212212         m_connection_state|=(data<<5);
213213         serial_connection_out();
214214      }
r26273r26274
265265   if ((m_command & (1<<0))!=0)
266266   {
267267      /* other side has rts set (comes in as CTS at this side) */
268      if (m_input_state & SERIAL_STATE_CTS)
268      if (m_input_state & CTS)
269269      {
270270         if (m_status & I8251_STATUS_TX_EMPTY)
271271         {
r26273r26274
313313   set_out_data_bit(1);
314314
315315   /* assumption, rts is set to 1 */
316   m_connection_state &= ~SERIAL_STATE_RTS;
316   m_connection_state &= ~RTS;
317317   serial_connection_out();
318318
319319   transmit_register_reset();
r26273r26274
406406
407407            LOG(("Character length: %d\n", (((data>>2) & 0x03)+5)));
408408
409            int parity = SERIAL_PARITY_NONE;
409            int parity = PARITY_NONE;
410410
411411            if (data & (1<<4))
412412            {
r26273r26274
415415               if (data & (1<<5))
416416               {
417417                  LOG(("even parity\n"));
418                  parity = SERIAL_PARITY_EVEN;
418                  parity = PARITY_EVEN;
419419               }
420420               else
421421               {
422422                  LOG(("odd parity\n"));
423                  parity = SERIAL_PARITY_ODD;
423                  parity = PARITY_ODD;
424424               }
425425            }
426426            else
r26273r26274
478478                  stop_bit_count =  2;
479479                  break;
480480            }
481            set_data_frame(word_length,stop_bit_count,parity);
481            set_data_frame(word_length,stop_bit_count,parity,false);
482482
483483            switch (data & 0x03)
484484            {
r26273r26274
624624              1 = transmit enable
625625      */
626626
627      m_connection_state &=~SERIAL_STATE_RTS;
627      m_connection_state &= ~RTS;
628628      if (data & (1<<5))
629629      {
630630         /* rts set to 0 */
631         m_connection_state |= SERIAL_STATE_RTS;
631         m_connection_state |= RTS;
632632      }
633633
634      m_connection_state &=~SERIAL_STATE_DTR;
634      m_connection_state &= ~DTR;
635635      if (data & (1<<1))
636636      {
637         m_connection_state |= SERIAL_STATE_DTR;
637         m_connection_state |= DTR;
638638      }
639639
640640      if ((data & (1<<0))==0)
r26273r26274
741741   update_rx_ready();
742742   return m_data;
743743}
744
745
746void i8251_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
747{
748   device_serial_interface::device_timer(timer, id, param, ptr);
749}
trunk/src/emu/machine/i8251.h
r26273r26274
9393   virtual void device_start();
9494   virtual void device_config_complete();
9595   virtual void device_reset();
96   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
9697
9798   void update_rx_ready();
9899   void update_tx_ready();
trunk/src/emu/machine/mc2661.c
r26273r26274
339339         case STOP_BITS_2:   stop_bits = 2;      break;
340340         }
341341
342         if (!MODE_PARITY) parity_code = SERIAL_PARITY_NONE;
343         else if (MODE_PARITY_EVEN) parity_code = SERIAL_PARITY_EVEN;
344         else parity_code = SERIAL_PARITY_ODD;
342         if (!MODE_PARITY) parity_code = PARITY_NONE;
343         else if (MODE_PARITY_EVEN) parity_code = PARITY_EVEN;
344         else parity_code = PARITY_ODD;
345345
346         set_data_frame(word_length, stop_bits, parity_code);
346         set_data_frame(word_length, stop_bits, parity_code, false);
347347      }
348348
349349      m_mode_index++;
r26273r26274
366366   }
367367}
368368
369
370369//-------------------------------------------------
371//  rxc_w - receiver clock
372//-------------------------------------------------
373
374WRITE_LINE_MEMBER( mc2661_device::rxc_w )
375{
376   rcv_clock();
377}
378
379
380//-------------------------------------------------
381//  txc_w - transmitter clock
382//-------------------------------------------------
383
384WRITE_LINE_MEMBER( mc2661_device::txc_w )
385{
386   tra_clock();
387}
388
389
390//-------------------------------------------------
391370//  dsr_w - data set ready
392371//-------------------------------------------------
393372
r26273r26274
453432{
454433   return (m_sr & STATUS_TXEMT) ? ASSERT_LINE : CLEAR_LINE;
455434}
435
436
437void mc2661_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
438{
439   device_serial_interface::device_timer(timer, id, param, ptr);
440}
trunk/src/emu/machine/mc2661.h
r26273r26274
8686   DECLARE_READ8_MEMBER( read );
8787   DECLARE_WRITE8_MEMBER( write );
8888
89   DECLARE_WRITE_LINE_MEMBER( rxc_w );
90   DECLARE_WRITE_LINE_MEMBER( txc_w );
91
9289   DECLARE_WRITE_LINE_MEMBER( dsr_w );
9390   DECLARE_WRITE_LINE_MEMBER( dcd_w );
9491   DECLARE_WRITE_LINE_MEMBER( cts_w );
r26273r26274
10198   virtual void device_config_complete();
10299   virtual void device_start();
103100   virtual void device_reset();
101   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
104102
105103   // device_serial_interface overrides
106104   virtual void tra_callback();
trunk/src/emu/machine/z80sti.c
r26273r26274
742742
743743WRITE_LINE_MEMBER( z80sti_device::rc_w )
744744{
745   rcv_clock();
745   rx_clock_w(state);
746746}
747747
748748
r26273r26274
752752
753753WRITE_LINE_MEMBER( z80sti_device::tc_w )
754754{
755   tra_clock();
755   tx_clock_w(state);
756756}
trunk/src/emu/machine/z80dart.c
r26273r26274
240240   m_chanB->reset();
241241}
242242
243
244243//-------------------------------------------------
245244//  z80daisy_irq_state - get interrupt status
246245//-------------------------------------------------
r26273r26274
568567   }
569568}
570569
570void z80dart_channel::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
571{
572   device_serial_interface::device_timer(timer, id, param, ptr);
573}
571574
575
572576//-------------------------------------------------
573577//  tra_callback -
574578//-------------------------------------------------
r26273r26274
679683
680684   m_input_state = state;
681685
682   if (changed & SERIAL_STATE_CTS)
686   if (changed & CTS)
683687   {
684688      cts_w(state);
685689   }
r26273r26274
12211225
12221226WRITE_LINE_MEMBER( z80dart_channel::rxc_w )
12231227{
1228   //LOG(("Z80DART \"%s\" Channel %c : Receiver Clock Pulse\n", m_owner->tag(), m_index + 'A'));
12241229   int clocks = get_clock_mode();
1230   if (clocks == 1)
1231      rx_clock_w(state);
1232   else if(state)
1233   {
1234      rx_clock_w(m_rx_clock < clocks/2);
12251235
1226   if (!state) return;
1227
1228   //LOG(("Z80DART \"%s\" Channel %c : Receiver Clock Pulse\n", m_owner->tag(), m_index + 'A'));
1229
1230   if (++m_rx_clock == clocks)
1231   {
1232      m_rx_clock = 0;
1233      rcv_clock();
1236      m_rx_clock++;
1237      if (m_rx_clock == clocks)
1238         m_rx_clock = 0;
1239         
12341240   }
12351241}
12361242
r26273r26274
12411247
12421248WRITE_LINE_MEMBER( z80dart_channel::txc_w )
12431249{
1250   //LOG(("Z80DART \"%s\" Channel %c : Transmitter Clock Pulse\n", m_owner->tag(), m_index + 'A'));
12441251   int clocks = get_clock_mode();
1252   if (clocks == 1)
1253      tx_clock_w(state);
1254   else if(state)
1255   {
1256      tx_clock_w(m_tx_clock < clocks/2);
12451257
1246   if (!state) return;
1247
1248   //LOG(("Z80DART \"%s\" Channel %c : Transmitter Clock Pulse\n", m_owner->tag(), m_index + 'A'));
1249
1250   if (++m_tx_clock == clocks)
1251   {
1252      m_tx_clock = 0;
1253      tra_clock();
1258      m_tx_clock++;
1259      if (m_tx_clock == clocks)
1260         m_tx_clock = 0;
1261         
12541262   }
12551263}
12561264
r26273r26274
12751283
12761284   int num_data_bits = get_rx_word_length();
12771285   int stop_bit_count = get_stop_bits();
1278   int parity_code = SERIAL_PARITY_NONE;
1286   int parity_code = PARITY_NONE;
12791287
12801288   if (m_wr[1] & WR4_PARITY_ENABLE)
12811289   {
12821290      if (m_wr[1] & WR4_PARITY_EVEN)
1283         parity_code = SERIAL_PARITY_EVEN;
1291         parity_code = PARITY_EVEN;
12841292      else
1285         parity_code = SERIAL_PARITY_ODD;
1293         parity_code = PARITY_ODD;
12861294   }
12871295
1288   set_data_frame(num_data_bits, stop_bit_count, parity_code);
1296   set_data_frame(num_data_bits, stop_bit_count, parity_code, false);
12891297}
12901298
12911299
r26273r26274
13001308   m_out_dtr_func(m_dtr);
13011309
13021310   if (state)
1303      m_connection_state &= ~SERIAL_STATE_DTR;
1311      m_connection_state &= ~DTR;
13041312   else
1305      m_connection_state |= SERIAL_STATE_DTR;
1313      m_connection_state |= DTR;
13061314
13071315   serial_connection_out();
13081316}
r26273r26274
13171325   m_out_rts_func(state);
13181326
13191327   if (state)
1320      m_connection_state &= ~SERIAL_STATE_RTS;
1328      m_connection_state &= ~RTS;
13211329   else
1322      m_connection_state |= SERIAL_STATE_RTS;
1330      m_connection_state |= RTS;
13231331
13241332   serial_connection_out();
13251333}
trunk/src/emu/machine/z80dart.h
r26273r26274
255255   // device-level overrides
256256   virtual void device_start();
257257   virtual void device_reset();
258   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
258259
259260   // device_serial_interface overrides
260261   virtual void tra_callback();
trunk/src/emu/machine/mos6551.c
r26273r26274
114114}
115115
116116
117void mos6551_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
118{
119   device_serial_interface::device_timer(timer, id, param, ptr);
120}
121
122
117123//-------------------------------------------------
118124//  tra_callback -
119125//-------------------------------------------------
r26273r26274
223229
224230      int num_data_bits = 8;
225231      int stop_bit_count = 1;
226      int parity_code = SERIAL_PARITY_NONE;
232      int parity_code = PARITY_NONE;
227233
228234      switch (m_ctrl & CTRL_WL_MASK)
229235      {
r26273r26274
233239      case CTRL_WL_5: num_data_bits = 5; break;
234240      }
235241
236      set_data_frame(num_data_bits, stop_bit_count, parity_code);
242      set_data_frame(num_data_bits, stop_bit_count, parity_code, false);
237243   }
238244
239245   if (m_cmd & CMD_DTR)
240      m_connection_state |= SERIAL_STATE_DTR;
246      m_connection_state |= DTR;
241247   else
242      m_connection_state &= ~SERIAL_STATE_DTR;
248      m_connection_state &= ~DTR;
243249
244   m_write_dtr((m_connection_state & SERIAL_STATE_DTR) ? 0 : 1);
250   m_write_dtr((m_connection_state & DTR) ? 0 : 1);
245251
246252   if ((m_cmd & CMD_TC_MASK) == CMD_TC_RTS_HI)
247      m_connection_state &= ~SERIAL_STATE_RTS;
253      m_connection_state &= ~RTS;
248254   else
249      m_connection_state |= SERIAL_STATE_RTS;
255      m_connection_state |= RTS;
250256
251   m_write_rts((m_connection_state & SERIAL_STATE_RTS) ? 0 : 1);
257   m_write_rts((m_connection_state & RTS) ? 0 : 1);
252258
253259   serial_connection_out();
254260}
r26273r26274
366372
367373WRITE_LINE_MEMBER( mos6551_device::rxc_w )
368374{
369   rcv_clock();
370   tra_clock();
375   rx_clock_w(state);
376   tx_clock_w(state);
371377}
372378
373379
trunk/src/emu/machine/mos6551.h
r26273r26274
9090   // device-level overrides
9191   virtual void device_start();
9292   virtual void device_reset();
93   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
9394
9495   // device_serial_interface overrides
9596   virtual void tra_callback();
trunk/src/emu/machine/n68681.c
r26273r26274
533533   CSR = 0;
534534}
535535
536void duart68681_channel::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
537{
538   device_serial_interface::device_timer(timer, id, param, ptr);
539}
540
536541// serial device virtual overrides
537542void duart68681_channel::rcv_complete()
538543{
r26273r26274
810815      case 0: // with parity
811816         if (MR1 & 4)
812817         {
813            parity = SERIAL_PARITY_ODD;
818            parity = PARITY_ODD;
814819         }
815820         else
816821         {
817            parity = SERIAL_PARITY_EVEN;
822            parity = PARITY_EVEN;
818823         }
819824         break;
820825
821826      case 1: // force parity
822827         if (MR1 & 4)
823828         {
824            parity = SERIAL_PARITY_MARK;
829            parity = PARITY_MARK;
825830         }
826831         else
827832         {
828            parity = SERIAL_PARITY_SPACE;
833            parity = PARITY_SPACE;
829834         }
830835         break;
831836
832837      case 2: // no parity
833         parity = SERIAL_PARITY_NONE;
838         parity = PARITY_NONE;
834839         break;
835840
836841      case 3: // multidrop mode
r26273r26274
840845
841846   //printf("ch %d MR1 %02x MR2 %02x => %d bits / char, %d stop bits, parity %d\n", m_ch, MR1, MR2, (MR1 & 3)+5, stopbits, parity);
842847
843   set_data_frame((MR1 & 3)+5, stopbits, parity);
848   set_data_frame((MR1 & 3)+5, stopbits, parity, false);
844849}
845850
846851void duart68681_channel::write_CR(UINT8 data)
trunk/src/emu/machine/n68681.h
r26273r26274
4141   // device-level overrides
4242   virtual void device_start();
4343   virtual void device_reset();
44   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
4445
4546   // device_serial overrides
4647   virtual void rcv_complete();    // Rx completed receiving byte
trunk/src/emu/machine/im6402.c
r26273r26274
182182   set_tre(ASSERT_LINE);
183183}
184184
185void im6402_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
186{
187   device_serial_interface::device_timer(timer, id, param, ptr);
188}
185189
186190//-------------------------------------------------
187191//  tra_callback -
r26273r26274
255259{
256260   m_input_state = state;
257261
258   rcv_clock(); // HACK for Wang PC keyboard
262   rx_clock_w(1); // HACK for Wang PC keyboard
263   rx_clock_w(0);
259264}
260265
261266
r26273r26274
293298{
294299   if (state)
295300   {
296      m_rrc_count++;
297
298      if (m_rrc_count == 16)
299      {
300         rcv_clock();
301         m_rrc_count = 0;
302      }
301      rx_clock_w(m_rrc_count < 8);
302      m_rrc_count = (m_rrc_count + 1) & 15;
303303   }
304304}
305305
r26273r26274
312312{
313313   if (state)
314314   {
315      m_trc_count++;
316
317      if (m_trc_count == 16)
318      {
319         tra_clock();
320         m_trc_count = 0;
321      }
315      tx_clock_w(m_trc_count < 8);
316      m_trc_count = (m_trc_count + 1) & 15;
322317   }
323318}
324319
r26273r26274
381376      float stop_bits = 1 + (m_sbs ? ((word_length == 5) ? 0.5 : 1) : 0);
382377      int parity_code;
383378
384      if (m_pi) parity_code = SERIAL_PARITY_NONE;
385      else if (m_epe) parity_code = SERIAL_PARITY_EVEN;
386      else parity_code = SERIAL_PARITY_ODD;
379      if (m_pi) parity_code = PARITY_NONE;
380      else if (m_epe) parity_code = PARITY_EVEN;
381      else parity_code = PARITY_ODD;
387382
388      set_data_frame(word_length, stop_bits, parity_code);
383      set_data_frame(word_length, stop_bits, parity_code, false);
389384   }
390385}
391386
trunk/src/emu/machine/im6402.h
r26273r26274
119119   virtual void device_config_complete();
120120   virtual void device_start();
121121   virtual void device_reset();
122   void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
122123
123124   // device_serial_interface overrides
124125   virtual void tra_callback();
trunk/src/emu/machine/ins8250.c
r26273r26274
242242         switch ((m_regs.lcr>>3) & 7)
243243         {
244244         case 1:
245            tmp = SERIAL_PARITY_ODD;
245            tmp = PARITY_ODD;
246246            break;
247247         case 3:
248            tmp = SERIAL_PARITY_EVEN;
248            tmp = PARITY_EVEN;
249249            break;
250250         case 5:
251            tmp = SERIAL_PARITY_MARK;
251            tmp = PARITY_MARK;
252252            break;
253253         case 7:
254            tmp = SERIAL_PARITY_SPACE;
254            tmp = PARITY_SPACE;
255255            break;
256256         default:
257            tmp = SERIAL_PARITY_NONE;
257            tmp = PARITY_NONE;
258258            break;
259259         }
260260         // if 5 data bits and stb = 1, stop bits is supposed to be 1.5
261         set_data_frame((m_regs.lcr & 3) + 5, (m_regs.lcr & 4)?2:1, tmp);
261         set_data_frame((m_regs.lcr & 3) + 5, (m_regs.lcr & 4)?2:1, tmp, false);
262262         break;
263263      case 4:
264264         if ( ( m_regs.mcr & 0x1f ) != ( data & 0x1f ) )
r26273r26274
539539   }
540540}
541541
542void ns16550_device::device_start()
543{
544   m_timeout = timer_alloc();
545   ins8250_uart_device::device_start();
546}
547
542548void ns16550_device::device_reset()
543549{
544550   memset(&m_rfifo, '\0', sizeof(m_rfifo));
r26273r26274
551557
552558void ns16550_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
553559{
554   trigger_int(COM_INT_PENDING_CHAR_TIMEOUT);
555   m_timeout->adjust(attotime::never);
560   if(id)
561      device_serial_interface::device_timer(timer, id, param, ptr);
562   else
563   {
564      trigger_int(COM_INT_PENDING_CHAR_TIMEOUT);
565      m_timeout->adjust(attotime::never);
566   }
556567}
557568
558569void ns16550_device::push_tx(UINT8 data)
trunk/src/emu/machine/ins8250.h
r26273r26274
104104public:
105105   ns16550_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
106106protected:
107   virtual void device_start() { m_timeout = timer_alloc(); ins8250_uart_device::device_start(); }
107   virtual void device_start();
108108   virtual void device_reset();
109109   virtual void rcv_complete();
110110   virtual void tra_complete();
trunk/src/emu/diserial.c
r26273r26274
4040   }
4141   m_rcv_clock = NULL;
4242   m_tra_clock = NULL;
43   m_rcv_clock_state = false;
44   m_tra_clock_state = false;
4345   m_tra_rate = attotime::never;
4446   m_rcv_rate = attotime::never;
4547   m_tra_flags = 0;
r26273r26274
5456{
5557}
5658
57//-------------------------------------------------
58//  interface_pre_start - work to be done prior to
59//  actually starting a device
60//-------------------------------------------------
61
6259void device_serial_interface::interface_pre_start()
6360{
64   m_rcv_clock = device().machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(device_serial_interface::rcv_timer), this));
65   m_tra_clock = device().machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(device_serial_interface::tra_timer), this));
61   m_rcv_clock = device().timer_alloc(RCV_TIMER_ID);
62   m_tra_clock = device().timer_alloc(TRA_TIMER_ID);
63   m_rcv_clock_state = false;
64   m_tra_clock_state = false;
6665}
6766
6867void device_serial_interface::set_rcv_rate(attotime rate)
r26273r26274
7978   m_tra_clock->adjust(attotime::never);
8079}
8180
82void device_serial_interface::tra_clock()
81void device_serial_interface::tra_edge()
8382{
8483   tra_callback();
8584   if(is_transmit_register_empty())
r26273r26274
8988   }
9089}
9190
92void device_serial_interface::tra_timer(void *ptr, int param)
91void device_serial_interface::rcv_edge()
9392{
94   tra_clock();
95}
96
97void device_serial_interface::rcv_clock()
98{
9993   rcv_callback();
10094   if(is_receive_register_full())
10195   {
r26273r26274
10498   }
10599}
106100
107void device_serial_interface::rcv_timer(void *ptr, int param)
101WRITE_LINE_MEMBER(device_serial_interface::tx_clock_w)
108102{
109   rcv_clock();
103   if(state != m_tra_clock_state) {
104      m_tra_clock_state = state;
105      if(m_tra_clock_state)
106         tra_edge();
107   }
110108}
111109
112void device_serial_interface::set_data_frame(int num_data_bits, int stop_bit_count, int parity_code)
110WRITE_LINE_MEMBER(device_serial_interface::rx_clock_w)
113111{
112   if(state != m_rcv_clock_state) {
113      m_rcv_clock_state = state;
114      if(!m_rcv_clock_state)
115         rcv_edge();
116   }
117}
118
119WRITE_LINE_MEMBER(device_serial_interface::clock_w)
120{
121   tx_clock_w(state);
122   rx_clock_w(state);
123}
124
125void device_serial_interface::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
126{
127   switch(id) {
128   case TRA_TIMER_ID: tx_clock_w(!m_tra_clock_state); break;
129   case RCV_TIMER_ID: rx_clock_w(!m_rcv_clock_state); break;
130   }
131}
132
133
134void device_serial_interface::set_data_frame(int num_data_bits, int stop_bit_count, int parity_code, bool synchronous)
135{
114136   m_df_word_length = num_data_bits;
115137   m_df_stop_bit_count = stop_bit_count;
116138   m_df_parity = parity_code;
139   m_synchronous = synchronous;
117140
118141   m_rcv_bit_count = m_df_word_length + m_df_stop_bit_count;
119142
120   if (m_df_parity != SERIAL_PARITY_NONE)
143   if (m_df_parity != PARITY_NONE)
121144   {
122145      m_rcv_bit_count++;
123146   }
r26273r26274
127150{
128151   m_rcv_bit_count_received = 0;
129152   m_rcv_flags &=~RECEIVE_REGISTER_FULL;
130   m_rcv_flags &=~RECEIVE_REGISTER_SYNCHRONISED;
131   m_rcv_flags |= RECEIVE_REGISTER_WAITING_FOR_START_BIT;
153   if (m_synchronous)
154   {
155      m_rcv_flags |= RECEIVE_REGISTER_SYNCHRONISED;
156      m_rcv_flags &=~RECEIVE_REGISTER_WAITING_FOR_START_BIT;
157   }
158   else
159   {
160      m_rcv_flags &=~RECEIVE_REGISTER_SYNCHRONISED;
161      m_rcv_flags |= RECEIVE_REGISTER_WAITING_FOR_START_BIT;
162   }
132163}
133164
134165WRITE_LINE_MEMBER(device_serial_interface::rx_w)
r26273r26274
165196   /* update bit count received */
166197   m_rcv_bit_count_received++;
167198
168   /* asyncrhonouse mode */
199   /* asynchronous mode */
169200   if (m_rcv_flags & RECEIVE_REGISTER_WAITING_FOR_START_BIT)
170201   {
171202      /* the previous bit is stored in uart.receive char bit 0 */
r26273r26274
216247
217248   m_rcv_byte_received  = data;
218249
219   if(m_df_parity == SERIAL_PARITY_NONE)
250   if(m_df_parity == PARITY_NONE)
220251      return;
221252
222253   //unsigned char computed_parity;
r26273r26274
229260   switch (m_df_parity)
230261   {
231262      /* check parity */
232      case SERIAL_PARITY_ODD:
233      case SERIAL_PARITY_EVEN:
263      case PARITY_ODD:
264      case PARITY_EVEN:
234265      {
235266         /* compute parity for received bits */
236267         //computed_parity = serial_helper_get_parity(data);
237268
238         if (m_df_parity == SERIAL_PARITY_ODD)
269         if (m_df_parity == PARITY_ODD)
239270         {
240271            /* odd parity */
241272
r26273r26274
250281
251282      }
252283      break;
253      case SERIAL_PARITY_MARK:
254      case SERIAL_PARITY_SPACE:
284      case PARITY_MARK:
285      case PARITY_SPACE:
255286         //computed_parity = parity_received;
256287         break;
257288   }
r26273r26274
289320   m_tra_bit_count = 0;
290321   m_tra_flags &=~TRANSMIT_REGISTER_EMPTY;
291322
292   /* start bit */
293   transmit_register_add_bit(0);
323   if (!m_synchronous)
324      /* start bit */
325      transmit_register_add_bit(0);
294326
295327   /* data bits */
296328   transmit_data = data_byte;
r26273r26274
306338   }
307339
308340   /* parity */
309   if (m_df_parity!=SERIAL_PARITY_NONE)
341   if (m_df_parity!=PARITY_NONE)
310342   {
311343      /* odd or even parity */
312344      unsigned char parity = 0;
313345      switch(m_df_parity)
314346      {
315      case SERIAL_PARITY_EVEN:
316      case SERIAL_PARITY_ODD:
347      case PARITY_EVEN:
348      case PARITY_ODD:
317349
318350         /* get parity */
319351         /* if parity = 0, data has even parity - i.e. there is an even number of one bits in the data */
320352         /* if parity = 1, data has odd parity - i.e. there is an odd number of one bits in the data */
321353         parity = serial_helper_get_parity(data_byte);
322354         break;
323      case SERIAL_PARITY_MARK:
355      case PARITY_MARK:
324356         parity = 1;
325357         break;
326      case SERIAL_PARITY_SPACE:
358      case PARITY_SPACE:
327359         parity = 0;
328360         break;
329361      }
r26273r26274
362394   UINT8 data = transmit_register_get_data_bit();
363395
364396   /* set tx data bit */
365   m_connection_state &=~SERIAL_STATE_TX_DATA;
397   m_connection_state &= ~TX;
366398   m_connection_state|=(data<<5);
367399
368400   /* state out through connection */
r26273r26274
457489{
458490}
459491
492void serial_source_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
493{
494   device_serial_interface::device_timer(timer, id, param, ptr);
495}
496
460497void serial_source_device::input_callback(UINT8 state)
461498{
462499   m_input_state = state;
trunk/src/mess/machine/isa_sblaster.c
r26273r26274
12841284   m_rx_waiting = m_tx_waiting = 0;
12851285
12861286   // MIDI is 31250 baud, 8-N-1
1287   set_rcv_rate(31250);
1288   set_tra_rate(31250);
1289   set_data_frame(8, 1, SERIAL_PARITY_NONE);
1287   set_rate(31250);
1288   set_data_frame(8, 1, PARITY_NONE, false);
12901289}
12911290
12921291UINT8 sb_device::dack_r(int line)
r26273r26274
14231422void sb_device::device_timer(emu_timer &timer, device_timer_id tid, int param, void *ptr)
14241423{
14251424//    printf("DMA timer expire\n");
1425   if (tid)
1426   {
1427      device_serial_interface::device_timer(timer, tid, param, ptr);
1428      return;
1429   }
14261430
14271431   UINT16 lsample, rsample;
14281432   switch (m_dsp.flags) {
trunk/src/mess/machine/zx8302.c
r26273r26274
270270
271271      transmit_ipc_data();
272272      break;
273
274   default:
275      device_serial_interface::device_timer(timer, id, param, ptr);
276      break;
273277   }
274278}
275279
r26273r26274
402406   m_baudx4_timer->adjust(attotime::zero, 0, attotime::from_hz(baudx4));
403407
404408   set_tra_rate(baud);
405   set_data_frame(8, 2, SERIAL_PARITY_NONE);
409   set_data_frame(8, 2, PARITY_NONE, false);
406410}
407411
408412
trunk/src/mess/machine/thomson.c
r26273r26274
686686
687687   LOG_IO(( "%s %f to7_io_porta_out: tx=%i, dtr=%i\n",  machine().describe_context(), machine().time().as_double(), tx, dtr ));
688688   if ( dtr )
689      m_connection_state |=  SERIAL_STATE_DTR;
689      m_connection_state |=  device_serial_interface::DTR;
690690   else
691      m_connection_state &= ~SERIAL_STATE_DTR;
691      m_connection_state &= ~device_serial_interface::DTR;
692692
693693   set_out_data_bit(tx);
694694   serial_connection_out();
r26273r26274
700700{
701701   centronics_device *printer = machine().device<centronics_device>("centronics");
702702   int cts = 1;
703   int dsr = ( m_input_state & SERIAL_STATE_DSR ) ? 0 : 1;
703   int dsr = ( m_input_state & device_serial_interface::DSR ) ? 0 : 1;
704704   int rd  = get_in_data_bit();
705705
706706   if ( machine().driver_data<thomson_state>()->to7_io_mode() == TO7_IO_RS232 )
707      cts = m_input_state & SERIAL_STATE_CTS ? 0 : 1;
707      cts = m_input_state & device_serial_interface::CTS ? 0 : 1;
708708   else
709709      cts = !printer->busy_r();
710710
r26273r26274
738738{
739739   m_input_state = state;
740740
741   LOG_IO(( "%f to7_io_in_callback:  cts=%i dsr=%i rd=%i\n", machine().time().as_double(), (state & SERIAL_STATE_CTS) ? 1 : 0, (state & SERIAL_STATE_DSR) ? 1 : 0, (int)get_in_data_bit() ));
741   LOG_IO(( "%f to7_io_in_callback:  cts=%i dsr=%i rd=%i\n", machine().time().as_double(), (state & device_serial_interface::CTS) ? 1 : 0, (state & device_serial_interface::DSR) ? 1 : 0, (int)get_in_data_bit() ));
742742}
743743
744744
r26273r26274
775775   LOG (( "to7_io_reset called\n" ));
776776
777777   if (io_pia) io_pia->set_port_a_z_mask(0x03 );
778   m_input_state = SERIAL_STATE_CTS;
779   m_connection_state &= ~SERIAL_STATE_DTR;
780   m_connection_state |=  SERIAL_STATE_RTS;  /* always ready to send */
778   m_input_state = device_serial_interface::CTS;
779   m_connection_state &= ~device_serial_interface::DTR;
780   m_connection_state |=  device_serial_interface::RTS;  /* always ready to send */
781781   set_out_data_bit(1);
782782   serial_connection_out();
783783}
trunk/src/mess/machine/keyboard.c
r26273r26274
436436   m_slot = m_owner && 1;
437437   m_timer = timer_alloc();
438438   set_tra_rate(baud);
439   set_data_frame(8, 1, SERIAL_PARITY_NONE);
439   set_data_frame(8, 1, PARITY_NONE, false);
440440}
441441
442442INPUT_CHANGED_MEMBER(serial_keyboard_device::update_frame)
r26273r26274
459459   switch(val & 0x30)
460460   {
461461   case 0x10:
462      set_data_frame(7, 1, SERIAL_PARITY_EVEN);
462      set_data_frame(7, 1, PARITY_EVEN, false);
463463      break;
464464   case 0x00:
465465   default:
466      set_data_frame(8, 1, SERIAL_PARITY_NONE);
466      set_data_frame(8, 1, PARITY_NONE, false);
467467      break;
468468   case 0x20:
469      set_data_frame(8, 2, SERIAL_PARITY_NONE);
469      set_data_frame(8, 2, PARITY_NONE, false);
470470      break;
471471   case 0x30:
472      set_data_frame(8, 1, SERIAL_PARITY_EVEN);
472      set_data_frame(8, 1, PARITY_EVEN, false);
473473      break;
474474   }
475475}
476476
477void serial_keyboard_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
478{
479   if (id)
480      device_serial_interface::device_timer(timer, id, param, ptr);
481   else
482      generic_keyboard_device::device_timer(timer, id, param, ptr);
483}
484
477485void serial_keyboard_device::send_key(UINT8 code)
478486{
479487   if(is_transmit_register_empty())
trunk/src/mess/machine/keyboard.h
r26273r26274
9494   virtual void device_start();
9595   virtual void device_config_complete();
9696   virtual void device_reset();
97   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
9798   virtual void tra_callback();
9899   virtual void tra_complete();
99100   virtual void input_callback(UINT8 state) { m_input_state = state; }
trunk/src/mess/machine/ser_mouse.c
r26273r26274
7272 **************************************************************************/
7373void serial_mouse_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
7474{
75   if (id)
76   {
77      device_serial_interface::device_timer(timer, id, param, ptr);
78      return;
79   }
80
7581   static int ox = 0, oy = 0;
7682   int nx,ny;
7783   int dx, dy, nb;
trunk/src/mess/machine/ser_mouse.h
r26273r26274
5252   virtual void dtr_w(UINT8 state) { m_dtr = state; check_state(); }
5353   virtual void rts_w(UINT8 state) { m_rts = state; check_state(); m_old_rts = state; }
5454protected:
55   virtual void set_frame() { set_data_frame(7, 2, SERIAL_PARITY_NONE); }
55   virtual void set_frame() { set_data_frame(7, 2, PARITY_NONE, false); }
5656   virtual void mouse_trans(int dx, int dy, int nb, int mbc);
5757   virtual void device_reset() {m_old_rts = 0; serial_mouse_device::device_reset();}
5858private:
r26273r26274
6868   virtual void dtr_w(UINT8 state) { m_dtr = state; check_state(); }
6969   virtual void rts_w(UINT8 state) { m_rts = state; check_state(); }
7070protected:
71   virtual void set_frame() { set_data_frame(8, 2, SERIAL_PARITY_NONE); }
71   virtual void set_frame() { set_data_frame(8, 2, PARITY_NONE, false); }
7272   virtual void mouse_trans(int dx, int dy, int nb, int mbc);
7373private:
7474   void check_state() { set_mouse_enable((m_dtr && m_rts)?true:false); }
trunk/src/mess/machine/esqpanel.c
r26273r26274
6666   // panel comms is at 62500 baud (double the MIDI rate), 8N2
6767   set_rcv_rate(62500);
6868   set_tra_rate(62500);
69   set_data_frame(8, 2, SERIAL_PARITY_NONE);
69   set_data_frame(8, 2, PARITY_NONE, false);
7070
7171   m_tx_busy = false;
7272   m_xmit_read = m_xmit_write = 0;
r26273r26274
7474   m_bButtonLightSecondByte = false;
7575}
7676
77void esqpanel_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
78{
79   device_serial_interface::device_timer(timer, id, param, ptr);
80}
81
7782void esqpanel_device::rcv_complete()    // Rx completed receiving byte
7883{
7984   receive_register_extract();
trunk/src/mess/machine/esqpanel.h
r26273r26274
7171   virtual void device_start();
7272   virtual void device_reset();
7373   virtual void device_config_complete();
74   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
7475
7576   // serial overrides
7677   virtual void rcv_complete();    // Rx completed receiving byte
trunk/src/mess/machine/wangpckb.c
r26273r26274
417417   // set serial callbacks
418418   m_maincpu->i8051_set_serial_tx_callback(WRITE8_DELEGATE(wangpc_keyboard_device, mcs51_tx_callback));
419419   m_maincpu->i8051_set_serial_rx_callback(READ8_DELEGATE(wangpc_keyboard_device, mcs51_rx_callback));
420   set_data_frame(8, 2, SERIAL_PARITY_NONE);
420   set_data_frame(8, 2, PARITY_NONE, false);
421421}
422422
423423
r26273r26274
441441
442442void wangpc_keyboard_device::input_callback(UINT8 state)
443443{
444   int bit = (state & SERIAL_STATE_RX_DATA) ? 1 : 0;
444   int bit = (state & RX) ? 1 : 0;
445445
446446   receive_register_update_bit(bit);
447447
trunk/src/mess/machine/terminal.c
r26273r26274
481481   m_timer = timer_alloc();
482482   set_rcv_rate(baud);
483483   set_tra_rate(baud);
484   set_data_frame(8, 1, SERIAL_PARITY_NONE);
484   set_data_frame(8, 1, PARITY_NONE, false);
485485}
486486
487487INPUT_CHANGED_MEMBER(serial_terminal_device::update_frame)
r26273r26274
505505   switch(val & 0x30)
506506   {
507507   case 0x10:
508      set_data_frame(7, 1, SERIAL_PARITY_EVEN);
508      set_data_frame(7, 1, PARITY_EVEN, false);
509509      break;
510510   case 0x00:
511511   default:
512      set_data_frame(8, 1, SERIAL_PARITY_NONE);
512      set_data_frame(8, 1, PARITY_NONE, false);
513513      break;
514514   case 0x20:
515      set_data_frame(8, 2, SERIAL_PARITY_NONE);
515      set_data_frame(8, 2, PARITY_NONE, false);
516516      break;
517517   case 0x30:
518      set_data_frame(8, 1, SERIAL_PARITY_EVEN);
518      set_data_frame(8, 1, PARITY_EVEN, false);
519519      break;
520520   }
521521}
trunk/src/mess/drivers/rainbow.c
r26273r26274
428428   m_z80_halted = true;
429429   m_kbd_tx_ready = m_kbd_rx_ready = false;
430430
431   m_kbd8251->input_callback(SERIAL_STATE_CTS); // raise clear to send
431   m_kbd8251->input_callback(device_serial_interface::CTS); // raise clear to send
432432
433433   m_KBD = 0;
434434
trunk/src/mess/drivers/atarist.c
r26273r26274
19551955
19561956WRITE_LINE_MEMBER( st_state::mfp_tdo_w )
19571957{
1958   m_mfp->rc_w(state);
1959   m_mfp->tc_w(state);
1958   m_mfp->clock_w(state);
19601959}
19611960
19621961static MC68901_INTERFACE( mfp_intf )
trunk/src/mess/drivers/thomson.c
r26273r26274
604604
605605const serial_image_interface to7_cc90232_config =
606606{
607   2400, 7, 2, SERIAL_PARITY_NONE, 1, "to7_io"
607   2400, 7, 2, device_serial_interface::PARITY_NONE, 1, "to7_io"
608608};
609609
610610const serial_image_interface to7_rf57932_config =
611611{
612   2400, 7, 2, SERIAL_PARITY_NONE, 1, "acia"
612   2400, 7, 2, device_serial_interface::PARITY_NONE, 1, "acia"
613613};
614614
615615const serial_image_interface to7_modem_config =
616616{
617   2400, 7, 2, SERIAL_PARITY_NONE, 1, NULL
617   2400, 7, 2, device_serial_interface::PARITY_NONE, 1, NULL
618618};
619619
620620/* ------------ driver ------------ */
trunk/src/mess/drivers/x68k.c
r26273r26274
20512051
20522052WRITE_LINE_MEMBER( x68k_state::mfp_tdo_w )
20532053{
2054   m_mfpdev->tc_w(state);
2055   m_mfpdev->rc_w(state);
2054   m_mfpdev->clock_w(state);
20562055}
20572056
20582057static MC68901_INTERFACE( mfp_interface )
trunk/src/mess/drivers/pc.c
r26273r26274
13781378
13791379static const serial_image_interface mc1502_serial =
13801380{
1381   9600, 8, 1, SERIAL_PARITY_NONE, 1, "upd8251"
1381   9600, 8, 1, device_serial_interface::PARITY_NONE, 1, "upd8251"
13821382};
13831383
13841384static MACHINE_CONFIG_START( ibmpcjr, tandy_pc_state )

Previous 199869 Revisions Next


© 1997-2024 The MAME Team